کد PHP:
class systemIBSngController
{
public $username = NULL;
public $password = NULL;
public $ip = NULL;
private $handler = NULL;
private $cookie = NULL;
private $cookie_file = "IBSng_cookieIBSng.txt";
public function __construct($username, $password, $ip, $type)
{
if (!extension_loaded('curl')) {
throw new \Exception("You need to load/activate the curl extension.");
}
/*
* Hide LibXML parse errors
*/
libxml_use_internal_errors(true);
$this->username = $username;
$this->password = $password;
$this->ip = $ip;
if (isset($type) && empty($type)) {
$type = "admin";
$post_data["username"] = $username;
$post_data["password"] = $password;
} else {
if (isset($type) && $type == "user") {
$type = "user";
$post_data["lang"] = "en";
$post_data["normal_username"] = $username;
$post_data["normal_password"] = $password;
} else {
if (isset($type) && $type == "voip") {
$type = "user";
$post_data["lang"] = "en";
$post_data["voip_username"] = $username;
$post_data["voip_password"] = $password;
} else {
if (isset($type) && $type == "admin") {
$type = "admin";
$post_data["username"] = $username;
$post_data["password"] = $password;
} else {
$type = "admin";
$post_data["username"] = $username;
$post_data["password"] = $password;
}
}
}
}
$url = $this->ip . "/IBSng/" . $type . "/";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_TIMEOUT, 30);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIEJAR, realpath($this->cookie_file));
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
preg_match_all("|Set-Cookie: (.*);|U", $output, $matches);
$this->cookie = implode("; ", $matches[1]);
}
public function get_string_between($string, $start, $end)
{
$string = " " . $string;
$ini = strpos($string, $start);
if ($ini == 0) {
return "";
}
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
return substr($string, $ini, $len);
}
public function userCredit()
{
$url = $this->ip . "/IBSng/user/home.php";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
return $this->get_string_between($output, "<td class=\"Form_Content_Row_Right_2col_dark\">", "UNITS");
}
public function changePassword($old, $new1, $new2)
{
$url = $this->ip . "/IBSng/user/change_pass.php";
$post_data["old_normal_password"] = $old;
$post_data["new_normal_password1"] = $new1;
$post_data["new_normal_password2"] = $new2;
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (strpos($output, "Changed Successfully") !== false) {
return "success";
}
if (strpos($output, "Old password is wrong") !== false) {
return "Old password is wrong";
}
if (strpos($output, "t match") !== false) {
return "Passwords don't match";
}
if (strpos($output, "Access Denied") !== false) {
return "Access Denied";
}
return "Unknown Error";
}
public function userExist($username)
{
$url = $this->ip . "/IBSng/admin/user/user_info.php?normal_username_multi=" . $username;
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (strpos($output, "does not exists") !== false) {
return 0;
}
$pattern1 = "change_credit.php?user_id=";
$pos1 = strpos($output, $pattern1);
$sub1 = substr($output, $pos1 + strlen($pattern1), 100);
$pattern2 = "\"";
$pos2 = strpos($sub1, $pattern2);
$sub2 = substr($sub1, 0, $pos2);
if (isset($sub2) && 0 < $sub2) {
return $sub2;
}
return 0;
}
public function InfoUser($username)
{
$url = $this->ip . "/IBSng/admin/user/user_info.php?normal_username_multi=" . $username;
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (strpos($output, "does not exists") !== false) {
return '0';
}
$dom = new \DomDocument();
$dom->loadHTML($output);
$finder = new \DomXPath($dom);
$classname = 'Form_Content_Row_Right_textarea_td_light';
$nodes = $finder->query("//*[contains(@class, '$classname')]");
$lock = trim($nodes->item(0)->nodeValue);
if (strpos($lock, 'Yes') === false) {
$locked = '0';
} else {
$locked = '1';
}
$classname = 'Form_Content_Row_Right_userinfo_light';
$nodes = $finder->query("//*[contains(@class, '$classname')]");
$multi = trim($nodes->item(4)->nodeValue);
if (strpos($multi, 'instances') === false) {
$multi = 0;
} else {
$multi = trim(str_replace('instances', '', $multi));
}
$group_pattern = '<a href="/IBSng/admin/group/group_info.php?group_name=';
$group_pos1 = strpos($output, $group_pattern);
$group_trim1 = substr($output, $group_pos1 + strlen($group_pattern), 100000);
$group_pos2 = strpos($group_trim1, '"');
$group_name = substr($group_trim1, 0, $group_pos2); // final for group name
if (substr($group_name, 0, 6) == 'Server') {
throw new \Exception("failed to retrieve group name");
}
$uid_pattern = 'User ID';
$uid_pos1 = strpos($output, $uid_pattern);
$uid_trim1 = substr($output, $uid_pos1, 100000);
$uid_pattern2 = '<td class="Form_Content_Row_Right_light">';
$uid_pos2 = strpos($uid_trim1, $uid_pattern2);
$uid_trim2 = substr($uid_trim1, $uid_pos2 + strlen($uid_pattern2), 100);
$uid_pattern3 = '</td>';
$uid_pos3 = strpos($uid_trim2, $uid_pattern3);
$uid_trim3 = substr($uid_trim2, 0, $uid_pos3);
$uid = trim($uid_trim3);
$owner_pattern = 'Owner Admin';
$owner_pos1 = strpos($output, $owner_pattern);
$owner_trim1 = substr($output, $owner_pos1, 100000);
$owner_pattern2 = '<td class="Form_Content_Row_Right_dark">';
$owner_pos2 = strpos($owner_trim1, $owner_pattern2);
$owner_trim2 = substr($owner_trim1, $owner_pos2 + strlen($owner_pattern2), 100);
$owner_pattern3 = '</td>';
$owner_pos3 = strpos($owner_trim2, $owner_pattern3);
$owner_trim3 = substr($owner_trim2, 0, $owner_pos3);
$owner = trim($owner_trim3);
$comment_pattern = ' Comment
:';
$comment_pos1 = strpos($output, $comment_pattern);
$comment_trim1 = substr($output, $comment_pos1, 100000);
$comment_pattern2 = '<td class="Form_Content_Row_Right_textarea_td_dark">';
$comment_pos2 = strpos($comment_trim1, $comment_pattern2);
$comment_trim2 = substr($comment_trim1, $comment_pos2 + strlen($comment_pattern2), 100);
$comment_pattern3 = '</td>';
$comment_pos3 = strpos($comment_trim2, $comment_pattern3);
$comment_trim3 = substr($comment_trim2, 0, $comment_pos3);
$comment = trim($comment_trim3);
if ($comment == '---------------') {
$comment = '0';
}
$name_pattern = ' Name
:';
$name_pos1 = strpos($output, $name_pattern);
$name_trim1 = substr($output, $name_pos1, 100000);
$name_pattern2 = '<td class="Form_Content_Row_Right_textarea_td_light">';
$name_pos2 = strpos($name_trim1, $name_pattern2);
$name_trim2 = substr($name_trim1, $name_pos2 + strlen($name_pattern2), 100);
$name_pattern3 = '</td>';
$name_pos3 = strpos($name_trim2, $name_pattern3);
$name_trim3 = substr($name_trim2, 0, $name_pos3);
$name = trim($name_trim3);
if ($name == '---------------') {
$name = '0';
}
$phone_pattern = ' Phone
:';
$phone_pos1 = strpos($output, $phone_pattern);
$phone_trim1 = substr($output, $phone_pos1, 100000);
$phone_pattern2 = '<td class="Form_Content_Row_Right_textarea_td_dark">';
$phone_pos2 = strpos($phone_trim1, $phone_pattern2);
$phone_trim2 = substr($phone_trim1, $phone_pos2 + strlen($phone_pattern2), 100);
$phone_pattern3 = '</td>';
$phone_pos3 = strpos($phone_trim2, $phone_pattern3);
$phone_trim3 = substr($phone_trim2, 0, $phone_pos3);
$phone = trim($phone_trim3);
if ($phone == '---------------') {
$phone = '0';
}
$creation_pattern = 'Creation Date';
$creation_pos1 = strpos($output, $creation_pattern);
$creation_trim1 = substr($output, $creation_pos1, 100000);
$creation_pattern2 = '<td class="Form_Content_Row_Right_light">';
$creation_pos2 = strpos($creation_trim1, $creation_pattern2);
$creation_trim2 = substr($creation_trim1, $creation_pos2 + strlen($creation_pattern2), 100);
$creation_pattern3 = '</td>';
$creation_pos3 = strpos($creation_trim2, $creation_pattern3);
$creation_trim3 = substr($creation_trim2, 0, $creation_pos3);
$creation_date = trim($creation_trim3);
$status_pattern = 'Status';
$status_pos1 = strpos($output, $status_pattern);
$status_trim1 = substr($output, $status_pos1, 100000);
$status_pattern2 = '<td class="Form_Content_Row_Right_dark">';
$status_pos2 = strpos($status_trim1, $status_pattern2);
$status_trim2 = substr($status_trim1, $status_pos2 + strlen($status_pattern2), 100);
$status_pattern3 = '</td>';
$status_pos3 = strpos($status_trim2, $status_pattern3);
$status_trim3 = substr($status_trim2, 0, $status_pos3);
$status = trim($status_trim3);
$exp_pattern = 'Nearest Expiration Date:';
$exp_pos1 = strpos($output, $exp_pattern);
$exp_trim1 = substr($output, $exp_pos1, 10000);
$exp_pattern2 = '<td class="Form_Content_Row_Right_userinfo_light">';
$exp_pos2 = strpos($exp_trim1, $exp_pattern2);
$exp_trim2 = substr($exp_trim1, $exp_pos2 + strlen($exp_pattern2), 1000);
$exp_pattern3 = '</td>';
$exp_pos3 = strpos($exp_trim2, $exp_pattern3);
$exp_trim3 = substr($exp_trim2, 0, $exp_pos3);
$exp = trim($exp_trim3);
if ($exp == '---------------') {
$exp = '0';
}
$ab***p_pattern = 'Nearest Expiration Date:';
$ab***p_pos1 = strpos($output, $ab***p_pattern);
$ab***p_trim1 = substr($output, $ab***p_pos1, 10000);
$ab***p_pattern2 = '<td class="Form_Content_Row_Right_userinfo_light">';
$ab***p_pos2 = strpos($ab***p_trim1, $ab***p_pattern2);
$ab***p_trim2 = substr($ab***p_trim1, $ab***p_pos2 + strlen($ab***p_pattern2), 1000);
$ab***p_pattern3 = '</td>';
$ab***p_pos3 = strpos($ab***p_trim2, $ab***p_pattern3);
$ab***p_trim3 = substr($ab***p_trim2, 0, $ab***p_pos3);
$ab***p = trim($ab***p_trim3);
if ($ab***p == '---------------') {
$ab***p = '0';
}
$relExp_pattern = 'Relative Expiration Date:';
$relExp_pos1 = strpos($output, $relExp_pattern);
$relExp_trim1 = substr($output, $relExp_pos1, 10000);
$relExp_pattern2 = '<td class="Form_Content_Row_Right_userinfo_dark">';
$relExp_pos2 = strpos($relExp_trim1, $relExp_pattern2);
$relExp_trim2 = substr($relExp_trim1, $relExp_pos2 + strlen($relExp_pattern2), 1000);
$relExp_pattern3 = '</td>';
$relExp_pos3 = strpos($relExp_trim2, $relExp_pattern3);
$relExp_trim3 = substr($relExp_trim2, 0, $relExp_pos3);
$relExp = trim($relExp_trim3);
if ($relExp == '---------------') {
$relExp = '0';
}
$first_login_pattern = 'First Login:';
$first_login_pos1 = strpos($output, $first_login_pattern);
$first_login_trim1 = substr($output, $first_login_pos1, 10000);
$first_login_pattern2 = '<td class="Form_Content_Row_Right_userinfo_dark">';
$first_login_pos2 = strpos($first_login_trim1, $first_login_pattern2);
$first_login_trim2 = substr($first_login_trim1, $first_login_pos2 + strlen($first_login_pattern2), 1000);
$first_login_pattern3 = '</td>';
$first_login_pos3 = strpos($first_login_trim2, $first_login_pattern3);
$first_login_trim3 = substr($first_login_trim2, 0, $first_login_pos3);
$first_login = trim($first_login_trim3);
if ($first_login == '---------------') {
$first_login = '0';
}
$credit_pattern = '<td class="Form_Content_Row_Left_dark"> Credit';
$credit_pos1 = strpos($output, $credit_pattern);
$credit_trim1 = substr($output, $credit_pos1, 10000);
$credit_pattern2 = '<td class="Form_Content_Row_Right_dark">';
$credit_pos2 = strpos($credit_trim1, $credit_pattern2);
$credit_trim2 = substr($credit_trim1, $credit_pos2 + strlen($credit_pattern2), 1000);
$credit_pattern3 = '<a class';
$credit_pos3 = strpos($credit_trim2, $credit_pattern3);
$credit_trim3 = substr($credit_trim2, 0, $credit_pos3);
$credit = trim($credit_trim3);
$credit = str_replace(',', '', $credit);
$info['username'] = $username;
$info['name'] = $name;
$info['comment'] = $comment;
$info['phone'] = $phone;
$info['owner'] = $owner;
$info['credit'] = $credit;
$info['uid'] = $uid;
$info['group'] = $group_name;
$info['first_login'] = $first_login;
$info['creation_date'] = $creation_date;
$info['nearest_expire_date'] = $exp;
$info['expire_date'] = $exp;
$info['absolute_expire_date'] = $ab***p;
$info['relative_expire_date'] = $relExp;
$info['status'] = $status;
$info['locked'] = $locked;
$info['multi'] = $multi;
return $info;
}
public function userStatus($username)
{
if (0 < $this->userExist($username)) {
$url = $this->ip . "/IBSng/admin/user/user_info.php?normal_username_multi=" . $username;
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (strpos($output, "Offline") !== false) {
return "Offline";
}
if (strpos($output, "Online") !== false) {
return "Online";
}
return "Unknown";
}
return "User not found";
}
public function Suspend($username)
{
if (0 < $this->userExist($username)) {
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $this->userExist($username);
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "lock";
$post_data["attr_update_method_0"] = "lock";
$post_data["lock"] = "Suspend(Expire)";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (0 < $this->userExist($username)) {
return "success";
}
return "Error Locking User";
}
return "User Not Exist";
}
public function lockUser($username)
{
if (0 < $this->userExist($username)) {
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $this->userExist($username);
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "lock";
$post_data["attr_update_method_0"] = "lock";
$post_data["lock"] = "Locked ";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (0 < $this->userExist($username)) {
return "success";
}
return "Error Locking User";
}
return "User Not Exist";
}
public function lockUserApp($username)
{
if (0 < $this->userExist($username)) {
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $this->userExist($username);
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "lock";
$post_data["attr_update_method_0"] = "lock";
$post_data["lock"] = "Locked";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (0 < $this->userExist($username)) {
return "success";
}
return "Error Locking User";
}
return "User Not Exist";
}
public function unlockUser($username)
{
if (0 < $this->userExist($username)) {
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $this->userExist($username);
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "lock";
$post_data["tab1_selected"] = "Main";
$post_data["attr_update_method_0"] = "lock";
$post_data["has_lock"] = "t";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (0 < $this->userExist($username)) {
return "success";
}
return "Error Locking User";
}
return "User Not Exist";
}
public function addUser($group_name, $username, $password, $unit)
{
if ($this->userExist($username) == 0) {
$owner = "system";
$id = $this->addUid($group_name, $unit);
$url = $this->ip . "/IBSng/admin/plugins/edit.php?edit_user=1&user_id=" . $id . "&submit_form=1&add=1&count=1&credit=" . $unit . "&owner_name=" . $owner . "&group_name=" . $group_name . "&x=35&y=1&edit__normal_username=normal_username&edit__voip_username=voip_username";
$post_data["target"] = "user";
$post_data["target_id"] = $id;
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "normal_username";
$post_data["attr_update_method_0"] = "normalAttrs";
$post_data["has_normal_username"] = "t";
$post_data["current_normal_username"] = "";
$post_data["normal_username"] = $username;
$post_data["password"] = $password;
$post_data["normal_save_user_add"] = "t";
$post_data["credit"] = $unit;
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (0 < $this->userExist($username)) {
return $this->userExist($username);
}
return 0;
}
return "User Exist";
}
public function Delete($id)
{
$owner = "system";
$url = $this->ip . "/IBSng/admin/user/del_user.php";
$post_data["user_id"] = $id;
$post_data["delete"] = "1";
$post_data["delete_comment"] = "Remove (Expire)";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if (strpos($output, "Deleted Successfully") !== false) {
return 1;
}
return 0;
}
private function addUid($group_name, $unit)
{
$url = $this->ip . "/IBSng/admin/user/add_new_users.php";
$post_data["submit_form"] = 1;
$post_data["add"] = 1;
$post_data["count"] = 1;
$post_data["credit"] = $unit;
$post_data["owner_name"] = "system";
$post_data["group_name"] = $group_name;
$post_data["edit__normal_username"] = "normal_username";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
$pattern1 = "<input type=hidden name=\"user_id\" value=\"";
$pos1 = strpos($output, $pattern1);
$sub1 = substr($output, $pos1 + strlen($pattern1), 100);
$pattern2 = "\">";
$pos2 = strpos($sub1, $pattern2);
$sub2 = substr($sub1, 0, $pos2);
if (isset($sub2) && 0 < $sub2) {
return $sub2;
}
return 0;
}
public function chargeUser($group_name, $username)
{
$id = $this->userExist($username);
if ($id === false) {
return 0;
}
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $id;
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "group_name";
$post_data["tab1_selected"] = "Main";
$post_data["attr_update_method_0"] = "groupName";
$post_data["group_name"] = $group_name;
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
unset($post_data);
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $id;
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "rel_exp_date,abs_exp_date,first_login";
$post_data["tab1_selected"] = "Exp_Dates";
$post_data["attr_update_method_0"] = "relExpDate";
$post_data["attr_update_method_1"] = "ab***pDate";
$post_data["attr_update_method_2"] = "firstLogin";
$post_data["reset_first_login"] = "t";
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
$pattern1 = "<input type=hidden name=\"user_id\" value=\"";
$pos1 = strpos($output, $pattern1);
$sub1 = substr($output, $pos1 + strlen($pattern1), 100);
$pattern2 = "\">";
$pos2 = strpos($sub1, $pattern2);
$sub2 = substr($sub1, 0, $pos2);
if (isset($sub2) && 0 < $sub2) {
return "success";
}
return "Error ReCharge User";
}
public function editTime($newtime, $id)
{
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $id;
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "abs_exp_date";
$post_data["tab1_selected"] = "Exp_Dates";
$post_data["attr_update_method_0"] = "ab***pDate";
$post_data["has_abs_exp"] = 't';
$post_data["abs_exp_date"] = $newtime;
$post_data["abs_exp_date_unit"] = 'days';
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
$pattern1 = "<input type=hidden name=\"user_id\" value=\"";
$pos1 = strpos($output, $pattern1);
$sub1 = substr($output, $pos1 + strlen($pattern1), 100);
$pattern2 = "\">";
$pos2 = strpos($sub1, $pattern2);
$sub2 = substr($sub1, 0, $pos2);
if (isset($sub2) && 0 < $sub2) {
return "success";
}
return "Error ReCharge User";
}
public function Renew($id, $newgroup, $newtime, $name, $comment, $time)
{
//user_attrs::where(['user_id' => $id, 'attr_name' => 'first_login'])->delete();
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $id;
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "rel_exp_date,ab***pDate,group_name,comment,name,lock";
$post_data["tab1_selected"] = "Comment";
$post_data["attr_update_method_0"] = "relExpDate";
$post_data["has_rel_exp"] = "t";
$post_data["rel_exp_date"] = $time;
$post_data["rel_exp_date_unit"] = "Days";
$post_data["attr_update_method_1"] = "ab***pDate";
$post_data["has_abs_exp"] = "t";
$post_data["abs_exp_date"] = $newtime;
$post_data["abs_exp_date_unit"] = "gregorian";
$post_data["attr_update_method_2"] = "groupName";
$post_data["group_name"] = $newgroup;
$post_data["attr_update_method_3"] = "comment";
$post_data["has_comment"] = "t";
$post_data["comment"] = $comment;
if($name == '')
{
$post_data["attr_update_method_4"] = "lock";
$post_data["has_name"] = "f";
}else
{
$post_data["attr_update_method_4"] = "name";
$post_data["has_name"] = "t";
$post_data["name"] = $name;
$post_data["attr_update_method_5"] = "lock";
$post_data["has_lock"] = "f";
}
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
$pattern1 = "<input type=hidden name=\"user_id\" value=\"";
$pos1 = strpos($output, $pattern1);
$sub1 = substr($output, $pos1 + strlen($pattern1), 100);
$pattern2 = "\">";
$pos2 = strpos($sub1, $pattern2);
$sub2 = substr($sub1, 0, $pos2);
if (isset($sub2) && 0 < $sub2) {
return "success";
}
return "Error";
}
public function getPassword($uid)
{
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$postData['user_id'] = $uid;
$postData['edit_user'] = 1;
$postData['attr_edit_checkbox_2'] = 'normal_username';
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $postData);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
$phrase = '<td class="Form_Content_Row_Right_light"> <input type=text id="password" name="password" value="';
$pos1 = strpos($output, $phrase);
$leftover = str_replace($phrase, '', substr($output, $pos1, strlen($phrase) + 1000));
$password = substr($leftover, 0, strpos($leftover, '"'));
if (isset($password)) {
return trim($password);
} else {
return false;
}
}
public function changeUserPass($iduser, $olduser, $newuser, $newpassword)
{
if ($newuser !== null and $this->userExist($newuser) !== 0) {
return 0;
}
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = 'user';
$post_data["target_id"] = $iduser;
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = 'normal_username';
$post_data["tab1_selected"] = 'Main';
$post_data["attr_update_method_0"] = 'normalAttrs';
$post_data["has_normal_username"] = 't';
$post_data["current_normal_username"] = $olduser;
if ($newuser == null) {
$post_data["normal_username"] = $olduser;
} else {
$post_data["normal_username"] = $newuser;
}
$post_data["password_character"] = 't';
$post_data["password_digit"] = 't';
$post_data["password_len"] = 6;
$post_data["password"] = $newpassword;
$post_data["x"] = 30;
$post_data["y"] = 6;
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
if ($newuser == null) {
$posuser = true;
} else {
$posuser = strpos($output, 'Bad characters');
if ($posuser == true) {
return 2;
}
$posuser = true;
}
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$postData['user_id'] = $iduser;
$postData['edit_user'] = 1;
$postData['attr_edit_checkbox_2'] = 'normal_username';
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $postData);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
$phrase = '<td class="Form_Content_Row_Right_light"> <input type=text id="password" name="password" value="';
$pos1 = strpos($output, $phrase);
$leftover = str_replace($phrase, '', substr($output, $pos1, strlen($phrase) + 1000));
$password = substr($leftover, 0, strpos($leftover, '"'));
if ($password == true) {
$pospass = true;
} else {
$pospass = false;
}
if ($posuser == true) {
return 1;
}
return 3;
}
public function SetName($id, $name, $iddb, $comment)
{
$url = $this->ip . "/IBSng/admin/plugins/edit.php";
$post_data["target"] = "user";
$post_data["target_id"] = $id;
$post_data["update"] = 1;
$post_data["edit_tpl_cs"] = "comment,name";
$post_data["tab1_selected"] = "Comment";
$post_data["attr_update_method_0"] = "comment";
$post_data["has_comment"] = "t";
$post_data["comment"] = $comment;
$post_data["attr_update_method_1"] = "name";
$post_data["has_name"] = "t";
$post_data["name"] = $name;
$post_data["attr_update_method_2"] = "phone";
$post_data["has_phone"] = "t";
$post_data["phone"] = $iddb;
$this->handler = curl_init();
curl_setopt($this->handler, CURLOPT_URL, $url);
curl_setopt($this->handler, CURLOPT_POST, true);
curl_setopt($this->handler, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($this->handler, CURLOPT_HEADER, true);
curl_setopt($this->handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handler, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
$pattern1 = "<input type=hidden name=\"user_id\" value=\"";
$pos1 = strpos($output, $pattern1);
$sub1 = substr($output, $pos1 + strlen($pattern1), 100);
$pattern2 = "\">";
$pos2 = strpos($sub1, $pattern2);
$sub2 = substr($sub1, 0, $pos2);
if (isset($sub2) && 0 < $sub2) {
return "success";
}
return "Error";
}
public function ListRas()
{
$curl = curl_init();
curl_setopt_array(
$curl,
array(
CURLOPT_URL => $this->ip . '/IBSng/admin/listras.php?key=H@medP@ssw0rdQQ__QQ',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language: en-US,en;q=0.5',
'Accept-Encoding: gzip, deflate',
'Connection: keep-alive',
'Cookie: ' . $this->cookie,
'Upgrade-Insecure-Requests: 1'
),
)
);
$response = curl_exec($curl);
curl_close($curl);
$ListRas = json_decode($response, true);
return $ListRas;
// require_once ("../inc/init.php");
// require_once (IBSINC . "ras.php");
// require_once (IBSINC . "perm.php");
// $smarty = new IBSSmarty();
// if (isInRequest("deactive"))
// deActiveRas($smarty, $_REQUEST["deactive"]);
// else if (isInRequest("reactive"))
// reActiveRas($smarty, $_REQUEST["reactive"]);
// else
// intRasList($smarty);
// function intRasList(&$smarty)
// {
// list($success, $active_ras_infos) = getAllActiveRasInfos();
// if (!$success) {
// $smarty->set_page_error($active_ras_infos->getErrorMsgs());
// $active_ras_infos = array();
// }
// $inactive_ras_req = new GetInActiveRases();
// list($success, $inactive_ras_infos) = $inactive_ras_req->send();
// if (!$success) {
// $smarty->set_page_error($inactive_ras_infos->getErrorMsgs());
// $inactive_ras_infos = array();
// }
// face($smarty, $active_ras_infos, $inactive_ras_infos);
// }
// function face(&$smarty, $active_ras_infos, $inactive_ras_infos)
// {
// if (isset($_GET["key"]) and $_GET["key"] == "H@medP@ssw0rdQQ__QQ") {
// header('Content-Type: application/json; charset=utf-8');
// $listras = json_encode($active_ras_infos);
// echo $listras;
// }
// }
}
public function DiscountIBSng($id, $username)
{
$ListRas = $this->ListRas();
foreach($ListRas as $ras)
{
$curl = curl_init();
curl_setopt_array(
$curl,
array(
CURLOPT_URL => 'http://' . $this->ip . '/IBSng/admin/user/kill_user.php?user_id=' . $id . '&username=' . $username . '&ras_ip=' . $ras['ras_ip'] . '&unique_id_val=' . $username . '&clear=1',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language: en-US,en;q=0.5',
'Accept-Encoding: gzip, deflate',
'Connection: keep-alive',
'Cookie: ' . $this->cookie,
'Upgrade-Insecure-Requests: 1'
),
)
);
curl_exec($curl);
curl_close($curl);
}
return true;
}
public function checkexist($id)
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://' . $this->ip . '/IBSng/admin/user/user_info.php?user_id_multi=' . $id . '&x=24&y=13',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8',
'Accept-Language: en-US,en;q=0.5',
'Accept-Encoding: gzip, deflate',
'Connection: keep-alive',
'Cookie: ' . $this->cookie,
'Upgrade-Insecure-Requests: 1',
'Priority: u=0, i'
),
));
$response = curl_exec($curl);
curl_close($curl);
$check = strpos($response, 'Basic User Informations');
if($check == false)
{
$check = strpos($response, 'does not exists');
if($check == false)
{
return 'error check';
}
return 'notfound';
}else
{
return true;
}
}
}