本文整理汇总了PHP中qa_fatal_error函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_fatal_error函数的具体用法?PHP qa_fatal_error怎么用?PHP qa_fatal_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_fatal_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: qa_user_favorite_set
function qa_user_favorite_set($userid, $handle, $cookieid, $entitytype, $entityid, $favorite)
{
require_once QA_INCLUDE_DIR . 'qa-db-favorites.php';
require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
require_once QA_INCLUDE_DIR . 'qa-app-updates.php';
if ($favorite) {
qa_db_favorite_create($userid, $entitytype, $entityid);
} else {
qa_db_favorite_delete($userid, $entitytype, $entityid);
}
switch ($entitytype) {
case QA_ENTITY_QUESTION:
$action = $favorite ? 'q_favorite' : 'q_unfavorite';
$params = array('postid' => $entityid);
break;
case QA_ENTITY_USER:
$action = $favorite ? 'u_favorite' : 'u_unfavorite';
$params = array('userid' => $entityid);
break;
case QA_ENTITY_TAG:
$action = $favorite ? 'tag_favorite' : 'tag_unfavorite';
$params = array('wordid' => $entityid);
break;
case QA_ENTITY_CATEGORY:
$action = $favorite ? 'cat_favorite' : 'cat_unfavorite';
$params = array('categoryid' => $entityid);
break;
default:
qa_fatal_error('Favorite type not recognized');
break;
}
qa_report_event($action, $userid, $handle, $cookieid, $params);
}
示例2: process_request
function process_request($request)
{
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 $this->directory . 'qa-open-utils.php';
// Check we're not using single-sign on integration, that we're logged in
if (QA_FINAL_EXTERNAL_USERS) {
qa_fatal_error('User accounts are handled by external code');
}
$userid = qa_get_logged_in_userid();
if (!isset($userid)) {
qa_redirect('login');
}
// Get current information on user
$useraccount = qa_db_user_find_by_id__open($userid);
// Check if settings were updated
$this->check_settings();
// Check if we're unlinking an account
$mylogins = $this->check_unlink($useraccount);
// Check if we need to associate another provider
$tolink = $this->check_associate($useraccount);
// Check if we're merging multiple accounts
$otherlogins = $this->check_merge($useraccount, $mylogins, $tolink);
// Prepare content for theme
$disp_conf = qa_get('confirm') || !empty($tolink);
$qa_content = qa_content_prepare();
// Build page
if (!$disp_conf) {
// just visiting the regular page
$qa_content['title'] = qa_lang_html('plugin_open/my_logins_title');
$qa_content['navigation']['sub'] = qa_user_sub_navigation($useraccount['handle'], '', true);
$qa_content['script_onloads'][] = '$(function(){ window.setTimeout(function() { qa_conceal(".form-notification-ok"); }, 1500); });';
$this->display_summary($qa_content, $useraccount);
$this->display_logins($qa_content, $useraccount, $mylogins);
$this->display_duplicates($qa_content, $useraccount, $otherlogins);
$this->display_services($qa_content, !empty($mylogins) || !empty($otherlogins));
} else {
// logged in and there are duplicates
$qa_content['title'] = qa_lang_html('plugin_open/other_logins_conf_title');
if (!$this->display_duplicates($qa_content, $useraccount, $otherlogins)) {
$tourl = qa_get('to');
if (!empty($tourl)) {
qa_redirect($tourl);
} else {
if ($tolink) {
// unable to link the login
$provider = ucfirst($tolink['source']);
qa_redirect('logins', array('provider' => $provider, 'code' => 99));
} else {
// no merge to confirm
qa_redirect('', array('provider' => '', 'code' => 98));
}
}
}
}
return $qa_content;
}
示例3: qa_db_count_active_users
function qa_db_count_active_users($table)
{
switch ($table) {
case 'posts':
case 'uservotes':
case 'userpoints':
break;
default:
qa_fatal_error('qa_db_count_active_users() called for unknown table');
break;
}
return qa_db_read_one_value(qa_db_query_sub('SELECT COUNT(DISTINCT(userid)) FROM ^' . $table));
}
示例4: qa_complete_reset_user
function qa_complete_reset_user($userid)
{
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
$password = qa_random_alphanum(max(QA_MIN_PASSWORD_LEN, QA_NEW_PASSWORD_LEN));
$userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
if (!qw_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/new_password_subject'), nl2br(qa_lang('emails/new_password_body')), array('^password' => $password, '^url' => qa_opt('site_url')))) {
qa_fatal_error('Could not send new password - password not reset');
}
qa_db_user_set_password($userid, $password);
// do this last, to be safe
qa_db_user_set($userid, 'emailcode', '');
// so can't be reused
qa_report_event('u_reset', $userid, $userinfo['handle'], qa_cookie_get(), array('email' => $userinfo['email']));
}
示例5: sendNewConfirm
function sendNewConfirm($userid)
{
require_once QA_INCLUDE_DIR . 'db/users.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/emails.php';
$userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
if (!qa_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/confirm_subject'), qa_lang('emails/confirm_body'), array('^url' => getNewConfirmUrl($userid, $userinfo['handle'])))) {
qa_fatal_error('Could not send email confirmation');
}
// $userinfo=qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
// $params = array();
// $params['fromemail'] = qa_opt('from_email'),
// $params['fromname'] = qa_opt('site_title'),
// $params['toemail'] = $userinfo['email'];
// $params['toname'] = $userinfo['handle'];
// $params['subject'] = qa_lang('emails/confirm_subject');
// $params['body'] = qa_lang('emails/confirm_body');
// qa_send_email($params);
}
示例6: process_request
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;
}
示例7: less_css
function less_css($handle)
{
include DUDE_THEME_DIR . "/less/variables.php";
// output css file name
$css_path = DUDE_THEME_DIR . '/css/' . "{$handle}.css";
// automatically regenerate files if source's modified time has changed or vars have changed
try {
// initialise the parser
$less = new lessc();
// load the cache
$cache_path = DUDE_THEME_DIR . "/cache/{$handle}.css.cache";
if (file_exists($cache_path)) {
$cache = unserialize(file_get_contents($cache_path));
}
// If the cache or root path in it are invalid then regenerate
if (empty($cache) || empty($cache['less']['root']) || !file_exists($cache['less']['root'])) {
$cache = array('vars' => $vars, 'less' => DUDE_THEME_DIR . "/less/{$handle}.less");
}
// less config
$less->setFormatter("compressed");
$less->setVariables($vars);
$less_cache = $less->cachedCompile($cache['less'], false);
if (!file_exists($css_path) || empty($cache) || empty($cache['less']['updated']) || $less_cache['updated'] > $cache['less']['updated']) {
file_put_contents($cache_path, serialize(array('vars' => $vars, 'less' => $less_cache)));
file_put_contents($css_path, $less_cache['compiled']);
} elseif ($vars !== $cache['vars']) {
$less_cache = $less->cachedCompile($cache['less'], true);
file_put_contents($cache_path, serialize(array('vars' => $vars, 'less' => $less_cache)));
file_put_contents($css_path, $less_cache['compiled']);
}
} catch (exception $ex) {
qa_fatal_error($ex->getMessage());
}
// return the compiled stylesheet with the query string it had if any
$url = DUDE_THEME_URL . "/css/{$handle}.css";
echo '<link href="' . $url . '" type="text/css" rel="stylesheet">';
}
示例8: qa_register_plugin_layer
function qa_register_plugin_layer($include, $name)
{
global $qa_plugin_directory, $qa_plugin_urltoroot;
if (empty($qa_plugin_directory) || empty($qa_plugin_urltoroot)) {
qa_fatal_error('qa_register_plugin_layer() can only be called from a plugin qa-plugin.php file');
}
qa_register_layer($include, $name, $qa_plugin_directory, $qa_plugin_urltoroot);
}
示例9: qa_db_read_one_value
/**
* Return the first column of the first row (and presumably only cell) from the $result resource.
* If there's no first row, throw a fatal error unless $allowempty is true.
*/
function qa_db_read_one_value($result, $allowempty = false)
{
if (!$result instanceof mysqli_result) {
qa_fatal_error('Reading one value from invalid result');
}
$row = $result->fetch_row();
if (is_array($row)) {
return $row[0];
}
if ($allowempty) {
return null;
} else {
qa_fatal_error('Reading one value from empty results');
}
}
示例10: qa_db_upgrade_tables
//.........这里部分代码省略.........
break;
case 21:
if (!QA_FINAL_EXTERNAL_USERS) {
qa_db_upgrade_query(qa_db_create_table_sql('userfields', array('fieldid' => $definitions['userfields']['fieldid'], 'title' => $definitions['userfields']['title'], 'content' => $definitions['userfields']['content'], 'position' => $definitions['userfields']['position'], 'flags' => $definitions['userfields']['flags'], 'PRIMARY KEY (fieldid)')));
$locktablesquery .= ', ^userfields WRITE';
qa_db_upgrade_query($locktablesquery);
qa_db_upgrade_query(qa_db_default_userfields_sql());
}
break;
// Up to here: Version 1.3 beta 1
// Up to here: Version 1.3 beta 1
case 22:
if (!QA_FINAL_EXTERNAL_USERS) {
qa_db_upgrade_query('ALTER TABLE ^users ADD COLUMN sessionsource ' . $definitions['users']['sessionsource']);
qa_db_upgrade_query($locktablesquery);
}
break;
// Up to here: Version 1.3 beta 2 and release
// Up to here: Version 1.3 beta 2 and release
case 23:
qa_db_upgrade_query(qa_db_create_table_sql('widgets', array('widgetid' => $definitions['widgets']['widgetid'], 'place' => $definitions['widgets']['place'], 'position' => $definitions['widgets']['position'], 'tags' => $definitions['widgets']['tags'], 'title' => $definitions['widgets']['title'], 'PRIMARY KEY (widgetid)', 'UNIQUE position (position)')));
$locktablesquery .= ', ^widgets WRITE';
qa_db_upgrade_query($locktablesquery);
break;
case 24:
qa_db_upgrade_query(qa_db_create_table_sql('tagwords', array('postid' => $definitions['tagwords']['postid'], 'wordid' => $definitions['tagwords']['wordid'], 'KEY postid (postid)', 'KEY wordid (wordid)', 'CONSTRAINT ^tagwords_ibfk_1 FOREIGN KEY (postid) REFERENCES ^posts(postid) ON DELETE CASCADE', 'CONSTRAINT ^tagwords_ibfk_2 FOREIGN KEY (wordid) REFERENCES ^words(wordid)')));
$locktablesquery .= ', ^tagwords WRITE';
qa_db_upgrade_query('ALTER TABLE ^words ADD COLUMN tagwordcount ' . $definitions['words']['tagwordcount']);
qa_db_upgrade_query($locktablesquery);
$keyrecalc['doreindexposts'] = true;
break;
// Up to here: Version 1.4 developer preview
// Up to here: Version 1.4 developer preview
case 25:
$keycolumns = qa_array_to_lower_keys(qa_db_read_all_values(qa_db_query_sub('SHOW COLUMNS FROM ^blobs')));
// might be using blobs table shared with another installation, so check if we need to upgrade
if (isset($keycolumns['filename'])) {
qa_db_upgrade_progress('Skipping upgrading blobs table since it was already upgraded by another QA site sharing it.');
} else {
qa_db_upgrade_query('ALTER TABLE ^blobs ADD COLUMN filename ' . $definitions['blobs']['filename'] . ', ADD COLUMN userid ' . $definitions['blobs']['userid'] . ', ADD COLUMN cookieid ' . $definitions['blobs']['cookieid'] . ', ADD COLUMN createip ' . $definitions['blobs']['createip'] . ', ADD COLUMN created ' . $definitions['blobs']['created']);
qa_db_upgrade_query($locktablesquery);
}
break;
case 26:
qa_db_upgrade_query('ALTER TABLE ^uservotes ADD COLUMN flag ' . $definitions['uservotes']['flag']);
qa_db_upgrade_query($locktablesquery);
qa_db_upgrade_query('ALTER TABLE ^posts ADD COLUMN flagcount ' . $definitions['posts']['flagcount'] . ', ADD KEY type_3 (type, flagcount, created)');
qa_db_upgrade_query($locktablesquery);
$keyrecalc['dorecountposts'] = true;
break;
case 27:
qa_db_upgrade_query('ALTER TABLE ^posts ADD COLUMN netvotes ' . $definitions['posts']['netvotes'] . ', ADD KEY type_4 (type, netvotes, created)');
qa_db_upgrade_query($locktablesquery);
$keyrecalc['dorecountposts'] = true;
break;
case 28:
qa_db_upgrade_query('ALTER TABLE ^posts ADD COLUMN views ' . $definitions['posts']['views'] . ', ADD COLUMN hotness ' . $definitions['posts']['hotness'] . ', ADD KEY type_5 (type, views, created), ADD KEY type_6 (type, hotness)');
qa_db_upgrade_query($locktablesquery);
$keyrecalc['dorecountposts'] = true;
break;
case 29:
qa_db_upgrade_query('ALTER TABLE ^posts ADD COLUMN lastviewip ' . $definitions['posts']['lastviewip']);
qa_db_upgrade_query($locktablesquery);
break;
case 30:
qa_db_upgrade_query('ALTER TABLE ^posts DROP FOREIGN KEY ^posts_ibfk_3');
// to allow category column types to be changed
qa_db_upgrade_query($locktablesquery);
qa_db_upgrade_query('ALTER TABLE ^posts DROP KEY categoryid, DROP KEY categoryid_2');
qa_db_upgrade_query($locktablesquery);
qa_db_upgrade_query('ALTER TABLE ^categories CHANGE COLUMN categoryid categoryid ' . $definitions['categories']['categoryid'] . ', ADD COLUMN parentid ' . $definitions['categories']['parentid'] . ', ADD COLUMN backpath ' . $definitions['categories']['backpath'] . ', ADD COLUMN content ' . $definitions['categories']['content'] . ', DROP INDEX tags, DROP INDEX position, ADD UNIQUE parentid (parentid, tags), ADD UNIQUE parentid_2 (parentid, position), ADD KEY backpath (backpath(' . QA_DB_MAX_CAT_PAGE_TAGS_LENGTH . '))');
qa_db_upgrade_query($locktablesquery);
qa_db_upgrade_query('ALTER TABLE ^posts CHANGE COLUMN categoryid categoryid ' . $definitions['posts']['categoryid'] . ', ADD COLUMN catidpath1 ' . $definitions['posts']['catidpath1'] . ', ADD COLUMN catidpath2 ' . $definitions['posts']['catidpath2'] . ', ADD COLUMN catidpath3 ' . $definitions['posts']['catidpath3']);
// QA_CATEGORY_DEPTH=4
qa_db_upgrade_query($locktablesquery);
qa_db_upgrade_query('ALTER TABLE ^posts ADD KEY catidpath1 (catidpath1, type, created), ADD KEY catidpath2 (catidpath2, type, created), ADD KEY catidpath3 (catidpath3, type, created), ADD KEY categoryid (categoryid, type, created), ADD KEY catidpath1_2 (catidpath1, updated, type), ADD KEY catidpath2_2 (catidpath2, updated, type), ADD KEY catidpath3_2 (catidpath3, updated, type), ADD KEY categoryid_2 (categoryid, updated, type)');
qa_db_upgrade_query($locktablesquery);
qa_db_upgrade_query('ALTER TABLE ^posts ADD CONSTRAINT ^posts_ibfk_3 FOREIGN KEY (categoryid) REFERENCES ^categories(categoryid) ON DELETE SET NULL');
qa_db_upgrade_query($locktablesquery);
$keyrecalc['dorecalccategories'] = true;
break;
// Up to here: Version 1.4 beta 1 and 2
}
qa_db_set_db_version($newversion);
if (qa_db_get_db_version() != $newversion) {
qa_fatal_error('Could not increment database version');
}
}
qa_db_upgrade_query('UNLOCK TABLES');
// Perform any necessary recalculations, as determined by upgrade steps
foreach ($keyrecalc as $state => $dummy) {
while ($state) {
set_time_limit(60);
$stoptime = time() + 2;
while (qa_recalc_perform_step($state) && time() < $stoptime) {
}
qa_db_upgrade_progress(qa_recalc_get_message($state));
}
}
}
示例11: qa_log_in_external_user
function qa_log_in_external_user($source, $identifier, $fields)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'db/users.php';
$users = qa_db_user_login_find($source, $identifier);
$countusers = count($users);
if ($countusers > 1) {
qa_fatal_error('External login mapped to more than one user');
}
// should never happen
if ($countusers) {
// user exists so log them in
qa_set_logged_in_user($users[0]['userid'], $users[0]['handle'], false, $source);
} else {
// create and log in user
require_once QA_INCLUDE_DIR . 'app/users-edit.php';
qa_db_user_login_sync(true);
$users = qa_db_user_login_find($source, $identifier);
// check again after table is locked
if (count($users) == 1) {
qa_db_user_login_sync(false);
qa_set_logged_in_user($users[0]['userid'], $users[0]['handle'], false, $source);
} else {
$handle = qa_handle_make_valid(@$fields['handle']);
if (strlen(@$fields['email'])) {
// remove email address if it will cause a duplicate
$emailusers = qa_db_user_find_by_email($fields['email']);
if (count($emailusers)) {
qa_redirect('login', array('e' => $fields['email'], 'ee' => '1'));
unset($fields['email']);
unset($fields['confirmed']);
}
}
$userid = qa_create_new_user((string) @$fields['email'], null, $handle, isset($fields['level']) ? $fields['level'] : QA_USER_LEVEL_BASIC, @$fields['confirmed']);
qa_db_user_login_add($userid, $source, $identifier);
qa_db_user_login_sync(false);
$profilefields = array('name', 'location', 'website', 'about');
foreach ($profilefields as $fieldname) {
if (strlen(@$fields[$fieldname])) {
qa_db_user_profile_set($userid, $fieldname, $fields[$fieldname]);
}
}
if (strlen(@$fields['avatar'])) {
qa_set_user_avatar($userid, $fields['avatar']);
}
qa_set_logged_in_user($userid, $handle, false, $source);
}
}
}
示例12: header
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-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 QA_INCLUDE_DIR . 'qa-util-image.php';
// Check we're not using single-sign on integration, that we're logged in
if (QA_FINAL_EXTERNAL_USERS) {
qa_fatal_error('User accounts are handled by external code');
}
$userid = qa_get_logged_in_userid();
if (!isset($userid)) {
qa_redirect('login');
}
// Get current information on user
list($useraccount, $userprofile, $userpoints, $userfields) = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true), qa_db_user_profile_selectspec($userid, true), qa_db_user_points_selectspec($userid, true), qa_db_userfields_selectspec());
$changehandle = qa_opt('allow_change_usernames') || !$userpoints['qposts'] && !$userpoints['aposts'] && !$userpoints['cposts'];
$doconfirms = qa_opt('confirm_user_emails') && $useraccount['level'] < QA_USER_LEVEL_EXPERT;
$isconfirmed = $useraccount['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED ? true : false;
$haspassword = isset($useraccount['passsalt']) && isset($useraccount['passcheck']);
$isblocked = qa_user_permit_error() ? true : false;
// Process profile if saved
if (qa_clicked('dosaveprofile') && !$isblocked) {
require_once QA_INCLUDE_DIR . 'qa-app-users-edit.php';
示例13: qa_limits_remaining
function qa_limits_remaining($userid, $action)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'qa-app-options.php';
require_once QA_INCLUDE_DIR . 'qa-db-limits.php';
$period = (int) (qa_opt('db_time') / 3600);
$dblimits = qa_db_limits_get($userid, qa_remote_ip_address(), $action);
switch ($action) {
case QA_LIMIT_QUESTIONS:
$userlimit = qa_opt('max_rate_user_qs');
$iplimit = qa_opt('max_rate_ip_qs');
break;
case QA_LIMIT_ANSWERS:
$userlimit = qa_opt('max_rate_user_as');
$iplimit = qa_opt('max_rate_ip_as');
break;
case QA_LIMIT_COMMENTS:
$userlimit = qa_opt('max_rate_user_cs');
$iplimit = qa_opt('max_rate_ip_cs');
break;
case QA_LIMIT_VOTES:
$userlimit = qa_opt('max_rate_user_votes');
$iplimit = qa_opt('max_rate_ip_votes');
break;
case QA_LIMIT_REGISTRATIONS:
$userlimit = 1;
// not really relevant
$iplimit = qa_opt('max_rate_ip_registers');
break;
case QA_LIMIT_LOGINS:
$userlimit = 1;
// not really relevant
$iplimit = qa_opt('max_rate_ip_logins');
break;
case QA_LIMIT_UPLOADS:
$userlimit = qa_opt('max_rate_user_uploads');
$iplimit = qa_opt('max_rate_ip_uploads');
break;
case QA_LIMIT_FLAGS:
$userlimit = qa_opt('max_rate_user_flags');
$iplimit = qa_opt('max_rate_ip_flags');
break;
case QA_LIMIT_MESSAGES:
$userlimit = qa_opt('max_rate_user_messages');
$iplimit = qa_opt('max_rate_ip_messages');
break;
default:
qa_fatal_error('Unknown limit code in qa_limits_remaining: ' . $action);
break;
}
return max(0, min($userlimit - (@$dblimits['user']['period'] == $period ? $dblimits['user']['count'] : 0), $iplimit - (@$dblimits['ip']['period'] == $period ? $dblimits['ip']['count'] : 0)));
}
示例14: qa_post_content_to_text
function qa_post_content_to_text($content, $format)
{
$viewer = qa_load_viewer($content, $format);
if (!isset($viewer)) {
qa_fatal_error('Content could not be parsed in format: ' . $format);
}
return $viewer->get_text($content, $format, array());
}
示例15: qa_complete_reset_user
function qa_complete_reset_user($userid)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
require_once QA_INCLUDE_DIR . 'util/string.php';
require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR . 'app/emails.php';
require_once QA_INCLUDE_DIR . 'app/cookies.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
$password = qa_random_alphanum(max(QA_MIN_PASSWORD_LEN, QA_NEW_PASSWORD_LEN));
$userinfo = qa_db_select_with_pending(qa_db_user_account_selectspec($userid, true));
if (!qa_send_notification($userid, $userinfo['email'], $userinfo['handle'], qa_lang('emails/new_password_subject'), qa_lang('emails/new_password_body'), array('^password' => $password, '^url' => qa_opt('site_url')))) {
qa_fatal_error('Could not send new password - password not reset');
}
qa_db_user_set_password($userid, $password);
// do this last, to be safe
qa_db_user_set($userid, 'emailcode', '');
// so can't be reused
qa_report_event('u_reset', $userid, $userinfo['handle'], qa_cookie_get(), array('email' => $userinfo['email']));
}