我使用这个Yubico身份验证PHP类:https://github.com/Yubico/php-yubico。我用以下代码创建了php文件test.php:
<?php
require_once 'Auth/Yubico.php';
$otp = "ccbbddeertkrctjkkcglfndnlihhnvekchkcctif";
# Generate a new id+key from https://api.yubico.com/get-api-key/
$yubi = new Auth_Yubico('42', 'FOOBAR=');
$auth = $yubi->verify($otp);
if (PEAR::isError($auth)) {
print "<p>Authentication failed: " . $auth->getMessage();
print "<p>Debug output from server: " . $yubi->getLastResponse();
} else {
print "<p>You are authenticated!";
}
?>完成这个github库中的所有指令。当我打开这个脚本时,我得到:
警告: require_once():有效的open_basedir限制。文件(/usr/share/php/Auth/yubico.php)不在允许的路径范围内:(/var/www/hmci/data:.)在第2行的/var/www/hmci/data/www/hmci.ru/php-yubico/test.php中,警告: require_once(/usr/share/php/Auth/Yubico.php):未能打开流:在第2行的/var/www/hmci/data/www/hmci.ru/php-yubico/test.php中不允许的操作: require_once():failed需要'Auth/Yubico.php‘(include_path=’.:/usr/share/php):/usr/share/pear')在第2行的/var/www/hmci/data/www/hmci.ru/php-yubico/test.php中
如何解决这个问题?
发布于 2013-01-22 18:19:20
open_basedir是一个PHP选项,限制PHP对特定目录的访问。
您的包含路径中有目录/usr/share/php,而没有访问它的权限。通常,PHP逐个地尝试include_path中的所有路径。这意味着PHP无法在当前目录中找到文件Auth/Yubico.php,因此PHP下一步将在/usr/share/php中搜索。
确保您想要包含的文件实际上在那里。您还可以从包含路径中删除/usr/share/php (通过编辑php.ini文件,如果您可以访问它,则使用ini_set()方法)。
发布于 2015-08-26 17:12:08
使用要包含的文件的显式路径导致PHP跳过目录扫描,导致错误:
require_once dirname(__FILE__) . '/Auth/Yubico.php';https://stackoverflow.com/questions/14465212
复制相似问题