RewriteEngine on ## redirect <2.4 thumbnails hotlinks to i.php RewriteRule ^upload/(.*)/'.preg_quote($conf['dir_thumbnail']).'/'.preg_quote($conf['prefix_thumbnail']).'(.*)\.(jpg|jpeg|png|gif)$ i.php?/upload/$1/$2-th.$3 [NC,L] RewriteRule ^galleries/(.*)/'.preg_quote($conf['dir_thumbnail']).'/'.preg_quote($conf['prefix_thumbnail']).'(.*)\.(jpg|jpeg|png|gif)$ i.php?/galleries/$1/$2-th.$3 [NC,L] ## redirect <2.4 high-def hotlinks to original file RewriteRule ^upload/(.*)/pwg_high/(.*)\.(jpg|jpeg|png|gif)$ upload/$1/$2.$3 [NC,L] RewriteRule ^galleries/(.*)/pwg_high/(.*)\.(jpg|jpeg|png|gif)$ galleries/$1/$2.$3 [NC,L] ## redirect <2.4 low-def hotlinks to i.php RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?'.preg_quote($_SERVER['SERVER_NAME']).'/.*$ [NC] RewriteRule ^upload/(.*)/(.*)\.(jpg|jpeg|png|gif)$ i.php?/upload/$1/$2-me.$3 [NC,L] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?'.preg_quote($_SERVER['SERVER_NAME']).'/.*$ [NC] RewriteRule ^galleries(.*)/(.*)\.(jpg|jpeg|png|gif)$ i.php?/galleries/$1/$2-me.$3 [NC,L] '; // check if the file is writable $writable = true; if (file_exists($htaccess)) { if (!is_readable($htaccess) || !is_writable($htaccess)) { $writable = false; } } else { $writable = is_writable(PHPWG_ROOT_PATH); } if (!$writable) { array_push($page['errors'], l10n('.htaccess file is not writable')); $template->assign('FILE_ERROR', true); $template->assign('FILE_CONTENT', $htaccess_content); $template->assign('DISPLAY_DESC', true); } else { $continue = true; $content = file_exists($htaccess) ? file_get_contents($htaccess) : null; // check if RewriteEngine off if (preg_match('#RewriteEngine\s+off#', $content)) { array_push($page['errors'], l10n('Unable to activate RewriteEngine')); $template->assign('REWRITE_ERROR', true); $template->assign('DISPLAY_DESC', true); $continue = false; } // check if already updated if (strpos($content, '## redirect <2.4') !== false) { array_push($page['infos'], l10n('Upgrade already applied, please remove this plugin')); $template->assign('ALREADY_UPDATED', true); $continue = false; } if ($continue) { if (isset($_GET['init_migration'])) { if (strpos($content, 'RewriteEngine on') !== false) { $htaccess_content = str_replace('RewriteEngine on', null, $htaccess_content); } file_put_contents($htaccess, "\n".$htaccess_content, FILE_APPEND); array_push($page['infos'], l10n('Upgrade successfully applied, please remove this plugin')); } else { // check if the host is incompatible if (preg_match('#free\.fr/?$#', $_SERVER['SERVER_NAME'])) { array_push($page['warnings'], l10n('Your host may be incompatible with URL rewriting')); $template->assign('HOST_WARNING', true); } $template->assign('DISPLAY_DESC', true); $template->assign('NO_ERROR', true); } } } $template->assign('DESC_CONTENT', load_language('desc_content.html', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/', array('return'=>true))); $template->assign('URL_INIT', get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)).'&init_migration'); $template->set_filename('addht_content', dirname(__FILE__).'/admin.tpl'); $template->assign_var_from_handle('ADMIN_CONTENT', 'addht_content'); ?>