کد PHP:
	
class main extends DB {
    
    public $error;
    public $username;
    public $password;
    public $ip;
    private $handler;
    public  $cookie_file = 'cookie.txt';
public function IBSng_init($username,$password,$ip){
        $this->username = $username;
        $this->password = $password;
        $this->ip = $ip;    
    }
    public function IBSng_user_exists($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_COOKIEFILE,$this->cookie_file);
        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') == true) {
            return true;
        }
        else {
            return false;
        }
    }
    public function IBSng_adduser($group_name,$username,$password){
        $owner = 'system';
        $IBSng_uid = $this->IBSng_cr8_uid($group_name);
        
        $url = $this->ip.'/IBSng/admin/plugins/edit.php?edit_user=1&user_id='.$IBSng_uid.'&submit_form=1&add=1&count=1&credit=1&owner_name='.$owner.'&group_name='.$group_name.'&x=35&y=1&edit__normal_username=normal_username';
        $post_data['target'] = 'user';
        $post_data['target_id'] = $IBSng_uid;
        $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; // username
        $post_data['password'] = $password; //password
        $post_data['normal_save_user_add'] = 't';
        $post_data['credit'] = 1;
        $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_COOKIEFILE,$this->cookie_file);
        curl_setopt($this->handler, CURLOPT_COOKIEJAR,$this->cookie_file);
        curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true); 
        $output = curl_exec($this->handler);
        $this->write_log('ibs_add_usr|'.$username.'|'.$password.'|'.$group_name);
        return true; // need to be coded for error reporting 
        
    }
    
    private function IBSng_cr8_uid($group_name){
        $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'] = 1;
        $post_data['owner_name'] = "system";
        $post_data['group_name'] = $group_name;//$group_name;
        $post_data['edit__normal_username'] = 1;
        $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_COOKIEFILE,$this->cookie_file);
        curl_setopt($this->handler, CURLOPT_COOKIEJAR,$this->cookie_file);
        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);
        return $sub2;
}    }