-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
116 lines (102 loc) · 3.79 KB
/
index.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
<?php
require 'config.php';
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>extentdl</title>
<meta name="generator" content="TextMate http://macromates.com/">
<link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<?php
require 'functions/error.php';
require 'functions/config.php';
require 'functions/wget.php';
// Check if no errors
if(!error_spew()){
parse_config();
// Import all submitted request vars
import_request_variables("gp", "r_");
// Download submitions
if($r_download){
if(empty($r_download_preset) || empty($r_download_url)) error_spool("Please fill in all fields");
else {
$wget_cmd = "$wget_path $output $wget_flags -P ".escapeshellarg($presets[$r_download_preset]['dir'])." ".escapeshellarg($r_download_url); // command to be executed
if($debug) echo "<code>Executing: $wget_cmd<br></code>"; // Echo command to be exec
execbg($wget_cmd); // MONEY SHOT
if($chmod) exec("chmod -R $chmod ".escapeshellarg($presets[$r_download_preset]['dir']));
// Record last download in config
$presets[$r_download_preset]['lastdl'] = $r_download_url;
update_config();
}
} // end download
//// Preset management
// add/update preset
elseif($r_edit){
if(empty($r_edit_dir) || empty($r_edit_name)) error_spool("Please fill in all fields");
else {
$presets[$r_edit_name]['dir'] = $r_edit_dir;
success("Preset [b]".$r_edit_name."[/b] added/updated successfully");
update_config();
}
} // end preset add/update
// delete preset
elseif($r_delete){
if(!empty($r_delete)){
unset($presets[$r_delete]);
update_config();
header("Location: ./");
}
} // end delete preset
error_spew();
if($preset_default_dir){
if($preset_default_dir == "1") $preset_default_dir = dirname($_SERVER['SCRIPT_FILENAME']);
}
?>
<form action="index.php" method="post" accept-charset="utf-8">
<fieldset>
<legend>Download</legend>
<?php if(!config_empty()) { ?>
<label for="download_preset">Preset:</label>
<select name="download_preset" id="download_preset" size="1">
<?php
foreach(array_keys($presets) as $name){
echo '<option value="'.ucwords($name).'">'.ucwords($name).'</option>';
}
?>
</select>
<label for="download_url">URL: </label><input type="text" name="download_url" value="" id="download_url">
<input type="submit" value="Download" name="download">
<?php } else echo "<strong>No presets exist</strong>" ?>
</fieldset>
</form>
<form action="index.php" method="post" accept-charset="utf-8">
<fieldset>
<legend>Add/Edit Preset</legend>
<label for="edit_name">Name: </label><input type="text" name="edit_name" value="" id="edit_name">
<label for="edit_dir">Directory: </label><input type="text" name="edit_dir" value="<?php echo $preset_default_dir; ?>" id="edit_dir">
<input type="submit" value="Add" name="edit">
</fieldset>
</form>
<fieldset>
<legend>Presets</legend>
<?php if(!config_empty()) { ?>
<table border="0" cellspacing="5" cellpadding="5">
<tr><th>Name</th><th>Directory</th><th>Last Download</th></tr>
<?php
foreach(array_keys($presets) as $name){
echo "<tr><td>$name <a href=\"?delete=".str_replace(" ", "%20", $name)."\">(delete)</a></td><td>".$presets[$name]['dir']."</td><td>".$presets[$name]['lastdl']."</td></tr>\n";
}
?>
</table>
<?php } else echo "<strong>No presets exist</strong>" ?>
</fieldset>
<?php
}
?>
</body>
</html>