Ejemplo n.º 1
0
 /**
  * 初始化
  * @see CController::init()
  */
 public function init()
 {
     parent::init();
     //前端控制器在此获得分类,从顶级分类(0)开始分层往下取,得到所有层次的分类
     //        ppr(XXcache::system('_catalog')); //这里是遍历出来未按照从属排序
     //        ppr($this->_catalog); //这里重新按从属排序
     $this->_catalog = Catalog::get(0, XXcache::system('_catalog'));
     //系统配置
     $this->_conf = XXcache::system('_config');
     $this->_seoTitle = $this->_conf['seo_title'];
     $this->_seoKeywords = $this->_conf['seo_keywords'];
     $this->_seoDescription = $this->_conf['seo_description'];
     if ($this->_conf['site_status'] == 'close') {
         self::_closed();
     }
     $this->_thisUrl = higu();
     if ($this->_conf['cache_page_status'] == 'open') {
         $value = Yii::app()->cache->get($this->_thisUrl);
         if ($value === false) {
             echo 'nocache';
         } else {
             echo 'cache';
             echo $value;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 初始化
  * @see CController::init()
  */
 public function init()
 {
     parent::init();
     //检测系统是否已经安装
     if (!is_file(WWWPATH . DS . 'data' . DS . 'install.lock')) {
         $this->redirect(array('/install'));
     }
     //系统配置
     $this->_conf = XXcache::system('_config');
     $this->_catalog = Catalog::get(0, XXcache::system('_catalog'));
     $this->_seoTitle = $this->_conf['seo_title'];
     $this->_seoKeywords = $this->_conf['seo_keywords'];
     $this->_seoDescription = $this->_conf['seo_description'];
     if ($this->_conf['site_status'] == 'close') {
         self::_closed();
     }
 }
Ejemplo n.º 3
0
 /**
  * 更新数据表数据
  */
 private function _updateData($data)
 {
     if (XUtils::method() == 'POST') {
         if (!empty($_FILES['site_logo']['name'])) {
             $this->_getLogo('site_logo', SITE_PATH . 'static/', $data['site_logo']);
         } else {
             unset($data['site_logo']);
         }
         foreach ((array) $data as $key => $row) {
             $row = XUtils::addslashes($row);
             Yii::app()->db->createCommand("REPLACE INTO {{config}}(`variable`, `value`) VALUES('{$key}', '{$row}') ")->execute();
         }
         XXcache::refresh('_config', 3600);
         parent::_backendLogger(array('catalog' => 'update', 'intro' => '更新系统配置,模块:' . $this->action->id));
         XUtils::message('success', '更新完成', $this->createUrl($this->action->id));
     }
 }
Ejemplo n.º 4
0
 /**
  * 缓存更新
  */
 public function actionCacheUpdate()
 {
     $scope = $this->_gets->getParam('scope');
     try {
         if (is_array($scope)) {
             foreach ($scope as $key => $row) {
                 XXcache::refresh($row, 3600);
             }
             $var['state'] = 'success';
             $var['message'] = '操作完成';
         } else {
             throw new Exception('请选择要更新的内容');
         }
     } catch (Exception $e) {
         $var['state'] = 'error';
         $var['message'] = '操作失败:' . $e->getMessage();
     }
     exit(CJSON::encode($var));
 }
Ejemplo n.º 5
0
 /**
  * 单页更新
  *
  * @param $id        	
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Page(), $id);
     if (isset($_POST['Page'])) {
         $model->attributes = $_POST['Page'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(200, 180)));
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             $model->attach_thumb = $file['paththumbname'];
             @unlink($_POST['oAttach']);
             @unlink($_POST['oThumb']);
         }
         if ($model->save()) {
             XXcache::refresh('_link');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑单页,ID:' . $id));
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Ejemplo n.º 6
0
 /**
  * 编辑
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl('catalog_update');
     $model = new Catalog();
     $parentId = intval($_POST['Catalog']['parent_id']);
     $model = parent::_dataLoad(new Catalog(), $id);
     if (isset($_POST['Catalog'])) {
         self::parentTrue($id, $parentId);
         $model->attributes = $_POST['Catalog'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->image = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         if ($model->save()) {
             XXcache::refresh('_catalog');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑类别,ID:' . $id . ',名称:' . $model->catalog_name));
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Ejemplo n.º 7
0
 /**
  * 更新广告
  */
 public function actionAdUpdate($id)
 {
     parent::_acl('ad_update');
     $model = parent::_dataLoad(new Ad(), $id);
     if (isset($_POST['Ad'])) {
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             @unlink($_POST['oAttach']);
         }
         $model->attributes = $_POST['Ad'];
         $model->expired_time = intval(strtotime($model->expired_time));
         $model->start_time = intval(strtotime($model->start_time));
         if ($model->save()) {
             XXcache::refresh('_ad');
             AdminLogger::_create(array('catalog' => 'update', 'intro' => '编辑广告,ID:' . $id));
             $this->redirect(array('ad'));
         }
     }
     $model->expired_time = date('Y-m-d', $model->expired_time);
     $model->start_time = date('Y-m-d', $model->start_time);
     $this->render('ad_update', array('model' => $model));
 }
Ejemplo n.º 8
0
 /**
  * 取单条记录
  * @param $catalog
  * @param array $array
  */
 public static function item($id, array $array = array())
 {
     if (empty($id)) {
         return;
     }
     $eachArr = empty($array) ? XXcache::system('_catalog', 86400) : $array;
     foreach ((array) $eachArr as $row) {
         if ($row['id'] == $id) {
             return $row;
         }
     }
 }
Ejemplo n.º 9
0
 private function doTb($tid, $cid = 0)
 {
     if ($tid == 2610) {
         //彩票部分
         $cacheId = 'doTb_' . $tid;
         $fcurl = cacheGet($cacheId);
         if (empty($fcurl)) {
             $url = 'http://www.114la.com/icai.json';
             $fcurl = XUtils::fcurl($url);
             cacheSet($cacheId, $fcurl, 3600);
         }
         $fcurl = substr($fcurl, 17, -1);
         $data_arr = json_decode($fcurl, TRUE);
         if (!empty($data_arr)) {
             //对应关系
             $dy = array('ssq' => array(220, 221, 222), 'dlt' => array(223, 224, 225), 'fc3d' => array(226, 227, 228), 'jx_11x5' => array(229, 230, 231));
             foreach ($data_arr as $tp => $v) {
                 $va = $v[0];
                 $fdata[$dy[$tp][0]] = array(0 => array('title' => '上期开奖号码', 'link' => $va['url'][0], 'opt_a' => implode(',', $va['result']), 'opt_b' => $va['phase'], 'opt_c' => $va['date']));
                 $fdata[$dy[$tp][1]] = array(0 => array('title' => '立即投注', 'link' => $va['url'][1]), 1 => array('title' => $va['chain'][0], 'link' => $va['chain'][1]));
                 foreach ($va['link'] as $vl => $tu) {
                     $tu['link'] = $tu['url'];
                     unset($tu['url']);
                     $va['link'][$vl] = $tu;
                 }
                 $fdata[$dy[$tp][2]] = $va['link'];
             }
         }
         if (!empty($fdata)) {
             foreach ($fdata as $cid => $cinfo) {
                 Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid));
                 foreach ($cinfo as $info) {
                     try {
                         $model = new Links();
                         $info['catalog_id'] = $cid;
                         $info['title'] = empty($info['title']) ? '待定' : $info['title'];
                         $info['link'] = empty($info['link']) || $info['link'] == '#' ? 'http://www.114la.com/' : $info['link'];
                         $info['mix'] = empty($info['mix']) ? null : base64_decode($info['mix']);
                         $info = array_filter($info);
                         $model->attributes = $this->_form($info);
                         //                        ppr($model->attributes);
                         $model->save();
                     } catch (Exception $exc) {
                         return 'error1caipiao';
                     }
                 }
             }
         }
         return 'ok';
         //            ppr($fdata,1);
     } elseif ($tid == 1114) {
         //实时热点部分
         $cacheId = 'doTb_' . $tid;
         $fcurl = cacheGet($cacheId);
         if (empty($fcurl)) {
             $url = 'http://api4.114la.com/1114_2.json';
             $fcurl = XUtils::fcurl($url);
             cacheSet($cacheId, $fcurl, 3600);
         }
         $fcurl = substr($fcurl, 20, -1);
         //            ppr($fcurl,1);
         if (!empty($fcurl) && ($fcurl = json_decode($fcurl, 1))) {
             //先将对应的旧数据处理
             $old = reqPost('old');
             if (empty($old)) {
                 Links::model()->updateAll(array('status_is' => 'N'), "`catalog_id`='{$cid}'");
             } else {
                 Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid));
             }
             //                ppr(Links::model()->findAll("`catalog_id`='$cid'"));
             foreach ($fcurl as $info) {
                 try {
                     $model = new Links();
                     $info['catalog_id'] = $cid;
                     $info['title'] = empty($info['title']) ? '待定' : $info['title'];
                     $info['link'] = empty($info['url']) || $info['url'] == '#' ? 'http://www.114la.com/' : $info['url'];
                     unset($info['url']);
                     $info = array_filter($info);
                     $model->attributes = $this->_form($info);
                     //                        ppr($model->attributes);
                     $model->save();
                 } catch (Exception $exc) {
                     return 'error1';
                 }
             }
             $cacheId = '_catalogAllNum';
             $catalogAllNum = XXcache::refresh($cacheId);
             return empty($catalogAllNum[$cid]) ? 0 : $catalogAllNum[$cid] . ' ok';
         } else {
             return 'error2';
         }
         ppr($data_arr, 1);
     } elseif ($tid > 1000 && $tid < 10000) {
         $tid = (int) $tid;
         $data = $re = 0;
         $cacheId = 'doTb_' . $tid;
         $fcurl = cacheGet($cacheId);
         if (empty($fcurl)) {
             $url = 'http://www.114la.com/api/ky.php?id=' . $tid . '&' . time();
             //                $url = 'http://www.114la.com/api/ky.php?id='.$tid;
             $fcurl = XUtils::fcurl($url);
             cacheSet($cacheId, $fcurl, 3600);
         }
         if (!empty($fcurl) && ($fcurl = json_decode($fcurl, 1))) {
             //先将对应的旧数据处理
             $old = reqPost('old');
             if (empty($old)) {
                 Links::model()->updateAll(array('status_is' => 'N'), "`catalog_id`='{$cid}'");
             } else {
                 Links::model()->deleteAll("catalog_id=:cid", array(':cid' => $cid));
             }
             //                ppr(Links::model()->findAll("`catalog_id`='$cid'"));
             foreach ($fcurl as $info) {
                 try {
                     $model = new Links();
                     $info['catalog_id'] = $cid;
                     $info['title'] = empty($info['title']) ? '待定' : $info['title'];
                     $info['link'] = empty($info['link']) || $info['link'] == '#' ? 'http://www.114la.com/' : $info['link'];
                     $info['mix'] = empty($info['mix']) ? null : base64_decode($info['mix']);
                     $info = array_filter($info);
                     $model->attributes = $this->_form($info);
                     //                        ppr($model->attributes);
                     $model->save();
                 } catch (Exception $exc) {
                     return 'error1';
                 }
             }
             $cacheId = '_catalogAllNum';
             $catalogAllNum = XXcache::refresh($cacheId);
             return empty($catalogAllNum[$cid]) ? 0 : $catalogAllNum[$cid] . ' ok';
         } else {
             return 'error2';
         }
     } else {
         return 'error3';
     }
 }
Ejemplo n.º 10
0
 private function groupEdite($data = null)
 {
     if (XUtils::method() == 'POST') {
         if (!empty($_POST['gname']) && !empty($_POST['auth'])) {
             $gid = reqPost('gid', null);
             $auth = '|' . implode('|', array_keys($_POST['auth'])) . '|';
             $sis = !empty($_POST['sis']) && $_POST['sis'] == 'Y' ? 'Y' : 'N';
             $attr = array('group_name' => $_POST['gname'], 'acl' => $auth, 'status_is' => $_POST['sis']);
             if (!empty($gid)) {
                 $attr['id'] = $gid;
             } else {
                 $attr['create_time'] = time();
             }
             empty($data) && ($data = new AdminGroup());
             $data->attributes = $attr;
             //            ppr($data);
             //            ppr($attr);
             //            ppr($_POST,1);
             if ($data->save()) {
                 //更新权限缓存
                 !empty($gid) && cacheDelete('_backendAcl' . $gid, '');
                 parent::_backendLogger(array('catalog' => 'create', 'intro' => '编辑管理员组及权限' . $data->group_name));
                 XXcache::refresh('_adminGroup');
                 $this->redirect(array('group'));
             }
         } else {
             $gid = reqPostNum('gid');
             if ($gid > 0) {
                 XUtils::message('error', '发生错误,请正确填写各项', $this->createUrl('admin/groupCreate', array('id' => $gid)));
             } else {
                 XUtils::message('error', '发生错误,请正确填写各项', $this->createUrl('admin/group'));
             }
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * 刷新内置缓存
  * @param  $model
  */
 protected function _refreshCache($model)
 {
     if (is_object($model)) {
         $modelx = get_class($model);
     } else {
         $modelx = $model;
     }
     switch (strtolower($modelx)) {
         case 'link':
             XXcache::refresh('_link', 86400);
             break;
         case 'ad':
             XXcache::refresh('_ad', 86400);
             break;
         case 'catalog':
             XXcache::refresh('_catalog', 86400);
             break;
         case 'UserGroup':
             XXcache::refresh('_userGroup', 86400);
             break;
     }
 }
Ejemplo n.º 12
0
 private function _getDataPid($pid)
 {
     //得到所有的父id为$pid的分类
     $dataList = XXcache::_doCatalog($pid, $this->_catalogAll);
     $dataRe = null;
     if (!empty($dataList)) {
         foreach ($dataList as $key => $value) {
             $dataRe[$value['id']]['name'] = empty($value['catalog_name']) ? null : $value['catalog_name'];
             $dataRe[$value['id']]['count'] = empty($value['data_count']) ? null : $value['data_count'];
             $dataRe[$value['id']]['path'] = empty($value['path']) ? null : $value['path'];
             $dataRe[$value['id']]['t'] = empty($value['seo_t']) ? null : $value['seo_t'];
             $dataRe[$value['id']]['k'] = empty($value['seo_k']) ? null : $value['seo_k'];
             $dataRe[$value['id']]['d'] = empty($value['seo_d']) ? null : $value['seo_d'];
             $dataRe[$value['id']]['url'] = empty($value['redirect_url']) ? null : $value['redirect_url'];
             $dataRe[$value['id']]['opt_1'] = empty($value['opt_1']) ? null : $value['opt_1'];
             $dataRe[$value['id']]['opt_2'] = empty($value['opt_2']) ? null : $value['opt_2'];
             if (!empty($value['last']) && !empty($value['id'])) {
                 $dataRe[$value['id']]['data'] = $this->_getDataCid($value['id'], $value['data_count']);
             }
         }
     }
     unset($dataList);
     //        ppr($dataRe,1);
     return $dataRe;
 }
Ejemplo n.º 13
0
 /**
  * 自定义字段
  */
 public function actionCustom()
 {
     parent::_acl();
     if (XUtils::method() == 'POST') {
         foreach ((array) $_POST['attr'] as $key => $row) {
             $val = is_array($row['val']) ? implode(',', $row['val']) : $row['val'];
             $var = $row["name"];
             $config = Config::model()->find('scope=:scope AND variable=:variable', array('scope' => 'custom', 'variable' => $var));
             if ($config) {
                 Config::model()->updateAll(array('value' => $val), 'scope=:scope AND variable=:variable', array('scope' => 'custom', 'variable' => $var));
             } else {
                 $config = new Config();
                 $config->scope = 'custom';
                 $config->variable = $var;
                 $config->value = $val;
                 $config->save();
             }
         }
         XXcache::refresh('_config', 3600);
         AdminLogger::_create(array('catalog' => 'update', 'intro' => '更新系统配置,模块:' . $this->action->id));
         XUtils::message('success', '更新完成', $this->createUrl($this->action->id));
     }
     $attrModel = Attr::lists(0, 'config');
     $this->render('custom', array('attrData' => self::loadData(), 'attrModel' => $attrModel));
 }
Ejemplo n.º 14
0
 public function actionDelete()
 {
     parent::_acl();
     $catalogId = reqGet('catalogId', null);
     //        ppr($_REQUEST,1);
     if (!empty($catalogId)) {
         $catalogId = intval($catalogId);
         $model = Catalog::model()->findByPk($catalogId);
         $name = $model->catalog_name;
         $model->delete();
         XXcache::refresh('_catalog');
         XXcache::refresh('_catalogAll');
         $model = Links::model()->deleteAll('catalog_id=:cid', array(':cid' => $catalogId));
         parent::_backendLogger(array('catalog' => 'delete', 'intro' => '删除分类 ' . $name . '(' . $catalogId . ') 及该分类所有链接'));
         XUtils::message('success', '已删除分类 ' . $name . ' 及该分类所有链接');
     }
     $this->redirect(Yii::app()->request->urlReferrer);
 }