Jump to content

header Location


SmileyWar

Recommended Posts

Hi guys, i'm having trouble with a script after MT updated the php version to PHP 5.3.10

 

The script sometimes will not work, while it did  not work i managed to eliminated the script which didnt work.

 

But after echoing parts to see what worked and what not, it starting working again. So i was not able to finish my tests.

 

I read time over time into my script and as far as i can tell i cant figure out what is causing it not to work. I assume it's the header location as it should always redirect the page in any given situation.

 

Anybody else having header location fluctuation or am i having different problems?

 

Any help would be appreciated.

 

	if ($check_voters >= '1'){
		$last = mysql_query("SELECT * FROM check_voters WHERE ip='".$ip."' ORDER BY id DESC LIMIT 1") or die(mysql_error());
		$row = mysql_fetch_array( $last ) or die(mysql_error());
		if ($row['date'] == $date){

			list($hours, $minutes) = split(':', $row['time']); 	
			$startTimestamp = (($hours * '60') + $minutes);

			list($hours, $minutes) = split(':', $time); 	
			$endTimestamp = (($hours * '60') + $minutes);

			$timeDif = ($endTimestamp - $startTimestamp);

				if ($timeDif <= '1500'){

					function encryptStringArray ($stringArray, $key = "some hashes") {
					 $s = strtr(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), serialize($stringArray), MCRYPT_MODE_CBC, md5(md5($key)))), '+/=', '-_,');
					 return $s;
					}
					$encoded = encryptStringArray($timeDif );

					$woops = $encoded.':casted';
					header('Location: page.php?woops='.$woops.'');

				}else{

			mysql_query("INSERT INTO check_voters (id, ip, date, time) VALUES ('', '".$ip."', '".$date."', '".$time."')") or die(mysql_error());

			# update visitors
			mysql_query("INSERT INTO visitors (id, category, efface, ip, browser, hostaddress, referred, country, date, time) VALUES ('', '".$catergory."', '".$q."', '".$ip."', '".$browser."', '".$hostaddress."', '".$referred."', '".$country."', '".$date."', '".$time."')") or die(mysql_error());

			$q_list = "SELECT COUNT(*) FROM list WHERE efface='".$q."'";
			$r_list = mysql_query($q_list) or die(mysql_error());
			$t_r_list = mysql_fetch_row($r_list);
			$check_list = $t_r_list[0];

				if ($check_list >= '1'){
					$a = '1';
					$check_fetch = mysql_query("SELECT * FROM list WHERE efface='".$q."'") or die(mysql_error());
					$check_row = mysql_fetch_array( $check_fetch ) or die(mysql_error());
					$new_number = ($check_row['votes'] + $a);
					mysql_query("UPDATE list SET votes='".$new_number."' WHERE efface='".$q."'");
					}else{

			mysql_query("INSERT INTO list (id, category, efface, votes) VALUES ('', '".$catergory."', '".$q."','1')");

				}
			# insert matched word into database
			mysql_query("INSERT INTO results (id, word, category, span) VALUES ('', '".$subject."', '".$category."', '".$characters."')");	

			header('Location: page.php?efface='.$subject.'');
			}


		}
	}else{

			mysql_query("INSERT INTO check_voters (id, ip, date, time) VALUES ('', '".$ip."', '".$date."', '".$time."')") or die(mysql_error());

			# update visitors
			mysql_query("INSERT INTO visitors (id, category, efface, ip, browser, hostaddress, referred, country, date, time) VALUES ('', '".$catergory."', '".$q."', '".$ip."', '".$browser."', '".$hostaddress."', '".$referred."', '".$country."', '".$date."', '".$time."')") or die(mysql_error());

			$q_list = "SELECT COUNT(*) FROM list WHERE efface='".$q."'";
			$r_list = mysql_query($q_list) or die(mysql_error());
			$t_r_list = mysql_fetch_row($r_list);
			$check_list = $t_r_list[0];

				if ($check_list >= '1'){
					$z = '1';
					$check_fetch = mysql_query("SELECT * FROM list WHERE efface='".$q."'") or die(mysql_error());
					$check_row = mysql_fetch_array( $check_fetch ) or die(mysql_error());
					$new_number = ($check_row['votes'] + $a);
					mysql_query("UPDATE list SET votes='".$new_number."' WHERE efface='".$q."'");
					}else{

					mysql_query("INSERT INTO list (id, category, efface, votes) VALUES ('', '".$catergory."', '".$q."','1')");


					}


			mysql_query("INSERT INTO results (id, word, category, span) VALUES ('', '".$subject."', '".$category."', '".$characters."')");

			header('Location: page.php?efface='.$subject.'');
			}

Link to comment
Share on other sites

Hello Barand, i have changed all the header locations with double quotations and stripped the escapes around the variables.

 

It works as it should do at the moment.

 

If this works for the future, thank you very much for your help :) (Does not mean i'm already great full of your help :D)

 

If not i'll come back with hopefully more explanation with my testing when it stops working again.

 

As of now, i'll set this topic to solved.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.