通过url传递文件夹名作为参数来调用php函数
我试图通过传递文件夹名作为URL参数来调用php函数,从而列出目录的内容。我遵循了stackoverflow上提供的一些其他示例,已经能够调用php函数,并且确信由于输出了echo语句,我正在访问其中的代码 url似乎编码正确,因为当我在php函数中显示路径信息时,所有路径都会签出通过url传递文件夹名作为参数来调用php函数,php,wordpress,Php,Wordpress,我试图通过传递文件夹名作为URL参数来调用php函数,从而列出目录的内容。我遵循了stackoverflow上提供的一些其他示例,已经能够调用php函数,并且确信由于输出了echo语句,我正在访问其中的代码 url似乎编码正确,因为当我在php函数中显示路径信息时,所有路径都会签出 www.mysite.com/php/genListing.php?function=genListing&folder=wp-content/uploads/myfiles 对is_readable()的
www.mysite.com/php/genListing.php?function=genListing&folder=wp-content/uploads/myfiles
对is_readable()的检查似乎失败。我已经检查了该目录的文件权限,所有用户都具有读取权限。有人知道问题出在哪里吗
genListing.php
if ( ! empty( $_GET['function'] ) && function_exists( $_GET['function'] ) ) {
if ( $_GET['function'] == 'genListing')
{
$atts = $_POST;
genListing( $atts );
}
}
function genListing( $atts ) {
$folder = $_GET[ 'folder' ];
if ( ! empty( $_GET['title'] ) ) {
$title = $_GET['title'];
}
else
{
$title = 'Directory Listing';
}
echo "<p>Made it inside genListing(): " . $folder . "</p>";
$fullFolderPath = trailingslashit( WP_INSTANCE_HOME ) . $folder;
echo "<p> Trying: " . $fullFolderPath . "</p>";
// bad folder check
if ( empty( $folder ) || ! is_readable( $fullFolderPath ) ) {
echo "<p>The folder selected was not valid.</p>";
return 'The folder selected was not valid.';
}
如果(!empty($\u GET['function'])和&function_存在($\u GET['function'])){
if($\u GET['function']=='genListing')
{
$atts=$\邮政编码;
基因清单(atts);
}
}
函数列表($atts){
$folder=$_GET['folder'];
如果(!empty($_GET['title'])){
$title=$_GET['title'];
}
其他的
{
$title='目录列表';
}
echo“在genListing()中创建:“$folder。””;
$fullFolderPath=trailingslashit(WP_实例_主)。$folder;
echo“正在尝试:“.$fullFolderPath。””;
//坏文件夹检查
if(空($folder)| |!可读($fullFolderPath)){
echo“所选文件夹无效。”;
返回“所选文件夹无效”;
}