function check_associate($useraccount)
 {
     $userid = $useraccount['userid'];
     $action = null;
     $key = null;
     if (!empty($_REQUEST['hauth_start'])) {
         $key = trim(strip_tags($_REQUEST['hauth_start']));
         $action = 'process';
     } else {
         if (!empty($_REQUEST['hauth_done'])) {
             $key = trim(strip_tags($_REQUEST['hauth_done']));
             $action = 'process';
         } else {
             if (!empty($_GET['link'])) {
                 $key = trim(strip_tags($_GET['link']));
                 $action = 'login';
             }
         }
     }
     if ($key == null) {
         return false;
     }
     $provider = $this->get_ha_provider($key);
     $source = strtolower($provider);
     if ($action == 'login') {
         // handle the login
         // after login come back to the same page
         $loginCallback = qa_path('', array(), qa_opt('site_url'));
         require_once $this->directory . 'Hybrid/Auth.php';
         require_once $this->directory . 'qa-open-utils.php';
         // prepare the configuration of HybridAuth
         $config = $this->get_ha_config($provider, $loginCallback);
         try {
             // try to login
             $hybridauth = new Hybrid_Auth($config);
             $adapter = $hybridauth->authenticate($provider);
             // if ok, create/refresh the user account
             $user = $adapter->getUserProfile();
             $duplicates = 0;
             if (!empty($user)) {
                 // prepare some data
                 $ohandle = null;
             }
             $oemail = null;
             if (empty($user->displayName)) {
                 $ohandle = $provider;
             } else {
                 $ohandle = preg_replace('/[\\@\\+\\/]/', ' ', $user->displayName);
             }
             if (strlen(@$user->email) && $user->emailVerified) {
                 // only if email is confirmed
                 $oemail = $user->email;
             }
             $duplicate = qa_db_user_login_find_duplicate__open($source, $user->identifier);
             if ($duplicate == null) {
                 // simply create a new login
                 qa_db_user_login_sync(true);
                 qa_db_user_login_add($userid, $source, $user->identifier);
                 if ($oemail) {
                     qa_db_user_login_set__open($source, $user->identifier, 'oemail', $oemail);
                 }
                 qa_db_user_login_set__open($source, $user->identifier, 'ohandle', $ohandle);
                 qa_db_user_login_sync(false);
                 // now that everything was added, log out to allow for multiple accounts
                 $adapter->logout();
                 // redirect to get rid of parameters
                 qa_redirect('logins');
             } else {
                 if ($duplicate['userid'] == $userid) {
                     // trying to add the same account, just update the email/handle
                     qa_db_user_login_sync(true);
                     if ($oemail) {
                         qa_db_user_login_set__open($source, $user->identifier, 'oemail', $oemail);
                     }
                     qa_db_user_login_set__open($source, $user->identifier, 'ohandle', $ohandle);
                     qa_db_user_login_sync(false);
                     // log out to allow for multiple accounts
                     $adapter->logout();
                     // redirect to get rid of parameters
                     qa_redirect('logins');
                 } else {
                     if (qa_get('confirm') == 2) {
                         return $duplicate;
                     } else {
                         qa_redirect('logins', array('link' => qa_get('link'), 'confirm' => 2));
                     }
                 }
             }
         } catch (Exception $e) {
             qa_redirect('logins', array('provider' => $provider, 'code' => $e->getCode()));
         }
     }
     if ($action == 'process') {
         require_once "Hybrid/Auth.php";
         require_once "Hybrid/Endpoint.php";
         Hybrid_Endpoint::process();
     }
     return false;
 }
Beispiel #2
0
 public function get_field(&$qa_content, $content, $format, $fieldname, $rows)
 {
     $scriptsrc = $this->urltoroot . 'ckeditor/ckeditor.js?' . QA_VERSION;
     $alreadyadded = false;
     if (isset($qa_content['script_src'])) {
         foreach ($qa_content['script_src'] as $testscriptsrc) {
             if ($testscriptsrc == $scriptsrc) {
                 $alreadyadded = true;
             }
         }
     }
     if (!$alreadyadded) {
         $uploadimages = qa_opt('wysiwyg_editor_upload_images');
         $uploadall = $uploadimages && qa_opt('wysiwyg_editor_upload_all');
         $imageUploadUrl = qa_js(qa_path('wysiwyg-editor-upload', array('qa_only_image' => true)));
         $fileUploadUrl = qa_js(qa_path('wysiwyg-editor-upload'));
         $qa_content['script_src'][] = $scriptsrc;
         $qa_content['script_lines'][] = array("var qa_wysiwyg_editor_config = {", "\ttoolbar: [", "\t\t{ name: 'basic', items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript' ] },", "\t\t{ name: 'color', items: [ 'TextColor', 'BGColor' ] },", "\t\t{ name: 'align', items: [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },", "\t\t{ name: 'clipboard', items: [ 'Cut', 'Copy', 'Paste', 'PasteFromWord', '-', 'Undo', 'Redo' ] },", "\t\t'/',", "\t\t{ name: 'font', items: [ 'Font', 'FontSize', 'Format' ] },", "\t\t{ name: 'paragraph', items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote' ] },", "\t\t{ name: 'links', items: [ 'Link', 'Unlink' ] },", "\t\t{ name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar' ] },", "\t\t{ name: 'last', items: [ 'RemoveFormat', 'Maximize' ] }", "\t],", "\tformat_tags: 'p;h1;h2;h3;pre',", "\tentities: false,", "\tremoveDialogTabs: 'image:advanced;link:advanced;table:advanced',", "\tdisableNativeSpellChecker: false,", "\tdefaultLanguage: 'en',", "\tlanguage: " . qa_js(qa_opt('site_language')) . ",", $uploadimages ? "\tfilebrowserImageUploadUrl: {$imageUploadUrl}," : "", $uploadall ? "\tfilebrowserUploadUrl: {$fileUploadUrl}," : "", "\tcustomConfig: ''", "};");
     }
     if ($format == 'html') {
         $html = $content;
         $text = $this->html_to_text($content);
     } else {
         $text = $content;
         $html = qa_html($content, true);
     }
     return array('tags' => 'name="' . $fieldname . '"', 'value' => qa_html($text), 'rows' => $rows, 'html_prefix' => '<input name="' . $fieldname . '_ckeditor_ok" id="' . $fieldname . '_ckeditor_ok" type="hidden" value="0"><input name="' . $fieldname . '_ckeditor_data" id="' . $fieldname . '_ckeditor_data" type="hidden" value="' . qa_html($html) . '">');
 }
 function get_field(&$qa_content, $content, $format, $fieldname, $rows)
 {
     $scriptsrc = $this->urltoroot . 'ckeditor.js?' . QA_VERSION;
     $alreadyadded = false;
     if (isset($qa_content['script_src'])) {
         foreach ($qa_content['script_src'] as $testscriptsrc) {
             if ($testscriptsrc == $scriptsrc) {
                 $alreadyadded = true;
             }
         }
     }
     if (!$alreadyadded) {
         $uploadimages = qa_opt('wysiwyg_editor_upload_images');
         $uploadall = $uploadimages && qa_opt('wysiwyg_editor_upload_all');
         $qa_content['script_src'][] = $scriptsrc;
         $qa_content['script_lines'][] = array("qa_wysiwyg_editor_config={toolbar:[" . "['Bold','Italic','Underline','Strike']," . "['Font','FontSize']," . "['TextColor','BGColor']," . "['Link','Unlink']," . "'/'," . "['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock']," . "['NumberedList','BulletedList','-','Outdent','Indent','Blockquote']," . "['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar']," . "['RemoveFormat', 'Maximize']" . "]" . ", defaultLanguage:" . qa_js(qa_opt('site_language')) . ", skin:'v2'" . ", toolbarCanCollapse:false" . ", removePlugins:'elementspath'" . ", resize_enabled:false" . ", autogrow:false" . ", entities:false" . ($uploadimages ? ", filebrowserImageUploadUrl:" . qa_js(qa_path('wysiwyg-editor-upload', array('qa_only_image' => true))) : "") . ($uploadall ? ", filebrowserUploadUrl:" . qa_js(qa_path('wysiwyg-editor-upload')) : "") . "};");
     }
     if ($format == 'html') {
         $html = $content;
         $text = $this->html_to_text($content);
     } else {
         $text = $content;
         $html = qa_html($content, true);
     }
     return array('tags' => 'name="' . $fieldname . '"', 'value' => qa_html($text), 'rows' => $rows, 'html_prefix' => '<input name="' . $fieldname . '_ckeditor_ok" id="' . $fieldname . '_ckeditor_ok" type="hidden" value="0"><input name="' . $fieldname . '_ckeditor_data" id="' . $fieldname . '_ckeditor_data" type="hidden" value="' . qa_html($html) . '">');
 }
 function logout_html($tourl)
 {
     require_once QA_INCLUDE_DIR . "qa-base.php";
     $_SESSION['logout_url'] = $tourl;
     $logout_url = qa_path('auth/logout', null, qa_path_to_root());
     echo '<a href="' . $logout_url . '">' . qa_lang_html('main/nav_logout') . '</a>';
 }
 function admin_form(&$qa_content)
 {
     // process the admin form if admin hits Save-Changes-button
     $ok = null;
     if (qa_clicked('q2apro_popularqu_save')) {
         qa_opt('q2apro_popularqu_enabled', (bool) qa_post_text('q2apro_popularqu_enabled'));
         // empty or 1
         qa_opt('q2apro_popularqu_maxqu', (int) qa_post_text('q2apro_popularqu_maxqu'));
         qa_opt('q2apro_popularqu_lastdays', (int) qa_post_text('q2apro_popularqu_lastdays'));
         qa_opt('q2apro_popularqu_checkhours', (int) qa_post_text('q2apro_popularqu_checkhours'));
         qa_opt('q2apro_popularqu_answercount', (bool) qa_post_text('q2apro_popularqu_answercount'));
         $ok = qa_lang('admin/options_saved');
         // in case the options have been changed, update the widget
         q2apro_save_most_viewed_questions();
     }
     // form fields to display frontend for admin
     $fields = array();
     $fields[] = array('type' => 'checkbox', 'label' => qa_lang('q2apro_popularqu_lang/enable_plugin'), 'tags' => 'name="q2apro_popularqu_enabled"', 'value' => qa_opt('q2apro_popularqu_enabled'));
     $fields[] = array('type' => 'input', 'label' => qa_lang('q2apro_popularqu_lang/admin_maxqu'), 'tags' => 'name="q2apro_popularqu_maxqu"', 'value' => qa_opt('q2apro_popularqu_maxqu'));
     $fields[] = array('type' => 'checkbox', 'label' => qa_lang('q2apro_popularqu_lang/admin_answercount'), 'tags' => 'name="q2apro_popularqu_answercount"', 'value' => qa_opt('q2apro_popularqu_answercount'));
     $fields[] = array('type' => 'input', 'label' => qa_lang('q2apro_popularqu_lang/admin_lastdays'), 'tags' => 'name="q2apro_popularqu_lastdays"', 'value' => qa_opt('q2apro_popularqu_lastdays'));
     $fields[] = array('type' => 'input', 'label' => qa_lang('q2apro_popularqu_lang/admin_checkhours'), 'tags' => 'name="q2apro_popularqu_checkhours"', 'value' => qa_opt('q2apro_popularqu_checkhours'));
     $fields[] = array('type' => 'static', 'note' => qa_lang('q2apro_popularqu_lang/admin_lastcache') . ' ' . date('Y-m-d H:i:s', (double) qa_opt('q2apro_popularqu_checktime')));
     $fields[] = array('type' => 'static', 'note' => qa_lang('q2apro_popularqu_lang/admin_remember') . ' <a href="' . qa_path('admin/layout') . '">/admin/layout</a>');
     $fields[] = array('type' => 'static', 'note' => '<span style="font-size:75%;color:#789;">' . strtr(qa_lang('q2apro_popularqu_lang/contact'), array('^1' => '<a target="_blank" href="http://www.q2apro.com/forum/">', '^2' => '</a>')) . '</span>');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang('main/save_button'), 'tags' => 'name="q2apro_popularqu_save"')));
 }
function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $selchildid, $answers)
{
    $oldselchildid = $oldquestion['selchildid'];
    qa_db_post_set_selchildid($oldquestion['postid'], isset($selchildid) ? $selchildid : null);
    qa_db_points_update_ifuser($oldquestion['userid'], 'aselects');
    if (isset($oldselchildid)) {
        if (isset($answers[$oldselchildid])) {
            qa_db_points_update_ifuser($answers[$oldselchildid]['userid'], 'aselecteds');
            qa_report_event('a_unselect', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $oldselchildid));
        }
    }
    if (isset($selchildid)) {
        $answer = $answers[$selchildid];
        qa_db_points_update_ifuser($answer['userid'], 'aselecteds');
        if (isset($answer['notify']) && !qa_post_is_by_user($answer, $userid, $cookieid)) {
            require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
            require_once QA_INCLUDE_DIR . 'qa-app-options.php';
            require_once QA_INCLUDE_DIR . 'qa-util-string.php';
            require_once QA_INCLUDE_DIR . 'qa-app-format.php';
            $blockwordspreg = qa_get_block_words_preg();
            $sendtitle = qa_block_words_replace($oldquestion['title'], $blockwordspreg);
            $sendcontent = qa_viewer_text($answer['content'], $answer['format'], array('blockwordspreg' => $blockwordspreg));
            qa_send_notification($answer['userid'], $answer['notify'], @$answer['handle'], qa_lang('emails/a_selected_subject'), qa_lang('emails/a_selected_body'), array('^s_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => $sendtitle, '^a_content' => $sendcontent, '^url' => qa_path(qa_q_request($oldquestion['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor('A', $selchildid))));
        }
        qa_report_event('a_select', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $selchildid));
    }
}
Beispiel #7
0
 public function get_field(&$qa_content, $content, $format, $fieldname, $rows)
 {
     $scriptsrc = $this->urltoroot . 'ckeditor/ckeditor.js?' . QA_VERSION;
     $alreadyadded = false;
     if (isset($qa_content['script_src'])) {
         foreach ($qa_content['script_src'] as $testscriptsrc) {
             if ($testscriptsrc == $scriptsrc) {
                 $alreadyadded = true;
             }
         }
     }
     if (!$alreadyadded) {
         $uploadimages = qa_opt('wysiwyg_editor_upload_images');
         $uploadall = $uploadimages && qa_opt('wysiwyg_editor_upload_all');
         $imageUploadUrl = qa_js(qa_path('wysiwyg-editor-upload', array('qa_only_image' => true)));
         $fileUploadUrl = qa_js(qa_path('wysiwyg-editor-upload'));
         $qa_content['script_src'][] = $scriptsrc;
         $qa_content['script_lines'][] = array("var qa_wysiwyg_editor_config = {", $uploadimages ? "\tfilebrowserImageUploadUrl: {$imageUploadUrl}," : "", $uploadall ? "\tfilebrowserUploadUrl: {$fileUploadUrl}," : "", "\tdefaultLanguage: 'en',", "\tlanguage: " . qa_js(qa_opt('site_language')) . "", "};");
     }
     if ($format == 'html') {
         $html = $content;
         $text = $this->html_to_text($content);
     } else {
         $text = $content;
         $html = qa_html($content, true);
     }
     return array('tags' => 'name="' . $fieldname . '"', 'value' => qa_html($text), 'rows' => $rows, 'html_prefix' => '<input name="' . $fieldname . '_ckeditor_ok" id="' . $fieldname . '_ckeditor_ok" type="hidden" value="0"><input name="' . $fieldname . '_ckeditor_data" id="' . $fieldname . '_ckeditor_data" type="hidden" value="' . qa_html($html) . '">');
 }
