function process_request($request)
 {
     // double check we are admin
     if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
         return;
     }
     if (qa_clicked('docancel')) {
         qa_redirect('admin/plugins');
     }
     $qa_content = qa_content_prepare();
     $qa_content['title'] = 'Widget Anywhere';
     $qa_content['custom'] = '<p><a href="' . qa_path('admin/plugins') . '#' . qa_html($this->anchor) . '">&laquo; back to plugin options</a></p>';
     $saved_msg = null;
     $editid = qa_get('editid');
     if (qa_post_text('dodelete')) {
         $this->delete_widget();
         qa_redirect('admin/plugins');
     } else {
         if (qa_clicked('save_button')) {
             // save widget
             $widget = $this->save_widget();
             $saved_msg = 'Widget saved.';
         } else {
             if (empty($editid)) {
                 // display blank form
                 $widget = array('id' => 0, 'title' => '', 'pages' => '', 'position' => '', 'ordering' => 1, 'content' => '');
             } else {
                 // load specified widget
                 $sql = 'SELECT * FROM ^' . $this->pluginkey . ' WHERE id=#';
                 $result = qa_db_query_sub($sql, $editid);
                 $widget = qa_db_read_one_assoc($result);
             }
         }
     }
     $sel_position = empty($widget['position']) ? null : @$this->positionlangs[$widget['position']];
     // set up page (template) list
     $widget_pages = explode(',', $widget['pages']);
     $sel_pages = array();
     $custom_pages = array();
     foreach ($widget_pages as $page) {
         if (strpos($page, 'custom:') === 0) {
             $custom_pages[] = substr($page, 7);
         } else {
             $sel_pages[] = $page;
         }
     }
     // $chkd = in_array('all', $sel_pages) ? 'checked' : '';
     // $pages_html = '<label><input type="checkbox" name="wpages_all" ' . $chkd . '> ' . qa_lang_html('admin/widget_all_pages') . '</label><br><br>';
     $pages_html = '';
     foreach ($this->templatelangkeys as $tmpl => $langkey) {
         $chkd = in_array($tmpl, $sel_pages) ? 'checked' : '';
         $pages_html .= '<label><input type="checkbox" name="wpages_' . $tmpl . '" ' . $chkd . '> ' . qa_lang_html($langkey) . '</label><br>';
     }
     $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $saved_msg, 'fields' => array('title' => array('label' => 'Title', 'tags' => 'NAME="wtitle"', 'value' => qa_html($widget['title'])), 'position' => array('type' => 'select', 'label' => 'Position', 'tags' => 'NAME="wposition"', 'options' => $this->positionlangs, 'value' => $sel_position), 'all_pages' => array('type' => 'checkbox', 'id' => 'tb_pages_all', 'label' => qa_lang_html('admin/widget_all_pages'), 'tags' => 'NAME="wpages_all" ID="wpages_all"', 'value' => in_array('all', $sel_pages)), 'pages' => array('type' => 'custom', 'id' => 'tb_pages_list', 'label' => qa_lang_html('admin/widget_pages_explanation'), 'html' => $pages_html), 'show_custom_pages' => array('type' => 'checkbox', 'id' => 'tb_show_custom_pages', 'label' => 'Show on custom page(s)', 'tags' => 'NAME="cb_custom_pages" ID="cb_custom_pages"', 'value' => count($custom_pages) > 0), 'custom_pages' => array('id' => 'tb_custom_pages', 'label' => 'Page slugs', 'tags' => 'NAME="wpages_custom"', 'value' => qa_html(implode(',', $custom_pages)), 'note' => 'Separate multiple page slugs (URL fragments) with commas, e.g. <code>custom-page,other-page</code>'), 'ordering' => array('type' => 'number', 'label' => 'Order', 'tags' => 'NAME="wordering"', 'value' => qa_html($widget['ordering'])), 'content' => array('type' => 'textarea', 'label' => 'Content (HTML)', 'tags' => 'NAME="wcontent"', 'value' => qa_html($widget['content']), 'rows' => 12)), 'hidden' => array('wid' => $widget['id']), 'buttons' => array('save' => array('tags' => 'NAME="save_button"', 'label' => 'Save widget', 'value' => '1'), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))));
     if ($widget['id'] > 0) {
         $qa_content['form']['fields']['delete'] = array('tags' => 'NAME="dodelete"', 'label' => 'Delete widget', 'value' => 0, 'type' => 'checkbox');
     }
     qa_set_display_rules($qa_content, array('tb_pages_list' => '!wpages_all', 'tb_show_custom_pages' => '!wpages_all', 'tb_custom_pages' => 'cb_custom_pages && !wpages_all'));
     return $qa_content;
 }
Example #2
0
 function qa_permit_check($opt)
 {
     if (qa_opt($opt) == QA_PERMIT_POINTS) {
         return qa_get_logged_in_points() >= qa_opt($opt . '_points');
     }
     return !qa_permit_value_error(qa_opt($opt), qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags());
 }
Example #3
0
function cs_ajax_delete_widget()
{
    if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
        $id = strip_tags($_REQUEST['id']);
        widget_opt_delete($id);
    }
    die;
}
Example #4
0
/**
 *判断是否为超级管理员
 */
function isManager()
{
    if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
        return true;
    } else {
        return false;
    }
}
 function forbid_new_tag()
 {
     $q_edit = $this->template == 'ask' || isset($this->content['form_q_edit']);
     $tag_prevent = qa_opt('tag_synonyms_prevent');
     if ($q_edit && $tag_prevent) {
         return qa_get_logged_in_points() < (int) qa_opt('tag_synonyms_rep') && qa_get_logged_in_level() < QA_USER_LEVEL_EXPERT;
     }
     return false;
 }
Example #6
0
/**
 * Adds few more links in the admin subnavigation
 *
 * @return array
 */
function donut_admin_sub_navigation()
{
    $navigation = array();
    $level = qa_get_logged_in_level();
    if ($level >= QA_USER_LEVEL_ADMIN) {
        $url = 'admin/donut-theme/general-settings';
        $navigation[$url] = array('label' => donut_lang('donut_theme_settings'), 'url' => qa_path_html($url));
    }
    return $navigation;
}
 function head_custom()
 {
     qa_html_theme_base::head_custom();
     if (!qa_opt('badge_active')) {
         return;
     }
     if ($this->request == 'admin/plugins' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $this->output("\n\t\t\t\t<script>" . (qa_opt('badge_notify_time') != '0' ? "\n\t\t\t\t\tjQuery('document').ready(function() { jQuery('.notify-container').delay(" . (int) qa_opt('badge_notify_time') * 1000 . ").slideUp('fast'); });" : "") . "\n\t\t\t\t\tfunction badgeEdit(slug,end) {\n\t\t\t\t\t\tif(end) {\n\t\t\t\t\t\t\tjQuery('#badge_'+slug+'_edit').hide();\n\t\t\t\t\t\t\tjQuery('#badge_'+slug+'_badge').show();\n\t\t\t\t\t\t\tjQuery('#badge_'+slug+'_badge').html(jQuery('#badge_'+slug+'_edit').val());\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tjQuery('#badge_'+slug+'_badge').hide();\n\t\t\t\t\t\tjQuery('#badge_'+slug+'_edit').show();\n\t\t\t\t\t\tjQuery('#badge_'+slug+'_edit').focus();\n\t\t\t\t\t}\n\t\t\t\t</script>");
     }
     $this->output('<style>', qa_opt('badges_css'), '</style>');
 }
