From 3e1dc0e0b95ee106311bc19b0d867d8c98882f91 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Sep 2009 13:06:13 -0700 Subject: [PATCH 01/47] flip exe bit on Config.php --- classes/Config.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 classes/Config.php diff --git a/classes/Config.php b/classes/Config.php old mode 100755 new mode 100644 From 1e707008c247d9d6c3c81bf1b1a6fef41f2049ba Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Sep 2009 13:06:46 -0700 Subject: [PATCH 02/47] flip exe bit on Deleted_notice.php --- classes/Deleted_notice.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 classes/Deleted_notice.php diff --git a/classes/Deleted_notice.php b/classes/Deleted_notice.php old mode 100755 new mode 100644 From e559f82e86c495abdc4cf5fff3d8c6279a808354 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Sep 2009 13:07:21 -0700 Subject: [PATCH 03/47] flip exe bit on statusnet.ini --- classes/statusnet.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 classes/statusnet.ini diff --git a/classes/statusnet.ini b/classes/statusnet.ini old mode 100755 new mode 100644 From 4181c6f04ad6a2321b2957d8784abc7dfef5779f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 13 Sep 2009 17:53:15 -0700 Subject: [PATCH 04/47] bug 1814: installer now only offers DB types which are available. Abstracted a couple of hardcoded lists of mysql/pgsql checks and radio button creation to use a nice little array of names, installer funcs, and modules to check. Only those DB types whose modules are present will be presented in the installer; if all are missing, we throw an error and list out all the possibilities we were looking for. --- install.php | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/install.php b/install.php index e828fa814b..092172d35f 100644 --- a/install.php +++ b/install.php @@ -181,6 +181,18 @@ $external_libraries=array( 'check_class'=>'Validate' ) ); +$dbModules = array( + 'mysql' => array( + 'name' => 'MySQL', + 'check_module' => 'mysql', // mysqli? + 'installer' => 'mysql_db_installer', + ), + 'pgsql' => array( + 'name' => 'PostgreSQL', + 'check_module' => 'pgsql', + 'installer' => 'pgsql_db_installer', + ), +); function main() { @@ -238,8 +250,18 @@ function checkPrereqs() $pass = false; } } - if (!checkExtension('pgsql') && !checkExtension('mysql')) { - ?>

Cannot find mysql or pgsql extension. You need one or the other:

$info) { + if (!checkExtension($info['check_module'])) { + $missingExtensions[] = $info['check_module']; + } + } + if (count($missingExtensions) == count($dbModules)) { + $req = implode(', ', $missingExtensions); + ?>

Cannot find database support. You need at least one of these PHP extensions installed:

$info) { + if (checkExtension($info['check_module'])) { + $dbRadios .= " $info[name]
\n"; + $checked = ''; + } + } echo<< @@ -376,8 +407,7 @@ function showForm()
  • - MySQL
    - PostgreSQL
    + $dbRadios

    Database type

  • @@ -465,17 +495,9 @@ function handlePost() return; } - // FIXME: use PEAR::DB or PDO instead of our own switch - - switch($dbtype) { - case 'mysql': - $db = mysql_db_installer($host, $database, $username, $password); - break; - case 'pgsql': - $db = pgsql_db_installer($host, $database, $username, $password); - break; - default: - } + global $dbModules; + $db = call_user_func($dbModules[$dbtype]['installer'], + $host, $database, $username, $password); if (!$db) { // database connection failed, do not move on to create config file. From 222ef4d1869485426e893f85caf8a3014f814faa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 17:43:02 +1200 Subject: [PATCH 05/47] added doxygen tags --- install.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index 092172d35f..5754c717a1 100644 --- a/install.php +++ b/install.php @@ -1,5 +1,5 @@ . + * + * @category Installation + * @package Installation + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * */ + + define('INSTALLDIR', dirname(__FILE__)); From 711fe39700e868ad2cea595b109d2958752d4aa6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 17:43:48 +1200 Subject: [PATCH 06/47] changed curly bracks on if, else, foreach to match pear code styles --- install.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/install.php b/install.php index 5754c717a1..75646c8526 100644 --- a/install.php +++ b/install.php @@ -203,14 +203,13 @@ $dbModules = array( function main() { - if (!checkPrereqs()) - { + if (!checkPrereqs()) { return; } - if( $_GET['checklibs'] ){ + if ($_GET['checklibs']) { showLibs(); - }else{ + } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { handlePost(); } else { @@ -221,13 +220,13 @@ function main() function haveExternalLibrary($external_library) { - if(isset($external_library['include']) && ! include_once($external_library['include'])){ + if (isset($external_library['include']) && ! include_once $external_library['include'] ) { return false; } - if(isset($external_library['check_function']) && ! function_exists($external_library['check_function'])){ + if (isset($external_library['check_function']) && ! function_exists($external_library['check_function'])) { return false; } - if(isset($external_library['check_class']) && ! class_exists($external_library['check_class'])){ + if (isset($external_library['check_class']) && ! class_exists($external_library['check_class'])) { return false; } return true; @@ -309,10 +308,10 @@ function showLibs() global $external_libraries; $present_libraries=array(); $absent_libraries=array(); - foreach($external_libraries as $external_library){ - if(haveExternalLibrary($external_library)){ + foreach ($external_libraries as $external_library){ + if (haveExternalLibrary($external_library)) { $present_libraries[]=$external_library; - }else{ + } else { $absent_libraries[]=$external_library; } } From c2e156dc492925d6aa94b91d5cee9ceb615bc2ab Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 17:44:22 +1200 Subject: [PATCH 07/47] added doxygen for main() --- install.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install.php b/install.php index 75646c8526..221e4746fe 100644 --- a/install.php +++ b/install.php @@ -201,6 +201,12 @@ $dbModules = array( ), ); +/** + * the actual installation. + * If call libraries are present, then install + * + * @return void + */ function main() { if (!checkPrereqs()) { From 20764dc08b0231e4be07c4e181c8603b005c20b5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 14 Sep 2009 19:05:14 +1200 Subject: [PATCH 08/47] removed most of the that was making this hard to read Conflicts: install.php --- install.php | 56 +++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/install.php b/install.php index 221e4746fe..6f8bff91ec 100644 --- a/install.php +++ b/install.php @@ -240,17 +240,16 @@ function haveExternalLibrary($external_library) function checkPrereqs() { - $pass = true; + $pass = true; if (file_exists(INSTALLDIR.'/config.php')) { - ?>

    Config file "config.php" already exists.

    - Config file "config.php" already exists.

    '); $pass = false; } if (version_compare(PHP_VERSION, '5.2.3', '<')) { - ?>

    Require PHP version 5.2.3 or greater.

    Require PHP version 5.2.3 or greater.

    '); + $pass = false; } $reqs = array('gd', 'curl', @@ -258,11 +257,10 @@ function checkPrereqs() foreach ($reqs as $req) { if (!checkExtension($req)) { - ?>

    Cannot load required extension:

    Cannot load required extension: %s

    ', $req); + $pass = false; } - } - + } // Make sure we have at least one database module available global $dbModules; $missingExtensions = array(); @@ -273,30 +271,28 @@ function checkPrereqs() } if (count($missingExtensions) == count($dbModules)) { $req = implode(', ', $missingExtensions); - ?>

    Cannot find database support. You need at least one of these PHP extensions installed:

    Cannot find mysql or pgsql extension. You need one or the other: %s

    ', $req); + $pass = false; + } + + if (!is_writable(INSTALLDIR)) { + printf('

    Cannot write config file to: %s

    ', INSTALLDIR); + printf('

    On your server, try this command: chmod a+w %s', INSTALLDIR); + $pass = false; } - if (!is_writable(INSTALLDIR)) { - ?>

    Cannot write config file to:

    -

    On your server, try this command: chmod a+w - Cannot write to %s directory: %s

    ', $fileSubdir, $fileFullPath); + printf('

    On your server, try this command: chmod a+w %s

    ', $fileFullPath); + $pass = false; + } + } - // Check the subdirs used for file uploads - $fileSubdirs = array('avatar', 'background', 'file'); - foreach ($fileSubdirs as $fileSubdir) { - $fileFullPath = INSTALLDIR."/$fileSubdir/"; - if (!is_writable($fileFullPath)) { - ?>

    Cannot write directory:

    -

    On your server, try this command: chmod a+w

    - Date: Sun, 13 Sep 2009 17:59:42 +1200 Subject: [PATCH 09/47] fixed missing semisolon --- install.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/install.php b/install.php index 6f8bff91ec..64c8fd9b14 100644 --- a/install.php +++ b/install.php @@ -444,10 +444,8 @@ E_O_T; function updateStatus($status, $error=false) { -?> -
  • >
  • - -$status"; } function handlePost() From 61d5d51cf55909e8fa2b4a362b47741a9cde25ae Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 18:22:32 +1200 Subject: [PATCH 10/47] lotsa tabulation changed to 4 spaces --- install.php | 185 +++++++++++++++++++++++++++------------------------- 1 file changed, 95 insertions(+), 90 deletions(-) diff --git a/install.php b/install.php index 64c8fd9b14..9d59f25b9d 100644 --- a/install.php +++ b/install.php @@ -450,9 +450,6 @@ function updateStatus($status, $error=false) function handlePost() { -?> - - + echo <<
    Page notice
      -server_encoding != 'UTF8') { - updateStatus("StatusNet requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding)); - showForm(); - return false; - } + //ensure database encoding is UTF8 + $record = pg_fetch_object(pg_query($conn, 'SHOW server_encoding')); + if ($record->server_encoding != 'UTF8') { + updateStatus("StatusNet requires UTF8 character encoding. Your database is ". htmlentities($record->server_encoding)); + showForm(); + return false; + } - updateStatus("Running database script..."); - //wrap in transaction; - pg_query($conn, 'BEGIN'); - $res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql'); + updateStatus("Running database script..."); + //wrap in transaction; + pg_query($conn, 'BEGIN'); + $res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql'); - if ($res === false) { - updateStatus("Can't run database script.", true); - showForm(); - return false; - } - foreach (array('sms_carrier' => 'SMS carrier', + if ($res === false) { + updateStatus("Can't run database script.", true); + showForm(); + return false; + } + foreach (array('sms_carrier' => 'SMS carrier', 'notice_source' => 'notice source', 'foreign_services' => 'foreign service') as $scr => $name) { - updateStatus(sprintf("Adding %s data to database...", $name)); - $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql'); - if ($res === false) { - updateStatus(sprintf("Can't run %d script.", $name), true); - showForm(); - return false; - } - } - pg_query($conn, 'COMMIT'); + updateStatus(sprintf("Adding %s data to database...", $name)); + $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn, 'pgsql'); + if ($res === false) { + updateStatus(sprintf("Can't run %d script.", $name), true); + showForm(); + return false; + } + } + pg_query($conn, 'COMMIT'); - if (empty($password)) { - $sqlUrl = "pgsql://$username@$host/$database"; - } - else { - $sqlUrl = "pgsql://$username:$password@$host/$database"; - } + if (empty($password)) { + $sqlUrl = "pgsql://$username@$host/$database"; + } + else { + $sqlUrl = "pgsql://$username:$password@$host/$database"; + } - $db = array('type' => 'pgsql', 'database' => $sqlUrl); + $db = array('type' => 'pgsql', 'database' => $sqlUrl); - return $db; + return $db; } function mysql_db_installer($host, $database, $username, $password) { - updateStatus("Starting installation..."); - updateStatus("Checking database..."); + updateStatus("Starting installation..."); + updateStatus("Checking database..."); - $conn = mysql_connect($host, $username, $password); - if (!$conn) { - updateStatus("Can't connect to server '$host' as '$username'.", true); - showForm(); - return false; - } - updateStatus("Changing to database..."); - $res = mysql_select_db($database, $conn); - if (!$res) { - updateStatus("Can't change to database.", true); - showForm(); - return false; - } - updateStatus("Running database script..."); - $res = runDbScript(INSTALLDIR.'/db/statusnet.sql', $conn); - if ($res === false) { - updateStatus("Can't run database script.", true); - showForm(); - return false; - } - foreach (array('sms_carrier' => 'SMS carrier', + $conn = mysql_connect($host, $username, $password); + if (!$conn) { + updateStatus("Can't connect to server '$host' as '$username'.", true); + showForm(); + return false; + } + updateStatus("Changing to database..."); + $res = mysql_select_db($database, $conn); + if (!$res) { + updateStatus("Can't change to database.", true); + showForm(); + return false; + } + updateStatus("Running database script..."); + $res = runDbScript(INSTALLDIR.'/db/statusnet.sql', $conn); + if ($res === false) { + updateStatus("Can't run database script.", true); + showForm(); + return false; + } + foreach (array('sms_carrier' => 'SMS carrier', 'notice_source' => 'notice source', 'foreign_services' => 'foreign service') as $scr => $name) { - updateStatus(sprintf("Adding %s data to database...", $name)); - $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn); - if ($res === false) { - updateStatus(sprintf("Can't run %d script.", $name), true); - showForm(); - return false; - } - } + updateStatus(sprintf("Adding %s data to database...", $name)); + $res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn); + if ($res === false) { + updateStatus(sprintf("Can't run %d script.", $name), true); + showForm(); + return false; + } + } - $sqlUrl = "mysqli://$username:$password@$host/$database"; - $db = array('type' => 'mysql', 'database' => $sqlUrl); - return $db; + $sqlUrl = "mysqli://$username:$password@$host/$database"; + $db = array('type' => 'mysql', 'database' => $sqlUrl); + return $db; } function writeConf($sitename, $server, $path, $fancy, $db) @@ -662,6 +659,14 @@ function writeConf($sitename, $server, $path, $fancy, $db) return $res; } +/** + * Install schema into the database + * + * @param filename $filename location of database schema file + * @param conn $conn connection to database + * @param type $type type of database, currently mysql or pgsql + * @return boolean - indicating success or failure + */ function runDbScript($filename, $conn, $type = 'mysql') { $sql = trim(file_get_contents($filename)); From 36aa89d6959d0d03f3fe3c769f867f314aba8bf9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 18:29:10 +1200 Subject: [PATCH 11/47] many doxygen comments added --- install.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index 9d59f25b9d..787edb20f0 100644 --- a/install.php +++ b/install.php @@ -224,6 +224,13 @@ function main() } } +/** + * checks if an external libary is present + * + * @param string $external_library Name of library + * + * @return boolean indicates if library present + */ function haveExternalLibrary($external_library) { if (isset($external_library['include']) && ! include_once $external_library['include'] ) { @@ -238,6 +245,11 @@ function haveExternalLibrary($external_library) return true; } +/** + * Check if all is ready for installation + * + * @return void + */ function checkPrereqs() { $pass = true; @@ -295,6 +307,13 @@ function checkPrereqs() return $pass; } +/** + * Checks if a php extension is both installed and loaded + * + * @param string $name of extension to check + * + * @return boolean whether extension is installed and loaded + */ function checkExtension($name) { if (!extension_loaded($name)) { @@ -305,6 +324,11 @@ function checkExtension($name) return true; } +/** + * Show list of libraries + * + * @return void + */ function showLibs() { global $external_libraries; @@ -356,9 +380,9 @@ E_O_T; foreach($present_libraries as $library) { echo '
    • '; - if($library['url']){ + if ($library['url']) { echo ''.htmlentities($library['name']).''; - }else{ + } else { echo htmlentities($library['name']); } echo '
    • '; From f5b7ea739660cf15abb92f534b30fc1cfd5e07c6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 18:31:44 +1200 Subject: [PATCH 12/47] fixed up curly brackets and spaces around for, if, else --- install.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/install.php b/install.php index 787edb20f0..30c6780abc 100644 --- a/install.php +++ b/install.php @@ -334,7 +334,7 @@ function showLibs() global $external_libraries; $present_libraries=array(); $absent_libraries=array(); - foreach ($external_libraries as $external_library){ + foreach ($external_libraries as $external_library) { if (haveExternalLibrary($external_library)) { $present_libraries[]=$external_library; } else { @@ -352,22 +352,21 @@ function showLibs()

      Absent Libraries

        E_O_T; - foreach($absent_libraries as $library) - { + foreach ($absent_libraries as $library) { echo '
      • '; - if($library['url']){ + if ($library['url']) { echo ''.htmlentities($library['name']).''; - }else{ + } else { echo htmlentities($library['name']); } echo '
          '; - if($library['deb']){ + if ($library['deb']) { echo '
        • deb: ' . htmlentities($library['deb']) . '
        • '; } - if($library['rpm']){ + if ($library['rpm']) { echo '
        • rpm: ' . htmlentities($library['rpm']) . '
        • '; } - if($library['pear']){ + if ($library['pear']) { echo '
        • pear: ' . htmlentities($library['pear']) . '
        • '; } echo '
        '; @@ -377,8 +376,7 @@ E_O_T;

        Installed Libraries

          E_O_T; - foreach($present_libraries as $library) - { + foreach ($present_libraries as $library) { echo '
        • '; if ($library['url']) { echo ''.htmlentities($library['name']).''; @@ -514,11 +512,11 @@ STR; if (empty($sitename)) { updateStatus("No sitename specified.", true); - $fail = true; + $fail = true; } - if($fail){ - showForm(); + if ($fail) { + showForm(); return; } @@ -603,8 +601,7 @@ function pgsql_db_installer($host, $database, $username, $password) { if (empty($password)) { $sqlUrl = "pgsql://$username@$host/$database"; - } - else { + } else { $sqlUrl = "pgsql://$username:$password@$host/$database"; } From 93605dce99832868c3fdbb8af42db507a8005e97 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 18:32:59 +1200 Subject: [PATCH 13/47] removed commented out code we no longer want --- install.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/install.php b/install.php index 30c6780abc..6e7e833a30 100644 --- a/install.php +++ b/install.php @@ -505,11 +505,6 @@ STR; $fail = true; } -// if (empty($password)) { -// updateStatus("No password specified.", true); -// $fail = true; -// } - if (empty($sitename)) { updateStatus("No sitename specified.", true); $fail = true; From dbc08ef0a09e481e0884a38ee704f4d193edef6a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 14 Sep 2009 19:08:05 +1200 Subject: [PATCH 14/47] most of code style errors gone Conflicts: install.php --- install.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/install.php b/install.php index 6e7e833a30..dea03fc5ec 100644 --- a/install.php +++ b/install.php @@ -516,8 +516,7 @@ STR; } global $dbModules; - $db = call_user_func($dbModules[$dbtype]['installer'], - $host, $database, $username, $password); + $db = call_user_func($dbModules[$dbtype]['installer'], $host, $database, $username, $password); if (!$db) { // database connection failed, do not move on to create config file. @@ -540,12 +539,10 @@ STR; updateStatus("StatusNet has been installed at $link"); updateStatus("You can visit your new StatusNet site."); -?> - - Date: Sun, 13 Sep 2009 20:15:21 +1200 Subject: [PATCH 15/47] added most of the required doxygen --- index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.php b/index.php index e2296549f3..83c14c4955 100644 --- a/index.php +++ b/index.php @@ -15,6 +15,10 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . + * + * @category StatusNet + * @package StatusNet + * @license GNU Affero General Public License http://www.gnu.org/licenses/ */ define('INSTALLDIR', dirname(__FILE__)); From a2f4fe7fc80fa851dd9293d64c4727d4bb233b90 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 20:16:07 +1200 Subject: [PATCH 16/47] fixed up if statements --- index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 83c14c4955..8f2a7cf7f8 100644 --- a/index.php +++ b/index.php @@ -49,11 +49,11 @@ function handleError($error) } $logmsg = "PEAR error: " . $error->getMessage(); - if(common_config('site', 'logdebug')) { + if (common_config('site', 'logdebug')) { $logmsg .= " : ". $error->getDebugInfo(); } common_log(LOG_ERR, $logmsg); - if(common_config('site', 'logdebug')) { + if (common_config('site', 'logdebug')) { $bt = $error->getBacktrace(); foreach ($bt as $line) { common_log(LOG_ERR, $line); From 738b6d1690ad595b85657fa282132459865fed93 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 20:31:19 +1200 Subject: [PATCH 17/47] lotsa of multiline if statements and function calls changed style to meat pear code style --- index.php | 54 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/index.php b/index.php index 8f2a7cf7f8..71de393246 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,8 @@ $action = null; function getPath($req) { if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER)) - && array_key_exists('p', $req)) { + && array_key_exists('p', $req) + ) { return $req['p']; } else if (array_key_exists('PATH_INFO', $_SERVER)) { return $_SERVER['PATH_INFO']; @@ -59,18 +60,25 @@ function handleError($error) common_log(LOG_ERR, $line); } } - if ($error instanceof DB_DataObject_Error || - $error instanceof DB_Error) { - $msg = sprintf(_('The database for %s isn\'t responding correctly, '. - 'so the site won\'t work properly. '. - 'The site admins probably know about the problem, '. - 'but you can contact them at %s to make sure. '. - 'Otherwise, wait a few minutes and try again.'), - common_config('site', 'name'), - common_config('site', 'email')); + if ($error instanceof DB_DataObject_Error + || $error instanceof DB_Error + ) { + $msg = sprintf( + _( + 'The database for %s isn\'t responding correctly, '. + 'so the site won\'t work properly. '. + 'The site admins probably know about the problem, '. + 'but you can contact them at %s to make sure. '. + 'Otherwise, wait a few minutes and try again.' + ), + common_config('site', 'name'), + common_config('site', 'email') + ); } else { - $msg = _('An important error occured, probably related to email setup. '. - 'Check logfiles for more info..'); + $msg = _( + 'An important error occured, probably related to email setup. '. + 'Check logfiles for more info..' + ); } $dac = new DBErrorAction($msg, 500); @@ -131,10 +139,11 @@ function main() $_lighty_url = @parse_url($_lighty_url); if ($_lighty_url['path'] != '/index.php' && $_lighty_url['path'] != '/') { - $_lighty_path = preg_replace('/^'.preg_quote(common_config('site','path')).'\//', '', substr($_lighty_url['path'], 1)); + $_lighty_path = preg_replace('/^'.preg_quote(common_config('site', 'path')).'\//', '', substr($_lighty_url['path'], 1)); $_SERVER['QUERY_STRING'] = 'p='.$_lighty_path; - if ($_lighty_url['query']) + if ($_lighty_url['query']) { $_SERVER['QUERY_STRING'] .= '&'.$_lighty_url['query']; + } parse_str($_lighty_url['query'], $_lighty_query); foreach ($_lighty_query as $key => $val) { $_GET[$key] = $_REQUEST[$key] = $val; @@ -145,7 +154,7 @@ function main() $_SERVER['REDIRECT_URL'] = preg_replace("/\?.+$/", "", $_SERVER['REQUEST_URI']); // quick check for fancy URL auto-detection support in installer. - if (isset($_SERVER['REDIRECT_URL']) && (preg_replace("/^\/$/","",(dirname($_SERVER['REQUEST_URI']))) . '/check-fancy') === $_SERVER['REDIRECT_URL']) { + if (isset($_SERVER['REDIRECT_URL']) && (preg_replace("/^\/$/", "", (dirname($_SERVER['REQUEST_URI']))) . '/check-fancy') === $_SERVER['REDIRECT_URL']) { die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs."); } global $user, $action; @@ -153,8 +162,12 @@ function main() Snapshot::check(); if (!_have_config()) { - $msg = sprintf(_("No configuration file found. Try running ". - "the installation program first.")); + $msg = sprintf( + _( + "No configuration file found. Try running ". + "the installation program first." + ) + ); $sac = new ServerErrorAction($msg); $sac->showPage(); return; @@ -200,9 +213,10 @@ function main() // 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') && - !isLoginAction($action) && - !preg_match('/rss$/', $action)) { + if (!$user && common_config('site', 'private') + && !isLoginAction($action) + && !preg_match('/rss$/', $action) + ) { common_redirect(common_local_url('login')); return; } From 87c59fe8734479046c8433f74787f615484b3df7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 20:32:58 +1200 Subject: [PATCH 18/47] fixed indentation for the pear code styles --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index 71de393246..b8d9c7c69d 100644 --- a/index.php +++ b/index.php @@ -34,7 +34,7 @@ function getPath($req) { if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER)) && array_key_exists('p', $req) - ) { + ) { return $req['p']; } else if (array_key_exists('PATH_INFO', $_SERVER)) { return $_SERVER['PATH_INFO']; From 5ca90e2c8cbc76693cf0f2278d14f2a35da7e34e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 14 Sep 2009 19:19:11 +1200 Subject: [PATCH 19/47] pulled @author from git logs Conflicts: install.php --- index.php | 14 ++++++++++++++ install.php | 21 ++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index b8d9c7c69d..a1d983dce7 100644 --- a/index.php +++ b/index.php @@ -19,6 +19,20 @@ * @category StatusNet * @package StatusNet * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @author Brenda Wallace + * @author Christopher Vollick + * @author CiaranG + * @author Craig Andrews + * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou + * @author Gina Haeussge + * @author Jeffery To + * @author Mike Cochrane + * @author Robin Millette + * @author Sarven Capadisli + * @author Tom Adams */ define('INSTALLDIR', dirname(__FILE__)); diff --git a/install.php b/install.php index dea03fc5ec..07a7bfaaf7 100644 --- a/install.php +++ b/install.php @@ -18,12 +18,22 @@ * * @category Installation * @package Installation - * @license GNU Affero General Public License http://www.gnu.org/licenses/ * + * @author Adrian Lang + * @author Brenda Wallace + * @author Brett Taylor + * @author Brion Vibber + * @author CiaranG + * @author Craig Andrews + * @author Eric Helgeson + * @author Evan Prodromou + * @author Evan Prodromou + * @author Robin Millette + * @author Sarven Capadisli + * @author Tom Adams + * @license GNU Affero General Public License http://www.gnu.org/licenses/ */ - - define('INSTALLDIR', dirname(__FILE__)); $external_libraries=array( @@ -281,6 +291,7 @@ function checkPrereqs() $missingExtensions[] = $info['check_module']; } } + if (count($missingExtensions) == count($dbModules)) { $req = implode(', ', $missingExtensions); printf('

          Cannot find mysql or pgsql extension. You need one or the other: %s

          ', $req); @@ -682,7 +693,7 @@ function writeConf($sitename, $server, $path, $fancy, $db) * * @return boolean - indicating success or failure */ -function runDbScript($filename, $conn, $type = 'mysql') +function runDbScript($filename, $conn, $type = 'mysqli') { $sql = trim(file_get_contents($filename)); $stmts = explode(';', $sql); @@ -693,7 +704,7 @@ function runDbScript($filename, $conn, $type = 'mysql') } // FIXME: use PEAR::DB or PDO instead of our own switch switch ($type) { - case 'mysql': + case 'mysqli': $res = mysql_query($stmt, $conn); if ($res === false) { $error = mysql_error(); From 84da24aba41b459ad8b2735328e257275c0f6136 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 21:27:34 +1200 Subject: [PATCH 20/47] cleaned up code style --- actions/all.php | 82 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/actions/all.php b/actions/all.php index 29a19afb6b..e56e10c21f 100644 --- a/actions/all.php +++ b/actions/all.php @@ -1,5 +1,5 @@ . + * + * @category Actions + * @package Actions + * @author Evan Prodromou + * @author Evan Prodromou + * @author Mike Cochrane + * @author Robin Millette + * @author Adrian Lang + * @author Meitar Moscovitz + * @author Sarven Capadisli + * @author Craig Andrews + * @author Evan Prodromou + * @author Evan Prodromou + * @author Jeffery To + * @author Zach Copley + * @author csarven + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @link http://status.net */ -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} require_once INSTALLDIR.'/lib/personalgroupnav.php'; require_once INSTALLDIR.'/lib/noticelist.php'; @@ -43,8 +63,8 @@ class AllAction extends ProfileAction $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); } - if($this->page > 1 && $this->notice->N == 0){ - $this->serverError(_('No such page'),$code=404); + if ($this->page > 1 && $this->notice->N == 0) { + $this->serverError(_('No such page'), $code = 404); } return true; @@ -73,20 +93,33 @@ class AllAction extends ProfileAction function getFeeds() { - return array(new Feed(Feed::RSS1, - common_local_url('allrss', array('nickname' => - $this->user->nickname)), - sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)), - new Feed(Feed::RSS2, - common_local_url('api', array('apiaction' => 'statuses', - 'method' => 'friends_timeline', - 'argument' => $this->user->nickname.'.rss')), - sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)), - new Feed(Feed::ATOM, - common_local_url('api', array('apiaction' => 'statuses', - 'method' => 'friends_timeline', - 'argument' => $this->user->nickname.'.atom')), - sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname))); + return array( + new Feed(Feed::RSS1, + common_local_url( + 'allrss', array( + 'nickname' => + $this->user->nickname) + ), + sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)), + new Feed(Feed::RSS2, + common_local_url( + 'api', array( + 'apiaction' => 'statuses', + 'method' => 'friends_timeline', + 'argument' => $this->user->nickname.'.rss' + ) + ), + sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)), + new Feed(Feed::ATOM, + common_local_url( + 'api', array( + 'apiaction' => 'statuses', + 'method' => 'friends_timeline', + 'argument' => $this->user->nickname.'.atom' + ) + ), + sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)) + ); } function showLocalNav() @@ -106,8 +139,7 @@ class AllAction extends ProfileAction } else { $message .= sprintf(_('You can try to [nudge %s](../%s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); } - } - else { + } else { $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname); } @@ -126,17 +158,19 @@ class AllAction extends ProfileAction $this->showEmptyListMessage(); } - $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, - $this->page, 'all', array('nickname' => $this->user->nickname)); + $this->pagination( + $this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'all', array('nickname' => $this->user->nickname) + ); } function showPageTitle() { $user =& common_current_user(); if ($user && ($user->id == $this->user->id)) { - $this->element('h1', NULL, _("You and friends")); + $this->element('h1', null, _("You and friends")); } else { - $this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname)); + $this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname)); } } From fcff85bb3610a0f2a77bfa72cf26ce8019ec0378 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 13 Sep 2009 21:55:45 +1200 Subject: [PATCH 21/47] code style cleanup --- actions/api.php | 100 ++++++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/actions/api.php b/actions/api.php index c236378bcb..9b5f548074 100644 --- a/actions/api.php +++ b/actions/api.php @@ -1,5 +1,5 @@ . + * + * @category Actions + * @package Actions + * @author Evan Prodromou + * @author Evan Prodromou + * @author Brenda Wallace + * @author Jeffery To + * @author Robin Millette + * @author Tom Adams + * @author Christopher Vollick + * @author CiaranG + * @author Craig Andrews + * @author Evan Prodromou + * @author Evan Prodromou + * @author Gina Haeussge + * @author Mike Cochrane + * @author Sarven Capadisli + * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @link http://status.net */ -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} class ApiAction extends Action { @@ -37,7 +58,7 @@ class ApiAction extends Action $this->api_action = $this->arg('apiaction'); $method = $this->arg('method'); $argument = $this->arg('argument'); - $this->basic_auth_process_header(); + $this->basic_auth_process_header(); if (isset($argument)) { $cmdext = explode('.', $argument); @@ -46,7 +67,7 @@ class ApiAction extends Action $this->content_type = strtolower($cmdext[1]); } else { - # Requested format / content-type will be an extension on the method + //Requested format / content-type will be an extension on the method $cmdext = explode('.', $method); $this->api_method = $cmdext[0]; $this->content_type = strtolower($cmdext[1]); @@ -55,10 +76,10 @@ class ApiAction extends Action if ($this->requires_auth()) { if (!isset($this->auth_user)) { - # This header makes basic auth go + //This header makes basic auth go header('WWW-Authenticate: Basic realm="StatusNet API"'); - # If the user hits cancel -- bam! + //If the user hits cancel -- bam! $this->show_basic_auth_error(); } else { $nickname = $this->auth_user; @@ -69,7 +90,7 @@ class ApiAction extends Action $this->user = $user; $this->process_command(); } else { - # basic authentication failed + //basic authentication failed list($proxy, $ip) = common_client_ip(); common_log(LOG_WARNING, "Failed API auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip."); @@ -84,7 +105,7 @@ class ApiAction extends Action if ($user) { $this->user = $user; } - # Twitter doesn't throw an error if the user isn't found + //Twitter doesn't throw an error if the user isn't found } $this->process_command(); @@ -97,7 +118,7 @@ class ApiAction extends Action $actionfile = INSTALLDIR."/actions/$action.php"; if (file_exists($actionfile)) { - require_once($actionfile); + include_once $actionfile; $action_class = ucfirst($action)."Action"; $action_obj = new $action_class(); @@ -113,10 +134,10 @@ class ApiAction extends Action call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata); } else { - $this->clientError("API method not found!", $code=404); + $this->clientError("API method not found!", $code = 404); } } else { - $this->clientError("API method not found!", $code=404); + $this->clientError("API method not found!", $code = 404); } } @@ -184,10 +205,11 @@ class ApiAction extends Action $user_id = $this->arg('user_id'); $screen_name = $this->arg('screen_name'); - if (empty($this->api_arg) && - empty($id) && - empty($user_id) && - empty($screen_name)) { + if (empty($this->api_arg) + && empty($id) + && empty($user_id) + && empty($screen_name) + ) { return true; } else { return false; @@ -208,35 +230,29 @@ class ApiAction extends Action function basic_auth_process_header() { - if(isset($_SERVER['AUTHORIZATION']) || isset($_SERVER['HTTP_AUTHORIZATION'])) - { - $authorization_header = isset($_SERVER['HTTP_AUTHORIZATION'])?$_SERVER['HTTP_AUTHORIZATION']:$_SERVER['AUTHORIZATION']; - } + if (isset($_SERVER['AUTHORIZATION']) || isset($_SERVER['HTTP_AUTHORIZATION'])) { + $authorization_header = isset($_SERVER['HTTP_AUTHORIZATION'])? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['AUTHORIZATION']; + } - if(isset($_SERVER['PHP_AUTH_USER'])) - { - $this->auth_user = $_SERVER['PHP_AUTH_USER']; - $this->auth_pw = $_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 + if (isset($_SERVER['PHP_AUTH_USER'])) { + $this->auth_user = $_SERVER['PHP_AUTH_USER']; + $this->auth_pw = $_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, $this->auth_pw) = explode(':', $auth_hash); + $auth_hash = base64_decode(substr($authorization_header, 6)); + list($this->auth_user, $this->auth_pw) = explode(':', $auth_hash); - // set all to NULL on a empty basic auth request - if($this->auth_user == "") { - $this->auth_user = NULL; - $this->auth_pw = NULL; - } - } - else - { - $this->auth_user = NULL; - $this->auth_pw = NULL; - } + // set all to null on a empty basic auth request + if ($this->auth_user == "") { + $this->auth_user = null; + $this->auth_pw = null; + } + } else { + $this->auth_user = null; + $this->auth_pw = null; + } } function show_basic_auth_error() @@ -252,7 +268,7 @@ class ApiAction extends Action $this->element('request', null, $_SERVER['REQUEST_URI']); $this->elementEnd('hash'); $this->endXML(); - } else if ($this->content_type == 'json') { + } else if ($this->content_type == 'json') { header('Content-Type: application/json; charset=utf-8'); $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']); print(json_encode($error_array)); From 5bad7040b14bf61d84cc33c8b4cf2af3b5861d3b Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 14 Sep 2009 22:08:17 +0200 Subject: [PATCH 22/47] Fix bad merge d7ae0ed4fd755ebad0788a17d0f2fb6a6ca9d63b --- lib/omb.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/omb.php b/lib/omb.php index 9133af7a05..0566701ff1 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -80,14 +80,9 @@ function omb_broadcast_notice($notice) $posted = array(); while ($rp->fetch()) { - if (!array_key_exists($rp->postnoticeurl, $posted)) { - common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl); - if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) { - common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl); - $posted[$rp->postnoticeurl] = true; - } else { - common_log(LOG_DEBUG, 'Failed posting to ' . $rp->postnoticeurl); - } + if (isset($posted[$rp->postnoticeurl])) { + /* We already posted to this url. */ + continue; } common_debug('Posting to ' . $rp->postnoticeurl, __FILE__); From 4081ed79b02fd06f7c347803478e1f835311c2ab Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 15 Sep 2009 12:59:32 -0700 Subject: [PATCH 23/47] Make it impossible to delete self-subscriptions via the API --- actions/twitapifriendships.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php index f2ea46910e..eea8945c39 100644 --- a/actions/twitapifriendships.php +++ b/actions/twitapifriendships.php @@ -99,6 +99,12 @@ class TwitapifriendshipsAction extends TwitterapiAction $other = $this->get_profile($id); $user = $apidata['user']; // Alwyas the auth user + if ($user->id == $other->id) { + $this->clientError(_("You cannot unfollow yourself!"), + 403, $apidata['content-type']); + return; + } + $sub = new Subscription(); $sub->subscriber = $user->id; $sub->subscribed = $other->id; From 38409f1683351ae2b9bc932d441c6021a8b2aae7 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 15 Sep 2009 14:37:11 -0700 Subject: [PATCH 24/47] Add Jiminy to notice sources --- db/notice_source.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/notice_source.sql b/db/notice_source.sql index f590d1b97a..2657763f44 100644 --- a/db/notice_source.sql +++ b/db/notice_source.sql @@ -21,6 +21,7 @@ VALUES ('identichat','identichat','http://identichat.prosody.im/', now()), ('IdentiFox','IdentiFox','http://www.bitbucket.org/uncryptic/identifox/', now()), ('identitwitch','IdentiTwitch','http://richfish.org/identitwitch/', now()), + ('Jiminy','Jiminy','http://code.google.com/p/jiminy/', now()), ('LaTwit','LaTwit','http://latwit.mac65.com/', now()), ('LiveTweeter', 'LiveTweeter', 'http://addons.songbirdnest.com/addon/1204', now()), ('livetweeter', 'livetweeter', 'http://addons.songbirdnest.com/addon/1204', now()), From 94466da35afcb0b1680a478964b58fbc7970f4ec Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 15 Sep 2009 16:31:09 -0700 Subject: [PATCH 25/47] Got rid of a bunch of ugly warnings --- install.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/install.php b/install.php index 07a7bfaaf7..a8f1ef4e24 100644 --- a/install.php +++ b/install.php @@ -1,5 +1,5 @@ . - * + * * @category Installation * @package Installation - * + * * @author Adrian Lang * @author Brenda Wallace * @author Brett Taylor @@ -33,7 +33,7 @@ * @author Tom Adams * @license GNU Affero General Public License http://www.gnu.org/licenses/ */ - + define('INSTALLDIR', dirname(__FILE__)); $external_libraries=array( @@ -211,10 +211,10 @@ $dbModules = array( ), ); -/** +/** * the actual installation. * If call libraries are present, then install - * + * * @return void */ function main() @@ -222,8 +222,8 @@ function main() if (!checkPrereqs()) { return; } - - if ($_GET['checklibs']) { + + if (!empty($_GET['checklibs'])) { showLibs(); } else { if ($_SERVER['REQUEST_METHOD'] == 'POST') { @@ -243,7 +243,7 @@ function main() */ function haveExternalLibrary($external_library) { - if (isset($external_library['include']) && ! include_once $external_library['include'] ) { + if (isset($external_library['include']) && ! @include_once $external_library['include'] ) { return false; } if (isset($external_library['check_function']) && ! function_exists($external_library['check_function'])) { @@ -282,7 +282,7 @@ function checkPrereqs() printf('

          Cannot load required extension: %s

          ', $req); $pass = false; } - } + } // Make sure we have at least one database module available global $dbModules; $missingExtensions = array(); @@ -291,13 +291,13 @@ function checkPrereqs() $missingExtensions[] = $info['check_module']; } } - + if (count($missingExtensions) == count($dbModules)) { $req = implode(', ', $missingExtensions); - printf('

          Cannot find mysql or pgsql extension. You need one or the other: %s

          ', $req); + printf('

          Cannot find mysql or pgsql extension. You need one or the other.'); $pass = false; } - + if (!is_writable(INSTALLDIR)) { printf('

          Cannot write config file to: %s

          ', INSTALLDIR); printf('

          On your server, try this command: chmod a+w %s', INSTALLDIR); @@ -365,19 +365,19 @@ function showLibs() E_O_T; foreach ($absent_libraries as $library) { echo '

        • '; - if ($library['url']) { + if (isset($library['url'])) { echo ''.htmlentities($library['name']).''; } else { echo htmlentities($library['name']); } echo '
            '; - if ($library['deb']) { + if (isset($library['deb'])) { echo '
          • deb: ' . htmlentities($library['deb']) . '
          • '; } - if ($library['rpm']) { + if (isset($library['rpm'])) { echo '
          • rpm: ' . htmlentities($library['rpm']) . '
          • '; } - if ($library['pear']) { + if (isset($library['pear'])) { echo '
          • pear: ' . htmlentities($library['pear']) . '
          • '; } echo '
          '; @@ -552,7 +552,7 @@ STR; updateStatus("You can visit your new StatusNet site."); } -function Pgsql_Db_installer($host, $database, $username, $password) +function Pgsql_Db_installer($host, $database, $username, $password) { $connstring = "dbname=$database host=$host user=$username"; @@ -613,7 +613,7 @@ function Pgsql_Db_installer($host, $database, $username, $password) return $db; } -function Mysql_Db_installer($host, $database, $username, $password) +function Mysql_Db_installer($host, $database, $username, $password) { updateStatus("Starting installation..."); updateStatus("Checking database..."); @@ -690,7 +690,7 @@ function writeConf($sitename, $server, $path, $fancy, $db) * @param string $filename location of database schema file * @param dbconn $conn connection to database * @param string $type type of database, currently mysql or pgsql - * + * * @return boolean - indicating success or failure */ function runDbScript($filename, $conn, $type = 'mysqli') From e29046b3a121db6aa95f94d4114467d0e747c6a7 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 15 Sep 2009 16:46:18 -0700 Subject: [PATCH 26/47] Fixed broken list items in installer output --- install.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index a8f1ef4e24..54ae0cd5e1 100644 --- a/install.php +++ b/install.php @@ -477,7 +477,11 @@ E_O_T; function updateStatus($status, $error=false) { - echo '
        • $status
        • "; } From 46ece1178ce87697e95e5c90daafced142486e56 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 21:12:44 -0400 Subject: [PATCH 27/47] check correct define (not backwards compatible) --- classes/Config.php | 4 +++- classes/Deleted_notice.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index 5bec13fdc8..92f237d7f2 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET')) { + exit(1); +} /** * Table Definition for config diff --git a/classes/Deleted_notice.php b/classes/Deleted_notice.php index 474d0b6f41..64dc85da65 100644 --- a/classes/Deleted_notice.php +++ b/classes/Deleted_notice.php @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET')) { + exit(1); +} /** * Table Definition for notice From d44bc16ee989af7f5ebbd6a40edcc7a4d90902a0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 26 Mar 2009 15:26:19 -0400 Subject: [PATCH 28/47] Start a common library for HTTP client stuff --- lib/httputil.php | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lib/httputil.php diff --git a/lib/httputil.php b/lib/httputil.php new file mode 100644 index 0000000000..5c1f4f3e11 --- /dev/null +++ b/lib/httputil.php @@ -0,0 +1,80 @@ +. + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @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); +} + +/** + * Utility class for doing HTTP-related stuff + * + * We make HTTP calls in several places, and we have several different + * ways of doing them. This class hides the specifics of what underlying + * library (curl or PHP-HTTP or whatever) that's used. + * + * @category HTTP + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class HTTPResponse +{ + var $code = null; + var $headers = null; + var $body = null; +} + +class HTTPClientUtil +{ + function __construct() + { + } + + function head($url, $headers) + { + } + + function get($url, $headers) + { + } + + function post($url, $headers, $body) + { + } + + function put($url, $headers, $body) + { + } + + function delete($url, $headers) + { + } +} From 20dd0db7049209a5f43697d8bba8eadb63736bce Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 20:29:41 -0400 Subject: [PATCH 29/47] move httputil to httpclient --- lib/{httputil.php => httpclient.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/{httputil.php => httpclient.php} (100%) diff --git a/lib/httputil.php b/lib/httpclient.php similarity index 100% rename from lib/httputil.php rename to lib/httpclient.php From ae20d073ce8cb393417be6f05cdf54289ecd5bad Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 20:40:03 -0400 Subject: [PATCH 30/47] update httpclient class --- lib/httpclient.php | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/lib/httpclient.php b/lib/httpclient.php index 5c1f4f3e11..145409f509 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -32,7 +32,7 @@ if (!defined('LACONICA')) { } /** - * Utility class for doing HTTP-related stuff + * Useful structure for HTTP responses * * We make HTTP calls in several places, and we have several different * ways of doing them. This class hides the specifics of what underlying @@ -52,29 +52,66 @@ class HTTPResponse var $body = null; } -class HTTPClientUtil +/** + * Utility class for doing HTTP client stuff + * + * We make HTTP calls in several places, and we have several different + * ways of doing them. This class hides the specifics of what underlying + * library (curl or PHP-HTTP or whatever) that's used. + * + * @category HTTP + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class HTTPClient { - function __construct() + static $_client = null; + + static function start() { + if (!is_null(self::$_client)) { + return self::$_client; + } + + $type = common_config('http', 'client'); + + switch ($type) { + case 'curl': + self::$_client = new CurlClient(); + break; + default: + throw new Exception("Unknown HTTP client type '$type'"); + break; + } + + return self::$_client; } function head($url, $headers) { + throw new Exception("HEAD method unimplemented"); } function get($url, $headers) { + throw new Exception("GET method unimplemented"); } function post($url, $headers, $body) { + throw new Exception("POST method unimplemented"); } function put($url, $headers, $body) { + throw new Exception("PUT method unimplemented"); } function delete($url, $headers) { + throw new Exception("DELETE method unimplemented"); } } From 3380b49aecb773ebadfe4a8e563f75ce4855e1a2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 20:40:18 -0400 Subject: [PATCH 31/47] add http client config value --- lib/common.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/common.php b/lib/common.php index 3b21b548cf..194eb568f7 100644 --- a/lib/common.php +++ b/lib/common.php @@ -284,6 +284,8 @@ $config = array('contentlimit' => null), 'message' => array('contentlimit' => null), + 'http' => + array('client' => 'curl'), // XXX: should this be the default? ); $config['db'] = &PEAR::getStaticProperty('DB_DataObject','options'); From 99c74f2cc4b2a2c62d4188c862fec96caec44c06 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 21:22:15 -0400 Subject: [PATCH 32/47] statusize OpenID plugin --- plugins/OpenID/OpenIDPlugin.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index eb450fc5e5..91bddf381f 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -1,6 +1,6 @@ . * * @category Plugin - * @package Laconica - * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET')) { exit(1); } @@ -36,10 +36,10 @@ if (!defined('LACONICA')) { * and identity system. * * @category Plugin - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ * @link http://openid.net/ */ From 8ceb4196f323295742fd1113ff014ebee9ad7ae3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 21:22:47 -0400 Subject: [PATCH 33/47] add user agent and correct version check to httpclient --- lib/httpclient.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/httpclient.php b/lib/httpclient.php index 145409f509..d606f5a6e9 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -27,7 +27,7 @@ * @link http://laconi.ca/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET')) { exit(1); } @@ -114,4 +114,9 @@ class HTTPClient { throw new Exception("DELETE method unimplemented"); } + + function userAgent() + { + return "StatusNet/".STATUSNET_VERSION." (".STATUSNET_CODENAME.")"; + } } From 9a9a0ae56f5ae65144e6da5014859b1e30044f8b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 21:50:19 -0400 Subject: [PATCH 34/47] add cURL client with HEAD method --- lib/curlclient.php | 134 +++++++++++++++++++++++++++++++++++++++++++++ lib/httpclient.php | 6 +- 2 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 lib/curlclient.php diff --git a/lib/curlclient.php b/lib/curlclient.php new file mode 100644 index 0000000000..e027102e36 --- /dev/null +++ b/lib/curlclient.php @@ -0,0 +1,134 @@ +n. + * + * @category HTTP + * @package Laconica + * @author Evan Prodromou + * @copyright 2009 StatusNet, 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('STATUSNET')) { + exit(1); +} + +define(CURLCLIENT_VERSION, "0.1"); + +/** + * Wrapper for Curl + * + * Makes Curl HTTP client calls within our HTTPClient framework + * + * @category HTTP + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class CurlClient extends HTTPClient +{ + function __construct() + { + } + + function head($url, $headers=null) + { + $ch = curl_init($url); + + $this->setup($ch); + + curl_setopt_array($ch, + array(CURLOPT_NOBODY => true)); + + $result = curl_exec($ch); + + return $this->parseResults($result); + } + + function setup($ch) + { + curl_setopt_array($ch, + array(CURLOPT_USERAGENT, $this->userAgent(), + CURLOPT_HEADER => true, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => $headers)); + } + + function userAgent() + { + $version = curl_version(); + return parent::userAgent() . " CurlClient/".CURLCLIENT_VERSION . " cURL/" . $version['version']; + } + + function parseResults($results) + { + $resp = new HTTPResponse(); + + $lines = explode("\r\n", $results); + + if (preg_match("#^HTTP/1.[01] (\d\d\d) .+$#", $lines[0], $match)) { + $resp->code = $match[1]; + } else { + throw Exception("Bad format: initial line is not HTTP status line"); + } + + $lastk = null; + + for ($i = 1; $i < count($lines); $i++) { + $l =& $lines[$i]; + if (mb_strlen($l) == 0) { + $resp->body = implode("\r\n", array_slice($lines, $i + 1)); + break; + } + if (preg_match("#^(\S+):\s+(.*)$#", $l, $match)) { + $k = $match[1]; + $v = $match[2]; + + if (array_key_exists($k, $resp->headers)) { + if (is_array($resp->headers[$k])) { + $resp->headers[$k][] = $v; + } else { + $resp->headers[$k] = array($resp->headers[$k], $v); + } + } else { + $resp->headers[$k] = $v; + } + $lastk = $k; + } else if (preg_match("#^\s+(.*)$#", $l, $match)) { + // continuation line + if (is_null($lastk)) { + throw Exception("Bad format: initial whitespace in headers"); + } + $h =& $resp->headers[$lastk]; + if (is_array($h)) { + $n = count($h); + $h[$n-1] .= $match[1]; + } else { + $h .= $match[1]; + } + } + } + + return $resp; + } +} diff --git a/lib/httpclient.php b/lib/httpclient.php index d606f5a6e9..9b0bb6f3a5 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -47,9 +47,9 @@ if (!defined('STATUSNET')) { class HTTPResponse { - var $code = null; - var $headers = null; - var $body = null; + public $code = null; + public $headers = null; + public $body = null; } /** From 6b7f09eba675679d5ea84ed33e85fa9d5c62a30d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 21:55:36 -0400 Subject: [PATCH 35/47] add get to curl client --- lib/curlclient.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/curlclient.php b/lib/curlclient.php index e027102e36..f45c3c2f4a 100644 --- a/lib/curlclient.php +++ b/lib/curlclient.php @@ -60,8 +60,31 @@ class CurlClient extends HTTPClient curl_setopt_array($ch, array(CURLOPT_NOBODY => true)); + if (!is_null($headers)) { + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + $result = curl_exec($ch); + curl_close($ch); + + return $this->parseResults($result); + } + + function get($url, $headers=null) + { + $ch = curl_init($url); + + $this->setup($ch); + + if (!is_null($headers)) { + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + + $result = curl_exec($ch); + + curl_close($ch); + return $this->parseResults($result); } @@ -70,8 +93,7 @@ class CurlClient extends HTTPClient curl_setopt_array($ch, array(CURLOPT_USERAGENT, $this->userAgent(), CURLOPT_HEADER => true, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_HTTPHEADER => $headers)); + CURLOPT_RETURNTRANSFER => true)); } function userAgent() From f8a8c14b550a3ac3a4b3a17c53559056f70409b2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 22:05:57 -0400 Subject: [PATCH 36/47] fix user-agent for curlclient --- lib/curlclient.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/curlclient.php b/lib/curlclient.php index f45c3c2f4a..99c3b6aa41 100644 --- a/lib/curlclient.php +++ b/lib/curlclient.php @@ -88,10 +88,14 @@ class CurlClient extends HTTPClient return $this->parseResults($result); } + function post($url, $headers=null) + { + } + function setup($ch) { curl_setopt_array($ch, - array(CURLOPT_USERAGENT, $this->userAgent(), + array(CURLOPT_USERAGENT => $this->userAgent(), CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true)); } From 2f97531a49c042a0a900edb31f067a3c9f32967f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 22:14:15 -0400 Subject: [PATCH 37/47] add post to curlclient --- lib/curlclient.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/curlclient.php b/lib/curlclient.php index 99c3b6aa41..c43bfb57f7 100644 --- a/lib/curlclient.php +++ b/lib/curlclient.php @@ -88,8 +88,27 @@ class CurlClient extends HTTPClient return $this->parseResults($result); } - function post($url, $headers=null) + function post($url, $headers=null, $body=null) { + $ch = curl_init($url); + + $this->setup($ch); + + curl_setopt($ch, CURLOPT_POST, true); + + if (!is_null($body)) { + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); + } + + if (!is_null($headers)) { + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + + $result = curl_exec($ch); + + curl_close($ch); + + return $this->parseResults($result); } function setup($ch) From 6f531745ca21e7b5460be90890c55b1934a45f15 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 22:28:59 -0400 Subject: [PATCH 38/47] change all evans to evan@status.net --- actions/all.php | 6 +++--- actions/api.php | 6 +++--- actions/finishremotesubscribe.php | 2 +- actions/updateprofile.php | 2 +- index.php | 6 +++--- install.php | 2 +- lib/httpclient.php | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/actions/all.php b/actions/all.php index e56e10c21f..5ffc7e9bd1 100644 --- a/actions/all.php +++ b/actions/all.php @@ -18,15 +18,15 @@ * * @category Actions * @package Actions - * @author Evan Prodromou - * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou * @author Mike Cochrane * @author Robin Millette * @author Adrian Lang * @author Meitar Moscovitz * @author Sarven Capadisli * @author Craig Andrews - * @author Evan Prodromou + * @author Evan Prodromou * @author Evan Prodromou * @author Jeffery To * @author Zach Copley diff --git a/actions/api.php b/actions/api.php index 9b5f548074..06fdbfb44c 100644 --- a/actions/api.php +++ b/actions/api.php @@ -18,8 +18,8 @@ * * @category Actions * @package Actions - * @author Evan Prodromou - * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou * @author Brenda Wallace * @author Jeffery To * @author Robin Millette @@ -27,7 +27,7 @@ * @author Christopher Vollick * @author CiaranG * @author Craig Andrews - * @author Evan Prodromou + * @author Evan Prodromou * @author Evan Prodromou * @author Gina Haeussge * @author Mike Cochrane diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index 44abbfceb7..5f6807d10a 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -41,7 +41,7 @@ require_once INSTALLDIR.'/lib/omb.php'; * * @category Action * @package Laconica - * @author Evan Prodromou + * @author Evan Prodromou * @author Robin Millette * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://laconi.ca/ diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 7f7dd75fef..d9cc7f7f3c 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -38,7 +38,7 @@ require_once INSTALLDIR.'/extlib/libomb/service_provider.php'; * * @category Action * @package Laconica - * @author Evan Prodromou + * @author Evan Prodromou * @author Robin Millette * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://laconi.ca/ diff --git a/index.php b/index.php index a1d983dce7..4e6c093792 100644 --- a/index.php +++ b/index.php @@ -23,9 +23,9 @@ * @author Christopher Vollick * @author CiaranG * @author Craig Andrews - * @author Evan Prodromou - * @author Evan Prodromou - * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou * @author Evan Prodromou * @author Gina Haeussge * @author Jeffery To diff --git a/install.php b/install.php index 54ae0cd5e1..24ad3eb246 100644 --- a/install.php +++ b/install.php @@ -26,7 +26,7 @@ * @author CiaranG * @author Craig Andrews * @author Eric Helgeson - * @author Evan Prodromou + * @author Evan Prodromou * @author Evan Prodromou * @author Robin Millette * @author Sarven Capadisli diff --git a/lib/httpclient.php b/lib/httpclient.php index 9b0bb6f3a5..0059711534 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -21,7 +21,7 @@ * * @category Action * @package Laconica - * @author Evan Prodromou + * @author Evan Prodromou * @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/ @@ -40,7 +40,7 @@ if (!defined('STATUSNET')) { * * @category HTTP * @package Laconica - * @author Evan Prodromou + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://laconi.ca/ */ @@ -61,7 +61,7 @@ class HTTPResponse * * @category HTTP * @package Laconica - * @author Evan Prodromou + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://laconi.ca/ */ From 1618d515e6d96c8c0458295282de89dfae790e00 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 22:30:52 -0400 Subject: [PATCH 39/47] dedupe evans --- actions/all.php | 9 +++------ actions/api.php | 15 ++++++--------- index.php | 21 +++++++++------------ install.php | 1 - 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/actions/all.php b/actions/all.php index 5ffc7e9bd1..22da3cd681 100644 --- a/actions/all.php +++ b/actions/all.php @@ -15,19 +15,16 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * + * * @category Actions * @package Actions * @author Evan Prodromou - * @author Evan Prodromou * @author Mike Cochrane * @author Robin Millette * @author Adrian Lang * @author Meitar Moscovitz * @author Sarven Capadisli * @author Craig Andrews - * @author Evan Prodromou - * @author Evan Prodromou * @author Jeffery To * @author Zach Copley * @author csarven @@ -35,8 +32,8 @@ * @link http://status.net */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); } require_once INSTALLDIR.'/lib/personalgroupnav.php'; diff --git a/actions/api.php b/actions/api.php index 06fdbfb44c..243ae4c629 100644 --- a/actions/api.php +++ b/actions/api.php @@ -15,11 +15,10 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * + * * @category Actions * @package Actions * @author Evan Prodromou - * @author Evan Prodromou * @author Brenda Wallace * @author Jeffery To * @author Robin Millette @@ -27,8 +26,6 @@ * @author Christopher Vollick * @author CiaranG * @author Craig Andrews - * @author Evan Prodromou - * @author Evan Prodromou * @author Gina Haeussge * @author Mike Cochrane * @author Sarven Capadisli @@ -36,8 +33,8 @@ * @link http://status.net */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); } class ApiAction extends Action @@ -205,9 +202,9 @@ class ApiAction extends Action $user_id = $this->arg('user_id'); $screen_name = $this->arg('screen_name'); - if (empty($this->api_arg) - && empty($id) - && empty($user_id) + if (empty($this->api_arg) + && empty($id) + && empty($user_id) && empty($screen_name) ) { return true; diff --git a/index.php b/index.php index 4e6c093792..fb37585908 100644 --- a/index.php +++ b/index.php @@ -15,23 +15,20 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - * + * * @category StatusNet * @package StatusNet * @license GNU Affero General Public License http://www.gnu.org/licenses/ - * @author Brenda Wallace - * @author Christopher Vollick + * @author Brenda Wallace + * @author Christopher Vollick * @author CiaranG - * @author Craig Andrews + * @author Craig Andrews * @author Evan Prodromou - * @author Evan Prodromou - * @author Evan Prodromou - * @author Evan Prodromou - * @author Gina Haeussge + * @author Gina Haeussge * @author Jeffery To * @author Mike Cochrane * @author Robin Millette - * @author Sarven Capadisli + * @author Sarven Capadisli * @author Tom Adams */ @@ -74,7 +71,7 @@ function handleError($error) common_log(LOG_ERR, $line); } } - if ($error instanceof DB_DataObject_Error + if ($error instanceof DB_DataObject_Error || $error instanceof DB_Error ) { $msg = sprintf( @@ -227,8 +224,8 @@ function main() // 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') - && !isLoginAction($action) + if (!$user && common_config('site', 'private') + && !isLoginAction($action) && !preg_match('/rss$/', $action) ) { common_redirect(common_local_url('login')); diff --git a/install.php b/install.php index 24ad3eb246..4398757dea 100644 --- a/install.php +++ b/install.php @@ -27,7 +27,6 @@ * @author Craig Andrews * @author Eric Helgeson * @author Evan Prodromou - * @author Evan Prodromou * @author Robin Millette * @author Sarven Capadisli * @author Tom Adams From 15a2b69777479f1544a681ed1bff76aa066cf95c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 15 Sep 2009 22:31:52 -0400 Subject: [PATCH 40/47] statusize new HTTP classes --- lib/curlclient.php | 10 +++++----- lib/httpclient.php | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/curlclient.php b/lib/curlclient.php index c43bfb57f7..36fc7d157e 100644 --- a/lib/curlclient.php +++ b/lib/curlclient.php @@ -1,6 +1,6 @@ n. * * @category HTTP - * @package Laconica + * @package StatusNet * @author Evan Prodromou * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ if (!defined('STATUSNET')) { @@ -39,10 +39,10 @@ define(CURLCLIENT_VERSION, "0.1"); * Makes Curl HTTP client calls within our HTTPClient framework * * @category HTTP - * @package Laconica + * @package StatusNet * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ class CurlClient extends HTTPClient diff --git a/lib/httpclient.php b/lib/httpclient.php index 0059711534..c8c8ae5b26 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -1,6 +1,6 @@ . * * @category Action - * @package Laconica + * @package StatusNet * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. + * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ if (!defined('STATUSNET')) { @@ -39,10 +39,10 @@ if (!defined('STATUSNET')) { * library (curl or PHP-HTTP or whatever) that's used. * * @category HTTP - * @package Laconica + * @package StatusNet * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ class HTTPResponse @@ -60,10 +60,10 @@ class HTTPResponse * library (curl or PHP-HTTP or whatever) that's used. * * @category HTTP - * @package Laconica + * @package StatusNet * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ class HTTPClient From 83b09164573ede90d87a7038a56f651a5f82b9f1 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 16 Sep 2009 11:14:26 +0200 Subject: [PATCH 41/47] Updated csarven emails to csarven@status.net and removed dupes --- actions/all.php | 3 +-- actions/api.php | 2 +- index.php | 2 +- install.php | 2 +- theme/readme.txt | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/actions/all.php b/actions/all.php index 22da3cd681..f1786462e1 100644 --- a/actions/all.php +++ b/actions/all.php @@ -23,11 +23,10 @@ * @author Robin Millette * @author Adrian Lang * @author Meitar Moscovitz - * @author Sarven Capadisli + * @author Sarven Capadisli * @author Craig Andrews * @author Jeffery To * @author Zach Copley - * @author csarven * @license GNU Affero General Public License http://www.gnu.org/licenses/ * @link http://status.net */ diff --git a/actions/api.php b/actions/api.php index 243ae4c629..d570bb0174 100644 --- a/actions/api.php +++ b/actions/api.php @@ -28,7 +28,7 @@ * @author Craig Andrews * @author Gina Haeussge * @author Mike Cochrane - * @author Sarven Capadisli + * @author Sarven Capadisli * @license GNU Affero General Public License http://www.gnu.org/licenses/ * @link http://status.net */ diff --git a/index.php b/index.php index fb37585908..d5174c2b7e 100644 --- a/index.php +++ b/index.php @@ -28,7 +28,7 @@ * @author Jeffery To * @author Mike Cochrane * @author Robin Millette - * @author Sarven Capadisli + * @author Sarven Capadisli * @author Tom Adams */ diff --git a/install.php b/install.php index 4398757dea..81241315e1 100644 --- a/install.php +++ b/install.php @@ -28,7 +28,7 @@ * @author Eric Helgeson * @author Evan Prodromou * @author Robin Millette - * @author Sarven Capadisli + * @author Sarven Capadisli * @author Tom Adams * @license GNU Affero General Public License http://www.gnu.org/licenses/ */ diff --git a/theme/readme.txt b/theme/readme.txt index 151b1fb71c..d030f2db4d 100644 --- a/theme/readme.txt +++ b/theme/readme.txt @@ -1,7 +1,7 @@ /** Howto: create a statusnet theme * * @package StatusNet - * @author Sarven Capadisli + * @author Sarven Capadisli * @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/ From 39aa9b3a9f6a27738ad1cd330c471ae388b11088 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 17 Sep 2009 20:15:15 +1200 Subject: [PATCH 42/47] fixed up space on @author tags --- index.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/index.php b/index.php index d5174c2b7e..208259eb6a 100644 --- a/index.php +++ b/index.php @@ -19,17 +19,20 @@ * @category StatusNet * @package StatusNet * @license GNU Affero General Public License http://www.gnu.org/licenses/ - * @author Brenda Wallace - * @author Christopher Vollick - * @author CiaranG - * @author Craig Andrews - * @author Evan Prodromou - * @author Gina Haeussge - * @author Jeffery To - * @author Mike Cochrane - * @author Robin Millette - * @author Sarven Capadisli - * @author Tom Adams + * @author Brenda Wallace + * @author Christopher Vollick + * @author CiaranG + * @author Craig Andrews + * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou + * @author Evan Prodromou + * @author Gina Haeussge + * @author Jeffery To + * @author Mike Cochrane + * @author Robin Millette + * @author Sarven Capadisli + * @author Tom Adams */ define('INSTALLDIR', dirname(__FILE__)); From e9bdc696516b007b94e9557ba98d5e96779fb0e0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 19 Sep 2009 12:28:08 +1200 Subject: [PATCH 43/47] @author tags updated -- only one entry per name now --- index.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index 208259eb6a..8ff67d19d9 100644 --- a/index.php +++ b/index.php @@ -18,21 +18,19 @@ * * @category StatusNet * @package StatusNet - * @license GNU Affero General Public License http://www.gnu.org/licenses/ - * @author Brenda Wallace - * @author Christopher Vollick + * @author Brenda Wallace + * @author Christopher Vollick * @author CiaranG - * @author Craig Andrews + * @author Craig Andrews * @author Evan Prodromou - * @author Evan Prodromou - * @author Evan Prodromou - * @author Evan Prodromou - * @author Gina Haeussge + * @author Gina Haeussge * @author Jeffery To * @author Mike Cochrane * @author Robin Millette - * @author Sarven Capadisli + * @author Sarven Capadisli * @author Tom Adams + * + * @license GNU Affero General Public License http://www.gnu.org/licenses/ */ define('INSTALLDIR', dirname(__FILE__)); From 83e232bd3f9f58f4d670bcf1e579fb65293096c6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 19 Sep 2009 16:01:42 +1200 Subject: [PATCH 44/47] Pear code style --- install.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/install.php b/install.php index 81241315e1..46248c7891 100644 --- a/install.php +++ b/install.php @@ -31,6 +31,8 @@ * @author Sarven Capadisli * @author Tom Adams * @license GNU Affero General Public License http://www.gnu.org/licenses/ + * @version 0.9 + * @link http://status.net */ define('INSTALLDIR', dirname(__FILE__)); @@ -476,12 +478,7 @@ E_O_T; function updateStatus($status, $error=false) { - echo '$status"; + echo '$status"; } function handlePost() From 8548e1185deac0a289e16ea48a64f323c3bec679 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 19 Sep 2009 21:38:52 +0200 Subject: [PATCH 45/47] Fix merges. --- actions/finishremotesubscribe.php | 63 ------------------------------- actions/updateprofile.php | 49 ++++-------------------- 2 files changed, 8 insertions(+), 104 deletions(-) diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index 5f6807d10a..b1cec66f48 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -143,67 +143,4 @@ class FinishremotesubscribeAction extends Action $user->nickname)), 303); } - - function add_avatar($profile, $url) - { - $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar'); - copy($url, $temp_filename); - $imagefile = new ImageFile($profile->id, $temp_filename); - $filename = Avatar::filename($profile->id, - image_type_to_extension($imagefile->type), - null, - common_timestamp()); - rename($temp_filename, Avatar::path($filename)); - return $profile->setOriginal($filename); - } - - function access_token($omb) - { - - common_debug('starting request for access token', __FILE__); - - $con = omb_oauth_consumer(); - $tok = new OAuthToken($omb['token'], $omb['secret']); - - common_debug('using request token "'.$tok.'"', __FILE__); - - $url = $omb['access_token_url']; - - common_debug('using access token url "'.$url.'"', __FILE__); - - # XXX: Is this the right thing to do? Strip off GET params and make them - # POST params? Seems wrong to me. - - $parsed = parse_url($url); - $params = array(); - parse_str($parsed['query'], $params); - - $req = OAuthRequest::from_consumer_and_token($con, $tok, "POST", $url, $params); - - $req->set_parameter('omb_version', OMB_VERSION_01); - - # XXX: test to see if endpoint accepts this signature method - - $req->sign_request(omb_hmac_sha1(), $con, $tok); - - # We re-use this tool's fetcher, since it's pretty good - - common_debug('posting to access token url "'.$req->get_normalized_http_url().'"', __FILE__); - common_debug('posting request data "'.$req->to_postdata().'"', __FILE__); - - $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); - $result = $fetcher->post($req->get_normalized_http_url(), - $req->to_postdata(), - array('User-Agent: StatusNet/' . STATUSNET_VERSION)); - - common_debug('got result: "'.print_r($result,true).'"', __FILE__); - - if ($result->status != 200) { - return null; - } - - parse_str($result->body, $return); - - return array($return['oauth_token'], $return['oauth_token_secret']); - } } diff --git a/actions/updateprofile.php b/actions/updateprofile.php index d9cc7f7f3c..4ff4f41c0d 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -55,46 +55,13 @@ class UpdateprofileAction extends Action */ function prepare($argarray) { - $version = $req->get_parameter('omb_version'); - if ($version != OMB_VERSION_01) { - $this->clientError(_('Unsupported OMB version'), 400); - return false; - } - # First, check to see if listenee exists - $listenee = $req->get_parameter('omb_listenee'); - $remote = Remote_profile::staticGet('uri', $listenee); - if (!$remote) { - $this->clientError(_('Profile unknown'), 404); - return false; - } - # Second, check to see if they should be able to post updates! - # We see if there are any subscriptions to that remote user with - # the given token. - - $sub = new Subscription(); - $sub->subscribed = $remote->id; - $sub->token = $token->key; - if (!$sub->find(true)) { - $this->clientError(_('You did not send us that profile'), 403); - return false; - } - - $profile = Profile::staticGet('id', $remote->id); - if (!$profile) { - # This one is our fault - $this->serverError(_('Remote profile with no matching profile'), 500); - return false; - } - $nickname = $req->get_parameter('omb_listenee_nickname'); - if ($nickname && !Validate::string($nickname, array('min_length' => 1, - 'max_length' => 64, - 'format' => NICKNAME_FMT))) { - $this->clientError(_('Nickname must have only lowercase letters and numbers and no spaces.')); - return false; - } - $license = $req->get_parameter('omb_listenee_license'); - if ($license && !common_valid_http_url($license)) { - $this->clientError(sprintf(_("Invalid license URL '%s'"), $license)); + parent::prepare($argarray); + $license = $_POST['omb_listenee_license']; + $site_license = common_config('license', 'url'); + if (!common_compatible_license($license, $site_license)) { + $this->clientError(sprintf(_('Listenee stream license ‘%s’ is not '. + 'compatible with site license ‘%s’.'), + $license, $site_license); return false; } return true; @@ -113,4 +80,4 @@ class UpdateprofileAction extends Action return; } } -} \ No newline at end of file +} From e0ff80f1c7c0d7daa9b81652e2d545b17b47fe05 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 19 Sep 2009 21:40:48 +0200 Subject: [PATCH 46/47] Add missing parenthesis. --- actions/updateprofile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 4ff4f41c0d..3cec9523cd 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -61,7 +61,7 @@ class UpdateprofileAction extends Action if (!common_compatible_license($license, $site_license)) { $this->clientError(sprintf(_('Listenee stream license ‘%s’ is not '. 'compatible with site license ‘%s’.'), - $license, $site_license); + $license, $site_license)); return false; } return true; From 8aad3154a7673091291af4b95da2736e98aa75e7 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sat, 19 Sep 2009 18:34:07 -0700 Subject: [PATCH 47/47] Make statuses/home_timeline return the same thing as statuses/friends_timeline to support apps trying to use the new retweet API method. --- actions/twitapistatuses.php | 5 +++++ lib/router.php | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index ad6654dff5..2f10ff966c 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -136,6 +136,11 @@ class TwitapistatusesAction extends TwitterapiAction } + function home_timeline($args, $apidata) + { + call_user_func(array($this, 'friends_timeline'), $args, $apidata); + } + function user_timeline($args, $apidata) { parent::handle($args); diff --git a/lib/router.php b/lib/router.php index 8f13b88520..2c4d63b0d7 100644 --- a/lib/router.php +++ b/lib/router.php @@ -265,12 +265,12 @@ class Router $m->connect('api/statuses/:method', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?')); + array('method' => '(public_timeline|home_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?')); $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); + array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); // users @@ -429,7 +429,7 @@ class Router $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); + array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); $m->connect('api/statusnet/groups/:method/:argument', array('action' => 'api',