Jump to content

String help


marcus

Recommended Posts


Parse error: syntax error, unexpected T_STRING in /home/csblog/public_html/file.php on line 8


What I am trying to do, is to get file contents of a website and echo them off, but if a link exists i want it to also direct it to the same page

[code]
<?php
$url = $_GET['url'];
if(!isset($url)){
echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form>";
}else {
$file = file_get_contents("$url");
echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form><br><br>";
$replace = "href='."http://cs-blog.net/file.php?url=$url".'";
$file = str_replace('href="',$replace,$file);
echo $file;
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/31150-string-help/
Share on other sites

well what r u trying to do with line 8 like the href
[CODE]
<?php
$url = $_GET['url'];
if(!isset($url)){
echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form>";
}else {
$file = file_get_contents("$url");
echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form><br><br>";
$replace = "href=' . "http://cs-blog.net/file.php?url=$url" . '";
$file = str_replace('href="',$replace,$file);
echo $file;
}
?>
[/CODE]
Link to comment
https://forums.phpfreaks.com/topic/31150-string-help/#findComment-143886
Share on other sites

say, the url you typed in was like miniclip.com or something. the links there are just href="/games/gamename.php"

i want so when the person clicks that it will go to ?url=http://miniclip.com/games/gamename.php

that didnt work ken, when i went to my other site, chyea.net and tried to click contact it stayed on chyea.net not chyea.net/contact.php
Link to comment
https://forums.phpfreaks.com/topic/31150-string-help/#findComment-143903
Share on other sites

[code]

          $domain="mydomain.com";
          $myscript="something.php";
$thisurl="http://" . $domain . $script . "?url=";
$regex = "/<\s*a\s+[^>]*href\s*=\s*[\"']?([^\"' >]+)[\"' >]/isU";
preg_match_all($regex,$page,$urls);

$urlarray=array_unique($urls[1]);

foreach($urlarray AS $url){
//echo $url . " " . $newurl . "<br>";
if($url!='#' && $url!='/'){
$newurl=$thisurl . urlencode($url);
if(!strstr($url,'http://')){
        $page=str_replace($url,$newurl,$page);
}
}
}
[/code]

Is this what you want?
take all the URLs and put them on a query string?
Link to comment
https://forums.phpfreaks.com/topic/31150-string-help/#findComment-143918
Share on other sites

Um, that wouldnt work, the url is given as a get, and i'm trying to make it produce it so that links with href=" will be produced in href="http://cs-blog.net/file.php?url=$url" and if it was from chyea.net the index would just stay at chyea.net then if you clicked contact it would be href="http://cs-blog.net/file.php?url=http://chyea.net versus href="http://cs-blog.net/file.php?url=http://chyea.net/contact.php"

But on the page it comes out with: http://cs-blog.net/file.php?url= but in the source it shows http://cs-blog.net/file.php?url=$url"contact.php"

[code]
<?php
$url = $_GET['url'];
if(!isset($url)){
echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form>";
}else {
$file = file_get_contents("$url");
echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form><br><br>";
$replace = 'href="http://cs-blog.net/file.php?url=$url"';
$file = str_replace('href="',$replace,$file);
$file = str_replace('../',"",$file);
echo $file;
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/31150-string-help/#findComment-144045
Share on other sites

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.