Example #8
0
function mp_announcements_sub_navigation()
{
    $level = qa_get_logged_in_level();
    $navigation = array();
    if ($level >= QA_USER_LEVEL_EDITOR) {
        $navigation = array('default' => array('url' => qa_path_html('mp-announcements-page'), 'label' => qa_lang_html('announcements/link_all')), 'create' => array('url' => qa_path_html('mp-announcements-create-page'), 'label' => qa_lang_html('announcements/link_create')));
    } else {
        $navigation = array('default' => array('url' => qa_path_html('mp-announcements-page'), 'label' => qa_lang_html('announcements/link_all')));
    }
    return $navigation;
}
    function q_view_clear()
    {
        // call default method output
        qa_html_theme_base::q_view_clear();
        // return if not admin!
        if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
            return;
        }
        // check if question is duplicate
        $closed = @$this->content['q_view']['raw']['closedbyid'] !== null;
        if ($closed) {
            // check if duplicate
            $duplicate = qa_db_read_one_value(qa_db_query_sub('SELECT postid FROM `^posts` 
																		WHERE `postid` = #
																		AND `type` = "Q"
																		;', $this->content['q_view']['raw']['closedbyid']), true);
            if ($duplicate) {
                $this->output('<div id="mergeDup" style="margin:10px 0 0 120px;padding:5px 10px;background:#FCC;border:1px solid #AAA;"><h3>Merge Duplicate:</h3>');
                // form output
                $this->output('
<FORM METHOD="POST">
<TABLE>
	<TR>
		<TD CLASS="qa-form-tall-label">
			From: &nbsp;
			<INPUT NAME="merge_from" id="merge_from" TYPE="text" VALUE="' . $this->content['q_view']['raw']['postid'] . '" CLASS="qa-form-tall-number">
			&nbsp; To: &nbsp;
			<INPUT NAME="merge_to" id="merge_to" TYPE="text" VALUE="' . $this->content['q_view']['raw']['closedbyid'] . '" CLASS="qa-form-tall-number">
		</TD>
	</TR>
	<TR>
		<TD CLASS="qa-form-tall-label">
		Text to show when redirecting from merged question:
		</TD>
	</TR>
	<TR>
		<TD CLASS="qa-form-tall-label">
		<INPUT NAME="merge_question_merged" id="merge_question_merged" TYPE="text" VALUE="' . qa_opt('merge_question_merged') . '" CLASS="qa-form-tall-text">
		</TD>
	</TR>
	<TR>
		<TD style="text-align:right;">
			<INPUT NAME="merge_question_process" VALUE="Merge" TITLE="" TYPE="submit" CLASS="qa-form-tall-button qa-form-tall-button-0">
		</TD>

	</TR>
	
</TABLE>
</FORM>				');
                $this->output('</div>');
            }
        }
    }
function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null)
{
    $rules = qa_page_q_post_rules_base($post, $parentpost, $siblingposts, $childposts);
    qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^postmeta (
			meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
			post_id bigint(20) unsigned NOT NULL,
			meta_key varchar(255) DEFAULT \'\',
			meta_value longtext,
			PRIMARY KEY (meta_id),
			KEY post_id (post_id),
			KEY meta_key (meta_key)
			) ENGINE=MyISAM  DEFAULT CHARSET=utf8');
    $expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE meta_key='is_expert_question' AND post_id=#", $post['postid']), true);
    if ($expert) {
        if (!qa_permit_value_error(qa_opt('expert_question_roles'), qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags())) {
            $is_expert = true;
        }
        $users = qa_opt('expert_question_users');
        $users = explode("\n", $users);
        $handle = qa_get_logged_in_handle();
        foreach ($users as $idx => $user) {
            if ($user == $handle) {
                $is_expert = true;
                break;
            }
            if (strpos($user, '=')) {
                $user = explode('=', $user);
                if ($user[0] == $handle) {
                    $catnames = explode(',', $user[1]);
                    $cats = qa_db_read_all_values(qa_db_query_sub('SELECT categoryid FROM ^categories WHERE title IN ($)', $catnames));
                    $is_expert = $cats;
                }
            }
        }
        if (isset($is_expert) && !$rules['viewable']) {
            // experts that aren't allowed to change hidden questions
            if (is_array($is_expert)) {
                $in_cats = qa_db_read_one_value(qa_db_query_sub("SELECT COUNT(postid) FROM ^posts WHERE categoryid IN (#) AND postid=#", $is_expert, $post['postid']), true);
                if ($in_cats) {
                    $rules['viewable'] = true;
                }
            } else {
                $rules['viewable'] = true;
            }
        }
        $rules['reshowable'] = false;
        $rules['answerbutton'] = true;
        $rules['commentbutton'] = true;
        $rules['commentable'] = true;
    }
    return $rules;
}
 function head_script()
 {
     // insert Javascript into the <head>
     $google_UA = qa_opt('google_analytics_UA');
     $is_admin = qa_get_logged_in_level() == 120 ? true : false;
     if (!empty($google_UA)) {
         if (!($is_admin && qa_opt('google_analytics_show_for_admin'))) {
             // the loged in user is not the admin
             $this->content['script'][] = '<script type="text/javascript">' . 'var _gaq = _gaq || [];' . '_gaq.push([\'_setAccount\', \'' . $google_UA . '\']);' . '_gaq.push([\'_trackPageview\']);' . '(function() {' . 'var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;' . 'ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';' . 'var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);' . '})();' . '</script>';
         }
     }
     qa_html_theme_base::head_script();
 }
 function head_script()
 {
     // insert Javascript into the <head>
     $google_UA = qa_opt('google_analytics_UA');
     $google_domain = qa_opt('google_analytics_domain');
     $is_admin = qa_get_logged_in_level() == 120 ? true : false;
     if (!empty($google_UA)) {
         if (!($is_admin && qa_opt('google_analytics_show_for_admin'))) {
             // the loged in user is not the admin
             $this->content['script'][] = $google_UA;
         }
     }
     qa_html_theme_base::head_script();
 }
