Пример #1
0
 function __construct()
 {
     global $_configMutex, $_zp_conf_vars;
     $_configMutex->lock();
     $zp_cfg = file_get_contents(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE);
     $i = strpos($zp_cfg, "\$conf['special_pages']");
     $j = strpos($zp_cfg, '//', $i);
     if ($i === false || $j === false) {
         $conf = array('special_pages' => array());
         $this->conf_vars = $conf['special_pages'];
         $i = strpos($zp_cfg, '/** Do not edit below this line. **/');
         if ($i === false) {
             zp_error(gettext('The Zenphoto configuration file is corrupt. You will need to restore it from a backup.'));
         }
         $this->zp_cfg_a = substr($zp_cfg, 0, $i);
         $this->zp_cfg_b = "//\n" . substr($zp_cfg, $i);
     } else {
         $this->zp_cfg_a = substr($zp_cfg, 0, $i);
         $this->zp_cfg_b = substr($zp_cfg, $j);
         eval(substr($zp_cfg, $i, $j - $i));
         $this->conf_vars = $conf['special_pages'];
         foreach ($_zp_conf_vars['special_pages'] as $page => $element) {
             if (isset($element['option'])) {
                 $this->plugin_vars[$page] = $element;
             }
         }
     }
     if (OFFSET_PATH == 2) {
         $old = array_keys($conf['special_pages']);
         $zp_cfg = file_get_contents(SERVERPATH . '/' . ZENFOLDER . '/zenphoto_cfg.txt');
         $i = strpos($zp_cfg, "\$conf['special_pages']");
         $j = strpos($zp_cfg, '//', $i);
         eval(substr($zp_cfg, $i, $j - $i));
         $new = array_keys($conf['special_pages']);
         if ($old != $new) {
             //Things have changed, need to reset to defaults;
             setOption('rewriteTokens_restore', 1);
             $this->handleOptionSave(NULL, NULL);
             setupLog(gettext('rewriteTokens restored to default'), true);
         }
     } else {
         enableExtension('rewriteTokens', 97 | ADMIN_PLUGIN);
         //	plugin must be enabled for saving options
     }
 }
Пример #2
0
    $priority = $plugin_is_filter & PLUGIN_PRIORITY;
    if ($plugin_is_filter & CLASS_PLUGIN) {
        $priority .= ' | CLASS_PLUGIN';
    }
    if ($plugin_is_filter & ADMIN_PLUGIN) {
        $priority .= ' | ADMIN_PLUGIN';
    }
    if ($plugin_is_filter & FEATURE_PLUGIN) {
        $priority .= ' | FEATURE_PLUGIN';
    }
    if ($plugin_is_filter & THEME_PLUGIN) {
        $priority .= ' | THEME_PLUGIN';
    }
    setupLog(sprintf(gettext('Plugin:%s enabled (%2$s)'), $extension, $priority), true);
    enableExtension($extension, $plugin_is_filter);
}
if ($option_interface) {
    //	prime the default options
    setupLog(sprintf(gettext('Plugin:%1$s option interface instantiated (%2$s)'), $extension, $option_interface), true);
    $option_interface = new $option_interface();
}
setupLog(sprintf(gettext('Plugin:%s setup completed'), $extension), true);
$iMutex->unlock();
$fp = fopen(SERVERPATH . '/' . ZENFOLDER . '/images/pass.png', 'rb');
// send the right headers
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header("Content-Type: image/png");
header("Content-Length: " . filesize(SERVERPATH . '/' . ZENFOLDER . '/images/pass.png'));
// dump the picture and stop the script
fpassthru($fp);
fclose($fp);
<?php

/**
 * Used for settint theme default options
 *
 * @package setup
 *
 */
define('OFFSET_PATH', 3);
require_once 'setup-functions.php';
require_once dirname(dirname(__FILE__)) . '/functions.php';
$theme = sanitize(sanitize($_POST['theme']));
require_once SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/themeoptions.php';
$optionHandler = new ThemeOptions();
/* prime the default theme options */
setupLog(sprintf(gettext('Set default options for %s'), $theme));
    ?>
" alt="<?php 
    echo $extension;
    ?>
