TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 04:43:21 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,105
  • Total Topics: 21,213
  • Online today: 243
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 247
  • Total: 247

QueryString.php

Started by biohrd, August 27, 2008, 12:55:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

biohrd

QuoteFind:
     
Code:
// Let's do something special for session ids!
      if (defined('SID') && SID != '')
         $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:board|topic)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html?' . SID . '\$2\"'", $buffer);
      else
         $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2\"'", $buffer);

Replace With:
     
Code:
// Let's do something special for session ids!
      if (defined('SID') && SID != '')
         $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:board|topic|page|cat|action)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html?' . SID . '\$2\"'", $buffer);
      else
         $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:board|topic|page|cat|action)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2\"'", $buffer);

Nazwa modyfikacji   Wersja   
1.   Karma Buttons   1.0     [ Odinstaluj ] [ Pokaż pliki ] [ UsuÅ,, ]
2.   Spoiler Show And Hide   1.0.3     [ Odinstaluj ] [ Pokaż pliki ] [ UsuÅ,, ]
3.   Referrals Mod   2.0.1     [ Odinstaluj ] [ Pokaż pliki ] [ UsuÅ,, ]
4.   Custom Profile Field Mod   3.17     [ Odinstaluj ] [ Pokaż pliki ] [ UsuÅ,, ]
5.   Hide Tag   1.7.0     [ Odinstaluj ] [ Pokaż pliki ] [ UsuÅ,, ]
6.   Pretty URLs - Base   0.8.3     [ Odinstaluj ] [ Pokaż pliki ] [ UsuÅ,, ]
7.   Hide SMF Version   1.0.2     [ Odinstaluj ] [ Pokaż pliki ] [ UsuÅ,, ]
8.   SMF Sitemap   1.2.2     [ Odinstaluj ] [ Pokaż pliki ] [ UsuÅ,, ]

I have these mods installed on forum (SMF 1.1.5)

I have trouble at QueryString.php, because I dont have these things:
// Let's do something special for session ids!
and all after this

