コード例 #1
0
 /**
  * reCAPTCHA HTML - we actually return nothing because the new reCAPTCHA requires 'explicit rendering'
  * via JavaScript when we have multiple Captchas per page. It also auto-detects the user's language.
  */
 public function form_html(&$qa_content, $error)
 {
     $pub = qa_opt('recaptcha_public_key');
     // onload handler
     $qa_content['script_lines'][] = array('function recaptcha_load(elemId) {', '  if (grecaptcha) {', '    grecaptcha.render(elemId, {', '      "sitekey": ' . qa_js($pub), '    });', '  }', '}', 'function recaptcha_onload() {', '  recaptcha_load("qa_captcha_div_1");', '}');
     $qa_content['script_src'][] = 'https://www.google.com/recaptcha/api.js?onload=recaptcha_onload&render=explicit';
     return '';
 }
コード例 #2
0
 public function test__qa_js()
 {
     $this->assertSame("'test'", qa_js('test'));
     $this->assertSame("'test'", qa_js('test', true));
     $this->assertSame(123, qa_js(123));
     $this->assertSame("'123'", qa_js(123, true));
     $this->assertSame('true', qa_js(true));
     $this->assertSame("'true'", qa_js(true, true));
 }
コード例 #3
0
 function form_html(&$qa_content, $error)
 {
     require_once $this->directory . 'recaptchalib.php';
     $language = qa_opt('site_language');
     if (strpos('|en|nl|fr|de|pt|ru|es|tr|', '|' . $language . '|') === false) {
         // supported as of 3/2010
         $language = 'en';
     }
     $qa_content['script_lines'][] = array("var RecaptchaOptions={", "\ttheme:'white',", "\tlang:" . qa_js($language), "};");
     return recaptcha_get_html(qa_opt('recaptcha_public_key'), $error, qa_is_https_probably());
 }
コード例 #4
0
function qa_set_up_captcha_field(&$qa_content, &$fields, $errors, $note = null)
{
    if (qa_captcha_possible()) {
        $fields['captcha'] = array('type' => 'custom', 'label' => qa_lang_html('misc/captcha_label'), 'html' => qa_captcha_html(@$errors['captcha']), 'error' => isset($errors['captcha']) ? qa_lang_html('misc/captcha_error') : null, 'note' => $note);
        $language = qa_opt('site_language');
        if (strpos('|en|nl|fr|de|pt|ru|es|tr|', '|' . $language . '|') === false) {
            // supported as of 3/2010
            $language = 'en';
        }
        $qa_content['script_lines'][] = array("var RecaptchaOptions = {", "\ttheme:'white',", "\tlang:" . qa_js($language), "}");
    }
}
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: qa-basic-adsense.php プロジェクト: swuit/swuit-q2a
    public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
    {
        $divstyle = '';
        switch ($region) {
            case 'full':
                // Leaderboard
                $divstyle = 'width:728px; margin:0 auto;';
                // fall-through
            // fall-through
            case 'main':
                // Leaderboard
                $width = 728;
                $height = 90;
                $format = '728x90_as';
                break;
            case 'side':
                // Wide skyscraper
                $width = 160;
                $height = 600;
                $format = '160x600_as';
                break;
        }
        ?>
<div style="<?php 
        echo $divstyle;
        ?>
">
	<script type="text/javascript">
	google_ad_client = <?php 
        echo qa_js(qa_opt('adsense_publisher_id'));
        ?>
;
	google_ad_width = <?php 
        echo qa_js($width);
        ?>
;
	google_ad_height = <?php 
        echo qa_js($height);
        ?>
;
	google_ad_format = <?php 
        echo qa_js($format);
        ?>
;
	google_ad_type = "text_image";
	google_ad_channel = "";
	</script>
	<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</div>
<?php 
    }
コード例 #7
0
    function facebook_html($tourl, $logout, $context)
    {
        if ($context == 'login' || $context == 'register') {
            $size = 'large';
        } else {
            $size = 'medium';
        }
        ?>
      <div id="fb-root" style="display:inline;"></div>
      <script>
        window.fbAsyncInit = function() {
          FB.init({
            appId      : <?php 
        echo qa_js(qa_opt('facebook_app_id'), true);
        ?>
,
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true
          });

         FB.Event.subscribe('<?php 
        echo $logout ? 'auth.logout' : 'auth.login';
        ?>
', function(response) {
           setTimeout("window.location=<?php 
        echo qa_js($tourl);
        ?>
", 100);
         });
        };
        (function(d){
           var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
           js = d.createElement('script'); js.id = id; js.async = true;
           js.src = "//connect.facebook.net/en_US/all.js";
           d.getElementsByTagName('head')[0].appendChild(js);
         }(document));
      </script>
      <div class="fb-login-button" style="display:inline; vertical-align:middle;" size="<?php 
        echo $size;
        ?>
" <?php 
        echo $logout ? 'autologoutlink="true"' : 'scope="email,user_about_me,user_location,user_website"';
        ?>
>
      </div>

<?php 
    }
コード例 #8
0
ファイル: BaseTest.php プロジェクト: swuit/swuit-q2a
 public function test__qa_js()
 {
     $test = qa_js('test');
     $this->assertSame("'test'", $test);
     $test = qa_js('test', true);
     $this->assertSame("'test'", $test);
     $test = qa_js(123);
     $this->assertSame(123, $test);
     $test = qa_js(123, true);
     $this->assertSame("'123'", $test);
     $test = qa_js(true);
     $this->assertSame('true', $test);
     $test = qa_js(true, true);
     $this->assertSame("'true'", $test);
 }
コード例 #9
0
ファイル: BaseTest.php プロジェクト: GitFuture/bmf
 public function test__qa_js()
 {
     $test = qa_js('test');
     $this->assertEquals($test, "'test'");
     $test = qa_js('test', true);
     $this->assertEquals($test, "'test'");
     $test = qa_js(123);
     $this->assertEquals($test, 123);
     $test = qa_js(123, true);
     $this->assertEquals($test, "'123'");
     $test = qa_js(true);
     $this->assertEquals($test, 'true');
     $test = qa_js(true, true);
     $this->assertEquals($test, "'true'");
 }
コード例 #10
0
 function process_request($request)
 {
     $message = '';
     $url = '';
     if (is_array($_FILES) && count($_FILES)) {
         if (!qa_opt('wysiwyg_editor_upload_images')) {
             $message = qa_lang('users/no_permission');
         }
         require_once QA_INCLUDE_DIR . 'qa-app-upload.php';
         $upload = qa_upload_file_one(qa_opt('wysiwyg_editor_upload_max_size'), qa_get('qa_only_image') || !qa_opt('wysiwyg_editor_upload_all'), qa_get('qa_only_image') ? 600 : null, null);
         $message = @$upload['error'];
         $url = @$upload['bloburl'];
     }
     echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(" . qa_js(qa_get('CKEditorFuncNum')) . ", " . qa_js($url) . ", " . qa_js($message) . ");</script>";
     return null;
 }
