نمایش نتایج: از شماره 1 تا 8 , از مجموع 8

موضوع: آموزش ایجاد یوزر در IBSng با PHP در یک وب سرور دیگر

Threaded View

پست قبلی پست قبلی   پست بعدی پست بعدی
  1. #1
    کاربر اخراج شده
    تاریخ عضویت
    Jul 2013
    نوشته ها
    4
    تشکر تشکر کرده 
    4
    تشکر تشکر شده 
    36
    تشکر شده در
    30 پست

    پیش فرض آموزش ایجاد یوزر در 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->handlerCURLOPT_URL$url);
            
    curl_setopt($this->handlerCURLOPT_COOKIEFILE,$this->cookie_file);
            
    curl_setopt($this->handlerCURLOPT_HEADERTRUE);
            
    curl_setopt($this->handlerCURLOPT_RETURNTRANSFERTRUE); 
            
    curl_setopt($this->handlerCURLOPT_FOLLOWLOCATIONtrue); 
            
    $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->handlerCURLOPT_URL$url);
            
    curl_setopt($this->handlerCURLOPT_POSTtrue);
            
    curl_setopt($this->handlerCURLOPT_POSTFIELDS$post_data);  
            
    curl_setopt($this->handlerCURLOPT_HEADERTRUE);
            
    curl_setopt($this->handlerCURLOPT_RETURNTRANSFERTRUE); 
            
    curl_setopt($this->handlerCURLOPT_COOKIEFILE,$this->cookie_file);
            
    curl_setopt($this->handlerCURLOPT_COOKIEJAR,$this->cookie_file);
            
    curl_setopt($this->handlerCURLOPT_FOLLOWLOCATIONtrue); 
            
    $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->handlerCURLOPT_URL$url);
            
    curl_setopt($this->handlerCURLOPT_POSTtrue);
            
    curl_setopt($this->handlerCURLOPT_POSTFIELDS$post_data);  
            
    curl_setopt($this->handlerCURLOPT_HEADERTRUE);
            
    curl_setopt($this->handlerCURLOPT_RETURNTRANSFERTRUE); 
            
    curl_setopt($this->handlerCURLOPT_COOKIEFILE,$this->cookie_file);
            
    curl_setopt($this->handlerCURLOPT_COOKIEJAR,$this->cookie_file);
            
    curl_setopt($this->handlerCURLOPT_FOLLOWLOCATIONtrue); 
            
    $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

    ?>
    ویرایش توسط roozserver : July 15th, 2013 در ساعت 20:15

  2. تعداد تشکر ها ازroozserver به دلیل پست مفید


اطلاعات موضوع

کاربرانی که در حال مشاهده این موضوع هستند

در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)

موضوعات مشابه

  1. پاسخ ها: 7
    آخرين نوشته: January 17th, 2015, 21:54
  2. آموزش تصویری استفاده یوزر از یک RAS خاص در IBSng
    توسط faranetwork در انجمن مباحث و منابع آموزشی
    پاسخ ها: 12
    آخرين نوشته: July 6th, 2013, 14:15
  3. آموزش تصویری ساخت یوزر در IBSng
    توسط faranetwork در انجمن مباحث و منابع آموزشی
    پاسخ ها: 14
    آخرين نوشته: May 15th, 2013, 15:40
  4. آموزش تصویری ساخت یوزر در IBSng
    توسط supportvps در انجمن مباحث و منابع آموزشی
    پاسخ ها: 0
    آخرين نوشته: March 6th, 2012, 02:21
  5. آموزش کامل انتقال یوزرهای IBSng
    توسط nasyry در انجمن ردهت,فدورا,سنت-او-اس Redhat,Fedora,CentOS
    پاسخ ها: 1
    آخرين نوشته: March 16th, 2011, 00:54

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •