</head>
<body>
	<?php 
printLogoAndLinks();
?>
	<div id="main">
		<?php 
printTabs();
?>
		<div id="content">
			<?php 
/* Page code */
?>
			<div id="container">
				<?php 
$subtab = getSubtabs();
if (isset($_GET['tag_parse_error'])) {
    echo '<div class="errorbox fade-message">';
    echo "<h2>";
    if ($_GET['tag_parse_error'] === '0') {
        echo gettext("Forbidden tag.");
    } else {
        echo gettext("Your Allowed tags change did not parse successfully.");
    }
    echo "</h2>";
    echo '</div>';
}
if (isset($_GET['post_error'])) {
    echo '<div class="errorbox">';
    echo "<h2>" . gettext('Error') . "</h2>";
    echo gettext('The form submission is incomplete. Perhaps the form size exceeds configured server or browser limits.');
function printSubtabs()
{
    global $zenphoto_tabs, $_zp_admin_tab, $_zp_admin_subtab;
    $tabs = @$zenphoto_tabs[$_zp_admin_tab]['subtabs'];
    if (isset($zenphoto_tabs[$_zp_admin_tab]['alert'])) {
        $alert = $zenphoto_tabs[$_zp_admin_tab]['alert'];
    } else {
        $alert = array();
    }
    $current = getSubtabs();
    if (!empty($tabs)) {
        $chars = 0;
        foreach ($tabs as $atab => $val) {
            $chars = $chars + mb_strlen($atab);
        }
        switch (getOption('locale')) {
            case 'zh_CN':
            case 'zh_TW':
            case 'ja_JP':
                $sub_tab_space = count($tabs) * 3 + $chars;
                break;
            default:
                $sub_tab_space = round((count($tabs) * 32 + round($chars * 7.5)) / 11.5);
                break;
        }
        ?>
			<ul class="subnav" style="width: <?php 
        echo $sub_tab_space;
        ?>
em">
				<?php 
        foreach ($tabs as $key => $link) {
            $i = strrpos($link, 'tab=');
            $amp = strrpos($link, '&');
            if ($i === false) {
                $tab = $_zp_admin_subtab;
            } else {
                if ($amp > $i) {
                    $source = substr($link, 0, $amp);
                } else {
                    $source = $link;
                }
                $tab = substr($source, $i + 4);
            }
            if (empty($link)) {
                $link = getRequestURI();
            } else {
                if (strpos($link, '/') !== 0) {
                    // zp_core relative
                    $link = WEBPATH . '/' . ZENFOLDER . '/' . $link;
                } else {
                    $link = WEBPATH . $link;
                }
            }
            $class = '';
            if ($tab == $current) {
                $class = 'current';
            } else {
                if (in_array($key, $alert)) {
                    $class = 'alertsubtab';
                }
            }
            echo '<li' . ($class ? ' class="' . $class . '"' : '') . '><a href="' . html_encode($link) . '">' . html_encode(ucfirst($key)) . '</a></li>' . "\n";
        }
        ?>
			</ul>
			<?php 
    }
    return $current;
}
function printSubtabs()
{
    global $zenphoto_tabs, $_zp_admin_tab, $_zp_admin_subtab;
    $tabs = @$zenphoto_tabs[$_zp_admin_tab]['subtabs'];
    $current = getSubtabs();
    if (!empty($tabs)) {
        $chars = 0;
        foreach ($tabs as $atab => $val) {
            $chars = $chars + mb_strlen($atab);
        }
        switch (getOption('locale')) {
            case 'zh_CN':
            case 'zh_TW':
            case 'ja_JP':
                $sub_tab_space = count($tabs) * 3 + $chars;
                break;
            default:
                $sub_tab_space = round((count($tabs) * 32 + round($chars * 7.5)) / 11.5);
                break;
        }
        ?>
			<ul class="subnav" style="width: <?php 
        echo $sub_tab_space;
        ?>
em">
				<?php 
        foreach ($tabs as $key => $link) {
            $i = strrpos($link, 'tab=');
            $amp = strrpos($link, '&');
            if ($i === false) {
                $tab = $_zp_admin_subtab;
            } else {
                if ($amp > $i) {
                    $source = substr($link, 0, $amp);
                } else {
                    $source = $link;
                }
                $tab = substr($source, $i + 4);
            }
            if (!$link) {
                $bt = debug_backtrace();
                $bt = array_shift($bt);
                if (isset($bt['file'])) {
                    $link = str_replace(SERVERPATH, '', str_replace('\\', '/', $bt['file']));
                }
            }
            if (strpos($link, '/') !== 0) {
                // zp_core relative
                $link = WEBPATH . '/' . ZENFOLDER . '/' . $link;
            } else {
                $link = WEBPATH . $link;
            }
            echo '<li' . ($current == $tab ? ' class="current"' : '') . '><a href="' . html_encode($link) . '">' . html_encode(ucfirst($key)) . '</a></li>' . "\n";
        }
        ?>
			</ul>
			<?php 
    }
    return $current;
}
$_zp_null_account = $_zp_loggedin == ADMIN_RIGHTS;
$tabs = array(gettext("admin information") => 'admin-options.php?tab=admin');
if (!$_zp_null_account) {
    if ($_zp_loggedin & (ADMIN_RIGHTS | OPTIONS_RIGHTS)) {
        $tabs[gettext("gallery configuration")] = 'admin-options.php?tab=gallery';
        $tabs[gettext("image display")] = 'admin-options.php?tab=image';
        $tabs[gettext("comment configuration")] = 'admin-options.php?tab=comments';
    }
    if ($_zp_loggedin & (ADMIN_RIGHTS | THEMES_RIGHTS)) {
        $tabs[gettext("theme options")] = 'admin-options.php?tab=theme';
    }
    if ($_zp_loggedin & ADMIN_RIGHTS) {
        $tabs[gettext("plugin options")] = 'admin-options.php?tab=plugin';
    }
}
$subtab = getSubtabs($tabs);
if ($subtab == 'gallery' || $subtab == 'image') {
    $sql = 'SHOW COLUMNS FROM ';
    if ($subtab == 'image') {
        $sql .= prefix('images');
        $targetid = 'customimagesort';
    } else {
        $sql .= prefix('albums');
        $targetid = 'customalbumsort';
    }
    $result = mysql_query($sql);
    $dbfields = array();
    while ($row = mysql_fetch_row($result)) {
        $dbfields[] = "'" . $row[0] . "'";
    }
    sort($dbfields);
function printSubtabs($tabs)
{
    $current = getSubtabs($tabs);
    ?>
	<ul class="subnav">
	<?php 
    foreach ($tabs as $key => $link) {
        $tab = substr($link, strrpos($link, '=') + 1);
        echo '<li' . ($current == $tab ? ' class="current"' : '') . '>' . '<a href = "' . WEBPATH . '/' . ZENFOLDER . '/' . $link . '">' . $key . '</a></li>' . "\n";
    }
    ?>
	</ul>
	<?php 
    return $current;
}