comparison interface/review_index_xml_images.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 /**
5 * "Lib_mb_utf8.php" is a set of common functions used to convert encode of text
6 * "config.php" containing a system name variable. Please make it the same as the system's folder name.
7 */
8 include_once('Lib_mb_utf8.php');
9 include_once('config.php');
10
11 //Path to the photos DIR
12 $imagePath="E:/images02/";
13
14 if (isset($_GET['books_id'])) {
15 $books_id = $_GET['books_id'];
16 }
17 if (isset($_GET['pages'])) {
18 $pages = $_GET['pages'];
19 if ( $pages==0 ) $pages=1;
20 }
21 if (isset($_GET['entry'])) {
22 $entry = $_GET['entry'];
23 }
24 if (isset($_GET['JSESSIONID'])) {
25 $JSESSIONID = $_GET['JSESSIONID'];
26 }
27
28 set_time_limit(0);
29 ini_set('memory_limit', '-1');
30
31 $link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password);
32 mysql_query("SET NAMES utf8");
33
34 if (!$link_mysql) {
35 die('Could not connect: ' . mysql_error());
36 }
37
38 $db_selected = mysql_select_db($mysql_database, $link_mysql);
39 if (!$db_selected) {
40 die ('Can\'t use foo : ' . mysql_error());
41 }
42
43 if (!function_exists("GetSQLValueString")) {
44 function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
45 {
46 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
47
48 $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
49
50 switch ($theType) {
51 case "text":
52 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
53 break;
54 case "long":
55 case "int":
56 $theValue = ($theValue != "") ? intval($theValue) : "NULL";
57 break;
58 case "double":
59 $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
60 break;
61 case "date":
62 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
63 break;
64 case "defined":
65 $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
66 break;
67 }
68 return $theValue;
69 }
70 }
71
72 $query = sprintf("SELECT `content` FROM `contents` WHERE `books_id`=\"%s\" AND `line`=%d", $books_id, $pages);
73 $result = mysql_query($query);
74 while ($row = mysql_fetch_assoc($result)) {
75 $contentString=$row['content'];
76 }
77 $contentString = preg_replace("/".$entry."/u", "<font color=\"#FF0000\">\\0</font>", $contentString);
78
79 $pagesImg = sprintf("%04d", $pages);
80
81
82 if ( !file_exists($imagePath.$books_id."/") ) {
83 mkdir($imagePath.$books_id."/");
84 }
85
86 if ( ! file_exists($imagePath.$books_id."/".$pagesImg.".jpg") ) {
87 $options = array(
88 'http' => array(
89 'header' => "Accept-Encoding:gzip,deflate,sdch
90 Accept-Language:en-US,en;q=0.8
91 Connection:keep-alive
92 Cookie:".file_get_contents("../cookie.txt")."
93 Host:server.wenzibase.com
94 Referer:http://server.wenzibase.com/userReadAction.action?prId=42&page=fangzhi
95 User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36",
96 'method' => 'GET',
97 ),
98 );
99
100 $context = stream_context_create($options);
101
102 $url = sprintf("http://server.wenzibase.com/loadImage.action?isImage=1&zoom=1&code=8007&tag=0&libId=23&bookId=%s&PageId=%d", $books_id, $pages);
103 $resultGet = file_get_contents($url, false, $context);
104 file_put_contents(sprintf($imagePath."/%s/%04d.jpg",$books_id,$pages), $resultGet);
105
106 /*
107 $url = sprintf("http://server.wenzibase.com.ezp-prod1.hul.harvard.edu/loadImage.action?isImage=0&zoom=3&code=8020&tag=0&libId=23&bookId=%s&PageId=%d", $bookId, $pageNum);
108 $resultGet = file_get_contents($url, false, $context);
109 $resultGet = preg_replace('/\A(.*?)(\\x47\\x49\\x46\\x38)/', "\\2", $resultGet);
110 file_put_contents(sprintf("images01/%s/%04da.gif",$bookId,$pageNum), $resultGet);
111
112 $url = sprintf("http://server.wenzibase.com/loadImage.action?isImage=0&zoom=3&code=8020&tag=0&libId=23&bookId=%s&PageId=%d", $books_id, $pages);
113 $resultGet = file_get_contents($url, false, $context);
114 $resultGet = preg_replace('/\A(.*?)(\\x47\\x49\\x46\\x38)/', "\\2", $resultGet);
115 file_put_contents(sprintf($imagePath."/%s/%04da.gif",$books_id,$pages), $resultGet);
116 */
117 }
118 ?>
119
120 <html>
121 <head>
122 <title> </title>
123 <script src="./jquery-1.10.2.min.js"></script>
124 <script type="text/javascript">
125 function selectTextboxContent(textbox)
126 {
127 setTimeout(function() { textbox.select(); }, 10);
128 }
129 </script>
130 </head>
131 <body>
132
133 <table border="1" width="1000">
134 <tr>
135 <td colspan="2" align="center">
136 <a href="review_index_xml_images.php?books_id=<?php echo $books_id; ?>&pages=<?php echo $pages-1; ?>&entry=<?php echo $entry; ?>">上一頁</a>
137 <input onfocus="selectTextboxContent(this)" type="text" id="txt1" name="txt1" value="<?php echo $pages; ?>" size="5">
138 <a href="review_index_xml_images.php?books_id=<?php echo $books_id; ?>&pages=<?php echo $pages+1; ?>&entry=<?php echo $entry; ?>">下一頁</a>
139 </td>
140 </tr>
141 <tr>
142 <td width="500"><img src="/images01/<?php echo $books_id; ?>/<?php echo $pagesImg; ?>.jpg" width="100%"></td>
143 <td width="500"><img src="/images01/<?php echo $books_id; ?>/<?php echo $pagesImg; ?>a.gif" width="100%"></td>
144 </tr>
145 <tr>
146 <td>Entry: <?php echo $entry; ?></br>Page: <input onfocus="selectTextboxContent(this)" type="text" id="txt2" name="txt2" value="<?php echo $pages; ?>"></td>
147 <td><?php echo $contentString; ?></td>
148 </tr>
149 <tr>
150 <td colspan="2" align="center">
151 <a href="review_index_xml_images.php?books_id=<?php echo $books_id; ?>&pages=<?php echo $pages-1; ?>&entry=<?php echo $entry; ?>">上一頁</a>
152 <a href="review_index_xml_images.php?books_id=<?php echo $books_id; ?>&pages=<?php echo $pages+1; ?>&entry=<?php echo $entry; ?>">下一頁</a></td>
153 </tr>
154 </table>
155
156 </body>
157 </html>