it is possible to copy php script ?

Discussion in 'PHP' started by ironmankho, Jul 24, 2008.

  1. #1
    i want to copy a php script with out execution ?

    [​IMG]
     
    ironmankho, Jul 24, 2008 IP
  2. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Not normally possible. PHP is a server side lang, meaning you only see what it prints out. Certain servers have a feature that allow you to include over the net, and there's ftp, but for what you want to do it doesn't work.
     
    ToddMicheau, Jul 24, 2008 IP
  3. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Ditto to the above. It's absolutely impossible. The file is parsed way before you can do anything to it, so you will only receive the execution output, not the code input.
     
    jayshah, Jul 24, 2008 IP
  4. ironmankho

    ironmankho Active Member

    Messages:
    393
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #4
    there is no hope ?
     
    ironmankho, Jul 24, 2008 IP
  5. ToddMicheau

    ToddMicheau Active Member

    Messages:
    183
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Your only hope is to get FTP access and download it that way, or perhaps asking the owner of the script if you could have a copy? Doubt the latter will work, but I've given away scripts before, so can't hurt to ask =]
     
    ToddMicheau, Jul 24, 2008 IP
  6. jackass2007

    jackass2007 Peon

    Messages:
    2,379
    Likes Received:
    267
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Its not possible until you have access to the server :eek:
     
    jackass2007, Jul 24, 2008 IP
  7. ahowell

    ahowell Peon

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Sounds a little fishy if you don't have direct access to the script ;)

    That aside, if you:
    - Do have FTP access to the server
    - Need to share source code via the browser

    you can use highlight_file() or show_source() to accomplish this. They both do the same... show_source() is actually just an alias for highlight_file().

    You can take 2 approaches to practicing this:
    1.) put this in each file that needs to show it's source in the browser (at the bottom)
    highlight_file(__FILE__);
    PHP:
    2.) Create a new file and use the following code. It will build a directory/file tree. The files (in left column) will be clickable. Click a file and it's source will display in the right column.

    <?php
    function getDirectory($path = '.', $level = 0, &$output = array()){
        $ignore = array('cgi-bin', '.', '..');
    
        $dh = @opendir($path);
        
        while (false !== ($file = readdir($dh))) {
            if (!in_array($file, $ignore)) {
                $spaces = str_repeat('&nbsp;', ($level * 4));
                
                if (is_dir("$path/$file")) {
                    $output[] = "<strong>$spaces $file</strong>";
                    getDirectory("$path/$file", ($level+1), $output);
                } else {
                    $output[] = "$spaces <a href=\"?file={$path}/{$file}\">{$file}</a>";
                }
            }
        }
        
        closedir( $dh );
        return $output;
    } 
    
    $output = getDirectory('/your/root/path/here');   // Change this!
    ?>
    
    
    <table border="1" cellpadding="5">
        <tr>
            <td width="20%" valign="top">
                <?php 
                    print_r('<pre>');
                    print_r(implode(PHP_EOL, $output)); 
                    print_r('</pre>');
                ?>
            </td>
            <td width="80%" valign="top">
                <?php
                    if (array_key_exists('file', $_GET)) {
                        highlight_file($_GET['file']);
                    }
                ?>
            </td>
        </tr>
    </table>
    PHP:
    If you use #2, make sure you drop the new file in the root of, or above where you want to start your file tree.
     
    ahowell, Jul 24, 2008 IP