Integrate script into other file, please help.

Discussion in 'PHP' started by scriptsy26, Aug 11, 2010.

  1. #1
    Hello


    I have got this file. and i want to integrate a script without interfering with this file.
    This file is the main file. i have tried include or literal. But i have still got errors.

    can someone help me with this.

    thanks.

    <?php

    if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') )
    {
    function file_put_contents($n, $d, $flag = false)
    {
    $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
    $f = @fopen($n, $mode);

    if ($f === false)
    {
    return 0;
    }
    else
    {
    if (is_array($d)) $d = implode($d);
    $bytes_written = fwrite($f, $d);
    fclose($f);
    return $bytes_written;
    }
    }
    }

    $fpp = "the-includes/search.txt";
    $searchlog = "[keywords]:".urldecode(stripslashes(strip_tags($_GET[search])))."\n";
    file_put_contents($fpp, $searchlog, FILE_APPEND);

    ?>


    This file i want to integrate with the main file.

    <script type="text/javascript">var isloaded = false;</script><script type="text/javascript" src="http://www.cpalead.com/mygateway.php?pub=37698&amp;gateid=MTExMjk0"></script><script type="text/javascript">if (!isloaded) { window.location = 'http://cpalead.com/adblock.php?pub=37698'; }</script><noscript><meta http-equiv="refresh" content="0;url=http://cpalead.com/nojava.php?pub=37698" /></noscript>
     
    scriptsy26, Aug 11, 2010 IP
  2. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #2
    Just put it outside PHP tag. Like this:
    
    <script type="text/javascript">var isloaded = false;</script><script type="text/javascript" src="http://www.cpalead.com/mygateway.php?pub=37698&amp;gateid=MTExMjk0"></script><script type="text/javascript">if (!isloaded) { window.location = 'http://cpalead.com/adblock.php?pub=37698'; }</script><noscript><meta http-equiv="refresh" content="0;url=http://cpalead.com/nojava.php?pub=37698" /></noscript> 
    
    <?php
    
    if ( !function_exists('file_put_contents') && !defined('FILE_APPEND') )
    {
    function file_put_contents($n, $d, $flag = false)
    {
    $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
    $f = @fopen($n, $mode);
    
    if ($f === false)
    {
    return 0;
    }
    else
    {
    if (is_array($d)) $d = implode($d);
    $bytes_written = fwrite($f, $d);
    fclose($f);
    return $bytes_written;
    }
    }
    }
    
    $fpp = "the-includes/search.txt";
    $searchlog = "[keywords]:".urldecode(stripslashes(strip_tags($_GET[search])))."\n";
    file_put_contents($fpp, $searchlog, FILE_APPEND);
    ?>
    
    PHP:
    Since that's a javascript, you can include it externally with:
    <script src='watever.js' type='text/javascript'></script>
    Code (markup):
     
    Rainulf, Aug 11, 2010 IP
  3. scriptsy26

    scriptsy26 Active Member

    Messages:
    274
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    83
    #3
    Hello Rainulf,

    Thank you for your reply, yes it was that simple, it really worked haha, thanks a lot.

    One question though, the javascript code, can you explain that? where do i put that, also on top?

    thanks really helped me.
     
    scriptsy26, Aug 12, 2010 IP
  4. extremephp

    extremephp Peon

    Messages:
    1,290
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes on Top!! But its not a Must in Most of the Cases!! :)

    But according to the rules, It should be Mentioned :D NO one cares :p

    ~Exp~
     
    extremephp, Aug 12, 2010 IP