Example #1
0
 function actionCache()
 {
     $dataList = array('pageCache' => '页面缓存', 'dataCache' => '数据缓存', 'allCache' => '全部缓存');
     //        ppr($dataList);
     $notice = '选择缓存类型';
     if (XUtils::method() == 'POST') {
         $cacheType = reqPost('cacheType', NULL);
         $path = SITE_BACKEND_PATH . 'assets';
         switch ($cacheType) {
             case 'pageCache':
                 XUtils::delDirAndFile($path);
                 break;
             case 'dataCache':
                 cacheFlush();
                 break;
             case 'allCache':
                 cacheFlush();
                 XUtils::delDirAndFile($path);
                 break;
         }
         $notice .= '<br />清空完成!';
     }
     $this->render('cache', array('dataList' => $dataList, 'notice' => $notice));
 }
Example #2
0
 public function actionTbAll()
 {
     $make = reqPost('make');
     $re = $crondArr = array();
     $crond_json_file = SITE_BACKEND_PATH . 'protected/data/crond/crond.json';
     if (!empty($make) && is_array($make)) {
         if (!empty($make['crond'])) {
             //这里生成crond地址
             $check = reqPost('check');
             $check['old'] = reqPost('old');
             file_put_contents($crond_json_file, json_encode($check));
             XUtils::message('success', '操作完成', $this->createUrl('links/tbAll'));
         } else {
             $type = array_keys($make);
             //         ppr($type[0],1);
             switch ($type[0]) {
                 case 'header':
                     $min = 1000;
                     $max = 1999;
                     break;
                 case 'left':
                     $min = 2000;
                     $max = 2999;
                     break;
                 case 'main':
                     $min = 3000;
                     $max = 3999;
                     break;
                 case 'shop':
                     $min = 4000;
                     $max = 4999;
                     break;
                 case 'fun':
                     $min = 5000;
                     $max = 5999;
                     break;
                 case 'tools':
                     $min = 6000;
                     $max = 6999;
                     break;
                 case 'games':
                     $min = 7000;
                     $max = 7999;
                     break;
             }
             if (!empty($max) && !empty($min)) {
                 $catalog_arr = Catalog::model()->findAll(array('select' => 'id,tb_id', 'condition' => "t.tb_id>:min AND t.tb_id<:max", 'params' => array(':min' => $min, ':max' => $max)));
             }
             if (!empty($catalog_arr)) {
                 foreach ($catalog_arr as $info) {
                     $re[$info->id] = $this->doTb($info->tb_id, $info->id);
                 }
             }
         }
         //            XUtils::message('success', '操作完成', $this->createUrl('links/tbAll'));
         //            $this->redirect(array('links/tbAll'));
     }
     if (is_file($crond_json_file)) {
         $arr = json_decode(file_get_contents($crond_json_file), TRUE);
         if (empty($arr['old'])) {
             unset($arr['old']);
         }
         $crondArr = array_keys($arr);
         //            ppr($arr);
     }
     $this->render('tb_all', array('catalog' => $re, 'crondArr' => $crondArr));
 }
Example #3
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'));
             }
         }
     }
 }
Example #4
0
 private function _form($links)
 {
     if (!empty($links['mix']) && !XUtils::isUtf8($links['mix'])) {
         $links['mix'] = XUtils::autoCharset($links['mix']);
     }
     if (!empty($links['title']) && !XUtils::isUtf8($links['title'])) {
         $links['title'] = XUtils::autoCharset($links['title']);
     }
     $links['mix'] = empty($links['mix']) ? null : XUtils::b64encode($links['mix']);
     //先判断是外链图片还是本地图片
     $imgtype = reqPost('imgtype', null);
     //        ppr($_POST,1);
     if (!empty($imgtype)) {
         if ($imgtype == 'local') {
             $links['image_link'] = $this->_doLocalImage('image_link');
         }
         if (empty($links['image_link'])) {
             $links['image_link'] = null;
         }
     }
     $links['begin_time'] = empty($links['begin_time']) ? 0 : strtotime($links['begin_time']);
     $links['end_time'] = empty($links['end_time']) ? 0 : strtotime($links['end_time']);
     //            ppr($links_arr,1);
     $links['create_time'] = $this->_thetime;
     $links['user_id'] = 0;
     return $links;
 }
Example #5
0
 /**
  * 编辑
  *
  * @param  $id
  */
 public function actionUpdate($id)
 {
     parent::_acl();
     $model = parent::_dataLoad(new Catalog(), $id);
     $catalogAll = reqPost('Catalog');
     if (!empty($catalogAll)) {
         $catalogAll['create_time'] = $this->_thetime;
         //先判断是外链图片还是本地图片
         $imgtype = reqPost('imgtype', null);
         //ppr($_POST,1);
         if (!empty($imgtype)) {
             if ($imgtype == 'local') {
                 $catalogAll['image_link'] = $this->_doLocalImage('image_link');
             }
             if (empty($catalogAll['image_link'])) {
                 $catalogAll['image_link'] = null;
             }
         }
         $model->attributes = $catalogAll;
         //        ppr($_POST);        ppr($_FILES);        ppr($catalogAll,1);
         unset($catalogAll);
         if ($model->save()) {
             //检查父分类是否为N
             $fmodel = Catalog::model()->findByPk($model->attributes['parent_id'], "`status_is`='N'");
             if (empty($fmodel)) {
                 if ($model->attributes['status_is'] == 'N') {
                     //若该分类为N,则该分类所有子分类均为N
                     $this->subSetStatus($model->attributes['id']);
                 }
             } else {
                 //若是,则该父分类下面所有均为N
                 $this->subSetStatus($fmodel->attributes['id']);
             }
             XXcache::refresh('_catalog');
             XXcache::refresh('_catalogAll');
             parent::_backendLogger(array('catalog' => 'update', 'intro' => '编辑全局分类,ID:' . $model->id . ',名称:' . $model->catalog_name));
             $fid = $this->_getParentCatalogId($model->parent_id);
             $this->redirect(array('index', 'fid' => $fid));
         }
     }
     $this->render('update', array('model' => $model, 'id' => $id));
 }
Example #6
0
 public static function doTb($tid, $cid = 0)
 {
     if ($tid > 1000 && $tid < 10000 && $tid != 2610) {
         $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)) {
                 self::model()->updateAll(array('status_is' => 'N'), "`catalog_id`='{$cid}'");
             } else {
                 self::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';
         }
     } elseif ($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) {
                 self::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);
     } else {
         return 'error3';
     }
 }