Mercurial > hg > extraction-interface
view 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 |
line wrap: on
line source
<?php header("Content-Type: text/html;charset=utf-8"); /** * "Lib_mb_utf8.php" is a set of common functions used to convert encode of text * "config.php" containing a system name variable. Please make it the same as the system's folder name. */ include_once('Lib_mb_utf8.php'); include_once('config.php'); //Path to the photos DIR $imagePath="E:/images02/"; if (isset($_GET['books_id'])) { $books_id = $_GET['books_id']; } if (isset($_GET['pages'])) { $pages = $_GET['pages']; if ( $pages==0 ) $pages=1; } if (isset($_GET['entry'])) { $entry = $_GET['entry']; } if (isset($_GET['JSESSIONID'])) { $JSESSIONID = $_GET['JSESSIONID']; } 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; } } $query = sprintf("SELECT `content` FROM `contents` WHERE `books_id`=\"%s\" AND `line`=%d", $books_id, $pages); $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $contentString=$row['content']; } $contentString = preg_replace("/".$entry."/u", "<font color=\"#FF0000\">\\0</font>", $contentString); $pagesImg = sprintf("%04d", $pages); if ( !file_exists($imagePath.$books_id."/") ) { mkdir($imagePath.$books_id."/"); } if ( ! file_exists($imagePath.$books_id."/".$pagesImg.".jpg") ) { $options = array( 'http' => array( 'header' => "Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Connection:keep-alive Cookie:".file_get_contents("../cookie.txt")." Host:server.wenzibase.com Referer:http://server.wenzibase.com/userReadAction.action?prId=42&page=fangzhi User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36", 'method' => 'GET', ), ); $context = stream_context_create($options); $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); $resultGet = file_get_contents($url, false, $context); file_put_contents(sprintf($imagePath."/%s/%04d.jpg",$books_id,$pages), $resultGet); /* $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); $resultGet = file_get_contents($url, false, $context); $resultGet = preg_replace('/\A(.*?)(\\x47\\x49\\x46\\x38)/', "\\2", $resultGet); file_put_contents(sprintf("images01/%s/%04da.gif",$bookId,$pageNum), $resultGet); $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); $resultGet = file_get_contents($url, false, $context); $resultGet = preg_replace('/\A(.*?)(\\x47\\x49\\x46\\x38)/', "\\2", $resultGet); file_put_contents(sprintf($imagePath."/%s/%04da.gif",$books_id,$pages), $resultGet); */ } ?> <html> <head> <title> </title> <script src="./jquery-1.10.2.min.js"></script> <script type="text/javascript"> function selectTextboxContent(textbox) { setTimeout(function() { textbox.select(); }, 10); } </script> </head> <body> <table border="1" width="1000"> <tr> <td colspan="2" align="center"> <a href="review_index_xml_images.php?books_id=<?php echo $books_id; ?>&pages=<?php echo $pages-1; ?>&entry=<?php echo $entry; ?>">上一頁</a> <input onfocus="selectTextboxContent(this)" type="text" id="txt1" name="txt1" value="<?php echo $pages; ?>" size="5"> <a href="review_index_xml_images.php?books_id=<?php echo $books_id; ?>&pages=<?php echo $pages+1; ?>&entry=<?php echo $entry; ?>">下一頁</a> </td> </tr> <tr> <td width="500"><img src="/images01/<?php echo $books_id; ?>/<?php echo $pagesImg; ?>.jpg" width="100%"></td> <td width="500"><img src="/images01/<?php echo $books_id; ?>/<?php echo $pagesImg; ?>a.gif" width="100%"></td> </tr> <tr> <td>Entry: <?php echo $entry; ?></br>Page: <input onfocus="selectTextboxContent(this)" type="text" id="txt2" name="txt2" value="<?php echo $pages; ?>"></td> <td><?php echo $contentString; ?></td> </tr> <tr> <td colspan="2" align="center"> <a href="review_index_xml_images.php?books_id=<?php echo $books_id; ?>&pages=<?php echo $pages-1; ?>&entry=<?php echo $entry; ?>">上一頁</a> <a href="review_index_xml_images.php?books_id=<?php echo $books_id; ?>&pages=<?php echo $pages+1; ?>&entry=<?php echo $entry; ?>">下一頁</a></td> </tr> </table> </body> </html>