本文整理汇总了PHP中sotf_Utils类的典型用法代码示例。如果您正苦于以下问题:PHP sotf_Utils类的具体用法?PHP sotf_Utils怎么用?PHP sotf_Utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sotf_Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cacheIcon
/** 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: findByName
/** 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;
}
示例3: findByName
/** 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;
}
示例4: save
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}')");
}
}
示例5: delete
/**
* 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");
}
示例6: set
/** 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}");
}
示例7: getUsername
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;
}
示例8:
$_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
示例9: basename
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] . "';");
示例10: header
<?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();
示例11: sotf_AdvSearch
* $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++) {
示例12: sotf_Rating
$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();
}
示例13: searchContactNames
/** 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;
}
示例14: moveUploadedFile
$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();
示例15: listGroupsOfUser
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;
}