PHP

December 12, 2009

XML :: PEAR Packages

XML :: PEAR Packages

Posted by pj at 04:33 PM | Comments (0)

September 23, 2009

Code for detecting if it's BST

http://www.devscripts.net/browse/116.php

Posted by pj at 03:45 PM | Comments (0)

July 09, 2009

PEAR CSS Builder

Manual :: features and usage patterns

Posted by pj at 03:55 PM | Comments (0)

PEAR Calendar

Manual :: Calendar

Posted by pj at 03:48 PM | Comments (0)

Installing Spredsheet_Excel_Writer PEAR module

/opt/php/bin/pear install channel://pear.php.net/OLE-1.0.0RC1
/opt/php/bin/pear install channel://pear.php.net/Spreadsheet_Excel_Writer

Posted by pj at 12:01 PM | Comments (0)

July 02, 2009

Limonade Framework

Limonade - PHP micro-framework

Posted by pj at 10:06 PM | Comments (0)

May 16, 2009

Mac PHP Postgres Bundle

BitNami :: MAPPStack

Posted by pj at 10:36 PM | Comments (0)

January 19, 2009

Using PHP and PGP

Kelv's Programming Area - How to use PGP / GnuPG with PHP

Posted by pj at 04:05 PM | Comments (0)

December 15, 2008

PHP / SWF graphing

PHP/SWF Charts > Introduction

Posted by pj at 11:05 AM | Comments (0)

October 16, 2008

iTunes XML Parser in PHP

Code Triangle :: iTunes XML Parser for PHP

Posted by pj at 03:21 PM | Comments (0)

July 28, 2008

Drupal on XAMPP

How to Install Drupal on an XAMPP installation | drupal.org

Posted by pj at 12:43 PM | Comments (0)

July 18, 2008

XML to JSON in PHP

Convert XML to JSON in PHP

Posted by pj at 02:59 PM | Comments (0)

July 16, 2008

The RDF API for PHP

Introduction to RAP

Also and more usefully:

http://www4.wiwiss.fu-berlin.de/bizer/rdfapi/tests.html

Posted by pj at 01:37 PM | Comments (0)

July 15, 2008

Drupal DOES use PHPtal

PHPTAL theme engine | drupal.org

Posted by pj at 09:35 AM | Comments (0)

April 20, 2008

ONLamp.com -- Improve Your Build Process with Ant

Posted by pj at 08:05 PM | Comments (0)

November 12, 2007

Parsing mail messages with PHP

PHP: Mailparse Functions - Manual

Posted by pj at 08:27 PM | Comments (0)

June 18, 2007

PHP and SOAP article on ADC

Using SOAP with PHP

Posted by pj at 02:58 PM | Comments (0)

April 26, 2007

Sending plain text and HTML version in the same email

Sending HTML/Plain text Emails - PHP

$boundary = "nextPart";

$headers = "FROM: [email]me@fromme.com[/email]\r\n";

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-Type: multipart/alternative; boundary = $boundary\r\n\r\n";

$headers .= "This is a MIME encoded message.\r\n\r\n";

//text version

$headers .= "--$boundary\n

            Content-Type: text/plain; charset=ISO_8859-1\r\n

            Content-Transfer_Encoding: 7bit\r\n\r\n";

$headers .= "This is the plain version\r\n\r\n";



// html version

$headers .= "--$boundary\r\n

            Content-Type: text/html; charset=ISO_8859-1\r\n

            Content-Transfer_Encoding: 7bit\r\n\r\n";

$headers .= "This is the HTML version";

mail("me@myemail.com", "An HTML Message", "", $headers); 

Posted by pj at 10:58 AM | Comments (0)

April 18, 2007

PHP and MySQL and Unicode

Unicode Data with PHP 5 and MySQL 4.1

Posted by pj at 11:01 AM | Comments (0)

January 24, 2007

PHP HTTP functions list

Some really useful stuff in here I wasn't aware of:


PHP: HTTP - Manual

Posted by pj at 12:31 PM

November 13, 2006

Applet for file uploading which gets around PHP file size limit

SourceForge.net: Open Discussion

Posted by pj at 11:50 AM | Comments (0)

September 24, 2006

Web site analysis in PHP

phpOpenTracker

Posted by pj at 08:51 PM

August 11, 2006

Python interpreter embedded in PHP

PECL :: Package :: python

Posted by pj at 10:03 AM | Comments (0)

August 06, 2006

New do_sql.php

