function calendar($s) { global $db; global $lang; global $login; global $rights; $return = array(); $tbl = MYSQL_TABLE_PREFIX . 'calendar'; $isallowed = $rights->isAllowed('calendar', 'manage'); if ($isallowed) { $result = $db->selectList($tbl, "*", "INSTR(`title`, '" . $s . "') > 0 OR\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSTR(`description`, '" . $s . "') > 0"); } else { if ($login->currentUser() === false) { $result = $db->selectList($tbl, "*", "(INSTR(`title`, '" . $s . "') > 0 OR\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSTR(`description`, '" . $s . "') > 0 )\r\n\t\t\t\t\tAND ( (`visible`=2) OR (`visible`=0 AND `userid`=" . $login->currentUserID() . ") )"); } else { $result = $db->selectList($tbl, "*", "(INSTR(`title`, '" . $s . "') > 0 OR\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSTR(`description`, '" . $s . "') > 0 ) \r\n\t\t\t\t\tAND ( (`visible`=2) OR (`visible`=0 AND `userid`=" . $login->currentUserID() . ") OR (`visible`=1) )"); } } if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('engines_calendar'); $title = $r['title']; $description = $r['description']; $url = makeURL('calendar', array('mode' => 'view', 'calendarid' => $r['calendarid'], 'day' => $r['start'])); $relevance = strcount($r['description'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } return $return; }
function smarty_function_makeurl($params, $template) { if (isset($params['mod'])) { $mod = $params['mod']; unset($params['mod']); return makeURL($mod, $params); } }
function GetArticlesOlder() { global $db, $ts, $comments; $articles = $db->selectList('article', '*', '`timestamp` < ' . $ts['2weeks'] . ' AND `published`=1', '`timestamp` DESC'); foreach ($articles as $i => $article) { $articles[$i]['url'] = makeURL('article', array('categoryid' => $article['categoryid'], 'articleid' => $article['articleid'])); $articles[$i]['comments'] = $comments->count('article', $article['articleid']); } return $articles; }
function getAllVisibleMinitools() { global $db; global $lang; $visibletools = $db->selectList('minitools', '`modename`'); for ($i = 0; $i < count($visibletools); $i++) { $visibletools[$i]['url'] = makeHTMLUrl($lang->get($visibletools[$i]['modename']), makeURL('minitools', array('mode' => $visibletools[$i]['modename']))); } return $visibletools; }
function getMembers() { global $db; $tbl_gr = MYSQL_TABLE_PREFIX . 'tournamentgroupregister'; $tbl_u = MYSQL_TABLE_PREFIX . 'users'; $members = $db->selectList($tbl_gr . '`, `' . $tbl_u, "*", "`tournamentid`=" . $this->tournamentid . " AND `groupid`=" . $this->id . "\r\n\t\t\t\tAND `" . $tbl_gr . "`.`memberid`=`" . $tbl_u . "`.`userid`"); foreach ($members as $i => $member) { $members[$i]['url'] = makeURL('profile', array('userid' => $member['userid'])); } return $members; }
function getPages() { global $db; $pages = $db->queryToList("\r\n\t\t\t\tselect `key` as k,\r\n\t\t\t\t(\r\n\t\t\t\tselect count(*) \r\n\t\t\t\tfrom " . MYSQL_TABLE_PREFIX . "content as c2\r\n\t\t\t\twhere c2.`key` = c.`key`\r\n\t\t\t\t) as version_count,\r\n\t\t\t\t(\r\n\t\t\t\tselect title\r\n\t\t\t\tfrom " . MYSQL_TABLE_PREFIX . "content as c3\r\n\t\t\t\twhere c3.`key` = c.`key`\r\n\t\t\t\torder by version desc\r\n\t\t\t\tlimit 1\r\n\t\t\t\t) as title\r\n\t\t\t\tfrom " . MYSQL_TABLE_PREFIX . "content as c\r\n\t\t\t\tgroup by `key`\r\n\t\t\t\torder by `key` asc\r\n\t\t\t"); if (count($pages) > 0) { foreach ($pages as $i => $v) { $pages[$i]['title'] = cutString($v['title']); $pages[$i]['edit_url'] = makeURL('admin', array('mode' => 'content', 'action' => 'edit', 'key' => $v['k'])); $pages[$i]['remove_url'] = makeURL('admin', array('mode' => 'content', 'action' => 'remove', 'key' => $v['k'])); $pages[$i]['url'] = makeURL($v['k']); } } return $pages; }
function get() { global $db, $login; $list = array(); if ($login->currentUser() !== false) { $list = $db->selectList($this->table, "*", "`userid`=" . $login->currentUserId()); if (count($list) > 0) { foreach ($list as $i => $l) { $list[$i]['url'] = makeURL($l['mod'], unserialize($l['params'])); } } } return $list; }
function getPolls($limit, $count, $orderby = "date", $orderhow = "DESC") { global $comments; $sql = $this->db->query("SELECT * FROM " . MYSQL_TABLE_PREFIX . "poll ORDER BY " . secureMySQL($orderby) . " " . secureMySQL($orderhow) . " LIMIT " . (int) $limit . "," . secureMySQL($count) . ";"); while ($result = mysql_fetch_assoc($sql)) { $result['name'] = makeHtmlURL(makeLineBreaks($result['name']), makeURL('poll', array('pollid' => $result['ID']))); $result['commenturl'] = makeURL('poll', array('pollid' => $result['ID'])) . "#comments"; $result['questions'] = $this->getQuestionsByPollID($result['ID']); $result['given_answers'] = $this->getSumOfAnswers($result['ID']); $result['comment_count'] = $comments->count('poll', $result['ID']); $result['allready_voted'] = 1; $polls[] = $result; } return $polls; }
function makeNews(&$comments, &$db, $table, $tbl_users, $start, $end, $title) { global $lng; $news = ''; $result = $db->query("SELECT * FROM `" . $table . "`, `" . $tbl_users . "`\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `" . $table . "`.`userid` = `" . $tbl_users . "`.`userid` \r\n\t\t\t\t\t\t\t\t\t\t\t\tAND `timestamp`>" . $start . " \r\n\t\t\t\t\t\t\t\t\t\t\t\tAND `timestamp`<" . $end . " \r\n\t\t\t\t\t\t\t\t\t\t\t\tAND (`language` = '" . secureMySQL($lng) . "' OR `language` = '')\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND (`domainid` = 0 OR `domainid` = " . getCurrentDomainIndex() . ")\r\n\t\t\t\t\t\t\t\t\t\t\t\tORDER BY `timestamp` DESC;"); while ($row = mysql_fetch_assoc($result)) { $row['time'] = timeElapsed($row['timestamp']); $row['url'] = makeURL('news', array('newsid' => $row['newsid'])); $row['text'] = stripslashes($row['text']); $row['title'] = stripslashes($row['title']); $row['user_url'] = makeURL('profile', array('userid' => $row['userid'])); $row['comments'] = $comments->count('news', $row['newsid']); $news[] = $row; } return array('title' => $title, 'news' => $news, 'news_count' => mysql_num_rows($result)); }
function listActive() { global $db; global $config; $limit = (int) $config->get('login', 'session-time'); $tbl_users = MYSQL_TABLE_PREFIX . 'users'; $time = time() - $limit; $sql = "SELECT * FROM `" . $tbl_users . "` WHERE `lastaction`>=" . $time; $result = $db->query($sql); while ($row = mysql_fetch_assoc($result)) { $row['str_lastaction'] = timeElapsed($row['lastaction']); $row['url'] = makeURL('profile', array('userid' => $row['userid'])); $list[] = $row; } return $list; }
function shoutbox($s) { global $db, $lang; $tbl = MYSQL_TABLE_PREFIX . 'shoutbox'; $return = array(); $result = $db->selectList($tbl, "*", "INSTR(`text`, '" . $s . "') > 0"); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('engines_shoutbox'); $title = $s; $description = $r['text']; $url = makeURL('shoutbox'); $relevance = strcount($r['text'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } return $return; }
function users($s) { global $db, $lang; $tbl = MYSQL_TABLE_PREFIX . 'users'; $return = array(); $result = $db->selectList($tbl, "*", "INSTR(`nickname`, '" . $s . "') > 0 OR\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSTR(`prename`, '" . $s . "') > 0"); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('engines_user'); $title = $r['nickname']; $description = $r['prename'] . " '" . $r['nickname'] . "' " . stripLastName($r['lastname']); $url = makeURL('profile', array('userid' => $r['userid'])); $relevance = strcount($r['prename'] . $r['nickname'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } return $return; }
function getList($eventid = 0) { global $db; global $register; if ((int) $eventid > 0) { $list = $db->selectList($this->table, "*", "`eventid`=" . (int) $eventid, "CASE `state` WHEN 1 THEN 0 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHEN 2 THEN 1 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHEN 3 THEN 2 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHEN 0 THEN 4 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tEND"); } else { $list = $db->selectList($this->table, "*", "1", "CASE `state` WHEN 1 THEN 0 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHEN 2 THEN 1 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHEN 3 THEN 2 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHEN 0 THEN 4 \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tEND"); } if (count($list) > 0) { foreach ($list as $i => $tournament) { $list[$i]['url'] = makeURL('tournament', array('tournamentid' => $tournament['tournamentid'])); $list[$i]['state'] = tournamentStateToString($tournament['state']); $list[$i]['joinstate'] = $register->getRegCount($tournament['tournamentid']) . " / " . $tournament['playerlimit']; } } return $list; }
function article($s) { global $db, $lang; $tbl = MYSQL_TABLE_PREFIX . 'article'; $return = array(); $result = $db->selectList($tbl, "*", "INSTR(`title`, '" . $s . "') > 0 OR\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSTR(`text`, '" . $s . "') > 0"); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('engines_article'); $title = $r['title']; $description = $r['preview']; $url = makeURL('article', array('articleid' => $r['articleid'])); $relevance = strcount($r['text'] . $r['title'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } return $return; }
function content($s) { global $db, $lang; $tbl = MYSQL_TABLE_PREFIX . 'content'; $return = array(); $result = $db->queryToList("select c.key, c.title, c.text, c.box_content\r\n\t\t\tfrom (\r\n\t\t\tselect `key`, max(version) as latest\r\n\t\t\tfrom " . $tbl . "\r\n\t\t\tgroup by `key`\r\n\t\t\t)\r\n\t\t\tas x\r\n\t\t\tinner join " . $tbl . " as c\r\n\t\t\ton c.key = x.key and c.version = x.latest\r\n\t\t\twhere title like '%" . $s . "%'\r\n\t\t\tor text like '%" . $s . "%'\r\n\t\t\tor box_content like '%" . $s . "%'"); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('engines_content'); $title = cutString($r['title']); $description = $r['text']; $url = makeURL($r['key']); $relevance = strcount($r['text'] . ' ' . $r['title'] . ' ' . $r['title'] . ' ' . $r['title'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } return $return; }
function media($s) { global $db, $lang; $tbl_cat = MYSQL_TABLE_PREFIX . 'media_categories'; $tbl_downloads = MYSQL_TABLE_PREFIX . 'media_downloads'; $tbl_images = MYSQL_TABLE_PREFIX . 'media_images'; $tbl_movies = MYSQL_TABLE_PREFIX . 'media_movies'; $return = array(); $result = $db->selectList($tbl_cat, "*", "INSTR(`name`, '" . $s . "') > 0"); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('category'); $title = $r['name']; $description = ''; $url = makeURL('media', array('categoryid' => $r['categoryid'])); $relevance = strcount($r['name'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } $result = $db->selectList($tbl_downloads, "*", "INSTR(`name`, '" . $s . "') > 0 OR INSTR(`description`, '" . $s . "') > 0"); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('download'); $title = $r['name']; $description = $r['description']; $url = makeURL('media', array('categoryid' => $r['categoryid'], 'downloadid' => $r['downloadid'])); $relevance = strcount($r['name'] . $r['description'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } $result = $db->selectList($tbl_movies, "*", "INSTR(`name`, '" . $s . "') > 0 OR INSTR(`description`, '" . $s . "') > 0"); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('movie'); $title = $r['name']; $description = $r['description']; $url = makeURL('media', array('categoryid' => $r['categoryid'], 'movieid' => $r['movieid'])); $relevance = strcount($r['name'] . $r['description'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } return $return; }
function board($s) { global $db, $lang; $return = array(); $tbl = MYSQL_TABLE_PREFIX . 'post'; $tbl_thread = MYSQL_TABLE_PREFIX . 'thread'; $result = $db->selectList($tbl, "*", "INSTR(`post`, '" . $s . "') > 0"); if (count($result) > 0) { foreach ($result as $i => $r) { $thread = $db->selectOneRow($tbl_thread, "*", "`threadid`=" . $r['threadid']); $engine = $lang->get('thread'); $title = $thread['thread']; $description = $r['post']; $url = makeURL('board', array('boardid' => $thread['boardid'], 'threadid' => $r['threadid'])); $relevance = strcount($r['post'], $s); $return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance); } } return $return; }
function bug($s) { global $db; global $lang; global $login; $tbl = MYSQL_TABLE_PREFIX . 'bugtracker_issues'; $return = array(); $result = $db->selectList($tbl, "*", "(INSTR(`summary`, '" . $s . "') > 0 OR\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSTR(`description`, '" . $s . "') > 0)"); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('engines_bug'); $title = $r['summary']; $description = $r['description']; $url = makeURL('bug', array('issueid' => $r['issueid'])); $relevance = strcount($r['summary'] . $r['description'], $s); @($return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance)); } } return $return; }
function inbox($s) { global $db; global $lang; global $login; $return = array(); $tbl = MYSQL_TABLE_PREFIX . 'inbox'; $result = $db->selectList($tbl, "*", "(INSTR(`subject`, '" . $s . "') > 0 OR\r\n\t\t\t\t\t\t\t\t\t\t\t\tINSTR(`message`, '" . $s . "') > 0) AND\r\n\t\t\t\t\t\t\t\t \t\t\t\t`recieverid`=" . $login->currentUserID()); if (count($result) > 0) { foreach ($result as $i => $r) { $engine = $lang->get('engines_inbox'); $title = $r['subject']; $description = $r['message']; $url = makeURL('pmbox', array('mode' => 'inbox', 'pmid' => $r['pmid'])); $relevance = strcount($r['message'] . $r['subject'], $s); @($return[] = array('engine' => $engine, 'title' => $title, 'description' => $description, 'url' => $url, 'relevance' => $relevance)); } } return $return; }
function makeTree($directory) { if (!is_dir($directory['path'])) { return; } @($dirlist = scandir($directory['path'])); $tree = array(); foreach ($dirlist as $dir) { if ($dir != '.' && $dir != '..') { $element = array(); $element['dir'] = is_dir($directory['path'] . '/' . $dir); $element['size'] = !is_dir($directory['path'] . '/' . $dir) ? filesize($directory['path'] . '/' . $dir) : 0; $element['name'] = $dir; $element['path'] = $directory['path'] . '/' . $dir; $element['children'] = makeTree($element); $element['url'] = makeURL('fileadmin', array('path' => $element['path'])); $tree[] = $element; } } return $tree; }
$smarty->assign('tables', $backup->listTables()); $smarty->assign('path', $template_dir . "/backup.tpl"); if (isset($_POST['doBackup'])) { @($b = $backup->backupTables($_POST['tables'])); if (isset($_POST['download'])) { $file = "backup-" . date("dmY-Hi") . ".xml"; header("Content-type: application/octet-stream"); header('Content-disposition: attachment; filename=' . $file); echo $b; die; } else { $smarty->assign('backup', $b); } } } else { $breadcrumbs->addElement($lang->get('restore'), makeURL($mod, array('mode' => 'backup', 'action' => 'restore'))); $smarty->assign('path', $template_dir . "/restore.tpl"); if (isset($_POST['doRestore'])) { $backup->restore($_POST['backup']); $notify->add($lang->get('backup'), $lang->get('backup_restored')); } if (isset($_POST['submit'])) { // set allowed file types $allowed_types = "(xml)"; // is really a file? if (is_uploaded_file($_FILES["file"]["tmp_name"])) { // valid extension? if (preg_match("/\\." . $allowed_types . "\$/i", $_FILES["file"]["name"])) { $h = fopen($_FILES["file"]["tmp_name"], "rb"); $fileContent = fread($h, filesize($_FILES["file"]["tmp_name"])); fclose($h);
$years = $months / 12; return add_s($years, 'year'); } else { return add_s($months, 'month'); } } function add_s($num, $word) { $num = floor($num); if ($num == 1) { return $num . ' ' . $word . ' ago'; } else { return $num . ' ' . $word . 's ago'; } } $query = $_REQUEST['search']; $jsonurl = "http://search.twitter.com/search.json?q=" . urlencode($query); $json = file_get_contents($jsonurl, 0, null, null); $json_output = json_decode($json); if (count($json_output->results) > 0) { foreach ($json_output->results as $result) { $time_since = time_since("{$result->created_at}"); echo '<div class="tweet">'; echo '<img width="48" height="48" src="' . "{$result->profile_image_url}" . '" class="left" />'; echo '<p><a class="from_user" href="http://twitter.com/' . "{$result->from_user}" . '">' . $result->from_user . ": </a>" . makeURL($result->text) . "</p>"; echo "<small>" . $time_since . " | From: " . html_entity_decode($result->source) . "</small>"; echo '</div>'; } } else { echo '<div class="tweet"><p>Sorry, no results found</p></div>'; }
<?php if ($eMail->getRegisterAdress() == '') { $notify->add($lang->get('error'), $lang->get('sender_mail_not_set')); } else { $smarty->assign('adress_set', true); } $smarty->assign('groups', $rights->getAllGroups()); $breadcrumbs->addElement($lang->get('circular_mail'), makeURL($mod, array('mode' => 'circular'))); $smarty->assign('path', $template_dir . "/circular.tpl");
} $ver = isset($_GET['version']) ? (int) $_GET['version'] : -1; $page = $content->getPage($_GET['key'], $ver); if ($ver == -1) { $ver = $page['version']; } @$smarty->assign('selected_version', $ver); $smarty->assign('content', $page); $assigned_groups = array_row($db->selectList('content_permissions', '*', "`key`='" . secureMySQL($_GET['key']) . "'"), 'groupid'); $smarty->assign('permissions', $assigned_groups); $breadcrumbs->addElement($page['title'], makeURL($_GET['key'])); $breadcrumbs->addElement($lang->get('edit'), makeURL($mod, array('mode' => 'content', 'action' => 'edit', 'key' => $_GET['key']))); $smarty->assign('path', $template_dir . "/content.edit.tpl"); break; case 'remove': if (isset($_POST['yes'])) { $content->removePage($_GET['key']); $notify->add($lang->get('content'), $lang->get('content_removed')); $log->add($mod, 'content ' . $_GET['key'] . ' removed'); } else { $breadcrumbs->addElement($lang->get('remove'), makeURL($mod, array('mode' => 'content', 'action' => 'remove', 'key' => $_GET['key']))); $smarty->assign('url_no', makeURL($mod, array('mode' => 'content'))); $smarty->assign('path', $template_dir . "/content.remove.tpl"); break; } default: $cont = $content->getPages(); $smarty->assign('content', $cont); $smarty->assign('add_url', makeURL($mod, array('mode' => 'content', 'action' => 'add'))); $smarty->assign('path', $template_dir . "/content.tpl"); }
<?php $breadcrumbs->addElement($lang->get('log'), makeURL($mod, array('mode' => 'log'))); $smarty->assign('path', $template_dir . "/log.tpl"); if ($log->mysqlIsEnabled()) { $list = $db->selectList($log->getTable(), "*", "1", "`timestamp` DESC"); if (count($list) > 0) { foreach ($list as $i => $l) { $list[$i]['time'] = '[ ' . date("d.m.Y", $l['timestamp']) . " | " . date("H:i.s", $l['timestamp']) . " ]"; } } $smarty->assign('list', $list); } $smarty->assign('filelist', $log->listFileLogs());
$events[$i]['seat'] = '-'; } } } $smarty->assign('events', $events); // buddylist if ($db->num_rows('menu', "`mod`='buddylist' AND `assigned_groupid`!=-1") > 0 || $db->num_rows('boxes', "`file`='buddylist' AND `visible`=1") > 0) { $smarty->assign('buddylist_enabled', true); if ($login->currentUser() !== false) { $smarty->assign('logged_in', true); } $tbl_b = MYSQL_TABLE_PREFIX . 'buddylist'; if (isset($_POST['buddy_request'])) { $db->insert($tbl_b, array('userid', 'buddyid'), array($login->currentUserID(), $u['userid'])); $notify->add($lang->get('buddies'), $lang->get('request_sent')); } if ($db->num_rows($tbl_b, " (`userid`=" . $login->currentUserID() . " AND `buddyid`=" . $u['userid'] . ")\r\n\t\t\t\t\t\t\t\t\t\tOR (`buddyid`=" . $login->currentUserID() . " AND `userid`=" . $u['userid'] . ")") > 0) { $smarty->assign('is_buddy', true); } else { $smarty->assign('is_buddy', false); } } // User Groups $usergroups = $rights->getGroups($u['userid'], 1); $smarty->assign('usergroups', $usergroups); } else { // include the template $smarty->assign('path', $template_dir . '/notfound.tpl'); } $smarty->assign('edit_personal_url', makeURL('usercp', array('mode' => 'personal')));
function makeEntryArrayHours($entries, &$maxCols) { $maxCols = 0; $day_view = array(); if (count($entries) > 0) { foreach ($entries as $entry) { $hour = (int) date("H", $entry['start']); $seconds = $entry['end'] - $entry['start']; if (date("i", $seconds) > 30 || $seconds <= 3600) { $rowspan = ceil($seconds / 60 / 60); } else { $rowspan = floor($seconds / 60 / 60); } // Check which column to put in for ($col = 0; $col <= $maxCols + 1; $col++) { $foundCol = true; for ($row = 0; $row < $rowspan; $row++) { if (isset($day_view[$hour + $row][$col])) { $foundCol = false; } } if ($foundCol) { $column = $col; break 1; } } $maxCols = $maxCols < $column ? $column : $maxCols; $day_view[$hour][$column]['start']['hour'] = date("H", $entry['start']); $day_view[$hour][$column]['start']['min'] = date("i", $entry['start']); $day_view[$hour][$column]['end']['hour'] = date("H", $entry['end']); $day_view[$hour][$column]['end']['min'] = date("i", $entry['end']); $day_view[$hour][$column]['rowspan'] = $rowspan; $day_view[$hour][$column]['title'] = makeHTMLURL($entry['title'], makeURL('calendar', array('mode' => 'view', 'calendarid' => $entry['calendarid']))); $day_view[$hour][$column]['description'] = nl2br($entry['description']); $day_view[$hour][$column]['calendarid'] = $entry['calendarid']; global $db; $color = $db->selectOneRow('calendar_categories', '*', "`categoryId`='" . $entry['categoryId'] . "'"); $day_view[$hour][$column]['backgroundcolor'] = strlen($color['backgroundcolor']) > 0 ? $color['backgroundcolor'] : "#57FF7E"; $day_view[$hour][$column]['fontcolor'] = strlen($color['fontcolor']) > 0 ? $color['fontcolor'] : "#000000"; for ($i = 1; $i < $rowspan; $i++) { $day_view[$hour + $i][$column]['rowspan'] = 0; } } } for ($i = 0; $i < 24; $i++) { $day_view[$i]['hour'] = $i; for ($j = 0; $j <= $maxCols; $j++) { if (!isset($day_view[$i][$j]['rowspan'])) { $day_view[$i][$j]['rowspan'] = 1; } } } ksort($day_view, SORT_NUMERIC); return $day_view; }
function dousperf($data, $user) { global $fld_sep, $val_sep; // This also defines how many worker fields there are $cols = array('#0000c0', '#00dd00', '#e06020', '#b020e0'); $nc = count($cols); $workers = 'all'; if (isset($_COOKIE['workers'])) { $w = substr(trim($_COOKIE['workers']), 0, 1024); if ($w !== false) { $wa = explode(',', $w, $nc + 1); if (count($wa) > $nc) { $w = ''; for ($i = 0; $i < $nc; $i++) { $w .= ($i == 0 ? '' : ',') . $wa[$i]; } } $workers = $w; } } $ans = getShiftData($user, $workers); $iCrap = strpos($_SERVER['HTTP_USER_AGENT'], 'iP'); if ($iCrap) { $vlines = false; } else { $vlines = true; } $pg = '<h1>User Shift Reward Performance</h1><br>'; if ($ans['STATUS'] == 'ok' and $ans['DATA'] != '') { addGBase(); addTips(); $cbx = array('skey' => 'shift key', 'slines' => 'shift lines', 'tkey' => 'time key', 'tlines' => 'time lines', 'over' => 'key overlap', 'smooth' => 'smooth', 'zerob' => 'zero based', 'utc' => 'utc'); $xon = array('skey' => 1, 'utc' => 1); if ($vlines === true) { $xon['slines'] = 1; } $pg .= '<form>'; $tt = "<ul class=tip><li>all = all workers</li><li>noname = worker with no workername</li>"; $tt .= "<li>or full workername without the username i.e. .worker or _worker</li>"; $tt .= "<li>add a '*' on the end to match multiple workers e.g. .S3*</li></ul>"; $pg .= "<span class=q onclick='tip(\"wtip\",6000)'>?</span>"; $pg .= "<span class=tip0><span class=notip id=wtip>{$tt}</span></span>"; $i = 0; $datacols = ''; $onch = " onchange='wch()'"; foreach ($cols as $col) { $i++; $pg .= " <span class=nb><font color={$col}>Worker{$i}"; $pg .= "<input type=checkbox id=lin{$i} checked onclick='godrw(0)'>:</font>"; $pg .= "<input type=text size=10 id=worker{$i}{$onch}> </span>"; if ($i > 1) { $datacols .= ','; } $datacols .= $col; } $oncl = "wch();location.href=\"" . makeURL('usperf') . "\""; $pg .= "<button type=button onclick='{$oncl}'>Update</button></form><div>"; foreach ($cbx as $nam => $txt) { $pg .= ' <span class=nb>'; $pg .= "<input type=checkbox id={$nam} onclick='gact(this)'>"; $pg .= "{$txt} </span>"; } $pg .= '</div>'; $pg .= '<div id=can0><canvas id=can width=1 height=1>'; $pg .= 'A graph will show here if your browser supports html5/canvas'; $pg .= "</canvas></div>\n"; $data = str_replace(array("\\", "'"), array("\\\\", "\\'"), $ans['DATA']); $data .= $fld_sep . 'cols' . $val_sep . $datacols; $pg .= "<script type='text/javascript'>\n"; $pg .= uspg($nc, '#ff0000', '#fff0f0'); $pg .= "\nfunction godrw(f){var cbx=["; $comma = ''; foreach ($cbx as $nam => $txt) { $pg .= "{$comma}'{$nam}'"; $comma = ','; } $pg .= '];if(f){var xon={};'; foreach ($xon as $nam => $val) { $pg .= "xon['{$nam}']=1;"; } $pg .= "doinit(cbx,xon)}dodrw('{$data}',cbx)};godrw(1);</script>\n"; } return $pg; }
<?php $lang->addModSpecificLocalization('buddylist'); if ($login->currentUser() !== false) { $dur = (int) $config->get('core', 'stat-duration'); $tbl_b = MYSQL_TABLE_PREFIX . 'buddylist'; $tbl_u = MYSQL_TABLE_PREFIX . 'users'; // list existing buddies $buddies = $db->selectList($tbl_b . "`, `" . $tbl_u, "*", "((\r\n\t\t\t\t\t\t`" . $tbl_b . "`.`userid`=" . $login->currentUserID() . " \r\n\t\t\t\t\t\tAND `" . $tbl_b . "`.`buddyid` = `" . $tbl_u . "`.`userid`\r\n\t\t\t\t\t)\r\n\t\t\t\t\tOR (\r\n\t\t\t\t\t\t`" . $tbl_b . "`.`buddyid`=" . $login->currentUserID() . " \r\n\t\t\t\t\t\tAND `" . $tbl_b . "`.`userid` = `" . $tbl_u . "`.`userid`\r\n\t\t\t\t\t)\r\n\t\t\t\t\t) AND `" . $tbl_b . "`.`accepted`=1"); if (null != $buddies && count($buddies) > 0) { foreach ($buddies as $index => $buddy) { if ($buddy['lastaction'] + $dur > time()) { $buddies[$index]['online'] = true; } else { $buddies[$index]['online'] = false; } $buddies[$index]['url'] = makeURL('profile', array('userid' => $buddy['userid'])); } } $smarty->assign('box_buddies', $buddies); $tpl_file = $template_dir . "/default.tpl"; } else { $tpl_file = $template_dir . "/login.tpl"; } $visible = true;
function find($needle) { global $user, $bbcode; $sql = "SELECT * FROM `" . $this->table . "` WHERE `text` LIKE '%" . secureMySQL($needle) . "%' LIMIT 20;"; $result = $this->db->query($sql); $list = array(); while ($row = mysql_fetch_assoc($result)) { $u = $user->getUserByID($row['userid']); $l['time'] = timeElapsed($row['timestamp']); $l['nickname'] = $u['nickname']; $l['text'] = $bbcode->parse($row['text']); $l['mod'] = $row['mod']; $l['url'] = makeURL('profile', array('userid' => $row['userid'])); $list[] = $l; } return $list; }