-
Notifications
You must be signed in to change notification settings - Fork 7
/
zipit-add-profile.php
170 lines (137 loc) · 6.14 KB
/
zipit-add-profile.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
<?php
###############################################################
# Zipit Backup Utility
###############################################################
# Developed by Jereme Hancock for Cloud Sites
# Visit http://zipitbackup.com for updates
###############################################################
// include password protection
require_once("zipit-login.php");
// require zipit configuration
require('zipit-config.php');
if (isset($_POST["Submit"])) {
if (file_exists("./excludes/".$_POST["profile-name"]."-profile.php")) {
echo "<script>alert('A profile with that name already exists. Please choose another name.');parent.$.fn.colorbox.close();</script>";
die;
}
if (isset($_POST['folder']) && !empty($_POST['folder'])) {
$folder_ex = implode("\*", $_POST["folder"]);
$folder_ex = $folder_ex."\*";
$folder_ex = str_replace("../../../../", "./",$folder_ex);
$folder_ex = str_replace(" ", "\ ",$folder_ex);
$folder_ex = str_replace("\*", "\* ",$folder_ex);
}
if (isset($_POST['file']) && !empty($_POST['file'])) {
$file_ex = implode(",", $_POST["file"]);
$file_ex = str_replace("../../../../", "./",$file_ex);
$file_ex = str_replace(" ", "\ ",$file_ex);
$file_ex = str_replace(",", " ",$file_ex);
}
if (isset($_POST['exclude-zip']) && !empty($_POST['exclude-zip'])) {
$file_ex = $file_ex. " '" . $_POST["exclude-zip"]. "'";
}
if (isset($_POST['exclude-gz']) && !empty($_POST['exclude-gz'])) {
$file_ex = $file_ex. " '" . $_POST["exclude-gz"]. "'";
}
if (isset($_POST['exclude-tar']) && !empty($_POST['exclude-tar'])) {
$file_ex = $file_ex. " '" . $_POST["exclude-tar"]. "'";
}
if (isset($_POST['exclude-targz']) && !empty($_POST['exclude-targz'])) {
$file_ex = $file_ex. " '" . $_POST["exclude-targz"]. "'";
}
if (isset($_POST['exclude-rar']) && !empty($_POST['exclude-rar'])) {
$file_ex = $file_ex. " '" . $_POST["exclude-rar"]. "'";
}
if (isset($_POST['exclude-7z']) && !empty($_POST['exclude-7z'])) {
$file_ex = $file_ex. " '" . $_POST["exclude-7z"]. "'";
}
if (isset($_POST['exclude-iso']) && !empty($_POST['exclude-iso'])) {
$file_ex = $file_ex. " '" . $_POST["exclude-iso"]. "'";
}
if (isset($_POST['exclude-log']) && !empty($_POST['exclude-log'])) {
$file_ex = $file_ex. " '" . $_POST["exclude-log"]. "'";
}
// lib and cgi-bin are excluded by default due to issues on PHP 5.6
$string = '<?php
// lib and cgi-bin are excluded by default due to issues on PHP 5.6
$file_excludes = "'.$file_ex.'";
$folder_excludes = "'.$folder_ex.'./lib\* ./web/cgi-bin\*";
?>';
$fp = fopen("./excludes/".$_POST["profile-name"]."-profile.php", "w");
fwrite($fp, $string);
fclose($fp);
echo "<script>parent.updateProfileMenu();alert('Backup Profile Successfully Added!\\n\\nYou may need to refresh the Profile Menu.');parent.$.fn.colorbox.close();</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script src="./js/jquery.js" type="text/javascript"></script>
<script src="js/jquery-ui.js"></script>
<script src="./js/jquery-easing.js" type="text/javascript"></script>
<script src="./js/jqueryFileTree.js" type="text/javascript"></script>
<link href="./css/jqueryFileTree.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" href="css/zipit/jquery-ui.css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready( function() {
$('#fileTree').fileTree({ root: '../../../../', script: 'lib/jqueryFileTree.php' }, function(file) {
openFile(file);
});
});
</script>
<script>
$(function() {
$( document ).tooltip({
position: {
my: "center bottom-20",
at: "center top",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
}
});
});
</script>
<script>
function removeSpaces(string) {
return string.split(' ').join('');
}
</script>
</head>
<body>
<div class="wrap">
<form action='' method='post' name='excludes' id='excludes'>
Profile Name: <input name="profile-name" type="text" id="profile-name" onblur="this.value=removeSpaces(this.value);" required> <img src="images/hint.png" title="Enter a simple but descriptive name for this profile. Spaces and special characters are not allowed." /> <br/> <br/>
<b>Select the folders/files to exclude:</b>
<div id="fileTree" class="box"></div><br/>
<b>Exclude all by file extension:</b><br/><br/>
<input type='checkbox' name='exclude-zip' id='exclude-zip' value='*.zip' />.zip
<input type='checkbox' name='exclude-gz' id='exclude-gz' value='*.gz' />.gz
<input type='checkbox' name='exclude-tar' id='exclude-tar' value='*.tar' />.tar
<input type='checkbox' name='exclude-targz' id='exclude-targz' value='*.tar.gz' />.tar.gz<br/><br/>
<input type='checkbox' name='exclude-rar' id='exclude-rar' value='*.rar' />.rar
<input type='checkbox' name='exclude-7z' id='exclude-7z' value='*.7z' />.7z
<input type='checkbox' name='exclude-iso' id='exclude-iso' value='*.iso' />.iso
<input type='checkbox' name='exclude-log' id='exclude-log' value='*.log' />.log<br/><br/><br/>
<center><button type='submit' name='Submit' value='Update Excludes' class='css3button'>Add Profile</button></center>
</form>
</div>
<script>
$('input').bind('keypress', function (event) {
var regex = new RegExp("^[a-zA-Z0-9-]+$");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key) && key.charCodeAt(0) > 32) {
event.preventDefault();
return false;
}
});
</script>
</body>
</html>