Esempio n. 1
0
 private function __construct()
 {
     $config = HaloEnv::getConfig();
     $this->host = $config['log']['host'];
     $this->port = $config['log']['port'];
     $this->prefix = $config['debug'] == 1 ? 'debug_' : '';
 }
Esempio n. 2
0
function haloDump($var)
{
    $config = HaloEnv::get('config');
    if ($config['dump']) {
        echo '<pre>';
        $res = var_export($var, true);
        var_dump(SecurityUtils::escape($res));
        echo '</pre>';
        // 		echo '<pre>'. $var. '</pre>';
    }
}
Esempio n. 3
0
 public static function productModel()
 {
     $config = HaloEnv::get('config');
     return $config['product']['model'];
 }
Esempio n. 4
0
 protected function checkReferer()
 {
     //检查是否是post请求
     if (strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0) {
         $this->inputRefererErrorResult();
     }
     $refer = $_SERVER['HTTP_REFERER'];
     if (empty($refer)) {
         $this->inputRefererErrorResult();
     } else {
         $legalHost = array('weibo.com', 'weibo.cn', 'zhaopin.weibo.cn', 'zhaopin.weibo.com', "pre.zhaopin.weibo.com", "www.zhaopin.weibo.com", "zhaopin.renmai.cn");
         $testHost = array('local.weibo.com', 'local.weibo.cn', 'renmai.weibo.com', 'renmai.weibo.cn', 'renmai.cn', 'fix.zhaopin.weibo.com', 'dev.zhaopin.weibo.com', 'local.zhaopin.weibo.com', "pre.zhaopin.weibo.com", "fix.weizhaopin.com");
         $config = HaloEnv::getConfig();
         if ($config->app->debug == 1) {
             $legalHost = array_merge($legalHost, $testHost);
         }
         $url = parse_url($refer);
         $result = false;
         foreach ($legalHost as $v) {
             //                $pos = stripos($url['host'],$v);
             //                if($pos!==false)
             if ($v == $url['host']) {
                 $result = true;
                 break;
             }
         }
         if ($result === false) {
             $this->inputRefererErrorResult();
         } else {
             if (!$_FILES && $_REQUEST['trace_type'] != 'ajax') {
                 $this->inputRefererErrorResult();
             }
         }
     }
 }
Esempio n. 5
0
 /**
  * Make an HTTP request
  *
  * @return string API results
  * @ignore
  */
 function http($url, $method, $postfields = NULL, $headers = array())
 {
     list($usec, $sec) = explode(" ", microtime());
     $begin = (double) $usec + (double) $sec;
     $this->http_info = array();
     $ci = curl_init();
     /* Curl settings */
     curl_setopt($ci, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
     curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
     curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
     curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ci, CURLOPT_ENCODING, "");
     curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
     curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
     curl_setopt($ci, CURLOPT_HEADER, FALSE);
     curl_setopt($ci, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
     $config = HaloEnv::get('config');
     $debug = $config['app']['debug'];
     if (!isEmptyString($this->http_proxy)) {
         curl_setopt($ci, CURLOPT_PROXY, $this->http_proxy);
         if (Logger::isDebugEnabled()) {
             Logger::DEBUG('URL:[' . $url . '][PROXY:' . $this->http_proxy . ']', __FILE__, __LINE__, 'sina_api');
         }
     }
     if ($this->cookie) {
         if (isset($this->cookie['SUW'])) {
             $this->cookie['SUW'] = urldecode($this->cookie['SUW']);
             curl_setopt($ci, CURLOPT_REFERER, "http://weibo.cn");
         } else {
             curl_setopt($ci, CURLOPT_REFERER, "http://weibo.com");
         }
         $cookie = http_build_query($this->cookie, null, '; ');
         curl_setopt($ci, CURLOPT_COOKIE, $cookie);
     }
     switch ($method) {
         case 'POST':
             curl_setopt($ci, CURLOPT_POST, TRUE);
             if (!empty($postfields)) {
                 curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
                 $this->postdata = $postfields;
             }
             break;
         case 'DELETE':
             curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
             if (!empty($postfields)) {
                 $url = "{$url}?{$postfields}";
             }
     }
     if (isset($this->access_token) && $this->access_token) {
         $headers[] = "Authorization: OAuth2 " . $this->access_token;
     }
     $headers[] = "API-RemoteIP: " . $_SERVER['REMOTE_ADDR'];
     curl_setopt($ci, CURLOPT_URL, $url);
     curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE);
     $response = curl_exec($ci);
     $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
     $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
     $this->url = $url;
     if ($this->http_code != 200) {
         if (curl_errno($ci) == CURLE_OPERATION_TIMEOUTED) {
             Logger::ERROR("sina api timeout url is " . $url . ", sever ip is " . $_SERVER['REMOTE_ADDR'], "", "", "sina_api_timeout");
             //                $msg = urlencode("Fatal error sina api is timeout on ip ".$_SERVER['REMOTE_ADDR']);
             //                system('wget "http://223.202.17.147/insert_information.php?email=junqiang.liu@yolu-inc.com&info='.$msg.'&pass=fuck18324hfbdhfkgmxc" -O /dev/null -o /dev/null');
         }
         $e = new Exception();
         Logger::ERROR("&&&&&& Curl error is: " . print_r(curl_error($ci), true), "", "", "sina_api_error");
         Logger::ERROR(sprintf("====\ncode: %d\nurl:%s\nresponse:%s====\nstack:%s\ninfo:%s\n", $this->http_code, $url, $response, $e->getTraceAsString(), print_r(curl_getinfo($ci), true)), __FILE__, __LINE__, 'sina_api_error');
     }
     if ($this->debug) {
         echo "<hr/>=====post data======\r\n<pre>";
         // 			var_dump($postfields);
         echo '</pre><hr/>=====info=====' . "\r\n<pre>";
         // 			var_dump( curl_getinfo($ci) );
         echo '</pre><hr/>=====$response=====' . "\r\n";
         // 			var_dump( $response );
     }
     curl_close($ci);
     return $response;
 }
Esempio n. 6
0
 protected function inputClientError($data)
 {
     $config = HaloEnv::get('config');
     $debug = $config['app']['debug'];
     Logger::ERROR($data);
     switch ($data['code']) {
         case 1100:
             $desc = "职位不存在";
             break;
         case 1108:
             $desc = "职位已关闭";
             break;
         case 1109:
             $desc = "职位尚未发布";
             break;
         case 1205:
             $desc = "重复投递简历";
             break;
         case 1206:
             $desc = "不能投递简历,职位或公司不存在";
             break;
         case 1208:
             $desc = "简历不存在";
             break;
         case 1209:
             $desc = "简历已存在";
             break;
         case 1216:
             $desc = "项目不存在";
             break;
         case 1300:
             $desc = '用户名或密码错误';
             break;
         default:
             $desc = "请求错误";
             break;
     }
     $data['desc'] = $desc;
     if (!$debug) {
         unset($data['error']);
         unset($data['code']);
     }
     echo json_encode($data);
     haloDie();
 }