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";
35 if (isset($aClassPaths[$sClass])) {
36 stopProfile(
"oxAutoload");
37 include $aClassPaths[$sClass];
42 $sBasePath = getShopBasePath();
46 if ($aClassDirs == null) {
50 foreach ($aClassDirs as $sDir) {
51 $sFilename = $sDir . $sClass .
'.php';
52 if (file_exists($sFilename)) {
53 if (!isset($aClassPaths[$sClass])) {
54 $aClassPaths[$sClass] = $sFilename;
56 stopProfile(
"oxAutoload");
67 if (is_array($aModuleFiles)) {
68 $sBasePath = getShopBasePath();
69 $oModulelist =
oxNew(
'oxmodulelist');
70 $aActiveModuleInfo = $oModulelist->getActiveModuleInfo();
71 if (is_array($aActiveModuleInfo)) {
72 foreach ($aModuleFiles as $sModuleId => $aModules) {
73 if (isset($aModules[$sClass]) && isset($aActiveModuleInfo[$sModuleId])) {
74 $sPath = $aModules[$sClass];
75 $sFilename = $sBasePath .
'modules/' . $sPath;
76 if (file_exists($sFilename)) {
77 if (!isset($aClassPaths[$sClass])) {
78 $aClassPaths[$sClass] = $sFilename;
80 stopProfile(
"oxAutoload");
91 $sClass = preg_replace(
'/_parent$/i',
'', $sClass);
97 foreach ($aModules as $sParentName => $sModuleName) {
99 if (preg_match(
'/\b' . $sClass .
'($|\&)/i', $sModuleName)) {
100 $myUtilsObject->getClassName($sParentName);
103 $aTriedClasses[] = $sClass;
107 stopProfile(
"oxAutoload");
119 $aClassDirs = array($sBasePath .
'core/',
120 $sBasePath .
'application/components/widgets/',
121 $sBasePath .
'application/components/services/',
122 $sBasePath .
'application/components/',
123 $sBasePath .
'application/models/',
124 $sBasePath .
'application/controllers/',
125 $sBasePath .
'application/controllers/admin/',
126 $sBasePath .
'application/controllers/admin/reports/',
127 $sBasePath .
'views/',
128 $sBasePath .
'core/exception/',
129 $sBasePath .
'core/interface/',
130 $sBasePath .
'core/cache/',
131 $sBasePath .
'core/cache/connectors/',
132 $sBasePath .
'core/wysiwigpro/',
133 $sBasePath .
'admin/reports/',
134 $sBasePath .
'admin/',
135 $sBasePath .
'modules/',
143 if (!function_exists(
'getShopBasePath')) {
149 function getShopBasePath()
162 if (defined(
'OX_IS_ADMIN')) {
177 ini_set(
'session.name',
'sid');
178 ini_set(
'session.use_cookies', 0);
179 ini_set(
'session.use_trans_sid', 0);
180 ini_set(
'url_rewriter.tags',
'');
183 if (!function_exists(
'error_404_handler')) {
191 function error_404_handler($sUrl =
'')
208 echo
"<div class='error_box'>" .
oxRegistry::getLang()->translateString(
'userError') .
"<code>[$iErrorNr] $sErrorText</code></div>";
221 $out = var_export($mVar,
true);
222 $f = fopen(
$myConfig->getConfigParam(
'sCompileDir') .
"/vardump.txt",
"a");
232 if (!function_exists(
'isSearchEngineUrl')) {
252 $f = fopen(
'out.txt',
'a');
253 $sString = var_export($mVar,
true);
254 fputs($f, $sString .
"\n---------------------------------------------\n");
269 if ($a->cnt == $b->cnt) {
273 return ($a->cnt < $b->cnt) ? -1 : 1;
276 if (!function_exists(
'startProfile')) {
282 function startProfile($sProfileName)
285 global $aExecutionCounts;
286 if (!isset($aExecutionCounts[$sProfileName])) {
287 $aExecutionCounts[$sProfileName] = 0;
289 if (!isset($aStartTimes[$sProfileName])) {
290 $aStartTimes[$sProfileName] = 0;
292 $aExecutionCounts[$sProfileName]++;
293 $aStartTimes[$sProfileName] = microtime(
true);
297 if (!function_exists(
'stopProfile')) {
303 function stopProfile($sProfileName)
305 global $aProfileTimes;
307 if (!isset($aProfileTimes[$sProfileName])) {
308 $aProfileTimes[$sProfileName] = 0;
310 $aProfileTimes[$sProfileName] += microtime(
true) - $aStartTimes[$sProfileName];
326 startProfile(
'oxNew');
327 $aArgs = func_get_args();
329 stopProfile(
'oxNew');
367 $sTplSource = $oSmarty->oxidcache->value;
369 $oSmarty->security =
true;
386 if (isset($oSmarty->oxidtimecache->value)) {
388 $iTplTimestamp = $oSmarty->oxidtimecache->value;
391 $iTplTimestamp = time();
423 if (!function_exists(
'getLangTableIdx')) {
432 function getLangTableIdx($iLangId)
436 $iLangPerTable = ($iLangPerTable > 1) ? $iLangPerTable : 8;
438 $iTableIdx = (int) ($iLangId / $iLangPerTable);
444 if (!function_exists(
'getLangTableName')) {
454 function getLangTableName($sTable, $iLangId)
456 $iTableIdx = getLangTableIdx($iLangId);
459 $sLangTableSuffix = $sLangTableSuffix ? $sLangTableSuffix :
"_set";
461 $sTable .= $sLangTableSuffix . $iTableIdx;
468 if (!function_exists(
'getViewName')) {
479 function getViewName($sTable, $iLangId = null, $sShopId = null)
485 if (!
$myConfig->getConfigParam(
'blSkipViewUsage')) {
490 if ($iLangId != -1 && $blIsMultiLang) {
493 $sAbbr = $oLang->getLanguageAbbr($iLangId);
494 $sViewSfx .=
"_{$sAbbr}";
497 if ($sViewSfx || (($iLangId == -1 || $sShopId == -1) && $blIsMultiLang)) {
498 return "oxv_{$sTable}{$sViewSfx}";
507 if (!function_exists(
'getRequestUrl')) {
516 function getRequestUrl($sParams =
'', $blReturnUrl =
false)
518 if ($_SERVER[
"REQUEST_METHOD"] !=
"POST") {
520 if (isset($_SERVER[
'REQUEST_URI']) && $_SERVER[
'REQUEST_URI']) {
521 $sRequest = $_SERVER[
'REQUEST_URI'];
524 $sRequest = $_SERVER[
'SCRIPT_URI'];
528 if ($sRequest && ($iPos = stripos($sRequest,
'?')) !==
false) {
532 $sRequest =
'index.php' . $oStr->substr($sRequest, $iPos);
535 $sRequest = $oStr->preg_replace(
'/(&|\?)(force_)?(admin_)?sid=[^&]*&?/',
'$1', $sRequest);
536 $sRequest = $oStr->preg_replace(
'/(&|\?)stoken=[^&]*&?/',
'$1', $sRequest);
537 $sRequest = $oStr->preg_replace(
'/&$/',
'', $sRequest);
539 return str_replace(
'&',
'&', $sRequest);
546 spl_autoload_register(
"oxAutoload");