function wpadm_run($pl, $dir) { require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-method-class.php'; $request_name = $pl . '_request'; if (isset($_POST[$request_name]) && !empty($_POST[$request_name])) { require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-core.php'; $wpadm = new WPAdm_Core(wpadm_unpack($_POST[$request_name]), $pl, $dir); echo '<wpadm>' . wpadm_pack($wpadm->getResult()->toArray()) . '</wpadm>'; exit; } }
function wpadm_run($pl, $dir) { @set_time_limit(0); require_once dirname(__FILE__) . '/class-wpadm-method-class.php'; $request_name = 'wpadm_' . $pl . '_request'; if (isset($_POST[$request_name]) && !empty($_POST[$request_name])) { require_once dirname(__FILE__) . '/class-wpadm-core.php'; $wpadm = new WPAdm_Core(wpadm_unpack($_POST[$request_name]), $pl, $dir); echo '<wpadm>' . wpadm_pack($wpadm->getResult()->toArray()) . '</wpadm>'; exit; } }
public function getResult() { $errors = array(); $this->id = uniqid('wpadm_method_local_send_to_s3_'); $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS); $this->result->setError(''); $this->queue = new WPAdm_Queue($this->id); WPAdm_Core::log('Start copy files to Amazon S3'); $this->queue->clear(); $files = $this->params['files']; //$this->getResult()->setData($files); $dir = isset($ad['dir']) ? $ad['dir'] : '/'; //$dir = trim($dir, '/') . '/' . $this->name; foreach ($files as $file) { $commandContext = new WPAdm_Command_Context(); $commandContext->addParam('command', 'local_send_to_s3')->addParam('file', ABSPATH . $file)->addParam('bucket', $this->params['bucket'])->addParam('AccessKeyId', $this->params['AccessKeyId'])->addParam('SecretAccessKey', $this->params['SecretAccessKey']); if (isset($this->params['dir']) && !empty($this->params['dir'])) { $commandContext->addParam('dir', $this->params['dir']); } $this->queue->add($commandContext); unset($commandContext); } $res = $this->queue->save()->execute(); if (!$res) { WPAdm_Core::log('S3: ' . $this->queue->getError()); $errors[] = 'S3: ' . $this->queue->getError(); } WPAdm_Core::log('End copy files to Amazon S3'); if (!empty($errors)) { $this->result->setError(implode("\n", $errors)); $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR); } return $this->result; }
public function execute(WPAdm_Command_Context $context) { @session_start(); require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php'; WPAdm_Core::log(langWPADM::get('Send to dropbox files', false)); $dropbox = new dropbox($context->get('key'), $context->get('secret'), $context->get('token')); if (!$dropbox->isAuth()) { $context->setError(langWPADM::get('Website "%d" can\'t authorize on Dropbox with using of "app key: %k" and "app secret: %s"', false, array('%d', '%k', '%s'), array(SITE_HOME, $context->get('key'), $context->get('secret')))); return false; } $files = $context->get('files'); $file = explode("/", $files); $file_name = array_pop($file); $folder_project_temp = $context->get('folder_project'); $folder_project = ""; if (!empty($folder_project_temp)) { $folder_project = $folder_project_temp . "/"; $dropbox->createDir($folder_project_temp); $dropbox->createDir($folder_project . $context->get('folder')); } else { $dropbox->createDir($context->get('folder')); } $fromFile = str_replace('//', '/', $files); $toFile = str_replace('//', '/', $folder_project . $context->get('folder') . '/' . $file_name); $res = $dropbox->uploadFile($fromFile, $toFile); if (isset($res['error']) && isset($res['text']) && $res['error'] == 1) { $context->setError(langWPADM::get('Dropbox returned an error during file sending: ', false) . '"' . $res['text'] . '"'); return false; } if (isset($res['size']) && isset($res['client_mtime'])) { WPAdm_Core::log(langWPADM::get('File upload: ', false) . basename($files) . langWPADM::get(' size: ', false) . $res['size']); } return true; }
function wpadm_run($pl, $dir) { require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-method-class.php'; $request_name = $pl . '_request'; if (isset($_POST[$request_name]) && !empty($_POST[$request_name])) { require_once DRBBACKUP_BASE_DIR . '/modules/class-wpadm-core.php'; WPAdm_Core::$cron = false; $user_ip = wpadm_getIp(); if ($_SERVER['SERVER_ADDR'] != $user_ip && $_SERVER['HTTP_USER_AGENT'] != 'dropbox-backup user-agent') { WPAdm_Running::init_params_default(false); } $wpadm = new WPAdm_Core(wpadm_unpack($_POST[$request_name]), $pl, $dir); echo '<wpadm>' . wpadm_pack($wpadm->getResult()->toArray()) . '</wpadm>'; exit; } }
public function getResult() { $errors = array(); $this->id = uniqid('wpadm_method_send_to_dropbox_'); $this->result->setResult(WPAdm_Result::WPADM_RESULT_SUCCESS); $this->result->setError(''); $this->queue = new WPAdm_Queue($this->id); $ad = $this->params['access_details']; WPAdm_Core::log(langWPADM::get('Start copy to Dropbox Cloud', false)); $this->queue->clear(); $files = $this->params['files']; //$this->getResult()->setData($files); $dir = isset($ad['dir']) ? $ad['dir'] : '/'; //$dir = trim($dir, '/') . '/' . $this->name; if (is_array($files)) { foreach ($files as $file) { $commandContext = new WPAdm_Command_Context(); $commandContext->addParam('command', 'send_to_dropbox')->addParam('key', $ad['key'])->addParam('secret', $ad['secret'])->addParam('token', $ad['token'])->addParam('folder_project', $ad['folder'])->addParam('folder', $dir)->addParam('files', ABSPATH . $file); $this->queue->add($commandContext); unset($commandContext); } } $res = $this->queue->save()->execute(); if (!$res) { WPAdm_Core::log(langWPADM::get('Answer from Dropbox ', false) . $this->queue->getError()); $errors[] = langWPADM::get('Answer from Dropbox ', false) . $this->queue->getError(); } WPAdm_Core::log(langWPADM::get('End Copy Files to Dropbox', false)); if (count($errors) > 0) { $this->result->setError(implode("\n", $errors)); $this->result->setResult(WPAdm_Result::WPADM_RESULT_ERROR); } return $this->result; }
public function execute(WPAdm_Command_Context $context) { ini_set("memory_limit", "256M"); require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php'; $af = $this->getArchiveName($context->get('to_file')); ini_set("memory_limit", "256M"); $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5'); $archive->setRemovePath($context->get('remove_path')); $files = $context->get('files'); if (!file_exists($af)) { WPAdm_Core::log(langWPADM::get('Create part ', false) . basename($af)); } if (file_exists($af) && filesize($af) > $context->get('max_file_size')) { $af = $this->getNextArchiveName($context->get('to_file')); unset($archive); if (!file_exists($af)) { WPAdm_Core::log(langWPADM::get('Create part ', false) . basename($af)); } $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5'); $archive->setRemovePath($context->get('remove_path')); } $files_str = implode(',', $files); $files_archive = WPAdm_Running::getCommandResultData('archive'); if (!in_array($files_str, $files_archive)) { $archive->add($files_str); $files_archive = WPAdm_Running::getCommandResultData('archive'); $files_archive[] = $files_str; if (!empty($files_archive)) { WPAdm_Running::setCommandResultData('archive', $files_archive); } } return true; }
public function execute(WPAdm_Command_Context $context) { require_once WPAdm_Core::getPluginDir() . '/modules/aws-autoloader.php'; $credentials = new Aws\Common\Credentials\Credentials($context->get('AccessKeyId'), $context->get('SecretAccessKey')); $client = Aws\S3\S3Client::factory(array('credentials' => $credentials)); $dir = $context->get('dir') ? $context->get('dir') . "/" : ''; try { if (!empty($dir)) { $logs = $client->putObject(array('Bucket' => $context->get('bucket'), 'Key' => $dir, 'Body' => '')); WPAdm_Core::log('Create folder ' . $dir); } $filePath = preg_replace('#[/\\\\]+#', '/', $context->get('file')); $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" => $context->get('bucket'), 'Key' => $key, 'Body' => fopen($filePath, 'r+'))); if ((int) $putRes == 1) { WPAdm_Core::log("File({$key}) Upload successfully to Amazon S3"); } } catch (Exception $e) { $context->setError($e->getMessage()); return false; } catch (S3Exception $e) { WPAdm_Core::log('error send file ' . $e->getMessage()); $context->setError($e->getMessage()); return false; } return true; }
public function getResult() { WPAdm_Core::log("start widget method", __CLASS__); $this->result->setData('not result'); wpadm_wp_stat::on_activate(); if (isset($this->params['side'])) { $this->deleteWidget(); $this->addWidget($this->params['side']); } $this->result->setResult(WPAdm_result::WPADM_RESULT_SUCCESS); return $this->result; }
public function getResult() { global $wp_version; $this->result->setResult(WPAdm_result::WPADM_RESULT_SUCCESS); if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugin_name = array_pop(explode("/", WPAdm_Core::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->result->setData($data_return); return $this->result; }
private function unpack($f, $to) { if (strpos($to, ABSPATH) === false) { $to = ABSPATH . $to; } require_once WPAdm_Core::getPluginDir() . '/modules/pclzip.lib.php'; $this->archive = new PclZip($f); $res = $this->archive->extract(PCLZIP_OPT_PATH, WPAdm_Core::getPluginDir(), PCLZIP_OPT_REPLACE_NEWER, PCLZIP_OPT_REMOVE_PATH, WPAdm_Core::$plugin_name); WPAdm_Core::log($this->archive->errorInfo(true)); if ($res) { return true; } return false; }
public static function init() { $lang_wp = self::getLanguageSystem(); $plugin_dir = WPAdm_Core::getPluginDir(); self::$lang_dir = $plugin_dir . '/libs/lang/'; if (isset($lang_wp)) { //self::downloadLang(); if (file_exists(self::$lang_dir . $lang_wp . '.php')) { require_once self::$lang_dir . $lang_wp . '.php'; self::$lang[$lang_wp] = $languag; self::$lang_name = $lang_wp; return true; } } return false; }
public function execute(WPAdm_Command_Context $context) { //WPAdm_Core::log(print_r($context, true)); require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php'; $mysqldump = new WPAdm_Mysqldump(); $mysqldump->host = $context->get('host'); $mysqldump->user = $context->get('user'); $mysqldump->password = $context->get('password'); try { $mysqldump->optimize($context->get('db')); } catch (Exception $e) { $context->setError($e->getMessage()); return false; } return true; }
public function execute(WPAdm_Command_Context $context) { require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php'; $af = $this->getArchiveName($context->get('to_file')); $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5'); $archive->setRemovePath($context->get('remove_path')); $files = $context->get('files'); if (file_exists($af) && filesize($af) > $context->get('max_file_size')) { $af = $this->getNextArchiveName($context->get('to_file')); unset($archive); $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5'); $archive->setRemovePath($context->get('remove_path')); } $archive->add(implode(',', $files)); return true; }
public function getResult() { $backups_dir = realpath(WPADM_DIR_BACKUP . '/' . $this->params['name']); if (strpos($backups_dir, DIRECTORY_SEPARATOR . 'wpadm_backups' . DIRECTORY_SEPARATOR) === false || !is_dir($backups_dir)) { $this->result->setResult = WPAdm_result::WPADM_RESULT_ERROR; $this->result->setError('Wrong name backup'); } else { if (is_dir($backups_dir)) { WPAdm_Core::rmdir($backups_dir); if (!is_dir($backups_dir)) { $this->result->setResult = WPAdm_result::WPADM_RESULT_SUCCESS; } else { $this->result->setResult = WPAdm_result::WPADM_RESULT_ERROR; $this->result->setError('Failed to remove backup'); } } } return $this->result; }
/** * @param string $com * @return command */ static function getCommand($com = '') { if (!preg_match("|[a-zA-Z0-9_]|", $com)) { return null; } $com = mb_strtolower($com); $tmp = explode('_', $com); $class_file = WPAdm_Core::getPluginDir() . "/commands/class-wpadm-command-" . str_replace('_', '-', $com) . ".php"; if (file_exists($class_file)) { require_once $class_file; foreach ($tmp as $k => $v) { $tmp[$k] = ucfirst($v); } $com = implode('_', $tmp); $class_name = "WPAdm_Command_{$com}"; return new $class_name(); } return null; }
public function execute(WPAdm_Command_Context $context) { if (file_exists($context->get('zip_file'))) { require_once WPAdm_Core::getPluginDir() . '/modules/pclzip.lib.php'; $this->archive = new PclZip($context->get('zip_file')); $file = $context->get('file'); $is_dump = $file && strpos($file, "mysqldump.sql"); WPAdm_Core::log("Data decompression " . basename($context->get('zip_file'))); if ($is_dump !== false) { $inzip = str_replace(ABSPATH, "", $file); $file_in_zip = $this->archive->extract(PCLZIP_OPT_BY_NAME, $inzip); } else { $file_in_zip = $this->archive->extract(PCLZIP_OPT_REPLACE_NEWER); } if ($file_in_zip == 0) { WPAdm_Core::log(langWPADM::get("Website \"%d\" returned an error during archive extracting: ", false, "%d", SITE_HOME) . $this->archive->errorInfo(true)); $context->setError(langWPADM::get("Website \"%d\" returned an error during archive extracting: ", false, "%d", SITE_HOME) . $this->archive->errorInfo(true)); return false; } //WPAdm_Core::log(print_r($file_in_zip, 1)); if ($is_dump !== false) { $db_host = $context->get('db_host'); if ($db_host !== false) { require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php'; $mysqldump = new WPAdm_Mysqldump(); $mysqldump->host = $context->get('db_host'); $mysqldump->user = $context->get('db_user'); $mysqldump->password = $context->get('db_password'); try { $mysqldump->restore($context->get('db_name'), $file); } catch (Exception $e) { $context->setError($e->getMessage()); return false; } } } } else { $context->setError(langWPADM::get("Website \"%d\" returned an error: The necessary file of archive \"%f\" wasn't found ", false, array('%d', '%f'), array(SITE_HOME, $context->get('zip_file')))); WPAdm_Core::log(langWPADM::get("Website \"%d\" returned an error: The necessary file of archive \"%f\" wasn't found ", false, array('%d', '%f'), array(SITE_HOME, $context->get('zip_file')))); return false; } return true; }
public function execute(WPAdm_Command_Context $context) { if (file_exists($context->get('zip_file'))) { require_once WPAdm_Core::getPluginDir() . '/modules/pclzip.lib.php'; $this->archive = new PclZip($context->get('zip_file')); $file = $context->get('file'); $is_dump = $file && strpos($file, "mysqldump.sql"); WPAdm_Core::log("Decompression Archive " . basename($context->get('zip_file'))); if ($is_dump !== false) { $inzip = str_replace(ABSPATH, "", $file); $file_in_zip = $this->archive->extract(PCLZIP_OPT_BY_NAME, $inzip); } else { $file_in_zip = $this->archive->extract(PCLZIP_OPT_REPLACE_NEWER); } if ($file_in_zip == 0) { WPAdm_Core::log("ERROR Archived: " . $this->archive->errorInfo(true)); $context->setError("ERROR Archived: " . $this->archive->errorInfo(true)); return false; } //WPAdm_Core::log(print_r($file_in_zip, 1)); if ($is_dump !== false) { $db_host = $context->get('db_host'); if ($db_host !== false) { require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-mysqldump.php'; $mysqldump = new WPAdm_Mysqldump(); $mysqldump->host = $context->get('db_host'); $mysqldump->user = $context->get('db_user'); $mysqldump->password = $context->get('db_password'); try { $mysqldump->restore($context->get('db_name'), $file); } catch (Exception $e) { $context->setError($e->getMessage()); return false; } } } } else { $context->setError("File Archive Not Exist " . $context->get('zip_file')); WPAdm_Core::log("File Archive Not Exist " . $context->get('zip_file')); return false; } return true; }
public function execute(WPAdm_Command_Context $context) { require_once WPAdm_Core::getPluginDir() . '/modules/class-wpadm-archive.php'; $af = $this->getArchiveName($context->get('to_file')); $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5'); $archive->setRemovePath($context->get('remove_path')); $files = $context->get('files'); // если привышен максимальный размер архива, создадим новый if (file_exists($af) && filesize($af) > $context->get('max_file_size')) { //WPAdm_Core::log(filesize($af) . ', max=' . $context->get('max_file_size')); $af = $this->getNextArchiveName($context->get('to_file')); unset($archive); $archive = new WPAdm_Archive($af, $context->get('to_file') . '.md5'); $archive->setRemovePath($context->get('remove_path')); } //WPAdm_Core::log('Add to archive ' . $af); $archive->add(implode(',', $files)); return true; }
private function save() { $file = WPAdm_Core::getTmpDir() . '/' . $this->id . '.queue'; $txt = serialize(array('id' => $this->id, 'step' => $this->step, 'contexts' => $this->contexts)); file_put_contents($file, $txt); return $this; }
private function directoryToArray($directory, $recursive) { $array_items = array(); $d = str_replace(ABSPATH, '', $directory); // Skip dirs if (isset($this->params['minus-path'])) { $minus_path = explode(",", $this->params['minus-path']); if (in_array($d, $minus_path)) { WPAdm_Core::log(langWPADM::get('Skip of Folder ', false) . $directory); return array(); } } else { $minus_path = array(); } $d = str_replace('\\', '/', $d); $tmp = explode('/', $d); $d1 = mb_strtolower($tmp[0]); unset($tmp[0]); $d2 = mb_strtolower(implode('/', $tmp)); if (strpos($d2, 'cache') !== false && isset($tmp[0]) && !in_array($tmp[0], array('plugins', 'themes'))) { WPAdm_Core::log(langWPADM::get('Skip of Cache-Folder ', false) . $directory); return array(); } if (strpos($directory, 'wpadm_backups') !== false) { return array(); } if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($directory . "/" . $file)) { if ($recursive) { $array_items = array_merge($array_items, $this->directoryToArray($directory . "/" . $file, $recursive)); } $file = $directory . "/" . $file; if (!is_dir($file)) { $ff = preg_replace("/\\/\\//si", "/", $file); $f = str_replace(ABSPATH, '', $ff); // skip "minus" dirs if (!in_array($f, $minus_path)) { $array_items[] = $ff; } else { WPAdm_Core::log(langWPADM::get('Skip of File ', false) . $ff); } } } else { $file = $directory . "/" . $file; if (!is_dir($file)) { $ff = preg_replace("/\\/\\//si", "/", $file); $f = str_replace(ABSPATH, '', $ff); // skip "minus" dirs if (!in_array($f, $minus_path)) { $array_items[] = $ff; } else { WPAdm_Core::log(langWPADM::get('Skip of Folder ', false) . $ff); } } } } } closedir($handle); } return $array_items; }
private function directoryToArray($directory, $recursive) { $array_items = array(); $d = str_replace(ABSPATH . '/', '', $directory); // пропускаем ненужные директории if (in_array($d, $this->params['minus-path'])) { WPAdm_Core::log('Пропускаем папку ' . $directory); return array(); } $d = str_replace('\\', '/', $d); $tmp = explode('/', $d); $d1 = mb_strtolower($tmp[0]); unset($tmp[0]); $d2 = mb_strtolower(implode('/', $tmp)); // if (strpos($d1, 'cache') !== false || ($d1 == 'wp-includes' && strpos($d2, 'cache') !== false)) { // if (($d1 == 'wp-includes' && strpos($d2, 'cache') !== false) // || ($d1 == 'wp-content' || !in_array($tmp[0], array('plugins', 'themes'))) if (strpos($d2, 'cache') !== false && !in_array($tmp[0], array('plugins', 'themes'))) { WPAdm_Core::log('Пропускаем папку(cache) ' . $directory); return array(); } if (strpos($directory, 'wpadm_backups') !== false) { return array(); } if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($directory . "/" . $file)) { if ($recursive) { $array_items = array_merge($array_items, $this->directoryToArray($directory . "/" . $file, $recursive)); } $file = $directory . "/" . $file; if (!is_dir($file)) { $ff = preg_replace("/\\/\\//si", "/", $file); $f = str_replace(ABSPATH . '/', '', $ff); // пропускаем ненужные директории if (!in_array($f, $this->params['minus-path'])) { $array_items[] = $ff; } else { WPAdm_Core::log('Пропускаем файл ' . $ff); } } } else { $file = $directory . "/" . $file; if (!is_dir($file)) { $ff = preg_replace("/\\/\\//si", "/", $file); $f = str_replace(ABSPATH . '/', '', $ff); // пропускаем ненужные директории if (!in_array($f, $this->params['minus-path'])) { $array_items[] = $ff; } else { WPAdm_Core::log('Пропускаем файл ' . $ff); } } } } } closedir($handle); } return $array_items; }
public static function setPluginDIr($dir) { self::$pl_dir = $dir; }
public static function hide_notice() { if (isset($_GET['type'])) { switch ($_GET['type']) { case 'preview': file_put_contents(WPAdm_Core::getTmpDir() . "/notice", 1); break; case 'star': if (isset($_GET['hide']) && $_GET['hide'] == '1d') { file_put_contents(WPAdm_Core::getTmpDir() . "/notice-star", time() . '_w'); } elseif (isset($_GET['hide']) && $_GET['hide'] == 'week' || !isset($_GET['hide'])) { file_put_contents(WPAdm_Core::getTmpDir() . "/notice-star", 0); } break; } } header('location:' . $_SERVER['HTTP_REFERER']); exit; }
public static function dropbox_backup_create() { require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php"; @session_write_close(); $log = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir); if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) { unlink(WPAdm_Core::getTmpDir() . "/logs2"); } if (WPAdm_Core::dir_writeble(WPADM_DIR_BACKUP)) { $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting'); $send_to_dropbox = true; if ($dropbox_options) { $dropbox_options = unserialize(base64_decode($dropbox_options)); if (!isset($dropbox_options['app_key'])) { WPAdm_Core::log(langWPADM::get('Website "%d" returned an error during connection to Dropbox: "App Key" wasn\'t found. Please, check your Dropbox settings.', false, '%d', SITE_HOME)); $send_to_dropbox = false; } if (!isset($dropbox_options['app_secret'])) { WPAdm_Core::log(langWPADM::get('Website "%d" returned an error during connection to Dropbox: "App Secret" wasn\'t found. Please, check your Dropbox settings.', false, '%d', SITE_HOME)); $send_to_dropbox = false; } if (!isset($dropbox_options['oauth_token'])) { WPAdm_Core::log(langWPADM::get('Website "%d" returned an error during file sending to Dropbox: "Auth Token not exist. Files cannot be sent to Dropbox cloud. Please, check your Dropbox settings."', false, '%d', SITE_HOME)); $send_to_dropbox = false; } } else { WPAdm_Core::log(langWPADM::get('Website "%d" returned an error during connection to Dropbox: "app key" and "app secret" wasn\'t found. Please, check your Dropbox settings.', false, '%d', SITE_HOME)); $res['type'] = 'local'; $send_to_dropbox = false; } if ($send_to_dropbox) { parent::$type = 'full'; $backup_local = new WPAdm_Core(array('method' => "local_backup", 'params' => array('optimize' => 1, 'limit' => 0, 'time' => @$_POST['time'], 'types' => array('db', 'files'))), 'full_backup_dropbox', WPAdm_Core::$pl_dir); $res = $backup_local->getResult()->toArray(); $res['md5_data'] = md5(print_r($res, 1)); $res['name'] = $backup_local->name; $res['time'] = $backup_local->time; $res['type'] = 'dropbox'; $res['counts'] = count($res['data']); unset($backup); $folder_project = self::getNameProject(); $backup = new WPAdm_Core(array('method' => "send-to-dropbox", 'params' => array('files' => $res['data'], 'access_details' => array('key' => $dropbox_options['app_key'], 'secret' => $dropbox_options['app_secret'], 'token' => $dropbox_options['auth_token_secret'], 'dir' => $res['name'], 'folder' => $folder_project))), 'full_backup_dropbox', WPAdm_Core::$pl_dir); $result_send = $backup->getResult()->toArray(); if ($result_send['result'] == 'error') { $res = array(); $res['error'] = $result_send['error']; $res['result'] = 'error'; @rename(WPAdm_Core::getTmpDir() . "/logs2", WPAdm_Core::getTmpDir() . "/logs_error_" . $backup_local->time); } WPAdm_Core::rmdir(WPADM_DIR_BACKUP . "/{$res['name']}"); } } else { $res['result'] = 'error'; $res['error'] = langWPADM::get('Website "%d" returned an error during file creation: Failed to create file, please check the permissions on the folder "%dir".', false, array('%d', '%dir'), array(SITE_HOME, WPADM_DIR_BACKUP)); $res['data'] = array(); $res['size'] = 0; } @session_start(); echo json_encode($res); wp_die(); }
public function save() { ini_set("memory_limit", "256M"); $this->deleteCommands(); $file = WPAdm_Core::getTmpDir() . '/' . $this->id . '.queue'; $txt = serialize(array('id' => $this->id, 'contexts' => $this->contexts)); file_put_contents($file, $txt); return $this; }
public static function delete_backup() { if (isset($_POST['backup-type'])) { if ($_POST['backup-type'] == 'local') { require_once dirname(__FILE__) . "/class-wpadm-core.php"; $dir = ABSPATH . 'wpadm_backups/' . $_POST['backup-name']; if (is_dir($dir)) { WPAdm_Core::rmdir($dir); } } elseif ($_POST['backup-type'] == 's3') { $amazon_option = self::getAmazonOptions(); if ($amazon_option) { require_once dirname(__FILE__) . '/modules/aws-autoloader.php'; $credentials = new Aws\Common\Credentials\Credentials($amazon_option['access_key_id'], $amazon_option['secret_access_key']); $client = Aws\S3\S3Client::factory(array('credentials' => $credentials)); try { $keys = $client->listObjects(array('Bucket' => $amazon_option['bucket'], 'Prefix' => $_POST['backup-name']))->getIterator(); if (isset($keys['Contents'])) { $n = count($keys['Contents']); for ($i = 0; $i < $n; $i++) { $client->deleteObject(array('Bucket' => $amazon_option['bucket'], 'Key' => $keys['Contents'][$i]['Key'])); } } } catch (Exception $e) { $_SESSION['errorMsgWpadmDB'] = $e->getMessage(); } catch (S3Exception $e) { $_SESSION['errorMsgWpadmDB'] = $e->getMessage(); } } } } header("Location: " . admin_url("admin.php?page=wpadm_wp_db_backup_s3")); }
/** * @param string $error */ public function setError($error) { WPAdm_Core::log($error); $this->error = $error; }
private function testKeys($params) { $str = 'test string'; if (!function_exists('openssl_public_decrypt')) { // зашифруем строку openssl_private_encrypt($str, $sign, $params['private']); // проверим подпись openssl_public_decrypt($sign, $str2, $params['public']); $ret = $str == $str2; } else { set_include_path(get_include_path() . PATH_SEPARATOR . WPAdm_Core::getPluginDir() . '/modules/phpseclib'); require_once 'Crypt/RSA.php'; // зашифруем строку define('CRYPT_RSA_PKCS15_COMPAT', true); $rsa = new Crypt_RSA(); $rsa->loadKey($params['private']); $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); $ciphertext = $rsa->encrypt($str); // проверим подпись $rsa = new Crypt_RSA(); $rsa->loadKey($params['public']); $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); $ret = $str == $rsa->decrypt($ciphertext); } $this->result->setResult(WPAdm_result::WPADM_RESULT_SUCCESS); $this->result->setData(array('match' => (int) $ret)); }
public function execute(WPAdm_Command_Context $context) { require_once WPAdm_Core::getPluginDir() . '/modules/S3.php'; $s3 = new S3($context->get('AccessKeyId'), $context->get('SecretAccessKey')); //new S3Wrapper(); //S3::setAuth($context->get('AccessKeyId'), $context->get('SecretAccessKey')); /*(array( 'key' => $context->get('AccessKeyId'), 'secret' => $context->get('SecretAccessKey'), 'token' => $context->get('SessionToken') )); */ // $s3->setTimeCorrectionOffset(60); $dir = $context->get('dir') ? $context->get('dir') : ''; if ($dir) { //$s3->mkdir('s3://' . $context->get('bucket') . '/' . $dir); $logs = $s3->putObject($dir, $context->get('bucket'), $dir . "/", s3::ACL_PUBLIC_READ); //$logs = $s3->putObjectString($dir, $context->get('bucket'), $context->get('bucket') . '/' . $dir, s3::ACL_PUBLIC_READ_WRITE); WPAdm_Core::log('create folder logs ' . serialize($logs)); /*$s3->registerStreamWrapper("s3"); @mkdir('s3://'.$context->get('bucket').'/'.$dir);*/ } try { $filePath = preg_replace('#[/\\\\]+#', '/', $context->get('file')); $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 = $s3->putObjectFile($filePath, $context->get('bucket'), $key, s3::ACL_PUBLIC_READ_WRITE); WPAdm_Core::log('putObjectFile ' . $filePath . ' == ' . $context->get('bucket') . " == " . $key . ' == ' . (int) $putRes); } catch (Exception $e) { $context->setError($e->getMessage()); return false; } catch (S3Exception $e) { WPAdm_Core::log('error send file ' . $e->getMessage()); $context->setError($e->getMessage()); return false; } return true; }