-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdown.php
209 lines (159 loc) · 6.6 KB
/
down.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
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/grid.css" type="text/css" media="screen">
<script src="js/jquery-1.6.3.min.js" type="text/javascript"></script>
</head>
<body id="page3">
<div class="extra">
<div class="main">
<!--==============================header=================================-->
<header>
<div class="wrapper p4">
<h1><a href="index.html">Software</a></h1>
<ul class="list-services">
<li><a href="#">Site Map</a></li>
<li><a href="#">Help</a></li>
<li><a href="#">FAQs</a></li>
</ul>
</div>
<nav>
<ul class="menu">
<li><a href="index.html">Home</a></li>
<li><a href="CaricoF.html">Upload</a></li>
<li class="active"><a href="downloads.html">Downloads</a></li>
<li ><a href="controllo.html">Controllo</a></li>
<li class="last"><a href="contacts.html">Contacts</a></li>
</ul>
</nav>
</header>
<?php
//SOMETHING DONE THAT SETS $url
function create_zip($files = array(),$destination = '',$overwrite = false) {
//if the zip file already exists and overwrite is false, return false
if(file_exists($destination) && !$overwrite) { return false; }
//vars
$valid_files = array();
//if files were passed in...
if(is_array($files)) {
//cycle through each file
foreach($files as $file) {
//make sure the file exists
if(file_exists($file)) {
$valid_files[] = $file;
}
}
}
if(count($valid_files)) {
$zip = new ZipArchive();
if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
foreach($valid_files as $file) {
$zip->addFile($file,$file);
}
$zip->close();
return file_exists($destination);
}
else
{
return false;
}
}
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$mysqli = new mysqli('localhost', 'root', '', 'PasteGo');
if ($mysqli->connect_error) {
die('Errore di connessione (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
} else {
echo 'Connesso. ' . $mysqli->host_info . "<br>";
}
$today = getdate();
$timeI= $today['hours'].":".$today['minutes'].":".$today['seconds'];
$dateI= $today['year']."-".$today['mon']."-".$today['mday'];
$dataoraCan=$dateI." ".$timeI;
//echo $dataoraCan."<br>";
$inserimento=TRUE;
$tempoint=$today['hours'].$today['minutes'];
$tempoint2=intval($tempoint);
$query1= $mysqli->query("SELECT data from ElencoDate where data != '".$dateI."' AND CheckC IS NULL");
$query2= $mysqli->query("SELECT percorso,Codice,Ip,data,ora from file");
//CANCELLAZIONE GIORNALIERA
if($query1->num_rows==1){
$row4= $query1->fetch_assoc();
if($row4['data']!=$dateI){
while($row3 = $query2->fetch_assoc()){
$mysqli->query("INSERT into Filecancellati(percorso,datacaricamento,oracaricamento,codice,Ip,dataoracancellamento)
VALUES ('".$row3['percorso']."','".$row3['data']."','".$row3['ora']."','".$row3['Codice']."','".$row3["Ip"]."','".$dataoraCan."')");
}
$mysqli->query("DELETE FROM file WHERE Codice!= '".$_POST['Code']."'");
$mysqli->query("UPDATE ElencoDate set CheckC=1 where data!='".$dateI."' AND CheckC IS NULL");
$mysqli->query("INSERT INTO ElencoDate(data)
VALUES('".$dateI."')");
echo "DATI GIORNALIERI CANCELLATI <br>";
$inserimento=false;
}
}
//CONTROLLO ORARIO DOPO 10M
$risultato2 = $mysqli->query("SELECT file.oraF FROM file WHERE Codice =".$_POST['Code']." ");
if ($risultato2->num_rows == 1) {
while($row = $risultato2->fetch_assoc()) {
$tempoQ= $row["oraF"];
}
$tempoOstring= substr($tempoQ,0,2).substr($tempoQ, 3,2);
$tempoOint= intval($tempoOstring);
if($tempoint2 >$tempoOint){
$inserimento=false;
$query4= $mysqli->query("SELECT file.percorso, file.data, file.ora, file.Codice, file.Ip from file where Codice='".$_POST['Code']."'");
while($row5=$query4->fetch_assoc()){
echo "prova while <br>";
$mysqli->query("INSERT into Filecancellati(percorso,datacaricamento,oracaricamento,codice,Ip,dataoracancellamento)
VALUES ('".$row5['percorso']."','".$row5['data']."','".$row5['ora']."','".$row5['Codice']."','".$row5["Ip"]."','".$dataoraCan."')");
/* echo $row5['percorso'].$row5['data'].$row5['ora'].$row5['Codice']." IP; ".$row5['Ip'].$dataoraCan;
*/
unlink("DirUp/".$row5['percorso']);
}
$mysqli->query("DELETE FROM file WHERE Codice=".$_POST['Code']." ");
echo "CANCELLATO <br>";
$inserimento=false;
}
}
//PROCEDURA NORMALE
if($inserimento==TRUE && isset($_POST['Code'])){
unlink("MyFile.zip");
$DataOra2=$today['year']."-".$today['mon']."-".$today['mday']." ".$today['hours'].":".$today['minutes'].":".$today['seconds'];
$risultato2 = $mysqli->query("SELECT * FROM file WHERE Codice =".$_POST['Code']." ");
if($risultato2->num_rows==1){
while($row=$risultato2->fetch_assoc()){
$sql="INSERT INTO ElencoDown(CodFile,Ipdown,dateG,ora)
VALUES(".$_POST['Code'].",'".$ip."','".$row['data']."','".$row['ora']."');";
$urlout= "DirUp/".$row["percorso"];
//$urlout=$row["percorso"];
if($mysqli->query($sql)===TRUE) echo "OK <br>";
else echo "<br>Error " . $mysqli->error."<br>";
}
echo "APERTO";
$files_to_zip = array(
$urlout
);
//if true, good; if false, zip creation failed
$result = create_zip($files_to_zip,"MyFile.zip");
header('Location:'."MyFile.zip");
}else
{
echo "CODICE INSERITO NON PRESENTE NEL DATABSE, INSERIRE UN CODICE CORRETTO";
}
}else echo "SE HAI INSERTO IL FILE DOPO MEZZANOTTE RIPROVARE A EFFETTUARE IL DOWNLOAD, PREMERE F5<BR>";
?>
</body>
</html>