Latest Posts

WordPress Get WP Head with get_wp_head()

function get_wp_head() { ob_start(); wp_head(); return ob_get_clean(); }

© Jason White 2019 | Privacy Policy | CV | Life Hacks

made with

Dump WordPress MySQL Database and Download

<?php // HACKY MYSQL DUMP UTILITY FOR WORDPRESS BY @ijasonwhite unlink(__FILE__); //STIL MANUALLY CHECK M’KAY include_once(‘wp-config.php’); $file = sys_get_temp_dir() . (“/”.uniqid().”.mysql_dump_file”); //outside of public_html in tmp $exec = “mysqldump –user=”.DB_USER.” –password=”.DB_PASSWORD.” –host=”.DB_HOST.” “.DB_NAME.” > “.$file; exec($exec); 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); unlink($file); exit; } else { echo ‘error 0x000000001’; exit; }

© Jason White 2019 | Privacy Policy | CV | Life Hacks

made with

Zip Archive a Directory and Download PHP

// ZIPS THIS FOLDER unlink(__FILE__); //STIL MANUALLY CHECK M’KAY $rootPath = realpath(__DIR__); $temp = tmpfile(); $tempPath = $rootPath.’/file.zip’; //stream_get_meta_data($temp)[‘uri’]; $tempPath = sys_get_temp_dir() . (“/”.uniqid().”.public_html_dump”); //outside of public_html in tmp // Initialize archive object $zip = new ZipArchive(); $zip->open($tempPath, ZipArchive::CREATE | ZipArchive::OVERWRITE); // Create recursive directory iterator /** @var SplFileInfo[] $files */ $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $name => $file) { // Skip directories (they would be added automatically) if (!$file->isDir()) { // Get real and relative path for current file $filePath = $file->getRealPath(); $relativePath = substr($filePath, strlen($rootPath) + 1); // Add current file to archive $zip->addFile($filePath, $relativePath); } } // Zip archive will be created only after closing object $zip->close(); if (file_exists($tempPath)) { header(‘Content-Description: File Transfer’); header(‘Content-Type: application/octet-stream’); header(‘Content-Disposition: attachment; filename=”‘.basename($tempPath).’.zip”‘); header(‘Expires: 0’); header(‘Cache-Control: must-revalidate’); header(‘Pragma: public’); header(‘Content-Length: ‘ . filesize($tempPath)); readfile($tempPath); unlink($tempPath); exit; } else { echo ‘error 0x000000001’; exit; }

© Jason White 2019 | Privacy Policy | CV | Life Hacks

made with

Linux: Recursively Delete Files Older Than X Days

Be careful, used without caution this command will ruin your day.

find /path/to/files/* -mtime +0 -exec rm -r -i {} ; Send Bitcoin Preview modal-

3QpEYxNYsTDFLWg4JJE5QiKXikCXNpHHX6

© Jason White 2019 | Privacy Policy | CV | Life Hacks

made with

Run mySQLdump and output to SSH

[email protected]:~# ssh-keygen -t rsa -b 2048

2. Copy new key pair to target server.

The long and short of this little trick is that you have to use ssh-keygen to create new authentication key pairs for. we’ll use these for automating login.

[email protected]:~# ssh-copy-id [email protected]

3. Dump the database.

Using mysqldump and gzip it’s time to dump the database to a compressed archive on the target host.

[email protected]:~# mysqldump -u[dbuser] -p[dbpass] -h [dbhost] [dbname] | gzip -c | ssh [email protected] ‘cat > /pathtodumps/dump.sql.gz’ Send Bitcoin Preview modal-

3QpEYxNYsTDFLWg4JJE5QiKXikCXNpHHX6

© Jason White 2019 | Privacy Policy | CV | Life Hacks

made with