コード例 #1
0
ファイル: index.php プロジェクト: beardon/stillwaterlife-web
* All rights reserved.
* LiveZilla is a registered trademark.
* 
* Improper changes to this file may cause critical errors.
***************************************************************************************/
define("IN_LIVEZILLA", true);
if (!defined("LIVEZILLA_PATH")) {
    define("LIVEZILLA_PATH", "./");
}
header("Content-Type: text/html; charset=UTF-8");
require LIVEZILLA_PATH . "_lib/functions.global.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php";
require LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php";
require LIVEZILLA_PATH . "_lib/functions.index.inc.php";
languageSelect();
@set_error_handler("handleError");
$scheme = getScheme();
if (isset($_GET[GET_INDEX_SERVER_ACTION]) && $_GET[GET_INDEX_SERVER_ACTION] == "addserver") {
    $html = doReplacements(getFile(TEMPLATE_HTML_ADD_SERVER));
    $html = str_replace("<!--lz_add_url-->", getServerAddLink($scheme), $html);
    exit($html);
} else {
    $html = getFile(TEMPLATE_HTML_INDEX);
    $errorbox = null;
    $errors['write'] = getFolderPermissions();
    $errors['php_version'] = getPhpVersion();
    $errors['mysql'] = getMySQL();
    if (!empty($errors['write']) || !empty($errors['php_version']) || !empty($errors['mysql'])) {
        $errorbox = getFile(TEMPLATE_HTML_INDEX_ERRORS);
        $errorbox = str_replace("<!--write_access-->", $errors['write'], $errorbox);
コード例 #2
0
function load_template()
{
    global $THEME_DIR, $CONFIG, $template_header, $template_footer;
    $tmpl_loc = array();
    $tmpl_loc = unserialize(base64_decode(LOC));
    if (file_exists(TEMPLATE_FILE)) {
        $template_file = TEMPLATE_FILE;
    } elseif (file_exists($THEME_DIR . TEMPLATE_FILE)) {
        $template_file = $THEME_DIR . TEMPLATE_FILE;
    } else {
        die("<b>Coppermine critical error</b>:<br />Unable to load template file " . TEMPLATE_FILE . "!</b>");
    }
    $template = fread(fopen($template_file, 'r'), filesize($template_file));
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_FLAGS}');
    $template = str_replace('{LANGUAGE_SELECT_FLAGS}', languageSelect('flags'), $template);
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_LIST}');
    $template = str_replace('{LANGUAGE_SELECT_LIST}', languageSelect('list'), $template);
    $gallery_pos = strpos($template, '{THEME_DIR}');
    $template = str_replace('{THEME_DIR}', $THEME_DIR, $template);
    $gallery_pos = strpos($template, '{THEME_SELECT_LIST}');
    $template = str_replace('{THEME_SELECT_LIST}', themeSelect('list'), $template);
    $gallery_pos = strpos($template, $tmpl_loc['l']);
    $template = str_replace($tmpl_loc['l'], $tmpl_loc['s'], $template);
    $template_header = substr($template, 0, $gallery_pos);
    $template_footer = substr($template, $gallery_pos);
    $add_version_info = '<!--Coppermine Photo Gallery ' . COPPERMINE_VERSION . '--></body>';
    $template_footer = ereg_replace("</body[^>]*>", $add_version_info, $template_footer);
}
コード例 #3
0
ファイル: functions.inc.php プロジェクト: phill104/branches
/**
 * load_template()
 *
 * Load and parse the template.html file
 *
 * @return
 **/
