PHPFeedSync
Sunday, July 6th, 2008Today I released my first open source project. The PHPFeedSync project aims to be a complete PHP implementation of the FeedSync protocol. You can find the project here: http://www.codeplex.com/phpfeedsync/.
Today I released my first open source project. The PHPFeedSync project aims to be a complete PHP implementation of the FeedSync protocol. You can find the project here: http://www.codeplex.com/phpfeedsync/.
Some way down the road the default php.ini started to get shipped with settings that stopped the error printing. The default location of this file is /usr/local/lib/php.ini, and the most common settings that controls the error reporting behaviour is listed below:
error_reporting = E_ALL | E_ERROR | ... | E_USER_NOTICE display_errors = On | Off log_errors = On | Off
First of all error_reporting decides what type of errors or messages that will be taken care of in the first place. See php.ini for details. Then you have the options to:
display_errors to Onerror_log by setting log_errors to OnThere is a reason why they stopped to display errors as a default thing. This is because you are risking to leak sensitive information about your server configuration. A way to achive instant information about errors, and keep the rest of your web site safe, is to alter the settings for just the scripts you are working with at run time. It can be done like this:
ini_set('display_errors','On'); error_reporting(E_ALL);
Replay Manager er en Windows-applikasjon som jeg har skrevet i C#. Utviklingsverktøyet jeg har brukt er Microsoft Visual C# 2005 Express edition.
Warcraft III er et mye spilt real time strategy spill. Når man er ferdig med en omgang av spillet så lagres kampen automatisk i fila LastReplay.w3g. Denne fila overskrives for hver omgang. Derfor må man ta en kopi av fila hvis man ønsker å bevare kampen, før man setter i gang med en ny. Det finnes utallige websider der man kan laste ned meget underholdende kamper mellom verdens beste spillere.
Replay Manager lagrer og organiserer Warcraft III replays automatisk. Måten dette gjøres på er å først overvåke fila LastReplay.w3g. Hvis denne endres på noen måte så tas det en kopi. Replay Manager sender så fila til en web service på wcportal.net som jeg har utviklet i PHP5. Fila parses av en parser utviklet i PHP av Juliusz Gonera. Web servicen henter så ut parset informasjon, og sender denne tilbake i XML format til Replay Manager. Denne informasjonen lagres så i ei XML-fil på klientmaskinen. Her kan du se et eksempel på ei slik fil. Replay–fila får nytt navn basert på parset informasjon. Fila blir også registrert i et register som Replay Manager bruker for å holde oversikt over replays på maskinen.
I selve applikasjonen finner man to WebBrowser–kontroller. I den venstre finner man ei liste med replays fra replay-registeret. Klikker man på en av disse så vises detaljer i browseren til høyre. Replay Manager bruker registeret, XML–fila som ble generert av Web Servicen og ei XSLT–fil for å generere lista og detaljvisningen. Høyreklikk og “save target as” hvis du har problemer med å få sett XSLT–fila på en skikkelig måte.
Programmet har også andre funksjoner som å laste opp replays til wcportal.net, vise fram RSS fra wcportal.net, med mer.
Replay Manager er ikke ferdig utviklet, men kan demonstreres for interessert arbeidsgiver. Send meg en e–post hvis du ønsker mer informasjon.
In this article you will get to know a litte about how character sets, XML and PHP5 work together. We will also look a bit deeper into the most common character sets and encodings.
First we need to talk a little so that you will be able to grasp the two terms:
Data is stored on disk as bits. To get a character out of a bit sequence the computer:
For instance:
110000197a using the Unicode character set.It’s also common to express code points in hex so for instance the arabic character ف has a 641 hex and a 1601 decimal code point.
Now it should be obvious that character encodings maps bits to code points while character sets maps code points to characters. Unicode has a lot of different encodings, but ISO–8859–1 (Latin–1) has only one. UTF–8 is one of the Unicode encodings. While Unicode and Latin–1 have an equal character map below code point 255 the UTF–8 encoding is different from Latin–1 from code point 128 and up.
Use the following XML declaration:
<?xml version="1.0" encoding="ISO-8859-1"?>to tell your software that your XML file has a Latin–1 encoding. The default is UTF–8 so if you omit the encoding part, you are really saying that your file contains UTF–8 characters.
Opera, Firefox and Internet Explorer knows how to display Unicode characters represented in the UTF-8 encoding. The problem is that web servers like Apache has a default Latin–1 content header. Browsers then think they are reading Latin–1 and displays characters, which have different encodings like å, wrong. The following PHP code changes the header so that browsers know that it’s UTF–8 they are receiving:
header('Content-Type: text/html; charset=utf-8');
It’s allways good to separate code and markup, and with DOM you can do such a thing. We will look at these properties of DOM in this article:
Let’s start with this file called base.xml:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>DOM example</title> </head> <body></body> </html>
Tip: To get Iternet Explorer 6 into “almost strict mode” the XML declaration needs to be removed. If not IE will turn into “quirks mode”.
Next step is to load the XML and add a style sheet and some contents. After the document has been created we fetch the head and body tag. Finally we modify the document and print it.
// Creating and parsing the base.xml document... $doc = DOMDocument::load('base.xml'); // Instantiating XPath object... $xp = new DOMXPath($doc); // Fetching elements... $head = $xp->query('/html/head')->item(0); $body = $xp->query('/html/body')->item(0); // Appending contents... $link = $head->appendChild($doc->createElement('link')); $link->setAttribute('href','example.css'); $link->setAttribute('type','text/css'); $link->setAttribute('rel','stylesheet'); $body->appendChild($doc->createElement('h1','Contents')); // Printing the modified document... print($doc->saveXML());
In this paper we will build a simple but powerful system containing some of the principles of archetypes. We will first look at how we can specify archetypes. Then we will make some instances and build the part of the system that displays them properly. Later we will implement a user interface where we can add, alter and remove instances. At the end we will try to use this system in both a useful and familiar context. The full article can be downloaded below: