Example #1
0
 public function invoke($arrInput)
 {
     if (!isset($arrInput['id']) || !isset($arrInput['title'])) {
         return "缺少参数";
     }
     $id = intval($arrInput['id']);
     $data['name'] = $arrInput['title'];
     if (isset($arrInput['delepic'])) {
         $data['pic_url'] = '';
     }
     if ($_FILES['fileToUpload'] && $_FILES['fileToUpload']['error'] == 0) {
         if (strpos($_FILES['fileToUpload']['type'], 'image') !== 0) {
             return "上传文件不是图片";
         }
         // 上传到百度云
         $imgurl = Net_Util::uploadPic($_FILES['fileToUpload']);
         if ($imagurl === false) {
             return "图片上传百度云失败";
         }
         $data['pic_url'] = $imgurl;
     }
     $dataService = new Service_Data_Message_V2_MessageType();
     $ret = $dataService->update($id, $data);
     return "更新成功";
 }
Example #2
0
 protected function invoke($arrInput)
 {
     $arrResult = array();
     $arrResult['errno'] = 0;
     //用于登录
     try {
         $this->objServiceDataMessage = new Service_Data_Message_V2_Message();
         $messageTypeDataService = new Service_Data_Message_V2_MessageType();
         $type_list = $messageTypeDataService->getList(100);
         //大于100的运营消息
         $data = $this->objServiceDataMessage->get_operation_message_details($arrInput['id']);
         $arrResult['data'] = $data[0];
         $arrResult['type_list'] = $type_list;
         $opt = $data[0]['opt'] ? json_decode($data[0]['opt'], true) : array();
         $arrResult['data']['opt'] = $opt;
         $linkInfo['id'] = $arrInput['id'];
         $linkInfo['type'] = $data[0]['type'];
         $linkInfo['origin'] = 'share';
         $arrResult['data']['articleLink'] = Net_Util::getMessageLink($linkInfo);
         $arrResult['data']['old_city_list'] = $opt['city_list'] ? json_encode($opt['city_list']) : '[]';
         $arrResult['data']['pic_cover'] = $arrResult['data']['pic_cover'] ? $arrResult['data']['pic_cover'] : $type_list[$arrResult['data']['type']]['pic_url'];
     } catch (Exception $e) {
         Bd_Log::warning($e->getMessage(), $e->getCode());
         $arrResult['errno'] = $e->getCode();
     }
     return $arrResult;
 }
Example #3
0
 public function invoke($arrInput)
 {
     if (!isset($arrInput['type_id']) || !isset($arrInput['title'])) {
         return '缺少参数';
     }
     $type_id = intval($arrInput['type_id']);
     $title = $arrInput['title'];
     $data['type_id'] = $type_id;
     $data['name'] = $title;
     if ($type_id < 1) {
         return "type id 不能小于 0";
     }
     $dataService = new Service_Data_Message_V2_MessageType();
     $existType = $dataService->getTypeByTypeId($type_id);
     if ($existType) {
         return "type id {$type_id} [{$existType['name']}] 已经存在  ";
     }
     if ($_FILES['fileToUpload'] && $_FILES['fileToUpload']['error'] == 0) {
         if (strpos($_FILES['fileToUpload']['type'], 'image') !== 0) {
             return "上传文件不是图片";
         }
         // 上传到百度云
         $imgurl = Net_Util::uploadPic($_FILES['fileToUpload']);
         if ($imagurl === false) {
             return "图片上传百度云失败";
         }
         $data['pic_url'] = $imgurl;
     }
     $ret = $dataService->addType($data);
     if ($ret === false) {
         return "保存失败";
     }
     return "添加成功";
 }
Example #4
0
 public function invoke()
 {
     $arrRequest = Saf_SmartMain::getCgi();
     $arrInput = $arrRequest['post'];
     $pageService = new Service_Page_Operation_V2_SaveOperationMessage('params_save_opmessage');
     $ret = $pageService->execute($arrInput);
     $msg = $ret['errmsg'];
     Net_Util::showAndReturn($msg, '/naviServerAdmin/v2/viewoperation');
 }
