Пример #1
0
 /** 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;
 }
Пример #2
0
$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"];
}
$smarty->assign("result", $result);
$smarty->assign("count", count($result));
$smarty->assign("programmes", $programmes);
$page->send();
Пример #3
0
function getProgrammes($params)
{
    global $config, $db;
    $prglist = xmlrpc_decode($params->getParam(0));
    $query = "SELECT programmes.* FROM (";
    $query .= " SELECT sotf_programmes.*, sotf_stations.name as station, sotf_series.title as seriestitle, sotf_series.description as seriesdescription, sotf_prog_rating.rating_value as rating FROM sotf_programmes";
    $query .= " LEFT JOIN sotf_stations ON sotf_programmes.station_id = sotf_stations.id";
    $query .= " LEFT JOIN sotf_series ON sotf_programmes.series_id = sotf_series.id";
    $query .= " LEFT JOIN sotf_prog_rating ON sotf_programmes.id = sotf_prog_rating.id";
    $query .= ") as programmes WHERE published = 't'";
    $results = array();
    foreach ($prglist as $prg) {
        //		debug("------------>".$prg."<------------------");
        //		debug("------------>".$query." AND id = '$prg'<------------------");
        $results[] = $db->getRow($query . " AND id = '{$prg}'");
    }
    foreach ($results as $key => $result) {
        //		debug("------------>".$result['id']."<------------------");
        $icon = sotf_Blob::cacheIcon($result['id']);
        $results[$key]['icon'] = $config['cacheUrl'] . "/" . $result['id'] . ".png";
        //TODO if no icon {$IMAGEDIR}/noicon.png $imageprefix????
    }
    $retval = xmlrpc_encode($results);
    return new xmlrpcresp($retval);
}
Пример #4
0
/** For portal */
function getProgrammes($params)
{
    global $config, $db;
    $prglist = xmlrpc_decoder($params->getParam(0));
    $query = "SELECT programmes.* FROM (";
    $query .= " SELECT sotf_programmes.*, sotf_stations.name as station, sotf_series.name as seriestitle, sotf_series.description as seriesdescription, sotf_prog_rating.rating_value as rating FROM sotf_programmes";
    $query .= " LEFT JOIN sotf_stations ON sotf_programmes.station_id = sotf_stations.id";
    $query .= " LEFT JOIN sotf_series ON sotf_programmes.series_id = sotf_series.id";
    $query .= " LEFT JOIN sotf_prog_rating ON sotf_programmes.id = sotf_prog_rating.id";
    $query .= ") as programmes WHERE published = 't'";
    $results = array();
    foreach ($prglist as $prg) {
        //		debug("------------>".$prg."<------------------");
        //		debug("------------>".$query." AND id = '$prg'<------------------");
        $p = $db->getRow($query . " AND id = '{$prg}'");
        if ($p != NULL) {
            $results[] = $p;
        }
        //else $results[] = array("id" => $prg, "title" => "DELETED");
    }
    foreach ($results as $key => $result) {
        //		debug("------------>".$result['id']."<------------------");
        $icon = sotf_Blob::cacheIcon2($result);
        if ($icon) {
            $results[$key]['icon'] = $config['cacheUrl'] . "/" . $icon;
        }
        //TODO if no icon {$IMAGEDIR}/noicon.png $imageprefix????
        $prg =& new sotf_Programme($result['id']);
        // audio files for programme
        $audioFiles = $prg->listAudioFiles('true');
        $results[$key]['audioFiles'] = array();
        $results[$key]['downloadFiles'] = array();
        foreach ($audioFiles as $fileList) {
            if ($fileList['stream_access'] == "t") {
                $results[$key]['audioFiles'][] = $fileList;
            }
            if ($fileList['download_access'] == "t") {
                $results[$key]['downloadFiles'][] = $fileList;
            }
        }
        //		$audioFiles = $prg->listAudioFiles('true');
        //		for ($i=0;$i<count($audioFiles);$i++)
        //		{
        //			$mainAudio[$audioFiles[$i]['filename']] = $audioFiles[$i];
        //		}
    }
    $retval = xmlrpc_encoder($results);
    return new xmlrpcresp($retval);
}
Пример #5
0
    // 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();
    if (array_key_exists("topic", $fields)) {
        $topicname = $page->getlocalized("topic");
        $topics = $advsearch->getTopics($result[$i]["id"]);
        foreach ($topics as $topic) {
            if ($topic["name"] != "") {
                if ($values[$topicname] == "") {
                    $values[$topicname] = $topic["name"];
                } else {
                    $values[$topicname] .= "; " . $topic["name"];
                }
            }
        }
    }
    $item['title'] = $result[$i][title];
    $item['id'] = $result[$i][id];
    $item['icon'] = sotf_Blob::cacheIcon($item['id']);
    $item['values'] = $values;
    $selected[] = $item;
    $item = "";
    $values = "";
}
//var_dump($selected);
//if (DB::isError($result)) die($result->getMessage());
//print("<BR />".count($result));
$smarty->assign("SQLquery", $SQLquery);
//the query
$smarty->assign("SQLquerySerial", "&SQLquerySerial={$SQLquerySerial}");
//the serialized query
//$smarty->assign("SQLqueryfields", $advsearch->GetSQLqueryfields());	//translated name for all fieldnames of the query
//$smarty->assign("SQLqueryEQs", $advsearch->GetSQLqueryEQs());		//translated name for all EQs (<, >, = ...) of the query
$smarty->assign("HumanReadable", $advsearch->GetHumanReadable());
<?php

// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id: showContactProgs.php 358 2004-04-29 12:46:01Z micsik $
 * 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";
$contactId = sotf_Utils::getParameter('id');
$contact =& new sotf_Contact($contactId);
$smarty->assign('PAGETITLE', $page->getlocalizedWithParams('programs_by', $contact->get('name')));
$smarty->assign('CONTACT_ID', $contactId);
$smarty->assign('CONTACT_NAME', $contact->get('name'));
$smarty->assign('CONTACT_DATA', $contact->getAllWithIcon());
$limit = $page->splitList($contact->countProgrammes(), "{$scriptUrl}/{$contactId}");
$progs = $contact->listProgrammes($limit["from"], $limit["maxresults"]);
for ($i = 0; $i < count($progs); $i++) {
    $progs[$i]['icon'] = sotf_Blob::cacheIcon2($progs[$i]);
}
$smarty->assign('PROGS', $progs);
$page->send();
 /**
  * Sets icon for object
  *
  * @param	object	$file	pathname of file
  * @return	boolean	True if the function succeeded, else false
  * @use	$db
  * @use	$config['iconWidth']
  * @use	$config['iconHeight']
  */
 function setIcon($file)
 {
     global $config;
     $tmpfile = $config['tmpDir'] . '/' . time() . ".png";
     if (!$this->prepareIcon($file, $tmpfile, $config['iconWidth'], $config['iconHeight'])) {
         raiseError("Could not resize image");
         //return false;
     } else {
         if ($fp = fopen($tmpfile, 'rb')) {
             $data = fread($fp, filesize($tmpfile));
             fclose($fp);
             // save into DB
             sotf_Blob::saveBlob($this->id, "icon", $data);
         } else {
             raiseError("could not open icon file!");
         }
     }
     if (is_file($tmpfile)) {
         debug("tmpfile", $tmpfile);
         //unlink($tmpfile);
     }
     return true;
 }
 /**
  * Sets icon for object.
  *
  * @internal change person icons to 50x50 done by wofli_fhsp and buddafly
  * @param	object	$file	pathname of file
  * @return	boolean	True if the function succeeded, else false
  */
 function setIcon($file, $ispersonicon = false)
 {
     // change from wolfi_fhstp and buddhafly (change person icons to 50x50)
     global $config;
     $tmpfile = $config['tmpDir'] . '/' . time() . ".png";
     if ($ispersonicon) {
         $succ = $this->prepareIcon($file, $tmpfile, 50, 50);
     } else {
         $succ = $this->prepareIcon($file, $tmpfile, $config['iconWidth'], $config['iconHeight']);
     }
     //-----------------------------------------------------------------------------------------
     if (!$succ) {
         addError("Could not resize image");
         //return false;
     } else {
         if ($fp = fopen($tmpfile, 'rb')) {
             $data = fread($fp, filesize($tmpfile));
             fclose($fp);
             // save into DB
             sotf_Blob::saveBlob($this->id, "icon", $data);
             // save into file system
             $iconFile = $this->getMetaDir() . '/icon.png';
             sotf_Utils::save($iconFile, $data);
         } else {
             addError("could not open icon file!");
         }
     }
     if (is_file($tmpfile)) {
         debug("remove tmpfile", $tmpfile);
         unlink($tmpfile);
     }
     sotf_Blob::uncacheIcon($this->id);
     return true;
 }
 /** get news for index page */
 function getNewProgrammes($fromDay, $maxItems)
 {
     global $config, $db;
     $sql = "SELECT i.* FROM sotf_programmes i, sotf_stations s WHERE i.station_id = s.id AND i.published='t' AND i.entry_date >= '{$fromDay}' ORDER BY i.entry_date DESC";
     $res = $db->limitQuery($sql, 0, $maxItems);
     if (DB::isError($res)) {
         raiseError($res);
     }
     $results = null;
     while (DB_OK === $res->fetchInto($row)) {
         $row['icon'] = sotf_Blob::cacheIcon2($row);
         $results[] = $row;
     }
     return $results;
 }
