/** static, this places the icon into the www/tmp, so that you can refer to
     it with <img src=, returns true if there is an icon for this object */
 function cacheIcon($id)
 {
     global $cachedir;
     $cacheTimeout = 2 * 60;
     // 2 minutes
     if (!$id) {
         raiseError("missing id");
     }
     $fname = "{$cachedir}/" . $id . '.png';
     if (is_readable($fname)) {
         $stat = stat($fname);
         if (time() - $stat['mtime'] <= $cacheTimeout) {
             return true;
         }
     }
     $icon = sotf_Blob::findBlob($id, 'icon');
     if (!$icon) {
         return false;
     }
     // TODO: cache cleanup!
     ////debug("cache: ". filesize($fname) ."==" . strlen($icon));
     if (is_readable($fname) && filesize($fname) == strlen($icon)) {
         return true;
     }
     debug("cached icon for", $id);
     sotf_Utils::save($fname, $icon);
     return true;
 }
 /** static */
 function findByName($name)
 {
     global $db;
     $name = sotf_Utils::magicQuotes($name);
     $res = $db->getOne("SELECT id FROM sotf_contacts WHERE name='{$name}'");
     // what happens when there are 2 matches? but name field is unique...
     return $res;
 }
 /** static */
 function findByName($name)
 {
     global $db, $config;
     $name = sotf_Utils::magicQuotes($name);
     // first find the local contact, then any other...
     //$id = sotf_Contact::findByNameLocal($name);
     //if(!$id)
     $id = $db->getOne("SELECT id FROM sotf_contacts WHERE name='{$name}'");
     // what happens when there are 2 matches? returns first match...
     return $id;
 }
 function save()
 {
     global $db, $user;
     $data = serialize($this);
     $count = $db->getOne("SELECT count(*) FROM sotf_user_prefs WHERE id = '{$this->id}'");
     if ($count == 1) {
         $db->query("UPDATE sotf_user_prefs SET prefs='{$data}' WHERE id = '{$this->id}'");
     } else {
         $name = sotf_Utils::magicQuotes($user->name);
         $db->query("INSERT INTO sotf_user_prefs (id, username, prefs) VALUES('{$user->id}','{$name}','{$data}')");
     }
 }
 /**
  * sotfShow::delete()
  *
  * purpose: to delete data from the tables
  *
  * @return (bool)
  */
 function delete()
 {
     if (!$this->isLocal()) {
         error("Can delete only local stations");
         return false;
     }
     // delete files from the repository
     sotf_Utils::erase($this->getDir());
     // delete programmes of the station
     // TODO getallprogrammes: call delete
     // delete user permissions
     $this->db->query("DELETE FROM sotf_user_group WHERE station = '" . $this->id . "'");
     // propagate deletion to other nodes
     $data = array('what' => 'station', 'del_time' => db_Wrap::getTimestampTZ(), 'node' => $GLOBALS['nodeId']);
     sotf_Base::saveDataWithId("sotf_deletions", 'id', $this->id, $data);
     // delete station description
     return parent::delete("sotf_stations", "station");
 }
 /** Sets the value of a persistent variable. */
 function set($name, $val)
 {
     $name = sotf_Utils::magicQuotes($name);
     $val = sotf_Utils::magicQuotes($val);
     if (isset($this->vars[$name])) {
         $update = 1;
     }
     $this->vars[$name] = $val;
     if ($update) {
         $result = $this->db->query("UPDATE {$this->table} SET value='{$val}' WHERE name='{$name}'");
     } else {
         $result = $this->db->query("INSERT INTO {$this->table} (name,value) VALUES('{$name}', '{$val}')");
     }
     if (DB::isError($result)) {
         raiseError($result);
     }
     debug("setvar", "{$name}={$val}");
 }
 function getUsername($user_id)
 {
     global $userdb;
     static $userNameCache;
     $storage =& sotf_User::getStorageObject();
     if (is_numeric($user_id)) {
         if ($userNameCache[$user_id]) {
             return $userNameCache[$user_id];
         }
         $data = $storage->userDbSelect(array('userid' => sotf_Utils::magicQuotes($user_id)));
         if (!$data) {
             return false;
         }
         $name = $data['username'];
         $userNameCache[$user_id] = $name;
         return $name;
     }
     return false;
 }
