-
Notifications
You must be signed in to change notification settings - Fork 0
/
hotcoffeepage.php
129 lines (104 loc) · 3.54 KB
/
hotcoffeepage.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?
/* C
M Hot Coffee CMS - Page
S
[_]) https://github.com/ilbak/hotcoffeecms */
// Password author (change it!)
$pagepass="changeit";
if (!isset($cmspagina)) { die(); }
// If there is the related page, creates it
if (!file_exists($pag."-data-none.php")) {
$pagejunk2=$pag."-data-none.php";
$pagejunk5 = fopen($pagejunk2, "w");
fwrite($pagejunk5, "!! Page under construction !!");
fclose($pagejunk5);
}
$pagepass2 = $_POST['pagepass2'];
$pagepost = $_POST['pagepost'];
$pageedit = $_POST['pageedit'];
if ($_GET['pageobj']=="") { $pageobj=$_POST['pageobj']; } else { $pageobj=$_GET['pageobj']; }
function errore($pag) {
// Writes a log of the error
$pagejunk1=time();
$pagejunk2=$pag."errore-none.php";
$pagejunk5 = fopen($pagejunk2, "w");
fwrite($pagejunk5, "<?\n");
fwrite($pagejunk5, "\$errip=\"".md5($_SERVER['REMOTE_ADDR'])."\";\n");
fwrite($pagejunk5, "\$errtime=\"".$pagejunk1."\";\n");
fwrite($pagejunk5, "?>");
fclose($pagejunk5);
}
function errorever($pag) {
if (file_exists($pag."errore-none.php")) {
include $pag."errore-none.php";
$pagejunk=time();
$pagejunk2=$pagejunk-$errtime;
if (($errip==md5($_SERVER['REMOTE_ADDR'])) && ($pagejunk2<=20)){
echo "This IP is not authorized to operate. Please try again in a few seconds.";
die();
}
} }
function erroreclean($pag) {
if (file_exists($pag."errore-none.php")) {
include $pag."errore-none.php";
$pagejunk=time();
$pagejunk2=$pagejunk-$errtime;
if ($pagejunk2>20){
unlink($pag."errore-none.php");
}}
}
switch ($pageobj) {
case 0:
include $pag."-data-none.php";
echo "<div align=right><br><a href='index.php?pag=".$pag."&pageobj=1'>[ Edit ]</a></div>";
break;
case 1:
// Modify
// Verify
errorever($pag);
if ($pageedit!="1") {
$pagejunk=fopen($pag."-data-none.php","r");
$pagecontent=fread($pagejunk,filesize($pag."-data-none.php"));
fclose($pagejunk);
echo "<form method='post'><fieldset><legend>Edit page</legend>";
echo "<input type='hidden' name='pageobj' value='1'>";
echo "<input type='hidden' name='pageedit' value='1'>";
echo "<input type='hidden' name='pag' value='".$pag."'>";
echo "<textarea name='pagepost' rows=30 cols=50 id='mytextarea'>".$pagecontent."</textarea><br />";
echo "<br><br>Password: <input type='password' name='pagepass2' value='' size='15'><br/>";
echo "<input type='reset' value='Reset'><input type='submit' value='OK'></center></fieldset></form>";
echo "<div align=right><br><a href='index.php?pag=".$pag."'>[ Back ]</a></div>";
echo $pageobj;
} else {
// if "pageedit" is active changes the page
if ($pagepass2==$pagepass) {
// Verify pass
$pagejunk2=$pag."-data-none.php";
$pagejunk5 = fopen($pagejunk2, "w");
fwrite($pagejunk5, $pagepost);
fclose($pagejunk5);
erroreclean($pag);
echo "<br>The page has been modified!<br><br>";
echo "<div align=right><br><a href='index.php?pag=".$pag."'>[ Back ]</a></div>";
} else {
echo "<br>Password error!<br><br>";
errore($pag);
echo "<br><div align=right><br><a href='index.php?pag=".$pag."'>[ Back ]</a></div>";
}
}
break;
}
?>
<script src='http://cdn.tinymce.com/4/tinymce.min.js'></script>
<script>
tinymce.init({
selector: '#mytextarea',
height: 500,
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste imagetools"
],
toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | link image',
});
</script>