All pastes #727301 Raw Edit

splat

public php v1 · immutable
#727301 ·published 2007-10-05 22:13 UTC
rendered paste body
<pre><?php//start with the index$filename="G:\\WEB\\home.asp";$file=fopen($filename,"r") or exit("Unable to open " . $filename . "! ");$contents = fread($file, filesize($filename));preg_match_all( '/<a href="\.\.\/topiclist\/(index[0-9]*\.asp)#[^"]*"/', $contents, $catout, PREG_SET_ORDER );fclose($file);// insert category index pages in to arrayforeach ($catout as $item) {  $page[] = $item[1];}// grab article info from category index pagefor($i = 0 ; $i < count($page) ; $i++) {  $filename = "G:\\WEB\\topiclist\\" . $page[$i];  $file = fopen($filename,"r") or exit("Unable to open " . $filename . "! ");  $contents = fread($file, filesize($filename));  fclose($file);  preg_match_all('/<li><a href="\.\.\/([^"]*)"[^>]*><b>(.*?)<\/b><\/a>([^\r\n]*)/', $contents, $output, PREG_SET_ORDER );  foreach ($output as $item) {   $filepath = str_replace("/", "\\", $item[1]);   if (!strstr($filepath, '\\')) {     $filepath = $filepath . "\\index.asp";   } elseif (!strstr($filepath, '.asp')) {     $filepath = $filepath . "index.asp";   }   if (fopen("G:\\WEB\\" . $filepath, "r")) {     $category[$i][] = $filepath;     $title[$i][] = $item[2];     $introText[$i][] = $item[3];   }}// go back thru and add in the titles that weren't bold  preg_match_all('/<li><a href="\.\.\/([^"]*)"[^>]*>(?!<b>)(.*?)(?!<\/b>)<\/a>/', $contents, $output, PREG_SET_ORDER );  foreach ($output as $item) {    $filepath = str_replace("/", "\\", $item[1]);    if (!strstr($filepath, '\\')) {     $filepath = $filepath . "\\index.asp";    } elseif (!strstr($filepath, '.asp')) {     $filepath = $filepath . "index.asp";    }    if (fopen("G:\\WEB\\" . $filepath, "r")) {     $category[$i][] = $filepath;     $title[$i][] = $item[2];    }  }}// get article contentfor($i = 0 ; $i < count($category) ; $i++) {  for($j = 0 ; $j < count($category[$i]) ; $j++) {   $filename = "G:\\WEB\\" . $category[$i][$j];   $file = fopen($filename,"r") or exit("Unable to open " . $filename . "! ");   $contents = fread($file, filesize($filename));   fclose($file);   preg_match_all('/<[bi]>&quot;(.*?)&quot;/', $contents, $output1, PREG_SET_ORDER );   preg_match_all('/<font size="\-1"><i>([a-zA-Z0-9, ]*)[-<\s]/', $contents, $output2, PREG_SET_ORDER );   preg_match_all('/<font size="\-1"><i>[^-]*[- ]{1,2}([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})[<\s]/', $contents, $output3, PREG_SET_ORDER );   foreach ($output1 as $item) {    $main[$i][$j][0] = $item[1]; // title_alias   }   foreach ($output2 as $item) {    $main[$i][$j][1] = $item[1]; // created_by_alias   }   foreach ($output3 as $item) {    $date = (!empty($item)) ? date('Y-m-d H:i:s',mktime(0, 0, 0, $item[1], $item[2], $item[3])) : date('Y-m-d H:i:s',mktime(0, 0, 0, 1, 1, 2000));    $main[$i][$j][2] = $date; // created   }  }}print_r($main);?></pre>