Beispiel #1
0
 public function process()
 {
     list($success, $form) = $this->process_form(array('feed_server_ids'));
     $search = false;
     if ($success) {
         if (array_key_exists('feed_search', $this->request->post)) {
             $terms = $this->session->get('search_terms', false);
             $since = $this->session->get('search_since', DEFAULT_SINCE);
             $fld = $this->session->get('search_fld', 'TEXT');
             $search = true;
         } else {
             $terms = false;
         }
         $ids = explode(',', $form['feed_server_ids']);
         $res = array();
         $unread_only = false;
         $login_time = $this->session->get('login_time', false);
         if ($login_time) {
             $this->out('login_time', $login_time);
         }
         if ($this->get('list_path') == 'unread') {
             $limit = $this->user_config->get('unread_per_source_setting', DEFAULT_PER_SOURCE);
             $date = process_since_argument($this->user_config->get('unread_since_setting', DEFAULT_SINCE));
             $unread_only = true;
             $cutoff_timestamp = strtotime($date);
             if ($login_time && $login_time > $cutoff_timestamp) {
                 $cutoff_timestamp = $login_time;
             }
         } elseif ($this->get('list_path') == 'combined_inbox') {
             $limit = $this->user_config->get('all_per_source_setting', DEFAULT_PER_SOURCE);
             $date = process_since_argument($this->user_config->get('all_since_setting', DEFAULT_SINCE));
             $cutoff_timestamp = strtotime($date);
         } else {
             $limit = $this->user_config->get('feed_limit_setting', DEFAULT_PER_SOURCE);
             $date = process_since_argument($this->user_config->get('feed_since_setting', DEFAULT_SINCE));
             $cutoff_timestamp = strtotime($date);
         }
         if (!$search || $search && $terms) {
             foreach ($ids as $id) {
                 $feed_data = Hm_Feed_List::dump($id);
                 if ($feed_data) {
                     $feed = is_feed($feed_data['server'], $limit);
                     if ($feed && $feed->parsed_data) {
                         foreach ($feed->parsed_data as $item) {
                             if (!array_key_exists('guid', $item)) {
                                 continue;
                             }
                             if (!Hm_Feed_Uid_Cache::is_unread(md5($item['guid']))) {
                                 if (isset($item['pubdate']) && strtotime($item['pubdate']) < $cutoff_timestamp) {
                                     continue;
                                 } elseif (isset($item['dc:date']) && strtotime($item['dc:date']) < $cutoff_timestamp) {
                                     continue;
                                 }
                                 if (isset($item['guid']) && $unread_only && Hm_Feed_Uid_Cache::is_read(md5($item['guid']))) {
                                     continue;
                                 }
                             }
                             if ($terms && !search_feed_item($item, $terms, $since, $fld)) {
                                 continue;
                             } else {
                                 //Hm_Page_Cache::add($id.'_'.md5($item['guid']), $item, true);
                                 $item['server_id'] = $id;
                                 $item['server_name'] = $feed_data['name'];
                                 $res[] = $item;
                             }
                         }
                     }
                 }
             }
         }
         $this->out('feed_list_data', $res);
         if (isset($this->request->get['list_path'])) {
             $this->out('feed_list_parent', $this->request->get['list_path']);
         } elseif (isset($this->request->get['page']) && $this->request->get['page'] == 'search') {
             $this->out('feed_list_parent', 'search');
         }
         $this->out('feed_server_ids', $form['feed_server_ids']);
     }
 }
Beispiel #2
0
/**
 * Sanitize a "since" setting value for combined pages
 * @param string $val value to check
 * @return sanitized value
 */
function since_setting_callback($val)
{
    return process_since_argument($val, true);
}
Beispiel #3
0
 /**
  * Connect to a POP3 server and fetch message headers
  * @todo see if this can be broken up into smaller functions
  */
 public function process()
 {
     $msgs = array();
     list($success, $form) = $this->process_form(array('pop3_server_id'));
     if ($success) {
         $unread_only = false;
         $login_time = $this->session->get('login_time', false);
         if ($login_time) {
             $this->out('login_time', $login_time);
         }
         $terms = false;
         if (array_key_exists('pop3_search', $this->request->post)) {
             $limit = $this->user_config->get('pop3_limit', DEFAULT_PER_SOURCE);
             $terms = $this->session->get('search_terms', false);
             $since = $this->session->get('search_since', DEFAULT_SINCE);
             $fld = $this->session->get('search_fld', 'TEXT');
             $date = process_since_argument($since);
             $cutoff_timestamp = strtotime($date);
         } elseif ($this->get('list_path') == 'unread') {
             $limit = $this->user_config->get('unread_per_source_setting', DEFAULT_PER_SOURCE);
             $date = process_since_argument($this->user_config->get('unread_since_setting', DEFAULT_SINCE));
             $unread_only = true;
             $cutoff_timestamp = strtotime($date);
             if ($login_time && $login_time > $cutoff_timestamp) {
                 $cutoff_timestamp = $login_time;
             }
         } elseif ($this->get('list_path') == 'email') {
             $limit = $this->user_config->get('all_email_per_source_setting', DEFAULT_PER_SOURCE);
             $date = process_since_argument($this->user_config->get('all_email_since_setting', DEFAULT_SINCE));
             $cutoff_timestamp = strtotime($date);
         } elseif ($this->get('list_path') == 'combined_inbox') {
             $limit = $this->user_config->get('all_per_source_setting', DEFAULT_PER_SOURCE);
             $date = process_since_argument($this->user_config->get('all_since_setting', DEFAULT_SINCE));
             $cutoff_timestamp = strtotime($date);
         } else {
             $limit = $this->user_config->get('pop3_limit', DEFAULT_PER_SOURCE);
             $date = process_since_argument($this->user_config->get('pop3_since', DEFAULT_SINCE));
             $cutoff_timestamp = strtotime($date);
         }
         $pop3 = Hm_POP3_List::connect($form['pop3_server_id'], false);
         $details = Hm_POP3_List::dump($form['pop3_server_id']);
         $path = sprintf("pop3_%d", $form['pop3_server_id']);
         if ($pop3->state == 'authed') {
             $this->out('pop3_mailbox_page_path', $path);
             $list = array_slice(array_reverse(array_unique(array_keys($pop3->mlist()))), 0, $limit);
             foreach ($list as $id) {
                 $msg_headers = $pop3->msg_headers($id);
                 if (!empty($msg_headers)) {
                     if (isset($msg_headers['date'])) {
                         if (!Hm_POP3_Uid_Cache::is_unread(sprintf('pop3_%d_%d', $form['pop3_server_id'], $id)) && strtotime($msg_headers['date']) < $cutoff_timestamp) {
                             continue;
                         }
                     }
                     if ($unread_only && Hm_POP3_Uid_Cache::is_read(sprintf('pop3_%d_%d', $form['pop3_server_id'], $id))) {
                         continue;
                     }
                     if ($terms) {
                         $body = implode('', $pop3->retr_full($id));
                         if (!search_pop3_msg($body, $msg_headers, $terms, $fld)) {
                             continue;
                         }
                     }
                     $msg_headers['server_name'] = $details['name'];
                     $msg_headers['server_id'] = $form['pop3_server_id'];
                     $msgs[$id] = $msg_headers;
                 }
             }
             $this->out('pop3_mailbox_page', $msgs);
             $this->out('pop3_server_id', $form['pop3_server_id']);
         }
     }
 }
Beispiel #4
0
 public function process()
 {
     list($success, $form) = $this->process_form(array('github_repo'));
     if ($success) {
         $login_time = $this->session->get('login_time', false);
         if ($login_time) {
             $this->out('login_time', $login_time);
         }
         if (array_key_exists('list_path', $this->request->get)) {
             if (in_array($this->request->get['list_path'], array('combined_inbox', 'unread'), true)) {
                 $this->out('list_parent', $this->request->get['list_path']);
             }
         }
         Hm_Github_Uid_Cache::load($this->session->get('github_read_uids', array()));
         $details = $this->user_config->get('github_connect_details');
         $repos = $this->user_config->get('github_repos');
         if (in_array($form['github_repo'], $repos, true) && $details) {
             $url = sprintf('https://api.github.com/repos/%s/events?page=1&per_page=25', $form['github_repo']);
             $this->out('github_data', github_fetch_content($details, $url));
             $this->out('github_data_source', $form['github_repo']);
             $this->out('github_data_source_id', array_search($form['github_repo'], $repos, true));
         }
         if (array_key_exists('list_path', $this->request->get)) {
             if ($this->request->get['list_path'] == 'unread') {
                 $this->out('github_list_since', process_since_argument($this->user_config->get('unread_since_setting', DEFAULT_SINCE)));
             }
             $this->out('list_path', $this->request->get['list_path'], false);
         } else {
             $this->out('list_path', false, false);
         }
         if (array_key_exists('github_unread', $this->request->post) && $this->request->post['github_unread']) {
             $this->out('github_unread', true);
         }
     }
 }
Beispiel #5
0
 public function process()
 {
     $res = array();
     $wp_details = $this->user_config->get('wp_connect_details', array());
     $details = wp_get_notifications($wp_details);
     if (array_key_exists('notes', $details)) {
         $res = $details['notes'];
     }
     $this->out('wp_notice_data', $res);
     if (array_key_exists('list_path', $this->request->get) && $this->request->get['list_path'] == 'unread') {
         $this->out('wp_list_since', process_since_argument($this->user_config->get('unread_since_setting', DEFAULT_SINCE)));
     }
 }
Beispiel #6
0
 /**
  * validate and set search tems in the session
  */
 public function process()
 {
     if (array_key_exists('search_terms', $this->request->get) && $this->request->get['search_terms']) {
         $this->out('run_search', 1, false);
         $this->session->set('search_terms', validate_search_terms($this->request->get['search_terms']));
     }
     if (array_key_exists('search_since', $this->request->get)) {
         $this->session->set('search_since', process_since_argument($this->request->get['search_since'], true));
     }
     if (array_key_exists('search_fld', $this->request->get)) {
         $this->session->set('search_fld', validate_search_fld($this->request->get['search_fld']));
     }
     $this->out('search_since', $this->session->get('search_since', DEFAULT_SINCE));
     $this->out('search_terms', $this->session->get('search_terms', ''));
     $this->out('search_fld', $this->session->get('search_fld', DEFAULT_SEARCH_FLD));
     if ($this->session->get('search_terms')) {
         $this->out('run_search', 1);
     }
 }
Beispiel #7
0
 /**
  * Returns UNSEEN messages for an IMAP server
  */
 public function process()
 {
     list($success, $form) = $this->process_form(array('imap_server_ids'));
     if ($success) {
         $limit = $this->user_config->get('unread_per_source_setting', DEFAULT_PER_SOURCE);
         $date = process_since_argument($this->user_config->get('unread_since_setting', DEFAULT_SINCE));
         $ids = explode(',', $form['imap_server_ids']);
         $msg_list = array();
         $folder = 'INBOX';
         if (array_key_exists('folder', $this->request->post)) {
             $folder = $this->request->post['folder'];
         }
         $msg_list = merge_imap_search_results($ids, 'UNSEEN', $this->session, array($folder), $limit, array('SINCE' => $date));
         $this->out('imap_unread_data', $msg_list);
         $this->out('imap_server_ids', $form['imap_server_ids']);
     }
 }