Javascript in php proxified page

Discussion in 'PHP' started by dkin69, Jun 17, 2007.

  1. #1
    Im trying to enter an ad code onto a proxified page, have been working on it for about 3 hours and cant seem to get it, any help is appreciated.

    Here is the code

    <script language='javascript' type="text/javascript">
    <!--
    if (!document.phpAds_used) document.phpAds_used = ',';
    phpAds_random = new String (Math.random());
    phpAds_random = phpAds_random.substring(2,11);

    document.write ("<" + "script language='javascript' type='text/javascript' src='");
    document.write ("http://www.claxonmedia.com/adserve_rot.php?n=" + phpAds_random);
    document.write ("&invoke=js");
    document.write ("&type=banner");
    document.write ("&aff=");
    document.write ("&exclude=" + document.phpAds_used);
    if (document.referer)
    document.write ("&referer=" + escape(document.referer));
    document.write ("'><" + "/script>");
    //-->
    </script><noscript><a
    href='http://www.claxonmedia.com/adclick.php?n=6034c6'><img
    src='http://www.claxonmedia.com/adserve_rot.php?n=6034c6&type=banner&aff='
    border='0' alt=''></a></noscript>

    Anyone know how I can echo that so it actually displays???

    Thanks all

    Dylan
     
    dkin69, Jun 17, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    It uses document.write() so it will echo the contents exactly where you put the script. Just put it somewhere in the <body> tag (assuming you already know how to edit the HTML of the proxified page)
     
    krt, Jun 17, 2007 IP
  3. dkin69

    dkin69 Active Member

    Messages:
    644
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I know where to put it, but I must be entering it wrong, I dont have much experience with javascript, Im a php guy, this is what I have entered.

            
    $_url_form      = '<div style="width:100%;margin:0;text-align:center;border-bottom:1px solid #725554;color:#000000;background-color:#F2FDF3;font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans,arial,sans-serif;padding:4px;">'
                            . '<form method="post" action="' . $_script_url . '">'
                            . ' <label for="____' . $_config['url_var_name'] . '"><a href="' . $_url . '">Address</a>:</label> <input id="____' . $_config['url_var_name'] . '" type="text" size="80" name="' . $_config['url_var_name'] . '" value="' . $_url . '" />'
                            . ' <input type="submit" name="go" value="Go" />'
                            . ' [go: <a href="' . $_script_url . '?' . $_config['url_var_name'] . '=' . encode_url($_url_parts['prev_dir']) .' ">up one dir</a>, <a href="' . $_script_base . '">main page</a>]'
                            . '<br>'
                            . '<script language=\'javascript\' type="text/javascript">'
                            . '<!--'
                            . '   if (!document.phpAds_used) document.phpAds_used = \',\';'
                            . '   phpAds_random = new String (Math.random());'
                            . '   phpAds_random = phpAds_random.substring(2,11);'
                            . '   '
                            . '   document.write ("<" + "script language=\'javascript\' type=\'text/javascript\' src=\'");'
                            . '   document.write ("http://www.claxonmedia.com/adserve_rot.php?n=" + phpAds_random);'
                            . '   document.write ("&invoke=js");'
                            . '   document.write ("&type=banner");'
                            . '   document.write ("&aff=");'
                            . '   document.write ("&exclude=" + document.phpAds_used);'
                            . '   if (document.referer)'
                            . '      document.write ("&referer=" + escape(document.referer));'
                            . '   document.write ("\'><" + "/script>");'
                            . '//-->'
                            . '</script><noscript><a href=\'http://www.claxonmedia.com/adclick.php?n=6034c6\'><img src=\'http://www.claxonmedia.com/adserve_rot.php?n=6034c6&type=banner&aff=\' border=\'0\' alt=\'\'></a></noscript><br><hr>';
    
    Code (markup):

    Is this wrong???

    Thanks

    Dylan
     
    dkin69, Jun 17, 2007 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    Seems like a massive waste of code to me .....

    
    <?php
    printf(	'<script language="javascript"'.
    		' src="http://www.claxonmedia.com/adserve_rot.php?n=%s&invoke=js&type=banner%s">'.
    		'</script>', 
    		rand( 0, 11 ), 
    		$_SERVER['HTTP_REFERER'] ? sprintf('&referer=%s', $_SERVER['HTTP_REFERER'] ) : '' 
    );
    ?>
    
    PHP:
     
    krakjoe, Jun 18, 2007 IP
  5. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Maybe because <!-- is on the same line as part of your JavaScript

    Add a "\n" to the end of it.

    i.e.:
                            . '<!--' . "\n"
    Code (markup):
    krakjoe, the "waste of code" is to evade some primitive ad blockers.
     
    krt, Jun 18, 2007 IP
    dkin69 likes this.
  6. dkin69

    dkin69 Active Member

    Messages:
    644
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #6
    perfect, thanks so much I really appreciate it.

    Rep Added.

    Dylan
     
    dkin69, Jun 18, 2007 IP