示例#1
0
                $properties["dc:date"] = toW3CDate($prog->get('production_date'));
            }
            $rss_writer_object->additem($properties);
        }
    }
    // define search box
    $properties = array();
    // The name of the text input form field
    $properties["name"] = "pattern";
    $properties["link"] = $config['rootUrl'] . "/search.php?language=any_language&station={$stationName}";
    $properties["title"] = "Search for:";
    $properties["description"] = $page->getlocalizedWithParams('search_in_station', $stationName);
    $rss_writer_object->addtextinput($properties);
} elseif ($userName) {
    // user's saved query
    $userid = sotf_User::getUserid($userName);
    if (!$userid) {
        raiseError("no such user: {$userName}");
    }
    $user2 = new sotf_User($userid);
    $prefs2 = $user2->getPreferences();
    debug('saved queries', $prefs2->savedQueries);
    $query = $prefs2->getQuery($queryName);
    if (!$query) {
        raiseError("no such user query: {$userName}/{$queryName}");
    }
    // Define the properties of the channel.
    $properties = array();
    $properties["description"] = "Results of the StreamOnTheFly query {$userName}/{$queryName}";
    $properties["link"] = $config['rootUrl'] . "";
    $properties["title"] = "StreamOnTheFly query results";
 /** 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;
 }
示例#3
0
<?php

// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id: login.php,v 1.4 2003/09/25 07:46:12 andras Exp $
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Author: Martin Schmidt, ptmschmidt@fh-stpoelten.ac.at
 */
require "init.inc.php";
$username = sotf_Utils::getParameter('userid');
$email = sotf_Utils::getParameter('email');
$okURL = sotf_Utils::getParameter('okURL');
if ($username && $email) {
    $temp_user = new sotf_User();
    $storage = $temp_user->getStorageObject();
    $fields['userid'] = $temp_user->getUserid($username);
    if ($fields['userid'] != NULL) {
        $data = $storage->userDbSelect($fields);
    }
    if ($email == $data['email'] && $username == $data['username']) {
        $new_password = sotf_Utils::randString(6);
        global $page;
        $login_href = "http://" . $_SERVER['HTTP_HOST'] . $config['localPrefix'] . "/login.php";
        $subject = $page->getlocalized("pass_mail_subject");
        $message = $page->getlocalizedWithParams("pass_mail_message", $username, $new_password, $login_href);
        mail($email, $subject, $message, "From: no-reply@streamonthefly.org\r\nX-Mailer: PHP/" . phpversion() . "\r\nMIME-Version: 1.0\r\nContent-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n");
        $fields['password'] = $new_password;
        $fields['email'] = $email;
        $storage->userDbUpdate($fields);
    } else {
        $errorMsg = $page->getlocalized("new_pass_error");
示例#4
0
print '<DIV ALIGN="center"><BR />
	<INPUT type="submit" name="delete_topic" value="Delete vocabularies">
	<INPUT type="submit" name="create_topic" value="Create vocabularies (topic tree, genres, roles)">
	</DIV>';
PrintButton($id);
////////////////////////// Test 8
$id = 8;
if (RunTest($id, "Node administrator", 7)) {
    dbug("TEST 8");
    require_once "../init.inc.php";
    // this will most probably cause an error if the connector class is configured properly!
    $res = sotf_User::findUsers("a");
    $res = NULL;
    $adminId = $db->getOne("SELECT user_id FROM sotf_user_permissions WHERE object_id='node' AND permission_id='1'");
    if (!$adminId && $admin_name && $admin_pass) {
        if (!sotf_User::getUserid($admin_name)) {
            // let's register the new admin user
            $error = sotf_User::register($admin_pass, $admin_name, '', 'en', '');
        }
        if (!$error) {
            $error = sotf_User::login($admin_name, $admin_pass);
        }
        if ($error) {
            $install_test_result[$id] = "Invalid username or password";
            $install_color[$id] = $install_red;
            //trigger_error("Invalid username or password");
        } else {
            $aid = $user->id;
            $count = $db->getOne("SELECT count(*) FROM sotf_user_permissions WHERE user_id='{$aid}' AND object_id='node' AND permission_id='1'");
            if ($count == 0) {
                $db->query("INSERT INTO sotf_user_permissions (object_id, user_id, permission_id) VALUES('node',{$aid},1)");