<!--?php
class Faster{
public $core; public $request; public $model; public $view; public $data; public $date;
}
class Faster_Request extends Faster{
private $_request_group; private $_request_action; private $_params;
public function _setGroup( $sGroup ) { $this->_request_group = $sGroup; }
public function _setAction( $sAction ) { $this->_request_action = $sAction; }
public function redirectRoute( $sPath, $bTemp = 1 ) { do_action( "msys_app_redirect", $sPath ); if ( $sPath == 404 ) { trigger_error( "404" ); $this->dispatchRoute( 404 ); exit( ); } $sPath = trim( $sPath ); if ( $bTemp == 1 and& $sPath != "" ) { header( "HTTP/1.1 302 Moved Temporarily" ); header( "Location: {$sPath}" ); exit( ); } if ( $sPath != "" ) { header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: {$sPath}" ); exit( ); } }
public function isPosted( ) { if ( empty( $_POST ) and& empty( $_FILES ) ) { return FALSE; } return TRUE; }
public function getSessionVar( $key ) { @session_set_cookie_params( 0, "/" ); @session_start( ); $result = @$_SESSION[session_id( )."_".@strtoupper( @$key )]; return $result; }
public function setSessionVar( $key, $val ) { @session_set_cookie_params( 0, "/" ); @session_start( ); $_SESSION[session_id( )."_".strtoupper( $key )] = $val; }
public function getIP( ) { $sTest = ""; if ( isset( $_SERVER['HTTP_X_FORWARD_FOR'] ) ) { $sTest = $_SERVER['HTTP_X_FORWARD_FOR']; } if ( $sTest ) { $s = $sTest; } else { $s = $_SERVER['REMOTE_ADDR']; } $s = strip_tags( $s ); if ( function_exists( "filter_var" ) ) { $result = filter_var( $s, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH ); } return $result; }
public function getUserAgent( ) { $s = $_SERVER['HTTP_USER_AGENT']; $result = strip_tags( $s ); if ( function_exists( "filter_var" ) ) { $result = filter_var( $s, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH ); } return $result; }
public function getReferrer( ) { $s = @$_SERVER['HTTP_REFERER']; $result = strip_tags( $s ); if ( function_exists( "filter_var" ) ) { $result = filter_var( $s, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH ); } return $result; }
public function getReferer( ) { return $this->getReferrer( ); }
public function getPath( ) { $sPath = str_replace( "index.php", "", $_SERVER['SCRIPT_NAME'] ); $result = @$_SERVER['REDIRECT_URL']; $sTest = substr( $result, 0, strlen( $sPath ) ); if ( $sTest == $sPath ) { $result = substr( $result, strlen( $sPath ) ); } if ( empty( $result ) ) { $result = dirname( __FILE__ ); } return $result; }
public function polishGroup( $path ) { $s = ltrim( $path, "/" ); $s = rtrim( $s, "/" ); $s = str_replace( "-", " ", $s ); $s = ucwords( strtolower( $s ) ); $s = str_replace( " ", "", $s ); $s = strrev( $s ); $s = basename( $s ); $result = strrev( $s ); return $result; }
public function polishAction( $path ) { $s = ltrim( $path, "/" ); $s = rtrim( $s, "/" ); $s = str_replace( "-", " ", $s ); $s = ucwords( strtolower( $s ) ); $s = str_replace( " ", "", $s ); if ( strpos( " ".$s, "/" ) === FALSE ) { $s = empty( $s ) ? "Default" : $s; return $s; } $asParts = explode( "/", $s ); $s = @$asParts[1]; $s = ucfirst( $s ); $s = empty( $s ) ? "Default" : $s; if ( substr( $s, 0 - 4 ) == ".php" ) { $s = str_replace( ".php", "", $s ); } $result = $s; return $result; }
private function _getGuessGroup( ) { $s = $this->getPath( ); $s = $this->polishGroup( $s ); return $s; }
private function _getGuessAction( ) { $s = $this->getPath( ); return $this->polishAction( $s ); }
public function getGroup( ) { if ( isset( $this->_request_group ) ) { $result = $this->_request_group; return $result; } $sGGroup = $this->_getGuessGroup( ); $sGAction = $this->_getGuessAction( ); $F = $this->core->base( ); $sTestPath1 = $F."/controllers/".$sGGroup."/c".$sGAction.".php"; $sTestPath2 = $F."/controllers/".$sGGroup."/cDefault.php"; if ( file_exists( $sTestPath1 ) || file_exists( $sTestPath2 ) ) { $this->_request_group = $sGGroup; $result = $sGGroup; return $result; } $this->_request_group = "Default"; $result = "Default"; return $result; }
public function getAction( ) { if ( isset( $this->_request_action ) ) { $result = $this->_request_action; return $result; } $sGGroup = $this->_getGuessGroup( ); $sGAction = $this->_getGuessAction( ); $F = $this->core->base( ); $sTestPath1 = $F."/controllers/".$sGGroup."/c".$sGAction.".php"; $sTestPath2 = $F."/controllers/".$sGGroup."/cDefault.php"; if ( file_exists( $sTestPath1 ) || file_exists( $sTestPath2 ) ) { if ( file_exists( $sTestPath1 ) ) { $this->_request_action = $sGAction; $result = $sGAction; return $result; } $this->_request_action = "Default"; $result = "Default"; return $result; } $this->_request_action = "Default"; $result = "Default"; return $result; }
public function getParam( $index ) { $asParams = $this->getParams( ); $result = @$asParams[$index]; return $result; }
public function getParams( ) { if ( isset( $this->_params ) ) { $result = $this->_params; return $result; } global $argv; $sTest = @$argv[1]; $bCLI = !empty( $sTest ); if ( $bCLI ) { $asParams = $argv; array_shift( $asParams ); array_shift( $asParams ); foreach ( $asParams as $sKey => $sVal ) { if ( substr( $sVal, 0, 2 ) == "--" ) { $sVal = preg_replace( "/^--/", "", $sVal ); $asParams[$sKey] = $sVal; } if ( substr( $sVal, 0, 1 ) == "\"" and& substr( $sVal, 0 - 1, 1 ) == "\"" ) { $sVal = ltrim( $sVal, "\"" ); $sVal = rtrim( $sVal, "\"" ); $asParams[$sKey] = $sVal; } else if ( substr( $sVal, 0, 1 ) == "'" and& substr( $sVal, 0 - 1, 1 ) == "'" ) { $sVal = ltrim( $sVal, "'" ); $sVal = rtrim( $sVal, "'" ); $asParams[$sKey] = $sVal; } } $this->_params = $asParams; $result = $asParams; return $result; } $F = $this->core->base( ); $sGroup = $this->getGroup( ); $sAction = $this->getAction( ); $s = $this->getPath( ); if ( 0 < strpos( " ".$s, "?" ) ) { $nPos = strpos( $s, "?" ); $s = substr( $s, 0, $nPos ); } $s = ltrim( $s, "/" ); $s = rtrim( $s, "/" ); $asParts = explode( "/", $s ); $sPossibleGroup = @$asParts[0]; $sPossibleAction = @$asParts[1]; $sPossibleGroup = str_replace( "-", " ", $sPossibleGroup ); $sPossibleGroup = ucwords( strtolower( $sPossibleGroup ) ); $sPossibleGroup = str_replace( " ", "", $sPossibleGroup ); $sPossibleGroup = ucfirst( $sPossibleGroup ); $sPossibleAction = str_replace( "-", " ", $sPossibleAction ); $sPossibleAction = ucwords( strtolower( $sPossibleAction ) ); $sPossibleAction = str_replace( " ", "", $sPossibleAction ); $sPossisPossibleActionbleGroup = ucfirst( $sPossibleAction ); if ( file_exists( $F."/controllers/".$sPossibleGroup ) ) { array_shift( $asParts ); } if ( file_exists( $F."/controllers/".$sPossibleGroup."/c".$sPossibleAction.".php" ) ) { array_shift( $asParts ); } if ( $sAction == "Default" ) { $sScript = @$_SERVER['SCRIPT_NAME']; $sRequest = @$_SERVER['REQUEST_URI']; $sScript = str_replace( "/index.php", "", $sScript ); $sRequest = str_replace( $sScript, "", $sRequest ); $sRequest .= "?"; $asParts = explode( "?", $sRequest ); $sRequest = $asParts[0]; $sRequest = ltrim( $sRequest, "/" ); $sRequest = rtrim( $sRequest, "/" ); if ( strlen( $sRequest ) == 0 ) { $result = array( ); return $result; } $asParts = explode( "/", $sRequest ); if ( $sGroup != "Default" ) { array_shift( $asParts ); } array_shift( $asParts ); } $this->_params = $asParts; $result = $asParts; return $result; }
public function getVars( ) { foreach ( $_GET as $sKey => $sVal ) { $sVal = urldecode( $sVal ); $sVal = stripslashes( $sVal ); $_GET[$sKey] = trim( $sVal ); } $result = $_GET; return $result; }
public function getPostedVars( ) { foreach ( $_POST as $sKey => $sVal ) { $sVal = trim( $sVal ); $sVal = stripslashes( $sVal ); $_POST[$sKey] = $sVal; } $result = $_POST; return $result; }
public function getServerVars( ) { $result = $_SERVER; return $result; }
public function getVar( $key, $do_strip_tags = TRUE ) { $sVal = @$_GET[$key]; $sVal = stripslashes( $sVal ); if ( $do_strip_tags ) { $sVal = strip_tags( $sVal ); } $sVal = urldecode( $sVal ); $result = trim( $sVal ); return $result; }
public function getPostedVar( $key, $do_strip_tags = TRUE ) { $sVal = @$_POST[$key]; $sVal = stripslashes( $sVal ); if ( $do_strip_tags ) { $sVal = strip_tags( $sVal ); } $result = trim( $sVal ); return $result; }
public function getServerVar( $key ) { $result = @$_SERVER[$key]; return $result; }
public function blockDefaultURLParams( ) { $sScript = @$_SERVER['SCRIPT_NAME']; $sRequest = @$_SERVER['REQUEST_URI']; $sScript = str_replace( "/index.php", "", $sScript ); $sRequest = str_replace( $sScript, "", $sRequest ); if ( 0 < strpos( " ".$sRequest, "?" ) ) { $asParts = explode( "?", $sRequest ); $sRequest = $asParts[0]; } if ( $sRequest != "/" ) { $this->request->redirectRoute( 404 ); } }
public function dispatchRoute( $_page_controller = "", $_stop_when_routed = TRUE ) { $_F = $this->core->base( ); if ( $_page_controller == 404 ) { if ( !headers_sent( ) ) { header( "HTTP/1.1 404 Not Found" ); header( "Status: 404 Not Found" ); } if ( file_exists( $_F."/404.php" ) ) { unset( $_page_controller ); unset( $_stop_when_routed ); do_action( "msys_app_dispatch", "404" ); require_once( $_F."/404.php" ); } else { do_action( "msys_app_dispatch", "404" ); @include( $_F."/404.html" ); } exit( ); } if ( empty( $_page_controller ) ) { $_sGroup = $this->getGroup( ); $_sAction = $this->getAction( ); if ( !file_exists( $_F."/controllers" ) ) { trigger_error( "Your folder layout is missing a controllers folder", E_USER_ERROR ); } if ( !file_exists( $_F."/controllers/Default" ) ) { trigger_error( "Your folder layout is missing a controllers/Default controller folder", E_USER_ERROR ); } if ( !file_exists( $_F."/controllers/Default/cDefault.php" ) ) { trigger_error( "Your folder layout is missing a controllers/Default/cDefault.php controller file", E_USER_ERROR ); } $_sPath = $_F."/controllers/".$_sGroup."/c".$_sAction.".php"; if ( !file_exists( $_sPath ) ) { $_sPath = $_F."/controllers/".$_sGroup."/c".$_sGroup.".php"; if ( !file_exists( $_sPath ) ) { trigger_error( "Your folder layout is missing a \"".$_sPath."\" controller file", E_USER_ERROR ); } } unset( $_page_controller ); unset( $_F ); unset( $_sGroup ); unset( $_sAction ); $_path = $_sPath; unset( $_sPath ); do_action( "msys_app_dispatch", $_path ); require_once( $_path ); } else { $_s = $_page_controller; unset( $_page_controller ); $_s = str_replace( ".php", "", $_s ); $_s = ltrim( $_s, "/" ); $_s = rtrim( $_s, "/" ); $_s .= ".x"; $_sBase = basename( $_s ); $_s = str_replace( "/".$_sBase, "/c".$_sBase, $_s ); $_s = str_replace( ".x", "", $_s ); $_path = $_F."/controllers/".$_s.".php"; do_action( "msys_app_dispatch", $_path ); require_once( $_path ); } if ( $_stop_when_routed ) { exit( 0 ); } }
public function getCookieVar( $key ) { $sCookiePrefix = @$this->core->config['COOKIE_PREFIX']."_"; $key = $sCookiePrefix.strtolower( $key ); if ( isset( $_COOKIE[$key] ) ) { $val = $_COOKIE[$key]; } else { $val = ""; } return $val; }
public function getEncryptedCookieVar( $key ) { $val = $this->getCookieVar( $key ); $val = $this->_decryptData( $val ); return $val; }
public function setCookieVar( $key, $val ) { $sCookiePrefix = @$this->core->config['COOKIE_PREFIX']."_"; $sPath = "/"; if ( empty( $val ) ) { $this->deleteCookieVar( $key ); } else { setcookie( strtolower( $sCookiePrefix.$key ), $val, 0, $sPath ); } }
public function setPersistentCookieVar( $key, $val, $days = 365 ) { $sCookiePrefix = @$this->core->config['COOKIE_PREFIX']."_"; $sPath = "/"; if ( !headers_sent( ) ) { header( "Cache-control: private" ); } setcookie( strtolower( $sCookiePrefix.$key ), $val, time( ) + 60 * 60 * 24 * $days, $sPath ); }
public function setEncryptedCookieVar( $key, $val ) { $val = $this->_encryptData( $val ); $this->setCookieVar( $key, $val ); }
public function setEncryptedPersistentCookieVar( $key, $val, $days = 365 ) { $val = $this->_encryptData( $val ); $this->setPersistentCookieVar( $key, $val, $days ); }
public function deleteCookieVar( $key ) { $sCookiePrefix = @$this->core->config['COOKIE_PREFIX']."_"; $sPath = "/"; $key = strtolower( $key ); setcookie( $sCookiePrefix.$key, " ", 0, $sPath ); setcookie( $sCookiePrefix.$key, "", time( ) - 3600, $sPath ); }
private function _decryptData( $sData ) { $sCookiePrefix = @$this->core->config['COOKIE_PREFIX']; $sPrivateKey = md5( $sCookiePrefix ); if ( trim( $sData ) == "" ) { return ""; } $sPrivateKey = strrev( $sPrivateKey ); $sData = urldecode( $sData ); $sData = base64_decode( $sData ); if ( function_exists( "mcrypt_encrypt" ) ) { $iv_size = mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ); $iv = mcrypt_create_iv( $iv_size, MCRYPT_RAND ); $sData = mcrypt_decrypt( MCRYPT_RIJNDAEL_256, $sPrivateKey, $sData, MCRYPT_MODE_ECB, $iv ); } else { $j = 0; $nLen = strlen( $sData ); $i = 0; while ( $i < $nLen ) { $sData[$i] = chr( ord( $sData[$i] ) ^ ord( $sPrivateKey[$j] ) ); ++$j; $j = strlen( $sPrivateKey ) <= $j ? 0 : $j; ++$i; } $sData = strrev( $sData ); } return trim( $sData ); }
private function _encryptData( $sData ) { $sCookiePrefix = @$this->core->config['COOKIE_PREFIX']; $sPrivateKey = md5( $sCookiePrefix ); if ( trim( $sData ) == "" ) { return ""; } $sPrivateKey = strrev( $sPrivateKey ); if ( function_exists( "mcrypt_encrypt" ) ) { $iv_size = mcrypt_get_iv_size( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB ); $iv = mcrypt_create_iv( $iv_size, MCRYPT_RAND ); $sData = mcrypt_encrypt( MCRYPT_RIJNDAEL_256, $sPrivateKey, $sData, MCRYPT_MODE_ECB, $iv ); } else { $sData = strrev( $sData ); $j = 0; $nLen = strlen( $sData ); $i = 0; while ( $i < $nLen ) { $sData[$i] = chr( ord( $sData[$i] ) ^ ord( $sPrivateKey[$j] ) ); ++$j; $j = strlen( $sPrivateKey ) <= $j ? 0 : $j; ++$i; } } $sData = trim( base64_encode( $sData ) ); $sData = str_replace( "=", "", $sData ); $sData = urlencode( $sData ); return $sData; }
}
class Faster_Model extends Faster{
public function load( $_name ) { $_F = $this->core->base( ); if ( 0 < strpos( " ".$_name, "/" ) ) { $_sBaseName = basename( $_name ); $_sPath = dirname( $_name ); $_sPath = rtrim( $_sPath, "/" )."/"; $_sModelPath = $_sPath.$_sBaseName.".php"; $_name = basename( $_name ); } else { $_sModelPath = $_name.".php"; } if ( !file_exists( $_F."/models" ) ) { trigger_error( "Your folder layout is missing a models folder", E_USER_ERROR ); } $_sPath = $_F."/models/".$_sModelPath; if ( !file_exists( $_sPath ) ) { trigger_error( "Your folder layout is missing a \"".$_sPath."\" models file", E_USER_ERROR ); } unset( $_sBaseName ); unset( $_sModelPath ); unset( $_F ); $_path = $_sPath; unset( $_sPath ); require_once( $_path ); $_o = new $_name( ); $_o->core = $this->core; $_o->request = $this->request; $_o->model = $this; $_o->view = $this->view; $_o->data = $this->data; $_o->date = $this->date; return $_o; }
}
class Faster_Core{
public $config; private $_page_load_start_time;
public function __construct( ) { $this->config = $this->getConfig( ); }
public function _setPageLoadStart( ) { $asMicro = explode( " ", microtime( ) ); $nStartTime = $asMicro[0] + $asMicro[1]; $this->_page_load_start_time = $nStartTime; }
public function getConfig( ) { $F = $this->base( ); return include( $F."/config/config.php" ); }
public function baseurl( ) { static $result = NULL; if ( !isset( $result ) ) { $result = site_url( ); $result = rtrim( $result, "/" ); $result .= "/".MSYS_JACK_DIR; } return $result; }
public function base( ) { static $result = NULL; if ( !isset( $result ) ) { $result = dirname( __FILE__ ); $result = rtrim( $result, "/" ); } return $result; }
public function sessiontimeout( ) { static $nSecs = NULL; if ( !isset( $nSecs ) ) { $nSecs = ini_get( "session.gc_maxlifetime" ); } $result = $nSecs; return $result; }
public function page_load_time( ) { $asMicro = explode( " ", microtime( ) ); $nEndTime = $asMicro[0] + $asMicro[1]; $nTotalTime = $nEndTime - $this->_page_load_start_time; return $nTotalTime; }
}
class Faster_View{
public $core; private $_request; private $_asVars = array( );
const ENCODE_DEFAULT = 0; const ENCODE_HTML = 1; const ENCODE_URL = 2;
public function _setRequest( $request ) { $this->_request = $request; }
public function setVar( $key, $val, $type_code = self::ENCODE_DEFAULT ) { $sUpper = strtoupper( $key ); if ( $sUpper != $key and& $key != "view" ) { trigger_error( "View variables must be in uppercase", E_USER_ERROR ); } switch ( $type_code ) { case self::ENCODE_HTML : $this->setVarH( $key, $val ); return; case self::ENCODE_URL : $val = urlencode( $val ); break; default : break; } $this->_asVars[$sUpper] = $val; }
public function setVarH( $key, $val ) { $sUpper = strtoupper( $key ); if ( $sUpper != $key and& $key != "view" ) { trigger_error( "View variables must be in uppercase", E_USER_ERROR ); } $sOrig = $val; try { $s = htmlentities( $val, ENT_COMPAT, "UTF-8" ); } catch ( Exception $e ) { $s = $val; } if ( empty( $s ) ) { $s = $sOrig; $s = html_entity_decode( $s ); $s = html_entity_decode( $s ); $s = htmlentities( $s ); } $quotes = array( "«" => "\"", "»" => "\"", "‘" => "'", "’" => "'", "‚" => "'", "‛" => "'", "“" => "\"", "”" => "\"", "„" => "\"", "‟" => "\"", "‹" => "'", "›" => "'" ); $s = strtr( $s, $quotes ); $s = str_replace( " ", " ", $s ); $s = str_replace( "”", "\"", $s ); $s = str_replace( "“", "\"", $s ); $s = str_replace( "„", "\"", $s ); $s = str_replace( "’", "'", $s ); $s = str_replace( "‘", "'", $s ); $s = str_replace( """, "\"", $s ); $s = str_replace( "'", "'", $s ); $s = str_replace( "\"", """, $s ); if ( empty( $s ) ) { $s = $sOrig; } $val = $s; $this->_asVars[$sUpper] = $val;}
public function __get( $key ) { $sUpper = strtoupper( $key ); if ( $sUpper != $key and& $key != "view" ) { trigger_error( "View variables must be in uppercase", E_USER_ERROR ); } if ( $key == "view" ) { return ""; } return $this->_asVars[$key]; }
public function setCVar( $key, $val, $type_code = self::ENCODE_DEFAULT ) { $sUpper = strtoupper( $key ); if ( $sUpper != $key and& $key != "view" ) { trigger_error( "View variables must be in uppercase", E_USER_ERROR ); } switch ( $type_code ) { case self::ENCODE_HTML : $val = htmlentities( $sVal ); break; case self::ENCODE_URL : $val = urlencode( $sVal ); break; default : break; } define( $sUpper, $val ); }
public function setCVars( $vars, $type_code = self::ENCODE_DEFAULT ) { foreach ( $vars as $key => $val ) { $this->setCVar( $key, $val, $type_code ); } }
public function setVars( $vars, $type_code = self::ENCODE_DEFAULT ) { foreach ( $vars as $key => $val ) { $this->setCVar( $key, $val, $type_code ); } }
public function getActiveTheme( $sBasePath = "" ) { if ( empty( $sBasePath ) ) { $sBasePath = $this->core->base( ); } @session_set_cookie_params( 0, "/" ); @session_start( ); $sTheme = @$_SESSION[session_id( )."_MSYS_ACTIVE_THEME"]; if ( empty( $sTheme ) ) { $asTemp = $this->getThemeVar( $sBasePath ); $sTheme = $asTemp['MSYS_ACTIVE_THEME']; $_SESSION[session_id( )."_MSYS_ACTIVE_THEME"] = $sTheme; } $sTheme = @$_SESSION[session_id( )."_MSYS_ACTIVE_THEME"]; return $sTheme; }
public function getThemeVar( $sBasePath ) { if ( !file_exists( $sBasePath."/themes/themes.php" ) ) { trigger_error( "Your folder layout is missing an themes/themes.php file that loads the theme.", E_USER_ERROR ); exit( "Your folder layout is missing an themes/themes.php file that loads the theme." ); } return include( $sBasePath."/themes/themes.php" ); }
public function render( $_file = "", $_draw_now = FALSE ) { $_F = $this->core->base( ); if ( empty( $_file ) ) { $_file = $this->_request->getGroup( )."/".$this->_request->getAction( ); } $_file = strrev( $_file ); $_file = str_replace( "/", "~", $_file ); $_file = preg_replace( "/~/", "v~", $_file, 1 ); $_file = str_replace( "~", "/", $_file ); $_file = strrev( $_file ); if ( !$_draw_now ) { ob_start( ); } $ACTIVE_THEME = $this->getActiveTheme( $_F ); if ( !file_exists( $_F."/themes/".$ACTIVE_THEME ) ) { trigger_error( "Your folder layout is missing an themes/".$ACTIVE_THEME." folder", E_USER_ERROR ); exit( "Your folder layout is missing an themes/".$ACTIVE_THEME." folder" ); } $_sPath = $_F."/themes/".$ACTIVE_THEME."/".$_file.".php"; $_sPath2 = $_F."/themes/Default/".$_file.".php"; if ( !file_exists( $_sPath ) ) { if ( !file_exists( $_sPath2 ) ) { trigger_error( "Your folder layout is missing a \"".$_file."\" theme file", E_USER_ERROR ); exit( "Your folder layout is missing a \"".$_file."\" theme file" ); } else { $_sPath = $_sPath2; } } if ( file_exists( $_sPath ) ) { unset( $_F ); unset( $_file ); $_path = $_sPath; unset( $_sPath ); require_once( $_path ); } else { $_file = $this->_request->getGroup( )."/".$this->_request->getGroup( ); $_file = strrev( $_file ); $_file = str_replace( "/", "~", $_file ); $_file = preg_replace( "/~/", "v~", $_file, 1 ); $_file = str_replace( "~", "/", $_file ); $_file = strrev( $_file ); $_sPath = $_F."/themes/".$ACTIVE_THEME."/".$_file.".php"; $_sPath2 = $_F."/themes/Default/".$_file.".php"; unset( $_F ); unset( $_file ); if ( file_exists( $_sPath ) ) { $_path = $_sPath; unset( $_sPath ); require_once( $_path ); } else if ( file_exists( $_sPath2 ) ) { $_path = $_sPath2; unset( $_sPath2 ); require_once( $_path ); } } if ( !$_draw_now ) { $_result = ob_get_contents( ); ob_end_clean( ); return $_result; } }
public function display( $sFile = "", $bDrawImmediately = FALSE ) { $sContent = $this->render( $sFile, $bDrawImmediately ); $sContent = apply_filters( "msys_app_display", $sContent, $sFile, $this->view ); echo $sContent; }
}
class PDOStatementStub{
private $_hst;
public function __construct( $st ) { $this->_hst = $st; return $this->_hst; }
public function __call( $pdo_call, $args ) { if ( !method_exists( $this, $pdo_call ) ) { if ( $pdo_call == "execute" ) { $st = $this->_hst; $sSQL = @$st->queryString; if ( stripos( $sSQL, "select" ) === FALSE and& stripos( $sSQL, "from" ) === FALSE ) { wp_cache_flush( ); } } $result = call_user_func_array( array( $this->_hst, $pdo_call ), $args ); return $result; } }
}
class PDOStub{
private $_hDB;
public function __construct( $dsn, $username, $password, $driver_options = array( ) ) { $this->_hDB = new PDO( $dsn, $username, $password, $driver_options ); $result = $this->_hDB; return $result; }
public function prepare( $sql, $driver_options = array( ) ) { $st = $this->_hDB->prepare( $sql, $driver_options ); $st = new PDOStatementStub( $st ); return $st; }
public function __call( $pdo_call, $args ) { if ( !method_exists( $this, $pdo_call ) ) { $result = call_user_func_array( array( $this->_hDB, $pdo_call ), $args ); return $result; } }
}
class Faster_Data{
private $_core;
public function _setCore( $core ) { $this->_core = $core; }
public function mysql( ) { static $PDO = NULL; if ( !$PDO ) { $sPort = @$this->_core->config['DB_PORT']; $sPort = empty( $sPort ) ? "3306" : $sPort; $DSN = sprintf( "mysql:dbname=%s;host=%s;port=%s", $this->_core->config['DB_DATABASE'], $this->_core->config['DB_SERVER'], $sPort ); try { $PDO = new PDOStub( $DSN, $this->_core->config['DB_USER'], $this->_core->config['DB_PASS'] ); } catch ( PDOException $e ) { $SQLSTATE = $this->get_ANSI_SQLSTATE_Code( $e ); if ( $SQLSTATE == "42000" ) { trigger_error( "Missing database \"".$this->_core->config['DB_DATABASE']."\"", E_USER_ERROR ); } } $PDO->setAttribute( PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, 1024 * 1024 * 50 ); $PDO->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $PDO->setAttribute( PDO::ATTR_PERSISTENT, TRUE ); $PDO->setAttribute( PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY ); $PDO->query( "SET NAMES utf8;" ); $PDO->query( "SET CHARACTER SET utf8;" ); } return $PDO;}
public function sqlite( ) { static $PDO = NULL; if ( !$PDO ) { $DSN = sprintf( "sqlite:%s", $this->_core->config['DB_DATABASE'] ); try { $PDO = new PDOStub( $DSN, $this->_core->config['DB_USER'], $this->_core->config['DB_PASS'] ); $PDO->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); } catch ( PDOException $e ) { $SQLSTATE = $this->get_ANSI_SQLSTATE_Code( $e ); if ( $SQLSTATE == "HY000" ) { trigger_error( "The database file \"".$this->_core->config['DB_DATABASE']."\" could not be found.", E_USER_ERROR ); } } } return $PDO;}
public function getNewID( $PDO, $prefix, $table, $size = 8, $with_dash = TRUE ) { $result = ""; $sPossible = "0123456789BCDFGHJKLMNPQRSTVWXZ"; $i = 1; while ( $i <= $size ) { if ( $with_dash and& $i == 4 ) { $result .= "-"; continue; } $nRand = mt_rand( 0, 29 ); $c = substr( $sPossible, $nRand, 1 ); $result .= $c; ++$i; } $table = strtoupper( $table ); $sDate = gmdate( "Y-m-d H:i:s" ); $sSQL = "INSERT INTO `{$prefix}msys_ids` (`id`, `group`, `dt_created`) VALUES ('{$result}', '{$table}', '{$sDate}');"; try { $PDO->exec( $sSQL ); } catch ( PDOException $e ) { $SQLSTATE = $this->get_ANSI_SQLSTATE_Code( $e ); if ( $SQLSTATE == "42S02" ) { trigger_error( "The \"{$prefix}msys_ids\" table does not exist.", E_USER_ERROR ); } if ( $SQLSTATE == "23000" ) { return $this->getNewID( $PDO, $table, $size, $with_dash ); } trigger_error( "The SQLSTATE ({$SQLSTATE}) error code happened in getNewID() of the Faster_Data class.", E_USER_ERROR ); } return $result;}
public function undoID( $PDO, $prefix, $table, $id ) { $sSQL = "DELETE FROM `{$prefix}msys_ids` WHERE `group` = :group AND `id` = :id"; $st = $PDO->prepare( $sSQL ); $st->bindValue( ":group", $table ); $st->bindValue( ":id", $id ); try { $st->execute( ); } catch ( PDOException $e ) { }}
public function get_ANSI_SQLSTATE_Code( $e ) { $s = $e->__toString( ); $asItems = explode( "[", $s ); $s = @$asItems[1]; $asItems = explode( "]", $s ); $result = @$asItems[0]; return trim( $result ); }
}
class Faster_Date{
public function getDateByInterval( $sDate, $sInterval ) { $dDate = new DateTime( date( $sDate ) ); $dDate->modify( "{$sInterval}" ); return $dDate->format( "Y-m-d H:i:s" ); }
public function getDateDiff( $sStartDate, $sEndDate ) { $asStartDate = date_parse( $sStartDate ); $asEndDate = date_parse( $sEndDate ); $sNewStartDate = gregoriantojd( $asStartDate['month'], $asStartDate['day'], $asStartDate['year'] ); $sNewEndDate = gregoriantojd( $asEndDate['month'], $asEndDate['day'], $asEndDate['year'] ); return round( $sNewEndDate - $sNewStartDate, 0 ); }
public function translateTZ( $sDate, $sOffset ) { $sOffset = str_replace( "+", "", $sOffset ); $sOffset = ( 0 - 1 ) * ( $sOffset / 60 ); if ( $sOffset == 0 ) { return $sDate; } $dDate = new DateTime( $sDate ); $dDate->modify( "{$sOffset} hours" ); $sDate = $dDate->format( "Y-m-d H:i:s" ); return $sDate; }
}
$sDir = dirname( __FILE__ );$sDir = rtrim( $sDir, "/" );$sDir2 = $sDir;$sDir2 = str_replace( "/app", "", $sDir2 );$sPluginDir = basename( $sDir2 );$sDir = str_replace( "wp-content/plugins/".$sPluginDir."/app", "", $sDir );$sDir = rtrim( $sDir, "/" );require_once( $sDir."/wp-blog-header.php" );if ( !defined( "MSYS_JACK_DIR" ) ){ define( "MSYS_JACK_DIR", "members" );}@set_time_limit( 1800 );@ini_set( "memory_limit", "64M" );status_header( 200 );if ( get_magic_quotes_gpc( ) ){ $process = array( $_GET, $_POST, $_COOKIE, $_REQUEST ); do { $val = each( $process )[1]; $key = each( $process )[0]; if ( !each( $process ) ) { break; } else { foreach ( $val as $k => $v ) { unset( $process[$key][$k] ); if ( is_array( $v ) ) { $process[$key][stripslashes( $k )] = $v; $process[] =and $process[$key][stripslashes( $k )]; } else { $process[$key][stripslashes( $k )] = stripslashes( $v ); } } } } while ( 1 ); unset( $process );}@ini_set( "asp_tags", "0" );@ini_set( "auto_detect_line_endings", "1" );@ini_set( "short_open_tag", "On" );$nDays = 1;@ini_set( "session.cookie_lifetime", 0 );@ini_set( "session.gc_maxlifetime", @60 * 60 * 24 * @$nDays );if ( isset( $_SERVER['REDIRECT_QUERY_STRING'] ) ){ $_GET = array( ); $_SERVER['QUERY_STRING'] = $_SERVER['REDIRECT_QUERY_STRING']; parse_str( preg_replace( "/and(\\w+)(and|$)/", "and$1=$2", strtr( $_SERVER['QUERY_STRING'], ";", "and" ) ), $_GET );}$mvc = new Faster( );$mvc->core = new Faster_Core( );$mvc->view = new Faster_View( );$mvc->request = new Faster_Request( );$mvc->model = new Faster_Model( );$mvc->data = new Faster_Data( );$mvc->date = new Faster_Date( );$mvc->view->core = $mvc->core;$mvc->view->_setRequest( $mvc->request );$mvc->request->core = $mvc->core;$mvc->request->view = $mvc->view;$mvc->request->request = $mvc->request;$mvc->request->model = $mvc->model;$mvc->request->data = $mvc->data;$mvc->request->date = $mvc->date;$mvc->model->core = $mvc->core;$mvc->model->view = $mvc->view;$mvc->model->request = $mvc->request;$mvc->model->model = $mvc->model;$mvc->model->data = $mvc->data;$mvc->model->date = $mvc->date;$mvc->data->_setCore( $mvc->core );$mvc->core->_setPageLoadStart( );$sTest = @$argv[1];$bCLI = !empty( $sTest );if ( $bCLI ){ $sPath = $sTest; $sPath = str_replace( "--PATH", "", $sPath ); $sPath = str_replace( "--path", "", $sPath ); $sPath = str_replace( "--", "", $sPath ); $sPath = str_replace( ".php", "", $sPath ); $sPath = str_replace( ".PHP", "", $sPath ); $sPath = str_replace( "=", "", $sPath ); $sPath = str_replace( "\"", "", $sPath ); $sPath = str_replace( "'", "", $sPath ); $sPath = str_replace( "\\", "/", $sPath ); $sPath = str_replace( " ", "", $sPath ); $mvc->request->_setGroup( $mvc->request->polishGroup( $sPath ) ); $mvc->request->_setAction( $mvc->request->polishAction( $sPath ) );}else{ $mvc->request->_setGroup( $mvc->request->getGroup( ) ); $mvc->request->_setAction( $mvc->request->getAction( ) );}try{ $sTimeZone = @$mvc->core->config['TIMEZONE']; $sTimeZone = empty( $sTimeZone ) ? "GMT" : $sTimeZone; if ( function_exists( "date_default_timezone_set" ) ) { date_default_timezone_set( $sTimeZone ); } else { putenv( "TZ=".$sTimeZone ); } @ini_set( "date.timezone", @$sTimeZone );}catch ( Exception $e ){}$sTZ = @$mvc->request->getCookieVar( "TZ" );if ( !empty( $sTZ ) and& !defined( "TIMEZONE" ) ){ define( "TIMEZONE", $sTZ );}if ( !function_exists( "fdebug" ) ){ function fdebug( $sLabel, $o = "" ) { trigger_error( $sLabel."=".str_replace( "\n", "", var_export( $o, TRUE ) ) ); }}$sDisplayErrors = @$mvc->core->config['DISPLAY_ERRORS'];$sDisplayErrors = empty( $sDisplayErrors ) ? "Off" : $sDisplayErrors;@ini_set( "display_errors", @$sDisplayErrors );$sErrReporting = @$mvc->core->config['ERROR_REPORTING'];$sErrReporting = empty( $sErrReporting ) ? E_ALL : $sErrReporting;error_reporting( $sErrReporting );include( "extra.php" );$bStopWhenRouted = TRUE;$mvc->request->dispatchRoute( "", $bStopWhenRouted );if ( !class_exists( "DateTime" ) ){ class DateTime {
public $date;
public function __construct( $date ) { $this->date = strtotime( $date ); }
public function setTimeZone( $timezone ) { try { $timezone = @$mvc->core->config['TIMEZONE']; $timezone = empty( $timezone ) ? "GMT" : $timezone; if ( function_exists( "date_default_timezone_set" ) ) { date_default_timezone_set( $timezone ); } else { putenv( "TZ=".$timezone ); } @ini_set( "date.timezone", @$timezone ); } catch ( Exception $e ) { }}
private function __getDate( ) { return date( DATE_ATOM, $this->date ); }
public function modify( $modifier ) { $this->date = strtotime( $this->__getDate( )." ".$modifier ); }
public function format( $format ) { return date( $format, $this->date ); }
}
}?>