Mercurial > hg > LGSearch
comparison search_function.php @ 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 | 1cf7bb8db5dd |
comparison
equal
deleted
inserted
replaced
2:45cbafdec56e | 3:bc6ce492f15d |
---|---|
106 } | 106 } |
107 | 107 |
108 | 108 |
109 global $system_root_url, $server_host, $lgserver_url; | 109 global $system_root_url, $server_host, $lgserver_url; |
110 | 110 |
111 $fp=fopen("./search_results/".$filename.".html","w"); | 111 if ($fp=fopen("./search_results/".$filename.".html","w")) { |
112 fwrite($fp,$header); | 112 |
113 $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>"; | 113 //$fp=fopen("./search_results/".$filename.".html","w"); |
114 $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>"; | 114 fwrite($fp,$header); |
115 | 115 $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>"; |
116 $str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; | 116 $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>"; |
117 // $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; | 117 |
118 echo $str; | 118 fwrite($fp,$str); |
119 fwrite($fp,$str); | 119 $str.="<a href='".$system_root_url."search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; |
120 echo sizeof($array)." result(s) of \"".$keywordStr."\" "; | 120 // $str.="<a href='http://".$_SERVER['HTTP_HOST']."/LGSearch/search_results/".$filename.".html' target='_blank'>html version</a><br><br>"; |
121 fwrite($fp,sizeof($array)." result(s) of \"".$keywordStr."\"<br>"); | 121 echo $str; |
122 $str="<table>"; | 122 echo sizeof($array)." result(s) of \"".$keywordStr."\" "; |
123 $str.="<tr>"; | 123 fwrite($fp,sizeof($array)." result(s) of \"".$keywordStr."\"<br>"); |
124 $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"; | 124 $str="<table>"; |
125 fwrite($fp,$str); | 125 $str.="<tr>"; |
126 echo $str; | 126 $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"; |
127 $i=1; | |
128 foreach($array as $row){ | |
129 $str="<tr>"; | |
130 $str.="<td>".$i; | |
131 $str.="<td>".$row['BOOK_ID']; | |
132 $str.="<td>".$row['Name']; | |
133 $str.="<td>".$row['LEVEL1']; | |
134 $str.="<td>".$row['LEVEL2']; | |
135 $str.="<td>".$row['PERIOD']; | |
136 $str.="<td>"; | |
137 fwrite($fp,$str); | 127 fwrite($fp,$str); |
138 echo $str; | 128 echo $str; |
139 foreach($row['SECTION'] as $section){ | 129 $i=1; |
140 | 130 foreach($array as $row){ |
141 $str="<div class='section'><a>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; | 131 $str="<tr>"; |
132 $str.="<td>".$i; | |
133 $str.="<td>".$row['BOOK_ID']; | |
134 $str.="<td>".$row['Name']; | |
135 $str.="<td>".$row['LEVEL1']; | |
136 $str.="<td>".$row['LEVEL2']; | |
137 $str.="<td>".$row['PERIOD']; | |
138 $str.="<td>"; | |
139 fwrite($fp,$str); | |
142 echo $str; | 140 echo $str; |
143 /* | 141 foreach($row['SECTION'] as $section){ |
144 // redirect to LGServer? | 142 |
145 $str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; | 143 $str="<div class='section'><a>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; |
144 echo $str; | |
145 /* | |
146 // redirect to LGServer? | |
147 $str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; | |
148 echo $str; | |
149 $str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; | |
150 */ | |
151 /* origial | |
152 $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>"; | |
153 echo $str; | |
154 $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>"; | |
155 */ | |
156 fwrite($fp,$str); | |
157 } | |
158 $str="<td>".$row['PAGE']; | |
159 if($tag==$NO_TAG){ | |
160 $str.="<td>".$row['CONTENT']; | |
161 }else if($tag==$LOCUST_TEMPLE){ | |
162 $str.="<td>".findLocustTempleDescription($row['CONTENT'],$keywordArray,0); | |
163 } | |
164 fwrite($fp,$str); | |
146 echo $str; | 165 echo $str; |
147 $str="<div class='section'><a href='".$lgserver_url."' target='_blank'>".$section['name']."</a>p".$section['start_page']."-".$section['end_page']."</div>"; | 166 $i++; |
148 */ | 167 } |
149 /* origial | 168 |
150 $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>"; | 169 echo "</table>"; |
151 echo $str; | 170 fwrite($fp,"</table></body></html>"); |
152 $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>"; | 171 fclose($fp); |
153 */ | 172 |
154 fwrite($fp,$str); | 173 } else { |
155 } | 174 error_log("error when opening file: "."./search_results/".$filename.".html" ,0); |
156 $str="<td>".$row['PAGE']; | 175 } |
157 if($tag==$NO_TAG){ | |
158 $str.="<td>".$row['CONTENT']; | |
159 }else if($tag==$LOCUST_TEMPLE){ | |
160 $str.="<td>".findLocustTempleDescription($row['CONTENT'],$keywordArray,0); | |
161 } | |
162 fwrite($fp,$str); | |
163 echo $str; | |
164 $i++; | |
165 } | |
166 | |
167 echo "</table>"; | |
168 fwrite($fp,"</table></body></html>"); | |
169 fclose($fp); | |
170 } | 176 } |
171 | 177 |
172 function findLocustTempleDescription($str,$keywordArray,$findUnknownTemple){ | 178 function findLocustTempleDescription($str,$keywordArray,$findUnknownTemple){ |
173 $result=""; | 179 $result=""; |
174 $pattern[0]="/(.*)("; | 180 $pattern[0]="/(.*)("; |
207 | 213 |
208 function writeCsvFile($array,$fileName){ | 214 function writeCsvFile($array,$fileName){ |
209 $columnNameArray=['BOOK_ID','LEVEL1','LEVEL2', | 215 $columnNameArray=['BOOK_ID','LEVEL1','LEVEL2', |
210 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','PAGE','SECTION','CONTENT', | 216 'Name','PERIOD','TimeSpan:begin','TimeSpan:end','PAGE','SECTION','CONTENT', |
211 'Description']; | 217 'Description']; |
212 $fp=fopen("./csv_files/".$fileName.".csv","w"); | 218 if( $fp=fopen("./csv_files/".$fileName.".csv","w")) { |
213 fputcsv($fp,$columnNameArray); | 219 // $fp=fopen("./csv_files/".$fileName.".csv","w"); |
214 foreach($array as $row){ | 220 fputcsv($fp,$columnNameArray); |
215 $book=array(); | 221 foreach($array as $row){ |
216 $row['Description']=''; | 222 $book=array(); |
217 foreach($columnNameArray as $column){ | 223 $row['Description']=''; |
218 $book[$column]=$row[$column]; | 224 foreach($columnNameArray as $column){ |
219 } | 225 $book[$column]=$row[$column]; |
220 $book['Name']="(".$row['PERIOD'].") ".$row['Name']; | 226 } |
221 $row['AUTHOR']=str_replace("(","(",$row['AUTHOR']); | 227 $book['Name']="(".$row['PERIOD'].") ".$row['Name']; |
222 $row['AUTHOR']=str_replace(")",") ",$row['AUTHOR']); | 228 $row['AUTHOR']=str_replace("(","(",$row['AUTHOR']); |
223 $book['Description']=$row['VOLUME']." ╱ ".$row['AUTHOR']." ╱ ".$row['EDITION']; | 229 $row['AUTHOR']=str_replace(")",") ",$row['AUTHOR']); |
224 $book['SECTION']=''; | 230 $book['Description']=$row['VOLUME']." ╱ ".$row['AUTHOR']." ╱ ".$row['EDITION']; |
225 foreach($row['SECTION'] as $idx=>$section){ | 231 $book['SECTION']=''; |
226 $book['SECTION'].=$section['name']." ".$section['start_page']."-".$section['end_page']; | 232 foreach($row['SECTION'] as $idx=>$section){ |
227 if($idx!=sizeof($row['SECTION'])){ | 233 $book['SECTION'].=$section['name']." ".$section['start_page']."-".$section['end_page']; |
228 $book['SECTION'].=" ╱ "; | 234 if($idx!=sizeof($row['SECTION'])){ |
229 } | 235 $book['SECTION'].=" ╱ "; |
230 } | 236 } |
231 fputcsv($fp,$book); | 237 } |
232 } | 238 fputcsv($fp,$book); |
233 fclose($fp); | 239 } |
240 fclose($fp); | |
241 | |
242 } else { | |
243 error_log("error when opening file: "."./csv_files/".$fileName.".csv", 0); | |
244 } | |
234 } | 245 } |
235 | 246 |
236 ?> | 247 ?> |
237 | 248 |