Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*=================con=======================*/
- $max_users = (int)2;
- //--------------------------------------------
- $accessArray = array();
- $timeCodeArray = array();
- $order = array("\r\n", "\n", "\r");
- $replace = '';
- /*=================fig=======================*/
- $action = $_POST['action'];
- if($action != NULL)
- {
- $file = "users.txt";
- $thisFile = file($file);
- $accessCode = $_POST['accessCode'];
- $write_text = $_POST['sendText'];
- $i = 0;
- while ($i <= (count($thisFile))-1) {
- if($i%2 == 0)
- {
- array_push($accessArray, str_replace($order, $replace, $thisFile[$i]));
- }
- else
- {
- array_push($timeCodeArray, str_replace($order, $replace, $thisFile[$i]));
- }
- $i++;
- }
- /*========================================================*/
- if($action == "establish")
- {
- $file = "users.txt";
- $thisFile = file($file);
- /*if statement, returning true or false*/
- if(checkIfUsersGone($accessArray, $timeCodeArray,$thisFile,$max_users) == "true")
- {
- echo "joining";
- $today = getdate();
- $now = ($today["hours"]*3600)+($today["minutes"]*60)+$today["seconds"]."\n";
- $userJoin = $accessCode."\n".$now;
- $fp = fopen('users.txt', 'a+');
- fwrite($fp, $userJoin);
- fclose($fp);
- }
- else
- {
- echo "full";
- }
- }
- if($action == "ping")
- {
- userPinged($thisFile,$accessCode);
- /*$order = array("\r\n", "\n", "\r");
- $replace = '';
- $today = getdate();
- $now = ($today["hours"]*3600)+($today["minutes"]*60)+$today["seconds"]."\n";*/
- /*$fp = fopen('users.txt', 'w');
- fwrite($fp, $thisFile[0].$thisFile[1].$thisFile[2].$thisFile[3]);
- fclose($fp);*/
- }
- /*========================================================*/
- }
- else
- {
- echo "urdoingitwrong";
- //echo $accessCode;
- }
- function checkIfUsersGone($aaa, $ttt, $mmm, $max)
- {
- $i = 0;
- $today = getdate();
- $now = (int)($today["hours"]*3600)+($today["minutes"]*60)+$today["seconds"];
- $saveString;
- $activeUsers = 0;
- while ($i <= (count($mmm))-1) {
- if($i%2 == 0)
- {
- if($now-$ttt[($i/2)] > 10){}
- elseif($now-$ttt[($i/2)] < -100) {}
- else{$saveString .= $mmm[$i].$mmm[$i+1];$activeUsers .= 1;};
- }
- else
- {
- }
- $i++;
- }
- $fp = fopen('users.txt', 'w+');
- fwrite($fp, $saveString);
- fclose($fp);
- if((int)$activeUsers < (int)$max)
- {
- return "true";
- }
- else
- {
- return "false";
- }
- }
- function userPinged($mmm, $aaa)
- {
- $order = array("\r\n", "\n", "\r");
- $replace = '';
- //--------
- $i = 0;
- $saveString;
- $today = getdate();
- $now = ($today["hours"]*3600)+($today["minutes"]*60)+$today["seconds"]."\n";
- while ($i <= (count($mmm))-1) {
- if($i%2 == 0)
- {
- if(str_replace($order, $replace, $mmm[$i]) == $aaa)
- {
- $saveString .= $mmm[$i].$now;};
- }
- else
- {
- $saveString .= $mmm[$i].$mmm[$i+1];};
- }
- }
- $i++;
- }
- echo "\n".$saveString;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement