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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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