X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Frss.inc.php;h=e45a822acebc2345fdc5d5ed23222af34b975aeb;hb=33b6f5a0072343de978e05f855739322b94179e5;hp=9dc4f86d6aeac812ba028c34cc75d515ab67d5f5;hpb=756ff73fbb0cdd01cce2eda27ba18e1cc99bd735;p=platal.git diff --git a/include/rss.inc.php b/include/rss.inc.php index 9dc4f86..e45a822 100644 --- a/include/rss.inc.php +++ b/include/rss.inc.php @@ -19,40 +19,24 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -function _rss_encode_date($d) { - if (preg_match('/^\d{14}$/', $d)) { - $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4)); - } else { - $t = strtotime($d); - } - return date('r', $t); -} - function init_rss($template, $alias, $hash, $require_uid = true) { - global $page; + $page =& Platal::page(); $page->changeTpl($template, NO_SKIN); - $page->register_modifier('rss_date', '_rss_encode_date'); - - $res = XDB::query( - 'SELECT a.id - FROM aliases AS a - INNER JOIN auth_user_quick AS q ON ( a.id = q.user_id AND q.core_rss_hash = {?} ) - WHERE a.alias = {?} AND a.type != "homonyme"', $hash, $alias); - $uid = $res->fetchOneCell(); - - if (empty($uid)) { + $user = Platal::session()->tokenAuth($alias, $hash); + if (is_null($user)) { if ($require_uid) { exit; } else { - $uid = null; + $user = null; } } if ($template) { + $page->assign('rss_hash', $hash); header('Content-Type: application/rss+xml; charset=utf8'); } - return $uid; + return is_null($user) ? null : $user->id(); } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: