/**
  * @brief 주어진 tpl파일의 컴파일
  **/
 function compile($tpl_path, $tpl_filename, $tpl_file = '')
 {
     // 디버그를 위한 컴파일 시작 시간 저장
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     // 변수 체크
     if (substr($tpl_path, -1) != '/') {
         $tpl_path .= '/';
     }
     if (substr($tpl_filename, -5) != '.html') {
         $tpl_filename .= '.html';
     }
     // tpl_file 변수 생성
     if (!$tpl_file) {
         $tpl_file = $tpl_path . $tpl_filename;
     }
     // tpl_file이 비어 있거나 해당 파일이 없으면 return
     if (!$tpl_file || !file_exists(FileHandler::getRealPath($tpl_file))) {
         return;
     }
     $this->tpl_path = preg_replace('/^\\.\\//', '', $tpl_path);
     $this->tpl_file = $tpl_file;
     // compiled된(or 될) 파일이름을 구함
     $compiled_tpl_file = FileHandler::getRealPath($this->_getCompiledFileName($tpl_file));
     // 일단 컴파일
     $buff = $this->_compile($tpl_file, $compiled_tpl_file);
     // Context와 compiled_tpl_file로 컨텐츠 생성
     $output = $this->_fetch($compiled_tpl_file, $buff, $tpl_path);
     if (__DEBUG__ == 3) {
         $GLOBALS['__template_elapsed__'] += getMicroTime() - $start;
     }
     return $output;
 }
示例#2
0
function printHTMLfooter($scriptName, $startTime)
{
    $endTime = getMicroTime();
    $totalTime = $endTime - $startTime;
    printf("<br><hr>RUBBoS (C) Rice University/INRIA<br><i>Page generated by {$scriptName} in %.3f seconds</i><br>\n", $totalTime);
    print "</body>\n";
    print "</html>\n";
}
示例#3
0
 public function view($fileName, $context = array())
 {
     $filePath = null;
     $cached = false;
     $fileSource = $this->getTemplateFile($fileName, $filePath);
     $filePath = str_replace(ROOT, '', $filePath);
     // Process plugins hook.
     // It is DI for Plugins::intercept() method.
     if (!empty($this->loader->pluginsCallback) && is_callable($this->loader->pluginsCallback)) {
         $fileSource = call_user_func($this->loader->pluginsCallback, 'before_view', $fileSource);
     }
     $start = getMicroTime();
     $data = $this->parseTemplate($fileSource, $context, $filePath, $cached);
     $took = getMicroTime($start);
     call_user_func($this->loader->debugCallback, array('Templates', 'Compile time', 'Cached'), array($filePath, $took, $cached ? 'From cache' : 'Compiled'));
     return $data;
 }
示例#4
0
function tf($page, &$startTime, &$endTime)
{
    global $xcludeContent;
    //The new parser strips all \r and lets \n do all the line break work
    $syntax = $page['data'];
    $syntax = str_replace("\r", '', $syntax);
    // Determine the page syntax type
    $is_html = isset($page['is_html']) ? $page['is_html'] == 1 : false;
    $parser = new JisonParser_Wiki_Handler();
    $WysiwygParser = new JisonParser_WikiCKEditor_Handler();
    $parserHtmlToWiki = new JisonParser_Html_Handler();
    // Parse
    $startTime = getMicroTime();
    if (!$is_html) {
        $wikiSyntax = $syntax;
        $html = $WysiwygParser->parse($wikiSyntax);
        $wiki = $parserHtmlToWiki->parse($html);
    } else {
        $htmlSyntax = $syntax;
        $wikiSyntax = $parserHtmlToWiki->parse($htmlSyntax);
        $html = $WysiwygParser->parse($wikiSyntax);
        $wiki = $parserHtmlToWiki->parse($html);
    }
    $endTime = getMicroTime();
    $success = $wikiSyntax == $wiki;
    if ($success == false && !$xcludeContent) {
        echo "\n";
        echo '"' . $wikiSyntax . '"';
        echo "\n---------------------" . mb_detect_encoding($wikiSyntax) . "-------------------------\n";
        echo $html;
        echo "\n----------------------------------------------\n";
        echo '"' . $wiki . '"';
        echo "\n----------------------" . mb_detect_encoding($wiki) . "------------------------\n";
    }
    echo $success ? "\tSUCCESS" : "\tFAILURE";
    unset($parser);
    unset($WysiwygParser);
    unset($parserHtmlToWiki);
    unset($html);
    return $success;
}
示例#5
0
 /**
  * @brief xml 파싱
  **/
 function parse($input = '')
 {
     // 디버그를 위한 컴파일 시작 시간 저장
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     $this->lang = Context::getLangType();
     $this->input = $input ? $input : $GLOBALS['HTTP_RAW_POST_DATA'];
     // 지원언어 종류를 뽑음
     preg_match_all("/xml:lang=\"([^\"].+)\"/i", $this->input, $matches);
     // xml:lang이 쓰였을 경우 지원하는 언어종류를 뽑음
     if (count($matches[1]) && ($supported_lang = array_unique($matches[1]))) {
         // supported_lang에 현재 접속자의 lang이 없으면 en이 있는지 확인하여 en이 있으면 en을 기본, 아니면 첫번째것을..
         if (!in_array($this->lang, $supported_lang)) {
             if (in_array('en', $supported_lang)) {
                 $this->lang = 'en';
             } else {
                 $this->lang = array_shift($supported_lang);
             }
         }
         // 특별한 언어가 지정되지 않았다면 언어체크를 하지 않음
     } else {
         unset($this->lang);
     }
     $this->oParser = xml_parser_create('UTF-8');
     xml_set_object($this->oParser, $this);
     xml_set_element_handler($this->oParser, "_tagOpen", "_tagClosed");
     xml_set_character_data_handler($this->oParser, "_tagBody");
     xml_parse($this->oParser, $this->input);
     xml_parser_free($this->oParser);
     if (!count($this->output)) {
         return;
     }
     $output = array_shift($this->output);
     // 디버그를 위한 컴파일 시작 시간 저장
     if (__DEBUG__ == 3) {
         $GLOBALS['__xmlparse_elapsed__'] += getMicroTime() - $start;
     }
     return $output;
 }
示例#6
0
	function output_page ( )
	{
		global $abs, $tpl, $pageTmr, $sql, $_CACHE;

		$tpl->gotoBlock ( "_ROOT" );

		# Timers
		$totalTime = getMicroTime ( ) - $pageTmr;

		$sqlTime = $sql->getSqlTime ( );
		$phpTime = $totalTime - $sqlTime;

		$tpl->assign ( array (
			"totTmr" => round ( $totalTime, 4 ),
			"phpTmr" => round ( $phpTime, 4 ),
			"sqlTmr" => round ( $sqlTime, 4 ),

			"dag" => date ( "d" ),
			"maand" => date ( "m" ),
			"jaar" => date ( "y" )
		) );

		if ( false )
		{

			# Cache deze pagina
			$html = $tpl->getOutputContent ( );
			$file = $abs . "cache/" . $_CACHE['file_hash'] . ".txt";

			$handle = fopen ( $file, 'w' );
			fwrite ( $handle, $html );
			fclose ( $handle );

		}


		$tpl->printToScreen ( );
	}
