Ejemplo n.º 1
0
function buildURL($p = '')
{
    $index = '';
    if (defined("INDEX_FILE")) {
        $index = INDEX_FILE;
    } else {
        $index = 'index.php';
    }
    $url = HttpRequest::getPathUrl();
    $nb = strlen($url);
    if ($nb == 0 || $url[$nb - 1] != "/") {
        $index = '/' . $index . '/';
    } else {
        $index = $index . '/';
    }
    return "http://" . $_SERVER['HTTP_HOST'] . HttpRequest::getPathUrl() . $index . Util::getActionString($p);
}
Ejemplo n.º 2
0
 /**
  *
  */
 static function redirection($pRedirection = "", $pSauvegarde = true)
 {
     $index = '';
     if (defined("INDEX_FILE")) {
         $index = INDEX_FILE;
     } else {
         $index = 'index.php';
     }
     $url = HttpRequest::getPathUrl();
     $nb = strlen($url);
     # save actual path
     if ($pSauvegarde) {
         $_SESSION['originUrl'] = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     }
     # FIXME surement � am�liorer
     if ($pRedirection != "" && substr($pRedirection, 0, 7) == "http://") {
         header("Location: " . $pRedirection);
     } else {
         if ($nb == 0 || $url[$nb - 1] != "/") {
             header("Location: http://" . $_SERVER['HTTP_HOST'] . $url . "/" . $index . "/" . $pRedirection);
         } else {
             header("Location: http://" . $_SERVER['HTTP_HOST'] . $url . $index . "/" . $pRedirection);
         }
     }
     exit(0);
 }
Ejemplo n.º 3
0
 /**
  * The logout action has to be triggered through an HTTP GET Request. It allows the user
  * to quit gracefully the system.
  *
  */
 public function logout()
 {
     // for openid sso
     if (OPENID_SSO_MODE) {
         setcookie('default_openid', false, 0, HttpRequest::getPathUrl());
     }
     Auth::logout();
     DefaultFC::redirection('wall/index');
 }
Ejemplo n.º 4
0
 public function finish_auth()
 {
     $always_trust = false;
     if (isset($_GET['pal_trust'])) {
         $always_trust = true;
         // we hide this parameter from the openid library
         unset($_GET['pal_trust']);
         $_SERVER['QUERY_STRING'] = str_replace('&pal_trust=true', '', $_SERVER['QUERY_STRING']);
     }
     $db = DbUtil::accessFactory();
     $store = new WMySqlStore($db);
     $store->createTables();
     $consumer =& new Auth_OpenID_Consumer($store);
     $url = HttpRequest::getPathUrl();
     $nb = strlen($url);
     $base_url = '';
     if ($nb == 0 || $url[$nb - 1] != "/") {
         $base_url = "http://" . $_SERVER['HTTP_HOST'] . $url . "/";
     } else {
         $base_url = "http://" . $_SERVER['HTTP_HOST'] . $url;
     }
     $return_url = $base_url . 'index.php/openid/finish_auth';
     // Complete the authentication process using the server's
     // response.
     $response = $consumer->complete($return_url);
     $success = false;
     // Check the response status.
     if ($response->status == Auth_OpenID_CANCEL) {
         // This means the authentication was cancelled.
         $msg = __('Verification cancelled.');
     } else {
         if ($response->status == Auth_OpenID_FAILURE) {
             // Authentication failed; display the error message.
             $msg = __("OpenID authentication failed: ") . $response->message;
         } else {
             if ($response->status == Auth_OpenID_SUCCESS) {
                 $success = true;
                 // This means the authentication succeeded; extract the
                 // identity URL and Simple Registration data (if it was
                 // returned).
                 $openid = $response->getDisplayIdentifier();
                 Auth::loginByOpenid($openid);
                 if (!Auth::isAuth()) {
                     $success = false;
                     $msg = __('Account not found.');
                 }
             }
         }
     }
     if ($success) {
         // for openid sso
         if (OPENID_SSO_MODE) {
             if ($always_trust) {
                 setcookie('default_openid', $openid, time() + 60 * 60 * 24 * 30 * 12, HttpRequest::getPathUrl());
             }
         }
         // Authentication process succeeded.
         // FIXME: log this connection
         // Redirection in the portal.
         DefaultFC::redirection('wall/index');
         exit;
     } else {
         $_SESSION['isError'] = true;
         $_SESSION['message'] = $msg;
         DefaultFC::redirection('users/index');
         exit;
     }
 }