/** * Validate POST data * * Validates POST data for a subscribe or unsubscribe request. This is the * default action for the event ACTION_HANDLE_SUBSCRIBE. * * @author Adrian Lang <*****@*****.**> */ function subscription_handle_post(&$params) { global $INFO; global $lang; // Get and validate parameters. if (!isset($params['target'])) { throw new Exception('no subscription target given'); } $target = $params['target']; $valid_styles = array('every', 'digest'); if (substr($target, -1, 1) === ':') { // Allow “list” subscribe style since the target is a namespace. $valid_styles[] = 'list'; } $style = valid_input_set('style', $valid_styles, $params, 'invalid subscription style given'); $action = valid_input_set('action', array('subscribe', 'unsubscribe'), $params, 'invalid subscription action given'); // Check other conditions. if ($action === 'subscribe') { if ($INFO['userinfo']['mail'] === '') { throw new Exception($lang['subscr_subscribe_noaddress']); } } elseif ($action === 'unsubscribe') { $is = false; foreach ($INFO['subscribed'] as $subscr) { if ($subscr['target'] === $target) { $is = true; } } if ($is === false) { throw new Exception(sprintf($lang['subscr_not_subscribed'], $_SERVER['REMOTE_USER'], prettyprint_id($target))); } // subscription_set deletes a subscription if style = null. $style = null; } $data = in_array($style, array('list', 'digest')) ? time() : null; $params = compact('target', 'style', 'data', 'action'); }
/** * Get URL parameters and config options and return an initialized option array * * @author Andreas Gohr <*****@*****.**> */ function rss_parseOptions() { global $conf; $opt = array(); foreach (array('feed_mode' => array('mode', 'recent'), 'link_to' => array('linkto', $conf['rss_linkto']), 'item_content' => array('content', $conf['rss_content']), 'namespace' => array('ns', null), 'items' => array('num', $conf['recent']), 'show_minor' => array('minor', false), 'search_query' => array('q', null)) as $name => $val) { $opt[$name] = isset($_REQUEST[$val[0]]) && !empty($_REQUEST[$val[0]]) ? $_REQUEST[$val[0]] : $val[1]; } $opt['items'] = max(0, (int) $opt['items']); $opt['show_minor'] = (bool) $opt['show_minor']; $opt['guardmail'] = $conf['mailguard'] != '' && $conf['mailguard'] != 'none'; $type = valid_input_set('type', array('rss', 'rss2', 'atom', 'atom1', 'rss1', 'default' => $conf['rss_type']), $_REQUEST); switch ($type) { case 'rss': $opt['feed_type'] = 'RSS0.91'; $opt['mime_type'] = 'text/xml'; break; case 'rss2': $opt['feed_type'] = 'RSS2.0'; $opt['mime_type'] = 'text/xml'; break; case 'atom': $opt['feed_type'] = 'ATOM0.3'; $opt['mime_type'] = 'application/xml'; break; case 'atom1': $opt['feed_type'] = 'ATOM1.0'; $opt['mime_type'] = 'application/atom+xml'; break; default: $opt['feed_type'] = 'RSS1.0'; $opt['mime_type'] = 'application/xml'; } $eventData = array('opt' => &$opt); trigger_event('FEED_OPTS_POSTPROCESS', $eventData); return $opt; }
/** * Get URL parameters and config options and return an initialized option array * * @author Andreas Gohr <*****@*****.**> */ function rss_parseOptions() { global $conf; global $INPUT; $opt = array(); foreach (array('feed_mode' => array('str', 'mode', 'recent'), 'link_to' => array('str', 'linkto', $conf['rss_linkto']), 'item_content' => array('str', 'content', $conf['rss_content']), 'namespace' => array('str', 'ns', null), 'items' => array('int', 'num', $conf['recent']), 'show_minor' => array('bool', 'minor', false), 'sort' => array('str', 'sort', 'natural'), 'search_query' => array('str', 'q', null), 'content_type' => array('str', 'view', $conf['rss_media'])) as $name => $val) { $opt[$name] = $INPUT->{$val}[0]($val[1], $val[2], true); } $opt['items'] = max(0, (int) $opt['items']); $opt['show_minor'] = (bool) $opt['show_minor']; $opt['sort'] = valid_input_set('sort', array('default' => 'natural', 'date'), $opt); $opt['guardmail'] = $conf['mailguard'] != '' && $conf['mailguard'] != 'none'; $type = $INPUT->valid('type', array('rss', 'rss2', 'atom', 'atom1', 'rss1'), $conf['rss_type']); switch ($type) { case 'rss': $opt['feed_type'] = 'RSS0.91'; $opt['mime_type'] = 'text/xml'; break; case 'rss2': $opt['feed_type'] = 'RSS2.0'; $opt['mime_type'] = 'text/xml'; break; case 'atom': $opt['feed_type'] = 'ATOM0.3'; $opt['mime_type'] = 'application/xml'; break; case 'atom1': $opt['feed_type'] = 'ATOM1.0'; $opt['mime_type'] = 'application/atom+xml'; break; default: $opt['feed_type'] = 'RSS1.0'; $opt['mime_type'] = 'application/xml'; } $eventData = array('opt' => &$opt); trigger_event('FEED_OPTS_POSTPROCESS', $eventData); return $opt; }