function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { $out = ''; require_once QA_INCLUDE_DIR . 'qa-app-users.php'; if (qa_is_logged_in()) { $out = ' <button id="adchattoggle" class="adchattoggle">Show/Hide Chat </button>'; $out .= '<div class="adchat" id="adchat" style="display:'; if (@$_COOKIE['showadchat'] == 'block') { $out .= "block"; } else { $out .= "none"; } $out .= '">'; $out .= ' <iframe src="' . $this->urltoroot . 'chat/" style="border:0; width:100%; height:480px;"></iframe> </div>'; } else { $out = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block" data-ad-client="' . qa_html(qa_opt("adsense_publisher_id")) . '" data-ad-slot="' . qa_html(qa_opt("adsense_adunit_id")) . '" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>'; } $output = '<div class="adchat-widget-container">' . $out . '</div>'; $themeobject->output($output); }
/** * init current user logined */ function hw_init_current_userlogin() { global $iflychat_userinfo; //init user if (qa_is_logged_in()) { $handle = qa_get_logged_in_handle(); //user name $userid = qa_get_logged_in_userid(); //user id $user = qa_db_select_with_pending(qa_db_user_account_selectspec($handle, false)); //get user avatar src $avatar_src = hw_get_user_avatar_src($user['flags'], $user['email'], $user['avatarblobid']); if (empty($avatar_src)) { $avatar_src = 'https://iflychat.com/sites/all/modules/drupalchat/themes/light/images/default_avatar.png'; } //set detail current user to chat $iflychat_userinfo = new iFlyChatUserDetails($handle, $userid); $iflychat_userinfo->setIsAdmin(TRUE); $iflychat_userinfo->setAvatarUrl($avatar_src); $iflychat_userinfo->setProfileLink(qa_opt('site_url') . 'user/' . $handle); $iflychat_userinfo->setRoomRoles(array()); $iflychat_userinfo->setRelationshipSet(FALSE); //$iflychat_userinfo->setAllRoles(array('1'=>'admin')); } }
function match_request($request) { if (qa_is_logged_in() && $request == 'notifications') { return true; } return false; }
function logged_in() { qa_html_theme_base::logged_in(); if (qa_is_logged_in()) { $userpoints = qa_get_logged_in_points(); $pointshtml = $userpoints == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints))); $this->output('<SPAN CLASS="qa-logged-in-points">', '(' . $pointshtml . ')', '</SPAN>'); } }
function logged_in() { if (qa_is_logged_in()) { // output user avatar to login bar $this->output('<div class="qa-logged-in-avatar">', QA_FINAL_EXTERNAL_USERS ? qa_get_external_avatar_html(qa_get_logged_in_userid(), 24, true) : qa_get_user_avatar_html(qa_get_logged_in_flags(), qa_get_logged_in_email(), qa_get_logged_in_handle(), qa_get_logged_in_user_field('avatarblobid'), qa_get_logged_in_user_field('avatarwidth'), qa_get_logged_in_user_field('avatarheight'), 24, true), '</div>'); } qa_html_theme_base::logged_in(); if (qa_is_logged_in()) { // adds points count after logged in username $userpoints = qa_get_logged_in_points(); $pointshtml = $userpoints == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints))); $this->output('<span class="qa-logged-in-points">', '(' . $pointshtml . ')', '</span>'); } }
function qa_user_permit_error($permitoption = null, $limitaction = null, $userlevel = null, $checkblocks = true) { global $wiki_enable; $permit_error = qa_user_permit_error_base($permitoption, $limitaction, $userlevel, $checkblocks); if ($permitoption == 'permit_edit_q' && $permit_error == 'level' && qa_is_logged_in()) { if (!isset($wiki_enable)) { $result = qa_db_query_sub('SELECT * FROM ^postmeta WHERE meta_key=$ AND post_id=#', 'is_community', qa_request_part(0)); $wiki_enable = $result->num_rows > 0; } if ($wiki_enable) { return false; } } return $permit_error; }
function qa_check_form_security_code($action, $value) { if (qa_caching_main::now_caching()) { $reportproblems = array(); $silentproblems = array(); if (!isset($value)) { $silentproblems[] = 'code missing'; } elseif (!strlen($value)) { $silentproblems[] = 'code empty'; } else { $parts = explode('-', $value); if (count($parts) == 3) { $loggedin = $parts[0]; $timestamp = $parts[1]; $hash = $parts[2]; $timenow = qa_opt('db_time'); if ($loggedin != '0') { $reportproblems[] = 'login status mismatch'; } /*if ($timestamp>$timenow) $reportproblems[]='time '.($timestamp-$timenow).'s in future'; else*/ if ($timestamp < $timenow - QA_FORM_EXPIRY_SECS) { $silentproblems[] = 'timeout after ' . ($timenow - $timestamp) . 's'; } $key = @$_COOKIE['qa_key']; if (!isset($key)) { $silentproblems[] = 'key cookie missing'; } elseif (!strlen($key)) { $silentproblems[] = 'key cookie empty'; } elseif (strlen($key) != QA_FORM_KEY_LENGTH) { $reportproblems[] = 'key cookie ' . $key . ' invalid'; } if ($hash != $key) { $reportproblems[] = 'key cookie mismatch'; } } else { $reportproblems[] = 'code ' . $value . ' malformed'; } } if (count($reportproblems)) { @error_log('PHP Question2Answer form security violation for ' . $action . ' by ' . (qa_is_logged_in() ? 'userid ' . qa_get_logged_in_userid() : 'anonymous') . ' (' . implode(', ', array_merge($reportproblems, $silentproblems)) . ')' . ' on ' . @$_SERVER['REQUEST_URI'] . ' via ' . @$_SERVER['HTTP_REFERER']); } return empty($silentproblems) && empty($reportproblems); } else { return qa_check_form_security_code_base($action, $value); } }
function qa_admin_check_privileges(&$qa_content) { if (!qa_is_logged_in()) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/admin_title'); $qa_content['error'] = qa_insert_login_links(qa_lang_html('admin/not_logged_in'), qa_request()); return false; } elseif (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) { $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/admin_title'); $qa_content['error'] = qa_lang_html('admin/no_privileges'); return false; } return true; }
function head_script() { qa_html_theme_base::head_script(); // only load if enabled and user logged-in if (qa_opt('q2apro_onsitenotifications_enabled') && qa_is_logged_in()) { $this->output('<script type="text/javascript"> var eventnotifyAjaxURL = "' . qa_path('eventnotify') . '"; </script>'); $this->output('<script type="text/javascript" src="' . QA_HTML_THEME_LAYER_URLTOROOT . 'script.js"></script>'); $this->output('<link rel="stylesheet" type="text/css" href="' . QA_HTML_THEME_LAYER_URLTOROOT . 'styles.css">'); // hack for snow flat theme (q2a v1.7) to show the notification icon outside the user's drop down if (qa_opt('site_theme') == 'SnowFlat') { $this->output(' <script type="text/javascript"> $(document).ready(function(){ // $("#osnbox").detach().appendTo(".qam-account-items-wrapper"); var elem = $("#osnbox").detach(); $(".qam-account-items-wrapper").prepend(elem); }); </script> '); } // hack for snow theme (q2a v1.6) to position the notification box more to the right if (qa_opt('site_theme') == 'Snow') { $this->output(' <style type="text/css"> #nfyWrap { left:-100px; } </style> '); } // from q2a v1.7 we can use: $isRTL = $this->isRTL; but prior q2a versions can not, so we provide an admin option if (qa_opt('q2apro_onsitenotifications_rtl')) { $this->output(' <style type="text/css"> #nfyReadClose { float:left !important; } .nfyWrap .nfyTop { text-align:right; } .nfyContainer { direction: rtl !important; text-align: right !important; } .nfyWrap .nfyFooter { text-align:left; } .nfyIcon { float:right; } .nfyWrap .nfyItemLine { float:right; margin-right:5px; } /* Snow Flat hacks */ .qam-account-items-wrapper #osnbox { float: right; margin-right:-30px; } .qam-account-items-wrapper .nfyWrap { top: 31px; left: 0; } </style> '); } } // end enabled }
function post_avatar($post, $class, $prefix = null) { if (qa_opt('it_layout_lists') == 'qlist') { qa_html_theme_base::post_avatar($post, $class, $prefix = null); return; } // check if it's a question list or question item if ($class != 'qa-q-item') { //if (!( ($this->template=='qa') or ($this->template=='questions') )) qa_html_theme_base::post_avatar($post, $class, $prefix); } else { $qlink = qa_q_path($post['raw']['postid'], $post['raw']['title'], true); $this->output('<div class="q-item-meta">'); // set avatar if (isset($post['avatar'])) { if (isset($prefix)) { $this->output($prefix); } $this->output('<section class="' . $class . '-avatar">' . $post['avatar']); $this->output('<section class="popup-user-avatar">'); qa_html_theme_base::post_meta_what($post, $class); qa_html_theme_base::post_meta_who($post, $class); $this->output('</section>'); $this->output('</section>'); } // set category if ($post["raw"]["categoryid"]) { require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $categoryid = $post["raw"]["categoryid"]; $catname = $post["raw"]["categoryname"]; $catbackpath = $post["raw"]["categorybackpath"]; $et_category = json_decode(qa_db_categorymeta_get($categoryid, 'et_category'), true); $this->output('<section class="' . $class . '-category">'); $categorypathprefix = 'questions/'; $this->output('<a class="' . $class . '-category-link" title="' . $et_category['et_cat_title'] . '" href="' . qa_path_html($categorypathprefix . implode('/', array_reverse(explode('/', $catbackpath)))) . '">'); if (!empty($et_category['et_cat_icon48'])) { $this->output('<img class="qa-category-image" width="48" height="48" alt="' . $et_category['et_cat_desc'] . '" src="' . $et_category['et_cat_icon48'] . '">'); } else { $this->output(qa_html($catname)); } $this->output('</a>'); if (!empty($et_category['et_cat_desc'])) { $this->output('<section class="' . $class . '-category-description">'); $this->output($et_category['et_cat_desc']); $this->output('</section>'); } $this->output('</section>'); } $this->output('</div>'); $this->output('<div class="qa-item-meta-bar">'); // Voting $this->voting_inner_html($post); // favourites if (qa_is_logged_in()) { $favourited = $post['favourited']; $favorite = qa_favorite_form(QA_ENTITY_QUESTION, $post['raw']['postid'], $favourited, qa_lang($favourited ? 'question/remove_q_favorites' : 'question/add_q_favorites')); if (isset($favorite)) { //$this->output('<form '.$favorite['form_tags'].'>'); $this->output('<div class="qa-favoriting qa-favoriting-' . $post['raw']['postid'] . '" ' . @$favorite['favorite_tags'] . '>'); $this->favorite_inner_html($favorite, $post['favourites']); $this->output('</div>'); $this->output('<input type="hidden" id="fav_code_' . $post['raw']['postid'] . '" name="fav_code" value="' . @$favorite['form_hidden']['code'] . '"/>'); //$this->output('</form>'); } } else { $this->output('<div class="qa-favoriting qa-favoriting-' . $post['raw']['postid'] . '" ' . @$favorite['favorite_tags'] . '>'); $this->output('<button class="btn btn-default btn-xs fa fa-heart qa-favorite" type="button" onclick="return qa_favorite_click(this);" name="favorite-login_q' . $post['raw']['postid'] . '" title="Favourite">' . $post['favourites'] . '</button>'); //<button class="btn btn-default btn-xs fa fa-heart qa-favorite" type="button" onclick="return qa_favorite_click(this);" name="favorite_Q_125_1" title="Add to my favorites">2</button> $this->output('</div>'); } // discussions $this->output('<div class="qa-list-discussions">'); $this->output('<a class="btn btn-default btn-xs fa fa-comment discussions-item-list" href="' . $qlink . '">' . ($post['comments'] + $post["answers_raw"]) . '</a>'); $this->output('</div>'); // Share $this->output('<div class="qa-list-share">'); $this->output('<button type="button" class="btn btn-default btn-xs fa fa-share-alt share-item-list" data-share-link="' . $qlink . '" data-share-title="' . $post['raw']['title'] . '"></button>'); $this->output('</div>'); $this->output('</div>'); } //qa_html_theme_base::voting_inner_html($post); }
function qa_content_prepare($voting = false, $categoryids = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_template, $qa_page_error_html; if (QA_DEBUG_PERFORMANCE) { global $qa_usage; $qa_usage->mark('control'); } $request = qa_request(); $requestlower = qa_request(); $navpages = qa_db_get_pending_result('navpages'); $widgets = qa_db_get_pending_result('widgets'); if (isset($categoryids) && !is_array($categoryids)) { // accept old-style parameter $categoryids = array($categoryids); } $lastcategoryid = count($categoryids) ? end($categoryids) : null; $charset = 'utf-8'; $qa_content = array('content_type' => 'text/html; charset=' . $charset, 'charset' => $charset, 'direction' => qa_opt('site_text_direction'), 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array()); if (qa_opt('show_custom_in_head')) { $qa_content['head_lines'][] = qa_opt('custom_in_head'); } if (qa_opt('show_custom_header')) { $qa_content['body_header'] = qa_opt('custom_header'); } if (qa_opt('show_custom_footer')) { $qa_content['body_footer'] = qa_opt('custom_footer'); } if (isset($categoryids)) { $qa_content['categoryids'] = $categoryids; } foreach ($navpages as $page) { if ($page['nav'] == 'B') { qa_navigation_add_page($qa_content['navigation']['main'], $page); } } if (qa_opt('nav_home') && qa_opt('show_custom_home')) { $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home')); } if (qa_opt('nav_activity')) { $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity')); } $hascustomhome = qa_has_custom_home(); if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) { $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa')); } if (qa_opt('nav_questions')) { $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs')); } if (qa_opt('nav_hot')) { $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot')); } if (qa_opt('nav_unanswered')) { $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered')); } if (qa_using_tags() && qa_opt('nav_tags')) { $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags'), 'selected_on' => array('tags$', 'tag/')); } if (qa_using_categories() && qa_opt('nav_categories')) { $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories'), 'selected_on' => array('categories$', 'categories/')); } if (qa_opt('nav_users')) { $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users'), 'selected_on' => array('users$', 'users/', 'user/')); } // Only the 'level' permission error prevents the menu option being shown - others reported on qa-page-ask.php if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') { $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask')); } if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN || !qa_user_maximum_permit_error('permit_moderate') || !qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')) { $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html('admin'), 'label' => qa_lang_html('main/nav_admin'), 'selected_on' => array('admin/')); } $qa_content['search'] = array('form_tags' => 'method="get" action="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'name="q"', 'button_label' => qa_lang_html('main/search_button')); if (!qa_opt('feedback_enabled')) { unset($qa_content['navigation']['footer']['feedback']); } foreach ($navpages as $page) { if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') { qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page); } } $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side'); $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom'); foreach ($widgets as $widget) { if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) { // see if it has been selected for display on this template $region = @$regioncodes[substr($widget['place'], 0, 1)]; $place = @$placecodes[substr($widget['place'], 1, 2)]; if (isset($region) && isset($place)) { // check region/place codes recognized $module = qa_load_module('widget', $widget['title']); if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template(substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) { $qa_content['widgets'][$region][$place][] = $module; } // if module loaded and happy to be displayed here, tell theme about it } } } $logoshow = qa_opt('logo_show'); $logourl = qa_opt('logo_url'); $logowidth = qa_opt('logo_width'); $logoheight = qa_opt('logo_height'); if ($logoshow) { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link" title="' . qa_html(qa_opt('site_title')) . '">' . '<img src="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : qa_path_to_root() . $logourl) . '"' . ($logowidth ? ' width="' . $logowidth . '"' : '') . ($logoheight ? ' height="' . $logoheight . '"' : '') . ' border="0" alt="' . qa_html(qa_opt('site_title')) . '"/></a>'; } else { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</a>'; } $topath = qa_get('to'); // lets user switch between login and register without losing destination page $userlinks = qa_get_login_links(qa_path_to_root(), isset($topath) ? $topath : qa_path($request, $_GET, '')); $qa_content['navigation']['user'] = array(); if (qa_is_logged_in()) { $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), qa_path_to_root(), false) : qa_get_one_user_html(qa_get_logged_in_handle(), false)); $qa_content['navigation']['user']['updates'] = array('url' => qa_path_html('updates'), 'label' => qa_lang_html('main/nav_updates')); if (!empty($userlinks['logout'])) { $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout')); } if (!QA_FINAL_EXTERNAL_USERS) { $source = qa_get_logged_in_source(); if (strlen($source)) { $loginmodules = qa_load_modules_with('login', 'match_source'); foreach ($loginmodules as $module) { if ($module->match_source($source) && method_exists($module, 'logout_html')) { ob_start(); $module->logout_html(qa_path('logout', array(), qa_opt('site_url'))); $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean()); } } } } $notices = qa_db_get_pending_result('notices'); foreach ($notices as $notice) { $qa_content['notices'][] = qa_notice_form($notice['noticeid'], qa_viewer_html($notice['content'], $notice['format']), $notice); } } else { require_once QA_INCLUDE_DIR . 'util/string.php'; if (!QA_FINAL_EXTERNAL_USERS) { $loginmodules = qa_load_modules_with('login', 'login_html'); foreach ($loginmodules as $tryname => $module) { ob_start(); $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($request, $_GET, qa_opt('site_url')), 'menu'); $label = ob_get_clean(); if (strlen($label)) { $qa_content['navigation']['user'][implode('-', qa_string_to_words($tryname))] = array('label' => $label); } } } if (!empty($userlinks['login'])) { $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login')); } if (!empty($userlinks['register'])) { $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register')); } } if (QA_FINAL_EXTERNAL_USERS || !qa_is_logged_in()) { if (qa_opt('show_notice_visitor') && !isset($topath) && !isset($_COOKIE['qa_noticed'])) { $qa_content['notices'][] = qa_notice_form('visitor', qa_opt('notice_visitor')); } } else { setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN); // don't show first-time notice if a user has logged in if (qa_opt('show_notice_welcome') && qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE) { if ($requestlower != 'confirm' && $requestlower != 'account') { // let people finish registering in peace $qa_content['notices'][] = qa_notice_form('welcome', qa_opt('notice_welcome')); } } } $qa_content['script_rel'] = array('qa-content/jquery-1.11.2.min.js'); $qa_content['script_rel'][] = 'qa-content/qa-page.js?' . QA_VERSION; if ($voting) { $qa_content['error'] = @$qa_page_error_html; } $qa_content['script_var'] = array('qa_root' => qa_path_to_root(), 'qa_request' => $request); return $qa_content; }
function voting_inner_html($post) { if (qw_hook_exist(__FUNCTION__)) { $args = func_get_args(); array_unshift($args, $this); return qw_event_hook(__FUNCTION__, $args, NULL); } $up_tags = preg_replace('/onclick="([^"]+)"/', '', str_replace('name', 'data-id', @$post['vote_up_tags'])); $down_tags = preg_replace('/onclick="([^"]+)"/', '', str_replace('name', 'data-id', @$post['vote_down_tags'])); if (qa_is_logged_in()) { $user_point = qa_get_logged_in_points(); if ($post['raw']['type'] == 'Q') { if (qa_opt('permit_vote_q') == '106') { $need = qa_opt('permit_vote_q_points') - $user_point; $up_tags = str_replace(qa_lang_html('main/vote_disabled_level'), 'You need ' . $need . ' more points to vote', $up_tags); } if (qa_opt('permit_vote_q') == '106' && qa_opt('permit_vote_down') == '106') { $max = max(qa_opt('permit_vote_down_points'), qa_opt('permit_vote_q_points')); $need = $max - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } elseif (qa_opt('permit_vote_q') == '106') { $need = qa_opt('permit_vote_q_points') - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } elseif (qa_opt('permit_vote_down') == '106') { $need = qa_opt('permit_vote_down_points') - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } } if ($post['raw']['type'] == 'A') { if (qa_opt('permit_vote_a') == '106') { $need = qa_opt('permit_vote_a_points') - $user_point; $up_tags = str_replace(qa_lang_html('main/vote_disabled_level'), 'You need ' . $need . ' more points to vote', $up_tags); } if (qa_opt('permit_vote_a') == '106' && qa_opt('permit_vote_down') == '106') { $max = max(qa_opt('permit_vote_down_points'), qa_opt('permit_vote_a_points')); $need = $max - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } elseif (qa_opt('permit_vote_a') == '106') { $need = qa_opt('permit_vote_a_points') - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } elseif (qa_opt('permit_vote_down') == '106') { $need = qa_opt('permit_vote_down_points') - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } } } $state = @$post['vote_state']; $code = qa_get_form_security_code('vote'); $vote_text = $post['raw']['netvotes'] > 1 || $post['raw']['netvotes'] < -1 ? _ra_lang('votes') : _ra_lang('vote'); $this->output('<p class="count">' . $post['raw']['netvotes'] . '<span>' . $vote_text . '</span></p>'); if (isset($post['vote_up_tags'])) { $this->output('<a ' . @$up_tags . ' href="#" data-code="' . $code . '" class="icon-chevron-up enabled vote-up ' . $state . '"></a>'); } if (isset($post['vote_down_tags'])) { $this->output('<a ' . @$down_tags . ' href="#" data-code="' . $code . '" class="icon-chevron-down enabled vote-down ' . $state . '"></a>'); } }
function logged_in() { qa_html_theme_base::logged_in(); if (qa_is_logged_in()) { $userpoints = qa_get_logged_in_points(); $username = qa_html(qa_get_logged_in_handle()); $userid = qa_get_logged_in_userid(); $user = qa_db_select_with_pending(qa_db_user_rank_selectspec($userid)); $userrank = ''; if (is_array($user)) { if (array_key_exists('rank', $user)) { $userrank = '(#' . number_format((int) $user['rank']) . ')'; } } $pointshtml = $userpoints == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_lang_html_sub('main/x_points', qa_html(number_format($userpoints))); $this->output('<SPAN><a CLASS="qa-logged-in-points" href="index.php?qa=user&qa_1=' . $username . '#activity">' . $pointshtml . $userrank . '</a></SPAN>'); } }
function qa_page_q_edit_c_form(&$qa_content, $id, $comment, $in, $errors) { $commentid = $comment['postid']; $prefix = 'c' . $commentid . '_'; $content = isset($in['content']) ? $in['content'] : $comment['content']; $format = isset($in['format']) ? $in['format'] : $comment['format']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor($content, $format, $editorname); $form = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'id' => $id, 'title' => qa_lang_html('question/edit_c_title'), 'style' => 'tall', 'fields' => array('content' => array_merge(qa_editor_load_field($editor, $qa_content, $content, $format, $prefix . 'content', 4, true), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('save' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script($prefix . 'content') : '') . '"', 'label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'dosave' => '1', $prefix . 'code' => qa_get_form_security_code('edit-' . $commentid))); if ($comment['isbyuser']) { if (!qa_is_logged_in()) { qa_set_up_name_field($qa_content, $form['fields'], isset($in['name']) ? $in['name'] : @$comment['name'], $prefix); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : !empty($comment['notify']), isset($in['email']) ? $in['email'] : @$comment['notify'], @$errors['email'], $prefix); } if (!qa_user_post_permit_error('permit_edit_silent', $comment)) { $form['fields']['silent'] = array('type' => 'checkbox', 'label' => qa_lang_html('question/save_silent_label'), 'tags' => 'name="' . $prefix . 'silent"', 'value' => qa_html(@$in['silent'])); } return $form; }
public function mark_all_messages() { if (qa_is_logged_in()) { qw_set_all_messages_as_read(qa_get_logged_in_userid()); } die; }
/** * Dynamic <code>CSS</code> based on options and other interaction with Q2A. * * @since Snow 1.4 * @version 1.0 * @return string The CSS code */ private function head_inline_css() { $css = array('<style>'); if (!qa_is_logged_in()) { $css[] = '.qa-nav-user { margin: 0 !important; }'; } if (qa_request_part(1) !== qa_get_logged_in_handle()) { $css[] = '@media (max-width: 979px) {'; $css[] = ' body.qa-template-user.fixed, body[class*="qa-template-user-"].fixed { padding-top: 118px !important; }'; $css[] = ' body.qa-template-users.fixed { padding-top: 95px !important; }'; $css[] = '}'; $css[] = '@media (min-width: 980px) {'; $css[] = ' body.qa-template-users.fixed { padding-top: 105px !important;}'; $css[] = '}'; } // sidebar styles for desktop (must use server-side UA detection, not media queries) if (!qa_is_mobile_probably()) { $css[] = '.qa-sidepanel { width: 25%; padding: 0px; float: right; overflow: hidden; *zoom: 1; }'; } $css[] = '</style>'; $this->output_array($css); }
/** * Checks if the user is eligible to delete the post * * @param null $userid if the userid is not passed uses loggedin userid * @param null $post_userid * * @return bool */ function ami_dhp_is_user_eligible_to_delete($userid = null, $post_userid = null) { // if the plugin is not enabled first reuturn false if (!qa_opt(qa_dhp_admin::PLUGIN_ENABLED)) { return false; } if (is_null($userid) || !isset($userid)) { // if the userid is not set then get the logged in userid $userid = qa_get_logged_in_userid(); } if (is_null($userid) && !qa_is_logged_in()) { // if still it is null then ret false return false; } // return true for all special users that is allowed from admin panel if (qa_get_logged_in_level() >= qa_opt(qa_dhp_admin::MIN_LEVEL_TO_DELETE_Q)) { return true; } if (qa_opt(qa_dhp_admin::SAME_USER_CAN_DELETE_QA) && !is_null($post_userid) && (int) $userid == (int) $post_userid) { return true; } return false; }
/** * prints the drop down for the user * */ function donut_user_drop_down() { if (qa_is_logged_in()) { require_once DONUT_THEME_BASE_DIR . '/templates/user-loggedin-drop-down.php'; } else { require_once DONUT_THEME_BASE_DIR . '/templates/user-login-drop-down.php'; } }
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(); $errors = array(); if (qa_clicked('docancel')) { qa_redirect('blog'); } else { if (qa_clicked('dosaveoptions')) { $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; } } } } } qa_db_query_sub('INSERT INTO ^blog_posts (postid, userid, posted, title, type, content, views,format) VALUES (0,#,NOW(),$,#,$,0,$)', qa_get_logged_in_userid(), $in['title'], $type, $in['content'], 'draft'); header('location:' . qa_path_to_root() . '/user/' . qa_get_logged_in_handle() . ''); } } else { if (qa_clicked('doarticle')) { $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('INSERT INTO ^blog_posts (postid, userid, posted, title, type, content, views,format) VALUES (0,#,NOW(),$,#,$,0,$)', qa_get_logged_in_userid(), $in['title'], $type, $in['content'], 'markdown'); header('location:' . qa_path_to_root() . '/blog/'); } } } } if (qa_is_logged_in()) { $qa_content['title'] = qa_lang('qa_blog_lang/articles_page'); $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); $field['label'] = ''; $field['error'] = qa_html(@$errors['content']); $qa_content['custom'] = qa_lang('qa_blog_lang/default_blog_tagline'); $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="blog" 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' => qa_html(@$in['title']), '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' => $field), 'buttons' => array('post' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang('qa_blog_lang/post_button')), 'save' => array('tags' => 'name="dosaveoptions"', 'label' => qa_lang('qa_blog_lang/draft_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang('qa_blog_lang/cancel_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('article'), 'doarticle' => '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 { $qa_content['title'] = qa_lang('qa_blog_lang/title_error'); $qa_content['error'] = qa_insert_login_links(qa_lang('qa_blog_lang/access_error'), $request); } 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; }
/** * Dynamic <code>CSS</code> based on options and other interaction with Q2A. * * @since Snow 1.4 * @version 1.0 * @return string The CSS code */ private function head_inline_css() { $css = array('<style>'); if (!qa_is_logged_in()) { $css[] = '.qa-nav-user { margin: 0 !important; }'; } if (qa_request_part(1) !== qa_get_logged_in_handle()) { $css[] = '@media (max-width: 979px) {'; $css[] = ' body.qa-template-user.fixed, body[class*="qa-template-user-"].fixed { padding-top: 118px !important; }'; $css[] = ' body.qa-template-users.fixed { padding-top: 95px !important; }'; $css[] = '}'; $css[] = '@media (min-width: 980px) {'; $css[] = ' body.qa-template-users.fixed { padding-top: 105px !important;}'; $css[] = '}'; } $css[] = '</style>'; $this->output_array($css); }
/** * Get logged in user's points * * @access private * @since Snow 1.4 * @version 1.0 * @return string|null LoggedIn user's total points, null for guest * * @author Q2A Market <http://www.q2amarket.com> * @copyright (c) 2014, Q2A Market * @license http://www.gnu.org/copyleft/gpl.html */ private function user_points() { if (qa_is_logged_in()) { $userpoints = qa_get_logged_in_points(); $pointshtml = $userpoints == 1 ? qa_lang_html_sub('main/1_point', '1', '1') : qa_html(number_format($userpoints)); $points = '<DIV CLASS="qam-logged-in-points">' . $pointshtml . '</DIV>'; return $points; } return null; }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. More about this license: http://www.question2answer.org/license.php */ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser header('Location: ../'); exit; } // Check we're not using Q2A's single-sign on integration and that we're not logged in if (QA_FINAL_EXTERNAL_USERS) { qa_fatal_error('User login is handled by external code'); } if (qa_is_logged_in()) { qa_redirect(''); } // Process submitted form after checking we haven't reached rate limit $passwordsent = qa_get('ps'); if (qa_clicked('dologin')) { require_once QA_INCLUDE_DIR . 'qa-app-limits.php'; if (qa_limits_remaining(null, QA_LIMIT_LOGINS)) { require_once QA_INCLUDE_DIR . 'qa-db-users.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; qa_limits_increment(null, QA_LIMIT_LOGINS); $inemailhandle = qa_post_text('emailhandle'); $inpassword = qa_post_text('password'); $inremember = qa_post_text('remember'); $errors = array(); if (qa_opt('allow_login_email_only') || strpos($inemailhandle, '@') !== false) {
function voting_inner_html($post) { $up_tags = preg_replace('/onclick="([^"]+)"/', '', str_replace('name', 'data-id', @$post['vote_up_tags'])); $down_tags = preg_replace('/onclick="([^"]+)"/', '', str_replace('name', 'data-id', @$post['vote_down_tags'])); if (qa_is_logged_in()) { $user_point = qa_get_logged_in_points(); if ($post['raw']['type'] == 'Q') { if (qa_opt('permit_vote_q') == '106') { $need = qa_opt('permit_vote_q_points') - $user_point; $up_tags = str_replace(qa_lang_html('main/vote_disabled_level'), 'You need ' . $need . ' more points to vote', $up_tags); } if (qa_opt('permit_vote_q') == '106' && qa_opt('permit_vote_down') == '106') { $max = max(qa_opt('permit_vote_down_points'), qa_opt('permit_vote_q_points')); $need = $max - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } elseif (qa_opt('permit_vote_q') == '106') { $need = qa_opt('permit_vote_q_points') - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } elseif (qa_opt('permit_vote_down') == '106') { $need = qa_opt('permit_vote_down_points') - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } } if ($post['raw']['type'] == 'A') { if (qa_opt('permit_vote_a') == '106') { $need = qa_opt('permit_vote_a_points') - $user_point; $up_tags = str_replace(qa_lang_html('main/vote_disabled_level'), 'You need ' . $need . ' more points to vote', $up_tags); } if (qa_opt('permit_vote_a') == '106' && qa_opt('permit_vote_down') == '106') { $max = max(qa_opt('permit_vote_down_points'), qa_opt('permit_vote_a_points')); $need = $max - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } elseif (qa_opt('permit_vote_a') == '106') { $need = qa_opt('permit_vote_a_points') - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } elseif (qa_opt('permit_vote_down') == '106') { $need = qa_opt('permit_vote_down_points') - $user_point; $down_tags = preg_replace('/title="([^"]+)"/', 'title="You need ' . $need . ' more points to vote" ', $down_tags); } } } $state = @$post['vote_state']; $code = qa_get_form_security_code('vote'); $vote_text = $post['raw']['netvotes'] > 1 || $post['raw']['netvotes'] < -1 ? qa_lang('cleanstrap/votes') : qa_lang('cleanstrap/vote'); if (isset($post['vote_up_tags'])) { $this->output('<a ' . @$up_tags . ' href="#" data-code="' . $code . '" class=" icon-thumbs-up2 enabled vote-up ' . $state . '"></a>'); } $this->output('<span class="count">' . $post['raw']['netvotes'] . '</span>'); if (isset($post['vote_down_tags'])) { $this->output('<a ' . @$down_tags . ' href="#" data-code="' . $code . '" class=" icon-thumbs-down2 enabled vote-down ' . $state . '"></a>'); } }
function qa_check_form_security_code($action, $value) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } $reportproblems = array(); $silentproblems = array(); if (!isset($value)) { $silentproblems[] = 'code missing'; } elseif (!strlen($value)) { $silentproblems[] = 'code empty'; } else { $parts = explode('-', $value); if (count($parts) == 3) { $loggedin = $parts[0]; $timestamp = $parts[1]; $hash = $parts[2]; $timenow = qa_opt('db_time'); if ($timestamp > $timenow) { $reportproblems[] = 'time ' . ($timestamp - $timenow) . 's in future'; } elseif ($timestamp < $timenow - QA_FORM_EXPIRY_SECS) { $silentproblems[] = 'timeout after ' . ($timenow - $timestamp) . 's'; } if (qa_is_logged_in()) { if (!$loggedin) { $silentproblems[] = 'now logged in'; } } else { if ($loggedin) { $silentproblems[] = 'now logged out'; } else { $key = @$_COOKIE['qa_key']; if (!isset($key)) { $silentproblems[] = 'key cookie missing'; } elseif (!strlen($key)) { $silentproblems[] = 'key cookie empty'; } elseif (strlen($key) != QA_FORM_KEY_LENGTH) { $reportproblems[] = 'key cookie ' . $key . ' invalid'; } } } if (empty($silentproblems) && empty($reportproblems)) { if (strtolower(qa_calc_form_security_hash($action, $timestamp)) != strtolower($hash)) { $reportproblems[] = 'code mismatch'; } } } else { $reportproblems[] = 'code ' . $value . ' malformed'; } } if (count($reportproblems)) { @error_log('PHP Question2Answer form security violation for ' . $action . ' by ' . (qa_is_logged_in() ? 'userid ' . qa_get_logged_in_userid() : 'anonymous') . ' (' . implode(', ', array_merge($reportproblems, $silentproblems)) . ')' . ' on ' . @$_SERVER['REQUEST_URI'] . ' via ' . @$_SERVER['HTTP_REFERER']); } return empty($silentproblems) && empty($reportproblems); }
function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow) { // The 'approve', 'login', 'confirm', 'userblock', 'ipblock' permission errors are reported to the user here // The other option ('level') prevents the comment button being shown, in qa_page_q_post_rules(...) switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) { case 'login': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request())); break; case 'confirm': $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request())); break; case 'approve': $form = array('title' => qa_lang_html('question/comment_must_be_approved')); break; case 'limit': $form = array('title' => qa_lang_html('question/comment_limit')); break; default: $form = array('title' => qa_lang_html('users/no_permission')); break; case false: $prefix = 'c' . $parent['postid'] . '_'; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs'); $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname); if (method_exists($editor, 'update_script')) { $updatescript = $editor->update_script($prefix . 'content'); } else { $updatescript = ''; } $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : ''; $form = array('tags' => 'method="post" action="' . qa_self_html() . '" name="c_form_' . qa_html($parent['postid']) . '"', 'title' => qa_lang_html($question['postid'] == $parent['postid'] ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onclick="' . $updatescript . ' return qa_submit_comment(' . qa_js($question['postid']) . ', ' . qa_js($parent['postid']) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1', $prefix . 'code' => qa_get_form_security_code('comment-' . $parent['postid']))); if (!strlen($custom)) { unset($form['fields']['custom']); } if (!qa_is_logged_in()) { qa_set_up_name_field($qa_content, $form['fields'], @$in['name'], $prefix); } qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix); $onloads = array(); if ($captchareason) { $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_captcha_reason_note($captchareason)); if (strlen($captchaloadscript)) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' };'; } } if (!$loadfocusnow) { if (method_exists($editor, 'load_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' };'; } if (method_exists($editor, 'focus_script')) { $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' };'; } $form['buttons']['cancel']['tags'] .= ' onclick="return qa_toggle_element()"'; } if (count($onloads)) { $qa_content['script_onloads'][] = $onloads; } } $form['id'] = $formid; $form['collapse'] = !$loadfocusnow; $form['style'] = 'tall'; return $form; }
</td> </tr> <!-- <tr> <td class="qa-form-tall-label"> Your name to display (optional): </td> </tr> <tr> <td class="qa-form-tall-data"> <input name="name" type="text" value="" class="qa-form-tall-text"> </td> </tr> --> <tbody> <?php if (qa_is_logged_in() == false) { ?> <tr> <td class="qa-form-tall-label"> 请输入验证码: </td> </tr> <tr> <td class="qa-form-tall-data"> <div id="qa_captcha_div_1"><table><tbody><tr><td><img src="/bmf/captcha.php"></td><td><input name="captcha" style="width:80px;"></td></tr></tbody></table></div> <div class="qa-form-tall-note"> <a href="http://beimeifang.net/?qa=login">登录</a> 或 <a href="http://beimeifang.net/?qa=register">注册</a>后不会被要求输入验证码。</div> </td> </tr> <?php } ?>
Description: Override something in base theme class for Candy theme This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. More about this license: http://www.question2answer.org/license.php */ if (!qa_is_logged_in() and !(strpos(qa_self_html(), 'login') !== false)) { qa_redirect('login'); } else { class qa_html_theme extends qa_html_theme_base { function nav_user_search() { $this->search(); $this->nav('user'); } function sidepanel() { $this->output('<DIV CLASS="content-flow"><DIV CLASS="content-top"></DIV><DIV CLASS="content-wrapper"><DIV CLASS="qa-sidepanel">'); $this->sidebar(); $this->nav('cat'); $this->output_raw(@$this->content['sidepanel']);