News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - SleePy

#16
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');

$base_path = '/home/svn/sm-smf/trunk';
$settings_path = '/home/smf/svn_files';

$php_open = '<' . '?' . 'php';

$revision = trim(str_replace('Revision: ', '', shell_exec('svn info /home/svn/sm-smf/trunk | grep "Revision"')));

// Get.
$contents = file_get_contents($base_path . '/index.php');

// The revision.

// Edit.
$contents = strtr($contents, array(
   'require_once(dirname(__FILE__) . \'/Settings.php\');' => 'require(\'' . $settings_path . '/Settings.php\');',
));


if (isset($_GET['destory_session']))
{
   $contents = file_get_contents($base_path . '/SSI.php');
   $contents = substr($contents, strlen($php_open));
   eval($contents);

   require_once($sourcedir . '/Subs-Auth.php');
   setLoginCookie(-3600, 0);
   if (isset($_SESSION['login_' . $cookiename]))
      unset($_SESSION['login_' . $cookiename]);

   
   Header('location: ' . str_replace('session_destroy', '', $_SERVER['HTTP_REFERER']));
   exit;
}

// Prepare.
$contents = substr($contents, strlen($php_open));

// Send.
$forum_version = 'SMF test';

$GLOBALS['true_start'] = microtime();
eval($contents);
$GLOBALS['true_end'] = microtime();

// Its quite possible that this actually is overriding the apache call.
require_once($settings_path . '/exit_script.php');
?>
#17
<?php

// Get the contents man.
$contents = ob_get_contents();
ob_clean();

// The contents.
if ($boardurl != 'http://svn.test')
   $contents = str_replace('http://svn.test', $boardurl, $contents);

// Only do the Theme changer in certain cases.
if (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('xmlhttp', '.xml', 'viewsmfile', 'viewquery', 'verificationcode', 'suggest', 'smstats', 'quickmod', 'quickmod2', 'quotefast', 'openidreturn', 'jsoption', 'jsmodify', 'jseditor')))
   themechanger($contents);

// The true execution time.
$time = round(array_sum(explode(' ', $GLOBALS['true_end'])) - array_sum(explode(' ', $GLOBALS['true_start'])), 3);
preg_match('~<p>Page created in ([\d.]+) seconds with (\d+) queries.</p>~i', $contents, $matches);
$contents = str_replace($matches[0], $matches[0] . '<p>Page REALLY created in ' . ($time) . ' seconds</p>', $contents);

echo $contents;

exit;

