# HG changeset patch # User Matti Hamalainen # Date 1383726071 -7200 # Node ID 63c840590476205aa6f379caedc15dd5aa592d68 # Parent fef53f6170b512c907350b88c662c43429a7685f Move common code from mcommon.inc.php to msitegen module. diff -r fef53f6170b5 -r 63c840590476 admin.php --- a/admin.php Wed Nov 06 10:17:47 2013 +0200 +++ b/admin.php Wed Nov 06 10:21:11 2013 +0200 @@ -7,10 +7,10 @@ $sessionType = "admin"; require "mconfig.inc.php"; require "msite.inc.php"; -require "mcommon.inc.php"; require "msession.inc.php"; require "majax.php"; +cmLocaleInit(); // Switch to https first, if needed if (!stCheckHTTPS()) diff -r fef53f6170b5 -r 63c840590476 index.php --- a/index.php Wed Nov 06 10:17:47 2013 +0200 +++ b/index.php Wed Nov 06 10:21:11 2013 +0200 @@ -6,9 +6,9 @@ // require "mconfig.inc.php"; require "msite.inc.php"; -require "mcommon.inc.php"; require "msession.inc.php"; +cmLocaleInit(); // Switch to https first, if needed if (!stCheckHTTPS() && isset($_SERVER["REQUEST_URI"]) && diff -r fef53f6170b5 -r 63c840590476 msitegen.inc.php --- a/msitegen.inc.php Wed Nov 06 10:17:47 2013 +0200 +++ b/msitegen.inc.php Wed Nov 06 10:21:11 2013 +0200 @@ -422,4 +422,115 @@ return sprintf("%-".$len."s", $s); } + + +function cmLocaleInit() +{ + global $pageCharset; + + if (!isset($pageCharset)) + $pageCharset = "UTF-8"; + + mb_internal_encoding($pageCharset); + + $tmp = "en_US.".strtolower(str_replace("-", "", $pageCharset)); + setlocale(LC_ALL, $tmp); +} + + +function cmPrintCSSLine($uri) +{ + echo " \n"; +} + + +function cmPrintPageHeader($pageTitle, $pageExtra = "", $useContents = TRUE) +{ + global $pageCSS, $pageCharset, $pageAuthor, $pageCSSData, $pageUrchin; + + if (!isset($pageCSS)) + { + if (!isset($pageCSSData)) + { + $pageCSSData = array( + "cookie" => "docscss", + "prefix" => "http://tnsp.org/docs", + ); + } + + if (isset($_GET["css"])) + { + $index = intval($_GET["css"]); + setcookie($pageCSSData["cookie"], $index, time() + 365*24*60*60, "/"); // expire in a year + } + else + { + $index = isset($_COOKIE[$pageCSSData["cookie"]]) ? intval($_COOKIE[$pageCSSData["cookie"]]) : 1; + } + $pageCSS = $pageCSSData["prefix"].$index.".css"; + } + + echo + "\n". + "\n". + "\n". + "\n". + " \n". + " ".strip_tags($pageTitle)."\n"; + + if (is_array($pageCSS)) + { + foreach ($pageCSS as $uri) + cmPrintCSSLine($uri); + } + else + { + cmPrintCSSLine($pageCSS); + } + + echo $pageExtra."\n". + "\n". + "\n"; + + if (isset($pageUrchin)) + require_once $pageUrchin; + else + require_once "urchin.inc.php"; + +/* + echo + "\n". + "\n"; +*/ + + if ($useContents) + echo "
\n"; +} + + +function cmPrintPageFooter($useContents = TRUE) +{ + if ($useContents) + echo "
\n"; + + echo "\n\n"; +} + + +function cmQM($msg) +{ + global $pageTranslations, $pageLang; + + if (isset($pageTranslations[$msg]) && isset($pageTranslations[$msg][$pageLang])) + $str = $pageTranslations[$msg][$pageLang]; + else + $str = $msg; + + foreach (func_get_args() as $argn => $argv) + $str = preg_replace("/\%".$argn."/", $argv, $str); + return $str; +} + ?> \ No newline at end of file diff -r fef53f6170b5 -r 63c840590476 print.php --- a/print.php Wed Nov 06 10:17:47 2013 +0200 +++ b/print.php Wed Nov 06 10:21:11 2013 +0200 @@ -7,10 +7,10 @@ $sessionType = "admin"; require "mconfig.inc.php"; require "msite.inc.php"; -require "mcommon.inc.php"; require "msession.inc.php"; $pageCSS = "hardcopy.css"; +cmLocaleInit(); // // Check if we are allowed to execute diff -r fef53f6170b5 -r 63c840590476 show.php --- a/show.php Wed Nov 06 10:17:47 2013 +0200 +++ b/show.php Wed Nov 06 10:21:11 2013 +0200 @@ -6,9 +6,9 @@ // require "mconfig.inc.php"; require "msite.inc.php"; -require "mcommon.inc.php"; require "majax.php"; +cmLocaleInit(); stSetupCacheControl(); cmPrintPageHeader("PARTY INFORMATION DISPLAY SYSTEM", "", FALSE);