From ec345f7a1343769abdf3f5920a0732b24726b733 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Fri, 13 May 2011 14:26:51 -0400 Subject: new privatekey2 branch with privatekey changes --- data/schema/6.sql | 4 + data/tables.sql | 3 +- data/templates/editprofile.tpl.php | 8 + data/templates/rss.tpl.php | 4 +- data/templates/top.inc.php | 2 +- doc/UPGRADE.txt | 3 + src/SemanticScuttle/Model/User.php | 26 ++- src/SemanticScuttle/Service/Bookmark.php | 2 +- src/SemanticScuttle/Service/User.php | 211 +++++++++++++++++--- tests/BookmarkTest.php | 46 +++++ tests/TestBase.php | 13 +- tests/UserTest.php | 333 ++++++++++++++++++++++++++++++- www/index.php | 13 ++ www/jsScuttle.php | 10 + www/profile.php | 32 ++- www/rss.php | 43 +++- 16 files changed, 704 insertions(+), 49 deletions(-) diff --git a/data/schema/6.sql b/data/schema/6.sql index 0c208ad..e4acd53 100644 --- a/data/schema/6.sql +++ b/data/schema/6.sql @@ -13,3 +13,7 @@ CREATE TABLE `sc_users_sslclientcerts` ( PRIMARY KEY ( `id` ) , UNIQUE (`id`) ) CHARACTER SET utf8 COLLATE utf8_general_ci; + +ALTER TABLE `sc_users` ADD `privateKey` VARCHAR(33) NULL; +CREATE INDEX `privateKey` ON `sc_users` (`privateKey`); + diff --git a/data/tables.sql b/data/tables.sql index d53945e..dd4e924 100644 --- a/data/tables.sql +++ b/data/tables.sql @@ -84,8 +84,9 @@ CREATE TABLE `sc_users_sslclientcerts` ( `sslClientIssuerDn` VARCHAR( 1024 ) NOT NULL , `sslName` VARCHAR( 64 ) NOT NULL , `sslEmail` VARCHAR( 64 ) NOT NULL , + `privateKey` varchar(33) default NULL, PRIMARY KEY ( `id` ) , - UNIQUE (`id`) + UNIQUE KEY `privateKey` (`privateKey`) ) CHARACTER SET utf8 COLLATE utf8_general_ci; -- diff --git a/data/templates/editprofile.tpl.php b/data/templates/editprofile.tpl.php index cc74f04..76f608a 100644 --- a/data/templates/editprofile.tpl.php +++ b/data/templates/editprofile.tpl.php @@ -28,6 +28,14 @@ $this->includeTemplate($GLOBALS['top_include']); + + + /> +     + + + +

