--- /dev/null
+#!/usr/bin/php
+<?php
+require_once('test/Obj/test.phh');
+require_once('web/Obj/brisk.phh');
+
+$arr = array(array('v1' => '', 'v2' => '', 'exp' => 0),
+
+ array('v1' => '1.2.3', 'v2' => '1.2.3', 'exp' => 0),
+
+ array('v1' => '1.2.3', 'v2' => '1.2', 'exp' => 0),
+ array('v1' => '1.2.3', 'v2' => '1', 'exp' => 0),
+
+ array('v1' => '1.2', 'v2' => '1.2.3', 'exp' => 0),
+ array('v1' => '1', 'v2' => '1.2.3', 'exp' => 0),
+
+ array('v1' => '1', 'v2' => '2', 'exp' => -1),
+ array('v1' => '2', 'v2' => '1', 'exp' => 1),
+
+ array('v1' => '0.1', 'v2' => '0.2', 'exp' => -1),
+ array('v1' => '0.2', 'v2' => '0.1', 'exp' => 1),
+
+ array('v1' => '0.0.1', 'v2' => '0.0.2', 'exp' => -1),
+ array('v1' => '0.0.2', 'v2' => '0.0.1', 'exp' => 1),
+
+ array('v1' => '0.0.2', 'v2' => '0.0.1', 'exp' => 1),
+ );
+
+$tb = ' ';
+foreach($arr as $el) {
+ $ret = versions_cmp($el['v1'], $el['v2']);
+ printf("V1: [%s]\nV2: [%s]\nRet: [%+d]\n", $el['v1'], $el['v2'], $ret);
+ if ($ret != $el['exp']) {
+ printf("\nExp: [%+d] Ret and Exp differ!\n\n", $el['exp']);
+ exit(1);
+ }
+ else {
+ printf("\n");
+ }
+}
+exit(0);
+?>
<br><b>version '.$G_brisk_version.'</b><br><br>
Copyright 2006-2012 <a href=\\"mailto:brisk@alternativeoutput.it\\">Matteo Nastasi</a> (aka mop)<br><br>');
+// return values
+// -1 v1 < v2
+// 0 equal
+// 1 v1 > v2
+function versions_cmp($v1, $v2)
+{
+ // printf("V1: [%s]\nV2: [%s]\n", $v1, $v2);
+ if ($v1 == $v2)
+ return 0;
+
+ $v1_ar = split('\.', $v1);
+ $v2_ar = split('\.', $v2);
+
+ $v2_ct = count($v2_ar);
+
+ for ($i = 0 ; $i < count($v1_ar) ; $i++) {
+ if (($v2_ct - 1) < $i) {
+ break;
+ }
+ // printf("here [%s] [%s]\n", $v1_ar[$i], $v2_ar[$i]);
+ if ($v1_ar[$i] != $v2_ar[$i]) {
+ if (strval($v1_ar[$i]) < strval($v2_ar[$i]))
+ return -1;
+ else
+ return 1;
+ }
+ }
+ return 0;
+}
+
function addrtoipv4($addr)
{
$ipv4addr_arr = explode(':' , $addr);