Пример #11
0
    $smarty->assign('PLAYLIST', $playlist->load());
    // 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::cacheIcon($row['id']);
        $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', $repository->getTopTopics(5));
$page->send();
Пример #12
0
 /** 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 $config;
     $cacheTimeout = 10 * 60;
     // 10 minutes
     if (!$id) {
         raiseError("missing id");
     }
     $fname = $config['cacheDir'] . "/" . $id . '.png';
     if (is_readable($fname)) {
         $stat = stat($fname);
         if (time() - $stat['mtime'] <= $cacheTimeout) {
             return true;
         } else {
             debug("cached icon of {$id} expired");
             if (!unlink($fname)) {
                 clearstatcache();
                 if (file_exists($fname)) {
                     logError("Could not delete {$fname}");
                 }
             }
         }
     }
     $icon = sotf_Blob::findBlob($id, 'icon');
     if (!$icon) {
         return false;
     }
     debug("cached icon of {$id} for ", $forId);
     sotf_Utils::save($fname, $icon);
     return true;
 }
 /** static returns programmes owned/edited by current user */
 function myProgrammes($series, $filter, $sort, $count = false)
 {
     global $permissions, $db, $user;
     if (!isset($permissions->currentPermissions)) {
         return NULL;
     }
     // not logged in yet
     $sql = "SELECT  s.name AS station, se.name AS series, stats.visits, stats.listens, stats.downloads, flags.flags, rating.*, p.*" . " FROM sotf_programmes p LEFT JOIN sotf_stations s ON p.station_id = s.id" . " LEFT JOIN sotf_series se ON p.series_id=se.id" . " LEFT JOIN sotf_prog_rating rating ON p.id=rating.prog_id" . " LEFT JOIN sotf_user_progs flags ON p.id=flags.prog_id AND flags.user_id='{$user->id}'" . " LEFT JOIN sotf_prog_stats stats ON stats.prog_id=p.id " . ", sotf_user_permissions u" . " WHERE u.user_id = '{$user->id}' AND u.object_id=p.id";
     if ($series != "allseries") {
         $sql .= " AND p.series_id='{$series}'";
     }
     if ($filter == "all") {
     } elseif ($filter == "published") {
         $sql .= " AND p.published='t'";
     } elseif ($filter == "unpublished") {
         $sql .= " AND p.published='f'";
     } else {
         $sql .= " AND flags = '{$filter}'";
     }
     if ($sort) {
         $sql .= " ORDER BY {$sort}";
     }
     if ($count) {
         return $db->getOne("SELECT count(*) FROM ({$sql}) as a");
     }
     $plist = $db->getAll($sql);
     /////////////////added by Klaus Temper ///////////////////////
     foreach ($plist as $item) {
         $item["icon"] = sotf_Blob::cacheIcon2($item);
         $result[] = $item;
     }
     ///////////////////////////////////////////////////////
     /*
     	 foreach($plist as $item) {
     		$retval[] = new sotf_Programme($item['id'], $item);
     	 }*/
     return $result;
 }
