Ejemplo n.º 1
0
 /**
  * 
  * @param ARRAY $field
  * @param BOOLEAN $multi
  * @return STRING 
  */
 function createTextfield($field, $multi = false)
 {
     $output = "<input";
     $type = $field['type'];
     $value = !empty($field['value']) ? ' value="' . escape_quotes(htmlspecialchars_decode($field['value'])) . '"' : null;
     $size .= !empty($field['size']) ? ' size="' . $field['size'] . '" ' : null;
     $closing = "/>";
     switch ($type) {
         case "text":
         case "textfield":
             $output .= ' type="text"';
             break;
         case "email":
             $output .= ' type="email"';
             break;
         case "password":
         case "pass":
             $output .= ' type="password"';
             break;
         case "hidden":
             $output .= ' type="hidden"';
             break;
         case "telephone":
         case "tel":
             $output .= ' type="tel"';
             break;
         case "textarea":
             $output = '<textarea';
             $value = '>' . htmlspecialchars_decode($field['value']);
             $size = !empty($field['size']) ? ' cols="' . $field['size'] . '" ' : null;
             $rows = !empty($field['rows']) ? ' rows="' . $field['rows'] . '" ' : null;
             $closing = "</textarea>";
             break;
     }
     $placeholder = $field['placeholder'] ? $field['placeholder'] : $field['title'];
     if ($placeholder) {
         $output .= ' placeholder="' . $placeholder . '" ';
     }
     if (!empty($field['name'])) {
         if ($mutli == false) {
             $output .= ' name="' . $field['name'] . '"';
         } else {
             $output .= ' name="' . $field['name'] . '[]"';
         }
     }
     if (!empty($field['id'])) {
         $output .= ' id="' . $field['id'] . '"';
     }
     if (!empty($field['class'])) {
         $output .= ' class="' . $field['class'] . '"';
     }
     if (!empty($field['extra_tags'])) {
         $output .= $field['extra_tags'];
     }
     // Merge everything
     return $output . $size . $rows . $value . $closing;
 }
