setMenu('/ip hotspot user'); $iv = count($util); if ((intval($limit_bytes) != 0) and (!empty($limit_uptime))) { $limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 ); $util->add( array( 'name' => "$username", 'password' => "$password", 'limit-uptime' => "$limit_uptime", 'limit-bytes-total' => "$limit_bytes_total", 'profile' => "$profile" ) ); } elseif (intval($limit_bytes) != 0) { $limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 ); $util->add( array( 'name' => "$username", 'password' => "$password", 'limit-bytes-total' => "$limit_bytes_total", 'profile' => "$profile" ) ); } else { $util->add( array( 'name' => "$username", 'password' => "$password", 'limit-uptime' => "$limit_uptime", 'profile' => "$profile" ) ); $limit_bytes = 0; // For Adding it to Local database } if ($iv != count($util)) { include('dbconfig.php'); $stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1"); $stmt->execute(array()); $row = $stmt->fetch(PDO::FETCH_ASSOC); $booking_id = $row['booking_id']; $booking_id++; $uid = $booking_id.'-1-'.date('dmY'); $creator = 999; $created_by = 'Hotsoft'; $stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1"); $stmt->execute(array(':status' => 'Over')); $stmt = $DB_con->prepare("insert into hotspot_vouchers (created_on, created_by, creator, user_name, password, printed_times, printed_last, status, group_of, booking_id, limit_uptime, limit_bytes, profile, uid) values(NOW(), :created_by, :creator, :user_name, :password, :printed_times, :printed_last, :status, :group_of, :booking_id, :limit_uptime, :limit_bytes, :profile, :uid)"); $stmt->execute(array(':created_by' => $created_by, ':creator' => $creator, ':user_name' => $username, ':password' => $password, ':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => 1, ':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes, ':profile' => $profile, ':uid' => $uid)); echo 0; //Success } else { echo 3; // Duplicate/Existing username } } else { echo 2; //Blank Username } //End Adding a Guest User } elseif (strtolower($action) == 'checkout')) { //Removal $username=trim($_GET['username']); if (!empty($username)) { $printRequest = new RouterOS\Request('/ip/hotspot/user/print'); $printRequest->setArgument('.proplist', '.id,name'); $printRequest->setQuery(RouterOS\Query::where('name', $username)); $id = $client->sendSync($printRequest)->getProperty('.id'); $removeRequest = new RouterOS\Request('/ip/hotspot/user/remove'); $removeRequest->setArgument('numbers', $id); $client->sendSync($removeRequest); echo 0; //Success } else { echo 2; //Blank Username } } else { echo 1; //Wrong Action Verb } ?>