You shouldn’t use this function on untrusted data, but if you clean it up – and know what the expected variables will be called – this is a handy function. Here an example $_POST: First clean the input: Now extract the key-value pairs into varname-values: There’s a pile of constants that control behaviour in case… Read more »
Posts Categorized: PHP
There are times when you need to get an SQL dump of a database but you don’t have access to management tools AND system(), exec() and passthru() commands are disabled. This script from David Walsh will do the trick:
Here’s an example of adding a leading zero to columns 2 and 3 of the CSV file:
Timthumb is a great tool for cropping/resizing images dynamically at the time the page loads. But what if you want to update the src of an image tag with a new image, for example, in an image carousel? You can use timthumb via an ajax call, but the resulting data is binary so you have… Read more »
Here are two examples of getting attribute values using an xpath query: one using simpleXML and one using DOM document. Both queries are on namespaces within the XML file. First here’s the DOM Document version: … and the SimpleXML version:
Here’s a simpleXML script I used to parse a feed. There are MP3 links that are under the namespace xmlns:media=”http://search.yahoo.com/mrss/”. The links are in the feed like this: To get at the url attribute you first have to access the ‘media’ namespace by using children(‘media’,true). This tells the parser to find children of the namespace… Read more »
Thanks to Jaygilford.com Also note, you can use vsprintf to supply an array as an argument, and also take a look at the WordPress function $wpdb->prepare():
I need a script to extract the database details from the wp-config.php file so I could keep the logon details in one location when I was coding something outside the WP framework. I came up with a class that does this, connects to mysql and selects the database. There are three connection options: PDO, mySQLi… Read more »
Well I thought I would try XML-RPC publishing in a WordPress blog. The main advantage I see in using RPC vs. email publishing is the use of font–styles. It also works with my SyntaxHighlighter plugin… I’m using the ScribeFire plugin for Firefox to write this blog, but Microsoft Live Writer looks like a good desktop… Read more »
Use the following link and just change the category id: index.php?option=com_content&view=category&id=1&format=feed&type=rss See this link… there might be a better way in Joomla 1.5.22+ but this works fine. Link
I was recently trying to upload a plugin to WordPress and found that the plugin could not create a directory. The problem was not directory permissions – it was user/group ownership. PHP running as fastCGI is running as user nobody on my VPS. I tried changing directory perms to 777 for wp-content/uploads and wp-content/plugins but… Read more »
It’s useful to know that you can easily hack a Joomla module by opening the relevant module in the /modules directory. Edit the XML file for admin panel entries. Edit the mod_xxx.php file and the helper.php files for the PHP, or edit the file in the tmlp directory for the page HTML. Realy simple!
If you’re Joomla 1.5 back-end suddenly displays bullets everywhere… you’ve enabled debug mode in the system Global Settings… duh!