function CheckNewUrl($newUrl) { require_once('lib/hubbub2_loadurl.php'); // let's see if there is a valid entity record at this url $ne = hubbub2_loadurl($newUrl); if(sizeof($ne) == 0) { $result = array('result' => 'fail', 'reason' => 'entity_not_found'); } else if($ne['user'] == '' || $ne['server'] == '') { $result = array('result' => 'fail', 'reason' => 'invalid_entity'); } else { $userEntity = HubbubEntity::ds2array($GLOBALS['obj']['user']->selfEntity()); $localEntity = HubbubEntity::findEntity($ne); $result = array('entity' => $ne, 'match' => $localEntity); if(sizeof($localEntity) == 0 || $localEntity['user'] != $userEntity['user']) { $result['result'] = 'fail'; $result['reason'] = 'entity_mismatch'; } else { $result['result'] = 'OK'; } } return($result); }
function h2_getController($controllerName, $isRootController = true) { $controllerName = safeName($controllerName); $controllerFile = 'mvc/' . strtolower($controllerName) . '/' . strtolower($controllerName) . '.controller.php'; if (!file_exists($controllerFile) && $isRootController) { // maybe this is a user URL $entityDS = DB_GetDatasetWQuery('SELECT * FROM ' . getTableName('entities') . ' WHERE user=? AND _local="Y"', array($controllerName)); if (sizeof($entityDS) > 0) { $GLOBALS['msg']['entity'] = HubbubEntity::ds2array($entityDS); $GLOBALS['msg']['touser'] = $controllerName; $controllerName = 'userpage'; $_REQUEST['action'] = 'index'; $controllerFile = 'mvc/' . strtolower($controllerName) . '/' . strtolower($controllerName) . '.controller.php'; } else { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); header('Status: 404 Not Found'); die('File not found: ' . $_SERVER['REQUEST_URI'] . '<br/>' . $controllerName); } } require_once $controllerFile; $controllerClassName = $controllerName . 'Controller'; $thisController = new $controllerClassName($controllerName); if (is_callable(array($thisController, '__init'))) { $thisController->__init(); } $GLOBALS['controllers'][] =& $thisController; if ($isRootController) { $GLOBALS['obj']['controller'] =& $thisController; } return $thisController; }