PHP

List Dropbox folder content in a website - php snippet

This is a quick and dirty PHP script, to embed the contents of a publicly accessible Dropbox folder as a list of files within your website. Use at your own risk!

PHP write to file

One of those simple functions that I'm always using. It writes the given string to the end a file. If the file doesn't exist, then it creates it.

$err = write_to_end_of_file("some text", "A_file_name.txt");
if($err) print $err; // If there's been an error let us know
 
function write_to_end_of_file($str, $filename){
	if(!file_exists ($filename )){
		$fp = fopen($filename,"w"); 
		fwrite($fp, '');
		fclose($fp);
	}
	// Read & save old contents
	$old = file_get_contents($filename);
	// Open the file & write to it
	$fp = fopen($filename,"w"); 

Bridge between an Linux Apache server and Windows SQL server

A short description showing how to automatically run a simple PHP script on a windoze machine that connects to a local SQL server database, grabs some data, then sends it to a remote Apache server. I'm assuming that you already have a remote server running so have only provided instructions for installing the windows server below.

Setup your windows environment

1. Install Apache and PHP on the windows machine. xampp makes this easy: http://www.apachefriends.org/en/xampp-windows.html#522

Drupal and php 5.3 Compatibility

I was upgrading my server the other day & had a couple of very old Drupal 4.7 sites and quite a few Drupal 5.23 sites which I wanted to keep working. I thought I was in for a right headache but it turned out to be surprisingly easy with the following patches:

Drupal 5 Compatibility patch
http://drupal.org/node/853064

Drupal 4
And these are the lines I replaced in my Drupal 4.7 install.

Line 498 : common.inc
if ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) { // replaced: if ($errno & (E_ALL ^ E_NOTICE)) {

Line 497 : user.module

 
info@theanthillsocial.co.uk XHTML 1.0 Strict CSS2 WAI