33,000 hits and over 14Gb of traffic in two days? April 8, 2008
Posted by Lucanos in : programming, wordpress , add a commentHow, you may ask? Simple, I say - I was Hacked. The logs I have managed to extract from my server are sketchy at best, but I was lucky enough to be assisted by Kevon of TailRank.com who was very generous with his time and clued me into why I was being crippled by bandwidth overheads when his servers were doing their normal polling activity. (NOTE: TailRank were NOT responsible in any nature for this attack.)
Symptoms:
- Massive pagesize increase.
In my case a 61Kb page spooled into a 600Kb page due to the link insertion. - Bandwidth load increase.
A 900% increase in pagesize, mixed with increased traffic as the spiders start falling for the trap, will blow your bandwidth quota away.
Treatment:
- Check your WordPress Template’s Footer and Header files (normally footer.php and header.php respectively). There will be a massive collection of dodgy links (all hosted on similarly compromised WordPress installations).
- Delete the links manually.
- Unless you are constantly tweaking your WordPress template, lock down the permissions.
In SSH run “chmod -R 644 wp-content/themes” (from your WordPress root folder).
This will allow the system to Execute and Read your Themes, but not to Write to them. - When you have a chance, Upgrade your WordPress Installation.
Causes:
- I have poked around some of the links which were inserted by the Hacker and found that the content being loaded points to Seo52 as the culprit (or at least, accomplice) of this hack.
Email Regular Expression June 10, 2006
Posted by Lucanos in : javascript, programming, php, snippet , 1 comment so farI found a site which had a very good regular expression to test email addresses, at http://www.codetoad.com/asp_email_reg_exp.asp.
However, one slight modification to their original test, which has been annoying me a bit as of late, is the addition of the plus symbol “+” as an acceptable character in the middle of the username section.
A terrific tool to test Regular Expressions is available at http://www.cuneytyilmaz.com/prog/jrx/. Well worth a visit.
The reason I have been using the “+” symbol and been running into lesser validators, is because GMail allows you to tack on tags behind your username to help you sort and manage your email inbox.
So I can subscribe to a newsletter with the address “lucanos+newsletter@gmail.com” (as “lucanos” is my GMail username) and then setup my GMail inbox rules so those emails are handled in a specific way.
It’s also a good way to identify sites which are selling your address, or spamming/ all you do, if required to provide an email address, is create one in the format “GMailUsername+SiteDomain@gmail.com“. Then, if I get spam to that specific email address I know where they got it from, as the culprit’s name will be included in the destination address.
Pretty tricky, hey?
Eternal Copyright May 25, 2006
Posted by Lucanos in : Uncategorized, programming, php, snippet , 1 comment so farNow, for the most part, I don’t like copyright. I far prefer the far more community-minded and development-driving concepts of copyleft, GPL and creative commons. The only times I use copyright is when it comes to my photography (especially for commercial uses) and major software work (like a contract or a large project).
Copyright, from my understanding, is established by simply putting the copyright symbol “©” (”Alt-0169″ in most word processors and “&0169;” in HTML) the word “Copyright”, your name or business name, and then the year. The year is meant to be the year the item/photo/whatever was first created, and then, if it was updated after that time, it’s meant to have a dash, then the most recent year when a change was made.
This is all well and good when dealing with something static. Like a plain vanilla HTML page with static information, or a photo, or something that doesn’t change. But what about dynamic pages? What about pages like those served using a Content Management System, or your own PHP & SQL concoction? With those kinds of items, the content is constantly changing (or has the potential to do so), so the year section in the copyright notice also needs to be chaning constantly.
How to do it…
Easy, provided you have the ability to write PHP code into your page templates. In WordPress that shouldn’t be too hard. I know that in TextPattern all you do is put the PHP betweeen the … tags. The rest? Do a little research, and if you still have problems, let me know…
The code?
$startYear = 2006; // The start year
$currYear = date(”Y”);
echo $startYear.( $currYear > $startYear ? ” - “.$currYear : “” );
All you do is put the “&0169; Copyright John Smith ” in front of that baby and Bob’s your aunty’s live-in-lover.
If you have any problems with this snippet, or any suggestions, please feel free to comment here and I’ll see what I can do to assist.
UPDATE
I have created a TextPattern Plugin to automate the insertion of these notices, as per above. The plugin, when given a start year, generates the dynamic year range (e.g. “2000-2006″) and includes the Copyright Symbol.
Download it here.
WordPress - StatCounter Plugin April 17, 2006
Posted by Lucanos in : programming, php, wordpress , 32 commentsI developed this (my first WordPress plugin) based extensively on the works of Ronald Heft, Jr. and his terrific WordPress Plugin “Google Analyticator“.
I learnt a fair bit whilst adapting his plugin to the StatCounter tracking system, and I am sure that any further developments on my part will surely incorporate some of teh terrific ideas used by Ronald in his plugin. No point re-inventing the wheel, after all…
Instructions:
- Click HERE for a zipped version of the file.
- Unzip this file and upload the enclosed PHP file into your “wp-content/plugins” folder.
- Go to your Plugin screen in your WordPress admin console.
- Fill out the details, as per the instructions.
- Switch the plugin over to Enabled.
- Watch your StatCounter counters start ticking over.
- Enjoy!
Any suggestions, feedback, ideas, complaints, virgin offerings are more than welcome.
CSS Order Of Precedence April 8, 2006
Posted by Lucanos in : programming, CSS , add a commentJust thought I would share this tidbit, as I was unaware of it, and couldn’t find it when I did a quick search of the net…
When processing CSS rules, it seems that the styles are applied in the following order of precedence:
- Style
- ID
- Class
So any CSS coding applied via the Style attribute will over-write and out-rank any styling applied via the ID. And so forth.
But, this is just the results of my testing. So if anyone knows any better, please do let me know.
TextPattern Hack - Tags in CSS April 7, 2006
Posted by Lucanos in : programming, php, textpattern , add a commentI was recently put onto TextPattern, an Open-Source Content Management System, by one of my workmates. I have been working on a project for my employer, and, as I was already somewhat familiar with this CMS, we developed the internal website using this package.
One of the aspects of the TextPattern CMS which I found lacking, was that the CSS data, stored within the database, was unable to be dynamically changed and interacted with using the TextPattern markup language, plugins and/or PHP, even though that functionality is available within the page content and articles themselves.
As a result I have hacked the css.php file, used by TextPattern to render the CSS information.
Instructions:
- Download this file - css.zip
- Unzip it into the “/textpattern” subdirectory of your TextPattern installation.
(It will need to replace a file called “css.php” in order to work) - Enjoy!
Any problems, let me know.
TextPattern Plugin - les_rss2html
Posted by Lucanos in : programming, php, textpattern , add a commentMy first plugin… {sigh}.
Well, maybe not my first, but the first one I have decided to publicly release.
This one allows for RSS Feeds to be processed and inserted into a webpage, using replacement tags.
It’s actually a ported version of one I found from FeedForAll, who offer a free PHP script called RSS2HTML(download) which does this work. I simply modified it so as to use the TextPattern plugin format - for those people who would prefer to work with it that way…
Here it is. Help is included within the Plugin itself.
TextPattern Plugin - les_rss2html_v0_1.txt
DeviantART - Full-Viewer March 25, 2006
Posted by Lucanos in : programming, javascript, greasemonkey , 1 comment so far“If you have 17 inches, why not use all of it?“™
This GreaseMonkey userscript changes all links inside DeviantART.com and DeviouslyArtistic.com so that they point at the full-resolution image, rather than at the smaller preview page. Very handy when you are looking through alot of deviantions, as it cuts your clicks down by up to 50%! I created this userscript in August 2005. It was my first userscript, and, as such, started with a very simple, very clunky, very… inefficient way to perform the required actions. This script has been updated a number of times since then, fixing little glitches here and there.
UPDATE (2006/05/26):
Version History:
- v0.5 - 25 March 2006 Resolved a glitch which was preventing the “Move to Scraps” button from working. (It only seems to like links with “*/deviation/*” in them.)
v0.4- 22 January 2006 Resolved a long-term bug, restoring expected operations to the “Zoom Out” button.v0.3.2- 05 November 2005 (Failed) Attempt to resolve a long-term bug affecting the operations of the “Zoom Out” button.v0.3.1- 05 November 2005 (Failed) Attempt to resolve a long-term bug affecting the operations of the “Zoom Out” button.v0.2- 05 November 2005 Removed a section of the script which changed the link title. (Was part of initial debugging.)v0.1- 05 August 2005 Initial release.
How It Does What It Does:
- Create an array of all links on the page, using XPath.
- Identify the “Zoom Out” button, if present on the page
- Evaluate each of the links in turn.
- If the following conditions are matched, a replace is done changing “/deviation/” to “/view/” within the link’s href attribute.
- If there is no “Zoom Out” button OR the current link is not the “Zoom Out” button.
- If the current link does not end with “/scrap”
Enjoy!
DeviantART - Random Love January 16, 2006
Posted by Lucanos in : programming, javascript, greasemonkey , add a comment“Have you spread some Random Love today?“™
Share The Love!
This script adds buttons directing the user to A Random Deviant and/or a A Random Deviation to the main toolbar at the top of the screen (just beside the Shop button).
Version History:
- v0.1 - 16 January 2006
Initial release.
How It Does What It Does:
- Finds the Toolbar (using an XPath).
- Creates the Random Buttons (including Base64 encoded icons - they’re embedded in the script)
- Inserts them after the Shop Icon
- Changes their titles (A workaround, still figuring the cause there…)
Enjoy!
Will-Get Widgets - Konfabulator (Yahoo! Widgets) December 16, 2005
Posted by Lucanos in : programming, javascript, greasemonkey , add a comment“Who says you have to go through B to travel from A to C?“™
After enduring the less-than-perfect interface provided by the Yahoo! Widgets Repository, (which involves a redirecting page to download the widget file, which invariably redirects you to the begining of the collection after each download) for more than I could handle (5 minutes), I decided that a GreaseMonkey solution was warranted.
Version History:
- v0.1 - 16 December 2005
Initial release.
How It Does What It Does:
This script reads each of the links on any page within the Yahoo! Widgets galleryand, upon finding a link to the despised redirect page, changes it to point to the actual download page which the redirect page fires off.
Enjoy!