Esempio n. 1
0
 /**
  * 获取单条动态
  * @param <string> $id
  */
 public function im($id = NULL)
 {
     if (request::method() != 'get') {
         $this->send_response(400, NULL, '400:无法接受GET以外请求方式');
     }
     if (!$id) {
         $this->send_response(400, NULL, '400:动态ID为空');
     }
     $urlcode = $this->input->get('urlcode', '');
     $feedModel = new Feed_Model();
     $val = $feedModel->findFeed($id);
     if (empty($val)) {
         $this->send_response(404, NULL, '动态不存在');
     }
     $post_uid = $val['owner_uid'];
     $have_permision = false;
     if ($urlcode) {
         $url_info = Url_Model::instance()->get(trim($urlcode));
         if ($url_info) {
             if ($url_info['status_id'] == $id && $url_info['receiver_uid'] == $this->uid) {
                 $session = Session::instance();
                 $session->set('url_login', true);
                 $have_permision = true;
             }
         }
     }
     $val = $feedModel->new_feedview($val);
     if (empty($val)) {
         $this->send_response(404, NULL, '动态不存在');
     }
     unset($val['comment_list']);
     $this->send_response(200, $val);
 }
Esempio n. 2
0
 /**
  * 
  * 单例模型
  * @return Url_Model
  */
 public static function &instance()
 {
     if (!is_object(Url_Model::$instances)) {
         // Create a new instance
         Url_Model::$instances = new Url_Model();
     }
     return Url_Model::$instances;
 }
Esempio n. 3
0
 /**
  *
  * 评论mo短信
  * @param string $feedid
  * @param array $at
  */
 private function mo_sms_comment($commentid, $feedid, $receiver_uid, $receiver_name, $moid = '', $auto)
 {
     $type = $this->format_type($typeid);
     $sender_uid = $this->uid;
     $sender_name = sns::getrealname($this->uid);
     //检查接收者是否在自己联系人中,并且接收者级别<3
     if (Friend_Model::instance()->check_iscontact($sender_uid, $receiver_uid)) {
         $receiver_status = sns::getstatus($receiver_uid);
         if ($receiver_status >= 3 && $auto == true) {
             return false;
         }
     } else {
         return false;
     }
     //接收者的用户基本要<2x
     if (!$this->is_mo_sms_sent('comment', $feedid, $sender_uid, $receiver_uid, $moid)) {
         $receiver_info = sns::getuser($receiver_uid);
         $url_code = Url_Model::instance()->create('status', $sender_uid, $sender_name, $receiver_uid, $receiver_name, $receiver_info['mobile'], $receiver_info['zone_code'], $feedid);
         $short_url = MO_SMS_JUMP . $url_code;
         $comment_row = $this->comment_new->findOne(array('id' => $commentid));
         if ($comment_row) {
             $content = str::cnSubstr($this->feed_at_format($comment_row['content'], $comment_row['at']), 0, 15) . '..';
             $data = array();
             $data['sender']['id'] = $sender_uid;
             $data['sender']['name'] = $sender_name;
             $data['receiver'][] = $receiver_uid;
             $data['timestamp'] = time();
             $data['content']['text'] = $sender_name . '分享了:' . $content . ',点开互动: ' . $short_url;
             $mq_msg = array("kind" => "mobile_sms", "data" => $data);
             $this->mq_send(json_encode($mq_msg), $this->uid, 'momo_im');
             $this->mo_sms_log('comment', $commentid, $feedid, $this->uid, $receiver_uid, $moid);
             if ($moid) {
                 $this->update_my_mo($moid);
             }
             return true;
         }
     }
 }
Esempio n. 4
0
 public function __construct()
 {
     parent::__construct();
     $this->model = Url_Model::instance();
 }
