-
Word Press Hacking
Posted on February 5th, 2006 No commentsWell, as per usual, I wanted more out of my WordPress and hence got it. This time, it was searching. I don’t know when the basic searching was added to WordPress, but I really like MySQL’s FULLTEXT matching abilities, so I went to implement them on my site. NOTE: this is not a plugin and does indeed cause you to modify core files. preform at own risk.
I started by copying the searchform.php out of the default template and adding it into my current template’s folder. That is for ease of typing. I then opened my template’s header file (you might put this in sidebar.php also) and added in for it to include searchform.php by writing (note i added a div so i could edit its appearance in css):
I verified that my edits worked and updated my css to display that div as I wanted it. The search should currently work, although poorly. Next, I modified my database. You need to execute the following query on the database that holds your wordpress tables. (You can execute it from the sql input in phpMyAdmin if you have that set up. Note that this assumes the default prefix of wp_ that you should change as appropriate):
ALTER TABLE `wp_posts` ADD FULLTEXT `realsearch` (`post_title`,`post_content`)Next was time to modify the actual search function of WordPress. This is stored in the wp-includes/classes.php and is in the get_posts() function of WP_Query. You need to do the following:- locate line 416 and cut it (it comes after the comment about search pattern and reads
$search = ' AND (';) - add the following after line 424***:
if(strlen($q['s'])>3){
$search .= " AND MATCH(`post_content`,`post_title`) AGAINST('".mysql_escape_string($q['s'])."' IN BOOLEAN MODE) ";
} else { - paste the line below this.
- add a closing brace after the closing brace of the next else (should end on line 448, add another on line 449 so you can read it)
You may want to alter the lines around 580 to have it order by the match…against clause also, but you have to be aware that wordpress will add post_ to the beginning of the $q['orderby'] clause by default. i decided to override the $q['orderby'] with ‘score’ when i was matching fulltext and then editted line 585 (4 for me since i removed part) to add the direct section if needed. the place where $post_ is added was changed also to only occur if it was not matching fulltext.
i tested and made all this on my new child. Her name is Sin. She is a Mac. I am somewhat ashamed to admit how nice it is to work with. More on that later though. To look at my finished file, browse over to http://cardamar.quad341.com/classes.phps. Enjoy.
*** = for some reason, I cannot use IN BOOLEAN MODE on this server but can on my testing server. Just remove it for it to work again. If anyone can explain that, i’d be appreciative.
- locate line 416 and cut it (it comes after the comment about search pattern and reads
-
The harsh truth
Posted on January 29th, 2006 No commentsI’m a nerd. Everyone who visits here should know that. As such, I tinker with everything I have and usually find its limits sooner or later. This is how I have come to appreciate the .Net framework from Microsoft. Honestly, such unity is awesome. It seems rather large and truly limited for the time being, but Vista should make that non-existant.
But… some older boys have been talking to me (my coworkers) and explaining different problems. It goes along with computer problems… and they all get blamed on Microsoft Windows. Granted, a lot of the problems that plague Windows is the users. This is very true. The problem is that Windows has become too open for users, in my opinion. Honestly, why have we allowed people to get so far from standards? For more creativity!
But, no. That isn’t right. It’s like the web standards project. I am a huge advocate of standards (i’m sorry i’m an ass, everyone, but it’s worth it in the end). As such, I have come to see that the only advantages of allowing for non-compliant creations merely makes people able to make things faster and without as much knowldege. But is that better? Read the rest of this entry »
-
Updates
Posted on January 8th, 2006 No commentsOk, well… I updated WordPress to version 2. It’s got a nice backend, though as a user, you might not siee a difference. One nice advangate is that I can upload files for my posts a lot easier… but I don’t remember where they end up… I’ll find out later.
Anyway, my latest endevor was to set up berrydev.net as a site for BlackBerry Developers. I find the wiki system to be a good way to set up information, so I’m going to use that for the moment. It really needs some more configuration for uploads as well as a lot more content (and maybe a logo, but d-ba or russ is making that). Head over there and contribute?
Now for what entertained me earlier today. So i got an email for a topic that I submitted an answer for on Expert’s Exchange and it just happens to be abandoned (it happens a lot). Well, they use intellitext for their ads and it just happens to have made a weird association. Why php makes we want Microsoft online training is beyond me (especially considering their entire site is run by java server pages). See:
-
Catching up and I’m a moron
Posted on January 4th, 2006 No commentsA while ago I promised 2 little scripts. Well, one of them is the source of the index file i use for the cardamar mirror (Source Code). Since I wanted a bit of writing to go with it, i’ll just put it in here:
the script is reletively simple. the top is just the top part of the html and as such can be set up as you desire. inside the php, we first define an array of files we do not want to list. every directory has ‘.’ and ‘..’ meaning current folder and up one level respectively and probably should be ignored. .htaccess is the standard Apache directory settings file and also should be ignored. you also should make sure that you don’t include the file itself and any other files you don’t want to list in the array (in this case, i also exclude source.php). it then opens the current directory (‘./’) and starts looping through all of the files. if it finds it in that array or the file ends with .md5 or .diz, it does not display the file (continue forces the loop into another iteration). if it does find the file, it calculates the filesize in megs (rounded to the nearest tenth). $md5_s is the string that contains all of the md5 information if available. it trys to find the md5 of the file in a file with the exact same name as the file with .md5 at the end. the file contains only the md5 hash. if found, it makes a nicer looking bit of html which will be included. if no md5 can be found, $md5_s is still blank when it is included. the description of the file is found in a file of the same name as the original file with .diz at the end. It then echos all the information in html with heredoc syntax.
Updates: You could easily integrate as much as you wanted of this into a database. I chose not to since there aren’t many files that I am going to need to handle and physical files allows for people to make direct requests to the files without doing any tricks (like setting up a .htaccess file that passes the file name as the parameter and could then query the database for it. somewhat of a demo later). You could still keep the files physical and the md5 and/or descriptions in a database as well, but that would be best suited for large amounts of files (of which you also might want to put pages in as well).
Remember that source.php file that I excluded and that demo i mentioned? well, you can take a look at the source of source.php at http://cardamar.quad341.com/source.phps. funny, that looks like a script that is displaying the source of files, but the files with the parameter of ‘f’ in the get parameters (also note that i deny access to any file that begins with a . since they are supposed to be either hidden or are in another directory except for .htaccess so i can use this to display it). Well, we haven’t been going to http://cardamar.quad341.com/source.php?f=index.php or http://cardamar.quad341.com/source.php?f=source.php to view the source of the files but it does seem that this is what is parsing the files… so what gives? This is where .htaccess redirects comes into play (and why i allow people to see my .htaccess). If we go over to http://cardamar.quad341.com/source.php?f=.htaccess and take a look, you can see a simple example of using mod_rewrite to make the redirection of what seems to be a physical file to actually feed into another file. You can see that it enables the RewriteEngine and then searches for a REQUEST_URI (that’s the part after the domain) that begins with / and ends with .phps and selects everything in between. If it finds this, it feeds it to source.php?f= with after that filled in with the file name with .php on the end. Fun, eh?
Well, that’s one (well…three, but i’m still giving out one more). This other one is just a function. I set it up because someone needed to be able to sort some dates that were formed a specific way. I’m not sure how many people really need to sort dates after they have been put into visual form, but the function will. It searches for the month location and the year location (year is optional though) and then sorts it in order. You can also look at this for an example of using array_multisort. You can see the source of the function here and the output here.
Now for why I’m a moron:
I was waiting for a special person to get online, so i decided i’d message the aol server until they came on. This actually took a while and i had a lot of anger to take out on aol. suddenly the server stops sending me errors. ok, so i guess they signed in. i have since found out that the server just blocked me. it no longer took my messages. this caused some misunderstandings later… but needless to say, i just hate aol more now. -
Tales of Simple Overclocking
Posted on December 29th, 2005 No commentsAnyone who knows me knows that I generally won’t make my computer unstable for any reason. This doesn’t mean I won’t help another person do it. The following is our little adventure with an AMD Athlon X2 3800+ (Stock 2.0 GHz) on an Asus A8N32-SLI Deluxe. As usual, try any of this at your own risk and so forth.
Well, a while ago, I dropped a lot of money to get my own AMD Athlon X2 3800+ and an Asus A8N-SLI Premium with a eVGA 7800 GT for graphics. For Christmas, my friend bought his own similar machine (except he hasn’t received his 2gb of OCZ ram yet) with a better motherboard but same graphics card. Well, we’re cheap so we thought we would try SLI out in his machine (he also has a much nicer Seasonic PSU than my Antec). Considering we can install XP in 7 minutes with SATA RAID 0, we just installed XP again (x86. Driver support in x64 is terrible). After installing the drivers off the cd and the latest WHQL Nvidia Display Drivers (81.97 i think), we ran a benchmark to see stability and check performance. In Aquamark, we were in the 80k range (i think it was like 86k or 87k). We wanted to break 100k points.
Off to the bios. We first incremented to 2.2 ghz (by modifying the FSB and limiting the memory) and checked stability again. All was good. Incremented to 2.3 and something went wacky. It seems that Asus automatically reduced the multiplyer for us. How kind. So we overrode that back to 10 and all was happy. Again, stable but not to 100k. We changed heatsink and fan at this point to make sure that we didn’t have heating problems. Without a really good heatsink around, we used his extra thermaltake (i think? no idea what that was) and a Vantec Tornado 92mm fan (which can levitate itself at full power). This took a bit to get the fan controller hooked up as well, but eventually we were back online.
We chose to increment the FSB by 50 and boot to Windows and make sure it would run CPU-Z and at least one quick test for stability. It worked every time (though it was giving us insanely long boot times. The reason later). At 2.5 ghz, the glorious event occured. We actually topped 101k points (i’ll have to get the screenshot from him). Since we were targetting 2.6 from the beginning as our max, we just upped the fsb the rest of the way and tested again. Again, long boot and then fine. We tested again and got over 102k, but not a good improvement. Now that we were satisfied, I got my graphics card back in my computer and started debugging the problem.
OK, I know it’s driver related. In safe mode, everything seemed nice. So we started installing each driver one at a time and rebooting until one gave us trouble. That happened at the NVidia IDE driver. The problem seemed to go away when we left the NV SW, IDE, and Ethernet drivers off (all of which didn’t seem terribly neccisary when using the Marvel Yukon nic and SATA RAID since Windows had generic ones being used). Later my friend told me that it still does occasionally happen, it’s probably some other driver. Ah well.
Conclusion: the Asus A8N32-SLI overclocks decently; it merely has some driver issues right now.
-
It’s been too long
Posted on December 12th, 2005 No commentsWell, i’ve been busy…
So I’ve written a couple little scripts that I’m going to make available when I have the time to make a decent write-up about them… don’t at the moment.OK, also, I’ve found love at Cardamar Music. Their releases are heaven. Some of the greatest chill. You may recognize Cardamar from the chillout stream on di.fm. Nice guy, great music. I’m currently working on putting up a lot of the mixes he has supplied to me, but they are huge. Uploading takes several tries because there is a glitch and the server doesn’t support resume. *Sigh*.
Oh, and Dofus is great fun. You should join.
-
Site Status and Imagine Cup
Posted on November 13th, 2005 No commentsYesterday, the entire server was offline for a few hours for expected maintenance. Sorry for any inconvienance. It appears that the server upgrade will go on at the same time as this server is running so this site shouldn’t go down again until I go to transfer it.
The Microsoft people got back to me. They are going to work on the registration problem and get back to me some time during the week with when I can register. I felt pretty special receiving the email. Short version:
Dear Jim,
Thank you for contacting us with your question.
[Insert information about problem and project status]
Best Regards and Good Luck!
The Imagine Cup team
I took out the main part since I was wrong about that format but past that, I was pretty close. I spent yesterday setting up my laptop as Server 2003 Sp 1 (for the next 179 days, until the beta runs out) with MSSQL 2005 and C# and ASP Express editions of Visual Studio (all free! Yes, MSSQL is a trial, not the free express edition). I also want my lappy to still play music and do more normal things. Incase anyone else needs the reference, here’s a short list of things to enable and how:
- 3D Acceleration
-
- Open the display properties (right click on background or through control panel)
- Go to the troubleshooting tab
- Slide the hardware acceleration slider all the way to the right
- Sound
-
- Open Sound Properties (from the control panel)
- Flip the checkbox to start the sound service
- Hit OK and reboot
I’m going to hopefully figure out my team within the next couple days and then we can decide on the project. Then comes mapping it out and setting up a loose schedule. Then coding and then testing. Let the games begin!
-
Zend Studio 5: More or Less Review
Posted on November 11th, 2005 No commentsI can’t call this a full fledged review because I don’t have anything set up to really review the new features. At first glance, the improvements seem small. They are not by any means.
CVS/Subversion has been integrated. If you happen to be working on a server with this set up (sourceforge uses this, all you open source people), you can check out your documents and files and do all of your editting straight through ZDE. This is as huge as the ftp support that I fell in love with originally.
FTP support has even been improved: sFTP is now supported. I really like this idea for people who work on things that matter. It’s nice to at least have support for it. I don’t work on those types of things, so it’s not something I can really test.
Code Folding is not as extensive as I hoped it would be. It does exactly what is on the list of new features: you can fold functions, classes, non-php sections and phpDoc sections. Well… that’s nice except we don’t always have the luxery of classes. On something like this, you still are reverting back to the indentation of the braces and putting your cursor at the end to find out how the brace started. It’s useful for just seeing the code (which is very nice when you have a bunch of non-php sections) but I would liked to have seen folding on the other braced sections also so entire if blocks or when loops could be folded but the rest stay visible.
The integrated browser is a massive time-saver for most people. I personally have 2 monitors set up that I use when developing. I use my main one for ZDE and set opera up with “Reload Every:” set so I don’t even have to hit refresh. When I’m doing something smaller or am not at a location where I have the luxery of two monitors, this is a great way to organize. Actually, it still has it’s advantages of trying to analize the web site through the browser also.
If you’re doing PHP development, it’s pretty likely that you are, at one time or another, working on a web site. If you’ve told zce to run your code, you get to look at the html output and try to figure out if everything is right from there. You no longer do. You can change the view of your debug output to show html now. Very nice.
The find file and find resource have limited uses because they restrict themselves to what is open. This is great when you have an entire project open at once, but I personally like to avoid that many open files if possible. You still cannot tell the included file list to open the included files also. That is a huge gripe of mine.
Generally, I cannot say there is any new feature for the casual developer that was added from 4 that I can’t live without. For larger projects, these additions would become very fantastic to have, especially in a corperate environment. You cannot deny that this is the best PHP development enviromnet to work it. It is very effective and incredibly nice to work with. It makes all of your work go faster and helps cut debugging times. I recommend ZCE to all PHP developers. It is worth every penny. You probably don’t need to buy a new liscense to go from 4 to 5 though because unless you work on large projects, the added features will not seem that great.
The changes from back in version 3 when I starte using ZCE to version 5 are all steps in the right direction. I just wish I had a large enough project that I could get the company to use Zend Environment on it. It would be so lovely.
-
Zend Studio 5
Posted on November 10th, 2005 No commentsIt’s officially out of beta! Latest and greatest version of Zend Studio is available. You can go and see a list of the enhancements on the linked page. I’ll download it and try it out later and then write up whether someone whose liscense ran out should re-up. (I love it a lot in version 4, so I can only hope they can amaze me with 5. They do have code folding…)
Go try it, you PHP developer you.
-
Spammers, Please read. Rest, Just skip first paragraph
Posted on November 6th, 2005 No commentsAgain to spammers: I will allow you to have your own personal link as your website. Hell, you can even say something along the lines of “Nice site. Check out mine.” with or without ONE link to your site but not with an ad for it. If I continue to get a lot of these completely spam comments, I will implement capcha’s and cookies and enough to stop your god damn python scripts. Hell, I’ll just block all python scripts if you’re too dumb to even spoof a User-Agent header. You still need a real looking e-mail address (free accounts are fine) also. I’m not even verifying the e-mail accounts at this point in time. Don’t make me change that. If you want to be able to do more, contact me. E-mail quad341
(a-n-t-i-s-p-a-m) gmail (anti-spamm) com and we’ll set something up. Now that i’ve gotten that out of the way, on to what is actually going on. I’ll know about the server in 4 days. I expect it to happen so i’ll probably have some downtime. It always happens.
The Imagine Cup has started. We shall see how that turns out, but I will probably be making posts about that starting on Monday. The registration wasn’t working right so I’m waiting for a response from Microsoft about that. Yes, a personal email from Microsoft. It should read something like
Dear Sir or Madam,
Thank you for your interest in the Imagine Cup. Please know that your concern is of the utmost importance to us.
In response to your question, “[INSERT MY EMAIL, WORD FOR WORD],” the administration has responded, “GENERIC RESPONSE.”
Thank you,
The Imagine Cup Administration.We’ll see.


