Read a text file?
Moderator: General Moderators
Test it. It does work. Click here: http://juniorfiles.t35.com/reg.php?seri ... -NH7I-J8G5
Wierd... Can you test my vb application for me to see if it works ok. http://cardiffhigh.cardiff.sch.uk/~jami ... /Login.exe I recommend you scan it for viruses first just in case. Use this key: 7JKD-F982-J894-NH7I-8KDF this password: "Yoda" and this password "anewhope".
-
SKDevelopment
- Forum Newbie
- Posts: 13
- Joined: Thu Jan 26, 2006 10:42 am
No. In your case it always goes to Google. It is because '43T7-9H2O-348Y-UVH2-80VN' and '79EU-IDJH-J09F-UAWE-HRF9' are not empty strings and always evaluated to TRUE.m0u53m4t wrote: and if the serial is right, it goes to google, if its black listed it goes to Yahoo.
I think what you meant is:
Code: Select all
$serial = $_GET["serial"];
if (($serial == '7JKD-F982-J894-NH7I-8KDF' || $serial == '43T7-9H2O-348Y-UVH2-80VN' || $serial == '79EU-IDJH-J09F-UAWE-HRF9')) { // Valid serial keys
header( 'Location: http://www.google.com' ) ;
}
else {
header( 'Location: http://www.altavista.com' ) ;
}
// Attention !!! This condition is never checked !!!
if (($serial == '7K7D-SGF7-J894-NH7I-J8G5')) { // Blacklisted serials
header( 'Location: http://www.yahoo.com' ) ;
}Edit: I see the last has been mentioned already.
--
Best Regards,
Sergey Korolev
www.SKDevelopment.com
Then why does it work? http://juniorfiles.t35.com/reg.php?seri ... -NH7I-J8G5 should take you to yahoo.
-
SKDevelopment
- Forum Newbie
- Posts: 13
- Joined: Thu Jan 26, 2006 10:42 am
I think I should add this to my previous post. I said the 2nd condition will never be checked. Formally speaking it will be checked. The PHP Parser will parse the script to the end no matter which headers have been sent to the browser already. But anyway because of the 1st condition the browser will be redirected either to Google or to Altavista. And though the 2nd "if" will be parsed by the PHP parser anyway, the redirect to Yahoo will have no effect. Just as if the 2nd "if" was not parsed at all.
-
SKDevelopment
- Forum Newbie
- Posts: 13
- Joined: Thu Jan 26, 2006 10:42 am
Very interesting. Never checked it like that. This means the 2nd "Location" header takes precedence if 2 "Location" headers are sent.m0u53m4t wrote:Then why does it work? http://juniorfiles.t35.com/reg.php?seri ... -NH7I-J8G5 should take you to yahoo.
But I think it would be better for you to corrected your script. Such behavior does not look very reliable to me.
I tried to look at it with FireFox with LiveHTTPHeaders. Only 1 "Location" header is shown in each case. I did not explore the situation any further.
Edit: Gave a wrong example. Removed it. Sorry.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Just because you send a header redirect does not mean the script will terminate at taht point. You'll notice nearly everytime anyone uses header redirect it is proceeded by an exit() call so no other code is called.m0u53m4t wrote:Then why does it work? http://juniorfiles.t35.com/reg.php?seri ... -NH7I-J8G5 should take you to yahoo.
-
SKDevelopment
- Forum Newbie
- Posts: 13
- Joined: Thu Jan 26, 2006 10:42 am
I think your script could look something like this:
Code: Select all
<?php
$serial = $_GET["serial"];
if (in_array($serial,array('7JKD-F982-J894-NH7I-8KDF','43T7-9H2O-348Y-UVH2-80VN','79EU-IDJH-J09F-UAWE-HRF9'))) { // Valid serial keys
header( 'Location: http://www.google.com' ) ;
} elseif($serial == '7K7D-SGF7-J894-NH7I-J8G5') { // Blacklisted serials
header( 'Location: http://www.yahoo.com' ) ;
} else {
header( 'Location: http://www.altavista.com' ) ;
}
?>But if, like here, I do want the rest done then isn't that ok not to call exit()?Jcart wrote:Just because you send a header redirect does not mean the script will terminate at taht point. You'll notice nearly everytime anyone uses header redirect it is proceeded by an exit() call so no other code is called.m0u53m4t wrote:Then why does it work? http://juniorfiles.t35.com/reg.php?seri ... -NH7I-J8G5 should take you to yahoo.