Esempio n. 1
0
 /**
  * 发送短信
  * @param int $mobile  手机号
  * @param string $sms_content 短信内容
  * @return array
  */
 public function sendSms($mobile, $sms_content)
 {
     //实例化http类
     $curlHttp = new curlHttp();
     $send_array = array('account' => $this->user, 'password' => md5($this->pwd), 'phones' => $mobile, 'content' => mb_convert_encoding($sms_content, $this->encoding), 'sign' => $this->Signature, 'sendtime' => '');
     $result_array = $curlHttp->post(self::$gateway, 'message=' . $this->xmlEncode($send_array));
     if ($result_array['code'] == 200) {
         $data_array = $this->xmlDecode($result_array['data']);
         if ($data_array['result'] == 0) {
             return array('message' => 'ok', 'code' => 200, 'data' => $result_array);
         } else {
             return array('message' => '短信发送失败', 'code' => 404, 'data' => $result_array);
         }
     } else {
         return array('message' => '短信发送失败', 'code' => 404, 'data' => $result_array);
     }
 }
 /**
  * 从新浪获取头像,然后生成指定的3种尺寸图像供后续指定的$uid使用。(保护方法)
  * 该方法是该类进行主要操作时第一个必须要运行的方法,否则将因为无法初始化对应参数而出错。
  * 
  * @param integer $uid DZ uid
  * @return integer 成功则返回0,否则返回错误代码:
  * 	-1:初始化失败(无法获取新浪用户信息)
  * 	-2:传uid参数错误(小于1)
  * 	-3:无法获取服务器上的头像
  * 	-4:服务器返回错误数据(非头像数据或者给出来的头像太小);或者临时目录权限问题导致无大头像文件
  *  -5:GD库没有加载,无法进行头像同步操作
  */
 function _getFaceAndCreateTemp($uid)
 {
     if (!extension_loaded('gd')) {
         return -5;
     }
     if (empty($this->sina_userinfo) || !isset($this->sina_userinfo['id'])) {
         return -1;
     }
     $this->uid = (int) $uid;
     if ($this->uid < 1) {
         return -2;
     }
     //获取大头像
     $faceurl = str_replace($this->sina_userinfo['id'] . '/50/', $this->sina_userinfo['id'] . '/180/', $this->sina_userinfo['profile_image_url']);
     $body = $this->http->Get($faceurl);
     if ($this->http->getState() !== 200 || empty($body)) {
         return -3;
     }
     //写入临时目录
     $this->faceTempPath[1] = XWB_P_DATA . '/temp/' . $this->uid . '_1_xwb_face_temp.jpg';
     file_put_contents($this->faceTempPath[1], $body, LOCK_EX);
     //大头像安全性和有效性检查(服务器给出来的头像太小,也丢弃处理)
     $imageSize = getimagesize($this->faceTempPath[1]);
     if (false === $imageSize || $imageSize[0] < 30 || $imageSize[1] < 30) {
         $this->_delTempFace();
         return -4;
     }
     //创建中小头像
     foreach ($this->faceSize as $key => $size) {
         //大头像无需处理
         if (1 === $key) {
             continue;
         }
         $imgProc = XWB_plugin::N('images');
         $imgProc->loadFile($this->faceTempPath[1]);
         //载入大头像
         //$imgProc->crop(0,0,180,180);
         $imgProc->resize($size['w'], $size['h']);
         $this->faceTempPath[$key] = XWB_P_DATA . '/temp/' . $this->uid . '_' . $key . '_xwb_face_temp.jpg';
         $imgProc->save($this->faceTempPath[$key]);
         $imgProc = null;
         //释放资源,让其自动调用__destruct
     }
     return 0;
 }
Esempio n. 3
0
function proverb_fsockopen($url, $referer = '')
{
    $content = @file_get_contents($url);
    if (empty($content)) {
        include_once ROOT_PATH . '/inc/http/fsockopenHttp.class.php';
        $f = new fsockopenHttp();
        $f->setHeader('Referer', $referer);
        $content = $f->Get($url);
    }
    if (empty($content)) {
        include_once ROOT_PATH . '/inc/http/curlHttp.class.php';
        $f = new curlHttp();
        $f->_option[CURLOPT_REFERER] = $referer;
        $content = $f->Get($url);
    }
    return $content;
}