. */ require 'lib/functions.php'; require 'lib/mysql.class.php'; require 'lib/local.php'; getvars ('u,t'); if (empty ($u)) exit; $db = new Database (); $userid = ''; $tagUri = 'tag:'.$CONF['site'].',2005:notes'; header ('Content-Type: application/xml; charset=UTF-8'); if ($u == 'guest' && isset ($CONF['guestAccount'])) $u = $CONF['guestAccount']; $db->query ("SELECT id FROM user WHERE email='".$db->escape ($u)."'"); if ($db->next_record ()) $userid = $db->f ('id'); if (isset ($CONF['guestAccount']) && $u == $CONF['guestAccount']) $u = 'guest'; $tag = ''; if (!empty ($t)) $tag = '/'.htmlspecialchars (htmlentities2 ($t)); echo "\n"; echo "\n"; echo "".$u.($u[strlen ($u) - 1] != 's' ? "'s" : "'")." Notes and Links\n"; echo "".gmdate ('Y-m-d\TH:i:s\Z')."\n"; echo "\n"; echo "".$u."\n"; echo "".$u."\n"; echo "\n"; echo "Copyright (C) ".gmdate ('Y').' '.$u."\n"; echo "Cheetah News Aggregator\n"; echo "".$tagUri.'/'.$u.(!empty ($t) ? $tag : '')."\n"; echo "\n"; echo "http://".$CONF['site']."/images/favicon.png\n"; if (!empty ($t)) { $db->query ("SELECT note.id, note.title, note.date, note.mstamp, note.note FROM note ". "LEFT JOIN jntag ON note.id=jntag.noteid ". "LEFT JOIN ntag ON (ntag.id=jntag.tagid) ". "WHERE note.userid='".$userid."' AND note.public='yes' ". "AND ntag.tag='".$db->escape ($t)."' ". "GROUP BY note.id ORDER BY date DESC LIMIT 0,20"); } else { $db->query ("SELECT id, title, date, mstamp, note FROM note ". "WHERE note.userid='".$userid."' AND public='yes' ". "ORDER BY date DESC LIMIT 0,20"); } while ($db->next_record ()) { $pubDate = gmdate ('Y-m-d\TH:i:s\Z', strtotime ($db->f ('mstamp'))); echo "\n"; echo "".$tagUri.'/'.$u.(!empty ($t) ? $tag : '').'/'.$db->f ('id')."\n"; echo "".$pubDate."\n"; echo "".htmlspecialchars (htmlentities2 ($db->f ('title')))."\n"; echo "\n"; echo "
\n"; echo nl2br2 (createLinks (htmlspecialchars (htmlentities2 ($db->f ('note')))))."\n"; echo "
\n"; echo "
\n"; echo "
\n"; } echo "
\n"; function htmlentities2 ($htmlcode) { static $htmlEntities; static $entitiesDecoded; static $utf8Entities; if (!isset ($htmlEntities)) $htmlEntities = array_values (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES)); if (!isset ($entitiesDecoded)) $entitiesDecoded = array_keys (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES)); if (!isset ($utf8Entities)) { $num = count ($entitiesDecoded); for ($u = 0; $u < $num; $u++) $utf8Entities[$u] = '&#'.ord ($entitiesDecoded[$u]).';'; } return str_replace ($htmlEntities, $utf8Entities, $htmlcode); } function nl2br2 ($str) { return preg_replace ('/(\r\n|\n|\r)/', '', nl2br ($str)); } function createLinks ($str) { $lines = split ("\n", $str); for ($z = 0; $z < count ($lines); $z++) { $tmp = split (' ', $lines[$z]); for ($i = 0; $i < count ($tmp); $i++) { if (strstr ($tmp[$i], 'www.') && !strstr ($tmp[$i], 'http://')) $tmp[$i] = ''.$tmp[$i].''; else if (strstr ($tmp[$i], 'http://') || strstr ($tmp[$i], 'https://') || strstr ($tmp[$i], 'ftp://')) $tmp[$i] = ''.$tmp[$i].''; else if (strstr ($tmp[$i], '@') && $tmp[$i][0] != '@' && $tmp[$i][strlen ($tmp[$i]) - 1] != '@') $tmp[$i] = ''.$tmp[$i].''; } $lines[$z] = join (' ', $tmp); } return join ("\n", $lines); } ?>