summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@controlyourself.ca>2009-08-04 15:53:15 +0000
committerSarven Capadisli <csarven@controlyourself.ca>2009-08-04 15:53:15 +0000
commitd0a020dd4ea8d58bc8230ebcde22e54ad31894a8 (patch)
treec7d14f1e09bd46c72e577ca54645a7bab4a747e7 /lib
parent5f3af3e121a7ff06f5961bb4158e0b777ce5b5c1 (diff)
parentffa1d662a759a729151f2444bdf759749d59045e (diff)
Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x
Diffstat (limited to 'lib')
-rw-r--r--lib/profilesection.php2
-rw-r--r--lib/twitterapi.php49
-rw-r--r--lib/util.php11
3 files changed, 54 insertions, 8 deletions
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/twitterapi.php b/lib/twitterapi.php
index b2602e77c..4115d9dcb 100644
--- a/lib/twitterapi.php
+++ b/lib/twitterapi.php
@@ -213,6 +213,26 @@ 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();
@@ -413,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);
@@ -450,12 +479,12 @@ 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($entry['tags']){
+ if(array_key_exists('tags', $entry)){
foreach($entry['tags'] as $tag){
$this->element('category', null,$tag);
}
@@ -639,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 d784bb793..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()) {
@@ -1410,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);
}