Skip to content

Commit ed4c8a4

Browse files
committed
Merge pull request #39 from proditis/master
prep for release. this is getting way too long...
2 parents 58decf3 + 95e7bde commit ed4c8a4

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

htdocs/protected/models/Host.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,19 @@ public function resolve()
185185
}
186186
}
187187

188+
188189
public function beforeSave()
189190
{
190191
if($this->isNewRecord || $this->ipoctet===NULL || (ip2long($this->ipoctet)!==false && $this->ip!=ip2long($this->ipoctet)))
191192
{
192-
//if(ip2long($this->ipoctet)!==false && ip2long($this->ipoctet)!=0 && $this->ip==0)
193-
$this->ip=ip2long($this->ip);
193+
$this->ip=ip2long($this->ip);
194194
}
195195
return parent::beforeSave();
196196
}
197+
198+
/**
199+
* convert bit masks into cidr notation netmask
200+
*/
197201
public static function netmask($cidr=0)
198202
{
199203
$parts=explode('.',$cidr);
@@ -204,22 +208,33 @@ public static function netmask($cidr=0)
204208
return false;
205209
}
206210

211+
/**
212+
* strip any comparison symbols (such as <,>,=)
213+
* and return the $string without it.
214+
*/
207215
public static function strip_comparison($string)
208216
{
209217
$rep=array('<','>','=');
210218
return str_replace($rep,'',$string);
211219
}
212-
220+
221+
/**
222+
* returns the comparison symbols from the string.
223+
* $string comes from the search filters of the admin views.
224+
* This function grabs the >,<,= and combinations such as <=,>=
225+
*/
213226
public static function get_comparison($string)
214227
{
215228
$ret="";
216229

217230
for($i=0;$i<strlen($string);$i++)
218231
if( $string{$i}!='=' && $string{$i}!='<' && $string{$i}!='>')
219-
break;
220-
if(strlen(trim($string))==0 || $i==strlen($string))
221-
return "";
222-
return substr($string, 0,$i);
232+
break;
233+
234+
if(strlen(trim($string))==0 || $i==strlen($string))
235+
return "";
236+
237+
return substr($string, 0,$i);
223238
}
224239

225240
}

schema/00_echofish-schema.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,10 @@ CREATE TABLE `host` (
382382
id int unsigned primary key auto_increment,
383383
ip int unsigned default 0,
384384
fqdn varchar(255) NOT NULL,
385-
short varchar(50) unique,
385+
short varchar(50),
386386
description text,
387-
unique key `host_details` (fqdn,short,ip)
387+
KEY (`short`),
388+
UNIQUE KEY `host_details` (`short`,`fqdn`,`ip`)
388389
) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_unicode_ci;
389390

390391
DROP TABLE IF EXISTS `trail`;

schema/updates/v0.4-to-v0.5.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ ALTER TABLE `syslog` CHANGE `host` `host` INT UNSIGNED NOT NULL ;
1515

1616
ALTER TABLE `host` DROP PRIMARY KEY;
1717
ALTER TABLE `host` ADD `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ;
18-
ALTER TABLE `host` ADD UNIQUE ( `short` );
19-
ALTER TABLE `host` ADD UNIQUE key `host_details` (`fqdn`,`short`,`ip`);
18+
DROP INDEX `short` ON `host`; /* This is meant for the unique index */
19+
CREATE INDEX `short` on `host`(`short`);
20+
CREATE UNIQUE INDEX `host_details` ON `host`(`fqdn`,`short`,`ip`);
2021

2122
UPDATE `syslog` as t1 LEFT JOIN host as t2 ON t1.host=t2.ip SET t1.host=t2.id;
2223
UPDATE `archive` as t1 LEFT JOIN host as t2 ON t1.host=t2.ip SET t1.host=t2.id;

0 commit comments

Comments
 (0)