Пример #1
0
 public static function hookUpdraftplusBackupComplete($delete_jobdata)
 {
     if ($delete_jobdata) {
         $backup_history = get_option('updraft_backup_history', array());
         if (is_array($backup_history) && count($backup_history) > 0) {
             $args = array();
             $args['connector'] = 'updraftplus_backups';
             $args['fields'] = 'with-meta';
             $args['records_per_page'] = 9999;
             $args['orderby'] = 'created';
             $args['order'] = 'desc';
             $items = mainwp_wp_stream_query($args);
             $updraftplus_last_backupdate = 0;
             if (is_array($items) && count($items) > 0) {
                 $record = current($items);
                 $updraftplus_last_backupdate = self::get_record_meta_data($record, 'backup_date');
             }
             foreach ($backup_history as $date => $backup) {
                 if ($date > $updraftplus_last_backupdate) {
                     $message = "";
                     $backup_type = "";
                     if (isset($backup['db'])) {
                         $message .= "database, ";
                         $backup_type .= "database, ";
                     }
                     if (isset($backup['plugins'])) {
                         $message .= "plugins, ";
                         $backup_type .= "plugins, ";
                     }
                     if (isset($backup['themes'])) {
                         $message .= "themes, ";
                         $backup_type .= "themes, ";
                     }
                     $message = rtrim($message, ', ');
                     $message = "Updraftplus backup " . $message . " finished";
                     $backup_type = rtrim($backup_type, ', ');
                     $size = "N/A";
                     if (isset($backup['db-size'])) {
                         $size = $backup['db-size'];
                     } else {
                         if (isset($backup['themes-size'])) {
                             $size = $backup['themes-size'];
                         }
                     }
                     $destination = "";
                     //                                if (isset($backup['service']) && is_array($backup['service'])) {
                     //                                    foreach($backup['service'] as $ser) {
                     //                                        $destination .= $ser . ", ";
                     //                                    }
                     //                                }
                     //                                 $destination = rtrim($destination, ', ');
                     do_action("updraftplus_backup", $destination, $message, __('Finished', 'mainwp-child-reports'), $backup_type, $date);
                 }
             }
         }
     }
 }
