聯(lián)系官方銷售客服
1835022288
028-61286886
你好,我遇到一個問題,搞了一個下午,查不到原因所在。
這個問題是在線自動升級后造成的。
也就是說程序原本可以用,升級后不讓用了。
admin.php?s=yitihua&c=home&m=edit&id=4這個連接是有效的,
admin.php?s=yitihua&c=category&m=index&appid=2這個鏈接報錯了,要求登錄后臺,卡在登錄后臺頁面。準確的說,這個連接下的文件無法驗證管理員身份了。
home控制器和Category的寫法是一樣的啊。
先貼home的
<?php namespace Phpcmf\Controllers\Admin; class Home extends \Phpcmf\Table { public function __construct(...$params) { parent::__construct(...$params); \Phpcmf\Service::V()->assign([ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu( [ '應用概覽' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-list'], '新增應用' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/add', 'fa fa-clone'], '更新緩存' => ['ajax:yitihua/home/cache_update', 'fa fa-refresh'], 'help' => [350], ] ), ]); // 支持附表存儲 $this->is_data = 0; $this->my_field = array( ); // 初始化數(shù)據(jù)表 $this->_init([ 'table' => 'yth_app', 'field' => $this->my_field, 'order_by' => 'id asc', ]); // 表單顯示名稱 $this->name = dr_lang('應用概覽'); \Phpcmf\Service::V()->assign([ 'field' => $this->my_field, ]); } public function index() { list($tpl) = $this->_List(); // print_r($this->_List());exit; // 輸出模板 后臺位于 ./Views/home_list.html \Phpcmf\Service::V()->display($tpl); } //修改 public function edit() { list($tpl,$data) = $this->_Post(intval(\Phpcmf\Service::L('Input')->get('id'))); $data['seo']=dr_string2array($data['seo']); $data['unified_user_groups']=dr_string2array($data['unified_user_groups']); $data['unified_data_source']=dr_string2array($data['unified_data_source']); $data['unified_template']=dr_string2array($data['unified_template']); \Phpcmf\Service::V()->assign('data',$data); \Phpcmf\Service::V()->display('yth_admin_edit_app.html'); }
這是Category的
<?php namespace Phpcmf\Controllers\Admin; class Category extends \Phpcmf\Table { public $module; // 模塊信息 public $is_scategory; // 選擇欄目類型 protected $_is_extend_var = 0; // 繼承屬性變量 // 上級公共類 public function __construct(...$params) { parent::__construct(...$params); // 定義頁首的按鈕, \Phpcmf\Service::V()->assign([ 'menu' => \Phpcmf\Service::M('auth')->_admin_menu( [ '應用管理' => [APP_DIR.'/home/index', 'fa fa-list'], '新增應用' => [APP_DIR.'/home/add', 'fa fa-clone'], '更新緩存' => ['ajax:yitihua/home/cache_update', 'fa fa-refresh'], 'help' => [350], ] ), ]); $this->_Extend_Init(); } // 繼承類初始化 protected function _Extend_Init() { // 初始化模塊 $dir = APP_DIR ? APP_DIR : 'share'; // 支持附表存儲 $this->is_data = 0; // 模塊顯示名稱 $this->name = dr_lang('數(shù)據(jù)一體化[%s]', $dir); // print_r($this->is_scategory);exit; // 初始化數(shù)據(jù)表 $this->_init([ 'table' => 'yth_category', 'field' => '', 'show_field' => 'name', 'order_by' => 'displayorder ASC,id ASC', ]); //欄目涉及到所屬應用id $appid = intval(\Phpcmf\Service::L('Input')->get('appid')); // 寫入模板 快捷按鈕 \Phpcmf\Service::V()->assign([ 'appid' => $appid, 'uriprefix' => APP_DIR."/category", 'module' => $this->module, 'index_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/category/index',['appid' => $appid]), 'add_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/category/add',['appid' => $appid]), 'edit_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/category/edit',['appid' => $appid]), 'backIndex_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/category/index',['appid' => $appid]), 'reply_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/category/index',['appid' => $appid]), 'copy_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/category/copy',['appid' => $appid]), 'all_add_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/category/all_add',['appid' => $appid]), ]); } public function index() { $appid = intval(\Phpcmf\Service::L('Input')->get('appid')); $data = \Phpcmf\Service::M()->table($this->init['table'])->where('appid',$appid)->order_by('displayorder asc,id asc')->getAll(); if(!empty($data)){ \Phpcmf\Service::M('category')->init($this->init); // 初始化內(nèi)容模型 $category = \Phpcmf\Service::M('category')->repair($data); \Phpcmf\Service::V()->assign([ 'list' => $this->_get_tree_list($category) ]); }else{ \Phpcmf\Service::V()->assign([ 'list' => "" ]); } \Phpcmf\Service::V()->assign([ 'list_url' =>\Phpcmf\Service::L('Router')->url(APP_DIR.'/category/index'), 'list_name' => ' <i class="fa fa-reorder"></i> '.dr_lang('欄目管理'), 'move_select' => \Phpcmf\Service::L('Tree')->select_category( $category, 0, 'name="catid"', dr_lang('頂級欄目'), 0, 0 ), ]); // 輸出模板 后臺位于 ./Views/category_list.html \Phpcmf\Service::V()->display("category_list.html"); }
剛開始開發(fā)這個應用時,對于迅睿cms是個新手,一邊摸索一邊寫的。
升級框架前,這樣寫是可以的。
現(xiàn)在無法使用了,我想知道您能不能看出是什么問題。
是什么錯誤呢,主要看你什么錯誤,好對癥下藥
回復@官方研發(fā)實習技術
這是我要訪問的鏈接,會提示登錄,然后登陸后還是這個頁面。
因為url里要訪問的鏈接,驗證成功后會前往這個鏈接,就是admin.php?s=yitihua&c=category&m=index&appid=2
然后回又要驗證,
這個控制器category里沒驗證到管理員身份
這種情況應該是你沒有登錄成功導致的,
通過這個地址登錄是否會登錄成功呢?
回復@官方研發(fā)實習技術
我試過了,我確認我是登錄成功的。
那奇怪了,這種格式的地址,理論上登錄成功會跳轉(zhuǎn)到新的地址去
查了一個晚上,一個莫名其妙的bug
呵呵,怎么查都沒有原因,偶然之間試驗出來了
URL參數(shù)中不能帶有&app類的字母,比如我用了參數(shù)appid,結果就混亂了。
哎,參數(shù)中不能有app,不然就報錯。
回復@官方研發(fā)實習技術
app是系統(tǒng)保留關鍵字,不要亂加的,c,m,s,app,這幾個都是系統(tǒng)保留的參數(shù)
這回知道了,前邊的版本,這么寫沒報錯,所以就沒發(fā)現(xiàn)。這次升級了就不能用了,才去查原因。
回復@官方研發(fā)實習技術