functions.php

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
Lowepepsi2004
Registered User
Posts: 5
Joined: Tue Dec 30, 2014 11:44 am

functions.php

Post by Lowepepsi2004 »

Iv just recently updated my forum on my site to 3.1.2 from 3.0.1.The forum seems to be fine and I can login and out of, but its the members page with a login script seems to be the issue because it used the function.php within the forum, and it seemed the update of functions.php has stop my login script from working. I used the forums usernames and password to access a members area on the site by creating a script see below. is they a line I need to add or remove to make this work again?????

Code: Select all

<?php

//ob
ob_start();

//session
session_start();

if (isset($_SESSION['username']))
{
header("Location: main.php");
exit();
}

//connect
$error = 'Could Not Connect To The Database';
mysql_connect('SITE.mysql','DATABASE NAME','DATABASE PASSWORD') or die ($error);
mysql_select_db('DATABASE NAME') or die ($error);	

//include functions.php phpbb script
require 'forum/includes/functions.php';

if ($_POST{'login'})
{
//get form data
$username = addslashes(strip_tags(strtolower($_POST['username'])));
$password = addslashes(strip_tags($_POST['password']));

if (!$username||!$password)
	echo "Please Enter A Username And Password<p />";
else
{
//find username
$find = mysql_query("SELECT * FROM phpbb_users WHERE username_clean='$username'");
if  (mysql_num_rows($find)==0)
	echo "Username Not Found<p />";
else
 {
 while ($find_row = mysql_fetch_assoc($find))
 {
// grab passsord hash for user
$password_hash = $find_row['user_password'];
  }
  
  $check = phpbb_check_hash($password, $password_hash);
  if ($check==FALSE)
	echo "Incorrect Password";
  else if ($check==TRUE)
  {
   $_SESSION['username']=$username;
   header('Location: main.php');
   exit();
  }
  
  
 }
}



}
Last edited by darcie on Tue Dec 30, 2014 5:36 pm, edited 2 times in total.
Reason: moved to Extension Writers Discussion, code tags added
User avatar
M.Gaetan89
Registered User
Posts: 39
Joined: Sun Apr 21, 2013 12:36 pm
Location: Divonne-les-Bains
Name: Gaëtan
Contact:

Re: functions.php

Post by M.Gaetan89 »

The function phpbb_check_hash() is in forum/includes/functions_compatibility.php now.
If you posted your full script, you don't need to include forum/includes/functions.php anymore.
Lowepepsi2004
Registered User
Posts: 5
Joined: Tue Dec 30, 2014 11:44 am

Re: functions.php

Post by Lowepepsi2004 »

//include functions_compatibility.php phpbb script
require 'forum/includes/functions_compatibility.php'; still doesn't work :-( see www.eastriding4x4club.co.uk/members.php
User avatar
M.Gaetan89
Registered User
Posts: 39
Joined: Sun Apr 21, 2013 12:36 pm
Location: Divonne-les-Bains
Name: Gaëtan
Contact:

Re: functions.php

Post by M.Gaetan89 »

I just noticed that if ($_POST{'login'}) should be if ($_POST['login']).
Do you have any error showing up?
Lowepepsi2004
Registered User
Posts: 5
Joined: Tue Dec 30, 2014 11:44 am

Re: functions.php

Post by Lowepepsi2004 »

I get no errors, see http://www.eastriding4x4club.co.uk/members.php just a blank screen were the login field should be, iv been playing all day with different ideas. The php script did work before I updated the forum to the most recent and updated the php on the web sever to 5.6. I have edited the script to include both comments but still wont work.

Code: Select all

<?php

//ob
ob_start();

//session
session_start();
?>
<?php
if (isset($_SESSION['username']))
{
header("Location: main.php");
exit();
}

//connect
$error = 'Could Not Connect To The Database';
mysql_connect('**********************','********************','*************************') or die ($error);
mysql_select_db('***************') or die ($error);   

//include functions.php phpbb script
require 'forum/includes/functions_compatibility.php';

if ($_POST['login'])
{
//get form data
$username = addslashes(strip_tags(strtolower($_POST['username'])));
$password = addslashes(strip_tags($_POST['password']));

if (!$username||!$password)
   echo "Please Enter A Username And Password<p />";
else
{
//find username
$find = mysql_query("SELECT * FROM phpbb_users WHERE username_clean='$username'");
if  (mysql_num_rows($find)==0)
   echo "Username Not Found<p />";
else
 {
 while ($find_row = mysql_fetch_assoc($find))
 {
// grab passsord hash for user
$password_hash = $find_row['user_password'];
  }
  
  $check = phpbb_check_hash($password, $password_hash);
  if ($check==FALSE)
   echo "Incorrect Password";
  else if ($check==TRUE)
  {
   $_SESSION['username']=$username;
   header('Location: main.php');
   exit();
  }
  
  
 }
}



}
?>
Last edited by Paul on Sat Jan 03, 2015 7:26 pm, edited 1 time in total.
Reason: Added code tags
Lowepepsi2004
Registered User
Posts: 5
Joined: Tue Dec 30, 2014 11:44 am

Re: functions.php

Post by Lowepepsi2004 »

iv giving up, iv restored the old forum 3.0.12 and the database and the site is running fine. If you want me to upload any files and try for yourselfs let me know. Thanks for all your help and one day we will crack it.
millzee
Registered User
Posts: 21
Joined: Tue Oct 28, 2014 1:57 pm

Re: functions.php

Post by millzee »

i'm doing the same, functions_compatibility.php just doesn't work. Maybe one day in the future it will be sorted but for the amount of hassle and time i've wasted trying to diagnose errors caused for something that already works isn't really worth it.

maybe 3.0.12 to 3.1.12 will be the way forward for me.
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 28654
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: functions.php

Post by Paul »

You will need to tell what won't work. Did you include all required files? You can't just include functions_compatibility.php
Lowepepsi2004
Registered User
Posts: 5
Joined: Tue Dec 30, 2014 11:44 am

Re: functions.php

Post by Lowepepsi2004 »

What other links do I need to include??
Post Reply

Return to “Extension Writers Discussion”