| @@ -109,15 +109,15 @@ | ||
| 109 | 109 | function get_ip($ipHeader) { |
| 110 | 110 | $ip = '127.0.0.1'; |
| 111 | 111 | if ($ipHeader && is_array($ipHeader)) { |
| 112 | 112 | if (array_key_exists($ipHeader['hdr'], $_SERVER)) { |
| 113 | - $_ips = preg_split("/(,| |\t)/", $_SERVER[$ipHeader['hdr']]); | |
| 113 | + $_ips = preg_split("/(,| |\t)/", WPRHelper::getRawParam('SERVER', $ipHeader['hdr'])); | |
| 114 | 114 | if (array_key_exists(intval($ipHeader['pos']), $_ips)) { |
| 115 | 115 | $ip = $_ips[intval($ipHeader['pos'])]; |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } else if (array_key_exists('REMOTE_ADDR', $_SERVER)) { |
| 119 | - $ip = $_SERVER['REMOTE_ADDR']; | |
| 119 | + $ip = WPRHelper::getRawParam('SERVER', 'REMOTE_ADDR'); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $ip = trim($ip); |
| 123 | 123 | if (WPRHelper::safePregMatch('/^\[([0-9a-fA-F:]+)\](:[0-9]+)$/', $ip, $matches)) { |
| @@ -211,9 +211,11 @@ | ||
| 211 | 211 | $post = $this->get_post($post_id); |
| 212 | 212 | if ($this->is_key_ignored($this->ignored_events, $post["type"])) |
| 213 | 213 | return; |
| 214 | 214 | $event_data = array(); |
| 215 | - if ($post["type"] === "product") { | |
| 215 | + if (!isset($post["type"])) { | |
| 216 | + $event_data["post"] = $post; | |
| 217 | + } elseif ($post["type"] === "product") { | |
| 216 | 218 | $event_data["product"] = $post; |
| 217 | 219 | } elseif ($post["type"] === "shop_order") { |
| 218 | 220 | $event_data["order"] = $post; |
| 219 | 221 | } else { |
| @@ -226,9 +228,11 @@ | ||
| 226 | 228 | $post = $this->get_post($post_id); |
| 227 | 229 | if ($this->is_key_ignored($this->ignored_events, $post["type"])) |
| 228 | 230 | return; |
| 229 | 231 | $event_data = array(); |
| 230 | - if ($post["type"] === "product") { | |
| 232 | + if (!isset($post["type"])) { | |
| 233 | + $event_data["post"] = $post; | |
| 234 | + } elseif ($post["type"] === "product") { | |
| 231 | 235 | $event_data["product"] = $post; |
| 232 | 236 | } elseif ($post["type"] === "shop_order") { |
| 233 | 237 | $event_data["order"] = $post; |
| 234 | 238 | } else { |
| @@ -365,9 +369,11 @@ | ||
| 365 | 369 | $data = array(); |
| 366 | 370 | if (!empty($plugins) && defined('WP_PLUGIN_DIR')) { |
| 367 | 371 | foreach ($plugins as $plugin) { |
| 368 | 372 | $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin); |
| 369 | - $install_data = array('title' => $plugin_data['Name'], 'version' => $plugin_data['Version']); | |
| 373 | + $title = isset($plugin_data['Name']) ? $plugin_data['Name'] : ''; | |
| 374 | + $version = isset($plugin_data['Version']) ? $plugin_data['Version'] : ''; | |
| 375 | + $install_data = array('title' => $title, 'version' => $version); | |
| 370 | 376 | array_push($data, $install_data); |
| 371 | 377 | } |
| 372 | 378 | } |
| 373 | 379 | return $data; |
| @@ -377,9 +383,11 @@ | ||
| 377 | 383 | $data = array(); |
| 378 | 384 | if (!empty($themes)) { |
| 379 | 385 | foreach ($themes as $theme) { |
| 380 | 386 | $theme_data = wp_get_theme($theme); |
| 381 | - $install_data = array('title' => $theme_data['Name'], 'version' => $theme_data['Version']); | |
| 387 | + $title = isset($theme_data['Name']) ? $theme_data['Name'] : ''; | |
| 388 | + $version = isset($theme_data['Version']) ? $theme_data['Version'] : ''; | |
| 389 | + $install_data = array('title' => $title, 'version' => $version); | |
| 382 | 390 | array_push($data, $install_data); |
| 383 | 391 | } |
| 384 | 392 | } |
| 385 | 393 | return $data; |
| @@ -388,9 +396,11 @@ | ||
| 388 | 396 | function get_plugin_install_data($upgrader) { |
| 389 | 397 | $data = array(); |
| 390 | 398 | if ($upgrader->bulk != "1") { |
| 391 | 399 | $plugin_data = $upgrader->new_plugin_data; |
| 392 | - $install_data = array('title' => $plugin_data['Name'], 'version' => $plugin_data['Version']); | |
| 400 | + $title = isset($plugin_data['Name']) ? $plugin_data['Name'] : ''; | |
| 401 | + $version = isset($plugin_data['Version']) ? $plugin_data['Version'] : ''; | |
| 402 | + $install_data = array('title' => $title, 'version' => $version); | |
| 393 | 403 | array_push($data, $install_data); |
| 394 | 404 | } |
| 395 | 405 | return $data; |
| 396 | 406 | } |
| @@ -397,9 +407,11 @@ | ||
| 397 | 407 | |
| 398 | 408 | function get_theme_install_data($upgrader) { |
| 399 | 409 | $data = array(); |
| 400 | 410 | $theme_data = $upgrader->new_theme_data; |
| 401 | - $install_data = array('title' => $theme_data['Name'], 'version' => $theme_data['Version']); | |
| 411 | + $title = isset($theme_data['Name']) ? $theme_data['Name'] : ''; | |
| 412 | + $version = isset($theme_data['Version']) ? $theme_data['Version'] : ''; | |
| 413 | + $install_data = array('title' => $title, 'version' => $version); | |
| 402 | 414 | array_push($data, $install_data); |
| 403 | 415 | return $data; |
| 404 | 416 | } |
| 405 | 417 | |
| @@ -438,15 +450,17 @@ | ||
| 438 | 450 | } |
| 439 | 451 | |
| 440 | 452 | function upgrade_handler($upgrader, $data) { |
| 441 | 453 | $event_data = array(); |
| 442 | - if ($data['action'] === 'update') { | |
| 443 | - if ('core' === $data['type']) { | |
| 444 | - return; | |
| 454 | + if (isset($data['action'])) { | |
| 455 | + if ($data['action'] === 'update') { | |
| 456 | + if ('core' === $data['type']) { | |
| 457 | + return; | |
| 458 | + } | |
| 459 | + $event_data = $this->get_update_data($data); | |
| 460 | + } else if ($data['action'] === 'install') { | |
| 461 | + $event_data = $this->get_install_data($upgrader, $data); | |
| 445 | 462 | } |
| 446 | - $event_data = $this->get_update_data($data); | |
| 447 | - } else if ($data['action'] === 'install') { | |
| 448 | - $event_data = $this->get_install_data($upgrader, $data); | |
| 449 | 463 | } |
| 450 | 464 | $this->add_activity($event_data); |
| 451 | 465 | } |
| 452 | 466 | |