function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null)
{
    // default function call
    $rules = qa_page_q_post_rules_base($post, $parentpost, $siblingposts, $childposts);
    $userid = qa_get_logged_in_userid();
    $level = qa_get_logged_in_level();
    // do not show answer button if spam-limit exceeded (git-suggest)
    if (!qa_limits_remaining($userid, QA_LIMIT_ANSWERS)) {
        $rules['answerbutton'] = false;
    }
    // users are never allowed to hide posts
    $rules['hideable'] = false;
    // normal users are not allowed to edit posts after x min
    $timestamp = time();
    // edit time frame: 5 min (300s) for questions/comments + 20 min (1200s) for answers
    if ($post['type'] == 'A') {
        $rules['editable'] = $rules['editbutton'] = $rules['isbyuser'] && $timestamp - $post['created'] < 1200;
    } else {
        $rules['editable'] = $rules['editbutton'] = $rules['isbyuser'] && $timestamp - $post['created'] < 300;
    }
    // questions cannot be reopened, only admin
    $rules['reopenable'] = $rules['reopenable'] && $level >= QA_USER_LEVEL_ADMIN;
    // Moderator
    if ($level == QA_USER_LEVEL_EXPERT) {
        // allowed to edit own answers and all questions
        // time frame: allow edit after 5 min and up to 7 days (604800 sec), can edit his own answer immediately
        $rules['editable'] = $rules['editbutton'] = ($rules['isbyuser'] || $post['type'] == 'Q') && !isset($post['closedbyid']) && $post['userid'] != 1;
        // never allow question-posts of admin to be edited
    } else {
        if ($level == QA_USER_LEVEL_EDITOR) {
            // can edit all posts in forum, but not admin posts
            $rules['editable'] = $rules['editbutton'] = $post['userid'] != 1;
            // can clear flags
            $rules['clearflaggable'] = $post['flagcount'] >= (@$post['userflag'] ? 2 : 1);
        }
    }
    // && ( ($timestamp - $post['created'] > 300) || $rules['isbyuser'] ) // can edit question just after 5 min OR his own answer immediately
    // && ($timestamp - $post['created'] < 604800 || $level>=QA_USER_LEVEL_EDITOR) // do not allow edit of posts older than 7 days, Redakteur can
    // admin has all rights
    if ($level >= QA_USER_LEVEL_ADMIN) {
        $rules['editable'] = $rules['editbutton'] = $rules['hideable'] = true;
    }
    // experts, moderators, admins can close questions
    $rules['closeable'] = $level >= QA_USER_LEVEL_EXPERT && !$rules['closed'];
    // && ($timestamp - $post['created'] < 1209600) ); // within 7 days
    // do not show retag button as it does the same as edit button
    $rules['retagcatbutton'] = false;
    return $rules;
}
Example #14
0
 function process_request($request)
 {
     if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
         $qa_content = qa_content_prepare();
         $qa_content['error'] = "You don't have permission to access this page.";
         return $qa_content;
     }
     $qa_content = qa_content_prepare();
     $qa_content['site_title'] = "Infinity Theme";
     $qa_content['title'] = "Theme Option";
     $qa_content['error'] = "";
     $qa_content['suggest_next'] = "";
     $qa_content['custom'] = $this->page_form();
     $qa_content['sidepanel'] = '';
     return $qa_content;
 }
Example #15
0
function qa_admin_check_privileges(&$qa_content)
{
    global $qa_login_userid, $qa_request;
    if (!isset($qa_login_userid)) {
        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;
}
Example #16
0
 function doctype()
 {
     if ($this->request == 'admin/permissions' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'signature_allow';
         $permits[] = 'signature_edit_allow';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('signature_plugin/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'value' => $value, 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . '&nbsp;', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     if (qa_opt('signatures_enable')) {
         // add user signature
         if ($this->template == 'user' && isset($this->content['form_activity']) && !qa_get('tab')) {
             $sig_form = $this->content['user_signature_form'];
             // from overrides
             // insert our form
             if (isset($this->content['q_list'])) {
                 // array splicing kungfu thanks to Stack Exchange
                 // This adds form-signature before q_list
                 $keys = array_keys($this->content);
                 $vals = array_values($this->content);
                 $insertBefore = array_search('q_list', $keys);
                 $keys2 = array_splice($keys, $insertBefore);
                 $vals2 = array_splice($vals, $insertBefore);
                 $keys[] = 'form-signature';
                 $vals[] = $sig_form;
                 $this->content = array_merge(array_combine($keys, $vals), array_combine($keys2, $vals2));
             } else {
                 $this->content['form-signature'] = $sig_form;
             }
         }
     }
     qa_html_theme_base::doctype();
 }
Example #17
0
 function doctype()
 {
     if ($this->request == 'admin/permissions' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'xmlrpc_access';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('xmlrpc/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'value' => $value, 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . '&nbsp;', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     qa_html_theme_base::doctype();
 }
Example #18
0
 function doctype()
 {
     if ($this->request == 'admin/emails') {
         if (qa_post_text('option_notify_admin_a_post')) {
             qa_opt('notify_admin_a_post', (bool) qa_post_text('option_notify_admin_a_post'));
             qa_opt('notify_admin_c_post', (bool) qa_post_text('option_notify_admin_c_post'));
         }
         foreach ($this->content['form']['fields'] as $key => $val) {
             $arr[$key] = $val;
             if ($key == 'notify_admin_q_post') {
                 $arr['notify_admin_a_post'] = array('id' => 'notify_admin_a_post', 'label' => 'Email this address when an answer is posted', 'tags' => 'NAME="option_notify_admin_a_post" ID="option_notify_admin_a_post"', 'value' => qa_opt('notify_admin_a_post'), 'type' => 'checkbox', 'error' => '');
                 $arr['notify_admin_c_post'] = array('id' => 'notify_admin_a_post', 'label' => 'Email this address when a comment is posted', 'tags' => 'NAME="option_notify_admin_c_post" ID="option_notify_admin_c_post"', 'value' => qa_opt('notify_admin_c_post'), 'type' => 'checkbox', 'error' => '');
             }
             $this->content['form']['fields'] = $arr;
         }
     }
     if (qa_opt('admin_plus_notify') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN && (time() - (int) qa_opt('admin_plus_notify_checked')) / 3600 > qa_opt('admin_plus_notify_hours')) {
         qa_opt('admin_plus_notify_checked', time());
         $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php');
         if (count($pluginfiles)) {
             require_once QA_INCLUDE_DIR . 'qa-app-admin.php';
             $cnt = 0;
             foreach ($pluginfiles as $pluginfile) {
                 $plugindirectory = dirname($pluginfile) . '/';
                 $contents = file_get_contents($pluginfile);
                 $metadata = qa_admin_addon_metadata($contents, array('version' => 'Plugin Version', 'update' => 'Plugin Update Check URI'));
                 if (@$metadata['version'] && @$metadata['update']) {
                     $newdata = qa_admin_addon_metadata(qa_retrieve_url($metadata['update']), array('version' => 'Plugin Version', 'uri' => 'Plugin URI'));
                     if (strlen(@$newdata['version']) && strcmp($newdata['version'], $metadata['version'])) {
                         $this->content['notices'][] = qa_notice_form('updates', qa_viewer_html(qa_opt('admin_plus_notify_text'), 'html'));
                         $this->content['script'][] = "<script type=\"text/javascript\">jQuery(document).ready(function(){qa_reveal(document.getElementById('notice_updates'), 'notice');});</script>";
                         break;
                     }
                 }
             }
         }
     }
     qa_html_theme_base::doctype();
 }
 function is_expert_user()
 {
     if (!qa_permit_value_error(qa_opt('expert_question_roles'), qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags())) {
         return true;
     }
     $users = qa_opt('expert_question_users');
     $users = explode("\n", $users);
     $handle = qa_get_logged_in_handle();
     foreach ($users as $idx => $user) {
         if ($user == $handle) {
             return true;
         }
         if (strpos($user, '=')) {
             $user = explode('=', $user);
             if ($user[0] == $handle) {
                 $catnames = explode(',', $user[1]);
                 $cats = qa_db_read_all_values(qa_db_query_sub('SELECT categoryid FROM ^categories WHERE title IN ($)', $catnames));
                 return $cats;
             }
         }
     }
     return false;
 }
Example #20
0
 function getValidLoginUserData()
 {
     // Check if we have a valid registered user:
     if (!(qa_get_logged_in_userid() === null)) {
         $userData = array();
         $userId = qa_get_logged_in_userid();
         $userData['userID'] = $userId;
         $userData['userName'] = $this->trimUserName(qa_get_logged_in_handle());
         if (qa_get_logged_in_level() >= QA_USER_LEVEL_MODERATOR) {
             $userData['userRole'] = AJAX_CHAT_ADMIN;
         } elseif (qa_get_logged_in_level() == QA_USER_LEVEL_EDITOR) {
             $userData['userRole'] = AJAX_CHAT_MODERATOR;
         } else {
             $userData['userRole'] = AJAX_CHAT_USER;
         }
         $user = qa_db_select_with_pending(qa_db_user_account_selectspec($userId, true));
         $userData['avatar'] = qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true);
         return $userData;
     } else {
         // Guest users:
         return $this->getGuestUser();
     }
 }
 function process_request($request)
 {
     if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
         $qa_content = qa_content_prepare();
         $qa_content['error'] = "You don't have permission to access this page.";
         return $qa_content;
     }
     global $qa_modules;
     $qa_content = qa_content_prepare();
     $qa_content['site_title'] = "Q2A Ultimate SEO by QA-Themes.com ";
     $qa_content['title'] = "Ultimate SEO";
     $qa_content['error'] = "";
     $qa_content['suggest_next'] = "";
     $qa_content['script_rel'][] = $qa_modules['page']['Ultimate SEO Options']['urltoroot'] . 'include/easyResponsiveTabs.js';
     $qa_content['script_rel'][] = $qa_modules['page']['Ultimate SEO Options']['urltoroot'] . 'include/main.js';
     $qa_content['css_src'][] = $this->urltoroot . 'include/style.css';
     $qa_content['custom'] = $this->page_form();
     //empty sidebar's content
     $qa_content['sidepanel'] = '';
     $qa_content['sidebar'] = '';
     unset($qa_content['widgets']);
     $qa_content['widgets'] = array();
     return $qa_content;
 }
Example #22
0
function qa_admin_page_error()
{
    @(include_once QA_INCLUDE_DIR . 'qa-db-install.php');
    if (defined('QA_DB_VERSION_CURRENT') && qa_opt('db_version') < QA_DB_VERSION_CURRENT && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
        return strtr(qa_lang_html('admin/upgrade_db'), array('^1' => '<A HREF="' . qa_path_html('install') . '">', '^2' => '</A>'));
    } else {
        return null;
    }
}
Example #23
0
function qa_user_moderation_reason($userlevel = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    $reason = false;
    if (!isset($userlevel)) {
        $userlevel = qa_get_logged_in_level();
    }
    if ($userlevel < QA_USER_LEVEL_EXPERT && qa_user_permit_error('permit_moderate')) {
        $userid = qa_get_logged_in_userid();
        if (isset($userid)) {
            if (qa_opt('moderate_users') && qa_opt('moderate_unapproved') && $userlevel < QA_USER_LEVEL_APPROVED) {
                $reason = 'approve';
            } elseif (qa_opt('confirm_user_emails') && qa_opt('moderate_unconfirmed') && !(qa_get_logged_in_flags() & QA_USER_FLAGS_EMAIL_CONFIRMED)) {
                $reason = 'confirm';
            } elseif (qa_opt('moderate_by_points') && qa_get_logged_in_points() < qa_opt('moderate_points_limit')) {
                $reason = 'points';
            }
        } elseif (qa_opt('moderate_anon_post')) {
            $reason = 'login';
        }
    }
    return $reason;
}
Example #24
0
if ($explicitqa) {
    $slugs = array_slice($requestparts, 1);
} elseif (strlen($requestparts[0])) {
    $slugs = $requestparts;
} else {
    $slugs = array();
}
$countslugs = count($slugs);
//	Get list of questions, other bits of information that might be useful
$userid = qa_get_logged_in_userid();
list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'created', 0, $slugs, null, false, false, qa_opt_if_loaded('page_size_activity')), qa_db_recent_a_qs_selectspec($userid, 0, $slugs), qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null, $countslugs == 1 && !$explicitqa ? qa_db_page_full_selectspec($slugs[0], false) : null);
//	First, if this matches a custom page, return immediately with that page's content
if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
    qa_set_template('custom-' . $custompage['pageid']);
    $qa_content = qa_content_prepare();
    $level = qa_get_logged_in_level();
    if (!qa_permit_value_error($custompage['permit'], $userid, $level, qa_get_logged_in_flags()) || !isset($custompage['permit'])) {
        $qa_content['title'] = qa_html($custompage['heading']);
        $qa_content['custom'] = $custompage['content'];
        if ($level >= QA_USER_LEVEL_ADMIN) {
            $qa_content['navigation']['sub'] = array('admin/pages' => array('label' => qa_lang('admin/edit_custom_page'), 'url' => qa_path_html('admin/pages', array('edit' => $custompage['pageid']))));
        }
    } else {
        $qa_content['error'] = qa_lang_html('users/no_permission');
    }
    return $qa_content;
}
//	Then, see if we should redirect because the 'qa' page is the same as the home page
if ($explicitqa && !qa_is_http_post() && !qa_has_custom_home()) {
    qa_redirect(qa_category_path_request($categories, $categoryid), $_GET);
}
Example #25
0
	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
