public function process() { if (Hm_Page_Cache::get('nux_dev_news')) { $this->out('nux_dev_news', Hm_Page_Cache::get('nux_dev_news')); return; } $ch = Hm_Functions::c_init(); $res = array(); Hm_Functions::c_setopt($ch, CURLOPT_URL, 'http://cypht.org/git.txt'); Hm_Functions::c_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $curl_result = Hm_Functions::c_exec($ch); if (trim($curl_result)) { foreach (explode("\n", $curl_result) as $line) { if (preg_match("/^([a-z0-9]{40})\\|([a-z0-9]{7})\\|([^\\|]+)\\|([^\\|]+)\\|([^\\|]+)\$/", $line, $matches)) { $res[] = array('hash' => $matches[1], 'shash' => $matches[2], 'name' => $matches[3], 'age' => date('D, M d', strtotime($matches[4])), 'note' => $matches[5]); } } } Hm_Page_Cache::add('nux_dev_news', $res); $this->out('nux_dev_news', $res); }
/** * Return cached subfolder contents or query the IMAP server for it */ public function process() { list($success, $form) = $this->process_form(array('imap_server_id')); if ($success) { $folder = ''; if (isset($this->request->post['folder'])) { $folder = $this->request->post['folder']; } $path = sprintf("imap_%d_%s", $form['imap_server_id'], $folder); $page_cache = Hm_Page_Cache::get('imap_folders_' . $path); if ($page_cache) { $this->out('imap_expanded_folder_data', $page_cache); $this->out('imap_expanded_folder_id', $form['imap_server_id']); $this->out('imap_expanded_folder_path', $path); return; } $details = Hm_IMAP_List::dump($form['imap_server_id']); $cache = Hm_IMAP_List::get_cache($this->session, $form['imap_server_id']); $imap = Hm_IMAP_List::connect($form['imap_server_id'], $cache); if (is_object($imap) && $imap->get_state() == 'authenticated') { $msgs = $imap->get_folder_list_by_level($folder); if (isset($msgs[$folder])) { unset($msgs[$folder]); } Hm_Page_Cache::add('imap_folders_' . $path, $msgs); $this->out('imap_expanded_folder_data', $msgs); $this->out('imap_expanded_folder_id', $form['imap_server_id']); $this->out('imap_expanded_folder_path', $path); } else { Hm_Msgs::add('ERRCould not authenticate to the selected IMAP server'); } } }
public function process() { $content = ''; $headers = array(); list($success, $form) = $this->process_form(array('feed_uid', 'feed_list_path')); if ($success) { $path = explode('_', $form['feed_list_path']); $id = $path[1]; $cache = Hm_Page_Cache::get($id . '_' . $form['feed_uid']); $feed_items = array(); if ($cache) { $feed_items = array($cache); } else { $feed_data = Hm_Feed_List::dump($id); if ($feed_data) { $feed = is_feed($feed_data['server']); if ($feed && $feed->parsed_data) { $feed_items = $feed->parsed_data; } } } foreach ($feed_items as $item) { if (isset($item['id']) && !isset($item['guid'])) { $item['guid'] = $item['id']; unset($item['id']); } elseif (isset($item['title']) && !isset($item['guid'])) { $item['guid'] = md5($item['title']); } if (isset($item['guid']) && md5($item['guid']) == $form['feed_uid']) { if (isset($item['description'])) { $content = $item['description']; unset($item['description']); } elseif (isset($item['summary'])) { $content = $item['summary']; unset($item['summary']); } $title = $item['title']; $headers = $item; unset($headers['title']); $headers = array_merge(array('title' => $title), $headers); if (!$cache) { Hm_Page_Cache::add($id . '_' . md5($item['guid']), $item, true); } break; } } if ($content) { Hm_Feed_Uid_Cache::read($form['feed_uid']); $this->out('feed_message_content', $content); $this->out('feed_message_headers', $headers); } } }