Skip to content

Commit 754e182

Browse files
committed
fix some indentation issues and comment some of the public methods we
introduced into the Host model.
1 parent 8a71d5f commit 754e182

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
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
}

0 commit comments

Comments
 (0)