Exemple #8
0
    $_SESSION['error'] = $error;
    //needed after reload
    $page->redirect($_SERVER["PHP_SELF"] . "?" . $subpage . "=2");
    //redirect page
}
////SMARTY variables
$smarty->assign("table", $portal->getTable());
//current layout table
//user rights and options
$smarty->assign("is_admin", $portal->isAdmin($user->getId()));
//true if admin
$smarty->assign("is_logged_in", $user->loggedIn());
//true if logged in
$smarty->assign("username", $user->getName());
//username (if logged in)
$smarty->assign("back", sotf_Utils::getParameter('back'));
//true if came from programmes editor page to the view programme page
//directories and names
$smarty->assign("rootdir", $rootdir);
//root directory (portal/www)
$smarty->assign("php_self", $_SERVER['PHP_SELF']);
//php self for the form submit and hrefs
$smarty->assign("portal_name", $portal_name);
//name of the portal
$smarty->assign("sotfSite", $sotfSite);
//location of the StreamontheFly portal
$smarty->assign("portal", $settings["portal"]);
$smarty->assign("home", $settings["home"]);
$smarty->assign("programmes", $settings["programmes"]);
$smarty->assign("css", $settings["css"]);
//CSS enabled
Exemple #9
0
    if ($entry != "." && $entry != "..") {
        $currentFile = $dirPath . "/" . $entry;
        //debug("examining", $currentFile);
        if (!is_dir($currentFile)) {
            $XBMF[] = basename($currentFile);
        }
    }
}
$dir->close();
$smarty->assign("XBMF", $XBMF);
// UPDATE Topic Tree ADDED BY Martin Schmidt, FH St. Poelten
if (sotf_Utils::getParameter('updatetopictree')) {
    $query = "SELECT * FROM sotf_vars WHERE name='topic_update_done' AND value=1";
    $result = $db->getRow($query);
    if (count($result) == 0) {
        if (is_file($config['basedir'] . '/code/share/update_topics.txt') && sotf_Utils::getParameter('confirmed')) {
            $db->query("BEGIN;");
            // UPDATE sotf_topic_tree_defs, sotf_topics
            $update_statements = "";
            $upd_file = fopen($config['basedir'] . '/code/share/update_topics.txt', "r");
            while (!feof($upd_file)) {
                $update_statements .= fgets($upd_file, 4096);
            }
            fclose($upd_file);
            $db->query($update_statements);
            // UPDATE sotf_prog_topics (OLD TOPIC ID => NEW TOPIC ID)
            $new_topics = array('001td8' => '001td2', '001td9' => '001td6', '001td10' => '001td8', '001td11' => '001td9', '001td12' => '001td10', '001td13' => '001td11', '001td14' => '001td12', '001td15' => '001td12', '001td16' => '001td13', '001td17' => '001td10', '001td18' => '001td14', '001td19' => '001td15', '001td20' => '001td16', '001td21' => '001td18', '001td22' => '001td19', '001td23' => '001td20', '001td24' => '001td21', '001td25' => '001td22', '001td26' => '001td23', '001td27' => '001td24', '001td28' => '001td18', '001td29' => '001td25', '001td30' => '001td26', '001td31' => '001td27', '001td32' => '001td28', '001td33' => '001td29', '001td34' => '001td18', '001td35' => '001td25', '001td36' => '001td30', '001td37' => '001td18', '001td38' => '001td31', '001td39' => '001td32', '001td40' => '001td18', '001td41' => '001td34', '001td42' => '001td35', '001td43' => '001td35', '001td44' => '001td36', '001td45' => '001td35', '001td46' => '001td34', '001td47' => '001td34', '001td48' => '001td36', '001td49' => '001td26', '001td50' => '001td37', '001td51' => '001td38', '001td52' => '001td39', '001td53' => '001td40', '001td54' => '001td35', '001td55' => '001td38', '001td56' => '001td38', '001td57' => '001td41', '001td58' => '001td42', '001td59' => '001td43', '001td60' => '001td44', '001td61' => '001td41', '001td62' => '001td41', '001td63' => '001td41', '001td64' => '001td45', '001td65' => '001td46', '001td66' => '001td47', '001td67' => '001td48', '001td68' => '001td45', '001td69' => '001td41', '001td70' => '001td49', '001td71' => '001td41', '001td72' => '001td42', '001td73' => '001td50', '001td74' => '001td51', '001td75' => '001td52', '001td76' => '001td51', '001td77' => '001td53', '001td78' => '001td54', '001td79' => '001td55', '001td80' => '001td56', '001td81' => '001td57', '001td82' => '001td58', '001td83' => '001td51', '001td84' => '001td59', '001td85' => '001td60', '001td86' => '001td61', '001td87' => '001td62', '001td88' => '001td63', '001td89' => '001td62', '001td90' => '001td64', '001td91' => '001td65', '001td92' => '001td66', '001td93' => '001td67', '001td94' => '001td68', '001td95' => '001td66', '001td96' => '001td61', '001td97' => '001td69', '001td98' => '001td27', '001td99' => '001td65', '001td100' => '001td70', '001td101' => '001td69', '001td102' => '001td71', '001td103' => '001td72', '001td104' => '001td73', '001td105' => '001td74', '001td106' => '001td75', '001td107' => '001td76', '001td108' => '001td33', '001td109' => '001td111', '001td110' => '001td77', '001td111' => '001td33', '001td112' => '001td106', '001td113' => '001td78', '001td114' => '001td79', '001td115' => '001td80', '001td116' => '001td81', '001td117' => '001td82', '001td118' => '001td83', '001td119' => '001td84', '001td120' => '001td85', '001td121' => '001td86', '001td122' => '001td87', '001td123' => '001td88', '001td124' => '001td89', '001td125' => '001td90', '001td126' => '001td91', '001td127' => '001td92', '001td128' => '001td90', '001td129' => '001td90', '001td130' => '001td93', '001td131' => '001td90', '001td132' => '001td94', '001td133' => '001td91', '001td134' => '001td95', '001td135' => '001td96', '001td136' => '001td97', '001td137' => '001td98', '001td138' => '001td99', '001td139' => '001td98', '001td140' => '001td100', '001td141' => '001td17', '001td142' => '001td17', '001td143' => '001td17', '001td144' => '001td17', '001td145' => '001td17', '001td146' => '001td17', '001td147' => '001td17', '001td148' => '001td17', '001td149' => '001td17', '001td150' => '001td17', '001td151' => '001td17', '001td152' => '001td17', '001td153' => '001td17', '001td154' => '001td17', '001td155' => '001td17', '001td156' => '001td17', '001td157' => '001td17', '001td158' => '001td17', '001td159' => '001td17', '001td160' => '001td17', '001td161' => '001td17', '001td162' => '001td17', '001td163' => '001td17', '001td164' => '001td17', '001td165' => '001td17', '001td166' => '001td17', '001td167' => '001td17', '001td168' => '001td17', '001td169' => '001td17', '001td170' => '001td17', '001td171' => '001td17', '001td172' => '001td17', '001td173' => '001td17', '001td174' => '001td17', '001td175' => '001td17', '001td176' => '001td17', '001td177' => '001td17', '001td178' => '001td17', '001td179' => '001td17', '001td180' => '001td17', '001td181' => '001td17', '001td182' => '001td17', '001td183' => '001td17', '001td184' => '001td17', '001td185' => '001td17', '001td186' => '001td17', '001td187' => '001td17', '001td188' => '001td17', '001td189' => '001td17', '001td190' => '001td17', '001td191' => '001td17', '001td192' => '001td17', '001td193' => '001td17', '001td194' => '001td17', '001td195' => '001td17', '001td196' => '001td17', '001td197' => '001td17', '001td198' => '001td17', '001td199' => '001td17', '001td200' => '001td17', '001td201' => '001td17', '001td202' => '001td17', '001td203' => '001td17', '001td204' => '001td17', '001td205' => '001td17', '001td206' => '001td17', '001td207' => '001td17', '001td208' => '001td17', '001td209' => '001td17', '001td210' => '001td101', '001td211' => '001td102', '001td212' => '001td103', '001td213' => '001td104', '001td214' => '001td105', '001td215' => '001td44', '001td216' => '001td106', '001td217' => '001td106', '001td218' => '001td101', '001td219' => '001td101', '001td220' => '001td103', '001td221' => '001td107', '001td222' => '001td108', '001td223' => '001td103', '001td224' => '001td109', '001td225' => '001td109', '001td226' => '001td110', '001td227' => '001td112', '001td228' => '001td113', '001td229' => '001td114', '001td230' => '001td115', '001td231' => '001td16', '001td232' => '001td116', '001td233' => '001td117', '001td234' => '001td118', '001td235' => '001td119', '001td236' => '001td22', '001td237' => '001td120', '001td238' => '001td119', '001td239' => '001td121', '001td240' => '001td122', '001td241' => '001td113', '001td242' => '001td119', '001td243' => '001td119', '001td244' => '001td123', '001td245' => '001td15', '001td246' => '001td113', '001td247' => '001td124', '001td248' => '001td9', '001td249' => '001td119', '001td250' => '001td125', '001td251' => '001td10', '001td252' => '001td4', '001td253' => '001td126', '001td254' => '001td119', '001td255' => '001td113', '001td256' => '001td16', '001td257' => '001td15', '001td258' => '001td127', '001td259' => '001td18', '001td260' => '001td110');
            $old_topics = array_keys($new_topics);
            for ($k = 0; $k < count($old_topics); $k++) {
                // get programs with current OLD topic_id
                $q_progs = $db->query("SELECT prog_id FROM sotf_prog_topics WHERE topic_id = '" . $old_topics[$k] . "';");
<?php

// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id$
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
$filename = sotf_Utils::getParameter('filename');
$filename = sotf_Utils::getFileInDir($user->getUserDir(), $filename);
$file =& new sotf_File($filename);
if ($file->type != "none") {
    header("Content-type: " . $file->mimetype . "\n");
    header("Content-transfer-encoding: binary\n");
    header("Content-length: " . filesize($filename) . "\n");
    // send file
    readfile($filename);
} else {
    raiseError("download_problem");
}
$page->logRequest();
 * $Id$
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
require $config['classdir'] . "/sotf_AdvSearch.class.php";
$SQLquerySerial = sotf_Utils::getParameter('SQLquerySerial');
//the serialized query in the hidden field
$advsearch = new sotf_AdvSearch();
//create new search object object with this array
//if ($SQLquerySerial == "")							//get old search query from session if none in url
//	$SQLquerySerial = $_SESSION["SQLquerySerial"];				//get array from session
$SQLquery = $advsearch->Deserialize($SQLquerySerial);
//deserialize the content of the hidden field
if (sotf_Utils::getParameter('back') != NULL) {
    $_SESSION["SQLquerySerial"] = $SQLquerySerial;
    //save the new quey to the session
    $page->redirect("advsearch.php");
}
$query = $advsearch->GetSQLCommand();
$max = $db->getAll("SELECT count(*) FROM (" . $query . ") as count");
//get the number of results
$max = $max[0]["count"];
$limit = $page->splitList($max, "?SQLquerySerial={$SQLquerySerial}");
$result = $db->getAll($query . $limit["limit"]);
$allfields = $advsearch->GetSQLfields();
//get all possible fileld names with translation
$max = count($SQLquery);
//$fields will contain all the USED field names
for ($i = 0; $i < $max; $i++) {
Exemple #12
0
    $smarty->assign('AUDIO_FILES', $audioFiles);
    // other files
    $otherFiles = $prg->getAssociatedObjects('sotf_other_files', 'filename');
    $smarty->assign('OTHER_FILES', $otherFiles);
    // links
    $smarty->assign('LINKS', $prg->getAssociatedObjects('sotf_links', 'caption'));
    // referencing portals
    $smarty->assign('REFS', $prg->getRefs());
    // statistics
    $smarty->assign('STATS', $prg->getStats());
    // add this visit to statistics
    $prg->addStat('', "visits");
    // rating
    $rating = new sotf_Rating();
    $smarty->assign('RATING', $rating->getInstantRating($id));
    // my rating?
    $myRating = $rating->getMyRating($id);
    debug("r", $myRating);
    $smarty->assign('MY_RATING', $myRating);
    if ($page->loggedIn()) {
        // is in my playlist?
        $smarty->assign('inplaylist', sotf_UserPlaylist::contains($id));
    }
}
$db->commit();
if (sotf_Utils::getParameter('popup')) {
    $smarty->assign('POPUP', 1);
    $page->sendPopup();
} else {
    $page->send();
}
 /** static */
 function searchContactNames($pattern)
 {
     global $db, $config, $user;
     $pattern = sotf_Utils::magicQuotes($pattern);
     $res = $db->getAssoc("SELECT c.id AS id, c.name AS name FROM sotf_contacts c WHERE name ~* '{$pattern}' ORDER BY name");
     if (DB::isError($res)) {
         raiseError($res);
     }
     return $res;
 }
Exemple #14
0
    $file = $userDir . $newname . "." . $extension;
    moveUploadedFile('userfile', $file);
    $page->redirect("manageFiles.php");
    exit;
}
//---------
// delete files
$del = sotf_Utils::getParameter('del');
if ($del) {
    reset($_POST);
    while (list($k, $fname) = each($_POST)) {
        debug("P", $k);
        if (substr($k, 0, 4) == 'sel_') {
            if (!unlink($user->getUserDir() . '/' . $fname)) {
                addError("Could not delete: {$fname}");
            }
        }
    }
    $page->redirect("manageFiles.php");
    exit;
}
// close
$close = sotf_Utils::getParameter('close');
if ($close) {
    $page->redirect("closeAndRefresh.php");
    exit;
}
// generate output
$smarty->assign('USERFILES', $user->getUserFiles());
$smarty->assign("USERFTPURL", $user->getUrlForUserFTP());
$page->sendPopup();
 function listGroupsOfUser($uid)
 {
     global $db;
     if (!$uid) {
         return array();
     }
     $uid = sotf_Utils::magicQuotes($uid);
     $sql = "SELECT group_id, id FROM sotf_user_groups WHERE user_id='{$uid}'";
     $res = $db->getAssoc($sql);
     if (DB::isError($res)) {
         raiseError($res);
     }
     return $res;
 }
if ($save) {
    $userPerms = $permissions->getPermissions($objectid, $userid);
    debug("userPerms", $userPerms);
    if (sotf_Utils::getParameter('perm_admin')) {
        if (!in_array('admin', $userPerms)) {
            $permissions->addPermission($objectid, $userid, 'admin');
        }
    } else {
        if (in_array('admin', $userPerms)) {
            $permissions->delPermission($objectid, $userid, 'admin');
        }
        $perms['create'] = sotf_Utils::getParameter('perm_create');
        $perms['change'] = sotf_Utils::getParameter('perm_change');
        $perms['add_prog'] = sotf_Utils::getParameter('perm_add_prog');
        $perms['delete'] = sotf_Utils::getParameter('perm_delete');
        $perms['authorize'] = sotf_Utils::getParameter('perm_authorize');
        while (list($perm, $hasP) = each($perms)) {
            if ($hasP && !in_array($perm, $userPerms)) {
                $permissions->addPermission($objectid, $userid, $perm);
            } elseif (!$hasP && in_array($perm, $userPerms)) {
                $permissions->delPermission($objectid, $userid, $perm);
            }
        }
    }
    $page->redirect('closeAndRefresh.php?anchor=perms');
}
$smarty->assign('CONTEXT', $context);
$smarty->assign('OBJECT_NAME', $objectname);
$smarty->assign('OBJECT_ID', $objectid);
$smarty->assign('USER_NAME', $username);
$smarty->assign('USER_ID', $userid);
 */
require "init.inc.php";
$page->forceLogin();
//sotf_Utils::getParameter("");
$playlist = new sotf_UserPlaylist();
if (sotf_Utils::getParameter("delete_selected") != "") {
    $checkbox = sotf_Utils::getParameter("checkbox");
    $max = count($checkbox);
    for ($i = 0; $i < $max; $i++) {
        $playlist->delete($checkbox[$i]);
    }
    $page->redirect("playlist.php");
}
if (sotf_Utils::getParameter("play_selected") != "") {
    $pl = new sotf_Playlist();
    $checkbox = sotf_Utils::getParameter("checkbox");
    for ($i = 0; $i < count($checkbox); $i++) {
        $prg = new sotf_Programme($checkbox[$i]);
        $pl->addProg($prg);
    }
    $pl->startStreaming();
    $pl->sendRemotePlaylist();
    $page->logRequest();
    exit;
}
$result = $playlist->load();
$programmes = array();
for ($i = 0; $i < count($result); $i++) {
    $result[$i]['icon'] = sotf_Blob::cacheIcon($result[$i]['id']);
    $programmes["0:" . $i] = $result[$i]["title"];
}
Exemple #18
0
if (!$treeId) {
    if ($open) {
        $info = $vocabularies->getTopicInfo($open, $lang);
        $treeId = $info['tree_id'];
    } else {
        $treeId = $vocabularies->getDefaultTreeId();
    }
}
debug("treeid", $treeId);
$rootId = $vocabularies->getTopicTreeRoot($treeId);
if ($prgid) {
    $addMode = 1;
    $smarty->assign("OPENER_URL", "editMeta.php?id={$prgid}");
}
$smarty->assign('ADD_MODE', $addMode);
// list all topic trees
$smarty->assign('TREES', $vocabularies->listTopicTrees($lang));
// TODO; use user's language
$info = $vocabularies->getTopicTreeInfo($treeId, $lang);
debug("INFO", $info);
$treeLang = $lang;
if (strpos($info['languages'], $lang) === FALSE) {
    $treeLang = 'eng';
}
// fall back to English
$result = $vocabularies->getTree($treeId, $treeLang, true);
$smarty->assign('TREE_ID', $treeId);
$smarty->assign("TREE", $result);
$smarty->assign("prgid", sotf_Utils::getParameter('prgid'));
//$page->sendPopup();
$page->send("topicTree.htm");
Exemple #19
0
require "init.inc.php";
if (sotf_Utils::getParameter('reconnect')) {
    $playlist = new sotf_Playlist();
    $playlist->sendMyRemotePlaylist();
    $page->logRequest();
    exit;
}
if (sotf_Utils::getParameter('stop')) {
    $playlist = new sotf_Playlist();
    $playlist->stopMyStream();
    $page->redirect(myGetenv('HTTP_REFERER'));
    exit;
}
$id = sotf_Utils::getParameter('id');
$fileid = sotf_Utils::getParameter('fileid');
$jingle = sotf_Utils::getParameter('jingle');
if (empty($id)) {
    raiseError("Missing parameters!", 'id');
}
$playlist = new sotf_Playlist();
if ($jingle) {
    // play the jingle of station/series
    $obj = $repository->getObject($id);
    if (!$obj) {
        raiseError("no_such_object", $id);
    }
    if (!$obj->isLocal()) {
        // have to send user to home node of this programme
        sotf_Node::redirectToHomeNode($obj, 'listen.php');
        exit;
    }
Exemple #20
0
        if ($text) {
            $prgprop['text'] = $value;
        } elseif ($teaser) {
            $prgprop['teaser'] = $value;
        }
        $portal->setPrgProperties($id, $prgprop['text'], $prgprop['teaser']);
        $page->redirect($rootdir . "/closeAndRefresh.php");
        //close window and go back to edit mode
    } else {
        if ($text) {
            $value = $prgprop['text'];
        } elseif ($teaser) {
            $value = $prgprop['teaser'];
        }
    }
    $settings = $portal->loadSettings();
    ////Smarty
    $smarty->assign("portal", $settings["portal"]);
    $smarty->assign("rootdir", $rootdir);
    //root directory (portal/www)
    $smarty->assign("php_self", $_SERVER['PHP_SELF']);
    //php self for the form submit and hrefs
    $smarty->assign("portal_name", $portal_name);
    //name of the portal
    $smarty->assign("id", $id);
    $smarty->assign("value", $value);
    $smarty->assign("text", $text);
    $smarty->assign("teaser", $teaser);
    $smarty->assign("title", sotf_Utils::getParameter('title'));
    $page->send("edit_text.htm");
}
Exemple #21
0
$smarty->assign("USERFTPURL", $userFtpUrl);
$stations = $permissions->listStationsForEditor();
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);
}
////form sent
$series = sotf_Utils::getParameter("series");
$filter = sotf_Utils::getParameter("filter");
$sort1 = sotf_Utils::getParameter("sort1");
$sort2 = sotf_Utils::getParameter("sort2");
////from user prefs if first time on page
$prefs = $user->getPreferences();
if ($sort1 == NULL) {
    $sort1 = $prefs->editorSettings[sort1];
}
if ($sort2 == NULL) {
    $sort2 = $prefs->editorSettings[sort2];
}
if ($series == NULL) {
    $series = $prefs->editorSettings[series];
}
if ($filter == NULL) {
    $filter = $prefs->editorSettings[filter];
}
////default settings if first time here
    $video = false;
}
$converting = false;
// admins or owners can change files
checkPerm($id, 'change');
// delete link
$delLink = sotf_Utils::getParameter('dellink');
$linkid = sotf_Utils::getParameter('linkid');
if ($delLink) {
    $link = new sotf_NodeObject("sotf_links", $linkid);
    $link->delete();
    $page->redirect("editFiles.php?id={$id}#links");
    exit;
}
// delete file
$delFile = sotf_Utils::getParameter('delfile');
if ($delFile) {
    $prg->deleteFile($delFile);
    $page->redirect("editFiles.php?id={$id}#mfiles");
    exit;
}
// generate output
//$smarty->assign("OKURL",$okURL);
if ($new) {
    $smarty->assign("NEW", 1);
}
$smarty->assign('PRG_DATA', $prg->getAll());
$smarty->assign('LINKS', $prg->getAssociatedObjects('sotf_links', 'caption'));
// TODO: compare directory and SQL data for correctness
// other files
$otherFiles = $prg->listOtherFiles();
Exemple #23
0
function selectAudioVideo(&$prg)
{
    global $config;
    $files = $prg->listAudioFiles('TRUE', 'kbps DESC');
    if (is_array($files)) {
        foreach ($files as $f) {
            if ($f['download_access'] == 't') {
                /* sun 8.2.06 added to format properly the enclosure url --rama */
                $station = sotf_Utils::makeValidName($prg->get('station'), 23);
                $series = sotf_Utils::makeValidName($prg->get('series'), 23);
                $title = sotf_Utils::makeValidName($prg->get('title'), 30);
                if ($station != "" && $series != "" && $title != "") {
                    $fname = "{$station}-{$series}-{$title}";
                } elseif ($station != "" && $title != "") {
                    $fname = "{$station}-{$title}";
                } elseif ($title != "") {
                    $fname = $title;
                }
                /* end properly format enclosure url */
                //$f['url'] = $config['rootUrl'] . '/getFile.php/' . $f['filename'] . '?audio=1&id=' . $prg->id . '&filename=' . $f['filename'];
                //$f['url'] = $config['rootUrl'] . '/getFile.php?audio=1&id=' . $prg->id . '&filename=' . $f['filename'];
                $baseUrl = sotf_Node::getHomeNodeRootUrl($prg);
                //$f['url'] = $baseUrl . '/getFile.php/fid__' . $f['id'].".mp3"; // wreutz: very dirty hack for ipooder to work on os x
                //MODIFIED BY Martin Schmidt
                $f = array_merge($f, sotf_AudioFile::decodeFormatFilename($f['format']));
                if ($prg->isVideoPrg() && $f['format'] == "mp4") {
                    //echo "drinnen";
                    $f['url'] = $baseUrl . '/getFile.php/' . 'fid__' . $f['id'] . '__' . $fname . ".mp4";
                    return $f;
                } else {
                    if ($prg->isAudioPrg()) {
                        $f['url'] = $baseUrl . '/getFile.php/' . 'fid__' . $f['id'] . '__' . $fname . ".mp3";
                        //rjankowski changed order to get parsed by getFile.php
                        return $f;
                    }
                }
                //////////////////////////
                // rama: included $fname as formatted name $station-$series-$title
            }
        }
    }
    /*
    if(!$retval and is_array($files)) {
    	 foreach($files as $f) {
    		if($f['stream_access']=='t') {
    		  $f['url'] = $config['rootUrl'] . '/listen.php?id=' . $prg->id . '&fileid=' . $f['id'];
    		  return $f;
    		}
    	 }
    }
    */
    return NULL;
}
Exemple #24
0
 * Authors: András Micsik, Máté Pataki, Tamás Kézdi 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
