コード例 #1
0
ファイル: ui.base.php プロジェクト: h3len/Project
 /**
  *  输出调试结果,debug用
  *
  */
 protected function debug($data = '')
 {
     if (DEBUG_MODE) {
         if (1 == DEBUG_MODE) {
             if (!is_string($data)) {
                 print_r($data);
             } else {
                 echo $data;
             }
             echo '<br />#----------------------------------------------------------------------------------------------------------------------------#<br />';
             echo hg_page_debug();
         } else {
             hg_mkdir(LOG_DIR);
             hg_debug_tofile($data, 1, LOG_DIR . 'debug.txt');
         }
     }
 }
コード例 #2
0
ファイル: db.class.php プロジェクト: h3len/Project
 function halt($message = '', $sql = '')
 {
     $error = mysql_error();
     $errorno = mysql_errno();
     if ($errorno == 2006 && $this->goneaway-- > 0) {
         $this->connect($this->dbhost, $this->dbuser, $this->dbpw, $this->dbname, $this->dbcharset, $this->pconnect, $this->tablepre, $this->time);
         $this->query($sql);
     } else {
         $s = '';
         if ($message) {
             $s = "<b>UCenter info:</b> {$message}<br />";
         }
         if ($sql) {
             $s .= '<b>SQL:</b>' . htmlspecialchars($sql) . '<br />';
         }
         $s .= '<b>Error:</b>' . $error . '<br />';
         $s .= '<b>Errno:</b>' . $errorno . '<br />';
         $s = str_replace(UC_DBTABLEPRE, '[Table]', $s);
         $trace = hg_debug_tofile();
         exit($s . $trace);
     }
 }
コード例 #3
0
ファイル: db_mysql.class.php プロジェクト: h3len/Project
 function halt($message = '', $sql = '')
 {
     $error = mysql_error();
     $errorno = mysql_errno();
     if ($errorno == 2006 && $this->goneaway-- > 0) {
         $this->connect($this->dbhost, $this->dbuser, $this->dbpw, $this->dbname, $this->dbcharset, $this->pconnect, $this->tablepre, $this->time);
         $this->query($sql);
     } else {
         $s = '<strong>version:</strong>' . $this->version() . '<br />';
         $s = '<strong>Error:</strong>' . $error . '<br />';
         $s .= '<strong>Errno:</strong>' . $errorno . '<br />';
         $s .= '<strong>SQL:</strong>:' . $sql;
         $trace = hg_debug_tofile();
         exit($s . $trace);
     }
 }
コード例 #4
0
ファイル: curl.class.php プロジェクト: h3len/Project
 public function request($file)
 {
     $this->addRequestData('lpip', hg_getip());
     $this->addRequestData('m2o_ckey', CUSTOM_APPKEY);
     $para = '';
     if ($this->input['html']) {
         $para .= '&html=' . $this->input['html'];
     }
     if ($this->input['appid'] && $this->input['appkey']) {
         $this->addRequestData('appid', $this->input['appid']);
         $this->addRequestData('appkey', $this->input['appkey']);
     } else {
         if (defined('APPID') && defined('APPKEY')) {
             $this->addRequestData('appid', APPID);
             $this->addRequestData('appkey', APPKEY);
         }
     }
     $this->addRequestData('access_token', $this->input['access_token']);
     if ('get' == $this->mSubmitType || $this->mGetData) {
         $getData = array();
         if ($this->mGetData) {
             $getData = $this->mGetData;
         } else {
             if ($this->mRequestData) {
                 $getData = $this->mRequestData;
             }
         }
         foreach ($getData as $k => $v) {
             $para .= '&' . $k . '=' . $v;
         }
     }
     if (strpos($file, '?')) {
         $pachar = '&';
     } else {
         $pachar = '?';
     }
     $header = array();
     @(include CUR_CONF_PATH . 'conf/hosts.php');
     if ($hosts[$this->mUrlHost]) {
         $domain = $hosts[$this->mUrlHost];
         $header[] = 'Host: ' . $this->mUrlHost;
     } else {
         $domain = $this->mUrlHost;
     }
     //print_r($this->mRequestData);
     $url = $this->mRequestType . '://' . $domain . '/' . $this->mApiDir . $file . $pachar . 'format=' . $this->mReturnType . $para;
     if (DEBUG_MODE) {
         if (!$file) {
             $file = 'index';
         }
         hg_debug_tofile($url, 0, date('Y/m/d/') . $this->mApiDir, $file . '.txt');
         hg_debug_tofile($this->mRequestData, 1, date('Y/m/d/') . $this->mApiDir, $file . '.txt');
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     //curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
     //curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
     curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     if ($this->mCookies) {
         $cookies = implode(';', $this->mCookies);
         curl_setopt($ch, CURLOPT_COOKIE, $cookies);
     }
     if ($this->mRequestType == 'https') {
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     }
     if ('post' == $this->mSubmitType) {
         $header[] = 'Expect:';
         curl_setopt($ch, CURLOPT_POST, true);
         if ($this->mPostContentType == 'string') {
             $postdata = '';
             foreach ($this->mRequestData as $k => $v) {
                 $postdata .= '&' . $k . '=' . $v;
             }
         } else {
             $postdata = $this->mRequestData;
         }
         curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
     }
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     if ($this->isSetTimeOut) {
         curl_setopt($ch, CURLOPT_TIMEOUT, $this->isSetTimeOut);
     }
     $ret = curl_exec($ch);
     $head_info = curl_getinfo($ch);
     $i = 0;
     while ($head_info['http_code'] != 200 && $i < 1) {
         $i++;
         $ret = curl_exec($ch);
         $head_info = curl_getinfo($ch);
     }
     while (substr($ret, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
         $ret = substr($ret, 3);
     }
     curl_close($ch);
     if ($head_info['http_code'] != 200) {
         if (DEBUG_MODE) {
             hg_debug_tofile($head_info, 1, date('Y/m/d/') . $this->mApiDir, $file . '.txt');
         }
         return '';
     }
     if (DEBUG_MODE) {
         hg_debug_tofile($ret, 0, date('Y/m/d/') . $this->mApiDir, $file . '.txt');
     }
     if ($ret == 'null') {
         return '';
     }
     //$ret = iconv($this->mCharset, 'UTF-8', $ret);
     $func = $this->mReturnType . 'ToArray';
     $ret = $this->{$func}($ret);
     return $ret;
 }
コード例 #5
0
ファイル: curl.class.php プロジェクト: h3len/Project
 public function request($file)
 {
     /*
      * 接口基类方法verifyToken根据token获取登录用户信息
      * 或者根据客户端ID和客户端KEY也可以获取虚拟用户信息(超级用户权限)
      */
     $para = '&appid=' . $this->mAppid;
     $para .= '&appkey=' . $this->mAppkey;
     if ($this->mToken) {
         $para .= '&access_token=' . $this->mToken;
     }
     $para .= '&lpip=' . hg_getip();
     if ($this->input && $this->mAutoInput) {
         foreach ($this->input as $k => $v) {
             if (in_array($k, array('a', 'pp', 'mid', 'count', 'id'))) {
                 continue;
             }
             if (is_array($v)) {
                 foreach ($v as $kk => $vv) {
                     //二维数组
                     if (is_array($vv)) {
                         foreach ($vv as $kkk => $vvv) {
                             //防止用户提交的内容的字符开头是@符
                             if ($vvv && $vvv[0] == '@') {
                                 $vvv = ' ' . $vvv;
                             }
                             $this->addRequestData($k . "[{$kk}]" . "[{$kkk}]", $vvv);
                         }
                     } else {
                         //防止用户提交的内容的字符开头是@符
                         if ($vv && $vv[0] == '@') {
                             $vv = ' ' . $vv;
                         }
                         $this->addRequestData($k . "[{$kk}]", $vv);
                     }
                 }
             } else {
                 //防止用户提交的内容的字符开头是@符
                 if ($v && $v[0] == '@') {
                     $v = ' ' . $v;
                 }
                 $this->addRequestData($k, $v);
             }
         }
     }
     if ($_FILES) {
         $this->addFile($_FILES);
     }
     if ($this->input['html']) {
         $para .= '&html=' . $this->input['html'];
     }
     if ('get' == $this->mSubmitType && $this->mRequestData) {
         foreach ($this->mRequestData as $k => $v) {
             $para .= '&' . $k . '=' . urlencode($v);
         }
     }
     $url = $this->mRequestType . '://' . $this->mUrlHost . '/' . $this->mApiDir . $file . '?format=' . $this->mReturnType . $para;
     if ($file == 'news.php' && $this->mRequestData['a'] == 'show') {
         //	hg_pre($url);
     }
     if (DEBUG_MODE) {
         if (!$file) {
             $file = 'index';
         }
         hg_debug_tofile($url, 0, date('Y/m/d/') . $this->mApiDir, $file . '.txt');
         hg_debug_tofile($this->mRequestData, 1, date('Y/m/d/') . $this->mApiDir, $file . '.txt');
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     //curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
     curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     if ($this->mCookies) {
         $cookies = implode(';', $this->mCookies);
         curl_setopt($ch, CURLOPT_COOKIE, $cookies);
     }
     if ('post' == $this->mSubmitType) {
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
         curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mRequestData);
     }
     if ($this->mReponseHeader) {
         curl_setopt($ch, CURLOPT_HEADER, true);
         curl_setopt($ch, CURLOPT_NOBODY, false);
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     if ($this->isSetTimeOut) {
         curl_setopt($ch, CURLOPT_TIMEOUT, $this->isSetTimeOut);
     }
     $ret = curl_exec($ch);
     $head_info = $this->mCurlInfo = curl_getinfo($ch);
     curl_close($ch);
     if ($head_info['http_code'] != 200) {
         if (DEBUG_MODE) {
             hg_debug_tofile($head_info, 1, date('Y/m/d/') . $this->mApiDir, $file . '.txt');
         }
         if ($this->mErrorReturn == 'exit') {
             $uiview = new uiview();
             $uiview->ReportError('服务器访问接口[' . $url . ']异常,错误:' . $head_info['http_code']);
         } else {
             return '';
         }
     }
     if (DEBUG_MODE) {
         hg_debug_tofile($ret, 0, date('Y/m/d/') . $this->mApiDir, $file . '.txt');
     }
     if ($ret == 'null') {
         return '';
     }
     //	file_put_contents('1.txt', var_export('1',1));
     $func = $this->mReturnType . 'ToArray';
     $ret = $this->{$func}($ret);
     return $ret;
 }