示例#7
0
function display_follow_up($cid, $level, $display, $filter, $link, $comment_table)
{
    $follow = mysql_query("SELECT story_id,id,subject,writer,date FROM {$comment_table} WHERE parent={$cid}", $link) or die("ERROR: Query failed");
    while ($follow_row = mysql_fetch_array($follow)) {
        for ($i = 0; $i < $level; $i++) {
            printf("&nbsp&nbsp&nbsp");
        }
        print "<a href=\"ViewComment.php?comment_table={$comment_table}&storyId=" . $follow_row["story_id"] . "&commentId=" . $follow_row["id"] . "&filter={$filter}&display={$display}\">" . $follow_row["subject"] . "</a> by " . getUserName($follow_row["writer"], $link) . " on " . $follow_row["date"] . "<br>\n";
        if ($follow_row["childs"] > 0) {
            display_follow_up($follow_row["id"], $level + 1, $display, $filter, $link, $comment_table);
        }
    }
}
$scriptName = "ViewStory.php";
include "PHPprinter.php";
$startTime = getMicroTime();
// Check parameters
$storyId = $HTTP_POST_VARS['storyId'];
if ($storyId == null) {
    $storyId = $HTTP_GET_VARS['storyId'];
    if ($storyId == null) {
        printError($scriptName, $startTime, "Viewing story", "You must provide a story identifier!<br>");
        exit;
    }
}
getDatabaseLink($link);
$result = mysql_query("SELECT * FROM stories WHERE id={$storyId}") or die("ERROR: Query failed");
if (mysql_num_rows($result) == 0) {
    $result = mysql_query("SELECT * FROM old_stories WHERE id={$storyId}") or die("ERROR: Query failed");
    $comment_table = "old_comments";
} else {
示例#8
0
        die;
    }
}
$page_title = $VAR['page_title'];
$auth = new Auth($db, 'login.php', 'secret');
require INCLUDE_URL . SEP . 'acl.php';
require 'modules/core/translate.php';
############################
#		Debuging					#
############################
function getMicroTime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
$start = getMicroTime();
// If log off is set then we log off
if (isset($VAR['action']) && $VAR['action'] == 'logout') {
    $auth->logout('login.php');
}
/* get company info for defaults */
$q = 'SELECT * FROM ' . PRFX . 'TABLE_COMPANY, ' . PRFX . 'VERSION ORDER BY  ' . PRFX . 'VERSION.`VERSION_INSTALLED` DESC LIMIT 1';
if (!($rs = $db->execute($q))) {
    force_page('core', 'error&error_msg=MySQL Error: ' . $db->ErrorMsg() . '&menu=1&type=database');
    exit;
}
$smarty->assign('version', $rs->fields['VERSION_NAME']);
$smarty->assign('company_name', $rs->fields['COMPANY_NAME']);
$smarty->assign('company_address', $rs->fields['COMPANY_ADDRESS']);
$smarty->assign('company_city', $rs->fields['COMPANY_CITY']);
$smarty->assign('company_state', $rs->fields['COMPANY_STATE']);
示例#9
0
 /**
  * Finish recording DBClass log
  * @return void
  */
 function actDBClassFinish()
 {
     if (!$this->query) {
         return;
     }
     $this->act_dbclass_finish = getMicroTime();
     $elapsed_dbclass_time = $this->act_dbclass_finish - $this->act_dbclass_start;
     $this->elapsed_dbclass_time = $elapsed_dbclass_time;
     $GLOBALS['__dbclass_elapsed_time__'] += $elapsed_dbclass_time;
 }