" height="16px" width="16px" />
		</span>
		<?php 
    if (!$deprecate) {
        unset($plugins[$key]);
    }
}
?>
</p>

<?php 
if ($deprecate) {
    require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/deprecated-functions.php';
    $deprecated = new deprecated_functions();
    $listed = sha1(serialize($deprecated->listed_functions));
    if ($listed != getOption('deprecated_functions_signature')) {
        setOption('deprecated_functions_signature', $listed);
        enableExtension('deprecated-functions', 900 | CLASS_PLUGIN);
        setupLog(gettext('There has been a change in function deprecation. The deprecated-functions plugin has been enabled.'), true);
    }
    $compatibility = sha1(serialize($themes)) . sha1(serialize($plugins));
    if ($compatibility != getOption('zenphotoCompatibilityPack_signature')) {
        setOption('zenphotoCompatibilityPack_signature', $compatibility);
        enableExtension('zenphotoCompatibilityPack', 1 | CLASS_PLUGIN);
        setupLog(gettext('There has been a change of themes or plugins. The zenphotoCompatibilityPack plugin has been enabled.'), true);
    }
}
 *
 * @author Stephen Billard (sbillard)
 *
 * @package setup
 *
 */
require_once dirname(dirname(__FILE__)) . '/functions-basic.php';
require_once dirname(__FILE__) . '/setup-functions.php';
$iMutex = new zpMutex('i', getOption('imageProcessorConcurrency'));
$iMutex->lock();
$mod_rewrite = MOD_REWRITE;
if (is_null($mod_rewrite)) {
    $msg = gettext('The option “mod_rewrite” will be set to “enabled”.');
    setOption('mod_rewrite', 1);
} else {
    if ($mod_rewrite) {
        $msg = gettext('The option “mod_rewrite” is “enabled”.');
    } else {
        $msg = gettext('The option “mod_rewrite” is “disabled”.');
    }
}
setOption('mod_rewrite_detected', 1);
setupLog(gettext('Notice: “Module mod_rewrite” is working.') . ' ' . $msg, true);
$fp = fopen(SERVERPATH . '/' . ZENFOLDER . '/images/pass.png', 'rb');
// send the right headers
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header("Content-Type: image/png");
header("Content-Length: " . filesize(SERVERPATH . '/' . ZENFOLDER . '/images/pass.png'));
// dump the picture and stop the script
fpassthru($fp);
fclose($fp);
Пример #6
0
 function checkMark($check, $text, $sfx, $msg)
 {
     global $warn;
     $dsp = '';
     if ($check > 0) {
         $check = 1;
     }
     echo "\n<br/><span class=\"";
     switch ($check) {
         case 0:
             $dsp = "fail";
             break;
         case -1:
             $dsp = "warn";
             $warn = true;
             break;
         case 1:
             $dsp = "pass";
             break;
     }
     echo $dsp . "\">{$text}</span>";
     $dsp .= ' ' . trim($text);
     if ($check <= 0) {
         if (!empty($sfx)) {
             echo $sfx;
             $dsp .= ' ' . trim($sfx);
         }
         if (!empty($msg)) {
             if ($check == 0) {
                 echo '<div class="error">';
                 echo gettext('Error!');
                 echo "<p>" . $msg . "</p>";
                 echo "</div>";
             } else {
                 echo '<div class="warning">';
                 echo gettext('Warning!');
                 echo "<p>" . $msg . "</p>";
                 echo "</div>";
             }
             $dsp .= ' ' . trim($msg);
         }
     }
     setupLog($dsp);
     return $check;
 }
