$files[] = create_fullsize_read($rowset[$key]['filepath'], $rowset[$key]['filename']);
                //$files[] = $rowset[$key]['filepath'].$rowset[$key]['filename'];
            }
        }
    } else {
        foreach ($superCage->get->_source as $key => $val) {
            if (strpos($key, "pic") !== false) {
                $favs .= "{$val},";
            }
        }
        $favs .= "-1";
        $select_columns = 'filepath,filename';
        $result = cpg_db_query("SELECT {$select_columns} FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'AND pid IN ({$favs})");
        $rowset = cpg_db_fetch_rowset($result);
        foreach ($rowset as $key => $row) {
            //$filelist[] = $rowset[$key]['filepath'].$rowset[$key]['filename'];
            $files[] = create_fullsize_read($rowset[$key]['filepath'], $rowset[$key]['filename']);
            //add_to_history($USER_DATA['user_id'],$rowset[$key]['filename']);
        }
    }
    $flags['storepath'] = 0;
    // $cwd = './albums';
    //$cwd = "./{$CONFIG['fullpath']}";
    $cwd = substr($cwd, 0, -1);
    $zip = new zipfile($cwd, $flags);
    $zip->addfiles($files);
    $zip->filedownload('pictures.zip');
    foreach ($files as $fn) {
        secure_fullsize($fn);
    }
}
    //someone has entered the url manually, while the admin has disabled zipdownload
    pageheader($lang_error);
    starttable('-2', $lang_error);
    print <<<EOT
<tr>
        <td align="center" class="tableb">
      {$lang_errors['perm_denied']}
      </td>
</tr>
EOT;
    endtable();
    pagefooter();
    ob_end_flush();
} else {
    // zipdownload allowed, go ahead...
    $filelist = array();
    if (count($FAVPICS) > 0) {
        $favs = implode(",", $FAVPICS);
        $select_columns = 'filepath,filename';
        $result = db_query("SELECT {$select_columns} FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'AND pid IN ({$favs})");
        $rowset = db_fetch_rowset($result);
        foreach ($rowset as $key => $row) {
            $filelist[] = $rowset[$key]['filepath'] . $rowset[$key]['filename'];
        }
    }
    $flags['storepath'] = 0;
    $cwd = './albums';
    $zip = new zipfile($cwd, $flags);
    $zip->addfiles($filelist);
    $zip->filedownload('pictures.zip');
}