Archive for April, 2008

Keeping track of your users hardware / Software with Sparkle and PHP.

Tuesday, April 15th, 2008

Some months ago I started using the amazing Sparkle framework to manage the auto-update features on my MediaInfo Mac application, and it wasn’t until today that I decided to update my Sparkle version to the latest one from the SVN and give it a try, mostly because I’m planning to release upcoming MediaInfo Mac builds as 32 and 64bit Universal Binaries, but that’s a different story.

I have found that with the new Sparkle version, you can kindly ask the user if he/she wants to send anonymous information about the system they are using to run your application, like the MacOS version, amount of RAM, number of processors, language, etc. This is specially useful for many reasons (at least for me), first, I’m starting the process of localizing my application, so that gives me a pretty good idea of what languages are the most used so far, and, finally, it will let me now when I could stop caring about Tiger and start a Leopard only version of my Software.

The idea is pretty simple, you have a PHP script that generates the whole AppCast compatible feed, and all the hardware / software information is passed as url parameters, as in feed.php?osVersion=10.2.5&lang=en … etc.

So, by using good old Google, i found a really good script to generate the AppCast feed, but, i also needed a way to store the tracking data into a DB for later usage, and, i came up with this (really barebones, but working) prototype.

So, i did some minor modifications to the original PHP code; first, i changed the way to parse the version number from the file names, so as long as you use the pattern it will work, please note that you can put as much revision or subversion numbers as you wish: should also work.

This is the code snippet as i have it working now on my development server:

// ----------------------------------------------------------- //
// Script to generate an RSS appcast from folder contents
// Version 1.0.1
// (cc) Random Sequence 2007, Some Rights Reserved
// Licenced under a creative commons Attribution ShareAlike licence
// ----------------------------------------------------------- //
// REQUIRES PHP 5 or greater
// Tested with APACHE 1 & 2 on Mac OS X, Debian Linux   

// -------------------- BEGIN CONFIG ------------------------- //

$title = "Downloads";           // Used as feed title in feed readers
$description = "File List";     // Used as feed description in feed readers

// these are the types of files to list in the appcast & their MIME Types. Use lower case.
$fileTypes = array( "zip"=>"application/zip",

// -------------------- END OF CONFIG ------------------------ //

$appcastHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<rss version=\"2.0\" xmlns:dc=\"\" xmlns:sparkle=\"\">
    <title>MediaInfo Mac Software Updates Feed</title>
    <description>AppCast compatible feed for MediaInfo Mac Updates</description>
$appcastTemplate = "
            <guid  isPermaLink=\"false\">*guid*</guid>
                length=\"*length*\" />

$appcastFooter = "
$dir = getcwd()."/releases";
$files = scandir("$dir");
$etag = sha1(implode("/",$files));

// support for conditional fetch
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) {
    header('HTTP/1.1 304 Not Modified');

$appcast = $appcastHeader;

$link = "http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"];

$appcast = str_replace("*link*",$link,$appcast);
$appcast = str_replace("*title*",$title,$appcast);
$appcast = str_replace("*description*",$description,$appcast);

