4images Help / Hilfe > Bug Fixes & Patches
[1.7] Allow IP in download URL and remote image path
(1/1)
Chris:
This fix will let u use IP and FTP addresses in download URL and remote image path.
Open /includes/functions.php
Find:
--- Code: --- return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
--- End code ---
Replace with:
--- Code: --- return (preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?(\/)?/i", $file_name)) ? 1 : 0;
--- End code ---
Find:
--- Code: --- return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.([a-z]{1,4})$)#is", $file_name)) ? 1 : 0;
--- End code ---
Replace with:
--- Code: --- return (preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/.*\.([a-z]{1,4})$/i", $file_name)) ? 1 : 0;
--- End code ---
Find:
--- Code: --- return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is", $remote_media_file)) ? 1 : 0;
--- End code ---
Replace with:
--- Code: --- return (preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/.*\.(".$config['allowed_mediatypes_match'].")$/i", $remote_media_file)) ? 1 : 0;
--- End code ---
Find:
--- Code: --- return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.(gif|jpg|jpeg|png)$)#is", $remote_thumb_file)) ? 1 : 0;
--- End code ---
Replace with:
--- Code: --- return (preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/.*\.(gif|jpg|jpeg|png)$/i", $remote_thumb_file)) ? 1 : 0;
--- End code ---
Find:
--- Code: --- if (!preg_match("/^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+/i", $url)) {
--- End code ---
Replace with:
--- Code: --- if (!preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?(\/)?/i", $url)) {
--- End code ---
I've tested it with this url types:
http://example.com/image.jpg
http://user@example.com/image.jpg
http://user:pass@example.com/image.jpg
http://123.123.123.123/image.jpg
http://user@123.123.123.123/image.jpg
http://user:pass@123.123.123.123/image.jpg
ftp://, https:// and port numbers also working
Please let me know if u find anything not working after these changes.
P.S. there is a bug in member.php that let u upload not existing images by using remote url.
oswald:
Hmmm... what version is it for or what other mods do you have installed..... can't find most of the lines to edit in my original functions.php
V@no:
that fix for v1.7
Navigation
[0] Message Index
Go to full version