Пример #1
0
 public function run($boardId = 0, $page = 1, $pageSize = 10, $sortby = 'all', $filterType = '', $filterId = 0, $isImageList = 0, $topOrder = 0)
 {
     switch ($boardId) {
         case -1:
             $sortby = 'new';
             $boardId = 0;
             break;
         case -2:
             $sortby = 'marrow';
             $boardId = 0;
             break;
         case -3:
             $sortby = 'photo';
             $boardId = 0;
             break;
     }
     $sortby == '' && ($sortby = 'all');
     $sortMaps = array('publish' => 'new', 'essence' => 'marrow', 'top' => 'top', 'new' => 'new', 'marrow' => 'marrow', 'all' => 'all', 'photo' => 'photo');
     $sort = $sortby;
     $sort = isset($sortMaps[$sort]) ? $sortMaps[$sort] : '';
     $fid = (int) $boardId;
     global $_G;
     $key = CacheUtils::getTopicListKey(array($fid, $_G['groupid'], $page, $pageSize, $sort, $filterType, $filterId, $isImageList, $topOrder));
     $this->runWithCache($key, array('fid' => $fid, 'page' => $page, 'pageSize' => $pageSize, 'sort' => $sort, 'filterType' => $filterType, 'filterId' => $filterId, 'isImageList' => $isImageList, 'topOrder' => $topOrder));
     // Mobcent::dumpSql();
 }
Пример #2
0
 public function actionRewardEdit($id = 0)
 {
     if (!empty($_POST)) {
         $sponsor = isset($_POST['sponsor']) ? $_POST['sponsor'] : '';
         $startTime = isset($_POST['startTime']) ? strtotime($_POST['startTime']) : '';
         $stopTime = isset($_POST['stopTime']) ? strtotime($_POST['stopTime']) : '';
         $firstReward = isset($_POST['firstReward']) ? $_POST['firstReward'] : '';
         $inviteReward = isset($_POST['inviteReward']) ? $_POST['inviteReward'] : '';
         $exchangeMin = isset($_POST['exchangeMin']) ? $_POST['exchangeMin'] : '';
         // $exchangeType = isset($_POST['exchangeType']) ? $_POST['exchangeType'] : '';
         $virtualName = isset($_POST['virtualName']) ? $_POST['virtualName'] : '';
         $exchangeRatio = isset($_POST['exchangeRatio']) ? $_POST['exchangeRatio'] : '';
         $limitUser = isset($_POST['limitUser']) ? $_POST['limitUser'] : '';
         $limitDevice = isset($_POST['limitDevice']) ? $_POST['limitDevice'] : '';
         $limitTime = isset($_POST['limitTime']) ? $_POST['limitTime'] : '';
         $limitDays = isset($_POST['limitDays']) ? $_POST['limitDays'] : '';
         $limitNum = isset($_POST['limitNum']) ? $_POST['limitNum'] : '';
         $activityRule = isset($_POST['activityRule']) ? $_POST['activityRule'] : '';
         $shareAppUrl = isset($_POST['shareAppUrl']) ? $_POST['shareAppUrl'] : '';
         if ($limitDays == '') {
             $limitDays = abs($startTime - $stopTime) / 3600 / 24;
         }
         $updateRewardInvite = array('sponsor' => WebUtils::t($sponsor), 'start_time' => $startTime, 'stop_time' => $stopTime, 'first_reward' => $firstReward, 'invite_reward' => $inviteReward, 'exchange_min' => $exchangeMin, 'virtual_name' => WebUtils::t($virtualName), 'exchange_ratio' => $exchangeRatio, 'limit_user' => $limitUser, 'limit_device' => $limitDevice, 'limit_time' => $limitTime, 'limit_days' => $limitDays, 'limit_num' => $limitNum, 'activity_rule' => $activityRule, 'share_appurl' => $shareAppUrl);
         $activityId = $_POST['activityId'];
         AppbymeActivityInviteModel::updateActivityInvite($activityId, $updateRewardInvite);
         $cacheKey = CacheUtils::getActivityInviteKey(array('invite', $activityId));
         Yii::app()->cache->delete($cacheKey);
         header('location:' . $this->rootUrl . '/index.php?r=admin/reward/rewardlist');
     }
     $inviteInfo = AppbymeActivityInviteModel::getActivityInviteById($id);
     $this->renderPartial('rewardedit', array('inviteInfo' => $inviteInfo));
 }
Пример #3
0
 public static function getInviteConfig($activityId)
 {
     $key = CacheUtils::getActivityInviteKey(array('invite', $activityId));
     $config = Yii::app()->cache->get($key);
     if ($config === false) {
         $config = AppbymeActivityInviteModel::getActivityInviteById($activityId);
         Yii::app()->cache->set($key, $config);
     }
     return $config;
 }
