', '`', '\'', '"', '|', '+', '[', ']', '{', '}', ';', '!', '%'); static $drop_char_replace = array('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); return str_replace($drop_char_match, $drop_char_replace, urldecode($str)); } // much looser sanitise for general strings that shouldn't have HTML in them function wm_editor_sanitize_string($str) { static $drop_char_match = array('<', '>' ); static $drop_char_replace = array('', ''); return str_replace($drop_char_match, $drop_char_replace, urldecode($str)); } function wm_editor_validate_bandwidth($bw) { if(preg_match( '/^(\d+\.?\d*[KMGT]?)$/', $bw) ) { return true; } return false; } function wm_editor_validate_one_of($input,$valid=array(),$case_sensitive=false) { if(! $case_sensitive ) $input = strtolower($input); foreach ($valid as $v) { if(! $case_sensitive ) $v = strtolower($v); if($v == $input) return true; } return false; } // Labels for Nodes, Links and Scales shouldn't have spaces in function wm_editor_sanitize_name($str) { return str_replace( array(" "), "", $str); } function wm_editor_sanitize_selected($str) { $res = urldecode($str); if( ! preg_match("/^(LINK|NODE):/",$res)) { return ""; } return wm_editor_sanitize_name($res); } function wm_editor_sanitize_file($filename,$allowed_exts=array()) { $filename = wm_editor_sanitize_uri($filename); if ($filename == "") return ""; $ok = false; foreach ($allowed_exts as $ext) { $match = ".".$ext; if( substr($filename, -strlen($match),strlen($match)) == $match) { $ok = true; } } if(! $ok ) return ""; return $filename; } function wm_editor_sanitize_conffile($filename) { $filename = wm_editor_sanitize_uri($filename); # If we've been fed something other than a .conf filename, just pretend it didn't happen if ( substr($filename,-5,5) != ".conf" ) { $filename = ""; } # on top of the url stuff, we don't ever need to see a / in a config filename (CVE-2013-3739) if (strstr($filename,"/") !== false ) { $filename = ""; } return $filename; } function show_editor_startpage() { global $mapdir, $WEATHERMAP_VERSION, $config_loaded, $cacti_found, $ignore_cacti,$configerror; $fromplug = false; if (isset($_REQUEST['plug']) && (intval($_REQUEST['plug'])==1) ) { $fromplug = true; } $matches=0; $errormessage = ""; if ($configerror!='') { $errormessage .= $configerror.'
'; } if ( !$observium_found && !$ignore_observium) { //$errormessage .= '$cacti_base is not set correctly. Cacti integration will be disabled in the editor.'; //$errormessage .= "$observium_found and $ignore_observium"; //if ($config_loaded != 1) { //$errormessage .= " You might need to copy editor-config.php-dist to editor-config.php and edit it."; //} } if ($errormessage != '') { print '
'; // print 'Do you want to:
'; print '