Пример #1
0
 static function new_image($image)
 {
     global $_zp_exifvars;
     $entry_locale = getUserLocale();
     $languages = generateLanguageList();
     $languageTags = $element = array();
     $candidates = self::getTaggingItems();
     foreach ($candidates as $key) {
         if ($meta = $image->get($key)) {
             setupCurrentLocale('en_US');
             $en_us = $element[] = exifTranslate($meta);
             foreach ($languages as $language) {
                 setupCurrentLocale($language);
                 $xlated = exifTranslate($meta);
                 if ($xlated != $en_us) {
                     // the string has a translation in this language
                     $element[] = $xlated;
                     $languageTags[$language] = $xlated;
                 }
             }
         }
     }
     setupCurrentLocale($entry_locale);
     $element = array_unique(array_merge($image->getTags(), $element));
     $image->setTags($element);
     $image->save();
     foreach ($languageTags as $language => $tag) {
         $sql = 'UPDATE ' . prefix('tags') . ' SET `language`=' . db_quote($language) . ' WHERE `name`=' . db_quote($tag) . ' AND `language`=NULL OR `language` LIKE ""';
         query($sql, false);
     }
     return $image;
 }
Пример #2
0
 function __construct()
 {
     if (OFFSET_PATH == 2) {
         $seo_locale = extensionEnabled('seo_locale') && getOption('dynamic_locale_subdomain') != 2;
         setOptionDefault('dynamic_locale_visual', 0);
         setOptionDefault('dynamic_locale_subdomain', (int) $seo_locale);
         setOptionDefault('dynamic_locale_base', getUserLocale());
     }
 }
Пример #3
0
/**
 * returns a serialized "multilingual array" of translations
 * Used for setting default options with multi-lingual strings.
 * @param string $text to be translated
 */
function getAllTranslations($text)
{
    $entry_locale = getUserLocale();
    $result = array('en_US' => $text);
    $languages = generateLanguageList();
    $key = array_search('en_US', $languages);
    unset($languages[$key]);
    foreach ($languages as $language) {
        setupCurrentLocale($language);
        $xlated = gettext($text);
        if ($xlated != $text) {
            // the string has a translation in this language
            $result[$language] = $xlated;
        }
    }
    setupCurrentLocale($entry_locale);
    return serialize($result);
}
Пример #4
0
 /**
  * Does the log handling
  *
  * @param int $success
  * @param string $user
  * @param string $name
  * @param string $ip
  * @param string $type
  * @param string $authority kind of login
  * @param string $addl more info
  */
 private static function Logger($success, $user, $name, $action, $authority, $addl = NULL)
 {
     global $_zp_authority, $_zp_mutex;
     $pattern = '~^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$~';
     $forwardedIP = NULL;
     $ip = sanitize($_SERVER['REMOTE_ADDR']);
     if (!preg_match($pattern, $ip)) {
         $ip = NULL;
     }
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $forwardedIP = sanitize($_SERVER['HTTP_X_FORWARDED_FOR']);
         if (preg_match($pattern, $forwardedIP)) {
             $ip .= ' {' . $forwardedIP . '}';
         }
     }
     $admin = $_zp_authority->getMasterUser();
     $locale = $admin->getLanguage();
     if (empty($locale)) {
         $locale = 'en_US';
     }
     $cur_locale = getUserLocale();
     setupCurrentLocale($locale);
     //	the log will be in the language of the master user.
     switch ($action) {
         case 'clear_log':
             $type = gettext('Log reset');
             break;
         case 'delete_log':
             $type = gettext('Log deleted');
             break;
         case 'download_log':
             $type = gettext('Log downloaded');
             break;
         case 'setup_install':
             $type = gettext('Install');
             $addl = gettext('version') . ' ' . ZENPHOTO_VERSION . '[' . ZENPHOTO_RELEASE . "]";
             if (!zpFunctions::hasPrimaryScripts()) {
                 $addl .= ' ' . gettext('clone');
             }
             break;
         case 'setup_proptect':
             $type = gettext('Protect setup scripts');
             break;
         case 'user_new':
             $type = gettext('Request add user');
             break;
         case 'user_update':
             $type = gettext('Request update user');
             break;
         case 'user_delete':
             $type = gettext('Request delete user');
             break;
         case 'XSRF_blocked':
             $type = gettext('Cross Site Reference');
             break;
         case 'blocked_album':
             $type = gettext('Album access');
             break;
         case 'blocked_access':
             $type = gettext('Admin access');
             break;
         case 'Front-end':
             $type = gettext('Guest login');
             break;
         case 'Back-end':
             $type = gettext('Admin login');
             break;
         case 'auth_cookie':
             $type = gettext('Authorization cookie check');
             break;
         default:
             $type = $action;
             break;
     }
     $file = SERVERPATH . '/' . DATA_FOLDER . '/security.log';
     $max = getOption('security_log_size');
     $_zp_mutex->lock();
     if ($max && @filesize($file) > $max) {
         switchLog('security');
     }
     $preexists = file_exists($file) && filesize($file) > 0;
     $f = fopen($file, 'a');
     if ($f) {
         if (!$preexists) {
             // add a header
             fwrite($f, gettext('date' . "\t" . 'requestor’s IP' . "\t" . 'type' . "\t" . 'user ID' . "\t" . 'user name' . "\t" . 'outcome' . "\t" . 'authority' . "\tadditional information\n"));
         }
         $message = date('Y-m-d H:i:s') . "\t";
         $message .= $ip . "\t";
         $message .= $type . "\t";
         $message .= $user . "\t";
         $message .= $name . "\t";
         switch ($success) {
             case 0:
                 $message .= gettext("Failed") . "\t";
                 break;
             case 1:
                 $message .= gettext("Success") . "\t";
                 $message .= substr($authority, 0, strrpos($authority, '_auth'));
                 break;
             case 2:
                 $message .= gettext("Blocked") . "\t";
                 break;
             default:
                 $message .= $success . "\t";
         }
         if ($addl) {
             $message .= "\t" . $addl;
         }
         fwrite($f, $message . "\n");
         fclose($f);
         clearstatcache();
         if (!$preexists) {
             @chmod($file, 0660 & CHMOD_VALUE);
             if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
                 $permission = fileperms($file) & 0700;
                 //	on Windows owner==group==public
                 $check = $permission != 0600 & CHMOD_VALUE;
             } else {
                 $permission = fileperms($file) & 0777;
                 $check = $permission != 0660 & CHMOD_VALUE;
             }
             if ($check) {
                 $f = fopen($file, 'a');
                 fwrite($f, "\t\t" . gettext('Set Security log permissions') . "\t\t\t" . gettext('Failed') . "\t\t" . sprintf(gettext('File permissions of Security log are %04o'), $permission) . "\n");
                 fclose($f);
                 clearstatcache();
             }
         }
     }
     $_zp_mutex->unlock();
     setupCurrentLocale($cur_locale);
     //	restore to whatever was in effect.
 }
Пример #5
0
     $separator = '.';
 }
 $x = array_slice(explode($separator, $full_ip), 0, $__config['accessThreshold_SENSITIVITY']);
 $ip = implode($separator, $x);
 unset($x);
 if (isset($recentIP[$ip]['lastAccessed']) && $__time - $recentIP[$ip]['lastAccessed'] > $__config['accessThreshold_IP_ACCESS_WINDOW']) {
     $recentIP[$ip] = array('accessed' => array(), 'locales' => array(), 'blocked' => 0, 'interval' => 0);
 }
 $recentIP[$ip]['lastAccessed'] = $__time;
 if (@$recentIP[$ip]['blocked']) {
     file_put_contents(SERVERPATH . '/' . DATA_FOLDER . '/recentIP', serialize($recentIP));
     $mu->unlock();
     exitZP();
 } else {
     $recentIP[$ip]['accessed'][] = array('time' => $__time, 'ip' => $full_ip);
     $__locale = getUserLocale();
     if (isset($recentIP[$ip]['locales'][$__locale])) {
         $recentIP[$ip]['locales'][$__locale]['ip'][$full_ip] = $__time;
     } else {
         $recentIP[$ip]['locales'][$__locale] = array('time' => $__time, 'ip' => array($full_ip => $__time));
     }
     $__previous = $__interval = $__count = 0;
     array_walk($recentIP[$ip]['locales'], 'accessThreshold::walk', $__time);
     foreach ($recentIP[$ip]['locales'] as $key => $data) {
         if (is_null($data)) {
             unset($recentIP[$ip]['locales'][$key]);
         }
     }
     if ($__count > $__config['accessThreshold_LocaleCount']) {
         $recentIP[$ip]['blocked'] = 1;
     }
Пример #6
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 
    }
Пример #7
0
/**
 * Generates an editable list of language strings
 *
 * @param string $dbstring either a serialized languag string array or a single string
 * @param string $name the prefix for the label, id, and name tags
 * @param bool $textbox set to true for a textbox rather than a text field
 * @param string $locale optional locale of the translation desired
 * @param string $edit optional class
 */