Example #5
0
 public function invoke()
 {
     $arrRequest = Saf_SmartMain::getCgi();
     $arrInput = $arrRequest['get'];
     $pageService = new Service_Page_Operation_V2_CallIntelligence(null);
     $arr = $pageService->execute($arrInput);
     if ($arr['errno'] !== 0) {
         $msg = $arr['errmsg'];
     }
     Net_Util::showAndReturn($msg, '/naviServerAdmin/v2/viewoperation');
 }
Example #6
0
 public function invoke($arrInput)
 {
     //用于登录
     $typeDataService = new Service_Data_Message_V2_MessageType();
     $typelist = $typeDataService->getList(100);
     $data['typelist'] = $typelist;
     $data['premessage']['title'] = $arrInput['title'] ? htmlspecialchars($arrInput['title']) : '';
     $data['premessage']['ria_content'] = $arrInput['ria_content'] ? htmlspecialchars($arrInput['ria_content']) : '';
     $data['premessage']['province'] = $arrInput['province'] ? htmlspecialchars($arrInput['province']) : '全国';
     $data['premessage']['road_level'] = $arrInput['road_level'] ? htmlspecialchars($arrInput['road_level']) : '';
     $data['premessage']['origin'] = $arrInput['origin'] ? htmlspecialchars($arrInput['origin']) : '';
     $data['premessage']['timestamp'] = $arrInput['timestamp'] ? htmlspecialchars($arrInput['timestamp']) : '';
     if ($data['premessage']['timestamp']) {
         $data['intelligence_callback'] = Net_Util::updateIntelligenceStatus($data['premessage']['timestamp'], 3, false);
     }
     return $data;
 }
Example #7
0
 public function upload()
 {
     if ($_FILES['upfile'] && $_FILES['upfile']['error'] === 0) {
         $imageFile = $_FILES['upfile'];
         $return['size'] = filesize($imageFile['tmp_name']);
         $return['state'] = 'SUCCESS';
         $return['originalName'] = $return['name'] = $imageFile['name'];
         $return['type'] = strtolower(strrchr($imageFile["name"], '.'));
         $return['url'] = Net_Util::uploadPic($imageFile);
         return $return;
     } else {
         // 没有文件
         $return['state'] = 'FAILED';
         return $return;
     }
     //{"originalName":"demo.jpg","name":"demo.jpg","url":"upload\/demo.jpg","size":"99697","type":".jpg","state":"SUCCESS"}
 }
Example #8
0
 public function execute()
 {
     // 验证控制器反问权限
     $this->controller = $this->getRequest()->getControllerName();
     $this->action = $this->getRequest()->getActionName();
     $valid_users = Bd_Conf::getAppConf('operation/user');
     // 临时方案,继承该类的action需要验证用户
     $valid_access = false;
     foreach ($valid_users as $k => $v) {
         if ($v['name'] == CURRENT_USER) {
             $valid_access = true;
             break;
         }
     }
     if ($valid_access) {
         $this->invoke();
     } else {
         Net_Util::showAndReturn("没有权限\\n有需要可以找zhangyuliang01", '/naviServerAdmin/index');
         exit;
     }
 }
Example #9
0
 public function setObject($file_name, $object_name, $private = true)
 {
     $file_name = strpos($file_name, '@') !== false ? $file_name : '@' . $file_name;
     $post_data = array('upload' => $file_name);
     $signature = $this->getSignature($object_name);
     // object_name需要透传
     $baseUrl = self::HOST . '/' . self::BUCKET . '/' . $object_name . '?sign=' . self::FLAG . ':' . self::ACCESS_KEY . ':' . $signature;
     $url = $baseUrl . '&dumpheader=1&disposition=attach';
     if ($private === false) {
         $headers = array();
         $headers[] = "x-bs-acl:public-read";
         $headers[] = "image/png";
     }
     $res = Net_Util::postData($url, $post_data, $headers);
     // POST
     if (!empty($res)) {
         $ret = json_decode($res, true);
         if (empty($ret)) {
             Bd_Log::addNotice(__CLASS__, sprintf("Notice[bcs] Message[Invaid Json String] Return[%s]", $res));
             return false;
         }
         try {
             if ($ret["Error"]["Code"] === 0) {
                 return true;
             } else {
                 Bd_Log::addNotice(__CLASS__, sprintf("Notice[bcs] Message[Get error from BCS] Return[%s]", $res));
                 return false;
             }
         } catch (Exception $e) {
             Bd_Log::addNotice(__CLASS__, sprintf("Notice[bcs] Message[Catch an exception] Return[%s]", $res));
             return false;
         }
     } else {
         return false;
     }
 }
