Mercurial > hg > extraction-interface
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b12c99b7c3f0 |
---|---|
1 <?php | |
2 header("Content-Type: text/html;charset=utf-8"); | |
3 | |
4 if (isset($_GET['books_id'])) { | |
5 $books_id = $_GET['books_id']; | |
6 } | |
7 | |
8 include_once('./Lib_mb_utf8.php'); | |
9 | |
10 set_time_limit(0); | |
11 ini_set('memory_limit', '-1'); | |
12 | |
13 $link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password); | |
14 mysql_query("SET NAMES utf8"); | |
15 | |
16 if (!$link_mysql) { | |
17 die('Could not connect: ' . mysql_error()); | |
18 } | |
19 | |
20 $db_selected = mysql_select_db($mysql_database, $link_mysql); | |
21 if (!$db_selected) { | |
22 die ('Can\'t use foo : ' . mysql_error()); | |
23 } | |
24 | |
25 if (!function_exists("GetSQLValueString")) { | |
26 function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") | |
27 { | |
28 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; | |
29 | |
30 $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); | |
31 | |
32 switch ($theType) { | |
33 case "text": | |
34 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; | |
35 break; | |
36 case "long": | |
37 case "int": | |
38 $theValue = ($theValue != "") ? intval($theValue) : "NULL"; | |
39 break; | |
40 case "double": | |
41 $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; | |
42 break; | |
43 case "date": | |
44 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; | |
45 break; | |
46 case "defined": | |
47 $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; | |
48 break; | |
49 } | |
50 return $theValue; | |
51 } | |
52 } | |
53 | |
54 $pbCount = 1; | |
55 $imgCount = 1; | |
56 | |
57 function rep_pb_count($matches) { | |
58 global $pbCount; | |
59 return "</page>\n<page n=\"".++$pbCount."\">\n"; | |
60 } | |
61 function rep_img_count($matches) { | |
62 global $imgCount; | |
63 return "<img n=\"".$imgCount++."\"/>\n"; | |
64 } | |
65 | |
66 $counter=0; | |
67 $counterError=0; | |
68 $counterIndex1=0; | |
69 $counterIndex2=0; | |
70 $counterMultiIndex=0; | |
71 $counterSingleIndex=0; | |
72 $counterNullIndex=0; | |
73 | |
74 $hasWordInIndex=array(); | |
75 $hasWordInContent=array(); | |
76 | |
77 echo "<table width=\"100%\" border=\"1\">"; | |
78 $query = sprintf("SELECT * FROM books WHERE `id`=%s ORDER BY `id` ASC", $books_id); | |
79 $result = mysql_query($query); | |
80 while ($row = mysql_fetch_assoc($result)) { | |
81 $startPage = -1; | |
82 $endPage = -1; | |
83 $fileID = $row['id']; | |
84 $indexFilename = "../bookindexxml/".$fileID.".xml"; | |
85 | |
86 $index = file_get_contents($indexFilename); | |
87 if ( !preg_match("/<Index>(.*?)<\/Index>/sm", $index, $matches) ) { | |
88 //echo "ERROR!".$fileID."\n"; | |
89 } else { | |
90 $matchString = preg_replace("/\r\n/u", "", $matches[0]); | |
91 | |
92 $counter++; | |
93 if ( ! ($doc = simplexml_load_string( $matchString )) ) { | |
94 echo "ERROR!"; | |
95 exit; | |
96 } else { | |
97 | |
98 } | |
99 | |
100 foreach ( $doc->children() as $child ) { | |
101 $tempArray = $child->attributes(); | |
102 if ( $tempArray['Type'] == "UNKNOWN" ) { | |
103 echo "<tr bgcolor=\"#FFE4E1\"><font color=\"#FF0000\">"; | |
104 } else if ( $tempArray['Type'] == "FROMFULLTEXT" ) { | |
105 echo "<tr bgcolor=\"#FFFACD\"><font color=\"#000000\">"; | |
106 } else { | |
107 echo "<tr bgcolor=\"#FFFFFF\"><font color=\"#000000\">"; | |
108 } | |
109 echo "<td>".$tempArray['Entry']."</td>"; | |
110 echo "<td>".$tempArray['StartPage']."(".$tempArray['StartRange'].")</td>"; | |
111 echo "<td>".$tempArray['EndPage']."</td>"; | |
112 echo "</font></tr>"; | |
113 foreach ( $child->children() as $child2 ) { | |
114 $tempArray = $child2->attributes(); | |
115 if ( $tempArray['Type'] == "UNKNOWN" ) { | |
116 echo "<tr bgcolor=\"#FFE4E1\"><font color=\"#FF0000\">"; | |
117 } else if ( $tempArray['Type'] == "FROMFULLTEXT" ) { | |
118 echo "<tr bgcolor=\"#FFFACD\"><font color=\"#000000\">"; | |
119 } else { | |
120 echo "<tr bgcolor=\"#FFFFFF\"><font color=\"#000000\">"; | |
121 } | |
122 echo "<td><span style=\"padding: 0 40px\"> </span>".$tempArray['Entry']."</td>"; | |
123 echo "<td>".$tempArray['StartPage']."(".$tempArray['StartRange'].")</td>"; | |
124 echo "<td>".$tempArray['EndPage']."</td>"; | |
125 echo "</font></tr>"; | |
126 } | |
127 } | |
128 } | |
129 } | |
130 | |
131 ?> |