This repository was archived by the owner on Dec 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathedit-file.php
More file actions
1112 lines (978 loc) · 52.1 KB
/
Copy pathedit-file.php
File metadata and controls
1112 lines (978 loc) · 52.1 KB
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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Edit a file name or description.
* Files can only be edited by the uploader and level 9 or 8 users.
*
* @package ProjectSend
*/
$load_scripts = array(
'datepicker',
'chosen',
);
$allowed_levels = array(9,8,7,0);
require_once('sys.includes.php');
//Add a session check here
if(!check_for_session()) {
header("location:" . BASE_URI . "index.php");
}
$active_nav = 'files';
$page_title = __('Edit File','cftp_admin');
include('header.php');
define('CAN_INCLUDE_FILES', true);
/**
* The file's id is passed on the URI.
*/
if (!empty($_GET['file_id'])) {
$this_file_id = $_GET['file_id'];
}
$get_prev_id = isset($_GET['page_id']) ? $_GET['page_id'] : '';
//1 for send.php
//2 for
switch($get_prev_id) {
case 1:
$get_prev_url = BASE_URI.'sent.php';
break;
case 2:
$get_prev_url = BASE_URI.'inbox.php';
break;
case 3:
$get_prev_url = BASE_URI.'outbox.php';
break;
case 4:
$get_prev_url = BASE_URI.'draft.php';
break;
case 5:
$get_prev_url = BASE_URI.'expired.php';
break;
case 6:
$get_prev_url = BASE_URI.'public-files.php';
break;
case 7:
if($_GET['client_id']){ $get_prev_url = BASE_URI."manage-files.php?client_id=".$_GET['client_id'];}
else if($_GET['group_id']){ $get_prev_url = BASE_URI."manage-files.php?group_id=".$_GET['group_id'];}
else if($_GET['category']){ $get_prev_url = BASE_URI."manage-files.php?category=".$_GET['category'];}
else { $get_prev_url = BASE_URI.'manage-files.php'; }
break;
case 8:
$get_prev_url = BASE_URI.'upload-process-form.php';
break;
case 9:
$get_prev_url = BASE_URI.'upload-process-form-dropoff.php';
break;
default:
$get_prev_id = '#';
}
// var_dump($get_prev_url);
/** Fill the users array that will be used on the notifications process */
$users = array();
$statement = $dbh->prepare("SELECT id, name, email, level FROM " . TABLE_USERS . " WHERE ACTIVE = 1 ORDER BY name ASC");
$statement->execute();
$statement->setFetchMode(PDO::FETCH_ASSOC);
while( $row = $statement->fetch() ) {
$users[$row["id"]] = $row["name"];
//if ($row["level"] == '0') {
//$clients[$row["id"]] = $row["name"];
//}
$clients[$row["id"]] = $row["name"]." : ".$row["email"];
$cliEmail[$row["id"]] =$row["email"];
}
/** Fill the groups array that will be used on the form */
$groups = array();
$statement = $dbh->prepare("SELECT id, name FROM " . TABLE_GROUPS . " ORDER BY name ASC");
$statement->execute();
$statement->setFetchMode(PDO::FETCH_ASSOC);
while( $row = $statement->fetch() ) {
$groups[$row["id"]] = $row["name"];
}
/** Fill the categories array that will be used on the form */
$categories = array();
$get_categories = get_categories();
/**
* Get the user level to determine if the uploader is a
* system user or a client.
*/
$current_level = get_current_user_level();
?>
<style>
.disnone{
display: none;
}
</style>
<div id="main">
<div id="content">
<!-- Added by B) -------------------->
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h1 class="page-title txt-color-blueDark"><i class="fa-fw fa fa-home"></i><?php echo $page_title; ?></h1>
<?php
function randomPassword() {
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$pass = array(); //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
return implode($pass); //turn the array into a string
}
/**
* Show an error message if no ID value is passed on the URI.
*/
if(empty($this_file_id)) {
$no_results_error = 'no_id_passed';
}
else {
$sql = $dbh->prepare("SELECT * FROM " . TABLE_FILES . " WHERE id = :id");
$sql->bindParam(':id', $this_file_id, PDO::PARAM_INT);
$sql->execute();
/**
* Count the files assigned to this client. If there is none, show
* an error message.
*/
$count = $sql->rowCount();
if ( $count == 0 ) {
$no_results_error = 'id_not_exists';
}
/**
* Continue if client exists and has files under his account.
*/
$sql->setFetchMode(PDO::FETCH_ASSOC);
while( $row = $sql->fetch() ) {
$edit_file_info['url'] = $row['url'];
$edit_file_info['id'] = $row['id'];
$edit_file_info['expiry_date'] = $row['expiry_date'];
$edit_file_allowed = array(7,0);
if (in_session_or_cookies($edit_file_allowed)) {
if ($row['uploader'] != $global_user) {
$no_results_error = 'not_uploader';
}
}
}
}
/** Show the error if it is defined */
if (isset($no_results_error)) {
switch ($no_results_error) {
case 'no_id_passed':
$no_results_message = __('Please go to the clients or groups administration page, select "Manage files" from any client and then click on "Edit" on any file to return here.','cftp_admin');;
break;
case 'id_not_exists':
$no_results_message = __('There is not file with that ID number.','cftp_admin');;
break;
case 'not_uploader':
$no_results_message = __("You don't have permission to edit this file.",'cftp_admin');;
break;
}
?>
<style media="screen">
.whitebox_text {
background-color: #c26565;
color: #fff;
border-radius: 8px;
}
</style>
<div class="whiteform whitebox whitebox_text"> <?php echo $no_results_message; ?> </div>
<?php
}
else {
/**
* See what clients or groups already have this file assigned.
*/
$file_on_clients = array();
$file_on_groups = array();
if ( isset($_POST['submit'] ) ) {
$assignments = $dbh->prepare("SELECT file_id, client_id, group_id FROM " . TABLE_FILES_RELATIONS . " WHERE file_id = :id");
$assignments->bindParam(':id', $this_file_id, PDO::PARAM_INT);
$assignments->execute();
//echo $assignments->rowCount();
if ($assignments->rowCount() > 0) {
while ( $assignment_row = $assignments->fetch() ) {
if (!empty($assignment_row['client_id'])) {
$file_on_clients[] = $assignment_row['client_id'];
}
elseif (!empty($assignment_row['group_id'])) {
$file_on_groups[] = $assignment_row['group_id'];
}
}
}
$n = 0;
foreach ($_POST['file'] as $file) {
$n++;
if(!empty($file['name'])) {
/**
* If the uploader is a client, set the "client" var to the current
* uploader username, since the "client" field is not posted.
*/
$this_upload = new PSend_Upload_File();
/**
* Unassigned files are kept as orphans and can be related
* to clients or groups later.
*/
/** Add to the database for each client / group selected */
$add_arguments = array(
'file' => $edit_file_info['url'],
'name' => $file['name'],
'description' => $file['description'],
'uploader' => $global_user,
'uploader_id' => $global_id,
'expiry_date' => $file['expiry_date']
);
/** Set notifications to YES by default */
$send_notifications = true;
if (!empty($file['notify'])) {
$add_arguments['notify'] = true;
}else{
$add_arguments['notify'] = false;
}
if (!empty($file['number_downloads'])) {
$add_arguments['number_downloads'] = $file['number_downloads'];
}else{
$add_arguments['number_downloads'] = 0;
}
if (!empty($file['future_send_date'])) {
$add_arguments['future_send_date'] = $file['future_send_date'];
}
//1 == 1 for all all users added by B)
if ($current_level != 0 || 1 == 1) {
if (!empty($file['expires'])) {
$add_arguments['expires'] = '1';
}
if (!empty($file['public'])) {
$add_arguments['public'] = '1';
}
//echo "----------------------".$file['assignments']."--------------------------------------";
if (!empty($file['assignments']) || !empty($_POST['new_client']) ) {
/**
* Remove already assigned clients/groups from the list.
* Only adds assignments to the NEWLY selected ones.
*/
//------------------------------------------------------------
$nuser_list = $_POST['new_client'];
if(!empty($file['assignments'])){
$full_list = $file['assignments'];
}else{
$full_list = array();
}
if(!empty($nuser_list)) {
//echo "<pre>";print_r('1111111111');echo "</pre>";exit;
foreach($nuser_list as $nuser) {
$euser_query = $dbh->prepare("SELECT id FROM `".TABLE_USERS."` WHERE `email` = '".$nuser."'");
//echo "SELECT id FROM `".TABLE_USERS."` WHERE `email` = '".$nuser."'";exit();
$euser_query->execute();
$euser = $euser_query->fetch();
$nuser_id = $euser['id'];
if( $euser_query->rowCount() == 0 ) {
//echo "Here";exit();
$npw = randomPassword();
$cc_enpass = $hasher->HashPassword($npw);
$nuser_query = $dbh->prepare("INSERT INTO `".TABLE_USERS."` (`user`, `password`, `name`, `email`, `level`, `timestamp`, `address`, `phone`, `notify`, `contact`, `created_by`, `active`) VALUES ('".$nuser."', '".$cc_enpass."', '', '".$nuser."', '0', CURRENT_TIMESTAMP, NULL, NULL, '0', NULL, NULL, '1')");
$nuser_query->execute();
$nuser_id = $dbh->lastInsertId();
// --------------------------------- email notification start here!
$to_email_request = $nuser; // note the comma
// Message
$message = '
<html>
<head>
<title>Invitation to Download</title>
</head>
<body>
<p>Please find the login details</p>
<table>
<tr>
<td>User Name : </td><td>'.$nuser.'</td>
</tr>
<tr>
<td>Password</td><td>'.$npw.'</td>
</tr>
<tr>
<td>Site :</td><td>'.'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'].'</td>
</tr>
</table>
</body>
</html>
';
//--------------------------------------------------------------------------------------------
/**
* phpMailer
*/
require_once(ROOT_DIR.'/includes/phpmailer/class.phpmailer.php');
if (!spl_autoload_functions() OR (!in_array('PHPMailerAutoload', spl_autoload_functions()))) {
require_once(ROOT_DIR.'/includes/phpmailer/PHPMailerAutoload.php');
}
$send_mail = new PHPMailer();
switch (MAIL_SYSTEM) {
case 'smtp':
$send_mail->IsSMTP();
$send_mail->SMTPAuth = true;
$send_mail->Host = SMTP_HOST;
$send_mail->Port = SMTP_PORT;
$send_mail->Username = SMTP_USER;
$send_mail->Password = SMTP_PASS;
if ( defined('SMTP_AUTH') && SMTP_AUTH != 'none' ) {
$send_mail->SMTPSecure = SMTP_AUTH;
}
break;
case 'gmail':
$send_mail->IsSMTP();
$send_mail->SMTPAuth = true;
$send_mail->SMTPSecure = "tls";
$send_mail->Host = 'smtp.gmail.com';
$send_mail->Port = 587;
$send_mail->Username = SMTP_USER;
$send_mail->Password = SMTP_PASS;
break;
case 'sendmail':
$send_mail->IsSendmail();
break;
}
$send_mail->CharSet = EMAIL_ENCODING;
//
$send_mail->Subject = "Invitation to Download";
//
$send_mail->MsgHTML($message);
$send_mail->AltBody = __('This email contains HTML formatting and cannot be displayed right now. Please use an HTML compatible reader.','cftp_admin');
$send_mail->SetFrom(ADMIN_EMAIL_ADDRESS, MAIL_FROM_NAME);
$send_mail->AddReplyTo(ADMIN_EMAIL_ADDRESS, MAIL_FROM_NAME);
//
$send_mail->AddAddress($to_email_request);
/**
* Check if BCC is enabled and get the list of
* addresses to add, based on the email type.
*/
if (COPY_MAIL_ON_CLIENT_UPLOADS == '1') {
$try_bcc = true;
}
if ($try_bcc === true) {
$add_bcc_to = array();
if (COPY_MAIL_MAIN_USER == '1') {
$add_bcc_to[] = ADMIN_EMAIL_ADDRESS;
}
$more_addresses = COPY_MAIL_ADDRESSES;
if (!empty($more_addresses)) {
$more_addresses = explode(',',$more_addresses);
foreach ($more_addresses as $add_bcc) {
$add_bcc_to[] = $add_bcc;
}
}
/**
* Add the BCCs with the compiled array.
* First, clean the array to make sure the admin
* address is not written twice.
*/
if (!empty($add_bcc_to)) {
$add_bcc_to = array_unique($add_bcc_to);
foreach ($add_bcc_to as $set_bcc) {
$send_mail->AddBCC($set_bcc);
}
}
}
/**
* Finally, send the e-mail.
*/
if($send_mail->Send()) {
$cc_status = "<div class=\"alert alert-success cc-success\"><strong>Success!</strong>Your Request has been submitted successfully.</div>";
}
else {
$cc_status = "<div class=\"alert alert-danger cc-failed\"><strong>Oops! </strong>Something went wrong! please try after sometime.</div>";
}
echo "<script>$(document).ready(function(){ $('#cc-mail-status').modal('toggle');});</script>";
//--------------------------------------------------------------------------------------------
// email notification End here! B)
}
array_push($full_list,'c'.$nuser_id);
}
}
$full_assi_user = $full_list;
$add_arguments['assign_to'] = $full_assi_user;
$assignations_count = count($full_assi_user);
$newassigns=0;
foreach ($file_on_clients as $this_client) { $compare_clients[] = 'c'.$this_client; }
foreach ($file_on_groups as $this_group) { $compare_groups[] = 'g'.$this_group; }
if (!empty($compare_clients)) {
$full_list = array_diff($full_list,$compare_clients);
$newassigns=1;
}
if (!empty($compare_groups)) {
$full_list = array_diff($full_list,$compare_groups);
$newassigns=1;
}
$add_arguments['assign_to'] = $full_list;
$today = date("d-m-Y");
if($file['expires'] && ($file['expiry_date'] == $today) ){
$add_arguments['assign_to']= $full_assi_user;
}
/**
* On cleaning the DB, only remove the clients/groups
* That just have been deselected.
*/
$clean_who = $full_assi_user;
}
else {
$clean_who = 'All';
$assignations_count='0';
}
/** CLEAN deletes the removed users/groups from the assignments table */
if ($clean_who == 'All') {
$clean_all_arguments = array(
'owner_id' => $global_id, /** For the log */
'file_id' => $this_file_id,
'file_name' => $file['name']
);
$clean_assignments = $this_upload->clean_all_assignments($clean_all_arguments);
}
else {
$clean_arguments = array (
'owner_id' => $global_id, /** For the log */
'file_id' => $this_file_id,
'file_name' => $file['name'],
'assign_to' => $clean_who,
'current_clients' => $file_on_clients,
'current_groups' => $file_on_groups
);
$clean_assignments = $this_upload->clean_assignments($clean_arguments);
}
$categories_arguments = array(
'file_id' => $this_file_id,
'categories' => !empty( $file['categories'] ) ? $file['categories'] : '',
);
$this_upload->upload_save_categories( $categories_arguments );
}
if ($assignations_count == '0'){
$add_arguments['prev_assign'] ='2';
}
$add_arguments['uploader_type'] = 'user';
/**
* 1- Add the file to the database
*/
$process_file = $this_upload->upload_add_to_database($add_arguments);
if($process_file['database'] == true) {
$add_arguments['new_file_id'] = $process_file['new_file_id'];
$add_arguments['all_users'] = $users;
$add_arguments['all_groups'] = $groups;
$add_arguments['from_id'] = $global_id;
if ($current_level != 0 || 1 == 1) {
/**
* 2- Add the assignments to the database
*/
$process_assignment = $this_upload->upload_add_assignment($add_arguments);
// var_dump('55555555555555555555');
// echo "<pre>";print_r($add_arguments);echo "</pre>";exit;
/**
* 3- Hide for everyone if checked
*/
if (!empty($file['hideall'])) {
$this_file = new FilesActions();
$hide_file = $this_file->manage_hide($this_file_id);
}
/**
* 4- Add the notifications to the database
*/
$today = date("d-m-Y");
if (($send_notifications == true && $file['future_send_date'] == $today)
||($send_notifications == true && $file['expiry_date'] == $today && $file['expires'] == '1' && $get_prev_id != 3))
{
$process_notifications = $this_upload->upload_add_notifications($add_arguments);
}
}
$new_log_action = new LogActions();
if ($current_level == 0 ){
$action_log_number = 33;
}else{
$action_log_number = 32;
}
$log_action_args = array(
'action' => $action_log_number,
'owner_id' => $global_id,
'owner_user' => $global_user,
'affected_file' => $process_file['new_file_id'],
'affected_file_name' => $file['name']
);
$new_record_action = $new_log_action->log_action_save($log_action_args);
$msg = __('The file has been edited successfully.','cftp_admin');
echo system_message('ok',$msg);
include(ROOT_DIR.'/upload-send-notifications.php');
}
}
}
}
/** Validations OK, show the editor */
?>
<form action="edit-file.php?file_id=<?php echo filter_var($this_file_id,FILTER_VALIDATE_INT); ?>&page_id=<?php echo $get_prev_id; ?>" method="post" name="edit_file" id="edit_file">
<div class="container-fluid">
<?php
/** Reconstruct the current assignments arrays */
$file_on_clients = array();
$file_on_groups = array();
$assignments = $dbh->prepare("SELECT file_id, client_id, group_id FROM " . TABLE_FILES_RELATIONS . " WHERE file_id = :id");
$assignments->bindParam(':id', $this_file_id, PDO::PARAM_INT);
$assignments->execute();
if ($assignments->rowCount() > 0) {
while ( $assignment_row = $assignments->fetch() ) {
if (!empty($assignment_row['client_id'])) {
$file_on_clients[] = $assignment_row['client_id'];
}
elseif (!empty($assignment_row['group_id'])) {
$file_on_groups[] = $assignment_row['group_id'];
}
}
}
/** Get the current assigned categories */
$current_categories = array();
$current_statemente = $dbh->prepare("SELECT cat_id FROM " . TABLE_CATEGORIES_RELATIONS . " WHERE file_id = :id");
$current_statemente->bindParam(':id', $this_file_id, PDO::PARAM_INT);
$current_statemente->execute();
if ($current_statemente->rowCount() > 0) {
while ( $assignment_row = $current_statemente->fetch() ) {
$current_categories[] = $assignment_row['cat_id'];
}
}
$i = 1;
$statement = $dbh->prepare("SELECT * FROM " . TABLE_FILES . " WHERE id = :id");
$statement->bindParam(':id', $this_file_id, PDO::PARAM_INT);
$statement->execute();
while( $row = $statement->fetch() ) {
?>
<div class="file_editor <?php if ($i%2) { echo 'f_e_odd'; } ?>">
<div class="row">
<div class="col-sm-12">
<div class="file_number">
<p><span class="glyphicon glyphicon-saved" aria-hidden="true"></span><?php echo html_output($row['url']); ?></p>
</div>
</div>
</div>
<div class="row edit_files filevalues">
<div class="col-sm-12">
<div class="row edit_files_blocks">
<div class="col-sm-6 col-xl-3 column_even column">
<div class="file_data">
<div class="row">
<div class="col-sm-12">
<h3>
<?php _e('File information', 'cftp_admin');?>
</h3>
<div class="form-group">
<label>
<?php _e('Title', 'cftp_admin');?>
</label>
<input type="text" name="file[<?php echo $i; ?>][name]" value="<?php echo html_output($row['filename']); ?>" class="form-control file_title" placeholder="<?php _e('Enter here the required file title.', 'cftp_admin');?>" />
</div>
<div class="form-group">
<label>
<?php _e('Description', 'cftp_admin');?>
</label>
<textarea name="file[<?php echo $i; ?>][description]" class="form-control" placeholder="<?php _e('Optionally, enter here a description for the file.', 'cftp_admin');?>"><?php echo (!empty($row['description'])) ? html_output($row['description']) : ''; ?></textarea>
</div>
</div>
</div>
</div>
</div>
<?php
/** The following options are available to users only */
// 1 == 1 for all users
if ($global_level != 0 || 1 == 1) {
?>
<div class="col-sm-6 col-xl-3 column_even column">
<div class="file_data">
<?php
/**
* Only show the EXPIRY options if the current
* uploader is a system user, and not a client.
*/
if (!empty($row['future_send_date'])) {
$future_send_date = date('d-m-Y', strtotime($row['future_send_date']));
}
?>
<h3>
<?php _e('Expiration date', 'cftp_admin');?>
</h3>
<div class="form-group">
<label for="file[<?php echo $i; ?>][expires_date]">
<?php _e('Select a date', 'cftp_admin');?>
</label>
<div class="input-group date-container">
<?php
$date = date('d-m-Y');
if ($get_prev_id == 5) {
$expiry_date = date('d-m-Y', strtotime($date. ' + 14 days'));
} elseif (($get_prev_id == 6) || ($get_prev_id == 2) || ($row['expires']==1)) {
$expiry_date = date('d-m-Y', strtotime($edit_file_info['expiry_date'])) ;
} else {
$expiry_date = date('d-m-Y', strtotime($date. ' + 14 days'));
}
?>
<input type="text" class="date-field form-control datapick-field exPdate" readonly id="file[<?php echo $i; ?>][expiry_date]" name="file[<?php echo $i; ?>][expiry_date]" value="<?php echo (!empty($expiry_date)) ? $expiry_date : date('d-m-Y'); ?>" />
<div class="input-group-addon"> <i class="glyphicon glyphicon-time"></i> </div>
</div>
</div>
<div class="checkbox">
<label for="exp_checkbox">
<input type="checkbox" class="expires" id="exp_checkbox" name="file[<?php echo $i; ?>][expires]" value="1" <?php if ($row['expires']) { ?>checked="checked"<?php } ?> />
<?php _e('File expires', 'cftp_admin');?>
</label>
</div>
<div class="checkbox">
<label for="notify_checkbox">
<input type="checkbox" id="notify_checkbox" name="file[<?php echo $i; ?>][notify]" value="1" <?php if ($row['notify']) { ?>checked="checked"<?php } ?> />
<?php _e('Don\'t Notify Me', 'cftp_admin');?>
</label>
</div>
<div class="divider"></div>
<?php if($current_level != 0){ ?>
<h3>
<?php _e('Public downloading', 'cftp_admin');?>
</h3>
<div class="checkbox">
<label for="pub_checkbox">
<input type="checkbox" id="pub_checkbox" name="file[<?php echo $i; ?>][public]" value="1" <?php if ($row['public_allow']) { ?>checked="checked"<?php } ?> />
<?php _e('Allow public downloading of this file.', 'cftp_admin');?>
</label>
</div>
<?php } ?>
<div class="form-group">
<label>
<?php _e('Number of Downloads Allowed', 'cftp_admin');?>
</label>
<?php
if($row['number_downloads']>0)
{
$number_downloads = $row['number_downloads'];
}
else
{
$number_downloads = 0;
/* if(DOWNLOAD_MAX_TRIES>0)
{
$number_downloads = DOWNLOAD_MAX_TRIES;
}
else
{
$number_downloads = '';
}
*/
}
?>
<input type="text" name="file[<?php echo $i; ?>][number_downloads]" value="<?php echo html_output($number_downloads); ?>" size="1" class="form-control1 file_title" placeholder="<?php _e('Enter number of downloads.', 'cftp_admin');?>" />
</div>
</div>
</div>
<div class="col-sm-6 col-xl-3 assigns column">
<div class="file_data">
<?php
/**
* Only show the CLIENTS select field if the current
* uploader is a system user, and not a client.
*/
?>
<h3>
<?php
if($row['public_allow']){
?>
<script>
$(document).ready(function() {
$('.chosen-select_pub').prop('disabled', true).val('').trigger('chosen:updated').chosen();
});
</script>
<?php
}
?>
</script>
<?php _e('Send To', 'cftp_admin');?>
</h3>
<select multiple="multiple" name="new_client[]" class="form-control new_client" data-placeholder="<?php _e('Select one or more options. Type to search.', 'cftp_admin');?>" style="display:none">
</select>
<label>
<?php _e('Assign this file to', 'cftp_admin');?>
:</label>
<select multiple="multiple" name="file[<?php echo $i; ?>][assignments][]" class="form-control chosen-select chosen-select_pub" data-placeholder="<?php _e('Select one or more options. Type to search.', 'cftp_admin');?>">
<optgroup label="<?php _e('Clients', 'cftp_admin');?>">
<?php
/**
* The clients list is generated early on the file so the
* array doesn't need to be made once on every file.
*/
foreach($clients as $client => $client_name) {
?>
<option value="<?php echo 'c'.$client; ?>"<?php if (in_array($client,$file_on_clients)) { echo ' selected="selected"'; } ?>> <?php echo $client_name; ?> </option>
<?php
}
?>
</optgroup>
<optgroup label="<?php _e('Groups', 'cftp_admin');?>">
<?php
/**
* The groups list is generated early on the file so the
* array doesn't need to be made once on every file.
*/
foreach($groups as $group => $group_name) {
?>
<option value="<?php echo 'g'.$group; ?>"<?php if (in_array($group,$file_on_groups)) { echo ' selected="selected"'; } ?>> <?php echo $group_name; ?> </option>
<?php
}
?>
</optgroup>
</select>
<div class="list_mass_members"> <a href="#" class="btn btn-xs btn-primary add-all disnone" data-type="assigns">
<?php _e('Add all','cftp_admin'); ?>
</a> <a href="#" class="btn btn-xs btn-primary remove-all" data-type="assigns">
<?php _e('Remove all','cftp_admin'); ?>
</a> </div>
<div class="divider"></div>
<?php if ($current_level != 0) { ?>
<div class="checkbox">
<label for="hid_checkbox">
<input type="checkbox" id="hid_checkbox" name="file[<?php echo $i; ?>][hidden]" value="1" />
<?php _e('Upload hidden (will not send notifications)', 'cftp_admin');?>
</label>
</div>
<?php } ?>
<?php if ($current_level != 0) { if ($get_prev_id != 4) { ?>
<div class="checkbox">
<label for="hid_existing_checkbox">
<input type="checkbox" id="hid_existing_checkbox" name="file[<?php echo $i; ?>][hideall]" value="1" />
<?php _e('Hide from every already assigned clients and groups.', 'cftp_admin');?>
</label>
</div>
<?php } } ?>
</div>
</div>
<div class="col-sm-6 col-xl-3 categories column">
<div class="file_data">
<h3>
<?php _e('Categories', 'cftp_admin');?>
</h3>
<label>
<?php _e('Add to', 'cftp_admin');?>
:</label>
<select multiple="multiple" name="file[<?php echo $i; ?>][categories][]" class="form-control chosen-select" data-placeholder="<?php _e('Select one or more options. Type to search.', 'cftp_admin');?>">
<?php
/**
* The categories list is generated early on the file so the
* array doesn't need to be made once on every file.
*/
echo generate_categories_options( $get_categories['arranged'], 0, $current_categories );
?>
</select>
<div class="list_mass_members"> <a href="#" class="btn btn-xs btn-primary add-all disnone" data-type="categories">
<?php _e('Add all','cftp_admin'); ?>
</a> <a href="#" class="btn btn-xs btn-primary remove-all" data-type="categories">
<?php _e('Remove all','cftp_admin'); ?>
</a> </div>
</div>
<h3>
<?php _e('Future Send Date', 'cftp_admin');?>
</h3>
<div class="form-group">
<label for="file[<?php echo $i; ?>][future_send_date]">
<?php _e('Select a date', 'cftp_admin');?>
</label>
<div class="input-group date-container">
<input type="text" class="futuredate date-field form-control datapick-field" readonly id="file[<?php echo $i; ?>][future_send_date]" name="file[<?php echo $i; ?>][future_send_date]" value="<?php if(($get_prev_id ==3)||($get_prev_id ==8)||($get_prev_id ==9)) {echo($future_send_date);} else { echo(date('d-m-Y'));} ?>" />
<!-- <input type="text" class="date-field form-control datapick-field" readonly id="file[<?php echo $i; ?>][future_send_date]" name="file[<?php echo $i; ?>][future_send_date]" value="<?php echo (!empty($future_send_date)) ? $future_send_date : date('d-m-Y'); ?>" /> -->
<div class="input-group-addon"> <i class="glyphicon glyphicon-time"></i> </div>
</div>
</div>
</div>
<?php
} /** Close $current_level check */
?>
</div>
</div>
</div>
</div>
<?php
}
?>
<div class="after_form_buttons">
<a class="btn btn-default btn-wide" href="<?php if(($get_prev_id==8)||($get_prev_id==9)){echo BASE_URI.'inbox.php';}else{echo $get_prev_url;} ?>" ><?php if(($get_prev_id==8)||($get_prev_id==9)){echo 'Cancel';}else{?>Back <?php }?></a>
<button type="button" name="submit" class="btn btn-wide btn-primary" onclick="submitform()">
<?php _e('Save','cftp_admin'); ?>
</button>
<button type="submit" name="submit" class="btn btn-wide btn-primary" id="submitformid" style="display: none;"></button>
</div>
</div>
</form>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
<div id="myModal1" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Error!</h4>
</div>
<div class="modal-body">
<p>Expiry date should be greater than the future send date.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="myModal2" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Error!</h4>
</div>
<div class="modal-body">
<p>Expiry date shouldn't be less than the future send date.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Error!</h4>
</div>
<div class="modal-body">
<p>Expiry date should be greater than the Future send date.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function window_back() {
//window.history.back(-1);
}
$(document).ready(function() {
$('.chosen-select').chosen({
no_results_text : "<?php _e('Invite User :','cftp_admin'); ?>",
width : "98%",
search_contains : true,
});
// Start by B)
$(".no-results").click(function(e) {
console.log($('span',this).text());
});
$(document).on('click', ".no-results", function() {
var cc_email = $('span',this).text();
$(".new_client").append('<option val="'+cc_email+'" selected="selected">'+cc_email+'</option>');
$(this).parent().parent().siblings('.chosen-choices').prepend('<li class="search-choice"><span>'+cc_email+'</span><a style="text-decoration:none" class="cc-choice-close"> x</a></li>');
});
$(document).on('click', ".cc-choice-close", function() {
var cc_remove_op = $(this).siblings('span').text();
jQuery(".new_client option:contains('"+cc_remove_op+"')").remove();
$(this).parent().remove();
});
// End by B)
$('.date-container .date-field').datepicker({
format : 'dd-mm-yyyy',