Пример #14
0
 $smarty->assign('ID', $id);
 $prg =& $repository->getObject($id);
 if (!$prg) {
     raiseError("no_such_object", $id);
 }
 if (!$prg->getBool('published')) {
     if (!hasPerm($prg->id, 'change')) {
         raiseError("not_published_yet", $id);
         exit;
     }
     $smarty->assign("UNPUBLISHED", 1);
 }
 $page->setTitle($prg->get('title'));
 // general data
 $prgData = $prg->getAll();
 $prgData['icon'] = sotf_Blob::cacheIcon($id);
 $smarty->assign('PRG_DATA', $prgData);
 // station data
 $station = $prg->getStation();
 $smarty->assign('STATION_DATA', $station->getAllWithIcon());
 // series data
 $series = $prg->getSeries();
 if ($series) {
     $smarty->assign('SERIES_DATA', $series->getAllWithIcon());
 }
 // roles and contacts
 $smarty->assign('ROLES', $prg->getRoles());
 // genre
 $smarty->assign('GENRE', $vocabularies->getGenreName($prg->get('genre_id')));
 // topics
 $smarty->assign('TOPICS', $prg->getTopics());
 /** get news for index page, mode can be: all, free, promoted, premium */
 function getNewProgrammes($fromDay, $maxItems, $mode = 'all')
 {
     global $config, $db;
     if ($mode == 'premium') {
         $modeSql = "i.free_content='f' AND";
     } elseif ($mode == 'promoted') {
         $modeSql = "i.free_content='t' AND i.promoted='t' AND";
     } elseif ($mode == 'free') {
         $modeSql = "i.free_content='t' AND i.promoted='f' AND";
     }
     //$sql = "SELECT i.* FROM sotf_programmes i, sotf_stations s WHERE $modeSql i.station_id = s.id AND i.published='t' AND i.entry_date >= '$fromDay' ORDER BY i.entry_date DESC";
     $sql = "SELECT i.* FROM sotf_programmes i, sotf_stations s WHERE {$modeSql} i.station_id = s.id AND i.published='t' AND i.type='sound' AND i.entry_date >= '{$fromDay}' ORDER BY i.entry_date DESC";
     //MODIFIED BY Martin Schmidt
     $res = $db->limitQuery($sql, 0, $maxItems);
     if (DB::isError($res)) {
         raiseError($res);
     }
     $results = null;
     while (DB_OK === $res->fetchInto($row)) {
         $row['icon'] = sotf_Blob::cacheIcon2($row);
         $results[] = $row;
     }
     return $results;
 }
Пример #16
0
    if (array_key_exists("topic", $fields)) {
        $topicname = $page->getlocalized("topic");
        $topics = $advsearch->getTopics($result[$i]["id"]);
        foreach ($topics as $topic) {
            if ($topic["name"] != "") {
                if ($values[$topicname] == "") {
                    $values[$topicname] = $topic["name"];
                } else {
                    $values[$topicname] .= "; " . $topic["name"];
                }
            }
        }
    }
    $item['title'] = $result[$i][title];
    $item['id'] = $result[$i][id];
    $item['icon'] = sotf_Blob::cacheIcon2($result[$i]);
    $item['values'] = $values;
    $selected[] = $item;
    $item = "";
    $values = "";
}
//var_dump($selected);
//if (DB::isError($result)) die($result->getMessage());
//print("<BR />".count($result));
$smarty->assign("SQLquery", $SQLquery);
//the query
$smarty->assign("SQLquerySerial", $SQLquerySerial);
//the serialized query
//$smarty->assign("SQLqueryfields", $advsearch->GetSQLqueryfields());	//translated name for all fieldnames of the query
//$smarty->assign("SQLqueryEQs", $advsearch->GetSQLqueryEQs());		//translated name for all EQs (<, >, = ...) of the query
$smarty->assign("HumanReadable", $advsearch->GetHumanReadable());
Пример #17
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";
$contactId = sotf_Utils::getParameter('id');
$contact =& new sotf_Contact($contactId);
$smarty->assign('PAGETITLE', $page->getlocalizedWithParams('programs_by', $contact->get('name')));
$smarty->assign('CONTACT_ID', $contactId);
$smarty->assign('CONTACT_NAME', $contact->get('name'));
$smarty->assign('CONTACT_DATA', $contact->getAllWithIcon());
$limit = $page->splitList($contact->countProgrammes(), "{$scriptUrl}/{$contactId}");
$progs = $contact->listProgrammes($limit["from"], $limit["maxresults"]);
for ($i = 0; $i < count($progs); $i++) {
    $progs[$i]['icon'] = sotf_Blob::cacheIcon($progs[$i]['id']);
}
$smarty->assign('PROGS', $progs);
$page->send();