I've rewritten my do_sql.php code to work with the Pear DB library and refactored everything while I was at it:

<?php

require "DB.php";

include("read_config.php");

function sql_doozer($db, $sql, $is_query, $debug){

	if($debug == true){ print $sql; }

	# Set up the reply array

	(array) $reply;

	# Get our database connection details from the INI config file

	(array) $config = read_config($db.".ini");

	if($debug == true) { print_r($config); }

	$conf = $config["connection_parameters"];

	# Build the connection URL
	
	$db_url = $conf["type"]."://".$conf["user"].":".$conf["passwd"].
	"@".$conf["host"]."/".$conf["db"];

	if($debug == true){ print $db_url; }

	# Create our connection

	$connection = DB::Connect($db_url);

	if(DB::isError($connection)){

		$reply["status"] = false;

		$reply["message"] = $connection->getMessage();		

		return($reply);

		}

	(array) $reply["rows"];

	# Do the query

	$cursor = $connection->query($sql);

	if(DB::isError($cursor)){

		$reply["status"] = false;

		$reply["message"] = $cursor->getMessage()." - ".$sql;		

		return($reply);

		}

	$count = 0;

	# If this is an SQL query get the results back

	if($is_query == true){

		$reply["num_of_rows"] = $cursor->numRows();

		if(DB::isError($cursor)){

			$reply["status"] = false;

			$reply["message"] = $cursor->getMessage();

		
			return($reply);

			}

		while($this_row = $cursor->fetchRow(DB_FETCHMODE_ASSOC)){

			if(DB::isError($this_row)){

				$reply["status"] = false;

				$reply["message"] = $this_row->getMessage();		

				return($reply);

				}

			$reply["rows"][$count] = $this_row;

			$count++;

			}

		}

	if($debug == true){ print_r($reply["rows"]); }

	$reply["first_row"] = $reply["rows"][0];

	$reply["status"] = true;

	$reply["message"] = "OK";

	return($reply);

	}

function is_query($sql){

	# Check to see if our SQL is an insert or update statement

	$sql_list = explode(" ",$sql);

	if((strtolower($sql_list[0]) == "insert") 
	or (strtolower($sql_list[0]) == "update") 
	or (strtolower($sql_list[0]) == "create") 
	or (strtolower($sql_list[0]) == "alter")){

		return(false);

		}

	return(true);

	}

function do_sql($db, $sql, $debug){

	$is_query = is_query($sql);

	return(sql_doozer($db, $sql, $is_query, $debug));

	}

function do_sql_query($db, $sql, $debug){

        return(sql_doozer($db, $sql, true, $debug));

        }

function do_sql_insert($db, $sql, $debug){

        return(sql_doozer($db, $sql, false, $debug));

        }

function do_sql_update($db, $sql, $debug){

        return(sql_doozer($db, $sql, false, $debug));

        }

?>

Posted by pj at 03:32 PM | Comments (0)

July 31, 2006

Unit tests in PHP

ONLamp.com: Testing PHP Code with PHPUnit

Posted by pj at 10:14 PM

July 26, 2006

Bundle for Apache, PHP and MySQL

apache friends - xampp

Posted by pj at 11:43 AM | Comments (0)

July 04, 2006

We love PHPTAL

PHPTAL :: Template Attribute Language for PHP

Posted by pj at 01:40 PM | Comments (0)

July 01, 2005

Securing DB authentication credentials in PHP

I want to use Windows .ini style files for DB configuration settings in PHP. This is an approach I already use in Python.

Because these files are going to contain usernames and passwords I can't have them in the webserver file system as they would be visible to the web. However, if they aren't where the webserver can see them then PHP won't open them while running in safe mode.

My solution is to use a local .htaccess file with the following:

<Files ~ "\.ini$">
Order allow,deny
Deny from all
</Files>

Posted by pj at 12:54 PM

April 13, 2005

Merging multiple RSS feeds

Suzanne thought it would be a good idea if we could merge multiple news feeds from BIOME, HS&P and HEALTH-01 for our joint portal page.

Whilst unconvinced of the requirement for such a thing I have come up with the following:

- http://www.ltsn-01.ac.uk/static/merge_feeds.php

To get a text/xml view of it in your browser use:

- http://www.ltsn-01.ac.uk/static/merge_feeds.php?debug=1

The script is as follows:

- http://www.ltsn-01.ac.uk/static/merge_feeds.txt

