[SUCS Devel] [Git][sucssite/sucs-site][beta] 7 commits: Replace the old UID generation.
Imran Hussain
imranh at sucs.org
Sat Mar 12 16:28:20 GMT 2016
Imran Hussain pushed to branch beta at sucssite / sucs-site
Commits:
a16d95d0 by Imran Hussain at 2015-12-29T17:07:38+00:00
Replace the old UID generation.
New UID generation system that uses the full year as a prefix. Should stop UIDs
from being reused.
- - - - -
080478fe by Laurence Sebastian Bowes at 2016-02-13T03:26:59+00:00
Twat
- - - - -
c2f7394d by Laurence Sebastian Bowes at 2016-02-13T03:44:17+00:00
Minor fixes. Happy with this code now.
- - - - -
85a840ef by Laurence Sebastian Bowes at 2016-02-17T12:42:57+00:00
Updated info following on from what I think #29 was talking about
- - - - -
bbd8423e by Imran Hussain at 2016-03-12T15:59:14+00:00
Update stream page with new info
- - - - -
edf6aa38 by Imran Hussain at 2016-03-12T16:00:36+00:00
Remove old info from stream page
- - - - -
ec709448 by Imran Hussain at 2016-03-12T16:28:13+00:00
Merge branch 'master' into beta
- - - - -
4 changed files:
- components/signup.php
- lib/member_functions.php
- static/About/Room.txt
- static/Community/Stream.txt
Changes:
=====================================
components/signup.php
=====================================
--- a/components/signup.php
+++ b/components/signup.php
@@ -128,16 +128,8 @@ if (isset($_REQUEST['signupid']) && isset($_REQUEST['signuppw'])) {
);
$failed = true;
} else {
- // determine the uid range
- if ($row[type] == 2) {
- $baseuid = 8;
- } else {
- $baseuid = 29;
- }
- $minuid = $baseuid * 1000;
- $maxuid = $minuid + 999;
- //get the new uid
- $uid = findUid($minuid, $maxuid);
+ //generate the new uid
+ $uid = generateUid();
// make a password
$password = make_password();
// make the ldif
=====================================
lib/member_functions.php
=====================================
--- a/lib/member_functions.php
+++ b/lib/member_functions.php
@@ -29,21 +29,30 @@ function make_password($length = 8)
return $password;
}
-function findUid($start, $end)
+function generateUid()
{
- $ds = ldap_connect("localhost");
- ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
- $r = ldap_bind($ds);
- $sr = ldap_search($ds, "dc=sucs,dc=org", "uid=*", array(uidNumber));
- $info = ldap_get_entries($ds, $sr);
- for ($i = 0; $i < $info[count]; $i++) {
- $uids[$info[$i][uidnumber][0]] = true;
- }
- for ($i = $start; $i < $end; $i++) {
- if (!isset($uids[$i])) {
- $safeuid = $i;
- break;
+
+ //get the year, this'll be the start/prefix of the uid
+ $prefix = date("Y");
+
+ //generate a uid
+ //check to see if it's taken/safe to use
+ $ok = false;
+ while ($ok == false) {
+
+ //generate random number between 00000 and 99999
+ $uid = sprintf("%05d", mt_rand(0, 99999));
+
+ //id return 1 for error (safe to take). 0 for success (taken) not safe
+ exec("id ".$prefix.$uid, $output, $returnVal);
+
+ //check the result of id
+ if ($returnVal == 1) {
+ // We have an unused one!
+ $ok = true;
+ $safeuid = $prefix.$uid;
}
+
}
return $safeuid;
=====================================
static/About/Room.txt
=====================================
--- a/static/About/Room.txt
+++ b/static/About/Room.txt
@@ -1,5 +1,5 @@
-<p>The SUCS room houses our network of Linux desktop PCs, along with spaces for members with laptop computers to get connected.</p>
-<p><img alt="The SUCS Room" src="../pictures/sucsroom.jpg" /></p>
-<h3>Where to find the room</h3>
-<p style="float: left; margin: 0.5em"><a href="../pictures/room-map.jpg"><img alt="Location of SUCS Room on Campus Map" src="../pictures/room-map_thumb.jpg" /></a></p>
-<p>The SUCS room is located at the bottom of the Student Union building, approximately halfway along the side facing the back of Fulton House. To unlock the door, members can swipe their student card in the card reader or hold it up to the <abbr>RFID</abbr> sensor pad denoted by the black square (both located to the right of our blue door, underneath the window).</p>
\ No newline at end of file
+<p>The SUCS room houses our network of Linux desktop PCs, along with spaces for members with laptop computers to get connected.</p>
+<p><img alt="The SUCS Room" src="../pictures/sucsroom.jpg" /></p>
+<h3>Where to find the room</h3>
+<p style="float: left; margin: 0.5em"><a href="../pictures/room-map.jpg"><img alt="Location of SUCS Room on Campus Map" src="../pictures/room-map_thumb.jpg" /></a></p>
+<p>The SUCS room is located at the bottom of the Student Union building, approximately halfway along the side facing the back of Fulton House. To unlock the door, members can swipe their student card in the card reader or hold it up to the <abbr>RFID</abbr> sensor pad denoted by the square (both located to the right of our blue door, underneath the window).</p>
\ No newline at end of file
=====================================
static/Community/Stream.txt
=====================================
--- a/static/Community/Stream.txt
+++ b/static/Community/Stream.txt
@@ -1,28 +1,24 @@
-<p>
-<script src="/~imranh/sucs/jwplayer/jwplayer/jwplayer.js" type="text/javascript"></script>
-</p>
-<p>We are currently streaming <em><strong>nothing</strong></em>.<br />We also stream student forums on behalf of the Student Union - check <a href="http://swansea-union.co.uk/">their website for dates and times</a></p>
-<ul>
-<div id="JWPlayer">Loading the player...</div>
-<script type="text/javascript">
- jwplayer("JWPlayer").setup({
- primary: "html5",
- levels: [{
- file: "http://stream.sucs.org/high.flv",
- label: "High"
- },{
- file: "http://stream.sucs.org/low.flv",
- label: "Low",
- default: true
- }
- ],
- image: ""
- });
-</script>
-</ul>
-<p>
-To view the stream in an external media player <em>(e.g VLC)</em>
-<a href="../Stream/External">Click Here for instructions</a><em><br /></em></p>
-<p>All streams are currently FLV format. If you have any problems, please read the <a href="../Stream/FAQ">FAQ</a></p>
-<ul>
+<p>
+<script src="/~imranh/sucs/jwplayer/jwplayer/jwplayer.js" type="text/javascript"></script>
+</p>
+<p>We are currently streaming <em><strong>nothing</strong></em>.<br />We also stream student forums on behalf of the Student Union - check <a href="http://swansea-union.co.uk/">their website for dates and times</a></p>
+<ul>
+<div id="JWPlayer">Loading the player...</div>
+<script type="text/javascript">
+ jwplayer("JWPlayer").setup({
+ primary: "html5",
+ levels: [{
+ file: "rtmp://137.44.10.80/live",
+ label: "High"
+ },{
+ file: "rtmp://137.44.10.80/live",
+ label: "Low",
+ default: true
+ }
+ ],
+ image: ""
+ });
+</script>
+</ul>
+<ul>
</ul>
\ No newline at end of file
View it on GitLab: https://projects.sucs.org/sucssite/sucs-site/compare/4795e418472c8aa0fe6d342a8a7c1b42906f0d0c...ec70944850afef3ed98bb546c1ef02d4dd7df36c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/devel/attachments/20160312/a658dbd4/attachment-0001.html>
More information about the Devel
mailing list