How can I configure smarty and 'Auth/HTTP.php' in php

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How can I configure smarty and 'Auth/HTTP.php' in php

Postby loooooooper » 02. March 2011 10:31

I have been all over the net trying to find a solution to this error;
Warning: require_once(Auth/HTTP.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\OReilly\login.php on line 10

Fatal error: require_once() [function.require]: Failed opening required 'Auth/HTTP.php' (include_path='.;C:\xampp\smarty\libs') in C:\xampp\htdocs\OReilly\login.php on line 10

Am having trouble using PEAR packages with smarty. Everything was working fine with pear and its packages. However, when i installed smarty for my templates, i started getting errors in my scripts like 'headers already send by [path]....'.

Is there a way to make smarty and PEAR packages work together. I managed to configure the 'php.ini' file so that my templates in smarty load in the browser.
Here's my code;
Code: Select all
<?php
   #Auth_HTTP returns additional information about the user
   //include login details
   require_once('db_login.php');
   
   //include header templates page
   require_once('config.php');
   
   //include authentication page
   require_once("Auth.php");
   
   // We use the same connection string as the pear DB functions
   $AuthOptions = array(
                     'dsn' =>"mysql://$db_username:$db_password@$db_hostname/$db_database",
                     'table' => "users",//table name
                     'uernamecol' => "username", //table username column
                     'password' => "password", //table password column
                     'crypttype' => "md5", //password encryption type in db
                     'db_fields' =>"*" //enabling fetch for other db columns
                  );
   $authenticate = new Auth_HTTP("DB", $AuthOptions);
   
   // set the realm name
   $authenticate->setRealm('Member Area');
   
   // authentication failed error message
   $authenticate->setCancelText('<h2>Access Denied</h2>');
   
   // request authentication
   $authenticate->start( );

   // compare username and password to stored values
   if ($authenticate->getAuth( ))
      {
         session_start( );
         $smarty->assign('blog_title',$blog_title);
         $smarty->display('header.tpl');

         //setup session variable
         $_SESSION['username'] = $authenticate->username;
         $_SESSION['first_name'] = $authenticate->getAuthData('first_name');
         $_SESSION['last_name'] = $authenticate->getAuthData('last_name');
         $_SESSION['user_id'] = $authenticate->getAuthData('user_id');
         echo "Login successful. Great to see you ";
         echo $authenticate->getAuthData('first_name');
         echo " ";
         echo $authenticate->getAuthData('last_name').".<br />";
         $smarty->display('footer.tpl');
      }   
?>

Help pliz :?
User avatar
loooooooper
 
Posts: 3
Joined: 02. March 2011 08:41
Location: Kamplala, Uganda

Re: How can I configure smarty and 'Auth/HTTP.php' in php

Postby glitzi85 » 04. March 2011 20:52

Check the file C:\xampp\htdocs\OReilly\login.php, there should be an require_once instruction on line 10. This instruction is wrong (It is pointing to the file C:\xampp\htdocs\OReilly\Auth\HTTP.php which does not exist). The headers already sent messages are ok, the are produced because of the previous error messages. They should go away if you if you solve this error.

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: How can I configure smarty and 'Auth/HTTP.php' in php

Postby loooooooper » 07. March 2011 10:44

I cleared my cache and put my files in another directory to 'C:/xampp/htdocs/OReilly/Pear/blog/login' away from the 'Auth/http', I rebooted xampp.The path to the PEAR directory doesn't seem to be recognized in 'php.ini' cause am getting the following error message now;

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\Smarty\libs\Smarty.class.php:358) in C:\xampp\php\PEAR\Auth\HTTP.php on line 455

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\Smarty\libs\Smarty.class.php:358) in C:\xampp\php\PEAR\Auth\HTTP.php on line 456

What does this message mean? and what do i need to do.
User avatar
loooooooper
 
Posts: 3
Joined: 02. March 2011 08:41
Location: Kamplala, Uganda

Re: How can I configure smarty and 'Auth/HTTP.php' in php

Postby glitzi85 » 07. March 2011 10:57

Do you have any whitespace or HTML (easier: any non-php code) above the posted code?
The Auth-Function is sending out an HTTP Header to start the authentication. You are not allowed to send any output before all headers are sent, otherwise you will get this messages!

glitzi

Edit: Or any Smarty-Functions which produce output.
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: How can I configure smarty and 'Auth/HTTP.php' in php

Postby loooooooper » 07. March 2011 14:03

I 've double checked for white spaces(there not there) and am not using HTML, am all php. However, i 've my smarty template called config.php file which dispalys my header before the Auth/HTTP file.Is it wrong for me to include it in my login file before the authentication. here it is; config.php
Code: Select all
<?php
   // put full path to Smarty.class.php
   require('c:\xampp\smarty\libs\Smarty.class.php');
   
   $smarty = new Smarty();

   $smarty->template_dir = 'C:/xampp/htdocs/Smarty/templates';
   $smarty->config_dir = 'C:/xampp/htdocs/Smarty/configs';
   $smarty->cache_dir = 'C:/xampp/Smarty/cache';
   $smarty->compile_dir = 'C:/xampp/Smarty/templates_c';

   $smarty->assign('blog_title','Coffee Talk Blog');
   $smarty->assign('index','Developer Programme');
   $smarty->assign('loop','Enter into Forums');
   $smarty->display('header.tpl');
   $smarty->display('footer.tpl');
?>


This code comes first before the 'Auth/HTTP.php' file. where should i place it?
User avatar
loooooooper
 
Posts: 3
Joined: 02. March 2011 08:41
Location: Kamplala, Uganda

Re: How can I configure smarty and 'Auth/HTTP.php' in php

Postby glitzi85 » 08. March 2011 13:48

The authentication method must be used before ANY output is triggered. This includes HTML, whitespace and therefore also Smarty-Generated output. As you use HTTP Authentication you do not have any output from the Auth-Module so it can be called at the beginning without any problems. If you would use forms based authentication you would have to use output buffering to get the output to the correct place.

glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 53 guests