function testBase() { $loc = new folksoFabula(); $loc->setServerUrl('bobworld.com'); $rl = new folksoResourceLink(234, $loc); $this->assertIsA($rl, folksoResourceLink, "Problem with folksoResourceLink object creation"); $this->assertEqual($rl->identifier, 234, 'Problem with setting $identifier'); $this->assertEqual($rl->getLink(), 'http://bobworld.com/resource.php/folksores=234&folksodatatype=html', 'Incorrect url creation: ' . $rl->getLink()); }
function testBase() { $loc = new folksoFabula(); $loc->setServerUrl('bobworld.com'); $tl = new folksoTagLink('poesie', $loc); $this->assertIsA($tl, folksoTagLink, 'Problem with folksoTagLink object creation'); $this->assertEqual($tl->identifier, 'poesie', 'Problem with setting $identifier'); $this->assertEqual($tl->getLink(), 'http://bobworld.com/tag.php/folksotag=poesie&folksodatatype=html', 'Incorrect url creation: ' . $tl->getLink()); }
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Resources par tag</title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.autocomplete.js"></script> <?php require_once 'folksoClient.php'; require_once 'folksoFabula.php'; require_once 'folksoAdmin.php'; $loc = new folksoFabula(); $fk = new folksoAdmin(); /** If basic authentication info is present, we send it back to the browser for use in ajax requests **/ print $fk->BasicAuthJSScript(); print "<script type='text/javascript'>\n\n"; print $loc->WebPathJS(); print "</script>\n"; ?> <script type="text/javascript" src="js/folkso.js"></script> <script type="text/javascript" src="js/resview.js"> </script> <link rel="stylesheet" type="text/css" href="http://www.fabula.org/commun3/template.css" media="screen"> </link>
function testStatic() { $loc = new folksoFabula(); $this->assertEqual($loc->setServerUrl('example.com'), 'http://example.com', 'Not adding http:// to url with setServerUrl'); $this->assertEqual($loc->web_url, 'http://example.com', '$web_url is not getting set correctly by setServerUrl'); $this->assertEqual($loc->setServerUrl('http://bobworld.com'), 'http://bobworld.com', 'setServerUrl() is mangling url that already contained http://'); $this->assertEqual($loc->setServerUrl('bobworld3/'), 'http://bobworld3', 'setServerUrl() is not removing trailing slash'); $this->assertIsA($loc->locDBC(), folksoDBconnect, 'Not able to build a dbc object'); $loc->loginPage = 'loggezmoi.php'; $loc->setServerUrl('example.com'); $loc->set_server_web_path('hooha'); $this->assertEqual($loc->loginPage(), 'http://example.com/hooha/loggezmoi.php', 'Incorrect loginPage: ' . $loc->loginPage()); $this->assertEqual($loc->web_url, 'http://example.com', 'Incorrect web_url is set: ' . $loc->web_url); $loc->loginPage = 'tagorama/loggezmoi.php'; $this->assertEqual($loc->loginPage(), 'http://example.com/tagorama/loggezmoi.php', 'Incorrect login url with path in $loc->loginPage'); $loc->loginPage = '/tagallday/loggezmoi.php'; $this->assertEqual($loc->loginPage(), 'http://example.com/tagallday/loggezmoi.php', 'Incorrect login url with absolute path in $loc->loginPage' . $loc->loginPage()); }
/** * Based on the request received, checks each response object is * checked to see if it is equiped to handle the request. */ public function Respond() { if (!$this->valid_method()) { // some kind of error header('HTTP/1.0 405'); print "NOT OK. Illegal request method for this resource."; return; } if (!$this->validClientAddress($_SERVER['REMOTE_HOST'], $_SERVER['REMOTE_ADDR'])) { header('HTTP/1.0 403'); print "Sorry, this not available to you"; return; } $q = new folksoQuery($_SERVER, $_GET, $_POST); $realm = 'folkso'; $loc = new folksoFabula(); $dbc = $loc->locDBC(); $fks = new folksoSession($dbc); /** * $sid: session ID */ $sid = $_COOKIE['folksosess'] ? $_COOKIE['folksosess'] : $q->get_param('session'); try { $fks->setSid($sid); } catch (badSidException $e) { if ($q->is_write_method()) { header('HTTP/1.1 403 Login required'); // redirect instead header('Location: ' . $loc->loginPage()); exit; } } /* check each response object and run the response if activatep returns true*/ $repflag = false; if (count($this->responseObjects) === 0) { trigger_error("No responseObjects available", E_USER_ERROR); } /** Walking the response objects **/ foreach ($this->responseObjects as $resp) { if ($resp->activatep($q)) { $repflag = true; $resp->Respond($q, $dbc, $fks); break; } } /** check for no valid response **/ if (!$repflag) { header('HTTP/1.1 400'); print "Client did not make a valid query. (folksoServer)"; // default response or error page... } }