示例#10
0
 /**
  * Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
  * This method only functions when __DEBUG__ variable is set to 1.
  * __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
  * @return void
  */
 function _debugOutput()
 {
     if (!__DEBUG__) {
         return;
     }
     $end = getMicroTime();
     // Firebug console output
     if (__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) {
         static $firephp;
         if (!isset($firephp)) {
             $firephp = FirePHP::getInstance(true);
         }
         if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
             $firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
             return;
         }
         // display total execution time and Request/Response info
         if (__DEBUG__ & 2) {
             $firephp->fb(array('Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(), array(array('Request URI', 'Request method', 'Response method', 'Response contents size', 'Memory peak usage'), array(sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']), $_SERVER['REQUEST_METHOD'], Context::getResponseMethod(), $this->content_size . ' byte', FileHandler::filesize(memory_get_peak_usage())))), 'TABLE');
             $firephp->fb(array('Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - __StartTime__), array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'), array(sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']), sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']), sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']), sprintf('%0.5f sec', $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']), sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']), sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])))), 'TABLE');
         }
         // display DB query history
         if (__DEBUG__ & 4 && $GLOBALS['__db_queries__']) {
             $queries_output = array(array('Result/' . PHP_EOL . 'Elapsed time', 'Query ID', 'Query'));
             foreach ($GLOBALS['__db_queries__'] as $query) {
                 $queries_output[] = array($query['result'] . PHP_EOL . sprintf('%0.5f', $query['elapsed_time']), str_replace(_XE_PATH_, '', $query['called_file']) . PHP_EOL . $query['called_method'] . '()' . PHP_EOL . $query['query_id'], $query['query']);
             }
             $firephp->fb(array('DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), $queries_output), 'TABLE');
         }
         // dislpay the file and HTML comments
     } else {
         $buff = array();
         // display total execution time and Request/Response info
         if (__DEBUG__ & 2) {
             if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
                 return;
             }
             // Request/Response information
             $buff[] = "\n- Request/ Response info";
             $buff[] = sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']);
             $buff[] = sprintf("\tRequest method \t\t\t: %s", $_SERVER['REQUEST_METHOD']);
             $buff[] = sprintf("\tResponse method \t\t: %s", Context::getResponseMethod());
             $buff[] = sprintf("\tResponse contents size\t: %d byte", $this->content_size);
             // total execution time
             $buff[] = sprintf("\n- Total elapsed time : %0.5f sec", $end - __StartTime__);
             $buff[] = sprintf("\tclass file load elapsed time \t: %0.5f sec", $GLOBALS['__elapsed_class_load__']);
             $buff[] = sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
             $buff[] = sprintf("\tXmlParse compile elapsed time\t: %0.5f sec", $GLOBALS['__xmlparse_elapsed__']);
             $buff[] = sprintf("\tPHP elapsed time \t\t\t\t: %0.5f sec", $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']);
             $buff[] = sprintf("\tDB class elapsed time \t\t\t: %0.5f sec", $GLOBALS['__dbclass_elapsed_time__'] - $GLOBALS['__db_elapsed_time__']);
             // widget execution time
             $buff[] = sprintf("\tWidgets elapsed time \t\t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
             // layout execution time
             $buff[] = sprintf("\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
             // Widgets, the editor component replacement time
             $buff[] = sprintf("\tTrans Content \t\t\t\t\t: %0.5f sec", $GLOBALS['__trans_content_elapsed__']);
         }
         // DB Logging
         if (__DEBUG__ & 4) {
             if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
                 return;
             }
             if ($GLOBALS['__db_queries__']) {
                 $buff[] = sprintf("\n- DB Queries : %d Queries. %0.5f sec", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
                 $num = 0;
                 foreach ($GLOBALS['__db_queries__'] as $query) {
                     if ($query['result'] == 'Success') {
                         $query_result = "Query Success";
                     } else {
                         $query_result = sprintf("Query {$s} : %d\n\t\t\t   %s", $query['result'], $query['errno'], $query['errstr']);
                     }
                     $buff[] = sprintf("\t%02d. %s\n\t\t%0.6f sec. %s.", ++$num, $query['query'], $query['elapsed_time'], $query_result);
                     $buff[] = sprintf("\t\tConnection: %s.", $query['connection']);
                     $buff[] = sprintf("\t\tQuery ID: %s", $query['query_id']);
                     $buff[] = sprintf("\t\tCalled: %s. %s()", str_replace(_XE_PATH_, '', $query['called_file']), $query['called_method']);
                 }
             }
         }
         // Output in HTML comments
         if ($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') {
             $buff = implode("\r\n", $buff);
             $buff = sprintf("[%s %s:%d]\r\n%s", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
             if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
                 $buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
             }
             return "<!--\r\n" . $buff . "\r\n-->";
         }
         // Output to a file
         if ($buff && __DEBUG_OUTPUT__ == 0) {
             $debug_file = _XE_PATH_ . 'files/_debug_message.php';
             $buff = implode(PHP_EOL, $buff);
             $buff = sprintf("[%s]\n%s", date('Y-m-d H:i:s'), print_r($buff, true));
             $buff = str_repeat('=', 80) . "\n" . $buff . "\n" . str_repeat('-', 80);
             $buff = "\n<?php\n/*" . $buff . "*/\n?>\n";
             if (!@file_put_contents($debug_file, $buff, FILE_APPEND | LOCK_EX)) {
                 return;
             }
         }
     }
 }
 /**
  * @brief 디버그 모드일 경우 디버깅 메시지 출력
  *
  * __DEBUG__ 값이 1 이상이면 __DEBUG_OUTPUT__ 값에 따라 메시지 출력.
  * __DEBUG__를 세팅하고, __DEBUG_OUTPUT__ == 0 이면
  * tail -f ./files/_debug_message.php로 하여 console로 확인하면 편리함
  **/
 function _debugOutput()
 {
     if (!__DEBUG__) {
         return;
     }
     $end = getMicroTime();
     // Firebug 콘솔 출력
     if (__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '5.2.0', '>=')) {
         static $firephp;
         if (!isset($firephp)) {
             $firephp = FirePHP::getInstance(true);
         }
         if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
             $firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
             return;
         }
         // 전체 실행 시간 출력, Request/Response info 출력
         if (__DEBUG__ & 2) {
             $firephp->fb(array('Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(), array(array('Request URI', 'Request method', 'Response method', 'Response contents size'), array(sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']), $_SERVER['REQUEST_METHOD'], Context::getResponseMethod(), $this->content_size . ' byte'))), 'TABLE');
             $firephp->fb(array('Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - __StartTime__), array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'), array(sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']), sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']), sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']), sprintf('%0.5f sec', $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']), sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']), sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])))), 'TABLE');
         }
         // DB 쿼리 내역 출력
         if (__DEBUG__ & 4 && $GLOBALS['__db_queries__']) {
             $queries_output = array(array('Query', 'Elapsed time', 'Result'));
             foreach ($GLOBALS['__db_queries__'] as $query) {
                 array_push($queries_output, array($query['query'], sprintf('%0.5f', $query['elapsed_time']), $query['result']));
             }
             $firephp->fb(array('DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']), $queries_output), 'TABLE');
         }
         // 파일 및 HTML 주석으로 출력
     } else {
         // 전체 실행 시간 출력, Request/Response info 출력
         if (__DEBUG__ & 2) {
             // Request/Response 정보 작성
             $buff .= "\n- Request/ Response info\n";
             $buff .= sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s\n", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']);
             $buff .= sprintf("\tRequest method \t\t\t: %s\n", $_SERVER['REQUEST_METHOD']);
             $buff .= sprintf("\tResponse method \t\t: %s\n", Context::getResponseMethod());
             $buff .= sprintf("\tResponse contents size\t\t: %d byte\n", $this->content_size);
             // 전체 실행 시간
             $buff .= sprintf("\n- Total elapsed time : %0.5f sec\n", $end - __StartTime__);
             $buff .= sprintf("\tclass file load elapsed time \t: %0.5f sec\n", $GLOBALS['__elapsed_class_load__']);
             $buff .= sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)\n", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
             $buff .= sprintf("\tXmlParse compile elapsed time\t: %0.5f sec\n", $GLOBALS['__xmlparse_elapsed__']);
             $buff .= sprintf("\tPHP elapsed time \t\t: %0.5f sec\n", $end - __StartTime__ - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']);
             // 위젯 실행 시간 작성
             $buff .= sprintf("\n\tWidgets elapsed time \t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
             // 레이아웃 실행 시간
             $buff .= sprintf("\n\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
             // 위젯, 에디터 컴포넌트 치환 시간
             $buff .= sprintf("\n\tTrans Content \t\t\t: %0.5f sec\n", $GLOBALS['__trans_content_elapsed__']);
         }
         // DB 로그 작성
         if (__DEBUG__ & 4) {
             if ($GLOBALS['__db_queries__']) {
                 $buff .= sprintf("\n- DB Queries : %d Queries. %0.5f sec\n", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
                 $num = 0;
                 foreach ($GLOBALS['__db_queries__'] as $query) {
                     $buff .= sprintf("\t%02d. %s\n\t\t%0.6f sec. ", ++$num, $query['query'], $query['elapsed_time']);
                     if ($query['result'] == 'Success') {
                         $buff .= "Query Success\n";
                     } else {
                         $buff .= sprintf("Query {$s} : %d\n\t\t\t   %s\n", $query['result'], $query['errno'], $query['errstr']);
                     }
                 }
             }
         }
         // HTML 주석으로 출력
         if (__DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') {
             $buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
             if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) {
                 $buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
             }
             return "<!--\r\n" . $buff . "\r\n-->";
         }
         // 파일에 출력
         if (__DEBUG_OUTPUT__ == 0) {
             $debug_file = _XE_PATH_ . 'files/_debug_message.php';
             $buff = sprintf("[%s %s:%d]\n%s\n", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
             $buff = str_repeat('=', 40) . "\n" . $buff . str_repeat('-', 40);
             $buff = "\n<?php\n/*" . $buff . "*/\n?>\n";
             if (@(!($fp = fopen($debug_file, 'a')))) {
                 return;
             }
             fwrite($fp, $buff);
             fclose($fp);
         }
     }
 }
示例#12
0
 /**
  * It creates a module instance
  * @param string $module module name
  * @param string $type instance type, (e.g., view, controller, model)
  * @param string $kind admin or svc
  * @return ModuleObject module instance (if failed it returns null)
  * @remarks if there exists a module instance created before, returns it.
  * */
 function &getModuleInstance($module, $type = 'view', $kind = '')
 {
     if (__DEBUG__ == 3) {
         $start_time = getMicroTime();
     }
     $parent_module = $module;
     $kind = strtolower($kind);
     $type = strtolower($type);
     $kinds = array('svc' => 1, 'admin' => 1);
     if (!isset($kinds[$kind])) {
         $kind = 'svc';
     }
     $key = $module . '.' . ($kind != 'admin' ? '' : 'admin') . '.' . $type;
     if (is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__'])) {
         $module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key];
     }
     // if there is no instance of the module in global variable, create a new one
     if (!isset($GLOBALS['_loaded_module'][$module][$type][$kind])) {
         ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
         if ($extend_module && (!is_readable($high_class_file) || !is_readable($class_file))) {
             $module = $parent_module;
             ModuleHandler::_getModuleFilePath($module, $type, $kind, $class_path, $high_class_file, $class_file, $instance_name);
         }
         // Check if the base class and instance class exist
         if (!class_exists($module, true)) {
             return NULL;
         }
         if (!class_exists($instance_name, true)) {
             return NULL;
         }
         // Create an instance
         $oModule = new $instance_name();
         if (!is_object($oModule)) {
             return NULL;
         }
         // Load language files for the class
         Context::loadLang($class_path . 'lang');
         if ($extend_module) {
             Context::loadLang(ModuleHandler::getModulePath($parent_module) . 'lang');
         }
         // Set variables to the instance
         $oModule->setModule($module);
         $oModule->setModulePath($class_path);
         // If the module has a constructor, run it.
         if (!isset($GLOBALS['_called_constructor'][$instance_name])) {
             $GLOBALS['_called_constructor'][$instance_name] = TRUE;
             if (@method_exists($oModule, $instance_name)) {
                 $oModule->{$instance_name}();
             }
         }
         // Store the created instance into GLOBALS variable
         $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
     }
     if (__DEBUG__ == 3) {
         $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
     }
     // return the instance
     return $GLOBALS['_loaded_module'][$module][$type][$kind];
 }
示例#13
0
<?php

ini_set('include_path', ini_get('include_path') . ':../:');
require_once "design.inc.php";
$title = "Probe overview";
doHeader($title, array('calender' => TRUE));
echo "<h1>{$title}</h1>";
require_once "functions.inc.php";
#$displayTiming = TRUE;
$starttime = getMicroTime();
db_connect();
$probes = probes_info_query();
echo "\n<h4>Please select a probe:</h4>\n";
probes_info_form_tabel($probes, $probeid);
# Trick incl the graph php script
#include("../include/graph_probe_drops_bar01.php");
include "../include/graph_probe_drops_bar02.php";
include "../staging/pie01.php";
db_disconnect();
doFooter();
displayTimingInfo($starttime, getMicroTime(), $displayTiming, "php done");
 /**
  * @brief 모듈 객체를 생성함
  **/
 function &getModuleInstance($module, $type = 'view', $kind = '')
 {
     $class_path = ModuleHandler::getModulePath($module);
     if (!is_dir(_XE_PATH_ . $class_path)) {
         return NULL;
     }
     if (__DEBUG__ == 3) {
         $start_time = getMicroTime();
     }
     if ($kind != 'admin') {
         $kind = 'svc';
     }
     // global 변수에 미리 생성해 둔 객체가 없으면 새로 생성
     if (!$GLOBALS['_loaded_module'][$module][$type][$kind]) {
         /**
          * 모듈의 위치를 파악
          **/
         // 상위 클래스명 구함
         if (!class_exists($module)) {
             $high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
             if (!file_exists($high_class_file)) {
                 return NULL;
             }
             require_once $high_class_file;
         }
         // 객체의 이름을 구함
         switch ($type) {
             case 'controller':
                 if ($kind == 'admin') {
                     $instance_name = sprintf("%sAdmin%s", $module, "Controller");
                     $class_file = sprintf('%s%s%s.admin.%s.php', _XE_PATH_, $class_path, $module, $type);
                 } else {
                     $instance_name = sprintf("%s%s", $module, "Controller");
                     $class_file = sprintf('%s%s%s.%s.php', _XE_PATH_, $class_path, $module, $type);
                 }
                 break;
             case 'model':
                 if ($kind == 'admin') {
                     $instance_name = sprintf("%sAdmin%s", $module, "Model");
                     $class_file = sprintf('%s%s%s.admin.%s.php', _XE_PATH_, $class_path, $module, $type);
                 } else {
                     $instance_name = sprintf("%s%s", $module, "Model");
                     $class_file = sprintf('%s%s%s.%s.php', _XE_PATH_, $class_path, $module, $type);
                 }
                 break;
             case 'api':
                 $instance_name = sprintf("%s%s", $module, "API");
                 $class_file = sprintf('%s%s%s.api.php', _XE_PATH_, $class_path, $module);
                 break;
             case 'wap':
                 $instance_name = sprintf("%s%s", $module, "WAP");
                 $class_file = sprintf('%s%s%s.wap.php', _XE_PATH_, $class_path, $module);
                 break;
             case 'smartphone':
                 $instance_name = sprintf("%s%s", $module, "SPhone");
                 $class_file = sprintf('%s%s%s.smartphone.php', _XE_PATH_, $class_path, $module);
                 break;
             case 'class':
                 $instance_name = $module;
                 $class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
                 break;
             default:
                 $type = 'view';
                 if ($kind == 'admin') {
                     $instance_name = sprintf("%sAdmin%s", $module, "View");
                     $class_file = sprintf('%s%s%s.admin.view.php', _XE_PATH_, $class_path, $module, $type);
                 } else {
                     $instance_name = sprintf("%s%s", $module, "View");
                     $class_file = sprintf('%s%s%s.view.php', _XE_PATH_, $class_path, $module, $type);
                 }
                 break;
         }
         // 클래스 파일의 이름을 구함
         if (!file_exists($class_file)) {
             return NULL;
         }
         // eval로 객체 생성
         require_once $class_file;
         $eval_str = sprintf('$oModule = new %s();', $instance_name);
         @eval($eval_str);
         if (!is_object($oModule)) {
             return NULL;
         }
         // 해당 위치에 속한 lang 파일을 읽음
         Context::loadLang($class_path . 'lang');
         // 생성된 객체에 자신이 호출된 위치를 세팅해줌
         $oModule->setModule($module);
         $oModule->setModulePath($class_path);
         // 요청된 module에 constructor가 있으면 실행
         if (!isset($GLOBALS['_called_constructor'][$instance_name])) {
             $GLOBALS['_called_constructor'][$instance_name] = true;
             if (@method_exists($oModule, $instance_name)) {
                 $oModule->{$instance_name}();
             }
         }
         // GLOBALS 변수에 생성된 객체 저장
         $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
     }
     if (__DEBUG__ == 3) {
         $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
     }
     // 객체 리턴
     return $GLOBALS['_loaded_module'][$module][$type][$kind];
 }
 /**
  * Get the total execution time until this point
  *
  * @access public
  * @return float elapsed time in seconds since script start.
  * @static
  */
 function requestTime()
 {
     $start = DebugKitDebugger::requestStartTime();
     $now = getMicroTime();
     return $now - $start;
 }
 /**
  * compiles specified tpl file and execution result in Context into resultant content
  * @param string $tpl_path path of the directory containing target template file
  * @param string $tpl_filename target template file's name
  * @param string $tpl_file if specified use it as template file's full path
  * @return string Returns compiled result in case of success, NULL otherwise
  */
 public function compile($tpl_path, $tpl_filename, $tpl_file = '')
 {
     $buff = false;
     // store the starting time for debug information
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     // initiation
     $this->init($tpl_path, $tpl_filename, $tpl_file);
     // if target file does not exist exit
     if (!$this->file || !file_exists($this->file)) {
         return "Err : '{$this->file}' template file does not exists.";
     }
     // for backward compatibility
     if (is_null(self::$rootTpl)) {
         self::$rootTpl = $this->file;
     }
     $source_template_mtime = filemtime($this->file);
     $latest_mtime = $source_template_mtime > $this->handler_mtime ? $source_template_mtime : $this->handler_mtime;
     // cache control
     $oCacheHandler = CacheHandler::getInstance('template');
     // get cached buff
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'template:' . $this->file;
         $buff = $oCacheHandler->get($cache_key, $latest_mtime);
     } else {
         if (is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file)) {
             $buff = 'file://' . $this->compiled_file;
         }
     }
     if ($buff === FALSE) {
         $buff = $this->parse();
         if ($oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, $buff);
         } else {
             FileHandler::writeFile($this->compiled_file, $buff);
         }
     }
     $output = $this->_fetch($buff);
     if ($__templatehandler_root_tpl == $this->file) {
         $__templatehandler_root_tpl = null;
     }
     // store the ending time for debug information
     if (__DEBUG__ == 3) {
         $GLOBALS['__template_elapsed__'] += getMicroTime() - $start;
     }
     return $output;
 }
示例#17
0
 /**
  * when display mode is HTML, prepare code before print.
  * @param string $output compiled template string
  * @return void
  */
 function prepareToPrint(&$output)
 {
     if (Context::getResponseMethod() != 'HTML') {
         return;
     }
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     // move <style ..></style> in body to the header
     $output = preg_replace_callback('!<style(.*?)>(.*?)<\\/style>!is', array($this, '_moveStyleToHeader'), $output);
     // move <link ..></link> in body to the header
     $output = preg_replace_callback('!<link(.*?)/>!is', array($this, '_moveLinkToHeader'), $output);
     // move <meta ../> in body to the header
     $output = preg_replace_callback('!<meta(.*?)(?:\\/|)>!is', array($this, '_moveMetaToHeader'), $output);
     // change a meta fine(widget often put the tag like <!--Meta:path--> to the content because of caching)
     $output = preg_replace_callback('/<!--(#)?Meta:([a-z0-9\\_\\-\\/\\.\\@]+)-->/is', array($this, '_transMeta'), $output);
     // handles a relative path generated by using the rewrite module
     if (Context::isAllowRewrite()) {
         $url = parse_url(Context::getRequestUri());
         $real_path = $url['path'];
         $pattern = '/src=("|\'){1}(\\.\\/)?(files\\/attach|files\\/cache|files\\/faceOff|files\\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\\/([^"\']+)\\.(jpg|jpeg|png|gif)("|\'){1}/s';
         $output = preg_replace($pattern, 'src=$1' . $real_path . '$3/$4.$5$6', $output);
         $pattern = '/href=("|\'){1}(\\?[^"\']+)/s';
         $output = preg_replace($pattern, 'href=$1' . $real_path . '$2', $output);
         if (Context::get('vid')) {
             $pattern = '/\\/' . Context::get('vid') . '\\?([^=]+)=/is';
             $output = preg_replace($pattern, '/?$1=', $output);
         }
     }
     // prevent the 2nd request due to url(none) of the background-image
     $output = preg_replace('/url\\((["\']?)none(["\']?)\\)/is', 'none', $output);
     if (is_array(Context::get('INPUT_ERROR'))) {
         $INPUT_ERROR = Context::get('INPUT_ERROR');
         $keys = array_keys($INPUT_ERROR);
         $keys = '(' . implode('|', $keys) . ')';
         $output = preg_replace_callback('@(<input)([^>]*?)\\sname="' . $keys . '"([^>]*?)/?>@is', array(&$this, '_preserveValue'), $output);
         $output = preg_replace_callback('@<select[^>]*\\sname="' . $keys . '".+</select>@isU', array(&$this, '_preserveSelectValue'), $output);
         $output = preg_replace_callback('@<textarea[^>]*\\sname="' . $keys . '".+</textarea>@isU', array(&$this, '_preserveTextAreaValue'), $output);
     }
     if (__DEBUG__ == 3) {
         $GLOBALS['__trans_content_elapsed__'] = getMicroTime() - $start;
     }
     // Remove unnecessary information
     $output = preg_replace('/member\\_\\-([0-9]+)/s', 'member_0', $output);
     // set icon
     $oAdminModel = getAdminModel('admin');
     $favicon_url = $oAdminModel->getFaviconUrl();
     $mobicon_url = $oAdminModel->getMobileIconUrl();
     Context::set('favicon_url', $favicon_url);
     Context::set('mobicon_url', $mobicon_url);
     // convert the final layout
     Context::set('content', $output);
     $oTemplate = TemplateHandler::getInstance();
     if (Mobile::isFromMobilePhone()) {
         $this->_loadMobileJSCSS();
         $output = $oTemplate->compile('./common/tpl', 'mobile_layout');
     } else {
         $this->_loadJSCSS();
         $output = $oTemplate->compile('./common/tpl', 'common_layout');
     }
     // replace the user-defined-language
     $oModuleController = getController('module');
     $oModuleController->replaceDefinedLangCode($output);
 }
function genTime()
{
    static $startPoint;
    if (!isset($startPoint)) {
        $startPoint = getMicroTime();
    } else {
        return getMicroTime() - $startPoint;
    }
}
示例#19
0
</tr>
</table>
<?php 
if ($_SESSION['debug'] == 1) {
    echo '<div><pre>';
    echo '<b>GET:</b>';
    print_r($_GET);
    echo '<b>POST:</b>';
    print_r($_POST);
    echo '<b>SESSION:</b>';
    print_r($_SESSION);
    echo '<b>COOKIES:</b>';
    print_r($HTTP_COOKIE_VARS);
    echo '<b>$_SERVER:</b>';
    print_r($_SERVER);
    $mt_end = getMicroTime();
    echo "<b>Time elapsed</b>: " . round(($mt_end - $mt_start) * 1000) . " ms \n";
    //  echo "<b>Query number</b>: $query_number\n";
    echo "<b>mysql stats:</b>\n";
    $status = explode('  ', mysql_stat());
    print_r($status);
    echo "<b>mysql processes</b>:\n";
    $result = mysql_list_processes();
    while ($row = mysql_fetch_assoc($result)) {
        printf("%s %s %s %s %s\n", $row["Id"], $row["Host"], $row["db"], $row["Command"], $row["Time"]);
    }
    mysql_free_result($result);
    echo "<b>Locales:</b>\n";
    system("locale");
    echo '</pre></div>';
}
示例#20
0
    }
    require _XE_PATH_ . 'classes/object/Object.class.php';
    require _XE_PATH_ . 'classes/extravar/Extravar.class.php';
    require _XE_PATH_ . 'classes/handler/Handler.class.php';
    require _XE_PATH_ . 'classes/xml/XmlParser.class.php';
    require _XE_PATH_ . 'classes/xml/XmlGenerator.class.php';
    require _XE_PATH_ . 'classes/xml/XmlJsFilter.class.php';
    require _XE_PATH_ . 'classes/xml/XmlLangParser.class.php';
    require _XE_PATH_ . 'classes/cache/CacheHandler.class.php';
    require _XE_PATH_ . 'classes/context/Context.class.php';
    require _XE_PATH_ . 'classes/db/DB.class.php';
    require _XE_PATH_ . 'classes/file/FileHandler.class.php';
    require _XE_PATH_ . 'classes/widget/WidgetHandler.class.php';
    require _XE_PATH_ . 'classes/editor/EditorHandler.class.php';
    require _XE_PATH_ . 'classes/module/ModuleObject.class.php';
    require _XE_PATH_ . 'classes/module/ModuleHandler.class.php';
    require _XE_PATH_ . 'classes/display/DisplayHandler.class.php';
    require _XE_PATH_ . 'classes/template/TemplateHandler.class.php';
    require _XE_PATH_ . 'classes/mail/Mail.class.php';
    require _XE_PATH_ . 'classes/page/PageHandler.class.php';
    require _XE_PATH_ . 'classes/mobile/Mobile.class.php';
    require _XE_PATH_ . 'classes/validator/Validator.class.php';
    require _XE_PATH_ . 'classes/frontendfile/FrontEndFileHandler.class.php';
    require _XE_PATH_ . 'classes/security/Security.class.php';
    require _XE_PATH_ . 'classes/security/IpFilter.class.php';
    if (__DEBUG__) {
        $GLOBALS['__elapsed_class_load__'] = getMicroTime() - __ClassLoadStartTime__;
    }
}
/* End of file config.inc.php */
/* Location: ./config/config.inc.php */
示例#21
0
<?php