function themechanger(&$contents)
{
   global $smcFunc, $context, $user_info;

   if (empty($_SERVER['REQUEST_URL']))
      return;

   // Figure out our location easily.
   $location = preg_replace('~[;|?]theme=(\d+)~i', '', $_SERVER['REQUEST_URL']);
   if (strpos($location, '?') !== false)
      $location = $location . ';';
   else
      $location = $location . '?';

   // Is the current theme, wrong!
   if (isset($_REQUEST['theme']))
      $user_info['theme'] = (int) $_REQUEST['theme'];
   elseif (!empty($_SESSION['id_theme']))
      $user_info['theme'] = (int) $_SESSION['id_theme'];

   // Start.
   $thestring = '
<div id="svn_theme_changer" style="position: absolute; top:1em; left: 40em; color:red; z-index:999; display: none;">
   <form method="get" action="javascript://void;">
      <select name="theme" onchange="location=\''. $location . 'theme=\' + this.options[this.selectedIndex].value">';

   // Go database!
   $request = $smcFunc['db_query']('', '
      SELECT value, id_theme
      FROM {db_prefix}themes
         WHERE id_theme != {int:no_theme}
         AND id_member = {int:guest_id}
         AND variable = {string:theme_name}',
      array(
         'no_theme' => 0,
         'guest_id' => 0,
         'theme_name' => 'name',
   ));
   while ($row = $smcFunc['db_fetch_assoc']($request))
      $thestring .= '
         <option value="' . $row['id_theme'] . '"' . ($user_info['theme'] == $row['id_theme'] ? ' selected="selected"' : ''). '>' . $row['value'] . '</option>';

   $thestring .= '
      </select>
   </form>
</div>
<div style="position: absolute; top:0; left: 0; right: 0; color:red; z-index:999; dislay: none;">
<div id="svn_theme_changer_show" style="display: block; float: right;" ><a href="#1" onclick="document.getElementById(\'svn_theme_changer\').style.display = \'\'; document.getElementById(\'svn_theme_changer_show\').style.display = \'none\'; document.getElementById(\'svn_theme_changer_hide\').style.display = \'\';">expand</a></div>
<div id="svn_theme_changer_hide" style="display: none; float: right;"><a href="#2" onclick="document.getElementById(\'svn_theme_changer\').style.display = \'none\'; document.getElementById(\'svn_theme_changer_show\').style.display = \'\'; document.getElementById(\'svn_theme_changer_hide\').style.display = \'none\';">collapse</a></div></div>
<a style="float: right;" href="javascript:location=\'' . $_SERVER['REQUEST_URL'] . '&destory_session&secs=' . $context['session_id'] . '\'">[Destroy Session]</a>';
   

   // board_select_spot.gif   collapse
   // smiley_select_spot.gif  expand
   // Hack out and display the few themes we have quickly.
   $contents = str_replace('<body>', '<body>' . $thestring, $contents);

   return $contents;
}
?>
#18
<?php

   /**
    * SMF Authentication
    *
    * @author
    * @version 0.1
    * @package auth_smf
    * @subpackage core
    */

   /**
    * SMF Authentication
    *
    * @package auth_smf
    * @subpackage core
    */
   class SMFAuth extends TBGModule
   {
      protected $_longname = 'SMF Authentication';
      
      protected $_description = 'Allows authentication with a working SMF 2.0+ installtion';
      
      protected $_module_config_title = 'SMF Authentication';
      
      protected $_module_config_description = 'Configure server connection settings';
      
      protected $_module_version = '0.1';
      
      protected $_has_config_settings = true;

      /**
       * Return an instance of this module
       *
       * @return SMF Authentication
       */
      public static function getModule()
      {
         return TBGContext::getModule('auth_smf');
      }

      protected function _initialize()
      {
      }
      
      protected function _addRoutes()
      {
      }

      protected function _install($scope)
      {
      }

      protected function _uninstall()
      {
      }
      
      public final function getType()
      {
         return parent::MODULE_AUTH;
      }

      public function getRoute()
      {
         return TBGContext::getRouting()->generate('smf_authentication_index');
      }

      public function postConfigSettings(TBGRequest $request)
      {
         $settings = array('ssi_location', 'login_groups', 'admin_groups', 'enabled_groups', 'access_groups', 'password_salt');
         foreach ($settings as $setting)
         {
            if ($request->hasParameter($setting))
            {
               if (in_array($setting, array('login_groups', 'enabled_groups', 'access_groups', 'admin_groups')))
                  $value = serialize($request->getParameter($setting));
               else
                  $value = $request->getParameter($setting);

               $this->saveSetting($setting, $value);
            }
         }
      }
      
      public function connect()
      {
         $ssi_loc = $this->getSetting('ssi_location');

         // Ignore errors about SMF trying to be pre-PHP 5.3 compatible.
         try
         {
            require_once($ssi_loc . '/SSI.php');
         }
         catch (Exception $e)
         {
            // This ends SMF from trying to do url rewriting and fixes a loading issue in TBG.
            ob_end_clean();
         }

         return true;
      }
      
      public function bind()
      {
      }
      
      public function escape($string)
      {
      }

      public function doLogin($username, $password, $mode = 1)
      {
         global $user_info;

         $ssi_loc = $this->getSetting('ssi_location');

         // Ignore errors about SMF trying to be pre-PHP 5.3 compatible.
         try
         {
            require_once($ssi_loc . '/SSI.php');
         }
         catch (Exception $e)
         {
            // This ends SMF from trying to do url rewriting and fixes a loading issue in TBG.
            ob_end_clean();

            // Because of the exception we caught from a deprecated warning, we have to call this manually.
            loadUserSettings();
         }

         $logingroups = unserialize($this->getSetting('login_groups'));
         $admingroups = unserialize($this->getSetting('admin_groups'));
         $salt = $this->getSetting('password_salt');
         $accessgroups = unserialize($this->getSetting('access_groups'));

         // Are they even allowed to login?
         if (!empty($logingroups) && array_intersect($logingroups, $user_info['groups']) == array())
            throw new Exception(TBGContext::getI18n()->__('You are not a member of a group allowed to log in'));

         // Try to get the user.
         $user = TBGUser::getByUsername($user_info['username']);
         if ($user instanceof TBGUser)
         {
            if (time() - $this->getSetting('smf_auth_updated', $user->getID())> 3600)
            {
               $user->setBuddyname($user_info['username']);
               $user->setRealname($user_info['name']);
               $user->setPassword($user->getJoinedDate() . $user_info['username'] . $salt); // update password
               $user->setEmail($user_info['email']); // update email address
               $user->save();
            }
         }
         else
         {
            /*
             * If not, and we are performing an initial login, create the user object
             * if we are validating a log in, kick the user out as the session is invalid.
             */
            if ($mode == 1)
            {                  
               // create user
               $user = new TBGUser();
               $user->setUsername($user_info['username']);
               $user->setRealname($user_info['name']);
               $user->setBuddyname($user_info['username']);
               $user->setEmail($user_info['email']);
               $user->setEnabled();
               $user->setActivated();
               $user->setJoined();
               $user->setPassword($user->getJoinedDate() . $user_info['username'] . $salt);
               $user->save();
            }
            else
               throw new Exception('User does not exist in TBG');
         }

         // Lets only do this every once in a while.
         if (time() - $this->getSetting('smf_auth_updated', $user->getID())> 3600)
         {
            // Nobody admins the admins.
            if (!empty($admingroups) && array_intersect($admingroups, $user_info['groups']))
            {
               $group = new TBGGroup();
               $group->setID(1);
               $user->setGroup($group);
            }
            else
            {
               $group = new TBGGroup();
               $group->setID(2);
               $user->setGroup($group);
            }

            // Give them the access they need!
            if (!empty($accessgroups))
            {
               // First, clear out current teams.
               $user->clearTeams();

               // Then add back the ones they should be in.
               foreach ($accessgroups as $smf_id => $tbg_groups)
                  if (in_array($smf_id, $user_info['groups']))
                     foreach ($tbg_groups as $tbgroup)
                     {
                        $team = new TBGTeam();
                        $team->setID($tbgroup);
                        $user->addToTeam($team);
                     }
            }

            // Update the time stamp so we don't keep doing this every page load.
            $this->saveSetting('smf_auth_updated', time(), $user->getID());
         }

         /*
          * Set cookies and return user row for general operations.
          */
         TBGContext::getResponse()->setCookie('tbg3_username', $user_info['username']);
         TBGContext::getResponse()->setCookie('tbg3_password', TBGUser::hashPassword($user->getJoinedDate() . $user_info['username'] . $salt));

         return TBGUsersTable::getTable()->getByUsername($user_info['username']);
      }

      public function verifyLogin($username, $password)
      {
         return $this->doLogin($username, 'a', 2);
      }
   }