Пример #4
0
 public static function addThumbTaskList($image)
 {
     $thumbTaskList = CacheUtils::getDzPluginCache('thumb_task_list', true);
     $maxCount = WebUtils::getDzPluginAppbymeAppConfig('image_thumb_task_max_length');
     $maxCount === false && ($maxCount = 20);
     if ($maxCount == 0 || $maxCount > count($thumbTaskList)) {
         $thumbTaskList[md5($image)] = $image;
     }
     CacheUtils::setDzPluginCache('thumb_task_list', $thumbTaskList, false);
 }
Пример #5
0
 public function run($fid = 0, $type = '')
 {
     global $_G;
     if ($type == 'rec') {
         $res = $this->getResult(array('fid' => $fid, 'type' => $type));
         echo WebUtils::outputWebApi($res, '', true);
     }
     $key = CacheUtils::getForumListKey(array($fid, $_G['groupid'], $type));
     $this->runWithCache($key, array('fid' => $fid));
 }
Пример #6
0
 public function run($moduleId, $page = 1, $pageSize = 10, $longitude = '', $latitude = '', $radius = 100000, $isImageList = 0)
 {
     $getKeyArray = array('mid' => $moduleId, 'page' => $page, 'pageSize' => $pageSize, 'longitude' => $longitude, 'latitude' => $latitude, 'radius' => $radius, 'isImageList' => $isImageList);
     $filter = unserialize(AppbymePoralModule::getModuleParam($moduleId));
     if (is_array($filter['other_filter']) || $filter['topic_orderby'] == 'distance') {
         $res = $this->getResult($getKeyArray);
         echo WebUtils::outputWebApi($res, '', true);
     }
     $key = CacheUtils::getNewsListKey(array($moduleId, $page, $pageSize, $isImageList));
     $this->runWithCache($key, $getKeyArray);
 }
Пример #7
0
 public function setByReference($scope_id, $reference, $type = null)
 {
     $contents = CacheUtils::fetch($reference);
     if (!$contents) {
         return false;
     } else {
         if ($type != null && !array_key_exists($contents['content_type'], $type)) {
             return false;
         }
         return $this->memcache->set($this->makeKey($scope_id, $key), $contents, MEMCACHE_COMPRESSED, $this->expires);
     }
 }
Пример #8
0
 public function setByReference($scope_id, $reference, $type = null)
 {
     // TODO make sure valid content
     try {
         $contents = CacheUtils::fetch($reference);
         if ($contents === false) {
             return false;
         } else {
             if ($contents['http_code'] != '200') {
                 return false;
             } else {
                 if ($type != null && !in_array($contents['content_type'], $type)) {
                     return false;
                 } else {
                     $result = file_put_contents($this->getFilename($scope_id, $key, ".unknown"), $contents);
                     return $result;
                 }
             }
         }
     } catch (Exception $exception) {
         return false;
     }
 }
Пример #9
0
 public function actionMakeThumb($count = 10)
 {
     $thumbTaskList = CacheUtils::getDzPluginCache('thumb_task_list');
     $thumbTaskList === false && ($thumbTaskList = array());
     $count <= 0 && ($count = count($thumbTaskList));
     $count = min(count($thumbTaskList), $count);
     $i = 0;
     foreach ($thumbTaskList as $key => $thumb) {
         if ($i >= $count) {
             break;
         }
         ImageUtils::getThumbImageEx($thumb, 20, false, false, true);
         $i++;
     }
     echo WebUtils::jsonEncode($thumbTaskList);
     array_splice($thumbTaskList, 0, $count);
     CacheUtils::setDzPluginCache('thumb_task_list', $thumbTaskList);
 }
Пример #10
0
 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;
 }
Пример #11
0
 public function setByReference($scope_id, $reference, $type = null)
 {
     // TODO make sure valid content
     try {
         $contents = CacheUtils::fetch($reference);
         if ($contents === false) {
             return false;
         } else {
             if ($contents['http_code'] != '200') {
                 return false;
             } else {
                 if ($type != null && !in_array($contents['content_type'], $type)) {
                     return false;
                 } else {
                     $result = $this->cache->save($contents['body'], $this->makeKey($scope_id, $reference));
                     return $result;
                 }
             }
         }
     } catch (Exception $exception) {
         return false;
     }
 }
Пример #12
0
 public function run($fid = 0)
 {
     global $_G;
     $key = CacheUtils::getForumListKey(array($fid, $_G['groupid']));
     $this->runWithCache($key, array('fid' => $fid));
 }