Not-Noticeably.net

Skip navigation

All posts tagged with "WordPress"

How to change your WordPress username

Sick of using the name 'admin' to login to your WP installation? Have a user with the login 'PiNkbUnNiEz!1" but want to change it without that user losing all their posts/creating a new account etc.? Tried to do it but found the field disabled in your WP admin panel?
Here is what you need to do.

  1. Before you do anything, backup your database. If you don't know how to do this, ask at the WP forums or Google it - there are some plugins that will do this for you if you don't have access to things like phpMyAdmin (a MySQL tool which can be used to backup your database - Jem has a tutorial on this which may be useful)

  2. Paste this into a file. Name it anything you like, as long as it has a .php extension:

    <?php
    $existing_username = 'admin';
    $new_username = 'MY_NEW_USERNAME';

    // —————

    if (!file_exists('wp-config.php')) exit('Could not find wp-config.php, please make sure you place this file in the same directory as all your WP files.');

    require 'wp-config.php';

    $link = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if (!$link) exit('Could not connect to MySQL');
    mysql_select_db(DB_NAME, $link) or exit('Could not connect to MySQL');

    if (mysql_query('UPDATE `' . $table_prefix . "users` SET `user_login` = '" . mysql_real_escape_string($new_username, $link) . "' WHERE `user_login` = '" . mysql_real_escape_string($existing_username, $link) . "' LIMIT 1", $link)) echo 'Username updated, your username is now ' . $new_username . '.';
    else echo 'Could not update your username. MySQL said: ' . mysql_error($link);

    mysql_close($link);
    ?>

    Change the first two lines (excluding the one that says '<?php', obviously :P ) to your existing username (probably admin) and your new desired username. Save the file, then upload it to your WordPress directory. Make sure this file is in the same place as wp-config.php.

  3. Go to the file in your browser, e.g. yoursite/wordpress/the-file.php and voilà! :D

"I wrote my own CMS!1!!" - part 2

You may remember my last rant about people who have written their own CMS, in which my point was pretty much that people are copying a simple blog tutorial and saying it's a CMS.

In part two of this thrilling instalment1, I revisit the topic of the custom CMS to rant about the latest craze - which is... well... writing one's own CMS. Everyone and their dog seems to want to do it. It's the thing to do to earn cool points and tell everyone how great you are. I should know, I've done it.

But what I am seeing at the moment is people who have no idea what they're doing. People who simply want to make a CMS because it's cool. When I wrote this CMS, I did it after almost 3 years of being comfortable with the language, knowing exactly what I wanted and what each function does and why. I knew the security implications involved in it, the problems I might experience, the limitations of what I had to work with, etc. I didn't even write my first script until I'd been comfortable with the language for two years. Editing, picking apart other scripts was fine, but my own script? If you ever saw PHPAskIt v1 (it's still out there, worryingly enough) you'll know I wasn't even ready then. However, I'll still admit I only wrote this CMS because I was totally jealous of Jem it was cool. :(

As you may or may not know, I have been learning Ruby on Rails for the past 6 months or so. I am fairly familiar with it at the moment but I am freely able to admit that I am not under any circumstances ready to undertake as large a project as a CMS in it. I don't know how RoR can be exploited, I don't know what sort of problems there are by using X rather than Y - I just don't know enough at the moment. I'm comfortable hacking about existing scripts and adding on little bits and pieces, but that's it.

So my point today is this: before you decide "zomg!1 I must write a CMS!1!!", ask yourself the following questions:

  1. I'm going to be using PHP and MySQL. Do I have enough knowledge in these areas to make my CMS work?
  2. Do I know what the limitations of my server/host/databases are?
  3. Will I have access to PHP4 or 5? What's the difference?
  4. Why am I writing a CMS in the first place? What do I need it to do that others out there can't?
  5. What do I know about security, particularly remote file inclusion, XSS and SQL injection? How will my CMS deal with these areas?
  6. I want my CMS to do X, Y and Z. Do I know how I can achieve this?

If you're unsure of the answers to any of these questions, my advice would be you're not ready yet. Keep looking at existing scripts and see how they're doing things. Search the internet for vulnerabilities in those scripts and how they are exploited to ensure it doesn't happen to you. Get friends to try and break your script as much as they possibly can. I can guarantee that some things normal internet users might do, you'll never think of - for example I found people were trying to go to non-existent tags on my site or page numbers that didn't exist and it caused my site to break.

However, don't think I'm discouraging you from writing a CMS (much :P ). A CMS is the perfect way to develop confidence in a programming language and to learn more about it than you ever could have otherwise. By all means start trying to write your own CMS and learning techniques to make it work the way you want to - but here's the important part: don't put it online. Install yourself a web server (I have XAMPP - very easy to install, has everything you need and installs in a single click. Mac OS X has built-in web server features but you can get XAMPP and other similar packages for it if you're not entirely sure how to use the built-in stuff, I must admit it's always confused me) and develop your up-and-coming CMS there; learn how to interact effectively with MySQL and all that in your own time without hacker types lurking everywhere and undoing all your hard work. I made the mistake of writing the first version of PHPAskIt online and ended up with all sorts of security issues. While I was writing the CMS, it stayed offline for 8 months because I didn't feel it was secure enough to go online - would my host tell me off for too many database queries? Would my PHP version and theirs clash?

Don't think you have to write a CMS just because "everyone else is doing it". You need to feel you can do it and that there is actually a point to doing it. If WordPress or similar does everything you need, is it really necessary? There is no shame whatsoever in using WP. The only reason I stopped using it is because it started to take over my site in ways I really didn't like and I'd modified it so much in the end that every time there was an upgrade I had to update each file individually to make sure it didn't mess with my changes. You also need to make sure you know what you're doing and why you're doing it. If you don't know the slightest bit about PHP, it really isn't worth it.

1 *Cough* ^

Things that annoy me

  1. Idiots who redistribute insecure scripts or scripts that aren't around on the author's site any more.
    I saw a classic the other day: "PHPCurrently (might be hackable) - download here!11one" Might be hackable?! Why on earth would you give it out for others to install then? For your information, PHPCurrently isn't just a "might be" in terms of "hackability" - it's a "definitely".

  2. People who think they know what they're doing and preach about it when they have no idea what they're on about.
    "I LERNT PHP!11!1" No, you learnt PHP includes. "OMFG THATZ LEIK PHP THO I ROOLZ!!11"

  3. WordPress.
    Why are you suddenly not working with my forms any more? I'm not talking about this site - WP (usually) worked fine on here, but it's a client's site. Can't really switch them to my CMS because they need the rich text editor (and no, my CMS doesn't have one :P ). No explanation as to why the form won't work. Same script, same version, same everything... WP just doesn't like it any more. Gah.

  4. University work.
    I have to do my dissertation again, from scratch. The draft I handed in last week was no where near good enough, apparently. Grrr.

  5. Cutenews.
    Now don't get me wrong, I'm sure it's a great script. I've never used it though, and I always associate it with really bad "tween" sites full of rubbish tutorials, stolen layouts and all that. Of course, there are exceptions to those, but still... The URLs are ugly (who wants those long index.php?subaction=showcomments&blahblahblahblah=1&blah=2 things? Not me) and it just ... doesn't appeal to me.

Um, and other things that I can't think of right now. :P

Older Entries