Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 59eae45

Browse files
authored
Uploads Files
1 parent 2d3d110 commit 59eae45

File tree

3 files changed

+310
-0
lines changed

3 files changed

+310
-0
lines changed

‎LICENSE‎

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
The MIT License (MIT).
2+
Copyright (c) 2024-2029 NaInSec.
3+
National Indonesia Security <https://nainsec.pro.net/>.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. So much and thank you...
6+
"Source" form shall mean the preferred form for making modifications,
7+
including but not limited to software source code, documentation
8+
source, and configuration files.
9+
10+
"Object" form shall mean any form resulting from mechanical
11+
transformation or translation of a Source form, including but
12+
not limited to compiled object code, generated documentation,
13+
and conversions to other media types.
14+
15+
"Work" shall mean the work of authorship, whether in Source or
16+
Object form, made available under the License, as indicated by a
17+
copyright notice that is included in or attached to the work
18+
(an example is provided in the Appendix below).
19+
20+
"Derivative Works" shall mean any work, whether in Source or Object
21+
form, that is based on (or derived from) the Work and for which the
22+
editorial revisions, annotations, elaborations, or other modifications
23+
represent, as a whole, an original work of authorship. For the purposes
24+
of this License, Derivative Works shall not include works that remain
25+
separable from, or merely link (or bind by name) to the interfaces of,
26+
the Work and Derivative Works thereof.
27+
28+
"Contribution" shall mean any work of authorship, including
29+
the original version of the Work and any modifications or additions
30+
to that Work or Derivative Works thereof, that is intentionally
31+
submitted to Licensor for inclusion in the Work by the copyright owner
32+
or by an individual or Legal Entity authorized to submit on behalf of
33+
the copyright owner. For the purposes of this definition, "submitted"
34+
means any form of electronic, verbal, or written communication sent
35+
to the Licensor or its representatives, including but not limited to
36+
communication on electronic mailing lists, source code control systems,
37+
and issue tracking systems that are managed by, or on behalf of, the
38+
Licensor for the purpose of discussing and improving the Work, but
39+
excluding communication that is conspicuously marked or otherwise
40+
designated in writing by the copyright owner as "Not a Contribution."
41+
42+
"Contributor" shall mean Licensor and any individual or Legal Entity
43+
on behalf of whom a Contribution has been received by Licensor and
44+
subsequently incorporated within the Work.
45+
46+
2. Grant of Copyright License. Subject to the terms and conditions of
47+
this License, each Contributor hereby grants to You a perpetual,
48+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
49+
copyright license to reproduce, prepare Derivative Works of,
50+
publicly display, publicly perform, sublicense, and distribute the
51+
Work and such Derivative Works in Source or Object form.
52+
53+
3. Grant of Patent License. Subject to the terms and conditions of
54+
this License, each Contributor hereby grants to You a perpetual,
55+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
56+
(except as stated in this section) patent license to make, have made,
57+
use, offer to sell, sell, import, and otherwise transfer the Work,
58+
where such license applies only to those patent claims licensable
59+
by such Contributor that are necessarily infringed by their
60+
Contribution(s) alone or by combination of their Contribution(s)
61+
with the Work to which such Contribution(s) was submitted. If You
62+
institute patent litigation against any entity (including a
63+
cross-claim or counterclaim in a lawsuit) alleging that the Work
64+
or a Contribution incorporated within the Work constitutes direct
65+
or contributory patent infringement, then any patent licenses
66+
granted to You under this License for that Work shall terminate
67+
as of the date such litigation is filed.
68+
69+
4. Redistribution. You may reproduce and distribute copies of the
70+
Work or Derivative Works thereof in any medium, with or without
71+
modifications, and in Source or Object form, provided that You
72+
meet the following conditions:
73+
74+
(a) You must give any other recipients of the Work or
75+
Derivative Works a copy of this License; and
76+
77+
(b) You must cause any modified files to carry prominent notices
78+
stating that You changed the files; and
79+
80+
(c) You must retain, in the Source form of any Derivative Works
81+
that You distribute, all copyright, patent, trademark, and
82+
attribution notices from the Source form of the Work,
83+
excluding those notices that do not pertain to any part of
84+
the Derivative Works; and
85+
86+
(d) If the Work includes a "NOTICE" text file as part of its
87+
distribution, then any Derivative Works that You distribute must
88+
include a readable copy of the attribution notices contained
89+
within such NOTICE file, excluding those notices that do not
90+
pertain to any part of the Derivative Works, in at least one
91+
of the following places: within a NOTICE text file distributed
92+
as part of the Derivative Works; within the Source form or
93+
documentation, if provided along with the Derivative Works; or,
94+
within a display generated by the Derivative Works, if and
95+
wherever such third-party notices normally appear. The contents
96+
of the NOTICE file are for informational purposes only and
97+
do not modify the License. You may add Your own attribution
98+
notices within Derivative Works that You distribute, alongside
99+
or as an addendum to the NOTICE text from the Work, provided
100+
that such additional attribution notices cannot be construed
101+
as modifying the License.
102+
103+
You may add Your own copyright statement to Your modifications and
104+
may provide additional or different license terms and conditions
105+
for use, reproduction, or distribution of Your modifications, or
106+
for any such Derivative Works as a whole, provided Your use,
107+
reproduction, and distribution of the Work otherwise complies with
108+
the conditions stated in this License.
109+
110+
5. Submission of Contributions. Unless You explicitly state otherwise,
111+
any Contribution intentionally submitted for inclusion in the Work
112+
by You to the Licensor shall be under the terms and conditions of
113+
this License, without any additional terms or conditions.
114+
Notwithstanding the above, nothing herein shall supersede or modify
115+
the terms of any separate license agreement you may have executed
116+
with Licensor regarding such Contributions.
117+
118+
6. Trademarks. This License does not grant permission to use the trade
119+
names, trademarks, service marks, or product names of the Licensor,
120+
except as required for reasonable and customary use in describing the
121+
origin of the Work and reproducing the content of the NOTICE file.
122+
123+
7. Disclaimer of Warranty. Unless required by applicable law or
124+
agreed to in writing, Licensor provides the Work (and each
125+
Contributor provides its Contributions) on an "AS IS" BASIS,
126+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
127+
implied, including, without limitation, any warranties or conditions
128+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
129+
PARTICULAR PURPOSE. You are solely responsible for determining the
130+
appropriateness of using or redistributing the Work and assume any
131+
risks associated with Your exercise of permissions under this License.
132+
133+
8. Limitation of Liability. In no event and under no legal theory,
134+
whether in tort (including negligence), contract, or otherwise,
135+
unless required by applicable law (such as deliberate and grossly
136+
negligent acts) or agreed to in writing, shall any Contributor be
137+
liable to You for damages, including any direct, indirect, special,
138+
incidental, or consequential damages of any character arising as a
139+
result of this License or out of the use or inability to use the
140+
Work (including but not limited to damages for loss of goodwill,
141+
work stoppage, computer failure or malfunction, or any and all
142+
other commercial damages or losses), even if such Contributor
143+
has been advised of the possibility of such damages.
144+
145+
9. Accepting Warranty or Additional Liability. While redistributing
146+
the Work or Derivative Works thereof, You may choose to offer,
147+
and charge a fee for, acceptance of support, warranty, indemnity,
148+
or other liability obligations and/or rights consistent with this
149+
License. However, in accepting such obligations, You may act only
150+
on Your own behalf and on Your sole responsibility, not on behalf
151+
of any other Contributor, and only if You agree to indemnify,
152+
defend, and hold each Contributor harmless for any liability
153+
incurred by, or claims asserted against, such Contributor by reason
154+
of your accepting any such warranty or additional liability.
155+
156+
END OF TERMS AND CONDITIONS
157+
158+
APPENDIX: How to apply the Apache License to your work.
159+
160+
To apply the Apache License to your work, attach the following
161+
boilerplate notice, with the fields enclosed by brackets "{}"
162+
replaced with your own identifying information. (Don't include
163+
the brackets!) The text should be enclosed in the appropriate
164+
comment syntax for the file format. We also recommend that a
165+
file or class name and description of purpose be included on the
166+
same "printed page" as the copyright notice for easier
167+
identification within third-party archives.
168+
169+
Copyright {yyyy} {name of copyright owner}
170+
171+
Licensed under the Apache License, Version 2.0 (the "License");
172+
you may not use this file except in compliance with the License.
173+
You may obtain a copy of the License at
174+
175+
http://www.apache.org/licenses/LICENSE-2.0
176+
177+
Unless required by applicable law or agreed to in writing, software
178+
distributed under the License is distributed on an "AS IS" BASIS,
179+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
180+
See the License for the specific language governing permissions and
181+
limitations under the License.
182+
ations under the License.

‎backdump.php‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
require_once('./mysqldump.php');
4+
5+
$dbhost = 'localhost'; //Server Hostname
6+
$dbuser = 'username'; //Server User Name
7+
$dbpass = 'password'; //Server Password
8+
$dbname = 'database_name'; //DB Name
9+
10+
$drop_table_if_exists = false;
11+
$version = '1.0';
12+
13+
$backup = new MySQLDump();
14+
$backup->droptableifexists = $drop_table_if_exists;
15+
16+
$backup->connect($dbhost, $dbuser, $dbpass, $dbname);
17+
18+
if (!$backup->connected) {
19+
die('Error: ' . $backup->mysql_error);
20+
}
21+
22+
$backup->list_tables();
23+
$table_count = count($backup->tables);
24+
$backup_output = "";
25+
26+
for ($i = 0; $i < $table_count; $i++) {
27+
$table_name = $backup->tables[$i];
28+
$backup->dump_table($table_name);
29+
$backup_output .= $backup->output;
30+
}
31+
32+
$backup_filename = date("d-m-Y-DayzDB") . '.sql';
33+
34+
$file_handle = fopen($backup_filename, 'w') or die("Error: Can't open file");
35+
fwrite($file_handle, $backup_output);
36+
fclose($file_handle);
37+
38+
$zip_filename = $backup_filename . '.zip';
39+
create_zip(array($backup_filename), $zip_filename);
40+
41+
unlink($backup_filename);
42+
43+
function create_zip($files = array(), $destination = '', $overwrite = true) {
44+
$zip = new ZipArchive();
45+
if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
46+
return false;
47+
}
48+
49+
foreach ($files as $file) {
50+
$zip->addFile($file, basename($file));
51+
}
52+
53+
$zip->close();
54+
return file_exists($destination);
55+
}
56+
?>

‎mysqldump.php‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
class MySQLDump {
4+
public $tables = [];
5+
public $connected = false;
6+
public $output;
7+
public $droptableifexists = false;
8+
public $mysql_error;
9+
public function __construct() {}
10+
public function connect($host, $user, $pass, $db) {
11+
$conn = @mysqli_connect($host, $user, $pass, $db);
12+
if (!$conn) {
13+
$this->mysql_error = mysqli_connect_error();
14+
return false;
15+
}
16+
$this->connected = true;
17+
return true;
18+
}
19+
20+
public function list_tables() {
21+
if (!$this->connected) {
22+
return false;
23+
}
24+
$this->tables = [];
25+
$sql = mysqli_query($this->conn, "SHOW TABLES");
26+
while ($row = mysqli_fetch_array($sql)) {
27+
array_push($this->tables, $row[0]);
28+
}
29+
return true;
30+
}
31+
32+
public function list_values($tablename) {
33+
$sql = mysqli_query($this->conn, "SELECT * FROM $tablename");
34+
$this->output .= "\n\n-- Dumping data for table: $tablename\n\n";
35+
while ($row = mysqli_fetch_array($sql)) {
36+
$this->output .= "INSERT INTO `$tablename` VALUES(";
37+
$values = array_map(function($value) {
38+
return is_numeric($value) ? $value : "'" . addslashes($value) . "'";
39+
}, $row);
40+
$this->output .= implode(", ", $values) . ");\n";
41+
}
42+
}
43+
44+
public function dump_table($tablename) {
45+
$this->output = "";
46+
$this->get_table_structure($tablename);
47+
$this->list_values($tablename);
48+
}
49+
50+
public function get_table_structure($tablename) {
51+
$this->output .= "\n\n-- Dumping structure for table: $tablename\n\n";
52+
if ($this->droptableifexists) {
53+
$this->output .= "DROP TABLE IF EXISTS `$tablename`;\nCREATE TABLE `$tablename` (\n";
54+
} else {
55+
$this->output .= "CREATE TABLE `$tablename` (\n";
56+
}
57+
$sql = mysqli_query($this->conn, "DESCRIBE $tablename");
58+
$primary = null;
59+
while ($row = mysqli_fetch_array($sql)) {
60+
$name = $row[0];
61+
$type = $row[1];
62+
$null = ($row[2] == 'YES') ? 'NULL' : 'NOT NULL';
63+
$extra = ($row[5] !== "") ? $row[5] . '' : '';
64+
if ($row[3] == "PRI") {
65+
$primary = $name;
66+
}
67+
$this->output .= " `$name` $type$null$extra,\n";
68+
}
69+
$this->output .= " PRIMARY KEY (`$primary`)\n);\n";
70+
}
71+
}
72+
?>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /