#!/usr/bin/php readPHPArgv(); $ret=$cg->getopt($args, $short_opts, $long_opts); if (PEAR::isError($ret)) { die ("Error in command line: " . $ret->getMessage() . "\n (try --help)\n"); } $gopts=$ret[0]; $options_output = array(); if (sizeof($gopts) > 0) { foreach ($gopts as $o) { switch ($o[0]) { case '--config': $configfile=$o[1]; break; case '--htmloutput': $htmlfile=$o[1]; break; case '--dumpafter': $dumpafter=1; break; case '--image-uri': // $map->imageuri=$o[1]; $options_output['imageuri'] = $o[1]; break; case '--dumpconfig': //$map->dumpconfig=$o[1]; // $options_output['dumpconfig'] = $o[1]; $dumpconfig=$o[1]; break; case '--randomdata': $randomdata=1; break; case '--stats': $dumpstats=1; break; case '--uberdebug': // allow ALL trace messages (normally we block some of the chatty ones) $weathermap_debug_suppress=array(); // FALL THROUGH case '--debug': $options_output['debugging'] = TRUE; $weathermap_debugging=TRUE; // enable assertion handling assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_WARNING, 0); assert_options(ASSERT_QUIET_EVAL, 1); // Set up the callback assert_options(ASSERT_CALLBACK, 'my_assert_handler'); break; case '--sizedebug': case '--no-data': //$map->sizedebug=TRUE; $options_output['sizedebug'] = TRUE; break; case '--bulge': //$map->widthmod=TRUE; $options_output['widthmod'] = TRUE; break; case '--output': $imagefile=$o[1]; break; case '--define': preg_match("/^([^=]+)=(.*)\s*$/",$o[1],$matches); if(isset($matches[2])) { $varname = $matches[1]; $value = $matches[2]; debug(">> $varname = '$value'\n"); // save this for later, so that when the map object exists, it can be defined $defines[$varname]=$value; } else { print "WARNING: --define format is: --define name=value\n"; } break; case '--version': print 'PHP Network Weathermap v' . $WEATHERMAP_VERSION."\n"; exit(); break; case '--help': print 'PHP Network Weathermap v' . $WEATHERMAP_VERSION."\n"; print "Copyright Howard Jones, 2005-2007 howie@thingy.com\nReleased under the GNU Public License\nhttp://www.network-weathermap.com/\n\n"; print "Usage: php weathermap [options]\n\n"; print " --config {filename} - filename to read from. Default weathermap.conf\n"; print " --output {filename} - filename to write image. Default weathermap.png\n"; print " --htmloutput {filename} - filename to write HTML. Default weathermap.html\n\n"; print " --image-uri {uri} - URI to prefix tags in HTML.\n"; print " --bulge - Enable link-bulging mode. See manual.\n\n"; print " --define name=value - Define internal variables\n"; print " (equivalent to global SET in config file)\n\n"; print " --no-data - skip the data-reading process (just a 'grey' map)\n"; print " --randomdata - as above, but use random data\n"; print " --debug - produce (LOTS) of debugging information during run\n"; print " --dump-after - dump all internal PHP structures (HUGE)\n"; print " --dumpconfig {filename} - filename to write a new config to (for testing)\n\n"; print " --help - show this help\n"; print " --version - show version number\n\n"; print "More info at http://www.network-weathermap.com/\n"; exit(); break; } } } // set this BEFORE we create the map object, so we get the debug output from Reset(), as well if(isset($options_output['debugging']) && $options_output['debugging']) { $weathermap_debugging=TRUE; debug("------------------------------------\n"); debug("Starting PHP-Weathermap run, with config: $configfile\n"); debug("------------------------------------\n"); } $map=new Weathermap; $map->rrdtool = $rrdtool; $map->context="cli"; // now stuff in all the others, that we got from getopts foreach ($options_output as $key=>$value) { $map->$key = $value; // $map->add_hint($key,$value); } $weathermap_map = $configfile; if ($map->ReadConfig($configfile)) { // allow command-lines to override the config file, but provide a default if neither are present if ($imagefile == '') { if ($map->imageoutputfile == '') { $imagefile="weathermap.png"; } else { $imagefile=$map->imageoutputfile; } } if ($htmlfile == '') { if ($map->htmloutputfile != '') { $htmlfile = $map->htmloutputfile; } } // feed in any command-line defaults, so that they appear as if SET lines in the config // XXX FIXME foreach ($defines as $hintname=>$hint) { $map->add_hint($hintname,$hint); } // now stuff in all the others, that we got from getopts foreach ($options_output as $key=>$value) { // $map->$key = $value; $map->add_hint($key,$value); } if ( (isset($options_output['sizedebug']) && ! $options_output['sizedebug']) || (!isset($options_output['sizedebug'])) ) { if ($randomdata == 1) { $map->RandomData(); } else { $map->ReadData(); } } # exit(); if ($imagefile != '') { $map->DrawMap($imagefile); $map->imagefile=$imagefile; } if ($htmlfile != '') { debug("Writing HTML to $htmlfile\n"); $fd=fopen($htmlfile, 'w'); fwrite($fd, ''); if($map->htmlstylesheet != '') fwrite($fd,''); fwrite($fd,'' . $map->ProcessString($map->title, $map) . ''); if ($map->htmlstyle == "overlib") { fwrite($fd, "
\n"); fwrite($fd, " \n"); } fwrite($fd, $map->MakeHTML()); fwrite($fd, '
Network Map created with PHP Network Weathermap v' . $WEATHERMAP_VERSION . ''); fclose ($fd); } if ($dumpconfig != '') $map->WriteConfig($dumpconfig); if ($dumpstats != '') $map->DumpStats(); if ($dumpafter == 1) print_r ($map); # print_r ($map->node_template_tree); # print_r ($map->link_template_tree); # $map->cachefolder="editcache"; # $map->CacheUpdate(1); } else { die ("\n\nCould not read Weathermap config file. No output produced. Maybe try --help?\n"); } function my_assert_handler($file, $line, $code) { echo "Assertion Failed: File $file Line $line Code $code"; debug_print_backtrace(); exit(); } // vim:ts=4:sw=4: ?> #!/usr/bin/php readPHPArgv(); $ret=$cg->getopt($args, $short_opts, $long_opts); if (PEAR::isError($ret)) { die ("Error in command line: " . $ret->getMessage() . "\n (try --help)\n"); } $gopts=$ret[0]; $options_output = array(); if (sizeof($gopts) > 0) { foreach ($gopts as $o) { switch ($o[0]) { case '--config': $configfile=$o[1]; break; case '--htmloutput': $htmlfile=$o[1]; break; case '--dumpafter': $dumpafter=1; break; case '--image-uri': // $map->imageuri=$o[1]; $options_output['imageuri'] = $o[1]; break; case '--dumpconfig': //$map->dumpconfig=$o[1]; // $options_output['dumpconfig'] = $o[1]; $dumpconfig=$o[1]; break; case '--randomdata': $randomdata=1; break; case '--stats': $dumpstats=1; break; case '--uberdebug': // allow ALL trace messages (normally we block some of the chatty ones) $weathermap_debug_suppress=array(); // FALL THROUGH case '--debug': $options_output['debugging'] = TRUE; $weathermap_debugging=TRUE; // enable assertion handling assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_WARNING, 0); assert_options(ASSERT_QUIET_EVAL, 1); // Set up the callback assert_options(ASSERT_CALLBACK, 'my_assert_handler'); break; case '--sizedebug': case '--no-data': //$map->sizedebug=TRUE; $options_output['sizedebug'] = TRUE; break; case '--bulge': //$map->widthmod=TRUE; $options_output['widthmod'] = TRUE; break; case '--output': $imagefile=$o[1]; break; case '--define': preg_match("/^([^=]+)=(.*)\s*$/",$o[1],$matches); if(isset($matches[2])) { $varname = $matches[1]; $value = $matches[2]; debug(">> $varname = '$value'\n"); // save this for later, so that when the map object exists, it can be defined $defines[$varname]=$value; } else { print "WARNING: --define format is: --define name=value\n"; } break; case '--version': print 'PHP Network Weathermap v' . $WEATHERMAP_VERSION."\n"; exit(); break; case '--help': print 'PHP Network Weathermap v' . $WEATHERMAP_VERSION."\n"; print "Copyright Howard Jones, 2005-2007 howie@thingy.com\nReleased under the GNU Public License\nhttp://www.network-weathermap.com/\n\n"; print "Usage: php weathermap [options]\n\n"; print " --config {filename} - filename to read from. Default weathermap.conf\n"; print " --output {filename} - filename to write image. Default weathermap.png\n"; print " --htmloutput {filename} - filename to write HTML. Default weathermap.html\n\n"; print " --image-uri {uri} - URI to prefix tags in HTML.\n"; print " --bulge - Enable link-bulging mode. See manual.\n\n"; print " --define name=value - Define internal variables\n"; print " (equivalent to global SET in config file)\n\n"; print " --no-data - skip the data-reading process (just a 'grey' map)\n"; print " --randomdata - as above, but use random data\n"; print " --debug - produce (LOTS) of debugging information during run\n"; print " --dump-after - dump all internal PHP structures (HUGE)\n"; print " --dumpconfig {filename} - filename to write a new config to (for testing)\n\n"; print " --help - show this help\n"; print " --version - show version number\n\n"; print "More info at http://www.network-weathermap.com/\n"; exit(); break; } } } // set this BEFORE we create the map object, so we get the debug output from Reset(), as well if(isset($options_output['debugging']) && $options_output['debugging']) { $weathermap_debugging=TRUE; debug("------------------------------------\n"); debug("Starting PHP-Weathermap run, with config: $configfile\n"); debug("------------------------------------\n"); } $map=new Weathermap; $map->rrdtool = $rrdtool; $map->context="cli"; // now stuff in all the others, that we got from getopts foreach ($options_output as $key=>$value) { $map->$key = $value; // $map->add_hint($key,$value); } $weathermap_map = $configfile; if ($map->ReadConfig($configfile)) { // allow command-lines to override the config file, but provide a default if neither are present if ($imagefile == '') { if ($map->imageoutputfile == '') { $imagefile="weathermap.png"; } else { $imagefile=$map->imageoutputfile; } } if ($htmlfile == '') { if ($map->htmloutputfile != '') { $htmlfile = $map->htmloutputfile; } } // feed in any command-line defaults, so that they appear as if SET lines in the config // XXX FIXME foreach ($defines as $hintname=>$hint) { $map->add_hint($hintname,$hint); } // now stuff in all the others, that we got from getopts foreach ($options_output as $key=>$value) { // $map->$key = $value; $map->add_hint($key,$value); } if ( (isset($options_output['sizedebug']) && ! $options_output['sizedebug']) || (!isset($options_output['sizedebug'])) ) { if ($randomdata == 1) { $map->RandomData(); } else { $map->ReadData(); } } # exit(); if ($imagefile != '') { $map->DrawMap($imagefile); $map->imagefile=$imagefile; } if ($htmlfile != '') { debug("Writing HTML to $htmlfile\n"); $fd=fopen($htmlfile, 'w'); fwrite($fd, ''); if($map->htmlstylesheet != '') fwrite($fd,''); fwrite($fd,'' . $map->ProcessString($map->title, $map) . ''); if ($map->htmlstyle == "overlib") { fwrite($fd, "
\n"); fwrite($fd, " \n"); } fwrite($fd, $map->MakeHTML()); fwrite($fd, '
Network Map created with PHP Network Weathermap v' . $WEATHERMAP_VERSION . ''); fclose ($fd); } if ($dumpconfig != '') $map->WriteConfig($dumpconfig); if ($dumpstats != '') $map->DumpStats(); if ($dumpafter == 1) print_r ($map); # print_r ($map->node_template_tree); # print_r ($map->link_template_tree); # $map->cachefolder="editcache"; # $map->CacheUpdate(1); } else { die ("\n\nCould not read Weathermap config file. No output produced. Maybe try --help?\n"); } function my_assert_handler($file, $line, $code) { echo "Assertion Failed: File $file Line $line Code $code"; debug_print_backtrace(); exit(); } // vim:ts=4:sw=4: ?> WebSVN - weathermap - Diff - Rev 137 and 85 - /weathermap
  jablonka.czprosek.czf

weathermap

Subversion Repositories:
[/] [weathermap] - Diff between revs 85 and 137

Show entire file Ignore whitespace

Rev 85 Rev 137

Powered by WebSVN 2.2.1