]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'mobile-style' of git://gitorious.org/laconica/meitar into review
authorSarven Capadisli <csarven@controlyourself.ca>
Tue, 17 Feb 2009 20:32:19 +0000 (20:32 +0000)
committerSarven Capadisli <csarven@controlyourself.ca>
Tue, 17 Feb 2009 20:32:19 +0000 (20:32 +0000)
Conflicts:

lib/action.php

100 files changed:
EVENTS.txt
README
actions/all.php
actions/avatarsettings.php
actions/doc.php
actions/emailsettings.php
actions/newnotice.php
actions/noticesearch.php
actions/public.php
actions/replies.php
actions/showfavorites.php
actions/showgroup.php
actions/showstream.php
actions/tag.php
actions/tagother.php
actions/twittersettings.php
bin/flowplayer-3.0.5.swf [new file with mode: 0644]
bin/flowplayer.audio-3.0.3.swf [new file with mode: 0644]
bin/flowplayer.controls-3.0.3.swf [new file with mode: 0644]
classes/Channel.php [deleted file]
classes/Command.php [deleted file]
classes/CommandInterpreter.php [deleted file]
classes/Notice.php
classes/Notice_tag.php
classes/User.php
classes/laconica.ini
config.php.sample
db/carrier.sql [deleted file]
db/laconica.sql
db/sms_carrier.sql [new file with mode: 0644]
doc-src/about [new file with mode: 0644]
doc-src/contact [new file with mode: 0644]
doc-src/faq [new file with mode: 0644]
doc-src/groups [new file with mode: 0644]
doc-src/help [new file with mode: 0644]
doc-src/im [new file with mode: 0644]
doc-src/openid [new file with mode: 0644]
doc-src/openmublog [new file with mode: 0644]
doc-src/privacy [new file with mode: 0644]
doc-src/sms [new file with mode: 0644]
doc-src/source [new file with mode: 0644]
doc-src/tags [new file with mode: 0644]
doc/about [deleted file]
doc/contact [deleted file]
doc/faq [deleted file]
doc/groups [deleted file]
doc/help [deleted file]
doc/im [deleted file]
doc/openid [deleted file]
doc/openmublog [deleted file]
doc/privacy [deleted file]
doc/sms [deleted file]
doc/source [deleted file]
doc/tags [deleted file]
extlib/Net/URL.php [new file with mode: 0644]
extlib/Net/URL/Mapper.php [new file with mode: 0644]
extlib/Net/URL/Mapper/Exception.php [new file with mode: 0644]
extlib/Net/URL/Mapper/Part.php [new file with mode: 0644]
extlib/Net/URL/Mapper/Part/Dynamic.php [new file with mode: 0644]
extlib/Net/URL/Mapper/Part/Fixed.php [new file with mode: 0644]
extlib/Net/URL/Mapper/Part/Wildcard.php [new file with mode: 0644]
extlib/Net/URL/Mapper/Path.php [new file with mode: 0644]
htaccess.sample
index.php
js/flowplayer-3.0.5.min.js [new file with mode: 0644]
js/jquery.simplemodal-1.2.2.pack.js [new file with mode: 0644]
js/video.js [new file with mode: 0644]
lib/action.php
lib/channel.php [new file with mode: 0644]
lib/command.php [new file with mode: 0644]
lib/commandinterpreter.php [new file with mode: 0644]
lib/common.php
lib/dberroraction.php [new file with mode: 0644]
lib/facebookutil.php
lib/featureduserssection.php
lib/feed.php [new file with mode: 0644]
lib/feedlist.php
lib/grouplist.php
lib/htmloutputter.php
lib/jabber.php
lib/mail.php
lib/popularnoticesection.php
lib/profilelist.php
lib/router.php [new file with mode: 0644]
lib/section.php
lib/twitter.php
lib/util.php
lib/xmlstringer.php [new file with mode: 0644]
plugins/BlogspamNetPlugin.php [new file with mode: 0644]
plugins/GoogleAnalyticsPlugin.php
scripts/facebookqueuehandler.php [new file with mode: 0755]
scripts/startdaemons.sh
scripts/stopdaemons.sh
scripts/twitterqueuehandler.php [new file with mode: 0755]
scripts/update_facebook.php [deleted file]
theme/base/css/display.css
theme/base/css/modal.css [new file with mode: 0644]
theme/base/css/modal_ie.css [new file with mode: 0644]
theme/base/images/x.png [new file with mode: 0644]
theme/readme.txt

index d9634325dbb73701b6542fae5a163f262364be72..af0bee587c1be7dc32eaa514ceac66848b494765 100644 (file)
@@ -15,6 +15,24 @@ StartSecondaryNav: Showing the secondary nav menu
 EndSecondaryNav: At the end of the secondary nav menu
 - $action: the current action
 
+StartShowStyles: Showing Style links; good place to add UA style resets
+- $action: the current action
+
+EndShowStyles: End showing Style links; good place to add custom styles
+- $action: the current action
+
+StartShowLaconicaStyles: Showing Laconica Style links
+- $action: the current action
+
+EndShowLaconicaStyles: End showing Laconica Style links;  good place to add handheld or JavaScript dependant styles
+- $action: the current action
+
+StartShowUAStyles: Showing custom UA Style links
+- $action: the current action
+
+EndShowUAStyles: End showing custom UA Style links; good place to add user-agent (e.g., filter, -webkit, -moz) specific styles
+- $action: the current action
+
 StartShowScripts: Showing JavaScript links
 - $action: the current action
 
@@ -39,3 +57,28 @@ StartShowSections: Start the list of sections in the sidebar
 
 EndShowSections: End the list of sections in the sidebar
 - $action: the current action
+
+StartShowHeader: Showing before the header container
+- $action: the current action
+
+EndShowHeader: Showing after the header container
+- $action: the current action
+
+StartShowFooter: Showing before the footer container
+- $action: the current action
+
+EndShowFooter: Showing after the footer container
+- $action: the current action
+
+StartShowContentBlock: Showing before the content container
+- $action: the current action
+
+EndShowContentBlock: Showing after the content container
+- $action: the current action
+
+StartNoticeSave: before inserting a notice (good place for content filters)
+- $notice: notice being saved (no ID or URI)
+
+EndNoticeSave: after inserting a notice and related code
+- $notice: notice that was saved (with ID and URI)
+
diff --git a/README b/README
index 989fcb7f0ac9913a8822fae65c601d267451d697..67dc9a66b3f95f95af2563a9f21c48e248cc3045 100644 (file)
--- a/README
+++ b/README
@@ -507,7 +507,7 @@ server is probably a good idea for high-volume sites.
    needs as a parameter the install path; if you run it from the
    Laconica dir, "." should suffice.
 
-This will run six (for now) queue handlers:
+This will run eight (for now) queue handlers:
 
 * xmppdaemon.php - listens for new XMPP messages from users and stores
   them as notices in the database.
@@ -521,6 +521,10 @@ This will run six (for now) queue handlers:
   of registered users.
 * xmppconfirmhandler.php - sends confirmation messages to registered
   users.
+* twitterqueuehandler.php - sends queued notices to Twitter for user
+  who have opted to set up Twitter bridging.
+* facebookqueuehandler.php - sends queued notices to Facebook for users
+  of the built-in Facebook application.
 
 Note that these queue daemons are pretty raw, and need your care. In
 particular, they leak memory, and you may want to restart them on a
@@ -553,6 +557,53 @@ Sample cron job:
 # Update Twitter friends subscriptions every half hour
 0,30 * * * * /path/to/php /path/to/laconica/scripts/synctwitterfriends.php>&/dev/null
 
+Built-in Facebook Application 
+-----------------------------
+
+Laconica's Facebook application allows your users to automatically
+update their Facebook statuses with their latest notices, invite
+their friends to use the app (and thus your site), view their notice
+timelines, and post notices -- all from within Facebook. The application
+is built into Laconica and runs on your host.  For automatic Facebook
+status updating to work you will need to enable queuing and run the
+facebookqueuehandler.php daemon (see the "Queues and daemons" section
+above).
+
+Quick setup instructions*:
+
+Install the Facebook Developer application on Facebook: 
+
+    http://www.facebook.com/developers/
+
+Use it to create a new application and generate an API key and secret.
+Uncomment the Facebook app section of your config.php and copy in the
+key and secret, e.g.:
+
+    # Config section for the built-in Facebook application
+    $config['facebook']['apikey'] = 'APIKEY';
+    $config['facebook']['secret'] = 'SECRET';
+
+In Facebook's application editor, specify the following URLs for your app:
+
+- Callback URL: http://example.net/mublog/facebook/
+- Post-Remove URL: http://example.net/mublog/facebook/remove
+- Post-Add Redirect URL: http://apps.facebook.com/yourapp/
+- Canvas URL: http://apps.facebook.com/yourapp/
+
+(Replace 'example.net' with your host's URL, 'mublog' with the path
+to your Laconica installation, and 'yourapp' with the name of the
+Facebook application you created.)
+
+Additionally, Choose "Web" for Application type in the Advanced tab.
+In the "Canvas setting" section, choose the "FBML" for Render Method,
+"Smart Size" for IFrame size, and "Full width (760px)" for Canvas Width.
+Everything else can be left with default values.
+
+*For more detailed instructions please see the installation guide on the
+Laconica wiki:
+
+    http://laconi.ca/trac/wiki/FacebookApplication
+
 Sitemaps
 --------
 
index d75d1b94612b8f6adc42cd5f22c61490fed98a6f..08dcccbddb711c12ff7578e165d99c72b1068545 100644 (file)
@@ -42,9 +42,9 @@ class AllAction extends Action
         if (!$this->page) {
             $this->page = 1;
         }
-        
+
         common_set_returnto($this->selfUrl());
-        
+
         return true;
     }
 
@@ -69,13 +69,22 @@ class AllAction extends Action
         }
     }
 
-    function showFeeds()
+    function getFeeds()
     {
-        $this->element('link', array('rel' => 'alternate',
-                                     'href' => common_local_url('allrss', array('nickname' =>
-                                                                                $this->user->nickname)),
-                                     'type' => 'application/rss+xml',
-                                     'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname)));
+        return array(new Feed(Feed::RSS1,
+                              common_local_url('allrss', array('nickname' =>
+                                                               $this->user->nickname)),
+                              sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
+                     new Feed(Feed::RSS2,
+                              common_local_url('api', array('apiaction' => 'statuses',
+                                                            'method' => 'friends',
+                                                            'argument' => $this->user->nickname.'.rss')),
+                              sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
+                     new Feed(Feed::ATOM,
+                              common_local_url('api', array('apiaction' => 'statuses',
+                                                            'method' => 'friends',
+                                                            'argument' => $this->user->nickname.'.atom')),
+                              sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
     }
 
     function showLocalNav()
@@ -84,15 +93,6 @@ class AllAction extends Action
         $nav->show();
     }
 
-    function showExportData()
-    {
-        $fl = new FeedList($this);
-        $fl->show(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $this->user->nickname)),
-                                 'type' => 'rss',
-                                 'version' => 'RSS 1.0',
-                                 'item' => 'allrss')));
-    }
-
     function showContent()
     {
         $notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
@@ -110,7 +110,7 @@ class AllAction extends Action
         $user =& common_current_user();
         if ($user && ($user->id == $this->user->id)) {
             $this->element('h1', NULL, _("You and friends"));
-        } else { 
+        } else {
             $this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname));
         }
     }
index 7dd53f6eb5af40f4e959d4a79a28f6ef5f988808..f38a44a24a3e782dc20b588005a6d39ac09c47b4 100644 (file)
@@ -145,6 +145,7 @@ class AvatarsettingsAction extends AccountSettingsAction
                                         'height' => AVATAR_PROFILE_SIZE,
                                         'alt' => $user->nickname));
             $this->elementEnd('div');
+            $this->submit('delete', _('Delete'));
             $this->elementEnd('li');
         }
 
@@ -256,6 +257,8 @@ class AvatarsettingsAction extends AccountSettingsAction
             $this->uploadAvatar();
         } else if ($this->arg('crop')) {
             $this->cropAvatar();
+        } else if ($this->arg('delete')) {
+            $this->deleteAvatar();
         } else {
             $this->showForm(_('Unexpected form submission.'));
         }
@@ -344,6 +347,29 @@ class AvatarsettingsAction extends AccountSettingsAction
             $this->showForm(_('Failed updating avatar.'));
         }
     }
+    
+    /**
+     * Get rid of the current avatar.
+     *
+     * @return void
+     */
+    
+    function deleteAvatar()
+    {
+        $user = common_current_user();
+        $profile = $user->getProfile();
+        
+        $avatar = $profile->getOriginalAvatar();
+        $avatar->delete();
+        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+        $avatar->delete();
+        $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
+        $avatar->delete();
+        $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
+        $avatar->delete();
+
+        $this->showForm(_('Avatar deleted.'), true);
+    }
 
     /**
      * Add the jCrop stylesheet
index 6957659add3c1bcaa8455b2ffac167ceab952057..ebffb7c1542fc64843d635b7a19c310c689f20f5 100644 (file)
@@ -50,7 +50,7 @@ class DocAction extends Action
 
     /**
      * Class handler.
-     * 
+     *
      * @param array $args array of arguments
      *
      * @return nothing
@@ -59,7 +59,7 @@ class DocAction extends Action
     {
         parent::handle($args);
         $this->title    = $this->trimmed('title');
-        $this->filename = INSTALLDIR.'/doc/'.$this->title;
+        $this->filename = INSTALLDIR.'/doc-src/'.$this->title;
         if (!file_exists($this->filename)) {
             $this->clientError(_('No such document.'));
             return;
@@ -71,14 +71,14 @@ class DocAction extends Action
     function showPageTitle() {
         $this->element('h1', array('class' => 'entry-title'), $this->title());
     }
-    
+
     // overrided to add hentry, and content-inner classes
     function showContentBlock()
      {
          $this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
          $this->showPageTitle();
          $this->showPageNoticeBlock();
-         $this->elementStart('div', array('id' => 'content_inner', 
+         $this->elementStart('div', array('id' => 'content_inner',
              'class' => 'entry-content'));
          // show the actual content (forms, lists, whatever)
          $this->showContent();
@@ -88,7 +88,7 @@ class DocAction extends Action
 
     /**
      * Display content.
-     * 
+     *
      * @return nothing
      */
     function showContent()
@@ -100,7 +100,7 @@ class DocAction extends Action
 
     /**
      * Page title.
-     * 
+     *
      * @return page title
      */
     function title()
index b84acb214150902cc15e68b6bfe1794f64fa8ab1..634388fdddbdf41acae10d679719d45148c5d869 100644 (file)
@@ -164,6 +164,11 @@ class EmailsettingsAction extends AccountSettingsAction
                         $user->emailnotifymsg);
         $this->elementEnd('li');
         $this->elementStart('li');
+        $this->checkbox('emailnotifyattn',
+                        _('Send me email when someone sends me an "@-reply".'),
+                        $user->emailnotifyattn);
+        $this->elementEnd('li');
+        $this->elementStart('li');
         $this->checkbox('emailnotifynudge',
                         _('Allow friends to nudge me and send me an email.'),
                         $user->emailnotifynudge);
@@ -255,6 +260,7 @@ class EmailsettingsAction extends AccountSettingsAction
         $emailnotifyfav   = $this->boolean('emailnotifyfav');
         $emailnotifymsg   = $this->boolean('emailnotifymsg');
         $emailnotifynudge = $this->boolean('emailnotifynudge');
+        $emailnotifyattn  = $this->boolean('emailnotifyattn');
         $emailmicroid     = $this->boolean('emailmicroid');
         $emailpost        = $this->boolean('emailpost');
 
@@ -270,6 +276,7 @@ class EmailsettingsAction extends AccountSettingsAction
         $user->emailnotifyfav   = $emailnotifyfav;
         $user->emailnotifymsg   = $emailnotifymsg;
         $user->emailnotifynudge = $emailnotifynudge;
+        $user->emailnotifyattn  = $emailnotifyattn;
         $user->emailmicroid     = $emailmicroid;
         $user->emailpost        = $emailpost;
 
index 5e7691f33d1cae68442b8b18b4c643eb3deca24b..9face9644356a0a08375f3dfdeee1dda5d7a7059 100644 (file)
@@ -98,7 +98,12 @@ class NewnoticeAction extends Action
                 return;
             }
 
-            $this->saveNewNotice();
+            try {
+                $this->saveNewNotice();
+            } catch (Exception $e) {
+                $this->showForm($e->getMessage());
+                return;
+            }
         } else {
             $this->showForm();
         }
@@ -123,15 +128,13 @@ class NewnoticeAction extends Action
         $content = $this->trimmed('status_textarea');
 
         if (!$content) {
-            $this->showForm(_('No content!'));
-            return;
+            $this->clientError(_('No content!'));
         } else {
             $content_shortened = common_shorten_links($content);
 
             if (mb_strlen($content_shortened) > 140) {
-                $this->showForm(_('That\'s too long. '.
-                                  'Max notice size is 140 chars.'));
-                return;
+                $this->clientError(_('That\'s too long. '.
+                                     'Max notice size is 140 chars.'));
             }
         }
 
@@ -154,7 +157,7 @@ class NewnoticeAction extends Action
                                   ($replyto == 'false') ? null : $replyto);
 
         if (is_string($notice)) {
-            $this->showForm($notice);
+            $this->clientError($notice);
             return;
         }
 
index a5f01350c4c732bfd1fab1e87ecb8b57873c9ee5..dc58d7528ae315c61c4f58a26bc841d9dc3a4772 100644 (file)
@@ -57,11 +57,11 @@ class NoticesearchAction extends SearchAction
 
         return true;
     }
-    
+
     /**
      * Get instructions
-     * 
-     * @return string instruction text 
+     *
+     * @return string instruction text
      */
     function getInstructions()
     {
@@ -70,7 +70,7 @@ class NoticesearchAction extends SearchAction
 
     /**
      * Get title
-     * 
+     *
      * @return string title
      */
     function title()
@@ -78,6 +78,20 @@ class NoticesearchAction extends SearchAction
         return _('Text search');
     }
 
+    function getFeeds()
+    {
+        $q = $this->trimmed('q');
+
+        if (!$q) {
+            return null;
+        }
+
+        return array(new Feed(Feed::RSS1, common_local_url('noticesearchrss',
+                                                           array('q' => $q)),
+                              sprintf(_('Search results for "%s" on %s'),
+                                      $q, common_config('site', 'name'))));
+    }
+
     /**
      * Show results
      *
@@ -119,26 +133,6 @@ class NoticesearchAction extends SearchAction
                           $page, 'noticesearch', array('q' => $q));
     }
 
-    /**
-     * Show header
-     *
-     * @param array $arr array containing the query
-     *
-     * @return void
-     */
-
-    function extraHead()
-    {
-        $q = $this->trimmed('q');
-        if ($q) {
-            $this->element('link', array('rel' => 'alternate',
-                                         'href' => common_local_url('noticesearchrss',
-                                                                    array('q' => $q)),
-                                         'type' => 'application/rss+xml',
-                                         'title' => _('Search Stream Feed')));
-        }
-    }
-
     /**
      * Show notice
      *
index cc6537f74f8afd4731f2bd15162fbaf176bd8bc7..a20ae40321ca17b36ae28313f4a87eac90d69f92 100644 (file)
@@ -73,9 +73,9 @@ class PublicAction extends Action
     {
         parent::prepare($args);
         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-        
+
         common_set_returnto($this->selfUrl());
-        
+
         return true;
     }
 
@@ -119,12 +119,20 @@ class PublicAction extends Action
      * @return void
      */
 
-    function showFeeds()
+    function getFeeds()
     {
-        $this->element('link', array('rel' => 'alternate',
-                                     'href' => common_local_url('publicrss'),
-                                     'type' => 'application/rss+xml',
-                                     'title' => _('Public Stream Feed')));
+        return array(new Feed(Feed::RSS1, common_local_url('publicrss'),
+                              _('Public Stream Feed (RSS 1.0)')),
+                     new Feed(Feed::RSS2,
+                              common_local_url('api',
+                                               array('apiaction' => 'statuses',
+                                                     'method' => 'public_timeline.rss')),
+                              _('Public Stream Feed (RSS 2.0)')),
+                     new Feed(Feed::ATOM,
+                              common_local_url('api',
+                                               array('apiaction' => 'statuses',
+                                                     'method' => 'public_timeline.atom')),
+                              _('Public Stream Feed (Atom)')));
     }
 
     /**
@@ -185,27 +193,6 @@ class PublicAction extends Action
                           $this->page, 'public');
     }
 
-    /**
-     * Makes a list of exported feeds for this page
-     *
-     * @return void
-     *
-     * @todo I18N
-     */
-
-    function showExportData()
-    {
-        $fl = new FeedList($this);
-        $fl->show(array(0 => array('href' => common_local_url('publicrss'),
-                                   'type' => 'rss',
-                                   'version' => 'RSS 1.0',
-                                   'item' => 'publicrss'),
-                        1 => array('href' => common_local_url('publicatom'),
-                                   'type' => 'atom',
-                                   'version' => 'Atom 1.0',
-                                   'item' => 'publicatom')));
-    }
-
     function showSections()
     {
         // $top = new TopPostersSection($this);
index 7eff74a6691e34505ceda2aa6dccbf9bc979bf33..4ab9b14ed26be98187ee0949c0a2a4b3fac352c6 100644 (file)
@@ -84,7 +84,7 @@ class RepliesAction extends Action
         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
 
         common_set_returnto($this->selfUrl());
-        
+
         return true;
     }
 
@@ -129,16 +129,13 @@ class RepliesAction extends Action
      * @return void
      */
 
-    function showFeeds()
+    function getFeeds()
     {
         $rssurl   = common_local_url('repliesrss',
                                      array('nickname' => $this->user->nickname));
         $rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname);
 
-        $this->element('link', array('rel' => 'alternate',
-                                     'href' => $rssurl,
-                                     'type' => 'application/rss+xml',
-                                     'title' => $rsstitle));
+        return array(new Feed(Feed::RSS1, $rssurl, $rsstitle));
     }
 
     /**
@@ -153,25 +150,6 @@ class RepliesAction extends Action
         $nav->show();
     }
 
-    /**
-     * Show the replies feed links
-     *
-     * @return void
-     */
-
-    function showExportData()
-    {
-        $fl = new FeedList($this);
-
-        $rssurl = common_local_url('repliesrss',
-                                   array('nickname' => $this->user->nickname));
-
-        $fl->show(array(0=>array('href'=> $rssurl,
-                                 'type' => 'rss',
-                                 'version' => 'RSS 1.0',
-                                 'item' => 'repliesrss')));
-    }
-
     /**
      * Show the content
      *
index 31479e1a7891d0933e63cb8bc5735ccc99d59345..d1c9283f0f47bff1a6811039a891760898de3f87 100644 (file)
@@ -113,7 +113,7 @@ class ShowfavoritesAction extends Action
         }
 
         common_set_returnto($this->selfUrl());
-        
+
         return true;
     }
 
@@ -136,10 +136,10 @@ class ShowfavoritesAction extends Action
     /**
      * Feeds for the <head> section
      *
-     * @return void
+     * @return array Feed objects to show
      */
 
-    function showFeeds()
+    function getFeeds()
     {
         $feedurl   = common_local_url('favoritesrss',
                                       array('nickname' =>
@@ -147,10 +147,7 @@ class ShowfavoritesAction extends Action
         $feedtitle = sprintf(_('Feed for favorites of %s'),
                              $this->user->nickname);
 
-        $this->element('link', array('rel' => 'alternate',
-                                     'href' => $feedurl,
-                                     'type' => 'application/rss+xml',
-                                     'title' => $feedtitle));
+        return array(new Feed(Feed::RSS1, $feedurl, $feedtitle));
     }
 
     /**
@@ -165,28 +162,6 @@ class ShowfavoritesAction extends Action
         $nav->show();
     }
 
-    /**
-     * Show the replies feed links
-     *
-     * @return void
-     */
-
-    function showExportData()
-    {
-        $feedurl = common_local_url('favoritesrss',
-                                    array('nickname' =>
-                                          $this->user->nickname));
-
-        $fl = new FeedList($this);
-
-        // XXX: I18N
-
-        $fl->show(array(0=>array('href'=> $feedurl,
-                                 'type' => 'rss',
-                                 'version' => 'RSS 1.0',
-                                 'item' => 'Favorites')));
-    }
-
     /**
      * Show the content
      *
index 7bc68fbc64a151ac377c414a4ace0e0d52997d26..c20941a35ee07776acb475fd69152e4b139b79b4 100644 (file)
@@ -244,7 +244,7 @@ class ShowgroupAction extends Action
         if ($this->group->location) {
             $this->elementStart('dl', 'entity_location');
             $this->element('dt', null, _('Location'));
-            $this->element('dd', 'location', $this->group->location);
+            $this->element('dd', 'label', $this->group->location);
             $this->elementEnd('dl');
         }
 
@@ -292,37 +292,18 @@ class ShowgroupAction extends Action
     }
 
     /**
-     * Show a list of links to feeds this page produces
+     * Get a list of the feeds for this page
      *
      * @return void
      */
 
-    function showExportData()
-    {
-        $fl = new FeedList($this);
-        $fl->show(array(0=>array('href'=>common_local_url('grouprss',
-                                                          array('nickname' => $this->group->nickname)),
-                                 'type' => 'rss',
-                                 'version' => 'RSS 1.0',
-                                 'item' => 'notices')));
-    }
-
-    /**
-     * Show a list of links to feeds this page produces
-     *
-     * @return void
-     */
-
-    function showFeeds()
+    function getFeeds()
     {
         $url =
           common_local_url('grouprss',
                            array('nickname' => $this->group->nickname));
 
-        $this->element('link', array('rel' => 'alternate',
-                                     'href' => $url,
-                                     'type' => 'application/rss+xml',
-                                     'title' => sprintf(_('Notice feed for %s group'),
+        return array(new Feed(Feed::RSS1, $url, sprintf(_('Notice feed for %s group'),
                                                         $this->group->nickname)));
     }
 
index 962f4b4524f499be25b7e1e403709e7b6ba543b9..c736c99b5db774ee78e18563fa903893ca52fd81 100644 (file)
@@ -155,54 +155,35 @@ class ShowstreamAction extends Action
         return;
     }
 
-    function showExportData()
+    function getFeeds()
     {
-        $fl = new FeedList($this);
-        $fl->show(array(0=>array('href'=>common_local_url('userrss',
-                                                          array('nickname' => $this->user->nickname)),
-                                 'type' => 'rss',
-                                 'version' => 'RSS 1.0',
-                                 'item' => 'notices'),
-                        1=>array('href'=>common_local_url('usertimeline',
-                                                          array('nickname' => $this->user->nickname)),
-                                 'type' => 'atom',
-                                 'version' => 'Atom 1.0',
-                                 'item' => 'usertimeline'),
-                        2=>array('href'=>common_local_url('foaf',
-                                                          array('nickname' => $this->user->nickname)),
-                                 'type' => 'rdf',
-                                 'version' => 'FOAF',
-                                 'item' => 'foaf')));
-    }
-
-    function showFeeds()
-    {
-        $this->element('link', array('rel' => 'alternate',
-                                     'type' => 'application/rss+xml',
-                                     'href' => common_local_url('userrss',
-                                                                array('nickname' => $this->user->nickname)),
-                                     'title' => sprintf(_('Notice feed for %s (RSS)'),
-                                                        $this->user->nickname)));
-
-        $this->element('link',
-                       array('rel' => 'alternate',
-                             'href' => common_local_url('api',
-                                                        array('apiaction' => 'statuses',
-                                                              'method' => 'user_timeline.atom',
-                                                              'argument' => $this->user->nickname)),
-                             'type' => 'application/atom+xml',
-                             'title' => sprintf(_('Notice feed for %s (Atom)'),
-                                                $this->user->nickname)));
+        return array(new Feed(Feed::RSS1,
+                              common_local_url('userrss',
+                                               array('nickname' => $this->user->nickname)),
+                              sprintf(_('Notice feed for %s (RSS 1.0)'),
+                                      $this->user->nickname)),
+                     new Feed(Feed::RSS2,
+                              common_local_url('api',
+                                               array('apiaction' => 'statuses',
+                                                     'method' => 'user_timeline',
+                                                     'argument' => $this->user->nickname.'.rss')),
+                              sprintf(_('Notice feed for %s (RSS 2.0)'),
+                                      $this->user->nickname)),
+                     new Feed(Feed::ATOM,
+                              common_local_url('api',
+                                               array('apiaction' => 'statuses',
+                                                     'method' => 'user_timeline',
+                                                     'argument' => $this->user->nickname.'.atom')),
+                              sprintf(_('Notice feed for %s (Atom)'),
+                                      $this->user->nickname)),
+                     new Feed(Feed::FOAF,
+                              common_local_url('foaf', array('nickname' =>
+                                                             $this->user->nickname)),
+                              sprintf(_('FOAF for %s'), $this->user->nickname)));
     }
 
     function extraHead()
     {
-        // FOAF
-        $this->element('link', array('rel' => 'meta',
-                                     'href' => common_local_url('foaf', array('nickname' =>
-                                                                              $this->user->nickname)),
-                                     'type' => 'application/rdf+xml',
-                                     'title' => 'FOAF'));
         // for remote subscriptions etc.
         $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
                                      'content' => common_local_url('xrds', array('nickname' =>
@@ -281,7 +262,7 @@ class ShowstreamAction extends Action
         if ($this->profile->location) {
             $this->elementStart('dl', 'entity_location');
             $this->element('dt', null, _('Location'));
-            $this->element('dd', 'location', $this->profile->location);
+            $this->element('dd', 'label', $this->profile->location);
             $this->elementEnd('dl');
         }
 
index 4401f892a94603df41e2b06748bba5cca35bcb05..231f2c299280580842099f251541fbc9d2619204 100644 (file)
@@ -37,9 +37,9 @@ class TagAction extends Action
         }
 
         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-        
+
         common_set_returnto($this->selfUrl());
-        
+
         return true;
     }
 
@@ -61,12 +61,11 @@ class TagAction extends Action
         $this->showPage();
     }
 
-    function showFeeds()
+    function getFeeds()
     {
-        $this->element('link', array('rel' => 'alternate',
-                                     'href' => common_local_url('tagrss', array('tag' => $this->tag)),
-                                     'type' => 'application/rss+xml',
-                                     'title' => sprintf(_('Feed for tag %s'), $this->tag)));
+        return array(new Feed(Feed::RSS1,
+                              common_local_url('tagrss', array('tag' => $this->tag)),
+                              sprintf(_('Feed for tag %s'), $this->tag)));
     }
 
     function showPageNotice()
@@ -74,15 +73,6 @@ class TagAction extends Action
         return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
     }
 
-    function showExportData()
-    {
-        $fl = new FeedList($this);
-        $fl->show(array(0=>array('href'=>common_local_url('tagrss', array('tag' => $this->tag)),
-                                 'type' => 'rss',
-                                 'version' => 'RSS 1.0',
-                                 'item' => 'tagrss')));
-    }
-
     function showContent()
     {
         $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
index 3e8a12fd693d3d78a3717530dee6e31ec35795b9..79151c91184a7c7e3642eefea49c48c2fe579c10 100644 (file)
@@ -110,7 +110,7 @@ class TagotherAction extends Action
         if ($this->profile->location) {
             $this->elementStart('dl', 'entity_location');
             $this->element('dt', null, _('Location'));
-            $this->element('dd', 'location', $this->profile->location);
+            $this->element('dd', 'label', $this->profile->location);
             $this->elementEnd('dl');
         }
         if ($this->profile->homepage) {
index 2d41469bba01b9c2456af282819b42d78052e96b..a79859bbf0a9205c40c25022913477b0a4d5193c 100644 (file)
@@ -32,6 +32,7 @@ if (!defined('LACONICA')) {
 }
 
 require_once INSTALLDIR.'/lib/connectsettingsaction.php';
+require_once INSTALLDIR.'/lib/twitter.php';
 
 define('SUBSCRIPTIONS', 80);
 
@@ -90,7 +91,7 @@ class TwittersettingsAction extends ConnectSettingsAction
 
         $fuser = null;
 
-        $flink = Foreign_link::getByUserID($user->id, 1); // 1 == Twitter
+        $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
 
         if ($flink) {
             $fuser = $flink->getForeignUser();
@@ -358,7 +359,7 @@ class TwittersettingsAction extends ConnectSettingsAction
 
         $flink->user_id     = $user->id;
         $flink->foreign_id  = $twit_user->id;
-        $flink->service     = 1; // Twitter
+        $flink->service     = TWITTER_SERVICE;
         $flink->credentials = $password;
         $flink->created     = common_sql_now();
 
diff --git a/bin/flowplayer-3.0.5.swf b/bin/flowplayer-3.0.5.swf
new file mode 100644 (file)
index 0000000..05b64a0
Binary files /dev/null and b/bin/flowplayer-3.0.5.swf differ
diff --git a/bin/flowplayer.audio-3.0.3.swf b/bin/flowplayer.audio-3.0.3.swf
new file mode 100644 (file)
index 0000000..ef85f1b
Binary files /dev/null and b/bin/flowplayer.audio-3.0.3.swf differ
diff --git a/bin/flowplayer.controls-3.0.3.swf b/bin/flowplayer.controls-3.0.3.swf
new file mode 100644 (file)
index 0000000..09a27e8
Binary files /dev/null and b/bin/flowplayer.controls-3.0.3.swf differ
diff --git a/classes/Channel.php b/classes/Channel.php
deleted file mode 100644 (file)
index fdeff21..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-<?php
-/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-if (!defined('LACONICA')) { exit(1); }
-
-class Channel
-{
-
-    function on($user)
-    {
-        return false;
-    }
-
-    function off($user)
-    {
-        return false;
-    }
-
-    function output($user, $text)
-    {
-        return false;
-    }
-
-    function error($user, $text)
-    {
-        return false;
-    }
-
-    function source()
-    {
-        return null;
-    }
-}
-
-class XMPPChannel extends Channel
-{
-
-    var $conn = null;
-
-    function source()
-    {
-        return 'xmpp';
-    }
-
-    function __construct($conn)
-    {
-        $this->conn = $conn;
-    }
-
-    function on($user)
-    {
-        return $this->set_notify($user, 1);
-    }
-
-    function off($user)
-    {
-        return $this->set_notify($user, 0);
-    }
-
-    function output($user, $text)
-    {
-        $text = '['.common_config('site', 'name') . '] ' . $text;
-        jabber_send_message($user->jabber, $text);
-    }
-
-    function error($user, $text)
-    {
-        $text = '['.common_config('site', 'name') . '] ' . $text;
-        jabber_send_message($user->jabber, $text);
-    }
-
-    function set_notify(&$user, $notify)
-    {
-        $orig = clone($user);
-        $user->jabbernotify = $notify;
-        $result = $user->update($orig);
-        if (!$result) {
-            $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
-            common_log(LOG_ERR,
-                       'Could not set notify flag to ' . $notify .
-                       ' for user ' . common_log_objstring($user) .
-                       ': ' . $last_error->message);
-            return false;
-        } else {
-            common_log(LOG_INFO,
-                       'User ' . $user->nickname . ' set notify flag to ' . $notify);
-            return true;
-        }
-    }
-}
-
-class WebChannel extends Channel
-{
-    var $out = null;
-
-    function __construct($out=null)
-    {
-        $this->out = $out;
-    }
-
-    function source()
-    {
-        return 'web';
-    }
-
-    function on($user)
-    {
-        return false;
-    }
-
-    function off($user)
-    {
-        return false;
-    }
-
-    function output($user, $text)
-    {
-        # XXX: buffer all output and send it at the end
-        # XXX: even better, redirect to appropriate page
-        #      depending on what command was run
-        $this->out->startHTML();
-        $this->out->elementStart('head');
-        $this->out->element('title', null, _('Command results'));
-        $this->out->elementEnd('head');
-        $this->out->elementStart('body');
-        $this->out->element('p', array('id' => 'command_result'), $text);
-        $this->out->elementEnd('body');
-        $this->out->endHTML();
-    }
-
-    function error($user, $text)
-    {
-        common_user_error($text);
-    }
-}
-
-class AjaxWebChannel extends WebChannel
-{
-    function output($user, $text)
-    {
-        $this->out->startHTML('text/xml;charset=utf-8');
-        $this->out->elementStart('head');
-        $this->out->element('title', null, _('Command results'));
-        $this->out->elementEnd('head');
-        $this->out->elementStart('body');
-        $this->out->element('p', array('id' => 'command_result'), $text);
-        $this->out->elementEnd('body');
-        $this->out->endHTML();
-    }
-
-    function error($user, $text)
-    {
-        $this->out->startHTML('text/xml;charset=utf-8');
-        $this->out->elementStart('head');
-        $this->out->element('title', null, _('Ajax Error'));
-        $this->out->elementEnd('head');
-        $this->out->elementStart('body');
-        $this->out->element('p', array('id' => 'error'), $text);
-        $this->out->elementEnd('body');
-        $this->out->endHTML();
-    }
-}
-
-class MailChannel extends Channel
-{
-
-    var $addr = null;
-
-    function source()
-    {
-        return 'mail';
-    }
-
-    function __construct($addr=null)
-    {
-        $this->addr = $addr;
-    }
-
-    function on($user)
-    {
-        return $this->set_notify($user, 1);
-    }
-
-    function off($user)
-    {
-        return $this->set_notify($user, 0);
-    }
-
-    function output($user, $text)
-    {
-
-        $headers['From'] = $user->incomingemail;
-        $headers['To'] = $this->addr;
-
-        $headers['Subject'] = _('Command complete');
-
-        return mail_send(array($this->addr), $headers, $text);
-    }
-
-    function error($user, $text)
-    {
-
-        $headers['From'] = $user->incomingemail;
-        $headers['To'] = $this->addr;
-
-        $headers['Subject'] = _('Command failed');
-
-        return mail_send(array($this->addr), $headers, $text);
-    }
-
-    function set_notify($user, $value)
-    {
-        $orig = clone($user);
-        $user->smsnotify = $value;
-        $result = $user->update($orig);
-        if (!$result) {
-            common_log_db_error($user, 'UPDATE', __FILE__);
-            return false;
-        }
-        return true;
-    }
-}
diff --git a/classes/Command.php b/classes/Command.php
deleted file mode 100644 (file)
index eacbdac..0000000
+++ /dev/null
@@ -1,419 +0,0 @@
-<?php
-/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-if (!defined('LACONICA')) { exit(1); }
-
-require_once(INSTALLDIR.'/classes/Channel.php');
-
-class Command
-{
-    
-    var $user = null;
-    
-    function __construct($user=null)
-    {
-        $this->user = $user;
-    }
-    
-    function execute($channel)
-    {
-        return false;
-    }
-}
-
-class UnimplementedCommand extends Command
-{
-    function execute($channel)
-    {
-        $channel->error($this->user, _("Sorry, this command is not yet implemented."));
-    }
-}
-
-class TrackingCommand extends UnimplementedCommand
-{
-}
-
-class TrackOffCommand extends UnimplementedCommand
-{
-}
-
-class TrackCommand extends UnimplementedCommand
-{
-    var $word = null;
-    function __construct($user, $word)
-    {
-        parent::__construct($user);
-        $this->word = $word;
-    }
-}
-
-class UntrackCommand extends UnimplementedCommand
-{
-    var $word = null;
-    function __construct($user, $word)
-    {
-        parent::__construct($user);
-        $this->word = $word;
-    }
-}
-
-class NudgeCommand extends UnimplementedCommand
-{
-    var $other = null;
-    function __construct($user, $other)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-}
-
-class InviteCommand extends UnimplementedCommand
-{
-    var $other = null;
-    function __construct($user, $other)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-}
-
-class StatsCommand extends Command
-{
-    function execute($channel)
-    {
-
-        $subs = new Subscription();
-        $subs->subscriber = $this->user->id;
-        $subs_count = (int) $subs->count() - 1;
-
-        $subbed = new Subscription();
-        $subbed->subscribed = $this->user->id;
-        $subbed_count = (int) $subbed->count() - 1;
-
-        $notices = new Notice();
-        $notices->profile_id = $this->user->id;
-        $notice_count = (int) $notices->count();
-        
-        $channel->output($this->user, sprintf(_("Subscriptions: %1\$s\n".
-                                   "Subscribers: %2\$s\n".
-                                   "Notices: %3\$s"),
-                                 $subs_count,
-                                 $subbed_count,
-                                 $notice_count));
-    }
-}
-
-class FavCommand extends Command
-{
-    
-    var $other = null;
-    
-    function __construct($user, $other)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-    
-    function execute($channel)
-    {
-        
-        $recipient = 
-          common_relative_profile($this->user, common_canonical_nickname($this->other));
-        
-        if (!$recipient) {
-            $channel->error($this->user, _('No such user.'));
-            return;
-        }
-        $notice = $recipient->getCurrentNotice();
-        if (!$notice) {
-            $channel->error($this->user, _('User has no last notice'));
-            return;
-        }
-        
-        $fave = Fave::addNew($this->user, $notice);
-
-        if (!$fave) {
-            $channel->error($this->user, _('Could not create favorite.'));
-            return;
-        }
-
-        $other = User::staticGet('id', $recipient->id);
-        
-        if ($other && $other->id != $user->id) {
-            if ($other->email && $other->emailnotifyfav) {
-                mail_notify_fave($other, $this->user, $notice);
-            }
-        }
-        
-        $this->user->blowFavesCache();
-        
-        $channel->output($this->user, _('Notice marked as fave.'));
-    }
-}
-
-class WhoisCommand extends Command
-{
-    var $other = null;
-    function __construct($user, $other)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-    
-    function execute($channel)
-    {
-        $recipient = 
-          common_relative_profile($this->user, common_canonical_nickname($this->other));
-        
-        if (!$recipient) {
-            $channel->error($this->user, _('No such user.'));
-            return;
-        }
-        
-        $whois = sprintf(_("%1\$s (%2\$s)"), $recipient->nickname,
-                         $recipient->profileurl);
-        if ($recipient->fullname) {
-            $whois .= "\n" . sprintf(_('Fullname: %s'), $recipient->fullname);
-        }
-        if ($recipient->location) {
-            $whois .= "\n" . sprintf(_('Location: %s'), $recipient->location);
-        }
-        if ($recipient->homepage) {
-            $whois .= "\n" . sprintf(_('Homepage: %s'), $recipient->homepage);
-        }
-        if ($recipient->bio) {
-            $whois .= "\n" . sprintf(_('About: %s'), $recipient->bio);
-        }
-        $channel->output($this->user, $whois);
-    }
-}
-
-class MessageCommand extends Command
-{
-    var $other = null;
-    var $text = null;
-    function __construct($user, $other, $text)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-        $this->text = $text;
-    }
-    
-    function execute($channel)
-    {
-        $other = User::staticGet('nickname', common_canonical_nickname($this->other));
-        $len = mb_strlen($this->text);
-        if ($len == 0) {
-            $channel->error($this->user, _('No content!'));
-            return;
-        } else if ($len > 140) {
-            $content = common_shorten_links($content);
-            if (mb_strlen($content) > 140) {
-                $channel->error($this->user, sprintf(_('Message too long - maximum is 140 characters, you sent %d'), $len));
-                return;
-            }
-        }
-        
-        if (!$other) {
-            $channel->error($this->user, _('No such user.'));
-            return;
-        } else if (!$this->user->mutuallySubscribed($other)) {
-            $channel->error($this->user, _('You can\'t send a message to this user.'));
-            return;
-        } else if ($this->user->id == $other->id) {
-            $channel->error($this->user, _('Don\'t send a message to yourself; just say it to yourself quietly instead.'));
-            return;
-        }
-        $message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
-        if ($message) {
-            $channel->output($this->user, sprintf(_('Direct message to %s sent'), $this->other));
-        } else {
-            $channel->error($this->user, _('Error sending direct message.'));
-        }
-    }
-}
-
-class GetCommand extends Command
-{
-    
-    var $other = null;
-    
-    function __construct($user, $other)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-    
-    function execute($channel)
-    {
-        $target_nickname = common_canonical_nickname($this->other);
-        
-        $target =
-          common_relative_profile($this->user, $target_nickname);
-
-        if (!$target) {
-            $channel->error($this->user, _('No such user.'));
-            return;
-        }
-        $notice = $target->getCurrentNotice();
-        if (!$notice) {
-            $channel->error($this->user, _('User has no last notice'));
-            return;
-        }
-        $notice_content = $notice->content;
-        
-        $channel->output($this->user, $target_nickname . ": " . $notice_content);
-    }
-}
-
-class SubCommand extends Command
-{
-    
-    var $other = null;
-    
-    function __construct($user, $other)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-    
-    function execute($channel)
-    {
-        
-        if (!$this->other) {
-            $channel->error($this->user, _('Specify the name of the user to subscribe to'));
-            return;
-        }
-        
-        $result = subs_subscribe_user($this->user, $this->other);
-        
-        if ($result == 'true') {
-            $channel->output($this->user, sprintf(_('Subscribed to %s'), $this->other));
-        } else {
-            $channel->error($this->user, $result);
-        }
-    }
-}
-
-class UnsubCommand extends Command
-{
-
-    var $other = null;
-    
-    function __construct($user, $other)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-
-    function execute($channel)
-    {
-        if(!$this->other) {
-            $channel->error($this->user, _('Specify the name of the user to unsubscribe from'));
-            return;
-        }
-        
-        $result=subs_unsubscribe_user($this->user, $this->other);
-        
-        if ($result) {
-            $channel->output($this->user, sprintf(_('Unsubscribed from %s'), $this->other));
-        } else {
-            $channel->error($this->user, $result);
-        }
-    }
-}
-
-class OffCommand extends Command
-{
-    var $other = null;
-    function __construct($user, $other=null)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-    function execute($channel)
-    {
-        if ($other) {
-            $channel->error($this->user, _("Command not yet implemented."));
-        } else {
-            if ($channel->off($this->user)) {
-                $channel->output($this->user, _('Notification off.'));
-            } else {
-                $channel->error($this->user, _('Can\'t turn off notification.'));
-            }
-        }
-    }
-}
-
-class OnCommand extends Command
-{
-    var $other = null;
-    function __construct($user, $other=null)
-    {
-        parent::__construct($user);
-        $this->other = $other;
-    }
-    
-    function execute($channel)
-    {
-        if ($other) {
-            $channel->error($this->user, _("Command not yet implemented."));
-        } else {
-            if ($channel->on($this->user)) {
-                $channel->output($this->user, _('Notification on.'));
-            } else {
-                $channel->error($this->user, _('Can\'t turn on notification.'));
-            }
-        }
-    }
-}
-
-class HelpCommand extends Command
-{
-    function execute($channel)
-    {
-        $channel->output($this->user,
-                         _("Commands:\n".
-                           "on - turn on notifications\n".
-                           "off - turn off notifications\n".
-                           "help - show this help\n".
-                           "follow <nickname> - subscribe to user\n".
-                           "leave <nickname> - unsubscribe from user\n".
-                           "d <nickname> <text> - direct message to user\n".
-                           "get <nickname> - get last notice from user\n".
-                           "whois <nickname> - get profile info on user\n".
-                           "fav <nickname> - add user's last notice as a 'fave'\n".
-                           "stats - get your stats\n".
-                           "stop - same as 'off'\n".
-                           "quit - same as 'off'\n".
-                           "sub <nickname> - same as 'follow'\n".
-                           "unsub <nickname> - same as 'leave'\n".
-                           "last <nickname> - same as 'get'\n".
-                           "on <nickname> - not yet implemented.\n".
-                           "off <nickname> - not yet implemented.\n".                           
-                           "nudge <nickname> - not yet implemented.\n".
-                           "invite <phone number> - not yet implemented.\n".
-                           "track <word> - not yet implemented.\n".
-                           "untrack <word> - not yet implemented.\n".
-                           "track off - not yet implemented.\n".
-                           "untrack all - not yet implemented.\n".
-                           "tracks - not yet implemented.\n".
-                           "tracking - not yet implemented.\n"));
-    }
-}
diff --git a/classes/CommandInterpreter.php b/classes/CommandInterpreter.php
deleted file mode 100644 (file)
index 0679f54..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-<?php
-/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-if (!defined('LACONICA')) { exit(1); }
-
-require_once(INSTALLDIR.'/classes/Command.php');
-
-class CommandInterpreter
-{
-
-    function handle_command($user, $text)
-    {
-        # XXX: localise
-
-        $text = preg_replace('/\s+/', ' ', trim($text));
-        list($cmd, $arg) = explode(' ', $text, 2);
-
-        # We try to support all the same commands as Twitter, see
-        # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands
-        # There are a few compatibility commands from earlier versions of
-        # Laconica
-
-        switch(strtolower($cmd)) {
-         case 'help':
-            if ($arg) {
-                return null;
-            }
-            return new HelpCommand($user);
-         case 'on':
-            if ($arg) {
-                list($other, $extra) = explode(' ', $arg, 2);
-                if ($extra) {
-                    return null;
-                } else {
-                    return new OnCommand($user, $other);
-                }
-            } else {
-                return new OnCommand($user);
-            }
-         case 'off':
-            if ($arg) {
-                list($other, $extra) = explode(' ', $arg, 2);
-                if ($extra) {
-                    return null;
-                } else {
-                    return new OffCommand($user, $other);
-                }
-            } else {
-                return new OffCommand($user);
-            }
-         case 'stop':
-         case 'quit':
-            if ($arg) {
-                return null;
-            } else {
-                return new OffCommand($user);
-            }
-         case 'follow':
-         case 'sub':
-            if (!$arg) {
-                return null;
-            }
-            list($other, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else {
-                return new SubCommand($user, $other);
-            }
-         case 'leave':
-         case 'unsub':
-            if (!$arg) {
-                return null;
-            }
-            list($other, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else {
-                return new UnsubCommand($user, $other);
-            }
-         case 'get':
-         case 'last':
-            if (!$arg) {
-                return null;
-            }
-            list($other, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else {
-                return new GetCommand($user, $other);
-            }
-         case 'd':
-         case 'dm':
-            if (!$arg) {
-                return null;
-            }
-            list($other, $extra) = explode(' ', $arg, 2);
-            if (!$extra) {
-                return null;
-            } else {
-                return new MessageCommand($user, $other, $extra);
-            }
-         case 'whois':
-            if (!$arg) {
-                return null;
-            }
-            list($other, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else {
-                return new WhoisCommand($user, $other);
-            }
-         case 'fav':
-            if (!$arg) {
-                return null;
-            }
-            list($other, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else {
-                return new FavCommand($user, $other);
-            }
-         case 'nudge':
-            if (!$arg) {
-                return null;
-            }
-            list($other, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else {
-                return new NudgeCommand($user, $other);
-            }
-         case 'stats':
-            if ($arg) {
-                return null;
-            }
-            return new StatsCommand($user);
-         case 'invite':
-            if (!$arg) {
-                return null;
-            }
-            list($other, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else {
-                return new InviteCommand($user, $other);
-            }
-         case 'track':
-            if (!$arg) {
-                return null;
-            }
-            list($word, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else if ($word == 'off') {
-                return new TrackOffCommand($user);
-            } else {
-                return new TrackCommand($user, $word);
-            }
-         case 'untrack':
-            if (!$arg) {
-                return null;
-            }
-            list($word, $extra) = explode(' ', $arg, 2);
-            if ($extra) {
-                return null;
-            } else if ($word == 'all') {
-                return new TrackOffCommand($user);
-            } else {
-                return new UntrackCommand($user, $word);
-            }
-         case 'tracks':
-         case 'tracking':
-            if ($arg) {
-                return null;
-            }
-            return new TrackingCommand($user);
-         default:
-            return false;
-        }
-    }
-}
-
index 32998836862043f1ca74a9602f478a9328440774..8300667fa469c5d8c3f5d1d73c0c415e9cd38f0a 100644 (file)
@@ -34,22 +34,23 @@ class Notice extends Memcached_DataObject
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
 
-    public $__table = 'notice';                             // table name
-    public $id;                                 // int(4)    primary_key not_null
-    public $profile_id;                         // int(4)     not_null
+    public $__table = 'notice';                          // table name
+    public $id;                              // int(4)  primary_key not_null
+    public $profile_id;                      // int(4)   not_null
     public $uri;                             // varchar(255)  unique_key
     public $content;                         // varchar(140)
-    public $rendered;                         // text()
+    public $rendered;                        // text()
     public $url;                             // varchar(255)
-    public $created;                         // datetime()     not_null
-    public $modified;                         // timestamp()      not_null default_CURRENT_TIMESTAMP
-    public $reply_to;                         // int(4)
-    public $is_local;                         // tinyint(1)
-    public $source;                             // varchar(32)
+    public $created;                         // datetime()   not_null
+    public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
+    public $reply_to;                        // int(4)
+    public $is_local;                        // tinyint(1)
+    public $source;                          // varchar(32)
 
     /* Static get */
-    function staticGet($k,$v=null)
-    { return Memcached_DataObject::staticGet('Notice',$k,$v); }
+    function staticGet($k,$v=NULL) {
+        return Memcached_DataObject::staticGet('Notice',$k,$v);
+    }
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
@@ -94,23 +95,28 @@ class Notice extends Memcached_DataObject
         /* Add them to the database */
         foreach(array_unique($match[1]) as $hashtag) {
             /* elide characters we don't want in the tag */
-            $hashtag = common_canonical_tag($hashtag);
-
-            $tag = DB_DataObject::factory('Notice_tag');
-            $tag->notice_id = $this->id;
-            $tag->tag = $hashtag;
-            $tag->created = $this->created;
-            $id = $tag->insert();
-            if (!$id) {
-                $last_error = PEAR::getStaticProperty('DB_DataObject','lastError');
-                common_log(LOG_ERR, 'DB error inserting hashtag: ' . $last_error->message);
-                common_server_error(sprintf(_('DB error inserting hashtag: %s'), $last_error->message));
-                return;
-            }
+            $this->saveTag($hashtag);
         }
         return true;
     }
 
+    function saveTag($hashtag)
+    {
+        $hashtag = common_canonical_tag($hashtag);
+
+        $tag = new Notice_tag();
+        $tag->notice_id = $this->id;
+        $tag->tag = $hashtag;
+        $tag->created = $this->created;
+        $id = $tag->insert();
+
+        if (!$id) {
+            throw new ServerException(sprintf(_('DB error inserting hashtag: %s'),
+                                              $last_error->message));
+            return;
+        }
+    }
+
     static function saveNew($profile_id, $content, $source=null, $is_local=1, $reply_to=null, $uri=null) {
 
         $profile = Profile::staticGet($profile_id);
@@ -136,10 +142,12 @@ class Notice extends Memcached_DataObject
         $notice->profile_id = $profile_id;
 
         $blacklist = common_config('public', 'blacklist');
+        $autosource = common_config('public', 'autosource');
 
         # Blacklisted are non-false, but not 1, either
 
-        if ($blacklist && in_array($profile_id, $blacklist)) {
+        if (($blacklist && in_array($profile_id, $blacklist)) ||
+            ($source && $autosource && in_array($source, $autosource))) {
             $notice->is_local = -1;
         } else {
             $notice->is_local = $is_local;
@@ -154,32 +162,37 @@ class Notice extends Memcached_DataObject
         $notice->source = $source;
         $notice->uri = $uri;
 
-        $id = $notice->insert();
-
-        if (!$id) {
-            common_log_db_error($notice, 'INSERT', __FILE__);
-            return _('Problem saving notice.');
-        }
+        if (Event::handle('StartNoticeSave', array(&$notice))) {
 
-        # Update the URI after the notice is in the database
-        if (!$uri) {
-            $orig = clone($notice);
-            $notice->uri = common_notice_uri($notice);
+            $id = $notice->insert();
 
-            if (!$notice->update($orig)) {
-                common_log_db_error($notice, 'UPDATE', __FILE__);
+            if (!$id) {
+                common_log_db_error($notice, 'INSERT', __FILE__);
                 return _('Problem saving notice.');
             }
-        }
 
-        # XXX: do we need to change this for remote users?
+            # Update the URI after the notice is in the database
+            if (!$uri) {
+                $orig = clone($notice);
+                $notice->uri = common_notice_uri($notice);
+
+                if (!$notice->update($orig)) {
+                    common_log_db_error($notice, 'UPDATE', __FILE__);
+                    return _('Problem saving notice.');
+                }
+            }
+
+            # XXX: do we need to change this for remote users?
+
+            $notice->saveReplies();
+            $notice->saveTags();
+            $notice->saveGroups();
 
-        $notice->saveReplies();
-        $notice->saveTags();
-        $notice->saveGroups();
+            $notice->addToInboxes();
+            $notice->query('COMMIT');
 
-        $notice->addToInboxes();
-               $notice->query('COMMIT');
+            Event::handle('EndNoticeSave', array($notice));
+        }
 
         # Clear the cache for subscribed users, so they'll update at next request
         # XXX: someone clever could prepend instead of clearing the cache
@@ -614,6 +627,15 @@ class Notice extends Memcached_DataObject
                 continue;
             }
 
+            // we automatically add a tag for every group name, too
+
+            $tag = Notice_tag::pkeyGet(array('tag' => common_canonical_tag($nickname),
+                                           'notice_id' => $this->id));
+
+            if (is_null($tag)) {
+                $this->saveTag($nickname);
+            }
+
             if ($profile->isMember($group)) {
 
                 $gi = new Group_inbox();
@@ -725,10 +747,19 @@ class Notice extends Memcached_DataObject
                         if (!$id) {
                             common_log_db_error($reply, 'INSERT', __FILE__);
                             return;
+                        } else {
+                            $replied[$recipient->id] = 1;
                         }
                     }
                 }
             }
         }
+
+        foreach (array_keys($replied) as $recipient) {
+            $user = User::staticGet('id', $recipient);
+            if ($user) {
+                mail_notify_attn($user, $this);
+            }
+        }
     }
 }
index 94f9296d602c92cc1c121cd498ad988ce4b6024d..0365973f565b0b5879d8e628a82a51b343e174a8 100644 (file)
@@ -19,7 +19,7 @@
 
 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 
-class Notice_tag extends Memcached_DataObject 
+class Notice_tag extends Memcached_DataObject
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -35,9 +35,9 @@ class Notice_tag extends Memcached_DataObject
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
-    
+
     static function getStream($tag, $offset=0, $limit=20) {
-        $qry = 
+        $qry =
           'SELECT notice.* ' .
           'FROM notice JOIN notice_tag ON notice.id = notice_tag.notice_id ' .
           'WHERE notice_tag.tag = "%s" ';
@@ -46,7 +46,7 @@ class Notice_tag extends Memcached_DataObject
                                  'notice_tag:notice_stream:' . common_keyize($tag),
                                  $offset, $limit);
     }
-    
+
     function blowCache()
     {
         $cache = common_memcache();
@@ -54,4 +54,9 @@ class Notice_tag extends Memcached_DataObject
             $cache->delete(common_cache_key('notice_tag:notice_stream:' . $this->tag));
         }
     }
+
+    function &pkeyGet($kv)
+    {
+        return Memcached_DataObject::pkeyGet('Notice_tag', $kv);
+    }
 }
index a6a1b11b9f502d7a6a27d155ce840eb92154a0ae..495a982360e04c716a2a52708d4f8ff87c197283 100644 (file)
@@ -40,6 +40,7 @@ class User extends Memcached_DataObject
     public $emailnotifyfav;                  // tinyint(1)   default_1
     public $emailnotifynudge;                // tinyint(1)   default_1
     public $emailnotifymsg;                  // tinyint(1)   default_1
+    public $emailnotifyattn;                 // tinyint(1)   default_1
     public $emailmicroid;                    // tinyint(1)   default_1
     public $language;                        // varchar(50)
     public $timezone;                        // varchar(50)
@@ -62,8 +63,10 @@ class User extends Memcached_DataObject
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 
     /* Static get */
-    function staticGet($k,$v=null)
-    { return Memcached_DataObject::staticGet('User',$k,$v); }
+    function staticGet($k,$v=NULL)
+    {
+        return Memcached_DataObject::staticGet('User',$k,$v);
+    }
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
index 255122a97f74e0f988e56d1dedc20f20fa92a397..5fd2cd1f86661e182414198509d29032d8693d06 100755 (executable)
@@ -292,7 +292,8 @@ created = 142
 modified = 384
 
 [sms_carrier__keys]
-id = N
+id = K
+name = U
 
 [subscription]
 subscriber = 129
@@ -331,6 +332,7 @@ emailnotifysub = 17
 emailnotifyfav = 17
 emailnotifynudge = 17
 emailnotifymsg = 17
+emailnotifyattn = 17
 emailmicroid = 17
 language = 2
 timezone = 2
index d1191ea01b1bf75f08901520fc31fbecc9ef4e7f..6e55eaffc8bdf9190fafd0e735008ed787360af1 100644 (file)
@@ -109,6 +109,14 @@ $config['sphinx']['port'] = 3312;
 #$config['public']['blacklist'][] = 123;
 #$config['public']['blacklist'][] = 2307;
 
+#Mark certain notice sources as automatic and thus not
+#appropriate for public feed
+#$config['public]['autosource'][] = 'twitterfeed';
+#$config['public]['autosource'][] = 'rssdent';
+#$config['public]['autosource'][] = 'Ping.Fm';
+#$config['public]['autosource'][] = 'HelloTxt';
+#$config['public]['autosource'][] = 'Updating.Me';
+
 #Do notice broadcasts offline
 #If you use this, you must run the six offline daemons in the
 #background. See the README for details.
@@ -141,7 +149,7 @@ $config['sphinx']['port'] = 3312;
 #$config['profile']['banned'][] = 'hacker';
 #$config['profile']['banned'][] = 12345;
 
-# config section for the built-in Facebook application
+# Config section for the built-in Facebook application
 #$config['facebook']['apikey'] = 'APIKEY';
 #$config['facebook']['secret'] = 'SECRET';
 
diff --git a/db/carrier.sql b/db/carrier.sql
deleted file mode 100644 (file)
index 932f7c8..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-insert into sms_carrier
-    (name, email_pattern, created)
-values
-    ('3 River Wireless', '%s@sms.3rivers.net', now()),
-    ('7-11 Speakout', '%s@cingularme.com', now()),
-    ('Airtel (Karnataka, India)', '%s@airtelkk.com', now()),
-    ('Alaska Communications Systems', '%s@msg.acsalaska.com', now()),
-    ('Alltel Wireless', '%s@message.alltel.com', now()),
-    ('AT&T Wireless', '%s@txt.att.net', now()),
-    ('Bell Mobility (Canada)', '%s@txt.bell.ca', now()),
-    ('Boost Mobile', '%s@myboostmobile.com', now()),
-    ('Cellular One (Dobson)', '%s@mobile.celloneusa.com', now()),
-    ('Cincinnati Bell Wireless', '%s@gocbw.com', now()),
-    ('Cingular (Postpaid)', '%s@cingularme.com', now()),
-    ('Centennial Wireless', '%s@cwemail.com', now()),
-    ('Cingular (GoPhone prepaid)', '%s@cingularme.com', now()),
-    ('Claro (Nicaragua)', '%s@ideasclaro-ca.com', now()),
-    ('Comcel', '%s@comcel.com.co', now()),
-    ('Cricket', '%s@sms.mycricket.com', now()),
-    ('CTI', '%s@sms.ctimovil.com.ar', now()),
-    ('Emtel (Mauritius)', '%s@emtelworld.net', now()),
-    ('Fido (Canada)', '%s@fido.ca', now()),
-    ('General Communications Inc.', '%s@msg.gci.net', now()),
-    ('Globalstar', '%s@msg.globalstarusa.com', now()),
-    ('Helio', '%s@myhelio.com', now()),
-    ('Illinois Valley Cellular', '%s@ivctext.com', now()),
-    ('i wireless', '%s.iws@iwspcs.net', now()),
-    ('Meteor (Ireland)', '%s@sms.mymeteor.ie', now()),
-    ('Mero Mobile (Nepal)', '%s@sms.spicenepal.com', now()),
-    ('MetroPCS', '%s@mymetropcs.com', now()),
-    ('Movicom', '%s@movimensaje.com.ar', now()),
-    ('Mobitel (Sri Lanka)', '%s@sms.mobitel.lk', now()),
-    ('Movistar (Colombia)', '%s@movistar.com.co', now()),
-    ('MTN (South Africa)', '%s@sms.co.za', now()),
-    ('MTS (Canada)', '%s@text.mtsmobility.com', now()),
-    ('Nextel (Argentina)', '%s@nextel.net.ar', now()),
-    ('Orange (Poland)', '%s@orange.pl', now()),
-    ('Orange (UK)', '%s@orange.net', now()),
-    ('Personal (Argentina)', '%s@personal-net.com.ar', now()),
-    ('Plus GSM (Poland)', '%s@text.plusgsm.pl', now()),
-    ('President''s Choice (Canada)', '%s@txt.bell.ca', now()),
-    ('Qwest', '%s@qwestmp.com', now()),
-    ('Rogers (Canada)', '%s@pcs.rogers.com', now()),
-    ('Sasktel (Canada)', '%s@sms.sasktel.com', now()),
-    ('Setar Mobile email (Aruba)', '%s@mas.aw', now()),
-    ('Solo Mobile', '%s@txt.bell.ca', now()),
-    ('Sprint (PCS)', '%s@messaging.sprintpcs.com', now()),
-    ('Sprint (Nextel)', '%s@page.nextel.com', now()),
-    ('Suncom', '%s@tms.suncom.com', now()),
-    ('T-Mobile', '%s@tmomail.net', now()),
-    ('T-Mobile (Austria)', '%s@sms.t-mobile.at', now()),
-    ('Telus Mobility (Canada)', '%s@msg.telus.com', now()),
-    ('Thumb Cellular', '%s@sms.thumbcellular.com', now()),
-    ('Tigo (Formerly Ola)', '%s@sms.tigo.com.co', now()),
-    ('Unicel', '%s@utext.com', now()),
-    ('US Cellular', '%s@email.uscc.net', now()),
-    ('Verizon', '%s@vtext.com', now()),
-    ('Virgin Mobile (Canada)', '%s@vmobile.ca', now()),
-    ('Virgin Mobile (USA)', '%s@vmobl.com', now()),
-    ('Vodafone NZ (txt ''R'' to 901 to enable first)', '%s@sms.vodafone.net.nz', now()),
-    ('YCC', '%s@sms.ycc.ru', now());
index 16f482134bc9eb01a2b862feca2c3ac6f99a844a..dd93a727b71f5504f168b8342483b7107984cbbb 100644 (file)
@@ -31,7 +31,7 @@ create table avatar (
 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
 
 create table sms_carrier (
-    id integer auto_increment primary key comment 'primary key for SMS carrier',
+    id integer primary key comment 'primary key for SMS carrier',
     name varchar(64) unique key comment 'name of the carrier',
     email_pattern varchar(255) not null comment 'sprintf pattern for making an email address from a phone number',
     created datetime not null comment 'date this record was created',
@@ -50,6 +50,7 @@ create table user (
     emailnotifyfav tinyint default 1 comment 'Notify by email of favorites',
     emailnotifynudge tinyint default 1 comment 'Notify by email of nudges',
     emailnotifymsg tinyint default 1 comment 'Notify by email of direct messages',
+    emailnotifyattn tinyint default 1 comment 'Notify by email of @-replies',
     emailmicroid tinyint default 1 comment 'whether to publish email microid',
     language varchar(50) comment 'preferred language',
     timezone varchar(50) comment 'timezone',
diff --git a/db/sms_carrier.sql b/db/sms_carrier.sql
new file mode 100644 (file)
index 0000000..6879f20
--- /dev/null
@@ -0,0 +1,63 @@
+INSERT INTO sms_carrier
+    (id, name, email_pattern, created)
+VALUES
+    (100056, '3 River Wireless', '%s@sms.3rivers.net', now()),
+    (100057, '7-11 Speakout', '%s@cingularme.com', now()),
+    (100058, 'Airtel (Karnataka, India)', '%s@airtelkk.com', now()),
+    (100059, 'Alaska Communications Systems', '%s@msg.acsalaska.com', now()),
+    (100060, 'Alltel Wireless', '%s@message.alltel.com', now()),
+    (100061, 'AT&T Wireless', '%s@txt.att.net', now()),
+    (100062, 'Bell Mobility (Canada)', '%s@txt.bell.ca', now()),
+    (100063, 'Boost Mobile', '%s@myboostmobile.com', now()),
+    (100064, 'Cellular One (Dobson)', '%s@mobile.celloneusa.com', now()),
+    (100065, 'Cingular (Postpaid)', '%s@cingularme.com', now()),
+    (100066, 'Centennial Wireless', '%s@cwemail.com', now()),
+    (100067, 'Cingular (GoPhone prepaid)', '%s@cingularme.com', now()),
+    (100068, 'Claro (Nicaragua)', '%s@ideasclaro-ca.com', now()),
+    (100069, 'Comcel', '%s@comcel.com.co', now()),
+    (100070, 'Cricket', '%s@sms.mycricket.com', now()),
+    (100071, 'CTI', '%s@sms.ctimovil.com.ar', now()),
+    (100072, 'Emtel (Mauritius)', '%s@emtelworld.net', now()),
+    (100073, 'Fido (Canada)', '%s@fido.ca', now()),
+    (100074, 'General Communications Inc.', '%s@msg.gci.net', now()),
+    (100075, 'Globalstar', '%s@msg.globalstarusa.com', now()),
+    (100076, 'Helio', '%s@myhelio.com', now()),
+    (100077, 'Illinois Valley Cellular', '%s@ivctext.com', now()),
+    (100078, 'i wireless', '%s.iws@iwspcs.net', now()),
+    (100079, 'Meteor (Ireland)', '%s@sms.mymeteor.ie', now()),
+    (100080, 'Mero Mobile (Nepal)', '%s@sms.spicenepal.com', now()),
+    (100081, 'MetroPCS', '%s@mymetropcs.com', now()),
+    (100082, 'Movicom', '%s@movimensaje.com.ar', now()),
+    (100083, 'Mobitel (Sri Lanka)', '%s@sms.mobitel.lk', now()),
+    (100084, 'Movistar (Colombia)', '%s@movistar.com.co', now()),
+    (100085, 'MTN (South Africa)', '%s@sms.co.za', now()),
+    (100086, 'MTS (Canada)', '%s@text.mtsmobility.com', now()),
+    (100087, 'Nextel (Argentina)', '%s@nextel.net.ar', now()),
+    (100088, 'Orange (Poland)', '%s@orange.pl', now()),
+    (100089, 'Personal (Argentina)', '%s@personal-net.com.ar', now()),
+    (100090, 'Plus GSM (Poland)', '%s@text.plusgsm.pl', now()),
+    (100091, 'President\'s Choice (Canada)', '%s@txt.bell.ca', now()),
+    (100092, 'Qwest', '%s@qwestmp.com', now()),
+    (100093, 'Rogers (Canada)', '%s@pcs.rogers.com', now()),
+    (100094, 'Sasktel (Canada)', '%s@sms.sasktel.com', now()),
+    (100095, 'Setar Mobile email (Aruba)', '%s@mas.aw', now()),
+    (100096, 'Solo Mobile', '%s@txt.bell.ca', now()),
+    (100097, 'Sprint (PCS)', '%s@messaging.sprintpcs.com', now()),
+    (100098, 'Sprint (Nextel)', '%s@page.nextel.com', now()),
+    (100099, 'Suncom', '%s@tms.suncom.com', now()),
+    (100100, 'T-Mobile', '%s@tmomail.net', now()),
+    (100101, 'T-Mobile (Austria)', '%s@sms.t-mobile.at', now()),
+    (100102, 'Telus Mobility (Canada)', '%s@msg.telus.com', now()),
+    (100103, 'Thumb Cellular', '%s@sms.thumbcellular.com', now()),
+    (100104, 'Tigo (Formerly Ola)', '%s@sms.tigo.com.co', now()),
+    (100105, 'Unicel', '%s@utext.com', now()),
+    (100106, 'US Cellular', '%s@email.uscc.net', now()),
+    (100107, 'Verizon', '%s@vtext.com', now()),
+    (100108, 'Virgin Mobile (Canada)', '%s@vmobile.ca', now()),
+    (100109, 'Virgin Mobile (USA)', '%s@vmobl.com', now()),
+    (100110, 'YCC', '%s@sms.ycc.ru', now()),
+    (100111, 'Orange (UK)', '%s@orange.net', now()),
+    (100112, 'Cincinnati Bell Wireless', '%s@gocbw.com', now()),
+    (100113, 'T-Mobile Germany', '%s@t-mobile-sms.de', now()),
+    (100114, 'Vodafone Germany', '%s@vodafone-sms.de', now()),
+    (100115, 'E-Plus', '%s@smsmail.eplus.de', now());
diff --git a/doc-src/about b/doc-src/about
new file mode 100644 (file)
index 0000000..3036a51
--- /dev/null
@@ -0,0 +1,10 @@
+%%site.name%% is a
+[micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service
+based on the Free Software [Laconica](http://laconi.ca/) tool.
+
+If you [register](%%action.register%%) for an account,
+you can post small (140 chars or less) text notices
+about yourself, where you are, what you're doing, or practically
+anything you want. You can also subscribe to the notices of your
+friends, or other people you're interested in, and follow them on the
+Web or in an [RSS](http://en.wikipedia.org/wiki/RSS) feed.
diff --git a/doc-src/contact b/doc-src/contact
new file mode 100644 (file)
index 0000000..a8efc45
--- /dev/null
@@ -0,0 +1,24 @@
+There are a number of options for getting in contact with responsible
+people for %%site.name%%.
+
+Post a notice
+-------------
+
+If you have a question about how to do something, just post a notice
+with your question. People here like to answer messages. Watch the
+[public timeline](%%action.public%%) for answers; they'll usually start
+with "@" plus your user name.
+
+Bugs
+----
+
+If you think you've found a bug in the [Laconica](http://laconi.ca/) software,
+or if there's a new feature you'd like to see, add it into the [Laconica bug database](http://laconi.ca/PITS/HomePage). Don't forget to check the list of
+existing bugs to make sure it hasn't already been reported!
+
+Email
+-----
+
+You can reach the responsible party for this server at [%%site.email%%](mailto:%%site.email%%).
+
+
diff --git a/doc-src/faq b/doc-src/faq
new file mode 100644 (file)
index 0000000..31582b9
--- /dev/null
@@ -0,0 +1,42 @@
+These are some *Frequently Asked Questions* about this service, with
+some answers.
+
+What is %%site.name%%?
+----------------------
+
+%%site.name%% is a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service.
+You can use it to write short notices about yourself, where you are,
+and what you're doing, and those notices will be sent to all your friends
+and fans.
+
+How is %%site.name%% different from Twitter, Jaiku, Pownce, Plurk, others?
+--------------------------------------------------------------------------
+
+%%site.name%% is an [Open Network Service](http://opendefinition.org/ossd). Our main
+goal is to provide a fair and transparent service that preserves users' autonomy. In
+particular, all the software used for %%site.name%% is [Free Software](http://en.wikipedia.org/wiki/Free_Software), and all the data is available
+under the [%%license.title%%](%%license.url%%) license, making it Open Data.
+
+The software also implements the [OpenMicroBlogging](http://openmicroblogging.org/) protocol, meaning that you can have friends on other microblogging services
+that can receive your notices.
+
+The goal here is *autonomy* -- you deserve the right to manage your own on-line
+presence. If you don't like how %%site.name%% works, you can take your data and the source code and set up your own server (or move your account to another one).
+
+Where is feature X?
+-------------------
+
+The software we run, [Laconica](http://laconi.ca/), is still in its early stages,
+and many features people expect from microblogging sites are not yet implemented. Some important ones that are expected "soon":
+
+* More [AJAX](http://en.wikipedia.org/wiki/AJAX)-y interface
+* Maps
+* Cross-post to Pownce, Jaiku, etc.
+* Pull messages from Twitter, Pownce, Jaiku, etc.
+* [Facebook](http://www.facebook.com/) integration
+* Image, video, audio notices
+
+There is [a list of bugs and features](http://laconi.ca/trac/) that you may find
+interesting. New ideas or complaints are very welcome.
+
+
diff --git a/doc-src/groups b/doc-src/groups
new file mode 100644 (file)
index 0000000..645390e
--- /dev/null
@@ -0,0 +1,42 @@
+Users on %%site.name%% can create *groups* that other users can join.
+Groups can be a great way to share information and entertainment with
+a group of people who have a common interest or background.
+
+You can find out about groups on the server on the
+[Groups](%%action.groups%%) page. You can join a group by clicking on
+the "Join" button either in the group list or on the group's home page.
+
+Starting a new group
+--------------------
+
+If you want, you can start a new group for friends and people with
+common interests. Note that all groups are free for anyone to join.
+
+To start a new group, use the [new group](%%action.newgroup%%) tool
+and fill out the form. Describe your group as best you can if you want
+people to be able to find it.
+
+When choosing the nickname for your group, try to keep it short. The
+nickname is included in every message to and from the group, so the
+less chars the better. Try using acronyms for organizations, or
+airport codes for places (like 'pdx' instead of 'portland').
+
+Sending messages to a group
+---------------------------
+
+You can send a message to a group using the syntax "!groupname"
+anywhere in the message. If you have more than one group named, the
+notice will go to each group. Only members can send notices to a
+group, and groups do not respond to direct messages (DMs).
+
+Receiving messages
+------------------
+
+New group messages will appear in your inbox, and will also come to
+your phone or IM client if you've set them up to receive notices.
+
+Remote groups
+-------------
+
+While it's technically possible, this version of Laconica does not
+support remote group membership.
diff --git a/doc-src/help b/doc-src/help
new file mode 100644 (file)
index 0000000..a8cfccd
--- /dev/null
@@ -0,0 +1,32 @@
+%%site.name%% is a **microblogging service**. Users post short (140
+character) notices which are broadcast to their friends and fans using
+the Web, RSS, or instant messages.
+
+If you'd like to try it out, first [register](%%action.register%%) a new account.
+Then, on the [public timeline](%%action.public%%), enter your message into
+the textbox at the top of the page, and click "Send". It will go out on the
+public timeline and to anyone who is subscribed to your notices (probably nobody,
+at first).
+
+To subscribe to other people's notifications, go to their profile page
+and click the "subscribe" button. They'll get a notice that you're now
+subscribed to their notifications, and, who knows?, they might subscribe
+back.
+
+More help
+---------
+
+Here are some documents that you might find helpful in understanding
+%%site.name%% and how to use it.
+
+* [About](%%doc.about%%) - an overview of the service
+* [FAQ](%%doc.faq%%) - frequently-asked questions about %%site.name%%
+* [Contact](%%doc.contact%%) - who to contact with questions about the service
+* [IM](%%doc.im%%) - using the instant-message (IM) features of %%site.name%%
+* [SMS](%%doc.sms%%) - tying your cellphone to %%site.name%%
+* [tags](%%doc.tags%%) - different ways to use tagging
+* [Groups](%%doc.groups%%) - joining together in groups
+* [OpenID](%%doc.openid%%) - what OpenID is and how to use it with this service
+* [OpenMicroBlogging](%%doc.openmublog%%) - subscribing to remote users
+* [Privacy](%%doc.privacy%%) - %%site.name%%'s privacy policy
+* [Source](%%doc.source%%) - How to get the Laconica source code
diff --git a/doc-src/im b/doc-src/im
new file mode 100644 (file)
index 0000000..da07f9f
--- /dev/null
@@ -0,0 +1,35 @@
+You can post messages to %%site.name%% using a [Jabber](http://jabber.org/) client
+on your computer, mobile phone, or other platform. ([GTalk](http://talk.google.com/),
+Google's Jabber program, will also work.) This can be a convenient way to keep
+up with your friends on %%site.name%%.
+
+If you don't already have a Jabber account, you can use GTalk or one of the other
+[public Jabber services](http://www.jabber.org/im-services). You'll probably also
+need an IM client like [Pidgin](http://www.pidgin.im/).
+
+Managing your IM settings
+-------------------------
+
+Use the [IM settings](%%action.imsettings%%) page to set your IM preferences. You can add or change your Jabber address and set the flags for Jabber update.
+
+When you add or change your address, you'll receive a message from **%%xmpp.user%%@%%xmpp.server%%** asking you to confirm the change. (You may need to
+add %%xmpp.user%%@%%xmpp.server%% to your buddy list *before* changing your IM
+settings; this is definitely true for GTalk.)
+
+Sending updates
+---------------
+
+You send updates by sending messages to %%xmpp.user%%@%%xmpp.server%%. Messages
+should be less than 140 characters; longer messages will be truncated.
+
+Commands
+--------
+
+You can do some minor management of your account through Jabber. These are the
+currently-implemented commands:
+
+* **on**: Turn on notifications. You'll receive copies of messages by people
+  you subscribe to.
+* **off**: Turn off notifications. You'll no longer receive Jabber
+  notifications.
+
diff --git a/doc-src/openid b/doc-src/openid
new file mode 100644 (file)
index 0000000..c741e36
--- /dev/null
@@ -0,0 +1,11 @@
+%%site.name%% supports the [OpenID](http://openid.net/) standard for single signon between Web sites. OpenID lets you log into many different Web sites without using a different password for each. (See [Wikipedia's OpenID article](http://en.wikipedia.org/wiki/OpenID) for more information.)
+
+If you already have an account on %%site.name%%, you can [login](%%action.login%%) with your username and password as usual.
+To use OpenID in the future, you can [add an OpenID to your account](%%action.openidsettings%%) after you have logged in normally.
+
+There are many [Public OpenID providers](http://wiki.openid.net/Public_OpenID_providers), and you may already have an OpenID-enabled account on another service.
+
+* On wikis: If you have an account on an OpenID-enabled wiki, like [Wikitravel](http://wikitravel.org/), [wikiHow](http://www.wikihow.com/), [Vinismo](http://vinismo.com/), [AboutUs](http://aboutus.org/) or [Keiki](http://kei.ki/), you can log in to %%site.name%% by entering the **full URL** of your user page on that other wiki in the box above. For example, *http://kei.ki/en/User:Evan*.
+* [Yahoo!](http://openid.yahoo.com/) : If you have an account with Yahoo!, you can log in to this site by entering your Yahoo!-provided OpenID in the box above. Yahoo! OpenID URLs have the form *https://me.yahoo.com/yourusername*.
+* [AOL](http://dev.aol.com/aol-and-63-million-openids) : If you have an account with [AOL](http://www.aol.com/), like an [AIM](http://www.aim.com/) account, you can log in to %%site.name%% by entering your AOL-provided OpenID in the box above. AOL OpenID URLs have the form *http://openid.aol.com/yourusername*. Your username should be all lowercase, no spaces.
+* [Blogger](http://bloggerindraft.blogspot.com/2008/01/new-feature-blogger-as-openid-provider.html), [Wordpress.com](http://faq.wordpress.com/2007/03/06/what-is-openid/), [LiveJournal](http://www.livejournal.com/openid/about.bml), [Vox](http://bradfitz.vox.com/library/post/openid-for-vox.html) : If you have a blog on any of these services, enter your blog URL in the box above. For example, *http://yourusername.blogspot.com/*, *http://yourusername.wordpress.com/*, *http://yourusername.livejournal.com/*, or *http://yourusername.vox.com/*.
diff --git a/doc-src/openmublog b/doc-src/openmublog
new file mode 100644 (file)
index 0000000..6e3abee
--- /dev/null
@@ -0,0 +1,25 @@
+[OpenMicroBlogging](http://openmicroblogging.org/) is a protocol that
+lets users of one [microblogging](http://en.wikipedia.org/wiki/microblogging) service
+subscribe to notices by users of another service. The protocol, based on
+[OAuth](http://oauth.net/), is open and free, and doesn't depend on any
+central authority to maintain the federated microblogs.
+
+The [Laconica](http://laconi.ca/) software that runs %%site.name%% supports
+OpenMicroBlogging 0.1. Anyone can make a new installation of Laconica on their
+own servers, and users of that new installation can subscribe to notices from
+%%site.name%%.
+
+Remote subscription
+-------------------
+
+If you have an account on a remote site that supports OpenMicroBlogging, and you
+want to subscribe to the notices of a user on this site, click on the "Subscribe"
+link under their avatar on their profile page. This should take you to the
+[remote subscription](%%action.remotesubscribe%%) page. Make sure that you've got the
+right nickname registered, and enter your profile URL on the other microblogging
+service.
+
+You'll be taken to your microblogging service, where you'll be asked to confirm the
+subscription. When you confirm, your service will receive new notifications from
+the user on %%site.name%%, and your service will forward them to you (using IM, SMS,
+the Web, or whatever else).
diff --git a/doc-src/privacy b/doc-src/privacy
new file mode 100644 (file)
index 0000000..90c7b3c
--- /dev/null
@@ -0,0 +1,45 @@
+This document outlines this service's respect for your personal
+privacy as a user of the service.
+
+- Almost all the text and files that users upload to this site is
+  available under the site license (see the license block at the bottom
+  of this page). Users agree to the license when they register to use
+  the site for the first time. Typically that means that the data can
+  be copied far and wide, for commercial and non-commercial purposes,
+  and in modified or unmodified form. If you're not OK with that,
+  don't use the service.
+- The following data items are considered *private data* that won't be
+  shared with other users, business partners, or the public at large:
+  * your password
+  * your email address
+  * your IM address (AIM, Jabber, or other instant messaging address)
+  * your phone number
+  * your "private messages"
+  * your login credentials (username and password) for other services (Twitter, Facebook, etc.)
+- Some private data may be published in aggregate, e.g. "30% of our
+  users are registered with Hotmail addresses."
+- Your notices (including files) can be downloaded and re-used by
+  other services, either one-by-one or in bulk as
+  [RSS](http://en.wikipedia.org/wiki/RSS) files.
+- Your profile information (including subscriptions and avatars) can be
+  downloaded and re-used by other services, either scraped from the HTML
+  interface or in bulk as [FOAF](http://en.wikipedia.org/wiki/FOAF) files.
+- Your notices will be forwarded to users who subscribe to them,
+  including users on another microblogging service.
+- Your profile information will be sent to microblogging services for
+  users who subscribe to you or to whom you subscribe.
+- Based on your email preferences, you may receive automated email
+  messages for important system events, such as when others subscribe
+  to your notices.
+- Based on your email preferences, you may receive an email
+  newsletter. You can opt out of the newsletter if you don't want to
+  receive it.
+- In urgent situations, administrators may send you email directly to
+  your registered email address, even if you've requested no notices
+  or newsletter. *Administrators will use digitally-signed email.*
+- This service will comply with court orders to turn over your private
+  information.
+  
+  
+  
+
diff --git a/doc-src/sms b/doc-src/sms
new file mode 100644 (file)
index 0000000..1beb497
--- /dev/null
@@ -0,0 +1,68 @@
+You can post messages to %%site.name%% using a many kinds of cell
+phones that support SMS messaging. This site does not support SMS
+directly; rather, it uses your carrier's email gateway to send and
+receive messages.
+
+Managing your SMS settings
+--------------------------
+
+Use the [SMS settings](%%action.smssettings%%) page to set your SMS
+preferences. You can add or change your SMS number and set the
+flags for SMS updates.
+
+When you add or change your phone number, you'll receive a message on your
+phone with a verification code. Enter it into the SMS settings page to
+confirm that the owner of the phone authorizes sending it messages.
+
+Note that only the carriers listed in the drop down list on the form
+are supported by %%site.name%%. They're the only ones we know how to
+make email addresses for.
+
+Receiving messages
+------------------
+
+Once you've verified your phone number, you can enable sending
+messages to your phone. If you have a lot of friends and a typical
+phone, it can be hard to keep up.
+
+Sending messages
+----------------
+
+To send a message, you must send an email to the incoming email
+address visible on your SMS settings page. The method for sending
+email from your phone varies from carrier to carrier and from handset
+to handet; if in doubt, ask your carrier.
+
+Keep your incoming email address a secret -- it's the only way we know
+you're really you!
+
+Commands
+--------
+
+You can use the following commands with %%site.name%%.
+
+* on - turn on notifications
+* off - turn off notifications
+* help - show this help
+* follow <nickname> - subscribe to user
+* leave <nickname> - unsubscribe from user
+* d <nickname> <text> - direct message to user
+* get <nickname> - get last notice from user
+* whois <nickname> - get profile info on user
+* fav <nickname> - add user's last notice as a 'fave'
+* stats - get your stats
+* stop - same as 'off'
+* quit - same as 'off'
+* sub <nickname> - same as 'follow'
+* unsub <nickname> - same as 'leave'
+* last <nickname> - same as 'get'
+* on <nickname> - not yet implemented.
+* off <nickname> - not yet implemented.
+* nudge <nickname> - not yet implemented.
+* invite <phone number> - not yet implemented.
+* track <word> - not yet implemented.
+* untrack <word> - not yet implemented.
+* track off - not yet implemented.
+* untrack all - not yet implemented.
+* tracks - not yet implemented.
+* tracking - not yet implemented.
diff --git a/doc-src/source b/doc-src/source
new file mode 100644 (file)
index 0000000..83debbe
--- /dev/null
@@ -0,0 +1,12 @@
+This service uses a Free microblogging tool called **Laconica**.
+Laconica is available under the [GNU Affero General Public License
+Version 3.0](http://www.fsf.org/licensing/licenses/agpl-3.0.html), a
+Free Software license for network services.
+
+You can get a copy of the software from the
+[Laconica](http://laconi.ca/) main site. The version of the software
+that runs on *this* site is unmodified from that version. The site
+also depends on certain libraries and other software; you can get
+those at the Laconica site, too.
+
+
diff --git a/doc-src/tags b/doc-src/tags
new file mode 100644 (file)
index 0000000..2ed352e
--- /dev/null
@@ -0,0 +1,40 @@
+%%site.name%% supports
+[tags](http://en.wikipedia.org/wiki/Tag_(metadata)) to help you
+organize your activities here. You can use tags for people and for
+notices.
+
+Tagging a notice
+----------------
+
+You can tag a notice using a *hashtag*; a # character followed by
+letters and numbers as well as '.', '-', and '_'. Note that accented
+latin characters are not supported, and non-roman scripts are right out.
+
+The HTML for the notice will link to a stream of all the other notices
+with that tag. This can be a great way to keep track of a conversation.
+
+The most popular current tags on the site can be found in the [public
+tag cloud](%%action.publictagcloud%%). Their size shows their
+popularity and recency.
+
+Tagging yourself
+----------------
+
+You can also add tags for yourself on your [profile
+settings](%%action.profilesettings%%) page. Use single words to
+describe yourself, your experiences and your interest. The tags will
+become links on your profile page to a list of all the users on the
+site who use that same tag. It can be a nice way to find people who
+are related to you geographically or who have a common interest.
+
+Tagging your subscriptions
+--------------------------
+
+You can also tag your subscriptions, on the subscriptions page. This
+makes it easy to organize your subscriptions into groups and sort
+through them separately.
+
+You can also send a notice "to the attention of" everyone you've
+marked with a particular tag (note: *not* people who've marked
+themselves with that tag). "@#family hello" will send a notice to
+everyone you've marked with the tag 'family'.
\ No newline at end of file
diff --git a/doc/about b/doc/about
deleted file mode 100644 (file)
index 3036a51..0000000
--- a/doc/about
+++ /dev/null
@@ -1,10 +0,0 @@
-%%site.name%% is a
-[micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service
-based on the Free Software [Laconica](http://laconi.ca/) tool.
-
-If you [register](%%action.register%%) for an account,
-you can post small (140 chars or less) text notices
-about yourself, where you are, what you're doing, or practically
-anything you want. You can also subscribe to the notices of your
-friends, or other people you're interested in, and follow them on the
-Web or in an [RSS](http://en.wikipedia.org/wiki/RSS) feed.
diff --git a/doc/contact b/doc/contact
deleted file mode 100644 (file)
index a8efc45..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-There are a number of options for getting in contact with responsible
-people for %%site.name%%.
-
-Post a notice
--------------
-
-If you have a question about how to do something, just post a notice
-with your question. People here like to answer messages. Watch the
-[public timeline](%%action.public%%) for answers; they'll usually start
-with "@" plus your user name.
-
-Bugs
-----
-
-If you think you've found a bug in the [Laconica](http://laconi.ca/) software,
-or if there's a new feature you'd like to see, add it into the [Laconica bug database](http://laconi.ca/PITS/HomePage). Don't forget to check the list of
-existing bugs to make sure it hasn't already been reported!
-
-Email
------
-
-You can reach the responsible party for this server at [%%site.email%%](mailto:%%site.email%%).
-
-
diff --git a/doc/faq b/doc/faq
deleted file mode 100644 (file)
index 31582b9..0000000
--- a/doc/faq
+++ /dev/null
@@ -1,42 +0,0 @@
-These are some *Frequently Asked Questions* about this service, with
-some answers.
-
-What is %%site.name%%?
-----------------------
-
-%%site.name%% is a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service.
-You can use it to write short notices about yourself, where you are,
-and what you're doing, and those notices will be sent to all your friends
-and fans.
-
-How is %%site.name%% different from Twitter, Jaiku, Pownce, Plurk, others?
---------------------------------------------------------------------------
-
-%%site.name%% is an [Open Network Service](http://opendefinition.org/ossd). Our main
-goal is to provide a fair and transparent service that preserves users' autonomy. In
-particular, all the software used for %%site.name%% is [Free Software](http://en.wikipedia.org/wiki/Free_Software), and all the data is available
-under the [%%license.title%%](%%license.url%%) license, making it Open Data.
-
-The software also implements the [OpenMicroBlogging](http://openmicroblogging.org/) protocol, meaning that you can have friends on other microblogging services
-that can receive your notices.
-
-The goal here is *autonomy* -- you deserve the right to manage your own on-line
-presence. If you don't like how %%site.name%% works, you can take your data and the source code and set up your own server (or move your account to another one).
-
-Where is feature X?
--------------------
-
-The software we run, [Laconica](http://laconi.ca/), is still in its early stages,
-and many features people expect from microblogging sites are not yet implemented. Some important ones that are expected "soon":
-
-* More [AJAX](http://en.wikipedia.org/wiki/AJAX)-y interface
-* Maps
-* Cross-post to Pownce, Jaiku, etc.
-* Pull messages from Twitter, Pownce, Jaiku, etc.
-* [Facebook](http://www.facebook.com/) integration
-* Image, video, audio notices
-
-There is [a list of bugs and features](http://laconi.ca/trac/) that you may find
-interesting. New ideas or complaints are very welcome.
-
-
diff --git a/doc/groups b/doc/groups
deleted file mode 100644 (file)
index 645390e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-Users on %%site.name%% can create *groups* that other users can join.
-Groups can be a great way to share information and entertainment with
-a group of people who have a common interest or background.
-
-You can find out about groups on the server on the
-[Groups](%%action.groups%%) page. You can join a group by clicking on
-the "Join" button either in the group list or on the group's home page.
-
-Starting a new group
---------------------
-
-If you want, you can start a new group for friends and people with
-common interests. Note that all groups are free for anyone to join.
-
-To start a new group, use the [new group](%%action.newgroup%%) tool
-and fill out the form. Describe your group as best you can if you want
-people to be able to find it.
-
-When choosing the nickname for your group, try to keep it short. The
-nickname is included in every message to and from the group, so the
-less chars the better. Try using acronyms for organizations, or
-airport codes for places (like 'pdx' instead of 'portland').
-
-Sending messages to a group
----------------------------
-
-You can send a message to a group using the syntax "!groupname"
-anywhere in the message. If you have more than one group named, the
-notice will go to each group. Only members can send notices to a
-group, and groups do not respond to direct messages (DMs).
-
-Receiving messages
-------------------
-
-New group messages will appear in your inbox, and will also come to
-your phone or IM client if you've set them up to receive notices.
-
-Remote groups
--------------
-
-While it's technically possible, this version of Laconica does not
-support remote group membership.
diff --git a/doc/help b/doc/help
deleted file mode 100644 (file)
index a8cfccd..0000000
--- a/doc/help
+++ /dev/null
@@ -1,32 +0,0 @@
-%%site.name%% is a **microblogging service**. Users post short (140
-character) notices which are broadcast to their friends and fans using
-the Web, RSS, or instant messages.
-
-If you'd like to try it out, first [register](%%action.register%%) a new account.
-Then, on the [public timeline](%%action.public%%), enter your message into
-the textbox at the top of the page, and click "Send". It will go out on the
-public timeline and to anyone who is subscribed to your notices (probably nobody,
-at first).
-
-To subscribe to other people's notifications, go to their profile page
-and click the "subscribe" button. They'll get a notice that you're now
-subscribed to their notifications, and, who knows?, they might subscribe
-back.
-
-More help
----------
-
-Here are some documents that you might find helpful in understanding
-%%site.name%% and how to use it.
-
-* [About](%%doc.about%%) - an overview of the service
-* [FAQ](%%doc.faq%%) - frequently-asked questions about %%site.name%%
-* [Contact](%%doc.contact%%) - who to contact with questions about the service
-* [IM](%%doc.im%%) - using the instant-message (IM) features of %%site.name%%
-* [SMS](%%doc.sms%%) - tying your cellphone to %%site.name%%
-* [tags](%%doc.tags%%) - different ways to use tagging
-* [Groups](%%doc.groups%%) - joining together in groups
-* [OpenID](%%doc.openid%%) - what OpenID is and how to use it with this service
-* [OpenMicroBlogging](%%doc.openmublog%%) - subscribing to remote users
-* [Privacy](%%doc.privacy%%) - %%site.name%%'s privacy policy
-* [Source](%%doc.source%%) - How to get the Laconica source code
diff --git a/doc/im b/doc/im
deleted file mode 100644 (file)
index da07f9f..0000000
--- a/doc/im
+++ /dev/null
@@ -1,35 +0,0 @@
-You can post messages to %%site.name%% using a [Jabber](http://jabber.org/) client
-on your computer, mobile phone, or other platform. ([GTalk](http://talk.google.com/),
-Google's Jabber program, will also work.) This can be a convenient way to keep
-up with your friends on %%site.name%%.
-
-If you don't already have a Jabber account, you can use GTalk or one of the other
-[public Jabber services](http://www.jabber.org/im-services). You'll probably also
-need an IM client like [Pidgin](http://www.pidgin.im/).
-
-Managing your IM settings
--------------------------
-
-Use the [IM settings](%%action.imsettings%%) page to set your IM preferences. You can add or change your Jabber address and set the flags for Jabber update.
-
-When you add or change your address, you'll receive a message from **%%xmpp.user%%@%%xmpp.server%%** asking you to confirm the change. (You may need to
-add %%xmpp.user%%@%%xmpp.server%% to your buddy list *before* changing your IM
-settings; this is definitely true for GTalk.)
-
-Sending updates
----------------
-
-You send updates by sending messages to %%xmpp.user%%@%%xmpp.server%%. Messages
-should be less than 140 characters; longer messages will be truncated.
-
-Commands
---------
-
-You can do some minor management of your account through Jabber. These are the
-currently-implemented commands:
-
-* **on**: Turn on notifications. You'll receive copies of messages by people
-  you subscribe to.
-* **off**: Turn off notifications. You'll no longer receive Jabber
-  notifications.
-
diff --git a/doc/openid b/doc/openid
deleted file mode 100644 (file)
index c741e36..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-%%site.name%% supports the [OpenID](http://openid.net/) standard for single signon between Web sites. OpenID lets you log into many different Web sites without using a different password for each. (See [Wikipedia's OpenID article](http://en.wikipedia.org/wiki/OpenID) for more information.)
-
-If you already have an account on %%site.name%%, you can [login](%%action.login%%) with your username and password as usual.
-To use OpenID in the future, you can [add an OpenID to your account](%%action.openidsettings%%) after you have logged in normally.
-
-There are many [Public OpenID providers](http://wiki.openid.net/Public_OpenID_providers), and you may already have an OpenID-enabled account on another service.
-
-* On wikis: If you have an account on an OpenID-enabled wiki, like [Wikitravel](http://wikitravel.org/), [wikiHow](http://www.wikihow.com/), [Vinismo](http://vinismo.com/), [AboutUs](http://aboutus.org/) or [Keiki](http://kei.ki/), you can log in to %%site.name%% by entering the **full URL** of your user page on that other wiki in the box above. For example, *http://kei.ki/en/User:Evan*.
-* [Yahoo!](http://openid.yahoo.com/) : If you have an account with Yahoo!, you can log in to this site by entering your Yahoo!-provided OpenID in the box above. Yahoo! OpenID URLs have the form *https://me.yahoo.com/yourusername*.
-* [AOL](http://dev.aol.com/aol-and-63-million-openids) : If you have an account with [AOL](http://www.aol.com/), like an [AIM](http://www.aim.com/) account, you can log in to %%site.name%% by entering your AOL-provided OpenID in the box above. AOL OpenID URLs have the form *http://openid.aol.com/yourusername*. Your username should be all lowercase, no spaces.
-* [Blogger](http://bloggerindraft.blogspot.com/2008/01/new-feature-blogger-as-openid-provider.html), [Wordpress.com](http://faq.wordpress.com/2007/03/06/what-is-openid/), [LiveJournal](http://www.livejournal.com/openid/about.bml), [Vox](http://bradfitz.vox.com/library/post/openid-for-vox.html) : If you have a blog on any of these services, enter your blog URL in the box above. For example, *http://yourusername.blogspot.com/*, *http://yourusername.wordpress.com/*, *http://yourusername.livejournal.com/*, or *http://yourusername.vox.com/*.
diff --git a/doc/openmublog b/doc/openmublog
deleted file mode 100644 (file)
index 6e3abee..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-[OpenMicroBlogging](http://openmicroblogging.org/) is a protocol that
-lets users of one [microblogging](http://en.wikipedia.org/wiki/microblogging) service
-subscribe to notices by users of another service. The protocol, based on
-[OAuth](http://oauth.net/), is open and free, and doesn't depend on any
-central authority to maintain the federated microblogs.
-
-The [Laconica](http://laconi.ca/) software that runs %%site.name%% supports
-OpenMicroBlogging 0.1. Anyone can make a new installation of Laconica on their
-own servers, and users of that new installation can subscribe to notices from
-%%site.name%%.
-
-Remote subscription
--------------------
-
-If you have an account on a remote site that supports OpenMicroBlogging, and you
-want to subscribe to the notices of a user on this site, click on the "Subscribe"
-link under their avatar on their profile page. This should take you to the
-[remote subscription](%%action.remotesubscribe%%) page. Make sure that you've got the
-right nickname registered, and enter your profile URL on the other microblogging
-service.
-
-You'll be taken to your microblogging service, where you'll be asked to confirm the
-subscription. When you confirm, your service will receive new notifications from
-the user on %%site.name%%, and your service will forward them to you (using IM, SMS,
-the Web, or whatever else).
diff --git a/doc/privacy b/doc/privacy
deleted file mode 100644 (file)
index 90c7b3c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-This document outlines this service's respect for your personal
-privacy as a user of the service.
-
-- Almost all the text and files that users upload to this site is
-  available under the site license (see the license block at the bottom
-  of this page). Users agree to the license when they register to use
-  the site for the first time. Typically that means that the data can
-  be copied far and wide, for commercial and non-commercial purposes,
-  and in modified or unmodified form. If you're not OK with that,
-  don't use the service.
-- The following data items are considered *private data* that won't be
-  shared with other users, business partners, or the public at large:
-  * your password
-  * your email address
-  * your IM address (AIM, Jabber, or other instant messaging address)
-  * your phone number
-  * your "private messages"
-  * your login credentials (username and password) for other services (Twitter, Facebook, etc.)
-- Some private data may be published in aggregate, e.g. "30% of our
-  users are registered with Hotmail addresses."
-- Your notices (including files) can be downloaded and re-used by
-  other services, either one-by-one or in bulk as
-  [RSS](http://en.wikipedia.org/wiki/RSS) files.
-- Your profile information (including subscriptions and avatars) can be
-  downloaded and re-used by other services, either scraped from the HTML
-  interface or in bulk as [FOAF](http://en.wikipedia.org/wiki/FOAF) files.
-- Your notices will be forwarded to users who subscribe to them,
-  including users on another microblogging service.
-- Your profile information will be sent to microblogging services for
-  users who subscribe to you or to whom you subscribe.
-- Based on your email preferences, you may receive automated email
-  messages for important system events, such as when others subscribe
-  to your notices.
-- Based on your email preferences, you may receive an email
-  newsletter. You can opt out of the newsletter if you don't want to
-  receive it.
-- In urgent situations, administrators may send you email directly to
-  your registered email address, even if you've requested no notices
-  or newsletter. *Administrators will use digitally-signed email.*
-- This service will comply with court orders to turn over your private
-  information.
-  
-  
-  
-
diff --git a/doc/sms b/doc/sms
deleted file mode 100644 (file)
index 1beb497..0000000
--- a/doc/sms
+++ /dev/null
@@ -1,68 +0,0 @@
-You can post messages to %%site.name%% using a many kinds of cell
-phones that support SMS messaging. This site does not support SMS
-directly; rather, it uses your carrier's email gateway to send and
-receive messages.
-
-Managing your SMS settings
---------------------------
-
-Use the [SMS settings](%%action.smssettings%%) page to set your SMS
-preferences. You can add or change your SMS number and set the
-flags for SMS updates.
-
-When you add or change your phone number, you'll receive a message on your
-phone with a verification code. Enter it into the SMS settings page to
-confirm that the owner of the phone authorizes sending it messages.
-
-Note that only the carriers listed in the drop down list on the form
-are supported by %%site.name%%. They're the only ones we know how to
-make email addresses for.
-
-Receiving messages
-------------------
-
-Once you've verified your phone number, you can enable sending
-messages to your phone. If you have a lot of friends and a typical
-phone, it can be hard to keep up.
-
-Sending messages
-----------------
-
-To send a message, you must send an email to the incoming email
-address visible on your SMS settings page. The method for sending
-email from your phone varies from carrier to carrier and from handset
-to handet; if in doubt, ask your carrier.
-
-Keep your incoming email address a secret -- it's the only way we know
-you're really you!
-
-Commands
---------
-
-You can use the following commands with %%site.name%%.
-
-* on - turn on notifications
-* off - turn off notifications
-* help - show this help
-* follow <nickname> - subscribe to user
-* leave <nickname> - unsubscribe from user
-* d <nickname> <text> - direct message to user
-* get <nickname> - get last notice from user
-* whois <nickname> - get profile info on user
-* fav <nickname> - add user's last notice as a 'fave'
-* stats - get your stats
-* stop - same as 'off'
-* quit - same as 'off'
-* sub <nickname> - same as 'follow'
-* unsub <nickname> - same as 'leave'
-* last <nickname> - same as 'get'
-* on <nickname> - not yet implemented.
-* off <nickname> - not yet implemented.
-* nudge <nickname> - not yet implemented.
-* invite <phone number> - not yet implemented.
-* track <word> - not yet implemented.
-* untrack <word> - not yet implemented.
-* track off - not yet implemented.
-* untrack all - not yet implemented.
-* tracks - not yet implemented.
-* tracking - not yet implemented.
diff --git a/doc/source b/doc/source
deleted file mode 100644 (file)
index 83debbe..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-This service uses a Free microblogging tool called **Laconica**.
-Laconica is available under the [GNU Affero General Public License
-Version 3.0](http://www.fsf.org/licensing/licenses/agpl-3.0.html), a
-Free Software license for network services.
-
-You can get a copy of the software from the
-[Laconica](http://laconi.ca/) main site. The version of the software
-that runs on *this* site is unmodified from that version. The site
-also depends on certain libraries and other software; you can get
-those at the Laconica site, too.
-
-
diff --git a/doc/tags b/doc/tags
deleted file mode 100644 (file)
index 2ed352e..0000000
--- a/doc/tags
+++ /dev/null
@@ -1,40 +0,0 @@
-%%site.name%% supports
-[tags](http://en.wikipedia.org/wiki/Tag_(metadata)) to help you
-organize your activities here. You can use tags for people and for
-notices.
-
-Tagging a notice
-----------------
-
-You can tag a notice using a *hashtag*; a # character followed by
-letters and numbers as well as '.', '-', and '_'. Note that accented
-latin characters are not supported, and non-roman scripts are right out.
-
-The HTML for the notice will link to a stream of all the other notices
-with that tag. This can be a great way to keep track of a conversation.
-
-The most popular current tags on the site can be found in the [public
-tag cloud](%%action.publictagcloud%%). Their size shows their
-popularity and recency.
-
-Tagging yourself
-----------------
-
-You can also add tags for yourself on your [profile
-settings](%%action.profilesettings%%) page. Use single words to
-describe yourself, your experiences and your interest. The tags will
-become links on your profile page to a list of all the users on the
-site who use that same tag. It can be a nice way to find people who
-are related to you geographically or who have a common interest.
-
-Tagging your subscriptions
---------------------------
-
-You can also tag your subscriptions, on the subscriptions page. This
-makes it easy to organize your subscriptions into groups and sort
-through them separately.
-
-You can also send a notice "to the attention of" everyone you've
-marked with a particular tag (note: *not* people who've marked
-themselves with that tag). "@#family hello" will send a notice to
-everyone you've marked with the tag 'family'.
\ No newline at end of file
diff --git a/extlib/Net/URL.php b/extlib/Net/URL.php
new file mode 100644 (file)
index 0000000..3dcfef6
--- /dev/null
@@ -0,0 +1,485 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Copyright (c) 2002-2004, Richard Heyes                                |
+// | All rights reserved.                                                  |
+// |                                                                       |
+// | Redistribution and use in source and binary forms, with or without    |
+// | modification, are permitted provided that the following conditions    |
+// | are met:                                                              |
+// |                                                                       |
+// | o Redistributions of source code must retain the above copyright      |
+// |   notice, this list of conditions and the following disclaimer.       |
+// | o Redistributions in binary form must reproduce the above copyright   |
+// |   notice, this list of conditions and the following disclaimer in the |
+// |   documentation and/or other materials provided with the distribution.|
+// | o The names of the authors may not be used to endorse or promote      |
+// |   products derived from this software without specific prior written  |
+// |   permission.                                                         |
+// |                                                                       |
+// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
+// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
+// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
+// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
+// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
+// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
+// |                                                                       |
+// +-----------------------------------------------------------------------+
+// | Author: Richard Heyes <richard at php net>                            |
+// +-----------------------------------------------------------------------+
+//
+// $Id: URL.php,v 1.49 2007/06/28 14:43:07 davidc Exp $
+//
+// Net_URL Class
+
+
+class Net_URL
+{
+    var $options = array('encode_query_keys' => false);
+    /**
+    * Full url
+    * @var string
+    */
+    var $url;
+
+    /**
+    * Protocol
+    * @var string
+    */
+    var $protocol;
+
+    /**
+    * Username
+    * @var string
+    */
+    var $username;
+
+    /**
+    * Password
+    * @var string
+    */
+    var $password;
+
+    /**
+    * Host
+    * @var string
+    */
+    var $host;
+
+    /**
+    * Port
+    * @var integer
+    */
+    var $port;
+
+    /**
+    * Path
+    * @var string
+    */
+    var $path;
+
+    /**
+    * Query string
+    * @var array
+    */
+    var $querystring;
+
+    /**
+    * Anchor
+    * @var string
+    */
+    var $anchor;
+
+    /**
+    * Whether to use []
+    * @var bool
+    */
+    var $useBrackets;
+
+    /**
+    * PHP4 Constructor
+    *
+    * @see __construct()
+    */
+    function Net_URL($url = null, $useBrackets = true)
+    {
+        $this->__construct($url, $useBrackets);
+    }
+
+    /**
+    * PHP5 Constructor
+    *
+    * Parses the given url and stores the various parts
+    * Defaults are used in certain cases
+    *
+    * @param string $url         Optional URL
+    * @param bool   $useBrackets Whether to use square brackets when
+    *                            multiple querystrings with the same name
+    *                            exist
+    */
+    function __construct($url = null, $useBrackets = true)
+    {
+        $this->url = $url;
+        $this->useBrackets = $useBrackets;
+
+        $this->initialize();
+    }
+
+    function initialize()
+    {
+        $HTTP_SERVER_VARS  = !empty($_SERVER) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
+
+        $this->user        = '';
+        $this->pass        = '';
+        $this->host        = '';
+        $this->port        = 80;
+        $this->path        = '';
+        $this->querystring = array();
+        $this->anchor      = '';
+
+        // Only use defaults if not an absolute URL given
+        if (!preg_match('/^[a-z0-9]+:\/\//i', $this->url)) {
+            $this->protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http');
+
+            /**
+            * Figure out host/port
+            */
+            if (!empty($HTTP_SERVER_VARS['HTTP_HOST']) && 
+                preg_match('/^(.*)(:([0-9]+))?$/U', $HTTP_SERVER_VARS['HTTP_HOST'], $matches)) 
+            {
+                $host = $matches[1];
+                if (!empty($matches[3])) {
+                    $port = $matches[3];
+                } else {
+                    $port = $this->getStandardPort($this->protocol);
+                }
+            }
+
+            $this->user        = '';
+            $this->pass        = '';
+            $this->host        = !empty($host) ? $host : (isset($HTTP_SERVER_VARS['SERVER_NAME']) ? $HTTP_SERVER_VARS['SERVER_NAME'] : 'localhost');
+            $this->port        = !empty($port) ? $port : (isset($HTTP_SERVER_VARS['SERVER_PORT']) ? $HTTP_SERVER_VARS['SERVER_PORT'] : $this->getStandardPort($this->protocol));
+            $this->path        = !empty($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : '/';
+            $this->querystring = isset($HTTP_SERVER_VARS['QUERY_STRING']) ? $this->_parseRawQuerystring($HTTP_SERVER_VARS['QUERY_STRING']) : null;
+            $this->anchor      = '';
+        }
+
+        // Parse the url and store the various parts
+        if (!empty($this->url)) {
+            $urlinfo = parse_url($this->url);
+
+            // Default querystring
+            $this->querystring = array();
+
+            foreach ($urlinfo as $key => $value) {
+                switch ($key) {
+                    case 'scheme':
+                        $this->protocol = $value;
+                        $this->port     = $this->getStandardPort($value);
+                        break;
+
+                    case 'user':
+                    case 'pass':
+                    case 'host':
+                    case 'port':
+                        $this->$key = $value;
+                        break;
+
+                    case 'path':
+                        if ($value{0} == '/') {
+                            $this->path = $value;
+                        } else {
+                            $path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path);
+                            $this->path = sprintf('%s/%s', $path, $value);
+                        }
+                        break;
+
+                    case 'query':
+                        $this->querystring = $this->_parseRawQueryString($value);
+                        break;
+
+                    case 'fragment':
+                        $this->anchor = $value;
+                        break;
+                }
+            }
+        }
+    }
+    /**
+    * Returns full url
+    *
+    * @return string Full url
+    * @access public
+    */
+    function getURL()
+    {
+        $querystring = $this->getQueryString();
+
+        $this->url = $this->protocol . '://'
+                   . $this->user . (!empty($this->pass) ? ':' : '')
+                   . $this->pass . (!empty($this->user) ? '@' : '')
+                   . $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port)
+                   . $this->path
+                   . (!empty($querystring) ? '?' . $querystring : '')
+                   . (!empty($this->anchor) ? '#' . $this->anchor : '');
+
+        return $this->url;
+    }
+
+    /**
+    * Adds or updates a querystring item (URL parameter).
+    * Automatically encodes parameters with rawurlencode() if $preencoded
+    *  is false.
+    * You can pass an array to $value, it gets mapped via [] in the URL if
+    * $this->useBrackets is activated.
+    *
+    * @param  string $name       Name of item
+    * @param  string $value      Value of item
+    * @param  bool   $preencoded Whether value is urlencoded or not, default = not
+    * @access public
+    */
+    function addQueryString($name, $value, $preencoded = false)
+    {
+        if ($this->getOption('encode_query_keys')) {
+            $name = rawurlencode($name);
+        }
+
+        if ($preencoded) {
+            $this->querystring[$name] = $value;
+        } else {
+            $this->querystring[$name] = is_array($value) ? array_map('rawurlencode', $value): rawurlencode($value);
+        }
+    }
+
+    /**
+    * Removes a querystring item
+    *
+    * @param  string $name Name of item
+    * @access public
+    */
+    function removeQueryString($name)
+    {
+        if ($this->getOption('encode_query_keys')) {
+            $name = rawurlencode($name);
+        }
+
+        if (isset($this->querystring[$name])) {
+            unset($this->querystring[$name]);
+        }
+    }
+
+    /**
+    * Sets the querystring to literally what you supply
+    *
+    * @param  string $querystring The querystring data. Should be of the format foo=bar&x=y etc
+    * @access public
+    */
+    function addRawQueryString($querystring)
+    {
+        $this->querystring = $this->_parseRawQueryString($querystring);
+    }
+
+    /**
+    * Returns flat querystring
+    *
+    * @return string Querystring
+    * @access public
+    */
+    function getQueryString()
+    {
+        if (!empty($this->querystring)) {
+            foreach ($this->querystring as $name => $value) {
+                // Encode var name
+                $name = rawurlencode($name);
+
+                if (is_array($value)) {
+                    foreach ($value as $k => $v) {
+                        $querystring[] = $this->useBrackets ? sprintf('%s[%s]=%s', $name, $k, $v) : ($name . '=' . $v);
+                    }
+                } elseif (!is_null($value)) {
+                    $querystring[] = $name . '=' . $value;
+                } else {
+                    $querystring[] = $name;
+                }
+            }
+            $querystring = implode(ini_get('arg_separator.output'), $querystring);
+        } else {
+            $querystring = '';
+        }
+
+        return $querystring;
+    }
+
+    /**
+    * Parses raw querystring and returns an array of it
+    *
+    * @param  string  $querystring The querystring to parse
+    * @return array                An array of the querystring data
+    * @access private
+    */
+    function _parseRawQuerystring($querystring)
+    {
+        $parts  = preg_split('/[' . preg_quote(ini_get('arg_separator.input'), '/') . ']/', $querystring, -1, PREG_SPLIT_NO_EMPTY);
+        $return = array();
+
+        foreach ($parts as $part) {
+            if (strpos($part, '=') !== false) {
+                $value = substr($part, strpos($part, '=') + 1);
+                $key   = substr($part, 0, strpos($part, '='));
+            } else {
+                $value = null;
+                $key   = $part;
+            }
+
+            if (!$this->getOption('encode_query_keys')) {
+                $key = rawurldecode($key);
+            }
+
+            if (preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) {
+                $key = $matches[1];
+                $idx = $matches[2];
+
+                // Ensure is an array
+                if (empty($return[$key]) || !is_array($return[$key])) {
+                    $return[$key] = array();
+                }
+
+                // Add data
+                if ($idx === '') {
+                    $return[$key][] = $value;
+                } else {
+                    $return[$key][$idx] = $value;
+                }
+            } elseif (!$this->useBrackets AND !empty($return[$key])) {
+                $return[$key]   = (array)$return[$key];
+                $return[$key][] = $value;
+            } else {
+                $return[$key] = $value;
+            }
+        }
+
+        return $return;
+    }
+
+    /**
+    * Resolves //, ../ and ./ from a path and returns
+    * the result. Eg:
+    *
+    * /foo/bar/../boo.php    => /foo/boo.php
+    * /foo/bar/../../boo.php => /boo.php
+    * /foo/bar/.././/boo.php => /foo/boo.php
+    *
+    * This method can also be called statically.
+    *
+    * @param  string $path URL path to resolve
+    * @return string      The result
+    */
+    function resolvePath($path)
+    {
+        $path = explode('/', str_replace('//', '/', $path));
+
+        for ($i=0; $i<count($path); $i++) {
+            if ($path[$i] == '.') {
+                unset($path[$i]);
+                $path = array_values($path);
+                $i--;
+
+            } elseif ($path[$i] == '..' AND ($i > 1 OR ($i == 1 AND $path[0] != '') ) ) {
+                unset($path[$i]);
+                unset($path[$i-1]);
+                $path = array_values($path);
+                $i -= 2;
+
+            } elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') {
+                unset($path[$i]);
+                $path = array_values($path);
+                $i--;
+
+            } else {
+                continue;
+            }
+        }
+
+        return implode('/', $path);
+    }
+
+    /**
+    * Returns the standard port number for a protocol
+    *
+    * @param  string  $scheme The protocol to lookup
+    * @return integer         Port number or NULL if no scheme matches
+    *
+    * @author Philippe Jausions <Philippe.Jausions@11abacus.com>
+    */
+    function getStandardPort($scheme)
+    {
+        switch (strtolower($scheme)) {
+            case 'http':    return 80;
+            case 'https':   return 443;
+            case 'ftp':     return 21;
+            case 'imap':    return 143;
+            case 'imaps':   return 993;
+            case 'pop3':    return 110;
+            case 'pop3s':   return 995;
+            default:        return null;
+       }
+    }
+
+    /**
+    * Forces the URL to a particular protocol
+    *
+    * @param string  $protocol Protocol to force the URL to
+    * @param integer $port     Optional port (standard port is used by default)
+    */
+    function setProtocol($protocol, $port = null)
+    {
+        $this->protocol = $protocol;
+        $this->port     = is_null($port) ? $this->getStandardPort($protocol) : $port;
+    }
+
+    /**
+     * Set an option
+     *
+     * This function set an option
+     * to be used thorough the script.
+     *
+     * @access public
+     * @param  string $optionName  The optionname to set
+     * @param  string $value       The value of this option.
+     */
+    function setOption($optionName, $value)
+    {
+        if (!array_key_exists($optionName, $this->options)) {
+            return false;
+        }
+
+        $this->options[$optionName] = $value;
+        $this->initialize();
+    }
+
+    /**
+     * Get an option
+     *
+     * This function gets an option
+     * from the $this->options array
+     * and return it's value.
+     *
+     * @access public
+     * @param  string $opionName  The name of the option to retrieve
+     * @see    $this->options
+     */
+    function getOption($optionName)
+    {
+        if (!isset($this->options[$optionName])) {
+            return false;
+        }
+
+        return $this->options[$optionName];
+    }
+
+}
+?>
diff --git a/extlib/Net/URL/Mapper.php b/extlib/Net/URL/Mapper.php
new file mode 100644 (file)
index 0000000..65e3881
--- /dev/null
@@ -0,0 +1,324 @@
+<?php
+/**
+ * URL parser and mapper
+ *
+ * PHP version 5
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2006, Bertrand Mansion <golgote@mamasam.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @author     Bertrand Mansion <golgote@mamasam.com>
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: Mapper.php,v 1.1 2007/03/28 10:23:04 mansion Exp $
+ * @link       http://pear.php.net/package/Net_URL_Mapper
+ */
+
+require_once 'Net/URL/Mapper/Path.php';
+require_once 'Net/URL/Mapper/Exception.php';
+
+/**
+ * URL parser and mapper class
+ *
+ * This class takes an URL and a configuration and returns formatted data
+ * about the request according to a configuration parameter
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @author     Bertrand Mansion <golgote@mamasam.com>
+ * @version    Release: @package_version@
+ */
+class Net_URL_Mapper
+{
+    /**
+    * Array of Net_URL_Mapper instances
+    * @var array
+    */
+    private static $instances = array();
+
+    /**
+    * Mapped paths collection
+    * @var array
+    */
+    protected $paths = array();
+
+    /**
+    * Prefix used for url mapping
+    * @var string
+    */
+    protected $prefix = '';
+
+    /**
+    * Optional scriptname if mod_rewrite is not available
+    * @var string
+    */
+    protected $scriptname = '';
+
+    /**
+    * Mapper instance id
+    * @var string
+    */
+    protected $id = '__default__';
+
+    /**
+    * Class constructor
+    * Constructor is private, you should use getInstance() instead.
+    */
+    private function __construct() { }
+
+    /**
+    * Returns a singleton object corresponding to the requested instance id
+    * @param  string    Requested instance name
+    * @return Object    Net_URL_Mapper Singleton
+    */
+    public static function getInstance($id = '__default__')
+    {
+        if (!isset(self::$instances[$id])) {
+            $m = new Net_URL_Mapper();
+            $m->id = $id;
+            self::$instances[$id] = $m;
+        }
+        return self::$instances[$id];
+    }
+
+    /**
+    * Returns the instance id
+    * @return   string  Mapper instance id
+    */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+    * Parses a path and creates a connection
+    * @param    string  The path to connect
+    * @param    array   Default values for path parts
+    * @param    array   Regular expressions for path parts
+    * @return   object  Net_URL_Mapper_Path
+    */
+    public function connect($path, $defaults = array(), $rules = array())
+    {
+        $pathObj = new Net_URL_Mapper_Path($path, $defaults, $rules);
+        $this->addPath($pathObj);
+        return $pathObj;
+    }
+
+    /**
+    * Set the url prefix if needed
+    *
+    * Example: using the prefix to differenciate mapper instances
+    * <code>
+    * $fr = Net_URL_Mapper::getInstance('fr');
+    * $fr->setPrefix('/fr');
+    * $en = Net_URL_Mapper::getInstance('en');
+    * $en->setPrefix('/en');
+    * </code>
+    *
+    * @param    string  URL prefix
+    */
+    public function setPrefix($prefix)
+    {
+        $this->prefix = '/'.trim($prefix, '/');
+    }
+
+    /**
+    * Set the scriptname if mod_rewrite not available
+    *
+    * Example: will match and generate url like
+    * - index.php/view/product/1
+    * <code>
+    * $m = Net_URL_Mapper::getInstance();
+    * $m->setScriptname('index.php');
+    * </code>
+    * @param    string  URL prefix
+    */
+    public function setScriptname($scriptname)
+    {
+        $this->scriptname = $scriptname;
+    }
+
+    /**
+    * Will attempt to match an url with a defined path
+    *
+    * If an url corresponds to a path, the resulting values are returned
+    * in an array. If none is found, null is returned. In case an url is
+    * matched but its content doesn't validate the path rules, an exception is
+    * thrown.
+    *
+    * @param    string  URL
+    * @return   array|null   array if match found, null otherwise
+    * @throws   Net_URL_Mapper_InvalidException
+    */
+    public function match($url)
+    {
+        $nurl = '/'.trim($url, '/');
+
+        // Remove scriptname if needed
+        
+        if (!empty($this->scriptname) &&
+            strpos($nurl, $this->scriptname) === 0) {
+            $nurl = substr($nurl, strlen($this->scriptname));
+            if (empty($nurl)) {
+                $nurl = '/';
+            }
+        }
+
+        // Remove prefix
+        
+        if (!empty($this->prefix)) {
+            if (strpos($nurl, $this->prefix) !== 0) {
+                return null;
+            }
+            $nurl = substr($nurl, strlen($this->prefix));
+            if (empty($nurl)) {
+                $nurl = '/';
+            }
+        }
+        
+        // Remove query string
+        
+        if (($pos = strpos($nurl, '?')) !== false) {
+            $nurl = substr($nurl, 0, $pos);
+        }
+
+        $paths = array();
+        $values = null;
+
+        // Make a list of paths that conform to route format
+
+        foreach ($this->paths as $path) {
+            $regex = $path->getFormat();
+            if (preg_match($regex, $nurl)) {
+                $paths[] = $path;
+            }   
+        }
+
+        // Make sure one of the paths found is valid
+
+        foreach ($paths as $path) {
+            $regex = $path->getRule();
+            if (preg_match($regex, $nurl, $matches)) {
+                $values = $path->getDefaults();
+                array_shift($matches);
+                $clean = array();
+                foreach ($matches as $k => $v) {
+                    $v = trim($v, '/');
+                    if (!is_int($k) && $v !== '') {
+                        $values[$k] = $v;
+                    }
+                }
+                break;
+            }
+        }
+
+        // A path conforms but does not validate
+
+        if (is_null($values) && !empty($paths)) {
+            $e = new Net_URL_Mapper_InvalidException('A path was found but is invalid.');
+            $e->setPath($paths[0]);
+            $e->setUrl($url);
+            throw $e;
+        }
+
+        return $values;
+    }
+
+    /**
+    * Generate an url based on given parameters
+    *
+    * Will attempt to find a path definition that matches the given parameters and
+    * will generate an url based on this path.
+    *
+    * @param    array   Values to be used for the url generation
+    * @param    array   Key/value pairs for query string if needed
+    * @param    string  Anchor (fragment) if needed
+    * @return   string|false    String if a rule was found, false otherwise
+    */
+    public function generate($values = array(), $qstring = array(), $anchor = '')
+    {
+        // Use root path if any
+
+        if (empty($values) && isset($this->paths['/'])) {
+            return $this->scriptname.$this->prefix.$this->paths['/']->generate($values, $qstring, $anchor);
+        }
+
+        foreach ($this->paths as $path) {
+            $set = array();
+            foreach ($values as $k => $v) {
+                if ($path->hasKey($k, $v)) {
+                    $set[$k] = $v;
+                }
+            }
+
+            if (count($set) == count($values) &&
+                count($set) <= $path->getMaxKeys()) {
+
+                $req = $path->getRequired();
+                if (count(array_intersect(array_keys($set), $req)) != count($req)) {
+                    continue;
+                }
+                $gen = $path->generate($set, $qstring, $anchor);
+                return $this->scriptname.$this->prefix.$gen;
+            }
+        }
+        return false;
+    }
+
+    /**
+    * Returns defined paths
+    * @return array     Array of paths
+    */
+    public function getPaths()
+    {
+        return $this->paths;
+    }
+
+    /**
+    * Reset all paths
+    * This is probably only useful for testing
+    */
+    public function reset()
+    {
+        $this->paths = array();
+        $this->prefix = '';
+    }
+
+    /**
+    * Add a new path to the mapper
+    * @param object     Net_URL_Mapper_Path object
+    */
+    public function addPath(Net_URL_Mapper_Path $path)
+    {
+        $this->paths[$path->getPath()] = $path;
+    }
+
+}
+?>
\ No newline at end of file
diff --git a/extlib/Net/URL/Mapper/Exception.php b/extlib/Net/URL/Mapper/Exception.php
new file mode 100644 (file)
index 0000000..ac3ad17
--- /dev/null
@@ -0,0 +1,104 @@
+<?php
+/**
+ * Exception classes for Net_URL_Mapper
+ *
+ * PHP version 5
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2006, Bertrand Mansion <golgote@mamasam.com> 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @author     Bertrand Mansion <golgote@mamasam.com>
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: Exception.php,v 1.1 2007/03/28 10:23:04 mansion Exp $
+ * @link       http://pear.php.net/package/Net_URL_Mapper
+ */
+
+/**
+ * Base class for exceptions in PEAR
+ */
+require_once 'PEAR/Exception.php'; 
+
+/**
+ * Base class for exceptions in Net_URL_Mapper package
+ *
+ * Such a base class is required by the Exception RFC:
+ * http://pear.php.net/pepr/pepr-proposal-show.php?id=132
+ * It will rarely be thrown directly, its specialized subclasses will be
+ * thrown most of the time.
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @version    Release: @package_version@
+ */
+class Net_URL_Mapper_Exception extends PEAR_Exception
+{
+}
+
+/**
+ * Exception thrown when a path is invalid
+ *
+ * A path can conform to a given structure, but contain invalid parameters.
+ * <code>
+ * $m = Net_URL_Mapper::getInstance();
+ * $m->connect('hi/:name', null, array('name'=>'[a-z]+'));
+ * $m->match('/hi/FOXY'); // Will throw the exception
+ * </code>
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @version    Release: @package_version@
+ */
+class Net_URL_Mapper_InvalidException extends Net_URL_Mapper_Exception
+{
+    protected $path;
+    protected $url;
+
+    public function setPath($path)
+    {
+        $this->path = $path;
+    }
+
+    public function getPath()
+    {
+        return $this->path;
+    }
+
+    public function setUrl($url)
+    {
+        $this->url = $url;
+    }
+
+    public function getUrl()
+    {
+        return $this->url;
+    }
+} 
+?>
\ No newline at end of file
diff --git a/extlib/Net/URL/Mapper/Part.php b/extlib/Net/URL/Mapper/Part.php
new file mode 100644 (file)
index 0000000..2f15b2c
--- /dev/null
@@ -0,0 +1,142 @@
+<?php
+/**
+ * URL parser and mapper
+ *
+ * PHP version 5
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2006, Bertrand Mansion <golgote@mamasam.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @author     Bertrand Mansion <golgote@mamasam.com>
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: Part.php,v 1.1 2007/03/28 10:23:04 mansion Exp $
+ * @link       http://pear.php.net/package/Net_URL_Mapper
+ */
+
+abstract class Net_URL_Mapper_Part
+{
+    protected $defaults;
+    protected $rule;
+    protected $public;
+    protected $type;
+    protected $required = false;
+    
+    /**
+    * Part name if dynamic or content, generated from path
+    * @var string
+    */
+    public $content;
+    
+    const DYNAMIC = 1;
+    const WILDCARD = 2;
+    const FIXED = 3;
+
+    public function __construct($content, $path)
+    {
+        $this->content = $content;
+        $this->path = $path;
+    }
+
+    public function setRule($rule)
+    {
+        $this->rule = $rule;
+    }
+
+    abstract public function getFormat();
+    
+    abstract public function getRule();
+
+    public function addSlash($str)
+    {
+        $str = trim($str, '/');
+        if (($pos = strpos($this->path, '/')) !== false) {
+            if ($pos == 0) {
+                $str = '/'.$str;
+            } else {
+                $str .= '/';
+            }
+        }
+        return $str;
+    }
+
+    public function addSlashRegex($str)
+    {
+        $str = trim($str, '/');
+        if (($pos = strpos($this->path, '/')) !== false) {
+            if ($pos == 0) {
+                $str = '\/'.$str;
+            } else {
+                $str .= '\/';
+            }
+        }
+        if (!$this->isRequired()) {
+            $str = '('.$str.'|)';
+        }
+        return $str;
+    }
+
+    public function setDefaults($defaults)
+    {
+        $this->defaults = (string)$defaults;
+    }
+
+    public function getType()
+    {
+        return $this->type;
+    }
+
+    public function accept($visitor, $method = null)
+    {
+        $args = func_get_args();
+        $visitor->$method($this, $args);
+    }
+
+    public function setRequired($required)
+    {
+        $this->required = $required;
+    }
+
+    public function isRequired()
+    {
+        return $this->required;
+    }
+
+    abstract public function generate($value = null);
+    
+    public function match($value)
+    {
+        $rule = $this->getRule();
+        return preg_match('/^'.$rule.'$/', $this->addSlash($value));
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/extlib/Net/URL/Mapper/Part/Dynamic.php b/extlib/Net/URL/Mapper/Part/Dynamic.php
new file mode 100644 (file)
index 0000000..349d873
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * URL parser and mapper
+ *
+ * PHP version 5
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2006, Bertrand Mansion <golgote@mamasam.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @author     Bertrand Mansion <golgote@mamasam.com>
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: Dynamic.php,v 1.1 2007/03/28 10:23:04 mansion Exp $
+ * @link       http://pear.php.net/package/Net_URL_Mapper
+ */
+
+require_once 'Net/URL/Mapper/Part.php';
+
+class Net_URL_Mapper_Part_Dynamic extends Net_URL_Mapper_Part
+{
+    
+    public function __construct($content, $path)
+    {
+        $this->type = Net_URL_Mapper_Part::DYNAMIC;
+        $this->setRequired(true);
+        parent::__construct($content, $path);
+    }
+
+    public function getFormat()
+    {
+        return $this->addSlashRegex('[^\/]+');
+    }
+
+    public function getRule()
+    {
+        if (!empty($this->rule)) {
+            return '(?P<'.$this->content.'>'.$this->addSlashRegex($this->rule).')';
+        }
+        return '(?P<'.$this->content.'>'.$this->addSlashRegex('[^\/]+').')';
+    }
+
+    public function generate($value = null)
+    {
+        if (is_array($value) && isset($value[$this->content])) {
+            $val = $value[$this->content];
+        } elseif (!is_array($value) && !is_null($value)) {
+            $val = $value;
+        } else {
+            $val = $this->defaults;
+        }
+        return $this->addSlash(urlencode($val));
+    }
+}
+?>
\ No newline at end of file
diff --git a/extlib/Net/URL/Mapper/Part/Fixed.php b/extlib/Net/URL/Mapper/Part/Fixed.php
new file mode 100644 (file)
index 0000000..b315b44
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * URL parser and mapper
+ *
+ * PHP version 5
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2006, Bertrand Mansion <golgote@mamasam.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @author     Bertrand Mansion <golgote@mamasam.com>
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: Fixed.php,v 1.1 2007/03/28 10:23:04 mansion Exp $
+ * @link       http://pear.php.net/package/Net_URL_Mapper
+ */
+
+require_once 'Net/URL/Mapper/Part.php';
+
+class Net_URL_Mapper_Part_Fixed extends Net_URL_Mapper_Part
+{
+    
+    public function __construct($content, $path)
+    {
+        $this->type = Net_URL_Mapper_Part::FIXED;
+        parent::__construct($content, $path);
+    }
+
+    public function getFormat()
+    {
+        return $this->getRule();
+    }
+
+    public function getRule()
+    {
+        return preg_quote($this->path, '/');
+    }
+
+    public function generate($value = null)
+    {
+        return $this->path;
+    }
+}
+?>
\ No newline at end of file
diff --git a/extlib/Net/URL/Mapper/Part/Wildcard.php b/extlib/Net/URL/Mapper/Part/Wildcard.php
new file mode 100644 (file)
index 0000000..6085ff6
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/**
+ * URL parser and mapper
+ *
+ * PHP version 5
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2006, Bertrand Mansion <golgote@mamasam.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @author     Bertrand Mansion <golgote@mamasam.com>
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: Wildcard.php,v 1.1 2007/03/28 10:23:04 mansion Exp $
+ * @link       http://pear.php.net/package/Net_URL_Mapper
+ */
+
+require_once 'Net/URL/Mapper/Part.php';
+
+class Net_URL_Mapper_Part_Wildcard extends Net_URL_Mapper_Part
+{
+    
+    public function __construct($content, $path)
+    {
+        $this->type = Net_URL_Mapper_Part::WILDCARD;
+        $this->setRequired(true);
+        parent::__construct($content, $path);
+    }
+
+    public function getFormat()
+    {
+        return $this->addSlashRegex('.*');;
+    }
+
+    public function getRule()
+    {
+        return '(?P<'.$this->content.'>'.$this->addSlashRegex('.*').')';
+    }
+
+    public function generate($value = null)
+    {
+        if (is_array($value) && isset($value[$this->content])) {
+            $val = $value[$this->content];
+        } elseif (!is_array($value) && !is_null($value)) {
+            $val = $value;
+        } else {
+            $val = $this->defaults;
+        }
+        return $this->addSlash(str_replace(
+            array('%2F', '%23'), 
+            array('/', '#'), urlencode($val)));
+    }
+}
+?>
\ No newline at end of file
diff --git a/extlib/Net/URL/Mapper/Path.php b/extlib/Net/URL/Mapper/Path.php
new file mode 100644 (file)
index 0000000..b541002
--- /dev/null
@@ -0,0 +1,430 @@
+<?php
+/**
+ * URL parser and mapper
+ *
+ * PHP version 5
+ *
+ * LICENSE:
+ * 
+ * Copyright (c) 2006, Bertrand Mansion <golgote@mamasam.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the 
+ *      documentation and/or other materials provided with the distribution.
+ *    * The names of the authors may not be used to endorse or promote products 
+ *      derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Net
+ * @package    Net_URL_Mapper
+ * @author     Bertrand Mansion <golgote@mamasam.com>
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version    CVS: $Id: Path.php,v 1.1 2007/03/28 10:23:04 mansion Exp $
+ * @link       http://pear.php.net/package/Net_URL_Mapper
+ */
+
+require_once 'Net/URL.php';
+require_once 'Net/URL/Mapper/Part/Dynamic.php';
+require_once 'Net/URL/Mapper/Part/Wildcard.php';
+require_once 'Net/URL/Mapper/Part/Fixed.php';
+
+class Net_URL_Mapper_Path
+{
+    private $path = '';
+    private $N = 0;
+    public $token;
+    public $value;
+    private $line = 1;
+    private $state = 1;
+
+
+    protected $alias;
+    protected $rules = array();
+    protected $defaults = array();
+    protected $parts = array();
+    protected $rule;
+    protected $format;
+    protected $minKeys;
+    protected $maxKeys;
+    protected $fixed = true;
+    protected $required;
+
+    public function __construct($path = '', $defaults = array(), $rules = array())
+    {
+        $this->path = '/'.trim(Net_URL::resolvePath($path), '/');
+        $this->setDefaults($defaults);
+        $this->setRules($rules);
+
+        try {
+            $this->parsePath();
+        } catch (Exception $e) {
+            // The path could not be parsed correctly, treat it as fixed
+            $this->fixed = true;
+            $part = self::createPart(Net_URL_Mapper_Part::FIXED, $this->path, $this->path);
+            $this->parts = array($part);
+        }
+        $this->getRequired();
+    }
+
+    public function getPath()
+    {
+        return $this->path;
+    }
+
+    protected function parsePath()
+    {
+        while ($this->yylex()) { }
+    }
+
+    /**
+    * Get the path alias
+    * Path aliases can be used instead of full path
+    * @return null|string
+    */
+    public function getAlias()
+    {
+        return $this->alias;
+    }
+
+    /**
+    * Set the path name
+    * @param string Set the path name
+    * @see getAlias()
+    */
+    public function setAlias($alias)
+    {
+        $this->alias = $alias;
+        return $this;
+    }
+
+    /**
+    * Get the path parts default values
+    * @return null|array
+    */
+    public function getDefaults()
+    {
+        return $this->defaults;
+    }
+
+    /**
+    * Set the path parts default values
+    * @param array  Associative array with format partname => value
+    */    
+    public function setDefaults($defaults)
+    {
+        if (is_array($defaults)) {
+            $this->defaults = $defaults;
+        } else {
+            $this->defaults = array();
+        }
+    }
+
+    /**
+    * Set the path parts default values
+    * @param array  Associative array with format partname => value
+    */    
+    public function setRules($rules)
+    {
+        if (is_array($rules)) {
+            $this->rules = $rules;   
+        } else {
+            $this->rules = array();
+        }
+    }
+
+    /**
+    * Returns the regular expression used to match this path
+    * @return string  PERL Regular expression
+    */ 
+    public function getRule()
+    {
+        if (is_null($this->rule)) {
+            $this->rule = '/^';
+            foreach ($this->parts as $path => $part) {
+                $this->rule .= $part->getRule();
+            }
+            $this->rule .= '$/';
+        }
+        return $this->rule;
+    }
+
+    public function getFormat()
+    {
+        if (is_null($this->format)) {
+            $this->format = '/^';
+            foreach ($this->parts as $path => $part) {
+                $this->format .= $part->getFormat();
+            }
+            $this->format .= '$/';
+        }
+        return $this->format;
+    }
+
+    protected function addPart($part)
+    {
+        if (array_key_exists($part->content, $this->defaults)) {
+            $part->setRequired(false);
+            $part->setDefaults($this->defaults[$part->content]);
+        }
+        if (isset($this->rules[$part->content])) {
+            $part->setRule($this->rules[$part->content]);
+        }
+        $this->rule = null;
+        if ($part->getType() != Net_URL_Mapper_Part::FIXED) {
+            $this->fixed = false;
+            $this->parts[$part->content] = $part;
+        } else {
+            $this->parts[] = $part;
+        }
+        return $part;
+    }
+
+    public static function createPart($type, $content, $path)
+    {
+        switch ($type) {
+            case Net_URL_Mapper_Part::DYNAMIC:
+                return new Net_URL_Mapper_Part_Dynamic($content, $path);
+                break;
+            case Net_URL_Mapper_Part::WILDCARD:
+                return new Net_URL_Mapper_Part_Wildcard($content, $path);
+                break;
+            default:
+                return new Net_URL_Mapper_Part_Fixed($content, $path);
+        }
+    }
+
+    /**
+    * Checks whether the path contains the given part by name
+    * If value parameter is given, the part also checks if the 
+    * given value conforms to the part rule.
+    * @param string Part name
+    * @param mixed  The value to check against 
+    */
+    public function hasKey($partName, $value = null)
+    {
+        if (array_key_exists($partName, $this->parts)) {
+            if (!is_null($value) && $value !== false) {
+                return $this->parts[$partName]->match($value);
+            } else {
+                return true;
+            }
+        } elseif (array_key_exists($partName, $this->defaults) &&
+            $value == $this->defaults[$partName]) {
+            return true;
+        }
+        return false;
+    }
+
+    public function generate($values = array(), $qstring = array(), $anchor = '')
+    {
+        $path = '';
+        foreach ($this->parts as $part) {
+            $path .= $part->generate($values);
+        }
+        $path = '/'.trim(Net_URL::resolvePath($path), '/');
+        if (!empty($qstring)) {
+            $path .= '?'.http_build_query($qstring);
+        }
+        if (!empty($anchor)) {
+            $path .= '#'.ltrim($anchor, '#');
+        }
+        return $path;
+    }
+
+    public function getRequired()
+    {
+        if (!isset($this->required)) {
+            $req = array();
+            foreach ($this->parts as $part) {
+                if ($part->isRequired()) {
+                    $req[] = $part->content;
+                }
+            }
+            $this->required = $req;
+        }
+        return $this->required;
+    }
+
+    public function getMaxKeys()
+    {
+        if (is_null($this->maxKeys)) {
+            $this->maxKeys = count($this->required);
+            $this->maxKeys += count($this->defaults);
+        }
+        return $this->maxKeys;
+    }
+
+
+
+
+    private $_yy_state = 1;
+    private $_yy_stack = array();
+
+    function yylex()
+    {
+        return $this->{'yylex' . $this->_yy_state}();
+    }
+
+    function yypushstate($state)
+    {
+        array_push($this->_yy_stack, $this->_yy_state);
+        $this->_yy_state = $state;
+    }
+
+    function yypopstate()
+    {
+        $this->_yy_state = array_pop($this->_yy_stack);
+    }
+
+    function yybegin($state)
+    {
+        $this->_yy_state = $state;
+    }
+
+
+
+    function yylex1()
+    {
+        $tokenMap = array (
+              1 => 1,
+              3 => 1,
+              5 => 1,
+              7 => 1,
+              9 => 1,
+            );
+        if ($this->N >= strlen($this->path)) {
+            return false; // end of input
+        }
+        $yy_global_pattern = "/^(\/?:\/?\\(([a-zA-Z0-9_]+)\\))|^(\/?\\*\/?\\(([a-zA-Z0-9_]+)\\))|^(\/?:([a-zA-Z0-9_]+))|^(\/?\\*([a-zA-Z0-9_]+))|^(\/?([^\/:*]+))/";
+
+        do {
+            if (preg_match($yy_global_pattern, substr($this->path, $this->N), $yymatches)) {
+                $yysubmatches = $yymatches;
+                $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
+                if (!count($yymatches)) {
+                    throw new Exception('Error: lexing failed because a rule matched' .
+                        'an empty string.  Input "' . substr($this->path,
+                        $this->N, 5) . '... state START');
+                }
+                next($yymatches); // skip global match
+                $this->token = key($yymatches); // token number
+                if ($tokenMap[$this->token]) {
+                    // extract sub-patterns for passing to lex function
+                    $yysubmatches = array_slice($yysubmatches, $this->token + 1,
+                        $tokenMap[$this->token]);
+                } else {
+                    $yysubmatches = array();
+                }
+                $this->value = current($yymatches); // token value
+                $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
+                if ($r === null) {
+                    $this->N += strlen($this->value);
+                    $this->line += substr_count("\n", $this->value);
+                    // accept this token
+                    return true;
+                } elseif ($r === true) {
+                    // we have changed state
+                    // process this token in the new state
+                    return $this->yylex();
+                } elseif ($r === false) {
+                    $this->N += strlen($this->value);
+                    $this->line += substr_count("\n", $this->value);
+                    if ($this->N >= strlen($this->path)) {
+                        return false; // end of input
+                    }
+                    // skip this token
+                    continue;
+                } else {                    $yy_yymore_patterns = array(
+        1 => "^(\/?\\*\/?\\(([a-zA-Z0-9_]+)\\))|^(\/?:([a-zA-Z0-9_]+))|^(\/?\\*([a-zA-Z0-9_]+))|^(\/?([^\/:*]+))",
+        3 => "^(\/?:([a-zA-Z0-9_]+))|^(\/?\\*([a-zA-Z0-9_]+))|^(\/?([^\/:*]+))",
+        5 => "^(\/?\\*([a-zA-Z0-9_]+))|^(\/?([^\/:*]+))",
+        7 => "^(\/?([^\/:*]+))",
+        9 => "",
+    );
+
+                    // yymore is needed
+                    do {
+                        if (!strlen($yy_yymore_patterns[$this->token])) {
+                            throw new Exception('cannot do yymore for the last token');
+                        }
+                        if (preg_match($yy_yymore_patterns[$this->token],
+                              substr($this->path, $this->N), $yymatches)) {
+                            $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
+                            next($yymatches); // skip global match
+                            $this->token = key($yymatches); // token number
+                            $this->value = current($yymatches); // token value
+                            $this->line = substr_count("\n", $this->value);
+                        }
+                    } while ($this->{'yy_r1_' . $this->token}() !== null);
+                    // accept
+                    $this->N += strlen($this->value);
+                    $this->line += substr_count("\n", $this->value);
+                    return true;
+                }
+            } else {
+                throw new Exception('Unexpected input at line' . $this->line .
+                    ': ' . $this->path[$this->N]);
+            }
+            break;
+        } while (true);
+    } // end function
+
+
+    const START = 1;
+    function yy_r1_1($yy_subpatterns)
+    {
+
+    $c = $yy_subpatterns[0];
+    $part = self::createPart(Net_URL_Mapper_Part::DYNAMIC, $c, $this->value);
+    $this->addPart($part);
+    }
+    function yy_r1_3($yy_subpatterns)
+    {
+
+    $c = $yy_subpatterns[0];
+    $part = self::createPart(Net_URL_Mapper_Part::WILDCARD, $c, $this->value);
+    $this->addPart($part);
+    }
+    function yy_r1_5($yy_subpatterns)
+    {
+
+    $c = $yy_subpatterns[0];
+    $part = self::createPart(Net_URL_Mapper_Part::DYNAMIC, $c, $this->value);
+    $this->addPart($part);
+    }
+    function yy_r1_7($yy_subpatterns)
+    {
+
+    $c = $yy_subpatterns[0];
+    $part = self::createPart(Net_URL_Mapper_Part::WILDCARD, $c, $this->value);
+    $this->addPart($part);
+    }
+    function yy_r1_9($yy_subpatterns)
+    {
+
+    $c = $yy_subpatterns[0];
+    $part = self::createPart(Net_URL_Mapper_Part::FIXED, $c, $this->value);
+    $this->addPart($part);
+    }
+
+}
+
+?>
\ No newline at end of file
index 5f9827f9630f64f56ddbedf9008c522e5097b92f..634900dbf6a642f24923970de29ba029fe2d56da 100644 (file)
@@ -4,165 +4,9 @@ RewriteEngine On
 
 RewriteBase /mublog/
 
-RewriteRule ^$ index.php?action=public [L,QSA]
-RewriteRule ^rss$ index.php?action=publicrss [L,QSA]
-RewriteRule ^xrds$ index.php?action=publicxrds [L,QSA]
-RewriteRule ^featuredrss$ index.php?action=featuredrss [L,QSA]
-RewriteRule ^favoritedrss$ index.php?action=favoritedrss [L,QSA]
-RewriteRule ^opensearch/people$ index.php?action=opensearch&type=people [L,QSA]
-RewriteRule ^opensearch/notice$ index.php?action=opensearch&type=notice [L,QSA]
-
-RewriteRule ^doc/about$ index.php?action=doc&title=about [L,QSA]
-RewriteRule ^doc/contact$ index.php?action=doc&title=contact [L,QSA]
-RewriteRule ^doc/faq$ index.php?action=doc&title=faq [L,QSA]
-RewriteRule ^doc/help$ index.php?action=doc&title=help [L,QSA]
-RewriteRule ^doc/im$ index.php?action=doc&title=im [L,QSA]
-RewriteRule ^doc/openid$ index.php?action=doc&title=openid [L,QSA]
-RewriteRule ^doc/openmublog$ index.php?action=doc&title=openmublog [L,QSA]
-RewriteRule ^doc/privacy$ index.php?action=doc&title=privacy [L,QSA]
-RewriteRule ^doc/source$ index.php?action=doc&title=source [L,QSA]
-RewriteRule ^doc/tags$ index.php?action=doc&title=tags [L,QSA]
-RewriteRule ^doc/groups$ index.php?action=doc&title=groups [L,QSA]
-RewriteRule ^doc/sms$ index.php?action=doc&title=sms [L,QSA]
-
-RewriteRule ^facebook/$ index.php?action=facebookhome [L,QSA]
-RewriteRule ^facebook/index.php$ index.php?action=facebookhome [L,QSA]
-RewriteRule ^facebook/settings.php$ index.php?action=facebooksettings [L,QSA]
-RewriteRule ^facebook/invite.php$ index.php?action=facebookinvite [L,QSA]
-RewriteRule ^facebook/remove$ index.php?action=facebookremove [L,QSA]
-
-RewriteRule ^main/login$ index.php?action=login [L,QSA]
-RewriteRule ^main/logout$ index.php?action=logout [L,QSA]
-RewriteRule ^main/register/(.*)$ index.php?action=register&code=$1 [L,QSA]
-RewriteRule ^main/register$ index.php?action=register [L,QSA]
-RewriteRule ^main/openid$ index.php?action=openidlogin [L,QSA]
-RewriteRule ^main/remote$ index.php?action=remotesubscribe [L,QSA]
-
-RewriteRule ^main/subscribe$ index.php?action=subscribe [L,QSA]
-RewriteRule ^main/unsubscribe$ index.php?action=unsubscribe [L,QSA]
-RewriteRule ^main/confirmaddress$ index.php?action=confirmaddress [L,QSA]
-RewriteRule ^main/confirmaddress/(.*)$ index.php?action=confirmaddress&code=$1 [L,QSA]
-RewriteRule ^main/recoverpassword$ index.php?action=recoverpassword [L,QSA]
-RewriteRule ^main/recoverpassword/(.*)$ index.php?action=recoverpassword&code=$1 [L,QSA]
-RewriteRule ^main/invite$ index.php?action=invite [L,QSA]
-
-RewriteRule ^main/favor$ index.php?action=favor [L,QSA]
-RewriteRule ^main/disfavor$ index.php?action=disfavor [L,QSA]
-
-RewriteRule ^main/sup$ index.php?action=sup [L,QSA]
-
-RewriteRule ^main/tagother$ index.php?action=tagother [L,QSA]
-
-RewriteRule ^main/block$ index.php?action=block [L,QSA]
-
-RewriteRule ^settings/profile$ index.php?action=profilesettings [L,QSA]
-RewriteRule ^settings/avatar$ index.php?action=avatarsettings [L,QSA]
-RewriteRule ^settings/password$ index.php?action=passwordsettings [L,QSA]
-RewriteRule ^settings/openid$ index.php?action=openidsettings [L,QSA]
-RewriteRule ^settings/im$ index.php?action=imsettings [L,QSA]
-RewriteRule ^settings/email$ index.php?action=emailsettings [L,QSA]
-RewriteRule ^settings/sms$ index.php?action=smssettings [L,QSA]
-RewriteRule ^settings/twitter$ index.php?action=twittersettings [L,QSA]
-RewriteRule ^settings/other$ index.php?action=othersettings [L,QSA]
-
-RewriteRule ^search/group$ index.php?action=groupsearch [L,QSA]
-RewriteRule ^search/people$ index.php?action=peoplesearch [L,QSA]
-RewriteRule ^search/notice$ index.php?action=noticesearch [L,QSA]
-RewriteRule ^search/notice/rss$ index.php?action=noticesearchrss [L,QSA]
-
-RewriteRule ^notice/new$ index.php?action=newnotice [L,QSA]
-RewriteRule ^notice/(\d+)$ index.php?action=shownotice&notice=$1 [L,QSA]
-RewriteRule ^notice/delete/((\d+))?$ index.php?action=deletenotice&notice=$2 [L,QSA]
-RewriteRule ^notice/delete$ index.php?action=deletenotice [L,QSA]
-
-RewriteRule ^message/new$ index.php?action=newmessage [L,QSA]
-RewriteRule ^message/(\d+)$ index.php?action=showmessage&message=$1 [L,QSA]
-
-RewriteRule ^user/(\d+)$ index.php?action=userbyid&id=$1 [L,QSA]
-
-RewriteRule ^tags/?$ index.php?action=publictagcloud [L,QSA]
-RewriteRule ^tag/([a-zA-Z0-9]+)/rss$ index.php?action=tagrss&tag=$1 [L,QSA]
-RewriteRule ^tag(/(.*))?$ index.php?action=tag&tag=$2 [L,QSA]
-
-RewriteRule ^peopletag/([a-zA-Z0-9]+)$ index.php?action=peopletag&tag=$1 [L,QSA]
-
-RewriteRule ^featured/?$ index.php?action=featured [L,QSA]
-RewriteRule ^favorited/?$ index.php?action=favorited [L,QSA]
-
-RewriteRule ^group/new$ index.php?action=newgroup [L,QSA]
-RewriteRule ^group/([a-zA-Z0-9]+)/edit$ index.php?action=editgroup&nickname=$1 [L,QSA]
-RewriteRule ^group/([a-zA-Z0-9]+)/join$ index.php?action=joingroup&nickname=$1 [L,QSA]
-RewriteRule ^group/([a-zA-Z0-9]+)/leave$ index.php?action=leavegroup&nickname=$1 [L,QSA]
-RewriteRule ^group/([a-zA-Z0-9]+)/members$ index.php?action=groupmembers&nickname=$1 [L,QSA]
-RewriteRule ^group/([a-zA-Z0-9]+)/logo$ index.php?action=grouplogo&nickname=$1 [L,QSA]
-RewriteRule ^group/([0-9]+)/id$ index.php?action=groupbyid&id=$1 [L,QSA]
-RewriteRule ^group/([a-zA-Z0-9]+)/rss$ index.php?action=grouprss&nickname=$1 [L,QSA]
-RewriteRule ^group/([a-zA-Z0-9]+)$ index.php?action=showgroup&nickname=$1 [L,QSA]
-RewriteRule ^group$ index.php?action=groups [L,QSA]
-
-# Twitter-compatible API rewrites
-# XXX: Surely these can be refactored a little -- Zach
-RewriteRule ^api/statuses/public_timeline(.*)$ index.php?action=api&apiaction=statuses&method=public_timeline$1 [L,QSA]
-RewriteRule ^api/statuses/friends_timeline(.*)$ index.php?action=api&apiaction=statuses&method=friends_timeline$1 [L,QSA]
-RewriteRule ^api/statuses/user_timeline/(.*)$ index.php?action=api&apiaction=statuses&method=user_timeline&argument=$1 [L,QSA]
-RewriteRule ^api/statuses/user_timeline(.*)$ index.php?action=api&apiaction=statuses&method=user_timeline$1 [L,QSA]
-RewriteRule ^api/statuses/show/(.*)$ index.php?action=api&apiaction=statuses&method=show&argument=$1 [L,QSA]
-RewriteRule ^api/statuses/update(.*)$ index.php?action=api&apiaction=statuses&method=update$1 [L,QSA]
-RewriteRule ^api/statuses/replies(.*)$ index.php?action=api&apiaction=statuses&method=replies&argument=$1 [L,QSA]
-RewriteRule ^api/statuses/destroy/(.*)$ index.php?action=api&apiaction=statuses&method=destroy&argument=$1 [L,QSA]
-RewriteRule ^api/statuses/friends/(.*)$ index.php?action=api&apiaction=statuses&method=friends&argument=$1 [L,QSA]
-RewriteRule ^api/statuses/friends(.*)$ index.php?action=api&apiaction=statuses&method=friends$1 [L,QSA]
-RewriteRule ^api/statuses/followers/(.*)$ index.php?action=api&apiaction=statuses&method=followers&argument=$1 [L,QSA]
-RewriteRule ^api/statuses/followers(.*)$ index.php?action=api&apiaction=statuses&method=followers$1 [L,QSA]
-RewriteRule ^api/statuses/featured(.*)$ index.php?action=api&apiaction=statuses&method=featured$1 [L,QSA]
-RewriteRule ^api/users/show/(.*)$ index.php?action=api&apiaction=users&method=show&argument=$1 [L,QSA]
-RewriteRule ^api/users/show(.*)$ index.php?action=api&apiaction=users&method=show$1 [L,QSA]
-RewriteRule ^api/direct_messages/sent(.*)$ index.php?action=api&apiaction=direct_messages&method=sent$1 [L,QSA]
-RewriteRule ^api/direct_messages/destroy/(.*)$ index.php?action=api&apiaction=direct_messages&method=destroy&argument=$1 [L,QSA]
-RewriteRule ^api/direct_messages/new(.*)$ index.php?action=api&apiaction=direct_messages&method=create$1 [L,QSA]
-RewriteRule ^api/direct_messages(.*)$ index.php?action=api&apiaction=direct_messages&method=direct_messages$1 [L,QSA]
-RewriteRule ^api/friendships/create/(.*)$ index.php?action=api&apiaction=friendships&method=create&argument=$1 [L,QSA]
-RewriteRule ^api/friendships/destroy/(.*)$ index.php?action=api&apiaction=friendships&method=destroy&argument=$1 [L,QSA]
-RewriteRule ^api/friendships/exists(.*)$ index.php?action=api&apiaction=friendships&method=exists$1 [L,QSA]
-RewriteRule ^api/account/verify_credentials(.*)$ index.php?action=api&apiaction=account&method=verify_credentials$1 [L,QSA]
-RewriteRule ^api/account/end_session$ index.php?action=api&apiaction=account&method=end_session$1 [L,QSA]
-RewriteRule ^api/account/update_location(.*)$ index.php?action=api&apiaction=account&method=update_location$1 [L,QSA]
-RewriteRule ^api/account/update_delivery_device(.*)$ index.php?action=api&apiaction=account&method=update_delivery_device$1 [L,QSA]
-RewriteRule ^api/account/rate_limit_status(.*)$ index.php?action=api&apiaction=account&method=rate_limit_status$1 [L,QSA]
-RewriteRule ^api/favorites/create/(.*)$ index.php?action=api&apiaction=favorites&method=create&argument=$1 [L,QSA]
-RewriteRule ^api/favorites/destroy/(.*)$ index.php?action=api&apiaction=favorites&method=destroy&argument=$1 [L,QSA]
-RewriteRule ^api/favorites/(.*)$ index.php?action=api&apiaction=favorites&method=favorites&argument=$1 [L,QSA]
-RewriteRule ^api/favorites(.*)$ index.php?action=api&apiaction=favorites&method=favorites$1 [L,QSA]
-RewriteRule ^api/notifications/follow/(.*)$ index.php?action=api&apiaction=notifications&method=follow&argument=$1 [L,QSA]
-RewriteRule ^api/notifications/leave/(.*)$ index.php?action=api&apiaction=notifications&method=leave&argument=$1 [L,QSA]
-RewriteRule ^api/blocks/create/(.*)$ index.php?action=api&apiaction=blocks&method=create&argument=$1 [L,QSA]
-RewriteRule ^api/blocks/destroy/(.*)$ index.php?action=api&apiaction=blocks&method=destroy&argument=$1 [L,QSA]
-RewriteRule ^api/help/(.*)$ index.php?action=api&apiaction=help&method=$1 [L,QSA]
-RewriteRule ^api/laconica/version(.*)$ index.php?action=api&apiaction=laconica&method=version$1 [L,QSA]
-RewriteRule ^api/laconica/config(.*)$ index.php?action=api&apiaction=laconica&method=config$1 [L,QSA]
-RewriteRule ^api/laconica/wadl\.xml$ index.php?action=api&apiaction=laconica&method=wadl.xml [L,QSA]
-
-RewriteRule ^(\w+)/subscriptions$ index.php?action=subscriptions&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/subscriptions/([a-zA-Z0-9]+)$ index.php?action=subscriptions&nickname=$1&tag=$2 [L,QSA]
-RewriteRule ^(\w+)/subscribers/([a-zA-Z0-9]+)$ index.php?action=subscribers&nickname=$1&tag=$2 [L,QSA]
-RewriteRule ^(\w+)/subscribers$ index.php?action=subscribers&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/nudge$ index.php?action=nudge&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/xrds$ index.php?action=xrds&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/rss$ index.php?action=userrss&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/all$ index.php?action=all&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/all/rss$ index.php?action=allrss&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/foaf$ index.php?action=foaf&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/replies$ index.php?action=replies&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/replies/rss$ index.php?action=repliesrss&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/avatar/(original|96|48|24)$ index.php?action=avatarbynickname&nickname=$1&size=$2 [L,QSA]
-RewriteRule ^(\w+)/favorites$ index.php?action=showfavorites&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/favorites/rss$ index.php?action=favoritesrss&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/inbox$ index.php?action=inbox&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/outbox$ index.php?action=outbox&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/microsummary$ index.php?action=microsummary&nickname=$1 [L,QSA]
-RewriteRule ^(\w+)/groups$ index.php?action=usergroups&nickname=$1 [L,QSA]
-
-RewriteRule ^(\w+)$ index.php?action=showstream&nickname=$1 [L,QSA]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule (.*) index.php?p=$1 [L,QSA]
 
 <FilesMatch "\.(ini)">
   Order allow,deny
index e62d9469ab553924bc9d02aa24c5492bbf8b1a46..b180e2b653b285f2c54585d83d7558e170f7e74d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -22,69 +22,130 @@ define('LACONICA', true);
 
 require_once INSTALLDIR . '/lib/common.php';
 
-// XXX: we need a little more structure in this script
+$user = null;
+$action = null;
+
+function getPath($req)
+{
+    if (common_config('site', 'fancy')) {
+        return $req['p'];
+    } else if ($_SERVER['PATH_INFO']) {
+        return $_SERVER['PATH_INFO'];
+    } else {
+        return $req['p'];
+    }
+}
 
-// get and cache current user
+function handleError($error)
+{
+    if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
+        return;
+    }
 
-$user = common_current_user();
+    common_log(LOG_ERR, "PEAR error: " . $error->getMessage());
+    $msg = sprintf(_('The database for %s isn\'t responding correctly, '.
+                     'so the site won\'t work properly. '.
+                     'The site admins probably know about the problem, '.
+                     'but you can contact them at %s to make sure. '.
+                     'Otherwise, wait a few minutes and try again.'),
+                   common_config('site', 'name'),
+                   common_config('site', 'email'));
+
+    $dac = new DBErrorAction($msg, 500);
+    $dac->showPage();
+    exit(-1);
+}
 
-// initialize language env
+function main()
+{
+    global $user, $action;
 
-common_init_language();
+    // For database errors
 
-$action = $_REQUEST['action'];
+    PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError');
 
-if (!$action || !preg_match('/^[a-zA-Z0-9_-]*$/', $action)) {
-    common_redirect(common_local_url('public'));
-}
+    // XXX: we need a little more structure in this script
 
-// If the site is private, and they're not on one of the "public"
-// parts of the site, redirect to login
+    // get and cache current user
 
-if (!$user && common_config('site', 'private') &&
-    !in_array($action, array('login', 'openidlogin', 'finishopenidlogin',
-                             'recoverpassword', 'api', 'doc', 'register'))) {
-    common_redirect(common_local_url('login'));
-}
+    $user = common_current_user();
 
-$action_class = ucfirst($action).'Action';
+    // initialize language env
 
-if (!class_exists($action_class)) {
-    $cac = new ClientErrorAction(_('Unknown action'), 404);
-    $cac->showPage();
-} else {
-    $action_obj = new $action_class();
+    common_init_language();
 
-    // XXX: find somewhere for this little block to live
+    $path = getPath($_REQUEST);
 
-    if ($config['db']['mirror'] && $action_obj->isReadOnly()) {
-        if (is_array($config['db']['mirror'])) {
-            // "load balancing", ha ha
-            $k = array_rand($config['db']['mirror']);
+    $r = Router::get();
 
-            $mirror = $config['db']['mirror'][$k];
-        } else {
-            $mirror = $config['db']['mirror'];
-        }
-        $config['db']['database'] = $mirror;
+    $args = $r->map($path);
+
+    if (!$args) {
+        $cac = new ClientErrorAction(_('Unknown page'), 404);
+        $cac->showPage();
+        return;
     }
 
-    try {
-        if ($action_obj->prepare($_REQUEST)) {
-            $action_obj->handle($_REQUEST);
-        }
-    } catch (ClientException $cex) {
-        $cac = new ClientErrorAction($cex->getMessage(), $cex->getCode());
+    $args = array_merge($args, $_REQUEST);
+
+    $action = $args['action'];
+
+    if (!$action || !preg_match('/^[a-zA-Z0-9_-]*$/', $action)) {
+        common_redirect(common_local_url('public'));
+        return;
+    }
+
+    // If the site is private, and they're not on one of the "public"
+    // parts of the site, redirect to login
+
+    if (!$user && common_config('site', 'private') &&
+        !in_array($action, array('login', 'openidlogin', 'finishopenidlogin',
+                                 'recoverpassword', 'api', 'doc', 'register'))) {
+        common_redirect(common_local_url('login'));
+        return;
+    }
+
+    $action_class = ucfirst($action).'Action';
+
+    if (!class_exists($action_class)) {
+        $cac = new ClientErrorAction(_('Unknown action'), 404);
         $cac->showPage();
-    } catch (ServerException $sex) { // snort snort guffaw
-        $sac = new ServerErrorAction($sex->getMessage(), $sex->getCode());
-        $sac->showPage();
-    } catch (Exception $ex) {
-        $sac = new ServerErrorAction($ex->getMessage());
-        $sac->showPage();
+    } else {
+        $action_obj = new $action_class();
+
+        // XXX: find somewhere for this little block to live
+
+        if ($config['db']['mirror'] && $action_obj->isReadOnly()) {
+            if (is_array($config['db']['mirror'])) {
+                // "load balancing", ha ha
+                $k = array_rand($config['db']['mirror']);
+
+                $mirror = $config['db']['mirror'][$k];
+            } else {
+                $mirror = $config['db']['mirror'];
+            }
+            $config['db']['database'] = $mirror;
+        }
+
+        try {
+            if ($action_obj->prepare($args)) {
+                $action_obj->handle($args);
+            }
+        } catch (ClientException $cex) {
+            $cac = new ClientErrorAction($cex->getMessage(), $cex->getCode());
+            $cac->showPage();
+        } catch (ServerException $sex) { // snort snort guffaw
+            $sac = new ServerErrorAction($sex->getMessage(), $sex->getCode());
+            $sac->showPage();
+        } catch (Exception $ex) {
+            $sac = new ServerErrorAction($ex->getMessage());
+            $sac->showPage();
+        }
     }
 }
 
+main();
+
 // XXX: cleanup exit() calls or add an exit handler so
 // this always gets called
 
diff --git a/js/flowplayer-3.0.5.min.js b/js/flowplayer-3.0.5.min.js
new file mode 100644 (file)
index 0000000..b1c3315
--- /dev/null
@@ -0,0 +1,24 @@
+/** 
+ * 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 <http://www.gnu.org/licenses/>.
+ * 
+ * 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];i<length&&fn.call(value,i,value)!==false;value=obj[++i]){}}return obj;}function el(id){return document.getElementById(id);}function extend(to,from,skipFuncs){if(to&&from){each(from,function(name,value){if(!skipFuncs||typeof value!='function'){to[name]=value;}});}}function select(query){var index=query.indexOf(".");if(index!=-1){var tag=query.substring(0,index)||"*";var klass=query.substring(index+1,query.length);var els=[];each(document.getElementsByTagName(tag),function(){if(this.className&&this.className.indexOf(klass)!=-1){els.push(this);}});return els;}}function stopEvent(e){e=e||window.event;if(e.preventDefault){e.stopPropagation();e.preventDefault();}else{e.returnValue=false;e.cancelBubble=true;}return false;}function bind(to,evt,fn){to[evt]=to[evt]||[];to[evt].push(fn);}function makeId(){return"_"+(""+Math.random()).substring(2,10);}var Clip=function(json,index,player){var self=this;var cuepoints={};var listeners={};self.index=index;if(typeof json=='string'){json={url:json};}extend(this,json,true);each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var evt="on"+this;if(evt.indexOf("*")!=-1){evt=evt.substring(0,evt.length-1);var before="onBefore"+evt.substring(2);self[before]=function(fn){bind(listeners,before,fn);return self;};}self[evt]=function(fn){bind(listeners,evt,fn);return self;};if(index==-1){if(self[before]){player[before]=self[before];}if(self[evt]){player[evt]=self[evt];}}});extend(this,{onCuepoint:function(points,fn){if(arguments.length==1){cuepoints.embedded=[null,points];return self;}if(typeof points=='number'){points=[points];}var fnId=makeId();cuepoints[fnId]=[points,fn];if(player.isLoaded()){player._api().fp_addCuepoints(points,index,fnId);}return self;},update:function(json){extend(self,json);if(player.isLoaded()){player._api().fp_updateClip(json,index);}var conf=player.getConfig();var clip=(index==-1)?conf.clip:conf.playlist[index];extend(clip,json,true);},_fireEvent:function(evt,arg1,arg2,target){if(evt=='onLoad'){each(cuepoints,function(key,val){if(val[0]){player._api().fp_addCuepoints(val[0],index,key);}});return false;}target=target||self;if(evt=='onCuepoint'){var fn=cuepoints[arg1];if(fn){return fn[1].call(player,target,arg2);}}if(evt=='onStart'||evt=='onUpdate'){extend(target,arg1);if(!target.duration){target.duration=arg1.metaData.duration;}else{target.fullDuration=arg1.metaData.duration;}}var ret=true;each(listeners[evt],function(){ret=this.call(player,target,arg1,arg2);});return ret;}});if(json.onCuepoint){var arg=json.onCuepoint;self.onCuepoint.apply(self,typeof arg=='function'?[arg]:arg);delete json.onCuepoint;}each(json,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete json[key];}});if(index==-1){player.onCuepoint=this.onCuepoint;}};var Plugin=function(name,json,player,fn){var listeners={};var self=this;var hasMethods=false;if(fn){extend(listeners,fn);}each(json,function(key,val){if(typeof val=='function'){listeners[key]=val;delete json[key];}});extend(this,{animate:function(props,speed,fn){if(!props){return self;}if(typeof speed=='function'){fn=speed;speed=500;}if(typeof props=='string'){var key=props;props={};props[key]=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}if(speed===undefined){speed=500;}json=player._api().fp_animate(name,props,speed,fnId);return self;},css:function(props,val){if(val!==undefined){var css={};css[props]=val;props=css;}json=player._api().fp_css(name,props);extend(self,json);return self;},show:function(){this.display='block';player._api().fp_showPlugin(name);return self;},hide:function(){this.display='none';player._api().fp_hidePlugin(name);return self;},toggle:function(){this.display=player._api().fp_togglePlugin(name);return self;},fadeTo:function(o,speed,fn){if(typeof speed=='function'){fn=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}this.display=player._api().fp_fadeTo(name,o,speed,fnId);this.opacity=o;return self;},fadeIn:function(speed,fn){return self.fadeTo(1,speed,fn);},fadeOut:function(speed,fn){return self.fadeTo(0,speed,fn);},getName:function(){return name;},_fireEvent:function(evt,arg){if(evt=='onUpdate'){var json=player._api().fp_getPlugin(name);if(!json){return;}extend(self,json);delete self.methods;if(!hasMethods){each(json.methods,function(){var method=""+this;self[method]=function(){var a=[].slice.call(arguments);var ret=player._api().fp_invoke(name,method,a);return ret=='undefined'?self:ret;};});hasMethods=true;}}var fn=listeners[evt];if(fn){fn.call(self,arg);if(evt.substring(0,1)=="_"){delete listeners[evt];}}}});};function Player(wrapper,params,conf){var
+self=this,api=null,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,playerIndex,activeIndex,swfHeight,wrapperHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null);},getParent:function(){return wrapper;},hide:function(all){if(all){wrapper.style.height="0px";}if(api){api.style.height="0px";}return self;},show:function(){wrapper.style.height=wrapperHeight+"px";if(api){api.style.height=swfHeight+"px";}return self;},isHidden:function(){return api&&parseInt(api.style.height,10)===0;},load:function(fn){if(!api&&self._fireEvent("onBeforeLoad")!==false){each(players,function(){this.unload();});html=wrapper.innerHTML;flashembed(wrapper,params,{config:conf});if(fn){fn.cached=true;bind(listeners,"onLoad",fn);}}return self;},unload:function(){try{if(api&&api.fp_isFullscreen()){}}catch(error){return;}if(api&&html.replace(/\s/g,'')!==''&&!api.fp_isFullscreen()&&self._fireEvent("onBeforeUnload")!==false){api.fp_close();wrapper.innerHTML=html;self._fireEvent("onUnload");api=null;}return self;},getClip:function(index){if(index===undefined){index=activeIndex;}return playlist[index];},getCommonClip:function(){return commonClip;},getPlaylist:function(){return playlist;},getPlugin:function(name){var plugin=plugins[name];if(!plugin&&self.isLoaded()){var json=self._api().fp_getPlugin(name);if(json){plugin=new Plugin(name,json,self);plugins[name]=plugin;}}return plugin;},getScreen:function(){return self.getPlugin("screen");},getControls:function(){return self.getPlugin("controls");},getConfig:function(copy){return copy?clone(conf):conf;},getFlashParams:function(){return params;},loadPlugin:function(name,url,props,fn){if(typeof props=='function'){fn=props;props={};}var fnId=fn?makeId():"_";self._api().fp_loadPlugin(name,url,props,fnId);var arg={};arg[fnId]=fn;var p=new Plugin(name,null,self,arg);plugins[name]=p;return p;},getState:function(){return api?api.fp_getState():-1;},play:function(clip){function play(){if(clip!==undefined){self._api().fp_play(clip);}else{self._api().fp_play();}}if(api){play();}else{self.load(function(){play();});}return self;},getVersion:function(){var js="flowplayer.js 3.0.5";if(api){var ver=api.fp_getVersion();ver.push(js);return ver;}return js;},_api:function(){if(!api){throw"Flowplayer "+self.id()+" not loaded. Try moving your call to player's onLoad event";}return api;},_dump:function(){console.log(listeners);},setClip:function(clip){self.setPlaylist([clip]);},getIndex:function(){return playerIndex;}});each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","),function(){var name="on"+this;if(name.indexOf("*")!=-1){name=name.substring(0,name.length-1);var name2="onBefore"+name.substring(2);self[name2]=function(fn){bind(listeners,name2,fn);return self;};}self[name]=function(fn){bind(listeners,name,fn);return self;};});each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset,close,setPlaylist").split(","),function(){var name=this;self[name]=function(arg){if(!api){return self;}var ret=(arg===undefined)?api["fp_"+name]():api["fp_"+name](arg);return ret=='undefined'?self:ret;};});self._fireEvent=function(evt,arg0,arg1,arg2){if(conf.debug){log(arguments);}if(!api&&evt=='onLoad'&&arg0=='player'){api=api||el(apiId);swfHeight=api.clientHeight;each(playlist,function(){this._fireEvent("onLoad");});each(plugins,function(name,p){p._fireEvent("onUpdate");});commonClip._fireEvent("onLoad");}if(evt=='onLoad'&&arg0!='player'){return;}if(evt=='onError'){if(typeof arg0=='string'||(typeof arg0=='number'&&typeof arg1=='number')){arg0=arg1;arg1=arg2;}}if(evt=='onContextMenu'){each(conf.contextMenu[arg0],function(key,fn){fn.call(self);});return;}if(evt=='onPluginEvent'){var name=arg0.name||arg0;var p=plugins[name];if(p){p._fireEvent("onUpdate",arg0);p._fireEvent(arg1);}return;}if(evt=='onPlaylistReplace'){playlist=[];var index=0;each(arg0,function(){playlist.push(new Clip(this,index++,self));});}var ret=true;if(typeof arg0=='number'&&arg0<playlist.length){activeIndex=arg0;var clip=playlist[arg0];if(clip){ret=clip._fireEvent(evt,arg1,arg2);}if(!clip||ret!==false){ret=commonClip._fireEvent(evt,arg1,arg2,clip);}}var i=0;each(listeners[evt],function(){ret=this.call(self,arg0,arg1);if(this.cached){listeners[evt].splice(i,1);}if(ret===false){return false;}i++;});return ret;};function init(){if($f(wrapper)){$f(wrapper).getParent().innerHTML="";playerIndex=$f(wrapper).getIndex();players[playerIndex]=self;}else{players.push(self);playerIndex=players.length-1;}wrapperHeight=parseInt(wrapper.style.height,10)||wrapper.clientHeight;if(typeof params=='string'){params={src:params};}playerId=wrapper.id||"fp"+makeId();apiId=params.id||playerId+"_api";params.id=apiId;conf.playerId=playerId;if(typeof conf=='string'){conf={clip:{url:conf}};}if(typeof conf.clip=='string'){conf.clip={url:conf.clip};}conf.clip=conf.clip||{};if(wrapper.getAttribute("href",2)&&!conf.clip.url){conf.clip.url=wrapper.getAttribute("href",2);}commonClip=new Clip(conf.clip,-1,self);conf.playlist=conf.playlist||[conf.clip];var index=0;each(conf.playlist,function(){var clip=this;if(typeof clip=='object'&&clip.length){clip=""+clip;}if(typeof clip=='string'){clip={url:clip};}each(conf.clip,function(key,val){if(conf.clip[key]!==undefined&&typeof val!='function'){clip[key]=val;}});conf.playlist[index]=clip;clip=new Clip(clip,index,self);playlist.push(clip);index++;});each(conf,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete conf[key];}});each(conf.plugins,function(name,val){if(val){plugins[name]=new Plugin(name,val,self);}});if(!conf.plugins||conf.plugins.controls===undefined){plugins.controls=new Plugin("controls",null,self);}params.bgcolor=params.bgcolor||"#000000";params.version=params.version||[9,0];params.expressInstall='http://www.flowplayer.org/swf/expressinstall.swf';function doClick(e){if(!self.isLoaded()&&self._fireEvent("onBeforeClick")!==false){self.load();}return stopEvent(e);}html=wrapper.innerHTML;if(html.replace(/\s/g,'')!==''){if(wrapper.addEventListener){wrapper.addEventListener("click",doClick,false);}else if(wrapper.attachEvent){wrapper.attachEvent("onclick",doClick);}}else{if(wrapper.addEventListener){wrapper.addEventListener("click",stopEvent,false);}self.load();}}if(typeof wrapper=='string'){flashembed.domReady(function(){var node=el(wrapper);if(!node){throw"Flowplayer cannot access element: "+wrapper;}else{wrapper=node;init();}});}else{init();}}var players=[];function Iterator(arr){this.length=arr.length;this.each=function(fn){each(arr,fn);};this.size=function(){return arr.length;};}window.flowplayer=window.$f=function(){var instance=null;var arg=arguments[0];if(!arguments.length){each(players,function(){if(this.isLoaded()){instance=this;return false;}});return instance||players[0];}if(arguments.length==1){if(typeof arg=='number'){return players[arg];}else{if(arg=='*'){return new Iterator(players);}each(players,function(){if(this.id()==arg.id||this.id()==arg||this.getParent()==arg){instance=this;return false;}});return instance;}}if(arguments.length>1){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<domReady.ready.length;i++){domReady.ready[i].call();}domReady.ready=null;domReady.done=true;}}var domReady=jQ?jQuery:function(f){if(domReady.done){return f();}if(domReady.timer){domReady.ready.push(f);}else{domReady.ready=[f];domReady.timer=setInterval(isDomReady,13);}};function extend(to,from){if(from){for(key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}}return to;}function asString(obj){switch(typeOf(obj)){case'string':obj=obj.replace(new RegExp('(["\\\\])','g'),'\\$1');obj=obj.replace(/^\s?(\d+)%/,"$1pct");return'"'+obj+'"';case'array':return'['+map(obj,function(el){return asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+asString(obj[prop]));}}return'{'+str.join(',')+'}';}return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");}function typeOf(obj){if(obj===null||obj===undefined){return false;}var type=typeof obj;return(type=='object'&&obj.push)?'array':type;}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});}function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}}return newArr;}function getHTML(p,c){var ie=document.all;var html='<object width="'+p.width+'" height="'+p.height+'"';if(ie&&!p.id){p.id="_"+(""+Math.random()).substring(9);}if(p.id){html+=' id="'+p.id+'"';}if(p.w3c||!ie){html+=' data="'+p.src+'" type="application/x-shockwave-flash"';}else{html+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';}html+='>';if(p.w3c||ie){html+='<param name="movie" value="'+p.src+'" />';}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+='<param name="'+k+'" value="'+e[k]+'" />';}}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+='<param name="flashvars" value=\''+vars+'\' />';}html+="</object>";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="<h2>Flash version "+required+" or greater is required</h2>"+"<h3>"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>";}}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
new file mode 100644 (file)
index 0000000..b5ad5c2
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * 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(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?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:\'<a 2j="2h" 2f="2e"></a>\',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=$(\'<x 2d="2c:K;"/>\').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
new file mode 100644 (file)
index 0000000..936a631
--- /dev/null
@@ -0,0 +1,9 @@
+$('document').ready(function() {
+    $('a.media, a.mediamp3').append(' <sup>[PLAY]</sup>');
+    $('a.mediamp3').html('').css('display', 'block').css('width', '224px').css('height','24px').flowplayer('../bin/flowplayer-3.0.5.swf');
+    $('a.media').click(function() {
+        $('<a id="p1i"></a>').attr('href', $(this).attr('href')).flowplayer('../bin/flowplayer-3.0.5.swf').modal({'closeHTML':'<a class="modalCloseImg" title="Close"><img src="x.png" /></a>'});
+        return false;
+    });
+});
+
index 3e236d7146ba82675de08ba7dc007b4d8fe3e251..8ff9e646b8cb769e3c60bc4bdde2e99af07c9daa 100644 (file)
@@ -151,31 +151,45 @@ class Action extends HTMLOutputter // lawsuit
      */
     function showStylesheets()
     {
-        $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/display.css', null) . '?version=' . LACONICA_VERSION,
-                                     'media' => 'screen, projection, tv'));
-        $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
-                       'href="'.theme_path('css/ie.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
-        foreach (array(6,7) as $ver) {
-            if (file_exists(theme_file('css/ie'.$ver.'.css', 'base'))) {
-                // Yes, IE people should be put in jail.
-                $this->comment('[if lte IE '.$ver.']><link rel="stylesheet" type="text/css" '.
-                               'href="'.theme_path('css/ie'.$ver.'.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
+        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,
+                                             'media' => 'screen, projection, tv'));
+                if (common_config('site', 'mobile')) {
+                    $this->element('link', array('rel' => 'stylesheet',
+                                                 'type' => 'text/css',
+                                                 'href' => theme_path('css/mobile.css', 'base') . '?version=' . LACONICA_VERSION,
+                                                 // TODO: "handheld" CSS for other mobile devices
+                                                 'media' => 'only screen and (max-device-width: 480px)')); // Mobile WebKit
+                }
+                Event::handle('EndShowLaconicaStyles', array($this));
             }
-        }
-        $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
-                       'href="'.theme_path('css/ie.css', null).'?version='.LACONICA_VERSION.'" /><![endif]');
-        if (common_config('site', 'mobile')) {
-            $this->element('link', array('rel' => 'stylesheet',
-                                         'type' => 'text/css',
-                                         'href' => theme_path('css/mobile.css', 'base') . '?version=' . LACONICA_VERSION,
-                                         // TODO: "handheld" CSS for other mobile devices
-                                         'media' => 'only screen and (max-device-width: 480px)')); // Mobile WebKit
+            if (Event::handle('StartShowUAStyles', array($this))) {
+                $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
+                               'href="'.theme_path('css/ie.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
+                foreach (array(6,7) as $ver) {
+                    if (file_exists(theme_file('css/ie'.$ver.'.css', 'base'))) {
+                        // Yes, IE people should be put in jail.
+                        $this->comment('[if lte IE '.$ver.']><link rel="stylesheet" type="text/css" '.
+                                       'href="'.theme_path('css/ie'.$ver.'.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
+                    }
+                }
+                $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
+                               'href="'.theme_path('css/ie.css', null).'?version='.LACONICA_VERSION.'" /><![endif]');
+                Event::handle('EndShowUAStyles', array($this));
+            }
+            Event::handle('EndShowStyles', array($this));
         }
     }
 
@@ -194,6 +208,13 @@ 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))) {
@@ -203,6 +224,18 @@ class Action extends HTMLOutputter // lawsuit
                 $this->element('script', array('type' => 'text/javascript',
                                                'src' => common_path('js/util.js?version='.LACONICA_VERSION)),
                                ' ');
+
+
+                $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));
@@ -232,9 +265,19 @@ class Action extends HTMLOutputter // lawsuit
      *
      * @return nothing
      */
+
     function showFeeds()
     {
-        // does nothing by default
+        $feeds = $this->getFeeds();
+
+        if ($feeds) {
+            foreach ($feeds as $feed) {
+                $this->element('link', array('rel' => $feed->rel(),
+                                             'href' => $feed->url,
+                                             'type' => $feed->mimeType(),
+                                             'title' => $feed->title));
+            }
+        }
     }
 
     /**
@@ -272,9 +315,15 @@ class Action extends HTMLOutputter // lawsuit
     {
         $this->elementStart('body', array('id' => $this->trimmed('action')));
         $this->elementStart('div', array('id' => 'wrap'));
-        $this->showHeader();
+        if (Event::handle('StartShowHeader', array($this))) {
+            $this->showHeader();
+            Event::handle('EndShowHeader', array($this));
+        }
         $this->showCore();
-        $this->showFooter();
+        if (Event::handle('StartShowFooter', array($this))) {
+            $this->showFooter();
+            Event::handle('EndShowFooter', array($this));
+        }
         $this->elementEnd('div');
         $this->elementEnd('body');
     }
@@ -429,7 +478,10 @@ class Action extends HTMLOutputter // lawsuit
     {
         $this->elementStart('div', array('id' => 'core'));
         $this->showLocalNavBlock();
-        $this->showContentBlock();
+        if (Event::handle('StartShowContentBlock', array($this))) {
+            $this->showContentBlock();
+            Event::handle('EndShowContentBlock', array($this));
+        }
         $this->showAside();
         $this->elementEnd('div');
     }
@@ -547,15 +599,16 @@ class Action extends HTMLOutputter // lawsuit
     /**
      * Show export data feeds.
      *
-     * MAY overload if there are feeds
-     *
-     * @return nothing
+     * @return void
      */
+
     function showExportData()
     {
-        // is there structure to this?
-        // list of (visible!) feed links
-        // can we reuse list of feeds from showFeeds() ?
+        $feeds = $this->getFeeds();
+        if ($feeds) {
+            $fl = new FeedList($this);
+            $fl->show($feeds);
+        }
     }
 
     /**
@@ -931,4 +984,17 @@ class Action extends HTMLOutputter // lawsuit
             $this->elementEnd('div');
         }
     }
+
+    /**
+     * An array of feeds for this action.
+     *
+     * Returns an array of potential feeds for this action.
+     *
+     * @return array Feed object to show in head and links
+     */
+
+    function getFeeds()
+    {
+        return null;
+    }
 }
diff --git a/lib/channel.php b/lib/channel.php
new file mode 100644 (file)
index 0000000..f1e2055
--- /dev/null
@@ -0,0 +1,237 @@
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, Controlez-Vous, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('LACONICA')) { exit(1); }
+
+class Channel
+{
+    function on($user)
+    {
+        return false;
+    }
+
+    function off($user)
+    {
+        return false;
+    }
+
+    function output($user, $text)
+    {
+        return false;
+    }
+
+    function error($user, $text)
+    {
+        return false;
+    }
+
+    function source()
+    {
+        return null;
+    }
+}
+
+class XMPPChannel extends Channel
+{
+
+    var $conn = null;
+
+    function source()
+    {
+        return 'xmpp';
+    }
+
+    function __construct($conn)
+    {
+        $this->conn = $conn;
+    }
+
+    function on($user)
+    {
+        return $this->set_notify($user, 1);
+    }
+
+    function off($user)
+    {
+        return $this->set_notify($user, 0);
+    }
+
+    function output($user, $text)
+    {
+        $text = '['.common_config('site', 'name') . '] ' . $text;
+        jabber_send_message($user->jabber, $text);
+    }
+
+    function error($user, $text)
+    {
+        $text = '['.common_config('site', 'name') . '] ' . $text;
+        jabber_send_message($user->jabber, $text);
+    }
+
+    function set_notify(&$user, $notify)
+    {
+        $orig = clone($user);
+        $user->jabbernotify = $notify;
+        $result = $user->update($orig);
+        if (!$result) {
+            $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
+            common_log(LOG_ERR,
+                       'Could not set notify flag to ' . $notify .
+                       ' for user ' . common_log_objstring($user) .
+                       ': ' . $last_error->message);
+            return false;
+        } else {
+            common_log(LOG_INFO,
+                       'User ' . $user->nickname . ' set notify flag to ' . $notify);
+            return true;
+        }
+    }
+}
+
+class WebChannel extends Channel
+{
+    var $out = null;
+
+    function __construct($out=null)
+    {
+        $this->out = $out;
+    }
+
+    function source()
+    {
+        return 'web';
+    }
+
+    function on($user)
+    {
+        return false;
+    }
+
+    function off($user)
+    {
+        return false;
+    }
+
+    function output($user, $text)
+    {
+        # XXX: buffer all output and send it at the end
+        # XXX: even better, redirect to appropriate page
+        #      depending on what command was run
+        $this->out->startHTML();
+        $this->out->elementStart('head');
+        $this->out->element('title', null, _('Command results'));
+        $this->out->elementEnd('head');
+        $this->out->elementStart('body');
+        $this->out->element('p', array('id' => 'command_result'), $text);
+        $this->out->elementEnd('body');
+        $this->out->endHTML();
+    }
+
+    function error($user, $text)
+    {
+        common_user_error($text);
+    }
+}
+
+class AjaxWebChannel extends WebChannel
+{
+    function output($user, $text)
+    {
+        $this->out->startHTML('text/xml;charset=utf-8');
+        $this->out->elementStart('head');
+        $this->out->element('title', null, _('Command results'));
+        $this->out->elementEnd('head');
+        $this->out->elementStart('body');
+        $this->out->element('p', array('id' => 'command_result'), $text);
+        $this->out->elementEnd('body');
+        $this->out->endHTML();
+    }
+
+    function error($user, $text)
+    {
+        $this->out->startHTML('text/xml;charset=utf-8');
+        $this->out->elementStart('head');
+        $this->out->element('title', null, _('Ajax Error'));
+        $this->out->elementEnd('head');
+        $this->out->elementStart('body');
+        $this->out->element('p', array('id' => 'error'), $text);
+        $this->out->elementEnd('body');
+        $this->out->endHTML();
+    }
+}
+
+class MailChannel extends Channel
+{
+
+    var $addr = null;
+
+    function source()
+    {
+        return 'mail';
+    }
+
+    function __construct($addr=null)
+    {
+        $this->addr = $addr;
+    }
+
+    function on($user)
+    {
+        return $this->set_notify($user, 1);
+    }
+
+    function off($user)
+    {
+        return $this->set_notify($user, 0);
+    }
+
+    function output($user, $text)
+    {
+
+        $headers['From'] = $user->incomingemail;
+        $headers['To'] = $this->addr;
+
+        $headers['Subject'] = _('Command complete');
+
+        return mail_send(array($this->addr), $headers, $text);
+    }
+
+    function error($user, $text)
+    {
+
+        $headers['From'] = $user->incomingemail;
+        $headers['To'] = $this->addr;
+
+        $headers['Subject'] = _('Command failed');
+
+        return mail_send(array($this->addr), $headers, $text);
+    }
+
+    function set_notify($user, $value)
+    {
+        $orig = clone($user);
+        $user->smsnotify = $value;
+        $result = $user->update($orig);
+        if (!$result) {
+            common_log_db_error($user, 'UPDATE', __FILE__);
+            return false;
+        }
+        return true;
+    }
+}
diff --git a/lib/command.php b/lib/command.php
new file mode 100644 (file)
index 0000000..507990a
--- /dev/null
@@ -0,0 +1,419 @@
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, Controlez-Vous, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('LACONICA')) { exit(1); }
+
+require_once(INSTALLDIR.'/lib/channel.php');
+
+class Command
+{
+
+    var $user = null;
+
+    function __construct($user=null)
+    {
+        $this->user = $user;
+    }
+
+    function execute($channel)
+    {
+        return false;
+    }
+}
+
+class UnimplementedCommand extends Command
+{
+    function execute($channel)
+    {
+        $channel->error($this->user, _("Sorry, this command is not yet implemented."));
+    }
+}
+
+class TrackingCommand extends UnimplementedCommand
+{
+}
+
+class TrackOffCommand extends UnimplementedCommand
+{
+}
+
+class TrackCommand extends UnimplementedCommand
+{
+    var $word = null;
+    function __construct($user, $word)
+    {
+        parent::__construct($user);
+        $this->word = $word;
+    }
+}
+
+class UntrackCommand extends UnimplementedCommand
+{
+    var $word = null;
+    function __construct($user, $word)
+    {
+        parent::__construct($user);
+        $this->word = $word;
+    }
+}
+
+class NudgeCommand extends UnimplementedCommand
+{
+    var $other = null;
+    function __construct($user, $other)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+}
+
+class InviteCommand extends UnimplementedCommand
+{
+    var $other = null;
+    function __construct($user, $other)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+}
+
+class StatsCommand extends Command
+{
+    function execute($channel)
+    {
+
+        $subs = new Subscription();
+        $subs->subscriber = $this->user->id;
+        $subs_count = (int) $subs->count() - 1;
+
+        $subbed = new Subscription();
+        $subbed->subscribed = $this->user->id;
+        $subbed_count = (int) $subbed->count() - 1;
+
+        $notices = new Notice();
+        $notices->profile_id = $this->user->id;
+        $notice_count = (int) $notices->count();
+
+        $channel->output($this->user, sprintf(_("Subscriptions: %1\$s\n".
+                                   "Subscribers: %2\$s\n".
+                                   "Notices: %3\$s"),
+                                 $subs_count,
+                                 $subbed_count,
+                                 $notice_count));
+    }
+}
+
+class FavCommand extends Command
+{
+
+    var $other = null;
+
+    function __construct($user, $other)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+
+    function execute($channel)
+    {
+
+        $recipient =
+          common_relative_profile($this->user, common_canonical_nickname($this->other));
+
+        if (!$recipient) {
+            $channel->error($this->user, _('No such user.'));
+            return;
+        }
+        $notice = $recipient->getCurrentNotice();
+        if (!$notice) {
+            $channel->error($this->user, _('User has no last notice'));
+            return;
+        }
+
+        $fave = Fave::addNew($this->user, $notice);
+
+        if (!$fave) {
+            $channel->error($this->user, _('Could not create favorite.'));
+            return;
+        }
+
+        $other = User::staticGet('id', $recipient->id);
+
+        if ($other && $other->id != $user->id) {
+            if ($other->email && $other->emailnotifyfav) {
+                mail_notify_fave($other, $this->user, $notice);
+            }
+        }
+
+        $this->user->blowFavesCache();
+
+        $channel->output($this->user, _('Notice marked as fave.'));
+    }
+}
+
+class WhoisCommand extends Command
+{
+    var $other = null;
+    function __construct($user, $other)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+
+    function execute($channel)
+    {
+        $recipient =
+          common_relative_profile($this->user, common_canonical_nickname($this->other));
+
+        if (!$recipient) {
+            $channel->error($this->user, _('No such user.'));
+            return;
+        }
+
+        $whois = sprintf(_("%1\$s (%2\$s)"), $recipient->nickname,
+                         $recipient->profileurl);
+        if ($recipient->fullname) {
+            $whois .= "\n" . sprintf(_('Fullname: %s'), $recipient->fullname);
+        }
+        if ($recipient->location) {
+            $whois .= "\n" . sprintf(_('Location: %s'), $recipient->location);
+        }
+        if ($recipient->homepage) {
+            $whois .= "\n" . sprintf(_('Homepage: %s'), $recipient->homepage);
+        }
+        if ($recipient->bio) {
+            $whois .= "\n" . sprintf(_('About: %s'), $recipient->bio);
+        }
+        $channel->output($this->user, $whois);
+    }
+}
+
+class MessageCommand extends Command
+{
+    var $other = null;
+    var $text = null;
+    function __construct($user, $other, $text)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+        $this->text = $text;
+    }
+
+    function execute($channel)
+    {
+        $other = User::staticGet('nickname', common_canonical_nickname($this->other));
+        $len = mb_strlen($this->text);
+        if ($len == 0) {
+            $channel->error($this->user, _('No content!'));
+            return;
+        } else if ($len > 140) {
+            $content = common_shorten_links($content);
+            if (mb_strlen($content) > 140) {
+                $channel->error($this->user, sprintf(_('Message too long - maximum is 140 characters, you sent %d'), $len));
+                return;
+            }
+        }
+
+        if (!$other) {
+            $channel->error($this->user, _('No such user.'));
+            return;
+        } else if (!$this->user->mutuallySubscribed($other)) {
+            $channel->error($this->user, _('You can\'t send a message to this user.'));
+            return;
+        } else if ($this->user->id == $other->id) {
+            $channel->error($this->user, _('Don\'t send a message to yourself; just say it to yourself quietly instead.'));
+            return;
+        }
+        $message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
+        if ($message) {
+            $channel->output($this->user, sprintf(_('Direct message to %s sent'), $this->other));
+        } else {
+            $channel->error($this->user, _('Error sending direct message.'));
+        }
+    }
+}
+
+class GetCommand extends Command
+{
+
+    var $other = null;
+
+    function __construct($user, $other)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+
+    function execute($channel)
+    {
+        $target_nickname = common_canonical_nickname($this->other);
+
+        $target =
+          common_relative_profile($this->user, $target_nickname);
+
+        if (!$target) {
+            $channel->error($this->user, _('No such user.'));
+            return;
+        }
+        $notice = $target->getCurrentNotice();
+        if (!$notice) {
+            $channel->error($this->user, _('User has no last notice'));
+            return;
+        }
+        $notice_content = $notice->content;
+
+        $channel->output($this->user, $target_nickname . ": " . $notice_content);
+    }
+}
+
+class SubCommand extends Command
+{
+
+    var $other = null;
+
+    function __construct($user, $other)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+
+    function execute($channel)
+    {
+
+        if (!$this->other) {
+            $channel->error($this->user, _('Specify the name of the user to subscribe to'));
+            return;
+        }
+
+        $result = subs_subscribe_user($this->user, $this->other);
+
+        if ($result == 'true') {
+            $channel->output($this->user, sprintf(_('Subscribed to %s'), $this->other));
+        } else {
+            $channel->error($this->user, $result);
+        }
+    }
+}
+
+class UnsubCommand extends Command
+{
+
+    var $other = null;
+
+    function __construct($user, $other)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+
+    function execute($channel)
+    {
+        if(!$this->other) {
+            $channel->error($this->user, _('Specify the name of the user to unsubscribe from'));
+            return;
+        }
+
+        $result=subs_unsubscribe_user($this->user, $this->other);
+
+        if ($result) {
+            $channel->output($this->user, sprintf(_('Unsubscribed from %s'), $this->other));
+        } else {
+            $channel->error($this->user, $result);
+        }
+    }
+}
+
+class OffCommand extends Command
+{
+    var $other = null;
+    function __construct($user, $other=null)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+    function execute($channel)
+    {
+        if ($other) {
+            $channel->error($this->user, _("Command not yet implemented."));
+        } else {
+            if ($channel->off($this->user)) {
+                $channel->output($this->user, _('Notification off.'));
+            } else {
+                $channel->error($this->user, _('Can\'t turn off notification.'));
+            }
+        }
+    }
+}
+
+class OnCommand extends Command
+{
+    var $other = null;
+    function __construct($user, $other=null)
+    {
+        parent::__construct($user);
+        $this->other = $other;
+    }
+
+    function execute($channel)
+    {
+        if ($other) {
+            $channel->error($this->user, _("Command not yet implemented."));
+        } else {
+            if ($channel->on($this->user)) {
+                $channel->output($this->user, _('Notification on.'));
+            } else {
+                $channel->error($this->user, _('Can\'t turn on notification.'));
+            }
+        }
+    }
+}
+
+class HelpCommand extends Command
+{
+    function execute($channel)
+    {
+        $channel->output($this->user,
+                         _("Commands:\n".
+                           "on - turn on notifications\n".
+                           "off - turn off notifications\n".
+                           "help - show this help\n".
+                           "follow <nickname> - subscribe to user\n".
+                           "leave <nickname> - unsubscribe from user\n".
+                           "d <nickname> <text> - direct message to user\n".
+                           "get <nickname> - get last notice from user\n".
+                           "whois <nickname> - get profile info on user\n".
+                           "fav <nickname> - add user's last notice as a 'fave'\n".
+                           "stats - get your stats\n".
+                           "stop - same as 'off'\n".
+                           "quit - same as 'off'\n".
+                           "sub <nickname> - same as 'follow'\n".
+                           "unsub <nickname> - same as 'leave'\n".
+                           "last <nickname> - same as 'get'\n".
+                           "on <nickname> - not yet implemented.\n".
+                           "off <nickname> - not yet implemented.\n".
+                           "nudge <nickname> - not yet implemented.\n".
+                           "invite <phone number> - not yet implemented.\n".
+                           "track <word> - not yet implemented.\n".
+                           "untrack <word> - not yet implemented.\n".
+                           "track off - not yet implemented.\n".
+                           "untrack all - not yet implemented.\n".
+                           "tracks - not yet implemented.\n".
+                           "tracking - not yet implemented.\n"));
+    }
+}
diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php
new file mode 100644 (file)
index 0000000..49c733c
--- /dev/null
@@ -0,0 +1,197 @@
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, Controlez-Vous, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('LACONICA')) { exit(1); }
+
+require_once INSTALLDIR.'/lib/command.php';
+
+class CommandInterpreter
+{
+    function handle_command($user, $text)
+    {
+        # XXX: localise
+
+        $text = preg_replace('/\s+/', ' ', trim($text));
+        list($cmd, $arg) = explode(' ', $text, 2);
+
+        # We try to support all the same commands as Twitter, see
+        # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands
+        # There are a few compatibility commands from earlier versions of
+        # Laconica
+
+        switch(strtolower($cmd)) {
+         case 'help':
+            if ($arg) {
+                return null;
+            }
+            return new HelpCommand($user);
+         case 'on':
+            if ($arg) {
+                list($other, $extra) = explode(' ', $arg, 2);
+                if ($extra) {
+                    return null;
+                } else {
+                    return new OnCommand($user, $other);
+                }
+            } else {
+                return new OnCommand($user);
+            }
+         case 'off':
+            if ($arg) {
+                list($other, $extra) = explode(' ', $arg, 2);
+                if ($extra) {
+                    return null;
+                } else {
+                    return new OffCommand($user, $other);
+                }
+            } else {
+                return new OffCommand($user);
+            }
+         case 'stop':
+         case 'quit':
+            if ($arg) {
+                return null;
+            } else {
+                return new OffCommand($user);
+            }
+         case 'follow':
+         case 'sub':
+            if (!$arg) {
+                return null;
+            }
+            list($other, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else {
+                return new SubCommand($user, $other);
+            }
+         case 'leave':
+         case 'unsub':
+            if (!$arg) {
+                return null;
+            }
+            list($other, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else {
+                return new UnsubCommand($user, $other);
+            }
+         case 'get':
+         case 'last':
+            if (!$arg) {
+                return null;
+            }
+            list($other, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else {
+                return new GetCommand($user, $other);
+            }
+         case 'd':
+         case 'dm':
+            if (!$arg) {
+                return null;
+            }
+            list($other, $extra) = explode(' ', $arg, 2);
+            if (!$extra) {
+                return null;
+            } else {
+                return new MessageCommand($user, $other, $extra);
+            }
+         case 'whois':
+            if (!$arg) {
+                return null;
+            }
+            list($other, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else {
+                return new WhoisCommand($user, $other);
+            }
+         case 'fav':
+            if (!$arg) {
+                return null;
+            }
+            list($other, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else {
+                return new FavCommand($user, $other);
+            }
+         case 'nudge':
+            if (!$arg) {
+                return null;
+            }
+            list($other, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else {
+                return new NudgeCommand($user, $other);
+            }
+         case 'stats':
+            if ($arg) {
+                return null;
+            }
+            return new StatsCommand($user);
+         case 'invite':
+            if (!$arg) {
+                return null;
+            }
+            list($other, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else {
+                return new InviteCommand($user, $other);
+            }
+         case 'track':
+            if (!$arg) {
+                return null;
+            }
+            list($word, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else if ($word == 'off') {
+                return new TrackOffCommand($user);
+            } else {
+                return new TrackCommand($user, $word);
+            }
+         case 'untrack':
+            if (!$arg) {
+                return null;
+            }
+            list($word, $extra) = explode(' ', $arg, 2);
+            if ($extra) {
+                return null;
+            } else if ($word == 'all') {
+                return new TrackOffCommand($user);
+            } else {
+                return new UntrackCommand($user, $word);
+            }
+         case 'tracks':
+         case 'tracking':
+            if ($arg) {
+                return null;
+            }
+            return new TrackingCommand($user);
+         default:
+            return false;
+        }
+    }
+}
+
index 7bfd14c4291517b9f0d31663dc0e18381ebfc5f8..4fc749ca06540095b258e9ab4871a7e842855e00 100644 (file)
@@ -106,7 +106,8 @@ $config =
         array('server' => null),
         'public' =>
         array('localonly' => true,
-              'blacklist' => array()),
+              'blacklist' => array(),
+              'autosource' => array()),
         'theme' =>
         array('server' => null),
         'throttle' =>
diff --git a/lib/dberroraction.php b/lib/dberroraction.php
new file mode 100644 (file)
index 0000000..0dc9249
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/**
+ * DB error action.
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package  Laconica
+ * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @author   Zach Copley <zach@controlyourself.ca>
+ * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link     http://laconi.ca/
+ *
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, Controlez-Vous, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if (!defined('LACONICA')) {
+    exit(1);
+}
+
+require_once INSTALLDIR.'/lib/servererroraction.php';
+
+/**
+ * Class for displaying DB Errors
+ *
+ * This only occurs if there's been a DB_DataObject_Error that's
+ * reported through PEAR, so we try to avoid doing anything that connects
+ * to the DB, so we don't trigger it again.
+ *
+ * @category Action
+ * @package  Laconica
+ * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link     http://laconi.ca/
+ */
+
+class DBErrorAction extends ServerErrorAction
+{
+    function __construct($message='Error', $code=500)
+    {
+        parent::__construct($message, $code);
+    }
+
+    function title()
+    {
+        return _('Database error');
+    }
+
+    function getLanguage()
+    {
+        // Don't try to figure out user's language; just show the page
+        return common_config('site', 'language');
+    }
+
+    function showPrimaryNav()
+    {
+        // don't show primary nav
+    }
+}
index beab51366081b90b77a9775bf0f3cef04a225bd3..ec39872732fa45ae22ed95c88f4f3b34633ee28f 100644 (file)
@@ -25,21 +25,6 @@ define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2
 define("FACEBOOK_NOTICE_PREFIX", 1);
 define("FACEBOOK_PROMPTED_UPDATE_PREF", 2);
 
-// Gets all the notices from users with a Facebook link since a given ID
-function getFacebookNotices($since)
-{
-    $qry = 'SELECT notice.* ' .
-        'FROM notice ' .
-        'JOIN foreign_link ' .
-        'WHERE notice.profile_id = foreign_link.user_id ' .
-        'AND foreign_link.service = 2';
-
-    // XXX: What should the limit be?
-    //static function getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since) {
-    
-    return Notice::getStreamDirect($qry, 0, 1000, 0, 0, null, $since);
-}
-
 function getFacebook()
 {
     $apikey = common_config('facebook', 'apikey');
@@ -52,3 +37,97 @@ function updateProfileBox($facebook, $flink, $notice) {
     $fbaction->updateProfileBox($notice);
 }
 
+function isFacebookBound($notice, $flink) {
+
+    // If the user does not want to broadcast to Facebook, move along
+    if (!($flink->noticesync & FOREIGN_NOTICE_SEND == FOREIGN_NOTICE_SEND)) {
+        common_log(LOG_INFO, "Skipping notice $notice->id " .
+            'because user has FOREIGN_NOTICE_SEND bit off.');
+        return false;
+    }
+
+    $success = false;
+
+    // If it's not a reply, or if the user WANTS to send @-replies...
+    if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $notice->content) ||
+        ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY)) {
+
+        $success = true;
+
+        // The two condition below are deal breakers:
+
+        // Avoid a loop
+        if ($notice->source == 'Facebook') {
+            common_log(LOG_INFO, "Skipping notice $notice->id because its " .
+                'source is Facebook.');
+            $success = false;
+        }
+
+        $facebook = getFacebook();
+        $fbuid = $flink->foreign_id;
+
+        try {
+
+            // Check to see if the user has given the FB app status update perms
+            $result = $facebook->api_client->
+                users_hasAppPermission('status_update', $fbuid);
+
+            if ($result != 1) {
+                $user = $flink->getUser();
+                $msg = "Can't send notice $notice->id to Facebook " .
+                    "because user $user->nickname hasn't given the " .
+                    'Facebook app \'status_update\' permission.';
+                common_log(LOG_INFO, $msg);
+                $success = false;
+            }
+
+        } catch(FacebookRestClientException $e){
+            common_log(LOG_ERR, $e->getMessage());
+            $success = false;
+        }
+
+    }
+
+    return $success;
+
+}
+
+
+function facebookBroadcastNotice($notice)
+{
+    $facebook = getFacebook();
+    $flink = Foreign_link::getByUserID($notice->profile_id, FACEBOOK_SERVICE);
+    $fbuid = $flink->foreign_id;
+
+    if (isFacebookBound($notice, $flink)) {
+
+        $status = null;
+
+        // Get the status 'verb' (prefix) the user has set
+        try {
+            $prefix = $facebook->api_client->
+                data_getUserPreference(FACEBOOK_NOTICE_PREFIX, $fbuid);
+
+            $status = "$prefix $notice->content";
+
+        } catch(FacebookRestClientException $e) {
+            common_log(LOG_ERR, $e->getMessage());
+            return false;
+        }
+
+        // Okay, we're good to go!
+
+        try {
+            $facebook->api_client->users_setStatus($status, $fbuid, false, true);
+            updateProfileBox($facebook, $flink, $notice);
+        } catch(FacebookRestClientException $e) {
+            common_log(LOG_ERR, $e->getMessage());
+            return false;
+
+             // Should we remove flink if this fails?
+        }
+
+    }
+
+    return true;
+}
index 2935d83630ff3110ab64f607b675912da3dbe9d6..aed94b1a555e845b36c7fd23513fd90b0a9756cc 100644 (file)
@@ -86,4 +86,9 @@ class FeaturedUsersSection extends ProfileSection
     {
         return 'featured_users';
     }
+
+    function moreUrl()
+    {
+        return common_local_url('featured');
+    }
 }
diff --git a/lib/feed.php b/lib/feed.php
new file mode 100644 (file)
index 0000000..4669268
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Data structure for info about syndication feeds (RSS 1.0, RSS 2.0, Atom)
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Feed
+ * @package   Laconica
+ * @author    Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2009 Control Yourself, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+    exit(1);
+}
+
+/**
+ * Data structure for feeds
+ *
+ * This structure is a helpful container for shipping around information about syndication feeds.
+ *
+ * @category Feed
+ * @package  Laconica
+ * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @author   Sarven Capadisli <csarven@controlyourself.ca>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://laconi.ca/
+ */
+
+class Feed
+{
+    const RSS1 = 1;
+    const RSS2 = 2;
+    const ATOM = 3;
+    const FOAF = 4;
+
+    var $type = null;
+    var $url = null;
+    var $title = null;
+
+    function __construct($type, $url, $title)
+    {
+        $this->type  = $type;
+        $this->url   = $url;
+        $this->title = $title;
+    }
+
+    function mimeType()
+    {
+        switch ($this->type) {
+         case Feed::RSS1:
+            return 'application/rdf+xml';
+         case Feed::RSS2:
+            return 'application/rss+xml';
+         case Feed::ATOM:
+            return 'application/atom+xml';
+         case Feed::FOAF:
+            return 'application/rdf+xml';
+         default:
+            return null;
+        }
+    }
+
+    function typeName()
+    {
+        switch ($this->type) {
+         case Feed::RSS1:
+            return _('RSS 1.0');
+         case Feed::RSS2:
+            return _('RSS 2.0');
+         case Feed::ATOM:
+            return _('Atom');
+         case Feed::FOAF:
+            return _('FOAF');
+         default:
+            return null;
+        }
+    }
+
+    function rel()
+    {
+        switch ($this->type) {
+         case Feed::RSS1:
+         case Feed::RSS2:
+         case Feed::ATOM:
+            return 'alternate';
+         case Feed::FOAF:
+            return 'meta';
+         default:
+            return null;
+        }
+    }
+}
index 47d909e969c1ac51986f7448e7c3996630ff4c7d..927e43c330fda3c0ee1754f12d30038a7271b5d2 100644 (file)
@@ -50,7 +50,7 @@ if (!defined('LACONICA')) {
 class FeedList extends Widget
 {
     var $action = null;
-    
+
     function __construct($action=null)
     {
        parent::__construct($action);
@@ -64,8 +64,8 @@ class FeedList extends Widget
         $this->out->element('h2', null, _('Export data'));
         $this->out->elementStart('ul', array('class' => 'xoxo'));
 
-        foreach ($feeds as $key => $value) {
-            $this->feedItem($feeds[$key]);
+        foreach ($feeds as $feed) {
+            $this->feedItem($feed);
         }
 
         $this->out->elementEnd('ul');
@@ -74,85 +74,27 @@ class FeedList extends Widget
 
     function feedItem($feed)
     {
-        $nickname = $this->action->trimmed('nickname');
-
-        switch($feed['item']) {
-         case 'notices': default:
-            $feed_classname = $feed['type'];
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = "$nickname's ".$feed['version']." notice feed";
-            $feed['textContent'] = "RSS";
-            break;
-
-         case 'allrss':
-            $feed_classname = $feed['type'];
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = $feed['version']." feed for $nickname and friends";
-            $feed['textContent'] = "RSS";
-            break;
-
-         case 'repliesrss':
-            $feed_classname = $feed['type'];
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = $feed['version']." feed for replies to $nickname";
-            $feed['textContent'] = "RSS";
-            break;
-
-         case 'publicrss':
-            $feed_classname = $feed['type'];
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = "Public timeline ".$feed['version']." feed";
-            $feed['textContent'] = "RSS";
-            break;
+        $classname = null;
 
-         case 'publicatom':
-            $feed_classname = "atom";
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = "Public timeline ".$feed['version']." feed";
-            $feed['textContent'] = "Atom";
+        switch ($feed->type) {
+         case Feed::RSS1:
+         case Feed::RSS2:
+            $classname = 'rss';
             break;
-
-         case 'tagrss':
-            $feed_classname = $feed['type'];
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = $feed['version']." feed for this tag";
-            $feed['textContent'] = "RSS";
+         case Feed::ATOM:
+            $classname = 'atom';
             break;
-
-         case 'favoritedrss':
-            $feed_classname = $feed['type'];
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = "Favorited ".$feed['version']." feed";
-            $feed['textContent'] = "RSS";
-            break;
-
-         case 'foaf':
-            $feed_classname = "foaf";
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = "$nickname's FOAF file";
-            $feed['textContent'] = "FOAF";
-            break;
-
-         case 'favoritesrss':
-            $feed_classname = "favorites";
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = "Feed for favorites of $nickname";
-            $feed['textContent'] = "RSS";
-            break;
-
-         case 'usertimeline':
-            $feed_classname = "atom";
-            $feed_mimetype = "application/".$feed['type']."+xml";
-            $feed_title = "$nickname's ".$feed['version']." notice feed";
-            $feed['textContent'] = "Atom";
+         case Feed::FOAF:
+            $classname = 'foaf';
             break;
         }
+
         $this->out->elementStart('li');
-        $this->out->element('a', array('href' => $feed['href'],
-                                  'class' => $feed_classname,
-                                  'type' => $feed_mimetype,
-                                  'title' => $feed_title),
-                       $feed['textContent']);
+        $this->out->element('a', array('href' => $feed->url,
+                                       'class' => $classname,
+                                       'type' => $feed->mimeType(),
+                                       'title' => $feed->title),
+                            $feed->typeName());
         $this->out->elementEnd('li');
     }
 }
index 4c448e250d5011b13d3d8280fac33c97cf482bd5..6801ab42617eb40d876fecccba72066c0c2e2ba4 100644 (file)
@@ -124,7 +124,7 @@ class GroupList extends Widget
         if ($this->group->location) {
             $this->out->elementStart('dl', 'entity_location');
             $this->out->element('dt', null, _('Location'));
-            $this->out->elementStart('dd', 'location');
+            $this->out->elementStart('dd', 'label');
             $this->out->raw($this->highlight($this->group->location));
             $this->out->elementEnd('dd');
             $this->out->elementEnd('dl');
index e2319b1fdc2a10bc54851c194d6b165c84888f20..06603ac05485660b206726ad217a769756f9713b 100644 (file)
@@ -101,29 +101,32 @@ class HTMLOutputter extends XMLOutputter
             $type = common_negotiate_type($cp, $sp);
 
             if (!$type) {
-                common_user_error(_('This page is not available in a '.
-                                    'media type you accept'), 406);
-                exit(0);
+                throw new ClientException(_('This page is not available in a '.
+                                            'media type you accept'), 406);
             }
         }
 
         header('Content-Type: '.$type);
-        
+
         $this->extraHeaders();
 
         $this->startXML('html',
                         '-//W3C//DTD XHTML 1.0 Strict//EN',
                         'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd');
 
-        // FIXME: correct language for interface
-
-        $language = common_language();
+        $language = $this->getLanguage();
 
         $this->elementStart('html', array('xmlns' => 'http://www.w3.org/1999/xhtml',
                                           'xml:lang' => $language,
                                           'lang' => $language));
     }
 
+    function getLanguage()
+    {
+        // FIXME: correct language for interface
+        return common_language();
+    }
+
     /**
     *  Ends an HTML document
     *
@@ -134,7 +137,7 @@ class HTMLOutputter extends XMLOutputter
         $this->elementEnd('html');
         $this->endXML();
     }
-    
+
     /**
     *  To specify additional HTTP headers for the action
     *
index f41d984d6261a46698f11cf27de238d8698e3ce1..3fbb3e1ab9ee0c04c9ad263cc3ba43654b97a39b 100644 (file)
@@ -114,7 +114,7 @@ function jabber_connect($resource=null)
         try {
             $conn->connect(true); // true = persistent connection
         } catch (XMPPHP_Exception $e) {
-            common_log(LOG_ERROR, $e->getMessage());
+            common_log(LOG_ERR, $e->getMessage());
             return false;
         }
 
@@ -186,6 +186,11 @@ function jabber_format_entry($profile, $notice)
     $entry .= "<id>". $notice->uri . "</id>\n";
     $entry .= "<published>".common_date_w3dtf($notice->created)."</published>\n";
     $entry .= "<updated>".common_date_w3dtf($notice->modified)."</updated>\n";
+    if ($notice->reply_to) {
+        $replyurl = common_local_url('shownotice',
+                                     array('notice' => $notice->reply_to));
+        $entry .= "<link rel='related' href='" . $replyurl . "'/>\n";
+    }
     $entry .= "</entry>\n";
 
     $html  = "\n<html xmlns='http://jabber.org/protocol/xhtml-im'>\n";
index a1faefc806576a3a336efc0341cedd912c52a21a..9fa86de5cc81a40643340db104248c79adb40c8e 100644 (file)
@@ -573,3 +573,53 @@ function mail_notify_fave($other, $user, $notice)
     common_init_locale();
     mail_to_user($other, $subject, $body);
 }
+
+/**
+ * notify a user that they have received an "attn:" message AKA "@-reply"
+ *
+ * @param User   $user   The user who recevied the notice
+ * @param Notice $notice The notice that was sent
+ *
+ * @return void
+ */
+
+function mail_notify_attn($user, $notice)
+{
+    if (!$user->email || !$user->emailnotifyattn) {
+        return;
+    }
+
+    $sender = $notice->getProfile();
+
+    $bestname = $sender->getBestName();
+
+    common_init_locale($user->language);
+
+    $subject = sprintf(_('%s sent a notice to your attention'), $bestname);
+
+    $body = sprintf(_("%1\$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".
+                      "\t%4\$s\n\n" .
+                      "You can reply back here:\n\n".
+                      "\t%5\$s\n\n" .
+                      "The list of all @-replies for you here:\n\n" .
+                      "%6\$s\n\n" .
+                      "Faithfully yours,\n" .
+                      "%2\$s\n\n" .
+                      "P.S. You can turn off these email notifications here: %7\$s\n"),
+                    $bestname,
+                    common_config('site', 'name'),
+                    common_local_url('shownotice',
+                                     array('notice' => $notice->id)),
+                    $notice->content,
+                    common_local_url('newnotice',
+                                     array('replyto' => $sender->nickname)),
+                    common_local_url('replies',
+                                     array('nickname' => $user->nickname)),
+                    common_local_url('emailsettings'));
+
+    common_init_locale();
+    mail_to_user($user, $subject, $body);
+}
index 5734d800189d9bdd7be139d85aef94775b8b53c7..5380563b9e70ee48cb8590bc376d39b16cbb20fd 100644 (file)
@@ -80,4 +80,9 @@ class PopularNoticeSection extends NoticeSection
     {
         return 'popular_notices';
     }
+
+    function moreUrl()
+    {
+        return common_local_url('favorited');
+    }
 }
index 4d924b039e9647fd329240044a9874d11a9ead59..8bef49dceeefc0885576274a86e7adc786a0dee1 100644 (file)
@@ -123,7 +123,7 @@ class ProfileList extends Widget
         if ($this->profile->location) {
             $this->out->elementStart('dl', 'entity_location');
             $this->out->element('dt', null, _('Location'));
-            $this->out->elementStart('dd', 'location');
+            $this->out->elementStart('dd', 'label');
             $this->out->raw($this->highlight($this->profile->location));
             $this->out->elementEnd('dd');
             $this->out->elementEnd('dl');
diff --git a/lib/router.php b/lib/router.php
new file mode 100644 (file)
index 0000000..d47ad71
--- /dev/null
@@ -0,0 +1,363 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * URL routing utilities
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  URL
+ * @package   Laconica
+ * @author    Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2009 Control Yourself, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+    exit(1);
+}
+
+require_once 'Net/URL/Mapper.php';
+
+/**
+ * URL Router
+ *
+ * Cheap wrapper around Net_URL_Mapper
+ *
+ * @category URL
+ * @package  Laconica
+ * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://laconi.ca/
+ */
+
+class Router
+{
+    static $m = null;
+    static $inst = null;
+
+    static function get()
+    {
+        if (!Router::$inst) {
+            Router::$inst = new Router();
+        }
+        return Router::$inst;
+    }
+
+    function __construct()
+    {
+        if (!$this->m) {
+            $this->m = $this->initialize();
+        }
+    }
+
+    function initialize() {
+
+        $m = Net_URL_Mapper::getInstance();
+
+        // In the "root"
+
+        $m->connect('', array('action' => 'public'));
+        $m->connect('rss', array('action' => 'publicrss'));
+        $m->connect('xrds', array('action' => 'publicxrds'));
+        $m->connect('featuredrss', array('action' => 'featuredrss'));
+        $m->connect('favoritedrss', array('action' => 'favoritedrss'));
+        $m->connect('opensearch/people', array('action' => 'opensearch',
+                                               'type' => 'people'));
+        $m->connect('opensearch/notice', array('action' => 'opensearch',
+                                               'type' => 'notice'));
+
+        // docs
+
+        $m->connect('doc/:title', array('action' => 'doc'));
+
+        // facebook
+
+        $m->connect('facebook', array('action' => 'facebookhome'));
+        $m->connect('facebook/index.php', array('action' => 'facebookhome'));
+        $m->connect('facebook/settings.php', array('action' => 'facebooksettings'));
+        $m->connect('facebook/invite.php', array('action' => 'facebookinvite'));
+        $m->connect('facebook/remove', array('action' => 'facebookremove'));
+
+        // main stuff is repetitive
+
+        $main = array('login', 'logout', 'register', 'subscribe',
+                      'unsubscribe', 'confirmaddress', 'recoverpassword',
+                      'invite', 'favor', 'disfavor', 'sup',
+                      'tagother', 'block');
+
+        foreach ($main as $a) {
+            $m->connect('main/'.$a, array('action' => $a));
+        }
+
+        // these take a code
+
+        foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
+            $m->connect('main/'.$c.'/:code', array('action' => $c));
+        }
+
+        // exceptional
+
+        $m->connect('main/openid', array('action' => 'openidlogin'));
+        $m->connect('main/remote', array('action' => 'remotesubscribe'));
+
+        // settings
+
+        foreach (array('profile', 'avatar', 'password', 'openid', 'im',
+                       'email', 'sms', 'twitter', 'other') as $s) {
+            $m->connect('settings/'.$s, array('action' => $s.'settings'));
+        }
+
+        // search
+
+        foreach (array('group', 'people', 'notice') as $s) {
+            $m->connect('search/'.$s, array('action' => $s.'search'));
+        }
+
+        $m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
+
+        // notice
+
+        $m->connect('notice/new', array('action' => 'newnotice'));
+        $m->connect('notice/:notice',
+                    array('action' => 'shownotice'),
+                    array('notice' => '[0-9]+'));
+        $m->connect('notice/delete', array('action' => 'deletenotice'));
+        $m->connect('notice/delete/:notice',
+                    array('action' => 'deletenotice'),
+                    array('notice' => '[0-9]+'));
+
+        $m->connect('message/new', array('action' => 'newmessage'));
+        $m->connect('message/:message',
+                    array('action' => 'showmessage'),
+                    array('message' => '[0-9]+'));
+
+        $m->connect('user/:id',
+                    array('action' => 'userbyid'),
+                    array('id' => '[0-9]+'));
+
+        $m->connect('tags/', array('action' => 'publictagcloud'));
+        $m->connect('tag/', array('action' => 'publictagcloud'));
+        $m->connect('tags', array('action' => 'publictagcloud'));
+        $m->connect('tag', array('action' => 'publictagcloud'));
+        $m->connect('tag/:tag/rss',
+                    array('action' => 'tagrss'),
+                    array('tag' => '[a-zA-Z0-9]+'));
+        $m->connect('tag/:tag',
+                    array('action' => 'tag'),
+                    array('tag' => '[a-zA-Z0-9]+'));
+
+        $m->connect('peopletag/:tag',
+                    array('action' => 'peopletag'),
+                    array('tag' => '[a-zA-Z0-9]+'));
+
+        $m->connect('featured/', array('action' => 'featured'));
+        $m->connect('featured', array('action' => 'featured'));
+        $m->connect('favorited/', array('action' => 'favorited'));
+        $m->connect('favorited', array('action' => 'favorited'));
+
+        // groups
+
+        $m->connect('group/new', array('action' => 'newgroup'));
+
+        foreach (array('edit', 'join', 'leave') as $v) {
+            $m->connect('group/:nickname/'.$v,
+                        array('action' => $v.'group'),
+                        array('nickname' => '[a-zA-Z0-9]+'));
+        }
+
+        foreach (array('members', 'logo', 'rss') as $n) {
+            $m->connect('group/:nickname/'.$n,
+                        array('action' => 'group'.$n),
+                        array('nickname' => '[a-zA-Z0-9]+'));
+        }
+
+        $m->connect('group/:id/id',
+                    array('action' => 'groupbyid'),
+                    array('id' => '[0-9]+'));
+
+        $m->connect('group/:nickname',
+                    array('action' => 'showgroup'),
+                    array('nickname' => '[a-zA-Z0-9]+'));
+
+        $m->connect('group/', array('action' => 'groups'));
+        $m->connect('group', array('action' => 'groups'));
+        $m->connect('groups/', array('action' => 'groups'));
+        $m->connect('groups', array('action' => 'groups'));
+
+        // Twitter-compatible API
+
+        // statuses API
+
+        $m->connect('api/statuses/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'statuses'),
+                    array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|friends|followers|featured)(\.(atom|rss|xml|json))?'));
+
+        $m->connect('api/statuses/:method/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'statuses'),
+                    array('method' => '(user_timeline|show|destroy|friends|followers)'));
+
+        // users
+
+        $m->connect('api/users/show/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'users'));
+
+        $m->connect('api/users/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'users'),
+                    array('method' => 'show(\.(xml|json|atom|rss))?'));
+
+        // direct messages
+
+        $m->connect('api/direct_messages/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'direct_messages'),
+                    array('method' => '(sent|new)(\.(xml|json|atom|rss))?'));
+
+        $m->connect('api/direct_messages/destroy/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'direct_messages'));
+
+        $m->connect('api/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'direct_messages'),
+                    array('method' => 'direct_messages(\.(xml|json|atom|rss))?'));
+
+        // friendships
+
+        $m->connect('api/friendships/:method/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'friendships'),
+                    array('method' => '(create|destroy)'));
+
+        $m->connect('api/friendships/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'friendships'),
+                    array('method' => 'exists(\.(xml|json|rss|atom))'));
+
+        // account
+
+        $m->connect('api/account/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'account'));
+
+        // favorites
+
+        $m->connect('api/favorites/:method/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'favorites'));
+
+        $m->connect('api/favorites/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'favorites',
+                          'method' => 'favorites'));
+
+        $m->connect('api/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'favorites'),
+                    array('method' => 'favorites(\.(xml|json|rss|atom))?'));
+
+        // notifications
+
+        $m->connect('api/notifications/:method/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'favorites'));
+
+        // blocks
+
+        $m->connect('api/blocks/:method/:argument',
+                    array('action' => 'api',
+                          'apiaction' => 'blocks'));
+
+        // help
+
+        $m->connect('api/help/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'help'));
+
+        // laconica
+
+        $m->connect('api/laconica/:method',
+                    array('action' => 'api',
+                          'apiaction' => 'laconica'));
+
+        // user stuff
+
+        foreach (array('subscriptions', 'subscribers',
+                       'nudge', 'xrds', 'all', 'foaf',
+                       'replies', 'inbox', 'outbox', 'microsummary') as $a) {
+            $m->connect(':nickname/'.$a,
+                        array('action' => $a),
+                        array('nickname' => '[a-zA-Z0-9]{1,64}'));
+        }
+
+        foreach (array('subscriptions', 'subscribers') as $a) {
+            $m->connect(':nickname/'.$a.'/:tag',
+                        array('action' => $a),
+                        array('tag' => '[a-zA-Z0-9]+',
+                              'nickname' => '[a-zA-Z0-9]{1,64}'));
+        }
+
+        foreach (array('rss', 'groups') as $a) {
+            $m->connect(':nickname/'.$a,
+                        array('action' => 'user'.$a),
+                        array('nickname' => '[a-zA-Z0-9]{1,64}'));
+        }
+
+        foreach (array('all', 'replies', 'favorites') as $a) {
+            $m->connect(':nickname/'.$a.'/rss',
+                        array('action' => $a.'rss'),
+                        array('nickname' => '[a-zA-Z0-9]{1,64}'));
+        }
+
+        $m->connect(':nickname/favorites',
+                    array('action' => 'showfavorites'),
+                    array('nickname' => '[a-zA-Z0-9]{1,64}'));
+
+        $m->connect(':nickname/avatar/:size',
+                    array('action' => 'avatarbynickname'),
+                    array('size' => '(original|96|48|24)',
+                          'nickname' => '[a-zA-Z0-9]{1,64}'));
+
+        $m->connect(':nickname',
+                    array('action' => 'showstream'),
+                    array('nickname' => '[a-zA-Z0-9]{1,64}'));
+
+        return $m;
+    }
+
+    function map($path)
+    {
+        return $this->m->match($path);
+    }
+
+    function build($action, $args=null, $fragment=null)
+    {
+        $action_arg = array('action' => $action);
+
+        if ($args) {
+            $args = array_merge($action_arg, $args);
+        } else {
+            $args = $action_arg;
+        }
+
+        return $this->m->generate($args, null, $fragment);
+    }
+}
\ No newline at end of file
index 0c32ddcf84e91a5696e5ea32cb29d4f45108995d..d145750862a504ec10d1e912e1f4a4c709624040 100644 (file)
@@ -103,6 +103,6 @@ class Section extends Widget
 
     function moreTitle()
     {
-        return null;
+        return _('More...');
     }
 }
index 1972985493a92b414d54667506b4983f86e80c44..deb6fd276b6ac71de7fe10280ad33f129c3cd717 100644 (file)
@@ -19,6 +19,8 @@
 
 if (!defined('LACONICA')) { exit(1); }
 
+define("TWITTER_SERVICE", 1); // Twitter is foreign_service ID 1
+
 function get_twitter_data($uri, $screen_name, $password)
 {
 
@@ -28,14 +30,13 @@ function get_twitter_data($uri, $screen_name, $password)
             CURLOPT_FAILONERROR        => true,
             CURLOPT_HEADER            => false,
             CURLOPT_FOLLOWLOCATION    => true,
-            # CURLOPT_USERAGENT        => "identi.ca",
+            CURLOPT_USERAGENT      => "Laconica",
             CURLOPT_CONNECTTIMEOUT    => 120,
             CURLOPT_TIMEOUT            => 120,
             # Twitter is strict about accepting invalid "Expect" headers
             CURLOPT_HTTPHEADER => array('Expect:')
     );
 
-
     $ch = curl_init($uri);
     curl_setopt_array($ch, $options);
     $data = curl_exec($ch);
@@ -95,7 +96,7 @@ function add_twitter_user($twitter_id, $screen_name)
     $fuser->nickname = $screen_name;
     $fuser->uri = 'http://twitter.com/' . $screen_name;
     $fuser->id = $twitter_id;
-    $fuser->service = 1; // Twitter
+    $fuser->service = TWITTER_SERVICE; // Twitter
     $fuser->created = common_sql_now();
     $result = $fuser->insert();
 
@@ -206,3 +207,93 @@ function save_twitter_friends($user, $twitter_id, $screen_name, $password)
     return true;
 }
 
+function is_twitter_bound($notice, $flink) {
+
+    // Check to see if notice should go to Twitter
+    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) ||
+            ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY)) {
+                return true;
+        }
+    }
+    
+    return false;
+}
+
+function broadcast_twitter($notice)
+{
+    global $config;
+    $success = true;
+
+    $flink = Foreign_link::getByUserID($notice->profile_id, 
+        TWITTER_SERVICE);
+            
+    // 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)) {
+
+        $fuser = $flink->getForeignUser();
+        $twitter_user = $fuser->nickname;
+        $twitter_password = $flink->credentials;
+        $uri = 'http://www.twitter.com/statuses/update.json';
+
+        // XXX: Hack to get around PHP cURL's use of @ being a a meta character
+        $statustxt = preg_replace('/^@/', ' @', $notice->content);
+
+        $options = array(
+            CURLOPT_USERPWD        => "$twitter_user:$twitter_password",
+            CURLOPT_POST           => true,
+            CURLOPT_POSTFIELDS     => 
+                array(
+                        'status' => $statustxt,
+                        'source' => $config['integration']['source']
+                     ),
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_FAILONERROR    => true,
+            CURLOPT_HEADER         => false,
+            CURLOPT_FOLLOWLOCATION => true,
+            CURLOPT_USERAGENT      => "Laconica",
+            CURLOPT_CONNECTTIMEOUT => 120,  // XXX: How long should this be?
+            CURLOPT_TIMEOUT        => 120,
+
+            # Twitter is strict about accepting invalid "Expect" headers
+            CURLOPT_HTTPHEADER => array('Expect:')
+            );
+
+        $ch = curl_init($uri);
+        curl_setopt_array($ch, $options);
+        $data = curl_exec($ch);
+        $errmsg = curl_error($ch);
+
+        if ($errmsg) {
+            common_debug("cURL error: $errmsg - " .
+                "trying to send notice for $twitter_user.",
+                         __FILE__);
+            $success = false;
+        }
+
+        curl_close($ch);
+
+        if (!$data) {
+            common_debug("No data returned by Twitter's " .
+                "API trying to send update for $twitter_user",
+                         __FILE__);
+            $success = false;
+        }
+
+        // Twitter should return a status
+        $status = json_decode($data);
+
+        if (!$status->id) {
+            common_debug("Unexpected data returned by Twitter " .
+                " API trying to send update for $twitter_user",
+                         __FILE__);
+            $success = false;
+        }
+    }
+    
+    return $success;
+}
+
index c5a092f6300c4f7c8bdae1bd27b4e8d0cac9f95f..46aa7b9df907b2691f0ce782376a7005da573a98 100644 (file)
@@ -394,32 +394,32 @@ function common_render_text($text)
 
 function common_replace_urls_callback($text, $callback) {
     // Start off with a regex
-    $regex = '#
-    (?:
-        (?:
-            (?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|xmpp|irc)://
-            |
-            (?:mailto|aim|tel):
-        )
-        [^.\s]+\.[^\s]+
-        |
-        (?:[^.\s/:]+\.)+
-        (?:museum|travel|[a-z]{2,4})
-        (?:[:/][^\s]*)?
-    )
-    #ix';
+    $regex = '#'.
+    '(?:'.
+        '(?:'.
+            '(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|xmpp|irc)://'.
+            '|'.
+            '(?:mailto|aim|tel):'.
+        ')'.
+        '[^.\s]+\.[^\s]+'.
+        '|'.
+        '(?:[^.\s/:]+\.)+'.
+        '(?:museum|travel|[a-z]{2,4})'.
+        '(?:[:/][^\s]*)?'.
+    ')'.
+    '#ix';
     preg_match_all($regex, $text, $matches);
 
     // Then clean up what the regex left behind
     $offset = 0;
-    foreach($matches[0] as $url) {
-        $url = htmlspecialchars_decode($url);
+    foreach($matches[0] as $orig_url) {
+        $url = htmlspecialchars_decode($orig_url);
 
         // Make sure we didn't pick up an email address
         if (preg_match('#^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$#i', $url)) continue;
 
-        // Remove trailing punctuation
-        $url = rtrim($url, '.?!,;:\'"`');
+        // Remove surrounding punctuation
+        $url = trim($url, '.?!,;:\'"`([<');
 
         // Remove surrounding parens and the like
         preg_match('/[)\]>]+$/', $url, $trailing);
@@ -446,7 +446,7 @@ function common_replace_urls_callback($text, $callback) {
 
         // If the first part wasn't cap'd but the last part was, we captured too much
         if ((!$prev_part && $last_part)) {
-            $url = substr_replace($url, '', mb_strpos($url, '.'.$url_parts[2], 0));
+            $url = mb_substr($url, 0 , mb_strpos($url, '.'.$url_parts['2'], 0));
         }
 
         // Capture the new TLD
@@ -456,6 +456,9 @@ function common_replace_urls_callback($text, $callback) {
 
         if (!in_array($url_parts[2], $tlds)) continue;
 
+        // Put the url back the way we found it.
+        $url = (mb_strpos($orig_url, htmlspecialchars($url)) === FALSE) ? $url:htmlspecialchars($url);
+
         // Call user specified func
         $modified_url = $callback($url);
 
@@ -469,16 +472,25 @@ 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;
+    $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)) {
-        $longurl = htmlentities($longurl, ENT_QUOTES, 'UTF-8');
-        $title = "title=\"$longurl\"";
+        $attrs['title'] = $longurl;
     }
-    else $title = '';
 
-    return "<a href=\"$url\" $title rel=\"external\">$display</a>";
+    return XMLStringer::estring('a', $attrs, $display);
 }
 
 function common_longurl($short_url)
@@ -579,7 +591,13 @@ function common_tag_link($tag)
 {
     $canonical = common_canonical_tag($tag);
     $url = common_local_url('tag', array('tag' => $canonical));
-    return '<span class="tag"><a href="' . htmlspecialchars($url) . '" rel="tag">' . htmlspecialchars($tag) . '</a></span>';
+    $xs = new XMLStringer();
+    $xs->elementStart('span', 'tag');
+    $xs->element('a', array('href' => $url,
+                            'rel' => 'tag'),
+                 $tag);
+    $xs->elementEnd('span');
+    return $xs->getString();
 }
 
 function common_canonical_tag($tag)
@@ -597,7 +615,14 @@ function common_at_link($sender_id, $nickname)
     $sender = Profile::staticGet($sender_id);
     $recipient = common_relative_profile($sender, common_canonical_nickname($nickname));
     if ($recipient) {
-        return '<span class="vcard"><a href="'.htmlspecialchars($recipient->profileurl).'" class="url"><span class="fn nickname">'.$nickname.'</span></a></span>';
+        $xs = new XMLStringer(false);
+        $xs->elementStart('span', 'vcard');
+        $xs->elementStart('a', array('href' => $recipient->profileurl,
+                                     'class' => 'url'));
+        $xs->element('span', 'fn nickname', $nickname);
+        $xs->elementEnd('a');
+        $xs->elementEnd('span');
+        return $xs->getString();
     } else {
         return $nickname;
     }
@@ -608,7 +633,14 @@ function common_group_link($sender_id, $nickname)
     $sender = Profile::staticGet($sender_id);
     $group = User_group::staticGet('nickname', common_canonical_nickname($nickname));
     if ($group && $sender->isMember($group)) {
-        return '<span class="vcard"><a href="'.htmlspecialchars($group->permalink()).'" class="url"><span class="fn nickname">'.$nickname.'</span></a></span>';
+        $xs = new XMLStringer();
+        $xs->elementStart('span', 'vcard');
+        $xs->elementStart('a', array('href' => $group->permalink(),
+                                     'class' => 'url'));
+        $xs->element('span', 'fn nickname', $nickname);
+        $xs->elementEnd('a');
+        $xs->elementEnd('span');
+        return $xs->getString();
     } else {
         return $nickname;
     }
@@ -625,7 +657,13 @@ function common_at_hash_link($sender_id, $tag)
         $url = common_local_url('subscriptions',
                                 array('nickname' => $user->nickname,
                                       'tag' => $tag));
-        return '<span class="tag"><a href="'.htmlspecialchars($url).'" rel="tag">'.$tag.'</a></span>';
+        $xs = new XMLStringer();
+        $xs->elementStart('span', 'tag');
+        $xs->element('a', array('href' => $url,
+                                'rel' => $tag),
+                     $tag);
+        $xs->elementEnd('span');
+        return $xs->getString();
     } else {
         return $tag;
     }
@@ -669,275 +707,18 @@ function common_relative_profile($sender, $nickname, $dt=null)
 
 function common_local_url($action, $args=null, $fragment=null)
 {
-    $url = null;
+    $r = Router::get();
+    $path = $r->build($action, $args, $fragment);
+    if ($path) {
+    }
     if (common_config('site','fancy')) {
-        $url = common_fancy_url($action, $args);
+        $url = common_path(mb_substr($path, 1));
     } else {
-        $url = common_simple_url($action, $args);
-    }
-    if (!is_null($fragment)) {
-        $url .= '#'.$fragment;
+        $url = common_path('index.php'.$path);
     }
     return $url;
 }
 
-function common_fancy_url($action, $args=null)
-{
-    switch (strtolower($action)) {
-     case 'public':
-        if ($args && isset($args['page'])) {
-            return common_path('?page=' . $args['page']);
-        } else {
-            return common_path('');
-        }
-     case 'featured':
-        if ($args && isset($args['page'])) {
-            return common_path('featured?page=' . $args['page']);
-        } else {
-            return common_path('featured');
-        }
-     case 'favorited':
-        if ($args && isset($args['page'])) {
-            return common_path('favorited?page=' . $args['page']);
-        } else {
-            return common_path('favorited');
-        }
-     case 'publicrss':
-        return common_path('rss');
-     case 'publicatom':
-        return common_path("api/statuses/public_timeline.atom");
-     case 'publicxrds':
-        return common_path('xrds');
-     case 'tagrss':
-        return common_path('tag/' . $args['tag'] . '/rss');
-     case 'featuredrss':
-        return common_path('featuredrss');
-     case 'favoritedrss':
-        return common_path('favoritedrss');
-     case 'opensearch':
-        if ($args && $args['type']) {
-            return common_path('opensearch/'.$args['type']);
-        } else {
-            return common_path('opensearch/people');
-        }
-     case 'doc':
-        return common_path('doc/'.$args['title']);
-     case 'block':
-     case 'login':
-     case 'logout':
-     case 'subscribe':
-     case 'unsubscribe':
-     case 'invite':
-        return common_path('main/'.$action);
-     case 'tagother':
-        return common_path('main/tagother?id='.$args['id']);
-     case 'register':
-        if ($args && $args['code']) {
-            return common_path('main/register/'.$args['code']);
-        } else {
-            return common_path('main/register');
-        }
-     case 'remotesubscribe':
-        if ($args && $args['nickname']) {
-            return common_path('main/remote?nickname=' . $args['nickname']);
-        } else {
-            return common_path('main/remote');
-        }
-     case 'nudge':
-        return common_path($args['nickname'].'/nudge');
-     case 'openidlogin':
-        return common_path('main/openid');
-     case 'profilesettings':
-        return common_path('settings/profile');
-     case 'passwordsettings':
-        return common_path('settings/password');
-     case 'emailsettings':
-        return common_path('settings/email');
-     case 'openidsettings':
-        return common_path('settings/openid');
-     case 'smssettings':
-        return common_path('settings/sms');
-     case 'twittersettings':
-        return common_path('settings/twitter');
-     case 'othersettings':
-        return common_path('settings/other');
-     case 'deleteprofile':
-        return common_path('settings/delete');
-     case 'newnotice':
-        if ($args && $args['replyto']) {
-            return common_path('notice/new?replyto='.$args['replyto']);
-        } else {
-            return common_path('notice/new');
-        }
-     case 'shownotice':
-        return common_path('notice/'.$args['notice']);
-     case 'deletenotice':
-        if ($args && $args['notice']) {
-            return common_path('notice/delete/'.$args['notice']);
-        } else {
-            return common_path('notice/delete');
-        }
-     case 'microsummary':
-     case 'xrds':
-     case 'foaf':
-        return common_path($args['nickname'].'/'.$action);
-     case 'all':
-     case 'replies':
-     case 'inbox':
-     case 'outbox':
-        if ($args && isset($args['page'])) {
-            return common_path($args['nickname'].'/'.$action.'?page=' . $args['page']);
-        } else {
-            return common_path($args['nickname'].'/'.$action);
-        }
-     case 'subscriptions':
-     case 'subscribers':
-        $nickname = $args['nickname'];
-        unset($args['nickname']);
-        if (isset($args['tag'])) {
-            $tag = $args['tag'];
-            unset($args['tag']);
-        }
-        $params = http_build_query($args);
-        if ($params) {
-            return common_path($nickname.'/'.$action . (($tag) ? '/' . $tag : '') . '?' . $params);
-        } else {
-            return common_path($nickname.'/'.$action . (($tag) ? '/' . $tag : ''));
-        }
-     case 'allrss':
-        return common_path($args['nickname'].'/all/rss');
-     case 'repliesrss':
-        return common_path($args['nickname'].'/replies/rss');
-     case 'userrss':
-        if (isset($args['limit']))
-          return common_path($args['nickname'].'/rss?limit=' . $args['limit']);
-        return common_path($args['nickname'].'/rss');
-     case 'showstream':
-        if ($args && isset($args['page'])) {
-            return common_path($args['nickname'].'?page=' . $args['page']);
-        } else {
-            return common_path($args['nickname']);
-        }
-
-     case 'usertimeline':
-        return common_path("api/statuses/user_timeline/".$args['nickname'].".atom");
-     case 'confirmaddress':
-        return common_path('main/confirmaddress/'.$args['code']);
-     case 'userbyid':
-        return common_path('user/'.$args['id']);
-     case 'recoverpassword':
-        $path = 'main/recoverpassword';
-        if ($args['code']) {
-            $path .= '/' . $args['code'];
-        }
-        return common_path($path);
-     case 'imsettings':
-        return common_path('settings/im');
-     case 'avatarsettings':
-        return common_path('settings/avatar');
-     case 'groupsearch':
-        return common_path('search/group' . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'peoplesearch':
-        return common_path('search/people' . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'noticesearch':
-        return common_path('search/notice' . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'noticesearchrss':
-        return common_path('search/notice/rss' . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'avatarbynickname':
-        return common_path($args['nickname'].'/avatar/'.$args['size']);
-     case 'tag':
-        $path = 'tag/' . $args['tag'];
-        unset($args['tag']);
-        return common_path($path . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'publictagcloud':
-        return common_path('tags');
-     case 'peopletag':
-        $path = 'peopletag/' . $args['tag'];
-        unset($args['tag']);
-        return common_path($path . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'tags':
-        return common_path('tags' . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'favor':
-        return common_path('main/favor');
-     case 'disfavor':
-        return common_path('main/disfavor');
-     case 'showfavorites':
-        if ($args && isset($args['page'])) {
-            return common_path($args['nickname'].'/favorites?page=' . $args['page']);
-        } else {
-            return common_path($args['nickname'].'/favorites');
-        }
-     case 'favoritesrss':
-        return common_path($args['nickname'].'/favorites/rss');
-     case 'showmessage':
-        return common_path('message/' . $args['message']);
-     case 'newmessage':
-        return common_path('message/new' . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'api':
-        // XXX: do fancy URLs for all the API methods
-        switch (strtolower($args['apiaction'])) {
-         case 'statuses':
-            switch (strtolower($args['method'])) {
-             case 'user_timeline.rss':
-                return common_path('api/statuses/user_timeline/'.$args['argument'].'.rss');
-             case 'user_timeline.atom':
-                return common_path('api/statuses/user_timeline/'.$args['argument'].'.atom');
-             case 'user_timeline.json':
-                return common_path('api/statuses/user_timeline/'.$args['argument'].'.json');
-             case 'user_timeline.xml':
-                return common_path('api/statuses/user_timeline/'.$args['argument'].'.xml');
-             default: return common_simple_url($action, $args);
-            }
-         default: return common_simple_url($action, $args);
-        }
-     case 'sup':
-        if ($args && isset($args['seconds'])) {
-            return common_path('main/sup?seconds='.$args['seconds']);
-        } else {
-            return common_path('main/sup');
-        }
-     case 'newgroup':
-        return common_path('group/new');
-     case 'showgroup':
-        return common_path('group/'.$args['nickname'] . (($args['page']) ? ('?page=' . $args['page']) : ''));
-     case 'editgroup':
-        return common_path('group/'.$args['nickname'].'/edit');
-     case 'joingroup':
-        return common_path('group/'.$args['nickname'].'/join');
-     case 'leavegroup':
-        return common_path('group/'.$args['nickname'].'/leave');
-     case 'groupbyid':
-        return common_path('group/'.$args['id'].'/id');
-     case 'grouprss':
-        return common_path('group/'.$args['nickname'].'/rss');
-     case 'groupmembers':
-        return common_path('group/'.$args['nickname'].'/members' . (($args['page']) ? ('?page=' . $args['page']) : ''));
-     case 'grouplogo':
-        return common_path('group/'.$args['nickname'].'/logo');
-     case 'usergroups':
-        $nickname = $args['nickname'];
-        unset($args['nickname']);
-        return common_path($nickname.'/groups' . (($args) ? ('?' . http_build_query($args)) : ''));
-     case 'groups':
-        return common_path('group' . (($args) ? ('?' . http_build_query($args)) : ''));
-     default:
-        return common_simple_url($action, $args);
-    }
-}
-
-function common_simple_url($action, $args=null)
-{
-    global $config;
-    /* XXX: pretty URLs */
-    $extra = '';
-    if ($args) {
-        foreach ($args as $key => $value) {
-            $extra .= "&${key}=${value}";
-        }
-    }
-    return common_path("index.php?action=${action}${extra}");
-}
-
 function common_path($relative)
 {
     global $config;
@@ -1046,24 +827,6 @@ function common_redirect($url, $code=307)
 
 function common_broadcast_notice($notice, $remote=false)
 {
-
-    // Check to see if notice should go to Twitter
-    $flink = Foreign_link::getByUserID($notice->profile_id, 1); // 1 == Twitter
-    if (($flink->noticesync & FOREIGN_NOTICE_SEND) == 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) ||
-            (($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) == FOREIGN_NOTICE_SEND_REPLY)) {
-
-            $result = common_twitter_broadcast($notice, $flink);
-
-            if (!$result) {
-                common_debug('Unable to send notice: ' . $notice->id . ' to Twitter.', __FILE__);
-            }
-        }
-    }
-
     if (common_config('queue', 'enabled')) {
         // Do it later!
         return common_enqueue_notice($notice);
@@ -1072,73 +835,11 @@ function common_broadcast_notice($notice, $remote=false)
     }
 }
 
-function common_twitter_broadcast($notice, $flink)
-{
-    global $config;
-    $success = true;
-    $fuser = $flink->getForeignUser();
-    $twitter_user = $fuser->nickname;
-    $twitter_password = $flink->credentials;
-    $uri = 'http://www.twitter.com/statuses/update.json';
-
-    // XXX: Hack to get around PHP cURL's use of @ being a a meta character
-    $statustxt = preg_replace('/^@/', ' @', $notice->content);
-
-    $options = array(
-                     CURLOPT_USERPWD         => "$twitter_user:$twitter_password",
-                     CURLOPT_POST            => true,
-                     CURLOPT_POSTFIELDS        => array(
-                                                        'status'    => $statustxt,
-                                                        'source'    => $config['integration']['source']
-                                                        ),
-                     CURLOPT_RETURNTRANSFER    => true,
-                     CURLOPT_FAILONERROR        => true,
-                     CURLOPT_HEADER            => false,
-                     CURLOPT_FOLLOWLOCATION    => true,
-                     CURLOPT_USERAGENT        => "Laconica",
-                     CURLOPT_CONNECTTIMEOUT    => 120,  // XXX: Scary!!!! How long should this be?
-                     CURLOPT_TIMEOUT            => 120,
-
-                     # Twitter is strict about accepting invalid "Expect" headers
-                     CURLOPT_HTTPHEADER => array('Expect:')
-                     );
-
-    $ch = curl_init($uri);
-    curl_setopt_array($ch, $options);
-    $data = curl_exec($ch);
-    $errmsg = curl_error($ch);
-
-    if ($errmsg) {
-        common_debug("cURL error: $errmsg - trying to send notice for $twitter_user.",
-                     __FILE__);
-        $success = false;
-    }
-
-    curl_close($ch);
-
-    if (!$data) {
-        common_debug("No data returned by Twitter's API trying to send update for $twitter_user",
-                     __FILE__);
-        $success = false;
-    }
-
-    // Twitter should return a status
-    $status = json_decode($data);
-
-    if (!$status->id) {
-        common_debug("Unexpected data returned by Twitter API trying to send update for $twitter_user",
-                     __FILE__);
-        $success = false;
-    }
-
-    return $success;
-}
-
 // Stick the notice on the queue
 
 function common_enqueue_notice($notice)
 {
-    foreach (array('jabber', 'omb', 'sms', 'public') as $transport) {
+    foreach (array('jabber', 'omb', 'sms', 'public', 'twitter', 'facebook') as $transport) {
         $qi = new Queue_item();
         $qi->notice_id = $notice->id;
         $qi->transport = $transport;
@@ -1185,6 +886,15 @@ function common_real_broadcast($notice, $remote=false)
             common_log(LOG_ERR, 'Error in public broadcast for notice ' . $notice->id);
         }
     }
+    if ($success) {
+        $success = broadcast_twitter($notice);
+        if (!$success) {
+            common_log(LOG_ERR, 'Error in Twitter broadcast for notice ' . $notice->id);
+        }
+    }
+
+    // XXX: Do a real-time FB broadcast here?
+
     // XXX: broadcast notices to other IM
     return $success;
 }
diff --git a/lib/xmlstringer.php b/lib/xmlstringer.php
new file mode 100644 (file)
index 0000000..951b13b
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Generator for in-memory XML
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Output
+ * @package   Laconica
+ * @author    Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2009 Control Yourself, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+    exit(1);
+}
+
+/**
+ * Create in-memory XML
+ *
+ * @category Output
+ * @package  Laconica
+ * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://laconi.ca/
+ * @see      Action
+ * @see      HTMLOutputter
+ */
+
+class XMLStringer extends XMLOutputter
+{
+    function __construct($indent=false)
+    {
+        $this->xw = new XMLWriter();
+        $this->xw->openMemory();
+        $this->xw->setIndent($indent);
+    }
+
+    function getString()
+    {
+        return $this->xw->outputMemory();
+    }
+
+    // utility for quickly creating XML-strings
+
+    static function estring($tag, $attrs=null, $content=null)
+    {
+        $xs = new XMLStringer();
+        $xs->element($tag, $attrs, $content);
+        return $xs->getString();
+    }
+}
\ No newline at end of file
diff --git a/plugins/BlogspamNetPlugin.php b/plugins/BlogspamNetPlugin.php
new file mode 100644 (file)
index 0000000..d9372bc
--- /dev/null
@@ -0,0 +1,144 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Plugin to check submitted notices with blogspam.net
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category  Plugin
+ * @package   Laconica
+ * @author    Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2009 Control Yourself, Inc.
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+    exit(1);
+}
+
+define('BLOGSPAMNETPLUGIN_VERSION', '0.1');
+
+/**
+ * Plugin to check submitted notices with blogspam.net
+ *
+ * When new notices are saved, we check their text with blogspam.net (or
+ * a compatible service).
+ *
+ * Blogspam.net is supposed to catch blog comment spam, and I found that
+ * some of its tests (min/max size, bayesian match) gave a lot of false positives.
+ * So, I've turned those tests off by default. This may not get as many
+ * hits, but it's better than nothing.
+ *
+ * @category Plugin
+ * @package  Laconica
+ * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://laconi.ca/
+ *
+ * @see      Event
+ */
+
+class BlogspamNetPlugin extends Plugin
+{
+    var $baseUrl = 'http://test.blogspam.net:8888/';
+
+    function __construct($url=null)
+    {
+        parent::__construct();
+        if ($url) {
+            $this->baseUrl = $url;
+        }
+    }
+
+    function onStartNoticeSave($notice)
+    {
+        $args = $this->testArgs($notice);
+        common_debug("Blogspamnet args = " . print_r($args, TRUE));
+        $request = xmlrpc_encode_request('testComment', array($args));
+        $context = stream_context_create(array('http' => array('method' => "POST",
+                                                               'header' =>
+                                                               "Content-Type: text/xml\r\n".
+                                                               "User-Agent: " . $this->userAgent(),
+                                                               'content' => $request)));
+        $file = file_get_contents($this->baseUrl, false, $context);
+        $response = xmlrpc_decode($file);
+        if (xmlrpc_is_fault($response)) {
+            throw new ServerException("$response[faultString] ($response[faultCode])", 500);
+        } else {
+            common_debug("Blogspamnet results = " . $response);
+            if (preg_match('/^ERROR(:(.*))?$/', $response, $match)) {
+                throw new ServerException(sprintf(_("Error from %s: %s"), $this->baseUrl, $match[2]), 500);
+            } else if (preg_match('/^SPAM(:(.*))?$/', $response, $match)) {
+                throw new ClientException(sprintf(_("Spam checker results: %s"), $match[2]), 400);
+            } else if (preg_match('/^OK$/', $response)) {
+                // don't do anything
+            } else {
+                throw new ServerException(sprintf(_("Unexpected response from %s: %s"), $this->baseUrl, $response), 500);
+            }
+        }
+        return true;
+    }
+
+    function testArgs($notice)
+    {
+        $args = array();
+        $args['comment'] = $notice->content;
+        $args['ip'] = $this->getClientIP();
+
+        if (isset($_SERVER) && array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
+            $args['agent'] = $_SERVER['HTTP_USER_AGENT'];
+        }
+
+        $profile = $notice->getProfile();
+
+        if ($profile && $profile->homepage) {
+            $args['link'] = $profile->homepage;
+        }
+
+        if ($profile && $profile->fullname) {
+            $args['name'] = $profile->fullname;
+        } else {
+            $args['name'] = $profile->nickname;
+        }
+
+        $args['site'] = common_root_url();
+        $args['version'] = $this->userAgent();
+
+        $args['options'] = "max-size=140,min-size=0,min-words=0,exclude=bayasian";
+
+        return $args;
+    }
+
+    function getClientIP()
+    {
+        if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+            // Note: order matters here; use proxy-forwarded stuff first
+            foreach (array('HTTP_X_FORWARDED_FOR', 'CLIENT-IP', 'REMOTE_ADDR') as $k) {
+                if (isset($_SERVER[$k])) {
+                    return $_SERVER[$k];
+                }
+            }
+        }
+        return '127.0.0.1';
+    }
+
+    function userAgent()
+    {
+        return 'BlogspamNetPlugin/'.BLOGSPAMNETPLUGIN_VERSION . ' Laconica/' . LACONICA_VERSION;
+    }
+}
index 87a70e31ea9acf9f90f25e5f43b8091869add2b1..1ecbb664e078352fbbe7285f590bc03c13af58c0 100644 (file)
@@ -37,7 +37,7 @@ if (!defined('LACONICA')) {
  * This plugin will spoot out the correct JavaScript spell to invoke Google Analytics on a page.
  *
  * Note that Google Analytics is not compatible with the Franklin Street Statement; consider using
- * Pikiw (http://www.pikiw.org/) instead!
+ * Piwik (http://www.piwik.org/) instead!
  *
  * @category Plugin
  * @package  Laconica
diff --git a/scripts/facebookqueuehandler.php b/scripts/facebookqueuehandler.php
new file mode 100755 (executable)
index 0000000..c6859cb
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env php
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, Controlez-Vous, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+# Abort if called from a web server
+if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+    print "This script must be run from the command line\n";
+    exit();
+}
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('LACONICA', true);
+
+require_once(INSTALLDIR . '/lib/common.php');
+require_once(INSTALLDIR . '/lib/facebookutil.php');
+require_once(INSTALLDIR . '/lib/queuehandler.php');
+
+set_error_handler('common_error_handler');
+
+class FacebookQueueHandler extends QueueHandler
+{
+    
+    function transport()
+    {
+        return 'facebook';
+    }
+    
+    function start()
+    {
+        $this->log(LOG_INFO, "INITIALIZE");
+        return true;
+    }
+
+    function handle_notice($notice)
+    {
+        return facebookBroadcastNotice($notice);
+    }
+    
+    function finish()
+    {
+    }
+
+}
+
+ini_set("max_execution_time", "0");
+ini_set("max_input_time", "0");
+set_time_limit(0);
+
+mb_internal_encoding('UTF-8');
+
+$id = ($argc > 1) ? $argv[1] : null;
+
+$handler = new FacebookQueueHandler($id);
+
+$handler->runOnce();
index 685bd938fa289862898fd2357b7f0f32a29e452c..a3256966d5a27231dff79499eef69f92f6e01079 100755 (executable)
@@ -23,7 +23,8 @@
 DIR=`dirname $0`
 
 for f in xmppdaemon.php jabberqueuehandler.php publicqueuehandler.php \
-         xmppconfirmhandler.php smsqueuehandler.php ombqueuehandler.php; do
+         xmppconfirmhandler.php smsqueuehandler.php ombqueuehandler.php \
+         twitterqueuehandler.php facebookqueuehandler.php; do
 
          echo -n "Starting $f...";
         php $DIR/$f
index 08e1d4714ff8643549864575fe5cbc333f0c4d5f..fd4406d415b35f766c200c5e3dc85cf2705edde5 100755 (executable)
@@ -24,7 +24,7 @@ SDIR=`dirname $0`
 DIR=`php $SDIR/getpiddir.php`
 
 for f in jabberhandler ombhandler publichandler smshandler \
-        xmppconfirmhandler xmppdaemon; do
+        xmppconfirmhandler xmppdaemon twitterhandler facebookhandler ; do
 
        FILES="$DIR/$f.*.pid"
        for ff in "$FILES" ; do
diff --git a/scripts/twitterqueuehandler.php b/scripts/twitterqueuehandler.php
new file mode 100755 (executable)
index 0000000..7da4f1e
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env php
+<?php
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, Controlez-Vous, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+# Abort if called from a web server
+if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+    print "This script must be run from the command line\n";
+    exit();
+}
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('LACONICA', true);
+
+require_once(INSTALLDIR . '/lib/common.php');
+require_once(INSTALLDIR . '/lib/twitter.php');
+require_once(INSTALLDIR . '/lib/queuehandler.php');
+
+set_error_handler('common_error_handler');
+
+class TwitterQueueHandler extends QueueHandler
+{
+    
+    function transport()
+    {
+        return 'twitter';
+    }
+    
+    function start()
+    {
+        $this->log(LOG_INFO, "INITIALIZE");
+        return true;
+    }
+
+    function handle_notice($notice)
+    {
+        return broadcast_twitter($notice);
+    }
+    
+    function finish()
+    {
+    }
+
+}
+
+ini_set("max_execution_time", "0");
+ini_set("max_input_time", "0");
+set_time_limit(0);
+
+mb_internal_encoding('UTF-8');
+
+$id = ($argc > 1) ? $argv[1] : null;
+
+$handler = new TwitterQueueHandler($id);
+
+$handler->runOnce();
diff --git a/scripts/update_facebook.php b/scripts/update_facebook.php
deleted file mode 100755 (executable)
index 60e1041..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/env php
-<?php
-/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.     If not, see <http://www.gnu.org/licenses/>.
- */
-
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
-    print "This script must be run from the command line\n";
-    exit();
-}
-
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
-
-require_once INSTALLDIR . '/lib/common.php';
-require_once INSTALLDIR . '/lib/facebookutil.php';
-
-// For storing the last run date-time
-$last_updated_file = INSTALLDIR . '/scripts/facebook_last_updated';
-
-// Lock file name
-$lock_file = INSTALLDIR . '/scripts/update_facebook.lock';
-
-// Make sure only one copy of the script is running at a time
-$lock_file = @fopen($lock_file, "w+");
-if (!flock( $lock_file, LOCK_EX | LOCK_NB, &$wouldblock) || $wouldblock) {
-    die("Can't open lock file. Script already running?\n");
-}
-
-$facebook = getFacebook();
-$current_time = time();
-$since = getLastUpdated();
-updateLastUpdated($current_time);
-$notice = getFacebookNotices($since);
-$cnt = 0;
-
-while($notice->fetch()) {
-
-    $flink = Foreign_link::getByUserID($notice->profile_id, FACEBOOK_SERVICE);
-    $user = $flink->getUser();
-    $fbuid = $flink->foreign_id;
-    
-    if (!userCanUpdate($fbuid)) {
-        continue;
-    }
-
-    $prefix = $facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX, $fbuid);
-    $content = "$prefix $notice->content";
-    
-    if (($flink->noticesync & FOREIGN_NOTICE_SEND) == FOREIGN_NOTICE_SEND) {
-
-        // If it's not a reply, or if the user WANTS to send replies...
-        if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $content) ||
-            (($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) == FOREIGN_NOTICE_SEND_REPLY)) {
-             
-                // Avoid a Loop
-                if ($notice->source != 'Facebook') {
-                    
-                    try {
-                        $facebook->api_client->users_setStatus($content, 
-                            $fbuid, false, true);
-                        updateProfileBox($facebook, $flink, $notice);
-                        $cnt++;
-                    } catch(FacebookRestClientException $e) {
-                        print "Couldn't sent notice $notice->id!\n";
-                        print $e->getMessage();
-
-                        // Remove flink?
-                    }
-                }
-        }
-    }
-}
-
-if ($cnt > 0) {
-    print date('r', $current_time) . 
-    ": Found $cnt new notices for Facebook since last run at " . 
-     date('r', $since) . "\n";
-}
-
-fclose($lock_file);
-exit(0);
-
-
-function userCanUpdate($fbuid) {
-    
-    global $facebook;
-
-    $result = false;
-    
-    try {
-        $result = $facebook->api_client->users_hasAppPermission('status_update', $fbuid);
-    } catch(FacebookRestClientException $e){
-        print_r($e);
-    }
-
-    return $result;
-}
-
-function getLastUpdated(){
-    global $last_updated_file, $current_time;
-    $last = $current_time;
-
-    if (file_exists($last_updated_file) && 
-        ($file = fopen($last_updated_file, 'r'))) {
-            $last = fgets($file);
-    } else {
-        print "$last_updated_file doesn't exit. Trying to create it...\n";
-        $file = fopen($last_updated_file, 'w+') or 
-            die("Can't open $last_updated_file for writing!\n");
-        print 'Success. Using current time (' . date('r', $last) . 
-            ") to look for new notices.\n";
-    }
-    
-    fclose($file);
-    return $last;
-}
-
-function updateLastUpdated($time){
-    global $last_updated_file;
-    $file = fopen($last_updated_file, 'w') or
-        die("Can't open $last_updated_file for writing!");
-    fwrite($file, $time);
-    fclose($file);
-}
-
index 3b72d00ceeb85442ea428e59a1d17dd820fd47a5..5ce5ac884d0a35f80d34674e158e4d90de527973 100644 (file)
@@ -22,7 +22,6 @@ line-height:1.65;
 position:relative;
 }
 h1,h2,h3,h4,h5,h6 {
-text-transform:uppercase;
 margin-bottom:7px;
 overflow:hidden;
 }
@@ -43,7 +42,6 @@ font-weight:bold;
 legend {
 font-weight:bold;
 font-size:1.3em;
-text-transform:uppercase;
 }
 input, textarea, select, option {
 padding:4px;
diff --git a/theme/base/css/modal.css b/theme/base/css/modal.css
new file mode 100644 (file)
index 0000000..985e4ad
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..eab4637
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..c11f7af
Binary files /dev/null and b/theme/base/images/x.png differ
index 335801385d0d31aa64f2fd0eebf48a6502226eb2..4998b3c988b48b553c1fe4de0df8425f5a5ca5ba 100644 (file)
@@ -31,3 +31,6 @@ cp -r ./default ./mytheme
 nano ./mytheme/css/display.css
 
 3. Search and replace a colour or a path to the background image of your choice.
+
+4. Set /config.php to load 'mytheme':
+$config['site']['theme'] = 'mytheme';