Merging multiple RSS feeds into one involves de-duping based on link URLs in items and interleaving items so that they appear next to items of the same age in the final feed.

The script pulls our news feed and the feed from a blog we're hosting and represents them. In theory it can handle as many feeds as you want.

But why? I hear you ask.. Errm.. still not sure? Suzanne?

As a side effect of all this work, I was determined to get the feed to validate on http://feedvalidator.org.

It doesn't like my image references so those are gone from the feed, then it was a matter of getting the right content-type (application/rss+xml), stripping annoying Windows meta characters from the feed, making sure there are no duplicate URLs, and I've UTF-8 encoded the final output for good measure.

- http://www.ltsn-01.ac.uk/static/strip_ms_chars.txt

Basically all the problems we've had with the LOM XML stuff.

I've done this with the rest of our feeds too and they now validate.

Posted by pj at 04:58 PM

March 23, 2005

PHP4 Installer for Mac OS X

Marc Liyanage - Software - Mac OS X Packages - PHP

Posted by pj at 03:38 PM

February 09, 2005

An iCalendar view of our events database

I've spent today hacking together a PHP script to generate a view of our ltsn01_general.events table.

http://www.ltsn-01.ac.uk/static/ltsn-01_events.ics.php

I've also written a cron job which uses curl to get a snapshot of that output into a static .ics file:

http://www.ltsn-01.ac.uk/static/ltsn-01_events.ics

I've successfully subscribed to this in iCal.

There is also a web view of this calendar here:

http://minnesota.ncl.ac.uk/calendar/

Posted by pj at 04:29 PM

December 10, 2004

Article about PEAR, Smarty and MySQL

ONLamp.com: Three-Tier Development with PHP 5

Posted by pj at 01:31 PM

December 02, 2004

This is quite sick - ZPT in PHP

circle.ch :: PHPTAL - PHP Template Attribute Language

http://phptal.sourceforge.net/

Posted by pj at 09:36 PM

November 24, 2004

Photo metadata

I've finished the cataloguing tool for my photo album and formalised how the RDF is represented for the album, each collection, associated events and event attendees and then person depictions in the images themselves.

This is done within the framework of the CC License and Work model to assign a CC license to everything aswell.

I've also set up an RSS feed of the latest catalogued pictures and then hacked Feed2JS so that it pics up the image thumbnails if they are in the feed:

Paul Hollands - Photo Album - RSS

Posted by pj at 10:14 AM

November 16, 2004

Script to generate just FOAF

I've added a PHP script that generates just my FOAF, as opposed to the FOAF and blog DC.

http://minnesota.ncl.ac.uk/foaf.rdf.php?email=p.j.hollands@ncl.ac.uk

Posted by pj at 05:02 PM

November 11, 2004

Changes to my photo album code

I finally installed my PHP photo album on minnesota with the latest version of PHP which has GD rolled into it. When I finally got the JPEG library compiled into it though, I was getting images with only 256 colours.

I amended the code as follows and now have better image quality than I do with the app running on my iBook with a more aged PHP:

#$img_src=imagecreatefromjpeg('yoursource.jpg');
#$img_dst=imagecreatetruecolor(20,20);
#imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, 20, 20, 20, 20);
#imagejpeg($img_dst, $g_dstfile, 100);
#imagedestroy($img_dst);

$original = imagecreatefromjpeg($url);

$new = imagecreatetruecolor($width, $height);
#$new = imagecreate($width, $height);

imagecopyresampled($new, $original, 0,0,0,0, $width, $height, $size[0], $size[1]);

#imagecopyresized($new, $original, 0,0,0,0, $width, $height, $size[0], $size[1]);

Header("Content-type: image/jpeg");

if(is_null($gamma_off)){ imagegammacorrect($new, 1.0, 1.6); }

imagejpeg($new, '', 100);

#imagejpeg($new, '', 90);

imagedestroy($new);

imagedestroy($original);
< http://minnesota.ncl.ac.uk/photo_collections.php >

I've also added CC license, DC and FOAF metadata to the scripts. See copyright.rdf.

Posted by pj at 11:40 AM

October 29, 2004

Article about MT and PHP includes

Looking to roll some common PHP into the headers of all my bogs.. This might be useful:

< http://www.elise.com/mt/archives/000484using_php_and_mt_includes.php >

Posted by pj at 05:58 PM

Magpie RSS parser for PHP

< http://magpierss.sourceforge.net/ >

Posted by pj at 03:36 PM