aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcassio <cassiopc@gmail.com>2018-10-29 16:21:03 +0000
committercassio <cassiopc@gmail.com>2018-10-29 16:21:03 +0000
commit61ce4a0eb58d0e1632b2a1dc87195ce1faada78e (patch)
tree83d473c3ea4d291d0cca9b0a9b983a607d059183
parent6ef5a17d21e2b4c89e4c42627b148f9d5adaa2ab (diff)
downloadboca-61ce4a0eb58d0e1632b2a1dc87195ce1faada78e.tar.gz
boca-61ce4a0eb58d0e1632b2a1dc87195ce1faada78e.zip
check if same computer is being used - this is only useful for in-loco contests
-rw-r--r--src/flog.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/flog.php b/src/flog.php
index ed5afbd..0134b1c 100644
--- a/src/flog.php
+++ b/src/flog.php
@@ -156,6 +156,37 @@ function DBLogInContest($name,$pass,$contest,$msg=true) {
unset($_SESSION["usertable"]);
return false;
}
+
+ if(!ctype_alnum($name)) {
+ LOGLevel("User $name tried to log in contest $contest but username is not alphanum.",2);
+ if($msg) MSGError("Username must be alpha numeric.");
+ unset($_SESSION["usertable"]);
+ return false;
+ }
+ $ccode = explode(' ',trim($_SERVER['HTTP_USER_AGENT']),100);
+ $ccode = $ccode[count($ccode)-1];
+ $ds = DIRECTORY_SEPARATOR;
+ if($ds=="") $ds = "/";
+ $dircode=$_SESSION["locr"] . $ds . "private" . $ds . "agentcode";
+ @mkdir($dircode);
+ $dircode .= $ds . $contest . '-' . $name;
+ if(@file_exists($dircode)) {
+ if(($prevuser = @file_get_contents($dircode)) === false) {
+ LOGLevel("User $name tried to log in contest $contest but computer file cannot be read.",2);
+ if($msg) MSGError("Invalid computer (2).");
+ unset($_SESSION["usertable"]);
+ return false;
+ }
+ if($prevuser != $ccode) {
+ LOGLevel("User $name tried to log in contest $contest but computer is invalid.",2);
+ if($msg) MSGError("Invalid computer (3).");
+ unset($_SESSION["usertable"]);
+ return false;
+ }
+ } else {
+ @file_put_contents($dircode, $ccode);
+ }
+
$gip=getIP();
if ($a["userip"] != $gip && $a["userip"] != "" && $a["usertype"] != "score") {
LOGLevel("User $name is using two different IPs: " . $a["userip"] .