Example #1
0
 private function bulid_hyperlinks($matches)
 {
     $notlink = false;
     $matches[0] = str_replace("&", "&", $matches[0]);
     if (stripos($matches[0], YOURLS_SITE) !== false) {
         $shortUrl = $matches[0];
     } else {
         $shortUrl = url::getShortUrl($matches[0]);
     }
     return $shortUrl;
 }
Example #2
0
 private function bulid_hyperlinks($matches)
 {
     $matchUrl = str_replace('&', '&', $matches[0]);
     $tmp = preg_split("/(&#039|&quot)/", $matchUrl);
     $debris = isset($tmp[1]) ? substr($matchUrl, strlen($tmp[0])) : "";
     $matchUrl = $tmp[0];
     if (stripos($matchUrl, YOURLS_SITE) !== false) {
         $shortUrl = $matchUrl;
     } else {
         $shortUrl = strlen($matchUrl) <= 18 ? $matchUrl : url::getShortUrl($matchUrl);
     }
     return "<a href=\"{$shortUrl}\" target=\"_blank\">{$shortUrl}</a>{$debris}";
 }
Example #3
0
 /**
  * 
  * 活动邀请
  */
 public function invite($id = NULL)
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, '请求的方法不存在');
     }
     if (empty($id)) {
         $this->send_response(400, NULL, '400501:活动ID为空');
     }
     $data = $this->get_data();
     if (!$data) {
         $this->send_response(400, NULL, '400412:活动信息非法');
     }
     $event_info = $this->model->get($id);
     if (!$event_info) {
         $this->send_response(400, NULL, '400506:活动不存在');
     }
     if (empty($data['user'])) {
         $this->send_response(400, NULL, '400508:活动报名信息为空');
     }
     $return = array();
     $update_apply_type = false;
     $post = new Validation($data);
     $post->add_rules('user', 'required');
     $post->add_callbacks(TRUE, array($this, '_check_user_validation'));
     if ($post->validate()) {
         $form = $post->as_array();
         if (count($form['user'] > 0)) {
             $user_array = $this->_get_event_uid($form['user']);
             $i = 0;
             $cover = Event_Image_Model::instance()->getCover($id);
             $cover = $cover ? $cover : '';
             $opt = array('event' => array('id' => $id, 'name' => $event_info['title'], 'cover' => $cover), 'no_sign' => 1);
             foreach ($user_array as $mobile => $user) {
                 $i++;
                 if ($this->user_id == $user['user_id'] || empty($user['user_id'])) {
                     continue;
                 }
                 $apply_type = $this->model->getApplyType(array('eid' => $id, 'uid' => $user['user_id']));
                 if (!$apply_type || $apply_type == Kohana::config('event.apply_type.refused')) {
                     if ($apply_type == Kohana::config('event.apply_type.refused')) {
                         $update_apply_type = true;
                     }
                     $eventUser = array('eid' => $id, 'pid' => 0, 'uid' => $user['user_id'], 'name' => $user['name'], 'mobile' => $mobile, 'apply_type' => Kohana::config('event.apply_type.unconfirmed'), 'apply_time' => time(), 'invite_by' => $this->user_id, 'grade' => Kohana::config('event.grade.normal'));
                     $this->model->applyEvent($eventUser, $update_apply_type);
                 }
                 if (!in_array($apply_type, array(Kohana::config('event.apply_type.joined'), Kohana::config('event.apply_type.interested')))) {
                     $return[] = array('uid' => $user['user_id'], 'name' => $user['name'], 'mobile' => $mobile, 'avatar' => sns::getAvatar($user['user_id']));
                     $device_id = md5($mobile . '_' . '0');
                     $token = User_Model::instance()->request_access_token(0, $user['user_id'], $device_id, Kohana::config('event.appid'));
                     $event_url = MO_EVENT . 'event/show/' . $id . '?token=' . $token['oauth_token'];
                     $event_short_url = url::getShortUrl($event_url);
                     $content = '邀请你参加活动:' . $event_short_url;
                     $this->send_event_mq($this->user_id, $user['user_id'], $content, $opt);
                 } else {
                     $this->send_response(400, NULL, '400511:该用户已报名');
                 }
             }
             $this->send_response(200, array('num' => $i, 'user' => $return));
         }
     }
     $errors = $post->errors();
     foreach ($errors as $key => $value) {
         switch ($key) {
             case 'user_name_empty':
                 $this->send_response(400, NULL, '400502:名字为空');
                 break;
             case 'user_mobile_empty':
                 $this->send_response(400, NULL, '400503:手机号为空');
                 break;
             case 'user_mobile_format':
                 $this->send_response(400, NULL, '400504:手机号格式不正确');
                 break;
         }
     }
 }