wxPHP newest Administrator

February 1st, 2008

Me!!
:D

wxPHP is a project that as been a little forgot. It started in 2005, but due to library complications, it was difficult to produce a working binary. Now i’m trying to revive it. Already have a working version, and it’s already available in PECL developmental tree, as the wxwidgets extension.

wxPHP is a project hosted at SourceForge.

Since the code is very young in nature, there will be some errors using the extension. But i already produced some workable programs with it.
All programmers, are invited to compile and use it. Feedback is important.

wxWidgets - a cross plataform gui library

January 29th, 2008

Programming Gui interfaces, often generates dependencies to platform to which one is developing. You’ll be using GTK in Linux, windows native controls,.. etc. Of course you call always use java’s swing package, and don’t even consider such a problem.

wxWidgets presents it self as a library, that makes the bridge between your source code and the graphical toolkit of the platform your developing. That way, you can compile the same code in another platform, and have exactly the same behavior.

The library is developed in C++, and there are language bindings available for most of the popular programming languages: Python, Pearl, Ruby. This way you got yet another advantage, the need to recompile on every other platform, leaving this dependency to be fulfilled by the runtime.

Adobe AIR Derby

September 11th, 2007

Adobe launched a developer contest, for their newest palatoform. The Adobe AIR Developer Derby. And well,.. i entered the contest. My application, was far from complete for initial features i was hopping to implement, but i stumbled some accessebity issues, and and to cut back, in some of them.

The initial idea is there, the design i think is great. I asked for help for the design to a friend of mine. Hes is quite talented.
Adobe AIR, features great ideas, with the correct framework, you can make an application have the same interaction has if it was online.

The interface is based mostly in drag&drop events. So if you’r asking how to do something, just try to drag it first.

This is a capture of the interface:

capture01

Here’s the link:
http://web.seariver.info/installer.air

and enjoy,… the concept :D

PHP sends SMS, via Skype

September 11th, 2007

You coul’d always subscribe to a gateway, it would be a cleaner way to do it. But this could come in use for some of us.
It requires skype to be installed and configured on your computer. It’s really quite simple, i just adapdted from their .vbs examples.

<?php
	ini_set('max_execution_time',0);
	ob_implicit_flush();
	$oSkype = new COM("Skype4COM.Skype") or die("Unable to instanciate Skype");
	echo "Loaded Skype, versionn";

	//bring it to front
	if(! $oSkype->Client->IsRunning)
	{
		$oSkype->Client->Start();
		sleep(10);
	}
	echo "everything ok: ".$oSkype->Client->IsRunning."n";

	//Send SMS
	$oSkype->SendSms("+123456789011", "Hello!!")
?>

No need for any extra php extension, support for COM is part of the php core. A few more lines and a local http server, and you can build your personal web-interfaced SMS Gateway.

No, this is not or free. Your using skype, so you probably have to buy credit.
Of course you can explore the de Skype4COM documentation, and include more features, into your web application.

Gmail’s webAPI

August 24th, 2007

Gmail is a very popular, if not the most popular and used email service on the web.  Configuration of your email client to their servers is not the most standard: the ports of smtp and pop services are not the usual, and the service requires ssl. Also pop3 service needs to be activated, it is not activated by default.

I can’t blame them, since they offer a very good service, with gigs of space. A security flaw could escalate to a very big problem. Today my problem is SSL, i’ve been programming in the AIR plataform, and their socket library does not support SSL, so SMTP conection is out of the question, and i pretty much gave up on gmail service for my little project, and used another email service for communication.

Today i found an interesting link, that just may solve the problem. It’s an unofficial documentation of the gmail mobile api.
Adobe air may not support ssl in their sockets library, but it’s supported in a lower level, that is available to other classes such as URLRequest, wich support HTTPS.
So, it seems to be possible to use gmail’s webservice to achieve mailling functionality, using Flex 3 API.

To work around the ssl requirement, the service run through a proxy. Setting up a proxy for the webapi, seems to be a lot of trouble, but it is possible, and aSSL could be of some use, even for a generic webapplication.
Making a proxy to establish TLS with the SMTP server, maybe would be another way to go, and would be a more generic solution, not only for the gmail service.

Workaround seems to be a science by it self!!

Regex URL parser

August 21st, 2007

The first instinct was to make a multilined verification code, for parsing the url. I wanted to extract the host and port of the url, and thought that would be simple enough, no need for elaborated code. Just locate the “://”, and than the “:” take the needed tokens and ignore the rest.

