public function process_request($request) { $qa_content = qa_content_prepare(); $category_1 = qa_opt('qa_blog_cat_1'); $category_2 = qa_opt('qa_blog_cat_2'); $category_3 = qa_opt('qa_blog_cat_3'); $category_4 = qa_opt('qa_blog_cat_4'); $category_5 = qa_opt('qa_blog_cat_5'); $html = ""; $postid = qa_request_part(1); if (isset($postid)) { $result = qa_db_query_sub('SELECT * FROM ^blog_posts WHERE `postid` LIKE #', $postid); if ($row = mysqli_fetch_array($result)) { $userid = $row['userid']; $author = handleLinkForID($row['userid']); $editor = qa_get_logged_in_userid(); if ($userid >= $editor) { if (qa_clicked('doedit')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } $result = qa_db_query_sub('UPDATE ^blog_posts SET updated=NOW(), title=$, content=$, type=#, format=$ WHERE postid=#', $in['title'], $in['content'], $type, 'markdown', $postid); header('location:' . qa_path_to_root() . '/blog/' . $postid); } } else { if (qa_clicked('doresetoptions')) { $in = array(); qa_get_post_content('editor', 'content', $in['editor'], $in['content'], $in['format'], $in['text']); $in['title'] = qa_post_text('title'); $in['category'] = qa_post_text('category'); if (strlen($in['title']) < 10 || strlen($in['content']) < 50 || $in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { if (strlen($in['title']) < 10) { $errors['title'] = qa_lang('qa_blog_lang/error_title'); } if (strlen($in['content']) < 50) { $errors['content'] = qa_lang('qa_blog_lang/error_content'); } if ($in['category'] !== 'cat_0' && $in['category'] !== 'cat_1' && $in['category'] !== 'cat_2' && $in['category'] !== 'cat_3' && $in['category'] !== 'cat_4' && $in['category'] !== 'cat_5') { $errors['type'] = 'Invalid category'; } } else { $type = 0; if ($in['category'] === 'cat_1') { $type = 1; } else { if ($in['category'] === 'cat_2') { $type = 2; } else { if ($in['category'] === 'cat_3') { $type = 3; } else { if ($in['category'] === 'cat_4') { $type = 4; } else { if ($in['category'] === 'cat_5') { $type = 5; } } } } } $result = qa_db_query_sub('UPDATE ^blog_posts SET updated=NOW(), title=$, content=$, type=#, format=$ WHERE postid=#', $in['title'], $in['content'], $type, 'draft', $postid); header('location:' . qa_path_to_root() . '/blog/' . $postid); } } else { if (qa_clicked('dogoback')) { qa_redirect('blog'); } else { if (qa_clicked('dosaveoptions')) { qa_redirect('blog'); } else { if (qa_clicked('docancel')) { qa_redirect('blog'); } } } } } } $qa_content['title'] = 'Editing: ' . $row['title']; $userpostslink = '/user/' . qa_get_logged_in_handle() . '/articles'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); $field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false); $typeoptions = array('cat_1' => $category_1, 'cat_2' => $category_2, 'cat_3' => $category_3, 'cat_4' => $category_4, 'cat_5' => $category_5); $qa_content['form'] = array('tags' => 'name="edit" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang('qa_blog_lang/post_title'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => $row['title'], 'rows' => 2, 'error' => qa_html(@$errors['title'])), 'category' => array('label' => qa_lang('qa_blog_lang/post_cat'), 'type' => 'select', 'tags' => 'name="category"', 'options' => $typeoptions, 'error' => qa_html(@$errors['type'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => array('value' => $row['content'], 'tags' => 'name="content"', 'error' => qa_html(@$errors['content']), 'rows' => 4)), 'buttons' => array('edit' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang('qa_blog_lang/update_button')), 'save' => array('tags' => 'name="doresetoptions"', 'label' => qa_lang('qa_blog_lang/draft_button')), 'hide' => array('tags' => 'name="dosaveoptions"', 'label' => qa_lang('qa_blog_lang/hide_button')), 'goback' => array('tags' => 'name="dogoback"', 'label' => qa_lang('qa_blog_lang/cancel_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang('qa_blog_lang/delete_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('article'), 'doedit' => '1')); $html = "<h2>" . qa_lang('qa_blog_lang/past_post') . "</h2>"; $userid = qa_get_logged_in_userid(); $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE userid = '{$userid}' ORDER BY posted DESC"); $i = 0; while ($blob = mysqli_fetch_array($result)) { $i++; $html .= '<ul><li><h3><a href="blog/' . $blob['postid'] . '/' . seoUrl3($blob['title']) . '">' . $blob['title'] . '</a><h3></li></ul>'; } if ($i == 0) { $html .= qa_lang('qa_blog_lang/post_null'); } $html .= ''; $qa_content['custom2'] = $html; } else { $site_url = qa_opt('site_url'); $qa_content['title'] = qa_lang('qa_blog_lang/title_error'); $qa_content['error'] = qa_lang('qa_blog_lang/edit_error') . '<a href=' . $site_url . '/blog/> ' . qa_lang('qa_blog_lang/edit_error1') . '</a>'; $qa_content['custom2'] = qa_lang('qa_blog_lang/edit_note'); } return $qa_content; } }
public function process_request($request) { $category_1 = qa_opt('qa_blog_cat_1'); $category_2 = qa_opt('qa_blog_cat_2'); $category_3 = qa_opt('qa_blog_cat_3'); $category_4 = qa_opt('qa_blog_cat_4'); $category_5 = qa_opt('qa_blog_cat_5'); $qa_content = qa_content_prepare(); $cat = -1; if (isset($_GET['category'])) { $cat = $_GET['category']; } $qa_content['navigation']['sub'] = array(); $qa_content['navigation']['sub']['all'] = array('label' => qa_lang('qa_blog_lang/nav_all'), 'url' => qa_path_to_root() . '/blog', 'selected' => isset($_GET['category']) ? 0 : 1); $qa_content['navigation']['sub']['cat1'] = array('label' => $category_1, 'url' => qa_path_to_root() . '/blog?category=1', 'selected' => $cat == 1 ? 1 : 0); $qa_content['navigation']['sub']['cat2'] = array('label' => $category_2, 'url' => qa_path_to_root() . '/blog?category=2', 'selected' => $cat == 2 ? 1 : 0); $qa_content['navigation']['sub']['cat3'] = array('label' => $category_3, 'url' => qa_path_to_root() . '/blog?category=3', 'selected' => $cat == 3 ? 1 : 0); $qa_content['navigation']['sub']['cat4'] = array('label' => $category_4, 'url' => qa_path_to_root() . '/blog?category=4', 'selected' => $cat == 4 ? 1 : 0); $qa_content['navigation']['sub']['cat5'] = array('label' => $category_5, 'url' => qa_path_to_root() . '/blog?category=5', 'selected' => $cat == 5 ? 1 : 0); $qa_content['navigation']['sub']['post'] = array('label' => qa_lang('qa_blog_lang/nav_post'), 'url' => qa_path_to_root() . '/articles'); $qa_content['title'] = qa_opt('qa_blog_title'); $postid = qa_request_part(1); if (isset($postid)) { $result = qa_db_query_sub('SELECT * FROM ^blog_posts WHERE `postid` LIKE #', $postid); if ($row = mysqli_fetch_array($result)) { qa_db_query_sub('UPDATE ^blog_posts SET Views = Views + 1 WHERE `postid` LIKE #', $postid); $qa_content['title'] = $row['title']; $qa_content['custom'] = ""; $html = qa_viewer_html($row['content'], $row['format'], array('showurllinks' => 1)); $strviews = qa_lang('qa_blog_lang/post_views'); $views = $row['views']; if ($row['views'] == 1) { $strviews = qa_lang('qa_blog_lang/post_views'); } $author = handleLinkForID($row['userid']); if ($row['userid'] == 0) { $author = qa_lang('qa_blog_lang/userid_null'); } $user = $row['userid']; $date = $row['posted']; $date = new DateTime($date); $on = $date->format('Y.m.d'); $at = $date->format('H:i'); $parentid = $postid; $result = qa_db_query_sub("SELECT COUNT(*) as total FROM ^blog_comments WHERE `parentid` LIKE #", $parentid); $countdata = mysqli_fetch_assoc($result); $count = $countdata['total']; $delete = "<a href='" . qa_path_to_root() . "/edit/" . $postid . "'/>\n\t\t\t<img src='" . qa_opt('site_url') . "qa-plugin/blog-post/images/delete.png'> Delete </a>"; $edit = "<a href='" . qa_path_to_root() . "/edit/" . $postid . "'/>\n\t\t\t<img src='" . qa_opt('site_url') . "qa-plugin/blog-post/images/edit.png'> Edit </a>"; $flag = "<a href='#'/>\n\t\t\t<img src='" . qa_opt('site_url') . "qa-plugin/blog-post/images/edit.png'> Flag </a>"; $comments = qa_lang('qa_blog_lang/post_comments'); $queryName = qa_db_read_one_assoc(qa_db_query_sub('SELECT content FROM `^userprofile` WHERE `userid`=' . $user . ' AND title="name" LIMIT 0,#;', $user), true); $name = isset($queryName['content']) && trim($queryName['content']) != '' ? $queryName['content'] : $author; $result = qa_db_query_sub('SELECT * FROM ^users WHERE userid=#', $user); if ($row = mysqli_fetch_array($result)) { $fullname = '<a href="/user/' . $row['handle'] . '">' . $name . '</a>'; } if (qa_is_logged_in()) { $html .= "<hr>\n\t\t\t\t\t<span style='float:left;padding-left:10px'>\n\t\t\t\t\t" . qa_lang('qa_blog_lang/posted_by') . " " . $fullname . " " . qa_lang('qa_blog_lang/on') . "\n\t\t\t\t\t" . $on . " " . qa_lang('qa_blog_lang/at') . " " . $at . "</span>\n\t\t\t\t\t<span style='float:right;padding-right:10px;'>\n\t\t\t\t\t" . $edit . " . " . $delete . " |\n\t\t\t\t\t<img src='" . qa_path_to_root() . "/qa-plugin/blog-post/images/comment.png'>" . $count . " " . $comments . "\n\t\t\t\t\t<img src='" . qa_path_to_root() . "/qa-plugin/blog-post/images/hits.jpg'>" . $views . " " . $strviews . "</span>\n\t\t\t\t\t<br>"; } else { $html .= "<hr>\n\t\t\t\t\t<span style='float:left;padding-left:10px'>\n\t\t\t\t\t" . qa_lang('qa_blog_lang/posted_by') . " " . $fullname . " " . qa_lang('qa_blog_lang/on') . "\n\t\t\t\t\t" . $on . " " . qa_lang('qa_blog_lang/at') . " " . $at . "</span>\n\t\t\t\t\t<span style='float:right;padding-right:10px;'>" . $count . " " . $comments . " | " . $row['views'] . " " . $strviews . "</span>\n\t\t\t\t\t<br>"; } # $html .= "<h2>Comments features is not available in free version</h2>"; $parentid = qa_request_part(1); $result = qa_db_query_sub("SELECT * FROM ^blog_comments WHERE parentid = '{$parentid}' "); $i = 0; while ($blob = mysqli_fetch_array($result)) { $i++; $html .= "<p> " . $blob['comment'] . "</span><br>" . qa_lang('qa_blog_lang/comment') . "\n\t\t\t\t\t" . $author . " " . qa_lang('qa_blog_lang/on') . " " . $on . " " . qa_lang('qa_blog_lang/at') . "\n\t\t\t\t\t" . $at . "</p>"; } if ($i == 0) { $html .= '<h3>No Comments yet</h3>'; } } else { $html = qa_lang('qa_blog_lang/post_null'); } } else { $cat = -1; if (isset($_GET['category'])) { $cat = $_GET['category']; } $qa_content['navigation']['sub'] = array(); $qa_content['navigation']['sub']['all'] = array('label' => qa_lang('qa_blog_lang/nav_all'), 'url' => './blog', 'selected' => isset($_GET['category']) ? 0 : 1); $qa_content['navigation']['sub']['cat1'] = array('label' => $category_1, 'url' => './blog?category=1', 'selected' => $cat == 1 ? 1 : 0); $qa_content['navigation']['sub']['cat2'] = array('label' => $category_2, 'url' => './blog?category=2', 'selected' => $cat == 2 ? 1 : 0); $qa_content['navigation']['sub']['cat3'] = array('label' => $category_3, 'url' => './blog?category=3', 'selected' => $cat == 3 ? 1 : 0); $qa_content['navigation']['sub']['cat4'] = array('label' => $category_4, 'url' => './blog?category=4', 'selected' => $cat == 4 ? 1 : 0); $qa_content['navigation']['sub']['cat5'] = array('label' => $category_5, 'url' => './blog?category=5', 'selected' => $cat == 5 ? 1 : 0); $qa_content['navigation']['sub']['post'] = array('label' => qa_lang('qa_blog_lang/nav_post'), 'url' => './articles'); $html = qa_opt('qa_blog_tagline') . '<hr>'; $page = 1; if (isset($_GET['page'])) { $page = $_GET['page']; } $limit = 10; if (isset($_GET['category'])) { $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE type=# and format='markdown'\n\t\tORDER BY posted DESC LIMIT #,#", $cat, ($page - 1) * $limit, $limit); } else { $result = qa_db_query_sub("SELECT * FROM ^blog_posts WHERE format='markdown' ORDER BY posted DESC LIMIT #,#", ($page - 1) * $limit, $limit); } $i = 0; while ($article = mysqli_fetch_array($result)) { $i++; $author = $article['userid']; if ($article['userid'] == 0) { $author = qa_lang('qa_blog_lang/userid_null'); } $html .= article_item_with_author($article['title'], '' . qa_path_to_root() . '/blog/' . $article['postid'] . '/' . seoUrl($article['title']) . '/', $article['content'], $author, $article['posted'], $article['views'], $article['type'], $article['postid']); } if ($i == 0) { $html = "<h4>" . qa_lang('qa_blog_lang/posts_null') . "</h4>"; } else { if (isset($_GET['category'])) { $result = qa_db_query_sub("SELECT COUNT(*) as total FROM ^blog_posts WHERE type=#", $cat); } else { $result = qa_db_query_sub("SELECT COUNT(*) as total FROM ^blog_posts"); } $countdata = mysqli_fetch_assoc($result); $count = $countdata['total']; if ($count / $limit > 1) { $html .= '<br><br><div class="qa-page-links"> <span class="qa-page-links-label">Page: </span><ul class="qa-page-links-list">'; if ($page > 1) { $html .= '<li class="qa-page-links-item"> <a href="./questions?page=' . ($page - 1) . '" class="qa-page-prev">« prev</a> </li>'; } for ($i = 0; $i < $count / $limit; $i++) { if ($page - 1 == $i) { $html .= '<li class="qa-page-links-item"><span class="qa-page-selected">' . ($i + 1) . '</span></li>'; } else { $html .= '<li class="qa-page-links-item"><a href="./blog?page=' . ($i + 1) . '" class="qa-page-link">' . ($i + 1) . '</a></li>'; } } if ($page < $count / $limit) { $html .= '<li class="qa-page-links-item"> <a href="./blog?page=' . ($page + 1) . '" class="qa-page-next">next »</a> </li></ul></div>'; } else { $html .= '</ul></div>'; } } } $this->content['custom'] = $html; } $qa_content['custom'] = $html; //print_r($qa_content['site_title']); return $qa_content; }