<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 beta 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/584ed85ca725d4a75cdb532c98877e7c1d0632dc">584ed85c</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-09-27T17:15:00Z</i>
</div>
<pre class='commit-message'>Fixed postcode lookup.
Made the sucs site use the SUCS PAF lookup.</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/d1734db30c20596dbc1af7af9fdf116be967fc86">d1734db3</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-09-27T17:20:58Z</i>
</div>
<pre class='commit-message'>Remove dev things.</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/d13114c46694ff88c99f9d64bce7ad7b6fb24af3">d13114c4</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-09-27T17:50:42Z</i>
</div>
<pre class='commit-message'>Merge branch 'master' into 'master'
Fixed postcode lookup
Made the sucs site use the SUCS PAF lookup.
See merge request !18</pre>
</li>
<li>
<strong><a href="https://projects.sucs.org/sucssite/sucs-site/commit/aac2527b71a1f0da1e26458a097a6d4781f5e9c3">aac2527b</a></strong>
<div>
<span>by Imran Hussain</span>
<i>at 2015-09-27T18:05:44Z</i>
</div>
<pre class='commit-message'>Merge branch 'master' into 'beta'
Push postcode lookup fix to beta
The title.
See merge request !19</pre>
</li>
</ul>
<h4>3 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
components/signupajax.php
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
htdocs/js/signup.js
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
lib/validationData.php
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/af3d9f58620ad5bb42167fc154a6bb28cf72c78b...aac2527b71a1f0da1e26458a097a6d4781f5e9c3#diff-0'>
<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">@@ -15,8 +15,7 @@ if (isset($_GET['key'])){
</span> }
break;
case "postcode":
- $postcode=implode("", explode(" ", $_GET['value']));
- echo json_encode(lookup_postcode($postcode));
<span style="color: #000000;background-color: #ddffdd">+ echo lookup_postcode($_GET['value']);
</span> break;
case "username":
$username = $_GET['value'];
</code></pre>
<br>
</li>
<li id='diff-1'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/af3d9f58620ad5bb42167fc154a6bb28cf72c78b...aac2527b71a1f0da1e26458a097a6d4781f5e9c3#diff-1'>
<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">@@ -21,21 +21,34 @@ function validate(){
</span> }
function processPostcode(){
// lookup postcode
<span style="color: #000000;background-color: #ffdddd">- $.getJSON("/signup/ajax",{key: "postcode",value: $('input#postcode').val().replace(/ /g,'')}, function(j){
</span><span style="color: #000000;background-color: #ddffdd">+ $.getJSON("signup/ajax",{key: "postcode",value: $('input#postcode').val()}, function(j){
</span> //populate dropdown
var options = '';
<span style="color: #000000;background-color: #ffdddd">- if (j.length > 1) {
</span><span style="color: #000000;background-color: #ddffdd">+ if (j.addresses.length > 1) {
</span> // make dropdown visible
$('div#addseldiv').removeAttr("style");
<span style="color: #000000;background-color: #ffdddd">- for (var i = 0; i < j.length; i++) {
- options += '<option>' + j[i] + '</option>';
</span><span style="color: #000000;background-color: #ddffdd">+ 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>';
</span> }
$("select#addsel").html(options);
$('select#addsel option:first').attr('selected', 'selected');
}
<span style="color: #000000;background-color: #ffdddd">- if (j.length == 1) {
</span><span style="color: #000000;background-color: #ddffdd">+ if (j.addresses.length == 1) {
</span> $('div#addseldiv').attr("style","display:none");
<span style="color: #000000;background-color: #ffdddd">- $("textarea#address").val(j[0].replace(/, /g,'\n'))
</span><span style="color: #000000;background-color: #ddffdd">+ $("textarea#address")
</span> $('div#addressmessage').attr("style","color:green; float:right; clear:right;");
$('div#addressmessage').html("OK");
validation["address"]=true;
</code></pre>
<br>
</li>
<li id='diff-2'>
<a href='https://projects.sucs.org/sucssite/sucs-site/compare/af3d9f58620ad5bb42167fc154a6bb28cf72c78b...aac2527b71a1f0da1e26458a097a6d4781f5e9c3#diff-2'>
<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">@@ -12,29 +12,15 @@ function lookupSID($sid) {
</span> }
// lookup addresses from postcodes useing the univeritys website
-function lookup_postcode($postcode = "")
-{
<span style="color: #000000;background-color: #ffdddd">- $url = "https://intranet.swan.ac.uk/common/postcodeLookup.asp?pCode=".$postcode;
- $referer = "https://intranet.swan.ac.uk/common/postcodeaddresslookup.asp";
</span><span style="color: #000000;background-color: #ddffdd">+function lookup_postcode($postcode) {
+
+ include_once "../paf-key.php";
+
+ $url = "http://paf.sucs.org/?apikey=$apikey&postcode=".rawurlencode($postcode);
</span>
$req = curl_init($url);
<span style="color: #000000;background-color: #ffdddd">- curl_setopt($req, CURLOPT_HEADER, false);
- curl_setopt($req, CURLOPT_REFERER, $referer);
- curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($req, CURLOPT_SSLVERSION, 3);
</span> $page = curl_exec($req);
curl_close($req);
<span style="color: #000000;background-color: #ffdddd">- $scrape = explode("returnAddress(\"", $page);
</span>-
<span style="color: #000000;background-color: #ffdddd">- $addresses = array();
- for ($i = 1; $i < count($scrape); $i++) {
- if (preg_match("/^[^,\"].+?\"/", $scrape[$i], $address)) {
- $addr = str_replace("<BR>\"", "", $address[0]);
- array_push($addresses, str_replace("<BR>", ", ", $addr));
- }
- }
- return $addresses;
</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/af3d9f58620ad5bb42167fc154a6bb28cf72c78b...aac2527b71a1f0da1e26458a097a6d4781f5e9c3">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/af3d9f58620ad5bb42167fc154a6bb28cf72c78b...aac2527b71a1f0da1e26458a097a6d4781f5e9c3"}}</script>
</p>
</div>
</body>
</html>