コード例 #11
0
ファイル: qa-sig-layer.php プロジェクト: NoahY/q2a-signatures
 function doctype()
 {
     if ($this->request == 'admin/permissions' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'signature_allow';
         $permits[] = 'signature_edit_allow';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('signature_plugin/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'value' => $value, 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . '&nbsp;', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     if (qa_opt('signatures_enable')) {
         // add user signature
         if ($this->template == 'user' && isset($this->content['form_activity']) && !qa_get('tab')) {
             $sig_form = $this->content['user_signature_form'];
             // from overrides
             // insert our form
             if (isset($this->content['q_list'])) {
                 // array splicing kungfu thanks to Stack Exchange
                 // This adds form-signature before q_list
                 $keys = array_keys($this->content);
                 $vals = array_values($this->content);
                 $insertBefore = array_search('q_list', $keys);
                 $keys2 = array_splice($keys, $insertBefore);
                 $vals2 = array_splice($vals, $insertBefore);
                 $keys[] = 'form-signature';
                 $vals[] = $sig_form;
                 $this->content = array_merge(array_combine($keys, $vals), array_combine($keys2, $vals2));
             } else {
                 $this->content['form-signature'] = $sig_form;
             }
         }
     }
     qa_html_theme_base::doctype();
 }
コード例 #12
0
ファイル: qa-rpc-layer.php プロジェクト: swuit/swuit-q2a
 function doctype()
 {
     if ($this->request == 'admin/permissions' && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
         $permits[] = 'xmlrpc_access';
         foreach ($permits as $optionname) {
             $value = qa_opt($optionname);
             $optionfield = array('id' => $optionname, 'label' => qa_lang_html('xmlrpc/' . $optionname) . ':', 'tags' => 'NAME="option_' . $optionname . '" ID="option_' . $optionname . '"', 'value' => $value, 'error' => qa_html(@$errors[$optionname]));
             $widest = QA_PERMIT_USERS;
             $narrowest = QA_PERMIT_ADMINS;
             $permitoptions = qa_admin_permit_options($widest, $narrowest, !QA_FINAL_EXTERNAL_USERS && qa_opt('confirm_user_emails'));
             if (count($permitoptions) > 1) {
                 qa_optionfield_make_select($optionfield, $permitoptions, $value, $value == QA_PERMIT_CONFIRMED ? QA_PERMIT_USERS : min(array_keys($permitoptions)));
             }
             $this->content['form']['fields'][$optionname] = $optionfield;
             $this->content['form']['fields'][$optionname . '_points'] = array('id' => $optionname . '_points', 'tags' => 'NAME="option_' . $optionname . '_points" ID="option_' . $optionname . '_points"', 'type' => 'number', 'value' => qa_opt($optionname . '_points'), 'prefix' => qa_lang_html('admin/users_must_have') . '&nbsp;', 'note' => qa_lang_html('admin/points'));
             $checkboxtodisplay[$optionname . '_points'] = '(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS) . ') ||(option_' . $optionname . '==' . qa_js(QA_PERMIT_POINTS_CONFIRMED) . ')';
         }
         qa_set_display_rules($this->content, $checkboxtodisplay);
     }
     qa_html_theme_base::doctype();
 }
