private function runCommand() { $this->backupFolder(); if (file_exists(main::getPluginDir() . "/modules/{$this->method}.php")) { include main::getPluginDir() . "/modules/{$this->method}.php"; $this->method = str_replace("-", "_", $this->method); $command = new $this->method($this->params); $command->run(); $this->result = $command->result; if (!empty($command->dirs) && !empty($command->size)) { $this->result->setData($command->dirs); $this->result->setSize($command->size); } if ($this->auth === false && isset($this->request['sets'])) { $this->result->addElement('time', $command->time); $this->result->addElement('type', 'local'); $this->result->addElement('name', $command->name); $res = (array) $this->result; $this->result->addElement('counts', count($res['data'])); $this->result->addElement('md5_data', md5(print_r($res['data'], 1))); } } else { $this->setError('Command not found'); } }
public function run() { include main::getPluginDir() . '/libs/classes/aws-autoloader.php'; $ad = $this->params['access_details']; main::log(lang::get('Start copy files to Amazon S3', false)); $files = $this->params['files']; $dir = isset($ad['dir']) ? $ad['dir'] : '/'; $credentials = new Aws\Common\Credentials\Credentials($ad['AccessKeyId'], $ad['SecretAccessKey']); $client = Aws\S3\S3Client::factory(array('credentials' => $credentials)); try { $n = count($files); for ($i = 0; $i < $n; $i++) { $filePath = preg_replace('#[/\\\\]+#', '/', BACKUP_DIR . '/' . $dir . '/' . $files[$i]); $key = $dir ? $dir . '/' . basename($filePath) : basename($filePath); $key = ltrim(preg_replace('#[/\\\\]+#', '/', $key), '/'); //if first will be '/', file not will be uploaded, but result will be ok $putRes = $client->putObject(array("Bucket" => $ad['bucket'], 'Key' => $key, 'Body' => fopen($filePath, 'r+'))); if (isset($putRes['RequestId']) && !empty($putRes['RequestId'])) { main::log(str_replace('%s', basename($filePath), lang::get("File(%s) Upload successfully to Amazon S3", false))); } } main::log(lang::get('End copy files to Amazon S3', false)); } catch (Exception $e) { main::log('Error send to Amazon s3: ' . $e->getMessage()); $this->setError($e->getMessage()); return false; } catch (S3Exception $e) { main::log('Error send to Amazon s3: ' . $e->getMessage()); $this->setError($e->getMessage()); return false; } return true; }
public function run() { try { main::log(lang::get('Start Backup process...', false)); $this->init(); $db_param = $this->getDBParams(); $mysql = $this->incMysql(); if (isset($this->params['optimize'])) { main::log(lang::get('Optimize Database Tables', false)); $mysql->optimize(); } $mysql->backup($this->db_file); if (filesize($this->db_file) == 0) { throw new Exception(lang::get('Error in create dump Database: Chance of a lack of rights for the backup.', fale)); } else { $size_dump = round(filesize($this->db_file) / 1024 / 1024, 2); main::log(str_replace('%s', $size_dump, lang::get('Database Dump was successfully created( %s Mb):', false)) . str_replace(ABSPATH, '', $this->db_file)); } $files = $this->createListFiles(); $files[] = $this->db_file; if (($n = count($files)) > 0) { include main::getPluginDir() . "/libs/pclzip.lib.php"; $archive = $this->dir_backup . '/' . $this->getArchive($this->name); $zip = new PclZip($archive); main::log(lang::get('Add files to Backup', false)); main::log(lang::get('Create part ', false) . basename($archive)); for ($i = 0; $i < $n; $i++) { if (file_exists($archive) && filesize($archive) > $this->max_size_archive) { unset($zip); $archive = $this->dir_backup . '/' . $this->getNextArchive($this->name); main::log(lang::get('Create part ', false) . basename($archive)); $zip = new PclZip($archive); } $zip->add($files[$i], PCLZIP_OPT_REMOVE_PATH, ABSPATH); $this->saveMd5($files[$i], $archive); } // delete dump db main::log(lang::get('Remove dump Database with folder', false)); main::remove($this->db_file); $dirs = readDirectrory($this->dir_backup, array('.zip', '.md5')); $size = 0; if (($n = count($dirs)) > 0) { for ($i = 0; $i < $n; $i++) { $size += filesize($dirs[$i]); $dirs[$i] = basename($dirs[$i]); } } $sizeMb = round($size / 1024 / 1024, 2); // MB main::log(str_replace('%s', $sizeMb, lang::get('Backup created is finish ( %s Mb)', false))); $this->dirs = $dirs; $this->size = $size; } } catch (Exception $e) { $this->setError($e->message); } }
public function incMysql() { include main::getPluginDir() . '/libs/classes/as3b-mysql.php'; $db_param = $this->getDBParams(); $mysql = new as3b_mysql(); $mysql->user = $db_param['user']; $mysql->password = $db_param['pass']; $mysql->host = $db_param['host']; $mysql->db = $db_param['db']; $mysql->connect(); return $mysql; }
public function run() { if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugin_name = array_pop(explode("/", main::getPluginDir())); $plugin_name2 = str_replace("-", "_", $plugin_name); $plugin = get_plugins("/{$plugin_name}"); $pl_version = ""; if (isset($plugin["{$plugin_name}.php"])) { $pl_version = $plugin["{$plugin_name}.php"]['Version']; } if (isset($plugin["{$plugin_name2}.php"])) { $pl_version = $plugin["{$plugin_name2}.php"]['Version']; } $data_return = array('reply' => 'pong', 'date' => array('time_zone' => date('O'), 'time' => time()), 'system_version' => $wp_version, 'plugin_version' => $pl_version, 'system' => 'wordpress'); //get info for minimal requirements $data_return['php_version'] = @phpversion(); $data_return['php_max_execution_time'] = @intval(ini_get('max_execution_time')); $data_return['php_memory_limit'] = @ini_get('memory_limit'); $data_return['php_extensions'] = @implode(',', get_loaded_extensions()); $data_return['php_disabled_functions'] = @ini_get('disable_functions'); $data_return['php_max_execution_time_up'] = 0; $data_return['php_memory_limit_up'] = 0; $data_return['mysql_version'] = ''; $data_return['suhosin_functions_blacklist'] = ''; //try set new max time $newMaxExecutionTime = 3000; @set_time_limit($newMaxExecutionTime); if (@intval(ini_get('max_execution_time')) == $newMaxExecutionTime) { $data_return['php_max_execution_time_up'] = 1; } //try set new memory limit $newMemoryLimit = 256; @ini_set('memory_limit', $newMemoryLimit . 'M'); if (@intval(ini_get('memory_limit')) == $newMemoryLimit) { $data_return['php_memory_limit_up'] = 1; } //try get mysql version $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD); if (!mysqli_connect_errno()) { $data_return['mysql_version'] = $mysqli->server_info; } //check suhosin if (extension_loaded('suhosin')) { $data_return['suhosin_functions_blacklist'] = @ini_get('suhosin.executor.func.blacklist'); } $this->setResult($data_return); }
private function local() { $this->files = readDirectrory(BACKUP_DIR . '/' . $this->params['name'], array('.zip')); include main::getPluginDir() . '/libs/pclzip.lib.php'; if (($n = count($this->files)) > 0) { for ($i = 0; $i < $n; $i++) { main::log(str_replace('%s', basename($this->files[$i]), lang::get("Data decompression: %s", false))); $this->archive = new PclZip($this->files[$i]); $file_in_zip = $this->archive->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER); } if (file_exists(BACKUP_DIR . '/' . $this->params['name'] . '/mysqldump.sql')) { main::log(lang::get("Run process restore Database", false)); $mysql = $this->incMysql(); $mysql->restore(BACKUP_DIR . '/' . $this->params['name'] . '/mysqldump.sql'); main::log(lang::get("Stopped process restore Database", false)); main::remove(BACKUP_DIR . '/' . $this->params['name'] . '/mysqldump.sql'); } } }