define('ITEMS_IN_RSS', 10);
require "init.inc.php";
require_once $config['classdir'] . "/xmlwriterclass.php";
require_once $config['classdir'] . "/rss_writer_class.php";
require_once $config['classdir'] . "/sotf_AdvSearch.class.php";
$prgId = sotf_Utils::getParameter('id');
$stationId = sotf_Utils::getParameter('station');
$seriesId = sotf_Utils::getParameter('series');
$userName = sotf_Utils::getParameter('user');
$queryName = sotf_Utils::getParameter('qname');
$query = sotf_Utils::getParameter('query');
$from = sotf_Utils::getParameter('from');
$count = sotf_Utils::getParameter('count');
if (!$count) {
    $count = ITEMS_IN_RSS;
}
function createImageTag($url, $title, $link)
{
    return "<url>{$url}</url><title>{$title}</title><link>{$link}</link>";
}
function getW3CDate()
{
    $retval = date("Y-m-d\\TH:i:sO");
    // 1997-07-16T19:20:30+01:00  "2002-05-06T00:00:00Z";
    $retval = substr($retval, 0, -2) . ':' . substr($retval, -2);
    return $retval;
}
/** this is a hack to convert pgsql date format to W3C date format required by RSS */
///////////////////////////////////////////////////
if ($_GET['uilang']) {
    $page->setUILanguage($_GET['uilang']);
    $url = $_GET['okURL'];
    if (!$url) {
        $url = $config['localPrefix'];
    }
    $page->redirect($url);
    exit;
}
// we need trick for making pages indexed by Google
// therefore we pass some parameters in pathinfo
// after this call getParameter can be used to get these parameters as well
$pathinfoParamExceptions = array('getIcon', 'getJingle', 'getUserFile');
if (!in_array($page->action, $pathinfoParamExceptions)) {
    sotf_Utils::collectPathinfoParams();
}
// permissions object is for managing and asking for permissions
$permissions = new sotf_Permission();
//$permissions->debug = true;
// the repository of radio stations
$repository = new sotf_Repository($config['repositoryDir'], $db);
// all controlled vocabularies
$vocabularies = new sotf_Vocabularies($db);
// now you have the following global objects: $config, $db, $userdb, $smarty, $page, $repository, $user, $permission
// is that too many?
// forwarding all $config to smarty is a security risk
// $smarty->assign("CONFIG", $config);
// add basic variables to Smarty
$smarty->assign("NODEID", $config['nodeId']);
$smarty->assign("NODE_NAME", $config['nodeName']);
 /** Search for users. */
 function findUsers($pattern, $prefix = false)
 {
     global $userdb;
     $storage =& sotf_User::getStorageObject();
     $fields['pattern'] = sotf_Utils::magicQuotes($pattern);
     if ($prefix) {
         $fields['prefix'] = 1;
     }
     $res = $storage->userDbFind($fields);
     if (DB::isError($res)) {
         raiseError($res);
     }
     return $res;
 }
