Jan 27, 2022, 02:52 PM

News:

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


Recent posts

Pages 1 2 3 4 5 ... 10
21
PasteBin / Paste-1327107545:v:use_geshi-1...
Last post by SleePy - Jan 21, 2012, 12:59 AM
/*
* userInfo as a class.  We kinda do a poor method, but its the best way for now.
*/
class userInfo
{
   public static $instanceID = 0;

   public static function _()
   {
      if (self::$instanceID == 0)
         self::$instanceID = new userInfo;

      return self::$instanceID;
   }

   public function __set($key, $value)
   {
      global $user_info;
      $user_info[$key] = $value;
   }

   public function __get($key)
   {
      global $user_info;
      return $user_info[$key];
   }

   public function __isset($key)
   {
      global $user_info;
      return isset($user_info[$key]);
   }

   public function __unset($key)
   {
      global $user_info;
      unset($user_info[$key], $user_info[$key]);
   }
}
22
PasteBin / Paste-1325977207:v:use_geshi-1...
Last post by Guest - Jan 07, 2012, 11:00 PM
/**
 * Lets give you a token of our appreciation.
 * @param string $action
 * @param string $type = 'post'
 * @return array
 */
function createToken($action, $type = 'post')
{
   global $modSettings, $context;

   $token = md5(mt_rand() . session_id() . (string) microtime(true) . $modSettings['rand_seed'] . $type);
   $token_var = substr(preg_replace('~^\d+~', '', md5(mt_rand() . (string) microtime(true) . mt_rand())), 0, rand(7, 12));

   $_SESSION['token'][$type . '-' . $action] = array($token_var, md5($token . $_SERVER['HTTP_USER_AGENT']), time(), $token);

   $context[$action . '_token'] = $token;
   $context[$action . '_token_var'] = $token_var;

   return array($token_var, $token);
}

/**
 * Only patrons with valid tokens can ride this ride.
 * @param string $action
 * @param string $type = 'post' (get, request, or post)
 * @param bool $reset = true
 * @return bool
 */
