make.cgi 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/perl
  2. # This file is part of qorg11 blog
  3. # qorg11 blog is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. # qorg11 blog is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with qorg11 blog. If not, see <https://www.gnu.org/licenses/>.
  13. use CGI;
  14. use DateTime;
  15. use SQLite::DB;
  16. use POSIX;
  17. my $db = SQLite::DB->new("articles.sqlite");
  18. $db->connect;
  19. my $Time = time();
  20. my $date = strftime('%Y-%m-%dT%H:%M:%SZ', localtime($Time)), "\n";
  21. my $q = CGI->new;
  22. print $q->header;
  23. my $title = $q->param("title");
  24. my $content = $q->param("content");
  25. my $passwd = "..pIzZ9BCBKWY";
  26. if (crypt($q->param("passwd"),"$1......") ne $passwd) {
  27. print "Nope";
  28. die;
  29. }
  30. else {
  31. $db->exec("INSERT INTO blog (TITLE, CONTENT, DATE) VALUES (?, ?, ?)",$title, $content, $date) || print $db->get_error;
  32. }