Arquivo da Categoria ‘PHP’

PHP sort array by two field values

29, Abril, 2015 Nenhum comentário



Adobe Content Server 4 (ACS4) Setup Guide

16, Maio, 2014 Nenhum comentário

Source of this great guide: The Web Development Logs –

This setup guide is written for a single server installation, using Apache, MySQL and PHP to keep things simple.

I make no excuses that i borrowed a lot of content from the original Adobe Content Server 4 Technical Reference Manuals and other Documentation while adding in my personal notes, screen shots, and potential pitfalls to look out for.

Read through everything you can before beginning the setup process, understanding the concept of Adobe Content Server as a whole is as important as getting everything running smoothly.

Please refer to, study, and read the original ACS4 installation and quick start documentation here.

The ACS4 installation can be split into steps:

  • Installing the basic requirements
  • Setting up the Admin console
  • Setting up the Fulfillment service
  • Setting up the Packaging service
  • Generating the Certificate files
  • Completing Config Files
  • Content Server Status Checks
  • Book Packaging and Distribution
  • Serving the Sample Store

You may wish to have the packaging service and media storage on seperate machines to distribute workloads.

Basic requirements to run Adobe Content Server:

  • The Java Runtime Environment (JRE)
  • Apache Tomcat version 6 or higher
  • MySQL version 5 or higher.

In addition, to run an online store, you will also need:

  • Apache HTTP Server
  • PHP 5 or above.

Ler mais…

Tags: , , ,

PHP ONIX Importer

24, Janeiro, 2014 Nenhum comentário

A simple, fast, extensible way to convert very large ONIX sources with arbitrary data structures into manageable, queryable data. Allows arbitrary XML structures as input, and stores them as Mongo object structures which can then be queried, indexed or serialized as JSON.

Tags: , ,

Wrong charset in php/oracle

20, Janeiro, 2014 Nenhum comentário

Tags: , ,

Send CDATA with php/nusoap

16, Janeiro, 2014 Nenhum comentário

Set charencoding to false:

Creating a web service and WSDL using NuSOAP

16, Janeiro, 2014 1 comentário

Get NuSOAP and download into a directory. Then create a file called “mywsdl.php” for example.

The first thing I did was to set a namespace for my web service. This makes my web service unique and identifiable. The namespace does not have to be a URL but if you make it a URL things can be a lot easier.

Next we need to create the server object and start to program against it:

Creating your data types

There are three main types of data you will be using. Built in types can be used without being declared. The other two are slightly more complicated, structures and arrays.

First lets look at an example structure:

This is quite a complicated function, and from the source code we see that the parameters are as follows:

  • 1: name
  • 2: typeClass (complexType|simpleType|attribute)
  • 3: phpType: currently supported are array and struct (php assoc array)
  • 4: compositor (all|sequence|choice)
  • 5: restrictionBase namespace:name (
  • 6: elements = array ( name = array(name=>”,type=>”) )
  • 7: attrs = array(array(‘ref’ => “”, “” => “string[]“))
  • 8: arrayType: namespace:name (

The first is simply the name you want to define (in the context of the ‘targetNamespace’ defined above.

The next is the type. simpleType is usually based on another type with restrictions (e.g. a string with max length of 4 or some such other restriction), complexTypes usually have more than one subelement (as above).

The phpType, as specified is either array or struct.

The compositor is a way of defining how the subelements of the current element work, are they either all optional element, to be included in any order (all), optional but only to be allowed in the given order (sequence) or only one of them is allowed at any one time (choice).

The restrictionBase and attrs and arrayType we shall cover later when we talk about support for arrays.

The elements item is an array containing a list of subelement, each of which has a name and a type.

The above example defines a type called “Walk” which is effectively a struct, containing 4 fields, WalkId, WalkTitle, WalkDate and WalkDescription. It is a complex type and all elements can be included in any order. WalkId is a integer, WalkTitle and WalkDescription are strings and WalkDate is a date field.

What about list of walks

The next think you might want to do is return a list of walks matching some criteria (e.g. latest 10 walks). For this we use the array data type:

Here the php type is array instead of struct. The compositor is blank and the restrictionBase is ‘SOAP-ENC:Array’. This tells the system that your complex type is based on the Array type defined within the soap-encoding namespace. The elements parameter is then a blank array and the attrs parameter is an array defining the type of the array and the parameter defines the type of the elements within the array (as you can see, these are usually the same except for the [] part after the array definition.

Do some work!

Well so far we’ve defined the types of data (or some extra ones not already defined) that we want to pass in and out of your web service. Next we define the actual operation the web service will support.

Here we define a method which will input a integer, defining the walk id and get passed back a Walk data struct (containing the id, title, description and date). We again define the namespace and I’ve set the action to the namespace + “#GetWalk” which is the method name.

We define a normal php function to actually do the work:

Dates should be in ISO international format CCYY-MM-DD HH:MM:SS with an optional timezone attached at the end (or shorted as in this example).

Finally, we pass whatever data the php page receives into the soap processor and see what happens:

If you now browse to your completed webpage you should find you are presented with a nice page listing the operations supported and the parameters, as well as a link to the wsdl which can be used with code generation tools (such as wsdl.exe with .Net or the java equivalent) to generate client code for your wsdl.