Example #1
0
function qa_reset_options($names)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    foreach ($names as $name) {
        qa_set_option($name, qa_default_option($name));
    }
}
$securityexpired = false;
$recalculate = false;
$optionnames = qa_db_points_option_names();
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')));
Example #3
0
function qa_opt($name, $value = null)
{
    global $qa_options_cache;
    if (!isset($value) && isset($qa_options_cache[$name])) {
        return $qa_options_cache[$name];
    }
    // quick shortcut to reduce calls to qa_get_options()
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    return $options[$name];
}
    } elseif ($blockable) {
        if (qa_clicked('doblock')) {
            $oldblocked = qa_opt('block_ips_write');
            qa_set_option('block_ips_write', (strlen($oldblocked) ? $oldblocked . ' , ' : '') . $ip);
            qa_report_event('ip_block', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array('ip' => $ip));
            qa_redirect(qa_request());
        }
        if (qa_clicked('dounblock')) {
            require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
            $blockipclauses = qa_block_ips_explode(qa_opt('block_ips_write'));
            foreach ($blockipclauses as $key => $blockipclause) {
                if (qa_block_ip_match($ip, $blockipclause)) {
                    unset($blockipclauses[$key]);
                }
            }
            qa_set_option('block_ips_write', implode(' , ', $blockipclauses));
            qa_report_event('ip_unblock', $userid, qa_get_logged_in_handle(), qa_cookie_get(), array('ip' => $ip));
            qa_redirect(qa_request());
        }
        if (qa_clicked('dohideall') && !qa_user_maximum_permit_error('permit_hide_show')) {
            // allow moderator in one category to hide posts across all categories if they are identified via IP page
            require_once QA_INCLUDE_DIR . 'qa-db-admin.php';
            require_once QA_INCLUDE_DIR . 'qa-app-posts.php';
            $postids = qa_db_get_ip_visible_postids($ip);
            foreach ($postids as $postid) {
                qa_post_set_hidden($postid, true, $userid);
            }
            qa_redirect(qa_request());
        }
    }
}
        if (is_array(@$_FILES['avatar_default_file']) && $_FILES['avatar_default_file']['size']) {
            require_once QA_INCLUDE_DIR . 'qa-util-image.php';
            $oldblobid = qa_opt('avatar_default_blobid');
            $toobig = qa_image_file_too_big($_FILES['avatar_default_file']['tmp_name'], qa_opt('avatar_store_size'));
            if ($toobig) {
                $errors['avatar_default_show'] = qa_lang_sub('main/image_too_big_x_pc', (int) ($toobig * 100));
            } else {
                $imagedata = qa_image_constrain_data(file_get_contents($_FILES['avatar_default_file']['tmp_name']), $width, $height, qa_opt('avatar_store_size'));
                if (isset($imagedata)) {
                    require_once QA_INCLUDE_DIR . 'qa-app-blobs.php';
                    $newblobid = qa_create_blob($imagedata, 'jpeg');
                    if (isset($newblobid)) {
                        qa_set_option('avatar_default_blobid', $newblobid);
                        qa_set_option('avatar_default_width', $width);
                        qa_set_option('avatar_default_height', $height);
                        qa_set_option('avatar_default_show', 1);
                    }
                    if (strlen($oldblobid)) {
                        qa_delete_blob($oldblobid);
                    }
                } else {
                    $errors['avatar_default_show'] = qa_lang_sub('main/image_not_read', implode(', ', qa_gd_image_formats()));
                }
            }
        }
    }
}
//	Mailings management
if ($adminsection == 'mailing') {
    if (qa_clicked('domailingtest') || qa_clicked('domailingstart') || qa_clicked('domailingresume') || qa_clicked('domailingcancel')) {
        if (!qa_check_form_security_code('admin/' . $adminsection, qa_post_text('code'))) {
function qa_reset_options($names)
{
    foreach ($names as $name) {
        qa_set_option($name, qa_default_option($name));
    }
}
Example #7
0
                $newpoints = isset($errors['points']) ? $oldpoints : $inpoints;
                $newtitle = isset($errors['title']) ? $pointstitle[$oldpoints] : $intitle;
                unset($pointstitle[$oldpoints]);
                $pointstitle[$newpoints] = $newtitle;
            } elseif (empty($errors)) {
                // creating a new user title
                $pointstitle[$inpoints] = $intitle;
            }
        }
        //	Save the new option value
        krsort($pointstitle, SORT_NUMERIC);
        $option = '';
        foreach ($pointstitle as $points => $title) {
            $option .= (strlen($option) ? ',' : '') . $points . ' ' . $title;
        }
        qa_set_option('points_to_titles', $option);
        if (empty($errors)) {
            qa_redirect('admin/users');
        }
    }
}
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/users_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_path_html(qa_request()) . '"', 'style' => 'tall', 'fields' => array('title' => array('tags' => 'name="title" id="title"', 'label' => qa_lang_html('admin/user_title'), 'value' => qa_html(isset($intitle) ? $intitle : @$pointstitle[$oldpoints]), 'error' => qa_html(@$errors['title'])), 'delete' => array('tags' => 'name="dodelete" id="dodelete"', 'label' => qa_lang_html('admin/delete_title'), 'value' => 0, 'type' => 'checkbox'), 'points' => array('id' => 'points_display', 'tags' => 'name="points"', 'label' => qa_lang_html('admin/points_required'), 'type' => 'number', 'value' => qa_html(isset($inpoints) ? $inpoints : @$oldpoints), 'error' => qa_html(@$errors['points']))), 'buttons' => array('save' => array('label' => qa_lang_html(isset($pointstitle[$oldpoints]) ? 'main/save_button' : 'admin/add_title_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('dosavetitle' => '1', 'edit' => @$oldpoints, 'code' => qa_get_form_security_code('admin/usertitles')));
if (isset($pointstitle[$oldpoints])) {
    qa_set_display_rules($qa_content, array('points_display' => '!dodelete'));
} else {
    unset($qa_content['form']['fields']['delete']);
}
$setparent = !$setmissing && (qa_post_text('setparent') || qa_get('setparent')) && isset($editcategory['categoryid']);
$hassubcategory = false;
foreach ($categories as $category) {
    if (!strcmp($category['parentid'], $editcategoryid)) {
        $hassubcategory = true;
    }
}
//	Process saving options
$savedoptions = false;
$securityexpired = false;
if (qa_clicked('dosaveoptions')) {
    if (!qa_check_form_security_code('admin/categories', qa_post_text('code'))) {
        $securityexpired = true;
    } else {
        qa_set_option('allow_no_category', (int) qa_post_text('option_allow_no_category'));
        qa_set_option('allow_no_sub_category', (int) qa_post_text('option_allow_no_sub_category'));
        $savedoptions = true;
    }
}
//	Process saving an old or new category
if (qa_clicked('docancel')) {
    if ($setmissing || $setparent) {
        qa_redirect(qa_request(), array('edit' => $editcategory['categoryid']));
    } elseif (isset($editcategory['categoryid'])) {
        qa_redirect(qa_request());
    } else {
        qa_redirect(qa_request(), array('edit' => @$editcategory['parentid']));
    }
} elseif (qa_clicked('dosetmissing')) {
    if (!qa_check_form_security_code('admin/categories', qa_post_text('code'))) {
        $securityexpired = true;
Example #9
0
function ra_opt($name, $value = null)
{
    /*
    	Shortcut to get or set an option value without specifying database
    */
    global $qa_options_cache;
    if (!isset($value) && isset($qa_options_cache[$name])) {
        if (ra_is_serialized($qa_options_cache[$name])) {
            return unserialize($qa_options_cache[$name]);
        }
        return $qa_options_cache[$name];
        // quick shortcut to reduce calls to qa_get_options()
    }
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        if (is_array($value)) {
            $value = serialize($value);
        }
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    if (ra_is_serialized($options[$name])) {
        return unserialize($options[$name]);
    }
    return $options[$name];
}
Example #10
0
            }
        }
        $success .= 'The ' . $modulename . ' ' . $moduletype . ' module has completed database initialization.';
    }
    if (qa_clicked('super')) {
        require_once QA_INCLUDE_DIR . 'qa-db-users.php';
        require_once QA_INCLUDE_DIR . 'qa-app-users-edit.php';
        $inemail = qa_post_text('email');
        $inpassword = qa_post_text('password');
        $inhandle = qa_post_text('handle');
        $fielderrors = array_merge(qa_handle_email_filter($inhandle, $inemail), qa_password_validate($inpassword));
        if (empty($fielderrors)) {
            require_once QA_INCLUDE_DIR . 'qa-app-users.php';
            $userid = qa_create_new_user($inemail, $inpassword, $inhandle, QA_USER_LEVEL_SUPER);
            qa_set_logged_in_user($userid, $inhandle);
            qa_set_option('feedback_email', $inemail);
            $success .= "Congratulations - Your Question2Answer site is ready to go!\n\nYou are logged in as the super administrator and can start changing settings.\n\nThank you for installing Question2Answer.";
        }
    }
}
if (is_resource(qa_db_connection(false)) && !@$pass_failure_from_install) {
    $check = qa_db_check_tables();
    // see where the database is at
    switch ($check) {
        case 'none':
            if (@$pass_failure_errno == 1146) {
                // don't show error if we're in installation process
                $errorhtml = '';
            }
            $errorhtml .= 'Welcome to Question2Answer. It\'s time to set up your database!';
            if (QA_FINAL_EXTERNAL_USERS) {
Example #11
0
/**
 * Reset the options in $names to their defaults
 *
 * @param $names
 */
function donut_reset_options($names)
{
    foreach ($names as $name) {
        qa_set_option($name, donut_default_option($name));
    }
}
Example #12
0
} elseif (qa_clicked('dosaveoptions')) {
    if (!qa_check_form_security_code('admin/' . $adminsection, qa_post_text('code'))) {
        $securityexpired = true;
    } else {
        foreach ($getoptions as $optionname) {
            $optionvalue = qa_post_text('option_' . $optionname);
            if (@$optiontype[$optionname] == 'number' || @$optiontype[$optionname] == 'checkbox' || @$optiontype[$optionname] == 'number-blank' && strlen($optionvalue)) {
                $optionvalue = (int) $optionvalue;
            }
            if (isset($optionmaximum[$optionname])) {
                $optionvalue = min($optionmaximum[$optionname], $optionvalue);
            }
            if (isset($optionminimum[$optionname])) {
                $optionvalue = max($optionminimum[$optionname], $optionvalue);
            }
            qa_set_option($optionname, $optionvalue);
        }
        $formokhtml = donut_lang_html('options_saved');
    }
}
//	Get the actual options
$options = qa_get_options($getoptions);
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = donut_lang('donut_theme_settings') . ' - ' . donut_lang($subtitle);
$qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['form'] = array('ok' => $formokhtml, 'tags' => 'method="post" action="' . qa_self_html() . '" name="admin_form" onsubmit="document.forms.admin_form.has_js.value=1; return true;"', 'style' => $formstyle, 'fields' => array(), 'buttons' => array('save' => array('tags' => 'id="dosaveoptions"', 'label' => qa_lang_html('admin/save_options_button')), 'reset' => array('tags' => 'name="doresetoptions"', 'label' => qa_lang_html('admin/reset_options_button'))), 'hidden' => array('dosaveoptions' => '1', 'has_js' => '0', 'code' => qa_get_form_security_code('admin/' . $adminsection)));
function qa_optionfield_make_select(&$optionfield, $options, $value, $default)
{
    $optionfield['type'] = 'select';
Example #13
0
function qa_opt($name, $value = null)
{
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    return $options[$name];
}