Пример #1
0
/**
 *	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!
}
Пример #2
0
if (isset($_POST['add_field'])) {
    $ue_field_name = str_replace(' ', '_', trim($_POST['user_field']));
    // Replace space with underscore - better security
    if (preg_match('#^\\w+$#', $ue_field_name) === 1) {
        if ($_POST['user_type'] == EUF_DB_FIELD) {
            $_POST['user_values'] = array($_POST['table_db'], $_POST['field_id'], $_POST['field_value'], $_POST['field_order']);
        }
        $new_values = $user->make_delimited($_POST['user_values']);
        $new_parms = $tp->toDB($_POST['user_include'] . "^,^" . $_POST['user_regex'] . "^,^" . $_POST['user_regexfail'] . "^,^" . $_POST['user_hide']);
        // Check to see if its a reserved field name before adding to database
        if ($ue->user_extended_reserved($ue_field_name)) {
            // Reserved field name
            $message = "[user_" . $tp->toHTML($ue_field_name) . "] " . EXTLAN_74;
            $message_type = E_MESSAGE_ERROR;
        } else {
            $result = $mes->autoMessage($ue->user_extended_add($ue_field_name, $tp->toDB($_POST['user_text']), intval($_POST['user_type']), $new_parms, $new_values, $tp->toDB($_POST['user_default']), intval($_POST['user_required']), intval($_POST['user_read']), intval($_POST['user_write']), intval($_POST['user_applicable']), 0, intval($_POST['user_parent'])), 'insert', EXTLAN_29, false, false);
            //	$result = $mes->autoMessage($ue->user_extended_add($ue_field_name, $tp->toDB($_POST['user_text']), intval($_POST['user_type']), $new_parms, $new_values, $tp->toDB($_POST['user_default']), intval($_POST['user_required']), intval($_POST['user_read']), intval($_POST['user_write']), intval($_POST['user_applicable']), 0, intval($_POST['user_parent'])), 'insert', EXTLAN_29, false, false);
            if (!$result) {
                $message = EXTLAN_75;
                $message_type = E_MESSAGE_INFO;
            } else {
                $admin_log->log_event('EUF_05', $ue_field_name . '[!br!]' . $tp->toDB($_POST['user_text']) . '[!br!]' . intval($_POST['user_type']), E_LOG_INFORMATIVE, '');
                e107::getCache()->clear_sys('user_extended_struct', true);
            }
        }
    } else {
        $message = EXTLAN_76 . " : " . $tp->toHTML($ue_field_name);
        $message_type = E_MESSAGE_ERROR;
    }
}
if (isset($_POST['update_field'])) {