示例#1
0
function gom_config_settings_array()
{
    global $wpdb;
    $admin_users = $wpdb->get_results("SELECT user_id FROM gom_permissions WHERE action = 'admin'");
    $users = gom_get_user_list();
    foreach ($users as $user) {
        $users_array_by_id[$user->ID] = $user;
    }
    $ret = array();
    $ret['GPDB_NAME'] = 'constant';
    $ret['GPDB_USER'] = '******';
    $ret['GPDB_PASSWORD'] = '******';
    $ret['GPDB_HOST'] = 'constant';
    $ret['GPDB_CHARSET'] = 'define';
    $ret['GPDB_COLLATE'] = 'define';
    $ret['GP_AUTH_KEY'] = 'constant';
    $ret['GP_SECURE_AUTH_KEY'] = 'constant';
    $ret['GP_LOGGED_IN_KEY'] = 'constant';
    $ret['GP_NONCE_KEY'] = 'constant';
    $ret['GP_LANG'] = 'define';
    $ret['CUSTOM_USER_TABLE'] = 'constant';
    $ret['CUSTOM_USER_META_TABLE'] = 'constant';
    $ret['gp_table_prefix'] = 'variable';
    $ret['GP_GOOGLE_TRANSLATE_KEY'] = 'define';
    $ret['GP_GOOGLE_TRANSLATE'] = 'define-bool';
    foreach ($admin_users as $user) {
        $name = strtoupper($users_array_by_id[$user->user_id]->user_login);
        $ret['GP_GOOGLE_TRANSLATE_KEY_' . $name] = 'define';
    }
    $ret['GP_USE_SLUG_FOR_DOWNLOADS'] = 'define-bool';
    $ret['GP_REMOVE_PROJECTS_FROM_BREADCRUMS'] = 'define-bool';
    $ret['GP_REMOVE_PROJECTS_FROM_BREADCRUMS_LOGO_URL'] = 'define';
    $ret['GP_WORDPRESS_SINGLE_SIGN_ON'] = 'define-bool';
    $ret['AUTH_CLASS'] = 'constant';
    $ret['AUTH_CLASS_FILE'] = 'constant';
    $ret['GP_WORDPRESS_HASH'] = 'constant';
    $ret['GP_AUTH_COOKIE'] = 'constant';
    $ret['GP_SECURE_AUTH_COOKIE'] = 'constant';
    $ret['GP_LOGGED_IN_COOKIE'] = 'constant';
    $ret['GP_AUTH_SALT'] = 'constant';
    $ret['GP_SECURE_AUTH_SALT'] = 'constant';
    $ret['GP_LOGGED_IN_SALT'] = 'constant';
    $ret['GP_NONCE_SALT'] = 'constant';
    $ret['GP_NEW_WINDOW_FOR_EXTERNAL_LINKS'] = 'define-bool';
    $ret['GP_REMOVE_POWERED_BY'] = 'define-bool';
    $ret['GP_BULK_DOWNLOAD_TRANSLATIONS'] = 'define-bool';
    $ret['GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_PO'] = 'define-bool';
    $ret['GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_MO'] = 'define-bool';
    $ret['GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_ANDROID'] = 'define-bool';
    $ret['GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_RESX'] = 'define-bool';
    $ret['GP_BULK_DOWNLOAD_TRANSLATIONS_FORMAT_STRINGS'] = 'define-bool';
    $ret['GP_BULK_DOWNLOAD_TRANSLATIONS_TEMP_DIR'] = 'constant';
    $ret['GP_SSL'] = 'define-bool';
    $ret['GP_FORCE_SSL'] = 'define-bool';
    $ret['HTTP_X_FORWARDED_PROTO'] = 'code-bool';
    $ret['advanced_gpconfig'] = 'text';
    return $ret;
}
示例#2
0
function gom_users_page()
{
    global $gpdb, $gom_utils;
    $is_admin = current_user_can('manage_options');
    if (!$is_admin) {
        echo '<div class="update-nag"><p>' . __('You do not have permissions to this page!') . '</p></div>';
        return;
    }
    $table_prefix = gom_get_gp_table_prefix();
    if (array_key_exists('add-user', $_POST)) {
        if (array_key_exists('add_login_name', $_POST)) {
            $user_login = $_POST['add_login_name'];
            $user_nicename = $user_login;
            $display_name = $user_login;
            $user_email = '';
            $user_url = '';
            $user_registered = date("Y-m-d H:i:s");
            $user_status = 0;
            $passowrd = '';
            if (array_key_exists('add_nice_name', $_POST)) {
                if ($_POST['add_nice_name'] != '') {
                    $user_nicename = $_POST['add_nice_name'];
                }
            }
            if (array_key_exists('add_display_name', $_POST)) {
                if ($_POST['add_display_name'] != '') {
                    $display_name = $_POST['add_display_name'];
                }
            }
            if (array_key_exists('add_email', $_POST)) {
                if ($_POST['add_email'] != '') {
                    $user_email = $_POST['add_email'];
                }
            }
            if (array_key_exists('add_url', $_POST)) {
                if ($_POST['add_url'] != '') {
                    $user_url = $_POST['add_url'];
                }
            }
            if (array_key_exists('add_password', $_POST)) {
                if ($_POST['add_password'] != '') {
                    $password = wp_hash_password($_POST['add_password']);
                }
            }
            $sqlstring = $gpdb->prepare('INSERT INTO ' . $table_prefix . 'users (user_login, user_nicename, display_name, user_email, user_url, user_registered, user_status, user_pass) VALUES (%s, %s, %s, %s, %s, %s, %d, %s );', $user_login, $user_nicename, $display_name, $user_email, $user_url, $user_registered, $user_status, $password);
            $gpdb->query($sqlstring);
        } else {
            echo '<div class="update-nag"><p>' . __('Please select a user to add!') . '</p></div>';
        }
    } else {
        if (is_array($_POST)) {
            foreach ($_POST as $key => $value) {
                if (substr($key, 0, 12) == 'delete-user-') {
                    $user_id_to_delete = intval(str_replace('delete-user-', '', $key));
                    if ($user_id_to_delete > 0) {
                        $sqlstring = $gpdb->prepare('DELETE FROM ' . $table_prefix . 'users WHERE ID=%d;', $user_id_to_delete);
                        $gpdb->query($sqlstring);
                        $sqlstring = $gpdb->prepare('DELETE FROM ' . $table_prefix . 'usermeta WHERE user_id=%d;', $user_id_to_delete);
                        $gpdb->query($sqlstring);
                    } else {
                        echo '<div class="update-nag"><p>' . __('Invalid user selected to remove!') . '</p></div>';
                    }
                }
                if (substr($key, 0, 9) == 'pw-reset-') {
                    $user_id_to_reset = intval(str_replace('pw-reset-', '', $key));
                    if ($user_id_to_reset > 0) {
                        if (array_key_exists('password-' . $user_id_to_reset, $_POST)) {
                            $password = $_POST['password-' . $user_id_to_reset];
                            if ($password != '') {
                                $password = wp_hash_password($password);
                                $sqlstring = $gpdb->prepare('UPDATE ' . $table_prefix . 'users SET user_pass=%s WHERE ID=%d;', $password, $user_id_to_reset);
                                //$gpdb->query( $sqlstring );
                            }
                        }
                    } else {
                        echo '<div class="update-nag"><p>' . __('Invalid user selected to remove!') . '</p></div>';
                    }
                }
            }
        }
    }
    $users = gom_get_user_list();
    echo '<div class="wrap">' . "<br>";
    echo '	' . screen_icon('options-general') . "\n";
    echo '	<h2>' . __('User Management') . '</h2>' . "\n";
    echo '	<br>' . "\n";
    gom_confirm_delete_javascript();
    echo "\n";
    echo '<form method="post">';
    echo '		<table class="widefat">' . "\n";
    echo '			<thead>' . "\n";
    echo '			<tr>';
    echo '				<th>' . __('ID') . '</td>' . "\n";
    echo '				<th>' . __('Login Name') . '</td>' . "\n";
    echo '				<th>' . __('Nice Name') . '</td>' . "\n";
    echo '				<th>' . __('Display Name') . '</td>' . "\n";
    echo '				<th>' . __('E-Mail') . '</td>' . "\n";
    echo '				<th>' . __('URL') . '</td>' . "\n";
    echo '				<th>' . __('Registration Date') . '</td>' . "\n";
    echo '				<th>' . __('Status') . '</td>' . "\n";
    echo '				<th>' . __('Password') . '</td>' . "\n";
    echo '				<th>' . __('Action') . '</td>' . "\n";
    echo '			</tr>' . "\n";
    echo '			</thead>' . "\n";
    echo '			<tbody>' . "\n";
    $alternate = false;
    foreach ($users as $user_obj) {
        if (!$alternate) {
            $alternate = true;
            $class = ' class="alternate"';
        } else {
            $alternate = false;
            $class = '';
        }
        echo '			<tr' . $class . '>' . "\n";
        echo '				<td>' . esc_html($user_obj->ID) . '</td>' . "\n";
        echo '				<td>' . esc_html($user_obj->user_login) . '</td>' . "\n";
        echo '				<td>' . esc_html($user_obj->user_nicename) . '</td>' . "\n";
        echo '				<td>' . esc_html($user_obj->display_name) . '</td>' . "\n";
        echo '				<td>' . esc_html($user_obj->user_email) . '</td>' . "\n";
        echo '				<td>' . esc_html($user_obj->user_url) . '</td>' . "\n";
        echo '				<td>' . esc_html($user_obj->user_registered) . '</td>' . "\n";
        echo '				<td>' . esc_html($user_obj->user_status) . '</td>' . "\n";
        echo '				<td><input type="text" size="10" name="password-' . $user_obj->ID . '"></td>' . "\n";
        echo '				<td><input type="submit" name="pw-reset-' . $user_obj->ID . '" value="' . __('PW Reset') . '" class="button-primary"></input>&nbsp;&nbsp;<input type="submit" name="delete-user-' . $user_obj->ID . '" value="' . __('Delete') . '" class="button-primary" onclick="return GOMConfirmAction(\'' . __('Are you sure you wish to delete this user?  This cannot be undone!') . '\')"></input></td>' . "\n";
        echo '			</tr>' . "\n";
    }
    echo '			<tr' . $class . '>' . "\n";
    echo '				<td></td>' . "\n";
    echo '				<td><input type="text" size="10" name="add_login_name"></td>' . "\n";
    echo '				<td><input type="text" size="10" name="add_nice_name"></td>' . "\n";
    echo '				<td><input type="text" size="10" name="add_display_name"></td>' . "\n";
    echo '				<td><input type="text" size="20" name="add_email"></td>' . "\n";
    echo '				<td><input type="text" size="15" name="add_url"></td>' . "\n";
    echo '				<td></td>' . "\n";
    echo '				<td></td>' . "\n";
    echo '				<td><input type="text" size="10" name="add_password"></td>' . "\n";
    echo '				<td><input type="submit" name="add-user" value="' . __('Add') . '" class="button-primary"></input></td>' . "\n";
    echo '			</tr>' . "\n";
    echo '			</tbody>' . "\n";
    echo '		</table>' . "\n";
    echo '</form>' . "\n";
    echo '</div>' . "<br>";
}