Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Users online meter
- <?php
- if (!is_dir('OU')) mkdir('OU');
- if (!is_dir('OG')) mkdir('OG');
- if (isset($_POST['logout'])) setcookie('user',$_GET['user'],time()-1000);
- $files = scandir('OU');
- foreach ($files as $user){
- if ($user=='.' || $user=='..') continue;
- $handle=fopen("OU/$user",'r');
- $time = fread($handle, filesize("OU/$user"));
- fclose($handle);
- if ((time()-$time)>6) unlink("OU/$user");
- }
- $gcount=0;
- $files = scandir('OG');
- foreach ($files as $user){
- if ($user=='.' || $user=='..') continue;
- $handle=fopen("OG/$user",'r');
- $time = fread($handle, filesize("OG/$user"));
- fclose($handle);
- if ((time()-$time)>6) {unlink("OG/$user");$gcount--;}
- $gcount++;
- }
- if (!is_file('check.php')){
- $handle = fopen("check.php", "w");
- $c='<meta http-equiv="refresh" content="3">
- <?php
- if (isset($_GET["user"]) && isset($_GET["type"])){
- $user=$_GET["user"];
- $type=$_GET["type"];
- if ($type=="user"){
- $handle = fopen("OU/$user", "w");
- fwrite($handle, time());
- fclose($handle);
- }else{
- $handle = fopen("OG/$user", "w");
- fwrite($handle, time());
- fclose($handle);
- }
- }
- ?>';
- fwrite($handle, $c);
- fclose($handle);
- }
- if (isset($_POST['submit'])){
- if ($_POST['user']!=''){
- setcookie('user',$user,time()+1000);
- $user=$_POST['user'];
- $handle = fopen("OU/$user", "w");
- fwrite($handle, time());
- fclose($handle);
- $type='user';
- }}else{
- if (isset($_COOKIE['me']))
- $user=$_COOKIE['me'];
- else{
- $gcount++;
- $user='Guest'.(rand(1,999)*rand(1,999)/rand(1,999));
- setcookie('me',$user);}
- $handle = fopen("OG/$user", "w");
- fwrite($handle, time());
- fclose($handle);
- $type='guest';
- }
- $files = scandir('OU');
- $users='';
- foreach ($files as $userd) if ($userd!='.' && $userd!='..') $users.='and '.$userd."<br>";
- ?>
- <table style="border: 1px solid #000000; width: 343px; background-color: #F8F8D7;" align="center">
- <?php if (!isset($_POST['submit'])&& !isset($_COOKIE['user'])){ ?>
- <form action="" method="post">
- <tr>
- <td style="padding:5px;width: 105px; font-family: 'Times New Roman', Times, serif; font-size: 14pt; border-left-style: solid; border-left-width: 0; border-top-style: solid; border-top-width: 0; border-right-width: 0; border-bottom-width: 0;">User Name:</td>
- <td style="padding:5px;border-right-style: solid; border-right-width: 0; border-top-style: solid; border-top-width: 0; width: 123px; border-left-width: 0; border-bottom-width: 0;">
- <input name="user" style="width: 220px; font-size: 14pt; font-family: 'Times New Roman', Times, serif;"></td>
- </tr>
- <tr>
- <td style="padding:5px;width: 105px; font-family: 'Times New Roman', Times, serif; font-size: 14pt; border-left-style: solid; border-left-width: 0; border-right-width: 0; border-top-width: 0; border-bottom-width: 0;">Password:</td>
- <td style="padding:5px;border-right-style: solid; border-right-width: 0; border-bottom-style: solid; border-bottom-width: 0; width: 123px; border-left-width: 0; border-top-width: 0;">
- <input name="pass" style="width: 170px;width: 220px; font-size: 14pt;" type="password"></td>
- </tr>
- <tr>
- <td style="padding:5px; font-family: 'Times New Roman', Times, serif; font-size: 14pt; text-align: right; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-bottom-style: solid; border-bottom-width: 0; border-top-width: 0;" colspan="2">
- <br>
- <input name="submit" style="font-size: 14pt; font-family: 'times New Roman', Times, serif; color: #F132A8; width: 80px;" type="submit" value="Login"></td>
- </tr>
- </form>
- <?php }else { ?>
- <form action="<?php echo $_SERVER['PHP_SELF'].'?user=$user' ?>" method="post">
- <td style="padding:5px; font-family: 'Times New Roman', Times, serif; font-size: 14pt; text-align: right; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; border-bottom-style: solid; border-bottom-width: 0; border-top-width: 0;" colspan="2">
- <br>
- <input name="logout" style="font-size: 14pt; font-family: 'times New Roman', Times, serif; color: #F132A8; width: 80px;" type="submit" value="Logout"></td>
- </form>
- <?php } ?>
- </table>
- <table style="border: 1px solid #000000; width: 343px; background-color: #D7F6F8;" align="center">
- <tr>
- <td style="padding:5px;font-family: 'Times New Roman', Times, serif; font-size: 14pt; border-left-style: solid; border-left-width: 0; border-top-style: solid; border-top-width: 0; text-align: center; border-right-width: 0; border-bottom-width: 0;">
- Who is Online?</td>
- </tr>
- <tr>
- <td style="padding:5px;font-family: 'Times New Roman', Times, serif; font-size: 14pt; border-left-style: solid; border-left-width: 0; text-align: center; border-right-width: 0; border-top-width: 0; border-bottom-width: 0;">
- <span style="color: #7B0909">
- <?php
- echo "$gcount Guests<br>";
- echo($users);
- ?>
- </span>
- </tr>
- </table>
- <div style="text-align: center"><br>
- <font face="Tahoma"><a target="_blank" href=">
- <span style="font-size: 8pt; text-decoration: none"></span></a></font>
- </div>
- <iframe id="I1" border="1" frameborder="1" name="I1" style="visibility:hidden;display:none" src="<?php echo "check.php?user=$user&type=$type" ?>" >Your browser does not support inline frames or is currently configured not to display inline frames.
- </iframe>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement