function cw_faq_get_article($id, $lang = '', $full_info = true, $only_active = true) { global $tables, $var_dirs, $var_dirs_web; global $current_language; if (!$lang) { $lang = $current_language; } $data = cw_query_first("select {$tables['faq_questions']}.*, IF({$tables['faq_questions_lng']}.question_id != '', {$tables['faq_questions_lng']}.thema, {$tables['faq_questions']}.thema) as thema, IF({$tables['faq_questions_lng']}.question_id != '', {$tables['faq_questions_lng']}.content, {$tables['faq_questions']}.content) as content from {$tables['faq_questions']} left join {$tables['faq_questions_lng']} on {$tables['faq_questions']}.question_id={$tables['faq_questions_lng']}.question_id and {$tables['faq_questions_lng']}.code='{$lang}' where {$tables['faq_questions']}.question_id='{$id}'" . ($only_active ? ' and active=1' : '')); if (!$data) { return false; } if ($full_info) { $data['related'] = cw_query("select {$tables['faq_questions']}.question_id from {$tables['faq_questions']} where {$tables['faq_questions']}.active=1 and {$tables['faq_questions']}.rubrik_id = '" . $data['rubrik_id'] . "' and {$tables['faq_questions']}.question_id != '{$id}' order by {$tables['faq_questions']}.date desc"); if ($data['related']) { foreach ($data['related'] as $k => $v) { $data['related'][$k] = cw_faq_get_article($v['question_id'], $lang, false, true); } } $data['comments'] = cw_query("select email, comment from {$tables['faq_comments']} WHERE question_id = '{$id}'"); } $data['files'] = cw_file_area_get_list('faq_files', $id); $data['votes'] = cw_faq_get_votes($id); $data['views'] = cw_faq_get_views($id); $data['faq_show_ratings'] = true; return $data; }
} $lng_insert = array('question_id' => $question_id, 'thema' => $data['thema'], 'content' => $data['content'], 'code' => $current_language); cw_array2insert('faq_questions_lng', $lng_insert, true); if ($_FILES) { $data = array(); $data['file_path'] = cw_move_uploaded_file('file', ''); $data['filename'] = $_FILES['file']['name']; if ($data['file_path']) { cw_file_area_save('faq_files', $question_id, $data); } } // cw_faq_recalc_counters(array_shift(cw_faq_rubrik_path($to_insert['rubrik_id']))); $parents = cw_faq_parent_rubriks($to_insert['rubrik_id']); cw_faq_recalc_counters($parents[0]['rubrik_id']); cw_header_location('index.php?target=faq&mode=question&question_id=' . $question_id); } $saved_question = $to_insert; cw_header_location('index.php?target=faq&mode=question&error=1&question_id=' . $question_id); } if ($error) { $smarty->assign('question', array_map('stripslashes', $saved_question)); $smarty->assign('field_errors', $field_errors); $field_errors = array(); $saved_question = array(); } else { $smarty->assign('question', cw_faq_get_article($question_id, $current_language, false, false)); } $smarty->assign('all_rubriks', cw_faq_get_all_rubriks()); $location[] = array(cw_get_langvar_by_name('lbl_faq_questions'), 'index.php?target=faq&mode=questions'); $location[] = array(cw_get_langvar_by_name('lbl_faq_question'), ''); $smarty->assign('main', 'question');
<?php # kornev 42779 cw_load('faq'); $article = cw_faq_get_article($id); $smarty->assign('faq_article', $article); $smarty->assign('main', 'faq_printing');
if ($user && $mail && $comment && cw_faq_checkemail($mail) && cw_faq_ipcheck($_SERVER['REMOTE_ADDR'])) { $date = date("YmdHis"); $comment = nl2br($comment); $result = db_query("INSERT INTO {$tables['faq_comments']} (question_id, user, email, comment, date, helped) VALUES ('{$id}','" . strip_tags($user) . "','{$mail}','{$comment}','{$date}','{$helped}')"); $top_message['content'] = cw_get_langvar_by_name("txt_faq_comment_saved"); $top_message['type'] = "I"; } else { if (cw_faq_ipcheck($_SERVER['REMOTE_ADDR']) == FALSE) { $top_message['content'] = cw_get_langvar_by_name("txt_ask_a_question_banned"); $top_message['type'] = "E"; } else { $top_message['content'] = cw_get_langvar_by_name("txt_faq_comments_required"); $top_message['type'] = "E"; } } cw_header_location("index.php?target={$target}&mode=add_comment&cat_id={$cat_id}&id={$id}"); } $article = cw_faq_get_article($id, $current_language); if (!$article) { cw_header_location('index.php'); } $smarty->assign('faq_article', $article); $smarty->assign('main', 'add_comment'); } if ($customer_id) { $smarty->assign('userinfo', cw_user_get_info($customer_id)); } $smarty->assign('home_style', 'popup'); $smarty->assign('faq_type', $faq_type); $smarty->assign('current_main_dir', 'main'); $smarty->assign('current_section_dir', 'faq');