News:

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

Main Menu

Recent posts

#31
PasteBin / Paste-1319594570:v:use_geshi-1...
Last post by SleePy - Oct 26, 2011, 02:02 AM
<?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;
}
?>
#32
PasteBin / Paste-1319225066:v:use_geshi-1...
Last post by groundup - Oct 21, 2011, 07:24 PM
/**
 * Are we using this browser?
 * @param $browser: browser we are checking for.
*/
function isBrowser($browser)
{
   global $context;

   // Don't know any browser!
   if (empty($context['browser']))
      detectBrowser();

   return !empty($context['browser']['is_' . $browser]) || !empty($context['browser'][$browser]);
}

/**
 * This function is... detecting the browser, right.
 * Loads a bunch of browser information in to $context
 */
function detectBrowser()
{
   global $context, $user_info;

   // The following determines the user agent (browser) as best it can.
   $context['browser'] = array(
      // Most desktop browsers.
      'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
      'is_webkit' => strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false,
      'is_firefox' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/~', $_SERVER['HTTP_USER_AGENT']) === 1,
      'is_gecko' = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$context['browser']['is_webkit'] && !$context['browser']['is_konqueror'];

      // Mobile browsers.
      'is_iphone' => strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') !== false,
      'is_android' => strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false,

      // Others.
      'is_web_tv' => strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false,
      'is_konqueror' => strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false,
   );

   // Detect IE and not those who wish to emulate it.
   $context['browser']['is_ie'] = !$context['browser']('is_opera') && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'] && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1;

   // Detect Safari/Chrome from webkit.
   if ($context['browser']['is_webkit'])
   {
      $context['browser']['is_chrome'] = $context['browser']['is_webkit'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false;
      $context['browser']['is_safari'] = !$context['browser']['is_chrome'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false;
   }

   // More Opera checks if we are opera.
   if ($context['browser']['is_opera'])
      $context['browser'] += array(
         'is_opera6' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 6') !== false,
         'is_opera7' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/7') !== false,
         'is_opera8' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 8') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/8') !== false,
         'is_opera9' => preg_match('~Opera[ /]9(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_opera10' => preg_match('~Opera[ /]10\\.~', $_SERVER['HTTP_USER_AGENT']) === 1 || (preg_match('~Opera[ /]9\\.[89]~', $_SERVER['HTTP_USER_AGENT']) === 1 && preg_match('~Version/1[0-9]\\.~', $_SERVER['HTTP_USER_AGENT']) === 1),
      );

   // Additional firefox checks.
   if ($context['browser']['is_firefox'])
      $context['browser'] += array(
         'is_firefox1' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/1\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_firefox2' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/2\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_firefox3' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/3\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
      );

   // Additional IE checks.
   if ($context['browser']['is_ie'])
   {
      $context['browser'] += array(
         'is_ie8' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8') !== false,
         'is_ie5.5' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') !== false,
         'is_ie5' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== false;
         'is_ie4' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 4') !== false && !$context['browser']['is_web_tv'],
         'is_mac_ie' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false,
      );

      // Detect IE7 and not IE8 in combat mode.
      $context['browser']['is_ie7'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false && !$context['browser']['is_ie8'],

      // Before IE8 we need to fix IE... lots!
      $context['browser']['ie_standards_fix'] = !$context['browser']['is_ie8'];

      $context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_ie8'] && !$context['browser']['is_ie7'];

   }

   if ($context['browser']['is_ie'] || $context['browser']['is_opera'])
      $context['browser']['needs_size_fix'] = ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie4'] || $context['browser']['is_opera6']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false;

   // Be you robot or human?
   if ($user_info['possibly_robot'])
   {
      // This isn't meant to be reliable, it's just meant to catch most bots to prevent PHPSESSID from showing up.
      $context['browser']['possibly_robot'] = !empty($user_info['possibly_robot']);

      // Robots shouldn't be logging in or registering.  So, they aren't a bot.  Better to be wrong than sorry (or people won't be able to log in!), anyway.
      if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register'))) || !$user_info['is_guest'])
         $context['browser']['possibly_robot'] = false;
   }
   else
      $context['browser']['possibly_robot'] = false;

}
#33
PasteBin / Paste-1319224933:v:use_geshi-1...
Last post by groundup - Oct 21, 2011, 07:22 PM
/**
 * Are we using this browser?
 * @param $browser: browser we are checking for.
*/
function isBrowser($browser)
{
   global $context;

   // Don't know any browser!
   if (empty($context['browser']))
      detectBrowser();

   return !empty($context['browser']['is_' . $browser]);
}

/**
 * This function is... detecting the browser, right.
 * Loads a bunch of browser information in to $context
 */
function detectBrowser()
{
   global $context, $user_info;

   // The following determines the user agent (browser) as best it can.
   $context['browser'] = array(
      // Most desktop browsers.
      'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
      'is_webkit' => strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false,
      'is_firefox' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/~', $_SERVER['HTTP_USER_AGENT']) === 1,
      'is_gecko' = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$context['browser']['is_webkit'] && !$context['browser']['is_konqueror'];

      // Mobile browsers.
      'is_iphone' => strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') !== false,
      'is_android' => strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false,

      // Others.
      'is_web_tv' => strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false,
      'is_konqueror' => strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false,
   );

   // Detect IE and not those who wish to emulate it.
   $context['browser']['is_ie'] = !$context['browser']('is_opera') && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'] && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1;

   // Detect Safari/Chrome from webkit.
   if ($context['browser']['is_webkit'])
   {
      $context['browser']['is_chrome'] = $context['browser']['is_webkit'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false;
      $context['browser']['is_safari'] = !$context['browser']['is_chrome'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false;
   }

   // More Opera checks if we are opera.
   if ($context['browser']['is_opera'])
      $context['browser'] += array(
         'is_opera6' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 6') !== false,
         'is_opera7' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/7') !== false,
         'is_opera8' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 8') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/8') !== false,
         'is_opera9' => preg_match('~Opera[ /]9(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_opera10' => preg_match('~Opera[ /]10\\.~', $_SERVER['HTTP_USER_AGENT']) === 1 || (preg_match('~Opera[ /]9\\.[89]~', $_SERVER['HTTP_USER_AGENT']) === 1 && preg_match('~Version/1[0-9]\\.~', $_SERVER['HTTP_USER_AGENT']) === 1),
      );

   // Additional firefox checks.
   if ($context['browser']['is_firefox'])
      $context['browser'] += array(
         'is_firefox1' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/1\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_firefox2' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/2\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_firefox3' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/3\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
      );

   // Additional IE checks.
   if ($context['browser']['is_ie'])
   {
      $context['browser'] += array(
         'is_ie8' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8') !== false,
         'is_ie5.5' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') !== false,
         'is_ie5' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== false;
         'is_ie4' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 4') !== false && !$context['browser']['is_web_tv'],
         'is_mac_ie' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false,
      );

      // Detect IE7 and not IE8 in combat mode.
      $context['browser']['is_ie7'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false && !$context['browser']['is_ie8'],

      // Before IE8 we need to fix IE... lots!
      $context['browser']['ie_standards_fix'] = !$context['browser']['is_ie8'];

      $context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_ie8'] && !$context['browser']['is_ie7'];

   }

   if ($context['browser']['is_ie'] || $context['browser']['is_opera'])
      $context['browser']['needs_size_fix'] = ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie4'] || $context['browser']['is_opera6']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false;

   // Be you robot or human?
   if ($user_info['possibly_robot'])
   {
      // This isn't meant to be reliable, it's just meant to catch most bots to prevent PHPSESSID from showing up.
      $context['browser']['possibly_robot'] = !empty($user_info['possibly_robot']);

      // Robots shouldn't be logging in or registering.  So, they aren't a bot.  Better to be wrong than sorry (or people won't be able to log in!), anyway.
      if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register'))) || !$user_info['is_guest'])
         $context['browser']['possibly_robot'] = false;
   }
   else
      $context['browser']['possibly_robot'] = false;

}
#34
PasteBin / Paste-1319224894:v:use_geshi-1...
Last post by groundup - Oct 21, 2011, 07:21 PM
/**
 * Are we using this browser?
 * @param $browser: browser we are checking for.
*/
function isBrowser($browser)
{
   global $context;

   // Don't know any browser!
   if (empty($context['browser']))
      detectBrowser();

   return !empty($context['is_' . $browser]);
}

/**
 * This function is... detecting the browser, right.
 * Loads a bunch of browser information in to $context
 */
function detectBrowser()
{
   global $context, $user_info;

   // The following determines the user agent (browser) as best it can.
   $context['browser'] = array(
      // Most desktop browsers.
      'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
      'is_webkit' => strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false,
      'is_firefox' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/~', $_SERVER['HTTP_USER_AGENT']) === 1,
      'is_gecko' = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$context['browser']['is_webkit'] && !$context['browser']['is_konqueror'];

      // Mobile browsers.
      'is_iphone' => strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') !== false,
      'is_android' => strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false,

      // Others.
      'is_web_tv' => strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false,
      'is_konqueror' => strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false,
   );

   // Detect IE and not those who wish to emulate it.
   $context['browser']['is_ie'] = !$context['browser']('is_opera') && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'] && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1;

   // Detect Safari/Chrome from webkit.
   if ($context['browser']['is_webkit'])
   {
      $context['browser']['is_chrome'] = $context['browser']['is_webkit'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false;
      $context['browser']['is_safari'] = !$context['browser']['is_chrome'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false;
   }

   // More Opera checks if we are opera.
   if ($context['browser']['is_opera'])
      $context['browser'] += array(
         'is_opera6' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 6') !== false,
         'is_opera7' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/7') !== false,
         'is_opera8' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 8') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/8') !== false,
         'is_opera9' => preg_match('~Opera[ /]9(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_opera10' => preg_match('~Opera[ /]10\\.~', $_SERVER['HTTP_USER_AGENT']) === 1 || (preg_match('~Opera[ /]9\\.[89]~', $_SERVER['HTTP_USER_AGENT']) === 1 && preg_match('~Version/1[0-9]\\.~', $_SERVER['HTTP_USER_AGENT']) === 1),
      );

   // Additional firefox checks.
   if ($context['browser']['is_firefox'])
      $context['browser'] += array(
         'is_firefox1' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/1\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_firefox2' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/2\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_firefox3' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/3\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
      );

   // Additional IE checks.
   if ($context['browser']['is_ie'])
   {
      $context['browser'] += array(
         'is_ie8' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8') !== false,
         'is_ie5.5' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') !== false,
         'is_ie5' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== false;
         'is_ie4' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 4') !== false && !$context['browser']['is_web_tv'],
         'is_mac_ie' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false,
      );

      // Detect IE7 and not IE8 in combat mode.
      $context['browser']['is_ie7'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false && !$context['browser']['is_ie8'],

      // Before IE8 we need to fix IE... lots!
      $context['browser']['ie_standards_fix'] = !$context['browser']['is_ie8'];

      $context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_ie8'] && !$context['browser']['is_ie7'];

   }

   if ($context['browser']['is_ie'] || $context['browser']['is_opera'])
      $context['browser']['needs_size_fix'] = ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie4'] || $context['browser']['is_opera6']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false;

   // Be you robot or human?
   if ($user_info['possibly_robot'])
   {
      // This isn't meant to be reliable, it's just meant to catch most bots to prevent PHPSESSID from showing up.
      $context['browser']['possibly_robot'] = !empty($user_info['possibly_robot']);

      // Robots shouldn't be logging in or registering.  So, they aren't a bot.  Better to be wrong than sorry (or people won't be able to log in!), anyway.
      if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register'))) || !$user_info['is_guest'])
         $context['browser']['possibly_robot'] = false;
   }
   else
      $context['browser']['possibly_robot'] = false;

}
#35
PasteBin / Paste-1319224617:v:use_geshi-1...
Last post by Guest - Oct 21, 2011, 07:16 PM
/**
 * Are we using this browser?
 * @param $browser: browser we are checking for.
*/
function isBrowser($browser)
{
   global $context;

   // Don't know any browser!
   if (empty($context['browser']))
      detectBrowser();

   return !empty(isBrowser('$browser')) ? true : false;
}

/**
 * This function is... detecting the browser, right.
 * Loads a bunch of browser information in to $context
 */
function detectBrowser()
{
   global $context, $user_info;

   // The following determines the user agent (browser) as best it can.
   $context['browser'] = array(
      // Most desktop browsers.
      'is_opera' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false,
      'is_webkit' => strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false,
      'is_firefox' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/~', $_SERVER['HTTP_USER_AGENT']) === 1,
      'is_gecko' = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$context['browser']['is_webkit'] && !$context['browser']['is_konqueror'];

      // Mobile browsers.
      'is_iphone' => strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') !== false,
      'is_android' => strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false,

      // Others.
      'is_web_tv' => strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false,
      'is_konqueror' => strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false,
   );

   // Detect IE and not those who wish to emulate it.
   $context['browser']['is_ie'] = !$context['browser']('is_opera') && !$context['browser']['is_gecko'] && !$context['browser']['is_web_tv'] && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1;

   // Detect Safari/Chrome from webkit.
   if ($context['browser']['is_webkit'])
   {
      $context['browser']['is_chrome'] = $context['browser']['is_webkit'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false;
      $context['browser']['is_safari'] = !$context['browser']['is_chrome'] && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false;
   }

   // More Opera checks if we are opera.
   if ($context['browser']['is_opera'])
      $context['browser'] += array(
         'is_opera6' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 6') !== false,
         'is_opera7' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/7') !== false,
         'is_opera8' => strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 8') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera/8') !== false,
         'is_opera9' => preg_match('~Opera[ /]9(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_opera10' => preg_match('~Opera[ /]10\\.~', $_SERVER['HTTP_USER_AGENT']) === 1 || (preg_match('~Opera[ /]9\\.[89]~', $_SERVER['HTTP_USER_AGENT']) === 1 && preg_match('~Version/1[0-9]\\.~', $_SERVER['HTTP_USER_AGENT']) === 1),
      );

   // Additional firefox checks.
   if ($context['browser']['is_firefox'])
      $context['browser'] += array(
         'is_firefox1' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/1\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_firefox2' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat)/2\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
         'is_firefox3' => preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/3\\.~', $_SERVER['HTTP_USER_AGENT']) === 1,
      );

   // Additional IE checks.
   if ($context['browser']['is_ie'])
   {
      $context['browser'] += array(
         'is_ie8' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8') !== false,
         'is_ie5.5' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.5') !== false,
         'is_ie5' = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.0') !== false;
         'is_ie4' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 4') !== false && !$context['browser']['is_web_tv'],
         'is_mac_ie' => strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5.') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false,
      );

      // Detect IE7 and not IE8 in combat mode.
      $context['browser']['is_ie7'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false && !$context['browser']['is_ie8'],

      // Before IE8 we need to fix IE... lots!
      $context['browser']['ie_standards_fix'] = !$context['browser']['is_ie8'];

      $context['browser']['is_ie6'] = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false && !$context['browser']['is_ie8'] && !$context['browser']['is_ie7'];

   }

   if ($context['browser']['is_ie'] || $context['browser']['is_opera'])
      $context['browser']['needs_size_fix'] = ($context['browser']['is_ie5'] || $context['browser']['is_ie5.5'] || $context['browser']['is_ie4'] || $context['browser']['is_opera6']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') === false;

   // Be you robot or human?
   if ($user_info['possibly_robot'])
   {
      // This isn't meant to be reliable, it's just meant to catch most bots to prevent PHPSESSID from showing up.
      $context['browser']['possibly_robot'] = !empty($user_info['possibly_robot']);

      // Robots shouldn't be logging in or registering.  So, they aren't a bot.  Better to be wrong than sorry (or people won't be able to log in!), anyway.
      if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register'))) || !$user_info['is_guest'])
         $context['browser']['possibly_robot'] = false;
   }
   else
      $context['browser']['possibly_robot'] = false;

}
#36
PasteBin / Paste-1316651025:v:use_geshi-1...
Last post by Guest - Sep 22, 2011, 12:23 AM
[root@490 Downloads]# vi /etc/selinux/config
[root@490 Downloads]# "setenforce 0"
bash: setenforce: command not found...
^[[AInstall package 'libselinux-utils' to provide command 'setenforce'? [N/y]
 * Waiting in queue...
 * Running... The transaction failed: all-packages-already-installed, The packages are already all installed

[root@490 Downloads]#
#37
PasteBin / Paste-1316650822:v:use_geshi-1...
Last post by Guest - Sep 22, 2011, 12:20 AM
[waterfly@490 Downloads]$ ls -l /KVMstorage/
total 16
-rwxr-xr-x. 1 root root 10737418240 Sep 21 09:38 FreeBSDv1.img
-rwxr-xr-x. 1 root root 12884901888 Sep 21 10:15 freebsd.img
drwx------. 2 root root       16384 Sep  9 14:25 lost+found
#38
PasteBin / Paste-1316649823:v:use_geshi-1...
Last post by Guest - Sep 22, 2011, 12:03 AM
[root@490 Downloads]# ls -l
total 2356848
-rwxrwxrwx. 1 qemu qemu 2414686208 Sep 21 06:55 FreeBSD-8.2-RELEASE-amd64-dvd1.iso
[root@490 Downloads]# chown waterfly:waterfly FreeBSD-8.2-RELEASE-amd64-dvd1.iso
[root@490 Downloads]# virt-install --name FreeBSDv1 --cdrom FreeBSD-8.2-RELEASE-amd64-dvd1.iso --ram 512 --disk path=/KVMstorage/FreeBSDv1.img,size=10

Starting install...
ERROR    internal error Process exited while reading console log output: char device redirected to /dev/pts/3
qemu-kvm: -drive file=/home/waterfly/Downloads/FreeBSD-8.2-RELEASE-amd64-dvd1.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw: could not open disk image /home/waterfly/Downloads/FreeBSD-8.2-RELEASE-amd64-dvd1.iso: Permission denied

Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start FreeBSDv1
otherwise, please restart your installation.
[root@490 Downloads]# ls -l
total 2356848
-rwxrwxrwx. 1 qemu qemu 2414686208 Sep 21 06:55 FreeBSD-8.2-RELEASE-amd64-dvd1.iso
[root@490 Downloads]# chown waterfly:waterfly FreeBSD-8.2-RELEASE-amd64-dvd1.iso
[root@490 Downloads]# ls -l
total 2356848
-rwxrwxrwx. 1 waterfly waterfly 2414686208 Sep 21 06:55 FreeBSD-8.2-RELEASE-amd64-dvd1.iso
[root@490 Downloads]# virt-install --name FreeBSDv1 --cdrom FreeBSD-8.2-RELEASE-amd64-dvd1.iso --ram 512 --disk path=/KVMstorage/FreeBSDv1.img,size=10

Starting install...
ERROR    internal error Process exited while reading console log output: char device redirected to /dev/pts/3
qemu-kvm: -drive file=/home/waterfly/Downloads/FreeBSD-8.2-RELEASE-amd64-dvd1.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw: could not open disk image /home/waterfly/Downloads/FreeBSD-8.2-RELEASE-amd64-dvd1.iso: Permission denied

Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start FreeBSDv1
otherwise, please restart your installation.
[root@490 Downloads]# ls -la
total 2356856
drwxr-xr-x.  2 waterfly waterfly       4096 Sep 21 09:35 .
drwx------. 23 waterfly waterfly       4096 Sep 20 15:01 ..
-rwxrwxrwx.  1 qemu     qemu     2414686208 Sep 21 06:55 FreeBSD-8.2-RELEASE-amd64-dvd1.iso
[root@490 Downloads]#
#39
PasteBin / Paste-1316190696:v:use_geshi-1...
Last post by SleePy - Sep 16, 2011, 04:31 PM
<?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);
      }
   }

#40
PasteBin / Paste-1316190533:v:use_geshi-1...
Last post by SleePy - Sep 16, 2011, 04:28 PM
<?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);
      }
   }