jablonka.czprosek.czf

weathermap

Subversion Repositories:
[/] [editor.inc.php] - Diff between revs 1 and 13

Show entire file Ignore whitespace

Rev 1 Rev 13
Line 2... Line 2...
function show_editor_startpage() function show_editor_startpage()
{ {
global $mapdir, $WEATHERMAP_VERSION; global $mapdir, $WEATHERMAP_VERSION, $config_loaded, $cacti_found, $ignore_cacti;
   
$matches=0; $matches=0;
   
print '<html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" media="screen" href="editor.css" /> <script src="editor.js" type="text/javascript"></script><title>PHP Weathermap Editor ' . $WEATHERMAP_VERSION print '<html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" media="screen" href="editor.css" /> <script src="editor.js" type="text/javascript"></script><title>PHP Weathermap Editor ' . $WEATHERMAP_VERSION
. '</title></head><body>'; . '</title></head><body>';
   
print '<div id="nojs" class="alert"><b>WARNING</b> - '; print '<div id="nojs" class="alert"><b>WARNING</b> - ';
print 'Sorry, it\'s partly laziness on my part, but you really need JavaScript enabled and DOM support in your browser to use this editor. It\'s a visual tool, so accessibility is already an issue, if it is, and from a security viewpoint, you\'re already running my '; print 'Sorry, it\'s partly laziness on my part, but you really need JavaScript enabled and DOM support in your browser to use this editor. It\'s a visual tool, so accessibility is already an issue, if it is, and from a security viewpoint, you\'re already running my ';
print 'code on your <i>server</i> so either you trust it all having read it, or you\'re already screwed.<P>'; print 'code on your <i>server</i> so either you trust it all having read it, or you\'re already screwed.<P>';
print 'If it\'s a major issue for you, please feel free to complain. It\'s mainly laziness as I said, and there could be a fallback (not so smooth) mode for non-javascript browsers if it was seen to be worthwhile (I would take a bit of convincing, because I don\'t see a benefit, personally).</div>'; print 'If it\'s a major issue for you, please feel free to complain. It\'s mainly laziness as I said, and there could be a fallback (not so smooth) mode for non-javascript browsers if it was seen to be worthwhile (I would take a bit of convincing, because I don\'t see a benefit, personally).</div>';
   
  $errormessage = "";
   
  if(! $cacti_found && !$ignore_cacti)
  {
  $errormessage .= '$cacti_base is not set correctly. Cacti integration will be disabled in the editor.';
  if($config_loaded != 1) { $errormessage .= " You might need to copy editor-config.php-dist to editor-config.php and edit it."; }
  }
   
  if($errormessage != '')
  {
  print '<div class="alert" id="nocacti">'.$errormessage.'</div>';
  }
   
print '<div id="withjs">'; print '<div id="withjs">';
print '<div id="dlgStart" class="dlgProperties" ><div class="dlgTitlebar">Welcome</div><div class="dlgBody">'; print '<div id="dlgStart" class="dlgProperties" ><div class="dlgTitlebar">Welcome</div><div class="dlgBody">';
print 'Welcome to the PHP Weathermap '.$WEATHERMAP_VERSION.' editor.<p>'; print 'Welcome to the PHP Weathermap '.$WEATHERMAP_VERSION.' editor.<p>';
print '<div style="border: 3px dashed red; background: #055; padding: 5px; font-size: 97%;"><b>NOTE:</b> This editor is not finished! There are many features of '; print '<div style="border: 3px dashed red; background: #055; padding: 5px; font-size: 97%;"><b>NOTE:</b> This editor is not finished! There are many features of ';
print 'Weathermap that you will be missing out on if you choose to use the editor only.'; print 'Weathermap that you will be missing out on if you choose to use the editor only.';
print 'These include: curves, node offsets, font definitions, colour changing, per-node/per-link settings and image uploading. You CAN use the editor without damaging these features if you added them by hand, however.</div><p>'; print 'These include: curves, node offsets, font definitions, colour changing, per-node/per-link settings and image uploading. You CAN use the editor without damaging these features if you added them by hand, however.</div><p>';
   
   
print 'Do you want to:<p>'; print 'Do you want to:<p>';
print 'Create A New Map:<br>'; print 'Create A New Map:<br>';
print '<form method="GET">'; print '<form method="GET">';
print 'Named: <input type="text" name="mapname" size="20">'; print 'Named: <input type="text" name="mapname" size="20">';
   
Line 42... Line 57...
while ($file=readdir($dh)) while ($file=readdir($dh))
{ {
$realfile=$mapdir . DIRECTORY_SEPARATOR . $file; $realfile=$mapdir . DIRECTORY_SEPARATOR . $file;
   
// if(is_file($realfile) && ( preg_match('/\.conf$/',$file) )) // if(is_file($realfile) && ( preg_match('/\.conf$/',$file) ))
if (is_file($realfile) ) if ( (is_file($realfile)) && (is_readable($realfile)) )
{ {
$title='(no title)'; $title='(no title)';
$fd=fopen($realfile, "r"); $fd=fopen($realfile, "r");
  if($fd)
while (!feof($fd))  
{ {
$buffer=fgets($fd, 4096); while (!feof($fd))
  {
if (preg_match("/^\s*TITLE\s+(.*)/i", $buffer, $matches)) { $title=$matches[1]; } $buffer=fgets($fd, 4096);
   
  if (preg_match("/^\s*TITLE\s+(.*)/i", $buffer, $matches)) { $title=$matches[1]; }
  }
   
  fclose ($fd);
  $titles[$file] = $title;
  # print "<li><a href=\"?mapname=$file\">$file</a> - <span class=\"comment\">$title</span></li>\n";
  $n++;
} }
   
fclose ($fd);  
$titles[$file] = $title;  
# print "<li><a href=\"?mapname=$file\">$file</a> - <span class=\"comment\">$title</span></li>\n";  
$n++;  
} }
} }
   
closedir ($dh); closedir ($dh);
} }
Line 249... Line 266...
closedir ($dh); closedir ($dh);
} }
} }
return ($imagelist); return ($imagelist);
} }
   
  function handle_inheritance(&$map, &$inheritables)
  {
  foreach ($inheritables as $inheritable)
  {
  $fieldname = $inheritable[1];
  $formname = $inheritable[2];
   
  $new = $_REQUEST[$formname];
   
  $old = ($inheritable[0]=='node' ? $map->defaultnode->$fieldname : $map->defaultlink->$fieldname);
   
  if($old != $new)
  {
  if($inheritable[0]=='node')
  {
  $map->defaultnode->$fieldname = $new;
  foreach ($map->nodes as $node)
  {
  if($node->$fieldname == $old)
  {
  $map->nodes[$node->name]->$fieldname = $new;
  }
  }
  }
   
  if($inheritable[0]=='link')
  {
  $map->defaultlink->$fieldname = $new;
  foreach ($map->links as $link)
  {
  if($link->$fieldname == $old)
  {
  $map->links[$link->name]->$fieldname = $new;
  }
  }
  }
  }
  }
  }
   
  function get_fontlist(&$map,$name,$current)
  {
  $output = '<select class="fontcombo" name="'.$name.'">';
   
  # $sortedfonts = $map->fonts;
  # ksort ($sortedfonts);
  ksort($map->fonts);
   
  foreach ($map->fonts as $fontnumber => $font)
  {
  $output .= '<option ';
  if($current == $fontnumber) $output .= 'SELECTED';
  $output .= ' value="'.$fontnumber.'">'.$fontnumber.' ('.$font->type.')</option>';
  }
   
  $output .= "</select>";
   
  return($output);
  }
   
// vim:ts=4:sw=4: // vim:ts=4:sw=4:
?> ?>
   

Powered by WebSVN 2.2.1