changeset 3:bc6ce492f15d

add passwd in search page, php error log
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 25 Jun 2015 17:43:28 +0200
parents 45cbafdec56e
children c3c31d031945
files config/config.php search.php search_function.php
diffstat 3 files changed, 99 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/config/config.php	Wed Mar 25 16:03:54 2015 +0100
+++ b/config/config.php	Thu Jun 25 17:43:28 2015 +0200
@@ -8,17 +8,17 @@
 	$mysql_server = "localhost";
 	$mysql_user = "root";
 	$mysql_password = "admin";
-	$server_host = "http://localgazetteers-dev/";
-	$lgserver_url = $server_host."LGServer/";
+	$server_host = "http://localgazetteers.mpiwg-berlin.mpg.de/";
+	$lgserver_url = $server_host."LGServices/";
 
 } else {
 	// localhost
-	$mysql_database = "Gazetteers";
+	$mysql_database = "Gazetteer";
 	$mysql_server = "localhost";
 	$mysql_user = "root";
 	$mysql_password = "root";
 	$server_host = "http://localhost:1080/localgazetteers-dev/";
-	$lgserver_url = "http://localgazetteers-dev/LGServer/";
+	$lgserver_url = "http://localgazetteers-dev/LGServices/";
 
 }
 
--- a/search.php	Wed Mar 25 16:03:54 2015 +0100
+++ b/search.php	Thu Jun 25 17:43:28 2015 +0200
@@ -1,9 +1,7 @@
 <?php
-
 include_once('config/Lib_mb_utf8.php');
 include_once('config/config.php');
 include_once('search_function.php');
-
 ?>
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
@@ -15,6 +13,16 @@
 		<script src="search.js" charset="utf-8"></script>
 	</head>
 	<body>
+		<script type="text/javascript">
+			// prompt to ask the password when open page
+		    var password = "3333";
+		    var string = prompt("Please enter password", "");
+		    if(string!=password) {
+		        alert("Wrong password!");
+		        window.location="http://localgazetteers.mpiwg-berlin.mpg.de";
+		    }
+    	</script>
+
 		<form action='search.php' method='POST'>
 			關鍵字: <input type="text" name="keyword" size="100"> (若要搜尋多筆關鍵字請用半型逗號,隔開)<br>
 			將結果輸出至: <input type="text" name="filename" size="40">.html (請用英文非空白字元命名)<br>
--- a/search_function.php	Wed Mar 25 16:03:54 2015 +0100
+++ b/search_function.php	Thu Jun 25 17:43:28 2015 +0200
@@ -108,65 +108,71 @@
 
 	global $system_root_url, $server_host, $lgserver_url;
 