#19
<?php

   /**
    * SMF Authentication
    *
    * @author
    * @version 0.1
    * @package auth_smf
    * @subpackage core
    */

   /**
    * SMF Authentication
    *
    * @package auth_smf
    * @subpackage core
    */
   class SMFAuth extends TBGModule
   {
      protected $_longname = 'SMF Authentication';
      
      protected $_description = 'Allows authentication with a working SMF 2.0+ installtion';
      
      protected $_module_config_title = 'SMF Authentication';
      
      protected $_module_config_description = 'Configure server connection settings';
      
      protected $_module_version = '0.1';
      
      protected $_has_config_settings = true;

      /**
       * Return an instance of this module
       *
       * @return SMF Authentication
       */
      public static function getModule()
      {
         return TBGContext::getModule('auth_smf');
      }

      protected function _initialize()
      {
      }
      
      protected function _addRoutes()
      {
      }

      protected function _install($scope)
      {
      }

      protected function _uninstall()
      {
      }
      
      public final function getType()
      {
         return parent::MODULE_AUTH;
      }

      public function getRoute()
      {
         return TBGContext::getRouting()->generate('smf_authentication_index');
      }

      public function postConfigSettings(TBGRequest $request)
      {
         $settings = array('ssi_location', 'login_groups', 'admin_groups', 'enabled_groups', 'access_groups', 'password_salt');
         foreach ($settings as $setting)
         {
            if ($request->hasParameter($setting))
            {
               if (in_array($setting, array('login_groups', 'enabled_groups', 'access_groups', 'admin_groups')))
                  $value = serialize($request->getParameter($setting));
               else
                  $value = $request->getParameter($setting);

               $this->saveSetting($setting, $value);
            }
         }
      }
      
      public function connect()
      {
         $ssi_loc = $this->getSetting('ssi_location');

         // Ignore errors about SMF trying to be pre-PHP 5.3 compatible.
         try
         {
            require_once($ssi_loc . '/SSI.php');
         }
         catch (Exception $e)
         {
            // This ends SMF from trying to do url rewriting and fixes a loading issue in TBG.
            ob_end_clean();
         }

         return true;
      }
      
      public function bind()
      {
      }
      
      public function escape($string)
      {
      }

      public function doLogin($username, $password, $mode = 1)
      {
         global $user_info;

         $ssi_loc = $this->getSetting('ssi_location');

         // Ignore errors about SMF trying to be pre-PHP 5.3 compatible.
         try
         {
            require_once($ssi_loc . '/SSI.php');
         }
         catch (Exception $e)
         {
            // This ends SMF from trying to do url rewriting and fixes a loading issue in TBG.
            ob_end_clean();

            // Because of the exception we caught from a deprecated warning, we have to call this manually.
            loadUserSettings();
         }

         $logingroups = unserialize($this->getSetting('login_groups'));
         $admingroups = unserialize($this->getSetting('admin_groups'));
         $salt = $this->getSetting('password_salt');
         $accessgroups = unserialize($this->getSetting('access_groups'));

         // Are they even allowed to login?
         if (!empty($logingroups) && array_intersect($logingroups, $user_info['groups']) != array())
            throw new Exception(TBGContext::getI18n()->__('You are not a member of a group allowed to log in'));

         // Try to get the user.
         $user = TBGUser::getByUsername($user_info['username']);
         if ($user instanceof TBGUser)
         {
            if (time() - $this->getSetting('smf_auth_updated', $user->getID())> 3600)
            {
               $user->setBuddyname($user_info['username']);
               $user->setRealname($user_info['name']);
               $user->setPassword($user->getJoinedDate() . $user_info['username'] . $salt); // update password
               $user->setEmail($user_info['email']); // update email address
               $user->save();
            }
         }
         else
         {
            /*
             * If not, and we are performing an initial login, create the user object
             * if we are validating a log in, kick the user out as the session is invalid.
             */
            if ($mode == 1)
            {                  
               // create user
               $user = new TBGUser();
               $user->setUsername($user_info['username']);
               $user->setRealname($user_info['name']);
               $user->setBuddyname($user_info['username']);
               $user->setEmail($user_info['email']);
               $user->setEnabled();
               $user->setActivated();
               $user->setJoined();
               $user->setPassword($user->getJoinedDate() . $user_info['username'] . $salt);
               $user->save();
            }
            else
               throw new Exception('User does not exist in TBG');
         }

         // Lets only do this every once in a while.
         if (time() - $this->getSetting('smf_auth_updated', $user->getID())> 3600)
         {
            // Nobody admins the admins.
            if (!empty($admingroups) && array_intersect($admingroups, $user_info['groups']))
            {
               $group = new TBGGroup();
               $group->setID(1);
               $user->setGroup($group);
            }
            else
            {
               $group = new TBGGroup();
               $group->setID(2);
               $user->setGroup($group);
            }

            // Give them the access they need!
            if (!empty($accessgroups))
            {
               // First, clear out current teams.
               $user->clearTeams();

               // Then add back the ones they should be in.
               foreach ($accessgroups as $smf_id => $tbg_groups)
                  if (in_array($smf_id, $user_info['groups']))
                     foreach ($tbg_groups as $tbgroup)
                     {
                        $team = new TBGTeam();
                        $team->setID($tbgroup);
                        $user->addToTeam($team);
                     }
            }

            // Update the time stamp so we don't keep doing this every page load.
            $this->saveSetting('smf_auth_updated', time(), $user->getID());
         }

         /*
          * Set cookies and return user row for general operations.
          */
         TBGContext::getResponse()->setCookie('tbg3_username', $user_info['username']);
         TBGContext::getResponse()->setCookie('tbg3_password', TBGUser::hashPassword($user->getJoinedDate() . $user_info['username'] . $salt));

         return TBGUsersTable::getTable()->getByUsername($user_info['username']);
      }

      public function verifyLogin($username, $password)
      {
         return $this->doLogin($username, 'a', 2);
      }
   }

