PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon May 29, 2017 2:40 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Source browser
PostPosted: Sun Feb 15, 2009 11:55 am 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
Made a lil file browser cuz nothing else existed ( that didnt have file inclusion holes ). Uses kodify.
Syntax: [ Download ] [ Hide ]
 
<?php
// kodify -> http://github.com/d11wtq/kodify  ( or can be used w/ http://us3.php.net/highlight_file )
/**
Copyright (c) 2008-2009, Ne8, LLC.
All rights reserved.
 
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
 
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
 
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
 
    * Neither the name of Ne8, LLC. nor the names of its
      contributors may be used to endorse or promote products derived from this
      software without specific prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

$directory = 'DataShuffler-0.1/';    
?>
<script type="text/javascript" src="/lx_analyzer.js"></script>
<script type="text/javascript" src="/kodify.js"></script>
<script type="text/javascript" src="/php.js"></script>
<link id="theme" rel="stylesheet" type="text/css" href="/blackboard.css" />
<?php
function listfiles( $path = '', $depth = 0 )    
{
    global $directory;  
    if( !$path )
    {
        $path = $directory . $path;
    }
   
    $files = glob( $path . '*' );
    foreach( $files as $file )
    {
        echo str_repeat( '&nbsp;', $depth * 5 );
        if( is_dir( $file ) )
        {
           
            echo htmlentities( basename( $file ) ) . '<br />';
            listfiles( $file . '/', $depth + 1 );
        }
        else
        {
            ?>
            <a href="?file=<?=urlencode( $file )?>"><?=htmlentities( basename( $file ) )?></a>
            <br />
            <?php
        }
    }
}
listfiles();
if( isset( $_GET['file'] ) && file_exists( $_GET['file'] ) )
{
    $file = pathinfo(  $_GET['file'] );
    if( substr( realpath( $file['dirname'] ), 0, strlen( realpath( $directory ) ) ) === realpath( $directory )  )
    {
        echo '<pre class="kodify php">' . htmlentities( file_get_contents( $_GET['file'] ) ) . '</pre>';
    }
}
 


Last edited by josh on Mon Feb 16, 2009 10:40 pm, edited 7 times in total.

Top
 Profile  
 
 Post subject: Re: source browser
PostPosted: Sun Feb 15, 2009 8:45 pm 
Offline
DevNet Master

Joined: Wed Feb 11, 2004 4:23 pm
Posts: 4872
Location: Palm beach, Florida
Here's an example: http://datashuffler.org/source_browser. ... Mapper.php


Top
 Profile  
 
 Post subject: Re: source browser
PostPosted: Mon Feb 16, 2009 7:49 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4294
Location: Sofia, Bulgaria
There are plenty of such tools ;) :P (well, maybe they are not easy to find)
http://justin.madirish.net/node/322

_________________
Image
http://openfmi.net/projects/flattc/ Linux is better :)


Top
 Profile  
 
 Post subject: Re: Source browser
PostPosted: Sun Apr 26, 2009 2:39 am 
Offline
Forum Newbie

Joined: Sun Apr 26, 2009 12:22 am
Posts: 8
This is a well written script. This could be xhtml compliant if you removed the <pre>'s and just nested <div>'s with margins. Other that that, nice script.

You can actually achieve this with PHP's SPL (Standard Public Library) and it might be faster.


Top
 Profile  
 
 Post subject: Re: Source browser
PostPosted: Sun Oct 11, 2009 3:30 pm 
Offline
Forum Contributor
User avatar

Joined: Sat Oct 20, 2007 2:16 pm
Posts: 298
Location: York, England
coalgames wrote:
This is a well written script. This could be xhtml compliant if you removed the <pre>'s and just nested <div>'s with margins. Other that that, nice script.

You can actually achieve this with PHP's SPL (Standard Public Library) and it might be faster.


If it's in the core, it most certainly will be faster: compiled C kicks PHP's butt. ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group