【发布时间】:2018-03-21 10:47:27
【问题描述】:
我正在开发 http://example.com/userfiles/upload.php 作为 Drupal CKEditor 的文件浏览器,我想限制对登录用户的访问,但 upload.php 中的 $user->uid 似乎没有返回任何值。
我必须将路径 /userfiles 添加到 Apache 的重写规则异常中才能访问它(否则,它会将其转发到 index.php?q= 并且不会加载)。
我还不完全了解 Drupal 的 index.php 是如何工作的,但我怀疑 Apache 的重写规则可能是访问 $user->uid 值的问题?
或者我是否需要额外的代码才能从 Drupal 访问这个值?
$global user;
if (!$user->uid) {
echo("You're not allowed to upload files");
die(0);
}
【问题讨论】:
标签: php apache mod-rewrite drupal drupal-7