function qa_question_validate($title, $content, $format, $text, $tagstring, $notify, $email)
{
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    $options = qa_get_options(array('min_len_q_title', 'max_len_q_title', 'min_len_q_content', 'min_num_q_tags', 'max_num_q_tags'));
    $errors = array();
    $maxtitlelength = max($options['min_len_q_title'], min($options['max_len_q_title'], QA_DB_MAX_TITLE_LENGTH));
    qa_length_validate($errors, 'title', $title, $options['min_len_q_title'], $maxtitlelength);
    qa_length_validate($errors, 'content', $content, 0, QA_DB_MAX_CONTENT_LENGTH);
    // for storage
    qa_length_validate($errors, 'content', $text, $options['min_len_q_content'], null);
    // for display
    if (isset($tagstring)) {
        $counttags = count(qa_tagstring_to_tags($tagstring));
        $mintags = min($options['min_num_q_tags'], $options['max_num_q_tags']);
        // to deal with silly settings
        if ($counttags < $mintags) {
            $errors['tags'] = qa_lang_sub('question/min_tags_x', $mintags);
        } elseif ($counttags > $options['max_num_q_tags']) {
            $errors['tags'] = qa_lang_sub('question/max_tags_x', $options['max_num_q_tags']);
        } else {
            qa_length_validate($errors, 'tags', $tagstring, 0, QA_DB_MAX_TAGS_LENGTH);
        }
    }
    qa_notify_validate($errors, $notify, $email);
    return $errors;
}
Example #2
0
function qa_db_points_calculations()
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    require_once QA_INCLUDE_DIR . 'app/options.php';
    $options = qa_get_options(qa_db_points_option_names());
    return array('qposts' => array('multiple' => $options['points_multiple'] * $options['points_post_q'], 'formula' => "COUNT(*) AS qposts FROM ^posts AS userid_src WHERE userid~ AND type='Q'"), 'aposts' => array('multiple' => $options['points_multiple'] * $options['points_post_a'], 'formula' => "COUNT(*) AS aposts FROM ^posts AS userid_src WHERE userid~ AND type='A'"), 'cposts' => array('multiple' => 0, 'formula' => "COUNT(*) AS cposts FROM ^posts AS userid_src WHERE userid~ AND type='C'"), 'aselects' => array('multiple' => $options['points_multiple'] * $options['points_select_a'], 'formula' => "COUNT(*) AS aselects FROM ^posts AS userid_src WHERE userid~ AND type='Q' AND selchildid IS NOT NULL"), 'aselecteds' => array('multiple' => $options['points_multiple'] * $options['points_a_selected'], 'formula' => "COUNT(*) AS aselecteds FROM ^posts AS userid_src JOIN ^posts AS questions ON questions.selchildid=userid_src.postid WHERE userid_src.userid~ AND userid_src.type='A' AND NOT (questions.userid<=>userid_src.userid)"), 'qupvotes' => array('multiple' => $options['points_multiple'] * $options['points_vote_up_q'], 'formula' => "COUNT(*) AS qupvotes FROM ^uservotes AS userid_src JOIN ^posts ON userid_src.postid=^posts.postid WHERE userid_src.userid~ AND LEFT(^posts.type, 1)='Q' AND userid_src.vote>0"), 'qdownvotes' => array('multiple' => $options['points_multiple'] * $options['points_vote_down_q'], 'formula' => "COUNT(*) AS qdownvotes FROM ^uservotes AS userid_src JOIN ^posts ON userid_src.postid=^posts.postid WHERE userid_src.userid~ AND LEFT(^posts.type, 1)='Q' AND userid_src.vote<0"), 'aupvotes' => array('multiple' => $options['points_multiple'] * $options['points_vote_up_a'], 'formula' => "COUNT(*) AS aupvotes FROM ^uservotes AS userid_src JOIN ^posts ON userid_src.postid=^posts.postid WHERE userid_src.userid~ AND LEFT(^posts.type, 1)='A' AND userid_src.vote>0"), 'adownvotes' => array('multiple' => $options['points_multiple'] * $options['points_vote_down_a'], 'formula' => "COUNT(*) AS adownvotes FROM ^uservotes AS userid_src JOIN ^posts ON userid_src.postid=^posts.postid WHERE userid_src.userid~ AND LEFT(^posts.type, 1)='A' AND userid_src.vote<0"), 'qvoteds' => array('multiple' => $options['points_multiple'], 'formula' => "COALESCE(SUM(" . "LEAST(" . (int) $options['points_per_q_voted_up'] . "*upvotes," . (int) $options['points_q_voted_max_gain'] . ")" . "-" . "LEAST(" . (int) $options['points_per_q_voted_down'] . "*downvotes," . (int) $options['points_q_voted_max_loss'] . ")" . "), 0) AS qvoteds FROM ^posts AS userid_src WHERE LEFT(type, 1)='Q' AND userid~"), 'avoteds' => array('multiple' => $options['points_multiple'], 'formula' => "COALESCE(SUM(" . "LEAST(" . (int) $options['points_per_a_voted_up'] . "*upvotes," . (int) $options['points_a_voted_max_gain'] . ")" . "-" . "LEAST(" . (int) $options['points_per_a_voted_down'] . "*downvotes," . (int) $options['points_a_voted_max_loss'] . ")" . "), 0) AS avoteds FROM ^posts AS userid_src WHERE LEFT(type, 1)='A' AND userid~"), 'upvoteds' => array('multiple' => 0, 'formula' => "COALESCE(SUM(upvotes), 0) AS upvoteds FROM ^posts AS userid_src WHERE userid~"), 'downvoteds' => array('multiple' => 0, 'formula' => "COALESCE(SUM(downvotes), 0) AS downvoteds FROM ^posts AS userid_src WHERE userid~"));
}
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     $widget_opt = qa_get_options(array(q2a_breadcrumbs_admin::SHOW_HOME, q2a_breadcrumbs_admin::TRUNCATE_LENGTH));
     // breadcrumb start
     $themeobject->output('<ul class="breadcrumb clearfix">');
     if ($widget_opt[q2a_breadcrumbs_admin::SHOW_HOME]) {
         $themeobject->output($this->breadcrumb_part(array('type' => 'home')));
     }
     $themeobject->output($this->create_breadcrumbs($this->navigation(), $qa_content, $widget_opt, $template));
     $themeobject->output('</ul>');
 }
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     require_once AMI_FB_LIKE_BOX_DIR . '/qa-facebook-like-box-admin.php';
     $has_error = false;
     $error_message = "";
     $widget_opt = qa_get_options(array('facebook_app_id', qa_facebook_like_box_admin::SHOW_FB_LIKE_BOX, qa_facebook_like_box_admin::SHOW_FB_LIKE_MODAL, qa_facebook_like_box_admin::FACEBOOK_PAGE_URL, qa_facebook_like_box_admin::LIKE_BOX_COLOR_SCHEME, qa_facebook_like_box_admin::LIKE_BOX_SHOW_HEADER, qa_facebook_like_box_admin::LIKE_BOX_SHOW_BORDER, qa_facebook_like_box_admin::LIKE_BOX_SHOW_FACES, qa_facebook_like_box_admin::LIKE_BOX_SHOW_DATA_STREAM, qa_facebook_like_box_admin::LIKE_BOX_HEIGHT, qa_facebook_like_box_admin::LIKE_BOX_WIDTH, qa_facebook_like_box_admin::MODAL_USE_CSS_FROM_THEME, qa_facebook_like_box_admin::MODAL_COLOR_SCHEME, qa_facebook_like_box_admin::MODAL_SHOW_HEADER, qa_facebook_like_box_admin::MODAL_SHOW_BORDER, qa_facebook_like_box_admin::MODAL_SHOW_FACES, qa_facebook_like_box_admin::MODAL_SHOW_DATA_STREAM, qa_facebook_like_box_admin::MODAL_HEIGHT, qa_facebook_like_box_admin::MODAL_WIDTH, qa_facebook_like_box_admin::MODAL_COOKIE_EXPIRE, qa_facebook_like_box_admin::MODAL_HEADER_MAIN_TEXT, qa_facebook_like_box_admin::MODAL_DISPLAY_EVERY_TIME, qa_facebook_like_box_admin::MODAL_FOOTER_TEXT, qa_facebook_like_box_admin::MODAL_COSTUM_CSS));
     $fb_page_url = $this->get_fb_settings($widget_opt, 'url');
     $show_fb_like_box = $this->get_fb_settings($widget_opt, 'show_fb_like_box');
     $show_fb_like_box_modal = $this->get_fb_settings($widget_opt, 'show_fb_like_modal');
     if (empty($fb_page_url)) {
         $has_error = true;
         $error_message = qa_lang('flb_like_box/plz_provide_fb_url');
     }
     if (!$has_error) {
         if ($show_fb_like_box) {
             $themeobject->output($this->get_facebook_like_box($widget_opt));
         }
         if ($show_fb_like_box_modal) {
             $themeobject->output($this->get_facebook_like_modal($widget_opt));
         }
     } else {
         $themeobject->output('<div class="qa-sidebar error" style="color:red;">' . $error_message . '</div>');
     }
 }
    header('Content-Type: image/jpeg');
    echo $content;
} else {
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    require_once QA_INCLUDE_DIR . 'qa-app-blobs.php';
    require_once QA_INCLUDE_DIR . 'qa-util-image.php';
    //	Otherwise retrieve the raw image and scale as appropriate
    $blob = qa_read_blob($blobid);
    if (isset($blob)) {
        if ($size > 0) {
            $content = qa_image_constrain_data($blob['content'], $width, $height, $size);
        } else {
            $content = $blob['content'];
        }
        if (isset($content)) {
            header('Content-Type: image/jpeg');
            echo $content;
            if (strlen($content) && $size > 0) {
                $cachesizes = qa_get_options(array('avatar_profile_size', 'avatar_users_size', 'avatar_q_page_q_size', 'avatar_q_page_a_size', 'avatar_q_page_c_size', 'avatar_q_list_size'));
                // to prevent cache being filled with inappropriate sizes
                if (array_search($size, $cachesizes)) {
                    qa_db_cache_set($cachetype, $blobid, $content);
                }
            }
        }
    }
}
qa_db_disconnect();
/*
	Omit PHP closing tag to help avoid accidental output
*/
Example #6
0
function qa_opt($name, $value = null)
{
    global $qa_options_cache;
    if (!isset($value) && isset($qa_options_cache[$name])) {
        return $qa_options_cache[$name];
    }
    // quick shortcut to reduce calls to qa_get_options()
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    return $options[$name];
}
            }
            if (qa_clicked('domailingcancel')) {
                qa_mailing_stop();
            }
        }
    }
    $mailingprogress = qa_mailing_progress_message();
    if (isset($mailingprogress)) {
        $formokhtml = qa_html($mailingprogress);
        $checkboxtodisplay = array('mailing_enabled' => '0');
    } else {
        $checkboxtodisplay = array('mailing_from_name' => 'option_mailing_enabled', 'mailing_from_email' => 'option_mailing_enabled', 'mailing_subject' => 'option_mailing_enabled', 'mailing_body' => 'option_mailing_enabled', 'mailing_per_minute' => 'option_mailing_enabled', 'domailingtest' => 'option_mailing_enabled', 'domailingstart' => 'option_mailing_enabled');
    }
}
//	Get the actual options
$options = qa_get_options($getoptions);
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html($subtitle);
$qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['form'] = array('ok' => $formokhtml, 'tags' => 'method="post" action="' . qa_self_html() . '" name="admin_form" onsubmit="document.forms.admin_form.has_js.value=1; return true;"', 'style' => $formstyle, 'fields' => array(), 'buttons' => array('save' => array('tags' => 'id="dosaveoptions"', 'label' => qa_lang_html('admin/save_options_button')), 'reset' => array('tags' => 'name="doresetoptions"', 'label' => qa_lang_html('admin/reset_options_button'))), 'hidden' => array('dosaveoptions' => '1', 'has_js' => '0', 'code' => qa_get_form_security_code('admin/' . $adminsection)));
if ($recalchotness) {
    $qa_content['form']['ok'] = '<span id="recalc_ok"></span>';
    $qa_content['form']['hidden']['code_recalc'] = qa_get_form_security_code('admin/recalc');
    $qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
    $qa_content['script_onloads'][] = array("qa_recalc_click('dorecountposts', document.getElementById('dosaveoptions'), null, 'recalc_ok');");
} elseif ($startmailing) {
    if (qa_post_text('has_js')) {
        $qa_content['form']['ok'] = '<span id="mailing_ok">' . qa_html($mailingprogress) . '</span>';
        $qa_content['script_onloads'][] = array("qa_mailing_start('mailing_ok', 'domailingpause');");
    function filter_subs($text)
    {
        // text subs
        $subs = array('site_title' => qa_opt('site_title'), 'site_url' => qa_opt('site_url'));
        foreach ($subs as $i => $v) {
            $text = str_replace('^' . $i, $v, $text);
        }
        // function subs
        preg_match_all('/\\^qa_path\\(([^)]+)\\)/', $text, $qa_path, PREG_SET_ORDER);
        foreach ($qa_path as $match) {
            $text = str_replace($match[0], qa_path($match[1]), $text);
        }
        preg_match_all('/\\^qa_opt\\(([^)]+)\\)/', $text, $qa_opt, PREG_SET_ORDER);
        foreach ($qa_opt as $match) {
            // backwards compat
            if (in_array($match[1], array('points_per_q_voted_up', 'points_per_q_voted_down')) && !qa_opt('points_per_q_voted_up')) {
                $match[1] = 'points_per_q_voted';
            } else {
                if (in_array($match[1], array('points_per_a_voted_up', 'points_per_a_voted_down')) && !qa_opt('points_per_a_voted_up')) {
                    $match[1] = 'points_per_a_voted';
                }
            }
            $text = str_replace($match[0], qa_opt($match[1]), $text);
        }
        // if subs
        if (qa_get_logged_in_userid()) {
            $text = preg_replace('/\\^if_logged_in=`([^`]+)`/', '$1', $text);
            $text = preg_replace('/\\^if_not_logged_in=`[^`]+`/', '', $text);
            $handle = qa_get_logged_in_handle();
            $subs = array('profile_url' => qa_path('user/' . $handle), 'handle' => $handle);
            foreach ($subs as $i => $v) {
                $text = str_replace('^' . $i, $v, $text);
            }
        } else {
            global $qa_root_url_relative;
            $userlinks = qa_get_login_links($qa_root_url_relative, null);
            $subs = array('login' => $userlinks['login'], 'register' => $userlinks['register']);
            foreach ($subs as $i => $v) {
                $text = str_replace('^' . $i, $v, $text);
            }
            $text = preg_replace('/\\^if_not_logged_in=`([^`]+)`/', '$1', $text);
            $text = preg_replace('/\\^if_logged_in=`[^`]+`/', '', $text);
        }
        // table subs
        if (strpos($text, '^pointstable') !== false) {
            require_once QA_INCLUDE_DIR . 'qa-db-points.php';
            $optionnames = qa_db_points_option_names();
            $options = qa_get_options($optionnames);
            $table = '
<table class="qa-form-wide-table">
	<tbody>';
            $multi = (int) $options['points_multiple'];
            foreach ($optionnames as $optionname) {
                switch ($optionname) {
                    case 'points_multiple':
                        continue 2;
                    case 'points_per_q_voted_up':
                    case 'points_per_a_voted_up':
                        $prefix = '+';
                        break;
                    case 'points_per_q_voted_down':
                    case 'points_per_a_voted_down':
                        $prefix = '-';
                        break;
                    case 'points_per_q_voted':
                    case 'points_per_a_voted':
                        $prefix = '&#177;';
                        break;
                    case 'points_q_voted_max_gain':
                    case 'points_a_voted_max_gain':
                        $prefix = '+';
                        break;
                    case 'points_q_voted_max_loss':
                    case 'points_a_voted_max_loss':
                        $prefix = '&ndash;';
                        break;
                    case 'points_base':
                        $prefix = '+';
                        break;
                    default:
                        $prefix = '<SPAN STYLE="visibility:hidden;">+</SPAN>';
                        // for even alignment
                        break;
                }
                $points = $optionname != 'points_base' ? (int) $options[$optionname] * $multi : (int) $options[$optionname];
                if ($points != 0 && $points != -10000 && $points != 10000 && strpos($optionname, 'max') === false) {
                    $table .= '
		<tr>
			<td class="qa-form-wide-label">
				' . qa_lang_html('options/' . $optionname) . '
			</td>
			<td class="qa-form-wide-data" style="text-align:right">
				<span class="qa-form-wide-prefix"><span style="width: 1em; display: -moz-inline-stack;">' . $prefix . '</span></span>
				' . qa_html($points) . ($optionname == 'points_multiple' ? '' : '
				<span class="qa-form-wide-note">' . qa_lang_html('admin/points') . '</span>') . '
			</td>
		</tr>';
                }
            }
            $table .= '
	</tbody>
</table>';
            $text = str_replace('^pointstable', $table, $text);
        }
        if (strpos($text, '^privilegestable') !== false) {
            $options = qa_get_permit_options();
            foreach ($options as $option) {
                if (qa_opt($option) == QA_PERMIT_POINTS) {
                    $popts[$option] = (int) qa_opt($option . '_points');
                }
            }
            if (isset($popts)) {
                asort($popts);
                $table = '
	<table class="qa-form-wide-table">
		<tbody>';
                foreach ($popts as $key => $val) {
                    // fudge
                    if ($key == 'permit_retag_cat') {
                        $name = qa_lang_html(qa_using_categories() ? 'profile/permit_recat' : 'profile/permit_retag');
                    } else {
                        $name = qa_lang('profile/' . $key);
                    }
                    if ($name == '[profile/' . $key . ']') {
                        global $qa_lang_file_pattern;
                        foreach ($qa_lang_file_pattern as $k => $v) {
                            if (qa_lang($k . '/' . $key) != '[' . $k . '/' . $key . ']') {
                                $name = qa_lang($k . '/' . $key);
                                break;
                            }
                        }
                    }
                    $table .= '
			<tr>
				<td class="qa-form-wide-label">
					' . $name . '
				</td>
				<td class="qa-form-wide-data" style="text-align:right">
					' . qa_html($val) . '
					<span class="qa-form-wide-note">' . qa_lang_html('admin/points') . '</span>' . '
				</td>
			</tr>';
                }
                $table .= '
		</tbody>
	</table>';
                $text = str_replace('^privilegestable', $table, $text);
            } else {
                $text = str_replace('^privilegestable', '', $text);
            }
        }
        return $text;
    }
Example #9
0
function ra_opt($name, $value = null)
{
    /*
    	Shortcut to get or set an option value without specifying database
    */
    global $qa_options_cache;
    if (!isset($value) && isset($qa_options_cache[$name])) {
        if (ra_is_serialized($qa_options_cache[$name])) {
            return unserialize($qa_options_cache[$name]);
        }
        return $qa_options_cache[$name];
        // quick shortcut to reduce calls to qa_get_options()
    }
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        if (is_array($value)) {
            $value = serialize($value);
        }
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    if (ra_is_serialized($options[$name])) {
        return unserialize($options[$name]);
    }
    return $options[$name];
}
    function user_activity_form()
    {
        $handle = $this->_user_handle();
        if (!$handle) {
            return;
        }
        $userid = $this->getuserfromhandle($handle);
        if (!$userid) {
            return;
        }
        // update last visit
        if ($userid == qa_get_logged_in_userid() && qa_opt('user_act_list_new')) {
            qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^usermeta (
				meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
				user_id bigint(20) unsigned NOT NULL,
				meta_key varchar(255) DEFAULT NULL,
				meta_value longtext,
				PRIMARY KEY (meta_id),
				UNIQUE (user_id,meta_key)
				) ENGINE=MyISAM  DEFAULT CHARSET=utf8');
            $last_visit = qa_db_read_one_value(qa_db_query_sub('SELECT UNIX_TIMESTAMP(meta_value) FROM ^usermeta WHERE user_id=# AND meta_key=$', qa_get_logged_in_userid(), 'visited_profile'), true);
            qa_db_query_sub('INSERT INTO ^usermeta (user_id,meta_key,meta_value) VALUES(#,$,NOW()) ON DUPLICATE KEY UPDATE meta_value=NOW()', $userid, 'visited_profile');
        } else {
            $last_visit = time();
        }
        $event_query = qa_db_query_sub("SELECT \n\t\t\t\te.event, \n\t\t\t\tBINARY e.params as params, \n\t\t\t\tUNIX_TIMESTAMP(e.datetime) AS datetime\n\t\t\tFROM \n\t\t\t\t^eventlog AS e\n\t\t\tWHERE\n\t\t\t\te.userid=#\n\t\t\t\tAND\n\t\t\t\tDATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime\n\t\t\tORDER BY datetime DESC" . (qa_opt('user_act_list_max') ? " LIMIT " . (int) qa_opt('user_act_list_max') : ""), $userid, qa_opt('user_act_list_age'));
        // no post
        $nopost = array('u_password', 'u_reset', 'u_save', 'u_confirmed', 'u_edit', 'u_level', 'u_block', 'u_unblock', 'u_register', 'in_u_edit', 'in_u_level', 'in_u_block', 'in_u_unblock', 'feedback', 'search');
        // points
        require_once QA_INCLUDE_DIR . 'qa-db-points.php';
        $optionnames = qa_db_points_option_names();
        $options = qa_get_options($optionnames);
        $multi = (int) $options['points_multiple'];
        // compat fudge
        $upvote = '';
        $downvote = '';
        if (@$options['points_per_q_voted_up']) {
            $upvote = '_up';
            $downvote = '_down';
        }
        $option_events['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi;
        $option_events['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1;
        $option_events['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1;
        $option_events['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi;
        $option_events['in_a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi;
        $option_events['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1;
        $option_events['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1;
        $option_events['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi;
        $option_events['in_a_select'] = (int) $options['points_a_selected'] * $multi;
        $option_events['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1;
        $option_events['q_post'] = (int) $options['points_post_q'] * $multi;
        $option_events['a_post'] = (int) $options['points_post_a'] * $multi;
        $option_events['a_select'] = (int) $options['points_select_a'] * $multi;
        $option_events['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi;
        $option_events['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi;
        $option_events['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi;
        $option_events['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi;
        $fields = array();
        $events = array();
        $postids = array();
        $count = 0;
        while (($event = qa_db_read_one_assoc($event_query, true)) !== null) {
            if (preg_match('/postid=([0-9]+)/', $event['params'], $m) === 1) {
                $event['postid'] = (int) $m[1];
                $postids[] = (int) $m[1];
                $events[$m[1] . '_' . $count++] = $event;
            } else {
                $events['nopost_' . $count++] = $event;
            }
        }
        // get post info, also makes sure post exists
        $posts = null;
        if (!empty($postids)) {
            $post_query = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, type, parentid, BINARY title as title FROM ^posts WHERE postid IN (' . implode(',', $postids) . ')'));
            foreach ($post_query as $post) {
                $posts[(string) $post['postid']] = $post;
            }
        }
        foreach ($events as $postid_string => $event) {
            $type = $event['event'];
            $postid = preg_replace('/_.*/', '', $postid_string);
            $post = null;
            $post = @$posts[$postid];
            // these calls allow you to deal with deleted events;
            // uncomment the first one to skip them
            // uncomment the second one to build your own routine based on whether they are deleted.
            if (!in_array($type, $nopost) && $post == null) {
                continue;
            }
            // $deleted = (!in_array($type, $nopost) && $post == null);
            // hide / show exceptions
            if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
                if ($userid != qa_get_logged_in_userid()) {
                    // show public
                    $types = explode("\n", qa_opt('user_act_list_show'));
                    if (!in_array($type, $types)) {
                        continue;
                    }
                } else {
                    // hide from owner
                    $types = explode("\n", qa_opt('user_act_list_hide'));
                    if (in_array($type, $types)) {
                        continue;
                    }
                }
            }
            if (!qa_opt('user_act_list_' . $type)) {
                continue;
            }
            $params = array();
            $paramsa = explode("\t", $event['params']);
            foreach ($paramsa as $param) {
                $parama = explode('=', $param);
                if (isset($parama[1])) {
                    $params[$parama[0]] = $parama[1];
                } else {
                    $params[$param] = $param;
                }
            }
            $link = '';
            if (in_array($type, $nopost)) {
                if ($type == 'search') {
                    if ((int) $params['start'] != 0) {
                        continue;
                    }
                    $link = '<a href="' . qa_path_html('search', array('q' => $params['query'])) . '">' . qa_html($params['query']) . '</a>';
                } else {
                    if (in_array($type, array('u_edit', 'u_level', 'u_block', 'u_unblock'))) {
                        $ohandle = $this->getHandleFromID($params['userid']);
                        $link = '<a href="' . qa_path_html('user/' . $ohandle, null, qa_opt('site_url')) . '">' . $ohandle . '</a>';
                    } else {
                        $link = '';
                    }
                }
            } else {
                if ($type == 'badge_awarded') {
                    if (!qa_opt('badge_active') || !function_exists('qa_get_badge_type')) {
                        continue;
                    }
                    if ($post != null) {
                        if (strpos($post['type'], 'Q') !== 0) {
                            $anchor = qa_anchor(strpos($post['type'], 'A') === 0 ? 'A' : 'C', $params['postid']);
                            $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT parentid,type,BINARY title as title,postid FROM ^posts WHERE postid=#', $post['parentid']), true);
                            if ($parent['type'] == 'A') {
                                $parent = qa_db_read_one_assoc(qa_db_query_sub('SELECT BINARY title as title,postid FROM ^posts WHERE postid=#', $parent['parentid']), true);
                            }
                            $activity_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
                            $link = '<a href="' . $activity_url . '">' . $parent['title'] . '</a>';
                        } else {
                            $activity_url = qa_path_html(qa_q_request($params['postid'], $post['title']), null, qa_opt('site_url'), null, null);
                            $link = '<a href="' . $activity_url . '">' . $post['title'] . '</a>';
                        }
                    }
                } else {
                    if ($post != null && strpos($event['event'], 'q_') !== 0 && strpos($event['event'], 'in_q_') !== 0) {
                        // comment or answer
                        if (!isset($params['parentid'])) {
                            $params['parentid'] = $post['parentid'];
                        }
                        $parent = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $params['parentid']));
                        if ($parent['type'] == 'A') {
                            $parent = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $parent['parentid']));
                        }
                        $anchor = qa_anchor(strpos($event['event'], 'a_') === 0 || strpos($event['event'], 'in_a_') === 0 ? 'A' : 'C', $params['postid']);
                        $activity_url = qa_path_html(qa_q_request($parent['postid'], $parent['title']), null, qa_opt('site_url'), null, $anchor);
                        $link = '<a href="' . $activity_url . '">' . $parent['title'] . '</a>';
                    } else {
                        if ($post != null) {
                            // question
                            if (!isset($params['title'])) {
                                $params['title'] = $posts[$params['postid']]['title'];
                            }
                            if ($params['title'] !== null) {
                                $activity_url = qa_path_html(qa_q_request($params['postid'], $params['title']), null, qa_opt('site_url'));
                                $link = '<a href="' . $activity_url . '">' . $params['title'] . '</a>';
                            }
                        }
                    }
                }
            }
            $time = $event['datetime'];
            if (qa_opt('user_act_list_shading')) {
                $days = (qa_opt('db_time') - $time) / 60 / 60 / 24;
                $col = round($days / qa_opt('user_act_list_age') * 255 / 2);
                $bkg = 255 - round($days / qa_opt('user_act_list_age') * 255 / 8);
                $bkg = dechex($bkg);
                $col = dechex($col);
                if (strlen($col) == 1) {
                    $col = '0' . $col;
                }
                if (strlen($bkg) == 1) {
                    $bkg = '0' . $bkg;
                }
                $col = '#' . $col . $col . $col;
                $bkg = '#' . $bkg . $bkg . $bkg;
            }
            $whenhtml = qa_html(qa_time_to_string(qa_opt('db_time') - $time));
            $when = qa_lang_html_sub('main/x_ago', $whenhtml);
            $when = str_replace(' ', '<br/>', $when);
            $when = preg_replace('/([0-9]+)/', '<span class="qa-history-item-date-no">$1</span>', $when);
            if (strpos($type, '_vote_nil') == 4) {
                if ($params['oldvote'] == '1') {
                    // unvoting an upvote
                    $points = @$option_events[str_replace('_vote_nil', '_unvote_up', $type)];
                } else {
                    // unvoting a downvote
                    $points = @$option_events[str_replace('_vote_nil', '_unvote_down', $type)];
                }
            } else {
                $points = @$option_events[$type];
            }
            $string = qa_opt('user_act_list_' . $type);
            if ($type == 'badge_awarded') {
                $slug = $params['badge_slug'];
                $typea = qa_get_badge_type_by_slug($slug);
                if (!$typea) {
                    continue;
                }
                $types = $typea['slug'];
                $typed = $typea['name'];
                $badge_name = qa_badge_name($slug);
                if (!qa_opt('badge_' . $slug . '_name')) {
                    qa_opt('badge_' . $slug . '_name', $badge_name);
                }
                $var = qa_opt('badge_' . $slug . '_var');
                $name = qa_opt('badge_' . $slug . '_name');
                $desc = qa_badge_desc_replace($slug, $var, false);
                $string = str_replace('^badge', '<span class="badge-' . $types . '" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '</span>', $string);
            }
            $fields[] = array('type' => 'static', 'label' => '<div class="qa-history-item-date' . ($time >= $last_visit && strpos($type, 'in_') === 0 ? ' qa-history-item-date-new' : '') . '"' . (qa_opt('user_act_list_shading') ? ' style="color:' . $col . ';background-color:' . $bkg . '"' : '') . '>' . $when . '</div>', 'value' => '<table class="qa-history-item-table"><tr><td class="qa-history-item-type-cell"><div class="qa-history-item-type qa-history-item-' . $type . '">' . $string . '</div></td><td class="qa-history-item-title-cell"><div class="qa-history-item-title">' . $link . '</div></td class="qa-history-item-points-cell"><td align="right">' . ($points ? '<div class="qa-history-item-points qa-history-item-points-' . ($points < 0 ? 'neg">' : 'pos">+') . $points . '</div>' : '&nbsp') . '</td></tr></table>');
        }
        if (empty($fields)) {
            return;
        }
        return array('style' => 'wide', 'title' => qa_opt('user_act_list_title'), 'fields' => $fields);
    }
 function privilege_check($event, $userid, $params)
 {
     // points
     require_once QA_INCLUDE_DIR . 'qa-db-points.php';
     $optionnames = qa_db_points_option_names();
     $options = qa_get_options($optionnames);
     $multi = (int) $options['points_multiple'];
     switch ($event) {
         case 'q_post':
             $event_points = (int) $options['points_post_q'] * $multi;
             break;
         case 'a_post':
             $event_points = (int) $options['points_post_a'] * $multi;
             break;
         case 'a_select':
             $event_points = (int) $options['points_select_a'] * $multi;
             break;
         case 'q_vote_up':
             $event_points = (int) $options['points_vote_up_q'] * $multi;
             break;
         case 'a_vote_up':
             $event_points = (int) $options['points_vote_up_a'] * $multi;
             break;
         default:
             return;
     }
     $this->check_privileges($userid, $event_points);
     // other user
     if (in_array($event, array('a_select', 'q_vote_up', 'a_vote_up'))) {
         $uid2 = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^posts WHERE postid=#', $params['postid']), true);
         if ($uid2 && $uid2 != $userid) {
             if (isset($options['points_per_q_voted'])) {
                 // 1.4
                 switch ($event) {
                     case 'a_select':
                         $event_points = (int) $options['points_a_selected'] * $multi;
                         break;
                     case 'q_vote_up':
                         $event_points = (int) $params['vote'] <= (int) $options['points_q_voted_max_gain'] / (int) $options['points_per_q_voted'] ? (int) $options['points_per_q_voted'] * $multi : (int) $options['points_q_voted_max_gain'];
                         break;
                     case 'a_vote_up':
                         $event_points = (int) $params['vote'] <= (int) $options['points_a_voted_max_gain'] / (int) $options['points_per_a_voted'] ? (int) $options['points_per_a_voted'] * $multi : (int) $options['points_a_voted_max_gain'];
                         break;
                     default:
                         return;
                 }
             } else {
                 // 1.5
                 switch ($event) {
                     case 'a_select':
                         $event_points = (int) $options['points_a_selected'] * $multi;
                         break;
                     case 'q_vote_up':
                         $event_points = (int) $params['vote'] <= (int) $options['points_q_voted_max_gain'] / (int) $options['points_per_q_voted_up'] ? (int) $options['points_per_q_voted'] * $multi : (int) $options['points_q_voted_max_gain'];
                         break;
                     case 'a_vote_up':
                         $event_points = (int) $params['vote'] <= (int) $options['points_a_voted_max_gain'] / (int) $options['points_per_a_voted_up'] ? (int) $options['points_per_a_voted'] * $multi : (int) $options['points_a_voted_max_gain'];
                         break;
                     default:
                         return;
                 }
             }
             $this->check_privileges($uid2, $event_points);
         }
     }
 }
Example #12
0
function qa_opt($name, $value = null)
{
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    return $options[$name];
}
Example #13
0
    function activitylist()
    {
        // get points for each activity
        require_once QA_INCLUDE_DIR . 'qa-db-points.php';
        require_once QA_INCLUDE_DIR . 'qa-db-users.php';
        $optionnames = qa_db_points_option_names();
        $options = qa_get_options($optionnames);
        $multi = (int) $options['points_multiple'];
        $upvote = '';
        $downvote = '';
        if (@$options['points_per_q_voted_up']) {
            $upvote = '_up';
            $downvote = '_down';
        }
        $event_point['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi;
        $event_point['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1;
        $event_point['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1;
        $event_point['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi;
        $event_point['in_a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi;
        $event_point['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1;
        $event_point['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1;
        $event_point['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi;
        $event_point['in_a_select'] = (int) $options['points_a_selected'] * $multi;
        $event_point['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1;
        $event_point['q_post'] = (int) $options['points_post_q'] * $multi;
        $event_point['a_post'] = (int) $options['points_post_a'] * $multi;
        $event_point['a_select'] = (int) $options['points_select_a'] * $multi;
        $event_point['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi;
        $event_point['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi;
        $event_point['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi;
        $event_point['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi;
        /*
        // Exclude Activities
        $exclude = array(
        	'u_login',
        	'u_logout',
        	'u_password',
        	'u_reset',
        	'u_save',
        	'u_edit',
        	'u_block',
        	'u_unblock',
        	'feedback',
        	'search',
        	'badge_awarded',
        );
        $excludes = "'".implode("','",$exclude)."'";
        $eventslist = qa_db_read_all_assoc(
        	qa_db_query_sub( 
        		'SELECT UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params FROM ^userlog WHERE userid=# AND 
        		DATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime
        		AND event NOT IN (' . $excludes .') ORDER BY datetime DESC'.(qa_opt('qat_activity_number')?' LIMIT '.(int)qa_opt('qat_activity_number'):''),
        		$userid, qa_opt('qat_activity_age')
        	)
        );
        */
        // Get Events
        $userid = qa_get_logged_in_userid();
        $eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params FROM ^userlog WHERE effecteduserid=# AND 
				DATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime
				ORDER BY datetime DESC' . (qa_opt('qat_activity_number') ? ' LIMIT ' . (int) qa_opt('qat_activity_number') : ''), $userid, qa_opt('qat_activity_age')));
        $event = array();
        $output = '';
        $i = 0;
        //
        $userids = array();
        foreach ($eventslist as $event) {
            $userids[$event['userid']] = $event['userid'];
            $userids[$event['effecteduserid']] = $event['effecteduserid'];
        }
        $handles = qa_db_user_get_userid_handles($userids);
        // get event's: time, type, parameters
        // get post id of questions
        foreach ($eventslist as $event) {
            $title = '';
            $link = '';
            $vote_status = '';
            $handle = $handles[$event['userid']];
            $user_link = qa_path('user/' . $handle);
            $datetime = $event['datetime'];
            $event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
            $event['params'] = json_decode($event['params'], true);
            $output .= '<li>';
            switch ($event['event']) {
                case 'related':
                    // related question to an answer
                    $url = qa_path_html(qa_q_request($event['postid'], $event['params']['title']), null, qa_opt('site_url'), null, null);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
									<span class="what">Asked a question related to your answer</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['title'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'a_post':
                    // user's question had been answered
                    $anchor = qa_anchor('A', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
									<span class="what">Answered</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'c_post':
                    // user's question had been commented
                    $anchor = qa_anchor('C', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
									<span class="what">Commented</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'q_reshow':
                    // user's question had been answered
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, null);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
										<span class="what">your question had been accepted</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'a_reshow':
                    // user's question had been answered
                    $anchor = qa_anchor('A', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
										<span class="what">your answer had been made visible</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'c_reshow':
                    // user's question had been answered
                    $anchor = qa_anchor('C', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
										<span class="what">your comment had been accepted</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'a_select':
                    // user's question had been answered
                    $anchor = qa_anchor('A', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
										<span class="what">selected your answer</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'in_q_vote':
                    // user's question had been answered
                    $anchor = qa_anchor('Q', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    if ($event['params']['q_vote_up']) {
                        $vote_status .= '<span>' . $event['params']['q_vote_up'] . ' upvotes</span>';
                    }
                    if ($event['params']['q_vote_down']) {
                        if (isset($vote_status)) {
                            $vote_status .= ' - ';
                        }
                        $vote_status .= '<span>' . $event['params']['q_vote_down'] . ' downvotes</span>';
                    }
                    if ($event['params']['favorite'] && $event['params']['favorite'] >= 1) {
                        if (isset($vote_status)) {
                            $vote_status .= ' - ';
                        }
                        $vote_status .= '<span>' . $event['params']['favorite'] . ' favourites</span>';
                    }
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
										<span class="what">your question received new votes: ' . $vote_status . '</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'in_a_vote':
                    // user's question had been answered
                    $anchor = qa_anchor('A', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    if ($event['params']['a_vote_up']) {
                        $vote_status = '<span>' . $event['params']['a_vote_up'] . ' upvotes</span>';
                    }
                    if ($event['params']['a_vote_down']) {
                        if (isset($vote_status)) {
                            $vote_status .= ' - ';
                        }
                        $vote_status .= '<span>' . $event['params']['a_vote_down'] . ' downvotes</span>';
                    }
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
										<span class="what">your answer received new votes: ' . $vote_status . '</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'q_approve':
                    $anchor = qa_anchor('Q', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
									<span class="what">your question was approved</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'a_approve':
                    $anchor = qa_anchor('A', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
									<span class="what">your answer was approved</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'c_approve':
                    $anchor = qa_anchor('C', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
									<span class="what">your comment was approved</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['qtitle'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'q_reject':
                    $anchor = qa_anchor('C', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
									<span class="what">your question was rejected</span>
									</p>
									<span class="title">' . $event['params']['qtitle'] . '</span>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'a_reject':
                case 'c_reject':
                    break;
                case 'u_level':
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title">
										<span class="what">You level had been changed from' . qa_html(qa_user_level_string($event['params']['oldlevel'])) . ' to ' . qa_html(qa_user_level_string($event['params']['level'])) . '</span>
									</p>
								</div>';
                    break;
                case 'a_post':
                    break;
            }
        }
        $output .= '</li>';
        return $output;
    }
function qa_create_new_user($email, $password, $handle, $level = QA_USER_LEVEL_BASIC, $confirmed = false)
{
    require_once QA_INCLUDE_DIR . 'qa-db-users.php';
    require_once QA_INCLUDE_DIR . 'qa-db-points.php';
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
    $userid = qa_db_user_create($email, $password, $handle, $level, qa_remote_ip_address());
    qa_db_points_update_ifuser($userid, null);
    if ($confirmed) {
        qa_db_user_set_flag($userid, QA_USER_FLAGS_EMAIL_CONFIRMED, true);
    }
    $options = qa_get_options(array('custom_welcome', 'site_url', 'confirm_user_emails'));
    $custom = trim($options['custom_welcome']);
    if ($options['confirm_user_emails'] && $level < QA_USER_LEVEL_EXPERT && !$confirmed) {
        $confirm = strtr(qa_lang('emails/welcome_confirm'), array('^url' => qa_get_new_confirm_url($userid, $handle)));
    } else {
        $confirm = '';
    }
    qa_send_notification($userid, $email, $handle, qa_lang('emails/welcome_subject'), qa_lang('emails/welcome_body'), array('^password' => isset($password) ? $password : qa_lang('users/password_to_set'), '^url' => $options['site_url'], '^custom' => empty($custom) ? '' : $custom . "\n\n", '^confirm' => $confirm));
    qa_report_event('u_register', $userid, $handle, qa_cookie_get(), array('email' => $email, 'level' => $level));
    return $userid;
}
Example #15
0
    public function activitylist()
    {
        $offset = (int) qa_get('offset');
        $offset = isset($offset) ? $offset * 15 : 0;
        // get points for each activity
        require_once QA_INCLUDE_DIR . 'qa-db-points.php';
        require_once QA_INCLUDE_DIR . 'qa-db-users.php';
        $optionnames = qa_db_points_option_names();
        $options = qa_get_options($optionnames);
        $multi = (int) $options['points_multiple'];
        $upvote = '';
        $downvote = '';
        if (@$options['points_per_q_voted_up']) {
            $upvote = '_up';
            $downvote = '_down';
        }
        $event_point['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi;
        $event_point['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1;
        $event_point['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1;
        $event_point['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi;
        $event_point['a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi;
        $event_point['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1;
        $event_point['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1;
        $event_point['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi;
        $event_point['in_a_select'] = (int) $options['points_a_selected'] * $multi;
        $event_point['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1;
        $event_point['q_post'] = (int) $options['points_post_q'] * $multi;
        $event_point['a_post'] = (int) $options['points_post_a'] * $multi;
        $event_point['a_select'] = (int) $options['points_select_a'] * $multi;
        $event_point['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi;
        $event_point['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi;
        $event_point['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi;
        $event_point['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi;
        // Get Events
        $userid = qa_get_logged_in_userid();
        $eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT id, UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params, `read` FROM ^ra_userevent WHERE effecteduserid=# AND `read`=0 AND event NOT IN ("u_wall_post", "u_message") ORDER BY datetime DESC LIMIT 15 OFFSET #', $userid, $offset));
        if (count($eventslist) > 0) {
            $event = array();
            $output = '';
            $i = 0;
            //
            $userids = array();
            foreach ($eventslist as $event) {
                $userids[$event['userid']] = $event['userid'];
                $userids[$event['effecteduserid']] = $event['effecteduserid'];
            }
            if (QA_FINAL_EXTERNAL_USERS) {
                $handles = qa_get_public_from_userids($userids);
            } else {
                $handles = qa_db_user_get_userid_handles($userids);
            }
            // get event's: time, type, parameters
            // get post id of questions
            foreach ($eventslist as $event) {
                $title = '';
                $link = '';
                $vote_status = '';
                $handle = isset($handles[$event['userid']]) ? $handles[$event['userid']] : qa_lang('main/anonymous');
                $datetime = $event['datetime'];
                $event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
                $event['params'] = json_decode($event['params'], true);
                $id = ' data-id="' . $event['id'] . '"';
                $read = $event['read'] ? ' read' : ' unread';
                $url_param = array('ra_notification' => $event['id']);
                $user_link = qa_path_html('user/' . $handle, $url_param, QW_BASE_URL);
                switch ($event['event']) {
                    case 'related':
                        // related question to an answer
                        $url = qa_path_html(qa_q_request($event['postid'], $event['params']['title']), $url_param, QW_BASE_URL, null, null);
                        echo '<div class="event-content clearfix' . $read . '' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/asked_question_related_to_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/answer') . '</strong>
										</div>
										<div class="footer">
											<span class="event-icon icon-link"></span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'a_post':
                        // user's question had been answered
                        $anchor = qa_anchor('A', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        $title = qw_truncate($event['params']['qtitle'], 60);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/answered_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/question') . '</strong>
										</div>
										<div class="footer">
											<span class="event-icon icon-answer"></span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'c_post':
                        // user's question had been commented
                        $anchor = qa_anchor('C', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        if ($event['params']['parenttype'] == 'Q') {
                            $type = qa_lang_html('dude/question');
                        } elseif ($event['params']['parenttype'] == 'A') {
                            $type = qa_lang_html('dude/answer');
                        } else {
                            $type = qa_lang_html('dude/comment');
                        }
                        if (isset($event['params']['parent_uid']) && $event['params']['parent_uid'] != $userid) {
                            $what = qa_lang_html('dude/followup_comment');
                            $type = qa_lang_html('dude/comment');
                        } else {
                            $what = qa_lang_html('dude/replied_to_your');
                        }
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . $what . '</span>
											<strong class="where">' . $type . '</strong>
										</div>
										<div class="footer">
											<span class="event-icon icon-arrow-back"></span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'q_reshow':
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, null);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-eye" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<span>' . qa_lang_html('dude/your') . '</span>
											<strong>' . qa_lang_html('dude/question') . '</strong>
											<span class="what">' . qa_lang_html('dude/is_visible') . '</span>
										</div>
										<div class="footer">
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'a_reshow':
                        // user's question had been answered
                        $anchor = qa_anchor('A', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-eye" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<span>' . qa_lang_html('dude/your') . '</span>
											<strong>' . qa_lang_html('dude/answer') . '</strong>
											<span class="what">' . qa_lang_html('dude/is_visible') . '</span>
										</div>
										<div class="footer">
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'c_reshow':
                        // user's question had been answered
                        $anchor = qa_anchor('C', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-eye" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<span>' . qa_lang_html('dude/your') . '</span>
											<strong>' . qa_lang_html('dude/comment') . '</strong>
											<span class="what">' . qa_lang_html('dude/is_visible') . '</span>
										</div>
										<div class="footer">
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'a_select':
                        $anchor = qa_anchor('A', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/selected_as_best') . '</span>
										</div>
										<div class="footer">
											<span class="event-icon icon-award"></span>
											<span class="points">' . qa_lang_sub('dude/you_have_earned_x_points', $event_point['a_post']) . '</span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'q_vote_up':
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null);
                        $title = qw_truncate($event['params']['qtitle'], 60);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/upvoted_on_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/question') . '</strong>
										</div>
										<div class="footer">
											<span class="event-icon icon-thumb-up"></span>
											<span class="points">' . qa_lang_sub('dude/you_have_earned_x_points', $event_point['a_vote_up']) . '</span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'a_vote_up':
                        $anchor = qa_anchor('A', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/upvoted_on_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/answer') . '</strong>
										</div>
										<div class="footer">
											<span class="event-icon icon-thumb-up"></span>
											<span class="points">' . qa_lang_sub('dude/you_have_earned_x_points', $event_point['a_vote_up']) . '</span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'q_approve':
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-input-checked" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/approved_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/question') . '</strong>
										</div>
										<div class="footer">
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'a_approve':
                        $anchor = qa_anchor('A', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-input-checked" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/approved_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/answer') . '</strong>
										</div>
										<div class="footer">
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'u_favorite':
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $user_link . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/added_you_to') . '</span>
											<strong class="where">' . qa_lang_html('dude/favourite') . '</strong>
										</div>
										<div class="footer">
											<span class="event-icon icon-heart"></span>									
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'q_favorite':
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $user_link . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/added_your_question_to') . '</span>
											<strong class="where">' . qa_lang_html('dude/favourite') . '</strong>
										</div>
										<div class="footer">
											<span class="event-icon icon-heart"></span>									
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'q_vote_down':
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-thumb-down" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<span class="what">' . qa_lang_html('dude/you_have_received_down_vote') . '</span>
											<strong class="where">' . qa_lang_html('dude/question') . '</strong>
										</div>
										<div class="footer">
											<span class="points">' . qa_lang_sub('dude/you_have_lost_x_points', $event_point['q_vote_down']) . '</span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'c_approve':
                        $anchor = qa_anchor('C', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-input-checked" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/approved_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/comment') . '</strong>
										</div>
										<div class="footer">									
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'q_reject':
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-times" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/your_question_is_rejected') . '</span>
										</div>
										<div class="footer">
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'a_reject':
                        $anchor = qa_anchor('A', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-times" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/your_answer_is_rejected') . '</span>
										</div>
										<div class="footer">									
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'c_reject':
                        $anchor = qa_anchor('C', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-times" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/your_comment_is_rejected') . '</span>
										</div>
										<div class="footer">									
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'u_level':
                        $url = qa_path_absolute('user/' . $event['params']['handle']);
                        $old_level = $event['params']['oldlevel'];
                        $new_level = $event['params']['level'];
                        if ($new_level < $old_level) {
                            break;
                        }
                        $approved_only = "";
                        if ($new_level == QA_USER_LEVEL_APPROVED && $old_level < QA_USER_LEVEL_APPROVED) {
                            $approved_only = true;
                        } else {
                            $approved_only = false;
                        }
                        if ($approved_only === false) {
                            $new_designation = qw_get_user_desg($new_level);
                        }
                        $content = strtr(qa_lang($approved_only ? 'notification/u_level_approved_notf' : 'notification/u_level_improved_notf'), array('^new_designation' => @$new_designation));
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a class="icon icon-user" href="' . $url . '"></a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . $content . '</span>
										</div>
										<div class="footer">
											<span class="points">' . qa_lang_sub('dude/you_have_earned_x_points', $event_point['a_vote_up']) . '</span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                }
            }
        } else {
            echo '<div class="no-more-activity">' . qa_lang_html('dude/no_more_activity') . '</div>';
        }
        die;
    }
    if (qa_clicked('docancel')) {
    } elseif (qa_clicked('dosaverecalc')) {
        if (!qa_check_form_security_code('admin/points', qa_post_text('code'))) {
            $securityexpired = true;
        } else {
            foreach ($optionnames as $optionname) {
                qa_set_option($optionname, (int) qa_post_text('option_' . $optionname));
            }
            if (!qa_post_text('has_js')) {
                qa_redirect('admin/recalc', array('dorecalcpoints' => 1));
            } else {
                $recalculate = true;
            }
        }
    }
    $options = qa_get_options($optionnames);
}
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/points_title');
$qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error();
$qa_content['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '" name="points_form" onsubmit="document.forms.points_form.has_js.value=1; return true;"', 'style' => 'wide', 'buttons' => array('saverecalc' => array('tags' => 'id="dosaverecalc"', 'label' => qa_lang_html('admin/save_recalc_button'))), 'hidden' => array('dosaverecalc' => '1', 'has_js' => '0', 'code' => qa_get_form_security_code('admin/points')));
if (qa_clicked('doshowdefaults')) {
    $qa_content['form']['ok'] = qa_lang_html('admin/points_defaults_shown');
    $qa_content['form']['buttons']['cancel'] = array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'));
} else {
    if ($recalculate) {
        $qa_content['form']['ok'] = '<span id="recalc_ok"></span>';
        $qa_content['form']['hidden']['code_recalc'] = qa_get_form_security_code('admin/recalc');
        $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
        $qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
function qa_captcha_possible()
{
    $options = qa_get_options(array('recaptcha_public_key', 'recaptcha_private_key'));
    return function_exists('fsockopen') && strlen(trim($options['recaptcha_public_key'])) && strlen(trim($options['recaptcha_private_key']));
}