-	$fp=fopen("./search_results/".$filename.".html","w");
-	fwrite($fp,$header);
-    $str="<a href='".$server_host."LGMap/get_coordinates_for_listed_books.php?file=".$filename.".csv&name=".$keywordStr."' target='_blank'>view the distribution on the map (click here at the first time)</a><br><br>";
-    $str.="<a href='".$server_host."LGMap/map.php?mode=1&file=".$filename.".csv&name=".$keywordStr."' target='_blank'>view the distribution on the map</a><br><br>";
+	if ($fp=fopen("./search_results/".$filename.".html","w")) {
+
+		//$fp=fopen("./search_results/".$filename.".html","w");
+		fwrite($fp,$header);
+	    $str="<a href='".$server_host."LGMap/get_coordinates_for_listed_books.php?file=".$filename.".csv&name=".$keywordStr."' target='_blank'>view the distribution on the map (click here at the first time)</a><br><br>";
+	    $str.="<a href='".$server_host."LGMap/map.php?mode=1&file=".$filename.".csv&name=".$keywordStr."' target='_blank'>view the distribution on the map</a><br><br>";
 
-	$str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>";
-	// $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>";
-	echo $str;
-	fwrite($fp,$str);
-	echo sizeof($array)." result(s) of \"".$keywordStr."\" ";
-	fwrite($fp,sizeof($array)." result(s) of \"".$keywordStr."\"<br>");
-	$str="<table>";
-	$str.="<tr>";
-	$str.="<td class='sequence'>#<td class='bookId'>book id<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2<td class='period'>period<td class='sectionName'>section info<td class='page'>page<td class='content'>content";
-	fwrite($fp,$str);
-	echo $str;
-	$i=1;
-	foreach($array as $row){
-		$str="<tr>";
-		$str.="<td>".$i;
-		$str.="<td>".$row['BOOK_ID'];
-		$str.="<td>".$row['Name'];
-		$str.="<td>".$row['LEVEL1'];
-		$str.="<td>".$row['LEVEL2'];
-		$str.="<td>".$row['PERIOD'];
-		$str.="<td>";
+		fwrite($fp,$str);
+		$str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>";
+		// $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>";
+		echo $str;
+		echo sizeof($array)." result(s) of \"".$keywordStr."\" ";
+		fwrite($fp,sizeof($array)." result(s) of \"".$keywordStr."\"<br>");
+		$str="<table>";
+		$str.="<tr>";
+		$str.="<td class='sequence'>#<td class='bookId'>book id<td class='bookName'>book name<td class='level1'>level1<td class='level2'>level2<td class='period'>period<td class='sectionName'>section info<td class='page'>page<td class='content'>content";
 		fwrite($fp,$str);
 		echo $str;
-		foreach($row['SECTION'] as $section){
-
-			$str="<div class='section'><a>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
-			echo $str;
-			/*
-			// redirect to LGServer?
-			$str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
-			echo $str;
-			$str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
-			*/
-			/* origial
-			$str="<div class='section'><a href='/interface/tagging_text.php?id=".$section['id']."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
-			echo $str;
-			$str="<div class='section'><a href='/interface/tagging_text.php?id=".$section['id']."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
-			*/
+		$i=1;
+		foreach($array as $row){
+			$str="<tr>";
+			$str.="<td>".$i;
+			$str.="<td>".$row['BOOK_ID'];
+			$str.="<td>".$row['Name'];
+			$str.="<td>".$row['LEVEL1'];
+			$str.="<td>".$row['LEVEL2'];
+			$str.="<td>".$row['PERIOD'];
+			$str.="<td>";
 			fwrite($fp,$str);
-		}
-		$str="<td>".$row['PAGE'];
-		if($tag==$NO_TAG){
-			$str.="<td>".$row['CONTENT'];
-		}else if($tag==$LOCUST_TEMPLE){
-			$str.="<td>".findLocustTempleDescription($row['CONTENT'],$keywordArray,0);
+			echo $str;
+			foreach($row['SECTION'] as $section){
+
+				$str="<div class='section'><a>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
+				echo $str;
+				/*
+				// redirect to LGServer?
+				$str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
+				echo $str;
+				$str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
+				*/
+				/* origial
+				$str="<div class='section'><a href='/interface/tagging_text.php?id=".$section['id']."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
+				echo $str;
+				$str="<div class='section'><a href='/interface/tagging_text.php?id=".$section['id']."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>";
+				*/
+				fwrite($fp,$str);
+			}
+			$str="<td>".$row['PAGE'];
+			if($tag==$NO_TAG){
+				$str.="<td>".$row['CONTENT'];
+			}else if($tag==$LOCUST_TEMPLE){
+				$str.="<td>".findLocustTempleDescription($row['CONTENT'],$keywordArray,0);
+			}
+			fwrite($fp,$str);
+			echo $str;
+			$i++;
 		}
-		fwrite($fp,$str);
-		echo $str;
-		$i++;
+
+		echo "</table>";
+		fwrite($fp,"</table></body></html>");
+		fclose($fp);
+
+	} else {
+		error_log("error when opening file: "."./search_results/".$filename.".html" ,0);
 	}
-
-	echo "</table>";
-	fwrite($fp,"</table></body></html>");
-	fclose($fp);
 }
 
 function findLocustTempleDescription($str,$keywordArray,$findUnknownTemple){
@@ -209,28 +215,33 @@
 	$columnNameArray=['BOOK_ID','LEVEL1','LEVEL2',
         	'Name','PERIOD','TimeSpan:begin','TimeSpan:end','PAGE','SECTION','CONTENT',
         	'Description'];
-	$fp=fopen("./csv_files/".$fileName.".csv","w");
-	fputcsv($fp,$columnNameArray);
-	foreach($array as $row){
-		$book=array();
-		$row['Description']='';
-		foreach($columnNameArray as $column){
-			$book[$column]=$row[$column];
+    if( $fp=fopen("./csv_files/".$fileName.".csv","w")) {
+		// $fp=fopen("./csv_files/".$fileName.".csv","w");
+		fputcsv($fp,$columnNameArray);
+		foreach($array as $row){
+			$book=array();
+			$row['Description']='';
+			foreach($columnNameArray as $column){
+				$book[$column]=$row[$column];
+			}
+			$book['Name']="(".$row['PERIOD'].") ".$row['Name'];
+	        	$row['AUTHOR']=str_replace("(","(",$row['AUTHOR']);
+	        	$row['AUTHOR']=str_replace(")",") ",$row['AUTHOR']);
+	        	$book['Description']=$row['VOLUME']." ╱ ".$row['AUTHOR']." ╱ ".$row['EDITION'];
+			$book['SECTION']='';
+			foreach($row['SECTION'] as $idx=>$section){
+				$book['SECTION'].=$section['name']." ".$section['start_page']."-".$section['end_page'];
+				if($idx!=sizeof($row['SECTION'])){
+					$book['SECTION'].=" ╱ ";
+				}
+			}
+			fputcsv($fp,$book);
 		}
-		$book['Name']="(".$row['PERIOD'].") ".$row['Name'];
-        	$row['AUTHOR']=str_replace("(","(",$row['AUTHOR']);
-        	$row['AUTHOR']=str_replace(")",") ",$row['AUTHOR']);
-        	$book['Description']=$row['VOLUME']." ╱ ".$row['AUTHOR']." ╱ ".$row['EDITION'];
-		$book['SECTION']='';
-		foreach($row['SECTION'] as $idx=>$section){
-			$book['SECTION'].=$section['name']." ".$section['start_page']."-".$section['end_page'];
-			if($idx!=sizeof($row['SECTION'])){
-				$book['SECTION'].=" ╱ ";
-			}
-		}
-		fputcsv($fp,$book);
-	}
-	fclose($fp);
+		fclose($fp);
+
+	} else {
+    	error_log("error when opening file: "."./csv_files/".$fileName.".csv", 0);
+    }	
 }
 
 ?>