/**
 * Tests unitaires
 *
 * @package wikirenderer
 * @subpackage tests
 * @author Laurent Jouanneau
 * @copyright 2003-2006 Laurent Jouanneau
 */
header('ContentType: text/plain');
require_once 'wikirenderer/WikiRenderer.lib.php';
include 'dataSeries.php';
function getMicroTime()
{
    list($micro, $time) = explode(' ', microtime());
    return $micro + $time;
}
$start = getMicroTime();
$wr = new WikiRenderer('classicwr_to_xhtml');
foreach ($list as $k => $t) {
    $res = $wr->render($t[0]);
}
$stop = getMicroTime();
echo "time=" . intval(($stop - $start) * 1000) / 1000;
示例#22
0
 function getRuntimeSec($in_msec = true)
 {
     $time = getMicroTime($this) - $this->fStartTime;
     $pos = strpos($time, '.');
     return $in_msec ? substr($time, 0, $pos + 4) : substr($time, 0, $pos + 4);
 }
示例#23
0
 /**
  * @brief Widget name and argument and produce a result and Return the results
  * Tags used in templateHandler $this-&gt; execute() will be replaced by the code running
  *
  * $Javascript_mode is true when editing your page by the code for handling Includes photos
  */
 function execute($widget, $args, $javascript_mode = false, $escaped = true)
 {
     // Save for debug run-time widget
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     $before = microtime(true);
     // urldecode the value of args haejum
     $object_vars = get_object_vars($args);
     if (count($object_vars)) {
         foreach ($object_vars as $key => $val) {
             if (in_array($key, array('widgetbox_content', 'body', 'class', 'style', 'widget_sequence', 'widget', 'widget_padding_left', 'widget_padding_top', 'widget_padding_bottom', 'widget_padding_right', 'widgetstyle', 'document_srl'))) {
                 continue;
             }
             if ($escaped) {
                 $args->{$key} = utf8RawUrlDecode($val);
             }
         }
     }
     /**
      * Widgets widgetContent/widgetBox Wanted If you are not content
      */
     $widget_content = '';
     if ($widget != 'widgetContent' && $widget != 'widgetBox') {
         if (!is_dir(sprintf(_XE_PATH_ . 'widgets/%s/', $widget))) {
             return;
         }
         // Hold the contents of the widget parameter
         $widget_content = $this->getCache($widget, $args);
     }
     if ($widget == 'widgetBox') {
         $widgetbox_content = $args->widgetbox_content;
     }
     /**
      * Wanted specified by the administrator of the widget style
      */
     // Sometimes the wrong code, background-image: url (none) can be heard but none in this case, the request for the url so unconditionally Removed
     $style = preg_replace('/url\\((.+)(\\/?)none\\)/is', '', $args->style);
     // Find a style statement that based on the internal margin dropping pre-change
     $widget_padding_left = $args->widget_padding_left;
     $widget_padding_right = $args->widget_padding_right;
     $widget_padding_top = $args->widget_padding_top;
     $widget_padding_bottom = $args->widget_padding_bottom;
     $inner_style = sprintf("padding:%dpx %dpx %dpx %dpx !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left);
     /**
      * Wanted widget output
      */
     $widget_content_header = '';
     $widget_content_body = '';
     $widget_content_footer = '';
     // If general call is given on page styles should return immediately dreamin '
     if (!$javascript_mode) {
         if ($args->id) {
             $args->id = ' id="' . $args->id . '" ';
         }
         switch ($widget) {
             // If a direct orthogonal addition information
             case 'widgetContent':
                 if ($args->document_srl) {
                     $oDocumentModel = getModel('document');
                     $oDocument = $oDocumentModel->getDocument($args->document_srl);
                     $body = $oDocument->getContent(false, false, false, false);
                 } else {
                     $body = base64_decode($args->body);
                 }
                 // Change the editor component
                 $oEditorController = getController('editor');
                 $body = $oEditorController->transComponent($body);
                 $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s"><div style="%s">', $args->id, $style, $inner_style);
                 $widget_content_body = $body;
                 $widget_content_footer = '</div></div>';
                 break;
                 // If the widget box; it could
             // If the widget box; it could
             case 'widgetBox':
                 $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s;"><div style="%s"><div>', $args->id, $style, $inner_style);
                 $widget_content_body = $widgetbox_content;
                 break;
                 // If the General wijetil
             // If the General wijetil
             default:
                 $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s">', $args->id, $style);
                 $widget_content_body = sprintf('<div style="*zoom:1;%s">%s</div>', $inner_style, $widget_content);
                 $widget_content_footer = '</div>';
                 break;
         }
         // Edit page is called when a widget if you add the code for handling
     } else {
         switch ($widget) {
             // If a direct orthogonal addition information
             case 'widgetContent':
                 if ($args->document_srl) {
                     $oDocumentModel = getModel('document');
                     $oDocument = $oDocumentModel->getDocument($args->document_srl);
                     $body = $oDocument->getContent(false, false, false);
                 } else {
                     $body = base64_decode($args->body);
                 }
                 // by args
                 $attribute = array();
                 if ($args) {
                     foreach ($args as $key => $val) {
                         if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) {
                             continue;
                         }
                         if (strpos($val, '|@|') > 0) {
                             $val = str_replace('|@|', ',', $val);
                         }
                         $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                     }
                 }
                 $oWidgetController = getController('widget');
                 $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>' . '<div class="widgetResize"></div>' . '<div class="widgetResizeLeft"></div>' . '<div class="widgetBorder">' . '<div style="%s">', $args->widgetstyle, $style, $args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom, $args->document_srl, implode(' ', $attribute), $inner_style);
                 $widget_content_body = $body;
                 $widget_content_footer = sprintf('</div>' . '</div>' . '<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>' . '</div>', base64_encode($body));
                 break;
                 // If the widget box; it could
             // If the widget box; it could
             case 'widgetBox':
                 // by args
                 $attribute = array();
                 if ($args) {
                     foreach ($args as $key => $val) {
                         if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) {
                             continue;
                         }
                         if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) {
                             continue;
                         }
                         if (strpos($val, '|@|') > 0) {
                             $val = str_replace('|@|', ',', $val);
                         }
                         $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                     }
                 }
                 $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >' . '<div class="widgetBoxResize"></div>' . '<div class="widgetBoxResizeLeft"></div>' . '<div class="widgetBoxBorder"><div class="nullWidget" style="%s">', $args->widgetstyle, $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, implode(' ', $attribute), $inner_style);
                 $widget_content_body = $widgetbox_content;
                 break;
                 // If the General wijetil
             // If the General wijetil
             default:
                 // by args
                 $attribute = array();
                 if ($args) {
                     $allowed_key = array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget');
                     foreach ($args as $key => $val) {
                         if (in_array($key, $allowed_key)) {
                             continue;
                         }
                         if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) {
                             continue;
                         }
                         if (strpos($val, '|@|') > 0) {
                             $val = str_replace('|@|', ',', $val);
                         }
                         $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
                     }
                 }
                 $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >' . '<div class="widgetResize"></div>' . '<div class="widgetResizeLeft"></div>' . '<div class="widgetBorder">', $args->widgetstyle, $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $widget, implode(' ', $attribute));
                 $widget_content_body = sprintf('<div style="%s">%s</div>', $inner_style, $widget_content);
                 $widget_content_footer = '</div></div>';
                 break;
         }
     }
     // Compile the widget style.
     if ($args->widgetstyle) {
         $widget_content_body = $this->compileWidgetStyle($args->widgetstyle, $widget, $widget_content_body, $args, $javascript_mode);
     }
     $output = $widget_content_header . $widget_content_body . $widget_content_footer;
     // Debug widget creation time information added to the results
     if (__DEBUG__ == 3) {
         $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
     }
     $after = microtime(true);
     $elapsed_time = $after - $before;
     $slowlog = new stdClass();
     $slowlog->caller = "widget.execute";
     $slowlog->called = $widget;
     $slowlog->called_extension = $widget;
     writeSlowlog('widget', $elapsed_time, $slowlog);
     // Return result
     return $output;
 }