Ejemplo n.º 2
0
function generate_port_link($port, $text = null, $type = null, $overlib = 1, $single_graph = 0)
{
    global $config;
    $graph_array = array();
    $port = ifNameDescr($port);
    if (!$text) {
        $text = fixIfName($port['label']);
    }
    if ($type) {
        $port['graph_type'] = $type;
    }
    if (!isset($port['graph_type'])) {
        $port['graph_type'] = 'port_bits';
    }
    $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    if (!isset($port['hostname'])) {
        $port = array_merge($port, device_by_id_cache($port['device_id']));
    }
    $content = '<div class=list-large>' . $port['hostname'] . ' - ' . fixifName($port['label']) . '</div>';
    if ($port['ifAlias']) {
        $content .= escape_quotes($port['ifAlias']) . '<br />';
    }
    $content .= "<div style=\\'width: 850px\\'>";
    $graph_array['type'] = $port['graph_type'];
    $graph_array['legend'] = 'yes';
    $graph_array['height'] = '100';
    $graph_array['width'] = '340';
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $port['port_id'];
    $content .= generate_graph_tag($graph_array);
    if ($single_graph == 0) {
        $graph_array['from'] = $config['time']['week'];
        $content .= generate_graph_tag($graph_array);
        $graph_array['from'] = $config['time']['month'];
        $content .= generate_graph_tag($graph_array);
        $graph_array['from'] = $config['time']['year'];
        $content .= generate_graph_tag($graph_array);
    }
    $content .= '</div>';
    $url = generate_port_url($port);
    if ($overlib == 0) {
        return $content;
    } else {
        if (port_permitted($port['port_id'], $port['device_id'])) {
            return overlib_link($url, $text, $content, $class);
        } else {
            return fixifName($text);
        }
    }
}
Ejemplo n.º 3
0
function generate_device_link($device, $text = null, $vars = array(), $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
{
    global $config;
    if (!$start) {
        $start = $config['time']['day'];
    }
    if (!$end) {
        $end = $config['time']['now'];
    }
    $class = devclass($device);
    if (!$text) {
        $text = $device['hostname'];
    }
    if (isset($config['os'][$device['os']]['over'])) {
        $graphs = $config['os'][$device['os']]['over'];
    } else {
        if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) {
            $graphs = $config['os'][$device['os_group']]['over'];
        } else {
            $graphs = $config['os']['default']['over'];
        }
    }
    $url = generate_device_url($device, $vars);
    // beginning of overlib box contains large hostname followed by hardware & OS details
    $contents = '<div><span class="list-large">' . $device['hostname'] . '</span>';
    if ($device['hardware']) {
        $contents .= ' - ' . $device['hardware'];
    }
    if ($device['os']) {
        $contents .= ' - ' . mres($config['os'][$device['os']]['text']);
    }
    if ($device['version']) {
        $contents .= ' ' . mres($device['version']);
    }
    if ($device['features']) {
        $contents .= ' (' . mres($device['features']) . ')';
    }
    if (isset($device['location'])) {
        $contents .= ' - ' . htmlentities($device['location']);
    }
    $contents .= '</div>';
    foreach ($graphs as $entry) {
        $graph = $entry['graph'];
        $graphhead = $entry['text'];
        $contents .= '<div class="overlib-box">';
        $contents .= '<span class="overlib-title">' . $graphhead . '</span><br />';
        $contents .= generate_minigraph_image($device, $start, $end, $graph);
        $contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph);
        $contents .= '</div>';
    }
    if ($escape_text) {
        $text = htmlentities($text);
    }
    if ($overlib == 0) {
        $link = $contents;
    } else {
        $link = overlib_link($url, $text, escape_quotes($contents), $class);
    }
    if (device_permitted($device['device_id'])) {
        return $link;
    } else {
        return $device['hostname'];
    }
}
Ejemplo n.º 4
0
 /**
  * FUNCTION USED TO CREATE TEXT FIELD
  * @param name
  * @param id
  * @param value
  * @param class
  * @param extra_tags
  * @param label
  */
 function createTextfield($field, $multi = FALSE)
 {
     //Starting Text Field
     if ($field['type'] == 'textfield') {
         $textField = '<input type="text"';
     }
     if ($field['type'] == 'password') {
         $textField = '<input type="password"';
     } elseif ($field['type'] == 'textarea') {
         $textField = '<textarea';
     }
     if (!empty($field['name'])) {
         if (!$multi) {
             $textField .= ' name="' . $field['name'] . '" ';
         } else {
             $textField .= ' name="' . $field['name'] . '[]" ';
         }
     }
     if (!empty($field['id'])) {
         $textField .= ' id="' . $field['id'] . '" ';
     }
     if (!empty($field['class'])) {
         $textField .= ' class="' . $field['class'] . '" ';
     }
     if (!empty($field['size'])) {
         if (${$field}['type'] == 'textfield' || $field['type'] == 'password') {
             $textField .= ' size="' . $field['size'] . '" ';
         } else {
             $textField .= ' cols="' . $field['size'] . '" ';
         }
     }
     if (!empty($field['rows']) && $field['type'] == 'textarea') {
         $textField .= ' rows="' . $field['rows'] . '" ';
     }
     if (!empty($field['extra_tags'])) {
         $textField .= ' ' . $field['extra_tags'] . ' ';
     }
     if (!empty($field['value'])) {
         if ($field['type'] == 'textfield' || $field['type'] == 'password') {
             $textField .= ' value="' . escape_quotes(htmlspecialchars_decode($field['value'])) . '" ';
         }
     }
     if ($field['type'] == 'textarea') {
         $textField .= '>' . htmlspecialchars_decode($field['value']);
     }
     //Finishing It
     if ($field['type'] == 'textfield' || $field['type'] == 'password') {
         $textField .= ' >';
     } elseif ($field['type'] == 'textarea') {
         $textField .= '</textarea>';
     }
     //Checking Label
     if (!empty($field['label'])) {
         $formTextField = '<label>' . $field['label'] . $textField . '</label>';
     } else {
         $formTextField = $textField;
     }
     return $formTextField;
 }
Ejemplo n.º 5
0
function replace_restricted_words($str)
{
    $words = array_filter(explode(" ", $str), "remove_empty");
    foreach ($words as $key => $value) {
        $checkQ = db_query("SELECT 1\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\temprivo.restricted_words\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tword = '" . escape_quotes($value) . "'");
        if (db_num_rows($checkQ)) {
            for ($i = 0; $i < strlen($value); $i++) {
                $stars .= "*";
            }
            $words[$key] = $stars;
        }
    }
    return array_to_string($words);
}