Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • osian/sucs-site
  • kais58/sucs-site
  • imranh/sucs-site
  • foshjedi2004/sucs-site
  • gigosaurus/sucs-site
  • matstn/sucs-site
  • ripp_/sucs-site
  • eggnog/sucs-site
  • sucssite/sucs-site
  • elbows/sucs-site
  • realitykiller/sucs-site
  • crox/sucs-site
  • vectre/sucs-site
  • welshbyte/sucs-site
  • paperclipman/sucs-site
15 results
Show changes
Commits on Source (433)
Showing with 454 additions and 841 deletions
# Some of the files that are generated by the setup script don't want to be version controlled.
# To that end I have added this .gitignore file to ignore the following files and folders
# This is the generated .htaccess
htdocs/.htaccess
# Generated settings.php file
settings.php
# Compiled templates_c
templates_c/
# Password file for the su-api thing
suapi.inc.php
# lastsnap.jpg from cam
htdocs/images/lastsnap.jpg
\ No newline at end of file
# specify what docker image
# go with the default image for now and mangle it
#image: debian:jessie
stages:
- test
- deploy
#before_script:
php-syntax-check:
stage: test
image: php:7.0-cli-jessie
script:
# - apt-get clean
# - apt-get update
# - apt-get install -y php-cli
- php -l htdocs/index.php
- find components -name *.php | xargs -n 1 php -l
- find plugins -name *.php | xargs -n 1 php -l
- find lib -name *.php | xargs -n 1 php -l
js-syntax-check:
stage: test
image:
name: node:16
#entrypoint: ["/bin/bash", "-c"]
script:
- npm install -g jshint
- find htdocs/js/ -name *.js ! -name jquery* | xargs -n 1 jshint --verbose
deploy-beta:
stage: deploy
script:
- apt update
- apt install -y curl
- curl https://beta.sucs.org/pull.php
only:
- beta
environment: beta
deploy-live:
stage: deploy
script:
- apt update
- apt install -y curl
- curl https://sucs.org/pull.php
only:
- sucs-site
environment: live
[submodule "htdocs/js/ckeditor"]
path = htdocs/js/ckeditor
url = git://github.com/ckeditor/ckeditor-releases.git
2008-01-29 - Version 0.3 "Logged Out"
Sessions now last a lot longer and are more secure to boot (chckens)
Library admin component allows adding books (chckens, eventually)
Bananas component shelved in favour of Members component for most things (chckens)
Fixes:
Don't list societies with no website in the societies website list (chckens)
Pastebin now redirects to url of pasted item to prevent confusion (chckens)
News article summary can now deal with new lines in the first paragraph (chckens)
2007-10-28 - Version 0.2 "Oktoberfest"
Options component now allows users to change their hackergotchi (aeternus)
Pastebin now lets you view a plaintext version of pastes (aeternus)
Simple password security checks added to hopefully prevent weak passwords (chckens)
Members page now displays this academic year's banana leaderboard (chckens)
2007-09-25 - Version 0.1 "Ferocious Freshers"
First actual version with a number, below are some recent changes:
New member options component!
- MAC registration, contact details editing (aeternus)
- Password changing (chckens)
- Groups display, hackergotchi display (dez)
Beginnings of generic error handling support (chckens)
Fixes:
Improved usability of ShortURI interface (patch from davea)
Layout tweaks to defend against long titles (dez)
Fix calculation for banana summaries on Member pages (chckens)
What's in these 'ere folders:
components/
PHP components of the site, each drives a separate element - e.g.
static content, the library, the help system, etc.
htdocs/
Where all served content is to be found:
css/
Cascading StyleSheets
files/
Files for download (e.g. Help examples)
images/
Images used by the site skin
js/
JavaScript
tinymce/
Placeholder dir for TinyMCE, which should not itself
be stored in SVN
pictures/
Images used in the content (e.g. /Help)
lib/
Custom libraries used by the site - e.g. session library
plugins/
Custom Smarty plugins used by the site - e.g. banana drawing
function
static/
Static content for the static content components (includes help)
fragments/
Any HTML fragments used to make up parts of pages (e.g.
secondary bars)
templates/
Smarty templates
templates_c/
Compiled Smarty templates - do not use this dir
# SUCS Site
[![build status](https://projects.sucs.org/ci/projects/2/status.png?ref=master)](https://projects.sucs.org/ci/projects/2?ref=master)
---
## Project Structure
<br>
| Directory | Description |
| --------- | ----------- |
| components | PHP components of the site, each drives a separate element - e.g. static content, the library, the help system, etc. |
| htdocs/css | Cascading StyleSheets |
| htdocs/files | Files for download (e.g. Help examples) |
| htdocs/images | Images used by the site skin |
| htdocs/js | JavaScript |
| htdocs/js/tinymce | Placeholder dir for TinyMCE, which should not itself be stored in SVN |
| htdocs/pictures | Images used in the content (e.g. /Help) |
| lib | Custom libraries used by the site - e.g. session library |
| plugins | Custom Smarty plugins used by the site - e.g. banana drawing function |
| static | Static content for the static content components (includes help) |
| static/fragments | Any HTML fragments used to make up parts of pages (e.g. secondary bars) |
| templates | Smarty templates |
| templates_c | Compiled Smarty templates - do not use this dir |
\ No newline at end of file
......@@ -24,7 +24,8 @@ $component The pagemap record used for the current page:
[component] component name
$smarty The smarty object
$DB The ADODB database object
$DB The sucssite ADODB database object
$sucsDB The sucs ADODB databse object
$session The Session object
Session has the following properties
......
......@@ -8,35 +8,36 @@ $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
// Tell the banana library that the person/organisation/thing we're dealing with isn't a SUCS member
$isnonmember = true;
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");
$smarty->assign('users', $users);
......@@ -46,5 +47,4 @@ $smarty->assign('title', "Banana Awards");
$smarty->assign('body', $result);
?>
<?php
//include our admin functions
include("../lib/blog/admin.lib.php");
$admin = new admin();
//make our command list from the path
$request=$pathlist;
array_shift($request);
array_shift($request);
array_shift($request);
$smarty->assign("title", "Blog Admin");
if ($session->loggedin) $admin->menu(); else {
header("Location: {$admin->httpPath}");
exit;
}
ob_start();
//alter the debuging state on request
if ($request[0] == "debug") {
$_SESSION[debug] = $request[1];
}
//if logged in
if($session->loggedin && blogger($session->username)) {
//call appropriate functions..
switch (array_shift($request)) {
case "newentry":
$admin->printEntryForm() ;
$smarty->assign("subselect", _("Write new entry"));
if ($admin->blog->editor) $smarty->assign("action", "edit");
break;
case "Settings":
if ($_REQUEST['submit'] == "Save Settings") {
$admin->updateSettings();
} else {
$admin->printSettingsForm() ;
}
$smarty->assign("subselect", _("Settings"));
break;
case "postentry":
$admin->postEntry() ;
break;
case "postupdate":
$admin->updateEntry(array_shift($request)) ;
break;
case "update":
$admin->updateForm(array_shift($request)) ;
$smarty->assign("subselect", _("Edit entries"));
if ($admin->blog->editor) $smarty->assign("action", "edit");
break;
case "showentries":
$admin->printEntries() ;
$smarty->assign("subselect", _("Edit entries"));
break;
case "deleteentry":
$admin->deleteEntry(array_shift($request)) ;
break;
case "confirmdeleteentries":
$admin->confirmDeleteEntries();
break;
case "deleteentries":
$admin->deleteEntries();
break;
case "moderatecomments":
$admin->printComments();
$admin->printAuthorisedUsers();
$comments=_("Comments");
$result = $BlogDB->GetOne("SELECT count(comments.id) from comments join entries on comments.post = entries.id where moderated = false and entries.user_id = ".$admin->id.";");
if($result){
$comments .= " (".$result[0].")";
}
$smarty->assign("subselect", $comments);
break;
case "updatecomments":
$admin->updateComments();
break;
case "deletecomments":
$admin->deleteComments(array_shift($request));
break;
case "updateauthusers":
$admin->updateAuthorisedUsers();
break;
default:
$admin->mainPage();
}
}
else {
//run appropriate functions
switch (array_shift($request)) {
case "signup":
$admin->addUserForm();
$smarty->assign("subselect", _("Start a Blog"));
break;
case "adduser":
$admin->addUser();
break;
//or offer login box
default:
$admin->addUserForm();
$smarty->assign("subselect", _("Start a Blog"));
break;
}
}
?>
<div id="bottompanel">
<p><? echo _("Validate"); ?> : <a href="http://validator.w3.org/check?uri=referer">XHTML</a> / <a href="http://jigsaw.w3.org/css-validator/check/referer/">CSS</a></p>
</div>
<?php
$page = ob_get_contents();
ob_end_clean();
$smarty->assign("body", $page);
$smarty->assign("extra_styles", "/css/blog.css");
//if we are in debug mode display a bunch of stuff
if($_SESSION[debug]){
echo "<div class=\"debug\"><h2>"._("Debug Info")."</h2><pre>\n";
echo "**"._("Session")."**\n";
print_r($_SESSION);
echo "**"._("Request")."**\n";
print_r($_REQUEST);
echo "**"._("Class")."**\n";
print_r($admin);
echo "</pre></div>";
}
?>
<?php
/*
* Comment posting AJAX service
*/
// don't output the site template
$no_template = TRUE;
// don't output anything before we've returned status
ob_start();
require_once("../lib/blog/blog.lib.php");
$blogid = $_POST['blog'];
$postid = $_POST['post'];
$blog = new blogs($blogid);
$ret = $blog->newComment($postid, FALSE);
if($ret[0]) {
echo "<split>OK";
} else {
echo "<split>ERROR<split>".$ret[1];
}
ob_end_flush();
?>
<?php
/*
* feed script - outputs an feed. Currently supports both RSS 2.0 and ATOM
*/
// We're outputting raw XML, so want to turn the templating off
$no_template = TRUE;
//include the blog lib, and thus everything else we need
include("../lib/blog/blog.lib.php");
//setup our path and from that get the feed type and usernae
$request = explode('/', substr($_SERVER['PATH_INFO'], 1));
array_shift($request);
array_shift($request);
//default to rss (so old links and existing feed readers still work, would be nice to ditch this at some point)
$feedtype = 'rss';
if ($request[0] == 'rss' or $request[0] == 'atom'){
$feedtype = array_shift($request);
}
//grab the username
$user = array('username'=> array_shift($request));
//check the user is sane
if(!safeuname($user['username'])){
error(1,"Invalid username");
}
//check the user exists
$row = $BlogDB->GetRow("SELECT username, id, name, title, description FROM users WHERE username='".$user['username']."' AND enabled=true;");
if(!$row){
error(1, "No such user");
}
else {
//fetch the users info from the db
$user = $row;
if(substr(dirname($_SERVER['SCRIPT_NAME']), -1)=="/"){
$user['link'] = "http://".$_SERVER['HTTP_HOST']."/blogs/".$user['username']."/";
$user['feed'] = "http://".$_SERVER['HTTP_HOST']."/blog/feed/".$feedtype."/".$user['username']."";
}
else {
$user['link'] = "http://".$_SERVER['HTTP_HOST']."/blogs/".$user['username']."/";
$user['feed'] = "http://".$_SERVER['HTTP_HOST']."/blog/feed/".$feedtype."/".$user['username']."";
}
}
//check to see if we are only interested in one category
switch(array_shift($request)){
case "category":
$extra = " AND category=".(int)array_shift($request);
break;
default:
$extra = "";
}
//grab the first 15 entires
$query = "SELECT subject, body, timestamp, shortsubject FROM entries WHERE user_id=".$user['id'].$extra." ORDER BY timestamp DESC LIMIT 15;";
$result = $BlogDB->GetAll($query);
//if we have relivent entrys fetch them
if (count($result) > 0) {
$row = array_shift($result);
//set the publish dates in the required format
if($feedtype=='rss') {
$pubdate = date("r",strtotime($row['timestamp']));
}
if($feedtype=='atom') {
//this should be a date type c when we are on php5, untill then, this nasty hack should work.
$pubdate = preg_replace('/ /', 'T', $row['timestamp']).":00";
}
$entries = "";
//output this entry
if ($feedtype=='rss') {
do {
$entrydate = date("r",strtotime($row['timestamp']));
$entries .= "\t\t<item>\n";
$entries .= "\t\t\t<guid>".$user['link']."entry/".$row['shortsubject']."</guid>\n";
$entries .= "\t\t\t<title>" . $row['subject'] . "</title>\n";
$entries .= "\t\t\t<description><![CDATA[" . substr(strip_tags($row['body']),0,150) . " [...]]]></description>\n";
$entries .= "\t\t\t<link>".$user['link']."entry/".$row['shortsubject']."</link>\n";
$entries .= "\t\t\t<pubDate>" . $entrydate . "</pubDate>\n";
$entries .= "\t\t\t<dc:creator>".$user['name']."</dc:creator>\n";
$entries .= "\t\t\t<content:encoded><![CDATA[" . str_replace("'", "&#8217;", $row['body']) . "]]></content:encoded>\n";
$entries .= "\t\t</item>\n";
//and ever other
} while ($row = array_shift($result));
}
if($feedtype=='atom') {
do {
$entrydate = preg_replace('/ /', 'T', $row['timestamp']).":00";
$entries .= "\t<entry>\n";
$entries .= "\t\t<title>".htmlentities($row['subject'])."</title>\n";
$entries .= "\t\t<link rel=\"alternate\" type=\"text/html\" href=\"".$user['link']."entry/".$row['shortsubject']."\"/>\n";
$entries .= "\t\t<id>".$user['link']."entry/".$row['shortsubject']."</id>\n";
$entries .= "\t\t<updated>".$entrydate."</updated>\n";
$entries .= "\t\t<content type=\"xhtml\" xml:lang=\"en\" xml:base=\"".$user['link']."entry/"."\">\n";
$entries .= "\t\t<div xmlns=\"http://www.w3.org/1999/xhtml\">\n";
//just passing though the raw body will cause the feed to fail if the code isnt valid, perhaps we should chuck everything though tidy on its way in (or even out) once we're on php5
$config = array('output-xhtml' => true, 'show-body-only' => true, 'wrap' => false);
$tidy = new tidy;
$tidy->parseString($row['body'], $config, 'utf8');
$tidy->cleanRepair();
$entries .= $tidy;
$entries .= "\t\t</div>\n";
$entries .= "\t\t</content>\n";
$entries .= "\t</entry>\n";
} while ($row = array_shift($result));
}
}
if($feedtype=='rss') {
//tell the client its xml and utf8 encoded (which it should be)
header("Content-type: application/rss+xml; charset=utf-8");
echo "<?xml version=\"1.0\" ?>\n";
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel>
<title><?php print $user['title']?></title>
<description><?php print $user['description']?></description>
<link><?php print $user['link']?></link>
<pubDate><?php echo $pubdate; ?></pubDate>
<generator>SUCS Blogs - http://sucs.org/blogs/</generator>
<language>en</language>
<?php
// add our entrys here
echo $entries; ?>
</channel>
</rss>
<?
}
if($feedtype=='atom') {
//tell the client its xml and utf8 encoded (which it should be)
header("Content-type: application/atom+xml; charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text"><?php print $user['title']?></title>
<subtitle type="text"><?php print $user['description']?></subtitle>
<updated><?php print $pubdate;?></updated>
<id><?php print $user['link']?></id>
<link rel="alternate" type="text/html" hreflang="en" href="<?php print $user['link']?>"/>
<link rel="self" type="application/atom+xml" href="<?php print $user['feed']?>"/>
<rights>Copyright (c) <? echo date("Y",strtotime($row['timestamp'])).", ".$user['name'] ?></rights>
<author>
<name><? echo $user['name'] ?></name>
</author>
<generator uri="http://sucs.org/blogs/" version="1.0">SUCS Blogs</generator>
<?
echo $entries;
?>
</feed>
<?
}
?>
<?php
//include our blog functions
require_once("../lib/blog/blog.lib.php");
//make our command list
$request=explode('/',substr($_SERVER['PATH_INFO'], 1));
//bodge - fix this
array_shift($request);
//if we have something which might be a username start a blogs instance
if ($request[0] != "" and $request[0] != "list"){
$blogsingle = new blogs(array_shift($request));
}
//otherwise, or if there was no such user, start a bloglist instance
if (!isset($blogsingle) || !isset($blogsingle->id)) {
$bloglist = new bloglist();
$request = array("list");
}
$blog = isset($bloglist) ? $bloglist : $blogsingle;
if (isset($blog->userName)) {
if ($session->username==$blog->userName) $smarty->assign("subselect", _("My Blog"));
else $smarty->assign("subselect", $blog->userName._("'s Blog"));
}
ob_start();
$smarty->assign("title", $blog->title);
$smarty->assign("extra_scripts", array("<script type=\"text/javascript\" src=\"$baseurl/js/xmlhttp.js\"></script>"));
//check we have a valid username before offering a RSS feed
if($blog->userName) {
$smarty->assign("rss_url", "http://{$_SERVER['HTTP_HOST']}{$blog->httpPath}feed/rss/{$blog->userName}".(($request[0]=="category") ? "/category/".(int)$request[1]:""));
$smarty->assign("atom_url", "http://{$_SERVER['HTTP_HOST']}{$blog->httpPath}feed/atom/{$blog->userName}".(($request[0]=="category") ? "/category/".(int)$request[1]:""));
// echo " <link rel=\"alternate\" type=\"application/rss+xml\" title=\"{$blog->title}\" href=\"$rss_url\"/>\n";
// echo " <link rel=\"alternate\" type=\"application/atom+xml\" title=\"{$blog->title}\" href=\"$atom_url\"/>\n";
}
ob_start();
$blog->menu();
// if there was an error, print it here
if (isset($blogsingle) && !isset($blogsingle->id)) {
error_exc($blogsingle);
}
//run the appropriate command
switch (array_shift($request)) {
case "entry":
$blog->printEntryAndComments(array_shift($request));
break;
case "category":
$blog->printEntries(0,15,'and category = '.(int)array_shift($request));
break;
case "postcomment":
$blog->newComment((int)array_shift($request)) ;
break;
case "Archive":
$blog->printArchive($request);
if ($session->username == $blog->userName) $smarty->assign("subselect", _("My Archive"));
else $smarty->assign("subselect", $blog->userName._("'s Archive"));
break;
case "list":
$blog->listBlogs();
break;
default:
$blog->printEntries();
}
?>
<div id="bottompanel">
<p><? echo _("Validate"); ?> : <a href="http://validator.w3.org/check?uri=referer">XHTML</a> / <a href="http://jigsaw.w3.org/css-validator/check/referer/">CSS</a> /
<?
if($blog->userName) {
echo "<a href=\"http://feedvalidator.org/check.cgi?url=$rss_url\">RSS</a> / <a href=\"http://feedvalidator.org/check.cgi?url=$atom_url\">ATOM</a>";
}
else {
echo "RSS / ATOM";
}
?>
</p>
</div>
<?php
$page = ob_get_contents();
ob_end_clean();
$smarty->assign("body", $page);
$smarty->assign("extra_styles", "/css/blog.css");
//display debuing info as required
if($_SESSION[debug]){
echo "<div class=\"debug\"><h2>"._("Debug Info")."</h2><pre>\n";
echo "**"._("Session")."**\n";
print_r($_SESSION);
echo "**"._("Request")."**\n";
print_r($_REQUEST);
echo "**"._("Class")."**\n";
print_r($blog);
echo "</pre></div>";
}
?>
<?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});
}
}
<?php
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");
<?php 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])));
}
?>
<?php
<?php
$smarty->assign("election_year", ELECTION_YEAR);
$smarty->assign("title", "Executive Election ".ELECTION_YEAR);
function display_ballot() {
global $DB, $smarty, $output;
require_once("../lib/members.php");
$members = new Members;
$role = $DB->GetAll("SELECT post FROM election_candidates GROUP BY post");
foreach ($role as $post) {
$candidate[$post['post']] = $DB->GetAll("SELECT username, manifesto_link FROM election_candidates WHERE post=? ORDER BY username ASC", $post['post']);
$i=0;
foreach ($candidate[$post['post']] as $person) {
$details = $members->memberView($person['username']);
$candidate[$post['post']][$i]['realname'] = $details[0]['cn'];
if (empty($person['manifesto_link'])) $candidate[$post['post']][$i]['manifesto_link'] = ELECTION_NO_MANIFESTO;
$i++;
}
}
$smarty->assign("candidate", $candidate);
$output = $smarty->fetch('election-vote.tpl');
$smarty->assign("title", "Executive Election " . ELECTION_YEAR);
function display_ballot()
{
global $DB, $smarty, $output;
require_once("../lib/members.php");
$members = new Members;
$role = $DB->GetAll("SELECT post FROM election_candidates GROUP BY post");
foreach ($role as $post) {
$candidate[$post['post']] = $DB->GetAll("SELECT username, manifesto_link FROM election_candidates WHERE post=? ORDER BY username ASC", $post['post']);
$i = 0;
foreach ($candidate[$post['post']] as $person) {
$details = $members->memberView($person['username']);
$candidate[$post['post']][$i]['realname'] = $details[0]['cn'];
if (empty($person['manifesto_link'])) $candidate[$post['post']][$i]['manifesto_link'] = ELECTION_NO_MANIFESTO;
$i++;
}
}
$smarty->assign("candidate", $candidate);
$output = $smarty->fetch('election-vote.tpl');
}
if (!$session->loggedin) {
# You can't vote if you're not logged in!
trigger_error("You are not logged in.", E_USER_WARNING);
# You can't vote if you're not logged in!
trigger_error("You are not logged in.", E_USER_WARNING);
} else {
# The election hasn't started yet
if (strtotime('now') < strtotime(ELECTION_START)) trigger_error("The polling station is not yet open. Voting begins on ".date('l jS F, Y \a\t H:i', strtotime(ELECTION_START)).".");
# The election is over - display the results
else if (strtotime('now') > strtotime(ELECTION_END)) {
require_once("../lib/members.php");
$members = new Members;
$role = $DB->GetAll("SELECT post FROM election_candidates GROUP BY post");
foreach ($role as $post) {
$candidate[$post['post']] = $DB->GetAll("SELECT username, manifesto_link FROM election_candidates WHERE post=?", $post['post']);
$i=0;
foreach ($candidate[$post['post']] as $person) {
$details = $members->memberView($person['username']);
$candidate[$post['post']][$i]['realname'] = $details[0]['cn'];
if (empty($person['manifesto_link'])) $candidate[$post['post']][$i]['manifesto_link'] = ELECTION_NO_MANIFESTO;
$candidate[$post['post']][$i]['votes'] = $DB->GetOne("SELECT count(username) FROM election_votes WHERE ".$post['post']."=?", array($person['username']));
$i++;
}
}
$smarty->assign("candidate", $candidate);
$output = $smarty->fetch('election-results.tpl');
} else {
# It's election time
# Check the user hasn't already voted
$vote_details = $DB->GetRow("SELECT time, ipaddress FROM election_votes WHERE username=?", $session->username);
if (count($vote_details)>0) {
trigger_error("You already voted on ".date('l jS F, Y \a\t H:i', strtotime($vote_details['time']))." from IP address ".$vote_details['ipaddress'].".", E_USER_WARNING);
$output = "<p>Please email the Returning Officer at <a href=\"mailto:vote@sucs.org\">vote@sucs.org</a> with any queries.</p>\n<p>Once polling has closed on ".date('l jS F, Y \a\t H:i', strtotime(ELECTION_END)).", the election results will be available on this page.</p>";
} else {
if ($_POST['submit']=="Cast Votes") {
# We have a ballot paper to process
$output = "<h2>Thank you for your vote</h2>\n<p>You will shortly receive an email confirming your vote.</p>\n<p>Once polling has closed on ".date('l jS F, Y \a\t H:i', strtotime(ELECTION_END)).", the election results will be available on this page.</p>";
# Establish which positions are contested
$role = $DB->GetCol("SELECT post FROM election_candidates GROUP BY post HAVING count(username) > 1");
$fail = FALSE;
$invalid_candidate = FALSE;
$abstain_count = 0;
foreach ($role as $post) {
if ($_POST[$post] == "abstain") $abstain_count++;
# check that we have a valid option selected
if (!($DB->GetOne("SELECT username FROM election_candidates WHERE post=? AND username=?", array($post, $_POST[$post])) || $_POST[$post]=="abstain")) $fail = TRUE;
}
# Check their password first
if ($session->check_pass($session->username, $_POST['vote_passwd'])) {
if ($fail) {
# Either no option or an invalid candidate was supplied
trigger_error("An invalid option was selected in at least one ballot. Please try again.", E_USER_WARNING);
display_ballot();
} else {
# User has abstained in all votes
if ($abstain_count == count($role)) {
trigger_error("You have not selected any candidates in any ballots.", E_USER_WARNING);
display_ballot();
} else {
# The input is valid - record the vote
$vote = array(
'username' => $session->username,
'time' => 'now',
'ipaddress' => $_SERVER['REMOTE_ADDR']);
# Email the Returning Officer
$ro_message = "User: ".$vote['username']."\nIP: ".$vote['ipaddress']."\n\n";
# Email the voter with confirmation
$voter_message = "Thank you for voting in the SUCS election this year. Here are the votes you cast:\n\n";
foreach ($role as $post) {
# Don't add votes up as we go
# $DB->Execute("UPDATE election_candidates SET votes=votes+1 WHERE post=? AND username=?", array($post, $_POST[$post]));
$vote[$post] = $_POST[$post];
$ro_message .= ucfirst($post).": ".$_POST[$post]."\n";
$voter_message .= ucfirst($post).": ".$_POST[$post]."\n";
}
$voter_message .= "\nResults of the election will be announced on ".date('l jS F, Y \a\t H:i', strtotime(ELECTION_END))." at http://sucs.org/Vote\n";
$DB->AutoExecute("election_votes", $vote, 'INSERT');
mail("SUCS Returning Officer <vote@sucs.org>", "[SUCS Election] Vote received from ".$vote['username'], $ro_message, "From: SUCS Election ".ELECTION_YEAR." <vote@sucs.org>");
mail($session->fullname." <".$session->username."@sucs.org>", "[SUCS Election] Thanks For Voting", $voter_message, "From: SUCS Election ".ELECTION_YEAR." <vote@sucs.org>");
}
}
} else {
display_ballot();
}
} else {
# Display the ballot paper
display_ballot();
}
}
}
# The election hasn't started yet
if (strtotime('now') < strtotime(ELECTION_START)) trigger_error("The polling station is not yet open. Voting begins on " . date('l jS F, Y \a\t H:i', strtotime(ELECTION_START)) . ".");
# The election is over - display the results
else if (strtotime('now') > strtotime(ELECTION_END)) {
require_once("../lib/members.php");
$members = new Members;
$role = $DB->GetAll("SELECT post FROM election_candidates GROUP BY post");
foreach ($role as $post) {
$candidate[$post['post']] = $DB->GetAll("SELECT username, manifesto_link FROM election_candidates WHERE post=?", $post['post']);
$i = 0;
foreach ($candidate[$post['post']] as $person) {
$details = $members->memberView($person['username']);
$candidate[$post['post']][$i]['realname'] = $details[0]['cn'];
if (empty($person['manifesto_link'])) $candidate[$post['post']][$i]['manifesto_link'] = ELECTION_NO_MANIFESTO;
$candidate[$post['post']][$i]['votes'] = $DB->GetOne("SELECT count(username) FROM election_votes WHERE " . $post['post'] . "=?", array($person['username']));
$i++;
}
}
$smarty->assign("candidate", $candidate);
$output = $smarty->fetch('election-results.tpl');
} else {
# It's election time
# Check the user hasn't already voted
$vote_details = $DB->GetRow("SELECT time, ipaddress FROM election_votes WHERE username=?", $session->username);
if (count($vote_details) > 0) {
trigger_error("You already voted on " . date('l jS F, Y \a\t H:i', strtotime($vote_details['time'])) . " from IP address " . $vote_details['ipaddress'] . ".", E_USER_WARNING);
$output = "<p>Please email the Returning Officer at <a href=\"mailto:vote@sucs.org\">vote@sucs.org</a> with any queries.</p>\n<p>Once polling has closed on " . date('l jS F, Y \a\t H:i', strtotime(ELECTION_END)) . ", the election results will be available on this page.</p>";
} else {
if ($_POST['submit'] == "Cast Votes") {
# We have a ballot paper to process
$output = "<h2>Thank you for your vote</h2>\n<p>You will shortly receive an email confirming your vote.</p>\n<p>Once polling has closed on " . date('l jS F, Y \a\t H:i', strtotime(ELECTION_END)) . ", the election results will be available on this page.</p>";
# Establish which positions are contested
$role = $DB->GetCol("SELECT post FROM election_candidates GROUP BY post HAVING count(username) > 1");
$fail = FALSE;
$invalid_candidate = FALSE;
$abstain_count = 0;
foreach ($role as $post) {
if ($_POST[$post] == "abstain") $abstain_count++;
# check that we have a valid option selected
if (!($DB->GetOne("SELECT username FROM election_candidates WHERE post=? AND username=?", array($post, $_POST[$post])) || $_POST[$post] == "abstain")) $fail = TRUE;
}
# Check their password first
if ($session->check_pass($session->username, $_POST['vote_passwd'])) {
if ($fail) {
# Either no option or an invalid candidate was supplied
trigger_error("An invalid option was selected in at least one ballot. Please try again.", E_USER_WARNING);
display_ballot();
} else {
# User has abstained in all votes
if ($abstain_count == count($role)) {
trigger_error("You have not selected any candidates in any ballots.", E_USER_WARNING);
display_ballot();
} else {
# The input is valid - record the vote
$vote = array(
'username' => $session->username,
'time' => 'now',
'ipaddress' => $_SERVER['REMOTE_ADDR']);
# Email the Returning Officer
$ro_message = "User: " . $vote['username'] . "\nIP: " . $vote['ipaddress'] . "\n\n";
# Email the voter with confirmation
$voter_message = "Thank you for voting in the SUCS election this year. Here are the votes you cast:\n\n";
foreach ($role as $post) {
# Don't add votes up as we go
# $DB->Execute("UPDATE election_candidates SET votes=votes+1 WHERE post=? AND username=?", array($post, $_POST[$post]));
$vote[$post] = $_POST[$post];
$ro_message .= ucfirst($post) . ": " . $_POST[$post] . "\n";
$voter_message .= ucfirst($post) . ": " . $_POST[$post] . "\n";
}
$voter_message .= "\nResults of the election will be announced on " . date('l jS F, Y \a\t H:i', strtotime(ELECTION_END)) . " at http://sucs.org/Vote\n";
$DB->AutoExecute("election_votes", $vote, 'INSERT');
mail("SUCS Returning Officer <vote@sucs.org>", "[SUCS Election] Vote received from " . $vote['username'], $ro_message, "From: SUCS Election " . ELECTION_YEAR . " <vote@sucs.org>");
mail($session->fullname . " <" . $session->username . "@sucs.org>", "[SUCS Election] Thanks For Voting", $voter_message, "From: SUCS Election " . ELECTION_YEAR . " <vote@sucs.org>");
}
}
} else {
display_ballot();
}
} else {
# Display the ballot paper
display_ballot();
}
}
}
}
$smarty->assign("body", $output);
......
<?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);
......
<?php
/*
/*
* Main events page, including admin functions
*/
$permission = "bananas";
$permission = "sucsstaff";
$eventtable = "events";
$eventcategories = array("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);
$smarty->assign("title", "Events");
$smarty->assign("secondary", file_get_contents("../static/fragments/Events-secondary.txt"));
//$smarty->assign("secondary", file_get_contents("../static/fragments/Events.txt"));
?>