#20
dragonfly9_to_smf.sql:723:    if (substr($oldAttachmentDir, 0, 2) == '..')
eblah_to_smf.php:70:          if (empty($line) || substr($line, 0, 1) == '#')
eblah_to_smf.php:823:                elseif (substr(trim($parts[0]), 0, 8) == 'AllRead_' && isset($boards[substr(trim($parts[0]), 8)]))
phpnuke_to_smf.sql:902:    if (substr($oldAttachmentDir, 0, 2) == '..')
vbulletin35_to_smf.sql:309:       if (substr($row2['value'], 0, 2) == './')
vbulletin35_to_smf.sql:405:       if (substr($row2['value'], 0, 2) == './')
vbulletin36_to_smf.sql:449:       if (substr($row2['value'], 0, 2) == './')
vbulletin36_to_smf.sql:538:       if (substr($row2['value'], 0, 2) == './')
vbulletin37_to_smf.sql:459:       if (substr($row2['value'], 0, 2) == './')
vbulletin37_to_smf.sql:548:       if (substr($row2['value'], 0, 2) == './')
vbulletin3_to_smf.sql:308:       if (substr($row2['value'], 0, 2) == './')
vbulletin3_to_smf.sql:375:       if (substr($row2['value'], 0, 2) == './')
vbulletin40_to_smf.sql:461:       if (substr($row2['value'], 0, 2) == './')
vbulletin40_to_smf.sql:551:       if (substr($row2['value'], 0, 2) == './')
vbulletin41_to_smf.sql:463:       if (substr($row2['value'], 0, 2) == './')
vbulletin41_to_smf.sql:553:       if (substr($row2['value'], 0, 2) == './')
yabb21_to_smf.php:71:          if (empty($line) || substr($line, 0, 1) == '#')
yabb21_to_smf.php:84:          if (substr($yabb[$path], 0, 9) == '$boarddir')
yabb21_to_smf.php:91:          if (empty($line) || substr($line, 0, 1) == '#')
yabb22_to_smf.php:71:          if (empty($line) || substr($line, 0, 1) == '#')
yabb22_to_smf.php:84:          if (substr($yabb[$path], 0, 9) == '$boarddir')
yabb22_to_smf.php:91:          if (empty($line) || substr($line, 0, 1) == '#')
yabb2_to_smf.php:73:          if (empty($line) || substr($line, 0, 1) == '#')
yabb2_to_smf.php:88:          if (empty($line) || substr($line, 0, 1) == '#')
yabb_to_smf.php:68:          if (empty($line) || substr($line, 0, 1) == '#')
install.php:280:          if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
install.php:464:    elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
install.php:562:    if ($failure && substr(__FILE__, 1, 2) == ':\\')
install.php:776:       if (!updateSettingsFile($vars) && substr(__FILE__, 1, 2) == ':\\')
install.php:936:       if (!updateSettingsFile($vars) && substr(__FILE__, 1, 2) == ':\\')
install.php:1028:       if (substr($key, 0, 8) == 'default_')
install.php:1135:       $localCookies = isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false);
install.php:1563:       if (substr($ftp_server, 0, 6) == 'ftp://')
install.php:1565:       elseif (substr($ftp_server, 0, 7) == 'ftps://')
install.php:1567:       if (substr($ftp_server, 0, 7) == 'http://')
install.php:1806:          if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
install.php:1852:          elseif (substr($filesystem_path, 0, 9) == '/var/www/')
updateDatabase.php:100:    if (substr($old_version, 0, 3) == '1.0')
updateDatabase.php:102:    elseif (substr($old_version, 0, 3) == '1.1')
updateDatabase.php:104:    elseif (substr($old_version, 0, 3) == '2.0')
create_backup.php:811:       if (substr($ftp_server, 0, 6) == 'ftp://')
create_backup.php:813:       elseif (substr($ftp_server, 0, 7) == 'ftps://')
create_backup.php:815:       if (substr($ftp_server, 0, 7) == 'http://')
create_backup.php:1054:          if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
create_backup.php:1100:          elseif (substr($filesystem_path, 0, 9) == '/var/www/')
repair.php:49:    if (substr(trim($string), 0, 6) == 'SELECT')
repair_settings.php:295:       if (substr($settingsArray[$i], 0, 1) == '$')
repair_settings.php:616:       if (substr($settingsArray[$i], 0, 1) == '$' && preg_match('~^[$]([a-zA-Z_]+)\s*=\s*(["\'])?(.*?)(?:\\2)?;~', $settingsArray[$i], $match) == 1)
restore_backup.php:529:       if (substr($data, 0, 2) == 'PK')
restore_backup.php:717:       elseif (substr(trim($settingsArray[$i]), -16) == '/install.php\');' && substr(trim($settingsArray[$i]), 0, 26) == 'header(\'Location: http://\'')
smf_api.php:737:          $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
smfinfo.php:1752:    if (substr($forum_version, 0, 2) == '1.')
webinstall.php:582:    if (substr(__FILE__, 1, 2) == ':\\')
webinstall.php:1525:       if (substr($ftp_server, 0, 6) == 'ftp://')
webinstall.php:1527:       elseif (substr($ftp_server, 0, 7) == 'ftps://')
webinstall.php:1529:       if (substr($ftp_server, 0, 7) == 'http://')
webinstall.php:1774:          if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
webinstall.php:1813:          elseif (substr($filesystem_path, 0, 9) == '/var/www/')
upgrade.php:230:          if (substr($ftp_server, 0, 6) == 'ftp://')
upgrade.php:232:          elseif (substr($ftp_server, 0, 7) == 'ftps://')
upgrade.php:234:          if (substr($ftp_server, 0, 7) == 'http://')
upgrade.php:473:             if (substr($file, 0, 1) == '*' && substr($listing[$i], -(strlen($file) - 1)) == substr($file, 1))
upgrade.php:519:             elseif (substr($filesystem_path, 0, 9) == '/var/www/')
upgrade.php:1305:    if (substr($boarddir, 0, 1) == '.')
upgrade.php:1308:    if (substr($sourcedir, 0, 1) == '.')
upgrade.php:1311:    if (empty($cachedir) || substr($cachedir, 0, 1) == '.')
upgrade.php:2106:       if (substr($settingsArray[$i], 0, 1) == '$')
upgrade.php:2580:       elseif ($mysql_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE')
upgrade.php:3164:    if ($failure && substr(__FILE__, 1, 2) == ':\\')
upgrade.php:3231:             if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || substr($upcontext['chmod']['path'], 0, 1) == '/'))
upgrade_1-0.sql:607: if (empty($modSettings['smfVersion']) || (substr($modSettings['smfVersion'], 0, 9) == '1.0 Beta ' && $modSettings['smfVersion'][9] <= 5))
upgrade_1-0.sql:1343:       if (substr($row['setting'], 0, 5) == 'match')
Admin.php:831:                'url' => (substr($item[1], 0, 4) == 'area' ? $scripturl . '?action=admin;' . $item[1] : $item[1]) . ';' . $context['session_var'] . '=' . $context['session_id'] . ((substr($item[1], 0, 4) == 'area' && $section == 'settings' ? '#' . $item[0][0] : '')),
Admin.php:831:                'url' => (substr($item[1], 0, 4) == 'area' ? $scripturl . '?action=admin;' . $item[1] : $item[1]) . ';' . $context['session_var'] . '=' . $context['session_id'] . ((substr($item[1], 0, 4) == 'area' && $section == 'settings' ? '#' . $item[0][0] : '')),
Admin.php:1098:                if (substr($k, 0, 2) == 'on')
Class-Package.php:141:          elseif (substr($el, 0, 1) == '@')
Class-Package.php:208:          elseif (substr($el, 0, 1) == '@')
Class-Package.php:509:          if (substr($k, 0, 1) == '@')
Class-Package.php:719:       if (substr($ftp_server, 0, 6) == 'ftp://')
Class-Package.php:721:       elseif (substr($ftp_server, 0, 7) == 'ftps://')
Class-Package.php:723:       if (substr($ftp_server, 0, 7) == 'http://')
Class-Package.php:826:       while ((strlen($this->last_message) < 4 || substr($this->last_message, 0, 1) == ' ' || substr($this->last_message, 3, 1) != ' ') && time() - $time < 5);
Class-Package.php:1011:          elseif (substr($filesystem_path, 0, 9) == '/var/www/')
DbPackages-mysql.php:537:          'table_name' => substr($table_name, 0, 1) == '`' ? $table_name : '`' . $table_name . '`',
DbPackages-mysql.php:604:          'table_name' => substr($table_name, 0, 1) == '`' ? $table_name : '`' . $table_name . '`',
Display.php:196:       if (substr($_REQUEST['start'], 0, 4) == 'from')
Display.php:226:       elseif (substr($_REQUEST['start'], 0, 3) == 'msg')
Help.php:89:    if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp')
Load.php:1306:             $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
Load.php:1715:       if (substr($template_name, 0, 5) == 'index' && !function_exists('template_button_strip'))
Load.php:2202:                   echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
Logging.php:312:          $is_select = substr(trim($qq['q']), 0, 6) == 'SELECT' || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0;
ManageErrors.php:128:             'html' => htmlspecialchars((substr($row['url'], 0, 1) == '?' ? $scripturl : '') . $row['url']),
ManageErrors.php:209:          $context['filter']['value']['html'] = '\'' . strtr(htmlspecialchars((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
ManageLanguages.php:293:          if (substr($dirname, 0, 6) == 'Themes' && preg_match('~Themes[\\/]([^\\/]+)[\\/]~', $dirname, $match))
ManageNews.php:70:    if (substr($_REQUEST['sa'], 0, 7) == 'mailing')
ManageSettings.php:1662:             'regex' => substr($row['mask'], 0, 5) == 'regex' ? substr($row['mask'], 5) : '',
Memberlist.php:478:          if (substr($field, 0, 5) == 'cust_' && isset($context['custom_search_fields'][$curField]))
Modlog.php:146:          if (substr($key, 0, 10) == 'modlog_ac_' && strpos($text, $search_params['string']) !== false)
PersonalMessage.php:2359:          if (substr($action, 0, 4) == 'add_')
PersonalMessage.php:2364:          elseif (substr($action, 0, 4) == 'rem_')
Profile-Modify.php:1223:             elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
Register.php:421:             elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
Reports.php:882:          if (substr($key, 0, 5) == '#sep#')
Reports.php:894:          if (substr($key, 0, 5) == '#sep#')
Subs-Admin.php:289:       if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>')
Subs-Attachment.php:381:          $is_not = substr($real_type, 0, 4) == 'not_';
Subs-Editor.php:840:             elseif (substr($href, 0, 7) == 'mailto:')
Subs-Graphics.php:193:    if ($fp_destination && substr($source, 0, 7) == 'http://')
Subs-Mail.php:429:       if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.'))
Subs-Mail.php:429:       if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.'))
Subs-Mail.php:449:       if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25))
Subs-Membergroups.php:748:    if (substr($sort, 0, 1) == '1' || strpos($sort, ', 1') !== false)
Subs-Package.php:167:    if (substr($gzfilename, 0, 7) == 'http://')
Subs-Package.php:207:       if (substr($data, 0, 2) == 'PK')
Subs-Package.php:778:             if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/'))
Subs-Package.php:1036:          if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/'))
Subs-Package.php:1208:       if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require')
Subs-Package.php:1208:       if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require')
Subs-Post.php:48:    while (substr($message, 0, 8) == '[/quote]')
Subs-Post.php:467:          if (substr($replace, 0, 1) == '/')
Subs-Post.php:469:          elseif (substr($replace, 0, 1) == '?')
Subs-Post.php:471:          elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
Subscriptions-PayPal.php:226:       if (substr($_POST['txn_type'], 0, 14) == 'subscr_payment')
Themes.php:1777:          if (substr($_GET['directory'], 0, 1) == '.')
Themes.php:1814:       if (substr($_REQUEST['filename'], 0, 1) == '.')
Themes.php:1926:          if (isset($file_data[$i + 1]) && substr($file_data[$i + 1], 0, 9) == 'function ')
Themes.php:1975:       if (substr($entry, 0, 1) == '.' || $entry == 'CVS')
ViewQuery.php:98:       $is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT';
SSI.php:58: if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
Admin.template.php:1221:                            <option value="regex"', substr($context['field']['mask'], 0, 5) == 'regex' ? ' selected="selected"' : '', '>', $txt['custom_edit_mask_regex'], '</option>
#21
index.php:51: if (@version_compare(PHP_VERSION, '5.1') == -1)
index.php:85:    if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') === 'ob_gzhandler' || @version_compare(PHP_VERSION, '4.2.0') == -1)
convert.php:334:    if (@version_compare(PHP_VERSION, '5') == -1)
install.php:358:       if (@version_compare(PHP_VERSION, '5') == -1)
install.php:803:       if (@version_compare(PHP_VERSION, '5') == -1)
install.php:1258:    if (!function_exists('sha1') || @version_compare(PHP_VERSION, '5') == -1)
install.php:1465:       if (@version_compare(PHP_VERSION, '4.2.0') == -1)
smf_api.php:789:    if (@version_compare(PHP_VERSION, '4.2.0') == -1)
upgrade.php:795:    if (@version_compare(PHP_VERSION, '5') == -1)
QueryString.php:72:    if ((strpos(@ini_get('arg_separator.input'), ';') === false || @version_compare(PHP_VERSION, '4.2.0') == -1) && !empty($_SERVER['QUERY_STRING']))
Session.php:88:    if (@version_compare(PHP_VERSION, '4.2.0') == -1)
Subs.php:2548:    if (@version_compare(PHP_VERSION, '4.2.0') == -1)
Subs.php:3107:    if (@version_compare(PHP_VERSION, '4.2.0') == -1)
Subs.php:3539:    if (@version_compare(PHP_VERSION, '4.2.0') == -1)
SSI.php:65: if (@version_compare(PHP_VERSION, '5.1') == -1)
#22
<?php
$other_path = '/home/svn/sm-smf/trunk/other';
$settings_path = '/home/smf/svn_files';

$php_open = '<' . '?' . 'php';
$php_close = '?' . '>';
require_once(dirname(__FILE__) . '/Settings.php');


// Is it cached?
if (file_exists($settings_path . '/upgrade_emulate_cache') && !empty($_REQUEST['data']))
   $contents = file_get_contents($settings_path . '/upgrade_emulate_cache');
else
{
   // Get.
   $contents = file_get_contents($other_path . '/upgrade.php');

   // Edit.
   $contents = strtr($contents, array(
      'dirname(__FILE__)' => '\'' . $other_path . '\'',
      'require_once($upgrade_path . \'/Settings.php\');' => 'require_once(\'' . $settings_path . '/Settings.php\');',
      'require_once(dirname(__FILE__) . \'/upgrade_1-0.sql\');' => 'require_once(\'' . $other_path . '/upgrade_1-0.sql\');',
      'require_once(dirname(__FILE__) . \'/upgrade_1-1.sql\');' => 'require_once(\'' . $other_path . '/upgrade_1-1.sql\');',
      'require_once(dirname(__FILE__) . \'/upgrade_2-0_mysql.sql\');' => 'require_once(\'' . $other_path . '/upgrade_2-0_mysql.sql\');',
      'require_once(dirname(__FILE__) . \'/upgrade_2-0_postgresql.sql\');' => 'require_once(\'' . $other_path . '/upgrade_2-0_postgresql.sql\');',
      'require_once(dirname(__FILE__) . \'/upgrade_2-0_sqlite.sql\');' => 'require_once(\'' . $other_path . '/upgrade_2-0_sqlite.sql\');',
      'dirname(__FILE__) . \'/upgrade_2-0_\' . $db_type . \'.sql\'' => '\'' . $other_path . '/upgrade_2-0_\' . $db_type . \'.sql\'',
      '$boarddir . \'/Settings' => '\'' . $settings_path . '/Settings',
   ));

   // Prepare.
   $contents = substr($contents, strlen($php_open), -strlen($php_close));

   file_put_contents($settings_path . '/upgrade_emulate_cache', $contents);
}

// Send.
eval($contents);

// done.
exit;
?>
#23
<?php

// Get the contents man.
$contents = ob_get_contents();
ob_clean();

// The contents.
if ($boardurl != 'http://smf-svn.test')
   $contents = str_replace('http://smf-svn.test', $boardurl, $contents);

// Only do the Theme changer in certain cases.
if (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('xmlhttp', '.xml', 'viewsmfile', 'viewquery', 'verificationcode', 'suggest', 'smstats', 'quickmod', 'quickmod2', 'quotefast', 'openidreturn', 'jsoption', 'jsmodify', 'jseditor')))
   themechanger($contents);

