-
Notifications
You must be signed in to change notification settings - Fork 2
/
addForumExecute.php
49 lines (41 loc) · 1.37 KB
/
addForumExecute.php
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
<?php
include("common.php");
$name = stripslashes($_POST['name']);
$name = str_replace("\n","",$name);
$name = str_replace("\r\n","",$name);
$name = str_replace("\r","",$name);
$name = str_replace("~","",$name);
$description = stripslashes($_POST['description']);
$description = str_replace("\n","",$description);
$description = str_replace("\r\n","",$description);
$description = str_replace("\r","",$description);
$description = str_replace("~","",$description);
$description = substr($description,3,strlen($description)-7);
if (trim($name) == "")
{
header("Location: addForum.php?error=1");
exit();
}
if (trim($description) == "")
{
header("Location: addForum.php?error=2");
exit();
}
$forumId = trim(file_get_contents("db/forumNo.dat"));
$fh = fopen("db/forumList.dat","a");
fwrite($fh,$forumId."~".$name."~".$description."~0~0\n");
fclose($fh);
file_put_contents("db/Topics/".$forumId.".dat","");
file_put_contents("db/Topics/".$forumId."sticky.dat","");
file_put_contents("db/forumNo.dat",($forumId+1)."\n");
//***********************
$fileC = file("db/forumStatistics.dat",FILE_IGNORE_NEW_LINES);
$fileC[0] = trim($fileC[0]) + 1;
$str = "";
foreach ($fileC as $statistic)
{
$str .= $statistic."\n";
}
file_put_contents("db/forumStatistics.dat",$str);
header("Location: index.php");
?>