آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر
سلام
دوستان خیلی گشتم یه همچین چیزی پیدا کنم نبود ، مجبور شدم خودم بنویسم ، واسه همین کد رو میزارم که همه استفاده کنن
این کد به کتابخانه php-Curl نیاز داره ولی شما با ساکت ساده هم میتونین به همین روش بنویسینش
کد 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;
} }
نحوه استفاده :
کد PHP:
<?php
$main = new main(); // main esme class i hast ke man vase mesal neveshtam shoma har esmi zadid inja farakhani konin
$main->IBSng_init($IBSng['user'],$IBSng['pass'],$IBSng['ip']);
$main->IBSng_adduser($group_name,$username,$password); // group_name = نام گروه داخل IBSng
?>
پاسخ : آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر
این برنامه مطمئنید که کار می کنه
من تست کردم ولی ارور میده
پاسخ : آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر
یکم بیشتر توضیح بده در موردش کد اول معلوم است پس کد دوم چیه؟
1 فایل پیوست
پاسخ : آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر
نقل قول:
نوشته اصلی توسط
roozserver
سلام
دوستان خیلی گشتم یه همچین چیزی پیدا کنم نبود ، مجبور شدم خودم بنویسم ، واسه همین کد رو میزارم که همه استفاده کنن
این کد به کتابخانه php-curl نیاز داره ولی شما با ساکت ساده هم میتونین به همین روش بنویسینش
کد 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;
} }
نحوه استفاده :
کد PHP:
<?php
$main = new main(); // main esme class i hast ke man vase mesal neveshtam shoma har esmi zadid inja farakhani konin
$main->ibsng_init($ibsng['user'],$ibsng['pass'],$ibsng['ip']);
$main->ibsng_adduser($group_name,$username,$password); // group_name = نام گروه داخل ibsng
?>
دوست عزیز شما اومدی از کلاس db ارث بری کردی در صورتی که کلاسی به نام db وجود نداره.
یکم که دقیقتر نگاه کردم کلی مشکل داره , در هر صورت بنده براتون درستش کردم البته نمیدونم که کار میکنه یا نه تست نکردم.
پاسخ : آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر
این اصلا کار نمیده
باید دنبال راه دیگه ای باشیم
پاسخ : آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر
منم تست کردم کار نکرد
خطاهای زیادی میده
پاسخ : آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر
من میتونم با پی اچ پی تو IBSng یوزر بسازم هرکی خواست پیام خصوصی بده واسه جزییات و قیمت
پاسخ : آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر
Ibsmng.ir
Sent from my Hol-U19 using Tapatalk