echo $contents;

exit;


function themechanger(&$contents)
{
   global $smcFunc, $context, $user_info;

   if (empty($_SERVER['REQUEST_URL']))
      return;

   // Figure out our location easily.
   $location = preg_replace('~[;|?]theme=(\d+)~i', '', $_SERVER['REQUEST_URL']);
   if (strpos($location, '?') !== false)
      $location = $location . ';';
   else
      $location = $location . '?';

   // Is the current theme, wrong!
   if (isset($_REQUEST['theme']))
      $user_info['theme'] = (int) $_REQUEST['theme'];
   elseif (!empty($_SESSION['id_theme']))
      $user_info['theme'] = (int) $_SESSION['id_theme'];

   // Start.
   $thestring = '
<div id="svn_theme_changer" style="position: absolute; top:1em; left: 40em; color:red; z-index:999; display: none;">
   <form method="get" action="javascript://void;">
      <select name="theme" onchange="location=\''. $location . 'theme=\' + this.options[this.selectedIndex].value">';

   // Go database!
   $request = $smcFunc['db_query']('', '
      SELECT value, id_theme
      FROM {db_prefix}themes
         WHERE id_theme != {int:no_theme}
         AND id_member = {int:guest_id}
         AND variable = {string:theme_name}',
      array(
         'no_theme' => 0,
         'guest_id' => 0,
         'theme_name' => 'name',
   ));
   while ($row = $smcFunc['db_fetch_assoc']($request))
      $thestring .= '
         <option value="' . $row['id_theme'] . '"' . ($user_info['theme'] == $row['id_theme'] ? ' selected="selected"' : ''). '>' . $row['value'] . '</option>';

   $thestring .= '
      </select>
   </form>
</div>
<div style="position: absolute; top:0; left: 0; right: 0; color:red; z-index:999; dislay: none;">
<div id="svn_theme_changer_show" style="display: block; float: right;" ><a href="#1" onclick="document.getElementById(\'svn_theme_changer\').style.display = \'\'; document.getElementById(\'svn_theme_changer_show\').style.display = \'none\'; document.getElementById(\'svn_theme_changer_hide\').style.display = \'\';">expand</a></div>
<div id="svn_theme_changer_hide" style="display: none; float: right;"><a href="#2" onclick="document.getElementById(\'svn_theme_changer\').style.display = \'none\'; document.getElementById(\'svn_theme_changer_show\').style.display = \'\'; document.getElementById(\'svn_theme_changer_hide\').style.display = \'none\';">collapse</a></div></div>
<a style="float: right;" href="javascript:location=\'' . $_SERVER['REQUEST_URL'] . '&destory_session&secs=' . $context['session_id'] . '\'">[Destroy Session]</a>';

   // Display the few themes we have quickly.
   $contents = str_replace('<body>', '<body>' . $thestring, $contents);

   return $contents;
}
?>
#24
<?php
$base_path = '/home/svn/sm-smf/trunk';
$settings_path = '/home/smf/svn_files';

