12 startProfile(
"oxAutoload");
13 $sClass = basename( $sClass );
14 $sClass = strtolower($sClass);
16 static $sBasePath = null;
17 static $aClassDirs = null;
20 static $aTriedClasses = array();
24 $sBaseClassLocation = null;
25 $aBaseClasses = array(
"oxutils",
"oxsupercfg",
"oxutilsobject");
26 if (in_array($sClass, $aBaseClasses)) {
27 $sFilename = getShopBasePath() .
"core/" . $sClass .
".php" ;
34 if (isset($aClassPaths[$sClass])) {
35 stopProfile(
"oxAutoload");
36 include $aClassPaths[$sClass];
40 $sBasePath = getShopBasePath();
44 if ( $aClassDirs == null ) {
48 foreach ( $aClassDirs as $sDir ) {
49 $sFilename = $sDir . $sClass .
'.php';
50 if ( file_exists( $sFilename ) ) {
51 if (!isset($aClassPaths[$sClass])) {
52 $aClassPaths[$sClass] = $sFilename;
55 stopProfile(
"oxAutoload");
66 if ( is_array( $aModuleFiles ) ) {
67 $sBasePath = getShopBasePath();
68 $oModulelist =
oxNew(
'oxmodulelist');
69 $aActiveModuleInfo = $oModulelist->getActiveModuleInfo();
70 if (is_array($aActiveModuleInfo)) {
71 foreach ($aModuleFiles as $sModuleId => $aModules) {
72 if (isset($aModules[$sClass]) && isset($aActiveModuleInfo[$sModuleId])) {
73 $sPath = $aModules[$sClass];
74 $sFilename = $sBasePath.
'modules/'. $sPath;
75 if ( file_exists( $sFilename ) ) {
76 if (!isset($aClassPaths[$sClass])) {
77 $aClassPaths[$sClass] = $sFilename;
80 stopProfile(
"oxAutoload");
90 $sClass = preg_replace(
'/_parent$/i',
'', $sClass );
93 if ( !in_array( $sClass, $aTriedClasses ) && is_array( $aModules =
oxUtilsObject::getInstance()->getModuleVar(
'aModules' ) ) ) {
96 foreach ( $aModules as $sParentName => $sModuleName ) {
98 if ( preg_match(
'/\b'.$sClass.
'($|\&)/i', $sModuleName ) ) {
99 $myUtilsObject->getClassName( $sParentName );
102 $aTriedClasses[] = $sClass;
106 stopProfile(
"oxAutoload");
118 $aClassDirs = array( $sBasePath .
'core/',
119 $sBasePath .
'application/components/widgets/',
120 $sBasePath .
'application/components/',
121 $sBasePath .
'application/models/',
122 $sBasePath .
'application/controllers/',
123 $sBasePath .
'application/controllers/admin/',
124 $sBasePath .
'application/controllers/admin/reports/',
125 $sBasePath .
'views/',
126 $sBasePath .
'core/exception/',
127 $sBasePath .
'core/interface/',
128 $sBasePath .
'core/cache/',
129 $sBasePath .
'core/cache/connectors/',
130 $sBasePath .
'core/wysiwigpro/',
131 $sBasePath .
'admin/reports/',
132 $sBasePath .
'admin/',
133 $sBasePath .
'modules/',
140 if ( !function_exists(
'getShopBasePath' ) ) {
146 function getShopBasePath()
159 if (defined(
'OX_IS_ADMIN')) {
174 ini_set(
'session.name',
'sid');
175 ini_set(
'session.use_cookies', 0);
176 ini_set(
'session.use_trans_sid', 0);
177 ini_set(
'url_rewriter.tags',
'');
178 ini_set(
'magic_quotes_runtime', 0);
188 if (!get_magic_quotes_gpc()) {
206 return is_array($mInput) ? array_map(
'_stripMagicQuotes', $mInput ) : stripslashes( $mInput );
209 if ( !function_exists(
'error_404_handler' ) ) {
217 function error_404_handler($sUrl =
'')
236 echo
"<div class='error_box'>".oxRegistry::getLang()->translateString(
'userError').
"<code>[$iErrorNr] $sErrorText</code></div>";
251 $out = var_export( $mVar,
true );
252 $f = fopen(
$myConfig->getConfigParam(
'sCompileDir' ).
"/vardump.txt",
"a" );
262 if ( !function_exists(
'isSearchEngineUrl' ) ) {
284 $f = fopen(
'out.txt',
'a' );
285 $sString = var_export( $mVar,
true );
286 fputs( $f, $sString.
"\n---------------------------------------------\n" );
301 if ( $a->cnt == $b->cnt )
303 return ( $a->cnt < $b->cnt ) ? -1 : 1;
306 if ( !function_exists(
'startProfile' ) ) {
314 function startProfile( $sProfileName )
317 global $aExecutionCounts;
318 if (!isset($aExecutionCounts[$sProfileName])) {
319 $aExecutionCounts[$sProfileName] = 0;
321 if (!isset($aStartTimes[$sProfileName])) {
322 $aStartTimes[$sProfileName] = 0;
324 $aExecutionCounts[$sProfileName]++;
325 $aStartTimes[$sProfileName] = microtime(
true);
329 if ( !function_exists(
'stopProfile' ) ) {
337 function stopProfile( $sProfileName )
339 global $aProfileTimes;
341 if (!isset($aProfileTimes[$sProfileName])) {
342 $aProfileTimes[$sProfileName] = 0;
344 $aProfileTimes[$sProfileName] += microtime(
true ) - $aStartTimes[$sProfileName];
360 startProfile(
'oxNew' );
361 $aArgs = func_get_args();
363 stopProfile(
'oxNew' );
414 $sTplSource = $oSmarty->oxidcache->value;
416 $oSmarty->security =
true;
433 if ( isset( $oSmarty->oxidtimecache->value ) ) {
435 $iTplTimestamp = $oSmarty->oxidtimecache->value;
438 $iTplTimestamp = time();
472 if ( !function_exists(
'getLangTableIdx' ) ) {
481 function getLangTableIdx( $iLangId )
485 $iLangPerTable = ( $iLangPerTable > 1 ) ? $iLangPerTable : 8;
487 $iTableIdx = (int) ( $iLangId / $iLangPerTable );
492 if ( !function_exists(
'getLangTableName' ) ) {
502 function getLangTableName( $sTable, $iLangId )
504 $iTableIdx = getLangTableIdx( $iLangId );
507 $sLangTableSuffix = $sLangTableSuffix ? $sLangTableSuffix :
"_set";
509 $sTable .= $sLangTableSuffix . $iTableIdx;
516 if ( !function_exists(
'getViewName' ) ) {
527 function getViewName( $sTable, $iLangId = null, $sShopId = null )
533 if ( !
$myConfig->getConfigParam(
'blSkipViewUsage' ) ) {
538 if ( $iLangId != -1 && $blIsMultiLang ) {
541 $sAbbr = $oLang->getLanguageAbbr( $iLangId );
542 $sViewSfx .=
"_{$sAbbr}";
545 if ( $sViewSfx || (($iLangId == -1 || $sShopId == -1 ) && $blIsMultiLang)) {
546 return "oxv_{$sTable}{$sViewSfx}";
555 if ( !function_exists(
'getRequestUrl' ) ) {
564 function getRequestUrl( $sParams =
'', $blReturnUrl =
false )
566 if ($_SERVER[
"REQUEST_METHOD"] !=
"POST" ) {
568 if ( isset( $_SERVER[
'REQUEST_URI'] ) && $_SERVER[
'REQUEST_URI'] ) {
569 $sRequest = $_SERVER[
'REQUEST_URI'];
572 $sRequest = $_SERVER[
'SCRIPT_URI'];
576 if ( $sRequest && ( $iPos = stripos( $sRequest,
'?' ) ) !==
false ) {
580 $sRequest =
'index.php' . $oStr->substr( $sRequest, $iPos );
583 $sRequest = $oStr->preg_replace(
'/(&|\?)(force_)?(admin_)?sid=[^&]*&?/',
'$1', $sRequest );
584 $sRequest = $oStr->preg_replace(
'/(&|\?)stoken=[^&]*&?/',
'$1', $sRequest );
585 $sRequest = $oStr->preg_replace(
'/&$/',
'', $sRequest );
586 return str_replace(
'&',
'&', $sRequest );
593 spl_autoload_register(
"oxAutoload");