コード例 #13
0
$qa_content['error'] = qa_admin_page_error();
$qa_content['form'] = array('style' => 'wide', 'fields' => array('q2a_version' => array('label' => qa_lang_html('admin/q2a_version'), 'value' => qa_html(QA_VERSION)), 'q2a_date' => array('label' => qa_lang_html('admin/q2a_build_date'), 'value' => qa_html(QA_BUILD_DATE)), 'q2a_latest' => array('label' => qa_lang_html('admin/q2a_latest_version'), 'type' => 'custom', 'html' => '<iframe src="http://www.question2answer.org/question2answer-latest.php?version=' . urlencode(QA_VERSION) . '&language=' . urlencode(qa_opt('site_language')) . '" width="100" height="16" style="vertical-align:middle; border:0; background:transparent;" allowTransparency="true" scrolling="no" frameborder="0"></iframe>'), 'break0' => array('type' => 'blank'), 'db_version' => array('label' => qa_lang_html('admin/q2a_db_version'), 'value' => qa_html(qa_opt('db_version'))), 'db_size' => array('label' => qa_lang_html('admin/q2a_db_size'), 'value' => qa_html(number_format(qa_db_table_size() / 1048576, 1) . ' MB')), 'break1' => array('type' => 'blank'), 'php_version' => array('label' => qa_lang_html('admin/php_version'), 'value' => qa_html(phpversion())), 'mysql_version' => array('label' => qa_lang_html('admin/mysql_version'), 'value' => qa_html(qa_db_mysql_version())), 'break2' => array('type' => 'blank'), 'qcount' => array('label' => qa_lang_html('admin/total_qs'), 'value' => qa_html(number_format($qcount))), 'qcount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($qcount - $qcount_anon))), 'qcount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($qcount_anon))), 'break3' => array('type' => 'blank'), 'acount' => array('label' => qa_lang_html('admin/total_as'), 'value' => qa_html(number_format($acount))), 'acount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($acount - $acount_anon))), 'acount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($acount_anon))), 'break4' => array('type' => 'blank'), 'ccount' => array('label' => qa_lang_html('admin/total_cs'), 'value' => qa_html(number_format($ccount))), 'ccount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($ccount - $ccount_anon))), 'ccount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($ccount_anon))), 'break5' => array('type' => 'blank'), 'users' => array('label' => qa_lang_html('admin/users_registered'), 'value' => QA_FINAL_EXTERNAL_USERS ? '' : qa_html(number_format(qa_db_count_users()))), 'users_active' => array('label' => qa_lang_html('admin/users_active'), 'value' => qa_html(number_format((int) qa_opt('cache_userpointscount')))), 'users_posted' => array('label' => qa_lang_html('admin/users_posted'), 'value' => qa_html(number_format(qa_db_count_active_users('posts')))), 'users_voted' => array('label' => qa_lang_html('admin/users_voted'), 'value' => qa_html(number_format(qa_db_count_active_users('uservotes'))))));
if (QA_FINAL_EXTERNAL_USERS) {
    unset($qa_content['form']['fields']['users']);
} else {
    unset($qa_content['form']['fields']['users_active']);
}
foreach ($qa_content['form']['fields'] as $index => $field) {
    if (empty($field['type'])) {
        $qa_content['form']['fields'][$index]['type'] = 'static';
    }
}
$qa_content['form_2'] = array('tags' => 'method="post" action="' . qa_path_html('admin/recalc') . '"', 'title' => qa_lang_html('admin/database_cleanup'), 'style' => 'basic', 'buttons' => array('recount_posts' => array('label' => qa_lang_html('admin/recount_posts'), 'tags' => 'name="dorecountposts" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recount_posts_stop')) . ', \'recount_posts_note\');"', 'note' => '<span id="recount_posts_note">' . qa_lang_html('admin/recount_posts_note') . '</span>'), 'reindex_content' => array('label' => qa_lang_html('admin/reindex_content'), 'tags' => 'name="doreindexcontent" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/reindex_content_stop')) . ', \'reindex_content_note\');"', 'note' => '<span id="reindex_content_note">' . qa_lang_html('admin/reindex_content_note') . '</span>'), 'recalc_points' => array('label' => qa_lang_html('admin/recalc_points'), 'tags' => 'name="dorecalcpoints" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'recalc_points_note\');"', 'note' => '<span id="recalc_points_note">' . qa_lang_html('admin/recalc_points_note') . '</span>'), 'refill_events' => array('label' => qa_lang_html('admin/refill_events'), 'tags' => 'name="dorefillevents" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'refill_events_note\');"', 'note' => '<span id="refill_events_note">' . qa_lang_html('admin/refill_events_note') . '</span>'), 'recalc_categories' => array('label' => qa_lang_html('admin/recalc_categories'), 'tags' => 'name="dorecalccategories" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'recalc_categories_note\');"', 'note' => '<span id="recalc_categories_note">' . qa_lang_html('admin/recalc_categories_note') . '</span>'), 'delete_hidden' => array('label' => qa_lang_html('admin/delete_hidden'), 'tags' => 'name="dodeletehidden" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/delete_stop')) . ', \'delete_hidden_note\');"', 'note' => '<span id="delete_hidden_note">' . qa_lang_html('admin/delete_hidden_note') . '</span>')), 'hidden' => array('code' => qa_get_form_security_code('admin/recalc')));
if (!qa_using_categories()) {
    unset($qa_content['form_2']['buttons']['recalc_categories']);
}
if (defined('QA_BLOBS_DIRECTORY')) {
    if (qa_db_has_blobs_in_db()) {
        $qa_content['form_2']['buttons']['blobs_to_disk'] = array('label' => qa_lang_html('admin/blobs_to_disk'), 'tags' => 'name="doblobstodisk" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/blobs_stop')) . ', \'blobs_to_disk_note\');"', 'note' => '<span id="blobs_to_disk_note">' . qa_lang_html('admin/blobs_to_disk_note') . '</span>');
    }
    if (qa_db_has_blobs_on_disk()) {
        $qa_content['form_2']['buttons']['blobs_to_db'] = array('label' => qa_lang_html('admin/blobs_to_db'), 'tags' => 'name="doblobstodb" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/blobs_stop')) . ', \'blobs_to_db_note\');"', 'note' => '<span id="blobs_to_db_note">' . qa_lang_html('admin/blobs_to_db_note') . '</span>');
    }
}
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
コード例 #14
0
ファイル: messages.php プロジェクト: swuit/swuit-q2a
}
if (!qa_opt('allow_private_messages') || !qa_opt('show_message_history')) {
    return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
//	Find the messages for this user
$start = qa_get_start();
$pagesize = qa_opt('page_size_pms');
// get number of messages then actual messages for this page
$func = $showOutbox ? 'qa_db_messages_outbox_selectspec' : 'qa_db_messages_inbox_selectspec';
$pmSpecCount = qa_db_selectspec_count($func('private', $loginUserId, true));
$pmSpec = $func('private', $loginUserId, true, $start, $pagesize);
list($numMessages, $userMessages) = qa_db_select_with_pending($pmSpecCount, $pmSpec);
$count = $numMessages['count'];
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html($showOutbox ? 'misc/pm_outbox_title' : 'misc/pm_inbox_title');
$qa_content['script_rel'][] = 'qa-content/qa-user.js?' . QA_VERSION;
$qa_content['message_list'] = array('tags' => 'id="privatemessages"', 'messages' => array(), 'form' => array('tags' => 'name="pmessage" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'hidden' => array('qa_click' => '', 'handle' => qa_html($loginUserHandle), 'start' => qa_html($start), 'code' => qa_get_form_security_code('pm-' . $loginUserHandle))));
$htmlDefaults = qa_message_html_defaults();
if ($showOutbox) {
    $htmlDefaults['towhomview'] = true;
}
foreach ($userMessages as $message) {
    $msgFormat = qa_message_html_fields($message, $htmlDefaults);
    $replyHandle = $showOutbox ? $message['tohandle'] : $message['fromhandle'];
    $msgFormat['form'] = array('style' => 'light', 'buttons' => array('reply' => array('tags' => 'onclick="window.location.href=\'' . qa_path_html('message/' . $replyHandle) . '\';return false"', 'label' => qa_lang_html('question/reply_button')), 'delete' => array('tags' => 'name="m' . qa_html($message['messageid']) . '_dodelete" onclick="return qa_pm_click(' . qa_js($message['messageid']) . ', this, ' . qa_js($showOutbox ? 'outbox' : 'inbox') . ');"', 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('profile/delete_pm_popup'))));
    $qa_content['message_list']['messages'][] = $msgFormat;
}
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_messages_sub_navigation($showOutbox ? 'outbox' : 'inbox');
return $qa_content;
コード例 #15
0
ファイル: qa-page.php プロジェクト: TheProjecter/microprobe
 }
 //	Combine various Javascript elements in $qa_content into single array for theme layer
 $script = array('<SCRIPT TYPE="text/javascript"><!--');
 if (isset($qa_content['script_var'])) {
     foreach ($qa_content['script_var'] as $var => $value) {
         $script[] = 'var ' . $var . '=' . qa_js($value) . ';';
     }
 }
 if (isset($qa_content['script_lines'])) {
     foreach ($qa_content['script_lines'] as $scriptlines) {
         $script[] = '';
         $script = array_merge($script, $scriptlines);
     }
 }
 if (isset($qa_content['focusid'])) {
     $qa_content['script_onloads'][] = array("var elem=document.getElementById(" . qa_js($qa_content['focusid']) . ");", "if (elem) {", "\telem.select();", "\telem.focus();", "}");
 }
 if (isset($qa_content['script_onloads'])) {
     array_push($script, '', 'var qa_oldonload=window.onload;', 'window.onload=function() {', "\tif (typeof qa_oldonload=='function')", "\t\tqa_oldonload();");
     foreach ($qa_content['script_onloads'] as $scriptonload) {
         $script[] = "\t";
         foreach ((array) $scriptonload as $scriptline) {
             $script[] = "\t" . $scriptline;
         }
     }
     $script[] = '}';
 }
 $script[] = '//--></SCRIPT>';
 if (isset($qa_content['script_rel'])) {
     $uniquerel = array_unique($qa_content['script_rel']);
     // remove any duplicates
コード例 #16
0
 if (strlen(@$metadata['version'])) {
     $namehtml .= ' v' . qa_html($metadata['version']);
 }
 if (strlen(@$metadata['author'])) {
     $authorhtml = qa_html($metadata['author']);
     if (strlen(@$metadata['author_uri'])) {
         $authorhtml = '<a href="' . qa_html($metadata['author_uri']) . '">' . $authorhtml . '</a>';
     }
     $authorhtml = qa_lang_html_sub('main/by_x', $authorhtml);
 } else {
     $authorhtml = '';
 }
 if (strlen(@$metadata['version']) && strlen(@$metadata['update'])) {
     $elementid = 'version_check_' . md5($plugindirectory);
     $updatehtml = '(<span id="' . $elementid . '">...</span>)';
     $qa_content['script_onloads'][] = array("qa_version_check(" . qa_js($metadata['update']) . ", 'Plugin Version', " . qa_js($metadata['version'], true) . ", 'Plugin URI', " . qa_js($elementid) . ");");
 } else {
     $updatehtml = '';
 }
 if (strlen(@$metadata['description'])) {
     $deschtml = qa_html($metadata['description']);
 } else {
     $deschtml = '';
 }
 if (isset($pluginoptionmodules[$plugindirectory]) && !$showthisform) {
     $deschtml .= (strlen($deschtml) ? ' - ' : '') . '<a href="' . qa_admin_plugin_options_path($plugindirectory) . '">' . qa_lang_html('admin/options') . '</a>';
 }
 $pluginhtml = $namehtml . ' ' . $authorhtml . ' ' . $updatehtml . '<br>' . $deschtml . (strlen($deschtml) ? '<br>' : '') . '<small style="color:#666">' . qa_html($plugindirectory) . '</small>';
 if (qa_qa_version_below(@$metadata['min_q2a'])) {
     $pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' . qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])) . '</span>';
 } elseif (qa_php_version_below(@$metadata['min_php'])) {
コード例 #17
0
function qa_page_q_add_c_form(&$qa_content, $questionid, $parentid, $formid, $usecaptcha, $in, $errors, $loadfocusnow)
{
    switch (qa_user_permit_error('permit_post_c')) {
        case 'login':
            $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request()));
            break;
        case 'confirm':
            $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request()));
            break;
        case 'limit':
            $form = array('title' => qa_lang_html('question/comment_limit'));
            break;
        default:
            $form = array('title' => qa_lang_html('users/no_permission'));
            break;
        case false:
            $prefix = 'c' . $parentid . '_';
            $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs');
            $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname);
            if (method_exists($editor, 'update_script')) {
                $updatescript = $editor->update_script($prefix . 'content');
            } else {
                $updatescript = '';
            }
            $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : '';
            $form = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '" NAME="c_form_' . qa_html($parentid) . '"', 'title' => qa_lang_html($questionid == $parentid ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onClick="' . $updatescript . ' return qa_submit_comment(' . qa_js($questionid) . ', ' . qa_js($parentid) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1'));
            if (!strlen($custom)) {
                unset($form['fields']['custom']);
            }
            qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix);
            $onloads = array();
            if ($usecaptcha) {
                $userid = qa_get_logged_in_userid();
                $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_insert_login_links(qa_lang_html(isset($userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix')));
                if (strlen($captchaloadscript)) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' }';
                }
            }
            if (!$loadfocusnow) {
                if (method_exists($editor, 'load_script')) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' }';
                }
                if (method_exists($editor, 'focus_script')) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' }';
                }
                $form['buttons']['cancel']['tags'] .= ' onClick="return qa_toggle_element()"';
            }
            if (count($onloads)) {
                $qa_content['script_onloads'][] = $onloads;
            }
    }
    $form['id'] = $formid;
    $form['collapse'] = !$loadfocusnow;
    $form['style'] = 'tall';
    return $form;
}
コード例 #18
0
ファイル: question-view.php プロジェクト: swuit/swuit-q2a
function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow)
{
    // The 'approve', 'login', 'confirm', 'userblock', 'ipblock' permission errors are reported to the user here
    // The other option ('level') prevents the comment button being shown, in qa_page_q_post_rules(...)
    switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) {
        case 'login':
            $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request()));
            break;
        case 'confirm':
            $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request()));
            break;
        case 'approve':
            $form = array('title' => qa_lang_html('question/comment_must_be_approved'));
            break;
        case 'limit':
            $form = array('title' => qa_lang_html('question/comment_limit'));
            break;
        default:
            $form = array('title' => qa_lang_html('users/no_permission'));
            break;
        case false:
            $prefix = 'c' . $parent['postid'] . '_';
            $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs');
            $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname);
            if (method_exists($editor, 'update_script')) {
                $updatescript = $editor->update_script($prefix . 'content');
            } else {
                $updatescript = '';
            }
            $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : '';
            $form = array('tags' => 'method="post" action="' . qa_self_html() . '" name="c_form_' . qa_html($parent['postid']) . '"', 'title' => qa_lang_html($question['postid'] == $parent['postid'] ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onclick="' . $updatescript . ' return qa_submit_comment(' . qa_js($question['postid']) . ', ' . qa_js($parent['postid']) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1', $prefix . 'code' => qa_get_form_security_code('comment-' . $parent['postid'])));
            if (!strlen($custom)) {
                unset($form['fields']['custom']);
            }
            if (!qa_is_logged_in()) {
                qa_set_up_name_field($qa_content, $form['fields'], @$in['name'], $prefix);
            }
            qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix);
            $onloads = array();
            if ($captchareason) {
                $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_captcha_reason_note($captchareason));
                if (strlen($captchaloadscript)) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' };';
                }
            }
            if (!$loadfocusnow) {
                if (method_exists($editor, 'load_script')) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' };';
                }
                if (method_exists($editor, 'focus_script')) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' };';
                }
                $form['buttons']['cancel']['tags'] .= ' onclick="return qa_toggle_element()"';
            }
            if (count($onloads)) {
                $qa_content['script_onloads'][] = $onloads;
            }
    }
    $form['id'] = $formid;
    $form['collapse'] = !$loadfocusnow;
    $form['style'] = 'tall';
    return $form;
}
コード例 #19
0
ファイル: format.php プロジェクト: amiyasahu/question2answer
function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategories, $categoryid, $allownone, $allownosub, $maxdepth = null, $excludecategoryid = null)
{
    $pathcategories = qa_category_path($navcategories, $categoryid);
    $startpath = '';
    foreach ($pathcategories as $category) {
        $startpath .= '/' . $category['categoryid'];
    }
    if (isset($maxdepth)) {
        $maxdepth = min(QA_CATEGORY_DEPTH, $maxdepth);
    } else {
        $maxdepth = QA_CATEGORY_DEPTH;
    }
    $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION;
    $qa_content['script_onloads'][] = sprintf('qa_category_select(%s, %s);', qa_js($fieldname), qa_js($startpath));
    $qa_content['script_var']['qa_cat_exclude'] = $excludecategoryid;
    $qa_content['script_var']['qa_cat_allownone'] = (int) $allownone;
    $qa_content['script_var']['qa_cat_allownosub'] = (int) $allownosub;
    $qa_content['script_var']['qa_cat_maxdepth'] = $maxdepth;
    $field['type'] = 'select';
    $field['tags'] = sprintf('name="%s_0" id="%s_0" onchange="qa_category_select(%s);"', $fieldname, $fieldname, qa_js($fieldname));
    $field['options'] = array();
    // create the menu that will be shown if Javascript is disabled
    if ($allownone) {
        $field['options'][''] = qa_lang_html('main/no_category');
    }
    // this is also copied to first menu created by Javascript
    $keycategoryids = array();
    if ($allownosub) {
        $category = @$navcategories[$categoryid];
        $upcategory = @$navcategories[$category['parentid']];
        // first get supercategories
        while (isset($upcategory)) {
            $keycategoryids[$upcategory['categoryid']] = true;
            $upcategory = @$navcategories[$upcategory['parentid']];
        }
        $keycategoryids = array_reverse($keycategoryids, true);
        $depth = count($keycategoryids);
        // number of levels above
        if (isset($category)) {
            $depth++;
            // to count category itself
            foreach ($navcategories as $navcategory) {
                // now get siblings and self
                if (!strcmp($navcategory['parentid'], $category['parentid'])) {
                    $keycategoryids[$navcategory['categoryid']] = true;
                }
            }
        }
        if ($depth < $maxdepth) {
            foreach ($navcategories as $navcategory) {
                // now get children, if not too deep
                if (!strcmp($navcategory['parentid'], $categoryid)) {
                    $keycategoryids[$navcategory['categoryid']] = true;
                }
            }
        }
    } else {
        $haschildren = false;
        foreach ($navcategories as $navcategory) {
            // check if it has any children
            if (!strcmp($navcategory['parentid'], $categoryid)) {
                $haschildren = true;
                break;
            }
        }
        if (!$haschildren) {
            $keycategoryids[$categoryid] = true;
        }
        // show this category if it has no children
    }
    foreach ($keycategoryids as $keycategoryid => $dummy) {
        if (strcmp($keycategoryid, $excludecategoryid)) {
            $field['options'][$keycategoryid] = qa_category_path_html($navcategories, $keycategoryid);
        }
    }
    $field['value'] = @$field['options'][$categoryid];
    $field['note'] = '<div id="' . $fieldname . '_note">' . '<noscript style="color:red;">' . qa_lang_html('question/category_js_note') . '</noscript>' . '</div>';
}
コード例 #20
0
 function load_script($fieldname)
 {
     return "if (qa_ckeditor_" . $fieldname . "=CKEDITOR.replace(" . qa_js($fieldname) . ", window.qa_wysiwyg_editor_config)) { qa_ckeditor_" . $fieldname . ".setData(document.getElementById(" . qa_js($fieldname . '_ckeditor_data') . ").value); document.getElementById(" . qa_js($fieldname . '_ckeditor_ok') . ").value=1; }";
 }
