Added support for "Tiny URLs" (http://example.com/enano/?/Foo)
authorDan
Sat, 21 Mar 2009 14:54:16 -0400
changeset 876 aed15c337b72
parent 864 09c3ba4f6fbf
child 877 e9ee4e246f96
Added support for "Tiny URLs" (http://example.com/enano/?/Foo)
includes/paths.php
install/includes/payload.php
install/includes/stages/website.php
install/install.php
language/english/install.json
--- a/includes/paths.php	Sat Mar 14 15:26:33 2009 -0400
+++ b/includes/paths.php	Sat Mar 21 14:54:16 2009 -0400
@@ -142,13 +142,10 @@
     {
       // This method really isn't supported because apache has a habit of passing dots as underscores, thus corrupting the request
       // If you really want to try it, the URI format is yoursite.com/?/Page_title
-      if ( count($_GET) > 0 )
+      if ( !empty($_SERVER['QUERY_STRING']) && substr($_SERVER['QUERY_STRING'], 0, 1) == '/' )
       {
-        list($getkey) = array_keys($_GET);
-        if ( substr($getkey, 0, 1) == '/' )
-        {
-          $title = substr($getkey, 1);
-        }
+        $pos = ( ($_ = strpos($_SERVER['QUERY_STRING'], '&')) !== false ) ? $_ - 1: 0x7FFFFFFF;
+        $title = substr($_SERVER['QUERY_STRING'], 1, $pos);
       }
     }
     return ( $sanitize ) ? sanitize_page_id($title) : $title;
--- a/install/includes/payload.php	Sat Mar 14 15:26:33 2009 -0400
+++ b/install/includes/payload.php	Sat Mar 21 14:54:16 2009 -0400
@@ -192,6 +192,9 @@
     case 'shortened':
       $sp_append = '/index.php/';
       break;
+    case 'tiny':
+      $sp_append = '/?/';
+      break;
     case 'rewrite':
       $sp_append = '/';
       break;
--- a/install/includes/stages/website.php	Sat Mar 14 15:26:33 2009 -0400
+++ b/install/includes/stages/website.php	Sat Mar 21 14:54:16 2009 -0400
@@ -56,6 +56,20 @@
       }
       else
       {
+        ajaxGet(scriptPath + '/install/install.php?/tiny&do=modrewrite_test', __ajaxMrwTest_chain_tiny);
+      }
+    }
+  }
+  var __ajaxMrwTest_chain_tiny = function()
+  {
+    if ( ajax.readyState == 4 )
+    {
+      if ( ajax.responseText == 'good_tiny' )
+      {
+        ajaxMrwSet('tiny');
+      }
+      else
+      {
         ajaxGet(scriptPath + '/install/install.php?do=modrewrite_test&str=standard', __ajaxMrwTest_chain_standard);
       }
     }
@@ -78,12 +92,13 @@
   function ajaxMrwSet(level)
   {
     install_unset_ajax_loading();
-    if ( !in_array(level, ['rewrite', 'shortened', 'standard']) )
+    if ( !in_array(level, ['rewrite', 'shortened', 'standard', 'tiny']) )
       return false;
     
     document.getElementById('url_radio_rewrite').checked = false;
     document.getElementById('url_radio_shortened').checked = false;
     document.getElementById('url_radio_standard').checked = false;
+    document.getElementById('url_radio_tiny').checked = false;
     document.getElementById('url_radio_' + level).checked = true;
     document.getElementById('url_radio_' + level).focus();
     
@@ -95,6 +110,9 @@
       case 'shortened':
         var str = $lang.get('website_msg_bestmethod_shortened');
         break;
+      case 'tiny':
+        var str = $lang.get('website_msg_bestmethod_tiny');
+        break;
       case 'standard':
         var str = $lang.get('website_msg_bestmethod_standard');
         break;
@@ -148,7 +166,7 @@
   ?>
   
   <?php
-  $patch_necessary = ( ( strtolower(PHP_OS) == 'win32' || strtolower(PHP_OS) == 'winnt' ) && substr(@$_SERVER['SERVER_SOFTWARE'], 'Apache/2.2') );
+  $patch_necessary = ( ( strtolower(PHP_OS) == 'win32' || strtolower(PHP_OS) == 'winnt' ) && strstr(@$_SERVER['SERVER_SOFTWARE'], 'Apache/2.2') );
   if ( defined('WINDOWS_MOD_REWRITE_WORKAROUNDS') )
   {
     ?>
@@ -264,6 +282,23 @@
           </tr>
         </table>
         
+        <table border="0" cellpadding="10" cellspacing="0">
+          <tr>
+            <td valign="top">
+              <input type="radio" name="url_scheme" value="tiny" id="url_radio_tiny" tabindex="5" />
+            </td>
+            <td>
+              <label for="url_radio_tiny">
+                <b><?php echo $lang->get('website_field_urlscheme_opt_tiny'); ?></b>
+              </label>
+              <span id="hint_url_scheme_tiny" class="fieldtip">
+                <p><?php echo $lang->get('website_field_urlscheme_opt_tiny_hint'); ?></p>
+                <p><small><b><?php echo $lang->get('website_field_urlscheme_lbl_example'); ?></b> <tt><?php echo $scriptpath_full . '?/Page'; ?></tt></small></p>
+              </span>
+            </td>
+          </tr>
+        </table>
+        
         <p>
           <a href="#mrw_scan" onclick="ajaxMrwTest(); return false;" tabindex="4"><?php echo $lang->get('website_btn_urlscheme_detect'); ?></a>
         </p>
--- a/install/install.php	Sat Mar 14 15:26:33 2009 -0400
+++ b/install/install.php	Sat Mar 21 14:54:16 2009 -0400
@@ -195,6 +195,10 @@
       {
         echo 'good_' . $_GET['str'];
       }
+      else if ( $_SERVER['QUERY_STRING'] == '/tiny&do=modrewrite_test' )
+      {
+        echo 'good_tiny';
+      }
       else
       {
         echo 'bad';
--- a/language/english/install.json	Sat Mar 14 15:26:33 2009 -0400
+++ b/language/english/install.json	Sat Mar 21 14:54:16 2009 -0400
@@ -1,6 +1,6 @@
 /*
  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
- * Version 1.1.1
+ * Version 1.1.6 (Caoineag beta 1)
  * Copyright (C) 2006-2007 Dan Fuhry
  *
  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
@@ -248,6 +248,7 @@
       msg_ajax_test_fail_body: 'None of the URL handling tests worked; you may have problems using Enano on your server.',
       msg_bestmethod_rewrite: 'The installer has detected that using rewritten URLs is the best level that will work.',
       msg_bestmethod_shortened: 'The installer has detected that using shortened URLs is the best level that will work.',
+      msg_bestmethod_tiny: 'The installer has detected that using tiny URLs is the best level that will work.',
       msg_bestmethod_standard: 'The installer has detected that using standard URLs is the only level that will work.',
       msg_modrewrite_enabled: 'Your copy of Enano has the Windows mod_rewrite workaround patch enabled.',
       msg_modrewrite_necessary: 'If you don\'t plan to use the Rewritten URLs option below, you should go back and re-download Enano without this workaround enabled. The mod_rewrite issues Enano faces under Windows are caused by a security change in Apache 2.2 that is not present in Apache 2.0. <a href="http://enanocms.org/windows-patch" onclick="window.open(this.href); return false;">Learn more</a>',
@@ -270,6 +271,8 @@
       field_urlscheme_opt_shortened_hint: 'This eliminates the "?title=" portion of your URL, and instead uses a slash. This is occasionally more friendly to search engines.',
       field_urlscheme_opt_rewrite: 'Rewritten URLs',
       field_urlscheme_opt_rewrite_hint: 'Using this option, you can completely eliminate the "index.php" from URLs. This is the most friendly option to search engines and looks very professional, but requires support for URL rewriting on your server. If you\'re running Apache and have the right permissions, Enano can configure this automatically. Otherwise, you\'ll need to configure your server manually and have a knowledge of regular expressions for this option to work.',
+      field_urlscheme_opt_tiny: '<span style="font-weight: bold; color: #a00;">(Experimental)</span> Tiny URLs',
+      field_urlscheme_opt_tiny_hint: 'This makes URLs very small - close to the size of Rewritten. However it doesn\'t work with every server, and we\'re still trying to experiment to find which servers it works with. If you can\'t use Rewritten URLs, you are encouraged to give this a try and let the Enano team know whether it works for you or not.',
       btn_urlscheme_detect: 'Auto-detect the best formatting scheme',
       
       objective_verify: 'Verify that your site information is correct. Again, all of the above settings can be changed from the administration panel.',