public function save($id_person, $lock)
 {
     $this->dbh->TransactionBegin();
     if ($this->metaRequests->existsNewMetaRequest($this->course_id, $this->typ_poziadavky, $lock)) {
         // je potrebne zrusit transakciu inac bude tabulka zablokovana stale
         $this->dbh->TransactionRollback();
         // vyhod exception aby user vedel ze sa stranka modifikovala
         throw new RequestModified();
     }
     // najprv uloz metapoziadavku
     $sql = "INSERT INTO meta_poziadavka (id_predmet, id_osoba, id_poziadavka_typ, cas_pridania)\n        \t VALUES(\$1, \$2, \$3, now())";
     $this->dbh->query($sql, array($this->course_id, $id_person, $this->typ_poziadavky));
     $metaPoziadavkaID = $this->dbh->GetLastInsertID();
     // uloz komentare (posledny parameter
     Comments::saveComment($metaPoziadavkaID, $this->requirement['komentare']['vseobecne'], 1, $id_person);
     Comments::saveComment($metaPoziadavkaID, $this->requirement['komentare']['sw'], 2, $id_person);
     // update komentarov k diskusii, tak aby boli naviazane na najnovsiu poziadavku
     // update vykonat, len ak sme prave nepreberali poziadavku z minuleho roka  ( vtedy by bolo $this->poziadavka_prebrata == 1)
     if (!$this->poziadavka_prebrata) {
         Comments::updateComments($metaPoziadavkaID, $this->previousMetaID);
     }
     // nasledne uloz rozlozenia
     foreach ($this->requirement["layouts"] as $layout) {
         $this->__saveLayout($layout, $id_person, $metaPoziadavkaID);
     }
     $this->dbh->TransactionEnd();
 }
 /**
  * Process a trackback someone sent to us
  * 
  * @param string $ip IP Address of the pinger
  * @param array $ext_vars The trackback data, in the format:
  * +================================================+
  * | key       |   value                            |
  * +-----------+------------------------------------+
  * | url*      | URL of the pinging site            |
  * +-----------+------------------------------------+
  * | title     | Title of the referring article     |
  * +-----------+------------------------------------+
  * | excerpt   | Excerpt from the referring article |
  * +-----------+------------------------------------+
  * | blog_name | Name of the referring blog         |
  * +===========+====================================+
  * @param int $commentid If given, the ID of a comment in a blog
  */
 function receiveTrackback($ip, $ext_vars, $commentid = null)
 {
     $this->_ip = $ip;
     $this->_tbdata = $ext_vars;
     $allow = $this->allowTrackback();
     if (is_array($allow)) {
         foreach ($allow['message'] as $msg) {
             $err .= ' ' . $msg;
         }
         $this->userResponse(1, $msg);
     } else {
         $replyto = is_null($commentid) ? $commentid : 0;
         /*
          * According to the spec, only URL is required, all else is optional
          */
         $vars['posterwebsite'] = my_addslashes($this->_tbdata['url']);
         $vars['title'] = isset($this->_tbdata['title']) ? my_addslashes($this->_tbdata['title']) : '';
         $vars['commenttext'] = isset($this->_tbdata['excerpt']) ? my_addslashes($this->_tbdata['excerpt']) : '';
         $vars['postername'] = isset($this->_tbdata['blog_name']) ? my_addslashes($this->_tbdata['blog_name']) : '';
         $vars['posttime'] = time();
         $vars['ip'] = $this->_ip;
         $vars['postid'] = $this->_post->postid;
         if ($replyto > 0) {
             $vars['parentid'] = $replyto;
         }
         /*
          * Added check for moderation.
          * Follow the same rules as for comments
          */
         $vars['commenttext'] = Comments::processCommentText(my_addslashes($vars['commenttext']));
         $vars['onhold'] = Comments::needsModeration($vars['commenttext']) ? 1 : 0;
         $vars['type'] = 'trackback';
         //Save the trackback
         $id = Comments::saveComment(&$db, $vars);
         if ($id > 0) {
             // notify owner
             if (C_NOTIFY == true) {
                 Comments::notify($vars['postername'], $this->_post->permalink, $vars['onhold'], $vars['commenttext']);
             }
             Comments::updateCommentCount($this->_db, $this->_post->postid);
             $this->userResponse(0);
         } else {
             $this->userResponse(1, "Error adding trackback : " . mysql_error());
         }
     }
 }
 /**
  * Add a new comment to an article
  *
  * @param object $db EZ SQL instance
  * @param object $authImage AuthImage instance
  * @param object $post The post receiving the comment
  * @param int    $replyto The ID of the parent comment
  */
 function newComment(&$db, &$authImage, $post, $replyto, $post_vars)
 {
     $result = Comments::canProceed(&$db, $post, &$authImage, $post_vars['spamcode'], $post_vars['comment']);
     if ($result['proceed'] === true) {
         $vars = Comments::prepFields($post_vars, $replyto, $post->postid);
         if ($post_vars['set_cookie']) {
             Comments::setCommentCookie($vars['postername'], $vars['posteremail'], $vars['posterwebsite']);
         }
         $id = Comments::saveComment(&$db, $vars);
         if ($id > 0) {
             if (C_NOTIFY == true) {
                 Comments::notify($vars['postername'], $post->permalink, $vars['onhold'], $vars['commenttext']);
             }
             $newnumcomments = $db->get_var('SELECT count(*) as c FROM `' . T_COMMENTS . '` WHERE postid=' . $post->postid . ' and deleted="false" group by postid');
             $db->query('UPDATE `' . T_POSTS . '` SET commentcount=' . $newnumcomments . ' WHERE postid=' . $post->postid);
             $result = $id;
         } else {
             $result['error'] = true;
             $result['message'][] = array("Error", "Error inserting comment for post " . $post->title);
             error_log(mysql_error(), 0);
         }
     }
     return $result;
 }
