From a16d95d05b16377dbc5b3c30ddf254a5493eae58 Mon Sep 17 00:00:00 2001 From: Imran Hussain Date: Tue, 29 Dec 2015 17:07:38 +0000 Subject: [PATCH 1/6] Replace the old UID generation. New UID generation system that uses the full year as a prefix. Should stop UIDs from being reused. --- components/signup.php | 12 ++---------- lib/member_functions.php | 35 ++++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/components/signup.php b/components/signup.php index 3e722a1..c850da5 100644 --- 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 diff --git a/lib/member_functions.php b/lib/member_functions.php index a7a5701..b4579c7 100644 --- 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("%06d", mt_rand(0, 99999)); + + // id return 1 for error (safe to take). 0 for sucess (taken) not safe + shell_exec("id ".$prefix.$uid, $output, $returnVal); + + //check the result of id + if ($returnVal == 1) { + // We have a unused one! + $ok = true; + $sfaeuid = $prefix.$uid; } + } return $safeuid; -- GitLab From 080478fe19d550e7de5157cdb22c290025f6b306 Mon Sep 17 00:00:00 2001 From: Laurence Sebastian Bowes Date: Sat, 13 Feb 2016 03:26:59 +0000 Subject: [PATCH 2/6] Twat --- lib/member_functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/member_functions.php b/lib/member_functions.php index b4579c7..ff41a26 100644 --- a/lib/member_functions.php +++ b/lib/member_functions.php @@ -50,7 +50,7 @@ function generateUid() if ($returnVal == 1) { // We have a unused one! $ok = true; - $sfaeuid = $prefix.$uid; + $safeuid = $prefix.$uid; } } -- GitLab From c2f7394d9ed8408f824008a6a2ed5a57f03af51e Mon Sep 17 00:00:00 2001 From: Laurence Sebastian Bowes Date: Sat, 13 Feb 2016 03:44:17 +0000 Subject: [PATCH 3/6] Minor fixes. Happy with this code now. --- lib/member_functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/member_functions.php b/lib/member_functions.php index ff41a26..f5f4d7b 100644 --- a/lib/member_functions.php +++ b/lib/member_functions.php @@ -41,14 +41,14 @@ function generateUid() while ($ok == false) { //generate random number between 00000 and 99999 - $uid = sprintf("%06d", mt_rand(0, 99999)); + $uid = sprintf("%05d", mt_rand(0, 99999)); - // id return 1 for error (safe to take). 0 for sucess (taken) not safe - shell_exec("id ".$prefix.$uid, $output, $returnVal); + //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 a unused one! + // We have an unused one! $ok = true; $safeuid = $prefix.$uid; } -- GitLab From 85a840ef4881bc721f037017a959334aba835199 Mon Sep 17 00:00:00 2001 From: Laurence Sebastian Bowes Date: Wed, 17 Feb 2016 12:42:57 +0000 Subject: [PATCH 4/6] Updated info following on from what I think #29 was talking about --- static/About/Room.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/static/About/Room.txt b/static/About/Room.txt index ba2df62..0f66a67 100644 --- a/static/About/Room.txt +++ b/static/About/Room.txt @@ -1,5 +1,5 @@ -

The SUCS room houses our network of Linux desktop PCs, along with spaces for members with laptop computers to get connected.

-

The SUCS Room

-

Where to find the room

-

Location of SUCS Room on Campus Map

-

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 RFID sensor pad denoted by the black square (both located to the right of our blue door, underneath the window).

\ No newline at end of file +

The SUCS room houses our network of Linux desktop PCs, along with spaces for members with laptop computers to get connected.

+

The SUCS Room

+

Where to find the room

+

Location of SUCS Room on Campus Map

+

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 RFID sensor pad denoted by the square (both located to the right of our blue door, underneath the window).

\ No newline at end of file -- GitLab From bbd8423ef23d7cdc002f6fd712778992983e6a59 Mon Sep 17 00:00:00 2001 From: Imran Hussain Date: Sat, 12 Mar 2016 15:59:14 +0000 Subject: [PATCH 5/6] Update stream page with new info --- static/Community/Stream.txt | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/static/Community/Stream.txt b/static/Community/Stream.txt index d408088..df67df9 100644 --- a/static/Community/Stream.txt +++ b/static/Community/Stream.txt @@ -1,28 +1,28 @@ -

- -

-

We are currently streaming nothing.
We also stream student forums on behalf of the Student Union - check their website for dates and times

-
    -
    Loading the player...
    - -
-

-To view the stream in an external media player (e.g VLC) -Click Here for instructions

-

All streams are currently FLV format. If you have any problems, please read the FAQ

-
    +

    + +

    +

    We are currently streaming nothing.
    We also stream student forums on behalf of the Student Union - check their website for dates and times

    +
      +
      Loading the player...
      + +
    +

    +To view the stream in an external media player (e.g VLC) +Click Here for instructions

    +

    All streams are currently RTMP format.

    +
    \ No newline at end of file -- GitLab From edf6aa38c27c9ce13bb50379a2741fbde8c2975a Mon Sep 17 00:00:00 2001 From: Imran Hussain Date: Sat, 12 Mar 2016 16:00:36 +0000 Subject: [PATCH 6/6] Remove old info from stream page --- static/Community/Stream.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/static/Community/Stream.txt b/static/Community/Stream.txt index df67df9..5494137 100644 --- a/static/Community/Stream.txt +++ b/static/Community/Stream.txt @@ -20,9 +20,5 @@ });
-

-To view the stream in an external media player (e.g VLC) -Click Here for instructions

-

All streams are currently RTMP format.

\ No newline at end of file -- GitLab