Esempio n. 5
0
 public function download($id, $filetype, $filename)
 {
     //$fileinfo=explode('.', $filename);
     $beta = (int) $_GET['beta'];
     $upgrade_table = $this->_get_upgrade_table($beta);
     $fileinfo = array();
     $fileinfo[1] = $id;
     $fileinfo[2] = $filetype;
     $db = Database::instance();
     //根据id获取安装包信息
     $idinfo = explode('_', $id);
     $id = intval($idinfo[0]);
     if (isset($idinfo[1])) {
         $sql = "SELECT u.*,b.brand_id,b.upgrade_id FROM {$upgrade_table} u \n            LEFT JOIN `upgrade_brand` b ON (b.upgrade_id=u.id) \n            WHERE u.id = {$id} AND b.brand_id='{$idinfo['1']}' LIMIT 1";
     } else {
         $sql = "SELECT u.*,b.brand_id,b.upgrade_id FROM {$upgrade_table} u \n            LEFT JOIN `upgrade_brand` b ON (b.upgrade_id=u.id) \n            WHERE u.id = {$id} LIMIT 1";
     }
     $query = $db->query($sql);
     $res = $query->result_array(FALSE);
     if ($res) {
         $downinfo = $res[0];
     } else {
         $this->send_response(400, '', '40001无法下载');
     }
     if ($fileinfo[2] == 'jad' && preg_match('/\\.jar$/i', $filename)) {
         //获取jar包
         $brand_cond = '';
         if ($downinfo['brand_id']) {
             //$brand_cond="AND b.brand_id='{$downinfo['brand_id']}' ";
         }
         $sql = "SELECT u.*,b.brand_id,b.upgrade_id FROM {$upgrade_table} u \n            LEFT JOIN `upgrade_brand` b ON (b.upgrade_id=u.id) \n            WHERE u.platform = 'j2me' AND u.signed={$downinfo['signed']} AND u.channel='{$downinfo['channel']}' AND RIGHT(u.download_url, 3) = 'jar' {$brand_cond}\n            ORDER BY u.`id` DESC LIMIT 1";
         $query = $db->query($sql);
         if ($res = $query->result_array(FALSE)) {
             $j2me = $res[0];
             $data = file_get_contents($j2me['download_url']);
             header("Content-Type: application/java-archive");
             header("Content-Length: " . strlen($data));
             exit($data);
         } else {
             $this->send_response(400, '', '40001无法下载');
         }
     }
     $uid = $this->input->get('uid');
     $timestamp = $this->input->get('timestamp');
     $token = $this->input->get('token');
     $the_token = md5("{$fileinfo[1]}/{$filetype}/{$filename}" . $uid . $timestamp . $beta . $this->key);
     if ($token != $the_token) {
         //校验失败
         $data = file_get_contents($downinfo['download_url']);
         header("Content-Length: " . strlen($data));
         exit($data);
     }
     $userinfo = User_Model::instance()->get_user_info($uid);
     if (!$userinfo || !$userinfo['mobile']) {
         //用户不存在或者无手机号
         $data = file_get_contents($downinfo['download_url']);
         header("Content-Length: " . strlen($data));
         exit($data);
     }
     $url_code = "";
     if ((int) $downinfo['appid'] == 29) {
         $url_code = Url_Model::instance()->create('callshow', Kohana::config('uap.xiaomo'), '小秘-秀秀', $userinfo['uid'], $userinfo['realname'], $userinfo['mobile'], '86', '', '', '', (int) $downinfo['appid']);
     } else {
         $url_code = Url_Model::instance()->create('sys', Kohana::config('uap.xiaomo'), '小秘', $userinfo['uid'], $userinfo['realname'], $userinfo['mobile']);
     }
     if (!$url_code) {
         $data = file_get_contents($downinfo['download_url']);
         header("Content-Length: " . strlen($data));
         exit($data);
     }
     if ($fileinfo[2] == 'jad') {
         $filecontent = file_get_contents($downinfo['download_url']);
         if ($filecontent) {
             $filecontent .= "AUTO_LOGIN: "******"\n";
             if ($downinfo['brand_id']) {
                 $filecontent .= "phone_model: " . $downinfo['brand_id'] . "\n";
             }
             header("Content-Type: text/vnd.sun.j2me.app-descriptor");
             header("Content-Length: " . strlen($filecontent));
             exit($filecontent);
         } else {
             $this->send_response(400, '', '40002无法下载');
         }
     } elseif ($fileinfo[2] == 'ipa') {
         if (class_exists('ZipArchive')) {
             $ipa_content = file_get_contents($downinfo['download_url']);
             $done = FALSE;
             if ($ipa_content) {
                 $filename = tempnam('/tmp', 'ipa_');
                 file_put_contents($filename, $ipa_content);
                 $appname = $this->_get_appname($downinfo['appid']);
                 $zip = new ZipArchive();
                 if ($zip->open($filename, ZIPARCHIVE::CREATE)) {
                     $zip->addFromString("Payload/{$appname}.app/assets/auth.json", '{"autoLogin":"******"}');
                     $zip->close();
                     $done = TRUE;
                 }
             }
             if ($done) {
                 $filecontent = file_get_contents($filename);
                 @unlink($filename);
             } else {
                 $this->send_response(400, '', '40002无法下载');
             }
         } else {
             $filecontent = file_get_contents($downinfo['download_url']);
             if (!$filecontent) {
                 $this->send_response(400, '', '40002无法下载');
             }
         }
         header("Content-Type: application/x-zip");
         header("Content-Length: " . strlen($filecontent));
         exit($filecontent);
     } elseif ($fileinfo[2] == 'apk') {
         if (class_exists('ZipArchive')) {
             $apk_content = file_get_contents($downinfo['download_url']);
             $done = FALSE;
             if ($apk_content) {
                 $filename = tempnam('/tmp', 'apk_');
                 file_put_contents($filename, $apk_content);
                 $zip = new ZipArchive();
                 if ($zip->open($filename, ZIPARCHIVE::CREATE)) {
                     $zip->addFromString('assets/auth.json', '{"autoLogin":"******"}');
                     $zip->close();
                     $done = TRUE;
                 }
             }
             if ($done) {
                 $keyfile = DOCROOT . "_tools/momo.key";
                 $filename_signed = $filename . '_signed';
                 if ((int) $downinfo['appid'] == 29) {
                     $keyfile = DOCROOT . "_tools/momoshow.key";
                     exec("/usr/bin/jarsigner -verbose -keystore {$keyfile} -keypass momo.android -storepass momo.android {$filename} momoshow");
                 } else {
                     exec("/usr/bin/jarsigner -verbose -keystore {$keyfile} -keypass momo.android -storepass momo.android {$filename} momo");
                 }
                 exec(DOCROOT . "_tools/zipalign -v 4 {$filename} {$filename_signed}");
                 $filecontent = file_get_contents($filename);
                 @unlink($filename);
                 @unlink($filename_signed);
             } else {
                 $this->send_response(400, '', '40002无法下载');
             }
         } else {
             $filecontent = file_get_contents($downinfo['download_url']);
             if (!$filecontent) {
                 $this->send_response(400, '', '40002无法下载');
             }
         }
         header("Content-Type: application/vnd.android.package-archive");
         header("Content-Length: " . strlen($filecontent));
         exit($filecontent);
     }
 }