function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '')
{
    global $_zp_languages, $_zp_active_languages, $_zp_current_locale;
    if (!empty($edit)) {
        $edit = ' class="' . $edit . '"';
    }
    if (is_null($locale)) {
        if (is_null($_zp_current_locale)) {
            $_zp_current_locale = getUserLocale();
            if (empty($_zp_current_locale)) {
                $_zp_current_locale = 'en_US';
            }
        }
        $locale = $_zp_current_locale;
    }
    if (preg_match('/^a:[0-9]+:{/', $dbstring)) {
        $strings = unserialize($dbstring);
    } else {
        $strings = array($locale => $dbstring);
    }
    if (getOption('multi_lingual')) {
        if (is_null($_zp_active_languages)) {
            $_zp_active_languages = generateLanguageList();
        }
        $emptylang = array_flip($_zp_active_languages);
        unset($emptylang['']);
        natsort($emptylang);
        if ($textbox) {
            $class = 'box';
        } else {
            $class = '';
        }
        echo "<ul class=\"language_string_list" . $class . "\">\n";
        $empty = true;
        foreach ($emptylang as $key => $lang) {
            if (isset($strings[$key])) {
                $string = $strings[$key];
                if (!empty($string)) {
                    unset($emptylang[$key]);
                    $empty = false;
                    echo '<li><label for="' . $name . '_' . $key . '">';
                    echo $lang;
                    if ($textbox) {
                        echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . ' cols="' . TEXTAREA_COLUMNS . '"	style="width: 310px" rows="6">' . $string . '</textarea>';
                    } else {
                        echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '" type="text" value="' . $string . '" style="width: 310px" size="' . TEXT_INPUT_SIZE . '" />';
                    }
                    echo "</label></li>\n";
                }
            }
        }
        if ($empty) {
            $element = $emptylang[$locale];
            unset($emptylang[$locale]);
            $emptylang = array_merge(array($locale => $element), $emptylang);
        }
        foreach ($emptylang as $key => $lang) {
            echo '<li><label for="' . $name . '_' . $key . '">';
            echo $lang;
            if ($textbox) {
                echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . ' cols="' . TEXTAREA_COLUMNS . '"	style="width: 310px" rows="6"></textarea>';
            } else {
                echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '" type="text" value="" style="width: 310px" size="' . TEXT_INPUT_SIZE . '" />';
            }
            echo "</label></li>\n";
        }
        echo "</ul>\n";
    } else {
        if (empty($locale)) {
            $locale = 'en_US';
        }
        if (isset($strings[$locale])) {
            $dbstring = $strings[$locale];
        } else {
            $dbstring = array_shift($strings);
        }
        if ($textbox) {
            echo '<textarea name="' . $name . '_' . $locale . '"' . $edit . ' cols="' . TEXTAREA_COLUMNS . '"	rows="6">' . $dbstring . '</textarea>';
        } else {
            echo '<input id="' . $name . '_' . $locale . '" name="' . $name . '_' . $locale . '" type="text" value="' . $dbstring . '" size="' . TEXT_INPUT_SIZE . '" />';
        }
    }
}
Пример #8
0
    /**
     * Prints html meta data to be used in the <head> section of a page
     *
     */
    static function getHTMLMetaData()
    {
        global $_zp_gallery, $_zp_galley_page, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_gallery_page, $_zp_current_category, $_zp_authority, $_zp_conf_vars, $_myFavorites, $htmlmetatags_need_cache, $_zp_page;
        zp_register_filter('image_processor_uri', 'htmlmetatags::ipURI');
        $host = sanitize("http://" . $_SERVER['HTTP_HOST']);
        $url = $host . getRequestURI();
        // Convert locale shorttag to allowed html meta format
        $locale = str_replace("_", "-", getUserLocale());
        $canonicalurl = '';
        // generate page title, get date
        $pagetitle = "";
        // for gallery index setup below switch
        $date = strftime(DATE_FORMAT);
        // if we don't have a item date use current date
        $desc = getBareGalleryDesc();
        $thumb = '';
        if (getOption('htmlmeta_sitelogo')) {
            $thumb = getOption('htmlmeta_sitelogo');
        }
        if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
            $ogimage_width = getOption('htmlmeta_ogimage_width');
            $ogimage_height = getOption('htmlmeta_ogimage_height');
            if (empty($ogimage_width)) {
                $ogimage_width = 1280;
            }
            if (empty($ogimage_height)) {
                $ogimage_height = 900;
            }
        }
        $type = 'article';
        switch ($_zp_gallery_page) {
            case 'index.php':
                $desc = getBareGalleryDesc();
                //$canonicalurl = $host . getGalleryIndexURL();
                $canonicalurl = $host . getPageNumURL($_zp_page);
                $type = 'website';
                break;
            case 'album.php':
                $pagetitle = getBareAlbumTitle() . " - ";
                $date = getAlbumDate();
                $desc = getBareAlbumDesc();
                $canonicalurl = $host . getPageNumURL($_zp_page);
                if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                    $thumbimg = $_zp_current_album->getAlbumThumbImage();
                    getMaxSpaceContainer($ogimage_width, $ogimage_height, $thumbimg, false);
                    $thumb = $host . html_encode(pathurlencode($thumbimg->getCustomImage(NULL, $ogimage_width, $ogimage_height, NULL, NULL, NULL, NULL, false, NULL)));
                }
                break;
            case 'image.php':
                $pagetitle = getBareImageTitle() . " (" . getBareAlbumTitle() . ") - ";
                $date = getImageDate();
                $desc = getBareImageDesc();
                $canonicalurl = $host . getImageURL();
                if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                    $thumb = $host . html_encode(pathurlencode(getCustomSizedImageMaxSpace($ogimage_width, $ogimage_height)));
                }
                break;
            case 'news.php':
                if (function_exists("is_NewsArticle")) {
                    if (is_NewsArticle()) {
                        $pagetitle = getBareNewsTitle() . " - ";
                        $date = getNewsDate();
                        $desc = trim(getBare(getNewsContent()));
                        $canonicalurl = $host . $_zp_current_zenpage_news->getLink();
                    } else {
                        if (is_NewsCategory()) {
                            $pagetitle = $_zp_current_category->getTitlelink() . " - ";
                            $date = strftime(DATE_FORMAT);
                            $desc = trim(getBare($_zp_current_category->getDesc()));
                            $canonicalurl = $host . $_zp_current_category->getLink();
                            $type = 'category';
                        } else {
                            $pagetitle = gettext('News') . " - ";
                            $desc = '';
                            $canonicalurl = $host . getNewsIndexURL();
                            $type = 'website';
                        }
                    }
                    if ($_zp_page != 1) {
                        $canonicalurl .= '/' . $_zp_page;
                    }
                }
                break;
            case 'pages.php':
                $pagetitle = getBarePageTitle() . " - ";
                $date = getPageDate();
                $desc = trim(getBare(getPageContent()));
                $canonicalurl = $host . $_zp_current_zenpage_page->getLink();
                break;
            default:
                // for all other possible static custom pages
                $custompage = stripSuffix($_zp_gallery_page);
                $standard = array('contact' => gettext('Contact'), 'register' => gettext('Register'), 'search' => gettext('Search'), 'archive' => gettext('Archive view'), 'password' => gettext('Password required'));
                if (is_object($_myFavorites)) {
                    $standard['favorites'] = gettext('My favorites');
                }
                if (array_key_exists($custompage, $standard)) {
                    $pagetitle = $standard[$custompage] . " - ";
                } else {
                    $pagetitle = $custompage . " - ";
                }
                $desc = '';
                $canonicalurl = $host . getCustomPageURL($custompage);
                if ($_zp_page != 1) {
                    $canonicalurl .= '/' . $_zp_page;
                }
                break;
        }
        // shorten desc to the allowed 200 characters if necesssary.
        $desc = html_encode(trim(substr(getBare($desc), 0, 160)));
        $pagetitle = $pagetitle . getBareGalleryTitle();
        // get master admin
        $admin = $_zp_authority->getMasterUser();
        $author = $admin->getName();
        $meta = '';
        if (getOption('htmlmeta_http-equiv-cache-control')) {
            $meta .= '<meta http-equiv="Cache-control" content="' . getOption("htmlmeta_cache_control") . '">' . "\n";
        }
        if (getOption('htmlmeta_http-equiv-pragma')) {
            $meta .= '<meta http-equiv="pragma" content="' . getOption("htmlmeta_pragma") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-keywords')) {
            $meta .= '<meta name="keywords" content="' . htmlmetatags::getMetaKeywords() . '">' . "\n";
        }
        if (getOption('htmlmeta_name-description')) {
            $meta .= '<meta name="description" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_name-page-topic')) {
            $meta .= '<meta name="page-topic" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_name-robots')) {
            $meta .= '<meta name="robots" content="' . getOption("htmlmeta_robots") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-publisher')) {
            $meta .= '<meta name="publisher" content="' . FULLWEBPATH . '">' . "\n";
        }
        if (getOption('htmlmeta_name-creator')) {
            $meta .= '<meta name="creator" content="' . FULLWEBPATH . '">' . "\n";
        }
        if (getOption('htmlmeta_name-author')) {
            $meta .= '<meta name="author" content="' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-copyright')) {
            $meta .= '<meta name="copyright" content=" (c) ' . FULLWEBPATH . ' - ' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-rights')) {
            $meta .= '<meta name="rights" content="' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-generator')) {
            $meta .= '<meta name="generator" content="Zenphoto ' . ZENPHOTO_VERSION . '">' . "\n";
        }
        if (getOption('htmlmeta_name-revisit-after')) {
            $meta .= '<meta name="revisit-after" content="' . getOption("htmlmeta_revisit_after") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-expires')) {
            $expires = getOption("htmlmeta_expires");
            if ($expires == (int) $expires) {
                $expires = preg_replace('|\\s\\-\\d+|', '', date('r', time() + $expires)) . ' GMT';
            }
            $meta .= '<meta name="expires" content="' . $expires . '">' . "\n";
        }
        // OpenGraph meta
        if (getOption('htmlmeta_og-title')) {
            $meta .= '<meta property="og:title" content="' . $pagetitle . '">' . "\n";
        }
        if (getOption('htmlmeta_og-image') && !empty($thumb)) {
            $meta .= '<meta property="og:image" content="' . $thumb . '">' . "\n";
        }
        if (getOption('htmlmeta_og-description')) {
            $meta .= '<meta property="og:description" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_og-url')) {
            $meta .= '<meta property="og:url" content="' . html_encode($url) . '">' . "\n";
        }
        if (getOption('htmlmeta_og-type')) {
            $meta .= '<meta property="og:type" content="' . $type . '">' . "\n";
        }
        // Social network extras
        if (getOption('htmlmeta_name-pinterest')) {
            $meta .= '<meta name="pinterest" content="nopin">' . "\n";
        }
        // dissalow users to pin images on Pinterest
        // Twitter card
        $twittername = getOption('htmlmeta_twittername');
        if (getOption('htmlmeta_twittercard') || !empty($twittername)) {
            $meta .= '<meta property="twitter:creator" content="' . $twittername . '">' . "\n";
            $meta .= '<meta property="twitter:site" content="' . $twittername . '">' . "\n";
            $meta .= '<meta property="twitter:card" content="summary">' . "\n";
            $meta .= '<meta property="twitter:title" content="' . $pagetitle . '">' . "\n";
            $meta .= '<meta property="twitter:description" content="' . $desc . '">' . "\n";
            if (!empty($thumb)) {
                $meta .= '<meta property="twitter:image" content="' . $thumb . '">' . "\n";
            }
        }
        // Canonical url
        if (getOption('htmlmeta_canonical-url')) {
            $meta .= '<link rel="canonical" href="' . $canonicalurl . '">' . "\n";
            if (METATAG_LOCALE_TYPE) {
                $langs = generateLanguageList();
                if (count($langs) != 1) {
                    foreach ($langs as $text => $lang) {
                        $langcheck = zpFunctions::getLanguageText($lang, '-');
                        //	for hreflang we need en-US
                        if ($langcheck != $locale) {
                            switch (METATAG_LOCALE_TYPE) {
                                case 1:
                                    $altlink = seo_locale::localePath(true, $lang);
                                    break;
                                case 2:
                                    $altlink = dynamic_locale::fullHostPath($lang);
                                    break;
                            }
                            switch ($_zp_gallery_page) {
                                case 'index.php':
                                    $altlink .= '/';
                                    break;
                                case 'gallery.php':
                                    $altlink .= '/' . _PAGE_ . '/gallery';
                                    break;
                                case 'album.php':
                                    $altlink .= '/' . html_encode($_zp_current_album->name) . '/';
                                    break;
                                case 'image.php':
                                    $altlink .= '/' . html_encode($_zp_current_album->name) . '/' . html_encode($_zp_current_image->filename) . IM_SUFFIX;
                                    break;
                                case 'news.php':
                                    if (function_exists("is_NewsArticle")) {
                                        if (is_NewsArticle()) {
                                            $altlink .= '/' . _NEWS_ . '/' . html_encode($_zp_current_zenpage_news->getTitlelink());
                                        } else {
                                            if (is_NewsCategory()) {
                                                $altlink .= '/' . _NEWS_ . '/' . html_encode($_zp_current_category->getTitlelink());
                                            } else {
                                                $altlink .= '/' . _NEWS_;
                                            }
                                        }
                                    }
                                    break;
                                case 'pages.php':
                                    $altlink .= '/' . _PAGES_ . '/' . html_encode($_zp_current_zenpage_page->getTitlelink());
                                    break;
                                case 'archive.php':
                                    $altlink .= '/' . _ARCHIVE_;
                                    break;
                                case 'search.php':
                                    $altlink .= '/' . _SEARCH_ . '/';
                                    break;
                                case 'contact.php':
                                    $altlink .= '/' . _CONTACT_ . '/';
                                    break;
                                default:
                                    // for all other possible none standard custom pages
                                    $altlink .= '/' . _PAGE_ . '/' . html_encode($pagetitle);
                                    break;
                            }
                            // switch
                            //append page number if needed
                            switch ($_zp_gallery_page) {
                                case 'index.php':
                                case 'album.php':
                                    if ($_zp_page != 1) {
                                        $altlink .= _PAGE_ . '/' . $_zp_page . '/';
                                    }
                                    break;
                                case 'gallery.php':
                                case 'news.php':
                                    if ($_zp_page != 1) {
                                        $altlink .= '/' . $_zp_page;
                                    }
                                    break;
                            }
                            $meta .= '<link rel="alternate" hreflang="' . $langcheck . '" href="' . $altlink . '">' . "\n";
                        }
                        // if lang
                    }
                    // foreach
                }
                // if count
            }
            // if option
        }
        // if canonical
        if (!empty($htmlmetatags_need_cache)) {
            $meta .= '<script type="text/javascript">' . "\n";
            $meta .= 'var caches = ["' . implode('","', $htmlmetatags_need_cache) . '"];' . "\n";
            $meta .= '
					window.onload = function() {
						var index,value;
						for (index in caches) {
								value = caches[index];
								$.ajax({
									cache: false,
									type: "GET",
									url: value
								});
						}
					}
					';
            $meta .= '</script>' . "\n";
        }
        zp_remove_filter('image_processor_uri', 'htmlmetatags::ipURI');
        echo $meta;
    }
Пример #9
0
/**
 * Central place for meta header handling
 */
function printStandardMeta()
{
    $lang = substr(getUserLocale(), 0, 2);
    echo '<meta http-equiv="content-type" content="text/html; charset=' . LOCAL_CHARSET . '"';
    if ($lang) {
        echo ' lang="' . $lang . '"';
    }
    echo ">\n";
}
Пример #10
0
 static function post_processor()
 {
     global $admin_e, $admin_n, $user, $_zp_authority, $_zp_captcha, $_zp_gallery, $_notify, $_link, $_message;
     //Handle registration
     if (isset($_POST['username']) && !empty($_POST['username'])) {
         $_notify = 'honeypot';
         // honey pot check
     }
     if (getOption('register_user_captcha')) {
         if (isset($_POST['code'])) {
             $code = sanitize($_POST['code'], 3);
             $code_ok = sanitize($_POST['code_h'], 3);
         } else {
             $code = '';
             $code_ok = '';
         }
         if (!$_zp_captcha->checkCaptcha($code, $code_ok)) {
             $_notify = 'invalidcaptcha';
         }
     }
     $admin_n = trim(sanitize($_POST['admin_name']));
     if (empty($admin_n)) {
         $_notify = 'incomplete';
     }
     if (isset($_POST['admin_email'])) {
         $admin_e = trim(sanitize($_POST['admin_email']));
     } else {
         $admin_e = trim(sanitize($_POST['user'], 0));
     }
     if (!is_valid_email_zp($admin_e)) {
         $_notify = 'invalidemail';
     }
     $pass = trim(sanitize($_POST['pass'], 0));
     $user = trim(sanitize($_POST['user'], 0));
     if (empty($pass)) {
         $_notify = 'empty';
     } else {
         if (!empty($user) && !empty($admin_n) && !empty($admin_e)) {
             if (isset($_POST['disclose_password']) || $pass == trim(sanitize($_POST['pass_r']))) {
                 $currentadmin = $_zp_authority->getAnAdmin(array('`user`=' => $user, '`valid`>' => 0));
                 if (is_object($currentadmin)) {
                     $_notify = 'exists';
                 } else {
                     if ($_zp_authority->getAnAdmin(array('`email`=' => $admin_e, '`valid`=' => '1'))) {
                         $_notify = 'dup_email';
                     }
                 }
                 if (empty($_notify)) {
                     $userobj = $_zp_authority->newAdministrator('');
                     $userobj->transient = false;
                     $userobj->setUser($user);
                     $userobj->setPass($pass);
                     $userobj->setName($admin_n);
                     $userobj->setEmail($admin_e);
                     $userobj->setRights(0);
                     $userobj->setObjects(NULL);
                     $userobj->setGroup('');
                     $userobj->setCustomData('');
                     $userobj->setLanguage(getUserLocale());
                     if (extensionEnabled('userAddressFields')) {
                         $addresses = getOption('register_user_address_info');
                         $userinfo = register_user::getUserInfo(0);
                         $_comment_form_save_post = serialize($userinfo);
                         if ($addresses == 'required') {
                             if (!isset($userinfo['street']) || empty($userinfo['street'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the street field.');
                             }
                             if (!isset($userinfo['city']) || empty($userinfo['city'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the city field.');
                             }
                             if (!isset($userinfo['state']) || empty($userinfo['state'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the state field.');
                             }
                             if (!isset($userinfo['country']) || empty($userinfo['country'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the country field.');
                             }
                             if (!isset($userinfo['postal']) || empty($userinfo['postal'])) {
                                 $userobj->transient = true;
                                 $userobj->msg .= ' ' . gettext('You must supply the postal code field.');
                             }
                         }
                         zp_setCookie('reister_user_form_addresses', $_comment_form_save_post);
                         userAddressFields::setCustomData($userobj, $userinfo);
                     }
                     zp_apply_filter('register_user_registered', $userobj);
                     if ($userobj->transient) {
                         if (empty($_notify)) {
                             $_notify = 'filter';
                         }
                     } else {
                         $userobj->save();
                         if (MOD_REWRITE) {
                             $verify = '?verify=';
                         } else {
                             $verify = '&verify=';
                         }
                         $_link = PROTOCOL . "://" . $_SERVER['HTTP_HOST'] . register_user::getLink() . $verify . bin2hex(serialize(array('user' => $user, 'email' => $admin_e)));
                         $_message = sprintf(get_language_string(getOption('register_user_text')), $_link, $admin_n, $user, $pass);
                         $_notify = zp_mail(get_language_string(gettext('Registration confirmation')), $_message, array($user => $admin_e));
                         if (empty($_notify)) {
                             $_notify = 'accepted';
                         }
                     }
                 }
             } else {
                 $_notify = 'mismatch';
             }
         } else {
             $_notify = 'incomplete';
         }
     }
 }
Пример #11
0
 /**
  *
  * Formats the message and calls sendTweet() on an object
  * @param object $obj
  */
 private static function tweetObject($obj)
 {
     if (getOption('multi_lingual')) {
         $cur_locale = getUserLocale();
         setupCurrentLocale(getOption('tweet_language'));
         //	the log will be in the language of the master user.
     }
     $error = '';
     if (class_exists('tinyURL')) {
         $link = tinyURL::getURL($obj);
     } else {
         $link = $obj->getLink();
     }
     switch ($type = $obj->table) {
         case 'pages':
         case 'news':
             $error = self::composeStatus($link, $obj->getTitle(), $obj->getContent());
             break;
         case 'albums':
         case 'images':
             if ($type == 'images') {
                 $text = sprintf(gettext('New image: [%2$s]%1$s '), $item = $obj->getTitle(), $obj->imagefolder);
             } else {
                 $text = sprintf(gettext('New album: %s '), $item = $obj->getTitle());
             }
             $error = self::composeStatus($link, '', $item);
             break;
         case 'comments':
             $error = self::composeStatus($link, '', $obj->getComment());
             break;
     }
     if (isset($cur_locale)) {
         setupCurrentLocale($cur_locale);
         //	restore to whatever was in effect.
     }
     return $error;
 }
Пример #12
0
/**
 * Generates an editable list of language strings
 *
 * @param string $dbstring either a serialized languag string array or a single string
 * @param string $name the prefix for the label, id, and name tags
 * @param bool $textbox set to true for a textbox rather than a text field
 * @param string $locale optional locale of the translation desired
 * @param string $edit optional class
 * @param int $wide column size. true or false for the standard or short sizes. Or pass a column size
 * @param string $ulclass set to the class for the UL element
 * @param int $rows set to the number of rows to show.
 */
function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '', $wide = TEXT_INPUT_SIZE, $ulclass = 'language_string_list', $rows = 6)
{
    global $_zp_active_languages, $_zp_current_locale;
    $dbstring = zpFunctions::unTagURLs($dbstring);
    if (!empty($edit)) {
        $edit = ' class="' . $edit . '"';
    }
    if (is_null($locale)) {
        $locale = getUserLocale();
    }
    $strings = getSerializedArray($dbstring);
    if (count($strings) == 1) {
        $keys = array_keys($strings);
        $lang = array_shift($keys);
        if (!is_string($lang)) {
            $strings = array($locale => array_shift($strings));
        }
    }
    $activelang = generateLanguageList();
    if (getOption('multi_lingual') && !empty($activelang)) {
        if ($textbox) {
            if (strpos($wide, '%') === false) {
                $width = ' cols="' . $wide . '"';
            } else {
                $width = ' style="width:' . ((int) $wide - 1) . '%;"';
            }
        } else {
            if (strpos($wide, '%') === false) {
                $width = ' size="' . $wide . '"';
            } else {
                $width = ' style="width:' . ((int) $wide - 2) . '%;"';
            }
        }
        // put the language list in perferred order
        $preferred = array($_zp_current_locale);
        foreach (parseHttpAcceptLanguage() as $lang) {
            $preferred[] = str_replace('-', '_', $lang['fullcode']);
        }
        $preferred = array_unique($preferred);
        $emptylang = array();
        foreach ($preferred as $lang) {
            foreach ($activelang as $key => $active) {
                if ($active == $lang) {
                    $emptylang[$active] = $key;
                    unset($activelang[$key]);
                    continue 2;
                }
            }
            if (strlen($lang) == 2) {
                //	"wild card language"
                foreach ($activelang as $key => $active) {
                    if (substr($active, 0, 2) == $lang) {
                        $emptylang[$active] = $key;
                    }
                }
            }
        }
        foreach ($activelang as $key => $active) {
            $emptylang[$active] = $key;
        }
        if ($textbox) {
            $class = 'box';
        } else {
            $class = '';
        }
        echo '<ul class="' . $ulclass . $class . '"' . ">\n";
        $empty = true;
        foreach ($emptylang as $key => $lang) {
            if (isset($strings[$key])) {
                $string = $strings[$key];
                if (!empty($string)) {
                    unset($emptylang[$key]);
                    $empty = false;
                    ?>
						<li>
							<label for="<?php 
                    echo $name . '_' . $key;
                    ?>
"><?php 
                    echo $lang;
                    ?>
</label>
							<?php 
                    if ($textbox) {
                        echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . $width . '	rows="' . $rows . '">' . html_encode($string) . '</textarea>';
                    } else {
                        echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value="' . html_encode($string) . '"' . $width . ' />';
                    }
                    ?>
						</li>
						<?php 
                }
            }
        }
        foreach ($emptylang as $key => $lang) {
            ?>
				<li>
					<label for="<?php 
            echo $name . '_' . $key;
            ?>
"><?php 
            echo $lang;
            ?>
</label>
					<?php 
            if ($textbox) {
                echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . $width . '	rows="' . $rows . '"></textarea>';
            } else {
                echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value=""' . $width . ' />';
            }
            ?>
				</li>
				<?php 
        }
        echo "</ul>\n";
    } else {
        if ($textbox) {
            if (strpos($wide, '%') === false) {
                $width = ' cols="' . $wide . '"';
            } else {
                $width = ' style="width:' . $wide . ';"';
            }
        } else {
            if (strpos($wide, '%') === false) {
                $width = ' size="' . $wide . '"';
            } else {
                $width = ' style="width:' . $wide . ';"';
            }
        }
        if (empty($locale)) {
            $locale = 'en_US';
        }
        if (isset($strings[$locale])) {
            $dbstring = $strings[$locale];
        } else {
            $dbstring = array_shift($strings);
        }
        if ($textbox) {
            echo '<textarea name="' . $name . '_' . $locale . '"' . $edit . $width . '	rows="' . $rows . '">' . html_encode($dbstring) . '</textarea>';
        } else {
            echo '<input name="' . $name . '_' . $locale . '"' . $edit . ' type="text" value="' . html_encode($dbstring) . '"' . $width . ' />';
        }
    }
}
Пример #13
0
/**
 * Parses the verification and registration if they have occurred
 * places the user registration form
 *
 * @param string $thanks the message shown on successful registration
 */
function printRegistrationForm($thanks = NULL)
{
    global $notify, $admin_e, $admin_n, $user, $_zp_authority, $_zp_captcha, $_zp_gallery_page, $_zp_gallery;
    require_once dirname(dirname(__FILE__)) . '/admin-functions.php';
    $userobj = NULL;
    // handle any postings
    if (isset($_GET['verify'])) {
        $currentadmins = $_zp_authority->getAdministrators();
        $params = unserialize(pack("H*", trim(sanitize($_GET['verify']), '.')));
        $userobj = $_zp_authority->getAnAdmin(array('`user`=' => $params['user'], '`valid`=' => 1));
        if ($userobj->getEmail() == $params['email']) {
            if (!$userobj->getRights()) {
                $userobj->setCredentials(array('registered', 'user', 'email'));
                $rights = getOption('register_user_user_rights');
                $group = NULL;
                if (!is_numeric($rights)) {
                    //  a group or template
                    $admin = $_zp_authority->getAnAdmin(array('`user`=' => $rights, '`valid`=' => 0));
                    if ($admin) {
                        $userobj->setObjects($admin->getObjects());
                        if ($admin->getName() != 'template') {
                            $group = $rights;
                        }
                        $rights = $admin->getRights();
                    } else {
                        $rights = NO_RIGHTS;
                    }
                }
                $userobj->setRights($rights | NO_RIGHTS);
                $userobj->setGroup($group);
                zp_apply_filter('register_user_verified', $userobj);
                $notify = false;
                if (getOption('register_user_notify')) {
                    $notify = zp_mail(gettext('Zenphoto Gallery registration'), sprintf(gettext('%1$s (%2$s) has registered for the zenphoto gallery providing an e-mail address of %3$s.'), $userobj->getName(), $userobj->getUser(), $userobj->getEmail()));
                }
                if (empty($notify)) {
                    if (getOption('register_user_create_album')) {
                        $userobj->createPrimealbum();
                    }
                    $notify = 'verified';
                    $_POST['user'] = $userobj->getUser();
                }
                $userobj->save();
            } else {
                $notify = 'verified';
            }
        } else {
            $notify = 'not_verified';
            // User ID no longer exists
        }
    }
    if (isset($_POST['register_user'])) {
        if (getOption('register_user_captcha')) {
            if (isset($_POST['code'])) {
                $code = sanitize($_POST['code'], 3);
                $code_ok = sanitize($_POST['code_h'], 3);
            } else {
                $code = '';
                $code_ok = '';
            }
            if (!$_zp_captcha->checkCaptcha($code, $code_ok)) {
                $notify = 'invalidcaptcha';
            }
        }
        $admin_n = trim(sanitize($_POST['admin_name']));
        if (empty($admin_n)) {
            $notify = 'incomplete';
        }
        if (isset($_POST['admin_email'])) {
            $admin_e = trim(sanitize($_POST['admin_email']));
        } else {
            $admin_e = trim(sanitize($_POST['adminuser']));
        }
        if (!is_valid_email_zp($admin_e)) {
            $notify = 'invalidemail';
        }
        $pass = trim(sanitize($_POST['adminpass']));
        $user = trim(sanitize($_POST['adminuser']));
        if (!empty($user) && !empty($admin_n) && !empty($admin_e)) {
            if ($pass == trim(sanitize($_POST['adminpass_2']))) {
                $currentadmin = $_zp_authority->getAnAdmin(array('`user`=' => $user, '`valid`>' => 0));
                if (is_object($currentadmin)) {
                    $notify = 'exists';
                }
                if (empty($notify)) {
                    $notify = $_zp_authority->validatePassword($pass);
                    //	test for valid password
                    if (empty($notify)) {
                        $userobj = $_zp_authority->newAdministrator('');
                        $userobj->transient = false;
                        $userobj->setUser($user);
                        $userobj->setPass($pass);
                        $userobj->setName($admin_n);
                        $userobj->setEmail($admin_e);
                        $userobj->setRights(0);
                        $userobj->setObjects(NULL);
                        $userobj->setGroup('');
                        $userobj->setCustomData('');
                        $userobj->setLanguage(getUserLocale());
                        zp_apply_filter('register_user_registered', $userobj);
                        if ($userobj->transient) {
                            if (empty($notify)) {
                                $notify = 'filter';
                            }
                        } else {
                            $userobj->save();
                            $link = rewrite_path(FULLWEBPATH . '/page/' . substr($_zp_gallery_page, 0, -4) . '?verify=' . bin2hex(serialize(array('user' => $user, 'email' => $admin_e))), FULLWEBPATH . '/index.php?p=' . substr($_zp_gallery_page, 0, -4) . '&verify=' . bin2hex(serialize(array('user' => $user, 'email' => $admin_e))), false);
                            $message = sprintf(get_language_string(getOption('register_user_text')), $link);
                            $notify = zp_mail(get_language_string(gettext('Registration confirmation')), $message, array($user => $admin_e));
                            if (empty($notify)) {
                                $notify = 'accepted';
                            }
                        }
                    }
                }
            } else {
                $notify = 'mismatch';
            }
        } else {
            $notify = 'incomplete';
        }
    }
    if (zp_loggedin()) {
        if (isset($_GET['userlog']) && $_GET['userlog'] == 1) {
            echo '<meta http-equiv="refresh" content="1; url=' . WEBPATH . '/">';
        } else {
            echo '<div class="errorbox fade-message">';
            echo '<h2>' . gettext("you are already logged in.") . '</h2>';
            echo '</div>';
        }
        return;
    }
    if (!empty($notify)) {
        if ($notify == 'verified' || $notify == 'accepted') {
            ?>
			<div class="Messagebox fade-message">
				<p>
				<?php 
            if ($notify == 'verified') {
                if (is_null($thanks)) {
                    $thanks = gettext("Thank you for registering.");
                }
                echo $thanks;
            } else {
                echo gettext('Your registration information has been accepted. An email has been sent to you to verify your email address.');
            }
            ?>
				</p>
			</div>
			<?php 
            if ($notify == 'verified') {
                require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/user_login-out.php';
                ?>
				<p><?php 
                echo gettext('You may now log onto the site.');
                ?>
</p>
				<?php 
                printPasswordForm('', false, true, WEBPATH . '/' . ZENFOLDER . '/admin.php');
            }
            $notify = 'success';
        } else {
            echo '<div class="errorbox fade-message">';
            echo '<h2>' . gettext("Registration failed.") . '</h2>';
            echo '<p>';
            switch ($notify) {
                case 'exists':
                    printf(gettext('The user ID <em>%s</em> is already in use.'), $admin_e);
                    break;
                case 'mismatch':
                    echo gettext('Your passwords did not match.');
                    break;
                case 'incomplete':
                    echo gettext('You have not filled in all the fields.');
                    break;
                case 'notverified':
                    echo gettext('Invalid verification link.');
                    break;
                case 'invalidemail':
                    echo gettext('Enter a valid email address.');
                    break;
                case 'invalidcaptcha':
                    echo gettext('The CAPTCHA you entered was not correct.');
                    break;
                case 'not_verified':
                    echo gettext('Your registration request could not be completed.');
                    break;
                case 'filter':
                    if (is_object($userobj) && !empty($userobj->msg)) {
                        echo $userobj->msg;
                    } else {
                        echo gettext('Your registration attempt failed a <code>register_user_registered</code> filter check.');
                    }
                    break;
                default:
                    echo $notify;
                    break;
            }
            echo '</p>';
            echo '</div>';
        }
    }
    if ($notify != 'success') {
        $form = getPlugin('register_user/register_user_form.php', true);
        require_once $form;
    }
}
Пример #14
0
/**
 * Generates an editable list of language strings
 *
 * @param string $dbstring either a serialized languag string array or a single string
 * @param string $name the prefix for the label, id, and name tags
 * @param bool $textbox set to true for a textbox rather than a text field
 * @param string $locale optional locale of the translation desired
 * @param string $edit optional class
 * @param int $wide column size. true or false for the standard or short sizes. Or pass a column size
 * @param string $ulclass set to the class for the UL element
 * @param int $rows set to the number of rows to show.
 */
function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '', $wide = TEXT_INPUT_SIZE, $ulclass = 'language_string_list', $rows = 6)
{
    global $_zp_active_languages, $_zp_current_locale;
    if (!empty($edit)) {
        $edit = ' class="' . $edit . '"';
    }
    if (empty($id)) {
        $groupid = '';
    } else {
        $groupid = ' id="' . $id . '"';
    }
    if (is_null($locale)) {
        if (is_null($_zp_current_locale)) {
            $_zp_current_locale = getUserLocale();
        }
        $locale = $_zp_current_locale;
    }
    if (preg_match('/^a:[0-9]+:{/', $dbstring)) {
        $strings = unserialize($dbstring);
    } else {
        $strings = array($locale => $dbstring);
    }
    if (getOption('multi_lingual')) {
        $emptylang = generateLanguageList();
        $emptylang = array_flip($emptylang);
        unset($emptylang['']);
        if ($textbox) {
            $class = 'box';
        } else {
            $class = '';
        }
        echo '<ul' . $groupid . ' class="' . $ulclass . $class . '"' . ">\n";
        $empty = true;
        foreach ($emptylang as $key => $lang) {
            if (isset($strings[$key])) {
                $string = $strings[$key];
                if (!empty($string)) {
                    unset($emptylang[$key]);
                    $empty = false;
                    ?>
					<li>
						<label for="<?php 
                    echo $name . '_' . $key;
                    ?>
"><?php 
                    echo $lang;
                    ?>
</label>
						<?php 
                    if ($textbox) {
                        echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . ' cols="' . $wide . '"	rows="' . $rows . '">' . html_encode($string) . '</textarea>';
                    } else {
                        echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value="' . html_encode($string) . '" size="' . $wide . '" />';
                    }
                    ?>
					</li>
					<?php 
                }
            }
        }
        if ($empty) {
            $element = $emptylang[$locale];
            unset($emptylang[$locale]);
            $emptylang = array_merge(array($locale => $element), $emptylang);
        }
        foreach ($emptylang as $key => $lang) {
            echo '<li><label for="' . $name . '_' . $key . '"></label>';
            echo $lang;
            if ($textbox) {
                echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . ' cols="' . $wide . '"	rows="' . $rows . '"></textarea>';
            } else {
                echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value="" size="' . $wide . '" />';
            }
            echo "</li>\n";
        }
        echo "</ul>\n";
    } else {
        if (empty($locale)) {
            $locale = 'en_US';
        }
        if (isset($strings[$locale])) {
            $dbstring = $strings[$locale];
        } else {
            $dbstring = array_shift($strings);
        }
        if ($textbox) {
            echo '<textarea' . $groupid . ' name="' . $name . '_' . $locale . '"' . $edit . ' cols="' . $wide . '"	rows="' . $rows . '">' . html_encode($dbstring) . '</textarea>';
        } else {
            echo '<input' . $groupid . ' name="' . $name . '_' . $locale . '"' . $edit . ' type="text" value="' . html_encode($dbstring) . '" size="' . $wide . '" />';
        }
    }
}
Пример #15
0
/**
 * Generates an editable list of language strings
 *
 * @param string $dbstring either a serialized languag string array or a single string
 * @param string $name the prefix for the label, id, and name tags
 * @param bool $textbox set to true for a textbox rather than a text field
 * @param string $locale optional locale of the translation desired
 * @param string $edit optional class
 * @param int $wide column size. true or false for the standard or short sizes. Or pass a column size
 * @param string $ulclass set to the class for the UL element
 * @param int $rows set to the number of rows to show.
 */
function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '', $wide = TEXT_INPUT_SIZE, $ulclass = 'language_string_list', $rows = 6)
{
    global $_zp_active_languages, $_zp_current_locale, $_lsInstance;
    $dbstring = zpFunctions::unTagURLs($dbstring);
    if (!empty($edit)) {
        $edit = ' class="' . $edit . '"';
    }
    if (is_null($locale)) {
        $locale = getUserLocale();
    }
    $strings = getSerializedArray($dbstring);
    if (count($strings) == 1) {
        $keys = array_keys($strings);
        $lang = array_shift($keys);
        if (!is_string($lang)) {
            $strings = array($locale => array_shift($strings));
        }
    }
    $activelang = generateLanguageList();
    $allLang = array_flip(generateLanguageList('all'));
    foreach ($strings as $lang => $v) {
        if (!array_key_exists($lang, $activelang)) {
            $activelang[$allLang[$lang]] = $lang;
        }
    }
    echo '<div id="ls_' . ++$_lsInstance . '">' . "\n";
    if ($multi = getOption('multi_lingual') && !empty($activelang)) {
        if ($textbox) {
            if (strpos($wide, '%') === false) {
                $width = ' cols="' . $wide . '"';
            } else {
                $width = ' style="width:' . ((int) $wide - 1) . '%;"';
            }
        } else {
            if (strpos($wide, '%') === false) {
                $width = ' size="' . $wide . '"';
            } else {
                $width = ' style="width:' . ((int) $wide - 2) . '%;"';
            }
        }
        // put the language list in perferred order
        $preferred = array();
        if ($_zp_current_locale) {
            $preferred[] = $_zp_current_locale;
        }
        foreach (parseHttpAcceptLanguage() as $lang) {
            $preferred[] = str_replace('-', '_', $lang['fullcode']);
        }
        $preferred = array_unique($preferred);
        $emptylang = array();
        foreach ($preferred as $lang) {
            foreach ($activelang as $key => $active) {
                if ($active == $lang) {
                    $emptylang[$active] = $key;
                    unset($activelang[$key]);
                    continue 2;
                }
            }
            if (strlen($lang) == 2) {
                //	"wild card language"
                foreach ($activelang as $key => $active) {
                    if (substr($active, 0, 2) == $lang) {
                        $emptylang[$active] = $key;
                    }
                }
            }
        }
        foreach ($activelang as $key => $active) {
            $emptylang[$active] = $key;
        }
        if ($textbox) {
            $class = 'box';
        } else {
            $class = '';
        }
        echo '<ul id="ul_' . $_lsInstance . '" class="' . $ulclass . $class . '"' . ">\n";
        $empty = true;
        foreach ($emptylang as $key => $lang) {
            if (isset($strings[$key])) {
                $string = $strings[$key];
                if (!empty($string)) {
                    unset($emptylang[$key]);
                    $empty = false;
                    ?>
						<li>
							<label for="<?php 
                    echo $name . '_' . $key;
                    ?>
"><?php 
                    echo $lang;
                    ?>
</label>
							<?php 
                    if ($textbox) {
                        echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . $width . '	rows="' . $rows . '">' . html_encode($string) . '</textarea>';
                    } else {
                        echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value="' . html_encode($string) . '"' . $width . ' />';
                    }
                    ?>
						</li>
						<?php 
                }
            }
        }
        foreach ($emptylang as $key => $lang) {
            ?>
				<li>
					<label for="<?php 
            echo $name . '_' . $key;
            ?>
"><?php 
            echo $lang;
            ?>
</label>
					<?php 
            if ($textbox) {
                echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . $width . '	rows="' . $rows . '"></textarea>';
            } else {
                echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value=""' . $width . ' />';
            }
            ?>
				</li>
				<?php 
        }
        echo "</ul>\n";
    } else {
        if ($textbox) {
            if (strpos($wide, '%') === false) {
                $width = ' cols="' . $wide . '"';
            } else {
                $width = ' style="width:' . $wide . ';"';
            }
        } else {
            if (strpos($wide, '%') === false) {
                $width = ' size="' . $wide . '"';
            } else {
                $width = ' style="width:' . $wide . ';"';
            }
        }
        if (empty($locale)) {
            $locale = 'en_US';
        }
        if (isset($strings[$locale])) {
            $dbstring = $strings[$locale];
            unset($strings[$locale]);
        } else {
            $dbstring = array_shift($strings);
        }
        if ($textbox) {
            echo '<textarea name="' . $name . '_' . $locale . '"' . $edit . $width . '	rows="' . $rows . '">' . html_encode($dbstring) . '</textarea>';
        } else {
            echo '<input name="' . $name . '_' . $locale . '"' . $edit . ' type="text" value="' . html_encode($dbstring) . '"' . $width . ' />';
        }
        foreach ($strings as $key => $dbstring) {
            if (!empty($dbstring)) {
                ?>
					<input type="hidden" name="<?php 
                echo $name . '_' . $key;
                ?>
" value="<?php 
                echo html_encode($dbstring);
                ?>
" />
					<?php 
            }
        }
    }
    echo "</div>\n";
    if ($multi) {
        ?>
			<script type="text/javascript">
				$(function () {
					$('#ls_<?php 
        echo $_lsInstance;
        ?>
').resizable({
						minHeight: 60,
						resize: function (event, ui) {
							$(this).css("width", '');
							$('#ul_<?php 
        echo $_lsInstance;
        ?>
').height($('#ls_<?php 
        echo $_lsInstance;
        ?>
').height());
						}
					});
				});</script>
			<?php 
    }
}
Пример #16
0
 *
 * @package admin
 * @subpackage development
 */
// force UTF-8 Ø
if (!defined('OFFSET_PATH')) {
    define('OFFSET_PATH', 2);
    require_once dirname(__FILE__) . '/admin-globals.php';
    require_once SERVERPATH . '/' . ZENFOLDER . '/template-functions.php';
    $extension = sanitize($_GET['extension']);
    if (!in_array($extension, array_keys(getPluginFiles('*.php')))) {
        exit;
    }
    header('Last-Modified: ' . ZP_LAST_MODIFIED);
    header('Content-Type: text/html; charset=' . LOCAL_CHARSET);
    $real_locale = getUserLocale();
    $pluginType = @$_GET['type'];
    if ($pluginType) {
        $pluginToBeDocPath = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/' . $extension . '.php';
    } else {
        $pluginToBeDocPath = SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . $extension . '.php';
    }
    $plugin_description = '';
    $plugin_notice = '';
    $plugin_disable = '';
    $plugin_author = '';
    $plugin_version = '';
    $plugin_is_filter = '';
    $plugin_URL = '';
    $option_interface = '';
    $doclink = '';
Пример #17
0
/**
 * Does the log handling
 *
 * @param int $success
 * @param string $user
 * @param string $name
 * @param string $ip
 * @param string $type
 * @param string $authority kind of login
 * @param string $addl more info
 */
function security_logger_loginLogger($success, $user, $name, $ip, $action, $authority, $addl = NULL)
{
    global $_zp_authority;
    $admin = $_zp_authority->getAnAdmin(array('`user`=' => $_zp_authority->master_user, '`valid`=' => 1));
    if ($admin) {
        $locale = $admin->getLanguage();
    }
    if (empty($locale)) {
        $locale = 'en_US';
    }
    $cur_locale = getUserLocale();
    setupCurrentLocale($locale);
    //	the log will be in the language of the master user.
    switch ($action) {
        case 'clear_log':
            $type = gettext('Log reset');
            break;
        case 'delete_log':
            $type = gettext('Log deleted');
            break;
        case 'download_log':
            $type = gettext('Log downloaded');
            break;
        case 'install':
            $type = gettext('Installed');
            $addl = gettext('version') . ' ' . ZENPHOTO_VERSION . '[' . ZENPHOTO_RELEASE . "]";
            break;
        case 'delete':
            $type = gettext('Removed setup file');
            break;
        case 'new':
            $type = gettext('Request add user');
            break;
        case 'update':
            $type = gettext('Request update user');
            break;
        case 'delete':
            $type = gettext('Request delete user');
            break;
        case 'XSRF access blocked':
            $type = gettext('XSRF access blocked');
            break;
        case 'Blocked album':
            $type = gettext('Blocked album');
            break;
        case 'Blocked access':
            $type = gettext('Blocked access');
            break;
        case 'Front-end':
            $type = gettext('Guest login');
            break;
        case 'Back-end':
            $type = gettext('Admin login');
            break;
        default:
            $type = $action;
    }
    $file = dirname(dirname(dirname(__FILE__))) . '/' . DATA_FOLDER . '/security_log.txt';
    $preexists = file_exists($file) && filesize($file) > 0;
    $f = fopen($file, 'a');
    if ($f) {
        if (!$preexists) {
            // add a header
            fwrite($f, gettext('date' . "\t" . 'requestor\'s IP' . "\t" . 'type' . "\t" . 'user ID' . "\t" . 'user name' . "\t" . 'outcome' . "\t" . 'authority' . "\tadditional information\n"));
        }
        $message = date('Y-m-d H:i:s') . "\t";
        $message .= $ip . "\t";
        $message .= $type . "\t";
        $message .= $user . "\t";
        $message .= $name . "\t";
        if ($success) {
            $message .= gettext("Success") . "\t";
            $message .= substr($authority, 0, strrpos($authority, '_auth'));
        } else {
            $message .= gettext("Failed") . "\t";
        }
        if ($addl) {
            $message .= "\t" . $addl;
        }
        fwrite($f, $message . "\n");
        fclose($f);
        clearstatcache();
        if (!$preexists) {
            chmod($file, 0600);
            $permission = fileperms($file) & 0777;
            if ($permission != 0600) {
                $f = fopen($file, 'a');
                fwrite($f, "\t\t" . gettext('Set Security log permissions') . "\t\t\t" . gettext('Failed') . "\t\t" . sprintf(gettext('File permissions of Security log are %04o'), $permission) . "\n");
                fclose($f);
                clearstatcache();
            }
        }
    }
    setupCurrentLocale($cur_locale);
    //	restore to whatever was in effect.
}
Пример #18
0
 /**
  * Prints html meta data to be used in the <head> section of a page
  *
  */
 static function getHTMLMetaData()
 {
     global $_zp_gallery, $_zp_page, $_zp_current_album, $_zp_current_image, $_zp_current_search, $_zp_current_article, $_zp_current_page, $_zp_gallery_page, $_zp_current_category, $_zp_authority, $_zp_conf_vars, $_myFavorites;
     $host = sanitize("http://" . $_SERVER['HTTP_HOST']);
     $url = $host . getRequestURI();
     // Convert locale shorttag to allowed html meta format
     $locale_ = getUserLocale();
     $locale = zpFunctions::getLanguageText($locale_, '-');
     $canonicalurl = '';
     // generate page title, get date
     $pagetitle = "";
     // for gallery index setup below switch
     $date = strftime(DATE_FORMAT);
     // if we don't have a item date use current date
     $desc = getBareGalleryDesc();
     $thumb = '';
     if (getOption('htmlmeta_sitelogo')) {
         $thumb = getOption('htmlmeta_sitelogo');
     }
     if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
         $ogimage_width = getOption('htmlmeta_ogimage_width');
         $ogimage_height = getOption('htmlmeta_ogimage_height');
         if (empty($ogimage_width)) {
             $ogimage_width = 1280;
         }
         if (empty($ogimage_height)) {
             $ogimage_height = 900;
         }
         $twittercard_type = 'summary';
     }
     $type = 'article';
     switch ($_zp_gallery_page) {
         case 'index.php':
             $desc = getBareGalleryDesc();
             $canonicalurl = $host . $_zp_gallery->getLink($_zp_page);
             $type = 'website';
             break;
         case 'album.php':
         case 'favorites.php':
             $pagetitle = getBareAlbumTitle() . " - ";
             $date = getAlbumDate();
             $desc = getBareAlbumDesc();
             $canonicalurl = $host . $_zp_current_album->getLink($_zp_page);
             if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                 $thumbimg = $_zp_current_album->getAlbumThumbImage();
                 getMaxSpaceContainer($ogimage_width, $ogimage_height, $thumbimg, false);
                 $thumb = $host . html_encode(pathurlencode($thumbimg->getCustomImage(NULL, $ogimage_width, $ogimage_height, NULL, NULL, NULL, NULL, false, NULL)));
                 $twittercard_type = 'summary_large_image';
             }
             break;
         case 'image.php':
             $pagetitle = getBareImageTitle() . " (" . getBareAlbumTitle() . ") - ";
             $date = getImageDate();
             $desc = getBareImageDesc();
             $canonicalurl = $host . $_zp_current_image->getLink();
             if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                 $thumb = $host . html_encode(pathurlencode(getCustomSizedImageMaxSpace($ogimage_width, $ogimage_height)));
                 $twittercard_type = 'summary_large_image';
             }
             break;
         case 'news.php':
             if (function_exists("is_NewsArticle")) {
                 if (is_NewsArticle()) {
                     $pagetitle = getBareNewsTitle() . " - ";
                     $date = getNewsDate();
                     $desc = trim(getBare(getNewsContent()));
                     $canonicalurl = $host . $_zp_current_article->getLink();
                 } else {
                     if (is_NewsCategory()) {
                         $pagetitle = $_zp_current_category->getTitlelink() . " - ";
                         $date = strftime(DATE_FORMAT);
                         $desc = trim(getBare($_zp_current_category->getDesc()));
                         $canonicalurl = $host . $_zp_current_category->getLink($_zp_page);
                         $type = 'category';
                     } else {
                         $pagetitle = gettext('News') . " - ";
                         $desc = '';
                         $canonicalurl = $host . getNewsPathNav($_zp_page);
                         $type = 'website';
                     }
                 }
             }
             break;
         case 'pages.php':
             $pagetitle = getBarePageTitle() . " - ";
             $date = getPageDate();
             $desc = trim(getBare(getPageContent()));
             $canonicalurl = $host . $_zp_current_page->getLink();
             break;
         default:
             // for all other possible static custom pages
             $custompage = stripSuffix($_zp_gallery_page);
             $standard = array('contact' => gettext('Contact'), 'register' => gettext('Register'), 'search' => gettext('Search'), 'archive' => gettext('Archive view'), 'password' => gettext('Password required'));
             if (is_object($_myFavorites)) {
                 $standard['favorites'] = gettext('My favorites');
             }
             if (array_key_exists($custompage, $standard)) {
                 $pagetitle = $standard[$custompage] . " - ";
             } else {
                 $pagetitle = $custompage . " - ";
             }
             $desc = '';
             $canonicalurl = $host . getCustomPageURL($custompage);
             break;
     }
     // shorten desc to the allowed 200 characters if necesssary.
     $desc = html_encode(trim(substr(getBare($desc), 0, 160)));
     $pagetitle = $pagetitle . getBareGalleryTitle();
     // get master admin
     $admin = $_zp_authority->getMasterUser();
     $author = $admin->getName();
     $meta = '';
     if (getOption('htmlmeta_http-equiv-cache-control')) {
         $meta .= '<meta http-equiv="Cache-control" content="' . getOption("htmlmeta_cache_control") . '">' . "\n";
     }
     if (getOption('htmlmeta_http-equiv-pragma')) {
         $meta .= '<meta http-equiv="pragma" content="' . getOption("htmlmeta_pragma") . '">' . "\n";
     }
     if (getOption('htmlmeta_name-keywords')) {
         $meta .= '<meta name="keywords" content="' . htmlmetatags::getMetaKeywords() . '">' . "\n";
     }
     if (getOption('htmlmeta_name-description')) {
         $meta .= '<meta name="description" content="' . $desc . '">' . "\n";
     }
     if (getOption('htmlmeta_name-page-topic')) {
         $meta .= '<meta name="page-topic" content="' . $desc . '">' . "\n";
     }
     if (getOption('htmlmeta_name-robots')) {
         $meta .= '<meta name="robots" content="' . getOption("htmlmeta_robots") . '">' . "\n";
     }
     if (getOption('htmlmeta_name-publisher')) {
         $meta .= '<meta name="publisher" content="' . FULLWEBPATH . '">' . "\n";
     }
     if (getOption('htmlmeta_name-creator')) {
         $meta .= '<meta name="creator" content="' . FULLWEBPATH . '">' . "\n";
     }
     if (getOption('htmlmeta_name-author')) {
         $meta .= '<meta name="author" content="' . $author . '">' . "\n";
     }
     if (getOption('htmlmeta_name-copyright')) {
         $meta .= '<meta name="copyright" content=" (c) ' . FULLWEBPATH . ' - ' . $author . '">' . "\n";
     }
     if (getOption('htmlmeta_name-rights')) {
         $meta .= '<meta name="rights" content="' . $author . '">' . "\n";
     }
     if (getOption('htmlmeta_name-generator')) {
         $meta .= '<meta name="generator" content="ZenPhoto20 ' . ZENPHOTO_VERSION . '">' . "\n";
     }
     if (getOption('htmlmeta_name-revisit-after')) {
         $meta .= '<meta name="revisit-after" content="' . getOption("htmlmeta_revisit_after") . ' days">' . "\n";
     }
     if (getOption('htmlmeta_name-expires')) {
         $expires = getOption("htmlmeta_expires");
         if ($expires == (int) $expires) {
             $expires = preg_replace('|\\s\\-\\d+|', '', date('r', time() + $expires)) . ' GMT';
         }
         $meta .= '<meta name="expires" content="' . $expires . '">' . "\n";
     }
     // OpenGraph meta
     if (getOption('htmlmeta_opengraph')) {
         $meta .= '<meta property="og:title" content="' . $pagetitle . '">' . "\n";
         if (!empty($thumb)) {
             $meta .= '<meta property="og:image" content="' . $thumb . '">' . "\n";
         }
         $meta .= '<meta property="og:description" content="' . $desc . '">' . "\n";
         $meta .= '<meta property="og:url" content="' . html_encode($url) . '">' . "\n";
         $meta .= '<meta property="og:type" content="' . $type . '">' . "\n";
     }
     // Social network extras
     if (getOption('htmlmeta_name-pinterest')) {
         $meta .= '<meta name="pinterest" content="nopin">' . "\n";
     }
     // dissalow users to pin images on Pinterest
     // Twitter card
     $twittername = getOption('htmlmeta_twittername');
     if (getOption('htmlmeta_twittercard') || !empty($twittername)) {
         $meta .= '<meta name="twitter:creator" content="' . $twittername . '">' . "\n";
         $meta .= '<meta name="twitter:site" content="' . $twittername . '">' . "\n";
         $meta .= '<meta name="twitter:card" content="' . $twittercard_type . '">' . "\n";
         $meta .= '<meta name="twitter:title" content="' . $pagetitle . '">' . "\n";
         $meta .= '<meta name="twitter:description" content="' . $desc . '">' . "\n";
         if (!empty($thumb)) {
             $meta .= '<meta name="twitter:image" content="' . $thumb . '">' . "\n";
         }
     }
     // Canonical url
     if (getOption('htmlmeta_canonical-url')) {
         $meta .= '<link rel="canonical" href="' . $canonicalurl . '">' . "\n";
         if (METATAG_LOCALE_TYPE) {
             $langs = generateLanguageList();
             if (count($langs) != 1) {
                 if (METATAG_LOCALE_TYPE == 1) {
                     $locallink = seo_locale::localePath(false, $locale_);
                 } else {
                     $locallink = '';
                 }
                 foreach ($langs as $text => $lang) {
                     $langcheck = zpFunctions::getLanguageText($lang, '-');
                     //	for hreflang we need en-US
                     if ($langcheck != $locale) {
                         if (METATAG_LOCALE_TYPE == 1) {
                             $altlink = seo_locale::localePath(true, $lang);
                         } else {
                             $altlink = dynamic_locale::fullHostPath($lang);
                         }
                         switch ($_zp_gallery_page) {
                             case 'index.php':
                                 $altlink .= str_replace($locallink, '', $_zp_gallery->getLink($_zp_page));
                                 break;
                             case 'album.php':
                             case 'favorites.php':
                                 $altlink .= str_replace($locallink, '', $_zp_current_album->getLink($_zp_page));
                                 break;
                             case 'image.php':
                                 $altlink .= str_replace($locallink, '', $_zp_current_image->getLink());
                                 break;
                             case 'news.php':
                                 if (function_exists("is_NewsArticle")) {
                                     if (is_NewsArticle()) {
                                         $altlink .= str_replace($locallink, '', $_zp_current_article->getLink());
                                     } else {
                                         if (is_NewsCategory()) {
                                             $altlink .= str_replace($locallink, '', $_zp_current_category->getLink($_zp_page));
                                         } else {
                                             $altlink .= getNewsPathNav($_zp_page);
                                         }
                                     }
                                 }
                                 break;
                             case 'pages.php':
                                 $altlink .= str_replace($locallink, '', $_zp_current_page->getLink());
                                 break;
                             case 'archive.php':
                                 $altlink .= getCustomPageURL('archive');
                                 break;
                             case 'search.php':
                                 $searchwords = $_zp_current_search->codifySearchString();
                                 $searchdate = $_zp_current_search->getSearchDate();
                                 $searchfields = $_zp_current_search->getSearchFields(true);
                                 $searchpagepath = getSearchURL($searchwords, $searchdate, $searchfields, $_zp_page, array('albums' => $_zp_current_search->getAlbumList()));
                                 $altlink .= $searchpagepath;
                                 break;
                             case 'contact.php':
                                 $altlink .= getCustomPageURL('contact');
                                 break;
                             default:
                                 // for all other possible none standard custom pages
                                 $altlink .= getCustomPageURL($pagetitle);
                                 break;
                         }
                         // switch
                         $meta .= '<link rel="alternate" hreflang="' . $langcheck . '" href="' . html_encode($altlink) . '">' . "\n";
                     }
                     // if lang
                 }
                 // foreach
             }
             // if count
         }
         // if option
     }
     // if canonical
     echo $meta;
 }
Пример #19
0
 /**
  * Common logon handler.
  * Will log the user on if he exists. Otherwise it will create a user accoung and log
  * on that account.
  *
  * Redirects into Zenphoto on success presuming there is a redirect link.
  *
  * @param $user
  * @param $email
  * @param $name
  * @param $redirect
  */
 static function credentials($user, $email, $name, $redirect)
 {
     $userobj = Zenphoto_Authority::getAnAdmin(array('`user`=' => $user, '`valid`=' => 1));
     $more = false;
     if ($userobj) {
         //	update if changed
         $save = false;
         if (!empty($email) && $email != $userobj->getEmail()) {
             $save = true;
             $userobj->setEmail($email);
         }
         if (!empty($name) && $name != $userobj->getName()) {
             $save = true;
             $userobj->setName($name);
         }
         if ($save) {
             $userobj->save();
         }
     } else {
         //	User does not exist, create him
         $groupname = getOption('federated_login_group');
         $groupobj = Zenphoto_Authority::getAnAdmin(array('`user`=' => $groupname, '`valid`=' => 0));
         if ($groupobj) {
             $group = NULL;
             if ($groupobj->getName() != 'template') {
                 $group = $groupname;
             }
             $userobj = Zenphoto_Authority::newAdministrator('');
             $userobj->transient = false;
             $userobj->setUser($user);
             $credentials = array('federated', 'user', 'email');
             if ($name) {
                 $credentials[] = 'name';
             }
             $userobj->setCredentials($credentials);
             $userobj->setName($name);
             $userobj->setPass($user . HASH_SEED . gmdate('d M Y H:i:s'));
             $userobj->setObjects(NULL);
             $userobj->setCustomData('');
             $userobj->setLanguage(getUserLocale());
             $userobj->setObjects($groupobj->getObjects());
             if (is_valid_email_zp($email)) {
                 $userobj->setEmail($email);
                 if (getOption('register_user_create_album')) {
                     $userobj->createPrimealbum();
                 }
             } else {
                 $groupobj = Zenphoto_Authority::getAnAdmin(array('`user`=' => 'federated_verify', '`valid`=' => 0));
                 if (empty($groupobj)) {
                     $groupobj = Zenphoto_Authority::newAdministrator('federated_verify', 0);
                     $groupobj->setName('group');
                     $groupobj->setRights(NO_RIGHTS);
                     $groupobj->save();
                 }
                 $group = 'federated_verify';
                 $redirect = WEBPATH . '/' . ZENFOLDER . '/admin.php';
             }
             $userobj->setRights($groupobj->getRights());
             $userobj->setGroup($group);
             $userobj->save();
         } else {
             $more = sprintf(gettext('Group %s does not exist.'), $groupname);
         }
     }
     if (!$more) {
         zp_apply_filter('federated_login_attempt', true, $user);
         Zenphoto_Authority::logUser($userobj);
         if ($redirect) {
             header("Location: " . $redirect);
             exitZP();
         }
     }
     return $more;
 }
Пример #20
0
/**
 * Sets the locale, etc. to the zenphoto domain details.
 * Returns the rewult of setupCurrentLocale()
 *
 */
function setMainDomain()
{
    getUserLocale();
    return setupCurrentLocale();
}