Пример #2
0
 public static function gather_updated_items($last_id, $query = array())
 {
     if (false === $last_id) {
         return '';
     }
     $default = array('record_greater_than' => (int) $last_id);
     // Filter default
     $query = wp_parse_args($query, $default);
     // Run query
     $items = mainwp_wp_stream_query($query);
     return $items;
 }
 public function filter_predefined_intervals($intervals)
 {
     $query = mainwp_wp_stream_query(array('order' => 'ASC', 'orderby' => 'created', 'records_per_page' => 1, 'ignore_context' => true));
     $first_stream_item = reset($query);
     if (false === $first_stream_item) {
         return array();
     }
     $first_stream_date = \Carbon\Carbon::parse($first_stream_item->created);
     foreach ($intervals as $key => $interval) {
         if (!isset($interval['start']) || false === $interval['start']) {
             $intervals[$key]['start'] = $interval['start'] = $first_stream_date;
         }
         if (!isset($interval['end']) || false === $interval['end']) {
             $intervals[$key]['end'] = $interval['end'] = \Carbon\Carbon::now();
         }
         if (!is_a($interval['start'], '\\Carbon\\Carbon') || !is_a($interval['end'], '\\Carbon\\Carbon')) {
             unset($intervals[$key]);
             continue;
         }
     }
     return $intervals;
 }
 public function get_stream()
 {
     // Filters
     $allowed_params = array('connector', 'context', 'action', 'author', 'author_role', 'object_id', 'search', 'date', 'date_from', 'date_to', 'record__in', 'blog_id', 'ip');
     $sections = isset($_POST['sections']) ? unserialize(base64_decode($_POST['sections'])) : array();
     if (!is_array($sections)) {
         $sections = array();
     }
     //return $sections;
     $other_tokens = isset($_POST['other_tokens']) ? unserialize(base64_decode($_POST['other_tokens'])) : array();
     if (!is_array($other_tokens)) {
         $other_tokens = array();
     }
     //return $other_tokens;
     unset($_POST['sections']);
     unset($_POST['other_tokens']);
     $args = array();
     foreach ($allowed_params as $param) {
         if (self::$mainwpChildReports) {
             $paramval = mainwp_wp_stream_filter_input(INPUT_POST, $param);
         } else {
             $paramval = wp_stream_filter_input(INPUT_POST, $param);
         }
         if ($paramval || '0' === $paramval) {
             $args[$param] = $paramval;
         }
     }
     foreach ($args as $arg => $val) {
         if (!in_array($arg, $allowed_params)) {
             unset($args[$arg]);
         }
     }
     $args['action__not_in'] = array('login');
     $args['fields'] = 'with-meta';
     if (isset($args['date_from'])) {
         $args['date_from'] = date("Y-m-d H:i:s", $args['date_from']);
     }
     if (isset($args['date_to'])) {
         $args['date_to'] = date("Y-m-d H:i:s", $args['date_to']);
     }
     $args['records_per_page'] = 9999;
     //        error_log(print_r($args, true));
     if (self::$mainwpChildReports) {
         $records = mainwp_wp_stream_query($args);
     } else {
         $records = wp_stream_query($args);
     }
     //        if (count($records) > 0)
     //            error_log(print_r($records, true));
     //        else
     //            error_log("==============");
     if (!is_array($records)) {
         $records = array();
     }
     //return $records;
     //$other_tokens_data = $this->get_other_tokens_data($records, $other_tokens);
     if (isset($other_tokens['header']) && is_array($other_tokens['header'])) {
         $other_tokens_data['header'] = $this->get_other_tokens_data($records, $other_tokens['header']);
     }
     if (isset($other_tokens['body']) && is_array($other_tokens['body'])) {
         $other_tokens_data['body'] = $this->get_other_tokens_data($records, $other_tokens['body']);
     }
     if (isset($other_tokens['footer']) && is_array($other_tokens['footer'])) {
         $other_tokens_data['footer'] = $this->get_other_tokens_data($records, $other_tokens['footer']);
     }
     $sections_data = array();
     if (isset($sections['header']) && is_array($sections['header']) && !empty($sections['header'])) {
         foreach ($sections['header']['section_token'] as $index => $sec) {
             $tokens = $sections['header']['section_content_tokens'][$index];
             $sections_data['header'][$index] = $this->get_section_loop_data($records, $tokens, $sec);
         }
     }
     if (isset($sections['body']) && is_array($sections['body']) && !empty($sections['body'])) {
         foreach ($sections['body']['section_token'] as $index => $sec) {
             $tokens = $sections['body']['section_content_tokens'][$index];
             $sections_data['body'][$index] = $this->get_section_loop_data($records, $tokens, $sec);
         }
     }
     if (isset($sections['footer']) && is_array($sections['footer']) && !empty($sections['footer'])) {
         foreach ($sections['footer'] as $index => $sec) {
             $tokens = $sections['footer']['section_content_tokens'][$index];
             $sections_data['footer'][$index] = $this->get_section_loop_data($records, $tokens, $sec);
         }
     }
     $information = array('other_tokens_data' => $other_tokens_data, 'sections_data' => $sections_data);
     return $information;
 }
 public function get_stream()
 {
     // Filters
     $allowed_params = array('connector', 'context', 'action', 'author', 'author_role', 'object_id', 'search', 'date', 'date_from', 'date_to', 'record__in', 'blog_id', 'ip');
     $sections = isset($_POST['sections']) ? maybe_unserialize(base64_decode($_POST['sections'])) : array();
     if (!is_array($sections)) {
         $sections = array();
     }
     //return $sections;
     $other_tokens = isset($_POST['other_tokens']) ? maybe_unserialize(base64_decode($_POST['other_tokens'])) : array();
     if (!is_array($other_tokens)) {
         $other_tokens = array();
     }
     //return $other_tokens;
     unset($_POST['sections']);
     unset($_POST['other_tokens']);
     $args = array();
     foreach ($allowed_params as $param) {
         if (self::$mainwpChildReports) {
             $paramval = mainwp_wp_stream_filter_input(INPUT_POST, $param);
         } else {
             $paramval = wp_stream_filter_input(INPUT_POST, $param);
         }
         if ($paramval || '0' === $paramval) {
             $args[$param] = $paramval;
         }
     }
     foreach ($args as $arg => $val) {
         if (!in_array($arg, $allowed_params)) {
             unset($args[$arg]);
         }
     }
     // to fix bug
     $exclude_connector_posts = true;
     if (isset($sections['body']) && isset($sections['body']['section_token']) && is_array($sections['body']['section_token'])) {
         foreach ($sections['body']['section_token'] as $sec) {
             if (strpos($sec, "[section.posts") !== false) {
                 $exclude_connector_posts = false;
                 break;
             }
         }
     }
     if ($exclude_connector_posts) {
         if (isset($sections['header']) && isset($sections['header']['section_token']) && is_array($sections['header']['section_token'])) {
             foreach ($sections['header']['section_token'] as $sec) {
                 if (strpos($sec, "[section.posts") !== false) {
                     $exclude_connector_posts = false;
                     break;
                 }
             }
         }
     }
     if ($exclude_connector_posts) {
         if (isset($sections['footer']) && isset($sections['footer']['section_token']) && is_array($sections['footer']['section_token'])) {
             foreach ($sections['footer']['section_token'] as $sec) {
                 if (strpos($sec, "[section.posts") !== false) {
                     $exclude_connector_posts = false;
                     break;
                 }
             }
         }
     }
     if ($exclude_connector_posts) {
         if (isset($other_tokens['body']) && is_array($other_tokens['body'])) {
             foreach ($other_tokens['body'] as $sec) {
                 if (strpos($sec, "[post.") !== false) {
                     $exclude_connector_posts = false;
                     break;
                 }
             }
         }
     }
     if ($exclude_connector_posts) {
         if (isset($other_tokens['header']) && is_array($other_tokens['header'])) {
             foreach ($other_tokens['header'] as $sec) {
                 if (strpos($sec, "[post.") !== false) {
                     $exclude_connector_posts = false;
                     break;
                 }
             }
         }
     }
     if ($exclude_connector_posts) {
         if (isset($other_tokens['footer']) && is_array($other_tokens['footer'])) {
             foreach ($other_tokens['footer'] as $sec) {
                 if (strpos($sec, "[post.") !== false) {
                     $exclude_connector_posts = false;
                     break;
                 }
             }
         }
     }
     if ($exclude_connector_posts) {
         $args['connector__not_in'] = array('posts');
     }
     ///// end fix /////
     $args['action__not_in'] = array('login');
     // fix for Stream 3
     if (3 !== self::$streamVersionNumber) {
         $args['fields'] = 'with-meta';
         if (isset($args['date_from'])) {
             $args['date_from'] = date('Y-m-d H:i:s', $args['date_from']);
         }
         if (isset($args['date_to'])) {
             $args['date_to'] = date('Y-m-d H:i:s', $args['date_to']);
         }
     } else {
         if (isset($args['date_from'])) {
             $args['date_from'] = date('Y-m-d', $args['date_from']);
         }
         if (isset($args['date_to'])) {
             $args['date_to'] = date('Y-m-d', $args['date_to']);
         }
     }
     $args['records_per_page'] = 9999;
     //        error_log(print_r($args, true));
     if (self::$mainwpChildReports) {
         $records = mainwp_wp_stream_query($args);
     } else {
         if (149 === self::$streamVersionNumber) {
             $records = wp_stream_query($args);
         } else {
             if (3 === self::$streamVersionNumber) {
                 $records = wp_stream_get_instance()->db->query->query($args);
             }
         }
     }
     if (!is_array($records)) {
         $records = array();
     }
     //return $records;
     //$other_tokens_data = $this->get_other_tokens_data($records, $other_tokens);
     if (isset($other_tokens['header']) && is_array($other_tokens['header'])) {
         $other_tokens_data['header'] = $this->get_other_tokens_data($records, $other_tokens['header']);
     }
     if (isset($other_tokens['body']) && is_array($other_tokens['body'])) {
         $other_tokens_data['body'] = $this->get_other_tokens_data($records, $other_tokens['body']);
     }
     if (isset($other_tokens['footer']) && is_array($other_tokens['footer'])) {
         $other_tokens_data['footer'] = $this->get_other_tokens_data($records, $other_tokens['footer']);
     }
     $sections_data = array();
     if (isset($sections['header']) && is_array($sections['header']) && !empty($sections['header'])) {
         foreach ($sections['header']['section_token'] as $index => $sec) {
             $tokens = $sections['header']['section_content_tokens'][$index];
             $sections_data['header'][$index] = $this->get_section_loop_data($records, $tokens, $sec);
         }
     }
     if (isset($sections['body']) && is_array($sections['body']) && !empty($sections['body'])) {
         foreach ($sections['body']['section_token'] as $index => $sec) {
             $tokens = $sections['body']['section_content_tokens'][$index];
             $sections_data['body'][$index] = $this->get_section_loop_data($records, $tokens, $sec);
         }
     }
     if (isset($sections['footer']) && is_array($sections['footer']) && !empty($sections['footer'])) {
         foreach ($sections['footer'] as $index => $sec) {
             $tokens = $sections['footer']['section_content_tokens'][$index];
             $sections_data['footer'][$index] = $this->get_section_loop_data($records, $tokens, $sec);
         }
     }
     $information = array('other_tokens_data' => $other_tokens_data, 'sections_data' => $sections_data);
     return $information;
 }