/** * Performs host check and then does a backup of the DB * * * @author Jeff Behnke <*****@*****.**> * @copyright (c) 2009-15 ValidWebs.com * * Created: 11/22/15, 2:45 PM * * @param $host * * @return bool|string */ function vvv_dash_wp_backup($host) { if (isset($host)) { $type = check_host_type($host); if (isset($type['key'])) { if (isset($type['path'])) { $path = VVV_WEB_ROOT . '/' . $type['key'] . $type['path']; $db_settings = get_wp_db_settings($path); } else { $path = VVV_WEB_ROOT . '/' . $type['key'] . '/'; $db_settings = get_wp_db_settings($path); } } else { $host = strstr($host, '.', true); $path = VVV_WEB_ROOT . '/' . $host . '/htdocs'; $db_settings = get_wp_db_settings($path); } if (is_array($db_settings) && $path) { $file_name = 'dumps/' . $host . '_' . date('m-d-Y_g-i-s', time()) . '.sql'; $export = shell_exec('wp db export --add-drop-table --path=' . $path . ' ' . $file_name); if (file_exists($file_name)) { return vvv_dash_notice('Your backup is ready at www/default/dashboard/' . $file_name); } } else { return false; } } return false; }
/** * Process $_POST supper globals used in the dashboard * * @author Jeff Behnke <*****@*****.**> * @copyright (c) 2009-15 ValidWebs.com * * Created: 12/8/15, 4:01 PM * * @return bool|string */ public function process_post() { $status = false; if (isset($_POST)) { if (isset($_POST['install_dev_plugins']) && isset($_POST['host'])) { $status = $this->install_dev_plugins($_POST); } if (isset($_POST['backup']) && isset($_POST['host'])) { $status = $this->create_db_backup($_POST['host']); } if (isset($_POST['roll_back']) && $_POST['roll_back'] == 'Roll Back') { $status = $this->db_roll_back($_POST['host'], $_POST['file_path']); if ($status) { $status = vvv_dash_notice($status); } } if (isset($_POST['purge_hosts'])) { $purge_status = $this->_cache->purge('host-sites'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } if (isset($_POST['purge_themes'])) { $purge_status = $this->_cache->purge('-themes'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } if (isset($_POST['purge_plugins'])) { $purge_status = $this->_cache->purge('-plugins'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } if (isset($_POST['update_item']) && isset($_POST['host'])) { $type = check_host_type($_POST['host']); if (isset($type['key'])) { if (isset($type['path'])) { if (!empty($_POST['type']) && 'plugins' == $_POST['type']) { $update_status = shell_exec('wp plugin update ' . $_POST['item'] . ' --path=' . VVV_WEB_ROOT . '/' . $type['key'] . $type['path']); $purge_status = $_POST['item'] . ' was updated!<br />'; $purge_status .= $this->_cache->purge('-plugins'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } if (!empty($_POST['type']) && 'themes' == $_POST['type']) { $status = shell_exec('wp theme update ' . $_POST['item'] . ' --path=' . VVV_WEB_ROOT . '/' . $type['key'] . $type['path']); $purge_status = $_POST['item'] . ' was updated!<br />'; $purge_status .= $this->_cache->purge('-themes'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } } else { if (!empty($_POST['type']) && 'plugins' == $_POST['type']) { $update_status = shell_exec('wp plugin update ' . $_POST['item'] . ' --path=' . VVV_WEB_ROOT . '/' . $type['key'] . '/'); $purge_status = $_POST['item'] . ' was updated!<br />'; $purge_status .= $this->_cache->purge('-plugins'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } if (!empty($_POST['type']) && 'themes' == $_POST['type']) { $update_status = shell_exec('wp theme update ' . $_POST['item'] . ' --path=' . VVV_WEB_ROOT . '/' . $type['key'] . '/'); $purge_status = $_POST['item'] . ' was updated!<br />'; $purge_status .= $this->_cache->purge('-themes'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } } } else { $host_info = $this->set_host_info($_POST['host']); $is_env = isset($host_info['is_env']) ? $host_info['is_env'] : false; $host = $host_info['host']; // WP Starter if ($is_env) { $host_path = VVV_WEB_ROOT . '/' . $host . '/public/wp'; } else { // Normal WP $host_path = VVV_WEB_ROOT . '/' . $host . '/' . $host_info['path']; } if (!empty($_POST['type']) && 'plugins' == $_POST['type']) { $update_status = shell_exec('wp plugin update ' . $_POST['item'] . ' --path=' . $host_path); $purge_status = $_POST['item'] . ' was updated!<br />'; $purge_status .= $this->_cache->purge('-plugins'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } if (!empty($_POST['type']) && 'themes' == $_POST['type']) { $status = shell_exec('wp theme update ' . $_POST['item'] . ' --path=' . $host_path); $purge_status = $_POST['item'] . ' was updated!<br />'; $purge_status .= $this->_cache->purge('-themes'); $status = vvv_dash_notice($purge_status . ' files were purged from cache!'); } } } } return $status; }
<i class="fa fa-database"></i> Backup DB </button> </form> <form class="backup form-inline" action="" method="get"> <input type="hidden" name="host" value="<?php echo $array['host']; ?> " /> <button type="submit" class="btn btn-warning btn-xs" name="migrate" value="true"> <i class="fa fa-database"></i> Migrate </button> </form> <?php } $type = check_host_type($array['host']); if (isset($type['key'])) { if (isset($type['path'])) { $debug_log_path = VVV_WEB_ROOT . '/' . $type['key'] . '/' . $type['path'] . '/wp-content/debug.log'; } else { $debug_log_path = VVV_WEB_ROOT . '/' . $type['key'] . '/wp-content/debug.log'; } } else { $this_host = strstr($array['host'], '.', true); $debug_log_path = VVV_WEB_ROOT . '/' . $this_host . '/htdocs/wp-content/debug.log'; } if (file_exists($debug_log_path)) { ?> <form class="backup" action="" method="get"> <input type="hidden" name="host" value="<?php echo $array['host'];