Beispiel #1
0
function uc_fopen2($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE)
{
    $__times__ = isset($_GET['__times__']) ? intval($_GET['__times__']) + 1 : 1;
    if ($__times__ > 2) {
        return '';
    }
    $url .= (strpos($url, '?') === FALSE ? '?' : '&') . "__times__={$__times__}";
    return uc_fopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout, $block);
}
Beispiel #2
0
 function doucenter()
 {
     $d_url = 'index.php?admin_setting-ucenter';
     if (isset($this->post['submit'])) {
         $settings['ucopen'] = $this->post['ucopen'];
         $settings['feed'] = serialize($this->post['feed']);
         $setting = $_ENV['setting']->update_setting($settings);
         $this->cache->removecache('setting');
         $this->message('UCenter设置成功!', $d_url);
     } elseif (isset($this->post['ucsubmit'])) {
         $ucopen = 1;
         $ucapi = $this->post['ucapi'];
         $ucpassword = $this->post['ucpassword'];
         $ucip = $this->post['ucip'];
         $ucapi = preg_replace("/\\/\$/", '', trim($ucapi));
         $ucip = trim($ucip);
         if (empty($ucapi) || !preg_match("/^(http:\\/\\/)/i", $ucapi)) {
             $this->message('您输入的URL地址不正确!', $d_url);
         }
         if (!$ucip) {
             $temp = @parse_url($ucapi);
             $ucip = gethostbyname($temp['host']);
             if (ip2long($ucip) == -1 || ip2long($ucip) === FALSE) {
                 $ucip = '';
             }
         }
         define('UC_API', true);
         if (!@(include_once HDWIKI_ROOT . '/api/uc_client/client.php')) {
             $this->message('uc_client目录不存在。', $d_url);
         }
         $ucinfo = uc_fopen($ucapi . '/index.php?m=app&a=ucinfo&release=' . UC_CLIENT_RELEASE, 500, '', '', 1, $ucip);
         list($status, $ucversion, $ucrelease, $uccharset, $ucdbcharset, $apptypes) = explode('|', $ucinfo);
         if ($status != 'UC_STATUS_OK') {
             $this->message('uc_url_unreachable', $d_url);
         } else {
             $dbcharset = strtolower(str_replace('-', '', trim(WIKI_CHARSET)));
             $ucdbcharset = strtolower(str_replace('-', '', $ucdbcharset));
             if (UC_CLIENT_VERSION > $ucversion) {
                 $this->message('uc_version_incorrect', $d_url);
             } elseif ($dbcharset && $ucdbcharset != $dbcharset) {
                 $this->message('uc_dbcharset_incorrect', $d_url);
             }
             $tagtemplates = '';
             $app_url = WIKI_URL;
             $postdata = "m=app&a=add&ucfounder=&ucfounderpw=" . urlencode($ucpassword) . "&apptype=" . urlencode('OTHER') . "&appname=" . urlencode('HDWIKI') . "&appurl=" . urlencode($app_url) . "&appip=&appcharset=" . $dbcharset . '&appdbcharset=' . $dbcharset . '&' . $tagtemplates . '&release=' . UC_CLIENT_RELEASE;
             $s = uc_fopen($ucapi . '/index.php', 500, $postdata, '', 1, $ucip);
             if (empty($s)) {
                 $this->message('不能连接到 UCenter 服务端。', $d_url);
             } elseif ($s == '-1') {
                 $this->message('UCenter 密码错误。', $d_url);
             } else {
                 $ucs = explode('|', $s);
                 if (empty($ucs[0]) || empty($ucs[1])) {
                     $this->message('UCenter 不能返回数据。', $d_url);
                 }
             }
             $ucdata = "<?php\r\n\t\t\t\t\tdefine('UC_OPEN','{$ucopen}');\r\n\t\t\t\t\tdefine('UC_CONNECT', 'uc_api_post');\r\n\r\n\t\t\t\t\tdefine('UC_DBHOST', '{$ucs[2]}');\r\n\t\t\t\t\tdefine('UC_DBUSER', '{$ucs[4]}');\r\n\t\t\t\t\tdefine('UC_DBPW', '{$ucs[5]}');\r\n\t\t\t\t\tdefine('UC_DBNAME', '{$ucs[3]}');\r\n\t\t\t\t\tdefine('UC_DBCHARSET', '{$ucs[6]}');\r\n\t\t\t\t\tdefine('UC_DBTABLEPRE', '{$ucs[7]}');\r\n\r\n\t\t\t\t\tdefine('UC_KEY', '{$ucs[0]}');\r\n\t\t\t\t\tdefine('UC_API', '{$ucapi}');\r\n\t\t\t\t\tdefine('UC_CHARSET', '{$ucs[8]}');\r\n\t\t\t\t\tdefine('UC_IP', '{$ucip}');\r\n\t\t\t\t\tdefine('UC_APPID', '{$ucs[1]}');\r\n\t\t\t\t\t?>";
             $byte = file::writetofile(HDWIKI_ROOT . '/api/ucconfig.inc.php', $ucdata);
             if ($byte == 0) {
                 $this->message('不能写ucconfig.inc.php文件。', $d_url);
             }
             $this->message('UCenter 设置成功!', $d_url);
         }
     } elseif (isset($this->post['import'])) {
         set_time_limit(0);
         $url = HDWIKI_ROOT . '/api/ucconfig.inc.php';
         if (!file_exists($url)) {
             $this->message('您还没有设置过UCenter!', 'BACK');
         } else {
             include $url;
             if (!(UC_OPEN && isset($this->setting['ucopen']) && $this->setting['ucopen'])) {
                 $this->message('您还没有开通ucenter!', 'BACK');
             }
             $url = HDWIKI_ROOT . "/data/import_uc.lock";
             if (file_exists($url)) {
                 $this->message('您已经导入过用户,想重新导入请删除' . $url . '文件。', 'BACK');
             }
         }
         #包含uc相应文件。
         require_once HDWIKI_ROOT . '/api/uc_client/client.php';
         require_once HDWIKI_ROOT . '/api/uc_client/lib/db.class.php';
         #
         #实例uc数据类
         $ucdb = new db();
         $ucdb->connect(UC_DBHOST, UC_DBUSER, UC_DBPW, UC_DBNAME, UC_DBCHARSET, UC_DBCONNECT, UC_DBTABLEPRE);
         #
         $this->load('user');
         $ucuserlist = '';
         $usercount = $_ENV['user']->get_total_num('', 0);
         for ($i = 0; $i < $usercount; $i = $i + 100) {
             $userlist = $_ENV['user']->get_list('', 0, $i, 100);
             foreach ($userlist as $temUser) {
                 if (uc_get_user($temUser['username'])) {
                     $ucuserlist .= "username:"******"\tuser_email:" . $temUser['email'] . "\r\n";
                 } else {
                     $salt = substr(uniqid(rand()), -6);
                     $password = md5($temUser['password'] . $salt);
                     $ucdb->query("INSERT INTO " . UC_DBTABLEPRE . "members SET username='******'username'] . "', password='******', email='" . $temUser['email'] . "', regip='" . $temUser['regip'] . "', regdate='" . time() . "', salt='" . $salt . "'");
                     $uid = $ucdb->insert_id();
                     $ucdb->query("INSERT INTO " . UC_DBTABLEPRE . "memberfields SET uid='{$uid}'");
                 }
             }
         }
         $mes = "import complate!";
         if (empty($ucuserlist)) {
             $ucuserlist = $mes;
         }
         file::writetofile(HDWIKI_ROOT . "/data/hdwiki_user_uc.txt", $ucuserlist);
         file::writetofile(HDWIKI_ROOT . "/data/import_uc.lock", $mes);
         $this->message('导入用户数据成功!', $d_url);
     } else {
         $this->view->assign('ucopen', $this->setting['ucopen']);
         $url = "./api/ucconfig.inc.php";
         if (!file_exists($url)) {
             $iscon = 1;
         } else {
             include $url;
             if (UC_OPEN && $this->setting['uc']) {
                 $isopen = 1;
             }
             $url = HDWIKI_ROOT . "/data/import_uc.lock";
             if (file_exists($url)) {
                 $islock = 1;
             }
             $this->view->assign('uc_api', UC_API);
         }
         $feed = unserialize($this->setting['feed']);
         $this->view->assign('create', @in_array('create', $feed));
         $this->view->assign('edit', @in_array('edit', $feed));
         $this->view->assign('iscon', $iscon);
         $this->view->assign('isopen', $isopen);
         $this->view->assign('islock', $islock);
         $this->view->display("admin_ucenter");
     }
 }
Beispiel #3
0
$host = "uc.gongchang.com";
$port = 80;
$timeout = 20;
$rs = fsocketopen($ip ? $ip : $host, $port, $errno, $errstr, $timeout);
var_dump($rs);
exit;
define("HTTP_USER_AGENT", "user_agent");
$url = "http://uc.gongchang.com/index.php?__times__=1";
$limit = 500000;
$post = "m=user&a=logincheck&inajax=2&release=20141101&input=fd14gacr90GxmjjEO3QWYa0iw48epTyJ6SG9HT8fvDfxAjT62greyxq%2BkWPZKN9xUO3V%2BLtfVBiClw1sc4pu4mA5j8vLz%2BMoivs16bXXCyexSuGgNLn7jwTyi3KGQP%2BawH5wzE9Frls7599G6hklEIs3HA&appid=31";
$cookie = "";
$bysocket = true;
$ip = "";
$timeout = 20;
$_SERVER[HTTP_USER_AGENT] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36 OPR/33.0.1990.58";
uc_fopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout);
function uc_fopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = false, $ip = '', $timeout = 15, $block = true)
{
    $return = '';
    $matches = parse_url($url);
    !isset($matches['scheme']) && ($matches['scheme'] = '');
    !isset($matches['host']) && ($matches['host'] = '');
    !isset($matches['path']) && ($matches['path'] = '');
    !isset($matches['query']) && ($matches['query'] = '');
    !isset($matches['port']) && ($matches['port'] = '');
    $scheme = $matches['scheme'];
    $host = $matches['host'];
    $path = $matches['path'] ? $matches['path'] . ($matches['query'] ? '?' . $matches['query'] : '') : '/';
    $port = !empty($matches['port']) ? $matches['port'] : 80;
    if ($post) {
        $out = "POST {$path} HTTP/1.0\r\n";
 UC_API ? UC_API : define(UC_API, $settingnew['UC_API']);
 require_once S_ROOT . '/uc_client/client.php';
 $ucinfo = uc_fopen($ucapi . '/index.php?m=app&a=ucinfo&release=' . UC_CLIENT_RELEASE, 500, '', '', 1, $ucip);
 list($status, $ucversion, $ucrelease, $uccharset, $ucdbcharset, $apptypes) = explode('|', $ucinfo);
 if ($status != 'UC_STATUS_OK') {
     kekezu::admin_show_msg($_lang['uc_communication_fail'], 'index.php?do=config&view=integration&type=uc', 3, '', 'warning');
 } else {
     $dbcharset = strtolower(DBCHARSET ? str_replace('-', '', DBCHARSET) : 'utf8');
     $ucdbcharset = strtolower($settingnew['UC_DBCHARSET'] ? str_replace('-', '', $settingnew['UC_DBCHARSET']) : $settingnew['UC_DBCHARSET']);
     if (UC_CLIENT_VERSION > $ucversion) {
         kekezu::admin_show_msg($_lang['uc_different_version'], 'index.php?do=config&view=integration&type=uc', 3, '', 'warning');
     } elseif ($dbcharset && $ucdbcharset != $dbcharset) {
         kekezu::admin_show_msg($_lang['uc_different_coding'], 'index.php?do=config&view=integration&type=uc', 3, '', 'warning');
     }
     $postdata = "m=app&a=add&ucfounder=&ucfounderpw=" . urlencode($ucfounderpw) . "&apptype=" . urlencode($app_type) . "&appname=" . urlencode($app_name) . "&appurl=" . urlencode($app_url) . "&appip=&appcharset=" . CHARSET . '&appdbcharset=' . DBCHARSET . '&' . $app_tagtemplates . '&release=' . UC_CLIENT_RELEASE;
     $ucconfig = uc_fopen($ucapi . '/index.php', 500, $postdata, '', 1, $ucip);
     if (empty($ucconfig)) {
         kekezu::admin_show_msg($_lang['uc_app_fail_to_add'], 'index.php?do=config&view=integration&type=uc', '', 3, 'warning');
     } elseif ($ucconfig == '-1') {
         kekezu::admin_show_msg($_lang['uc_error_author_password'], 'index.php?do=config&view=integration&type=uc', 3, '', 'warning');
     } else {
         list($appauthkey, $appid) = explode('|', $ucconfig);
         if (empty($appauthkey) || empty($appid)) {
             kekezu::admin_system_log($_lang['add_log_msg']);
             kekezu::admin_show_msg(keke::lang('uc_app_invalid_to_add'), 'index.php?do=config&view=integration&type=uc', 3, '', 'success');
         }
     }
 }
 $ucconfig_info = explode('|', $ucconfig);
 $config_ucenter = keke_tpl_class::sreadfile(S_ROOT . "/config/config_ucenter.php");
 $config_ucenter = preg_replace("/define\\('UC_KEY',\\s*'.*?'\\);/s", "define('UC_KEY', '" . $ucconfig_info['0'] . "');", $config_ucenter);