foreach ($files as $file) {
	if (isset($matches[1]) && isset($fileTypes[strtolower($matches[1])]) !== false) {
		$appcastFile = $appcastTemplate;
		$folderUrl = "http://".$_SERVER["HTTP_HOST"].substr($_SERVER["PHP_SELF"],0,strrpos($_SERVER["PHP_SELF"],"/"))."/releases/";
		$guid = $folderUrl.sha1($file);
		$path_parts = pathinfo($file);
		$title = mb_convert_case( str_replace("_", " ", $path_parts['filename']) , MB_CASE_TITLE, "UTF-8");
		//$description = preg_replace("/^(.*?)([0-9]+[a-z])\.([a-z09]{1,3})$/i","$1",$file);
		$description = getFileDescription("releases/".$file.".html");
		$pubdate = date("D, d M Y H:i:s",filectime("releases/".$file));
		$type = $fileTypes[strtolower($matches[1])];
		$url = $folderUrl.$file;
		$length = filesize("releases/".$file);  
		preg_match("/(\d+\.)+\d+/", $file, $m_version);
		$version = $m_version[0];
		//$version = preg_replace("/^(.*?)([0-9]+[a-z])\.([a-z09]{1,3})$/i","$2",$file);
		$appcastFile = str_replace("*guid*",$guid,$appcastFile);
		$appcastFile = str_replace("*title*",$title,$appcastFile);
		$appcastFile = str_replace("*description*",$description,$appcastFile);
		$appcastFile = str_replace("*version*",$version,$appcastFile);
		$appcastFile = str_replace("*pubdate*",$pubdate,$appcastFile);
		$appcastFile = str_replace("*type*",$type,$appcastFile);
		$appcastFile = str_replace("*url*",$url,$appcastFile);
		$appcastFile = str_replace("*length*",$length,$appcastFile);                                    
		$appcast .= $appcastFile;

// Reads a file called filename.html and returns the HTML output

function getFileDescription($fileName) {
	$handle = @fopen("$fileName", "r");
	$rValue = "";
	if ($handle) {
		while (!feof($handle)) {
			$buffer = fgets($handle, 4096);
			$rValue .= $buffer;
	return $rValue;

$appcast .= $appcastFooter;
/*"GET /u.php?UUID=F2958FD0-2EC9-40CA-8171-C63D663AAE90&
		ramMB=2048 HTTP/1.1" 200 575 "-" "MediaInfo Mac/ Sparkle/282"
// Database Functions

$vars = array('osVersion' , 'cputype', 'cpu64bit', 'cpusubtype', 'model', 'ncpu', 'lang', 'appName', 'appVersion', 'cpuFreqMHz', 'ramMB', 'UUID');
$values = array();
$shouldInsert = true;
foreach ($vars as $item) {
	if (isset($_GET[$item])) {
		$values[$item] = html_entity_decode($_GET[$item]);
	} else {
		if ($item != 'cpu64bit') {
			$shouldInsert = false;

if (isset($_GET['cpu64bit'])) {
	$values['cpu64bit'] = html_entity_decode($_GET['cpu64bit']);
} else {
	$values['cpu64bit'] = '0';

if ($shouldInsert == true) {
	$mysqli = new mysqli("yourDBHost", "yourDBUser", "yourDBPassword", "yourDBName");

	if (mysqli_connect_errno()) {
	    printf("Connect failed: %s\n", mysqli_connect_error());

	$stmt = $mysqli->prepare("INSERT INTO stats (os_version, cpu_type, cpu_64bit, cpu_subtype, model, n_cpu, lang, app_name, app_version, cpu_freq, ram_mb, UUID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
	$stmt->bind_param('siississsiis', $values['osVersion'], $values['cputype'], $values['cpu64bit'], $values['cpusubtype'], $values['model'], $values['ncpu'], $values['lang'], $values['appName'], $values['appVersion'], $values['cpuFreqMHz'], $values['ramMB'], $values['UUID']);


header("Content-type: application/xml; charset=UTF-8");
header("ETag: $etag");

echo $appcast;

As usual, suggestions or improvements are welcome ;)

MediaInfo Mac update released

Sunday, April 13th, 2008

Hi there, just a quick note to let you know that a new version of MediaInfo Mac ( has been released, not only it includes several bugfixes and improvements in the Cocoa arena, but also a new build of the MediaInfo engine which features the following improvements:

  • AVC: Count of reference frames.
  • AU: Comments.
  • Some global speed improvement.
  • Id3v2: Unsynchronized frames support (v2.3 & v2.4).
  • MKV: handling of files created for streaming.
  • MPEG-4: Handling of corrupted stream size info with some PCM streams.
  • DVD video: Hebrew patch (“iw” code is mapped to Hebrew).
  • MPEG-4: better handling of bitrate mode (VBR or CBR).
  • AVI: MediaInfo reads now the framerate value from the container rather than the stream value.
  • AC3: TrueHD detection.
  • MPEG-TS (or Bluray): VC-1, AC3+ and AC3 TrueHD detection.
  • AVC in MKV: all SEI userdata infos from x264/eavc in Writing library settings.
  • EVO: Better detection of duration.
  • Dirac: raw files parsing.
  • MPEG-TS: Dirac management.
  • MPEG-TS: DVB subtitles/Teletext management.
  • MPEG-4 Visual (DivX/XviD): writing library name was missing.
  • MPEG-Video: some DTS files with wrong extension were detected as MPEG-Video.
  • SWF: Compressed SWF files support is back.

If you are an actual user, just launch the application and use the auto update feature, or you can get the latest version by visiting the official MediaInfo Mac website.

As usual, feel free to leave any comment or suggestion in here.

Enjoy :)

Sticked WordPress Theme, beta release.

Saturday, April 12th, 2008

After a lot of work I’m happy to say that Sticked is ready!

Sticked is a WordPress theme that i had in mind since too many time ago, and now, i am sharing it with you all :).


  • Customizable background and body textures. [Click here to see screenshot]
    You can select from a bunch of available textures for both your page background and your main body background, you can even create your own if you feel like.
  • Customizable colors for “Stickies”. [Click here to see screenshot]
    Sticked will add a new setting in your admin UI, there you can select an specific color for each post.
  • Compatible with most modern (and not so modern) browsers.
    Sticked has been tested with the following browsers: 

    • Internet Explorer 6: 80% – (Some minor image glitches due to the lack of support for PNG transparent images in this browser).
    • Internet Explorer 7 & Internet Explorer 8: 100%.
    • Safari for Mac and Windows: 100%.
    • Opera 9 for Mac and Windows: 100%.
    • Firefox for Mac and Windows: 100%.
  • Styled blockquotes:
    By using the <blockquote> tag, you can create specific boxes to highlight parts of your content, examples below: 

    This text is enclosed between <blockquote></blockquote> html tags.

    This text is enclosed between <blockquote class=”mac”></blockquote> html tags.

    This text is enclosed between <blockquote class=”warning”></blockquote> html tags.

  • Proportional fonts:
    Sticked uses proportional fonts, that means that the text size will be readable and consistent at any resolution, including big LCD screens.
  • Widgets Ready:
    Sticked is compatible with most WordPress sidebar widgets out there.

Theme Downloads and Tools

CLICK HERE to download the latest version (0.6) of Sticked for WordPress 2.5

CLICK HERE to download a PSD (Photoshop) file containing a blank header.

Installation is like with any other WordPress Theme, just upload the contents of the zip file inside your wp-content/themes/ directory and you are done.

If you have any question or suggestion, feel free to leave a comment here.

8 random facts about myself

Tuesday, April 8th, 2008

Well, it looks like I got tagged. Here are the rules: 

  • Each player starts with eight random facts/habits about themselves.
  • People who are tagged need to write a post on their own blog (about their eight things) and post these rules.
  • At the end of your blog, you need to choose eight people to get tagged and list their names.
  • I like absurd humor movies, specially old ones like The Pink Panther series, almost anything from Peter Sellers, stupid things like “The Naked Gun“, etc. I also enjoy quality love / history stories like “Cinema Paradiso” or “Somebody like You”.
  • I enjoy sharing my skills with different people, and also learning from them, that makes me discover new things almost daily and meet new cool people all around the world.
  • I **AM** an addict to technology, specially computers and synthesizers.
  • I believe that the whole internet era changed the meaning of the word “Friend”, I truly believe that you can feel “friendship” for people that you don’t know in real life, that usually put me in terrible discussions with other people who seems to believe the contrary.
  • I am a person who likes good Wines and quality Food, i like to cook my own food and usually i like to invite friends to enjoy whatever i prepare.
  • Unless I am in a relationship with some girl, I´m usually a lonely person, maybe because I am more of a creative person, and creativity usually comes when you are relaxed and alone.
  • I do believe in love more than anything else, thats a fact.
  • I enjoy helping others as much as i can, I believe that it is a good way to feel realized about yourself.

After all this rant about myself, I’m tagging the following people:

Zach & Timothy, sadly, most of my friends don’t have blogs, so that’s all :p

Stck’d, a new WordPress Theme for my blog.

Sunday, April 6th, 2008

Hi there, as you maybe noticed, I did a complete redesign of this blog and I am using for the first time a custom WordPress Theme that i have created from scratch.

This is my first ever WordPress Theme so i hope you like it :)

The idea for Stck’d was to create a theme with some smooth visual elements while maintaining an easy to the eyes structure and focusing on the contents, instead of graphics.

It is on my plans to release this theme for free as soon as i finish fixing bugs, etc, so if you like it or you have any comment / suggestion, feel free to leave a comment in here, any feedback is appreciated.

April 7, some updates:

Per-post color selection:

It is now possible to select the post-it color on a per post basis, just add a custom field called “color” to your post, and it will automagically change the paper color for said item. Available colors are:

  • Cyan.
  • Green.
  • Pink.
  • Yellow.
  • Magenta.

Adding a custom color field for a post.

Stck’d is now compatible with the following browsers:

// Diego.

bbPress, an amazing platform for forums and message boards!

Saturday, April 5th, 2008

In the past days, i have been working on the design and development of a new “community like” website. Since the main purpose of this site is to inform fans of a rock band about tour dates, news, events, etc, WordPress was my CMS of choice for the backend (on top of that, i have been waiting a lot to have a chance to learn the WordPress Theme API), but the real problem showed up when i had to choose what forum software i was going to use.

At first, i started by using phpbb3, which is great, but even the fact that there are some WordPress integration solutions, etc, i had to hack a lot the integration code, and it wasn’t really working as tight as i wanted to… and then…. i found bbPress!.

bbPress is a fairly young forum software developed by the same guys in charge of the WordPress codebase, it is not only a pleasure to work with it, but it is also a pleasure to modify it to fit your needs. It uses a templating engine almost 100% identical to the one on WordPress, it integrates seamlessly with WordPress, and, on top of that, it is fast as hell, what more could you ask for ? :D

If you are curious enough, you can take a look at how things are looking so far, keep in mind that this is still work in progress :)

Some CSS explanations…

Saturday, April 5th, 2008

Another big moment from #CSS on freenode :p

[Riyonuk] does list-style-type go on ul or li?
[reisio] Riyonuk: either, but ul is a better idea
[Riyonuk] why?
[reisio] ...and I use 'list-style'
[reisio] because ul applies to the ul and the li's within it
[reisio] li only applies to the li's
[Riyonuk] but the ul itself doesn't have bullets
[Riyonuk] the li's have bullets
[reisio] that's moot
[Riyonuk] how so?
[reisio] for the same reason saying 'guys don't have breasts' is moot
[Riyonuk] not really
[reisio] guys do have breasts
[reisio] they just don't usually have mammory glands
[Riyonuk] ok, how did we go from css bullet propertys to male breasts ]_]
[reisio] you asked :p
[reisio] breast plate?
[reisio] it's basically just the top of your chest
[reisio] female boob fun realm just happens to coincide there
[reisio] so it's become fairly synonymous
[Riyonuk] I'm just gonna add list-style-type to ul
[Riyonuk] ._.
[Riyonuk] I remmeber when were young, and every saturday after school, we'd go down to the beach, and I'd throw sand in your eyes
[reisio] yeah that was fun and lame
[Riyonuk] crap, wrong channel
[Riyonuk] XD