PluginProbe
ManageWP Worker / 3.9.16
ManageWP Worker v3.9.16
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / stats.class.php

stats.class.php in ManageWP Worker 3.9.16, at stats.class.php

764 lines 29.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*************************************************************
3 *
4 * stats.class.php
5 *
6 * Get Site Stats
7 *
8 *
9 * Copyright (c) 2011 Prelovac Media
10 * www.prelovac.com
11 **************************************************************/
12
13
14 class MMB_Stats extends MMB_Core
15 {
16 function __construct()
17 {
18 parent::__construct();
19 }
20
21 /*************************************************************
22 * FACADE functions
23 * (functions to be called after a remote call from Master)
24 **************************************************************/
25
26 function get_core_update($stats, $options = array())
27 {
28 global $wp_version;
29
30 if (isset($options['core']) && $options['core']) {
31 $core = $this->mmb_get_transient('update_core');
32 if (isset($core->updates) && !empty($core->updates)) {
33 $current_transient = $core->updates[0];
34 if ($current_transient->response == "development" || version_compare($wp_version, $current_transient->current, '<')) {
35 $current_transient->current_version = $wp_version;
36 $stats['core_updates'] = $current_transient;
37 } else
38 $stats['core_updates'] = false;
39 } else
40 $stats['core_updates'] = false;
41 }
42
43 return $stats;
44 }
45
46 function get_hit_counter($stats, $options = array())
47 {
48 $mmb_user_hits = get_option('user_hit_count');
49 if (is_array($mmb_user_hits)) {
50 end($mmb_user_hits);
51 $last_key_date = key($mmb_user_hits);
52 $current_date = date('Y-m-d');
53 if ($last_key_date != $current_date)
54 $this->set_hit_count(true);
55 }
56 $stats['hit_counter'] = get_option('user_hit_count');
57
58 return $stats;
59 }
60
61 function get_comments($stats, $options = array())
62 {
63 $nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
64 $trimlen = isset($options['trimcontent']) ? (int) $options['trimcontent'] : 200;
65
66 if ($nposts) {
67 $comments = get_comments('status=hold&number=' . $nposts);
68 if (!empty($comments)) {
69 foreach ($comments as &$comment) {
70 $commented_post = get_post($comment->comment_post_ID);
71 $comment->post_title = $commented_post->post_title;
72 $comment->comment_content = $this->trim_content($comment->comment_content, $trimlen);
73 unset($comment->comment_author_url);
74 unset($comment->comment_author_email);
75 unset($comment->comment_author_IP);
76 unset($comment->comment_date_gmt);
77 unset($comment->comment_karma);
78 unset($comment->comment_agent);
79 unset($comment->comment_type);
80 unset($comment->comment_parent);
81 unset($comment->user_id);
82 }
83 $stats['comments']['pending'] = $comments;
84 }
85
86 $comments = get_comments('status=approve&number=' . $nposts);
87 if (!empty($comments)) {
88 foreach ($comments as &$comment) {
89 $commented_post = get_post($comment->comment_post_ID);
90 $comment->post_title = $commented_post->post_title;
91 $comment->comment_content = $this->trim_content($comment->comment_content, $trimlen);
92 unset($comment->comment_author_url);
93 unset($comment->comment_author_email);
94 unset($comment->comment_author_IP);
95 unset($comment->comment_date_gmt);
96 unset($comment->comment_karma);
97 unset($comment->comment_agent);
98 unset($comment->comment_type);
99 unset($comment->comment_parent);
100 unset($comment->user_id);
101 }
102 $stats['comments']['approved'] = $comments;
103 }
104 }
105 return $stats;
106 }
107
108 function get_posts($stats, $options = array())
109 {
110 $nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
111
112 if ($nposts) {
113 $posts = get_posts('post_status=publish&numberposts=' . $nposts . '&orderby=post_date&order=desc');
114 $recent_posts = array();
115 if (!empty($posts)) {
116 foreach ($posts as $id => $recent_post) {
117 $recent = new stdClass();
118 $recent->post_permalink = get_permalink($recent_post->ID);
119 $recent->ID = $recent_post->ID;
120 $recent->post_date = $recent_post->post_date;
121 $recent->post_title = $recent_post->post_title;
122 $recent->comment_count = (int) $recent_post->comment_count;
123 $recent_posts[] = $recent;
124 }
125 }
126
127 $posts = get_pages('post_status=publish&numberposts=' . $nposts . '&orderby=post_date&order=desc');
128 $recent_pages_published = array();
129 if (!empty($posts)) {
130 foreach ((array) $posts as $id => $recent_page_published) {
131 $recent = new stdClass();
132 $recent->post_permalink = get_permalink($recent_page_published->ID);
133
134 $recent->ID = $recent_page_published->ID;
135 $recent->post_date = $recent_page_published->post_date;
136 $recent->post_title = $recent_page_published->post_title;
137
138 $recent_posts[] = $recent;
139 }
140 }
141 if (!empty($recent_posts)) {
142 usort($recent_posts, array(
143 $this,
144 'cmp_posts_worker'
145 ));
146 $stats['posts'] = array_slice($recent_posts, 0, $nposts);
147 }
148 }
149 return $stats;
150 }
151
152 function get_drafts($stats, $options = array())
153 {
154 $nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
155
156 if ($nposts) {
157 $drafts = get_posts('post_status=draft&numberposts=' . $nposts . '&orderby=post_date&order=desc');
158 $recent_drafts = array();
159 if (!empty($drafts)) {
160 foreach ($drafts as $id => $recent_draft) {
161 $recent = new stdClass();
162 $recent->post_permalink = get_permalink($recent_draft->ID);
163 $recent->ID = $recent_draft->ID;
164 $recent->post_date = $recent_draft->post_date;
165 $recent->post_title = $recent_draft->post_title;
166
167 $recent_drafts[] = $recent;
168 }
169 }
170 $drafts = get_pages('post_status=draft&numberposts=' . $nposts . '&orderby=post_date&order=desc');
171 $recent_pages_drafts = array();
172 if (!empty($drafts)) {
173 foreach ((array) $drafts as $id => $recent_pages_draft) {
174 $recent = new stdClass();
175 $recent->post_permalink = get_permalink($recent_pages_draft->ID);
176 $recent->ID = $recent_pages_draft->ID;
177 $recent->post_date = $recent_pages_draft->post_date;
178 $recent->post_title = $recent_pages_draft->post_title;
179
180 $recent_drafts[] = $recent;
181 }
182 }
183 if (!empty($recent_drafts)) {
184 usort($recent_drafts, array(
185 $this,
186 'cmp_posts_worker'
187 ));
188 $stats['drafts'] = array_slice($recent_drafts, 0, $nposts);
189 }
190 }
191 return $stats;
192 }
193
194 function get_scheduled($stats, $options = array())
195 {
196 $nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
197
198 if ($nposts) {
199 $scheduled = get_posts('post_status=future&numberposts=' . $nposts . '&orderby=post_date&order=desc');
200 $scheduled_posts = array();
201 if (!empty($scheduled)) {
202 foreach ($scheduled as $id => $scheduled) {
203 $recent = new stdClass();
204 $recent->post_permalink = get_permalink($scheduled->ID);
205 $recent->ID = $scheduled->ID;
206 $recent->post_date = $scheduled->post_date;
207 $recent->post_title = $scheduled->post_title;
208 $scheduled_posts[] = $recent;
209 }
210 }
211 $scheduled = get_pages('post_status=future&numberposts=' . $nposts . '&orderby=post_date&order=desc');
212 $recent_pages_drafts = array();
213 if (!empty($scheduled)) {
214 foreach ((array) $scheduled as $id => $scheduled) {
215 $recent = new stdClass();
216 $recent->post_permalink = get_permalink($scheduled->ID);
217 $recent->ID = $scheduled->ID;
218 $recent->post_date = $scheduled->post_date;
219 $recent->post_title = $scheduled->post_title;
220
221 $scheduled_posts[] = $recent;
222 }
223 }
224 if (!empty($scheduled_posts)) {
225 usort($scheduled_posts, array(
226 $this,
227 'cmp_posts_worker'
228 ));
229 $stats['scheduled'] = array_slice($scheduled_posts, 0, $nposts);
230 }
231 }
232 return $stats;
233 }
234
235 function get_backups($stats, $options = array())
236 {
237 $stats['mwp_backups'] = $this->get_backup_instance()->get_backup_stats();
238 $stats['mwp_next_backups'] = $this->get_backup_instance()->get_next_schedules();
239
240 return $stats;
241 }
242
243 function get_backup_req($stats = array(), $options = array())
244 {
245 $stats['mwp_backups'] = $this->get_backup_instance()->get_backup_stats();
246 $stats['mwp_next_backups'] = $this->get_backup_instance()->get_next_schedules();
247 $stats['mwp_backup_req'] = $this->get_backup_instance()->check_backup_compat();
248
249 return $stats;
250 }
251
252 function get_updates($stats, $options = array())
253 {
254 $upgrades = false;
255 $premium = array();
256 if (isset($options['premium']) && $options['premium']) {
257 $premium_updates = array();
258 $upgrades = apply_filters('mwp_premium_update_notification', $premium_updates);
259 if (!empty($upgrades)) {
260 foreach( $upgrades as $data ){
261 if( isset($data['Name']) )
262 $premium[] = $data['Name'];
263 }
264 $stats['premium_updates'] = $upgrades;
265 $upgrades = false;
266 }
267 }
268 if (isset($options['themes']) && $options['themes']) {
269 $this->get_installer_instance();
270 $upgrades = $this->installer_instance->get_upgradable_themes( $premium );
271 if (!empty($upgrades)) {
272 $stats['upgradable_themes'] = $upgrades;
273 $upgrades = false;
274 }
275 }
276
277 if (isset($options['plugins']) && $options['plugins']) {
278 $this->get_installer_instance();
279 $upgrades = $this->installer_instance->get_upgradable_plugins( $premium );
280 if (!empty($upgrades)) {
281 $stats['upgradable_plugins'] = $upgrades;
282 $upgrades = false;
283 }
284 }
285
286 return $stats;
287 }
288
289 function get_errors($stats, $options = array())
290 {
291 $period = isset($options['days']) ? (int) $options['days'] * 86400 : 86400;
292 $maxerrors = isset($options['max']) ? (int) $options['max'] : 20;
293 $errors = array();
294 if (isset($options['get']) && $options['get'] == true) {
295 if (function_exists('ini_get')) {
296 $logpath = ini_get('error_log');
297 if (!empty($logpath) && file_exists($logpath)) {
298 $logfile = @fopen($logpath, 'r');
299 if ($logfile && filesize($logpath) > 0) {
300 $maxlines = 1;
301 $linesize = -4096;
302 $lines = array();
303 $line = true;
304 while ($line !== false) {
305 if( fseek($logfile, ($maxlines * $linesize), SEEK_END) !== -1){
306 $maxlines++;
307 if ($line) {
308 $line = fread($logfile, ($linesize * -1)) . $line;
309
310 foreach ((array) preg_split("/(\r|\n|\r\n)/U", $line) as $l) {
311 preg_match('/\[(.*)\]/Ui', $l, $match);
312 if (!empty($match)) {
313 $key = str_replace($match[0], '', $l);
314 if(!isset($errors[$key])){
315 $errors[$key] = 1;
316 } else {
317 $errors[$key] = $errors[$key] + 1;
318 }
319
320 if ((strtotime($match[1]) < ((int) time() - $period)) || count($errors) >= $maxerrors) {
321 $line = false;
322 break;
323 }
324 }
325 }
326 }
327 } else
328 break;
329 }
330 }
331 if (!empty($errors)){
332 $stats['errors'] = $errors;
333 $stats['logpath'] = $logpath;
334 $stats['logsize'] = @filesize($logpath);
335 }
336 }
337 }
338 }
339
340 return $stats;
341 }
342
343 function pre_init_stats($params)
344 {
345 global $_mmb_item_filter;
346
347 include_once(ABSPATH . 'wp-includes/update.php');
348 include_once(ABSPATH . '/wp-admin/includes/update.php');
349
350 $stats = $this->mmb_parse_action_params('pre_init_stats', $params, $this);
351 $num = extract($params);
352
353 if ($refresh == 'transient') {
354 $current = $this->mmb_get_transient('update_core');
355 if (isset($current->last_checked) || get_option('mmb_forcerefresh')) {
356 update_option('mmb_forcerefresh', false);
357 if (time() - $current->last_checked > 14400) {
358 @wp_version_check();
359 @wp_update_plugins();
360 @wp_update_themes();
361 }
362 }
363 }
364
365 global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $wp_version, $wp_local_package;
366
367 $stats['worker_version'] = MMB_WORKER_VERSION;
368 $stats['wordpress_version'] = $wp_version;
369 $stats['wordpress_locale_pckg'] = $wp_local_package;
370 $stats['php_version'] = phpversion();
371 $stats['mysql_version'] = $wpdb->db_version();
372 $stats['wp_multisite'] = $this->mmb_multisite;
373 $stats['network_install'] = $this->network_admin_install;
374
375 if ( !function_exists('get_filesystem_method') )
376 include_once(ABSPATH . 'wp-admin/includes/file.php');
377 $mmode = get_option('mwp_maintenace_mode');
378
379 if( !empty($mmode) && isset($mmode['active']) && $mmode['active'] == true){
380 $stats['maintenance'] = true;
381 }
382 $stats['writable'] = $this->is_server_writable();
383
384 return $stats;
385 }
386
387 function get($params)
388 {
389 global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $_mmb_item_filter;
390
391 include_once(ABSPATH . 'wp-includes/update.php');
392 include_once(ABSPATH . '/wp-admin/includes/update.php');
393
394 $stats = $this->mmb_parse_action_params('get', $params, $this);
395 $update_check = array();
396 $num = extract($params);
397 if ($refresh == 'transient') {
398 $update_check = apply_filters('mwp_premium_update_check', $update_check);
399 if (!empty($update_check)) {
400 foreach ($update_check as $update) {
401 if (is_array($update['callback'])) {
402 $update_result = call_user_func(array(
403 $update['callback'][0],
404 $update['callback'][1]
405 ));
406 } else if (is_string($update['callback'])) {
407 $update_result = call_user_func($update['callback']);
408 }
409 }
410 }
411 }
412
413 if ($this->mmb_multisite) {
414 $stats = $this->get_multisite($stats);
415 }
416
417 $stats = apply_filters('mmb_stats_filter', $stats);
418 return $stats;
419 }
420
421 function get_multisite($stats = array())
422 {
423 global $current_user, $wpdb;
424 $user_blogs = get_blogs_of_user( $current_user->ID );
425 $network_blogs = $wpdb->get_results( $wpdb->prepare("select `blog_id`, `site_id` from `{$wpdb->blogs}`") );
426 if ($this->network_admin_install == '1' && is_super_admin()) {
427 if (!empty($network_blogs)) {
428 $blogs = array();
429 foreach ( $network_blogs as $details) {
430 if($details->site_id == $details->blog_id)
431 continue;
432 else {
433 $data = get_blog_details($details->blog_id);
434 if(in_array($details->blog_id, array_keys($user_blogs)))
435 $stats['network_blogs'][] = $data->siteurl;
436 else {
437 $user = get_users( array( 'blog_id' => $details->blog_id, 'number' => 1) );
438 if( !empty($user) )
439 $stats['other_blogs'][$data->siteurl] = $user[0]->user_login;
440 }
441 }
442 }
443 }
444 }
445 return $stats;
446 }
447
448 function get_comments_stats()
449 {
450 $num_pending_comments = 3;
451 $num_approved_comments = 3;
452 $pending_comments = get_comments('status=hold&number=' . $num_pending_comments);
453 foreach ($pending_comments as &$comment) {
454 $commented_post = get_post($comment->comment_post_ID);
455 $comment->post_title = $commented_post->post_title;
456 }
457 $stats['comments']['pending'] = $pending_comments;
458
459
460 $approved_comments = get_comments('status=approve&number=' . $num_approved_comments);
461 foreach ($approved_comments as &$comment) {
462 $commented_post = get_post($comment->comment_post_ID);
463 $comment->post_title = $commented_post->post_title;
464 }
465 $stats['comments']['approved'] = $approved_comments;
466
467 return $stats;
468 }
469
470 function get_initial_stats()
471 {
472 global $mmb_plugin_dir;
473
474 $stats = array();
475
476 $stats['email'] = get_option('admin_email');
477 $stats['no_openssl'] = $this->get_random_signature();
478 $stats['content_path'] = WP_CONTENT_DIR;
479 $stats['worker_path'] = $mmb_plugin_dir;
480 $stats['worker_version'] = MMB_WORKER_VERSION;
481 $stats['site_title'] = get_bloginfo('name');
482 $stats['site_tagline'] = get_bloginfo('description');
483 $stats['site_home'] = get_option('home');
484 $stats['admin_url'] = admin_url();
485 $stats['wp_multisite'] = $this->mmb_multisite;
486 $stats['network_install'] = $this->network_admin_install;
487
488 if ($this->mmb_multisite) {
489 $details = get_blog_details($this->mmb_multisite);
490 if (isset($details->site_id)) {
491 $details = get_blog_details($details->site_id);
492 if (isset($details->siteurl))
493 $stats['network_parent'] = $details->siteurl;
494 }
495 }
496 if (!function_exists('get_filesystem_method'))
497 include_once(ABSPATH . 'wp-admin/includes/file.php');
498
499 $stats['writable'] = $this->is_server_writable();
500
501 return $stats;
502 }
503
504 function set_hit_count($fix_count = false)
505 {
506 global $mmb_core;
507 if ($fix_count || (!is_admin() && !MMB_Stats::is_bot() && !isset($_GET['doing_wp_cron']))) {
508
509 $date = date('Y-m-d');
510 $user_hit_count = (array) get_option('user_hit_count');
511 if (!$user_hit_count) {
512 $user_hit_count[$date] = 1;
513 update_option('user_hit_count', $user_hit_count);
514 } else {
515 $dated_keys = array_keys($user_hit_count);
516 $last_visit_date = $dated_keys[count($dated_keys) - 1];
517
518 $days = intval((strtotime($date) - strtotime($last_visit_date)) / 60 / 60 / 24);
519
520 if ($days > 1) {
521 $date_to_add = date('Y-m-d', strtotime($last_visit_date));
522
523 for ($i = 1; $i < $days; $i++) {
524 if (count($user_hit_count) > 14) {
525 $shifted = @array_shift($user_hit_count);
526 }
527
528 $next_key = strtotime('+1 day', strtotime($date_to_add));
529 if ($next_key == $date) {
530 break;
531 } else {
532 $user_hit_count[$next_key] = 0;
533 }
534 }
535
536 }
537
538 if (!isset($user_hit_count[$date])) {
539 $user_hit_count[$date] = 0;
540 }
541 if (!$fix_count)
542 $user_hit_count[$date] = ((int) $user_hit_count[$date]) + 1;
543
544 if (count($user_hit_count) > 14) {
545 $shifted = @array_shift($user_hit_count);
546 }
547
548 update_option('user_hit_count', $user_hit_count);
549
550 }
551 }
552 }
553
554 function get_hit_count()
555 {
556 // Check if there are no hits on last key date
557 $mmb_user_hits = get_option('user_hit_count');
558 if (is_array($mmb_user_hits)) {
559 end($mmb_user_hits);
560 $last_key_date = key($mmb_user_hits);
561 $current_date = date('Y-m-d');
562 if ($last_key_date != $curent_date)
563 $this->set_hit_count(true);
564 }
565
566 return get_option('user_hit_count');
567 }
568
569 function is_bot()
570 {
571 $agent = $_SERVER['HTTP_USER_AGENT'];
572
573 if ($agent == '')
574 return false;
575
576 $bot_list = array(
577 "Teoma",
578 "alexa",
579 "froogle",
580 "Gigabot",
581 "inktomi",
582 "looksmart",
583 "URL_Spider_SQL",
584 "Firefly",
585 "NationalDirectory",
586 "Ask Jeeves",
587 "TECNOSEEK",
588 "InfoSeek",
589 "WebFindBot",
590 "girafabot",
591 "crawler",
592 "www.galaxy.com",
593 "Googlebot",
594 "Scooter",
595 "Slurp",
596 "msnbot",
597 "appie",
598 "FAST",
599 "WebBug",
600 "Spade",
601 "ZyBorg",
602 "rabaz",
603 "Baiduspider",
604 "Feedfetcher-Google",
605 "TechnoratiSnoop",
606 "Rankivabot",
607 "Mediapartners-Google",
608 "Sogou web spider",
609 "WebAlta Crawler",
610 "aolserver"
611 );
612
613 foreach ($bot_list as $bot)
614 if (strpos($agent, $bot) !== false)
615 return true;
616
617 return false;
618 }
619
620
621 function set_notifications($params)
622 {
623 if (empty($params))
624 return false;
625
626 extract($params);
627
628 if (!isset($delete)) {
629 $mwp_notifications = array(
630 'plugins' => $plugins,
631 'themes' => $themes,
632 'wp' => $wp,
633 'backups' => $backups,
634 'url' => $url,
635 'notification_key' => $notification_key
636 );
637 update_option('mwp_notifications', $mwp_notifications);
638 } else {
639 delete_option('mwp_notifications');
640 }
641
642 return true;
643
644 }
645
646 //Cron update check for notifications
647 function check_notifications()
648 {
649 global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $wp_version, $wp_local_package;
650
651 $mwp_notifications = get_option('mwp_notifications', true);
652
653 $args = array();
654 $updates = array();
655 $send = 0;
656 if (is_array($mwp_notifications) && $mwp_notifications != false) {
657 include_once(ABSPATH . 'wp-includes/update.php');
658 include_once(ABSPATH . '/wp-admin/includes/update.php');
659 extract($mwp_notifications);
660
661 //Check wordpress core updates
662 if ($wp) {
663 @wp_version_check();
664 if (function_exists('get_core_updates')) {
665 $wp_updates = get_core_updates();
666 if (!empty($wp_updates)) {
667 $current_transient = $wp_updates[0];
668 if ($current_transient->response == "development" || version_compare($wp_version, $current_transient->current, '<')) {
669 $current_transient->current_version = $wp_version;
670 $updates['core_updates'] = $current_transient;
671 } else
672 $updates['core_updates'] = array();
673 } else
674 $updates['core_updates'] = array();
675 }
676 }
677
678 //Check plugin updates
679 if ($plugins) {
680 @wp_update_plugins();
681 $this->get_installer_instance();
682 $updates['upgradable_plugins'] = $this->installer_instance->get_upgradable_plugins();
683 }
684
685 //Check theme updates
686 if ($themes) {
687 @wp_update_themes();
688 $this->get_installer_instance();
689
690 $updates['upgradable_themes'] = $this->installer_instance->get_upgradable_themes();
691 }
692
693 if ($backups) {
694 $this->get_backup_instance();
695 $backups = $this->backup_instance->get_backup_stats();
696 $updates['backups'] = $backups;
697 foreach ($backups as $task_name => $backup_results) {
698 foreach ($backup_results as $k => $backup) {
699 if (isset($backups[$task_name][$k]['server']['file_path'])) {
700 unset($backups[$task_name][$k]['server']['file_path']);
701 }
702 }
703 }
704 $updates['backups'] = $backups;
705 }
706
707
708 if (!empty($updates)) {
709 $args['body']['updates'] = $updates;
710 $args['body']['notification_key'] = $notification_key;
711 $send = 1;
712 }
713
714 }
715
716
717 $alert_data = get_option('mwp_pageview_alerts',true);
718 if(is_array($alert_data) && $alert_data['alert']){
719 $pageviews = get_option('user_hit_count');
720 $args['body']['alerts']['pageviews'] = $pageviews;
721 $args['body']['alerts']['site_id'] = $alert_data['site_id'];
722 if(!isset($url)){
723 $url = $alert_data['url'];
724 }
725 $send = 1;
726 }
727
728 if($send){
729 if (!class_exists('WP_Http')) {
730 include_once(ABSPATH . WPINC . '/class-http.php');
731 }
732 $result = wp_remote_post($url, $args);
733
734 if (is_array($result) && $result['body'] == 'mwp_delete_alert') {
735 delete_option('mwp_pageview_alerts');
736 }
737 }
738
739
740 }
741
742
743 function cmp_posts_worker($a, $b)
744 {
745 return ($a->post_date < $b->post_date);
746 }
747
748 function trim_content($content = '', $length = 200)
749 {
750 if (function_exists('mb_strlen') && function_exists('mb_substr'))
751 $content = (mb_strlen($content) > ($length + 3)) ? mb_substr($content, 0, $length) . '...' : $content;
752 else
753 $content = (strlen($content) > ($length + 3)) ? substr($content, 0, $length) . '...' : $content;
754
755 return $content;
756 }
757
758 function set_alerts($args){
759 extract($args);
760 update_option('mwp_pageview_alerts',array('site_id' => $site_id,'alert' => $alert,'url' => $url));
761 }
762
763 }
764 ?>