From 16a6aa53907de29c6d993fd18e62d45e4380f451 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 6 Mar 2009 17:18:21 -0800 Subject: Some fixes for OpenID and OMB URLs --- lib/router.php | 7 +++---- lib/util.php | 9 ++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/router.php b/lib/router.php index 516b48122..d34b84cd4 100644 --- a/lib/router.php +++ b/lib/router.php @@ -49,6 +49,8 @@ class Router { var $m = null; static $inst = null; + static $bare = array('requesttoken', 'accesstoken', 'userauthorization', + 'postnotice', 'updateprofile', 'finishremotesubscribe'); static function get() { @@ -118,8 +120,7 @@ class Router $m->connect('main/remote', array('action' => 'remotesubscribe')); $m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '[A-Za-z0-9_-]+')); - foreach (array('requesttoken', 'accesstoken', 'userauthorization', - 'postnotice', 'updateprofile', 'finishremotesubscribe') as $action) { + foreach (Router::$bare as $action) { $m->connect('index.php?action=' . $action, array('action' => $action)); } @@ -277,7 +278,6 @@ class Router 'apiaction' => 'friendships'), array('method' => 'exists(\.(xml|json|rss|atom))')); - // Social graph $m->connect('api/friends/ids/:argument', @@ -352,7 +352,6 @@ class Router array('action' => 'api', 'apiaction' => 'laconica')); - // search $m->connect('api/search.atom', array('action' => 'twitapisearchatom')); $m->connect('api/search.json', array('action' => 'twitapisearchjson')); diff --git a/lib/util.php b/lib/util.php index 9637dc506..ca8376f28 100644 --- a/lib/util.php +++ b/lib/util.php @@ -722,12 +722,15 @@ function common_local_url($action, $args=null, $params=null, $fragment=null) { $r = Router::get(); $path = $r->build($action, $args, $params, $fragment); - if ($path) { - } + if (common_config('site','fancy')) { $url = common_path(mb_substr($path, 1)); } else { - $url = common_path('index.php'.$path); + if (mb_strpos($path, '/index.php') === 0) { + $url = common_path(mb_substr($path, 1)); + } else { + $url = common_path('index.php'.$path); + } } return $url; } -- cgit v1.2.3-54-g00ecf From ac7170bf6cbf36699cf182ccb1bd5214f6e8741e Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 6 Mar 2009 21:09:43 -0800 Subject: Atom search results for Twitter-compatible API + phpcs stuff --- actions/twitapisearchatom.php | 368 ++++++++++++++++++++++++++++++++++++++++++ actions/twitapisearchjson.php | 6 +- lib/jsonsearchresultslist.php | 69 ++++---- 3 files changed, 411 insertions(+), 32 deletions(-) create mode 100644 actions/twitapisearchatom.php (limited to 'lib') diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php new file mode 100644 index 000000000..3ab82bfb6 --- /dev/null +++ b/actions/twitapisearchatom.php @@ -0,0 +1,368 @@ +. + * + * @category Search + * @package Laconica + * @author Zach Copley + * @copyright 2008-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/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/twitterapi.php'; + +/** + * Action for outputting search results in Twitter compatible Atom + * format. + * + * TODO: abstract Atom stuff into a ruseable base class like + * RSS10Action. + * + * @category Search + * @package Laconica + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see TwitterapiAction + */ + +class TwitapisearchatomAction extends TwitterapiAction +{ + + var $notices; + var $cnt; + var $query; + var $lang; + var $rpp; + var $page; + var $since_id; + var $geocode; + + /** + * Constructor + * + * Just wraps the Action constructor. + * + * @param string $output URI to output to, default = stdout + * @param boolean $indent Whether to indent output, default true + * + * @see Action::__construct + */ + + function __construct($output='php://output', $indent=true) + { + parent::__construct($output, $indent); + } + + /** + * Do we need to write to the database? + * + * @return boolean true + */ + + function isReadonly() + { + return true; + } + + /** + * Read arguments and initialize members + * + * @param array $args Arguments from $_REQUEST + * + * @return boolean success + * + */ + + function prepare($args) + { + parent::prepare($args); + + $this->query = $this->trimmed('q'); + $this->lang = $this->trimmed('lang'); + $this->rpp = $this->trimmed('rpp'); + + if (!$this->rpp) { + $this->rpp = 15; + } + + if ($this->rpp > 100) { + $this->rpp = 100; + } + + $this->page = $this->trimmed('page'); + + if (!$this->page) { + $this->page = 1; + } + + // TODO: Suppport since_id -- we need to tweak the backend + // Search classes to support it. + + $this->since_id = $this->trimmed('since_id'); + $this->geocode = $this->trimmed('geocode'); + + // TODO: Also, language and geocode + + return true; + } + + /** + * Handle a request + * + * @param array $args Arguments from $_REQUEST + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + $this->showAtom(); + } + + /** + * Get the notices to output as results. This also sets some class + * attrs so we can use them to calculate pagination, and output + * since_id and max_id. + * + * @return array an array of Notice objects sorted in reverse chron + */ + + function getNotices() + { + // TODO: Support search operators like from: and to:, boolean, etc. + + $notice = new Notice(); + + // lcase it for comparison + $q = strtolower($this->query); + + $search_engine = $notice->getSearchEngine('identica_notices'); + $search_engine->set_sort_mode('chron'); + $search_engine->limit(($this->page - 1) * $this->rpp, + $this->rpp + 1, true); + $search_engine->query($q); + $this->cnt = $notice->find(); + + $cnt = 0; + + while ($notice->fetch()) { + + ++$cnt; + + if (!$this->max_id) { + $this->max_id = $notice->id; + } + + if ($cnt > $this->rpp) { + break; + } + + $notices[] = clone($notice); + } + + return $notices; + } + + /** + * Output search results as an Atom feed + * + * @return void + */ + + function showAtom() + { + $notices = $this->getNotices(); + + $this->initAtom(); + $this->showFeed(); + + foreach ($notices as $n) { + $this->showEntry($n); + } + + $this->endAtom(); + } + + /** + * Show feed specific Atom elements + * + * @return void + */ + + function showFeed() + { + // TODO: A9 OpenSearch stuff like search.twitter.com? + + $lang = common_config('site', 'language'); + $server = common_config('site', 'server'); + $sitename = common_config('site', 'name'); + + // XXX: Use xmlns:laconica instead? + + $this->elementStart('feed', + array('xmlns' => 'http://www.w3.org/2005/Atom', + 'xmlns:twitter' => 'http://api.twitter.com/', + 'xml:lang' => $lang)); + + $year = date('Y'); + $this->element('id', null, "tag:$server,$year:search/$server"); + + $site_uri = common_path(false); + + $search_uri = $site_uri . 'api/search.atom?q=' . urlencode($this->query); + + if ($this->rpp != 15) { + $search_uri .= '&rpp=' . $this->rpp; + } + + // FIXME: this alternate link is not quite right because our + // web-based notice search doesn't support a rpp (responses per + // page) param yet + + $this->element('link', array('type' => 'text/html', + 'rel' => 'alternate', + 'href' => $site_uri . 'search/notice?q=' . + urlencode($this->query))); + + // self link + + $self_uri = $search_uri . '&page=' . $this->page; + + $this->element('link', array('type' => 'application/atom+xml', + 'rel' => 'self', + 'href' => $self_uri)); + + $this->element('title', null, "$this->query - $sitename Search"); + + // refresh link + + $refresh_uri = $search_uri . "&since_id=" . $this->max_id; + + $this->element('link', array('type' => 'application/atom+xml', + 'rel' => 'refresh', + 'href' => $refresh_uri)); + + // pagination links + + if ($this->cnt > $this->rpp) { + + $next_uri = $search_uri . "&max_id=" . $this->max_id . + '&page=' . ($this->page + 1); + + $this->element('link', array('type' => 'application/atom+xml', + 'rel' => 'next', + 'href' => $next_uri)); + } + + if ($this->page > 1) { + + $previous_uri = $search_uri . "&max_id=" . $this->max_id . + '&page=' . ($this->page - 1); + + $this->element('link', array('type' => 'application/atom+xml', + 'rel' => 'previous', + 'href' => $previous_uri)); + } + + } + + /** + * Build an Atom entry similar to search.twitter.com's based on + * a given notice + * + * @param Notice $notice the notice to use + * + * @return void + */ + + function showEntry($notice) + { + $server = common_config('site', 'server'); + $profile = $notice->getProfile(); + $nurl = common_local_url('shownotice', array('notice' => $notice->id)); + + $this->elementStart('entry'); + + $year = date('Y', strtotime($notice->created)); + + $this->element('id', null, "tag:$server,$year:$notice->id"); + $this->element('published', null, common_date_w3dtf($notice->created)); + $this->element('link', array('type' => 'text/html', + 'rel' => 'alternate', + 'href' => $nurl)); + $this->element('title', null, common_xml_safe_str(trim($notice->content))); + $this->element('content', array('type' => 'text/html'), $notice->rendered); + $this->element('updated', null, common_date_w3dtf($notice->created)); + $this->element('link', array('type' => 'image/png', + 'rel' => 'image', + 'href' => $profile->avatarUrl())); + + // TODO: Here is where we'd put in a link to an atom feed for threads + + $this->element("twitter:source", null, + htmlentities($this->source_link($notice->source))); + + $this->elementStart('author'); + + $name = $profile->nickname; + + if ($profile->fullname) { + $name .= ' (' . $profile->fullname . ')'; + } + + $this->element('name', null, $name); + $this->element('uri', null, common_profile_uri($profile)); + $this->elementEnd('author'); + + $this->elementEnd('entry'); + } + + /** + * Initialize the Atom output, send headers + * + * @return void + */ + + function initAtom() + { + header('Content-Type: application/atom+xml; charset=utf-8'); + $this->startXml(); + } + + /** + * End the Atom feed + * + * @return void + */ + + function endAtom() + { + $this->elementEnd('feed'); + } + +} diff --git a/actions/twitapisearchjson.php b/actions/twitapisearchjson.php index b50aa86b7..0f9f523a1 100644 --- a/actions/twitapisearchjson.php +++ b/actions/twitapisearchjson.php @@ -2,7 +2,7 @@ /** * Laconica, the distributed open-source microblogging tool * - * List of replies + * Action for showing Twitter-like JSON search results * * PHP version 5 * @@ -114,7 +114,7 @@ class TwitapisearchjsonAction extends TwitterapiAction function showResults() { - // TODO: Support search operators like from: and to: + // TODO: Support search operators like from: and to:, boolean, etc. $notice = new Notice(); @@ -137,7 +137,7 @@ class TwitapisearchjsonAction extends TwitterapiAction } /** - * This is a read-only action + * Do we need to write to the database? * * @return boolean true */ diff --git a/lib/jsonsearchresultslist.php b/lib/jsonsearchresultslist.php index 171e1db4d..0cdcf0c51 100644 --- a/lib/jsonsearchresultslist.php +++ b/lib/jsonsearchresultslist.php @@ -22,7 +22,7 @@ * @category Search * @package Laconica * @author Zach Copley - * @copyright 2008-2009 Control Yourself, Inc. + * @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/ */ @@ -62,14 +62,19 @@ class JSONSearchResultsList /** * constructor * - * @param Notice $notice stream of notices from DB_DataObject + * @param Notice $notice stream of notices from DB_DataObject + * @param string $query the original search query + * @param int $rpp the number of results to display per page + * @param int $page a page offset + * @param int $since_id only display notices newer than this */ function __construct($notice, $query, $rpp, $page, $since_id = 0) { $this->notice = $notice; $this->query = urlencode($query); - $this->results_per_page = $this->rpp = $rpp; + $this->results_per_page = $rpp; + $this->rpp = $rpp; $this->page = $page; $this->since_id = $since_id; $this->results = array(); @@ -78,7 +83,7 @@ class JSONSearchResultsList /** * show the list of search results * - * @return int count of the search results listed. + * @return int $count of the search results listed. */ function show() @@ -103,7 +108,7 @@ class JSONSearchResultsList array_push($this->results, $item); } - $time_end = microtime(true); + $time_end = microtime(true); $this->completed_in = $time_end - $time_start; // Set other attrs @@ -197,7 +202,7 @@ class ResultItem function buildResult() { - $this->text = $this->notice->content; + $this->text = $this->notice->content; $replier_profile = null; if ($this->notice->reply_to) { @@ -209,18 +214,21 @@ class ResultItem $this->to_user_id = ($replier_profile) ? intval($replier_profile->id) : null; - $this->to_user = ($replier_profile) ? + $this->to_user = ($replier_profile) ? $replier_profile->nickname : null; - $this->from_user = $this->profile->nickname; - $this->id = $this->notice->id; + + $this->from_user = $this->profile->nickname; + $this->id = $this->notice->id; $this->from_user_id = $this->profile->id; $user = User::staticGet('id', $this->profile->id); + $this->iso_language_code = $this->user->language; $this->source = $this->getSourceLink($this->notice->source); $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); + $this->profile_image_url = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE); @@ -233,27 +241,30 @@ class ResultItem * Either the name (and link) of the API client that posted the notice, * or one of other other channels. * - * @return string the source of the Notice + * @param string $source the source of the Notice + * + * @return string a fully rendered source of the Notice */ - function getSourceLink($source) - { - $source_name = _($source); - switch ($source) { - case 'web': - case 'xmpp': - case 'mail': - case 'omb': - case 'api': - break; - default: - $ns = Notice_source::staticGet($source); - if ($ns) { - $source_name = '' . $ns->name . ''; - } - break; - } - return $source_name; - } + function getSourceLink($source) + { + $source_name = _($source); + switch ($source) { + case 'web': + case 'xmpp': + case 'mail': + case 'omb': + case 'api': + break; + default: + $ns = Notice_source::staticGet($source); + if ($ns) { + $source_name = '' . $ns->name . ''; + } + break; + } + + return $source_name; + } } -- cgit v1.2.3-54-g00ecf From 986a32223177a759b0ef071822d227011ee1b3c7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 7 Mar 2009 09:43:50 -0800 Subject: Limit duplicate notices in a particular time period (default 60s) We disallow posting a notice with duplicate content more than once a minute. Conflicts: config.php.sample --- README | 2 ++ classes/Notice.php | 47 ++++++++++++++++++++++++++++++++++++++++------- config.php.sample | 6 ++++++ lib/common.php | 3 ++- 4 files changed, 50 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/README b/README index 388d67ed2..ec2e2ec4f 100644 --- a/README +++ b/README @@ -879,6 +879,8 @@ notice: A plain string that will appear on every page. A good place to put introductory information about your service, or info about upgrades and outages, or other community info. Any HTML will be escaped. +dupelimit: Time in which it's not OK for the same person to post the + same notice; default = 60 seconds. db -- diff --git a/classes/Notice.php b/classes/Notice.php index 907239b08..eac90ce95 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -121,6 +121,8 @@ class Notice extends Memcached_DataObject $profile = Profile::staticGet($profile_id); + $final = common_shorten_links($content); + if (!$profile) { common_log(LOG_ERR, 'Problem saving notice. Unknown user.'); return _('Problem saving notice. Unknown user.'); @@ -131,7 +133,12 @@ class Notice extends Memcached_DataObject return _('Too many notices too fast; take a breather and post again in a few minutes.'); } - $banned = common_config('profile', 'banned'); + if (common_config('site', 'dupelimit') > 0 && !Notice::checkDupes($profile_id, $final)) { + common_log(LOG_WARNING, 'Dupe posting by profile #' . $profile_id . '; throttled.'); + return _('Too many duplicate messages too quickly; take a breather and post again in a few minutes.'); + } + + $banned = common_config('profile', 'banned'); if ( in_array($profile_id, $banned) || in_array($profile->nickname, $banned)) { common_log(LOG_WARNING, "Attempted post from banned user: $profile->nickname (user id = $profile_id)."); @@ -155,12 +162,12 @@ class Notice extends Memcached_DataObject $notice->query('BEGIN'); - $notice->reply_to = $reply_to; - $notice->created = common_sql_now(); - $notice->content = common_shorten_links($content); - $notice->rendered = common_render_content($notice->content, $notice); - $notice->source = $source; - $notice->uri = $uri; + $notice->reply_to = $reply_to; + $notice->created = common_sql_now(); + $notice->content = $final; + $notice->rendered = common_render_content($final, $notice); + $notice->source = $source; + $notice->uri = $uri; if (Event::handle('StartNoticeSave', array(&$notice))) { @@ -204,6 +211,32 @@ class Notice extends Memcached_DataObject return $notice; } + static function checkDupes($profile_id, $content) { + $profile = Profile::staticGet($profile_id); + if (!$profile) { + return false; + } + $notice = $profile->getNotices(0, NOTICE_CACHE_WINDOW); + if ($notice) { + $last = 0; + while ($notice->fetch()) { + if (time() - strtotime($notice->created) >= common_config('site', 'dupelimit')) { + return true; + } else if ($notice->content == $content) { + return false; + } + } + } + # If we get here, oldest item in cache window is not + # old enough for dupe limit; do direct check against DB + $notice = new Notice(); + $notice->profile_id = $profile_id; + $notice->content = $content; + $notice->whereAdd('now() - created < ' . common_config('notice', 'dupelimit')); + $cnt = $notice->count(); + return ($cnt > 0); + } + static function checkEditThrottle($profile_id) { $profile = Profile::staticGet($profile_id); if (!$profile) { diff --git a/config.php.sample b/config.php.sample index a6cada77a..c2b27408c 100644 --- a/config.php.sample +++ b/config.php.sample @@ -159,3 +159,9 @@ $config['sphinx']['port'] = 3312; # Add Google Analytics # require_once('plugins/GoogleAnalyticsPlugin.php'); # $ga = new GoogleAnalyticsPlugin('your secret code'); + +#Don't allow saying the same thing more than once per hour +#$config['site']['dupelimit'] = 3600; +#Don't enforce the dupe limit +#$config['site']['dupelimit'] = -1; + diff --git a/lib/common.php b/lib/common.php index 0355d01e3..917fdeafa 100644 --- a/lib/common.php +++ b/lib/common.php @@ -85,7 +85,8 @@ $config = 'broughtbyurl' => null, 'closed' => false, 'inviteonly' => false, - 'private' => false), + 'private' => false, + 'dupelimit' => 60), # default for same person saying the same thing 'syslog' => array('appname' => 'laconica', # for syslog 'priority' => 'debug'), # XXX: currently ignored -- cgit v1.2.3-54-g00ecf From 1980f166a78954b15ed53e1421164452ec692497 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 7 Mar 2009 11:36:10 -0800 Subject: change trust root calculation --- lib/openid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/openid.php b/lib/openid.php index 5c3d460da..3aa488b6d 100644 --- a/lib/openid.php +++ b/lib/openid.php @@ -160,7 +160,7 @@ function oid_authenticate($openid_url, $returnto, $immediate=false) $auth_request->addExtension($sreg_request); } - $trust_root = common_local_url('public'); + $trust_root = common_path(''); $process_url = common_local_url($returnto); if ($auth_request->shouldSendRedirect()) { -- cgit v1.2.3-54-g00ecf From 22742c3b72a02c29eef0e678abd839e378a783c4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 7 Mar 2009 12:38:22 -0800 Subject: Make OpenID login and registration URLs work The OpenID login and registration URLs were not generating correctly. I added them to the list of "bare" actions in the router class, and they work great now. --- lib/router.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/router.php b/lib/router.php index d34b84cd4..52051fdb5 100644 --- a/lib/router.php +++ b/lib/router.php @@ -50,7 +50,8 @@ class Router var $m = null; static $inst = null; static $bare = array('requesttoken', 'accesstoken', 'userauthorization', - 'postnotice', 'updateprofile', 'finishremotesubscribe'); + 'postnotice', 'updateprofile', 'finishremotesubscribe', + 'finishopenidlogin', 'finishaddopenid'); static function get() { -- cgit v1.2.3-54-g00ecf From 1179ecd13d68e76d74ad94e2d3ca22d9681eeffe Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 7 Mar 2009 12:55:09 -0800 Subject: Fix nonce usage in OAuth store The OAuth store was failing on getting a request token, because the token value was forced to be non-null in the DB. Let this value be null, and use the correct primary key (consumer, timestamp, nonce). Drop the reference to token table, and don't ever use it. --- classes/Nonce.php | 9 ++++----- classes/laconica.ini | 4 ++-- db/laconica.sql | 5 ++--- lib/oauthstore.php | 3 +-- 4 files changed, 9 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/classes/Nonce.php b/classes/Nonce.php index 2c0edfa14..486a65a3c 100644 --- a/classes/Nonce.php +++ b/classes/Nonce.php @@ -4,22 +4,21 @@ */ require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; -class Nonce extends Memcached_DataObject +class Nonce extends Memcached_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */ public $__table = 'nonce'; // table name public $consumer_key; // varchar(255) primary_key not_null - public $tok; // char(32) primary_key not_null + public $tok; // char(32) public $nonce; // char(32) primary_key not_null - public $ts; // datetime() not_null + public $ts; // datetime() primary_key not_null public $created; // datetime() not_null public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=null) - { return Memcached_DataObject::staticGet('Nonce',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Nonce',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/laconica.ini b/classes/laconica.ini index 5fd2cd1f8..529454d99 100755 --- a/classes/laconica.ini +++ b/classes/laconica.ini @@ -145,7 +145,7 @@ id = N [nonce] consumer_key = 130 -tok = 130 +tok = 2 nonce = 130 ts = 142 created = 142 @@ -153,8 +153,8 @@ modified = 384 [nonce__keys] consumer_key = K -tok = K nonce = K +ts = K [notice] id = 129 diff --git a/db/laconica.sql b/db/laconica.sql index c2cd887de..098fa4fd1 100644 --- a/db/laconica.sql +++ b/db/laconica.sql @@ -181,15 +181,14 @@ create table token ( create table nonce ( consumer_key varchar(255) not null comment 'unique identifier, root URL', - tok char(32) not null comment 'identifying value', + tok char(32) null comment 'buggy old value, ignored', nonce char(32) not null comment 'nonce', ts datetime not null comment 'timestamp sent', created datetime not null comment 'date this record was created', modified timestamp comment 'date this record was modified', - constraint primary key (consumer_key, tok, nonce), - constraint foreign key (consumer_key, tok) references token (consumer_key, tok) + constraint primary key (consumer_key, ts, nonce) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; /* One-to-many relationship of user to openid_url */ diff --git a/lib/oauthstore.php b/lib/oauthstore.php index 9af05ea2d..7d2e1f27b 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -58,12 +58,11 @@ class LaconicaOAuthDataStore extends OAuthDataStore { $n = new Nonce(); $n->consumer_key = $consumer->key; - $n->tok = $token->key; + $n->ts = $timestamp; $n->nonce = $nonce; if ($n->find(true)) { return true; } else { - $n->ts = $timestamp; $n->created = DB_DataObject_Cast::dateTime(); $n->insert(); return false; -- cgit v1.2.3-54-g00ecf From 2400589c2fc9355679b5da318286ecf96e386133 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 7 Mar 2009 13:00:13 -0800 Subject: helpful documentation for oauthstore nonce stuff --- lib/oauthstore.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/oauthstore.php b/lib/oauthstore.php index 7d2e1f27b..183164e17 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -54,6 +54,12 @@ class LaconicaOAuthDataStore extends OAuthDataStore } } + // http://oauth.net/core/1.0/#nonce + // "The Consumer SHALL then generate a Nonce value that is unique for + // all requests with that timestamp." + + // XXX: It's not clear why the token is here + function lookup_nonce($consumer, $token, $nonce, $timestamp) { $n = new Nonce(); -- cgit v1.2.3-54-g00ecf From f9a7ae27b8879569a3f0eff478cbd3b650bdca28 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 8 Mar 2009 01:31:25 +0100 Subject: Remove leave button from grouplist if current user is admin of that group. --- lib/grouplist.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/grouplist.php b/lib/grouplist.php index 4c448e250..8f3b0abd8 100644 --- a/lib/grouplist.php +++ b/lib/grouplist.php @@ -164,8 +164,10 @@ class GroupList extends Widget # XXX: special-case for user looking at own # subscriptions page if ($user->isMember($this->group)) { - $lf = new LeaveForm($this->out, $this->group); - $lf->show(); + if (!$user->isAdmin($this->group)) { + $lf = new LeaveForm($this->out, $this->group); + $lf->show(); + } } else { $jf = new JoinForm($this->out, $this->group); $jf->show(); -- cgit v1.2.3-54-g00ecf From ad83998f10952c3841b4b999b5a340ca26d329f7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 7 Mar 2009 17:16:52 -0800 Subject: Revert "Remove leave button from grouplist if current user is admin of that group." People shouldn't be forced to be part of a group, even if they are the admin. If a group has no admin, we need to figure out what to do with it, but it's wrong to force anyone to be part of a group. This reverts commit f9a7ae27b8879569a3f0eff478cbd3b650bdca28. --- lib/grouplist.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/grouplist.php b/lib/grouplist.php index 8e2637fec..1b8547499 100644 --- a/lib/grouplist.php +++ b/lib/grouplist.php @@ -164,10 +164,8 @@ class GroupList extends Widget # XXX: special-case for user looking at own # subscriptions page if ($user->isMember($this->group)) { - if (!$user->isAdmin($this->group)) { - $lf = new LeaveForm($this->out, $this->group); - $lf->show(); - } + $lf = new LeaveForm($this->out, $this->group); + $lf->show(); } else { $jf = new JoinForm($this->out, $this->group); $jf->show(); -- cgit v1.2.3-54-g00ecf From 2133d5a4e7fc694b097fe65282e557d99ee109ad Mon Sep 17 00:00:00 2001 From: CiaranG Date: Sun, 8 Mar 2009 16:16:10 +0000 Subject: PostgreSQL - some more fixes to make queries compatible with both databases. (submitted by oxygene) --- actions/postnotice.php | 2 +- actions/twittersettings.php | 8 ++++---- lib/jabber.php | 4 ++-- lib/util.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/actions/postnotice.php b/actions/postnotice.php index 0b4735296..c32d8ca94 100644 --- a/actions/postnotice.php +++ b/actions/postnotice.php @@ -79,7 +79,7 @@ class PostnoticeAction extends Action } $notice = Notice::staticGet('uri', $notice_uri); if (!$notice) { - $notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, 0, $notice_uri); + $notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, null, $notice_uri); if (is_string($notice)) { common_server_serror($notice, 500); return false; diff --git a/actions/twittersettings.php b/actions/twittersettings.php index a79859bbf..45725d3ff 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -186,12 +186,12 @@ class TwittersettingsAction extends ConnectSettingsAction $current_user = common_current_user(); - $qry = 'SELECT user.* ' . + $qry = 'SELECT "user".* ' . 'FROM subscription ' . - 'JOIN user ON subscription.subscribed = user.id ' . - 'JOIN foreign_link ON foreign_link.user_id = user.id ' . + 'JOIN "user" ON subscription.subscribed = "user".id ' . + 'JOIN foreign_link ON foreign_link.user_id = "user".id ' . 'WHERE subscriber = %d ' . - 'ORDER BY user.nickname'; + 'ORDER BY "user".nickname'; $user = new User(); diff --git a/lib/jabber.php b/lib/jabber.php index 3fbb3e1ab..3cd3b0d37 100644 --- a/lib/jabber.php +++ b/lib/jabber.php @@ -410,8 +410,8 @@ function jabber_broadcast_notice($notice) "ON $UT.id = notice_inbox.user_id " . 'WHERE notice_inbox.notice_id = ' . $notice->id . ' ' . 'AND notice_inbox.source = 2 ' . - 'AND user.jabber is not null ' . - 'AND user.jabbernotify = 1 '); + "AND $UT.jabber is not null " . + "AND $UT.jabbernotify = 1 "); while ($user->fetch()) { if (!array_key_exists($user->id, $sent_to)) { diff --git a/lib/util.php b/lib/util.php index ca8376f28..221175ccd 100644 --- a/lib/util.php +++ b/lib/util.php @@ -688,7 +688,7 @@ function common_relative_profile($sender, $nickname, $dt=null) $recipient = new Profile(); // XXX: use a join instead of a subquery $recipient->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$sender->id.' and subscribed = id)', 'AND'); - $recipient->whereAdd('nickname = "' . trim($nickname) . '"', 'AND'); + $recipient->whereAdd("nickname = '" . trim($nickname) . "'", 'AND'); if ($recipient->find(true)) { // XXX: should probably differentiate between profiles with // the same name by date of most recent update @@ -698,7 +698,7 @@ function common_relative_profile($sender, $nickname, $dt=null) $recipient = new Profile(); // XXX: use a join instead of a subquery $recipient->whereAdd('EXISTS (SELECT subscriber from subscription where subscribed = '.$sender->id.' and subscriber = id)', 'AND'); - $recipient->whereAdd('nickname = "' . trim($nickname) . '"', 'AND'); + $recipient->whereAdd("nickname = '" . trim($nickname) . "'", 'AND'); if ($recipient->find(true)) { // XXX: should probably differentiate between profiles with // the same name by date of most recent update -- cgit v1.2.3-54-g00ecf From e55808698bedb489e8f9b6d46a81dceb0e32e07d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 8 Mar 2009 11:49:34 -0700 Subject: use call_user_func for callbacks --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 221175ccd..ca9006d64 100644 --- a/lib/util.php +++ b/lib/util.php @@ -467,7 +467,7 @@ function common_replace_urls_callback($text, $callback) { $url = (mb_strpos($orig_url, htmlspecialchars($url)) === FALSE) ? $url:htmlspecialchars($url); // Call user specified func - $modified_url = $callback($url); + $modified_url = call_user_func($callback, $url); // Replace it! $start = mb_strpos($text, $url, $offset); -- cgit v1.2.3-54-g00ecf From c8b10381a9157144f8c92dede1ebabc6b05390c0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 8 Mar 2009 01:54:21 +0100 Subject: Add subedit to the main/ routes. --- lib/router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/router.php b/lib/router.php index 52051fdb5..902f25d8a 100644 --- a/lib/router.php +++ b/lib/router.php @@ -101,7 +101,7 @@ class Router $main = array('login', 'logout', 'register', 'subscribe', 'unsubscribe', 'confirmaddress', 'recoverpassword', 'invite', 'favor', 'disfavor', 'sup', - 'block'); + 'block', 'subedit'); foreach ($main as $a) { $m->connect('main/'.$a, array('action' => $a)); -- cgit v1.2.3-54-g00ecf From e8e40439961160989c32e1cd661ecce94b75fcee Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 8 Mar 2009 17:04:48 +0100 Subject: Typo in lib/omb.php updateprofile request handling. --- lib/omb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/omb.php b/lib/omb.php index befcf4666..c302a7b64 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -295,7 +295,7 @@ function omb_update_profile($profile, $remote_profile, $subscription) common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__); - if (empty($result) || $result) { + if (empty($result) || !$result) { common_debug("Unable to contact " . $req->get_normalized_http_url()); } else if ($result->status == 403) { # not authorized, don't send again common_debug('403 result, deleting subscription', __FILE__); -- cgit v1.2.3-54-g00ecf From fbe794e44d235d2f66ef418796f87947631afb6a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 3 Mar 2009 16:12:05 +0100 Subject: Improve handling of null values in profile parameters. This commit fixes two issues: - Allowing remote users to clear profile parameters via OMB. - Improved handling of profile parameters which evaluate to false ('0' for example) --- actions/finishremotesubscribe.php | 8 ++++---- actions/remotesubscribe.php | 8 ++++---- actions/updateprofile.php | 14 ++++++++------ actions/userauthorization.php | 26 +++++++++++++------------- lib/profilelist.php | 10 +++++----- 5 files changed, 34 insertions(+), 32 deletions(-) (limited to 'lib') diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index acfacbdc1..eaf57c2d8 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -136,16 +136,16 @@ class FinishremotesubscribeAction extends Action $profile->nickname = $nickname; $profile->profileurl = $profile_url; - if ($fullname) { + if (!is_null($fullname)) { $profile->fullname = $fullname; } - if ($homepage) { + if (!is_null($homepage)) { $profile->homepage = $homepage; } - if ($bio) { + if (!is_null($bio)) { $profile->bio = $bio; } - if ($location) { + if (!is_null($location)) { $profile->location = $location; } diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index 7ea7acd6d..a2e01bd3a 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -367,16 +367,16 @@ class RemotesubscribeAction extends Action return; } - if ($profile->fullname) { + if (!is_null($profile->fullname)) { $req->set_parameter('omb_listenee_fullname', $profile->fullname); } - if ($profile->homepage) { + if (!is_null($profile->homepage)) { $req->set_parameter('omb_listenee_homepage', $profile->homepage); } - if ($profile->bio) { + if (!is_null($profile->bio)) { $req->set_parameter('omb_listenee_bio', $profile->bio); } - if ($profile->location) { + if (!is_null($profile->location)) { $req->set_parameter('omb_listenee_location', $profile->location); } $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 2268c432f..7dc52fda9 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -138,22 +138,24 @@ class UpdateprofileAction extends Action $orig_profile = clone($profile); - if ($nickname) { + /* Use values even if they are an empty string. Parsing an empty string in + updateProfile is the specified way of clearing a parameter in OMB. */ + if (!is_null($nickname)) { $profile->nickname = $nickname; } - if ($profile_url) { + if (!is_null($profile_url)) { $profile->profileurl = $profile_url; } - if ($fullname) { + if (!is_null($fullname)) { $profile->fullname = $fullname; } - if ($homepage) { + if (!is_null($homepage)) { $profile->homepage = $homepage; } - if ($bio) { + if (!is_null($bio)) { $profile->bio = $bio; } - if ($location) { + if (!is_null($location)) { $profile->location = $location; } diff --git a/actions/userauthorization.php b/actions/userauthorization.php index 0566b4b70..6a76e3a4c 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -113,9 +113,9 @@ class UserauthorizationAction extends Action $this->element('a', array('href' => $profile, 'class' => 'external profile nickname'), $nickname); - if ($fullname) { + if (!is_null($fullname)) { $this->elementStart('div', 'fullname'); - if ($homepage) { + if (!is_null($homepage)) { $this->element('a', array('href' => $homepage), $fullname); } else { @@ -123,10 +123,10 @@ class UserauthorizationAction extends Action } $this->elementEnd('div'); } - if ($location) { + if (!is_null($location)) { $this->element('div', 'location', $location); } - if ($bio) { + if (!is_null($bio)) { $this->element('div', 'bio', $bio); } $this->elementStart('div', 'license'); @@ -179,16 +179,16 @@ class UserauthorizationAction extends Action $params['omb_listener_nickname'] = $user->nickname; $params['omb_listener_profile'] = common_local_url('showstream', array('nickname' => $user->nickname)); - if ($profile->fullname) { + if (!is_null($profile->fullname)) { $params['omb_listener_fullname'] = $profile->fullname; } - if ($profile->homepage) { + if (!is_null($profile->homepage)) { $params['omb_listener_homepage'] = $profile->homepage; } - if ($profile->bio) { + if (!is_null($profile->bio)) { $params['omb_listener_bio'] = $profile->bio; } - if ($profile->location) { + if (!is_null($profile->location)) { $params['omb_listener_location'] = $profile->location; } $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); @@ -267,16 +267,16 @@ class UserauthorizationAction extends Action $profile->nickname = $nickname; $profile->profileurl = $profile_url; - if ($fullname) { + if (!is_null($fullname)) { $profile->fullname = $fullname; } - if ($homepage) { + if (!is_null($homepage)) { $profile->homepage = $homepage; } - if ($bio) { + if (!is_null($bio)) { $profile->bio = $bio; } - if ($location) { + if (!is_null($location)) { $profile->location = $location; } @@ -409,7 +409,7 @@ class UserauthorizationAction extends Action 'omb_listenee_profile', 'omb_listenee_nickname', 'omb_listenee_license') as $param) { - if (!$req->get_parameter($param)) { + if (is_null($req->get_parameter($param))) { throw new OAuthException("Required parameter '$param' not found"); } } diff --git a/lib/profilelist.php b/lib/profilelist.php index c2040fbc2..75053b7a4 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -102,13 +102,13 @@ class ProfileList extends Widget 'alt' => ($this->profile->fullname) ? $this->profile->fullname : $this->profile->nickname)); - $hasFN = ($this->profile->fullname) ? 'nickname' : 'fn nickname'; + $hasFN = ($this->profile->fullname !== '') ? 'nickname' : 'fn nickname'; $this->out->elementStart('span', $hasFN); $this->out->raw($this->highlight($this->profile->nickname)); $this->out->elementEnd('span'); $this->out->elementEnd('a'); - if ($this->profile->fullname) { + if ($this->profile->fullname !== '') { $this->out->elementStart('dl', 'entity_fn'); $this->out->element('dt', null, 'Full name'); $this->out->elementStart('dd'); @@ -118,7 +118,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->location) { + if ($this->profile->location !== '') { $this->out->elementStart('dl', 'entity_location'); $this->out->element('dt', null, _('Location')); $this->out->elementStart('dd', 'label'); @@ -126,7 +126,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->homepage) { + if ($this->profile->homepage !== '') { $this->out->elementStart('dl', 'entity_url'); $this->out->element('dt', null, _('URL')); $this->out->elementStart('dd'); @@ -137,7 +137,7 @@ class ProfileList extends Widget $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); } - if ($this->profile->bio) { + if ($this->profile->bio !== '') { $this->out->elementStart('dl', 'entity_note'); $this->out->element('dt', null, _('Note')); $this->out->elementStart('dd', 'note'); -- cgit v1.2.3-54-g00ecf From 945bbf00dc9ee106359e9387956c72c1290d12fc Mon Sep 17 00:00:00 2001 From: CiaranG Date: Mon, 9 Mar 2009 20:24:56 +0000 Subject: PostgreSQL - a couple more GROUP BY queries that needed to be explicit --- actions/favorited.php | 2 +- lib/topposterssection.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/actions/favorited.php b/actions/favorited.php index 5082f4a4e..231b97897 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -178,7 +178,7 @@ class FavoritedAction extends Action $qry = 'SELECT notice.*, '. $weightexpr . ' as weight ' . 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . - 'GROUP BY fave.notice_id ' . + 'GROUP BY id,profile_id,uri,content,rendered,url,created,notice.modified,reply_to,is_local,source ' . 'ORDER BY weight DESC'; $offset = ($this->page - 1) * NOTICES_PER_PAGE; diff --git a/lib/topposterssection.php b/lib/topposterssection.php index 4bd59ac79..1a2ce0014 100644 --- a/lib/topposterssection.php +++ b/lib/topposterssection.php @@ -51,7 +51,7 @@ class TopPostersSection extends ProfileSection $qry = 'SELECT profile.*, count(*) as value ' . 'FROM profile JOIN notice ON profile.id = notice.profile_id ' . (common_config('public', 'localonly') ? 'WHERE is_local = 1 ' : '') . - 'GROUP BY profile.id ' . + 'GROUP BY profile.id,nickname,fullname,profileurl,homepage,bio,location,profile.created,profile.modified,textsearch ' . 'ORDER BY value DESC '; $limit = PROFILES_PER_SECTION; -- cgit v1.2.3-54-g00ecf From c6cd87c106b763ed5610dae64e5a02ba86609ece Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Mon, 9 Mar 2009 20:01:35 -0500 Subject: Changed all $config[][] calls to common_config() --- actions/finishopenidlogin.php | 3 +-- actions/noticesearchrss.php | 3 +-- actions/publicrss.php | 5 ++--- actions/remotesubscribe.php | 4 +--- lib/mail.php | 7 +++---- lib/omb.php | 1 - lib/searchaction.php | 4 +--- lib/twitter.php | 3 +-- lib/util.php | 11 ++++------- 9 files changed, 14 insertions(+), 27 deletions(-) (limited to 'lib') diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php index 6d92cb9aa..52d9be29c 100644 --- a/actions/finishopenidlogin.php +++ b/actions/finishopenidlogin.php @@ -62,9 +62,8 @@ class FinishopenidloginAction extends Action if ($this->error) { $this->element('div', array('class' => 'error'), $this->error); } else { - global $config; $this->element('div', 'instructions', - sprintf(_('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), $config['site']['name'])); + sprintf(_('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name'))); } } diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php index 7172977ee..0f98ed04b 100644 --- a/actions/noticesearchrss.php +++ b/actions/noticesearchrss.php @@ -82,10 +82,9 @@ class NoticesearchrssAction extends Rss10Action function getChannel() { - global $config; $q = $this->trimmed('q'); $c = array('url' => common_local_url('noticesearchrss', array('q' => $q)), - 'title' => $config['site']['name'] . sprintf(_(' Search Stream for "%s"'), $q), + 'title' => common_config('site', 'name') . sprintf(_(' Search Stream for "%s"'), $q), 'link' => common_local_url('noticesearch', array('q' => $q)), 'description' => sprintf(_('All updates matching search term "%s"'), $q)); return $c; diff --git a/actions/publicrss.php b/actions/publicrss.php index c35877997..77e26e0f4 100644 --- a/actions/publicrss.php +++ b/actions/publicrss.php @@ -84,12 +84,11 @@ class PublicrssAction extends Rss10Action */ function getChannel() { - global $config; $c = array( 'url' => common_local_url('publicrss') - , 'title' => sprintf(_('%s Public Stream'), $config['site']['name']) + , 'title' => sprintf(_('%s Public Stream'), common_config('site', 'name')) , 'link' => common_local_url('public') - , 'description' => sprintf(_('All updates for %s'), $config['site']['name'])); + , 'description' => sprintf(_('All updates for %s'), common_config('site', 'name'))); return $c; } diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index a2e01bd3a..af130f425 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -333,8 +333,6 @@ class RemotesubscribeAction extends Action function requestAuthorization($user, $omb, $token, $secret) { - global $config; # for license URL - $con = omb_oauth_consumer(); $tok = new OAuthToken($token, $secret); @@ -358,7 +356,7 @@ class RemotesubscribeAction extends Action $req->set_parameter('omb_listenee', $user->uri); $req->set_parameter('omb_listenee_profile', common_profile_url($user->nickname)); $req->set_parameter('omb_listenee_nickname', $user->nickname); - $req->set_parameter('omb_listenee_license', $config['license']['url']); + $req->set_parameter('omb_listenee_license', common_config('license', 'url')); $profile = $user->getProfile(); if (!$profile) { diff --git a/lib/mail.php b/lib/mail.php index 9fa86de5c..dde7571eb 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -50,10 +50,9 @@ function mail_backend() static $backend = null; if (!$backend) { - global $config; - $backend = Mail::factory($config['mail']['backend'], - ($config['mail']['params']) ? - $config['mail']['params'] : + $backend = Mail::factory(common_config('mail', 'backend'), + (common_config('mail', 'params')) ? + common_config('mail', 'params') : array()); if (PEAR::isError($backend)) { common_server_error($backend->getMessage(), 500); diff --git a/lib/omb.php b/lib/omb.php index c302a7b64..878c735da 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -251,7 +251,6 @@ function omb_broadcast_profile($profile) function omb_update_profile($profile, $remote_profile, $subscription) { - global $config; # for license URL $user = User::staticGet($profile->id); $con = omb_oauth_consumer(); $token = new OAuthToken($subscription->token, $subscription->secret); diff --git a/lib/searchaction.php b/lib/searchaction.php index df6876445..c762db16f 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -110,8 +110,6 @@ class SearchAction extends Action function showForm($error=null) { - global $config; - $q = $this->trimmed('q'); $page = $this->trimmed('page', 1); $this->elementStart('form', array('method' => 'get', @@ -122,7 +120,7 @@ class SearchAction extends Action $this->element('legend', null, _('Search site')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); - if (!isset($config['site']['fancy']) || !$config['site']['fancy']) { + if (!common_config('site', 'fancy')) { $this->hidden('action', $this->trimmed('action')); } $this->input('q', 'Keyword(s)', $q); diff --git a/lib/twitter.php b/lib/twitter.php index deb6fd276..a3929524b 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -224,7 +224,6 @@ function is_twitter_bound($notice, $flink) { function broadcast_twitter($notice) { - global $config; $success = true; $flink = Foreign_link::getByUserID($notice->profile_id, @@ -248,7 +247,7 @@ function broadcast_twitter($notice) CURLOPT_POSTFIELDS => array( 'status' => $statustxt, - 'source' => $config['integration']['source'] + 'source' => common_config('integration', 'source') ), CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true, diff --git a/lib/util.php b/lib/util.php index ca9006d64..6341438ca 100644 --- a/lib/util.php +++ b/lib/util.php @@ -72,8 +72,7 @@ function common_timezone() } } - global $config; - return $config['site']['timezone']; + return common_config('site', 'timezone'); } function common_language() @@ -737,9 +736,8 @@ function common_local_url($action, $args=null, $params=null, $fragment=null) function common_path($relative) { - global $config; - $pathpart = ($config['site']['path']) ? $config['site']['path']."/" : ''; - return "http://".$config['site']['server'].'/'.$pathpart.$relative; + $pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : ''; + return "http://".common_config('site', 'server').'/'.$pathpart.$relative; } function common_date_string($dt) @@ -992,8 +990,7 @@ function common_ensure_syslog() { static $initialized = false; if (!$initialized) { - global $config; - openlog($config['syslog']['appname'], 0, LOG_USER); + openlog(common_config('syslog', 'appname'), 0, LOG_USER); $initialized = true; } } -- cgit v1.2.3-54-g00ecf From 91980c73a76bcbedd5f23a3232988a32aa8c7127 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 10 Mar 2009 16:15:57 -0700 Subject: Updates to the API to improve Atom feeds --- actions/twitapidirect_messages.php | 22 +++++--- actions/twitapifavorites.php | 14 +++-- actions/twitapistatuses.php | 53 +++++++++++++------ lib/common.php | 3 +- lib/router.php | 8 +-- lib/twitterapi.php | 103 ++++++++----------------------------- 6 files changed, 90 insertions(+), 113 deletions(-) (limited to 'lib') diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index ce98bf6ec..7101db8df 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -38,7 +38,6 @@ class Twitapidirect_messagesAction extends TwitterapiAction function show_messages($args, $apidata, $type) { - $user = $apidata['user']; $count = $this->arg('count'); @@ -102,7 +101,17 @@ class Twitapidirect_messagesAction extends TwitterapiAction $this->show_rss_dmsgs($message, $title, $link, $subtitle); break; case 'atom': - $this->show_atom_dmsgs($message, $title, $link, $subtitle); + $selfuri = common_root_url() . 'api/direct_messages'; + $selfuri .= ($type == 'received') ? '.atom' : '/sent.atom'; + $taguribase = common_config('integration', 'taguri'); + + if ($type == 'sent') { + $id = "tag:$taguribase:SentDirectMessages:" . $user->id; + } else { + $id = "tag:$taguribase:DirectMessages:" . $user->id; + } + + $this->show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id); break; case 'json': $this->show_json_dmsgs($message); @@ -261,16 +270,17 @@ class Twitapidirect_messagesAction extends TwitterapiAction } - function show_atom_dmsgs($message, $title, $link, $subtitle) + function show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id) { $this->init_document('atom'); $this->element('title', null, $title); - $siteserver = common_config('site', 'server'); - $this->element('id', null, "tag:$siteserver,2008:DirectMessage"); + $this->element('id', null, $id); $this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null); - $this->element('updated', null, common_date_iso8601(strftime('%c'))); + $this->element('link', array('href' => $selfuri, 'rel' => 'self', + 'type' => 'application/atom+xml'), null); + $this->element('updated', null, common_date_iso8601('now')); $this->element('subtitle', null, $subtitle); if (is_array($message)) { diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php index 737b7229f..31dce341b 100644 --- a/actions/twitapifavorites.php +++ b/actions/twitapifavorites.php @@ -61,10 +61,9 @@ class TwitapifavoritesAction extends TwitterapiAction } $sitename = common_config('site', 'name'); - $siteserver = common_config('site', 'server'); - $title = sprintf(_('%s / Favorites from %s'), $sitename, $user->nickname); - $id = "tag:$siteserver:favorites:".$user->id; + $taguribase = common_config('integration', 'taguri'); + $id = "tag:$taguribase:Favorites:".$user->id; $link = common_local_url('favorites', array('nickname' => $user->nickname)); $subtitle = sprintf(_('%s updates favorited by %s / %s.'), $sitename, $profile->getBestName(), $user->nickname); @@ -76,7 +75,14 @@ class TwitapifavoritesAction extends TwitterapiAction $this->show_rss_timeline($notice, $title, $link, $subtitle); break; case 'atom': - $this->show_atom_timeline($notice, $title, $id, $link, $subtitle); + if (isset($apidata['api_arg'])) { + $selfuri = $selfuri = common_root_url() . + 'api/favorites/' . $apidata['api_arg'] . '.atom'; + } else { + $selfuri = $selfuri = common_root_url() . + 'api/favorites.atom'; + } + $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri); break; case 'json': $this->show_json_timeline($notice); diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index 63e29068b..b50a17abd 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -29,10 +29,12 @@ class TwitapistatusesAction extends TwitterapiAction parent::handle($args); $sitename = common_config('site', 'name'); - $siteserver = common_config('site', 'server'); $title = sprintf(_("%s public timeline"), $sitename); - $id = "tag:$siteserver:Statuses"; + + $taguribase = common_config('integration', 'taguri'); + $id = "tag:$taguribase:PublicTimeline"; $link = common_root_url(); + $subtitle = sprintf(_("%s updates from everyone!"), $sitename); // Number of public statuses to return by default -- Twitter sends 20 @@ -70,7 +72,8 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_rss_timeline($notice, $title, $link, $subtitle); break; case 'atom': - $this->show_atom_timeline($notice, $title, $id, $link, $subtitle); + $selfuri = common_root_url() . 'api/statuses/public_timeline.atom'; + $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri); break; case 'json': $this->show_json_timeline($notice); @@ -114,7 +117,6 @@ class TwitapistatusesAction extends TwitterapiAction } $since = strtotime($this->arg('since')); - $user = $this->get_user($apidata['api_arg'], $apidata); $this->auth_user = $user; @@ -124,12 +126,10 @@ class TwitapistatusesAction extends TwitterapiAction } $profile = $user->getProfile(); - $sitename = common_config('site', 'name'); - $siteserver = common_config('site', 'server'); - $title = sprintf(_("%s and friends"), $user->nickname); - $id = "tag:$siteserver:friends:" . $user->id; + $taguribase = common_config('integration', 'taguri'); + $id = "tag:$taguribase:FriendsTimeline:" . $user->id; $link = common_local_url('all', array('nickname' => $user->nickname)); $subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'), $user->nickname, $sitename); @@ -143,7 +143,14 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_rss_timeline($notice, $title, $link, $subtitle); break; case 'atom': - $this->show_atom_timeline($notice, $title, $id, $link, $subtitle); + if (isset($apidata['api_arg'])) { + $selfuri = $selfuri = common_root_url() . + 'api/statuses/friends_timeline/' . $apidata['api_arg'] . '.atom'; + } else { + $selfuri = $selfuri = common_root_url() . + 'api/statuses/friends_timeline.atom'; + } + $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri); break; case 'json': $this->show_json_timeline($notice); @@ -199,10 +206,9 @@ class TwitapistatusesAction extends TwitterapiAction $since = strtotime($this->arg('since')); $sitename = common_config('site', 'name'); - $siteserver = common_config('site', 'server'); - $title = sprintf(_("%s timeline"), $user->nickname); - $id = "tag:$siteserver:user:".$user->id; + $taguribase = common_config('integration', 'taguri'); + $id = "tag:$taguribase:UserTimeline:".$user->id; $link = common_local_url('showstream', array('nickname' => $user->nickname)); $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename); @@ -224,7 +230,14 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_rss_timeline($notice, $title, $link, $subtitle, $suplink); break; case 'atom': - $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink); + if (isset($apidata['api_arg'])) { + $selfuri = $selfuri = common_root_url() . + 'api/statuses/user_timeline/' . $apidata['api_arg'] . '.atom'; + } else { + $selfuri = $selfuri = common_root_url() . + 'api/statuses/user_timeline.atom'; + } + $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri); break; case 'json': $this->show_json_timeline($notice); @@ -347,10 +360,9 @@ class TwitapistatusesAction extends TwitterapiAction $profile = $user->getProfile(); $sitename = common_config('site', 'name'); - $siteserver = common_config('site', 'server'); - $title = sprintf(_('%1$s / Updates replying to %2$s'), $sitename, $user->nickname); - $id = "tag:$siteserver:replies:".$user->id; + $taguribase = common_config('integration', 'taguri'); + $id = "tag:$taguribase:Replies:".$user->id; $link = common_local_url('replies', array('nickname' => $user->nickname)); $subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $user->nickname, $profile->getBestName()); @@ -388,7 +400,14 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_rss_timeline($notices, $title, $link, $subtitle); break; case 'atom': - $this->show_atom_timeline($notices, $title, $id, $link, $subtitle); + if (isset($apidata['api_arg'])) { + $selfuri = $selfuri = common_root_url() . + 'api/statuses/replies/' . $apidata['api_arg'] . '.atom'; + } else { + $selfuri = $selfuri = common_root_url() . + 'api/statuses/replies.atom'; + } + $this->show_atom_timeline($notices, $title, $id, $link, $subtitle, null, $selfuri); break; case 'json': $this->show_json_timeline($notices); diff --git a/lib/common.php b/lib/common.php index 917fdeafa..c3d697aee 100644 --- a/lib/common.php +++ b/lib/common.php @@ -140,7 +140,8 @@ $config = 'user' => false, 'group' => false), 'integration' => - array('source' => 'Laconica'), # source attribute for Twitter + array('source' => 'Laconica', # source attribute for Twitter + 'taguri' => $_server.',2009'), # base for tag URIs 'memcached' => array('enabled' => false, 'server' => 'localhost', diff --git a/lib/router.php b/lib/router.php index 902f25d8a..50d5a4ee1 100644 --- a/lib/router.php +++ b/lib/router.php @@ -226,7 +226,7 @@ class Router $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(user_timeline|friends_timeline|show|destroy|friends|followers)')); + array('method' => '(user_timeline|friends_timeline|replies|show|destroy|friends|followers)')); // users @@ -257,7 +257,7 @@ class Router } foreach (array('xml', 'json', 'rss', 'atom') as $e) { - $m->connect('api/direct_message/sent.'.$e, + $m->connect('api/direct_messages/sent.'.$e, array('action' => 'api', 'apiaction' => 'direct_messages', 'method' => 'sent.'.$e)); @@ -277,7 +277,7 @@ class Router $m->connect('api/friendships/:method', array('action' => 'api', 'apiaction' => 'friendships'), - array('method' => 'exists(\.(xml|json|rss|atom))')); + array('method' => 'exists(\.(xml|json))')); // Social graph @@ -360,7 +360,7 @@ class Router // user stuff - foreach (array('subscriptions', 'subscribers', + foreach (array('subscriptions', 'subscribers', 'nudge', 'xrds', 'all', 'foaf', 'replies', 'inbox', 'outbox', 'microsummary') as $a) { $m->connect(':nickname/'.$a, diff --git a/lib/twitterapi.php b/lib/twitterapi.php index 1de169a0b..e7239acd5 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -127,8 +127,6 @@ class TwitterapiAction extends Action { $profile = $notice->getProfile(); - - $server = common_config('site', 'server'); $entry = array(); # We trim() to avoid extraneous whitespace in the output @@ -137,8 +135,12 @@ class TwitterapiAction extends Action $entry['title'] = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content)); $entry['link'] = common_local_url('shownotice', array('notice' => $notice->id)); $entry['published'] = common_date_iso8601($notice->created); - $entry['id'] = "tag:$server,2008:$entry[link]"; + + $taguribase = common_config('integration', 'taguri'); + $entry['id'] = "tag:$taguribase:$entry[link]"; + $entry['updated'] = $entry['published']; + $entry['author'] = $profile->getBestName(); # RSS Item specific $entry['description'] = $entry['content']; @@ -151,7 +153,6 @@ class TwitterapiAction extends Action function twitter_rss_dmsg_array($message) { - $server = common_config('site', 'server'); $entry = array(); $entry['title'] = sprintf('Message from %s to %s', @@ -160,8 +161,12 @@ class TwitterapiAction extends Action $entry['content'] = common_xml_safe_str(trim($message->content)); $entry['link'] = common_local_url('showmessage', array('message' => $message->id)); $entry['published'] = common_date_iso8601($message->created); - $entry['id'] = "tag:$server,2008:$entry[link]"; + + $taguribase = common_config('integration', 'taguri'); + + $entry['id'] = "tag:$taguribase,:$entry[link]"; $entry['updated'] = $entry['published']; + $entry['author'] = $message->getFrom()->getBestName(); # RSS Item specific $entry['description'] = $entry['content']; @@ -242,6 +247,9 @@ class TwitterapiAction extends Action $this->element('published', null, $entry['published']); $this->element('updated', null, $entry['updated']); $this->element('link', array('href' => $entry['link'], 'rel' => 'alternate', 'type' => 'text/html'), null); + $this->elementStart('author'); + $this->element('name', null, $entry['author']); + $this->elementEnd('author'); $this->elementEnd('entry'); } @@ -358,7 +366,7 @@ class TwitterapiAction extends Action $this->end_twitter_rss(); } - function show_atom_timeline($notice, $title, $id, $link, $subtitle=null, $suplink=null) + function show_atom_timeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null) { $this->init_document('atom'); @@ -366,12 +374,20 @@ class TwitterapiAction extends Action $this->element('title', null, $title); $this->element('id', null, $id); $this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null); + if (!is_null($suplink)) { # For FriendFeed's SUP protocol $this->element('link', array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'href' => $suplink, 'type' => 'application/json')); } + + if (!is_null($selfuri)) { + $this->element('link', array('href' => $selfuri, + 'rel' => 'self', 'type' => 'application/atom+xml'), null); + } + + $this->element('updated', null, common_date_iso8601('now')); $this->element('subtitle', null, $subtitle); if (is_array($notice)) { @@ -634,79 +650,4 @@ class TwitterapiAction extends Action return $source_name; } - function show_extended_profile($user, $apidata) - { - - $this->auth_user = $apidata['user']; - - $profile = $user->getProfile(); - - if (!$profile) { - common_server_error(_('User has no profile.')); - return; - } - - $twitter_user = $this->twitter_user_array($profile, true); - - // Add in extended user fields offered up by this method - $twitter_user['created_at'] = $this->date_twitter($profile->created); - - $subbed = DB_DataObject::factory('subscription'); - $subbed->subscriber = $profile->id; - $subbed_count = (int) $subbed->count() - 1; - - $notices = DB_DataObject::factory('notice'); - $notices->profile_id = $profile->id; - $notice_count = (int) $notices->count(); - - $twitter_user['friends_count'] = (is_int($subbed_count)) ? $subbed_count : 0; - $twitter_user['statuses_count'] = (is_int($notice_count)) ? $notice_count : 0; - - // Other fields Twitter sends... - $twitter_user['profile_background_color'] = ''; - $twitter_user['profile_text_color'] = ''; - $twitter_user['profile_link_color'] = ''; - $twitter_user['profile_sidebar_fill_color'] = ''; - - $faves = DB_DataObject::factory('fave'); - $faves->user_id = $user->id; - $faves_count = (int) $faves->count(); - $twitter_user['favourites_count'] = $faves_count; - - $timezone = 'UTC'; - - if ($user->timezone) { - $timezone = $user->timezone; - } - - $t = new DateTime; - $t->setTimezone(new DateTimeZone($timezone)); - $twitter_user['utc_offset'] = $t->format('Z'); - $twitter_user['time_zone'] = $timezone; - - $following = 'false'; - - if (isset($this->auth_user)) { - if ($this->auth_user->isSubscribed($profile)) { - $following = 'true'; - } - - // Not implemented yet - $twitter_user['notifications'] = 'false'; - } - - $twitter_user['following'] = $following; - - if ($apidata['content-type'] == 'xml') { - $this->init_document('xml'); - $this->show_twitter_xml_user($twitter_user); - $this->end_document('xml'); - } elseif ($apidata['content-type'] == 'json') { - $this->init_document('json'); - $this->show_json_objects($twitter_user); - $this->end_document('json'); - } - - } - } -- cgit v1.2.3-54-g00ecf From a547c5f642c23dd4f1c83b4a1500914c0ef1c861 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 6 Mar 2009 21:50:19 +0100 Subject: Fix array access on possibly undefined index. --- lib/omb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/omb.php b/lib/omb.php index 878c735da..e8e1acc41 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -305,7 +305,7 @@ function omb_update_profile($profile, $remote_profile, $subscription) return false; } else { # success! parse_str($result->body, $return); - if ($return['omb_version'] == OMB_VERSION_01) { + if (isset($return['omb_version']) && $return['omb_version'] === OMB_VERSION_01) { return true; } else { return false; -- cgit v1.2.3-54-g00ecf From 00c14d22ded3868939f4999daa0a3c3e4203c20e Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 7 Mar 2009 01:43:55 +0100 Subject: Remove comparison with member variable of null variable, cleaned code a bit. --- lib/profilelist.php | 12 +++++------- lib/subgroupnav.php | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/profilelist.php b/lib/profilelist.php index 75053b7a4..898200d2d 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -89,6 +89,7 @@ class ProfileList extends Widget 'id' => 'profile-' . $this->profile->id)); $user = common_current_user(); + $is_own = !is_null($user) && ($user->id === $this->user->id); $this->out->elementStart('div', 'entity_profile vcard'); @@ -154,7 +155,7 @@ class ProfileList extends Widget $this->out->elementStart('dl', 'entity_tags'); $this->out->elementStart('dt'); - if ($user->id == $this->owner->id) { + if ($is_own) { $this->out->element('a', array('href' => common_local_url('tagother', array('id' => $this->profile->id))), _('Tags')); @@ -183,7 +184,7 @@ class ProfileList extends Widget $this->out->elementEnd('dl'); } - if ($user && $user->id == $this->owner->id) { + if ($is_own) { $this->showOwnerControls($this->profile); } @@ -193,11 +194,11 @@ class ProfileList extends Widget $this->out->elementStart('ul'); - if ($user && $user->id != $this->profile->id) { + if (!$is_own) { # XXX: special-case for user looking at own # subscriptions page $this->out->elementStart('li', 'entity_subscribe'); - if ($user->isSubscribed($this->profile)) { + if (!is_null($user) && $user->isSubscribed($this->profile)) { $usf = new UnsubscribeForm($this->out, $this->profile); $usf->show(); } else { @@ -206,9 +207,6 @@ class ProfileList extends Widget } $this->out->elementEnd('li'); $this->out->elementStart('li', 'entity_block'); - if ($user && $user->id == $this->owner->id) { - $this->showBlockForm(); - } $this->out->elementEnd('li'); } diff --git a/lib/subgroupnav.php b/lib/subgroupnav.php index 5fd8a72a2..31c3ea0b5 100644 --- a/lib/subgroupnav.php +++ b/lib/subgroupnav.php @@ -98,7 +98,7 @@ class SubGroupNav extends Widget $this->user->nickname), $action == 'usergroups', 'nav_usergroups'); - if ($this->user->id == $cur->id) { + if (!is_null($cur) && $this->user->id === $cur->id) { $this->out->menuItem(common_local_url('invite'), _('Invite'), sprintf(_('Invite friends and colleagues to join you on %s'), -- cgit v1.2.3-54-g00ecf From c0db74dcfbff431970ae1d829e776f466f1c4091 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 7 Mar 2009 02:03:45 +0100 Subject: Another undefined object member. --- lib/profilelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/profilelist.php b/lib/profilelist.php index 898200d2d..766189ab4 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -89,7 +89,7 @@ class ProfileList extends Widget 'id' => 'profile-' . $this->profile->id)); $user = common_current_user(); - $is_own = !is_null($user) && ($user->id === $this->user->id); + $is_own = !is_null($user) && isset($this->user) && ($user->id === $this->user->id); $this->out->elementStart('div', 'entity_profile vcard'); -- cgit v1.2.3-54-g00ecf From c0f44ca44d9530c3658d22c0b3ac311a60cbff6c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 7 Mar 2009 02:19:38 +0100 Subject: Check if that $_SERVER param is set before accessing. --- lib/action.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/action.php b/lib/action.php index 812df635e..45ce56ac0 100644 --- a/lib/action.php +++ b/lib/action.php @@ -819,9 +819,8 @@ class Action extends HTMLOutputter // lawsuit } if ($lm) { header('Last-Modified: ' . date(DATE_RFC1123, $lm)); - $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE']; - if ($if_modified_since) { - $ims = strtotime($if_modified_since); + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { + $ims = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); if ($lm <= $ims) { $if_none_match = $_SERVER['HTTP_IF_NONE_MATCH']; if (!$if_none_match || -- cgit v1.2.3-54-g00ecf From 048bc770777f325aea76315f44afedb2daf90f76 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 7 Mar 2009 23:22:57 +0100 Subject: Add nullcheck for foreign profile. --- lib/twitter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/twitter.php b/lib/twitter.php index a3929524b..7abb40151 100644 --- a/lib/twitter.php +++ b/lib/twitter.php @@ -210,7 +210,7 @@ function save_twitter_friends($user, $twitter_id, $screen_name, $password) function is_twitter_bound($notice, $flink) { // Check to see if notice should go to Twitter - if (($flink->noticesync & FOREIGN_NOTICE_SEND)) { + if ($flink->noticesync & FOREIGN_NOTICE_SEND) { // If it's not a Twitter-style reply, or if the user WANTS to send replies. if (!preg_match('/^@[a-zA-Z0-9_]{1,15}\b/u', $notice->content) || @@ -231,7 +231,7 @@ function broadcast_twitter($notice) // XXX: Not sure WHERE to check whether a notice should go to // Twitter. Should we even put in the queue if it shouldn't? --Zach - if (is_twitter_bound($notice, $flink)) { + if (!is_null($flink) && is_twitter_bound($notice, $flink)) { $fuser = $flink->getForeignUser(); $twitter_user = $fuser->nickname; -- cgit v1.2.3-54-g00ecf From 70d5fc46845804507640e354c9d9e06367a53fb0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 11 Mar 2009 16:21:10 -0400 Subject: Document the site-logo configuration option The configuration option for site logo wasn't well documented, so I added it to the README file, config.php.sample, and common.php. --- README | 2 ++ config.php.sample | 3 +++ lib/common.php | 1 + 3 files changed, 6 insertions(+) (limited to 'lib') diff --git a/README b/README index 07957c09e..1c2cbe681 100644 --- a/README +++ b/README @@ -884,6 +884,8 @@ notice: A plain string that will appear on every page. A good place be escaped. dupelimit: Time in which it's not OK for the same person to post the same notice; default = 60 seconds. +logo: URL of an image file to use as the logo for the site. Overrides + the logo in the theme, if any. db -- diff --git a/config.php.sample b/config.php.sample index e9052bbf9..529e86f15 100644 --- a/config.php.sample +++ b/config.php.sample @@ -37,6 +37,9 @@ $config['site']['path'] = 'laconica'; # Enables extra log information, for example full details of PEAR DB errors #$config['site']['logdebug'] = true; +#To set your own logo, overriding the one in the theme +#$config['site']['logo'] = '/mylogo.png'; + # This is a PEAR DB DSN, see http://pear.php.net/manual/en/package.database.db.intro-dsn.php # Set it to match your actual database diff --git a/lib/common.php b/lib/common.php index c3d697aee..7739d9475 100644 --- a/lib/common.php +++ b/lib/common.php @@ -73,6 +73,7 @@ $config = 'theme' => 'default', 'path' => $_path, 'logfile' => null, + 'logo' => null, 'logdebug' => false, 'fancy' => false, 'locale_path' => INSTALLDIR.'/locale', -- cgit v1.2.3-54-g00ecf From 254e5e502017dad767a6b57aa2c5c9422d6e02e5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 11 Mar 2009 22:28:42 -0400 Subject: Update README and version number Update the README and the version number for this release. --- README | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- lib/common.php | 2 +- 2 files changed, 47 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/README b/README index 1c2cbe681..a7798a26a 100644 --- a/README +++ b/README @@ -2,8 +2,8 @@ README ------ -Laconica 0.7.1 ("West of the Fields") -6 February 2009 +Laconica 0.7.2 ("Talk about the Passion") +11 March 2009 This is the README file for Laconica, the Open Source microblogging platform. It includes installation instructions, descriptions of @@ -71,8 +71,47 @@ for additional terms. New this version ================ -This is a minor bug-fix release since version 0.7.0, released Jan 29 -2009. Notable changes this version: +This is a minor bug-fix and feature release since version 0.7.1, +released Feb 9 2009. Notable changes this version: + +- First version of a web-based installer +- Use Net_URL_Mapper instead of mod_rewrite to map "fancy URLs", + for a much simpler installation and use of PATH_INFO on sites + that don't have mod_rewrite. +- A plugin framework for system events, to make it easier to build + server-side plugins. +- A plugin for Google Analytics +- A plugin to use blogspam.net to check notices for spam +- A plugin to send linkbacks for notices about blog posts +- Configurable check for duplicate notices in a specific time + period +- Better Atom feeds +- First implementation of Twitter Search API +- Add streamlined mobile device-friendly styles when enabled in config. +- A queue server for sending notices to Twitter +- A queue server for sending notices to Facebook +- A queue server for sending notices to a ping server +- Fixed a bug in nonces for OAuth in OpenMicroBlogging +- Fixed bugs in transfer of avatars in OpenMicroBlogging +- @-links go to permalinks for local users +- Better handling of DB errors (instead of dreaded DB_DataObject blank + screen) +- Initial version of an RPM spec file +- More consistent display of notices in notice search +- A stylesheet for printed output +- "Social graph" methods for Twitter API +- Documentation for the JavaScript badge +- Debugged a ton of problems that happened with E_NOTICE on +- Better caching in RSS feeds +- Optionally send email when an @-message is received +- Automatically add tags for every group message +- Add framebusting JavaScript to help avoid clickjacking attacks. +- Optionally ignore some notice sources for public page. +- Add default SMS carriers and notice sources to distribution file. +- Change titles to use mixed case instead of all uppercase. +- Use exceptions for error handling. + +Changes in version 0.7.1: - Vast improvement in auto-linking to URLs. - Link to group search from user's group page @@ -1228,6 +1267,9 @@ if anyone's been overlooked in error. * Ken Sheppardson (Trac server, man-about-town) * Tiago 'gouki' Faria (i18n managerx) * Sean Murphy +* Leslie Michael Orchard +* Eric Helgeson +* Ken Sedgwick Thanks also to the developers of our upstream library code and to the thousands of people who have tried out Identi.ca, installed Laconi.ca, diff --git a/lib/common.php b/lib/common.php index 7739d9475..44ed270d7 100644 --- a/lib/common.php +++ b/lib/common.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -define('LACONICA_VERSION', '0.7.1'); +define('LACONICA_VERSION', '0.7.2'); define('AVATAR_PROFILE_SIZE', 96); define('AVATAR_STREAM_SIZE', 48); -- cgit v1.2.3-54-g00ecf From e185c0395a6cd250ccd7c8e385c54830be73f937 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 12 Mar 2009 00:13:28 -0400 Subject: Revert "trac #201 Add flowplayer to enable multimedia playback capability." This reverts commit 9c9b6790ce78296c0b182f03b5f6f2c035e43a7c. This code wasn't ready for release, so I've reverted it for now. Conflicts: lib/action.php lib/util.php --- bin/flowplayer-3.0.5.swf | Bin 92317 -> 0 bytes bin/flowplayer.audio-3.0.3.swf | Bin 2756 -> 0 bytes bin/flowplayer.controls-3.0.3.swf | Bin 15977 -> 0 bytes js/flowplayer-3.0.5.min.js | 24 ------------------------ js/jquery.simplemodal-1.2.2.pack.js | 8 -------- js/video.js | 9 --------- lib/action.php | 18 ------------------ lib/util.php | 6 ------ theme/base/css/modal.css | 22 ---------------------- theme/base/css/modal_ie.css | 16 ---------------- theme/base/images/x.png | Bin 1066 -> 0 bytes 11 files changed, 103 deletions(-) delete mode 100644 bin/flowplayer-3.0.5.swf delete mode 100644 bin/flowplayer.audio-3.0.3.swf delete mode 100644 bin/flowplayer.controls-3.0.3.swf delete mode 100644 js/flowplayer-3.0.5.min.js delete mode 100644 js/jquery.simplemodal-1.2.2.pack.js delete mode 100644 js/video.js delete mode 100644 theme/base/css/modal.css delete mode 100644 theme/base/css/modal_ie.css delete mode 100644 theme/base/images/x.png (limited to 'lib') diff --git a/bin/flowplayer-3.0.5.swf b/bin/flowplayer-3.0.5.swf deleted file mode 100644 index 05b64a032..000000000 Binary files a/bin/flowplayer-3.0.5.swf and /dev/null differ diff --git a/bin/flowplayer.audio-3.0.3.swf b/bin/flowplayer.audio-3.0.3.swf deleted file mode 100644 index ef85f1bff..000000000 Binary files a/bin/flowplayer.audio-3.0.3.swf and /dev/null differ diff --git a/bin/flowplayer.controls-3.0.3.swf b/bin/flowplayer.controls-3.0.3.swf deleted file mode 100644 index 09a27e8a9..000000000 Binary files a/bin/flowplayer.controls-3.0.3.swf and /dev/null differ diff --git a/js/flowplayer-3.0.5.min.js b/js/flowplayer-3.0.5.min.js deleted file mode 100644 index b1c33150a..000000000 --- a/js/flowplayer-3.0.5.min.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * flowplayer.js 3.0.5. The Flowplayer API - * - * Copyright 2009 Flowplayer Oy - * - * This file is part of Flowplayer. - * - * Flowplayer is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Flowplayer is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Flowplayer. If not, see . - * - * Version: 3.0.5 - Tue Feb 03 2009 13:14:17 GMT-0000 (GMT+00:00) - */ -(function(){function log(args){console.log("$f.fireEvent",[].slice.call(args));}function clone(obj){if(!obj||typeof obj!='object'){return obj;}var temp=new obj.constructor();for(var key in obj){if(obj.hasOwnProperty(key)){temp[key]=clone(obj[key]);}}return temp;}function each(obj,fn){if(!obj){return;}var name,i=0,length=obj.length;if(length===undefined){for(name in obj){if(fn.call(obj[name],name,obj[name])===false){break;}}}else{for(var value=obj[0];i1){var swf=arguments[1];var conf=(arguments.length==3)?arguments[2]:{};if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(swf),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:arg,swf,conf);}}else if(arg){return new Player(arg,swf,conf);}}return null;};extend(window.$f,{fireEvent:function(id,evt,a0,a1,a2){var p=$f(id);return p?p._fireEvent(evt,a0,a1,a2):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(document.all){window.onbeforeunload=function(){$f("*").each(function(){if(this.isLoaded()){this.close();}});};}if(typeof jQuery=='function'){jQuery.prototype.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);}return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}})();(function(){var jQ=typeof jQuery=='function';function isDomReady(){if(domReady.done){return false;}var d=document;if(d&&d.getElementsByTagName&&d.getElementById&&d.body){clearInterval(domReady.timer);domReady.timer=null;for(var i=0;i';}var e=extend({},p);e.width=e.height=e.id=e.w3c=e.src=null;for(var k in e){if(e[k]!==null){html+='';}}var vars="";if(c){for(var key in c){if(c[key]!==null){vars+=key+'='+(typeof c[key]=='object'?asString(c[key]):c[key])+'&';}}vars=vars.substring(0,vars.length-1);html+='';}html+="";return html;}function Flash(root,opts,flashvars){var version=flashembed.getVersion();extend(this,{getContainer:function(){return root;},getConf:function(){return conf;},getVersion:function(){return version;},getFlashvars:function(){return flashvars;},getApi:function(){return root.firstChild;},getHTML:function(){return getHTML(opts,flashvars);}});var required=opts.version;var express=opts.expressInstall;var ok=!required||flashembed.isSupported(required);if(ok){opts.onFail=opts.version=opts.expressInstall=null;root.innerHTML=getHTML(opts,flashvars);}else if(required&&express&&flashembed.isSupported([6,65])){extend(opts,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML(opts,flashvars);}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="

