if(isset($item['art_id']) && $item['art_id'] == $art_id) { if($action == 'add_comment' && ($item['art_comments'] == ARTICLE_COMMENTS)) { if(!isset($_POST['data'])) { header("Location: $sys_http_root/"); exit; } $data = $_POST['data']; $article->validate_comment($data); if(!$data['ac_data'] || !$data['ac_username']) { //$template->enable('BLOCK_acdata_error'); $template->set_var('err_msg', 'Nekorekti aizpildīta forma!'); $template->set_var('acd_username', $data['ac_username']); $template->set_var('acd_useremail', $data['ac_useremail']); } else if($article->add_comment($art_id, $data, ARTICLE_DONTVALIDATE)) { //header("Location: $sys_http_root/article/$art_id/"); $np = join('/', array_keys($path)); header("Location: $sys_http_root/$np/$art_id/"); exit; } else $template->set_var('err_msg', $article->error_msg); } // add_comment if(isset($_SESSION['user']['username'])) $template->set_var('acd_username', $_SESSION['user']['username']); if(isset($_SESSION['user']['useremail'])) $template->set_var('acd_useremail', $_SESSION['user']['useremail']); // ja ir atdaliitaajs (ivads->turpinaajums) //$patt = '/(.*)
\1
\3
', $item['art_data'], 1); //print_r($item); //die(); $item['art_date'] = proc_date($item['art_date']); // printr($item); // exit; $template->set_array($item); $template->set_title('Komentāri - '.$item['art_name']); if($item['art_imagepath']) { $template->enable('BLOCK_art_image'); } else { $template->disable('BLOCK_art_image'); } $comment_count = $article->comment_count($art_id); if($item['art_comments'] == ARTICLE_NOCOMMENTS) $template->disable('BLOCK_is_comments'); if($comment_count && ($item['art_comments'] == ARTICLE_COMMENTS)) { // saglabaajam raksta komentaaru skaitu, lai veelaak // vareetu piefixeet, vai ir jauni vai nee $_SESSION['comments']['viewed'][$art_id] = $comment_count; $template->enable('BLOCK_comment'); $comments = $article->load_comments($art_id); foreach($comments as $item) { $template->set_array($item); $template->set_var('ac_date', proc_date($item['ac_date'])); if($item['ac_useremail']) $template->enable('BLOCK_email'); else $template->disable('BLOCK_email'); $template->parse_block('BLOCK_comment', TMPL_APPEND); } // foreach } else $template->enable('BLOCK_nocomment'); } // isset $art_id .... ?>