示例#24
0
 function actFinish()
 {
     if (!$this->query) {
         return;
     }
     $this->act_finish = getMicroTime();
     $elapsed_time = $this->act_finish - $this->act_start;
     $this->elapsed_time = $elapsed_time;
     $GLOBALS['__db_elapsed_time__'] += $elapsed_time;
     $log['query'] = $this->query;
     $log['elapsed_time'] = $elapsed_time;
     // 에러 발생시 에러 로그를 남김 (__DEBUG_DB_OUTPUT__이 지정되어 있을경우)
     if ($this->isError()) {
         $log['result'] = 'Failed';
         $log['errno'] = $this->errno;
         $log['errstr'] = $this->errstr;
         if (__DEBUG_DB_OUTPUT__ == 1) {
             $debug_file = _XE_PATH_ . "files/_debug_db_query.php";
             $buff = sprintf("%s\n", print_r($log, true));
             if ($display_line) {
                 $buff = "\n<?php\n/*\n====================================\n" . $buff . "------------------------------------\n*/\n?>\n";
             }
             if (@(!($fp = fopen($debug_file, "a")))) {
                 return;
             }
             fwrite($fp, $buff);
             fclose($fp);
         }
     } else {
         $log['result'] = 'Success';
     }
     $GLOBALS['__db_queries__'][] = $log;
     // __LOG_SLOW_QUERY__ 가 정해져 있다면 시간 체크후 쿼리 로그 남김
     if (__LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__) {
         $buff = '';
         $log_file = _XE_PATH_ . 'files/_db_slow_query.php';
         if (!file_exists($log_file)) {
             $buff = '<?php exit();?>' . "\n";
         }
         $buff .= sprintf("%s\t%s\n\t%0.6f sec\n\n", date("Y-m-h H:i"), $this->query, $elapsed_time);
         if ($fp = fopen($log_file, 'a')) {
             fwrite($fp, $buff);
             fclose($fp);
         }
     }
 }
示例#25
0
 /**
  * Parse xml data to extract values from it and construct data object
  * @param string $input a data buffer containing xml data
  * @param mixed $arg1 ???
  * @param mixed $arg2 ???
  * @return array Returns a resultant data object or NULL in case of error
  */
 function parse($input = '', $arg1 = NULL, $arg2 = NULL)
 {
     // Save the compile starting time for debugging
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     $this->lang = Context::getLangType();
     $this->input = $input ? $input : $GLOBALS['HTTP_RAW_POST_DATA'];
     $this->input = str_replace(array('', ''), array('', ''), $this->input);
     // extracts a supported language
     preg_match_all("/xml:lang=\"([^\"].+)\"/i", $this->input, $matches);
     // extracts the supported lanuage when xml:lang is used
     if (count($matches[1]) && ($supported_lang = array_unique($matches[1]))) {
         $tmpLangList = array_flip($supported_lang);
         // if lang of the first log-in user doesn't exist, apply en by default if exists. Otherwise apply the first lang.
         if (!isset($tmpLangList[$this->lang])) {
             if (isset($tmpLangList['en'])) {
                 $this->lang = 'en';
             } else {
                 $this->lang = array_shift($supported_lang);
             }
         }
         // uncheck the language if no specific language is set.
     } else {
         $this->lang = '';
     }
     $this->oParser = xml_parser_create('UTF-8');
     xml_set_object($this->oParser, $this);
     xml_set_element_handler($this->oParser, "_tagOpen", "_tagClosed");
     xml_set_character_data_handler($this->oParser, "_tagBody");
     xml_parse($this->oParser, $this->input);
     xml_parser_free($this->oParser);
     if (!count($this->output)) {
         return;
     }
     $output = array_shift($this->output);
     // Save compile starting time for debugging
     if (__DEBUG__ == 3) {
         $GLOBALS['__xmlparse_elapsed__'] += getMicroTime() - $start;
     }
     return $output;
 }
示例#26
0
 function Session($start_time)
 {
     $this->fDbType = DB_MySQL;
     $this->fDbServer = 'localhost';
     $this->fDbTablePrefix = 'infobasar_';
     $this->fDbName = '';
     $this->fDbUser = '';
     $this->fDbPassw = '';
     $this->fOutputState = 'Init';
     $this->fTraceFlags = TC_X;
     # Flags unten setzen!;
     $this->fTraceFile = null;
     #$this->fTraceFile = '/tmp/inst.log';
     $this->fStartTime = getMicroTime($this, $start_time);
     session_start();
     $this->fSessionId = session_id();
     if (!session_is_registered('inst_step')) {
         session_register('inst_step');
         $_SESSION['inst_step'] = 0;
     }
     if (isset($_POST['inst_next'])) {
         $_SESSION['inst_step']++;
     } elseif (isset($_POST['inst_last'])) {
         $_SESSION['inst_step']--;
     }
     if ($_SESSION['inst_step'] > 10) {
         $_SESSION['inst_step'] = 0;
     }
     $this->fStep = $_SESSION['inst_step'];
     $uri = $_SERVER['REQUEST_URI'];
     $this->fScriptURL = $uri;
     $pos = strpos($uri, ".php");
     if ($pos <= 0) {
         if (strpos($uri, ".php") > 0) {
             $this->fScriptURL = $uri;
         } else {
             $this->fScriptURL = $uri . "/install.php";
         }
         $this->fPageURL = '';
     } else {
         $this->fScriptURL = substr($uri, 0, $pos + 4);
         if ($pos + 5 < strlen($uri)) {
             $pageURL = substr($uri, $pos + 5);
             if (($pos = strpos($pageURL, '/', 1)) > 0) {
                 $this->fScriptURL = substr($pageURL, 0, $pos);
             }
         }
     }
     $this->fScriptFile = $_SERVER['SCRIPT_FILENAME'];
     $this->fScriptBase = preg_replace('/\\/\\w+\\.php.*$/', '', $_SERVER['PHP_SELF']);
     $this->fFileSystemBase = preg_replace('/\\/\\w+\\.php.*$/', '', $this->fScriptFile);
     #dumpPost($this);
     #$this->trace (TC_X, "Step: $this->fStep");
 }
