Hi everybody,
Please some help over here, I`m pretty new in PHP.
I have a cronrefresh php file within a website, I need this script get infornation from a URL of the site.
Part of the script where $URL variable appears is:
PHP Code:
$fdURL = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'csvURL".$_GET['fd_refresh']."'");
$URL = mysql_fetch_assoc($fdURL);
$fdtype = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'csvType".$_GET['fd_refresh']."'");
$type = mysql_fetch_assoc($fdtype);
if ($type['value'] == 'tab') {
$type = "\t";
} else {
$type = $type['value'];
}
// set row variable and open file
$row = intval($pieces[11]);
if ($URL['title'] == 'Upload ') {
$handle = fopen('../'.$URL['value'], "r");
} else {
$handle = fopen($URL['value'], "r");
But I want to restrict public access to that URL setting up an user and password to access $URL.
I`ve seen fopen documentation and to do this with fopen is needed to embed the user and password like this
PHP Code:
$handle = fopen('http://username:password@www.example.com/myfolder','r');
but if the URL is stored in the variable $URL I`m not sure how to modify this part of the script in order to don`t affect the rest of the script.
It could be something like this?:
Instead of:
PHP Code:
$handle = fopen('../'.$URL['value'], "r");
} else {
$handle = fopen($URL['value'], "r");
this
PHP Code:
$handle = fopen('../'.username:password@$URL['value'], "r");
} else {
$handle = fopen(username:password@$URL['value'], "r");
or
Instead of:
PHP Code:
$URL = mysql_fetch_assoc($fdURL);
This
PHP Code:
$URL = username:password@mysql_fetch_assoc($fdURL);
Thanks in advance for any help.