<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>Imran Hussain pushed to branch sucs-site at <a href="https://projects.sucs.org/sucssite/sucs-site">sucssite / sucs-site</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/c508252ed91cb2264aded2686b31fc2da44d661d">c508252e</a></strong>
<div>
<span>by gigosaurus</span>
<i>at 2015-10-13T11:45:04Z</i>
</div>
<pre class='commit-message'>Improve the regex and validation</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/f77eef1c5ce4135df657e8eea84048f9658b6c30">f77eef1c</a></strong>
<div>
<span>by gigosaurus</span>
<i>at 2015-10-13T13:07:03Z</i>
</div>
<pre class='commit-message'>Merge branch 'master' of projects.sucs.org:/sucssite/sucs-site</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/9819ed53d165f38978ca023afbcf1cc8ecf6dd9e">9819ed53</a></strong>
<div>
<span>by gigosaurus</span>
<i>at 2015-10-13T19:01:10Z</i>
</div>
<pre class='commit-message'>postcodes can now be dumb</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/a87d2d7631f6bd6e3ffffb0fdea398e2f0df31f4">a87d2d76</a></strong>
<div>
<span>by Peter Jenkins</span>
<i>at 2015-10-13T20:26:12Z</i>
</div>
<pre class='commit-message'>Made the setup script more obvious</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/f28a63a1ed9c7cf1d9956f79f1e6e7580b490529">f28a63a1</a></strong>
<div>
<span>by gigosaurus</span>
<i>at 2015-10-13T20:52:33Z</i>
</div>
<pre class='commit-message'>removing my fuck up</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/b4a9420ca420b07057df06904623ac939fd45c49">b4a9420c</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-10-14T08:49:31Z</i>
</div>
<pre class='commit-message'>Merge branch 'master' into 'master'

Reduced user error

Postcodes can now be lowercase and lack a space.
Phone numbers must be at least 10 characters long (increased from 1, shouldn't cause any issues?).
Any email containing "@sucs." is not allowed for signup.
signup.js has been reformatted.

See merge request !33</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/8721f21b1dbdffed5867e2d68342160456b4d486">8721f21b</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-10-17T13:14:55Z</i>
</div>
<pre class='commit-message'>Remove some old stuff from the repo</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/c1be0332c16996f4c39dc786b6665a70a2a4e006">c1be0332</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-10-20T16:33:16Z</i>
</div>
<pre class='commit-message'>Add the SUCS Site apache config to the vcs.

For people who want to setup the sucssite on another machine.</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/bc305a95d98a7df26d2552d6fb4330515152be26">bc305a95</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-10-20T16:38:17Z</i>
</div>
<pre class='commit-message'>Merge branch 'master' into 'beta'

Push Signup validation changes to beta

They seem to work on my local copy.

Time for public testing.

See merge request !34</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/594f64debe93c47f29381c892fe8fec09eccee0c">594f64de</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-10-20T18:52:29Z</i>
</div>
<pre class='commit-message'>Merge branch 'beta' into 'sucs-site'

Push changes from beta to live

Beta didn't blow up and changes work

See merge request !35</pre>
</li>
</ul>
<h4>9 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
<span class='deleted-file'>

ChangeLog
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
components/signupajax.php
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
<span class='deleted-file'>

db_changes/sucssite-0.3.sql
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-3'>
htdocs/js/signup.js
</a>
</li>
<li class='file-stats'>
<a href='#diff-4'>
lib/sanitization.php
</a>
</li>
<li class='file-stats'>
<a href='#diff-5'>
lib/validation.php
</a>
</li>
<li class='file-stats'>
<a href='#diff-6'>
lib/validationData.php
</a>
</li>
<li class='file-stats'>
<a href='#diff-7'>
setup.sh
</a>
</li>
<li class='file-stats'>
<a href='#diff-8'>
<span class='new-file'>
+
sucssite-apache-vhost.conf
</span>
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-0'>
<strong>
ChangeLog
</strong>
deleted
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ChangeLog
</span><span style="color: #000000;background-color: #ddffdd">+++ /dev/null
</span><span style="color: #aaaaaa">@@ -1,33 +0,0 @@
</span>-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!
<span style="color: #000000;background-color: #ffdddd">-- MAC registration, contact details editing (aeternus)
-- Password changing (chckens)
-- Groups display, hackergotchi display (dez)
</span>-
-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)
</code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-1'>
<strong>
components/signupajax.php
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/components/signupajax.php
</span><span style="color: #000000;background-color: #ddffdd">+++ b/components/signupajax.php
</span><span style="color: #aaaaaa">@@ -14,7 +14,10 @@ if (isset($_GET['key'])) {
</span>             }
             break;
         case "postcode":
