Example #1
0
 public function actionCreateInner()
 {
     parent::_acl();
     //内页主类
     $innerCatalog = Catalog::model()->findAll("`status_is`='Y' AND `parent_id`='2'");
     //        ppr($innerCatalog,1);
     $page_arr = null;
     if (!empty($innerCatalog)) {
         foreach ($innerCatalog as $pageInfo) {
             $page_arr[$pageInfo->id] = array('name' => $pageInfo->catalog_name, 'path' => $pageInfo->path, 'error' => 0);
             try {
                 if (FALSE === strpos($pageInfo->path, 'http:')) {
                     if (empty($pageInfo->path)) {
                         $page_arr[$pageInfo->id]['error'] = '目录名未填写';
                         continue;
                     }
                     preg_match_all("/\\w+/", $pageInfo->path, $re);
                     if (empty($re[0][0])) {
                         $page_arr[$pageInfo->id]['error'] = '目录名只能是字母数字下划线';
                         continue;
                     }
                     $dir = SITE_PATH . substr($this->_conf['path_inside_page'], 1) . '/' . $re[0][0] . '/';
                     if (!is_dir($dir)) {
                         mkdir($dir);
                         if (!is_writable($dir)) {
                             $page_arr[$pageInfo->id]['error'] = '目录写入失败';
                             continue;
                         }
                     }
                     //                        ppr($pageInfo);ppr($this->_getDataPid($pageInfo->id));
                     $links = $this->_getDataPid($pageInfo->id);
                     //                        ppr($links);
                     //统一内页模板
                     $code = $this->render($this->_conf['theme'] . '/inner', array('info' => $pageInfo, 'links' => $links, 'innerCatalog' => $innerCatalog), 1);
                     $filename_html = $dir . 'index.html';
                     $filename_htm = $dir . 'index.htm';
                     file_put_contents($filename_html, $code, LOCK_EX);
                     file_put_contents($filename_htm, $code, LOCK_EX);
                 } else {
                     $page_arr[$pageInfo->id]['error'] = '已设置' . '<a href=' . $pageInfo->path . ' target="blank">外链</a>';
                 }
             } catch (Exception $exc) {
                 continue;
             }
         }
         return $page_arr;
     }
 }
Example #2
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));
     }
 }
Example #3
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if (XUtils::method() == 'POST') {
         $ids = reqPost('id');
         empty($ids) && XUtils::message('error', '未选择记录');
     } else {
         XUtils::message('errorBack', '只支持POST数据');
     }
     $upd = reqPost('upd', null);
     $del = reqPost('del', null);
     //        ppr($ids);
     //        ppr($_POST,1);
     if ($upd) {
         $sortOrder = reqPost('sort_order');
         $title = reqPost('title');
         $link = reqPost('link');
         $img_link = reqPost('img_link');
         $status = reqPost('status');
         foreach ((array) $ids as $id) {
             $catalogModel = Links::model()->findByPk($id);
             if ($catalogModel) {
                 $catalogModel->sort_order = $sortOrder[$id];
                 $catalogModel->title = $title[$id];
                 $catalogModel->link = $link[$id];
                 $catalogModel->image_link = $img_link[$id];
                 $catalogModel->status_is = $status[$id];
                 $catalogModel->create_time = time();
                 //                ppr($catalogModel,1);
                 $catalogModel->save();
             }
         }
         parent::_backendLogger(array('links' => 'update_batch', 'intro' => '修改数据'));
     } elseif ($del) {
         foreach ((array) $ids as $id) {
             $catalogModel = Links::model()->findByPk($id);
             $catalogModel->delete();
         }
         parent::_backendLogger(array('links' => 'delete_batch', 'intro' => '删除数据'));
     }
     XXcache::refresh('_catalogAllNum');
     XUtils::message('success', '操作完成', Yii::app()->request->urlReferrer);
 }
Example #4
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 #5
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);
 }