'); preg_match_all('/]*>(.*)<\/tr>/isU', $page_html, $trs); $ahrefexp = '/]*href=["\'](?P[^"\']*)["\']\s*[^>]*>(?P.*)<\s*\/a>/si'; $csvout=''; foreach ($trs[1] as $tr) { preg_match_all('/]*>(.*)<\/t[hd]>/isU', $tr, $tds); $first = true; foreach ($tds[1] as $td) { # For CSV output, prefer blank to regular decode for nbsp $td = preg_replace('/ /', ' ', $td); # Double quotes must be escaped by another double quote $td = preg_replace('/"/', '""', $td); if (!$first) $csvout .= ','; if (preg_match_all($ahrefexp, $td, $matches)) $td = $matches['name'][0]; $csvout .= '"' . html_entity_decode($td) . '"'; $first = false; } $csvout .= "\n"; } if ($csvout != '') { $csvout = preg_replace('/\n","/', '","', $csvout); $fname = FmtPageName('$Name',$pagename); $HTTPHeaders[] = 'Cache-Control: public'; $HTTPHeaders[] = 'Content-type: text/csv'; $HTTPHeaders[] = 'Content-disposition: attachment;filename="' . $fname .'.csv";'; foreach ($HTTPHeaders as $h) { header($h); } echo $csvout; } else { # No tables, then we do nothing, default handler. HandleBrowse($pagename, $auth); } } else HandleBrowse($pagename, $auth); }