function logout_html($tourl)
 {
     require_once QA_INCLUDE_DIR . "qa-base.php";
     $_SESSION['logout_url'] = $tourl;
     $logout_url = qa_path('auth/logout', null, qa_path_to_root());
     echo '<a href="' . $logout_url . '">' . qa_lang_html('main/nav_logout') . '</a>';
 }
Example #2
0
            // handles can't contain @ symbols
            $matchusers = qa_db_user_find_by_email($inemailhandle);
        } else {
            $matchusers = qa_db_user_find_by_handle($inemailhandle);
        }
        if (count($matchusers) == 1) {
            // if matches more than one (should be impossible), don't log in
            $inuserid = $matchusers[0];
            $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($inuserid, true));
            if (strtolower(qa_db_calc_passcheck($inpassword, $userinfo['passsalt'])) == strtolower($userinfo['passcheck'])) {
                // login and redirect
                require_once QA_INCLUDE_DIR . 'qa-app-users.php';
                qa_set_logged_in_user($inuserid, $userinfo['handle'], $inremember ? true : false);
                $topath = qa_get('to');
                if (isset($topath)) {
                    qa_redirect_raw(qa_path_to_root() . $topath);
                } elseif ($passwordsent) {
                    qa_redirect('account');
                } else {
                    qa_redirect('welcome');
                }
            } else {
                $errors['password'] = qa_lang('users/password_wrong');
            }
        } else {
            $errors['emailhandle'] = qa_lang('users/user_not_found');
        }
    } else {
        $pageerror = qa_lang('users/login_limit');
    }
} else {
Example #3
0
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
$handle = qa_request_part(1);
if (!strlen($handle)) {
    qa_redirect('users');
}
//	Get the HTML to display for the handle, and if we're using external users, determine the userid
if (QA_FINAL_EXTERNAL_USERS) {
    $publictouserid = qa_get_userids_from_public(array($handle));
    if (!count($publictouserid)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    $userid = reset($publictouserid);
    // don't use $publictouserid[$handle] since $handle capitalization might be different
    $usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true);
    $userhtml = @$usershtml[$userid];
} else {
    $userhtml = qa_html($handle);
}
//	Find the user profile and questions and answers for this handle
$loginuserid = qa_get_logged_in_userid();
$identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle;
@(list($useraccount, $userprofile, $userfields, $userpoints, $userrank, $questions, $answerqs, $commentqs, $editqs, $favorite) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_profile_selectspec($handle, false), QA_FINAL_EXTERNAL_USERS ? null : qa_db_userfields_selectspec(), qa_db_user_points_selectspec($identifier), qa_db_user_rank_selectspec($identifier), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_user_posts')), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier), isset($loginuserid) && !QA_FINAL_EXTERNAL_USERS ? qa_db_is_favorite_selectspec($loginuserid, QA_ENTITY_USER, $handle) : null));
//	Check the user exists and work out what can and can't be set (if not using single sign-on)
$loginlevel = qa_get_logged_in_level();
if (!QA_FINAL_EXTERNAL_USERS) {
    // if we're using integrated user management, we can know and show more
    if (!is_array($userpoints) && !is_array($useraccount)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
Example #4
0
 function badge_notify()
 {
     $userid = qa_get_logged_in_userid();
     qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^userbadges (' . 'awarded_at DATETIME NOT NULL,' . 'user_id INT(11) NOT NULL,' . 'notify TINYINT DEFAULT 0 NOT NULL,' . 'object_id INT(10),' . 'badge_slug VARCHAR (64) CHARACTER SET ascii DEFAULT \'\',' . 'id INT(11) NOT NULL AUTO_INCREMENT,' . 'PRIMARY KEY (id)' . ') ENGINE=MyISAM DEFAULT CHARSET=utf8');
     $result = qa_db_read_all_values(qa_db_query_sub('SELECT badge_slug FROM ^userbadges WHERE user_id=# AND notify>=1', $userid));
     if (count($result) > 0) {
         $notice = '<div class="notify-container">';
         if (count($result) == 1) {
             $slug = $result[0];
             $badge_name = qa_lang('badges/' . $slug);
             if (!qa_opt('badge_' . $slug . '_name')) {
                 qa_opt('badge_' . $slug . '_name', $badge_name);
             }
             $name = qa_opt('badge_' . $slug . '_name');
             $notice .= '<div class="badge-notify notify">' . qa_lang('badges/badge_notify') . "'" . $name . '\'&nbsp;&nbsp;' . qa_lang('badges/badge_notify_profile_pre') . '<a href="' . qa_path_html((QA_FINAL_EXTERNAL_USERS ? qa_path_to_root() : '') . 'user/' . qa_get_logged_in_handle(), array('tab' => 'badges'), qa_opt('site_url')) . '">' . qa_lang('badges/badge_notify_profile') . '</a><div class="notify-close" onclick="jQuery(this).parent().slideUp(\'slow\')">x</div></div>';
         } else {
             $number_text = count($result) > 2 ? str_replace('#', count($result) - 1, qa_lang('badges/badge_notify_multi_plural')) : qa_lang('badges/badge_notify_multi_singular');
             $slug = $result[0];
             $badge_name = qa_lang('badges/' . $slug);
             if (!qa_opt('badge_' . $slug . '_name')) {
                 qa_opt('badge_' . $slug . '_name', $badge_name);
             }
             $name = qa_opt('badge_' . $slug . '_name');
             $notice .= '<div class="badge-notify notify">' . qa_lang('badges/badge_notify') . "'" . $name . '\'&nbsp;' . $number_text . '&nbsp;&nbsp;' . qa_lang('badges/badge_notify_profile_pre') . '<a href="' . qa_path_html('user/' . qa_get_logged_in_handle(), array('tab' => 'badges'), qa_opt('site_url')) . '">' . qa_lang('badges/badge_notify_profile') . '</a><div class="notify-close" onclick="jQuery(this).parent().slideUp(\'slow\')">x</div></div>';
         }
         $notice .= '</div>';
         // remove notification flag
         qa_db_query_sub('UPDATE ^userbadges SET notify=0 WHERE user_id=# AND notify>=1', $userid);
         $this->badge_notice = $notice;
     }
 }
Example #5
0
function qa_load_theme_class($theme, $template, $content, $request)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    global $qa_layers;
    //	First load the default class
    require_once QA_INCLUDE_DIR . 'qa-theme-base.php';
    $classname = 'qa_html_theme_base';
    //	Then load the selected theme if valid, otherwise load the Classic theme
    if (!file_exists(QA_THEME_DIR . $theme . '/qa-styles.css')) {
        $theme = 'Classic';
    }
    $themeroothtml = qa_html(qa_path_to_root() . 'qa-theme/' . $theme . '/');
    if (file_exists(QA_THEME_DIR . $theme . '/qa-theme.php')) {
        require_once QA_THEME_DIR . $theme . '/qa-theme.php';
        if (class_exists('qa_html_theme')) {
            $classname = 'qa_html_theme';
        }
    }
    //	Create the list of layers to load
    $loadlayers = $qa_layers;
    if (!qa_user_maximum_permit_error('permit_view_voters_flaggers')) {
        $loadlayers[] = array('directory' => QA_INCLUDE_DIR . 'plugins/', 'include' => 'qa-layer-voters-flaggers.php', 'urltoroot' => null);
    }
    //	Then load any theme layers using some class-munging magic (substitute class names)
    $layerindex = 0;
    foreach ($loadlayers as $layer) {
        $filename = $layer['directory'] . $layer['include'];
        $layerphp = file_get_contents($filename);
        if (strlen($layerphp)) {
            $newclassname = 'qa_layer_' . ++$layerindex . '_from_' . preg_replace('/[^A-Za-z0-9_]+/', '_', basename($layer['include']));
            // include file name in layer class name to make debugging easier if there is an error
            if (preg_match('/\\s+class\\s+qa_html_theme_layer\\s+extends\\s+qa_html_theme_base\\s+/im', $layerphp) != 1) {
                qa_fatal_error('Class for layer must be declared as "class qa_html_theme_layer extends qa_html_theme_base" in ' . $layer['directory'] . $layer['include']);
            }
            $searchwordreplace = array('qa_html_theme_base::qa_html_theme_base' => $classname . '::__construct', 'parent::qa_html_theme_base' => 'parent::__construct', 'qa_html_theme_layer' => $newclassname, 'qa_html_theme_base' => $classname, 'QA_HTML_THEME_LAYER_DIRECTORY' => "'" . $layer['directory'] . "'", 'QA_HTML_THEME_LAYER_URLTOROOT' => "'" . qa_path_to_root() . $layer['urltoroot'] . "'");
            foreach ($searchwordreplace as $searchword => $replace) {
                if (preg_match_all('/\\W(' . preg_quote($searchword, '/') . ')\\W/im', $layerphp, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) {
                    $searchmatches = array_reverse($matches[1]);
                    // don't use preg_replace due to complication of escaping replacement phrase
                    foreach ($searchmatches as $searchmatch) {
                        $layerphp = substr_replace($layerphp, $replace, $searchmatch[1], strlen($searchmatch[0]));
                    }
                }
            }
            //	echo '<pre style="text-align:left;">'.htmlspecialchars($layerphp).'</pre>'; // to debug munged code
            qa_eval_from_file($layerphp, $filename);
            $classname = $newclassname;
        }
    }
    //	Finally, instantiate the object
    $themeclass = new $classname($template, $content, $themeroothtml, $request);
    return $themeclass;
}
Example #6
0
function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    if (!isset($neaturls)) {
        require_once QA_INCLUDE_DIR . 'qa-app-options.php';
        $neaturls = qa_opt('neat_urls');
    }
    if (!isset($rooturl)) {
        $rooturl = qa_path_to_root();
    }
    $url = $rooturl . (empty($rooturl) || substr($rooturl, -1) == '/' ? '' : '/');
    $paramsextra = '';
    $requestparts = explode('/', $request);
    $pathmap = qa_get_request_map();
    if (isset($pathmap[$requestparts[0]])) {
        $newpart = $pathmap[$requestparts[0]];
        if (strlen($newpart)) {
            $requestparts[0] = $newpart;
        } elseif (count($requestparts) == 1) {
            array_shift($requestparts);
        }
    }
    foreach ($requestparts as $index => $requestpart) {
        $requestparts[$index] = urlencode($requestpart);
    }
    $requestpath = implode('/', $requestparts);
    switch ($neaturls) {
        case QA_URL_FORMAT_INDEX:
            if (!empty($request)) {
                $url .= 'index.php/' . $requestpath;
            }
            break;
        case QA_URL_FORMAT_NEAT:
            $url .= $requestpath;
            break;
        case QA_URL_FORMAT_PARAM:
            if (!empty($request)) {
                $paramsextra = '?qa=' . $requestpath;
            }
            break;
        default:
            $url .= 'index.php';
        case QA_URL_FORMAT_PARAMS:
            if (!empty($request)) {
                foreach ($requestparts as $partindex => $requestpart) {
                    $paramsextra .= (strlen($paramsextra) ? '&' : '?') . 'qa' . ($partindex ? '_' . $partindex : '') . '=' . $requestpart;
                }
            }
            break;
    }
    if (isset($params)) {
        foreach ($params as $key => $value) {
            $paramsextra .= (strlen($paramsextra) ? '&' : '?') . urlencode($key) . '=' . urlencode((string) $value);
        }
    }
    return $url . $paramsextra . (empty($anchor) ? '' : '#' . urlencode($anchor));
}
Example #7
0
 /**
  * Custom ask button for medium and small screen
  *
  * @access private
  * @since Snow 1.4
  * @version 1.0
  * @return string Ask button html markup
  */
 private function ask_button()
 {
     return '<div class="qam-ask-search-box">' . '<div class="qam-ask-mobile">' . '<a href="' . qa_path('ask', null, qa_path_to_root()) . '" class="' . $this->ask_search_box_class . '">' . qa_lang_html('main/nav_ask') . '</a>' . '</div>' . '<div class="qam-search-mobile ' . $this->ask_search_box_class . '" id="qam-search-mobile">' . '</div>' . '</div>';
 }
 if ($type == 'number-blank') {
     $type = 'number';
 }
 $value = $options[$optionname];
 $optionfield = array('id' => $optionname, 'label' => ($indented ? '&ndash; ' : '') . qa_lang_html('options/' . $optionname), 'tags' => 'name="option_' . $optionname . '" id="option_' . $optionname . '"', 'value' => qa_html($value), 'type' => $type, 'error' => qa_html(@$errors[$optionname]));
 if (isset($optionmaximum[$optionname])) {
     $optionfield['note'] = qa_lang_html_sub('admin/maximum_x', $optionmaximum[$optionname]);
 }
 $feedrequest = null;
 $feedisexample = false;
 switch ($optionname) {
     // special treatment for certain options
     case 'site_language':
         require_once QA_INCLUDE_DIR . 'qa-util-string.php';
         qa_optionfield_make_select($optionfield, qa_admin_language_options(), $value, '');
         $optionfield['suffix'] = strtr(qa_lang_html('admin/check_language_suffix'), array('^1' => '<a href="' . qa_html(qa_path_to_root() . 'qa-include/qa-check-lang.php') . '">', '^2' => '</a>'));
         if (!qa_has_multibyte()) {
             $optionfield['error'] = qa_lang_html('admin/no_multibyte');
         }
         break;
     case 'neat_urls':
         $neatoptions = array();
         $rawoptions = array(QA_URL_FORMAT_NEAT, QA_URL_FORMAT_INDEX, QA_URL_FORMAT_PARAM, QA_URL_FORMAT_PARAMS, QA_URL_FORMAT_SAFEST);
         foreach ($rawoptions as $rawoption) {
             $neatoptions[$rawoption] = '<iframe src="' . qa_path_html('url/test/' . QA_URL_TEST_STRING, array('dummy' => '', 'param' => QA_URL_TEST_STRING), null, $rawoption) . '" width="20" height="16" style="vertical-align:middle; border:0" scrolling="no" frameborder="0"></iframe>&nbsp;' . '<small>' . qa_html(urldecode(qa_path('123/why-do-birds-sing', null, '/', $rawoption))) . ($rawoption == QA_URL_FORMAT_NEAT ? strtr(qa_lang_html('admin/neat_urls_note'), array('^1' => '<a href="http://www.question2answer.org/htaccess.php" target="_blank">', '^2' => '</a>')) : '') . '</small>';
         }
         qa_optionfield_make_select($optionfield, $neatoptions, $value, QA_URL_FORMAT_SAFEST);
         $optionfield['type'] = 'select-radio';
         $optionfield['note'] = qa_lang_html_sub('admin/url_format_note', '<span style=" ' . qa_admin_url_test_html() . '/span>');
         break;
     case 'site_theme':
Example #9
0
 /**
  * Custom ask button for medium and small screen
  *
  * @access private
  * @since Snow 1.4
  * @version 1.0
  * @return string Ask button html markup
  *
  * @author Q2A Market <http://www.q2amarket.com>
  * @copyright (c) 2014, Q2A Market
  * @license http://www.gnu.org/copyleft/gpl.html
  */
 private function ask_button()
 {
     $html = '<div class="qam-ask-search-box">';
     $html .= '<div class="qam-ask-mobile"><a href="' . qa_path('ask', null, qa_path_to_root()) . '" class="' . $this->qam_opt('ask_search_box_color') . '">' . qa_lang_html('main/nav_ask') . '</a></div>';
     $html .= '<div class="qam-search-mobile ' . $this->qam_opt('ask_search_box_color') . '" id="qam-search-mobile"></div>';
     $html .= '</div>';
     return $html;
 }
Example #10
0
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;
}
Example #11
0
    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;
        }
    }
Example #12
0
/**
 * returns the base url for the theme
 *
 * @return string
 */
function donut_theme_url()
{
    return qa_path_to_root() . donut_theme_folder();
}
Example #13
0
    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;
    }
