Skip to content

Commit

Permalink
code cleanup update
Browse files Browse the repository at this point in the history
  • Loading branch information
detain committed Jun 24, 2017
1 parent 83ff1f9 commit 5fd32c5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bin/activate_fantastico.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/php
<?php

require_once(__DIR__ . '/../../../include/functions.inc.php');
require_once(__DIR__.'/../../../include/functions.inc.php');
$GLOBALS['tf']->session->create(160308, 'services');
$GLOBALS['tf']->session->verify();

Expand Down
2 changes: 1 addition & 1 deletion bin/fantastico_licenses.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/php
<?php

require_once(__DIR__ . '/../../../include/functions.inc.php');
require_once(__DIR__.'/../../../include/functions.inc.php');

print_r(get_fantastico_licenses());

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function getSettings(GenericEvent $event) {
$settings = $event->getSubject();
$settings->add_text_setting(self::$module, 'Fantastico', 'fantastico_username', 'Fantastico Username:', 'Fantastico Username', $settings->get_setting('FANTASTICO_USERNAME'));
$settings->add_text_setting(self::$module, 'Fantastico', 'fantastico_password', 'Fantastico Password:', 'Fantastico Password', $settings->get_setting('FANTASTICO_PASSWORD'));
$settings->add_dropdown_setting(self::$module, 'Fantastico', 'outofstock_licenses_fantastico', 'Out Of Stock Fantastico Licenses', 'Enable/Disable Sales Of This Type', $settings->get_setting('OUTOFSTOCK_LICENSES_FANTASTICO'), array('0', '1'), array('No', 'Yes', ));
$settings->add_dropdown_setting(self::$module, 'Fantastico', 'outofstock_licenses_fantastico', 'Out Of Stock Fantastico Licenses', 'Enable/Disable Sales Of This Type', $settings->get_setting('OUTOFSTOCK_LICENSES_FANTASTICO'), array('0', '1'), array('No', 'Yes',));
}

}
14 changes: 7 additions & 7 deletions src/fantastico.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* get_fantastico_licenses()
* simple wrapper to get all the fantastico licenses.
*
* @return false|array array of licenses. {@link Fantastico.getIpListDetailed}
* @return FALSE|array array of licenses. {@link Fantastico.getIpListDetailed}
*/
function get_fantastico_licenses() {
$fantastico = new Fantastico(FANTASTICO_USERNAME, FANTASTICO_PASSWORD);
$fantasticoIps = $fantastico->getIpListDetailed(Fantastico::ALL_TYPES);
request_log('licenses', false, __FUNCTION__, 'fantastico', 'getIpListDetailed', 'Fantastico::ALL_TYPES', $fantasticoIps);
request_log('licenses', FALSE, __FUNCTION__, 'fantastico', 'getIpListDetailed', 'Fantastico::ALL_TYPES', $fantasticoIps);
return $fantasticoIps;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ function get_available_fantastico($type) {
$fantastico = new Fantastico(FANTASTICO_USERNAME, FANTASTICO_PASSWORD);
$ips = $fantastico->getIpList(Fantastico::ALL_TYPES);
$db->query("select * from {$settings['TABLE']} left join services on {$settings['PREFIX']}_type=services_id where services_module='licenses' and services_category=".SERVICE_TYPES_FANTASTICO." and {$settings['PREFIX']}_status in ('canceled','expired')");
$found = false;
$found = FALSE;
// go through all canceled/expired ips
while ($db->next_record(MYSQL_ASSOC)) {
// check if ip is still licensed
Expand Down Expand Up @@ -148,24 +148,24 @@ function activate_fantastico($ipAddress, $type) {
if ($result['isVPS'] == 'No') {
$result = $fantastico->editIp($db->Record['license_ip'], $ipAddress);
myadmin_log('licenses', 'info', "Fantastico Re-Using IP {$db->Record['license_ip']} Type $type As $ipAddress result: ".myadmin_stringify($result, 'json'), __LINE__, __FILE__);
return true;
return TRUE;
}
} else {
if ($result['isVPS'] == 'Yes') {
$result = $fantastico->editIp($db->Record['license_ip'], $ipAddress);
myadmin_log('licenses', 'info', "Fantastico Re-Using IP {$db->Record['license_ip']} Type $type As $ipAddress result: ".myadmin_stringify($result, 'json'), __LINE__, __FILE__);
return true;
return TRUE;
}
}
}
}
$result = $fantastico->addIp($ipAddress, $type);
if (isset($result['faultcode'])) {
myadmin_log('licenses', 'error', 'Fantastico addIp($ipAddress, $type) returned Fault '.$result['faultcode'].': '.$result['fault'], __LINE__, __FILE__);
return false;
return FALSE;
}
myadmin_log('licenses', 'info', "Fantastico New License $ipAddress Type $type Licensed ID {$result['id']}", __LINE__, __FILE__);
return true;
return TRUE;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/fantastico_licenses_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ function fantastico_licenses_list() {
if ($GLOBALS['tf']->ima == 'admin') {
$table = new TFTable;
$table->set_title('Fantastico License List');
$header = false;
$header = FALSE;
$licenses = get_fantastico_licenses();
foreach ($licenses as $lid => $data) {
if (!$header) {
foreach (array_keys($data) as $field) {
$table->add_field(ucwords(str_replace('_', ' ', $field)));
}
$table->add_row();
$header = true;
$header = TRUE;
}
foreach ($data as $key => $field) {
$table->add_field($field);
Expand Down
4 changes: 2 additions & 2 deletions src/reusable_fantastico.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function reusable_fantastico() {
page_title('ReUsable Fantastico Licenses');
if ($GLOBALS['tf']->ima == 'admin') {
$module = 'licenses';
$serviceTypes = run_event('get_service_types', false, $module);
$serviceTypes = run_event('get_service_types', FALSE, $module);
$db = get_module_db($module);
$settings = get_module_settings($module);
$fantastico = new Fantastico(FANTASTICO_USERNAME, FANTASTICO_PASSWORD);
Expand All @@ -37,7 +37,7 @@ function reusable_fantastico() {
$type = 5003;
$serviceCost = $serviceTypes[$type]['services_cost'];
$db->query(make_insert_query($settings['TABLE'], array(
$settings['PREFIX'].'_id' => null,
$settings['PREFIX'].'_id' => NULL,
$settings['PREFIX'].'_type' => $type,
$settings['PREFIX'].'_custid' => 8,
$settings['PREFIX'].'_cost' => $serviceCost,
Expand Down

0 comments on commit 5fd32c5

Please sign in to comment.