-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathforumListChange.php
100 lines (91 loc) · 2.05 KB
/
forumListChange.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
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
<?php
include("common.php");
if ($_GET['mode'] == 'down')
{
$fhTemp = fopen("db/forumListtemp.dat","w");
$fh = fopen("db/forumList.dat","r");
while (!feof($fh))
{
$a = trim(fgets($fh));
if ($a != "")
{
$item = new Forum($a);
if ($item->getForumId() == $_GET['forumId'])
{
$b = trim(fgets($fh));
fwrite($fhTemp, $b."\n");
}
fwrite($fhTemp, $a."\n");
}
}
fclose($fh);
fclose($fhTemp);
unlink("db/forumList.dat");
rename("db/forumListtemp.dat", "db/forumList.dat");
}
else if ($_GET['mode'] == 'up')
{
$fhTemp = fopen("db/forumListtemp.dat","w");
$fh = fopen("db/forumList.dat","r");
$a = trim(fgets($fh));
while (!feof($fh))
{
$b = trim(fgets($fh));
$item = new Forum($b);
if ($item->getForumId() == $_GET['forumId'])
{
fwrite($fhTemp, $b."\n");
$b = $a;
}
else
{
if ($a != "")
{
fwrite($fhTemp, $a."\n");
}
}
$a = $b;
}
if ($a != "")
{
fwrite($fhTemp, $a."\n");
}
fclose($fh);
fclose($fhTemp);
unlink("db/forumList.dat");
rename("db/forumListtemp.dat", "db/forumList.dat");
}
else if ($_GET['mode'] == 'delete')
{
$fhTemp = fopen("db/forumListtemp.dat","w");
$fh = fopen("db/forumList.dat","r");
while (!feof($fh))
{
$a = trim(fgets($fh));
if ($a != "")
{
$item = new Forum($a);
if ($item->getForumId() != $_GET['forumId'])
{
fwrite($fhTemp, $a."\n");
}
}
}
fclose($fh);
fclose($fhTemp);
unlink("db/forumList.dat");
rename("db/forumListtemp.dat", "db/forumList.dat");
unlink("db/Topics/".$_GET['forumId'].".dat");
unlink("db/Topics/".$_GET['forumId']."sticky.dat");
//***********************
$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");
?>