What does __FILE__ in php mean?

In php there are a few magic constants and I find FILE to be a very useful one. It returns the full path and filename of the file in question. Take a look at the PHP Manual – Magic Constants for more information on the others.

Woopra Failed to Connect?

I have used Woopra for a few months now and have started seeing this warning/error almost everyday now: Could not enable live functionality at this time. Click to reconnect. If you click the text/warning/error it seems to go away… Anybody konw what’s really going on under the cover? What happened: It turns out Woopra have upgraded their desktop application and will get to the web based application once they are done with everything else.

Change PHP Session Time

The default time for a php session is 1440 seconds. You can change it by doing the following: 1 ini_set("session.gc_maxlifetime",1440); You can obviously adjust the second parameter (1440) to anything you like to change the timeout limit.

Stop mouse click in browsers

There have been multiple ways to stop your user/s from right clicking on your site, but many of them now fail due to the way firefox’s contextual menu loads. Below is an example of how to do it: 1 function _c(e) {if (document.all) {if (event.button==2||event.button==3) {return false;}} else {if (e.button==2||e.button==3) {e.preventDefault();e.stopPropagation();return false;}}if (e.which) {}}if (document.all){document.onmousedown=_c;}else{document.onclick=_c;document.ondblclick=_c;} ..and here is the full working example in a webpage: 1 2 3 4 5 <script><br /> function _c(e) {if (document.

Microsoft apps never care!

I often seem to have this issue when dealing with Microsoft software. You click “Cancel” and it just carrys on going, so you click it again a few more times and instead of it just stopping in it’s tracks, decides to rather tell you it’s cancelling and then shows a cancelling dialog box for the next 10 minutes! Cummon guys, that’s not very professional!

Place HTML Div on top of Flash

If you have ever tried to place a div or similar HTML element on top of a swf flash object you will know that it always tries to take precedence. You will need to do the following: In the code for the flash in the embed area add: 1 wmode="transparent" If you are using SWFObject to insert swf files you can do the following: 1 2 3 4 5 <script type="text/javascript"> var so = new SWFObject("movie.

Stage align and Stage scale in actionscript 3

If you want to position the flash top/left and not have it scale when you resize it’s bounding box window, you can set the following code. 1 2 stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; For full documentation from Adobe take a look here.

Error 406?

So you received an error 406 while trying to upload a file and you have no idea to fix it! Create an .htaccess file in the root of your local website and add the following into it: 1 2 3 4 <IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule>

Firefox error in FeedProcessor.js

[Exception… “Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIChannel.contentType]” nsresult: “0x80040111 (NS_ERROR_NOT_AVAILABLE)” location: “JS frame :: file:///C:/Program%20Files/Mozilla%20Firefox/components/FeedProcessor.js :: FP_onStartRequest :: line 1440” data: no] file:///C:/Program%20Files/Mozilla%20Firefox/components/FeedProcessor.js Line 1440 So what the heck does that all mean? Basically, there is an exception error on like 1440 of the local Firefox javascript file “FeedProcessor.js”. The line in question is as follows: channel.contentType = “application/vnd.mozilla.maybe.feed”; The whole section of code reads as follows: // nsIStreamListener

mySQL select multiple ids

1 SELECT * FROM tablename WHERE `active`='1' AND `id` IN ('107' , '125' ) ORDER BY `id` DESC LIMIT 12`

Force Download in PHP

This script works in all browsers, including Internet Explorer! 🙂 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 if (strstr($_SERVER['HTTP_USER_AGENT'],"MSIE")) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: application-download"); header("Content-Disposition: attachment; filename=\"".basename($filename)."\";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".@filesize($ab_file)); set_time_limit(0); } else { header("Content-type: application-download"); header("Content-Length: ".filesize($ab_file)); header("Content-Disposition attachment; filename=".$filename); } readfile($ab_file);

Remove an onRelease Handler

After creating a onRelease handler in Actionscript 2 as follows: 1 myMovieClip.onRelease = function() { doWhatever(); } ..you then want to remove the handler for whatever reason, you can remove it like this: 1 delete myMovieClip.onRelease;

shortText function toggler in php

I often have to show a shortened version of a news item and then a link to show the entire news article or whatever. Here’s a way to get that short text! 1 2 3 4 function shortText($text, $length) { if( strlen($text) > $length ) return substr(preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $text), 0, $length)."?"; return preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $text); }

PHP – file() lines

1 2 3 4 $lines = file('all-words.txt'); foreach ($lines as $line_num => $line) { echo "Line number ".$line_num; }

Windows Live Writer – Beta2

Start writing content to your blogs from your Windows Desktop now. No need to login to your wordpress backend to post items anymore, there is now a decent desktop application that allows you to do exactly that! I have looked at it before but not until recently when Beta2 came out did I gain more interest for it. The WordPress functionality added is what got me going and now I am able to post directly!

Reported Attack Site!

What the heck is that? So you’ve just visited a website using Mozilla Firefox and this message has popped up telling you that the site looks suspicious. Usually the site has been marked as a possible virus containing website and Firefox will show you this message attempting to protect itself against Malware, Spyware or other forms of Viruses. There are occasions when this is mearly a warning and not to be taken as concrete evidence of viruses or impending browser/computer doom!

Simple HEX Colour Values

Actual Display Colour HEX Colour #000000 #FF0000 #00FF00 #0000FF #FFFF00 #00FFFF #FF00FF #C0C0C0 #FFFFFF

Send Email PHP Function

Ever find yourself typing the headers into the php mail() function over and over again? Try using a standard function and calling it when you need to send mail. 1 2 3 4 function sendEmail($subject,$content,$from,$to){ $header = "Content-Type: text/html; charset=iso-8859-1\nFrom:$from"; if( mail($to, $subject, $content, $header) ); }

mySQL Development Tools

I came across a very interesting article about mySQL Development Tools. http://www.smashingmagazine.com/2009/03/25/mysql-admin-and-development-tools-round-up/