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; }
function process_request($request) { $userid = qa_get_logged_in_userid(); $categoryoptions = array(); $qa_content = qa_content_prepare(); // check if we have done a post of the page if (qa_post_text('okthen')) { // update the current category $newcategory = qa_post_text('category'); if (isset($newcategory)) { mp_set_categoryid($newcategory); // redirect to main page qa_redirect(''); } else { $qa_content['error'] = 'You must select a course to continue.'; } } // retrieve list of categories user is associated with // populate category options $results = mp_get_categories_for_user($userid); foreach ($results as $row) { $categoryoptions[$row['categoryid']] = $row['title']; } $qa_content['title'] = 'Registered courses'; $qa_content['custom'] = 'The following list displays all courses your account is associated with. Select a course from the list below and click <B>Select</B> to change to the new course<br /><br />'; $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'wide', 'fields' => array('courses' => array('type' => 'select-radio', 'label' => 'Courses', 'tags' => 'NAME="category"', 'options' => $categoryoptions, 'value' => mp_get_categoryid(), 'error' => qa_html(@$errors['course']))), 'buttons' => array('ok' => array('tags' => 'NAME="okthen"', 'label' => 'Select', 'value' => '1'))); return $qa_content; }
function process_request($request) { // double check we are admin if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) { return; } if (qa_clicked('docancel')) { qa_redirect('admin/plugins'); } $qa_content = qa_content_prepare(); $qa_content['title'] = 'Widget Anywhere'; $qa_content['custom'] = '<p><a href="' . qa_path('admin/plugins') . '#' . qa_html($this->anchor) . '">« back to plugin options</a></p>'; $saved_msg = null; $editid = qa_get('editid'); if (qa_post_text('dodelete')) { $this->delete_widget(); qa_redirect('admin/plugins'); } else { if (qa_clicked('save_button')) { // save widget $widget = $this->save_widget(); $saved_msg = 'Widget saved.'; } else { if (empty($editid)) { // display blank form $widget = array('id' => 0, 'title' => '', 'pages' => '', 'position' => '', 'ordering' => 1, 'content' => ''); } else { // load specified widget $sql = 'SELECT * FROM ^' . $this->pluginkey . ' WHERE id=#'; $result = qa_db_query_sub($sql, $editid); $widget = qa_db_read_one_assoc($result); } } } $sel_position = empty($widget['position']) ? null : @$this->positionlangs[$widget['position']]; // set up page (template) list $widget_pages = explode(',', $widget['pages']); $sel_pages = array(); $custom_pages = array(); foreach ($widget_pages as $page) { if (strpos($page, 'custom:') === 0) { $custom_pages[] = substr($page, 7); } else { $sel_pages[] = $page; } } // $chkd = in_array('all', $sel_pages) ? 'checked' : ''; // $pages_html = '<label><input type="checkbox" name="wpages_all" ' . $chkd . '> ' . qa_lang_html('admin/widget_all_pages') . '</label><br><br>'; $pages_html = ''; foreach ($this->templatelangkeys as $tmpl => $langkey) { $chkd = in_array($tmpl, $sel_pages) ? 'checked' : ''; $pages_html .= '<label><input type="checkbox" name="wpages_' . $tmpl . '" ' . $chkd . '> ' . qa_lang_html($langkey) . '</label><br>'; } $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $saved_msg, 'fields' => array('title' => array('label' => 'Title', 'tags' => 'NAME="wtitle"', 'value' => qa_html($widget['title'])), 'position' => array('type' => 'select', 'label' => 'Position', 'tags' => 'NAME="wposition"', 'options' => $this->positionlangs, 'value' => $sel_position), 'all_pages' => array('type' => 'checkbox', 'id' => 'tb_pages_all', 'label' => qa_lang_html('admin/widget_all_pages'), 'tags' => 'NAME="wpages_all" ID="wpages_all"', 'value' => in_array('all', $sel_pages)), 'pages' => array('type' => 'custom', 'id' => 'tb_pages_list', 'label' => qa_lang_html('admin/widget_pages_explanation'), 'html' => $pages_html), 'show_custom_pages' => array('type' => 'checkbox', 'id' => 'tb_show_custom_pages', 'label' => 'Show on custom page(s)', 'tags' => 'NAME="cb_custom_pages" ID="cb_custom_pages"', 'value' => count($custom_pages) > 0), 'custom_pages' => array('id' => 'tb_custom_pages', 'label' => 'Page slugs', 'tags' => 'NAME="wpages_custom"', 'value' => qa_html(implode(',', $custom_pages)), 'note' => 'Separate multiple page slugs (URL fragments) with commas, e.g. <code>custom-page,other-page</code>'), 'ordering' => array('type' => 'number', 'label' => 'Order', 'tags' => 'NAME="wordering"', 'value' => qa_html($widget['ordering'])), 'content' => array('type' => 'textarea', 'label' => 'Content (HTML)', 'tags' => 'NAME="wcontent"', 'value' => qa_html($widget['content']), 'rows' => 12)), 'hidden' => array('wid' => $widget['id']), 'buttons' => array('save' => array('tags' => 'NAME="save_button"', 'label' => 'Save widget', 'value' => '1'), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button')))); if ($widget['id'] > 0) { $qa_content['form']['fields']['delete'] = array('tags' => 'NAME="dodelete"', 'label' => 'Delete widget', 'value' => 0, 'type' => 'checkbox'); } qa_set_display_rules($qa_content, array('tb_pages_list' => '!wpages_all', 'tb_show_custom_pages' => '!wpages_all', 'tb_custom_pages' => 'cb_custom_pages && !wpages_all')); return $qa_content; }
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(); }
function match_request($request) { $this->expert_user = $this->is_expert_user(); $expert = qa_opt('expert_question_page_url'); if ($request == $expert && $this->expert_user) { return true; } if ($request == $expert) { qa_redirect('ask', array(qa_opt('expert_question_page_url') => 'true')); } return false; }
function doctype() { if (qa_post_text('merge_from') && qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { $merged = qa_merge_do_merge(); if ($merged === true) { qa_redirect(qa_q_request(qa_post_text('merge_to'), null), array('merged' => qa_post_text('merge_from'))); } else { $error1 = $merged[0]; $error2 = $merged[1]; $this->content['error'] = "Error merging posts."; } } qa_html_theme_base::doctype(); }
function process_request($request) { $parts = explode('/', $request); $tag = $parts[1]; $qa_content = qa_content_prepare(); $qa_content['title'] = 'Edit the description for Fture test ' . qa_html($tag); require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(array('type' => 'text', 'rows' => 4, 'tags' => 'NAME="tagdesc" ID="tagdesc"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'description')))), 'buttons' => array(array('tags' => 'NAME="dosave"', 'label' => 'Save Description'))); if (qa_clicked('dosave')) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $taglc = qa_strtolower($tag); qa_db_tagmeta_set($taglc, 'description', qa_post_text('tagdesc')); qa_redirect('tag/' . $tag); } $qa_content['focusid'] = 'tagdesc'; return $qa_content; }
function doctype() { if (@$this->content['error'] == qa_lang_html('main/page_not_found') && preg_match('/^[0-9]+\\//', $this->request) !== false) { $pid = preg_replace('/\\/.*/', '', $this->request); $merged = qa_db_read_one_assoc(qa_db_query_sub("SELECT ^posts.postid as postid,^posts.title as title FROM ^postmeta, ^posts WHERE ^postmeta.meta_key='merged_with' AND ^postmeta.post_id=# AND ^posts.postid=^postmeta.meta_value", $pid), true); if ($merged) { qa_redirect(qa_q_request($merged['postid'], $merged['title']), array('merged' => $pid)); } } else { if (qa_get('merged')) { $this->content['error'] = str_replace('^post', qa_get('merged'), qa_opt('merge_question_merged')); } } if (qa_post_text('ajax_merge_get_from')) { return; } qa_html_theme_base::doctype(); }
function process_request($request) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-posts.php'; require_once QA_INCLUDE_DIR . 'qa-db-post-create.php'; require_once QA_INCLUDE_DIR . 'mp-db-users.php'; // report that we entered this page qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'])); // create the editor and update its content qa_get_post_content('editor', 'content', $ineditor, $incontent, $informat, $intext); $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_qs'); $editor = qa_load_editor(@$incontent, @$informat, $editorname); // retrieve variable data $innotify = qa_post_text('notify') ? true : false; // handle creation of annoucement if (qa_post_text('docreate')) { //retrieve data $title = qa_post_text('title'); $content = $incontent; $format = $informat; // validate data // handle create work // actual create process is in file mp-app-posts.php $postid = qa_post_create('AN', null, $title, $content, $format, mp_get_categoryid(), null, qa_get_logged_in_userid(), $innotify); // redirect page qa_redirect('mp-announcements-page'); // our work is done here } $qa_content = qa_content_prepare(); // if the user is not logged in, request user to login if (!qa_get_logged_in_userid()) { $qa_content['error'] = qa_insert_login_links('Please ^1log in^2 or ^3register^4 first.', $request); return $qa_content; } $qa_content['title'] = 'Create Announcement'; $qa_content['form_newannouncement'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('announcements/a_title_label'), 'tags' => 'NAME="title"', 'value' => qa_html(qa_post_text('title')), 'error' => qa_html(@$errors['title'])), 'content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, false), array('label' => qa_lang_html('announcements/a_content_label'), 'error' => qa_html(@$errors['content']))), 'notify' => array('label' => 'Send email notification to all registered students', 'tags' => 'NAME="notify"', 'type' => 'checkbox', 'value' => qa_html($innotify))), 'buttons' => array('ok' => array('tags' => 'NAME="docreate"', 'label' => 'Create Announcement', 'value' => '1')), 'hidden' => array('hiddenfield' => '1', 'editor' => qa_html($editorname))); // create the sub menu for navigation $qa_content['navigation']['sub'] = mp_announcements_sub_navigation(); $qa_content['navigation']['sub']['create']['selected'] = true; return $qa_content; }
function process_request($request) { require_once QA_INCLUDE_DIR . "qa-base.php"; $expire = 14 * 24 * 60 * 60; if (isset($_SESSION['logout_url'])) { $tourl = $_SESSION['logout_url']; } else { $tourl = false; } if (isset($_COOKIE["qa-login_fname"])) { setcookie("qa-login_fname", '1', time() - $expire, '/'); setcookie("qa-login_lname", '1', time() - $expire, '/'); setcookie("qa-login_email", '1', time() - $expire, '/'); } session_destroy(); if (!$tourl) { qa_redirect('logout'); } else { header('Location: ' . $tourl); } return null; }
function admin_form(&$qa_content) { // Process form input $ok = null; if (qa_clicked('theme_switch_save')) { if (!qa_post_text('theme_switch_enable')) { qa_opt('site_theme', qa_opt('theme_switch_default')); } qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^usermeta ( meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, user_id bigint(20) unsigned NOT NULL, meta_key varchar(255) DEFAULT NULL, meta_value longtext, PRIMARY KEY (meta_id), UNIQUE (user_id,meta_key) ) ENGINE=MyISAM DEFAULT CHARSET=utf8'); qa_opt('theme_switch_enable', (bool) qa_post_text('theme_switch_enable')); qa_opt('theme_switch_default', qa_post_text('theme_switch_default')); qa_opt('theme_switch_title', qa_post_text('theme_switch_title')); qa_opt('theme_switch_text', qa_post_text('theme_switch_text')); qa_opt('theme_switch_enable_mobile', (bool) qa_post_text('theme_switch_enable_mobile')); qa_opt('theme_switch_mobile', qa_post_text('theme_switch_mobile')); global $qa_request; qa_redirect($qa_request, array('ok' => qa_lang_html('admin/options_saved'))); } // Create the form for display $themes = qa_admin_theme_options(); $fields = array(); $fields[] = array('label' => 'Enable theme switching', 'tags' => 'NAME="theme_switch_enable"', 'value' => qa_opt('theme_switch_enable'), 'type' => 'checkbox'); $fields[] = array('label' => 'Default theme', 'tags' => 'NAME="theme_switch_default"', 'type' => 'select', 'options' => qa_admin_theme_options(), 'value' => @$themes[qa_opt('theme_switch_default')]); $fields[] = array('label' => 'Theme switch title', 'type' => 'text', 'value' => qa_html(qa_opt('theme_switch_title')), 'tags' => 'NAME="theme_switch_title"'); $fields[] = array('label' => 'Theme switch text', 'type' => 'text', 'value' => qa_html(qa_opt('theme_switch_text')), 'tags' => 'NAME="theme_switch_text"'); if (!function_exists('qa_register_plugin_overrides')) { // 1.4 $fields[] = array('label' => 'Enable mobile theme', 'tags' => 'NAME="theme_switch_enable_mobile"', 'value' => qa_opt('theme_switch_enable_mobile'), 'type' => 'checkbox'); $fields[] = array('label' => 'Mobile theme', 'tags' => 'NAME="theme_switch_mobile"', 'type' => 'select', 'options' => qa_admin_theme_options(), 'value' => @$themes[qa_opt('theme_switch_mobile')]); } return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save', 'tags' => 'NAME="theme_switch_save"'))); }
function process_request($request) { $parts = explode('/', $request); $tag = $parts[1]; $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html_sub('useo/edit_desc_for_x', qa_html($tag)); if (qa_user_permit_error('useo_tag_desc_permit_edit')) { $qa_content['error'] = qa_lang_html('users/no_permission'); return $qa_content; } require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; if (qa_clicked('dosave')) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; $taglc = qa_strtolower($tag); qa_db_tagmeta_set($taglc, 'title', qa_post_text('tagtitle')); qa_db_tagmeta_set($taglc, 'description', qa_post_text('tagdesc')); qa_db_tagmeta_set($taglc, 'icon', qa_post_text('tagicon')); qa_redirect('tag/' . $tag); } $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(array('label' => 'Title:', 'type' => 'text', 'rows' => 2, 'tags' => 'NAME="tagtitle" ID="tagtitle"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'title'))), array('label' => 'Description:', 'type' => 'text', 'rows' => 4, 'tags' => 'NAME="tagdesc" ID="tagdesc"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'description'))), array('label' => 'Icon image:', 'type' => 'text', 'rows' => 1, 'tags' => 'NAME="tagicon" ID="tagicon"', 'value' => qa_html(qa_db_tagmeta_get($tag, 'icon')))), 'buttons' => array(array('tags' => 'NAME="dosave"', 'label' => qa_lang_html('useo/save_desc_button')))); $qa_content['focusid'] = 'tagdesc'; return $qa_content; }
function process_request($request) { $start = qa_get_start(); $userid = qa_get_logged_in_userid(); // Prepare content for theme require_once QA_INCLUDE_DIR . 'qa-db-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QW_CONTROL_DIR . '/addons/social-login/cs-social-login-utils.php'; if (QA_FINAL_EXTERNAL_USERS) { qa_fatal_error('User accounts are handled by external code'); } if (!isset($userid)) { qa_redirect('login'); } $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('notification/my_notification_settings'); $qa_content['site_title'] = qa_opt('site_title'); if (qa_clicked('save_notf_user_settings')) { $data_to_save = array('qw_mail_when_a_post' => !!qa_post_text('qw_mail_when_a_post'), 'qw_mail_when_related' => !!qa_post_text('qw_mail_when_related'), 'qw_mail_when_c_post' => !!qa_post_text('qw_mail_when_c_post'), 'qw_mail_when_q_reshow' => !!qa_post_text('qw_mail_when_q_reshow'), 'qw_mail_when_c_reshow' => !!qa_post_text('qw_mail_when_c_reshow'), 'qw_mail_when_a_select' => !!qa_post_text('qw_mail_when_a_select'), 'qw_mail_when_q_vote_up' => !!qa_post_text('qw_mail_when_q_vote_up'), 'qw_mail_when_q_vote_down' => !!qa_post_text('qw_mail_when_q_vote_down'), 'qw_mail_when_a_vote_up' => !!qa_post_text('qw_mail_when_a_vote_up'), 'qw_mail_when_a_vote_down' => !!qa_post_text('qw_mail_when_a_vote_down'), 'qw_mail_when_q_favorite' => !!qa_post_text('qw_mail_when_q_favorite'), 'qw_mail_when_u_favorite' => !!qa_post_text('qw_mail_when_u_favorite'), 'qw_mail_when_u_message' => !!qa_post_text('qw_mail_when_u_message'), 'qw_mail_when_u_wall_post' => !!qa_post_text('qw_mail_when_u_wall_post'), 'qw_mail_when_u_level' => !!qa_post_text('qw_mail_when_u_level'), 'qw_mail_when_q_post_user_fl' => !!qa_post_text('qw_mail_when_q_post_user_fl'), 'qw_mail_when_q_post_tag_fl' => !!qa_post_text('qw_mail_when_q_post_tag_fl'), 'qw_mail_when_q_post_cat_fl' => !!qa_post_text('qw_mail_when_q_post_cat_fl'), 'qw_mail_when_q_approve' => !!qa_post_text('qw_mail_when_q_approve'), 'qw_mail_when_q_reject' => !!qa_post_text('qw_mail_when_q_reject'), 'qw_mail_when_a_approve' => !!qa_post_text('qw_mail_when_a_approve'), 'qw_mail_when_a_reject' => !!qa_post_text('qw_mail_when_a_reject'), 'qw_mail_when_c_approve' => !!qa_post_text('qw_mail_when_c_approve'), 'qw_mail_when_c_reject' => !!qa_post_text('qw_mail_when_c_reject')); qw_save_notification_settings(json_encode($data_to_save), $userid); qa_redirect('notification-settings', array('state' => 'settings-saved')); } $disp_conf = qa_get('confirm'); $preferences = qw_get_notification_settings($userid); // qw_log(print_r(qw_check_pref_for_event($userid , 'a_post') , true )) ; if (!$disp_conf) { // display some summary about the user $qa_content['form_profile'] = array('title' => qa_lang_html('notification/my_notification_settings'), 'tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '" CLASS="social-login-settings"', 'style' => 'wide', 'buttons' => array('check_all' => array('type' => 'button', 'tags' => 'name="check_all_notf_fields" id="check_all_notf_fields" ', 'label' => qa_lang_html('notification/check_all')), 'uncheck_all' => array('type' => 'button', 'tags' => 'name="un_check_all_notf_fields" id="un_check_all_notf_fields" ', 'label' => qa_lang_html('notification/uncheck_all')), 'save' => array('tags' => 'onClick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('notification/save_settings'))), 'fields' => array('qw_mail_when_a_post' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_a_post_lable'), 'tags' => 'NAME="qw_mail_when_a_post"', 'value' => @$preferences['qw_mail_when_a_post'] ? true : false), 'qw_mail_when_related' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_related_lable'), 'tags' => 'NAME="qw_mail_when_related"', 'value' => @$preferences['qw_mail_when_related'] ? true : false), 'qw_mail_when_c_post' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_c_post_lable'), 'tags' => 'NAME="qw_mail_when_c_post"', 'value' => @$preferences['qw_mail_when_c_post'] ? true : false), 'qw_mail_when_q_reshow' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_reshow_lable'), 'tags' => 'NAME="qw_mail_when_q_reshow"', 'value' => @$preferences['qw_mail_when_q_reshow'] ? true : false), 'qw_mail_when_c_reshow' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_c_reshow_lable'), 'tags' => 'NAME="qw_mail_when_c_reshow"', 'value' => @$preferences['qw_mail_when_c_reshow'] ? true : false), 'qw_mail_when_a_select' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_a_select_lable'), 'tags' => 'NAME="qw_mail_when_a_select"', 'value' => @$preferences['qw_mail_when_a_select'] ? true : false), 'qw_mail_when_q_vote_up' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_vote_up_lable'), 'tags' => 'NAME="qw_mail_when_q_vote_up"', 'value' => @$preferences['qw_mail_when_q_vote_up'] ? true : false), 'qw_mail_when_q_vote_down' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_vote_down_lable'), 'tags' => 'NAME="qw_mail_when_q_vote_down"', 'value' => @$preferences['qw_mail_when_q_vote_down'] ? true : false), 'qw_mail_when_a_vote_up' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_a_vote_up_lable'), 'tags' => 'NAME="qw_mail_when_a_vote_up"', 'value' => @$preferences['qw_mail_when_a_vote_up'] ? true : false), 'qw_mail_when_a_vote_down' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_a_vote_down_lable'), 'tags' => 'NAME="qw_mail_when_a_vote_down"', 'value' => @$preferences['qw_mail_when_a_vote_down'] ? true : false), 'qw_mail_when_q_favorite' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_favorite_lable'), 'tags' => 'NAME="qw_mail_when_q_favorite"', 'value' => @$preferences['qw_mail_when_q_favorite'] ? true : false), 'qw_mail_when_u_favorite' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_u_favorite_lable'), 'tags' => 'NAME="qw_mail_when_u_favorite"', 'value' => @$preferences['qw_mail_when_u_favorite'] ? true : false), 'qw_mail_when_u_message' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_u_message_lable'), 'tags' => 'NAME="qw_mail_when_u_message"', 'value' => @$preferences['qw_mail_when_u_message'] ? true : false), 'qw_mail_when_u_wall_post' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_u_wall_post_lable'), 'tags' => 'NAME="qw_mail_when_u_wall_post"', 'value' => @$preferences['qw_mail_when_u_wall_post'] ? true : false), 'qw_mail_when_u_level' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_u_level_lable'), 'tags' => 'NAME="qw_mail_when_u_level"', 'value' => @$preferences['qw_mail_when_u_level'] ? true : false), 'qw_mail_when_q_post_user_fl' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_post_user_fl_lable'), 'tags' => 'NAME="qw_mail_when_q_post_user_fl"', 'value' => @$preferences['qw_mail_when_q_post_user_fl'] ? true : false), 'qw_mail_when_q_post_tag_fl' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_post_tag_fl_lable'), 'tags' => 'NAME="qw_mail_when_q_post_tag_fl"', 'value' => @$preferences['qw_mail_when_q_post_tag_fl'] ? true : false), 'qw_mail_when_q_post_cat_fl' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_post_cat_fl_lable'), 'tags' => 'NAME="qw_mail_when_q_post_cat_fl"', 'value' => @$preferences['qw_mail_when_q_post_cat_fl'] ? true : false), 'qw_mail_when_q_approve' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_approve_lable'), 'tags' => 'NAME="qw_mail_when_q_approve"', 'value' => @$preferences['qw_mail_when_q_approve'] ? true : false), 'qw_mail_when_q_reject' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_q_reject_lable'), 'tags' => 'NAME="qw_mail_when_q_reject"', 'value' => @$preferences['qw_mail_when_q_reject'] ? true : false), 'qw_mail_when_a_approve' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_a_approve_lable'), 'tags' => 'NAME="qw_mail_when_a_approve"', 'value' => @$preferences['qw_mail_when_a_approve'] ? true : false), 'qw_mail_when_a_reject' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_a_reject_lable'), 'tags' => 'NAME="qw_mail_when_a_reject"', 'value' => @$preferences['qw_mail_when_a_reject'] ? true : false), 'qw_mail_when_c_approve' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_c_approve_lable'), 'tags' => 'NAME="qw_mail_when_c_approve"', 'value' => @$preferences['qw_mail_when_c_approve'] ? true : false), 'qw_mail_when_c_reject' => array('type' => 'checkbox', 'label' => qa_lang_html('notification/mail_when_c_reject_lable'), 'tags' => 'NAME="qw_mail_when_c_reject"', 'value' => @$preferences['qw_mail_when_c_reject'] ? true : false)), 'hidden' => array('save_notf_user_settings' => '1')); if (qa_get_state() == 'settings-saved') { $qa_content['form_profile']['ok'] = qa_lang_html('notification/settings_saved'); } } $qa_content['navigation']['sub'] = qa_account_sub_navigation(); return $qa_content; }
function process_request($request) { $parts = explode('/', $request); $categoryid = $parts[1]; $fullcategory = qa_db_select_with_pending(qa_db_full_category_selectspec($categoryid, true)); $slugs = explode('/', $fullcategory['backpath']); $new_request = implode('/', array_reverse($slugs)); $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html_sub('useo/edit_desc_for_x', qa_html($fullcategory['title'])); if (qa_user_permit_error('useo_cat_desc_permit_edit')) { $qa_content['error'] = qa_lang_html('users/no_permission'); return $qa_content; } require_once QA_INCLUDE_DIR . 'qa-db-metas.php'; if (qa_clicked('dosave')) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; qa_db_categorymeta_set($categoryid, 'useo_cat_title', qa_post_text('useo_cat_title')); qa_db_categorymeta_set($categoryid, 'useo_cat_description', qa_post_text('useo_cat_description')); qa_redirect($new_request); } $qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array(array('label' => 'Link Title:', 'type' => 'text', 'rows' => 2, 'tags' => 'NAME="useo_cat_title" ID="useo_cat_title"', 'value' => qa_html(qa_db_categorymeta_get($categoryid, 'useo_cat_title'))), array('label' => 'Description:', 'type' => 'text', 'rows' => 4, 'tags' => 'NAME="useo_cat_description" ID="useo_cat_description"', 'value' => qa_html(qa_db_categorymeta_get($categoryid, 'useo_cat_description')))), 'buttons' => array(array('tags' => 'NAME="dosave"', 'label' => qa_lang_html('useo/save_desc_button')))); $qa_content['focusid'] = 'tagtitle'; return $qa_content; }
function qa_page_q_refresh($start = 0, $state = null, $showtype = null, $showid = null) { $params = array(); if ($start > 0) { $params['start'] = $start; } if (isset($state)) { $params['state'] = $state; } if (isset($showtype) && isset($showid)) { $anchor = qa_anchor($showtype, $showid); $params['show'] = $showid; } else { $anchor = null; } qa_redirect(qa_request(), $params, null, null, $anchor); }
} if (count($matchusers) == 1) { // if matches more than one (should be impossible), don't log in $inuserid = $matchusers[0]; $userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($inuserid, true)); if (strtolower(qa_db_calc_passcheck($inpassword, $userinfo['passsalt'])) == strtolower($userinfo['passcheck'])) { // login and redirect require_once QA_INCLUDE_DIR . 'qa-app-users.php'; qa_set_logged_in_user($inuserid, $userinfo['handle'], $inremember ? true : false); $topath = qa_get('to'); if (isset($topath)) { qa_redirect_raw(qa_path_to_root() . $topath); } elseif ($passwordsent) { qa_redirect('account'); } else { qa_redirect('welcome'); } } else { $errors['password'] = qa_lang('users/password_wrong'); } } else { $errors['emailhandle'] = qa_lang('users/user_not_found'); } } else { $pageerror = qa_lang('users/login_limit'); } } else { $inemailhandle = qa_get('e'); } // Prepare content for theme $qa_content = qa_content_prepare();
$qa_content = qa_content_prepare(); $level = qa_get_logged_in_level(); if (!qa_permit_value_error($custompage['permit'], $userid, $level, qa_get_logged_in_flags()) || !isset($custompage['permit'])) { $qa_content['title'] = qa_html($custompage['heading']); $qa_content['custom'] = $custompage['content']; if ($level >= QA_USER_LEVEL_ADMIN) { $qa_content['navigation']['sub'] = array('admin/pages' => array('label' => qa_lang('admin/edit_custom_page'), 'url' => qa_path_html('admin/pages', array('edit' => $custompage['pageid'])))); } } else { $qa_content['error'] = qa_lang_html('users/no_permission'); } return $qa_content; } // Then, see if we should redirect because the 'qa' page is the same as the home page if ($explicitqa && !qa_is_http_post() && !qa_has_custom_home()) { qa_redirect(qa_category_path_request($categories, $categoryid), $_GET); } // Then, if there's a slug that matches no category, check page modules provided by plugins if (!$explicitqa && $countslugs && !isset($categoryid)) { $pagemodules = qa_load_modules_with('page', 'match_request'); $request = qa_request(); foreach ($pagemodules as $pagemodule) { if ($pagemodule->match_request($request)) { qa_set_template('plugin'); return $pagemodule->process_request($request); } } } // Then, check whether we are showing a custom home page if (!$explicitqa && !$countslugs && qa_opt('show_custom_home')) { qa_set_template('custom');
$errors['oldpassword'] = qa_lang('users/password_wrong'); } $useraccount['password'] = $inoldpassword; $errors = $errors + qa_password_validate($innewpassword1, $useraccount); // array union if ($innewpassword1 != $innewpassword2) { $errors['newpassword2'] = qa_lang('users/password_mismatch'); } if (empty($errors)) { qa_db_user_set_password($userid, $innewpassword1); qa_db_user_set($userid, 'sessioncode', ''); // stop old 'Remember me' style logins from still working qa_set_logged_in_user($userid, $useraccount['handle'], false, $useraccount['sessionsource']); // reinstate this specific session qa_report_event('u_password', $userid, $useraccount['handle'], qa_cookie_get()); qa_redirect('account', array('state' => 'password-changed')); } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('profile/my_account_title'); $qa_content['error'] = @$errors['page']; $qa_content['form_profile'] = array('tags' => 'enctype="multipart/form-data" method="post" action="' . qa_self_html() . '"', 'style' => 'wide', 'fields' => array('duration' => array('type' => 'static', 'label' => qa_lang_html('users/member_for'), 'value' => qa_time_to_string(qa_opt('db_time') - $useraccount['created'])), 'type' => array('type' => 'static', 'label' => qa_lang_html('users/member_type'), 'value' => qa_html(qa_user_level_string($useraccount['level'])), 'note' => $isblocked ? qa_lang_html('users/user_blocked') : null), 'handle' => array('label' => qa_lang_html('users/handle_label'), 'tags' => 'name="handle"', 'value' => qa_html(isset($inhandle) ? $inhandle : $useraccount['handle']), 'error' => qa_html(@$errors['handle']), 'type' => $changehandle && !$isblocked ? 'text' : 'static'), 'email' => array('label' => qa_lang_html('users/email_label'), 'tags' => 'name="email"', 'value' => qa_html(isset($inemail) ? $inemail : $useraccount['email']), 'error' => isset($errors['email']) ? qa_html($errors['email']) : ($doconfirms && !$isconfirmed ? qa_insert_login_links(qa_lang_html('users/email_please_confirm')) : null), 'type' => $isblocked ? 'static' : 'text'), 'messages' => array('label' => qa_lang_html('users/private_messages'), 'tags' => 'name="messages"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_MESSAGES), 'note' => qa_lang_html('users/private_messages_explanation')), 'wall' => array('label' => qa_lang_html('users/wall_posts'), 'tags' => 'name="wall"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_WALL_POSTS), 'note' => qa_lang_html('users/wall_posts_explanation')), 'mailings' => array('label' => qa_lang_html('users/mass_mailings'), 'tags' => 'name="mailings"', 'type' => 'checkbox', 'value' => !($useraccount['flags'] & QA_USER_FLAGS_NO_MAILINGS), 'note' => qa_lang_html('users/mass_mailings_explanation')), 'avatar' => null), 'buttons' => array('save' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('users/save_profile'))), 'hidden' => array('dosaveprofile' => '1', 'code' => qa_get_form_security_code('account'))); if (qa_get_state() == 'profile-saved') { $qa_content['form_profile']['ok'] = qa_lang_html('users/profile_saved'); } if (!qa_opt('allow_private_messages')) { unset($qa_content['form_profile']['fields']['messages']); } if (!qa_opt('allow_user_walls')) {
Description: Controller for logout page (not much to do) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. More about this license: http://www.question2answer.org/license.php */ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser header('Location: ../'); exit; } if (QA_FINAL_EXTERNAL_USERS) { qa_fatal_error('User logout is handled by external code'); } if (qa_is_logged_in()) { qa_set_logged_in_user(null); } qa_redirect(''); // back to home page /* Omit PHP closing tag to help avoid accidental output */
} else { $messageid = null; } $fromhandle = qa_get_logged_in_handle(); $canreply = !(qa_get_logged_in_flags() & QA_USER_FLAGS_NO_MESSAGES); $more = strtr(qa_lang($canreply ? 'emails/private_message_reply' : 'emails/private_message_info'), array('^f_handle' => $fromhandle, '^url' => qa_path_absolute($canreply ? 'message/' . $fromhandle : 'user/' . $fromhandle))); $subs = array('^message' => $inmessage, '^f_handle' => $fromhandle, '^f_url' => qa_path_absolute('user/' . $fromhandle), '^more' => $more, '^a_url' => qa_path_absolute('account')); if (qa_send_notification($toaccount['userid'], $toaccount['email'], $toaccount['handle'], qa_lang('emails/private_message_subject'), qa_lang('emails/private_message_body'), $subs)) { $messagesent = true; } else { $pageerror = qa_lang_html('main/general_error'); } qa_report_event('u_message', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array('userid' => $toaccount['userid'], 'handle' => $toaccount['handle'], 'messageid' => $messageid, 'message' => $inmessage)); if ($messagesent && qa_opt('show_message_history')) { // show message as part of general history qa_redirect(qa_request(), array('state' => 'message-sent')); } } } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('misc/private_message_title'); $qa_content['error'] = @$pageerror; $qa_content['form_message'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('message' => array('type' => $messagesent ? 'static' : '', 'label' => qa_lang_html_sub('misc/message_for_x', qa_get_one_user_html($handle, false)), 'tags' => 'name="message" id="message"', 'value' => qa_html(@$inmessage, $messagesent), 'rows' => 8, 'note' => qa_lang_html_sub('misc/message_explanation', qa_html(qa_opt('site_title'))), 'error' => qa_html(@$errors['message']))), 'buttons' => array('send' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('main/send_button'))), 'hidden' => array('domessage' => '1', 'code' => qa_get_form_security_code('message-' . $handle))); $qa_content['focusid'] = 'message'; if ($messagesent) { $qa_content['form_message']['ok'] = qa_lang_html('misc/message_sent'); unset($qa_content['form_message']['buttons']); if (qa_opt('show_message_history')) { unset($qa_content['form_message']['fields']['message']);
$errors['page'] = qa_lang_html('misc/form_security_again'); } else { qa_wall_delete_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $message); qa_redirect(qa_request(), $_GET); } } } if (qa_clicked('dowallpost')) { $inmessage = qa_post_text('message'); if (!strlen($inmessage)) { $errors['message'] = qa_lang('profile/post_wall_empty'); } elseif (!qa_check_form_security_code('wall-' . $useraccount['handle'], qa_post_text('code'))) { $errors['message'] = qa_lang_html('misc/form_security_again'); } elseif (!$wallposterrorhtml) { qa_wall_add_post($loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), $useraccount['userid'], $useraccount['handle'], $inmessage, ''); qa_redirect(qa_request()); } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html_sub('profile/wall_for_x', $userhtml); $qa_content['error'] = @$errors['page']; $qa_content['script_rel'][] = 'qa-content/qa-user.js?' . QA_VERSION; $qa_content['message_list'] = array('tags' => 'id="wallmessages"', 'form' => array('tags' => 'name="wallpost" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'hidden' => array('qa_click' => '', 'handle' => qa_html($useraccount['handle']), 'start' => qa_html($start), 'code' => qa_get_form_security_code('wall-' . $useraccount['handle']))), 'messages' => array()); if ($start == 0) { // only allow posting on first page if ($wallposterrorhtml) { $qa_content['message_list']['error'] = $wallposterrorhtml; } else { $qa_content['message_list']['form']['fields'] = array('message' => array('tags' => 'name="message" id="message"', 'value' => qa_html(@$inmessage, false), 'rows' => 2, 'error' => qa_html(@$errors['message']))); $qa_content['message_list']['form']['buttons'] = array('post' => array('tags' => 'name="dowallpost" onclick="return qa_submit_wall_post(this, false);"', 'label' => qa_lang_html('profile/post_wall_button')));
GNU General Public License for more details. More about this license: http://www.question2answer.org/license.php */ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-q-list.php'; // Check that we're logged in $userid = qa_get_logged_in_userid(); if (!isset($userid)) { qa_redirect('login'); } // Find out which updates to show $forfavorites = qa_get('show') != 'content'; $forcontent = qa_get('show') != 'favorites'; // Get lists of recent updates for this user $questions = qa_db_select_with_pending(qa_db_user_updates_selectspec($userid, $forfavorites, $forcontent)); if ($forfavorites) { if ($forcontent) { $sometitle = qa_lang_html('misc/recent_updates_title'); $nonetitle = qa_lang_html('misc/no_recent_updates'); } else { $sometitle = qa_lang_html('misc/recent_updates_favorites'); $nonetitle = qa_lang_html('misc/no_updates_favorites'); } } else {
modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. More about this license: http://www.question2answer.org/license.php */ define('QA_BASE_DIR', dirname(dirname(empty($_SERVER['SCRIPT_FILENAME']) ? __FILE__ : $_SERVER['SCRIPT_FILENAME'])) . '/'); require 'qa-base.php'; require_once QA_INCLUDE_DIR . 'qa-app-users.php'; if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) { qa_redirect('admin/general', null, qa_opt('site_url')); } header('Content-type: text/html; charset=utf-8'); ?> <HTML> <HEAD> <META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=utf-8"/> <TITLE>Question2Answer Language Check</TITLE> <STYLE> code {font-size:125%;} </STYLE> </HEAD> <BODY STYLE="font-family:arial; font-size:12px;"> <?php function get_phrase_substitutions($phrase) {
if (qa_clicked('doshowdefaults')) { $options = array(); foreach ($optionnames as $optionname) { $options[$optionname] = qa_default_option($optionname); } } else { if (qa_clicked('docancel')) { } elseif (qa_clicked('dosaverecalc')) { if (!qa_check_form_security_code('admin/points', qa_post_text('code'))) { $securityexpired = true; } else { foreach ($optionnames as $optionname) { qa_set_option($optionname, (int) qa_post_text('option_' . $optionname)); } if (!qa_post_text('has_js')) { qa_redirect('admin/recalc', array('dorecalcpoints' => 1)); } else { $recalculate = true; } } } $options = qa_get_options($optionnames); } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/points_title'); $qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error(); $qa_content['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '" name="points_form" onsubmit="document.forms.points_form.has_js.value=1; return true;"', 'style' => 'wide', 'buttons' => array('saverecalc' => array('tags' => 'id="dosaverecalc"', 'label' => qa_lang_html('admin/save_recalc_button'))), 'hidden' => array('dosaverecalc' => '1', 'has_js' => '0', 'code' => qa_get_form_security_code('admin/points'))); if (qa_clicked('doshowdefaults')) { $qa_content['form']['ok'] = qa_lang_html('admin/points_defaults_shown'); $qa_content['form']['buttons']['cancel'] = array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'));
require_once QA_INCLUDE_DIR . 'qa-db-admin.php'; require_once QA_INCLUDE_DIR . 'qa-db-maxima.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-app-admin.php'; $adminsection = strtolower(qa_request_part(1)); // Get list of categories and all options $categories = qa_db_select_with_pending(qa_db_category_nav_selectspec(null, true)); // See if we need to redirect if (empty($adminsection)) { $subnav = qa_admin_sub_navigation(); if (isset($subnav[@$_COOKIE['qa_admin_last']])) { qa_redirect($_COOKIE['qa_admin_last']); } elseif (count($subnav)) { reset($subnav); qa_redirect(key($subnav)); } } // Check admin privileges (do late to allow one DB query) if (!qa_admin_check_privileges($qa_content)) { return $qa_content; } // For non-text options, lists of option types, minima and maxima $optiontype = array('avatar_message_list_size' => 'number', 'avatar_profile_size' => 'number', 'avatar_q_list_size' => 'number', 'avatar_q_page_a_size' => 'number', 'avatar_q_page_c_size' => 'number', 'avatar_q_page_q_size' => 'number', 'avatar_store_size' => 'number', 'avatar_users_size' => 'number', 'columns_tags' => 'number', 'columns_users' => 'number', 'feed_number_items' => 'number', 'flagging_hide_after' => 'number', 'flagging_notify_every' => 'number', 'flagging_notify_first' => 'number', 'hot_weight_a_age' => 'number', 'hot_weight_answers' => 'number', 'hot_weight_q_age' => 'number', 'hot_weight_views' => 'number', 'hot_weight_votes' => 'number', 'logo_height' => 'number-blank', 'logo_width' => 'number-blank', 'mailing_per_minute' => 'number', 'max_len_q_title' => 'number', 'max_num_q_tags' => 'number', 'max_rate_ip_as' => 'number', 'max_rate_ip_cs' => 'number', 'max_rate_ip_flags' => 'number', 'max_rate_ip_logins' => 'number', 'max_rate_ip_messages' => 'number', 'max_rate_ip_qs' => 'number', 'max_rate_ip_registers' => 'number', 'max_rate_ip_uploads' => 'number', 'max_rate_ip_votes' => 'number', 'max_rate_user_as' => 'number', 'max_rate_user_cs' => 'number', 'max_rate_user_flags' => 'number', 'max_rate_user_messages' => 'number', 'max_rate_user_qs' => 'number', 'max_rate_user_uploads' => 'number', 'max_rate_user_votes' => 'number', 'min_len_a_content' => 'number', 'min_len_c_content' => 'number', 'min_len_q_content' => 'number', 'min_len_q_title' => 'number', 'min_num_q_tags' => 'number', 'moderate_points_limit' => 'number', 'page_size_activity' => 'number', 'page_size_ask_check_qs' => 'number', 'page_size_ask_tags' => 'number', 'page_size_home' => 'number', 'page_size_hot_qs' => 'number', 'page_size_q_as' => 'number', 'page_size_qs' => 'number', 'page_size_related_qs' => 'number', 'page_size_search' => 'number', 'page_size_tag_qs' => 'number', 'page_size_tags' => 'number', 'page_size_una_qs' => 'number', 'page_size_users' => 'number', 'page_size_wall' => 'number', 'pages_prev_next' => 'number', 'q_urls_title_length' => 'number', 'show_fewer_cs_count' => 'number', 'show_fewer_cs_from' => 'number', 'show_full_date_days' => 'number', 'smtp_port' => 'number', 'allow_change_usernames' => 'checkbox', 'allow_close_questions' => 'checkbox', 'allow_login_email_only' => 'checkbox', 'allow_multi_answers' => 'checkbox', 'allow_private_messages' => 'checkbox', 'allow_user_walls' => 'checkbox', 'allow_self_answer' => 'checkbox', 'allow_view_q_bots' => 'checkbox', 'approve_user_required' => 'checkbox', 'avatar_allow_gravatar' => 'checkbox', 'avatar_allow_upload' => 'checkbox', 'avatar_default_show' => 'checkbox', 'captcha_on_anon_post' => 'checkbox', 'captcha_on_feedback' => 'checkbox', 'captcha_on_register' => 'checkbox', 'captcha_on_reset_password' => 'checkbox', 'captcha_on_unapproved' => 'checkbox', 'captcha_on_unconfirmed' => 'checkbox', 'comment_on_as' => 'checkbox', 'comment_on_qs' => 'checkbox', 'confirm_user_emails' => 'checkbox', 'confirm_user_required' => 'checkbox', 'do_ask_check_qs' => 'checkbox', 'do_close_on_select' => 'checkbox', 'do_complete_tags' => 'checkbox', 'do_count_q_views' => 'checkbox', 'do_example_tags' => 'checkbox', 'extra_field_active' => 'checkbox', 'extra_field_display' => 'checkbox', 'feed_for_activity' => 'checkbox', 'feed_for_hot' => 'checkbox', 'feed_for_qa' => 'checkbox', 'feed_for_questions' => 'checkbox', 'feed_for_search' => 'checkbox', 'feed_for_tag_qs' => 'checkbox', 'feed_for_unanswered' => 'checkbox', 'feed_full_text' => 'checkbox', 'feed_per_category' => 'checkbox', 'feedback_enabled' => 'checkbox', 'flagging_of_posts' => 'checkbox', 'follow_on_as' => 'checkbox', 'links_in_new_window' => 'checkbox', 'logo_show' => 'checkbox', 'mailing_enabled' => 'checkbox', 'moderate_anon_post' => 'checkbox', 'moderate_by_points' => 'checkbox', 'moderate_edited_again' => 'checkbox', 'moderate_notify_admin' => 'checkbox', 'moderate_unapproved' => 'checkbox', 'moderate_unconfirmed' => 'checkbox', 'moderate_users' => 'checkbox', 'neat_urls' => 'checkbox', 'notify_admin_q_post' => 'checkbox', 'notify_users_default' => 'checkbox', 'q_urls_remove_accents' => 'checkbox', 'register_notify_admin' => 'checkbox', 'show_c_reply_buttons' => 'checkbox', 'show_custom_answer' => 'checkbox', 'show_custom_ask' => 'checkbox', 'show_custom_comment' => 'checkbox', 'show_custom_footer' => 'checkbox', 'show_custom_header' => 'checkbox', 'show_custom_home' => 'checkbox', 'show_custom_in_head' => 'checkbox', 'show_custom_register' => 'checkbox', 'show_custom_sidebar' => 'checkbox', 'show_custom_sidepanel' => 'checkbox', 'show_custom_welcome' => 'checkbox', 'show_home_description' => 'checkbox', 'show_message_history' => 'checkbox', 'show_notice_visitor' => 'checkbox', 'show_notice_welcome' => 'checkbox', 'show_selected_first' => 'checkbox', 'show_url_links' => 'checkbox', 'show_user_points' => 'checkbox', 'show_user_titles' => 'checkbox', 'show_view_counts' => 'checkbox', 'show_view_count_q_page' => 'checkbox', 'show_when_created' => 'checkbox', 'site_maintenance' => 'checkbox', 'smtp_active' => 'checkbox', 'smtp_authenticate' => 'checkbox', 'suspend_register_users' => 'checkbox', 'tag_separator_comma' => 'checkbox', 'votes_separated' => 'checkbox', 'voting_on_as' => 'checkbox', 'voting_on_q_page_only' => 'checkbox', 'voting_on_qs' => 'checkbox', 'smtp_password' => 'password'); $optionmaximum = array('feed_number_items' => QA_DB_RETRIEVE_QS_AS, 'max_len_q_title' => QA_DB_MAX_TITLE_LENGTH, 'page_size_activity' => QA_DB_RETRIEVE_QS_AS, 'page_size_ask_check_qs' => QA_DB_RETRIEVE_QS_AS, 'page_size_ask_tags' => QA_DB_RETRIEVE_QS_AS, 'page_size_home' => QA_DB_RETRIEVE_QS_AS, 'page_size_hot_qs' => QA_DB_RETRIEVE_QS_AS, 'page_size_qs' => QA_DB_RETRIEVE_QS_AS, 'page_size_related_qs' => QA_DB_RETRIEVE_QS_AS, 'page_size_search' => QA_DB_RETRIEVE_QS_AS, 'page_size_tag_qs' => QA_DB_RETRIEVE_QS_AS, 'page_size_tags' => QA_DB_RETRIEVE_TAGS, 'page_size_una_qs' => QA_DB_RETRIEVE_QS_AS, 'page_size_users' => QA_DB_RETRIEVE_USERS, 'page_size_wall' => QA_DB_RETRIEVE_MESSAGES); $optionminimum = array('flagging_hide_after' => 2, 'flagging_notify_every' => 1, 'flagging_notify_first' => 1, 'max_num_q_tags' => 2, 'max_rate_ip_logins' => 1, 'page_size_activity' => 1, 'page_size_ask_check_qs' => 3, 'page_size_ask_tags' => 3, 'page_size_home' => 1, 'page_size_hot_qs' => 1, 'page_size_q_as' => 1, 'page_size_qs' => 1, 'page_size_search' => 1, 'page_size_tag_qs' => 1, 'page_size_tags' => 1, 'page_size_users' => 1, 'page_size_wall' => 1); // Define the options to show (and some other visual stuff) based on request $formstyle = 'tall'; $checkboxtodisplay = null; $maxpermitpost = max(qa_opt('permit_post_q'), qa_opt('permit_post_a')); if (qa_opt('comment_on_qs') || qa_opt('comment_on_as')) {
function qa_get_logged_in_user_field($field) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_cached_logged_in_user; $userid = qa_get_logged_in_userid(); if (isset($userid) && !isset($qa_cached_logged_in_user)) { require_once QA_INCLUDE_DIR . 'db/selects.php'; $qa_cached_logged_in_user = qa_db_get_pending_result('loggedinuser', qa_db_user_account_selectspec($userid, true)); if (!isset($qa_cached_logged_in_user)) { // the user can no longer be found (should only apply to deleted users) qa_clear_session_user(); qa_redirect(''); // implicit exit; } } return @$qa_cached_logged_in_user[$field]; }
function qa_admin_check_clicks() { if (qa_is_http_post()) { foreach ($_POST as $field => $value) { if (strpos($field, 'admin_') === 0) { @(list($dummy, $postid, $action) = explode('_', $field)); if (strlen($postid) && strlen($action) && qa_admin_single_click($postid, $action)) { qa_redirect(qa_request()); } } } } }
qa_redirect(qa_request()); } if (qa_clicked('dodelete') && $loginlevel >= QA_USER_LEVEL_ADMIN) { require_once QA_INCLUDE_DIR . 'qa-app-users-edit.php'; qa_delete_user($userid); qa_report_event('u_delete', $loginuserid, qa_get_logged_in_handle(), qa_cookie_get(), array('userid' => $userid, 'handle' => $useraccount['handle'])); qa_redirect('users'); } } } // Process bonus setting button if ($loginlevel >= QA_USER_LEVEL_ADMIN && qa_clicked('dosetbonus')) { require_once QA_INCLUDE_DIR . 'qa-db-points.php'; qa_db_points_set_bonus($userid, (int) qa_post_text('bonus')); qa_db_points_update_ifuser($userid, null); qa_redirect(qa_request(), null, null, null, 'activity'); } // Get information on user references in answers and other stuff need for page $pagesize = qa_opt('page_size_user_posts'); $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, $pagesize); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); $usershtml[$userid] = $userhtml; // Prepare content for theme $qa_content = qa_content_prepare(true); $qa_content['title'] = qa_lang_html_sub('profile/user_x', $userhtml); if (isset($loginuserid) && !QA_FINAL_EXTERNAL_USERS) { $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_USER, $useraccount['userid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'users/add_user_x_favorites', $handle)); } // General information about the user, only available if we're using internal user management if (!QA_FINAL_EXTERNAL_USERS) {
qa_update_post_text($in, $oldin); } if (qa_using_categories() && count($categories) && !qa_opt('allow_no_category') && !isset($in['categoryid'])) { $errors['categoryid'] = qa_lang_html('question/category_required'); } elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) { $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed'); } if ($captchareason) { require_once 'qa-app-captcha.php'; qa_captcha_validate_post($errors); } if (empty($errors)) { $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create(); // create a new cookie if necessary $questionid = qa_question_create($followanswer, $userid, qa_get_logged_in_handle(), $cookieid, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $in['notify'], $in['email'], $in['categoryid'], $in['extra'], $in['queued'], $in['name']); qa_redirect(qa_q_request($questionid, $in['title'])); // our work is done here } } } // Prepare content for theme $qa_content = qa_content_prepare(false, array_keys(qa_category_path($categories, @$in['categoryid']))); $qa_content['title'] = qa_lang_html(isset($followanswer) ? 'question/ask_follow_title' : 'question/ask_title'); $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'));
} } } // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/plugins_title'); $qa_content['error'] = qa_admin_page_error(); $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION; $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; } if (count($pluginfiles)) { foreach ($pluginfiles as $pluginindex => $pluginfile) { $plugindirectory = dirname($pluginfile) . '/';