Пример #7
0
        preg_match('|@category\\s+(.*)\\s|', $str, $matches);
        $deprecate = !isset($matches[1]) || $matches[1] != 'package';
    } else {
        $deprecate = true;
    }
} else {
    $deprecate = false;
}
if ($option_interface) {
    //	prime the default options
    setupLog(sprintf(gettext('Plugin:%1$s option interface instantiated (%2$s)'), $extension, $option_interface));
    $option_interface = new $option_interface();
}
$iMutex->unlock();
if ($deprecate) {
    $img = 'pass_2.png';
} else {
    $img = 'pass.png';
}
$fp = fopen(SERVERPATH . '/' . ZENFOLDER . '/images/' . $img, 'rb');
// send the right headers
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header("Content-Type: image/png");
header("Content-Length: " . filesize(SERVERPATH . '/' . ZENFOLDER . '/images/' . $img));
// dump the picture and stop the script
fpassthru($fp);
fclose($fp);
list($usec, $sec) = explode(" ", microtime());
$last = (double) $usec + (double) $sec;
setupLog(sprintf(gettext('Plugin:%1$s setup completed in %2$.4f seconds'), $extension, $last - $start));
Пример #8
0
     if ($updateErrors) {
         $autorun = false;
         echo gettext('Done with table update with errors. See the <code>setup</code> log for details.');
     } else {
         echo gettext('Done with table update.');
     }
     echo "</h3>";
     checkUnique($tbl_administrators, array('valid' => 0, 'user' => 0));
     checkUnique($tbl_albums, array('folder' => 0));
     checkUnique($tbl_images, array('albumid' => 0, 'filename' => 0));
     checkUnique($tbl_options, array('name' => 0, 'ownerid' => 0, 'theme' => 0));
     checkUnique($tbl_news_categories, array('titlelink' => 0));
     checkUnique($tbl_news, array('titlelink' => 0));
     checkUnique($tbl_pages, array('titlelink' => 0));
     checkUnique($tbl_tags, array('name' => 0));
     setupLog(gettext("Done with database creation and update"), true);
     // set defaults on any options that need it
     require dirname(__FILE__) . '/setup-option-defaults.php';
     if ($debug == 'albumids') {
         // fixes 1.2 move/copy albums with wrong ids
         $albums = $_zp_gallery->getAlbums();
         foreach ($albums as $album) {
             checkAlbumParentid($album, NULL, 'setuplog');
         }
     }
 }
 zp_apply_filter('log_setup', $updateErrors, 'install', gettext('Completed'));
 $clones = array();
 if ($_zp_loggedin == ADMIN_RIGHTS) {
     $filelist = safe_glob(SERVERPATH . "/" . BACKUPFOLDER . '/*.zdb');
     if (count($filelist) > 0) {
Пример #9
0
/**
 * helper delete function for setup files.
 *
 * @param string $component
 */
function setupDeleteComponent($rslt, $component)
{
    if ($rslt) {
        setupLog(sprintf(gettext('%s deleted.'), $component), true);
        return true;
    } else {
        setupLog(sprintf(gettext('failed to delete %s.'), $component), true);
        return false;
    }
}
Пример #10
0
                if ($indexComments) {
                    $tableString .= "  COMMENT 'zp20'";
                }
                $create[] = $tableString . ',';
            }
            unset($database[$tablename]['keys'][$key]);
        }
    }
    if (!$exists) {
        $create[] = "  PRIMARY KEY (`id`)";
        $create[] = ") {$collation};";
        $create = implode("\n", $create);
        setupQuery($create);
    } else {
        //handle surplus fields
        if (array_key_exists('keys', $database[$tablename]) && !empty($database[$tablename]['keys'])) {
            foreach ($database[$tablename]['keys'] as $index) {
                $key = $index['Key_name'];
                if (isset($index['Index_comment']) && $index['Index_comment'] === 'zp20') {
                    $dropString = "ALTER TABLE " . prefix($tablename) . " DROP INDEX `" . $key . "`;";
                    setupQuery($dropString);
                } else {
                    $orpahns = sprintf(gettext('Setup found the key "%1$s" in the "%2$s" table. This index is not in use by ZenPhoto20.'), $key, $tablename);
                }
            }
        }
    }
}
foreach ($orphans as $message) {
    setupLog($message, true);
}
Пример #11
0
function updateConfigfile($zp_cfg)
{
    global $xsrftoken;
    $mod1 = fileperms(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE) & 0777;
    $mod2 = fileperms(SERVERPATH . '/' . DATA_FOLDER) & 0777;
    @chmod(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, 0777);
    if (is_writeable(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE)) {
        rename(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, $backkup = SERVERPATH . '/' . DATA_FOLDER . '/' . str_replace(strrchr(CONFIGFILE, "."), '', CONFIGFILE) . '.bak.php');
        chmod($backkup, $mod1);
        if ($handle = fopen(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, 'w')) {
            if (fwrite($handle, $zp_cfg)) {
                setupLog(gettext("Updated configuration file"));
                $base = true;
            }
        }
        fclose($handle);
        clearstatcache();
    }
    @chmod(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, $mod2);
    $str = configMod();
    $xsrftoken = sha1(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE . $str . session_id());
}
Пример #12
0
setupLog(sprintf(gettext('Theme:%s setup started'), $theme));
$requirePath = getPlugin('themeoptions.php', $theme);
if (!empty($requirePath)) {
    require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/cacheManager.php';
    require_once SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/themeoptions.php';
    /* prime the default theme options */
    $_zp_gallery->setCurrentTheme($theme);
    $optionHandler = new ThemeOptions();
    setupLog(sprintf(gettext('Theme:%s option interface instantiated'), $theme));
}
/* then set any "standard" options that may not have been covered by the theme */
standardThemeOptions($theme, NULL);
$iMutex->unlock();
if (protectedTheme($theme)) {
    $img = 'pass.png';
} else {
    $img = 'pass_2.png';
}
$fp = fopen(SERVERPATH . '/' . ZENFOLDER . '/images/' . $img, 'rb');
// send the right headers
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header("Content-Type: image/png");
header("Content-Length: " . filesize(SERVERPATH . '/' . ZENFOLDER . '/images/' . $img));
// dump the picture and stop the script
fpassthru($fp);
fclose($fp);
list($usec, $sec) = explode(" ", microtime());
$last = (double) $usec + (double) $sec;
/* and record that we finished */
setupLog(sprintf(gettext('Theme:%s setup completed in %2$.4f seconds'), $theme, $last - $start));
Пример #13
0
 */