Example #10
0
 public function invoke($arrInput)
 {
     //用于登录
     $row = array();
     $row['type'] = $arrInput['type'];
     $row['title'] = $arrInput['title'];
     $cids = $arrInput['cids'];
     if ($arrInput['content']) {
         $row['content'] = stripslashes($arrInput['content']);
     }
     if ($arrInput['ria_content']) {
         $row['ria_content'] = stripslashes($arrInput['ria_content']);
     }
     if (is_numeric($arrInput['start_time'])) {
         $row['start_time'] = intval($arrInput['start_time']);
     } else {
         $row['start_time'] = strtotime($arrInput['start_time']);
     }
     if (is_numeric($arrInput['stop_time'])) {
         $row['stop_time'] = intval($arrInput['stop_time']);
     } else {
         $row['stop_time'] = strtotime($arrInput['stop_time']);
     }
     if (isset($arrInput['is_push'])) {
         $row['is_push'] = $arrInput['is_push'];
     } else {
         $row['is_push'] = 0;
     }
     $row['push_title'] = $arrInput['push_title'] ? $arrInput['push_title'] : '';
     $row['cid'] = 0;
     $row['os'] = isset($arrInput['os']) ? $arrInput['os'] : -1;
     if (isset($arrInput['push_cond']) && $arrInput['push_cond'] == 0 && $arrInput['app_version']) {
         //按版本推送
         $row['app_version'] = $arrInput['app_version'];
     } else {
         //按城市推送
         $city_ids = array();
         if ($cids) {
             //过略重复,避免重复推送
             foreach ($cids as $k => $v) {
                 $v = intval($v);
                 if ($v == 0) {
                     //全国
                     $city_ids = array();
                     break;
                 }
                 $city_ids[$v] = $v;
             }
         }
         if ($city_ids) {
             sort($city_ids);
             $opt['city_list'] = $city_ids;
             $row['opt'] = json_encode($opt);
         }
     }
     $row['position'] = $arrInput['position'] ? $arrInput['position'] : 0;
     if ($arrInput['link']) {
         $row['link'] = $arrInput['link'];
     }
     if ($arrInput['from_title']) {
         $row['from_type'] = 1;
         $row['from_title'] = $arrInput['from_title'];
     }
     foreach ($_FILES as $k => $v) {
         if ($v['error'] === 0) {
             //文件上传成功
             if (strpos($v['type'], 'image') !== 0) {
                 return array('errno' => 1, "errmsg" => '上传文件不是图片');
             }
             $imgurl = Net_Util::uploadPic($v);
             if ($imgurl === false) {
                 return array('errno' => 1, "errmsg" => "图片上传百度云失败");
             }
             $row[$k] = $imgurl;
         }
     }
     $row['status'] = isset($arrInput['status']) ? $arrInput['status'] : 0;
     $dataService = new Service_Data_Message_V2_Message();
     $ret = $dataService->addMessage($row);
     if ($ret) {
         // 如果是来自情报系统,则需要反调其接口通知状态
         if ($arrInput['timestamp']) {
             $callRet = Net_Util::updateIntelligenceStatus($arrInput['timestamp'], 2);
             if (!$callRet) {
                 $errmsg = "\\n通知情报系统失败";
             }
         }
         //获取短连接
         $lastId = $dataService->getInsertId();
         $linkInfo['id'] = $lastId;
         $linkInfo['type'] = $row['type'];
         $linkInfo['origin'] = 'share';
         $messgeLink = Net_Util::getMessageLink($linkInfo);
         $update['opt'] = $opt['shortUrl'] = Net_Util::shortUrl($messgeLink);
         $ret = $dataService->updateMessage($lastId, $update);
         return array('errno' => 0, 'errmsg' => '添加成功' . $errmsg);
     }
     return array('errno' => 1, 'errmsg' => '添加失败' . $errmsg);
 }