$php_open = '<' . '?' . 'php';
$php_close = '?' . '>';

$revision = trim(str_replace('Revision: ', '', shell_exec('svn info /home/svn/sm-smf/trunk | grep "Revision"')));

require_once(dirname(__FILE__) . '/Settings.php');

// Get.
$contents = file_get_contents($base_path . '/index.php');

// Edit.
$contents = strtr($contents, array(
   'require_once(dirname(__FILE__) . \'/Settings.php\');' => 'require(\'' . $settings_path . '/Settings.php\');',
));

// WIP, needs fixing.
if (isset($_GET['destory_session']))
{
   $contents = file_get_contents($base_path . '/SSI.php');
   $contents = substr($contents, strlen($php_open), -strlen($php_close));
   eval($contents);

   require_once($sourcedir . '/Subs-Auth.php');
   setLoginCookie(-3600, 0);
   if (isset($_SESSION['login_' . $cookiename]))
      unset($_SESSION['login_' . $cookiename]);

   
   Header('location: ' . str_replace('session_destroy', '', $_SERVER['HTTP_REFERER']));
   exit;
}

// Prepare.
$contents = substr($contents, strlen($php_open), -strlen($php_close));

// Send.
$forum_version = 'SMF test';
eval($contents);

require_once($settings_path . '/exit_script.php');
?>
#25
<?php
/**********************************************************************************
* Settings.php                                                                    *
***********************************************************************************
* SMF: Simple Machines Forum                                                      *
* Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com)                    *
* =============================================================================== *
* Software Version:           SMF 2.0 RC1                                         *
* Software by:                Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2009 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
* Support, News, Updates at:  http://www.simplemachines.org                       *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
**********************************************************************************/

if (isset($revision))
   $forum_version .= ' Revision:' . $revision;

########## Maintenance ##########
# Note: If $maintenance is set to 2, the forum will be unusable!  Change it to 0 to fix it.
$mtitle = 'Maintenance Mode';      # Title for the Maintenance Mode message.
$mmessage = 'Okay faithful users...we\'re attempting to restore an older backup of the database...news will be posted once we\'re back!';      # Description of why the forum is in maintenance mode.