But than it hited me,.. “hum,.. too many lines, too sloppy”. A few months ago i made an effort to understand regex expressions, i already had a little understanding of how it works. I essencialy learned it from this quick start. But i am in no position to make one from scratch, and i’m not that stuborn, so i googled my needs and it came up with this.

Regular expressions are available in many languages, wich makes them very useful. But the script i googled, had some is good only for complete URL’s, and it didn’t included ‘port’. So i made some minor adjustments to my needs. It will return has little has just the host. Without further ado:

var e=/^((http|ftp|smtp):/)?/?([^:/s:]+):?([0-9]+)?((/w+)*/)?([w-.]+.[^#?s]+)?(#[w-]+)?$/;

if (data.match(e)) {
	return  {url: RegExp['$&'],
	protocol: RegExp.$2,
	host:RegExp.$3,
	port:RegExp.$4,
	path:RegExp.$5,
	file:RegExp.$7,
	hash:RegExp.$8};
}

XML to SVG through XSLT

August 20th, 2007

Sometime ago, i browsed the web in search, in some kind of stylesheet repository that i could use for some graphical representation of data. But i had no luck, i did find some tutorials wich had some usable samples. Today i also searched for some standard markup language, to define recordset’s for the xml data input, also with no luck.
I’m starting to think poorly of my web-skills.

The objective of today, was to make webstat look-a-like representation of a log file, generated by my most recent web-application, separating into diferent dataset’s according to the HTTP method used. So that i could keep track of it’s usage.

Since i wanted something graphical, SVG seemed to be a good answer, and because it isn’t the most common of web standards, and because it need’s the adobe plugin, or the browser to be firefox, i used Batik for rendering into PNG. So, i was able to use the graphical versatility of SVG, a automated XSLT tranformation, and remove all client dependencies and specificity of software.

My stylesheet was based on the tutorial link above. It’s far from complete, but supports multiple recordset’s.

Here is the PNG output:

PNG Output

Blue is GET, Red is PUT, Green is POST, Black is DELETE. The numbers stand for “Days ago”.

And here are the source files: Tranformation Sample

I used a php based script to retrive the statistical data from the application log.

AIR as no command-line

August 4th, 2007

Command-line execution is a very juicy feature. But this won’t be implemented on Adobe Intergrated Runtime, any time soon.
Since AIR is supposed to be cross-plataform, plataform specific command-line sintax, may cause a problem.
If it’s adobe’s intention to make it impossible for a developer to make an application that would just run in one plataform, i think they should stick to the current implementation (none).

This is object of discussion at Adobe’s forums, and someone as implemented a cross-plataform workaround entitled “The Artemis Project“. From what i read, it’s a tcp/ip bridge, to a listening Java App.
The Beta version seems to be available since april.

My reason for searching this kind of solution, was to make another workaround “threading”, also not yet available in the current AIR beta version.
There are some security risks considered in a comand-line execution, sinse it cannot stop a “fomat c:”. But what is stopping other runtime’s from this?

For my workaround need’s, being able to launch another AIR application, would be enough. But threading is a much more important feature. Let’s just wait…

Base64 encode decode, AIR based Javascript

July 27th, 2007

Hello everyone,.. as i was coding, i stumped upon the need of a base64 encoder. I’m currently experimenting with Adobe AIR, and i’m making the effort not to use Flash. I’m already using corelib, so let’s leave it at that.

Since most of the time, i’m a copy/paste programmer, i googled for some code. But the best solution for my case was not found in a ActionScript post,.. but rather in a pure Javascript one. I adapted it so that it would support a ByteArray source.

So, without further ado:

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(byteArr) {
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;

	do {
		chr1 = byteArr[i++];
		chr2 = byteArr[i++];
		chr3 = byteArr[i++];

		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;

		if (isNaN(chr2)) {
		enc3 = enc4 = 64;
		} else if (isNaN(chr3)) {
		enc4 = 64;
		}

		output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
		keyStr.charAt(enc3) + keyStr.charAt(enc4);
	} while (i < byteArr.length);

	return output;
}

function decode64(input) {
	var output = new air.ByteArray();
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	//input = input.replace(/[^A-Za-z0-9+/=]/g, "");

	do {
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output.writeByte(chr1);

		if (enc3 != 64) {
			output.writeByte(chr2);
		}
		if (enc4 != 64) {
			output.writeByte(chr3);
		}
	} while (i < input.length);

	return output;
}