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