Skip to content

Commit

Permalink
History
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Brüggemann committed Jul 25, 2014
1 parent 96cabc0 commit 0551fa7
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
2 changes: 2 additions & 0 deletions history.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
body {padding: 0 2ex;}
table,th,td {border-collapse: collapse; border: 1px solid silver; padding: 0.5em 1ex;}
56 changes: 56 additions & 0 deletions history.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="pl">

<head>
<title></title>
<link rel="stylesheet" href="history.css" />
<meta charset="UTF-8" />
</head>

<body>

<?php

function v($v, $czyscHtmlIExit = false) {
if ($czyscHtmlIExit) ob_end_clean();
echo '<pre>' . print_r($v, true) . '</pre>';
if ($czyscHtmlIExit) exit;
}
function vv($v, $czyscHtmlIExit = false) {
if ($czyscHtmlIExit) ob_end_clean();
echo '<pre>';
var_dump($v);
echo '</pre>';
if ($czyscHtmlIExit) exit;
}
function vvv($var, & $result = null, $is_view = true)
{
if (is_array($var) || is_object($var)) foreach ($var as $key=> $value) vvv($value, $result[$key], false);
else $result = $var;

if ($is_view) v($result);
}



foreach (glob('./history/*') as $f) {

echo '<h1>'.basename($f).'</h1>';

$data = file($f, FILE_IGNORE_NEW_LINES);
echo '<table>';
foreach ($data as $e) {
$d = explode('&', $e);
echo '<tr>'
.'<td>'.date('H:i:s', (int)$d[0]).'</td>'
.'<td>'.$d[1].'</td>'
.'<td>'.$d[2].'</td>'
.'</tr>';
}
echo '</table>';
}

?>

</body>
</html>
35 changes: 35 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
<?php

function v($v, $czyscHtmlIExit = false) {
if ($czyscHtmlIExit) ob_end_clean();
echo '<pre>' . print_r($v, true) . '</pre>';
if ($czyscHtmlIExit) exit;
}
function vv($v, $czyscHtmlIExit = false) {
if ($czyscHtmlIExit) ob_end_clean();
echo '<pre>';
var_dump($v);
echo '</pre>';
if ($czyscHtmlIExit) exit;
}
function vvv($var, & $result = null, $is_view = true)
{
if (is_array($var) || is_object($var)) foreach ($var as $key=> $value) vvv($value, $result[$key], false);
else $result = $var;

if ($is_view) v($result);
}



function loginForm() {
echo'
<div id="loginform">
Expand All @@ -18,6 +40,17 @@ function getSetup($key = null) {
return isset($key) ? $arr[$key] : $arr;
}

function deleteOldHistory() {
$expireHistory = getSetup('expire_history');
$expireDate = date('Y-m-d', strtotime("-$expireHistory day"));
foreach (glob('./history/*') as $f) {
if (basename($f) < $expireDate) {
unlink($f);
}
}
}



//-------------------------

Expand Down Expand Up @@ -46,12 +79,14 @@ function getSetup($key = null) {
<?php
if (!isset($_SESSION['name'])) {
loginForm();
deleteOldHistory();
} else {
?>
<div id="wrapper">
<div id="menu">
<p class="welcome">Welcome, <b><?php echo $_SESSION['name']; ?></b></p>
<p class="logout"><a id="exit" href="#">Exit Chat</a></p>
<p class="logout" style="margin-right: 1em;"><a target="_blank" href="history.php">History</a></p>
<div style="clear:both"></div>
</div>
<div id="chatbox"><?php
Expand Down
5 changes: 4 additions & 1 deletion setup.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
interval = 2500 ; in milliseconds

; extra time for cache when is problem with Internet
expire_cache = 60 ; in seconds
expire_cache = 60 ; in seconds

; time for history
expire_history = 30 ; in days

0 comments on commit 0551fa7

Please sign in to comment.