Mercurial > hg > extraction-interface
view interface/review_index_xml.php @ 0:b12c99b7c3f0
commit for previous development
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 19 Jan 2015 17:13:49 +0100 |
parents | |
children |
line wrap: on
line source
<?php header("Content-Type: text/html;charset=utf-8"); if (isset($_GET['books_id'])) { $books_id = $_GET['books_id']; } include_once('./Lib_mb_utf8.php'); set_time_limit(0); ini_set('memory_limit', '-1'); $link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password); mysql_query("SET NAMES utf8"); if (!$link_mysql) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($mysql_database, $link_mysql); if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); } if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $pbCount = 1; $imgCount = 1; function rep_pb_count($matches) { global $pbCount; return "</page>\n<page n=\"".++$pbCount."\">\n"; } function rep_img_count($matches) { global $imgCount; return "<img n=\"".$imgCount++."\"/>\n"; } $counter=0; $counterError=0; $counterIndex1=0; $counterIndex2=0; $counterMultiIndex=0; $counterSingleIndex=0; $counterNullIndex=0; $hasWordInIndex=array(); $hasWordInContent=array(); echo "<table width=\"100%\" border=\"1\">"; $query = sprintf("SELECT * FROM books WHERE `id`=%s ORDER BY `id` ASC", $books_id); $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $startPage = -1; $endPage = -1; $fileID = $row['id']; $indexFilename = "../bookindexxml/".$fileID.".xml"; $index = file_get_contents($indexFilename); if ( !preg_match("/<Index>(.*?)<\/Index>/sm", $index, $matches) ) { //echo "ERROR!".$fileID."\n"; } else { $matchString = preg_replace("/\r\n/u", "", $matches[0]); $counter++; if ( ! ($doc = simplexml_load_string( $matchString )) ) { echo "ERROR!"; exit; } else { } foreach ( $doc->children() as $child ) { $tempArray = $child->attributes(); if ( $tempArray['Type'] == "UNKNOWN" ) { echo "<tr bgcolor=\"#FFE4E1\"><font color=\"#FF0000\">"; } else if ( $tempArray['Type'] == "FROMFULLTEXT" ) { echo "<tr bgcolor=\"#FFFACD\"><font color=\"#000000\">"; } else { echo "<tr bgcolor=\"#FFFFFF\"><font color=\"#000000\">"; } echo "<td>".$tempArray['Entry']."</td>"; echo "<td>".$tempArray['StartPage']."(".$tempArray['StartRange'].")</td>"; echo "<td>".$tempArray['EndPage']."</td>"; echo "</font></tr>"; foreach ( $child->children() as $child2 ) { $tempArray = $child2->attributes(); if ( $tempArray['Type'] == "UNKNOWN" ) { echo "<tr bgcolor=\"#FFE4E1\"><font color=\"#FF0000\">"; } else if ( $tempArray['Type'] == "FROMFULLTEXT" ) { echo "<tr bgcolor=\"#FFFACD\"><font color=\"#000000\">"; } else { echo "<tr bgcolor=\"#FFFFFF\"><font color=\"#000000\">"; } echo "<td><span style=\"padding: 0 40px\"> </span>".$tempArray['Entry']."</td>"; echo "<td>".$tempArray['StartPage']."(".$tempArray['StartRange'].")</td>"; echo "<td>".$tempArray['EndPage']."</td>"; echo "</font></tr>"; } } } } ?>