/** * * HTML for the configuration change notification */ function reconfigurePage($diff, $needs, $mandatory) { if (OFFSET_PATH) { $where = 'admin'; } else { $where = 'gallery'; } if (function_exists('getXSRFToken')) { $token = '&xsrfToken=' . getXSRFToken('setup'); } else { $token = ''; } $l1 = '<a href="' . WEBPATH . '/' . ZENFOLDER . '/setup.php?autorun=' . $where . $token . '">'; $l2 = '</a>'; ?> <div class="reconfigbox"> <h1> <?php echo gettext('ZenPhoto20 has detected a change in your installation.'); ?> </h1> <div id="errors"> <ul> <?php foreach ($diff as $thing => $rslt) { switch ($thing) { case 'SERVER_SOFTWARE': echo '<li>' . sprintf(gettext('Your server software has changed from %1$s to %2$s.'), $rslt['old'], $rslt['new']) . '</li>'; break; case 'DATABASE': $dbs = db_software(); echo '<li>' . sprintf(gettext('Your database software has changed from %1$s to %2$s.'), $rslt['old'], $rslt['new']) . '</li>'; break; case 'ZENPHOTO': echo '<li>' . sprintf(gettext('ZenPhoto20 %1$s has been copied over %2$s.'), ZENPHOTO_VERSION, $rslt['old']) . '</li>'; break; case 'FOLDER': echo '<li>' . sprintf(gettext('Your installation has moved from %1$s to %2$s.'), $rslt['old'], $rslt['new']) . '</li>'; break; case 'CONFIGURATION': echo '<li>' . gettext('Your installation configuration is damaged.') . ' ' . $rslt['old'] . '</li>'; $l1 = ''; break; case 'REQUESTS': if (!empty($rslt)) { echo '<li><div id="files">'; echo gettext('setup has been requested by:'); echo '<ul>'; foreach ($rslt['old'] as $request) { echo '<li>' . $request . '</li>'; } echo '</ul></div></li>'; } break; default: $sz = @filesize(SERVERPATH . '/' . ZENFOLDER . '/' . $thing); echo '<li>' . sprintf(gettext('The script <code>%1$s</code> has changed.'), $thing) . '</li>'; break; } } ?> </ul> </div> <p> <?php if ($mandatory) { printf(gettext('The change detected is critical. You <strong>must</strong> run %1$ssetup%2$s for your site to function.'), $l1, $l2); } else { printf(gettext('The change detected may not be critical but you should run %1$ssetup%2$s at your earliest convenience.'), $l1, $l2); } ?> </p> </div> <?php }
/** * * Computes the "installation signature" of the Zenphoto install * @return string */ function installSignature() { $testFiles = array('template-functions.php' => filesize(SERVERPATH . '/' . ZENFOLDER . '/template-functions.php'), 'functions-filter.php' => filesize(SERVERPATH . '/' . ZENFOLDER . '/functions-filter.php'), 'lib-auth.php' => filesize(SERVERPATH . '/' . ZENFOLDER . '/lib-auth.php'), 'lib-utf8.php' => filesize(SERVERPATH . '/' . ZENFOLDER . '/lib-utf8.php'), 'functions.php' => filesize(SERVERPATH . '/' . ZENFOLDER . '/functions.php'), 'functions-basic.php' => filesize(SERVERPATH . '/' . ZENFOLDER . '/functions-basic.php'), 'functions-controller.php' => filesize(SERVERPATH . '/' . ZENFOLDER . '/functions-controller.php'), 'functions-image.php' => filesize(SERVERPATH . '/' . ZENFOLDER . '/functions-image.php')); if (isset($_SERVER['SERVER_SOFTWARE'])) { $s = $_SERVER['SERVER_SOFTWARE']; } else { $s = 'software unknown'; } $dbs = db_software(); $version = ZENPHOTO_VERSION; $i = strpos($version, '-'); if ($i !== false) { $version = substr($version, 0, $i); } return array_merge($testFiles, array('SERVER_SOFTWARE' => $s, 'ZENPHOTO' => $version . '[' . ZENPHOTO_RELEASE . ']', 'FOLDER' => dirname(SERVERPATH . '/' . ZENFOLDER), 'DATABASE' => $dbs['application'] . ' ' . $dbs['version'])); }
function db_collation() { $software = db_software(); if (substr(trim($software['version']), 0, 1) > '4') { $collation = ' CHARACTER SET utf8 COLLATE utf8_unicode_ci'; } else { $collation = ''; } return $collation; }
<?php } } } $connection = db_connect($_zp_conf_vars, false); if ($connection) { if (empty($_zp_conf_vars['mysql_database'])) { $connection = false; $connectDBErr = gettext('No database selected'); } } else { $connectDBErr = db_error(); } if ($_zp_DB_connection) { // connected to DB software $dbsoftware = db_software(); $dbapp = $dbsoftware['application']; $dbversion = $dbsoftware['version']; $required = $dbsoftware['required']; $desired = $dbsoftware['desired']; $sqlv = versionCheck($required, $desired, $dbversion); $good = checkMark($sqlv, sprintf(gettext('%1$s version %2$s'), $dbapp, $dbversion), "", sprintf(gettext('%1$s Version %2$s or greater is required. Version %3$s or greater is preferred. Use a lower version at your own risk.'), $dbapp, $required, $desired), false) && $good; } primeMark(gettext('Database connection')); if ($cfg) { if ($adminstuff = !extension_loaded(strtolower($selected_database)) || !$connection) { if (is_writable(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE)) { $good = false; checkMark(false, '', gettext("Database credentials in configuration file"), sprintf(gettext('<em>%1$s</em> reported: %2$s'), DATABASE_SOFTWARE, $connectDBErr)); // input form for the information include dirname(__FILE__) . '/setup-sqlform.php';
<?php /* * compares current database to the release database template and makes * updates as needed * * @author Stephen Billard * @Copyright 2016 by Stephen L Billard for use in {@link https://github.com/ZenPhoto20/ZenPhoto20 ZenPhoto20} * */ $dbSoftware = db_software(); $indexComments = version_compare($dbSoftware['version'], '5.5.0') >= 0; $database = $orphans = array(); foreach (getDBTables() as $table) { $tablecols = db_list_fields($table); foreach ($tablecols as $key => $datum) { //remove don't care fields unset($datum['Collation']); unset($datum['Key']); unset($datum['Extra']); unset($datum['Privileges']); $database[$table]['fields'][$datum['Field']] = $datum; } $indices = array(); $sql = 'SHOW KEYS FROM ' . prefix($table); $result = query_full_array($sql); foreach ($result as $index) { if ($index['Key_name'] !== 'PRIMARY') { $indices[$index['Key_name']][] = $index; } }