[Chameleon] Re:I need help with Authenticator.php

dominique briand dominiquebriand at gmail.com
Thu Nov 29 13:14:24 EST 2007


hello,
I implemented en authentication with Authenticator.php, I use a postgres
database to register users and passwords,
here are the modified scripts:

login.html

<html>
<head>
<title>*****</title>
<link href="samplelogin.css" rel="stylesheet" type="text/css">
</head>
<body>
<form method="POST">
<input type='hidden' name='sid' value='[$SID$]'>

<div id="conteneur" name="conteneur">
<div id="TitleLayer" name="TitleLayer">
<br><b><u><center><FONT SIZE="+1">Please authenticate to
access*****</center></u></br>
</div>

<div id="IconLayer">
<IMG SRC="./logo1.jpg" align = middle >
</div>

<div id="InboxLayer" name="InboxLayer">
<TABLE>
<TR><TD>User :</TD><TD><input type="text" name="username"
value=""></TD></TR>
<TR><TD>Password : </TD><TD><input type="password" name="password"
value=""></TD></TR>
<TR><TD><input type="submit" name="submit" value="submit"></TD><TD><a href="
help.html" target="_blank">?</TD></TR>
</TABLE>
</div>
</div>

</form>
</body>
</html>


index.phtml


<?php
/*
 *
 */
include( "../../htdocs/chameleon.php" );

$szTemplate = "./template.html";
$szMapFile = "../map/chameleon.map";

class SampleApp extends Chameleon
{
    function SampleApp()
    {
        parent::Chameleon();
        $this->moMapSession = new MapSession_RW;
        $this->moMapSession->setTempDir( getSessionSavePath());
    }
}
//creation d'une nouvelle session
$oApp =  new SampleApp();
//appel pour l'authetification
$oApp->moAuthenticator = new Authenticator('login.html' );
//renseignement des chemins pour les fichiers importants
$oApp->registerSkin( 'skins/sample' );
$oApp->CWCInitialize( $szTemplate, $szMapFile  );
//acceptation des widgets ayant un niveau de maturité alpha (developpement)
$oApp->mnMinimumMaturityLevel = MATURITY_ALPHA;
$oApp->CWCExecute();
?>


in the file Authenticator.php :

function Authenticator($szLoginTemplate) {
        $this->mszLoginTemplate = $szLoginTemplate;
    }

    function authenticate( $user, $password )
    {
        $_SESSION['CWCAuthentication'] = false;

    $user="'$user'";
    $password="'$password'";

    $_SESSION['user'] = $user;

    //echo $user."</br>";
    //echo $password."</br>";

    $conn = pg_connect("host=** port=** dbname=** user=** password=***");

    if (!$conn) {
          return "Autentification error occured.\n";
          exit;
    }

    $result = pg_query($conn, "SELECT *** FROM *** where (****=$user and
****=$password)");


    $nb_resultat = pg_num_rows($result);

//echo $nb_resultat."</br>";


        if ($nb_resultat==1)
    {

        $_SESSION['CWCAuthentication'] = true;


    }

         else {$_SESSION['CWCAuthentication'] = false;}


       return $_SESSION['CWCAuthentication'];
   }


cheers
dominique

> ----------------------------------------------------------
>
> Message: 1
> Date: Wed, 28 Nov 2007 12:03:53 -0800 (PST)
> From: Minerva Duran Martinez <mine_tod at yahoo.com.mx>
> Subject: [Chameleon] I need help with Authenticator.php
> To: chameleon at lists.maptools.org
> Message-ID: <554011.93015.qm at web34413.mail.mud.yahoo.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi
>
> I need help,
> Someone Authenticator.php  implemented in their applications chameleon,
> because I want to implement but I don't know as.
>
> Regards,
>
> Minerva
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/chameleon/attachments/20071129/8c80a3ae/attachment.html


More information about the Chameleon mailing list