PluginProbe
ManageWP Worker / 3.9.15
ManageWP Worker v3.9.15
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.15, at stats.class.php

754 lines 27.9 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
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 $stats['premium_updates'] = $upgrades;
261 $upgrades = false;
262 }
263 }
264 if (isset($options['themes']) && $options['themes']) {
265 $this->get_installer_instance();
266 $upgrades = $this->installer_instance->get_upgradable_themes();
267 if (!empty($upgrades)) {
268 $stats['upgradable_themes'] = $upgrades;
269 $upgrades = false;
270 }
271 }
272
273 if (isset($options['plugins']) && $options['plugins']) {
274 $this->get_installer_instance();
275 $upgrades = $this->installer_instance->get_upgradable_plugins();
276 if (!empty($upgrades)) {
277 $stats['upgradable_plugins'] = $upgrades;
278 $upgrades = false;
279 }
280 }
281
282 return $stats;
283 }
284
285 function get_errors($stats, $options = array())
286 {
287 $period = isset($options['days']) ? (int) $options['days'] * 86400 : 86400;
288 $maxerrors = isset($options['max']) ? (int) $options['max'] : 20;
289 $errors = array();
290 if (isset($options['get']) && $options['get'] == true) {
291 if (function_exists('ini_get')) {
292 $logpath = ini_get('error_log');
293 if (!empty($logpath) && file_exists($logpath)) {
294 $logfile = @fopen($logpath, 'r');
295 if ($logfile && filesize($logpath) > 0) {
296 $maxlines = 1;
297 $linesize = -4096;
298 $lines = array();
299 $line = true;
300 while ($line !== false) {
301 if( fseek($logfile, ($maxlines * $linesize), SEEK_END) !== -1){
302 $maxlines++;
303 if ($line) {
304 $line = fread($logfile, ($linesize * -1)) . $line;
305
306 foreach ((array) preg_split("/(\r|\n|\r\n)/U", $line) as $l) {
307 preg_match('/\[(.*)\]/Ui', $l, $match);
308 if (!empty($match)) {
309 $key = str_replace($match[0], '', $l);
310 if(!isset($errors[$key])){
311 $errors[$key] = 1;
312 } else {
313 $errors[$key] = $errors[$key] + 1;
314 }
315
316 if ((strtotime($match[1]) < ((int) time() - $period)) || count($errors) >= $maxerrors) {
317 $line = false;
318 break;
319 }
320 }
321 }
322 }
323 } else
324 break;
325 }
326 }
327 if (!empty($errors)){
328 $stats['errors'] = $errors;
329 $stats['logpath'] = $logpath;
330 $stats['logsize'] = @filesize($logpath);
331 }
332 }
333 }
334 }
335
336 return $stats;
337 }
338
339 function pre_init_stats($params)
340 {
341 global $_mmb_item_filter;
342
343 include_once(ABSPATH . 'wp-includes/update.php');
344 include_once(ABSPATH . '/wp-admin/includes/update.php');
345
346 $stats = $this->mmb_parse_action_params('pre_init_stats', $params, $this);
347 $num = extract($params);
348
349 if ($refresh == 'transient') {
350 $current = $this->mmb_get_transient('update_core');
351 if (isset($current->last_checked) || get_option('mmb_forcerefresh')) {
352 update_option('mmb_forcerefresh', false);
353 if (time() - $current->last_checked > 14400) {
354 @wp_version_check();
355 @wp_update_plugins();
356 @wp_update_themes();
357 }
358 }
359 }
360
361 global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $wp_version, $wp_local_package;
362
363 $stats['worker_version'] = MMB_WORKER_VERSION;
364 $stats['wordpress_version'] = $wp_version;
365 $stats['wordpress_locale_pckg'] = $wp_local_package;
366 $stats['php_version'] = phpversion();
367 $stats['mysql_version'] = $wpdb->db_version();
368 $stats['wp_multisite'] = $this->mmb_multisite;
369 $stats['network_install'] = $this->network_admin_install;
370 $stats['network_install'] = $this->network_admin_install;
371
372 if ( !function_exists('get_filesystem_method') )
373 include_once(ABSPATH . 'wp-admin/includes/file.php');
374 $mmode = get_option('mwp_maintenace_mode');
375
376 if( !empty($mmode) && isset($mmode['active']) && $mmode['active'] == true){
377 $stats['maintenance'] = true;
378 }
379 $stats['writable'] = $this->is_server_writable();
380
381 return $stats;
382 }
383
384 function get($params)
385 {
386 global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $_mmb_item_filter;
387
388 include_once(ABSPATH . 'wp-includes/update.php');
389 include_once(ABSPATH . '/wp-admin/includes/update.php');
390
391 $stats = $this->mmb_parse_action_params('get', $params, $this);
392 $update_check = array();
393 $num = extract($params);
394 if ($refresh == 'transient') {
395 $update_check = apply_filters('mwp_premium_update_check', $update_check);
396 if (!empty($update_check)) {
397 foreach ($update_check as $update) {
398 if (is_array($update['callback'])) {
399 $update_result = call_user_func(array(
400 $update['callback'][0],
401 $update['callback'][1]
402 ));
403 } else if (is_string($update['callback'])) {
404 $update_result = call_user_func($update['callback']);
405 }
406 }
407 }
408 }
409
410 if ($this->mmb_multisite) {
411 $stats = $this->get_multisite($stats);
412 }
413
414 $stats = apply_filters('mmb_stats_filter', $stats);
415 return $stats;
416 }
417
418 function get_multisite($stats = array())
419 {
420 global $current_user;
421
422 if ($this->network_admin_install == '1' && current_user_can('update_core')) {
423 $user_blogs = get_blogs_of_user($current_user->ID);
424 if (!empty($user_blogs)) {
425 $blogs = array();
426 foreach ($user_blogs as $blog_id => $data) {
427 if ($this->mmb_multisite == $blog_id)
428 continue;
429
430 if (isset($data->siteurl))
431 $blogs[] = $data->siteurl;
432 }
433 if (!empty($blogs))
434 $stats['network_blogs'] = $blogs;
435 }
436 }
437 return $stats;
438 }
439
440 function get_comments_stats()
441 {
442 $num_pending_comments = 3;
443 $num_approved_comments = 3;
444 $pending_comments = get_comments('status=hold&number=' . $num_pending_comments);
445 foreach ($pending_comments as &$comment) {
446 $commented_post = get_post($comment->comment_post_ID);
447 $comment->post_title = $commented_post->post_title;
448 }
449 $stats['comments']['pending'] = $pending_comments;
450
451
452 $approved_comments = get_comments('status=approve&number=' . $num_approved_comments);
453 foreach ($approved_comments as &$comment) {
454 $commented_post = get_post($comment->comment_post_ID);
455 $comment->post_title = $commented_post->post_title;
456 }
457 $stats['comments']['approved'] = $approved_comments;
458
459 return $stats;
460 }
461
462 function get_initial_stats()
463 {
464 global $mmb_plugin_dir;
465
466 $stats = array();
467
468 $stats['email'] = get_option('admin_email');
469 $stats['no_openssl'] = $this->get_random_signature();
470 $stats['content_path'] = WP_CONTENT_DIR;
471 $stats['worker_path'] = $mmb_plugin_dir;
472 $stats['worker_version'] = MMB_WORKER_VERSION;
473 $stats['site_title'] = get_bloginfo('name');
474 $stats['site_tagline'] = get_bloginfo('description');
475 $stats['site_home'] = get_option('home');
476 $stats['admin_url'] = admin_url();
477 $stats['wp_multisite'] = $this->mmb_multisite;
478 $stats['network_install'] = $this->network_admin_install;
479
480 if ($this->mmb_multisite) {
481 $details = get_blog_details($this->mmb_multisite);
482 if (isset($details->site_id)) {
483 $details = get_blog_details($details->site_id);
484 if (isset($details->siteurl))
485 $stats['network_parent'] = $details->siteurl;
486 }
487 }
488 if (!function_exists('get_filesystem_method'))
489 include_once(ABSPATH . 'wp-admin/includes/file.php');
490
491 $stats['writable'] = $this->is_server_writable();
492
493 return $stats;
494 }
495
496 function set_hit_count($fix_count = false)
497 {
498 if ($fix_count || (!is_admin() && !MMB_Stats::is_bot())) {
499 $date = date('Y-m-d');
500 $user_hit_count = (array) get_option('user_hit_count');
501 if (!$user_hit_count) {
502 $user_hit_count[$date] = 1;
503 update_option('user_hit_count', $user_hit_count);
504 } else {
505 $dated_keys = array_keys($user_hit_count);
506 $last_visit_date = $dated_keys[count($dated_keys) - 1];
507
508 $days = intval((strtotime($date) - strtotime($last_visit_date)) / 60 / 60 / 24);
509
510 if ($days > 1) {
511 $date_to_add = date('Y-m-d', strtotime($last_visit_date));
512
513 for ($i = 1; $i < $days; $i++) {
514 if (count($user_hit_count) > 14) {
515 $shifted = @array_shift($user_hit_count);
516 }
517
518 $next_key = strtotime('+1 day', strtotime($date_to_add));
519 if ($next_key == $date) {
520 break;
521 } else {
522 $user_hit_count[$next_key] = 0;
523 }
524 }
525
526 }
527
528 if (!isset($user_hit_count[$date])) {
529 $user_hit_count[$date] = 0;
530 }
531 if (!$fix_count)
532 $user_hit_count[$date] = ((int) $user_hit_count[$date]) + 1;
533
534 if (count($user_hit_count) > 14) {
535 $shifted = @array_shift($user_hit_count);
536 }
537
538 update_option('user_hit_count', $user_hit_count);
539
540 }
541 }
542 }
543
544 function get_hit_count()
545 {
546 // Check if there are no hits on last key date
547 $mmb_user_hits = get_option('user_hit_count');
548 if (is_array($mmb_user_hits)) {
549 end($mmb_user_hits);
550 $last_key_date = key($mmb_user_hits);
551 $current_date = date('Y-m-d');
552 if ($last_key_date != $curent_date)
553 $this->set_hit_count(true);
554 }
555
556 return get_option('user_hit_count');
557 }
558
559 function is_bot()
560 {
561 $agent = $_SERVER['HTTP_USER_AGENT'];
562
563 if ($agent == '')
564 return false;
565
566 $bot_list = array(
567 "Teoma",
568 "alexa",
569 "froogle",
570 "Gigabot",
571 "inktomi",
572 "looksmart",
573 "URL_Spider_SQL",
574 "Firefly",
575 "NationalDirectory",
576 "Ask Jeeves",
577 "TECNOSEEK",
578 "InfoSeek",
579 "WebFindBot",
580 "girafabot",
581 "crawler",
582 "www.galaxy.com",
583 "Googlebot",
584 "Scooter",
585 "Slurp",
586 "msnbot",
587 "appie",
588 "FAST",
589 "WebBug",
590 "Spade",
591 "ZyBorg",
592 "rabaz",
593 "Baiduspider",
594 "Feedfetcher-Google",
595 "TechnoratiSnoop",
596 "Rankivabot",
597 "Mediapartners-Google",
598 "Sogou web spider",
599 "WebAlta Crawler",
600 "aolserver"
601 );
602
603 foreach ($bot_list as $bot)
604 if (strpos($agent, $bot) !== false)
605 return true;
606
607 return false;
608 }
609
610
611 function set_notifications($params)
612 {
613 if (empty($params))
614 return false;
615
616 extract($params);
617
618 if (!isset($delete)) {
619 $mwp_notifications = array(
620 'plugins' => $plugins,
621 'themes' => $themes,
622 'wp' => $wp,
623 'backups' => $backups,
624 'url' => $url,
625 'notification_key' => $notification_key
626 );
627 update_option('mwp_notifications', $mwp_notifications);
628 } else {
629 delete_option('mwp_notifications');
630 }
631
632 return true;
633
634 }
635
636 //Cron update check for notifications
637 function check_notifications()
638 {
639 global $wpdb, $mmb_wp_version, $mmb_plugin_dir, $wp_version, $wp_local_package;
640
641 $mwp_notifications = get_option('mwp_notifications', true);
642
643 $args = array();
644 $updates = array();
645 $send = 0;
646 if (is_array($mwp_notifications) && $mwp_notifications != false) {
647 include_once(ABSPATH . 'wp-includes/update.php');
648 include_once(ABSPATH . '/wp-admin/includes/update.php');
649 extract($mwp_notifications);
650
651 //Check wordpress core updates
652 if ($wp) {
653 @wp_version_check();
654 if (function_exists('get_core_updates')) {
655 $wp_updates = get_core_updates();
656 if (!empty($wp_updates)) {
657 $current_transient = $wp_updates[0];
658 if ($current_transient->response == "development" || version_compare($wp_version, $current_transient->current, '<')) {
659 $current_transient->current_version = $wp_version;
660 $updates['core_updates'] = $current_transient;
661 } else
662 $updates['core_updates'] = array();
663 } else
664 $updates['core_updates'] = array();
665 }
666 }
667
668 //Check plugin updates
669 if ($plugins) {
670 @wp_update_plugins();
671 $this->get_installer_instance();
672 $updates['upgradable_plugins'] = $this->installer_instance->get_upgradable_plugins();
673 }
674
675 //Check theme updates
676 if ($themes) {
677 @wp_update_themes();
678 $this->get_installer_instance();
679
680 $updates['upgradable_themes'] = $this->installer_instance->get_upgradable_themes();
681 }
682
683 if ($backups) {
684 $this->get_backup_instance();
685 $backups = $this->backup_instance->get_backup_stats();
686 $updates['backups'] = $backups;
687 foreach ($backups as $task_name => $backup_results) {
688 foreach ($backup_results as $k => $backup) {
689 if (isset($backups[$task_name][$k]['server']['file_path'])) {
690 unset($backups[$task_name][$k]['server']['file_path']);
691 }
692 }
693 }
694 $updates['backups'] = $backups;
695 }
696
697
698 if (!empty($updates)) {
699 $args['body']['updates'] = $updates;
700 $args['body']['notification_key'] = $notification_key;
701 $send = 1;
702 }
703
704 }
705
706
707 $alert_data = get_option('mwp_pageview_alerts',true);
708 if(is_array($alert_data) && $alert_data['alert']){
709 $pageviews = get_option('user_hit_count');
710 $args['body']['alerts']['pageviews'] = $pageviews;
711 $args['body']['alerts']['site_id'] = $alert_data['site_id'];
712 if(!isset($url)){
713 $url = $alert_data['url'];
714 }
715 $send = 1;
716 }
717
718 if($send){
719 if (!class_exists('WP_Http')) {
720 include_once(ABSPATH . WPINC . '/class-http.php');
721 }
722 $result = wp_remote_post($url, $args);
723
724 if (is_array($result) && $result['body'] == 'mwp_delete_alert') {
725 delete_option('mwp_pageview_alerts');
726 }
727 }
728
729
730 }
731
732
733 function cmp_posts_worker($a, $b)
734 {
735 return ($a->post_date < $b->post_date);
736 }
737
738 function trim_content($content = '', $length = 200)
739 {
740 if (function_exists('mb_strlen') && function_exists('mb_substr'))
741 $content = (mb_strlen($content) > ($length + 3)) ? mb_substr($content, 0, $length) . '...' : $content;
742 else
743 $content = (strlen($content) > ($length + 3)) ? substr($content, 0, $length) . '...' : $content;
744
745 return $content;
746 }
747
748 function set_alerts($args){
749 extract($args);
750 update_option('mwp_pageview_alerts',array('site_id' => $site_id,'alert' => $alert,'url' => $url));
751 }
752
753 }
754 ?>