Jump to content

[SOLVED] Run an external script after array?


Graxeon

Recommended Posts

I have this:

 

<?php
$URL = $_GET['url'];
$allowed_url = array("google.com","yahoo.com");
if(in_array($URL,$allowed_url))
{
   header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en");
}else{
   header("Location: http://www.google.com/");
}
?>

 

But I want to run it with this in a separate PHP file:

 

<?php

   header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en");

?>

 

So how can I call that second script through the first one like this:

 

<?php
$URL = $_GET['url'];
$allowed_url = array("google.com","yahoo.com");
if(in_array($URL,$allowed_url))
{
CALL 2nd PHP file from here
}else{
   header("Location: http://www.google.com/");
}
?>

 

I don't want the script to redirect to the 2nd one...I just want the second one to run after it's gone through the array check system thing.

Why?

 

Some of my other scripts don't work within the array script so I need to run it externally.

 

My team doesn't want me to share the script so that's why I have to ask in this manner :(.

 

Can you not use:

 

<?php include(filename.php); ?>

 

I'm only new to php so excuse me if I'm completely wrong :P

 

I tried this but it didn't work:

 

<?php
$URL = $_GET['url'];
$allowed_url = array("google.com","yahoo.com");
if(in_array($URL,$allowed_url))
{
include(file2.php);
}else{
   header("Location: http://www.google.com/");
}
?>

 

<?php
$URL = $_GET['url'];
$allowed_url = array("google.com","yahoo.com");
if(in_array($URL,$allowed_url))
{
header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en");
}else{
   header("Location: http://www.google.com/");
}
?>

 

 

????

 

Guessing I'm misunderstanding the problem.

include should work, did it give an error or anything?

 

Nope, just a blank page.

 

Guessing I'm misunderstanding the problem.

 

Oh...right I should explain what it's doing first.

 

Ok this script is checking to see if the inputs after "url=" are in the predefined list of "allowed" inputs:

 

<?php
$URL = $_GET['url'];
$allowed_url = array("google.com","yahoo.com");
if(in_array($URL,$allowed_url))
{
header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en");
}else{
   header("Location: http://www.google.com/");
}
?>

 

If the input is in the predefined list, then this part of the script is run:

 

header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en");

 

If the input is not in the list, then the user is redirected to "http://www.google.com"

 

Now...what I want to do is instead of having "header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en");" within the same script, I want it to be on an external file.

 

So I should have 2 PHP files, the first one would be this:

 

<?php
$URL = $_GET['url'];
$allowed_url = array("google.com","yahoo.com");
if(in_array($URL,$allowed_url))
{
CALL 2nd PHP file from here
}else{
   header("Location: http://www.google.com/");
}
?>

 

The 2nd script would be:

 

<?php
//This can be any script, btw. My team doesn't allow me to share the script that I do want to put here, sorry.
   header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en");

?>

 

That 2nd script would take whatever "allowed" input the user used in the first script and just run it through the 2nd script.

 

 

 

Does that make more sense? >.<

Since your scripts are using header statements, they shouldn't print out anything but headers, which you won't see in a browser.

 

<?php
$URL = $_GET['url'];
$allowed_url = array("google.com","yahoo.com");
if(in_array($URL,$allowed_url))
{
    require 'file2.php'; //require is the same as include, but the script throws a fatal error if the file isn't able to be included.
}else{
   header("Location: http://www.google.com/");
}
?>

 

file2.php

<?php
//This can be any script, btw. My team doesn't allow me to share the script that I do want to put here, sorry.
   header("Location: http://video.".$URL."/videorankings?type=blogged&cr=usa&hl=en");

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.