From 584ea1b23c540cdd781f52eeecd6ad893f63c1a8 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 10 Sep 2009 12:13:43 -0400 Subject: Revert "If a shortened URL begins with http://, don't include it in the shortened url. Saves 7 characters, which is pretty awesome for 140 character max length notices." This reverts commit e2848eb8621dd645fa68cb1641c0af1df5530408. Downstream consumers of our notices (such as Friendfeed, Facebook, etc) don't have sophisticated URL detection, so a notice that reads: "check out ur1.ca/1" won't be linked. So the http:// prefix is mandatory. --- lib/util.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 3e95d2bea..256acf199 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1414,9 +1414,6 @@ function common_shorten_url($long_url) curl_close($curlh); - if(substr($short_url,0,7)=='http://'){ - $short_url = substr($short_url,7); - } return $short_url; } -- cgit v1.2.3-54-g00ecf From 2a56245614f90221946ab918e820f6546133a212 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 10 Sep 2009 21:13:30 -0400 Subject: Re-use enclosure decision logic to decide if a link gets a paperclip/lightbox popup. --- lib/util.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 256acf199..292045928 100644 --- a/lib/util.php +++ b/lib/util.php @@ -552,12 +552,13 @@ function common_linkify($url) { } if (!empty($f)) { - if (isset($f->filename)) { + if ($f->isEnclosure()) { $is_attachment = true; $attachment_id = $f->id; - } else { // if it has OEmbed info, it's an attachment, too + } else { $foe = File_oembed::staticGet('file_id', $f->id); if (!empty($foe)) { + // if it has OEmbed info, it's an attachment, too $is_attachment = true; $attachment_id = $f->id; -- cgit v1.2.3-54-g00ecf From 292bb7c4d8ca469447385e29a80f125e03284d70 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 10 Sep 2009 21:19:38 -0400 Subject: Allow @ signs in the path, querystring, and fragment parts of URLs --- lib/util.php | 6 +++--- tests/URLDetectionTest.php | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 292045928..b831859e9 100644 --- a/lib/util.php +++ b/lib/util.php @@ -442,9 +442,9 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) { ')'. '(?:'. '(?:\:\d+)?'. //:port - '(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"]*)?'. // /path - '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\/]*)?'. // ?query string - '(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\/\?\#]*)?'. // #fragment + '(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@]*)?'. // /path + '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@\/]*)?'. // ?query string + '(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\@/\?\#]*)?'. // #fragment ')(?http://www.somesite.com/xyz/35637563@N00/52803365/ link'), array('http://127.0.0.1', 'http://127.0.0.1'), array('127.0.0.1', -- cgit v1.2.3-54-g00ecf From c04987018cd6c845c6da7a92d9857d8c651f7022 Mon Sep 17 00:00:00 2001 From: Marcel van der Boom Date: Tue, 8 Sep 2009 22:21:33 +0200 Subject: Several fixes to make RabbitMQ a player. * extlib/Stomp.php -spaces for tabs (we're on PEAR, right?) - send: initialize the $properties parameter as array() instead of null this prevents unsetting $headers if $properties was not set (besides that, it's the proper way to initialize an array) - subscribe: insert FIXME's on ActiveMQ specifics - ack: make sure the content-length header is set *and* is zero. I have seen the header set to '3' there but could not find where it came from, this is at least safe. - disconnect: typo in $headers variable - readFrame: use fgets() instead of gets() so that RabbitQ, which is more protocol strict can also play * extlib/Stomp/Frame.php - spaces for tabs - add note on possibly protocol violating linefeed * extlib/Stomp/Message.php - space for tabs - add content-length header for message * lib/stompqueuemanager.php - use the notice for logging, not the frame --- extlib/Stomp.php | 124 ++++++++++++++++++++++++++-------------------- extlib/Stomp/Frame.php | 87 ++++++++++++++++---------------- extlib/Stomp/Message.php | 6 ++- lib/stompqueuemanager.php | 5 +- 4 files changed, 123 insertions(+), 99 deletions(-) (limited to 'lib') diff --git a/extlib/Stomp.php b/extlib/Stomp.php index abd9cba62..c9e90629c 100644 --- a/extlib/Stomp.php +++ b/extlib/Stomp.php @@ -26,7 +26,7 @@ require_once 'Stomp/Frame.php'; * * @package Stomp * @author Hiram Chirino - * @author Dejan Bosanac + * @author Dejan Bosanac * @author Michael Caplan * @version $Revision: 43 $ */ @@ -44,15 +44,15 @@ class Stomp * * @var int */ - public $prefetchSize = 1; - - /** + public $prefetchSize = 1; + + /** * Client id used for durable subscriptions * * @var string */ - public $clientId = null; - + public $clientId = null; + protected $_brokerUri = null; protected $_socket = null; protected $_hosts = array(); @@ -66,7 +66,7 @@ class Stomp protected $_sessionId; protected $_read_timeout_seconds = 60; protected $_read_timeout_milliseconds = 0; - + /** * Constructor * @@ -134,10 +134,10 @@ class Stomp require_once 'Stomp/Exception.php'; throw new Stomp_Exception("No broker defined"); } - + // force disconnect, if previous established connection exists $this->disconnect(); - + $i = $this->_currentHost; $att = 0; $connected = false; @@ -190,11 +190,11 @@ class Stomp if ($password != '') { $this->_password = $password; } - $headers = array('login' => $this->_username , 'passcode' => $this->_password); - if ($this->clientId != null) { - $headers["client-id"] = $this->clientId; - } - $frame = new Stomp_Frame("CONNECT", $headers); + $headers = array('login' => $this->_username , 'passcode' => $this->_password); + if ($this->clientId != null) { + $headers["client-id"] = $this->clientId; + } + $frame = new Stomp_Frame("CONNECT", $headers); $this->_writeFrame($frame); $frame = $this->readFrame(); if ($frame instanceof Stomp_Frame && $frame->command == 'CONNECTED') { @@ -209,7 +209,7 @@ class Stomp } } } - + /** * Check if client session has ben established * @@ -229,7 +229,7 @@ class Stomp return $this->_sessionId; } /** - * Send a message to a destination in the messaging system + * Send a message to a destination in the messaging system * * @param string $destination Destination queue * @param string|Stomp_Frame $msg Message @@ -237,7 +237,7 @@ class Stomp * @param boolean $sync Perform request synchronously * @return boolean */ - public function send ($destination, $msg, $properties = null, $sync = null) + public function send ($destination, $msg, $properties = array(), $sync = null) { if ($msg instanceof Stomp_Frame) { $msg->headers['destination'] = $destination; @@ -319,10 +319,12 @@ class Stomp public function subscribe ($destination, $properties = null, $sync = null) { $headers = array('ack' => 'client'); - $headers['activemq.prefetchSize'] = $this->prefetchSize; - if ($this->clientId != null) { - $headers["activemq.subcriptionName"] = $this->clientId; - } + // FIXME: this seems to be activemq specific, but not hurting rabbitmq? + $headers['activemq.prefetchSize'] = $this->prefetchSize; + if ($this->clientId != null) { + // FIXME: this seems to be activemq specific, but not hurting rabbitmq? + $headers["activemq.subcriptionName"] = $this->clientId; + } if (isset($properties)) { foreach ($properties as $name => $value) { $headers[$name] = $value; @@ -424,7 +426,7 @@ class Stomp } /** * Acknowledge consumption of a message from a subscription - * Note: This operation is always asynchronous + * Note: This operation is always asynchronous * * @param string|Stomp_Frame $messageMessage ID * @param string $transactionId @@ -433,20 +435,26 @@ class Stomp */ public function ack ($message, $transactionId = null) { + // Handle the headers, + $headers = array(); + if ($message instanceof Stomp_Frame) { - $frame = new Stomp_Frame('ACK', $message->headers); - $this->_writeFrame($frame); - return true; + // Copy headers from the object + // FIXME: at least content-length can be wrong here (set to 3 sometimes). + $headers = $message->headers; } else { - $headers = array(); if (isset($transactionId)) { $headers['transaction'] = $transactionId; } $headers['message-id'] = $message; - $frame = new Stomp_Frame('ACK', $headers); - $this->_writeFrame($frame); - return true; } + // An ACK has no content + $headers['content-length'] = 0; + + // Create it and write it out + $frame = new Stomp_Frame('ACK', $headers); + $this->_writeFrame($frame); + return true; } /** * Graceful disconnect from the server @@ -454,11 +462,11 @@ class Stomp */ public function disconnect () { - $headers = array(); + $headers = array(); - if ($this->clientId != null) { - $headers["client-id"] = $this->clientId; - } + if ($this->clientId != null) { + $headers["client-id"] = $this->clientId; + } if (is_resource($this->_socket)) { $this->_writeFrame(new Stomp_Frame('DISCONNECT', $headers)); @@ -490,19 +498,19 @@ class Stomp $this->_writeFrame($stompFrame); } } - + /** * Set timeout to wait for content to read * * @param int $seconds_to_wait Seconds to wait for a frame * @param int $milliseconds Milliseconds to wait for a frame */ - public function setReadTimeout($seconds, $milliseconds = 0) + public function setReadTimeout($seconds, $milliseconds = 0) { $this->_read_timeout_seconds = $seconds; $this->_read_timeout_milliseconds = $milliseconds; } - + /** * Read responce frame from server * @@ -513,19 +521,29 @@ class Stomp if (!$this->hasFrameToRead()) { return false; } - + $rb = 1024; $data = ''; - do { - $read = fgets($this->_socket, $rb); - if ($read === false) { - $this->_reconnect(); - return $this->readFrame(); - } - $data .= $read; - $len = strlen($data); - } while (($len < 2 || ! ($data[$len - 2] == "\x00" && $data[$len - 1] == "\n"))); - + do { + $read = fread($this->_socket, $rb); + if ($read === false) { + $this->_reconnect(); + return $this->readFrame(); + } + $data .= $read; + $len = strlen($data); + + $continue = true; + // ActiveMq apparently add \n after 0 char + if($data[$len - 2] == "\x00" && $data[$len - 1] == "\n") { + $continue = false; + } + + // RabbitMq does not + if($data[$len - 1] == "\x00") { + $continue = false; + } + } while ( $continue ); list ($header, $body) = explode("\n\n", $data, 2); $header = explode("\n", $header); $headers = array(); @@ -546,7 +564,7 @@ class Stomp return $frame; } } - + /** * Check if there is a frame to read * @@ -557,7 +575,7 @@ class Stomp $read = array($this->_socket); $write = null; $except = null; - + $has_frame_to_read = stream_select($read, $write, $except, $this->_read_timeout_seconds, $this->_read_timeout_milliseconds); if ($has_frame_to_read === false) { @@ -565,18 +583,18 @@ class Stomp } else if ($has_frame_to_read > 0) { return true; } else { - return false; + return false; } } - + /** * Reconnects and renews subscriptions (if there were any) - * Call this method when you detect connection problems + * Call this method when you detect connection problems */ protected function _reconnect () { $subscriptions = $this->_subscriptions; - + $this->connect($this->_username, $this->_password); foreach ($subscriptions as $dest => $properties) { $this->subscribe($dest, $properties); diff --git a/extlib/Stomp/Frame.php b/extlib/Stomp/Frame.php index dc59c1cb7..9fd97b4f5 100644 --- a/extlib/Stomp/Frame.php +++ b/extlib/Stomp/Frame.php @@ -17,46 +17,46 @@ */ /* vim: set expandtab tabstop=3 shiftwidth=3: */ - -/** - * Stomp Frames are messages that are sent and received on a StompConnection. - * - * @package Stomp - * @author Hiram Chirino - * @author Dejan Bosanac - * @author Michael Caplan - * @version $Revision: 36 $ - */ -class Stomp_Frame -{ - public $command; - public $headers = array(); - public $body; - - /** - * Constructor - * - * @param string $command - * @param array $headers - * @param string $body - */ - public function __construct ($command = null, $headers = null, $body = null) - { - $this->_init($command, $headers, $body); - } - - protected function _init ($command = null, $headers = null, $body = null) - { - $this->command = $command; - if ($headers != null) { - $this->headers = $headers; - } - $this->body = $body; - - if ($this->command == 'ERROR') { - require_once 'Stomp/Exception.php'; - throw new Stomp_Exception($this->headers['message'], 0, $this->body); - } + +/** + * Stomp Frames are messages that are sent and received on a StompConnection. + * + * @package Stomp + * @author Hiram Chirino + * @author Dejan Bosanac + * @author Michael Caplan + * @version $Revision: 36 $ + */ +class Stomp_Frame +{ + public $command; + public $headers = array(); + public $body; + + /** + * Constructor + * + * @param string $command + * @param array $headers + * @param string $body + */ + public function __construct ($command = null, $headers = null, $body = null) + { + $this->_init($command, $headers, $body); + } + + protected function _init ($command = null, $headers = null, $body = null) + { + $this->command = $command; + if ($headers != null) { + $this->headers = $headers; + } + $this->body = $body; + + if ($this->command == 'ERROR') { + require_once 'Stomp/Exception.php'; + throw new Stomp_Exception($this->headers['message'], 0, $this->body); + } } /** @@ -74,7 +74,8 @@ class Stomp_Frame $data .= "\n"; $data .= $this->body; - return $data .= "\x00\n"; - } -} + $data .= "\x00\n"; // Should there really be a linefeed here? + return $data; + } +} ?> \ No newline at end of file diff --git a/extlib/Stomp/Message.php b/extlib/Stomp/Message.php index 6bcad3efd..055662133 100644 --- a/extlib/Stomp/Message.php +++ b/extlib/Stomp/Message.php @@ -29,8 +29,12 @@ require_once 'Stomp/Frame.php'; */ class Stomp_Message extends Stomp_Frame { - public function __construct ($body, $headers = null) + public function __construct ($body, $headers = array()) { + if(!isset($headers['content-length'])) { + // TODO: log this, to see if this is correct + $headers['content-length'] = strlen($body); + } $this->_init("SEND", $headers, $body); } } diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php index f059b42f0..5d8b2996b 100644 --- a/lib/stompqueuemanager.php +++ b/lib/stompqueuemanager.php @@ -141,10 +141,11 @@ class StompQueueManager $this->con->ack($frame); } else { if ($handler->handle_notice($notice)) { - $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue); + $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue); + $this->con->ack($frame); } else { - $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue); + $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue); // FIXME we probably shouldn't have to do // this kind of queue management ourselves $this->con->ack($frame); -- cgit v1.2.3-54-g00ecf From 57feeb566a0cb2c544545dbfc616437cae69b923 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 11 Sep 2009 22:37:37 -0400 Subject: Add a parameter named 'inreplyto' to the 'notice/new' page, so urls can inclue 'inreplyto' id's. Also add 'inreplyto' to the urls sent in emails. --- actions/newnotice.php | 3 ++- lib/mail.php | 2 +- lib/noticeform.php | 11 +++++++++-- lib/noticelist.php | 2 +- lib/router.php | 4 ++++ 5 files changed, 17 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/actions/newnotice.php b/actions/newnotice.php index 00a822860..6e3720e09 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -431,13 +431,14 @@ class NewnoticeAction extends Action $content = $this->trimmed('status_textarea'); if (!$content) { $replyto = $this->trimmed('replyto'); + $inreplyto = $this->trimmed('inreplyto'); $profile = Profile::staticGet('nickname', $replyto); if ($profile) { $content = '@' . $profile->nickname . ' '; } } - $notice_form = new NoticeForm($this, '', $content); + $notice_form = new NoticeForm($this, '', $content, null, $inreplyto); $notice_form->show(); } diff --git a/lib/mail.php b/lib/mail.php index df585406c..432b7b329 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -629,7 +629,7 @@ function mail_notify_attn($user, $notice) $notice->content,//%4 $conversationUrl,//%5 common_local_url('newnotice', - array('replyto' => $sender->nickname)),//%6 + array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6 common_local_url('replies', array('nickname' => $user->nickname)),//%7 common_local_url('emailsettings'));//%8 diff --git a/lib/noticeform.php b/lib/noticeform.php index 1e3a45142..d1387b1b7 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -69,6 +69,12 @@ class NoticeForm extends Form var $user = null; + /** + * The notice being replied to + */ + + var $inreplyto = null; + /** * Constructor * @@ -77,12 +83,13 @@ class NoticeForm extends Form * @param string $content content to pre-fill */ - function __construct($out=null, $action=null, $content=null, $user=null) + function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto) { parent::__construct($out); $this->action = $action; $this->content = $content; + $this->inreplyto = $inreplyto; if ($user) { $this->user = $user; @@ -161,7 +168,7 @@ class NoticeForm extends Form if ($this->action) { $this->out->hidden('notice_return-to', $this->action, 'returnto'); } - $this->out->hidden('notice_in-reply-to', $this->action, 'inreplyto'); + $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto'); } /** diff --git a/lib/noticelist.php b/lib/noticelist.php index ec85e4a5c..6b2bccd97 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -442,7 +442,7 @@ class NoticeListItem extends Widget { if (common_logged_in()) { $reply_url = common_local_url('newnotice', - array('replyto' => $this->profile->nickname)); + array('replyto' => $this->profile->nickname, 'inreplyto' => $this->notice->id)); $this->out->elementStart('a', array('href' => $reply_url, 'class' => 'notice_reply', 'title' => _('Reply to this notice'))); diff --git a/lib/router.php b/lib/router.php index 00e728f55..0505c9942 100644 --- a/lib/router.php +++ b/lib/router.php @@ -175,6 +175,10 @@ class Router $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+')); + $m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto', + array('action' => 'newnotice'), + array('replyto' => '[A-Za-z0-9_-]+'), + array('inreplyto' => '[0-9]+')); $m->connect('notice/:notice/file', array('action' => 'file'), -- cgit v1.2.3-54-g00ecf From b75ed37eeb8318a5a5f82f080fb2536af0dbc6be Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sat, 12 Sep 2009 16:58:04 -0400 Subject: Show username in subject of emails Fixes http://status.net/trac/ticket/1862 --- lib/mail.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/mail.php b/lib/mail.php index 432b7b329..5bf4d7425 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -551,9 +551,9 @@ function mail_notify_fave($other, $user, $notice) common_init_locale($other->language); - $subject = sprintf(_('%s added your notice as a favorite'), $bestname); + $subject = sprintf(_('%s (@%s) added your notice as a favorite'), $bestname, $user->nickname); - $body = sprintf(_("%1\$s just added your notice from %2\$s". + $body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s". " as one of their favorites.\n\n" . "The URL of your notice is:\n\n" . "%3\$s\n\n" . @@ -570,7 +570,8 @@ function mail_notify_fave($other, $user, $notice) $notice->content, common_local_url('showfavorites', array('nickname' => $user->nickname)), - common_config('site', 'name')); + common_config('site', 'name'), + $user->nickname); common_init_locale(); mail_to_user($other, $subject, $body); @@ -607,9 +608,9 @@ function mail_notify_attn($user, $notice) $conversationUrl = null; } - $subject = sprintf(_('%s sent a notice to your attention'), $bestname); + $subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname); - $body = sprintf(_("%1\$s just sent a notice to your attention (an '@-reply') on %2\$s.\n\n". + $body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n". "The notice is here:\n\n". "\t%3\$s\n\n" . "It reads:\n\n". @@ -632,7 +633,8 @@ function mail_notify_attn($user, $notice) array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6 common_local_url('replies', array('nickname' => $user->nickname)),//%7 - common_local_url('emailsettings'));//%8 + common_local_url('emailsettings'), //%8 + $sender->nickname); //%9 common_init_locale(); mail_to_user($user, $subject, $body); -- cgit v1.2.3-54-g00ecf From 7cd80b29c45c2255e32328dc8b4e8a19933aa645 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sat, 12 Sep 2009 17:06:46 -0400 Subject: NoticeForm's constructor's inreplyto argument should be optional (defaulting to null) --- lib/noticeform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/noticeform.php b/lib/noticeform.php index d1387b1b7..350e37db8 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -83,7 +83,7 @@ class NoticeForm extends Form * @param string $content content to pre-fill */ - function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto) + function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null) { parent::__construct($out); -- cgit v1.2.3-54-g00ecf From 0a1d2635c1278a12a643c6ee684a9707df6e87dd Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sun, 13 Sep 2009 01:01:31 -0400 Subject: Set a Vary header with accept-encoding and cookies. Fixes http://status.net/trac/ticket/17 --- lib/action.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/action.php b/lib/action.php index fafb2c6fc..670eb498c 100644 --- a/lib/action.php +++ b/lib/action.php @@ -881,6 +881,7 @@ class Action extends HTMLOutputter // lawsuit */ function handle($argarray=null) { + header('Vary: Accept-Encoding,Cookie'); $lm = $this->lastModified(); $etag = $this->etag(); if ($etag) { -- cgit v1.2.3-54-g00ecf From 20997619b353faa94591800fbfc02bc19a4cdce3 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sun, 13 Sep 2009 01:24:57 -0400 Subject: When viewing a page in https, all links to non-actions (links to CSS, JS, etc) should be https. Fixes the mixed content warnings that browsers display. Fixes http://status.net/trac/ticket/1552 --- lib/util.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index b831859e9..5b57b79b5 100644 --- a/lib/util.php +++ b/lib/util.php @@ -750,8 +750,18 @@ function common_local_url($action, $args=null, $params=null, $fragment=null) return $url; } -function common_path($relative, $ssl=false) +function common_path($relative, $ssl=null) { + if($ssl==null) { + //ssl was not specifically requested + if( $_SERVER['HTTPS'] && $_SERVER['HTTPS']!="off" ) { + //currently in https, so stay in https + $ssl=true; + } else { + //not in https, so stay not in https + $ssl=false; + } + } $pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : ''; if (($ssl && (common_config('site', 'ssl') === 'sometimes')) -- cgit v1.2.3-54-g00ecf From b9e4b6dd49e8f2c56025df8424137144723d2021 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sun, 13 Sep 2009 17:30:50 -0400 Subject: Generate ETags for pages which don't specify themselves. --- index.php | 2 +- lib/action.php | 43 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/index.php b/index.php index 7669778f6..72ceb45df 100644 --- a/index.php +++ b/index.php @@ -227,7 +227,7 @@ function main() try { if ($action_obj->prepare($args)) { - $action_obj->handle($args); + $action_obj->handleWrapper($args); } } catch (ClientException $cex) { $cac = new ClientErrorAction($cex->getMessage(), $cex->getCode()); diff --git a/lib/action.php b/lib/action.php index 670eb498c..06cdbdfe0 100644 --- a/lib/action.php +++ b/lib/action.php @@ -873,38 +873,71 @@ class Action extends HTMLOutputter // lawsuit } /** - * Handler method + * Wrapper for the handle method that handles etags, last-modified, and other conditional headers * * @param array $argarray is ignored since it's now passed in in prepare() * * @return boolean is read only action? */ - function handle($argarray=null) + function handleWrapper($argarray=null) { - header('Vary: Accept-Encoding,Cookie'); + header('Vary: Accept-Encoding,Cookie,Accept-Language,Authorization'); + header("Cache-Control: must-revalidate"); $lm = $this->lastModified(); $etag = $this->etag(); if ($etag) { header('ETag: ' . $etag); } + $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ? + $_SERVER['HTTP_IF_NONE_MATCH'] : null; if ($lm) { header('Last-Modified: ' . date(DATE_RFC1123, $lm)); if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE']; $ims = strtotime($if_modified_since); if ($lm <= $ims) { - $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ? - $_SERVER['HTTP_IF_NONE_MATCH'] : null; if (!$if_none_match || !$etag || $this->_hasEtag($etag, $if_none_match)) { header('HTTP/1.1 304 Not Modified'); + header('Content-Length: 0'); // Better way to do this? exit(0); } } } } + if($etag) { + $ret = $this->handle($argarray); + }else{ + ob_start(); + $ret = $this->handle($argarray); + $output = ob_get_contents(); + ob_end_clean(); + //deep etag + $etag = md5($output); + header('ETag: ' . $etag); + if($if_none_match && $this->_hasEtag($etag, $if_none_match)) { + header('HTTP/1.1 304 Not Modified'); + header('Content-Length: 0'); + // Better way to do this? + exit(0); + } + header('Content-Length: '.strlen($output)); + print $output; + } + return $ret; + } + + /** + * Handler method + * + * @param array $argarray is ignored since it's now passed in in prepare() + * + * @return boolean is read only action? + */ + function handle($argarray=null) + { } /** -- cgit v1.2.3-54-g00ecf From 48565a2cdc9df329dee1ad327a1c632dd8f1d4c3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 17:08:27 -0400 Subject: Revert "Several fixes to make RabbitMQ a player." This reverts commit c04987018cd6c845c6da7a92d9857d8c651f7022. --- extlib/Stomp.php | 124 ++++++++++++++++++++-------------------------- extlib/Stomp/Frame.php | 87 ++++++++++++++++---------------- extlib/Stomp/Message.php | 6 +-- lib/stompqueuemanager.php | 5 +- 4 files changed, 99 insertions(+), 123 deletions(-) (limited to 'lib') diff --git a/extlib/Stomp.php b/extlib/Stomp.php index c9e90629c..abd9cba62 100644 --- a/extlib/Stomp.php +++ b/extlib/Stomp.php @@ -26,7 +26,7 @@ require_once 'Stomp/Frame.php'; * * @package Stomp * @author Hiram Chirino - * @author Dejan Bosanac + * @author Dejan Bosanac * @author Michael Caplan * @version $Revision: 43 $ */ @@ -44,15 +44,15 @@ class Stomp * * @var int */ - public $prefetchSize = 1; - - /** + public $prefetchSize = 1; + + /** * Client id used for durable subscriptions * * @var string */ - public $clientId = null; - + public $clientId = null; + protected $_brokerUri = null; protected $_socket = null; protected $_hosts = array(); @@ -66,7 +66,7 @@ class Stomp protected $_sessionId; protected $_read_timeout_seconds = 60; protected $_read_timeout_milliseconds = 0; - + /** * Constructor * @@ -134,10 +134,10 @@ class Stomp require_once 'Stomp/Exception.php'; throw new Stomp_Exception("No broker defined"); } - + // force disconnect, if previous established connection exists $this->disconnect(); - + $i = $this->_currentHost; $att = 0; $connected = false; @@ -190,11 +190,11 @@ class Stomp if ($password != '') { $this->_password = $password; } - $headers = array('login' => $this->_username , 'passcode' => $this->_password); - if ($this->clientId != null) { - $headers["client-id"] = $this->clientId; - } - $frame = new Stomp_Frame("CONNECT", $headers); + $headers = array('login' => $this->_username , 'passcode' => $this->_password); + if ($this->clientId != null) { + $headers["client-id"] = $this->clientId; + } + $frame = new Stomp_Frame("CONNECT", $headers); $this->_writeFrame($frame); $frame = $this->readFrame(); if ($frame instanceof Stomp_Frame && $frame->command == 'CONNECTED') { @@ -209,7 +209,7 @@ class Stomp } } } - + /** * Check if client session has ben established * @@ -229,7 +229,7 @@ class Stomp return $this->_sessionId; } /** - * Send a message to a destination in the messaging system + * Send a message to a destination in the messaging system * * @param string $destination Destination queue * @param string|Stomp_Frame $msg Message @@ -237,7 +237,7 @@ class Stomp * @param boolean $sync Perform request synchronously * @return boolean */ - public function send ($destination, $msg, $properties = array(), $sync = null) + public function send ($destination, $msg, $properties = null, $sync = null) { if ($msg instanceof Stomp_Frame) { $msg->headers['destination'] = $destination; @@ -319,12 +319,10 @@ class Stomp public function subscribe ($destination, $properties = null, $sync = null) { $headers = array('ack' => 'client'); - // FIXME: this seems to be activemq specific, but not hurting rabbitmq? - $headers['activemq.prefetchSize'] = $this->prefetchSize; - if ($this->clientId != null) { - // FIXME: this seems to be activemq specific, but not hurting rabbitmq? - $headers["activemq.subcriptionName"] = $this->clientId; - } + $headers['activemq.prefetchSize'] = $this->prefetchSize; + if ($this->clientId != null) { + $headers["activemq.subcriptionName"] = $this->clientId; + } if (isset($properties)) { foreach ($properties as $name => $value) { $headers[$name] = $value; @@ -426,7 +424,7 @@ class Stomp } /** * Acknowledge consumption of a message from a subscription - * Note: This operation is always asynchronous + * Note: This operation is always asynchronous * * @param string|Stomp_Frame $messageMessage ID * @param string $transactionId @@ -435,26 +433,20 @@ class Stomp */ public function ack ($message, $transactionId = null) { - // Handle the headers, - $headers = array(); - if ($message instanceof Stomp_Frame) { - // Copy headers from the object - // FIXME: at least content-length can be wrong here (set to 3 sometimes). - $headers = $message->headers; + $frame = new Stomp_Frame('ACK', $message->headers); + $this->_writeFrame($frame); + return true; } else { + $headers = array(); if (isset($transactionId)) { $headers['transaction'] = $transactionId; } $headers['message-id'] = $message; + $frame = new Stomp_Frame('ACK', $headers); + $this->_writeFrame($frame); + return true; } - // An ACK has no content - $headers['content-length'] = 0; - - // Create it and write it out - $frame = new Stomp_Frame('ACK', $headers); - $this->_writeFrame($frame); - return true; } /** * Graceful disconnect from the server @@ -462,11 +454,11 @@ class Stomp */ public function disconnect () { - $headers = array(); + $headers = array(); - if ($this->clientId != null) { - $headers["client-id"] = $this->clientId; - } + if ($this->clientId != null) { + $headers["client-id"] = $this->clientId; + } if (is_resource($this->_socket)) { $this->_writeFrame(new Stomp_Frame('DISCONNECT', $headers)); @@ -498,19 +490,19 @@ class Stomp $this->_writeFrame($stompFrame); } } - + /** * Set timeout to wait for content to read * * @param int $seconds_to_wait Seconds to wait for a frame * @param int $milliseconds Milliseconds to wait for a frame */ - public function setReadTimeout($seconds, $milliseconds = 0) + public function setReadTimeout($seconds, $milliseconds = 0) { $this->_read_timeout_seconds = $seconds; $this->_read_timeout_milliseconds = $milliseconds; } - + /** * Read responce frame from server * @@ -521,29 +513,19 @@ class Stomp if (!$this->hasFrameToRead()) { return false; } - + $rb = 1024; $data = ''; - do { - $read = fread($this->_socket, $rb); - if ($read === false) { - $this->_reconnect(); - return $this->readFrame(); - } - $data .= $read; - $len = strlen($data); - - $continue = true; - // ActiveMq apparently add \n after 0 char - if($data[$len - 2] == "\x00" && $data[$len - 1] == "\n") { - $continue = false; - } - - // RabbitMq does not - if($data[$len - 1] == "\x00") { - $continue = false; - } - } while ( $continue ); + do { + $read = fgets($this->_socket, $rb); + if ($read === false) { + $this->_reconnect(); + return $this->readFrame(); + } + $data .= $read; + $len = strlen($data); + } while (($len < 2 || ! ($data[$len - 2] == "\x00" && $data[$len - 1] == "\n"))); + list ($header, $body) = explode("\n\n", $data, 2); $header = explode("\n", $header); $headers = array(); @@ -564,7 +546,7 @@ class Stomp return $frame; } } - + /** * Check if there is a frame to read * @@ -575,7 +557,7 @@ class Stomp $read = array($this->_socket); $write = null; $except = null; - + $has_frame_to_read = stream_select($read, $write, $except, $this->_read_timeout_seconds, $this->_read_timeout_milliseconds); if ($has_frame_to_read === false) { @@ -583,18 +565,18 @@ class Stomp } else if ($has_frame_to_read > 0) { return true; } else { - return false; + return false; } } - + /** * Reconnects and renews subscriptions (if there were any) - * Call this method when you detect connection problems + * Call this method when you detect connection problems */ protected function _reconnect () { $subscriptions = $this->_subscriptions; - + $this->connect($this->_username, $this->_password); foreach ($subscriptions as $dest => $properties) { $this->subscribe($dest, $properties); diff --git a/extlib/Stomp/Frame.php b/extlib/Stomp/Frame.php index 9fd97b4f5..dc59c1cb7 100644 --- a/extlib/Stomp/Frame.php +++ b/extlib/Stomp/Frame.php @@ -17,46 +17,46 @@ */ /* vim: set expandtab tabstop=3 shiftwidth=3: */ - -/** - * Stomp Frames are messages that are sent and received on a StompConnection. - * - * @package Stomp - * @author Hiram Chirino - * @author Dejan Bosanac - * @author Michael Caplan - * @version $Revision: 36 $ - */ -class Stomp_Frame -{ - public $command; - public $headers = array(); - public $body; - - /** - * Constructor - * - * @param string $command - * @param array $headers - * @param string $body - */ - public function __construct ($command = null, $headers = null, $body = null) - { - $this->_init($command, $headers, $body); - } - - protected function _init ($command = null, $headers = null, $body = null) - { - $this->command = $command; - if ($headers != null) { - $this->headers = $headers; - } - $this->body = $body; - - if ($this->command == 'ERROR') { - require_once 'Stomp/Exception.php'; - throw new Stomp_Exception($this->headers['message'], 0, $this->body); - } + +/** + * Stomp Frames are messages that are sent and received on a StompConnection. + * + * @package Stomp + * @author Hiram Chirino + * @author Dejan Bosanac + * @author Michael Caplan + * @version $Revision: 36 $ + */ +class Stomp_Frame +{ + public $command; + public $headers = array(); + public $body; + + /** + * Constructor + * + * @param string $command + * @param array $headers + * @param string $body + */ + public function __construct ($command = null, $headers = null, $body = null) + { + $this->_init($command, $headers, $body); + } + + protected function _init ($command = null, $headers = null, $body = null) + { + $this->command = $command; + if ($headers != null) { + $this->headers = $headers; + } + $this->body = $body; + + if ($this->command == 'ERROR') { + require_once 'Stomp/Exception.php'; + throw new Stomp_Exception($this->headers['message'], 0, $this->body); + } } /** @@ -74,8 +74,7 @@ class Stomp_Frame $data .= "\n"; $data .= $this->body; - $data .= "\x00\n"; // Should there really be a linefeed here? - return $data; - } -} + return $data .= "\x00\n"; + } +} ?> \ No newline at end of file diff --git a/extlib/Stomp/Message.php b/extlib/Stomp/Message.php index 055662133..6bcad3efd 100644 --- a/extlib/Stomp/Message.php +++ b/extlib/Stomp/Message.php @@ -29,12 +29,8 @@ require_once 'Stomp/Frame.php'; */ class Stomp_Message extends Stomp_Frame { - public function __construct ($body, $headers = array()) + public function __construct ($body, $headers = null) { - if(!isset($headers['content-length'])) { - // TODO: log this, to see if this is correct - $headers['content-length'] = strlen($body); - } $this->_init("SEND", $headers, $body); } } diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php index 5d8b2996b..f059b42f0 100644 --- a/lib/stompqueuemanager.php +++ b/lib/stompqueuemanager.php @@ -141,11 +141,10 @@ class StompQueueManager $this->con->ack($frame); } else { if ($handler->handle_notice($notice)) { - $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue); - + $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue); $this->con->ack($frame); } else { - $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue); + $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue); // FIXME we probably shouldn't have to do // this kind of queue management ourselves $this->con->ack($frame); -- cgit v1.2.3-54-g00ecf From d7e13e847dbce55ad8ed017f02e1ac8420881e4e Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 15 Sep 2009 17:17:36 -0400 Subject: 304 responses should not have a Content-Length header. --- lib/action.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib') diff --git a/lib/action.php b/lib/action.php index 06cdbdfe0..ebef4f9e4 100644 --- a/lib/action.php +++ b/lib/action.php @@ -900,7 +900,6 @@ class Action extends HTMLOutputter // lawsuit !$etag || $this->_hasEtag($etag, $if_none_match)) { header('HTTP/1.1 304 Not Modified'); - header('Content-Length: 0'); // Better way to do this? exit(0); } @@ -919,7 +918,6 @@ class Action extends HTMLOutputter // lawsuit header('ETag: ' . $etag); if($if_none_match && $this->_hasEtag($etag, $if_none_match)) { header('HTTP/1.1 304 Not Modified'); - header('Content-Length: 0'); // Better way to do this? exit(0); } -- cgit v1.2.3-54-g00ecf From 4b7881c64e741d7b82f1d65bd9651148692cf1d4 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 18 Sep 2009 19:32:51 +0200 Subject: Removed trailing single space in author @title --- lib/noticelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/noticelist.php b/lib/noticelist.php index 6b2bccd97..336457b45 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -261,7 +261,7 @@ class NoticeListItem extends Widget $attrs = array('href' => $this->profile->profileurl, 'class' => 'url'); if (!empty($this->profile->fullname)) { - $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ') '; + $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')'; } $this->out->elementStart('a', $attrs); $this->showAvatar(); -- cgit v1.2.3-54-g00ecf From 6af71f2cd2b2fcacb0f1eb2e0172a300802fe8bc Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 18 Sep 2009 17:37:36 -0400 Subject: Show context link if this notice starts a conversation --- lib/noticelist.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/noticelist.php b/lib/noticelist.php index 6b2bccd97..507413da7 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -418,9 +418,17 @@ class NoticeListItem extends Widget function showContext() { - // XXX: also show context if there are replies to this notice - if (!empty($this->notice->conversation) - && $this->notice->conversation != $this->notice->id) { + $hasConversation = false; + if( !empty($this->notice->conversation) + && $this->notice->conversation != $this->notice->id){ + $hasConversation = true; + }else{ + $conversation = Notice::conversationStream($this->notice->id, 1, 1); + if($conversation->N > 0){ + $hasConversation = true; + } + } + if ($hasConversation){ $convurl = common_local_url('conversation', array('id' => $this->notice->conversation)); $this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id, -- cgit v1.2.3-54-g00ecf From 74296fa12c7813ad5cdc80750173c11912b5860f Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sat, 19 Sep 2009 18:34:07 -0700 Subject: Make statuses/home_timeline return the same thing as statuses/friends_timeline to support apps trying to use the new retweet API method. --- actions/twitapistatuses.php | 5 +++++ lib/router.php | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index edee239a0..5e2867ea8 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -136,6 +136,11 @@ class TwitapistatusesAction extends TwitterapiAction } + function home_timeline($args, $apidata) + { + call_user_func(array($this, 'friends_timeline'), $args, $apidata); + } + function user_timeline($args, $apidata) { parent::handle($args); diff --git a/lib/router.php b/lib/router.php index 0505c9942..5529e60ac 100644 --- a/lib/router.php +++ b/lib/router.php @@ -272,12 +272,12 @@ class Router $m->connect('api/statuses/:method', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?')); + array('method' => '(public_timeline|home_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?')); $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); + array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); // users @@ -436,7 +436,7 @@ class Router $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); + array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); $m->connect('api/statusnet/groups/:method/:argument', array('action' => 'api', -- cgit v1.2.3-54-g00ecf From 44820d296dd0c00cef9b48af3a3574f765042715 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sun, 20 Sep 2009 13:44:22 +0200 Subject: No need to call farbtastic.go.js because it was moved to userdesign.go.js --- lib/designsettings.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/designsettings.php b/lib/designsettings.php index fdc05562e..820d534f2 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -325,7 +325,6 @@ class DesignSettingsAction extends AccountSettingsAction parent::showScripts(); $this->script('js/farbtastic/farbtastic.js'); - $this->script('js/farbtastic/farbtastic.go.js'); $this->script('js/userdesign.go.js'); $this->autofocus('design_background-image_file'); -- cgit v1.2.3-54-g00ecf From 42ba05de5fa9413ce0f383cfdafa7288e291ab17 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 09:33:40 -0400 Subject: revert output buffering (costly) for ETags (low priority) --- index.php | 2 +- lib/action.php | 41 +++++------------------------------------ 2 files changed, 6 insertions(+), 37 deletions(-) (limited to 'lib') diff --git a/index.php b/index.php index fa94f0c75..362ab3cd3 100644 --- a/index.php +++ b/index.php @@ -233,7 +233,7 @@ function main() try { if ($action_obj->prepare($args)) { - $action_obj->handleWrapper($args); + $action_obj->handle($args); } } catch (ClientException $cex) { $cac = new ClientErrorAction($cex->getMessage(), $cex->getCode()); diff --git a/lib/action.php b/lib/action.php index ebef4f9e4..670eb498c 100644 --- a/lib/action.php +++ b/lib/action.php @@ -873,29 +873,28 @@ class Action extends HTMLOutputter // lawsuit } /** - * Wrapper for the handle method that handles etags, last-modified, and other conditional headers + * Handler method * * @param array $argarray is ignored since it's now passed in in prepare() * * @return boolean is read only action? */ - function handleWrapper($argarray=null) + function handle($argarray=null) { - header('Vary: Accept-Encoding,Cookie,Accept-Language,Authorization'); - header("Cache-Control: must-revalidate"); + header('Vary: Accept-Encoding,Cookie'); $lm = $this->lastModified(); $etag = $this->etag(); if ($etag) { header('ETag: ' . $etag); } - $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ? - $_SERVER['HTTP_IF_NONE_MATCH'] : null; if ($lm) { header('Last-Modified: ' . date(DATE_RFC1123, $lm)); if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE']; $ims = strtotime($if_modified_since); if ($lm <= $ims) { + $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ? + $_SERVER['HTTP_IF_NONE_MATCH'] : null; if (!$if_none_match || !$etag || $this->_hasEtag($etag, $if_none_match)) { @@ -906,36 +905,6 @@ class Action extends HTMLOutputter // lawsuit } } } - if($etag) { - $ret = $this->handle($argarray); - }else{ - ob_start(); - $ret = $this->handle($argarray); - $output = ob_get_contents(); - ob_end_clean(); - //deep etag - $etag = md5($output); - header('ETag: ' . $etag); - if($if_none_match && $this->_hasEtag($etag, $if_none_match)) { - header('HTTP/1.1 304 Not Modified'); - // Better way to do this? - exit(0); - } - header('Content-Length: '.strlen($output)); - print $output; - } - return $ret; - } - - /** - * Handler method - * - * @param array $argarray is ignored since it's now passed in in prepare() - * - * @return boolean is read only action? - */ - function handle($argarray=null) - { } /** -- cgit v1.2.3-54-g00ecf From bef4a8b6ba9e19f2ec629031444279ca76f17bcf Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 09:34:55 -0400 Subject: Revert "When viewing a page in https, all links to non-actions (links to CSS, JS, etc) should be https. Fixes the mixed content warnings that browsers display." This reverts commit 20997619b353faa94591800fbfc02bc19a4cdce3. The commit doesn't take into account having different servers (theme server, avatar server) and being able to set HTTPS for some but not all. --- lib/util.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 5b57b79b5..b831859e9 100644 --- a/lib/util.php +++ b/lib/util.php @@ -750,18 +750,8 @@ function common_local_url($action, $args=null, $params=null, $fragment=null) return $url; } -function common_path($relative, $ssl=null) +function common_path($relative, $ssl=false) { - if($ssl==null) { - //ssl was not specifically requested - if( $_SERVER['HTTPS'] && $_SERVER['HTTPS']!="off" ) { - //currently in https, so stay in https - $ssl=true; - } else { - //not in https, so stay not in https - $ssl=false; - } - } $pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : ''; if (($ssl && (common_config('site', 'ssl') === 'sometimes')) -- cgit v1.2.3-54-g00ecf From a5ed805aeabab3930d066b2777dbab9663bc487f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 23 Sep 2009 23:23:13 -0400 Subject: move scripts to just before , add event for scripts that need to be in --- EVENTS.txt | 6 ++++++ lib/action.php | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/EVENTS.txt b/EVENTS.txt index 68cb28603..dfaf34a66 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -134,3 +134,9 @@ StartAddressData: Allows the site owner to provide additional information about EndAddressData: At the end of
- $action: the current action + +StartShowHeadElements: Right after the tag +- $action: the current action + +EndShowHeadElements: Right before the tag; put