Closed Thread Icon

Topic awaiting preservation: PHP Question (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25322" title="Pages that link to Topic awaiting preservation: PHP Question (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP Question <span class="small">(Page 1 of 1)</span>\

 
u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 03-24-2005 10:08

What would you do?

Write this way:

code:
if ($filename == '.') continue;

if (!$d and $filename == '..') continue;

if (HIDE_HT_F and preg_match('/^\.ht|ds_s/i', $filename)) {
continue;
}

if (HIDE_FILE and !$d and $d != $thisdir and $filename == $thisfile) {
continue;
}

if (HIDE_IMGD and preg_match('/^dirlist_images$/i', $filename)) {
continue;
}



or this:

code:
if (($filename == '.')
or (!$d and $filename == '..')
or (HIDE_HT_F and preg_match('/^\.ht|ds_s/i', $filename))
or (HIDE_FILE and !$d and $d != $thisdir and $filename == $thisfile)
or (HIDE_IMGD and preg_match('/^dirlist_images$/i', $filename))) {

continue;
}



Thanks yor the response.

(Edited by u-neek on 03-24-2005 10:22)

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 03-24-2005 19:04
code:
if      ($filename == '.')
continue;
else if ( (! $d)
and ($filename == '..')
)
continue;
else if ( (HIDE_HT_F)
and (preg_match('/^\.ht|ds_s/i', $filename))
)
continue;
else if ( (HIDE_FILE)
and (! $d)
and ($d != $thisdir)
and ($filename == $thisfile)
)
continue;
else if ( (HIDE_IMGD)
and (preg_match('/^dirlist_images$/i', $filename))
)
continue;





.

(Edited by hyperbole on 03-24-2005 19:07)

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 03-25-2005 14:44
code:
function isValidFilename($filename)
{
return !
(($filename == '.')
or (!$d and $filename == '..')
or (HIDE_HT_F and preg_match('/^\.ht|ds_s/i', $filename))
or (HIDE_FILE and !$d and $d != $thisdir and $filename == $thisfile)
or (HIDE_IMGD and preg_match('/^dirlist_images$/i', $filename)));
}

then:
if (!isValidFilename($filename))
continue;

u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 03-26-2005 10:42

Thanks for the comments. Here is my final solution:

code:
$hidden = array(
'{/\.(ht|ds_s)}i', // .ht* and .DS_S* files
'{/\.{1}$}', // exclude the "."
'{^'.THIS_DIR.LIB_URL.'/?}i', // the library directory
'{^'.THIS_DIR.SCRIPT_NAME.'}i', // this file
'{^'.THIS_DIR.'\.\./?}' // change to above directories
);

function filterHidden($hidden = array(), $string) {

foreach($hidden as $v) {
if (preg_match($v, $string)) {
return true;
}
}
return false;

}



I call the function with the following parameters: filterHidden($hidden, $path);

« BackwardsOnwards »

Show Forum Drop Down Menu