//////////////////////////////////////////////////////////////////////
// //
// txtForum v.0.5 //
// author: Zoran Raskovic //
// techno_zoki@sendmail.ru //
// techno_zoki@yahoo.com //
// icq: 46742125 //
// date: April 6, 2002 //
// //
// You need to set $posts, $httpindex, //
// $row1_color and $row2_color //
// //
// Please drop me a line or two if you find txtForum useful. //
// Also, send me your url where you are using my forum :) //
// Questions, comments and suggestions are welcomed as well. //
// //
// Special thanks to Ted Suzman for fixing up some code //
// and Ivana Nedeljkovic (Verdana) for the banner. //
// //
//////////////////////////////////////////////////////////////////
//$posts - path to your posts.txt file
$posts = '/home/u17739/auditoriya.info/www/fizika/forum/posts.txt';
//$httpindex - url where your index.php is
$httpindex = '/fizika/forum/index.php';
//$row1_color - color of alternating row one
$row1_color="#ffffff";
//$row2_color - color of alternating row two
$row2_color="#BCD8E2";
////////////////////////DO NOT EDIT BEYOND THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING!!!!/////////////////////////////
//top part
$topics=0;
$msgs=0;
$fp = fopen ($posts, "rb");
while (!feof ($fp))
{
$buff = fgets($fp, 4096);
if(substr($buff, 0, 10 )=="[new_post]") {
$p=explode('|||^^^|||', "$buff");
if ($p[2]==0) {
$topics++;
$msgs++;
}
else {
$msgs++;
}
}
}
fclose($fp);
switch($a)
{
//are we posting a new topic?
CASE "post_new":
//do we have all required info?
if (!$name or !$subject or !$msg) {
header("Location: $httpindex");
exit;
}
else {
//open txt file for reading and writing
$fp = fopen ($posts, "rb");
//get the next post_id
$id=fgets($fp, 4096);
$new_id=$id+1;
//close file
fclose($fp);
$fp = fopen ($posts, "r+b");
//memorize this id
flock ($fp,2);
fwrite($fp, $new_id);
flock ($fp,3);
//close file
fclose($fp);
$fp = fopen ($posts, "ab");
flock ($fp,2);
fwrite($fp, "\r\n");
flock ($fp,3);
//close file
fclose($fp);
//write new post in file
$name=htmlspecialchars($name);
$subject=htmlspecialchars($subject);
$msg=htmlspecialchars($msg);
$msg = preg_replace("/(\015\012)|(\015)|(\012)/","
",$msg);
$datum=date("m-d-Y @ h:i:s");
$fp = fopen ($posts, "ab");
flock ($fp,2);
fwrite($fp, "[new_post]|||^^^|||$new_id|||^^^|||0|||^^^|||$name|||^^^|||$subject|||^^^|||$datum|||^^^|||$msg|||^^^|||");
flock ($fp,3);
//close file
fclose($fp);
//forward user to the topic listing
header("Location: $httpindex");
exit;
}
BREAK;
//if there's a reply..
CASE "reply":
//do we have all required info?
if (!$name or !$subject or !$msg) {
header("Location: {$httpindex}?a=view_thread&tid=$tid");
exit;
}
else {
//open txt file for reading and writing
$fp = fopen ($posts, "rb");
//get the next post_id
$id=fgets($fp, 4096);
$new_id=$id+1;
//close file
fclose($fp);
$fp = fopen ($posts, "r+b");
//memorize this id
flock ($fp,2);
fwrite($fp, $new_id);
flock ($fp,3);
//close file
fclose($fp);
$fp = fopen ($posts, "ab");
flock ($fp,2);
fwrite($fp, "\r\n");
flock ($fp,3);
//close file
fclose($fp);
//write new post in file
$name=htmlspecialchars($name);
$subject=htmlspecialchars($subject);
$msg=htmlspecialchars($msg);
$msg = preg_replace("/(\015\012)|(\015)|(\012)/","
",$msg);
$datum=date("m-d-Y @ h:i:s");
$fp = fopen ($posts, "ab");
flock ($fp,2);
fwrite($fp, "[new_post]|||^^^|||$new_id|||^^^|||$tid|||^^^|||$name|||^^^|||$subject|||^^^|||$datum|||^^^|||$msg|||^^^|||");
flock($fp,3);
//close file
fclose($fp);
//forward user to the thread they just posted to
header("Location: {$httpindex}?a=view_thread&tid=$tid");
exit;
}
BREAK;
//are we viewing a thread?
CASE "view_thread":
?>
![]() | |
| Вернуться к списку тем | |
| $topics тем and $msgs сообщений | $now $timezone |
| Author | Message |
| $p[3] | $p[4] $msg1 |
| $p[5] | |
| $p[3] | Re: $p[4] $msg1 |
| $p[5] | |
| $p[3] | Re: $p[4] $msg1 |
| $p[5] |
Back to list"; //display form for replying echo "
"; BREAK; //if nothing else, list all threads here DEFAULT: ?>![]() | |
| $topics тем и $msgs сообщений | $now $timezone |
| Subject | Author | Replies | Date |
| $p[4] | $p[3] | $replies | $p[5] |
"; // display form for posting a new topic echo "Отправить сообщение
"; BREAK; } ?>