forked from dtouzeau/artica
/
storage.center.php
369 lines (295 loc) · 10.8 KB
/
storage.center.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
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.users.menus.inc');
include_once('ressources/class.artica.inc');
include_once('ressources/class.ini.inc');
include_once('ressources/class.os.system.inc');
$user=new usersMenus();
if(($user->AsSystemAdministrator==false) OR ($user->AsSambaAdministrator==false)) {
$tpl=new templates();
$text=$tpl->_ENGINE_parse_body('{ERROR_NO_PRIVS}');
$text=replace_accents(html_entity_decode($text));
echo "alert('$text');";
exit;
}
if($_POST["action"]=="upload"){upload_file();exit;}
if(isset($_GET["popup"])){popup();exit;}
if(isset($_GET["popup-add-software"])){popup_add_software();exit;}
if(isset($_GET["upload-iframe"])){upload_iframe();exit;}
if(isset($_GET["sflist"])){echo software_list();exit;}
if(isset($_GET["DelRemoteSoftware"])){echo software_delete();exit;}
if(isset($_GET["SavePackegInfos"])){echo software_edit();exit;}
if(isset($_GET["popup-edit-software"])){echo popup_edit_software();exit;}
js();
function software_edit(){
$strDescription = addslashes(nl2br($_GET["description"]));
$commandline = addslashes($_GET["commandline"]);
$ExecuteAfter = addslashes($_GET["ExecuteAfter"]);
$MinutesToWait=$_GET["MinutesToWait"];
$sql="UPDATE files_storage SET
description='$strDescription',
ExecuteAfter='$ExecuteAfter',
commandline='$commandline',
MinutesToWait='$MinutesToWait'
WHERE id_files={$_GET["SavePackegInfos"]}";
$q=new mysql();
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){
echo "$q->mysql_error";
}
}
function software_delete(){
$sql="DELETE FROM files_storage WHERE id_files={$_GET["DelRemoteSoftware"]}";
$q=new mysql();
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){
echo $q->mysql_error;
}
}
function js(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body('{APP_STORAGE_CENTER}');
$html="
function LoadMainLabel(){
LoadWinORG('650','$page?popup=yes','$title');
}
function AddRemoteSoftware(){
YahooWin2('500','$page?popup-add-software=yes');
}
function EditRemoteSoftware(id){
YahooWin2('500','$page?popup-edit-software='+id);
}
function RefreshSoftwaresList(){
LoadAjax('software_list','$page?sflist=yes');
}
var x_DelRemoteSoftware=function (obj) {
var results=obj.responseText;
if (results.length>0){alert(results);}
RefreshSoftwaresList();
}
function DelRemoteSoftware(id){
var XHR = new XHRConnection();
XHR.appendData('DelRemoteSoftware',id);
document.getElementById('software_list').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>';
XHR.sendAndLoad('$page', 'GET',x_DelRemoteSoftware);
}
var x_SavePackegInfos=function (obj) {
var results=obj.responseText;
if (results.length>0){alert(results);}
RefreshSoftwaresList();
YahooWin2Hide();
}
function SavePackegInfos(id){
var XHR = new XHRConnection();
XHR.appendData('SavePackegInfos',id);
XHR.appendData('description',document.getElementById('txtDescription').value);
XHR.appendData('commandline',document.getElementById('commandline').value);
XHR.appendData('ExecuteAfter',document.getElementById('ExecuteAfter').value);
XHR.appendData('MinutesToWait',document.getElementById('MinutesToWait').value);
document.getElementById('packageinfo').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>';
XHR.sendAndLoad('$page', 'GET',x_SavePackegInfos);
}
LoadMainLabel();
";
echo $html;
}
function popup(){
$list=software_list();
$add=Paragraphe("software-back-64-add.png","{ADD_NEW_SOFTWARE}","{ADD_NEW_SOFTWARE_TEXT}","javascript:AddRemoteSoftware()");
$refresh=Paragraphe("64-refresh.png","{refresh}","{resfresh_software_list}","javascript:RefreshSoftwaresList()");
$users=new usersMenus();
if(!$users->winexe_installed){
$warn=Paragraphe("64-infos.png","{APP_WINEXE_NOT_INSTALLED}",
"{APP_WINEXE_NOT_INSTALLED_TEXT}","javascript:Loadjs('setup.index.progress.php?product=APP_WINEXE&start-install=yes');")."<br>";
}
$html="<H1>{APP_STORAGE_CENTER}</H1>
<table style='width:100%'>
<tr>
<td valign='top' width=1%>$warn$refresh<br>$add</td>
<td valign='top'>
<p class=caption>{APP_STORAGE_CENTER_TEXT}</p>
". RoundedLightWhite("<div id='software_list' style='width:100%;height:450px;overflow:auto'>$list</div>")."
</td>
</tr>
</table>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function software_list(){
$q=new mysql();
$sql="SELECT description,filetype,filesize,filename,id_files,OCS_PACKAGE FROM files_storage ORDER BY filesize DESC";
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){$error=$q->mysql_error;}
$html="<span style='color:red'>$error</span>
<table style='width:99%'>
<tr>
<th width=1%> </th>
<th width=99%>{filename}</th>
<th width=1% nowrap>{filesize}</th>
<th width=1%> </th>
</tr>";
while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
$filesize=ParseBytes($ligne["filesize"]);
$filename=texttooltip($ligne["filename"],$ligne["description"],"EditRemoteSoftware({$ligne["id_files"]})",null,0);
$delete=imgtootltip("ed_delete.gif","{delete}","DelRemoteSoftware({$ligne["id_files"]})");
if($ligne["OCS_PACKAGE"]==1){$delete=" ";}
$html=$html . "
<tr " . CellRollOver().">
<td valign='top'><img src='img/fw_bold.gif'></td>
<td><strong>$filename</strong></td>
<td><strong>$filesize</strong></td>
<td width=1%>$delete</td>
</TR>";
}
$html=$html . "</table>";
$tpl=new templates();
return $tpl->_ENGINE_parse_body($html);
}
function popup_edit_software(){
$page=CurrentPageName();
$sql="SELECT description,filetype,filesize,filename,commandline,ExecuteAfter,MinutesToWait,OCS_PACKAGE FROM files_storage WHERE id_files={$_GET["popup-edit-software"]}";
$q=new mysql();
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));
$filesize=ParseBytes($ligne["filesize"]);
$ligne["description"]=html_entity_decode($ligne["description"]);
$ligne["description"]=br2nl($ligne["description"]);
$commandline=$ligne["commandline"];
$ExecuteAfter=$ligne["ExecuteAfter"];
$MinutesToWait=$ligne["MinutesToWait"];
for($i=2;$i<60;$i++){
$mins[$i*60]=$i;
}
$MinutesToWait=Field_array_Hash($mins,"MinutesToWait",$MinutesToWait);
$form="<TABLE style='width:98%' class=table_form>
<TR>
<TD class=legend valign='top'>{description}: </TD>
<TD><TEXTAREA NAME=\"txtDescription\" id=\"txtDescription\" ROWS=\"5\" COLS=\"30\">{$ligne["description"]}</TEXTAREA></TD>
</TR>
<TR>
<TD class=legend nowrap>{commandline}: </TD>
<TD>". Field_text("commandline",$commandline)."</TD>
</TR>
<TR>
<TD class=legend nowrap>{ExecuteAfter}: </TD>
<TD>". Field_text("ExecuteAfter",$ExecuteAfter)."</TD>
</TR>
<TR>
<TD class=legend nowrap>{MinutesToWait}: </TD>
<TD>$MinutesToWait</TD>
</TR>
<tr>
<td valing='top' align='right' colspan=2><input type='button' OnClick=\"javascript:SavePackegInfos({$_GET["popup-edit-software"]});\" value=\"{edit} »\">
</tr>
</table>";
if($ligne["OCS_PACKAGE"]==1){
$form=
"<table style='width:100%'>
<tr>
<td width=1% valign='top'><img src='img/64-ocs.png'></td>
<td valign='top'>".
RoundedLightWhite("<p><code style='font-size:13px;font-weight:bold'>{$ligne["description"]}</code></p>
<br><code style='font-size:13px;font-weight:bold'>{commandline}: $commandline</code>
<br><code style='font-size:10px;font-weight:bold'>{ExecuteAfter}: $ExecuteAfter</code>
<br><code style='font-size:13px;font-weight:bold'>{MinutesToWait}:{$ligne["MinutesToWait"]}mn</code>
")."</td>
</tr>
</table>";
}
$html="<H1>{$ligne["filename"]}</H1>
<p class=caption style='font-size:14px'>$filesize ({$ligne["filetype"]})</p>
<div id='packageinfo'>
$form
</div>
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function popup_add_software(){
//iframe()
$page=CurrentPageName();
$html="<H1>{ADD_NEW_SOFTWARE}</H1>
<p class=caption>{ADD_NEW_SOFTWARE_TEXT}</p>
<iframe src='$page?upload-iframe=yes' style='width:100%;height:300px;border:0px'></iframe>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function upload_iframe(){
$page=CurrentPageName();
for($i=2;$i<60;$i++){
$mins[$i*60]=$i;
}
$MinutesToWait=Field_array_Hash($mins,"MinutesToWait");
$html="
<FORM METHOD=\"post\" ACTION=\"$page\" ENCTYPE=\"multipart/form-data\">
<INPUT TYPE=\"hidden\" NAME=\"MAX_FILE_SIZE\" VALUE=\"100000000\">
<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"upload\">
<TABLE style='width:98%' class=table_form>
<TR>
<TD class=legend valign='top'>{description}: </TD>
<TD><TEXTAREA NAME=\"txtDescription\" ROWS=\"5\" COLS=\"30\"></TEXTAREA></TD>
</TR>
<TR>
<TD class=legend>{file}: </TD>
<TD><INPUT TYPE=\"file\" NAME=\"binFile\"></TD>
</TR>
<TR>
<TD class=legend nowrap>{commandline}: </TD>
<TD>". Field_text("commandline")."</TD>
</TR>
<TR>
<TD class=legend nowrap>{ExecuteAfter}: </TD>
<TD>". Field_text("ExecuteAfter")."</TD>
</TR>
<TR>
<TD class=legend nowrap>{MinutesToWait}: </TD>
<TD>$MinutesToWait</TD>
</TR>
<TR>
<TD COLSPAN=\"2\" align='right'><INPUT TYPE=\"submit\" VALUE=\"{upload} »\"></TD>
</TR>
</TABLE>
</FORM>
";
$html=iframe($html,0);
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function upload_file(){
$tpl=new templates();
if(!is_array($_FILES["binFile"])){
upload_iframe();
exit;
}
$filename=$_FILES["binFile"]["name"];
$size=$_FILES["binFile"]["size"];
$filepath=$_FILES["binFile"]["tmp_name"];
$txtDescription=$_POST["txtDescription"];
$type=$_FILES["binFile"]["type"];
$error=$_FILES["binFile"]["error"];
$ExecuteAfter=addslashes($_POST["ExecuteAfter"]);
$commandline=addslashes($_POST["commandline"]);
$MinutesToWait=addslashes($_POST["MinutesToWait"]);
$filename=str_replace(" ","-",$filename);
//$filename=filesize()
if($error==0){
$q=new mysql();
$data = addslashes(fread(fopen($filepath, "r"), filesize($filepath)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO files_storage ";
$sql .= "(description, bin_data, filename, filesize, filetype,commandline,ExecuteAfter,MinutesToWait) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$filename', '$size', '$type','$commandline','$ExecuteAfter','$MinutesToWait')";
$q->QUERY_SQL($sql,"artica_backup");
if($q->ok){
echo $tpl->_ENGINE_parse_body("<strong style='font-size:16px;color:red'>{success} $filename</strong>");
exit;
}
echo $tpl->_ENGINE_parse_body("<strong style='font-size:16px;color:red'>$q->mysql_error</strong>");
}else{
echo $tpl->_ENGINE_parse_body("<strong style='font-size:16px;color:red'>Error number $error</strong>");
exit;
}
}
?>