parse_template($tplfile, IN_TEMPLAYE, $tpldir, $name, $cachefile); //} return $objfile; } function template_storage($name) { global $_SCONFIG, $_SGLOBAL, $_SC; if (strexists($name, '/')) { $tpl = $name; } else { $tpl = "template/".IN_TEMPLAYE."/$name"; } $objfile = IN_ROOT . 'data/tpl_cache/' . str_replace('/', '_', $tpl) . '.php'; $domain = ""; if ($_SCONFIG['ismemcache'] && $_SGLOBAL['mc']) $templatemmc = memcache_get($_SGLOBAL['mc'], $tpl); if (empty($templatemmc)) { include_once(IN_ROOT . 'source/system/function_template.php'); $templatemmc = parse_template($tpl); } } function strexists($haystack, $needle) { return !(strpos($haystack, $needle) === FALSE); } function sreadfile($filename) { $content = ''; if (function_exists('file_get_contents')) { @$content = file_get_contents($filename); } else { if (@$fp = fopen($filename, 'r')) { @$content = fread($fp, filesize($filename)); @fclose($fp); } } return $content; } function swritefile($filename, $writetext, $openmod = 'w') { if (@$fp = fopen($filename, $openmod)) { flock($fp, 2); fwrite($fp, $writetext); fclose($fp); return true; } else { runlog('error', "File: $filename write error."); return false; } } function runlog($file, $log, $halt = 0) { global $_SGLOBAL, $_SERVER; $nowurl = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']); $log = sgmdate('Y-m-d H:i:s', $_SGLOBAL['timestamp']) . "\t$type\t" . getonlineip() . "\t$_SGLOBAL[supe_uid]\t{$nowurl}\t" . str_replace(array( "\r", "\n" ), array( ' ', ' ' ), trim($log)) . "\n"; $yearmonth = sgmdate('Ym', $_SGLOBAL['timestamp']); $logdir = './data/log/'; if (!is_dir($logdir)) mkdir($logdir, 0777); $logfile = $logdir . $yearmonth . '_' . $file . '.php'; if (@filesize($logfile) > 2048000) { $dir = opendir($logdir); $length = strlen($file); $maxid = $id = 0; while ($entry = readdir($dir)) { if (strexists($entry, $yearmonth . '_' . $file)) { $id = intval(substr($entry, $length + 8, -4)); $id > $maxid && $maxid = $id; } } closedir($dir); $logfilebak = $logdir . $yearmonth . '_' . $file . '_' . ($maxid + 1) . '.php'; @rename($logfile, $logfilebak); } if ($fp = @fopen($logfile, 'a')) { @flock($fp, 2); fwrite($fp, "