コード例 #21
0
    function logout_html($tourl)
    {
        $app_id = qa_opt('facebook_app_id');
        if (!strlen($app_id)) {
            return;
        }
        if (isset($_COOKIE['fbs_' . $app_id])) {
            // check we still have a Facebook cookie ...
            ?>
		
<span id="fb-root"></span>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
	FB.init({appId: <?php 
            echo qa_js($app_id);
            ?>
, status: true, cookie: true, xfbml: true});
	FB.Event.subscribe('auth.sessionChange', function(response) {
		window.location=<?php 
            echo qa_js($tourl);
            ?>
;
	});
</script>
<fb:login-button autologoutlink="true"></fb:login-button>
<?php 
        } else {
            // ... if not, show a standard logout link, since sometimes the redirect to Q2A's logout page doesn't complete
            echo '<A HREF="' . qa_html($tourl) . '">' . qa_lang_html('main/nav_logout') . '</A>';
        }
    }
コード例 #22
0
ファイル: qa-plugin.php プロジェクト: rahularyan/dude-theme
function ra_installed_plugin()
{
    $tables = qa_db_list_tables_lc();
    $moduletypes = qa_list_module_types();
    $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php');
    foreach ($moduletypes as $type) {
        $modules = qa_load_modules_with($type, 'init_queries');
        foreach ($modules as $name => $module) {
            $queries = $module->init_queries($tables);
            if (!empty($queries)) {
                if (qa_is_http_post()) {
                    qa_redirect('install');
                } else {
                    $qa_content['error'] = strtr(qa_lang_html('admin/module_x_database_init'), array('^1' => qa_html($name), '^2' => qa_html($type), '^3' => '<a href="' . qa_path_html('install') . '">', '^4' => '</a>'));
                }
            }
        }
    }
    if (qa_is_http_post() && !qa_check_form_security_code('admin/plugins', qa_post_text('qa_form_security_code'))) {
        $qa_content['error'] = qa_lang_html('misc/form_security_reload');
        $showpluginforms = false;
    } else {
        $showpluginforms = true;
    }
    $plugin = array();
    if (count($pluginfiles)) {
        foreach ($pluginfiles as $pluginindex => $pluginfile) {
            $plugindirectory = dirname($pluginfile) . '/';
            $hash = qa_admin_plugin_directory_hash($plugindirectory);
            $showthisform = $showpluginforms && qa_get('show') == $hash;
            $contents = file_get_contents($pluginfile);
            $metadata = qa_admin_addon_metadata($contents, array('name' => 'Plugin Name', 'uri' => 'Plugin URI', 'description' => 'Plugin Description', 'version' => 'Plugin Version', 'date' => 'Plugin Date', 'author' => 'Plugin Author', 'author_uri' => 'Plugin Author URI', 'license' => 'Plugin License', 'min_q2a' => 'Plugin Minimum Question2Answer Version', 'min_php' => 'Plugin Minimum PHP Version', 'update' => 'Plugin Update Check URI'));
            if (strlen(@$metadata['name'])) {
                $namehtml = qa_html($metadata['name']);
            } else {
                $namehtml = qa_lang_html('admin/unnamed_plugin');
            }
            $plugin_name = $namehtml;
            if (strlen(@$metadata['uri'])) {
                $plugin_uri = qa_html($metadata['uri']);
            }
            if (strlen(@$metadata['version'])) {
                $plugin_version = qa_html($metadata['version']);
            }
            if (strlen(@$metadata['author'])) {
                $plugin_author = qa_html($metadata['author']);
                if (strlen(@$metadata['author_uri'])) {
                    $plugin_author_url = qa_html($metadata['author_uri']);
                }
            }
            if (strlen(@$metadata['version']) && strlen(@$metadata['update'])) {
                $elementid = 'version_check_' . md5($plugindirectory);
                $plugin_update = '(<span id="' . $elementid . '"></span>)';
                $qa_content['script_onloads'][] = array("qa_version_check(" . qa_js($metadata['update']) . ", 'Plugin Version', " . qa_js($metadata['version'], true) . ", 'Plugin URI', " . qa_js($elementid) . ");");
            }
            if (strlen(@$metadata['description'])) {
                $plugin_description = qa_html($metadata['description']);
            }
            //if (isset($pluginoptionmodules[$plugindirectory]))
            $plugin_option = qa_admin_plugin_options_path($plugindirectory);
            if (qa_qa_version_below(@$metadata['min_q2a'])) {
                $plugin_error = qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a']));
            } elseif (qa_php_version_below(@$metadata['min_php'])) {
                $plugin_error = qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php']));
            }
            $plugin[] = array('tags' => 'id="' . qa_html($hash) . '"', 'name' => @$plugin_name, 'uri' => @$plugin_uri, 'version' => @$plugin_version, 'author' => @$plugin_author, 'author_url' => @$plugin_author_url, 'update' => @$plugin_update, 'description' => @$plugin_description, 'path' => @$plugindirectory, 'option' => @$plugin_option, 'error' => @$plugin_error, 'fields' => array(array('type' => 'custom')));
        }
    }
    return $plugin;
}
コード例 #23
0
}
if ($question['basetype'] == 'Q') {
    $qa_content['a_list']['title_tags'] = 'id="a_list_title"';
    if ($countfortitle > 0) {
        $split = $countfortitle == 1 ? qa_lang_html_sub_split('question/1_answer_title', '1', '1') : qa_lang_html_sub_split('question/x_answers_title', $countfortitle);
        if ($microdata) {
            $split['data'] = '<span itemprop="answerCount">' . $split['data'] . '</span>';
        }
        $qa_content['a_list']['title'] = $split['prefix'] . $split['data'] . $split['suffix'];
    } else {
        $qa_content['a_list']['title_tags'] .= ' style="display:none;" ';
    }
}
if (!$formrequested) {
    $qa_content['page_links'] = qa_html_page_links(qa_request(), $pagestart, $pagesize, $countforpages, qa_opt('pages_prev_next'), array(), false, 'a_list_title');
}
//	Some generally useful stuff
if (qa_using_categories() && count($categories)) {
    $qa_content['navigation']['cat'] = qa_category_navigation($categories, $question['categoryid']);
}
if (isset($jumptoanchor)) {
    $qa_content['script_onloads'][] = array('qa_scroll_page_to($("#"+' . qa_js($jumptoanchor) . ').offset().top);');
}
//	Determine whether this request should be counted for page view statistics
if (qa_opt('do_count_q_views') && !$formrequested && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $userid || !isset($question['userid'])) && ($question['cookieid'] != $cookieid || !isset($question['cookieid'])))) {
    $qa_content['inc_views_postid'] = $questionid;
}
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
コード例 #24
0
    foreach ($relatedquestions as $key => $related) {
        if ($related['postid'] == $questionid || $related['score'] < $minscore) {
            // related questions will include itself so remove that
            unset($relatedquestions[$key]);
        }
    }
    if (count($relatedquestions)) {
        $qa_content['q_list']['title'] = qa_lang('main/related_qs_title');
    } else {
        $qa_content['q_list']['title'] = qa_lang('main/no_related_qs_title');
    }
    $qa_content['q_list']['qs'] = array();
    foreach ($relatedquestions as $related) {
        $qa_content['q_list']['qs'][] = qa_post_html_fields($related, $qa_login_userid, $qa_cookieid, $usershtml, null, qa_post_html_defaults('Q'));
    }
}
//	Some generally useful stuff
if (qa_using_categories() && count($categories)) {
    $qa_content['navigation']['cat'] = qa_category_navigation($categories, $question['categoryid']);
}
if (isset($jumptoanchor)) {
    $qa_content['script_onloads'][] = array("window.location.hash=" . qa_js($jumptoanchor) . ";");
}
if (isset($focusonid)) {
    $qa_content['script_onloads'][] = array("document.getElementById(" . qa_js($focusonid) . ").focus();");
}
//	Determine whether the page view should be counted
if (qa_opt('do_count_q_views') && !$formrequested && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $qa_login_userid || !isset($question['userid'])) && ($question['cookieid'] != $qa_cookieid || !isset($question['cookieid'])))) {
    $qa_content['inc_views_postid'] = $questionid;
}
$this->content = $qa_content;
コード例 #25
0
ファイル: qa-wysiwyg-upload.php プロジェクト: ramo01/1kapp
 function process_request($request)
 {
     $message = '';
     $url = '';
     if (is_array($_FILES) && count($_FILES)) {
         //	Check that we're allowed to upload images (if not, no other uploads are allowed either)
         if (!qa_opt('wysiwyg_editor_upload_images')) {
             $message = qa_lang('users/no_permission');
         }
         //	Check that we haven't reached the upload limit and are not blocked
         if (empty($message)) {
             require_once QA_INCLUDE_DIR . 'qa-app-users.php';
             require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
             switch (qa_user_permit_error(null, QA_LIMIT_UPLOADS)) {
                 case 'limit':
                     $message = qa_lang('main/upload_limit');
                     break;
                 case false:
                     qa_limits_increment(qa_get_logged_in_userid(), QA_LIMIT_UPLOADS);
                     break;
                 default:
                     $message = qa_lang('users/no_permission');
                     break;
             }
         }
         //	Find out some information about the uploaded file and check it's not too large
         if (empty($message)) {
             require_once QA_INCLUDE_DIR . 'qa-app-blobs.php';
             $file = reset($_FILES);
             $pathinfo = pathinfo($file['name']);
             $extension = strtolower(@$pathinfo['extension']);
             $filesize = $file['size'];
             $maxsize = min(qa_opt('wysiwyg_editor_upload_max_size'), qa_get_max_upload_size());
             if ($filesize <= 0 || $filesize > $maxsize) {
                 // if file was too big for PHP, $filesize will be zero
                 $message = qa_lang_sub('main/max_upload_size_x', number_format($maxsize / 1048576, 1) . 'MB');
             }
         }
         //	If it's only allowed to be an image, check it's an image
         if (empty($message)) {
             if (qa_get('qa_only_image') || !qa_opt('wysiwyg_editor_upload_all')) {
                 // check if we need to confirm it's an image
                 switch ($extension) {
                     case 'png':
                         // these are allowed image extensions
                     // these are allowed image extensions
                     case 'gif':
                     case 'jpeg':
                     case 'jpg':
                         if (function_exists('getimagesize')) {
                             // getimagesize() does not require GD library
                             if (!is_array(@getimagesize($file['tmp_name']))) {
                                 $message = qa_lang_sub('main/image_not_read', 'GIF, JPG, PNG');
                             }
                         }
                         break;
                     default:
                         $message = qa_lang_sub('main/image_not_read', 'GIF, JPG, PNG');
                         break;
                 }
             }
         }
         //	If there have been no errors, looks like we're all set...
         if (empty($message)) {
             require_once QA_INCLUDE_DIR . 'qa-db-blobs.php';
             $userid = qa_get_logged_in_userid();
             $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
             $blobid = qa_db_blob_create(file_get_contents($file['tmp_name']), $extension, @$file['name'], $userid, $cookieid, qa_remote_ip_address());
             if (isset($blobid)) {
                 $url = qa_get_blob_url($blobid, true);
             } else {
                 $message = 'Failed to create object in database - please try again';
             }
         }
     }
     echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(" . qa_js(qa_get('CKEditorFuncNum')) . ", " . qa_js($url) . ", " . qa_js($message) . ");</script>";
     return null;
 }
