index.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <link type="text/css" rel="stylesheet" href="../studio/css/font.css"/>
  7. <link type="text/css" rel="stylesheet" href="../studio/css/style.css"/>
  8. <link type="text/css" rel="stylesheet" href="../studio/css/color_day.css" id="colorchange" />
  9. <style>
  10. .toc_1{
  11. padding-left:0;
  12. }
  13. .toc_2{
  14. padding-left:1em;
  15. }
  16. .toc_3{
  17. padding-left:2em;
  18. }
  19. .toc_4{
  20. padding-left:3em;
  21. }
  22. .nimbus-is-editor{
  23. background-color: var(--tool-bg-color);
  24. color: white;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <?php require_once '../lang/lang.php'; ?>
  30. <?php
  31. require_once "../public/_pdo.php";
  32. require_once "../path.php";
  33. require_once "../public/load_lang.php";
  34. if(isset($_GET["language"])){
  35. $language=$_GET["language"];
  36. }
  37. else{
  38. $language="en";
  39. }
  40. include "./language/".$language.".php";
  41. echo "{$language}<br>";
  42. $toc=array();
  43. if(($handle=fopen("./book_index_".$language.".csv",'r'))!==FALSE){
  44. while(($data=fgetcsv($handle,0,','))!==FALSE){
  45. array_push($toc,$data);
  46. if($data[2]>0){
  47. $bookid=$data[2];
  48. $toc_book["$bookid"]=$data[1];
  49. }
  50. }
  51. }
  52. echo "<h2>";
  53. echo $gui['word_analysis'];
  54. echo "</h2>";
  55. if(isset($_GET["spell"])){
  56. $spell=$_GET["spell"];
  57. }
  58. else{
  59. $spell="";
  60. }
  61. if(isset($_GET["wordop"])){
  62. $wordop=$_GET["wordop"];
  63. if(isset($_GET["spell"]) && $_GET["spell"]!="" && $wordop="end"){
  64. $spell="%".$_GET["spell"];
  65. $wordop="like";
  66. }
  67. else if(isset($_GET["spell"]) && $_GET["spell"]!="" && $wordop="begin"){
  68. $spell=$_GET["spell"]."%";
  69. $wordop="like";
  70. }
  71. else{
  72. $spell="";
  73. }
  74. }
  75. else{
  76. $wordop="=";
  77. }
  78. if(!isset($_GET["groupby"])){
  79. ?>
  80. <form action="index.php" method="get">
  81. <input type="hidden" name="language" value="<?php echo $language ?>" />
  82. <?php echo $gui['spell'] ?>:
  83. <select name="wordop">
  84. <option value="like" ><?php echo $gui['like'] ?></option>
  85. <option value="end" ><?php echo $gui['end_with'] ?></option>
  86. <option value="begin" ><?php echo $gui['begin_with'] ?></option>
  87. </select>
  88. <input type="text" name="spell" value="" style="width: auto;" placeholder=<?php echo $gui['empty'] ?> /><br>
  89. <?php echo $gui['group_by'] ?>:
  90. <select name="groupby">
  91. <option value="base" ><?php echo $gui['base'] ?></option>
  92. <option value="word" ><?php echo $gui['spell'] ?></option>
  93. <option value="end1" ><?php echo $gui['ending_1'] ?></option>
  94. <option value="end2" ><?php echo $gui['ending_2'] ?></option>
  95. </select>
  96. <input type="submit" value="<?php echo $gui['submit'] ?>"><br>
  97. <br>
  98. <?php
  99. $arrlength=count($toc);
  100. echo "<ul>";
  101. for($x=0;$x<$arrlength;$x++) {
  102. echo "<li class='toc_".$toc[$x][0]."'><input type='checkbox' name='".$toc[$x][2]."' onchange=\"chk_change(this)\" checked />".$toc[$x][1]."</li>";
  103. }
  104. echo "</ul>";
  105. ?>
  106. <input type="submit">
  107. </form>
  108. <?php
  109. return;
  110. }
  111. $groupby=$_GET["groupby"];
  112. echo "<a href='index.php?language=$language'>".$gui['home']."</a><br>";
  113. echo $gui['your_choice'].":</br>";
  114. $boolList=array();
  115. for($i=1;$i<218;$i++){
  116. if(isset($_GET["$i"])){
  117. if($_GET["$i"]=="on"){
  118. array_push($boolList,"$i");
  119. echo $toc_book["$i"]."; ";
  120. }
  121. }
  122. }
  123. echo "</br>";
  124. $countInsert=0;
  125. $wordlist=array();
  126. $db_file = _FILE_DB_STATISTICS_;
  127. $bookstring="";
  128. for($i=0;$i<count($boolList);$i++)
  129. {
  130. $bookstring.="'".$boolList[$i]."'";
  131. if($i<count($boolList)-1){
  132. $bookstring.=",";
  133. }
  134. }
  135. //open database
  136. PDO_Connect("sqlite:$db_file");
  137. if($spell==""){
  138. echo("<h3>".$gui['group_by'].":$groupby</h3>");
  139. $query = "SELECT count(*) FROM \"word\" WHERE (bookid in (".$bookstring.")) ";/*查總數*/
  140. $count_word=PDO_FetchOne($query);
  141. $query = "SELECT sum(count) FROM \"word\" WHERE (bookid in (".$bookstring.")) ";/*查總數,并分類匯總*/
  142. $sum_word=PDO_FetchOne($query);
  143. $query = "select count(*) from (SELECT count() FROM \"word\" WHERE (bookid in (".$bookstring.") and $groupby<>'') group by $groupby )";/*查總數,并分類匯總*/
  144. $count_parent=PDO_FetchOne($query);
  145. $query = "select sum(length) from (SELECT * FROM \"word\" WHERE (bookid in (".$bookstring.") and $groupby<>'') group by $groupby )";/*查總數,并分類匯總*/
  146. $count_parent1=PDO_FetchOne($query);
  147. $query = "SELECT sum(count) FROM \"word\" WHERE (bookid in (".$bookstring.") and $groupby<>'') ";/*查總數,并分類匯總*/
  148. $sum_parent=PDO_FetchOne($query);
  149. $format=number_format($count_word);
  150. echo $gui['vacab'].":$format<br>";
  151. echo $gui['word_count'].":".number_format($sum_word)."<br> ";
  152. echo "<b>$groupby</b>".$gui['statistics'].":".number_format($count_parent)."<br> ";
  153. echo "<b>$groupby</b>字母".$gui['statistics'].":".number_format($count_parent1)."<br> ";
  154. echo $gui['effective'].":".number_format($sum_parent)." <br>";
  155. $query = "select * from (SELECT $groupby,sum(count) as wordsum FROM \"word\" WHERE (bookid in (".$bookstring.") and $groupby<>'') group by $groupby) order by wordsum DESC limit 0 ,4000";/*查總數,并分類匯總*/
  156. $Fetch = PDO_FetchAll($query);
  157. $iFetch=count($Fetch);
  158. echo "<table>";
  159. echo "<th>".$gui['serial_num']."</th><th>$groupby</th><th>".$gui['count']."</th><th>".$gui['percentage']."</th><th>".$gui['accumulative']."</th>";
  160. $sum_prsent=0;
  161. if($iFetch>0){
  162. $sum=$Fetch[0]["wordsum"];
  163. $first=$sum*100/$sum_word;
  164. for($i=0;$i<$iFetch;$i++){
  165. $sum=$Fetch[$i]["wordsum"];
  166. $prsent=$sum*100/$sum_word;
  167. $prsent1=$prsent*100/$first;
  168. $sum_prsent+=$prsent;
  169. echo "<tr>";
  170. echo "<td>".($i+1)."</td><td>".$Fetch[$i][$groupby]."</td><td>".number_format($sum)."</td><td><span style='width:".$prsent1."px;background-color:red;'></span><span style:'width:".(100-$prsent1)."px;background-color: var(--tool-link-hover-color);'></span>".number_format($prsent,3)."</td><td>".number_format($sum_prsent,1)."</td>";
  171. echo "</tr>";
  172. }
  173. }
  174. echo "</table>";
  175. }
  176. else{
  177. echo("<h3>Word: <spen style='color: var(--tool-link-hover-color);'>$spell</spen></h3>");
  178. $newSpell=$PDO->quote($spell);
  179. $query = "SELECT count(*) FROM \"word\" WHERE (word $wordop $newSpell) ";/*查總词數*/
  180. $count_word=PDO_FetchOne($query);
  181. $query = "SELECT sum(count) FROM \"word\" WHERE (word $wordop $newSpell) ";/*查總數,并分類匯總*/
  182. $sum_word=PDO_FetchOne($query);
  183. echo "单词总个数:".number_format($count_word)."<br>";
  184. echo "单词总数:".number_format($sum_word)."<br>";
  185. $query = "select count(*) from (SELECT bookid FROM \"word\" WHERE (word $wordop $newSpell) group by bookid) ";/*查總數,并分類匯總*/
  186. $in_book_count=PDO_FetchOne($query);
  187. echo "<p>In $in_book_count Books</p>";
  188. $query = "select bookid,co,su from (SELECT bookid,sum(count) as su,count(*) co FROM \"word\" WHERE (word $wordop $newSpell) group by bookid) order by co DESC limit 0 ,20";/*查總數,并分類匯總*/
  189. $Fetch = PDO_FetchAll($query);
  190. $iFetch=count($Fetch);
  191. echo "<table>";
  192. echo "<th>序号</th><th>Book</th><th>单词个数</th><th>单词数量</th>";
  193. if($iFetch>0){
  194. for($i=0;$i<$iFetch;$i++){
  195. echo "<tr>";
  196. echo "<td>".($i+1)."</td><td>".$toc_book[$Fetch[$i]["bookid"]]."</td><td>".number_format($Fetch[$i]["co"])."</td><td>".number_format($Fetch[$i]["su"])."</td>";
  197. echo "</tr>";
  198. }
  199. }
  200. echo "</table>";
  201. $query = "select count(*) from (SELECT bookid FROM \"word\" WHERE (word $wordop $newSpell) group by word) ";/*查總數,并分類匯總*/
  202. $word_count=PDO_FetchOne($query);
  203. echo "<p>$word_count Words</p>";
  204. $query = "select word,co from (SELECT word,sum(count) co FROM \"word\" WHERE (word $wordop $newSpell) group by word) order by co DESC limit 0 ,100";/*查總數,并分類匯總*/
  205. $Fetch = PDO_FetchAll($query);
  206. $iFetch=count($Fetch);
  207. echo "<table>";
  208. echo "<th>序号</th><th>Word</th><th>数量</th>";
  209. if($iFetch>0){
  210. for($i=0;$i<$iFetch;$i++){
  211. echo "<tr>";
  212. echo "<td>".($i+1)."</td><td>".$Fetch[$i]["word"]."</td><td>".number_format($Fetch[$i]["co"])."</td>";
  213. echo "</tr>";
  214. }
  215. }
  216. echo "</table>";
  217. }
  218. /*查询结束*/
  219. ?>
  220. </body>
  221. </html>