88 lines
3.0 KiB
PHP
88 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* @author Paul Baranowski <paul@paulbaranowski.org>
|
|
* @version $Revision: 2834 $
|
|
* @package Campcaster
|
|
* @subpackage StorageServer
|
|
* @copyright 2006 MDLF, Inc.
|
|
* @license http://www.gnu.org/licenses/gpl.txt
|
|
* @link http://www.campware.org
|
|
*
|
|
* Note: This file was broken into two parts: install.php and
|
|
* installMain.php so that the archive server could use the same
|
|
* installation script, but with just a different config file.
|
|
*/
|
|
|
|
// Do not allow remote execution
|
|
$arr = array_diff_assoc($_SERVER, $_ENV);
|
|
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
|
header("HTTP/1.1 400");
|
|
header("Content-type: text/plain; charset=UTF-8");
|
|
echo "400 Not executable\r\n";
|
|
exit(1);
|
|
}
|
|
|
|
echo "**********************************\n";
|
|
echo "* StorageServer Upgrade to 1.2.0 *\n";
|
|
echo "**********************************\n";
|
|
|
|
require_once(dirname(__FILE__).'/../../conf.php');
|
|
require_once(dirname(__FILE__)."/../installInit.php");
|
|
require_once(dirname(__FILE__)."/../../StoredFile.php");
|
|
|
|
// Check to see if upgrade has already been applied
|
|
$sql = "SELECT md5 FROM ".$CC_CONFIG['filesTable']." LIMIT 1";
|
|
$result = $CC_DBC->query($sql);
|
|
if (!PEAR::isError($result)) {
|
|
echo "THIS UPGRADE HAS ALREADY BEEN APPLIED.\n";
|
|
exit(0);
|
|
}
|
|
|
|
echo " * Adding column 'md5' to '".$CC_CONFIG['filesTable']." table...";
|
|
$sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ADD COLUMN md5 char(32)";
|
|
camp_install_query($sql, false);
|
|
$sql = "ALTER TABLE ".$CC_CONFIG['filesTable']." ALTER COLUMN md5 SET STORAGE EXTENDED";
|
|
camp_install_query($sql);
|
|
|
|
echo " * Creating index on column 'md5'...";
|
|
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx ON ".$CC_CONFIG['filesTable']." (md5)";
|
|
camp_install_query($sql);
|
|
|
|
echo " * Converting metadata values 'ls:genre' to 'dc:type'...";
|
|
$sql = "UPDATE ".$CC_CONFIG['mdataTable']." SET predns='dc', predicate='type' WHERE predns='ls' and predicate='genre'";
|
|
camp_install_query($sql);
|
|
|
|
// Get MD5 values for all files
|
|
echo " * Computing MD5 sums for all files (this may take a while)...\n";
|
|
$sql = "SELECT to_hex(gunid) as gunid, name FROM ".$CC_CONFIG['filesTable'] ." WHERE ftype='audioclip'";
|
|
$rows = $CC_DBC->GetAll($sql);
|
|
$errorFiles = array();
|
|
foreach ($rows as $row) {
|
|
$gunid = StoredFile::NormalizeGunid($row['gunid']);
|
|
$storedFile = new StoredFile($gunid);
|
|
$fileName = $storedFile->getRealFileName();
|
|
$humanName = basename($row['name']);
|
|
echo " File: $humanName\n";
|
|
if (file_exists($fileName)) {
|
|
$md5 = md5_file($fileName);
|
|
$storedFile->setMd5($md5);
|
|
//echo " MD5: $md5\n";
|
|
} else {
|
|
$errorFiles[] = "$gunid -- $humanName";
|
|
echo " ERROR: file does not exist! (GUNID: $gunid)\n";
|
|
}
|
|
}
|
|
|
|
if (count($errorFiles) > 0) {
|
|
echo "\n\nWARNING\n";
|
|
echo "The following files were not found:\n";
|
|
foreach ($errorFiles as $file) {
|
|
echo $file."\n";
|
|
}
|
|
}
|
|
echo "*******************************************\n";
|
|
echo "* StorageServer Upgrade to 1.2.0 Complete *\n";
|
|
echo "*******************************************\n";
|
|
|
|
?>
|