function mp_announcement_create($userid, $handle, $cookieid, $title, $content, $format, $text, $notify, $categoryid)
{
    /* 
     * Proceeds to create an announcement
     *
     */
    require_once QA_INCLUDE_DIR . 'qa-db-post-create.php';
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    require_once QA_INCLUDE_DIR . 'mp-app-users.php';
    // persist data to database
    $postid = qa_db_post_create('AN', null, $userid, $cookieid, qa_remote_ip_address(), $title, $content, $format, null, $notify, $categoryid);
    qa_user_report_action(qa_get_logged_in_userid(), null, null, null, null);
    // update new post with category path hierarchy
    qa_db_posts_calc_category_path($postid);
    // send notifications
    if ($notify && isset($postid)) {
        $category = mp_get_categoryinfo($categoryid);
        $recipients = mp_get_category_userids($categoryid);
        foreach ($recipients as $recipient) {
            // retrieve the user flags
            $userflags = mp_get_user_flags($recipient['userid']);
            // check user flags to determine whether user should be notified or not
            // of the new answer post
            if (!($userflags & QA_USER_FLAGS_NOTIFY_ANNOUNCEMENTS)) {
                qa_send_notification($recipient['userid'], null, null, qa_lang('emails/an_posted_subject'), qa_lang('emails/an_posted_body'), array('^an_handle' => $handle, '^category_title' => $category['title'], '^an_title' => $title, '^an_url' => qa_path('mp-announcements-page', null, qa_opt('site_url'), null, null)));
            }
        }
    }
    // report announcement create event
    qa_report_event('an_post', $userid, $handle, $cookieid, array('postid' => $postid, 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $categoryid, 'notify' => $notify));
    return $postid;
}
function qa_get_request_content()
{
    if (qa_opt('news_plugin_active')) {
        $requestlower = strtolower(qa_request());
        if ($requestlower && $requestlower === 'my-profile') {
            $userid = qa_get_logged_in_userid();
            if (!$userid) {
                qa_redirect();
            }
            $handles = qa_userids_to_handles(array($userid));
            $handle = $handles[$userid];
            qa_redirect(qa_path('user/' . $handle));
        } else {
            if ($requestlower && $requestlower === qa_opt('news_plugin_request')) {
                // send on cron
                if (qa_opt('news_plugin_send') && qa_get('cron') == qa_opt('news_plugin_cron_rand') && time() >= qa_opt('news_plugin_send_last') + 23 * 60 * 60) {
                    // minumum cron interval is 23 hours
                    qa_news_plugin_createNewsletter(true);
                    return false;
                } else {
                    if (qa_get('cron') == qa_opt('news_plugin_cron_rand')) {
                        if (!qa_opt('news_plugin_send')) {
                            error_log('Q2A Newsletter Recreate Error: sending newsletter not allowed via admin/plugins');
                        } else {
                            error_log('Q2A Newsletter Recreate Error: cron request before minimum time elapsed');
                        }
                        echo "false\n";
                        return false;
                    }
                }
                include qa_opt('news_plugin_loc');
                return false;
            } else {
                if (qa_opt('news_plugin_pdf') && $requestlower && $requestlower === qa_opt('news_plugin_request_pdf')) {
                    $pdf = file_get_contents(qa_opt('news_plugin_loc_pdf'));
                    header('Content-Description: File Transfer');
                    header('Cache-Control: public, must-revalidate, max-age=0');
                    // HTTP/1.1
                    header('Pragma: public');
                    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
                    // Date in the past
                    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
                    // force download dialog
                    header('Content-Type: application/force-download');
                    header('Content-Type: application/octet-stream', false);
                    header('Content-Type: application/download', false);
                    header('Content-Type: application/pdf', false);
                    // use the Content-Disposition header to supply a recommended filename
                    header('Content-Disposition: attachment; filename="' . basename(qa_opt('news_plugin_loc_pdf')) . '";');
                    header('Content-Transfer-Encoding: binary');
                    header('Content-Length: ' . strlen($pdf));
                    echo $pdf;
                    return false;
                }
            }
        }
    }
    return qa_get_request_content_base();
}
Beispiel #10
0
function qa_get_blob_url($blobid, $absolute = false)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    return qa_path('blob', array('qa_blobid' => $blobid), $absolute ? qa_opt('site_url') : null, QA_URL_FORMAT_PARAMS);
}
 public function process_event($event, $userid, $handle, $cookieid, $params)
 {
     switch ($event) {
         case 'q_post':
             $this->send_hipchat_notification($this->build_new_question_message(isset($handle) ? $handle : qa_lang('main/anonymous'), $params['title'], qa_q_path($params['postid'], $params['title'], true)));
             break;
         case 'a_post':
             $parentpost = qa_post_get_full($params['parentid']);
             $this->send_hipchat_notification($this->build_new_answer_message(isset($handle) ? $handle : qa_lang('main/anonymous'), $parentpost['title'], qa_path(qa_q_request($params['parentid'], $parentpost['title']), null, qa_opt('site_url'), null, qa_anchor('A', $params['postid']))));
             break;
     }
 }
 function get_field(&$qa_content, $content, $format, $fieldname, $rows, $autofocus)
 {
     $uploadimages = qa_opt('wysiwyg_editor_upload_images');
     $uploadall = $uploadimages && qa_opt('wysiwyg_editor_upload_all');
     $qa_content['script_src'][] = $this->urltoroot . 'ckeditor.js?' . QA_VERSION;
     $qa_content['script_onloads'][] = "CKEDITOR.replace(" . qa_js($fieldname) . ", {toolbar:[" . "['Bold','Italic','Underline','Strike']," . "['Font','FontSize']," . "['TextColor','BGColor']," . "['Link','Unlink']," . "'/'," . "['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock']," . "['NumberedList','BulletedList','-','Outdent','Indent','Blockquote']," . "['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar']," . "['RemoveFormat', 'Maximize']" . "]" . ", defaultLanguage:" . qa_js(qa_opt('site_language')) . ", skin:'v2'" . ", toolbarCanCollapse:false" . ", removePlugins:'elementspath'" . ", resize_enabled:false" . ", autogrow:false" . ", startupFocus:" . ($autofocus ? 'true' : 'false') . ", entities:false" . ($uploadimages ? ", filebrowserImageUploadUrl:" . qa_js(qa_path('wysiwyg-editor-upload', array('qa_only_image' => true))) : "") . ($uploadall ? ", filebrowserUploadUrl:" . qa_js(qa_path('wysiwyg-editor-upload')) : "") . "})";
     if ($format == 'html') {
         $html = $content;
     } else {
         $html = qa_html($content, true);
     }
     return array('tags' => 'NAME="' . $fieldname . '"', 'value' => qa_html($html), 'rows' => $rows);
 }
 function doctype()
 {
     global $qa_theme_switch_is_mobile;
     if ($qa_theme_switch_is_mobile && qa_opt('theme_switch_enable_mobile') && qa_opt('site_theme') != qa_opt('theme_switch_mobile')) {
         $this->content['navigation']['footer']['theme_switch'] = array('label' => 'Mobile Version', 'url' => qa_path($this->request, array('theme_switch' => qa_opt('theme_switch_mobile'))));
     } else {
         if (qa_opt('theme_switch_enable_mobile') && qa_opt('site_theme') == qa_opt('theme_switch_mobile')) {
             $this->content['navigation']['footer']['theme_switch'] = array('label' => 'Full Site', 'url' => qa_path($this->request, array('theme_switch' => qa_opt('theme_switch_default'))));
         }
     }
     if (@$_GET['theme_switch']) {
         /*
         
         	if($userid = qa_get_logged_in_userid()) {
         		qa_db_query_sub(
         			'INSERT INTO ^usermeta (user_id,meta_key,meta_value) VALUES (#,$,$) ON DUPLICATE KEY UPDATE meta_value=$',
         			$userid,'custom_theme',$_GET['theme_switch'],$_GET['theme_switch']
         		);
         	}
         */
         setcookie('qa_theme_switch', $_GET['theme_switch'], time() + 86400 * 365, '/', QA_COOKIE_DOMAIN);
         qa_redirect($this->request, array());
     }
     if (qa_opt('theme_switch_enable')) {
         if ($this->template == 'user' && !qa_get('tab')) {
             // add theme switcher
             $handle = preg_replace('/^[^\\/]+\\/([^\\/]+).*/', "\$1", $this->request);
             $theme_form = $this->theme_switch_form();
             if ($theme_form) {
                 // insert our form
                 if ($this->content['q_list']) {
                     // paranoia
                     // array splicing kungfu thanks to Stack Exchange
                     // This adds form-theme-switch 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-theme-switch';
                     $vals[] = $theme_form;
                     $this->content = array_merge(array_combine($keys, $vals), array_combine($keys2, $vals2));
                 } else {
                     $this->content['form-theme-switch'] = $theme_form;
                 }
                 // this shouldn't happen
             }
         }
     }
     qa_html_theme_base::doctype();
 }
 function process_request($request)
 {
     @ini_set('display_errors', 0);
     // we don't want to show PHP errors inside XML
     $titlehtml = qa_html(qa_opt('site_title'));
     $template = str_replace('_searchTerms_placeholder_', '{searchTerms}', qa_path('search', array('q' => '_searchTerms_placeholder_'), qa_opt('site_url')));
     header('Content-type: text/xml; charset=utf-8');
     echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">' . "\n";
     echo "\t<ShortName>" . $titlehtml . "</ShortName>\n";
     echo "\t<Description>" . qa_lang_html('main/search_button') . ' ' . $titlehtml . "</Description>\n";
     echo "\t" . '<Url type="text/html" method="get" template="' . qa_html($template) . '"/>' . "\n";
     echo "\t<InputEncoding>UTF-8</InputEncoding>\n";
     echo '</OpenSearchDescription>' . "\n";
     return null;
 }
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     $loginmodules = qa_load_modules_with('login', 'login_html');
     if (empty($loginmodules)) {
         return;
     }
     $themeobject->output('<div class="open-login-sidebar">', qa_lang_html('plugin_open/login_title'), '</div>', '<p class="open-login-sidebar-buttons">');
     foreach ($loginmodules as $tryname => $module) {
         ob_start();
         $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($request, $_GET, qa_opt('site_url')), 'sidebar');
         $label = ob_get_clean();
         if (strlen($label)) {
             $themeobject->output($label);
         }
     }
     $themeobject->output('</p>');
 }
 function form_fields($form, $columns)
 {
     $handle = $this->_user_handle();
     if ($this->template === 'user' && !empty($form['fields'])) {
         foreach ($form['fields'] as $key => &$field) {
             if ($key === 'questions') {
                 $url = qa_path('user-activity/questions/' . $handle);
                 $field['value'] .= ' &mdash; <a href="' . $url . '">All actions by ' . qa_html($handle) . ' &rsaquo;</a>';
             } else {
                 if ($key === 'answers') {
                     $url = qa_path('user-activity/answers/' . $handle);
                     $field['value'] .= ' &mdash; <a href="' . $url . '">All reactions by ' . qa_html($handle) . ' &rsaquo;</a>';
                 }
             }
         }
     }
     qa_html_theme_base::form_fields($form, $columns);
 }
Beispiel #17
0
function qa_merge_do_merge()
{
    qa_opt('merge_question_merged', qa_post_text('merge_question_merged'));
    $from = (int) qa_post_text('merge_from');
    $to = (int) qa_post_text('merge_to');
    $titles = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid,title,acount FROM ^posts WHERE postid IN (#,#)", qa_post_text('merge_from'), qa_post_text('merge_to')));
    if (count($titles) != 2) {
        $error1 = null;
        $error2 = null;
        if (empty($titles)) {
            $error1 = 'Post not found.';
            $error2 = $error1;
        } else {
            if ($titles[0]['postid'] == $from) {
                $error2 = 'Post not found.';
            } else {
                if ($titles[0]['postid'] == $to) {
                    $error1 = 'Post not found.';
                } else {
                    $error1 = 'unknown error.';
                }
            }
        }
        return array($error1, $error2);
    } else {
        $acount = (int) $titles[0]['acount'] + (int) $titles[1]['acount'];
        $text = '<div class="qa-content-merged"> ' . str_replace('^post', qa_path(qa_q_request((int) qa_post_text('merge_to'), $titles[0]['postid'] == $to ? $titles[0]['title'] : $titles[1]['title']), null, qa_opt('site_url')), qa_opt('merge_question_merged')) . ' </div>';
        qa_db_query_sub("UPDATE ^posts SET parentid=# WHERE parentid=#", $to, $from);
        qa_db_query_sub("UPDATE ^posts SET acount=# WHERE postid=#", $acount, $to);
        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');
        qa_db_query_sub("INSERT INTO ^postmeta (post_id,meta_key,meta_value) VALUES (#,'merged_with',#)", $from, $to);
        require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
        qa_post_delete($from);
        return true;
    }
}
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     $themeobject->output('<H2 STYLE="margin-top:0; padding-top:0;">', qa_opt('share_plugin_widget_title'), '</H2>');
     $url = qa_path($request, null, qa_opt('site_url'));
     $code = array('facebook' => '<div class="fb-like" data-href="' . $url . '" data-send="false" data-layout="button_count" data-width="36" data-show-faces="false"></div>', 'twitter' => '<a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a>', 'google' => '<g:plusone size="medium" annotation="none"></g:plusone>', 'linkedin' => '<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share"></script>', 'email' => '<a title="Share this question via email" id="share-button-email" href="mailto:?subject=' . rawurlencode('[' . qa_opt('site_title') . '] ' . @$qa_content['q_view']['raw']['title']) . '&body=' . rawurlencode($url) . '"><img height="24" src="' . $this->urltoroot . 'qa-share-mail.png' . '"/></a>');
     // sort by weight
     $weight = array('facebook' => qa_opt('share_plugin_facebook_weight'), 'twitter' => qa_opt('share_plugin_twitter_weight'), 'google' => qa_opt('share_plugin_google_weight'), 'linkedin' => qa_opt('share_plugin_linkedin_weight'), 'email' => qa_opt('share_plugin_email_weight'));
     asort($weight);
     // output
     foreach ($weight as $key => $val) {
         if (qa_opt('share_plugin_' . $key)) {
             $shares[] = '<div class="qa-share-button qa-share-button-' . $key . '">' . $code[$key] . '</div>';
         }
     }
     if (empty($shares)) {
         return null;
     }
     $output = '<div class="share-widget-container">' . implode('&nbsp;', $shares) . '</div>';
     $themeobject->output($output);
 }