function validateToken($action, $type = 'post', $reset = true)
{
   global $modSettings;

   $type = $type == 'get' || $type == 'request' ? $type : 'post';

   // This nasty piece of code validates a token.
   /*
      1. The token exists in session.
      2. The {$type} variable should exist.
      3. We concat the variable we received with the user agent
      4. Match that result against what is in the session.
      5. If it matchs, success, otherwise we fallout.
   */
   if (isset($_SESSION['token'][$type . '-' . $action], $GLOBALS['_' . strtoupper($type)][$_SESSION['token'][$type . '-' . $action][0]]) && md5($GLOBALS['_' . strtoupper($type)][$_SESSION['token'][$type . '-' . $action][0]] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['token'][$type . '-' . $action][1])
   {
      // Invalidate this token now.
      unset($_SESSION['token'][$type . '-' . $action]);

      return true;
   }

   // Patrons with invalid tokens get the boot.
   if ($reset)
   {
      // Might as well do some cleanup on this.
      cleanTokens();

      // I'm back baby.
      createToken($action, $type);

      fatal_lang_error('token_verify_fail', false);
   }
   // Remove this token as its useless
   else
      unset($_SESSION['token'][$type . '-' . $action]);

   // Randomly check if we should remove some older tokens.
   if (mt_rand(0, 138) == 23)
      cleanTokens();

   return false;
}

/**
 * Clean up a little.
 * @param bool $complete = false
 */
function cleanTokens($complete = false)
{
   // We appreciate cleaning up after yourselves.
   if (!isset($_SESSION['token']))
      return;

   // Clean up tokens, trying to give enough time still.
   foreach ($_SESSION['token'] as $key => $data)
      if ($data[2] + 10800 < time() || $complete)
         unset($_SESSION['token'][$key]);
}
23
PasteBin / Paste-1325028133:v:use_geshi-1...
Last post by Guest - Dec 27, 2011, 11:22 PM
Show types:

if the show is in

   PAST
      Grey background

   Current/future

      If shwtype = Repeat
         Blue

      If shwtype=live
         if one time
            Plum

         if recurring
            Green
      End live types
   End Current/Future
End Show Types
24
PasteBin / Paste-1324935696:v:use_geshi-1...
Last post by Guest - Dec 26, 2011, 09:41 PM
   //Let's prep the account to get some info...
   $res2=mysql_query("
      SELECT cx.id_member, cx.uname, cx.requestd, cx.nextbd, cx.cxreasons,
         cx.intnotes, ls.start_time, a.payment_provider, a.ccFirst6, a.ccLast4
      FROM ADMIN_cxrequests AS cx
      LEFT JOIN z_log_subscribed AS ls ON (ls.id_member = cx.id_member)
      INNER JOIN account AS a ON (ls.id_member = a.id_member)
      WHERE cx.cxid='$cxid'
      AND ls.id_member = cx.id_member
      AND ls.id_subscribe = '1'
   "); echo mysql_error();
   list($id_member,$uname,$requestd,$nextbd,$cxreasons,$intnotes,
      $mbrsince,$provider,$ccf6,$ccl4)=$res2;
25
PasteBin / Paste-1324606495:v:use_geshi-1...
Last post by asdfasdf - Dec 23, 2011, 02:14 AM
$array1 = array(1,2,3,4,5,6,7)

$choices = "1,3,5,2,3,4,3,2,7,4,2,1,4,5,3,4,2,1,3,3";

item "1" in array one appeared in $choices 2 times
item "2" in array one appeared in $choices 4 times
item "3" in array one appeared in $choices 6 times
item "4" in array one appeared in $choices 3 times
item "5" in array one appeared in $choices 2 times
item "6" in array one appeared in $choices 0 times
item "7" in array one appeared in $choices 1 times

Then print the results as follows:

Item "1": 2 - 11%
Item "2": 4 - 22%
Item "3": 6 - 33%
Item "4": 3 - 16%
Item "5": 2 - 11%
Item "7": 1 - 6%

Notice that Item "6" is not in the display, since it has no votes/selections

--------------------------------------
$mstrreas1=mysql_query("
   SELECT id, reason
   FROM CONFIG_cxreasons
   ");

while($mstrreastmp1=mysql_fetch_array($mstrreas1)){
   list($mid,$mreason)=$mstrreastmp1;
   foreach($reasonlist as $key=>$indreason){
      if($mreason=="$indreason"){
      $mreason$mid++;$reasontotal++;
   }
}
26
PasteBin / Paste-1324606230:v:use_geshi-0...
Last post by Guest - Dec 23, 2011, 02:10 AM
$array1 = array(1,2,3,4,5,6,7)

$choices = "1,3,5,2,3,4,3,2,7,4,2,1,4,5,3,4,2,1,3,3";

item "1" in array one appeared in $choices 2 times
item "2" in array one appeared in $choices 4 times
item "3" in array one appeared in $choices 6 times
item "4" in array one appeared in $choices 3 times
item "5" in array one appeared in $choices 2 times
item "6" in array one appeared in $choices 0 times
item "7" in array one appeared in $choices 1 times

Then print the results as follows:

Item "1": 2 - 11%
Item "2": 4 - 22%
Item "3": 6 - 33%
Item "4": 3 - 16%
Item "5": 2 - 11%
Item "7": 1 - 6%

Notice that Item "6" is not in the display, since it has no votes/selections
27
PasteBin / Paste-1321995762:v:use_geshi-1...
Last post by Guest - Nov 22, 2011, 09:02 PM
if($srchprice=="Any")
{$sprc="pprice LIKE '%'";}

if($srchprice=="100000")
{$sprc="pprice <= '100000'";}

if($srchprice=="250000")
{$sprc="((pprice >= '100000.01') && (pprice <= '250000'))";}

if($srchprice=="500000")
{$sprc="((pprice >= '250000.01') && (pprice <= '500000'))";}

if($srchprice=="750000")
{$sprc="((pprice >= '500000.01') && (pprice <= '750000'))";}

if($srchprice=="1000000")
{$sprc="((pprice >= '750000.01') && (pprice <= '1000000'))";}

if($srchprice=="99999999")
{$sprc="pprice >= '1000000.01'";}
28
PasteBin / Paste-1321325648:v:use_geshi-1...
Last post by SleePy - Nov 15, 2011, 02:54 AM
      // Get the tracked bugs
      $request = smcFunc::db_query('', '
         SELECT COUNT(DISTINCT t.id_topic)
         FROM {db_prefix}topics AS t
            INNER JOIN main_messages AS m ON (m.id_msg = t.id_first_msg)
         WHERE t.id_board = {int:bugs_board}
            AND m.subject REGEXP({string:regex})',
         array(
            'bugs_board' => 137,
            'regex' => '\[[0-9]{4}\]'
      ));
      list ($tracked) = smcFunc::db_fetch_row($request);
      smcFunc::db_free_result($request);

      // Get the total
      $request = smcFunc::db_query('', '
         SELECT COUNT(id_topic)
         FROM {db_prefix}topics
         WHERE id_board = {int:bugs_board}',
         array(
            'bugs_board' => 137
      ));
      list ($total) = smcFunc::db_fetch_row($request);
      smcFunc::db_free_result($request);

      // Get the locked
      $request = smcFunc::db_query('', '
         SELECT COUNT(id_topic)
         FROM {db_prefix}topics
         WHERE id_board = {int:bugs_board}
            and locked = {int:locked}',
         array(
            'bugs_board' => 137,
            'locked' => 1,
      ));
      list ($locked) = smcFunc::db_fetch_row($request);
      smcFunc::db_free_result($request);
29
PasteBin / Paste-1320742963:v:use_geshi-1...
Last post by Guest - Nov 08, 2011, 09:02 AM
dsadsadsadas
30
PasteBin / Paste-1319595022:v:use_geshi-1...
Last post by SleePy - Oct 26, 2011, 02:10 AM
<?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');
?>
Pages 1 2 3 4 5 ... 10