Two php files into One ?

Discussion in 'PHP' started by pediw, Mar 28, 2010.

  1. #1
    Hello

    I have a Proxy script with these two files:
    Index.php and Index.inc.php

    But i need to get this script working as a single file ... like proxy.php
    Can somebody do it for me or explain me how to do this please ?

    I have attached that files
     

    Attached Files:

    Last edited: Mar 28, 2010
    pediw, Mar 28, 2010 IP
  2. odrey

    odrey Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try to help..
    create one new file, then include both of two files
     
    odrey, Mar 28, 2010 IP
  3. Nyu

    Nyu Peon

    Messages:
    79
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ... or include the index.inc.php to your index.php. Just add this line to the top of the index.php file
    include 'index.inc.php';
    PHP:
     
    Nyu, Mar 29, 2010 IP
  4. pediw

    pediw Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    index.inc.php is already included in index.php ... but i want to have both of these files in just one file .. :(
    anyone ?
     
    pediw, Mar 29, 2010 IP
  5. Nyu

    Nyu Peon

    Messages:
    79
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Is there any specific reason for that? You have a cleaner code structure if you keep the two files seperated as thats the way it was meant to be. But if you want to merge these two files you only have to copy everything from the index.inc.php file and replace the line where you include the file in your index.php with the copied code.
     
    Nyu, Mar 29, 2010 IP
  6. meloncreative

    meloncreative Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ^^ What he said, copy + paste is your friend :)
     
    meloncreative, Mar 29, 2010 IP
  7. pediw

    pediw Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i've already did it but i get an error when i replace:

    function show_report($data)
    {    
        include $data['which'] . '.inc.php';
        exit(0);
    }
    PHP:
    with the code inside index.inc.php

    Please have a look to this files because I'm from Iran and we really need this script to unblock the blocked websites ..

    this code is a bit complicated for me .. but i know its really for you guys .. please have a look ..

    Thank you
     
    pediw, Mar 29, 2010 IP
  8. pediw

    pediw Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    anyone? :(
     
    pediw, Mar 29, 2010 IP
  9. Nyu

    Nyu Peon

    Messages:
    79
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Do only replace the line which starts with include not the whole function. To make it work properly omit the first if statement within index.inc.php and start copying the code from the first echo. Replace the include line and add <?php to the end of your copied text. Now it should work ;)
     
    Nyu, Mar 30, 2010 IP
  10. Cloud Computing Forum

    Cloud Computing Forum Guest

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Hi, the function show_report loads up a file depending on which on what action has been requested here:

    else if (isset($_GET['action']) && $_GET['action'] == 'cookies')
    {
        show_report(array('which' => 'cookies'));
    }else
    {
        show_report(array('which' => 'index', 'category' => 'entry_form'));
    }
    Code (markup):
    Combining these files may loose you some functionality if you are using more than one action.
     
    Cloud Computing Forum, Mar 30, 2010 IP
  11. Cloud Computing Forum

    Cloud Computing Forum Guest

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    If you don't mind potentially loosing functionality you can try the attached file.

    You'll need to remove one of the dots in the file name if there is two when you download it.
     

    Attached Files:

    Cloud Computing Forum, Mar 30, 2010 IP
  12. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #12
    The following will work if you don't ever need to include cookies.in.php

    
    ...
    ...
    function show_report($data)
    {    
    [COLOR="SeaGreen"]?>
    --- Paste content of index.inc.php file here AS IS ---
    <?php[/COLOR]
        exit(0);
    }
    ...
    ...
    
    Code (markup):
     
    stOK, Mar 30, 2010 IP
  13. Cloud Computing Forum

    Cloud Computing Forum Guest

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Done in my attached file above.
     
    Cloud Computing Forum, Mar 30, 2010 IP
  14. pediw

    pediw Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Wow thanks everyone for helping me out !
    my problem is solved now
     
    pediw, Mar 30, 2010 IP