Beispiel #19
0
 /**
  * Custom ask button for medium and small screen
  *
  * @access private
  * @since Snow 1.4
  * @version 1.0
  * @return string Ask button html markup
  */
 private function ask_button()
 {
     return '<div class="qam-ask-search-box">' . '<div class="qam-ask-mobile">' . '<a href="' . qa_path('ask', null, qa_path_to_root()) . '" class="' . $this->ask_search_box_class . '">' . qa_lang_html('main/nav_ask') . '</a>' . '</div>' . '<div class="qam-search-mobile ' . $this->ask_search_box_class . '" id="qam-search-mobile">' . '</div>' . '</div>';
 }
Beispiel #20
0
 function qa_get_login_links($rooturl, $tourl)
 {
     return array('login' => qa_path('login', isset($tourl) ? array('to' => $tourl) : null, $rooturl), 'register' => qa_path('register', isset($tourl) ? array('to' => $tourl) : null, $rooturl), 'confirm' => qa_path('confirm', null, $rooturl), 'logout' => qa_path('logout', null, $rooturl));
 }
function qa_flag_set_tohide($post, $userid, $handle, $cookieid, $question)
{
    require_once QA_INCLUDE_DIR . 'qa-db-votes.php';
    require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
    qa_db_userflag_set($post['postid'], $userid, true);
    qa_db_post_recount_flags($post['postid']);
    switch ($post['basetype']) {
        case 'Q':
            $action = 'q_flag';
            break;
        case 'A':
            $action = 'a_flag';
            break;
        case 'C':
            $action = 'c_flag';
            break;
    }
    qa_report_write_action($userid, null, $action, $post['basetype'] == 'Q' ? $post['postid'] : null, $post['basetype'] == 'A' ? $post['postid'] : null, $post['basetype'] == 'C' ? $post['postid'] : null);
    qa_report_event($action, $userid, $handle, $cookieid, array('postid' => $post['postid']));
    $post = qa_db_select_with_pending(qa_db_full_post_selectspec(null, $post['postid']));
    $flagcount = $post['flagcount'];
    $notifycount = $flagcount - qa_opt('flagging_notify_first');
    if ($notifycount >= 0 && $notifycount % qa_opt('flagging_notify_every') == 0) {
        require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
        require_once QA_INCLUDE_DIR . 'qa-app-format.php';
        $anchor = $post['basetype'] == 'Q' ? null : qa_anchor($post['basetype'], $post['postid']);
        qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('emails/flagged_subject'), qa_lang('emails/flagged_body'), array('^p_handle' => isset($post['handle']) ? $post['handle'] : qa_lang('main/anonymous'), '^flags' => $flagcount == 1 ? qa_lang_html_sub('main/1_flag', '1', '1') : qa_lang_html_sub('main/x_flags', $flagcount), '^p_context' => trim(@$post['title'] . "\n\n" . qa_viewer_text($post['content'], $post['format'])), '^url' => qa_path(qa_q_request($question['postid'], $question['title']), null, qa_opt('site_url'), null, $anchor)));
    }
    if ($flagcount >= qa_opt('flagging_hide_after') && !$post['hidden']) {
        return true;
    }
    return false;
}
            $errors['emailhandle'] = qa_lang('users/user_not_found');
        }
    } else {
        $pageerror = qa_lang('users/login_limit');
    }
} else {
    $inemailhandle = qa_get('e');
}
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('users/login_title');
$qa_content['error'] = @$pageerror;
if (empty($inemailhandle) || isset($errors['emailhandle'])) {
    $forgotpath = qa_path('forgot');
} else {
    $forgotpath = qa_path('forgot', array('e' => $inemailhandle));
}
$forgothtml = '<A HREF="' . qa_html($forgotpath) . '">' . qa_lang_html('users/forgot_link') . '</A>';
$qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $passwordsent ? qa_lang_html('users/password_sent') : null, 'fields' => array('email_handle' => array('label' => qa_opt('allow_login_email_only') ? qa_lang_html('users/email_label') : qa_lang_html('users/email_handle_label'), 'tags' => 'NAME="emailhandle" ID="emailhandle"', 'value' => qa_html(@$inemailhandle), 'error' => qa_html(@$errors['emailhandle'])), 'password' => array('type' => 'password', 'label' => qa_lang_html('users/password_label'), 'tags' => 'NAME="password" ID="password"', 'value' => qa_html(@$inpassword), 'error' => empty($errors['password']) ? '' : qa_html(@$errors['password']) . ' - ' . $forgothtml, 'note' => $passwordsent ? qa_lang_html('users/password_sent') : $forgothtml), 'remember' => array('type' => 'checkbox', 'label' => qa_lang_html('users/remember_label'), 'tags' => 'NAME="remember"', 'value' => @$inremember ? true : false)), 'buttons' => array('login' => array('label' => qa_lang_html('users/login_button'))), 'hidden' => array('dologin' => '1'));
$loginmodules = qa_load_modules_with('login', 'login_html');
foreach ($loginmodules as $module) {
    ob_start();
    $module->login_html(qa_opt('site_url') . qa_get('to'), 'login');
    $html = ob_get_clean();
    if (strlen($html)) {
        @($qa_content['custom'] .= '<BR>' . $html . '<BR>');
    }
}
$qa_content['focusid'] = isset($inemailhandle) && !isset($errors['emailhandle']) ? 'password' : 'emailhandle';
return $qa_content;
/*
Beispiel #23
0
    public function messagelist()
    {
        $offset = (int) qa_get('offset');
        $offset = isset($offset) ? $offset * 15 : 0;
        require_once QA_INCLUDE_DIR . 'qa-db-users.php';
        // Get Events
        $message_events = array('u_message', 'u_wall_post');
        $events = "'" . implode("','", $message_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 IN (' . $events . ') ORDER BY id DESC LIMIT 15 OFFSET #', $userid, $offset));
        if (count($eventslist) > 0) {
            $event = array();
            $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 = '';
                $handle = $handles[$event['userid']];
                $reciever_handle = $handles[$event['effecteduserid']];
                $reciever_link = qa_path('user/' . $reciever_handle);
                $datetime = $event['datetime'];
                $event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
                $event['params'] = json_decode($event['params'], true);
                $message = substr($event['params']['message'], 0, 30) . '..';
                $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);
                switch ($event['event']) {
                    case 'u_message':
                        // related question to an answer
                        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="' . qa_path_html('message/' . $handle, $url_param, QW_BASE_URL) . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/sent_you_a_private_message') . '</span>
											<span class="message">' . $message . '</span>
										</div>
										<div class="footer">
											<span class="event-icon icon-email"></span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'u_wall_post':
                        // user's question had been answered
                        $url = qa_path_html('user/' . $reciever_handle . '/wall', $url_param, QW_BASE_URL);
                        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/posted_on_your_wall') . '</span>
											<span class="message">' . $message . '</span>
										</div>
										<div class="footer">
											<span class="event-icon icon-pin"></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_messages') . '</div>';
        }
        die;
    }
 /**
  * @deprecated This function will become private in Q2A 1.8. It is specific to this plugin and
  * should not be used by outside code.
  */
 public function sitemap_output($request, $priority)
 {
     echo "\t<url>\n" . "\t\t<loc>" . qa_xml(qa_path($request, null, qa_opt('site_url'))) . "</loc>\n" . "\t\t<priority>" . max(0, min(1.0, $priority)) . "</priority>\n" . "\t</url>\n";
 }
 function sitemap_index_output($request)
 {
     echo "\t<sitemap>\n" . "\t\t<loc>" . qa_xml(qa_path($request, null, qa_opt('site_url'))) . "</loc>\n" . "\t</sitemap>\n";
 }
Beispiel #26
0
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/updates.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
if ($feedtype != 'search' && $feedtype != 'hot') {
    // leave search results and hot questions sorted by relevance
    $questions = qa_any_sort_and_dedupe($questions);
}
$questions = array_slice($questions, 0, $count);
$blockwordspreg = qa_get_block_words_preg();
//	Prepare the XML output
$lines = array();
$lines[] = '<?xml version="1.0" encoding="utf-8"?>';
$lines[] = '<rss version="2.0">';
$lines[] = '<channel>';
$lines[] = '<title>' . qa_xml($sitetitle . ' - ' . $title) . '</title>';
$lines[] = '<link>' . qa_xml(qa_path($linkrequest, $linkparams, $siteurl)) . '</link>';
$lines[] = '<description>Powered by Question2Answer</description>';
foreach ($questions as $question) {
    //	Determine whether this is a question, answer or comment, and act accordingly
    $options = array('blockwordspreg' => @$blockwordspreg, 'showurllinks' => $showurllinks);
    $time = null;
    $htmlcontent = null;
    if (isset($question['opostid'])) {
        $time = $question['otime'];
        if ($full) {
            $htmlcontent = qa_viewer_html($question['ocontent'], $question['oformat'], $options);
        }
    } elseif (isset($question['postid'])) {
        $time = $question['created'];
        if ($full) {
            $htmlcontent = qa_viewer_html($question['content'], $question['format'], $options);
Beispiel #27
0
function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    qa_redirect_raw(qa_path($request, $params, $rooturl, $neaturls, $anchor));
}
Beispiel #28
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()));
    }
}
 $feedisexample = false;
 switch ($optionname) {
     // special treatment for certain options
     case 'site_language':
         require_once QA_INCLUDE_DIR . 'qa-util-string.php';
         qa_optionfield_make_select($optionfield, qa_admin_language_options(), $value, '');
         $optionfield['suffix'] = strtr(qa_lang_html('admin/check_language_suffix'), array('^1' => '<a href="' . qa_html(qa_path_to_root() . 'qa-include/qa-check-lang.php') . '">', '^2' => '</a>'));
         if (!qa_has_multibyte()) {
             $optionfield['error'] = qa_lang_html('admin/no_multibyte');
         }
         break;
     case 'neat_urls':
         $neatoptions = array();
         $rawoptions = array(QA_URL_FORMAT_NEAT, QA_URL_FORMAT_INDEX, QA_URL_FORMAT_PARAM, QA_URL_FORMAT_PARAMS, QA_URL_FORMAT_SAFEST);
         foreach ($rawoptions as $rawoption) {
             $neatoptions[$rawoption] = '<iframe src="' . qa_path_html('url/test/' . QA_URL_TEST_STRING, array('dummy' => '', 'param' => QA_URL_TEST_STRING), null, $rawoption) . '" width="20" height="16" style="vertical-align:middle; border:0" scrolling="no" frameborder="0"></iframe>&nbsp;' . '<small>' . qa_html(urldecode(qa_path('123/why-do-birds-sing', null, '/', $rawoption))) . ($rawoption == QA_URL_FORMAT_NEAT ? strtr(qa_lang_html('admin/neat_urls_note'), array('^1' => '<a href="http://www.question2answer.org/htaccess.php" target="_blank">', '^2' => '</a>')) : '') . '</small>';
         }
         qa_optionfield_make_select($optionfield, $neatoptions, $value, QA_URL_FORMAT_SAFEST);
         $optionfield['type'] = 'select-radio';
         $optionfield['note'] = qa_lang_html_sub('admin/url_format_note', '<span style=" ' . qa_admin_url_test_html() . '/span>');
         break;
     case 'site_theme':
     case 'site_theme_mobile':
         $themeoptions = qa_admin_theme_options();
         if (!isset($themeoptions[$value])) {
             $value = 'Classic';
         }
         // check here because we also need $value for qa_admin_addon_metadata()
         qa_optionfield_make_select($optionfield, $themeoptions, $value, 'Classic');
         $contents = file_get_contents(QA_THEME_DIR . $value . '/qa-styles.css');
         $metadata = qa_admin_addon_metadata($contents, array('uri' => 'Theme URI', 'version' => 'Theme Version', 'date' => 'Theme Date', 'author' => 'Theme Author', 'author_uri' => 'Theme Author URI', 'license' => 'Theme License', 'update' => 'Theme Update Check URI'));
    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;
    }