Merge branch 'master' of dev.sourcefabric.org:campcaster

This commit is contained in:
naomiaro 2010-09-13 17:19:44 -04:00
commit eff63827d7
39 changed files with 875 additions and 1162 deletions

View File

@ -316,22 +316,6 @@ echo "Setting up storageServer..."
make -C $modules_dir/storageServer storage || exit 1 make -C $modules_dir/storageServer storage || exit 1
#-------------------------------------------------------------------------------
# Setup the database tables for the scheduler
#-------------------------------------------------------------------------------
echo "Setting up database tables for the scheduler..."
make -C $products_dir/scheduler init || exit 1
#-------------------------------------------------------------------------------
# Add "scheduler" user
#-------------------------------------------------------------------------------
echo "Adding the 'scheduler' user..."
php $modules_dir/storageServer/var/install/campcaster-user.php --addupdate scheduler $scheduler_storage_pass
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Setup directory permissions # Setup directory permissions
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------

View File

@ -311,17 +311,18 @@ class uiBase
*/ */
public function loadStationPrefs(&$mask, $reload=FALSE) public function loadStationPrefs(&$mask, $reload=FALSE)
{ {
global $CC_CONFIG;
if (!is_array($this->STATIONPREFS) || ($reload === TRUE) ) { if (!is_array($this->STATIONPREFS) || ($reload === TRUE) ) {
$this->STATIONPREFS = array(); $this->STATIONPREFS = array();
foreach ($mask as $key => $val) { foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
$setting = $this->gb->loadGroupPref(NULL, 'StationPrefs', $val['element']); $setting = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $val['element']);
if (is_string($setting)) { if (is_string($setting)) {
$this->STATIONPREFS[$val['element']] = $setting; $this->STATIONPREFS[$val['element']] = $setting;
} elseif ($val['required']) { } elseif ($val['required']) {
// set default values on first login // set default values on first login
$default = isset($val['default'])?$val['default']:null; $default = isset($val['default'])?$val['default']:null;
$this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $default); $this->gb->saveGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $default);
$this->STATIONPREFS[$val['element']] = $default; $this->STATIONPREFS[$val['element']] = $default;
} }
} }
@ -529,24 +530,24 @@ class uiBase
public function getMetaInfo($id) public function getMetaInfo($id)
{ {
$type = strtolower(GreenBox::getFileType($id)); $type = strtolower(GreenBox::getFileType($id));
if($type == 'playlist') { if($type == 'playlist') {
require_once("../../../storageServer/var/Playlist.php"); require_once("../../../storageServer/var/Playlist.php");
$playList = new Playlist(GreenBox::GunidFromId($id)); $playList = new Playlist(GreenBox::GunidFromId($id));
$playListData = $playList->export(); $playListData = $playList->export();
for ($i = 1; $i < count($playListData); $i++) { for ($i = 1; $i < count($playListData); $i++) {
$entry = StoredFile::RecallByGunid($playListData["".$i]["gunid"]); $entry = StoredFile::RecallByGunid($playListData["".$i]["gunid"]);
$playListEntries[] = $entry->getName(); $playListEntries[] = $entry->getName();
} }
$_SESSION['mdata'] = $playListEntries; $_SESSION['mdata'] = $playListEntries;
} }
$data = array('id' => $id, $data = array('id' => $id,
'gunid' => BasicStor::GunidFromId($id), 'gunid' => BasicStor::GunidFromId($id),
'title' => $this->getMetadataValue($id, UI_MDATA_KEY_TITLE), 'title' => $this->getMetadataValue($id, UI_MDATA_KEY_TITLE),

View File

@ -296,10 +296,11 @@ class uiBrowser extends uiBase {
function changeStationPrefs(&$mask) function changeStationPrefs(&$mask)
{ {
global $CC_CONFIG;
$form = new HTML_QuickForm('changeStationPrefs', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('changeStationPrefs', UI_STANDARD_FORM_METHOD, UI_HANDLER);
foreach($mask as $key => $val) { foreach($mask as $key => $val) {
$element = isset($val['element']) ? $val['element'] : null; $element = isset($val['element']) ? $val['element'] : null;
$p = $this->gb->loadGroupPref($this->sessid, 'StationPrefs', $element); $p = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $element);
if (is_string($p)) { if (is_string($p)) {
$mask[$key]['default'] = $p; $mask[$key]['default'] = $p;
} }

View File

@ -696,6 +696,7 @@ class uiHandler extends uiBase {
*/ */
function changeStationPrefs($formdata, $mask) function changeStationPrefs($formdata, $mask)
{ {
global $CC_CONFIG;
$this->redirUrl = UI_BROWSER; $this->redirUrl = UI_BROWSER;
if ($this->_validateForm($formdata, $mask) == FALSE) { if ($this->_validateForm($formdata, $mask) == FALSE) {
@ -705,18 +706,18 @@ class uiHandler extends uiBase {
foreach ($mask as $key => $val) { foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
if (!empty($formdata[$val['element']])) { if (!empty($formdata[$val['element']])) {
$result = $this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]); $result = $this->gb->saveGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $formdata[$val['element']]);
if (PEAR::isError($result)) if (PEAR::isError($result))
$this->_retMsg('Error while saving settings.'); $this->_retMsg('Error while saving settings.');
} else { } else {
$this->gb->delGroupPref($this->sessid, 'StationPrefs', $val['element']); $this->gb->delGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element']);
} }
} }
if (isset($val['type']) if (isset($val['type'])
&& ($val['type'] == 'file') && ($val['type'] == 'file')
&& ($val['element'] == "stationlogo") && ($val['element'] == "stationlogo")
&& !empty($formdata[$val['element']]['name'])) { && !empty($formdata[$val['element']]['name'])) {
$stationLogoPath = $this->gb->loadGroupPref($this->sessid, 'StationPrefs', 'stationLogoPath'); $stationLogoPath = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], 'stationLogoPath');
$filePath = $formdata[$val['element']]['tmp_name']; $filePath = $formdata[$val['element']]['tmp_name'];
if (function_exists("getimagesize")) { if (function_exists("getimagesize")) {
$size = @getimagesize($filePath); $size = @getimagesize($filePath);

View File

@ -1,12 +1,12 @@
<?php <?php
class uiTwitter { class uiTwitter {
private $Base; private $Base;
private $settings = array( private $settings = array(
'bitly-login' => 'campcaster', 'bitly-login' => 'campcaster',
'bitly-apikey' => 'R_2f812152bfc21035468350273ec8ff43' 'bitly-apikey' => 'R_2f812152bfc21035468350273ec8ff43'
); );
/** /**
* Time in sec * Time in sec
* *
@ -19,7 +19,7 @@ class uiTwitter {
$this->Base =& $uiBase; $this->Base =& $uiBase;
$this->loadSettings(); $this->loadSettings();
} }
private static function getSettingFormMask() private static function getSettingFormMask()
{ {
$formmask = array( $formmask = array(
@ -182,7 +182,7 @@ class uiTwitter {
'label' => 'Provider', 'label' => 'Provider',
'options' => array( 'options' => array(
'bit.ly' => 'bit.ly', 'bit.ly' => 'bit.ly',
'tinyurl.com' => 'tinyurl.com', 'tinyurl.com' => 'tinyurl.com',
), ),
'isPref' => true 'isPref' => true
), ),
@ -209,29 +209,30 @@ class uiTwitter {
'label' => 'Submit', 'label' => 'Submit',
) )
); );
return $formmask; return $formmask;
} }
private function loadSettings() private function loadSettings()
{ {
global $CC_CONFIG;
$mask = uiTwitter::getSettingFormMask(); $mask = uiTwitter::getSettingFormMask();
foreach($mask as $key => $val) { foreach($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
$element = preg_replace('/^twitter-/', '', $val['element'], 1); $element = preg_replace('/^twitter-/', '', $val['element'], 1);
$p = $this->Base->gb->loadGroupPref($this->Base->sessid, 'StationPrefs', $val['element']); $p = $this->Base->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $val['element']);
if (is_string($p)) { if (is_string($p)) {
$this->settings[$element] = $p; $this->settings[$element] = $p;
} }
} }
} }
} }
public function getSettingsForm() public function getSettingsForm()
{ {
$mask = uiTwitter::getSettingFormMask(); $mask = uiTwitter::getSettingFormMask();
$form = new HTML_QuickForm('twitter', UI_STANDARD_FORM_METHOD, UI_HANDLER);# $form = new HTML_QuickForm('twitter', UI_STANDARD_FORM_METHOD, UI_HANDLER);#
foreach($mask as $key => $val) { foreach($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref'] && !$val['hiddenPref']) { if (isset($val['isPref']) && $val['isPref'] && !$val['hiddenPref']) {
$element = preg_replace('/^twitter-/', '', $val['element']); $element = preg_replace('/^twitter-/', '', $val['element']);
@ -246,48 +247,49 @@ class uiTwitter {
$form->accept($renderer); $form->accept($renderer);
return $renderer->toArray(); return $renderer->toArray();
} }
public function saveSettings() public function saveSettings()
{ {
global $CC_CONFIG;
if ($this->Base->_validateForm($_REQUEST, uiTwitter::getSettingFormMask()) !== TRUE) { if ($this->Base->_validateForm($_REQUEST, uiTwitter::getSettingFormMask()) !== TRUE) {
$this->Base->_retMsg('An error has occured on validating the form.'); $this->Base->_retMsg('An error has occured on validating the form.');
return FALSE; return FALSE;
} }
$mask = uiTwitter::getSettingFormMask(); $mask = uiTwitter::getSettingFormMask();
$form = new HTML_QuickForm('twitter', UI_STANDARD_FORM_METHOD, UI_HANDLER); $form = new HTML_QuickForm('twitter', UI_STANDARD_FORM_METHOD, UI_HANDLER);
uiBase::parseArrayToForm($form, $mask); uiBase::parseArrayToForm($form, $mask);
$formdata = $form->exportValues(); $formdata = $form->exportValues();
foreach ($mask as $key => $val) { foreach ($mask as $key => $val) {
if (isset($val['isPref']) && $val['isPref']) { if (isset($val['isPref']) && $val['isPref']) {
if (!empty($formdata[$val['element']])) { if (!empty($formdata[$val['element']])) {
$result = $this->Base->gb->saveGroupPref($this->Base->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]); $result = $this->Base->gb->saveGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $formdata[$val['element']]);
if (PEAR::isError($result)) if (PEAR::isError($result))
$this->Base->_retMsg('Error while saving twitter settings.'); $this->Base->_retMsg('Error while saving twitter settings.');
} elseif (!$val['hiddenPref']) { } elseif (!$val['hiddenPref']) {
$this->Base->gb->delGroupPref($this->Base->sessid, 'StationPrefs', $val['element']); $this->Base->gb->delGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], $val['element']);
} }
} }
} }
$this->Base->_retMsg('Twitter settings saved.'); $this->Base->_retMsg('Twitter settings saved.');
} }
public function getFeed($p_useSampledata = false) public function getFeed($p_useSampledata = false)
{ {
if ($p_useSampledata) { if ($p_useSampledata) {
$whatsplaying = array( $whatsplaying = array(
"tracktitle" => "Gimme Shelter", "tracktitle" => "Gimme Shelter",
"trackartist" => "The Rolling Stones", "trackartist" => "The Rolling Stones",
"playlisttitle" => "The Blues Hour" "playlisttitle" => "The Blues Hour"
); );
} else { } else {
$whatsplaying = $this->getWhatsplaying($this->settings['offset']); $whatsplaying = $this->getWhatsplaying($this->settings['offset']);
} }
if (!$whatsplaying) { if (!$whatsplaying) {
return; return;
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -313,35 +315,35 @@ class uiTwitter {
if ($this->settings['has_trackartist']) { $tweetbody[] = $whatsplaying['trackartist']; } if ($this->settings['has_trackartist']) { $tweetbody[] = $whatsplaying['trackartist']; }
if ($this->settings['has_playlisttitle']) { $tweetbody[] = $whatsplaying['playlisttitle']; } if ($this->settings['has_playlisttitle']) { $tweetbody[] = $whatsplaying['playlisttitle']; }
if ($this->settings['has_stationname']) { $tweetbody[] = $this->Base->STATIONPREFS['stationName']; } if ($this->settings['has_stationname']) { $tweetbody[] = $this->Base->STATIONPREFS['stationName']; }
$tweetbody = implode (". ",$tweetbody); $tweetbody = implode (". ",$tweetbody);
// chop body to fit if necessary // chop body to fit if necessary
if ((strlen($tweetprefix) + strlen($tweetbody) + strlen($tweetsuffix)) > 140) { if ((strlen($tweetprefix) + strlen($tweetbody) + strlen($tweetsuffix)) > 140) {
$tweetbody = substr($tweetbody, 0, (140 - (strlen($tweetprefix) + strlen($tweetsuffix) + 3))) . "..."; $tweetbody = substr($tweetbody, 0, (140 - (strlen($tweetprefix) + strlen($tweetsuffix) + 3))) . "...";
} }
$tweet = $tweetprefix . $tweetbody . $tweetsuffix; $tweet = $tweetprefix . $tweetbody . $tweetsuffix;
return $tweet; return $tweet;
} }
public function shortUrl($p_url) public function shortUrl($p_url)
{ {
switch ($this->settings['shortener-provider']) { switch ($this->settings['shortener-provider']) {
case 'tinyurl.com': case 'tinyurl.com':
$short = file_get_contents('http://tinyurl.com/api-create.php?url='.$p_url); $short = file_get_contents('http://tinyurl.com/api-create.php?url='.$p_url);
break; break;
case 'bit.ly': case 'bit.ly':
$short = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl={$p_url}&format=text&login={$this->settings['bitly-login']}&apiKey={$this->settings['bitly-apikey']}"); $short = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl={$p_url}&format=text&login={$this->settings['bitly-login']}&apiKey={$this->settings['bitly-apikey']}");
break; break;
} }
return $short; return $short;
} }
public function getWhatsplaying($p_offset) public function getWhatsplaying($p_offset)
{ {
$timestamp = time() + $p_offset; $timestamp = time() + $p_offset;
@ -362,47 +364,48 @@ class uiTwitter {
if (!$clip['gunid']) { if (!$clip['gunid']) {
return FALSE; return FALSE;
} }
return array( return array(
'tracktitle' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_TITLE, $this->Base->sessid), 'tracktitle' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_TITLE, $this->Base->sessid),
'trackartist' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_CREATOR, $this->Base->sessid), 'trackartist' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_CREATOR, $this->Base->sessid),
'playlisttitle' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($pl['playlistId']), UI_MDATA_KEY_TITLE, $this->Base->sessid), 'playlisttitle' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($pl['playlistId']), UI_MDATA_KEY_TITLE, $this->Base->sessid),
); );
} }
public function sendFeed($p_feed) public function sendFeed($p_feed)
{ {
global $CC_CONFIG;
$twitter = new twitter(); $twitter = new twitter();
$twitter->username = $this->settings['login']; $twitter->username = $this->settings['login'];
$twitter->password = $this->settings['password']; $twitter->password = $this->settings['password'];
if ($res = $twitter->update($p_feed)) { if ($res = $twitter->update($p_feed)) {
$this->Base->gb->saveGroupPref($this->Base->sessid, 'StationPrefs', 'twitter-lastupdate', time()); $this->Base->gb->saveGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], 'twitter-lastupdate', time());
return $res; return $res;
} }
return false; return false;
} }
public function needsUpdate() public function needsUpdate()
{ {
if (time() - $this->Base->gb->loadGroupPref($this->Base->sessid, 'StationPrefs', 'twitter-lastupdate') + $this->runtime > $this->settings['interval']) { if (time() - $this->Base->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], 'twitter-lastupdate') + $this->runtime > $this->settings['interval']) {
return true; return true;
} }
return false; return false;
} }
public function twitterify($p_string) public function twitterify($p_string)
{ {
$string = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $p_string); $string = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $p_string);
$string = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $string); $string = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $string);
$string = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $string); $string = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $string);
$string = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $string); $string = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $string);
return $string; return $string;
} }
public function isActive() public function isActive()
{ {
return $this->settings['is_active']; return $this->settings['is_active'];
} }
} }

View File

@ -27,7 +27,7 @@
WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $? WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $?
echo " *** StorageServer bin/setupDirs.sh BEGIN" echo " *** StorageServer bin/setupDirs.sh BEGIN"
echo " *** Root URL: $WWW_ROOT" echo " * Root URL: $WWW_ROOT"
PHP_PWD_COMMAND=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \ PHP_PWD_COMMAND=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \
{ {
errno=$? errno=$?
@ -37,6 +37,7 @@ PHP_PWD_COMMAND=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \
fi fi
exit $errno exit $errno
} }
PHP_PWD=$PHP_PWD_COMMAND PHP_PWD=$PHP_PWD_COMMAND
# MOD_PHP may not be working, this command will tell us # MOD_PHP may not be working, this command will tell us
if [ ${PHP_PWD_COMMAND:0:5} == '<?php' ]; then if [ ${PHP_PWD_COMMAND:0:5} == '<?php' ]; then
@ -44,14 +45,19 @@ if [ ${PHP_PWD_COMMAND:0:5} == '<?php' ]; then
exit 1 exit 1
fi fi
echo " *** Webspace mapping test:" if [ $PHP_PWD == "" ]; then
echo " *** mod_php : $PHP_PWD" echo " * ERROR: Could not get PHP working directory."
exit 1
fi
echo " ** Webspace mapping test:"
echo " * mod_php : $PHP_PWD"
INSTALL_DIR="$PWD/var/install" INSTALL_DIR="$PWD/var/install"
echo " *** install : $INSTALL_DIR" echo " * install : $INSTALL_DIR"
if [ $PHP_PWD == $INSTALL_DIR ]; then if [ $PHP_PWD == $INSTALL_DIR ]; then
echo " *** Mapping OK" echo " * Mapping OK"
else else
echo " *** WARNING: there was a problem with webspace mapping!!!" echo " * WARNING: there was a problem with webspace mapping!!!"
fi fi
HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \ HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \
@ -61,11 +67,11 @@ HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \
echo " -> Probably wrong setting in var/conf.php: URL configuration"; echo " -> Probably wrong setting in var/conf.php: URL configuration";
exit $ERN; exit $ERN;
} }
echo " *** The system group that is running the http daemon: '$HTTP_GROUP'" echo " ** The system group that is running the http daemon: '$HTTP_GROUP'"
for i in $* for i in $*
do do
echo " *** chown :$HTTP_GROUP $i" echo " * chown :$HTTP_GROUP $i"
if [ -G $i ]; then if [ -G $i ]; then
chown :$HTTP_GROUP $i || \ chown :$HTTP_GROUP $i || \
{ {
@ -73,7 +79,7 @@ do
echo "ERROR: chown :$HTTP_GROUP $i -> You should have permissions to set group owner to group '$HTTP_GROUP'"; echo "ERROR: chown :$HTTP_GROUP $i -> You should have permissions to set group owner to group '$HTTP_GROUP'";
exit $ERN; exit $ERN;
} }
echo " *** chmod g+sw $i" echo " * chmod g+sw $i"
chmod g+sw $i || exit $? chmod g+sw $i || exit $?
fi fi
done done

View File

@ -1413,20 +1413,18 @@ class BasicStor {
return $uid; return $uid;
} }
if (Subjects::IsGroup($uid) === FALSE) { if (Subjects::IsGroup($uid) === FALSE) {
$res = Alib::AddPerm($uid, '_all', $fid, 'A'); $res = Alib::AddPerm($uid, '_all', '0', 'A');
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
if (!$CC_CONFIG['isArchive']) { $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']);
$res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']); if (PEAR::isError($res)) {
if (PEAR::isError($res)) { return $res;
return $res;
}
$res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']);
if (PEAR::isError($res)) {
return $res;
}
} }
// $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']);
// if (PEAR::isError($res)) {
// return $res;
// }
} }
return $uid; return $uid;
} }
@ -1811,10 +1809,8 @@ class BasicStor {
} else { } else {
$this->deleteData(); $this->deleteData();
} }
if (!$CC_CONFIG['isArchive']) { $tr = new Transport($this);
$tr = new Transport($this); $tr->resetData();
$tr->resetData();
}
$res = array('cnt'=>0, 'results'=>array()); $res = array('cnt'=>0, 'results'=>array());
if (!$loadSampleData) { if (!$loadSampleData) {
return $res; return $res;
@ -1939,42 +1935,42 @@ class BasicStor {
{ {
global $CC_CONFIG; global $CC_CONFIG;
// Create the Admin group // Create the Admin group
if (!empty($CC_CONFIG['AdminsGr'])) { // if (!empty($CC_CONFIG['AdminsGr'])) {
if (!Subjects::GetSubjId($CC_CONFIG['AdminsGr'])) { // if (!Subjects::GetSubjId($CC_CONFIG['AdminsGr'])) {
echo " * Creating group '".$CC_CONFIG['AdminsGr']."'..."; // echo " * Creating group '".$CC_CONFIG['AdminsGr']."'...";
// Add the admin group // // Add the admin group
$admid = Subjects::AddSubj($CC_CONFIG['AdminsGr']); // $admid = Subjects::AddSubj($CC_CONFIG['AdminsGr']);
if (PEAR::isError($admid)) { // if (PEAR::isError($admid)) {
return $admid; // return $admid;
} // }
//
// Add the "all" permission to the "admin" group // // Add the "all" permission to the "admin" group
$res = Alib::AddPerm($admid, '_all', $this->rootId, 'A'); // $res = Alib::AddPerm($admid, '_all', $this->storId, 'A');
if (PEAR::isError($res)) { // if (PEAR::isError($res)) {
return $res; // return $res;
} // }
echo "done.\n"; // echo "done.\n";
} else { // } else {
echo " * Skipping: group already exists: '".$CC_CONFIG['AdminsGr']."'\n"; // echo " * Skipping: group already exists: '".$CC_CONFIG['AdminsGr']."'\n";
} // }
} // }
// Add the "all" group // Add the "all" group
if (!empty($CC_CONFIG['AllGr'])) { // if (!empty($CC_CONFIG['AllGr'])) {
if (!Subjects::GetSubjId($CC_CONFIG['AllGr'])) { // if (!Subjects::GetSubjId($CC_CONFIG['AllGr'])) {
echo " * Creating group '".$CC_CONFIG['AllGr']."'..."; // echo " * Creating group '".$CC_CONFIG['AllGr']."'...";
$allid = Subjects::AddSubj($CC_CONFIG['AllGr']); // $allid = Subjects::AddSubj($CC_CONFIG['AllGr']);
if (PEAR::isError($allid)) { // if (PEAR::isError($allid)) {
return $allid; // return $allid;
} // }
//
// Add the "read" permission to the "all" group. // // Add the "read" permission to the "all" group.
Alib::AddPerm($allid, 'read', $this->rootId, 'A'); // Alib::AddPerm($allid, 'read', $this->storId, 'A');
echo "done.\n"; // echo "done.\n";
} else { // } else {
echo " * Skipping: group already exists: '".$CC_CONFIG['AllGr']."'\n"; // echo " * Skipping: group already exists: '".$CC_CONFIG['AllGr']."'\n";
} // }
} // }
// Add the "Station Preferences" group // Add the "Station Preferences" group
if (!empty($CC_CONFIG['StationPrefsGr'])) { if (!empty($CC_CONFIG['StationPrefsGr'])) {
@ -2001,10 +1997,10 @@ class BasicStor {
} }
// Add root user to the admin group // Add root user to the admin group
$r = Subjects::AddSubjectToGroup('root', $CC_CONFIG['AdminsGr']); // $r = Subjects::AddSubjectToGroup('root', $CC_CONFIG['AdminsGr']);
if (PEAR::isError($r)) { // if (PEAR::isError($r)) {
return $r; // return $r;
} // }
echo "done.\n"; echo "done.\n";
} else { } else {
echo " * Skipping: user already exists: 'root'\n"; echo " * Skipping: user already exists: 'root'\n";
@ -2013,12 +2009,12 @@ class BasicStor {
// Create the user named 'scheduler'. // Create the user named 'scheduler'.
if (!Subjects::GetSubjId('scheduler')) { if (!Subjects::GetSubjId('scheduler')) {
echo " * Creating user 'scheduler'..."; echo " * Creating user 'scheduler'...";
Subjects::AddSubj('scheduler', $CC_CONFIG['schedulerPass']); $subid = Subjects::AddSubj('scheduler', $CC_CONFIG['schedulerPass']);
$res = Alib::AddPerm($rootUid, 'read', $this->rootId, 'A'); $res = Alib::AddPerm($subid, 'read', '0', 'A');
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
return $res; return $res;
} }
$r = Subjects::AddSubjectToGroup('scheduler', $CC_CONFIG['AllGr']); //$r = Subjects::AddSubjectToGroup('scheduler', $CC_CONFIG['AllGr']);
echo "done.\n"; echo "done.\n";
} else { } else {
echo " * Skipping: user already exists: 'scheduler'\n"; echo " * Skipping: user already exists: 'scheduler'\n";

View File

@ -1,5 +1,14 @@
<?php <?php
// 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);
}
require_once('conf.php'); require_once('conf.php');
require_once('DB.php'); require_once('DB.php');
require_once('install/installInit.php'); require_once('install/installInit.php');

View File

@ -1432,10 +1432,10 @@ class GreenBox extends BasicStor {
* @return string * @return string
* preference value * preference value
*/ */
public function loadGroupPref($sessid, $group, $key) public function loadGroupPref($group, $key)
{ {
$pr = new Prefs($this); $pr = new Prefs($this);
$res = $pr->loadGroupPref($sessid, $group, $key); $res = $pr->loadGroupPref($group, $key);
return $res; return $res;
} // fn loadGroupPref } // fn loadGroupPref

View File

@ -132,16 +132,16 @@ class Prefs {
/** /**
* Read group preference record * Read group preference record
* *
* @param string $sessid
* session id
* @param string $group * @param string $group
* group name * group name
* @param string $key * @param string $key
* preference key * preference key
* @param boolean $returnErrorIfKeyNotExists
* If set to true and the key doesnt exist, return a PEAR error.
* @return string * @return string
* preference value * preference value
*/ */
function loadGroupPref($sessid, $group, $key) function loadGroupPref($group, $key, $returnErrorIfKeyNotExists = true)
{ {
// if sessid is would be used here fix Transport::cronCallMethod ! // if sessid is would be used here fix Transport::cronCallMethod !
$subjid = Subjects::GetSubjId($group); $subjid = Subjects::GetSubjId($group);
@ -157,8 +157,12 @@ class Prefs {
return $val; return $val;
} }
if ($val === FALSE) { if ($val === FALSE) {
return PEAR::raiseError( if ($returnErrorIfKeyNotExists) {
"Prefs::loadGroupPref: invalid preference key", GBERR_PREF); return PEAR::raiseError(
"Prefs::loadGroupPref: invalid preference key", GBERR_PREF);
} else {
return '';
}
} }
return $val; return $val;
} }
@ -437,59 +441,5 @@ class Prefs {
return TRUE; return TRUE;
} }
/**
* Install database table for preference storage
*
* @return boolean
*/
// function install()
// {
// global $CC_CONFIG, $CC_DBC;
// $CC_DBC->createSequence("{$this->prefTable}_id_seq");
// $r = $CC_DBC->query("CREATE TABLE {$this->prefTable} (
// id int not null,
// subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
// keystr varchar(255),
// valstr text
// )");
// if (PEAR::isError($r)) {
// return $r;
// }
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx
// ON {$this->prefTable} (id)");
// $CC_DBC->query("CREATE UNIQUE INDEX {$this->prefTable}_subj_key_idx
// ON {$this->prefTable} (subjid, keystr)");
// $CC_DBC->query("CREATE INDEX {$this->prefTable}_subjid_idx
// ON {$this->prefTable} (subjid)");
// $stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']);
// if (PEAR::isError($stPrefGr)) {
// echo $stPrefGr->getMessage()."\n";
// }
// $r = Prefs::Insert($stPrefGr, 'stationName', "Radio Station 1");
// if (PEAR::isError($r)) {
// echo $r->getMessage()."\n";
// }
// $genres = file_get_contents(dirname(__FILE__).'/../genres.xml');
// $r = Prefs::Insert($stPrefGr, 'genres', $genres);
// if (PEAR::isError($r)) {
// echo $r->getMessage()."\n";
// }
// return TRUE;
// }
/**
* Uninstall database table for preference storage
*
* @return boolean
*/
// function uninstall()
// {
// global $CC_CONFIG, $CC_DBC;
// $CC_DBC->query("DROP TABLE {$this->prefTable}");
// $CC_DBC->dropSequence("{$this->prefTable}_id_seq");
// }
} // class Prefs } // class Prefs
?> ?>

View File

@ -458,7 +458,7 @@ class StoredFile {
if (!is_integer($storedFile->id)) { if (!is_integer($storedFile->id)) {
// NOTE: POSTGRES-SPECIFIC // NOTE: POSTGRES-SPECIFIC
$sql = "SELECT currval('file_id_seq')"; $sql = "SELECT currval('".$CC_CONFIG["filesSequence"]."')";
$storedFile->id = $CC_DBC->getOne($sql); $storedFile->id = $CC_DBC->getOne($sql);
} }
// Insert metadata // Insert metadata

View File

@ -199,9 +199,9 @@ class Transport
{ {
require_once('Prefs.php'); require_once('Prefs.php');
$pr = new Prefs($this->gb); $pr = new Prefs($this->gb);
$group = 'StationPrefs'; $group = $CC_CONFIG['StationPrefsGr'];
$key = 'TransportsDenied'; $key = 'TransportsDenied';
$res = $pr->loadGroupPref($sessid, $group, $key); $res = $pr->loadGroupPref($group, $key);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
if ($res->getCode() !== GBERR_PREF) { if ($res->getCode() !== GBERR_PREF) {
return $res; return $res;
@ -863,6 +863,7 @@ class Transport
*/ */
function cronCallMethod($trtok) function cronCallMethod($trtok)
{ {
global $CC_CONFIG;
$trec = TransportRecord::recall($this, $trtok); $trec = TransportRecord::recall($this, $trtok);
if (PEAR::isError($trec)) { if (PEAR::isError($trec)) {
return $trec; return $trec;
@ -903,9 +904,9 @@ class Transport
case 'waiting': case 'waiting':
require_once('Prefs.php'); require_once('Prefs.php');
$pr = new Prefs($this->gb); $pr = new Prefs($this->gb);
$group = 'StationPrefs'; $group = $CC_CONFIG['StationPrefsGr'];
$key = 'TransportsDenied'; $key = 'TransportsDenied';
$res = $pr->loadGroupPref(NULL/*sessid*/, $group, $key); $res = $pr->loadGroupPref($group, $key);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
if ($res->getCode() !== GBERR_PREF) { if ($res->getCode() !== GBERR_PREF) {
return $res; return $res;
@ -1668,32 +1669,31 @@ class Transport
{ {
global $CC_CONFIG; global $CC_CONFIG;
$xrp = XML_RPC_encode($pars); $xrp = XML_RPC_encode($pars);
$group = 'StationPrefs'; $pr = new Prefs($this->gb);
$group = $CC_CONFIG["StationPrefsGr"];
$key = 'archiveServerLocation'; $key = 'archiveServerLocation';
$archiveUrl = $pr->loadGroupPref(NULL/*sessid*/, $group, $key); $archiveUrl = $pr->loadGroupPref($group, $key, false);
if($archiveUrl){ echo "Archive URL: $archiveUrl\n";
if ($archiveUrl) {
$archiveUrlInfo = parse_url($archiveUrl); $archiveUrlInfo = parse_url($archiveUrl);
if ($archiveUrlInfo['port']) {
if($archiveUrlInfo['port']){
$port = $archiveUrlInfo['port']; $port = $archiveUrlInfo['port'];
} }
else { else {
$port = 80; $port = 80;
} }
$c = new XML_RPC_Client($archiveUrlInfo['path'], $archiveUrlInfo['host'], $port);
$c = new XML_RPC_Client($archiveUrlInfo['path'], $archiveUrlInfo['host'], $port);
} }
else { else {
$c = new XML_RPC_Client( $c = new XML_RPC_Client(
$CC_CONFIG['archiveUrlPath']."/".$CC_CONFIG['archiveXMLRPC'], $CC_CONFIG['archiveUrlPath']."/".$CC_CONFIG['archiveXMLRPC'],
$CC_CONFIG['archiveUrlHost'], $CC_CONFIG['archiveUrlPort'] $CC_CONFIG['archiveUrlHost'], $CC_CONFIG['archiveUrlPort']
); );
} }
$f = new XML_RPC_Message($method, array($xrp)); $f = new XML_RPC_Message($method, array($xrp));
$r = $c->send($f); $r = $c->send($f);
if (!$r) { if (!$r) {

View File

@ -15,7 +15,6 @@
* <dt>bufferDir <dd>directory for temporary files * <dt>bufferDir <dd>directory for temporary files
* <dt>transDir <dd>directory for incomplete transferred files * <dt>transDir <dd>directory for incomplete transferred files
* <dt>accessDir <dd>directory for symlinks to accessed files * <dt>accessDir <dd>directory for symlinks to accessed files
* <dt>isArchive <dd>local/central flag
* <dt>validate <dd>enable/disable validator * <dt>validate <dd>enable/disable validator
* <dt>useTrash <dd>enable/disable safe delete (move to trash) * <dt>useTrash <dd>enable/disable safe delete (move to trash)
* <dt>storageUrlPath<dd>path-URL-part of storageServer base dir * <dt>storageUrlPath<dd>path-URL-part of storageServer base dir
@ -44,20 +43,20 @@ $CC_CONFIG = array(
'phptype' => 'pgsql', 'phptype' => 'pgsql',
'database' => 'Campcaster-paul', 'database' => 'Campcaster-paul',
), ),
'tblNamePrefix' => 'ls_', 'tblNamePrefix' => 'cc_',
/* ================================================ storage configuration */ /* ================================================ storage configuration */
'authCookieName'=> 'campcaster_session_id', 'authCookieName'=> 'campcaster_session_id',
'AdminsGr' => 'Admins', //'AdminsGr' => 'Admins',
'StationPrefsGr'=> 'StationPrefs', 'StationPrefsGr'=> 'StationPrefs',
'AllGr' => 'All', //'AllGr' => 'All',
'TrashName' => 'trash_', 'TrashName' => 'trash_',
'storageDir' => dirname(__FILE__).'/../../storageServer/var/stor', 'storageDir' => dirname(__FILE__).'/../../storageServer/var/stor',
'bufferDir' => dirname(__FILE__).'/../../storageServer/var/stor/buffer', 'bufferDir' => dirname(__FILE__).'/../../storageServer/var/stor/buffer',
'transDir' => dirname(__FILE__).'/../../storageServer/var/trans', 'transDir' => dirname(__FILE__).'/../../storageServer/var/trans',
'accessDir' => dirname(__FILE__).'/../../storageServer/var/access', 'accessDir' => dirname(__FILE__).'/../../storageServer/var/access',
'pearPath' => dirname(__FILE__).'/../../../../usr/lib/pear', 'pearPath' => dirname(__FILE__).'/../../../../usr/lib/pear',
// 'zendPath' => dirname(__FILE__).'/../../../../usr/lib',
'cronDir' => dirname(__FILE__).'/../../storageServer/var/cron', 'cronDir' => dirname(__FILE__).'/../../storageServer/var/cron',
'isArchive' => FALSE,
'validate' => TRUE, 'validate' => TRUE,
'useTrash' => TRUE, 'useTrash' => TRUE,
@ -71,6 +70,7 @@ $CC_CONFIG = array(
'archiveUrlPath' => '/campcasterStorageServer', 'archiveUrlPath' => '/campcasterStorageServer',
'archiveXMLRPC' => 'xmlrpc/xrLocStor.php', 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php',
'archiveUrlHost' => 'localhost', 'archiveUrlHost' => 'localhost',
// 'archiveUrlHost' => '192.168.30.166',
'archiveUrlPort' => 80, 'archiveUrlPort' => 80,
'archiveAccountLogin' => 'root', 'archiveAccountLogin' => 'root',
'archiveAccountPass' => 'q', 'archiveAccountPass' => 'q',
@ -110,6 +110,7 @@ $CC_CONFIG = array(
'lockfile' => dirname(__FILE__).'/../../storageServer/var/stor/buffer/cron.lock', 'lockfile' => dirname(__FILE__).'/../../storageServer/var/stor/buffer/cron.lock',
'cronfile' => dirname(__FILE__).'/cron/croncall.php', 'cronfile' => dirname(__FILE__).'/cron/croncall.php',
'paramdir' => dirname(__FILE__).'/cron/params', 'paramdir' => dirname(__FILE__).'/cron/params',
'systemPrefId' => "0", // ID for system prefs in prefs table
); );
// Add database table names // Add database table names
@ -122,15 +123,16 @@ $CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs';
$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb'; $CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb';
$CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans'; $CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans';
$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref'; $CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref';
$CC_CONFIG['playlogTable'] = 'playlog'; $CC_CONFIG['playlogTable'] = $CC_CONFIG['tblNamePrefix'].'playlog';
$CC_CONFIG['scheduleTable'] = 'schedule'; $CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule';
$CC_CONFIG['backupTable'] = 'backup'; $CC_CONFIG['backupTable'] = $CC_CONFIG['tblNamePrefix'].'backup';
$CC_CONFIG['filesSequence'] = $CC_CONFIG['tblNamePrefix']."file_id_seq";
$CC_CONFIG['sysSubjs'] = array( $CC_CONFIG['sysSubjs'] = array(
'root', $CC_CONFIG['AdminsGr'], $CC_CONFIG['AllGr'], $CC_CONFIG['StationPrefsGr'] 'root', /*$CC_CONFIG['AdminsGr'],*/ /*$CC_CONFIG['AllGr'],*/ $CC_CONFIG['StationPrefsGr']
); );
$old_ip = get_include_path(); $old_include_path = get_include_path();
set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_ip); set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_include_path);
// see if a ~/.campcaster/storageServer.conf.php exists, and // see if a ~/.campcaster/storageServer.conf.php exists, and
// overwrite the settings from there if any // overwrite the settings from there if any

View File

@ -70,8 +70,8 @@ $CC_CONFIG = array(
'storageUrlPort' => ls_php_port, 'storageUrlPort' => ls_php_port,
/* ================================================ archive configuration */ /* ================================================ archive configuration */
'archiveUrlPath' => 'ls_archiveUrlPath', 'archiveUrlPath' => 'ls_storageUrlPath',
'archiveXMLRPC' => 'xmlrpc/xrArchive.php', 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php',
'archiveUrlHost' => 'ls_php_host', 'archiveUrlHost' => 'ls_php_host',
'archiveUrlPort' => ls_php_port, 'archiveUrlPort' => ls_php_port,
'archiveAccountLogin' => 'root', 'archiveAccountLogin' => 'root',

View File

@ -43,8 +43,8 @@ $CC_CONFIG = array(
'storageUrlPort' => ls_php_port, 'storageUrlPort' => ls_php_port,
/* ================================================ archive configuration */ /* ================================================ archive configuration */
'archiveUrlPath' => 'ls_archiveUrlPath', 'archiveUrlPath' => 'ls_storageUrlPath',
'archiveXMLRPC' => 'xmlrpc/xrArchive.php', 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php',
'archiveUrlHost' => 'ls_php_host', 'archiveUrlHost' => 'ls_php_host',
'archiveUrlPort' => ls_php_port, 'archiveUrlPort' => ls_php_port,
'archiveAccountLogin' => 'root', 'archiveAccountLogin' => 'root',

View File

@ -164,7 +164,7 @@ class Cron {
*/ */
function lockCrontab() function lockCrontab()
{ {
return touch($this->lockfile); return @touch($this->lockfile);
} }
/** /**

View File

@ -111,7 +111,7 @@ class Crontab
// It's a regular crontab-entry // It's a regular crontab-entry
$ct = split("[ \t]", $line, 6); $ct = split("[ \t]", $line, 6);
$this->addCron($ct[0], $ct[1], $ct[2], $ct[3], $ct[4], $ct[5], $ct[6]); $this->addCron($ct[0], $ct[1], $ct[2], $ct[3], $ct[4], $ct[5]);
} }
} }
@ -122,6 +122,9 @@ class Crontab
{ {
global $DEBUG, $PATH; global $DEBUG, $PATH;
if (empty($this->linetypes)) {
return;
}
$filename = ($DEBUG ? tempnam("$PATH/crons", "cron") : tempnam("/tmp", "cron")); $filename = ($DEBUG ? tempnam("$PATH/crons", "cron") : tempnam("/tmp", "cron"));
$file = fopen($filename, "w"); $file = fopen($filename, "w");

View File

@ -6,7 +6,9 @@
header("Content-type: text/plain"); header("Content-type: text/plain");
$egid = posix_getegid(); $egid = posix_getegid();
$info = posix_getgrgid($egid); $info = posix_getgrgid($egid);
if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") { if ( (isset($_SERVER["REMOTE_ADDR"]) && ($_SERVER["REMOTE_ADDR"] == "127.0.0.1"))
|| (isset($_SERVER["HTTP_HOST"]) && ($_SERVER["HTTP_HOST"] == "localhost"))
|| (isset($_SERVER["SHELL"])) ) {
echo $info['name']; echo $info['name'];
} }
?> ?>

View File

@ -4,7 +4,10 @@
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
header("Content-type: text/plain"); header("Content-type: text/plain");
if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") { //var_dump($_SERVER);
if ( (isset($_SERVER["REMOTE_ADDR"]) && ($_SERVER["REMOTE_ADDR"] == "127.0.0.1"))
|| (isset($_SERVER["HTTP_HOST"]) && ($_SERVER["HTTP_HOST"] == "localhost"))
|| (isset($_SERVER["SHELL"])) ) {
echo `pwd`; echo `pwd`;
} }
?> ?>

View File

@ -5,11 +5,10 @@
* @copyright 2010 Sourcefabric O.P.S. * @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt * @license http://www.gnu.org/licenses/gpl.txt
* *
* 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.
*/ */
$WHITE_SCREEN_OF_DEATH = false;
// Do not allow remote execution // Do not allow remote execution
$arr = array_diff_assoc($_SERVER, $_ENV); $arr = array_diff_assoc($_SERVER, $_ENV);
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) { if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
@ -27,8 +26,472 @@ require_once('../conf.php');
require_once('../GreenBox.php'); require_once('../GreenBox.php');
require_once("installInit.php"); require_once("installInit.php");
campcaster_db_connect(true); campcaster_db_connect(true);
require_once('installMain.php');
require_once('installStorage.php'); //------------------------------------------------------------------------------
// Install database tables
//------------------------------------------------------------------------------
if (!camp_db_table_exists($CC_CONFIG['subjTable'])) {
echo " * Creating database table ".$CC_CONFIG['subjTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['subjTable']." (
id int not null PRIMARY KEY,
login varchar(255) not null default'',
pass varchar(255) not null default'',
type char(1) not null default 'U',
realname varchar(255) not null default'',
lastlogin timestamp,
lastfail timestamp
)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_id_idx
ON ".$CC_CONFIG['subjTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_login_idx
ON ".$CC_CONFIG['subjTable']." (login)";
camp_install_query($sql, false);
$CC_DBC->createSequence($CC_CONFIG['subjTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['subjTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['smembTable'])) {
echo " * Creating database table ".$CC_CONFIG['smembTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['smembTable']." (
id int not null PRIMARY KEY,
uid int not null default 0,
gid int not null default 0,
level int not null default 0,
mid int)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['smembTable']."_id_idx
ON ".$CC_CONFIG['smembTable']." (id)";
camp_install_query($sql, false);
$CC_DBC->createSequence($CC_CONFIG['smembTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['smembTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['permTable'])) {
echo " * Creating database table ".$CC_CONFIG['permTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['permTable']." (
permid int not null PRIMARY KEY,
subj int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
action varchar(20),
obj int,
type char(1))";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_permid_idx
ON ".$CC_CONFIG['permTable']." (permid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['permTable']."_subj_obj_idx
ON ".$CC_CONFIG['permTable']." (subj, obj)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_all_idx
ON ".$CC_CONFIG['permTable']." (subj, action, obj)";
camp_install_query($sql, false);
$CC_DBC->createSequence($CC_CONFIG['permTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['permTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['sessTable'])) {
echo " * Creating database table ".$CC_CONFIG['sessTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['sessTable']." (
sessid char(32) not null PRIMARY KEY,
userid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
login varchar(255),
ts timestamp)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['sessTable']."_sessid_idx
ON ".$CC_CONFIG['sessTable']." (sessid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['sessTable']."_userid_idx
ON ".$CC_CONFIG['sessTable']." (userid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['sessTable']."_login_idx
ON ".$CC_CONFIG['sessTable']." (login)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['sessTable']."\n";
}
/**
* file states:
* <ul>
* <li>empty</li>
* <li>incomplete</li>
* <li>ready</li>
* <li>edited</li>
* <li>deleted</li>
* </ul>
* file types:
* <ul>
* <li>audioclip</li>
* <li>playlist</li>
* <li>webstream</li>
* </ul>
* access types:
* <ul>
* <li>access</li>
* <li>download</li>
* </ul>
*/
if (!camp_db_table_exists($CC_CONFIG['filesTable'])) {
echo " * Creating database table ".$CC_CONFIG['filesTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['filesTable']." (
id int not null,
gunid bigint not null, -- global unique ID
name varchar(255) not null default'', -- human file id ;)
mime varchar(255) not null default'', -- mime type
ftype varchar(128) not null default'', -- file type
state varchar(128) not null default'empty', -- file state
currentlyaccessing int not null default 0, -- access counter
editedby int REFERENCES ".$CC_CONFIG['subjTable'].", -- who edits it
mtime timestamp(6) with time zone, -- lst modif.time
md5 char(32)
)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_id_idx
ON ".$CC_CONFIG['filesTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_gunid_idx
ON ".$CC_CONFIG['filesTable']." (gunid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_name_idx
ON ".$CC_CONFIG['filesTable']." (name)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx
ON ".$CC_CONFIG['filesTable']." (md5)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['filesTable']."\n";
}
if (!camp_db_sequence_exists($CC_CONFIG["filesSequence"])) {
echo " * Creating database sequence ".$CC_CONFIG['filesSequence']."...";
$sql = "CREATE SEQUENCE ".$CC_CONFIG["filesSequence"]
." INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1000000
CACHE 1";
camp_install_query($sql);
} else {
echo " * Skipping: database sequence already exists: ".$CC_CONFIG['filesSequence']."\n";
}
/**
* id subjns subject predns predicate objns object
* y1 literal xmbf NULL namespace literal http://www.sotf.org/xbmf
* x1 gunid <gunid> xbmf contributor NULL NULL
* x2 mdid x1 xbmf role literal Editor
*
* predefined shortcuts:
* _L = literal
* _G = gunid (global id of media file)
* _I = mdid (local id of metadata record)
* _nssshortcut = namespace shortcut definition
* _blank = blank node
*/
if (!camp_db_table_exists($CC_CONFIG['mdataTable'])) {
echo " * Creating database table ".$CC_CONFIG['mdataTable']."...";
$CC_DBC->createSequence($CC_CONFIG['mdataTable']."_id_seq");
$sql = "CREATE TABLE ".$CC_CONFIG['mdataTable']." (
id int not null,
gunid bigint,
subjns varchar(255), -- subject namespace shortcut/uri
subject varchar(255) not null default '',
predns varchar(255), -- predicate namespace shortcut/uri
predicate varchar(255) not null,
predxml char(1) not null default 'T', -- Tag or Attribute
objns varchar(255), -- object namespace shortcut/uri
object text
)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['mdataTable']."_id_idx
ON ".$CC_CONFIG['mdataTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_gunid_idx
ON ".$CC_CONFIG['mdataTable']." (gunid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_subj_idx
ON ".$CC_CONFIG['mdataTable']." (subjns, subject)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_pred_idx
ON ".$CC_CONFIG['mdataTable']." (predns, predicate)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['mdataTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['accessTable'])) {
echo " * Creating database table ".$CC_CONFIG['accessTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['accessTable']." (
gunid bigint, -- global unique id
token bigint, -- access token
chsum char(32) not null default'', -- md5 checksum
ext varchar(128) not null default'', -- extension
type varchar(20) not null default'', -- access type
parent bigint, -- parent token
owner int REFERENCES ".$CC_CONFIG['subjTable'].", -- subject have started it
ts timestamp
)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_token_idx
ON ".$CC_CONFIG['accessTable']." (token)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_gunid_idx
ON ".$CC_CONFIG['accessTable']." (gunid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_parent_idx
ON ".$CC_CONFIG['accessTable']." (parent)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['accessTable']."\n";
}
echo " * Inserting default users...\n";
$gb = new GreenBox();
$r = $gb->initData(true);
if (PEAR::isError($r)) {
echo "\n * ERROR: ";
print_r($r);
}
//echo "done.\n";
//------------------------------------------------------------------------------
// Submodules
//------------------------------------------------------------------------------
if (!camp_db_table_exists($CC_CONFIG['transTable'])) {
echo " * Creating database table ".$CC_CONFIG['transTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['transTable']." (
id int not null, -- primary key
trtok char(16) not null, -- transport token
direction varchar(128) not null, -- direction: up|down
state varchar(128) not null, -- state
trtype varchar(128) not null, -- transport type
lock char(1) not null default 'N',-- running lock
target varchar(255) default NULL, -- target system,
-- if NULL => predefined set
rtrtok char(16) default NULL, -- remote hub's transport token
mdtrtok char(16), -- metadata transport token
gunid bigint, -- global unique id
pdtoken bigint, -- put/download token from archive
url varchar(255), -- url on remote side
localfile varchar(255), -- pathname of local part
fname varchar(255), -- mnemonic filename
title varchar(255), -- dc:title mdata value (or filename ...)
expectedsum char(32), -- expected file checksum
realsum char(32), -- checksum of transported part
expectedsize int, -- expected filesize in bytes
realsize int, -- filesize of transported part
uid int, -- local user id of transport owner
errmsg varchar(255), -- error message string for failed tr.
jobpid int, -- pid of transport job
start timestamp, -- starttime
ts timestamp -- mtime
)";
camp_install_query($sql, false);
$CC_DBC->createSequence($CC_CONFIG['transTable']."_id_seq");
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_id_idx
ON ".$CC_CONFIG['transTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_trtok_idx
ON ".$CC_CONFIG['transTable']." (trtok)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_token_idx
ON ".$CC_CONFIG['transTable']." (pdtoken)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['transTable']."_gunid_idx
ON ".$CC_CONFIG['transTable']." (gunid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['transTable']."_state_idx
ON ".$CC_CONFIG['transTable']." (state)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['transTable']."\n";
}
/**
* Scheduler tables.
*/
if (!camp_db_table_exists($CC_CONFIG['scheduleTable'])) {
echo " * Creating database table ".$CC_CONFIG['scheduleTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['scheduleTable']."("
." id BIGINT NOT NULL,"
." playlist BIGINT NOT NULL,"
." starts TIMESTAMP NOT NULL,"
." ends TIMESTAMP NOT NULL,"
." PRIMARY KEY(id))";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['scheduleTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['playlogTable'])) {
echo " * Creating database table ".$CC_CONFIG['playlogTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['playlogTable']."("
." id BIGINT NOT NULL,"
." audioClipId BIGINT NOT NULL,"
." timestamp TIMESTAMP NOT NULL,"
." PRIMARY KEY(id))";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['playlogTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['backupTable'])) {
echo " * Creating database table ".$CC_CONFIG['backupTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['backupTable']." ("
." token VARCHAR(64) NOT NULL,"
." sessionId VARCHAR(64) NOT NULL,"
." status VARCHAR(32) NOT NULL,"
." fromTime TIMESTAMP NOT NULL,"
." toTime TIMESTAMP NOT NULL,"
." PRIMARY KEY(token))";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['backupTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['prefTable'])) {
echo " * Creating database table ".$CC_CONFIG['prefTable']."...";
$CC_DBC->createSequence($CC_CONFIG['prefTable']."_id_seq");
$sql = "CREATE TABLE ".$CC_CONFIG['prefTable']." (
id int not null,
subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
keystr varchar(255),
valstr text
)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_id_idx
ON ".$CC_CONFIG['prefTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_subj_key_idx
ON ".$CC_CONFIG['prefTable']." (subjid, keystr)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['prefTable']."_subjid_idx
ON ".$CC_CONFIG['prefTable']." (subjid)";
camp_install_query($sql);
echo " * Inserting starting data into table ".$CC_CONFIG['prefTable']."...";
$stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']);
Prefs::Insert($CC_CONFIG["systemPrefId"], 'stationName', "Radio Station 1");
$genres = file_get_contents( dirname(__FILE__).'/../genres.xml');
Prefs::Insert($CC_CONFIG["systemPrefId"], 'genres', $genres);
echo "done.\n";
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['prefTable']."\n";
}
//------------------------------------------------------------------------
// Install storage directories
//------------------------------------------------------------------------
foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) {
$test = file_exists($CC_CONFIG[$d]);
if ( $test === FALSE ) {
@mkdir($CC_CONFIG[$d], 02775);
if (file_exists($CC_CONFIG[$d])) {
$rp = realpath($CC_CONFIG[$d]);
echo " * Directory $rp created\n";
} else {
echo " * Failed creating {$CC_CONFIG[$d]}\n";
exit(1);
}
} elseif (is_writable($CC_CONFIG[$d])) {
$rp = realpath($CC_CONFIG[$d]);
echo " * Skipping directory already exists: $rp\n";
} else {
$rp = realpath($CC_CONFIG[$d]);
echo " * WARNING: Directory already exists, but is not writable: $rp\n";
//exit(1);
}
$CC_CONFIG[$d] = $rp;
}
//------------------------------------------------------------------------
// Storage directory writability test
//------------------------------------------------------------------------
echo " * Testing writability of ".$CC_CONFIG['storageDir']."...";
if (!($fp = @fopen($CC_CONFIG['storageDir']."/_writeTest", 'w'))) {
echo "\nPlease make directory {$CC_CONFIG['storageDir']} writeable by your webserver".
"\nand run install again\n\n";
exit(1);
} else {
fclose($fp);
unlink($CC_CONFIG['storageDir']."/_writeTest");
}
echo "done.\n";
//------------------------------------------------------------------------
// Install Cron job
//------------------------------------------------------------------------
require_once(dirname(__FILE__).'/../cron/Cron.php');
$m = '*/2';
$h ='*';
$dom = '*';
$mon = '*';
$dow = '*';
$command = realpath("{$CC_CONFIG['cronDir']}/transportCron.php");
$old_regex = '/transportCron\.php/';
echo " * Install storageServer cron job...\n";
$cron = new Cron();
$access = $cron->openCrontab('write');
if ($access != 'write') {
do {
$r = $cron->forceWriteable();
} while ($r);
}
foreach ($cron->ct->getByType(CRON_CMD) as $id => $line) {
if (preg_match($old_regex, $line['command'])) {
echo " * Removing old entry: ".$line['command']."\n";
$cron->ct->delEntry($id);
}
}
echo " * Adding new entry: ".$command."\n";
$cron->ct->addCron($m, $h, $dom, $mon, $dow, $command);
$cron->closeCrontab();
echo " Done.\n";
echo "**********************************\n"; echo "**********************************\n";
echo "* StorageServer Install Complete *\n"; echo "* StorageServer Install Complete *\n";

View File

@ -3,7 +3,6 @@ if (!function_exists('pg_connect')) {
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR); trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
exit(2); exit(2);
} }
require_once('DB.php'); require_once('DB.php');
require_once('File/Find.php'); require_once('File/Find.php');
@ -18,6 +17,17 @@ function camp_db_table_exists($p_name)
return true; return true;
} }
function camp_db_sequence_exists($p_name)
{
global $CC_DBC;
$sql = "SELECT 1 FROM pg_class where relname = '$p_name'";
$result = $CC_DBC->GetOne($sql);
if (!PEAR::isError($result) && $result == "1") {
return true;
}
return false;
}
function camp_install_query($sql, $verbose = true) function camp_install_query($sql, $verbose = true)
{ {
global $CC_DBC; global $CC_DBC;

View File

@ -1,333 +0,0 @@
<?php
/**
* @version $Revision: 2475 $
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
// 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);
}
//------------------------------------------------------------------------------
// Install database tables
//------------------------------------------------------------------------------
if (!camp_db_table_exists($CC_CONFIG['subjTable'])) {
echo " * Creating database table ".$CC_CONFIG['subjTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['subjTable']." (
id int not null PRIMARY KEY,
login varchar(255) not null default'',
pass varchar(255) not null default'',
type char(1) not null default 'U',
realname varchar(255) not null default'',
lastlogin timestamp,
lastfail timestamp
)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_id_idx
ON ".$CC_CONFIG['subjTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_login_idx
ON ".$CC_CONFIG['subjTable']." (login)";
camp_install_query($sql, false);
$CC_DBC->createSequence($CC_CONFIG['subjTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['subjTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['smembTable'])) {
echo " * Creating database table ".$CC_CONFIG['smembTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['smembTable']." (
id int not null PRIMARY KEY,
uid int not null default 0,
gid int not null default 0,
level int not null default 0,
mid int)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['smembTable']."_id_idx
ON ".$CC_CONFIG['smembTable']." (id)";
camp_install_query($sql, false);
$CC_DBC->createSequence($CC_CONFIG['smembTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['smembTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['permTable'])) {
echo " * Creating database table ".$CC_CONFIG['permTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['permTable']." (
permid int not null PRIMARY KEY,
subj int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
action varchar(20),
obj int,
type char(1))";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_permid_idx
ON ".$CC_CONFIG['permTable']." (permid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['permTable']."_subj_obj_idx
ON ".$CC_CONFIG['permTable']." (subj, obj)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_all_idx
ON ".$CC_CONFIG['permTable']." (subj, action, obj)";
camp_install_query($sql, false);
$CC_DBC->createSequence($CC_CONFIG['permTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['permTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['sessTable'])) {
echo " * Creating database table ".$CC_CONFIG['sessTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['sessTable']." (
sessid char(32) not null PRIMARY KEY,
userid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
login varchar(255),
ts timestamp)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['sessTable']."_sessid_idx
ON ".$CC_CONFIG['sessTable']." (sessid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['sessTable']."_userid_idx
ON ".$CC_CONFIG['sessTable']." (userid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['sessTable']."_login_idx
ON ".$CC_CONFIG['sessTable']." (login)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['sessTable']."\n";
}
/**
* file states:
* <ul>
* <li>empty</li>
* <li>incomplete</li>
* <li>ready</li>
* <li>edited</li>
* <li>deleted</li>
* </ul>
* file types:
* <ul>
* <li>audioclip</li>
* <li>playlist</li>
* <li>webstream</li>
* </ul>
* access types:
* <ul>
* <li>access</li>
* <li>download</li>
* </ul>
*/
if (!camp_db_table_exists($CC_CONFIG['filesTable'])) {
echo " * Creating database table ".$CC_CONFIG['filesTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['filesTable']." (
id int not null,
gunid bigint not null, -- global unique ID
name varchar(255) not null default'', -- human file id ;)
mime varchar(255) not null default'', -- mime type
ftype varchar(128) not null default'', -- file type
state varchar(128) not null default'empty', -- file state
currentlyaccessing int not null default 0, -- access counter
editedby int REFERENCES ".$CC_CONFIG['subjTable'].", -- who edits it
mtime timestamp(6) with time zone, -- lst modif.time
md5 char(32)
)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_id_idx
ON ".$CC_CONFIG['filesTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_gunid_idx
ON ".$CC_CONFIG['filesTable']." (gunid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_name_idx
ON ".$CC_CONFIG['filesTable']." (name)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx
ON ls_files (md5)";
camp_install_query($sql);
$sql = "CREATE SEQUENCE file_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1000000
CACHE 1";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['filesTable']."\n";
}
/**
* id subjns subject predns predicate objns object
* y1 literal xmbf NULL namespace literal http://www.sotf.org/xbmf
* x1 gunid <gunid> xbmf contributor NULL NULL
* x2 mdid x1 xbmf role literal Editor
*
* predefined shortcuts:
* _L = literal
* _G = gunid (global id of media file)
* _I = mdid (local id of metadata record)
* _nssshortcut = namespace shortcut definition
* _blank = blank node
*/
if (!camp_db_table_exists($CC_CONFIG['mdataTable'])) {
echo " * Creating database table ".$CC_CONFIG['mdataTable']."...";
$CC_DBC->createSequence($CC_CONFIG['mdataTable']."_id_seq");
$sql = "CREATE TABLE ".$CC_CONFIG['mdataTable']." (
id int not null,
gunid bigint,
subjns varchar(255), -- subject namespace shortcut/uri
subject varchar(255) not null default '',
predns varchar(255), -- predicate namespace shortcut/uri
predicate varchar(255) not null,
predxml char(1) not null default 'T', -- Tag or Attribute
objns varchar(255), -- object namespace shortcut/uri
object text
)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['mdataTable']."_id_idx
ON ".$CC_CONFIG['mdataTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_gunid_idx
ON ".$CC_CONFIG['mdataTable']." (gunid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_subj_idx
ON ".$CC_CONFIG['mdataTable']." (subjns, subject)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_pred_idx
ON ".$CC_CONFIG['mdataTable']." (predns, predicate)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['mdataTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['accessTable'])) {
echo " * Creating database table ".$CC_CONFIG['accessTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['accessTable']." (
gunid bigint, -- global unique id
token bigint, -- access token
chsum char(32) not null default'', -- md5 checksum
ext varchar(128) not null default'', -- extension
type varchar(20) not null default'', -- access type
parent bigint, -- parent token
owner int REFERENCES ".$CC_CONFIG['subjTable'].", -- subject have started it
ts timestamp
)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_token_idx
ON ".$CC_CONFIG['accessTable']." (token)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_gunid_idx
ON ".$CC_CONFIG['accessTable']." (gunid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_parent_idx
ON ".$CC_CONFIG['accessTable']." (parent)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['accessTable']."\n";
}
echo " * Inserting starting data into tables...\n";
$gb = new GreenBox();
$r = $gb->initData(true);
if (PEAR::isError($r)) {
echo "\n * ERROR: ";
print_r($r);
}
//echo "done.\n";
//------------------------------------------------------------------------------
// Submodules
//------------------------------------------------------------------------------
if (!camp_db_table_exists($CC_CONFIG['transTable'])) {
echo " * Creating database table ".$CC_CONFIG['transTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['transTable']." (
id int not null, -- primary key
trtok char(16) not null, -- transport token
direction varchar(128) not null, -- direction: up|down
state varchar(128) not null, -- state
trtype varchar(128) not null, -- transport type
lock char(1) not null default 'N',-- running lock
target varchar(255) default NULL, -- target system,
-- if NULL => predefined set
rtrtok char(16) default NULL, -- remote hub's transport token
mdtrtok char(16), -- metadata transport token
gunid bigint, -- global unique id
pdtoken bigint, -- put/download token from archive
url varchar(255), -- url on remote side
localfile varchar(255), -- pathname of local part
fname varchar(255), -- mnemonic filename
title varchar(255), -- dc:title mdata value (or filename ...)
expectedsum char(32), -- expected file checksum
realsum char(32), -- checksum of transported part
expectedsize int, -- expected filesize in bytes
realsize int, -- filesize of transported part
uid int, -- local user id of transport owner
errmsg varchar(255), -- error message string for failed tr.
jobpid int, -- pid of transport job
start timestamp, -- starttime
ts timestamp -- mtime
)";
camp_install_query($sql, false);
$CC_DBC->createSequence($CC_CONFIG['transTable']."_id_seq");
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_id_idx
ON ".$CC_CONFIG['transTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_trtok_idx
ON ".$CC_CONFIG['transTable']." (trtok)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_token_idx
ON ".$CC_CONFIG['transTable']." (pdtoken)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['transTable']."_gunid_idx
ON ".$CC_CONFIG['transTable']." (gunid)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['transTable']."_state_idx
ON ".$CC_CONFIG['transTable']." (state)";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['transTable']."\n";
}
?>

View File

@ -1,115 +0,0 @@
<?php
// 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);
}
if (!camp_db_table_exists($CC_CONFIG['prefTable'])) {
echo " * Creating database table ".$CC_CONFIG['prefTable']."...";
$CC_DBC->createSequence($CC_CONFIG['prefTable']."_id_seq");
$sql = "CREATE TABLE ".$CC_CONFIG['prefTable']." (
id int not null,
subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE,
keystr varchar(255),
valstr text
)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_id_idx
ON ".$CC_CONFIG['prefTable']." (id)";
camp_install_query($sql, false);
$sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_subj_key_idx
ON ".$CC_CONFIG['prefTable']." (subjid, keystr)";
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['prefTable']."_subjid_idx
ON ".$CC_CONFIG['prefTable']." (subjid)";
camp_install_query($sql);
echo " * Inserting starting data into table ".$CC_CONFIG['prefTable']."...";
$stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']);
Prefs::Insert($stPrefGr, 'stationName', "Radio Station 1");
$genres = file_get_contents( dirname(__FILE__).'/../genres.xml');
Prefs::Insert($stPrefGr, 'genres', $genres);
echo "done.\n";
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['prefTable']."\n";
}
//------------------------------------------------------------------------
// Install storage directories
//------------------------------------------------------------------------
foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) {
$test = file_exists($CC_CONFIG[$d]);
if ( $test === FALSE ) {
@mkdir($CC_CONFIG[$d], 02775);
if (file_exists($CC_CONFIG[$d])) {
$rp = realpath($CC_CONFIG[$d]);
echo " * Directory $rp created\n";
} else {
echo " * Failed creating {$CC_CONFIG[$d]}\n";
exit(1);
}
} elseif (is_writable($CC_CONFIG[$d])) {
$rp = realpath($CC_CONFIG[$d]);
echo " * Skipping directory already exists: $rp\n";
} else {
$rp = realpath($CC_CONFIG[$d]);
echo " * ERROR. Directory already exists, but is not writable: $rp\n";
exit(1);
}
$CC_CONFIG[$d] = $rp;
}
//------------------------------------------------------------------------
// Storage directory writability test
//------------------------------------------------------------------------
echo " * Testing writability of ".$CC_CONFIG['storageDir']."...";
if (!($fp = @fopen($CC_CONFIG['storageDir']."/_writeTest", 'w'))) {
echo "\nPlease make directory {$CC_CONFIG['storageDir']} writeable by your webserver".
"\nand run install again\n\n";
exit(1);
} else {
fclose($fp);
unlink($CC_CONFIG['storageDir']."/_writeTest");
}
echo "done.\n";
//------------------------------------------------------------------------
// Install Cron job
//------------------------------------------------------------------------
require_once(dirname(__FILE__).'/../cron/Cron.php');
$m = '*/2';
$h ='*';
$dom = '*';
$mon = '*';
$dow = '*';
$command = realpath("{$CC_CONFIG['cronDir']}/transportCron.php");
$old_regex = '/transportCron\.php/';
echo " * Install storageServer cron job...\n";
$cron = new Cron();
$access = $cron->openCrontab('write');
if ($access != 'write') {
do {
$r = $cron->forceWriteable();
} while ($r);
}
foreach ($cron->ct->getByType(CRON_CMD) as $id => $line) {
if (preg_match($old_regex, $line['command'])) {
echo " * Removing old entry: ".$line['command']."\n";
$cron->ct->delEntry($id);
}
}
echo " * Adding new entry: ".$command."\n";
$cron->ct->addCron($m, $h, $dom, $mon, $dow, $command);
$cron->closeCrontab();
echo " Done.\n";
?>

View File

@ -23,9 +23,171 @@ echo "***************************\n";
require_once('../conf.php'); require_once('../conf.php');
require_once('installInit.php'); require_once('installInit.php');
campcaster_db_connect(false); campcaster_db_connect(false);
require_once('uninstallStorage.php');
function camp_uninstall_delete_files($p_path)
{
if (!empty($p_path) && (strlen($p_path) > 4)) {
list($dirList,$fileList) = File_Find::maptree($p_path);
foreach ($fileList as $filepath) {
echo " * Removing $filepath...";
@unlink($filepath);
echo "done.\n";
}
foreach ($dirList as $dirpath) {
echo " * Removing $dirpath...";
@rmdir($dirpath);
echo "done.\n";
}
}
}
if (!PEAR::isError($CC_DBC)) { if (!PEAR::isError($CC_DBC)) {
require_once('uninstallMain.php'); if (camp_db_table_exists($CC_CONFIG['prefTable'])) {
echo " * Removing database table ".$CC_CONFIG['prefTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['prefTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['prefTable']."\n";
}
}
//------------------------------------------------------------------------
// Uninstall Cron job
//------------------------------------------------------------------------
require_once(dirname(__FILE__).'/../cron/Cron.php');
$old_regex = '/transportCron\.php/';
echo " * Uninstall storageServer cron job...\n";
$cron = new Cron();
$access = $cron->openCrontab('write');
if ($access != 'write') {
do {
$r = $cron->forceWriteable();
} while ($r);
}
foreach ($cron->ct->getByType(CRON_CMD) as $id => $line) {
if (preg_match($old_regex, $line['command'])) {
echo " removing cron entry\n";
$cron->ct->delEntry($id);
}
}
$cron->closeCrontab();
echo "Done.\n";
camp_uninstall_delete_files($CC_CONFIG['storageDir']);
camp_uninstall_delete_files($CC_CONFIG['transDir']);
camp_uninstall_delete_files($CC_CONFIG['accessDir']);
if (camp_db_table_exists($CC_CONFIG['transTable'])) {
echo " * Removing database table ".$CC_CONFIG['transTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['transTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['transTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['mdataTable'])) {
echo " * Removing database table ".$CC_CONFIG['mdataTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['mdataTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['mdataTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['mdataTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
echo " * Removing database table ".$CC_CONFIG['filesTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['filesTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
}
if (camp_db_sequence_exists($CC_CONFIG['filesSequence'])) {
$sql = "DROP SEQUENCE ".$CC_CONFIG['filesSequence'];
camp_install_query($sql);
}
if (camp_db_table_exists($CC_CONFIG['accessTable'])) {
echo " * Removing database table ".$CC_CONFIG['accessTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['accessTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['accessTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['permTable'])) {
echo " * Removing database table ".$CC_CONFIG['permTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['permTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['permTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['permTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['sessTable'])) {
echo " * Removing database table ".$CC_CONFIG['sessTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['sessTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['sessTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['subjTable'])) {
echo " * Removing database table ".$CC_CONFIG['subjTable']."...";
$CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id_seq");
$sql = "DROP TABLE ".$CC_CONFIG['subjTable'];
camp_install_query($sql, false);
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['subjTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['smembTable'])) {
echo " * Removing database table ".$CC_CONFIG['smembTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['smembTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['smembTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['scheduleTable'])) {
echo " * Removing database table ".$CC_CONFIG['scheduleTable']."...";
camp_install_query("DROP TABLE ".$CC_CONFIG['scheduleTable']);
} else {
echo " * Skipping: database table ".$CC_CONFIG['scheduleTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['backupTable'])) {
echo " * Removing database table ".$CC_CONFIG['backupTable']."...";
camp_install_query("DROP TABLE ".$CC_CONFIG['backupTable']);
} else {
echo " * Skipping: database table ".$CC_CONFIG['backupTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['playlogTable'])) {
echo " * Removing database table ".$CC_CONFIG['playlogTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['playlogTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['playlogTable']."\n";
} }
echo "************************************\n"; echo "************************************\n";

View File

@ -1,101 +0,0 @@
<?php
/**
* @version $Revision: 2458 $
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
// 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;
}
if (camp_db_table_exists($CC_CONFIG['transTable'])) {
echo " * Removing database table ".$CC_CONFIG['transTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['transTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['transTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['mdataTable'])) {
echo " * Removing database table ".$CC_CONFIG['mdataTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['mdataTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['mdataTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['mdataTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
echo " * Removing database table ".$CC_CONFIG['filesTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['filesTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['accessTable'])) {
echo " * Removing database table ".$CC_CONFIG['accessTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['accessTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['accessTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['permTable'])) {
echo " * Removing database table ".$CC_CONFIG['permTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['permTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['permTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['permTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['sessTable'])) {
echo " * Removing database table ".$CC_CONFIG['sessTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['sessTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['sessTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['subjTable'])) {
echo " * Removing database table ".$CC_CONFIG['subjTable']."...";
$CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id_seq");
$sql = "DROP TABLE ".$CC_CONFIG['subjTable'];
camp_install_query($sql, false);
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['subjTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['smembTable'])) {
echo " * Removing database table ".$CC_CONFIG['smembTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['smembTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['smembTable']."\n";
}
?>

View File

@ -1,77 +0,0 @@
<?php
/**
* @package Campcaster
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
// 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;
}
function camp_uninstall_delete_files($p_path)
{
if (!empty($p_path) && (strlen($p_path) > 4)) {
list($dirList,$fileList) = File_Find::maptree($p_path);
foreach ($fileList as $filepath) {
echo " * Removing $filepath...";
@unlink($filepath);
echo "done.\n";
}
foreach ($dirList as $dirpath) {
echo " * Removing $dirpath...";
@rmdir($dirpath);
echo "done.\n";
}
}
}
if (!PEAR::isError($CC_DBC)) {
if (camp_db_table_exists($CC_CONFIG['prefTable'])) {
echo " * Removing database table ".$CC_CONFIG['prefTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['prefTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['prefTable']."\n";
}
}
//------------------------------------------------------------------------
// Uninstall Cron job
//------------------------------------------------------------------------
require_once(dirname(__FILE__).'/../cron/Cron.php');
$old_regex = '/transportCron\.php/';
echo " * Uninstall storageServer cron job...\n";
$cron = new Cron();
$access = $cron->openCrontab('write');
if ($access != 'write') {
do {
$r = $cron->forceWriteable();
} while ($r);
}
foreach ($cron->ct->getByType(CRON_CMD) as $id => $line) {
if (preg_match($old_regex, $line['command'])) {
echo " removing cron entry\n";
$cron->ct->delEntry($id);
}
}
$cron->closeCrontab();
echo "Done.\n";
camp_uninstall_delete_files($CC_CONFIG['storageDir']);
camp_uninstall_delete_files($CC_CONFIG['transDir']);
camp_uninstall_delete_files($CC_CONFIG['accessDir']);
?>

View File

@ -2742,7 +2742,7 @@ class XR_LocStor extends LocStor {
} }
require_once(dirname(__FILE__).'/../Prefs.php'); require_once(dirname(__FILE__).'/../Prefs.php');
$pr = new Prefs($this); $pr = new Prefs($this);
$res = $pr->loadGroupPref($r['sessid'], $r['group'], $r['key']); $res = $pr->loadGroupPref($r['group'], $r['key']);
if (PEAR::isError($res)) { if (PEAR::isError($res)) {
$ec0 = intval($res->getCode()); $ec0 = intval($res->getCode());
$ec = ( $ec = (
@ -3523,23 +3523,23 @@ class XR_LocStor extends LocStor {
* @return XML_RPC_Response * @return XML_RPC_Response
* @see LocStor::getAudioClip * @see LocStor::getAudioClip
*/ */
public function xr_resetStorage($input) // public function xr_resetStorage($input)
{ // {
list($ok, $r) = XR_LocStor::xr_getParams($input); // list($ok, $r) = XR_LocStor::xr_getParams($input);
if (!$ok) { // if (!$ok) {
return $r; // return $r;
} // }
$res = $this->resetStorage( // $res = $this->resetStorage(
isset($r['loadSampleData']) ? $r['loadSampleData'] : TRUE, // isset($r['loadSampleData']) ? $r['loadSampleData'] : TRUE,
!(isset($r['invalidateSessionIds']) ? $r['invalidateSessionIds'] : FALSE) // !(isset($r['invalidateSessionIds']) ? $r['invalidateSessionIds'] : FALSE)
); // );
if (PEAR::isError($res)) { // if (PEAR::isError($res)) {
return new XML_RPC_Response(0, 805, // return new XML_RPC_Response(0, 805,
"xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() // "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo()
); // );
} // }
return new XML_RPC_Response(XML_RPC_encode($res)); // return new XML_RPC_Response(XML_RPC_encode($res));
} // }
/** /**
* Test XMLRPC - strupper and return given string, * Test XMLRPC - strupper and return given string,

View File

@ -222,13 +222,13 @@ $mdefs = array(
'1320'=>'missing session ID argument', '1320'=>'missing session ID argument',
) )
), ),
"ResetStorageMethod" => array( // "ResetStorageMethod" => array(
'm'=>'resetStorage', // 'm'=>'resetStorage',
'p'=>array(), // 'p'=>array(),
't'=>array(), // 't'=>array(),
'r'=>array(), // 'r'=>array(),
'e'=>array('3001'=>'storage client reported an error'), // 'e'=>array('3001'=>'storage client reported an error'),
), // ),
"RevertEditedPlaylistMethod" => array( "RevertEditedPlaylistMethod" => array(
'm'=>'revertEditedPlaylist', 'm'=>'revertEditedPlaylist',
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/), 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),

View File

@ -88,7 +88,7 @@ $methods = array(
'accessRawAudioData' => 'Get access to raw audio data.', 'accessRawAudioData' => 'Get access to raw audio data.',
'releaseRawAudioData' => 'Release access to raw audio data.', 'releaseRawAudioData' => 'Release access to raw audio data.',
'getAudioClip' => 'Return the contents of an Audio clip.', 'getAudioClip' => 'Return the contents of an Audio clip.',
'resetStorage' => 'Reset storageServer for debugging.', // 'resetStorage' => 'Reset storageServer for debugging.',
'storeWebstream' => 'Store audio stream identified by URL', 'storeWebstream' => 'Store audio stream identified by URL',
'createPlaylist' => 'Create a new Playlist metafile.', 'createPlaylist' => 'Create a new Playlist metafile.',

View File

@ -109,8 +109,8 @@ $infos = array(
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'), 'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
"searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL), "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
"browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL), "browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL),
"resetStorage" => array('m'=>"locstor.resetStorage", // "resetStorage" => array('m'=>"locstor.resetStorage",
'p'=>array()), // 'p'=>array()),
# 'p'=>array('loadSampleData', 'invalidateSessionIds')), # 'p'=>array('loadSampleData', 'invalidateSessionIds')),
"storeWebstream" => array('m'=>"locstor.storeWebstream", "storeWebstream" => array('m'=>"locstor.storeWebstream",
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'), 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'),
@ -259,12 +259,12 @@ switch ($method) {
), ),
); );
break; break;
case "resetStorage": // case "resetStorage":
$parr = array( // $parr = array(
'loadSampleData'=>(boolean)$pars[0], // 'loadSampleData'=>(boolean)$pars[0],
'invalidateSessionIds'=>(boolean)$pars[1], // 'invalidateSessionIds'=>(boolean)$pars[1],
); // );
break; // break;
default: default:
$pinfo = $infos[$method]['p']; $pinfo = $infos[$method]['p'];
if (is_null($pinfo)) { if (is_null($pinfo)) {

View File

@ -99,9 +99,8 @@ $methodDefs = array(
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'), 'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
"searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL), "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
"browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL), "browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL),
"resetStorage" => array('m'=>"locstor.resetStorage", // "resetStorage" => array('m'=>"locstor.resetStorage",
'p'=>array()), // 'p'=>array()),
# 'p'=>array('loadSampleData', 'invalidateSessionIds')),
"storeWebstream" => array('m'=>"locstor.storeWebstream", "storeWebstream" => array('m'=>"locstor.storeWebstream",
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'), 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'),
'r'=>array('gunid') 'r'=>array('gunid')

View File

@ -84,16 +84,6 @@ case "$mode" in
$scheduler_exe -c $config_file status $scheduler_exe -c $config_file status
;; ;;
'install')
echo "Installing Campcaster scheduler database tables..."
BASE_DIR=$basedir php $vardir/install/install.php -c $config_file
;;
'uninstall')
echo "Uninstalling Campcaster scheduler database tables..."
BASE_DIR=$basedir php $vardir/install/uninstall.php -c $config_file
;;
'kill') 'kill')
echo "Killing all Campcaster scheduler processes..." echo "Killing all Campcaster scheduler processes..."
killall campcaster-scheduler killall campcaster-scheduler
@ -105,7 +95,7 @@ case "$mode" in
echo "Campcaster scheduler System V runlevel init script." echo "Campcaster scheduler System V runlevel init script."
echo "" echo ""
echo "Usage:" echo "Usage:"
echo " $0 start|stop|restart|status|install|uninstall|kill" echo " $0 start|stop|restart|status|kill"
echo "" echo ""
esac esac

View File

@ -100,16 +100,6 @@ case "$mode" in
$scheduler_exe -c $config_file status $scheduler_exe -c $config_file status
;; ;;
'install')
echo "Installing Campcaster scheduler database tables..."
BASE_DIR=$usrdir php $vardir/install/install.php -c $config_file
;;
'uninstall')
echo "Uninstalling Campcaster scheduler database tables..."
BASE_DIR=$usrdir php $vardir/install/uninstall.php -c $config_file
;;
'kill') 'kill')
echo "Killing all Campcaster scheduler processes..." echo "Killing all Campcaster scheduler processes..."
killall campcaster-scheduler killall campcaster-scheduler
@ -121,7 +111,7 @@ case "$mode" in
echo "Campcaster scheduler System V runlevel init script." echo "Campcaster scheduler System V runlevel init script."
echo "" echo ""
echo "Usage:" echo "Usage:"
echo " $0 start|run|stop|restart|status|install|uninstall|kill" echo " $0 start|run|stop|restart|status|kill"
echo "" echo ""
esac esac

View File

@ -343,7 +343,6 @@ copy_files:
${MAKE} -C ${EVENT_SCHEDULER_DIR} install ${MAKE} -C ${EVENT_SCHEDULER_DIR} install
${MKDIR} ${USR_BIN_DIR} ${MKDIR} ${USR_BIN_DIR}
${MKDIR} ${USR_ETC_DIR} ${MKDIR} ${USR_ETC_DIR}
${MKDIR} ${USR_VAR_DIR}/install
${MKDIR} ${USR_TMP_DIR} ${MKDIR} ${USR_TMP_DIR}
${CP} ${BIN_DIR}/campcaster-scheduler.sh ${USR_BIN_DIR} ${CP} ${BIN_DIR}/campcaster-scheduler.sh ${USR_BIN_DIR}
${CP} ${SCHEDULER_EXE} ${USR_BIN_DIR} ${CP} ${SCHEDULER_EXE} ${USR_BIN_DIR}
@ -357,7 +356,6 @@ copy_files:
${CAT} ${ETC_DIR}/campcaster-scheduler.xml.template \ ${CAT} ${ETC_DIR}/campcaster-scheduler.xml.template \
| ${SED} -e ${REPLACE_SED_STRING} \ | ${SED} -e ${REPLACE_SED_STRING} \
> ${USR_ETC_DIR}/campcaster-scheduler.xml > ${USR_ETC_DIR}/campcaster-scheduler.xml
${CP} ${VAR_DIR}/install/*.php ${USR_VAR_DIR}/install/
create_database: create_database:
ifeq (@CREATE_LS_DATABASE@,yes) ifeq (@CREATE_LS_DATABASE@,yes)
@ -373,20 +371,11 @@ ifeq (@CREATE_ODBC_DATA_SOURCE@,yes)
--dbserver=${DB_SERVER} --dbserver=${DB_SERVER}
endif endif
init_database:
ifeq (@INIT_LS_DATABASE@,yes)
${USR_BIN_DIR}/campcaster-scheduler.sh install
endif
check_local: all ${TEST_RUNNER} kill start_local run_tests stop_local check_local: all ${TEST_RUNNER} kill start_local run_tests stop_local
run_tests: ${TEST_RUNNER} run_tests: ${TEST_RUNNER}
${TEST_RUNNER_SH} -o ${TEST_RESULTS} -s ${TEST_XSLT} ${TEST_RUNNER_SH} -o ${TEST_RESULTS} -s ${TEST_XSLT}
init: ${SCHEDULER_EXE}
-${SCHEDULER_SH} install
start: ${SCHEDULER_EXE} start: ${SCHEDULER_EXE}
${SCHEDULER_SH} start ${SCHEDULER_SH} start
sleep 2 sleep 2
@ -401,12 +390,6 @@ stop: ${SCHEDULER_EXE}
status: ${SCHEDULER_EXE} status: ${SCHEDULER_EXE}
${SCHEDULER_SH} status ${SCHEDULER_SH} status
deinit: ${SCHEDULER_EXE}
-${SCHEDULER_SH} uninstall
init_local: ${SCHEDULER_EXE}
${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} install
start_local: ${SCHEDULER_EXE} start_local: ${SCHEDULER_EXE}
${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} start ${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} start
sleep 2 sleep 2
@ -422,9 +405,6 @@ run_local: ${SCHEDULER_EXE}
${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} --debug start ${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} --debug start
sleep 2 sleep 2
deinit_local: ${SCHEDULER_EXE}
${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} uninstall
storage_server_init: storage_server_init:
${MAKE} -C ${STORAGE_SERVER_DIR} ${MAKE} -C ${STORAGE_SERVER_DIR}

View File

@ -1,27 +0,0 @@
<?php
/**
* @package Campcaster
* @subpackage Scheduler
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
// 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);
}
$oldIncludePath = get_include_path();
$pearDir = getenv('BASE_DIR').'/lib/pear';
set_include_path($pearDir.PATH_SEPARATOR.$oldIncludePath);
require_once('installInit.php');
require_once('installScheduler.php');
echo " * Scheduler install complete\n";
?>

View File

@ -1,80 +0,0 @@
<?php
if (!function_exists('pg_connect')) {
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
exit(2);
}
require_once('DB.php');
function camp_db_table_exists($p_name)
{
global $CC_DBC;
$sql = "SELECT * FROM ".$p_name;
$result = $CC_DBC->GetOne($sql);
if (PEAR::isError($result)) {
return false;
}
return true;
}
function camp_install_query($sql)
{
global $CC_DBC;
$result = $CC_DBC->query($sql);
if (PEAR::isError($result)) {
echo "Error! ".$result->getMessage()."\n";
echo " SQL statement was:\n";
echo " ".$sql."\n\n";
} else {
echo "done.\n";
}
}
$options = getopt("c:");
if (!$options) {
echo "\nYou must specific the config file with -c.\n\n";
exit;
}
$configFile = $options['c'];
if (!file_exists($configFile)) {
echo "\nThe config file '$configFile' does not exist.\n\n";
exit;
}
echo " * Using config file $configFile\n";
$xml = file_get_contents($configFile);
$parser = xml_parser_create();
xml_parse_into_struct($parser, $xml, $vals, $index);
xml_parser_free($parser);
$CC_CONFIG['dsn'] = array('hostspec' => 'localhost',
'phptype' => 'pgsql');
// Get the user index
$userIndex = $index['SIMPLECONNECTIONMANAGER'][0];
$CC_CONFIG['dsn']['username'] = $vals[$userIndex]['attributes']['USERNAME'];
$CC_CONFIG['dsn']['password'] = $vals[$userIndex]['attributes']['PASSWORD'];
$CC_CONFIG['dsn']['database'] = $vals[$userIndex]['attributes']['DSN'];
$CC_CONFIG['playlogTable'] = 'playlog';
$CC_CONFIG['scheduleTable'] = 'schedule';
$CC_CONFIG['backupTable'] = 'backup';
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
if (PEAR::isError($CC_DBC)) {
echo $CC_DBC->getMessage()."\n";
echo $CC_DBC->getUserInfo()."\n";
echo "Database connection problem.\n";
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
" with corresponding permissions.\n";
exit(1);
} else {
echo " * Connected to database\n";
}
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
?>

View File

@ -1,51 +0,0 @@
<?php
// 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);
}
if (!camp_db_table_exists($CC_CONFIG['scheduleTable'])) {
echo " * Creating database table ".$CC_CONFIG['scheduleTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['scheduleTable']."("
." id BIGINT NOT NULL,"
." playlist BIGINT NOT NULL,"
." starts TIMESTAMP NOT NULL,"
." ends TIMESTAMP NOT NULL,"
." PRIMARY KEY(id))";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['scheduleTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['playlogTable'])) {
echo " * Creating database table ".$CC_CONFIG['playlogTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['playlogTable']."("
." id BIGINT NOT NULL,"
." audioClipId BIGINT NOT NULL,"
." timestamp TIMESTAMP NOT NULL,"
." PRIMARY KEY(id))";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['playlogTable']."\n";
}
if (!camp_db_table_exists($CC_CONFIG['backupTable'])) {
echo " * Creating database table ".$CC_CONFIG['backupTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['backupTable']." ("
." token VARCHAR(64) NOT NULL,"
." sessionId VARCHAR(64) NOT NULL,"
." status VARCHAR(32) NOT NULL,"
." fromTime TIMESTAMP NOT NULL,"
." toTime TIMESTAMP NOT NULL,"
." PRIMARY KEY(token))";
camp_install_query($sql);
} else {
echo " * Skipping: database table already exists: ".$CC_CONFIG['backupTable']."\n";
}
?>

View File

@ -1,24 +0,0 @@
<?php
/**
* @package Campcaster
* @subpackage Scheduler
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
*/
// 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;
}
require_once('installInit.php');
require_once('uninstallScheduler.php');
echo " * Scheduler uninstall complete\n";
?>

View File

@ -1,34 +0,0 @@
<?PHP
// 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;
}
if (camp_db_table_exists($CC_CONFIG['scheduleTable'])) {
echo " * Removing database table ".$CC_CONFIG['scheduleTable']."...";
camp_install_query("DROP TABLE ".$CC_CONFIG['scheduleTable']);
} else {
echo " * Skipping: database table ".$CC_CONFIG['scheduleTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['backupTable'])) {
echo " * Removing database table ".$CC_CONFIG['backupTable']."...";
camp_install_query("DROP TABLE ".$CC_CONFIG['backupTable']);
} else {
echo " * Skipping: database table ".$CC_CONFIG['backupTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['playlogTable'])) {
echo " * Removing database table ".$CC_CONFIG['playlogTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['playlogTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['playlogTable']."\n";
}
?>