} } foreach ($fList as $fid) { if (isset($_POST['counts'])) { $for->forumUpdateCounts($fid, $_POST['counts_threads']); $msg .= FORLAN_167 . ": {$fid} <br />"; } if (isset($_POST['lastpost'])) { $with_threads = isset($_POST['lastpost_nothread']) ? FALSE : TRUE; $for->forumUpdateLastpost('forum', $fid, $with_threads); $msg .= FORLAN_168 . ": {$fid} <br />"; } } if (isset($_POST['userpostcounts'])) { require_once e_HANDLER . 'user_extended_class.php'; $ue = new e107_user_extended(); $list = $for->getUserCounts(); foreach ($list as $uid => $cnt) { $ue->user_extended_setvalue($uid, 'user_plugin_forum_posts', $cnt, 'int'); } $msg .= FORLAN_169 . ' <br />'; } $forum->show_message($msg); } if (isset($_POST['create_sub'])) { $fid = (int) $sub_action; $tmp = array(); $tmp['forum_name'] = $e107->tp->toDB($_POST['subname_new']); $tmp['forum_description'] = $e107->tp->toDB($_POST['subdesc_new']); $tmp['forum_order'] = (int) $_POST['suborder_new']; if ($tmp['forum_name'] != '' && $e107->sql->db_Select('forum', '*', "forum_id = {$fid}")) {
// Must be logged in to change settings e107::redirect(); exit; } if ((!ADMIN || !getperms("4")) && e_QUERY && e_QUERY != "update") { header('location:' . e_BASE . 'usersettings.php'); exit; } include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/lan_user.php'); // Generic user-related language defines include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/lan_usersettings.php'); require_once e_HANDLER . 'ren_help.php'; require_once e_HANDLER . 'user_extended_class.php'; // require_once (e_HANDLER.'user_handler.php'); require_once e_HANDLER . 'validator_class.php'; $ue = new e107_user_extended(); $userMethods = e107::getUserSession(); require_once e_HANDLER . 'ren_help.php'; if (deftrue('BOOTSTRAP') === 3) { $template = e107::getCoreTemplate('usersettings', '', true, true); // always merge $USERSETTINGS_MESSAGE = "{MESSAGE}"; $USERSETTINGS_MESSAGE_CAPTION = LAN_OK; $USERSETTINGS_EDIT_CAPTION = LAN_USET_39; // 'Update User Settings' $USERSETTINGS_EDIT = $template['edit']; $usersettings_shortcodes = e107::getScBatch('usersettings'); $usersettings_shortcodes->wrapper('usersettings/edit'); } else { include_once e107::coreTemplatePath('usersettings'); //correct way to load a core template.
/** * Carries out the copy of timezone data from the user record to an extended user field * @return boolean TRUE on success, FALSE on failure */ function copy_user_timezone() { $sql = e107::getDb(); $sql2 = e107::getDb('sql2'); $tp = e107::getParser(); require_once e_HANDLER . 'user_extended_class.php'; $ue = new e107_user_extended(); $tmp = $ue->parse_extended_xml('getfile'); $tmp['timezone']['parms'] = $tp->toDB($tmp['timezone']['parms']); if (!$ue->user_extended_add($tmp['timezone'])) { return FALSE; } // Created the field - now copy existing data if ($sql->db_Select('user', 'user_id, user_timezone')) { while ($row = $sql->db_Fetch()) { $sql2->update('user_extended', "`user_timezone`='{$row['user_timezone']}' WHERE `user_extended_id`={$row['user_id']}"); } } return TRUE; // All done! }
exit; } if (isset($_POST['cancel'])) { header('location:' . e_SELF); exit; } if (isset($_POST['cancel_cat'])) { header("location:" . e_SELF . "?cat"); exit; } include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_' . e_PAGE); $e_sub_cat = 'user_extended'; $curtype = '1'; require_once "auth.php"; require_once e_HANDLER . 'message_handler.php'; $ue = new e107_user_extended(); $user = new users_ext(); $frm = e107::getForm(); $mes = e107::getMessage(); require_once e_HANDLER . 'user_extended_class.php'; require_once e_HANDLER . 'userclass_class.php'; $message = ''; $message_type = E_MESSAGE_SUCCESS; if (e_QUERY) { $tmp = explode(".", e_QUERY); $action = $tmp[0]; $sub_action = varset($tmp[1], ''); $id = varset($tmp[2], 0); unset($tmp); } // TODO $_POST['up_x'] check for the evil IE
public function __construct($method, &$username, &$userpass) { $this->e107 = e107::getInstance(); $newvals = array(); if ($method == 'none') { $this->loginResult = AUTH_NOCONNECT; return; } require_once e_PLUGIN . 'alt_auth/' . $method . '_auth.php'; $_login = new auth_login(); if (isset($_login->Available) && $_login->Available === FALSE) { // Relevant auth method not available (e.g. PHP extension not loaded) $this->loginResult = AUTH_NOT_AVAILABLE; return; } $login_result = $_login->login($username, $userpass, $newvals, FALSE); if ($login_result === AUTH_SUCCESS) { require_once e_HANDLER . 'user_handler.php'; require_once e_HANDLER . 'validator_class.php'; if (MAGIC_QUOTES_GPC == FALSE) { $username = mysql_real_escape_string($username); } $username = preg_replace("/\\sOR\\s|\\=|\\#/", "", $username); $username = substr($username, 0, e107::getPref('loginname_maxlength')); $aa_sql = e107::getDb('aa'); $userMethods = new UserHandler(); $db_vals = array('user_password' => $aa_sql->escape($userMethods->HashPassword($userpass, $username))); $xFields = array(); // Possible extended user fields // See if any of the fields need processing before save if (isset($_login->copyMethods) && count($_login->copyMethods)) { foreach ($newvals as $k => $v) { if (isset($_login->copyMethods[$k])) { $newvals[$k] = $this->translate($_login->copyMethods[$k], $v); if (AA_DEBUG1) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Alt auth convert", $k . ': ' . $v . '=>' . $newvals[$k], FALSE, LOG_TO_ROLLING); } } } } foreach ($newvals as $k => $v) { if (strpos($k, 'x_') === 0) { // Extended field $k = substr($k, 2); $xFields['user_' . $k] = $v; } else { // Normal user table if (strpos($k, 'user_' !== 0)) { $k = 'user_' . $k; } // translate the field names (but latest handlers don't need translation) $db_vals[$k] = $v; } } $ulogin = new userlogin(); if (count($xFields)) { // We're going to have to do something with extended fields as well - make sure there's an object require_once e_HANDLER . 'user_extended_class.php'; $ue = new e107_user_extended(); $q = $qry = "SELECT u.user_id,u." . implode(',u.', array_keys($db_vals)) . ", ue.user_extended_id, ue." . implode(',ue.', array_keys($xFields)) . " FROM `#user` AS u\n\t\t\t\t\t\tLEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = u.user_id\n\t\t\t\t\t\tWHERE " . $ulogin->getLookupQuery($username, FALSE, 'u.'); if (AA_DEBUG) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Alt auth login", "Query: {$qry}[!br!]" . print_r($xFields, TRUE), FALSE, LOG_TO_ROLLING); } } else { $qry = "SELECT * FROM `#user` WHERE " . $ulogin->getLookupQuery($username, FALSE); } if ($aa_sql->db_Select_gen($qry)) { // Existing user - get current data, see if any changes $row = $aa_sql->db_Fetch(MYSQL_ASSOC); foreach ($db_vals as $k => $v) { if ($row[$k] == $v) { unset($db_vals[$k]); } } if (count($db_vals)) { $newUser = array(); $newUser['data'] = $db_vals; validatorClass::addFieldTypes($userMethods->userVettingInfo, $newUser); $newUser['WHERE'] = '`user_id`=' . $row['user_id']; $aa_sql->db_Update('user', $newUser); if (AA_DEBUG1) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Alt auth login", "User data update: " . print_r($newUser, TRUE), FALSE, LOG_TO_ROLLING); } } foreach ($xFields as $k => $v) { if ($row[$k] == $v) { unset($xFields[$k]); } } if (AA_DEBUG1) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Alt auth login", "User data read: " . print_r($row, TRUE) . "[!br!]" . print_r($xFields, TRUE), FALSE, LOG_TO_ROLLING); } if (AA_DEBUG) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Alt auth login", "User xtnd read: " . print_r($xFields, TRUE), FALSE, LOG_TO_ROLLING); } if (count($xFields)) { $xArray = array(); $xArray['data'] = $xFields; if ($row['user_extended_id']) { $ue->addFieldTypes($xArray); // Add in the data types for storage $xArray['WHERE'] = '`user_extended_id`=' . intval($row['user_id']); if (AA_DEBUG) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Alt auth login", "User xtnd update: " . print_r($xFields, TRUE), FALSE, LOG_TO_ROLLING); } $aa_sql->db_Update('user_extended', $xArray); } else { // Never been an extended user fields record for this user $xArray['data']['user_extended_id'] = $row['user_id']; $ue->addDefaultFields($xArray); // Add in the data types for storage, plus any default values if (AA_DEBUG) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Alt auth login", "Write new extended record" . print_r($xFields, TRUE), FALSE, LOG_TO_ROLLING); } $aa_sql->db_Insert('user_extended', $xArray); } } } else { // Just add a new user if (AA_DEBUG) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Alt auth login", "Add new user: "******"[!br!]" . print_r($xFields, TRUE), FALSE, LOG_TO_ROLLING); } if (!isset($db_vals['user_name'])) { $db_vals['user_name'] = $username; } if (!isset($db_vals['user_loginname'])) { $db_vals['user_loginname'] = $username; } if (!isset($db_vals['user_join'])) { $db_vals['user_join'] = time(); } $db_vals['user_class'] = e107::getPref('initial_user_classes'); if (!isset($db_vals['user_signature'])) { $db_vals['user_signature'] = ''; } if (!isset($db_vals['user_prefs'])) { $db_vals['user_prefs'] = ''; } if (!isset($db_vals['user_perms'])) { $db_vals['user_perms'] = ''; } $userMethods->userClassUpdate($db_vals, 'userall'); $newUser = array(); $newUser['data'] = $db_vals; $userMethods->addNonDefaulted($newUser); validatorClass::addFieldTypes($userMethods->userVettingInfo, $newUser); $newID = $aa_sql->db_Insert('user', $newUser); if ($newID !== FALSE) { if (count($xFields)) { $xFields['user_extended_id'] = $newID; $xArray = array(); $xArray['data'] = $xFields; $ue->addDefaultFields($xArray); // Add in the data types for storage, plus any default values $result = $aa_sql->db_Insert('user_extended', $xArray); if (AA_DEBUG) { $this->e107->admin_log->e_log_event(10, debug_backtrace(), 'DEBUG', 'Alt auth login', "Add extended: UID={$newID} result={$result}", FALSE, LOG_TO_ROLLING); } } } else { // Error adding user to database - possibly a conflict on unique fields $this->e107->admin_log->e_log_event(10, __FILE__ . '|' . __FUNCTION__ . '@' . __LINE__, 'ALT_AUTH', 'Alt auth login', 'Add user fail: DB Error ' . $aa_sql->getLastErrorText() . "[!br!]" . print_r($db_vals, TRUE), FALSE, LOG_TO_ROLLING); $this->loginResult = LOGIN_DB_ERROR; return; } } $this->loginResult = LOGIN_CONTINUE; return; } else { // Failure modes switch ($login_result) { case AUTH_NOCONNECT: if (varset(e107::getPref('auth_noconn'), TRUE)) { $this->loginResult = LOGIN_TRY_OTHER; return; } $username = md5('xx_noconn_xx'); $this->loginResult = LOGIN_ABORT; return; case AUTH_BADPASSWORD: if (varset(e107::getPref('auth_badpassword'), TRUE)) { $this->loginResult = LOGIN_TRY_OTHER; return; } $userpass = md5('xx_badpassword_xx'); $this->loginResult = LOGIN_ABORT; // Not going to magically be able to log in! return; } } $this->loginResult = LOGIN_ABORT; // catch-all just in case return; }
function step7() { $ns = e107::getRender(); $stepCaption = 'Step 7: Calculate user post counts'; if (!isset($_POST['calculate_usercounts'])) { $text = "\n\t\tThis step will calculate post count information for all users, as well as recount all for thread and reply counts.\n\t\t<br /><br />\n\t\t<form method='post'>\n\t\t<input class='btn btn-success' data-loading-text='Please wait...' type='submit' name='calculate_usercounts' value='Proceed with post count calculation' />\n\t\t</form>\n\t\t"; $ns->tablerender($stepCaption, $text); return; } global $forum; require_once e_HANDLER . 'user_extended_class.php'; $ue = new e107_user_extended(); $counts = $forum->getUserCounts(); foreach ($counts as $uid => $count) { $ue->user_extended_setvalue($uid, 'user_plugin_forum_posts', $count, 'int'); } $forum->forumUpdateCounts('all', true); // var_dump($counts); $text = "\n\tSuccessfully recalculated forum posts for " . count($counts) . " users.\n\t<br /><br />\n\t<form method='post' action='" . e_SELF . "?step=8'>\n\t<input class='btn btn-success' type='submit' name='nextStep[8]' value='Proceed to step 8' />\n\t</form>\n\t"; $ns->tablerender($stepCaption, $text); }
if (vartrue($_POST['email2'])) { exit; } $qs = explode(".", e_QUERY); if ($qs[0] != 'activate') { // multi-language fix. e107::coreLan('signup'); //include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE); // include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_usersettings.php"); Shouldn't need this now } e107::coreLan('user'); // Generic user-related language defines define('SIGNUP_DEBUG', FALSE); e107::js('core', 'jquery.mailcheck.min.js', 'jquery', 2); include_once e_HANDLER . 'user_extended_class.php'; $usere = new e107_user_extended(); require_once e_HANDLER . 'validator_class.php'; // require_once(e_HANDLER.'user_handler.php'); $userMethods = e107::getUserSession(); $userMethods->deleteExpired(); // Delete time-expired partial registrations require_once e107::coreTemplatePath('signup'); //correct way to load a core template. $signup_shortcodes = e107::getScBatch('signup'); // $facebook_shortcodes = e107::getScBatch('facebook',TRUE); $signup_imagecode = $pref['signcode'] && extension_loaded('gd'); $text = ''; $extraErrors = array(); $error = FALSE; // ------------------------------------------------------------------ if (!$_POST) {
function sc_user_extended_all($parm) { $sql = e107::getDb(); $tp = e107::getParser(); $template = e107::getCoreTemplate('user', 'extended'); $EXTENDED_CATEGORY_START = $template['start']; $EXTENDED_CATEGORY_END = $template['end']; $EXTENDED_CATEGORY_TABLE = $template['item']; $qry = "SELECT f.*, c.user_extended_struct_name AS category_name, c.user_extended_struct_id AS category_id FROM #user_extended_struct as f\n\t\t\tLEFT JOIN #user_extended_struct as c ON f.user_extended_struct_parent = c.user_extended_struct_id\n\t\t\tORDER BY c.user_extended_struct_order ASC, f.user_extended_struct_order ASC\n\t\t"; require_once e_HANDLER . "user_extended_class.php"; $ue = new e107_user_extended(); $ueCatList = $ue->user_extended_get_categories(); $ueFieldList = $ue->user_extended_get_fields(); $ueCatList[0][0] = array('user_extended_struct_name' => LAN_USER_44, 'user_extended_struct_text' => ''); // print_a($ueFieldList); $ret = ""; foreach ($ueCatList as $catnum => $cat) { $key = $cat[0]['user_extended_struct_text'] ? $cat[0]['user_extended_struct_text'] : $cat[0]['user_extended_struct_name']; $cat_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$this->var['user_id']}}", TRUE); //XXX FIXME Fails $cat_name = true; //XXX TEMP Fix. if ($cat_name != FALSE && count($ueFieldList[$catnum])) { $ret .= str_replace("{EXTENDED_NAME}", $key, $EXTENDED_CATEGORY_START); foreach ($ueFieldList[$catnum] as $f) { $key = $f['user_extended_struct_name']; if ($ue_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$this->var['user_id']}}", TRUE)) { $extended_record = str_replace("EXTENDED_ICON", "USER_EXTENDED={$key}.icon", $EXTENDED_CATEGORY_TABLE); $extended_record = str_replace("{EXTENDED_NAME}", $tp->toHTML($ue_name, "", "defs"), $extended_record); $extended_record = str_replace("EXTENDED_VALUE", "USER_EXTENDED={$key}.value.{$this->var['user_id']}", $extended_record); if (HIDE_EMPTY_FIELDS === TRUE) { $this_value = $tp->parseTemplate("{USER_EXTENDED={$key}.value.{$this->var['user_id']}}", TRUE); if ($this_value != "") { $ret .= $tp->parseTemplate($extended_record, TRUE); } } else { $ret .= $tp->parseTemplate($extended_record, TRUE); } } } } $ret .= $EXTENDED_CATEGORY_END; } return $ret; }