-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink_upload.php
More file actions
executable file
·77 lines (64 loc) · 3 KB
/
Copy pathlink_upload.php
File metadata and controls
executable file
·77 lines (64 loc) · 3 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
<?php
$UPLOAD_ID = ''; // Initialize upload id
include("./include/common.php");
if(!isset($_POST['upload_file']) || empty($_POST['upload_file'])){ kak("<span class='error'>Invalid parameters passed</span>", 1, __LINE__); }
// Generate upload id
$UPLOAD_ID = generateUploadID();
// Format link file path
$PATH_TO_LINK_FILE = $TEMP_DIR . $UPLOAD_ID . ".link";
//Pass ini settings via the link file
$_CONFIG['temp_dir'] = $TEMP_DIR;
$_CONFIG['upload_id'] = $UPLOAD_ID;
$_CONFIG['path_to_link_file'] = $PATH_TO_LINK_FILE;
$_CONFIG['redirect_after_upload'] = $_INI['redirect_after_upload'];
$_CONFIG['embedded_upload_results'] = $_INI['embedded_upload_results'];
$_CONFIG['cgi_upload_hook'] = $_INI['cgi_upload_hook'];
$_CONFIG['debug_upload'] = $_INI['debug_upload'];
$_CONFIG['delete_link_file'] = $_INI['delete_link_file'];
$_CONFIG['purge_temp_dirs'] = $_INI['purge_temp_dirs'];
$_CONFIG['purge_temp_dirs_limit'] = $_INI['purge_temp_dirs_limit'];
///////////////////////////////////////////////////////////////////////////////////////////////
// ATTENTION
//
// You can pass data via the link file by creating or over-riding config values. eg.
//
// $_CONFIG['max_upload_size'] = $_SESSION['new_max_upload_size'];
// $_CONFIG['max_upload_size'] = $_COOKIE['new_max_upload_size'];
// $_CONFIG['max_upload_size'] = $_POST['new_max_upload_size'];
//
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
// ATTENTION
//
// All upload form values including file names are available to this script through $_POST.
// Therefore it is possible to create or over-ride config values based on user input. eg.
//
// if($_POST['upload_location'] == 1){ $_CONFIG['upload_dir'] = '/var/home/docs/foo/'; }
// else{ $_CONFIG['upload_dir'] = '/var/home/docs/bar/'; }
//
// To access file names simply use a for loop. eg
//
// for($i = 0; $i < count($_POST['upload_file']); $i++){
// $file_name = rawurldecode($_POST['upload_file'][$i]);
// }
//
////////////////////////////////////////////////////////////////////////////////////////////////
// Create temp, upload and log directories
if(!createDir($TEMP_DIR)){
showAlertMessage("<span class='error'>Failed to create temp_dir</span>", 1);
}
if(!createDir($_CONFIG['upload_dir'])){
showAlertMessage("<span class='error'>Failed to create upload_dir</span>", 1);
}
// Purge old .link files
if($_INI['purge_link_files']){ purgeFiles($TEMP_DIR, $_INI['purge_link_limit'], 'link', $_INI['debug_ajax']); }
// Purge old .redirect files
if($_INI['purge_redirect_files']){ purgeFiles($TEMP_DIR, $_INI['purge_redirect_limit'], 'redirect', $_INI['debug_ajax']); }
// Write link file
if(writeLinkFile($_CONFIG, $DATA_DELIMITER)){
startUpload($UPLOAD_ID, $_INI['debug_upload'], $_INI['debug_ajax']);
}
else{
showAlertMessage("<span class='error'>Failed to create link file: $UPLOAD_ID.link</span>", 1);
}
?>