*/
define('QA_BASE_DIR', dirname(dirname(empty($_SERVER['SCRIPT_FILENAME']) ? __FILE__ : $_SERVER['SCRIPT_FILENAME'])) . '/');
require 'qa-base.php';
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
    qa_redirect('admin/general', null, qa_opt('site_url'));
}
header('Content-type: text/html; charset=utf-8');
?>
<HTML>
	<HEAD>
		<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=utf-8"/>
		<TITLE>Question2Answer Language Check</TITLE>
		<STYLE>
			code {font-size:125%;}
		</STYLE>
	</HEAD>
	<BODY STYLE="font-family:arial; font-size:12px;">
<?php 
function get_phrase_substitutions($phrase)
Example #26
0
    function main_parts($content)
    {
        qa_html_theme_base::main_parts($content);
        if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN and $this->template == 'question' and qa_opt('useo_meta_editor_enable')) {
            $this->output('<div class="qa-widgets-main qa-widgets-main-low">');
            $this->output('<form name="useo-meta-editor" action="' . qa_self_html() . '" method="post">');
            $this->output('
			<h2> Page Title And Meta Tags </h2>
			<strong>Only administrators can see this section.</strong>
			<table class="qa-form-tall-table">
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Page Title
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . $this->content['q_view']['raw']['title'] . '" id="useo-meta-editor-title" class="qa-form-tall-text" type="text" value="' . $this->meta_title . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>

				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Description Meta Tag
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<textarea placeholder="' . $this->content['description'] . '" id="useo-meta-editor-description" class="qa-form-tall-text" cols="40" rows="3" name="useo-meta-editor-description">' . $this->meta_description . '</textarea>
						</td>
					</tr>
				</tbody>
				<tbody id="useo-meta-keywords">
					<tr>
						<td class="qa-form-tall-label">
							Keywords Meta Tag
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . $this->content['keywords'] . '" id="useo-meta-editor-keywords" class="qa-form-tall-text" type="text" value="' . $this->meta_keywords . '" name="useo-meta-editor-keywords">
							<div class="qa-form-tall-note">A comma separated list of your most important keywords</div>
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td  id="useo_buttons_container_meta" class="qa-form-tall-buttons" colspan="1">
							<input id="useo_save_meta" class="qa-form-tall-button qa-form-tall-button-save" type="submit" title="" value="Save Options">
						</td>
					</tr>
				</tbody>
			</table>
			');
            $this->output('</form>');
            $this->output('<hr /></div>');
        }
        if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN and $this->template == 'question' and qa_opt('useo_social_enable_editor')) {
            $this->output('<div class="qa-widgets-main qa-widgets-main-low">');
            $this->output('<form name="useo-meta-editor" action="' . qa_self_html() . '" method="post">');
            $this->output('
			<h2> Social Tags Editor </h2>
			<p>Only administrators can see this section.</p>
			<h3>Open Graph</h3>
			<table class="qa-form-tall-table">
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Site Title
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . @$this->metas['og-sitename']['content'] . '" id="useo-og-sitename" class="qa-form-tall-text" type="text" value="' . @$this->social_metas['og-sitename'] . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Page Title
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . @$this->metas['og-title']['content'] . '" id="useo-og-title" class="qa-form-tall-text" type="text" value="' . @$this->social_metas['og-title'] . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Description Meta Tag
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<textarea placeholder="' . @$this->metas['og-description']['content'] . '" id="useo-og-description" class="qa-form-tall-text" cols="40" rows="3" name="useo-meta-editor-description">' . @$this->social_metas['og-description'] . '</textarea>
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Shared Page\'s URL
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . @$this->metas['og-url']['content'] . '" id="useo-og-url" class="qa-form-tall-text" type="text" value="' . @$this->social_metas['og-url'] . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Thumbnail Image
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . @$this->metas['og-image']['content'] . '" id="useo-og-image" class="qa-form-tall-text" type="text" value="' . @$this->social_metas['og-image'] . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>
			</table>
			<h3>Twitter Cards</h3>
			<table class="qa-form-tall-table">
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Page Title
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . @$this->metas['tc-title']['content'] . '" id="useo-tc-title" class="qa-form-tall-text" type="text" value="' . @$this->social_metas['tc-title'] . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Description
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<textarea placeholder="' . @$this->metas['tc-description']['content'] . '" id="useo-tc-description" class="qa-form-tall-text" cols="40" rows="3" name="useo-meta-editor-description">' . @$this->social_metas['tc-description'] . '</textarea>
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Thumbnail Image
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . @$this->metas['tc-image']['content'] . '" id="useo-tc-image" class="qa-form-tall-text" type="text" value="' . @$this->social_metas['tc-image'] . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Twitter Handler
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . @$this->metas['tc-handler']['content'] . '" id="useo-tc-handler" class="qa-form-tall-text" type="text" value="' . @$this->social_metas['tc-handler'] . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>
			</table>
			<h3>Google+ Schemas</h3>
			<table class="qa-form-tall-table">
				<tbody>
					<tr>
						<td class="qa-form-tall-label">
							Thumbnail Image
						</td>
					</tr>
					<tr>
						<td class="qa-form-tall-data">
							<input placeholder="' . @$this->metas['gp-image']['content'] . '" id="useo-gp-image" class="qa-form-tall-text" type="text" value="' . @$this->social_metas['gp-image'] . '" name="useo-meta-editor-title">
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr>
						<td  id="useo_buttons_container_social" class="qa-form-tall-buttons" colspan="1">
							<input id="useo_save_social" class="qa-form-tall-button qa-form-tall-button-save" type="submit" title="" value="Save Options">
						</td>
					</tr>
				</tbody>

			</table>
			');
            $this->output('</form>');
            $this->output('<hr /></div>');
        }
    }