<span style="color: #000000;background-color: #ffdddd">-            echo lookup_postcode($_GET['value']);
</span><span style="color: #000000;background-color: #ddffdd">+            $postcode = validPostcode($_GET['value']);
+            if ($postcode != false) {
+                lookup_postcode($postcode);
+            }
</span>             break;
         case "username":
             $username = $_GET['value'];
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-2'>
<strong>
db_changes/sucssite-0.3.sql
</strong>
deleted
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/db_changes/sucssite-0.3.sql
</span><span style="color: #000000;background-color: #ddffdd">+++ /dev/null
</span><span style="color: #aaaaaa">@@ -1,5 +0,0 @@
</span>-DELETE FROM session;
-ALTER TABLE session DROP COLUMN time;
-ALTER TABLE session ADD COLUMN logintime timestamp(0) without time zone;
-ALTER TABLE session ADD COLUMN lastseen timestamp(0) without time zone;
-DELETE FROM menu WHERE title='Bananas';
</code></pre>

<br>
</li>
<li id='diff-3'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-3'>
<strong>
htdocs/js/signup.js
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/htdocs/js/signup.js
</span><span style="color: #000000;background-color: #ddffdd">+++ b/htdocs/js/signup.js
</span><span style="color: #aaaaaa">@@ -1,275 +1,283 @@
</span>-var validation = {"studentid":false, "username":false, "realname":false, "address":false, "contact":false, "email":false, "phone":false};
<span style="color: #000000;background-color: #ddffdd">+var validation = {
+    "studentid": false,
+    "username": false,
+    "realname": false,
+    "address": false,
+    "contact": false,
+    "email": false,
+    "phone": false
+};
</span> var submitted = false;
-function validate(){
-       var valid = true;
-       for (field in req){
-               if (!validation[req[field]]){
-                       valid=false;
-                       break;
-               }
-       }
-       if((valid || ($('input#override:checked').size()==1)) && !submitted && ($('input#tnc:checked').size()==1)){
-               $('input#submit').removeAttr("disabled");
-               return true;
-       }
-       else{
-               $('input#submit').attr("disabled","disabled");
-               return false;
-       }
-       
<span style="color: #000000;background-color: #ddffdd">+function validate() {
+    var valid = true;
+    for (field in req) {
+        if (!validation[req[field]]) {
+            valid = false;
+            break;
+        }
+    }
+    if ((valid || ($('input#override:checked').size() == 1)) && !submitted && ($('input#tnc:checked').size() == 1)) {
+        $('input#submit').removeAttr("disabled");
+        return true;
+    }
+    else {
+        $('input#submit').attr("disabled", "disabled");
+        return false;
+    }
+
</span> 
 }
-function processPostcode(){
-               // lookup postcode
<span style="color: #000000;background-color: #ffdddd">-                $.getJSON("signup/ajax",{key: "postcode",value: $('input#postcode').val()}, function(j){
</span>-                  //populate dropdown     
<span style="color: #000000;background-color: #ffdddd">-                        var options = '';
-                        if (j.addresses.length > 1) {
</span>-                          // make dropdown visible
<span style="color: #000000;background-color: #ffdddd">-                                $('div#addseldiv').removeAttr("style");
-                                for (var i = 0; i < (j.addresses.length); i++) {
-                                        options += '<option>';
-                                        if (j.addresses[i].flat != null) {
-                                               options += j.addresses[i].flat + "\n";
-                                        }
-                                        if (j.addresses[i].house != null) {
-                                               options += j.addresses[i].house + "\n";
-                                        }
-                                        if (j.addresses[i].road != null) {
-                                               options += j.addresses[i].road + "\n";
-                                        }
-                                        if (j.addresses[i].city != null) {
-                                               options += j.addresses[i].city + "\n";
-                                        }
-                                        options += '</option>';
-                                }
-                                $("select#addsel").html(options);
-                                $('select#addsel option:first').attr('selected', 'selected');
-                        }
-                        if (j.addresses.length == 1) {
-                                $('div#addseldiv').attr("style","display:none");
-                                $("textarea#address")
</span>-                          $('div#addressmessage').attr("style","color:green; float:right; clear:right;");
-                               $('div#addressmessage').html("OK");
-                               validation["address"]=true;
-                               validate();
<span style="color: #000000;background-color: #ffdddd">-                        }
-                })
</span><span style="color: #000000;background-color: #ddffdd">+function processPostcode() {
+    // lookup postcode
+    $.getJSON("signup/ajax", {key: "postcode", value: $('input#postcode').val()}, function (j) {
+        //populate dropdown
+        var options = '';
+        if (j.addresses.length > 1) {
+            // make dropdown visible
+            $('div#addseldiv').removeAttr("style");
+            for (var i = 0; i < (j.addresses.length); i++) {
+                options += '<option>';
+                if (j.addresses[i].flat != null) {
+                    options += j.addresses[i].flat + "\n";
+                }
+                if (j.addresses[i].house != null) {
+                    options += j.addresses[i].house + "\n";
+                }
+                if (j.addresses[i].road != null) {
+                    options += j.addresses[i].road + "\n";
+                }
+                if (j.addresses[i].city != null) {
+                    options += j.addresses[i].city + "\n";
+                }
+                options += '</option>';
+            }
+            $("select#addsel").html(options);
+            $('select#addsel option:first').attr('selected', 'selected');
+        }
+        if (j.addresses.length == 1) {
+            $('div#addseldiv').attr("style", "display:none");
+            $("textarea#address")
+            $('div#addressmessage').attr("style", "color:green; float:right; clear:right;");
+            $('div#addressmessage').html("OK");
+            validation["address"] = true;
+            validate();
+        }
+    })
</span> }
 
-function lookupSID(setname){
<span style="color: #000000;background-color: #ffdddd">-        $.get("/signup/ajax",{key:"sid" ,value: $('input#studentid').val()},function(j){
-                arr=j.split(":");
-                key=arr.shift();
-                val=arr.join(":");
-                if(key=="OK"){
</span>-                  if(setname=true)
-                               $("input#realname").val(val);
<span style="color: #000000;background-color: #ffdddd">-                        $('div#studentidmessage').attr("style","color:green; float:right; clear:right;");
</span>-                  $('div#studentidmessage').html(key);
-                       validation['studentid']=true;
-                       processName("realname","realname");
<span style="color: #000000;background-color: #ddffdd">+function lookupSID(setname) {
+    $.get("/signup/ajax", {key: "sid", value: $('input#studentid').val()}, function (j) {
+        arr = j.split(":");
+        key = arr.shift();
+        val = arr.join(":");
+        if (key == "OK") {
+            if (setname = true)
+                $("input#realname").val(val);
+            $('div#studentidmessage').attr("style", "color:green; float:right; clear:right;");
+            $('div#studentidmessage').html(key);
+            validation['studentid'] = true;
+            processName("realname", "realname");
</span> 
<span style="color: #000000;background-color: #ffdddd">-                }
-                else{
-                        $('div#studentidmessage').attr("style","color:red; float:right; clear:right;");
</span>-                  $('div#studentidmessage').html(val);
-                       validation['email']=false;
-                       validate();
<span style="color: #000000;background-color: #ffdddd">-                }
-        },'text')
</span><span style="color: #000000;background-color: #ddffdd">+        }
+        else {
+            $('div#studentidmessage').attr("style", "color:red; float:right; clear:right;");
+            $('div#studentidmessage').html(val);
+            validation['email'] = false;
+            validate();
+        }
+    }, 'text')
</span> }
-function processSID(){
-       lookupSID(true);
<span style="color: #000000;background-color: #ddffdd">+function processSID() {
+    lookupSID(true);
</span> }
 
-function processUsername(){
<span style="color: #000000;background-color: #ffdddd">-        $.get("/signup/ajax",{key: "username", value: $('input#username').val()},function(j){
-                if (j!="OK") {
-                        $('div#usernamemessage').attr("style","color:red; float:right; clear:right;");
</span>-                  validation['username']=false;
<span style="color: #000000;background-color: #ffdddd">-                }
-                else{   
-                        $('div#usernamemessage').attr("style","color:green; float:right; clear:right;");
</span>-                  validation['username']=true;
<span style="color: #000000;background-color: #ffdddd">-                }
</span>-          $('div#usernamemessage').html(j);
-               validate();
<span style="color: #000000;background-color: #ffdddd">-        },'text')
</span><span style="color: #000000;background-color: #ddffdd">+function processUsername() {
+    $.get("/signup/ajax", {key: "username", value: $('input#username').val()}, function (j) {
+        if (j != "OK") {
+            $('div#usernamemessage').attr("style", "color:red; float:right; clear:right;");
+            validation['username'] = false;
+        }
+        else {
+            $('div#usernamemessage').attr("style", "color:green; float:right; clear:right;");
+            validation['username'] = true;
+        }
+        $('div#usernamemessage').html(j);
+        validate();
+    }, 'text')
</span> }
 
-function processName(type, input){
<span style="color: #000000;background-color: #ffdddd">-        $.get("/signup/ajax",{key: type, value: $('input#'+input).val()},function(j){
-                if (j!="OK") {
-                        $('div#'+input+'message').attr("style","color:red; float:right; clear:right;");
</span>-                  validation[input]=false;
<span style="color: #000000;background-color: #ffdddd">-                }
-                else{   
-                        $('div#'+input+'message').attr("style","color:green; float:right; clear:right;");
</span>-                  validation[input]=true;
<span style="color: #000000;background-color: #ffdddd">-                }
</span>-          $('div#'+input+'message').html(j);
-               validate();
<span style="color: #000000;background-color: #ffdddd">-        },'text')
</span><span style="color: #000000;background-color: #ddffdd">+function processName(type, input) {
+    $.get("/signup/ajax", {key: type, value: $('input#' + input).val()}, function (j) {
+        if (j != "OK") {
+            $('div#' + input + 'message').attr("style", "color:red; float:right; clear:right;");
+            validation[input] = false;
+        }
+        else {
+            $('div#' + input + 'message').attr("style", "color:green; float:right; clear:right;");
+            validation[input] = true;
+        }
+        $('div#' + input + 'message').html(j);
+        validate();
+    }, 'text')
</span> }
-function processContact(){
-       processName('realname','contact');
<span style="color: #000000;background-color: #ddffdd">+function processContact() {
+    processName('realname', 'contact');
</span> }
 
-function processAddress(){
<span style="color: #000000;background-color: #ffdddd">-        $.get("/signup/ajax",{key: "address", value: $('textarea#address').val()},function(j){
-                if (j!="OK") {
-                        $('div#addressmessage').attr("style","color:red; float:right; clear:right;");
-                        validation['address']=false;
-                }   
-                else{   
-                        $('div#addressmessage').attr("style","color:green; float:right; clear:right;");
-                        validation['address']=true;
-                }
</span>-          $('div#addressmessage').html(j);
-               validate();
<span style="color: #000000;background-color: #ffdddd">-        },'text')
</span><span style="color: #000000;background-color: #ddffdd">+function processAddress() {
+    $.get("/signup/ajax", {key: "address", value: $('textarea#address').val()}, function (j) {
+        if (j != "OK") {
+            $('div#addressmessage').attr("style", "color:red; float:right; clear:right;");
+            validation['address'] = false;
+        }
+        else {
+            $('div#addressmessage').attr("style", "color:green; float:right; clear:right;");
+            validation['address'] = true;
+        }
+        $('div#addressmessage').html(j);
+        validate();
+    }, 'text')
</span> }
 
-function processEmail(){
<span style="color: #000000;background-color: #ffdddd">-        $.get("/signup/ajax",{key: "email", value: $('input#email').val()},function(j){
-                if (j!="OK") {
-                        $('div#emailmessage').attr("style","color:red; float:right; clear:right;");
</span>-                  validation['email']=false;
<span style="color: #000000;background-color: #ffdddd">-                }
-                else{   
-                        $('div#emailmessage').attr("style","color:green; float:right; clear:right;");
</span>-                  validation['email']=true;
<span style="color: #000000;background-color: #ffdddd">-                }
</span>-          $('div#emailmessage').html(j);
-               validate();
<span style="color: #000000;background-color: #ffdddd">-        },'text')
</span><span style="color: #000000;background-color: #ddffdd">+function processEmail() {
+    $.get("/signup/ajax", {key: "email", value: $('input#email').val()}, function (j) {
+        if (j != "OK") {
+            $('div#emailmessage').attr("style", "color:red; float:right; clear:right;");
+            validation['email'] = false;
+        }
+        else {
+            $('div#emailmessage').attr("style", "color:green; float:right; clear:right;");
+            validation['email'] = true;
+        }
+        $('div#emailmessage').html(j);
+        validate();
+    }, 'text')
</span> }
 
-function processPhone(){
<span style="color: #000000;background-color: #ffdddd">-        $.get("/signup/ajax",{key: "phone", value: $('input#phone').val()},function(j){
-                if (j!="OK") {
-                        $('div#phonemessage').attr("style","color:red; float:right; clear:right;");
</span>-                  validation['phone']=false;
<span style="color: #000000;background-color: #ffdddd">-                }
-                else{   
-                        $('div#phonemessage').attr("style","color:green; float:right; clear:right;");
</span>-                  validation['phone']=true;
<span style="color: #000000;background-color: #ffdddd">-                }
</span>-          $('div#phonemessage').html(j);
-               validate();
<span style="color: #000000;background-color: #ffdddd">-        },'text')
</span><span style="color: #000000;background-color: #ddffdd">+function processPhone() {
+    $.get("/signup/ajax", {key: "phone", value: $('input#phone').val()}, function (j) {
+        if (j != "OK") {
+            $('div#phonemessage').attr("style", "color:red; float:right; clear:right;");
+            validation['phone'] = false;
+        }
+        else {
+            $('div#phonemessage').attr("style", "color:green; float:right; clear:right;");
+            validation['phone'] = true;
+        }
+        $('div#phonemessage').html(j);
+        validate();
+    }, 'text')
</span> }
 
-$(function(){
-       if($('input#studentid').size()==1){
-               usertype=1;
-       }
-       else if($('input#contact').size()==1){
-               usertype=2;
-       }
-       else{
-               usertype=5;
-       }
<span style="color: #000000;background-color: #ffdddd">-        req=new Array("username","realname","email","phone");
-        switch(usertype){
-                case "1":
-                        req.push("studentid","address");
-                        break;
-                case "2":
-                        req.push("contact");
-                        break;
-                case "5":
-                        req.push("address");
</span><span style="color: #000000;background-color: #ddffdd">+$(function () {
+    if ($('input#studentid').size() == 1) {
+        usertype = 1;
+    }
+    else if ($('input#contact').size() == 1) {
+        usertype = 2;
+    }
+    else {
+        usertype = 5;
+    }
+    req = new Array("username", "realname", "email", "phone");
+    switch (usertype) {
+        case "1":
+            req.push("studentid", "address");
+            break;
+        case "2":
+            req.push("contact");
+            break;
+        case "5":
+            req.push("address");
+    }
+    //usertype=$('input#usertype').val();
+    $("document").ready(function () {
+        // makes script sutff appear
+        $('div#postcodediv').removeAttr("style");
+        $('input#submit').attr("disabled", "disabled");
+        // if the fields are not empty validate them
+        if ($('input#username').val() != "") processUsername();
+        if ($('input#email').val() != "") processEmail();
+        if ($('input#phone').val() != "") processPhone();
+        if (usertype != 2) {
+            if ($('input#postcode').val() != "") processPostcode();
+            if ($('textarea#address').val() != "") processAddress();
+            if ($('input#realname').val() != "") processName("realname", "realname");
+        }
+        else {
+            if ($('input#contact').val() != "") processContact();
+            if ($('input#realname').val() != "") processName("socname", "realname");
</span>         }
-       //usertype=$('input#usertype').val();
-       $("document").ready(function(){
-               // makes script sutff appear
-               $('div#postcodediv').removeAttr("style");
-               $('input#submit').attr("disabled","disabled");
-               // if the fields are not empty validate them
-               if($('input#username').val()!="") processUsername();
-               if($('input#email').val()!="") processEmail();
-               if($('input#phone').val()!="") processPhone();
-               if(usertype!=2){
-                       if($('input#postcode').val()!="") processPostcode();
-                       if($('textarea#address').val()!="") processAddress();
-                       if($('input#realname').val()!="") processName("realname","realname");
-               }
-               else{
-                       if($('input#contact').val()!="") processContact();
-                       if($('input#realname').val()!="") processName("socname","realname");
-               }
-               if((usertype==1) && ($('input#studentid').val()!="")){
-                       if($('input#realname').val()=="") lookupSID(true);
-                       else lookupSID(false);
-               }
<span style="color: #000000;background-color: #ddffdd">+        if ((usertype == 1) && ($('input#studentid').val() != "")) {
+            if ($('input#realname').val() == "") lookupSID(true);
+            else lookupSID(false);
+        }
+
+        validate();
+    })
+    // dont do address stuff for societies
+    if (usertype != 2) {
+        // process postcode when the box changes
+        $("input#postcode").change(processPostcode);
</span> 
-               validate();
-       })
-       // dont do address stuff for societies
-       if(usertype!=2){
-       // process postcode when the box changes
-       $("input#postcode").change(processPostcode);
-       
-       //populate the address box when an address is selected
-       $("select#addsel").change(function(){
-       
-               // everything is shit and will strip out the line breaks
-               // so we have to do weird shit with innerHTML
-       
-               // store the entire options as e
-               var e = document.getElementById("addsel");
-               // store the selected address's innerHTML as strUser (because stackpver flow copy and paste)
-               var strUser = e.options[e.selectedIndex].innerHTML;
-               // set the text area to the strUser var
-               $("textarea#address").text( strUser );
-               $('div#addressmessage').attr("style","color:green; float:right; clear:right;");
-               $('div#addressmessage').html("OK");
-               validation['address']=true;
-       })
-       }
-       //else deal with the contact field
-       else{
<span style="color: #000000;background-color: #ddffdd">+        //populate the address box when an address is selected
+        $("select#addsel").change(function () {
+
+            // everything is shit and will strip out the line breaks
+            // so we have to do weird shit with innerHTML
+
+            // store the entire options as e
+            var e = document.getElementById("addsel");
+            // store the selected address's innerHTML as strUser (because stackpver flow copy and paste)
+            var strUser = e.options[e.selectedIndex].innerHTML;
+            // set the text area to the strUser var
+            $("textarea#address").text(strUser);
+            $('div#addressmessage').attr("style", "color:green; float:right; clear:right;");
+            $('div#addressmessage').html("OK");
+            validation['address'] = true;
+        })
+    }
+    //else deal with the contact field
+    else {
</span>         $("input#contact").change(processContact)
 
-       }
-       //if is a student
-       if(usertype==1){
-       //lookup the real name from the studentid
-       $("input#studentid").change(processSID)
-       }
-       //validate username
-       $("input#username").change(processUsername)
-       //validate personal and society names differntly
-       if(usertype!=2){
-               persoc='realname';
-       }
-       else{
-               persoc='socname';
-       }
-       //validate real name
-       $("input#realname").change(function(){
-               processName(persoc, 'realname');
-       })
-       
<span style="color: #000000;background-color: #ffdddd">-        //validate email address
-        $("input#email").change(processEmail);
-        //validate phone number
-        $("input#phone").change(processPhone);
</span>-  $("textarea#address").change(processAddress);
-       $("input#override").change(validate);
-       $("input#tnc").change(validate);
-       // Disable the submit button once clicked
-       $("form#mainform").submit(function() {
-               var valid = validate();
-               if(valid){
-                       // mark form as submitted
-                       submitted = true;
-                       // disable the submit button
-                       $('input#submit').attr("disabled","disabled");
-               }
-               return valid;
-       });
<span style="color: #000000;background-color: #ddffdd">+    }
+    //if is a student
+    if (usertype == 1) {
+        //lookup the real name from the studentid
+        $("input#studentid").change(processSID)
+    }
+    //validate username
+    $("input#username").change(processUsername)
+    //validate personal and society names differntly
+    if (usertype != 2) {
+        persoc = 'realname';
+    }
+    else {
+        persoc = 'socname';
+    }
+    //validate real name
+    $("input#realname").change(function () {
+        processName(persoc, 'realname');
+    })
+
+    //validate email address
+    $("input#email").change(processEmail);
+    //validate phone number
+    $("input#phone").change(processPhone);
+    $("textarea#address").change(processAddress);
+    $("input#override").change(validate);
+    $("input#tnc").change(validate);
+    // Disable the submit button once clicked
+    $("form#mainform").submit(function () {
+        var valid = validate();
+        if (valid) {
+            // mark form as submitted
+            submitted = true;
+            // disable the submit button
+            $('input#submit').attr("disabled", "disabled");
+        }
+        return valid;
+    });
</span> })
 
</code></pre>

<br>
</li>
<li id='diff-4'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-4'>
<strong>
lib/sanitization.php
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/lib/sanitization.php
</span><span style="color: #000000;background-color: #ddffdd">+++ b/lib/sanitization.php
</span><span style="color: #aaaaaa">@@ -9,4 +9,12 @@ function sanitizeAddress($address)
</span>     return str_replace(array("\r\n", "\r"), array("\n", "\n"), $address);
 }
 
<span style="color: #000000;background-color: #ddffdd">+function sanitizePostcode($postcode)
+{
+    //force uppercase, remove any possible stupid spaces and add the single space in the correct place
+    $postcode = strtoupper($postcode);
+    $postcode = str_replace(" ", "", $postcode);
+    return substr_replace($postcode, " ", -3, 0);
+}
+
</span> ?>
</code></pre>

<br>
</li>
<li id='diff-5'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-5'>
<strong>
lib/validation.php
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/lib/validation.php
</span><span style="color: #000000;background-color: #ddffdd">+++ b/lib/validation.php
</span><span style="color: #aaaaaa">@@ -252,11 +252,22 @@ function validAddress($address)
</span>     }
 }
 
<span style="color: #000000;background-color: #ddffdd">+function validPostcode($postcode)
+{
+    $postcode = sanitizePostcode($postcode);
+    if (!preg_match('/^[A-Z]{1,2}[0-9]{1,2}[A-Z]{0,1} [0-9][A-Z]{2}$/', $postcode)) {
+        return false;
+    } else {
+        return $postcode;
+    }
+
+}
+
</span> function validPhone($phone)
 {
     global $error;
     $phone = sanitizePhone($phone);
<span style="color: #000000;background-color: #ffdddd">-    if (!preg_match("/^\+?[0-9-]+$/", $phone)) {
</span><span style="color: #000000;background-color: #ddffdd">+    if (!preg_match("/^\+?[0-9-]{10,}$/", $phone)) {
</span>         $error = "Must be all numbers";
         return false;
     }
<span style="color: #aaaaaa">@@ -266,7 +277,7 @@ function validPhone($phone)
</span> function validSignupEmail($email)
 {
     global $error;
<span style="color: #000000;background-color: #ffdddd">-    if (preg_match('/@sucs\.org$/', $email)) {
</span><span style="color: #000000;background-color: #ddffdd">+    if (preg_match('/@sucs\.$/', $email)) {
</span>         $error = "SUCS email addresses are not allowed";
         return false;
     } elseif (!validEmail($email)) {
</code></pre>

<br>
</li>
<li id='diff-6'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-6'>
<strong>
lib/validationData.php
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/lib/validationData.php
</span><span style="color: #000000;background-color: #ddffdd">+++ b/lib/validationData.php
</span><span style="color: #aaaaaa">@@ -1,5 +1,5 @@
</span> <?
-// lookup real names from sid's useing campus ldap
<span style="color: #000000;background-color: #ddffdd">+// lookup real names from sid's using campus ldap
</span> function lookupSID($sid)
 {
     $ds = ldap_connect("ccs-suld1.swan.ac.uk");
<span style="color: #aaaaaa">@@ -12,7 +12,7 @@ function lookupSID($sid)
</span>     return ucwords(strtolower($info[0]['givenname'][0] . " " . $info[0]['sn'][0]));
 }
 
-// lookup addresses from postcodes useing the univeritys website
<span style="color: #000000;background-color: #ddffdd">+// lookup addresses from postcodes using the university's website
</span> function lookup_postcode($postcode)
 {
 
<span style="color: #aaaaaa">@@ -21,9 +21,8 @@ function lookup_postcode($postcode)
</span>     $url = "http://paf.sucs.org/?apikey=$apikey&postcode=" . rawurlencode($postcode);
 
     $req = curl_init($url);
<span style="color: #000000;background-color: #ffdddd">-    $page = curl_exec($req);
</span><span style="color: #000000;background-color: #ddffdd">+    curl_exec($req);
</span>     curl_close($req);
-
 }
 
 ?>
</code></pre>

<br>
</li>
<li id='diff-7'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-7'>
<strong>
setup.sh
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/setup.sh
</span><span style="color: #000000;background-color: #ddffdd">+++ b/setup.sh
</span><span style="color: #aaaaaa">@@ -27,5 +27,4 @@ echo "Done!"
</span> 
 # and you're done!
 echo -e "\nYou should now be able to view your local copy of the SUCS site at http://sucs.org/~$USER/sucssite/"
-echo "Please contact a member of the admin team if you require use of the development database"
-
<span style="color: #000000;background-color: #ddffdd">+echo "Please contact a member of the admin team to gain access to the development database"
</span>\ No newline at end of file
</code></pre>

<br>
</li>
<li id='diff-8'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c#diff-8'>
<strong>
sucssite-apache-vhost.conf
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- /dev/null
</span><span style="color: #000000;background-color: #ddffdd">+++ b/sucssite-apache-vhost.conf
</span><span style="color: #aaaaaa">@@ -0,0 +1,203 @@
</span><span style="color: #000000;background-color: #ddffdd">+# The main sucs website
+
+<VirtualHost 137.44.10.1:80>
+       DocumentRoot "/var/www/sucssite/htdocs"
+       ServerAdmin admin@sucs.org
+       ServerName sucs.org
+       ServerAlias www.sucs.org
+       ServerAlias sucs.swan.ac.uk
+       ServerAlias www.sucs.swan.ac.uk
+       ServerAlias compsoc.swan.ac.uk
+       ServerAlias www.compsoc.swan.ac.uk
+
+       Include /etc/apache2/conf.sucs.d/userdir.conf
+
+       ErrorLog /var/log/apache2/sucssite_error.log
+       CustomLog /var/log/apache2/sucssite_access.log combined
+       LogLevel warn
+
+       <Directory "/var/www/sucssite/htdocs">
+               AllowOverride All
+
+               XBitHack On
+
+               Order allow,deny
+               Allow from all
+               
+
+               Options +MultiViews
+               <IfModule mod_rewrite.c>
+                       RewriteEngine On
+
+                       # Ensure requests are for our preferred domains
+
+                       # Disabled by ~imranh 08/04/2015
+                       # We want people to do to sucs.org becuase we have a ssl cert for that
+                       # Keep stuff thats come in via *.swan.ac.uk in .ac.uk
+                       #RewriteCond %{HTTP_HOST} ^www.sucs.swan.ac.uk [NC,OR]
+                       #RewriteCond %{HTTP_HOST} ^compsoc.swan.ac.uk [NC,OR]
+                       #RewriteCond %{HTTP_HOST} ^www.compsoc.swan.ac.uk [NC]
+                       #RewriteRule ^(.*)$ http://sucs.swan.ac.uk/$1 [R=301,L]
+
+                       #(web)mail.sucs.org to sucs.org/webmail
+                       RewriteCond %{HTTP_HOST} ^mail.sucs.org [NC,OR]
+                       RewriteCond %{HTTP_HOST} ^webmail.sucs.org [NC]
+                       RewriteRule ^(.*)$ http://sucs.org/webmail/ [R=301,L]
+
+                       # Everything else may as well goto sucs.org
+                       RewriteCond %{HTTP_HOST} !^sucs.org [NC]
+                       #RewriteCond %{HTTP_HOST} !^sucs.swan.ac.uk [NC]
+                       RewriteRule ^(.*)$ http://sucs.org/$1 [R=301,L]
+
+                       # If its not a file or directory pass it to the website script
+                       RewriteCond %{REQUEST_URI} !=/server-status
+                       RewriteCond %{REQUEST_FILENAME} !-f
+                       RewriteCond %{REQUEST_FILENAME} !-d
+                       RewriteCond %{REQUEST_URI} !^/index\.php.*
+                       RewriteRule ^(.*)$ index.php/$1 [QSA,L]
+               </IfModule>
+               #RedirectMatch permanent ^/Community/Forum$ https://sucs.org/Community/Forum/
+               RedirectMatch permanent ^/webmail$ https://sucs.org/webmail/
+       </Directory>
+</VirtualHost>
+
+<IfModule mod_ssl.c>
+<VirtualHost 137.44.10.1:443>
+       DocumentRoot "/var/www/sucssite/htdocs"
+       ServerAdmin admin@sucs.org
+       ServerName sucs.org
+       ServerAlias www.sucs.org
+       ServerAlias sucs.swan.ac.uk
+       ServerAlias www.sucs.swan.ac.uk
+       ServerAlias compsoc.swan.ac.uk
+       ServerAlias www.compsoc.swan.ac.uk
+
+       ErrorLog /var/log/apache2/ssl_error.log
+       TransferLog /var/log/apache2/ssl_access.log
+       LogLevel warn
+
+       SSLEngine on
+
+       SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
+       SSLProtocol All -SSLv2 -SSLv3
+       SSLHonorCipherOrder On
+       Header always set Strict-Transport-Security "max-age=604800"
+       Header always set X-Frame-Options SAMEORIGIN
+       Header always set X-Content-Type-Options nosniff
+       SSLCompression off
+
+       SSLCertificateFile /usr/local/sucs-pki/certs/sucs.crt
+       SSLCertificateKeyFile /usr/local/sucs-pki/private/sucs.key
+       SSLCertificateChainFile /usr/local/sucs-pki/certs/globalsign.crt
+
+       <Files ~ "\.(cgi|shtml|phtml|php3?)$">
+           SSLOptions +StdEnvVars
+       </Files>
+
+       <Directory "/var/www/cgi-bin">
+           SSLOptions +StdEnvVars
+       </Directory>
+
+       SetEnvIf User-Agent ".*MSIE.*" \
+                nokeepalive ssl-unclean-shutdown \
+                downgrade-1.0 force-response-1.0
+
+       CustomLog /var/log/apache2/ssl_request.log \
+                 "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
+
+       ProxyRequests Off
+       <Proxy *>
+               Order allow,deny
+               Allow from all
+       </Proxy>
+       ProxyVia On
+       SSLProxyEngine on
+       ProxyPass /svn https://projects.sucs.org/svn
+       <Location /svn >
+               #DAV svn
+               #SVNParentPath /var/projects/svn
+                #Redirect / https://projects.sucs.org/
+               ProxyPassReverse https://projects.sucs.org/svn
+       </Location>
+
+       Include /etc/apache2/conf.sucs.d/userdir.conf
+
+       <Directory "/var/www/sucssite/htdocs">
+               Options Indexes FollowSymLinks Includes ExecCGI MultiViews
+               AllowOverride All
+
+               XBitHack On
+
+               Order allow,deny
+               Allow from all
+
+               Options +MultiViews
+               <IfModule mod_rewrite.c>
+                       RewriteEngine On
+
+                       # Ensure requests are for our preferred domains
+                       # Disabled by ~imranh 08/04/2015
+                       # We want people to do to sucs.org becuase we have a ssl cert for that
+                       # Keep stuff thats come in via *.swan.ac.uk in .ac.uk
+                       #RewriteCond %{HTTP_HOST} ^www.sucs.swan.ac.uk [NC,OR]
+                       #RewriteCond %{HTTP_HOST} ^compsoc.swan.ac.uk [NC,OR]
+                       #RewriteCond %{HTTP_HOST} ^www.compsoc.swan.ac.uk [NC]
+                       #RewriteRule ^(.*)$ https://sucs.swan.ac.uk/$1 [R=301,L]
+
+                       #(web)mail.sucs.org to sucs.org/webmail
+                       RewriteCond %{HTTP_HOST} ^mail.sucs.org [NC,OR]
+                       RewriteCond %{HTTP_HOST} ^webmail.sucs.org [NC]
+                       RewriteRule ^(.*)$ https://sucs.org/webmail/$1 [R=301,L]
+
+                       # Everything else may as well goto sucs.org
+                       RewriteCond %{HTTP_HOST} !^sucs.org [NC]
+                       #RewriteCond %{HTTP_HOST} !^sucs.swan.ac.uk [NC]
+                       RewriteRule ^(.*)$ https://sucs.org/$1 [R=301,L]
+
+                       # If its not a file or directory pass it to the website script
+                       RewriteCond %{REQUEST_URI} !=/server-status
+                       RewriteCond %{REQUEST_FILENAME} !-f
+                       RewriteCond %{REQUEST_FILENAME} !-d
+                       RewriteCond %{REQUEST_URI} !^/index\.php.*
+                       RewriteRule ^(.*)$ index.php/$1 [QSA,L]
+               </IfModule>
+
+       </Directory>
+
+       # Disabled, Moved to the gitlab VM ~imranh
+       #Include /etc/apache2/conf.d/projects.conf
+
+       # Redirect to squirrelmail install
+       Alias /squirrelmail /usr/share/squirrelmail
+       Alias /webmail/program/js/tiny_mce/ /usr/share/tinymce/www/
+       Alias /webmail /var/lib/roundcube
+       Alias /roundcube/program/js/tiny_mce/ /usr/share/tinymce/www/
+       Alias /roundcube /var/lib/roundcube
+       
+       # 2015-03-16 Moved the /cam alias to here from /etc/apache2/conf.d/webcam to stop it becoming an alias on all virtual hosts, commented out the file in the other location. ~rjames93
+       Alias /cam /var/cam
+       <Directory "/var/cam">
+                       Order allow,deny
+                       Allow from all
+                       Options Indexes SymLinksIfOwnerMatch
+       </Directory>
+
+       <Location /cam>
+               AuthType Basic
+               AuthName "Staff Only Area"
+               AuthBasicProvider ldap
+               AuthLDAPURL "ldap://127.0.0.1/dc=sucs,dc=org?uid"
+               AuthLDAPGroupAttribute memberUid
+               AuthLDAPGroupAttributeIsDN off
+               Require ldap-group cn=sucsstaff,ou=Group,dc=sucs,dc=org
+       </Location>
+
+       Alias /stats/collectd-web /var/www/collectd-web
+       <Directory /var/www/collectd-web/cgi-bin>
+               Options Indexes ExecCGI
+                AllowOverride All
+                AddHandler cgi-script .cgi
+       </Directory>
+
+</VirtualHost>
+</IfModule>
</span></code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c">View it on GitLab</a>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":["merge_requests","issues","commit"],"url":"https://projects.sucs.org/sucssite/sucs-site/compare/5fe75688e9868a911c9a5e0af992293b816a3043...594f64debe93c47f29381c892fe8fec09eccee0c"}}</script>
</p>
</div>
</body>
</html>