示例#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
            //	"passed" login
            $user = unserialize($_SESSION['admin'][$cloneid]);
            $user2 = $_zp_authority->getAnAdmin(array('`user`=' => $user->getUser(), '`valid`=' => 1));
            if ($user2 && $user->getPass() == $user2->getPass()) {
                Zenphoto_Authority::logUser($user2);
                $_zp_current_admin_obj = $user2;
                $_zp_loggedin = $_zp_current_admin_obj->getRights();
            }
        }
        unset($cloneid);
    }
    if ($_zp_loggedin) {
        $locale = $_zp_current_admin_obj->getLanguage();
        if (!empty($locale)) {
            //	set his prefered language
            setupCurrentLocale($locale);
        }
    }
}
if (!$_zp_loggedin) {
    //	Clear the ssl cookie
    zp_clearCookie("zenphoto_ssl");
    if (class_exists('ipBlocker')) {
        ipBlocker::load();
    }
}
// Handle a logout action.
if (isset($_REQUEST['logout'])) {
    $location = Zenphoto_Authority::handleLogout();
    zp_clearCookie("zenphoto_ssl");
    if (empty($location)) {
/**
 * 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.
}
示例#4
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);
}
示例#5
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.
 }
示例#6
0
                }
                $whose = 'Official plugin';
                $ico = 'images/zp_gold.png';
                break;
        }
        if ($real_locale == 'en_US') {
            $translatetext = '';
        } else {
            $translatetext = '<br />' . '<a href="http://www.google.com/translate_c?langpair=en|' . strtolower(substr($real_locale, 0, 2)) . '&u=' . FULLWEBPATH . '/' . ZENFOLDER . '/pluginDoc.php?extension=' . $extension . '"' . 'title="' . gettext('This document is generated from the plugin comment block and other items that are in English and outside of the <em>Gettext()</em> translation system. This link will send the URL to the Google translation WEB to present the page in your language.') . '">' . gettext('Translate this page.') . '</a>';
        }
        if ($plugin_URL) {
            $doclink = sprintf('See also the <a href="%1$s">%2$s</a>', $plugin_URL, $extension);
        }
        $pluginusage = gettext('Plugin usage information');
        $pagetitle = sprintf(gettext('%1$s %2$s: %3$s'), html_encode($_zp_gallery->getTitle()), gettext('admin'), html_encode($extension));
        setupCurrentLocale('en_US');
        ?>
		<!DOCTYPE html>
		<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
				<?php 
        printStandardMeta();
        ?>
				<title><?php 
        echo $pagetitle;
        ?>
</title>
				<link rel="stylesheet" href="<?php 
        echo WEBPATH . '/' . ZENFOLDER;
        ?>
/admin.css" type="text/css" />
示例#7
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;
 }
/**
 * Sets the optional textdomain for separate translation files for themes.
 * The plugin translation files must be located within
 * zenphoto/themes/<theme name>/locale/<language locale>/LC_MESSAGES/ and must
 * have the name of the theme (<theme name>.po  <theme name>.mo)
 *
 * Return value is the success of the setlocale() call
 * 
 * @param string $plugindomain The name of the theme
 * @return bool
 */
function setThemeDomain($themedomain)
{
    return setupCurrentLocale($themedomain, "theme");
}