Remote Files
RJM Programming - March, 2023
";
$uval="";
$tval="";
$oval="1";
$blurb="";
$pblurb="";
$cfor="For ";
$title="";
$pregt="@\(.*)\@i";
$matcho=1;
$curo=0;
if (isset($_POST['url']) && $_POST['url'] != '') {
$file = fopen ("http:" . str_replace("http:","",str_replace("https:","",str_replace("+"," ",urldecode($_POST['url'])))), "r");
$pblurb="Looking in " . str_replace("+"," ",urldecode($_POST['url'])) . " ";
$uval=str_replace("+"," ",urldecode($_POST['url']));
$cfor="for ";
} else if (isset($_GET['url']) && $_GET['url'] != '') {
$file = fopen ("http:" . str_replace("http:","",str_replace("https:","",str_replace("+"," ",urldecode($_GET['url'])))), "r");
$pblurb="Looking in " . str_replace("+"," ",urldecode($_GET['url'])) . " ";
$uval=str_replace("+"," ",urldecode($_GET['url']));
$cfor="for ";
} else {
$file = fopen ("http://www.rjmprogramming.com.au/index.php", "r");
$cfor="Looking in " . "http://www.rjmprogramming.com.au/index.php" . " for ";
}
if (isset($_POST['type']) && $_POST['type'] != '') {
$pregt="@\\<" . str_replace("+"," ",urldecode($_POST['type'])) . "\\>(.*)\\" . str_replace("+"," ",urldecode($_POST['type'])) . "\\>@i";
$pregt="@\\>(.*)\\" . str_replace("+"," ",urldecode($_POST['type'])) . "\\>@i";
$tval=str_replace("+"," ",urldecode($_POST['type']));
$pblurb.=$cfor . str_replace("+"," ",urldecode($_GET['type'])) . " element ";
$cfor=" ";
} else if (isset($_GET['type']) && $_GET['type'] != '') {
$pregt="@\\<" . str_replace("+"," ",urldecode($_GET['type'])) . "\\>(.*)\\" . str_replace("+"," ",urldecode($_GET['type'])) . "\\>@i";
$pregt="@\\>(.*)\\" . str_replace("+"," ",urldecode($_GET['type'])) . "\\>@i";
$tval=str_replace("+"," ",urldecode($_GET['type']));
$pblurb.=$cfor . str_replace("+"," ",urldecode($_GET['type'])) . " element ";
$cfor=" ";
} else {
$pregt="@\(.*)\@i";
$cfor.="title " . " element ";
}
if (isset($_POST['ord']) && $_POST['ord'] != '') {
$matcho=intval(str_replace("+"," ",urldecode($_POST['ord'])));
$oval="$matcho";
$pblurb.=$cfor . "number " . $matcho . " ...
";
} else if (isset($_GET['ord']) && $_GET['ord'] != '') {
$matcho=intval(str_replace("+"," ",urldecode($_GET['ord'])));
$oval="$matcho";
$pblurb.=$cfor . "number " . $matcho . " ...
";
} else {
$matcho=1;
$cfor.="number " . $matcho . " ...
";
}
if (!$file) {
echo "Unable to open remote file.\n";
exit;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
/* This only works if the title and its tags are on one line */
if (preg_match ($pregt, $line, $out)) {
$title = $out[1];
$curo++;
if ($curo >= $matcho) { $blurb="$pblurb"; break; }
}
}
fclose($file);
$postblurb="
";
echo "Remote Files - RJM Programming - March, 2023${preblurb}${blurb}${title}
${postblurb}";
exit;
?>