| @@ -33,9 +33,9 @@ | ||
| 33 | 33 | $host = WebTotemAPI::siteInfo(); |
| 34 | 34 | |
| 35 | 35 | $files = self::getAgentsFiles( $host['id'] ); |
| 36 | 36 | |
| 37 | - if ( isset($files['am_filename']) and $files['am_filename'] ) { | |
| 37 | + if ( $files['amFilename'] ) { | |
| 38 | 38 | |
| 39 | 39 | if (!is_writable(ABSPATH)) { |
| 40 | 40 | WebTotemOption::setNotification('error', __('There are no permissions to write to the root directory', 'wtotem')); |
| 41 | 41 | return FALSE; |
| @@ -42,20 +42,19 @@ | ||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Download file. |
| 45 | 45 | $result = self::downloadFile( |
| 46 | - $files['download_link'], | |
| 47 | - ABSPATH . $files['am_filename'] | |
| 46 | + $files['downloadLink'], | |
| 47 | + ABSPATH . $files['amFilename'] | |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | 50 | // If the file is downloaded, then we write the data to the DB. |
| 51 | 51 | if ( $result ) { |
| 52 | 52 | WebTotemOption::setOptions( [ |
| 53 | - 'am_installed' => true, | |
| 54 | - 'am_file' => $files['am_filename'], | |
| 55 | - 'waf_file' => $files['waf_filename'], | |
| 56 | - 'av_file' => $files['av_filename'], | |
| 57 | - 'am_created_at' => $files['created_at'], | |
| 53 | + 'am_installed' => true, | |
| 54 | + 'am_file' => $files['amFilename'], | |
| 55 | + 'waf_file' => $files['wafFilename'], | |
| 56 | + 'av_file' => $files['avFilename'], | |
| 58 | 57 | ] ); |
| 59 | 58 | |
| 60 | 59 | self::generateMarkerFile(); |
| 61 | 60 | |
| @@ -69,11 +68,8 @@ | ||
| 69 | 68 | return FALSE; |
| 70 | 69 | } |
| 71 | 70 | } |
| 72 | 71 | |
| 73 | - // Update config_id. | |
| 74 | - WebTotemAPI::getHostID($host['name']); | |
| 75 | - | |
| 76 | 72 | } catch ( \Exception $e ) { |
| 77 | 73 | WebTotemOption::setNotification( 'error', $e->getMessage() ); |
| 78 | 74 | |
| 79 | 75 | return FALSE; |
| @@ -93,9 +89,9 @@ | ||
| 93 | 89 | */ |
| 94 | 90 | public static function getAgentsFiles( $host_id ) { |
| 95 | 91 | $result = WebTotemAPI::getAgentsFiles( $host_id ); |
| 96 | 92 | if ( ! $result ) { |
| 97 | - $file = [ 'download_link' => NULL ]; | |
| 93 | + $file = [ 'amFilename' => NULL, 'downloadLink' => NULL ]; | |
| 98 | 94 | |
| 99 | 95 | $message = __( 'Error generating the agent manager file.', 'wtotem' ); |
| 100 | 96 | WebTotemOption::setNotification( 'error', $message ); |
| 101 | 97 | } else { |
| @@ -255,9 +251,9 @@ | ||
| 255 | 251 | return $wp_filesystem; |
| 256 | 252 | } |
| 257 | 253 | |
| 258 | 254 | /** |
| 259 | - * @param $download_url | |
| 255 | + * @param $url | |
| 260 | 256 | * Link from where to download the file. |
| 261 | 257 | * @param $path |
| 262 | 258 | * Path where to save the file. |
| 263 | 259 | * |
| @@ -270,12 +266,8 @@ | ||
| 270 | 266 | 'timeout' => '30', |
| 271 | 267 | 'sslverify' => FALSE, |
| 272 | 268 | ]; |
| 273 | 269 | |
| 274 | -// if(WebTotemOption::getOption('api_environment') == 'M'){ | |
| 275 | -// $download_url = str_replace("wtotem.com", "wtotem.net", $download_url); | |
| 276 | -// } | |
| 277 | - | |
| 278 | 270 | $response = wp_remote_get($download_url, $args); |
| 279 | 271 | $http_code = wp_remote_retrieve_response_code($response); |
| 280 | 272 | |
| 281 | 273 | if ($http_code < 200) { |
| @@ -308,9 +300,9 @@ | ||
| 308 | 300 | if ( ! file_exists($file_path) or $wp_filesystem->get_contents($file_path) != $content) { |
| 309 | 301 | |
| 310 | 302 | if ( ! $wp_filesystem->put_contents( $file_path, $content, FS_CHMOD_FILE ) ) { |
| 311 | 303 | $message = sprintf( __( 'Check %s folder\'s write permission.', 'wtotem' ), WEBTOTEM_PLUGIN_PATH ) . sprintf( __( ' Read more <a href="%s" target="_blank">here</a>.', 'wtotem' ), 'https://docs.wtotem.com/agent-setup#it-additional-recommendations' ); |
| 312 | - WebTotemOption::setNotification( 'warning', $message ); | |
| 304 | + WebTotemOption::setNotification( 'error', $message ); | |
| 313 | 305 | } |
| 314 | 306 | |
| 315 | 307 | } |
| 316 | 308 | } |
| @@ -315,27 +307,8 @@ | ||
| 315 | 307 | } |
| 316 | 308 | } |
| 317 | 309 | } |
| 318 | 310 | } |
| 319 | - | |
| 320 | - /** | |
| 321 | - * WAF Include. | |
| 322 | - */ | |
| 323 | - public static function wafInclude(){ | |
| 324 | - if(WebTotemOption::isActivated()){ | |
| 325 | - $sapi = @php_sapi_name(); | |
| 326 | - if( $sapi != "cli" ) { | |
| 327 | - if ($waf = WebTotemOption::getOption("waf_file")) { | |
| 328 | - $include_waf_file = ABSPATH . '_include_' . $waf; | |
| 329 | - | |
| 330 | - if (is_file($include_waf_file) && is_readable($include_waf_file)) { | |
| 331 | - include_once $include_waf_file; | |
| 332 | - } | |
| 333 | - } | |
| 334 | - } | |
| 335 | - } | |
| 336 | - | |
| 337 | - } | |
| 338 | 311 | |
| 339 | 312 | /** |
| 340 | 313 | * Check if the plugin version has changed. |
| 341 | 314 | */ |