Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 38

Thread: help with javascript to php please

  1. #21
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Server's still not accessible maybe try this out assuming your JS (splashpage.js) is all set for the overlay.

    Whatever you want to call the page where the user enters the address:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="new_page_name.php"> 
    <label for="url">URL:</label> 
    <input input value="http://www." type="text" name="url" id="url" size="40"> 
    <input type="submit" name="SubmitButton" value="Submit"> 
    </form> 
    </body> 
    </html>
    new_page_name.php:

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    </head>
    <?php
    if (isset($_POST['url'])) {
    $domain $_POST['url'];
    $correct_domain "http://www.";
    $chars_allowed strlen($correct_domain);
    if (
    substr($domain0$chars_allowed)== $correct_domain) {
    ?>
    <body>
    <?php
    $requested_page 
    file_get_contents($domain);
    $requested_page str_replace("<head>""<head>\n<script type=\"text/javascript\" src=\"splashpage.js\"></script>\n"$requested_page);
    echo 
    $requested_page;
    } else {
    //Error, you can handle this however you want
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    </head>
    <body>
    <span style="color:#ff0000;">Please Enter a Valid Domain starting with <?php echo $correct_domain?>.</span>
    <form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF']?>"> 
    <label for="url">URL:</label> 
    <input input value="http://www." type="text" name="url" id="url" size="40"> 
    <input type="submit" name="SubmitButton" value="Submit"> 
    </form> 
    <?php
    }
    }
    ?>
    </body> 
    </html>
    Corrections to my coding/thoughts welcome.

  2. #22
    Join Date
    Apr 2010
    Location
    Berlin, Germany
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    What do you mean by:
    } else {
    //Error, you can handle this however you want
    -------------------------
    Im also trying to replace this javascript string:

    $requested_page = str_replace("<head>", "<head>\n<script type=\"text/javascript\" src=\"splashpage.js\"></script>\n", $requested_page);

    with "player_page.html"

    I just dont realise the correct syntax. Please give me a hint.
    Last edited by dorello; 05-06-2010 at 05:10 PM.

  3. #23
    Join Date
    Apr 2010
    Location
    Berlin, Germany
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi bluewalrus,

    your code works pretty well, there is just a problem with showing the images from the called sites. So, I mean when you write an address like google.com or whatever, the images wont show.
    Otherwise, in terms of combining two sites, works great!
    Got an idea how to? If you need a server to make tests, I can give you one.

  4. #24
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Mine should be up it's kinda pathetic that I'm paying 2 hosts and they still cant transfer my domains. Anyway you need to set the base domain to the requested domain I'd think. Then call all your pages absolutely since you have control on that...

    PHP Code:
    $requested_page str_replace("<head>""<head>\n<base href=\"$domain\" />\n<script type=\"text/javascript\" src=\"splashpage.js\"></script>\n"$requested_page); 
    Is it working other than that? I just saw your post before your most recent, if any of that is still active please repost..
    Corrections to my coding/thoughts welcome.

  5. #25
    Join Date
    Apr 2010
    Location
    Berlin, Germany
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, Ill try and replay your message. Just sent you a pm.

  6. #26
    Join Date
    Apr 2010
    Location
    Berlin, Germany
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, what I got with your pretty code:
    When using this:

    PHP Code:
    <?php
    if (isset($_POST['url'])) {
    $domain $_POST['url'];
    $correct_domain "http://www.";
    $chars_allowed strlen($correct_domain);
    if (
    substr($domain0$chars_allowed)== $correct_domain) {
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta http-equiv="refresh" content="0;url=<?php echo $domain;?>" />
    </head>


    <body>
    <?php
    $requested_page 
    file_get_contents($domain);
    $requested_page str_replace("<head>""<head>\n<script type=\"text/javascript\" src=\"splashpage.js\"></script>\n"$requested_page);
    //$requested_page = str_replace("<head>", "<head>\n<base href=\"$domain\" />\n<script type=\"text/javascript\" src=\"splashpage.js\"></script>\n", $requested_page);  
    echo $requested_page;
    } else {
    //Error, you can handle this however you want
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    </head>
    <body>
    //<span style="color:#ff0000;">Please Enter a Valid Domain starting with <?php echo $correct_domain?>.</span>
    <?php
    }
    }
    ?>
    ... I get the splashpage.js on top, except the images on the page under, are not shown.

    If I take out this part:

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta http-equiv="refresh" content="0;url=<?php echo $domain;?>" />
    </head>
    ... the page called per html shows correctly, but splashpage doesnt show on top at all.

    I am desperated:-)

  7. #27
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Is this live, could I see how it's functioning? I think the problem is dual html tags but want to double check.
    Corrections to my coding/thoughts welcome.

  8. #28
    Join Date
    Apr 2010
    Location
    Berlin, Germany
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I sent you a pm:-)

  9. #29
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Okay give this one a try...
    PHP Code:
    <?php
    if (isset($_POST['url'])) {
    $domain $_POST['url'];
    $correct_domain "http://www.";
    $chars_allowed strlen($correct_domain);
    if (
    substr($domain0$chars_allowed)== $correct_domain) {
    ?>
    <body>
    <?php
    $requested_page 
    file_get_contents($domain);
    $requested_page str_replace("<head>""<head>\n<base href=\"$domain\" />\n<script type=\"text/javascript\" src=\"splashpage.js\"></script>\n"$requested_page);  
    echo 
    $requested_page;
    } else {
    //Error, you can handle this however you want
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    </head>
    <body>
    //<span style="color:#ff0000;">Please Enter a Valid Domain starting with <?php echo $correct_domain?>.</span>
    <?php
    }
    }
    ?>
    You will need to have all of the codes on your site called absolute though with this code.
    Corrections to my coding/thoughts welcome.

  10. #30
    Join Date
    Apr 2010
    Location
    Berlin, Germany
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmm, splashpage doesnt show at all:-( although Ive changed html codes to absolute, as you said.
    I must say, I had to change allow_url_fopen to ON, in order to get this working (I mean in the previous version):

    $requested_page = file_get_contents($domain);

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •