我有一个PHP照相馆脚本,它是这样工作的:htaccess重写规则以欺骗服务器路径到脚本?
$image_path = "../images/11/mycoolphotos/md";
如果脚本和照片是在同一台服务器上,那么这个完美的作品!
然而,我们刚调到我们所有的图像到Amazon S3的 - 这样的路径是这样的:
$image_path = "https://s3.amazonaws.com/mywebsite/images/11/mycoolphotos/md";
但它不工作!它不会像../路径那样读取LIST或文件? 我可以包括一个“订购文件路径”,它的工作,但我们有8000照片画廊!太多工作 ?
$order_file_path = "https://s3.amazonaws.com/mywebsite/images/11/mycoolphotos.txt";
// this works, but it would take too much time. This just lists the image names, like 1.jpg, 2.jpg,.. so on for that gallery
我想知道如果我们欺骗服务器在读(不知道如何为.htaccess重写这个)
https://s3.amazonaws.com/mywebsite/images/
为
../
如果它的工作?
否则,我不知道该从哪里出发?
非常感谢!
编辑更新:我发现PATH阅读功能:任何人都可以解码这个?我尝试了下面的建议,但没有运气....?
/**
* Check for image order file. In case it does not
* exists, read the image directory.
*/
if (is_file($order_file_path . '/' . $order_file_name)) {
$fp = fopen($order_file_path . '/' . $order_file_name, "r");
$row = '';
$use_order_file = 'true';
while ($data = fgetcsv ($fp, 1000, ';')) {
$image_data[] = trim($data[0]);
$image_file_names[trim($data[0])] = trim($data[0]);
$num = count($data);
$row++;
for ($j = 0; $j < $num; $j++) {
$content_data_temp['field_' . $j] = $data[$j];
}
$content_data[] = $content_data_temp;
$content_data_temp = '';
}
fclose ($fp);
} else if (is_dir($image_path)) {
$content_data = '';
$handle = opendir($image_path);
while ($file = readdir($handle)) {
if (preg_match("/^\.{1,2}$/i", $file)) {
continue;
}
if (preg_match("/\.[a-z]{3}$/i", $file)) {
$image_data[] = $file;
$image_file_names[$file] = $file;
}
}
closedir($handle);
} else {
echo 'Working on older photos, please check back.';
exit;
}
$image_number = count ($image_data);
而不是硬编码路径。将其设置为一个变量。 '$ baseurl =“http:// amazonaws ...”' –
嗯。你可以做些什么,我有点失落? – eberswine
不要将路径硬编码到路径字符串中。像我说的那样将基础根设置为一个变量,并像'$ image = $ baseurl一样引用它。 “/图片/ ...”'。如果你没有得到这个,现在停止学习PHP并获得一本书。然后了解SQL注入 –