Example #11
0
 public function invoke($arrInput)
 {
     //用于登录
     $id = (int) $arrInput['id'];
     $dataService = new Service_Data_Message_V2_Message();
     $data = $dataService->get_operation_message_details($id);
     $message = $data[0];
     if (!$message) {
         return array('errno' => '1', 'errmsg' => 'message not found');
     }
     $cid = $message['cid'];
     $opt = json_decode($message['opt'], true);
     $app_version = $message['app_versiont'];
     if (!$opt['push_response']) {
         return array('errno' => 1, 'errmsg' => '暂无统计');
     }
     // push_reponse 是以city_code 作为键值
     // "push_response":{"131":{"3":["msgid#8452819436143893891"],"4":["msgid#1259143845097668564"]},"289":{"3":["msgid#7402617256944954515"],"4":["msgid#2232901761059640260"]},"340":{"3":["msgid#7206400091464665875"],"4":["msgid#4420386400034273812"]}}
     // {"3":["msgid#3386917452281572931"],"4":["msgid#2528194748361896020"]} 全国推或者按照版本推
     $broadcast = array();
     $group = array();
     $reponses = $opt['push_response'];
     foreach ($reponses as $k => $v) {
         if ($k == 0 && !$app_version) {
             //广播
             $broadcast = $v;
         }
         if ($k == 0 && $app_version) {
             //按版本号推送
             $group['ver_' . $app_version] = $v;
         }
         if ($k > 0) {
             //按城市的组播
             $group[$k] = $v;
         }
     }
     $rebroadcast = $regroup = array();
     if ($broadcast) {
         // 查询广播绑定人数
         // 广播成功接收用户数,只有android数据
         foreach ($broadcast as $os => $msids) {
             //目前只有一个
             foreach ($msids as $msgid) {
                 $id = $this->stripMsgid($msgid);
                 $ret = Net_Util::getMsgCountByResourceId($id);
                 foreach ($ret['ack_counts'] as $t => $cnt) {
                     $rebroadcast['detail'][$os]['count'] += $cnt;
                     $rebroadcast['sum'] += $cnt;
                 }
             }
         }
     }
     //组播
     if ($group) {
         foreach ($group as $tag => $msgids) {
             $ret = Net_Util::getUserCountByTag($tag);
             if ($ret) {
                 // ios and android
                 foreach ($msgids as $os => $srcIDs) {
                     //其实只有一个msgid
                     foreach ($srcIDs as $oneID) {
                         $msgid = $this->stripMsgid($oneID);
                         $tagCntReturn = Net_Util::getGroupMesageArriveCount($ret['tid'], $msgid);
                         $regroup['tags'][$tag]['os'][$os]['usercount'] += $tagCntReturn['usercount'];
                         $regroup['tags'][$tag]['os'][$os]['success_count'] += $tagCntReturn['success_count'];
                         $regroup['tags'][$tag]['sum']['usercount'] = $tagCntReturn['usercount'];
                         $regroup['tags'][$tag]['sum']['success_count'] += $tagCntReturn['success_count'];
                         //其实 ios 和 android 返回的usercount是一样的,表示tag的绑定用户数
                         $regroup['sum']['usercount'] += $tagCntReturn['usercount'];
                         $regroup['sum']['success_count'] += $tagCntReturn['success_count'];
                     }
                 }
             }
         }
         $regroup['sum']['usercount'] = $regroup['sum']['usercount'] >> 1;
         //算重了
     }
     $return['errno'] = 0;
     $return['data']['broadcast'] = $rebroadcast;
     $return['data']['group'] = $regroup;
     return $return;
 }
 public function invoke($arrInput)
 {
     //用于登录
     $row = array();
     $row['type'] = $arrInput['type'];
     $row['title'] = $arrInput['title'];
     $id = $arrInput['id'];
     $cids = $arrInput['cids'];
     $dataService = new Service_Data_Message_V2_Message();
     $Message = $dataService->get_operation_message_details($id);
     $Message = $Message[0];
     $allow_column = array('title', 'content', 'ria_content', 'stop_time', 'from_type', 'from_title', 'link');
     //发布之后只能修改的列
     $opt = $Message['opt'] ? json_decode($Message['opt'], true) : array();
     if (empty($Message)) {
         return array('errno' => 1, 'errmsg' => '运营消息不存在');
     }
     if ($arrInput['content']) {
         $row['content'] = stripslashes($arrInput['content']);
     }
     if ($arrInput['ria_content']) {
         $row['ria_content'] = stripslashes($arrInput['ria_content']);
     }
     if (is_numeric($arrInput['start_time'])) {
         $row['start_time'] = intval($arrInput['start_time']);
     } else {
         $row['start_time'] = strtotime($arrInput['start_time']);
     }
     if (is_numeric($arrInput['stop_time'])) {
         $row['stop_time'] = intval($arrInput['stop_time']);
     } else {
         $row['stop_time'] = strtotime($arrInput['stop_time']);
     }
     if (isset($arrInput['is_push'])) {
         $row['is_push'] = $arrInput['is_push'];
     } else {
         $row['is_push'] = 0;
     }
     $row['push_title'] = $arrInput['push_title'] ? $arrInput['push_title'] : '';
     $row['os'] = isset($arrInput['os']) ? $arrInput['os'] : -1;
     if (isset($arrInput['push_cond']) && $arrInput['push_cond'] == 0 && $arrInput['app_version']) {
         //按版本推送
         $row['app_version'] = $arrInput['app_version'];
         $row['cid'] = 0;
         $opt['city_list'] = array();
         $row['opt'] = json_encode($opt);
     } else {
         //按城市推送
         $row['app_version'] = '';
         $city_ids = array();
         if ($cids) {
             //过略重复,避免重复推送
             foreach ($cids as $k => $v) {
                 $v = intval($v);
                 if ($v == 0) {
                     //全国
                     $city_ids = array();
                     break;
                 }
                 $city_ids[$v] = $v;
             }
         }
         if ($city_ids) {
             sort($city_ids);
             $opt['city_list'] = $city_ids;
             $row['opt'] = json_encode($opt);
         }
     }
     $row['position'] = $arrInput['position'] ? $arrInput['position'] : 0;
     if ($arrInput['link']) {
         $row['link'] = $arrInput['link'];
     }
     if ($arrInput['from_type'] && $arrInput['from_title']) {
         $row['from_type'] = 1;
         $row['from_title'] = $arrInput['from_title'];
     } else {
         $row['from_type'] = 0;
         $row['from_title'] = '百度导航';
     }
     foreach ($_FILES as $k => $v) {
         if ($v['error'] === 0) {
             //文件上传成功
             if (strpos($v['type'], 'image') !== 0) {
                 return array('errno' => 1, "errmsg" => '上传文件不是图片');
             }
             $imgurl = Net_Util::uploadPic($v);
             if ($imgurl === false) {
                 return array('errno' => 1, "errmsg" => "图片上传百度云失败");
             }
             $row[$k] = $imgurl;
             $allow_column[] = $k;
         }
     }
     $row['status'] = isset($arrInput['status']) ? $arrInput['status'] : 0;
     if ($Message['status'] == 1) {
         //发布状态只能修改标题和内容
         $allow_row = array();
         foreach ($allow_column as $v) {
             $allow_row[$v] = $row[$v];
         }
         $row = $allow_row;
         $exat_message = "\\n[发布状态只能修改标题,内容,图片,来源]";
     }
     if (isset($arrInput['shortUrl']) && strpos($arrInput['shortUrl'], 'http') === 0) {
         $opt['shortUrl'] = trim($arrInput['shortUrl']);
     } else {
         $linkInfo['id'] = $id;
         $linkInfo['type'] = $row['type'];
         $linkInfo['origin'] = 'share';
         $messgeLink = Net_Util::getMessageLink($linkInfo);
         $shortUrl = Net_Util::shortUrl($messgeLink);
         if ($shortUrl == false) {
             $shortUrl = Net_Util::thirdShortUrl($messgeLink);
         }
         $opt['shortUrl'] = $shortUrl;
     }
     $row['opt'] = json_encode($opt);
     $ret = $dataService->updateMessage($id, $row);
     if ($ret) {
         return array('errno' => 0, 'errmsg' => '修改成功' . $exat_message);
     }
     return array('errno' => 1, 'errmsg' => '没有修改' . $exat_message);
 }