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

Fons Arts F.Arts at GISArts.nl
Mon Mar 17 04:25:47 EDT 2008


Hi,

I'm planning to implement authenication to. i'm using your scripts.
After i add the line,

$oApp->moAuthenticator = new Authenticator('login.html' );

to the index.phtml i got a black page and an error in my php_error.log. 

[17-Mar-2008 09:18:00] PHP Fatal error: Call to undefined method
Authenticator::isAuthenticated() in
/home/gisarts/apps/chameleon-2.2.1/htdocs/chameleon.php on line 922

Chameleon.php (line 922)
function CWCAuthenticate()
{
if ($this->moAuthenticator != null)
{
if (isset($_REQUEST['username']) && isset($_REQUEST['password']))
{
if ($this->moAuthenticator->authenticate($_REQUEST['username'],
$_REQUEST['password'] ) == false)
$this->setVar('szLoginError', $this->moMLT->get("6", 'Login Failed -
Incorrect Username and/or Password'));
}
if (!$this->moAuthenticator->isAuthenticated())
{
$this->setVar('SID', session_id());
$this->mszTemplateName = $this->moAuthenticator->mszLoginTemplate;
$this->CWCLoadTemplate($this->mszTemplateName);
}
}
}


Thanks in advance,

Fons


________________________________

Van: chameleon-bounces at lists.maptools.org
[mailto:chameleon-bounces at lists.maptools.org] Namens dominique briand
Verzonden: donderdag 29 november 2007 19:14
Aan: chameleon at lists.maptools.org
Onderwerp: [Chameleon] Re:I need help with Authenticator.php


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/20080317/8a93908c/attachment.html


More information about the Chameleon mailing list