Commit 1704da03 authored by Imran Hussain's avatar Imran Hussain

Run a code reformatting tool against the sucsite php code.

parent e2bf8da2
......@@ -8,34 +8,34 @@ $members = new Members;
$banana_index = array_search("Bananas", $pathlist);
if ((sizeof($pathlist) > $banana_index + 1) && (trim($pathlist[$banana_index + 1]) != "")) {
$mode = "detail";
$who = $pathlist[$banana_index + 1];
$mode = "detail";
$who = $pathlist[$banana_index + 1];
} else {
// User wasn't looking for anything in particular, so bump them to the Members page
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://$preferred_hostname$baseurl/Community/Members/");
// User wasn't looking for anything in particular, so bump them to the Members page
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://$preferred_hostname$baseurl/Community/Members/");
}
/* redirect requests for members' bananas to Members component. Only serve banana info for non-members (e.g. LIS ;-)) */
if (count($members->memberView($who)) > 0) {
// this is actually a real member, so serve a redirect and let Members handle it
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://$preferred_hostname$baseurl/Community/Members/$who");
// this is actually a real member, so serve a redirect and let Members handle it
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://$preferred_hostname$baseurl/Community/Members/$who");
} else {
// banana admin bits
if ($mode == "detail") {
if ($session->loggedin) {
include("../lib/banana-admin.php");
}
}
// attempt to find some bananas for this name in the database
$smarty->assign("awards",$DB->GetAll("SELECT *, date_trunc('second', whn) FROM awards WHERE username=? ORDER BY whn DESC", array($who)));
// banana admin bits
if ($mode == "detail") {
if ($session->loggedin) {
include("../lib/banana-admin.php");
}
}
// attempt to find some bananas for this name in the database
$smarty->assign("awards", $DB->GetAll("SELECT *, date_trunc('second', whn) FROM awards WHERE username=? ORDER BY whn DESC", array($who)));
}
if (isset($who))
$smarty->assign('who', "$who");
$smarty->assign('who', "$who");
$smarty->assign('mode', "$mode");
......@@ -46,5 +46,4 @@ $smarty->assign('title', "Banana Awards");
$smarty->assign('body', $result);
?>
<?php
function listdir($mypath, $recurse, $summaries) {
global $DB, $base;
function listdir($mypath, $recurse, $summaries)
{
global $DB, $base;
$dirlist = @scandir($base."static".$mypath);
$output = array();
if (is_array($dirlist)) foreach($dirlist as $file) {
// Hide files starting with a .
if ($file[0]!=".") {
$element = array();
if (!is_dir($base."static".$mypath."/".$file)) {
$pagename = preg_replace("/\.txt/", "", $file);
if ($summaries) $element['summary'] = $DB->GetOne("select summary from static where path=?", array($mypath."/".$pagename));
if ($pagename!=@$lastdir) $output[$pagename]=str_replace("_", " ", $element);
} else {
if ($recurse) $element['file']=listdir($mypath."/".$file, $recurse, $summaries);
if ($summaries) $element['summary'] = $DB->GetOne("select summary from static where path=?", array($mypath."/".$file));
$output[$file]=$element;
$lastdir=$file;
}
}
}
return $output;
$dirlist = @scandir($base . "static" . $mypath);
$output = array();
if (is_array($dirlist)) foreach ($dirlist as $file) {
// Hide files starting with a .
if ($file[0] != ".") {
$element = array();
if (!is_dir($base . "static" . $mypath . "/" . $file)) {
$pagename = preg_replace("/\.txt/", "", $file);
if ($summaries) $element['summary'] = $DB->GetOne("select summary from static where path=?", array($mypath . "/" . $pagename));
if ($pagename != @$lastdir) $output[$pagename] = str_replace("_", " ", $element);
} else {
if ($recurse) $element['file'] = listdir($mypath . "/" . $file, $recurse, $summaries);
if ($summaries) $element['summary'] = $DB->GetOne("select summary from static where path=?", array($mypath . "/" . $file));
$output[$file] = $element;
$lastdir = $file;
}
}
}
return $output;
}
if ($path==$component['path']) {
$dirlist = listdir($component['path'], TRUE, TRUE);
if ($path == $component['path']) {
$dirlist = listdir($component['path'], TRUE, TRUE);
$smarty->assign('rootnode', $component['path']);
$smarty->assign('dirlist', $dirlist);
$output = $smarty->fetch('contents.tpl');
$smarty->assign('title', $pathlist[1]);
$smarty->assign('body', $output);
$smarty->assign('rootnode', $component['path']);
$smarty->assign('dirlist', $dirlist);
$output = $smarty->fetch('contents.tpl');
$smarty->assign('title', $pathlist[1]);
$smarty->assign('body', $output);
} else {
include("static.php");
include("static.php");
if ($title!="File not found") {
if (!is_dir($base."static".$path)) {
$pos = strrpos($path, "/");
$path = substr($path, 0, $pos);
}
if ($title != "File not found") {
if (!is_dir($base . "static" . $path)) {
$pos = strrpos($path, "/");
$path = substr($path, 0, $pos);
}
$dirlist = listdir($path, FALSE, FALSE);
$smarty->assign('rootnode', $path);
$smarty->assign('data', $dirlist);
$smarty->assign('level', 0);
if (!isset($_REQUEST['action'])) {
$output = $smarty->fetch('contents-loop.tpl');
$smarty->assign("secondary", "<div class=\"cbb\"><h3>In this section</h3>".$output."</div>");
}
}
$dirlist = listdir($path, FALSE, FALSE);
$smarty->assign('rootnode', $path);
$smarty->assign('data', $dirlist);
$smarty->assign('level', 0);
if (!isset($_REQUEST['action'])) {
$output = $smarty->fetch('contents-loop.tpl');
$smarty->assign("secondary", "<div class=\"cbb\"><h3>In this section</h3>" . $output . "</div>");
}
}
}
?>
<?php
$output = "<pre>".print_r($session, true)."</pre>";
$output = "<pre>" . print_r($session, true) . "</pre>";
$smarty->assign("title", "Debug");
$smarty->assign("body", $output);
?>
<?
exec("/usr/local/bin/shame.py -a", $Shame);
for ( $i=1 ; $i < (count($Shame) - 1); $i++)
{
list($space, $place, $user, $size) = preg_split("/ +/", $Shame[$i]);
if ($i <= 12)
{
$item[]=$user;
$slice[]=preg_replace('/M/', '', ${size});
}
else {
$otherSize += preg_replace('/M/', '', ${size});
}
}
exec("/usr/local/bin/shame.py -a", $Shame);
for ($i = 1; $i < (count($Shame) - 1); $i++) {
list($space, $place, $user, $size) = preg_split("/ +/", $Shame[$i]);
if ($i <= 12) {
$item[] = $user;
$slice[] = preg_replace('/M/', '', ${size});
} else {
$otherSize += preg_replace('/M/', '', ${size});
}
}
// $itemName[]="Other";
// $sliceSize[]=$otherSize;
$slice = array_merge(array($otherSize),$slice);
$item = array_merge(array("Other"), $item);
$slice = array_merge(array($otherSize), $slice);
$item = array_merge(array("Other"), $item);
/* echo "<pre>";
print_r($slice);
print_r($item);*/
include("../../lib/pieChart.php");
piechart("Top 12 Users of disk space", $slice, $item, 1)
include("../../lib/pieChart.php");
piechart("Top 12 Users of disk space", $slice, $item, 1)
?>
<? exec("/usr/local/bin/shame.py -a", $Shame);
$max=10; //SET to number of users to display
$smarty->assign('title',"The SUCS Hall of Shame");
<? exec("/usr/local/bin/shame.py -a", $Shame);
$max = 10; //SET to number of users to display
$smarty->assign('title', "The SUCS Hall of Shame");
//$o="<div style='text-align: center;'><img src=\"/images/disk.graph.php\" alt=\"pie chart of top 12 disk users\"/></div>";
$o.="<table align=\"center\">\n";
$o.="\t<tr><th align=\"center\">User</th><th align=\"center\">Home Directory Size</th></tr>\n";
for ( $i=1 ; $i < 13 /*(count($Shame) - 1)*/; $i++)
{
list($space, $place, $user, $size) = preg_split("/ +/", $Shame[$i]);
if ($size > 0)
$o.="\t<tr><td align=\"center\">$user</td><td align=\"center\">${size}B</td></tr>\n";
}
exec("df -m /home",$dfraw);
$dfout = preg_split('/[ ]+/', $dfraw[1]);
$o.="\t<tr><td align=\"center\" colspan=\"2\">".floor($dfout[2]/1024)."GB used of ".floor($dfout[1]/1024). "GB (".floor($dfout[3]/1024)."GB available)</td></tr>\n";
$o.="</table>\n";
$o.=$Shame[count($Shame) - 1];
$o.="<br />\n";
//readfile("tail.html");
$out="<script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>
$o .= "<table align=\"center\">\n";
$o .= "\t<tr><th align=\"center\">User</th><th align=\"center\">Home Directory Size</th></tr>\n";
for ($i = 1; $i < 13 /*(count($Shame) - 1)*/; $i++) {
list($space, $place, $user, $size) = preg_split("/ +/", $Shame[$i]);
if ($size > 0)
$o .= "\t<tr><td align=\"center\">$user</td><td align=\"center\">${size}B</td></tr>\n";
}
exec("df -m /home", $dfraw);
$dfout = preg_split('/[ ]+/', $dfraw[1]);
$o .= "\t<tr><td align=\"center\" colspan=\"2\">" . floor($dfout[2] / 1024) . "GB used of " . floor($dfout[1] / 1024) . "GB (" . floor($dfout[3] / 1024) . "GB available)</td></tr>\n";
$o .= "</table>\n";
$o .= $Shame[count($Shame) - 1];
$o .= "<br />\n";
//readfile("tail.html");
$out = "<script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>
<script type=\"text/javascript\">
google.load(\"visualization\", \"1\", {packages:[\"corechart\"]});
google.setOnLoadCallback(drawChart);
......@@ -26,26 +25,28 @@
var data = new google.visualization.DataTable();
data.addColumn('string', 'User');
data.addColumn('number', 'Megabytes in use');
data.addRows(".(count($Shame) - 1).");\n";
for( $i=0; $i<(count($Shame) - 3); $i++ ){
list($u,$d)=parseLine($Shame[$i+1]);
$out.="data.setValue(".($i+1).", 0, '".$u."');\n";
$out.="data.setValue(".($i+1).", 1,".$d.");\n";
}
$others=0;
for ( $i=$max; $i<count($data); $i++ ) {
list($u,$d)=parseLine($Shame[$i+1]);
$others+=$d;
}
$out.="data.setValue(0, 0, 'Free Space');\ndata.setValue(0,1,".$dfout[3]." );\n";
$out.="\t\tvar chart = new google.visualization.PieChart(document.getElementById('chart_div'));
data.addRows(" . (count($Shame) - 1) . ");\n";
for ($i = 0; $i < (count($Shame) - 3); $i++) {
list($u, $d) = parseLine($Shame[$i + 1]);
$out .= "data.setValue(" . ($i + 1) . ", 0, '" . $u . "');\n";
$out .= "data.setValue(" . ($i + 1) . ", 1," . $d . ");\n";
}
$others = 0;
for ($i = $max; $i < count($data); $i++) {
list($u, $d) = parseLine($Shame[$i + 1]);
$others += $d;
}
$out .= "data.setValue(0, 0, 'Free Space');\ndata.setValue(0,1," . $dfout[3] . " );\n";
$out .= "\t\tvar chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {width: 500, height: 360, backgroundColor: 'none', is3D: true, title: 'Disk Usage',sliceVisibilityThreshold: 1/180});
}
</script>";
$out.="<div id='chart_div' align='center'></div>";
$smarty->assign('body', ($out.$o));
function parseLine($l){
$fields=explode("|",preg_filter("/[ ]+/","|",$l));
return array(trim($fields[2]),trim(str_replace("M","",$fields[3])));
$out .= "<div id='chart_div' align='center'></div>";
$smarty->assign('body', ($out . $o));
function parseLine($l)
{
$fields = explode("|", preg_filter("/[ ]+/", "|", $l));
return array(trim($fields[2]), trim(str_replace("M", "", $fields[3])));
}
?>
This diff is collapsed.
<?php
if (strtotime('now') > strtotime(ELECTION_START) && strtotime('now') < strtotime(ELECTION_END) && !$DB->GetOne("SELECT username FROM election_votes where username=?", $session->username)) {
$messages['info'][] = "<strong>You haven't voted yet</strong><br />\nThe SUCS Executive Election is in progress. <a href=\"/Vote\">Vote now!</a>\n";
$messages['info'][] = "<strong>You haven't voted yet</strong><br />\nThe SUCS Executive Election is in progress. <a href=\"/Vote\">Vote now!</a>\n";
}
......
......@@ -2,56 +2,56 @@
$body = "";
$email_to = "joinus@sucs.org";
$_REQUEST['email'] = str_replace("\n", "", $_REQUEST['email']);
$headers = "From: ".$_REQUEST['email']."\n"."Reply-to: ".$_REQUEST['email'];
$subject = "Join request for user ".$_REQUEST['uname'];
$headers = "From: " . $_REQUEST['email'] . "\n" . "Reply-to: " . $_REQUEST['email'];
$subject = "Join request for user " . $_REQUEST['uname'];
// Perform data integrity checks
// Full name
if (preg_match("/[^\p{L}- ]/iu", $_REQUEST['realname'])) {
$body .= "<p>That's a suspiciously unusual-looking name, <strong>" . htmlentities($_REQUEST['realname']) . "</strong>.</p>\n";
$body .= "<p>Please click <em>Back</em> and correct it.</p>\n";
$body .= "<p>That's a suspiciously unusual-looking name, <strong>" . htmlentities($_REQUEST['realname']) . "</strong>.</p>\n";
$body .= "<p>Please click <em>Back</em> and correct it.</p>\n";
} else {
// Student number
if (!is_numeric($_REQUEST['student_number']) || strlen($_REQUEST['student_number']) <> 6) {
$body .= "<p>The student number <strong>" . htmlentities($_REQUEST['student_number']) . "</strong> appears not to be valid.</p>\n";
$body .= "<p>Please click <em>Back</em> and correct it.</p>\n";
} else {
if (!is_numeric($_REQUEST['student_number']) || strlen($_REQUEST['student_number']) <> 6) {
$body .= "<p>The student number <strong>" . htmlentities($_REQUEST['student_number']) . "</strong> appears not to be valid.</p>\n";
$body .= "<p>Please click <em>Back</em> and correct it.</p>\n";
} else {
// Email address
list($username, $maildomain) = preg_split("/@/", $_REQUEST['email']);
if (!checkdnsrr($maildomain, "MX") && !checkdnsrr($maildomain)) {
$body .= "<p>The email address <strong>" . htmlentities($_REQUEST['email']) . "</strong> appears not to be valid.</p>\n";
$body .= "<p>Please click <em>Back</em> and correct it.</p>\n";
} else {
list($username, $maildomain) = preg_split("/@/", $_REQUEST['email']);
if (!checkdnsrr($maildomain, "MX") && !checkdnsrr($maildomain)) {
$body .= "<p>The email address <strong>" . htmlentities($_REQUEST['email']) . "</strong> appears not to be valid.</p>\n";
$body .= "<p>Please click <em>Back</em> and correct it.</p>\n";
} else {
// Username
// This test is rather inadequate. Needs improving
if (!preg_match("/^[a-z0-9_]*$/i", $_REQUEST['uname'])) {
$body .= "<p>Usernames can only contain letters, numbers and underscores(_).</p>\n";
$body .= "<p>Please click <em>Back</em> and choose a different one.</p>\n";
} else {
// This test is rather inadequate. Needs improving
if (!preg_match("/^[a-z0-9_]*$/i", $_REQUEST['uname'])) {
$body .= "<p>Usernames can only contain letters, numbers and underscores(_).</p>\n";
$body .= "<p>Please click <em>Back</em> and choose a different one.</p>\n";
} else {
// We're good to go
$address = "http";
if ($_SERVER['HTTPS']) $address .= "s";
$address .= "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ;
$email_body = "This email was automatically created by the SUCS Website.\n\n";
$email_body .= "It was created by " . $address . "\n";
$email_body .= "from IP " . $_SERVER['REMOTE_ADDR'] . " on " . date("r") . "\n\n";
$email_body .= "The details of the request are as follows:\n\n";
$email_body .= " Real name ............ {$_REQUEST['realname']}\n";
$email_body .= " Student number ....... {$_REQUEST['student_number']}\n";
$email_body .= " Email address ........ {$_REQUEST['email']}\n";
$email_body .= " Requested username ... {$_REQUEST['uname']}\n\n";
$email_body .= "Please reply to this email, providing the user with details of\n";
$email_body .= "how to join.\n\n";
$email_body .= "-- \nSUCS Website\n";
$address = "http";
if ($_SERVER['HTTPS']) $address .= "s";
$address .= "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$email_body = "This email was automatically created by the SUCS Website.\n\n";
$email_body .= "It was created by " . $address . "\n";
$email_body .= "from IP " . $_SERVER['REMOTE_ADDR'] . " on " . date("r") . "\n\n";
$email_body .= "The details of the request are as follows:\n\n";
$email_body .= " Real name ............ {$_REQUEST['realname']}\n";
$email_body .= " Student number ....... {$_REQUEST['student_number']}\n";
$email_body .= " Email address ........ {$_REQUEST['email']}\n";
$email_body .= " Requested username ... {$_REQUEST['uname']}\n\n";
$email_body .= "Please reply to this email, providing the user with details of\n";
$email_body .= "how to join.\n\n";
$email_body .= "-- \nSUCS Website\n";
mail($email_to, $subject, $email_body, $headers);
mail($email_to, $subject, $email_body, $headers);
$body .= "<p>Thank you for your request to join SUCS.</p>";
$body .= "<p>Someone from our admin team will email you shortly.</p>";
} // username
} // email
} // student number
$body .= "<p>Thank you for your request to join SUCS.</p>";
$body .= "<p>Someone from our admin team will email you shortly.</p>";
} // username
} // email
} // student number
} // full name
$smarty->assign("body", $body);
......
......@@ -6,97 +6,97 @@
$permission = "sucsstaff";
$eventtable = "events";
$eventcategories = array("Technical","Talks","Gaming","Social","Misc");
$eventcategories = array("Technical", "Talks", "Gaming", "Social", "Misc");
$smarty->assign("event_categories", $eventcategories);
$events_index = array_search("Events", $pathlist);
if (isset($pathlist[$events_index + 1])) {
list($eventcat, $eventid) = preg_split("/_/", $pathlist[$events_index + 1]);
if (!in_array($eventcat, $eventcategories)) {
trigger_error("Invalid category specified", E_USER_ERROR);
unset($eventcat, $eventid);
} elseif (!ctype_digit($eventid)) {
trigger_error("Invalid event specified", E_USER_ERROR);
print_r($eventid);
unset($eventcat, $eventid);
}
list($eventcat, $eventid) = preg_split("/_/", $pathlist[$events_index + 1]);
if (!in_array($eventcat, $eventcategories)) {
trigger_error("Invalid category specified", E_USER_ERROR);
unset($eventcat, $eventid);
} elseif (!ctype_digit($eventid)) {
trigger_error("Invalid event specified", E_USER_ERROR);
print_r($eventid);
unset($eventcat, $eventid);
}
}
if (isset($session->groups[$permission])) {
$smarty->assign("editable", true);
$action = @$_REQUEST['action'];
// process form actions with side-effects first
switch ($action) {
case "save":
$record['name'] = $_REQUEST['name'];
$record['description'] = $_REQUEST['description'];
$record['location'] = $_REQUEST['location'];
// reconstruct date/time
$datetime = $_REQUEST['Date_Year'];
$datetime .= str_pad((int) $_REQUEST['Date_Month'],2,'0',STR_PAD_LEFT);
$datetime .= str_pad((int) $_REQUEST['Date_Day'],2,'0',STR_PAD_LEFT);
$datetime .= " ".$_REQUEST['Time_Hour'];
$datetime .= ":".$_REQUEST['Time_Minute'];
$record['whn'] = $datetime;
$record['category'] = $_REQUEST['category'];
$id = @$_REQUEST['id'];
// this may be an existing event which needs to be updated
if (ctype_digit($id)) {
$DB->AutoExecute($eventtable, $record, 'UPDATE', "id=".$id);
} else {
$DB->AutoExecute($eventtable, $record, 'INSERT');
}
unset($action);
break;
$smarty->assign("editable", true);
$action = @$_REQUEST['action'];
// process form actions with side-effects first
switch ($action) {
case "save":
$record['name'] = $_REQUEST['name'];
$record['description'] = $_REQUEST['description'];
$record['location'] = $_REQUEST['location'];
// reconstruct date/time
$datetime = $_REQUEST['Date_Year'];
$datetime .= str_pad((int)$_REQUEST['Date_Month'], 2, '0', STR_PAD_LEFT);
$datetime .= str_pad((int)$_REQUEST['Date_Day'], 2, '0', STR_PAD_LEFT);
$datetime .= " " . $_REQUEST['Time_Hour'];
$datetime .= ":" . $_REQUEST['Time_Minute'];
$record['whn'] = $datetime;
$record['category'] = $_REQUEST['category'];
$id = @$_REQUEST['id'];
// this may be an existing event which needs to be updated
if (ctype_digit($id)) {
$DB->AutoExecute($eventtable, $record, 'UPDATE', "id=" . $id);
} else {
$DB->AutoExecute($eventtable, $record, 'INSERT');
}
unset($action);
break;
}
}
if (isset($session->groups[$permission]) && isset($action)) {
switch($action) {
case "create":
$event = array("id" => "*");
$body = $smarty->fetch("event_edit.tpl");
break;
case "edit":
if (isset($eventcat) && isset($eventid)) {
$event = $DB->GetRow("SELECT * FROM $eventtable WHERE id=?", array($eventid));
//make tastier breadcrumbs
$pathlist[$events_index + 1] = $event['name'];
$smarty->assign("event", $event);
$body = $smarty->fetch("event_edit.tpl");
}
break;
}
switch ($action) {
case "create":
$event = array("id" => "*");
$body = $smarty->fetch("event_edit.tpl");
break;
case "edit":
if (isset($eventcat) && isset($eventid)) {
$event = $DB->GetRow("SELECT * FROM $eventtable WHERE id=?", array($eventid));
//make tastier breadcrumbs
$pathlist[$events_index + 1] = $event['name'];
$smarty->assign("event", $event);
$body = $smarty->fetch("event_edit.tpl");
}
break;
}
} else {
// not logged in, or no special action required
if (isset($eventcat) && isset($eventid)) {
$event = $DB->GetRow("SELECT * FROM $eventtable WHERE id=?", array($eventid));
// not logged in, or no special action required
if (isset($eventcat) && isset($eventid)) {
$event = $DB->GetRow("SELECT * FROM $eventtable WHERE id=?", array($eventid));
//make tastier breadcrumbs
$pathlist[$events_index + 1] = $event['name'];
//make tastier breadcrumbs
$pathlist[$events_index + 1] = $event['name'];
$smarty->assign("event", $event);
$body = $smarty->fetch("event.tpl");
} else {
$events = $DB->GetAll("SELECT *,date_part('epoch', whn) as whn_timestamp
$smarty->assign("event", $event);
$body = $smarty->fetch("event.tpl");
} else {
$events = $DB->GetAll("SELECT *,date_part('epoch', whn) as whn_timestamp
FROM $eventtable WHERE date_trunc('day', whn) >= date_trunc('day',NOW()) ORDER BY whn ASC");
$oldevents = $DB->GetAll("SELECT *,date_part('epoch', whn) as whn_timestamp
$oldevents = $DB->GetAll("SELECT *,date_part('epoch', whn) as whn_timestamp
FROM $eventtable WHERE date_trunc('day', whn) < date_trunc('day', NOW()) ORDER BY whn DESC LIMIT 3");
$smarty->assign("events", $events);
$smarty->assign("oldevents", $oldevents);
$body = $smarty->fetch("events.tpl");
}
$smarty->assign("events", $events);
$smarty->assign("oldevents", $oldevents);
$body = $smarty->fetch("events.tpl");
}
}
$smarty->assign("body", $body);
......
......@@ -9,22 +9,22 @@ $cal = new vcalendar();
$cal->setConfig('unique_id', 'sucs.org');
$cal->setProperty('method', 'PUBLISH');
$cal->setProperty('x-wr-calname', "SUCS Events Calendar");
$cal->setProperty('X-WR-CALDESC',
"Upcoming events for members of the Swansea University Computer Society");
$cal->setProperty('X-WR-CALDESC',
"Upcoming events for members of the Swansea University Computer Society");
$cal->setProperty('X-WR-TIMEZONE', 'Europe/London');
//populate with upcoming events
$events = $DB->GetAll("SELECT * FROM events WHERE
date_trunc('day', whn) >= date_trunc('day', NOW()) ORDER BY whn ASC");
foreach($events as $event) {
$vevent = new vevent();
$vevent->setProperty('dtstart', $event['whn']);
$vevent->setProperty('LOCATION', $event['location']);
$vevent->setProperty('summary', $event['name']);
$vevent->setProperty('description', $event['description']);
$vevent->setProperty('categories', $event['category']);
$cal -> setComponent($vevent);
foreach ($events as $event) {
$vevent = new vevent();
$vevent->setProperty('dtstart', $event['whn']);
$vevent->setProperty('LOCATION', $event['location']);
$vevent->setProperty('summary', $event['name']);
$vevent->setProperty('description', $event['description']);
$vevent->setProperty('categories', $event['category']);
$cal->setComponent($vevent);
}
//spit out a shiny new iCal file
......
<?php
$smarty->assign("news",$DB->GetArray("(SELECT * FROM news WHERE expiry > now() ORDER BY date DESC LIMIT 3) UNION SELECT * FROM news WHERE sticky=true and expiry > now() ORDER BY date DESC"));
$smarty->assign("news", $DB->GetArray("(SELECT * FROM news WHERE expiry > now() ORDER BY date DESC LIMIT 3) UNION SELECT * FROM news WHERE sticky=true and expiry > now() ORDER BY date DESC"));
$output = $smarty->fetch("front.tpl");
$smarty->assign("title", "Home");
$smarty->assign("body", $output);
if (!$session->loggedin) {
$output = file_get_contents("../static/fragments/Join.txt");
$output = file_get_contents("../static/fragments/Join.txt");
} else {
$output = "<div class=\"cbb\"><h3>You are logged in</h3><p>If you would like to contribute to the site or report a bug, please contact imranh.</p></div>";
$output = "<div class=\"cbb\"><h3>You are logged in</h3><p style=\"text-align: center;\">Why not join our <a href=\"#\" onclick=\"window.open('/mw/','Milliways','height=600,width=800,menubar=no,resizable=yes,location=no,directories=no,scrollbars=yes,status=no,toolbar=no')\" style=\"font-size: 150%; font-weight: bold; color: #ffc62b;\">Live Chat</a>?</p></div>";
$output = "<div class=\"cbb\"><h3>You are logged in</h3><p>If you would like to contribute to the site or report a bug, please contact imranh.</p></div>";
$output = "<div class=\"cbb\"><h3>You are logged in</h3><p style=\"text-align: center;\">Why not join our <a href=\"#\" onclick=\"window.open('/mw/','Milliways','height=600,width=800,menubar=no,resizable=yes,location=no,directories=no,scrollbars=yes,status=no,toolbar=no')\" style=\"font-size: 150%; font-weight: bold; color: #ffc62b;\">Live Chat</a>?</p></div>";
//include('users.php');
//$output .= $result;
include('electionreminder.php');
$output .= $result;
include('electionreminder.php');
$output .= $result;
}
$output .= "<div class=\"cbb\"><h3>SUCS Tools</h3><p>Download the SUCS Tools to make it easier to access SUCS services from your computer.</p><ul><li><a href=\"/files/sucstools-latest.exe\">SUCS Tools for Windows</a></li><li><a href=\"/files/SUCS-latest.dmg\">SUCS Tools for Mac OS X</a></li></ul><p>More information about the tools is available in \"<a href=\"/Knowledge/Help/SUCS%20Services/Using%20the%20SUCS%20Tools\">Using the SUCS Tools</a>\".</p></div>";
$smarty->assign("secondary",$output);
$smarty->assign("secondary", $output);
?>
......@@ -9,5 +9,5 @@ $smarty->assign("title", "Games");
$smarty->assign("body", $output);
$output = file_get_contents("../static/fragments/Games-secondary.txt");
$smarty->assign("secondary",$output);
$smarty->assign("secondary", $output);
?>
<?
$out = exec("/usr/bin/id");
$smarty->assign("body",$out);
$out = exec("/usr/bin/id");
$smarty->assign("body", $out);