]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Removing unnecessary require_once lines (autoload!)
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 9 Sep 2013 21:05:33 +0000 (23:05 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 9 Sep 2013 21:06:56 +0000 (23:06 +0200)
59 files changed:
actions/apiaccountratelimitstatus.php
actions/apiaccountupdatedeliverydevice.php
actions/apiaccountupdateprofile.php
actions/apiaccountupdateprofileimage.php
actions/apiaccountverifycredentials.php
actions/apiatomservice.php
actions/apiblockcreate.php
actions/apiblockdestroy.php
actions/apiconversation.php
actions/apidirectmessage.php
actions/apidirectmessagenew.php
actions/apifavoritecreate.php
actions/apifavoritedestroy.php
actions/apifriendshipscreate.php
actions/apifriendshipsdestroy.php
actions/apifriendshipsshow.php
actions/apigroupcreate.php
actions/apigroupismember.php
actions/apigroupjoin.php
actions/apigroupleave.php
actions/apigrouplist.php
actions/apigroupprofileupdate.php
actions/apilist.php
actions/apilistmember.php
actions/apilistmemberships.php
actions/apilists.php
actions/apilistsubscriber.php
actions/apilistsubscriptions.php
actions/apimediaupload.php
actions/apistatusesdestroy.php
actions/apistatusesretweet.php
actions/apistatusesretweets.php
actions/apistatusesupdate.php
actions/apisubscriptions.php
actions/apitimelinefavorites.php
actions/apitimelinefriends.php
actions/apitimelinehome.php
actions/apitimelinementions.php
actions/apitimelineretweetedbyme.php
actions/apitimelineretweetedtome.php
actions/apitimelineretweetsofme.php
actions/apitimelineuser.php
actions/apiuserfollowers.php
actions/apiuserfriends.php
actions/atompubfavoritefeed.php
actions/atompubmembershipfeed.php
actions/atompubshowfavorite.php
actions/atompubshowmembership.php
actions/atompubshowsubscription.php
actions/atompubsubscriptionfeed.php
actions/newnotice.php
lib/apiauth.php [deleted file]
lib/apiauthaction.php [new file with mode: 0644]
lib/apibareauth.php [deleted file]
lib/apibareauthaction.php [new file with mode: 0644]
lib/apilistusers.php
lib/apiprivateauth.php
lib/mailhandler.php
plugins/Bookmark/actions/apitimelinebookmarks.php

index 8490e2965c87bad502750611157a916c68426184..0883425513fa2f4584fdc59dffede0cd0cbabf17 100644 (file)
@@ -35,8 +35,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * We don't have a rate limit, but some clients check this method.
  * It always returns the same thing: 150 hits left.
index 57e4fbfa00f3f7ef1ab0f1573988cc83e73a6428..dd0c40445647585233d0cd6945d014eb46504abf 100644 (file)
@@ -32,8 +32,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Sets which channel (device) StatusNet delivers updates to for
  * the authenticating user. Sending none as the device parameter
index 15b13c0f20b3c62cda9e6fb298eefb1f3816df53..04151ec01eb8aacc095668eaf029d618dd3784c2 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * API analog to the profile settings page
  * Only the parameters specified will be updated.
index 3bf064ea891a90737dd260c2875f6bfe8ffc766f..07cafbdb99bbf3f73350040d85f83123595f1215 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Updates the authenticating user's profile image. Note that this API method
  * expects raw multipart data, not a URL to an image.
index 359939b0cc9b8b78201187c6bc5a3e7482a1193b..ccb3bd7a600258da358ffd5d6fb51a2f1c27fa7d 100644 (file)
@@ -33,8 +33,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Check a user's credentials. Returns an HTTP 200 OK response code and a
  * representation of the requesting user if authentication was successful;
index 5d786723e95602cb95b9ec73857735528765ffe9..8267c38b839e9b8db712cb8ac756759327d3f347 100644 (file)
@@ -27,7 +27,9 @@
  * @link      http://status.net/
  */
 
-require_once INSTALLDIR.'/lib/apibareauth.php';
+if (!defined('STATUSNET')) {
+    exit(1);
+}
 
 /**
  * Shows an AtomPub service document for a user
index 766d91bd41d8fe9ed63c75da3caa40b2a8d4b17a..bb0d7228896662551194e390d4404c2d91cb1230 100644 (file)
@@ -32,8 +32,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Blocks the user specified in the ID parameter as the authenticating user.
  * Destroys a friendship to the blocked user if it exists. Returns the
index 7dd0859e9c8a192bfc375531cc2c6d3f05d07b0c..535c7a10ab6e902d997c4264e016e746d3932504 100644 (file)
@@ -32,8 +32,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Un-blocks the user specified in the ID parameter for the authenticating user.
  * Returns the un-blocked user in the requested format when successful.
index 23ddf02c5d60063cd0c81379f83bf20db410c84f..b3b44c77219b415f1cbe1dfa53a8fa45ffad5871 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Show a stream of notices in a particular conversation
  *
index 584decc74799cf8cd2ffcfa81d1738bed8219e43..308d143f27a68102a9e0deb7982f900fca10c3a6 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Show a list of direct messages from or to the authenticating user
  *
index d642252b4dc1864eb8052458b4999b0b344474e7..6d637fcb46461c9b27839460841f4ef155d78ead 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Creates a new direct message from the authenticating user to
  * the user specified by id.
index 26e4325e656bfe63f053c05e647c8a81695687ff..607fb76edc3dcc931442e8c102fec990cda8ca29 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Favorites the status specified in the ID parameter as the authenticating user.
  * Returns the favorite status when successful.
index af1b4075f645d83b27eb66c14ba0ea4b78995e72..02f81cf4dfe25f9ea0b315d5bd2a929afc9ae44a 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Un-favorites the status specified in the ID parameter as the authenticating user.
  * Returns the un-favorited status in the requested format when successful.
index 993280981845331e8f95206f93272d33fc931737..acafbb964b372a86b595bbcba8758b76aeb2c8ba 100644 (file)
@@ -33,8 +33,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Allows the authenticating users to follow (subscribe) the user specified in
  * the ID parameter.  Returns the befriended user in the requested format when
index 1534aa799f482119b9c16908dd215191b40392ac..5f7c85e0aff62bd725a48f634e81e67237fca7b2 100644 (file)
@@ -33,8 +33,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Allows the authenticating users to unfollow (unsubscribe) the user specified in
  * the ID parameter.  Returns the unfollowed user in the requested format when
index bf7e7daf62100ffd3c2d6b7707e47b1260dea5be..58e610ecdb529f8dec5d5ba10e6d2321cf2f4831 100644 (file)
@@ -33,8 +33,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Outputs detailed information about the relationship between two users
  *
index 295962896d580355d77292220986d926fa766ff7..6992da9db985c0a5b71f130e39b9aa2a62d4296f 100644 (file)
@@ -35,8 +35,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Make a new group. Sets the authenticated user as the administrator of the group.
  *
index 13ed9e1fbf059a0b0897fc17e3e318d9d75d727b..c9a363582b75b4f8bda6bb6f555c585dd8f155dc 100644 (file)
@@ -35,8 +35,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Returns whether a user is a member of a specified group.
  *
index 6f3df0d8cd17a7274921c1f14cf65964b5654e28..e18e20c5dd3bc2496cc02af15d0cdc5b22b279a9 100644 (file)
@@ -35,8 +35,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Joins the authenticated user to the group speicified by ID
  *
index 9d2825b00e25ea9add0652731909ef1d7ced6ef7..bdfa36aa432bf682623a09bd6e82f9e44a80e32f 100644 (file)
@@ -35,8 +35,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Removes the authenticated user from the group specified by ID
  *
index c7518ca129fb39dfc314fed08a00fc7382bdd6e0..a3fc3fc43573eface1437988d14726234b6a02d8 100644 (file)
@@ -35,8 +35,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Returns whether a user is a member of a specified group.
  *
index eb47fa2512f93b1095d20f4b9746d7f5199cb3f2..73b3823e365bd380bc1da930b79c2114948d1776 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * API analog to the group edit page
  *
index 90cbfddb6984a9ad500dee70401caa57fc59bf3b..56d0f0f1bc14452d3eeea54d9566c77242f1f20e 100644 (file)
@@ -30,8 +30,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 class ApiListAction extends ApiBareAuthAction
 {
     /**
index 8e6a84c96d16167b426d373914d9f0cfedebf727..1d56a3dbc7a22a4f1b5f225fc8afb1e609bc30cd 100644 (file)
@@ -30,8 +30,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Action handler for Twitter list_memeber methods
  *
index 3d235c5d9379746cd13cd083a0b79c7892ff7efc..9dc48fa8d45d0b13482313144c962daa288ab786 100644 (file)
@@ -30,8 +30,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Action handler for API method to list lists a user belongs to.
  * (people tags for a user)
index 5eab3e6a1f3e500befd0b9d01ed0468e92a7c979..529bdd67856e0616d8d896bf8b73be8519c60dfd 100644 (file)
@@ -30,8 +30,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Action handler for Twitter list_memeber methods
  *
index cd10568e1b3fb9c2cc6de471f5d11035f4b8753c..9d7fde329f3ec6a474ea14b65dac42f4f7aa691a 100644 (file)
@@ -29,8 +29,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 class ApiListSubscriberAction extends ApiBareAuthAction
 {
     var $list   = null;
index 480523033bbf9d119cb58bc2b0c1da8d4199c90d..263d00ca3009a82751365c925415ca3c87c5d196 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 class ApiListSubscriptionsAction extends ApiBareAuthAction
 {
     var $lists = array();
index 0b08dbedf1bc1dec517b0e8e26307ca1e9e4d280..9c888ce3ed138e139fec48be0e497c46717cc942 100644 (file)
@@ -30,9 +30,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
 /**
  * Upload an image via the API.  Returns a shortened URL for the image
  * to the user.
index 1f97b1a9de72a8bc00798cfe31189ba98cbb5750..db41c87ad0f5cca2f443d4e247e53e5df1bf8959 100644 (file)
@@ -38,8 +38,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Deletes one of the authenticating user's statuses (notices).
  *
index feed505fb23c566aad57dbe4af1c41ca6da1caa9..ee391fdb4adc33ce02b6944ac3d9f79c27163679 100644 (file)
@@ -31,9 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
 /**
  * Repeat a notice through the API
  *
index 3a1a43bc63124b2e87c6dee19e13cdeea0ddea8b..7af4cd3ec6649959832917de0019e43188df2ee0 100644 (file)
@@ -31,9 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
 /**
  * Show up to 100 repeats of a notice
  *
index 9144f09002001be66f27f2b9108b3596f3151d01..7209ae33335a942d0a86bedc408d0f08ff5140b9 100644 (file)
@@ -129,9 +129,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
 /**
  * Updates the authenticating user's status (posts a notice).
  *
index 84731ac00fff4a46bf471cca286f756247bbdd6e..be53086ee4001f46a54c079613f3117e1c1026c5 100644 (file)
@@ -33,8 +33,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * This class outputs a list of profiles as Twitter-style user and status objects.
  * It is used by the API methods /api/statuses/(friends|followers). To support the
index e2cb7c2ee2f8481221c42500b664959b2893d5e1..7e8dd7aad6e6bb0fefb058acb9dc111961072bdc 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/lib/apibareauth.php';
-
 /**
  * Returns the 20 most recent favorite notices for the authenticating user or user
  * specified by the ID parameter in the requested format.
index 591baccfccfba26713cf40c018d10a7be0927cad..ed4cce490812714d2464e97019817e57f03e41c0 100644 (file)
@@ -133,8 +133,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Returns the most recent notices (default 20) posted by the target user.
  * This is the equivalent of 'You and friends' page accessed via Web.
index 22c6cc5f944b6f3ee481e479fca84d1bcea63b84..1ca74b208e7bc261780d2237d4a140282c640af6 100644 (file)
@@ -38,8 +38,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Returns the most recent notices (default 20) posted by the target user.
  * This is the equivalent of 'You and friends' page accessed via Web.
index 07fbdf0b674a3f6cb93a29c3638da21afa6c00e9..4ba8a4966b195a33043eb6e68219e25571e77111 100644 (file)
@@ -38,8 +38,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Returns the most recent (default 20) mentions (status containing @nickname)
  *
index 5fe9609159210aff303e007fe74016a92da50682..01f3fe378b17bc948aadbaf587fa0774187e60e6 100644 (file)
@@ -31,9 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
 /**
  * Show authenticating user's most recent repeats
  *
index 2ea84f16e3f839d6477a3eb125d8330131ca2662..85f52f7388f88c27314534c8c1736b6a4587b74d 100644 (file)
@@ -31,8 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Show most recent notices that are repeats in user's inbox
  *
index d01db87b937172dec45d61164633237c9960004e..fe90213665074e7e6b4e430946c22200c4c6925e 100644 (file)
@@ -31,9 +31,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
 /**
  * Show authenticating user's most recent notices that have been repeated
  *
index 19e1a52d15509131f15c6fe1cfe413b17025ca98..2540c036c141b112d7f496ef6166cc656a95a64c 100644 (file)
@@ -38,8 +38,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Returns the most recent notices (default 20) posted by the authenticating
  * user. Another user's timeline can be requested via the id parameter. This
index a5a429259d97043c198d327a4b137e76b57bddee..61d743e27c1356919183f960fe730fb55b57ebb0 100644 (file)
@@ -33,8 +33,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Ouputs the authenticating user's followers (subscribers), each with
  * current Twitter-style status inline.  They are ordered by the order
index b77d08097c2171d012ac1657d56d1a8624fa4f15..be6ccba273c5d587b426afc68bff4d57583d700d 100644 (file)
@@ -33,8 +33,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Ouputs the authenticating user's friends (subscriptions), each with
  * current Twitter-style status inline.  They are ordered by the date
index 8d5fde815062bf69a342355b36caaed933e708e7..837a9da3e96d7784ad3921c20560e6b38773e50f 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Feed of ActivityStreams 'favorite' actions
  *
index 57d7317eefe38bb9714ad7d4f26ef8c248379e17..e5ca8b0a5a3251d7241fe0f2122a41c100cecffb 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Feed of group memberships for a user, in ActivityStreams format
  *
index d8f371a39cedd4b2a15da12a1753949e75ab08fb..436e88e6939e548f3e7b9ce0dd1a00bfc4b48279 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Show a single favorite in Atom Activity Streams format.
  *
index 025e2cb83eea6067a8871b032e5bc8812baa353f..ad6aa6c1d05db3bf00bf0ec3bff912a01a27235a 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Show (or delete) a single membership event as an ActivityStreams entry
  *
index 4dbb2af2e0d553fcd55e5799fb35ccd375f0d08a..ec3949c4d839deb54d44493ef20cf34150ea39c7 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Show a single subscription
  *
index 744a970d602a6dd5c0bc70a8c34f9723d88da8bb..1b9f4b98a573be7fe9b4545b4159eac01df3ef7f 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Subscription feed class for AtomPub
  *
index 9ac8d46b6e7fbac8ec62bbbc8290b3ee717a122d..1c8f956b5d80bef41bf40916ab6347149608a451 100644 (file)
@@ -34,9 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/noticelist.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
-
 /**
  * Action for posting new notices
  *
diff --git a/lib/apiauth.php b/lib/apiauth.php
deleted file mode 100644 (file)
index 499c502..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Base class for API actions that require authentication
- *
- * 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  API
- * @package   StatusNet
- * @author    Adrian Lang <mail@adrianlang.de>
- * @author    Brenda Wallace <shiny@cpan.org>
- * @author    Craig Andrews <candrews@integralblue.com>
- * @author    Dan Moore <dan@moore.cx>
- * @author    Evan Prodromou <evan@status.net>
- * @author    mEDI <medi@milaro.net>
- * @author    Sarven Capadisli <csarven@status.net>
- * @author    Zach Copley <zach@status.net>
- * @copyright 2009-2010 StatusNet, Inc.
- * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
- * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://status.net/
- */
-
-/* External API usage documentation. Please update when you change how this method works. */
-
-/*! @page authentication Authentication
-
-    StatusNet supports HTTP Basic Authentication and OAuth for API calls.
-
-    @warning Currently, users who have created accounts without setting a
-    password via OpenID, Facebook Connect, etc., cannot use the API until
-    they set a password with their account settings panel.
-
-    @section HTTP Basic Auth
-
-
-
-    @section OAuth
-
-*/
-
-if (!defined('STATUSNET')) {
-    exit(1);
-}
-
-require_once INSTALLDIR . '/lib/apioauth.php';
-
-/**
- * Actions extending this class will require auth
- *
- * @category API
- * @package  StatusNet
- * @author   Zach Copley <zach@status.net>
- * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://status.net/
- */
-class ApiAuthAction extends ApiAction
-{
-    var $auth_user_nickname = null;
-    var $auth_user_password = null;
-
-    /**
-     * Take arguments for running, looks for an OAuth request,
-     * and outputs basic auth header if needed
-     *
-     * @param array $args $_REQUEST args
-     *
-     * @return boolean success flag
-     *
-     */
-    function prepare($args)
-    {
-        parent::prepare($args);
-
-        // NOTE: $this->auth_user has to get set in prepare(), not handle(),
-        // because subclasses do stuff with it in their prepares.
-
-        $oauthReq = $this->getOAuthRequest();
-
-        if (!$oauthReq) {
-            if ($this->requiresAuth()) {
-                $this->checkBasicAuthUser(true);
-            } else {
-                // Check to see if a basic auth user is there even
-                // if one's not required
-                $this->checkBasicAuthUser(false);
-            }
-        } else {
-            $this->checkOAuthRequest($oauthReq);
-        }
-
-        // NOTE: Make sure we're scoped properly based on the auths!
-        if (isset($this->auth_user) && !empty($this->auth_user)) {
-            $this->scoped = $this->auth_user->getProfile();
-        } else {
-            $this->scoped = null;
-        }
-
-        // Reject API calls with the wrong access level
-
-        if ($this->isReadOnly($args) == false) {
-            if ($this->access != self::READ_WRITE) {
-                // TRANS: Client error 401.
-                $msg = _('API resource requires read-write access, ' .
-                         'but you only have read access.');
-                $this->clientError($msg, 401, $this->format);
-                exit;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     * Determine whether the request is an OAuth request.
-     * This is to avoid doign any unnecessary DB lookups.
-     *
-     * @return mixed the OAuthRequest or false
-     */
-    function getOAuthRequest()
-    {
-        ApiOauthAction::cleanRequest();
-
-        $req  = OAuthRequest::from_request();
-
-        $consumer    = $req->get_parameter('oauth_consumer_key');
-        $accessToken = $req->get_parameter('oauth_token');
-
-        // XXX: Is it good enough to assume it's not meant to be an
-        // OAuth request if there is no consumer or token? --Z
-
-        if (empty($consumer) || empty($accessToken)) {
-            return false;
-        }
-
-        return $req;
-    }
-
-    /**
-     * Verifies the OAuth request signature, sets the auth user
-     * and access type (read-only or read-write)
-     *
-     * @param OAuthRequest $request the OAuth Request
-     *
-     * @return nothing
-     */
-    function checkOAuthRequest($request)
-    {
-        $datastore   = new ApiStatusNetOAuthDataStore();
-        $server      = new OAuthServer($datastore);
-        $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
-
-        $server->add_signature_method($hmac_method);
-
-        try {
-            $server->verify_request($request);
-
-            $consumer     = $request->get_parameter('oauth_consumer_key');
-            $access_token = $request->get_parameter('oauth_token');
-
-            $app = Oauth_application::getByConsumerKey($consumer);
-
-            if (empty($app)) {
-                common_log(
-                    LOG_WARNING,
-                    'API OAuth - Couldn\'t find the OAuth app for consumer key: ' .
-                    $consumer
-                );
-                // TRANS: OAuth exception thrown when no application is found for a given consumer key.
-                throw new OAuthException(_('No application for that consumer key.'));
-            }
-
-            // set the source attr
-            if ($app->name != 'anonymous') {
-                $this->source = $app->name;
-            }
-
-
-            $appUser = Oauth_application_user::getKV('token', $access_token);
-
-            if (!empty($appUser)) {
-                // If access_type == 0 we have either a request token
-                // or a bad / revoked access token
-
-                if ($appUser->access_type != 0) {
-                    // Set the access level for the api call
-                    $this->access = ($appUser->access_type & Oauth_application::$writeAccess)
-                      ? self::READ_WRITE : self::READ_ONLY;
-
-                    // Set the auth user
-                    if (Event::handle('StartSetApiUser', array(&$user))) {
-                        $user = User::getKV('id', $appUser->profile_id);
-                        if (!empty($user)) {
-                            if (!$user->hasRight(Right::API)) {
-                                // TRANS: Authorization exception thrown when a user without API access tries to access the API.
-                                throw new AuthorizationException(_('Not allowed to use API.'));
-                            }
-                        }
-                        $this->auth_user = $user;
-                        // FIXME: setting the value returned by common_current_user()
-                        // There should probably be a better method for this. common_set_user()
-                        // does lots of session stuff.
-                        global $_cur;
-                        $_cur = $this->auth_user;
-                        Event::handle('EndSetApiUser', array($user)); 
-                    }
-
-                    $msg = "API OAuth authentication for user '%s' (id: %d) on behalf of " .
-                        "application '%s' (id: %d) with %s access.";
-
-                    common_log(
-                        LOG_INFO,
-                        sprintf(
-                            $msg,
-                            $this->auth_user->nickname,
-                            $this->auth_user->id,
-                            $app->name,
-                            $app->id,
-                            ($this->access = self::READ_WRITE) ? 'read-write' : 'read-only'
-                        )
-                    );
-                } else {
-                    // TRANS: OAuth exception given when an incorrect access token was given for a user.
-                    throw new OAuthException(_('Bad access token.'));
-                }
-            } else {
-                // Also should not happen.
-                // TRANS: OAuth exception given when no user was found for a given token (no token was found).
-                throw new OAuthException(_('No user for that token.'));
-            }
-
-        } catch (OAuthException $e) {
-            $this->logAuthFailure($e->getMessage());
-            common_log(LOG_WARNING, 'API OAuthException - ' . $e->getMessage());
-            $this->clientError($e->getMessage(), 401, $this->format);
-            exit;
-        }
-    }
-
-    /**
-     * Does this API resource require authentication?
-     *
-     * @return boolean true
-     */
-    function requiresAuth()
-    {
-        return true;
-    }
-
-    /**
-     * Check for a user specified via HTTP basic auth. If there isn't
-     * one, try to get one by outputting the basic auth header.
-     *
-     * @return boolean true or false
-     */
-    function checkBasicAuthUser($required = true)
-    {
-        $this->basicAuthProcessHeader();
-
-        $realm = common_config('api', 'realm');
-
-        if (empty($realm)) {
-            $realm = common_config('site', 'name') . ' API';
-        }
-
-        if (empty($this->auth_user_nickname) && $required) {
-            header('WWW-Authenticate: Basic realm="' . $realm . '"');
-
-            // show error if the user clicks 'cancel'
-            // TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel".
-            $this->clientError(_('Could not authenticate you.'), 401, $this->format);
-            exit;
-
-        } else {
-
-            $user = common_check_user($this->auth_user_nickname,
-                                      $this->auth_user_password);
-
-            if (Event::handle('StartSetApiUser', array(&$user))) {
-
-                if (!empty($user)) {
-                    if (!$user->hasRight(Right::API)) {
-                        // TRANS: Authorization exception thrown when a user without API access tries to access the API.
-                        throw new AuthorizationException(_('Not allowed to use API.'));
-                    }
-                    $this->auth_user = $user;
-                }
-
-                Event::handle('EndSetApiUser', array($user));
-            }
-
-            // By default, basic auth users have rw access
-            $this->access = self::READ_WRITE;
-
-            if (empty($this->auth_user) && ($required || isset($_SERVER['PHP_AUTH_USER']))) {
-                $msg = sprintf(
-                    "basic auth nickname = %s",
-                    $this->auth_user_nickname
-                );
-                $this->logAuthFailure($msg);
-                // TRANS: Client error thrown when authentication fails.
-                $this->clientError(_('Could not authenticate you.'), 401, $this->format);
-                exit;
-            }
-        }
-    }
-
-    /**
-     * Read the HTTP headers and set the auth user.  Decodes HTTP_AUTHORIZATION
-     * param to support basic auth when PHP is running in CGI mode.
-     *
-     * @return void
-     */
-    function basicAuthProcessHeader()
-    {
-        $authHeaders = array('AUTHORIZATION',
-                             'HTTP_AUTHORIZATION',
-                             'REDIRECT_HTTP_AUTHORIZATION'); // rewrite for CGI
-        $authorization_header = null;
-        foreach ($authHeaders as $header) {
-            if (isset($_SERVER[$header])) {
-                $authorization_header = $_SERVER[$header];
-                break;
-            }
-        }
-
-        if (isset($_SERVER['PHP_AUTH_USER'])) {
-            $this->auth_user_nickname = $_SERVER['PHP_AUTH_USER'];
-            $this->auth_user_password = $_SERVER['PHP_AUTH_PW'];
-        } elseif (isset($authorization_header)
-            && strstr(substr($authorization_header, 0, 5), 'Basic')) {
-
-            // Decode the HTTP_AUTHORIZATION header on php-cgi server self
-            // on fcgid server the header name is AUTHORIZATION
-            $auth_hash = base64_decode(substr($authorization_header, 6));
-            list($this->auth_user_nickname,
-                 $this->auth_user_password) = explode(':', $auth_hash);
-
-            // Set all to null on a empty basic auth request
-
-            if (empty($this->auth_user_nickname)) {
-                $this->auth_user_nickname = null;
-                $this->auth_password = null;
-            }
-        }
-    }
-
-    /**
-     * Log an API authentication failure. Collect the proxy and IP
-     * and log them
-     *
-     * @param string $logMsg additional log message
-     */
-     function logAuthFailure($logMsg)
-     {
-        list($proxy, $ip) = common_client_ip();
-
-        $msg = sprintf(
-            'API auth failure (proxy = %1$s, ip = %2$s) - ',
-            $proxy,
-            $ip
-        );
-
-        common_log(LOG_WARNING, $msg . $logMsg);
-     }
-}
diff --git a/lib/apiauthaction.php b/lib/apiauthaction.php
new file mode 100644 (file)
index 0000000..3edcda4
--- /dev/null
@@ -0,0 +1,376 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Base class for API actions that require authentication
+ *
+ * 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  API
+ * @package   StatusNet
+ * @author    Adrian Lang <mail@adrianlang.de>
+ * @author    Brenda Wallace <shiny@cpan.org>
+ * @author    Craig Andrews <candrews@integralblue.com>
+ * @author    Dan Moore <dan@moore.cx>
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    mEDI <medi@milaro.net>
+ * @author    Sarven Capadisli <csarven@status.net>
+ * @author    Zach Copley <zach@status.net>
+ * @copyright 2009-2010 StatusNet, Inc.
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://status.net/
+ */
+
+/* External API usage documentation. Please update when you change how this method works. */
+
+/*! @page authentication Authentication
+
+    StatusNet supports HTTP Basic Authentication and OAuth for API calls.
+
+    @warning Currently, users who have created accounts without setting a
+    password via OpenID, Facebook Connect, etc., cannot use the API until
+    they set a password with their account settings panel.
+
+    @section HTTP Basic Auth
+
+
+
+    @section OAuth
+
+*/
+
+if (!defined('STATUSNET')) {
+    exit(1);
+}
+
+require_once INSTALLDIR . '/lib/apioauth.php';
+
+/**
+ * Actions extending this class will require auth
+ *
+ * @category API
+ * @package  StatusNet
+ * @author   Zach Copley <zach@status.net>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://status.net/
+ */
+class ApiAuthAction extends ApiAction
+{
+    var $auth_user_nickname = null;
+    var $auth_user_password = null;
+
+    /**
+     * Take arguments for running, looks for an OAuth request,
+     * and outputs basic auth header if needed
+     *
+     * @param array $args $_REQUEST args
+     *
+     * @return boolean success flag
+     *
+     */
+    function prepare($args)
+    {
+        parent::prepare($args);
+
+        // NOTE: $this->auth_user has to get set in prepare(), not handle(),
+        // because subclasses do stuff with it in their prepares.
+
+        $oauthReq = $this->getOAuthRequest();
+
+        if (!$oauthReq) {
+            if ($this->requiresAuth()) {
+                $this->checkBasicAuthUser(true);
+            } else {
+                // Check to see if a basic auth user is there even
+                // if one's not required
+                $this->checkBasicAuthUser(false);
+            }
+        } else {
+            $this->checkOAuthRequest($oauthReq);
+        }
+
+        // NOTE: Make sure we're scoped properly based on the auths!
+        $this->scoped = $this->auth_user->getProfile();
+
+        // Reject API calls with the wrong access level
+
+        if ($this->isReadOnly($args) == false) {
+            if ($this->access != self::READ_WRITE) {
+                // TRANS: Client error 401.
+                $msg = _('API resource requires read-write access, ' .
+                         'but you only have read access.');
+                $this->clientError($msg, 401, $this->format);
+                exit;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Determine whether the request is an OAuth request.
+     * This is to avoid doign any unnecessary DB lookups.
+     *
+     * @return mixed the OAuthRequest or false
+     */
+    function getOAuthRequest()
+    {
+        ApiOauthAction::cleanRequest();
+
+        $req  = OAuthRequest::from_request();
+
+        $consumer    = $req->get_parameter('oauth_consumer_key');
+        $accessToken = $req->get_parameter('oauth_token');
+
+        // XXX: Is it good enough to assume it's not meant to be an
+        // OAuth request if there is no consumer or token? --Z
+
+        if (empty($consumer) || empty($accessToken)) {
+            return false;
+        }
+
+        return $req;
+    }
+
+    /**
+     * Verifies the OAuth request signature, sets the auth user
+     * and access type (read-only or read-write)
+     *
+     * @param OAuthRequest $request the OAuth Request
+     *
+     * @return nothing
+     */
+    function checkOAuthRequest($request)
+    {
+        $datastore   = new ApiStatusNetOAuthDataStore();
+        $server      = new OAuthServer($datastore);
+        $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
+
+        $server->add_signature_method($hmac_method);
+
+        try {
+            $server->verify_request($request);
+
+            $consumer     = $request->get_parameter('oauth_consumer_key');
+            $access_token = $request->get_parameter('oauth_token');
+
+            $app = Oauth_application::getByConsumerKey($consumer);
+
+            if (empty($app)) {
+                common_log(
+                    LOG_WARNING,
+                    'API OAuth - Couldn\'t find the OAuth app for consumer key: ' .
+                    $consumer
+                );
+                // TRANS: OAuth exception thrown when no application is found for a given consumer key.
+                throw new OAuthException(_('No application for that consumer key.'));
+            }
+
+            // set the source attr
+            if ($app->name != 'anonymous') {
+                $this->source = $app->name;
+            }
+
+
+            $appUser = Oauth_application_user::getKV('token', $access_token);
+
+            if (!empty($appUser)) {
+                // If access_type == 0 we have either a request token
+                // or a bad / revoked access token
+
+                if ($appUser->access_type != 0) {
+                    // Set the access level for the api call
+                    $this->access = ($appUser->access_type & Oauth_application::$writeAccess)
+                      ? self::READ_WRITE : self::READ_ONLY;
+
+                    // Set the auth user
+                    if (Event::handle('StartSetApiUser', array(&$user))) {
+                        $user = User::getKV('id', $appUser->profile_id);
+                        if (!empty($user)) {
+                            if (!$user->hasRight(Right::API)) {
+                                // TRANS: Authorization exception thrown when a user without API access tries to access the API.
+                                throw new AuthorizationException(_('Not allowed to use API.'));
+                            }
+                        }
+                        $this->auth_user = $user;
+                        // FIXME: setting the value returned by common_current_user()
+                        // There should probably be a better method for this. common_set_user()
+                        // does lots of session stuff.
+                        global $_cur;
+                        $_cur = $this->auth_user;
+                        Event::handle('EndSetApiUser', array($user)); 
+                    }
+
+                    $msg = "API OAuth authentication for user '%s' (id: %d) on behalf of " .
+                        "application '%s' (id: %d) with %s access.";
+
+                    common_log(
+                        LOG_INFO,
+                        sprintf(
+                            $msg,
+                            $this->auth_user->nickname,
+                            $this->auth_user->id,
+                            $app->name,
+                            $app->id,
+                            ($this->access = self::READ_WRITE) ? 'read-write' : 'read-only'
+                        )
+                    );
+                } else {
+                    // TRANS: OAuth exception given when an incorrect access token was given for a user.
+                    throw new OAuthException(_('Bad access token.'));
+                }
+            } else {
+                // Also should not happen.
+                // TRANS: OAuth exception given when no user was found for a given token (no token was found).
+                throw new OAuthException(_('No user for that token.'));
+            }
+
+        } catch (OAuthException $e) {
+            $this->logAuthFailure($e->getMessage());
+            common_log(LOG_WARNING, 'API OAuthException - ' . $e->getMessage());
+            $this->clientError($e->getMessage(), 401, $this->format);
+            exit;
+        }
+    }
+
+    /**
+     * Does this API resource require authentication?
+     *
+     * @return boolean true
+     */
+    function requiresAuth()
+    {
+        return true;
+    }
+
+    /**
+     * Check for a user specified via HTTP basic auth. If there isn't
+     * one, try to get one by outputting the basic auth header.
+     *
+     * @return boolean true or false
+     */
+    function checkBasicAuthUser($required = true)
+    {
+        $this->basicAuthProcessHeader();
+
+        $realm = common_config('api', 'realm');
+
+        if (empty($realm)) {
+            $realm = common_config('site', 'name') . ' API';
+        }
+
+        if (empty($this->auth_user_nickname) && $required) {
+            header('WWW-Authenticate: Basic realm="' . $realm . '"');
+
+            // show error if the user clicks 'cancel'
+            // TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel".
+            $this->clientError(_('Could not authenticate you.'), 401, $this->format);
+            exit;
+
+        } else {
+
+            $user = common_check_user($this->auth_user_nickname,
+                                      $this->auth_user_password);
+
+            if (Event::handle('StartSetApiUser', array(&$user))) {
+
+                if (!empty($user)) {
+                    if (!$user->hasRight(Right::API)) {
+                        // TRANS: Authorization exception thrown when a user without API access tries to access the API.
+                        throw new AuthorizationException(_('Not allowed to use API.'));
+                    }
+                    $this->auth_user = $user;
+                }
+
+                Event::handle('EndSetApiUser', array($user));
+            }
+
+            // By default, basic auth users have rw access
+            $this->access = self::READ_WRITE;
+
+            if (empty($this->auth_user) && ($required || isset($_SERVER['PHP_AUTH_USER']))) {
+                $msg = sprintf(
+                    "basic auth nickname = %s",
+                    $this->auth_user_nickname
+                );
+                $this->logAuthFailure($msg);
+                // TRANS: Client error thrown when authentication fails.
+                $this->clientError(_('Could not authenticate you.'), 401, $this->format);
+                exit;
+            }
+        }
+    }
+
+    /**
+     * Read the HTTP headers and set the auth user.  Decodes HTTP_AUTHORIZATION
+     * param to support basic auth when PHP is running in CGI mode.
+     *
+     * @return void
+     */
+    function basicAuthProcessHeader()
+    {
+        $authHeaders = array('AUTHORIZATION',
+                             'HTTP_AUTHORIZATION',
+                             'REDIRECT_HTTP_AUTHORIZATION'); // rewrite for CGI
+        $authorization_header = null;
+        foreach ($authHeaders as $header) {
+            if (isset($_SERVER[$header])) {
+                $authorization_header = $_SERVER[$header];
+                break;
+            }
+        }
+
+        if (isset($_SERVER['PHP_AUTH_USER'])) {
+            $this->auth_user_nickname = $_SERVER['PHP_AUTH_USER'];
+            $this->auth_user_password = $_SERVER['PHP_AUTH_PW'];
+        } elseif (isset($authorization_header)
+            && strstr(substr($authorization_header, 0, 5), 'Basic')) {
+
+            // Decode the HTTP_AUTHORIZATION header on php-cgi server self
+            // on fcgid server the header name is AUTHORIZATION
+            $auth_hash = base64_decode(substr($authorization_header, 6));
+            list($this->auth_user_nickname,
+                 $this->auth_user_password) = explode(':', $auth_hash);
+
+            // Set all to null on a empty basic auth request
+
+            if (empty($this->auth_user_nickname)) {
+                $this->auth_user_nickname = null;
+                $this->auth_password = null;
+            }
+        }
+    }
+
+    /**
+     * Log an API authentication failure. Collect the proxy and IP
+     * and log them
+     *
+     * @param string $logMsg additional log message
+     */
+     function logAuthFailure($logMsg)
+     {
+        list($proxy, $ip) = common_client_ip();
+
+        $msg = sprintf(
+            'API auth failure (proxy = %1$s, ip = %2$s) - ',
+            $proxy,
+            $ip
+        );
+
+        common_log(LOG_WARNING, $msg . $logMsg);
+     }
+}
diff --git a/lib/apibareauth.php b/lib/apibareauth.php
deleted file mode 100644 (file)
index 043181b..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Base class for API actions that require "bare auth". Bare auth means
- * authentication is required only if the action is called without an argument
- * or query param specifying user id.
- *
- * 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  API
- * @package   StatusNet
- * @author    Adrian Lang <mail@adrianlang.de>
- * @author    Brenda Wallace <shiny@cpan.org>
- * @author    Craig Andrews <candrews@integralblue.com>
- * @author    Dan Moore <dan@moore.cx>
- * @author    Evan Prodromou <evan@status.net>
- * @author    mEDI <medi@milaro.net>
- * @author    Sarven Capadisli <csarven@status.net>
- * @author    Zach Copley <zach@status.net>
- * @copyright 2009 StatusNet, Inc.
- * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
- * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://status.net/
- */
-
-if (!defined('STATUSNET')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/apiauth.php';
-
-/**
- * Actions extending this class will require auth unless a target
- * user ID has been specified
- *
- * @category API
- * @package  StatusNet
- * @author   Adrian Lang <mail@adrianlang.de>
- * @author   Brenda Wallace <shiny@cpan.org>
- * @author   Craig Andrews <candrews@integralblue.com>
- * @author   Dan Moore <dan@moore.cx>
- * @author   Evan Prodromou <evan@status.net>
- * @author   mEDI <medi@milaro.net>
- * @author   Sarven Capadisli <csarven@status.net>
- * @author   Zach Copley <zach@status.net>
- * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://status.net/
- */
-class ApiBareAuthAction extends ApiAuthAction
-{
-    /**
-     * Take arguments for running
-     *
-     * @param array $args $_REQUEST args
-     *
-     * @return boolean success flag
-     *
-     */
-    function prepare($args)
-    {
-        parent::prepare($args);
-        return true;
-    }
-
-    /**
-     * Does this API resource require authentication?
-     *
-     * @return boolean true or false
-     */
-    function requiresAuth()
-    {
-        // If the site is "private", all API methods except statusnet/config
-        // need authentication
-        if (common_config('site', 'private')) {
-            return true;
-        }
-
-        // check whether a user has been specified somehow
-        $id           = $this->arg('id');
-        $user_id      = $this->arg('user_id');
-        $screen_name  = $this->arg('screen_name');
-
-        if (empty($id) && empty($user_id) && empty($screen_name)) {
-            return true;
-        }
-
-        return false;
-    }
-}
diff --git a/lib/apibareauthaction.php b/lib/apibareauthaction.php
new file mode 100644 (file)
index 0000000..8c20a03
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Base class for API actions that require "bare auth". Bare auth means
+ * authentication is required only if the action is called without an argument
+ * or query param specifying user id.
+ *
+ * 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  API
+ * @package   StatusNet
+ * @author    Adrian Lang <mail@adrianlang.de>
+ * @author    Brenda Wallace <shiny@cpan.org>
+ * @author    Craig Andrews <candrews@integralblue.com>
+ * @author    Dan Moore <dan@moore.cx>
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    mEDI <medi@milaro.net>
+ * @author    Sarven Capadisli <csarven@status.net>
+ * @author    Zach Copley <zach@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link      http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+    exit(1);
+}
+
+/**
+ * Actions extending this class will require auth unless a target
+ * user ID has been specified
+ *
+ * @category API
+ * @package  StatusNet
+ * @author   Adrian Lang <mail@adrianlang.de>
+ * @author   Brenda Wallace <shiny@cpan.org>
+ * @author   Craig Andrews <candrews@integralblue.com>
+ * @author   Dan Moore <dan@moore.cx>
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   mEDI <medi@milaro.net>
+ * @author   Sarven Capadisli <csarven@status.net>
+ * @author   Zach Copley <zach@status.net>
+ * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link     http://status.net/
+ */
+class ApiBareAuthAction extends ApiAuthAction
+{
+    /**
+     * Take arguments for running
+     *
+     * @param array $args $_REQUEST args
+     *
+     * @return boolean success flag
+     *
+     */
+    function prepare($args)
+    {
+        parent::prepare($args);
+        return true;
+    }
+
+    /**
+     * Does this API resource require authentication?
+     *
+     * @return boolean true or false
+     */
+    function requiresAuth()
+    {
+        // If the site is "private", all API methods except statusnet/config
+        // need authentication
+        if (common_config('site', 'private')) {
+            return true;
+        }
+
+        // check whether a user has been specified somehow
+        $id           = $this->arg('id');
+        $user_id      = $this->arg('user_id');
+        $screen_name  = $this->arg('screen_name');
+
+        if (empty($id) && empty($user_id) && empty($screen_name)) {
+            return true;
+        }
+
+        return false;
+    }
+}
index 04fc46730d9461beaefe4c26a3f0173f27b4133c..0838228ba0248c345a18fb1c5a33ea98af97240c 100644 (file)
@@ -29,8 +29,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 class ApiListUsersAction extends ApiBareAuthAction
 {
     var $list   = null;
index df401c382e9b54806e39f1341c698404d35e44b4..12f98984637fd0c95c0bd07a2c5b263ff960d60d 100644 (file)
@@ -40,8 +40,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/lib/apiauth.php';
-
 /**
  * Actions extending this class will require auth only if a site is private
  *
index 75e4e1c1e48424494d0c22388e7a2d9bb61da894..188e8487039da5cb4a8a9ba2679cbf52c5d32017 100644 (file)
@@ -18,7 +18,6 @@
  */
 
 require_once(INSTALLDIR . '/lib/mail.php');
-require_once(INSTALLDIR . '/lib/mediafile.php');
 require_once('Mail/mimeDecode.php');
 
 // @todo FIXME: we use both Mail_mimeDecode and mailparse
index 34dbfa75d34e220cf2ccb974defb1d1a96e943ec..58aac5d21c0e193f7d1d210c1d1d4774bafd76c7 100644 (file)
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/lib/apibareauth.php';
-
 /**
  * Returns the 20 most recent favorite notices for the authenticating user or user
  * specified by the ID parameter in the requested format.