Exemple #27
0
<?php

// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id$
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
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);
$playlist = new sotf_Playlist();
$playlist->addProg($prg, $fileid);
$playlist->startStreaming();
$playlist->sendRemotePlaylist();
$page->logRequest();
 function splitList($rp_count, $rp_url, $anchor = "")
 {
     global $smarty, $sotfVars;
     $rp_maxresults = $sotfVars->get("hitsPerPage", 10);
     //display maximal so many results
     //$rp_maxresults = 2;
     $rp_from = sotf_Utils::getParameter('from');
     if (!isset($rp_from)) {
         $rp_from = 1;
     }
     //if first time on page
     // refresh link
     $refresh_url = $this->splitListURL($rp_url, $rp_from);
     if (strpos($refresh_url, "?") === false) {
         $refresh_url .= "?t=" . time();
     } else {
         $refresh_url .= "&t=" . time();
     }
     if ($anchor) {
         $refresh_url .= '#' . $anchor;
     }
     $smarty->assign("rp_refresh_url", $refresh_url);
     // last item displayed
     $rp_to = $rp_from + $rp_maxresults - 1;
     //set 'to' field
     if ($rp_to > $rp_count) {
         $rp_to = $rp_count;
     }
     //if less then $maxresults
     if ($rp_from > 1) {
         // url to first page
         $smarty->assign("rp_first_url", $this->splitListURL($rp_url, 1, $anchor));
         // url to prev page
         $rp_prev = $rp_from - $rp_maxresults;
         if ($rp_prev >= 1) {
             $smarty->assign("rp_prev_url", $this->splitListURL($rp_url, $rp_prev, $anchor));
         }
     }
     $reminder = $rp_count % $rp_maxresults;
     if ($reminder == 0) {
         $reminder = $rp_maxresults;
     }
     $rp_last = $rp_count - $reminder + 1;
     if ($rp_from < $rp_last) {
         // url to next page
         $rp_next = $rp_from + $rp_maxresults;
         if ($rp_next <= $rp_count) {
             $smarty->assign("rp_next_url", $this->splitListURL($rp_url, $rp_next, $anchor));
         }
         // url to last page
         $smarty->assign("rp_last_url", $this->splitListURL($rp_url, $rp_last, $anchor));
     }
     $smarty->assign("rp_count", $rp_count);
     $smarty->assign("rp_to", $rp_to);
     $smarty->assign("rp_from", $rp_from);
     $smarty->assign("rp_url", $rp_url);
     $smarty->assign("anchor", $anchor);
     if ($rp_to == $rp_count) {
         $smarty->assign("rp_theend", true);
     }
     if ($rp_from == 1) {
         $smarty->assign("rp_thebeginning", true);
     }
     $limit["from"] = $rp_from - 1;
     $limit["to"] = $rp_to - 1;
     $limit["maxresults"] = $rp_maxresults;
     $limit["limit"] = " LIMIT " . $rp_maxresults . " OFFSET " . ($rp_from - 1);
     return $limit;
     //print($query." LIMIT ".$maxresults." OFFSET ".($from - 1))
 }
    $fname = $_FILES['userfile']['name'];
    $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) {
    $portal->insertCell($row, $col, "before");
    //insert cell before current
    $_SESSION["settings"]["table"] = $portal->getTable();
    //save result
} elseif (sotf_Utils::getParameter('delete')) {
    $portal->deleteCell($row, $col);
    //delete current cell
    $_SESSION["settings"]["table"] = $portal->getTable();
    //save result
    $page->redirect($rootdir . "/closeAndRefresh.php");
    //close window and go back to edit mode
} elseif ($cell["resource"] != NULL) {
    $portal->setCell($row, $col, $cell);
    ////save cuttent portal table to the session
    $_SESSION["settings"]["table"] = $portal->getTable();
    if ($cell["resource"] == sotf_Utils::getParameter('oldresource')) {
        $page->redirect($rootdir . "/closeAndRefresh.php");
    }
    //if resource type not chnged
}
////SMARTY
$settings = $_SESSION["settings"];
$smarty->assign("portal", $settings["portal"]);
$smarty->assign("css", $settings["css"]);
$smarty->assign("table", $portal->getTable());
$smarty->assign("resources", $portal->getResources());
$smarty->assign("files", $portal->getUploadedFiles());
$smarty->assign("queries", $portal->getQueries());
$smarty->assign("playlists", $portal->getPlaylists());
$smarty->assign("styles", $portal->getStyles());
$smarty->assign("aligns", $portal->getAligns());