function load_template()
{
    global $THEME_DIR, $CONFIG, $template_header, $template_footer;
    if (file_exists(TEMPLATE_FILE)) {
        $template_file = TEMPLATE_FILE;
    } elseif (file_exists($THEME_DIR . TEMPLATE_FILE)) {
        $template_file = $THEME_DIR . TEMPLATE_FILE;
    } else {
        die("<b>Coppermine critical error</b>:<br />Unable to load template file " . TEMPLATE_FILE . "!</b>");
    }
    $template = fread(fopen($template_file, 'r'), filesize($template_file));
    $template = CPGPluginAPI::filter('template_html', $template);
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_FLAGS}');
    $template = str_replace('{LANGUAGE_SELECT_FLAGS}', languageSelect('flags'), $template);
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_LIST}');
    $template = str_replace('{LANGUAGE_SELECT_LIST}', languageSelect('list'), $template);
    $gallery_pos = strpos($template, '{THEME_DIR}');
    $template = str_replace('{THEME_DIR}', $THEME_DIR, $template);
    $gallery_pos = strpos($template, '{THEME_SELECT_LIST}');
    $template = str_replace('{THEME_SELECT_LIST}', themeSelect('list'), $template);
    $gallery_pos = strpos($template, '{GALLERY}');
    if (!strstr($template, '{CREDITS}')) {
        $template = str_replace('{GALLERY}', '{CREDITS}', $template);
    } else {
        $template = str_replace('{GALLERY}', '', $template);
    }
    $template_header = substr($template, 0, $gallery_pos);
    $template_header = str_replace('{META}', '{META}' . "<script src='include/tag/lib/httpreq.js' type='text/javascript'></script><script src='include/tag/lib/photonotes.js' type='text/javascript'></script><link rel='stylesheet' href='include/tag/lib/photonotes.css' type='text/css' />", $template_header);
    $template_header = str_replace('{META}', '{META}' . CPGPluginAPI::filter('page_meta', ''), $template_header);
    // Filter gallery header and footer
    $template_header .= CPGPluginAPI::filter('gallery_header', '');
    $template_footer = CPGPluginAPI::filter('gallery_footer', '') . substr($template, $gallery_pos);
    $add_version_info = "<!--Coppermine Photo Gallery " . COPPERMINE_VERSION . " (" . COPPERMINE_VERSION_STATUS . ")-->\n</body>";
    $template_footer = ereg_replace("</body[^>]*>", $add_version_info, $template_footer);
}
コード例 #4
0
ファイル: show.blade.php プロジェクト: fuzhongqing/newoj
						<h1>提交</h1>
						@if (Auth::guest())
							请先<a href="{{ url('/auth/login') }}" target="_blank">登陆</a>
						@else
						<div class="col-md-12">

							<input type="hidden" name="_token" id="_token" value="{{ csrf_token() }}">
							<input type="hidden" id="url" value="{{ url('problem').'/'.$data->problem_id.'/submit.json' }}">
							<input type="hidden" id="problem_id" value="{{ $data->problem_id }}">
							<div class="form-group">
								<label class="control-label">语言</label>
								<select class="form-control" name="language" id = "language">
									<?php 
for ($i = 0; $i < $lang_count; $i++) {
    if ($lang & 1 << $i) {
        echo '<option value = "' . $i . '">' . languageSelect($i) . '</option>';
    }
}
?>
								</select>
							</div>

							<div class="form-group">
								  <label class="control-label">代码(请用 [Ctrl-V] 粘贴)</label>
									<textarea class="form-control" rows="26" name="code" id = "code"></textarea>
							</div>
							<div class="form-group">
									<button type="submit" class="btn btn-primary" id="code_submit">提交</button>
							</div>
						@endif
						<!-- modal close button -->
コード例 #5
0
    $html = str_replace("<!--voucher_id-->", base64UrlEncode($ticket->Id), $html);
    $html = str_replace("<!--server-->", LIVEZILLA_URL, $html);
    $ofc = !empty($_POST["form_ofc"]) ? "&amp;ofc=MQ__" : "";
    if (!empty($_POST["form_extends"]) && !empty($_POST["form_group"])) {
        $html = str_replace("<!--co-->", "&amp;co=" . base64UrlEncode($_POST["form_extends"]) . "&amp;intgroup=" . base64UrlEncode($_POST["form_group"]) . $ofc, $html);
    } else {
        if (!empty($_POST["form_group"])) {
            $html = str_replace("<!--co-->", "&amp;intgroup=" . base64UrlEncode($_POST["form_group"]) . $ofc, $html);
        } else {
            $html = str_replace("<!--co-->", $ofc, $html);
        }
    }
    exit($html);
} else {
    if (!empty($_GET["confirm"]) && $_GET["confirm"] == "1" && !empty($_GET["vc"]) && strlen(base64UrlDecode($_GET["vc"])) == 16) {
        require LIVEZILLA_PATH . "_lib/functions.pp.paypal.inc.php";
        $voucher = new CommercialChatVoucher("", base64UrlDecode($_GET["vc"]));
        if ($voucher->Load()) {
            if (PayProvValidatePayment($voucher->Price)) {
                languageSelect($voucher->Language);
                $voucher->SetPaymentDetails(PayProvGetPaymentId(), PayProvGetPayerId(), PayProvGetPaymentDetails());
                if (empty($PAYMENTERROR)) {
                    $voucher->SetVoucherParams(!empty($voucher->Voided), true, false, false, false, true, base64UrlDecode($_GET[GET_EXTERN_GROUP]));
                } else {
                    $voucher->SetVoucherParams(!empty($voucher->Voided), false, false, false, false);
                }
            }
        }
    }
}
unloadDataProvider();
コード例 #6
0
/**
 * load_template()
 *
 * Load and parse the template.html file
 *
 * @return
 **/
function load_template()
{
    global $THEME_DIR, $template_header, $template_footer, $LINEBREAK;
    $template = file_get_contents($THEME_DIR . TEMPLATE_FILE);
    if ($template === FALSE) {
        die("Coppermine critical error:<br />Unable to load template file " . $THEME_DIR . TEMPLATE_FILE . "!");
    }
    $template = CPGPluginAPI::filter('template_html', $template);
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_FLAGS}');
    if ($gallery_pos) {
        $template = str_replace('{LANGUAGE_SELECT_FLAGS}', languageSelect('flags'), $template);
    }
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_LIST}');
    if ($gallery_pos) {
        $template = str_replace('{LANGUAGE_SELECT_LIST}', languageSelect('list'), $template);
    }
    $gallery_pos = strpos($template, '{THEME_DIR}');
    $template = str_replace('{THEME_DIR}', $THEME_DIR, $template);
    $gallery_pos = strpos($template, '{THEME_SELECT_LIST}');
    if ($gallery_pos) {
        $template = str_replace('{THEME_SELECT_LIST}', themeSelect('list'), $template);
    }
    // Failsafe-option if JAVASCRIPT-token is missing from custom theme
    if (strpos($template, '{JAVASCRIPT}') === FALSE) {
        if (stripos($template, '</head>') !== FALSE) {
            $template = str_ireplace('</head>', '{JAVASCRIPT}' . $LINEBREAK . '</head>', $template);
        } elseif (stripos($template, '<head>') !== FALSE) {
            $template = str_ireplace('<head>', '<head>' . $LINEBREAK . '{JAVASCRIPT}', $template);
        } elseif (stripos($template, '</title>') !== FALSE) {
            $template = str_ireplace('</title>', '</title>' . $LINEBREAK . '{JAVASCRIPT}', $template);
        }
    }
    $gallery_pos = strpos($template, '{GALLERY}');
    if (!strstr($template, '{CREDITS}')) {
        $template = str_replace('{GALLERY}', '{CREDITS}', $template);
    } else {
        $template = str_replace('{GALLERY}', '', $template);
    }
    $template_header = substr($template, 0, $gallery_pos);
    $template_header = str_replace('{META}', '{META}' . CPGPluginAPI::filter('page_meta', ''), $template_header);
    $template_footer = substr($template, $gallery_pos);
    // Filter gallery header and footer
    $template_header = CPGPluginAPI::filter('gallery_header', $template_header);
    $template_footer = CPGPluginAPI::filter('gallery_footer', $template_footer);
    $add_version_info = '<!--Coppermine Photo Gallery ' . COPPERMINE_VERSION . ' (' . COPPERMINE_VERSION_STATUS . ')-->' . $LINEBREAK . '</body>';
    $template_footer = preg_replace("#</body[^>]*>#", $add_version_info, $template_footer);
}
コード例 #7
0
function doReplacements($_toReplace)
{
    global $CONFIG, $LZLANG;
    if (!isset($LZLANG)) {
        languageSelect();
    }
    $to_replace_nam = array("lang", "config");
    $to_replace_con = array("lang" => $LZLANG, "config" => $CONFIG);
    foreach ($to_replace_nam as $nam_e) {
        foreach ($to_replace_con[$nam_e] as $short => $value) {
            if (!is_array($value)) {
                $_toReplace = str_replace("<!--" . $nam_e . "_" . $short . "-->", $value, $_toReplace);
            } else {
                foreach ($value as $subKey => $subValue) {
                    $_toReplace = str_replace("<!--" . $nam_e . "_" . $subKey . "-->", $subValue, $_toReplace);
                }
            }
        }
    }
    return str_replace("<!--file_chat-->", FILE_CHAT, $_toReplace);
}
コード例 #8
0
ファイル: index.blade.php プロジェクト: fuzhongqing/newoj
    echo getStatusColor($e->result);
    ?>
" href="{{ url('/FAQ/#sys_stauts_') }}<?php 
    echo $e->result;
    ?>