########## Forum Info ##########
$mbname = 'SleePys Development Community';      # The name of your forum.
$language = 'english';      # The default language file set for the forum.
$boardurl = 'http://smf-svn.test';      # URL to your forum's folder. (without the trailing /!)
$webmaster_email = 'noreply@svn.test';      # Email address to send emails from. (like noreply@yourdomain.com.)
$cookiename = 'svn_test';      # Name of the cookie to set for authentication.

########## Database Info ##########
# Always have the defualt (MySQL)
$db_type = 'mysql';
$db_server = 'localhost';
$db_name = '__smf_svn_trunk';
$db_user = 'smf';
$db_passwd = 'smf';
$ssi_db_user = '';
$ssi_db_passwd = '';
$db_prefix = 'smf_';
$db_persist = 0;
$db_error_send = 1;
$db_show_debug = true;

# Maybe we are using Postgresql?
if (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, strlen('postgresql')) == 'postgresql')
{
   $boardurl = 'http://postgresql.svn.test';
   $cookiename .= '_postgresql';

   $db_type = 'postgresql';
   $db_user = 'SMF';
}
# Maybe Sqlite?
elseif (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, strlen('sqlite')) == 'sqlite')
{
   $boardurl = 'http://sqlite.svn.test';
   $cookiename .= '_sqlite';

   $db_type = 'sqlite';
   $db_name = '/home/data/sqlite_db';
}

########## Directories/Files ##########
# Note: These directories do not have to be changed unless you move things.
$boarddir = '/home/svn/sm-smf/trunk';      # The absolute path to the forum's folder. (not just '.'!)
$sourcedir = '/home/svn/sm-smf/trunk/Sources';      # Path to the Sources directory.
$cachedir = '/home/smf/svn_files/cache';      # Path to the cache directory.
$cachedir_fix = $cachedir;

########## Error-Catching ##########
# Note: You shouldn't touch these settings.
$db_last_error = 0;

# Make sure the paths are correct... at least try to fix them.
if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt'))
   $boarddir = dirname(__FILE__);
if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources'))
   $sourcedir = $boarddir . '/Sources';
if (!file_exists($cachedir) && file_exists($boarddir . '/cache'))
   $cachedir = $boarddir . '/cache';
?>
#26
# svn.test
   # Where the Physical files exist for good.
   <Directory "/home/svn/sm-smf/trunk">
       Options Indexes FollowSymLinks ExecCGI
      AllowOverride AuthConfig Indexes
       Order allow,deny
       Allow from all
   </Directory>
   <Directory "/home/smf/svn_files">
       Options Indexes FollowSymLinks ExecCGI
       AllowOverride None
       Order allow,deny
       Allow from all
   </Directory>
   <VirtualHost *:80>
      # Our urls.
      ServerName smf-svn.test
      ServerAlias postgresql.smf-svn.test sqlite.smf-svn.test mysql.svn.test

      # Setup the document root to our svn files.
      DocumentRoot /home/svn/sm-smf/trunk

      # We will use PHP 5.3 for this.
      AddHandler php5-script .php

      # Put the error log somewhere nice.
      ErrorLog "logs/custom/svn.test/error_php5.log"
      CustomLog "logs/custom/svn.test/access-80.log" common

      # Fake our Settings.php automatically :D
      php_value auto_prepend_file "/home/smf/svn_files/Settings.php"

      # Append a exit script at the end to handle url changes for postgresql.svn.test and sqlite.svn.test
      php_value auto_append_file "/home/smf/svn_files/exit_script.php"

      # Emulate some files to fake what we are really doing.
      Alias /upgrade.php /home/smf/svn_files/upgrade_emulator.php
      Alias /index.php /home/smf/svn_files/index_emulator.php
      Alias /phpinfo.php /home/smf/public_html/phpinfo.php
   </VirtualHost>
#27
<?php

/**
* A SMF based cache engine using Memcache.
* @since 3.0
* @version 3.0
*/
class SmCache
{
   /**
   * Is memcache enabled?
   * @since 3.0
   * @version 3.0
   */
   private static $disabled = false;

   /**
   * The memcache object.
   * @since 3.0
   * @version 3.0
   */
   private static $memcache = null;

   /**
   * The prekey, basically the prefix used on this memcache instance.
   * @since 3.0
   * @version 3.0
   */
   private static $prekey = '';

   /**
   * Gets data from MemCache.
   * @param string $key The unique key.
   * @param int $ttl How long the key should exist.
   * @return mixed The data which was stored is now returned.
   * @since 3.0
   * @version 3.0
   */
   public static function get($key, $ttl)
   {
      if (self::$disabled)
         return;

      $st = microtime();

      $value = self::$memcache->get(self::$prekey . strtr($key, ':', '-'), $ttl);

      // Update our hit counter.
      self::__cacheHits('get', strtr($key, ':', '-'), null, $ttl, $st, microtime());

      // Return the correct value.
      if (empty($value))
         return null;
      else
         return @unserialize($value);
   }

   /**
   * Sets the data into the memcache server.
   * @param string $key The unique key.
   * @param string $value The data to cache.
   * @param int $ttl How long the key should exist.
   * @return void Nothing is returned.
   * @since 3.0
   * @version 3.0
   */
   public static function set($key, $value, $ttl)
   {
      if (self::$disabled)
         return;

      $st = microtime();

      $value = $value === null ? null : serialize($value);

      // Note: due to inconsistencies in pecl, we use 0 as ttl to resolve a bug.
      if (is_null($value))
         self::$memcache->delete(self::$prekey  . strtr($key, ':', '-'), 0);
      else
         self::$memcache->set(self::$prekey . strtr($key, ':', '-'), $value, 0, $ttl);

      // Update our hit counter.
      self::__cacheHits('put', $key, strtr($key, ':', '-'), $ttl, $st, microtime());
   }

   /**
   * This does the hefty startup work.  Gets memcache going.
   * @param int $level Allows us to call this multiple times to try and start memcache up.
   * @return void Nothing is returned.
   * @since 3.0
   * @version 3.0
   */
   public static function __loadMemCache($level = 0)
   {
      global $modSettings;

      // If it is off, let the class know.
      if (empty($modSettings['cache_enable']) && !empty($modSettings))
      {
         return;
      }

      // Create our new memcache instance.
      self::$memcache = new Memcache;

      // Basic load balancing.
      $servers = explode(',', $modSettings['cache_memcached']);
      $server = explode(':', trim($servers[array_rand($servers)]));

      // Connect to memcache now.
      $connected = $memcache->pconnect($server[0], empty($server[1]) ? 11211 : $server[1]);

      // Try a few times to connect.
      if (!$connected && $level > 3)
         self::__loadMemCache(++$level);
      elseif ($level =< 2)
         return false;

      self::$prekey = md5(filemtime(__FILE__)) . '-SmSite-';
   }

