Ejemplo n.º 1
0
 function CheckInput()
 {
     $this->MakeSafe();
     if (!in_array($this->AttributeType, DeviceCustomAttribute::GetDeviceCustomAttributeTypeList())) {
         return false;
     }
     if (trim($this->DefaultValue) != "") {
         switch ($this->AttributeType) {
             case "number":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_FLOAT)) {
                     return false;
                 }
                 break;
             case "integer":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_INT)) {
                     return false;
                 }
                 break;
             case "date":
                 $dateparts = preg_split("/\\/|-/", $this->DefaultValue);
                 if (count($dateparts) != 3 || !checkdate($dateparts[0], $dateparts[1], $dateparts[2])) {
                     return false;
                 }
                 break;
             case "phone":
                 // stole this regex out of the jquery.validationEngine-en.js source
                 if (!preg_match("/^([\\+][0-9]{1,3}[\\ \\.\\-])?([\\(]{1}[0-9]{2,6}[\\)])?([0-9\\ \\.\\-\\/]{3,20})((x|ext|extension)[\\ ]?[0-9]{1,4})?\$/", $this->DefaultValue)) {
                     return false;
                 }
                 break;
             case "email":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_EMAIL)) {
                     return false;
                 }
                 break;
             case "ipv4":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_IP)) {
                     return false;
                 }
                 break;
             case "url":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_URL)) {
                     return false;
                 }
                 break;
             case "checkbox":
                 $acceptable = array("0", "1", "true", "false", "on", "off");
                 if (!in_array($this->DefaultValue, $acceptable)) {
                     return false;
                 }
                 break;
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 function CheckInput()
 {
     $this->MakeSafe();
     if (!in_array($this->AttributeType, DeviceCustomAttribute::GetDeviceCustomAttributeTypeList())) {
         return false;
     }
     if (trim($this->DefaultValue) != "") {
         switch ($this->AttributeType) {
             case "number":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_FLOAT)) {
                     return false;
                 }
                 break;
             case "integer":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_INT)) {
                     return false;
                 }
                 break;
             case "date":
                 $dateparts = preg_split("/\\/|-/", $this->DefaultValue);
                 if (count($dateparts) != 3 || !checkdate($dateparts[0], $dateparts[1], $dateparts[2])) {
                     return false;
                 }
                 break;
             case "phone":
                 // stole this regex out of the jquery.validationEngine-en.js source
                 if (!preg_match("/^([\\+][0-9]{1,3}[\\ \\.\\-])?([\\(]{1}[0-9]{2,6}[\\)])?([0-9\\ \\.\\-\\/]{3,20})((x|ext|extension)[\\ ]?[0-9]{1,4})?\$/", $this->DefaultValue)) {
                     return false;
                 }
                 break;
             case "email":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_EMAIL)) {
                     return false;
                 }
                 break;
             case "ipv4":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_IP)) {
                     return false;
                 }
                 break;
             case "url":
                 if (!filter_var($this->DefaultValue, FILTER_VALIDATE_URL)) {
                     return false;
                 }
                 break;
             case "checkbox":
                 $acceptable = array("0", "1", "true", "false", "on", "off");
                 if (!in_array($this->DefaultValue, $acceptable)) {
                     return false;
                 }
                 break;
             case "set":
                 // Attempt to stem S.U.T. here
                 // will track if we want a blank space at the beginning of our list
                 $blankstart = substr($this->DefaultValue, 0, 1) == ',';
                 // will store an array of our stuff
                 $dirtyarray = array();
                 // parse the list combining / removing duplicates
                 foreach (explode(',', $this->DefaultValue) as $item) {
                     $dirtyarray[$item] = $item;
                 }
                 // trim possible leading blank spaces / other blanks
                 if (!$blankstart) {
                     unset($dirtyarray['']);
                 }
                 // condense back to csv
                 $this->DefaultValue = implode(',', $dirtyarray);
                 break;
         }
     }
     return true;
 }
Ejemplo n.º 3
0
    foreach ($mediaList as $mt) {
        $mediatypes .= '<div>
					<div><img src="images/del.gif"></div>
					<div><input type="text" name="mediatype[]" data=' . $mt->MediaID . ' value="' . $mt->MediaType . '"></div>
					<div><select name="mediacolorcode[]"><option value=""></option>';
        foreach ($codeList as $cc) {
            $selected = $mt->ColorID == $cc->ColorID ? ' selected' : '';
            $mediatypes .= "<option value=\"{$cc->ColorID}\"{$selected}>{$cc->Name}</option>";
        }
        $mediatypes .= '</select></div>
				</div>';
    }
}
// build list of existing device custom attributes
$customattrs = "";
$dcaTypeList = DeviceCustomAttribute::GetDeviceCustomAttributeTypeList();
$dcaList = DeviceCustomAttribute::GetDeviceCustomAttributeList();
if (count($dcaList) > 0) {
    foreach ($dcaList as $dca) {
        $customattrs .= '<div>
					<div><img src="images/del.gif"></div>
					<div><input type="text" name="dcalabel[]" data=' . $dca->AttributeID . ' value="' . $dca->Label . '"></div>
					<div><select name="dcatype[]" id="dcatype">';
        foreach ($dcaTypeList as $dcatype) {
            $selected = $dca->AttributeType == $dcatype ? ' selected' : '';
            $customattrs .= "<option value=\"{$dcatype}\"{$selected}>{$dcatype}</option>";
        }
        $customattrs .= '</select></div>
					<div><input type="checkbox" name="dcarequired[]"';
        if ($dca->Required) {
            $customattrs .= ' checked';