homepage Welcome to WebmasterWorld Guest from 54.235.16.159
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Error on php5
Bucnright




msg:3532736
 1:27 pm on Dec 21, 2007 (gmt 0)

My host just upgraded to PHP5 now the activation link no longer works. The link is sent but when it is clicked it takes you back to the registration page with errors on the page for duplicate emaill address, username and more.

I am pretty sure these are the 2 files it uses.

1

<?php

include('lib/mysql.inc');
include('lib/sessionlib.inc');
include('lib/generallib.inc');

$user_id=$_REQUEST['user_id']+0;

//check if already exsits
$select=sqlquery("SELECT * FROM `users` WHERE (`id`='".$user_id."')and(`valid`=1);");
if (sqlnumrows($select)>0)
{
header("Location: index.php?p=home");
die;
}

if($_REQUEST['type']=='1')
{
$query="UPDATE `users` SET `valid`='1' WHERE (`id`=\"".$user_id."\") LIMIT 1";
sqlquery($query);

$query="UPDATE `teams` SET `valid`='1' WHERE (`id`=\"".$_REQUEST['team_id']."\") LIMIT 1";
sqlquery($query);
}
else
{
$query="UPDATE `users` SET `valid`='1', `pending`='0' WHERE (`id`=\"".$user_id."\") LIMIT 1";
sqlquery($query);
}

$select_userinfo=sqlquery("SELECT * FROM `users` WHERE (`id`=\"".$user_id."\") LIMIT 1");
$userinfo=sqlfetchobject($select_userinfo);

//insert same info from your form into phpbb database. Only use the columns that you need.
mysql_db_query("freeroll_phpb1","INSERT INTO phpbb_users (username, user_password, user_email, user_regdate) VALUES ('".$userinfo->login."','".$userinfo->pass."','".$userinfo->email."','".mktime()."');");
$phpbb_user_id=mysql_insert_id();
mysql_db_query("freeroll_phpb1","INSERT INTO phpbb_groups (group_type, group_description, group_single_user) VALUES ('1','Personal User','1');");
$phpbb_group_id=mysql_insert_id();
mysql_db_query("freeroll_phpb1","INSERT INTO phpbb_user_group (group_id, user_id, user_pending) VALUES ('".$phpbb_group_id."','".$phpbb_user_id."','0');");

header("Location: index.php?p=home");
?>

2


<?php

include('lib/mysql.inc');
include('lib/sessionlib.inc');
include('lib/generallib.inc');
require("lib/imageresizelib.inc");

$signup_ip=$REMOTE_ADDR;
$errors=array();

//image
if ($_FILES['file']['tmp_name']!="")
{
$fis=fopen($_FILES['file']['tmp_name'],"r");
$filedata=fread($fis,filesize($_FILES['file']['tmp_name']));

ob_start();
outputResizedImage($filedata,$_FILES['file']['type'],100,75,1);
$filedata=ob_get_contents();
ob_end_clean();

$filedata=addslashes($filedata);
fclose($fis);

$query="INSERT INTO `images` (`owner_table`,`filetype`, `filedata`) VALUES ".
"(\"".teams."\",\"".$_FILES['file']['type']."\",\"".$filedata."\");";
sqlquery($query);
$image_id=sqlinsertid();
}
else $image_id=0;

//check for errors
$select=sqlquery("SELECT * FROM `users` WHERE (`login`='".$_REQUEST['login']."') LIMIT 1");
if (sqlnumrows($select)!=0)
$errors['login']="Login Name allready exists!";

if (validateLogin($_REQUEST['login'], 4)==false)
$errors['login']="Invalid Login Name!";

if (validatePass($_REQUEST['pass'], 5)==false)
$errors['pass']="Invalid Password!";

if ($_REQUEST['pass']!= $_REQUEST['repass'])
$errors['repass']="Retype Same Password!";

$select=sqlquery("SELECT * FROM `users` WHERE (`email`='".$_REQUEST['email']."') LIMIT 1");
if (sqlnumrows($select)!=0)
$errors['email']="A member is already registered with this email!";

