initialise();
/**
* This will put the get_opts script into debug mode
* instead of returning the sql, it will exit with the result
* to enable you to fix a problem, should it arise, with relative ease.
* LEAVE THIS ALONE UNLESS YOU KNOW HOW TO DEBUG PHP AND MySQL
*
* Case insensitive too for future reference.
**/
define( "EXITSQL", 0, true );
class panel_core
{
/**
* Set core variables
**/
// Gets information from the database and sets options
function get_opts( $option )
{
// Make the $option variable lowercase to stop "BBCode" or "OnOff" (for example) being ignored.
$option = strtolower( $option );
// Get needed settings from database (Which just so happens to be.. wait for it... all of them :D)
$getsettings = @mysql_fetch_array( mysql_query( "SELECT * FROM `" . TABLEPREFIX . "settings`" ) )
or $this->log( "MySQL Error", mysql_error( ), 1 );
// Put the settings into a big ol' array
$settings = array( "bbcode" => $getsettings["bbcode"], // Should return integer
"emoticons" => $getsettings["emotes"], // Should return integer
"onoff" => $getsettings["onoff"], // Should return integer
"filter" => $getsettings["filter"], // Should return integer
"sitename" => $getsettings["sitename"], // Should return string
"siteurl" => $getsettings["siteurl"], // Should return string
"welcome" => $getsettings["welcome"], // Should return string
"clean" => $getsettings["clean"], // Should return integer
"css" => $getsettings["css_tag"]
);
// Gotta make sure what we're after is a valid setting...
if( $settings["$option"] != "" )
{
if( EXITSQL == 1 ) // Looks like we're debugging
{
$exit = gettype( $settings["$option"] );
exit( "MySQL Returned type $exit.
result: {$settings["$option"]}" ); // Exit with the type returned from sql (Like boolean etc etc) and show them it with the result!
}
else // Ah, glorious non-debugging-action-which-is-taking-up-this-comment-space.
{
return $settings["$option"]; // Just return the sql result and let it get on with whatever.
}
}
else // Not a valid setting, that makes me & the script :(
{
return false; // Return false and let's get out of here.
}
}
/**
* Tag cleaning decider function
*
* Decides what functions to call (What level of cleaning)
* for cleaning string passed into it, then cleans it.
**/
function clean( $string, $forcelevel = null, $sql = null )
{
if( $forcelevel != null )
{
$getlevel = $forcelevel;
}
else
{
$getlevel = $this->get_opts( "clean" );
}
switch( $getlevel )
{
default:
$string = panel_clean::max_clean( $string );
case 4: // Panicking
$string = panel_clean::max_clean( $string ); // Welcome back $string, we missed you!
break; // No need to carry on from here, it's instantly protected beyond any "hackers" playing around.
case 3: // Nervous
$string = panel_clean::med_clean( $string );
$string = panel_clean::base_clean( $string );
$string = panel_clean::core_clean( $string );
$donl2br = 0;
break;
case 2: // Cool, calm and default
$string = panel_clean::base_clean( $string );
$string = panel_clean::core_clean( $string );
break;
case 1: // Why panic when you have KOOL-AIDS (lol aids)
$string = panel_clean::core_clean( $string );
break;
}
if( $this->get_opts( "bbcode" ) == 1 ) // Are we parsing bbcode?
{
// We are, but we need to parse it _last_ to make sure the parsed code isn't cleaned!
$string = panel_bbcode::parse_main_bb( $string, $this->get_opts( "emoticons" ) );
}
return $string; // Give em it back :(
}
/**
* Ok, lets get on with getting basic user info.
**/
function get_info( $requested )
{
// Convert to lowercase to stop case insensitive problems.
$requested = strtolower( $requested );
$available = array( "username" => $_SESSION["p_username"],
"level" => $_SESSION["p_level"],
"auth" => $_SESSION["p_randauth"],
"passhash" => $_SESSION["p_hash"],
"ip" => $_SESSION["p_ip"], // Lol pips
"lusername" => $_SESSION["p_lusername"]
);
if( $available["$requested"] != "" ) // It's in there, give them the stuff they asked for.
{
return $available["$requested"];
}
else
{
// Eh, after something that's not there :(
return "Not Available.";
}
}
function check_user( $username )
{
if( $username == "" )
{
return false;
}
// Simple function to get user information dependant on if the password is supplied or not.
// Looks like we're checking info based on just the username (Probably an auth check in the panel)
$username = strtolower( $this->clean( $username ) ); // Clean up the username.
$sql = @mysql_query( "SELECT * FROM `" . TABLEPREFIX . "users` WHERE `lusername` = '$username'" )
or $this->log( "MySQL Error", mysql_error( ), 1 );
if( @mysql_num_rows( $sql ) == 0 )
{
return false;
}
else
{
$fetch = @mysql_fetch_array( $sql )
or $this->log( "MySQL Error", mysql_error( ), 1 );
$storedinfo = array( "password" => $this->get_info( "passhash" ),
"randauth" => $this->get_info( "auth" ),
"getuseip" => $this->get_info( "ip" ),
"gtuselvl" => $this->get_info( "level" )
);
if( $storedinfo["password"] != md5( $fetch["password"] ) /*|| $storedinfo["randauth"] != $fetch["randauth"]*/ || $storedinfo["getuseip"] != $_SERVER["REMOTE_ADDR"] || $storedinfo["gtuselvl"] != $fetch["level"] )
{
return false; // Ha, not giving the right stuff eh? Better kick em out!
}
else
{
return true;
}
}
}
function notice( $header, $message, $url ) // Standard notice, don't need to touch this.
{
@header("Refresh: 9;url=".$url);
echo("