diff --git a/data/templates/rss.tpl.php b/data/templates/rss.tpl.php index e6e66f7..6be5425 100644 --- a/data/templates/rss.tpl.php +++ b/data/templates/rss.tpl.php @@ -3,7 +3,7 @@ echo '<' . '?xml version="1.0" encoding="utf-8" ?' . ">\n"; ?> - <?php echo htmlspecialchars($feedtitle); ?> + <?php echo $feedtitle; ?> @@ -23,4 +23,4 @@ echo '<' . '?xml version="1.0" encoding="utf-8" ?' . ">\n"; - \ No newline at end of file + diff --git a/data/templates/top.inc.php b/data/templates/top.inc.php index bdd4b1a..738b71e 100644 --- a/data/templates/top.inc.php +++ b/data/templates/top.inc.php @@ -12,7 +12,7 @@ if (isset($rsschannels)) { $size = count($rsschannels); for ($i = 0; $i < $size; $i++) { echo ' '; } } diff --git a/doc/UPGRADE.txt b/doc/UPGRADE.txt index 3be6654..fe8624a 100644 --- a/doc/UPGRADE.txt +++ b/doc/UPGRADE.txt @@ -12,6 +12,9 @@ Database updates: Apply data/schema/6.sql or do the following: INSERT INTO `sc_version` (`schema_version`) VALUES ('6'); + ALTER TABLE `sc_users` ADD `privateKey` VARCHAR(33) NULL; + CREATE INDEX `privateKey` ON `sc_users` (`privateKey`); + From version 0.96 to 0.97 ------------------------- diff --git a/src/SemanticScuttle/Model/User.php b/src/SemanticScuttle/Model/User.php index 500f5b1..3aa617b 100644 --- a/src/SemanticScuttle/Model/User.php +++ b/src/SemanticScuttle/Model/User.php @@ -35,6 +35,7 @@ class SemanticScuttle_Model_User var $content; var $datetime; var $isAdmin; + var $privateKey; /** * Create a new user object @@ -68,6 +69,29 @@ class SemanticScuttle_Model_User return $this->username; } + /** + * Returns private key + * + * @param boolean return sanitized value which basically drops + * leading dash if exists + * + * @return string private key + */ + public function getPrivateKey($sanitized = false) + { + // Look for value only if not already set + if (!isset($this->privateKey)) { + $us = SemanticScuttle_Service_Factory::get('User'); + $user = $us->getUser($this->id); + $this->privateKey = $user['privateKey']; + } + if ($sanitized == true) { + return substr($this->privateKey, -32); + } else { + return $this->privateKey; + } + } + /** * Returns full user name as specified in the profile. * @@ -182,4 +206,4 @@ class SemanticScuttle_Model_User } } -?> \ No newline at end of file +?> diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index 919ca7a..e836cd8 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -717,7 +717,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService // All public bookmarks, user's own bookmarks // and any shared with user $privacy = ' AND ((B.bStatus = 0) OR (B.uId = '. $sId .')'; - $watchnames = $userservice->getWatchNames($sId, true); + $watchnames = $userservice->getWatchNames($sId); foreach ($watchnames as $watchuser) { $privacy .= ' OR (U.username = "'. $watchuser .'" AND B.bStatus = 1)'; } diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index 09a2cb1..c3633de 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -48,9 +48,10 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService protected $currentuser = null; protected $fields = array( - 'primary' => 'uId', - 'username' => 'username', - 'password' => 'password' + 'primary' => 'uId', + 'username' => 'username', + 'password' => 'password', + 'privatekey' => 'privatekey' ); protected $profileurl; @@ -215,6 +216,18 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService return $this->_getuser($this->getFieldName('username'), $username); } + /** + * Returns user row from database. + * + * @param string $privatekey Private Key + * + * @return array User array from database, false if no user was found + */ + public function getUserByPrivateKey($privatekey) + { + return $this->_getuser($this->getFieldName('privatekey'), $privatekey); + } + function getObjectUserByUsername($username) { $user = $this->_getuser($this->getFieldName('username'), $username); if($user != false) { @@ -279,6 +292,22 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService return ($this->getCurrentUserId() !== false); } + /** + * Tells you if the private key is enabled and valid + * + * @param string $privateKey Private Key + * + * @return boolean True if enabled and valid + */ + public function isPrivateKeyValid($privateKey) + { + // check length of private key + if (strlen($privateKey) == 32) { + return true; + } + return false; + } + /** * Returns the current user object * @@ -293,7 +322,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService { if (!is_null($newval)) { //internal use only: reset currentuser - $currentuser = $newval; + $this->currentuser = $newval; } else if ($refresh || !isset($this->currentuser)) { if ($id = $this->getCurrentUserId()) { $this->currentuser = $this->getUser($id); @@ -509,6 +538,47 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService } } + /** + * Try to authenticate via the privatekey + * + * @param string $privatekey Private Key + * + * @return boolean true if the user could be authenticated, + * false if not. + */ + public function loginPrivateKey($privatekey) + { + /* Check if private key valid and enabled */ + if (!$this->isPrivateKeyValid($privatekey)) { + return false; + } + + $query = 'SELECT '. $this->getFieldName('primary') .' FROM ' + . $this->getTableName() .' WHERE ' + . $this->getFieldName('privatekey') .' = "' + . $this->db->sql_escape($privatekey) .'"'; + + if (!($dbresult = $this->db->sql_query($query))) { + message_die( + GENERAL_ERROR, + 'Could not get user', + '', __LINE__, __FILE__, $query, $this->db + ); + return false; + } + + $row = $this->db->sql_fetchrow($dbresult); + $this->db->sql_freeresult($dbresult); + + if ($row) { + $id = $_SESSION[$this->getSessionKey()] + = $row[$this->getFieldName('primary')]; + return true; + } else { + return false; + } + } + /** * Logs the user off * @@ -519,7 +589,8 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService @setcookie($this->getCookiekey(), '', time() - 1, '/'); unset($_COOKIE[$this->getCookiekey()]); session_unset(); - $this->getCurrentUser(TRUE, false); + $this->currentuserId = null; + $this->currentuser = null; } function getWatchlist($uId) { @@ -646,24 +717,26 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService * No checks are done in here - you ought to have checked * everything before calling this method! * - * @param string $username Username to use - * @param string $password Password to use - * @param string $email Email to use + * @param string $username Username to use + * @param string $password Password to use + * @param string $email Email to use + * @param string $privateKey Key for RSS auth * * @return mixed Integer user ID if all is well, * boolean false if an error occured */ - public function addUser($username, $password, $email) + public function addUser($username, $password, $email, $privateKey = null) { // Set up the SQL UPDATE statement. $datetime = gmdate('Y-m-d H:i:s', time()); $password = $this->sanitisePassword($password); $values = array( - 'username' => $username, - 'password' => $password, - 'email' => $email, - 'uDatetime' => $datetime, - 'uModified' => $datetime + 'username' => $username, + 'password' => $password, + 'email' => $email, + 'uDatetime' => $datetime, + 'uModified' => $datetime, + 'privateKey' => $privateKey ); $sql = 'INSERT INTO '. $this->getTableName() . ' '. $this->db->sql_build_array('INSERT', $values); @@ -687,40 +760,64 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService /** * Updates the given user * - * @param integer $uId ID of user to change - * @param string $password Password to use - * @param string $name Realname to use - * @param string $email Email to use - * @param string $homepage User's homepage - * @param string $uContent User note + * @param integer $uId ID of user to change + * @param string $password Password to use + * @param string $name Realname to use + * @param string $email Email to use + * @param string $homepage User's homepage + * @param string $uContent User note + * @param string $privateKey RSS Private Key + * @param boolean $enablePrivateKey RSS Private Key Flag * * @return boolean True when all is well, false if not */ public function updateUser( - $uId, $password, $name, $email, $homepage, $uContent + $uId, $password, $name, $email, $homepage, $uContent, + $privateKey = null, $enablePrivateKey = false ) { if (!is_numeric($uId)) { return false; } + // prepend '-' to privateKey if disabled + if ($privateKey != null && strlen($privateKey) == 32 + && $enablePrivateKey == false + ) { + $privateKey = '-' . $privateKey; + } + + // remove '-' from privateKey if enabling + if ($privateKey != null && strlen($privateKey) == 33 + && $enablePrivateKey == true + ) { + $privateKey = substr($privateKey, 1, 32); + } + + // if new user is enabling Private Key, create new key + if ($privateKey == null && $enablePrivateKey == true) { + $privateKey = $this->getNewPrivateKey(); + } + // Set up the SQL UPDATE statement. $moddatetime = gmdate('Y-m-d H:i:s', time()); if ($password == '') { $updates = array( - 'uModified' => $moddatetime, - 'name' => $name, - 'email' => $email, - 'homepage' => $homepage, - 'uContent' => $uContent + 'uModified' => $moddatetime, + 'name' => $name, + 'email' => $email, + 'homepage' => $homepage, + 'uContent' => $uContent, + 'privateKey' => $privateKey ); } else { $updates = array( - 'uModified' => $moddatetime, - 'password' => $this->sanitisePassword($password), - 'name' => $name, - 'email' => $email, - 'homepage' => $homepage, - 'uContent' => $uContent + 'uModified' => $moddatetime, + 'password' => $this->sanitisePassword($password), + 'name' => $name, + 'email' => $email, + 'homepage' => $homepage, + 'uContent' => $uContent, + 'privateKey' => $privateKey ); } $sql = 'UPDATE '. $this->getTableName() @@ -837,6 +934,56 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService } } + /** + * Generates a new private key and confirms it isn't being used. + * Private key is 32 characters long, consisting of lowercase and + * numeric characters. + * + * @return string the new key value + */ + public function getNewPrivateKey() + { + do { + $newKey = md5(uniqid('SemanticScuttle', true)); + } while ($this->privateKeyExists($newKey)); + + return $newKey; + } + + /** + * Checks if a private key already exists + * + * @param string $privateKey key that has been generated + * + * @return boolean true when the private key exists, + * False if not. + */ + public function privateKeyExists($privateKey) + { + if (!$privateKey) { + return false; + } + $crit = array('privateKey' => $privateKey); + + $sql = 'SELECT COUNT(*) as "0" FROM ' + . $GLOBALS['tableprefix'] . 'users' + . ' WHERE '. $this->db->sql_build_array('SELECT', $crit); + + if (!($dbresult = $this->db->sql_query($sql))) { + message_die( + GENERAL_ERROR, 'Could not get vars', '', + __LINE__, __FILE__, $sql, $this->db + ); + } + if ($this->db->sql_fetchfield(0, 0) > 0) { + $exists = true; + } else { + $exists = false; + } + $this->db->sql_freeresult($dbresult); + return $exists; + } + function isReserved($username) { if (in_array($username, $GLOBALS['reservedusers'])) { return true; diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php index b50dab2..44a82d9 100644 --- a/tests/BookmarkTest.php +++ b/tests/BookmarkTest.php @@ -1330,5 +1330,51 @@ class BookmarkTest extends TestBase + /** + * Test private bookmarks + * + * @return void + */ + public function testPrivateBookmarks() + { + $uid = $this->addUser(); + /* create private bookmark */ + $this->bs->addBookmark( + 'http://test', 'test', 'desc', 'note', + 2,//private + array(), null, null, false, false, $uid + ); + /* create public bookmark */ + $this->bs->addBookmark( + 'http://example.org', 'title', 'desc', 'priv', + 0,//public + array(), null, null, false, false, $uid + ); + + $this->assertEquals(1, $this->bs->countBookmarks($uid, 'public')); + $this->assertEquals(1, $this->bs->countBookmarks($uid, 'private')); + $this->assertEquals(0, $this->bs->countBookmarks($uid, 'shared')); + $this->assertEquals(2, $this->bs->countBookmarks($uid, 'all')); + + $this->us->setCurrentUserId($uid); + $bookmarks = $this->bs->getBookmarks(); + // first record should be private bookmark + $b0 = $bookmarks['bookmarks'][0]; + $this->assertEquals('test', $b0['bTitle']); + // second record should be public bookmark + $b0 = $bookmarks['bookmarks'][1]; + $this->assertEquals('title', $b0['bTitle']); + + // test non authenticated query + $this->us->setCurrentUserId(null); + $bookmarks = $this->bs->getBookmarks(); + // should only result in one link - public + $b2 = $bookmarks['bookmarks'][0]; + $this->assertEquals('title', $b2['bTitle']); + // there should be no second record + $this->assertEquals(1,count($bookmarks['bookmarks'])); + + } + } ?> diff --git a/tests/TestBase.php b/tests/TestBase.php index 095f32d..1331ec6 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -78,14 +78,15 @@ class TestBase extends PHPUnit_Framework_TestCase * * @param string $username Username * @param string $password Password + * @param string $pkey Private Key * * @return integer ID of user * * @uses addUserData() */ - protected function addUser($username = null, $password = null) + protected function addUser($username = null, $password = null, $pkey = null) { - return reset($this->addUserData($username, $password)); + return reset($this->addUserData($username, $password, $pkey)); } @@ -95,10 +96,11 @@ class TestBase extends PHPUnit_Framework_TestCase * * @param string $username Username * @param string $password Password + * @param string $pkey Private Key * * @return array ID of user, Name of user, password of user */ - protected function addUserData($username = null, $password = null) + protected function addUserData($username = null, $password = null, $pkey = null) { $us = SemanticScuttle_Service_Factory::get('User'); $rand = rand(); @@ -113,7 +115,8 @@ class TestBase extends PHPUnit_Framework_TestCase $uid = $us->addUser( $username, $password, - 'unittest-' . $rand . '@example.org' + 'unittest-' . $rand . '@example.org', + $pkey ); return array($uid, $username, $password); } @@ -148,4 +151,4 @@ class TestBase extends PHPUnit_Framework_TestCase } } -?> \ No newline at end of file +?> diff --git a/tests/UserTest.php b/tests/UserTest.php index 2f57112..230167d 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -34,6 +34,157 @@ class UserTest extends TestBase + /** + * @covers SemanticScuttle_Service_User::addUser + */ + public function testAddUserPrivateKey() + { + $name = substr(md5(uniqid()), 0, 6); + $pkey = 'my-privatekey'; + $id = $this->us->addUser( + $name, uniqid(), 'foo@example.org', $pkey + ); + $this->assertNotEquals(false, $id); + $this->assertInternalType('integer', $id); + + $arUser = $this->us->getUserByPrivateKey($pkey); + $this->assertNotEquals(false, $arUser, 'user not found by private key'); + $this->assertEquals($id, $arUser['uId'], 'wrong user loaded'); + } + + + /** + * @covers SemanticScuttle_Service_User::updateUser + */ + public function testUpdateUserFalseWhenIdNotNumeric() + { + $this->assertFalse( + $this->us->updateUser('foo', null, null, null, null, null) + ); + } + + + /** + * @covers SemanticScuttle_Service_User::updateUser + */ + public function testUpdateUserPrivateKeyNewKeyEnabled() + { + $pkey = 'testUpdateUserPrivateKeyNewKey12'; + $uid = $this->addUser(); + + $this->assertTrue( + $this->us->updateUser( + $uid, 'password', 'name', 'test@example.org', '', '', + $pkey, true + ) + ); + $arUser = $this->us->getUser($uid); + $this->assertInternalType('array', $arUser); + $this->assertEquals($pkey, $arUser['privateKey']); + } + + + /** + * @covers SemanticScuttle_Service_User::updateUser + */ + public function testUpdateUserPrivateKeyNewKeyDisabled() + { + $pkey = 'testUpdateUserPrivateKeyNewKeyDi'; + $uid = $this->addUser(); + + $this->assertTrue( + $this->us->updateUser( + $uid, 'password', 'name', 'test@example.org', '', '', + $pkey, false + ) + ); + $arUser = $this->us->getUser($uid); + $this->assertInternalType('array', $arUser); + $this->assertEquals( + '-' . $pkey, $arUser['privateKey'], + 'private key did not get disabled' + ); + } + + + /** + * Passing an empty string / NULL as key but enabling it + * should automatically create a new key. + * + * @covers SemanticScuttle_Service_User::updateUser + */ + public function testUpdateUserPrivateKeyNoKeyEnabled() + { + $pkey = 'testUpdateUserPrivateKeyNoKeyEna'; + $uid = $this->addUser(); + + $this->assertTrue( + $this->us->updateUser( + $uid, 'password', 'name', 'test@example.org', '', '', + null, true + ) + ); + $arUser = $this->us->getUser($uid); + $this->assertInternalType('array', $arUser); + $this->assertNotEquals( + '', $arUser['privateKey'], 'private key was not created' + ); + } + + + /** + * Passing an empty string / NULL as key and disabling it + * should keep no key + * + * @covers SemanticScuttle_Service_User::updateUser + */ + public function testUpdateUserPrivateKeyNoKeyDisabled() + { + $pkey = 'testUpdateUserPrivateKeyNoKeyDis'; + $uid = $this->addUser(); + + $this->assertTrue( + $this->us->updateUser( + $uid, 'password', 'name', 'test@example.org', '', '', + null, false + ) + ); + $arUser = $this->us->getUser($uid); + $this->assertInternalType('array', $arUser); + $this->assertEquals( + '', $arUser['privateKey'], 'private key was set' + ); + } + + + /** + * Passing an empty string / NULL as key and disabling it + * should keep no key + * + * @covers SemanticScuttle_Service_User::updateUser + */ + public function testUpdateUserPrivateKeyExistingKeyEnabled() + { + $pkey = '12345678901234567890123456789012'; + $uid = $this->addUser(); + + $this->assertTrue( + $this->us->updateUser( + $uid, 'password', 'name', 'test@example.org', '', '', + '-' . $pkey, true + ) + ); + $arUser = $this->us->getUser($uid); + $this->assertInternalType('array', $arUser); + $this->assertEquals( + $pkey, $arUser['privateKey'], 'private key was not enabled' + ); + } + + //FIXME: verify I cannot re-use private key of different user + + + /** * Test that setting the current user ID is permanent. * and that the current user array is the same ID @@ -176,5 +327,185 @@ class UserTest extends TestBase ); } + + public function testGetUserByPrivateKeyEmptyKey() + { + $arUser = $this->us->getUserByPrivateKey(null); + $this->assertFalse($arUser); + } + + + public function testGetUserByPrivateKeyInvalid() + { + $arUser = $this->us->getUserByPrivateKey('foobar'); + $this->assertFalse($arUser); + + $arUser = $this->us->getUserByPrivateKey('%'); + $this->assertFalse($arUser); + } + + + public function testGetUserByPrivateKeyValidKey() + { + $pkey = $this->us->getNewPrivateKey(); + $uId = $this->addUser(null, null, $pkey); + + $arUser = $this->us->getUserByPrivateKey($pkey); + $this->assertInternalType('array', $arUser); + $this->assertArrayHasKey('uId', $arUser); + $this->assertArrayHasKey('username', $arUser); + + $this->assertEquals($uId, $arUser['uId']); + } + + + /** + * @covers SemanticScuttle_Service_User::privateKeyExists + */ + public function testPrivateKeyExistsEmpty() + { + $this->assertFalse($this->us->privateKeyExists(null)); + $this->assertFalse($this->us->privateKeyExists('')); + } + + + /** + * @covers SemanticScuttle_Service_User::privateKeyExists + */ + public function testPrivateKeyExistsInvalid() + { + $this->assertFalse($this->us->privateKeyExists('-1')); + } + + + /** + * @covers SemanticScuttle_Service_User::privateKeyExists + */ + public function testPrivateKeyExists() + { + $randKey = $this->us->getNewPrivateKey(); + $this->assertFalse($this->us->privateKeyExists($randKey)); + $uid = $this->addUser(null, null, $randKey); + + $this->us->setCurrentUserId($uid); + $this->assertEquals($uid, $this->us->getCurrentUserId()); + + $this->assertTrue($this->us->privateKeyExists($randKey)); + } + + + /** + * @covers SemanticScuttle_Service_User::isPrivateKeyValid + */ + public function testIsPrivateKeyValid() + { + $this->assertFalse( + $this->us->isPrivateKeyValid(null), + 'NULL is an invalid private key' + ); + + $randKey = $this->us->getNewPrivateKey(); + $this->assertTrue( + $this->us->isPrivateKeyValid($randKey), + 'generated key should be valid' + ); + + $randKey2 = '-'.$this->us->getNewPrivateKey(); + $this->assertFalse( + $this->us->isPrivateKeyValid($randKey2), + 'disabled privatekey should return false' + ); + } + + + public function testLoginPrivateKeyInvalid() + { + /* normal user with enabled privatekey */ + $randKey = $this->us->getNewPrivateKey(); + $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); + /* user that has disabled privatekey */ + $randKey2 = '-'.$this->us->getNewPrivateKey(); + $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); + + /* test invalid private key */ + $this->assertFalse( + $this->us->loginPrivateKey('02848248084082408240824802408248') + ); + } + + + public function testLoginPrivateKeyValidEnabledKey() + { + /* normal user with enabled privatekey */ + $randKey = $this->us->getNewPrivateKey(); + $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); + /* user that has disabled privatekey */ + $randKey2 = '-'.$this->us->getNewPrivateKey(); + $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); + + + /* test valid credentials with private key enabled */ + $this->assertTrue( + $this->us->loginPrivateKey($randKey) + ); + } + + + public function testLoginPrivateKeyInvalidEnabledKey() + { + /* normal user with enabled privatekey */ + $randKey = $this->us->getNewPrivateKey(); + $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); + /* user that has disabled privatekey */ + $randKey2 = '-'.$this->us->getNewPrivateKey(); + $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); + + + /* test valid credentials with private key enabled but invalid key */ + $this->assertFalse( + $this->us->loginPrivateKey('123') + ); + } + + + public function testLoginPrivateKeyValidDisabledKey() + { + /* normal user with enabled privatekey */ + $randKey = $this->us->getNewPrivateKey(); + $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); + /* user that has disabled privatekey */ + $randKey2 = '-'.$this->us->getNewPrivateKey(); + $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); + + /* confirm user exists so future fails should be due to randkey */ + $this->assertTrue( + $this->us->login('seconduser', 'passw0RD', false) + ); + + /* test valid credentials with private key disabled */ + $this->assertFalse( + $this->us->loginPrivateKey($randKey2) + ); + } + + + public function testLoginPrivateKeyInvalidDisabled() + { + /* normal user with enabled privatekey */ + $randKey = $this->us->getNewPrivateKey(); + $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); + /* user that has disabled privatekey */ + $randKey2 = '-'.$this->us->getNewPrivateKey(); + $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); + + /* test valid credentials with private key disabled and invalid key */ + $this->assertFalse( + $this->us->loginPrivateKey('-1') + ); + $this->assertFalse( + $this->us->loginPrivateKey(null) + ); + } + } -?> \ No newline at end of file +?> diff --git a/www/index.php b/www/index.php index f6704ae..0977923 100644 --- a/www/index.php +++ b/www/index.php @@ -45,6 +45,19 @@ $tplVars['rsschannels'] = array( array(sprintf(T_('%s: Recent bookmarks'), $sitename), createURL('rss').'?sort='.getSortOrder()) ); +if ($userservice->isLoggedOn()) { + $currentUsername = $currentUser->getUsername(); + if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) { + array_push( + $tplVars['rsschannels'], + array( + filter($sitename . sprintf(T_(': (private) ')) . $currentUsername), + createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) + ) + ); + } +} + if ($usecache) { // Generate hash for caching on $hashtext = $_SERVER['REQUEST_URI']; diff --git a/www/jsScuttle.php b/www/jsScuttle.php index c166755..76b49dc 100644 --- a/www/jsScuttle.php +++ b/www/jsScuttle.php @@ -89,6 +89,16 @@ function useAddress(ele) { } } +function getNewPrivateKey(input, response){ + var pk = document.getElementById('pPrivateKey'); + if (response != null) { + pk.value = response.trim(); + } else { + loadXMLDocProc('ajaxGetNewPrivateKey.php'); + } + return false; +} + function getTitle(input, response){ var title = document.getElementById('titleField'); if (title.value == '') { diff --git a/www/profile.php b/www/profile.php index ccdb7a8..e6894d0 100644 --- a/www/profile.php +++ b/www/profile.php @@ -25,10 +25,13 @@ require_once 'www-header.php'; // No specific services /* Managing all possible inputs */ +isset($_POST['submittedPK']) ? define('POST_SUBMITTEDPK', $_POST['submittedPK']): define('POST_SUBMITTEDPK', ''); isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', ''); isset($_POST['pPass']) ? define('POST_PASS', $_POST['pPass']): define('POST_PASS', ''); isset($_POST['pPassConf']) ? define('POST_PASSCONF', $_POST['pPassConf']): define('POST_PASSCONF', ''); isset($_POST['pName']) ? define('POST_NAME', $_POST['pName']): define('POST_NAME', ''); +isset($_POST['pPrivateKey']) ? define('POST_PRIVATEKEY', $_POST['pPrivateKey']): define('POST_PRIVATEKEY', ''); +isset($_POST['pEnablePrivateKey']) ? define('POST_ENABLEPRIVATEKEY', $_POST['pEnablePrivateKey']): define('POST_ENABLEPRIVATEKEY', ''); isset($_POST['pMail']) ? define('POST_MAIL', $_POST['pMail']): define('POST_MAIL', ''); isset($_POST['pPage']) ? define('POST_PAGE', $_POST['pPage']): define('POST_PAGE', ''); isset($_POST['pDesc']) ? define('POST_DESC', $_POST['pDesc']): define('POST_DESC', ''); @@ -61,10 +64,19 @@ if ($user) { exit(); } +$tplVars['privateKeyIsEnabled'] = ''; if ($userservice->isLoggedOn() && $user == $currentUser->getUsername()) { - $title = T_('My Profile'); + $title = T_('My Profile'); + $tplVars['privateKey'] = $currentUser->getPrivateKey(true); + + if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) { + $tplVars['privateKeyIsEnabled'] = 'checked="checked"'; + } else { + $tplVars['privateKeyIsEnabled'] = ''; + } } else { - $title = T_('Profile') .': '. $user; + $title = T_('Profile') .': '. $user; + $tplVars['privateKey'] = ''; } $tplVars['pagetitle'] = $title; $tplVars['subtitle'] = $title; @@ -72,11 +84,19 @@ $tplVars['subtitle'] = $title; $tplVars['user'] = $user; $tplVars['userid'] = $userid; +/* Update Private Key */ +if (POST_SUBMITTEDPK!='' && $currentUser->getId() == $userid) { + $userinfo = $userservice->getObjectUserByUsername($user); + $tplVars['privateKey'] = $userservice->getNewPrivateKey(); +} + if (POST_SUBMITTED!='' && $currentUser->getId() == $userid) { $error = false; $detPass = trim(POST_PASS); $detPassConf = trim(POST_PASSCONF); $detName = trim(POST_NAME); + $detPrivateKey = trim(POST_PRIVATEKEY); + $detEnablePrivateKey = trim(POST_ENABLEPRIVATEKEY); $detMail = trim(POST_MAIL); $detPage = trim(POST_PAGE); $detDesc = filter(POST_DESC); @@ -102,13 +122,19 @@ if (POST_SUBMITTED!='' && $currentUser->getId() == $userid) { $tplVars['error'] = T_('E-mail address is not valid.'); } if (!$error) { - if (!$userservice->updateUser($userid, $detPass, $detName, $detMail, $detPage, $detDesc)) { + if (!$userservice->updateUser($userid, $detPass, $detName, $detMail, $detPage, $detDesc, $detPrivateKey, $detEnablePrivateKey)) { $tplVars['error'] = T_('An error occurred while saving your changes.'); } else { $tplVars['msg'] = T_('Changes saved.'); } } $userinfo = $userservice->getObjectUserByUsername($user); + $tplVars['privateKey'] = $userinfo->getPrivateKey(true); + if ($userservice->isPrivateKeyValid($userinfo->getPrivateKey())) { + $tplVars['privateKeyIsEnabled'] = 'checked="checked"'; + } else { + $tplVars['privateKeyIsEnabled'] = ''; + } } if (!$userservice->isLoggedOn() || $currentUser->getId() != $userid) { diff --git a/www/rss.php b/www/rss.php index 50240e5..8c81e0e 100644 --- a/www/rss.php +++ b/www/rss.php @@ -64,9 +64,14 @@ if (!isset($rssEntries) || $rssEntries <= 0) { $rssEntries = $maxRssEntries; } +$privatekey = null; +if (isset($_GET['privatekey'])) { + $privatekey = $_GET['privatekey']; +} $watchlist = null; $pagetitle = ''; +$isTempLogin = false; if ($user && $user != 'all') { if ($user == 'watchlist') { $user = $cat; @@ -78,8 +83,24 @@ if ($user && $user != 'all') { } else { if ($userinfo = $userservice->getUserByUsername($user)) { $userid =& $userinfo[$userservice->getFieldName('primary')]; + /* if user is not logged in and has valid privatekey */ + if (!$userservice->isLoggedOn()) { + if ($privatekey != null) { + if ($userservice->loginPrivateKey($privatekey)) { + $isTempLogin = true; + } else { + $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user); + header('Content-type: text/html; charset=utf-8'); + $templateservice->loadTemplate('error.404.tpl', $tplVars); + //throw a 404 error + exit(); + } + } + } + } else { $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user); + header('Content-type: text/html; charset=utf-8'); $templateservice->loadTemplate('error.404.tpl', $tplVars); //throw a 404 error exit(); @@ -87,7 +108,19 @@ if ($user && $user != 'all') { } $pagetitle .= ": ". $user; } else { - $userid = null; + if ($privatekey != null) { + if ($userservice->loginPrivateKey($privatekey)) { + $isTempLogin = true; + } else { + $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user); + header('Content-type: text/html; charset=utf-8'); + $templateservice->loadTemplate('error.404.tpl', $tplVars); + //throw a 404 error + exit(); + } + } else { + $userid = null; + } } if ($cat) { @@ -100,7 +133,8 @@ $tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOB $bookmarks = $bookmarkservice->getBookmarks( 0, $rssEntries, $userid, $cat, - null, getSortOrder(), $watchlist + null, getSortOrder(), $watchlist, + null, null, null ); $bookmarks_tmp = filter($bookmarks['bookmarks']); @@ -134,6 +168,11 @@ $tplVars['feedlastupdate'] = date('r', strtotime($latestdate)); $templateservice->loadTemplate('rss.tpl', $tplVars); +/* If temporary login, please log out */ +if ($isTempLogin) { + $userservice->logout(); +} + if ($usecache) { // Cache output if existing copy has expired $cacheservice->End($hash); -- cgit v1.2.3-54-g00ecf From 6ed90e647a0a513def828ec66f17df2b724c518e Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Sat, 14 May 2011 21:46:35 -0400 Subject: Fixed sql commands where resources were not freed --- src/SemanticScuttle/Service/Bookmark.php | 1 + src/SemanticScuttle/Service/User.php | 9 ++++--- www/ajaxGetNewPrivateKey.php | 42 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 www/ajaxGetNewPrivateKey.php diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index e836cd8..57d0b2e 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -427,6 +427,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService $existence[$hashes[$row['bHash']]] = $row['count'] > 0; } + $this->db->sql_freeresult($dbresult); return $existence; } diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index c3633de..01945ca 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -674,11 +674,12 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService return false; } - $arrWatch = array(); + $retval = true; if ($this->db->sql_numrows($dbresult) == 0) - return false; - else - return true; + $retval = false; + + $this->db->sql_freeresult($dbresult); + return $retval; } function setWatchStatus($subjectUserID) { diff --git a/www/ajaxGetNewPrivateKey.php b/www/ajaxGetNewPrivateKey.php new file mode 100644 index 0000000..59545a2 --- /dev/null +++ b/www/ajaxGetNewPrivateKey.php @@ -0,0 +1,42 @@ +'; +?> + + +getNewPrivateKey + + +getNewPrivateKey(); ?> + + -- cgit v1.2.3-54-g00ecf From 16791766dee4f9c03700b7c817063071e4d0ed33 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Sat, 14 May 2011 23:08:46 -0400 Subject: Fixed SQL structure for PrivateKey --- data/schema/6.sql | 2 +- data/tables.sql | 8 ++++---- doc/UPGRADE.txt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/schema/6.sql b/data/schema/6.sql index e4acd53..cf9dd37 100644 --- a/data/schema/6.sql +++ b/data/schema/6.sql @@ -15,5 +15,5 @@ CREATE TABLE `sc_users_sslclientcerts` ( ) CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `sc_users` ADD `privateKey` VARCHAR(33) NULL; -CREATE INDEX `privateKey` ON `sc_users` (`privateKey`); +CREATE UNIQUE INDEX `privateKey` ON `sc_users` (`privateKey`); diff --git a/data/tables.sql b/data/tables.sql index dd4e924..68d5ba9 100644 --- a/data/tables.sql +++ b/data/tables.sql @@ -72,7 +72,9 @@ CREATE TABLE `sc_users` ( `email` varchar(50) NOT NULL default '', `homepage` varchar(255) default NULL, `uContent` text, - PRIMARY KEY (`uId`) + `privateKey` varchar(33) default NULL, + PRIMARY KEY (`uId`), + UNIQUE KEY `privateKey` (`privateKey`) ) CHARACTER SET utf8 COLLATE utf8_general_ci ; -- -------------------------------------------------------- @@ -84,9 +86,7 @@ CREATE TABLE `sc_users_sslclientcerts` ( `sslClientIssuerDn` VARCHAR( 1024 ) NOT NULL , `sslName` VARCHAR( 64 ) NOT NULL , `sslEmail` VARCHAR( 64 ) NOT NULL , - `privateKey` varchar(33) default NULL, - PRIMARY KEY ( `id` ) , - UNIQUE KEY `privateKey` (`privateKey`) + PRIMARY KEY ( `id` ) ) CHARACTER SET utf8 COLLATE utf8_general_ci; -- diff --git a/doc/UPGRADE.txt b/doc/UPGRADE.txt index fe8624a..53ccbf4 100644 --- a/doc/UPGRADE.txt +++ b/doc/UPGRADE.txt @@ -13,7 +13,7 @@ Database updates: Apply data/schema/6.sql or do the following: INSERT INTO `sc_version` (`schema_version`) VALUES ('6'); ALTER TABLE `sc_users` ADD `privateKey` VARCHAR(33) NULL; - CREATE INDEX `privateKey` ON `sc_users` (`privateKey`); + CREATE UNIQUE INDEX `privateKey` ON `sc_users` (`privateKey`); From version 0.96 to 0.97 -- cgit v1.2.3-54-g00ecf From 10214c43b51e99cc3f8f58a4c4e8893eb2480e62 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Mon, 16 May 2011 00:35:31 -0400 Subject: Updated 'Generate New Key' button to use ajax if javascript enabled. --- data/templates/editprofile.tpl.php | 4 +++- src/SemanticScuttle/Service/Bookmark.php | 11 ++++++----- www/profile.php | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/data/templates/editprofile.tpl.php b/data/templates/editprofile.tpl.php index 76f608a..258e864 100644 --- a/data/templates/editprofile.tpl.php +++ b/data/templates/editprofile.tpl.php @@ -33,7 +33,9 @@ $this->includeTemplate($GLOBALS['top_include']); />     - + + + diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index 57d0b2e..9a075be 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -728,14 +728,15 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService $privacy = ' AND B.bStatus = 0'; } + $tagcount = 0; // Set up the tags, if need be. - if (!is_array($tags) && !is_null($tags)) { + if (!is_array($tags) && !is_null($tags) && $tags<>"") { $tags = explode('+', trim($tags)); - } - $tagcount = count($tags); - for ($i = 0; $i < $tagcount; $i ++) { - $tags[$i] = trim($tags[$i]); + $tagcount = count($tags); + for ($i = 0; $i < $tagcount; $i ++) { + $tags[$i] = trim($tags[$i]); + } } // Set up the SQL query. diff --git a/www/profile.php b/www/profile.php index e6894d0..63f4da8 100644 --- a/www/profile.php +++ b/www/profile.php @@ -23,6 +23,7 @@ require_once 'www-header.php'; /* Service creation: only useful services are created */ // No specific services +$tplVars['loadjs'] = true; /* Managing all possible inputs */ isset($_POST['submittedPK']) ? define('POST_SUBMITTEDPK', $_POST['submittedPK']): define('POST_SUBMITTEDPK', ''); -- cgit v1.2.3-54-g00ecf From 2c3f6338e36be8dbfe32e30d8a3094da4df5d978 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 16 May 2011 12:54:05 +0200 Subject: there is no onClick attribute, only onclick --- data/templates/editprofile.tpl.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data/templates/editprofile.tpl.php b/data/templates/editprofile.tpl.php index 258e864..70f340d 100644 --- a/data/templates/editprofile.tpl.php +++ b/data/templates/editprofile.tpl.php @@ -35,7 +35,9 @@ $this->includeTemplate($GLOBALS['top_include']); - + + + -- cgit v1.2.3-54-g00ecf From 920f7fc623ecad4f1338ab68326f2817c12c4610 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Tue, 17 May 2011 00:24:43 -0400 Subject: Updated PrivateKey to include Tag searches --- data/templates/editprofile.tpl.php | 4 +-- src/SemanticScuttle/Service/Bookmark.php | 37 ++++++++++++++++++---------- src/SemanticScuttle/Service/Bookmark2Tag.php | 2 +- src/SemanticScuttle/Service/Tag.php | 4 +-- www/bookmarks.php | 17 ++++++++++++- www/tags.php | 15 ++++++++++- 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/data/templates/editprofile.tpl.php b/data/templates/editprofile.tpl.php index 258e864..25dc3a4 100644 --- a/data/templates/editprofile.tpl.php +++ b/data/templates/editprofile.tpl.php @@ -33,9 +33,7 @@ $this->includeTemplate($GLOBALS['top_include']); />     - - - + diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index 9a075be..232f9d0 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -821,23 +821,34 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService // Handle the parts of the query that depend on any tags that are present. $query_4 = ''; - for ($i = 0; $i < $tagcount; $i ++) { - $query_2 .= ', '. $b2tservice->getTableName() .' AS T'. $i; + if ($tagcount > 0) { + $query_2 .= ', '. $b2tservice->getTableName() .' AS T0'; $query_4 .= ' AND ('; + + $tagArray = array(); + for ($i = 0; $i < $tagcount; $i ++) { + $tmpTag = $this->db->sql_escape($tags[$i]); + $allLinkedTags = $tag2tagservice->getAllLinkedTags( + $tmpTag, '>', $user + ); - $allLinkedTags = $tag2tagservice->getAllLinkedTags( - $this->db->sql_escape($tags[$i]), '>', $user - ); + while (is_array($allLinkedTags) && count($allLinkedTags)>0) { + $tmpValue = array_pop($allLinkedTags); + if (in_array($tmpValue, $tagArray) == false) { + $tagArray[] = $tmpValue; + } + } - while (is_array($allLinkedTags) && count($allLinkedTags)>0) { - $query_4 .= ' T'. $i .'.tag = "'. array_pop($allLinkedTags) .'"'; - $query_4 .= ' OR'; + if (in_array($tmpTag, $tagArray) == false) { + $tagArray[] = $tmpTag; + } } - - $query_4 .= ' T'. $i .'.tag = "'. $this->db->sql_escape($tags[$i]) .'"'; - - $query_4 .= ') AND T'. $i .'.bId = B.bId'; - //die($query_4); + // loop through array of possible tags + foreach ($tagArray as $k => $v) { + $query_4 .= ' T0.tag = "'. $v .'" OR'; + } + $query_4 = substr($query_4,0,-3); + $query_4 .= ') AND T0.bId = B.bId'; } // Search terms diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php index a10cb61..fc59a1c 100644 --- a/src/SemanticScuttle/Service/Bookmark2Tag.php +++ b/src/SemanticScuttle/Service/Bookmark2Tag.php @@ -99,7 +99,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService $tags_count = is_array($tags)?count($tags):0; for ($i = 0; $i < $tags_count; $i++) { - $tags[$i] = trim(strtolower($tags[$i])); + $tags[$i] = trim(utf8_strtolower($tags[$i])); if ($fromApi) { include_once 'SemanticScuttle/functions.php'; $tags[$i] = convertTag($tags[$i], 'in'); diff --git a/src/SemanticScuttle/Service/Tag.php b/src/SemanticScuttle/Service/Tag.php index 25d3888..8325285 100644 --- a/src/SemanticScuttle/Service/Tag.php +++ b/src/SemanticScuttle/Service/Tag.php @@ -141,10 +141,10 @@ class SemanticScuttle_Service_Tag extends SemanticScuttle_DbService //normalize if(!is_array($tags)) { - $tags = strtolower(trim($tags)); + $tags = utf8_strtolower(trim($tags)); } else { for($i=0; $igetWatchNames($sId); + $watchnames = $userservice->getWatchNames($sId, true); foreach ($watchnames as $watchuser) { $privacy .= ' OR (U.username = "'. $watchuser .'" AND B.bStatus = 1)'; } @@ -728,15 +728,14 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService $privacy = ' AND B.bStatus = 0'; } - $tagcount = 0; // Set up the tags, if need be. - if (!is_array($tags) && !is_null($tags) && $tags<>"") { + if (!is_array($tags) && !is_null($tags)) { $tags = explode('+', trim($tags)); + } - $tagcount = count($tags); - for ($i = 0; $i < $tagcount; $i ++) { - $tags[$i] = trim($tags[$i]); - } + $tagcount = count($tags); + for ($i = 0; $i < $tagcount; $i ++) { + $tags[$i] = trim($tags[$i]); } // Set up the SQL query. @@ -821,34 +820,23 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService // Handle the parts of the query that depend on any tags that are present. $query_4 = ''; - if ($tagcount > 0) { - $query_2 .= ', '. $b2tservice->getTableName() .' AS T0'; + for ($i = 0; $i < $tagcount; $i ++) { + $query_2 .= ', '. $b2tservice->getTableName() .' AS T'. $i; $query_4 .= ' AND ('; - - $tagArray = array(); - for ($i = 0; $i < $tagcount; $i ++) { - $tmpTag = $this->db->sql_escape($tags[$i]); - $allLinkedTags = $tag2tagservice->getAllLinkedTags( - $tmpTag, '>', $user - ); - while (is_array($allLinkedTags) && count($allLinkedTags)>0) { - $tmpValue = array_pop($allLinkedTags); - if (in_array($tmpValue, $tagArray) == false) { - $tagArray[] = $tmpValue; - } - } + $allLinkedTags = $tag2tagservice->getAllLinkedTags( + $this->db->sql_escape($tags[$i]), '>', $user + ); - if (in_array($tmpTag, $tagArray) == false) { - $tagArray[] = $tmpTag; - } - } - // loop through array of possible tags - foreach ($tagArray as $k => $v) { - $query_4 .= ' T0.tag = "'. $v .'" OR'; + while (is_array($allLinkedTags) && count($allLinkedTags)>0) { + $query_4 .= ' T'. $i .'.tag = "'. array_pop($allLinkedTags) .'"'; + $query_4 .= ' OR'; } - $query_4 = substr($query_4,0,-3); - $query_4 .= ') AND T0.bId = B.bId'; + + $query_4 .= ' T'. $i .'.tag = "'. $this->db->sql_escape($tags[$i]) .'"'; + + $query_4 .= ') AND T'. $i .'.bId = B.bId'; + //die($query_4); } // Search terms diff --git a/tests/Tag2TagTest.php b/tests/Tag2TagTest.php index 0b73864..58556f1 100644 --- a/tests/Tag2TagTest.php +++ b/tests/Tag2TagTest.php @@ -332,6 +332,7 @@ class Tag2TagTest extends TestBase $this->assertSame('B3', $results['bookmarks'][0]['bTitle']); $results = $bs->getBookmarks(0, NULL, 1, 'aa+ee'); + $this->assertSame(1, intval($results['total'])); $this->assertSame('B2', $results['bookmarks'][0]['bTitle']); -- cgit v1.2.3-54-g00ecf From e0149e24e2b5fac3b875fda468b18fbe2b6b1218 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Sat, 21 May 2011 14:36:29 -0400 Subject: Resolve some failed bookmark and tag tests --- data/templates/bookmarks.tpl.php | 4 ++-- tests/AllTests.php | 3 ++- tests/Api/PostsAddTest.php | 4 ++-- tests/Bookmark2TagTest.php | 6 +++--- www/index.php | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/data/templates/bookmarks.tpl.php b/data/templates/bookmarks.tpl.php index 55d6a0f..42aaa95 100644 --- a/data/templates/bookmarks.tpl.php +++ b/data/templates/bookmarks.tpl.php @@ -220,8 +220,8 @@ if ($currenttag!= '') { $size = count($rsschannels); for ($i = 0; $i < $size; $i++) { $brss = '' - . '' . htmlspecialchars($rsschannels[$i][0]) .'' + . ' title="' . $rsschannels[$i][0] . '">' + . '' . $rsschannels[$i][0] .'' . ''; } diff --git a/tests/AllTests.php b/tests/AllTests.php index 9e825e8..92f8960 100644 --- a/tests/AllTests.php +++ b/tests/AllTests.php @@ -46,6 +46,7 @@ class AllTests extends PHPUnit_Framework_TestSuite $suite->addTestFile($tdir . '/VoteTest.php'); $suite->addTestFile($tdir . '/UserTest.php'); $suite->addTestFile($tdir . '/Api/ExportCsvTest.php'); + $suite->addTestFile($tdir . '/Api/OpenSearchTest.php'); $suite->addTestFile($tdir . '/Api/PostsAddTest.php'); $suite->addTestFile($tdir . '/Api/PostsDeleteTest.php'); $suite->addTestFile($tdir . '/Api/PostsUpdateTest.php'); @@ -58,4 +59,4 @@ class AllTests extends PHPUnit_Framework_TestSuite { } } -?> \ No newline at end of file +?> diff --git a/tests/Api/PostsAddTest.php b/tests/Api/PostsAddTest.php index 02e2b38..e6d0531 100644 --- a/tests/Api/PostsAddTest.php +++ b/tests/Api/PostsAddTest.php @@ -108,7 +108,7 @@ TXT; $this->assertEquals($bmUrl, $bm['bAddress']); $this->assertEquals($bmTitle, $bm['bTitle']); - $this->assertEquals($bmDescription, $bm['bDescription']); + $this->assertEquals($bmDescription, stripslashes($bm['bDescription'])); $this->assertEquals($bmTags, $bm['tags']); $this->assertEquals( gmdate('Y-m-d H:i:s', strtotime($bmDatetime)), @@ -170,7 +170,7 @@ TXT; $this->assertEquals($bmUrl, $bm['bAddress']); $this->assertEquals($bmTitle, $bm['bTitle']); - $this->assertEquals($bmDescription, $bm['bDescription']); + $this->assertEquals($bmDescription, stripslashes($bm['bDescription'])); $this->assertEquals($bmTags, $bm['tags']); $this->assertEquals( gmdate('Y-m-d H:i:s', strtotime($bmDatetime)), diff --git a/tests/Bookmark2TagTest.php b/tests/Bookmark2TagTest.php index 789540f..66a6e1f 100644 --- a/tests/Bookmark2TagTest.php +++ b/tests/Bookmark2TagTest.php @@ -290,8 +290,8 @@ class Bookmark2TagTest extends TestBase $arTags = $this->b2ts->getPopularTags(null, 10, null, 1); $this->assertInternalType('array', $arTags); $this->assertEquals(3, count($arTags)); - $this->assertContains(array('tag' => 'one', 'bCount' => '2'), $arTags); - $this->assertContains(array('tag' => 'two', 'bCount' => '1'), $arTags); + $this->assertContains(array('tag' => 'one', 'bCount' => '3'), $arTags); + $this->assertContains(array('tag' => 'two', 'bCount' => '2'), $arTags); $this->assertContains(array('tag' => 'thr', 'bCount' => '1'), $arTags); $arTags = $this->b2ts->getPopularTags(null, 10, null, 2); @@ -608,4 +608,4 @@ class Bookmark2TagTest extends TestBase $this->assertContains(array('tag' => 'usable', 'bCount' => '2'), $arTags); } } -?> \ No newline at end of file +?> diff --git a/www/index.php b/www/index.php index 0977923..931d64d 100644 --- a/www/index.php +++ b/www/index.php @@ -42,7 +42,7 @@ if (GET_ACTION == "logout") { // Header variables $tplVars['loadjs'] = true; $tplVars['rsschannels'] = array( -array(sprintf(T_('%s: Recent bookmarks'), $sitename), createURL('rss').'?sort='.getSortOrder()) +array(sprintf(T_('%s: Recent bookmarks'), htmlspecialchars($sitename)), createURL('rss').'?sort='.getSortOrder()) ); if ($userservice->isLoggedOn()) { -- cgit v1.2.3-54-g00ecf From 342d1c3205c2f2ae9d918f66e28e8ffa153c2854 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Sat, 21 May 2011 22:06:44 -0400 Subject: Altered tests to be more timezone friendly --- src/SemanticScuttle/Service/Bookmark.php | 2 +- tests/Api/PostsAddTest.php | 4 ++-- tests/Bookmark2TagTest.php | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index 17ab7ba..f69b4d1 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -486,7 +486,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService } else { $time = strtotime($date); } - $datetime = gmdate('Y-m-d H:i:s', $time); + $datetime = date('Y-m-d H:i:s', $time); if ($short === '') { $short = null; diff --git a/tests/Api/PostsAddTest.php b/tests/Api/PostsAddTest.php index e6d0531..2613a87 100644 --- a/tests/Api/PostsAddTest.php +++ b/tests/Api/PostsAddTest.php @@ -111,7 +111,7 @@ TXT; $this->assertEquals($bmDescription, stripslashes($bm['bDescription'])); $this->assertEquals($bmTags, $bm['tags']); $this->assertEquals( - gmdate('Y-m-d H:i:s', strtotime($bmDatetime)), + date('Y-m-d H:i:s', strtotime($bmDatetime)), $bm['bDatetime'] ); } @@ -173,7 +173,7 @@ TXT; $this->assertEquals($bmDescription, stripslashes($bm['bDescription'])); $this->assertEquals($bmTags, $bm['tags']); $this->assertEquals( - gmdate('Y-m-d H:i:s', strtotime($bmDatetime)), + date('Y-m-d H:i:s', strtotime($bmDatetime)), $bm['bDatetime'] ); } diff --git a/tests/Bookmark2TagTest.php b/tests/Bookmark2TagTest.php index 66a6e1f..0236a5f 100644 --- a/tests/Bookmark2TagTest.php +++ b/tests/Bookmark2TagTest.php @@ -282,16 +282,16 @@ class Bookmark2TagTest extends TestBase public function testGetPopularTagsDays() { $user = $this->addUser(); - $this->addTagBookmark($user, array('one', 'two'), 'today'); - $this->addTagBookmark($user, array('one', 'thr'), 'today'); - $this->addTagBookmark($user, array('one', 'two'), '-1 day 1 hour'); - $this->addTagBookmark($user, array('one', 'thr'), '-3 days 1 hour'); + $this->addTagBookmark($user, array('one', 'two'), 'now'); + $this->addTagBookmark($user, array('one', 'thr'), 'now'); + $this->addTagBookmark($user, array('one', 'two'), '-1 day -1 hour'); + $this->addTagBookmark($user, array('one', 'thr'), '-3 days -1 hour'); $arTags = $this->b2ts->getPopularTags(null, 10, null, 1); $this->assertInternalType('array', $arTags); $this->assertEquals(3, count($arTags)); - $this->assertContains(array('tag' => 'one', 'bCount' => '3'), $arTags); - $this->assertContains(array('tag' => 'two', 'bCount' => '2'), $arTags); + $this->assertContains(array('tag' => 'one', 'bCount' => '2'), $arTags); + $this->assertContains(array('tag' => 'two', 'bCount' => '1'), $arTags); $this->assertContains(array('tag' => 'thr', 'bCount' => '1'), $arTags); $arTags = $this->b2ts->getPopularTags(null, 10, null, 2); -- cgit v1.2.3-54-g00ecf From 84e603aa91a303a1419962ff3ff6086710a7b1a9 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Sat, 4 Jun 2011 00:29:04 -0400 Subject: Reverted changes of date() to gdate(), added tests to confirm existence of private RSS feed, and finalized changes to the user session usage with rss.php --- src/SemanticScuttle/Service/Bookmark.php | 2 +- src/SemanticScuttle/Service/Bookmark2Tag.php | 2 +- src/SemanticScuttle/Service/User.php | 2 -- tests/Api/PostsAddTest.php | 4 ++-- tests/TestBaseApi.php | 21 ++++++++++++------- tests/www/bookmarksTest.php | 27 ++++++++++++++++++++++++ www/ajaxGetNewPrivateKey.php | 31 +++++++++++----------------- www/index.php | 2 +- www/jsScuttle.php | 8 +++++++ www/rss.php | 14 ++----------- 10 files changed, 68 insertions(+), 45 deletions(-) diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php index f69b4d1..17ab7ba 100644 --- a/src/SemanticScuttle/Service/Bookmark.php +++ b/src/SemanticScuttle/Service/Bookmark.php @@ -486,7 +486,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService } else { $time = strtotime($date); } - $datetime = date('Y-m-d H:i:s', $time); + $datetime = gmdate('Y-m-d H:i:s', $time); if ($short === '') { $short = null; diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php index fc59a1c..04ee43d 100644 --- a/src/SemanticScuttle/Service/Bookmark2Tag.php +++ b/src/SemanticScuttle/Service/Bookmark2Tag.php @@ -584,7 +584,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService if (is_int($days)) { $query .= ' AND B.bDatetime > "' - . date('Y-m-d H:i:s', time() - (86400 * $days)) + . gmdate('Y-m-d H:i:s', time() - (86400 * $days)) . '"'; } diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index 18d5a29..a4870b7 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -571,8 +571,6 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService $this->db->sql_freeresult($dbresult); if ($row) { - $id = $_SESSION[$this->getSessionKey()] - = $row[$this->getFieldName('primary')]; return true; } else { return false; diff --git a/tests/Api/PostsAddTest.php b/tests/Api/PostsAddTest.php index 2613a87..e6d0531 100644 --- a/tests/Api/PostsAddTest.php +++ b/tests/Api/PostsAddTest.php @@ -111,7 +111,7 @@ TXT; $this->assertEquals($bmDescription, stripslashes($bm['bDescription'])); $this->assertEquals($bmTags, $bm['tags']); $this->assertEquals( - date('Y-m-d H:i:s', strtotime($bmDatetime)), + gmdate('Y-m-d H:i:s', strtotime($bmDatetime)), $bm['bDatetime'] ); } @@ -173,7 +173,7 @@ TXT; $this->assertEquals($bmDescription, stripslashes($bm['bDescription'])); $this->assertEquals($bmTags, $bm['tags']); $this->assertEquals( - date('Y-m-d H:i:s', strtotime($bmDatetime)), + gmdate('Y-m-d H:i:s', strtotime($bmDatetime)), $bm['bDatetime'] ); } diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index 20574f3..d8917aa 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -164,15 +164,16 @@ class TestBaseApi extends TestBase * * Useful for testing HTML pages or ajax URLs. * - * @param string $urlSuffix Suffix for the URL - * @param mixed $auth If user authentication is needed (true/false) - * or array with username and password + * @param string $urlSuffix Suffix for the URL + * @param mixed $auth If user authentication is needed (true/false) + * or array with username and password + * @param boolean $privateKey True if to add user with private key * * @return array(HTTP_Request2, integer) HTTP request object and user id * * @uses getRequest() */ - protected function getLoggedInRequest($urlSuffix = null, $auth = true) + protected function getLoggedInRequest($urlSuffix = null, $auth = true, $privateKey = false) { if (is_array($auth)) { list($username, $password) = $auth; @@ -180,7 +181,13 @@ class TestBaseApi extends TestBase $username = 'testuser'; $password = 'testpassword'; } - $uid = $this->addUser($username, $password); + //include privatekey if requested + if ($privateKey) { + $pKey = $this->us->getNewPrivateKey(); + } else { + $pKey = null; + } + $uid = $this->addUser($username, $password, $pKey); $req = new HTTP_Request2( $GLOBALS['unittestUrl'] . '/login.php?unittestMode=1', @@ -234,7 +241,7 @@ class TestBaseApi extends TestBase */ protected function setUnittestConfig($arConfig) { - $str = '<' . "?php\r\n"; + $str = '<' . "?php\n"; foreach ($arConfig as $name => $value) { $str .= '$' . $name . ' = ' . var_export($value, true) . ";\n"; @@ -253,4 +260,4 @@ class TestBaseApi extends TestBase ); } } -?> \ No newline at end of file +?> diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index df360cc..eaf78bf 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -76,5 +76,32 @@ class www_bookmarksTest extends TestBaseApi $this->assertEquals(1, (string)$elements[0]['value']); }//end testDefaultPrivacyBookmarksAdd + + /** + * Test that the private RSS link exists when a user + * has a private key and is enabled + */ + public function testVerifyPrivateRSSLinkExists() + { + list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true, true); + + $user = $this->us->getUser($uId); + $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' + . $user['username']; + $req->setUrl($reqUrl); + $req->setMethod(HTTP_Request2::METHOD_GET); + $response = $req->send(); + $response_body = $response->getBody(); + $this->assertNotEquals('', $response_body, 'Response is empty'); + + $x = simplexml_load_string($response_body); + $ns = $x->getDocNamespaces(); + $x->registerXPathNamespace('ns', reset($ns)); + + $elements = $x->xpath('//ns:link'); + $this->assertEquals(5, count($elements), 'Number of Links in Head not correct'); + $this->assertContains('privatekey=', (string)$elements[4]['href']); + }//end testVerifyPrivateRSSLinkExists + }//end class www_bookmarksTest ?> diff --git a/www/ajaxGetNewPrivateKey.php b/www/ajaxGetNewPrivateKey.php index 59545a2..eacebd8 100644 --- a/www/ajaxGetNewPrivateKey.php +++ b/www/ajaxGetNewPrivateKey.php @@ -1,23 +1,16 @@ + * @author Mark Pemberton + * @license AGPL http://www.gnu.org/licenses/agpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT"); header("Cache-Control: no-cache, must-revalidate"); diff --git a/www/index.php b/www/index.php index 931d64d..fab235f 100644 --- a/www/index.php +++ b/www/index.php @@ -51,7 +51,7 @@ if ($userservice->isLoggedOn()) { array_push( $tplVars['rsschannels'], array( - filter($sitename . sprintf(T_(': (private) ')) . $currentUsername), + filter($sitename . sprintf(T_(': Recent bookmarks (private)')) . $currentUsername), createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) ) ); diff --git a/www/jsScuttle.php b/www/jsScuttle.php index 76b49dc..3ca41ec 100644 --- a/www/jsScuttle.php +++ b/www/jsScuttle.php @@ -89,6 +89,14 @@ function useAddress(ele) { } } +/** + * Makes an ajax call to PHP script to generate an new Private Key + * + * @param input Calling object + * @param response Response object that returned value is placed + * + * @return boolean Returns false to halt execution after call + */ function getNewPrivateKey(input, response){ var pk = document.getElementById('pPrivateKey'); if (response != null) { diff --git a/www/rss.php b/www/rss.php index 8c81e0e..2927534 100644 --- a/www/rss.php +++ b/www/rss.php @@ -71,7 +71,6 @@ if (isset($_GET['privatekey'])) { $watchlist = null; $pagetitle = ''; -$isTempLogin = false; if ($user && $user != 'all') { if ($user == 'watchlist') { $user = $cat; @@ -86,9 +85,7 @@ if ($user && $user != 'all') { /* if user is not logged in and has valid privatekey */ if (!$userservice->isLoggedOn()) { if ($privatekey != null) { - if ($userservice->loginPrivateKey($privatekey)) { - $isTempLogin = true; - } else { + if (!$userservice->loginPrivateKey($privatekey)) { $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user); header('Content-type: text/html; charset=utf-8'); $templateservice->loadTemplate('error.404.tpl', $tplVars); @@ -109,9 +106,7 @@ if ($user && $user != 'all') { $pagetitle .= ": ". $user; } else { if ($privatekey != null) { - if ($userservice->loginPrivateKey($privatekey)) { - $isTempLogin = true; - } else { + if (!$userservice->loginPrivateKey($privatekey)) { $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user); header('Content-type: text/html; charset=utf-8'); $templateservice->loadTemplate('error.404.tpl', $tplVars); @@ -168,11 +163,6 @@ $tplVars['feedlastupdate'] = date('r', strtotime($latestdate)); $templateservice->loadTemplate('rss.tpl', $tplVars); -/* If temporary login, please log out */ -if ($isTempLogin) { - $userservice->logout(); -} - if ($usecache) { // Cache output if existing copy has expired $cacheservice->End($hash); -- cgit v1.2.3-54-g00ecf From 032ea9ec2582be96527defe65091c6209905ce5a Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Tue, 7 Jun 2011 21:42:11 -0400 Subject: Fixed missing change that was in master --- data/templates/default/bookmarks.tpl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 27118f5..8753b7f 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -221,9 +221,12 @@ if ($currenttag!= '') { $brss = ''; $size = count($rsschannels); for ($i = 0; $i < $size; $i++) { - $brss = '' - . '' . $rsschannels[$i][0] .'' + . '' . $rsschannels[$i][0] .'' . ''; } -- cgit v1.2.3-54-g00ecf From cd2756a4d0d18497648deacfb619e227335648ad Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Tue, 7 Jun 2011 22:13:50 -0400 Subject: Refined bookmarksTest.php and added indexTest.php --- tests/www/bookmarksTest.php | 33 +++++++++++++++++++++--- tests/www/indexTest.php | 63 +++++++++++++++++++++++++++++++++++++++++++++ tests/www/searchTest.php | 4 ++- 3 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 tests/www/indexTest.php diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index eaf78bf..1f6d1a5 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -98,10 +98,37 @@ class www_bookmarksTest extends TestBaseApi $ns = $x->getDocNamespaces(); $x->registerXPathNamespace('ns', reset($ns)); - $elements = $x->xpath('//ns:link'); - $this->assertEquals(5, count($elements), 'Number of Links in Head not correct'); - $this->assertContains('privatekey=', (string)$elements[4]['href']); + $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); + $this->assertEquals(2, count($elements), 'Number of Links in Head not correct'); + $this->assertContains('privatekey=', (string)$elements[1]['href']); }//end testVerifyPrivateRSSLinkExists + + /** + * Test that the private RSS link doesn't exists when a user + * does not have a private key or is not enabled + */ + public function testVerifyPrivateRSSLinkDoesNotExist() + { + list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true); + + $user = $this->us->getUser($uId); + $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' + . $user['username']; + $req->setUrl($reqUrl); + $req->setMethod(HTTP_Request2::METHOD_GET); + $response = $req->send(); + $response_body = $response->getBody(); + $this->assertNotEquals('', $response_body, 'Response is empty'); + + $x = simplexml_load_string($response_body); + $ns = $x->getDocNamespaces(); + $x->registerXPathNamespace('ns', reset($ns)); + + $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); + $this->assertEquals(1, count($elements), 'Number of Links in Head not correct'); + $this->assertNotContains('privatekey=', (string)$elements[0]['href']); + }//end testVerifyPrivateRSSLinkDoesNotExist + }//end class www_bookmarksTest ?> diff --git a/tests/www/indexTest.php b/tests/www/indexTest.php new file mode 100644 index 0000000..d95a328 --- /dev/null +++ b/tests/www/indexTest.php @@ -0,0 +1,63 @@ +getLoggedInRequest('?unittestMode=1', true, true); + + $user = $this->us->getUser($uId); + $reqUrl = $GLOBALS['unittestUrl'] . 'index.php/'; + $req->setUrl($reqUrl); + $req->setMethod(HTTP_Request2::METHOD_GET); + $response = $req->send(); + $response_body = $response->getBody(); + $this->assertNotEquals('', $response_body, 'Response is empty'); + + $x = simplexml_load_string($response_body); + $ns = $x->getDocNamespaces(); + $x->registerXPathNamespace('ns', reset($ns)); + + $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); + $this->assertEquals(2, count($elements), 'Number of Links in Head not correct'); + $this->assertContains('privatekey=', (string)$elements[1]['href']); + }//end testVerifyPrivateRSSLinkExists + + + /** + * Test that the private RSS link doesn't exists when a user + * does not have a private key or is not enabled + */ + public function testVerifyPrivateRSSLinkDoesNotExist() + { + list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true); + + $user = $this->us->getUser($uId); + $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' + . $user['username']; + $req->setUrl($reqUrl); + $req->setMethod(HTTP_Request2::METHOD_GET); + $response = $req->send(); + $response_body = $response->getBody(); + $this->assertNotEquals('', $response_body, 'Response is empty'); + + $x = simplexml_load_string($response_body); + $ns = $x->getDocNamespaces(); + $x->registerXPathNamespace('ns', reset($ns)); + + $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); + $this->assertEquals(1, count($elements), 'Number of Links in Head not correct'); + $this->assertNotContains('privatekey=', (string)$elements[0]['href']); + }//end testVerifyPrivateRSSLinkDoesNotExist + + +}//end class www_bookmarksTest +?> diff --git a/tests/www/searchTest.php b/tests/www/searchTest.php index 5dce69d..89af32d 100644 --- a/tests/www/searchTest.php +++ b/tests/www/searchTest.php @@ -1,4 +1,6 @@ \ No newline at end of file +?> -- cgit v1.2.3-54-g00ecf From 1dc33f4416c940ee3b46d9fabf3a2b1a2d369bb0 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Tue, 7 Jun 2011 22:42:21 -0400 Subject: Refined rss feed description --- www/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/index.php b/www/index.php index fab235f..2fa21f8 100644 --- a/www/index.php +++ b/www/index.php @@ -51,7 +51,7 @@ if ($userservice->isLoggedOn()) { array_push( $tplVars['rsschannels'], array( - filter($sitename . sprintf(T_(': Recent bookmarks (private)')) . $currentUsername), + filter(sprintf(T_('%s: Recent bookmarks (+private) %s'), $sitename, $currentUsername)), createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) ) ); -- cgit v1.2.3-54-g00ecf From 44a65eddaca98c2313ce128f9994e7484f9099b1 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 8 Jun 2011 07:00:17 +0200 Subject: fix tests for people that use a separate test database --- tests/www/bookmarksTest.php | 4 ++-- tests/www/indexTest.php | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index 1f6d1a5..a4de5f8 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -87,7 +87,7 @@ class www_bookmarksTest extends TestBaseApi $user = $this->us->getUser($uId); $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' - . $user['username']; + . $user['username'] . '?unittestMode=1'; $req->setUrl($reqUrl); $req->setMethod(HTTP_Request2::METHOD_GET); $response = $req->send(); @@ -114,7 +114,7 @@ class www_bookmarksTest extends TestBaseApi $user = $this->us->getUser($uId); $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' - . $user['username']; + . $user['username'] . '?unittestMode=1'; $req->setUrl($reqUrl); $req->setMethod(HTTP_Request2::METHOD_GET); $response = $req->send(); diff --git a/tests/www/indexTest.php b/tests/www/indexTest.php index d95a328..18cb75a 100644 --- a/tests/www/indexTest.php +++ b/tests/www/indexTest.php @@ -4,7 +4,7 @@ require_once 'HTTP/Request2.php'; class www_indexTest extends TestBaseApi { - protected $urlPart = 'api/posts/add'; + protected $urlPart = ''; /** * Test that the private rss feed exists when user is setup @@ -15,11 +15,9 @@ class www_indexTest extends TestBaseApi list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true, true); $user = $this->us->getUser($uId); - $reqUrl = $GLOBALS['unittestUrl'] . 'index.php/'; - $req->setUrl($reqUrl); - $req->setMethod(HTTP_Request2::METHOD_GET); $response = $req->send(); $response_body = $response->getBody(); + $this->assertNotEquals('', $response_body, 'Response is empty'); $x = simplexml_load_string($response_body); @@ -32,19 +30,16 @@ class www_indexTest extends TestBaseApi }//end testVerifyPrivateRSSLinkExists + /** * Test that the private RSS link doesn't exists when a user - * does not have a private key or is not enabled + * does not have a private key, or the private key is not enabled */ public function testVerifyPrivateRSSLinkDoesNotExist() { list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true); $user = $this->us->getUser($uId); - $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' - . $user['username']; - $req->setUrl($reqUrl); - $req->setMethod(HTTP_Request2::METHOD_GET); $response = $req->send(); $response_body = $response->getBody(); $this->assertNotEquals('', $response_body, 'Response is empty'); -- cgit v1.2.3-54-g00ecf From 39dfe3f1acf620eccb668d4f8d7451c1cef96ba5 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 8 Jun 2011 07:00:24 +0200 Subject: CS --- tests/TestBaseApi.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index d8917aa..7568147 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -164,17 +164,18 @@ class TestBaseApi extends TestBase * * Useful for testing HTML pages or ajax URLs. * - * @param string $urlSuffix Suffix for the URL - * @param mixed $auth If user authentication is needed (true/false) - * or array with username and password + * @param string $urlSuffix Suffix for the URL + * @param mixed $auth If user authentication is needed (true/false) + * or array with username and password * @param boolean $privateKey True if to add user with private key * * @return array(HTTP_Request2, integer) HTTP request object and user id * * @uses getRequest() */ - protected function getLoggedInRequest($urlSuffix = null, $auth = true, $privateKey = false) - { + protected function getLoggedInRequest( + $urlSuffix = null, $auth = true, $privateKey = false + ) { if (is_array($auth)) { list($username, $password) = $auth; } else { -- cgit v1.2.3-54-g00ecf From 5009535d3438ecc338dacc8120fa143fd28c5628 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 8 Jun 2011 07:21:33 +0200 Subject: docblocks for url and urlPart variables --- tests/TestBaseApi.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index 7568147..50a2413 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -24,7 +24,20 @@ require_once 'HTTP/Request2.php'; */ class TestBaseApi extends TestBase { + /** + * Created from the configured host and the $urlPart. + * Should be used as base for all generated URLs + * + * @var string + */ protected $url; + + /** + * Part of the URL behind the configured host. + * Needs to be overwritten in each derived test case class. + * + * @var string + */ protected $urlPart = null; /** -- cgit v1.2.3-54-g00ecf From 5deeecc408de104f2330a346dd528f6bb1e25b4e Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 8 Jun 2011 07:22:13 +0200 Subject: make bookmarks.php tests easier to read and use the TestBaseApi to get the urls --- tests/www/bookmarksTest.php | 62 ++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index a4de5f8..1e1f4eb 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -4,7 +4,7 @@ require_once 'HTTP/Request2.php'; class www_bookmarksTest extends TestBaseApi { - protected $urlPart = 'api/posts/add'; + protected $urlPart = 'bookmarks.php'; /** * Test that the default privacy setting is selected in the Privacy @@ -16,23 +16,11 @@ class www_bookmarksTest extends TestBaseApi $this->setUnittestConfig( array('defaults' => array('privacy' => 2)) ); - list($req, $uId) = $this->getLoggedInRequest(); - $cookies = $req->getCookieJar(); - $req->setMethod(HTTP_Request2::METHOD_POST); - $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_bookmarksget'); - $req->addPostParameter('description', 'Test bookmark 1 for default privacy.'); - $req->addPostParameter('status', '0'); - $req->send(); - $bms = $this->bs->getBookmarks(0, null, $uId); - $this->assertEquals(1, count($bms['bookmarks'])); + list($req, $uId) = $this->getLoggedInRequest(); $user = $this->us->getUser($uId); - $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' . $user['username'] . '?action=get' . '&unittestMode=1'; - - list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); $req->setMethod(HTTP_Request2::METHOD_POST); - $req->setUrl($reqUrl); - $req->setCookieJar($cookies); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?action=get')); $req->addPostParameter('submitted', '1'); $response = $req->send(); $response_body = $response->getBody(); @@ -41,12 +29,15 @@ class www_bookmarksTest extends TestBaseApi $ns = $x->getDocNamespaces(); $x->registerXPathNamespace('ns', reset($ns)); - $elements = $x->xpath('//ns:select[@name="status"]/ns:option[@selected="selected"]'); + $elements = $x->xpath( + '//ns:select[@name="status"]/ns:option[@selected="selected"]' + ); $this->assertEquals(1, count($elements), 'No selected status option found'); $this->assertEquals(2, (string)$elements[0]['value']); }//end testDefaultPrivacyBookmarksAddMissingTitleMissingPrivacy + /** * Test that the default privacy setting is selected in the Privacy * drop-down list when a new bookmark is being created. @@ -56,13 +47,10 @@ class www_bookmarksTest extends TestBaseApi $this->setUnittestConfig( array('defaults' => array('privacy' => 1)) ); - list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1'); + list($req, $uId) = $this->getLoggedInRequest(); $user = $this->us->getUser($uId); - $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' - . $user['username'] . '?action=add' . '&unittestMode=1'; - $req->setUrl($reqUrl); - $req->setMethod(HTTP_Request2::METHOD_GET); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?action=add')); $response = $req->send(); $response_body = $response->getBody(); $this->assertNotEquals('', $response_body, 'Response is empty'); @@ -71,12 +59,15 @@ class www_bookmarksTest extends TestBaseApi $ns = $x->getDocNamespaces(); $x->registerXPathNamespace('ns', reset($ns)); - $elements = $x->xpath('//ns:select[@name="status"]/ns:option[@selected="selected"]'); + $elements = $x->xpath( + '//ns:select[@name="status"]/ns:option[@selected="selected"]' + ); $this->assertEquals(1, count($elements), 'No selected status option found'); $this->assertEquals(1, (string)$elements[0]['value']); }//end testDefaultPrivacyBookmarksAdd + /** * Test that the private RSS link exists when a user * has a private key and is enabled @@ -86,10 +77,7 @@ class www_bookmarksTest extends TestBaseApi list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true, true); $user = $this->us->getUser($uId); - $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' - . $user['username'] . '?unittestMode=1'; - $req->setUrl($reqUrl); - $req->setMethod(HTTP_Request2::METHOD_GET); + $req->setUrl($this->getTestUrl('/' . $user['username'])); $response = $req->send(); $response_body = $response->getBody(); $this->assertNotEquals('', $response_body, 'Response is empty'); @@ -98,12 +86,17 @@ class www_bookmarksTest extends TestBaseApi $ns = $x->getDocNamespaces(); $x->registerXPathNamespace('ns', reset($ns)); - $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); - $this->assertEquals(2, count($elements), 'Number of Links in Head not correct'); + $elements = $x->xpath( + '//ns:link[@rel="alternate" and @type="application/rss+xml"]' + ); + $this->assertEquals( + 2, count($elements), 'Number of Links in Head not correct' + ); $this->assertContains('privatekey=', (string)$elements[1]['href']); }//end testVerifyPrivateRSSLinkExists + /** * Test that the private RSS link doesn't exists when a user * does not have a private key or is not enabled @@ -113,10 +106,7 @@ class www_bookmarksTest extends TestBaseApi list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true); $user = $this->us->getUser($uId); - $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' - . $user['username'] . '?unittestMode=1'; - $req->setUrl($reqUrl); - $req->setMethod(HTTP_Request2::METHOD_GET); + $req->setUrl($this->getTestUrl('/' . $user['username'])); $response = $req->send(); $response_body = $response->getBody(); $this->assertNotEquals('', $response_body, 'Response is empty'); @@ -125,8 +115,12 @@ class www_bookmarksTest extends TestBaseApi $ns = $x->getDocNamespaces(); $x->registerXPathNamespace('ns', reset($ns)); - $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); - $this->assertEquals(1, count($elements), 'Number of Links in Head not correct'); + $elements = $x->xpath( + '//ns:link[@rel="alternate" and @type="application/rss+xml"]' + ); + $this->assertEquals( + 1, count($elements), 'Number of Links in Head not correct' + ); $this->assertNotContains('privatekey=', (string)$elements[0]['href']); }//end testVerifyPrivateRSSLinkDoesNotExist -- cgit v1.2.3-54-g00ecf From dd34ad34075e071795bcb18f09cd9699141bbc25 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 9 Jun 2011 09:13:42 +0200 Subject: fix E_NOTICE --- www/rss.php | 1 + 1 file changed, 1 insertion(+) diff --git a/www/rss.php b/www/rss.php index 2927534..b8f6948 100644 --- a/www/rss.php +++ b/www/rss.php @@ -69,6 +69,7 @@ if (isset($_GET['privatekey'])) { $privatekey = $_GET['privatekey']; } +$userid = null; $watchlist = null; $pagetitle = ''; if ($user && $user != 'all') { -- cgit v1.2.3-54-g00ecf From 74bab13f05ee7552c13e0dc8f4523cd7071a0085 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Tue, 14 Jun 2011 22:39:47 -0400 Subject: Fixed auth issue with private RSS feed --- src/SemanticScuttle/Service/User.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index a4870b7..e6527ea 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -571,6 +571,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService $this->db->sql_freeresult($dbresult); if ($row) { + $this->setCurrentUserId($row[$this->getFieldName('primary')], true); return true; } else { return false; -- cgit v1.2.3-54-g00ecf From 045d139d64ada2c510ed05e177ba6f484ad68496 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Wed, 15 Jun 2011 00:58:29 -0400 Subject: Added RSS Feed tests --- tests/TestBaseApi.php | 7 ++-- tests/www/rssTest.php | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 tests/www/rssTest.php diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index 50a2413..f860d10 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -187,7 +187,8 @@ class TestBaseApi extends TestBase * @uses getRequest() */ protected function getLoggedInRequest( - $urlSuffix = null, $auth = true, $privateKey = false + $urlSuffix = null, $auth = true, $privateKey = false, + $setCookie = true ) { if (is_array($auth)) { list($username, $password) = $auth; @@ -217,7 +218,9 @@ class TestBaseApi extends TestBase $this->assertEquals(302, $res->getStatus(), 'Login failure'); $req = $this->getRequest($urlSuffix); - $req->setCookieJar($cookies); + if ($setCookie) { + $req->setCookieJar($cookies); + } return array($req, $uid); } diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php new file mode 100644 index 0000000..1822fc9 --- /dev/null +++ b/tests/www/rssTest.php @@ -0,0 +1,94 @@ +setUnittestConfig( + array('defaults' => array('privacy' => 2)) + ); + + /* create user without RSS private Key */ + list($req, $uId) = $this->getLoggedInRequest(null, true, false, false); + + /* create private bookmark */ + $this->bs->addBookmark( + 'http://test', 'test', 'desc', 'note', + 2,//private + array(), null, null, false, false, $uId + ); + /* create public bookmark */ + $this->bs->addBookmark( + 'http://example.org', 'title', 'desc', 'priv', + 0,//public + array(), null, null, false, false, $uId + ); + + /* get user details */ + $user = $this->us->getUser($uId); + + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc')); + $response = $req->send(); + $response_body = $response->getBody(); + + $rss = simplexml_load_string($response_body); + $items = $rss->channel->item; + + $this->assertEquals(1, count($items), 'Incorrect Number of RSS Items'); + $this->assertEquals('title', (string)$items[0]->title); + }//end testNoRSSPrivateKeyEnabled + + + /** + * Test a user who has RSS private key setup + * with private bookmark. + */ + public function testRSSPrivateKeyEnabled() + { + $this->setUnittestConfig( + array('defaults' => array('privacy' => 2)) + ); + + /* create user with RSS private Key */ + list($req, $uId) = $this->getLoggedInRequest(null, true, false, true); + + /* create private bookmark */ + $this->bs->addBookmark( + 'http://test', 'test', 'desc', 'note', + 2,//private + array(), null, null, false, false, $uId + ); + /* create public bookmark */ + $this->bs->addBookmark( + 'http://example.org', 'title', 'desc', 'priv', + 0,//public + array(), null, null, false, false, $uId + ); + + /* get user details */ + $user = $this->us->getUser($uId); + + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privatekey'])); + $response = $req->send(); + $response_body = $response->getBody(); + + $rss = simplexml_load_string($response_body); + $items = $rss->channel->item; + + $this->assertEquals(2, count($items), 'Incorrect Number of RSS Items'); + }//end testRSSPrivateKeyEnabled + + + +}//end class www_rssTest +?> -- cgit v1.2.3-54-g00ecf From f9dbdc6645ed3631d9ba77a29212934073bd76b4 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Wed, 15 Jun 2011 08:47:50 -0400 Subject: Fixed issue with storing RSS login in session --- src/SemanticScuttle/Service/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index e6527ea..b5b053f 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -571,7 +571,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService $this->db->sql_freeresult($dbresult); if ($row) { - $this->setCurrentUserId($row[$this->getFieldName('primary')], true); + $this->setCurrentUserId($row[$this->getFieldName('primary')], false); return true; } else { return false; -- cgit v1.2.3-54-g00ecf From 9eab02af5f6212b417a6aef095d55e6c5d8fc616 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:09:19 +0200 Subject: fix typo --- tests/www/rssTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 1822fc9..9d4e41b 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -78,7 +78,7 @@ class www_rssTest extends TestBaseApi $user = $this->us->getUser($uId); $req->setMethod(HTTP_Request2::METHOD_POST); - $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privatekey'])); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privateKey'])); $response = $req->send(); $response_body = $response->getBody(); -- cgit v1.2.3-54-g00ecf From d2aecd8a76a8c1f0d326cae13f158b74b6e60709 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:16:33 +0200 Subject: move private key generation to adduser --- tests/TestBase.php | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tests/TestBase.php b/tests/TestBase.php index 1331ec6..5ea656c 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -76,17 +76,18 @@ class TestBase extends PHPUnit_Framework_TestCase /** * Creates a new user in the database. * - * @param string $username Username - * @param string $password Password - * @param string $pkey Private Key + * @param string $username Username + * @param string $password Password + * @param mixed $privateKey String private key or boolean true to generate one * * @return integer ID of user * * @uses addUserData() */ - protected function addUser($username = null, $password = null, $pkey = null) - { - return reset($this->addUserData($username, $password, $pkey)); + protected function addUser( + $username = null, $password = null, $privateKey = null + ) { + return reset($this->addUserData($username, $password, $privateKey)); } @@ -94,14 +95,15 @@ class TestBase extends PHPUnit_Framework_TestCase /** * Creates a new user in the database and returns id, username and password. * - * @param string $username Username - * @param string $password Password - * @param string $pkey Private Key + * @param string $username Username + * @param string $password Password + * @param mixed $privateKey String private key or boolean true to generate one * - * @return array ID of user, Name of user, password of user + * @return array ID of user, Name of user, password of user, privatekey */ - protected function addUserData($username = null, $password = null, $pkey = null) - { + protected function addUserData( + $username = null, $password = null, $privateKey = null + ) { $us = SemanticScuttle_Service_Factory::get('User'); $rand = rand(); @@ -111,14 +113,17 @@ class TestBase extends PHPUnit_Framework_TestCase if ($password === null) { $password = $rand; } + if ($privateKey === true) { + $privateKey = $this->us->getNewPrivateKey(); + } $uid = $us->addUser( $username, $password, 'unittest-' . $rand . '@example.org', - $pkey + $privateKey ); - return array($uid, $username, $password); + return array($uid, $username, $password, $privateKey); } -- cgit v1.2.3-54-g00ecf From 6ec3b102aa896df8ddcf6323e0635dc42ac25f98 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:39:38 +0200 Subject: make the private tests really test something --- src/SemanticScuttle/Model/Bookmark.php | 17 ++++++++ tests/TestBase.php | 8 ++-- tests/TestBaseApi.php | 15 ++----- tests/www/rssTest.php | 73 +++++++++------------------------- 4 files changed, 42 insertions(+), 71 deletions(-) diff --git a/src/SemanticScuttle/Model/Bookmark.php b/src/SemanticScuttle/Model/Bookmark.php index 8bda0b3..1330642 100644 --- a/src/SemanticScuttle/Model/Bookmark.php +++ b/src/SemanticScuttle/Model/Bookmark.php @@ -23,6 +23,23 @@ */ class SemanticScuttle_Model_Bookmark { + /** + * Status "public" / visible for all + */ + const SPUBLIC = 0; + + /** + * Status "shared" / visible for people on your watchlist + */ + const SWATCHLIST = 1; + + /** + * Status "private" / visible for yourself only + */ + const SPRIVATE = 2; + + + /** * Checks if the given URL is valid and may be used with this * SemanticScuttle installation. diff --git a/tests/TestBase.php b/tests/TestBase.php index 5ea656c..2180d2d 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -76,8 +76,8 @@ class TestBase extends PHPUnit_Framework_TestCase /** * Creates a new user in the database. * - * @param string $username Username - * @param string $password Password + * @param string $username Username, may be null + * @param string $password Password, may be null * @param mixed $privateKey String private key or boolean true to generate one * * @return integer ID of user @@ -95,8 +95,8 @@ class TestBase extends PHPUnit_Framework_TestCase /** * Creates a new user in the database and returns id, username and password. * - * @param string $username Username - * @param string $password Password + * @param string $username Username, may be null + * @param string $password Password, may be null * @param mixed $privateKey String private key or boolean true to generate one * * @return array ID of user, Name of user, password of user, privatekey diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index f860d10..1052ae7 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -187,8 +187,7 @@ class TestBaseApi extends TestBase * @uses getRequest() */ protected function getLoggedInRequest( - $urlSuffix = null, $auth = true, $privateKey = false, - $setCookie = true + $urlSuffix = null, $auth = true, $privateKey = null ) { if (is_array($auth)) { list($username, $password) = $auth; @@ -196,13 +195,7 @@ class TestBaseApi extends TestBase $username = 'testuser'; $password = 'testpassword'; } - //include privatekey if requested - if ($privateKey) { - $pKey = $this->us->getNewPrivateKey(); - } else { - $pKey = null; - } - $uid = $this->addUser($username, $password, $pKey); + $uid = $this->addUser($username, $password, $privateKey); $req = new HTTP_Request2( $GLOBALS['unittestUrl'] . '/login.php?unittestMode=1', @@ -218,9 +211,7 @@ class TestBaseApi extends TestBase $this->assertEquals(302, $res->getStatus(), 'Login failure'); $req = $this->getRequest($urlSuffix); - if ($setCookie) { - $req->setCookieJar($cookies); - } + $req->setCookieJar($cookies); return array($req, $uid); } diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 9d4e41b..fc49264 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -7,44 +7,23 @@ class www_rssTest extends TestBaseApi protected $urlPart = 'rss.php'; /** - * Test a user who does not have RSS private key enabled - * and with a private bookmark. + * A private bookmark should not show up in an rss feed if the + * user is not logged in nor passes the private key */ - public function testNoRSSPrivateKeyEnabled() + public function testPrivateNotLoggedIn() { - $this->setUnittestConfig( - array('defaults' => array('privacy' => 2)) + list($uId, $username) = $this->addUserData(); + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE ); - /* create user without RSS private Key */ - list($req, $uId) = $this->getLoggedInRequest(null, true, false, false); - - /* create private bookmark */ - $this->bs->addBookmark( - 'http://test', 'test', 'desc', 'note', - 2,//private - array(), null, null, false, false, $uId - ); - /* create public bookmark */ - $this->bs->addBookmark( - 'http://example.org', 'title', 'desc', 'priv', - 0,//public - array(), null, null, false, false, $uId - ); - - /* get user details */ - $user = $this->us->getUser($uId); - - $req->setMethod(HTTP_Request2::METHOD_POST); - $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc')); - $response = $req->send(); - $response_body = $response->getBody(); + $req = $this->getRequest('/' . $username); + $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); $items = $rss->channel->item; - $this->assertEquals(1, count($items), 'Incorrect Number of RSS Items'); - $this->assertEquals('title', (string)$items[0]->title); + $this->assertEquals(0, count($items), 'I see a private bookmark'); }//end testNoRSSPrivateKeyEnabled @@ -54,38 +33,22 @@ class www_rssTest extends TestBaseApi */ public function testRSSPrivateKeyEnabled() { - $this->setUnittestConfig( - array('defaults' => array('privacy' => 2)) + list($uId, $username, $password, $privateKey) = $this->addUserData( + null, null, true ); - - /* create user with RSS private Key */ - list($req, $uId) = $this->getLoggedInRequest(null, true, false, true); - - /* create private bookmark */ - $this->bs->addBookmark( - 'http://test', 'test', 'desc', 'note', - 2,//private - array(), null, null, false, false, $uId + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE, + null, 'private bookmark' ); - /* create public bookmark */ - $this->bs->addBookmark( - 'http://example.org', 'title', 'desc', 'priv', - 0,//public - array(), null, null, false, false, $uId - ); - - /* get user details */ - $user = $this->us->getUser($uId); - $req->setMethod(HTTP_Request2::METHOD_POST); - $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privateKey'])); - $response = $req->send(); - $response_body = $response->getBody(); + $req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey); + $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); $items = $rss->channel->item; - $this->assertEquals(2, count($items), 'Incorrect Number of RSS Items'); + $this->assertEquals(1, count($items), 'I miss the private bookmark'); + $this->assertEquals('private bookmark', (string)$items[0]->title); }//end testRSSPrivateKeyEnabled -- cgit v1.2.3-54-g00ecf From f2ac531f2646c34c107b92cd9ff1e2c1a12c9b39 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:52:02 +0200 Subject: test that using the private key does not leave unwanted login cookies --- tests/www/rssTest.php | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index fc49264..d6891d6 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -24,14 +24,15 @@ class www_rssTest extends TestBaseApi $items = $rss->channel->item; $this->assertEquals(0, count($items), 'I see a private bookmark'); - }//end testNoRSSPrivateKeyEnabled + } + /** * Test a user who has RSS private key setup * with private bookmark. */ - public function testRSSPrivateKeyEnabled() + public function testPrivateWithPrivateKey() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true @@ -49,9 +50,43 @@ class www_rssTest extends TestBaseApi $this->assertEquals(1, count($items), 'I miss the private bookmark'); $this->assertEquals('private bookmark', (string)$items[0]->title); - }//end testRSSPrivateKeyEnabled + } + + + + /** + * Verify that fetching the feed with a private key + * does not keep you logged in + */ + public function testPrivatekeyDoesNotKeepLoggedYouIn() + { + list($uId, $username, $password, $privateKey) = $this->addUserData( + null, null, true + ); + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE, + null, 'private bookmark' + ); + $req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey); + $cookies = $req->setCookieJar()->getCookieJar(); + $response_body = $req->send()->getBody(); + + $rss = simplexml_load_string($response_body); + $items = $rss->channel->item; + + $this->assertEquals(1, count($items), 'I miss the private bookmark'); + $this->assertEquals('private bookmark', (string)$items[0]->title); + + //request the feed again, with the same cookies + $req = $this->getRequest('/' . $username); + $req->setCookieJar($cookies); + $response_body = $req->send()->getBody(); + $rss = simplexml_load_string($response_body); + $items = $rss->channel->item; + $this->assertEquals(0, count($items), 'I still see the private bookmark'); + } }//end class www_rssTest ?> -- cgit v1.2.3-54-g00ecf From 588d63a2c740335bb4ff7fbe7454fbe3876ea9c1 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 19:59:06 +0200 Subject: better method names --- tests/www/rssTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index d6891d6..63c2b3d 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -10,7 +10,7 @@ class www_rssTest extends TestBaseApi * A private bookmark should not show up in an rss feed if the * user is not logged in nor passes the private key */ - public function testPrivateNotLoggedIn() + public function testPrivateBookmarkNotLoggedIn() { list($uId, $username) = $this->addUserData(); $this->addBookmark( @@ -32,7 +32,7 @@ class www_rssTest extends TestBaseApi * Test a user who has RSS private key setup * with private bookmark. */ - public function testPrivateWithPrivateKey() + public function testPrivateBookmarkWithPrivateKey() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true @@ -58,7 +58,7 @@ class www_rssTest extends TestBaseApi * Verify that fetching the feed with a private key * does not keep you logged in */ - public function testPrivatekeyDoesNotKeepLoggedYouIn() + public function testPrivateKeyDoesNotKeepLoggedYouIn() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true -- cgit v1.2.3-54-g00ecf From 57a5f6864d0241ab513b53a02c7e4ab9ebdeda0d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 20:04:03 +0200 Subject: add own assertion to make it easier to switch to atom --- tests/www/rssTest.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 63c2b3d..477e98c 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -6,6 +6,23 @@ class www_rssTest extends TestBaseApi { protected $urlPart = 'rss.php'; + + /** + * Verifies that the given number of feed items exist in the feed + * XML tree. + * + * @var SimpleXMLElement $simpleXml RSS feed root element + * @var integer $nCount Number of expected feed items + * @var string $msg Error message + */ + protected function assertItemCount( + SimpleXMLElement $simpleXml, $nCount, $msg = null + ) { + $this->assertEquals($nCount, count($simpleXml->channel->item), $msg); + } + + + /** * A private bookmark should not show up in an rss feed if the * user is not logged in nor passes the private key @@ -21,9 +38,7 @@ class www_rssTest extends TestBaseApi $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); - $items = $rss->channel->item; - - $this->assertEquals(0, count($items), 'I see a private bookmark'); + $this->assertItemCount($rss, 0, 'I see a private bookmark'); } @@ -46,10 +61,10 @@ class www_rssTest extends TestBaseApi $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); - $items = $rss->channel->item; - - $this->assertEquals(1, count($items), 'I miss the private bookmark'); - $this->assertEquals('private bookmark', (string)$items[0]->title); + $this->assertItemCount($rss, 1, 'I miss the private bookmark'); + $this->assertEquals( + 'private bookmark', (string)$rss->channel->item[0]->title + ); } @@ -83,9 +98,7 @@ class www_rssTest extends TestBaseApi $req->setCookieJar($cookies); $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); - $items = $rss->channel->item; - - $this->assertEquals(0, count($items), 'I still see the private bookmark'); + $this->assertItemCount($rss, 0, 'I still see the private bookmark'); } }//end class www_rssTest -- cgit v1.2.3-54-g00ecf From 673fdc87582c2087beed8d33505213cbd83755cb Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 21:55:07 +0200 Subject: rename methods to keep them clear --- tests/www/rssTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 477e98c..4fab479 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -27,7 +27,7 @@ class www_rssTest extends TestBaseApi * A private bookmark should not show up in an rss feed if the * user is not logged in nor passes the private key */ - public function testPrivateBookmarkNotLoggedIn() + public function testUserPrivateBookmarkNotLoggedIn() { list($uId, $username) = $this->addUserData(); $this->addBookmark( @@ -47,7 +47,7 @@ class www_rssTest extends TestBaseApi * Test a user who has RSS private key setup * with private bookmark. */ - public function testPrivateBookmarkWithPrivateKey() + public function testUserPrivateBookmarkWithPrivateKey() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true @@ -73,7 +73,7 @@ class www_rssTest extends TestBaseApi * Verify that fetching the feed with a private key * does not keep you logged in */ - public function testPrivateKeyDoesNotKeepLoggedYouIn() + public function testUserPrivateKeyDoesNotKeepLoggedYouIn() { list($uId, $username, $password, $privateKey) = $this->addUserData( null, null, true -- cgit v1.2.3-54-g00ecf From 763d394436dc632bf18bff8876af22be9b44e9f4 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 22:27:17 +0200 Subject: test global feed with private bookmarks --- tests/www/rssTest.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 4fab479..75e4363 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -23,8 +23,29 @@ class www_rssTest extends TestBaseApi + /** - * A private bookmark should not show up in an rss feed if the + * A private bookmark should not show up in the global rss feed if the + * user is not logged in nor passes the private key + */ + public function testAllPrivateBookmarkNotLoggedIn() + { + list($uId, $username) = $this->addUserData(); + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE + ); + + $req = $this->getRequest(); + $response_body = $req->send()->getBody(); + + $rss = simplexml_load_string($response_body); + $this->assertItemCount($rss, 0, 'I see a private bookmark'); + } + + + + /** + * A private bookmark should not show up in the user's rss feed if the * user is not logged in nor passes the private key */ public function testUserPrivateBookmarkNotLoggedIn() @@ -43,9 +64,34 @@ class www_rssTest extends TestBaseApi + + /** + * Test the global feed by passing the private key + */ + public function testAllPrivateBookmarkWithPrivateKey() + { + list($uId, $username, $password, $privateKey) = $this->addUserData( + null, null, true + ); + $this->addBookmark( + $uId, null, SemanticScuttle_Model_Bookmark::SPRIVATE, + null, 'private bookmark' + ); + + $req = $this->getRequest('?privatekey=' . $privateKey); + $response_body = $req->send()->getBody(); + + $rss = simplexml_load_string($response_body); + $this->assertItemCount($rss, 1, 'I miss the private bookmark'); + $this->assertEquals( + 'private bookmark', (string)$rss->channel->item[0]->title + ); + } + + + /** - * Test a user who has RSS private key setup - * with private bookmark. + * Test the user feed by passing the private key */ public function testUserPrivateBookmarkWithPrivateKey() { -- cgit v1.2.3-54-g00ecf From 3d11286cbcc3cb35efe11f6e4a4ef5ac81620bda Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 22:31:24 +0200 Subject: privatekey -> privateKey everywhere --- src/SemanticScuttle/Service/User.php | 20 ++++++++++---------- tests/TestBase.php | 2 +- tests/UserTest.php | 24 ++++++++++++------------ tests/www/bookmarksTest.php | 4 ++-- tests/www/indexTest.php | 4 ++-- tests/www/rssTest.php | 6 +++--- www/bookmarks.php | 2 +- www/index.php | 2 +- www/rss.php | 16 ++++++++-------- www/tags.php | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index b5b053f..7550ed2 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -51,7 +51,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService 'primary' => 'uId', 'username' => 'username', 'password' => 'password', - 'privatekey' => 'privatekey' + 'privateKey' => 'privateKey' ); protected $profileurl; @@ -219,13 +219,13 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService /** * Returns user row from database. * - * @param string $privatekey Private Key + * @param string $privateKey Private Key * * @return array User array from database, false if no user was found */ - public function getUserByPrivateKey($privatekey) + public function getUserByPrivateKey($privateKey) { - return $this->_getuser($this->getFieldName('privatekey'), $privatekey); + return $this->_getuser($this->getFieldName('privateKey'), $privateKey); } function getObjectUserByUsername($username) { @@ -539,24 +539,24 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService } /** - * Try to authenticate via the privatekey + * Try to authenticate via the privateKey * - * @param string $privatekey Private Key + * @param string $privateKey Private Key * * @return boolean true if the user could be authenticated, * false if not. */ - public function loginPrivateKey($privatekey) + public function loginPrivateKey($privateKey) { /* Check if private key valid and enabled */ - if (!$this->isPrivateKeyValid($privatekey)) { + if (!$this->isPrivateKeyValid($privateKey)) { return false; } $query = 'SELECT '. $this->getFieldName('primary') .' FROM ' . $this->getTableName() .' WHERE ' - . $this->getFieldName('privatekey') .' = "' - . $this->db->sql_escape($privatekey) .'"'; + . $this->getFieldName('privateKey') .' = "' + . $this->db->sql_escape($privateKey) .'"'; if (!($dbresult = $this->db->sql_query($query))) { message_die( diff --git a/tests/TestBase.php b/tests/TestBase.php index 2180d2d..2914749 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -99,7 +99,7 @@ class TestBase extends PHPUnit_Framework_TestCase * @param string $password Password, may be null * @param mixed $privateKey String private key or boolean true to generate one * - * @return array ID of user, Name of user, password of user, privatekey + * @return array ID of user, Name of user, password of user, privateKey */ protected function addUserData( $username = null, $password = null, $privateKey = null diff --git a/tests/UserTest.php b/tests/UserTest.php index 230167d..6cd6786 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -40,7 +40,7 @@ class UserTest extends TestBase public function testAddUserPrivateKey() { $name = substr(md5(uniqid()), 0, 6); - $pkey = 'my-privatekey'; + $pkey = 'my-privateKey'; $id = $this->us->addUser( $name, uniqid(), 'foo@example.org', $pkey ); @@ -413,17 +413,17 @@ class UserTest extends TestBase $randKey2 = '-'.$this->us->getNewPrivateKey(); $this->assertFalse( $this->us->isPrivateKeyValid($randKey2), - 'disabled privatekey should return false' + 'disabled privateKey should return false' ); } public function testLoginPrivateKeyInvalid() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); @@ -436,10 +436,10 @@ class UserTest extends TestBase public function testLoginPrivateKeyValidEnabledKey() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); @@ -453,10 +453,10 @@ class UserTest extends TestBase public function testLoginPrivateKeyInvalidEnabledKey() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); @@ -470,10 +470,10 @@ class UserTest extends TestBase public function testLoginPrivateKeyValidDisabledKey() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); @@ -491,10 +491,10 @@ class UserTest extends TestBase public function testLoginPrivateKeyInvalidDisabled() { - /* normal user with enabled privatekey */ + /* normal user with enabled privateKey */ $randKey = $this->us->getNewPrivateKey(); $uid1 = $this->addUser('testusername', 'passw0rd', $randKey); - /* user that has disabled privatekey */ + /* user that has disabled privateKey */ $randKey2 = '-'.$this->us->getNewPrivateKey(); $uid2 = $this->addUser('seconduser', 'passw0RD', $randKey2); diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index 1e1f4eb..ae82118 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -92,7 +92,7 @@ class www_bookmarksTest extends TestBaseApi $this->assertEquals( 2, count($elements), 'Number of Links in Head not correct' ); - $this->assertContains('privatekey=', (string)$elements[1]['href']); + $this->assertContains('privateKey=', (string)$elements[1]['href']); }//end testVerifyPrivateRSSLinkExists @@ -121,7 +121,7 @@ class www_bookmarksTest extends TestBaseApi $this->assertEquals( 1, count($elements), 'Number of Links in Head not correct' ); - $this->assertNotContains('privatekey=', (string)$elements[0]['href']); + $this->assertNotContains('privateKey=', (string)$elements[0]['href']); }//end testVerifyPrivateRSSLinkDoesNotExist }//end class www_bookmarksTest diff --git a/tests/www/indexTest.php b/tests/www/indexTest.php index 18cb75a..503fd1f 100644 --- a/tests/www/indexTest.php +++ b/tests/www/indexTest.php @@ -26,7 +26,7 @@ class www_indexTest extends TestBaseApi $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); $this->assertEquals(2, count($elements), 'Number of Links in Head not correct'); - $this->assertContains('privatekey=', (string)$elements[1]['href']); + $this->assertContains('privateKey=', (string)$elements[1]['href']); }//end testVerifyPrivateRSSLinkExists @@ -50,7 +50,7 @@ class www_indexTest extends TestBaseApi $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]'); $this->assertEquals(1, count($elements), 'Number of Links in Head not correct'); - $this->assertNotContains('privatekey=', (string)$elements[0]['href']); + $this->assertNotContains('privateKey=', (string)$elements[0]['href']); }//end testVerifyPrivateRSSLinkDoesNotExist diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php index 75e4363..71d0198 100644 --- a/tests/www/rssTest.php +++ b/tests/www/rssTest.php @@ -78,7 +78,7 @@ class www_rssTest extends TestBaseApi null, 'private bookmark' ); - $req = $this->getRequest('?privatekey=' . $privateKey); + $req = $this->getRequest('?privateKey=' . $privateKey); $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); @@ -103,7 +103,7 @@ class www_rssTest extends TestBaseApi null, 'private bookmark' ); - $req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey); + $req = $this->getRequest('/' . $username . '?privateKey=' . $privateKey); $response_body = $req->send()->getBody(); $rss = simplexml_load_string($response_body); @@ -129,7 +129,7 @@ class www_rssTest extends TestBaseApi null, 'private bookmark' ); - $req = $this->getRequest('/' . $username . '?privatekey=' . $privateKey); + $req = $this->getRequest('/' . $username . '?privateKey=' . $privateKey); $cookies = $req->setCookieJar()->getCookieJar(); $response_body = $req->send()->getBody(); diff --git a/www/bookmarks.php b/www/bookmarks.php index 44119db..7056fa6 100644 --- a/www/bookmarks.php +++ b/www/bookmarks.php @@ -276,7 +276,7 @@ if ($templatename == 'editbookmark.tpl') { $tplVars['rsschannels'], array( filter($sitename . $rssTitle. sprintf(T_(': (private) ')) . $currentUsername), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) + createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) ) ); } diff --git a/www/index.php b/www/index.php index 2fa21f8..f270f73 100644 --- a/www/index.php +++ b/www/index.php @@ -52,7 +52,7 @@ if ($userservice->isLoggedOn()) { $tplVars['rsschannels'], array( filter(sprintf(T_('%s: Recent bookmarks (+private) %s'), $sitename, $currentUsername)), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) + createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) ) ); } diff --git a/www/rss.php b/www/rss.php index b8f6948..d888726 100644 --- a/www/rss.php +++ b/www/rss.php @@ -64,9 +64,9 @@ if (!isset($rssEntries) || $rssEntries <= 0) { $rssEntries = $maxRssEntries; } -$privatekey = null; -if (isset($_GET['privatekey'])) { - $privatekey = $_GET['privatekey']; +$privateKey = null; +if (isset($_GET['privateKey'])) { + $privateKey = $_GET['privateKey']; } $userid = null; @@ -83,10 +83,10 @@ if ($user && $user != 'all') { } else { if ($userinfo = $userservice->getUserByUsername($user)) { $userid =& $userinfo[$userservice->getFieldName('primary')]; - /* if user is not logged in and has valid privatekey */ + /* if user is not logged in and has valid privateKey */ if (!$userservice->isLoggedOn()) { - if ($privatekey != null) { - if (!$userservice->loginPrivateKey($privatekey)) { + if ($privateKey != null) { + if (!$userservice->loginPrivateKey($privateKey)) { $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user); header('Content-type: text/html; charset=utf-8'); $templateservice->loadTemplate('error.404.tpl', $tplVars); @@ -106,8 +106,8 @@ if ($user && $user != 'all') { } $pagetitle .= ": ". $user; } else { - if ($privatekey != null) { - if (!$userservice->loginPrivateKey($privatekey)) { + if ($privateKey != null) { + if (!$userservice->loginPrivateKey($privateKey)) { $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user); header('Content-type: text/html; charset=utf-8'); $templateservice->loadTemplate('error.404.tpl', $tplVars); diff --git a/www/tags.php b/www/tags.php index 09725e4..fca8a04 100644 --- a/www/tags.php +++ b/www/tags.php @@ -77,7 +77,7 @@ if ($userservice->isLoggedOn()) { $tplVars['rsschannels'], array( filter($sitename .': Tags: '. $cat . sprintf(T_(': (private) ')) . $currentUsername), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey()) + createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) ) ); } -- cgit v1.2.3-54-g00ecf From 90b6e65b1193b780c9c363fee3b1e92a5d0fba30 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 27 Jun 2011 23:03:31 +0200 Subject: escape feed links properly and fix some bugs in the feed link parameters --- data/templates/default/bookmarks.tpl.php | 12 ++++++------ data/templates/default/top.inc.php | 2 +- www/bookmarks.php | 20 +++++++++++++++----- www/index.php | 16 ++++++++++++---- www/tags.php | 17 +++++++++++++---- 5 files changed, 47 insertions(+), 20 deletions(-) diff --git a/data/templates/default/bookmarks.tpl.php b/data/templates/default/bookmarks.tpl.php index 8753b7f..0ed9c1d 100644 --- a/data/templates/default/bookmarks.tpl.php +++ b/data/templates/default/bookmarks.tpl.php @@ -222,12 +222,12 @@ if ($currenttag!= '') { $size = count($rsschannels); for ($i = 0; $i < $size; $i++) { $brss = '' - . '' . $rsschannels[$i][0] .'' - . ''; + . ' href="'. htmlspecialchars($rsschannels[$i][1]) . '"' + . ' title="' . htmlspecialchars($rsschannels[$i][0]) . '">' + . '' . htmlspecialchars($rsschannels[$i][0]) .'' + . ''; } $pagesBanner = '

'. $bfirst .' / '. $bprev .' / '. $bnext .' / '. $blast .' / '. sprintf(T_('Page %d of %d'), $page, $totalpages) ." ". $brss ."

\n"; diff --git a/data/templates/default/top.inc.php b/data/templates/default/top.inc.php index 9eed6ff..0f67a17 100644 --- a/data/templates/default/top.inc.php +++ b/data/templates/default/top.inc.php @@ -13,7 +13,7 @@ if (isset($rsschannels)) { for ($i = 0; $i < $size; $i++) { echo ' '; + . ' href="'. htmlspecialchars($rsschannels[$i][1]) .'" />' . "\n"; } } ?> diff --git a/www/bookmarks.php b/www/bookmarks.php index 7056fa6..72c063e 100644 --- a/www/bookmarks.php +++ b/www/bookmarks.php @@ -229,14 +229,14 @@ if ($templatename == 'editbookmark.tpl') { $tplVars['sidebar_blocks'] = array('watchstatus'); if (!$cat) { //user page without tags - $rssTitle = ": My Bookmarks"; + $rssTitle = "My Bookmarks"; $cat = NULL; $tplVars['currenttag'] = NULL; //$tplVars['sidebar_blocks'][] = 'menu2'; $tplVars['sidebar_blocks'][] = 'linked'; $tplVars['sidebar_blocks'][] = 'popular'; } else { //pages with tags - $rssTitle = ": Tags" . $catTitle; + $rssTitle = "Tags" . $catTitle; $rssCat = '/'. filter($cat, 'url'); $tplVars['currenttag'] = $cat; $tplVars['sidebar_blocks'][] = 'tagactions'; @@ -266,7 +266,11 @@ if ($templatename == 'editbookmark.tpl') { // Set template vars $tplVars['rsschannels'] = array( - array(filter($sitename .$rssTitle), createURL('rss', filter($user, 'url') . $rssCat.'?sort='.getSortOrder())) + array( + sprintf(T_('%s: %s'), $sitename, $rssTitle), + createURL('rss', filter($user, 'url')) + . $rssCat . '?sort='.getSortOrder() + ) ); if ($userservice->isLoggedOn()) { @@ -275,8 +279,14 @@ if ($templatename == 'editbookmark.tpl') { array_push( $tplVars['rsschannels'], array( - filter($sitename . $rssTitle. sprintf(T_(': (private) ')) . $currentUsername), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) + sprintf( + T_('%s: %s (+private %s)'), + $sitename, $rssTitle, $currentUsername + ), + createURL('rss', filter($currentUsername, 'url')) + . $rssCat + . '?sort=' . getSortOrder() + . '&privateKey=' . $currentUser->getPrivateKey() ) ); } diff --git a/www/index.php b/www/index.php index f270f73..7fbb84c 100644 --- a/www/index.php +++ b/www/index.php @@ -42,17 +42,25 @@ if (GET_ACTION == "logout") { // Header variables $tplVars['loadjs'] = true; $tplVars['rsschannels'] = array( -array(sprintf(T_('%s: Recent bookmarks'), htmlspecialchars($sitename)), createURL('rss').'?sort='.getSortOrder()) + array( + sprintf(T_('%s: Recent bookmarks'), $sitename), + createURL('rss') . '?sort=' . getSortOrder() + ) ); if ($userservice->isLoggedOn()) { - $currentUsername = $currentUser->getUsername(); if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) { + $currentUsername = $currentUser->getUsername(); array_push( $tplVars['rsschannels'], array( - filter(sprintf(T_('%s: Recent bookmarks (+private) %s'), $sitename, $currentUsername)), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) + sprintf( + T_('%s: Recent bookmarks (+private %s)'), + $sitename, $currentUsername + ), + createURL('rss') + . '?sort=' . getSortOrder() + . '&privateKey=' . $currentUser->getPrivateKey() ) ); } diff --git a/www/tags.php b/www/tags.php index fca8a04..127f6c5 100644 --- a/www/tags.php +++ b/www/tags.php @@ -67,17 +67,26 @@ if ($usecache) { $tplVars['pagetitle'] = T_('Tags') .': '. $cat; $tplVars['loadjs'] = true; $tplVars['rsschannels'] = array( -array(filter($sitename .': Tags: '. $cat), createURL('rss', 'all/'. filter($cat, 'url')).'?sort='.getSortOrder()) + array( + sprintf(T_('%s: tagged with "%s"'), $sitename, $cat), + createURL('rss', 'all/' . filter($cat, 'url')) + . '?sort='.getSortOrder() + ) ); if ($userservice->isLoggedOn()) { - $currentUsername = $currentUser->getUsername(); if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) { + $currentUsername = $currentUser->getUsername(); array_push( $tplVars['rsschannels'], array( - filter($sitename .': Tags: '. $cat . sprintf(T_(': (private) ')) . $currentUsername), - createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privateKey='.$currentUser->getPrivateKey()) + sprintf( + T_('%s: tagged with "%s" (+private %s)'), + $sitename, $cat, $currentUsername + ), + createURL('rss', filter($currentUsername, 'url')) + . '?sort=' . getSortOrder() + . '&privateKey=' . $currentUser->getPrivateKey() ) ); } -- cgit v1.2.3-54-g00ecf From 38c87907f1ef2137d989c0bde1201e539d7017fa Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 30 Jun 2011 19:17:47 +0200 Subject: add merged features to changelog, mention brett and mark --- doc/ChangeLog | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index cde9e61..1456cbc 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -5,20 +5,22 @@ ChangeLog for SemantiScuttle 0.98.0 - 2011-XX-XX ------------------- - Switch to jQuery and drop dojo +- Implement request #2928950: Private keys for RSS feeds (Mark Pemberton) +- Implement request #3164348: Configurable default privacy (Brett Dee) +- Implement request #1989987: Theming support +- Implement request #3054906: Show user's full name instead of nickname +- Implement patch #3059829: update ``FR_CA`` translation - Fix bug #3187177: Wrong URL / Export XML Bookmarks -- Fix bug in ``getTagsForBookmarks()`` that fetched all tags - Fix bug #3097187: Using opensearch with two tags does not work in Firefox - Fix bug #3251877: French translation JavaScript Bug when editing bookmarks - Fix bug #3168521: Title of tag-filtered RSS Feed is broken - Fix bug #2853627: Javascript warning -- Implement request #1989987: Theming support -- Implement request #3054906: Show user's full name instead of nickname -- Implement patch #3059829: update ``FR_CA`` translation +- Fix bug in ``getTagsForBookmarks()`` that fetched all tags +- Fix privacy issue when fetching tags of several users +- Fix Google custom search XML - Show error message on mysqli connection errors - Update php-gettext library to 1.0.10 - ``api/posts/add`` respects the "replace" parameter now -- Fix privacy issue when fetching tags of several users -- Fix Google custom search XML - Only URLs with an allowed protocol may be added to the database - Support HTTPS connections when ``$root`` is not configured - SQL schema version table to ease future database upgrades -- cgit v1.2.3-54-g00ecf From 257ea4ff6e8825f4b1ccefacae8dbaed8ccaf30a Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 4 Jul 2011 18:05:33 +0200 Subject: make rST rendering work fully --- build.xml | 53 ++++++++++++++--------------------------------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/build.xml b/build.xml index d0637c7..83e5c70 100644 --- a/build.xml +++ b/build.xml @@ -30,7 +30,8 @@ - + + - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-54-g00ecf From 9994e92a3c8c570154de4effa16d4e7f087e2b85 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 4 Jul 2011 18:08:38 +0200 Subject: link changelog --- doc/ChangeLog | 1 + doc/index.rst | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 1456cbc..87c1b46 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,6 +1,7 @@ ChangeLog for SemantiScuttle ============================ +.. contents:: 0.98.0 - 2011-XX-XX ------------------- diff --git a/doc/index.rst b/doc/index.rst index 1b8feea..85d2ab6 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -35,6 +35,7 @@ Developer documentation - `How to release a new version`__ - `Running unit testes`__ - `How to translate SemanticScuttle`__ +- `ChangeLog`__ __ developers/rules.html __ developers/api.html @@ -42,4 +43,4 @@ __ developers/debugging.html __ developers/release-new-version.html __ developers/running-unit-tests.html __ developers/translation.html - +__ ChangeLog.html -- cgit v1.2.3-54-g00ecf From 25e05c573b22cee0f55691eb50b73800fd8b5781 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 4 Jul 2011 18:14:58 +0200 Subject: add TOC to some pages --- doc/INSTALL.txt | 2 ++ doc/README.rst | 4 +++- doc/UPGRADE.txt | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/INSTALL.txt b/doc/INSTALL.txt index 5afc732..572da35 100644 --- a/doc/INSTALL.txt +++ b/doc/INSTALL.txt @@ -31,6 +31,8 @@ Installation instructions on the shell. 5. Set the ``www/`` directory as document root in your web server, restart the web server. +6. That's all! Visit your SemanticScuttle installation web site now + with your browser. Ugly www directory in URLs diff --git a/doc/README.rst b/doc/README.rst index 0c7befe..7702400 100644 --- a/doc/README.rst +++ b/doc/README.rst @@ -4,7 +4,9 @@ SemanticScuttle 0.98 A social bookmarking tool experimenting with new features like structured tags or collaborative descriptions of tags. -https://sourceforge.net/projects/semanticscuttle/ +- Home page: http://semanticscuttle.sourceforge.net/ +- Project page: https://sourceforge.net/projects/semanticscuttle/ +- Demo: http://semanticscuttle.sourceforge.net/demo/ Available under the GNU General Public License diff --git a/doc/UPGRADE.txt b/doc/UPGRADE.txt index 1a0b964..b144af2 100644 --- a/doc/UPGRADE.txt +++ b/doc/UPGRADE.txt @@ -2,6 +2,7 @@ Upgrading SemanticScuttle from a previous version ================================================= +.. contents:: From version 0.97 to 0.98 ========================= -- cgit v1.2.3-54-g00ecf From ae86aa2b5685f0e4f4c6cce9ee3511e60dff7dda Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 4 Jul 2011 18:25:15 +0200 Subject: doc directories are created automatically --- build.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.xml b/build.xml index 83e5c70..7b9229d 100644 --- a/build.xml +++ b/build.xml @@ -333,8 +333,6 @@ - - -- cgit v1.2.3-54-g00ecf From 651d5df1f90985a28a4e7a47cf54292e6f7fefb2 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 5 Jul 2011 06:46:51 +0200 Subject: add stylesheet to docs --- build.xml | 13 ++++++++++--- res/docs/style.css | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 res/docs/style.css diff --git a/build.xml b/build.xml index 7b9229d..ef57fb4 100644 --- a/build.xml +++ b/build.xml @@ -208,10 +208,10 @@ - - + @@ -221,6 +221,13 @@ + diff --git a/res/docs/style.css b/res/docs/style.css new file mode 100644 index 0000000..a49b9c1 --- /dev/null +++ b/res/docs/style.css @@ -0,0 +1,25 @@ +/* SemanticScuttle improvements */ +h1.title { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgIfAhkiAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAsvSURBVGiBxZprjCRXdcd/p6r6Nd0979mHZ+3sCkfx4AdJsAhGm2BMYhAbrAgsEimKjGIlxELk8SkrQoQiSGgrCSJZh9hECsQ8hJCQlRDjYDsY4RAvRF6b9drN2t7HzOzOzmtnpl/V1fW4Jx+qu6emZ3pmbI/kI7Wq+9Ste///87j33FstqspeS7kkR4HPAAeAx4G/mDqu9T0fCJC9JlAuyXuB72Ymbklnxt9K/fxjmFblf4A7p45rc08HA6y97KxcksPAI5mJW9JDN99DbvI2Rt7+CSSVPwo8tJdjdWRPCQAPWZmhYuHn70LwyeQFOzvC4C/cDfB75ZL85h6Pt3cEyiW5B7gzf+T9ABRGM+SHHFIZQ3p8isz4TajyYLkkQ3s1JuwRgXJJ9gGfT49NkSpeQzYvpDMKxic/kkLUp3D9MaxUbhL4u70YsyN75YH7xcmN5q75FUQCCqNp0BaYFraE5IdTiJUmf+ROVLm3XJLb9mjcN06gXJJ3Avdk9/0iqDK0L4slAZgA1Af1yeaFVMaQGXsrqeKkGOWBckn2xHhvqJNySQQ4YWVHxRk8RCYvZHICptX1ACYmURhLo8Zj4OfegyXyy8C9bzoB4GPArZmxKYg8hvbn2lYP2sCDLgnHMQwMOtjZETLjN2IMnyuXZORNI1AuyU3A553CJOJkKY5ncZxog9W7V/XBtOKExid78Fbs9MCYUf71TSHQBv8tSeVzTnESJxVSnMgkgLfWwyhBxCJgcF8WEPJxKP1WuSSfLZdk8PUS2FUpUS7JAeCdwG3AMeBGsbOkhg5jpXNM3nQd6YEsiAU48VVsoH0VC7Db323WrtRorHr4Ky/TWnwejVot4HvAD4BngOemjmvrdRMol+Qg8OvAbwC/ChwGASuFlcphpQqIk0XEZuL6/QzuH2kD7AVub6lXtVi6sELgGRAhbMwTVGeJGgsYvwrgA6eAp4iLwf+dOq7+tgTKJbkF+Ggb9E3xbQssG7EcxE6D2IjYWKkU+fFBhg+MkhvO94DcgUj7atSisdKkWfXbRGzEstEoIGouE7qLhLU5ouYSQAP4IfBd4OGp41rtEnjpc+SBh4EPbe0kC7EtcsMFsoMFBkYK5EeKWI5DMiz6hctu9IGvePWAoBkReBFhAGK125mAsD5PULtEsHYOjVoV4ONTx/XrHQL/DPzRBrdYwsDwAPmRPAOjA2QLWcSSra2btHI//WsIL8TGRELLDWm5AX4jJAxBxAYUb/4U3sIpBd4+dVyfc4APdIAXxguMXjtKbjiHZW01QUWg7Y9YoB0gUft7r5UT+k7bThttA07q220tyyZXsMgVB0AswgBa9YD6VZfMvrfhLZwS4H3Acw5wBbgOIFvMkh/Nbx1JG8SAGiBMAEiAwtqlPtqsJ6mPDeA4NtagTW2xhb86DcBilaWp+ElOdGAtX1ymsdLYBYFer/QuWtuvBxv0Znf6lZkrBG4Fb/5ZWgGLv/sgMyIybgHfaIWcBEDh8guX8Ztbzli7INIuHbpg2wWdWS8pNul7wXafXddXrizjXl2jefkkGrp8v8wDl1fxgWtFVbnvDvmlj93B4xmHcYBMPsPhWw9jpTKQmoD0frAH25177U8LWpdiXV/pJKnD5tlod/pGxWPp3ApB5SJhbZZXF/jWXV/gi+0BPAfgwac4m0nxl39wO/9oWU4qdeiDVPQwwweuRTqdqqGbxGisswvgnoX6s+DP9/FKlIjpZPJaINH66r2FvtWIWHplkdBdIazNslLn2d/+Ig8mBlhxAFTVFZHv33CQv3/3DeHxsDKNHjpKo+pQGMkCJgathvUENhDWYw9N3A2RC9WT4L60BZH2MxomQDqsz1JRj/UjAs9w5cV5Qq9BUJnGC7jyx1/jr5o+Zt06TCfnyvP3/RuPlOf4qjf/f9TPPUqr5uKu1duDR20gHasaEI0BRY04pIbfCxO/E3tmS9GYxIaE3Vy1Rn6TuTMXCRprBJUZwkgbJ57gk6emqSY6e0VV/S4BVQ2BMx8+wZcurfBfjYtP0Jw7ibtap9VorpPoeiFK6NqhEC6DpODgH0L+5j4kkuGVTPo4adW0mDtzkVa1QtiYx6gJvvljPvnlp7mQePiSqi5ATzmtqi5Q/tAJ/na5xo9rZx8hqFygtrhGFAY9edDxSoIIGs8e3kzbGx8Ba6d1xazPSuqzfH6OxtU1Im8VNZF54gx//Tff4aeJB1aB850fm5ZbVb1a9zh3z5f4tOub2erZb2OCJtWFVbTXA0SgGv/uxnk7X7yLYGXhmvtg6NdAMjsQUZprNZbPz6GBCxpx5jJf/rNv8INEIxd4SRMl9JYbGlWdvrDMxa88zWej5mrUuPgkgesTND02JHHXI4ZNeYKBYAXcn8XhdOhPYfg9YOX6Urg6c7VrkEqTFz/6L3w9cdsHXmiHele225G9/MCTPLNc5ydB7TKqESYMEiAT4DeFVfJ+CM2XYyK5G2DyT+LwckY3DRj669gef4Gv9Mw4L6iq1/uM0w+9qqqIvCTgYhIzT8f6vSFDMg96pls1ENXiKVYccEZg7FgcVurH9/wl0qOD+P4FIneReovOQbACL6pufbq97Z5YVaPhAdZQAyaKc6BfyCRnpU0eSuiNB/5lcF+BxumYlHcJALt4mIHrbgfAGDpxPqOqq/0w9vVAt4HNsDgZVCNEeuM/4YEu4J6k3tCm10OJtlEL9eYIKi4gjBd1kHgnNr0tvp0IAAcklQcTYdusg9guZDbptgK/+b6dEtTEZcdYIRwFmrrDqcOuCFhODtUIy5adwe8EuGv5iI3eM9iOgEaIZTM0EI62B9tWtiVQLkkKGBUnBxph2dtZOxE+m0gpuwkv26HtAYtChlF2cW61kwdGABE7jYhB+gF+LR7YcN9sIG070ClLBjKMA+k3SqAI8QmBSD/rbgTsey2aqw3ctRqRH5DOp8gP58gW03EObUkq7ltsUDWIWKQsBvaMAGLH1t9g1XUPGBPhrtSoLVUJ3BaqBtNaw/gNAncI92oVMORHcwzuK5IZcLYIL4NldQwBjr2HBERsxNq8iEVBQG2pSn25hgkCTFAnqM4QuUto1DkZFKx0ATs3Ri0coba4RibvMLS/SH4kF3u23a9lxTmgqjgWOUBExOktH14LgWx86cR63LlXaVBfqeFVXTSKCN0Fgso0xlvBGPzFKj86fYmny3PM3DGltx3ZV7u94NfeQnUWOzuK8YfxKnVsRyiO5ylMDJDJOSCdRdEQbwUBsIHXTWAJwAQNAs9nZfYqzaqL8QNM6BJUZwmrs2jk4Ycsn73Cv3/he3znmXOsdTp46CleBb7658e45f03R3fvG1w6Ks0lS1J5onSRVa/Jyqwhk0/hZKx4xTchrYCVBIG+shOBl4FaUJku2rkx6o0KUXM5PohtLqOqutrg1LMXefTTj/DDNbe/pe5/lNP3P8rpY29j/73v5oNHJhrvywSNiQgLK53HCzLxwa+JX46sNji3G4w7Hq+XS/IJVf5BBOnoWgGL5xZ57OEf8dh/PMdWu/mO+MQbkByw4R1ALo31qbt4x7uu5wMTg7zLknWgfsjyp77Nx//zeRaA09vVQrt6P/CZD8vv33CQo65P9acznP2n/+ZnftgtdXtFgWVgTlW7oSQiGeL/TlxDz+xy6xEGP/IObj48zlu8APeBJ3niJ+eptG8/r6oV+siuCIjIjRCfGW0jIfEx5WXV/i8nRESACWCSHq/0kZPb9bebWghgkf4E1oB5YElV+3mlK+3ibBFYFJECsVf298Gyth142KUHAERkEjgEpIA6cWwvbLVLeq0iIhYwRuyZQeKZZxV4VXXboz/+HwP+91Qbpr+OAAAAAElFTkSuQmCC"); + background-repeat: no-repeat; + padding-left: 64px; + padding-top: 0.2em; + margin-bottom: 00px; + height: 60px; + border-bottom: 3px solid #666; +} +h2 { + margin-top: 1.5em; + +} +pre { + padding: 1em; + background-color: #EEE; + border: 1px solid #BBB; + width: auto; +} + +tt, code { + background-color: #DDD; + padding: 0.2ex; +} -- cgit v1.2.3-54-g00ecf From 846e3a38cf049266a33cb3e553fcacbcbdc0bfa3 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 5 Jul 2011 19:55:01 +0200 Subject: allinone file, which we do not use for now --- build.xml | 3 ++- doc/allinone.rst | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 doc/allinone.rst diff --git a/build.xml b/build.xml index ef57fb4..54456e3 100644 --- a/build.xml +++ b/build.xml @@ -209,7 +209,7 @@ - @@ -219,6 +219,7 @@ + SemanticScuttle A social bookmarking tool @@ -109,30 +121,34 @@ **/.svn build* data/config.php + data/config.testing.php + data/config.testing-tmp.php data/locales/messages.po data/locales/*/LC_MESSAGES/messages.po dist/** - doc/developers/** scripts/** src/php-gettext/examples/** - src/php-gettext/bin/** - *.tgz + src/php-gettext/tests/** *.properties + *.sql + *.tgz - + + - - - diff --git a/data/templates/default/about.tpl.php b/data/templates/default/about.tpl.php index 7bff98d..8a9b206 100644 --- a/data/templates/default/about.tpl.php +++ b/data/templates/default/about.tpl.php @@ -17,7 +17,7 @@ $this->includeTemplate($GLOBALS['top_include']); isAdmin()): ?> -
  • SemanticScuttle v0.97.0
  • +
  • SemanticScuttle v0.98.0
  • diff --git a/doc/ChangeLog b/doc/ChangeLog index 87c1b46..7ed1796 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -26,6 +26,7 @@ ChangeLog for SemantiScuttle - Support HTTPS connections when ``$root`` is not configured - SQL schema version table to ease future database upgrades - Documentation is written with rST (reStructuredText) now +- Support per-host configuration files 0.97.2 - 2011-02-17 diff --git a/doc/developers/release-new-version.rst b/doc/developers/release-new-version.rst index 4b2540a..a5e77dc 100644 --- a/doc/developers/release-new-version.rst +++ b/doc/developers/release-new-version.rst @@ -2,18 +2,18 @@ How to release a new version of SemanticScuttle =============================================== 0. Run unit tests and verify that all of them pass -1. Update doc/ChangeLog -2. Update doc/UPGRADE.txt -3. Update version in data/templates/about.tpl.php, - build.xml and doc/README.txt +1. Update ``doc/ChangeLog`` +2. Update ``doc/UPGRADE.txt`` +3. Update version in ``data/templates/about.tpl.php``, + ``build.xml`` and ``doc/README.rst`` 4. Create a release zip file via the build script: - Just type "phing". + Just type "``phing``". 5. Make a test installation from your zip file with a fresh database. Register a user, add bookmarks etc. 6. When all is fine, it's time to release. The build script takes care for most of the tasks. - Run "phing release", and it will upload the release to + Run "``phing release``", and it will upload the release to sourceforge and create a svn tag. 7. Write announcement mail to the SemanticScuttle mailing list semanticscuttle-devel@lists.sourceforge.net -- cgit v1.2.3-54-g00ecf From 62afbfc18412db7bc4b4ede0a46691b021ab7dea Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 21 Jul 2011 22:33:27 +0200 Subject: include sql files in pear package --- build.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.xml b/build.xml index 202b3b8..9627c01 100644 --- a/build.xml +++ b/build.xml @@ -66,11 +66,12 @@ + + - - +
    @@ -130,7 +131,7 @@ src/php-gettext/examples/** src/php-gettext/tests/** *.properties - *.sql + semanticscuttle-dump.sql *.tgz
    + + + + + + + + - + + + + -- cgit v1.2.3-54-g00ecf From 7cb53eb4e55943aa59928a97391ad9507f907cbc Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 21 Jul 2011 23:22:29 +0200 Subject: task to deploy the demo to the website --- build.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build.xml b/build.xml index 8997366..6bd5eb2 100644 --- a/build.xml +++ b/build.xml @@ -367,6 +367,18 @@ + + + + + +?xml version="1.0" encoding="utf-8"?> diff --git a/doc/ChangeLog b/doc/ChangeLog index d97c5ac..417f4c6 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -3,6 +3,11 @@ ChangeLog for SemantiScuttle .. contents:: +0.98.1 - 2011-XX-XX +------------------- +- Fix bug #3375635: XML parsing problem in top.inc.php + + 0.98.0 - 2011-07-21 ------------------- - Switch to jQuery and drop dojo -- cgit v1.2.3-54-g00ecf From 20530bd5c5f235b6e4d5fed8b503998f07482629 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sat, 23 Jul 2011 08:29:44 +0200 Subject: doc header, currently unused --- res/docs/header.tpl.html | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 res/docs/header.tpl.html diff --git a/res/docs/header.tpl.html b/res/docs/header.tpl.html new file mode 100644 index 0000000..ee0650f --- /dev/null +++ b/res/docs/header.tpl.html @@ -0,0 +1,8 @@ + -- cgit v1.2.3-54-g00ecf From ba6465e310a5cb537cc46c2ed483e55ea9949cd0 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sat, 23 Jul 2011 08:33:52 +0200 Subject: Fix bug #3375428: Forgot to remove some old dojo files --- data/templates/default/dojo.inc.php | 35 ----------------- doc/ChangeLog | 1 + www/js/jstree-1.0-rc2/MultiComboBox.js | 72 ---------------------------------- 3 files changed, 1 insertion(+), 107 deletions(-) delete mode 100644 data/templates/default/dojo.inc.php delete mode 100644 www/js/jstree-1.0-rc2/MultiComboBox.js diff --git a/data/templates/default/dojo.inc.php b/data/templates/default/dojo.inc.php deleted file mode 100644 index 366dcfe..0000000 --- a/data/templates/default/dojo.inc.php +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/doc/ChangeLog b/doc/ChangeLog index 417f4c6..229db55 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -6,6 +6,7 @@ ChangeLog for SemantiScuttle 0.98.1 - 2011-XX-XX ------------------- - Fix bug #3375635: XML parsing problem in top.inc.php +- Fix bug #3375428: Forgot to remove some old dojo files 0.98.0 - 2011-07-21 diff --git a/www/js/jstree-1.0-rc2/MultiComboBox.js b/www/js/jstree-1.0-rc2/MultiComboBox.js deleted file mode 100644 index b263c8b..0000000 --- a/www/js/jstree-1.0-rc2/MultiComboBox.js +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved. - Available via Academic Free License >= 2.1 OR the modified BSD license. - see: http://dojotoolkit.org/license for details -*/ - -/* SemanticScuttle: This script is a light modification of dojox.form.MultiComboBox -This fork allows specific use until DOJO 1.2.3 in Google CDN. */ - - - -if(!dojo._hasResource["js.MultiComboBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["js.MultiComboBox"] = true; -dojo.provide("js.MultiComboBox"); -dojo.experimental("js.MultiComboBox"); -dojo.require("dijit.form.ComboBox"); -dojo.require("dijit.form.ValidationTextBox"); - -dojo.declare("js.MultiComboBox", - [dijit.form.ValidationTextBox, dijit.form.ComboBoxMixin],{ - // - // summary: A ComboBox that accpets multiple inputs on a single line? - // - // delimiter: String - // The character to use to separate items in the ComboBox input - delimiter: ",", - _previousMatches: false, - - _setValueAttr: function(value){ - if (this.delimiter && value.length != 0){ - value = value+this.delimiter+" "; - arguments[0] = this._addPreviousMatches(value); - } - this.inherited(arguments); - }, - - _addPreviousMatches: function(/* String */text){ - if(this._previousMatches){ - if(!text.match(new RegExp("^"+this._previousMatches))){ - text = this._previousMatches+text; - } - } - text = this._cleanupDelimiters(text); // SScuttle: this line was moved - return text; // String - }, - - _cleanupDelimiters: function(/* String */text){ - if(this.delimiter){ - text = text.replace(new RegExp(" +"), " "); - text = text.replace(new RegExp("^ *"+this.delimiter+"* *"), ""); - text = text.replace(new RegExp(this.delimiter+" *"+this.delimiter), this.delimiter); - } - return text; - }, - - _autoCompleteText: function(/* String */text){ - arguments[0] = this._addPreviousMatches(text); - this.inherited(arguments); - }, - - _startSearch: function(/* String */text){ - text = this._cleanupDelimiters(text); - var re = new RegExp("^.*"+this.delimiter+" *"); - - if((this._previousMatches = text.match(re))){ - arguments[0] = text.replace(re, ""); - } - this.inherited(arguments); - } -}); - -} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 0396dee7304c616ecb60c048d4013f917a7087f4 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sat, 23 Jul 2011 14:07:58 +0200 Subject: fix typo --- src/SemanticScuttle/constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SemanticScuttle/constants.php b/src/SemanticScuttle/constants.php index f8567d9..11ab0da 100644 --- a/src/SemanticScuttle/constants.php +++ b/src/SemanticScuttle/constants.php @@ -74,7 +74,7 @@ if (isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) { if (strlen($_SERVER["PATH_INFO"]) + * @license AGPL http://www.gnu.org/licenses/agpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ + +/** + * Server environment handling methods + * + * @category Bookmarking + * @package SemanticScuttle + * @author Christian Weiske + * @license AGPL http://www.gnu.org/licenses/agpl.html + * @link http://sourceforge.net/projects/semanticscuttle + */ +class SemanticScuttle_Environment +{ + /** + * Determines the correct $_SERVER['PATH_INFO'] value + * + * @return string New value + */ + public static function getServerPathInfo() + { + /* old code that does not work today. + if you find that this code helps you, tell us + and send us the output of var_export($_SERVER); + // Correct bugs with PATH_INFO (maybe for Apache 1 or CGI) -- for 1&1 host... + if (isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) { + if (strlen($_SERVER["PATH_INFO"]) \ No newline at end of file diff --git a/src/SemanticScuttle/constants.php b/src/SemanticScuttle/constants.php index 11ab0da..fcb2d90 100644 --- a/src/SemanticScuttle/constants.php +++ b/src/SemanticScuttle/constants.php @@ -69,16 +69,6 @@ define('PAGE_WATCHLIST', "watchlist"); // installations on the same host server define('INSTALLATION_ID', md5($GLOBALS['dbname'].$GLOBALS['tableprefix'])); -// Correct bugs with PATH_INFO (maybe for Apache 1 or CGI) -- for 1&1 host... -if (isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) { - if (strlen($_SERVER["PATH_INFO"]) diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php index 9252300..694df54 100644 --- a/src/SemanticScuttle/header.php +++ b/src/SemanticScuttle/header.php @@ -25,6 +25,7 @@ if ('@data_dir@' == '@' . 'data_dir@') { //FIXME: when you have multiple installations, the www_dir will be wrong $wwwdir = '@www_dir@/SemanticScuttle/'; } +require_once dirname(__FILE__) . '/Environment.php'; require_once dirname(__FILE__) . '/Config.php'; $cfg = new SemanticScuttle_Config(); diff --git a/tests/SemanticScuttle/EnvironmentTest.php b/tests/SemanticScuttle/EnvironmentTest.php new file mode 100644 index 0000000..a41efa1 --- /dev/null +++ b/tests/SemanticScuttle/EnvironmentTest.php @@ -0,0 +1,95 @@ + 'Opera/9.80 (X11; Linux x86_64; U; de) Presto/2.9.168 Version/11.50', + 'HTTP_HOST' => 'bm-cgi.bogo', + 'HTTP_ACCEPT' => 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1', + 'HTTP_ACCEPT_LANGUAGE' => 'de-DE,de;q=0.9,en;q=0.8', + 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', + 'HTTP_COOKIE' => 'PHPSESSID=ga446jhs0e09hkt60u9bsmp0n0', + 'HTTP_CACHE_CONTROL' => 'no-cache', + 'HTTP_CONNECTION' => 'Keep-Alive', + 'PATH' => '/usr/local/bin:/usr/bin:/bin', + 'SERVER_SIGNATURE' => '
    Apache/2.2.17 (Ubuntu) Server at bm-cgi.bogo Port 80
    ', + 'SERVER_SOFTWARE' => 'Apache/2.2.17 (Ubuntu)', + 'SERVER_NAME' => 'bm-cgi.bogo', + 'SERVER_ADDR' => '127.0.0.1', + 'SERVER_PORT' => '80', + 'REMOTE_ADDR' => '127.0.0.1', + 'DOCUMENT_ROOT' => '/etc/apache2/htdocs', + 'SERVER_ADMIN' => '[no address given]', + 'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/bm-cgi.bogo/profile.php', + 'REMOTE_PORT' => '45349', + 'GATEWAY_INTERFACE' => 'CGI/1.1', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + 'REQUEST_METHOD' => 'GET', + 'QUERY_STRING' => '', + 'REQUEST_URI' => '/profile.php/dummy', + 'SCRIPT_NAME' => '/profile.php', + 'PATH_INFO' => '/dummy', + 'PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/bm-cgi.bogo/dummy', + 'PHP_SELF' => '/profile.php/dummy', + 'REQUEST_TIME' => 1311422546, + ); + $this->assertEquals( + '/dummy', SemanticScuttle_Environment::getServerPathInfo() + ); + } + + + public function testServerPathInfoFastCgi() + { + $_SERVER = array( + 'PHP_FCGI_MAX_REQUESTS' => '5000', + 'PHPRC' => '/etc/php5/cgi/5.3.6/', + 'PHP_FCGI_CHILDREN' => '3', + 'PWD' => '/var/www/cgi-bin', + 'FCGI_ROLE' => 'RESPONDER', + 'REDIRECT_HANDLER' => 'php-cgi', + 'REDIRECT_STATUS' => '200', + 'HTTP_USER_AGENT' => 'Opera/9.80 (X11; Linux x86_64; U; de) Presto/2.9.168 Version/11.50', + 'HTTP_HOST' => 'bm-cgi.bogo', + 'HTTP_ACCEPT' => 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1', + 'HTTP_ACCEPT_LANGUAGE' => 'de-DE,de;q=0.9,en;q=0.8', + 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', + 'HTTP_COOKIE' => 'PHPSESSID=ga446jhs0e09hkt60u9bsmp0n0', + 'HTTP_CONNECTION' => 'Keep-Alive', + 'PATH' => '/usr/local/bin:/usr/bin:/bin', + 'SERVER_SIGNATURE' => '
    Apache/2.2.17 (Ubuntu) Server at bm-cgi.bogo Port 80
    ', + 'SERVER_SOFTWARE' => 'Apache/2.2.17 (Ubuntu)', + 'SERVER_NAME' => 'bm-cgi.bogo', + 'SERVER_ADDR' => '127.0.0.1', + 'SERVER_PORT' => '80', + 'REMOTE_ADDR' => '127.0.0.1', + 'DOCUMENT_ROOT' => '/etc/apache2/htdocs', + 'SERVER_ADMIN' => '[no address given]', + 'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/bm-cgi.bogo/profile.php', + 'REMOTE_PORT' => '45342', + 'REDIRECT_URL' => '/profile.php/dummy', + 'GATEWAY_INTERFACE' => 'CGI/1.1', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + 'REQUEST_METHOD' => 'GET', + 'QUERY_STRING' => '', + 'REQUEST_URI' => '/profile.php/dummy', + 'SCRIPT_NAME' => '/profile.php', + 'PATH_INFO' => '/dummy', + 'PATH_TRANSLATED' => '/etc/apache2/htdocs/dummy', + 'ORIG_PATH_INFO' => '/profile.php/dummy', + 'ORIG_SCRIPT_NAME' => '/cgi-bin-php/php-cgi-5.3.6', + 'ORIG_SCRIPT_FILENAME' => '/var/www/cgi-bin/php-cgi-5.3.6', + 'ORIG_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/bm-cgi.bogo/profile.php/dummy', + 'PHP_SELF' => '/profile.php/dummy', + 'REQUEST_TIME' => 1311422521, + ); + $this->assertEquals( + '/dummy', SemanticScuttle_Environment::getServerPathInfo() + ); + } + +} + +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 81aa17b8523d95310c90366d9af09767db0c84f2 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sat, 23 Jul 2011 17:47:51 +0200 Subject: fix typo --- doc/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index fc8c718..f963ca2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -7,7 +7,7 @@ ChangeLog for SemantiScuttle ------------------- - Fix bug #3375635: XML parsing problem in top.inc.php - Fix bug #3375428: Forgot to remove some old dojo files -- Fix bug #3160512: Make SemantiScuttle work with FastCGI +- Fix bug #3160512: Make SemanticScuttle work with FastCGI 0.98.0 - 2011-07-21 -- cgit v1.2.3-54-g00ecf