]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'sgmurphy-clone/0.7.x' into 0.7.x
authorEvan Prodromou <evan@controlyourself.ca>
Wed, 11 Feb 2009 15:11:26 +0000 (10:11 -0500)
committerEvan Prodromou <evan@controlyourself.ca>
Wed, 11 Feb 2009 15:11:26 +0000 (10:11 -0500)
40 files changed:
actions/doc.php
actions/noticesearch.php
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
lib/feedlist.php
lib/jabber.php
lib/router.php [new file with mode: 0644]
lib/util.php

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 a5f01350c4c732bfd1fab1e87ecb8b57873c9ee5..2d94a7906fea3095832a5cef20570583084a61da 100644 (file)
@@ -78,6 +78,62 @@ class NoticesearchAction extends SearchAction
         return _('Text search');
     }
 
+
+    function showExportData()
+    {
+        $q = $this->trimmed('q');
+        if (!$q) {
+            return;
+        }
+        $fl = new FeedList($this);
+        $fl->show(array(0 => array('href' => common_local_url('noticesearchrss', array('q' => $q)),
+                                   'type' => 'rss',
+                                   'version' => 'RSS 1.0',
+                                   'item' => 'noticesearchrss')));
+    }
+
+
+
+    function showFeeds()
+    {  
+        $q = $this->trimmed('q');
+        if (!$q) {
+            return;
+        }
+
+       $this->element('link', array('rel' => 'alternate',
+                                         'href' => common_local_url('noticesearchrss',
+                                                                    array('q' => $q)),
+                                         'type' => 'application/rss+xml',
+                                         'title' => _('Search Stream Feed')));
+    }
+
+
+    /**
+     * Show header
+     *
+     * @param array $arr array containing the query
+     *
+     * @return void
+     */
+
+    function extraHead2()
+    {
+        $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 results
      *
@@ -119,26 +175,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
      *
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..717b17361d2f7f60c343cf9c9f3ad3e33b11632c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -22,69 +22,105 @@ 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 main() {
 
-$user = common_current_user();
+    global $user, $action;
 
-// initialize language env
+    // XXX: we need a little more structure in this script
 
-common_init_language();
+    // get and cache current user
 
-$action = $_REQUEST['action'];
+    $user = common_current_user();
 
-if (!$action || !preg_match('/^[a-zA-Z0-9_-]*$/', $action)) {
-    common_redirect(common_local_url('public'));
-}
+    // initialize language env
 
-// If the site is private, and they're not on one of the "public"
-// parts of the site, redirect to login
+    common_init_language();
 
-if (!$user && common_config('site', 'private') &&
-    !in_array($action, array('login', 'openidlogin', 'finishopenidlogin',
-                             'recoverpassword', 'api', 'doc', 'register'))) {
-    common_redirect(common_local_url('login'));
-}
+    $path = getPath($_REQUEST);
+
+    $r = Router::get();
 
-$action_class = ucfirst($action).'Action';
+    $args = $r->map($path);
 
-if (!class_exists($action_class)) {
-    $cac = new ClientErrorAction(_('Unknown action'), 404);
-    $cac->showPage();
-} else {
-    $action_obj = new $action_class();
+    if (!$args) {
+        $cac = new ClientErrorAction(_('Unknown page'), 404);
+        $cac->showPage();
+        return;
+    }
 
-    // XXX: find somewhere for this little block to live
+    $args = array_merge($args, $_REQUEST);
 
-    if ($config['db']['mirror'] && $action_obj->isReadOnly()) {
-        if (is_array($config['db']['mirror'])) {
-            // "load balancing", ha ha
-            $k = array_rand($config['db']['mirror']);
+    $action = $args['action'];
 
-            $mirror = $config['db']['mirror'][$k];
-        } else {
-            $mirror = $config['db']['mirror'];
-        }
-        $config['db']['database'] = $mirror;
+    if (!$action || !preg_match('/^[a-zA-Z0-9_-]*$/', $action)) {
+        common_redirect(common_local_url('public'));
+        return;
     }
 
-    try {
-        if ($action_obj->prepare($_REQUEST)) {
-            $action_obj->handle($_REQUEST);
-        }
-    } catch (ClientException $cex) {
-        $cac = new ClientErrorAction($cex->getMessage(), $cex->getCode());
+    // 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
 
index 47d909e969c1ac51986f7448e7c3996630ff4c7d..8bfcb9c5ab37bd53f174efbc0cdcee13620d282b 100644 (file)
@@ -112,6 +112,13 @@ class FeedList extends Widget
             $feed['textContent'] = "Atom";
             break;
 
+         case 'noticesearchrss':
+            $feed_classname = $feed['type'];
+            $feed_mimetype = "application/".$feed['type']."+xml";
+            $feed_title = $feed['version']." feed for this notice search";
+            $feed['textContent'] = "RSS";
+            break;
+
          case 'tagrss':
             $feed_classname = $feed['type'];
             $feed_mimetype = "application/".$feed['type']."+xml";
index f41d984d6261a46698f11cf27de238d8698e3ce1..b385d3c5cc5412e050d281bcb50d54809511b87d 100644 (file)
@@ -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";
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 a130c7d49cc8d3d57a6e6a7b3ba6c26c68fb3564..c0c98011166c26b99a8b3d0aea6867cad9a2180d 100644 (file)
@@ -672,275 +672,22 @@ function common_relative_profile($sender, $nickname, $dt=null)
 
 function common_local_url($action, $args=null, $fragment=null)
 {
-    $url = null;
+    common_debug("Action = $action, args = " . (($args) ? '(' . implode($args, ',') . ')' : $args) . ", fragment = $fragment");
+    $r = Router::get();
+    $start = microtime();
+    $path = $r->build($action, $args, $fragment);
+    $end = microtime();
+    common_debug("Pathbuilding took " . ($end - $start));
+    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;