Fixed some regular expressions in HTML optimization algorithm; regex page groups can be edited now (oops)
authorDan
Tue, 09 Oct 2007 16:14:55 -0400
changeset 173 91127e62f38f
parent 172 1bc7e849a264
child 174 d74ff822acc9
child 175 ab6336bfce48
Fixed some regular expressions in HTML optimization algorithm; regex page groups can be edited now (oops)
includes/functions.php
index.php
plugins/SpecialAdmin.php
plugins/admin/PageGroups.php
--- a/includes/functions.php	Sun Oct 07 17:22:25 2007 -0400
+++ b/includes/functions.php	Tue Oct 09 16:14:55 2007 -0400
@@ -2796,7 +2796,7 @@
   $strip_tags = implode('|', $strip_tags);
   
   // Strip out the tags and replace with placeholders
-  preg_match_all("#<($strip_tags)(.*?)>(.*?)</($strip_tags)>#is", $html, $matches);
+  preg_match_all("#<($strip_tags)([ ]+.*?)?>(.*?)</($strip_tags)>#is", $html, $matches);
   $seed = md5(microtime() . mt_rand()); // Random value used for placeholders
   for ($i = 0;$i < sizeof($matches[1]); $i++)
   {
@@ -2804,7 +2804,7 @@
   }
   
   // Optimize (but don't obfuscate) Javascript
-  preg_match_all('/<script(.*?)>(.+?)<\/script>/is', $html, $jscript);
+  preg_match_all('/<script([ ]+.*?)?>(.*?)<\/script>/is', $html, $jscript);
   
   // list of Javascript reserved words - from about.com
   $reserved_words = array('abstract', 'as', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'continue', 'const', 'debugger', 'default', 'delete', 'do',
@@ -2819,6 +2819,8 @@
   {
     $js =& $jscript[2][$i];
     
+    // echo('<pre>' . "-----------------------------------------------------------------------------\n" . htmlspecialchars($js) . '</pre>');
+    
     // for line optimization, explode it
     $particles = explode("\n", $js);
     
--- a/index.php	Sun Oct 07 17:22:25 2007 -0400
+++ b/index.php	Tue Oct 09 16:14:55 2007 -0400
@@ -15,7 +15,7 @@
 
   // Set up gzip encoding before any output is sent
   
-  $aggressive_optimize_html = false;
+  $aggressive_optimize_html = true;
   
   global $do_gzip;
   $do_gzip = true;
--- a/plugins/SpecialAdmin.php	Sun Oct 07 17:22:25 2007 -0400
+++ b/plugins/SpecialAdmin.php	Tue Oct 09 16:14:55 2007 -0400
@@ -3158,6 +3158,8 @@
           $parser = $template->makeParserText($vars['sidebar_section']);
           $c = $template->tplWikiFormat($row['block_content'], false, 'sidebar-editor.tpl');
           $c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c);
+          // fix for the "Administration" link that somehow didn't get rendered properly
+          $c = preg_replace("/(^|\n)([ ]*)<a([ ]+.*)?>(.+)<\/a>(<br(.*)\/>)([\r\n]+|$)/isU", '\\1\\2<li><a\\3>\\4</a></li>\\7', $c);
           break;
         case BLOCK_HTML:
           $parser = $template->makeParserText($vars['sidebar_section_raw']);
--- a/plugins/admin/PageGroups.php	Sun Oct 07 17:22:25 2007 -0400
+++ b/plugins/admin/PageGroups.php	Tue Oct 09 16:14:55 2007 -0400
@@ -602,6 +602,23 @@
                   echo '<div class="info-box">The affecting tag was updated.</div>';
               }
             }
+            else if ( $_POST['pg_type'] == PAGE_GRP_REGEX )
+            {
+              $target = $_POST['pg_target'];
+              if ( empty($target) )
+              {
+                echo '<div class="error-box">Please enter an expression to match against..</div>';
+              }
+              else
+              {
+                $target = $db->escape($target);
+                $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
+                if ( !$q )
+                  $db->_die();
+                else
+                  echo '<div class="info-box">The expression to match against was updated.</div>';
+              }
+            }
             else if ( $_POST['pg_type'] == PAGE_GRP_CATLINK )
             {
               $target = $_POST['pg_target'];
@@ -860,6 +877,22 @@
                   </td>
                 </tr>';
           break;
+        case PAGE_GRP_REGEX:
+          echo '<tr>
+                  <td class="row2">
+                    Regular expression to use:<br />
+                    <small>Be sure to include the starting and ending delimiters and any flags you might need.<br />
+                           These pages might help: <a href="http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php">Pattern modifiers</a> &bull;
+                           <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Pattern syntax</a><br />
+                           Examples: <tt>/^(Special|Admin):/i</tt> &bull; <tt>/^Image:([0-9]+)$/</tt><br />
+                           Developers, remember that this will be matched against the full page identifier string. This means that <tt>/^About_Enano$/</tt>
+                           will NOT match the page Special:About_Enano.</small>
+                  </td>
+                  <td class="row1">
+                    <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" />
+                  </td>
+                </tr>';
+          break;
         case PAGE_GRP_CATLINK:
           
           // Build category list