dtpn60029 2011-04-08 09:09
浏览 39
已采纳

Extplorer $ _GET变量被忽略(而echo $ _GET ['var']仍然回应它..)

I'm using extplorer (http://extplorer.sourceforge.net/) and I'm having some issues.

This runs on PHP.

I did the following so far: Overrode it so that log in is not required, but rather, checks a $_SESSION var that my own CMS generates upon log-in in order to secure it. Installed, and confirmed the file/folder dislpays work for the regular root of the site (DOCUMENT_ROOT)

What I'm trying to do now is, each time extplorer is called into an iFrame, I want it to open a different home_dir based on a $_GET var fed through (?idr=35, for example). However for some odd reason I cannot get this to work.

I tried all sorts of combinations of code to make this work, and when I print_r($GLOBALS) I definitely see the home_dir array holding the path I determine (which should be something like /pages/35/folder as I need to allow my clients to upload small micro-sites to each page folder). I have notated each result with the error I see under FIrebug when the AJAX module calls the files to list the directory etc.

$brixwork_pageid = $_GET['idr'];
$GLOBALS['home_dir'] = $_SERVER['DOCUMENT_ROOT'].'/pages/'.$brixwork_pageid.'/folder';

: did not work. Error:

<br />
<b>Notice</b>:  Undefined index: idr in <b>/home/sonikas/public_html/picnetbc/admin/explorer/include/init.php</b> on line <b>76</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/sonikas/public_html/picnetbc/admin/explorer/include/result.class.php</b> on line <b>100</b><br />
{'action':'','message':"The home directory doesn\\'t exist, check your settings. (\/home\/sonikas\/public_html\/picnetbc\/pages\/\/folder)",'error':"The home directory doesn\\'t exist, check your settings. (\/home\/sonikas\/public_html\/picnetbc\/pages\/\/folder)",'success':false}

So I tried:

$GLOBALS['home_dir'] = $_SERVER['DOCUMENT_ROOT'].'/pages/'.$_GET['idr'].'/folder';

:also did not work. Error:

<br />
<b>Notice</b>:  Undefined index: idr in <b>/home/sonikas/public_html/picnetbc/admin/explorer/include/init.php</b> on line <b>76</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/sonikas/public_html/picnetbc/admin/explorer/include/result.class.php</b> on line <b>100</b><br />
{'action':'','message':"The home directory doesn\\'t exist, check your settings. (\/home\/sonikas\/public_html\/picnetbc\/pages\/\/folder)",'error':"The home directory doesn\\'t exist, check your settings. (\/home\/sonikas\/public_html\/picnetbc\/pages\/\/folder)",'success':false}

Then I tried:

$GLOBALS['home_dir'] = $_SERVER['DOCUMENT_ROOT'].'/pages/'.$GLOBALS['__GET']['idr'].'/folder';

:neither did this. Error:

<br />
<b>Notice</b>:  Undefined index: idr in <b>/home/sonikas/public_html/picnetbc/admin/explorer/include/init.php</b> on line <b>80</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/sonikas/public_html/picnetbc/admin/explorer/include/result.class.php</b> on line <b>100</b><br />
{'action':'','message':"The home directory doesn\\'t exist, check your settings. (\/home\/sonikas\/public_html\/picnetbc\/pages\/\/folder)",'error':"The home directory doesn\\'t exist, check your settings. (\/home\/sonikas\/public_html\/picnetbc\/pages\/\/folder)",'success':false}

So they're basically more or less the same errors. But the weird thing is, if I want to test this module, and I spit out print_r($GLOBALS) I see the home_dir array returning everything including the number that was given, which means that the GET var does get in there somehow. Any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • doufang7385 2011-04-08 09:29
    关注

    OK So I figured it out - I'm going to write this out so that in case anybody else wants to use this, they can use it.

    The issue was that, since this file explorer module (which is fantastic by the way) uses AJAX to make its calls, the initial PHP file opening would get the $_GET var through, but once it makes the AJAX calls, it would send no $_GET vars through!

    So instead of tinkering with the javascript to try to pass on the GET vars (which would have taken forever, since I didn't even write this thing and I have no idea where things are), I employed the SESSION var method. Since my CMS uses SESSIONS to log in anyway, the SESSION vars should save. In the init.php file, I put this line instead of the above tinkerings:

    if($_REQUEST['explorer_idr']!='') {
        // new request IDR is given - let's save this to a SESSION so that this opens each time on AJAX calls
        $_SESSION['explorer_idr'] = $_REQUEST['explorer_idr'];
    }
    
    $GLOBALS['home_dir'] = $_SERVER['DOCUMENT_ROOT'].'/pages/'.$_SESSION['explorer_idr'].'/folder';
    

    To make sure it doesn't clash with anything else, I made the array key "explorer_idr". This way, if a new $_REQUEST['explorer_idr'] is provided, it overrides the $_SESSION['explorer_idr'] to the given value - and if not, it just runs off the previously set var, so that by the time AJAX calls are made (which carry on the SESSION by the way), even if a specific $_GET is not given again, it runs off the saved $_SESSION... and if a $_GET is provided, meaning the user switched to another page, it will simply re-load the $_SESSION var again to make it work!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源