if (validateMail($_REQUEST['email'])==false)
$errors['email']="Invalid Email Address!";

if ($_REQUEST['type']=='1')
{
$select=sqlquery("SELECT * FROM `teams` WHERE (`name`='".$_REQUEST['team_name']."') LIMIT 1");
if (sqlnumrows($select)!=0)
$errors['team']="Team Name allready exists!";

if (validateString($_REQUEST['team_name'], 1)==false)
$errors['team']="Invalid Team Name!";
}
else
{
if ($_REQUEST['team']==0) $errors['team']="Please select a team!";
}

//registration with valid data
if (count($errors)==0)
{
if ($_REQUEST['type']=='1')
{
$query="INSERT INTO `teams` (`banner`, `banner_link` , `name`) VALUES ($image_id, \"".addslashes($_REQUEST['banner_link'])."\", \"".addslashes($_REQUEST['team_name'])."\")";
sqlquery($query);
$user_id=sqlinsertid();

$team_id=sqlinsertid();

$query="INSERT INTO `users` (`type`, `team` , `login` , `pass` , `email` , `signup_ip`, `signup_time`) VALUES (\"".addslashes($_REQUEST['type'])."\", $team_id, \"".addslashes($_REQUEST['login'])."\",'".md5($_REQUEST['pass'])."' , \"".addslashes($_REQUEST['email'])."\", '".$signup_ip."', NOW())";
sqlquery($query);

$user_id=sqlinsertid();
$email_address=$_REQUEST['email'];
}
else
{
$query="INSERT INTO `users` (`type`, `team` , `login` , `pass` , `email` , `signup_ip`, `signup_time`) VALUES (\"".addslashes($_REQUEST['type'])."\", \"".addslashes($_REQUEST['team'])."\", \"".addslashes($_REQUEST['login'])."\",'".md5($_REQUEST['pass'])."' , \"".addslashes($_REQUEST['email'])."\", '".$signup_ip."', NOW())";
sqlquery($query);

$user_id=sqlinsertid();
$email_address=$_REQUEST['email'];
}

$confaddress="http://".$_SERVER['HTTP_HOST']. str_replace(basename($PHP_SELF),"activateuseraccount.php", $_SERVER['SCRIPT_NAME'])."?user_id=".$user_id."&team_id=". $team_id."&type=".$_REQUEST['type']."";

$sender= 'The Poker Forum Challenge';
$email_subject = 'Activate Your Account';
$content= "We are having an error with the activation link. To have you account
activated please send an email to admin@example.com along with your username.<br/><br/>Click the following link once to activate your account you will be added to the site and forum: <a href='".$confaddress."' target='_blank'>Activatation Link</a>";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "From: ".$sender;

@mail($email_address, $email_subject ,$content, $headers);

//Header("Location:index.php?".$sessq."&p=regconfirm");
Header("Location:index.php?p=regconfirm");
}

//return to registration with previous invalid data
else
{
//Header("Location:index.php?".$sessq."&p=register&errors=".base64_encode(serialize($errors))."&values=".base64_encode(serialize($_REQUEST))."");
Header("Location:index.php?p=register&errors=".base64_encode(serialize($errors))."&values=".base64_encode(serialize($_REQUEST))."");
}
?>

[edited by: jatar_k at 12:32 pm (utc) on Dec. 22, 2007]
[edit reason] example.com [/edit]

 

Birdman




msg:3533291
 7:28 am on Dec 22, 2007 (gmt 0)

You'll need to post the errors so we can(try to) pinpoint the problem.

Marty

[edited by: Birdman at 7:28 am (utc) on Dec. 22, 2007]

igorberger




msg:3533308
 8:53 am on Dec 22, 2007 (gmt 0)

What software package are you using that you getting the errors? Or is it a custom PHP script that you have written?

If it is a specific software like WordPress or phpBB you may need to upgrade the version to have it PHP5 compatable. Make sure if you do upgrade you will have to resinstal all mods and custom modifications, so save a complate old version to your hard drive, including the database.

If the software is not a popular platform you may need to hack it, to make it PHP5 competable.

