git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1207 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
100 lines
4.0 KiB
PHP
100 lines
4.0 KiB
PHP
<?php
|
|
|
|
class auth
|
|
{
|
|
/** Display the authentication page
|
|
The message is displayed to the user in case of error
|
|
The url is the caller url to go back if authentication is correct */
|
|
public function pageHTML ($message="", $url="")
|
|
{
|
|
$res = "";
|
|
$res .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"";
|
|
$res .= " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
|
|
$res .= "<html>\n";
|
|
$res .= "<head>\n";
|
|
$res .= "<title>Title</title>\n";
|
|
$res .= "<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'";
|
|
$res .= " />\n";
|
|
$res .= "<script src='public/js/jquery.min.js' type='text/javascript'>";
|
|
$res .= "</script>\n";
|
|
$res .= "<script type='text/javascript' src='public/js/bootstrap.js'>";
|
|
$res .= "</script>\n";
|
|
$res .= "<link type='text/css' rel='stylesheet' href='";
|
|
$res .= "public/css/bootstrap.css'/>\n";
|
|
$res .= " <style type='text/css'>\n";
|
|
$res .= "body { padding-top: 40px; padding-bottom: 40px;";
|
|
$res .= " background-color: #eee; }\n";
|
|
$res .= ".form-signin { max-width: 330px;padding:15px;margin:0 auto;}\n";
|
|
$res .= ".form-signin .form-signin-heading, .form-signin .checkbox {";
|
|
$res .= " margin-bottom: 10px; }\n";
|
|
$res .= ".form-signin .checkbox { font-weight: normal; }\n";
|
|
$res .= ".form-signin .form-control {";
|
|
$res .= "position: relative; font-size: 16px; height: auto;";
|
|
$res .= "padding: 10px; -webkit-box-sizing: border-box;";
|
|
$res .= "-moz-box-sizing: border-box; box-sizing: border-box; }\n";
|
|
$res .= ".form-signin .form-control:focus { z-index: 2; }\n";
|
|
$res .= ".form-signin input[type='text'] { margin-bottom: -1px;";
|
|
$res .= "border-bottom-left-radius: 0; border-bottom-right-radius: 0; }\n";
|
|
$res .= ".form-signin input[type='password'] {";
|
|
$res .= "margin-bottom: 10px; border-top-left-radius: 0;";
|
|
$res .= "border-top-right-radius: 0; }\n";
|
|
$res .= " </style>\n";
|
|
$res .= " </head>\n";
|
|
$res .= " <body>\n";
|
|
$res .= "<div class='container'>\n";
|
|
$res .= " <form class='form-signin' role='form' method='post' ";
|
|
$res .= "action='#'>\n";
|
|
$res .= " <h2 class='form-signin-heading'>"._("Please sign in");
|
|
$res .= "</h2>\n";
|
|
$res .= " <input type='text' class='form-control' name='email' ";
|
|
$res .= "placeholder='"._("Email address")."' required autofocus/>\n";
|
|
$res .= " <input type='password' class='form-control' name='password' ";
|
|
$res .= "placeholder='"._("Password")."' required/>\n";
|
|
$res .= " <label class='checkbox'>";
|
|
$res .= "<input type='checkbox' name='remember-me'/>"._("Remember me");
|
|
$res .= "</label>\n";
|
|
$res .= " <button class='btn btn-lg btn-primary btn-block' ";
|
|
$res .= "type='submit'>"._("Sign in")."</button>\n";
|
|
if ($message !== "")
|
|
$res .= "<div class='alert alert-danger'>$message</div>";
|
|
$res .= " </form>\n";
|
|
$res .= "</div>\n";
|
|
$res .= "</body>\n";
|
|
$res .= "</html>\n";
|
|
return $res;
|
|
}
|
|
|
|
/** Establish the connection to authentication server */
|
|
public function connect ()
|
|
{
|
|
throw new Exception (_("No connect to authentication available"), 405);
|
|
}
|
|
|
|
/** Check if the email and password are correct
|
|
Return TRUE if the authentication is correct
|
|
Return an exception if there is a problem */
|
|
public function authentication ($email, $password)
|
|
{
|
|
throw new exception (_("No authentication available"), 405);
|
|
}
|
|
|
|
/** Return all the parameters recorded for the authenticate user */
|
|
public function getdetails ()
|
|
{
|
|
throw new exception (_("No getdetails available"), 405);
|
|
}
|
|
|
|
/** Method to change the password */
|
|
public function changepassword ($oldpassword, $newpassword)
|
|
{
|
|
throw new exception (_("No password change available"), 405);
|
|
}
|
|
|
|
/** List all the users available in the database
|
|
Return firstname, lastname, mail, with mail is an array */
|
|
public function listusers ()
|
|
{
|
|
throw new exception (_("No List User available"), 405);
|
|
}
|
|
}
|