예제 #1
0
<?php

include "system/external_construct_page.php";
$id = clear("id");
//nacteni dat o kategorii ------------------------------------------------------
$category = new category($pdo, $id);
if (!$category->id) {
    go_out();
}
$page = new page($pdo);
$page->add_description($category->description);
$page->header($category->title);
$page->footer();
예제 #2
0
 function save()
 {
     $text = clear("text");
     $add_comment = clear("add_comment");
     $del = clear("del");
     $edit_ok = clear("edit_ok");
     $edit_id = clear("edit_id");
     $is_spoiler = checkbox_value(clear("is_spoiler"));
     //pridavani prispevku
     if ($add_comment) {
         if (!$this->uid) {
             go_out();
         }
         if (!$text) {
             $this->msg->set_text($this->l->t("empty_comment"), "error");
             return 0;
         }
         //kontrola pripadne minimalni delky
         if ($this->short_posts != 'allowed') {
             $len = strlen(no_dia($text));
             if ($len < 100) {
                 $this->msg->set_text($this->l->t("short_comment", $len), "error");
                 $this->show_text = "yes";
                 return 0;
             }
         }
         //pokud jde o knihu, kontrola zda-li j*z nejaky komentar nevlozil
         if ($this->type == 'book' || $this->type == 'author' || $this->type == 'selfpublishing') {
             $sql = sql_query("select id from comments\n\t\t                              where (item = '" . $this->item . "'\n\t\t                              and type = '" . $this->type . "'\n\t\t                              and user = '******')");
             $data = sql_fetch_object($sql);
             if ($data->id) {
                 $this->msg->set_text($this->l->t("comment_exists"), "error");
                 $this->show_text = "yes";
                 return 0;
             }
         }
         //pokud jde o selfpublishing, kontrolujeme ze knihu koupil
         if ($this->type == 'selfpublishing') {
             if ($this->has_selfpublishing_bought()) {
                 $this->msg->set_text($this->l->t("not_bought"), "error");
                 $this->show_text = "yes";
                 return 0;
             }
         }
         $sql = sql_query("insert into comments\n                              (type, item, user, text, time, is_spoiler)\n                              values\n                              ('" . $this->type . "', '" . $this->item . "',\n                              '" . $this->uid . "', '" . $text . "', '" . time() . "', '" . $is_spoiler . "')");
         if ($sql) {
             //oznameni vsem kteri sleduji komentare
             $comment_id = mysql_insert_id();
             $this->msg->set_text($this->l->t("add_ok"));
             if ($this->type == 'book') {
                 $this->sent_notice($comment_id);
             }
             //pridame body
             add_points($this->uid, 3, 'comments');
         }
     }
     //mazani prispevku
     if ($del) {
         //kontrola zda-li je jeho a nenni starsi nez 24 hodin
         $sql = sql_query("select user, time\n                              from comments\n                              where (id = '{$del}')");
         $data = sql_fetch_object($sql);
         if ($data->user == $this->uid) {
             //mazani
             $sql = sql_query("delete from comments\n                                  where (id = '{$del}')");
             if ($sql) {
                 $this->msg->set_text($this->l->t("del_ok"));
                 //odebrani bodu
                 add_points($this->uid, -3, "comments");
             }
         }
     }
     //uprava prispevku
     if ($edit_ok) {
         //kontrola zda-li je jeho a nenni starsi nez 24 hodin
         $sql = sql_query("select user, time\n                              from comments\n                              where (id = '{$edit_id}')");
         $data = sql_fetch_object($sql);
         $time = time() - 24 * 3600;
         // && $time < $data->time - moznost mazani pouze 24 hodin po napsani prozatim zrusena
         if ($data->user == $this->uid) {
             if ($this->short_posts != 'allowed') {
                 $len = strlen(no_dia($text));
                 if ($len < 100) {
                     $this->msg->set_text($this->l->t("short_comment", $len), "error");
                     $this->show_text = "yes";
                     return 0;
                 }
             }
             //uprava
             $sql = sql_query("update comments\n                                  set text = '{$text}', is_spoiler = '{$is_spoiler}'\n                                  where (id = '{$edit_id}')");
             if ($sql) {
                 $this->msg->set_text($this->l->t("edit_ok"));
                 $this->show_text = '';
                 $_GET['edit'] = '';
             }
         }
     }
     //ulozeni / zruseni zasilani novych komentaru
     $notice_on = clear("notice_on");
     $notice_off = clear("notice_off");
     if ($notice_on && $this->type == 'book' && $this->uid) {
         //pripadne smazani kdyby slo o opakovany request
         $sql = sql_query("delete from comments_notice\n                              where (user = '******' and book = '" . $this->item . "')");
         $sql = sql_query("insert into comments_notice\n                              (user, book)\n                              values\n                              ('" . $this->uid . "', '" . $this->item . "')");
         if ($sql) {
             $this->msg->set_text($this->l->t("notice_on_msg"));
         }
     }
     if ($notice_off && $this->type == 'book' && $this->uid) {
         $sql = sql_query("delete from comments_notice\n                              where (user = '******' and book = '" . $this->item . "')");
         if ($sql) {
             $this->msg->set_text($this->l->t("notice_off_msg"));
         }
     }
 }