echo $targetid;
    ?>
').tagSuggest({
						tags: [
	<?php 
    echo implode(',', $dbfields);
    ?>
						]
						});
						});
						// ]]> -->
	</script>
	<?php 
}
zp_apply_filter('texteditor_config', 'zenphoto');
Zenphoto_Authority::printPasswordFormJS();
?>
</head>
<body>
	<?php 
printLogoAndLinks();
?>
	<div id="main">
		<?php 
printTabs();
?>
		<div id="content">
			<?php 
/* Page code */
?>
			<div id="container">
Beispiel #2
0
    /**
     * Print the login form for ZP. This will take into account whether mod_rewrite is enabled or not.
     *
     * @param string $redirect URL to return to after login
     * @param bool $logo set to true to display the ADMIN zenphoto logo.
     * @param bool $showUserField set to true to display the user input
     * @param bool $showCaptcha set to false to not display the forgot password captcha.
     * @param string $hint optional hint for the password
     *
     */
    function printLoginForm($redirect = null, $logo = true, $showUserField = true, $showCaptcha = true, $hint = '')
    {
        global $_zp_login_error, $_zp_captcha, $_zp_gallery;
        if (is_null($redirect)) {
            $redirect = getRequestURI();
        }
        if (is_null($showUserField)) {
            $showUserField = $_zp_gallery->getUserLogonField();
        }
        $cycle = sanitize_numeric(@$_GET['cycle']) + 1;
        if (isset($_POST['user'])) {
            $requestor = sanitize($_POST['user'], 0);
        } else {
            $requestor = '';
        }
        if (empty($requestor)) {
            if (isset($_GET['ref'])) {
                $requestor = sanitize($_GET['ref']);
            }
        }
        $alt_handlers = zp_apply_filter('alt_login_handler', array());
        $star = false;
        $mails = array();
        $info = array('challenge' => '', 'response' => '');
        if (!empty($requestor)) {
            if ($admin = $this->getAnAdmin(array('`user`=' => $requestor, '`valid`=' => 1))) {
                $info = $admin->getChallengePhraseInfo();
            } else {
                $info = array('challenge' => '');
            }
            if (empty($info['challenge']) || $cycle > 2 && $cycle % 5 != 1) {
                $locale = getUserLocale();
                $questions = array();
                foreach (getSerializedArray(getOption('challenge_foils')) as $question) {
                    $questions[] = get_language_string($question);
                }
                $rslt = query('SELECT `challenge_phrase`,`language` FROM ' . prefix('administrators') . ' WHERE `challenge_phrase` IS NOT NULL');
                while ($row = db_fetch_assoc($rslt)) {
                    if (is_null($row['language']) || $row['language'] == $locale) {
                        $q = getSerializedArray($row['challenge_phrase']);
                        $questions[] = $q['challenge'];
                    }
                }
                db_free_result($rslt);
                $questions = array_unique($questions);
                shuffle($questions);
                $info = array('challenge' => $questions[$cycle % count($questions)], 'response' => 0x0);
            } else {
                if ($admin->getEmail()) {
                    $star = $showCaptcha;
                }
            }
        }
        if (!$star) {
            $admins = $this->getAdministrators();
            while (count($admins) > 0) {
                $user = array_shift($admins);
                if ($user['email']) {
                    $star = $showCaptcha;
                }
            }
        }
        $whichForm = sanitize(@$_REQUEST['logon_step']);
        ?>
		<div id="loginform">
			<?php 
        if ($logo) {
            ?>
				<p>
					<img src="<?php 
            echo WEBPATH . '/' . ZENFOLDER;
            ?>
/images/zen-logo.png" title="ZenPhoto" alt="ZenPhoto" />
				</p>
				<?php 
        }
        switch ($_zp_login_error) {
            case 1:
                ?>
					<div class="errorbox" id="message"><h2><?php 
                echo gettext("There was an error logging in.");
                ?>
</h2>
						<?php 
                if ($showUserField) {
                    echo gettext("Check your username and password and try again.");
                } else {
                    echo gettext("Check password and try again.");
                }
                ?>
					</div>
					<?php 
                break;
            case 2:
                ?>
					<div class="messagebox fade-message">
						<h2><?php 
                echo gettext("A reset request has been sent.");
                ?>
</h2>
					</div>
					<?php 
                break;
            default:
                if (!empty($_zp_login_error)) {
                    ?>
						<div class="errorbox fade-message">
							<h2><?php 
                    echo $_zp_login_error;
                    ?>
</h2>
						</div>
						<?php 
                }
                break;
        }
        switch ($whichForm) {
            case 'challenge':
                ?>
					<form name="login" action="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/admin.php" method="post">
						<fieldset id="logon_box">
							<input type="hidden" name="login" value="1" />
							<input type="hidden" name="password" value="challenge" />
							<input type="hidden" name="redirect" value="<?php 
                echo html_encode(pathurlencode($redirect));
                ?>
" />
							<fieldset>
								<legend><?php 
                echo gettext('User');
                ?>
</legend>
								<input class="textfield" name="user" id="user" type="text" size="35" value="<?php 
                echo html_encode($requestor);
                ?>
" />
							</fieldset>
							<?php 
                if ($requestor) {
                    ?>
								<p class="logon_form_text"><?php 
                    echo gettext('Supply the correct response to the question below and you will be directed to a page where you can change your password.');
                    ?>
</p>
								<fieldset><legend><?php 
                    echo gettext('Challenge question:');
                    ?>
</legend>
									<?php 
                    echo html_encode($info['challenge']);
                    ?>
								</fieldset>
								<fieldset><legend><?php 
                    echo gettext('Your response');
                    ?>
</legend>
									<input class="textfield" name="pass" id="pass" type="text" size="35" />
								</fieldset>
								<br />
								<?php 
                } else {
                    ?>
								<p class="logon_form_text">
									<?php 
                    echo gettext('Enter your User ID and press <code>Refresh</code> to get your challenge question.');
                    ?>
								</p>
								<?php 
                }
                ?>
							<div class="buttons">
								<button type="submit" value="<?php 
                echo gettext("Submit");
                ?>
"<?php 
                if (!$info['challenge']) {
                    echo ' disabled="disabled"';
                }
                ?>
 ><img src="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/images/pass.png" alt="" /><?php 
                echo gettext("Submit");
                ?>
</button>
								<button type="button" value="<?php 
                echo gettext("Refresh");
                ?>
" id="challenge_refresh" onclick="launchScript('<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/admin.php', ['logon_step=challenge', 'ref=' + $('#user').val(), 'cycle=<?php 
                echo $cycle;
                ?>
']);" ><img src="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/images/refresh.png" alt="" /><?php 
                echo gettext("Refresh");
                ?>
</button>
								<button type="button" value="<?php 
                echo gettext("Return");
                ?>
" onclick="launchScript('<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/admin.php', ['logon_step=', 'ref=' + $('#user').val(), 'cycle=<?php 
                echo $cycle;
                ?>
']);" ><img src="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/images/refresh.png" alt="" /><?php 
                echo gettext("Return");
                ?>
</button>
							</div>
							<br class="clearall" />
						</fieldset>
						<br />
						<?php 
                if ($star) {
                    ?>
							<p class="logon_link">
								<a href="javascript:launchScript('<?php 
                    echo WEBPATH . '/' . ZENFOLDER;
                    ?>
/admin.php',['logon_step=captcha', 'ref='+$('#user').val()]);" >
									<?php 
                    echo gettext('Request reset by e-mail');
                    ?>
								</a>
							</p>
							<?php 
                }
                ?>
					</form>
					<?php 
                break;
            default:
                Zenphoto_Authority::printPasswordFormJS();
                if (empty($alt_handlers)) {
                    $legend = gettext('Login');
                } else {
                    ?>
						<script type="text/javascript">
							// <!-- <![CDATA[
							var handlers = [];
					<?php 
                    $list = '<select id="logon_choices" onchange="changeHandler(handlers[$(this).val()]);">' . '<option value="0">' . html_encode(get_language_string($_zp_gallery->getTitle())) . '</option>';
                    $c = 0;
                    foreach ($alt_handlers as $handler => $details) {
                        $c++;
                        $details['params'][] = 'redirect=' . $redirect;
                        if (!empty($requestor)) {
                            $details['params'][] = 'requestor=' . $requestor;
                        }
                        echo "handlers[" . $c . "]=['" . $details['script'] . "','" . implode("','", $details['params']) . "'];";
                        $list .= '<option value="' . $c . '">' . $handler . '</option>';
                    }
                    $list .= '</select>';
                    $legend = sprintf(gettext('Logon using:%s'), $list);
                    ?>
							function changeHandler(handler) {
								handler.push('user='******'#user').val());
								var script = handler.shift();
								launchScript(script, handler);
							}
							// ]]> -->
						</script>
						<?php 
                }
                $redirect = zp_apply_filter('login_redirect_link', $redirect);
                ?>
					<form name="login" action="<?php 
                echo html_encode(pathurlencode($redirect));
                ?>
" method="post">
						<input type="hidden" name="login" value="1" />
						<input type="hidden" name="password" value="1" />
						<input type="hidden" name="redirect" value="<?php 
                echo html_encode(pathurlencode($redirect));
                ?>
" />
						<fieldset id="logon_box"><legend><?php 
                echo $legend;
                ?>
</legend>
							<?php 
                if ($showUserField) {
                    //	requires a "user" field
                    ?>
								<fieldset><legend><?php 
                    echo gettext("User");
                    ?>
</legend>
									<input class="textfield" name="user" id="user" type="text" size="35" value="<?php 
                    echo html_encode($requestor);
                    ?>
" />
								</fieldset>
								<?php 
                }
                ?>
							<fieldset><legend><?php 
                echo gettext("Password");
                ?>
</legend>
								<input class="textfield" name="pass" id="pass" type="password" size="35" /><br />
								<label><input type="checkbox" name="disclose_password" id="disclose_password" onclick="togglePassword('');" /><?php 
                echo gettext('Show password');
                ?>
</label>
							</fieldset>
							<br />
							<div class="buttons">
								<button type="submit" value="<?php 
                echo gettext("Log in");
                ?>
" ><img src="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/images/pass.png" alt="" /><?php 
                echo gettext("Log in");
                ?>
</button>
								<button type="reset" value="<?php 
                echo gettext("Reset");
                ?>
" ><img src="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/images/reset.png" alt="" /><?php 
                echo gettext("Reset");
                ?>
</button>
							</div>
							<br class="clearall" />
						</fieldset>
					</form>
					<?php 
                if ($hint) {
                    echo '<p>' . $hint . '</p>';
                }
                if ($showUserField && OFFSET_PATH != 2) {
                    ?>
						<p class="logon_link">
							<a href="javascript:launchScript('<?php 
                    echo WEBPATH . '/' . ZENFOLDER;
                    ?>
/admin.php',['logon_step=challenge', 'ref='+$('#user').val()]);" >
								<?php 
                    echo gettext('I forgot my <strong>User ID</strong>/<strong>Password</strong>');
                    ?>
							</a>
						</p>
						<?php 
                }
                break;
            case 'captcha':
                $captcha = $_zp_captcha->getCaptcha(NULL);
                ?>
					<form name="login" action="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/admin.php" method="post">
						<?php 
                if (isset($captcha['hidden'])) {
                    echo $captcha['hidden'];
                }
                ?>
						<input type="hidden" name="login" value="1" />
						<input type="hidden" name="password" value="captcha" />
						<input type="hidden" name="redirect" value="<?php 
                echo html_encode(pathurlencode($redirect));
                ?>
" />
						<fieldset id="logon_box">
							<fieldset><legend><?php 
                echo gettext('User');
                ?>
</legend>
								<input class="textfield" name="user" id="user" type="text" value="<?php 
                echo html_encode($requestor);
                ?>
" />
							</fieldset>
							<?php 
                if (isset($captcha['html'])) {
                    echo $captcha['html'];
                }
                ?>
							<?php 
                if (isset($captcha['input'])) {
                    ?>
								<fieldset><legend><?php 
                    echo gettext("Enter CAPTCHA");
                    ?>
</legend>
									<?php 
                    echo $captcha['input'];
                    ?>
								</fieldset>
								<?php 
                }
                ?>
							<br />
							<div class="buttons">
								<button type="submit" value="<?php 
                echo gettext("Request");
                ?>
" ><img src="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/images/pass.png" alt="" /><?php 
                echo gettext("Request password reset");
                ?>
</button>
								<button type="button" value="<?php 
                echo gettext("Return");
                ?>
" onclick="launchScript('<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/admin.php', ['logon_step=', 'ref=' + $('#user').val()]);" ><img src="<?php 
                echo WEBPATH . '/' . ZENFOLDER;
                ?>
/images/refresh.png" alt="" /><?php 
                echo gettext("Return");
                ?>
</button>
							</div>
							<br class="clearall" />
						</fieldset>
					</form>
					<?php 
                break;
        }
        ?>
		</div>
		<?php 
    }