Example #14
0
    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;
    }
Example #15
0
    static function printCode($provider, $tourl, $context, $action = 'login', $print = true)
    {
        $css = $key = strtolower($provider);
        if ($key == 'live') {
            $css = 'windows';
            // translate provider name to zocial css class
        } else {
            if ($key == 'googleplus') {
                $provider = 'Google+';
            }
        }
        $showInHeader = qa_opt("{$key}_app_shortcut") ? true : false;
        if ($action == 'login' && !$showInHeader && $context == 'menu') {
            // do not show login button in the header for this
            return;
        }
        $zocial = qa_opt('open_login_zocial') == '1' ? 'zocial' : '';
        // use zocial buttons
        if ($action == 'logout') {
            $url = $tourl;
            $classes = "{$context} action-logout {$zocial} {$css}";
            $title = qa_lang_html('main/nav_logout');
            $text = qa_lang_html('main/nav_logout');
        } else {
            if ($action == 'login') {
                $topath = qa_get('to');
                // lets user switch between login and register without losing destination page
                // clean GET parameters (not performed when to parameter is already passed)
                $get = $_GET;
                unset($get['provider']);
                unset($get['code']);
                $tourl = isset($topath) ? $topath : qa_path(qa_request(), $get, '');
                // build our own tourl
                $params = array('login' => $key);
                $url = qa_path('login', $params, qa_path_to_root());
                if (strlen($tourl) > 0) {
                    $url .= '&amp;to=' . $tourl;
                    // play nice with validators
                }
                $classes = "{$context} action-login {$zocial}  {$css}";
                $title = qa_lang_html_sub('plugin_open/login_using', $provider);
                $text = $provider . ' ' . qa_lang_html('main/nav_login');
                if ($context != 'menu') {
                    $text = $title;
                }
            } else {
                if ($action == 'link') {
                    $url = qa_path('logins', array('link' => $key), qa_path_to_root());
                    // build our own url
                    $classes = "{$context} action-link {$zocial} {$css}";
                    $title = qa_lang_html_sub('plugin_open/login_using', $provider);
                    $text = qa_lang_html('main/nav_login');
                    if ($context != 'menu') {
                        $text = $title;
                    }
                } else {
                    if ($action == 'view') {
                        $url = 'javascript://';
                        $classes = "{$context} action-link {$zocial} {$css}";
                        $title = $provider;
                        $text = $tourl;
                    }
                }
            }
        }
        $html = <<<HTML
  <a class="open-login-button context-{$classes}" title="{$title}" href="{$url}" rel="nofollow">{$text}</a>
HTML;
        if ($print) {
            echo $html;
        } else {
            return $html;
        }
    }