Changeset 16275 for trunk/install
- Timestamp:
- Jul 2, 2012, 12:53:18 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/install/db/121-database.php
r15178 r16275 29 29 // see http://piwigo.org/doc/doku.php?id=user_documentation:htaccess_and_hotlink_in_2.4 30 30 31 if (!isset($page['warnings'])) $page['warnings'] = array(); 32 33 $upgrade_description = 'add/append htaccess for hotlinks'; 34 $warning_message = 'Failed to modify <b>.htaccess</b> file, a manual intervention is needed, <a href="http://piwigo.org/doc/doku.php?id=user_documentation:htaccess_and_hotlink_in_2.4" target="_blank">click here for more information</a>'; 35 36 $htaccess = PHPWG_ROOT_PATH.'/.htaccess'; 37 $writable = true; 38 if (file_exists($htaccess)) 39 { 40 if (!is_readable($htaccess) || !is_writable($htaccess)) 41 { 42 $writable = false; 43 } 44 } 45 else 46 { 47 $writable = is_writable(PHPWG_ROOT_PATH); 48 } 49 50 if (!$writable) 51 { 52 array_push($page['warnings'], $warning_message); 53 $upgrade_description.= ': failed'; 54 } 55 else 56 { 57 $content = file_exists($htaccess) ? file_get_contents($htaccess) : null; 58 if (strpos($content, 'RewriteEngine off') !== false) 59 { 60 array_push($page['warnings'], $warning_message); 61 $upgrade_description.= ': failed'; 62 } 63 else 64 { 65 $content.= ' 66 <IfModule mod_rewrite.c>'; 67 68 if (strpos($content, 'RewriteEngine on') === false) 69 { 70 $content.=' 71 RewriteEngine on'; 72 } 73 74 if (!isset($conf['prefix_thumbnail'])) 75 { 76 $conf['prefix_thumbnail'] = 'TN-'; 77 } 78 79 if (!isset($conf['dir_thumbnail'])) 80 { 81 $conf['dir_thumbnail'] = 'thumbnail'; 82 } 83 84 $content.= ' 85 ## redirect <2.4 thumbnails hotlinks to i.php 86 RewriteRule ^upload/(.*)/'.preg_quote($conf['dir_thumbnail']).'/'.preg_quote($conf['prefix_thumbnail']).'(.*)\.([a-z0-9]{3,4})$ i.php?/upload/$1/$2-th.$3 [L] 87 RewriteRule ^galleries/(.*)/'.preg_quote($conf['dir_thumbnail']).'/'.preg_quote($conf['prefix_thumbnail']).'(.*)\.([a-z0-9]{3,4})$ i.php?/galleries/$1/$2-th.$3 [L] 88 89 ## redirect <2.4 high-def hotlinks to original file 90 RewriteRule ^upload/(.*)/pwg_high/(.*)\.([a-z0-9]{3,4})$ upload/$1/$2.$3 [L] 91 RewriteRule ^galleries/(.*)/pwg_high/(.*)\.([a-z0-9]{3,4})$ galleries/$1/$2.$3 [L] 92 93 ## redirect <2.4 low-def hotlinks to i.php 94 RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?'.preg_quote($_SERVER['SERVER_NAME']).'/.*$ [NC] 95 RewriteRule ^upload/(.*)/(.*)\.([a-z0-9]{3,4})$ i.php?/upload/$1/$2-me.$3 [L] 96 RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?'.preg_quote($_SERVER['SERVER_NAME']).'/.*$ [NC] 97 RewriteRule ^galleries(.*)/(.*)\.([a-z0-9]{3,4})$ i.php?/galleries/$1/$2-me.$3 [L] 98 </IfModule>'; 99 100 file_put_contents($htaccess, $content); 101 } 102 } 31 $upgrade_description = 'add/append htaccess for hotlinks (cancelled, see plugin "Hotlink Compatibility")'; 103 32 104 33
Note: See TracChangeset
for help on using the changeset viewer.