Exemple #4
0
        $stmt = $db->prepare($sql);
        $stmt->execute(array($_POST['page'], $_POST['title'], $img_path, $_POST['entry'], $url));
        //We close down the query link to the database
        $stmt->closeCursor();
    }
    // Sanitize the page information.
    $page = htmlentities(strip_tags($_POST['page']));
    //Send the user to the newly created entry
    header('Location: /' . $page . '/' . $url);
    exit;
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['submit'] == 'Post Comment') {
    // Include and instantiate the Comments class.
    include_once 'comments.inc.php';
    $comments = new Comments();
    // Save the comment
    $comments->saveComment($_POST);
    // If available, store the entry the user came from
    if (isset($_SERVER['HTTP_REFERER'])) {
        $loc = $_SERVER['HTTP_REFERER'];
    } else {
        $loc = '/';
    }
    // Send the user back to the entry
    header('Location: ' . $loc);
    exit;
    // If the delete link is clicked on a comment, confirm it here
} elseif (isset($_GET['action']) && $_GET['action'] == 'comment_delete') {
    // Include and instantiate the comment class
    include_once 'comments.inc.php';
    $comments = new Comments();
    echo $comments->confirmDelete($_GET['id']);
Exemple #5
0
     $parent_list = array();
     $comment_obj->getParents($comment["id"], $parent_list);
     $smarty->assign("parent_list", array_reverse($parent_list));
     $smarty->assign("comment", $comment);
     break;
 case 'save':
     $json_data = $HTTP_RAW_POST_DATA;
     $array_data = json_decode($json_data, true);
     if (is_null($array_data["text"])) {
         throw new Exception("Texto em branco.");
     }
     $array_data["gcm_id"] = null;
     if (isset($_REQUEST["gcm_id"])) {
         $array_data["gcm_id"] = $_REQUEST["gcm_id"];
     }
     $comment_id = $comment_obj->saveComment($array_data);
     if (!$comment_id) {
         throw new Exception("Erro ao salvar comentario.");
     } else {
         $comment = $comment_obj->showComment($comment_id);
         if (!$comment) {
             throw new Exception("Erro ao carregar comentario.");
         }
         /*
         // Se recebeu o ID do GCM
         if(isset($_REQUEST["gcm_id"])) {
             include_once 'class/GCM.class.php';
             $gcm = new GCM(GCM_API_KEY);
             $gcm->setRegistrationIds([$_REQUEST["gcm_id"]]);
             $gcm_result = $gcm->sendMessage("Mensagem recebida");
         }