我有一個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注入 –