View Single Post
Old 04-09-2008, 06:59 PM   #2 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

It looks like the file information is stored in an associative array (but that's not particularly important here). To get at the file names you can use the file_name key on each of the main array items.

For example:
PHP Code:
$bad_file_found  FALSE;
$blacklist       = array('php''exe');
$blacklist_regex '/\.(?:'
                 
implode('|'array_map('preg_quote'$blacklist))
                 . 
')$/iD';

foreach (
$zip->getList() as $file)
{
    if (
preg_match($blacklist_regex$file['file_name']))
    {
        
$bad_file_found TRUE;
        break; 
// no need to continue foreach
    
}
}

if (
$bad_file_found)
{
    die(
'Hey, please do not include invalid file types in your ZIP.');
}

die(
'No invalid files found, woohoo!'); 
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
mikka23 (04-09-2008)