URL Change
As you might have noticed just by coming here, my blog URL has changed. I've changed the URL for personal reasons, though my old url of http://erics.seksibody.com will always forward here. I just wanted to put up a quick post incase anyone was wondering!
PHP and ini_set() – A few things you should know
Today I was writing some code for a website I'm building and came across a problem when trying to set the include path. When I was using set_include_path() and ini_set() to set the include_path, both functions would return false. It took me some time and a bit of help from Davey to finally figure out what was going on.
In my Apache configuration I was using php_admin_value to set an include_path for one of my virtual hosts. If you're not familiar with php_admin_value, you can see the manual page here. By using php_admin_value in the httpd.conf (or a vhost), you're there by telling PHP to force that setting and disallow anything else to change it, meaning PHP scripts or even .htaccess files. That was fine, except what I didn't realize, is that for some reason PHP sees that setting and disallows it to be changed in any other virtual host or PHP script running under Apache. I can only speculate that this behavior is a bug and not intended. I would assume for that value to only affect the virtual host it was declared in, but instead, I spent 30 minutes debugging my code wondering why my calls to set_include_path() were returning false.
Let me just clarify for a second, the virtual host I had php_admin_value on was called, lets say foo.example.com and the code I was working on, that was returning false, was in the virtual host for bar.example.com. So, as soon as I realized that was the only place I was using php_admin_value at was foo.example.com, I changed it to php_value and restarted Apache with the new configuration. Instantly the code on bar.example.com began working as expected and setting my new include_path value. I'm not sure if this is default expected behavior, but it's not what I expected at all. I will be filing a bug report to verify this though.
Well, that was my fun for the evening. I just wanted everyone to be aware of the effects php_admin_value and php_admin_flag have on your Apache configuration. If anyone has any different results or findings, please let me know!
Call of Duty mods
Lately in my spare time, I've been working on something a bit different. Instead of the normal PHP or Python adventures, I've been working with a game language for Call of Duty. It's structured somewhat like C++ but there's quite a few differences. I won't get into them now, but perhaps at a later date I'll post my findings on the language itself, somewhat of a tutorial of sorts. Anyway, I've been working with this language to create my own mod for the game.
Why do I want to do this, you may ask? It's for a few reasons, but mainly because I'm curious and picky. I can't find a mod out there that does everything I like. Out of the mods I can find, I can't find one that works without modification and is easy to add on to. I'm modeling my code closely after another mod that I've downloaded and like, but I'm rebuilding the code, hopefully fixing a few flaws and problems I've seen and ran into with the other mod. I'm also taking things from another mod I like that will add features that aren't in the mod I'm modeling mine after.
I haven't got much done so far, but I'm hoping sometime this week I'll have some actual code that can be tested on my server. I'm going to have quite a few features in it, like the ability to maintain a crouch only server (this means that there is no standing and running, you must remain crouched), user punishment methods, bash only (weapon melee only attack), weapon damage modifiers, weather effects, and lots of other things. I'll make another post explaining more, it's pretty interesting stuff though. Until next time...
Server Move
As some of you may know or have noticed, I've moved my blog to a new server! I'm trying to work the bugs out of everything right now, but it seems to be working good now. If anyone has any problems, please let me know! I'll update later in the week for everything else, I'm just trying to get everything back to normal for now.
wxWidgets and Python
So recently I've been playing with wxWidgets and Python. I've enjoyed it so far, but I've found one problem that I haven't really found a good solution for. When creating a window in Windows, the default background seems to be a rather dark gray. My theme for Windows is the windows classic, which shows all windows as a light grey color. The menu bar and the status bar of the application are the light grey desired, but the background of the application itself and any text label widgets I create are all dark gray. It makes no sense to me.
The solution I've found so far is to set the main window background to the color of the menubar background. This seems to make everything conform to the default light gray. Here's the code from my custom wx.Frame class:
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR))
self.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
This sets the frame's background to the correct expected color. I'm not sure if this is the way I should be going about things since I'm new to wxWidgets, so if anyone has any suggestions for me, please let me know! I'll post an update later this week when I get further along with my client. Right now I've taken a break from the SimpleIRC bot part of things and am creating a GUI interface for a client. Until next time!
SimpleIRC Updates
Well, it's been a little while since I've written about SimpleIRC, so it's time for an update. I've been getting a lot of work done on it during my spare time (which isn't much). I've fixed quite a few bugs in the main Core module and the Client code. I've also added some functionality pretty much everywhere, including some new modules. I still don't know when I'll have an offical release ready, but it's looking promising that it will be soon!
First major change I've made is moving all of the modules off the MySQLdb module and into using SQLAlchemy, which offers a vast variety of methods to interact with the database, as well as support for multiple database backends. The main feature I like about it is the fact that it enables you to create an object for each table and row in the database. It makes dealing with things a lot easier. I also redesigned the database to better support changes made and to add better functionality.
So far, I've got the following modules completely built and working;
- Eval
- Factoids
- Lart
- Seen
- Weather
The Core module is build, but not all the features are there yet. I'm also still working on how the handler methods work for commands, because I'd like to find a way to allow command access levels to be changed on the fly using the database, but still be specified if there is no record in the database. I'm also planning on adding functionality for users to enter their e-mail address for validation and password retreval purposes. I still have to work on the other modules annouced, but it's coming along very nicely so far.
I still have some bugs left to squash, and plenty of functionality in the client itself to implement, so if anyone would like to help as a tester or developer, please let me know. I'll update again soon as I get more accomplished and have more to talk about!
Vista and Google … network problems?
Alright, I admit. I like Vista. I'm a sucker for eye candy and Vista definately has that. I've got Vista installed on my laptop just to give it a test drive. I'm enjoying it so far, but there's one HUGE setback that's really bugging me. I can't reach certian google sites, like Gmail, Google Image Search, just to name a couple. I'm not saying it's only google, I've noticed the issue with CNN.com as well. It just seems very bizzare to me.
I've got a small network setup here at home with 4 computers. One is my server/router. It handles all requests in and out. I then have two desktop computers, one is mine and the other is my girlfriends. Both run Windows XP and I run Gentoo linux. Neither of us have any difficulty getting to any of the web sites mentioned. Now, on the laptop, I run Vista (used to run XP). When it ran XP, I could reach all of the google sites just fine, and CNN.com worked great as well as Gmail and Google Image Search. Now that I have Vista installed, I have random missing images on Google Image Search, and for Gmail, well, I can see the login screen (barely), but not my mailbox. CNN.com just completely hangs when I try to visit it.
I'm absolutely dumbfounded by this behavior. I've had Vista also on both desktops with the SAME issue. It's not just an incompatable NIC because I've tried several NICs through my process of trouble shooting. I've also tried differnet settings and configurations on my router. If anyone has any ideas, or possibly some way I could trace the connection problem down, please let me know!! I'm at my absolute witts end with this. I'm just looking for a way to even find where the connection is stopping... hopefully I can get this solved because I'm sure others out there are having similar issues too.
Edit - 12-11-2008: After doing some extensive testing on this, it really seems to be just an issue of drivers. With newer hardware and drivers, everything has been running fine Vista installs.
Gentoo stage1 install & ccache
Today I was trying to get Gentoo installed on my desktop from a stage1. I wanted the ccache feature enabled, but kept getting errors like the compiler couldn't create executables and such. I went and did a little digging in the Gentoo forums but ended up finding nothing. It then dawned on me what was wrong after retrying without ccache.
When you first emerge ccache, it automatically creates symlinks to itself for your CHOST setting. That means that in /usr/lib/ccache/bin I had i686-pc-linux-gnu-gcc symlinks to ccache. That's why compiles were failing, the compiler didn't exist on my system, but ccache was trying to use it like it did. The simple solution was to run:
ccache-config --remove-links i686-pc-linux-gnu
After using this, things were compiling again using ccache. I do want to note that after sys-devel/gcc emerges during bootstrapping, you'll loose ccache because it will now use the new i686-pc-linux-gnu-gcc compiler instead of ccache. All I did to fix this was pause my bootstrap using Ctrl+Z, then type the command
ccache-config --install-links i686-pc-linux-gnu
and then typed in %1 to resume the boostrap job I just paused. I can't prove that this made it use ccache again, but it eased my mind.
So, to sum it up, if you want ccache when compiling from a stage one, you must use
ccache-config --remove-links i686-pc-linux-gnu
first, then
ccache-config --install-links i686-pc-linux-gnu
after sys-devel/gcc has emerged to make sure ccache works with your new compiler. Hope that helps someone out there!
Product Review: Zend Studio Neon Beta
So, a couple of days ago I got an e-mail from Zend about Zend Studio Neon and their free beta release. I decided sometime yesterday to give it a try. I realize that the new editor is basically a version of Eclipse with PDT installed. I also noticed some other changes such as the Welcome screen is customized for Zend. Nothing special here, but I got past that and into the editor itself.
Now, first let me explain how I use Zend Development Studio right now. Currently I use it for work and a couple of my own projects that all use a SVN backend. I don't have to check them out in ZDE to get SVN working with them, it automatically detects the .svn folders within my project and lets me use SVN functionality. I'm also able to start a new project and easily create it from a folder or group of folders that I select, as well as assign external dependancies to be included while editing. I use the function completion and method completion with classes because I have a horrible memory and cannot remember arguments for some functions I only use every now and then. Beyond that, I don't expect much from ZDE besides the occasional use of the debugger, which has helped me out a few times.
Now, opening Zend Studio Neon, I realize that the editor is still beta, and that it's completely new from ZDE as it's Eclipse with PDT. I remember trying PDT not long ago and wasn't very impressed at all. It seemed to lack a lot of the basic features that ZDE has. OK, so first thing I want, I want to use my existing files and still have SVN access. I have a lot of local changes right now that I don't feel like commiting to break the whole project, so I don't want to check it out fresh again. I start a new PHP Project, type in my project name and change the default directory to where my project currently exists. It creates the project files and opens the project. First thing I check is SVN, it's there and working right off the bat. The PHP Explorer shows my revision numbers and allows me to right click and access the "Team" menu just as Eclipse does. Great, now I know that SVN works fine by default.
Now, lets see how editing files goes... I open up my first file and start typing away. First thing I notice is that it's pointing out a couple of errors to me already. I was using a loop and not using all my variables in the loop, which means in my assignment, I forgot to include the array keys. That could have been bad... good catch! Also, while fixing this problem, I notice that variable completion works, which is no supprise, it also worked in PDT when I tested it. Now, I open another file and find it's got a few errors in it as well. Some things are notifying me of unused variables in methods for my XML parser, others are telling me of issues where I misspelled a variable and it thinks it's undefined. Great, fix the ones that can be fixed and move on.
Now I wanted to test the function/method completion. This is one thing about PDT I wasn't completely satisfied with, but it appears to work well in Zend Studio Neon Beta. I created a new method in a parent class, then in the child class that extends it I implemented the functionality. When I start typing $this-> it then pops up a window with all my methods in the class, including the ones in the parent and the one I just created. For those methods that have phpdoc comments, it also fills in the types for the arguments and return value. I write my method out and save, everything looks good and I'm deffinately enjoying this better than just Eclipse and PDT. Now, one thing I didn't mention earlier which I noticed while making changes and saving files.. in my PHP Explorer where it shows my SVN versions, on the files I've modified, there is now a > infront of them signifying that they're changed. I prefer the old style where the color changed, but I can deal with this too, and it might be customizable.
So far my experiance with Zend Studio Neon Beta has been pretty plesant. When I first installed it I had a couple of issues that were a bit confusing. I blame windows though, because after rebooting and opening it up again, everything seems to work as expected. Also, one other feature I didn't get to is the phpdoc strings. It works about the same as it did in ZDE wheren when you type /** and hit enter before a method, it inserts the doc tags as expected. I can say that I like it so far, especially the fact that they're using Eclipse. I've been a fan of Eclipse for a few months now because of how easy it is to install plugins. I've been using eclipse for Python and C within the past few montsh, and now I can use Zend Neon for PHP. I also checked the Help menu where you can access the Software Updates to install new plugins. This means that I can most likely add PyDev and CDT for my Python and C needs, great! For now it looks like I'm back down to one error instead of three.
I'll post more later if I find some other interesting features of Zend Neon or if I find any problems.
SimpleIRC Update
SimpleIRC works! I've gotten the bot connecting to IRC and responding to commands. I've rewritten how the commands are handled and where they are stored. Previously, all commands, help text, usage, and access levels were stored in the module itself. I've made this to be more user friendly now by moving all of that to the database. I still need to do a little work on commands, but they are working! With all of that working, I can now start developing all the features of the bot. In case some of you missed it, or I forgot something, I'll list all planned modules and features.
The bot will contain core features of account management (register, login, set access level, change password), channel management (join, part) as well as commands to show basic statistics about the bot, commands, and the system it's running on. The stats will also extend to include an API for modules. This will enable each module to add a stats method that can be called by a specified command to the stats command.
Another module I'm adding to the bot is a Google search module. I will be rewriting this from the previous version which uses SOAP to use the new AJAX interface. The reason behind this is that Google is no longer releasing API keys required for SOAP. I'm not sure what effect this will have on the search module, but I'm hoping none.
I've also planned on adding a factoids module that will work similar to the one in the previous version. The new addition to this new version is that when using the bots nickname to trigger a factoid, it will also translate to perform commands if no factoid exists for that trigger. That means that saying "miniE: help" will trigger the help command if no factoid for "help" exists.
Those are the major changes I have planned so far. The following are other modules planned on being included.
- Bartender - This is a fun module that will serve up mixed drinks, shots, or just beer on command.
- Eval - A module to enable code evaluation. So far only PHP is planned to be supported, but I'd like to extend on that later.
- Lart - Want to hurt someone? Lash out at them with larts!
- Function Reference - Lookup a funcref for PHP4, PHP5, HTML, CSS1, CSS2, DOM1 and DOM2. Future plans to support other languages as well.
- Weather Lookup - Find the current temperature for your area!
- Temperature Conversion - Convert from F to C, C to F, F to K, C to K, K to F, or K to C
- Spell Check - Triggered by command or by adding (sp?) after a word to verify the spelling.
- Karma - Adds karma to users accounts. If no account is found for the user, karma is kept for the unknown user.
- Seen - Keep track of when the last time someone was on the channel and when they left.
- Validator - Validate your HTML and CSS documents right through IRC
That concludes the current list I have. If anyone else has any ideas for new modules or reccomendations of items to add to my current list, please let me know! I'm always open to any contribution.
Update: Sept. 30, 2007
I've also got trac running for the SimpleIRC project. If you would like to view it, please visit http://trac.php-oop.net/SimpleIRC/