示例#27
0
 /**
  * @param string $content  data for parse and view
  * @access   protected
  */
 protected function _view($content)
 {
     $Register = Register::getInstance();
     if (!empty($this->template) && $this->wrap == true) {
         Plugins::intercept('before_parse_layout', $this);
         $this->View->setLayout($this->template);
         $markers = $this->getGlobalMarkers(file_get_contents($this->View->getTemplateFilePath('main.html')));
         $markers['content'] = $content;
         // Cache global markers
         if ($this->cached) {
             if ($this->Cache->check($this->cacheKey . '_global_markers')) {
                 $gdata = $this->Cache->read($this->cacheKey . '_global_markers');
                 $this->globalMarkers = array_merge($this->globalMarkers, unserialize($gdata));
             } else {
                 $gdata = serialize($this->globalMarkers);
                 $this->Cache->write($gdata, $this->cacheKey . '_global_markers', $this->cacheTags);
             }
         }
         $boot_time = round(getMicroTime() - $Register['fps_boot_start_time'], 4);
         $markers = array_merge($markers, array('boot_time' => $boot_time));
         $output = $this->render('main.html', $markers);
     } else {
         $output = $content;
     }
     $this->_afterRender();
     echo $output;
     if (Config::read('debug_mode') == 1) {
         echo AtmDebug::getBody();
     }
     die;
 }
示例#28
0
 /**
  * It creates a module instance
  * @param string $module module name
  * @param string $type instance type, (e.g., view, controller, model)
  * @param string $kind admin or svc
  * @return ModuleObject module instance (if failed it returns null)
  * @remarks if there exists a module instance created before, returns it.
  **/
 function &getModuleInstance($module, $type = 'view', $kind = '')
 {
     if (__DEBUG__ == 3) {
         $start_time = getMicroTime();
     }
     $kind = strtolower($kind);
     $type = strtolower($type);
     $kinds = array('svc' => 1, 'admin' => 1);
     if (!isset($kinds[$kind])) {
         $kind = 'svc';
     }
     $key = $module . '.' . ($kind != 'admin' ? '' : 'admin') . '.' . $type;
     if (is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__'])) {
         $module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key];
     }
     // if there is no instance of the module in global variable, create a new one
     if (!isset($GLOBALS['_loaded_module'][$module][$type][$kind])) {
         $parent_module = $module;
         $class_path = ModuleHandler::getModulePath($module);
         if (!is_dir(FileHandler::getRealPath($class_path))) {
             return NULL;
         }
         // Get base class name and load the file contains it
         if (!class_exists($module)) {
             $high_class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
             if (!file_exists($high_class_file)) {
                 return NULL;
             }
             require_once $high_class_file;
         }
         // Get the object's name
         $types = explode(' ', 'view controller model api wap mobile class');
         if (!in_array($type, $types)) {
             $type = $types[0];
         }
         if ($type == 'class') {
             $instance_name = '%s';
             $class_file = '%s%s.%s.php';
         } elseif ($kind == 'admin' && array_search($type, $types) < 3) {
             $instance_name = '%sAdmin%s';
             $class_file = '%s%s.admin.%s.php';
         } else {
             $instance_name = '%s%s';
             $class_file = '%s%s.%s.php';
         }
         $instance_name = sprintf($instance_name, $module, ucfirst($type));
         $class_file = sprintf($class_file, $class_path, $module, $type);
         $class_file = FileHandler::getRealPath($class_file);
         // Get the name of the class file
         if (!is_readable($class_file)) {
             return NULL;
         }
         // Create an instance with eval function
         require_once $class_file;
         if (!class_exists($instance_name)) {
             return NULL;
         }
         $tmp_fn = create_function('', "return new {$instance_name}();");
         $oModule = $tmp_fn();
         if (!is_object($oModule)) {
             return NULL;
         }
         // Load language files for the class
         Context::loadLang($class_path . 'lang');
         if ($extend_module) {
             Context::loadLang(ModuleHandler::getModulePath($parent_module) . 'lang');
         }
         // Set variables to the instance
         $oModule->setModule($module);
         $oModule->setModulePath($class_path);
         // If the module has a constructor, run it.
         if (!isset($GLOBALS['_called_constructor'][$instance_name])) {
             $GLOBALS['_called_constructor'][$instance_name] = true;
             if (@method_exists($oModule, $instance_name)) {
                 $oModule->{$instance_name}();
             }
         }
         // Store the created instance into GLOBALS variable
         $GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
     }
     if (__DEBUG__ == 3) {
         $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $start_time;
     }
     // return the instance
     return $GLOBALS['_loaded_module'][$module][$type][$kind];
 }
示例#29
0
function __xe_autoload($class_name)
{
    if (__DEBUG__) {
        $time_at = getMicroTime();
    }
    if (isset($GLOBALS['__xe_autoload_file_map'][strtolower($class_name)])) {
        require _XE_PATH_ . $GLOBALS['__xe_autoload_file_map'][strtolower($class_name)];
    } elseif (preg_match('/^([a-zA-Z0-9_]+?)(Admin)?(View|Controller|Model|Api|Wap|Mobile)?$/', $class_name, $matches)) {
        $candidate_filename = array();
        $candidate_filename[] = 'modules/' . $matches[1] . '/' . $matches[1];
        if (isset($matches[2]) && $matches[2]) {
            $candidate_filename[] = 'admin';
        }
        $candidate_filename[] = isset($matches[3]) && $matches[3] ? strtolower($matches[3]) : 'class';
        $candidate_filename[] = 'php';
        $candidate_filename = implode('.', $candidate_filename);
        if (file_exists(_XE_PATH_ . $candidate_filename)) {
            require _XE_PATH_ . $candidate_filename;
        }
    }
    if (__DEBUG__) {
        $GLOBALS['__elapsed_class_load__'] += getMicroTime() - $time_at;
    }
}
                } else {
                    if ($_SERVER['REMOTE_ADDR'] != $websiteIp && strstr($current_url, 'preview=true') == true) {
                        require $wp_blog_header_path;
                    }
                }
            }
        }
        // else {   // This is what your server should get if no cache exists  //deprecated, as the ob_start() is cleaner
        //require( $wp_blog_header_path );
        // }
    } else {
        require $wp_blog_header_path;
    }
} catch (Exception $e) {
    require $wp_blog_header_path;
    echo "<!-- Something went wrong: " . $e->getMessage() . "-->";
}
if ($debug) {
    $end = microtime();
    $time = @getMicroTime($end) - @getMicroTime($start);
    echo "<!-- Page generated in " . round($time, 5) . " seconds. -->\n";
    echo "<!-- Site was cached  = " . $cache . " -->\n";
    if (isset($seconds_cache_redis)) {
        echo "<!-- wp-redis-cache-seconds  = " . $seconds_cache_redis . " -->\n";
    }
    echo "<!-- wp-redis-cache-ip  = " . $websiteIp . "-->\n";
    if (isset($unlimited)) {
        echo "<!-- wp-redis-cache-unlimited = " . $unlimited . "-->\n";
    }
    echo "<!-- wp-redis-cache-debug  = " . $debug . "-->\n";
}