private function _runAction($params) { extract($params); $isSaveSuccess = false; $image = $avatar; if (!empty($image) && ($imageData = WebUtils::httpRequest($image)) != '') { $savePath = UploadUtils::getTempAvatarPath(); if (!empty($savePath)) { $config = Yii::app()->params['mobcent']['user']; $this->_deleteTempAvatarFiles($uid); $avatarFiles = $this->_getTempAvatarFiles($uid); $avatarBigFile = $savePath . '/' . $avatarFiles['big']; $avatarMidFile = $savePath . '/' . $avatarFiles['mid']; $avatarSmallFile = $savePath . '/' . $avatarFiles['small']; file_put_contents($avatarBigFile, $imageData); file_put_contents($avatarMidFile, $imageData); file_put_contents($avatarSmallFile, $imageData); require_once MOBCENT_APP_ROOT . '/components/discuz/source/class/class_image.php'; $thumb = new Mobcent_Image(); $zoomRes = true; $zoomRes &= $thumb->makeThumb($avatarBigFile, '', $config['avatarBigLength']); $zoomRes &= $thumb->makeThumb($avatarMidFile, '', $config['avatarMidLength']); $zoomRes &= $thumb->makeThumb($avatarSmallFile, '', $config['avatarSmallLength']); $isSaveSuccess = $zoomRes && $this->_saveAvatarByUcenter($uid, $this->flashdata_encode(file_get_contents($avatarBigFile)), $this->flashdata_encode(file_get_contents($avatarMidFile)), $this->flashdata_encode(file_get_contents($avatarSmallFile))); $this->_deleteTempAvatarFiles($uid); } } if ($isSaveSuccess) { $this->_updateAvatarStatus(); return $res; } else { return WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('保存文件失败')); } // return $isSaveSuccess ? $res : WebUtils::makeErrorInfo_oldVersion($res, WebUtils::t('保存文件失败')); }
public static function getAppLevel() { $appId = self::getAppId(); // $appId = 'o8n5mW6eo6AP8A5Hmb'; // $appId = 'pmjAXPiqj7RKAiPrbL'; $url = sprintf('http://sdk.mobcent.com/baikesdk/pay/payState.do?gzip=0&forumKey=%s', $appId); $data = WebUtils::jsonDecode(WebUtils::httpRequest($url, 10)); return (int) (isset($data['data']['paystate']['user_defined']) ? $data['data']['paystate']['user_defined'] : self::LEVEL_FREE); }
private function _doNewApp($res, $appKey, $test) { // $url = 'http://192.168.1.211:9797/mobcentACA/app/wAMkQjefj3HPHsrfCk/profile'; $url = 'http://www.appbyme.com/mobcentACA/app/' . $appKey . '/profile'; $temRes = WebUtils::httpRequest($url, 30); $temRes = WebUtils::jsonDecode($temRes); $appInfo = array('appName' => WebUtils::t($temRes['appName']), 'appAuthor' => WebUtils::t($temRes['appAuthor']), 'appDescribe' => WebUtils::t($temRes['appDescribtion']), 'appVersion' => WebUtils::t($temRes['appVersion']), 'appIcon' => $temRes['appIcon'], 'appImage' => $temRes['appCover'], 'appContentId' => $temRes['contentId'], 'appDownloadUrl' => array('android' => $temRes['apkUrl'], 'apple' => $temRes['ipaUrl'], 'appleMobile' => $temRes['plistUrl']), 'appQRCode' => array('android' => $temRes['qrcode'], 'apple' => $temRes['qrcode'])); if ($test == 0) { AppbymeConfig::saveDownloadOptions($appInfo); AppbymeConfig::saveForumkey($temRes['forumKey']); } return $res; }
private function _getWeatherConfig() { $weather = array('allowUsage' => 1, 'allowCityQuery' => 1); $forumKey = isset($_GET['forumKey']) ? $_GET['forumKey'] : ''; $platType = isset($_GET['platType']) ? $_GET['platType'] : APP_TYPE_ANDROID; $url = 'http://sdk.mobcent.com/baikesdk/phpapi/settings'; // $url = 'http://192.168.1.213/forum/phpapi/settings'; $url .= sprintf('?forumKey=%s&platType=%s&gzip=false', $forumKey, $platType); $res = WebUtils::httpRequest($url, 10); $res = WebUtils::jsonDecode($res); isset($res['data']['weather']['show_weather']) && ($weather['allowUsage'] = (int) $res['data']['weather']['show_weather']); isset($res['data']['weather']['city_query_setting']) && ($weather['allowCityQuery'] = (int) $res['data']['weather']['city_query_setting']); return $weather; }
<?php /** * component_mobile_ui_forumlist view * * @author hongliang * @copyright 2012-2014 Appbyme */ $fid = $component['extParams']['forumId']; $url = $this->rootUrl . "/index.php?r=forum/forumlist&fid=" . $fid; $info = WebUtils::httpRequest($url, 30); $info = WebUtils::jsondecode($info); ?> <div class="content-list-ui content-list-add"> <?php foreach ($info['list'] as $k => $v) { ?> <div class="row"> <div class="board-name"> <span><?php echo $v['board_category_name']; ?> </span> </div> <?php foreach ($v['board_list'] as $kk => $vv) { if ($v['board_category_type'] == 2) { ?> <div class="col-xs-6 double-div uidiy-mobileui-component" data-component-data="<?php $component['title'] = '帖子列表';
public static function httpRequestAppAPI($route, $params = array(), $timeout = 20) { $url = WebUtils::createUrl_oldVersion($route, $params); return WebUtils::httpRequest($url, $timeout); }
public function getCaption($api_token, $job_id, $caption_format, $caption_options = null) { $query_dict = $this->_initJobReqDict($api_token, $job_id); $query_dict['caption_format'] = $caption_format; if ($caption_options != null) { $query_dict += $caption_options->getDictionary(); } $response = WebUtils::httpRequest($this->BASE_URL, Actions::GET_CAPTION_PATH, "GET", WebUtils::DOWNLOAD_TIMEOUT, $query_dict); if ($caption_options != null && $caption_options->build_url != null && $caption_options->build_url) { return json_decode($response, true)["CaptionUrl"]; } else { return $response; // Return raw caption text } }
public static function getThumbImageEx($image, $timeout = 15, $getImageInfo = false, $inBackgroud = false, $force = false) { $res = array('image' => $image, 'ratio' => '1'); if (empty($image)) { return $res; } $config = self::_getThumbConfig(); $allowDiscuzThumb = WebUtils::getDzPluginAppbymeAppConfig('image_thumb_allow_discuz'); if (!$force && !$config['isThumb'] && $allowDiscuzThumb < 0) { return $res; } $thumbImage = $image; global $_G; $attachFile = ''; // 是否用discuz生成的缩略图 if ($allowDiscuzThumb === false || $allowDiscuzThumb > 0) { if ($_G['setting']['ftp']['on'] == 0) { $attachUrl = self::getAttachUrl(); $attachUrl = str_replace($attachUrl, '', $image); $attachFile = $_G['setting']['attachdir'] . $attachUrl; $attachThumbFile = $attachFile . self::DISCUZ_THUMB_SUFFIX; if (file_exists($attachThumbFile)) { $res['image'] = $thumbImage . self::DISCUZ_THUMB_SUFFIX; if ($getImageInfo) { $imageInfo = ImageUtils::getImageInfo($attachThumbFile); $res['ratio'] = $imageInfo['ratio']; } return $res; } } } if (!$force && !$config['isThumb']) { return $res; } // 获取缩略图文件名 $savePath = sprintf('%s/%s', MOBCENT_THUMB_PATH, self::_getThumbTempPath($image)); $tempFileName = self::_getThumbTempFile($image); $smallFileName = $savePath . '/mobcentSmallPreview_' . $tempFileName; $bigFileName = $savePath . '/mobcentBigPreview_' . $tempFileName; if (file_exists($smallFileName) && file_exists($bigFileName)) { $res['image'] = self::_getThumbUrlFile($image, $tempFileName); if ($getImageInfo) { $imageInfo = ImageUtils::getImageInfo($smallFileName); $res['ratio'] = $imageInfo['ratio']; } return $res; } if ($inBackgroud) { CacheUtils::addThumbTaskList($image); return $res; } if (!is_dir($savePath)) { mkdir($savePath, 0777, true); } if (is_writable($savePath)) { // $timer = new CountTimer; // 先查看是否是本地附件的图片, 如果不是才去网络取图片数据 $imageData = ''; if ($attachFile != '' && file_exists($attachFile)) { $imageData = file_get_contents($attachFile); } if ($imageData == '') { $imageData = WebUtils::httpRequest($image, $timeout); if ($imageData == '') { return $res; } } $thumb = null; $zoomRes = true; require_once MOBCENT_APP_ROOT . '/components/discuz/source/class/class_image.php'; if (!file_exists($smallFileName)) { if (file_put_contents($smallFileName, $imageData) == false) { return $res; } $thumb = new Mobcent_Image(); $zoomRes &= $thumb->makeThumb($smallFileName, '', $config['imageSmallLength']); } if (!file_exists($bigFileName)) { if (file_put_contents($bigFileName, $imageData) == false) { return $res; } $thumb == null && ($thumb = new Mobcent_Image()); $zoomRes &= $thumb->makeThumb($bigFileName, '', $config['imageBigLength']); } if (file_exists($smallFileName) && file_exists($bigFileName) && $zoomRes) { $thumbImage = self::_getThumbUrlFile($image, $tempFileName); if ($getImageInfo) { $imageInfo = ImageUtils::getImageInfo($smallFileName); $res['ratio'] = $imageInfo['ratio']; } } else { FileUtils::safeDeleteFile($smallFileName); FileUtils::safeDeleteFile($bigFileName); } // var_dump($timer->stop()); } $res['image'] = $thumbImage; return $res; }
private function _doPostStatistics($act) { $forumKey = isset($_GET['forumKey']) ? $_GET['forumKey'] : ''; $platType = isset($_GET['platType']) ? $_GET['platType'] : APP_TYPE_ANDROID; $isReplyPost = $act == 'new' ? 0 : 1; $url = "http://sdk.mobcent.com/imsdk/post/postLog.do?forumKey=" . $forumKey . "&platType=" . $platType . "&isReplyPost=" . $isReplyPost; WebUtils::httpRequest($url, 5); }
private function _zhSearchData($kw, $page, $pagesize, $res, $searchparams) { $keyword = dhtmlspecialchars(trim($kw)); $keyword = WebUtils::t($keyword); require_once libfile('function/search'); require_once libfile('function/misc'); require_once libfile('function/post'); // $searchHelper = Cloud::loadClass('Service_SearchHelper'); // $searchparams = $searchHelper->makeSearchSignUrl(); $appService = Cloud::loadClass('Service_App'); if ($appService->getCloudAppStatus('search') && $searchparams) { $source = 'discuz'; $params = array(); $params['source'] = $source; $params['q'] = $keyword; $params['module'] = 'forum'; $searchparams['params'] = array_merge($searchparams['params'], $params); $utilService = Cloud::loadClass('Service_Util'); $url = $searchparams['url'] . '?' . $utilService->httpBuildQuery($searchparams['params'], '', '&'); } $url = $url . '&page=' . $page; // $pageInfo = WebUtils::emptyReturnLine(file_get_contents($url)); $pageInfo = WebUtils::emptyReturnLine(WebUtils::httpRequest($url)); $pregIds = '/&tid=(\\d*)"/'; $pregCount = '/<div class="allnum">(.*?)<\\/div>/'; //取出搜索结果总数 preg_match_all($pregIds, $pageInfo, $id); $ids = $id[1]; if (empty($ids)) { return WebUtils::makeErrorInfo_oldVersion($res, 'search_no_results'); } preg_match_all($pregCount, $pageInfo, $count); $countStr = trim($count[1][0]); preg_match_all('/\\d/', $countStr, $total); $total_num = (int) str_replace(',', '', implode(',', $total[0])); $ids = $id[1]; $data = $topicInfo = $topicSummary = array(); foreach ($ids as $v) { $topicInfo = ForumUtils::getTopicInfo($v); // $topicInfo['lastpost'] = dgmdate($topicInfo['lastpost'], 'u'); $topicInfos[] = $topicInfo; } unset($ids); $rows = $this->_fieldInfo($topicInfos); $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, 10, $total_num); $res['searchid'] = 0; $res = array_merge($res, $pageInfo); $res['list'] = $rows; return $res; }