Welcome to advanced Seditio Rewrite extension which makes your URLs both user and search engine friendly. First I need to say that you should be rather patient and experienced Seditio admin in order to use this extension.

Features:


      1. 100% automated. You don't need to change anything in your TPL files and code (besides the install process), it changes all the URLs automatically.
      2. 100% conversion of relative and absolute URLs pointing to your site. Even javascript popups and redirect headers are converted.
      3. Accurate. Converts image/css/js/resources/downloads and non-relative links correctly.
      4. RFC 2616 compliant. More details in bug report: http://www.neocrome.net/forums.php?m=posts&q=22718.
      5. URL format: http://yoursite.com/script_name/param1-value1/param2-value2.html#anchor. Examples: http://yoursite.com/admin.html, http://yoursite.com/forums/s-23.html, http://yoursite.com/plug/e-weblogs/m-home.html. You can also use some other characters instead of "/" and "-". Page suffix is also customizable.
      6. Unlimited number of GET parameters.
      7. Supported shortcuts:
      7.1. For list.php: http://yoursite.com/c-category_name.html
      7.2. For page.php: http://yoursite.com/i-page_id.html and http://yoursite.com/a-page_alias.html
      7.3. For plug.php: http://yoursite.com/p-plugin_name.html and http://yoursite.com/o-plugin_name.html
      7.4. For forums.php: http://yoursite.com/s-section_id.html, http://yoursite.com/q-topic_id.html and http://yoursite.com/t-post_id.html
      7.5. For users.php: http://yoursite.com/u-user_id.html
      8. Extra SEO shortcuts:
      8.1. For forums.php: http://yoursite.com/q-topic_id-topic-title-text-here.html, http://yoursite.com/s-section_id-section-title-text-here.html and http://yoursite.com/t-post_id-topic-title-text-here.html
      8.2. For page.php: http://yoursite.com/i-page_id-page-title-text-here.html
      8.3. For users.php: http://yoursite.com/user/UserName
      9. Supported webservers: Apache 1.x, Apache 2.x, Microsoft IIS, nginx.
      10. Backwards compatible. It won't break your old Google index and you can safely disable it any time you want.
      11. URL format managed in admin panel. Even .htaccess/.ini is generated by script.
      12. Flexible (if you are an experienced coder).


Installation:
You must be attentive to follow all the instructions given, otherwise you may fail with no result or even cause damage to your Seditio source tree.


      1. Download and install Seditio Patcher Tool (http://www.seditioforge.com/plugins/administration/code-patcher-tool-i47.html). It is used during the installation process. Or you can do patching manually (see step 9).

      2. Download the Rewrite extension (see the link below) and unpack it into a temporary location. Put the 'plugins/rewrite' folder into your Seditio 'plugins' folder. Put 'system/rewrite.php' into your Seditio 'system' folder. It is safe to install the plugin now, it just won't work until you finish the installation.

      3. Now log into your Seditio admin panel and do not logout until the installation is finished.

      4. Open 'patches/common.hook.txt'. Put its contents right before the following code in system/common.php:

      [code]
      /* ======== Anti-XSS protection ======== */

      $xg = sed_import('x','G','ALP');
      $xp = sed_import('x','P','ALP');

      $xk = sed_check_xp();
      [/code]
	
      So that it becomes:

      [code]
      /* === Hook === */
      $extp = sed_getextplugins('input');
      if (is_array($extp))
      { foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
      /* ======================== */

      /* ======== Anti-XSS protection ======== */

      $xg = sed_import('x','G','ALP');
      $xp = sed_import('x','P','ALP');

      $xk = sed_check_xp();
      [/code]

      5. Open your 'system/functions.php'. Find sed_javascript function and replace it with one found in 'patches/functions.sed_javascript.txt'. Then go to the bottom of 'system/functions.php' and just before "?>" add the code from 'patches/functions.bottom.txt'.

      6. In order for popups to work, you need to modify 2 files more. Open your 'system/core/pfs/pfs.inc.php' and find the code beginning with
      [code]
$pfs_header1 = $cfg['doctype']."<html><head>
<title>".$cfg['maintitle']."</title>".sed_htmlmetas()."
      [/code]
      and ending with
      [code]
//-->
</script>
";
      [/code]
      Replace it with the code provided in 'patches/pfs.pfs_header1.txt'.

      7. Open 'system/core/polls/polls.inc.php' and find the code beginning with
       [code]
$polls_header1 = $cfg['doctype']."<html><head>
<title>".$cfg['maintitle']."</title>".sed_htmlmetas()."
      [/code]
      and ending with
      [code]
//-->
</script>";
      [/code]
      Replace it with the code provided in 'patches/polls.polls_header1.txt'.

      8. Now go to your admin.php?m=plug and install the Rewrite Extension. Note that any redirect attempts will give you 404 error right after plugin is installed. Also no URLs will have been changed yet.

      9. There are 2 ways to solve the redirect problem.
      9.1. If you have successfully installed the Patcher Tool go to Admin -> Tools -> Patcher Tool. Enter patching parameters as follows. Find: "#\sheader\(#" (without quotes). Replace: " sed_header(" (without quotes). Push the "Scan" button. If the scanner tells that some files are not writable, set the appropriate chmods to them and their folders (you may set them back after patching). When done with chmods, click the "Patch" button. Be careful no to patch 'system/rewrite.php'. Restore it from the package if you have done so.
      9.2. If you don't have the Patcher or it fails to patch, you should patch the files manually. First you need "find-and-replace in files" text editor. Then download your Seditio source tree from server and patch it locally. All you need is to replace the "header" function calls with "sed_header" ones in all of the .php files. So, "Find" is "header(" and "Replace" is "sed_header(". Be careful no to patch 'system/rewrite.php'. Restore it from the package if you have done so. When you are done with patching, upload the files back to your server.

      10. Open 'system/common.php' again. Find the following code:
      [code]
      /* ======== Gzip and output filtering ======== */

if ($cfg['gzip'])
	{ @ob_start('ob_gzhandler'); }
else
	{ ob_start(); }

ob_start('sed_outputfilters');
      [/code]

      And add just a line of code to it:
      [code]
// Enables rewrite
ob_start('rewrite_output');
      [/code]
      
      11. Go to your Admin panel -> Plugins and install the Rewrite Extension. Then you need to configure it:
      11.1. Do not enable the rewrite engine until you have changed your .htaccess/.ini (see step 12).
      11.2. Choose rewrite options you want and separators for your URLs. Do not use the same separator for main and name-value.
      11.3. Add more scripts to the lists if your Seditio is non-standard.

      12. Go to your Admin panel -> Tools -> Rewrite Extension and generate your .htaccess/IsapiRewrite4.ini:
      12.1. Apache users. Save generated .htaccess in your Seditio root, or, if your .htaccess is writable, you can do it by clicking an appropriate link below.
      12.2. IIS users. Install free Ionic's ISAPI Rewrite Filter (http://cheeso.members.winisp.net/IIRF.aspx). For instructions see the Readme which comes with it . Put 'IsapiRewrite4.ini' generated by admin tool into the same directory your 'IsapiRewrite4.dll' resides.

      13. Go to Rewrite Extension configuration and enable the rewrite engine.


Updating instructions:
0.3-0.4:
1. Uninstall the plugin in your admin panel and remove old files.
2. Follow Steps 2, 11, 12 from the "Installation" instructions given above.
3. Finish with the Step 13. Now you have successfully upgraded.


Updating Seditio:
If you update your Seditio or add new plugins take care of the following things:


      1. Repeat all the manipulations with the source files after upgrading your Seditio.
      2. If installing a new plugin, search its source for header() calls and replace them with sed_header() calls. Do not use the Patcher tool in this case, because it will spoil the sed_header() function itself. Or you may use the Patcher tool, but you need to open the sed_header() function and change all sed_header() calls inside of it back to header() ones right after patching.



Customizing your URLs:


      1. First you should know about switches in Admin panel configuration witch control some standard features. When you make any changes in the URL format, disable the rewrite engine when you edit the configuration. Then generate new .htaccess/IsapiRewrite4.ini and enable the engine again after you have applied webserver configuration. Otherwise you may encounter problems by following URLs which haven't yet been accepted by webserver.
      1.1. SHORTCUTS. Whether to use shortcuts when converting URLs. Enabled by default. Switch it off if you don't need shortcut but want better performance. It also switches off the rest extras.
      1.2. EXTRA SEO. Whether to append additional text to the URLs. It doesn't make any sense for Seditio (besides extra database load) but it is significant for search engines.
      1.3. TRANSLIT. Whether to transliterate non-latin characters in extra SEO text. Use for your own risk.
      1.4. CHARSET. Your charset used for transliteration.
      1.5. USERS. Whether to use usernames as shortcuts. Pages of users with latinic names will be accessible at http://yoursite.com/users/UserName.
      1.6. MAIN SEPARATOR. The main URL separator. With rewrite=off it is "?" or "&", default for rewrite is "/".
      1.7. NAME-VALUE SEPARATOR. Secondary URL separator. With rewrite=off it is "=", default for rewrite is "-".
      1.8. SUFFIX. Pages suffix in the url. You may use ".html", ".asp", any other extension or just leave it blank for no suffix at all.

      2. If you have enabled EXTRA SEO, TRANSLIT and filled CHARSET but extra SEO still doesn't work (check forum topics, for example) or adds ????? instead of characters, it means that you don't have iconv extension or iconv cannot transliterate your encoding. In this case you need to write and enable your own translit function. The example with WINDOWS-1251 encoding is given in 'plugins/rewrite/rewrite.php'. After you have your translit function, comment the line with iconv() in rewrite_prep() and add $title = your_translit_function($title), like in example. Don't forget to say the file itself in your encoding!

      3. Still want more custom URLs? Not a problem.
      3.1. First you need to know PHP (http://www.php.net/manual/en/ is a good teacher). Then you need to know PCRE (http://www.php.net/manual/en/reference.pcre.pattern.syntax.php will help). Then you need some basic knowledge of mod_rewrite (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html is all you need).
      3.2. Ready to go? Now open 'system/rewrite.php' and find "Configuration" section in rewrite_output(). Here you can set the delimiters you want and also a page suffix. Note that $rwr_sep and $rwr_psep should be different sequences (otherwise the parser will fail) and you should be aware of RFC 2616 (http://www.w3.org/Protocols/rfc2616/rfc2616.html) when choosing separators.
      3.3. And finally the hardest task. Open your .htaccess files and edit the rules for your new URLs. Usually it means you need to replace old separators with new ones, old .html suffix with yours and don't forget to escape PCRE sequences.
      4. Want your own shortcuts? Not a problem if you are familiar with the fist 3 tricks. Open 'system/rewrite.php', rewrite_output() function and find "Custom shortcuts" section. After you have understood its simple logic, you will be able to add your own shortcuts or change existing ones. And don't forget to add your new rules to .htaccess file.



Changelog:
      0.4.3:
      + nginx webserver support.
      * Improved .htaccess/IsapiRewrite4.ini/nginx.conf generator.
      * Plugin compatibility fixes (e.g. T3 Index).
      * More stability.

      0.4.2:
      * Apache 1.3 compatibility.
      * Bugfix in .htaccess generator.
      * Stability fixes for EXTRA SEO.

      0.4.1:
      * PHP4-compatibility fix.

      0.4:
      @ All the configuration/customization has moved to the Admin panel.
      + Automated .htaccess/IsapiRewrite4.ini generator tool.
      * Code optimizations. Thanks to CTAPbIu_MABP for PHP coding lessons.

      0.3.3:
      * Slight optimization.

      0.3.2:
      * Bugfix for users.

      0.3.1:
      + http://yoursite.com/user/UserName user pages instead of http://yoursite.com/u-something.html
      * Performance optimizations.
      * A few bugfixes.
      - User-friendly shortcuts have gone for good (actually, for stability reasons).

      0.3:
      @ New efficient architecture.
      * Speed optimizations.
      * Fixed problems with popups.

      0.2.3:
      + Absolute urls support (converts old absolute urls).
      + Shortcuts to forum pages (t-page_id).
      + More EXTRA_SEO.
      * Fixes for background images and style properties.

      0.2.2:
      * Bugfix in .htaccess/IsapiRewrite4.ini

      0.2.1:
      + Microsoft IIS support (thanks seboo1987 for beta-testing).
      + More EXTRA_SEO.
      + Shortcuts for users.php and homepage-like URLs.
      * Optimizations in rewrite rules.

      0.2:
      + New shortcut engine.
      + New SEO-friendly shortcuts.
      + Shortcuts enabled by default.
      + Extra SEO abilities.
      + Microsoft IIS support (experimental)
      * Fixed a bug in sed_header().

Known issues:

1. CAPTCHA doesn't work after installing Rewrite Extension. To fix it open your php-captcha.inc.php (usually 'plugins/captcha/inc/php-captcha.inc.ph', but some other plugins use this script as well) and replace all "sed_header" occurances with "header" ones (without quotes). Now your captcha is back.

2.  When a user logs out, immidiate log-in gives "Wrong parameter in the URL" error. To fix this, go admin/m-config/n-edit/o-core/p-main.html and set an appropriate Cookie path. For example, if your Seditio is installed in htdocs root, it's just "/". If it is in "seditio" subfolder, path is "/seditio". Next time a user logs in, the bug is gone. 


Comments:
Yes, probably the most hardcore Seditio plugin you have ever seen. Designed first of all for my own and then for the other geeks who wish their URLs look as they want them to look.

Not 100% bug-proof, so report if any.

Made to be as fast as possible (limited by the architecture chosen, of course), but still there can be some optimizations. 