">
												<?php 
    echo getStatusText($e->result);
    ?>
											</a>
											</b>
											<?php 
    echo '</td>';
    echo '<td>' . $e->memory . 'KB</td>';
    echo '<td>' . $e->time . 'MS</td>';
    echo '<td>' . languageSelect($e->language) . '</td>';
    echo '<td>' . $e->code_length . 'B</td>';
    echo '<td>' . $e->in_date . '</td>';
    echo '</tr>';
}
?>
					</tbody>
          </table>
          <?php 
echo $solutions->render();
?>
	  </div>
  </div>
</div>
@endsection
コード例 #9
0
function closeArchiveEntry($_chatId, $_externalFullname, $_externalId, $_internalId, $_groupId, $_email, $_company, $_phone, $_host, $_ip, $_question, $_transcriptSent = false, $_waitingtime, $_startResult, $_endResult)
{
    global $CONFIG, $LZLANG;
    $result = queryDB(true, "SELECT `voucher_id`,`endtime`,`transcript_text`,`iso_language`,`time` FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_type`=1 AND `chat_id`='" . DBManager::RealEscape($_chatId) . "' LIMIT 1;");
    $row = DBManager::FetchArray($result);
    languageSelect($row["iso_language"], true);
    $etpl = $row["transcript_text"];
    $etpl = applyReplacements($etpl, true, false, false);
    CacheManager::SetDataUpdateTime(DATA_UPDATE_KEY_CHATS);
    $_externalFullname = empty($_externalFullname) ? $LZLANG["client_guest"] . " " . getNoName($_externalId . $_ip) : $_externalFullname;
    $filter = new Chat();
    $filter->Generate($_chatId, $_externalFullname, true, true, $_question, $row["time"]);
    $filter->PlainText = applyReplacements($filter->PlainText, true, false, false);
    $filter->HTML = applyReplacements($filter->HTML, true, false, false);
    if (!empty($filter->PlainText)) {
        $etpl = str_replace("%localdate%", date("r", $filter->FirstPost), $etpl);
        if (strpos($etpl, "%transcript%") === false && strpos($etpl, "%mailtext%") === false) {
            $etpl .= $filter->PlainText;
        } else {
            if (strpos($etpl, "%transcript%") !== false) {
                $etpl = str_replace("%transcript%", $filter->PlainText, $etpl);
            } else {
                if (strpos($etpl, "%mailtext%") !== false) {
                    $etpl = str_replace("%mailtext%", $filter->PlainText, $etpl);
                }
            }
        }
    } else {
        $etpl = "";
    }
    $etpl = str_replace(array("%email%", "%eemail%"), $_email, $etpl);
    $etpl = str_replace(array("%fullname%", "%efullname%"), $_externalFullname, $etpl);
    $etpl = str_replace("%rating%", getRatingAVGFromChatId($_chatId), $etpl);
    $name = !empty($_externalFullname) ? ",`fullname`='" . DBManager::RealEscape($_externalFullname) . "'" : "";
    queryDB(true, "UPDATE `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` SET `external_id`='" . DBManager::RealEscape($_externalId) . "',`closed`='" . DBManager::RealEscape(time()) . "'" . $name . ",`internal_id`='" . DBManager::RealEscape($_internalId) . "',`group_id`='" . DBManager::RealEscape($_groupId) . "',`html`='" . DBManager::RealEscape($filter->HTML) . "',`plaintext`='" . DBManager::RealEscape($filter->PlainText) . "',`transcript_text`='" . DBManager::RealEscape($etpl) . "',`email`='" . DBManager::RealEscape($_email) . "',`company`='" . DBManager::RealEscape($_company) . "',`phone`='" . DBManager::RealEscape($_phone) . "',`host`='" . DBManager::RealEscape($_host) . "',`ip`='" . DBManager::RealEscape($_ip) . "',`gzip`=0,`wait`='" . DBManager::RealEscape($_waitingtime) . "',`accepted`='" . DBManager::RealEscape($_startResult) . "',`ended`='" . DBManager::RealEscape($_endResult) . "',`transcript_sent`='" . DBManager::RealEscape(empty($CONFIG["gl_soct"]) && empty($CONFIG["gl_scct"]) && empty($CONFIG["gl_scto"]) && empty($CONFIG["gl_sctg"]) || empty($etpl) || $filter->ElementCount == 0 || $_transcriptSent ? "1" : "0") . "',`question`='" . DBManager::RealEscape(cutString($_question, 255)) . "' WHERE `chat_id`='" . DBManager::RealEscape($_chatId) . "' AND `closed`=0 LIMIT 1;");
    $result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_TICKET_MESSAGES . "` WHERE `channel_id`='" . DBManager::RealEscape($_chatId) . "';");
    if ($result && ($rowc = DBManager::FetchArray($result))) {
        $Ticket = new Ticket($rowc["ticket_id"], true);
        $Ticket->LinkChat($rowc["channel_id"], $rowc["id"]);
    }
}
コード例 #10
0
 /**
  * json方式提交代码
  * @param   $request   整个HTTP请求
  * @return  $response  JSON格式的返回结果
  */
 public function submit(Request $request)
 {
     $reslut = array();
     $problem_id = $request->input('problem_id');
     $language = $request->input('language');
     $code = $request->input('code');
     $cid = $request->input('cid');
     $len = strlen($code);
     if (!Auth::check()) {
         $reslut['level'] = 'error';
         $reslut['message'] = '请先登录';
         return json_encode($reslut);
     }
     $user_id = Auth::user()->user_id;
     if ($len < env('MINLENCODE', 2)) {
         $reslut['level'] = 'warning';
         $reslut['message'] = '代码过短';
         return json_encode($reslut);
     }
     if ($len > env('MAXLENCODE', 65536)) {
         $reslut['level'] = 'warning';
         $reslut['message'] = '代码过长';
         return json_encode($reslut);
     }
     $now = strftime("%Y-%m-%d %X", time() - env('TIMELY', 10));
     $timesql = DB::table('solution')->where('user_id', Auth::user()->user_id)->where('in_date', '>', $now);
     if ($timesql->count() > 0) {
         $reslut['level'] = 'error';
         $reslut['message'] = '提交频率过于频繁请等待' . env('TIMELY', 10) . '秒';
         return json_encode($reslut);
     }
     if (!~env('LANGMSK', 4080) & 1 << $language) {
         $reslut['level'] = 'error';
         $reslut['message'] = '该题不支持 ' . languageSelect($language) . ' 语言';
         return json_encode($reslut);
     }
     $id = null;
     if ($cid == "") {
         $id = DB::table('solution')->insertGetId(['problem_id' => $problem_id, 'user_id' => $user_id, 'in_date' => NOW(), 'language' => $language, 'ip' => $_SERVER['REMOTE_ADDR'], 'code_length' => $len]);
     } else {
         if ($cid == session('cid')) {
             $id = DB::table('solution')->insertGetId(['problem_id' => $problem_id, 'user_id' => $user_id, 'in_date' => NOW(), 'language' => $language, 'ip' => $_SERVER['REMOTE_ADDR'], 'contest_id' => $cid, 'code_length' => $len]);
         } else {
             $reslut['level'] = 'error';
             $reslut['message'] = '提交失败';
         }
     }
     DB::table('source_code')->insert(['solution_id' => $id, 'source' => $code]);
     $reslut['level'] = 'success';
     $reslut['message'] = '提交成功,运行中... RunID:' . $id;
     $reslut['runid'] = $id;
     $reslut['url'] = url('/status/status.json');
     return json_encode($reslut);
 }
