All pastes #730217 Raw Edit

splat

public php v1 · immutable
·published 2007-10-09 00:25 UTC
rendered paste body
<pre><?php// setup standard vars for db$id = '';$state = '';$sectionId = 4;$mask = 0;$createdBy = 62;$modified = '0000-00-00 00:00:00';$modifiedBy = 0;$checkedOut = 0;$checkedOutTime = '0000-00-00 00:00:00';$publishUp = '2000-01-01 00:00:00';$publishDown = '0000-00-00 00:00:00';$images = '';$urls = '';$attribs = 'pageclass_sfx=\nback_button=\nitem_title=1\nlink_titles=\nintrotext=1\nsection=0\nsection_link=0\ncategory=0\ncategory_link=0\nrating=\nauthor=\ncreatedate=\nmodifydate=\npdf=\nprint=\nemail=\nkeyref=\ndocbook_type=';$version = 1;$parentId = 0;$ordering = 0;$metakey = '';$metadesc = '';$access = 0;$hits = 0;//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="\.\.\/([^"]*)"[^>]*>(.*)<\/a>([^\r\n]*)[\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][] = mysql_escape_string(preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})[: -]{1,3}/', '', strip_tags($item[2]))); //title      $introText[$i][] = mysql_escape_string(strip_tags($item[3])); //intro text     }   } }$handle = fopen("import.sql", "w") or exit("Unable to open " . $filename . "! ");fwrite($handle, "INSERT INTO `jos_content` (`id`, `title`, `title_alias`, `introtext`, `fulltext`, `state`, `sectionid`, `mask`, `catid`, `created`, `created_by`, `created_by_alias`, `modified`, `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `images`, `urls`, `attribs`, `version`, `parentid`, `ordering`, `metakey`, `metadesc`, `access`, `hits`) VALUES\n");// 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('/<font size="\+1"[^>]*>[\s]*(.*)[^\r\n]*/', $contents, $output1, PREG_SET_ORDER );    foreach ($output1 as $item) {      $main[$i][$j][0] = mysql_escape_string(preg_replace('/&quot;/', '', strip_tags($item[1]))); // title_alias     }    preg_match_all('/<font size="\-1"><i>([a-zA-Z0-9":, \.]*)[-\r\n]/', $contents, $output2, PREG_SET_ORDER );    if (empty($output2)) {      $main[$i][$j][1] = '';     } else {      foreach ($output2 as $item) {        $main[$i][$j][1] = mysql_escape_string(strip_tags($item[1])); // created_by_alias       }     }    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 );    if (empty($output3)) {      $main[$i][$j][2] = "2000-01-01 00:00:00"; // created     } else {      foreach ($output3 as $item) {        $main[$i][$j][2] = date('Y-m-d H:i:s',mktime(0, 0, 0, $item[1], $item[2], $item[3])); // created       }     }         preg_match_all('/<!-- (CONTENT BEGINS|All Content Starts Here|CONTENT HERE|Content Start|CONTENT START|Ad Banner END)[^>]*>(.*?)<!-- (CONTENT ENDS|All Content Ends Here|CONTENT END|Content End|CONTENT END|END CONTENT|Begin Dynamic Html rollovers for links)[^>]*>/s', $contents, $output4, PREG_SET_ORDER );    foreach ($output4 as $item) {      $main[$i][$j][3] = mysql_escape_string($item[2]); // full text     }    // setup the variables for the database    $title = $title[$i][$j];    $titleAlias = $main[$i][$j][0];    $introText = $introText[$i][$j];    $fullText = $main[$i][$j][3];    $catid = $i+13;    $created = $main[$i][$j][2];    $createdByAlias = $main[$i][$j][1];    fwrite($handle, "('" . $id . "', '" . $title . "', '" . $titleAlias . "', '" . $introText . "', '" . $fullText . "', '" . $state . "', '" . $sectionId . "', '" . $mask . "', '" . $catid . "', '" . $created . "', '" . $createdBy . "', '" . $createdByAlias . "', '" . $modified . "', '" . $modifiedBy . "', '" . $checkedOut . "', '" . $checkedOutTime . "', '" . $publishUp . "', '" . $publishDown . "', '" . $images . "', '" . $urls . "', '" . $attribs . "', '" . $version . "', '" . $parentId . "', '" . $ordering . "', '" . $metakey . "', '" . $metadesc . "', '" . $access . "', '" . $hits . "'),\n");   } }fwrite($handle, ";");fclose($handle);?></pre>