Ad Perl Code?

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by PSP-Heaven, May 25, 2006.

  1. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    Is there a xAdvance ad code in Perl? SO I can stick the ad in my forum?:hsughwigg
     
  2. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    Sorry for it, but please, I need someone to help me! I will donate 100 points to the person who gives me the xAdvance ad code in perl.
     
    Last edited: May 25, 2006
  3. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    I'm no expert on YABB, but Perl -> PHP shouldn't be that hard... I'm not sure how well this will work, but it's worth giving it a try:

    Code:
    use PHP::Interpreter;
    
    my $p = PHP::Interpreter->new();
    $p->include("http://staff.x10hosting.com/adCode.php?ad=advanced"); 
    
    Put that in your forum footer document and it should display the ad code.

    P.S. Put the ad code on your site's splash page. It's not there, and you'll get suspended for it too.
     
  4. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    Oh, maybe that's why I got suspended. Damnit, thats my index page, no wonder! :( Thanks for reminding me!
    Thanks for telling me that, the code doesnt work, but Ill give you 50 points for saving my butt. It may not be much, but its something.
     
    Last edited: May 25, 2006
  5. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    Sorry the Perl code didn't work. Were there any error messages? Maybe it worked, it just wasn't displaying correctly. EDIT: It looks like the code worked. I can see it on your Forum.

    By the way, I took a look at your site and saw your Arcade. I know you were discouraged about having to put the ad code on all the pages in the arcade, and I think I have a solution for you. Create a function in Javascript to open a new window which will contain the game as well as the adcode dynamically. Could be pretty simple really, call the Javascript function with the parameter of which game to display, then have it output a PHP page which receives the game name in the URL and includes the game file and the ad code. That way, you would only have to have 1 PHP page with the ad code which would include the game files dynamically.
     
    Last edited: May 25, 2006
  6. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    No i didnt know there was a javascript version.
    The tick based game, should be Shadow of Light, has 104 PHP pages. Ill try what you said. I donated 50 points, if you dont know, for telling me about the index page, and if this works, expect another 100 points! By the way, do you like how my site looks?

    EDIT: Do you have ANY idea on HOW to create a function? Im not that advanced in JavaScript.
     
    Last edited: May 25, 2006
  7. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    Put this code in the <head> of your site.
    Code:
    <script>
    function newWindow(targetGame)
    {
      newWindow = window.open ('http://www.yourdomain.com/path/to/somefile.php?gamename=' + targetGame,
      'newWindow', 'width=400, height=400, scrollbars=no, resizable=no, toolbar=no');
    }
    </script>
    
    Then call the function with a normal anchor.

    Code:
    <a href="javascript:newWindow('abc')">Open a new window with the ABC game</a>
    
     
    Last edited: May 25, 2006
  8. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    The head of my arcade PHP game? Or my Main Website?
    Also, does this solve the problem of manually editing all my PHP files in my Shadow of Light game? It has 104 files, so this will display the ad code in each of them?
     
    Last edited: May 25, 2006
  9. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    Insert it in the <head> of your site so that it is included in the Arcade page where all the links are to the games.
     
  10. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    Okay, but does this solve the ad code problem? Thanks.
    Okay, I did it, I see it makes my games pop-up now! Its awesome! But I still need something to help with the adcode. Maybe like a function kindof like this:

    function adcodesol {
    add <? adcode code here ?> to pages <index.php, items.php, etc.>
    }
    end

    Something like that, it inserts the adcode automatically into all those pages.

    EDIT AGAIN: Also, is there a way, you can make the function autosize the window to fit all the content?
     
    Last edited: May 25, 2006
  11. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    If your somefile.php is a PHP script which outputs the game file, then you can also use it to display the ads.

    Code:
    <?php
    // Get the game passed from the Javascript link
    if(isset($_GET['targetgame']))
      $game = $_GET['targetgame'];
    else
      $game = "";
    
    // Display the game we want depending on the name passed.
    if($game == "abc") {
      include("/path/to/abc/game/file");
    }
    else if($game == "xyz") {
      include("/path/to/xyz/game/file");
    }
    else {
      echo "Sorry, that game wasn't found.";
    }
    
    // Display the ad code.
    include("http://staff.x10hosting.com/adCode.php?ad=advanced");
    ?>
    What that script will do is retrieve the game file and display it, then display the ad code below it.
     
  12. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    Okay, about this javascript:newWindow function, found an error, when i click a link for the first time on the page, it works fine, opening in a window of itself. But if I close it, then try a different link, or even the same one, it will not open a new window, nothing happens. Try it yourself. Only two game links working under this method at this time, they are RealInvaders and Breakout. http://www.teamxl.x10hosting.com/arcade.php

    Oh yeah, and also, the php code above is cool and all, but I dont know how to call it? How? <a href="abc">?
     
    Last edited: May 25, 2006
  13. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    Ok, I'm gonna walk you through this because you obviously don't know much Javascript or PHP...

    You're right, the Javascript above is wrong; it should be this:

    Code:
    <script>
    function newWindow(targetGame)
    {
      window.open ('http://www.teamxl.x10hosting.com/arcade/loadgame.php?gamename=' + targetGame,
      'newWindow', 'width=400, height=400, scrollbars=no, resizable=no, toolbar=no');
    }
    </script>
    
    Put that in the head of your site in place of the other code. Next create a PHP file called loadgame.php in your arcade directory. loadgame.php will have this in it:

    Code:
    <html>
    <head><title>Arcade</title></head>
    <body>
    <?php
    // Get the game passed from the Javascript link
    if(isset($_GET['targetgame']))
      $game = $_GET['targetgame'];
    else
      $game = "";
    
    // Display the game we want depending on the name passed.
    if($game == "realinvaders") {
      include("ri/ri.php");
    }
    else if($game == "jbreakout") {
      include("jbreakout/JBreakout.php");
    }
    // Finish the rest of the games in your arcade using the same format
    else {
      echo "Sorry, that game wasn't found.";
    }
    
    // Display the ad code.
    include("http://staff.x10hosting.com/adCode.php?ad=advanced");
    ?>
    </body>
    </html>
    
    Then in your Arcade page on your main site, change the links to this:
    Code:
    <a href="javascript:newWindow('realinvaders')">RealInvaders</a>
    <a href="javascript:newWindow('jbreakout')">Java Breakout</a>
    <!--  Finish the rest of the games using the same format.  Note, the name passed to the javascript newWindow function must be the same as the name of a game in the loadgame.php page-->
    
    Notice that
    Code:
    javascript:newWindow('realinvaders')
    
    Triggers this PHP statement:
    
    if($game == "realinvaders") {
      include("ri/ri.php");
    }
    
    The game to be displayed is passed like this:

    GameName entered into A link -> Javascript appends to the end of the loadgame.php url -> loadgame.php parses out the game name from the url -> The if-else statements determine which game to display based on what GameName was in the A link.
     
  14. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    Thank you, and yes, sadly I dont know much JavaScript, and barely anything in PHP, but your explanation makes perfect sense, thank you! I will try it now!

    EVEN though it was easy to understand, I keep on getting this error in the pop-up window:

    HTTP 404 - Page Not Found
    The file you are looking for cannot be found.

    File: /arcade/loadgame.php?gamename=realinvaders
    IP Address: 65.2.38.105
     
    Last edited: May 25, 2006
  15. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    It's looking for the loadgame.php in the Arcade folder. You don't have one, so take it out of the path like so:
    Code:
    <script>
    function newWindow(targetGame)
    {
      window.open ('http://www.teamxl.x10hosting.com/loadgame.php?gamename=' + targetGame,
      'newWindow', 'width=400, height=400, scrollbars=no, resizable=no, toolbar=no');
    }
    </script>
    
    Also change the PHP script to point to the correct directories which the games are installed in...
    Code:
    f($game == "realinvaders") {
      include("http://www.teamxl.x10hosting.com/arcade/ri/ri.php");
    }
     
    Last edited: May 25, 2006
  16. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    Last edited: May 25, 2006
  17. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    I still need help, the_magistrate, I set it up exactly how you told me, yet nothing. Check here: www.teamxl.biz/arcade.php
     
  18. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    Post the loadgame.php here so I can see what's wrong.
     
  19. PSP-Heaven

    PSP-Heaven New Member

    Messages:
    428
    Likes Received:
    0
    Trophy Points:
    0
    <html>
    <head><title>Arcade</title></head>
    <body>
    <?php
    // Get the game passed from the Javascript link
    if(isset($_GET['targetgame']))
    $game = $_GET['targetgame'];
    else
    $game = "";

    // Display the game we want depending on the name passed.
    if($game == "realinvaders") {
    include("http://www.teamxl.biz/arcade/ri/ri.php");
    }
    else if($game == "jbreakout") {
    include("http://www.teamxl.biz/arcade/jbreakout/JBreakout.php");
    }
    else if($game == "xraye") {
    include("http://www.teamxl.biz/arcade/xr/xraye.php");
    }
    else if($game == "spaceescape") {
    include("http://www.teamxl.biz/arcade/se/spaceescape.php");
    }
    else if($game == "gyroball") {
    include("http://www.teamxl.biz/arcade/gb/gyroball.php");
    }
    else if($game == "crimsonviper") {
    include("http://www.teamxl.biz/arcade/cv/crimsonviper.php");
    }
    else if($game == "j-rio") {
    include("http://www.teamxl.biz/arcade/j-rio/jrio.php");
    }
    else if($game == "shadowoflight") {
    include("http://www.teamxl.biz/arcade/sol/index.php");
    }
    // Finish the rest of the games in your arcade using the same format
    else {
    echo "Sorry, that game wasn't found.";
    }

    // Display the ad code.
    include("http://staff.x10hosting.com/adCode.php?ad=advanced");
    ?>
    </body>
    </html>
     
  20. The_Magistrate

    The_Magistrate New Member

    Messages:
    1,118
    Likes Received:
    0
    Trophy Points:
    0
    Change this:

    Code:
    // Get the game passed from the Javascript link
    if(isset($_GET['targetgame']))
    $game = $_GET['targetgame'];
    else
    $game = "";
    
    to this:

    Code:
    // Get the game passed from the Javascript link
    if(isset($_GET['gamename']))
    $game = $_GET['gamename'];
    else
    $game = "";
    
     

Share This Page