Removing lots of old code that is no longer used.

This commit is contained in:
paul.baranowski 2011-03-05 11:06:22 -05:00
parent cb119802df
commit 90b46d8eb3
30 changed files with 9 additions and 12517 deletions

View file

@ -1,112 +0,0 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Airtime project.
# http://airtime.sourcefabric.org/
#
# Airtime is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Airtime is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Airtime; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script creates a tgz archive of the Airtime storage.
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`
phpdir=$reldir
mkdir -p $reldir/tmp
tmpmaindir=`cd $reldir/tmp; pwd`
dbxml="db.xml"
datestr=`date '+%Y%m%d%H%M%S'`
xmltar="xmls.tar"
destfile="storage$datestr.tar"
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "This script creates a tgz archive of the Airtime storage.";
echo "parameters:";
echo "";
echo " -d, --destination Destination directory [default:$tmpmaindir].";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o hd: -l help,destinantion: -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-h|--help)
printUsage;
exit 0;;
-d|--destinantion)
destdir=$2
shift; shift;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
if [ "x$destdir" == "x" ]; then
destdir=$tmpmaindir
fi
destdir=`cd $destdir; pwd`
#-------------------------------------------------------------------------------
# Do backup
#-------------------------------------------------------------------------------
tmpdir=`mktemp -d $tmpmaindir/tmp.XXXXXX`
echo "Backuping to $destdir/$destfile :"
echo "Dumping database ..."
cd $phpdir
php -q airtime_backup.php > $tmpdir/$dbxml
echo "Packaging stored files ..."
cd $phpdir
storpath=`php -q getStorPath.php`
cd $storpath/..
find stor -name "*.xml" -print | tar cf $tmpdir/$xmltar -T -
find stor ! -name "*.xml" -a -type f -print | tar cf $tmpdir/$destfile -T -
cd $tmpdir
tar rf $xmltar $dbxml --remove-files
echo "Compressing XML part ..."
bzip2 $xmltar
tar rf $destfile $xmltar.bz2 --remove-files
mv $destfile "$destdir"
rmdir $tmpdir
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "done"

View file

@ -1,194 +0,0 @@
<?php
define('NSPACE', 'lse');
header("Content-type: text/plain");
require_once('DB.php');
require_once("XML/Util.php");
require_once("XML/Beautifier.php");
require_once(dirname(__FILE__)."/../application/configs/conf.php");
require_once(dirname(__FILE__)."/../application/models/BasicStor.php");
require_once(dirname(__FILE__)."/../application/models/Prefs.php");
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$bs = new BasicStor();
$stid = $bs->storId;
#var_dump($stid); exit;
#$farr = $bs->bsListFolder($stid); var_dump($farr); exit;
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;
// }
$media = StoredFile::Recall($fid);
$type = $media->getType();
$gunid = $media->getGunid();
$pars = array();
if ($gunid) {
$pars['id']="$gunid";
}
$pars['name'] = "$name";
switch ($type) {
case "audioclip":
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'audioClip',
'attributes'=> $pars,
));
break;
case "webstream":
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'webstream',
'attributes'=> $pars,
));
break;
case "playlist":
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'playlist',
'attributes'=> $pars,
));
break;
default:
return "";
}
}
function admDumpGroup(&$bs, $gid, $ind='')
{
$name = Subjects::GetSubjName($gid);
if (PEAR::isError($name)) {
echo $name->getMessage();
exit;
}
$isGr = Subjects::IsGroup($gid);
if (PEAR::isError($isGr)) {
echo $isGr->getMessage();
exit;
}
$pars = array('name'=>"$name");
$pars['id'] = $gid;
if (!$isGr) {
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'member',
'attributes'=> $pars,
));
}
$garr = Subjects::ListGroup($gid);
if (PEAR::isError($garr)) {
echo $garr->getMessage();
exit;
}
$res = '';
foreach ($garr as $i => $member) {
$fid2 = $member['id'];
$res .= admDumpGroup($bs, $fid2, "$ind ");
}
$tagarr = array(
'namespace' => NSPACE,
'localPart' => 'group',
'attributes'=> $pars,
);
$prefs = admDumpPrefs($bs, $gid);
if (!is_null($prefs)) {
$res .= $prefs;
}
if ($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);
// }
}
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;
}
}
# return "$ind<subjects>\n$res$ind</subjects>\n";
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'subjects',
'content'=> $res,
), 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(
'namespace' => NSPACE,
'localPart' => 'pref',
'attributes'=> $pars,
));
}
if (!$res) {
return NULL;
}
return XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'preferences',
'content'=> $res,
), FALSE);
}
$subjects = admDumpSubjects($bs, ' ');
$tree = admDumpFolder($bs, $stid, ' ');
$res = XML_Util::getXMLDeclaration("1.0", "UTF-8")."\n";
$node = XML_Util::createTagFromArray(array(
'namespace' => NSPACE,
'localPart' => 'storageServer',
'content' => "$subjects$tree",
), FALSE);
$res .= $node;
$fmt = new XML_Beautifier();
$res = $fmt->formatString($res);
#var_export($res);
#var_dump($res);
echo "$res";

View file

@ -1,110 +0,0 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Airtime project.
# http://airtime.sourcefabric.org/
#
# Airtime is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Airtime is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Airtime; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script restores the data which was backed up with airtime-backup.
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`
phpdir=$reldir
mkdir -p $reldir/tmp
tmpmaindir=`cd $reldir/tmp; pwd`
dbxml="db.xml"
tarfile0="xmls.tar"
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "This script restores the data which was backed up with airtime-backup."
echo "parameters:";
echo "";
echo " -f, --file File with the backed up data, required.";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o hf: -l help,file -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-h|--help)
printUsage;
exit 0;;
-f|--file)
tarfile=$2
shift; shift;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
if [ "x$tarfile" == "x" ]; then
echo "Required parameter file not specified.";
printUsage;
exit 1;
fi
tfdir=`dirname $tarfile`
tfdir=`cd $tfdir; pwd`
tfbname=`basename $tarfile`
tarfile="$tfdir/$tfbname"
#-------------------------------------------------------------------------------
# Do restore
#-------------------------------------------------------------------------------
tmpdir=`mktemp -d $tmpmaindir/tmp.XXXXXX`
echo "Restoring database from $tarfile ..."
cd $tmpdir
tar xf $tarfile
tar xjf $tarfile0.bz2
rm -f $tarfile0.bz2
cd $phpdir
php -q restore.php $tmpdir/$dbxml $tmpdir
rm -rf "$tmpdir/stor"
rm -f $tmpdir/*
rmdir "$tmpdir"
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "done"

View file

@ -1,257 +0,0 @@
<?php
echo "This file is currently not working. Try again in the next version. :) \n";
exit;
define('NSPACE', 'lse');
define('VERBOSE', FALSE);
#define('VERBOSE', TRUE);
header("Content-type: text/plain");
require_once 'DB.php';
require_once "XML/Util.php";
require_once "XML/Beautifier.php";
require_once dirname(__FILE__)."/../application/configs/conf.php";
require_once dirname(__FILE__)."/../application/models/BasicStor.php";
require_once dirname(__FILE__)."/../application/models/Prefs.php";
/* =========================================================== misc functions */
function ls_restore_processObject($el)
{
$res = array(
'name' => $el->attrs['name']->val,
'type' => $el->name,
);
switch ($res['type']) {
case 'folder':
foreach ($el->children as $i => $o) {
$res['children'][] = ls_restore_processObject($o);
}
break;
default:
$res['gunid'] = $el->attrs['id']->val;
break;
}
return $res;
}
function ls_restore_checkErr($r, $ln='')
{
if (PEAR::isError($r)) {
echo "ERROR $ln: ".$r->getMessage()." ".$r->getUserInfo()."\n";
exit;
}
}
function ls_restore_restoreObject($obj, /*$parid,*/ $reallyInsert=TRUE){
global $tmpdir, $bs;
switch ($obj['type']) {
case "audioClip";
case "webstream";
case "playlist";
$gunid = $obj['gunid'];
if (is_null($gunid)) {
break;
}
$gunid3 = substr($gunid, 0, 3);
$mediaFile = "$tmpdir/stor/$gunid3/$gunid";
# echo "X1 $gunid, $gunid3, $mediaFile\n";
if (!file_exists($mediaFile)) {
$mediaFile = NULL;
}
$mdataFile = "$tmpdir/stor/$gunid3/$gunid.xml";
if (!file_exists($mdataFile)) {
$mdataFile = NULL;
}
if ($reallyInsert) {
if (VERBOSE) {
echo " creating file {$obj['name']} ...\n";
}
$values = array(
"filename" => $obj['name'],
"filepath" => $mediaFile,
"metadata" => $mdataFile,
"gunid" => $obj['gunid'],
"filetype" => strtolower($obj['type'])
);
$r = StoredFile::Insert($values);
ls_restore_checkErr($r, __LINE__);
}
break;
}
}
/* =============================================================== processing */
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$bs = new BasicStor();
$pr = new Prefs($bs);
$dbxml = file_get_contents($argv[1]);
$tmpdir = $argv[2];
require_once("$STORAGE_SERVER_PATH/var/XmlParser.php");
$parser = new XmlParser($dbxml);
if ($parser->isError()) {
return PEAR::raiseError(
"MetaData::parse: ".$parser->getError()
);
}
$xmlTree = $parser->getTree();
/* ----------------------------------------- processing storageServer element */
$subjArr = FALSE;
//$tree = FALSE;
foreach ($xmlTree->children as $i => $el) {
switch ($el->name) {
case "subjects":
if ($subjArr !== FALSE) {
echo "ERROR: unexpected subjects element\n";
}
$subjArr = $el->children;
break;
// case "folder":
// if ($tree !== FALSE) {
// echo "ERROR: unexpected folder element\n";
// }
// $tree = ls_restore_processObject($el);
// break;
default:
echo "ERROR: unknown element name {$el->name}\n";
exit;
}
// echo "{$el->name}\n";
}
/* ---------------------------------------------- processing subjects element */
$subjects = array();
$groups = array();
foreach ($subjArr as $i => $el) {
switch ($el->name) {
case "group":
$grname = $el->attrs['name']->val;
$groups[$grname] = $el->children;
$subjects[$grname] = array(
'type' => 'group',
);
break;
case "user":
$login = $el->attrs['login']->val;
$subjects[$login] = array(
'type' => 'user',
'pass' => $el->attrs['pass']->val,
# 'realname' => $el->attrs['realname']->val,
'realname' => '',
'prefs' => (isset($el->children[0]) ? $el->children[0]->children : NULL),
);
break;
}
}
/* -------------------------------------------------------- processing groups */
foreach ($groups as $grname => $group) {
foreach ($group as $i => $el) {
switch ($el->name) {
case "member":
$groups[$grname][$i] = $el->attrs['name']->val;
break;
case "preferences":
$subjects[$grname]['prefs'] = $el->children;
unset($groups[$grname][$i]);
break;
}
}
}
#var_dump($xmlTree);
#var_dump($subjArr);
#var_dump($groups);
#var_dump($subjects);
#var_dump($tree);
#exit;
/* ================================================================ restoring */
if (VERBOSE) {
echo " resetting storage ...\n";
}
$bs->resetStorage(FALSE);
$storId = $bs->storId;
/* ------------------------------------------------------- restoring subjects */
foreach ($subjects as $login => $subj) {
$uid0 = Subjects::GetSubjId($login);
ls_restore_checkErr($uid0);
switch ($subj['type']) {
case "user":
if ($login=='root') {
$r = $bs->passwd($login, NULL, $subj['pass'], TRUE);
ls_restore_checkErr($r, __LINE__);
$uid = $uid0;
} else {
if (!is_null($uid0)) {
$r = $bs->removeSubj($login);
ls_restore_checkErr($r, __LINE__);
}
if (VERBOSE) {
echo " adding user $login ...\n";
}
$uid = BasicStor::addSubj($login, $subj['pass'], $subj['realname'], TRUE);
ls_restore_checkErr($uid, __LINE__);
}
break;
case "group":
if (!is_null($uid0)) {
$r = $bs->removeSubj($login);
if (PEAR::isError($r)) {
$uid = $uid0;
break;
}
//ls_restore_checkErr($r, __LINE__);
}
if (VERBOSE) {
echo " adding group $login ...\n";
}
$uid = BasicStor::addSubj($login, NULL);
ls_restore_checkErr($uid, __LINE__);
// var_export($uid); echo " ";
break;
} // switch
// echo "$login/$uid :\n";
if (isset($subj['prefs'])) {
// var_dump($subj['prefs']); exit;
foreach ($subj['prefs'] as $i => $el) {
switch ($el->name) {
case "pref":
$prefkey = $el->attrs['name']->val;
$prefval = $el->attrs['val']->val;
// echo" PREF($prefkey)=$prefval\n";
$res = $pr->insert($uid, $prefkey, $prefval);
ls_restore_checkErr($res, __LINE__);
break;
default:
var_dump($el);
}
}
}
}
/* --------------------------------------------------------- restoring groups */
#var_dump($groups);
foreach ($groups as $grname => $group) {
foreach ($group as $i => $login) {
if (VERBOSE) {
echo " adding subject $login to group $grname ...\n";
}
$r = Subjects::AddSubjectToGroup($login, $grname);
ls_restore_checkErr($r, __LINE__);
}
}
/* -------------------------------------------------------- restoring objects */
ls_restore_restoreObject($tree, /*$storId,*/ FALSE);

View file

@ -1,36 +0,0 @@
<?php
/**
* Do database restore in background. - command line php application
*
* required command line parameters:
* @param 1. backup file
* @param 2. status file
* @param 3. token
* @param 4. sessid
*
*/
require_once(dirname(__FILE__).'/../application/configs/conf.php');
require_once(dirname(__FILE__).'/../application/models/GreenBox.php');
require_once(dirname(__FILE__).'/../application/models/Restore.php');
include_once('DB.php');
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
if (DB::isError($CC_DBC)) {
die($CC_DBC->getMessage());
}
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = new GreenBox();
$rs = new Restore($gb);
if ($rs->loglevel=='debug') {
$rs->addLogItem('argv:'.print_r($argv,true));
}
$backupfile = $argv[1];
$token = $argv[3];
$sessid = $argv[4];
$rs->startRestore($backupfile,$token,$sessid);