コード例 #26
0
 function load_script($fieldname)
 {
     return "qa_ckeditor_" . $fieldname . "=CKEDITOR.replace(" . qa_js($fieldname) . ", window.qa_wysiwyg_editor_config);";
 }
コード例 #27
0
function qa_wall_post_view($message)
{
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    $options = qa_message_html_defaults();
    $htmlfields = qa_message_html_fields($message, $options);
    if ($message['deleteable']) {
        $htmlfields['form'] = array('style' => 'light', 'buttons' => array('delete' => array('tags' => 'name="m' . qa_html($message['messageid']) . '_dodelete" onclick="return qa_wall_post_click(' . qa_js($message['messageid']) . ', this);"', 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('profile/delete_wall_post_popup'))));
    }
    return $htmlfields;
}
コード例 #28
0
$qcount_anon = qa_db_count_posts('Q', false);
$acount = (int) qa_opt('cache_acount');
$acount_anon = qa_db_count_posts('A', false);
$ccount = (int) qa_opt('cache_ccount');
$ccount_anon = qa_db_count_posts('C', false);
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/stats_title');
$qa_content['error'] = qa_admin_page_error();
$qa_content['form'] = array('style' => 'wide', 'fields' => array('q2a_version' => array('label' => qa_lang_html('admin/q2a_version'), 'value' => qa_html(QA_VERSION)), 'q2a_date' => array('label' => qa_lang_html('admin/q2a_build_date'), 'value' => qa_html(QA_BUILD_DATE)), 'q2a_latest' => array('label' => qa_lang_html('admin/q2a_latest_version'), 'type' => 'custom', 'html' => '<IFRAME SRC="http://www.question2answer.org/question2answer-latest.php?version=' . urlencode(QA_VERSION) . '&language=' . urlencode(qa_opt('site_language')) . '" WIDTH="100" HEIGHT="16" STYLE="vertical-align:middle; border:0; background:transparent;" allowTransparency="true" SCROLLING="no" FRAMEBORDER="0"></IFRAME>'), 'break0' => array('type' => 'blank'), 'db_version' => array('label' => qa_lang_html('admin/q2a_db_version'), 'value' => qa_html(qa_opt('db_version'))), 'db_size' => array('label' => qa_lang_html('admin/q2a_db_size'), 'value' => qa_html(number_format(qa_db_table_size() / 1048576, 1) . ' MB')), 'break1' => array('type' => 'blank'), 'php_version' => array('label' => qa_lang_html('admin/php_version'), 'value' => qa_html(phpversion())), 'mysql_version' => array('label' => qa_lang_html('admin/mysql_version'), 'value' => qa_html(qa_db_mysql_version())), 'break2' => array('type' => 'blank'), 'qcount' => array('label' => qa_lang_html('admin/total_qs'), 'value' => qa_html(number_format($qcount))), 'qcount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($qcount - $qcount_anon))), 'qcount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($qcount_anon))), 'break3' => array('type' => 'blank'), 'acount' => array('label' => qa_lang_html('admin/total_as'), 'value' => qa_html(number_format($acount))), 'acount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($acount - $acount_anon))), 'acount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($acount_anon))), 'break4' => array('type' => 'blank'), 'ccount' => array('label' => qa_lang_html('admin/total_cs'), 'value' => qa_html(number_format($ccount))), 'ccount_users' => array('label' => qa_lang_html('admin/from_users'), 'value' => qa_html(number_format($ccount - $ccount_anon))), 'ccount_anon' => array('label' => qa_lang_html('admin/from_anon'), 'value' => qa_html(number_format($ccount_anon))), 'break5' => array('type' => 'blank'), 'users' => array('label' => qa_lang_html('admin/users_registered'), 'value' => QA_FINAL_EXTERNAL_USERS ? '' : qa_html(number_format(qa_db_count_users()))), 'users_active' => array('label' => qa_lang_html('admin/users_active'), 'value' => qa_html(number_format((int) qa_opt('cache_userpointscount')))), 'users_posted' => array('label' => qa_lang_html('admin/users_posted'), 'value' => qa_html(number_format(qa_db_count_active_users('posts')))), 'users_voted' => array('label' => qa_lang_html('admin/users_voted'), 'value' => qa_html(number_format(qa_db_count_active_users('uservotes'))))));
if (QA_FINAL_EXTERNAL_USERS) {
    unset($qa_content['form']['fields']['users']);
} else {
    unset($qa_content['form']['fields']['users_active']);
}
foreach ($qa_content['form']['fields'] as $index => $field) {
    if (empty($field['type'])) {
        $qa_content['form']['fields'][$index]['type'] = 'static';
    }
}
$qa_content['form_2'] = array('tags' => 'METHOD="POST" ACTION="' . qa_path_html('admin/recalc') . '"', 'title' => qa_lang_html('admin/database_cleanup'), 'style' => 'basic', 'buttons' => array('recount_posts' => array('label' => qa_lang_html('admin/recount_posts'), 'tags' => 'NAME="dorecountposts" onClick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang('admin/recount_posts_stop')) . ', \'recount_posts_note\');"', 'note' => '<SPAN ID="recount_posts_note">' . qa_lang_html('admin/recount_posts_note') . '</SPAN>'), 'reindex_content' => array('label' => qa_lang_html('admin/reindex_content'), 'tags' => 'NAME="doreindexcontent" onClick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang('admin/reindex_content_stop')) . ', \'reindex_content_note\');"', 'note' => '<SPAN ID="reindex_content_note">' . qa_lang_html('admin/reindex_content_note') . '</SPAN>'), 'recalc_points' => array('label' => qa_lang_html('admin/recalc_points'), 'tags' => 'NAME="dorecalcpoints" onClick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang('admin/recalc_stop')) . ', \'recalc_points_note\');"', 'note' => '<SPAN ID="recalc_points_note">' . qa_lang_html('admin/recalc_points_note') . '</SPAN>'), 'refill_events' => array('label' => qa_lang_html('admin/refill_events'), 'tags' => 'NAME="dorefillevents" onClick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang('admin/recalc_stop')) . ', \'refill_events_note\');"', 'note' => '<SPAN ID="refill_events_note">' . qa_lang_html('admin/refill_events_note') . '</SPAN>'), 'recalc_categories' => array('label' => qa_lang_html('admin/recalc_categories'), 'tags' => 'NAME="dorecalccategories" onClick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang('admin/recalc_stop')) . ', \'recalc_categories_note\');"', 'note' => '<SPAN ID="recalc_categories_note">' . qa_lang_html('admin/recalc_categories_note') . '</SPAN>'), 'delete_hidden' => array('label' => qa_lang_html('admin/delete_hidden'), 'tags' => 'NAME="dodeletehidden" onClick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang('admin/delete_stop')) . ', \'delete_hidden_note\');"', 'note' => '<SPAN ID="delete_hidden_note">' . qa_lang_html('admin/delete_hidden_note') . '</SPAN>')));
if (!qa_using_categories()) {
    unset($qa_content['form_2']['buttons']['recalc_categories']);
}
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
コード例 #29
0
$qa_content['error'] = @$errors['page'];
$editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs');
$editor = qa_load_editor(@$in['content'], @$in['format'], $editorname);
$field = qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], 'content', 12, false);
$field['label'] = qa_lang_html('question/q_content_label');
$field['error'] = qa_html(@$errors['content']);
$custom = qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : '';
$qa_content['form'] = array('tags' => 'name="ask" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'name="title" id="title" autocomplete="off"', 'value' => qa_html(@$in['title']), 'error' => qa_html(@$errors['title'])), 'similar' => array('type' => 'custom', 'html' => '<span id="similar"></span>'), 'content' => $field), 'buttons' => array('ask' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang_html('question/ask_button'))), 'hidden' => array('editor' => qa_html($editorname), 'code' => qa_get_form_security_code('ask'), 'doask' => '1'));
if (!strlen($custom)) {
    unset($qa_content['form']['fields']['custom']);
}
if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) {
    $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION;
    $qa_content['form']['fields']['title']['tags'] .= ' onchange="qa_title_change(this.value);"';
    if (strlen(@$in['title'])) {
        $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($in['title']) . ');';
    }
}
if (isset($followanswer)) {
    $viewer = qa_load_viewer($followanswer['content'], $followanswer['format']);
    $field = array('type' => 'static', 'label' => qa_lang_html('question/ask_follow_from_a'), 'value' => $viewer->get_html($followanswer['content'], $followanswer['format'], array('blockwordspreg' => qa_get_block_words_preg())));
    qa_array_insert($qa_content['form']['fields'], 'title', array('follows' => $field));
}
if (qa_using_categories() && count($categories)) {
    $field = array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid']));
    qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category'));
    if (!qa_opt('allow_no_category')) {
        // don't auto-select a category even though one is required
        $field['options'][''] = '';
    }
    qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field));