コード例 #11
0
 function SendPaidEmail($_purchasedForGroup = "")
 {
     global $CONFIG, $LZLANG;
     $loc = $CONFIG["db"]["cct"][$this->TypeId]->GetLocalization($this->Language);
     if ($loc != null && !empty($loc->EmailVoucherPaid)) {
         $email = $loc->EmailVoucherPaid;
         $email = str_replace("%buyer_first_name%", $this->Firstname, $email);
         $email = str_replace("%buyer_last_name%", $this->Lastname, $email);
         $email = str_replace("%voucher_code%", $this->Id, $email);
         $email = str_replace("%website_name%", $CONFIG["gl_site_name"], $email);
         $email = str_replace("%chat_url%", $this->GetVoucherChatURL($_purchasedForGroup), $email);
         languageSelect($loc->LanguageISOTwoLetter);
         $defmailbox = Mailbox::GetDefaultOutgoing();
         if ($defmailbox != null) {
             sendMail($defmailbox, $this->Email, $defmailbox->Email, $email, $LZLANG["client_voucher_email_subject_paid"]);
         }
     }
 }
コード例 #12
0
ファイル: functions.inc.php プロジェクト: phill104/branches
/**
 * load_template()
 *
 * Load and parse the template.html file
 *
 * @return
 **/
