SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cross Server scripting

    how do i embed php script from a different server on another site, I know it has to do with using the <script> tag but i am wondering if anyone here knows more, a little directing could help..........please please help.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can capture the output of a remote PHP script with file functions if your host hasn't disabled that:

    Code:
    $output = file_get_contents('http://www.example.com/script.php');
    However, you can't include() the script and have it run as if it were local. If you could explain what you're trying to do, perhaps someone can suggest a good method to accomplish it.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey man thanx for the comment, well I am trying to start something like an ad network. I want to allow people put code on their site and let ads be displayed on them...... so i need to do it with javascript like google..............I need a tutorials on how to do this, can any one point me.....

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It would work in the same way as if you were to do it on your own server. Create the PHP file which outputs as a JS file, and the other server can use:
    PHP Code:
    <script type="text/javascript" src="http://www.yoursite.com/js.php?var=val" /> 
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow theres no way you are 16. Well I didnt think it would work like that...any way are there any security issues I should be considering using the model u suggested.

    i want to do something like adsense. how do i get useragent information using javascript

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No security issues other than typical PHP ones (filtering input, etc). The PHP script is run on the remote server, to generate the Javascript.

    On that note, there isn't a need to get the useragent info in Javascript. You can get it all with PHP on js.php, and then output specific data in Javascript format with PHP.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was thinking that the php script would be able to access the server variables since it wasnt being accessed directly..........dude u really helped me with this..........cant still believe ur 16, am 22 when i was 16 I was fidling away with my playstation console.....

  8. #8
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I was thinking that the php script would be able to access the server variables since it wasnt being accessed directly
    Ah - but it is . If the browser calls a php script whether it's a page request or a javascript request, it's run on the server first.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  9. #9
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    alright thanks man!

    so I designed my application ( rember am developing an ad network like adsense ) to differiate between unique users by using $_SERVER[REMOTE_ADDRESS]. is that the best option especially in a situation where the users might be accessing from a cyber cafe.

    what other methods can i use to uniques identifief valid hits and clicks, and what are the methods that people can try to use to bypass them


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
  •