Ejemplo n.º 1
0
function qa_mailing_start()
{
    require_once QA_INCLUDE_DIR . 'qa-db-admin.php';
    if (strlen(qa_opt('mailing_last_userid')) == 0) {
        qa_opt('mailing_last_timestamp', time());
        qa_opt('mailing_last_userid', '0');
        qa_opt('mailing_total_users', qa_db_count_users());
        qa_opt('mailing_done_users', 0);
    }
}
Ejemplo n.º 2
0
     break;
 case 'non-users-missing':
     $errorhtml = 'This Question2Answer site is sharing its users with another Q2A site, but it needs some additional database tables for its own content. Please click below to create them.';
     $buttons = array('nonuser' => 'Create Tables');
     break;
 case 'table-missing':
     $errorhtml .= 'One or more tables are missing from your Question2Answer database.';
     $buttons = array('repair' => 'Repair Database');
     break;
 case 'column-missing':
     $errorhtml .= 'One or more Question2Answer database tables are missing a column.';
     $buttons = array('repair' => 'Repair Database');
     break;
 default:
     require_once QA_INCLUDE_DIR . 'qa-db-admin.php';
     if (!QA_FINAL_EXTERNAL_USERS && qa_db_count_users() == 0) {
         $errorhtml .= "There are currently no users in the Question2Answer database.\n\nPlease enter your details below to create the super administrator:";
         $fields = array('handle' => 'Username:'******'password' => 'Password:'******'email' => 'Email address:');
         $buttons = array('super' => 'Create Super Administrator');
     } else {
         $tables = qa_db_list_tables_lc();
         $moduletypes = qa_list_module_types();
         foreach ($moduletypes as $moduletype) {
             $modules = qa_load_modules_with($moduletype, 'init_queries');
             foreach ($modules as $modulename => $module) {
                 $queries = $module->init_queries($tables);
                 if (!empty($queries)) {
                     // also allows single query to be returned
                     $errorhtml = strtr(qa_lang_html('admin/module_x_database_init'), array('^1' => qa_html($modulename), '^2' => qa_html($moduletype), '^3' => '', '^4' => ''));
                     $buttons = array('module' => 'Initialize Database');
                     $hidden['moduletype'] = $moduletype;
Ejemplo n.º 3
0
//	Check admin privileges (do late to allow one DB query)
if (!qa_admin_check_privileges($qa_content)) {
    return $qa_content;
}
//	Get the information to display
$qcount = (int) qa_opt('cache_qcount');
$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_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_admin_check_privileges($qa_content)) {
    return $qa_content;
}
//	Get the information to display
$qcount = (int) qa_opt('cache_qcount');
$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);
$mysqlversion = qa_db_read_one_value(qa_db_query_raw('SELECT VERSION()'));
//	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_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>'), 'db_version' => array('label' => qa_lang_html('admin/q2a_db_version'), 'value' => qa_html(qa_opt('db_version'))), '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($mysqlversion)), 'break0' => 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))), 'break1' => 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))), 'break2' => 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))), 'break3' => 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_posts' => array('label' => qa_lang_html('admin/reindex_posts'), 'tags' => 'NAME="doreindexposts" onClick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang('admin/reindex_posts_stop')) . ', \'reindex_posts_note\');"', 'note' => '<SPAN ID="reindex_posts_note">' . qa_lang_html('admin/reindex_posts_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>'), '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;