Or, an alternative is to move to a hosting service that still runs PHP5, rent dedicated server and ask them to run PHP4 on it.

You may actually even run parallel versions on a server, PHP4 and PHP5

Please refer to [php.net...]

The biggest PITA change is how classes and object are handled.

This maybe the root of your problem.
[phpfreaks.com...]

Write and Close handlers are called after destructing objects since PHP 5.0.5. Thus destructors can use sessions but session handler can't use objects. In prior versions, they were called in the opposite order. It is possible to call session_write_close() from the destructor to solve this chicken and egg problem.

Good luck,
Igor

Bucnright




msg:3533325
 11:30 am on Dec 22, 2007 (gmt 0)

It is a custom script that was written. The error happens after using the activayion link.

It goes back to the registration page asking and ask you to Please select a team, Invalid login name, and Invalid password and Invalid Email. I also noticed when someone does try and sign up it also leaves out the person IP address in the database before the upgrade it worked fine.

[edited by: jatar_k at 12:31 pm (utc) on Dec. 22, 2007]
[edit reason] no urls thanks [/edit]

mikesmith76




msg:3533380
 3:09 pm on Dec 22, 2007 (gmt 0)

Or, an alternative is to move to a hosting service that still runs PHP5, rent dedicated server and ask them to run PHP4 on it.

Bad idea. No new versions of php4 are being released from the end of 2007, and support for security fixes is dropped mid next year. You would be running an unsupported and potentially insecure (i say potentially as after support is dropped any flaws found will be ignored).

Anyway to the original posters question. Do you have error_reporting enabled? If not enable it as it may give you an insight into any undeclared vars etc that may be causing your problem.

igorberger




msg:3533388
 3:19 pm on Dec 22, 2007 (gmt 0)

Just to correctt my typo. Or, an alternative is to move to a hosting service that still runs PHP4, rent dedicated server and ask them to run PHP4 on it.

I would recommend migration pathway case by case depending on one's needs and resources.

As Webmasters and Developers we deal with limited resources every day, and have to prioretize what is important.

If you have a custom build Website with a few thousand coding hours of development and you are not in a position to migrate to PHP5 fo what ever resons that you do not have time or financial budget to do it, what will your choice be?

Stay on PHP4 and deal with securety updates as time requires! I know people still using Windows 98 and they do not want to do Vista!

So no bad choices in Development World, only bad implementations.

mikesmith76




msg:3533893
 3:07 pm on Dec 23, 2007 (gmt 0)

I stick with my original comments. PHP5 is 3 years old now, any project of the size you are describing should already be working under php5, or should be well on the way to getting a php5 version working.

So as i said, continuing to use php4 when the end is in sight is a bad idea, imho.

igorberger




msg:3533927
 4:23 pm on Dec 23, 2007 (gmt 0)

Mike it is your show, so you do what you think works best for you and your clients.

Regards,
Igor

igorberger




msg:3533929
 4:35 pm on Dec 23, 2007 (gmt 0)

Mike just a little caveat towards the discussion.

I recently spoke to a 20 years IBM Asia Pacific main frame consultant and he told me 90 % of back office banking computing is still being done on main frames with Fortran and Coble.

If new technology is always best, why not run the bank operations on AMD X2 4800 processor with blade servers under PHP5 and MySql?

You should be consulting Bank of America and Citibank to change all their computing operations..:)

Regards,
Igor

igorberger




msg:3533930
 4:43 pm on Dec 23, 2007 (gmt 0)

Sorry Mike, I do want to continue this discussion, but I feel bad for the OP, if you interested in dissecting this whole matter from Core Hacker's prospective, which I am, can you start a new thread and name it PHP4 to PHP5 migration.

Thank you,
Igor

mikesmith76




msg:3533969
 6:55 pm on Dec 23, 2007 (gmt 0)

You've raised some valid points and i would be interested in continuing the discussion, however fair point the original poster still does not have an answer to his question.

To the original poster: did you try turning error reporting on? What were the results?

Bucnright




msg:3533986
 7:42 pm on Dec 23, 2007 (gmt 0)

It doesnt show up in the error report.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved