Website Summary Files Commits Branches @commit @diff @stats
path: root / db-dump.php
diff options
context:
space:
mode:
Commit727f5f11ff636a1106332b1cf5eb30bf1062cc01 (patch)
Author
 pgmatev <petargabriel.matev@gmail.com>
2020-07-03 17:32:43 +0300
Committer
 pgmatev <petargabriel.matev@gmail.com>
2020-07-03 17:32:43 +0300
Files2da8107008a7b75095728f46bc78771abc0ddd5f /db-dump.php
tues-interns-2020-727f5f11ff636a1106332b1cf5eb30bf1062cc01.tar
tues-interns-2020-727f5f11ff636a1106332b1cf5eb30bf1062cc01.tar.gz
tues-interns-2020-727f5f11ff636a1106332b1cf5eb30bf1062cc01.zip
Parented8262e9490b0d6a2d2348197070cde169d3a922 (diff)
Parent8ee0ee3c18dc24b5edb60a38705bd9be7ea3be26 (diff)
Merge branch 'master' of https://github.com/DevriX/tues-interns-2020
1 files changed, 40 insertions, 0 deletions
-rw-r--r--db-dump.php40
diff --git a/db-dump.php b/db-dump.php
new file mode 100644
index 0000000..d297093
--- /dev/null
+++ b/db-dump.php
@@ -0,0 +1,40 @@
+<?php
+
+$username = "dxinterns";
+$password = "dxinterns1";
+
+// Some basic basic security, before we grant acess to our db to everyone on the internet
+if(isset($_POST['submit'])){
+ if($_POST['username'] == $username && $_POST['password'] == $password){
+
+ // Export the db, will auto-override the previous one, so we do not need unique name for each export
+ $output = shell_exec( "wp db export interns-carmag.sql" );
+
+ $file = 'interns-carmag.sql';
+
+ //This renders the popup with the download button for the sql file
+ if ( file_exists( $file ) ) {
+ header( 'Content-Description: File Transfer' );
+ header( 'Content-Type: application/octet-stream' );
+ header( 'Content-Disposition: attachment; filename="'.basename( $file ).'"' );
+ header( 'Expires: 0' );
+ header( 'Cache-Control: must-revalidate' );
+ header( 'Pragma: public' );
+ header( 'Content-Length: ' . filesize( $file ) );
+ readfile( $file );
+ exit;
+ }
+
+ } else {
+ echo "Sorry the username and password were incorrect";
+ }
+} else {
+
+ ?><form method="post">
+ Username: <input type="text" name="username" /><br />
+ Password: <input type="password" name="password" />
+ <input type='submit' name='submit' />
+ </form><?php
+
+}
+