define('OFFSET_PATH', 2);
require_once dirname(dirname(__FILE__)) . '/functions.php';
require_once dirname(__FILE__) . '/setup-functions.php';
if (!isset($_POST['folder'])) {
    exit;
}
$folder = rtrim(sanitize($_POST['folder'], 3), '/');
if ($_POST['key'] == sha1(filemtime(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE) . file_get_contents(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE))) {
    if (folderPermissions($folder)) {
        setupLog(sprintf(gettext('Setting permissions (0%o) for %s.'), FILE_MOD, basename($folder)), true);
    } else {
        setupLog(sprintf(gettext('Notice: failed setting permissions (0%o) for %s.'), FILE_MOD, basename($folder)), true);
    }
} else {
    setupLog(sprintf(gettext('Notice: illegal call for permissions setting for %s.'), basename($folder)), true);
}
clearstatcache();
function folderPermissions($folder)
{
    $files = array();
    if (($dir = opendir($folder)) !== false) {
        while (($file = readdir($dir)) !== false) {
            if ($file != '.' && $file != '..') {
                $files[] = $file;
            }
        }
        closedir($dir);
    }
    foreach ($files as $file) {
        $path = $folder . '/' . $file;
Пример #14
0
function debugLog($message, $reset = false)
{
    setupLog($message, true);
}
Пример #15
0
         echo gettext('Done with table update with errors');
     }
 }
 echo "</h3>";
 checkUnique($tbl_administrators, array('valid' => 0, 'user' => 0));
 checkUnique($tbl_albums, array('folder' => 0));
 checkUnique($tbl_images, array('albumid' => 0, 'filename' => 0));
 checkUnique($tbl_options, array('name' => 0, 'ownerid' => 0, 'theme' => 0));
 checkUnique($tbl_news_categories, array('titlelink' => 0));
 checkUnique($tbl_news, array('titlelink' => 0));
 checkUnique($tbl_pages, array('titlelink' => 0));
 checkUnique($tbl_tags, array('name' => 0));
 // set defaults on any options that need it
 setupLog(gettext("Done with database creation and update"));
 if ($prevRel = getOption('zenphoto_release')) {
     setupLog(sprintf(gettext("Previous Release was %s"), $prevRel), true);
 }
 require dirname(__FILE__) . '/setup-option-defaults.php';
 if ($debug == 'base64') {
     // update zenpage codeblocks--remove the base64 encoding
     $sql = 'SELECT `id`, `codeblock` FROM ' . prefix('news') . ' WHERE `codeblock` NOT REGEXP "^a:[0-9]+:{"';
     $result = query_full_array($sql, false);
     if (is_array($result)) {
         foreach ($result as $row) {
             $codeblock = base64_decode($row['codeblock']);
             $sql = 'UPDATE ' . prefix('news') . ' SET `codeblock`=' . db_quote($codeblock) . ' WHERE `id`=' . $row['id'];
             query($sql);
         }
     }
     $sql = 'SELECT `id`, `codeblock` FROM ' . prefix('pages') . ' WHERE `codeblock` NOT REGEXP "^a:[0-9]+:{"';
     $result = query_full_array($sql, false);
Пример #16
0
 * @package setup
 *
 */
define('OFFSET_PATH', 2);
require_once 'setup-functions.php';
require_once dirname(dirname(__FILE__)) . '/admin-functions.php';
$iMutex = new Mutex('i', getOption('imageProcessorConcurrency'));
$iMutex->lock();
$theme = sanitize($_REQUEST['theme']);
setupLog(sprintf(gettext('Theme:%s setup started'), $theme), true);
$requirePath = getPlugin('themeoptions.php', $theme);
if (!empty($requirePath)) {
    require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/cacheManager.php';
    require_once SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/themeoptions.php';
    /* prime the default theme options */
    $optionHandler = new ThemeOptions();
    setupLog(sprintf(gettext('Theme:%s option interface instantiated'), $theme), true);
}
/* then set any "standard" options that may not have been covered by the theme */
standardThemeOptions($theme, NULL);
/* and record that we finished */
setupLog(sprintf(gettext('Theme:%s setup completed'), $theme), true);
$iMutex->unlock();
$fp = fopen(SERVERPATH . '/' . ZENFOLDER . '/images/pass.png', 'rb');
// send the right headers
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header("Content-Type: image/png");
header("Content-Length: " . filesize(SERVERPATH . '/' . ZENFOLDER . '/images/pass.png'));
// dump the picture and stop the script
fpassthru($fp);
fclose($fp);
Пример #17
0
purgeOption('zenphoto_version');
purgeOption('zenphoto_install');
setOption('zenphoto_install', serialize(installSignature()));
if (Zenphoto_Authority::$preferred_version > ($oldv = getOption('libauth_version'))) {
    if (empty($oldv)) {
        //	The password hash of these old versions did not have the extra text.
        //	Note: if the administrators table is empty we will re-do this option with the good stuff.
        purgeOption('extra_auth_hash_text');
        setOptionDefault('extra_auth_hash_text', '');
    }
    $msg = sprintf(gettext('Migrating lib-auth data version %1$s => version %2$s'), $oldv, Zenphoto_Authority::$preferred_version);
    if (!$_zp_authority->migrateAuth(Zenphoto_Authority::$preferred_version)) {
        $msg .= ': ' . gettext('failed');
    }
    echo $msg;
    setupLog($msg, true);
}
$admins = $_zp_authority->getAdministrators('all');
if (empty($admins)) {
    //	empty administrators table
    $groupsdefined = NULL;
    if (function_exists('hash')) {
        setOption('strong_hash', 3);
    } else {
        setOption('strong_hash', 1);
    }
    purgeOption('extra_auth_hash_text');
} else {
    if (function_exists('hash') && getOption('strong_hash') == 2) {
        setOption('strong_hash', 3);
    }
Пример #18
0
/**
 * Executes and logs database update queries
 * @param string $sql
 *
 * @author Stephen Billard
 * @Copyright 2016 by Stephen L Billard for use in {@link https://github.com/ZenPhoto20/ZenPhoto20 ZenPhoto20}
 */
function setupQuery($sql)
{
    global $updateErrors;
    $result = db_table_update($sql);
    if (OFFSET_PATH == 2) {
        //don't write to setup log if not running setup
        if ($result) {
            setupLog(sprintf(gettext('Query Success: %s'), $sql), true);
        } else {
            $updateErrors = true;
            $error = db_error();
            setupLog(sprintf(gettext('Query Failed: %1$s ' . "\n" . ' Error: %2$s'), $sql, $error), true);
        }
    }
    return $result;
}