Go to the documentation of this file.00001 <?php
00002
00010 function oxAutoload( $sClass )
00011 {
00012 startProfile("oxAutoload");
00013 $sClass = basename( $sClass );
00014 $sClass = strtolower($sClass);
00015
00016 static $sBasePath = null;
00017 static $aClassDirs = null;
00018
00019
00020 static $aTriedClasses = array();
00021
00022
00023
00024 $sBaseClassLocation = null;
00025 $aBaseClasses = array("oxutils", "oxsupercfg", "oxutilsobject", "oxconfig");
00026 if (in_array($sClass, $aBaseClasses)) {
00027 $sFilename = getShopBasePath() ."core/" . $sClass . ".php" ;
00028 include $sFilename;
00029 return;
00030 }
00031
00032 static $aClassPaths;
00033
00034 if (!$aClassPaths) {
00035 $aClassPaths = oxUtils::getInstance()->fromPhpFileCache("class_file_paths");
00036 }
00037
00038 if (isset($aClassPaths[$sClass])) {
00039 stopProfile("oxAutoload");
00040 include $aClassPaths[$sClass];
00041 return;
00042 }
00043
00044
00045 if ( $aClassDirs == null ) {
00046 $sBasePath = getShopBasePath();
00047 $aClassDirs = array( $sBasePath . 'core/',
00048 $sBasePath . 'views/',
00049 $sBasePath . 'core/exception/',
00050 $sBasePath . 'core/interface/',
00051 $sBasePath . 'admin/reports/',
00052 $sBasePath . 'admin/',
00053 $sBasePath . 'modules/',
00054 $sBasePath
00055 );
00056 }
00057
00058 foreach ( $aClassDirs as $sDir ) {
00059 $sFilename = $sDir . $sClass . '.php';
00060 if ( file_exists( $sFilename ) ) {
00061 if (!isset($aClassPaths[$sClass])) {
00062 $aClassPaths[$sClass] = $sFilename;
00063 oxUtils::getInstance()->toPhpFileCache("class_file_paths", $aClassPaths);
00064 }
00065 stopProfile("oxAutoload");
00066 include $sFilename;
00067 return;
00068 }
00069 }
00070
00071
00072 $sClass = preg_replace( '/_parent$/i', '', $sClass );
00073
00074
00075 if ( !in_array( $sClass, $aTriedClasses ) && is_array( $aModules = oxConfig::getInstance()->getConfigParam( 'aModules' ) ) ) {
00076
00077 $myUtilsObject = oxUtilsObject::getInstance();
00078 foreach ( $aModules as $sParentName => $sModuleName ) {
00079
00080 if ( stripos( $sModuleName, $sClass ) !== false ) {
00081 $myUtilsObject->getClassName( $sParentName );
00082 break;
00083 }
00084 }
00085 $aTriedClasses[] = $sClass;
00086 }
00087
00088 stopProfile("oxAutoload");
00089 }
00090
00091 if ( !function_exists( 'error_404_handler' ) ) {
00099 function error_404_handler($sUrl = '')
00100 {
00101 oxUtils::getInstance()->handlePageNotFoundError($sUrl);
00102 }
00103 }
00104
00116 function warningHandler($iErrorNr, $sErrorText)
00117 {
00118 echo "<div class='error_box'>".oxLang::getInstance()->translateString('userError')."<code>[$iErrorNr] $sErrorText</code></div>";
00119 }
00120
00129 function dumpVar( $mVar, $blToFile = false )
00130 {
00131 $myConfig = oxConfig::getInstance();
00132 if ( $blToFile ) {
00133 $out = var_export( $mVar, true );
00134 $f = fopen( $myConfig->getConfigParam( 'sCompileDir' )."/vardump.txt", "a" );
00135 fwrite( $f, $out );
00136 fclose( $f );
00137 } else {
00138 echo '<pre>';
00139 print_r( $mVar );
00140 echo '</pre>';
00141 }
00142 }
00143
00144 if ( !function_exists( 'isAdmin' ) ) {
00152 function isAdmin()
00153 {
00154
00155 if ( class_exists( 'oxConfig', false ) ) {
00156 $blAdmin = oxConfig::getInstance()->getConfigParam( 'blAdmin' );
00157 if ( isset( $blAdmin ) ) {
00158 stopProfile('isAdmin');
00159 return $blAdmin;
00160 }
00161 }
00162 return false;
00163 }
00164 }
00165
00166 if ( !function_exists( 'isSearchEngineUrl' ) ) {
00167
00173 function isSearchEngineUrl()
00174 {
00175 return false;
00176 }
00177 }
00178
00186 function debug( $mVar )
00187 {
00188 $f = fopen( 'out.txt', 'a' );
00189 $sString = var_export( $mVar, true );
00190 fputs( $f, $sString."\n---------------------------------------------\n" );
00191 fclose( $f );
00192 }
00193
00202 function cmpart( $a, $b )
00203 {
00204
00205 if ( $a->cnt == $b->cnt )
00206 return 0;
00207 return ( $a->cnt < $b->cnt ) ? -1 : 1;
00208 }
00209
00217 function startProfile( $sProfileName )
00218 {
00219 global $aStartTimes;
00220 global $aExecutionCounts;
00221 if (!isset($aExecutionCounts[$sProfileName])) {
00222 $aExecutionCounts[$sProfileName] = 0;
00223 }
00224 if (!isset($aStartTimes[$sProfileName])) {
00225 $aStartTimes[$sProfileName] = 0;
00226 }
00227 $aExecutionCounts[$sProfileName]++;
00228 $aStartTimes[$sProfileName] = microtime(true);
00229 }
00230
00238 function stopProfile( $sProfileName )
00239 {
00240 global $aProfileTimes;
00241 global $aStartTimes;
00242 if (!isset($aProfileTimes[$sProfileName])) {
00243 $aProfileTimes[$sProfileName] = 0;
00244 }
00245 $aProfileTimes[$sProfileName] += microtime( true ) - $aStartTimes[$sProfileName];
00246 }
00247
00258 function oxNew( $sClassName )
00259 {
00260 startProfile( 'oxNew' );
00261 $aArgs = func_get_args();
00262 $oRes = call_user_func_array( array( oxUtilsObject::getInstance(), "oxNew" ), $aArgs );
00263 stopProfile( 'oxNew' );
00264 return $oRes;
00265 }
00266
00274 function oxNewArticle( $sArtId )
00275 {
00276 return oxUtilsObject::getInstance()->oxNewArticle( $sArtId );
00277 }
00278
00286 function getDb($blAssoc = true)
00287 {
00288 return oxDb::getDb($blAssoc);
00289 }
00290
00296 function getStr()
00297 {
00298 return oxStr::getStr();
00299 }
00300
00310 function ox_get_template( $sTplName, &$sTplSource, $oSmarty )
00311 {
00312 $sTplSource = $oSmarty->oxidcache->value;
00313 if ( oxConfig::getInstance()->isDemoShop() ) {
00314 $oSmarty->security = true;
00315 }
00316
00317 return true;
00318 }
00319
00329 function ox_get_timestamp( $sTplName, &$iTplTimestamp, $oSmarty )
00330 {
00331 if ( isset( $oSmarty->oxidtimecache->value ) ) {
00332
00333 $iTplTimestamp = $oSmarty->oxidtimecache->value;
00334 } else {
00335
00336 $iTplTimestamp = time();
00337 }
00338
00339 return true;
00340 }
00341
00350 function ox_get_secure( $sTplName, $oSmarty )
00351 {
00352
00353 return true;
00354 }
00355
00364 function ox_get_trusted( $sTplName, $oSmarty )
00365 {
00366
00367 }
00368
00369 if ( !function_exists( 'getViewName' ) ) {
00370
00379 function getViewName( $sTable, $sShopId = null )
00380 {
00381
00382 return $sTable;
00383 }
00384 }
00385
00386 if ( !function_exists( 'getRequestUrl' ) ) {
00395 function getRequestUrl( $sParams = '', $blReturnUrl = false )
00396 {
00397 if ($_SERVER["REQUEST_METHOD"] != "POST" ) {
00398
00399 if ( isset( $_SERVER['REQUEST_URI'] ) && $_SERVER['REQUEST_URI'] ) {
00400 $sRequest = $_SERVER['REQUEST_URI'];
00401 } else {
00402
00403 $sRequest = $_SERVER['SCRIPT_URI'];
00404 }
00405
00406
00407 if ( $sRequest && ( $iPos = stripos( $sRequest, '?' ) ) !== false ) {
00408
00409 $oStr = getStr();
00410
00411 $sRequest = 'index.php' . $oStr->substr( $sRequest, $iPos );
00412
00413
00414 $sRequest = $oStr->preg_replace( '/(&|\?){1}sid=[^&]*&?/', '$1', $sRequest );
00415 $sRequest = $oStr->preg_replace( '/&$/', '', $sRequest );
00416 return str_replace( '&', '&', $sRequest );
00417 }
00418 }
00419 }
00420 }
00421
00422
00423 spl_autoload_register("oxAutoload");
00424
00425
00426 oxUtils::getInstance()->stripGpcMagicQuotes();