summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/attachmentlist.php7
-rw-r--r--lib/common.php2
-rw-r--r--lib/daemon.php11
-rw-r--r--lib/dbqueuemanager.php14
-rw-r--r--lib/groupsbymemberssection.php2
-rw-r--r--lib/groupsbypostssection.php2
-rw-r--r--lib/grouptagcloudsection.php2
-rw-r--r--lib/language.php2
-rw-r--r--lib/mail.php2
-rw-r--r--lib/messageform.php6
-rw-r--r--lib/noticelist.php42
-rw-r--r--lib/popularnoticesection.php6
-rw-r--r--lib/profilesection.php2
-rw-r--r--lib/queuehandler.php11
-rw-r--r--lib/router.php16
-rw-r--r--lib/rssaction.php85
-rw-r--r--lib/twitterapi.php118
-rw-r--r--lib/util.php20
18 files changed, 239 insertions, 111 deletions
diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php
index f6a1b59d0..41d03f8e2 100644
--- a/lib/attachmentlist.php
+++ b/lib/attachmentlist.php
@@ -340,7 +340,12 @@ class Attachment extends AttachmentListItem
case 'video':
case 'link':
if (!empty($this->oembed->html)) {
- $this->out->raw($this->oembed->html);
+ require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
+ $config = array(
+ 'safe'=>1,
+ 'elements'=>'*+object+embed');
+ $this->out->raw(htmLawed($this->oembed->html,$config));
+ //$this->out->raw($this->oembed->html);
}
break;
diff --git a/lib/common.php b/lib/common.php
index 507a2a281..8cd3ae2fc 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -19,7 +19,7 @@
if (!defined('LACONICA')) { exit(1); }
-define('LACONICA_VERSION', '0.8.0');
+define('LACONICA_VERSION', '0.8.1pre1');
define('AVATAR_PROFILE_SIZE', 96);
define('AVATAR_STREAM_SIZE', 48);
diff --git a/lib/daemon.php b/lib/daemon.php
index 9d89c63e7..231f5414e 100644
--- a/lib/daemon.php
+++ b/lib/daemon.php
@@ -24,6 +24,7 @@ if (!defined('LACONICA')) {
class Daemon
{
var $daemonize = true;
+ var $_id = 'generic';
function __construct($daemonize = true)
{
@@ -35,6 +36,16 @@ class Daemon
return null;
}
+ function get_id()
+ {
+ return $this->_id;
+ }
+
+ function set_id($id)
+ {
+ $this->_id = $id;
+ }
+
function background()
{
$pid = pcntl_fork();
diff --git a/lib/dbqueuemanager.php b/lib/dbqueuemanager.php
index a37a8ffdf..19aa9f3ae 100644
--- a/lib/dbqueuemanager.php
+++ b/lib/dbqueuemanager.php
@@ -22,7 +22,6 @@
* @category QueueManager
* @package Laconica
* @author Evan Prodromou <evan@controlyourself.ca>
- * @author Sarven Capadisli <csarven@controlyourself.ca>
* @copyright 2009 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
@@ -86,9 +85,15 @@ class DBQueueManager extends QueueManager
$start = time();
$result = null;
+ $sleeptime = 1;
+
do {
$qi = Queue_item::top($queue);
- if (!empty($qi)) {
+ if (empty($qi)) {
+ $this->_log(LOG_DEBUG, "No new queue items, sleeping $sleeptime seconds.");
+ sleep($sleeptime);
+ $sleeptime *= 2;
+ } else {
$notice = Notice::staticGet('id', $qi->notice_id);
if (!empty($notice)) {
$result = $notice;
@@ -98,6 +103,7 @@ class DBQueueManager extends QueueManager
$qi->free();
$qi = null;
}
+ $sleeptime = 1;
}
} while (empty($result) && (is_null($timeout) || (time() - $start) < $timeout));
@@ -118,7 +124,7 @@ class DBQueueManager extends QueueManager
} else {
if (empty($qi->claimed)) {
$this->_log(LOG_WARNING, 'Reluctantly releasing unclaimed queue item '.
- 'for '.$notice->id.', queue '.$queue);
+ 'for '.$notice->id.', queue '.$queue);
}
$qi->delete();
$qi->free();
@@ -145,7 +151,7 @@ class DBQueueManager extends QueueManager
} else {
if (empty($qi->claimed)) {
$this->_log(LOG_WARNING, 'Ignoring failure for unclaimed queue item '.
- 'for '.$notice->id.', queue '.$queue);
+ 'for '.$notice->id.', queue '.$queue);
} else {
$orig = clone($qi);
$qi->claimed = null;
diff --git a/lib/groupsbymemberssection.php b/lib/groupsbymemberssection.php
index 963e21f15..ad4884bf8 100644
--- a/lib/groupsbymemberssection.php
+++ b/lib/groupsbymemberssection.php
@@ -48,7 +48,7 @@ class GroupsByMembersSection extends GroupSection
$qry = 'SELECT user_group.*, count(*) as value ' .
'FROM user_group JOIN group_member '.
'ON user_group.id = group_member.group_id ' .
- 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' .
+ 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified,user_group.design_id ' .
'ORDER BY value DESC ';
$limit = GROUPS_PER_SECTION;
diff --git a/lib/groupsbypostssection.php b/lib/groupsbypostssection.php
index 325b4033f..dc7925d5e 100644
--- a/lib/groupsbypostssection.php
+++ b/lib/groupsbypostssection.php
@@ -48,7 +48,7 @@ class GroupsByPostsSection extends GroupSection
$qry = 'SELECT user_group.*, count(*) as value ' .
'FROM user_group JOIN group_inbox '.
'ON user_group.id = group_inbox.group_id ' .
- 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified ' .
+ 'GROUP BY user_group.id,user_group.nickname,user_group.fullname,user_group.homepage,user_group.description,user_group.location,user_group.original_logo,user_group.homepage_logo,user_group.stream_logo,user_group.mini_logo,user_group.created,user_group.modified,user_group.design_id ' .
'ORDER BY value DESC ';
$limit = GROUPS_PER_SECTION;
diff --git a/lib/grouptagcloudsection.php b/lib/grouptagcloudsection.php
index 9b7a10f6b..0e0cbdd63 100644
--- a/lib/grouptagcloudsection.php
+++ b/lib/grouptagcloudsection.php
@@ -73,7 +73,7 @@ class GroupTagCloudSection extends TagCloudSection
$quoted = array();
foreach ($names as $name) {
- $quoted[] = "\"$name\"";
+ $quoted[] = "'$name'";
}
$namestring = implode(',', $quoted);
diff --git a/lib/language.php b/lib/language.php
index 3ea3dd2aa..9ad2d31bd 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -53,7 +53,7 @@ function client_prefered_language($httplang)
if (!empty($httplang[2][$i])) {
// if no q default to 1.0
$client_langs[$httplang[2][$i]] =
- ($httplang[6][$i]? (float) $httplang[6][$i] : 1.0);
+ ($httplang[6][$i]? (float) $httplang[6][$i] : 1.0 - ($i*0.01));
}
if (!empty($httplang[3][$i]) && empty($client_langs[$httplang[3][$i]])) {
// if a catchall default 0.01 lower
diff --git a/lib/mail.php b/lib/mail.php
index 781a7541b..0050ad810 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -121,7 +121,7 @@ function mail_notify_from()
$domain = mail_domain();
- $notifyfrom = common_config('site', 'name') .' <noreply@'.$domain.'>';
+ $notifyfrom = '"'.common_config('site', 'name') .'" <noreply@'.$domain.'>';
}
return $notifyfrom;
diff --git a/lib/messageform.php b/lib/messageform.php
index b8878ec1f..8ea2b36c2 100644
--- a/lib/messageform.php
+++ b/lib/messageform.php
@@ -140,6 +140,12 @@ class MessageForm extends Form
'rows' => 4,
'name' => 'content'),
($this->content) ? $this->content : '');
+ $this->out->elementStart('dl', 'form_note');
+ $this->out->element('dt', null, _('Available characters'));
+ $this->out->element('dd', array('id' => 'notice_text-count'),
+ '140');
+ $this->out->elementEnd('dl');
+
}
/**
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 44726a17b..a8d5059ca 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -357,19 +357,14 @@ class NoticeListItem extends Widget
preg_match('/^http/', $this->notice->uri)) {
$noticeurl = $this->notice->uri;
}
- $this->out->elementStart('dl', 'timestamp');
- $this->out->element('dt', null, _('Published'));
- $this->out->elementStart('dd', null);
$this->out->elementStart('a', array('rel' => 'bookmark',
+ 'class' => 'timestamp',
'href' => $noticeurl));
$dt = common_date_iso8601($this->notice->created);
$this->out->element('abbr', array('class' => 'published',
'title' => $dt),
common_date_string($this->notice->created));
-
$this->out->elementEnd('a');
- $this->out->elementEnd('dd');
- $this->out->elementEnd('dl');
}
/**
@@ -384,8 +379,8 @@ class NoticeListItem extends Widget
function showNoticeSource()
{
if ($this->notice->source) {
- $this->out->elementStart('dl', 'device');
- $this->out->element('dt', null, _('From'));
+ $this->out->elementStart('span', 'source');
+ $this->out->text(_('from'));
$source_name = _($this->notice->source);
switch ($this->notice->source) {
case 'web':
@@ -394,22 +389,22 @@ class NoticeListItem extends Widget
case 'omb':
case 'system':
case 'api':
- $this->out->element('dd', null, $source_name);
+ $this->out->element('span', 'device', $source_name);
break;
default:
$ns = Notice_source::staticGet($this->notice->source);
if ($ns) {
- $this->out->elementStart('dd', null);
+ $this->out->elementStart('span', 'device');
$this->out->element('a', array('href' => $ns->url,
'rel' => 'external'),
$ns->name);
- $this->out->elementEnd('dd');
+ $this->out->elementEnd('span');
} else {
- $this->out->element('dd', null, $source_name);
+ $this->out->element('span', 'device', $source_name);
}
break;
}
- $this->out->elementEnd('dl');
+ $this->out->elementEnd('span');
}
}
@@ -429,13 +424,9 @@ class NoticeListItem extends Widget
&& $this->notice->conversation != $this->notice->id) {
$convurl = common_local_url('conversation',
array('id' => $this->notice->conversation));
- $this->out->elementStart('dl', 'response');
- $this->out->element('dt', null, _('To'));
- $this->out->elementStart('dd');
- $this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id),
+ $this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id,
+ 'class' => 'response'),
_('in context'));
- $this->out->elementEnd('dd');
- $this->out->elementEnd('dl');
}
}
@@ -453,17 +444,12 @@ class NoticeListItem extends Widget
if (common_logged_in()) {
$reply_url = common_local_url('newnotice',
array('replyto' => $this->profile->nickname));
-
- $this->out->elementStart('dl', 'notice_reply');
- $this->out->element('dt', null, _('Reply to this notice'));
- $this->out->elementStart('dd');
$this->out->elementStart('a', array('href' => $reply_url,
+ 'class' => 'notice_reply',
'title' => _('Reply to this notice')));
$this->out->text(_('Reply'));
$this->out->element('span', 'notice_id', $this->notice->id);
$this->out->elementEnd('a');
- $this->out->elementEnd('dd');
- $this->out->elementEnd('dl');
}
}
@@ -479,13 +465,9 @@ class NoticeListItem extends Widget
if ($user && $this->notice->profile_id == $user->id) {
$deleteurl = common_local_url('deletenotice',
array('notice' => $this->notice->id));
- $this->out->elementStart('dl', 'notice_delete');
- $this->out->element('dt', null, _('Delete this notice'));
- $this->out->elementStart('dd');
$this->out->element('a', array('href' => $deleteurl,
+ 'class' => 'notice_delete',
'title' => _('Delete this notice')), _('Delete'));
- $this->out->elementEnd('dd');
- $this->out->elementEnd('dl');
}
}
diff --git a/lib/popularnoticesection.php b/lib/popularnoticesection.php
index e47c9b385..167a6ff8d 100644
--- a/lib/popularnoticesection.php
+++ b/lib/popularnoticesection.php
@@ -74,11 +74,7 @@ class PopularNoticeSection extends NoticeSection
$offset = 0;
$limit = NOTICES_PER_SECTION + 1;
- if (common_config('db', 'type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
$notice = Memcached_DataObject::cachedQuery('Notice',
sprintf($qry, common_config('popular', 'dropoff')),
diff --git a/lib/profilesection.php b/lib/profilesection.php
index 9ff243fb5..d463a07b0 100644
--- a/lib/profilesection.php
+++ b/lib/profilesection.php
@@ -97,7 +97,7 @@ class ProfileSection extends Section
$this->out->elementEnd('a');
$this->out->elementEnd('span');
$this->out->elementEnd('td');
- if ($profile->value) {
+ if (isset($profile->value)) {
$this->out->element('td', 'value', $profile->value);
}
diff --git a/lib/queuehandler.php b/lib/queuehandler.php
index c2ff10f32..f11e5bd90 100644
--- a/lib/queuehandler.php
+++ b/lib/queuehandler.php
@@ -29,7 +29,6 @@ define('QUEUE_HANDLER_HIT_IDLE', 0);
class QueueHandler extends Daemon
{
- var $_id = 'generic';
function __construct($id=null, $daemonize=true)
{
@@ -55,16 +54,6 @@ class QueueHandler extends Daemon
return strtolower($this->class_name().'.'.$this->get_id());
}
- function get_id()
- {
- return $this->_id;
- }
-
- function set_id($id)
- {
- $this->_id = $id;
- }
-
function transport()
{
return null;
diff --git a/lib/router.php b/lib/router.php
index e12138637..19839b997 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -113,6 +113,16 @@ class Router
$m->connect('main/tagother/:id', array('action' => 'tagother'));
+ $m->connect('main/oembed.xml',
+ array('action' => 'api',
+ 'method' => 'oembed.xml',
+ 'apiaction' => 'oembed'));
+
+ $m->connect('main/oembed.json',
+ array('action' => 'api',
+ 'method' => 'oembed.json',
+ 'apiaction' => 'oembed'));
+
// these take a code
foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
@@ -206,7 +216,7 @@ class Router
array('tag' => '[a-zA-Z0-9]+'));
$m->connect('tag/:tag',
array('action' => 'tag'),
- array('tag' => '[a-zA-Z0-9]+'));
+ array('tag' => '[\pL\pN_\-\.]{1,64}'));
$m->connect('peopletag/:tag',
array('action' => 'peopletag'),
@@ -394,6 +404,10 @@ class Router
array('action' => 'api',
'apiaction' => 'laconica'));
+ $m->connect('api/laconica/:method',
+ array('action' => 'api',
+ 'apiaction' => 'laconica'));
+
// Groups
$m->connect('api/laconica/groups/:method/:argument',
array('action' => 'api',
diff --git a/lib/rssaction.php b/lib/rssaction.php
index 3b9f0fb47..0aca96566 100644
--- a/lib/rssaction.php
+++ b/lib/rssaction.php
@@ -39,6 +39,7 @@ class Rss10Action extends Action
var $creators = array();
var $limit = DEFAULT_RSS_LIMIT;
var $notices = null;
+ var $tags_already_output = array();
/**
* Constructor
@@ -96,11 +97,48 @@ class Rss10Action extends Action
{
// Parent handling, including cache check
parent::handle($args);
+
+ if (common_config('site', 'private')) {
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+
+ # This header makes basic auth go
+ header('WWW-Authenticate: Basic realm="Laconica RSS"');
+
+ # If the user hits cancel -- bam!
+ $this->show_basic_auth_error();
+ return;
+ } else {
+ $nickname = $_SERVER['PHP_AUTH_USER'];
+ $password = $_SERVER['PHP_AUTH_PW'];
+
+ if (!common_check_user($nickname, $password)) {
+ # basic authentication failed
+ list($proxy, $ip) = common_client_ip();
+
+ common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
+ $this->show_basic_auth_error();
+ return;
+ }
+ }
+ }
+
// Get the list of notices
$this->notices = $this->getNotices($this->limit);
$this->showRss();
}
+ function show_basic_auth_error()
+ {
+ header('HTTP/1.1 401 Unauthorized');
+ header('Content-Type: application/xml; charset=utf-8');
+ $this->startXML();
+ $this->elementStart('hash');
+ $this->element('error', null, 'Could not authenticate you.');
+ $this->element('request', null, $_SERVER['REQUEST_URI']);
+ $this->elementEnd('hash');
+ $this->endXML();
+ }
+
/**
* Get the notices to output in this stream
*
@@ -188,24 +226,6 @@ class Rss10Action extends Action
}
}
- // XXX: Surely there should be a common function to do this?
- function extract_tags ($string)
- {
- $count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($string), $match);
- if (!count)
- {
- return array();
- }
-
- $rv = array();
- foreach ($match[1] as $tag)
- {
- $rv[] = common_canonical_tag($tag);
- }
-
- return array_unique($rv);
- }
-
function showItem($notice)
{
$profile = Profile::staticGet($notice->profile_id);
@@ -230,6 +250,11 @@ class Rss10Action extends Action
$replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
$this->element('sioc:reply_of', array('rdf:resource' => $replyurl));
}
+ if (!empty($notice->conversation)) {
+ $conversationurl = common_local_url('conversation',
+ array('id' => $notice->conversation));
+ $this->element('sioc:has_discussion', array('rdf:resource' => $conversationurl));
+ }
$attachments = $notice->attachments();
if($attachments){
foreach($attachments as $attachment){
@@ -259,18 +284,28 @@ class Rss10Action extends Action
$this->element('sioc:links_to', array('rdf:resource'=>$attachment->url));
}
}
- $tags = $this->extract_tags($notice->content);
- if (!empty($tags)) {
- foreach ($tags as $tag)
- {
- $tagpage = common_local_url('tag', array('tag' => $tag));
- $tagrss = common_local_url('tagrss', array('tag' => $tag));
+
+ $tag = new Notice_tag();
+ $tag->notice_id = $notice->id;
+ if ($tag->find()) {
+ $entry['tags']=array();
+ while ($tag->fetch()) {
+ $tagpage = common_local_url('tag', array('tag' => $tag->tag));
+
+ if ( in_array($tag, $this->tags_already_output) ) {
+ $this->element('ctag:tagged', array('rdf:resource'=>$tagpage.'#concept'));
+ continue;
+ }
+
+ $tagrss = common_local_url('tagrss', array('tag' => $tag->tag));
$this->elementStart('ctag:tagged');
- $this->elementStart('ctag:Tag', array('rdf:about'=>$tagpage.'#concept', 'ctag:label'=>$tag));
+ $this->elementStart('ctag:Tag', array('rdf:about'=>$tagpage.'#concept', 'ctag:label'=>$tag->tag));
$this->element('foaf:page', array('rdf:resource'=>$tagpage));
$this->element('rdfs:seeAlso', array('rdf:resource'=>$tagrss));
$this->elementEnd('ctag:Tag');
$this->elementEnd('ctag:tagged');
+
+ $this->tags_already_output[] = $tag->tag;
}
}
$this->elementEnd('item');
diff --git a/lib/twitterapi.php b/lib/twitterapi.php
index ab6c0d62c..4115d9dcb 100644
--- a/lib/twitterapi.php
+++ b/lib/twitterapi.php
@@ -186,24 +186,24 @@ class TwitterapiAction extends Action
$twitter_status['favorited'] = false;
}
- # Enclosures
+ // Enclosures
$attachments = $notice->attachments();
-
- if (!empty($attachments)) {
-
- $twitter_status['attachments'] = array();
-
- foreach ($attachments as $attachment) {
- if ($attachment->isEnclosure()) {
- $enclosure = array();
- $enclosure['url'] = $attachment->url;
- $enclosure['mimetype'] = $attachment->mimetype;
- $enclosure['size'] = $attachment->size;
- $twitter_status['attachments'][] = $enclosure;
- }
+ $enclosures = array();
+
+ foreach ($attachments as $attachment) {
+ if ($attachment->isEnclosure()) {
+ $enclosure = array();
+ $enclosure['url'] = $attachment->url;
+ $enclosure['mimetype'] = $attachment->mimetype;
+ $enclosure['size'] = $attachment->size;
+ $enclosures[] = $enclosure;
}
}
+ if (!empty($enclosures)) {
+ $twitter_status['attachments'] = $enclosures;
+ }
+
if ($include_user) {
# Don't get notice (recursive!)
$twitter_user = $this->twitter_user_array($profile, false);
@@ -213,12 +213,32 @@ class TwitterapiAction extends Action
return $twitter_status;
}
+ function twitter_group_array($group)
+ {
+ $twitter_group=array();
+ $twitter_group['id']=$group->id;
+ $twitter_group['url']=$group->permalink();
+ $twitter_group['nickname']=$group->nickname;
+ $twitter_group['fullname']=$group->fullname;
+ $twitter_group['homepage_url']=$group->homepage_url;
+ $twitter_group['original_logo']=$group->original_logo;
+ $twitter_group['homepage_logo']=$group->homepage_logo;
+ $twitter_group['stream_logo']=$group->stream_logo;
+ $twitter_group['mini_logo']=$group->mini_logo;
+ $twitter_group['homepage']=$group->homepage;
+ $twitter_group['description']=$group->description;
+ $twitter_group['location']=$group->location;
+ $twitter_group['created']=$this->date_twitter($group->created);
+ $twitter_group['modified']=$this->date_twitter($group->modified);
+ return $twitter_group;
+ }
+
function twitter_rss_entry_array($notice)
{
$profile = $notice->getProfile();
$entry = array();
- # We trim() to avoid extraneous whitespace in the output
+ // We trim() to avoid extraneous whitespace in the output
$entry['content'] = common_xml_safe_str(trim($notice->rendered));
$entry['title'] = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
@@ -231,7 +251,26 @@ class TwitterapiAction extends Action
$entry['updated'] = $entry['published'];
$entry['author'] = $profile->getBestName();
- # Enclosure
+ // Enclosures
+ $attachments = $notice->attachments();
+ $enclosures = array();
+
+ foreach ($attachments as $attachment) {
+ if ($attachment->isEnclosure()) {
+ $enclosure = array();
+ $enclosure['url'] = $attachment->url;
+ $enclosure['mimetype'] = $attachment->mimetype;
+ $enclosure['size'] = $attachment->size;
+ $enclosures[] = $enclosure;
+ }
+ }
+
+ if (!empty($enclosures)) {
+ $entry['enclosures'] = $enclosures;
+ }
+
+/*
+ // Enclosure
$attachments = $notice->attachments();
if($attachments){
$entry['enclosures']=array();
@@ -245,8 +284,20 @@ class TwitterapiAction extends Action
}
}
}
+*/
- # RSS Item specific
+ // Tags/Categories
+ $tag = new Notice_tag();
+ $tag->notice_id = $notice->id;
+ if ($tag->find()) {
+ $entry['tags']=array();
+ while ($tag->fetch()) {
+ $entry['tags'][]=$tag->tag;
+ }
+ }
+ $tag->free();
+
+ // RSS Item specific
$entry['description'] = $entry['content'];
$entry['pubDate'] = common_date_rfc2822($notice->created);
$entry['guid'] = $entry['link'];
@@ -382,6 +433,15 @@ class TwitterapiAction extends Action
$this->elementEnd('status');
}
+ function show_twitter_xml_group($twitter_group)
+ {
+ $this->elementStart('group');
+ foreach($twitter_group as $element => $value) {
+ $this->element($element, null, $value);
+ }
+ $this->elementEnd('group');
+ }
+
function show_twitter_xml_user($twitter_user, $role='user')
{
$this->elementStart($role);
@@ -419,10 +479,16 @@ class TwitterapiAction extends Action
$this->element('link', null, $entry['link']);
# RSS only supports 1 enclosure per item
- if($entry['enclosures']){
+ if(array_key_exists('enclosures', $entry) and !empty($entry['enclosures'])){
$enclosure = $entry['enclosures'][0];
$this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
}
+
+ if(array_key_exists('tags', $entry)){
+ foreach($entry['tags'] as $tag){
+ $this->element('category', null,$tag);
+ }
+ }
$this->elementEnd('item');
}
@@ -602,6 +668,22 @@ class TwitterapiAction extends Action
$this->end_document('json');
}
+ function show_single_json_group($group)
+ {
+ $this->init_document('json');
+ $twitter_group = $this->twitter_group_array($group);
+ $this->show_json_objects($twitter_group);
+ $this->end_document('json');
+ }
+
+ function show_single_xml_group($group)
+ {
+ $this->init_document('xml');
+ $twitter_group = $this->twitter_group_array($group);
+ $this->show_twitter_xml_group($twitter_group);
+ $this->end_document('xml');
+ }
+
// Anyone know what date format this is?
// Twitter's dates look like this: "Mon Jul 14 23:52:38 +0000 2008" -- Zach
function date_twitter($dt)
diff --git a/lib/util.php b/lib/util.php
index 9e8ec41d2..c8e318efe 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -140,7 +140,7 @@ function common_have_session()
function common_ensure_session()
{
$c = null;
- if (array_key_exists(session_name, $_COOKIE)) {
+ if (array_key_exists(session_name(), $_COOKIE)) {
$c = $_COOKIE[session_name()];
}
if (!common_have_session()) {
@@ -404,7 +404,7 @@ function common_render_text($text)
$r = preg_replace('/[\x{0}-\x{8}\x{b}-\x{c}\x{e}-\x{19}]/', '', $r);
$r = common_replace_urls_callback($r, 'common_linkify');
- $r = preg_replace('/(^|\(|\[|\s+)#([A-Za-z0-9_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
+ $r = preg_replace('/(^|\(|\[|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
// XXX: machine tags
return $r;
}
@@ -414,9 +414,9 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) {
$regex = '#'.
'(?:'.
'(?:'.
- '(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|xmpp|irc)://'.
+ '(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|irc)://'.
'|'.
- '(?:mailto|aim|tel):'.
+ '(?:mailto|aim|tel|xmpp):'.
')'.
'[^.\s]+\.[^\s]+'.
'|'.
@@ -595,7 +595,8 @@ function common_tag_link($tag)
function common_canonical_tag($tag)
{
- return strtolower(str_replace(array('-', '_', '.'), '', $tag));
+ $tag = mb_convert_case($tag, MB_CASE_LOWER, "UTF-8");
+ return str_replace(array('-', '_', '.'), '', $tag);
}
function common_valid_profile_tag($str)
@@ -1409,20 +1410,21 @@ function common_client_ip()
return null;
}
- if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
- if ($_SERVER['HTTP_CLIENT_IP']) {
+ if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
+ if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
$proxy = $_SERVER['HTTP_CLIENT_IP'];
} else {
$proxy = $_SERVER['REMOTE_ADDR'];
}
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
- if ($_SERVER['HTTP_CLIENT_IP']) {
+ $proxy = null;
+ if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
}
- return array($ip, $proxy);
+ return array($proxy, $ip);
}