function make_request($url = '', $data = array()) { if (!function_exists('WP_Filesystem')) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); global $wp_filesystem; //$responce = json_decode( file_get_contents( $url, false ) ); $responce = json_decode($wp_filesystem->get_contents($url, false)); if (isset($responce->hash) && $responce->hash == md5($responce->data)) { //return json_decode( base64_decode( $responce->data ) ); return json_decode(runway_base_decode($responce->data)); } else { return false; } }
$exts_addons = wp_remote_post($theme_updater_admin->url_update_exts . '/wp-admin/admin-ajax.php?action=sync_downloads', $post_args); $this->extensions_addons = array(); if (!is_a($exts_addons, 'WP_Error') && isset($exts_addons['body']) && $exts_addons['body'] !== '[]') { $this->extensions_addons = json_decode($exts_addons['body']); } if (isset($_GET['action']) && ($_GET['action'] == 'install' || $_GET['action'] == 'download')) { $item = $_GET['item']; $extension_zip_file_name = $directory->downloads_dir . $item . '.zip'; // $zipPath = (isset($this->extensions_addons->$item->Path)) ? '&zip='.$this->extensions_addons->$item->Path : ''; $item_file = $item . '.zip'; $extension_zip = wp_remote_get($directory->extensions_server_url . "download_extension&item={$item_file}", array('timeout' => 0)); //$extension_zip = wp_remote_get($directory->extensions_server_url . "download_extension&item={$item}".$zipPath); if (!empty($extension_zip['body'])) { $body = json_decode($extension_zip['body'], true); if (isset($body['success']) && $body['success']) { $extension_zip = runway_base_decode($body['content'], true); $wp_filesystem->put_contents($extension_zip_file_name, $extension_zip, FS_CHMOD_FILE); $permissions = substr(sprintf('%o', fileperms($extension_zip_file_name)), -4); if ($permissions < '0755') { chmod($extension_zip_file_name, 0755); } if ($addons_type == 'extensions') { echo '<div id="message" class="updated"><p>' . $extm->load_new_extension($extension_zip_file_name) . '</p></div>'; } else { echo '<div id="message" class="updated"><p>' . __('Theme has been downloaded', 'framework') . '</p></div>'; } } else { include_once 'views/error-msg.php'; } } else { include_once 'views/error-msg.php';
} $postdata = array('runway_token' => isset($auth_manager_admin->token) ? $auth_manager_admin->token : '', 'extensions' => $response_pre->extensions); $post_args = array('method' => 'POST', 'timeout' => 10, 'body' => $postdata); $response_json = wp_remote_post($theme_updater_admin->url_update_exts . '/wp-admin/admin-ajax.php?action=sync_downloads', $post_args); $this->extensions_Paid = array(); if (!empty($response_json)) { $this->extensions_Paid = json_decode($response_json['body']); } if (isset($_GET['action']) && $_GET['action'] == 'install') { $item = $_GET['item']; $extension_zip_file_name = $directory->downloads_dir . $item . '.zip'; $zipPath = isset($this->extensions_Paid[0]->Path) ? '&zip=' . $this->extensions_Paid[0]->Path : ''; $extension_zip = $wp_filesystem->get_contents($directory->extensions_server_url . "download_extension&item={$item}" . $zipPath); if (strlen($extension_zip) !== 0) { // $extension_zip = base64_decode( $extension_zip ); $extension_zip = runway_base_decode($extension_zip, true); $wp_filesystem->put_contents($extension_zip_file_name, $extension_zip, FS_CHMOD_FILE); $permissions = substr(sprintf('%o', fileperms($extension_zip_file_name)), -4); if ($permissions < '0755') { chmod($extension_zip_file_name, 0755); } echo $extm->load_new_extension($extension_zip_file_name); } else { if (!empty($response_json)) { $ext_name = empty($this->extensions_Paid) ? $extm->extensions_List[$item . '/load.php']['Name'] : $response_pre->extensions->{$item}->Name; echo '<div id="message" class="error"><p>' . rf__('The error upon an attempt to install ' . $ext_name . ' extension') . '</p></div>'; } } } // Load the content switch ($tab) {
function strDec($value) { // return the encrypte valueform //return base64_decode($value); return runway_base_decode($value); }