Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.9
Fetching contributors…

Cannot retrieve contributors at this time

executable file 138 lines (127 sloc) 2.727 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
<?php
function addUser($userName)
{
$fileC = file("db/forumOnlineUsers.dat",FILE_IGNORE_NEW_LINES);

$updated = false;
for ($i = 0; $i < sizeOf($fileC); $i += 2)
{
if ($fileC[$i] == $userName)
{
$fileC[$i+1] = time();
$updated = true;
}
}

if (!$updated)
{
array_push($fileC, $userName);
array_push($fileC, time());
}

$str = "";
foreach ($fileC as $line)
{
$str .= $line."\n";
}
file_put_contents("db/forumOnlineUsers.dat",$str);
}

function addGuest($ip)
{
$fileC = file("db/forumOnlineGuests.dat",FILE_IGNORE_NEW_LINES);

$updated = false;
for ($i = 0; $i < sizeOf($fileC); $i += 2)
{
if ($fileC[$i] == $ip)
{
$fileC[$i+1] = time();
$updated = true;
}
}

if (!$updated)
{
array_push($fileC, $ip);
array_push($fileC, time());
}

$str = "";
foreach ($fileC as $line)
{
$str .= $line."\n";
}
file_put_contents("db/forumOnlineGuests.dat",$str);
}

function purge()
{
$fileC = file("db/forumOnlineGuests.dat",FILE_IGNORE_NEW_LINES);
$str = "";
for ($i = 0; $i < sizeOf($fileC)-1; $i += 2)
{
if (time() - $fileC[$i+1] <= 300)
{
$str .= $fileC[$i]."\n".$fileC[$i+1]."\n";
}
}
if (trim($str) != "")
{
file_put_contents("db/forumOnlineGuests.dat",$str);
}
else
{
file_put_contents("db/forumOnlineGuests.dat","");
}

$fileC = file("db/forumOnlineUsers.dat",FILE_IGNORE_NEW_LINES);
$str = "";
for ($i = 0; $i < sizeOf($fileC)-1; $i += 2)
{
if (time() - $fileC[$i+1] <= 300)
{
$str .= $fileC[$i]."\n".$fileC[$i+1]."\n";
}
}
if (trim($str) != "")
{
file_put_contents("db/forumOnlineUsers.dat",$str);
}
else
{
file_put_contents("db/forumOnlineUsers.dat","");
}
}

function removeUser($userName)
{
$fileC = file("db/forumOnlineUsers.dat",FILE_IGNORE_NEW_LINES);
$str = "";
for ($i = 0; $i < sizeOf($fileC)-1; $i += 2)
{
if ($fileC[$i] != $userName)
{
$str .= $fileC[$i]."\n".$fileC[$i+1]."\n";
}
}
if (trim($str) != "")
{
file_put_contents("db/forumOnlineUsers.dat",$str);
}
else
{
file_put_contents("db/forumOnlineUsers.dat","");
}
}

function removeGuest($ip)
{
$fileC = file("db/forumOnlineGuests.dat",FILE_IGNORE_NEW_LINES);
$str = "";
for ($i = 0; $i < sizeOf($fileC)-1; $i += 2)
{
if ($fileC[$i] != $ip)
{
$str .= $fileC[$i]."\n".$fileC[$i+1]."\n";
}
}
if (trim($str) != "")
{
file_put_contents("db/forumOnlineGuests.dat",$str);
}
else
{
file_put_contents("db/forumOnlineGuests.dat","");
}
}
?>
Something went wrong with that request. Please try again.