Skip to content

Commit ba916fd

Browse files
committed
updates improving plugin
1 parent 214ec81 commit ba916fd

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

src/Plugin.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,35 @@ function_requirements('class.Addon');
3737
$service->add_addon($addon);
3838
}
3939

40-
public static function doEnable(\Service_Order $serviceOrder) {
40+
public static function doEnable(\Service_Order $serviceOrder, $repeat_invoice_id, $regex_match = false) {
4141
$serviceInfo = $serviceOrder->getServiceInfo();
4242
$settings = get_module_settings($serviceOrder->getModule());
43+
if ($regex_match === false) {
44+
$db = get_module_db(self::$module);
45+
$ip = website_get_next_ip($serviceInfo[$settings['PREFIX'].'_server']);
46+
myadmin_log(self::$module, 'info', 'Trying To Give '.$settings['TTILE'].' '.$serviceInfo[$settings['PREFIX'] . '_id'].' Repeat Invoice '.$repeat_invoice_id.' IP ' . ($ip === false ? '<ip allocation failed>' : $ip), __LINE__, __FILE__);
47+
if ($ip) {
48+
$GLOBALS['tf']->history->add(self::$module . 'queue', $serviceInfo[$settings['PREFIX'] . '_id'], 'add_ip', $ip, $serviceInfo[$settings['PREFIX'] . '_custid']);
49+
$description = 'Additional IP ' . $ip . ' for ' . $settings['TBLNAME'] . ' ' . $serviceInfo[$settings['PREFIX'] . '_id'];
50+
$rdescription = '(Repeat Invoice: ' . $repeat_invoice_id . ') ' . $description;
51+
$db->query("update {$settings['PREFIX']}_ips set ips_main=0,ips_used=1,ips_{$settings['PREFIX']}={$serviceInfo[$settings['PREFIX'].'_id']} where ips_ip='{$ip}'", __LINE__, __FILE__);
52+
$db->query("update invoices set invoices_description='{$rdescription}' where invoices_type=1 and invoices_extra='{$repeat_invoice_id}'", __LINE__, __FILE__);
53+
$db->query("update repeat_invoices set repeat_invoices_description='{$description}' where repeat_invoices_id='{$repeat_invoice_id}'", __LINE__, __FILE__);
54+
} else {
55+
$db->query('SELECT * FROM ' . $settings['PREFIX'] . '_masters WHERE ' . $settings['PREFIX'] . '_id=' . $serviceInfo[$settings['PREFIX'] . '_server'], __LINE__, __FILE__);
56+
$db->next_record(MYSQL_ASSOC);
57+
$headers = '';
58+
$headers .= 'MIME-Version: 1.0' . EMAIL_NEWLINE;
59+
$headers .= 'Content-type: text/html; charset=UTF-8' . EMAIL_NEWLINE;
60+
$headers .= 'From: ' . TITLE . ' <' . EMAIL_FROM . '>' . EMAIL_NEWLINE;
61+
$subject = '0 Free IPs On ' . $settings['TBLNAME'] . ' Server ' . $db->Record[$settings['PREFIX'] . '_name'];
62+
admin_mail($subject, $settings['TBLNAME'] . " {$serviceInfo[$settings['PREFIX'].'_id']} Has Pending IPS<br>\n" . $subject, $headers, false, 'admin_email_vps_no_ips.tpl');
63+
}
64+
} else {
65+
$ip = $regex_match;
66+
$GLOBALS['tf']->history->add(self::$module . 'queue', $serviceInfo[$settings['PREFIX'] . '_id'], 'ensure_addon_ip', $ip, $serviceInfo[$settings['PREFIX'] . '_custid']);
67+
$db->query("update {$settings['PREFIX']}_ips set ips_main=0,ips_used=1,ips_{$settings['PREFIX']}={$id} where ips_ip='{$ip}'", __LINE__, __FILE__);
68+
}
4369
}
4470

4571
public static function doDisable(\Service_Order $serviceOrder) {

0 commit comments

Comments
 (0)