function load_template()
{
    global $THEME_DIR, $CONFIG, $template_header, $template_footer;
    if (file_exists($THEME_DIR . TEMPLATE_FILE)) {
        $template_file = $THEME_DIR . TEMPLATE_FILE;
    } else {
        die("Coppermine critical error:<br />Unable to load template file " . TEMPLATE_FILE . "!");
    }
    $template = fread(fopen($template_file, 'r'), filesize($template_file));
    $template = CPGPluginAPI::filter('template_html', $template);
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_FLAGS}');
    $template = str_replace('{LANGUAGE_SELECT_FLAGS}', languageSelect('flags'), $template);
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_LIST}');
    $template = str_replace('{LANGUAGE_SELECT_LIST}', languageSelect('list'), $template);
    $gallery_pos = strpos($template, '{THEME_DIR}');
    $template = str_replace('{THEME_DIR}', $THEME_DIR, $template);
    $gallery_pos = strpos($template, '{THEME_SELECT_LIST}');
    $template = str_replace('{THEME_SELECT_LIST}', themeSelect('list'), $template);
    $gallery_pos = strpos($template, '{SOCIAL_BOOKMARKS}');
    $template = str_replace('{SOCIAL_BOOKMARKS}', cpgSocialBookmark(), $template);
    $gallery_pos = strpos($template, '{GALLERY}');
    if (!strstr($template, '{CREDITS}')) {
        $template = str_replace('{GALLERY}', '{CREDITS}', $template);
    } else {
        $template = str_replace('{GALLERY}', '', $template);
    }
    $template_header = substr($template, 0, $gallery_pos);
    $template_header = str_replace('{META}', '{META}' . CPGPluginAPI::filter('page_meta', ''), $template_header);
    // Filter gallery header and footer
    $template_header .= CPGPluginAPI::filter('gallery_header', '');
    $template_footer = CPGPluginAPI::filter('gallery_footer', '') . substr($template, $gallery_pos);
    $add_version_info = "<!--Coppermine Photo Gallery " . COPPERMINE_VERSION . " (" . COPPERMINE_VERSION_STATUS . ")-->\n</body>";
    $template_footer = ereg_replace("</body[^>]*>", $add_version_info, $template_footer);
}
コード例 #13
0
ファイル: functions.inc.php プロジェクト: alencarmo/OCF
/**
 * load_template()
 *
 * Load and parse the template.html file
 *
 * @return
 **/
function load_template()
{
    global $THEME_DIR, $CONFIG, $template_header, $template_footer;
    $tmpl_loc = array();
    $tmpl_loc = unserialize(base64_decode(LOC));
    if (file_exists(TEMPLATE_FILE)) {
        $template_file = TEMPLATE_FILE;
    } elseif (file_exists($THEME_DIR . TEMPLATE_FILE)) {
        $template_file = $THEME_DIR . TEMPLATE_FILE;
    } else {
        die("<b>Coppermine critical error</b>:<br />Unable to load template file " . TEMPLATE_FILE . "!</b>");
    }
    $template = fread(fopen($template_file, 'r'), filesize($template_file));
    $template = CPGPluginAPI::filter('template_html', $template);
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_FLAGS}');
    $template = str_replace('{LANGUAGE_SELECT_FLAGS}', languageSelect('flags'), $template);
    $gallery_pos = strpos($template, '{LANGUAGE_SELECT_LIST}');
    $template = str_replace('{LANGUAGE_SELECT_LIST}', languageSelect('list'), $template);
    $gallery_pos = strpos($template, '{THEME_DIR}');
    $template = str_replace('{THEME_DIR}', $THEME_DIR, $template);
    $gallery_pos = strpos($template, '{THEME_SELECT_LIST}');
    $template = str_replace('{THEME_SELECT_LIST}', themeSelect('list'), $template);
    $gallery_pos = strpos($template, $tmpl_loc['l']);
    $template = str_replace($tmpl_loc['l'], $tmpl_loc['s'], $template);
    $template_header = substr($template, 0, $gallery_pos);
    $template_header = str_replace('{META}', '{META}' . CPGPluginAPI::filter('page_meta', ''), $template_header);
    // Filter gallery header and footer
    $template_header .= CPGPluginAPI::filter('gallery_header', '');
    $template_footer = CPGPluginAPI::filter('gallery_footer', '') . substr($template, $gallery_pos);
    $add_version_info = "<!--Coppermine Photo Gallery " . COPPERMINE_VERSION . " (" . COPPERMINE_VERSION_STATUS . ")-->\n</body>";
    $template_footer = ereg_replace("</body[^>]*>", $add_version_info, $template_footer);
}