/** * generates a simple captcha for comments * * Thanks to gregb34 who posted the original code * * Returns the captcha code string and image URL (via the $image parameter). * * @return string; */ function getCaptcha($prompt = NULL) { $theme = getOption('reCaptcha_theme'); $publicKey = getOption('reCaptcha_public_key'); $lang = strtolower(substr(ZENPHOTO_LOCALE, 0, 2)); if (!getOption('reCaptcha_public_key')) { return array('input' => '', 'html' => '<p class="errorbox">' . gettext('reCAPTCHA is not properly configured.') . '</p>', 'hidden' => ''); } else { $source = getPlugin('reCaptcha/' . $theme . '/reCaptcha.html'); if ($source) { $webpath = dirname(getplugin('reCaptcha/' . $theme . '/reCaptcha.html', false, true)); $tr = array('__GETHELP__' => gettext("Help"), '__GETIMAGE__' => gettext("Get a visual challenge"), '__GETAUDIO__' => gettext("Get an audio challenge"), '__RELOAD__' => gettext("Get another challenge"), '__WORDS__' => gettext("Type the two words"), '__NUMBERS__' => gettext("Type what you hear"), '__ERROR__' => gettext("Incorrect please try again"), '__SOURCEWEBPATH__' => $webpath); $html = strtr(file_get_contents($source), $tr); $theme = 'custom'; // to tell google to use the above } else { $html = ''; } $themejs = '<script type="text/javascript">' . "\n" . " var RecaptchaOptions = {\n"; if (!in_array($lang, array('de', 'en', 'es', 'fr', 'nl', 'ru', 'pt', 'tr'))) { // google's list as of June 2013 $themejs .= " custom_translations : {\n" . " instructions_visual : 'Type the two words',\n" . " instructions_audio : 'Type what you hear',\n" . " play_again : 'Play sound again',\n" . " cant_hear_this : 'Download the sound as MP3',\n" . " visual_challenge : 'Get a visual challenge',\n" . " audio_challenge : 'Get an audio challenge',\n" . " refresh_btn : 'Get another challenge',\n" . " help_btn : 'Help',\n" . " incorrect_try_again : 'Incorrect please try again',\n" . " },\n"; } $themejs .= " lang : '{$lang}',\n" . "\t\t\t\ttheme : '{$theme}'\n" . "\t\t\t\t};\n" . "</script>\n"; $html .= recaptcha_get_html($publicKey, NULL, secureServer()); return array('html' => '<label class="captcha_label">' . $prompt . '</label>', 'input' => $themejs . $html); } }
* @package plugins * @subpackage theme */ if (!defined('OFFSET_PATH')) { define('OFFSET_PATH', 3); require_once dirname(dirname(__FILE__)) . '/functions.php'; if (isset($_GET['action']) && $_GET['action'] == 'clear_rating') { if (!zp_loggedin(ADMIN_RIGHTS)) { // prevent nefarious access to this page. header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php?from=' . currentRelativeURL()); exitZP(); } require_once dirname(dirname(__FILE__)) . '/admin-functions.php'; if (session_id() == '') { // force session cookie to be secure when in https if (secureServer()) { $CookieInfo = session_get_cookie_params(); session_set_cookie_params($CookieInfo['lifetime'], $CookieInfo['path'], $CookieInfo['domain'], TRUE); } session_start(); } XSRFdefender('clear_rating'); query('UPDATE ' . prefix('images') . ' SET total_value=0, total_votes=0, rating=0, used_ips="" '); query('UPDATE ' . prefix('albums') . ' SET total_value=0, total_votes=0, rating=0, used_ips="" '); query('UPDATE ' . prefix('news') . ' SET total_value=0, total_votes=0, rating=0, used_ips="" '); query('UPDATE ' . prefix('pages') . ' SET total_value=0, total_votes=0, rating=0, used_ips="" '); header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php?action=external&msg=' . gettext('All ratings have been set to <em>unrated</em>.')); exitZP(); } } $plugin_is_filter = 5 | ADMIN_PLUGIN | THEME_PLUGIN;
/** * * Starts a zenphoto session (perhaps a secure one) */ function zp_session_start() { global $_zp_conf_vars; if (session_id() == '') { // insure that the session data has a place to be saved if (isset($_zp_conf_vars['session_save_path'])) { session_save_path($_zp_conf_vars['session_save_path']); } $_session_path = session_save_path(); if (ini_get('session.save_handler') == 'files' && !file_exists($_session_path) || !is_writable($_session_path)) { mkdir_recursive(SERVERPATH . '/' . DATA_FOLDER . '/PHP_sessions', FOLDER_MOD); session_save_path(SERVERPATH . '/' . DATA_FOLDER . '/PHP_sessions'); } if (secureServer()) { // force session cookie to be secure when in https $CookieInfo = session_get_cookie_params(); session_set_cookie_params($CookieInfo['lifetime'], $CookieInfo['path'], $CookieInfo['domain'], TRUE); } return session_start(); } return NULL; }
/** * * Starts a zenphoto session (perhaps a secure one) */ function zp_session_start() { if (session_id() == '') { // force session cookie to be secure when in https if (secureServer()) { $CookieInfo = session_get_cookie_params(); session_set_cookie_params($CookieInfo['lifetime'], $CookieInfo['path'], $CookieInfo['domain'], TRUE); } session_start(); } }
/** * Set log-in cookie for a user * @param object $user */ static function logUser($user) { $user->set('lastloggedin', $user->get('loggedin')); $user->set('loggedin', date('Y-m-d H:i:s')); $user->save(); zp_setCookie("zp_user_auth", $user->getPass() . '.' . $user->getID(), NULL, NULL, secureServer()); }
/** * Set log-in cookie for a user * @param string $user */ function logUser($user) { $user->lastlogon = $user->get('loggedin'); $user->set('loggedin', date('Y-m-d H:i:s')); $user->save(); zp_setCookie("zenphoto_auth", $user->getPass(), NULL, NULL, secureServer()); }