From e8509575a552df36ecb9f2908bccb2aaf691bd8d Mon Sep 17 00:00:00 2001 From: Siby P Varkey Date: Sun, 15 Jul 2018 17:17:58 +0530 Subject: [PATCH] Bug Fix; Auto expiry of account script + Bug fixes related to automatic expiry of accounts scripting and such. Type changes of fields in creating vouchers forms etc --- ajax_add_profile.php | 16 ++++++- ajax_adduser.php | 8 +++- ajax_addusers.php | 20 ++++++--- ajax_edit_profile.php | 9 ++-- config.php | 2 +- header.php | 2 +- home.php | 100 ++++++++++++++++++++++++++--------------- index.php | 12 ++--- modal_get_profiles.php | 25 +++++++++-- voucher.php | 4 +- 10 files changed, 135 insertions(+), 63 deletions(-) diff --git a/ajax_add_profile.php b/ajax_add_profile.php index 60f3c13..7c2bb2c 100644 --- a/ajax_add_profile.php +++ b/ajax_add_profile.php @@ -22,9 +22,11 @@ if ($_SESSION['user_level'] == 1) { $lock_user = $_GET['lock_user']; $rate_limit = $rx_rate_limit.'/'.$tx_rate_limit; + /* if (empty($session_timeout)) $session_timeout = '3d 00:00:00'; if (empty($mac_cookie_timeout)) $mac_cookie_timeout = '3d 00:00:00'; - if (empty($keepalive_timeout)) $keepalive_timeout = '00:02:00'; + if (empty($keepalive_timeout)) $keepalive_timeout = '00:02:00'; + */ if ($price == "") {$price = "0";} if($lock_user == Enable){$mac_bind = ';[:local mac $"mac-address"; /ip hotspot user set mac-address=$mac [find where name=$user]]';} else {$mac_bind = "";} @@ -57,6 +59,16 @@ if ($_SESSION['user_level'] == 1) { if(strtolower($session_timeout) == 'none') $session_timeout = '00:00:00'; $util->add( array( + 'name' => "$profile_name", + 'rate-limit' => "$rate_limit", + 'shared-users' => "$shared_users", + 'status-autorefresh' => "1m", + 'transparent-proxy' => "yes", + 'on-login' => "$login_script", + ) + ); + /* Old version + array( 'name' => "$profile_name", 'rate-limit' => "$rate_limit", 'session-timeout' => "$session_timeout", @@ -67,7 +79,7 @@ if ($_SESSION['user_level'] == 1) { 'transparent-proxy' => "yes", 'on-login' => "$login_script", ) - ); + */ /* if(strtolower($session_timeout) == 'none') { $id = $client->sendSync(new Request('/ip/hotspot/user/profile/print .proplist=.id', null, Query::where('name', $profile_name)))->getArgument('.id'); diff --git a/ajax_adduser.php b/ajax_adduser.php index d9aefed..10259f8 100644 --- a/ajax_adduser.php +++ b/ajax_adduser.php @@ -23,9 +23,11 @@ if ((!empty($username)) and (!empty($password)) and (!empty($profile))) { array( 'name' => "$username", 'password' => "$password", + 'disabled' => "no", 'limit-uptime' => "$limit_uptime", 'limit-bytes-total' => "$limit_bytes_total", - 'profile' => "$profile" + 'profile' => "$profile", + 'comment' => "Zetozone", ) ); } @@ -35,8 +37,10 @@ if ((!empty($username)) and (!empty($password)) and (!empty($profile))) { array( 'name' => "$username", 'password' => "$password", + 'disabled' => "no", 'limit-uptime' => "$limit_uptime", - 'profile' => "$profile" + 'profile' => "$profile", + 'comment' => "Zetozone", ) ); $limit_bytes = 0; // For Adding it to Local database diff --git a/ajax_addusers.php b/ajax_addusers.php index 2c51e77..b7bd430 100644 --- a/ajax_addusers.php +++ b/ajax_addusers.php @@ -21,9 +21,11 @@ if ( !isset($_SESSION) ) session_start(); switch ($pass_type) { case "s": $passAlphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; + $user_prefix = strtolower($user_prefix); break; case "c": $passAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"; + $user_prefix = strtoupper($user_prefix); break; case "n": $passAlphabet = "123456789123456789123456789123456789123456789123456789"; @@ -33,9 +35,11 @@ switch ($pass_type) { break; case "sn": $passAlphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz123456789123456789123456789"; + $user_prefix = strtolower($user_prefix); break; case "cn": $passAlphabet = "123456789123456789123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789123456789123456789"; + $user_prefix = strtoupper($user_prefix); break; case "scn": $passAlphabet = "abcdefghijklmnopqrstuvwxyz123456789123456789123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; @@ -88,11 +92,13 @@ if($_SESSION['user_level'] >= 1 and $_SESSION['user_level'] <= 3) { $limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 ); $util->add( array( - 'name' => "$user_name", - 'password' => "$pass_word", + 'name' => "$username", + 'password' => "$password", + 'disabled' => "no", 'limit-uptime' => "$limit_uptime", 'limit-bytes-total' => "$limit_bytes_total", - 'profile' => "$profile" + 'profile' => "$profile", + 'comment' => "Zetozone", ) ); } @@ -100,10 +106,12 @@ if($_SESSION['user_level'] >= 1 and $_SESSION['user_level'] <= 3) { { $util->add( array( - 'name' => "$user_name", - 'password' => "$pass_word", + 'name' => "$username", + 'password' => "$password", + 'disabled' => "no", 'limit-uptime' => "$limit_uptime", - 'profile' => "$profile" + 'profile' => "$profile", + 'comment' => "Zetozone", ) ); $limit_bytes = 0; // For Adding it to Local database diff --git a/ajax_edit_profile.php b/ajax_edit_profile.php index 89097e5..921b5bc 100644 --- a/ajax_edit_profile.php +++ b/ajax_edit_profile.php @@ -24,10 +24,12 @@ if ($_SESSION['user_level'] == 1) { $rate_limit = $rx_rate_limit.'/'.$tx_rate_limit; if (empty($rx_rate_limit)) $rx_rate_limit = "256k"; if (empty($tx_rate_limit)) $tx_rate_limit = "128k"; - if (empty($session_timeout)) $session_timeout = "1d 00:00:00"; if (empty($shared_users)) $shared_users = 1; +/* + if (empty($session_timeout)) $session_timeout = "1d 00:00:00"; if (empty($mac_cookie_timeout)) $mac_cookie_timeout = "1d 00:00:00"; if (empty($keepalive_timeout)) $keepalive_timeout = "00:02:00"; +*/ if ($price == "") {$price = "0";} if($lock_user == Enable){$mac_bind = ';[:local mac $"mac-address"; /ip hotspot user set mac-address=$mac [find where name=$user]]';} else {$mac_bind = "";} @@ -64,6 +66,7 @@ if ($_SESSION['user_level'] == 1) { $setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set'); $setRequest->setArgument('numbers', $id); $setRequest->setArgument('rate-limit', $rate_limit); +/* if(strtolower($session_timeout) != 'none') { $setRequest->setArgument('session-timeout', $session_timeout); } @@ -71,10 +74,10 @@ if ($_SESSION['user_level'] == 1) { { $setRequest->setArgument('session-timeout', '00:00:00'); } - $setRequest->setArgument('shared-users', $shared_users); $setRequest->setArgument('mac-cookie-timeout', $mac_cookie_timeout); $setRequest->setArgument('keepalive-timeout', $keepalive_timeout); - +*/ + $setRequest->setArgument('shared-users', $shared_users); $setRequest->setArgument('status-autorefresh', "1m"); $setRequest->setArgument('transparent-proxy', "yes"); $setRequest->setArgument('on-login', "$login_script"); diff --git a/config.php b/config.php index d06756f..2bf77f2 100644 --- a/config.php +++ b/config.php @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/header.php b/header.php index 54a60a0..0a375fa 100644 --- a/header.php +++ b/header.php @@ -918,7 +918,7 @@ function editprofile(oForm) { //Guest User Profile - End of Updating a User profile; '; + echo ''; } ?> @@ -767,7 +793,7 @@ setMenu('/ip hotspot user'); ?>
-

User accounts not yet initiated any activities, and can be removed

+

User accounts not yet initiated any activities, ie. accounts inactive at the moment

diff --git a/index.php b/index.php index 6da0ef5..810d4b7 100644 --- a/index.php +++ b/index.php @@ -21,11 +21,11 @@ use PEAR2\Net\RouterOS; require_once 'PEAR2/Autoload.php'; require_once 'config.php'; try { - $util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass")); - $printRequest = new RouterOS\Request('/ip/hotspot/user/print'); - include_once('home.php'); - } - catch (Exception $e) { - include_once('settings.php'); + $util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass")); + include_once('home.php'); +} +catch (Exception $e) { + echo "Error Accessing Data: " . $e->getMessage(); + include_once('settings.php'); } ?> \ No newline at end of file diff --git a/modal_get_profiles.php b/modal_get_profiles.php index a46f3d1..1d04cf4 100644 --- a/modal_get_profiles.php +++ b/modal_get_profiles.php @@ -22,7 +22,7 @@
- +
@@ -66,13 +66,22 @@ + + + + + + + + + +
@@ -94,7 +113,7 @@
- +
diff --git a/voucher.php b/voucher.php index b2dd577..2a37e12 100644 --- a/voucher.php +++ b/voucher.php @@ -4,7 +4,7 @@ include ('header.php'); if ( !isset($_SESSION) ) session_start(); ?> -
+
@@ -12,7 +12,7 @@ if ( !isset($_SESSION) ) session_start(); ?>

HotSpot User Voucher Printing

-
HotSpot User Voucher Printing
+
Printing of last set of vouchers