Hi everyone / anyone, it’s been many years since i plucked around in PHP scripts so i am a bit out of the loop and could use some help.
I have an old directory script, the developers website no longer exists hence i can’t ask them anymore.
The script parses an URL form input, i believe with this string/s
[php]function ParseURL($url) {
$url = trim($url);
//if (strpos($url, '.')<1) { return false; }
// check if empty
$len = strlen($url);
if ($len<3) { return false; }
if (strcmp("http://", substr($url, 0, 7)) !== 0) {
$url = "http://" . $url;
}
$url_stuff = parse_url($url);
if (!isset($url_stuff["path"])) { $url = $url . "/"; }
return $url;
}[/php]
This is inside a PHP file folder called “php4_classes” and once more in a folder called “php5_classes”.
I believe i can just add the https://
somewhere within here
[php]if (strcmp(“http://”, substr($url, 0, 7)) !== 0) {
$url = “http://” . $url;
}[/php]
BUT HOW CORRECTLY??
In addition, with the same file, i find the http:// mentioned once more within a
function GetHTML"
as
[php] if (strpos($nueva,“http://”)=== FALSE) {
$nueva = “http://” . $urlc . $nueva;
}
[/php]and a bit further down in
“function GetAllHTML”
i find
[php]$header = "GET " . $url_stuff[‘path’] . “?” . $url_stuff[‘query’] ;
$header = $header . " HTTP/1.1\r\nHost: " . $url_stuff[‘host’] . “\r\n\r\n”; "
[/php]
The last one i probably do not need to change or add anything in terms of being able to also add https websites to the directory, but the second one above may need the same add-in of a https recognition??
Hope someone knows how this probably simple solution??