Fixed whitespace to standard coding conventions.
This commit is contained in:
parent
52fe579ce4
commit
8014f94c58
35 changed files with 6072 additions and 6070 deletions
|
@ -16,9 +16,9 @@ require_once('../backend/StoredFile.php');
|
|||
|
||||
function printUsage() {
|
||||
|
||||
global $CC_CONFIG;
|
||||
global $CC_CONFIG;
|
||||
|
||||
echo "Usage:\n";
|
||||
echo "Usage:\n";
|
||||
echo " ./CleanStor [OPTION] \n";
|
||||
echo "\n";
|
||||
echo "Options:\n";
|
||||
|
@ -31,33 +31,33 @@ function printUsage() {
|
|||
}
|
||||
|
||||
function camp_clean_files($p_path) {
|
||||
if (!empty($p_path) && (strlen($p_path) > 4)) {
|
||||
if (!empty($p_path) && (strlen($p_path) > 4)) {
|
||||
list($dirList,$fileList) = File_Find::maptree($p_path);
|
||||
|
||||
$array_mus;
|
||||
foreach ($fileList as $filepath) {
|
||||
|
||||
if (@substr($filepath, strlen($filepath) - 3) != "xml") {
|
||||
$array_mus[] = $filepath;
|
||||
}
|
||||
if (@substr($filepath, strlen($filepath) - 3) != "xml") {
|
||||
$array_mus[] = $filepath;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($array_mus as $audio_file) {
|
||||
|
||||
if (@is_link($audio_file) && !@stat($audio_file)) {
|
||||
if (@is_link($audio_file) && !@stat($audio_file)) {
|
||||
|
||||
//filesystem clean up.
|
||||
@unlink($audio_file);
|
||||
echo "unlinked $audio_file\n";
|
||||
@unlink($audio_file . ".xml");
|
||||
echo "unlinked " . $audio_file . ".xml\n";
|
||||
@rmdir(@dirname($audio_file));
|
||||
echo "removed dir " . @dirname($audio_file) . "\n";
|
||||
//filesystem clean up.
|
||||
@unlink($audio_file);
|
||||
echo "unlinked $audio_file\n";
|
||||
@unlink($audio_file . ".xml");
|
||||
echo "unlinked " . $audio_file . ".xml\n";
|
||||
@rmdir(@dirname($audio_file));
|
||||
echo "removed dir " . @dirname($audio_file) . "\n";
|
||||
|
||||
//database clean up.
|
||||
$stored_audio_file = StoredFile::RecallByGunid(@basename($audio_file));
|
||||
$stored_audio_file->delete();
|
||||
}
|
||||
//database clean up.
|
||||
$stored_audio_file = StoredFile::RecallByGunid(@basename($audio_file));
|
||||
$stored_audio_file->delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ function camp_remove_files($p_path) {
|
|||
list($dirList,$fileList) = File_Find::maptree($p_path);
|
||||
|
||||
foreach ($fileList as $filepath) {
|
||||
echo " * Removing $filepath\n";
|
||||
@unlink($filepath);
|
||||
echo " * Removing $filepath\n";
|
||||
@unlink($filepath);
|
||||
echo "done.\n";
|
||||
}
|
||||
foreach ($dirList as $dirpath) {
|
||||
|
@ -82,18 +82,18 @@ function camp_remove_files($p_path) {
|
|||
}
|
||||
|
||||
function camp_empty_db($db) {
|
||||
global $CC_CONFIG;
|
||||
global $CC_CONFIG;
|
||||
|
||||
if (!PEAR::isError($db)) {
|
||||
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
echo " * Deleting from database table ".$CC_CONFIG['filesTable']."\n";
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['filesTable'];
|
||||
camp_install_query($sql, false);
|
||||
}
|
||||
else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
|
||||
}
|
||||
}
|
||||
if (!PEAR::isError($db)) {
|
||||
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
echo " * Deleting from database table ".$CC_CONFIG['filesTable']."\n";
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['filesTable'];
|
||||
camp_install_query($sql, false);
|
||||
}
|
||||
else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,17 +104,17 @@ $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
|||
|
||||
switch($argv[1]){
|
||||
|
||||
case '-e':
|
||||
case '--empty':
|
||||
camp_empty_db($CC_DBC);
|
||||
camp_remove_files($CC_CONFIG['storageDir']);
|
||||
break;
|
||||
case '-c':
|
||||
case '--clean':
|
||||
camp_clean_files($CC_CONFIG['storageDir']);
|
||||
break;
|
||||
default:
|
||||
printUsage();
|
||||
case '-e':
|
||||
case '--empty':
|
||||
camp_empty_db($CC_DBC);
|
||||
camp_remove_files($CC_CONFIG['storageDir']);
|
||||
break;
|
||||
case '-c':
|
||||
case '--clean':
|
||||
camp_clean_files($CC_CONFIG['storageDir']);
|
||||
break;
|
||||
default:
|
||||
printUsage();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,18 +20,18 @@ $stid = $bs->storId;
|
|||
|
||||
function admDumpFolder(&$bs, $fid, $ind='')
|
||||
{
|
||||
// NOTE: need to fix this, removed due to tree removal
|
||||
// $name = M2tree::GetObjName($fid);
|
||||
// if (PEAR::isError($name)) {
|
||||
// echo $name->getMessage();
|
||||
// exit;
|
||||
// }
|
||||
// NOTE: need to fix this, removed due to tree removal
|
||||
// $name = M2tree::GetObjName($fid);
|
||||
// if (PEAR::isError($name)) {
|
||||
// echo $name->getMessage();
|
||||
// exit;
|
||||
// }
|
||||
$media = StoredFile::Recall($fid);
|
||||
$type = $media->getType();
|
||||
$gunid = $media->getGunid();
|
||||
$pars = array();
|
||||
if ($gunid) {
|
||||
$pars['id']="$gunid";
|
||||
$pars['id']="$gunid";
|
||||
}
|
||||
$pars['name'] = "$name";
|
||||
switch ($type) {
|
||||
|
@ -65,13 +65,13 @@ function admDumpGroup(&$bs, $gid, $ind='')
|
|||
{
|
||||
$name = Subjects::GetSubjName($gid);
|
||||
if (PEAR::isError($name)) {
|
||||
echo $name->getMessage();
|
||||
exit;
|
||||
echo $name->getMessage();
|
||||
exit;
|
||||
}
|
||||
$isGr = Subjects::IsGroup($gid);
|
||||
if (PEAR::isError($isGr)) {
|
||||
echo $isGr->getMessage();
|
||||
exit;
|
||||
echo $isGr->getMessage();
|
||||
exit;
|
||||
}
|
||||
$pars = array('name'=>"$name");
|
||||
$pars['id'] = $gid;
|
||||
|
@ -84,8 +84,8 @@ function admDumpGroup(&$bs, $gid, $ind='')
|
|||
}
|
||||
$garr = Subjects::ListGroup($gid);
|
||||
if (PEAR::isError($garr)) {
|
||||
echo $garr->getMessage();
|
||||
exit;
|
||||
echo $garr->getMessage();
|
||||
exit;
|
||||
}
|
||||
$res = '';
|
||||
foreach ($garr as $i => $member) {
|
||||
|
@ -99,98 +99,98 @@ function admDumpGroup(&$bs, $gid, $ind='')
|
|||
);
|
||||
$prefs = admDumpPrefs($bs, $gid);
|
||||
if (!is_null($prefs)) {
|
||||
$res .= $prefs;
|
||||
$res .= $prefs;
|
||||
}
|
||||
if ($res) {
|
||||
$tagarr['content'] = $res;
|
||||
$tagarr['content'] = $res;
|
||||
}
|
||||
return XML_Util::createTagFromArray($tagarr, $res === '');
|
||||
// if (!$res) {
|
||||
// } else {
|
||||
// return XML_Util::createTagFromArray(array(
|
||||
// 'namespace' => NSPACE,
|
||||
// 'localPart' => 'group',
|
||||
// 'attributes'=> $pars,
|
||||
// 'content' => $res,
|
||||
// ), FALSE);
|
||||
// }
|
||||
// if (!$res) {
|
||||
// } else {
|
||||
// return XML_Util::createTagFromArray(array(
|
||||
// 'namespace' => NSPACE,
|
||||
// 'localPart' => 'group',
|
||||
// 'attributes'=> $pars,
|
||||
// 'content' => $res,
|
||||
// ), FALSE);
|
||||
// }
|
||||
|
||||
}
|
||||
function admDumpSubjects(&$bs, $ind='')
|
||||
{
|
||||
$res ='';
|
||||
$subjs = Subjects::GetSubjects('id, login, pass, type');
|
||||
foreach ($subjs as $i => $member) {
|
||||
switch ($member['type']) {
|
||||
case "U":
|
||||
$prefs = admDumpPrefs($bs, $member['id']);
|
||||
$pars = array('login'=>"{$member['login']}", 'pass'=>"{$member['pass']}");
|
||||
$pars['id'] = $member['id'];
|
||||
$tagarr = array(
|
||||
}
|
||||
function admDumpSubjects(&$bs, $ind='')
|
||||
{
|
||||
$res ='';
|
||||
$subjs = Subjects::GetSubjects('id, login, pass, type');
|
||||
foreach ($subjs as $i => $member) {
|
||||
switch ($member['type']) {
|
||||
case "U":
|
||||
$prefs = admDumpPrefs($bs, $member['id']);
|
||||
$pars = array('login'=>"{$member['login']}", 'pass'=>"{$member['pass']}");
|
||||
$pars['id'] = $member['id'];
|
||||
$tagarr = array(
|
||||
'namespace' => NSPACE,
|
||||
'localPart' => 'user',
|
||||
'attributes'=> $pars,
|
||||
);
|
||||
if (!is_null($prefs)) {
|
||||
$tagarr['content'] = $prefs;
|
||||
}
|
||||
$res .= XML_Util::createTagFromArray($tagarr , FALSE);
|
||||
break;
|
||||
case "G":
|
||||
$res .= admDumpGroup($bs, $member['id'], "$ind ");
|
||||
break;
|
||||
);
|
||||
if (!is_null($prefs)) {
|
||||
$tagarr['content'] = $prefs;
|
||||
}
|
||||
$res .= XML_Util::createTagFromArray($tagarr , FALSE);
|
||||
break;
|
||||
case "G":
|
||||
$res .= admDumpGroup($bs, $member['id'], "$ind ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
# return "$ind<subjects>\n$res$ind</subjects>\n";
|
||||
return XML_Util::createTagFromArray(array(
|
||||
# return "$ind<subjects>\n$res$ind</subjects>\n";
|
||||
return XML_Util::createTagFromArray(array(
|
||||
'namespace' => NSPACE,
|
||||
'localPart' => 'subjects',
|
||||
'content'=> $res,
|
||||
), FALSE);
|
||||
}
|
||||
), FALSE);
|
||||
}
|
||||
|
||||
function admDumpPrefs(&$bs, $subjid)
|
||||
{
|
||||
$res ='';
|
||||
$pr = new Prefs($bs);
|
||||
$prefkeys = $pr->readKeys($subjid);
|
||||
# var_dump($subjid); var_dump($prefkeys); #exit;
|
||||
foreach ($prefkeys as $i => $prefk) {
|
||||
$keystr = $prefk['keystr'];
|
||||
$prefval = $pr->readVal($subjid, $keystr);
|
||||
$pars = array('name'=>"$keystr", 'val'=>"$prefval");
|
||||
$res .= XML_Util::createTagFromArray(array(
|
||||
function admDumpPrefs(&$bs, $subjid)
|
||||
{
|
||||
$res ='';
|
||||
$pr = new Prefs($bs);
|
||||
$prefkeys = $pr->readKeys($subjid);
|
||||
# var_dump($subjid); var_dump($prefkeys); #exit;
|
||||
foreach ($prefkeys as $i => $prefk) {
|
||||
$keystr = $prefk['keystr'];
|
||||
$prefval = $pr->readVal($subjid, $keystr);
|
||||
$pars = array('name'=>"$keystr", 'val'=>"$prefval");
|
||||
$res .= XML_Util::createTagFromArray(array(
|
||||
'namespace' => NSPACE,
|
||||
'localPart' => 'pref',
|
||||
'attributes'=> $pars,
|
||||
));
|
||||
}
|
||||
if (!$res) {
|
||||
return NULL;
|
||||
}
|
||||
return XML_Util::createTagFromArray(array(
|
||||
));
|
||||
}
|
||||
if (!$res) {
|
||||
return NULL;
|
||||
}
|
||||
return XML_Util::createTagFromArray(array(
|
||||
'namespace' => NSPACE,
|
||||
'localPart' => 'preferences',
|
||||
'content'=> $res,
|
||||
), FALSE);
|
||||
}
|
||||
), FALSE);
|
||||
}
|
||||
|
||||
$subjects = admDumpSubjects($bs, ' ');
|
||||
$tree = admDumpFolder($bs, $stid, ' ');
|
||||
$subjects = admDumpSubjects($bs, ' ');
|
||||
$tree = admDumpFolder($bs, $stid, ' ');
|
||||
|
||||
$res = XML_Util::getXMLDeclaration("1.0", "UTF-8")."\n";
|
||||
$node = XML_Util::createTagFromArray(array(
|
||||
$res = XML_Util::getXMLDeclaration("1.0", "UTF-8")."\n";
|
||||
$node = XML_Util::createTagFromArray(array(
|
||||
'namespace' => NSPACE,
|
||||
'localPart' => 'storageServer',
|
||||
'content' => "$subjects$tree",
|
||||
), FALSE);
|
||||
$res .= $node;
|
||||
), FALSE);
|
||||
$res .= $node;
|
||||
|
||||
$fmt = new XML_Beautifier();
|
||||
$res = $fmt->formatString($res);
|
||||
$fmt = new XML_Beautifier();
|
||||
$res = $fmt->formatString($res);
|
||||
|
||||
#var_export($res);
|
||||
#var_dump($res);
|
||||
echo "$res";
|
||||
#var_export($res);
|
||||
#var_dump($res);
|
||||
echo "$res";
|
||||
|
||||
?>
|
||||
?>
|
|
@ -26,7 +26,7 @@ function camp_import_error_handler()
|
|||
|
||||
function printUsage()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
global $CC_CONFIG;
|
||||
echo "There are two ways to import audio files into Campcaster: linking\n";
|
||||
echo "or copying.\n";
|
||||
echo "\n";
|
||||
|
@ -71,11 +71,11 @@ function import_err($p_pearErrorObj, $txt='')
|
|||
{
|
||||
global $g_errors;
|
||||
if (PEAR::isError($p_pearErrorObj)) {
|
||||
$msg = $p_pearErrorObj->getMessage()." ".$p_pearErrorObj->getUserInfo();
|
||||
$msg = $p_pearErrorObj->getMessage()." ".$p_pearErrorObj->getUserInfo();
|
||||
}
|
||||
echo "\nERROR: $msg\n";
|
||||
if (!empty($txt)) {
|
||||
echo "ERROR: $txt\n";
|
||||
echo "ERROR: $txt\n";
|
||||
}
|
||||
$g_errors++;
|
||||
}
|
||||
|
@ -174,20 +174,20 @@ function camp_import_audio_file($p_filepath, $p_importMode = null, $p_testOnly =
|
|||
global $g_errors;
|
||||
$g_errors++;
|
||||
echo "ERROR: $p_filepath\n"
|
||||
." When importing with the '--link' option, files must be set\n"
|
||||
." world-readable. The file permissions for the file cannot be\n"
|
||||
." changed. Check that you are not trying to import from a FAT32\n"
|
||||
." drive. Otherwise, this problem might be fixed by running this \n"
|
||||
." script with 'sudo'.\n";
|
||||
." When importing with the '--link' option, files must be set\n"
|
||||
." world-readable. The file permissions for the file cannot be\n"
|
||||
." changed. Check that you are not trying to import from a FAT32\n"
|
||||
." drive. Otherwise, this problem might be fixed by running this \n"
|
||||
." script with 'sudo'.\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// $timeBegin = microtime(true);
|
||||
// $timeBegin = microtime(true);
|
||||
$md5sum = md5_file($p_filepath);
|
||||
// $timeEnd = microtime(true);
|
||||
// echo " * MD5 time: ".($timeEnd-$timeBegin)."\n";
|
||||
// $timeEnd = microtime(true);
|
||||
// echo " * MD5 time: ".($timeEnd-$timeBegin)."\n";
|
||||
|
||||
// Look up md5sum in database
|
||||
$duplicate = StoredFile::RecallByMd5($md5sum);
|
||||
|
@ -211,9 +211,9 @@ function camp_import_audio_file($p_filepath, $p_importMode = null, $p_testOnly =
|
|||
);
|
||||
$storedFile = StoredFile::Insert($values, $doCopyFiles);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
import_err($storedFile, "Error in StoredFile::Insert()");
|
||||
echo var_export($metadata)."\n";
|
||||
return;
|
||||
import_err($storedFile, "Error in StoredFile::Insert()");
|
||||
echo var_export($metadata)."\n";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
echo "==========================================================================\n";
|
||||
|
@ -250,8 +250,8 @@ if ($DEBUG_IMPORT) {
|
|||
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "camp_import_error_handler");
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
|
@ -308,8 +308,8 @@ if (is_null($importMode)) {
|
|||
global $CC_CONFIG;
|
||||
|
||||
if (!is_writable($CC_CONFIG["storageDir"])) {
|
||||
echo "ERROR: You do not have write permissions to the directory you are trying to import to:\n " . $CC_CONFIG["storageDir"] . "\n\n";
|
||||
exit;
|
||||
echo "ERROR: You do not have write permissions to the directory you are trying to import to:\n " . $CC_CONFIG["storageDir"] . "\n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
global $g_fileCount;
|
||||
|
@ -335,9 +335,9 @@ if (is_array($files)) {
|
|||
$end = intval(date('U'));
|
||||
$time = $end - $start;
|
||||
if ($time > 0) {
|
||||
$speed = round(($g_fileCount+$g_duplicates)/$time, 1);
|
||||
$speed = round(($g_fileCount+$g_duplicates)/$time, 1);
|
||||
} else {
|
||||
$speed = ($g_fileCount+$g_duplicates);
|
||||
$speed = ($g_fileCount+$g_duplicates);
|
||||
}
|
||||
|
||||
echo "==========================================================================\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue