Skip to content

Commit

Permalink
Make checksum code skippable
Browse files Browse the repository at this point in the history
  • Loading branch information
garvinhicking committed Dec 9, 2008
1 parent 63fe29e commit d9a5d6a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
8 changes: 7 additions & 1 deletion bundled-libs/serendipity_generateFTPChecksums.php
Expand Up @@ -9,10 +9,15 @@
die ("Don't hack!\n");
}

echo "Creating checksums.\n";

$basedir = realpath(dirname(__FILE__) . '/../') . '/';
require_once $basedir . 'include/functions_installer.inc.php';
require_once $basedir . 'include/functions_images.inc.php';

$conf = file_get_contents($basedir . 'serendipity_config.inc.php');
preg_match('@\$serendipity\[\'version\'\]\s*=\s*\'(.+)\'@imsU', $conf, $vmatch);

// Find all the files in the serendipity directory and calculate their md5 sums
$sums = array();
$excludes = array(
Expand All @@ -21,6 +26,7 @@
);
$files = serendipity_traversePath($basedir, '', false);
foreach ($files as $fdata) {
echo $fdata['relpath'] . "\n";
// Don't take checksums of directories
if ($fdata['directory']) {
continue;
Expand Down Expand Up @@ -48,7 +54,7 @@
if (!$file) {
die('Unable to open output file!');
}
fwrite($file, '<?php' . "\n" . 'global $serendipity;' . "\n" . '$serendipity[\'checksums\'] = array (' . "\n");
fwrite($file, '<?php' . "\n" . 'global $serendipity;' . "\n" . '$serendipity[\'checksums_' . $vmatch[1] . '\'] = array (' . "\n");
foreach ($sums as $fname => $sum) {
fwrite($file, "'$fname' => '$sum',\n");
}
Expand Down
Empty file added checksums.inc.php
Empty file.
2 changes: 1 addition & 1 deletion include/admin/upgrader.inc.php
Expand Up @@ -276,7 +276,7 @@ function serendipity_upgraderResultDiagnose($result, $s) {
echo serendipity_upgraderResultDiagnose(S9Y_U_SUCCESS, CHECKSUMS_PASS);
} else {
foreach ($badsums as $rfile => $sum) {
echo serendipity_upgraderResultDiagnose(S9Y_U_ERROR, sprintf(CHECKSUM_FAILED, $rfile));
echo serendipity_upgraderResultDiagnose(S9Y_U_WARNING, sprintf(CHECKSUM_FAILED, $rfile)) . "<br />\n";
}
}
?></td>
Expand Down
3 changes: 3 additions & 0 deletions include/functions_config.inc.php
Expand Up @@ -887,6 +887,9 @@ function serendipity_getSessionLanguage() {
return $serendipity['lang'];
}
*/
if (isset($serendipity['lang']) && !isset($serendipity['languages'][$serendipity['lang']])) {
$serendipity['lang'] = $serendipity['autolang'];
}

if (isset($_REQUEST['user_language']) && (!empty($serendipity['languages'][$_REQUEST['user_language']])) && !headers_sent()) {
serendipity_setCookie('serendipityLanguage', $_REQUEST['user_language'], false);
Expand Down
20 changes: 17 additions & 3 deletions include/functions_installer.inc.php
Expand Up @@ -1273,12 +1273,26 @@ function serendipity_FTPChecksum($filename, $type = null) {
* relative path of the file, and values are the bad checksum
*/
function serendipity_verifyFTPChecksums() {
global $serendipity;

$badsums = array();

// Load the checksums
require_once S9Y_INCLUDE_PATH . 'checksums.inc.php';
$f = S9Y_INCLUDE_PATH . 'checksums.inc.php';

if (!file_exists($f) || filesize($f) < 1) {
return $badsums;
}

require_once $f;
// Verify that every file in the checksum list was uploaded correctly
$badsums = array();
$basedir = realpath(dirname(__FILE__) . '/../');
foreach ($serendipity['checksums'] as $prel => $sum) {

if (!is_array($serendipity['checksums_' . $serendipity['version']])) {
return $badsums;
}

foreach ($serendipity['checksums_' . $serendipity['version']] as $prel => $sum) {
$path = $basedir . '/' . $prel;
// Don't take checksums of directories
if (is_dir($path)) {
Expand Down
5 changes: 5 additions & 0 deletions include/lang.inc.php
Expand Up @@ -6,6 +6,10 @@
die ("Don't hack!");
}

if (isset($serendipity['lang']) && !isset($serendipity['languages'][$serendipity['lang']])) {
$serendipity['lang'] = $serendipity['autolang'];
}

if (!defined('serendipity_LANG_LOADED') || serendipity_LANG_LOADED !== true) {
$charset = serendipity_getCharset();

Expand All @@ -21,6 +25,7 @@
}

// Try and include preferred language from the configurated setting

if (@include(S9Y_INCLUDE_PATH . 'lang/' . $charset . 'serendipity_lang_'. $serendipity['lang'] .'.inc.php') ) {
// Only here can we truely say the language is loaded
define('serendipity_LANG_LOADED', true);
Expand Down

0 comments on commit d9a5d6a

Please sign in to comment.