Flash version "+required+" or greater is required

"+"

"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"

"+"

Download latest version from here

";}}if(!ok&&opts.onFail){var ret=opts.onFail.call(this);if(typeof ret=='string'){root.innerHTML=ret;}}}window.flashembed=function(root,conf,flashvars){if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{domReady(function(){flashembed(root,conf,flashvars);});return;}}if(!root){return;}var opts={width:'100%',height:'100%',allowfullscreen:true,allowscriptaccess:'always',quality:'high',version:null,onFail:null,expressInstall:null,w3c:false};if(typeof conf=='string'){conf={src:conf};}extend(opts,conf);return new Flash(root,opts,flashvars);};extend(window.flashembed,{getVersion:function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return;}}try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}}if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}}return version;},isSupported:function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;},domReady:domReady,asString:asString,getHTML:getHTML});if(jQ){jQuery.prototype.flashembed=function(conf,flashvars){return this.each(function(){flashembed(this,conf,flashvars);});};}})(); \ No newline at end of file diff --git a/js/jquery.simplemodal-1.2.2.pack.js b/js/jquery.simplemodal-1.2.2.pack.js deleted file mode 100644 index b5ad5c23a..000000000 --- a/js/jquery.simplemodal-1.2.2.pack.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * SimpleModal 1.2.2 - jQuery Plugin - * http://www.ericmmartin.com/projects/simplemodal/ - * Copyright (c) 2008 Eric Martin - * Dual licensed under the MIT and GPL licenses - * Revision: $Id: jquery.simplemodal.js 181 2008-12-16 16:51:44Z emartin24 $ - */ -eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(g($){m f=$.Q.1Q&&1a($.Q.1D)==6&&!10[\'2g\'],1f=$.Q.1Q&&!$.2a,w=[];$.y=g(a,b){I $.y.12.1n(a,b)};$.y.D=g(){$.y.12.D()};$.1P.y=g(a){I $.y.12.1n(3,a)};$.y.1O={V:29,1J:\'r-H\',1B:{},1z:\'r-n\',20:{},1Z:{},v:2t,D:1o,1T:\'\',X:\'r-D\',l:F,1g:K,1e:F,1d:F,1c:F};$.y.12={7:F,4:{},1n:g(a,b){8(3.4.j){I K}3.7=$.U({},$.y.1O,b);3.v=3.7.v;3.1w=K;8(J a==\'27\'){a=a 25 1A?a:$(a);8(a.1v().1v().23()>0){3.4.T=a.1v();8(!3.7.1g){3.4.21=a.2x(1o)}}}q 8(J a==\'2w\'||J a==\'1r\'){a=$(\'<1q/>\').2s(a)}q{2r(\'2q 2p: 2o j 2l: \'+J a);I K}3.4.j=a.11(\'r-j\').E(3.7.1Z);a=F;3.1S();3.1R();8($.1m(3.7.1d)){3.7.1d.1l(3,[3.4])}I 3},1S:g(){w=3.1k();8(f){3.4.x=$(\'\').E($.U(3.7.2b,{1j:\'1i\',V:0,l:\'1h\',A:w[0],z:w[1],v:3.7.v,L:0,B:0})).O(\'u\')}3.4.H=$(\'<1q/>\').1N(\'1M\',3.7.1J).11(\'r-H\').E($.U(3.7.1B,{1j:\'1i\',V:3.7.V/1b,A:w[0],z:w[1],l:\'1h\',B:0,L:0,v:3.7.v+1})).O(\'u\');3.4.n=$(\'<1q/>\').1N(\'1M\',3.7.1z).11(\'r-n\').E($.U(3.7.20,{1j:\'1i\',l:\'1h\',v:3.7.v+2})).1K(3.7.D?$(3.7.1T).11(3.7.X):\'\').O(\'u\');3.19();8(f||1f){3.18()}3.4.n.1K(3.4.j.1I())},1H:g(){m a=3;$(\'.\'+3.7.X).1G(\'1L.r\',g(e){e.28();a.D()});$(10).1G(\'1F.r\',g(){w=a.1k();a.19();8(f||1f){a.18()}q{a.4.x&&a.4.x.E({A:w[0],z:w[1]});a.4.H.E({A:w[0],z:w[1]})}})},1E:g(){$(\'.\'+3.7.X).1C(\'1L.r\');$(10).1C(\'1F.r\')},18:g(){m p=3.7.l;$.26([3.4.x||F,3.4.H,3.4.n],g(i,e){8(e){m a=\'k.u.17\',N=\'k.u.1W\',16=\'k.u.24\',S=\'k.u.1y\',R=\'k.u.1x\',15=\'k.u.22\',1t=\'k.P.17\',1s=\'k.P.1W\',C=\'k.P.1y\',G=\'k.P.1x\',s=e[0].2v;s.l=\'2u\';8(i<2){s.14(\'A\');s.14(\'z\');s.Z(\'A\',\'\'+16+\' > \'+a+\' ? \'+16+\' : \'+a+\' + "o"\');s.Z(\'z\',\'\'+15+\' > \'+N+\' ? \'+15+\' : \'+N+\' + "o"\')}q{m b,W;8(p&&p.1Y==1X){8(p[0]){m c=J p[0]==\'1r\'?p[0].1V():p[0].13(/o/,\'\');b=c.1U(\'%\')==-1?c+\' + (t = \'+G+\' ? \'+G+\' : \'+R+\') + "o"\':1a(c.13(/%/,\'\'))+\' * ((\'+1t+\' || \'+a+\') / 1b) + (t = \'+G+\' ? \'+G+\' : \'+R+\') + "o"\'}8(p[1]){m d=J p[1]==\'1r\'?p[1].1V():p[1].13(/o/,\'\');W=d.1U(\'%\')==-1?d+\' + (t = \'+C+\' ? \'+C+\' : \'+S+\') + "o"\':1a(d.13(/%/,\'\'))+\' * ((\'+1s+\' || \'+N+\') / 1b) + (t = \'+C+\' ? \'+C+\' : \'+S+\') + "o"\'}}q{b=\'(\'+1t+\' || \'+a+\') / 2 - (3.2n / 2) + (t = \'+G+\' ? \'+G+\' : \'+R+\') + "o"\';W=\'(\'+1s+\' || \'+N+\') / 2 - (3.2m / 2) + (t = \'+C+\' ? \'+C+\' : \'+S+\') + "o"\'}s.14(\'L\');s.14(\'B\');s.Z(\'L\',b);s.Z(\'B\',W)}}})},1k:g(){m a=$(10);m h=$.Q.2k&&$.Q.1D>\'9.5\'&&$.1P.2i<=\'1.2.6\'?k.P[\'17\']:a.A();I[h,a.z()]},19:g(){m a,B,1u=(w[0]/2)-((3.4.n.A()||3.4.j.A())/2),1p=(w[1]/2)-((3.4.n.z()||3.4.j.z())/2);8(3.7.l&&3.7.l.1Y==1X){a=3.7.l[0]||1u;B=3.7.l[1]||1p}q{a=1u;B=1p}3.4.n.E({B:B,L:a})},1R:g(){3.4.x&&3.4.x.Y();8($.1m(3.7.1e)){3.7.1e.1l(3,[3.4])}q{3.4.H.Y();3.4.n.Y();3.4.j.Y()}3.1H()},D:g(){8(!3.4.j){I K}8($.1m(3.7.1c)&&!3.1w){3.1w=1o;3.7.1c.1l(3,[3.4])}q{8(3.4.T){8(3.7.1g){3.4.j.1I().O(3.4.T)}q{3.4.j.M();3.4.21.O(3.4.T)}}q{3.4.j.M()}3.4.n.M();3.4.H.M();3.4.x&&3.4.x.M();3.4={}}3.1E()}}})(1A);',62,158,'|||this|dialog|||opts|if||||||||function|||data|document|position|var|container|px||else|simplemodal|||body|zIndex||iframe|modal|width|height|left|sl|close|css|null|st|overlay|return|typeof|false|top|remove|bcw|appendTo|documentElement|browser|bst|bsl|parentNode|extend|opacity|le|closeClass|show|setExpression|window|addClass|impl|replace|removeExpression|bsw|bsh|clientHeight|fixIE|setPosition|parseInt|100|onClose|onShow|onOpen|ieQuirks|persist|fixed|none|display|getDimensions|apply|isFunction|init|true|vCenter|div|number|cw|ch|hCenter|parent|occb|scrollTop|scrollLeft|containerId|jQuery|overlayCss|unbind|version|unbindEvents|resize|bind|bindEvents|hide|overlayId|append|click|id|attr|defaults|fn|msie|open|create|closeHTML|indexOf|toString|clientWidth|Array|constructor|dataCss|containerCss|orig|scrollWidth|size|scrollHeight|instanceof|each|object|preventDefault|50|boxModel|iframeCss|javascript|src|Close|title|XMLHttpRequest|modalCloseImg|jquery|class|opera|type|offsetWidth|offsetHeight|Unsupported|Error|SimpleModal|alert|html|1000|absolute|style|string|clone'.split('|'),0,{})) \ No newline at end of file diff --git a/js/video.js b/js/video.js deleted file mode 100644 index 936a6312e..000000000 --- a/js/video.js +++ /dev/null @@ -1,9 +0,0 @@ -$('document').ready(function() { - $('a.media, a.mediamp3').append(' [PLAY]'); - $('a.mediamp3').html('').css('display', 'block').css('width', '224px').css('height','24px').flowplayer('../bin/flowplayer-3.0.5.swf'); - $('a.media').click(function() { - $('').attr('href', $(this).attr('href')).flowplayer('../bin/flowplayer-3.0.5.swf').modal({'closeHTML':''}); - return false; - }); -}); - diff --git a/lib/action.php b/lib/action.php index 45ce56ac0..975c2bfcb 100644 --- a/lib/action.php +++ b/lib/action.php @@ -156,15 +156,10 @@ class Action extends HTMLOutputter // lawsuit { if (Event::handle('StartShowStyles', array($this))) { if (Event::handle('StartShowLaconicaStyles', array($this))) { - $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => theme_path('css/display.css', 'base') . '?version=' . LACONICA_VERSION, 'media' => 'screen, projection, tv')); - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/modal.css', 'base') . '?version=' . LACONICA_VERSION, - 'media' => 'screen, projection, tv')); $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION, @@ -215,11 +210,6 @@ class Action extends HTMLOutputter // lawsuit $this->element('script', array('type' => 'text/javascript', 'src' => common_path('js/jquery.form.js')), ' '); - - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/jquery.simplemodal-1.2.2.pack.js')), - ' '); - Event::handle('EndShowJQueryScripts', array($this)); } if (Event::handle('StartShowLaconicaScripts', array($this))) { @@ -232,14 +222,6 @@ class Action extends HTMLOutputter // lawsuit // Frame-busting code to avoid clickjacking attacks. $this->element('script', array('type' => 'text/javascript'), 'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }'); - - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/flowplayer-3.0.5.min.js')), - ' '); - - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/video.js')), - ' '); Event::handle('EndShowLaconicaScripts', array($this)); } Event::handle('EndShowScripts', array($this)); diff --git a/lib/util.php b/lib/util.php index 6341438ca..a43666fa5 100644 --- a/lib/util.php +++ b/lib/util.php @@ -480,18 +480,12 @@ function common_replace_urls_callback($text, $callback) { function common_linkify($url) { // It comes in special'd, so we unspecial it before passing to the stringifying // functions - $ext = pathinfo($url, PATHINFO_EXTENSION); $url = htmlspecialchars_decode($url); - $video_ext = array('mp4', 'flv', 'avi', 'mpg', 'mp3', 'ogg'); $display = $url; $url = (!preg_match('#^([a-z]+://|(mailto|aim|tel):)#i', $url)) ? 'http://'.$url : $url; $attrs = array('href' => $url, 'rel' => 'external'); - if (in_array($ext, $video_ext)) { - $attrs['class'] = 'media'; - } - if ($longurl = common_longurl($url)) { $attrs['title'] = $longurl; } diff --git a/theme/base/css/modal.css b/theme/base/css/modal.css deleted file mode 100644 index 985e4adfa..000000000 --- a/theme/base/css/modal.css +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SimpleModal Basic Modal Dialog - * http://www.ericmmartin.com/projects/simplemodal/ - * http://code.google.com/p/simplemodal/ - * - * Copyright (c) 2008 Eric Martin - http://ericmmartin.com - * - * Licensed under the MIT license: - * http://www.opensource.org/licenses/mit-license.php - * - * Revision: $Id: basic.css 162 2008-12-01 23:36:58Z emartin24 $ - * - */ - - -/* Overlay */ -#simplemodal-overlay {background-color:#000; cursor:wait;} - -/* Container */ -#simplemodal-container {height:240px; width:320px; background-color:#fff; border:3px solid #ccc;} -#simplemodal-container a.modalCloseImg {background:url(../images/x.png) no-repeat; width:25px; height:29px; display:inline; z-index:3200; position:absolute; top:-15px; right:-18px; cursor:pointer;} -#simplemodal-container #basicModalContent {padding:8px;} diff --git a/theme/base/css/modal_ie.css b/theme/base/css/modal_ie.css deleted file mode 100644 index eab4637c0..000000000 --- a/theme/base/css/modal_ie.css +++ /dev/null @@ -1,16 +0,0 @@ -/* - * SimpleModal Basic Modal Dialog - * http://www.ericmmartin.com/projects/simplemodal/ - * http://code.google.com/p/simplemodal/ - * - * Copyright (c) 2008 Eric Martin - http://ericmmartin.com - * - * Licensed under the MIT license: - * http://www.opensource.org/licenses/mit-license.php - * - * Revision: $Id: basic_ie.css 162 2008-12-01 23:36:58Z emartin24 $ - * - */ - -/* IE 6 hacks*/ -#simplemodal-container a.modalCloseImg {background:none; right:-14px; width:22px; height:26px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../images/x.png',sizingMethod='scale');} diff --git a/theme/base/images/x.png b/theme/base/images/x.png deleted file mode 100644 index c11f7af69..000000000 Binary files a/theme/base/images/x.png and /dev/null differ -- cgit v1.2.3-54-g00ecf