Quote// Rewrite URLs to include the session ID.
function ob_sessrewrite($buffer)
{
   global $scripturl, $modSettings, $user_info, $context, $db_prefix, $sourcedir, $txt, $time_start, $db_count;

   // If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
   if ($scripturl == '' || !defined('SID'))
      return $buffer;

   // Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit().  This doesn't work below PHP 4.3.0, because it makes the output buffer bigger.
   // !!! smflib
   if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1)
      $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')(\?)?/', '"' . $scripturl . '?' . SID . '&', $buffer);
   // Debugging templates, are we?
   elseif (isset($_GET['debug']))
      $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '(\?)?/', '"' . $scripturl . '?debug;', $buffer);

   //   Rewrite the buffer with Pretty URLs!
   if ($modSettings['pretty_enable_filters'])
   {
      //   Remove the script tags now
      $context['pretty']['scriptID'] = 0;
      $context['pretty']['scripts'] = array();
      $buffer = preg_replace_callback('~<script.+?</script>~s', 'pretty_scripts_remove', $buffer);

      //   Find all URLs in the buffer
      $context['pretty']['search_patterns'][] = '~(<a[^>]+href=|<link[^>]+href=|<form[^>]+?action=)(\"[^\"#]+|\'[^\'#]+)~';
      $urls_query = array();
      $uncached_urls = array();
      foreach ($context['pretty']['search_patterns'] as $pattern)
      {
         preg_match_all($pattern, $buffer, $matches, PREG_PATTERN_ORDER);
         foreach ($matches[2] as $match)
         {
            //   Rip out everything that shouldn't be cached
            $match = preg_replace(array('~^[\"\']|PHPSESSID=[^;]+|sesc=[^;]+~', '~\"~', '~;+|=;~', '~\?;~', '~\?$|;$|=$~'), array('', '%22', ';', '?', ''), $match);
            $url_id = str_replace(array($scripturl . '?board=', $scripturl . '?topic=', $scripturl . '?action=', $scripturl), array('`B', '`T', '`A', '`S'), $match);
            $urls_query[] = '\'' . addslashes($url_id) . '\'';
            $uncached_urls[$url_id] = array(
               'url' => $match,
               'url_id' => $url_id
            );
         }
      }

      //   Procede only if there are actually URLs in the page
      if (count($urls_query) != 0)
      {
         $urls_query = array_keys(array_flip($urls_query));
         //   Retrieve cached URLs
         $context['pretty']['cached_urls'] = array();
         $query = db_query("
            SELECT url_id, replacement
            FROM {$db_prefix}pretty_urls_cache
            WHERE url_id IN (" . implode(', ', $urls_query) . ')', __FILE__, __LINE__);
         while ($row = mysql_fetch_assoc($query))
         {
            $context['pretty']['cached_urls'][$row['url_id']] = $row['replacement'];
            unset($uncached_urls[$row['url_id']]);
         }
         mysql_free_result($query);

         //   If there are any uncached URLs, process them
         if (count($uncached_urls) != 0)
         {
            //   Run each filter callback function on each URL
            require_once($sourcedir . '/PrettyUrls-Filters.php');
            $filter_callbacks = unserialize($modSettings['pretty_filter_callbacks']);
            foreach ($filter_callbacks as $callback)
               $uncached_urls = call_user_func($callback, $uncached_urls);

            //   Fill the cached URLs array
            $cache_data = array();
            foreach ($uncached_urls as $url_id => $url)
            {
               if (!isset($url['replacement']))
                  $url['replacement'] = $url['url'];
               $url['replacement'] = str_replace(chr(18), '\'', $url['replacement']);
               $url['replacement'] = preg_replace(array('~\"~', '~;+|=;~', '~\?;~', '~\?$|;$|=$~'), array('%22', ';', '?', ''), $url['replacement']);
               $context['pretty']['cached_urls'][$url_id] = $url['replacement'];
               if (strlen($url_id) < 256 && strlen($url['replacement']) < 256)
                  $cache_data[] = '(\'' . addslashes($url_id) . '\', \'' . addslashes($url['replacement']) . '\')';
            }

            //   Cache these URLs in the database
            if (count($cache_data) != 0)
               db_query("
                  REPLACE INTO {$db_prefix}pretty_urls_cache
                     (url_id, replacement)
                  VALUES " . implode(', ', $cache_data), __FILE__, __LINE__);
         }

         //   Put the URLs back into the buffer
         $context['pretty']['replace_patterns'][] = '~(<a[^>]+href=|<link[^>]+href=|<form[^>]+?action=)(\"[^\"]+\"|\'[^\']+\')~';
         foreach ($context['pretty']['replace_patterns'] as $pattern)
            $buffer = preg_replace_callback($pattern, 'pretty_buffer_callback', $buffer);
      }

      //   Restore the script tags
      if ($context['pretty']['scriptID'] > 0)
         $buffer = preg_replace_callback('~' . chr(20) . '([0-9]+)' . chr(20) . '~', 'pretty_scripts_restore', $buffer);
   }

   //   Update the load times
   $pattern = '~<span class="smalltext">' . $txt['smf301'] . '([.0-9]+)' . $txt['smf302'] . '([0-9]+)' . $txt['smf302b'] . '</span>~';
   if (preg_match($pattern, $buffer, $matches))
   {
      $newTime = round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3);
      $timeDiff = $newTime - (float) $matches[1];
      $queriesDiff = $db_count + $context['pretty']['db_count'] - (int) $matches[2];
      //   Remove the link if you like, I won't enforce it like others do
      $newLoadTime = '<span class="smalltext">' . $txt['smf301'] . $newTime . $txt['smf302'] . $db_count . $txt['smf302b'] . ' (Pretty URLs adds ' . $timeDiff . 's, ' . $queriesDiff . 'q)</span>';
      $buffer = str_replace($matches[0], $newLoadTime, $buffer);
   }

   // Return the changed buffer.
   return $buffer;
}

How to install? Please help.

G6Cad

You have to compare the code bits and see where they are diffrent, then add it in bit by bit. there are no easy way when you have some other mod installed that have changed the same part of code.

biohrd

TP is changing
Quoteboard|topic
to
Quoteboard|topic|page|cat|action

But I dont have board|topic in QueryString.php

:/

G6Cad

Try and search for a line over or under then.

What mod have removed the lines from the file ?

As we dont know the code for these mods, it's hard to give support on this.

You have to check the mods out, or simply uninstall the other mods, then install TP, and then install the mods back again. Thats about how far we can support you if another mod have removed the files TP searches for in the file,

Just a quick thought, are yu reaally sure it's the Sources/QueryString.php you have the file you try to edit ?  Have happend before that members have actually checked the wrong file for strings

biohrd

Mod is called "Preety Urls".

I think something is in this line, but I don't know where to edit
Quote//   Find all URLs in the buffer
      $context['pretty']['search_patterns'][] = '~(<a[^>]+href=|<link[^>]+href=|<form[^>]+?action=)(\"[^\"#]+|\'[^\'#]+)~';

bloc

Don't add the change in Querystring.php for TP when you are using Pretty Urls, they are not needed then. Pretty urls should already support TP.

biohrd

Cool. Thx for reply. I was worried a little, so I didnt installed TP :P