其实在opencart后台可以关闭这个选刊, System > Settings > Edit > Store > Allow downloads 然后选no
虽然不会删除你的downloads folder但是效果一样的, 不会有地方给黑客上载东西
希望帮到你!
Kind regards,
GeeHim Siu
Open Cart Support
因為 download 目錄在安裝時,必須要設定 777 才能安裝,這是安裝檔本身的限制。
警告字串:
下載目錄設定成 755 的錯誤訊息:Warning: Download directory needs to be writable for OpenCart to work!
Code: Select all
Warning: fopen(/home/username/public_html/download/test) [function.fopen]: failed to open stream: Permission denied in /home/username/public_html/admin/controller/common/home.php on line 99
Warning: fclose(): supplied argument is not a valid stream resource in /home/username/public_html/admin/controller/common/home.php on line 103
Warning: sprintf() [function.sprintf]: Too few arguments in /home/username/public_html/admin/controller/common/home.php on line 106
打開:
upload/admin/controller/common/home.php
尋找
Code: Select all
// Check download directory is writable
$file = DIR_DOWNLOAD . 'test';
$handle = fopen($file, 'a+');
fwrite($handle, '');
fclose($handle);
if (!file_exists($file)) {
$this->data['error_download'] = sprintf($this->language->get('error_download'). DIR_DOWNLOAD);
} else {
$this->data['error_download'] = '';
unlink($file);
}
否則在安裝時跟安裝後,都要求設定 777 讀寫權限,另一方面還要建議設定成 755 這樣會產生矛盾,您懂我的意思嗎?
總之,總結目前找到的解決方案:
1.手動變更 download 的目錄名稱。 (將 download 目錄更名成其它的亂數名稱)
2.放置「禁止讀取」的 .htaccess 檔案,避免駭客執行木馬程式。
OpenCart中国(http://www.opencartchina.com)
OpenCart中文论坛:http://www.opencartchina.com/bbs
Email: opencartchina@qq.com
QQ: 1487063622
OpenCart技术交流QQ 1群:282797742
OpenCart技术交流QQ 2群:298317506
OpenCart技术交流QQ 3群:198384554
OpenCart技术交流QQ 4群:227297836
中国版MyCnCart官方QQ群:473071696
需要設定讀寫權限的清單:
近幾年有些 Linux 虛擬主機,因為安裝特定的主機套件之緣故,就不再需要設定 CHMOD 權限,就能正常寫入產生檔案。(至於套件的詳細名稱,我明天再問看看。)3. Please make sure you have set the correct permissions on the files list below.
Files Status
/home/*.*/public_html/shop/config.php Writable
/home/*.*/public_html/shop/admin/config.php Writable
4. Please make sure you have set the correct permissions on the directories list below.
Directories Status
/home/*.*/public_html/shop/system/cache/ Writable
/home/*.*/public_html/shop/system/logs/ Writable
/home/*.*/public_html/shop/image/ Writable
/home/*.*/public_html/shop/image/cache/ Writable
/home/*.*/public_html/shop/image/data/ Writable
/home/*.*/public_html/shop/download/ Writable
現在的問題點在於說,傳統的 Linux 虛擬主機(不論是 cPanel 或 Plesk 體系的)通常都是「需要」設定「讀寫權限」才能正常運作。
我想要說的是,對於多數沒有在使用虛擬銷售的使用者來說。
在預設情況下,是不是真的有必要要求每個使用者,都要強制設定 download 的 CHMOD 到 777 才能安裝跟正常運作?
至於扯到是我的主機環境有問題,那我只能說是你們的觀念上邏輯錯誤。
因為我如果要解決的話,就直接將那段判斷讀寫權限的程式碼直接刪除就可以了,甚至在前後台的 config.php 也不用標示 download 的路徑,這樣不是更乾脆嗎?
我要說的是,你們應該可以開發成在安裝時,詢問使用者是否要使用下載型商品功能?
如果需要就請他們自行命名相對應的目錄名稱及設定讀寫權限,如果不需要就連 download 這個目錄都不用建立,這樣問題不就解決了嗎?
我想說的就是這樣。
PS.相同邏輯,也能應用在安裝時,讓使用者自行決定後台的安裝路徑名稱,不要都用預設的路徑造成可能的安全性問題。
这方面我不是专家, 所以我都是张我知道的资料告诉你, 如果755都不行就用757 都比777好
我们先前都试过有几个客人的hosting都不可以755运行的 但是9成以上都可以, 755可以给你权限来读写但是不可以execute
你试试上载一张图片然后看看他的permission是不是644
其实这个问题在讨论上有谈过, 你上载图片的时候, 那个文件会有一个mask的, 像:
testupload.jpg.12dec389004802ff38079c3a6f26175a
你要去system > settings > server 那里改那个encryption key, 越random越好
你的encryption够的话黑客应该是找不到文件, 找到都不可以execute, 但是像你说的一样, 你想跟一步加固你的商店就改downloads文件夹的名字
你说的都在这里讨论过:http://forum.opencart.com/viewtopic.php?f=20&t=98644
希望帮到你!
Kind regards,
GeeHim Siu
Open Cart Support
傳統的 mod_php5 都是需要設定 CHMOD 檔案權限。(你們安裝檔上面的權限檢查,就是這樣的東西。)
近期的 suPHP 不用設定 CHMOD 檔案目錄,直接就能安裝跟使用了。(你們在說的就是這樣的東西。)
不論是哪種環境,都是差不多的,差別只在 mod_php5 環境的用戶,他們的 download 都需要設定 777 才不會出現錯誤訊息。
解決方法如下:
打開:
upload/admin/controller/common/home.php
尋找
Code: Select all
// Check download directory is writable
$file = DIR_DOWNLOAD . 'test';
$handle = fopen($file, 'a+');
fwrite($handle, '');
fclose($handle);
if (!file_exists($file)) {
$this->data['error_download'] = sprintf($this->language->get('error_download'). DIR_DOWNLOAD);
} else {
$this->data['error_download'] = '';
unlink($file);
}
打開:
upload/admin/view/template/common/home.tpl
尋找
Code: Select all
<?php if ($error_download) { ?>
<div class="warning"><?php echo $error_download; ?></div>
<?php } ?>
打開:
upload/config.php 和 upload/admin/config.php
尋找
Code: Select all
define('DIR_DOWNLOAD', '安裝路徑/download/');
Code: Select all
define('DIR_DOWNLOAD', '安裝路徑/亂數名稱(例如:7PUFX0-9W-5K)/');
將預設的 download 目錄更名為上述名稱,並設定為 755 的讀寫權限。
就能停用 download 讀寫權限偵測,又不影響程式碼,對不需要下載型商品的用戶來說,這是正確的解決方案。
PS.上面的那段錯誤訊息,簡單來說就是要顯示這段文字的:
Code: Select all
$_['error_download'] = 'Warning: Download directory %s not writeable!';
Code: Select all
Warning: fopen(/home/username/public_html/download/test) [function.fopen]: failed to open stream: Permission denied in /home/username/public_html/admin/controller/common/home.php on line 99
Warning: fclose(): supplied argument is not a valid stream resource in /home/username/public_html/admin/controller/common/home.php on line 103
Warning: sprintf() [function.sprintf]: Too few arguments in /home/username/public_html/admin/controller/common/home.php on line 106
Attachments
suPHP 環境的安裝畫面。 - suPHP.png (123.61 KiB) Viewed 5396 times
mod_php5 環境的安裝畫面。 - mod_php5.png (125.51 KiB) Viewed 5396 times
opencart系統還在繼續完善中,比如在緩存技術方面,會對服務器方面要求的更高些。因此,從將來維護以及升級來看,採用較新較高級的服務器空間是很有必要的。
OpenCart中国(http://www.opencartchina.com)
OpenCart中文论坛:http://www.opencartchina.com/bbs
Email: opencartchina@qq.com
QQ: 1487063622
OpenCart技术交流QQ 1群:282797742
OpenCart技术交流QQ 2群:298317506
OpenCart技术交流QQ 3群:198384554
OpenCart技术交流QQ 4群:227297836
中国版MyCnCart官方QQ群:473071696
Code: Select all
$this->data['config_catalog'] = DIR_OPENCART . 'config.php';
$this->data['config_admin'] = DIR_OPENCART . 'admin/config.php';
$this->data['cache'] = DIR_SYSTEM . 'cache';
$this->data['logs'] = DIR_SYSTEM . 'logs';
$this->data['image'] = DIR_OPENCART . 'image';
$this->data['image_cache'] = DIR_OPENCART . 'image/cache';
$this->data['image_data'] = DIR_OPENCART . 'image/data';
$this->data['download'] = DIR_OPENCART . 'download';
Code: Select all
if (!file_exists(DIR_OPENCART . 'config.php')) {
$this->error['warning'] = 'Warning: config.php does not exist. You need to rename config-dist.php to config.php!';
} elseif (!is_writable(DIR_OPENCART . 'config.php')) {
$this->error['warning'] = 'Warning: config.php needs to be writable for OpenCart to be installed!';
}
if (!file_exists(DIR_OPENCART . 'admin/config.php')) {
$this->error['warning'] = 'Warning: admin/config.php does not exist. You need to rename admin/config-dist.php to admin/config.php!';
} elseif (!is_writable(DIR_OPENCART . 'admin/config.php')) {
$this->error['warning'] = 'Warning: admin/config.php needs to be writable for OpenCart to be installed!';
}
if (!is_writable(DIR_SYSTEM . 'cache')) {
$this->error['warning'] = 'Warning: Cache directory needs to be writable for OpenCart to work!';
}
if (!is_writable(DIR_SYSTEM . 'logs')) {
$this->error['warning'] = 'Warning: Logs directory needs to be writable for OpenCart to work!';
}
if (!is_writable(DIR_OPENCART . 'image')) {
$this->error['warning'] = 'Warning: Image directory needs to be writable for OpenCart to work!';
}
if (!is_writable(DIR_OPENCART . 'image/cache')) {
$this->error['warning'] = 'Warning: Image cache directory needs to be writable for OpenCart to work!';
}
if (!is_writable(DIR_OPENCART . 'image/data')) {
$this->error['warning'] = 'Warning: Image data directory needs to be writable for OpenCart to work!';
}
if (!is_writable(DIR_OPENCART . 'download')) {
$this->error['warning'] = 'Warning: Download directory needs to be writable for OpenCart to work!';
}
至於是採用 mod_php5 或 suPHP 的環境,都跟虛擬主機商的經營策略有關,畢竟不是所有主機上的用戶,他們的程式都能支援 suPHP 的環境,假使要移機也是逐一轉移。
我想說的就是這樣。
Users browsing this forum: Baidu [Spider] and 106 guests