1 فایل پیوست
مشکل با تابع curl در هاست Directadmin
سلام به تازگی یکی از دوستان پلاگینی در تایپیک زیر معرفی کردن برای اسکریپت freer که وقتی نصب میکنم یوزر در ibsng ساخته میشه ولی user و pass نداره
http://www.webhostingtalk.ir/f42/86809/#post820589
این در حالی هست که از یک هاست دیگه تست کردم مشکلی نبود احتمالا این پلاگین فقط از curl استفاده میکنه که phpinfo که از هاست گرفتم اینو میگه:
فایل پیوست 14439
کد پلاگین:
کد:
<?php
/*
Virutal Freer Auto account For IBSng
@author Ali Akbar azizi
For more information contanct me
http://ir-prog.ir
Yahoo! ID : al.az20
*/
//-- اطلاعات کلی پلاگین
$pluginData[ibsng][type] = 'notify';
$pluginData[ibsng][name] = 'ibsng';
$pluginData[ibsng][uniq] = 'ibsng';
$pluginData[ibsng][description] = 'ibsng';
$pluginData[ibsng][note] = 'برای پشتیبانی با ایمیل al.az20@yahoo.com تماس بگیرید';
$pluginData[ibsng][author][name] = 'Ali Akbar';
$pluginData[ibsng][author][url] = 'http://ir-prog.ir';
$pluginData[ibsng][author][email] = 'al.az20@yahoo.com';
//-- فیلدهای تنظیمات پلاگین
$pluginData[ibsng][field][config][1][title] = 'ادرس سرور بدون /';
$pluginData[ibsng][field][config][1][name] = 'url';
$pluginData[ibsng][field][config][2][title] = 'نام کاربری پنل';
$pluginData[ibsng][field][config][2][name] = 'username';
$pluginData[ibsng][field][config][3][title] = 'کلمه عبور پنل';
$pluginData[ibsng][field][config][3][name] = 'password';
//-- تابع پردازش و ارسال اطلاعات
function notify__ibsng($data,$output,$payment,$product,$cards)
{
global $db,$smarty;
if ($output[status] == 1 AND $cards)
{
foreach($cards as $card)
{
$ibs = new IBSng($data[username], $data[password], $data[url]);
$ibs->chargeUser($product[product_third_field_title],$card[card_first_field],$card[card_second_field]);
}
}
}
class IBSng
{
public $error;
public $username;
public $password;
public $ip;
private $handler;
private $cookie;
public function __construct($username, $password, $ip)
{
$this->username = $username;
$this->password = $password;
$this->ip = $ip;
$url = $this->ip . '/IBSng/admin/';
$this->handler = curl_init();
$post_data['username'] = $username;
$post_data['password'] = $password;
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_COOKIEJAR, $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 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 false;
}
else
{
$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);
return $sub2;
}
}
public function addUser($group_name, $username, $password)
{
$owner = 'system';
$id = $this->addUid($group_name);
$url = $this->ip . '/IBSng/admin/plugins/edit.php?edit_user=1&user_id=' . $id . '&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&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; // 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_COOKIE, $this->cookie);
curl_setopt($this->handler, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($this->handler);
return true;
}
private function addUid($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'] = '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);
return $sub2;
}
public function chargeUser($group_name,$username,$password)
{
$id = $this->userExist($username);
if($id === false)
return $this->addUser($group_name, $username, $password);
$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);
return $output;
}
}
پاسخ : مشکل با تابع curl در هاست Directadmin
yum install git
yum install libcurl
1 فایل پیوست
پاسخ : مشکل با تابع curl در هاست Directadmin
نقل قول:
نوشته اصلی توسط
beniii
yum install git
yum install libcurl
تشکر دست خوش تغییراتی شد ولی بازم مشکلی که نباید باشه هست ، تغییرات جدید :
فایل پیوست 14501