Arquivo

Arquivo de Janeiro, 2014

Remove all SVN directories and files

28, Janeiro, 2014 Nenhum comentário

Remove all directories and files from your project folder:

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.

https://github.com/Vaporbook/POI-PHP-ONIX-Importer

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 (http://schemas.xmlsoap.org/soap/encoding/:Array)
  • 6: elements = array ( name = array(name=>”,type=>”) )
  • 7: attrs = array(array(‘ref’ => “http://schemas.xmlsoap.org/soap/encoding/:arrayType”, “http://schemas.xmlsoap.org/wsdl/:arrayType” => “string[]“))
  • 8: arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string)

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.

VSFTPd Virtual Users

11, Janeiro, 2014 Nenhum comentário

This documenation was created from CentOS using the YUM package manager to keep things simple. Before you dig to deep you need the FTP Server to be installed. You can either install the FTP Server as you install CentOS or YUM group install it after the fact.

If you don’t have VSFTPd installed currently on your CentOS machine.

Needed for creating the user database later.

PAM configuration which configures the usage of the virual database we will be creating from a basic text file below.

In same cases the path of pam_userdb.so it’s different.

 

Add the user the virtual FTP server will use to log in all users.

VSFTPd configuration example used for this setup.

Create your text absed user and passwor

Create your text absed user and password list.

Insert your usernames and passwords

Create your user database from the entries located in the users file created above.

Create your user’s based FTP directory.

 

Fixes: not being able to write once logged into FTP

Fixes: “500 OOPS: cannot change directory”. If SELinux is not enabled or enforcing then this can be ignored.

Fixes: “425 Failed to establish connection” or “Client Error: Failed to retrieve directory listing”. If you have not run some sort of automated firewall utility you may need to add the module ip_conntrack_ftp to your iptables configuration. Just make sure your line includes ip_conntrack_ftp as stated below. If you are not running an iptables based firewall then this can be ignored.

And do this:

Tags: ,

FCKEDitor with Firefox Spell Checker

9, Janeiro, 2014 Nenhum comentário

It’s for an older version but i need this and i can’t upgrade the editor to CKeditor.

Firefox has a great built in Spell Checker. The problem is FCKeditor uses its own menu system, so the right click context menu is not available for the Firefox spell Check and the spell checker is not on by default with FCKeditor.

To resolve, do this in your fckconfig.js, which is a file you will find in the fckeditor, you need to add the following lines:

Installing SSL using OpenSSL on a WAMP localhost

4, Janeiro, 2014 Nenhum comentário

Before starting with all the key stuff, I installed the OpenSSL binaries for Windows into the System directory.

Your paths may be slightly different.. so change them appropriately.

GENERATE KEY

Again in the command prompt, go to C:\wamp\Apache2\bin and run the following command:

The command runs and prompts you to enter a PEM pass phrase and verify it. Since we are doing this locally, just put in some sort of “password”, but write it down, because you will need it in the next step.

It will then ask you to enter information that will be incorporated into your certificate request. When the command finishes, it has created several files, including privkey.pem, in c:\wamp\apache2\bin.

REMOVE PASSPHRASE

Run the following command:

You will be prompted for the pass phrase from the previous step. The RSA key is written and the file webserver.key is now available in the folder.

CONVERT INTO SIGNED CERTIFICATE

Run the following command to create a certificate which expires after one year:

STORE CERTIFICATE FILES

Create a folder c:\wamp\OpenSSL with the following subfolders:

Copy the following files to /certs/:

Copy the following files to /private/:

MODIFY HTTPD-SSL.CONF

Change the following lines, adjusting the email address and the paths to your settings:

SSLMutex default

MODIFY OPENSSL.CNF

There is a file openssl.cnf in c:\wamp\Apache2\conf even though no extension is shown in Windows Explorer. Go to the DOS command prompt and run DIR to see the file extension. Make a backup copy of this file first and rename it in DOS to openssl.cnf.txt so that you can edit it.

Modify the base directory:

Go to the DOS prompt and change the name of the file back to openssl.cnf.

MODIFY HTTPD.CONF

Last, but not least, make sure your secure site is part of the virtual hosts in Apache:

Ensure SSL is Enabled
Make sure that Apache is setup to even use SSL.
Do this by clicking the WAMP icon in your tray,
hovering to: Apache > Apache Modules,
scroll through the list and make sure that ssl_module has a check next to it.
If not, then click it.

TEST HTTPS

Run httpd –t and make sure the syntax is OK.

Restart Apache.

Check that port 443 is open by running the following in the command prompt:

Test the https connection from your browser and hopefully it works.

Setup Samba/Windows Shares on XBMC Live

3, Janeiro, 2014 Nenhum comentário

It’s relatively easy to setup samba shares on XBMC Live, but it does require bashing out some commands on the shell. First, you’ll need to install samba using apt-get:

Then, you’ll want to configure your shares by editing the the file named smb.conf, placed in the /etc/samba/ directory. For example, I added the user folder and media folders to be available shares by running the following command:

Update: It looks like this has changed in the more recent versions of Ubuntu that the XBMC Live distribution is packaged with (10.04). You can restart the samba service using the old method:

Scroll down all the way to the bottom of the file, then paste in the following (use right click in Putty to paste something from your clipboard):

After that, restart the samba server using:

Note: I updated the samba configuration above to include the ‘force user’ and ‘inherit permissions’ features as I was having trouble with newly created files not getting the right permissions and logging into samba.

Also, when accessing the shares from Windows, if you left the default security options you can use the account ‘guest’ with no password to access the shares. Otherwise, you can play with the settings to force a local linux account to be used in order to access the shares.

Tags: ,