Example #27
0
function qa_navigation_add_page(&$navigation, $page)
{
    if (!qa_permit_value_error($page['permit'], qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags()) || !isset($page['permit'])) {
        $url = qa_custom_page_url($page);
        $navigation[$page['flags'] & QA_PAGE_FLAGS_EXTERNAL ? 'custom-' . $page['pageid'] : $page['tags'] . '$'] = array('url' => qa_html($url), 'label' => qa_html($page['title']), 'opposite' => $page['nav'] == 'O', 'target' => $page['flags'] & QA_PAGE_FLAGS_NEW_WINDOW ? '_blank' : null, 'selected' => $page['flags'] & QA_PAGE_FLAGS_EXTERNAL && ($url == qa_path(qa_request()) || $url == qa_self_html()));
    }
}
Example #28
0
function qa_admin_single_click($entityid, $action)
{
    $userid = qa_get_logged_in_userid();
    if (!QA_FINAL_EXTERNAL_USERS && ($action == 'userapprove' || $action == 'userblock')) {
        // approve/block moderated users
        require_once QA_INCLUDE_DIR . 'db/selects.php';
        $useraccount = qa_db_select_with_pending(qa_db_user_account_selectspec($entityid, true));
        if (isset($useraccount) && qa_get_logged_in_level() >= QA_USER_LEVEL_MODERATOR) {
            switch ($action) {
                case 'userapprove':
                    if ($useraccount['level'] <= QA_USER_LEVEL_APPROVED) {
                        // don't demote higher level users
                        require_once QA_INCLUDE_DIR . 'app/users-edit.php';
                        qa_set_user_level($useraccount['userid'], $useraccount['handle'], QA_USER_LEVEL_APPROVED, $useraccount['level']);
                        return true;
                    }
                    break;
                case 'userblock':
                    require_once QA_INCLUDE_DIR . 'app/users-edit.php';
                    qa_set_user_blocked($useraccount['userid'], $useraccount['handle'], true);
                    return true;
                    break;
            }
        }
    } else {
        // something to do with a post
        require_once QA_INCLUDE_DIR . 'app/posts.php';
        $post = qa_post_get_full($entityid);
        if (isset($post)) {
            $queued = substr($post['type'], 1) == '_QUEUED';
            switch ($action) {
                case 'approve':
                    if ($queued && !qa_user_post_permit_error('permit_moderate', $post)) {
                        qa_post_set_hidden($entityid, false, $userid);
                        return true;
                    }
                    break;
                case 'reject':
                    if ($queued && !qa_user_post_permit_error('permit_moderate', $post)) {
                        qa_post_set_hidden($entityid, true, $userid);
                        return true;
                    }
                    break;
                case 'hide':
                    if (!$queued && !qa_user_post_permit_error('permit_hide_show', $post)) {
                        qa_post_set_hidden($entityid, true, $userid);
                        return true;
                    }
                    break;
                case 'reshow':
                    if ($post['hidden'] && !qa_user_post_permit_error('permit_hide_show', $post)) {
                        qa_post_set_hidden($entityid, false, $userid);
                        return true;
                    }
                    break;
                case 'delete':
                    if ($post['hidden'] && !qa_user_post_permit_error('permit_delete_hidden', $post)) {
                        qa_post_delete($entityid);
                        return true;
                    }
                    break;
                case 'clearflags':
                    require_once QA_INCLUDE_DIR . 'app/votes.php';
                    if (!qa_user_post_permit_error('permit_hide_show', $post)) {
                        qa_flags_clear_all($post, $userid, qa_get_logged_in_handle(), null);
                        return true;
                    }
                    break;
            }
        }
    }
    return false;
}
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
//	Check we're not using single-sign on integration
if (QA_FINAL_EXTERNAL_USERS) {
    qa_fatal_error('User accounts are handled by external code');
}
//	Get list of special users
$users = qa_db_select_with_pending(qa_db_users_from_level_selectspec(QA_USER_LEVEL_EXPERT));
//	Check we have permission to view this page (moderator or above)
if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) {
    $qa_content = qa_content_prepare();
    $qa_content['error'] = qa_lang_html('users/no_permission');
    return $qa_content;
}
//	Get userids and handles of retrieved users
$usershtml = qa_userids_handles_html($users);
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('users/special_users');
$qa_content['ranking'] = array('items' => array(), 'rows' => ceil(qa_opt('page_size_users') / qa_opt('columns_users')), 'type' => 'users');
foreach ($users as $user) {
    $qa_content['ranking']['items'][] = array('label' => $usershtml[$user['userid']], 'score' => qa_html(qa_user_level_string($user['level'])));
}
$qa_content['navigation']['sub'] = qa_users_sub_navigation();
return $qa_content;
Example #30
0
function ra_is_admin()
{
    if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
        return true;
    }
    return false;
}