Jump to content

Anyone familiar with UNLINK want to help?


ljzmcm

Recommended Posts

Hey everyone, first post here, trying to hustle to get something solved.

Self-taught php, still pretty amateur, and never messed with the unlink function.

 

I've got a basic directory indexing script here, similar to what you would see if there was no index.html,htm,php, etc file in a directory. However, you can incorporate it into pages. I am trying to add a function that will allow me to delete the listed item. Perhaps just a simple text link on the same line.

 

Anyone wanna take this on or add it for me? Thanks a bunch =)

 

<?php
unset($dir);
if(!empty($HTTP_GET_VARS['dir'])&&!strpos($HTTP_GET_VARS['dir'],'..')&&!strpos($HTTP_GET_VARS['dir'],'\.\.'))
{

    $dir=$HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/'.$HTTP_GET_VARS['dir'];
    $d=&$HTTP_GET_VARS['dir'];
}
else
{
    $dir='.';
    $d='.';
}
clearstatcache();
if($a=@opendir($dir))
{
    $dir=htmlspecialchars($dir);
    $d=htmlspecialchars($d);
    while(false!==($b=readdir($a)))
    {
        if(ereg("^\.",$b)) 
            continue; // ignore hidden files
        echo (is_dir($b))?"<li> <a href=?dir=$d/$b>$b</a>":"<li> <a href=$d/$b>$b</a>";
    }
    closedir($a);
}
else
{
    echo 'unable to open directory';
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/90005-anyone-familiar-with-unlink-want-to-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.