dighest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. include "./config.php";
  3. include "./_pdo.php";
  4. if(isset($_POST["title"])){
  5. $title=$_POST["title"];
  6. }
  7. else{
  8. echo "no title";
  9. exit;
  10. }
  11. if(isset($_POST["summary"])){
  12. $summary=$_POST["summary"];
  13. }
  14. else{
  15. echo "no summary";
  16. exit;
  17. }
  18. if(isset($_POST["tag"])){
  19. $tag=$_POST["tag"];
  20. }
  21. else{
  22. echo "no tag";
  23. exit;
  24. }
  25. if(isset($_POST["data"])){
  26. $data=$_POST["data"];
  27. }
  28. else{
  29. echo "no data";
  30. exit;
  31. }
  32. $db_file = $dir_palicannon.'dighest.db3';
  33. PDO_Connect("sqlite:$db_file");
  34. // 开始一个事务,关闭自动提交
  35. $PDO->beginTransaction();
  36. $query="INSERT INTO dighest_index ('id','title','summary','tag','user','time') VALUES (NULL,?,?,?,?,?)";
  37. $stmt = $PDO->prepare($query);
  38. $newData=array($title,$summary,$tag,4,time());
  39. $stmt->execute($newData);
  40. // 提交更改
  41. $PDO->commit();
  42. if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
  43. $error = PDO_ErrorInfo();
  44. echo "error - $error[2] <br>";
  45. }
  46. else{
  47. }
  48. //获取刚刚插入的书摘记录的索引号
  49. $new_index=$PDO->lastInsertId();
  50. // 开始一个事务,关闭自动提交
  51. $PDO->beginTransaction();
  52. $query="INSERT INTO dighest ('id','index_id','album','book','paragraph') VALUES (NULL,?,?,?,?)";
  53. $stmt = $PDO->prepare($query);
  54. $dighest_par_array=str_getcsv($data);
  55. $first_album=-1;
  56. $first_book=-1;
  57. $first_paragraph=-1;
  58. foreach($dighest_par_array as $value){
  59. $one_recorder=str_getcsv($value,"-");
  60. if(count($one_recorder)>=3){
  61. if($first_album==-1){
  62. $first_album=$one_recorder[0];
  63. $first_book=$one_recorder[1];
  64. $first_paragraph=$one_recorder[2];
  65. }
  66. $newData=array($new_index,$one_recorder[0],$one_recorder[1],$one_recorder[2]);
  67. $stmt->execute($newData);
  68. }
  69. }
  70. // 提交更改
  71. $PDO->commit();
  72. if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
  73. $error = PDO_ErrorInfo();
  74. echo "error - $error[2] <br>";
  75. }
  76. else{
  77. }
  78. //更新索引数据库
  79. $db_file = _FILE_DB_RESRES_INDEX_;
  80. PDO_Connect("sqlite:$db_file");
  81. // 开始一个事务,关闭自动提交
  82. $PDO->beginTransaction();
  83. $query="INSERT INTO 'index' ('id','book','paragraph','level','type','language','title','author','editor','edition','share','album','update_time') VALUES (NULL,?,?,?,?,?,?,?,?,?,?,?,?)";
  84. $stmt = $PDO->prepare($query);
  85. $newData = array($first_book,$first_paragraph,$new_index,'dighest','sc',$title,4,4,1,4,$first_album,time());
  86. $stmt->execute($newData);
  87. // 提交更改
  88. $PDO->commit();
  89. if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
  90. $error = PDO_ErrorInfo();
  91. echo "error - $error[2] <br>";
  92. }
  93. else{
  94. }
  95. //更新tag数据库
  96. $db_file = _FILE_DB_RESRES_INDEX_;
  97. PDO_Connect("sqlite:$db_file");
  98. // 开始一个事务,关闭自动提交
  99. $PDO->beginTransaction();
  100. $query="INSERT INTO 'tag' ('id','book','paragraph','title','summary','tag','language','author','time') VALUES (NULL,?,?,?,?,?,?,?,?)";
  101. $stmt = $PDO->prepare($query);
  102. $newData=array(1024,$new_index,$title,$summary,$tag,'sc',1,time());
  103. $stmt->execute($newData);
  104. // 提交更改
  105. $PDO->commit();
  106. if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
  107. $error = PDO_ErrorInfo();
  108. echo "error - $error[2] <br>";
  109. }
  110. else{
  111. }
  112. ?>