コード例 #30
0
ファイル: qa-page.php プロジェクト: Trideon/gigolo
/**
 *	Output the $qa_content via the theme class after doing some pre-processing, mainly relating to Javascript
 */
function qa_output_content($qa_content)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    global $qa_template;
    $requestlower = strtolower(qa_request());
    //	Set appropriate selected flags for navigation (not done in qa_content_prepare() since it also applies to sub-navigation)
    foreach ($qa_content['navigation'] as $navtype => $navigation) {
        if (!is_array($navigation) || $navtype == 'cat') {
            continue;
        }
        foreach ($navigation as $navprefix => $navlink) {
            $selected =& $qa_content['navigation'][$navtype][$navprefix]['selected'];
            if (isset($navlink['selected_on'])) {
                // match specified paths
                foreach ($navlink['selected_on'] as $path) {
                    if (strpos($requestlower . '$', $path) === 0) {
                        $selected = true;
                    }
                }
            } elseif ($requestlower === $navprefix || $requestlower . '$' === $navprefix) {
                // exact match for array key
                $selected = true;
            }
        }
    }
    //	Slide down notifications
    if (!empty($qa_content['notices'])) {
        foreach ($qa_content['notices'] as $notice) {
            $qa_content['script_onloads'][] = array("qa_reveal(document.getElementById(" . qa_js($notice['id']) . "), 'notice');");
        }
    }
    //	Handle maintenance mode
    if (qa_opt('site_maintenance') && $requestlower != 'login') {
        if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
            if (!isset($qa_content['error'])) {
                $qa_content['error'] = strtr(qa_lang_html('admin/maintenance_admin_only'), array('^1' => '<a href="' . qa_path_html('admin/general') . '">', '^2' => '</a>'));
            }
        } else {
            $qa_content = qa_content_prepare();
            $qa_content['error'] = qa_lang_html('misc/site_in_maintenance');
        }
    }
    //	Handle new users who must confirm their email now, or must be approved before continuing
    $userid = qa_get_logged_in_userid();
    if (isset($userid) && $requestlower != 'confirm' && $requestlower != 'account') {
        $flags = qa_get_logged_in_flags();
        if ($flags & QA_USER_FLAGS_MUST_CONFIRM && !($flags & QA_USER_FLAGS_EMAIL_CONFIRMED) && qa_opt('confirm_user_emails')) {
            $qa_content = qa_content_prepare();
            $qa_content['title'] = qa_lang_html('users/confirm_title');
            $qa_content['error'] = strtr(qa_lang_html('users/confirm_required'), array('^1' => '<a href="' . qa_path_html('confirm') . '">', '^2' => '</a>'));
        } elseif ($flags & QA_USER_FLAGS_MUST_APPROVE && qa_get_logged_in_level() < QA_USER_LEVEL_APPROVED && qa_opt('moderate_users')) {
            $qa_content = qa_content_prepare();
            $qa_content['title'] = qa_lang_html('users/approve_title');
            $qa_content['error'] = strtr(qa_lang_html('users/approve_required'), array('^1' => '<a href="' . qa_path_html('account') . '">', '^2' => '</a>'));
        }
    }
    //	Combine various Javascript elements in $qa_content into single array for theme layer
    $script = array('<script>');
    if (isset($qa_content['script_var'])) {
        foreach ($qa_content['script_var'] as $var => $value) {
            $script[] = 'var ' . $var . ' = ' . qa_js($value) . ';';
        }
    }
    if (isset($qa_content['script_lines'])) {
        foreach ($qa_content['script_lines'] as $scriptlines) {
            $script[] = '';
            $script = array_merge($script, $scriptlines);
        }
    }
    if (isset($qa_content['focusid'])) {
        $qa_content['script_onloads'][] = array("var elem = document.getElementById(" . qa_js($qa_content['focusid']) . ");", "if (elem) {", "\telem.select();", "\telem.focus();", "}");
    }
    if (isset($qa_content['script_onloads'])) {
        array_push($script, '', 'var qa_oldonload = window.onload;', 'window.onload = function() {', "\tif (typeof qa_oldonload == 'function')", "\t\tqa_oldonload();");
        foreach ($qa_content['script_onloads'] as $scriptonload) {
            $script[] = "\t";
            foreach ((array) $scriptonload as $scriptline) {
                $script[] = "\t" . $scriptline;
            }
        }
        $script[] = '};';
    }
    $script[] = '</script>';
    if (isset($qa_content['script_rel'])) {
        $uniquerel = array_unique($qa_content['script_rel']);
        // remove any duplicates
        foreach ($uniquerel as $script_rel) {
            $script[] = '<script src="' . qa_html(qa_path_to_root() . $script_rel) . '"></script>';
        }
    }
    if (isset($qa_content['script_src'])) {
        $uniquesrc = array_unique($qa_content['script_src']);
        // remove any duplicates
        foreach ($uniquesrc as $script_src) {
            $script[] = '<script src="' . qa_html($script_src) . '"></script>';
        }
    }
    $qa_content['script'] = $script;
    //	Load the appropriate theme class and output the page
    $tmpl = substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template;
    $themeclass = qa_load_theme_class(qa_get_site_theme(), $tmpl, $qa_content, qa_request());
    $themeclass->initialize();
    header('Content-type: ' . $qa_content['content_type']);
    $themeclass->doctype();
    $themeclass->html();
    $themeclass->finish();
}