2
0

dighest.php 3.2 KB

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