function create($station, $track = '') { global $user; $prg = new sotf_Programme(); $prg->set('station', $station); $id = new sotf_Id($station, NULL, $track); $id->track = sotf_Programme::getNextTrackId($station, $id->date, $track); $prg->set('entry_date', $id->date); $prg->set('owner', $user->name); while (1) { $prg->set('track', $id->track); $prg->id = $id->toString(); if ($prg->save()) { // this will also create the required directories via setMetadataFile !! debug("created new programme", $prg->id); return $prg; } $id->track = sotf_Programme::getNextTrackId($station, $id->date, $id->track); } }
function getStreamInfo($streamData) { global $config, $db; if ($config['httpStreaming']) { // no stream info... return; } elseif ($config['tamburineURL']) { $rpc = new rpc_Utils(); //$rpc->debug = true; $response = $rpc->callTamburine('getpls', $streamData['pid']); if (is_null($response)) { logError("no reply from tamburine server"); } else { $offset = $response[2]; $filename = $response[2 + $offset]; //debug("response", $response); //debug("fname", $filename); } } elseif ($config['tamburineCMD']) { // streaming with tbrcmd $cmd = $config['tamburineCMD'] . " getpls " . $streamData['pid'] . " 2>&1"; exec($cmd, $output, $retval); debug("cmd", $cmd); //debug("output", $output); //debug("retval", $retval); foreach ($output as $line) { if (preg_match('/\\-\\>(\\/\\S+)\\s*$/', $line, $mm)) { $filename = $mm[1]; break; } } } if ($filename) { $prg = sotf_Programme::getPrgFromFilename($filename); if (is_object($prg)) { return array('name' => $prg->get('title'), 'url' => $config['localPrefix'] . "/get.php/" . $prg->id); } else { return array('name' => $prg); } } else { debug("Could not get stream info"); // TODO: stop stream! } }
} } //********* IMPORT ARRIVED XBMF $dirPath = $config['xbmfInDir']; $dir = dir($dirPath); while ($entry = $dir->read()) { if ($entry != "." && $entry != "..") { $currentFile = $dirPath . "/" . $entry; if (!is_dir($currentFile)) { $XBMF[] = basename($currentFile); } } } $dir->close(); foreach ($XBMF as $xbmfFile) { $id = sotf_Programme::importXBMF($config['xbmfInDir'] . "/{$xbmfFile}", $config['publishXbmf']); if ($id) { debug("CRON", "Imported new XBMF: {$xbmfFile}"); unlink($config['xbmfInDir'] . "/{$xbmfFile}"); } else { logger("CRON", "Import FAILED for XBMF: {$xbmfFile}"); } } //******** Expire old programmes // *** regenerate metadata files?? //******** Update topic counts //******** Clean caches adn tmp dirs // remove m3us and pngs from tmpdir // update subject tree language availability stopTiming(); $page->logRequest();
$page->errorURL = "showStation.php?stationid={$stationid}"; $page->setTitle($st->get('name')); // delete series $delseries = sotf_Utils::getParameter('delseries'); if ($delseries) { $seriesid = sotf_Utils::getParameter('seriesid'); $series = new sotf_Series($seriesid); $series->delete(); $page->redirect("showStation.php?stationid={$stationid}#series"); exit; } // delete prog $delprog = sotf_Utils::getParameter('delprog'); $prgid = sotf_Utils::getParameter('prgid'); if ($delprog) { $prg = new sotf_Programme($prgid); $prg->delete(); $page->redirect("showStation.php?stationid={$stationid}#progs"); exit; } // generate output $smarty->assign('STATION_ID', $stationid); $smarty->assign('STATION', $st->get('name')); $smarty->assign('STATION_DATA', $st->getAllWithIcon()); if ($st->isLocal()) { $smarty->assign('IS_LOCAL', 1); } $smarty->assign('ROLES', $st->getRoles()); if ($entered) { $smarty->assign('ENTERED', $entered); }
// check if user has default query $advsearch = new sotf_AdvSearch(); $prefs = $user->getPreferences(); $defQuery = $prefs->getDefaultQuery(); } // show default query or new programmes $maxItemsIndexPage = $sotfVars->get("maxItemsIndexPage", 10); if ($defQuery) { $smarty->assign("DEF_QUERY", 1); debug("default query", $defQuery); $advsearch->Deserialize($defQuery); $query = $advsearch->GetSQLCommand(); debug("query", $query); //get the number of results $max = $db->getOne("SELECT count(*) FROM ( {$query} ) as foo "); $smarty->assign("DEF_QUERY_MAX", $max); $res = $db->limitQuery($query, 0, $maxItemsIndexPage); $hits = ''; while (DB_OK === $res->fetchInto($row)) { $row['icon'] = sotf_Blob::cacheIcon2($row); $hits[] = $row; } $smarty->assign("NEWS", $hits); } else { // get new programmes $smarty->assign('NEWS', sotf_Programme::getNewProgrammes($fromDay, $maxItemsIndexPage)); } // get topics with most content $smarty->assign('TOPICS', $vocabularies->getTopTopics(5)); $db->commit(); $page->send();
} else { print "<script type=\"text/javascript\" language=\"javascript1.1\">error();</script>"; } $x->update(); print "success"; } elseif ($name == "caption") { $x = new sotf_NodeObject("sotf_other_files", $id); $x->set('caption', addslashes($value)); $x->update(); print "success"; } elseif ($name == "addtree") { $vocabularies->addToTopic($id, $value); // doesnt work: print("<script type=\"text/javascript\">window.opener.opener.reload();</script>"); print "success"; } elseif ($name == "editorpub") { $x = new sotf_Programme($id); if ($value == 'true') { $x->publish(); } elseif ($value == 'false') { $x->withdraw(); } else { print "<script type=\"text/javascript\" language=\"javascript1.1\">error();</script>"; } print "success"; } elseif ($name == "editorflag") { $x = new sotf_Object("sotf_user_progs"); $x->set('user_id', $user->id); $x->set('prog_id', $id); $x->find(); $x->set('flags', $value); if ($x->id) {
if(is_array(NULL)) print "ARRAY IS NULL"; $k = ''; $k= 0; if(empty($k)) print("empty"); else print("not"); */ //$prog = new sotf_Programme('001pr4'); //$prog->setBlob('icon', $prog->get('icon')); //echo "Icon saved"; $ids = $db->getCol("select id from sotf_programmes"); while (list(, $id) = each($ids)) { $obj = new sotf_Programme($id); $icon = $obj->getBlob('icon'); $obj->saveBlob('icon', $icon); echo "<br>icon saved for {$id}"; } $ids = $db->getCol("select id from sotf_stations"); while (list(, $id) = each($ids)) { $obj = new sotf_Station($id); $icon = $obj->getBlob('icon'); $obj->saveBlob('icon', $icon); echo "<br>icon saved for {$id}"; } $ids = $db->getCol("select id from sotf_series"); while (list(, $id) = each($ids)) { $obj = new sotf_Series($id); $icon = $obj->getBlob('icon');
* Authors: András Micsik, Máté Pataki, Tamás Déri * at MTA SZTAKI DSD, http://dsd.sztaki.hu * Update Topic Tree by Martin Schmidt, FH St. Poelten */ require "init.inc.php"; // may contain long jobs set_time_limit(300); $smarty->assign('PAGETITLE', $page->getlocalized('AdminPage')); $page->forceLogin(); //$page->errorURL = "admin.php"; checkPerm('node', 'change', 'authorize'); // import XBMF $xbmfFile = sotf_Utils::getParameter('import_xbmf'); if ($xbmfFile) { $file = $config['xbmfInDir'] . "/{$xbmfFile}"; $id = sotf_Programme::importXBMF($file, $config['publishXbmf'], true); if ($id) { echo "Import succesful: <a target=\"_opener\" href=\"editMeta.php?id={$id}\">click here</a>"; unlink($file); } else { echo "Import failed"; } $page->logRequest(); exit; } // update CVS if (sotf_Utils::getParameter('updatecvs')) { die("doesn't work this way, sorry"); checkPerm('node', 'change'); chdir($config['basedir']); header("Content-type: text/plain\n");
$file = $user->getUserDir() . '/' . $fname; moveUploadedFile('userfile', $file); $prg = new sotf_Programme($prgId); if ($main) { $prg->setAudio($file); $page->redirect("closeAndRefresh.php"); } else { $prg->setOtherFile($file); $page->redirect("closeAndRefresh.php#anchor=mfiles"); } exit; } // add files if ($add) { $copy = sotf_Utils::getParameter('copy'); $prg = new sotf_Programme($prgId); reset($_POST); while (list($k, $fname) = each($_POST)) { debug("P", $k); if (substr($k, 0, 4) == 'sel_') { $file = sotf_Utils::getFileInDir($user->getUserDir(), $fname); if ($main) { debug("setAudio", "'{$fname}', '{$copy}'"); $prg->setAudio($file, $copy); } else { debug("setOtherFile", "'{$fname}', '{$copy}'"); $prg->setOtherFile($file, $copy); } } } if ($main) {
$data['numStations'] = sotf_Station::countAll(); $data['numAudioProgs'] = sotf_Programme::countAll('sound'); //MOD BY Martin Schmidt $data['numVideoProgs'] = sotf_Programme::countAll('video'); //MOD BY Martin Schmidt $allStats = sotf_Statistics::networkStats(); $allStats['l_and_d'] = $allStats['listens'] + $allStats['downloads']; $data['access'] = $allStats; $audioFileStats = sotf_Programme::getFileStats('sound'); //MOD BY Martin Schmidt $audioFileStats['size_mb'] = sprintf('%d', $audioFileStats['filesize'] / 1024 / 1024); //MOD BY Martin Schmidt $audioFileStats['length_hour'] = sprintf('%d', $audioFileStats['play_length'] / 60 / 60); //MOD BY Martin Schmidt //ADDED BY Martin Schmidt $videoFileStats = sotf_Programme::getFileStats('video'); $videoFileStats['size_mb'] = sprintf('%d', $videoFileStats['filesize'] / 1024 / 1024); $videoFileStats['length_hour'] = sprintf('%d', $videoFileStats['play_length'] / 60 / 60); ///////////////////////// $data['audioFiles'] = $audioFileStats; $data['videoFiles'] = $videoFileStats; $data['allFiles']['size_mb'] = $videoFileStats['size_mb'] + $audioFileStats['size_mb']; $data['allFiles']['length_hour'] = $videoFileStats['length_hour'] + $audioFileStats['length_hour']; $data['numAllProgs'] = $data['numAudioProgs'] + $data['numVideoProgs']; $data['numUsers'] = sotf_User::countUsers(); $smarty->assign($data); // end $data assignements // STATIONS assignement $smarty->assign('STATIONS', sotf_Station::listStationNames()); // search languages assignements for searchbox $searchLangs = $config['languages'];
if (sotf_Utils::getParameter('addprog')) { $fname = sotf_Utils::getFileSafeParameter('fname'); $station = sotf_Utils::getFileSafeParameter('station'); if (!sotf_Permission::get('upload', $station)) { raiseError("no permission to upload to {$station}"); exit; } $newPrg = sotf_Programme::create($station); $newPrg->setAudio($fname); //$page->redirect("editFiles.php"); $page->redirect($_SERVER['SCRIPT_NAME']); exit; } $userFtpUrl = str_replace('ftp://', "ftp://{$userid}@", "{$userFTP}{$userid}"); $smarty->assign("USERFTPURL", $userFtpUrl); $stations = sotf_Permission::listStationsWithPermission('upload'); if (!empty($stations)) { $smarty->assign_by_ref("STATIONS", $stations); } $userAudioFiles = new sotf_FileList(); $userAudioFiles->getAudioFromDir($user->getUserDir()); $list = $userAudioFiles->getFileNames(); if (!empty($list)) { $smarty->assign_by_ref("USER_AUDIO_FILES", $list); } $myProgs = sotf_Programme::myProgrammes($user->name); $plist = new sotf_PrgList($myProgs); // todo sort/filter using sotf_PrgList $l = $plist->getList(); $smarty->assign_by_ref("MYPROGS", $l); $page->send();
<?php require "init.inc.php"; if ($_REQUEST['select_station']) { $page->redirect("listStation.php?station=" . $_POST['station']); } /* defaults for main "index" page */ define("MAX_ITEMS_IN_INDEX", 10); $data['numNodes'] = sotf_Node::numNodes(); if ($data['numNodes'] == 0) { $data['numNodes'] = 1; } $data['numStations'] = sotf_Station::numStations(); $data['numProgs'] = sotf_Programme::numProgrammes(); $smarty->assign($data); $smarty->assign('STATIONS', sotf_Station::listStationNames()); $searchLangs = $languages; array_unshift($searchLangs, "any_language"); for ($i = 0; $i < count($searchLangs); $i++) { $langNames[$i] = $page->getlocalized($searchLangs[$i]); } $smarty->assign('searchLangs', $searchLangs); $smarty->assign('langNames', $langNames); $now = getDate(); $yesterday = mktime(0, 0, 0, $now['mon'], $now['mday'] - 2, $now['year']); $fromDay = date('Y-m-d', $yesterday); $smarty->assign(array('LOCAL_NEWS' => sotf_Programme::getNewProgrammes(true, $fromDay, MAX_ITEMS_IN_INDEX), 'OTHER_NEWS' => sotf_Programme::getNewProgrammes(false, $fromDay, MAX_ITEMS_IN_INDEX))); $page->send();
$playlist = new sotf_Playlist(); $smarty->assign('PLAYLIST', $playlist->load()); // check if user has default query $advsearch = new sotf_AdvSearch(); $prefs = $user->getPreferences(); $defQuery = $prefs->getDefaultQuery(); } // show default query instead of new programmes if ($defQuery) { $smarty->assign("DEF_QUERY", 1); debug("default query", $defQuery); $advsearch->Deserialize($defQuery); $query = $advsearch->GetSQLCommand(); debug("query", $query); //get the number of results $max = $db->getOne("SELECT count(*) FROM ( {$query} ) as foo "); $smarty->assign("DEF_QUERY_MAX", $max); $res = $db->limitQuery($query, 0, MAX_ITEMS_IN_INDEX); $hits = ''; while (DB_OK === $res->fetchInto($row)) { $row['icon'] = sotf_Blob::cacheIcon($row['id']); $hits[] = $row; } $smarty->assign("NEWS", $hits); } else { // get new programmes $smarty->assign('NEWS', sotf_Programme::getNewProgrammes($fromDay, MAX_ITEMS_IN_INDEX)); } // get topics with most content $smarty->assign('TOPICS', $repository->getTopTopics(5)); $page->send();
$properties["description"] = "New programmes at StreamOnTheFly"; $properties["link"] = $config['rootUrl'] . ""; $properties["title"] = "StreamOnTheFly"; //$properties["language"]="en"; $properties["dc:date"] = date("Y-m-d H:i:s"); // "2002-05-06T00:00:00Z"; $rss_writer_object->addchannel($properties); // If your channel has a logo, before adding any channel items, specify the logo details this way. $properties = array(); $properties["url"] = $config['rootUrl'] . "/static/sotflogosmall.gif"; $properties["link"] = $config['rootUrl'] . ""; $properties["title"] = "StreamOnTheFly logo"; $properties["description"] = "World wide network of radio archives"; $rss_writer_object->addimage($properties); // Then add your channel items one by one. $newProgs = sotf_Programme::getNewProgrammes($fromDay, ITEMS_IN_RSS); foreach ($newProgs as $prog) { $properties = array(); $properties["description"] = $prog['abstract']; $properties["link"] = $config['rootUrl'] . "/get.php?id=" . $prog['id']; $properties["title"] = $prog['title']; $properties["dc:date"] = $prog['production_date']; $rss_writer_object->additem($properties); } // If your channel has a search page, after adding the channel items, specify a search form details this way. $properties = array(); // The name property if the name of the text input form field $properties["name"] = "pattern"; $properties["link"] = $config['rootUrl'] . "/search.php?language=any_language"; $properties["title"] = "Search for:"; $properties["description"] = "Search in StreamOnTheFly";
$properties = array(); $properties["description"] = "New programmes at StreamOnTheFly"; $properties["link"] = $config['rootUrl'] . ""; $properties["title"] = "StreamOnTheFly"; //$properties["language"]="en"; $properties["dc:date"] = getW3CDate(); $rss_writer_object->addchannel($properties); // If your channel has a logo, before adding any channel items, specify the logo details this way. $properties = array(); $properties["url"] = $config['rootUrl'] . "/static/sotflogosmall.gif"; $properties["link"] = $config['rootUrl'] . ""; $properties["title"] = "StreamOnTheFly logo"; $properties["description"] = "World wide network of radio archives"; $rss_writer_object->addimage($properties); // Then add your channel items one by one. $newProgs = sotf_Programme::getNewProgrammes($fromDay, $count); if (!empty($newProgs)) { foreach ($newProgs as $prog) { $properties = array(); $properties["description"] = $prog['abstract']; $properties["link"] = $config['rootUrl'] . "/get.php?id=" . $prog['id']; $properties["title"] = $prog['title']; $properties["dc:date"] = $prog['production_date']; $rss_writer_object->additem($properties); } } else { $properties = array(); $properties["description"] = ''; $properties["link"] = $config['rootUrl']; $properties["title"] = "no new items"; //$properties["dc:date"]= ;
/** static: import a programme from the given XBMF archive */ function importXBMF($fileName, $publish = false, $console = false) { global $db, $config, $permissions, $repository, $vocabularies; $pathToFile = $config['xbmfInDir'] . '/'; // create temp folder with unique name $folderName = uniqid("xbmf"); if (!mkdir($pathToFile . $folderName)) { logError("Could not create dir for XBMF", $pathToFile . $folderName); return false; } // untar contents of file to folder $tar = new Archive_Tar($fileName, true); // create archive handler $tar->setErrorHandling(PEAR_ERROR_PRINT); // enable error reporting $result = $tar->extract($pathToFile . $folderName); // untar contents debug("untar result", $result); //parse the xml file $metaFile = $pathToFile . $folderName . "/XBMF/Metadata.xml"; if (!is_file($metaFile)) { $metaFile = $pathToFile . $folderName . "/XBMF/metadata.xml"; if (!is_file($metaFile)) { logError("no metadata file found in XBMF!", $folderName); return false; } } $myPack = new unpackXML($metaFile); if (!$myPack->error) { //if the file has been found $metadata = $myPack->process(); } if (!$metadata or $myPack->error) { //errors during import - stop execution sotf_Utils::delete($pathToFile . $folderName); echo "<font color=#FF0000><b>The import of {$fileName} did not succeed!</b></font>"; logError("XML processing failed within this XBMF", $folderName); return false; //did not succeed } else { /* echo "Came In: " . $myPack->encoding . "<br>"; echo "Went Out: " . $myPack->outencoding . "<br>"; echo "<pre>"; print_r($metadata); echo "</pre>"; */ dump($metadata, "METADATA"); debug("METADATA", $metadata); } $db->begin(); // Select station $stId = trim($metadata['stationid']); if (is_numeric($stId)) { $stId = $newPrg->makeId($config['nodeId'], 'sotf_stations', (int) $stId); } $station =& $repository->getObject($stId); if (!$station) { logError("invalid stationid: " . $metadata['stationid']); return false; // by default I put the programme into the first station //$stId = $db->getOne("SELECT id FROM sotf_stations ORDER BY id"); //$station = &$repository->getObject($stId); } // select/create programme entry if ($metadata['identifier']) { $prgId = sotf_Programme::getMapping($station->id, $metadata['identifier'], 'prg'); } if ($prgId) { // updating an exisiting programme debug("updating existing programme", $prgId); $newPrg = new sotf_Programme($prgId); if ($station->id != $newPrg->get('station_id')) { logError("station provided in metadata is different from the station saved previously!"); return false; } //$station = &$repository->getObject($newPrg->get('station_id')); $updatingPrg = 1; } else { // a new programme $newPrg = new sotf_Programme(); $track = $metadata['title']; debug("create new programme with track", $track); $newPrg->create($station->id, $track); sotf_Programme::addMapping($station->id, $metadata['identifier'], 'prg', $newPrg->id); } $newPrg->set('foreign_id', $metadata['identifier']); // select/create series if ($metadata['series'] && $metadata['series']['id']) { $seriesId = sotf_Programme::getMapping($station->id, $metadata['series']['id'], 'series'); if (!$seriesId) { $series1 = new sotf_Series(); $series1->set('name', $metadata['series']['title']); $series1->set('station_id', $station->id); $series1->find(); if ($series1->exists()) { $seriesId = $series1->id; } } if ($seriesId) { $newPrg->set('series_id', $seriesId); $series =& $repository->getObject($seriesId); } else { $newSeries = 1; $series = new sotf_Series(); $series->set('station_id', $station->id); } $series->set('name', $metadata['series']['title']); $series->set('description', $metadata['series']['description']); if ($series->exists()) { $series->update(); } else { $series->create(); sotf_Programme::addMapping($station->id, $metadata['series']['id'], 'series', $series->id); } } // permissions foreach (array($metadata['owner'], $metadata['publishedby']) as $foreignUser) { if (is_array($foreignUser)) { $userId = sotf_User::getUserid($foreignUser['login']); debug("owner/publisher", $foreignUser); if ($userId) { if ($permissions->hasPermission($station->id, 'admin', $userId) || $series && $permissions->hasPermission($series->id, 'create', $userId)) { // add permission for user $permissions->addPermission($newPrg->id, $userId, 'admin'); $admins[] = $userId; } } } } // if we did not get permission info, add permissions for all station/series admins debug("admins2", $admins); if (empty($admins)) { if ($series) { $admins1 = $permissions->listUsersWithPermission($series->id, 'admin'); } if (!$admins1) { $admins1 = $permissions->listUsersWithPermission($station->id, 'admin'); } while (list(, $admin) = each($admins1)) { $admins[] = $admin['id']; $permissions->addPermission($newPrg->id, $admin['id'], 'admin'); } } debug("admins3", $admins); // now create permissions while (list(, $adminId) = each($admins)) { $permissions->addPermission($newPrg->id, $adminId, 'admin'); if ($newSeries) { $permissions->addPermission($series->id, $adminId, 'admin'); } } /* * PART 2.2 - Insert all the relevant data from the xml file into the database */ // basic metadata $newPrg->set('title', sotf_Programme::normalizeText($metadata['title'], 255)); $newPrg->set('alternative_title', sotf_Programme::normalizeText($metadata['alternative'], 255)); $newPrg->set('episode_sequence', 0); if (!empty($metadata['episodesequence'])) { $epiSeq = sotf_Programme::normalizeText($metadata['episodesequence']); if (is_numeric($epiSeq)) { $newPrg->set('episode_sequence', (int) $epiSeq); } else { logError("Bad episode sequence: " . $metadata['episodesequence']); } } $newPrg->set('abstract', sotf_Programme::normalizeText($metadata['description'])); $newPrg->set('keywords', sotf_Programme::normalizeText($metadata['keywords'])); $newPrg->set("production_date", date('Y-m-d', strtotime($metadata['created']))); $newPrg->set("broadcast_date", date('Y-m-d', strtotime($metadata['issued']))); $newPrg->set("modify_date", date('Y-m-d', strtotime($metadata['modified']))); $newPrg->set('language', $metadata['language']); if ($metadata['language'] == 'ger') { $newPrg->set('language', 'deu'); } if ($metadata['language'] == 'English') { $newPrg->set('language', 'eng'); } $newPrg->update(); // topic if ($metadata['topic']) { $vocabularies->addToTopic($newPrg->id, $metadata['topic']); } // genre $genre = trim($metadata['genre']); if (is_numeric($genre)) { $newPrg->set('genre_id', $genre); } else { logError("invalid genre id: " . $genre); } // rights $rights = new sotf_NodeObject("sotf_rights"); $rights->set('prog_id', $newPrg->id); $rights->set('rights_text', $metadata['rights']); $rights->find(); $rights->save(); $db->commit(); // contacts //$role = 21; // Other foreach ($metadata['publisher'] as $contact) { $role = 23; // Publisher $id = sotf_Programme::importContact($contact, $role, $newPrg->id, $station->id, $admins); } foreach ($metadata['creator'] as $contact) { $role = 22; // Creator $id = sotf_Programme::importContact($contact, $role, $newPrg->id, $station->id, $admins); } if (is_array($metadata['contributor'])) { foreach ($metadata['contributor'] as $contact) { $role = 24; // Contributor $id = sotf_Programme::importContact($contact, $role, $newPrg->id, $station->id, $admins); } } /* * PART 2.1 - Move the audio data to the specified station folder */ // insert audio $dirPath = $pathToFile . $folderName . "/XBMF/audio"; $dir = dir($dirPath); while ($entry = $dir->read()) { if ($entry != "." && $entry != "..") { $currentFile = $dirPath . "/" . $entry; if (!is_dir($currentFile)) { if (is_file($currentFile)) { debug("insert audio", $currentFile); $newPrg->setAudio($currentFile, true); } } } } $dir->close(); // insert other files $dirPath = $pathToFile . $folderName . "/XBMF/files"; $dir = dir($dirPath); while ($entry = $dir->read()) { if ($entry != "." && $entry != "..") { $currentFile = $dirPath . "/" . $entry; if (!is_dir($currentFile)) { $id = $newPrg->setOtherFile($currentFile, true); debug("insert other", $currentFile); /* by default, no need for this if($id) { $fileInfo = &$repository->getObject($id); $fileInfo->set('public_access', 't'); $fileInfo->update(); } */ } } } $dir->close(); // insert metadata if (is_readable($metaFile)) { debug("insert meta", $metaFile); $target1 = $newPrg->getMetaDir() . '/metadata.xml'; $target2 = $newPrg->getMetaDir() . '/metadata-in.xml'; if (!copy($metaFile, $target1)) { logError("Could not copy metadata into {$target1}"); } if (!copy($metaFile, $target2)) { logError("Could not copy metadata into {$target2}"); } } // insert icon $logoFile = $pathToFile . $folderName . "/icon.png"; if (is_readable($logoFile)) { debug("insert icon", $logoFile); $newPrg->setIcon($logoFile); } // convert missing formats! $audioFiles =& new sotf_FileList(); $audioFiles->getAudioFromDir($newPrg->getAudioDir()); $checker =& new sotf_AudioCheck($audioFiles); $checker->console = $console; // if we don't want progress bars $targets = $checker->convertAll($newPrg->id); if (is_array($targets)) { foreach ($targets as $target) { $newPrg->setAudio($target); } } /* * PART 2.3 - Remove (unlink) the xbmf file and the temp dir */ //publish if needed if ($publish) { $newPrg->publish(); } sotf_Utils::delete($pathToFile . $folderName); //unlink($fileName); return $newPrg->id; }
raiseError("You have no permission to upload to any station"); exit; } // delete prog if (sotf_Utils::getParameter('delprog')) { $prgid = sotf_Utils::getParameter('prgid'); $prg = new sotf_Programme($prgid); $prg->delete(); $page->redirect("editor.php"); exit; } if (sotf_Utils::getParameter('addprog')) { $fname = sotf_Utils::getParameter('fname'); $station = sotf_Utils::getParameter('station'); checkPerm($station, 'add_prog'); $newPrg = new sotf_Programme(); $track = preg_replace('/\\.[^.]*$/', '', $fname); debug("create with track", $track); $newPrg->create($station, $track); $newPrg->setAudio($user->getUserDir() . '/' . $fname); $permissions->addPermission($newPrg->id, $user->id, 'admin'); //$page->redirect("editFiles.php"); $page->redirect("editFiles.php?new=1&id=" . $newPrg->getID()); exit; } $stationId = sotf_Utils::getParameter('stationid'); if ($stationId) { $smarty->assign('SELECTED_STATION', $stationId); } $userFtpUrl = str_replace('ftp://', "ftp://{$user->name}@", $config['userFTP']); $smarty->assign("USERFTPURL", $userFtpUrl);
while (DB_OK === $res->fetchInto($row)) { $row['icon'] = sotf_Blob::cacheIcon2($row); $hits[] = $row; } $smarty->assign("NEWS", $hits); } else { // get new programmes if (nodeConfig('payableMode')) { $mode = 'free'; } else { $mode = 'all'; } $smarty->assign('NEWS', sotf_Programme::getNewProgrammes($fromDay, $maxItemsIndexPage, $mode)); } if (nodeConfig('payableMode')) { $fromDayPremium = date('Y-m-d', time() - 60 * 60 * 24 * 90); $maxItemsPremium = 7; $smarty->assign('PREMIUM', sotf_Programme::getNewProgrammes($fromDayPremium, $maxItemsPremium, 'premium')); $smarty->assign('PROMOTED', sotf_Programme::getPromotedProgrammes()); } // get topics with most content $smarty->assign('TOPICS', $vocabularies->getTopTopics(5)); // online counter for statistics if ($config['counterMode']) { $chCounter_status = 'active'; $chCounter_visible = 0; $chCounter_page_title = 'Hauptseite - index.php'; include $config['counterURL']; } $db->commit(); $page->send();
$file = sotf_Utils::getFileInDir($user->getUserDir(), $fname); move_uploaded_file($_FILES['userfile']['tmp_name'], $file); $prg = new sotf_Programme($prgId); if ($main) { $prg->setAudio($file); $page->redirect("closeAndRefresh.php"); } else { $prg->setOtherFile($fname); $page->redirect("closeAndRefresh.php#anchor=mfiles"); } exit; } // add files if ($add) { $copy = sotf_Utils::getParameter('copy'); $prg = new sotf_Programme($prgId); reset($_POST); while (list($k, $fname) = each($_POST)) { debug("P", $k); if (substr($k, 0, 4) == 'sel_') { if ($main) { debug("setAudio", "'{$fname}', '{$copy}'"); $prg->setAudio($user->getUserDir() . '/' . $fname, $copy); } else { debug("setOtherFile", "'{$fname}', '{$copy}'"); $prg->setOtherFile($fname, $copy); } } } if ($main) { $page->redirect("closeAndRefresh.php");
<?php require "init.inc.php"; $id = sotf_Utils::getParameter('id'); $fileid = sotf_Utils::getParameter('fileid'); if (empty($id)) { raiseError("Missing parameters!"); } $prg = new sotf_Programme($id); if (empty($fileid)) { // find a file to listen $fileid = $prg->selectFileToListen(); if (!$fileid) { raiseError("no_file_to_listen"); } } $file = new sotf_NodeObject("sotf_media_files", $fileid); if (!$prg->isLocal()) { raiseError("Currently you can listen only to programmes of local stations"); } if ($prg->get('published') != 't' || $file->get('stream_access') != 't') { raiseError("no_listen_access"); } $filepath = $prg->getFilePath($file); $tmpfile = $tmpdir . "/{$id_}{$fileid}.m3u"; //$name = "$id_$fileid"; $name = "{$id_}" . time(); $url = 'http://' . $iceServer . ':' . $icePort . '/' . $name . "\n"; debug("file", $filepath); if (!is_file($filepath)) { raiseError("no_such_file");