<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> <head> <meta http-equiv="Content-Type" CONTENT="text/html; charset=utf-8">
<title>Comments</title> <style type="text/css"> body {
background : #FFFFFF; color : #35393D; font-family : Verdana, Arial, Helvetica; font-size : 12px; text-decoration : none; text-indent : 0px; } </style> </head>
<body> <?php $start = microtime(TRUE); error_reporting(E_ALL); include('comments.class.php');
$comments = new Comments(); $comments->encoding('UTF-8'); # $comments->reverse(5); $comments->increment(5); $comments->id('commentview'); $comments->dir('comments'); if (isset($_POST['add'])) { $comments->add('User', $_POST['comment'], $_POST['reply_id']); $_GET['cpage'] = $comments->pageNum(); } if (isset($_POST['change'])) $comments->change($_POST['change_id'], $_POST['comment']); if (isset($_POST['delete'])) { $comments->delete($_POST['delete_id']); $_GET['cpage'] = $comments->pageNum(); } ?> <table> <tr> <td> <font color="green"> Comments class demo page.<br> This class stores user comments in text files. </font> </td> </tr> </table> <table> <tr> <td> Comments: </td> </tr> <?php function commentprint($comment) { $date = date('d.m.Y h:i:s A', $comment['timestamp']); $nbsp = ''; for ($i=0; $i<$comment['deep']*4; $i++) $nbsp .= ' '; echo "<tr><td>{$nbsp}id={$comment['id']} |{$comment['user']} | $date</td></tr><tr><td>{$nbsp}{$comment['comment']}</td></tr>\r\n"; } if (! isset($_GET['cpage'])) $_GET['cpage'] = 1; $comments->fetchFunc('commentprint'); $comments->fetch($_GET['cpage']); ?> </table> <table> <tr> <td> <?php for ($i=1; $i<=$comments->pageNum(); $i++) echo "<a href=\"{$_SERVER['PHP_SELF']}?cpage={$i}\">{$i}</a> "; ?> </td> </tr> </table> <form action="<?php echo $_SERVER['PHP_SELF'].'?cpage='.$_GET['cpage']; unset($comments); ?>" method="post"> <table> <tr> <td colspan="2"> Your comment : </td> </tr> <tr> <td> Change id. </td> <td align="right"> <input name="change_id"> </td> </tr> <tr> <td> Delete id. </td> <td align="right"> <input name="delete_id"> </td> </tr>
<tr> <td> Reply id. </td> <td align="right"> <input name="reply_id"> </td> </tr>
<tr> <td colspan="2"> <textarea name="comment" rows=5 cols=50></textarea> </td> </tr> <tr> <td align="right" colspan="2"> <input style="width: 75px" type="submit" name="delete" value="Delete"> <input style="width: 75px" type="submit" name="change" value="Change"> <input style="width: 75px" type="submit" name="add" value="Add"> </td> </tr>
</table> </form> <?php $time = round((microtime(TRUE)-$start), 5); echo "Generated in $time s."; ?> </body> </html>
|