   /**
   * Updates SMFs cache counter and debugging info.
   * @param string $type Either "get" or "put" based on what type of usage.
   * @param string $key The unique key.
   * @param string $value The data to cache.
   * @param int $ttl How long the key should exist.
   * @param int $start Time before trying caching.
   * @param int $stop Time after trying caching.
   * @return void Nothing is returned.
   * @since 3.0
   * @version 3.0
   */
   public static function __cacheHits($type, $key, $value, $ttl, $start, $stop)
   {
      global $cache_hits, $cache_count, $db_show_debug;

      $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
      if (isset($db_show_debug) && $db_show_debug === true)
      {
         $cache_hits[$cache_count] = array('k' => $key, 'd' => $type, 's' => $value === null ? 0 : strlen(serialize($value)), 't' => array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)));

      $cache_hits[$cache_count]['t'] = array_sum(explode(' ', $stop)) - array_sum(explode(' ', $start));

      }
   }
}

?>
#28
<?php

/**
* A SMF based cache engine using Memcache.
* @since 3.0
* @version 3.0
*/
class SmCache
{
   /**
   * Is memcache enabled?
   * @since 3.0
   * @version 3.0
   */
   private static $disabled = false;

   /**
   * The memcache object.
   * @since 3.0
   * @version 3.0
   */
   private static $memcache = null;

   /**
   * The prekey, basically the prefix used on this memcache instance.
   * @since 3.0
   * @version 3.0
   */
   private static $prekey = '';

   /**
   * Gets data from MemCache.
   * @param string $key The unique key.
   * @param int $ttl How long the key should exist.
   * @return mixed The data which was stored is now returned.
   * @since 3.0
   * @version 3.0
   */
   public static function get($key, $ttl)
   {
      if (self::$disabled)
         return;

      $st = microtime();

      $value = self::$memcache->get(self::$prekey . strtr($key, ':', '-'), $ttl);

      // Update our hit counter.
      self::__cacheHits('get', strtr($key, ':', '-'), null, $ttl, $st, microtime());

      // Return the correct value.
      if (empty($value))
         return null;
      else
         return @unserialize($value);
   }

   /**
   * Sets the data into the memcache server.
   * @param string $key The unique key.
   * @param string $value The data to cache.
   * @param int $ttl How long the key should exist.
   * @return void Nothing is returned.
   * @since 3.0
   * @version 3.0
   */
   public static function set($key, $value, $ttl)
   {
      if (self::$disabled)
         return;

      $st = microtime();

      $value = $value === null ? null : serialize($value);

      // Note: due to inconsistencies in pecl, we use 0 as ttl to resolve a bug.
      if (is_null($value))
         self::$memcache->delete(self::$prekey  . strtr($key, ':', '-'), 0);
      else
         self::$memcache->set(self::$prekey . strtr($key, ':', '-'), $value, 0, $ttl);

      // Update our hit counter.
      self::__cacheHits('put', $key, strtr($key, ':', '-'), $ttl, $st, microtime());
   }

   /**
   * This does the hefty startup work.  Gets memcache going.
   * @param int $level Allows us to call this multiple times to try and start memcache up.
   * @return void Nothing is returned.
   * @since 3.0
   * @version 3.0
   */
   public static function __loadMemCache($level = 0)
   {
      global $modSettings;

      // If it is off, let the class know.
      if (empty($modSettings['cache_enable']) && !empty($modSettings))
      {
         return;
      }

      // Create our new memcache instance.
      self::$memcache = new Memcache;

      // Basic load balancing.
      $servers = explode(',', $modSettings['cache_memcached']);
      $server = explode(':', trim($servers[array_rand($servers)]));

      // Connect to memcache now.
      $connected = $memcache->pconnect($server[0], empty($server[1]) ? 11211 : $server[1]);

      // Try a few times to connect.
      if (!$connected && $level > 3)
         self::__loadMemCache(++$level);
      elseif ($level =< 2)
         return false;

      self::$prekey = md5($boardurl . filemtime(__FILE__)) . '-SmSite-';
   }

   /**
   * Updates SMFs cache counter and debugging info.
   * @param string $type Either "get" or "put" based on what type of usage.
   * @param string $key The unique key.
   * @param string $value The data to cache.
   * @param int $ttl How long the key should exist.
   * @param int $start Time before trying caching.
   * @param int $stop Time after trying caching.
   * @return void Nothing is returned.
   * @since 3.0
   * @version 3.0
   */
   public static function __cacheHits($type, $key, $value, $ttl, $start, $stop)
   {
      global $cache_hits, $cache_count, $db_show_debug;

      $cache_count = isset($cache_count) ? $cache_count + 1 : 1;
      if (isset($db_show_debug) && $db_show_debug === true)
      {
         $cache_hits[$cache_count] = array('k' => $key, 'd' => $type, 's' => $value === null ? 0 : strlen(serialize($value)), 't' => array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)));

      $cache_hits[$cache_count]['t'] = array_sum(explode(' ', $stop)) - array_sum(explode(' ', $start));

      }
   }
}

?>
#29
        #PasteBin!
        location /Pastebin/
        {
                try_files $uri @pastebin;
        }
        location @pastebin
        {
                rewrite "^/Pastebin/([0-9]+)/([A-Za-z0-9]{5})$" /Pastebin/index.php?view=$1&key=$2 last;
                rewrite ^/Pastebin/([0-9]+)/?$ /Pastebin/index.php?view=$1 last;
                rewrite ^/Pastebin/credits$ /Pastebin/index.php?credits last;
        }
#30
[***@**** ~]$ telnet irc.villageirc.net 6667
Trying 69.72.215.132...
Connected to irc.villageirc.net.
Escape character is '^]'.
:Loopy.NJ.US.VillageIRC.net NOTICE AUTH :*** Looking up your hostname...
:Loopy.NJ.US.VillageIRC.net NOTICE AUTH :*** Checking Ident
:Loopy.NJ.US.VillageIRC.net NOTICE AUTH :*** Found your hostname
join #simplemachines
nick Tester123
:Loopy.NJ.US.VillageIRC.net NOTICE AUTH :*** No Ident response
:Loopy.NJ.US.VillageIRC.net 451  join :Register first.
ERROR :Closing Link: 0.0.0.0 (Ping timeout: 36 seconds)