refactor: use Composer to manage php dependencies (#5216)

This commit is contained in:
Tony Murray 2017-01-01 03:37:15 -06:00 committed by Neil Lathwood
parent 74a4371fb4
commit e20a242785
2476 changed files with 332194 additions and 100577 deletions

View File

@ -5,4 +5,4 @@ imports:
# FIXME: find a way to keep excluded_paths list sorted # FIXME: find a way to keep excluded_paths list sorted
filter: filter:
excluded_paths: [ html/js/*, includes/phpmailer/*, html/css/*, includes/console_colour.php, includes/console_table.php, html/lib/*, lib/* ] excluded_paths: [ html/js/*, html/css/*, lib/*, vendor/* ]

View File

@ -1,188 +0,0 @@
<?php
/**
* ClassLoader.php
*
* PSR-0 and custom class loader for LibreNMS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS;
/**
* Class ClassLoader
* @package LibreNMS
*/
class ClassLoader
{
/**
* @var array stores dynamically added class > file mappings ($classMap[fullclass] = $file)
*/
private $classMap;
/**
* @var array stores dynamically added namespace > directory mappings ($dirMap[namespace][$dir] =1)
*/
private $dirMap;
/**
* ClassLoader constructor.
*/
public function __construct()
{
$this->classMap = array();
$this->dirMap = array();
}
/**
* Loads classes conforming to the PSR-0 specificaton
*
* @param string $name Class name to load
*/
public static function psrLoad($name)
{
global $vdebug;
$file = str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $name) . '.php';
$fullFile = realpath(__DIR__ . '/..') . DIRECTORY_SEPARATOR . $file;
if ($vdebug) {
echo __CLASS__ . " [[ $name > $fullFile ]]\n";
}
if (is_readable($fullFile)) {
include $fullFile;
}
}
/**
* Loads classes defined by mapClass()
*
* @param string $name Class name to load
*/
public function customLoad($name)
{
global $vdebug;
if (isset($this->classMap[$name])) {
$file = $this->classMap[$name];
if ($vdebug) {
echo __CLASS__ . " (( $name > $file ))\n";
}
if (is_readable($file)) {
include $file;
return;
}
}
list($namespace, $class) = $this->splitNamespace($name);
if (isset($this->dirMap[$namespace])) {
foreach (array_keys($this->dirMap[$namespace]) as $dir) {
$file = $dir . DIRECTORY_SEPARATOR . $class . '.php';
if ($vdebug) {
echo __CLASS__ . " (( $name > $file ))\n";
}
if (is_readable($file)) {
include $file;
return;
}
}
}
}
/**
* Register a custom class > file mapping
*
* @param string $class The full class name
* @param string $file The path to the file containing the class, full path is preferred
*/
public function registerClass($class, $file)
{
$this->classMap[$class] = $file;
}
/**
* Unregister a class from the list of class > file mappings
*
* @param string $class The full class name
*/
public function unregisterClass($class)
{
unset($this->classMap[$class]);
}
/**
* Register a directory to search for classes in.
* If a namespace is specified, it will search for
* classes with that exact namespace in those directories.
*
* @param string $dir directory containing classes with filename = class.php
* @param string $namespace the namespace of the classes
*/
public function registerDir($dir, $namespace = '')
{
$this->dirMap[$namespace][$dir] = 1;
}
/**
* Unregister a directory
*
* @param string $dir the directory to remove
* @param string $namespace the namespace of the classes
*/
public function unregisterDir($dir, $namespace = '')
{
unset($this->dirMap[$namespace][$dir]);
}
/**
* Register this autoloader
* Custom mappings will take precedence over PSR-0
*/
public function register()
{
spl_autoload_register(array($this, 'customLoad'));
spl_autoload_register(__NAMESPACE__.'\ClassLoader::psrLoad');
}
/**
* Unregister this autoloader
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'customLoad'));
spl_autoload_unregister(__NAMESPACE__.'\ClassLoader::psrLoad');
}
/**
* Split a class into namspace/classname
* @param string $class the full class name to split
* @return array of the split class [namespace, classname]
*/
private function splitNamespace($class)
{
$parts = explode('\\', $class);
$last = array_pop($parts);
return array(implode('\\', $parts), $last);
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* ComposerHelper.php
*
* Helper functions for composer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS;
use Composer\Script\Event;
use Composer\Installer\PackageEvent;
class ComposerHelper
{
public static function preUpdate(Event $event)
{
if (!$event->isDevMode()) {
$vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
$cmds = array(
"git checkout $vendor_dir",
"git clean -x -d -f $vendor_dir"
);
self::exec($cmds);
}
}
public static function postAutoloadDump(Event $event)
{
$vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
$no = $event->isDevMode() ? '' : 'no-';
$cmd = "git ls-files -z $vendor_dir | xargs -0 git update-index --{$no}assume-unchanged";
self::exec($cmd);
}
public static function commit(Event $event)
{
$vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
$composer_json_path = $event->getComposer()->getConfig()->getConfigSource()->getName();
$cmds = array(
"git add -f $vendor_dir $composer_json_path",
"git commit"
);
self::exec($cmds);
}
/**
* Run a command or array of commands and echo the command and output
*
* @param string|array $cmds
*/
private static function exec($cmds)
{
$cmd = "set -v\n" . implode(PHP_EOL, (array)$cmds);
passthru($cmd);
}
}

View File

@ -1,9 +1,51 @@
{ {
"name": "librenms/librenms",
"description": "A fully featured network monitoring system that provides a wealth of features and device support.",
"type": "project",
"keywords": ["network", "monitoring", "snmp", "laravel"],
"homepage": "http://www.librenms.org/",
"license": "GPL-3.0",
"support": {
"source": "https://github.com/librenms/librenms/",
"docs": "http://docs.librenms.org/",
"forum": "https://community.librenms.org/",
"issues": "https://github.com/librenms/librenms/issues/",
"irc": "irc://irc.freenode.org/#librenms"
},
"config": {
"platform": {"php": "5.3.9"}
},
"require": {
"php": ">=5.3.9",
"ezyang/htmlpurifier": "^4.8",
"phpmailer/phpmailer": "^5.2.21",
"slim/slim": "^2.6",
"easybook/geshi": "^1.0.8",
"amenadiel/jpgraph": "^3.6",
"tecnickcom/tcpdf": "~6.2.0",
"xjtuwangke/passwordhash": "dev-master",
"pear/console_color2": "^0.1",
"pear/console_table": "^1.3",
"dapphp/radius": "^2.0",
"php-amqplib/php-amqplib": "^2.0",
"symfony/yaml": "^2.8"
},
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "2.6.*", "squizlabs/php_codesniffer": "2.6.*",
"phpunit/phpunit": "4.*", "phpunit/phpunit": "4.*",
"jakub-onderka/php-parallel-lint": "*", "jakub-onderka/php-parallel-lint": "*",
"jakub-onderka/php-console-highlighter": "*", "jakub-onderka/php-console-highlighter": "*",
"fojuth/readmegen": "1.*" "fojuth/readmegen": "1.*"
},
"autoload": {
"psr-4": {
"LibreNMS\\": "LibreNMS",
"LibreNMS\\Tests\\": "tests"
}
},
"scripts": {
"pre-update-cmd": "LibreNMS\\ComposerHelper::preUpdate",
"post-autoload-dump": "LibreNMS\\ComposerHelper::postAutoloadDump",
"commit": "LibreNMS\\ComposerHelper::commit"
} }
} }

View File

@ -119,10 +119,18 @@ be sure to note this as a comment in the code (preferably) or the commit
message. Accurate attribution is crucial to our success as a Free Software message. Accurate attribution is crucial to our success as a Free Software
project. project.
- To incorporate larger blocks of code from third parties (e.g. JavaScript - For any dependency
libraries): - Include its name, source URL, copyright notice, and license in doc/General/Credits.md
- Include its name, source URL, copyright notice, and license in
doc/General/Credits.md - To add a php dependency, please use composer
- Add the dependency `composer require --update-no-dev -o slim/slim`
- Add the files and commit `composer commit` or `git add -f vendor/ composer.json; git commit`
- Updating php dependencies
- Update dependencies `composer update --no-dev -o`
- Add the files and commit `composer commit` or `git add -f vendor/; git commit`
- To add a javascript or other dependency
- Where possible please include libraries in the lib/ folder. - Where possible please include libraries in the lib/ folder.
- Add it in a separate commit into its own directory, using - Add it in a separate commit into its own directory, using
git subtree if it is available via git: git subtree if it is available via git:
@ -131,9 +139,7 @@ project.
```ssh ```ssh
git subtree add --squash --prefix=lib/jquery-bootgrid https://github.com/rstaib/jquery-bootgrid.git master git subtree add --squash --prefix=lib/jquery-bootgrid https://github.com/rstaib/jquery-bootgrid.git master
``` ```
- Add the code to integrate it in a separate commit. Include: - Add the code to integrate it in a separate commit.
- code to update it in Makefile
- Scrutinizer exclusions to .scrutinizer.yml (not needed if added to lib/ folder).
- symlinks where necessary to maintain sensible paths - symlinks where necessary to maintain sensible paths
- Don't submit code whose license conflicts with the GPLv3. If you're not - Don't submit code whose license conflicts with the GPLv3. If you're not
@ -155,7 +161,7 @@ project.
Please note that the above is necessary even if you don't care about Please note that the above is necessary even if you don't care about
keeping the copyright to your code, because otherwise we could be accused keeping the copyright to your code, because otherwise we could be accused
of misappropriating Obserivum's code. As the code bases develop, we of misappropriating Observium's code. As the code bases develop, we
expect them to diverge, which means this will become less of an issue expect them to diverge, which means this will become less of an issue
anyway. anyway.

View File

@ -15,8 +15,6 @@
$init_modules = array('web', 'alerts'); $init_modules = array('web', 'alerts');
require realpath(__DIR__ . '/..') . '/includes/init.php'; require realpath(__DIR__ . '/..') . '/includes/init.php';
require $config['install_dir'] . '/html/lib/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim(); $app = new \Slim\Slim();
require $config['install_dir'] . '/html/includes/api_functions.inc.php'; require $config['install_dir'] . '/html/includes/api_functions.inc.php';
$app->setName('api'); $app->setName('api');

View File

@ -1,5 +1,4 @@
<?php <?php
/** /**
* LibreNMS * LibreNMS
* *
@ -10,6 +9,11 @@
* @copyright (C) 2006 - 2012 Adam Armstrong * @copyright (C) 2006 - 2012 Adam Armstrong
*/ */
use Amenadiel\JpGraph\Graph\Graph;
use Amenadiel\JpGraph\Plot\BarPlot;
use Amenadiel\JpGraph\Plot\GroupBarPlot;
use Amenadiel\JpGraph\Plot\LinePlot;
ini_set('allow_url_fopen', 0); ini_set('allow_url_fopen', 0);
ini_set('display_errors', 0); ini_set('display_errors', 0);
@ -37,12 +41,6 @@ if (get_client_ip() != $_SERVER['SERVER_ADDR']) {
} }
} }
require_once $config['install_dir'] . '/html/lib/jpgraph/jpgraph.php';
require_once $config['install_dir'] . '/html/lib/jpgraph/jpgraph_line.php';
require_once $config['install_dir'] . '/html/lib/jpgraph/jpgraph_bar.php';
require_once $config['install_dir'] . '/html/lib/jpgraph/jpgraph_utils.inc.php';
require_once $config['install_dir'] . '/html/lib/jpgraph/jpgraph_date.php';
if (is_numeric($_GET['bill_id'])) { if (is_numeric($_GET['bill_id'])) {
if (get_client_ip() != $_SERVER['SERVER_ADDR']) { if (get_client_ip() != $_SERVER['SERVER_ADDR']) {
if (bill_permitted($_GET['bill_id'])) { if (bill_permitted($_GET['bill_id'])) {
@ -59,7 +57,7 @@ if (is_numeric($_GET['bill_id'])) {
exit; exit;
} }
if (is_numeric($_GET['bill_id']) && is_numeric($_GET[bill_hist_id])) { if (is_numeric($_GET['bill_id']) && is_numeric($_GET['bill_hist_id'])) {
$histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to` FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', array($_GET['bill_id'], $_GET['bill_hist_id'])); $histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to` FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', array($_GET['bill_id'], $_GET['bill_hist_id']));
if (is_null($histrow)) { if (is_null($histrow)) {
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
@ -68,8 +66,8 @@ if (is_numeric($_GET['bill_id']) && is_numeric($_GET[bill_hist_id])) {
$start = $histrow['from']; $start = $histrow['from'];
$end = $histrow['to']; $end = $histrow['to'];
} else { } else {
$start = $_GET[from]; $start = $_GET['from'];
$end = $_GET[to]; $end = $_GET['to'];
} }
$xsize = (is_numeric($_GET['x']) ? $_GET['x'] : '800' ); $xsize = (is_numeric($_GET['x']) ? $_GET['x'] : '800' );

View File

@ -1,5 +1,4 @@
<?php <?php
/* /*
* LibreNMS * LibreNMS
* *
@ -10,8 +9,10 @@
* @copyright (C) 2006 - 2012 Adam Armstrong * @copyright (C) 2006 - 2012 Adam Armstrong
*/ */
use Amenadiel\JpGraph\Graph\Graph;
use Amenadiel\JpGraph\Plot\LinePlot;
ini_set('allow_url_fopen', 0); ini_set('allow_url_fopen', 0);
ini_set('display_errors', 0);
if (strpos($_SERVER['REQUEST_URI'], 'debug')) { if (strpos($_SERVER['REQUEST_URI'], 'debug')) {
$debug = '1'; $debug = '1';
@ -37,11 +38,6 @@ if (get_client_ip() != $_SERVER['SERVER_ADDR']) {
} }
} }
require $config['install_dir'] . '/html/lib/jpgraph/jpgraph.php';
require $config['install_dir'] . '/html/lib/jpgraph/jpgraph_line.php';
require $config['install_dir'] . '/html/lib/jpgraph/jpgraph_utils.inc.php';
require $config['install_dir'] . '/html/lib/jpgraph/jpgraph_date.php';
if (is_numeric($_GET['bill_id'])) { if (is_numeric($_GET['bill_id'])) {
if (get_client_ip() != $_SERVER['SERVER_ADDR']) { if (get_client_ip() != $_SERVER['SERVER_ADDR']) {
if (bill_permitted($_GET['bill_id'])) { if (bill_permitted($_GET['bill_id'])) {
@ -61,7 +57,7 @@ if (is_numeric($_GET['bill_id'])) {
$rate_data = dbFetchRow('SELECT * from `bills` WHERE `bill_id`= ? LIMIT 1', array($bill_id)); $rate_data = dbFetchRow('SELECT * from `bills` WHERE `bill_id`= ? LIMIT 1', array($bill_id));
$bill_name = $rate_data['bill_name']; $bill_name = $rate_data['bill_name'];
if (is_numeric($_GET['bill_id']) && is_numeric($_GET[bill_hist_id])) { if (is_numeric($_GET['bill_id']) && is_numeric($_GET['bill_hist_id'])) {
$histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`, rate_95th, rate_average FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', array($_GET['bill_id'], $_GET['bill_hist_id'])); $histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`, rate_95th, rate_average FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', array($_GET['bill_id'], $_GET['bill_hist_id']));
if (is_null($histrow)) { if (is_null($histrow)) {
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
@ -72,20 +68,20 @@ if (is_numeric($_GET['bill_id']) && is_numeric($_GET[bill_hist_id])) {
$rate_95th = $histrow['rate_95th']; $rate_95th = $histrow['rate_95th'];
$rate_average = $histrow['rate_average']; $rate_average = $histrow['rate_average'];
} else { } else {
$start = $_GET[from]; $start = $_GET['from'];
$end = $_GET[to]; $end = $_GET['to'];
$rate_95th = $rate_data['rate_95th']; $rate_95th = $rate_data['rate_95th'];
$rate_average = $rate_data['rate_average']; $rate_average = $rate_data['rate_average'];
} }
$xsize = $_GET[x]; $xsize = $_GET['x'];
$ysize = $_GET[y]; $ysize = $_GET['y'];
$count = $_GET[count]; $count = $_GET['count'];
$count = ($count + 0); $count = ($count + 0);
$iter = 1; $iter = 1;
if ($_GET[type]) { if ($_GET['type']) {
$type = $_GET[type]; $type = $_GET['type'];
} else { } else {
$type = 'date'; $type = 'date';
} }
@ -232,12 +228,12 @@ $lineplot_out->SetColor('darkblue');
$lineplot_out->SetFillColor('lightblue@0.4'); $lineplot_out->SetFillColor('lightblue@0.4');
$lineplot_out->SetWeight(1); $lineplot_out->SetWeight(1);
if ($_GET['95th']) { if (isset($_GET['95th'])) {
$lineplot_95th = new LinePlot($per_data, $ticks); $lineplot_95th = new LinePlot($per_data, $ticks);
$lineplot_95th->SetColor('red'); $lineplot_95th->SetColor('red');
} }
if ($_GET['ave']) { if (isset($_GET['ave'])) {
$lineplot_ave = new LinePlot($ave_data, $ticks); $lineplot_ave = new LinePlot($ave_data, $ticks);
$lineplot_ave->SetColor('red'); $lineplot_ave->SetColor('red');
} }
@ -250,11 +246,11 @@ $graph->Add($lineplot);
$graph->Add($lineplot_in); $graph->Add($lineplot_in);
$graph->Add($lineplot_out); $graph->Add($lineplot_out);
if ($_GET['95th']) { if (isset($_GET['95th'])) {
$graph->Add($lineplot_95th); $graph->Add($lineplot_95th);
} }
if ($_GET['ave']) { if (isset($_GET['ave'])) {
$graph->Add($lineplot_ave); $graph->Add($lineplot_ave);
} }

View File

@ -1,5 +1,7 @@
<?php <?php
use Phpass\PasswordHash;
@ini_set('session.use_only_cookies', 1); @ini_set('session.use_only_cookies', 1);
@ini_set('session.cookie_httponly', 1); @ini_set('session.cookie_httponly', 1);

View File

@ -1,5 +1,7 @@
<?php <?php
use Phpass\PasswordHash;
if (!isset($_SESSION['username'])) { if (!isset($_SESSION['username'])) {
$_SESSION['username'] = ''; $_SESSION['username'] = '';
} }

View File

@ -1,5 +1,6 @@
<?php <?php
use Phpass\PasswordHash;
function authenticate($username, $password) function authenticate($username, $password)
{ {

View File

@ -1,6 +1,7 @@
<?php <?php
require_once $config['install_dir'].'/lib/pure_php_radius/radius.class.php'; use Dapphp\Radius\Radius;
use Phpass\PasswordHash;
$radius = new Radius($config['radius']['hostname'], $config['radius']['secret'], $config['radius']['suffix'], $config['radius']['timeout'], $config['radius']['port']); $radius = new Radius($config['radius']['hostname'], $config['radius']['secret'], $config['radius']['suffix'], $config['radius']['timeout'], $config['radius']['port']);

View File

@ -1,258 +0,0 @@
<?php
#
# Portable PHP password hashing framework.
#
# Version 0.3 / genuine.
#
# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
# the public domain. Revised in subsequent years, still public domain.
#
# There's absolutely no warranty.
#
# The homepage URL for this framework is:
#
# http://www.openwall.com/phpass/
#
# Please be sure to update the Version line if you edit this file in any way.
# It is suggested that you leave the main version number intact, but indicate
# your project name (after the slash) and add your own revision information.
#
# Please do not change the "private" password hashing method implemented in
# here, thereby making your hashes incompatible. However, if you must, please
# change the hash type identifier (the "$P$") to something different.
#
# Obviously, since this code is in the public domain, the above are not
# requirements (there can be none), but merely suggestions.
#
class PasswordHash {
var $itoa64;
var $iteration_count_log2;
var $portable_hashes;
var $random_state;
function __construct($iteration_count_log2, $portable_hashes)
{
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$this->iteration_count_log2 = $iteration_count_log2;
$this->portable_hashes = $portable_hashes;
$this->random_state = microtime();
if (function_exists('getmypid'))
$this->random_state .= getmypid();
}
function get_random_bytes($count)
{
$output = openssl_random_pseudo_bytes($count,$strong);
if(empty($output))
{
if (is_readable('/dev/urandom') &&
($fh = @fopen('/dev/urandom', 'rb')))
{
$output = fread($fh, $count);
fclose($fh);
}
}
if (strlen($output) < $count) {
$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->random_state =
md5(microtime() . $this->random_state);
$output .=
pack('H*', md5($this->random_state));
}
$output = substr($output, 0, $count);
}
return $output;
}
function encode64($input, $count)
{
$output = '';
$i = 0;
do {
$value = ord($input[$i++]);
$output .= $this->itoa64[$value & 0x3f];
if ($i < $count)
$value |= ord($input[$i]) << 8;
$output .= $this->itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
break;
if ($i < $count)
$value |= ord($input[$i]) << 16;
$output .= $this->itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
break;
$output .= $this->itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return $output;
}
function gensalt_private($input)
{
$output = '$P$';
$output .= $this->itoa64[min($this->iteration_count_log2 +
((PHP_VERSION >= '5') ? 5 : 3), 30)];
$output .= $this->encode64($input, 6);
return $output;
}
function crypt_private($password, $setting)
{
$output = '*0';
if (substr($setting, 0, 2) == $output)
$output = '*1';
$id = substr($setting, 0, 3);
# We use "$P$", phpBB3 uses "$H$" for the same thing
if ($id != '$P$' && $id != '$H$')
return $output;
$count_log2 = strpos($this->itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
return $output;
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
return $output;
# We're kind of forced to use MD5 here since it's the only
# cryptographic primitive available in all versions of PHP
# currently in use. To implement our own low-level crypto
# in PHP would result in much worse performance and
# consequently in lower iteration counts and hashes that are
# quicker to crack (by non-PHP code).
if (PHP_VERSION >= '5') {
$hash = md5($salt . $password, TRUE);
do {
$hash = md5($hash . $password, TRUE);
} while (--$count);
} else {
$hash = pack('H*', md5($salt . $password));
do {
$hash = pack('H*', md5($hash . $password));
} while (--$count);
}
$output = substr($setting, 0, 12);
$output .= $this->encode64($hash, 16);
return $output;
}
function gensalt_extended($input)
{
$count_log2 = min($this->iteration_count_log2 + 8, 24);
# This should be odd to not reveal weak DES keys, and the
# maximum valid value is (2**24 - 1) which is odd anyway.
$count = (1 << $count_log2) - 1;
$output = '_';
$output .= $this->itoa64[$count & 0x3f];
$output .= $this->itoa64[($count >> 6) & 0x3f];
$output .= $this->itoa64[($count >> 12) & 0x3f];
$output .= $this->itoa64[($count >> 18) & 0x3f];
$output .= $this->encode64($input, 3);
return $output;
}
function gensalt_blowfish($input)
{
# This one needs to use a different order of characters and a
# different encoding scheme from the one in encode64() above.
# We care because the last character in our encoded string will
# only represent 2 bits. While two known implementations of
# bcrypt will happily accept and correct a salt string which
# has the 4 unused bits set to non-zero, we do not want to take
# chances and we also do not want to waste an additional byte
# of entropy.
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$output = '$2a$';
$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
$output .= '$';
$i = 0;
do {
$c1 = ord($input[$i++]);
$output .= $itoa64[$c1 >> 2];
$c1 = ($c1 & 0x03) << 4;
if ($i >= 16) {
$output .= $itoa64[$c1];
break;
}
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 4;
$output .= $itoa64[$c1];
$c1 = ($c2 & 0x0f) << 2;
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 6;
$output .= $itoa64[$c1];
$output .= $itoa64[$c2 & 0x3f];
} while (1);
return $output;
}
function HashPassword($password)
{
$random = '';
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
$random = $this->get_random_bytes(16);
$hash =
crypt($password, $this->gensalt_blowfish($random));
if (strlen($hash) == 60)
return $hash;
}
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
if (strlen($random) < 3)
$random = $this->get_random_bytes(3);
$hash =
crypt($password, $this->gensalt_extended($random));
if (strlen($hash) == 20)
return $hash;
}
if (strlen($random) < 6)
$random = $this->get_random_bytes(6);
$hash =
$this->crypt_private($password,
$this->gensalt_private($random));
if (strlen($hash) == 34)
return $hash;
# Returning '*' on error is safe here, but would _not_ be safe
# in a crypt(3)-like function used _both_ for generating new
# hashes and for validating passwords against existing hashes.
return '*';
}
function CheckPassword($password, $stored_hash)
{
$hash = $this->crypt_private($password, $stored_hash);
if ($hash[0] == '*')
$hash = crypt($password, $stored_hash);
return $hash == $stored_hash;
}
}
?>

View File

@ -1,224 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim;
/**
* Environment
*
* This class creates and returns a key/value array of common
* environment variables for the current HTTP request.
*
* This is a singleton class; derived environment variables will
* be common across multiple Slim applications.
*
* This class matches the Rack (Ruby) specification as closely
* as possible. More information available below.
*
* @package Slim
* @author Josh Lockhart
* @since 1.6.0
*/
class Environment implements \ArrayAccess, \IteratorAggregate
{
/**
* @var array
*/
protected $properties;
/**
* @var \Slim\Environment
*/
protected static $environment;
/**
* Get environment instance (singleton)
*
* This creates and/or returns an environment instance (singleton)
* derived from $_SERVER variables. You may override the global server
* variables by using `\Slim\Environment::mock()` instead.
*
* @param bool $refresh Refresh properties using global server variables?
* @return \Slim\Environment
*/
public static function getInstance($refresh = false)
{
if (is_null(self::$environment) || $refresh) {
self::$environment = new self();
}
return self::$environment;
}
/**
* Get mock environment instance
*
* @param array $userSettings
* @return \Slim\Environment
*/
public static function mock($userSettings = array())
{
$defaults = array(
'REQUEST_METHOD' => 'GET',
'SCRIPT_NAME' => '',
'PATH_INFO' => '',
'QUERY_STRING' => '',
'SERVER_NAME' => 'localhost',
'SERVER_PORT' => 80,
'ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
'ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'USER_AGENT' => 'Slim Framework',
'REMOTE_ADDR' => '127.0.0.1',
'slim.url_scheme' => 'http',
'slim.input' => '',
'slim.errors' => @fopen('php://stderr', 'w')
);
self::$environment = new self(array_merge($defaults, $userSettings));
return self::$environment;
}
/**
* Constructor (private access)
*
* @param array|null $settings If present, these are used instead of global server variables
*/
private function __construct($settings = null)
{
if ($settings) {
$this->properties = $settings;
} else {
$env = array();
//The HTTP request method
$env['REQUEST_METHOD'] = $_SERVER['REQUEST_METHOD'];
//The IP
$env['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
// Server params
$scriptName = $_SERVER['SCRIPT_NAME']; // <-- "/foo/index.php"
$requestUri = $_SERVER['REQUEST_URI']; // <-- "/foo/bar?test=abc" or "/foo/index.php/bar?test=abc"
$queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; // <-- "test=abc" or ""
// Physical path
if (strpos($requestUri, $scriptName) !== false) {
$physicalPath = $scriptName; // <-- Without rewriting
} else {
$physicalPath = str_replace('\\', '', dirname($scriptName)); // <-- With rewriting
}
$env['SCRIPT_NAME'] = rtrim($physicalPath, '/'); // <-- Remove trailing slashes
// Virtual path
$env['PATH_INFO'] = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path
$env['PATH_INFO'] = str_replace('?' . $queryString, '', $env['PATH_INFO']); // <-- Remove query string
$env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/'); // <-- Ensure leading slash
// Query string (without leading "?")
$env['QUERY_STRING'] = $queryString;
//Name of server host that is running the script
$env['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
//Number of server port that is running the script
$env['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
//HTTP request headers (retains HTTP_ prefix to match $_SERVER)
$headers = \Slim\Http\Headers::extract($_SERVER);
foreach ($headers as $key => $value) {
$env[$key] = $value;
}
//Is the application running under HTTPS or HTTP protocol?
$env['slim.url_scheme'] = empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off' ? 'http' : 'https';
//Input stream (readable one time only; not available for multipart/form-data requests)
$rawInput = @file_get_contents('php://input');
if (!$rawInput) {
$rawInput = '';
}
$env['slim.input'] = $rawInput;
//Error stream
$env['slim.errors'] = @fopen('php://stderr', 'w');
$this->properties = $env;
}
}
/**
* Array Access: Offset Exists
*/
public function offsetExists($offset)
{
return isset($this->properties[$offset]);
}
/**
* Array Access: Offset Get
*/
public function offsetGet($offset)
{
if (isset($this->properties[$offset])) {
return $this->properties[$offset];
} else {
return null;
}
}
/**
* Array Access: Offset Set
*/
public function offsetSet($offset, $value)
{
$this->properties[$offset] = $value;
}
/**
* Array Access: Offset Unset
*/
public function offsetUnset($offset)
{
unset($this->properties[$offset]);
}
/**
* IteratorAggregate
*
* @return \ArrayIterator
*/
public function getIterator()
{
return new \ArrayIterator($this->properties);
}
}

View File

@ -1,49 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Exception;
/**
* Pass Exception
*
* This Exception will cause the Router::dispatch method
* to skip the current matching route and continue to the next
* matching route. If no subsequent routes are found, a
* HTTP 404 Not Found response will be sent to the client.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class Pass extends \Exception
{
}

View File

@ -1,47 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Exception;
/**
* Stop Exception
*
* This Exception is thrown when the Slim application needs to abort
* processing and return control flow to the outer PHP script.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class Stop extends \Exception
{
}

View File

@ -1,246 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Helper;
class Set implements \ArrayAccess, \Countable, \IteratorAggregate
{
/**
* Key-value array of arbitrary data
* @var array
*/
protected $data = array();
/**
* Constructor
* @param array $items Pre-populate set with this key-value array
*/
public function __construct($items = array())
{
$this->replace($items);
}
/**
* Normalize data key
*
* Used to transform data key into the necessary
* key format for this set. Used in subclasses
* like \Slim\Http\Headers.
*
* @param string $key The data key
* @return mixed The transformed/normalized data key
*/
protected function normalizeKey($key)
{
return $key;
}
/**
* Set data key to value
* @param string $key The data key
* @param mixed $value The data value
*/
public function set($key, $value)
{
$this->data[$this->normalizeKey($key)] = $value;
}
/**
* Get data value with key
* @param string $key The data key
* @param mixed $default The value to return if data key does not exist
* @return mixed The data value, or the default value
*/
public function get($key, $default = null)
{
if ($this->has($key)) {
$isInvokable = is_object($this->data[$this->normalizeKey($key)]) && method_exists($this->data[$this->normalizeKey($key)], '__invoke');
return $isInvokable ? $this->data[$this->normalizeKey($key)]($this) : $this->data[$this->normalizeKey($key)];
}
return $default;
}
/**
* Add data to set
* @param array $items Key-value array of data to append to this set
*/
public function replace($items)
{
foreach ($items as $key => $value) {
$this->set($key, $value); // Ensure keys are normalized
}
}
/**
* Fetch set data
* @return array This set's key-value data array
*/
public function all()
{
return $this->data;
}
/**
* Fetch set data keys
* @return array This set's key-value data array keys
*/
public function keys()
{
return array_keys($this->data);
}
/**
* Does this set contain a key?
* @param string $key The data key
* @return boolean
*/
public function has($key)
{
return array_key_exists($this->normalizeKey($key), $this->data);
}
/**
* Remove value with key from this set
* @param string $key The data key
*/
public function remove($key)
{
unset($this->data[$this->normalizeKey($key)]);
}
/**
* Property Overloading
*/
public function __get($key)
{
return $this->get($key);
}
public function __set($key, $value)
{
$this->set($key, $value);
}
public function __isset($key)
{
return $this->has($key);
}
public function __unset($key)
{
return $this->remove($key);
}
/**
* Clear all values
*/
public function clear()
{
$this->data = array();
}
/**
* Array Access
*/
public function offsetExists($offset)
{
return $this->has($offset);
}
public function offsetGet($offset)
{
return $this->get($offset);
}
public function offsetSet($offset, $value)
{
$this->set($offset, $value);
}
public function offsetUnset($offset)
{
$this->remove($offset);
}
/**
* Countable
*/
public function count()
{
return count($this->data);
}
/**
* IteratorAggregate
*/
public function getIterator()
{
return new \ArrayIterator($this->data);
}
/**
* Ensure a value or object will remain globally unique
* @param string $key The value or object name
* @param Closure The closure that defines the object
* @return mixed
*/
public function singleton($key, $value)
{
$this->set($key, function ($c) use ($value) {
static $object;
if (null === $object) {
$object = $value($c);
}
return $object;
});
}
/**
* Protect closure from being directly invoked
* @param Closure $callable A closure to keep from being invoked and evaluated
* @return Closure
*/
public function protect(\Closure $callable)
{
return function () use ($callable) {
return $callable;
};
}
}

View File

@ -1,91 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Http;
class Cookies extends \Slim\Helper\Set
{
/**
* Default cookie settings
* @var array
*/
protected $defaults = array(
'value' => '',
'domain' => null,
'path' => null,
'expires' => null,
'secure' => false,
'httponly' => false
);
/**
* Set cookie
*
* The second argument may be a single scalar value, in which case
* it will be merged with the default settings and considered the `value`
* of the merged result.
*
* The second argument may also be an array containing any or all of
* the keys shown in the default settings above. This array will be
* merged with the defaults shown above.
*
* @param string $key Cookie name
* @param mixed $value Cookie settings
*/
public function set($key, $value)
{
if (is_array($value)) {
$cookieSettings = array_replace($this->defaults, $value);
} else {
$cookieSettings = array_replace($this->defaults, array('value' => $value));
}
parent::set($key, $cookieSettings);
}
/**
* Remove cookie
*
* Unlike \Slim\Helper\Set, this will actually *set* a cookie with
* an expiration date in the past. This expiration date will force
* the client-side cache to remove its cookie with the given name
* and settings.
*
* @param string $key Cookie name
* @param array $settings Optional cookie settings
*/
public function remove($key, $settings = array())
{
$settings['value'] = '';
$settings['expires'] = time() - 86400;
$this->set($key, array_replace($this->defaults, $settings));
}
}

View File

@ -1,104 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Http;
/**
* HTTP Headers
*
* @package Slim
* @author Josh Lockhart
* @since 1.6.0
*/
class Headers extends \Slim\Helper\Set
{
/********************************************************************************
* Static interface
*******************************************************************************/
/**
* Special-case HTTP headers that are otherwise unidentifiable as HTTP headers.
* Typically, HTTP headers in the $_SERVER array will be prefixed with
* `HTTP_` or `X_`. These are not so we list them here for later reference.
*
* @var array
*/
protected static $special = array(
'CONTENT_TYPE',
'CONTENT_LENGTH',
'PHP_AUTH_USER',
'PHP_AUTH_PW',
'PHP_AUTH_DIGEST',
'AUTH_TYPE'
);
/**
* Extract HTTP headers from an array of data (e.g. $_SERVER)
* @param array $data
* @return array
*/
public static function extract($data)
{
$results = array();
foreach ($data as $key => $value) {
$key = strtoupper($key);
if (strpos($key, 'X_') === 0 || strpos($key, 'HTTP_') === 0 || in_array($key, static::$special)) {
if ($key === 'HTTP_CONTENT_LENGTH') {
continue;
}
$results[$key] = $value;
}
}
return $results;
}
/********************************************************************************
* Instance interface
*******************************************************************************/
/**
* Transform header name into canonical form
* @param string $key
* @return string
*/
protected function normalizeKey($key)
{
$key = strtolower($key);
$key = str_replace(array('-', '_'), ' ', $key);
$key = preg_replace('#^http #', '', $key);
$key = ucwords($key);
$key = str_replace(' ', '-', $key);
return $key;
}
}

View File

@ -1,617 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Http;
/**
* Slim HTTP Request
*
* This class provides a human-friendly interface to the Slim environment variables;
* environment variables are passed by reference and will be modified directly.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class Request
{
const METHOD_HEAD = 'HEAD';
const METHOD_GET = 'GET';
const METHOD_POST = 'POST';
const METHOD_PUT = 'PUT';
const METHOD_PATCH = 'PATCH';
const METHOD_DELETE = 'DELETE';
const METHOD_OPTIONS = 'OPTIONS';
const METHOD_OVERRIDE = '_METHOD';
/**
* @var array
*/
protected static $formDataMediaTypes = array('application/x-www-form-urlencoded');
/**
* Application Environment
* @var \Slim\Environment
*/
protected $env;
/**
* HTTP Headers
* @var \Slim\Http\Headers
*/
public $headers;
/**
* HTTP Cookies
* @var \Slim\Helper\Set
*/
public $cookies;
/**
* Constructor
* @param \Slim\Environment $env
*/
public function __construct(\Slim\Environment $env)
{
$this->env = $env;
$this->headers = new \Slim\Http\Headers(\Slim\Http\Headers::extract($env));
$this->cookies = new \Slim\Helper\Set(\Slim\Http\Util::parseCookieHeader($env['HTTP_COOKIE']));
}
/**
* Get HTTP method
* @return string
*/
public function getMethod()
{
return $this->env['REQUEST_METHOD'];
}
/**
* Is this a GET request?
* @return bool
*/
public function isGet()
{
return $this->getMethod() === self::METHOD_GET;
}
/**
* Is this a POST request?
* @return bool
*/
public function isPost()
{
return $this->getMethod() === self::METHOD_POST;
}
/**
* Is this a PUT request?
* @return bool
*/
public function isPut()
{
return $this->getMethod() === self::METHOD_PUT;
}
/**
* Is this a PATCH request?
* @return bool
*/
public function isPatch()
{
return $this->getMethod() === self::METHOD_PATCH;
}
/**
* Is this a DELETE request?
* @return bool
*/
public function isDelete()
{
return $this->getMethod() === self::METHOD_DELETE;
}
/**
* Is this a HEAD request?
* @return bool
*/
public function isHead()
{
return $this->getMethod() === self::METHOD_HEAD;
}
/**
* Is this a OPTIONS request?
* @return bool
*/
public function isOptions()
{
return $this->getMethod() === self::METHOD_OPTIONS;
}
/**
* Is this an AJAX request?
* @return bool
*/
public function isAjax()
{
if ($this->params('isajax')) {
return true;
} elseif (isset($this->headers['X_REQUESTED_WITH']) && $this->headers['X_REQUESTED_WITH'] === 'XMLHttpRequest') {
return true;
} else {
return false;
}
}
/**
* Is this an XHR request? (alias of Slim_Http_Request::isAjax)
* @return bool
*/
public function isXhr()
{
return $this->isAjax();
}
/**
* Fetch GET and POST data
*
* This method returns a union of GET and POST data as a key-value array, or the value
* of the array key if requested; if the array key does not exist, NULL is returned,
* unless there is a default value specified.
*
* @param string $key
* @param mixed $default
* @return array|mixed|null
*/
public function params($key = null, $default = null)
{
$union = array_merge($this->get(), $this->post());
if ($key) {
return isset($union[$key]) ? $union[$key] : $default;
}
return $union;
}
/**
* Fetch GET data
*
* This method returns a key-value array of data sent in the HTTP request query string, or
* the value of the array key if requested; if the array key does not exist, NULL is returned.
*
* @param string $key
* @param mixed $default Default return value when key does not exist
* @return array|mixed|null
*/
public function get($key = null, $default = null)
{
if (!isset($this->env['slim.request.query_hash'])) {
$output = array();
if (function_exists('mb_parse_str') && !isset($this->env['slim.tests.ignore_multibyte'])) {
mb_parse_str($this->env['QUERY_STRING'], $output);
} else {
parse_str($this->env['QUERY_STRING'], $output);
}
$this->env['slim.request.query_hash'] = Util::stripSlashesIfMagicQuotes($output);
}
if ($key) {
if (isset($this->env['slim.request.query_hash'][$key])) {
return $this->env['slim.request.query_hash'][$key];
} else {
return $default;
}
} else {
return $this->env['slim.request.query_hash'];
}
}
/**
* Fetch POST data
*
* This method returns a key-value array of data sent in the HTTP request body, or
* the value of a hash key if requested; if the array key does not exist, NULL is returned.
*
* @param string $key
* @param mixed $default Default return value when key does not exist
* @return array|mixed|null
* @throws \RuntimeException If environment input is not available
*/
public function post($key = null, $default = null)
{
if (!isset($this->env['slim.input'])) {
throw new \RuntimeException('Missing slim.input in environment variables');
}
if (!isset($this->env['slim.request.form_hash'])) {
$this->env['slim.request.form_hash'] = array();
if ($this->isFormData() && is_string($this->env['slim.input'])) {
$output = array();
if (function_exists('mb_parse_str') && !isset($this->env['slim.tests.ignore_multibyte'])) {
mb_parse_str($this->env['slim.input'], $output);
} else {
parse_str($this->env['slim.input'], $output);
}
$this->env['slim.request.form_hash'] = Util::stripSlashesIfMagicQuotes($output);
} else {
$this->env['slim.request.form_hash'] = Util::stripSlashesIfMagicQuotes($_POST);
}
}
if ($key) {
if (isset($this->env['slim.request.form_hash'][$key])) {
return $this->env['slim.request.form_hash'][$key];
} else {
return $default;
}
} else {
return $this->env['slim.request.form_hash'];
}
}
/**
* Fetch PUT data (alias for \Slim\Http\Request::post)
* @param string $key
* @param mixed $default Default return value when key does not exist
* @return array|mixed|null
*/
public function put($key = null, $default = null)
{
return $this->post($key, $default);
}
/**
* Fetch PATCH data (alias for \Slim\Http\Request::post)
* @param string $key
* @param mixed $default Default return value when key does not exist
* @return array|mixed|null
*/
public function patch($key = null, $default = null)
{
return $this->post($key, $default);
}
/**
* Fetch DELETE data (alias for \Slim\Http\Request::post)
* @param string $key
* @param mixed $default Default return value when key does not exist
* @return array|mixed|null
*/
public function delete($key = null, $default = null)
{
return $this->post($key, $default);
}
/**
* Fetch COOKIE data
*
* This method returns a key-value array of Cookie data sent in the HTTP request, or
* the value of a array key if requested; if the array key does not exist, NULL is returned.
*
* @param string $key
* @return array|string|null
*/
public function cookies($key = null)
{
if ($key) {
return $this->cookies->get($key);
}
return $this->cookies;
// if (!isset($this->env['slim.request.cookie_hash'])) {
// $cookieHeader = isset($this->env['COOKIE']) ? $this->env['COOKIE'] : '';
// $this->env['slim.request.cookie_hash'] = Util::parseCookieHeader($cookieHeader);
// }
// if ($key) {
// if (isset($this->env['slim.request.cookie_hash'][$key])) {
// return $this->env['slim.request.cookie_hash'][$key];
// } else {
// return null;
// }
// } else {
// return $this->env['slim.request.cookie_hash'];
// }
}
/**
* Does the Request body contain parsed form data?
* @return bool
*/
public function isFormData()
{
$method = isset($this->env['slim.method_override.original_method']) ? $this->env['slim.method_override.original_method'] : $this->getMethod();
return ($method === self::METHOD_POST && is_null($this->getContentType())) || in_array($this->getMediaType(), self::$formDataMediaTypes);
}
/**
* Get Headers
*
* This method returns a key-value array of headers sent in the HTTP request, or
* the value of a hash key if requested; if the array key does not exist, NULL is returned.
*
* @param string $key
* @param mixed $default The default value returned if the requested header is not available
* @return mixed
*/
public function headers($key = null, $default = null)
{
if ($key) {
return $this->headers->get($key, $default);
}
return $this->headers;
// if ($key) {
// $key = strtoupper($key);
// $key = str_replace('-', '_', $key);
// $key = preg_replace('@^HTTP_@', '', $key);
// if (isset($this->env[$key])) {
// return $this->env[$key];
// } else {
// return $default;
// }
// } else {
// $headers = array();
// foreach ($this->env as $key => $value) {
// if (strpos($key, 'slim.') !== 0) {
// $headers[$key] = $value;
// }
// }
//
// return $headers;
// }
}
/**
* Get Body
* @return string
*/
public function getBody()
{
return $this->env['slim.input'];
}
/**
* Get Content Type
* @return string|null
*/
public function getContentType()
{
return $this->headers->get('CONTENT_TYPE');
}
/**
* Get Media Type (type/subtype within Content Type header)
* @return string|null
*/
public function getMediaType()
{
$contentType = $this->getContentType();
if ($contentType) {
$contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType);
return strtolower($contentTypeParts[0]);
}
return null;
}
/**
* Get Media Type Params
* @return array
*/
public function getMediaTypeParams()
{
$contentType = $this->getContentType();
$contentTypeParams = array();
if ($contentType) {
$contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType);
$contentTypePartsLength = count($contentTypeParts);
for ($i = 1; $i < $contentTypePartsLength; $i++) {
$paramParts = explode('=', $contentTypeParts[$i]);
$contentTypeParams[strtolower($paramParts[0])] = $paramParts[1];
}
}
return $contentTypeParams;
}
/**
* Get Content Charset
* @return string|null
*/
public function getContentCharset()
{
$mediaTypeParams = $this->getMediaTypeParams();
if (isset($mediaTypeParams['charset'])) {
return $mediaTypeParams['charset'];
}
return null;
}
/**
* Get Content-Length
* @return int
*/
public function getContentLength()
{
return $this->headers->get('CONTENT_LENGTH', 0);
}
/**
* Get Host
* @return string
*/
public function getHost()
{
if (isset($this->env['HTTP_HOST'])) {
if (strpos($this->env['HTTP_HOST'], ':') !== false) {
$hostParts = explode(':', $this->env['HTTP_HOST']);
return $hostParts[0];
}
return $this->env['HTTP_HOST'];
}
return $this->env['SERVER_NAME'];
}
/**
* Get Host with Port
* @return string
*/
public function getHostWithPort()
{
return sprintf('%s:%s', $this->getHost(), $this->getPort());
}
/**
* Get Port
* @return int
*/
public function getPort()
{
return (int)$this->env['SERVER_PORT'];
}
/**
* Get Scheme (https or http)
* @return string
*/
public function getScheme()
{
return $this->env['slim.url_scheme'];
}
/**
* Get Script Name (physical path)
* @return string
*/
public function getScriptName()
{
return $this->env['SCRIPT_NAME'];
}
/**
* LEGACY: Get Root URI (alias for Slim_Http_Request::getScriptName)
* @return string
*/
public function getRootUri()
{
return $this->getScriptName();
}
/**
* Get Path (physical path + virtual path)
* @return string
*/
public function getPath()
{
return $this->getScriptName() . $this->getPathInfo();
}
/**
* Get Path Info (virtual path)
* @return string
*/
public function getPathInfo()
{
return $this->env['PATH_INFO'];
}
/**
* LEGACY: Get Resource URI (alias for Slim_Http_Request::getPathInfo)
* @return string
*/
public function getResourceUri()
{
return $this->getPathInfo();
}
/**
* Get URL (scheme + host [ + port if non-standard ])
* @return string
*/
public function getUrl()
{
$url = $this->getScheme() . '://' . $this->getHost();
if (($this->getScheme() === 'https' && $this->getPort() !== 443) || ($this->getScheme() === 'http' && $this->getPort() !== 80)) {
$url .= sprintf(':%s', $this->getPort());
}
return $url;
}
/**
* Get IP
* @return string
*/
public function getIp()
{
$keys = array('X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR');
foreach ($keys as $key) {
if (isset($this->env[$key])) {
return $this->env[$key];
}
}
return $this->env['REMOTE_ADDR'];
}
/**
* Get Referrer
* @return string|null
*/
public function getReferrer()
{
return $this->headers->get('HTTP_REFERER');
}
/**
* Get Referer (for those who can't spell)
* @return string|null
*/
public function getReferer()
{
return $this->getReferrer();
}
/**
* Get User Agent
* @return string|null
*/
public function getUserAgent()
{
return $this->headers->get('HTTP_USER_AGENT');
}
}

View File

@ -1,512 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Http;
/**
* Response
*
* This is a simple abstraction over top an HTTP response. This
* provides methods to set the HTTP status, the HTTP headers,
* and the HTTP body.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class Response implements \ArrayAccess, \Countable, \IteratorAggregate
{
/**
* @var int HTTP status code
*/
protected $status;
/**
* @var \Slim\Http\Headers
*/
public $headers;
/**
* @var \Slim\Http\Cookies
*/
public $cookies;
/**
* @var string HTTP response body
*/
protected $body;
/**
* @var int Length of HTTP response body
*/
protected $length;
/**
* @var array HTTP response codes and messages
*/
protected static $messages = array(
//Informational 1xx
100 => '100 Continue',
101 => '101 Switching Protocols',
//Successful 2xx
200 => '200 OK',
201 => '201 Created',
202 => '202 Accepted',
203 => '203 Non-Authoritative Information',
204 => '204 No Content',
205 => '205 Reset Content',
206 => '206 Partial Content',
//Redirection 3xx
300 => '300 Multiple Choices',
301 => '301 Moved Permanently',
302 => '302 Found',
303 => '303 See Other',
304 => '304 Not Modified',
305 => '305 Use Proxy',
306 => '306 (Unused)',
307 => '307 Temporary Redirect',
//Client Error 4xx
400 => '400 Bad Request',
401 => '401 Unauthorized',
402 => '402 Payment Required',
403 => '403 Forbidden',
404 => '404 Not Found',
405 => '405 Method Not Allowed',
406 => '406 Not Acceptable',
407 => '407 Proxy Authentication Required',
408 => '408 Request Timeout',
409 => '409 Conflict',
410 => '410 Gone',
411 => '411 Length Required',
412 => '412 Precondition Failed',
413 => '413 Request Entity Too Large',
414 => '414 Request-URI Too Long',
415 => '415 Unsupported Media Type',
416 => '416 Requested Range Not Satisfiable',
417 => '417 Expectation Failed',
418 => '418 I\'m a teapot',
422 => '422 Unprocessable Entity',
423 => '423 Locked',
//Server Error 5xx
500 => '500 Internal Server Error',
501 => '501 Not Implemented',
502 => '502 Bad Gateway',
503 => '503 Service Unavailable',
504 => '504 Gateway Timeout',
505 => '505 HTTP Version Not Supported'
);
/**
* Constructor
* @param string $body The HTTP response body
* @param int $status The HTTP response status
* @param \Slim\Http\Headers|array $headers The HTTP response headers
*/
public function __construct($body = '', $status = 200, $headers = array())
{
$this->setStatus($status);
$this->headers = new \Slim\Http\Headers(array('Content-Type' => 'text/html'));
$this->headers->replace($headers);
$this->cookies = new \Slim\Http\Cookies();
$this->write($body);
}
public function getStatus()
{
return $this->status;
}
public function setStatus($status)
{
$this->status = (int)$status;
}
/**
* DEPRECATION WARNING! Use `getStatus` or `setStatus` instead.
*
* Get and set status
* @param int|null $status
* @return int
*/
public function status($status = null)
{
if (!is_null($status)) {
$this->status = (int) $status;
}
return $this->status;
}
/**
* DEPRECATION WARNING! Access `headers` property directly.
*
* Get and set header
* @param string $name Header name
* @param string|null $value Header value
* @return string Header value
*/
public function header($name, $value = null)
{
if (!is_null($value)) {
$this->headers->set($name, $value);
}
return $this->headers->get($name);
}
/**
* DEPRECATION WARNING! Access `headers` property directly.
*
* Get headers
* @return \Slim\Http\Headers
*/
public function headers()
{
return $this->headers;
}
public function getBody()
{
return $this->body;
}
public function setBody($content)
{
$this->write($content, true);
}
/**
* DEPRECATION WARNING! use `getBody` or `setBody` instead.
*
* Get and set body
* @param string|null $body Content of HTTP response body
* @return string
*/
public function body($body = null)
{
if (!is_null($body)) {
$this->write($body, true);
}
return $this->body;
}
/**
* Append HTTP response body
* @param string $body Content to append to the current HTTP response body
* @param bool $replace Overwrite existing response body?
* @return string The updated HTTP response body
*/
public function write($body, $replace = false)
{
if ($replace) {
$this->body = $body;
} else {
$this->body .= (string)$body;
}
$this->length = strlen($this->body);
return $this->body;
}
public function getLength()
{
return $this->length;
}
/**
* DEPRECATION WARNING! Use `getLength` or `write` or `body` instead.
*
* Get and set length
* @param int|null $length
* @return int
*/
public function length($length = null)
{
if (!is_null($length)) {
$this->length = (int) $length;
}
return $this->length;
}
/**
* Finalize
*
* This prepares this response and returns an array
* of [status, headers, body]. This array is passed to outer middleware
* if available or directly to the Slim run method.
*
* @return array[int status, array headers, string body]
*/
public function finalize()
{
// Prepare response
if (in_array($this->status, array(204, 304))) {
$this->headers->remove('Content-Type');
$this->headers->remove('Content-Length');
$this->setBody('');
}
return array($this->status, $this->headers, $this->body);
}
/**
* DEPRECATION WARNING! Access `cookies` property directly.
*
* Set cookie
*
* Instead of using PHP's `setcookie()` function, Slim manually constructs the HTTP `Set-Cookie`
* header on its own and delegates this responsibility to the `Slim_Http_Util` class. This
* response's header is passed by reference to the utility class and is directly modified. By not
* relying on PHP's native implementation, Slim allows middleware the opportunity to massage or
* analyze the raw header before the response is ultimately delivered to the HTTP client.
*
* @param string $name The name of the cookie
* @param string|array $value If string, the value of cookie; if array, properties for
* cookie including: value, expire, path, domain, secure, httponly
*/
public function setCookie($name, $value)
{
// Util::setCookieHeader($this->header, $name, $value);
$this->cookies->set($name, $value);
}
/**
* DEPRECATION WARNING! Access `cookies` property directly.
*
* Delete cookie
*
* Instead of using PHP's `setcookie()` function, Slim manually constructs the HTTP `Set-Cookie`
* header on its own and delegates this responsibility to the `Slim_Http_Util` class. This
* response's header is passed by reference to the utility class and is directly modified. By not
* relying on PHP's native implementation, Slim allows middleware the opportunity to massage or
* analyze the raw header before the response is ultimately delivered to the HTTP client.
*
* This method will set a cookie with the given name that has an expiration time in the past; this will
* prompt the HTTP client to invalidate and remove the client-side cookie. Optionally, you may
* also pass a key/value array as the second argument. If the "domain" key is present in this
* array, only the Cookie with the given name AND domain will be removed. The invalidating cookie
* sent with this response will adopt all properties of the second argument.
*
* @param string $name The name of the cookie
* @param array $settings Properties for cookie including: value, expire, path, domain, secure, httponly
*/
public function deleteCookie($name, $settings = array())
{
$this->cookies->remove($name, $settings);
// Util::deleteCookieHeader($this->header, $name, $value);
}
/**
* Redirect
*
* This method prepares this response to return an HTTP Redirect response
* to the HTTP client.
*
* @param string $url The redirect destination
* @param int $status The redirect HTTP status code
*/
public function redirect ($url, $status = 302)
{
$this->setStatus($status);
$this->headers->set('Location', $url);
}
/**
* Helpers: Empty?
* @return bool
*/
public function isEmpty()
{
return in_array($this->status, array(201, 204, 304));
}
/**
* Helpers: Informational?
* @return bool
*/
public function isInformational()
{
return $this->status >= 100 && $this->status < 200;
}
/**
* Helpers: OK?
* @return bool
*/
public function isOk()
{
return $this->status === 200;
}
/**
* Helpers: Successful?
* @return bool
*/
public function isSuccessful()
{
return $this->status >= 200 && $this->status < 300;
}
/**
* Helpers: Redirect?
* @return bool
*/
public function isRedirect()
{
return in_array($this->status, array(301, 302, 303, 307));
}
/**
* Helpers: Redirection?
* @return bool
*/
public function isRedirection()
{
return $this->status >= 300 && $this->status < 400;
}
/**
* Helpers: Forbidden?
* @return bool
*/
public function isForbidden()
{
return $this->status === 403;
}
/**
* Helpers: Not Found?
* @return bool
*/
public function isNotFound()
{
return $this->status === 404;
}
/**
* Helpers: Client error?
* @return bool
*/
public function isClientError()
{
return $this->status >= 400 && $this->status < 500;
}
/**
* Helpers: Server Error?
* @return bool
*/
public function isServerError()
{
return $this->status >= 500 && $this->status < 600;
}
/**
* DEPRECATION WARNING! ArrayAccess interface will be removed from \Slim\Http\Response.
* Iterate `headers` or `cookies` properties directly.
*/
/**
* Array Access: Offset Exists
*/
public function offsetExists($offset)
{
return isset($this->headers[$offset]);
}
/**
* Array Access: Offset Get
*/
public function offsetGet($offset)
{
return $this->headers[$offset];
}
/**
* Array Access: Offset Set
*/
public function offsetSet($offset, $value)
{
$this->headers[$offset] = $value;
}
/**
* Array Access: Offset Unset
*/
public function offsetUnset($offset)
{
unset($this->headers[$offset]);
}
/**
* DEPRECATION WARNING! Countable interface will be removed from \Slim\Http\Response.
* Call `count` on `headers` or `cookies` properties directly.
*
* Countable: Count
*/
public function count()
{
return count($this->headers);
}
/**
* DEPRECATION WARNING! IteratorAggregate interface will be removed from \Slim\Http\Response.
* Iterate `headers` or `cookies` properties directly.
*
* Get Iterator
*
* This returns the contained `\Slim\Http\Headers` instance which
* is itself iterable.
*
* @return \Slim\Http\Headers
*/
public function getIterator()
{
return $this->headers->getIterator();
}
/**
* Get message for HTTP status code
* @param int $status
* @return string|null
*/
public static function getMessageForCode($status)
{
if (isset(self::$messages[$status])) {
return self::$messages[$status];
} else {
return null;
}
}
}

View File

@ -1,434 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Http;
/**
* Slim HTTP Utilities
*
* This class provides useful methods for handling HTTP requests.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class Util
{
/**
* Strip slashes from string or array
*
* This method strips slashes from its input. By default, this method will only
* strip slashes from its input if magic quotes are enabled. Otherwise, you may
* override the magic quotes setting with either TRUE or FALSE as the send argument
* to force this method to strip or not strip slashes from its input.
*
* @param array|string $rawData
* @param bool $overrideStripSlashes
* @return array|string
*/
public static function stripSlashesIfMagicQuotes($rawData, $overrideStripSlashes = null)
{
$strip = is_null($overrideStripSlashes) ? get_magic_quotes_gpc() : $overrideStripSlashes;
if ($strip) {
return self::stripSlashes($rawData);
} else {
return $rawData;
}
}
/**
* Strip slashes from string or array
* @param array|string $rawData
* @return array|string
*/
protected static function stripSlashes($rawData)
{
return is_array($rawData) ? array_map(array('self', 'stripSlashes'), $rawData) : stripslashes($rawData);
}
/**
* Encrypt data
*
* This method will encrypt data using a given key, vector, and cipher.
* By default, this will encrypt data using the RIJNDAEL/AES 256 bit cipher. You
* may override the default cipher and cipher mode by passing your own desired
* cipher and cipher mode as the final key-value array argument.
*
* @param string $data The unencrypted data
* @param string $key The encryption key
* @param string $iv The encryption initialization vector
* @param array $settings Optional key-value array with custom algorithm and mode
* @return string
*/
public static function encrypt($data, $key, $iv, $settings = array())
{
if ($data === '' || !extension_loaded('mcrypt')) {
return $data;
}
//Merge settings with defaults
$defaults = array(
'algorithm' => MCRYPT_RIJNDAEL_256,
'mode' => MCRYPT_MODE_CBC
);
$settings = array_merge($defaults, $settings);
//Get module
$module = mcrypt_module_open($settings['algorithm'], '', $settings['mode'], '');
//Validate IV
$ivSize = mcrypt_enc_get_iv_size($module);
if (strlen($iv) > $ivSize) {
$iv = substr($iv, 0, $ivSize);
}
//Validate key
$keySize = mcrypt_enc_get_key_size($module);
if (strlen($key) > $keySize) {
$key = substr($key, 0, $keySize);
}
//Encrypt value
mcrypt_generic_init($module, $key, $iv);
$res = @mcrypt_generic($module, $data);
mcrypt_generic_deinit($module);
return $res;
}
/**
* Decrypt data
*
* This method will decrypt data using a given key, vector, and cipher.
* By default, this will decrypt data using the RIJNDAEL/AES 256 bit cipher. You
* may override the default cipher and cipher mode by passing your own desired
* cipher and cipher mode as the final key-value array argument.
*
* @param string $data The encrypted data
* @param string $key The encryption key
* @param string $iv The encryption initialization vector
* @param array $settings Optional key-value array with custom algorithm and mode
* @return string
*/
public static function decrypt($data, $key, $iv, $settings = array())
{
if ($data === '' || !extension_loaded('mcrypt')) {
return $data;
}
//Merge settings with defaults
$defaults = array(
'algorithm' => MCRYPT_RIJNDAEL_256,
'mode' => MCRYPT_MODE_CBC
);
$settings = array_merge($defaults, $settings);
//Get module
$module = mcrypt_module_open($settings['algorithm'], '', $settings['mode'], '');
//Validate IV
$ivSize = mcrypt_enc_get_iv_size($module);
if (strlen($iv) > $ivSize) {
$iv = substr($iv, 0, $ivSize);
}
//Validate key
$keySize = mcrypt_enc_get_key_size($module);
if (strlen($key) > $keySize) {
$key = substr($key, 0, $keySize);
}
//Decrypt value
mcrypt_generic_init($module, $key, $iv);
$decryptedData = @mdecrypt_generic($module, $data);
$res = rtrim($decryptedData, "\0");
mcrypt_generic_deinit($module);
return $res;
}
/**
* Serialize Response cookies into raw HTTP header
* @param \Slim\Http\Headers $headers The Response headers
* @param \Slim\Http\Cookies $cookies The Response cookies
* @param array $config The Slim app settings
*/
public static function serializeCookies(\Slim\Http\Headers &$headers, \Slim\Http\Cookies $cookies, array $config)
{
if ($config['cookies.encrypt']) {
foreach ($cookies as $name => $settings) {
if (is_string($settings['expires'])) {
$expires = strtotime($settings['expires']);
} else {
$expires = (int) $settings['expires'];
}
$settings['value'] = static::encodeSecureCookie(
$settings['value'],
$expires,
$config['cookies.secret_key'],
$config['cookies.cipher'],
$config['cookies.cipher_mode']
);
static::setCookieHeader($headers, $name, $settings);
}
} else {
foreach ($cookies as $name => $settings) {
static::setCookieHeader($headers, $name, $settings);
}
}
}
/**
* Encode secure cookie value
*
* This method will create the secure value of an HTTP cookie. The
* cookie value is encrypted and hashed so that its value is
* secure and checked for integrity when read in subsequent requests.
*
* @param string $value The insecure HTTP cookie value
* @param int $expires The UNIX timestamp at which this cookie will expire
* @param string $secret The secret key used to hash the cookie value
* @param int $algorithm The algorithm to use for encryption
* @param int $mode The algorithm mode to use for encryption
* @return string
*/
public static function encodeSecureCookie($value, $expires, $secret, $algorithm, $mode)
{
$key = hash_hmac('sha1', (string) $expires, $secret);
$iv = self::getIv($expires, $secret);
$secureString = base64_encode(
self::encrypt(
$value,
$key,
$iv,
array(
'algorithm' => $algorithm,
'mode' => $mode
)
)
);
$verificationString = hash_hmac('sha1', $expires . $value, $key);
return implode('|', array($expires, $secureString, $verificationString));
}
/**
* Decode secure cookie value
*
* This method will decode the secure value of an HTTP cookie. The
* cookie value is encrypted and hashed so that its value is
* secure and checked for integrity when read in subsequent requests.
*
* @param string $value The secure HTTP cookie value
* @param string $secret The secret key used to hash the cookie value
* @param int $algorithm The algorithm to use for encryption
* @param int $mode The algorithm mode to use for encryption
* @return bool|string
*/
public static function decodeSecureCookie($value, $secret, $algorithm, $mode)
{
if ($value) {
$value = explode('|', $value);
if (count($value) === 3 && ((int) $value[0] === 0 || (int) $value[0] > time())) {
$key = hash_hmac('sha1', $value[0], $secret);
$iv = self::getIv($value[0], $secret);
$data = self::decrypt(
base64_decode($value[1]),
$key,
$iv,
array(
'algorithm' => $algorithm,
'mode' => $mode
)
);
$verificationString = hash_hmac('sha1', $value[0] . $data, $key);
if ($verificationString === $value[2]) {
return $data;
}
}
}
return false;
}
/**
* Set HTTP cookie header
*
* This method will construct and set the HTTP `Set-Cookie` header. Slim
* uses this method instead of PHP's native `setcookie` method. This allows
* more control of the HTTP header irrespective of the native implementation's
* dependency on PHP versions.
*
* This method accepts the Slim_Http_Headers object by reference as its
* first argument; this method directly modifies this object instead of
* returning a value.
*
* @param array $header
* @param string $name
* @param string $value
*/
public static function setCookieHeader(&$header, $name, $value)
{
//Build cookie header
if (is_array($value)) {
$domain = '';
$path = '';
$expires = '';
$secure = '';
$httponly = '';
if (isset($value['domain']) && $value['domain']) {
$domain = '; domain=' . $value['domain'];
}
if (isset($value['path']) && $value['path']) {
$path = '; path=' . $value['path'];
}
if (isset($value['expires'])) {
if (is_string($value['expires'])) {
$timestamp = strtotime($value['expires']);
} else {
$timestamp = (int) $value['expires'];
}
if ($timestamp !== 0) {
$expires = '; expires=' . gmdate('D, d-M-Y H:i:s e', $timestamp);
}
}
if (isset($value['secure']) && $value['secure']) {
$secure = '; secure';
}
if (isset($value['httponly']) && $value['httponly']) {
$httponly = '; HttpOnly';
}
$cookie = sprintf('%s=%s%s', urlencode($name), urlencode((string) $value['value']), $domain . $path . $expires . $secure . $httponly);
} else {
$cookie = sprintf('%s=%s', urlencode($name), urlencode((string) $value));
}
//Set cookie header
if (!isset($header['Set-Cookie']) || $header['Set-Cookie'] === '') {
$header['Set-Cookie'] = $cookie;
} else {
$header['Set-Cookie'] = implode("\n", array($header['Set-Cookie'], $cookie));
}
}
/**
* Delete HTTP cookie header
*
* This method will construct and set the HTTP `Set-Cookie` header to invalidate
* a client-side HTTP cookie. If a cookie with the same name (and, optionally, domain)
* is already set in the HTTP response, it will also be removed. Slim uses this method
* instead of PHP's native `setcookie` method. This allows more control of the HTTP header
* irrespective of PHP's native implementation's dependency on PHP versions.
*
* This method accepts the Slim_Http_Headers object by reference as its
* first argument; this method directly modifies this object instead of
* returning a value.
*
* @param array $header
* @param string $name
* @param array $value
*/
public static function deleteCookieHeader(&$header, $name, $value = array())
{
//Remove affected cookies from current response header
$cookiesOld = array();
$cookiesNew = array();
if (isset($header['Set-Cookie'])) {
$cookiesOld = explode("\n", $header['Set-Cookie']);
}
foreach ($cookiesOld as $c) {
if (isset($value['domain']) && $value['domain']) {
$regex = sprintf('@%s=.*domain=%s@', urlencode($name), preg_quote($value['domain']));
} else {
$regex = sprintf('@%s=@', urlencode($name));
}
if (preg_match($regex, $c) === 0) {
$cookiesNew[] = $c;
}
}
if ($cookiesNew) {
$header['Set-Cookie'] = implode("\n", $cookiesNew);
} else {
unset($header['Set-Cookie']);
}
//Set invalidating cookie to clear client-side cookie
self::setCookieHeader($header, $name, array_merge(array('value' => '', 'path' => null, 'domain' => null, 'expires' => time() - 100), $value));
}
/**
* Parse cookie header
*
* This method will parse the HTTP request's `Cookie` header
* and extract cookies into an associative array.
*
* @param string
* @return array
*/
public static function parseCookieHeader($header)
{
$cookies = array();
$header = rtrim($header, "\r\n");
$headerPieces = preg_split('@\s*[;,]\s*@', $header);
foreach ($headerPieces as $c) {
$cParts = explode('=', $c, 2);
if (count($cParts) === 2) {
$key = urldecode($cParts[0]);
$value = urldecode($cParts[1]);
if (!isset($cookies[$key])) {
$cookies[$key] = $value;
}
}
}
return $cookies;
}
/**
* Generate a random IV
*
* This method will generate a non-predictable IV for use with
* the cookie encryption
*
* @param int $expires The UNIX timestamp at which this cookie will expire
* @param string $secret The secret key used to hash the cookie value
* @return string Hash
*/
private static function getIv($expires, $secret)
{
$data1 = hash_hmac('sha1', 'a'.$expires.'b', $secret);
$data2 = hash_hmac('sha1', 'z'.$expires.'y', $secret);
return pack("h*", $data1.$data2);
}
}

View File

@ -1,349 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim;
/**
* Log
*
* This is the primary logger for a Slim application. You may provide
* a Log Writer in conjunction with this Log to write to various output
* destinations (e.g. a file). This class provides this interface:
*
* debug( mixed $object, array $context )
* info( mixed $object, array $context )
* notice( mixed $object, array $context )
* warning( mixed $object, array $context )
* error( mixed $object, array $context )
* critical( mixed $object, array $context )
* alert( mixed $object, array $context )
* emergency( mixed $object, array $context )
* log( mixed $level, mixed $object, array $context )
*
* This class assumes only that your Log Writer has a public `write()` method
* that accepts any object as its one and only argument. The Log Writer
* class may write or send its argument anywhere: a file, STDERR,
* a remote web API, etc. The possibilities are endless.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class Log
{
const EMERGENCY = 1;
const ALERT = 2;
const CRITICAL = 3;
const FATAL = 3; //DEPRECATED replace with CRITICAL
const ERROR = 4;
const WARN = 5;
const NOTICE = 6;
const INFO = 7;
const DEBUG = 8;
/**
* @var array
*/
protected static $levels = array(
self::EMERGENCY => 'EMERGENCY',
self::ALERT => 'ALERT',
self::CRITICAL => 'CRITICAL',
self::ERROR => 'ERROR',
self::WARN => 'WARNING',
self::NOTICE => 'NOTICE',
self::INFO => 'INFO',
self::DEBUG => 'DEBUG'
);
/**
* @var mixed
*/
protected $writer;
/**
* @var bool
*/
protected $enabled;
/**
* @var int
*/
protected $level;
/**
* Constructor
* @param mixed $writer
*/
public function __construct($writer)
{
$this->writer = $writer;
$this->enabled = true;
$this->level = self::DEBUG;
}
/**
* Is logging enabled?
* @return bool
*/
public function getEnabled()
{
return $this->enabled;
}
/**
* Enable or disable logging
* @param bool $enabled
*/
public function setEnabled($enabled)
{
if ($enabled) {
$this->enabled = true;
} else {
$this->enabled = false;
}
}
/**
* Set level
* @param int $level
* @throws \InvalidArgumentException If invalid log level specified
*/
public function setLevel($level)
{
if (!isset(self::$levels[$level])) {
throw new \InvalidArgumentException('Invalid log level');
}
$this->level = $level;
}
/**
* Get level
* @return int
*/
public function getLevel()
{
return $this->level;
}
/**
* Set writer
* @param mixed $writer
*/
public function setWriter($writer)
{
$this->writer = $writer;
}
/**
* Get writer
* @return mixed
*/
public function getWriter()
{
return $this->writer;
}
/**
* Is logging enabled?
* @return bool
*/
public function isEnabled()
{
return $this->enabled;
}
/**
* Log debug message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function debug($object, $context = array())
{
return $this->log(self::DEBUG, $object, $context);
}
/**
* Log info message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function info($object, $context = array())
{
return $this->log(self::INFO, $object, $context);
}
/**
* Log notice message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function notice($object, $context = array())
{
return $this->log(self::NOTICE, $object, $context);
}
/**
* Log warning message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function warning($object, $context = array())
{
return $this->log(self::WARN, $object, $context);
}
/**
* DEPRECATED for function warning
* Log warning message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function warn($object, $context = array())
{
return $this->log(self::WARN, $object, $context);
}
/**
* Log error message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function error($object, $context = array())
{
return $this->log(self::ERROR, $object, $context);
}
/**
* Log critical message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function critical($object, $context = array())
{
return $this->log(self::CRITICAL, $object, $context);
}
/**
* DEPRECATED for function critical
* Log fatal message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function fatal($object, $context = array())
{
return $this->log(self::CRITICAL, $object, $context);
}
/**
* Log alert message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function alert($object, $context = array())
{
return $this->log(self::ALERT, $object, $context);
}
/**
* Log emergency message
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
*/
public function emergency($object, $context = array())
{
return $this->log(self::EMERGENCY, $object, $context);
}
/**
* Log message
* @param mixed $level
* @param mixed $object
* @param array $context
* @return mixed|bool What the Logger returns, or false if Logger not set or not enabled
* @throws \InvalidArgumentException If invalid log level
*/
public function log($level, $object, $context = array())
{
if (!isset(self::$levels[$level])) {
throw new \InvalidArgumentException('Invalid log level supplied to function');
} else if ($this->enabled && $this->writer && $level <= $this->level) {
$message = (string)$object;
if (count($context) > 0) {
if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
$message .= ' - ' . $context['exception'];
unset($context['exception']);
}
$message = $this->interpolate($message, $context);
}
return $this->writer->write($message, $level);
} else {
return false;
}
}
/**
* DEPRECATED for function log
* Log message
* @param mixed $object The object to log
* @param int $level The message level
* @return int|bool
*/
protected function write($object, $level)
{
return $this->log($level, $object);
}
/**
* Interpolate log message
* @param mixed $message The log message
* @param array $context An array of placeholder values
* @return string The processed string
*/
protected function interpolate($message, $context = array())
{
$replace = array();
foreach ($context as $key => $value) {
$replace['{' . $key . '}'] = $value;
}
return strtr($message, $replace);
}
}

View File

@ -1,75 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim;
/**
* Log Writer
*
* This class is used by Slim_Log to write log messages to a valid, writable
* resource handle (e.g. a file or STDERR).
*
* @package Slim
* @author Josh Lockhart
* @since 1.6.0
*/
class LogWriter
{
/**
* @var resource
*/
protected $resource;
/**
* Constructor
* @param resource $resource
* @throws \InvalidArgumentException If invalid resource
*/
public function __construct($resource)
{
if (!is_resource($resource)) {
throw new \InvalidArgumentException('Cannot create LogWriter. Invalid resource handle.');
}
$this->resource = $resource;
}
/**
* Write message
* @param mixed $message
* @param int $level
* @return int|bool
*/
public function write($message, $level = null)
{
return fwrite($this->resource, (string) $message . PHP_EOL);
}
}

View File

@ -1,114 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim;
/**
* Middleware
*
* @package Slim
* @author Josh Lockhart
* @since 1.6.0
*/
abstract class Middleware
{
/**
* @var \Slim\Slim Reference to the primary application instance
*/
protected $app;
/**
* @var mixed Reference to the next downstream middleware
*/
protected $next;
/**
* Set application
*
* This method injects the primary Slim application instance into
* this middleware.
*
* @param \Slim\Slim $application
*/
final public function setApplication($application)
{
$this->app = $application;
}
/**
* Get application
*
* This method retrieves the application previously injected
* into this middleware.
*
* @return \Slim\Slim
*/
final public function getApplication()
{
return $this->app;
}
/**
* Set next middleware
*
* This method injects the next downstream middleware into
* this middleware so that it may optionally be called
* when appropriate.
*
* @param \Slim|\Slim\Middleware
*/
final public function setNextMiddleware($nextMiddleware)
{
$this->next = $nextMiddleware;
}
/**
* Get next middleware
*
* This method retrieves the next downstream middleware
* previously injected into this middleware.
*
* @return \Slim\Slim|\Slim\Middleware
*/
final public function getNextMiddleware()
{
return $this->next;
}
/**
* Call
*
* Perform actions specific to this middleware and optionally
* call the next downstream middleware.
*/
abstract public function call();
}

View File

@ -1,174 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Middleware;
/**
* Content Types
*
* This is middleware for a Slim application that intercepts
* the HTTP request body and parses it into the appropriate
* PHP data structure if possible; else it returns the HTTP
* request body unchanged. This is particularly useful
* for preparing the HTTP request body for an XML or JSON API.
*
* @package Slim
* @author Josh Lockhart
* @since 1.6.0
*/
class ContentTypes extends \Slim\Middleware
{
/**
* @var array
*/
protected $contentTypes;
/**
* Constructor
* @param array $settings
*/
public function __construct($settings = array())
{
$defaults = array(
'application/json' => array($this, 'parseJson'),
'application/xml' => array($this, 'parseXml'),
'text/xml' => array($this, 'parseXml'),
'text/csv' => array($this, 'parseCsv')
);
$this->contentTypes = array_merge($defaults, $settings);
}
/**
* Call
*/
public function call()
{
$mediaType = $this->app->request()->getMediaType();
if ($mediaType) {
$env = $this->app->environment();
$env['slim.input_original'] = $env['slim.input'];
$env['slim.input'] = $this->parse($env['slim.input'], $mediaType);
}
$this->next->call();
}
/**
* Parse input
*
* This method will attempt to parse the request body
* based on its content type if available.
*
* @param string $input
* @param string $contentType
* @return mixed
*/
protected function parse ($input, $contentType)
{
if (isset($this->contentTypes[$contentType]) && is_callable($this->contentTypes[$contentType])) {
$result = call_user_func($this->contentTypes[$contentType], $input);
if ($result) {
return $result;
}
}
return $input;
}
/**
* Parse JSON
*
* This method converts the raw JSON input
* into an associative array.
*
* @param string $input
* @return array|string
*/
protected function parseJson($input)
{
if (function_exists('json_decode')) {
$result = json_decode($input, true);
if ($result) {
return $result;
}
}
}
/**
* Parse XML
*
* This method creates a SimpleXMLElement
* based upon the XML input. If the SimpleXML
* extension is not available, the raw input
* will be returned unchanged.
*
* @param string $input
* @return \SimpleXMLElement|string
*/
protected function parseXml($input)
{
if (class_exists('SimpleXMLElement')) {
try {
$backup = libxml_disable_entity_loader(true);
$result = new \SimpleXMLElement($input);
libxml_disable_entity_loader($backup);
return $result;
} catch (\Exception $e) {
// Do nothing
}
}
return $input;
}
/**
* Parse CSV
*
* This method parses CSV content into a numeric array
* containing an array of data for each CSV line.
*
* @param string $input
* @return array
*/
protected function parseCsv($input)
{
$temp = fopen('php://memory', 'rw');
fwrite($temp, $input);
fseek($temp, 0);
$res = array();
while (($data = fgetcsv($temp)) !== false) {
$res[] = $data;
}
fclose($temp);
return $res;
}
}

View File

@ -1,212 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Middleware;
/**
* Flash
*
* This is middleware for a Slim application that enables
* Flash messaging between HTTP requests. This allows you
* set Flash messages for the current request, for the next request,
* or to retain messages from the previous request through to
* the next request.
*
* @package Slim
* @author Josh Lockhart
* @since 1.6.0
*/
class Flash extends \Slim\Middleware implements \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* @var array
*/
protected $settings;
/**
* @var array
*/
protected $messages;
/**
* Constructor
* @param array $settings
*/
public function __construct($settings = array())
{
$this->settings = array_merge(array('key' => 'slim.flash'), $settings);
$this->messages = array(
'prev' => array(), //flash messages from prev request (loaded when middleware called)
'next' => array(), //flash messages for next request
'now' => array() //flash messages for current request
);
}
/**
* Call
*/
public function call()
{
//Read flash messaging from previous request if available
$this->loadMessages();
//Prepare flash messaging for current request
$env = $this->app->environment();
$env['slim.flash'] = $this;
$this->next->call();
$this->save();
}
/**
* Now
*
* Specify a flash message for a given key to be shown for the current request
*
* @param string $key
* @param string $value
*/
public function now($key, $value)
{
$this->messages['now'][(string) $key] = $value;
}
/**
* Set
*
* Specify a flash message for a given key to be shown for the next request
*
* @param string $key
* @param string $value
*/
public function set($key, $value)
{
$this->messages['next'][(string) $key] = $value;
}
/**
* Keep
*
* Retain flash messages from the previous request for the next request
*/
public function keep()
{
foreach ($this->messages['prev'] as $key => $val) {
$this->messages['next'][$key] = $val;
}
}
/**
* Save
*/
public function save()
{
$_SESSION[$this->settings['key']] = $this->messages['next'];
}
/**
* Load messages from previous request if available
*/
public function loadMessages()
{
if (isset($_SESSION[$this->settings['key']])) {
$this->messages['prev'] = $_SESSION[$this->settings['key']];
}
}
/**
* Return array of flash messages to be shown for the current request
*
* @return array
*/
public function getMessages()
{
return array_merge($this->messages['prev'], $this->messages['now']);
}
/**
* Array Access: Offset Exists
*/
public function offsetExists($offset)
{
$messages = $this->getMessages();
return isset($messages[$offset]);
}
/**
* Array Access: Offset Get
*/
public function offsetGet($offset)
{
$messages = $this->getMessages();
return isset($messages[$offset]) ? $messages[$offset] : null;
}
/**
* Array Access: Offset Set
*/
public function offsetSet($offset, $value)
{
$this->now($offset, $value);
}
/**
* Array Access: Offset Unset
*/
public function offsetUnset($offset)
{
unset($this->messages['prev'][$offset], $this->messages['now'][$offset]);
}
/**
* Iterator Aggregate: Get Iterator
* @return \ArrayIterator
*/
public function getIterator()
{
$messages = $this->getMessages();
return new \ArrayIterator($messages);
}
/**
* Countable: Count
*/
public function count()
{
return count($this->getMessages());
}
}

View File

@ -1,94 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Middleware;
/**
* HTTP Method Override
*
* This is middleware for a Slim application that allows traditional
* desktop browsers to submit pseudo PUT and DELETE requests by relying
* on a pre-determined request parameter. Without this middleware,
* desktop browsers are only able to submit GET and POST requests.
*
* This middleware is included automatically!
*
* @package Slim
* @author Josh Lockhart
* @since 1.6.0
*/
class MethodOverride extends \Slim\Middleware
{
/**
* @var array
*/
protected $settings;
/**
* Constructor
* @param array $settings
*/
public function __construct($settings = array())
{
$this->settings = array_merge(array('key' => '_METHOD'), $settings);
}
/**
* Call
*
* Implements Slim middleware interface. This method is invoked and passed
* an array of environment variables. This middleware inspects the environment
* variables for the HTTP method override parameter; if found, this middleware
* modifies the environment settings so downstream middleware and/or the Slim
* application will treat the request with the desired HTTP method.
*
* @return array[status, header, body]
*/
public function call()
{
$env = $this->app->environment();
if (isset($env['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
// Header commonly used by Backbone.js and others
$env['slim.method_override.original_method'] = $env['REQUEST_METHOD'];
$env['REQUEST_METHOD'] = strtoupper($env['HTTP_X_HTTP_METHOD_OVERRIDE']);
} elseif (isset($env['REQUEST_METHOD']) && $env['REQUEST_METHOD'] === 'POST') {
// HTML Form Override
$req = new \Slim\Http\Request($env);
$method = $req->post($this->settings['key']);
if ($method) {
$env['slim.method_override.original_method'] = $env['REQUEST_METHOD'];
$env['REQUEST_METHOD'] = strtoupper($method);
}
}
$this->next->call();
}
}

View File

@ -1,116 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Middleware;
/**
* Pretty Exceptions
*
* This middleware catches any Exception thrown by the surrounded
* application and displays a developer-friendly diagnostic screen.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class PrettyExceptions extends \Slim\Middleware
{
/**
* @var array
*/
protected $settings;
/**
* Constructor
* @param array $settings
*/
public function __construct($settings = array())
{
$this->settings = $settings;
}
/**
* Call
*/
public function call()
{
try {
$this->next->call();
} catch (\Exception $e) {
$log = $this->app->getLog(); // Force Slim to append log to env if not already
$env = $this->app->environment();
$env['slim.log'] = $log;
$env['slim.log']->error($e);
$this->app->contentType('text/html');
$this->app->response()->status(500);
$this->app->response()->body($this->renderBody($env, $e));
}
}
/**
* Render response body
* @param array $env
* @param \Exception $exception
* @return string
*/
protected function renderBody(&$env, $exception)
{
$title = 'Slim Application Error';
$code = $exception->getCode();
$message = $exception->getMessage();
$file = $exception->getFile();
$line = $exception->getLine();
$trace = str_replace(array('#', '\n'), array('<div>#', '</div>'), $exception->getTraceAsString());
$html = sprintf('<h1>%s</h1>', $title);
$html .= '<p>The application could not run because of the following error:</p>';
$html .= '<h2>Details</h2>';
$html .= sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception));
if ($code) {
$html .= sprintf('<div><strong>Code:</strong> %s</div>', $code);
}
if ($message) {
$html .= sprintf('<div><strong>Message:</strong> %s</div>', $message);
}
if ($file) {
$html .= sprintf('<div><strong>File:</strong> %s</div>', $file);
}
if ($line) {
$html .= sprintf('<div><strong>Line:</strong> %s</div>', $line);
}
if ($trace) {
$html .= '<h2>Trace</h2>';
$html .= sprintf('<pre>%s</pre>', $trace);
}
return sprintf("<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}</style></head><body>%s</body></html>", $title, $html);
}
}

View File

@ -1,210 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim\Middleware;
/**
* Session Cookie
*
* This class provides an HTTP cookie storage mechanism
* for session data. This class avoids using a PHP session
* and instead serializes/unserializes the $_SESSION global
* variable to/from an HTTP cookie.
*
* You should NEVER store sensitive data in a client-side cookie
* in any format, encrypted (with cookies.encrypt) or not. If you
* need to store sensitive user information in a session, you should
* rely on PHP's native session implementation, or use other middleware
* to store session data in a database or alternative server-side cache.
*
* Because this class stores serialized session data in an HTTP cookie,
* you are inherently limited to 4 Kb. If you attempt to store
* more than this amount, serialization will fail.
*
* @package Slim
* @author Josh Lockhart
* @since 1.6.0
*/
class SessionCookie extends \Slim\Middleware
{
/**
* @var array
*/
protected $settings;
/**
* Constructor
*
* @param array $settings
*/
public function __construct($settings = array())
{
$defaults = array(
'expires' => '20 minutes',
'path' => '/',
'domain' => null,
'secure' => false,
'httponly' => false,
'name' => 'slim_session',
);
$this->settings = array_merge($defaults, $settings);
if (is_string($this->settings['expires'])) {
$this->settings['expires'] = strtotime($this->settings['expires']);
}
/**
* Session
*
* We must start a native PHP session to initialize the $_SESSION superglobal.
* However, we won't be using the native session store for persistence, so we
* disable the session cookie and cache limiter. We also set the session
* handler to this class instance to avoid PHP's native session file locking.
*/
ini_set('session.use_cookies', 0);
session_cache_limiter(false);
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this, 'write'),
array($this, 'destroy'),
array($this, 'gc')
);
}
/**
* Call
*/
public function call()
{
$this->loadSession();
$this->next->call();
$this->saveSession();
}
/**
* Load session
*/
protected function loadSession()
{
if (session_id() === '') {
session_start();
}
$value = $this->app->getCookie($this->settings['name']);
if ($value) {
try {
$_SESSION = unserialize($value);
} catch (\Exception $e) {
$this->app->getLog()->error('Error unserializing session cookie value! ' . $e->getMessage());
}
} else {
$_SESSION = array();
}
}
/**
* Save session
*/
protected function saveSession()
{
$value = serialize($_SESSION);
if (strlen($value) > 4096) {
$this->app->getLog()->error('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.');
} else {
$this->app->setCookie(
$this->settings['name'],
$value,
$this->settings['expires'],
$this->settings['path'],
$this->settings['domain'],
$this->settings['secure'],
$this->settings['httponly']
);
}
// session_destroy();
}
/********************************************************************************
* Session Handler
*******************************************************************************/
/**
* @codeCoverageIgnore
*/
public function open($savePath, $sessionName)
{
return true;
}
/**
* @codeCoverageIgnore
*/
public function close()
{
return true;
}
/**
* @codeCoverageIgnore
*/
public function read($id)
{
return '';
}
/**
* @codeCoverageIgnore
*/
public function write($id, $data)
{
return true;
}
/**
* @codeCoverageIgnore
*/
public function destroy($id)
{
return true;
}
/**
* @codeCoverageIgnore
*/
public function gc($maxlifetime)
{
return true;
}
}

View File

@ -1,465 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim;
/**
* Route
* @package Slim
* @author Josh Lockhart, Thomas Bley
* @since 1.0.0
*/
class Route
{
/**
* @var string The route pattern (e.g. "/books/:id")
*/
protected $pattern;
/**
* @var mixed The route callable
*/
protected $callable;
/**
* @var array Conditions for this route's URL parameters
*/
protected $conditions = array();
/**
* @var array Default conditions applied to all route instances
*/
protected static $defaultConditions = array();
/**
* @var string The name of this route (optional)
*/
protected $name;
/**
* @var array Key-value array of URL parameters
*/
protected $params = array();
/**
* @var array value array of URL parameter names
*/
protected $paramNames = array();
/**
* @var array key array of URL parameter names with + at the end
*/
protected $paramNamesPath = array();
/**
* @var array HTTP methods supported by this Route
*/
protected $methods = array();
/**
* @var array[Callable] Middleware to be run before only this route instance
*/
protected $middleware = array();
/**
* @var bool Whether or not this route should be matched in a case-sensitive manner
*/
protected $caseSensitive;
/**
* Constructor
* @param string $pattern The URL pattern (e.g. "/books/:id")
* @param mixed $callable Anything that returns TRUE for is_callable()
* @param bool $caseSensitive Whether or not this route should be matched in a case-sensitive manner
*/
public function __construct($pattern, $callable, $caseSensitive = true)
{
$this->setPattern($pattern);
$this->setCallable($callable);
$this->setConditions(self::getDefaultConditions());
$this->caseSensitive = $caseSensitive;
}
/**
* Set default route conditions for all instances
* @param array $defaultConditions
*/
public static function setDefaultConditions(array $defaultConditions)
{
self::$defaultConditions = $defaultConditions;
}
/**
* Get default route conditions for all instances
* @return array
*/
public static function getDefaultConditions()
{
return self::$defaultConditions;
}
/**
* Get route pattern
* @return string
*/
public function getPattern()
{
return $this->pattern;
}
/**
* Set route pattern
* @param string $pattern
*/
public function setPattern($pattern)
{
$this->pattern = $pattern;
}
/**
* Get route callable
* @return mixed
*/
public function getCallable()
{
return $this->callable;
}
/**
* Set route callable
* @param mixed $callable
* @throws \InvalidArgumentException If argument is not callable
*/
public function setCallable($callable)
{
$matches = array();
if (is_string($callable) && preg_match('!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!', $callable, $matches)) {
$class = $matches[1];
$method = $matches[2];
$callable = function() use ($class, $method) {
static $obj = null;
if ($obj === null) {
$obj = new $class;
}
return call_user_func_array(array($obj, $method), func_get_args());
};
}
if (!is_callable($callable)) {
throw new \InvalidArgumentException('Route callable must be callable');
}
$this->callable = $callable;
}
/**
* Get route conditions
* @return array
*/
public function getConditions()
{
return $this->conditions;
}
/**
* Set route conditions
* @param array $conditions
*/
public function setConditions(array $conditions)
{
$this->conditions = $conditions;
}
/**
* Get route name
* @return string|null
*/
public function getName()
{
return $this->name;
}
/**
* Set route name
* @param string $name
*/
public function setName($name)
{
$this->name = (string)$name;
}
/**
* Get route parameters
* @return array
*/
public function getParams()
{
return $this->params;
}
/**
* Set route parameters
* @param array $params
*/
public function setParams($params)
{
$this->params = $params;
}
/**
* Get route parameter value
* @param string $index Name of URL parameter
* @return string
* @throws \InvalidArgumentException If route parameter does not exist at index
*/
public function getParam($index)
{
if (!isset($this->params[$index])) {
throw new \InvalidArgumentException('Route parameter does not exist at specified index');
}
return $this->params[$index];
}
/**
* Set route parameter value
* @param string $index Name of URL parameter
* @param mixed $value The new parameter value
* @throws \InvalidArgumentException If route parameter does not exist at index
*/
public function setParam($index, $value)
{
if (!isset($this->params[$index])) {
throw new \InvalidArgumentException('Route parameter does not exist at specified index');
}
$this->params[$index] = $value;
}
/**
* Add supported HTTP method(s)
*/
public function setHttpMethods()
{
$args = func_get_args();
$this->methods = $args;
}
/**
* Get supported HTTP methods
* @return array
*/
public function getHttpMethods()
{
return $this->methods;
}
/**
* Append supported HTTP methods
*/
public function appendHttpMethods()
{
$args = func_get_args();
$this->methods = array_merge($this->methods, $args);
}
/**
* Append supported HTTP methods (alias for Route::appendHttpMethods)
* @return \Slim\Route
*/
public function via()
{
$args = func_get_args();
$this->methods = array_merge($this->methods, $args);
return $this;
}
/**
* Detect support for an HTTP method
* @param string $method
* @return bool
*/
public function supportsHttpMethod($method)
{
return in_array($method, $this->methods);
}
/**
* Get middleware
* @return array[Callable]
*/
public function getMiddleware()
{
return $this->middleware;
}
/**
* Set middleware
*
* This method allows middleware to be assigned to a specific Route.
* If the method argument `is_callable` (including callable arrays!),
* we directly append the argument to `$this->middleware`. Else, we
* assume the argument is an array of callables and merge the array
* with `$this->middleware`. Each middleware is checked for is_callable()
* and an InvalidArgumentException is thrown immediately if it isn't.
*
* @param Callable|array[Callable]
* @return \Slim\Route
* @throws \InvalidArgumentException If argument is not callable or not an array of callables.
*/
public function setMiddleware($middleware)
{
if (is_callable($middleware)) {
$this->middleware[] = $middleware;
} elseif (is_array($middleware)) {
foreach ($middleware as $callable) {
if (!is_callable($callable)) {
throw new \InvalidArgumentException('All Route middleware must be callable');
}
}
$this->middleware = array_merge($this->middleware, $middleware);
} else {
throw new \InvalidArgumentException('Route middleware must be callable or an array of callables');
}
return $this;
}
/**
* Matches URI?
*
* Parse this route's pattern, and then compare it to an HTTP resource URI
* This method was modeled after the techniques demonstrated by Dan Sosedoff at:
*
* http://blog.sosedoff.com/2009/09/20/rails-like-php-url-router/
*
* @param string $resourceUri A Request URI
* @return bool
*/
public function matches($resourceUri)
{
//Convert URL params into regex patterns, construct a regex for this route, init params
$patternAsRegex = preg_replace_callback(
'#:([\w]+)\+?#',
array($this, 'matchesCallback'),
str_replace(')', ')?', (string)$this->pattern)
);
if (substr($this->pattern, -1) === '/') {
$patternAsRegex .= '?';
}
$regex = '#^' . $patternAsRegex . '$#';
if ($this->caseSensitive === false) {
$regex .= 'i';
}
//Cache URL params' names and values if this route matches the current HTTP request
if (!preg_match($regex, $resourceUri, $paramValues)) {
return false;
}
foreach ($this->paramNames as $name) {
if (isset($paramValues[$name])) {
if (isset($this->paramNamesPath[$name])) {
$this->params[$name] = explode('/', urldecode($paramValues[$name]));
} else {
$this->params[$name] = urldecode($paramValues[$name]);
}
}
}
return true;
}
/**
* Convert a URL parameter (e.g. ":id", ":id+") into a regular expression
* @param array $m URL parameters
* @return string Regular expression for URL parameter
*/
protected function matchesCallback($m)
{
$this->paramNames[] = $m[1];
if (isset($this->conditions[$m[1]])) {
return '(?P<' . $m[1] . '>' . $this->conditions[$m[1]] . ')';
}
if (substr($m[0], -1) === '+') {
$this->paramNamesPath[$m[1]] = 1;
return '(?P<' . $m[1] . '>.+)';
}
return '(?P<' . $m[1] . '>[^/]+)';
}
/**
* Set route name
* @param string $name The name of the route
* @return \Slim\Route
*/
public function name($name)
{
$this->setName($name);
return $this;
}
/**
* Merge route conditions
* @param array $conditions Key-value array of URL parameter conditions
* @return \Slim\Route
*/
public function conditions(array $conditions)
{
$this->conditions = array_merge($this->conditions, $conditions);
return $this;
}
/**
* Dispatch route
*
* This method invokes the route object's callable. If middleware is
* registered for the route, each callable middleware is invoked in
* the order specified.
*
* @return bool
*/
public function dispatch()
{
foreach ($this->middleware as $mw) {
call_user_func_array($mw, array($this));
}
$return = call_user_func_array($this->getCallable(), array_values($this->getParams()));
return ($return === false) ? false : true;
}
}

View File

@ -1,257 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim;
/**
* Router
*
* This class organizes, iterates, and dispatches \Slim\Route objects.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class Router
{
/**
* @var Route The current route (most recently dispatched)
*/
protected $currentRoute;
/**
* @var array Lookup hash of all route objects
*/
protected $routes;
/**
* @var array Lookup hash of named route objects, keyed by route name (lazy-loaded)
*/
protected $namedRoutes;
/**
* @var array Array of route objects that match the request URI (lazy-loaded)
*/
protected $matchedRoutes;
/**
* @var array Array containing all route groups
*/
protected $routeGroups;
/**
* Constructor
*/
public function __construct()
{
$this->routes = array();
$this->routeGroups = array();
}
/**
* Get Current Route object or the first matched one if matching has been performed
* @return \Slim\Route|null
*/
public function getCurrentRoute()
{
if ($this->currentRoute !== null) {
return $this->currentRoute;
}
if (is_array($this->matchedRoutes) && count($this->matchedRoutes) > 0) {
return $this->matchedRoutes[0];
}
return null;
}
/**
* Return route objects that match the given HTTP method and URI
* @param string $httpMethod The HTTP method to match against
* @param string $resourceUri The resource URI to match against
* @param bool $reload Should matching routes be re-parsed?
* @return array[\Slim\Route]
*/
public function getMatchedRoutes($httpMethod, $resourceUri, $reload = false)
{
if ($reload || is_null($this->matchedRoutes)) {
$this->matchedRoutes = array();
foreach ($this->routes as $route) {
if (!$route->supportsHttpMethod($httpMethod) && !$route->supportsHttpMethod("ANY")) {
continue;
}
if ($route->matches($resourceUri)) {
$this->matchedRoutes[] = $route;
}
}
}
return $this->matchedRoutes;
}
/**
* Add a route object to the router
* @param \Slim\Route $route The Slim Route
*/
public function map(\Slim\Route $route)
{
list($groupPattern, $groupMiddleware) = $this->processGroups();
$route->setPattern($groupPattern . $route->getPattern());
$this->routes[] = $route;
foreach ($groupMiddleware as $middleware) {
$route->setMiddleware($middleware);
}
}
/**
* A helper function for processing the group's pattern and middleware
* @return array Returns an array with the elements: pattern, middlewareArr
*/
protected function processGroups()
{
$pattern = "";
$middleware = array();
foreach ($this->routeGroups as $group) {
$k = key($group);
$pattern .= $k;
if (is_array($group[$k])) {
$middleware = array_merge($middleware, $group[$k]);
}
}
return array($pattern, $middleware);
}
/**
* Add a route group to the array
* @param string $group The group pattern (ie. "/books/:id")
* @param array|null $middleware Optional parameter array of middleware
* @return int The index of the new group
*/
public function pushGroup($group, $middleware = array())
{
return array_push($this->routeGroups, array($group => $middleware));
}
/**
* Removes the last route group from the array
* @return bool True if successful, else False
*/
public function popGroup()
{
return (array_pop($this->routeGroups) !== null);
}
/**
* Get URL for named route
* @param string $name The name of the route
* @param array $params Associative array of URL parameter names and replacement values
* @throws \RuntimeException If named route not found
* @return string The URL for the given route populated with provided replacement values
*/
public function urlFor($name, $params = array())
{
if (!$this->hasNamedRoute($name)) {
throw new \RuntimeException('Named route not found for name: ' . $name);
}
$search = array();
foreach ($params as $key => $value) {
$search[] = '#:' . preg_quote($key, '#') . '\+?(?!\w)#';
}
$pattern = preg_replace($search, $params, $this->getNamedRoute($name)->getPattern());
//Remove remnants of unpopulated, trailing optional pattern segments, escaped special characters
return preg_replace('#\(/?:.+\)|\(|\)|\\\\#', '', $pattern);
}
/**
* Add named route
* @param string $name The route name
* @param \Slim\Route $route The route object
* @throws \RuntimeException If a named route already exists with the same name
*/
public function addNamedRoute($name, \Slim\Route $route)
{
if ($this->hasNamedRoute($name)) {
throw new \RuntimeException('Named route already exists with name: ' . $name);
}
$this->namedRoutes[(string) $name] = $route;
}
/**
* Has named route
* @param string $name The route name
* @return bool
*/
public function hasNamedRoute($name)
{
$this->getNamedRoutes();
return isset($this->namedRoutes[(string) $name]);
}
/**
* Get named route
* @param string $name
* @return \Slim\Route|null
*/
public function getNamedRoute($name)
{
$this->getNamedRoutes();
if ($this->hasNamedRoute($name)) {
return $this->namedRoutes[(string) $name];
} else {
return null;
}
}
/**
* Get named routes
* @return \ArrayIterator
*/
public function getNamedRoutes()
{
if (is_null($this->namedRoutes)) {
$this->namedRoutes = array();
foreach ($this->routes as $route) {
if ($route->getName() !== null) {
$this->addNamedRoute($route->getName(), $route);
}
}
}
return new \ArrayIterator($this->namedRoutes);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,282 +0,0 @@
<?php
/**
* Slim - a micro PHP 5 framework
*
* @author Josh Lockhart <info@slimframework.com>
* @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com
* @license http://www.slimframework.com/license
* @version 2.4.2
* @package Slim
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Slim;
/**
* View
*
* The view is responsible for rendering a template. The view
* should subclass \Slim\View and implement this interface:
*
* public render(string $template);
*
* This method should render the specified template and return
* the resultant string.
*
* @package Slim
* @author Josh Lockhart
* @since 1.0.0
*/
class View
{
/**
* Data available to the view templates
* @var \Slim\Helper\Set
*/
protected $data;
/**
* Path to templates base directory (without trailing slash)
* @var string
*/
protected $templatesDirectory;
/**
* Constructor
*/
public function __construct()
{
$this->data = new \Slim\Helper\Set();
}
/********************************************************************************
* Data methods
*******************************************************************************/
/**
* Does view data have value with key?
* @param string $key
* @return boolean
*/
public function has($key)
{
return $this->data->has($key);
}
/**
* Return view data value with key
* @param string $key
* @return mixed
*/
public function get($key)
{
return $this->data->get($key);
}
/**
* Set view data value with key
* @param string $key
* @param mixed $value
*/
public function set($key, $value)
{
$this->data->set($key, $value);
}
/**
* Set view data value as Closure with key
* @param string $key
* @param mixed $value
*/
public function keep($key, Closure $value)
{
$this->data->keep($key, $value);
}
/**
* Return view data
* @return array
*/
public function all()
{
return $this->data->all();
}
/**
* Replace view data
* @param array $data
*/
public function replace(array $data)
{
$this->data->replace($data);
}
/**
* Clear view data
*/
public function clear()
{
$this->data->clear();
}
/********************************************************************************
* Legacy data methods
*******************************************************************************/
/**
* DEPRECATION WARNING! This method will be removed in the next major point release
*
* Get data from view
*/
public function getData($key = null)
{
if (!is_null($key)) {
return isset($this->data[$key]) ? $this->data[$key] : null;
} else {
return $this->data->all();
}
}
/**
* DEPRECATION WARNING! This method will be removed in the next major point release
*
* Set data for view
*/
public function setData()
{
$args = func_get_args();
if (count($args) === 1 && is_array($args[0])) {
$this->data->replace($args[0]);
} elseif (count($args) === 2) {
// Ensure original behavior is maintained. DO NOT invoke stored Closures.
if (is_object($args[1]) && method_exists($args[1], '__invoke')) {
$this->data->set($args[0], $this->data->protect($args[1]));
} else {
$this->data->set($args[0], $args[1]);
}
} else {
throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`');
}
}
/**
* DEPRECATION WARNING! This method will be removed in the next major point release
*
* Append data to view
* @param array $data
*/
public function appendData($data)
{
if (!is_array($data)) {
throw new \InvalidArgumentException('Cannot append view data. Expected array argument.');
}
$this->data->replace($data);
}
/********************************************************************************
* Resolve template paths
*******************************************************************************/
/**
* Set the base directory that contains view templates
* @param string $directory
* @throws \InvalidArgumentException If directory is not a directory
*/
public function setTemplatesDirectory($directory)
{
$this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR);
}
/**
* Get templates base directory
* @return string
*/
public function getTemplatesDirectory()
{
return $this->templatesDirectory;
}
/**
* Get fully qualified path to template file using templates base directory
* @param string $file The template file pathname relative to templates base directory
* @return string
*/
public function getTemplatePathname($file)
{
return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR);
}
/********************************************************************************
* Rendering
*******************************************************************************/
/**
* Display template
*
* This method echoes the rendered template to the current output buffer
*
* @param string $template Pathname of template file relative to templates directory
* @param array $data Any additonal data to be passed to the template.
*/
public function display($template, $data = null)
{
echo $this->fetch($template, $data);
}
/**
* Return the contents of a rendered template file
*
* @param string $template The template pathname, relative to the template base directory
* @param array $data Any additonal data to be passed to the template.
* @return string The rendered template
*/
public function fetch($template, $data = null)
{
return $this->render($template, $data);
}
/**
* Render a template file
*
* NOTE: This method should be overridden by custom view subclasses
*
* @param string $template The template pathname, relative to the template base directory
* @param array $data Any additonal data to be passed to the template.
* @return string The rendered template
* @throws \RuntimeException If resolved template pathname is not a valid file
*/
protected function render($template, $data = null)
{
$templatePathname = $this->getTemplatePathname($template);
if (!is_file($templatePathname)) {
throw new \RuntimeException("View cannot render `$template` because the template does not exist");
}
$data = array_merge($this->data->all(), (array) $data);
extract($data);
ob_start();
require $templatePathname;
return ob_get_clean();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,194 +0,0 @@
<?php
/*************************************************************************************
* diff.php
* --------
* Author: Conny Brunnkvist (conny@fuchsia.se), W. Tasin (tasin@fhm.edu)
* Copyright: (c) 2004 Fuchsia Open Source Solutions (http://www.fuchsia.se/)
* Release Version: 1.0.8.12
* Date Started: 2004/12/29
*
* Diff-output language file for GeSHi.
*
* CHANGES
* -------
* 2008/05/23 (1.0.7.22)
* - Added description of extra language features (SF#1970248)
* 2006/02/27
* - changing language file to use matching of start (^) and end ($) (wt)
* 2004/12/29 (1.0.0)
* - First Release
*
* TODO (updated 2006/02/27)
* -------------------------
*
*
*************************************************************************************
*
* This file is part of GeSHi.
*
* GeSHi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GeSHi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GeSHi; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
************************************************************************************/
$language_data = array (
'LANG_NAME' => 'Diff',
'COMMENT_SINGLE' => array(),
'COMMENT_MULTI' => array(),
'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
'QUOTEMARKS' => array(),
'ESCAPE_CHAR' => ' ',
'KEYWORDS' => array(
1 => array(
'\ No newline at end of file'
),
// 2 => array(
// '***************' /* This only seems to works in some cases? */
// ),
),
'SYMBOLS' => array(
),
'CASE_SENSITIVE' => array(
1 => false,
// 2 => false
),
'STYLES' => array(
'KEYWORDS' => array(
1 => 'color: #aaaaaa; font-style: italic;',
// 2 => 'color: #dd6611;',
),
'COMMENTS' => array(
),
'ESCAPE_CHAR' => array(
0 => ''
),
'BRACKETS' => array(
0 => ''
),
'STRINGS' => array(
0 => ''
),
'NUMBERS' => array(
0 => ''
),
'METHODS' => array(
0 => ''
),
'SYMBOLS' => array(
0 => ''
),
'SCRIPT' => array(
0 => ''
),
'REGEXPS' => array(
0 => 'color: #440088;',
1 => 'color: #991111;',
2 => 'color: #00b000;',
3 => 'color: #888822;',
4 => 'color: #888822;',
5 => 'color: #0011dd;',
6 => 'color: #440088;',
7 => 'color: #991111;',
8 => 'color: #00b000;',
9 => 'color: #888822;',
),
),
'URLS' => array(
1 => '',
// 2 => ''
),
'OOLANG' => false,
'OBJECT_SPLITTERS' => array(),
'REGEXPS' => array(
0 => "[0-9,]+[acd][0-9,]+",
//Removed lines
1 => array(
GESHI_SEARCH => '(^|(?<=\A\s))\\&lt;.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
//Inserted lines
2 => array(
GESHI_SEARCH => '(^|(?<=\A\s))\\&gt;.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
//Location line
3 => array(
GESHI_SEARCH => '(^|(?<=\A\s))-{3}\\s.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
//Inserted line
4 => array(
GESHI_SEARCH => '(^|(?<=\A\s))(\\+){3}\\s.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
//Modified line
5 => array(
GESHI_SEARCH => '(^|(?<=\A\s))\\!.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
//File specification
6 => array(
GESHI_SEARCH => '(^|(?<=\A\s))[\\@]{2}.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
//Removed line
7 => array(
GESHI_SEARCH => '(^|(?<=\A\s))\\-.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
//Inserted line
8 => array(
GESHI_SEARCH => '(^|(?<=\A\s))\\+.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
//File specification
9 => array(
GESHI_SEARCH => '(^|(?<=\A\s))(\\*){3}\\s.*$',
GESHI_REPLACE => '\\0',
GESHI_MODIFIERS => 'm',
GESHI_BEFORE => '',
GESHI_AFTER => ''
),
),
'STRICT_MODE_APPLIES' => GESHI_NEVER,
'SCRIPT_DELIMITERS' => array(
),
'HIGHLIGHT_STRICT_BLOCK' => array(
)
);

View File

@ -1,170 +0,0 @@
<?php
$language_data = array(
'LANG_NAME' => 'IOS',
'COMMENT_SINGLE' => array(1 => '!'),
'CASE_KEYWORDS' => GESHI_CAPS_LOWER,
'OOLANG' => false,
'NUMBERS' => GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX,
'KEYWORDS' => array(
1 => array(
'no',
'shutdown',
),
// 2 => array(
// 'router', 'interface', 'service', 'config-register', 'upgrade', 'version', 'hostname', 'boot-start-marker', 'boot', 'boot-end-marker', 'enable', 'aaa', 'clock', 'ip',
// 'logging', 'access-list', 'route-map', 'snmp-server', 'mpls', 'speed', 'media-type', 'negotiation', 'timestamps', 'prefix-list', 'network', 'mask', 'unsuppress-map',
// 'neighbor', 'remote-as', 'ebgp-multihop', 'update-source', 'description', 'peer-group', 'policy-map', 'class-map', 'class', 'match', 'access-group', 'bandwidth', 'username',
// 'password', 'send-community', 'next-hop-self', 'route-reflector-client', 'ldp', 'discovery', 'advertise-labels', 'label', 'protocol', 'login', 'debug', 'log', 'duplex', 'router-id',
// 'authentication', 'mode', 'maximum-paths', 'address-family', 'set', 'local-preference', 'community', 'trap-source', 'location', 'host', 'tacacs-server', 'session-id',
// 'flow-export', 'destination', 'source', 'in', 'out', 'permit', 'deny', 'control-plane', 'line', 'con' ,'aux', 'vty', 'access-class', 'ntp', 'server', 'end', 'source-interface',
// 'key', 'chain', 'key-string', 'redundancy', 'match-any', 'queue-limit', 'encapsulation', 'pvc', 'vbr-nrt', 'address', 'bundle-enable', 'atm', 'sonet', 'clns', 'route-cache',
// 'default-information', 'redistribute', 'log-adjacency-changes', 'metric', 'spf-interval', 'prc-interval', 'lsp-refresh-interval', 'max-lsp-lifetime', 'set-overload-bit',
// 'on-startup', 'wait-for-bgp', 'system', 'flash', 'timezone', 'subnet-zero', 'cef', 'flow-cache', 'timeout', 'active', 'domain', 'lookup', 'dhcp', 'use', 'vrf', 'hello', 'interval',
// 'priority', 'ilmi-keepalive', 'buffered', 'debugging', 'fpd', 'secret', 'accounting', 'exec', 'group', 'local', 'recurring', 'source-route', 'call', 'rsvp-sync', 'scripting',
// 'mtu', 'passive-interface', 'area' , 'distribute-list', 'metric-style', 'is-type', 'originate', 'activate', 'both', 'auto-summary', 'synchronization', 'aggregate-address', 'le', 'ge',
// 'bgp-community', 'route', 'exit-address-family', 'standard', 'file', 'verify', 'domain-name', 'domain-lookup', 'route-target', 'export', 'import', 'map', 'rd', 'mfib', 'vtp', 'mls',
// 'hardware-switching', 'replication-mode', 'ingress', 'flow', 'error', 'action', 'slb', 'purge', 'share-global', 'routing', 'traffic-eng', 'tunnels', 'propagate-ttl', 'switchport', 'vlan',
// 'portfast', 'counters', 'max', 'age', 'ethernet', 'evc', 'uni', 'count', 'oam', 'lmi', 'gmt', 'netflow', 'pseudowire-class', 'spanning-tree', 'name', 'circuit-type'
// ),
// 3 => array(
// 'isis', 'ospf', 'eigrp', 'rip', 'igrp', 'bgp', 'ipv4', 'unicast', 'multicast', 'ipv6', 'connected', 'static', 'subnets', 'tcl'
// ),
// 4 => array(
// 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide',
// 'level-1', 'level-2', 'log-neighbor-changes', 'directed-request', 'password-encryption', 'common', 'origin-as', 'bgp-nexthop', 'random-detect', 'localtime', 'sso', 'stm-1',
// 'dot1q', 'isl', 'new-model', 'always', 'summary-only', 'freeze', 'global', 'forwarded', 'access', 'trunk', 'edge', 'transparent'
// ),
),
'REGEXPS' => array(
1 => array(
GESHI_SEARCH => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})',
GESHI_REPLACE => '\\1',
GESHI_BEFORE => '',
),
2 => array(
GESHI_SEARCH => '(255\.\d{1,3}\.\d{1,3}\.\d{1,3})',
GESHI_REPLACE => '\\1',
GESHI_BEFORE => '',
),
3 => array(
GESHI_SEARCH => '(source|interface|update-source|router-id) ([A-Za-z0-9\/\:\-\.]+)',
GESHI_REPLACE => '\\2',
GESHI_BEFORE => '\\1 ',
),
4 => array(
GESHI_SEARCH => '(neighbor) ([\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}]+|[a-zA-Z0-9\-\_]+)',
GESHI_REPLACE => '\\2',
GESHI_BEFORE => '\\1 ',
),
5 => array(
GESHI_SEARCH => '(distribute-map|access-group|policy-map|class-map\ match-any|ip\ access-list\ extended|match\ community|community-list\ standard|community-list\ expanded|ip\ access-list\ standard|router\ bgp|remote-as|key\ chain|service-policy\ input|service-policy\ output|class|login\ authentication|authentication\ key-chain|username|import\ map|export\ map|domain-name|hostname|route-map|access-class|ip\ vrf\ forwarding|ip\ vrf|vtp\ domain|name|pseudowire-class|pw-class|prefix-list|vrf) ([A-Za-z0-9\-\_\.]+)',
GESHI_REPLACE => '\\2',
GESHI_BEFORE => '\\1 ',
),
6 => array(
GESHI_SEARCH => '(password|key-string|key) ([0-9]) (.+)',
GESHI_REPLACE => '\\2 \\3',
GESHI_BEFORE => '\\1 ',
),
7 => array(
GESHI_SEARCH => '(enable) ([a-z]+) ([0-9]) (.+)',
GESHI_REPLACE => '\\3 \\4',
GESHI_BEFORE => '\\1 \\2 ',
),
8 => array(
GESHI_SEARCH => '(description|location|contact|remark) (.+)',
GESHI_REPLACE => '\\2',
GESHI_BEFORE => '\\1 ',
),
9 => array(
GESHI_SEARCH => '([0-9\.\_\*]+\:[0-9\.\_\*]+)',
GESHI_REPLACE => '\\1',
),
10 => array(
GESHI_SEARCH => '(boot) ([a-z]+) (.+)',
GESHI_REPLACE => '\\3',
GESHI_BEFORE => '\\1 \\2 ',
),
11 => array(
GESHI_SEARCH => '(net) ([0-9a-z\.]+)',
GESHI_REPLACE => '\\2',
GESHI_BEFORE => '\\1 ',
),
12 => array(
GESHI_SEARCH => '(access-list|RO|RW) ([0-9]+)',
GESHI_REPLACE => '\\2',
GESHI_BEFORE => '\\1 ',
),
13 => array(
GESHI_SEARCH => '(vlan) ([0-9]+)',
GESHI_REPLACE => '\\2',
GESHI_BEFORE => '\\1 ',
),
14 => array(
GESHI_SEARCH => '(encapsulation|speed|duplex|mtu|metric|media-type|negotiation|transport\ input|bgp-community|set\ as-path\ prepend|maximum-prefix|version|local-preference|continue|redistribute|cluster-id|vtp\ mode|label\ protocol|spanning-tree\ mode) (.+)',
GESHI_REPLACE => '\\2',
GESHI_BEFORE => '\\1 ',
),
),
'STYLES' => array(
'REGEXPS' => array(
0 => 'color: #ff0000;',
1 => 'color: #0000cc;',
// x.x.x.x
2 => 'color: #000099; font-style: italic',
// 255.x.x.x
3 => 'color: #000000; font-weight: bold; font-style: italic;',
// interface xxx
4 => 'color: #ff0000;',
// neighbor x.x.x.x
5 => 'color: #000099;',
// variable names
6 => 'color: #cc0000;',
7 => 'color: #cc0000;',
// passwords
8 => 'color: #555555;',
// description
9 => 'color: #990099;',
// communities
10 => 'color: #cc0000; font-style: italic;',
// no/shut
11 => 'color: #000099;',
// net numbers
12 => 'color: #000099;',
// acls
13 => 'color: #000099;',
// acls
14 => 'color: #990099;',
// warnings
),
'KEYWORDS' => array(
1 => 'color: #cc0000; font-weight: bold;',
// no/shut
2 => 'color: #000000;',
// commands
3 => 'color: #000000; font-weight: bold;',
// proto/service
4 => 'color: #000000;',
// options
5 => 'color: #ff0000;',
),
'COMMENTS' => array(1 => 'color: #808080; font-style: italic;'),
'ESCAPE_CHAR' => array(0 => 'color: #000099; font-weight: bold;'),
'BRACKETS' => array(0 => 'color: #66cc66;'),
'STRINGS' => array(0 => 'color: #ff0000;'),
'NUMBERS' => array(0 => 'color: #cc0000;'),
'METHODS' => array(0 => 'color: #006600;'),
'SYMBOLS' => array(0 => 'color: #66cc66;'),
'SCRIPT' => array(
0 => '',
1 => '',
2 => '',
3 => '',
),
),
);

View File

@ -1,802 +0,0 @@
<?php
require_once '../jpgraph.php';
require_once '../jpgraph_canvas.php';
require_once '../jpgraph_canvtools.php';
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of test_findpolygon
*
* @author ljp
*/
class Findpolygon {
private $nbrContours=-1;
public $contourCoord=array();
private $scale = array(0,6,0,8);
function flattenEdges($p) {
$fp=array();
for ($i = 0 ; $i < count($p) ; $i++) {
$fp[] = $p[$i][0];
$fp[] = $p[$i][1];
}
return $fp;
}
function SetupTestData() {
// for($i=0; $i<count($this->contourCoord[0]); ++$i) {
// echo '('.$this->contourCoord[0][$i][0][0].','.$this->contourCoord[0][$i][0][1].') -> '.
// '('.$this->contourCoord[0][$i][1][0].','.$this->contourCoord[0][$i][1][1].")\n";
// }
//
$c=0;
$p[$c] = array(0.6,1, 1,0.5, 2,0.5, 3,0.5, 3.5,1, 3.5,2, 3,2.5, 2,2.5, 1,2.5, 0.5,2, 0.6,1);
$c++;
$p[$c] = array(6,0.5, 5.5,1, 5.5,2, 6,2.5);
$this->nbrContours = $c+1;
for ($c = 0 ; $c < count($p) ; $c++) {
$n=count($p[$c]);
$this->contourCoord[$c][0] = array(array($p[$c][0],$p[$c][1]),array($p[$c][2],$p[$c][3]));
$k=1;
for ($i = 0; $i < ($n-4)/2; $i++, $k++) {
$this->contourCoord[$c][$k] = array($this->contourCoord[$c][$k-1][1], array($p[$c][2*$k+2],$p[$c][2*$k+1+2]));
}
// Swap edges order at random
$n = count($this->contourCoord[$c]);
for($i=0; $i < floor($n/2); ++$i) {
$swap1 = rand(0,$n-1);
$t = $this->contourCoord[$c][$swap1];
while( $swap1 == ($swap2 = rand(0,$n-1)) )
;
$this->contourCoord[$c][$swap1] = $this->contourCoord[$c][$swap2];
$this->contourCoord[$c][$swap2] = $t;
}
// Swap vector direction on 1/3 of the edges
for ($i = 0 ; $i < floor(count($this->contourCoord[$c])/3) ; $i++) {
$e = rand(0, count($this->contourCoord[$c])-1);
$edge = $this->contourCoord[$c][$e];
$v1 = $edge[0]; $v2 = $edge[1];
$this->contourCoord[$c][$e][0] = $v2;
$this->contourCoord[$c][$e][1] = $v1;
}
}
$pp = array();
for($j=0; $j < count($p); ++$j ) {
for( $i=0; $i < count($p[$j])/2; ++$i ) {
$pp[$j][$i] = array($p[$j][2*$i],$p[$j][2*$i+1]);
}
}
return $pp;
}
function p_edges($v) {
for ($i = 0 ; $i < count($v) ; $i++) {
echo "(".$v[$i][0][0].",".$v[$i][0][1].") -> (".$v[$i][1][0].",".$v[$i][1][1].")\n";
}
echo "\n";
}
function CompareCyclic($a,$b,$forward=true) {
// We assume disjoint vertices and if last==first this just means
// that the polygon is closed. For this comparison it must be unique
// elements
if( $a[count($a)-1] == $a[0] ) {
array_pop($a);
}
if( $b[count($b)-1] == $b[0] ) {
array_pop($b);
}
$n1 = count($a);
$n2 = count($b);
if( $n1 != $n2 ) {
return false;
}
$i=0;
while( ($i < $n2) && ($a[0] != $b[$i]) ) {
++$i;
}
if( $i >= $n2 ) {
return false;
}
$j=0;
if( $forward ) {
while( ($j < $n1) && ($a[$j] == $b[$i]) ) {
$i = ($i + 1) % $n2;
++$j;
}
}
else {
while( ($j < $n1) && ($a[$j] == $b[$i]) ) {
--$i;
if( $i < 0 ) {
$i = $n2-1;
}
++$j;
}
}
return $j >= $n1;
}
function dbg($s) {
// echo $s."\n";
}
function IsVerticeOnBorder($x1,$y1) {
// Check if the vertice lies on any of the four border
if( $x1==$this->scale[0] || $x1==$this->scale[1] ) {
return true;
}
if( $y1==$this->scale[2] || $y1==$this->scale[3] ) {
return true;
}
return false;
}
function FindPolygons($debug=false) {
$pol = 0;
for ($c = 0; $c < $this->nbrContours; $c++) {
$this->dbg("\n** Searching polygon chain $c ... ");
$this->dbg("------------------------------------------\n");
$edges = $this->contourCoord[$c];
while( count($edges) > 0 ) {
$edge = array_shift($edges);
list($x1,$y1) = $edge[0];
list($x2,$y2) = $edge[1];
$polygons[$pol]=array(
array($x1,$y1),array($x2,$y2)
);
$this->dbg("Searching on second vertice.");
$found=false;
if( ! $this->IsVerticeOnBorder($x2,$y2) ) {
do {
$this->dbg(" --Searching on edge: ($x1,$y1)->($x2,$y2)");
$found=false;
$nn = count($edges);
for( $i=0; $i < $nn && !$found; ++$i ) {
$edge = $edges[$i];
if( $found = ($x2==$edge[0][0] && $y2==$edge[0][1]) ) {
$polygons[$pol][] = array($edge[1][0],$edge[1][1]);
$x1 = $x2; $y1 = $y2;
$x2 = $edge[1][0]; $y2 = $edge[1][1];
}
elseif( $found = ($x2==$edge[1][0] && $y2==$edge[1][1]) ) {
$polygons[$pol][] = array($edge[0][0],$edge[0][1]);
$x1 = $x2; $y1 = $y2;
$x2 = $edge[0][0]; $y2 = $edge[0][1];
}
if( $found ) {
$this->dbg(" --Found next edge: [i=$i], (%,%) -> ($x2,$y2)");
unset($edges[$i]);
$edges = array_values($edges);
}
}
} while( $found );
}
if( !$found && count($edges)>0 ) {
$this->dbg("Searching on first vertice.");
list($x1,$y1) = $polygons[$pol][0];
list($x2,$y2) = $polygons[$pol][1];
if( ! $this->IsVerticeOnBorder($x1,$y1) ) {
do {
$this->dbg(" --Searching on edge: ($x1,$y1)->($x2,$y2)");
$found=false;
$nn = count($edges);
for( $i=0; $i < $nn && !$found; ++$i ) {
$edge = $edges[$i];
if( $found = ($x1==$edge[0][0] && $y1==$edge[0][1]) ) {
array_unshift($polygons[$pol],array($edge[1][0],$edge[1][1]));
$x2 = $x1; $y2 = $y1;
$x1 = $edge[1][0]; $y1 = $edge[1][1];
}
elseif( $found = ($x1==$edge[1][0] && $y1==$edge[1][1]) ) {
array_unshift($polygons[$pol],array($edge[0][0],$edge[0][1]));
$x2 = $x1; $y2 = $y1;
$x1 = $edge[0][0]; $y1 = $edge[0][1];
}
if( $found ) {
$this->dbg(" --Found next edge: [i=$i], ($x1,$y1) -> (%,%)");
unset($edges[$i]);
$edges = array_values($edges);
}
}
} while( $found );
}
}
$pol++;
}
}
return $polygons;
}
}
define('HORIZ_EDGE',0);
define('VERT_EDGE',1);
class FillGridRect {
private $edges,$dataPoints,$colors,$isoBars;
private $invert=false;
function __construct(&$edges,&$dataPoints,$isoBars,$colors) {
$this->edges = $edges;
$this->dataPoints = $dataPoints;
$this->colors = $colors;
$this->isoBars = $isoBars;
}
function GetIsobarColor($val) {
for ($i = 0 ; $i < count($this->isoBars) ; $i++) {
if( $val <= $this->isoBars[$i] ) {
return $this->colors[$i];
}
}
return $this->colors[$i]; // The color for all values above the highest isobar
}
function GetIsobarVal($a,$b) {
// Get the isobar that is between the values a and b
// If there are more isobars then return the one with lowest index
if( $b < $a ) {
$t=$a; $a=$b; $b=$t;
}
$i = 0 ;
$n = count($this->isoBars);
while( $i < $n && $this->isoBars[$i] < $a ) {
++$i;
}
if( $i >= $n )
die("Internal error. Cannot find isobar values for ($a,$b)");
return $this->isoBars[$i];
}
function getCrossingCoord($aRow,$aCol,$aEdgeDir,$aIsobarVal) {
// In order to avoid numerical problem when two vertices are very close
// we have to check and avoid dividing by close to zero denumerator.
if( $aEdgeDir == HORIZ_EDGE ) {
$d = abs($this->dataPoints[$aRow][$aCol] - $this->dataPoints[$aRow][$aCol+1]);
if( $d > 0.001 ) {
$xcoord = $aCol + abs($aIsobarVal - $this->dataPoints[$aRow][$aCol]) / $d;
}
else {
$xcoord = $aCol;
}
$ycoord = $aRow;
}
else {
$d = abs($this->dataPoints[$aRow][$aCol] - $this->dataPoints[$aRow+1][$aCol]);
if( $d > 0.001 ) {
$ycoord = $aRow + abs($aIsobarVal - $this->dataPoints[$aRow][$aCol]) / $d;
}
else {
$ycoord = $aRow;
}
$xcoord = $aCol;
}
if( $this->invert ) {
$ycoord = $this->nbrRows-1 - $ycoord;
}
return array($xcoord,$ycoord);
}
function Fill(ContCanvas $canvas) {
$nx_vertices = count($this->dataPoints[0]);
$ny_vertices = count($this->dataPoints);
// Loop through all squares in the grid
for($col=0; $col < $nx_vertices-1; ++$col) {
for($row=0; $row < $ny_vertices-1; ++$row) {
$n = 0;$quad_edges=array();
if ( $this->edges[VERT_EDGE][$row][$col] ) $quad_edges[$n++] = array($row, $col, VERT_EDGE);
if ( $this->edges[VERT_EDGE][$row][$col+1] ) $quad_edges[$n++] = array($row, $col+1,VERT_EDGE);
if ( $this->edges[HORIZ_EDGE][$row][$col] ) $quad_edges[$n++] = array($row, $col, HORIZ_EDGE);
if ( $this->edges[HORIZ_EDGE][$row+1][$col] ) $quad_edges[$n++] = array($row+1,$col, HORIZ_EDGE);
if( $n == 0 ) {
// Easy, fill the entire quadrant with one color since we have no crossings
// Select the top left datapoint as representing this quadrant
// color for this quadrant
$color = $this->GetIsobarColor($this->dataPoints[$row][$col]);
$polygon = array($col,$row,$col,$row+1,$col+1,$row+1,$col+1,$row,$col,$row);
$canvas->FilledPolygon($polygon,$color);
} elseif( $n==2 ) {
// There is one isobar edge crossing this quadrant. In order to fill we need to
// find out the orientation of the two areas this edge is separating in order to
// construct the two polygons that define the two areas to be filled
// There are six possible variants
// 0) North-South
// 1) West-East
// 2) West-North
// 3) East-North
// 4) West-South
// 5) East-South
$type=-1;
if( $this->edges[HORIZ_EDGE][$row][$col] ) {
if( $this->edges[HORIZ_EDGE][$row+1][$col] ) $type=0; // North-South
elseif( $this->edges[VERT_EDGE][$row][$col] ) $type=2;
elseif( $this->edges[VERT_EDGE][$row][$col+1] ) $type=3;
}
elseif( $this->edges[HORIZ_EDGE][$row+1][$col] ) {
if( $this->edges[VERT_EDGE][$row][$col] ) $type=4;
elseif( $this->edges[VERT_EDGE][$row][$col+1] ) $type=5;
}
else {
$type=1;
}
if( $type==-1 ) {
die('Internal error: n=2 but no edges in the quadrant was find to determine type.');
}
switch( $type ) {
case 0: //North-South
// North vertice
$v1 = $this->dataPoints[$row][$col];
$v2 = $this->dataPoints[$row][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x1,$y1) = $this->getCrossingCoord($row, $col,HORIZ_EDGE, $isobarValue);
// South vertice
$v1 = $this->dataPoints[$row+1][$col];
$v2 = $this->dataPoints[$row+1][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x2,$y2) = $this->getCrossingCoord($row+1, $col,HORIZ_EDGE, $isobarValue);
$polygon = array($col,$row,$x1,$y1,$x2,$y2,$col,$row+1,$col,$row);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v1));
$polygon = array($col+1,$row,$x1,$y1,$x2,$y2,$col+1,$row+1,$col+1,$row);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v2));
break;
case 1: // West-East
// West vertice
$v1 = $this->dataPoints[$row][$col];
$v2 = $this->dataPoints[$row+1][$col];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x1,$y1) = $this->getCrossingCoord($row, $col,VERT_EDGE, $isobarValue);
// East vertice
$v1 = $this->dataPoints[$row][$col+1];
$v2 = $this->dataPoints[$row+1][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x2,$y2) = $this->getCrossingCoord($row, $col+1,VERT_EDGE, $isobarValue);
$polygon = array($col,$row,$x1,$y1,$x2,$y2,$col+1,$row,$col,$row);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v1));
$polygon = array($col,$row+1,$x1,$y1,$x2,$y2,$col+1,$row+1,$col,$row+1);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v2));
break;
case 2: // West-North
// West vertice
$v1 = $this->dataPoints[$row][$col];
$v2 = $this->dataPoints[$row+1][$col];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x1,$y1) = $this->getCrossingCoord($row, $col,VERT_EDGE, $isobarValue);
// North vertice
$v1 = $this->dataPoints[$row][$col];
$v2 = $this->dataPoints[$row][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x2,$y2) = $this->getCrossingCoord($row, $col,HORIZ_EDGE, $isobarValue);
$polygon = array($col,$row,$x1,$y1,$x2,$y2,$col,$row);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v1));
$polygon = array($x1,$y1,$x2,$y2,$col+1,$row,$col+1,$row+1,$col,$row+1,$x1,$y1);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v2));
break;
case 3: // East-North
// if( $row==3 && $col==1 && $n==2 ) {
// echo " ** East-North<br>";
// }
// East vertice
$v1 = $this->dataPoints[$row][$col+1];
$v2 = $this->dataPoints[$row+1][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x1,$y1) = $this->getCrossingCoord($row, $col+1,VERT_EDGE, $isobarValue);
//
// if( $row==3 && $col==1 && $n==2 ) {
// echo " ** E_val($v1,$v2), isobar=$isobarValue<br>";
// echo " ** E($x1,$y1)<br>";
// }
// North vertice
$v1 = $this->dataPoints[$row][$col];
$v2 = $this->dataPoints[$row][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x2,$y2) = $this->getCrossingCoord($row, $col,HORIZ_EDGE, $isobarValue);
// if( $row==3 && $col==1 && $n==2 ) {
// echo " ** N_val($v1,$v2), isobar=$isobarValue<br>";
// echo " ** N($x2,$y2)<br>";
// }
// if( $row==3 && $col==1 && $n==2 )
// $canvas->Line($x1,$y1,$x2,$y2,'blue');
$polygon = array($x1,$y1,$x2,$y2,$col+1,$row,$x1,$y1);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v2));
$polygon = array($col,$row,$x2,$y2,$x1,$y1,$col+1,$row+1,$col,$row+1,$col,$row);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v1));
break;
case 4: // West-South
// West vertice
$v1 = $this->dataPoints[$row][$col];
$v2 = $this->dataPoints[$row+1][$col];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x1,$y1) = $this->getCrossingCoord($row, $col,VERT_EDGE, $isobarValue);
// South vertice
$v1 = $this->dataPoints[$row+1][$col];
$v2 = $this->dataPoints[$row+1][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x2,$y2) = $this->getCrossingCoord($row+1, $col,HORIZ_EDGE, $isobarValue);
$polygon = array($col,$row+1,$x1,$y1,$x2,$y2,$col,$row+1);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v1));
$polygon = array($x1,$y1,$x2,$y2,$col+1,$row+1,$col+1,$row,$col,$row,$x1,$y1);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v2));
break;
case 5: // East-South
//
// if( $row==1 && $col==1 && $n==2 ) {
// echo " ** Sout-East<br>";
// }
// East vertice
$v1 = $this->dataPoints[$row][$col+1];
$v2 = $this->dataPoints[$row+1][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x1,$y1) = $this->getCrossingCoord($row, $col+1,VERT_EDGE, $isobarValue);
// if( $row==1 && $col==1 && $n==2 ) {
// echo " ** E_val($v1,$v2), isobar=$isobarValue<br>";
// echo " ** E($x1,$y1)<br>";
// }
// South vertice
$v1 = $this->dataPoints[$row+1][$col];
$v2 = $this->dataPoints[$row+1][$col+1];
$isobarValue = $this->GetIsobarVal($v1, $v2);
list($x2,$y2) = $this->getCrossingCoord($row+1, $col,HORIZ_EDGE, $isobarValue);
// if( $row==1 && $col==1 && $n==2 ) {
// echo " ** S_val($v1,$v2), isobar=$isobarValue<br>";
// echo " ** S($x2,$y2)<br>";
// }
$polygon = array($col+1,$row+1,$x1,$y1,$x2,$y2,$col+1,$row+1);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v2));
$polygon = array($x1,$y1,$x2,$y2,$col,$row+1,$col,$row,$col+1,$row,$x1,$y1);
$canvas->FilledPolygon($polygon,$this->GetIsobarColor($v1));
break;
}
}
}
}
}
}
class ContCanvas {
public $g;
public $shape,$scale;
function __construct($xmax=6,$ymax=6,$width=400,$height=400) {
$this->g = new CanvasGraph($width,$height);
$this->scale = new CanvasScale($this->g, 0, $xmax, 0, $ymax);
$this->shape = new Shape($this->g, $this->scale);
//$this->g->SetFrame(true);
$this->g->SetMargin(5,5,5,5);
$this->g->SetMarginColor('white@1');
$this->g->InitFrame();
$this->shape->SetColor('gray');
for( $col=1; $col<$xmax; ++$col ) {
$this->shape->Line($col, 0, $col, $ymax);
}
for( $row=1; $row<$ymax; ++$row ) {
$this->shape->Line(0, $row, $xmax, $row);
}
}
function SetDatapoints($datapoints) {
$ny=count($datapoints);
$nx=count($datapoints[0]);
$t = new Text();
$t->SetFont(FF_ARIAL,FS_NORMAL,8);
for( $x=0; $x < $nx; ++$x ) {
for( $y=0; $y < $ny; ++$y ) {
list($x1,$y1) = $this->scale->Translate($x,$y);
if( $datapoints[$y][$x] > 0 )
$t->SetColor('blue');
else
$t->SetColor('black');
$t->SetFont(FF_ARIAL,FS_BOLD,8);
$t->Set($datapoints[$y][$x]);
$t->Stroke($this->g->img,$x1,$y1);
$t->SetColor('gray');
$t->SetFont(FF_ARIAL,FS_NORMAL,8);
$t->Set("($y,$x)");
$t->Stroke($this->g->img,$x1+10,$y1);
}
}
}
function DrawLinePolygons($p,$color='red') {
$this->shape->SetColor($color);
for ($i = 0 ; $i < count($p) ; $i++) {
$x1 = $p[$i][0][0]; $y1 = $p[$i][0][1];
for ($j = 1 ; $j < count($p[$i]) ; $j++) {
$x2=$p[$i][$j][0]; $y2 = $p[$i][$j][1];
$this->shape->Line($x1, $y1, $x2, $y2);
$x1=$x2; $y1=$y2;
}
}
}
function Line($x1,$y1,$x2,$y2,$color='red') {
$this->shape->SetColor($color);
$this->shape->Line($x1, $y1, $x2, $y2);
}
function Polygon($p,$color='blue') {
$this->shape->SetColor($color);
$this->shape->Polygon($p);
}
function FilledPolygon($p,$color='lightblue') {
$this->shape->SetColor($color);
$this->shape->FilledPolygon($p);
}
function Point($x,$y,$color) {
list($x1,$y1) = $this->scale->Translate($x, $y);
$this->shape->SetColor($color);
$this->g->img->Point($x1,$y1);
}
function Stroke() {
$this->g->Stroke();
}
}
class PixelFill {
private $edges,$dataPoints,$colors,$isoBars;
function __construct(&$edges,&$dataPoints,$isoBars,$colors) {
$this->edges = $edges;
$this->dataPoints = $dataPoints;
$this->colors = $colors;
$this->isoBars = $isoBars;
}
function GetIsobarColor($val) {
for ($i = 0 ; $i < count($this->isoBars) ; $i++) {
if( $val <= $this->isoBars[$i] ) {
return $this->colors[$i];
}
}
return $this->colors[$i]; // The color for all values above the highest isobar
}
function Fill(ContCanvas $canvas) {
$nx_vertices = count($this->dataPoints[0]);
$ny_vertices = count($this->dataPoints);
// Loop through all squares in the grid
for($col=0; $col < $nx_vertices-1; ++$col) {
for($row=0; $row < $ny_vertices-1; ++$row) {
$v=array(
$this->dataPoints[$row][$col],
$this->dataPoints[$row][$col+1],
$this->dataPoints[$row+1][$col+1],
$this->dataPoints[$row+1][$col],
);
list($x1,$y1) = $canvas->scale->Translate($col, $row);
list($x2,$y2) = $canvas->scale->Translate($col+1, $row+1);
for( $x=$x1; $x < $x2; ++$x ) {
for( $y=$y1; $y < $y2; ++$y ) {
$v1 = $v[0] + ($v[1]-$v[0])*($x-$x1)/($x2-$x1);
$v2 = $v[3] + ($v[2]-$v[3])*($x-$x1)/($x2-$x1);
$val = $v1 + ($v2-$v1)*($y-$y1)/($y2-$y1);
if( $row==2 && $col==2 ) {
//echo " ($val ($x,$y)) (".$v[0].",".$v[1].",".$v[2].",".$v[3].")<br>";
}
$color = $this->GetIsobarColor($val);
$canvas->g->img->SetColor($color);
$canvas->g->img->Point($x, $y);
}
}
}
}
}
}
$edges=array(array(),array(),array());
$datapoints=array();
for($col=0; $col<6; $col++) {
for($row=0; $row<6; $row++) {
$datapoints[$row][$col]=0;
$edges[VERT_EDGE][$row][$col] = false;
$edges[HORIZ_EDGE][$row][$col] = false;
}
}
$datapoints[1][2] = 2;
$datapoints[2][1] = 1;
$datapoints[2][2] = 7;
$datapoints[2][3] = 2;
$datapoints[3][1] = 2;
$datapoints[3][2] = 17;
$datapoints[3][3] = 4;
$datapoints[4][2] = 3;
$datapoints[1][4] = 12;
$edges[VERT_EDGE][1][2] = true;
$edges[VERT_EDGE][3][2] = true;
$edges[HORIZ_EDGE][2][1] = true;
$edges[HORIZ_EDGE][2][2] = true;
$edges[HORIZ_EDGE][3][1] = true;
$edges[HORIZ_EDGE][3][2] = true;
$isobars = array(5,10,15);
$colors = array('lightgray','lightblue','lightred','red');
$engine = new PixelFill($edges, $datapoints, $isobars, $colors);
$canvas = new ContCanvas();
$engine->Fill($canvas);
$canvas->SetDatapoints($datapoints);
$canvas->Stroke();
die();
//$tst = new Findpolygon();
//$p1 = $tst->SetupTestData();
//
//$canvas = new ContCanvas();
//for ($i = 0 ; $i < count($tst->contourCoord); $i++) {
// $canvas->DrawLinePolygons($tst->contourCoord[$i]);
//}
//
//$p2 = $tst->FindPolygons();
//for ($i = 0 ; $i < count($p2) ; $i++) {
// $canvas->FilledPolygon($tst->flattenEdges($p2[$i]));
//}
//
//for ($i = 0 ; $i < count($p2) ; $i++) {
// $canvas->Polygon($tst->flattenEdges($p2[$i]));
//}
//
//$canvas->Stroke();
//die();
//for( $trial = 0; $trial < 1; ++$trial ) {
// echo "\nTest $trial:\n";
// echo "========================================\n";
// $tst = new Findpolygon();
// $p1 = $tst->SetupTestData();
//
// // for ($i = 0 ; $i < count($p1) ; $i++) {
// // echo "Test polygon $i:\n";
// // echo "---------------------\n";
// // $tst->p_edges($tst->contourCoord[$i]);
// // echo "\n";
// // }
// //
// $p2 = $tst->FindPolygons();
// $npol = count($p2);
// //echo "\n** Found $npol separate polygon chains.\n\n";
//
// for( $i=0; $i<$npol; ++$i ) {
//
// $res_forward = $tst->CompareCyclic($p1[$i], $p2[$i],true);
// $res_backward = $tst->CompareCyclic($p1[$i], $p2[$i],false);
// if( $res_backward || $res_forward ) {
// // if( $res_forward )
// // echo "Forward matches!\n";
// // else
// // echo "Backward matches!\n";
// }
// else {
// echo "********** NO MATCH!!.\n\n";
// echo "\nBefore find:\n";
// for ($j = 0 ; $j < count($p1[$i]) ; $j++) {
// echo "(".$p1[$i][$j][0].','.$p1[$i][$j][1]."), ";
// }
// echo "\n";
//
// echo "\nAfter find:\n";
// for ($j = 0 ; $j < count($p2[$i]) ; $j++) {
// echo "(".$p2[$i][$j][0].','.$p2[$i][$j][1]."), ";
// }
// echo "\n";
// }
//
// }
//}
//
//echo "\n\nAll tests ready.\n\n";
//
?>

View File

@ -1,800 +0,0 @@
<?php
require_once '../jpgraph.php';
require_once '../jpgraph_canvas.php';
require_once '../jpgraph_canvtools.php';
class ContCanvas {
public $g;
public $shape,$scale;
function __construct($xmax=5,$ymax=5,$width=350,$height=350) {
$this->g = new CanvasGraph($width,$height);
$this->scale = new CanvasScale($this->g, 0, $xmax, 0, $ymax);
$this->shape = new Shape($this->g, $this->scale);
//$this->g->SetFrame(true);
$this->g->SetMargin(2,2,2,2);
$this->g->SetMarginColor('white@1');
$this->g->InitFrame();
}
function StrokeGrid() {
list($xmin,$xmax,$ymin,$ymax) = $this->scale->Get();
$this->shape->SetColor('gray');
for( $col=1; $col<$xmax; ++$col ) {
$this->shape->Line($col, 0, $col, $ymax);
}
for( $row=1; $row<$ymax; ++$row ) {
$this->shape->Line(0, $row, $xmax, $row);
}
}
function SetDatapoints($datapoints) {
$ny=count($datapoints);
$nx=count($datapoints[0]);
$t = new Text();
$t->SetFont(FF_ARIAL,FS_NORMAL,8);
for( $x=0; $x < $nx; ++$x ) {
for( $y=0; $y < $ny; ++$y ) {
list($x1,$y1) = $this->scale->Translate($x,$y);
if( $datapoints[$y][$x] > 0 )
$t->SetColor('blue');
else
$t->SetColor('black');
$t->SetFont(FF_ARIAL,FS_BOLD,8);
$t->Set($datapoints[$y][$x]);
$t->Stroke($this->g->img,$x1,$y1);
$t->SetColor('gray');
$t->SetFont(FF_ARIAL,FS_NORMAL,8);
$t->Set("($y,$x)");
$t->Stroke($this->g->img,$x1+10,$y1);
}
}
}
function DrawLinePolygons($p,$color='red') {
$this->shape->SetColor($color);
for ($i = 0 ; $i < count($p) ; $i++) {
$x1 = $p[$i][0][0];
$y1 = $p[$i][0][1];
for ($j = 1 ; $j < count($p[$i]) ; $j++) {
$x2=$p[$i][$j][0];
$y2 = $p[$i][$j][1];
$this->shape->Line($x1, $y1, $x2, $y2);
$x1=$x2;
$y1=$y2;
}
}
}
function Line($x1,$y1,$x2,$y2,$color='red') {
$this->shape->SetColor($color);
$this->shape->Line($x1, $y1, $x2, $y2);
}
function Polygon($p,$color='blue') {
$this->shape->SetColor($color);
$this->shape->Polygon($p);
}
function FilledPolygon($p,$color='lightblue') {
$this->shape->SetColor($color);
$this->shape->FilledPolygon($p);
}
function Point($x,$y,$color) {
list($x1,$y1) = $this->scale->Translate($x, $y);
$this->shape->SetColor($color);
$this->g->img->Point($x1,$y1);
}
function Stroke() {
$this->g->Stroke();
}
}
// Calculate the area for a simple polygon. This will not work for
// non-simple polygons, i.e. self crossing.
function polygonArea($aX, $aY) {
$n = count($aX);
$area = 0 ;
$j = 0 ;
for ($i=0; $i < $n; $i++) {
$j++;
if ( $j == $n) {
$j=0;
}
$area += ($aX[i]+$aX[j])*($aY[i]-$aY[j]);
}
return area*.5;
}
class SingleTestTriangle {
const contval=5;
static $maxdepth=2;
static $cnt=0;
static $t;
public $g;
public $shape,$scale;
public $cont = array(2,4,5);
public $contcolors = array('yellow','purple','seagreen','green','lightblue','blue','teal','orange','red','darkred','brown');
public $dofill=false;
public $showtriangulation=false,$triangulation_color="lightgray";
public $showannotation=false;
public $contlinecolor='black',$showcontlines=true;
private $labels = array(), $showlabels=false;
private $labelColor='black',$labelFF=FF_ARIAL,$labelFS=FS_BOLD,$labelFSize=9;
function __construct($width,$height,$nx,$ny) {
$xmax=$nx+0.1;$ymax=$ny+0.1;
$this->g = new CanvasGraph($width,$height);
$this->scale = new CanvasScale($this->g, -0.1, $xmax, -0.1, $ymax);
$this->shape = new Shape($this->g, $this->scale);
//$this->g->SetFrame(true);
$this->g->SetMargin(2,2,2,2);
$this->g->SetMarginColor('white@1');
//$this->g->InitFrame();
self::$t = new Text();
self::$t->SetColor('black');
self::$t->SetFont(FF_ARIAL,FS_BOLD,9);
self::$t->SetAlign('center','center');
}
function getPlotSize() {
return array($this->g->img->width,$this->g->img->height);
}
function SetContours($c) {
$this->cont = $c;
}
function ShowLabels($aFlg=true) {
$this->showlabels = $aFlg;
}
function ShowLines($aFlg=true) {
$this->showcontlines=$aFlg;
}
function SetFilled($f=true) {
$this->dofill = $f;
}
function ShowTriangulation($f=true) {
$this->showtriangulation = $f;
}
function Stroke() {
$this->g->Stroke();
}
function FillPolygon($color,&$p) {
self::$cnt++;
if( $this->dofill ) {
$this->shape->SetColor($color);
$this->shape->FilledPolygon($p);
}
if( $this->showtriangulation ) {
$this->shape->SetColor($this->triangulation_color);
$this->shape->Polygon($p);
}
}
function GetNextHigherContourIdx($val) {
for( $i=0; $i < count($this->cont); ++$i ) {
if( $val < $this->cont[$i] ) return $i;
}
return count($this->cont);
}
function GetContVal($v1) {
for( $i=0; $i < count($this->cont); ++$i ) {
if( $this->cont[$i] > $v1 ) {
return $this->cont[$i];
}
}
die('No contour value is larger or equal than : '.$v1);
}
function GetColor($v) {
return $this->contcolors[$this->GetNextHigherContourIdx($v)];
}
function storeAnnotation($x1,$y1,$v1,$angle) {
$this->labels[$this->GetNextHigherContourIdx($v1)][] = array($x1,$y1,$v1,$angle);
}
function labelProx($x1,$y1,$v1) {
list($w,$h) = $this->getPlotSize();
if( $x1 < 20 || $x1 > $w-20 )
return true;
if( $y1 < 20 || $y1 > $h-20 )
return true;
if( !isset ($this->labels[$this->GetNextHigherContourIdx($v1)]) ) {
return false;
}
$p = $this->labels[$this->GetNextHigherContourIdx($v1)];
$n = count($p);
$d = 999999;
for ($i = 0 ; $i < $n ; $i++) {
$xp = $p[$i][0];
$yp = $p[$i][1];
$d = min($d, ($x1-$xp)*($x1-$xp) + ($y1-$yp)*($y1-$yp));
}
$limit = $w*$h/9;
$limit = max(min($limit,20000),3500);
if( $d < $limit ) return true;
else return false;
}
function putLabel($x1,$y1,$x2,$y2,$v1) {
$angle = 0;
if( $x2 - $x1 != 0 ) {
$grad = ($y2-$y1)/($x2-$x1);
$angle = -(atan($grad) * 180/M_PI);
self::$t->SetAngle($angle);
}
$x = $this->scale->TranslateX($x1);
$y = $this->scale->TranslateY($y1);
if( !$this->labelProx($x, $y, $v1) ) {
$this->storeAnnotation($x, $y, $v1, $angle);
}
}
function strokeLabels() {
$t = new Text();
$t->SetColor($this->labelColor);
$t->SetFont($this->labelFF,$this->labelFS,$this->labelFSize);
$t->SetAlign('center','center');
foreach ($this->labels as $cont_idx => $pos) {
if( $cont_idx >= 10 ) return;
foreach ($pos as $idx => $coord) {
$t->Set( sprintf("%.1f",$coord[2]) );
$t->SetAngle($coord[3]);
$t->Stroke($this->g->img,$coord[0],$coord[1]);
}
}
}
function annotate($x1,$y1,$x2,$y2,$x1p,$y1p,$v1,$v2,$v1p) {
if( !$this->showannotation ) return;
/*
$this->g->img->SetColor('green');
$this->g->img->FilledCircle($this->scale->TranslateX($x1),$this->scale->TranslateY($y1), 4);
$this->g->img->FilledCircle($this->scale->TranslateX($x2),$this->scale->TranslateY($y2), 4);
$this->g->img->SetColor('red');
$this->g->img->FilledCircle($this->scale->TranslateX($x1p),$this->scale->TranslateY($y1p), 4);
*/
//self::$t->Set(sprintf("%.1f",$v1,$this->VC($v1)));
//self::$t->Stroke($this->g->img,$this->scale->TranslateX($x1),$this->scale->TranslateY($y1));
//self::$t->Set(sprintf("%.1f",$v2,$this->VC($v2)));
//self::$t->Stroke($this->g->img,$this->scale->TranslateX($x2),$this->scale->TranslateY($y2));
$x = $this->scale->TranslateX($x1p);
$y = $this->scale->TranslateY($y1p);
if( !$this->labelProx($x, $y, $v1p) ) {
$this->storeAnnotation($x, $y, $v1p);
self::$t->Set(sprintf("%.1f",$v1p,$this->VC($v1p)));
self::$t->Stroke($this->g->img,$x,$y);
}
}
function Pertubate(&$v1,&$v2,&$v3,&$v4) {
$pert = 0.9999;
$n = count($this->cont);
for($i=0; $i < $n; ++$i) {
if( $v1==$this->cont[$i] ) {
$v1 *= $pert;
break;
}
}
for($i=0; $i < $n; ++$i) {
if( $v2==$this->cont[$i] ) {
$v2 *= $pert;
break;
}
}
for($i=0; $i < $n; ++$i) {
if( $v3==$this->cont[$i] ) {
$v3 *= $pert;
break;
}
}
for($i=0; $i < $n; ++$i) {
if( $v4==$this->cont[$i] ) {
$v4 *= $pert;
break;
}
}
}
function interp2($x1,$y1,$x2,$y2,$v1,$v2) {
$cv = $this->GetContVal(min($v1,$v2));
$alpha = ($v1-$cv)/($v1-$v2);
$x1p = $x1*(1-$alpha) + $x2*$alpha;
$y1p = $y1*(1-$alpha) + $y2*$alpha;
$v1p = $v1 + $alpha*($v2-$v1);
return array($x1p,$y1p,$v1p);
}
function RectFill($v1,$v2,$v3,$v4,$x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4,$depth) {
if( $depth >= self::$maxdepth ) {
// Abort and just appoximate the color of this area
// with the average of the three values
$color = $this->GetColor(($v1+$v2+$v3+$v4)/4);
$p = array($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $x1, $y1);
$this->FillPolygon($color,$p) ;
}
else {
$this->Pertubate($v1,$v2,$v3,$v4);
$fcnt = 0 ;
$vv1 = $this->GetNextHigherContourIdx($v1);
$vv2 = $this->GetNextHigherContourIdx($v2);
$vv3 = $this->GetNextHigherContourIdx($v3);
$vv4 = $this->GetNextHigherContourIdx($v4);
$eps = 0.0001;
if( $vv1 == $vv2 && $vv2 == $vv3 && $vv3 == $vv4 ) {
$color = $this->GetColor($v1);
$p = array($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $x1, $y1);
$this->FillPolygon($color,$p) ;
}
else {
$dv1 = abs($vv1-$vv2);
$dv2 = abs($vv2-$vv3);
$dv3 = abs($vv3-$vv4);
$dv4 = abs($vv1-$vv4);
if( $dv1 == 1 ) {
list($x1p,$y1p,$v1p) = $this->interp2($x1,$y1,$x2,$y2,$v1,$v2);
$fcnt++;
}
if( $dv2 == 1 ) {
list($x2p,$y2p,$v2p) = $this->interp2($x2,$y2,$x3,$y3,$v2,$v3);
$fcnt++;
}
if( $dv3 == 1 ) {
list($x3p,$y3p,$v3p) = $this->interp2($x3,$y3,$x4,$y4,$v3,$v4);
$fcnt++;
}
if( $dv4 == 1 ) {
list($x4p,$y4p,$v4p) = $this->interp2($x4,$y4,$x1,$y1,$v4,$v1);
$fcnt++;
}
$totdv = $dv1 + $dv2 + $dv3 + $dv4 ;
if( ($fcnt == 2 && $totdv==2) || ($fcnt == 4 && $totdv==4) ) {
if( $fcnt == 2 && $totdv==2 ) {
if( $dv1 == 1 && $dv2 == 1) {
$color1 = $this->GetColor($v2);
$p1 = array($x1p,$y1p,$x2,$y2,$x2p,$y2p,$x1p,$y1p);
$color2 = $this->GetColor($v4);
$p2 = array($x1,$y1,$x1p,$y1p,$x2p,$y2p,$x3,$y3,$x4,$y4,$x1,$y1);
$color = $this->GetColor($v1p);
$p = array($x1p,$y1p,$x2p,$y2p);
$v = $v1p;
}
elseif( $dv1 == 1 && $dv3 == 1 ) {
$color1 = $this->GetColor($v2);
$p1 = array($x1p,$y1p,$x2,$y2,$x3,$y3,$x3p,$y3p,$x1p,$y1p);
$color2 = $this->GetColor($v4);
$p2 = array($x1,$y1,$x1p,$y1p,$x3p,$y3p,$x4,$y4,$x1,$y1);
$color = $this->GetColor($v1p);
$p = array($x1p,$y1p,$x3p,$y3p);
$v = $v1p;
}
elseif( $dv1 == 1 && $dv4 == 1 ) {
$color1 = $this->GetColor($v1);
$p1 = array($x1,$y1,$x1p,$y1p,$x4p,$y4p,$x1,$y1);
$color2 = $this->GetColor($v3);
$p2 = array($x1p,$y1p,$x2,$y2,$x3,$y3,$x4,$y4,$x4p,$y4p,$x1p,$y1p);
$color = $this->GetColor($v1p);
$p = array($x1p,$y1p,$x4p,$y4p);
$v = $v1p;
}
elseif( $dv2 == 1 && $dv4 == 1 ) {
$color1 = $this->GetColor($v1);
$p1 = array($x1,$y1,$x2,$y2,$x2p,$y2p,$x4p,$y4p,$x1,$y1);
$color2 = $this->GetColor($v3);
$p2 = array($x4p,$y4p,$x2p,$y2p,$x3,$y3,$x4,$y4,$x4p,$y4p);
$color = $this->GetColor($v2p);
$p = array($x2p,$y2p,$x4p,$y4p);
$v = $v2p;
}
elseif( $dv2 == 1 && $dv3 == 1 ) {
$color1 = $this->GetColor($v1);
$p1 = array($x1,$y1,$x2,$y2,$x2p,$y2p,$x3p,$y3p,$x4,$y4,$x1,$y1);
$color2 = $this->GetColor($v3);
$p2 = array($x2p,$y2p,$x3,$y3,$x3p,$y3p,$x2p,$y2p);
$color = $this->GetColor($v2p);
$p = array($x2p,$y2p,$x3p,$y3p);
$v = $v2p;
}
elseif( $dv3 == 1 && $dv4 == 1 ) {
$color1 = $this->GetColor($v1);
$p1 = array($x1,$y1,$x2,$y2,$x3,$y3,$x3p,$y3p,$x4p,$y4p,$x1,$y1);
$color2 = $this->GetColor($v4);
$p2 = array($x4p,$y4p,$x3p,$y3p,$x4,$y4,$x4p,$y4p);
$color = $this->GetColor($v4p);
$p = array($x4p,$y4p,$x3p,$y3p);
$v = $v4p;
}
$this->FillPolygon($color1,$p1);
$this->FillPolygon($color2,$p2);
if( $this->showcontlines ) {
if( $this->dofill ) {
$this->shape->SetColor($this->contlinecolor);
}
else {
$this->shape->SetColor($color);
}
$this->shape->Line($p[0],$p[1],$p[2],$p[3]);
}
if( $this->showlabels ) {
$this->putLabel( ($p[0]+$p[2])/2, ($p[1]+$p[3])/2, $p[2],$p[3] , $v);
}
}
elseif( $fcnt == 4 && $totdv==4 ) {
$vc = ($v1+$v2+$v3+$v4)/4;
if( $v1p == $v2p && $v2p == $v3p && $v3p == $v4p ) {
// Four edge crossings (saddle point) of the same contour
// so we first need to
// find out how the saddle is crossing "/" or "\"
if( $this->GetNextHigherContourIdx($vc) == $this->GetNextHigherContourIdx($v1) ) {
// "\"
$color1 = $this->GetColor($v1);
$p1 = array($x1,$y1,$x1p,$y1p,$x4p,$y4p,$x1,$y1);
$color2 = $this->GetColor($v2);
$p2 = array($x1p,$y1p,$x2,$y2,$x2p,$y2p,$x3p,$y3p,$x4,$y4,$x4p,$y4p,$x1p,$y1p);
$color3 = $color1;
$p3 = array($x2p,$y2p,$x3,$y3,$x3p,$y3p,$x2p,$y2p);
$colorl1 = $this->GetColor($v1p);
$pl1 = array($x1p,$y1p,$x4p,$y4p);
$colorl2 = $this->GetColor($v2p);
$pl2 = array($x2p,$y2p,$x3p,$y3p);
$vl1 = $v1p;
$vl2 = $v2p;
}
else {
// "/"
$color1 = $this->GetColor($v2);
$p1 = array($x1p,$y1p,$x2,$y2,$x2p,$y2p,$x1p,$y1p);
$color2 = $this->GetColor($v3);
$p2 = array($x1p,$y1p,$x2p,$y2p,$x3,$y3,$x3p,$y3p,$x4p,$y4p,$x1,$y1,$x1p,$y1p);
$color3 = $color1;
$p3 = array($x4p,$y4p,$x3p,$y3p,$x4,$y4,$x4p,$y4p);
$colorl1 = $this->GetColor($v1p);
$pl1 = array($x1p,$y1p,$x2p,$y2p);
$colorl2 = $this->GetColor($v4p);
$pl2 = array($x4p,$y4p,$x3p,$y3p);
$vl1 = $v1p;
$vl2 = $v4p;
}
}
else {
// There are two different contours crossing so we need to find
// out which belongs to which
if( $v1p == $v2p ) {
// "/"
$color1 = $this->GetColor($v2);
$p1 = array($x1p,$y1p,$x2,$y2,$x2p,$y2p,$x1p,$y1p);
$color2 = $this->GetColor($v3);
$p2 = array($x1p,$y1p,$x2p,$y2p,$x3,$y3,$x3p,$y3p,$x4p,$y4p,$x1,$y1,$x1p,$y1p);
$color3 = $this->GetColor($v4);
$p3 = array($x4p,$y4p,$x3p,$y3p,$x4,$y4,$x4p,$y4p);
$colorl1 = $this->GetColor($v1p);
$pl1 = array($x1p,$y1p,$x2p,$y2p);
$colorl2 = $this->GetColor($v4p);
$pl2 = array($x4p,$y4p,$x3p,$y3p);
$vl1 = $v1p;
$vl2 = $v4p;
}
else { //( $v1p == $v4p )
// "\"
$color1 = $this->GetColor($v1);
$p1 = array($x1,$y1,$x1p,$y1p,$x4p,$y4p,$x1,$y1);
$color2 = $this->GetColor($v2);
$p2 = array($x1p,$y1p,$x2,$y2,$x2p,$y2p,$x3p,$y3p,$x4,$y4,$x4p,$y4p,$x1p,$y1p);
$color3 = $this->GetColor($v3);
$p3 = array($x2p,$y2p,$x3,$y3,$x3p,$y3p,$x2p,$y2p);
$colorl1 = $this->GetColor($v1p);
$pl1 = array($x1p,$y1p,$x4p,$y4p);
$colorl2 = $this->GetColor($v2p);
$pl2 = array($x2p,$y2p,$x3p,$y3p);
$vl1 = $v1p;
$vl2 = $v2p;
}
}
$this->FillPolygon($color1,$p1);
$this->FillPolygon($color2,$p2);
$this->FillPolygon($color3,$p3);
if( $this->showcontlines ) {
if( $this->dofill ) {
$this->shape->SetColor($this->contlinecolor);
$this->shape->Line($pl1[0],$pl1[1],$pl1[2],$pl1[3]);
$this->shape->Line($pl2[0],$pl2[1],$pl2[2],$pl2[3]);
}
else {
$this->shape->SetColor($colorl1);
$this->shape->Line($pl1[0],$pl1[1],$pl1[2],$pl1[3]);
$this->shape->SetColor($colorl2);
$this->shape->Line($pl2[0],$pl2[1],$pl2[2],$pl2[3]);
}
}
if( $this->showlabels ) {
$this->putLabel( ($pl1[0]+$pl1[2])/2, ($pl1[1]+$pl1[3])/2, $pl1[2], $pl1[3], $vl1);
$this->putLabel( ($pl2[0]+$pl2[2])/2, ($pl2[1]+$pl2[3])/2, $pl2[2], $pl2[3],$vl2);
}
}
}
else {
$vc = ($v1+$v2+$v3+$v4)/4;
$xc = ($x1+$x4)/2;
$yc = ($y1+$y2)/2;
// Top left
$this->RectFill(($v1+$v2)/2, $v2, ($v2+$v3)/2, $vc,
$x1,$yc, $x2,$y2, $xc,$y2, $xc,$yc, $depth+1);
// Top right
$this->RectFill($vc, ($v2+$v3)/2, $v3, ($v3+$v4)/2,
$xc,$yc, $xc,$y2, $x3,$y3, $x3,$yc, $depth+1);
// Bottom left
$this->RectFill($v1, ($v1+$v2)/2, $vc, ($v1+$v4)/2,
$x1,$y1, $x1,$yc, $xc,$yc, $xc,$y4, $depth+1);
// Bottom right
$this->RectFill(($v1+$v4)/2, $vc, ($v3+$v4)/2, $v4,
$xc,$y1, $xc,$yc, $x3,$yc, $x4,$y4, $depth+1);
}
}
}
}
function TriFill($v1,$v2,$v3,$x1,$y1,$x2,$y2,$x3,$y3,$depth) {
if( $depth >= self::$maxdepth ) {
// Abort and just appoximate the color of this area
// with the average of the three values
$color = $this->GetColor(($v1+$v2+$v3)/3);
$p = array($x1, $y1, $x2, $y2, $x3, $y3, $x1, $y1);
$this->FillPolygon($color,$p) ;
}
else {
// In order to avoid some real unpleasentness in case a vertice is exactly
// the same value as a contour we pertuberate them so that we do not end up
// in udefined situation. This will only affect the calculations and not the
// visual appearance
$dummy=0;
$this->Pertubate($v1,$v2,$v3,$dummy);
$fcnt = 0 ;
$vv1 = $this->GetNextHigherContourIdx($v1);
$vv2 = $this->GetNextHigherContourIdx($v2);
$vv3 = $this->GetNextHigherContourIdx($v3);
$eps = 0.0001;
if( $vv1 == $vv2 && $vv2 == $vv3 ) {
$color = $this->GetColor($v1);
$p = array($x1, $y1, $x2, $y2, $x3, $y3, $x1, $y1);
$this->FillPolygon($color,$p) ;
}
else {
$dv1 = abs($vv1-$vv2);
$dv2 = abs($vv2-$vv3);
$dv3 = abs($vv1-$vv3);
if( $dv1 == 1 ) {
list($x1p,$y1p,$v1p) = $this->interp2($x1,$y1,$x2,$y2,$v1,$v2);
$fcnt++;
}
else {
$x1p = ($x1+$x2)/2;
$y1p = ($y1+$y2)/2;
$v1p = ($v1+$v2)/2;
}
if( $dv2 == 1 ) {
list($x2p,$y2p,$v2p) = $this->interp2($x2,$y2,$x3,$y3,$v2,$v3);
$fcnt++;
}
else {
$x2p = ($x2+$x3)/2;
$y2p = ($y2+$y3)/2;
$v2p = ($v2+$v3)/2;
}
if( $dv3 == 1 ) {
list($x3p,$y3p,$v3p) = $this->interp2($x3,$y3,$x1,$y1,$v3,$v1);
$fcnt++;
}
else {
$x3p = ($x3+$x1)/2;
$y3p = ($y3+$y1)/2;
$v3p = ($v3+$v1)/2;
}
if( $fcnt == 2 &&
((abs($v1p-$v2p) < $eps && $dv1 ==1 && $dv2==1 ) ||
(abs($v1p-$v3p) < $eps && $dv1 ==1 && $dv3==1 ) ||
(abs($v2p-$v3p) < $eps && $dv2 ==1 && $dv3==1 )) ) {
// This means that the contour line crosses exactly two sides
// and that the values of each vertice is such that only this
// contour line will cross this section.
// We can now be smart. The cotour line will simply divide the
// area in two polygons that we can fill and then return. There is no
// need to recurse.
// First find out which two sides the contour is crossing
if( abs($v1p-$v2p) < $eps ) {
$p4 = array($x1,$y1,$x1p,$y1p,$x2p,$y2p,$x3,$y3,$x1,$y1);
$color4 = $this->GetColor($v1);
$p3 = array($x1p,$y1p,$x2,$y2,$x2p,$y2p,$x1p,$y1p);
$color3 = $this->GetColor($v2);
$p = array($x1p,$y1p,$x2p,$y2p);
$color = $this->GetColor($v1p);
$v = $v1p;
}
elseif( abs($v1p-$v3p) < $eps ) {
$p4 = array($x1p,$y1p,$x2,$y2,$x3,$y3,$x3p,$y3p,$x1p,$y1p);
$color4 = $this->GetColor($v2);
$p3 = array($x1,$y1,$x1p,$y1p,$x3p,$y3p,$x1,$y1);
$color3 = $this->GetColor($v1);
$p = array($x1p,$y1p,$x3p,$y3p);
$color = $this->GetColor($v1p);
$v = $v1p;
}
else {
$p4 = array($x1,$y1,$x2,$y2,$x2p,$y2p,$x3p,$y3p,$x1,$y1);
$color4 = $this->GetColor($v2);
$p3 = array($x3p,$y3p,$x2p,$y2p,$x3,$y3,$x3p,$y3p);
$color3 = $this->GetColor($v3);
$p = array($x3p,$y3p,$x2p,$y2p);
$color = $this->GetColor($v3p);
$v = $v3p;
}
$this->FillPolygon($color4,$p4);
$this->FillPolygon($color3,$p3);
if( $this->showcontlines ) {
if( $this->dofill ) {
$this->shape->SetColor($this->contlinecolor);
}
else {
$this->shape->SetColor($color);
}
$this->shape->Line($p[0],$p[1],$p[2],$p[3]);
}
if( $this->showlabels ) {
$this->putLabel( ($p[0]+$p[2])/2, ($p[1]+$p[3])/2, $p[2], $p[3], $v);
}
}
else {
$this->TriFill($v1, $v1p, $v3p, $x1, $y1, $x1p, $y1p, $x3p, $y3p, $depth+1);
$this->TriFill($v1p, $v2, $v2p, $x1p, $y1p, $x2, $y2, $x2p, $y2p, $depth+1);
$this->TriFill($v3p, $v1p, $v2p, $x3p, $y3p, $x1p, $y1p, $x2p, $y2p, $depth+1);
$this->TriFill($v3p, $v2p, $v3, $x3p, $y3p, $x2p, $y2p, $x3, $y3, $depth+1);
}
}
}
}
function Fill($v1,$v2,$v3,$maxdepth) {
$x1=0;
$y1=1;
$x2=1;
$y2=0;
$x3=1;
$y3=1;
self::$maxdepth = $maxdepth;
$this->TriFill($v1, $v2, $v3, $x1, $y1, $x2, $y2, $x3, $y3, 0);
}
function Fillmesh($meshdata,$maxdepth,$method='tri') {
$nx = count($meshdata[0]);
$ny = count($meshdata);
self::$maxdepth = $maxdepth;
for( $x=0; $x < $nx-1; ++$x ) {
for( $y=0; $y < $ny-1; ++$y ) {
$v1 = $meshdata[$y][$x];
$v2 = $meshdata[$y][$x+1];
$v3 = $meshdata[$y+1][$x+1];
$v4 = $meshdata[$y+1][$x];
if( $method == 'tri' ) {
// Fill upper and lower triangle
$this->TriFill($v4, $v1, $v2, $x, $y+1, $x, $y, $x+1, $y, 0);
$this->TriFill($v4, $v2, $v3, $x, $y+1, $x+1, $y, $x+1, $y+1, 0);
}
else {
$this->RectFill($v4, $v1, $v2, $v3, $x, $y+1, $x, $y, $x+1, $y, $x+1, $y+1, 0);
}
}
}
if( $this->showlabels ) {
$this->strokeLabels();
}
}
}
$meshdata = array(
array (12,12,10,10),
array (10,10,8,14),
array (7,7,13,17),
array (4,5,8,12),
array (10,8,7,8));
$tt = new SingleTestTriangle(400,400,count($meshdata[0])-1,count($meshdata)-1);
$tt->SetContours(array(4.7, 6.0, 7.2, 8.6, 9.9, 11.2, 12.5, 13.8, 15.1, 16.4));
$tt->SetFilled(true);
//$tt->ShowTriangulation(true);
$tt->ShowLines(true);
//$tt->ShowLabels(true);
$tt->Fillmesh($meshdata, 8, 'rect');
//$tt->Fill(4.0,3.0,7.0, 4);
//$tt->Fill(7,4,1,5);
//$tt->Fill(1,7,4,5);
$tt->Stroke();
?>

View File

@ -1,237 +0,0 @@
class JpCountryFlags {
$iCountryFlags = array(
'Afghanistan' => 'afgh.gif',
'Republic of Angola' => 'agla.gif',
'Republic of Albania' => 'alba.gif',
'Alderney' => 'alde.gif',
'Democratic and Popular Republic of Algeria' => 'alge.gif',
'Territory of American Samoa' => 'amsa.gif',
'Principality of Andorra' => 'andr.gif',
'British Overseas Territory of Anguilla' => 'angu.gif',
'Antarctica' => 'anta.gif',
'Argentine Republic' => 'arge.gif',
'League of Arab States' => 'arle.gif',
'Republic of Armenia' => 'arme.gif',
'Aruba' => 'arub.gif',
'Commonwealth of Australia' => 'astl.gif',
'Republic of Austria' => 'aust.gif',
'Azerbaijani Republic' => 'azer.gif',
'British Antarctic Territory' => 'bant.gif',
'Kingdom of Belgium' => 'belg.gif',
'British Overseas Territory of Bermuda' => 'berm.gif',
'Commonwealth of the Bahamas' => 'bhms.gif',
'Kingdom of Bahrain' => 'bhrn.gif',
'Republic of Belarus' => 'blru.gif',
'Republic of Bolivia' => 'blva.gif',
'Belize' => 'blze.gif',
'Republic of Benin' => 'bnin.gif',
'Republic of Botswana' => 'bots.gif',
'Federative Republic of Brazil' => 'braz.gif',
'Barbados' => 'brbd.gif',
'British Indian Ocean Territory' => 'brin.gif',
'Brunei Darussalam' => 'brun.gif',
'Republic of Burkina' => 'bufa.gif',
'Republic of Bulgaria' => 'bulg.gif',
'Republic of Burundi' => 'buru.gif',
'Overseas Territory of the British Virgin Islands' => 'bvis.gif',
'Central African Republic' => 'cafr.gif',
'Kingdom of Cambodia' => 'camb.gif',
'Republic of Cameroon' => 'came.gif',
'Dominion of Canada' => 'cana.gif',
'Caribbean Community' => 'cari.gif',
'Republic of Cape Verde' => 'cave.gif',
'Republic of Chad' => 'chad.gif',
'Republic of Chile' => 'chil.gif',
'Territory of Christmas Island' => 'chms.gif',
'Commonwealth of Independent States' => 'cins.gif',
'Cook Islands' => 'ckis.gif',
'Republic of Colombia' => 'clmb.gif',
'Territory of Cocos Islands' => 'cois.gif',
'Commonwealth' => 'comn.gif',
'Union of the Comoros' => 'como.gif',
'Republic of the Congo' => 'cong.gif',
'Republic of Costa Rica' => 'corc.gif',
'Republic of Croatia' => 'croa.gif',
'Republic of Cuba' => 'cuba.gif',
'British Overseas Territory of the Cayman Islands' => 'cyis.gif',
'Republic of Cyprus' => 'cypr.gif',
'The Czech Republic' => 'czec.gif',
'Kingdom of Denmark' => 'denm.gif',
'Republic of Djibouti' => 'djib.gif',
'Commonwealth of Dominica' => 'domn.gif',
'Dominican Republic' => 'dore.gif',
'Republic of Ecuador' => 'ecua.gif',
'Arab Republic of Egypt' => 'egyp.gif',
'Republic of El Salvador' => 'elsa.gif',
'England' => 'engl.gif',
'Republic of Equatorial Guinea' => 'eqgu.gif',
'State of Eritrea' => 'erit.gif',
'Republic of Estonia' => 'estn.gif',
'Ethiopia' => 'ethp.gif',
'European Union' => 'euun.gif',
'British Overseas Territory of the Falkland Islands' => 'fais.gif',
'International Federation of Vexillological Associations' => 'fiav.gif',
'Republic of Fiji' => 'fiji.gif',
'Republic of Finland' => 'finl.gif',
'Territory of French Polynesia' => 'fpol.gif',
'French Republic' => 'fran.gif',
'Overseas Department of French Guiana' => 'frgu.gif',
'Gabonese Republic' => 'gabn.gif',
'Republic of the Gambia' => 'gamb.gif',
'Republic of Georgia' => 'geor.gif',
'Federal Republic of Germany' => 'germ.gif',
'Republic of Ghana' => 'ghan.gif',
'Gibraltar' => 'gibr.gif',
'Hellenic Republic' => 'grec.gif',
'State of Grenada' => 'gren.gif',
'Overseas Department of Guadeloupe' => 'guad.gif',
'Territory of Guam' => 'guam.gif',
'Republic of Guatemala' => 'guat.gif',
'The Bailiwick of Guernsey' => 'guer.gif',
'Republic of Guinea' => 'guin.gif',
'Republic of Haiti' => 'hait.gif',
'Hong Kong Special Administrative Region' => 'hokn.gif',
'Republic of Honduras' => 'hond.gif',
'Republic of Hungary' => 'hung.gif',
'Republic of Iceland' => 'icel.gif',
'International Committee of the Red Cross' => 'icrc.gif',
'Republic of India' => 'inda.gif',
'Republic of Indonesia' => 'indn.gif',
'Republic of Iraq' => 'iraq.gif',
'Republic of Ireland' => 'irel.gif',
'Organization of the Islamic Conference' => 'isco.gif',
'Isle of Man' => 'isma.gif',
'State of Israel' => 'isra.gif',
'Italian Republic' => 'ital.gif',
'Jamaica' => 'jama.gif',
'Japan' => 'japa.gif',
'The Bailiwick of Jersey' => 'jers.gif',
'Hashemite Kingdom of Jordan' => 'jord.gif',
'Republic of Kazakhstan' => 'kazk.gif',
'Republic of Kenya' => 'keny.gif',
'Republic of Kiribati' => 'kirb.gif',
'State of Kuwait' => 'kuwa.gif',
'Kyrgyz Republic' => 'kyrg.gif',
'Republic of Latvia' => 'latv.gif',
'Lebanese Republic' => 'leba.gif',
'Kingdom of Lesotho' => 'lest.gif',
'Republic of Liberia' => 'libe.gif',
'Principality of Liechtenstein' => 'liec.gif',
'Republic of Lithuania' => 'lith.gif',
'Grand Duchy of Luxembourg' => 'luxe.gif',
'Macao Special Administrative Region' => 'maca.gif',
'Republic of Macedonia' => 'mace.gif',
'Republic of Madagascar' => 'mada.gif',
'Republic of the Marshall Islands' => 'mais.gif',
'Republic of Maldives' => 'mald.gif',
'Republic of Mali' => 'mali.gif',
'Federation of Malaysia' => 'mals018.gif',
'Republic of Malta' => 'malt.gif',
'Republic of Malawi' => 'malw.gif',
'Overseas Department of Martinique' => 'mart.gif',
'Islamic Republic of Mauritania' => 'maur.gif',
'Territorial Collectivity of Mayotte' => 'mayt.gif',
'United Mexican States' => 'mexc.gif',
'Federated States of Micronesia' => 'micr.gif',
'Midway Islands' => 'miis.gif',
'Republic of Moldova' => 'mold.gif',
'Principality of Monaco' => 'mona.gif',
'Republic of Mongolia' => 'mong.gif',
'British Overseas Territory of Montserrat' => 'mont.gif',
'Kingdom of Morocco' => 'morc.gif',
'Republic of Mozambique' => 'moza.gif',
'Republic of Mauritius' => 'mrts.gif',
'Union of Myanmar' => 'myan.gif',
'Republic of Namibia' => 'namb.gif',
'North Atlantic Treaty Organization' => 'nato.gif',
'Republic of Nauru' => 'naur.gif',
'Turkish Republic of Northern Cyprus' => 'ncyp.gif',
'Netherlands Antilles' => 'nean.gif',
'Kingdom of Nepal' => 'nepa.gif',
'Kingdom of the Netherlands' => 'neth.gif',
'Territory of Norfolk Island' => 'nfis.gif',
'Federal Republic of Nigeria' => 'ngra.gif',
'Republic of Nicaragua' => 'nica.gif',
'Republic of Niger' => 'nigr.gif',
'Niue' => 'niue.gif',
'Commonwealth of the Northern Mariana Islands' => 'nmar.gif',
'Province of Northern Ireland' => 'noir.gif',
'Nordic Council' => 'nord.gif',
'Kingdom of Norway' => 'norw.gif',
'Territory of New Caledonia and Dependencies' => 'nwca.gif',
'New Zealand' => 'nwze.gif',
'Organization of American States' => 'oast.gif',
'Organization of African Unity' => 'oaun.gif',
'International Olympic Committee' => 'olym.gif',
'Sultanate of Oman' => 'oman.gif',
'Organization of Petroleum Exporting Countries' => 'opec.gif',
'Islamic Republic of Pakistan' => 'paks.gif',
'Republic of Palau' => 'pala.gif',
'Independent State of Papua New Guinea' => 'pang.gif',
'Republic of Paraguay' => 'para.gif',
'Republic of the Philippines' => 'phil.gif',
'British Overseas Territory of the Pitcairn Islands' => 'piis.gif',
'Republic of Poland' => 'pola.gif',
'Republic of Portugal' => 'port.gif',
'Commonwealth of Puerto Rico' => 'purc.gif',
'State of Qatar' => 'qata.gif',
'Russian Federation' => 'russ.gif',
'Republic of Rwanda' => 'rwan.gif',
'Kingdom of Saudi Arabia' => 'saar.gif',
'Republic of San Marino' => 'sama.gif',
'Nordic Sami Conference' => 'sami.gif',
'Sark' => 'sark.gif',
'Scotland' => 'scot.gif',
'Principality of Seborga' => 'sebo.gif',
'Republic of Sierra Leone' => 'sile.gif',
'Republic of Singapore' => 'sing.gif',
'Republic of Korea' => 'skor.gif',
'Republic of Slovenia' => 'slva.gif',
'Somali Republic' => 'smla.gif',
'Republic of Somaliland' => 'smld.gif',
'Republic of South Africa' => 'soaf.gif',
'Solomon Islands' => 'sois.gif',
'Kingdom of Spain' => 'span.gif',
'Secretariat of the Pacific Community' => 'spco.gif',
'Democratic Socialist Republic of Sri Lanka' => 'srla.gif',
'Saint Lucia' => 'stlu.gif',
'Republic of the Sudan' => 'suda.gif',
'Republic of Suriname' => 'surn.gif',
'Slovak Republic' => 'svka.gif',
'Kingdom of Sweden' => 'swdn.gif',
'Swiss Confederation' => 'swit.gif',
'Syrian Arab Republic' => 'syra.gif',
'Kingdom of Swaziland' => 'szld.gif',
'Republic of China' => 'taiw.gif',
'Republic of Tajikistan' => 'tajk.gif',
'United Republic of Tanzania' => 'tanz.gif',
'Kingdom of Thailand' => 'thal.gif',
'Autonomous Region of Tibet' => 'tibe.gif',
'Turkmenistan' => 'tkst.gif',
'Togolese Republic' => 'togo.gif',
'Tokelau' => 'toke.gif',
'Kingdom of Tonga' => 'tong.gif',
'Tristan da Cunha' => 'trdc.gif',
'Tromelin' => 'tris.gif',
'Republic of Tunisia' => 'tuns.gif',
'Republic of Turkey' => 'turk.gif',
'Tuvalu' => 'tuva.gif',
'United Arab Emirates' => 'uaem.gif',
'Republic of Uganda' => 'ugan.gif',
'Ukraine' => 'ukrn.gif',
'United Kingdom of Great Britain' => 'unkg.gif',
'United Nations' => 'unna.gif',
'United States of America' => 'unst.gif',
'Oriental Republic of Uruguay' => 'urgy.gif',
'Virgin Islands of the United States' => 'usvs.gif',
'Republic of Uzbekistan' => 'uzbk.gif',
'State of the Vatican City' => 'vacy.gif',
'Republic of Vanuatu' => 'vant.gif',
'Bolivarian Republic of Venezuela' => 'venz.gif',
'Republic of Yemen' => 'yemn.gif',
'Democratic Republic of Congo' => 'zare.gif',
'Republic of Zimbabwe' => 'zbwe.gif'
) ;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,128 +0,0 @@
<?php
/**
* imgdata_bevels.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: IMGDATA_BEVELS.INC
// Description: Base64 encoded images for round bevels
// Created: 2003-03-20
// Ver: $Id: imgdata_bevels.inc.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Bevels extends ImgData {
protected $name = 'Round Bevels';
protected $an = array(MARK_IMG_BEVEL => 'imgdata');
protected $colors = array('green','purple','orange','red','yellow');
protected $index = array('green'=>1,'purple'=>4,'orange'=>2,'red'=>0,'yellow'=>3);
protected $maxidx = 4 ;
protected $imgdata ;
function __construct() {
//==========================================================
// File: bullets_balls_red_013.png
//==========================================================
$this->imgdata[0][0]= 337 ;
$this->imgdata[0][1]=
'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'.
'BMVEX////////27t/f3+LFwcmNxMuxm62DmqKth1VpZmIWg6fv'.
'HCa7K0BwMEytCjFnIyUlEBg9vhQvAAAAAXRSTlMAQObYZgAAAA'.
'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'.
'RQfTAxcBNhk+pYJVAAAAl0lEQVR4nE2Q2xLDIAgFHUWBKJf//9'.
'oekmbafVDZARRbK/pYTKP9WNcNv64zzUdd9BjmrgnsVXRNSzO3'.
'CJ5ahdhy0XKQkxld1kxb45j7dp0x2lBNOyVgQpMaoadX7Hs7zr'.
'P1yKj47DKBnKaBKiSAkNss7O6PkMx6kIgYXISQJpcZCqdY6KR+'.
'J1PkS5Xob/h7MNz8x6D3fz5DKQjpkZOBYAAAAABJRU5ErkJggg'.
'==' ;
//==========================================================
// File: bullets_balls_green_013.png
//==========================================================
$this->imgdata[1][0]= 344 ;
$this->imgdata[1][1]=
'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'.
'BMVEX////////27t/e3+K3vriUub/Dm18j4xc3ob10k0ItqQlU'.
'e5JBmwpxY1ENaKBgUh0iHgwsSre9AAAAAXRSTlMAQObYZgAAAA'.
'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'.
'RQfTAxcBNTfJXtxZAAAAnklEQVR4nE2QWY4EMQhDUVhSIRC4/2'.
'kbaqLp9p+f2AxAayAzDfiK9znPORuvH0x8Ss9z6I9sHp6tcxE9'.
'nLmWmebmt5F5p2AR0+C9AWpLBjXRaZsCAT3SqklVp0YkAWaGtd'.
'c5Z41/STYpPzW7BjyiRrwkVmQto/Cw9tNEMvsgcekyCyFPboIu'.
'IsuXiKffYB4NK4r/h6d4g9HPPwCR7i8+GscIiiaonUAAAAAASU'.
'VORK5CYII=' ;
//==========================================================
// File: bullets_balls_oy_035.png
//==========================================================
$this->imgdata[2][0]= 341 ;
$this->imgdata[2][1]=
'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'.
'BMVEX////////27t/f3+K5tbqNwcjnkjXjbxR2i5anfEoNkbis'.
'PBxpU0sZbZejKgdqIRIlERIwYtkYAAAAAXRSTlMAQObYZgAAAA'.
'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'.
'RQfTAxcBNgK0wEu5AAAAm0lEQVR4nE3QVxIEIQgEUErAgTHA/U'.
'+7zbipf9RXgoGo0liMmX6RdSPLPtZM9F4LuuSIaZtZWffiU6Iz'.
'Y8SOMF0NogBj30ioGRGLZgiPvce1TbIRz6oBQEbOFGK0rIoxrn'.
'5hDomMA1cfGRCaRVhjS3gkzheM+4HtnlkXcvdZhWG4qZawewe6'.
'9Jnz/TKLB/ML6HUepn//QczazuwFO/0Ivpolhi4AAAAASUVORK'.
'5CYII=' ;
//==========================================================
// File: bullets_balls_oy_036.png
//==========================================================
$this->imgdata[3][0]= 340 ;
$this->imgdata[3][1]=
'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'.
'BMVEX////////27t/e3+LO3hfYzz65ubiNwci6uQ12ipadgVGa'.
'fwsNkbhnVkcaZ5dwSA8lFg7CEepmAAAAAXRSTlMAQObYZgAAAA'.
'FiS0dEAIgFHUgAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAHdElN'.
'RQfTAxcCBySi1nevAAAAjElEQVR4nFXPWw7EIAgFUNMoCMhj/6'.
'staKczc/2RkwjS2glQ+w3YytgXCXCZpRo8gJdGxZadJws13CUP'.
'4SZI4MYiUxypeiGGw1XShVBTNN9kLXP2GRrZPFvKgd7z/sqGGV'.
'7C7r7r3l09alYN3iA8Yn+ImdVrNoEeSRqJPAaHfhZzLYwXstdZ'.
'rP3n2bvdAI4INwtihiwAAAAASUVORK5CYII=' ;
//==========================================================
// File: bullets_balls_pp_019.png
//==========================================================
$this->imgdata[4][0]= 334 ;
$this->imgdata[4][1]=
'iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAM1'.
'BMVEX////+/v7i4eO/w8eHxcvKroNVormtfkjrMN2BeXQrepPc'.
'Esy4IL+OFaR7F25LHF8mFRh5XXtUAAAAAXRSTlMAQObYZgAAAA'.
'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'.
'RQfTAxcBNgkjEpIxAAAAlElEQVR4nE2QAQ7FIAhDDTAVndL7n3'.
'ZV/7JfEwMvFIWUlkTMVNInbVv5ZeJqG7Smh2QTBwJBpsdizAZP'.
'5NyW0awhK8kYodnZxS6ECvPRp2sI+y7PBv1mN02KH7h77QCJ8D'.
'4VvY5NUgEmCwj6ZMzHtJRgRSXwC1gfcqJJH0GBnSnK1kUQ72DY'.
'CPBv+MCS/e0jib77eQAJxwiEWm7hFwAAAABJRU5ErkJggg==' ;
}
}
?>

View File

@ -1,201 +0,0 @@
<?php
/**
* imgdata_diamonds.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: IMGDATA_DIAMONDS.INC
// Description: Base64 encoded images for diamonds
// Created: 2003-03-20
// Ver: $Id: imgdata_diamonds.inc.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Diamonds extends ImgData {
protected $name = 'Diamonds';
protected $an = array(MARK_IMG_DIAMOND =>'imgdata');
protected $colors = array('lightblue','darkblue','gray',
'blue','pink','purple','red','yellow');
protected $index = array('lightblue' =>7,'darkblue'=>2,'gray'=>6,
'blue'=>4,'pink'=>1,'purple'=>5,'red'=>0,'yellow'=>3);
protected $maxidx = 7 ;
protected $imgdata ;
function __construct() {
//==========================================================
// File: diam_red.png
//==========================================================
$this->imgdata[0][0]= 668 ;
$this->imgdata[0][1]=
'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAA/F'.
'BMVEX///////+cAAD/AADOAABjAABrAADWGBjOCAj/CAj/GBj/'.
'EBCcCAiMOTl7KSl7ISFzGBilGBjOEBBrCAjv5+eMQkK1QkKtMT'.
'GtKSnWKSn/KSlzEBCcEBDexsb/tbXOe3ucWlqcUlKUSkr/e3vn'.
'a2u9UlL/a2uEMTHeUlLeSkqtOTn/UlL/SkrWOTn/QkL/OTmlIS'.
'H/MTH/ISH39/f/9/f35+fezs7/5+fvzs7WtbXOra3nvb3/zs7G'.
'nJzvtbXGlJTepaW9jIy1hITWlJS1e3uta2ulY2P/lJTnhITne3'.
'vGY2O9Wlr/c3PeY2O1Skr/Y2P/WlreQkLWISGlEBCglEUaAAAA'.
'AXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAA'.
'sSAdLdfvwAAAAHdElNRQfTAwsWEw5WI4qnAAABGUlEQVR4nHXQ'.
'1XLDMBAFUKUCM1NiO8zcpIxpp8z0//9SWY7b2LHv6EU6s1qtAN'.
'iMBAojLPkigpJvogKC4pxDuQipjanlICXof1RQDkYEF21mKIfg'.
'/GGKtjAmOKt9oSyuCU7OhyiDCQnjowGfRnooCJIkiWJvv8NxnG'.
'nyNAwFcekvZpPP3mu7Vrp8fOq8DYbTyjdnAvBj7Jbd7nP95urs'.
'+MC2D6unF+Cu0VJULQBAlsOQuueN3Hrp2nGUvqppemBZ0aU7Se'.
'SXvYZFMKaLJn7MH3btJmZEMEmGSOreqy0SI/4ffo3uiUOYEACy'.
'OFopmNWlP5uZd9uPWmUoxvK9ilO9NtBo6mS7KkZD0fOJYqgGBU'.
'S/T7OKCAA9tfsFOicXcbxt29cAAAAASUVORK5CYII=' ;
//==========================================================
// File: diam_pink.png
//==========================================================
$this->imgdata[1][0]= 262 ;
$this->imgdata[1][1]=
'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbBAMAAAB/+ulmAAAAEl'.
'BMVEX///+AgID/M5n/Zpn/zMz/mZn1xELhAAAAAXRSTlMAQObY'.
'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'.
'AHdElNRQfTAwsWEi3tX8qUAAAAbUlEQVR4nFXJwQ3AMAhDUdRm'.
'kKojuCswABf2X6UEEiC+WF+PyDfoGEuvwXogq3Rk1Y6W0tBSG8'.
'6Uwpla6CmJnpoYKRsjjb/Y63vo9kIkLcZCCsbGYGwMRqIzEp1R'.
'OBmFk9HQGA2N0ZEIz5HX+h/jailYpfz4dAAAAABJRU5ErkJggg'.
'==' ;
//==========================================================
// File: diam_blue.png
//==========================================================
$this->imgdata[2][0]= 662 ;
$this->imgdata[2][1]=
'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAA+V'.
'BMVEX///+AgIAAAJwAAP8AAM4AAGMAAGsQEP8YGHMQEHMYGP8Q'.
'EKUICJwICM5KSpQxMYQpKXsYGNYQEM4ICGsICP97e85aWpw5OY'.
'xSUv85ObVCQt4xMa0pKa0hIaUpKf+9vd6EhLVra+dzc/9SUr1r'.
'a/9aWt5SUt5CQrVaWv9KSv8hIXs5Of8xMf8pKdYhIdYYGKUhIf'.
'/Ozs739//v7/fn5+/v7//n5/fW1ufOzufOzu/W1v+trc69veel'.
'pc6trd6UlMa9vf+MjL21tfe1tf+UlNZzc61ra6Wlpf+EhOeMjP'.
'9ra8ZSUpyEhP9CQoxKSrVCQv85Od4xMdYQENZnJhlWAAAAAXRS'.
'TlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAd'.
'LdfvwAAAAHdElNRQfTAwsWEx3Snct5AAABFklEQVR4nHXR5XbD'.
'IBgGYM6AuHsaqbvOfeuknev9X8xISbplSd5/8JyXwwcA/I0AKm'.
'PFchVBdvKNKggKQx2VIoRwMZihMiQE49YUlWBCcPL0hYq4ITh+'.
'qKECUoLDZWqoQNA766F/mJHlHXblPJJNiyURhM5eU9cNw5BlmS'.
'IrLOLxhzfotF7vwO2j3ez2ap/TmW4AIM7DoN9+tu+vLk6Pdg9O'.
'6ufXjfXLm6pxPACSJIpRFAa+/26DhuK6qjbiON40k0N3skjOvm'.
'NijBmchF5mi+1jhQqDmWyIzPp1hUlrv8On5l+6mMm1tigFNyrt'.
'5R97g+FKKyGKkTNKesXPJTZXOFIrUoKiypcTQVHjK4g8H2dWEQ'.
'B8bvUDLSQXSr41rmEAAAAASUVORK5CYII=' ;
//==========================================================
// File: diam_yellow.png
//==========================================================
$this->imgdata[3][0]= 262 ;
$this->imgdata[3][1]=
'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbBAMAAAB/+ulmAAAAEl'.
'BMVEX///+AgIBmMwCZZgD/zADMmQD/QLMZAAAAAXRSTlMAQObY'.
'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'.
'AHdElNRQfTAwsWEwcv/zIDAAAAbUlEQVR4nFXJwQ3AMAhDUdRm'.
'kKojuCswABf2X6UEEiC+WF+PyDfoGEuvwXogq3Rk1Y6W0tBSG8'.
'6Uwpla6CmJnpoYKRsjjb/Y63vo9kIkLcZCCsbGYGwMRqIzEp1R'.
'OBmFk9HQGA2N0ZEIz5HX+h/jailYpfz4dAAAAABJRU5ErkJggg'.
'==' ;
//==========================================================
// File: diam_lightblue.png
//==========================================================
$this->imgdata[4][0]= 671 ;
$this->imgdata[4][1]=
'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAA/1'.
'BMVEX///+AgIAAnP8A//8Azv8AY/8Aa/8I//8Y1v8Izv8Y//8Q'.
'//8InP8Qzv8Ypf85jP8he/8Yc/8Ia/8pe/8p//8p1v9Ctf8xrf'.
'8prf8QnP8Qc/9CjP+1//97//9r//9S//9K//9C//85//8x//8h'.
'//9r5/9K3v9S3v851v97zv9Svf85rf8hpf/G3v9SnP9anP9KlP'.
'8xhP/n7//v7+f3///n///O//+U//9z//9j//9a//975/9C3v8h'.
'1v+E5/+17/9j3v/O7//n9/+95/+l3v9jxv+U1v8Qpf9avf9Ktf'.
'+Uxv+11v97tf9rrf+cxv+Mvf9jpf+tzv+Etf/O3v/39/8Akkxr'.
'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx'.
'IAAAsSAdLdfvwAAAAHdElNRQfTAwsWEiHk6Ya/AAABGUlEQVR4'.
'nHXQ13KDMBAF0J2o0E01GHDvJa7p3em95/+/JQJMYjDc0Yt0Zr'.
'VaAaxHgtxwbSGPkGQpOIeQ2ORxJiJmNWYZyAhZR0WcgQGhViU0'.
'nEGoedDHGxgRapRPcRpXhOr7XZzCmLjaXk9IIjvkOEmSRLG62+'.
'F5XlEElhA5sW21GvXj6mGlDBfnJ51lr9svnvEKwH1hu2QPbwd3'.
'N9eXVzuL7/Hn29frdKaamgcgy67L3HFG9gDefV+dm5qme4YRXL'.
'oVR374mRqUELZYosf84XAxISFRQuMh4rrH8YxGSP6HX6H97NNQ'.
'KEAaR08qCeuSnx2a8zIPWqUowtKHSRK91rAw0elmVYQFVc8mhq'.
'7p5RD7Ps3IIwA9sfsFxFUX6eZ4Zh4AAAAASUVORK5CYII=' ;
//==========================================================
// File: diam_purple.png
//==========================================================
$this->imgdata[5][0]= 657 ;
$this->imgdata[5][1]=
'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAA/F'.
'BMVEX///////8xAP/OAP+cAP9jAP9rAP+cCP85CP/OEP9SKf/O'.
'CP9CEP9zGP9rCP+lGP/WOf/WIf9KIf9jOf+MQv+EMf97If9zEP'.
'+1Sv+lIf/ne//eUv/na//n5//Oxv/Wzv+chP9zUv97Wv9rQv9a'.
'Mf9KGP/v5/+te/97Kf+9Y/+tOf+tKf+lEP/vtf/WMf/WKf/v7+'.
'f39/+tnP+9rf9rSv9jQv9CGP+ljP+EY//Gtf+tlP+Ma/9zSv/e'.
'zv+UUv+9lP+cWv+lY/+cUv+MOf+EKf+UQv/Opf/OhP/Ga/+1Qv'.
'/Oe/+9Uv/ntf/eWv/eSv/WGP/3zv/vlP/WEP//9/+pL4oHAAAA'.
'AXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAA'.
'sSAdLdfvwAAAAHdElNRQfTAwsWEjX+M1LCAAABDklEQVR4nHXQ'.
'1bLDIBAGYFqIEW+ksbr7cXd3ff93OUCamdOE/Mxw882yywLwPz'.
'+gNKotlRFUVnNUQlCxTMRFCKEdE+MgpJaEiIOU4DKaoSIygtb3'.
'FBUQrm3xjPK4JvXjK0A5hFniYSBtIilQVYUm+X0KTVNiYah+2q'.
'ulFb8nUbSovD2+TCavwXQWmnMA6ro+di+uR5cPzfPhVqPV3N1p'.
'n3b3+rimAWAYhP3xnXd7P6oc9vadPsa1wYEs00dFQRAFehlX21'.
'25Sg9NOgwF5jeNTjVL9om0TjDc1lmeCKZ17nFPzhPtSRt6J06R'.
'WKUoeG3MoXRa/wjLHGLodwZcotPqjsYngnWslRBZH91hWTbpD2'.
'EdF1ECWW1SAAAAAElFTkSuQmCC' ;
//==========================================================
// File: diam_gray.png
//==========================================================
$this->imgdata[6][0]= 262 ;
$this->imgdata[6][1]=
'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbBAMAAAB/+ulmAAAAEl'.
'BMVEX//////wAzMzNmZmbMzMyZmZlq4Qo5AAAAAXRSTlMAQObY'.
'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'.
'AHdElNRQfTAwsWExZFTxLxAAAAbUlEQVR4nFXJwQ3AMAhDUdRm'.
'kKojuCswABf2X6UEEiC+WF+PyDfoGEuvwXogq3Rk1Y6W0tBSG8'.
'6Uwpla6CmJnpoYKRsjjb/Y63vo9kIkLcZCCsbGYGwMRqIzEp1R'.
'OBmFk9HQGA2N0ZEIz5HX+h/jailYpfz4dAAAAABJRU5ErkJggg'.
'==' ;
//==========================================================
// File: diam_blgr.png
//==========================================================
$this->imgdata[7][0]= 262 ;
$this->imgdata[7][1]=
'iVBORw0KGgoAAAANSUhEUgAAABsAAAAbBAMAAAB/+ulmAAAAEl'.
'BMVEX///+AgIBmzP9m///M//+Z//8hMmBVAAAAAXRSTlMAQObY'.
'ZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAA'.
'AHdElNRQfTAwsWEwCxm6egAAAAbUlEQVR4nFXJwQ3AMAhDUdRm'.
'kKojuCswABf2X6UEEiC+WF+PyDfoGEuvwXogq3Rk1Y6W0tBSG8'.
'6Uwpla6CmJnpoYKRsjjb/Y63vo9kIkLcZCCsbGYGwMRqIzEp1R'.
'OBmFk9HQGA2N0ZEIz5HX+h/jailYpfz4dAAAAABJRU5ErkJggg'.
'==' ;
}
}
?>

View File

@ -1,541 +0,0 @@
<?php
/**
* imgdata_pushpins.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: IMGDATA_PUSHPINS.INC
// Description: Base64 encoded images for pushpins
// Created: 2003-03-20
// Ver: $Id: imgdata_pushpins.inc.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_PushPins extends ImgData {
protected $name = 'Push pins';
protected $an = array(MARK_IMG_PUSHPIN => 'imgdata_small',
MARK_IMG_SPUSHPIN => 'imgdata_small',
MARK_IMG_LPUSHPIN => 'imgdata_large');
protected $colors = array('blue','green','orange','pink','red');
protected $index = array('red' => 0, 'orange' => 1, 'pink' => 2, 'blue' => 3, 'green' => 4 ) ;
protected $maxidx = 4 ;
protected $imgdata_large, $imgdata_small ;
function __construct() {
// The anchor should be where the needle "hits" the paper
// (bottom left corner)
$this->anchor_x = 0;
$this->anchor_y = 1;
//==========================================================
// File: ppl_red.png
//==========================================================
$this->imgdata_large[0][0]= 2490 ;
$this->imgdata_large[0][1]=
'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'.
'B3RJTUUH0wMKBh4Ryh89CgAACUdJREFUeJy9mNtTFFcexz+/7p'.
'4Lw1wZJKDGCAwmDAqUySamcCq1ed6k9mn3UfMP7F+1T3nYqn2J'.
'lZdoDEjpbq0KG8EBFBFBEJye6Zmenkv32Ydu5GYiUMmeqq6uqT'.
'6Xz3zP73aOcIKmAQkIFyD3N/jrBPwlKjLQEglVlJKyUjR3u7cc'.
'WLoP3/4dvv03LNrQ8I6x1rFbDML9kOmHvh7IRHU9JKmUSG8vpF'.
'IoXX/TV0AiEM5A5jT0noFMFMJHXUt/d5f9TUAbhtQ3cPFruDog'.
'8klHMnmO0dGYe/myOJGINEwTz3F2higFXgy8PpAkOC+h8hoaCt'.
'4ppHFcQAWSgOQlyI/p+lUjmRxWAwNJd3xca/f34yoFi4tgmjtD'.
'NIFkJ4xcgBCgVqEBFJ9DqcZea/gNAAVEg7AOGYnHe9XoaJd3+X'.
'LISSSwnz6lsbKCZ9sHh4UVdBkwdA6cPwNnIfJPmC3Ctgft3wwQ'.
'QPkvTZJJnbExzfvsM2nMzVG7e5fG48d4lnXwTwEYCjJxuHQBog'.
'BHUfKkgAIIhiGk06hTp/Dm5qS1uYlXLvtWd4gPgIiCrAEcVckT'.
'Ab5p7TaYJrK1hQaEenrwSiVfQdc91P0kSp7Ii89D5ksY/kAkLy'.
'IZXFdXkQjS1YUSEbdcRu168V6+HTUNIKJDRwdE+sBIQmP9Ld59'.
'bEBA3of4F/D+uXb7rGaaCSmXI3pPj64PDaHCYfEqFVSjgWo2D2'.
'73XlJNQTgCyQykIuBWoNKEeh1aLXBPBCggGdBOgxZVSjoajVhH'.
'o5HWlIpq4bCQSgm9vXhK4ZZKh5SUYygp4J1EQVUD9xlU18BJQD'.
'bUbJ5T5XJStyxN9fSI099P3baxV1dRloW2h2ivx/yakg2ot6F1'.
'EkCa4G1D+zVEq5ArKTWM42Q6HUczQV7U66w9e0ZpdRXlOIQ5vF'.
'VHUXILKify4jiEzkOqC3peQMoBQymFlMt4Dx6wUSxSsm2UZXEK'.
'P30QvOUt8/2Sd78CdWwFDTA+gsw3cOlPcPUD+CQB52oQ21RKXM'.
'eRhGXhOg7VoKrx8KuS4ygZhVg3ZI8FGIfwR9BVgAtfwxdXdP3L'.
'86nUR91dXelNXTeWWy10paQHX602YAP1ADASAL7LJvFtMpOCc0'.
'cG3FHuGlz6Gr4YEpnoTCbzsdHRbOzy5RCRiLRMk5rjyOtAimwA'.
'U4U3SurBN/0wnAASBCVDIKpB4kiAB5Ub0/UvO9LpPAMDGfn005'.
'AxPCzxep3Q6iqPLUseBoufCZRsAE6g5g5kKIDfKUj3wnpAG8QB'.
'/Z1OIqANQuI65AtwNScyYXR2XlAXL2YZHzcklRKWl5GVFXFtGx'.
'MoAiV/EQaAGH6BUQNWgQpwFngv+Ca8KUAQEBcwgTJHyMV7679R'.
'XS8YqdSI6u/PMD5ukMtJY3GR2uQkr5aXeWVZOEALmA8WsIAxfL'.
'd0goVLAdCOd+/YpgqeVtBv4yiA++q/RKKXixe7GB8PSyoljcVF'.
'yg8fyubyMpulEk2lyAIfAAvAC+B+oOQFoAt/+0rAejB/EzjNri'.
'vvqNnCd64jxcE39V8spnP+vMbAgDSePKE2NcXm06dslMuUlcID'.
'TuFvqwXMBU8N39bGgRR+ki0Dz4L5DSAe9NGD7zq+6kcN1L6H2b'.
'ao5WWaQHllRTafPmWrVMJUimoAQrBYJFjQwre7B6A8YAi8LCgD'.
'5DVo6/hbb/iHK1KggvFeD3hHziQKEMuiNTNDbXGRTdtmw7Iwla'.
'KGH0oqwbscLOoG46rAY6AOzRhY74PT6QuUKEN4PegXxd/yEDTT'.
'YMWOk+oEaLkuFdNk0zTZwjfkavDUArXWgGXgFb4dEShXhfYqlI'.
'ow3w9rg3B6ED60IOOA5oEYQBrcpG+mj9bg0VG8GMJhVDZLyzAo'.
'VSq8rFYxXXefcjVgG9+uisDrXUCApoKSBcUHMBmHhfcgNwhtD3'.
'q9IG6Lr15b4OUTmPwBJt8JqGuapp05o0mhoHnptLQfPsR+8IBK'.
'uYyNH3yr+B77LHheA3tK1Ta+IrMeTL2C6Xl48TOsNWDDgAz7s5'.
'/r+krP/eddCsbj8fDQ4GBm9MqVvvRXX2VULBayRGRzaYn1SoWa'.
'UjgB4PIB5QK4ZgBXBKaAHxQsrED1H7CRgCUPwgHZDqACmhWwXv'.
'2aDRqGYeRyufS169cvThQKV88PDuYbW1vJ5VRK+5euqxWlPMdX'.
'SRqgreHbZGN3ijfKBXBTAeh2Fdwi2MofshP/dvKwCmKhp4m83Y'.
'vj8Xg4l8tlCoXC0MTExMTFkZE/1m37wvLGRvKRacoD1209E7Fc'.
'pZwYREOQqEJ4z3HskHLsz4AoXykPIBSN0t3dTTQafROoHdumXC'.
'4fjoMiog0ODiauX7+eLxQKV3O53ETdti88nJnJ3rl505ifmWm3'.
'arWSodR8GNbycDoNHy5C5jFold1k8d+DyvELNwg93d18/vnn9P'.
'X1oes6nufx/Plz7t+/fxhQKSWJRCI5NjaWHxkZKdj1+sjSwkJm'.
'+uZN/dZ337VqCwullGUVdZjsgIUC5LqhrUPvCugWuApeApPAzY'.
'PKHWyaphGNRunt7WVwcBARwfM8Ojo6sCzrMKBhGLphGFEF2Wq1'.
'2jc7M5OZ/vHH0MPbt93awkJJmeZsC6ZaMK3DCwvWdNioQUb5B6'.
'AdBR+9SzkAz/NwHIeXL18iIui6TjgcJplMMjY2th8wHo+Hh4aG'.
'MsPDw6fddru7+Phxx51bt/RbN260qwsLpZhlFZsw9QJ+2Pbrga'.
'oJG2FY2oKwuTtVEz9uV34NbqdtbW0xPT1NNBoF4MyZM1y5coWu'.
'rq5dQBHRcrlc4tq1a/l8Pj9RMs38ndu3Ez//9JNXLRZNyuXZJk'.
'xVYKoExQpsK/+IaAuYb7no8zjC/R+A4zisrq7u+53NZjl16tQ+'.
'QIlEIslsNpuPRCJXZ2dnh2/duNFRW1oy07a96MKd575yxRqU1B'.
'5vPMpF5HHa1tYW9+7do7Ozc/eQpZTSQ6FQt1Lq8pMnT/5w7969'.
'nuLcXE1rNufO9fRMhlKpOyvt9qPtVmvb25fFfvvWbrepVCqHwo'.
'xaX19vff/996ZhGC8qlkW9Wt1Onz073fXxxz+6MB+9e9dUjuO+'.
'7ebq9wLdB9hoNCrr6+s/4wf3FCJW3fPmTZhXsNWCprjuW66Dfr'.
'928KAfBhJAEgiJSLuzs7OSTqctoFkqlZRt26j/I+L/AGjPTN4d'.
'Nqn4AAAAAElFTkSuQmCC' ;
//==========================================================
// File: ppl_orange.png
//==========================================================
$this->imgdata_large[1][0]= 2753 ;
$this->imgdata_large[1][1]=
'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'.
'B3RJTUUH0wMLFQ0VCkHCzQAACk5JREFUeJytmGtzG0d2hp8zNw'.
'AEcRdJ6EJK9FL0CqZUm9jWbkwq3vhDstl8dmLvz8rP2H8Q75ZT'.
'pkRfpLgqsS6WIFEKGYkiSBCDO+banQ8DUpRWEkklXQUUqlCDfv'.
'rp857pgfAOQ4AMOJdg4R/hX96Hf06bvDc5iT07i8yeg8ksiIAI'.
'4TBi/ds9/vivD/njapNHvRBfHXMu410AM+BUoVSF05NQsi1sO4'.
'8402AXwLQTuP31OAZO2aG0MEn14iSlnI1z3LnMk8IZYJyBwjIs'.
'/TWsVIWPJkvMFS4zMfMhUp5BsoCpAAEBLYKaMFGn00jBxnvu02'.
'35+JHmSJEnBpQEcPo38MmCxd/nS9Ry71Ga/g1W9a8gn0GsHkgA'.
'6DGjxkqb5CoO+YxF3A3p+jGjQUzoK+L/V0ADzFMwtSR8eLbAr8'.
'uXOTf9NzhTc0geSLUQcYHgYEH786RMg0zWJHV2Aitv4x/HpHVS'.
'QA2YBqTTGIUq5qkPMWaWkVwPnPtAA/BevmZcjxaaUtHh8pJJGu'.
'DpCB9FvT7A7YT7S3p5vFMNzmWo/O0MSx/Ms3TqI8r59zFTfUQe'.
'I7SBODE3tnfoIxYnNHligwik0zAzDdVpyKbA8sff5YAeMEwgkV'.
'cufQeTJzZoCsaFLKXPTnNpoUTNsSgJmNoGsuNQjIDwYD2HlnZy'.
'k++yxTKXZfKTU8zOpjhneeQYkorSmGERtIlICBKRbLX+y98YN3'.
'ADcNIm+bJD4U3pPnmbEaRgYVRTGBkDSSsmxKfY7ZLuDJA4hdjl'.
'JEgyBB2SJOvQ9RzTpNKoEwNq0CNFvOXR3/HxMgYVPObaz8kPmh'.
'hkEWMatAfRONGGvLizyOE9P8KkpwhPDAgQKJQbELUD0oOIhbbH'.
'JeVTmowxjAgZutB5AoOngA+2DdYrcTyOyYZP9+QpBvI29vwEhb'.
'It042BVQgDy9KTMfkwQG1A9ACCLlgBBGUwxxoc52WDh2ATyEPp'.
'1hoaPvrEBh0Dq5an9OUsl/9hylk5b5c+mowLc4E2Jtw4Eoljyf'.
'ogA/AGEAagNRjGyUxOmEycyVA5EWDBxrmUp3ytLIv/NJP69Goh'.
'+9mFydIvS5PZYkvH1oY/RFtKymlwBFQAgQd+kAA6qSQ8pvn2mp'.
'SkJkuVFHPHBnQMrEt5Sl+e4/Lvp51PF1PF5Xy6WMvOWZXMom8z'.
'OZTQ8+j5sbQiMEwopsCIwRtBGIJSCdzbTGo9NimkDcgdC7Bg49'.
'TG5n4/nfr0Si77WdYp1YzyZEkWPdteaEnB7pPqBTxuIf/VgciE'.
'SgasCPwh+GNIkaNNag1RiPge5pEhMQVjfoLcF+eoXSvbKxedwn'.
'LKzC3KWbOi5/sW5a44/SHFUSgVA7SCzRG0AvA9mPOgFIETgu4n'.
'Ww0wNQWFAqRSL6D2ZQYBdDrQ7R7jXiwgRcvIL02makuTmWtpM/'.
'+BlLMl5vuWzLVEuwH6oYnR1KS8kJINGXMM2YdfRlALoQoQQKeb'.
'bDVwoMdxQMaLCwLo96HZTF5HbrEhmOftianfZisfzueKv7ZmrX'.
'MsjhxKXZGBjzyeEHmSE3oWiggtyVGmE8DTIXTC5NxgAxOAGUM8'.
'fun9mnSSLQ/CxNzOTgJ3LIMgoGwkKBiiMyaVviHVkdCO4FEKNv'.
'LQzWBYHfITPa4UBVM0LR/WB7ARJsdDDTjA6deYFIFUOimJ3d0E'.
'sNdLavYYgBpthqKcjiiJRO8K6CK0CsJTjfQAGaJtD9vQFAxNNQ'.
'1FB0yBAfA8gdMAIagLoCVAen0M00zMOTYShNDtoHs9CAIUoI4E'.
'1IBihCdNhsMhsj6NuV7BCC2IBpBqQaaFOENCCeiEsO1BO4RQgy'.
'I5Hm4k4oIU9MrgZSAdBeTabZz+ODxKQRRBFBJo6IUc51anYRQo'.
'dto+24FNxYCiaWKkQsj00KkO4gxRRkAngJ868M0u3OkkM+hxQA'.
'cQ7YD7GO5XYSsPZybh/TCkFIYY+kWniTW4Q7jXgHvHMhiRpmuW'.
'ca08GZkkZ/nY6TZMNhCnf2CuPoDVJvxpB+q9BHA8Ag1uH+oP4c'.
'YEPCzDwmzSLquShHW/E0YRbG/BjZtw40hAy7aNzJlzRn75E6N0'.
'qiwTzafI7kOU3gWrhzZC2iHcbsPqLlxvJnCt4KC1RYAL3I5hzY'.
'Xv/huePYCtITQMKEnyB4KQvMURuJvw889HGSwUCs7CwkLpo6tX'.
'Ty/+7nel6VLGDn/8N9m+eZuo1UP8iNhLau6b3RfmOsHBGTUYw9'.
'WBNeDrGB4+h/4qNLKwTnLbHj9CJw/6GoIh9Jpvq0HHcayFhYXi'.
'l3/4w9LK8vLKexfma3G/mb/3n1njTivS7tNQaaU1grQDjJ868D'.
'Axx6vmxnBrY9C9IcSbSXbavNjb/S3eN6/0m1JcKBScixcvllZW'.
'Vi6uLC8v12q1v/M8b/HxVjP//YYr32yE4dYWvShO0ogi14xwxq'.
'F4rbnxZ3cMjtpvEEeMvwA0TdOYn5/PffHFF7Vr166tvPeLXyx7'.
'nrd4+/btyg/frFo//Xgncnd67qCn78earQqcmYD3fSi1wPCTSV'.
'3gzqvm9uFOMl5nUAqFQn5paal26dKla57vf7D+6FHph9VV88af'.
'vgq79bo70e3VT2l9A3hYg4UiRALVHTCHSZvYBm4A//6quf8zoG'.
'3bpuM4acMwKr1+//SDe/dK31+/bv90/Xrcq9fduNW6rbVeC+E7'.
'gWdD2DKg4UEpBmPcm10RuScida31ntb62HAigoigDw6Gh0axWH'.
'QWFhZKi4uLZ+I4PrVer2e+u37dXPvqq6hbr7tOp1NXWq89h6/b'.
'8FBB34WGBesdcPrj38lkMkGlUuml0+mu53nR3t4eo9HoSLhMJk'.
'OlUiGdTuN5Hq7rvgA0TdO4cOFC7vPPP6/VarXldqdTu7m2lrv7'.
'7beq++BBO263b/tKrfWSXlbvwJ6CuAtDgTYiaBFMw6BSqfDxxx'.
'+rarWqGo0GN2/eZGtrC6XenAkRoVKpcPXqVWZmZmg0Gty6desF'.
'oIhIOp3Ol8vlmmVZK3fv3Lm09uc/Zwbr653ccPgoNIzvnmn99Z'.
'7W9QG46lAaM5mM2l95GIYUi0VOnz7N7OwsWmsymQzyuse5Q8Mw'.
'DNLpNDMzM5w/f/7A6AGgUkoajYa9urpayOXzUz/fvZutr68Pim'.
'F4/2y1+n2o9Q/ru7uPesPhXnyo4A+vfHp6mmazybNnz9jZ2UFr'.
'TbPZJAhe+8/aS0Mphed5NBoNABqNBqPR6MWBVWstvu/nnj9/Pv'.
'vo0aPq5uZmPBgM/qcwPf39xV/9ajU1M3Nvq9PZaw8GoT50PjdN'.
'k6mpKa5cucL58+eJ45j19XWePHnCzs4OnudhmiaWZRGGIVH05r'.
'yEYYjrumxubrKxsfFyDQJ6NBp1Pc+7C4jWumBaVm+kVL2l1H2l'.
'1G6otS+H6V6z8u3tbVzXpdFooJRicXGRqakptre3uXXr1ltrcT'.
'Qa8ezZszemWAE9rfUdYBOwtVLRbrPZ+48ff+wDvuu6Sr3MB4Dr'.
'uty6desgfa1WC3iRyrNnz4pSSmezWUzTfGtYtNYcdvC/9sMlgP'.
'n5N4cAAAAASUVORK5CYII=' ;
//==========================================================
// File: ppl_pink.png
//==========================================================
$this->imgdata_large[2][0]= 2779 ;
$this->imgdata_large[2][1]=
'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'.
'B3RJTUUH0wMLFQolY9lkpgAACmhJREFUeJy9mOtzFNl5h5+3b9'.
'Mz0kzPBWmEVtIiWYhIiC0HCDhB8lb8ISk7nzdZ5+/zJ/8BTmpT'.
'660CZLwG1pVFgBkgGIHECEaa+/T9nHzQCCQuRpCNz6mp6g893U'.
'8/c37ve3qEjxiC4OA4n/Lp/EUu/tsMM/+aEWduVBx7WhdkShcY'.
'xUH2zo0Dwod/5N6vf8V//PoGdx8M8EOFPtK9jI8BdHCcMuVSmf'.
'LxHLmSZdm2U8xIbmKETDGDZZnIy4dBbCynyGhphurEDBOlHFnn'.
'qPcyPxTOwDCOccw7w5nlBRZWylI+ny/mZ6rL1dzUZ5/IWGZU3D'.
'ZIOMQDDaJcHDVGWUbJBi9odVr0QoVSPzigIEaZ8vgSS/8wZU3/'.
'k1fylipz5dLM2WlrZqHKaGCKbEbontq3KAKWQyZfZKTgYqc9Bp'.
'2I2PcJ4ogk/UEBQcwipbFZmT13vDBx8fhnE1Ofnp9yJopFyT3X'.
'yANfks0QHSQMDaL37pOxMLIu2UyVkjVKLjyKSeuD8dAYCFkso1'.
'gYMaeWJ40T56cl8yAi/O4FSa2P6kYczIDsgVpAqcDImZPMuAB1'.
'dkLQtcc8a/bwox8IUHAxZVxGZMouSLVYwKuMkD5IxN+JSdsRJB'.
'pexuTVgYYM6EoGmxkmg3/hEhNUMr/hd7dqbOzExMn/GRDAxWZc'.
'j3I8HiXfMjF2FQowKw7pjoN6E/Llw/GBJj8qxVOMlX4ipxc/lY'.
'kl2zBLkmrTcEzMkoNoRLVidLi/9g+Z3I+1xRHX5EcAihxnbPRv'.
'OTU9kZSmpKPy9FTGrLimPZ1H+UiyGaF67w6n7E1DwMngFDxGvc'.
'w70v0xZUby5IxjlIyMssUJrJwVWkXBdbXvSvwEibcSdKCAFI16'.
'4/sc0SRo9cGAGq1DwvQFzV6DVuBiV4zYnlEts6A2TSPcSiXoxo'.
'QqJCEEFMbQ2b69o5qMiOOPqIMQkagu/aSL7waE8101WFShLjk9'.
'yxgEvjRUiyYd+gwAjY2J9VpXfZ/JEXLhDp3OR6U4T97+hEnPwx'.
'tv4HsRjy2tTQSFzQgDUnwSLBQRI+x1ZgcH87Vcv4SF19Kt0ezS'.
'1h9s0Ma25pgr/YJfnLnEysok0+ezjM6EBLldGqKIJYuDRhOQEJ'.
'Oih8X9Q0xmcXNjlCofBJgn78wxVz7L2YWf8tPPz1hnfjbjzfxN'.
'qVwutq2etZXUQSXikcXGIgUiUkJSDIQMJgYGJsaB3c7b1qQ4GZ'.
'xSkdGZIwMeNLfK6uezMnvJK3pLxeVixfvMsyVjSNSO6IV9adPG'.
'AArkEEz8oUkFmBjYGO80qfd6pCWIayD59wIKcsjcKqufn7JO/S'.
'xfyi+5c24pey5rZ09mJRNkiDdT/tzbkBr3SYkpMYpgEaIJSYhI'.
'kSOY1GhilAQk5ntDIojxCZ/kf87Pl85xbuWEnLiUy+cW3NNuJX'.
'MmY5meKf6mT7wZS+THdOjxlG06tIlIOMZxchSxcFFEGAwAGGME'.
'jwyZYSnWL3cXWiIUbUI6hO/vxXuFOV84ycmlBWthNeflTjuzTi'.
'lzJmM5s46Ej0J63/ZoPmoy6PYxtYVNhmfs0mbAND1mmKVMBY1L'.
'mxA1LN7WgXQbCApNhKJHRIM+DQbv7yQGhjnJ5NgFuXBuxpu5mD'.
'udm3LPuY7pmZLUE6L1SIJaIPFuDAqyw9lnwDYv6NFHkWJh4ZDB'.
'wCBFD3uMxsTAwcBAiElpE/KcPg36dIiOvpsRxDCyhmlP2YY9ZU'.
'v8NMb/1id+FGO0DTztkSXLOONUqeITsMkW2zwnJEIDFhYGx+A1'.
'kwK4mASkvKDPc3p0iYhRRwYUhZLUTyV6Eu0t4s1Y4kcx6W6KaM'.
'EZThcXH59RRhGEgIAddnBwNEBKqqpUtWBIF22YDIhJsbEkJqFN'.
'qLtERHs7GnUkwISEQAf0uj30bY39PzbiC6qrDu2cExJ69Nhhhz'.
'59UlIUipCQOnVi4sjG7ubJBy6um0C+he/0iDHQKIQERYyKFLqr'.
'SI/W6kJCnvOcrWSLSquC1/Jw9Ks3R0FQKHr0uMc9bnCDGjX69A'.
'H0XlcJkibN5jOe/alCZStHbjJL9lSMLkXExvCXRiDV6GZEeGeX'.
'3TvvBVQoEjfBL/v0rT75Th7VU5C8gktI6NLlMY+5yU3WWGODDf'.
'r098tHpNFNH7/2lKdXXdz7efLzVaqJIBOCmK8AJUlI6g0aV+9y'.
'9+p7AR3bMQpTBWPy7yeN6fy0jNwewfpvC9Xe+3kFoUuXe9zj5n'.
'BusEGHjh6GIAGawC2FWuvSvbbF1maFylZAsC1ISZADBiVNSJrP'.
'eX73MY//skHP85z5+fnSxQsXj//4n39cmnPn7LbZlsajBmEnBL'.
'1nuEGDG9x4aa5Ldz+h0RCuBqwBv1Wo+7vs9r7n++0MmYeAM+zB'.
'+61EK1QUEnbbtN+9Bh3Hsebn54u//PdfLq9eWl2ZnZ1dSnaSwu'.
'Pin40b9g3doKE0WoNIl65xj3v75njd3BBubQi6ExKmDWkMRKSl'.
'tSbVKQcMao1Go5Ugb0+x53nOyZMnSysrKydXLq1cWlxa/McgCB'.
'Yev3hU+GPrD3I5/q94k3pXYQY58q6B5Bs0HB//neaGx00gyWaz'.
'VCoV7bquCoKAnZ0dfN/f03egLGj0m3XQNE1jdnY2/+WXXy6trq'.
'6uzP3oR5eCIFi4detW5feXL1vr679Let37zVB3/mQytjXJwmSB'.
'wikHp9ShY0RESqObwPrr5oBERKhUKly4cIFqtUq9XufmzZtsbW'.
'2hXvuDwTTNtxZq8TyvsLy8vLS4uLgahOHphw8elL69fNlc++qr'.
'uFOrNXPddm1cczVL5f5P+Lv5MuOJgTGxwYbZpZsCdeAq8M1Bcw'.
'CGYeC6LtVqlRMnTjAyMkKn0yGXyx0N0LZt03Ec1zCMSrfXO37v'.
'zp3S769csb+/ciXt1mrNdHf3ltZ6Lca8ZpJsduhtCdb2gEFJoQ'.
'xADYHuHDS3f32lFEEQUK/XGRkZoVAocP78eZaXl9FaI/Jq25Uk'.
'yWHAYrHozM/PlxYWFibTND32sFbLXrtyxVz76qukXas1M61WTW'.
'm99gx+20TdN9jqtfjP7QzOwwYNp037Zd0DukDnIByA1pqdnR2+'.
'++472u02Z8+eZWJiAsMwDsEBRNGBzYJpmsaJEyfyX3zxxdLS0t'.
'KlVqu1dP3q1cLta9ekU6u1dat1J9b6Sk9kraV1rYXegW7apDYw'.
'kFY6fPc4MNTw88bwfZ/NzU2UUnieRxAEiAiGcXiXfcigiIjruo'.
'VyubxkWdbK7fX1xWvffFMInjzBM82uMT5+p++6V1UUrSe7u03t'.
'+8lezlKt3gHyl0aSJDQaDa5fv876+vo+w6FzDq1BpZRsb2/bly'.
'9f9vL5/Njdu3fzG0+eMJHNxsfn532vXN5NPG/7abPZal6/Hvfe'.
'kroPHfsm98f7AHW9Xo+//vrrlmVZm71+37QNw3JnZ9PK4uJGpV'.
'pt4Dh+vLGhsrmcfv1iHzu01m89HjIdCon2fb8TBMHtvYeRUn50'.
'1Oj4vqp3Ok1f5LYSadfr9dQfDN642P/XeF2DA+SBAuA4jkOhUK'.
'BQKESO43S11p3BYBDt7u4y+CtB/i/q7jp1GMiw2AAAAABJRU5E'.
'rkJggg==' ;
//==========================================================
// File: ppl_blue.png
//==========================================================
$this->imgdata_large[3][0]= 2284 ;
$this->imgdata_large[3][1]=
'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'.
'B3RJTUUH0wMLFRAiTZAL3gAACHlJREFUeJy9mGtv29YZgJ9zKF'.
'F3y/Q9jh05tuQkarKgbYasde0UBdZgwNou/Vqga/sD9mP2B4a1'.
'BbZ9atFPxb5sqOtmXbI19bqsluPYiR3HN90vFEWRZx/IJI5zqa'.
'x0OwBBSgR5Hj7v+55zSEFXTUgIJyA9C6/9RsjMjAyFIxxJCDc7'.
'iBqKgyZACGg3G2x9+xXf/fG33P3mC9qNKsp1O+1JdkEnQTdgIO'.
'ttCSMUi8gj072MnugllAyB9G8rBGi6RsToJTF6iuRoFi1kHKZf'.
'7fB8Iggj0/Dy23D2dakNTR3JDsXPvzstxmZGRMER1EwHhQAEgE'.
'CLhIkPD6InY9S3djGLJVBtQP1Qb4HDAyoJYQOOZkPx49nhTH9i'.
'7MUBGT7egxkJgd70wZS/CUkoZtA/fRoE1DZ2ACiv52ibReCp4e'.
'7CIEHomxDiuVdGTqUnf/ZeOjR8fpiVXZul5ZrY3bWwbdcLr/dA'.
'AAIpAwQjUWIjQ+g9HZvswiCgBVF9/SI6OSLGzo0i+oLi6+Utbq'.
'+bKEftgwOE/0Ohocf66M+cBjo22U2RQLIHMhmYnvaOpR9S8bSU'.
'UqCURGpRkuMZMm9cIvPGJZLj0yBjT2LprkiSkykx9cuXIhOnUs'.
'm+QNC2XdG02ggBTcvFabsPWwTPpBAChSCgh4kYBpoeplWp47Qs'.
'7EYDt21xINzd5GCAxLExRl89Z+nHjpbKMmjbmkgfDzI0JEW53K'.
'Jaa6NcAOEX8v52uJzsBlAS6u0hcnTIccPRqhWPCUcLD+s1EaUp'.
'HCEhEMCyHNpt9SjgIU12A6iw6xb123vYhaaKjB9tlgMD5X+uBp'.
'zdkpg6azA8EaNQtKlVba+Xez4eCntnJrsDdFsW5nYFpxlFN846'.
'DXe8utkM4mhi+EgQmjYbS2WqexZKk6BpjwJ2YlK5VjeA3pNDiH'.
'YjRWPzPE7tmBo8EWwGhkXx+z3uXL7D3rU97LIF8RBEAl6lK/Uo'.
'6JNM1rZ2aTcr3eUgIQOGTgbdwXMGyRejenLYTvQGbAdRuetSud'.
'OivVuFZgtCEgICghICnZoMhmlVTPR49LCAEkQUhk/B7KXe0MWf'.
'nxj8xVR/cDheK14WZmtVMJSBnlGoN6FmQq0FLfdwJgORKPHRo/'.
'Snzx4G0F/FjJ4KiOdmjPCrrx8bffnMybMv9MQGNG3rzlVqtR1B'.
'sh/CYXCD4Aag1oCW7ZnUOjSp6WFi/QNEB8Y7BfTNjZyCmUvJ0I'.
'XXT47MTp98Ybon9VZCk8cVazfqlNargsY34G7ByAlIjkHd9CCr'.
'LbBdiHViUgiECuDKYCdz8b2cywREdiYZOj8zNnLuzOTzx6ODp+'.
'OaGaqwVzBFqz0Idhz2loE7YEwBLaAJLQcKbW8qjAcBF5Jh0AMP'.
'IOHe6kxgtb3UMO2OxkF//ffK28nQqxfvm3szrtnDVa799Qb/+v'.
'NtsbNSpm3tAv8B+w7Ub0FhAyoBcMPec9oK6raXk48ziQBXQcmC'.
'pT3YqHa0mpEBkTR6wz/Jjo2cy04+fzwxdDquNfQKO7sFUbpu0c'.
'wp3JoAYsA42Bbkl4GCryUNDEM7Avm6Z/CgSYBWG8pNuFuDu1Wo'.
'tjoxKIJGeHIiM/jmK9NnX5ycuJQMtUcqXPvLDTa+qIie4hAJ1U'.
'vdrmO2HaDfB931twJgAn1A4lGT96obPHPLBbhVgUoTHHWo9aAA'.
'JVAKpyKEmQNzWRENAsL18ycKjAFN/9gCNvzLB/390MMmE7pnDi'.
'Bvwt0K5Jv3O+0oB22nJ1Vvjb/UMhOpcKknqN1OiMB2DNHU2G5s'.
'sVndpGJVcZXjX1IAlvw9PmhRQcOFPhsSDkiBrQR1G7brgs0a7D'.
'ag3FK4rguqBXarI4Nt1SJv5gls7TEWtJDRBO2GwnIs8maevFnA'.
'Gx6awLZvzeTBu4kFbLigijC47pscpx0xyDfkvtUEnlarCDtrUC'.
't2HGIhvPHVdVwqjTIrxRU2a5uUrYoP0QZ2gMvACl7+3V/LuKDq'.
'sJuDy597516+CEezIHXv7vcgXQu2l+Bvn8He9Y4AE4kgk5P9DE'.
'R6aFdq5Et5Nit3yTf3m9sBcsAN3+D98c0Fit5JawE25r1zg1Fo'.
'5B8GFD7g+nVYnu8EUEop9XTa0N/9dUbqcphP/rDJzbUClVbpgR'.
'y2fXM3fND95qj75J8AC6BWPINfVSBieK+x+6cS5UCzCLu3oFV9'.
'GqCMx2NGOp2Znpv7aXZudsool3T5J/179sxVlHJ4kGPrP2COBX'.
'/7DmiApWCjxIMXpYNznYuXM+6TAKWUMppOZzLvv//ery5cuDCT'.
'SqVS336bCwr1JfAPB9r+2KAFwJS+OcETzZHz/7v3etl6ipz77X'.
'GAMh6PG+l0OjM3NzczOzs3k0pNnFlbW43+e/GKtMqrblSsF03V'.
'WHcJA0PjIAzvg9JTze2H67g9DjAwOTmZ+uCDD96anZ2dnZiYmF'.
'5dW41++Lvfa1fnr7qllVK9103mXNTnJgPA+YugsvB3HTaEl+Qs'.
'AZ/yeHPPDCiTyaRx5syZbGoilV1dW00szC9oV+avusuLy0Xd0X'.
'MgFkDM+zkYBZEHV8f7wwKu84zmngQoNU0LaZoWUa4K31y5qX/8'.
'4cfyyvwVN5/L10NOKNeg8UmDxoKF5Vfj1xXAgD0JrgAcvBDfel'.
'a4g4AykUgY6XR6emJiIru2ttZXq9S0K19eUcuLy8WQE8o5OAsN'.
'Ggsmpl+NpoL1g9X4UBU+C9xDgEKIwNTUVOqdd955M9mbnJ3/cj'.
'6Vu5aTheXCQXNdVeMzAwJSCGEA2XKpnF1cXIzlFnOVhJPIKdR+'.
'c88ctq4AlVKsrKzw0UcfKcC5uXqzXnNqSzb2pwLxOHP/l7Z/BN'.
'eB01LKt4HTrusKvGr8jB+hGn8MQAkYQMrfw4Nq/MFPtf+rdvDb'.
'k8QL+/5Z4Uepxm7bfwHuTAVUWpWaqAAAAABJRU5ErkJggg==' ;
//==========================================================
// File: ppl_green.png
//==========================================================
$this->imgdata_large[4][0]= 2854 ;
$this->imgdata_large[4][1]=
'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'.
'B3RJTUUH0wMLFQ4hANhluwAACrNJREFUeJytmF1zE1eagJ+3u9'.
'XdkvUty2AbmLEtEzDBgZ0UpDBOalNTUzU3czl7tct/2n+wt3M/'.
'NVM12SSTQQSyW2TA+QAJQogtYYFtyfrqL3WfvWj5g8AEjzfvhS'.
'SXjk8//Zz3Pf3qCMcJAWxMKlT4kH+jwu/FknnJSUItKFHzCrKA'.
'BggBQx5ziz/wn/yBz3hED4/oaJfSjgVoYjJJgTLTZCjohp7IGT'.
'k5aZ4kb+bRTR30Q7djj8f/kpPMUSCFedRL6W8e8qMQNE6S4xpv'.
'c5HrTPFubiJ3ZnlyOXV59rJYU5Z00h1c3d0brxAiUkScRijisk'.
'6XLTyiN3s8HuAJpniXa/q8/pt8Or+0kF8oXJm5YiydWcIpOrJu'.
'rjOQwd54AQwsMpTJYhPSoYuLQ58An/DnBQSdImXO8avsTPbqpc'.
'lLp67OXDVzMznZLGxSs2qyIRu4at8gKHQEC50kE1icxqCAdxST'.
'xjEA44tqaJlERl8uLWvvnX5PHuQfcCdxh5qq0aX76vj4WgWyXO'.
'QiNgBP8IAaddr08X8+wHFmJSQhBbPAZGoSZSt5wQs6qoNC7UEd'.
'4AEoLIQSCaCCy78Dv8Tiv1hjjW1CRj8XIAgEKqDtt9keboMJZa'.
'vMjuzQVd3Xr9prTJo+GF/jKZea95R25Lxs8jg5qFGiwDnOS0mW'.
'NE0rjNRIt3WbklUCA9mV3Zdz8OBT/JfCQLB0SKYVVjGFYSfx/E'.
'26ow4e6uDujlPFQpE0FU6P8qNTHdXJdEdda0qf0itWBVM3pa/3'.
'ccUlIECJet0cAJoeYk5EZCeS5IwEoerSxccJBwRqFFf38QCTaO'.
'TRVFKJm3NTbtLNSyh2IkhIXsvLCesEGNCWdmwyruSD/z9kUlRc'.
'3bqNlSxhJNJ43p5JITrOEis8Qtr0cXEpU/JT/pmO18n2vb42pU'.
'3JnDnHMBqyPlpnoAaxhr2llv1ZUBqEGlqYwDQMsskMOcMgVL3Y'.
'ZOQTHAcQQiIGjHCwCaiovjrv4hbcpKuJJjIcDHm685RGr4GLCx'.
'YHkAcrLoAoDSLBiAQrMkjqybHJCbxgh+7xAC1MpsgzwRwD3qHL'.
'WyTIBdlAa6u2rHfXaew06PV78ZZjAwleNnkolECoH5i090wOcY'.
'+TgwYzFHiPi1zkOkXexeAMASnVU+LiyiA1wFUuaqggACLizeWw'.
'ycMzyssmVYKkbpGyC5T+OUALk2mKLHKWf+ED/az+YW42d66YL+'.
'aNrmEEzQCFEnKw368EgEvcN1m80eTIQIt0TFOjMJHkzNEBBYPp'.
'sblf8QHzrORO5JaWZ5ZLl6cuJyyxpNPv4PZdoT+GyIxBfI5uUg'.
'eJMCwP2/bIHO1JEudcgUUWOceKNq99mCvnzs5PzRcuTV4y5mRO'.
'SMIjo47z5S7a94oQCNKgJsZwO7D/IDNg3/LLhRNXt4JohBb4aG'.
'82GLdXcf93mQ+Y43r2RHZp+cRy6cqJK4l8MS+tdItaqiYtc0Mm'.
'QpfJARh98HYh9IiXVcaAo58wGb+LBAjbSPgCOcoSa0wzxXtc08'.
'/pv8mfyL+9MLVQvDJ1JVHJV6SZbFI1qtTsB+KlehRtRTGE8Afo'.
'P4DRcAxiEudhAHjjzz+ubgX4oHowakHQOlqzICQwyVPITGVOXi'.
'xfLF6aumzmczl5lHzMff2+fCdPaGttEkXoLQAO9B7C6EugPYby'.
'gVPjGXc5eIbNAJPjGwiAbaAJUQv8wVG7GROkJFpyOqn/ovgLba'.
'44L0+sDaraXb6jzq7aBQWjBOyUoHcaopOgmaA3IRyNDZnA1HjO'.
'HSBkr7eEFDAEngHrQCf+/s2A8cSiSkqcKUeeTjwFy2Jd78t3+L'.
'TR4itIiBLwLQhzkJyB5Cx4HXDaENVQCBAQcRqFIHTRaBIvuYXg'.
'AdsouuNxEL0ZUBHnSQp66R73zYfUtQ6OytKT8RckQAJQoLtgO5'.
'BJgj0D/WfgdyHaAHx8THoUcbGx8ciwhUl3bDEiToURPooeI7pH'.
'MziK9Yd9nU5a6GgKjOH41vsgI4hAcyC5AZkapF+AoYNrjjsuhx'.
'FbtPmeB5ykyQQzTPAWAQWC8S9oAI0QRRuPb9jkmyMZNAOTklvC'.
'GGYZaFkGmkVAh8h4DtKFMIBunG+pB5B5AIkGBDsQ+qBiL20caj'.
'zhJknq5KlgMkLjJHJos4kYEbFJi5vc5eYbATVN02bNWe19+32t'.
'aJWlFm3wbf8Rz5NbDFJdlOFBF/g7cBf0JkrbBb+F6j1DOduEkU'.
'8bWCOiSofPWadBnSZDWmgUkEMGhZCINut8S/0NBtPptFlZrBSu'.
'vnt1+ndnflfIp9OJ/279Ubbbd+lP7KBKPoEBsgnqLph/BRzwdS'.
'LnBUFvHcfdpRsGPAGqwMco6jynz+e0SPKYCHMfLX5VKHwcenR+'.
'Igd1XTcqlUr+xn/cePv91fevzy8sLO2OtrOpWkqL7gXKSAVRdh'.
'ZFEmEXoYkwBNqovoc/3GHH3aUR+jwC1oD/AWrANi4hGwyBzqEG'.
'Vvb77Dgi0eT1VZzJZMxKpVJYXV1dXF1dXVm6sPSvruue3Xzcyj'.
'6/syvDzwj0lNazK6Fj5LFCRZouZpBABj6jXouu3+Np6HNvDHaf'.
'g91t74msbMuOJicnSSaTKKUQEUQEpRSO69But1/dB0VEm5uby9'.
'y4cWNpdXX1+sLCworrume//PuXpeqnVeOban0U1PW2kcx+O9L7'.
'Te9sUB4lWFR9SqNtNGcHx+/RDD2+Am4D94CnQA8OjjlEhMnyJC'.
'srK8zOzu7BiYioMAzZ2Njg9u3brwIqpSSXy2WXl5eXLly4sOo4'.
'zoV6vV6oflrVP/7Tx8Hmw1Zb6ydqmpWp7ha8h4O3gjOhzVANmF'.
'XPMNQWvdDnCXCXuHR+APqH4fbCtm2mp6eZn59H13WJuYXRaKSU'.
'UiSTyVcBdV3XDcOwRaTU7/en19bWCn/79G+JL/76RbhZ22y7u+'.
'6ahl71nPDz/nO17m7wAxlabFOihy4+DvAcqAMbPzZ3OFzX5dmz'.
'Z2iahoiosUUVhiGNRgPHcV4GzGQy5uLiYuH8+fMzo9FoslarJW'.
'9+elP75E+fBJu1zY7qqpqBUW3T/niohnVvy+1zm5aVtp+WE2XT'.
'nrHFzbjh1tYLz3XdPjD4R3BKKba2tqhWq4dzUO3noBPn4H5PKy'.
'LaO++8U7hx48byhQsXVne7u6tf3/v64t3P7mbq9+odt+OuaWi3'.
'PLxbW2ytubjbQCgiMnt6VlaurWgz0zM0m02q1WrUaDSUUuqI56'.
'ivDxE5MCgiYllWtlwuL5mmufLV/a/O/uXPf9Ff1F+80Lv6Yx29'.
'2qHzyZBh3cdvc7gaTZuZkzPh/Py8ACqVSv1/uPZDKXUAGEWRtF'.
'qtxEcffZTL5XLF+2v39fqjeivshA/TpP83JLwzYFBzcA4370Cc'.
'S81nTRBUs9lkOByi1GuOPI4Rh3+26JZlnSkWi781DOPXvV4v3+'.
'/2G0R8kSBxB/jew+tERK+c49m2TblcxrZtXNfl+fPneJ6HZVmU'.
'y2VJJpNyaJ9TSinlOA5bW1u4rntkQA0oAG8D54gb9W3ianxM3A'.
'e/cn73U3Hq1Cm5du2aPjs7a+ztcSIShmE4ajQa6tatWzQajZ+0'.
'fbiKI+It4SvijVUj7kL2qvGfgkskEqTTaZmcnDROnTplJhIJTU'.
'QiwPd9P/Q8T6XTaQzDIAiCfzjP/wFVfszuFqdHXgAAAABJRU5E'.
'rkJggg==' ;
//==========================================================
// File: pp_red.png
//==========================================================
$this->imgdata_small[0][0]= 384 ;
$this->imgdata_small[0][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'.
'B3RJTUUH0wMJFhouFobZrQAAAQ1JREFUeJyV1dFtwyAQBuD/og'.
'xQdYxa8gRY6hJ0jK6QdohMkTEuE5wUj5ERen05IoLvID7Jkn2G'.
'j8MgTMyMXqRlUQBYq9ydmaL2h1cwqD7l30t+L1iwlbYFRegY7I'.
'SHjkEifGg4ww3aBa/l4+9AhxWWr/dLhEunXUGHq6yGniw3QkOw'.
'3jJ7UBd82n/VVAlAtvsfp98lAj2sAJOhU4AeQ7DC1ubVBODWDJ'.
'TtCsEWa6u5M1NeFs1NzgdtuhHGtj+9Q2IDppQUAL6Cyrlz0gDN'.
'ohSMiJCt861672EiAhEhESG3woJ9V9OKTkwRKbdqz4cHmFLSFg'.
's69+LvAZKdeZ/n89uLnd2g0S+gjd5g8zzjH5Y/eLLi+NPEAAAA'.
'AElFTkSuQmCC' ;
//==========================================================
// File: pp_orange.png
//==========================================================
$this->imgdata_small[1][0]= 403 ;
$this->imgdata_small[1][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'.
'B3RJTUUH0wMJFhwAnApz5AAAASBJREFUeJyN1dFthDAMBuDf7S'.
'3BCm2VCRKpS4QxbhikW6IewzcBqm6Fm6JyH7iEEByCn5AJH38g'.
'BBIRHNUzBAWAGNfe/SrUGv92CtNt309BrfFdMGPjvt9CD8Fyml'.
'ZZaDchRgA/59FDMD18pvNoNyHxMnUmgLmPHoJ+CqqfMaNAH22C'.
'fgqKRwR+GRpxGjXBEiuXDBWQhTK3plxijyWWvtKVS5KNG1xM8I'.
'OBr7geV1WupDqpmTAPKjCqLhxk/z0PImQmjKrAuI6vMXlhFroD'.
'vfdqITXWqg2YMSJEAFcReoag6UXU2DzPG8w5t09YYsAyLWvHrL'.
'HUy6D3XmvMAAhAay8kAJpBosX4vt0G4+4Jam6s6Rz1fgFG0ncA'.
'f3XfOQcA+Acv5IUSdQw9hgAAAABJRU5ErkJggg==' ;
//==========================================================
// File: pp_pink.png
//==========================================================
$this->imgdata_small[2][0]= 419 ;
$this->imgdata_small[2][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'.
'B3RJTUUH0wMJFhsQzvz1RwAAATBJREFUeJyd1MFthDAQheF/oi'.
'gF+JYWQKICkCJRA1vGtrDbxFbhGvY0HVjCLeS2BeTiHFgTB2wg'.
'eRISstCnmcG2qCpbuXf3ADBQzWsPfZfS9y9HsEu4/Fo33Wf4Fx'.
'gxL3a1XkI3wbTNXHLoboVeLFUYDqObYBy+Fw/Uh9DdCmtOwIjF'.
'YvG76CZoOhNGRmpO8zz30CJoOhMAqlDxFzQLppgXj2XaNlP7FF'.
'GLL7ccMYCBgZERgCvXLBrfi2DEclmiKZwFY4tp6sW26bVfnede'.
'e5Hc5dC2bUgrXGKqWrwcXnNYDjmCrcCIiQgDcFYV05kQ8SXmnB'.
'NgPiVN06wrTDGAhz5EWY/FOccTk+cTnHM/YNu2YYllgFxCWuUM'.
'ikzGx+2Gc+4N+CoJW8n+5a2UKm2aBoBvGA6L7wfl8aoAAAAASU'.
'VORK5CYII=' ;
//==========================================================
// File: pp_blue.png
//==========================================================
$this->imgdata_small[3][0]= 883 ;
$this->imgdata_small[3][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAACi1'.
'BMVEX///8AAAAAADMAAGYAAJkAAMwAAP8zAAAzADMzAGYzAJkz'.
'AMwzAP9mAABmADNmAGZmAJlmAMxmAP+ZAACZADOZAGaZAJmZAM'.
'yZAP/MAADMADPMAGbMAJnMAMzMAP//AAD/ADP/AGb/AJn/AMz/'.
'AP8AMwAAMzMAM2YAM5kAM8wAM/8zMwAzMzMzM2YzM5kzM8wzM/'.
'9mMwBmMzNmM2ZmM5lmM8xmM/+ZMwCZMzOZM2aZM5mZM8yZM//M'.
'MwDMMzPMM2bMM5nMM8zMM///MwD/MzP/M2b/M5n/M8z/M/8AZg'.
'AAZjMAZmYAZpkAZswAZv8zZgAzZjMzZmYzZpkzZswzZv9mZgBm'.
'ZjNmZmZmZplmZsxmZv+ZZgCZZjOZZmaZZpmZZsyZZv/MZgDMZj'.
'PMZmbMZpnMZszMZv//ZgD/ZjP/Zmb/Zpn/Zsz/Zv8AmQAAmTMA'.
'mWYAmZkAmcwAmf8zmQAzmTMzmWYzmZkzmcwzmf9mmQBmmTNmmW'.
'ZmmZlmmcxmmf+ZmQCZmTOZmWaZmZmZmcyZmf/MmQDMmTPMmWbM'.
'mZnMmczMmf//mQD/mTP/mWb/mZn/mcz/mf8AzAAAzDMAzGYAzJ'.
'kAzMwAzP8zzAAzzDMzzGYzzJkzzMwzzP9mzABmzDNmzGZmzJlm'.
'zMxmzP+ZzACZzDOZzGaZzJmZzMyZzP/MzADMzDPMzGbMzJnMzM'.
'zMzP//zAD/zDP/zGb/zJn/zMz/zP8A/wAA/zMA/2YA/5kA/8wA'.
'//8z/wAz/zMz/2Yz/5kz/8wz//9m/wBm/zNm/2Zm/5lm/8xm//'.
'+Z/wCZ/zOZ/2aZ/5mZ/8yZ///M/wDM/zPM/2bM/5nM/8zM////'.
'/wD//zP//2b//5n//8z///9jJVUgAAAAAXRSTlMAQObYZgAAAA'.
'FiS0dEAIgFHUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElN'.
'RQfTAwkWGTNerea3AAAAYUlEQVR4nHXNwQ3AIAxDUUfyoROxRZ'.
'icARin0EBTIP3Hp1gBRqSqYo0seqjZpnngojlWBir5+b8o06lM'.
'ha5uFKEpDZulV8l52axhVzqaCdxQp32qVSSwC1wN3fYiw7b76w'.
'bN4SMue4/KbwAAAABJRU5ErkJggg==' ;
//==========================================================
// File: pp_green.png
//==========================================================
$this->imgdata_small[4][0]= 447 ;
$this->imgdata_small[4][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAA'.
'B3RJTUUH0wMJFhkLdq9eKQAAAUxJREFUeJyN1LFVwzAQxvH/8f'.
'IeDS0FLKABlN6eIwPYAzCHB0gWYI2jj+i1ABUTQN4TRSQ7iiWZ'.
'qxLn9Mt9ydmiqrSq930AYFiu6YdKrf/hP1gYQn6960PxwBaYMG'.
'E9UA3dBFtVQjdBOQmBakLennK0CapRwbZRZ3N0O/IeEsqp3HKL'.
'Smtt5pUZgTPg4gdDud+6xoS97wM2rsxxmRSoTgoVcMZsXJkBho'.
'SmKqCuOuEtls6nmGMFPTUmxBKx/MeyNfQGLoOOiC2ddsxb1Kzv'.
'ZzUqu5IXbGDvBJf+hDisi77qFSuhq7Xpuu66TyJLRGbsXVUPxV'.
'SxsgkzDMt0mKT3/RcjL8C5hHnvJToXY0xYRZ4xnVKsV/S+a8YA'.
'AvCb3s9g13UhYj+TTo93B3fApRV1FVlEAD6H42DjN9/WvzDYuJ'.
'dL5b1/ji+/IX8EGWP4AwRii8PdFHTqAAAAAElFTkSuQmCC' ;
}
}
?>

View File

@ -1,174 +0,0 @@
<?php
/**
* imgdata_squares.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: IMGDATA_SQUARES.INC
// Description: Base64 encoded images for squares
// Created: 2003-03-20
// Ver: $Id: imgdata_squares.inc.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Squares extends ImgData {
protected $name = 'Squares';
protected $an = array(MARK_IMG_SQUARE =>'imgdata');
protected $colors = array('bluegreen','blue','green',
'lightblue','orange','purple','red','yellow');
protected $index = array('bluegreen' =>2,'blue'=>5,'green'=>6,
'lightblue'=>0,'orange'=>7,'purple'=>4,'red'=>3,'yellow'=>1);
protected $maxidx = 7 ;
protected $imgdata ;
function __construct() {
//==========================================================
//sq_lblue.png
//==========================================================
$this->imgdata[0][0]= 362 ;
$this->imgdata[0][1]=
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAIAAADZrBkAAAAABm'.
'JLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsRAAALEQF/ZF+RAAAA'.
'B3RJTUUH0wMLFgojiPx/ygAAAPdJREFUeNpj/P377+kzHx89/c'.
'VAHNBQ5VBX52HavPWWjg6nnDQbkXoUFTnnL7zD9PPXrz17HxCj'.
'E6Jn6fL7H7/+ZWJgYCBGJ7IeBgYGJogofp1oehDa8OjE1IOiDa'.
'tOrHoYGBhY0NwD0enirMDAwMDFxYRVD7ptyDrNTAU0NXix6sGu'.
'jYGBgZOT9e/f/0xMjFyczFgVsGAKCfBza2kKzpl3hIuT1c9Xb/'.
'PW58/foKchJqx6tmy98vbjj8cvPm/afMnXW1JShA2fNmQ9EBFc'.
'Opnw6MGjkwm/Hlw6mQjqwaqTiRg9mDoZv//4M2/+UYJ64EBWgj'.
'cm2hwA8l24oNDl+DMAAAAASUVORK5CYII=' ;
//==========================================================
//sq_yellow.png
//==========================================================
$this->imgdata[1][0]= 338 ;
$this->imgdata[1][1]=
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAWl'.
'BMVEX////+/+H+/9/9/9v8/8P8/8H8/7v8/7n6/4P5/335/3n5'.
'/3X4/1f4/1P3/031/w30/wn0/wPt+ADp9ADm8ADk7gDc5gDa5A'.
'DL1ADFzgCwuACqsgClrABzeAC9M0MzAAAAAWJLR0QAiAUdSAAA'.
'AAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9MDCxYEDlOgDj'.
'EAAAB+SURBVHjaVcpbCsQgDEDRGERGKopjDa2a/W9zfLWj9/Nw'.
'Ac21ZRBOtZlRN9ApzSYFaDUj79KIorRDbJNO9bN/GUSh2ZRJFJ'.
'S18iorURBiyksO8buT0zkfYaUqzI91ckfhWhoGXTLzsDjI68Sz'.
'pGMjrzPzauA/iXk1AtykmvgBC8UcWUdc9HkAAAAASUVORK5CYI'.
'I=' ;
//==========================================================
//sq_blgr.png
//==========================================================
$this->imgdata[2][0]= 347 ;
$this->imgdata[2][1]=
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAZl'.
'BMVEX////0+vv0+vrz+fry+frv+Png7e/d7e/a6+zY6+250tSz'.
'0tSyztCtztGM0NWIz9SDzdNfsLVcrrRZrbJOp61MpqtIr7dHn6'.
'RErrZArLQ6q7M2g4kygYcsp68npa4ctr8QZ20JnqepKsl4AAAA'.
'AWJLR0QAiAUdSAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU'.
'1FB9MDCxYEByp8tpUAAAB7SURBVHjaVcjRFoIgDADQWZpWJpjY'.
'MsnG//9kzIFn3McLzfArDA3MndFjrhvgfDHFBEB9pt0CVzwrY3'.
'n2yicjhY4vTSp0nbXtN+hCV53SHDWe61dZY+/9463r2XuifHAM'.
'0SoH+6xEcovUlCfefeFSIwfTTQ3fB+pi4lV/bTIgvmaA7a0AAA'.
'AASUVORK5CYII=' ;
//==========================================================
//sq_red.png
//==========================================================
$this->imgdata[3][0]= 324 ;
$this->imgdata[3][1]=
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAXV'.
'BMVEX////++Pn99/j99ff99fb98/X98/T98PL55uj43+P24+bw'.
'kKPvjaHviJ3teJHpxMnoL2Pjs73WW3rWNljVWXnUVnbUK1DTJk'.
'3SUHPOBz/KQmmxPVmuOFasNFOeIkWVka/fAAAAAWJLR0QAiAUd'.
'SAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9MDCxYEHd'.
'ceT+8AAABtSURBVHjaVchbAkMwEAXQq6i3VrQiQfa/zDYTw8z5'.
'PCjGt9JVWFt1XWPh1fWNdfDy+tq6WPfRUPENNKnSnXNWPB4uv2'.
'b54nSZ8jHrMtOxvWZZZtpD4KP6xLkO9/AhzhaCOMhJh68cOjzV'.
'/K/4Ac2cG+nBcaRuAAAAAElFTkSuQmCC' ;
//==========================================================
//sq_pink.png
//==========================================================
$this->imgdata[4][0]= 445 ;
$this->imgdata[4][1]=
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAApV'.
'BMVEX////6+Pz69/v49Pr38/r17/jr4+/l3Onj2efh1ua/L+i+'.
'q8m+Lue9Lua8qsS8LuW8LeS7pca5LOG4LN+2Y9O2YNW1ZdO1Kt'.
'y0atC0aNGzb82zbc6zKtuzKdqycsuwa8qtJtOISZ2GRpuFN6GE'.
'NqCDQpmCMZ+BPpd/LJ1/K519S5B9Jpx9Jpt9JZt6RY11BJZ1BJ'.
'V0BJV0BJRzBJNvNoRtIoJUEmdZ/XbrAAAAAWJLR0QAiAUdSAAA'.
'AAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9MDCxYDF3iKMD'.
'YAAACeSURBVHjaVczbEoIgGARgCiMtrexoWpaa2FHUgvd/tH4Y'.
'BnEvv9ldhNPradPnnGBUTtPDzMRPSIF46SaBoR25dYjz3I20Lb'.
'ek6BgQz73Il7KKpSgCO0pTHU0886J1sCe0ZYbALjGhjFnEM2es'.
'VhZVI4d+B1QtfnV47ywCEaKeP/p7JdLejSYt0j6NIiOq1wJZIs'.
'QTDA0ELHwhPBCwyR/Cni9cOmzJtwAAAABJRU5ErkJggg==' ;
//==========================================================
//sq_blue.png
//==========================================================
$this->imgdata[5][0]= 283 ;
$this->imgdata[5][1]=
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAQl'.
'BMVEX////4+fz39/z19vvy8vru7/ni4+7g4fHW1ue8vteXmt6B'.
'hdhiZ7FQVaZETcxCSJo1Oq4zNoMjKakhJHcKFaMEC2jRVYdWAA'.
'AAAWJLR0QAiAUdSAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0'.
'SU1FB9MDCxYDN0PkEP4AAABfSURBVHjaVchHAoAgDATAVcCCIF'.
'j4/1elJEjmOFDHKVgDv4iz640gLs+LMF6ZUv/VqcXXplU7Gqpy'.
'PFzBT5qml9NzlOX259riWHlS4kOffviHD8PQYZx2EFMPRkw+9Q'.
'FSnRPeWEDzKAAAAABJRU5ErkJggg==' ;
//==========================================================
//sq_green.png
//==========================================================
$this->imgdata[6][0]= 325 ;
$this->imgdata[6][1]=
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAXV'.
'BMVEX////2+vX1+vX1+fT0+fPz+PPx9/Dv9u7u9e3h7uHe697a'.
'6dnO2s3I1sa10LOvza2ay5aEwYBWlE9TqE5Tkk1RkEpMrUJMg0'.
'hKiUNGpEFBojw8oTcsbScaYBMWlwmMT0NtAAAAAWJLR0QAiAUd'.
'SAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9MDCxYEFd'.
'nFx90AAABuSURBVHjaVc9HAoAgDADB2HuJWLDx/2cKBITscW4L'.
'5byzMIWtZobNDZIZtrcCGZsRQ8GwvRSRNxIiMuysODKG3alikl'.
'ueOPlpKTLBaRmOZxQxaXlfb5ZWI9om4WntrXiDSJzp7SBkwMQa'.
'FEy0VR/NAB2kNuj7rgAAAABJRU5ErkJggg==' ;
//==========================================================
//sq_orange.png
//==========================================================
$this->imgdata[7][0]= 321 ;
$this->imgdata[7][1]=
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAAUV'.
'BMVEX/////8+n/8uf/8OP/59H/5Mv/zqH/zJ3/ypv/yJf/vYH/'.
'u33/uXn/n0n/nUX/m0H/lzn/ljf/lDP/kS3/kCv/iR//hxv/fg'.
'n/fAX/eQDYZgDW6ia5AAAAAWJLR0QAiAUdSAAAAAlwSFlzAAAL'.
'EgAACxIB0t1+/AAAAAd0SU1FB9MDCxYEJIgbx+cAAAB2SURBVH'.
'jaVczRCoQwDETRbLAWLZSGUA35/w/dVI0283i4DODew3YESmWW'.
'kg5gWkoQAe6TleUQI/66Sy7i56+kLk7cht2N0+hcnJgQu0SqiC'.
'1SzSIbzWSi6gavqJ63wSduRi2f+kwyD5rEukwCdZ1kGAMGMfv9'.
'AbWuGMOr5COSAAAAAElFTkSuQmCC' ;
}
}
?>

View File

@ -1,168 +0,0 @@
<?php
/**
* imgdata_stars.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: IMGDATA_STARS.INC
// Description: Base64 encoded images for stars
// Created: 2003-03-20
// Ver: $Id: imgdata_stars.inc.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Stars extends ImgData {
protected $name = 'Stars';
protected $an = array(MARK_IMG_STAR => 'imgdata');
protected $colors = array('bluegreen','lightblue','purple','blue','green','pink','red','yellow');
protected $index = array('bluegreen'=>3,'lightblue'=>4,'purple'=>1,
'blue'=>5,'green'=>0,'pink'=>7,'red'=>2,'yellow'=>6);
protected $maxidx = 7 ;
protected $imgdata ;
function __construct() {
//==========================================================
// File: bstar_green_001.png
//==========================================================
$this->imgdata[0][0]= 329 ;
$this->imgdata[0][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAAUV'.
'BMVEX///////+/v7+83rqcyY2Q/4R7/15y/1tp/05p/0lg/zdX'.
'/zdX/zVV/zdO/zFJ9TFJvDFD4yg+8Bw+3iU68hwurhYotxYosx'.
'YokBoTfwANgQFUp7DWAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgF'.
'HUgAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJj'.
'CRyxgTAAAAcUlEQVR4nH3MSw6AIAwEUBL/IKBWwXL/g0pLojUS'.
'ZzGLl8ko9Zumhr5iy66/GH0dp49llNPB5sTotDY5PVuLG6tnM9'.
'CVKSIe1joSgPsAKSuANNaENFQvTAGzmheSkUpMBWeJZwqBT8wo'.
'hmysD4bnnPsC/x8ItUdGPfAAAAAASUVORK5CYII=' ;
//==========================================================
// File: bstar_blred.png
//==========================================================
$this->imgdata[1][0]= 325 ;
$this->imgdata[1][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'.
'BMVEX///+/v79uRJ6jWPOSUtKrb+ejWO+gWPaGTruJTr6rZvF2'.
'RqC2ocqdVuCeV+egV/GsnLuIXL66rMSpcOyATbipY/OdWOp+VK'.
'aTU9WhV+yJKBoLAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'.
'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJwynv1'.
'XVAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'.
'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'.
'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'.
'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ;
//==========================================================
// File: bstar_red_001.png
//==========================================================
$this->imgdata[2][0]= 325 ;
$this->imgdata[2][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'.
'BMVEX///+/v7+eRFHzWG3SUmHnb37vWGr2WHG7Tlm+TljxZneg'.
'Rk3KoaXgVmXnV2nxV227nJ++XGzErK3scIS4TVzzY3fqWG2mVF'.
'zVU2PsV2rJFw9VAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'.
'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJzCI0C'.
'lSAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'.
'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'.
'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'.
'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ;
//==========================================================
// File: bstar_blgr_001.png
//==========================================================
$this->imgdata[3][0]= 325 ;
$this->imgdata[3][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'.
'BMVEX///+/v79Ehp5Yx/NSq9Jvw+dYwu9YzfZOmbtOmb5myPFG'.
'gqChvcpWteBXvedXxvGcsbtcpb6su8RwzOxNmrhjyvNYwupUjK'.
'ZTr9VXwOyJhmWNAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'.
'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJTC65k'.
'vQAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'.
'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'.
'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'.
'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ;
//==========================================================
// File: bstar_blgr_002.png
//==========================================================
$this->imgdata[4][0]= 325 ;
$this->imgdata[4][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'.
'BMVEX///+/v79EnpxY8/FS0dJv5+dY7+9Y9vBOubtOur5m8fFG'.
'nKChycpW3uBX5+ZX8e2curtcvrqswsRw7OdNuLZj8/BY6udUpK'.
'ZT1dRX7OtNkrW5AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'.
'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJgXHeN'.
'wwAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'.
'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'.
'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'.
'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ;
//==========================================================
// File: bstar_blue_001.png
//==========================================================
$this->imgdata[5][0]= 325 ;
$this->imgdata[5][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'.
'BMVEX///+/v79EY55Yi/NSetJvledYiO9YkPZOb7tObr5mkvFG'.
'X6ChrcpWgOBXhedXi/Gcpbtcf76sssRwnOxNcbhjk/NYiepUbK'.
'ZTfdVXh+ynNEzzAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'.
'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJhStyP'.
'zCAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'.
'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'.
'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'.
'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ;
//==========================================================
// File: bstar_oy_007.png
//==========================================================
$this->imgdata[6][0]= 325 ;
$this->imgdata[6][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'.
'BMVEX///+/v7+ejUTz11jSvVLn02/v1lj21li7q06+r07x2mag'.
'lUbKxKHgy1bnz1fx1Ve7t5y+qlzEwqzs03C4pE3z2WPqz1imml'.
'TVv1Ps01dGRjeyAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'.
'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJjsGGc'.
'GbAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'.
'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'.
'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'.
'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ;
//==========================================================
// File: bstar_lred.png
//==========================================================
$this->imgdata[7][0]= 325 ;
$this->imgdata[7][1]=
'iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAMAAABsDg4iAAAATl'.
'BMVEX///+/v7+eRJPzWN3SUr7nb9TvWNj2WOS7Tqi+TqnxZtyg'.
'Ro/KocPgVsjnV9LxV927nLa+XLTErL7scN24TarzY9/qWNemVJ'.
'jVU8LsV9VCwcc9AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgA'.
'AAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfTAxYTJxi9ZY'.
'GoAAAAcElEQVR4nH3MyQ6AIAwEUFIqiwju2///qLQmWiJxDnN4'.
'mYxSv5lqGCs2nvaLLtZx/VhGOW1MjnPJWp0zsw2wsUY2jd09BY'.
'DFmESC+BwA5UCUxhqAhqrA4CGrLpCMVGK4sZe4B+/5RLdiyMb6'.
'on/PuS9CdQNC7yBXEQAAAABJRU5ErkJggg==' ;
}
}
?>

View File

@ -1,156 +0,0 @@
<?php
/**
* jpg-config.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPG-CONFIG.INC
// Description: Configuration file for JpGraph library
// Created: 2004-03-27
// Ver: $Id: jpg-config.inc.php 1871 2009-09-29 05:56:39Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
//------------------------------------------------------------------------
// Directories for cache and font directory.
//
// CACHE_DIR:
// The full absolute name of the directory to be used to store the
// cached image files. This directory will not be used if the USE_CACHE
// define (further down) is false. If you enable the cache please note that
// this directory MUST be readable and writable for the process running PHP.
// Must end with '/'
//
// TTF_DIR:
// Directory where TTF fonts can be found. Must end with '/'
//
// The default values used if these defines are left commented out are:
//
// UNIX:
// CACHE_DIR /tmp/jpgraph_cache/
// TTF_DIR /usr/share/fonts/truetype/
// MBTTF_DIR /usr/share/fonts/truetype/
//
// WINDOWS:
// CACHE_DIR $SERVER_TEMP/jpgraph_cache/
// TTF_DIR $SERVER_SYSTEMROOT/fonts/
// MBTTF_DIR $SERVER_SYSTEMROOT/fonts/
//
//------------------------------------------------------------------------
// define('CACHE_DIR','/tmp/jpgraph_cache/');
// define('TTF_DIR','/usr/share/fonts/truetype/');
// define('MBTTF_DIR','/usr/share/fonts/truetype/');
//-------------------------------------------------------------------------
// Cache directory specification for use with CSIM graphs that are
// using the cache.
// The directory must be the filesysystem name as seen by PHP
// and the 'http' version must be the same directory but as
// seen by the HTTP server relative to the 'htdocs' ddirectory.
// If a relative path is specified it is taken to be relative from where
// the image script is executed.
// Note: The default setting is to create a subdirectory in the
// directory from where the image script is executed and store all files
// there. As ususal this directory must be writeable by the PHP process.
define('CSIMCACHE_DIR','csimcache/');
define('CSIMCACHE_HTTP_DIR','csimcache/');
//------------------------------------------------------------------------
// Various JpGraph Settings. Adjust accordingly to your
// preferences. Note that cache functionality is turned off by
// default (Enable by setting USE_CACHE to true)
//------------------------------------------------------------------------
// Deafult locale for error messages.
// This defaults to English = 'en'
define('DEFAULT_ERR_LOCALE','en');
// Deafult graphic format set to 'auto' which will automatically
// choose the best available format in the order png,gif,jpeg
// (The supported format depends on what your PHP installation supports)
define('DEFAULT_GFORMAT','auto');
// Should the cache be used at all? By setting this to false no
// files will be generated in the cache directory.
// The difference from READ_CACHE being that setting READ_CACHE to
// false will still create the image in the cache directory
// just not use it. By setting USE_CACHE=false no files will even
// be generated in the cache directory.
define('USE_CACHE',false);
// Should we try to find an image in the cache before generating it?
// Set this define to false to bypass the reading of the cache and always
// regenerate the image. Note that even if reading the cache is
// disabled the cached will still be updated with the newly generated
// image. Set also 'USE_CACHE' below.
define('READ_CACHE',true);
// Determine if the error handler should be image based or purely
// text based. Image based makes it easier since the script will
// always return an image even in case of errors.
define('USE_IMAGE_ERROR_HANDLER',true);
// Should the library examine the global php_errmsg string and convert
// any error in it to a graphical representation. This is handy for the
// occasions when, for example, header files cannot be found and this results
// in the graph not being created and just a 'red-cross' image would be seen.
// This should be turned off for a production site.
define('CATCH_PHPERRMSG',true);
// Determine if the library should also setup the default PHP
// error handler to generate a graphic error mesage. This is useful
// during development to be able to see the error message as an image
// instead as a 'red-cross' in a page where an image is expected.
define('INSTALL_PHP_ERR_HANDLER',false);
// Should usage of deprecated functions and parameters give a fatal error?
// (Useful to check if code is future proof.)
define('ERR_DEPRECATED',true);
// The builtin GD function imagettfbbox() fuction which calculates the bounding box for
// text using TTF fonts is buggy. By setting this define to true the library
// uses its own compensation for this bug. However this will give a
// slightly different visual apparance than not using this compensation.
// Enabling this compensation will in general give text a bit more space to more
// truly reflect the actual bounding box which is a bit larger than what the
// GD function thinks.
define('USE_LIBRARY_IMAGETTFBBOX',true);
//------------------------------------------------------------------------
// The following constants should rarely have to be changed !
//------------------------------------------------------------------------
// What group should the cached file belong to
// (Set to '' will give the default group for the 'PHP-user')
// Please note that the Apache user must be a member of the
// specified group since otherwise it is impossible for Apache
// to set the specified group.
define('CACHE_FILE_GROUP','www');
// What permissions should the cached file have
// (Set to '' will give the default persmissions for the 'PHP-user')
define('CACHE_FILE_MOD',0664);
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,229 +0,0 @@
<?php
/**
* jpgraph_antispam-digits.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_ANTISPAM.PHP
// Description: Genarate anti-spam challenge
// Created: 2004-10-07
// Ver: $Id: jpgraph_antispam-digits.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class HandDigits {
public $digits = array();
public $iHeight=30, $iWidth=30;
function __construct() {
//==========================================================
// d6-small.jpg
//==========================================================
$this->digits['6'][0]= 645 ;
$this->digits['6'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAEBAAMBAAAAAAAAAAAAAAAABgMEBwX/xAAvEAABAwMC'.
'BAQEBwAAAAAAAAABAgMEAAURBiESIjFRBxMUQRUWMmFTYnGRkrHC/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFhEBAQEAAAAA'.
'AAAAAAAAAAAAAAER/9oADAMBAAIRAxEAPwDslwiR3oDku8ONttsAvDiVyMcO/ET7ke5/aoOz6k1Vr5htNjW7a7M1yO3NTQU9JUDu'.
'GgrlSn8xyf6p4gXaHJvNps9/mKZtSkGdMjRwpfqAFBLLACRlZUrJONsI2717No1lbZ10kx7XGnRpKWQ/6GVGMfzEJ5VFIVtsOH6e'.
'wyKVhYsia0y22pLThSkJK1uniVgdThOM0ol+StIUhpopIyCFq3H8aUVCwnG3PGe4Rp6fLXJtMdyM0ojcIWvIz3HFnAPfrWTXb6GN'.
'WaLXDwZjVz8pKEfhuIUFg/bAz9sVJ61nt61mxJFslLtq7e5yPqiBT4UDklKw4MDpt+u+9bFiu9riXNu83R+fcr6tohuQ5HQhmK37'.
'paaC8DruScmg6X8KkjZEhbaB9KEyFYSOw26Uqd+e7Qerl5z74DY/1SomP//Z' ;
//==========================================================
// d2-small.jpg
//==========================================================
$this->digits['2'][0]= 606 ;
$this->digits['2'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEQMBIgACEQEDEQH/xAAYAAEBAQEBAAAAAAAAAAAAAAAFAAQHAv/EACsQAAEDBAEC'.
'BAYDAAAAAAAAAAIBAwQABQYRIRIxQVFhcQcTFSJSU5GU0f/EABcBAAMBAAAAAAAAAAAAAAAAAAECAwT/xAAZEQACAwEAAAAAAAAA'.
'AAAAAAAAARESUUH/2gAMAwEAAhEDEQA/AOqXm/Q8dxmOL4PPSnCSNFixx6nXnkXgRT3Te17JWbGsveueSyLZdbPItNxOKLzTLjou'.
'gYCSoSoY8ISKSbFeUrzkdlnTL1YshskiErkQnFEZaF8kkdBBVdjyi6RNL5+9F486eS/ECVkcBtDt1vZcho5viS8ZCp9C9tAIAm/F'.
'VoPRU+HRtJ5JVRP1kP0PfwP+1VKrHBMliXG4Nw8VgE4xGkuqk2S1wTUNEVdIvgpL9iL6KtNxY7WOwo9tt0RCitj0sR2uCbFPPzH1'.
'7+6rRuSRcljMBMsUy2tky045KOawZk5xtEFBJEROO3hx61kh2rPCIX3MhsyC4QmfTbC6lH8dq5212qwkiG5H6Y/9R2qm+ofxqqsL'.
'DLZ6f//Z' ;
//==========================================================
// d9-small.jpg
//==========================================================
$this->digits['9'][0]= 680 ;
$this->digits['9'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABAUGBwP/xAArEAABAwMD'.
'AgYBBQAAAAAAAAABAgMEBQYRABIhE1EUIjEzQUIHMlJhcdH/xAAWAQEBAQAAAAAAAAAAAAAAAAACAQD/xAAYEQEAAwEAAAAAAAAA'.
'AAAAAAAAAREhQf/aAAwDAQACEQMRAD8AkK7brF6X7XpMeGoKhFMLEeT4ZUheEhanF4OcZ2pTgDykk92bZpdCsi7aezLjxkIPUZiV'.
'RSCy8hah7EkZ27yM7V+iscal5bE22Lon1qNDmSKROd8Sl+Ix1lMOlIS4HGgQpbStoUCnlJz8HmsXtW3Lst2rmBAelLMRRekOwnYz'.
'Edls9QKKnOVLyk7UgcbzzrdBthqEJJwZbAI4x1U/7o1TaFa9lG36aXaZTy54VrcXUgrzsGdx+T30aNydweqVw1GS87T6Lb86Q4ha'.
'my/IAYjZBx+snKk99oOQMf1AViE65SY348hzFy6hPKnqtKz7DC1lbqyPrvJKUJ7H+M6Wrt3InP7o1brFNp4bCDGhxGAsqz69VSiQ'.
'ORwBxrrQ7itm1ac7Hp0WoGTIc3PSn0pccdcP2WorycfA1RaRHjxosZqOyhtDTSAhCf2gDAGjVHTd9sKSCumynFEZK1tIJUe58/ro'.
'1V1//9k=' ;
//==========================================================
// d5-small.jpg
//==========================================================
$this->digits['5'][0]= 632 ;
$this->digits['5'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABgIFBwT/xAAoEAABAwME'.
'AQQCAwAAAAAAAAABAgMEBQYRABIhIkEUMVFhBxNCgaH/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAv/EABcRAQEBAQAAAAAAAAAAAAAA'.
'AAABEUH/2gAMAwEAAhEDEQA/ANGvW4YVOeiRX5b4mv5Sin05IdlupPKdo/j2SO3+6TbPNQvOsTVz33KRT4csR3YUF7Dsh5OSFvug'.
'kqG4FPBxnjxpvvi4KZb1pTpU+QwxUi2Y7ZIAefUk5ATxnB9/gbtL/wCH1UpuhPUlZlMVaQ0mS8zJjqZOPfc2TwpIUonI9tw40R1r'.
'WNGq/wBdJR1XT3lqHBUnGCfkfWjRWs1ve249erQqQYjOtN1FqPUpCXQ4WIzQSsJwT0UpRwQPG0nzqyuNHobjsl9kBuWqoOoXtT1/'.
'WppZcA8lKRj64HxqU+3KpAr6plElRVKef3S4E0K9O8pLXVzKcqSsJAB9wSAca6bSoNXeuA1+5pEV+SGFNU1iKVFqI0Vdx2AJUeoz'.
'8DGlTDwG3CAf3q/pI0ah6MDhLz6U+EpXwPoaNMU//9k=' ;
//==========================================================
// d1-small.jpg
//==========================================================
$this->digits['1'][0]= 646 ;
$this->digits['1'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEwMBIgACEQEDEQH/xAAZAAADAAMAAAAAAAAAAAAAAAAABQYCBAf/xAApEAACAQMD'.
'AwQBBQAAAAAAAAABAgMEBREABiESMUEHEyJRkSNCYXGB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFxEBAQEBAAAAAAAAAAAA'.
'AAAAAAEREv/aAAwDAQACEQMRAD8A6jdd4WLbstILnc4Uq0VoWpkJknb6IjXLHJUePOlez923fcW4r1SxWlqC2UbdKirQif3Xw3yA'.
'OFAGT09/kO3OmV3a20MFRf6lIYPcpy7yRRAzgxjIy2M8YwcdiBzpX6d22VNvUlTXsFkuwkrKqNSfnK7F8OTzwrAY+l5zoxKskudN'.
'EgQPUT9PBkWF3DH+1GPxo1mLnRoAqF2VRgGOFmX/AAgY/GjRUP6hVMFv2FuFqUvUGrpDFJMBnpdyF5bsAQew7Hxzp6LZNT0yQ1DI'.
'wp0QCFBhD0jCsfLZHxbx5xxpTuvb1+v9PV7Ztk9roLPLCjmSSN3mX5ZwqjCgZX7PfWxDQb2in96pv9qq46aTE0bW4x9ceAWAYPwS'.
'PsYzoixgmheBGjIVcYCnjp/jHjHbRpe1JLn9OnopE/a0ykvjwDx47aNMXqP/2Q==' ;
//==========================================================
// d8-small.jpg
//==========================================================
$this->digits['8'][0]= 694 ;
$this->digits['8'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AFQMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAABgcEBf/EACsQAAEDAwMD'.
'AwMFAAAAAAAAAAECAwQFBhEAEiEUMVEHE0EVYYEiIzJCsf/EABYBAQEBAAAAAAAAAAAAAAAAAAIAAf/EABcRAQEBAQAAAAAAAAAA'.
'AAAAAAABERL/2gAMAwEAAhEDEQA/AKL6gVVUa0i1T5QjvTprUJMlxW4R9zgQXe/AH+kaWrntqlWjaq7gpcmotXAw82ht9yY4tch8'.
'uAFC0k7VBXPGMY51ruiaue+bThIj+7NbWqS+7HDxajFf6AlB/k44o8ZOABk4xkL0X0tZiojKrlRuGRJjugqldSlKGf6t7BuUQe3J'.
'44xxxrA1a4KVJipLidri8uLHgqOcfjOPxo0o2hdDvS1CmV2Yl6fS5ioipIQR1CAlKkLKR2UUqAI8g6NRSwuuyHab6s1ufLI/Zai7'.
'UBJOxhTS0+6B32pWSFH4CidOdWU0ukLiN1BLr0zG5Sdm3GRvcPhIT858DvjXNrVsSLnm/VIdTXS6tTnFsxZTSN3jchaTwps+O/z9'.
'tcBVq3hIX0tYqlIiQHdy5CqRHKHXEjAOMgBKjnvyRk4xrQa7OiGt1K5biYZL8SoVEpjOqkFsONtJCNwASeCQrn7aNUKnQYtLp7EC'.
'EylmLHQltptPZKQOBo1FzH//2Q==' ;
//==========================================================
// d4-small.jpg
//==========================================================
$this->digits['4'][0]= 643 ;
$this->digits['4'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAABAYHAv/EAC0QAAIBAwQA'.
'BAMJAAAAAAAAAAECAwQFEQAGEiETFDFBUmGBByIjUVNxobHR/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAIB/8QAGBEBAAMBAAAAAAAA'.
'AAAAAAAAAAERIVH/2gAMAwEAAhEDEQA/ANjM00Nxmt1xiWW31CZp5uJwoAAaOQ/n7qfcZHqO5my3q5XX7R6ijiqnNut9u4NyJ4yv'.
'JJyjYr8Xhrn5g599J7x3ulBNU7Zo7dXXXcLQ8kURYi4epYtkALjOePv1nUvbLvV7P3BZm3DR3eh88Kp7pVzBZI6iUhGWRRGWwE44'.
'HX3V+uiL1uHgt+vL/H+aNJQ3CSeCOaFqSaJ1DJKs/TqRkMOvQjvRorHE4pRDLNWLGlRHGUeYIORXs9e5B7OP31E0fmdyb/t0DJ4Q'.
'27bfx3YZzPUIoAAz7IpOD6cuxq0uNumqLfVNDOqXBoZEjnZcqhIPXH4c46+WkdoWOltu3IDDLLLVVR83UVcuPEmmcZZ2/rHoAANG'.
'GI7KIY1ijoLeEQBVCwIoAHpgY6Hy0aZe7mJ2jeHLKcEhusj6aNKgzr//2Q==' ;
//==========================================================
// d7-small.jpg
//==========================================================
$this->digits['7'][0]= 658 ;
$this->digits['7'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABgEFBwT/xAAuEAABAwIE'.
'BAQGAwAAAAAAAAABAgMEBREABiExEhMiQSMyUXEHFBclVJFhk9L/xAAXAQADAQAAAAAAAAAAAAAAAAAAAQID/8QAGREBAQEAAwAA'.
'AAAAAAAAAAAAAAEREiFR/9oADAMBAAIRAxEAPwDXq9mCjZeQ05VZ5ZST4bfEpa3VdglCbqUe+g9MZ5Uq7V8415WXoMSdQ6etgSps'.
'19wpkCMDZKUpv0FZvbi1NzpYasMDLDUbMVXrtQdbeeU23xLWkj5RlLYK0J7anW9gbAjCzkOtsVSUJUdtc6dVZK51UeaFm4LKbhpC'.
'l7EhIFkDW974GbRI2XorUVls1OTdKAOqUpR0Hc3198GITQ6k+hLwrEpoODiDenRfW23bBicg78JXxPpD0mgVOW5PAivNNpahsPW5'.
'8xxQaSVkboQnhsnYm5OHqDGp1IpsalMKjMsMIC3+XZKbJFth62/QOEfMOZqZXp9JcKZTcGmTky3meSi7xQklI81vMR+sXIz/AEgp'.
'Q0qPNu6ea8Q2jqtbp8+2w9h/OKORc/cpHjt1dDSHOtLZ4ekHW23bBjj+o9H/AB539aP94MG0+L//2Q==' ;
//==========================================================
// d3-small.jpg
//==========================================================
$this->digits['3'][0]= 662 ;
$this->digits['3'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABAUGBwL/xAArEAABBAED'.
'AwMDBQEAAAAAAAABAgMEBREABhIhMUEiMmETFZEHFkJDUdH/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAL/xAAYEQEBAQEBAAAAAAAA'.
'AAAAAAAAEQExQf/aAAwDAQACEQMRAD8A0vclruBdk3VVLLUNssGRJsZSCtqOjlgJAHvcOD6c4HnOdIbcttw1W5P29cFEhuawqTXS'.
'VsJjnCMBxKkJJx7goAde+ceJfdNxU0UNlyymyXHi6kxWUNl1S3EnkAEIHX2nv86qtTuZr9Q9+1VhRsOoYpYcgSVyAE/TdewkJxnK'.
'sBCjkdPGpnOtFMd3PqsXgfOAgD8Y0aX+11H9rDDjn8lr9yj5J+dGqsqxaw6Cc9cQZU4Sp7zTJsIrKlcUEKwhSin1JABI45GUjqOu'.
'lbOvjbc3Ts9ynjGCy445UuFLYRzbWgrT6fhSCQSMDke+pew2zYVly/d7YchNqkMJZnQpgV9J8IzwWFJyUrAJHYgjvpLbu37G5nR7'.
'vck5C3YRKYEOEVJZj8kjKypXqWvirjk9h+dB9i4faa89TDZUfKlIyT8k+To10a6KTkpcJ/0vL/7o0TS//9k=' ;
}
}
class AntiSpam {
var $iNumber='';
function __construct($aNumber='') {
$this->iNumber = $aNumber;
}
function Rand($aLen) {
$d='';
for($i=0; $i < $aLen; ++$i) {
$d .= rand(1,9);
}
$this->iNumber = $d;
return $d;
}
function Stroke() {
$n=strlen($this->iNumber);
for($i=0; $i < $n; ++$i ) {
if( !is_numeric($this->iNumber[$i]) || $this->iNumber[$i]==0 ) {
return false;
}
}
$dd = new HandDigits();
$n = strlen($this->iNumber);
$img = @imagecreatetruecolor($n*$dd->iWidth, $dd->iHeight);
if( $img < 1 ) {
return false;
}
$start=0;
for($i=0; $i < $n; ++$i ) {
$size = $dd->digits[$this->iNumber[$i]][0];
$dimg = imagecreatefromstring(base64_decode($dd->digits[$this->iNumber[$i]][1]));
imagecopy($img,$dimg,$start,0,0,0,imagesx($dimg), $dd->iHeight);
$start += imagesx($dimg);
}
$resimg = @imagecreatetruecolor($start+4, $dd->iHeight+4);
if( $resimg < 1 ) {
return false;
}
imagecopy($resimg,$img,2,2,0,0,$start, $dd->iHeight);
header("Content-type: image/jpeg");
imagejpeg($resimg);
return true;
}
}
?>

View File

@ -1,639 +0,0 @@
<?php
/**
* jpgraph_antispam.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_ANTISPAM.PHP
// Description: Genarate anti-spam challenge
// Created: 2004-10-07
// Ver: $Id: jpgraph_antispam.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class HandDigits {
public $chars = array();
public $iHeight=30, $iWidth=30;
function __construct() {
//==========================================================
// lj-small.jpg
//==========================================================
$this->chars['j'][0]= 658 ;
$this->chars['j'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABUDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAUGBAf/xAAsEAACAQMDAwMBCQAAAAAAAAAB'.
'AgMEBREAEjEGIUEUUXGBBxMVIiNSYWKC/8QAFgEBAQEAAAAAAAAAAAAAAAAAAwEC/8QAGhEAAwADAQAAAAAAAAAAAAAAAAECERIh'.
'Mv/aAAwDAQACEQMRAD8A6veK2st8zRWSyV1dUBfvHaGVI4hknsS7AFv4AyM57ayWbqeS+11xtT2etttwo4YqhEqnQs5bcAfyk4AZ'.
'SOeD441TKRTyingUBG4/ah8j684+dSFzh/BvtaslejMUu9DPQTDnLx4lQ/ONw1TGBm0jdRWqguEMghEisWilgDmNs4Ze+MEEEH40'.
'aUVFTa7JeLjRXu4GjhmnNbSfqFQVlA3rkckOjH/Q99Glmkl0C/Q06pvsvT9vttXHDF6T1KrWbs5gRgQJM+FDlQxPhjpF1XcVq+qe'.
'jEoKiOecXBqh2TDDYIXLKuP6549xk8auI6aJqV45oknWdNswkAIkGMYIxjGO2NR1F0LZY5qkWqkS1xrM0M8lMSJpY+TGrnJiQ577'.
'cEgeNHhi7D3qC3UN69M8tIakRhgrh9o748+eNGtcCiKjjpkQKlMTEg3ZwoxtHHtgfTRpYXArvp//2Q==' ;
//==========================================================
// lf-small.jpg
//==========================================================
$this->chars['f'][0]= 633 ;
$this->chars['f'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQFBgcC/8QAKxAAAgEDAwMCBQUAAAAAAAAA'.
'AQIDBBEhAAUGEjFBEyIHFFFhoRUzYnGS/8QAFQEBAQAAAAAAAAAAAAAAAAAAAQP/xAAaEQACAwEBAAAAAAAAAAAAAAAAAQIRMRIh'.
'/9oADAMBAAIRAxEAPwDcnmLoIkiSYsouC3tA++O2lU9WkqVjJ+YdhZLsQI/4/YfQm50kZP0vbmaCSU0SRNIH6sghb9INs3t38dvp'.
'akUuz8x5DwdN5peS1jV1dSipSiVUigIcdQjQ26lIB/c6r3F86SZpE/zCFJaqsihQNhRgdj3Jyfxo0jDSbXHt9Oph9RAoV3qJGltY'.
'HDOxyb/nRpV0D3RXle21m48XraOk3IUSemUaV4g4Zc9ShcDtgff+tQfwvjq34Dtku7buamFqeJKemCCMxKFsEJU+/FrX8d76sEHG'.
'aNItzr4usVNdG3S0rmRYAVwEUmyjyQLZ11x7aF4zs9DQOyzml29I2cLa/pixIHi99DFCtU9dFuLIaijo9qiYPmR2mZmB9thgAHOD'.
'4+mjUrURyrUNMZFEkkIOFuFAbsP9d/OjVIQ6Vh4tP//Z' ;
//==========================================================
// lb-small.jpg
//==========================================================
$this->chars['b'][0]= 645 ;
$this->chars['b'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABUDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAYCAwUH/8QAKxAAAQMDAwMDAwUAAAAAAAAA'.
'AQIDBAAFEQYSIRMxUSJBYQcVI2JxgqHw/8QAFQEBAQAAAAAAAAAAAAAAAAAAAQL/xAAYEQEBAQEBAAAAAAAAAAAAAAAAATERYf/a'.
'AAwDAQACEQMRAD8A6H95mxNYwLXcX+pCuilSLXJ6YSplaUELjqxwe4IJ5PIPamJ2V0bPcS7+NxCX1cHggAnIP+xSd9RyzHh2m7FQ'.
'Q1CvMNQWTjCt+HFD+PB/Y1fI1PL1HFFt0zaGblFdJQ9cJjpZiqPJUlBAKnPcEpGB5NNRKdrOl1NlgiQol4R2w4Sc5VtGf7opZteo'.
'LhdorjUSM5FnQnlR50NeHQysYxtVxlJHIPgjtRRD3xkaghs6juumdHz4+Y7RVPnt59K2mk7W+fcKWsZ7djTXMkW+xMP3GRJjwIEN'.
'HTG/CWx5wPY8AADx2NYk3SL9wukvUjGobnBkORksIbjdMANozgEqSo8qJPGO/wAVO36IsjUmBIfZfuM7epZk3F9UhSSk5O0K9Kcq'.
'8AcU3UzFuhUSBFud6nRXoz96mqmJZWg7m2dqUNhWBwdqQSP1UU5c/FFCn//Z' ;
//==========================================================
// d6-small.jpg
//==========================================================
$this->chars['6'][0]= 645 ;
$this->chars['6'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAEBAAMBAAAAAAAAAAAAAAAABgMEBwX/xAAvEAABAwMC'.
'BAQEBwAAAAAAAAABAgMEAAURBiESIjFRBxMUQRUWMmFTYnGRkrHC/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFhEBAQEAAAAA'.
'AAAAAAAAAAAAAAER/9oADAMBAAIRAxEAPwDslwiR3oDku8ONttsAvDiVyMcO/ET7ke5/aoOz6k1Vr5htNjW7a7M1yO3NTQU9JUDu'.
'GgrlSn8xyf6p4gXaHJvNps9/mKZtSkGdMjRwpfqAFBLLACRlZUrJONsI2717No1lbZ10kx7XGnRpKWQ/6GVGMfzEJ5VFIVtsOH6e'.
'wyKVhYsia0y22pLThSkJK1uniVgdThOM0ol+StIUhpopIyCFq3H8aUVCwnG3PGe4Rp6fLXJtMdyM0ojcIWvIz3HFnAPfrWTXb6GN'.
'WaLXDwZjVz8pKEfhuIUFg/bAz9sVJ61nt61mxJFslLtq7e5yPqiBT4UDklKw4MDpt+u+9bFiu9riXNu83R+fcr6tohuQ5HQhmK37'.
'paaC8DruScmg6X8KkjZEhbaB9KEyFYSOw26Uqd+e7Qerl5z74DY/1SomP//Z' ;
//==========================================================
// lx-small.jpg
//==========================================================
$this->chars['x'][0]= 650 ;
$this->chars['x'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABMDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAUHBgj/xAApEAABAwMDAwQCAwAAAAAAAAAB'.
'AgMEBQYRACFBBxIxFCJRgRNxkcHw/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/xAAWEQEBAQAAAAAAAAAAAAAAAAAAEQH/2gAMAwEA'.
'AhEDEQA/AH9t3pKvO14UykVARa/HfAlxlDKXR24V2p3z7RlPwdtMep91uWdRGHWELjuTFFtLvcC4SNznnH+21O7ttiodOq1BvC0E'.
'p9I0lSX2kgqCSklK+5PKCMAng6zV2XRO6u3lSIURtbDRShltlZHa0tW7q/0MeTwnjxq1Jiw2xc9xTLbhSVU5iaXUFfqFFILgJOCd'.
'9Gt3SXabR6REpkL8yo0RpLCFNx1qBCRjOQMHxo0pEr6o3um2LVYpMEpTVqg25lHn08dfcB9kEgfZ1LIFDuawqZRb7aQlLTzqglsg'.
'9wQdveOEqBIB425xqhQuk8qo9UKlPrlRblw2ZBeCSVKW6CcoSrI2AGOT41SKzT4dYtmdS5bIXDZhNoWgbZJ94x8AYT/GkM03oNUc'.
'uKgwqtTZDTMOU0FttqRkoHggnPkEEHRrkJ6t1SlSHYUOc6zHaWrsbQrATk5/vRqK/9k=' ;
//==========================================================
// d2-small.jpg
//==========================================================
$this->chars['2'][0]= 606 ;
$this->chars['2'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEQMBIgACEQEDEQH/xAAYAAEBAQEBAAAAAAAAAAAAAAAFAAQHAv/EACsQAAEDBAEC'.
'BAYDAAAAAAAAAAIBAwQABQYRIRIxQVFhcQcTFSJSU5GU0f/EABcBAAMBAAAAAAAAAAAAAAAAAAECAwT/xAAZEQACAwEAAAAAAAAA'.
'AAAAAAAAARESUUH/2gAMAwEAAhEDEQA/AOqXm/Q8dxmOL4PPSnCSNFixx6nXnkXgRT3Te17JWbGsveueSyLZdbPItNxOKLzTLjou'.
'gYCSoSoY8ISKSbFeUrzkdlnTL1YshskiErkQnFEZaF8kkdBBVdjyi6RNL5+9F486eS/ECVkcBtDt1vZcho5viS8ZCp9C9tAIAm/F'.
'VoPRU+HRtJ5JVRP1kP0PfwP+1VKrHBMliXG4Nw8VgE4xGkuqk2S1wTUNEVdIvgpL9iL6KtNxY7WOwo9tt0RCitj0sR2uCbFPPzH1'.
'7+6rRuSRcljMBMsUy2tky045KOawZk5xtEFBJEROO3hx61kh2rPCIX3MhsyC4QmfTbC6lH8dq5212qwkiG5H6Y/9R2qm+ofxqqsL'.
'DLZ6f//Z' ;
//==========================================================
// lm-small.jpg
//==========================================================
$this->chars['m'][0]= 649 ;
$this->chars['m'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAAAAcDBAUCBv/EAC0QAAICAQMCBAMJAAAAAAAA'.
'AAECAwQRAAUSBiETMVFhB2KhFSIyQVJxgZHB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAgED/8QAGREBAQEAAwAAAAAAAAAAAAAAAQAR'.
'EiEx/9oADAMBAAIRAxEAPwB0MI2lIdgI0Cly3kFXLEn2zx1FDdp7rbpbjUtRWKio3hyxOGQllJzkegX66rQ2qW87Zuk9S5FNVmru'.
'iywyBhjDKTkeXfSr+GRfYtq2KAO32b1BGxAZu0dyJ2DKPTxY1wPddVszycUq2Golq8jRWbcnJWwCVGMjz+VQP50atxMtm2ZUOY4l'.
'4qfUnBP0x/Z0amy4jJm10Tt2yddWasFmfaRfdrlG3UcgArnxKzJ+Fu4DqCMkcgNem2DoWav8PLfTm+FPEkuSNTnqueS5bnHIv6CG'.
'LNjJwM99bm67NB1Ht89KSxNXnr2hNDbiUc47K4KyD2GQMfmMjUnS+7vuIktTqPCaaWCqAMMojPFyw8hyYMQBnAwNJHYGXPTsW9VN'.
'jg2zf50W9zk524GAEihuz+xbIOD82jW5TkjtRPZkTkJ+4VgDhQfuj/f3OjUxl1f/2Q==' ;
//==========================================================
// lt-small.jpg
//==========================================================
$this->chars['t'][0]= 648 ;
$this->chars['t'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQDBQYH/8QAJxAAAQMDAgYDAQEAAAAAAAAA'.
'AQIDBAUGEQASEyExQVFhIjJxFSP/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAP/xAAZEQADAQEBAAAAAAAAAAAAAAAAAREhMUH/2gAM'.
'AwEAAhEDEQA/AO4BLEiEy7uG4IGxxs5IOOx76wd2XYidSp1HoD70240gcNNPbDyI6wQQpaz8E9MczkdhqtbsKYLieDk6WLKmZmmL'.
'Hk7AHVkbkLI+RQc7uRxgkfr1tx2rGu6VbToLVKkhU+kbugGf9WfaknCk5ycaX0zmaa+3JkqvW/CmzojsB9xoF6OoFK0r6HOcEDI0'.
'aefTuKX5ScMdC14HYq8n12zo1DEUcKTGg1Z+hyBwoPBVIiA/VQyOIgedhUCB4WMfXSV3UufVLcTUIqVf26K6mXDbPVRRzKT54iMg'.
'+zjtq6mtsyJjclxpKlUhSXEbkgkqWnBx4+J5e/zU0pZemPvJJQzEPDfQOrwwFY9AZ5eeYPLV6FwhoFYZuigxpkJeIjqAeIoAk9wA'.
'D46EnuD+6Nc1smDNrTlRkxqtMo1vzKhIdYgU9YDqVpISrLhHxSSd21I0aYyqP//Z' ;
//==========================================================
// li-small.jpg
//==========================================================
$this->chars['i'][0]= 639 ;
$this->chars['i'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABYDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAABwAGBP/EACcQAAEEAQMEAgIDAAAAAAAAAAEC'.
'AwQRBQAGEiExQVEHExSBFWFx/8QAFgEBAQEAAAAAAAAAAAAAAAAAAgMB/8QAGBEBAQEBAQAAAAAAAAAAAAAAAAECMRH/2gAMAwEA'.
'AhEDEQA/AE7c+5M9BeRG29t1WUfKFFYW+GvrI7WD3B9g140YD5T36rcErDjbUR6dCBdejsKUpxITXI2FUrooCh70yvxzHyIlMvuK'.
'eVSH7IKEpJoKqu/ahddLryR/aMiO187bsmrWShhp1AZS2XHHrWhNJrzdf7f7GiVcHk3sptmHkJcJ2DIftS2FrKlJPXudWuLGYeQp'.
't2fmEIckqIZaaKuSGG0lQ4gduRoFRHQ9AOgs2lOJbk9aSUlpjGvAWeSVH2VKq/2dFPw3IjyJe8s281ct3I9UoHJXGiQkD2STrSZ7'.
'Yf8AOl7JTdw5eOCz0jw3+LbYCfA9nz71msb8KMxoTGTw+5srjsipAdDqFBQBIuiOl6KrdYyJMyTCshlw2G3Fr/HiNqNNAqJJUoGl'.
'KND+h47km1bZwsvCbYYjycxIyK1qDv2yEi0hQviK8atKDcy9j//Z' ;
//==========================================================
// lp-small.jpg
//==========================================================
$this->chars['p'][0]= 700 ;
$this->chars['p'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGgAAAQUBAAAAAAAAAAAAAAAAAAECBAUGB//EAC8QAAEDAwMCBAMJAAAAAAAA'.
'AAECAwQFESEABhIiMRMVUWEHFEEWIzIzcYGRocH/xAAWAQEBAQAAAAAAAAAAAAAAAAADAgH/xAAcEQACAgIDAAAAAAAAAAAAAAAA'.
'AQIxAxESIUH/2gAMAwEAAhEDEQA/AOh703xG21DMeOyqoVNDjSzERiwU6Ep5qtZNycA97HTF13d33KWtmlt9xwkLl1NkXVxIuQgK'.
'wLj+hqBvel0qmbR8GnR22nJNZiLeeKr8nDIT1OLJucX+uPbWom7iocRpafOac5MX1ALltp/Cbi+cJH++utdh+WVNL3PNdNYpdWgx'.
'Y0qmLZSrwJJcQoOJ5XKlJFu4HbJOjVbt+V5nu7eopNRivqcdhK+bFnWwA1Y2AOcgjvj9dGlxy0g5y0xd+hNXoG24C4obizq3HZUh'.
'YHqtRHD06bG/8a0MbbG1mqekxaBSGmgkrcdcitlLfrckZIz7DUatbeFak0tyRLUwzT5vmiGm0cufEkFBJItfkD+59tKmiO12atFa'.
'eQukO3ejUxgENqTcfnE5WbkHiOnJ76N2IqI1DibabptS+zkZhtp90F2Y0S026EkAFK/qL46cXv65NVZDfxHmVCK4DE2/RX/lRFbA'.
'C5LwAyq2EtpHZI7mxPYDRqoctdESimz/2Q==' ;
//==========================================================
// le-small.jpg
//==========================================================
$this->chars['e'][0]= 700 ;
$this->chars['e'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABgDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAYEBQcB/8QAKhAAAQMCBAUEAwEAAAAAAAAA'.
'AgEDBAURAAYSIQciMTJBE0JRYRQVFoH/xAAXAQEBAQEAAAAAAAAAAAAAAAAAAgED/8QAGREAAwEBAQAAAAAAAAAAAAAAAAERAjFB'.
'/9oADAMBAAIRAxEAPwDTszvhEYCoS80BTm2bCjQRwdAzVe2yopkpJtpRUVfjEIc4V2oMerByg5Ji30oMyS3GeMunK0upfnu09MdJ'.
'p2scTmWnnGfx6HThktgLfKj7xEOqyr7QBbL41LhBzpxbcOru0LKDLdSnOHoaltNqSC4qWL0x9xbJYum69caczSaHmGmTmpDUYn4l'.
'UiqjkynzAVtwV23Ud+X4Ibpa2DCPkjhfUaRO/p8yzpb+YHhUmhbev6ZEll1lvqK3jt2XrbBgp6HVwsK3THpfEubGSoOUyFMpbJmL'.
'Deh6SgOGKti57EuY6l62JMWdJy7k3hg1LkOozEbVm7suQSkTiKtkEfP1pH664Za/QItccgI4bseTHdNxiXHLQ8yVl7V32XyioqL5'.
'TGc1ng6eYs0idczXUZscBBABWgEhEtfKNuUezwPnBhEuj8X2M21z9BR6NUX211Kk/UKKAjuhkPhL7XVf8vtgw7UPJlEyrDWFSYLb'.
'LBNF6qrzG6t0spEu6+fpL7YMXhUndp//2Q==' ;
//==========================================================
// la-small.jpg
//==========================================================
$this->chars['a'][0]= 730 ;
$this->chars['a'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABoDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAABgMEBwX/xAAvEAABAwIFAQcCBwAAAAAAAAAB'.
'AgMEBREAEiExQQYHFBUiUXGBE2EyQkNSgpHh/8QAFwEBAQEBAAAAAAAAAAAAAAAAAAMBAv/EABkRAAMBAQEAAAAAAAAAAAAAAAAB'.
'IQIRMf/aAAwDAQACEQMRAD8AfdQ1pxjqZMSn0mRUZRYDaklJCE3OawO2ttTxY4hl07qFMVs1Ku02kpPnRGhsAqz8W9T9wDjozq6o'.
'Q1lDrcZLGVcmUoZg0obpufxK3Ftt9ccqB1GgBcmLSqtVEqOZcr6ARm/kbXHt7DEtc7WTJKTJqEWvRKfLqL9QplSjuPtGVYOJKBrm'.
't+U+n94WGStZzNypmRWqckUKTbixy6jAfxPxHtCgKqFNlU5huK6pLMndSlegG4J45N8aKmTMKQRBsCNMzwB+RbHWHGEAZlPZX2hx'.
'qZIC34ygZoYUbB50JSkFXFhZR9BrpheR4fIbQ6gvurJ7q02bIQTuAOAN8x40HAxRr3TrNRpBmSHVt1KMlTyJTCsqkKAPlSf28W+c'.
'UGaD1c9HSR1HFUh9tJU45EBcAtcC9+P9wqbg8IAto9o81yputrVGpiUkgHKkqUTZI32+cKm1z1tIUgPBBAKQ4UBQH3uL3xmXSXep'.
'HVDtXStE5K5jlPU7PF3Q41+okJFkjgC+3OuNSYiSzHaLtRcW4UDMpLYSCbakDW3thhum5p//2Q==' ;
//==========================================================
// d9-small.jpg
//==========================================================
$this->chars['9'][0]= 680 ;
$this->chars['9'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABAUGBwP/xAArEAABAwMD'.
'AgYBBQAAAAAAAAABAgMEBQYRABIhE1EUIjEzQUIHMlJhcdH/xAAWAQEBAQAAAAAAAAAAAAAAAAACAQD/xAAYEQEAAwEAAAAAAAAA'.
'AAAAAAAAAREhQf/aAAwDAQACEQMRAD8AkK7brF6X7XpMeGoKhFMLEeT4ZUheEhanF4OcZ2pTgDykk92bZpdCsi7aezLjxkIPUZiV'.
'RSCy8hah7EkZ27yM7V+iscal5bE22Lon1qNDmSKROd8Sl+Ix1lMOlIS4HGgQpbStoUCnlJz8HmsXtW3Lst2rmBAelLMRRekOwnYz'.
'Edls9QKKnOVLyk7UgcbzzrdBthqEJJwZbAI4x1U/7o1TaFa9lG36aXaZTy54VrcXUgrzsGdx+T30aNydweqVw1GS87T6Lb86Q4ha'.
'my/IAYjZBx+snKk99oOQMf1AViE65SY348hzFy6hPKnqtKz7DC1lbqyPrvJKUJ7H+M6Wrt3InP7o1brFNp4bCDGhxGAsqz69VSiQ'.
'ORwBxrrQ7itm1ac7Hp0WoGTIc3PSn0pccdcP2WorycfA1RaRHjxosZqOyhtDTSAhCf2gDAGjVHTd9sKSCumynFEZK1tIJUe58/ro'.
'1V1//9k=' ;
//==========================================================
// d5-small.jpg
//==========================================================
$this->chars['5'][0]= 632 ;
$this->chars['5'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABgIFBwT/xAAoEAABAwME'.
'AQQCAwAAAAAAAAABAgMEBQYRABIhIkEUMVFhBxNCgaH/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAv/EABcRAQEBAQAAAAAAAAAAAAAA'.
'AAABEUH/2gAMAwEAAhEDEQA/ANGvW4YVOeiRX5b4mv5Sin05IdlupPKdo/j2SO3+6TbPNQvOsTVz33KRT4csR3YUF7Dsh5OSFvug'.
'kqG4FPBxnjxpvvi4KZb1pTpU+QwxUi2Y7ZIAefUk5ATxnB9/gbtL/wCH1UpuhPUlZlMVaQ0mS8zJjqZOPfc2TwpIUonI9tw40R1r'.
'WNGq/wBdJR1XT3lqHBUnGCfkfWjRWs1ve249erQqQYjOtN1FqPUpCXQ4WIzQSsJwT0UpRwQPG0nzqyuNHobjsl9kBuWqoOoXtT1/'.
'WppZcA8lKRj64HxqU+3KpAr6plElRVKef3S4E0K9O8pLXVzKcqSsJAB9wSAca6bSoNXeuA1+5pEV+SGFNU1iKVFqI0Vdx2AJUeoz'.
'8DGlTDwG3CAf3q/pI0ah6MDhLz6U+EpXwPoaNMU//9k=' ;
//==========================================================
// d1-small.jpg
//==========================================================
$this->chars['1'][0]= 646 ;
$this->chars['1'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEwMBIgACEQEDEQH/xAAZAAADAAMAAAAAAAAAAAAAAAAABQYCBAf/xAApEAACAQMD'.
'AwQBBQAAAAAAAAABAgMEBREABiESMUEHEyJRkSNCYXGB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFxEBAQEBAAAAAAAAAAAA'.
'AAAAAAEREv/aAAwDAQACEQMRAD8A6jdd4WLbstILnc4Uq0VoWpkJknb6IjXLHJUePOlez923fcW4r1SxWlqC2UbdKirQif3Xw3yA'.
'OFAGT09/kO3OmV3a20MFRf6lIYPcpy7yRRAzgxjIy2M8YwcdiBzpX6d22VNvUlTXsFkuwkrKqNSfnK7F8OTzwrAY+l5zoxKskudN'.
'EgQPUT9PBkWF3DH+1GPxo1mLnRoAqF2VRgGOFmX/AAgY/GjRUP6hVMFv2FuFqUvUGrpDFJMBnpdyF5bsAQew7Hxzp6LZNT0yQ1DI'.
'wp0QCFBhD0jCsfLZHxbx5xxpTuvb1+v9PV7Ztk9roLPLCjmSSN3mX5ZwqjCgZX7PfWxDQb2in96pv9qq46aTE0bW4x9ceAWAYPwS'.
'PsYzoixgmheBGjIVcYCnjp/jHjHbRpe1JLn9OnopE/a0ykvjwDx47aNMXqP/2Q==' ;
//==========================================================
// ll-small.jpg
//==========================================================
$this->chars['l'][0]= 626 ;
$this->chars['l'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAYEBQf/xAArEAACAQIFAwIGAwAAAAAAAAAB'.
'AgMEEQAFBhIhFEFREzEHFSIyYcFxgZH/xAAXAQEAAwAAAAAAAAAAAAAAAAACAAED/8QAGhEAAwEAAwAAAAAAAAAAAAAAAAECMREh'.
'Qf/aAAwDAQACEQMRAD8A15Zfm1VURj1Fp5AqLKv3OARcL4W5Nzx+MLWjdRz5hqXU6TSb6OCr6WghiQbrJ91gOTy1yT5xZ55myZFk'.
'Gb5ozX6Ondm28XYqpQDwu7jEH4c5S2UaDy4xxrLmlUDWzk8XaQ3O49hbj+RiB85HNg8Ee3aqwIqhDuux7G/HHbvzgxEqaWOvy09R'.
'O0o3hjdQoUji20g+fY3wYSM6pJ4Ylr7V+Zz5PSaezHTlTRNWzxySSxt6q1MSkH6AOT2Fu3Aw7RfF/T9DEkLUeawuF2mKSgdWQj2/'.
'q3+fnDZDlqRZzQGaOGcpTOaeR1u8R+ncN3gj94so2jNWHeMNNKzorEX2qp9v3imNPoRE1zpjUtZ09HJmYq5lury0benZeTww23t3'.
'Ivgw+T0yRRyyxIqNfkLcA8jt7YMKcBWn/9k=' ;
//==========================================================
// ls-small.jpg
//==========================================================
$this->chars['s'][0]= 701 ;
$this->chars['s'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAAAAMCBAUGB//EACwQAAEEAQIFAgUFAAAAAAAA'.
'AAECAwQFEQAGEhMUITEiYQcjQVFxFRZCUoH/xAAWAQEBAQAAAAAAAAAAAAAAAAADAgH/xAAZEQADAQEBAAAAAAAAAAAAAAAAAQIR'.
'EiH/2gAMAwEAAhEDEQA/APWZMhmFXSJU+SGmWFiQtAWMJQAnJUr8Z+w/OuQk71uZnMsqnbjy9s8st9UMCQ6kZJdZaIHEkZ/JHceN'.
'N3HtizuY1JLrG48yLBSC9UTFKQiY4nACir+wAOOMEe2rm2bTbzlqtE1MyBuZAPybpw85KSfDRJ4Cg+Pl/wC61hJeGjV31VuuKqwr'.
'LGU+whZZK+Rw+oYJAyj3GjS4dZFpZVkqPLktdfMXNcaU2kBC1BIITkdx6c599GlnvPAa3TL2vNvU76n0063acr3YSLCEjpUpUQtW'.
'Dhf14SMEnOc57aZ8Tegm7dbrEQGZt1PeTDgc1PEW3FeXAvyAkZVkeMDOm2G3f3O7Cl/qEuqkQg4lp6CRxraWfUlRUD24kZA741Ko'.
'2k1HvlT3ri2sLOCgtsyJz6XEtBwZPAgJAGQMHUNPWKqWItsqh0UCFVyLeKhyLHQ2TMdHNVj+RKlAnJyfto1FW2ahgjrq6LYTFjjf'.
'lymUOLdWfJyoHA+gA7AAAaNPE3ysJdLT/9k=' ;
//==========================================================
// lh-small.jpg
//==========================================================
$this->chars['h'][0]= 677 ;
$this->chars['h'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABUDASIAAhEBAxEB/8QAGgAAAQUBAAAAAAAAAAAAAAAAAAIDBAUGB//EACwQAAIBAwMCBQIHAAAAAAAA'.
'AAECAwQFEQAGEiExExQiQVEVggcyU2GRocH/xAAXAQADAQAAAAAAAAAAAAAAAAAAAwQB/8QAGhEBAQEAAwEAAAAAAAAAAAAAAQAC'.
'AyEyMf/aAAwDAQACEQMRAD8A6DZb95q9bmpK6ieOCzNHJTxmE+NMhQ5fr1fLq3Ejvkak2e7ipiFsqb3R0m4qkPPJRiRXenU9VjKE'.
'5JVcA9R7nWc3/BUbfoKTdO3VRXhpjbZ2D8Rwk6RyZH6chB+46m7i2hDYtgA2ePlV2VkuKysoLzzRnlIScZJZeeevvjtrX7LK2rp7'.
'tTwwJ9WjhILDrTKnIdMEDl2+P80aVdJZb1QW+vgqENLPH4sBCDLIwUgnOf4GjVvDnLgUk79T81voqjb8NnuUx8pVRCiEaYUSuynl'.
'jHU9mOfnOoOx6hqz8PrbNdfEkMUXg1LSM3rKOUywJ7YAJ1ZTWmSpvdvlaVTDSUzJAhH5ZJBgv0x2RSAPlz21WXqoet3ba9nuW8n4'.
'Jr6qTPqnUNxSM/f6mPvxA9zqJnExTbR+h0nkhVu1uE8j0UBRQ9PGxBKFjnkAScdsDp10a0lc7z0tI7Y5YYN+5GAf7GjVXF4Icj3f'.
'/9k=' ;
//==========================================================
// ld-small.jpg
//==========================================================
$this->chars['d'][0]= 681 ;
$this->chars['d'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAQFBgH/xAAsEAABAwMEAAQFBQAAAAAAAAAB'.
'AgMEBQYRABIhMQcTI0EUMlFhkRgicaGx/8QAFgEBAQEAAAAAAAAAAAAAAAAAAgEA/8QAGBEBAQEBAQAAAAAAAAAAAAAAAAECETH/'.
'2gAMAwEAAhEDEQA/ALUhp6h3W/X63UlypbhCY0WMjLqGzwDtPCfv/WtealNpVInuVBBqCogcdbU36YUkAkJWVHG8YPXBxxzxqPcN'.
'YtWyWnIlUeW05VEOAvrCnnSkftK1H5lKJPHsMDoDUWq+KdrSbIqsalVsImiEtLUZ2MU71bcYJWkhZ/36ayLHhi/IXZVOmzKqp5uU'.
'688hTyjuGVEFJKvoQesD86NL2jGZp1EoLDSmk+ZAQ8d7oPzp3YGesFWMfxo1YGvSzLsT9QExVX8phTlMaFOExAJIBGQjJwCcL+/e'.
'rd+W7GuO0Kw05CQ6+ww69Gfdb2kFIKk7DgEkjgnr86rXRa9HuyP8LV4SH0sIBbWFFDiFEgDaocgdkjo8ccay0qw7ut5nyrcviQqC'.
'slsRKo0HwlODkBRzxj2AGoXTtpzIdQ8MbffUChz4NCPRaClAo9Mn6c7T3o13wytmo0K05VIqkiPJbizFiMWs4CTgnIIHOST796NL'.
'Ia1JX//Z' ;
//==========================================================
// d8-small.jpg
//==========================================================
$this->chars['8'][0]= 694 ;
$this->chars['8'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AFQMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAABgcEBf/EACsQAAEDAwMD'.
'AwMFAAAAAAAAAAECAwQFBhEAEiEUMVEHE0EVYYEiIzJCsf/EABYBAQEBAAAAAAAAAAAAAAAAAAIAAf/EABcRAQEBAQAAAAAAAAAA'.
'AAAAAAABERL/2gAMAwEAAhEDEQA/AKL6gVVUa0i1T5QjvTprUJMlxW4R9zgQXe/AH+kaWrntqlWjaq7gpcmotXAw82ht9yY4tch8'.
'uAFC0k7VBXPGMY51ruiaue+bThIj+7NbWqS+7HDxajFf6AlB/k44o8ZOABk4xkL0X0tZiojKrlRuGRJjugqldSlKGf6t7BuUQe3J'.
'44xxxrA1a4KVJipLidri8uLHgqOcfjOPxo0o2hdDvS1CmV2Yl6fS5ioipIQR1CAlKkLKR2UUqAI8g6NRSwuuyHab6s1ufLI/Zai7'.
'UBJOxhTS0+6B32pWSFH4CidOdWU0ukLiN1BLr0zG5Sdm3GRvcPhIT858DvjXNrVsSLnm/VIdTXS6tTnFsxZTSN3jchaTwps+O/z9'.
'tcBVq3hIX0tYqlIiQHdy5CqRHKHXEjAOMgBKjnvyRk4xrQa7OiGt1K5biYZL8SoVEpjOqkFsONtJCNwASeCQrn7aNUKnQYtLp7EC'.
'EylmLHQltptPZKQOBo1FzH//2Q==' ;
//==========================================================
// lz-small.jpg
//==========================================================
$this->chars['z'][0]= 690 ;
$this->chars['z'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABYDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAABgAHA//EACsQAAEDAwQBAwIHAAAAAAAAAAEC'.
'AwQFESEABhIxBxMiQVFxCCM0UmGRof/EABYBAQEBAAAAAAAAAAAAAAAAAAECAP/EABgRAAMBAQAAAAAAAAAAAAAAAAABEVEC/9oA'.
'DAMBAAIRAxEAPwBTWfLu1KXXZDbM4uewNvLajlwhaCbBAwDe5uehYd3xm6t6bi3jvulwqc7KgxXZZeYQLNLeF73WRg4HEdgfzrSa'.
'P45pNEkznITDc9ypLShtyWhJDJyXC2qxJHZvjoZOjyVv1v8AESt6FFS4ijxvTLbawEApSccrYHJf0+OtJMQ2rNXk7GZMufJgJjTH'.
'Un9M4qzxT7hyCiThIyRnPXWrRvyLElVBUF6vlhl0lwRYCFKcQhAtyWpVhyWTx+w++rUvp4EWjOvbniUOnVatcS43BYDbJSPZyIBw'.
'ejclIx+3Wa+J63T6DQanuGszI0eZVJJV60p0Jum5GEi6le7l0PjvSjyRsaTvJqI1BqhhR46ksuMrQVJcUSEoUbHNr/7o7C8L7eiz'.
'4lLlyJk2cEqW+6V+m0AE9ISLnsj5+O9UhsFK92bZZqb9SRu9p2c4A0OCEqDbYAJSlJwAVZv3fBvbFrg/462btlhuS1RG5nL8pYkq'.
'KrnsKH06I/rVrQKkf//Z' ;
//==========================================================
// d4-small.jpg
//==========================================================
$this->chars['4'][0]= 643 ;
$this->chars['4'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAABAYHAv/EAC0QAAIBAwQA'.
'BAMJAAAAAAAAAAECAwQFEQAGEiETFDFBUmGBByIjUVNxobHR/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAIB/8QAGBEBAAMBAAAAAAAA'.
'AAAAAAAAAAERIVH/2gAMAwEAAhEDEQA/ANjM00Nxmt1xiWW31CZp5uJwoAAaOQ/n7qfcZHqO5my3q5XX7R6ijiqnNut9u4NyJ4yv'.
'JJyjYr8Xhrn5g599J7x3ulBNU7Zo7dXXXcLQ8kURYi4epYtkALjOePv1nUvbLvV7P3BZm3DR3eh88Kp7pVzBZI6iUhGWRRGWwE44'.
'HX3V+uiL1uHgt+vL/H+aNJQ3CSeCOaFqSaJ1DJKs/TqRkMOvQjvRorHE4pRDLNWLGlRHGUeYIORXs9e5B7OP31E0fmdyb/t0DJ4Q'.
'27bfx3YZzPUIoAAz7IpOD6cuxq0uNumqLfVNDOqXBoZEjnZcqhIPXH4c46+WkdoWOltu3IDDLLLVVR83UVcuPEmmcZZ2/rHoAANG'.
'GI7KIY1ijoLeEQBVCwIoAHpgY6Hy0aZe7mJ2jeHLKcEhusj6aNKgzr//2Q==' ;
//==========================================================
// lv-small.jpg
//==========================================================
$this->chars['v'][0]= 648 ;
$this->chars['v'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQDBQYH/8QAKBAAAQQBAwMEAgMAAAAAAAAA'.
'AQIDBBEFAAYhEzFBEhQiYQdRFTKB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFxEBAQEBAAAAAAAAAAAAAAAAAAERIf/aAAwD'.
'AQACEQMRAD8A6Ngt1SZ4yrYgrecgTFsFJA9aGwAUrUaF2D2Avjzq6CIjiBPkB9bwQVIkIYIDae/wq+P9N+dY4SGMf+Txlev7KBmY'.
'PoadKRy4zxSgRxaTwO/x09u7KPYnasmHjlsyFZZXt4K23ezjvBpNGgLUrvXfVZyLLbWambiwEbKvvxYAkeotNlIJW2FEJWb7WBda'.
'NSQI0fHYyJjkrjKRDZQwnpQ1vgBIr+w8+a+9GocZr8iKkuY1eXhsKH8U8iZE9BHz6ZHUc48UfSPqzqH3kfeO9kTTDQYGGietpTaO'.
'shyW6AocpHNIrv8AvWzk9BUSdPdYS4BcRlomkhIV6KP0VE39V+tU2wdlRMHtZUB8NuTQ+51X27+Kr46ZPIAFV540D8zeLsJ5LMHa'.
'ubmMBCVJdjx0pRyLoWR4I8aNIQ8BvZMNtMTeUcsptKfc4tC1gAkCyFC+K0aJtf/Z' ;
//==========================================================
// lk-small.jpg
//==========================================================
$this->chars['k'][0]= 680 ;
$this->chars['k'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABUDASIAAhEBAxEB/8QAGQAAAwEBAQAAAAAAAAAAAAAAAAUGBAMH/8QALhAAAQMDAwIEBAcAAAAAAAAA'.
'AQIDBAUREgAGITFBEyIyYQcVUYEUIzNicZHx/8QAFgEBAQEAAAAAAAAAAAAAAAAAAwEE/8QAGxEAAwACAwAAAAAAAAAAAAAAAAEC'.
'AxESMeH/2gAMAwEAAhEDEQA/APVK/V36dU6NSJDTT8esPLiqfK8S2cCoeTkKvZQ6jm2ldSqKqbu+OgMOvSX3m4UBrLnDlbqiefKl'.
'Nzz2x1m+IwNP27CkJQ7JkR6rCkMJbP5jp8S2CPfkgD6H+dJ6Ca0nerr+64rTNSqMYrg+C9mmOwhVpDfsuxSbi97DmybaoZeQ5jTl'.
'PEp18JTIfeW3kq3ly4H26aNZqvTWZsjFcZTsVtSg0G8Rio+vr2vb7g6NLPRnuXy8F+8kl+obUh4KXJdqSJJQnohlkZqJPYBXh3P+'.
'a4b5Hyp6k1bO7sOotPyXkj9NlwFl0ewstJA9ifrqkVSmET4csoS7UTHXFQ+6SQlskKUMb/tH9ddLVUmS7DqdBqD7U6OsqfS46jzl'.
'hQ5bXb1K9Scuybdxo2OTu92dwSZkWn0Sb8viQWyn8Qq5D6ifSLd0BIv7q0arTBRSKPToMZbi2GWylsvLK148Wue/XRrRjxOpT2R2'.
'k9aP/9k=' ;
//==========================================================
// lr-small.jpg
//==========================================================
$this->chars['r'][0]= 681 ;
$this->chars['r'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABYDASIAAhEBAxEB/8QAGgAAAgIDAAAAAAAAAAAAAAAAAAYCBQMEB//EAC4QAAICAQIFAgMJAQAAAAAA'.
'AAECAwQRBQYAEiExQQdRFGFxEyIyM0JSYoGC8P/EABYBAQEBAAAAAAAAAAAAAAAAAAEAAv/EABcRAQEBAQAAAAAAAAAAAAAAAAAB'.
'EUH/2gAMAwEAAhEDEQA/AOs0ZdETU54Gt1INSmlPJEsyo7J+jlXPUYBPY9c+eE/dO9tY0a7ren6BVrW7VJTZtW5kZkjXkBSIKveQ'.
'gHp0AAJ4w+q2hVdT2Md0h46+saS4mr3EUK0gWTAB+vQj2PboeL/ZVOqmhaZVjkFmxdC6tctt3tM2G5/7bAx4C4+qxiWwd3prWzKe'.
'r3IBAth5OYxozKsgc8y4GTgnJB9uncdTi6tXq2140rRVM13JMEMAVAg7sMdBjJB/18uDgRO9R2Oo6FX2vShkFzURFUq1whIj+8DI'.
'7EdAFjXv7MeNb0kuStsFEmIaajZaos2fy2Q4VGH7SGxn+Rzw9yMLOm/FzRhZazmOTkP4grYyD3B8j2PTyeFfZ+z7G3BeSS8lmprl'.
'2K2qcnK0Z5S8gPjrgAY8cNEWmq7u23pEos6/Zji+Kd0rLLGWwseA3joeZj/w4OET1g0vlmrWV+ydFnkUxSgsvM4V+YYIwfHz6cHB'.
'ZeKZ1//Z' ;
//==========================================================
// lg-small.jpg
//==========================================================
$this->chars['g'][0]= 655 ;
$this->chars['g'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQCBQYH/8QAJxAAAQQBAwQCAgMAAAAAAAAA'.
'AQIDBBEFAAYhBxIxQRNhcYEiQlH/xAAYAQACAwAAAAAAAAAAAAAAAAACAwABBP/EABkRAAMBAQEAAAAAAAAAAAAAAAABAhEhIv/a'.
'AAwDAQACEQMRAD8AayO4t6bq3hmMHtxyLi4OKeKH5jyASiiQCCQeTRNAeB61FrBb+jTGpLO+BMW24EFMhkhpQru8m7B/H70x09Yi'.
'q3nv/vLfwpnJ7UNkqSRbngf2ofWkpXV7brymC2malLfagurjW0aHk89xPJ9cX9aprURHWbYEaMHHEBfwpv8AnXPk+/8AdGqGJOxO'.
'4YbOSxK4y4boIStUWysgkEmxY54r60aOI8oTV9MHtjJwunPUbO46WWo0HLlD8KY4goboFVoquOVEVwLT963WdnxYfT6ZJyz0JvHm'.
'KvtaSkW4tYNVSqKiTwB+fw5n9sY/cuOXCzDDcluyW3Ckd7V+0n0eNZTH9DdouFalHIOJBUhtDki0pNV3UALo81ehG6IdKjPZ6d47'.
'4ywltanVJvuJI+RQs/sHRqy2r003JhsImEc/CUyhxRZBjKV2oJ8eRXNmufPnRo1WIz3DdNn/2Q==' ;
//==========================================================
// lc-small.jpg
//==========================================================
$this->chars['c'][0]= 629 ;
$this->chars['c'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGQAAAwEBAQAAAAAAAAAAAAAAAAUGBwID/8QALRAAAgICAQIEBAYDAAAAAAAA'.
'AQIDBAURACExBhIiQRMVUWEHMkJScYFykaH/xAAWAQEBAQAAAAAAAAAAAAAAAAABAgP/xAAXEQEBAQEAAAAAAAAAAAAAAAAAATER'.
'/9oADAMBAAIRAxEAPwDcoGkmiT4Q8kWvzuPU38D2/v8A1zwrCFayq1qTaFk2H7aJHt05MeMvENzC4upDWkjW9kJXiricAJCigvJN'.
'IB1IVQT5frrv24twPgunk6a288crbklUSJNNdnSTZ2STHHqOP/Eb17njdZtAoqwEvrEiGVyG117/AG6HhyV8H1sljMldoxXTksGC'.
'zV7M0oaWGQOVeGQ92I6EMR22D11w4LmEPjaOL51iL8ssc9Z69zHtZkYCGGeQK0ez2UEoU39wCeX1S/LLiEt+mPSbMLxsGVv2kEjR'.
'305xkaEV/GTULMUT1LD/AAGh8gIZS2jv+vpybb8NMIb0dVLWYWgiiU0vmMphOj6V0TvQI3rfsON1E6dYjGtisa0F1mAWR2NhG0WZ'.
'3Ls3TqNs5Hc9h23w49NWL9K+Q/VD5T/zhwPH/9k=' ;
//==========================================================
// d7-small.jpg
//==========================================================
$this->chars['7'][0]= 658 ;
$this->chars['7'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABgEFBwT/xAAuEAABAwIE'.
'BAQGAwAAAAAAAAABAgMEBREABiExEhMiQSMyUXEHFBclVJFhk9L/xAAXAQADAQAAAAAAAAAAAAAAAAAAAQID/8QAGREBAQEAAwAA'.
'AAAAAAAAAAAAAAEREiFR/9oADAMBAAIRAxEAPwDXq9mCjZeQ05VZ5ZST4bfEpa3VdglCbqUe+g9MZ5Uq7V8415WXoMSdQ6etgSps'.
'19wpkCMDZKUpv0FZvbi1NzpYasMDLDUbMVXrtQdbeeU23xLWkj5RlLYK0J7anW9gbAjCzkOtsVSUJUdtc6dVZK51UeaFm4LKbhpC'.
'l7EhIFkDW974GbRI2XorUVls1OTdKAOqUpR0Hc3198GITQ6k+hLwrEpoODiDenRfW23bBicg78JXxPpD0mgVOW5PAivNNpahsPW5'.
'8xxQaSVkboQnhsnYm5OHqDGp1IpsalMKjMsMIC3+XZKbJFth62/QOEfMOZqZXp9JcKZTcGmTky3meSi7xQklI81vMR+sXIz/AEgp'.
'Q0qPNu6ea8Q2jqtbp8+2w9h/OKORc/cpHjt1dDSHOtLZ4ekHW23bBjj+o9H/AB539aP94MG0+L//2Q==' ;
//==========================================================
// ly-small.jpg
//==========================================================
$this->chars['y'][0]= 672 ;
$this->chars['y'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAQGBQf/xAArEAABAwMEAQIFBQAAAAAAAAAB'.
'AgMEBREhAAYSEzEHIhQkQVGxQmFxgaH/xAAWAQEBAQAAAAAAAAAAAAAAAAADAQL/xAAeEQEAAgEEAwAAAAAAAAAAAAABABECAxIh'.
'MUGR8P/aAAwDAQACEQMRAD8Ar3tys07dVHohemz5dWQ7fk91MsA3IIRY8rkKFySceTqw3JVV0KhyKw+0C1CQp9aUOFSiAk4AIAvn'.
'76xtz0ioVvbcJ6msx2JtOfZmw1PKI5LQcJNh7UqBKcn6+NRfqPu6s1fYc6GxSJsRfWDUVSGA22ygEckJWSexRNgOP0udXzDKOJ0I'.
'yo62mHm25Sy80l1Z4lSgpQvZRGLgWwPGjTjbchyLH+Ejx22EtJSgO8kki3kADA/nOjWjGzv73CyQZjUWNVp7bNSrj7qJDqflqUlQ'.
'DMds24l3HvcNr3Pi9gME6T9WWVsemdYWswwC2lPta4m5WMA3OdUExCmozUJD6g84ntMjrHIFBTdQz5yLDx/WDNytpwW6nAkViqVe'.
'uvmXdlme6n4dCwlRBKEgA2tj99QG7Ilncp5QqpU31PMsJ6x7A32f6SPxo0hPVCD45oVyKf0MtgeT97/nRrO7UOCFla3tn//Z' ;
//==========================================================
// d3-small.jpg
//==========================================================
$this->chars['3'][0]= 662 ;
$this->chars['3'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD//gAJSnBHcmFwaP/bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicg'.
'IiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAB4AEgMBIgACEQEDEQH/xAAZAAACAwEAAAAAAAAAAAAAAAAABAUGBwL/xAArEAABBAED'.
'AwMDBQEAAAAAAAABAgMEBREABhIhMUEiMmETFZEHFkJDUdH/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAL/xAAYEQEBAQEBAAAAAAAA'.
'AAAAAAAAEQExQf/aAAwDAQACEQMRAD8A0vclruBdk3VVLLUNssGRJsZSCtqOjlgJAHvcOD6c4HnOdIbcttw1W5P29cFEhuawqTXS'.
'VsJjnCMBxKkJJx7goAde+ceJfdNxU0UNlyymyXHi6kxWUNl1S3EnkAEIHX2nv86qtTuZr9Q9+1VhRsOoYpYcgSVyAE/TdewkJxnK'.
'sBCjkdPGpnOtFMd3PqsXgfOAgD8Y0aX+11H9rDDjn8lr9yj5J+dGqsqxaw6Cc9cQZU4Sp7zTJsIrKlcUEKwhSin1JABI45GUjqOu'.
'lbOvjbc3Ts9ynjGCy445UuFLYRzbWgrT6fhSCQSMDke+pew2zYVly/d7YchNqkMJZnQpgV9J8IzwWFJyUrAJHYgjvpLbu37G5nR7'.
'vck5C3YRKYEOEVJZj8kjKypXqWvirjk9h+dB9i4faa89TDZUfKlIyT8k+To10a6KTkpcJ/0vL/7o0TS//9k=' ;
//==========================================================
// ln-small.jpg
//==========================================================
$this->chars['n'][0]= 643 ;
$this->chars['n'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGwAAAgEFAAAAAAAAAAAAAAAAAAYCAQMEBQf/xAAtEAACAQMCBAUCBwAAAAAA'.
'AAABAgMEBREAIQYSE0EHIjFRcWGRIzIzQoGCwf/EABYBAQEBAAAAAAAAAAAAAAAAAAMEAP/EABkRAQEBAQEBAAAAAAAAAAAAAAEA'.
'AhEhUf/aAAwDAQACEQMRAD8A6FR3p7v4oV9rlkMQsjL00RyOss0KkFxnDcrc2PbI1NOJKyTjW+W5OmKeA0UEJx5meRZS2/8AUfbS'.
'LVGS1+K16vCzfiR3GmoqqXGyxz06hWPsFlVMfOmq1iNvE69KjBYo3oJMZ3GKeYYPxg/fW+xzZX1FLQyxwSTcpWNceu4G3+aNSmpY'.
'qmQzzwh2k8yhv2r2H23/AJ0aoy+EWh7I1ntacR3PxDtEzhjWy0wkkIwYmanU5GO6sNh7rrU8AVdTceNbhDXxNHUQvS0tZ3DzwxVA'.
'fB7hj59/XJ08cPWaKj4gvlwSQiG7dCboqvLy9NOmQT9SM7ayJrBa6K5V91hjlWorp4JGUOAglRSiMMDb82/vgaBGTpVvtNUVtyJg'.
'5+WNAh5ZCu/r2+dGrgq0pi0DhmlRsSSAfqMd+b6ZyNu3po1Rk1yNBe3/2Q==' ;
//==========================================================
// lu-small.jpg
//==========================================================
$this->chars['u'][0]= 671 ;
$this->chars['u'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAYDBAUH/8QAJRAAAQQBAwQDAQEAAAAAAAAA'.
'AQIDBBEFAAYhBxMxYRJBURSB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAQAD/8QAGhEBAQEAAwEAAAAAAAAAAAAAAQARITFBAv/aAAwD'.
'AQACEQMRAD8A6dLkQmJzu3WVtHIqjf0duKFNuBr5UTQ45F1R8/XI1PMmsYoJyjhS9iI7BKHeKjkXZVXqhyLHP+rrHeR1pZlx1W1M'.
'wTiW0ukkrS28nn5fV2SPPFfurHUKQhzYG7pLYKEfyBhaSOS7dG/YCki/uvWn3LPDOJrwa4kyEzOYeakqkpC3Hk0bNePQHgDRpchY'.
'leIZwzUWauKtuPctTSUlCAUmrBHIKuAPV/ujQsmHdm7hya43UbbD3ZVElOQJsdTS6IQaQUqBHCk8E2Pocgam6oYwObHy0Zm0oi45'.
'T1KBPdpV2f0pom/1Ws7cmPazu98Ltvcq3VzRHfehz8a4pirFEKRZo8eQT+eCdWYfS/b+WYnxpbuVcDRMdHcyTqg2fiAfiLoi+Rf+'.
'jT7Xc74HtOYnHyUOh8yWUvKeHhy0CiPVUAPoDRrm+OeznTva6lzsyMjCYbbaiNJjJSWElagD5tRpNUSALFeNGoOCH7Bv/9k=' ;
//==========================================================
// lw-small.jpg
//==========================================================
$this->chars['w'][0]= 673 ;
$this->chars['w'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABcDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAYDBAX/xAAtEAACAQMDAgMHBQAAAAAAAAAB'.
'AgMEBREABhIhMRMUQRUiIzJRYZEWNIGx0f/EABYBAQEBAAAAAAAAAAAAAAAAAAABA//EABoRAAICAwAAAAAAAAAAAAAAAAABERIh'.
'MVH/2gAMAwEAAhEDEQA/AHXbV13ZLu6t2/uaa1JijWopVp4XUTKSAXRyc+6ehBGeoPbTSlwpql0K3GneqpZViqUhI5JzGMEZJGeh'.
'GlXfaFILDf7FQzXC426rDLTojs8sLqVkXBGcfKf40twWbdWzZY75R0s90ul3jPtKjVMJDNn4DDp8iEhW+wJ1WZG2KWt3Lv26U1tv'.
'92o7PaYkgYUbqVepYlmUBlIwqnB++O2jTDt/bBtth9jcpvEWNGqalZQryTlmeR8jPct6+mNGmRC4a1U13htzVFItB5nA/cyOUVfp'.
'7oz/ALqitJulYJKuqvFsppHALLFb3cp9FBaXr+O51bq0q6i38KK5PDVAAxSzU6SIpz3Kjjn8jUFoS7uFmut1gq17xLFQ+DxOccj8'.
'Rsn+tVpiyJnqv09YfOXu5AycgZZQEhBZjgDBOOgwO/po0sttWHdNzqLruioa4UwmdaC3kYp4IwSvJlBHKQ4OSe3po0qxM6P/2Q==' ;
//==========================================================
// lq-small.jpg
//==========================================================
$this->chars['q'][0]= 671 ;
$this->chars['q'][1]=
'/9j/4AAQSkZJRgABAQEASgBKAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAx'.
'NDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy'.
'MjIyMjIyMjL/wAARCAAeABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAcDBAUG/8QAKRAAAQQBBAICAQQDAAAAAAAA'.
'AQIDBBEFAAYSIQcxIlETCBQVgSNBYf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/8QAFhEBAQEAAAAAAAAAAAAAAAAAAAER/9oADAMB'.
'AAIRAxEAPwDT3H5Qz+O3LN2vtrF/y86NYLzzVlAABJITQPv2a/17vXMboz3lDEYWPuafNx7CFrS03+2jpK2bs0CUkUa7pRvrUu63'.
'sr438yv7pLEo4XIK5Kcji0uJUkckm+uQUOVH6GsnyJv7A5vaJwuFdkONLmolgONFH4vioKRXYqyCADXvRMh0yspmZ4jyIEtDTK47'.
'aiA0lQUopBJBI/7X9aNT7amRo228e3a31iO3yUzCcdSPiKAIFdCho0TIswZ7GQlO/hlRxBooih1YXzAoKUkX0LPEBX110dJ7zbuv'.
'AORpO04cIpmxH23FSEIRwKuNnsdk0o31702XhFMKbuRUZJWP8LTQ6HBCuIB+iVWSR2BXuqK93/hDlvGzEphmG3Ml5JpDi1I7TzNA'.
'BYFlPafY+/7LBiv1CYDH4iFDOGySlMR22lFP4wCUpANfL11o1r4bxXlWMNEaE/bqlIbCFl/ANPK5Do/M0VDr2Rf3o0TX/9k=' ;
}
}
class AntiSpam {
private $iData='';
private $iDD=null;
function __construct($aData='') {
$this->iData = $aData;
$this->iDD = new HandDigits();
}
function Set($aData) {
$this->iData = $aData;
}
function Rand($aLen) {
$d='';
for($i=0; $i < $aLen; ++$i) {
if( rand(0,9) < 6 ) {
// Digits
$d .= chr( ord('1') + rand(0,8) );
}
else {
// Letters
do {
$offset = rand(0,25);
} while ( $offset==14 );
$d .= chr( ord('a') + $offset );
}
}
$this->iData = $d;
return $d;
}
function Stroke() {
$n=strlen($this->iData);
if( $n==0 ) {
return false;
}
for($i=0; $i < $n; ++$i ) {
if( $this->iData[$i]==='0' || strtolower($this->iData[$i])==='o') {
return false;
}
}
$img = @imagecreatetruecolor($n*$this->iDD->iWidth, $this->iDD->iHeight);
if( $img < 1 ) {
return false;
}
$start=0;
for($i=0; $i < $n; ++$i ) {
$dimg = imagecreatefromstring(base64_decode($this->iDD->chars[strtolower($this->iData[$i])][1]));
imagecopy($img,$dimg,$start,0,0,0,imagesx($dimg), $this->iDD->iHeight);
$start += imagesx($dimg);
}
$resimg = @imagecreatetruecolor($start+4, $this->iDD->iHeight+4);
if( $resimg < 1 ) {
return false;
}
imagecopy($resimg,$img,2,2,0,0,$start, $this->iDD->iHeight);
header("Content-type: image/jpeg");
imagejpeg($resimg);
return true;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,119 +0,0 @@
<?php
/**
* jpgraph_canvas.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_CANVAS.PHP
// Description: Canvas drawing extension for JpGraph
// Created: 2001-01-08
// Ver: $Id: jpgraph_canvas.php 1923 2010-01-11 13:48:49Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
//===================================================
// CLASS CanvasGraph
// Description: Creates a simple canvas graph which
// might be used together with the basic Image drawing
// primitives. Useful to auickoly produce some arbitrary
// graphic which benefits from all the functionality in the
// graph liek caching for example.
//===================================================
class CanvasGraph extends Graph {
//---------------
// CONSTRUCTOR
function __construct($aWidth=300,$aHeight=200,$aCachedName="",$timeout=0,$inline=1) {
parent::__construct($aWidth,$aHeight,$aCachedName,$timeout,$inline);
}
//---------------
// PUBLIC METHODS
function InitFrame() {
$this->StrokePlotArea();
}
// Method description
function Stroke($aStrokeFileName="") {
if( $this->texts != null ) {
for($i=0; $i < count($this->texts); ++$i) {
$this->texts[$i]->Stroke($this->img);
}
}
if( $this->iTables !== null ) {
for($i=0; $i < count($this->iTables); ++$i) {
$this->iTables[$i]->Stroke($this->img);
}
}
$this->StrokeTitles();
// If the filename is the predefined value = '_csim_special_'
// we assume that the call to stroke only needs to do enough
// to correctly generate the CSIM maps.
// We use this variable to skip things we don't strictly need
// to do to generate the image map to improve performance
// a best we can. Therefor you will see a lot of tests !$_csim in the
// code below.
$_csim = ($aStrokeFileName===_CSIM_SPECIALFILE);
// We need to know if we have stroked the plot in the
// GetCSIMareas. Otherwise the CSIM hasn't been generated
// and in the case of GetCSIM called before stroke to generate
// CSIM without storing an image to disk GetCSIM must call Stroke.
$this->iHasStroked = true;
if( !$_csim ) {
// Should we do any final image transformation
if( $this->iImgTrans ) {
if( !class_exists('ImgTrans',false) ) {
require_once('jpgraph_imgtrans.php');
}
$tform = new ImgTrans($this->img->img);
$this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist,
$this->iImgTransDirection,$this->iImgTransHighQ,
$this->iImgTransMinSize,$this->iImgTransFillColor,
$this->iImgTransBorder);
}
// If the filename is given as the special _IMG_HANDLER
// then the image handler is returned and the image is NOT
// streamed back
if( $aStrokeFileName == _IMG_HANDLER ) {
return $this->img->img;
}
else {
// Finally stream the generated picture
$this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName);
return true;
}
}
}
} // Class
/* EOF */
?>

View File

@ -1,547 +0,0 @@
<?php
/**
* jpgraph_canvtools.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_CANVTOOLS.PHP
// Description: Some utilities for text and shape drawing on a canvas
// Created: 2002-08-23
// Ver: $Id: jpgraph_canvtools.php 1857 2009-09-28 14:38:14Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
define('CORNER_TOPLEFT',0);
define('CORNER_TOPRIGHT',1);
define('CORNER_BOTTOMRIGHT',2);
define('CORNER_BOTTOMLEFT',3);
//===================================================
// CLASS CanvasScale
// Description: Define a scale for canvas so we
// can abstract away with absolute pixels
//===================================================
class CanvasScale {
private $g;
private $w,$h;
private $ixmin=0,$ixmax=10,$iymin=0,$iymax=10;
function __construct($graph,$xmin=0,$xmax=10,$ymin=0,$ymax=10) {
$this->g = $graph;
$this->w = $graph->img->width;
$this->h = $graph->img->height;
$this->ixmin = $xmin;
$this->ixmax = $xmax;
$this->iymin = $ymin;
$this->iymax = $ymax;
}
function Set($xmin=0,$xmax=10,$ymin=0,$ymax=10) {
$this->ixmin = $xmin;
$this->ixmax = $xmax;
$this->iymin = $ymin;
$this->iymax = $ymax;
}
function Get() {
return array($this->ixmin,$this->ixmax,$this->iymin,$this->iymax);
}
function Translate($x,$y) {
$xp = round(($x-$this->ixmin)/($this->ixmax - $this->ixmin) * $this->w);
$yp = round(($y-$this->iymin)/($this->iymax - $this->iymin) * $this->h);
return array($xp,$yp);
}
function TranslateX($x) {
$xp = round(($x-$this->ixmin)/($this->ixmax - $this->ixmin) * $this->w);
return $xp;
}
function TranslateY($y) {
$yp = round(($y-$this->iymin)/($this->iymax - $this->iymin) * $this->h);
return $yp;
}
}
//===================================================
// CLASS Shape
// Description: Methods to draw shapes on canvas
//===================================================
class Shape {
private $img,$scale;
function __construct($aGraph,$scale) {
$this->img = $aGraph->img;
$this->img->SetColor('black');
$this->scale = $scale;
}
function SetColor($aColor) {
$this->img->SetColor($aColor);
}
function Line($x1,$y1,$x2,$y2) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
$this->img->Line($x1,$y1,$x2,$y2);
}
function SetLineWeight($aWeight) {
$this->img->SetLineWeight($aWeight);
}
function Polygon($p,$aClosed=false) {
$n=count($p);
for($i=0; $i < $n; $i+=2 ) {
$p[$i] = $this->scale->TranslateX($p[$i]);
$p[$i+1] = $this->scale->TranslateY($p[$i+1]);
}
$this->img->Polygon($p,$aClosed);
}
function FilledPolygon($p) {
$n=count($p);
for($i=0; $i < $n; $i+=2 ) {
$p[$i] = $this->scale->TranslateX($p[$i]);
$p[$i+1] = $this->scale->TranslateY($p[$i+1]);
}
$this->img->FilledPolygon($p);
}
// Draw a bezier curve with defining points in the $aPnts array
// using $aSteps steps.
// 0=x0, 1=y0
// 2=x1, 3=y1
// 4=x2, 5=y2
// 6=x3, 7=y3
function Bezier($p,$aSteps=40) {
$x0 = $p[0];
$y0 = $p[1];
// Calculate coefficients
$cx = 3*($p[2]-$p[0]);
$bx = 3*($p[4]-$p[2])-$cx;
$ax = $p[6]-$p[0]-$cx-$bx;
$cy = 3*($p[3]-$p[1]);
$by = 3*($p[5]-$p[3])-$cy;
$ay = $p[7]-$p[1]-$cy-$by;
// Step size
$delta = 1.0/$aSteps;
$x_old = $x0;
$y_old = $y0;
for($t=$delta; $t<=1.0; $t+=$delta) {
$tt = $t*$t; $ttt=$tt*$t;
$x = $ax*$ttt + $bx*$tt + $cx*$t + $x0;
$y = $ay*$ttt + $by*$tt + $cy*$t + $y0;
$this->Line($x_old,$y_old,$x,$y);
$x_old = $x;
$y_old = $y;
}
$this->Line($x_old,$y_old,$p[6],$p[7]);
}
function Rectangle($x1,$y1,$x2,$y2) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
$this->img->Rectangle($x1,$y1,$x2,$y2);
}
function FilledRectangle($x1,$y1,$x2,$y2) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
$this->img->FilledRectangle($x1,$y1,$x2,$y2);
}
function Circle($x1,$y1,$r) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
if( $r >= 0 )
$r = $this->scale->TranslateX($r);
else
$r = -$r;
$this->img->Circle($x1,$y1,$r);
}
function FilledCircle($x1,$y1,$r) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
if( $r >= 0 )
$r = $this->scale->TranslateX($r);
else
$r = -$r;
$this->img->FilledCircle($x1,$y1,$r);
}
function RoundedRectangle($x1,$y1,$x2,$y2,$r=null) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
if( $r == null )
$r = 5;
elseif( $r >= 0 )
$r = $this->scale->TranslateX($r);
else
$r = -$r;
$this->img->RoundedRectangle($x1,$y1,$x2,$y2,$r);
}
function FilledRoundedRectangle($x1,$y1,$x2,$y2,$r=null) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
if( $r == null )
$r = 5;
elseif( $r > 0 )
$r = $this->scale->TranslateX($r);
else
$r = -$r;
$this->img->FilledRoundedRectangle($x1,$y1,$x2,$y2,$r);
}
function ShadowRectangle($x1,$y1,$x2,$y2,$fcolor=false,$shadow_width=null,$shadow_color=array(102,102,102)) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
if( $shadow_width == null )
$shadow_width=4;
else
$shadow_width=$this->scale->TranslateX($shadow_width);
$this->img->ShadowRectangle($x1,$y1,$x2,$y2,$fcolor,$shadow_width,$shadow_color);
}
function SetTextAlign($halign,$valign="bottom") {
$this->img->SetTextAlign($halign,$valign="bottom");
}
function StrokeText($x1,$y1,$txt,$dir=0,$paragraph_align="left") {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
$this->img->StrokeText($x1,$y1,$txt,$dir,$paragraph_align);
}
// A rounded rectangle where one of the corner has been moved "into" the
// rectangle 'iw' width and 'ih' height. Corners:
// 0=Top left, 1=top right, 2=bottom right, 3=bottom left
function IndentedRectangle($xt,$yt,$w,$h,$iw=0,$ih=0,$aCorner=3,$aFillColor="",$r=4) {
list($xt,$yt) = $this->scale->Translate($xt,$yt);
list($w,$h) = $this->scale->Translate($w,$h);
list($iw,$ih) = $this->scale->Translate($iw,$ih);
$xr = $xt + $w - 0;
$yl = $yt + $h - 0;
switch( $aCorner ) {
case 0: // Upper left
// Bottom line, left & right arc
$this->img->Line($xt+$r,$yl,$xr-$r,$yl);
$this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180);
$this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90);
// Right line, Top right arc
$this->img->Line($xr,$yt+$r,$xr,$yl-$r);
$this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360);
// Top line, Top left arc
$this->img->Line($xt+$iw+$r,$yt,$xr-$r,$yt);
$this->img->Arc($xt+$iw+$r,$yt+$r,$r*2,$r*2,180,270);
// Left line
$this->img->Line($xt,$yt+$ih+$r,$xt,$yl-$r);
// Indent horizontal, Lower left arc
$this->img->Line($xt+$r,$yt+$ih,$xt+$iw-$r,$yt+$ih);
$this->img->Arc($xt+$r,$yt+$ih+$r,$r*2,$r*2,180,270);
// Indent vertical, Indent arc
$this->img->Line($xt+$iw,$yt+$r,$xt+$iw,$yt+$ih-$r);
$this->img->Arc($xt+$iw-$r,$yt+$ih-$r,$r*2,$r*2,0,90);
if( $aFillColor != '' ) {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xr-$r,$yl-$r,$bc);
$this->img->PopColor();
}
break;
case 1: // Upper right
// Bottom line, left & right arc
$this->img->Line($xt+$r,$yl,$xr-$r,$yl);
$this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180);
$this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90);
// Left line, Top left arc
$this->img->Line($xt,$yt+$r,$xt,$yl-$r);
$this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270);
// Top line, Top right arc
$this->img->Line($xt+$r,$yt,$xr-$iw-$r,$yt);
$this->img->Arc($xr-$iw-$r,$yt+$r,$r*2,$r*2,270,360);
// Right line
$this->img->Line($xr,$yt+$ih+$r,$xr,$yl-$r);
// Indent horizontal, Lower right arc
$this->img->Line($xr-$iw+$r,$yt+$ih,$xr-$r,$yt+$ih);
$this->img->Arc($xr-$r,$yt+$ih+$r,$r*2,$r*2,270,360);
// Indent vertical, Indent arc
$this->img->Line($xr-$iw,$yt+$r,$xr-$iw,$yt+$ih-$r);
$this->img->Arc($xr-$iw+$r,$yt+$ih-$r,$r*2,$r*2,90,180);
if( $aFillColor != '' ) {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xt+$r,$yl-$r,$bc);
$this->img->PopColor();
}
break;
case 2: // Lower right
// Top line, Top left & Top right arc
$this->img->Line($xt+$r,$yt,$xr-$r,$yt);
$this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270);
$this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360);
// Left line, Bottom left arc
$this->img->Line($xt,$yt+$r,$xt,$yl-$r);
$this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180);
// Bottom line, Bottom right arc
$this->img->Line($xt+$r,$yl,$xr-$iw-$r,$yl);
$this->img->Arc($xr-$iw-$r,$yl-$r,$r*2,$r*2,0,90);
// Right line
$this->img->Line($xr,$yt+$r,$xr,$yl-$ih-$r);
// Indent horizontal, Lower right arc
$this->img->Line($xr-$r,$yl-$ih,$xr-$iw+$r,$yl-$ih);
$this->img->Arc($xr-$r,$yl-$ih-$r,$r*2,$r*2,0,90);
// Indent vertical, Indent arc
$this->img->Line($xr-$iw,$yl-$r,$xr-$iw,$yl-$ih+$r);
$this->img->Arc($xr-$iw+$r,$yl-$ih+$r,$r*2,$r*2,180,270);
if( $aFillColor != '' ) {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xt+$r,$yt+$r,$bc);
$this->img->PopColor();
}
break;
case 3: // Lower left
// Top line, Top left & Top right arc
$this->img->Line($xt+$r,$yt,$xr-$r,$yt);
$this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270);
$this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360);
// Right line, Bottom right arc
$this->img->Line($xr,$yt+$r,$xr,$yl-$r);
$this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90);
// Bottom line, Bottom left arc
$this->img->Line($xt+$iw+$r,$yl,$xr-$r,$yl);
$this->img->Arc($xt+$iw+$r,$yl-$r,$r*2,$r*2,90,180);
// Left line
$this->img->Line($xt,$yt+$r,$xt,$yl-$ih-$r);
// Indent horizontal, Lower left arc
$this->img->Line($xt+$r,$yl-$ih,$xt+$iw-$r,$yl-$ih);
$this->img->Arc($xt+$r,$yl-$ih-$r,$r*2,$r*2,90,180);
// Indent vertical, Indent arc
$this->img->Line($xt+$iw,$yl-$ih+$r,$xt+$iw,$yl-$r);
$this->img->Arc($xt+$iw-$r,$yl-$ih+$r,$r*2,$r*2,270,360);
if( $aFillColor != '' ) {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xr-$r,$yt+$r,$bc);
$this->img->PopColor();
}
break;
}
}
}
//===================================================
// CLASS RectangleText
// Description: Draws a text paragraph inside a
// rounded, possible filled, rectangle.
//===================================================
class CanvasRectangleText {
private $ix,$iy,$iw,$ih,$ir=4;
private $iTxt,$iColor='black',$iFillColor='',$iFontColor='black';
private $iParaAlign='center';
private $iAutoBoxMargin=5;
private $iShadowWidth=3,$iShadowColor='';
function __construct($aTxt='',$xl=0,$yt=0,$w=0,$h=0) {
$this->iTxt = new Text($aTxt);
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
}
function SetShadow($aColor='gray',$aWidth=3) {
$this->iShadowColor = $aColor;
$this->iShadowWidth = $aWidth;
}
function SetFont($FontFam,$aFontStyle,$aFontSize=12) {
$this->iTxt->SetFont($FontFam,$aFontStyle,$aFontSize);
}
function SetTxt($aTxt) {
$this->iTxt->Set($aTxt);
}
function ParagraphAlign($aParaAlign) {
$this->iParaAlign = $aParaAlign;
}
function SetFillColor($aFillColor) {
$this->iFillColor = $aFillColor;
}
function SetAutoMargin($aMargin) {
$this->iAutoBoxMargin=$aMargin;
}
function SetColor($aColor) {
$this->iColor = $aColor;
}
function SetFontColor($aColor) {
$this->iFontColor = $aColor;
}
function SetPos($xl=0,$yt=0,$w=0,$h=0) {
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
}
function Pos($xl=0,$yt=0,$w=0,$h=0) {
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
}
function Set($aTxt,$xl,$yt,$w=0,$h=0) {
$this->iTxt->Set($aTxt);
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
}
function SetCornerRadius($aRad=5) {
$this->ir = $aRad;
}
function Stroke($aImg,$scale) {
// If coordinates are specifed as negative this means we should
// treat them as abolsute (pixels) coordinates
if( $this->ix > 0 ) {
$this->ix = $scale->TranslateX($this->ix) ;
}
else {
$this->ix = -$this->ix;
}
if( $this->iy > 0 ) {
$this->iy = $scale->TranslateY($this->iy) ;
}
else {
$this->iy = -$this->iy;
}
list($this->iw,$this->ih) = $scale->Translate($this->iw,$this->ih) ;
if( $this->iw == 0 )
$this->iw = round($this->iTxt->GetWidth($aImg) + $this->iAutoBoxMargin);
if( $this->ih == 0 ) {
$this->ih = round($this->iTxt->GetTextHeight($aImg) + $this->iAutoBoxMargin);
}
if( $this->iShadowColor != '' ) {
$aImg->PushColor($this->iShadowColor);
$aImg->FilledRoundedRectangle($this->ix+$this->iShadowWidth,
$this->iy+$this->iShadowWidth,
$this->ix+$this->iw-1+$this->iShadowWidth,
$this->iy+$this->ih-1+$this->iShadowWidth,
$this->ir);
$aImg->PopColor();
}
if( $this->iFillColor != '' ) {
$aImg->PushColor($this->iFillColor);
$aImg->FilledRoundedRectangle($this->ix,$this->iy,
$this->ix+$this->iw-1,
$this->iy+$this->ih-1,
$this->ir);
$aImg->PopColor();
}
if( $this->iColor != '' ) {
$aImg->PushColor($this->iColor);
$aImg->RoundedRectangle($this->ix,$this->iy,
$this->ix+$this->iw-1,
$this->iy+$this->ih-1,
$this->ir);
$aImg->PopColor();
}
$this->iTxt->Align('center','center');
$this->iTxt->ParagraphAlign($this->iParaAlign);
$this->iTxt->SetColor($this->iFontColor);
$this->iTxt->Stroke($aImg, $this->ix+$this->iw/2, $this->iy+$this->ih/2);
return array($this->iw, $this->ih);
}
}
?>

View File

@ -1,611 +0,0 @@
<?php
/**
* jpgraph_contour.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_CONTOUR.PHP
// Description: Contour plot
// Created: 2009-03-08
// Ver: $Id: jpgraph_contour.php 1870 2009-09-29 04:24:18Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once('jpgraph_meshinterpolate.inc.php');
define('HORIZ_EDGE',0);
define('VERT_EDGE',1);
/**
* This class encapsulates the core contour plot algorithm. It will find the path
* of the specified isobars in the data matrix specified. It is assumed that the
* data matrix models an equspaced X-Y mesh of datavalues corresponding to the Z
* values.
*
*/
class Contour {
private $dataPoints = array();
private $nbrCols=0,$nbrRows=0;
private $horizEdges = array(), $vertEdges=array();
private $isobarValues = array();
private $stack = null;
private $isobarCoord = array();
private $nbrIsobars = 10, $isobarColors = array();
private $invert = true;
private $highcontrast = false, $highcontrastbw = false;
/**
* Create a new contour level "algorithm machine".
* @param $aMatrix The values to find the contour from
* @param $aIsobars Mixed. If integer it determines the number of isobars to be used. The levels are determined
* automatically as equdistance between the min and max value of the matrice.
* If $aIsobars is an array then this is interpretated as an array of values to be used as isobars in the
* contour plot.
* @return an instance of the contour algorithm
*/
function __construct($aMatrix,$aIsobars=10, $aColors=null) {
$this->nbrRows = count($aMatrix);
$this->nbrCols = count($aMatrix[0]);
$this->dataPoints = $aMatrix;
if( is_array($aIsobars) ) {
// use the isobar values supplied
$this->nbrIsobars = count($aIsobars);
$this->isobarValues = $aIsobars;
}
else {
// Determine the isobar values automatically
$this->nbrIsobars = $aIsobars;
list($min,$max) = $this->getMinMaxVal();
$stepSize = ($max-$min) / $aIsobars ;
$isobar = $min+$stepSize/2;
for ($i = 0; $i < $aIsobars; $i++) {
$this->isobarValues[$i] = $isobar;
$isobar += $stepSize;
}
}
if( $aColors !== null && count($aColors) > 0 ) {
if( !is_array($aColors) ) {
JpGraphError::RaiseL(28001);
//'Third argument to Contour must be an array of colors.'
}
if( count($aColors) != count($this->isobarValues) ) {
JpGraphError::RaiseL(28002);
//'Number of colors must equal the number of isobar lines specified';
}
$this->isobarColors = $aColors;
}
}
/**
* Flip the plot around the Y-coordinate. This has the same affect as flipping the input
* data matrice
*
* @param $aFlg If true the the vertice in input data matrice position (0,0) corresponds to the top left
* corner of teh plot otherwise it will correspond to the bottom left corner (a horizontal flip)
*/
function SetInvert($aFlg=true) {
$this->invert = $aFlg;
}
/**
* Find the min and max values in the data matrice
*
* @return array(min_value,max_value)
*/
function getMinMaxVal() {
$min = $this->dataPoints[0][0];
$max = $this->dataPoints[0][0];
for ($i = 0; $i < $this->nbrRows; $i++) {
if( ($mi=min($this->dataPoints[$i])) < $min ) $min = $mi;
if( ($ma=max($this->dataPoints[$i])) > $max ) $max = $ma;
}
return array($min,$max);
}
/**
* Reset the two matrices that keeps track on where the isobars crosses the
* horizontal and vertical edges
*/
function resetEdgeMatrices() {
for ($k = 0; $k < 2; $k++) {
for ($i = 0; $i <= $this->nbrRows; $i++) {
for ($j = 0; $j <= $this->nbrCols; $j++) {
$this->edges[$k][$i][$j] = false;
}
}
}
}
/**
* Determine if the specified isobar crosses the horizontal edge specified by its row and column
*
* @param $aRow Row index of edge to be checked
* @param $aCol Col index of edge to be checked
* @param $aIsobar Isobar value
* @return true if the isobar is crossing this edge
*/
function isobarHCrossing($aRow,$aCol,$aIsobar) {
if( $aCol >= $this->nbrCols-1 ) {
JpGraphError::RaiseL(28003,$aCol);
//'ContourPlot Internal Error: isobarHCrossing: Coloumn index too large (%d)'
}
if( $aRow >= $this->nbrRows ) {
JpGraphError::RaiseL(28004,$aRow);
//'ContourPlot Internal Error: isobarHCrossing: Row index too large (%d)'
}
$v1 = $this->dataPoints[$aRow][$aCol];
$v2 = $this->dataPoints[$aRow][$aCol+1];
return ($aIsobar-$v1)*($aIsobar-$v2) < 0 ;
}
/**
* Determine if the specified isobar crosses the vertical edge specified by its row and column
*
* @param $aRow Row index of edge to be checked
* @param $aCol Col index of edge to be checked
* @param $aIsobar Isobar value
* @return true if the isobar is crossing this edge
*/
function isobarVCrossing($aRow,$aCol,$aIsobar) {
if( $aRow >= $this->nbrRows-1) {
JpGraphError::RaiseL(28005,$aRow);
//'isobarVCrossing: Row index too large
}
if( $aCol >= $this->nbrCols ) {
JpGraphError::RaiseL(28006,$aCol);
//'isobarVCrossing: Col index too large
}
$v1 = $this->dataPoints[$aRow][$aCol];
$v2 = $this->dataPoints[$aRow+1][$aCol];
return ($aIsobar-$v1)*($aIsobar-$v2) < 0 ;
}
/**
* Determine all edges, horizontal and vertical that the specified isobar crosses. The crossings
* are recorded in the two edge matrices.
*
* @param $aIsobar The value of the isobar to be checked
*/
function determineIsobarEdgeCrossings($aIsobar) {
$ib = $this->isobarValues[$aIsobar];
for ($i = 0; $i < $this->nbrRows-1; $i++) {
for ($j = 0; $j < $this->nbrCols-1; $j++) {
$this->edges[HORIZ_EDGE][$i][$j] = $this->isobarHCrossing($i,$j,$ib);
$this->edges[VERT_EDGE][$i][$j] = $this->isobarVCrossing($i,$j,$ib);
}
}
// We now have the bottom and rightmost edges unsearched
for ($i = 0; $i < $this->nbrRows-1; $i++) {
$this->edges[VERT_EDGE][$i][$j] = $this->isobarVCrossing($i,$this->nbrCols-1,$ib);
}
for ($j = 0; $j < $this->nbrCols-1; $j++) {
$this->edges[HORIZ_EDGE][$i][$j] = $this->isobarHCrossing($this->nbrRows-1,$j,$ib);
}
}
/**
* Return the normalized coordinates for the crossing of the specified edge with the specified
* isobar- The crossing is simpy detrmined with a linear interpolation between the two vertices
* on each side of the edge and the value of the isobar
*
* @param $aRow Row of edge
* @param $aCol Column of edge
* @param $aEdgeDir Determine if this is a horizontal or vertical edge
* @param $ib The isobar value
* @return unknown_type
*/
function getCrossingCoord($aRow,$aCol,$aEdgeDir,$aIsobarVal) {
// In order to avoid numerical problem when two vertices are very close
// we have to check and avoid dividing by close to zero denumerator.
if( $aEdgeDir == HORIZ_EDGE ) {
$d = abs($this->dataPoints[$aRow][$aCol] - $this->dataPoints[$aRow][$aCol+1]);
if( $d > 0.001 ) {
$xcoord = $aCol + abs($aIsobarVal - $this->dataPoints[$aRow][$aCol]) / $d;
}
else {
$xcoord = $aCol;
}
$ycoord = $aRow;
}
else {
$d = abs($this->dataPoints[$aRow][$aCol] - $this->dataPoints[$aRow+1][$aCol]);
if( $d > 0.001 ) {
$ycoord = $aRow + abs($aIsobarVal - $this->dataPoints[$aRow][$aCol]) / $d;
}
else {
$ycoord = $aRow;
}
$xcoord = $aCol;
}
if( $this->invert ) {
$ycoord = $this->nbrRows-1 - $ycoord;
}
return array($xcoord,$ycoord);
}
/**
* In order to avoid all kinds of unpleasent extra checks and complex boundary
* controls for the degenerated case where the contour levels exactly crosses
* one of the vertices we add a very small delta (0.1%) to the data point value.
* This has no visible affect but it makes the code sooooo much cleaner.
*
*/
function adjustDataPointValues() {
$ni = count($this->isobarValues);
for ($k = 0; $k < $ni; $k++) {
$ib = $this->isobarValues[$k];
for ($row = 0 ; $row < $this->nbrRows-1; ++$row) {
for ($col = 0 ; $col < $this->nbrCols-1; ++$col ) {
if( abs($this->dataPoints[$row][$col] - $ib) < 0.0001 ) {
$this->dataPoints[$row][$col] += $this->dataPoints[$row][$col]*0.001;
}
}
}
}
}
/**
* @param $aFlg
* @param $aBW
* @return unknown_type
*/
function UseHighContrastColor($aFlg=true,$aBW=false) {
$this->highcontrast = $aFlg;
$this->highcontrastbw = $aBW;
}
/**
* Calculate suitable colors for each defined isobar
*
*/
function CalculateColors() {
if ( $this->highcontrast ) {
if ( $this->highcontrastbw ) {
for ($ib = 0; $ib < $this->nbrIsobars; $ib++) {
$this->isobarColors[$ib] = 'black';
}
}
else {
// Use only blue/red scale
$step = round(255/($this->nbrIsobars-1));
for ($ib = 0; $ib < $this->nbrIsobars; $ib++) {
$this->isobarColors[$ib] = array($ib*$step, 50, 255-$ib*$step);
}
}
}
else {
$n = $this->nbrIsobars;
$v = 0; $step = 1 / ($this->nbrIsobars-1);
for ($ib = 0; $ib < $this->nbrIsobars; $ib++) {
$this->isobarColors[$ib] = RGB::GetSpectrum($v);
$v += $step;
}
}
}
/**
* This is where the main work is done. For each isobar the crossing of the edges are determined
* and then each cell is analyzed to find the 0, 2 or 4 crossings. Then the normalized coordinate
* for the crossings are determined and pushed on to the isobar stack. When the method is finished
* the $isobarCoord will hold one arrayfor each isobar where all the line segments that makes
* up the contour plot are stored.
*
* @return array( $isobarCoord, $isobarValues, $isobarColors )
*/
function getIsobars() {
$this->adjustDataPointValues();
for ($isobar = 0; $isobar < $this->nbrIsobars; $isobar++) {
$ib = $this->isobarValues[$isobar];
$this->resetEdgeMatrices();
$this->determineIsobarEdgeCrossings($isobar);
$this->isobarCoord[$isobar] = array();
$ncoord = 0;
for ($row = 0 ; $row < $this->nbrRows-1; ++$row) {
for ($col = 0 ; $col < $this->nbrCols-1; ++$col ) {
// Find out how many crossings around the edges
$n = 0;
if ( $this->edges[HORIZ_EDGE][$row][$col] ) $neigh[$n++] = array($row, $col, HORIZ_EDGE);
if ( $this->edges[HORIZ_EDGE][$row+1][$col] ) $neigh[$n++] = array($row+1,$col, HORIZ_EDGE);
if ( $this->edges[VERT_EDGE][$row][$col] ) $neigh[$n++] = array($row, $col, VERT_EDGE);
if ( $this->edges[VERT_EDGE][$row][$col+1] ) $neigh[$n++] = array($row, $col+1,VERT_EDGE);
if ( $n == 2 ) {
$n1=0; $n2=1;
$this->isobarCoord[$isobar][$ncoord++] = array(
$this->getCrossingCoord($neigh[$n1][0],$neigh[$n1][1],$neigh[$n1][2],$ib),
$this->getCrossingCoord($neigh[$n2][0],$neigh[$n2][1],$neigh[$n2][2],$ib) );
}
elseif ( $n == 4 ) {
// We must determine how to connect the edges either northwest->southeast or
// northeast->southwest. We do that by calculating the imaginary middle value of
// the cell by averaging the for corners. This will compared with the value of the
// top left corner will help determine the orientation of the ridge/creek
$midval = ($this->dataPoints[$row][$col]+$this->dataPoints[$row][$col+1]+$this->dataPoints[$row+1][$col]+$this->dataPoints[$row+1][$col+1])/4;
$v = $this->dataPoints[$row][$col];
if( $midval == $ib ) {
// Orientation "+"
$n1=0; $n2=1; $n3=2; $n4=3;
} elseif ( ($midval > $ib && $v > $ib) || ($midval < $ib && $v < $ib) ) {
// Orientation of ridge/valley = "\"
$n1=0; $n2=3; $n3=2; $n4=1;
} elseif ( ($midval > $ib && $v < $ib) || ($midval < $ib && $v > $ib) ) {
// Orientation of ridge/valley = "/"
$n1=0; $n2=2; $n3=3; $n4=1;
}
$this->isobarCoord[$isobar][$ncoord++] = array(
$this->getCrossingCoord($neigh[$n1][0],$neigh[$n1][1],$neigh[$n1][2],$ib),
$this->getCrossingCoord($neigh[$n2][0],$neigh[$n2][1],$neigh[$n2][2],$ib) );
$this->isobarCoord[$isobar][$ncoord++] = array(
$this->getCrossingCoord($neigh[$n3][0],$neigh[$n3][1],$neigh[$n3][2],$ib),
$this->getCrossingCoord($neigh[$n4][0],$neigh[$n4][1],$neigh[$n4][2],$ib) );
}
}
}
}
if( count($this->isobarColors) == 0 ) {
// No manually specified colors. Calculate them automatically.
$this->CalculateColors();
}
return array( $this->isobarCoord, $this->isobarValues, $this->isobarColors );
}
}
/**
* This class represent a plotting of a contour outline of data given as a X-Y matrice
*
*/
class ContourPlot extends Plot {
private $contour, $contourCoord, $contourVal, $contourColor;
private $nbrCountours = 0 ;
private $dataMatrix = array();
private $invertLegend = false;
private $interpFactor = 1;
private $flipData = false;
private $isobar = 10;
private $showLegend = false;
private $highcontrast = false, $highcontrastbw = false;
private $manualIsobarColors = array();
/**
* Construct a contour plotting algorithm. The end result of the algorithm is a sequence of
* line segments for each isobar given as two vertices.
*
* @param $aDataMatrix The Z-data to be used
* @param $aIsobar A mixed variable, if it is an integer then this specified the number of isobars to use.
* The values of the isobars are automatically detrmined to be equ-spaced between the min/max value of the
* data. If it is an array then it explicetely gives the isobar values
* @param $aInvert By default the matrice with row index 0 corresponds to Y-value 0, i.e. in the bottom of
* the plot. If this argument is true then the row with the highest index in the matrice corresponds to
* Y-value 0. In affect flipping the matrice around an imaginary horizontal axis.
* @param $aHighContrast Use high contrast colors (blue/red:ish)
* @param $aHighContrastBW Use only black colors for contours
* @return an instance of the contour plot algorithm
*/
function __construct($aDataMatrix, $aIsobar=10, $aFactor=1, $aInvert=false, $aIsobarColors=array()) {
$this->dataMatrix = $aDataMatrix;
$this->flipData = $aInvert;
$this->isobar = $aIsobar;
$this->interpFactor = $aFactor;
if ( $this->interpFactor > 1 ) {
if( $this->interpFactor > 5 ) {
JpGraphError::RaiseL(28007);// ContourPlot interpolation factor is too large (>5)
}
$ip = new MeshInterpolate();
$this->dataMatrix = $ip->Linear($this->dataMatrix, $this->interpFactor);
}
$this->contour = new Contour($this->dataMatrix,$this->isobar,$aIsobarColors);
if( is_array($aIsobar) )
$this->nbrContours = count($aIsobar);
else
$this->nbrContours = $aIsobar;
}
/**
* Flipe the data around the center
*
* @param $aFlg
*
*/
function SetInvert($aFlg=true) {
$this->flipData = $aFlg;
}
/**
* Set the colors for the isobar lines
*
* @param $aColorArray
*
*/
function SetIsobarColors($aColorArray) {
$this->manualIsobarColors = $aColorArray;
}
/**
* Show the legend
*
* @param $aFlg true if the legend should be shown
*
*/
function ShowLegend($aFlg=true) {
$this->showLegend = $aFlg;
}
/**
* @param $aFlg true if the legend should start with the lowest isobar on top
* @return unknown_type
*/
function Invertlegend($aFlg=true) {
$this->invertLegend = $aFlg;
}
/* Internal method. Give the min value to be used for the scaling
*
*/
function Min() {
return array(0,0);
}
/* Internal method. Give the max value to be used for the scaling
*
*/
function Max() {
return array(count($this->dataMatrix[0])-1,count($this->dataMatrix)-1);
}
/**
* Internal ramewrok method to setup the legend to be used for this plot.
* @param $aGraph The parent graph class
*/
function Legend($aGraph) {
if( ! $this->showLegend )
return;
if( $this->invertLegend ) {
for ($i = 0; $i < $this->nbrContours; $i++) {
$aGraph->legend->Add(sprintf('%.1f',$this->contourVal[$i]), $this->contourColor[$i]);
}
}
else {
for ($i = $this->nbrContours-1; $i >= 0 ; $i--) {
$aGraph->legend->Add(sprintf('%.1f',$this->contourVal[$i]), $this->contourColor[$i]);
}
}
}
/**
* Framework function which gets called before the Stroke() method is called
*
* @see Plot#PreScaleSetup($aGraph)
*
*/
function PreScaleSetup($aGraph) {
$xn = count($this->dataMatrix[0])-1;
$yn = count($this->dataMatrix)-1;
$aGraph->xaxis->scale->Update($aGraph->img,0,$xn);
$aGraph->yaxis->scale->Update($aGraph->img,0,$yn);
$this->contour->SetInvert($this->flipData);
list($this->contourCoord,$this->contourVal,$this->contourColor) = $this->contour->getIsobars();
}
/**
* Use high contrast color schema
*
* @param $aFlg True, to use high contrast color
* @param $aBW True, Use only black and white color schema
*/
function UseHighContrastColor($aFlg=true,$aBW=false) {
$this->highcontrast = $aFlg;
$this->highcontrastbw = $aBW;
$this->contour->UseHighContrastColor($this->highcontrast,$this->highcontrastbw);
}
/**
* Internal method. Stroke the contour plot to the graph
*
* @param $img Image handler
* @param $xscale Instance of the xscale to use
* @param $yscale Instance of the yscale to use
*/
function Stroke($img,$xscale,$yscale) {
if( count($this->manualIsobarColors) > 0 ) {
$this->contourColor = $this->manualIsobarColors;
if( count($this->manualIsobarColors) != $this->nbrContours ) {
JpGraphError::RaiseL(28002);
}
}
$img->SetLineWeight($this->line_weight);
for ($c = 0; $c < $this->nbrContours; $c++) {
$img->SetColor( $this->contourColor[$c] );
$n = count($this->contourCoord[$c]);
$i = 0;
while ( $i < $n ) {
list($x1,$y1) = $this->contourCoord[$c][$i][0];
$x1t = $xscale->Translate($x1);
$y1t = $yscale->Translate($y1);
list($x2,$y2) = $this->contourCoord[$c][$i++][1];
$x2t = $xscale->Translate($x2);
$y2t = $yscale->Translate($y2);
$img->Line($x1t,$y1t,$x2t,$y2t);
}
}
}
}
// EOF
?>

View File

@ -1,523 +0,0 @@
<?php
/**
* jpgraph_date.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_DATE.PHP
// Description: Classes to handle Date scaling
// Created: 2005-05-02
// Ver: $Id: jpgraph_date.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
define('HOURADJ_1',0+30);
define('HOURADJ_2',1+30);
define('HOURADJ_3',2+30);
define('HOURADJ_4',3+30);
define('HOURADJ_6',4+30);
define('HOURADJ_12',5+30);
define('MINADJ_1',0+20);
define('MINADJ_5',1+20);
define('MINADJ_10',2+20);
define('MINADJ_15',3+20);
define('MINADJ_30',4+20);
define('SECADJ_1',0);
define('SECADJ_5',1);
define('SECADJ_10',2);
define('SECADJ_15',3);
define('SECADJ_30',4);
define('YEARADJ_1',0+30);
define('YEARADJ_2',1+30);
define('YEARADJ_5',2+30);
define('MONTHADJ_1',0+20);
define('MONTHADJ_6',1+20);
define('DAYADJ_1',0);
define('DAYADJ_WEEK',1);
define('DAYADJ_7',1);
define('SECPERYEAR',31536000);
define('SECPERDAY',86400);
define('SECPERHOUR',3600);
define('SECPERMIN',60);
class DateScale extends LinearScale {
private $date_format = '';
private $iStartAlign = false, $iEndAlign = false;
private $iStartTimeAlign = false, $iEndTimeAlign = false;
//---------------
// CONSTRUCTOR
function __construct($aMin=0,$aMax=0,$aType='x') {
assert($aType=="x");
assert($aMin<=$aMax);
$this->type=$aType;
$this->scale=array($aMin,$aMax);
$this->world_size=$aMax-$aMin;
$this->ticks = new LinearTicks();
$this->intscale=true;
}
//------------------------------------------------------------------------------------------
// Utility Function AdjDate()
// Description: Will round a given time stamp to an even year, month or day
// argument.
//------------------------------------------------------------------------------------------
function AdjDate($aTime,$aRound=0,$aYearType=false,$aMonthType=false,$aDayType=false) {
$y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime);
$h=0;$i=0;$s=0;
if( $aYearType !== false ) {
$yearAdj = array(0=>1, 1=>2, 2=>5);
if( $aRound == 0 ) {
$y = floor($y/$yearAdj[$aYearType])*$yearAdj[$aYearType];
}
else {
++$y;
$y = ceil($y/$yearAdj[$aYearType])*$yearAdj[$aYearType];
}
$m=1;$d=1;
}
elseif( $aMonthType !== false ) {
$monthAdj = array(0=>1, 1=>6);
if( $aRound == 0 ) {
$m = floor($m/$monthAdj[$aMonthType])*$monthAdj[$aMonthType];
$d=1;
}
else {
++$m;
$m = ceil($m/$monthAdj[$aMonthType])*$monthAdj[$aMonthType];
$d=1;
}
}
elseif( $aDayType !== false ) {
if( $aDayType == 0 ) {
if( $aRound == 1 ) {
//++$d;
$h=23;$i=59;$s=59;
}
}
else {
// Adjust to an even week boundary.
$w = (int)date('w',$aTime); // Day of week 0=Sun, 6=Sat
if( true ) { // Adjust to start on Mon
if( $w==0 ) $w=6;
else --$w;
}
if( $aRound == 0 ) {
$d -= $w;
}
else {
$d += (7-$w);
$h=23;$i=59;$s=59;
}
}
}
return mktime($h,$i,$s,$m,$d,$y);
}
//------------------------------------------------------------------------------------------
// Wrapper for AdjDate that will round a timestamp to an even date rounding
// it downwards.
//------------------------------------------------------------------------------------------
function AdjStartDate($aTime,$aYearType=false,$aMonthType=false,$aDayType=false) {
return $this->AdjDate($aTime,0,$aYearType,$aMonthType,$aDayType);
}
//------------------------------------------------------------------------------------------
// Wrapper for AdjDate that will round a timestamp to an even date rounding
// it upwards
//------------------------------------------------------------------------------------------
function AdjEndDate($aTime,$aYearType=false,$aMonthType=false,$aDayType=false) {
return $this->AdjDate($aTime,1,$aYearType,$aMonthType,$aDayType);
}
//------------------------------------------------------------------------------------------
// Utility Function AdjTime()
// Description: Will round a given time stamp to an even time according to
// argument.
//------------------------------------------------------------------------------------------
function AdjTime($aTime,$aRound=0,$aHourType=false,$aMinType=false,$aSecType=false) {
$y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime);
$h = (int)date('H',$aTime); $i = (int)date('i',$aTime); $s = (int)date('s',$aTime);
if( $aHourType !== false ) {
$aHourType %= 6;
$hourAdj = array(0=>1, 1=>2, 2=>3, 3=>4, 4=>6, 5=>12);
if( $aRound == 0 )
$h = floor($h/$hourAdj[$aHourType])*$hourAdj[$aHourType];
else {
if( ($h % $hourAdj[$aHourType]==0) && ($i > 0 || $s > 0) ) {
$h++;
}
$h = ceil($h/$hourAdj[$aHourType])*$hourAdj[$aHourType];
if( $h >= 24 ) {
$aTime += 86400;
$y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime);
$h -= 24;
}
}
$i=0;$s=0;
}
elseif( $aMinType !== false ) {
$aMinType %= 5;
$minAdj = array(0=>1, 1=>5, 2=>10, 3=>15, 4=>30);
if( $aRound == 0 ) {
$i = floor($i/$minAdj[$aMinType])*$minAdj[$aMinType];
}
else {
if( ($i % $minAdj[$aMinType]==0) && $s > 0 ) {
$i++;
}
$i = ceil($i/$minAdj[$aMinType])*$minAdj[$aMinType];
if( $i >= 60) {
$aTime += 3600;
$y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime);
$h = (int)date('H',$aTime); $i = 0;
}
}
$s=0;
}
elseif( $aSecType !== false ) {
$aSecType %= 5;
$secAdj = array(0=>1, 1=>5, 2=>10, 3=>15, 4=>30);
if( $aRound == 0 ) {
$s = floor($s/$secAdj[$aSecType])*$secAdj[$aSecType];
}
else {
$s = ceil($s/$secAdj[$aSecType]*1.0)*$secAdj[$aSecType];
if( $s >= 60) {
$s=0;
$aTime += 60;
$y = (int)date('Y',$aTime); $m = (int)date('m',$aTime); $d = (int)date('d',$aTime);
$h = (int)date('H',$aTime); $i = (int)date('i',$aTime);
}
}
}
return mktime($h,$i,$s,$m,$d,$y);
}
//------------------------------------------------------------------------------------------
// Wrapper for AdjTime that will round a timestamp to an even time rounding
// it downwards.
// Example: AdjStartTime(mktime(18,27,13,2,22,2005),false,2) => 18:20
//------------------------------------------------------------------------------------------
function AdjStartTime($aTime,$aHourType=false,$aMinType=false,$aSecType=false) {
return $this->AdjTime($aTime,0,$aHourType,$aMinType,$aSecType);
}
//------------------------------------------------------------------------------------------
// Wrapper for AdjTime that will round a timestamp to an even time rounding
// it upwards
// Example: AdjEndTime(mktime(18,27,13,2,22,2005),false,2) => 18:30
//------------------------------------------------------------------------------------------
function AdjEndTime($aTime,$aHourType=false,$aMinType=false,$aSecType=false) {
return $this->AdjTime($aTime,1,$aHourType,$aMinType,$aSecType);
}
//------------------------------------------------------------------------------------------
// DateAutoScale
// Autoscale a date axis given start and end time
// Returns an array ($start,$end,$major,$minor,$format)
//------------------------------------------------------------------------------------------
function DoDateAutoScale($aStartTime,$aEndTime,$aDensity=0,$aAdjust=true) {
// Format of array
// array ( Decision point, array( array( Major-scale-step-array ),
// array( Minor-scale-step-array ),
// array( 0=date-adjust, 1=time-adjust, adjustment-alignment) )
//
$scalePoints =
array(
/* Intervall larger than 10 years */
SECPERYEAR*10,array(array(SECPERYEAR*5,SECPERYEAR*2),
array(SECPERYEAR),
array(0,YEARADJ_1, 0,YEARADJ_1) ),
/* Intervall larger than 2 years */
SECPERYEAR*2,array(array(SECPERYEAR),array(SECPERYEAR),
array(0,YEARADJ_1) ),
/* Intervall larger than 90 days (approx 3 month) */
SECPERDAY*90,array(array(SECPERDAY*30,SECPERDAY*14,SECPERDAY*7,SECPERDAY),
array(SECPERDAY*5,SECPERDAY*7,SECPERDAY,SECPERDAY),
array(0,MONTHADJ_1, 0,DAYADJ_WEEK, 0,DAYADJ_1, 0,DAYADJ_1)),
/* Intervall larger than 30 days (approx 1 month) */
SECPERDAY*30,array(array(SECPERDAY*14,SECPERDAY*7,SECPERDAY*2, SECPERDAY),
array(SECPERDAY,SECPERDAY,SECPERDAY,SECPERDAY),
array(0,DAYADJ_WEEK, 0,DAYADJ_1, 0,DAYADJ_1, 0,DAYADJ_1)),
/* Intervall larger than 7 days */
SECPERDAY*7,array(array(SECPERDAY,SECPERHOUR*12,SECPERHOUR*6,SECPERHOUR*2),
array(SECPERHOUR*6,SECPERHOUR*3,SECPERHOUR,SECPERHOUR),
array(0,DAYADJ_1, 1,HOURADJ_12, 1,HOURADJ_6, 1,HOURADJ_1)),
/* Intervall larger than 1 day */
SECPERDAY,array(array(SECPERDAY,SECPERHOUR*12,SECPERHOUR*6,SECPERHOUR*2,SECPERHOUR),
array(SECPERHOUR*6,SECPERHOUR*2,SECPERHOUR,SECPERHOUR,SECPERHOUR),
array(1,HOURADJ_12, 1,HOURADJ_6, 1,HOURADJ_1, 1,HOURADJ_1)),
/* Intervall larger than 12 hours */
SECPERHOUR*12,array(array(SECPERHOUR*2,SECPERHOUR,SECPERMIN*30,900,600),
array(1800,1800,900,300,300),
array(1,HOURADJ_1, 1,MINADJ_30, 1,MINADJ_15, 1,MINADJ_10, 1,MINADJ_5) ),
/* Intervall larger than 2 hours */
SECPERHOUR*2,array(array(SECPERHOUR,SECPERMIN*30,900,600,300),
array(1800,900,300,120,60),
array(1,HOURADJ_1, 1,MINADJ_30, 1,MINADJ_15, 1,MINADJ_10, 1,MINADJ_5) ),
/* Intervall larger than 1 hours */
SECPERHOUR,array(array(SECPERMIN*30,900,600,300),array(900,300,120,60),
array(1,MINADJ_30, 1,MINADJ_15, 1,MINADJ_10, 1,MINADJ_5) ),
/* Intervall larger than 30 min */
SECPERMIN*30,array(array(SECPERMIN*15,SECPERMIN*10,SECPERMIN*5,SECPERMIN),
array(300,300,60,10),
array(1,MINADJ_15, 1,MINADJ_10, 1,MINADJ_5, 1,MINADJ_1)),
/* Intervall larger than 1 min */
SECPERMIN,array(array(SECPERMIN,15,10,5),
array(15,5,2,1),
array(1,MINADJ_1, 1,SECADJ_15, 1,SECADJ_10, 1,SECADJ_5)),
/* Intervall larger than 10 sec */
10,array(array(5,2),
array(1,1),
array(1,SECADJ_5, 1,SECADJ_1)),
/* Intervall larger than 1 sec */
1,array(array(1),
array(1),
array(1,SECADJ_1)),
);
$ns = count($scalePoints);
// Establish major and minor scale units for the date scale
$diff = $aEndTime - $aStartTime;
if( $diff < 1 ) return false;
$done=false;
$i=0;
while( ! $done ) {
if( $diff > $scalePoints[2*$i] ) {
// Get major and minor scale for this intervall
$scaleSteps = $scalePoints[2*$i+1];
$major = $scaleSteps[0][min($aDensity,count($scaleSteps[0])-1)];
// Try to find out which minor step looks best
$minor = $scaleSteps[1][min($aDensity,count($scaleSteps[1])-1)];
if( $aAdjust ) {
// Find out how we should align the start and end timestamps
$idx = 2*min($aDensity,floor(count($scaleSteps[2])/2)-1);
if( $scaleSteps[2][$idx] === 0 ) {
// Use date adjustment
$adj = $scaleSteps[2][$idx+1];
if( $adj >= 30 ) {
$start = $this->AdjStartDate($aStartTime,$adj-30);
$end = $this->AdjEndDate($aEndTime,$adj-30);
}
elseif( $adj >= 20 ) {
$start = $this->AdjStartDate($aStartTime,false,$adj-20);
$end = $this->AdjEndDate($aEndTime,false,$adj-20);
}
else {
$start = $this->AdjStartDate($aStartTime,false,false,$adj);
$end = $this->AdjEndDate($aEndTime,false,false,$adj);
// We add 1 second for date adjustment to make sure we end on 00:00 the following day
// This makes the final major tick be srawn when we step day-by-day instead of ending
// on xx:59:59 which would not draw the final major tick
$end++;
}
}
else {
// Use time adjustment
$adj = $scaleSteps[2][$idx+1];
if( $adj >= 30 ) {
$start = $this->AdjStartTime($aStartTime,$adj-30);
$end = $this->AdjEndTime($aEndTime,$adj-30);
}
elseif( $adj >= 20 ) {
$start = $this->AdjStartTime($aStartTime,false,$adj-20);
$end = $this->AdjEndTime($aEndTime,false,$adj-20);
}
else {
$start = $this->AdjStartTime($aStartTime,false,false,$adj);
$end = $this->AdjEndTime($aEndTime,false,false,$adj);
}
}
}
// If the overall date span is larger than 1 day ten we show date
$format = '';
if( ($end-$start) > SECPERDAY ) {
$format = 'Y-m-d ';
}
// If the major step is less than 1 day we need to whow hours + min
if( $major < SECPERDAY ) {
$format .= 'H:i';
}
// If the major step is less than 1 min we need to show sec
if( $major < 60 ) {
$format .= ':s';
}
$done=true;
}
++$i;
}
return array($start,$end,$major,$minor,$format);
}
// Overrides the automatic determined date format. Must be a valid date() format string
function SetDateFormat($aFormat) {
$this->date_format = $aFormat;
$this->ticks->SetLabelDateFormat($this->date_format);
}
function AdjustForDST($aFlg=true) {
$this->ticks->AdjustForDST($aFlg);
}
function SetDateAlign($aStartAlign,$aEndAlign=false) {
if( $aEndAlign === false ) {
$aEndAlign=$aStartAlign;
}
$this->iStartAlign = $aStartAlign;
$this->iEndAlign = $aEndAlign;
}
function SetTimeAlign($aStartAlign,$aEndAlign=false) {
if( $aEndAlign === false ) {
$aEndAlign=$aStartAlign;
}
$this->iStartTimeAlign = $aStartAlign;
$this->iEndTimeAlign = $aEndAlign;
}
function AutoScale($img,$aStartTime,$aEndTime,$aNumSteps,$_adummy=false) {
// We need to have one dummy argument to make the signature of AutoScale()
// identical to LinearScale::AutoScale
if( $aStartTime == $aEndTime ) {
// Special case when we only have one data point.
// Create a small artifical intervall to do the autoscaling
$aStartTime -= 10;
$aEndTime += 10;
}
$done=false;
$i=0;
while( ! $done && $i < 5) {
list($adjstart,$adjend,$maj,$min,$format) = $this->DoDateAutoScale($aStartTime,$aEndTime,$i);
$n = floor(($adjend-$adjstart)/$maj);
if( $n * 1.7 > $aNumSteps ) {
$done=true;
}
$i++;
}
/*
if( 0 ) { // DEBUG
echo " Start =".date("Y-m-d H:i:s",$aStartTime)."<br>";
echo " End =".date("Y-m-d H:i:s",$aEndTime)."<br>";
echo "Adj Start =".date("Y-m-d H:i:s",$adjstart)."<br>";
echo "Adj End =".date("Y-m-d H:i:s",$adjend)."<p>";
echo "Major = $maj s, ".floor($maj/60)."min, ".floor($maj/3600)."h, ".floor($maj/86400)."day<br>";
echo "Min = $min s, ".floor($min/60)."min, ".floor($min/3600)."h, ".floor($min/86400)."day<br>";
echo "Format=$format<p>";
}
*/
if( $this->iStartTimeAlign !== false && $this->iStartAlign !== false ) {
JpGraphError::RaiseL(3001);
//('It is only possible to use either SetDateAlign() or SetTimeAlign() but not both');
}
if( $this->iStartTimeAlign !== false ) {
if( $this->iStartTimeAlign >= 30 ) {
$adjstart = $this->AdjStartTime($aStartTime,$this->iStartTimeAlign-30);
}
elseif( $this->iStartTimeAlign >= 20 ) {
$adjstart = $this->AdjStartTime($aStartTime,false,$this->iStartTimeAlign-20);
}
else {
$adjstart = $this->AdjStartTime($aStartTime,false,false,$this->iStartTimeAlign);
}
}
if( $this->iEndTimeAlign !== false ) {
if( $this->iEndTimeAlign >= 30 ) {
$adjend = $this->AdjEndTime($aEndTime,$this->iEndTimeAlign-30);
}
elseif( $this->iEndTimeAlign >= 20 ) {
$adjend = $this->AdjEndTime($aEndTime,false,$this->iEndTimeAlign-20);
}
else {
$adjend = $this->AdjEndTime($aEndTime,false,false,$this->iEndTimeAlign);
}
}
if( $this->iStartAlign !== false ) {
if( $this->iStartAlign >= 30 ) {
$adjstart = $this->AdjStartDate($aStartTime,$this->iStartAlign-30);
}
elseif( $this->iStartAlign >= 20 ) {
$adjstart = $this->AdjStartDate($aStartTime,false,$this->iStartAlign-20);
}
else {
$adjstart = $this->AdjStartDate($aStartTime,false,false,$this->iStartAlign);
}
}
if( $this->iEndAlign !== false ) {
if( $this->iEndAlign >= 30 ) {
$adjend = $this->AdjEndDate($aEndTime,$this->iEndAlign-30);
}
elseif( $this->iEndAlign >= 20 ) {
$adjend = $this->AdjEndDate($aEndTime,false,$this->iEndAlign-20);
}
else {
$adjend = $this->AdjEndDate($aEndTime,false,false,$this->iEndAlign);
}
}
$this->Update($img,$adjstart,$adjend);
if( ! $this->ticks->IsSpecified() )
$this->ticks->Set($maj,$min);
if( $this->date_format == '' )
$this->ticks->SetLabelDateFormat($format);
else
$this->ticks->SetLabelDateFormat($this->date_format);
}
}
?>

View File

@ -1,392 +0,0 @@
<?php
/**
* jpgraph_errhandler.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_ERRHANDLER.PHP
// Description: Error handler class together with handling of localized
// error messages. All localized error messages are stored
// in a separate file under the "lang/" subdirectory.
// Created: 2006-09-24
// Ver: $Id: jpgraph_errhandler.inc.php 1920 2009-12-08 10:02:26Z ljp $
//
// Copyright 2006 (c) Aditus Consulting. All rights reserved.
//========================================================================
if( !defined('DEFAULT_ERR_LOCALE') ) {
define('DEFAULT_ERR_LOCALE','en');
}
if( !defined('USE_IMAGE_ERROR_HANDLER') ) {
define('USE_IMAGE_ERROR_HANDLER',true);
}
GLOBAL $__jpg_err_locale ;
$__jpg_err_locale = DEFAULT_ERR_LOCALE;
class ErrMsgText {
private $lt=NULL;
function __construct() {
GLOBAL $__jpg_err_locale;
$file = 'lang/'.$__jpg_err_locale.'.inc.php';
// If the chosen locale doesn't exist try english
if( !file_exists(dirname(__FILE__).'/'.$file) ) {
$__jpg_err_locale = 'en';
}
$file = 'lang/'.$__jpg_err_locale.'.inc.php';
if( !file_exists(dirname(__FILE__).'/'.$file) ) {
die('Chosen locale file ("'.$file.'") for error messages does not exist or is not readable for the PHP process. Please make sure that the file exists and that the file permissions are such that the PHP process is allowed to read this file.');
}
require($file);
$this->lt = $_jpg_messages;
}
function Get($errnbr,$a1=null,$a2=null,$a3=null,$a4=null,$a5=null) {
GLOBAL $__jpg_err_locale;
if( !isset($this->lt[$errnbr]) ) {
return 'Internal error: The specified error message ('.$errnbr.') does not exist in the chosen locale ('.$__jpg_err_locale.')';
}
$ea = $this->lt[$errnbr];
$j=0;
if( $a1 !== null ) {
$argv[$j++] = $a1;
if( $a2 !== null ) {
$argv[$j++] = $a2;
if( $a3 !== null ) {
$argv[$j++] = $a3;
if( $a4 !== null ) {
$argv[$j++] = $a4;
if( $a5 !== null ) {
$argv[$j++] = $a5;
}
}
}
}
}
$numargs = $j;
if( $ea[1] != $numargs ) {
// Error message argument count do not match.
// Just return the error message without arguments.
return $ea[0];
}
switch( $numargs ) {
case 1:
$msg = sprintf($ea[0],$argv[0]);
break;
case 2:
$msg = sprintf($ea[0],$argv[0],$argv[1]);
break;
case 3:
$msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2]);
break;
case 4:
$msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2],$argv[3]);
break;
case 5:
$msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2],$argv[3],$argv[4]);
break;
case 0:
default:
$msg = sprintf($ea[0]);
break;
}
return $msg;
}
}
//
// A wrapper class that is used to access the specified error object
// (to hide the global error parameter and avoid having a GLOBAL directive
// in all methods.
//
class JpGraphError {
private static $__iImgFlg = true;
private static $__iLogFile = '';
private static $__iTitle = 'JpGraph Error: ';
public static function Raise($aMsg,$aHalt=true){
throw new JpGraphException($aMsg);
}
public static function SetErrLocale($aLoc) {
GLOBAL $__jpg_err_locale ;
$__jpg_err_locale = $aLoc;
}
public static function RaiseL($errnbr,$a1=null,$a2=null,$a3=null,$a4=null,$a5=null) {
throw new JpGraphExceptionL($errnbr,$a1,$a2,$a3,$a4,$a5);
}
public static function SetImageFlag($aFlg=true) {
self::$__iImgFlg = $aFlg;
}
public static function GetImageFlag() {
return self::$__iImgFlg;
}
public static function SetLogFile($aFile) {
self::$__iLogFile = $aFile;
}
public static function GetLogFile() {
return self::$__iLogFile;
}
public static function SetTitle($aTitle) {
self::$__iTitle = $aTitle;
}
public static function GetTitle() {
return self::$__iTitle;
}
}
class JpGraphException extends Exception {
// Redefine the exception so message isn't optional
public function __construct($message, $code = 0) {
// make sure everything is assigned properly
parent::__construct($message, $code);
}
// custom string representation of object
public function _toString() {
return __CLASS__ . ": [{$this->code}]: {$this->message} at " . basename($this->getFile()) . ":" . $this->getLine() . "\n" . $this->getTraceAsString() . "\n";
}
// custom representation of error as an image
public function Stroke() {
if( JpGraphError::GetImageFlag() ) {
$errobj = new JpGraphErrObjectImg();
$errobj->SetTitle(JpGraphError::GetTitle());
}
else {
$errobj = new JpGraphErrObject();
$errobj->SetTitle(JpGraphError::GetTitle());
$errobj->SetStrokeDest(JpGraphError::GetLogFile());
}
$errobj->Raise($this->getMessage());
}
static public function defaultHandler(Exception $exception) {
global $__jpg_OldHandler;
if( $exception instanceof JpGraphException ) {
$exception->Stroke();
}
else {
// Restore old handler
if( $__jpg_OldHandler !== NULL ) {
set_exception_handler($__jpg_OldHandler);
}
throw $exception;
}
}
}
class JpGraphExceptionL extends JpGraphException {
// Redefine the exception so message isn't optional
public function __construct($errcode,$a1=null,$a2=null,$a3=null,$a4=null,$a5=null) {
// make sure everything is assigned properly
$errtxt = new ErrMsgText();
JpGraphError::SetTitle('JpGraph Error: '.$errcode);
parent::__construct($errtxt->Get($errcode,$a1,$a2,$a3,$a4,$a5), 0);
}
}
// Setup the default handler
global $__jpg_OldHandler;
$__jpg_OldHandler = set_exception_handler(array('JpGraphException','defaultHandler'));
//
// First of all set up a default error handler
//
//=============================================================
// The default trivial text error handler.
//=============================================================
class JpGraphErrObject {
protected $iTitle = "JpGraph error: ";
protected $iDest = false;
function __construct() {
// Empty. Reserved for future use
}
function SetTitle($aTitle) {
$this->iTitle = $aTitle;
}
function SetStrokeDest($aDest) {
$this->iDest = $aDest;
}
// If aHalt is true then execution can't continue. Typical used for fatal errors
function Raise($aMsg,$aHalt=false) {
if( $this->iDest != '' ) {
if( $this->iDest == 'syslog' ) {
error_log($this->iTitle.$aMsg);
}
else {
$str = '['.date('r').'] '.$this->iTitle.$aMsg."\n";
$f = @fopen($this->iDest,'a');
if( $f ) {
@fwrite($f,$str);
@fclose($f);
}
}
}
else {
$aMsg = $this->iTitle.$aMsg;
// Check SAPI and if we are called from the command line
// send the error to STDERR instead
if( PHP_SAPI == 'cli' ) {
fwrite(STDERR,$aMsg);
}
else {
echo $aMsg;
}
}
if( $aHalt )
exit(1);
}
}
//==============================================================
// An image based error handler
//==============================================================
class JpGraphErrObjectImg extends JpGraphErrObject {
function __construct() {
parent::__construct();
// Empty. Reserved for future use
}
function Raise($aMsg,$aHalt=true) {
$img_iconerror =
'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaV'.
'BMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/'.
'f0VyckJlZT9YWDxMTDjAwMDy8sLl5bnY2K/MzKW/v5yyspKlpY'.
'iYmH+MjHY/PzV/f2xycmJlZVlZWU9MTEXY2Ms/PzwyMjLFTjea'.
'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx'.
'IAAAsSAdLdfvwAAAAHdElNRQfTBgISOCqusfs5AAABLUlEQVR4'.
'2tWV3XKCMBBGWfkranCIVClKLd/7P2Q3QsgCxjDTq+6FE2cPH+'.
'xJ0Ogn2lQbsT+Wrs+buAZAV4W5T6Bs0YXBBwpKgEuIu+JERAX6'.
'wM2rHjmDdEITmsQEEmWADgZm6rAjhXsoMGY9B/NZBwJzBvn+e3'.
'wHntCAJdGu9SviwIwoZVDxPB9+Rc0TSEbQr0j3SA1gwdSn6Db0'.
'6Tm1KfV6yzWGQO7zdpvyKLKBDmRFjzeB3LYgK7r6A/noDAfjtS'.
'IXaIzbJSv6WgUebTMV4EoRB8a2mQiQjgtF91HdKDKZ1gtFtQjk'.
'YcWaR5OKOhkYt+ZsTFdJRfPAApOpQYJTNHvCRSJR6SJngQadfc'.
'vd69OLMddVOPCGVnmrFD8bVYd3JXfxXPtLR/+mtv59/ALWiiMx'.
'qL72fwAAAABJRU5ErkJggg==' ;
if( function_exists("imagetypes") ) {
$supported = imagetypes();
} else {
$supported = 0;
}
if( !function_exists('imagecreatefromstring') ) {
$supported = 0;
}
if( ob_get_length() || headers_sent() || !($supported & IMG_PNG) ) {
// Special case for headers already sent or that the installation doesn't support
// the PNG format (which the error icon is encoded in).
// Dont return an image since it can't be displayed
die($this->iTitle.' '.$aMsg);
}
$aMsg = wordwrap($aMsg,55);
$lines = substr_count($aMsg,"\n");
// Create the error icon GD
$erricon = Image::CreateFromString(base64_decode($img_iconerror));
// Create an image that contains the error text.
$w=400;
$h=100 + 15*max(0,$lines-3);
$img = new Image($w,$h);
// Drop shadow
$img->SetColor("gray");
$img->FilledRectangle(5,5,$w-1,$h-1,10);
$img->SetColor("gray:0.7");
$img->FilledRectangle(5,5,$w-3,$h-3,10);
// Window background
$img->SetColor("lightblue");
$img->FilledRectangle(1,1,$w-5,$h-5);
$img->CopyCanvasH($img->img,$erricon,5,30,0,0,40,40);
// Window border
$img->SetColor("black");
$img->Rectangle(1,1,$w-5,$h-5);
$img->Rectangle(0,0,$w-4,$h-4);
// Window top row
$img->SetColor("darkred");
for($y=3; $y < 18; $y += 2 )
$img->Line(1,$y,$w-6,$y);
// "White shadow"
$img->SetColor("white");
// Left window edge
$img->Line(2,2,2,$h-5);
$img->Line(2,2,$w-6,2);
// "Gray button shadow"
$img->SetColor("darkgray");
// Gray window shadow
$img->Line(2,$h-6,$w-5,$h-6);
$img->Line(3,$h-7,$w-5,$h-7);
// Window title
$m = floor($w/2-5);
$l = 110;
$img->SetColor("lightgray:1.3");
$img->FilledRectangle($m-$l,2,$m+$l,16);
// Stroke text
$img->SetColor("darkred");
$img->SetFont(FF_FONT2,FS_BOLD);
$img->StrokeText($m-90,15,$this->iTitle);
$img->SetColor("black");
$img->SetFont(FF_FONT1,FS_NORMAL);
$txt = new Text($aMsg,52,25);
$txt->Align("left","top");
$txt->Stroke($img);
if ($this->iDest) {
$img->Stream($this->iDest);
} else {
$img->Headers();
$img->Stream();
}
if( $aHalt )
die();
}
}
if( ! USE_IMAGE_ERROR_HANDLER ) {
JpGraphError::SetImageFlag(false);
}
?>

View File

@ -1,181 +0,0 @@
<?php
/**
* jpgraph_error.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_ERROR.PHP
// Description: Error plot extension for JpGraph
// Created: 2001-01-08
// Ver: $Id: jpgraph_error.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
//===================================================
// CLASS ErrorPlot
// Description: Error plot with min/max value for
// each datapoint
//===================================================
class ErrorPlot extends Plot {
private $errwidth=2;
//---------------
// CONSTRUCTOR
function __construct($datay,$datax=false) {
parent::__construct($datay,$datax);
$this->numpoints /= 2;
}
//---------------
// PUBLIC METHODS
// Gets called before any axis are stroked
function PreStrokeAdjust($graph) {
if( $this->center ) {
$a=0.5; $b=0.5;
++$this->numpoints;
} else {
$a=0; $b=0;
}
$graph->xaxis->scale->ticks->SetXLabelOffset($a);
$graph->SetTextScaleOff($b);
//$graph->xaxis->scale->ticks->SupressMinorTickMarks();
}
// Method description
function Stroke($img,$xscale,$yscale) {
$numpoints=count($this->coords[0])/2;
$img->SetColor($this->color);
$img->SetLineWeight($this->weight);
if( isset($this->coords[1]) ) {
if( count($this->coords[1])!=$numpoints )
JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints);
//("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
else
$exist_x = true;
}
else
$exist_x = false;
for( $i=0; $i<$numpoints; ++$i) {
if( $exist_x )
$x=$this->coords[1][$i];
else
$x=$i;
if( !is_numeric($x) ||
!is_numeric($this->coords[0][$i*2]) || !is_numeric($this->coords[0][$i*2+1]) ) {
continue;
}
$xt = $xscale->Translate($x);
$yt1 = $yscale->Translate($this->coords[0][$i*2]);
$yt2 = $yscale->Translate($this->coords[0][$i*2+1]);
$img->Line($xt,$yt1,$xt,$yt2);
$img->Line($xt-$this->errwidth,$yt1,$xt+$this->errwidth,$yt1);
$img->Line($xt-$this->errwidth,$yt2,$xt+$this->errwidth,$yt2);
}
return true;
}
} // Class
//===================================================
// CLASS ErrorLinePlot
// Description: Combine a line and error plot
// THIS IS A DEPRECATED PLOT TYPE JUST KEPT FOR
// BACKWARD COMPATIBILITY
//===================================================
class ErrorLinePlot extends ErrorPlot {
public $line=null;
//---------------
// CONSTRUCTOR
function __construct($datay,$datax=false) {
parent::__construct($datay,$datax);
// Calculate line coordinates as the average of the error limits
$n = count($datay);
for($i=0; $i < $n; $i+=2 ) {
$ly[]=($datay[$i]+$datay[$i+1])/2;
}
$this->line=new LinePlot($ly,$datax);
}
//---------------
// PUBLIC METHODS
function Legend($graph) {
if( $this->legend != "" )
$graph->legend->Add($this->legend,$this->color);
$this->line->Legend($graph);
}
function Stroke($img,$xscale,$yscale) {
parent::Stroke($img,$xscale,$yscale);
$this->line->Stroke($img,$xscale,$yscale);
}
} // Class
//===================================================
// CLASS LineErrorPlot
// Description: Combine a line and error plot
//===================================================
class LineErrorPlot extends ErrorPlot {
public $line=null;
//---------------
// CONSTRUCTOR
// Data is (val, errdeltamin, errdeltamax)
function __construct($datay,$datax=false) {
$ly=array(); $ey=array();
$n = count($datay);
if( $n % 3 != 0 ) {
JpGraphError::RaiseL(4002);
//('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3');
}
for($i=0; $i < $n; $i+=3 ) {
$ly[]=$datay[$i];
$ey[]=$datay[$i]+$datay[$i+1];
$ey[]=$datay[$i]+$datay[$i+2];
}
parent::__construct($ey,$datax);
$this->line=new LinePlot($ly,$datax);
}
//---------------
// PUBLIC METHODS
function Legend($graph) {
if( $this->legend != "" )
$graph->legend->Add($this->legend,$this->color);
$this->line->Legend($graph);
}
function Stroke($img,$xscale,$yscale) {
parent::Stroke($img,$xscale,$yscale);
$this->line->Stroke($img,$xscale,$yscale);
}
} // Class
/* EOF */
?>

View File

@ -1,400 +0,0 @@
<?php
/**
* jpgraph_flags.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_FLAGS.PHP
// Description: Class Jpfile. Handles plotmarks
// Created: 2003-06-28
// Ver: $Id: jpgraph_flags.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
//------------------------------------------------------------
// Defines for the different basic sizes of flags
//------------------------------------------------------------
DEFINE('FLAGSIZE1',1);
DEFINE('FLAGSIZE2',2);
DEFINE('FLAGSIZE3',3);
DEFINE('FLAGSIZE4',4);
class FlagImages {
public $iCountryNameMap = array(
'Afghanistan' => 'afgh',
'Republic of Angola' => 'agla',
'Republic of Albania' => 'alba',
'Alderney' => 'alde',
'Democratic and Popular Republic of Algeria' => 'alge',
'Territory of American Samoa' => 'amsa',
'Principality of Andorra' => 'andr',
'British Overseas Territory of Anguilla' => 'angu',
'Antarctica' => 'anta',
'Argentine Republic' => 'arge',
'League of Arab States' => 'arle',
'Republic of Armenia' => 'arme',
'Aruba' => 'arub',
'Commonwealth of Australia' => 'astl',
'Republic of Austria' => 'aust',
'Azerbaijani Republic' => 'azer',
'Bangladesh' => 'bngl',
'British Antarctic Territory' => 'bant',
'Kingdom of Belgium' => 'belg',
'British Overseas Territory of Bermuda' => 'berm',
'Commonwealth of the Bahamas' => 'bhms',
'Kingdom of Bahrain' => 'bhrn',
'Republic of Belarus' => 'blru',
'Republic of Bolivia' => 'blva',
'Belize' => 'blze',
'Republic of Benin' => 'bnin',
'Republic of Botswana' => 'bots',
'Federative Republic of Brazil' => 'braz',
'Barbados' => 'brbd',
'British Indian Ocean Territory' => 'brin',
'Brunei Darussalam' => 'brun',
'Republic of Burkina' => 'bufa',
'Republic of Bulgaria' => 'bulg',
'Republic of Burundi' => 'buru',
'Overseas Territory of the British Virgin Islands' => 'bvis',
'Central African Republic' => 'cafr',
'Kingdom of Cambodia' => 'camb',
'Republic of Cameroon' => 'came',
'Dominion of Canada' => 'cana',
'Caribbean Community' => 'cari',
'Republic of Cape Verde' => 'cave',
'Republic of Chad' => 'chad',
'Republic of Chile' => 'chil',
'Peoples Republic of China' => 'chin',
'Territory of Christmas Island' => 'chms',
'Commonwealth of Independent States' => 'cins',
'Cook Islands' => 'ckis',
'Republic of Colombia' => 'clmb',
'Territory of Cocos Islands' => 'cois',
'Commonwealth' => 'comn',
'Union of the Comoros' => 'como',
'Republic of the Congo' => 'cong',
'Republic of Costa Rica' => 'corc',
'Republic of Croatia' => 'croa',
'Republic of Cuba' => 'cuba',
'British Overseas Territory of the Cayman Islands' => 'cyis',
'Republic of Cyprus' => 'cypr',
'The Czech Republic' => 'czec',
'Kingdom of Denmark' => 'denm',
'Republic of Djibouti' => 'djib',
'Commonwealth of Dominica' => 'domn',
'Dominican Republic' => 'dore',
'Republic of Ecuador' => 'ecua',
'Arab Republic of Egypt' => 'egyp',
'Republic of El Salvador' => 'elsa',
'England' => 'engl',
'Republic of Equatorial Guinea' => 'eqgu',
'State of Eritrea' => 'erit',
'Republic of Estonia' => 'estn',
'Ethiopia' => 'ethp',
'European Union' => 'euun',
'British Overseas Territory of the Falkland Islands' => 'fais',
'International Federation of Vexillological Associations' => 'fiav',
'Republic of Fiji' => 'fiji',
'Republic of Finland' => 'finl',
'Territory of French Polynesia' => 'fpol',
'French Republic' => 'fran',
'Overseas Department of French Guiana' => 'frgu',
'Gabonese Republic' => 'gabn',
'Republic of the Gambia' => 'gamb',
'Republic of Georgia' => 'geor',
'Federal Republic of Germany' => 'germ',
'Republic of Ghana' => 'ghan',
'Gibraltar' => 'gibr',
'Hellenic Republic' => 'grec',
'State of Grenada' => 'gren',
'Overseas Department of Guadeloupe' => 'guad',
'Territory of Guam' => 'guam',
'Republic of Guatemala' => 'guat',
'The Bailiwick of Guernsey' => 'guer',
'Republic of Guinea' => 'guin',
'Republic of Haiti' => 'hait',
'Hong Kong Special Administrative Region' => 'hokn',
'Republic of Honduras' => 'hond',
'Republic of Hungary' => 'hung',
'Republic of Iceland' => 'icel',
'International Committee of the Red Cross' => 'icrc',
'Republic of India' => 'inda',
'Republic of Indonesia' => 'indn',
'Republic of Iraq' => 'iraq',
'Republic of Ireland' => 'irel',
'Organization of the Islamic Conference' => 'isco',
'Isle of Man' => 'isma',
'State of Israel' => 'isra',
'Italian Republic' => 'ital',
'Jamaica' => 'jama',
'Japan' => 'japa',
'The Bailiwick of Jersey' => 'jers',
'Hashemite Kingdom of Jordan' => 'jord',
'Republic of Kazakhstan' => 'kazk',
'Republic of Kenya' => 'keny',
'Republic of Kiribati' => 'kirb',
'State of Kuwait' => 'kuwa',
'Kyrgyz Republic' => 'kyrg',
'Republic of Latvia' => 'latv',
'Lebanese Republic' => 'leba',
'Kingdom of Lesotho' => 'lest',
'Republic of Liberia' => 'libe',
'Principality of Liechtenstein' => 'liec',
'Republic of Lithuania' => 'lith',
'Grand Duchy of Luxembourg' => 'luxe',
'Macao Special Administrative Region' => 'maca',
'Republic of Macedonia' => 'mace',
'Republic of Madagascar' => 'mada',
'Republic of the Marshall Islands' => 'mais',
'Republic of Mali' => 'mali',
'Federation of Malaysia' => 'mals',
'Republic of Malta' => 'malt',
'Republic of Malawi' => 'malw',
'Overseas Department of Martinique' => 'mart',
'Islamic Republic of Mauritania' => 'maur',
'Territorial Collectivity of Mayotte' => 'mayt',
'United Mexican States' => 'mexc',
'Federated States of Micronesia' => 'micr',
'Midway Islands' => 'miis',
'Republic of Moldova' => 'mold',
'Principality of Monaco' => 'mona',
'Republic of Mongolia' => 'mong',
'British Overseas Territory of Montserrat' => 'mont',
'Kingdom of Morocco' => 'morc',
'Republic of Mozambique' => 'moza',
'Republic of Mauritius' => 'mrts',
'Union of Myanmar' => 'myan',
'Republic of Namibia' => 'namb',
'North Atlantic Treaty Organization' => 'nato',
'Republic of Nauru' => 'naur',
'Turkish Republic of Northern Cyprus' => 'ncyp',
'Netherlands Antilles' => 'nean',
'Kingdom of Nepal' => 'nepa',
'Kingdom of the Netherlands' => 'neth',
'Territory of Norfolk Island' => 'nfis',
'Federal Republic of Nigeria' => 'ngra',
'Republic of Nicaragua' => 'nica',
'Republic of Niger' => 'nigr',
'Niue' => 'niue',
'Commonwealth of the Northern Mariana Islands' => 'nmar',
'Province of Northern Ireland' => 'noir',
'Nordic Council' => 'nord',
'Kingdom of Norway' => 'norw',
'Territory of New Caledonia and Dependencies' => 'nwca',
'New Zealand' => 'nwze',
'Organization of American States' => 'oast',
'Organization of African Unity' => 'oaun',
'International Olympic Committee' => 'olym',
'Sultanate of Oman' => 'oman',
'Islamic Republic of Pakistan' => 'paks',
'Republic of Palau' => 'pala',
'Independent State of Papua New Guinea' => 'pang',
'Republic of Paraguay' => 'para',
'Republic of Peru' => 'peru',
'Republic of the Philippines' => 'phil',
'British Overseas Territory of the Pitcairn Islands' => 'piis',
'Republic of Poland' => 'pola',
'Republic of Portugal' => 'port',
'Commonwealth of Puerto Rico' => 'purc',
'State of Qatar' => 'qata',
'Russian Federation' => 'russ',
'Romania' => 'rmna',
'Republic of Rwanda' => 'rwan',
'Kingdom of Saudi Arabia' => 'saar',
'Republic of San Marino' => 'sama',
'Nordic Sami Conference' => 'sami',
'Sark' => 'sark',
'Scotland' => 'scot',
'Principality of Seborga' => 'sebo',
'Republic of Serbia' => 'serb',
'Republic of Sierra Leone' => 'sile',
'Republic of Singapore' => 'sing',
'Republic of Korea' => 'skor',
'Republic of Slovenia' => 'slva',
'Somali Republic' => 'smla',
'Republic of Somaliland' => 'smld',
'Republic of South Africa' => 'soaf',
'Solomon Islands' => 'sois',
'Kingdom of Spain' => 'span',
'Secretariat of the Pacific Community' => 'spco',
'Democratic Socialist Republic of Sri Lanka' => 'srla',
'Saint Lucia' => 'stlu',
'Republic of the Sudan' => 'suda',
'Republic of Suriname' => 'surn',
'Slovak Republic' => 'svka',
'Kingdom of Sweden' => 'swdn',
'Swiss Confederation' => 'swit',
'Syrian Arab Republic' => 'syra',
'Kingdom of Swaziland' => 'szld',
'Republic of China' => 'taiw',
'Taiwan' => 'taiw',
'Republic of Tajikistan' => 'tajk',
'United Republic of Tanzania' => 'tanz',
'Kingdom of Thailand' => 'thal',
'Autonomous Region of Tibet' => 'tibe',
'Turkmenistan' => 'tkst',
'Togolese Republic' => 'togo',
'Tokelau' => 'toke',
'Kingdom of Tonga' => 'tong',
'Tristan da Cunha' => 'trdc',
'Tromelin' => 'tris',
'Republic of Tunisia' => 'tuns',
'Republic of Turkey' => 'turk',
'Tuvalu' => 'tuva',
'United Arab Emirates' => 'uaem',
'Republic of Uganda' => 'ugan',
'Ukraine' => 'ukrn',
'United Kingdom of Great Britain' => 'unkg',
'United Nations' => 'unna',
'United States of America' => 'unst',
'Oriental Republic of Uruguay' => 'urgy',
'Virgin Islands of the United States' => 'usvs',
'Republic of Uzbekistan' => 'uzbk',
'State of the Vatican City' => 'vacy',
'Republic of Vanuatu' => 'vant',
'Bolivarian Republic of Venezuela' => 'venz',
'Republic of Yemen' => 'yemn',
'Democratic Republic of Congo' => 'zare',
'Republic of Zimbabwe' => 'zbwe' ) ;
private $iFlagCount = -1;
private $iFlagSetMap = array(
FLAGSIZE1 => 'flags_thumb35x35',
FLAGSIZE2 => 'flags_thumb60x60',
FLAGSIZE3 => 'flags_thumb100x100',
FLAGSIZE4 => 'flags'
);
private $iFlagData ;
private $iOrdIdx=array();
function __construct($aSize=FLAGSIZE1) {
switch($aSize) {
case FLAGSIZE1 :
case FLAGSIZE2 :
case FLAGSIZE3 :
case FLAGSIZE4 :
$file = dirname(__FILE__).'/'.$this->iFlagSetMap[$aSize].'.dat';
$fp = fopen($file,'rb');
$rawdata = fread($fp,filesize($file));
$this->iFlagData = unserialize($rawdata);
break;
default:
JpGraphError::RaiseL(5001,$aSize);
//('Unknown flag size. ('.$aSize.')');
}
$this->iFlagCount = count($this->iCountryNameMap);
}
function GetNum() {
return $this->iFlagCount;
}
function GetImgByName($aName,&$outFullName) {
$idx = $this->GetIdxByName($aName,$outFullName);
return $this->GetImgByIdx($idx);
}
function GetImgByIdx($aIdx) {
if( array_key_exists($aIdx,$this->iFlagData) ) {
$d = $this->iFlagData[$aIdx][1];
return Image::CreateFromString($d);
}
else {
JpGraphError::RaiseL(5002,$aIdx);
//("Flag index \"<22>$aIdx\" does not exist.");
}
}
function GetIdxByOrdinal($aOrd,&$outFullName) {
$aOrd--;
$n = count($this->iOrdIdx);
if( $n == 0 ) {
reset($this->iCountryNameMap);
$this->iOrdIdx=array();
$i=0;
while( list($key,$val) = each($this->iCountryNameMap) ) {
$this->iOrdIdx[$i++] = array($val,$key);
}
$tmp=$this->iOrdIdx[$aOrd];
$outFullName = $tmp[1];
return $tmp[0];
}
elseif( $aOrd >= 0 && $aOrd < $n ) {
$tmp=$this->iOrdIdx[$aOrd];
$outFullName = $tmp[1];
return $tmp[0];
}
else {
JpGraphError::RaiseL(5003,$aOrd);
//('Invalid ordinal number specified for flag index.');
}
}
function GetIdxByName($aName,&$outFullName) {
if( is_integer($aName) ) {
$idx = $this->GetIdxByOrdinal($aName,$outFullName);
return $idx;
}
$found=false;
$aName = strtolower($aName);
$nlen = strlen($aName);
reset($this->iCountryNameMap);
// Start by trying to match exact index name
while( list($key,$val) = each($this->iCountryNameMap) ) {
if( $nlen == strlen($val) && $val == $aName ) {
$found=true;
break;
}
}
if( !$found ) {
reset($this->iCountryNameMap);
// If the exact index doesn't work try a (partial) full name
while( list($key,$val) = each($this->iCountryNameMap) ) {
if( strpos(strtolower($key), $aName) !== false ) {
$found=true;
break;
}
}
}
if( $found ) {
$outFullName = $key;
return $val;
}
else {
JpGraphError::RaiseL(5004,$aName);
//("The (partial) country name \"$aName\" does not have a cooresponding flag image. The flag may still exist but under another name, e.g. insted of \"usa\" try \"united states\".");
}
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,458 +0,0 @@
<?php
/**
* jpgraph_gradient.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_GRADIENT.PHP
// Description: Create a color gradient
// Created: 2003-02-01
// Ver: $Id: jpgraph_gradient.php 1761 2009-08-01 08:31:28Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
// Styles for gradient color fill
define("GRAD_VER",1);
define("GRAD_VERT",1);
define("GRAD_HOR",2);
define("GRAD_MIDHOR",3);
define("GRAD_MIDVER",4);
define("GRAD_CENTER",5);
define("GRAD_WIDE_MIDVER",6);
define("GRAD_WIDE_MIDHOR",7);
define("GRAD_LEFT_REFLECTION",8);
define("GRAD_RIGHT_REFLECTION",9);
define("GRAD_RAISED_PANEL",10);
define("GRAD_DIAGONAL",11);
//===================================================
// CLASS Gradient
// Description: Handles gradient fills. This is to be
// considered a "friend" class of Class Image.
//===================================================
class Gradient {
private $img=null, $numcolors=100;
//---------------
// CONSTRUCTOR
function __construct(&$img) {
$this->img = $img;
}
function SetNumColors($aNum) {
$this->numcolors=$aNum;
}
//---------------
// PUBLIC METHODS
// Produce a gradient filled rectangle with a smooth transition between
// two colors.
// ($xl,$yt) Top left corner
// ($xr,$yb) Bottom right
// $from_color Starting color in gradient
// $to_color End color in the gradient
// $style Which way is the gradient oriented?
function FilledRectangle($xl,$yt,$xr,$yb,$from_color,$to_color,$style=1) {
$this->img->SetLineWeight(1);
switch( $style ) {
case GRAD_VER:
$steps = ceil(abs($xr-$xl)+1);
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
for( $i=0, $x=$xl; $i < $steps; ++$i ) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yt,$x,$yb);
$x += $delta;
}
break;
case GRAD_HOR:
$steps = ceil(abs($yb-$yt)+1);
$delta = $yb >= $yt ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
for($i=0,$y=$yt; $i < $steps; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
break;
case GRAD_MIDHOR:
$steps = ceil(abs($yb-$yt)/2);
$delta = $yb >= $yt ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
for($y=$yt, $i=0; $i < $steps; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
--$i;
if( abs($yb-$yt) % 2 == 1 ) {
--$steps;
}
for($j=0; $j < $steps; ++$j, --$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
$this->img->Line($xl,$y,$xr,$y);
break;
case GRAD_MIDVER:
$steps = ceil(abs($xr-$xl)/2);
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
for($x=$xl, $i=0; $i < $steps; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
--$i;
if( abs($xr-$xl) % 2 == 1 ) {
--$steps;
}
for($j=0; $j < $steps; ++$j, --$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$this->img->Line($x,$yb,$x,$yt);
break;
case GRAD_WIDE_MIDVER:
$diff = ceil(abs($xr-$xl));
$steps = floor(abs($diff)/3);
$firststep = $diff - 2*$steps ;
$delta = $xr >= $xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$firststep,$colors,$this->numcolors);
for($x=$xl, $i=0; $i < $firststep; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
--$i;
$this->img->current_color = $colors[$i];
for($j=0; $j< $steps; ++$j) {
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
for($j=0; $j < $steps; ++$j, --$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
break;
case GRAD_WIDE_MIDHOR:
$diff = ceil(abs($yb-$yt));
$steps = floor(abs($diff)/3);
$firststep = $diff - 2*$steps ;
$delta = $yb >= $yt? 1 : -1;
$this->GetColArray($from_color,$to_color,$firststep,$colors,$this->numcolors);
for($y=$yt, $i=0; $i < $firststep; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
--$i;
$this->img->current_color = $colors[$i];
for($j=0; $j < $steps; ++$j) {
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
for($j=0; $j < $steps; ++$j, --$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
break;
case GRAD_LEFT_REFLECTION:
$steps1 = ceil(0.3*abs($xr-$xl));
$delta = $xr>=$xl ? 1 : -1;
$from_color = $this->img->rgb->Color($from_color);
$adj = 1.4;
$m = ($adj-1.0)*(255-min(255,min($from_color[0],min($from_color[1],$from_color[2]))));
$from_color2 = array(min(255,$from_color[0]+$m),
min(255,$from_color[1]+$m), min(255,$from_color[2]+$m));
$this->GetColArray($from_color2,$to_color,$steps1,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$steps2 = max(1,ceil(0.08*abs($xr-$xl)));
$this->img->SetColor($to_color);
for($j=0; $j< $steps2; ++$j) {
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$steps = abs($xr-$xl)-$steps1-$steps2;
$this->GetColArray($to_color,$from_color,$steps,$colors,$this->numcolors);
$n = count($colors);
for($i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
break;
case GRAD_RIGHT_REFLECTION:
$steps1 = ceil(0.7*abs($xr-$xl));
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps1,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$steps2 = max(1,ceil(0.08*abs($xr-$xl)));
$this->img->SetColor($to_color);
for($j=0; $j< $steps2; ++$j) {
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$from_color = $this->img->rgb->Color($from_color);
$adj = 1.4;
$m = ($adj-1.0)*(255-min(255,min($from_color[0],min($from_color[1],$from_color[2]))));
$from_color = array(min(255,$from_color[0]+$m),
min(255,$from_color[1]+$m), min(255,$from_color[2]+$m));
$steps = abs($xr-$xl)-$steps1-$steps2;
$this->GetColArray($to_color,$from_color,$steps,$colors,$this->numcolors);
$n = count($colors);
for($i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
break;
case GRAD_CENTER:
$steps = ceil(min(($yb-$yt)+1,($xr-$xl)+1)/2);
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
$dx = ($xr-$xl)/2;
$dy = ($yb-$yt)/2;
$x=$xl;$y=$yt;$x2=$xr;$y2=$yb;
$n = count($colors);
for($x=$xl, $i=0; $x < $xl+$dx && $y < $yt+$dy && $i < $n; ++$x, ++$y, --$x2, --$y2, ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Rectangle($x,$y,$x2,$y2);
}
$this->img->Line($x,$y,$x2,$y2);
break;
case GRAD_RAISED_PANEL:
// right to left
$steps1 = $xr-$xl;
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($to_color,$from_color,$steps1,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
// left to right
$xr -= 3;
$xl += 3;
$yb -= 3;
$yt += 3;
$steps2 = $xr-$xl;
$delta = $xr>=$xl ? 1 : -1;
for($x=$xl, $j=$steps2; $j >= 0; --$j) {
$this->img->current_color = $colors[$j];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
break;
case GRAD_DIAGONAL:
// use the longer dimension to determine the required number of steps.
// first loop draws from one corner to the mid-diagonal and the second
// loop draws from the mid-diagonal to the opposing corner.
if($xr-$xl > $yb - $yt) {
// width is greater than height -> use x-dimension for steps
$steps = $xr-$xl;
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$y = $yt+($i/$steps)*($yb-$yt)*$delta;
$this->img->Line($x,$yt,$xl,$y);
$x += $delta;
}
for($x=$xl, $i = 0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$steps+$i];
$y = $yt+($i/$steps)*($yb-$yt)*$delta;
$this->img->Line($x,$yb,$xr,$y);
$x += $delta;
}
} else {
// height is greater than width -> use y-dimension for steps
$steps = $yb-$yt;
$delta = $yb>=$yt ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors);
$n = count($colors);
for($y=$yt, $i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$x = $xl+($i/$steps)*($xr-$xl)*$delta;
$this->img->Line($x,$yt,$xl,$y);
$y += $delta;
}
for($y=$yt, $i = 0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$steps+$i];
$x = $xl+($i/$steps)*($xr-$xl)*$delta;
$this->img->Line($x,$yb,$xr,$y);
$x += $delta;
}
}
break;
default:
JpGraphError::RaiseL(7001,$style);
//("Unknown gradient style (=$style).");
break;
}
}
// Fill a special case of a polygon with a flat bottom
// with a gradient. Can be used for filled line plots.
// Please note that this is NOT a generic gradient polygon fill
// routine. It assumes that the bottom is flat (like a drawing
// of a mountain)
function FilledFlatPolygon($pts,$from_color,$to_color) {
if( count($pts) == 0 ) return;
$maxy=$pts[1];
$miny=$pts[1];
$n = count($pts) ;
for( $i=0, $idx=0; $i < $n; $i += 2) {
$x = round($pts[$i]);
$y = round($pts[$i+1]);
$miny = min($miny,$y);
$maxy = max($maxy,$y);
}
$colors = array();
$this->GetColArray($from_color,$to_color,abs($maxy-$miny)+1,$colors,$this->numcolors);
for($i=$miny, $idx=0; $i <= $maxy; ++$i ) {
$colmap[$i] = $colors[$idx++];
}
$n = count($pts)/2 ;
$idx = 0 ;
while( $idx < $n-1 ) {
$p1 = array(round($pts[$idx*2]),round($pts[$idx*2+1]));
$p2 = array(round($pts[++$idx*2]),round($pts[$idx*2+1]));
// Find the largest rectangle we can fill
$y = max($p1[1],$p2[1]) ;
for($yy=$maxy; $yy > $y; --$yy) {
$this->img->current_color = $colmap[$yy];
$this->img->Line($p1[0],$yy,$p2[0]-1,$yy);
}
if( $p1[1] == $p2[1] ) {
continue;
}
// Fill the rest using lines (slow...)
$slope = ($p2[0]-$p1[0])/($p1[1]-$p2[1]);
$x1 = $p1[0];
$x2 = $p2[0]-1;
$start = $y;
if( $p1[1] > $p2[1] ) {
while( $y >= $p2[1] ) {
$x1=$slope*($start-$y)+$p1[0];
$this->img->current_color = $colmap[$y];
$this->img->Line($x1,$y,$x2,$y);
--$y;
}
}
else {
while( $y >= $p1[1] ) {
$x2=$p2[0]+$slope*($start-$y);
$this->img->current_color = $colmap[$y];
$this->img->Line($x1,$y,$x2,$y);
--$y;
}
}
}
}
//---------------
// PRIVATE METHODS
// Add to the image color map the necessary colors to do the transition
// between the two colors using $numcolors intermediate colors
function GetColArray($from_color,$to_color,$arr_size,&$colors,$numcols=100) {
if( $arr_size==0 ) {
return;
}
// If color is given as text get it's corresponding r,g,b values
$from_color = $this->img->rgb->Color($from_color);
$to_color = $this->img->rgb->Color($to_color);
$rdelta=($to_color[0]-$from_color[0])/$numcols;
$gdelta=($to_color[1]-$from_color[1])/$numcols;
$bdelta=($to_color[2]-$from_color[2])/$numcols;
$colorsperstep = $numcols/$arr_size;
$prevcolnum = -1;
$from_alpha = $from_color[3];
$to_alpha = $to_color[3];
$adelta = ( $to_alpha - $from_alpha ) / $numcols ;
for ($i=0; $i < $arr_size; ++$i) {
$colnum = floor($colorsperstep*$i);
if ( $colnum == $prevcolnum ) {
$colors[$i] = $colidx;
}
else {
$r = floor($from_color[0] + $colnum*$rdelta);
$g = floor($from_color[1] + $colnum*$gdelta);
$b = floor($from_color[2] + $colnum*$bdelta);
$alpha = $from_alpha + $colnum*$adelta;
$colidx = $this->img->rgb->Allocate(sprintf("#%02x%02x%02x",$r,$g,$b),$alpha);
$colors[$i] = $colidx;
}
$prevcolnum = $colnum;
}
}
} // Class
?>

View File

@ -1,214 +0,0 @@
<?php
/**
* jpgraph_iconplot.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_ICONPLOT.PHP
// Description: Extension module to add icons to plots
// Created: 2004-02-18
// Ver: $Id: jpgraph_iconplot.php 1404 2009-06-28 15:25:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
//===================================================
// CLASS IconPlot
// Description: Make it possible to add a (small) image
// to the graph
//===================================================
class IconPlot {
public $iX=0,$iY=0,$iScale=1.0,$iMix=100;
private $iHorAnchor='left',$iVertAnchor='top';
private $iFile='';
private $iAnchors = array('left','right','top','bottom','center');
private $iCountryFlag='',$iCountryStdSize=3;
private $iScalePosY=null,$iScalePosX=null;
private $iImgString='';
function __construct($aFile="",$aX=0,$aY=0,$aScale=1.0,$aMix=100) {
$this->iFile = $aFile;
$this->iX=$aX;
$this->iY=$aY;
$this->iScale= $aScale;
if( $aMix < 0 || $aMix > 100 ) {
JpGraphError::RaiseL(8001); //('Mix value for icon must be between 0 and 100.');
}
$this->iMix = $aMix ;
}
function SetCountryFlag($aFlag,$aX=0,$aY=0,$aScale=1.0,$aMix=100,$aStdSize=3) {
$this->iCountryFlag = $aFlag;
$this->iX=$aX;
$this->iY=$aY;
$this->iScale= $aScale;
if( $aMix < 0 || $aMix > 100 ) {
JpGraphError::RaiseL(8001);//'Mix value for icon must be between 0 and 100.');
}
$this->iMix = $aMix;
$this->iCountryStdSize = $aStdSize;
}
function SetPos($aX,$aY) {
$this->iX=$aX;
$this->iY=$aY;
}
function CreateFromString($aStr) {
$this->iImgString = $aStr;
}
function SetScalePos($aX,$aY) {
$this->iScalePosX = $aX;
$this->iScalePosY = $aY;
}
function SetScale($aScale) {
$this->iScale = $aScale;
}
function SetMix($aMix) {
if( $aMix < 0 || $aMix > 100 ) {
JpGraphError::RaiseL(8001);//('Mix value for icon must be between 0 and 100.');
}
$this->iMix = $aMix ;
}
function SetAnchor($aXAnchor='left',$aYAnchor='center') {
if( !in_array($aXAnchor,$this->iAnchors) ||
!in_array($aYAnchor,$this->iAnchors) ) {
JpGraphError::RaiseL(8002);//("Anchor position for icons must be one of 'top', 'bottom', 'left', 'right' or 'center'");
}
$this->iHorAnchor=$aXAnchor;
$this->iVertAnchor=$aYAnchor;
}
function PreStrokeAdjust($aGraph) {
// Nothing to do ...
}
function DoLegend($aGraph) {
// Nothing to do ...
}
function Max() {
return array(false,false);
}
// The next four function are framework function tht gets called
// from Gantt and is not menaiungfull in the context of Icons but
// they must be implemented to avoid errors.
function GetMaxDate() { return false; }
function GetMinDate() { return false; }
function GetLineNbr() { return 0; }
function GetAbsHeight() {return 0; }
function Min() {
return array(false,false);
}
function StrokeMargin(&$aImg) {
return true;
}
function Stroke($aImg,$axscale=null,$ayscale=null) {
$this->StrokeWithScale($aImg,$axscale,$ayscale);
}
function StrokeWithScale($aImg,$axscale,$ayscale) {
if( $this->iScalePosX === null || $this->iScalePosY === null ||
$axscale === null || $ayscale === null ) {
$this->_Stroke($aImg);
}
else {
$this->_Stroke($aImg,
round($axscale->Translate($this->iScalePosX)),
round($ayscale->Translate($this->iScalePosY)));
}
}
function GetWidthHeight() {
$dummy=0;
return $this->_Stroke($dummy,null,null,true);
}
function _Stroke($aImg,$x=null,$y=null,$aReturnWidthHeight=false) {
if( $this->iFile != '' && $this->iCountryFlag != '' ) {
JpGraphError::RaiseL(8003);//('It is not possible to specify both an image file and a country flag for the same icon.');
}
if( $this->iFile != '' ) {
$gdimg = Graph::LoadBkgImage('',$this->iFile);
}
elseif( $this->iImgString != '') {
$gdimg = Image::CreateFromString($this->iImgString);
}
else {
if( ! class_exists('FlagImages',false) ) {
JpGraphError::RaiseL(8004);//('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.');
}
$fobj = new FlagImages($this->iCountryStdSize);
$dummy='';
$gdimg = $fobj->GetImgByName($this->iCountryFlag,$dummy);
}
$iconw = imagesx($gdimg);
$iconh = imagesy($gdimg);
if( $aReturnWidthHeight ) {
return array(round($iconw*$this->iScale),round($iconh*$this->iScale));
}
if( $x !== null && $y !== null ) {
$this->iX = $x; $this->iY = $y;
}
if( $this->iX >= 0 && $this->iX <= 1.0 ) {
$w = imagesx($aImg->img);
$this->iX = round($w*$this->iX);
}
if( $this->iY >= 0 && $this->iY <= 1.0 ) {
$h = imagesy($aImg->img);
$this->iY = round($h*$this->iY);
}
if( $this->iHorAnchor == 'center' )
$this->iX -= round($iconw*$this->iScale/2);
if( $this->iHorAnchor == 'right' )
$this->iX -= round($iconw*$this->iScale);
if( $this->iVertAnchor == 'center' )
$this->iY -= round($iconh*$this->iScale/2);
if( $this->iVertAnchor == 'bottom' )
$this->iY -= round($iconh*$this->iScale);
$aImg->CopyMerge($gdimg,$this->iX,$this->iY,0,0,
round($iconw*$this->iScale),round($iconh*$this->iScale),
$iconw,$iconh,
$this->iMix);
}
}
?>

View File

@ -1,247 +0,0 @@
<?php
/**
* jpgraph_imgtrans.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_IMGTRANS.PHP
// Description: Extension for JpGraph to do some simple img transformations
// Created: 2003-09-06
// Ver: $Id: jpgraph_imgtrans.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
//------------------------------------------------------------------------
// Class ImgTrans
// Perform some simple image transformations.
//------------------------------------------------------------------------
class ImgTrans {
private $gdImg=null;
function __construct($aGdImg) {
// Constructor
$this->gdImg = $aGdImg;
}
// --------------------------------------------------------------------
// _TransVert3D() and _TransHor3D() are helper methods to
// Skew3D().
// --------------------------------------------------------------------
function _TransVert3D($aGdImg,$aHorizon=100,$aSkewDist=120,$aDir=SKEW3D_DOWN,$aMinSize=true,$aFillColor='#FFFFFF',$aQuality=false,$aBorder=false,$aHorizonPos=0.5) {
// Parameter check
if( $aHorizonPos < 0 || $aHorizonPos > 1.0 ) {
JpGraphError::RaiseL(9001);
//("Value for image transformation out of bounds.\nVanishing point on horizon must be specified as a value between 0 and 1.");
}
$w = imagesx($aGdImg);
$h = imagesy($aGdImg);
// Create new image
$ww = $w;
if( $aMinSize )
$hh = ceil($h * $aHorizon / ($aSkewDist+$h));
else
$hh = $h;
$newgdh = imagecreatetruecolor($ww,$hh);
$crgb = new RGB( $newgdh );
$fillColor = $crgb->Allocate($aFillColor);
imagefilledrectangle($newgdh,0,0,$ww-1,$hh-1,$fillColor);
if( $aBorder ) {
$colidx = $crgb->Allocate($aBorder);
imagerectangle($newgdh,0,0,$ww-1,$hh-1,$colidx);
}
$mid = round($w * $aHorizonPos);
$last=$h;
for($y=0; $y < $h; ++$y) {
$yp = $h-$y-1;
$yt = floor($yp * $aHorizon / ($aSkewDist + $yp));
if( !$aQuality ) {
if( $last <= $yt ) continue ;
$last = $yt;
}
for($x=0; $x < $w; ++$x) {
$xt = ($x-$mid) * $aSkewDist / ($aSkewDist + $yp);
if( $aDir == SKEW3D_UP )
$rgb = imagecolorat($aGdImg,$x,$h-$y-1);
else
$rgb = imagecolorat($aGdImg,$x,$y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$colidx = imagecolorallocate($newgdh,$r,$g,$b);
$xt = round($xt+$mid);
if( $aDir == SKEW3D_UP ) {
$syt = $yt;
}
else {
$syt = $hh-$yt-1;
}
if( !empty($set[$yt]) ) {
$nrgb = imagecolorat($newgdh,$xt,$syt);
$nr = ($nrgb >> 16) & 0xFF;
$ng = ($nrgb >> 8) & 0xFF;
$nb = $nrgb & 0xFF;
$colidx = imagecolorallocate($newgdh,floor(($r+$nr)/2),
floor(($g+$ng)/2),floor(($b+$nb)/2));
}
imagesetpixel($newgdh,$xt,$syt,$colidx);
}
$set[$yt] = true;
}
return $newgdh;
}
// --------------------------------------------------------------------
// _TransVert3D() and _TransHor3D() are helper methods to
// Skew3D().
// --------------------------------------------------------------------
function _TransHor3D($aGdImg,$aHorizon=100,$aSkewDist=120,$aDir=SKEW3D_LEFT,$aMinSize=true,$aFillColor='#FFFFFF',$aQuality=false,$aBorder=false,$aHorizonPos=0.5) {
$w = imagesx($aGdImg);
$h = imagesy($aGdImg);
// Create new image
$hh = $h;
if( $aMinSize )
$ww = ceil($w * $aHorizon / ($aSkewDist+$w));
else
$ww = $w;
$newgdh = imagecreatetruecolor($ww,$hh);
$crgb = new RGB( $newgdh );
$fillColor = $crgb->Allocate($aFillColor);
imagefilledrectangle($newgdh,0,0,$ww-1,$hh-1,$fillColor);
if( $aBorder ) {
$colidx = $crgb->Allocate($aBorder);
imagerectangle($newgdh,0,0,$ww-1,$hh-1,$colidx);
}
$mid = round($h * $aHorizonPos);
$last = -1;
for($x=0; $x < $w-1; ++$x) {
$xt = floor($x * $aHorizon / ($aSkewDist + $x));
if( !$aQuality ) {
if( $last >= $xt ) continue ;
$last = $xt;
}
for($y=0; $y < $h; ++$y) {
$yp = $h-$y-1;
$yt = ($yp-$mid) * $aSkewDist / ($aSkewDist + $x);
if( $aDir == SKEW3D_RIGHT )
$rgb = imagecolorat($aGdImg,$w-$x-1,$y);
else
$rgb = imagecolorat($aGdImg,$x,$y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$colidx = imagecolorallocate($newgdh,$r,$g,$b);
$yt = floor($hh-$yt-$mid-1);
if( $aDir == SKEW3D_RIGHT ) {
$sxt = $ww-$xt-1;
}
else
$sxt = $xt ;
if( !empty($set[$xt]) ) {
$nrgb = imagecolorat($newgdh,$sxt,$yt);
$nr = ($nrgb >> 16) & 0xFF;
$ng = ($nrgb >> 8) & 0xFF;
$nb = $nrgb & 0xFF;
$colidx = imagecolorallocate($newgdh,floor(($r+$nr)/2),
floor(($g+$ng)/2),floor(($b+$nb)/2));
}
imagesetpixel($newgdh,$sxt,$yt,$colidx);
}
$set[$xt] = true;
}
return $newgdh;
}
// --------------------------------------------------------------------
// Skew image for the apperance of a 3D effect
// This transforms an image into a 3D-skewed version
// of the image. The transformation is specified by giving the height
// of the artificial horizon and specifying a "skew" factor which
// is the distance on the horizon line between the point of
// convergence and perspective line.
//
// The function returns the GD handle of the transformed image
// leaving the original image untouched.
//
// Parameters:
// * $aGdImg, GD handle to the image to be transformed
// * $aHorizon, Distance to the horizon
// * $aSkewDist, Distance from the horizon point of convergence
// on the horizon line to the perspective points. A larger
// value will fore-shorten the image more
// * $aDir, parameter specifies type of convergence. This of this
// as the walls in a room you are looking at. This specifies if the
// image should be applied on the left,right,top or bottom walls.
// * $aMinSize, true=make the new image just as big as needed,
// false = keep the image the same size as the original image
// * $aFillColor, Background fill color in the image
// * $aHiQuality, true=performa some interpolation that improves
// the image quality but at the expense of performace. Enabling
// high quality will have a dramatic effect on the time it takes
// to transform an image.
// * $aBorder, if set to anything besides false this will draw a
// a border of the speciied color around the image
// --------------------------------------------------------------------
function Skew3D($aHorizon=120,$aSkewDist=150,$aDir=SKEW3D_DOWN,$aHiQuality=false,$aMinSize=true,$aFillColor='#FFFFFF',$aBorder=false) {
return $this->_Skew3D($this->gdImg,$aHorizon,$aSkewDist,$aDir,$aHiQuality,
$aMinSize,$aFillColor,$aBorder);
}
function _Skew3D($aGdImg,$aHorizon=120,$aSkewDist=150,$aDir=SKEW3D_DOWN,$aHiQuality=false,$aMinSize=true,$aFillColor='#FFFFFF',$aBorder=false) {
if( $aDir == SKEW3D_DOWN || $aDir == SKEW3D_UP )
return $this->_TransVert3D($aGdImg,$aHorizon,$aSkewDist,$aDir,$aMinSize,$aFillColor,$aHiQuality,$aBorder);
else
return $this->_TransHor3D($aGdImg,$aHorizon,$aSkewDist,$aDir,$aMinSize,$aFillColor,$aHiQuality,$aBorder);
}
}
?>

View File

@ -1,335 +0,0 @@
<?php
/**
* jpgraph_led.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_LED.PHP
// Description: Module to generate Dotted LED-like digits
// Created: 2006-11-26
// Ver: $Id: jpgraph_led.php 1674 2009-07-22 19:42:23Z ljp $
//
// Copyright 2006 (c) Aditus Consulting. All rights reserved.
//
// Changed: 2007-08-06 by Alexander Kurochkin (inspector@list.ru)
//========================================================================
// Constants for color schema
DEFINE('LEDC_RED', 0);
DEFINE('LEDC_GREEN', 1);
DEFINE('LEDC_BLUE', 2);
DEFINE('LEDC_YELLOW', 3);
DEFINE('LEDC_GRAY', 4);
DEFINE('LEDC_CHOCOLATE', 5);
DEFINE('LEDC_PERU', 6);
DEFINE('LEDC_GOLDENROD', 7);
DEFINE('LEDC_KHAKI', 8);
DEFINE('LEDC_OLIVE', 9);
DEFINE('LEDC_LIMEGREEN', 10);
DEFINE('LEDC_FORESTGREEN', 11);
DEFINE('LEDC_TEAL', 12);
DEFINE('LEDC_STEELBLUE', 13);
DEFINE('LEDC_NAVY', 14);
DEFINE('LEDC_INVERTGRAY', 15);
// Check that mb_strlen() is available
if( ! function_exists('mb_strlen') ) {
JpGraphError::RaiseL(25500);
//'Multibyte strings must be enabled in the PHP installation in order to run the LED module
// so that the function mb_strlen() is available. See PHP documentation for more information.'
}
//========================================================================
// CLASS DigitalLED74
// Description:
// Construct a number as an image that looks like LED numbers in a
// 7x4 digital matrix
//========================================================================
class DigitalLED74
{
private $iLED_X = 4, $iLED_Y=7,
// fg-up, fg-down, bg
$iColorSchema = array(
LEDC_RED => array('red','darkred:0.9','red:0.3'),// 0
LEDC_GREEN => array('green','darkgreen','green:0.3'),// 1
LEDC_BLUE => array('lightblue:0.9','darkblue:0.85','darkblue:0.7'),// 2
LEDC_YELLOW => array('yellow','yellow:0.4','yellow:0.3'),// 3
LEDC_GRAY => array('gray:1.4','darkgray:0.85','darkgray:0.7'),
LEDC_CHOCOLATE => array('chocolate','chocolate:0.7','chocolate:0.5'),
LEDC_PERU => array('peru:0.95','peru:0.6','peru:0.5'),
LEDC_GOLDENROD => array('goldenrod','goldenrod:0.6','goldenrod:0.5'),
LEDC_KHAKI => array('khaki:0.7','khaki:0.4','khaki:0.3'),
LEDC_OLIVE => array('#808000','#808000:0.7','#808000:0.6'),
LEDC_LIMEGREEN => array('limegreen:0.9','limegreen:0.5','limegreen:0.4'),
LEDC_FORESTGREEN => array('forestgreen','forestgreen:0.7','forestgreen:0.5'),
LEDC_TEAL => array('teal','teal:0.7','teal:0.5'),
LEDC_STEELBLUE => array('steelblue','steelblue:0.65','steelblue:0.5'),
LEDC_NAVY => array('navy:1.3','navy:0.95','navy:0.8'),//14
LEDC_INVERTGRAY => array('darkgray','lightgray:1.5','white')//15
),
/* Each line of the character is encoded as a 4 bit value
0 ____
1 ___x
2 __x_
3 __xx
4 _x__
5 _x_x
6 _xx_
7 _xxx
8 x___
9 x__x
10 x_x_
11 x_xx
12 xx__
13 xx_x
14 xxx_
15 xxxx
*/
$iLEDSpec = array(
0 => array(6,9,11,15,13,9,6),
1 => array(2,6,10,2,2,2,2),
2 => array(6,9,1,2,4,8,15),
3 => array(6,9,1,6,1,9,6),
4 => array(1,3,5,9,15,1,1),
5 => array(15,8,8,14,1,9,6),
6 => array(6,8,8,14,9,9,6),
7 => array(15,1,1,2,4,4,4),
8 => array(6,9,9,6,9,9,6),
9 => array(6,9,9,7,1,1,6),
'!' => array(4,4,4,4,4,0,4),
'?' => array(6,9,1,2,2,0,2),
'#' => array(0,9,15,9,15,9,0),
'@' => array(6,9,11,11,10,9,6),
'-' => array(0,0,0,15,0,0,0),
'_' => array(0,0,0,0,0,0,15),
'=' => array(0,0,15,0,15,0,0),
'+' => array(0,0,4,14,4,0,0),
'|' => array(4,4,4,4,4,4,4), //vertical line, used for simulate rus 'Ы'
',' => array(0,0,0,0,0,12,4),
'.' => array(0,0,0,0,0,12,12),
':' => array(12,12,0,0,0,12,12),
';' => array(12,12,0,0,0,12,4),
'[' => array(3,2,2,2,2,2,3),
']' => array(12,4,4,4,4,4,12),
'(' => array(1,2,2,2,2,2,1),
')' => array(8,4,4,4,4,4,8),
'{' => array(3,2,2,6,2,2,3),
'}' => array(12,4,4,6,4,4,12),
'<' => array(1,2,4,8,4,2,1),
'>' => array(8,4,2,1,2,4,8),
'*' => array(9,6,15,6,9,0,0),
'"' => array(10,10,0,0,0,0,0),
'\'' => array(4,4,0,0,0,0,0),
'`' => array(4,2,0,0,0,0,0),
'~' => array(13,11,0,0,0,0,0),
'^' => array(4,10,0,0,0,0,0),
'\\' => array(8,8,4,6,2,1,1),
'/' => array(1,1,2,6,4,8,8),
'%' => array(1,9,2,6,4,9,8),
'&' => array(0,4,10,4,11,10,5),
'$' => array(2,7,8,6,1,14,4),
' ' => array(0,0,0,0,0,0,0),
'•' => array(0,0,6,6,0,0,0), //149
'°' => array(14,10,14,0,0,0,0), //176
'†' => array(4,4,14,4,4,4,4), //134
'‡' => array(4,4,14,4,14,4,4), //135
'±' => array(0,4,14,4,0,14,0), //177
'‰' => array(0,4,2,15,2,4,0), //137 show right arrow
'™' => array(0,2,4,15,4,2,0), //156 show left arrow
'Ў' => array(0,0,8,8,0,0,0), //159 show small hi-stick - that need for simulate rus 'Ф'
"\t" => array(8,8,8,0,0,0,0), //show hi-stick - that need for simulate rus 'У'
"\r" => array(8,8,8,8,8,8,8), //vertical line - that need for simulate 'M', 'W' and rus 'М','Ш' ,'Щ'
"\n" => array(15,15,15,15,15,15,15), //fill up - that need for simulate rus 'Ж'
"Ґ" => array(10,5,10,5,10,5,10), //chess
"µ" => array(15,0,15,0,15,0,15), //4 horizontal lines
// latin
'A' => array(6,9,9,15,9,9,9),
'B' => array(14,9,9,14,9,9,14),
'C' => array(6,9,8,8,8,9,6),
'D' => array(14,9,9,9,9,9,14),
'E' => array(15,8,8,14,8,8,15),
'F' => array(15,8,8,14,8,8,8),
'G' => array(6,9,8,8,11,9,6),
'H' => array(9,9,9,15,9,9,9),
'I' => array(14,4,4,4,4,4,14),
'J' => array(15,1,1,1,1,9,6),
'K' => array(8,9,10,12,12,10,9),
'L' => array(8,8,8,8,8,8,15),
'M' => array(8,13,10,8,8,8,8),// need to add \r
'N' => array(9,9,13,11,9,9,9),
'O' => array(6,9,9,9,9,9,6),
'P' => array(14,9,9,14,8,8,8),
'Q' => array(6,9,9,9,13,11,6),
'R' => array(14,9,9,14,12,10,9),
'S' => array(6,9,8,6,1,9,6),
'T' => array(14,4,4,4,4,4,4),
'U' => array(9,9,9,9,9,9,6),
'V' => array(0,0,0,10,10,10,4),
'W' => array(8,8,8,8,10,13,8),// need to add \r
'X' => array(9,9,6,6,6,9,9),
'Y' => array(10,10,10,10,4,4,4),
'Z' => array(15,1,2,6,4,8,15),
// russian utf-8
'А' => array(6,9,9,15,9,9,9),
'Б' => array(14,8,8,14,9,9,14),
'В' => array(14,9,9,14,9,9,14),
'Г' => array(15,8,8,8,8,8,8),
'Д' => array(14,9,9,9,9,9,14),
'Е' => array(15,8,8,14,8,8,15),
'Ё' => array(6,15,8,14,8,8,15),
//Ж is combine: >\n<
'З' => array(6,9,1,2,1,9,6),
'И' => array(9,9,9,11,13,9,9),
'Й' => array(13,9,9,11,13,9,9),
'К' => array(9,10,12,10,9,9,9),
'Л' => array(7,9,9,9,9,9,9),
'М' => array(8,13,10,8,8,8,8),// need to add \r
'Н' => array(9,9,9,15,9,9,9),
'О' => array(6,9,9,9,9,9,6),
'П' => array(15,9,9,9,9,9,9),
'Р' => array(14,9,9,14,8,8,8),
'С' => array(6,9,8,8,8,9,6),
'Т' => array(14,4,4,4,4,4,4),
'У' => array(9,9,9,7,1,9,6),
'Ф' => array(2,7,10,10,7,2,2),// need to add Ў
'Х' => array(9,9,6,6,6,9,9),
'Ц' => array(10,10,10,10,10,15,1),
'Ч' => array(9,9,9,7,1,1,1),
'Ш' => array(10,10,10,10,10,10,15),// \r
'Щ' => array(10,10,10,10,10,15,0),// need to add \r
'Ъ' => array(12,4,4,6,5,5,6),
'Ы' => array(8,8,8,14,9,9,14),// need to add |
'Ь' => array(8,8,8,14,9,9,14),
'Э' => array(6,9,1,7,1,9,6),
'Ю' => array(2,2,2,3,2,2,2),// need to add O
'Я' => array(7,9,9,7,3,5,9)
),
$iSuperSampling = 3, $iMarg = 1, $iRad = 4;
function __construct($aRadius = 2, $aMargin= 0.6) {
$this->iRad = $aRadius;
$this->iMarg = $aMargin;
}
function SetSupersampling($aSuperSampling = 2) {
$this->iSuperSampling = $aSuperSampling;
}
function _GetLED($aLedIdx, $aColor = 0) {
$width= $this->iLED_X*$this->iRad*2 + ($this->iLED_X+1)*$this->iMarg + $this->iRad ;
$height= $this->iLED_Y*$this->iRad*2 + ($this->iLED_Y)*$this->iMarg + $this->iRad * 2;
// Adjust radious for supersampling
$rad = $this->iRad * $this->iSuperSampling;
// Margin in between "Led" dots
$marg = $this->iMarg * $this->iSuperSampling;
$swidth = $width*$this->iSuperSampling;
$sheight = $height*$this->iSuperSampling;
$simg = new RotImage($swidth, $sheight, 0, DEFAULT_GFORMAT, false);
$simg->SetColor($this->iColorSchema[$aColor][2]);
$simg->FilledRectangle(0, 0, $swidth-1, $sheight-1);
if( array_key_exists($aLedIdx, $this->iLEDSpec) ) {
$d = $this->iLEDSpec[$aLedIdx];
}
else {
$d = array(0,0,0,0,0,0,0);
}
for($r = 0; $r < 7; ++$r) {
$dr = $d[$r];
for($c = 0; $c < 4; ++$c) {
if( ($dr & pow(2,3-$c)) !== 0 ) {
$color = $this->iColorSchema[$aColor][0];
}
else {
$color = $this->iColorSchema[$aColor][1];
}
$x = 2*$rad*$c+$rad + ($c+1)*$marg + $rad ;
$y = 2*$rad*$r+$rad + ($r+1)*$marg + $rad ;
$simg->SetColor($color);
$simg->FilledCircle($x,$y,$rad);
}
}
$img = new Image($width, $height, DEFAULT_GFORMAT, false);
$img->Copy($simg->img, 0, 0, 0, 0, $width, $height, $swidth, $sheight);
$simg->Destroy();
unset($simg);
return $img;
}
function Stroke($aValStr, $aColor = 0, $aFileName = '') {
$this->StrokeNumber($aValStr, $aColor, $aFileName);
}
function StrokeNumber($aValStr, $aColor = 0, $aFileName = '') {
if( $aColor < 0 || $aColor >= sizeof($this->iColorSchema) ) {
$aColor = 0;
}
if(($n = mb_strlen($aValStr,'utf8')) == 0) {
$aValStr = ' ';
$n = 1;
}
for($i = 0; $i < $n; ++$i) {
$d = mb_substr($aValStr, $i, 1, 'utf8');
if( ctype_digit($d) ) {
$d = (int)$d;
}
else {
$d = strtoupper($d);
}
$digit_img[$i] = $this->_GetLED($d, $aColor);
}
$w = imagesx($digit_img[0]->img);
$h = imagesy($digit_img[0]->img);
$number_img = new Image($w*$n, $h, DEFAULT_GFORMAT, false);
for($i = 0; $i < $n; ++$i) {
$number_img->Copy($digit_img[$i]->img, $i*$w, 0, 0, 0, $w, $h, $w, $h);
}
if( $aFileName != '' ) {
$number_img->Stream($aFileName);
} else {
$number_img->Headers();
$number_img->Stream();
}
}
}
?>

View File

@ -1,508 +0,0 @@
<?php
/**
* jpgraph_legend.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_LEGEND.INC.PHP
// Description: Class to handle the legend box in the graph that gives
// names on the data series. The number of rows and columns
// in the legend are user specifyable.
// Created: 2001-01-08 (Refactored to separate file 2008-08-01)
// Ver: $Id: jpgraph_legend.inc.php 1926 2010-01-11 16:33:07Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
DEFINE('_DEFAULT_LPM_SIZE',8); // Default Legend Plot Mark size
//===================================================
// CLASS Legend
// Description: Responsible for drawing the box containing
// all the legend text for the graph
//===================================================
class Legend {
public $txtcol=array();
public $font_family=FF_FONT1,$font_style=FS_NORMAL,$font_size=12;
private $color=array(0,0,0); // Default fram color
private $fill_color=array(235,235,235); // Default fill color
private $shadow=true; // Shadow around legend "box"
private $shadow_color='darkgray';
private $mark_abs_hsize=_DEFAULT_LPM_SIZE,$mark_abs_vsize=_DEFAULT_LPM_SIZE;
private $xmargin=10,$ymargin=0,$shadow_width=2;
private $xlmargin=4;
private $ylinespacing=5;
// We need a separate margin since the baseline of the last text would coincide with the bottom otherwise
private $ybottom_margin = 8;
private $xpos=0.05, $ypos=0.15, $xabspos=-1, $yabspos=-1;
private $halign="right", $valign="top";
private $font_color='black';
private $hide=false,$layout_n=1;
private $weight=1,$frameweight=1;
private $csimareas='';
private $reverse = false ;
private $bkg_gradtype=-1, $bkg_gradfrom='lightgray', $bkg_gradto='gray';
//---------------
// CONSTRUCTOR
function __construct() {
// Empty
}
//---------------
// PUBLIC METHODS
function Hide($aHide=true) {
$this->hide=$aHide;
}
function SetHColMargin($aXMarg) {
$this->xmargin = $aXMarg;
}
function SetVColMargin($aSpacing) {
$this->ylinespacing = $aSpacing ;
}
function SetLeftMargin($aXMarg) {
$this->xlmargin = $aXMarg;
}
// Synonym
function SetLineSpacing($aSpacing) {
$this->ylinespacing = $aSpacing ;
}
function SetShadow($aShow='gray',$aWidth=4) {
if( is_string($aShow) ) {
$this->shadow_color = $aShow;
$this->shadow=true;
}
else {
$this->shadow = $aShow;
}
$this->shadow_width = $aWidth;
}
function SetMarkAbsSize($aSize) {
$this->mark_abs_vsize = $aSize ;
$this->mark_abs_hsize = $aSize ;
}
function SetMarkAbsVSize($aSize) {
$this->mark_abs_vsize = $aSize ;
}
function SetMarkAbsHSize($aSize) {
$this->mark_abs_hsize = $aSize ;
}
function SetLineWeight($aWeight) {
$this->weight = $aWeight;
}
function SetFrameWeight($aWeight) {
$this->frameweight = $aWeight;
}
function SetLayout($aDirection=LEGEND_VERT) {
$this->layout_n = $aDirection==LEGEND_VERT ? 1 : 99 ;
}
function SetColumns($aCols) {
$this->layout_n = $aCols ;
}
function SetReverse($f=true) {
$this->reverse = $f ;
}
// Set color on frame around box
function SetColor($aFontColor,$aColor='black') {
$this->font_color=$aFontColor;
$this->color=$aColor;
}
function SetFont($aFamily,$aStyle=FS_NORMAL,$aSize=10) {
$this->font_family = $aFamily;
$this->font_style = $aStyle;
$this->font_size = $aSize;
}
function SetPos($aX,$aY,$aHAlign='right',$aVAlign='top') {
$this->Pos($aX,$aY,$aHAlign,$aVAlign);
}
function SetAbsPos($aX,$aY,$aHAlign='right',$aVAlign='top') {
$this->xabspos=$aX;
$this->yabspos=$aY;
$this->halign=$aHAlign;
$this->valign=$aVAlign;
}
function Pos($aX,$aY,$aHAlign='right',$aVAlign='top') {
if( !($aX<1 && $aY<1) ) {
JpGraphError::RaiseL(25120);//(" Position for legend must be given as percentage in range 0-1");
}
$this->xpos=$aX;
$this->ypos=$aY;
$this->halign=$aHAlign;
$this->valign=$aVAlign;
}
function SetFillColor($aColor) {
$this->fill_color=$aColor;
}
function Clear() {
$this->txtcol = array();
}
function Add($aTxt,$aColor,$aPlotmark='',$aLinestyle=0,$csimtarget='',$csimalt='',$csimwintarget='') {
$this->txtcol[]=array($aTxt,$aColor,$aPlotmark,$aLinestyle,$csimtarget,$csimalt,$csimwintarget);
}
function GetCSIMAreas() {
return $this->csimareas;
}
function SetBackgroundGradient($aFrom='navy',$aTo='silver',$aGradType=2) {
$this->bkg_gradtype=$aGradType;
$this->bkg_gradfrom = $aFrom;
$this->bkg_gradto = $aTo;
}
function Stroke($aImg) {
// Constant
$fillBoxFrameWeight=1;
if( $this->hide ) return;
$aImg->SetFont($this->font_family,$this->font_style,$this->font_size);
if( $this->reverse ) {
$this->txtcol = array_reverse($this->txtcol);
}
$n=count($this->txtcol);
if( $n == 0 ) return;
// Find out the max width and height of each column to be able
// to size the legend box.
$numcolumns = ($n > $this->layout_n ? $this->layout_n : $n);
for( $i=0; $i < $numcolumns; ++$i ) {
$colwidth[$i] = $aImg->GetTextWidth($this->txtcol[$i][0]) +
2*$this->xmargin + 2*$this->mark_abs_hsize;
$colheight[$i] = 0;
}
// Find our maximum height in each row
$rows = 0 ; $rowheight[0] = 0;
for( $i=0; $i < $n; ++$i ) {
$h = max($this->mark_abs_vsize,$aImg->GetTextHeight($this->txtcol[$i][0]))+$this->ylinespacing;
// Makes sure we always have a minimum of 1/4 (1/2 on each side) of the mark as space
// between two vertical legend entries
//$h = round(max($h,$this->mark_abs_vsize+$this->ymargin));
//echo "Textheight #$i: tetxheight=".$aImg->GetTextHeight($this->txtcol[$i][0]).', ';
//echo "h=$h ({$this->mark_abs_vsize},{$this->ymargin})<br>";
if( $i % $numcolumns == 0 ) {
$rows++;
$rowheight[$rows-1] = 0;
}
$rowheight[$rows-1] = max($rowheight[$rows-1],$h);
}
$abs_height = 0;
for( $i=0; $i < $rows; ++$i ) {
$abs_height += $rowheight[$i] ;
}
// Make sure that the height is at least as high as mark size + ymargin
$abs_height = max($abs_height,$this->mark_abs_vsize);
$abs_height += $this->ybottom_margin;
// Find out the maximum width in each column
for( $i=$numcolumns; $i < $n; ++$i ) {
$colwidth[$i % $numcolumns] = max(
$aImg->GetTextWidth($this->txtcol[$i][0])+2*$this->xmargin+2*$this->mark_abs_hsize,
$colwidth[$i % $numcolumns]);
}
// Get the total width
$mtw = 0;
for( $i=0; $i < $numcolumns; ++$i ) {
$mtw += $colwidth[$i] ;
}
// remove the last rows interpace margin (since there is no next row)
$abs_height -= $this->ylinespacing;
// Find out maximum width we need for legend box
$abs_width = $mtw+$this->xlmargin+($numcolumns-1)*$this->mark_abs_hsize;
if( $this->xabspos === -1 && $this->yabspos === -1 ) {
$this->xabspos = $this->xpos*$aImg->width ;
$this->yabspos = $this->ypos*$aImg->height ;
}
// Positioning of the legend box
if( $this->halign == 'left' ) {
$xp = $this->xabspos;
}
elseif( $this->halign == 'center' ) {
$xp = $this->xabspos - $abs_width/2;
}
else {
$xp = $aImg->width - $this->xabspos - $abs_width;
}
$yp=$this->yabspos;
if( $this->valign == 'center' ) {
$yp-=$abs_height/2;
}
elseif( $this->valign == 'bottom' ) {
$yp-=$abs_height;
}
// Stroke legend box
$aImg->SetColor($this->color);
$aImg->SetLineWeight($this->frameweight);
$aImg->SetLineStyle('solid');
if( $this->shadow ) {
$aImg->ShadowRectangle($xp,$yp,
$xp+$abs_width+$this->shadow_width+2,
$yp+$abs_height+$this->shadow_width+2,
$this->fill_color,$this->shadow_width+2,$this->shadow_color);
}
else {
$aImg->SetColor($this->fill_color);
$aImg->FilledRectangle($xp,$yp,$xp+$abs_width,$yp+$abs_height);
$aImg->SetColor($this->color);
$aImg->Rectangle($xp,$yp,$xp+$abs_width,$yp+$abs_height);
}
if( $this->bkg_gradtype >= 0 ) {
$grad = new Gradient($aImg);
$grad->FilledRectangle($xp+1, $yp+1,
$xp+$abs_width-3, $yp+$abs_height-3,
$this->bkg_gradfrom, $this->bkg_gradto,
$this->bkg_gradtype);
}
// x1,y1 is the position for the legend marker + text
// The vertical position is the baseline position for the text
// and every marker is adjusted acording to that.
// For multiline texts this get more complicated.
$x1 = $xp + $this->xlmargin;
$y1 = $yp + $rowheight[0] - $this->ylinespacing + 2 ; // The ymargin is included in rowheight
// Now, y1 is the bottom vertical position of the first legend, i.e if
// the legend has multiple lines it is the bottom line.
$grad = new Gradient($aImg);
$patternFactory = null;
// Now stroke each legend in turn
// Each plot has added the following information to the legend
// p[0] = Legend text
// p[1] = Color,
// p[2] = For markers a reference to the PlotMark object
// p[3] = For lines the line style, for gradient the negative gradient style
// p[4] = CSIM target
// p[5] = CSIM Alt text
$i = 1 ; $row = 0;
foreach($this->txtcol as $p) {
// STROKE DEBUG BOX
if( _JPG_DEBUG ) {
$aImg->SetLineWeight(1);
$aImg->SetColor('red');
$aImg->SetLineStyle('solid');
$aImg->Rectangle($x1,$y1,$xp+$abs_width-1,$y1-$rowheight[$row]);
}
$aImg->SetLineWeight($this->weight);
$x1 = round($x1)+1; // We add one to not collide with the border
$y1=round($y1);
// This is the center offset up from the baseline which is
// considered the "center" of the marks. This gets slightly complicated since
// we need to consider if the text is a multiline paragraph or if it is only
// a single line. The reason is that for single line the y1 corresponds to the baseline
// and that is fine. However for a multiline paragraph there is no single baseline
// and in that case the y1 corresponds to the lowest y for the bounding box. In that
// case we center the mark in the middle of the paragraph
if( !preg_match('/\n/',$p[0]) ) {
// Single line
$marky = ceil($y1-$this->mark_abs_vsize/2)-1;
} else {
// Paragraph
$marky = $y1 - $aImg->GetTextHeight($p[0])/2;
// echo "y1=$y1, p[o]={$p[0]}, marky=$marky<br>";
}
//echo "<br>Mark #$i: marky=$marky<br>";
$x1 += $this->mark_abs_hsize;
if ( !empty($p[2]) && $p[2]->GetType() > -1 ) {
// Make a plot mark legend. This is constructed with a mark which
// is run through with a line
// First construct a bit of the line that looks exactly like the
// line in the plot
$aImg->SetColor($p[1]);
if( is_string($p[3]) || $p[3]>0 ) {
$aImg->SetLineStyle($p[3]);
$aImg->StyleLine($x1-$this->mark_abs_hsize,$marky,$x1+$this->mark_abs_hsize,$marky);
}
// Stroke a mark with the standard size
// (As long as it is not an image mark )
if( $p[2]->GetType() != MARK_IMG ) {
// Clear any user callbacks since we ont want them called for
// the legend marks
$p[2]->iFormatCallback = '';
$p[2]->iFormatCallback2 = '';
// Since size for circles is specified as the radius
// this means that we must half the size to make the total
// width behave as the other marks
if( $p[2]->GetType() == MARK_FILLEDCIRCLE || $p[2]->GetType() == MARK_CIRCLE ) {
$p[2]->SetSize(min($this->mark_abs_vsize,$this->mark_abs_hsize)/2);
$p[2]->Stroke($aImg,$x1,$marky);
}
else {
$p[2]->SetSize(min($this->mark_abs_vsize,$this->mark_abs_hsize));
$p[2]->Stroke($aImg,$x1,$marky);
}
}
}
elseif ( !empty($p[2]) && (is_string($p[3]) || $p[3]>0 ) ) {
// Draw a styled line
$aImg->SetColor($p[1]);
$aImg->SetLineStyle($p[3]);
$aImg->StyleLine($x1-$this->mark_abs_hsize,$marky,$x1+$this->mark_abs_hsize,$marky);
$aImg->StyleLine($x1-$this->mark_abs_hsize,$marky+1,$x1+$this->mark_abs_hsize,$marky+1);
}
else {
// Draw a colored box
$color = $p[1] ;
// We make boxes slightly larger to better show
$boxsize = max($this->mark_abs_vsize,$this->mark_abs_hsize) + 2 ;
$ym = $marky-ceil($boxsize/2) ; // Marker y-coordinate
// We either need to plot a gradient or a
// pattern. To differentiate we use a kludge.
// Patterns have a p[3] value of < -100
if( $p[3] < -100 ) {
// p[1][0] == iPattern, p[1][1] == iPatternColor, p[1][2] == iPatternDensity
if( $patternFactory == null ) {
$patternFactory = new RectPatternFactory();
}
$prect = $patternFactory->Create($p[1][0],$p[1][1],1);
$prect->SetBackground($p[1][3]);
$prect->SetDensity($p[1][2]+1);
$prect->SetPos(new Rectangle($x1,$ym,$boxsize,$boxsize));
$prect->Stroke($aImg);
$prect=null;
}
else {
if( is_array($color) && count($color)==2 ) {
// The client want a gradient color
$grad->FilledRectangle($x1-$boxsize/2,$ym,
$x1+$boxsize/2,$ym+$boxsize,
$color[0],$color[1],-$p[3]);
}
else {
$aImg->SetColor($p[1]);
$aImg->FilledRectangle($x1-$boxsize/2,$ym,
$x1+$boxsize/2,$ym+$boxsize);
}
$aImg->SetColor($this->color);
$aImg->SetLineWeight($fillBoxFrameWeight);
$aImg->Rectangle($x1-$boxsize/2,$ym,
$x1+$boxsize/2,$ym+$boxsize);
}
}
$aImg->SetColor($this->font_color);
$aImg->SetFont($this->font_family,$this->font_style,$this->font_size);
$aImg->SetTextAlign('left','baseline');
$debug=false;
$aImg->StrokeText($x1+$this->mark_abs_hsize+$this->xmargin,$y1,$p[0],
0,'left',$debug);
// Add CSIM for Legend if defined
if( !empty($p[4]) ) {
$xs = $x1 - $this->mark_abs_hsize ;
$ys = $y1 + 1 ;
$xe = $x1 + $aImg->GetTextWidth($p[0]) + $this->mark_abs_hsize + $this->xmargin ;
$ye = $y1-$rowheight[$row]+1;
$coords = "$xs,$ys,$xe,$y1,$xe,$ye,$xs,$ye";
if( ! empty($p[4]) ) {
$this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($p[4])."\"";
if( !empty($p[6]) ) {
$this->csimareas .= " target=\"".$p[6]."\"";
}
if( !empty($p[5]) ) {
$tmp=sprintf($p[5],$p[0]);
$this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" ";
}
$this->csimareas .= " />\n";
}
}
if( $i >= $this->layout_n ) {
$x1 = $xp+$this->xlmargin;
$row++;
if( !empty($rowheight[$row]) )
$y1 += $rowheight[$row];
$i = 1;
}
else {
$x1 += $colwidth[($i-1) % $numcolumns] ;
++$i;
}
}
}
} // Class
?>

View File

@ -1,706 +0,0 @@
<?php
/**
* jpgraph_line.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_LINE.PHP
// Description: Line plot extension for JpGraph
// Created: 2001-01-08
// Ver: $Id: jpgraph_line.php 1921 2009-12-11 11:46:39Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once ('jpgraph_plotmark.inc.php');
// constants for the (filled) area
DEFINE("LP_AREA_FILLED", true);
DEFINE("LP_AREA_NOT_FILLED", false);
DEFINE("LP_AREA_BORDER",false);
DEFINE("LP_AREA_NO_BORDER",true);
//===================================================
// CLASS LinePlot
// Description:
//===================================================
class LinePlot extends Plot{
public $mark=null;
protected $filled=false;
protected $fill_color='blue';
protected $step_style=false, $center=false;
protected $line_style=1; // Default to solid
protected $filledAreas = array(); // array of arrays(with min,max,col,filled in them)
public $barcenter=false; // When we mix line and bar. Should we center the line in the bar.
protected $fillFromMin = false, $fillFromMax = false;
protected $fillgrad=false,$fillgrad_fromcolor='navy',$fillgrad_tocolor='silver',$fillgrad_numcolors=100;
protected $iFastStroke=false;
//---------------
// CONSTRUCTOR
function __construct($datay,$datax=false) {
parent::__construct($datay,$datax);
$this->mark = new PlotMark() ;
$this->color = ColorFactory::getColor();
$this->fill_color = $this->color;
}
//---------------
// PUBLIC METHODS
function SetFilled($aFlg=true) {
$this->filled = $aFlg;
}
function SetBarCenter($aFlag=true) {
$this->barcenter=$aFlag;
}
function SetStyle($aStyle) {
$this->line_style=$aStyle;
}
function SetStepStyle($aFlag=true) {
$this->step_style = $aFlag;
}
function SetColor($aColor) {
parent::SetColor($aColor);
}
function SetFillFromYMin($f=true) {
$this->fillFromMin = $f ;
}
function SetFillFromYMax($f=true) {
$this->fillFromMax = $f ;
}
function SetFillColor($aColor,$aFilled=true) {
//$this->color = $aColor;
$this->fill_color=$aColor;
$this->filled=$aFilled;
}
function SetFillGradient($aFromColor,$aToColor,$aNumColors=100,$aFilled=true) {
$this->fillgrad_fromcolor = $aFromColor;
$this->fillgrad_tocolor = $aToColor;
$this->fillgrad_numcolors = $aNumColors;
$this->filled = $aFilled;
$this->fillgrad = true;
}
function Legend($graph) {
if( $this->legend!="" ) {
if( $this->filled && !$this->fillgrad ) {
$graph->legend->Add($this->legend,
$this->fill_color,$this->mark,0,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
}
elseif( $this->fillgrad ) {
$color=array($this->fillgrad_fromcolor,$this->fillgrad_tocolor);
// In order to differentiate between gradients and cooors specified as an RGB triple
$graph->legend->Add($this->legend,$color,"",-2 /* -GRAD_HOR */,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
} else {
$graph->legend->Add($this->legend,
$this->color,$this->mark,$this->line_style,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
}
}
}
function AddArea($aMin=0,$aMax=0,$aFilled=LP_AREA_NOT_FILLED,$aColor="gray9",$aBorder=LP_AREA_BORDER) {
if($aMin > $aMax) {
// swap
$tmp = $aMin;
$aMin = $aMax;
$aMax = $tmp;
}
$this->filledAreas[] = array($aMin,$aMax,$aColor,$aFilled,$aBorder);
}
// Gets called before any axis are stroked
function PreStrokeAdjust($graph) {
// If another plot type have already adjusted the
// offset we don't touch it.
// (We check for empty in case the scale is a log scale
// and hence doesn't contain any xlabel_offset)
if( empty($graph->xaxis->scale->ticks->xlabel_offset) || $graph->xaxis->scale->ticks->xlabel_offset == 0 ) {
if( $this->center ) {
++$this->numpoints;
$a=0.5; $b=0.5;
} else {
$a=0; $b=0;
}
$graph->xaxis->scale->ticks->SetXLabelOffset($a);
$graph->SetTextScaleOff($b);
//$graph->xaxis->scale->ticks->SupressMinorTickMarks();
}
}
function SetFastStroke($aFlg=true) {
$this->iFastStroke = $aFlg;
}
function FastStroke($img,$xscale,$yscale,$aStartPoint=0,$exist_x=true) {
// An optimized stroke for many data points with no extra
// features but 60% faster. You can't have values or line styles, or null
// values in plots.
$numpoints=count($this->coords[0]);
if( $this->barcenter ) {
$textadj = 0.5-$xscale->text_scale_off;
}
else {
$textadj = 0;
}
$img->SetColor($this->color);
$img->SetLineWeight($this->weight);
$pnts=$aStartPoint;
while( $pnts < $numpoints ) {
if( $exist_x ) {
$x=$this->coords[1][$pnts];
}
else {
$x=$pnts+$textadj;
}
$xt = $xscale->Translate($x);
$y=$this->coords[0][$pnts];
$yt = $yscale->Translate($y);
if( is_numeric($y) ) {
$cord[] = $xt;
$cord[] = $yt;
}
elseif( $y == '-' && $pnts > 0 ) {
// Just ignore
}
else {
JpGraphError::RaiseL(10002);//('Plot too complicated for fast line Stroke. Use standard Stroke()');
}
++$pnts;
} // WHILE
$img->Polygon($cord,false,true);
}
function Stroke($img,$xscale,$yscale) {
$idx=0;
$numpoints=count($this->coords[0]);
if( isset($this->coords[1]) ) {
if( count($this->coords[1])!=$numpoints ) {
JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints);
//("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
}
else {
$exist_x = true;
}
}
else {
$exist_x = false;
}
if( $this->barcenter ) {
$textadj = 0.5-$xscale->text_scale_off;
}
else {
$textadj = 0;
}
// Find the first numeric data point
$startpoint=0;
while( $startpoint < $numpoints && !is_numeric($this->coords[0][$startpoint]) ) {
++$startpoint;
}
// Bail out if no data points
if( $startpoint == $numpoints ) return;
if( $this->iFastStroke ) {
$this->FastStroke($img,$xscale,$yscale,$startpoint,$exist_x);
return;
}
if( $exist_x ) {
$xs=$this->coords[1][$startpoint];
}
else {
$xs= $textadj+$startpoint;
}
$img->SetStartPoint($xscale->Translate($xs),
$yscale->Translate($this->coords[0][$startpoint]));
if( $this->filled ) {
if( $this->fillFromMax ) {
//$max = $yscale->GetMaxVal();
$cord[$idx++] = $xscale->Translate($xs);
$cord[$idx++] = $yscale->scale_abs[1];
}
else {
$min = $yscale->GetMinVal();
if( $min > 0 || $this->fillFromMin ) {
$fillmin = $yscale->scale_abs[0];//Translate($min);
}
else {
$fillmin = $yscale->Translate(0);
}
$cord[$idx++] = $xscale->Translate($xs);
$cord[$idx++] = $fillmin;
}
}
$xt = $xscale->Translate($xs);
$yt = $yscale->Translate($this->coords[0][$startpoint]);
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
$yt_old = $yt;
$xt_old = $xt;
$y_old = $this->coords[0][$startpoint];
$this->value->Stroke($img,$this->coords[0][$startpoint],$xt,$yt);
$img->SetColor($this->color);
$img->SetLineWeight($this->weight);
$img->SetLineStyle($this->line_style);
$pnts=$startpoint+1;
$firstnonumeric = false;
while( $pnts < $numpoints ) {
if( $exist_x ) {
$x=$this->coords[1][$pnts];
}
else {
$x=$pnts+$textadj;
}
$xt = $xscale->Translate($x);
$yt = $yscale->Translate($this->coords[0][$pnts]);
$y=$this->coords[0][$pnts];
if( $this->step_style ) {
// To handle null values within step style we need to record the
// first non numeric value so we know from where to start if the
// non value is '-'.
if( is_numeric($y) ) {
$firstnonumeric = false;
if( is_numeric($y_old) ) {
$img->StyleLine($xt_old,$yt_old,$xt,$yt_old);
$img->StyleLine($xt,$yt_old,$xt,$yt);
}
elseif( $y_old == '-' ) {
$img->StyleLine($xt_first,$yt_first,$xt,$yt_first);
$img->StyleLine($xt,$yt_first,$xt,$yt);
}
else {
$yt_old = $yt;
$xt_old = $xt;
}
$cord[$idx++] = $xt;
$cord[$idx++] = $yt_old;
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
elseif( $firstnonumeric==false ) {
$firstnonumeric = true;
$yt_first = $yt_old;
$xt_first = $xt_old;
}
}
else {
$tmp1=$y;
$prev=$this->coords[0][$pnts-1];
if( $tmp1==='' || $tmp1===NULL || $tmp1==='X' ) $tmp1 = 'x';
if( $prev==='' || $prev===null || $prev==='X' ) $prev = 'x';
if( is_numeric($y) || (is_string($y) && $y != '-') ) {
if( is_numeric($y) && (is_numeric($prev) || $prev === '-' ) ) {
$img->StyleLineTo($xt,$yt);
}
else {
$img->SetStartPoint($xt,$yt);
}
}
if( $this->filled && $tmp1 !== '-' ) {
if( $tmp1 === 'x' ) {
$cord[$idx++] = $cord[$idx-3];
$cord[$idx++] = $fillmin;
}
elseif( $prev === 'x' ) {
$cord[$idx++] = $xt;
$cord[$idx++] = $fillmin;
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
else {
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
}
else {
if( is_numeric($tmp1) && (is_numeric($prev) || $prev === '-' ) ) {
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
}
}
$yt_old = $yt;
$xt_old = $xt;
$y_old = $y;
$this->StrokeDataValue($img,$this->coords[0][$pnts],$xt,$yt);
++$pnts;
}
if( $this->filled ) {
$cord[$idx++] = $xt;
if( $this->fillFromMax ) {
$cord[$idx++] = $yscale->scale_abs[1];
}
else {
if( $min > 0 || $this->fillFromMin ) {
$cord[$idx++] = $yscale->Translate($min);
}
else {
$cord[$idx++] = $yscale->Translate(0);
}
}
if( $this->fillgrad ) {
$img->SetLineWeight(1);
$grad = new Gradient($img);
$grad->SetNumColors($this->fillgrad_numcolors);
$grad->FilledFlatPolygon($cord,$this->fillgrad_fromcolor,$this->fillgrad_tocolor);
$img->SetLineWeight($this->weight);
}
else {
$img->SetColor($this->fill_color);
$img->FilledPolygon($cord);
}
if( $this->weight > 0 ) {
$img->SetLineWeight($this->weight);
$img->SetColor($this->color);
// Remove first and last coordinate before drawing the line
// sine we otherwise get the vertical start and end lines which
// doesn't look appropriate
$img->Polygon(array_slice($cord,2,count($cord)-4));
}
}
if(!empty($this->filledAreas)) {
$minY = $yscale->Translate($yscale->GetMinVal());
$factor = ($this->step_style ? 4 : 2);
for($i = 0; $i < sizeof($this->filledAreas); ++$i) {
// go through all filled area elements ordered by insertion
// fill polygon array
$areaCoords[] = $cord[$this->filledAreas[$i][0] * $factor];
$areaCoords[] = $minY;
$areaCoords =
array_merge($areaCoords,
array_slice($cord,
$this->filledAreas[$i][0] * $factor,
($this->filledAreas[$i][1] - $this->filledAreas[$i][0] + ($this->step_style ? 0 : 1)) * $factor));
$areaCoords[] = $areaCoords[sizeof($areaCoords)-2]; // last x
$areaCoords[] = $minY; // last y
if($this->filledAreas[$i][3]) {
$img->SetColor($this->filledAreas[$i][2]);
$img->FilledPolygon($areaCoords);
$img->SetColor($this->color);
}
// Check if we should draw the frame.
// If not we still re-draw the line since it might have been
// partially overwritten by the filled area and it doesn't look
// very good.
if( $this->filledAreas[$i][4] ) {
$img->Polygon($areaCoords);
}
else {
$img->Polygon($cord);
}
$areaCoords = array();
}
}
if( $this->mark->type == -1 || $this->mark->show == false )
return;
for( $pnts=0; $pnts<$numpoints; ++$pnts) {
if( $exist_x ) {
$x=$this->coords[1][$pnts];
}
else {
$x=$pnts+$textadj;
}
$xt = $xscale->Translate($x);
$yt = $yscale->Translate($this->coords[0][$pnts]);
if( is_numeric($this->coords[0][$pnts]) ) {
if( !empty($this->csimtargets[$pnts]) ) {
if( !empty($this->csimwintargets[$pnts]) ) {
$this->mark->SetCSIMTarget($this->csimtargets[$pnts],$this->csimwintargets[$pnts]);
}
else {
$this->mark->SetCSIMTarget($this->csimtargets[$pnts]);
}
$this->mark->SetCSIMAlt($this->csimalts[$pnts]);
}
if( $exist_x ) {
$x=$this->coords[1][$pnts];
}
else {
$x=$pnts;
}
$this->mark->SetCSIMAltVal($this->coords[0][$pnts],$x);
$this->mark->Stroke($img,$xt,$yt);
$this->csimareas .= $this->mark->GetCSIMAreas();
}
}
}
} // Class
//===================================================
// CLASS AccLinePlot
// Description:
//===================================================
class AccLinePlot extends Plot {
protected $plots=null,$nbrplots=0;
private $iStartEndZero=true;
//---------------
// CONSTRUCTOR
function __construct($plots) {
$this->plots = $plots;
$this->nbrplots = count($plots);
$this->numpoints = $plots[0]->numpoints;
// Verify that all plots have the same number of data points
for( $i=1; $i < $this->nbrplots; ++$i ) {
if( $plots[$i]->numpoints != $this->numpoints ) {
JpGraphError::RaiseL(10003);//('Each plot in an accumulated lineplot must have the same number of data points',0)
}
}
for($i=0; $i < $this->nbrplots; ++$i ) {
$this->LineInterpolate($this->plots[$i]->coords[0]);
}
}
//---------------
// PUBLIC METHODS
function Legend($graph) {
foreach( $this->plots as $p ) {
$p->DoLegend($graph);
}
}
function Max() {
list($xmax) = $this->plots[0]->Max();
$nmax=0;
$n = count($this->plots);
for($i=0; $i < $n; ++$i) {
$nc = count($this->plots[$i]->coords[0]);
$nmax = max($nmax,$nc);
list($x) = $this->plots[$i]->Max();
$xmax = Max($xmax,$x);
}
for( $i = 0; $i < $nmax; $i++ ) {
// Get y-value for line $i by adding the
// individual bars from all the plots added.
// It would be wrong to just add the
// individual plots max y-value since that
// would in most cases give to large y-value.
$y=$this->plots[0]->coords[0][$i];
for( $j = 1; $j < $this->nbrplots; $j++ ) {
$y += $this->plots[ $j ]->coords[0][$i];
}
$ymax[$i] = $y;
}
$ymax = max($ymax);
return array($xmax,$ymax);
}
function Min() {
$nmax=0;
list($xmin,$ysetmin) = $this->plots[0]->Min();
$n = count($this->plots);
for($i=0; $i < $n; ++$i) {
$nc = count($this->plots[$i]->coords[0]);
$nmax = max($nmax,$nc);
list($x,$y) = $this->plots[$i]->Min();
$xmin = Min($xmin,$x);
$ysetmin = Min($y,$ysetmin);
}
for( $i = 0; $i < $nmax; $i++ ) {
// Get y-value for line $i by adding the
// individual bars from all the plots added.
// It would be wrong to just add the
// individual plots min y-value since that
// would in most cases give to small y-value.
$y=$this->plots[0]->coords[0][$i];
for( $j = 1; $j < $this->nbrplots; $j++ ) {
$y += $this->plots[ $j ]->coords[0][$i];
}
$ymin[$i] = $y;
}
$ymin = Min($ysetmin,Min($ymin));
return array($xmin,$ymin);
}
// Gets called before any axis are stroked
function PreStrokeAdjust($graph) {
// If another plot type have already adjusted the
// offset we don't touch it.
// (We check for empty in case the scale is a log scale
// and hence doesn't contain any xlabel_offset)
if( empty($graph->xaxis->scale->ticks->xlabel_offset) ||
$graph->xaxis->scale->ticks->xlabel_offset == 0 ) {
if( $this->center ) {
++$this->numpoints;
$a=0.5; $b=0.5;
} else {
$a=0; $b=0;
}
$graph->xaxis->scale->ticks->SetXLabelOffset($a);
$graph->SetTextScaleOff($b);
$graph->xaxis->scale->ticks->SupressMinorTickMarks();
}
}
function SetInterpolateMode($aIntMode) {
$this->iStartEndZero=$aIntMode;
}
// Replace all '-' with an interpolated value. We use straightforward
// linear interpolation. If the data starts with one or several '-' they
// will be replaced by the the first valid data point
function LineInterpolate(&$aData) {
$n=count($aData);
$i=0;
// If first point is undefined we will set it to the same as the first
// valid data
if( $aData[$i]==='-' ) {
// Find the first valid data
while( $i < $n && $aData[$i]==='-' ) {
++$i;
}
if( $i < $n ) {
for($j=0; $j < $i; ++$j ) {
if( $this->iStartEndZero )
$aData[$i] = 0;
else
$aData[$j] = $aData[$i];
}
}
else {
// All '-' => Error
return false;
}
}
while($i < $n) {
while( $i < $n && $aData[$i] !== '-' ) {
++$i;
}
if( $i < $n ) {
$pstart=$i-1;
// Now see how long this segment of '-' are
while( $i < $n && $aData[$i] === '-' ) {
++$i;
}
if( $i < $n ) {
$pend=$i;
$size=$pend-$pstart;
$k=($aData[$pend]-$aData[$pstart])/$size;
// Replace the segment of '-' with a linear interpolated value.
for($j=1; $j < $size; ++$j ) {
$aData[$pstart+$j] = $aData[$pstart] + $j*$k ;
}
}
else {
// There are no valid end point. The '-' goes all the way to the end
// In that case we just set all the remaining values the the same as the
// last valid data point.
for( $j=$pstart+1; $j < $n; ++$j )
if( $this->iStartEndZero ) {
$aData[$j] = 0;
}
else {
$aData[$j] = $aData[$pstart] ;
}
}
}
}
return true;
}
// To avoid duplicate of line drawing code here we just
// change the y-values for each plot and then restore it
// after we have made the stroke. We must do this copy since
// it wouldn't be possible to create an acc line plot
// with the same graphs, i.e AccLinePlot(array($pl,$pl,$pl));
// since this method would have a side effect.
function Stroke($img,$xscale,$yscale) {
$img->SetLineWeight($this->weight);
$this->numpoints = count($this->plots[0]->coords[0]);
// Allocate array
$coords[$this->nbrplots][$this->numpoints]=0;
for($i=0; $i<$this->numpoints; $i++) {
$coords[0][$i]=$this->plots[0]->coords[0][$i];
$accy=$coords[0][$i];
for($j=1; $j<$this->nbrplots; ++$j ) {
$coords[$j][$i] = $this->plots[$j]->coords[0][$i]+$accy;
$accy = $coords[$j][$i];
}
}
for($j=$this->nbrplots-1; $j>=0; --$j) {
$p=$this->plots[$j];
for( $i=0; $i<$this->numpoints; ++$i) {
$tmp[$i]=$p->coords[0][$i];
$p->coords[0][$i]=$coords[$j][$i];
}
$p->Stroke($img,$xscale,$yscale);
for( $i=0; $i<$this->numpoints; ++$i) {
$p->coords[0][$i]=$tmp[$i];
}
$p->coords[0][]=$tmp;
}
}
} // Class
/* EOF */
?>

View File

@ -1,329 +0,0 @@
<?php
/**
* jpgraph_log.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_LOG.PHP
// Description: Log scale plot extension for JpGraph
// Created: 2001-01-08
// Ver: $Id: jpgraph_log.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
DEFINE('LOGLABELS_PLAIN',0);
DEFINE('LOGLABELS_MAGNITUDE',1);
//===================================================
// CLASS LogScale
// Description: Logarithmic scale between world and screen
//===================================================
class LogScale extends LinearScale {
//---------------
// CONSTRUCTOR
// Log scale is specified using the log of min and max
function __construct($min,$max,$type="y") {
parent::__construct($min,$max,$type);
$this->ticks = new LogTicks();
$this->name = 'log';
}
//----------------
// PUBLIC METHODS
// Translate between world and screen
function Translate($a) {
if( !is_numeric($a) ) {
if( $a != '' && $a != '-' && $a != 'x' ) {
JpGraphError::RaiseL(11001);
// ('Your data contains non-numeric values.');
}
return 1;
}
if( $a < 0 ) {
JpGraphError::RaiseL(11002);
//("Negative data values can not be used in a log scale.");
exit(1);
}
if( $a==0 ) $a=1;
$a=log10($a);
return ceil($this->off + ($a*1.0 - $this->scale[0]) * $this->scale_factor);
}
// Relative translate (don't include offset) usefull when we just want
// to know the relative position (in pixels) on the axis
function RelTranslate($a) {
if( !is_numeric($a) ) {
if( $a != '' && $a != '-' && $a != 'x' ) {
JpGraphError::RaiseL(11001);
//('Your data contains non-numeric values.');
}
return 1;
}
if( $a==0 ) {
$a=1;
}
$a=log10($a);
return round(($a*1.0 - $this->scale[0]) * $this->scale_factor);
}
// Use bcpow() for increased precision
function GetMinVal() {
if( function_exists("bcpow") ) {
return round(bcpow(10,$this->scale[0],15),14);
}
else {
return round(pow(10,$this->scale[0]),14);
}
}
function GetMaxVal() {
if( function_exists("bcpow") ) {
return round(bcpow(10,$this->scale[1],15),14);
}
else {
return round(pow(10,$this->scale[1]),14);
}
}
// Logarithmic autoscaling is much simplier since we just
// set the min and max to logs of the min and max values.
// Note that for log autoscale the "maxstep" the fourth argument
// isn't used. This is just included to give the method the same
// signature as the linear counterpart.
function AutoScale($img,$min,$max,$maxsteps,$majend=true) {
if( $min==0 ) $min=1;
if( $max <= 0 ) {
JpGraphError::RaiseL(11004);
//('Scale error for logarithmic scale. You have a problem with your data values. The max value must be greater than 0. It is mathematically impossible to have 0 in a logarithmic scale.');
}
if( is_numeric($this->autoscale_min) ) {
$smin = round($this->autoscale_min);
$smax = ceil(log10($max));
if( $min >= $max ) {
JpGraphError::RaiseL(25071);//('You have specified a min value with SetAutoMin() which is larger than the maximum value used for the scale. This is not possible.');
}
}
else {
$smin = floor(log10($min));
if( is_numeric($this->autoscale_max) ) {
$smax = round($this->autoscale_max);
if( $smin >= $smax ) {
JpGraphError::RaiseL(25072);//('You have specified a max value with SetAutoMax() which is smaller than the miminum value used for the scale. This is not possible.');
}
}
else
$smax = ceil(log10($max));
}
$this->Update($img,$smin,$smax);
}
//---------------
// PRIVATE METHODS
} // Class
//===================================================
// CLASS LogTicks
// Description:
//===================================================
class LogTicks extends Ticks{
private $label_logtype=LOGLABELS_MAGNITUDE;
private $ticklabels_pos = array();
//---------------
// CONSTRUCTOR
function __construct() {
}
//---------------
// PUBLIC METHODS
function IsSpecified() {
return true;
}
function SetLabelLogType($aType) {
$this->label_logtype = $aType;
}
// For log scale it's meaningless to speak about a major step
// We just return -1 to make the framework happy (specifically
// StrokeLabels() )
function GetMajor() {
return -1;
}
function SetTextLabelStart($aStart) {
JpGraphError::RaiseL(11005);
//('Specifying tick interval for a logarithmic scale is undefined. Remove any calls to SetTextLabelStart() or SetTextTickInterval() on the logarithmic scale.');
}
function SetXLabelOffset($dummy) {
// For log scales we dont care about XLabel offset
}
// Draw ticks on image "img" using scale "scale". The axis absolute
// position in the image is specified in pos, i.e. for an x-axis
// it specifies the absolute y-coord and for Y-ticks it specified the
// absolute x-position.
function Stroke($img,$scale,$pos) {
$start = $scale->GetMinVal();
$limit = $scale->GetMaxVal();
$nextMajor = 10*$start;
$step = $nextMajor / 10.0;
$img->SetLineWeight($this->weight);
if( $scale->type == "y" ) {
// member direction specified if the ticks should be on
// left or right side.
$a=$pos + $this->direction*$this->GetMinTickAbsSize();
$a2=$pos + $this->direction*$this->GetMajTickAbsSize();
$count=1;
$this->maj_ticks_pos[0]=$scale->Translate($start);
$this->maj_ticklabels_pos[0]=$scale->Translate($start);
if( $this->supress_first )
$this->maj_ticks_label[0]="";
else {
if( $this->label_formfunc != '' ) {
$f = $this->label_formfunc;
$this->maj_ticks_label[0]=call_user_func($f,$start);
}
elseif( $this->label_logtype == LOGLABELS_PLAIN ) {
$this->maj_ticks_label[0]=$start;
}
else {
$this->maj_ticks_label[0]='10^'.round(log10($start));
}
}
$i=1;
for($y=$start; $y<=$limit; $y+=$step,++$count ) {
$ys=$scale->Translate($y);
$this->ticks_pos[]=$ys;
$this->ticklabels_pos[]=$ys;
if( $count % 10 == 0 ) {
if( !$this->supress_tickmarks ) {
if( $this->majcolor!="" ) {
$img->PushColor($this->majcolor);
$img->Line($pos,$ys,$a2,$ys);
$img->PopColor();
}
else {
$img->Line($pos,$ys,$a2,$ys);
}
}
$this->maj_ticks_pos[$i]=$ys;
$this->maj_ticklabels_pos[$i]=$ys;
if( $this->label_formfunc != '' ) {
$f = $this->label_formfunc;
$this->maj_ticks_label[$i]=call_user_func($f,$nextMajor);
}
elseif( $this->label_logtype == 0 ) {
$this->maj_ticks_label[$i]=$nextMajor;
}
else {
$this->maj_ticks_label[$i]='10^'.round(log10($nextMajor));
}
++$i;
$nextMajor *= 10;
$step *= 10;
$count=1;
}
else {
if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) {
if( $this->mincolor!="" ) {
$img->PushColor($this->mincolor);
}
$img->Line($pos,$ys,$a,$ys);
if( $this->mincolor!="" ) {
$img->PopColor();
}
}
}
}
}
else {
$a=$pos - $this->direction*$this->GetMinTickAbsSize();
$a2=$pos - $this->direction*$this->GetMajTickAbsSize();
$count=1;
$this->maj_ticks_pos[0]=$scale->Translate($start);
$this->maj_ticklabels_pos[0]=$scale->Translate($start);
if( $this->supress_first ) {
$this->maj_ticks_label[0]="";
}
else {
if( $this->label_formfunc != '' ) {
$f = $this->label_formfunc;
$this->maj_ticks_label[0]=call_user_func($f,$start);
}
elseif( $this->label_logtype == 0 ) {
$this->maj_ticks_label[0]=$start;
}
else {
$this->maj_ticks_label[0]='10^'.round(log10($start));
}
}
$i=1;
for($x=$start; $x<=$limit; $x+=$step,++$count ) {
$xs=$scale->Translate($x);
$this->ticks_pos[]=$xs;
$this->ticklabels_pos[]=$xs;
if( $count % 10 == 0 ) {
if( !$this->supress_tickmarks ) {
$img->Line($xs,$pos,$xs,$a2);
}
$this->maj_ticks_pos[$i]=$xs;
$this->maj_ticklabels_pos[$i]=$xs;
if( $this->label_formfunc != '' ) {
$f = $this->label_formfunc;
$this->maj_ticks_label[$i]=call_user_func($f,$nextMajor);
}
elseif( $this->label_logtype == 0 ) {
$this->maj_ticks_label[$i]=$nextMajor;
}
else {
$this->maj_ticks_label[$i]='10^'.round(log10($nextMajor));
}
++$i;
$nextMajor *= 10;
$step *= 10;
$count=1;
}
else {
if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) {
$img->Line($xs,$pos,$xs,$a);
}
}
}
}
return true;
}
} // Class
/* EOF */
?>

View File

@ -1,129 +0,0 @@
<?php
/**
* jpgraph_meshinterpolate.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_MESHINTERPOLATE.INC.PHP
// Description: Utility class to do mesh linear interpolation of a matrix
// Created: 2009-03-09
// Ver: $Id: jpgraph_meshinterpolate.inc.php 1709 2009-07-30 08:00:08Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
/**
* Utility function to do linear mesh interpolation
* @param $aDat Matrix to interpolate
* @param $aFactor Interpolation factor
*/
function doMeshInterpolate( &$aData, $aFactor ) {
$m = new MeshInterpolate();
$aData = $m->Linear($aData,$aFactor);
}
/**
* Utility class to interpolate a given data matrix
*
*/
class MeshInterpolate {
private $data = array();
/**
* Calculate the mid points of the given rectangle which has its top left
* corner at $row,$col. The $aFactordecides how many spliots should be done.
* i.e. how many more divisions should be done recursively
*
* @param $row Top left corner of square to work with
* @param $col Top left corner of square to work with
* $param $aFactor In how many subsquare should we split this square. A value of 1 indicates that no action
*/
function IntSquare( $aRow, $aCol, $aFactor ) {
if ( $aFactor <= 1 )
return;
$step = pow( 2, $aFactor-1 );
$v0 = $this->data[$aRow][$aCol];
$v1 = $this->data[$aRow][$aCol + $step];
$v2 = $this->data[$aRow + $step][$aCol];
$v3 = $this->data[$aRow + $step][$aCol + $step];
$this->data[$aRow][$aCol + $step / 2] = ( $v0 + $v1 ) / 2;
$this->data[$aRow + $step / 2][$aCol] = ( $v0 + $v2 ) / 2;
$this->data[$aRow + $step][$aCol + $step / 2] = ( $v2 + $v3 ) / 2;
$this->data[$aRow + $step / 2][$aCol + $step] = ( $v1 + $v3 ) / 2;
$this->data[$aRow + $step / 2][$aCol + $step / 2] = ( $v0 + $v1 + $v2 + $v3 ) / 4;
$this->IntSquare( $aRow, $aCol, $aFactor-1 );
$this->IntSquare( $aRow, $aCol + $step / 2, $aFactor-1 );
$this->IntSquare( $aRow + $step / 2, $aCol, $aFactor-1 );
$this->IntSquare( $aRow + $step / 2, $aCol + $step / 2, $aFactor-1 );
}
/**
* Interpolate values in a matrice so that the total number of data points
* in vert and horizontal axis are $aIntNbr more. For example $aIntNbr=2 will
* make the data matrice have tiwce as many vertical and horizontal dta points.
*
* Note: This will blow up the matrcide in memory size in the order of $aInNbr^2
*
* @param $ &$aData The original data matricde
* @param $aInNbr Interpolation factor
* @return the interpolated matrice
*/
function Linear( &$aData, $aIntFactor ) {
$step = pow( 2, $aIntFactor-1 );
$orig_cols = count( $aData[0] );
$orig_rows = count( $aData );
// Number of new columns/rows
// N = (a-1) * 2^(f-1) + 1
$p = pow( 2, $aIntFactor-1 );
$new_cols = $p * ( $orig_cols - 1 ) + 1;
$new_rows = $p * ( $orig_rows - 1 ) + 1;
$this->data = array_fill( 0, $new_rows, array_fill( 0, $new_cols, 0 ) );
// Initialize the new matrix with the values that we know
for ( $i = 0; $i < $new_rows; $i++ ) {
for ( $j = 0; $j < $new_cols; $j++ ) {
$v = 0 ;
if ( ( $i % $step == 0 ) && ( $j % $step == 0 ) ) {
$v = $aData[$i / $step][$j / $step];
}
$this->data[$i][$j] = $v;
}
}
for ( $i = 0; $i < $new_rows-1; $i += $step ) {
for ( $j = 0; $j < $new_cols-1; $j += $step ) {
$this->IntSquare( $i, $j, $aIntFactor );
}
}
return $this->data;
}
}
?>

View File

@ -1,369 +0,0 @@
<?php
/**
* jpgraph_mgraph.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_MGRAPH.PHP
// Description: Class to handle multiple graphs in the same image
// Created: 2006-01-15
// Ver: $Id: jpgraph_mgraph.php 1770 2009-08-17 06:10:22Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
//=============================================================================
// CLASS MGraph
// Description: Create a container image that can hold several graph
//=============================================================================
class MGraph {
public $title = null, $subtitle = null, $subsubtitle = null;
protected $img=NULL;
protected $iCnt=0,$iGraphs = array(); // image_handle, x, y, fx, fy, sizex, sizey
protected $iFillColor='white', $iCurrentColor=0;
protected $lm=4,$rm=4,$tm=4,$bm=4;
protected $iDoFrame = FALSE, $iFrameColor = 'black', $iFrameWeight = 1;
protected $iLineWeight = 1;
protected $expired=false;
protected $cache=null,$cache_name = '',$inline=true;
protected $image_format='png',$image_quality=75;
protected $iWidth=NULL,$iHeight=NULL;
protected $background_image='',$background_image_center=true,
$backround_image_format='',$background_image_mix=100,
$background_image_y=NULL, $background_image_x=NULL;
private $doshadow=false, $shadow_width=4, $shadow_color='gray@0.5';
public $footer;
// Create a new instane of the combined graph
function __construct($aWidth=NULL,$aHeight=NULL,$aCachedName='',$aTimeOut=0,$aInline=true) {
$this->iWidth = $aWidth;
$this->iHeight = $aHeight;
// If the cached version exist just read it directly from the
// cache, stream it back to browser and exit
if( $aCachedName!='' && READ_CACHE && $aInline ) {
$this->cache = new ImgStreamCache();
$this->cache->SetTimeOut($aTimeOut);
$image = new Image();
if( $this->cache->GetAndStream($image,$aCachedName) ) {
exit();
}
}
$this->inline = $aInline;
$this->cache_name = $aCachedName;
$this->title = new Text();
$this->title->ParagraphAlign('center');
$this->title->SetFont(FF_FONT2,FS_BOLD);
$this->title->SetMargin(3);
$this->title->SetAlign('center');
$this->subtitle = new Text();
$this->subtitle->ParagraphAlign('center');
$this->subtitle->SetFont(FF_FONT1,FS_BOLD);
$this->subtitle->SetMargin(3);
$this->subtitle->SetAlign('center');
$this->subsubtitle = new Text();
$this->subsubtitle->ParagraphAlign('center');
$this->subsubtitle->SetFont(FF_FONT1,FS_NORMAL);
$this->subsubtitle->SetMargin(3);
$this->subsubtitle->SetAlign('center');
$this->footer = new Footer();
}
// Specify background fill color for the combined graph
function SetFillColor($aColor) {
$this->iFillColor = $aColor;
}
// Add a frame around the combined graph
function SetFrame($aFlg,$aColor='black',$aWeight=1) {
$this->iDoFrame = $aFlg;
$this->iFrameColor = $aColor;
$this->iFrameWeight = $aWeight;
}
// Specify a background image blend
function SetBackgroundImageMix($aMix) {
$this->background_image_mix = $aMix ;
}
// Specify a background image
function SetBackgroundImage($aFileName,$aCenter_aX=NULL,$aY=NULL) {
// Second argument can be either a boolean value or
// a numeric
$aCenter=TRUE;
$aX=NULL;
if( is_numeric($aCenter_aX) ) {
$aX=$aCenter_aX;
}
// Get extension to determine image type
$e = explode('.',$aFileName);
if( !$e ) {
JpGraphError::RaiseL(12002,$aFileName);
//('Incorrect file name for MGraph::SetBackgroundImage() : '.$aFileName.' Must have a valid image extension (jpg,gif,png) when using autodetection of image type');
}
$valid_formats = array('png', 'jpg', 'gif');
$aImgFormat = strtolower($e[count($e)-1]);
if ($aImgFormat == 'jpeg') {
$aImgFormat = 'jpg';
}
elseif (!in_array($aImgFormat, $valid_formats) ) {
JpGraphError::RaiseL(12003,$aImgFormat,$aFileName);
//('Unknown file extension ($aImgFormat) in MGraph::SetBackgroundImage() for filename: '.$aFileName);
}
$this->background_image = $aFileName;
$this->background_image_center=$aCenter;
$this->background_image_format=$aImgFormat;
$this->background_image_x = $aX;
$this->background_image_y = $aY;
}
function _strokeBackgroundImage() {
if( $this->background_image == '' ) return;
$bkgimg = Graph::LoadBkgImage('',$this->background_image);
// Background width & Heoght
$bw = imagesx($bkgimg);
$bh = imagesy($bkgimg);
// Canvas width and height
$cw = imagesx($this->img);
$ch = imagesy($this->img);
if( $this->doshadow ) {
$cw -= $this->shadow_width;
$ch -= $this->shadow_width;
}
if( $this->background_image_x === NULL || $this->background_image_y === NULL ) {
if( $this->background_image_center ) {
// Center original image in the plot area
$x = round($cw/2-$bw/2); $y = round($ch/2-$bh/2);
}
else {
// Just copy the image from left corner, no resizing
$x=0; $y=0;
}
}
else {
$x = $this->background_image_x;
$y = $this->background_image_y;
}
imagecopymerge($this->img,$bkgimg,$x,$y,0,0,$bw,$bh,$this->background_image_mix);
}
function AddMix($aGraph,$x=0,$y=0,$mix=100,$fx=0,$fy=0,$w=0,$h=0) {
$this->_gdImgHandle($aGraph->Stroke( _IMG_HANDLER),$x,$y,$fx=0,$fy=0,$w,$h,$mix);
}
function Add($aGraph,$x=0,$y=0,$fx=0,$fy=0,$w=0,$h=0) {
$this->_gdImgHandle($aGraph->Stroke( _IMG_HANDLER),$x,$y,$fx=0,$fy=0,$w,$h);
}
function _gdImgHandle($agdCanvas,$x,$y,$fx=0,$fy=0,$w=0,$h=0,$mix=100) {
if( $w == 0 ) {
$w = @imagesx($agdCanvas);
}
if( $w === NULL ) {
JpGraphError::RaiseL(12007);
//('Argument to MGraph::Add() is not a valid GD image handle.');
return;
}
if( $h == 0 ) {
$h = @imagesy($agdCanvas);
}
$this->iGraphs[$this->iCnt++] = array($agdCanvas,$x,$y,$fx,$fy,$w,$h,$mix);
}
function SetMargin($lm,$rm,$tm,$bm) {
$this->lm = $lm;
$this->rm = $rm;
$this->tm = $tm;
$this->bm = $bm;
}
function SetExpired($aFlg=true) {
$this->expired = $aFlg;
}
function SetImgFormat($aFormat,$aQuality=75) {
$this->image_format = $aFormat;
$this->image_quality = $aQuality;
}
// Set the shadow around the whole image
function SetShadow($aShowShadow=true,$aShadowWidth=4,$aShadowColor='gray@0.3') {
$this->doshadow = $aShowShadow;
$this->shadow_color = $aShadowColor;
$this->shadow_width = $aShadowWidth;
$this->footer->iBottomMargin += $aShadowWidth;
$this->footer->iRightMargin += $aShadowWidth;
}
function StrokeTitle($image,$w,$h) {
// Stroke title
if( $this->title->t !== '' ) {
$margin = 3;
$y = $this->title->margin;
if( $this->title->halign == 'center' ) {
$this->title->Center(0,$w,$y);
}
elseif( $this->title->halign == 'left' ) {
$this->title->SetPos($this->title->margin+2,$y);
}
elseif( $this->title->halign == 'right' ) {
$indent = 0;
if( $this->doshadow ) {
$indent = $this->shadow_width+2;
}
$this->title->SetPos($w-$this->title->margin-$indent,$y,'right');
}
$this->title->Stroke($image);
// ... and subtitle
$y += $this->title->GetTextHeight($image) + $margin + $this->subtitle->margin;
if( $this->subtitle->halign == 'center' ) {
$this->subtitle->Center(0,$w,$y);
}
elseif( $this->subtitle->halign == 'left' ) {
$this->subtitle->SetPos($this->subtitle->margin+2,$y);
}
elseif( $this->subtitle->halign == 'right' ) {
$indent = 0;
if( $this->doshadow ) {
$indent = $this->shadow_width+2;
}
$this->subtitle->SetPos($this->img->width-$this->subtitle->margin-$indent,$y,'right');
}
$this->subtitle->Stroke($image);
// ... and subsubtitle
$y += $this->subtitle->GetTextHeight($image) + $margin + $this->subsubtitle->margin;
if( $this->subsubtitle->halign == 'center' ) {
$this->subsubtitle->Center(0,$w,$y);
}
elseif( $this->subsubtitle->halign == 'left' ) {
$this->subsubtitle->SetPos($this->subsubtitle->margin+2,$y);
}
elseif( $this->subsubtitle->halign == 'right' ) {
$indent = 0;
if( $this->doshadow ) {
$indent = $this->shadow_width+2;
}
$this->subsubtitle->SetPos($w-$this->subsubtitle->margin-$indent,$y,'right');
}
$this->subsubtitle->Stroke($image);
}
}
function Stroke($aFileName='') {
// Find out the necessary size for the container image
$w=0; $h=0;
for($i=0; $i < $this->iCnt; ++$i ) {
$maxw = $this->iGraphs[$i][1]+$this->iGraphs[$i][5];
$maxh = $this->iGraphs[$i][2]+$this->iGraphs[$i][6];
$w = max( $w, $maxw );
$h = max( $h, $maxh );
}
$w += $this->lm+$this->rm;
$h += $this->tm+$this->bm;
// User specified width,height overrides
if( $this->iWidth !== NULL && $this->iWidth !== 0 ) $w = $this->iWidth;
if( $this->iHeight!== NULL && $this->iHeight !== 0) $h = $this->iHeight;
if( $this->doshadow ) {
$w += $this->shadow_width;
$h += $this->shadow_width;
}
$image = new Image($w,$h);
$image->SetImgFormat( $this->image_format,$this->image_quality);
if( $this->doshadow ) {
$image->SetColor($this->iFrameColor);
$image->ShadowRectangle(0,0,$w-1,$h-1,$this->iFillColor,$this->shadow_width,$this->shadow_color);
$w -= $this->shadow_width;
$h -= $this->shadow_width;
}
else {
$image->SetColor($this->iFillColor);
$image->FilledRectangle(0,0,$w-1,$h-1);
}
$image->SetExpired($this->expired);
$this->img = $image->img;
$this->_strokeBackgroundImage();
if( $this->iDoFrame && ! $this->doshadow ) {
$image->SetColor($this->iFrameColor);
$image->SetLineWeight($this->iFrameWeight);
$image->Rectangle(0,0,$w-1,$h-1);
}
// Copy all sub graphs to the container
for($i=0; $i < $this->iCnt; ++$i ) {
$image->CopyMerge($this->iGraphs[$i][0],
$this->iGraphs[$i][1]+$this->lm,$this->iGraphs[$i][2]+$this->tm,
$this->iGraphs[$i][3],$this->iGraphs[$i][4],
$this->iGraphs[$i][5],$this->iGraphs[$i][6],
-1,-1, /* Full from width and height */
$this->iGraphs[$i][7]);
}
$this->StrokeTitle($image,$w,$h);
$this->footer->Stroke($image);
// Output image
if( $aFileName == _IMG_HANDLER ) {
return $image->img;
}
else {
//Finally stream the generated picture
$this->cache = new ImgStreamCache();
$this->cache->PutAndStream($image,$this->cache_name,$this->inline,$aFileName);
}
}
}
// EOF
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,957 +0,0 @@
<?php
/**
* jpgraph_pie3d.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_PIE3D.PHP
// Description: 3D Pie plot extension for JpGraph
// Created: 2001-03-24
// Ver: $Id: jpgraph_pie3d.php 1329 2009-06-20 19:23:30Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
//===================================================
// CLASS PiePlot3D
// Description: Plots a 3D pie with a specified projection
// angle between 20 and 70 degrees.
//===================================================
class PiePlot3D extends PiePlot {
private $labelhintcolor="red",$showlabelhint=true;
private $angle=50;
private $edgecolor="", $edgeweight=1;
private $iThickness=false;
//---------------
// CONSTRUCTOR
function __construct($data) {
$this->radius = 0.5;
$this->data = $data;
$this->title = new Text("");
$this->title->SetFont(FF_FONT1,FS_BOLD);
$this->value = new DisplayValue();
$this->value->Show();
$this->value->SetFormat('%.0f%%');
}
//---------------
// PUBLIC METHODS
// Set label arrays
function SetLegends($aLegend) {
$this->legends = array_reverse(array_slice($aLegend,0,count($this->data)));
}
function SetSliceColors($aColors) {
$this->setslicecolors = $aColors;
}
function Legend($aGraph) {
parent::Legend($aGraph);
$aGraph->legend->txtcol = array_reverse($aGraph->legend->txtcol);
}
function SetCSIMTargets($aTargets,$aAlts='',$aWinTargets='') {
$this->csimtargets = $aTargets;
$this->csimwintargets = $aWinTargets;
$this->csimalts = $aAlts;
}
// Should the slices be separated by a line? If color is specified as "" no line
// will be used to separate pie slices.
function SetEdge($aColor='black',$aWeight=1) {
$this->edgecolor = $aColor;
$this->edgeweight = $aWeight;
}
// Specify projection angle for 3D in degrees
// Must be between 20 and 70 degrees
function SetAngle($a) {
if( $a<5 || $a>90 ) {
JpGraphError::RaiseL(14002);
//("PiePlot3D::SetAngle() 3D Pie projection angle must be between 5 and 85 degrees.");
}
else {
$this->angle = $a;
}
}
function Add3DSliceToCSIM($i,$xc,$yc,$height,$width,$thick,$sa,$ea) { //Slice number, ellipse centre (x,y), height, width, start angle, end angle
$sa *= M_PI/180;
$ea *= M_PI/180;
//add coordinates of the centre to the map
$coords = "$xc, $yc";
//add coordinates of the first point on the arc to the map
$xp = floor($width*cos($sa)/2+$xc);
$yp = floor($yc-$height*sin($sa)/2);
$coords.= ", $xp, $yp";
//If on the front half, add the thickness offset
if ($sa >= M_PI && $sa <= 2*M_PI*1.01) {
$yp = floor($yp+$thick);
$coords.= ", $xp, $yp";
}
//add coordinates every 0.2 radians
$a=$sa+0.2;
while ($a<$ea) {
$xp = floor($width*cos($a)/2+$xc);
if ($a >= M_PI && $a <= 2*M_PI*1.01) {
$yp = floor($yc-($height*sin($a)/2)+$thick);
} else {
$yp = floor($yc-$height*sin($a)/2);
}
$coords.= ", $xp, $yp";
$a += 0.2;
}
//Add the last point on the arc
$xp = floor($width*cos($ea)/2+$xc);
$yp = floor($yc-$height*sin($ea)/2);
if ($ea >= M_PI && $ea <= 2*M_PI*1.01) {
$coords.= ", $xp, ".floor($yp+$thick);
}
$coords.= ", $xp, $yp";
$alt='';
if( !empty($this->csimtargets[$i]) ) {
$this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".$this->csimtargets[$i]."\"";
if( !empty($this->csimwintargets[$i]) ) {
$this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" ";
}
if( !empty($this->csimalts[$i]) ) {
$tmp=sprintf($this->csimalts[$i],$this->data[$i]);
$this->csimareas .= "alt=\"$tmp\" title=\"$tmp\" ";
}
$this->csimareas .= " />\n";
}
}
function SetLabels($aLabels,$aLblPosAdj="auto") {
$this->labels = $aLabels;
$this->ilabelposadj=$aLblPosAdj;
}
// Distance from the pie to the labels
function SetLabelMargin($m) {
$this->value->SetMargin($m);
}
// Show a thin line from the pie to the label for a specific slice
function ShowLabelHint($f=true) {
$this->showlabelhint=$f;
}
// Set color of hint line to label for each slice
function SetLabelHintColor($c) {
$this->labelhintcolor=$c;
}
function SetHeight($aHeight) {
$this->iThickness = $aHeight;
}
// Normalize Angle between 0-360
function NormAngle($a) {
// Normalize anle to 0 to 2M_PI
//
if( $a > 0 ) {
while($a > 360) $a -= 360;
}
else {
while($a < 0) $a += 360;
}
if( $a < 0 )
$a = 360 + $a;
if( $a == 360 ) $a=0;
return $a;
}
// Draw one 3D pie slice at position ($xc,$yc) with height $z
function Pie3DSlice($img,$xc,$yc,$w,$h,$sa,$ea,$z,$fillcolor,$shadow=0.65) {
// Due to the way the 3D Pie algorithm works we are
// guaranteed that any slice we get into this method
// belongs to either the left or right side of the
// pie ellipse. Hence, no slice will cross 90 or 270
// point.
if( ($sa < 90 && $ea > 90) || ( ($sa > 90 && $sa < 270) && $ea > 270) ) {
JpGraphError::RaiseL(14003);//('Internal assertion failed. Pie3D::Pie3DSlice');
exit(1);
}
$p[] = array();
// Setup pre-calculated values
$rsa = $sa/180*M_PI; // to Rad
$rea = $ea/180*M_PI; // to Rad
$sinsa = sin($rsa);
$cossa = cos($rsa);
$sinea = sin($rea);
$cosea = cos($rea);
// p[] is the points for the overall slice and
// pt[] is the points for the top pie
// Angular step when approximating the arc with a polygon train.
$step = 0.05;
if( $sa >= 270 ) {
if( $ea > 360 || ($ea > 0 && $ea <= 90) ) {
if( $ea > 0 && $ea <= 90 ) {
// Adjust angle to simplify conditions in loops
$rea += 2*M_PI;
}
$p = array($xc,$yc,$xc,$yc+$z,
$xc+$w*$cossa,$z+$yc-$h*$sinsa);
$pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa);
for( $a=$rsa; $a < 2*M_PI; $a += $step ) {
$tca = cos($a);
$tsa = sin($a);
$p[] = $xc+$w*$tca;
$p[] = $z+$yc-$h*$tsa;
$pt[] = $xc+$w*$tca;
$pt[] = $yc-$h*$tsa;
}
$pt[] = $xc+$w;
$pt[] = $yc;
$p[] = $xc+$w;
$p[] = $z+$yc;
$p[] = $xc+$w;
$p[] = $yc;
$p[] = $xc;
$p[] = $yc;
for( $a=2*M_PI+$step; $a < $rea; $a += $step ) {
$pt[] = $xc + $w*cos($a);
$pt[] = $yc - $h*sin($a);
}
$pt[] = $xc+$w*$cosea;
$pt[] = $yc-$h*$sinea;
$pt[] = $xc;
$pt[] = $yc;
}
else {
$p = array($xc,$yc,$xc,$yc+$z,
$xc+$w*$cossa,$z+$yc-$h*$sinsa);
$pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa);
$rea = $rea == 0.0 ? 2*M_PI : $rea;
for( $a=$rsa; $a < $rea; $a += $step ) {
$tca = cos($a);
$tsa = sin($a);
$p[] = $xc+$w*$tca;
$p[] = $z+$yc-$h*$tsa;
$pt[] = $xc+$w*$tca;
$pt[] = $yc-$h*$tsa;
}
$pt[] = $xc+$w*$cosea;
$pt[] = $yc-$h*$sinea;
$pt[] = $xc;
$pt[] = $yc;
$p[] = $xc+$w*$cosea;
$p[] = $z+$yc-$h*$sinea;
$p[] = $xc+$w*$cosea;
$p[] = $yc-$h*$sinea;
$p[] = $xc;
$p[] = $yc;
}
}
elseif( $sa >= 180 ) {
$p = array($xc,$yc,$xc,$yc+$z,$xc+$w*$cosea,$z+$yc-$h*$sinea);
$pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea);
for( $a=$rea; $a>$rsa; $a -= $step ) {
$tca = cos($a);
$tsa = sin($a);
$p[] = $xc+$w*$tca;
$p[] = $z+$yc-$h*$tsa;
$pt[] = $xc+$w*$tca;
$pt[] = $yc-$h*$tsa;
}
$pt[] = $xc+$w*$cossa;
$pt[] = $yc-$h*$sinsa;
$pt[] = $xc;
$pt[] = $yc;
$p[] = $xc+$w*$cossa;
$p[] = $z+$yc-$h*$sinsa;
$p[] = $xc+$w*$cossa;
$p[] = $yc-$h*$sinsa;
$p[] = $xc;
$p[] = $yc;
}
elseif( $sa >= 90 ) {
if( $ea > 180 ) {
$p = array($xc,$yc,$xc,$yc+$z,$xc+$w*$cosea,$z+$yc-$h*$sinea);
$pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea);
for( $a=$rea; $a > M_PI; $a -= $step ) {
$tca = cos($a);
$tsa = sin($a);
$p[] = $xc+$w*$tca;
$p[] = $z + $yc - $h*$tsa;
$pt[] = $xc+$w*$tca;
$pt[] = $yc-$h*$tsa;
}
$p[] = $xc-$w;
$p[] = $z+$yc;
$p[] = $xc-$w;
$p[] = $yc;
$p[] = $xc;
$p[] = $yc;
$pt[] = $xc-$w;
$pt[] = $z+$yc;
$pt[] = $xc-$w;
$pt[] = $yc;
for( $a=M_PI-$step; $a > $rsa; $a -= $step ) {
$pt[] = $xc + $w*cos($a);
$pt[] = $yc - $h*sin($a);
}
$pt[] = $xc+$w*$cossa;
$pt[] = $yc-$h*$sinsa;
$pt[] = $xc;
$pt[] = $yc;
}
else { // $sa >= 90 && $ea <= 180
$p = array($xc,$yc,$xc,$yc+$z,
$xc+$w*$cosea,$z+$yc-$h*$sinea,
$xc+$w*$cosea,$yc-$h*$sinea,
$xc,$yc);
$pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea);
for( $a=$rea; $a>$rsa; $a -= $step ) {
$pt[] = $xc + $w*cos($a);
$pt[] = $yc - $h*sin($a);
}
$pt[] = $xc+$w*$cossa;
$pt[] = $yc-$h*$sinsa;
$pt[] = $xc;
$pt[] = $yc;
}
}
else { // sa > 0 && ea < 90
$p = array($xc,$yc,$xc,$yc+$z,
$xc+$w*$cossa,$z+$yc-$h*$sinsa,
$xc+$w*$cossa,$yc-$h*$sinsa,
$xc,$yc);
$pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa);
for( $a=$rsa; $a < $rea; $a += $step ) {
$pt[] = $xc + $w*cos($a);
$pt[] = $yc - $h*sin($a);
}
$pt[] = $xc+$w*$cosea;
$pt[] = $yc-$h*$sinea;
$pt[] = $xc;
$pt[] = $yc;
}
$img->PushColor($fillcolor.":".$shadow);
$img->FilledPolygon($p);
$img->PopColor();
$img->PushColor($fillcolor);
$img->FilledPolygon($pt);
$img->PopColor();
}
function SetStartAngle($aStart) {
if( $aStart < 0 || $aStart > 360 ) {
JpGraphError::RaiseL(14004);//('Slice start angle must be between 0 and 360 degrees.');
}
$this->startangle = $aStart;
}
// Draw a 3D Pie
function Pie3D($aaoption,$img,$data,$colors,$xc,$yc,$d,$angle,$z,
$shadow=0.65,$startangle=0,$edgecolor="",$edgeweight=1) {
//---------------------------------------------------------------------------
// As usual the algorithm get more complicated than I originally
// envisioned. I believe that this is as simple as it is possible
// to do it with the features I want. It's a good exercise to start
// thinking on how to do this to convince your self that all this
// is really needed for the general case.
//
// The algorithm two draw 3D pies without "real 3D" is done in
// two steps.
// First imagine the pie cut in half through a thought line between
// 12'a clock and 6'a clock. It now easy to imagine that we can plot
// the individual slices for each half by starting with the topmost
// pie slice and continue down to 6'a clock.
//
// In the algortithm this is done in three principal steps
// Step 1. Do the knife cut to ensure by splitting slices that extends
// over the cut line. This is done by splitting the original slices into
// upto 3 subslices.
// Step 2. Find the top slice for each half
// Step 3. Draw the slices from top to bottom
//
// The thing that slightly complicates this scheme with all the
// angle comparisons below is that we can have an arbitrary start
// angle so we must take into account the different equivalence classes.
// For the same reason we must walk through the angle array in a
// modulo fashion.
//
// Limitations of algorithm:
// * A small exploded slice which crosses the 270 degree point
// will get slightly nagged close to the center due to the fact that
// we print the slices in Z-order and that the slice left part
// get printed first and might get slightly nagged by a larger
// slice on the right side just before the right part of the small
// slice. Not a major problem though.
//---------------------------------------------------------------------------
// Determine the height of the ellippse which gives an
// indication of the inclination angle
$h = ($angle/90.0)*$d;
$sum = 0;
for($i=0; $i<count($data); ++$i ) {
$sum += $data[$i];
}
// Special optimization
if( $sum==0 ) return;
if( $this->labeltype == 2 ) {
$this->adjusted_data = $this->AdjPercentage($data);
}
// Setup the start
$accsum = 0;
$a = $startangle;
$a = $this->NormAngle($a);
//
// Step 1 . Split all slices that crosses 90 or 270
//
$idx=0;
$adjexplode=array();
$numcolors = count($colors);
for($i=0; $i<count($data); ++$i, ++$idx ) {
$da = $data[$i]/$sum * 360;
if( empty($this->explode_radius[$i]) ) {
$this->explode_radius[$i]=0;
}
$expscale=1;
if( $aaoption == 1 ) {
$expscale=2;
}
$la = $a + $da/2;
$explode = array( $xc + $this->explode_radius[$i]*cos($la*M_PI/180)*$expscale,
$yc - $this->explode_radius[$i]*sin($la*M_PI/180) * ($h/$d) *$expscale );
$adjexplode[$idx] = $explode;
$labeldata[$i] = array($la,$explode[0],$explode[1]);
$originalangles[$i] = array($a,$a+$da);
$ne = $this->NormAngle($a+$da);
if( $da <= 180 ) {
// If the slice size is <= 90 it can at maximum cut across
// one boundary (either 90 or 270) where it needs to be split
$split=-1; // no split
if( ($da<=90 && ($a <= 90 && $ne > 90)) ||
(($da <= 180 && $da >90) && (($a < 90 || $a >= 270) && $ne > 90)) ) {
$split = 90;
}
elseif( ($da<=90 && ($a <= 270 && $ne > 270)) ||
(($da<=180 && $da>90) && ($a >= 90 && $a < 270 && ($a+$da) > 270 )) ) {
$split = 270;
}
if( $split > 0 ) { // split in two
$angles[$idx] = array($a,$split);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
$angles[++$idx] = array($split,$ne);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
}
else { // no split
$angles[$idx] = array($a,$ne);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
}
}
else {
// da>180
// Slice may, depending on position, cross one or two
// bonudaries
if( $a < 90 ) $split = 90;
elseif( $a <= 270 ) $split = 270;
else $split = 90;
$angles[$idx] = array($a,$split);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
//if( $a+$da > 360-$split ) {
// For slices larger than 270 degrees we might cross
// another boundary as well. This means that we must
// split the slice further. The comparison gets a little
// bit complicated since we must take into accound that
// a pie might have a startangle >0 and hence a slice might
// wrap around the 0 angle.
// Three cases:
// a) Slice starts before 90 and hence gets a split=90, but
// we must also check if we need to split at 270
// b) Slice starts after 90 but before 270 and slices
// crosses 90 (after a wrap around of 0)
// c) If start is > 270 (hence the firstr split is at 90)
// and the slice is so large that it goes all the way
// around 270.
if( ($a < 90 && ($a+$da > 270)) || ($a > 90 && $a<=270 && ($a+$da>360+90) ) || ($a > 270 && $this->NormAngle($a+$da)>270) ) {
$angles[++$idx] = array($split,360-$split);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
$angles[++$idx] = array(360-$split,$ne);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
}
else {
// Just a simple split to the previous decided
// angle.
$angles[++$idx] = array($split,$ne);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
}
}
$a += $da;
$a = $this->NormAngle($a);
}
// Total number of slices
$n = count($angles);
for($i=0; $i<$n; ++$i) {
list($dbgs,$dbge) = $angles[$i];
}
//
// Step 2. Find start index (first pie that starts in upper left quadrant)
//
$minval = $angles[0][0];
$min = 0;
for( $i=0; $i<$n; ++$i ) {
if( $angles[$i][0] < $minval ) {
$minval = $angles[$i][0];
$min = $i;
}
}
$j = $min;
$cnt = 0;
while( $angles[$j][1] <= 90 ) {
$j++;
if( $j>=$n) {
$j=0;
}
if( $cnt > $n ) {
JpGraphError::RaiseL(14005);
//("Pie3D Internal error (#1). Trying to wrap twice when looking for start index");
}
++$cnt;
}
$start = $j;
//
// Step 3. Print slices in z-order
//
$cnt = 0;
// First stroke all the slices between 90 and 270 (left half circle)
// counterclockwise
while( $angles[$j][0] < 270 && $aaoption !== 2 ) {
list($x,$y) = $adjexplode[$j];
$this->Pie3DSlice($img,$x,$y,$d,$h,$angles[$j][0],$angles[$j][1],
$z,$adjcolors[$j],$shadow);
$last = array($x,$y,$j);
$j++;
if( $j >= $n ) $j=0;
if( $cnt > $n ) {
JpGraphError::RaiseL(14006);
//("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.");
}
++$cnt;
}
$slice_left = $n-$cnt;
$j=$start-1;
if($j<0) $j=$n-1;
$cnt = 0;
// The stroke all slices from 90 to -90 (right half circle)
// clockwise
while( $cnt < $slice_left && $aaoption !== 2 ) {
list($x,$y) = $adjexplode[$j];
$this->Pie3DSlice($img,$x,$y,$d,$h,$angles[$j][0],$angles[$j][1],
$z,$adjcolors[$j],$shadow);
$j--;
if( $cnt > $n ) {
JpGraphError::RaiseL(14006);
//("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.");
}
if($j<0) $j=$n-1;
$cnt++;
}
// Now do a special thing. Stroke the last slice on the left
// halfcircle one more time. This is needed in the case where
// the slice close to 270 have been exploded. In that case the
// part of the slice close to the center of the pie might be
// slightly nagged.
if( $aaoption !== 2 )
$this->Pie3DSlice($img,$last[0],$last[1],$d,$h,$angles[$last[2]][0],
$angles[$last[2]][1],$z,$adjcolors[$last[2]],$shadow);
if( $aaoption !== 1 ) {
// Now print possible labels and add csim
$this->value->ApplyFont($img);
$margin = $img->GetFontHeight()/2 + $this->value->margin ;
for($i=0; $i < count($data); ++$i ) {
$la = $labeldata[$i][0];
$x = $labeldata[$i][1] + cos($la*M_PI/180)*($d+$margin)*$this->ilabelposadj;
$y = $labeldata[$i][2] - sin($la*M_PI/180)*($h+$margin)*$this->ilabelposadj;
if( $this->ilabelposadj >= 1.0 ) {
if( $la > 180 && $la < 360 ) $y += $z;
}
if( $this->labeltype == 0 ) {
if( $sum > 0 ) $l = 100*$data[$i]/$sum;
else $l = 0;
}
elseif( $this->labeltype == 1 ) {
$l = $data[$i];
}
else {
$l = $this->adjusted_data[$i];
}
if( isset($this->labels[$i]) && is_string($this->labels[$i]) ) {
$l=sprintf($this->labels[$i],$l);
}
$this->StrokeLabels($l,$img,$labeldata[$i][0]*M_PI/180,$x,$y,$z);
$this->Add3DSliceToCSIM($i,$labeldata[$i][1],$labeldata[$i][2],$h*2,$d*2,$z,
$originalangles[$i][0],$originalangles[$i][1]);
}
}
//
// Finally add potential lines in pie
//
if( $edgecolor=="" || $aaoption !== 0 ) return;
$accsum = 0;
$a = $startangle;
$a = $this->NormAngle($a);
$a *= M_PI/180.0;
$idx=0;
$img->PushColor($edgecolor);
$img->SetLineWeight($edgeweight);
$fulledge = true;
for($i=0; $i < count($data) && $fulledge; ++$i ) {
if( empty($this->explode_radius[$i]) ) {
$this->explode_radius[$i]=0;
}
if( $this->explode_radius[$i] > 0 ) {
$fulledge = false;
}
}
for($i=0; $i < count($data); ++$i, ++$idx ) {
$da = $data[$i]/$sum * 2*M_PI;
$this->StrokeFullSliceFrame($img,$xc,$yc,$a,$a+$da,$d,$h,$z,$edgecolor,
$this->explode_radius[$i],$fulledge);
$a += $da;
}
$img->PopColor();
}
function StrokeFullSliceFrame($img,$xc,$yc,$sa,$ea,$w,$h,$z,$edgecolor,$exploderadius,$fulledge) {
$step = 0.02;
if( $exploderadius > 0 ) {
$la = ($sa+$ea)/2;
$xc += $exploderadius*cos($la);
$yc -= $exploderadius*sin($la) * ($h/$w) ;
}
$p = array($xc,$yc,$xc+$w*cos($sa),$yc-$h*sin($sa));
for($a=$sa; $a < $ea; $a += $step ) {
$p[] = $xc + $w*cos($a);
$p[] = $yc - $h*sin($a);
}
$p[] = $xc+$w*cos($ea);
$p[] = $yc-$h*sin($ea);
$p[] = $xc;
$p[] = $yc;
$img->SetColor($edgecolor);
$img->Polygon($p);
// Unfortunately we can't really draw the full edge around the whole of
// of the slice if any of the slices are exploded. The reason is that
// this algorithm is to simply. There are cases where the edges will
// "overwrite" other slices when they have been exploded.
// Doing the full, proper 3D hidden lines stiff is actually quite
// tricky. So for exploded pies we only draw the top edge. Not perfect
// but the "real" solution is much more complicated.
if( $fulledge && !( $sa > 0 && $sa < M_PI && $ea < M_PI) ) {
if($sa < M_PI && $ea > M_PI) {
$sa = M_PI;
}
if($sa < 2*M_PI && (($ea >= 2*M_PI) || ($ea > 0 && $ea < $sa ) ) ) {
$ea = 2*M_PI;
}
if( $sa >= M_PI && $ea <= 2*M_PI ) {
$p = array($xc + $w*cos($sa),$yc - $h*sin($sa),
$xc + $w*cos($sa),$z + $yc - $h*sin($sa));
for($a=$sa+$step; $a < $ea; $a += $step ) {
$p[] = $xc + $w*cos($a);
$p[] = $z + $yc - $h*sin($a);
}
$p[] = $xc + $w*cos($ea);
$p[] = $z + $yc - $h*sin($ea);
$p[] = $xc + $w*cos($ea);
$p[] = $yc - $h*sin($ea);
$img->SetColor($edgecolor);
$img->Polygon($p);
}
}
}
function Stroke($img,$aaoption=0) {
$n = count($this->data);
// If user hasn't set the colors use the theme array
if( $this->setslicecolors==null ) {
$colors = array_keys($img->rgb->rgb_table);
sort($colors);
$idx_a=$this->themearr[$this->theme];
$ca = array();
$m = count($idx_a);
for($i=0; $i < $m; ++$i) {
$ca[$i] = $colors[$idx_a[$i]];
}
$ca = array_reverse(array_slice($ca,0,$n));
}
else {
$ca = $this->setslicecolors;
}
if( $this->posx <= 1 && $this->posx > 0 ) {
$xc = round($this->posx*$img->width);
}
else {
$xc = $this->posx ;
}
if( $this->posy <= 1 && $this->posy > 0 ) {
$yc = round($this->posy*$img->height);
}
else {
$yc = $this->posy ;
}
if( $this->radius <= 1 ) {
$width = floor($this->radius*min($img->width,$img->height));
// Make sure that the pie doesn't overflow the image border
// The 0.9 factor is simply an extra margin to leave some space
// between the pie an the border of the image.
$width = min($width,min($xc*0.9,($yc*90/$this->angle-$width/4)*0.9));
}
else {
$width = $this->radius * ($aaoption === 1 ? 2 : 1 ) ;
}
// Add a sanity check for width
if( $width < 1 ) {
JpGraphError::RaiseL(14007);//("Width for 3D Pie is 0. Specify a size > 0");
}
// Establish a thickness. By default the thickness is a fifth of the
// pie slice width (=pie radius) but since the perspective depends
// on the inclination angle we use some heuristics to make the edge
// slightly thicker the less the angle.
// Has user specified an absolute thickness? In that case use
// that instead
if( $this->iThickness ) {
$thick = $this->iThickness;
$thick *= ($aaoption === 1 ? 2 : 1 );
}
else {
$thick = $width/12;
}
$a = $this->angle;
if( $a <= 30 ) $thick *= 1.6;
elseif( $a <= 40 ) $thick *= 1.4;
elseif( $a <= 50 ) $thick *= 1.2;
elseif( $a <= 60 ) $thick *= 1.0;
elseif( $a <= 70 ) $thick *= 0.8;
elseif( $a <= 80 ) $thick *= 0.7;
else $thick *= 0.6;
$thick = floor($thick);
if( $this->explode_all ) {
for($i=0; $i < $n; ++$i)
$this->explode_radius[$i]=$this->explode_r;
}
$this->Pie3D($aaoption,$img,$this->data, $ca, $xc, $yc, $width, $this->angle,
$thick, 0.65, $this->startangle, $this->edgecolor, $this->edgeweight);
// Adjust title position
if( $aaoption != 1 ) {
$this->title->SetPos($xc,$yc-$this->title->GetFontHeight($img)-$width/2-$this->title->margin, "center","bottom");
$this->title->Stroke($img);
}
}
//---------------
// PRIVATE METHODS
// Position the labels of each slice
function StrokeLabels($label,$img,$a,$xp,$yp,$z) {
$this->value->halign="left";
$this->value->valign="top";
// Position the axis title.
// dx, dy is the offset from the top left corner of the bounding box that sorrounds the text
// that intersects with the extension of the corresponding axis. The code looks a little
// bit messy but this is really the only way of having a reasonable position of the
// axis titles.
$this->value->ApplyFont($img);
$h=$img->GetTextHeight($label);
// For numeric values the format of the display value
// must be taken into account
if( is_numeric($label) ) {
if( $label >= 0 ) {
$w=$img->GetTextWidth(sprintf($this->value->format,$label));
}
else {
$w=$img->GetTextWidth(sprintf($this->value->negformat,$label));
}
}
else {
$w=$img->GetTextWidth($label);
}
while( $a > 2*M_PI ) {
$a -= 2*M_PI;
}
if( $a>=7*M_PI/4 || $a <= M_PI/4 ) $dx=0;
if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dx=($a-M_PI/4)*2/M_PI;
if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dx=1;
if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dx=(1-($a-M_PI*5/4)*2/M_PI);
if( $a>=7*M_PI/4 ) $dy=(($a-M_PI)-3*M_PI/4)*2/M_PI;
if( $a<=M_PI/4 ) $dy=(1-$a*2/M_PI);
if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dy=1;
if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dy=(1-($a-3*M_PI/4)*2/M_PI);
if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dy=0;
$x = round($xp-$dx*$w);
$y = round($yp-$dy*$h);
// Mark anchor point for debugging
/*
$img->SetColor('red');
$img->Line($xp-10,$yp,$xp+10,$yp);
$img->Line($xp,$yp-10,$xp,$yp+10);
*/
$oldmargin = $this->value->margin;
$this->value->margin=0;
$this->value->Stroke($img,$label,$x,$y);
$this->value->margin=$oldmargin;
}
} // Class
/* EOF */
?>

View File

@ -1,659 +0,0 @@
<?php
/**
* jpgraph_plotband.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_PLOTBAND.PHP
// Description: PHP4 Graph Plotting library. Extension module.
// Created: 2004-02-18
// Ver: $Id: jpgraph_plotband.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
// Constants for types of static bands in plot area
define("BAND_RDIAG",1); // Right diagonal lines
define("BAND_LDIAG",2); // Left diagonal lines
define("BAND_SOLID",3); // Solid one color
define("BAND_VLINE",4); // Vertical lines
define("BAND_HLINE",5); // Horizontal lines
define("BAND_3DPLANE",6); // "3D" Plane
define("BAND_HVCROSS",7); // Vertical/Hor crosses
define("BAND_DIAGCROSS",8); // Diagonal crosses
// Utility class to hold coordinates for a rectangle
class Rectangle {
public $x,$y,$w,$h;
public $xe, $ye;
function __construct($aX,$aY,$aWidth,$aHeight) {
$this->x=$aX;
$this->y=$aY;
$this->w=$aWidth;
$this->h=$aHeight;
$this->xe=$aX+$aWidth-1;
$this->ye=$aY+$aHeight-1;
}
}
//=====================================================================
// Class RectPattern
// Base class for pattern hierarchi that is used to display patterned
// bands on the graph. Any subclass that doesn't override Stroke()
// must at least implement method DoPattern($aImg) which is responsible
// for drawing the pattern onto the graph.
//=====================================================================
class RectPattern {
protected $color;
protected $weight;
protected $rect=null;
protected $doframe=true;
protected $linespacing; // Line spacing in pixels
protected $iBackgroundColor=-1; // Default is no background fill
function __construct($aColor,$aWeight=1) {
$this->color = $aColor;
$this->weight = $aWeight;
}
function SetBackground($aBackgroundColor) {
$this->iBackgroundColor=$aBackgroundColor;
}
function SetPos($aRect) {
$this->rect = $aRect;
}
function ShowFrame($aShow=true) {
$this->doframe=$aShow;
}
function SetDensity($aDens) {
if( $aDens < 1 || $aDens > 100 )
JpGraphError::RaiseL(16001,$aDens);
//(" Desity for pattern must be between 1 and 100. (You tried $aDens)");
// 1% corresponds to linespacing=50
// 100 % corresponds to linespacing 1
$this->linespacing = floor(((100-$aDens)/100.0)*50)+1;
}
function Stroke($aImg) {
if( $this->rect == null )
JpGraphError::RaiseL(16002);
//(" No positions specified for pattern.");
if( !(is_numeric($this->iBackgroundColor) && $this->iBackgroundColor==-1) ) {
$aImg->SetColor($this->iBackgroundColor);
$aImg->FilledRectangle($this->rect->x,$this->rect->y,$this->rect->xe,$this->rect->ye);
}
$aImg->SetColor($this->color);
$aImg->SetLineWeight($this->weight);
// Virtual function implemented by subclass
$this->DoPattern($aImg);
// Frame around the pattern area
if( $this->doframe )
$aImg->Rectangle($this->rect->x,$this->rect->y,$this->rect->xe,$this->rect->ye);
}
}
//=====================================================================
// Class RectPatternSolid
// Implements a solid band
//=====================================================================
class RectPatternSolid extends RectPattern {
function __construct($aColor="black",$aWeight=1) {
parent::__construct($aColor,$aWeight);
}
function DoPattern($aImg) {
$aImg->SetColor($this->color);
$aImg->FilledRectangle($this->rect->x,$this->rect->y,
$this->rect->xe,$this->rect->ye);
}
}
//=====================================================================
// Class RectPatternHor
// Implements horizontal line pattern
//=====================================================================
class RectPatternHor extends RectPattern {
function __construct($aColor="black",$aWeight=1,$aLineSpacing=7) {
parent::__construct($aColor,$aWeight);
$this->linespacing = $aLineSpacing;
}
function DoPattern($aImg) {
$x0 = $this->rect->x;
$x1 = $this->rect->xe;
$y = $this->rect->y;
while( $y < $this->rect->ye ) {
$aImg->Line($x0,$y,$x1,$y);
$y += $this->linespacing;
}
}
}
//=====================================================================
// Class RectPatternVert
// Implements vertical line pattern
//=====================================================================
class RectPatternVert extends RectPattern {
function __construct($aColor="black",$aWeight=1,$aLineSpacing=7) {
parent::__construct($aColor,$aWeight);
$this->linespacing = $aLineSpacing;
}
//--------------------
// Private methods
//
function DoPattern($aImg) {
$x = $this->rect->x;
$y0 = $this->rect->y;
$y1 = $this->rect->ye;
while( $x < $this->rect->xe ) {
$aImg->Line($x,$y0,$x,$y1);
$x += $this->linespacing;
}
}
}
//=====================================================================
// Class RectPatternRDiag
// Implements right diagonal pattern
//=====================================================================
class RectPatternRDiag extends RectPattern {
function __construct($aColor="black",$aWeight=1,$aLineSpacing=12) {
parent::__construct($aColor,$aWeight);
$this->linespacing = $aLineSpacing;
}
function DoPattern($aImg) {
// --------------------
// | / / / / /|
// |/ / / / / |
// | / / / / |
// --------------------
$xe = $this->rect->xe;
$ye = $this->rect->ye;
$x0 = $this->rect->x + round($this->linespacing/2);
$y0 = $this->rect->y;
$x1 = $this->rect->x;
$y1 = $this->rect->y + round($this->linespacing/2);
while($x0<=$xe && $y1<=$ye) {
$aImg->Line($x0,$y0,$x1,$y1);
$x0 += $this->linespacing;
$y1 += $this->linespacing;
}
if( $xe-$x1 > $ye-$y0 ) {
// Width larger than height
$x1 = $this->rect->x + ($y1-$ye);
$y1 = $ye;
$y0 = $this->rect->y;
while( $x0 <= $xe ) {
$aImg->Line($x0,$y0,$x1,$y1);
$x0 += $this->linespacing;
$x1 += $this->linespacing;
}
$y0=$this->rect->y + ($x0-$xe);
$x0=$xe;
}
else {
// Height larger than width
$diff = $x0-$xe;
$y0 = $diff+$this->rect->y;
$x0 = $xe;
$x1 = $this->rect->x;
while( $y1 <= $ye ) {
$aImg->Line($x0,$y0,$x1,$y1);
$y1 += $this->linespacing;
$y0 += $this->linespacing;
}
$diff = $y1-$ye;
$y1 = $ye;
$x1 = $diff + $this->rect->x;
}
while( $y0 <= $ye ) {
$aImg->Line($x0,$y0,$x1,$y1);
$y0 += $this->linespacing;
$x1 += $this->linespacing;
}
}
}
//=====================================================================
// Class RectPatternLDiag
// Implements left diagonal pattern
//=====================================================================
class RectPatternLDiag extends RectPattern {
function __construct($aColor="black",$aWeight=1,$aLineSpacing=12) {
$this->linespacing = $aLineSpacing;
parent::__construct($aColor,$aWeight);
}
function DoPattern($aImg) {
// --------------------
// |\ \ \ \ \ |
// | \ \ \ \ \|
// | \ \ \ \ |
// |------------------|
$xe = $this->rect->xe;
$ye = $this->rect->ye;
$x0 = $this->rect->x + round($this->linespacing/2);
$y0 = $this->rect->ye;
$x1 = $this->rect->x;
$y1 = $this->rect->ye - round($this->linespacing/2);
while($x0<=$xe && $y1>=$this->rect->y) {
$aImg->Line($x0,$y0,$x1,$y1);
$x0 += $this->linespacing;
$y1 -= $this->linespacing;
}
if( $xe-$x1 > $ye-$this->rect->y ) {
// Width larger than height
$x1 = $this->rect->x + ($this->rect->y-$y1);
$y0=$ye; $y1=$this->rect->y;
while( $x0 <= $xe ) {
$aImg->Line($x0,$y0,$x1,$y1);
$x0 += $this->linespacing;
$x1 += $this->linespacing;
}
$y0=$this->rect->ye - ($x0-$xe);
$x0=$xe;
}
else {
// Height larger than width
$diff = $x0-$xe;
$y0 = $ye-$diff;
$x0 = $xe;
while( $y1 >= $this->rect->y ) {
$aImg->Line($x0,$y0,$x1,$y1);
$y0 -= $this->linespacing;
$y1 -= $this->linespacing;
}
$diff = $this->rect->y - $y1;
$x1 = $this->rect->x + $diff;
$y1 = $this->rect->y;
}
while( $y0 >= $this->rect->y ) {
$aImg->Line($x0,$y0,$x1,$y1);
$y0 -= $this->linespacing;
$x1 += $this->linespacing;
}
}
}
//=====================================================================
// Class RectPattern3DPlane
// Implements "3D" plane pattern
//=====================================================================
class RectPattern3DPlane extends RectPattern {
private $alpha=50; // Parameter that specifies the distance
// to "simulated" horizon in pixel from the
// top of the band. Specifies how fast the lines
// converge.
function __construct($aColor="black",$aWeight=1) {
parent::__construct($aColor,$aWeight);
$this->SetDensity(10); // Slightly larger default
}
function SetHorizon($aHorizon) {
$this->alpha=$aHorizon;
}
function DoPattern($aImg) {
// "Fake" a nice 3D grid-effect.
$x0 = $this->rect->x + $this->rect->w/2;
$y0 = $this->rect->y;
$x1 = $x0;
$y1 = $this->rect->ye;
$x0_right = $x0;
$x1_right = $x1;
// BTW "apa" means monkey in Swedish but is really a shortform for
// "alpha+a" which was the labels I used on paper when I derived the
// geometric to get the 3D perspective right.
// $apa is the height of the bounding rectangle plus the distance to the
// artifical horizon (alpha)
$apa = $this->rect->h + $this->alpha;
// Three cases and three loops
// 1) The endpoint of the line ends on the bottom line
// 2) The endpoint ends on the side
// 3) Horizontal lines
// Endpoint falls on bottom line
$middle=$this->rect->x + $this->rect->w/2;
$dist=$this->linespacing;
$factor=$this->alpha /($apa);
while($x1>$this->rect->x) {
$aImg->Line($x0,$y0,$x1,$y1);
$aImg->Line($x0_right,$y0,$x1_right,$y1);
$x1 = $middle - $dist;
$x0 = $middle - $dist * $factor;
$x1_right = $middle + $dist;
$x0_right = $middle + $dist * $factor;
$dist += $this->linespacing;
}
// Endpoint falls on sides
$dist -= $this->linespacing;
$d=$this->rect->w/2;
$c = $apa - $d*$apa/$dist;
while( $x0>$this->rect->x ) {
$aImg->Line($x0,$y0,$this->rect->x,$this->rect->ye-$c);
$aImg->Line($x0_right,$y0,$this->rect->xe,$this->rect->ye-$c);
$dist += $this->linespacing;
$x0 = $middle - $dist * $factor;
$x1 = $middle - $dist;
$x0_right = $middle + $dist * $factor;
$c = $apa - $d*$apa/$dist;
}
// Horizontal lines
// They need some serious consideration since they are a function
// of perspective depth (alpha) and density (linespacing)
$x0=$this->rect->x;
$x1=$this->rect->xe;
$y=$this->rect->ye;
// The first line is drawn directly. Makes the loop below slightly
// more readable.
$aImg->Line($x0,$y,$x1,$y);
$hls = $this->linespacing;
// A correction factor for vertical "brick" line spacing to account for
// a) the difference in number of pixels hor vs vert
// b) visual apperance to make the first layer of "bricks" look more
// square.
$vls = $this->linespacing*0.6;
$ds = $hls*($apa-$vls)/$apa;
// Get the slope for the "perspective line" going from bottom right
// corner to top left corner of the "first" brick.
// Uncomment the following lines if you want to get a visual understanding
// of what this helpline does. BTW this mimics the way you would get the
// perspective right when drawing on paper.
/*
$x0 = $middle;
$y0 = $this->rect->ye;
$len=floor(($this->rect->ye-$this->rect->y)/$vls);
$x1 = $middle+round($len*$ds);
$y1 = $this->rect->ye-$len*$vls;
$aImg->PushColor("red");
$aImg->Line($x0,$y0,$x1,$y1);
$aImg->PopColor();
*/
$y -= $vls;
$k=($this->rect->ye-($this->rect->ye-$vls))/($middle-($middle-$ds));
$dist = $hls;
while( $y>$this->rect->y ) {
$aImg->Line($this->rect->x,$y,$this->rect->xe,$y);
$adj = $k*$dist/(1+$dist*$k/$apa);
if( $adj < 2 ) $adj=1;
$y = $this->rect->ye - round($adj);
$dist += $hls;
}
}
}
//=====================================================================
// Class RectPatternCross
// Vert/Hor crosses
//=====================================================================
class RectPatternCross extends RectPattern {
private $vert=null;
private $hor=null;
function __construct($aColor="black",$aWeight=1) {
parent::__construct($aColor,$aWeight);
$this->vert = new RectPatternVert($aColor,$aWeight);
$this->hor = new RectPatternHor($aColor,$aWeight);
}
function SetOrder($aDepth) {
$this->vert->SetOrder($aDepth);
$this->hor->SetOrder($aDepth);
}
function SetPos($aRect) {
parent::SetPos($aRect);
$this->vert->SetPos($aRect);
$this->hor->SetPos($aRect);
}
function SetDensity($aDens) {
$this->vert->SetDensity($aDens);
$this->hor->SetDensity($aDens);
}
function DoPattern($aImg) {
$this->vert->DoPattern($aImg);
$this->hor->DoPattern($aImg);
}
}
//=====================================================================
// Class RectPatternDiagCross
// Vert/Hor crosses
//=====================================================================
class RectPatternDiagCross extends RectPattern {
private $left=null;
private $right=null;
function __construct($aColor="black",$aWeight=1) {
parent::__construct($aColor,$aWeight);
$this->right = new RectPatternRDiag($aColor,$aWeight);
$this->left = new RectPatternLDiag($aColor,$aWeight);
}
function SetOrder($aDepth) {
$this->left->SetOrder($aDepth);
$this->right->SetOrder($aDepth);
}
function SetPos($aRect) {
parent::SetPos($aRect);
$this->left->SetPos($aRect);
$this->right->SetPos($aRect);
}
function SetDensity($aDens) {
$this->left->SetDensity($aDens);
$this->right->SetDensity($aDens);
}
function DoPattern($aImg) {
$this->left->DoPattern($aImg);
$this->right->DoPattern($aImg);
}
}
//=====================================================================
// Class RectPatternFactory
// Factory class for rectangular pattern
//=====================================================================
class RectPatternFactory {
function __construct() {
// Empty
}
function Create($aPattern,$aColor,$aWeight=1) {
switch($aPattern) {
case BAND_RDIAG:
$obj = new RectPatternRDiag($aColor,$aWeight);
break;
case BAND_LDIAG:
$obj = new RectPatternLDiag($aColor,$aWeight);
break;
case BAND_SOLID:
$obj = new RectPatternSolid($aColor,$aWeight);
break;
case BAND_VLINE:
$obj = new RectPatternVert($aColor,$aWeight);
break;
case BAND_HLINE:
$obj = new RectPatternHor($aColor,$aWeight);
break;
case BAND_3DPLANE:
$obj = new RectPattern3DPlane($aColor,$aWeight);
break;
case BAND_HVCROSS:
$obj = new RectPatternCross($aColor,$aWeight);
break;
case BAND_DIAGCROSS:
$obj = new RectPatternDiagCross($aColor,$aWeight);
break;
default:
JpGraphError::RaiseL(16003,$aPattern);
//(" Unknown pattern specification ($aPattern)");
}
return $obj;
}
}
//=====================================================================
// Class PlotBand
// Factory class which is used by the client.
// It is responsible for factoring the corresponding pattern
// concrete class.
//=====================================================================
class PlotBand {
public $depth; // Determine if band should be over or under the plots
private $prect=null;
private $dir, $min, $max;
function __construct($aDir,$aPattern,$aMin,$aMax,$aColor="black",$aWeight=1,$aDepth=DEPTH_BACK) {
$f = new RectPatternFactory();
$this->prect = $f->Create($aPattern,$aColor,$aWeight);
if( is_numeric($aMin) && is_numeric($aMax) && ($aMin > $aMax) )
JpGraphError::RaiseL(16004);
//('Min value for plotband is larger than specified max value. Please correct.');
$this->dir = $aDir;
$this->min = $aMin;
$this->max = $aMax;
$this->depth=$aDepth;
}
// Set position. aRect contains absolute image coordinates
function SetPos($aRect) {
assert( $this->prect != null ) ;
$this->prect->SetPos($aRect);
}
function ShowFrame($aFlag=true) {
$this->prect->ShowFrame($aFlag);
}
// Set z-order. In front of pplot or in the back
function SetOrder($aDepth) {
$this->depth=$aDepth;
}
function SetDensity($aDens) {
$this->prect->SetDensity($aDens);
}
function GetDir() {
return $this->dir;
}
function GetMin() {
return $this->min;
}
function GetMax() {
return $this->max;
}
function PreStrokeAdjust($aGraph) {
// Nothing to do
}
// Display band
function Stroke($aImg,$aXScale,$aYScale) {
assert( $this->prect != null ) ;
if( $this->dir == HORIZONTAL ) {
if( $this->min === 'min' ) $this->min = $aYScale->GetMinVal();
if( $this->max === 'max' ) $this->max = $aYScale->GetMaxVal();
// Only draw the bar if it actually appears in the range
if ($this->min < $aYScale->GetMaxVal() && $this->max > $aYScale->GetMinVal()) {
// Trucate to limit of axis
$this->min = max($this->min, $aYScale->GetMinVal());
$this->max = min($this->max, $aYScale->GetMaxVal());
$x=$aXScale->scale_abs[0];
$y=$aYScale->Translate($this->max);
$width=$aXScale->scale_abs[1]-$aXScale->scale_abs[0]+1;
$height=abs($y-$aYScale->Translate($this->min))+1;
$this->prect->SetPos(new Rectangle($x,$y,$width,$height));
$this->prect->Stroke($aImg);
}
}
else { // VERTICAL
if( $this->min === 'min' ) $this->min = $aXScale->GetMinVal();
if( $this->max === 'max' ) $this->max = $aXScale->GetMaxVal();
// Only draw the bar if it actually appears in the range
if ($this->min < $aXScale->GetMaxVal() && $this->max > $aXScale->GetMinVal()) {
// Trucate to limit of axis
$this->min = max($this->min, $aXScale->GetMinVal());
$this->max = min($this->max, $aXScale->GetMaxVal());
$y=$aYScale->scale_abs[1];
$x=$aXScale->Translate($this->min);
$height=abs($aYScale->scale_abs[1]-$aYScale->scale_abs[0]);
$width=abs($x-$aXScale->Translate($this->max));
$this->prect->SetPos(new Rectangle($x,$y,$width,$height));
$this->prect->Stroke($aImg);
}
}
}
}
?>

View File

@ -1,162 +0,0 @@
<?php
/**
* jpgraph_plotline.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_PLOTLINE.PHP
// Description: PlotLine extension for JpGraph
// Created: 2009-03-24
// Ver: $Id: jpgraph_plotline.php 1881 2009-10-01 10:28:12Z ljp $
//
// CLASS PlotLine
// Data container class to hold properties for a static
// line that is drawn directly in the plot area.
// Useful to add static borders inside a plot to show for example set-values
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
class PlotLine {
public $scaleposition, $direction=-1;
protected $weight=1;
protected $color = 'black';
private $legend='',$hidelegend=false, $legendcsimtarget='', $legendcsimalt='',$legendcsimwintarget='';
private $iLineStyle='solid';
public $numpoints=0; // Needed since the framework expects this property
function __construct($aDir=HORIZONTAL,$aPos=0,$aColor='black',$aWeight=1) {
$this->direction = $aDir;
$this->color=$aColor;
$this->weight=$aWeight;
$this->scaleposition=$aPos;
}
function SetLegend($aLegend,$aCSIM='',$aCSIMAlt='',$aCSIMWinTarget='') {
$this->legend = $aLegend;
$this->legendcsimtarget = $aCSIM;
$this->legendcsimwintarget = $aCSIMWinTarget;
$this->legendcsimalt = $aCSIMAlt;
}
function HideLegend($f=true) {
$this->hidelegend = $f;
}
function SetPosition($aScalePosition) {
$this->scaleposition=$aScalePosition;
}
function SetDirection($aDir) {
$this->direction = $aDir;
}
function SetColor($aColor) {
$this->color=$aColor;
}
function SetWeight($aWeight) {
$this->weight=$aWeight;
}
function SetLineStyle($aStyle) {
$this->iLineStyle = $aStyle;
}
//---------------
// PRIVATE METHODS
function DoLegend($graph) {
if( !$this->hidelegend ) $this->Legend($graph);
}
// Framework function the chance for each plot class to set a legend
function Legend($aGraph) {
if( $this->legend != '' ) {
$dummyPlotMark = new PlotMark();
$lineStyle = 1;
$aGraph->legend->Add($this->legend,$this->color,$dummyPlotMark,$lineStyle,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
}
}
function PreStrokeAdjust($aGraph) {
// Nothing to do
}
// Called by framework to allow the object to draw
// optional information in the margin area
function StrokeMargin($aImg) {
// Nothing to do
}
// Framework function to allow the object to adjust the scale
function PrescaleSetup($aGraph) {
// Nothing to do
}
function Min() {
return array(null,null);
}
function Max() {
return array(null,null);
}
function _Stroke($aImg,$aMinX,$aMinY,$aMaxX,$aMaxY,$aXPos,$aYPos) {
$aImg->SetColor($this->color);
$aImg->SetLineWeight($this->weight);
$oldStyle = $aImg->SetLineStyle($this->iLineStyle);
if( $this->direction == VERTICAL ) {
$ymin_abs = $aMinY;
$ymax_abs = $aMaxY;
$xpos_abs = $aXPos;
$aImg->StyleLine($xpos_abs, $ymin_abs, $xpos_abs, $ymax_abs);
}
elseif( $this->direction == HORIZONTAL ) {
$xmin_abs = $aMinX;
$xmax_abs = $aMaxX;
$ypos_abs = $aYPos;
$aImg->StyleLine($xmin_abs, $ypos_abs, $xmax_abs, $ypos_abs);
}
else {
JpGraphError::RaiseL(25125);//(" Illegal direction for static line");
}
$aImg->SetLineStyle($oldStyle);
}
function Stroke($aImg,$aXScale,$aYScale) {
$this->_Stroke($aImg,
$aImg->left_margin,
$aYScale->Translate($aYScale->GetMinVal()),
$aImg->width-$aImg->right_margin,
$aYScale->Translate($aYScale->GetMaxVal()),
$aXScale->Translate($this->scaleposition),
$aYScale->Translate($this->scaleposition)
);
}
}
?>

View File

@ -1,528 +0,0 @@
<?php
/**
* jpgraph_plotmark.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_PLOTMARK.PHP
// Description: Class file. Handles plotmarks
// Created: 2003-03-21
// Ver: $Id: jpgraph_plotmark.inc.php 1106 2009-02-22 20:16:35Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
//===================================================
// CLASS PlotMark
// Description: Handles the plot marks in graphs
//===================================================
class PlotMark {
public $title, $show=true;
public $type,$weight=1;
public $iFormatCallback="", $iFormatCallback2="";
public $fill_color="blue";
public $color="black", $width=4;
private $yvalue,$xvalue='',$csimtarget,$csimwintarget='',$csimalt,$csimareas;
private $markimg='',$iScale=1.0;
private $oldfilename='',$iFileName='';
private $imgdata_balls = null;
private $imgdata_diamonds = null;
private $imgdata_squares = null;
private $imgdata_bevels = null;
private $imgdata_stars = null;
private $imgdata_pushpins = null;
//--------------
// CONSTRUCTOR
function __construct() {
$this->title = new Text();
$this->title->Hide();
$this->csimareas = '';
$this->type=-1;
}
//---------------
// PUBLIC METHODS
function SetType($aType,$aFileName='',$aScale=1.0) {
$this->type = $aType;
if( $aType == MARK_IMG && $aFileName=='' ) {
JpGraphError::RaiseL(23003);//('A filename must be specified if you set the mark type to MARK_IMG.');
}
$this->iFileName = $aFileName;
$this->iScale = $aScale;
}
function SetCallback($aFunc) {
$this->iFormatCallback = $aFunc;
}
function SetCallbackYX($aFunc) {
$this->iFormatCallback2 = $aFunc;
}
function GetType() {
return $this->type;
}
function SetColor($aColor) {
$this->color=$aColor;
}
function SetFillColor($aFillColor) {
$this->fill_color = $aFillColor;
}
function SetWeight($aWeight) {
$this->weight = $aWeight;
}
// Synonym for SetWidth()
function SetSize($aWidth) {
$this->width=$aWidth;
}
function SetWidth($aWidth) {
$this->width=$aWidth;
}
function SetDefaultWidth() {
switch( $this->type ) {
case MARK_CIRCLE:
case MARK_FILLEDCIRCLE:
$this->width=4;
break;
default:
$this->width=7;
}
}
function GetWidth() {
return $this->width;
}
function Hide($aHide=true) {
$this->show = !$aHide;
}
function Show($aShow=true) {
$this->show = $aShow;
}
function SetCSIMAltVal($aY,$aX='') {
$this->yvalue=$aY;
$this->xvalue=$aX;
}
function SetCSIMTarget($aTarget,$aWinTarget='') {
$this->csimtarget=$aTarget;
$this->csimwintarget=$aWinTarget;
}
function SetCSIMAlt($aAlt) {
$this->csimalt=$aAlt;
}
function GetCSIMAreas(){
return $this->csimareas;
}
function AddCSIMPoly($aPts) {
$coords = round($aPts[0]).", ".round($aPts[1]);
$n = count($aPts)/2;
for( $i=1; $i < $n; ++$i){
$coords .= ", ".round($aPts[2*$i]).", ".round($aPts[2*$i+1]);
}
$this->csimareas="";
if( !empty($this->csimtarget) ) {
$this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($this->csimtarget)."\"";
if( !empty($this->csimwintarget) ) {
$this->csimareas .= " target=\"".$this->csimwintarget."\" ";
}
if( !empty($this->csimalt) ) {
$tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue);
$this->csimareas .= " title=\"$tmp\" alt=\"$tmp\"";
}
$this->csimareas .= " />\n";
}
}
function AddCSIMCircle($x,$y,$r) {
$x = round($x); $y=round($y); $r=round($r);
$this->csimareas="";
if( !empty($this->csimtarget) ) {
$this->csimareas .= "<area shape=\"circle\" coords=\"$x,$y,$r\" href=\"".htmlentities($this->csimtarget)."\"";
if( !empty($this->csimwintarget) ) {
$this->csimareas .= " target=\"".$this->csimwintarget."\" ";
}
if( !empty($this->csimalt) ) {
$tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue);
$this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" ";
}
$this->csimareas .= " />\n";
}
}
function Stroke($img,$x,$y) {
if( !$this->show ) return;
if( $this->iFormatCallback != '' || $this->iFormatCallback2 != '' ) {
if( $this->iFormatCallback != '' ) {
$f = $this->iFormatCallback;
list($width,$color,$fcolor) = call_user_func($f,$this->yvalue);
$filename = $this->iFileName;
$imgscale = $this->iScale;
}
else {
$f = $this->iFormatCallback2;
list($width,$color,$fcolor,$filename,$imgscale) = call_user_func($f,$this->yvalue,$this->xvalue);
if( $filename=="" ) $filename = $this->iFileName;
if( $imgscale=="" ) $imgscale = $this->iScale;
}
if( $width=="" ) $width = $this->width;
if( $color=="" ) $color = $this->color;
if( $fcolor=="" ) $fcolor = $this->fill_color;
}
else {
$fcolor = $this->fill_color;
$color = $this->color;
$width = $this->width;
$filename = $this->iFileName;
$imgscale = $this->iScale;
}
if( $this->type == MARK_IMG ||
($this->type >= MARK_FLAG1 && $this->type <= MARK_FLAG4 ) ||
$this->type >= MARK_IMG_PUSHPIN ) {
// Note: For the builtin images we use the "filename" parameter
// to denote the color
$anchor_x = 0.5;
$anchor_y = 0.5;
switch( $this->type ) {
case MARK_FLAG1:
case MARK_FLAG2:
case MARK_FLAG3:
case MARK_FLAG4:
$this->markimg = FlagCache::GetFlagImgByName($this->type-MARK_FLAG1+1,$filename);
break;
case MARK_IMG :
// Load an image and use that as a marker
// Small optimization, if we have already read an image don't
// waste time reading it again.
if( $this->markimg == '' || !($this->oldfilename === $filename) ) {
$this->markimg = Graph::LoadBkgImage('',$filename);
$this->oldfilename = $filename ;
}
break;
case MARK_IMG_PUSHPIN:
case MARK_IMG_SPUSHPIN:
case MARK_IMG_LPUSHPIN:
if( $this->imgdata_pushpins == null ) {
require_once 'imgdata_pushpins.inc.php';
$this->imgdata_pushpins = new ImgData_PushPins();
}
$this->markimg = $this->imgdata_pushpins->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_pushpins->GetAnchor();
break;
case MARK_IMG_SQUARE:
if( $this->imgdata_squares == null ) {
require_once 'imgdata_squares.inc.php';
$this->imgdata_squares = new ImgData_Squares();
}
$this->markimg = $this->imgdata_squares->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_squares->GetAnchor();
break;
case MARK_IMG_STAR:
if( $this->imgdata_stars == null ) {
require_once 'imgdata_stars.inc.php';
$this->imgdata_stars = new ImgData_Stars();
}
$this->markimg = $this->imgdata_stars->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_stars->GetAnchor();
break;
case MARK_IMG_BEVEL:
if( $this->imgdata_bevels == null ) {
require_once 'imgdata_bevels.inc.php';
$this->imgdata_bevels = new ImgData_Bevels();
}
$this->markimg = $this->imgdata_bevels->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_bevels->GetAnchor();
break;
case MARK_IMG_DIAMOND:
if( $this->imgdata_diamonds == null ) {
require_once 'imgdata_diamonds.inc.php';
$this->imgdata_diamonds = new ImgData_Diamonds();
}
$this->markimg = $this->imgdata_diamonds->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_diamonds->GetAnchor();
break;
case MARK_IMG_BALL:
case MARK_IMG_SBALL:
case MARK_IMG_MBALL:
case MARK_IMG_LBALL:
if( $this->imgdata_balls == null ) {
require_once 'imgdata_balls.inc.php';
$this->imgdata_balls = new ImgData_Balls();
}
$this->markimg = $this->imgdata_balls->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_balls->GetAnchor();
break;
}
$w = $img->GetWidth($this->markimg);
$h = $img->GetHeight($this->markimg);
$dw = round($imgscale * $w );
$dh = round($imgscale * $h );
// Do potential rotation
list($x,$y) = $img->Rotate($x,$y);
$dx = round($x-$dw*$anchor_x);
$dy = round($y-$dh*$anchor_y);
$this->width = max($dx,$dy);
$img->Copy($this->markimg,$dx,$dy,0,0,$dw,$dh,$w,$h);
if( !empty($this->csimtarget) ) {
$this->csimareas = "<area shape=\"rect\" coords=\"".
$dx.','.$dy.','.round($dx+$dw).','.round($dy+$dh).'" '.
"href=\"".htmlentities($this->csimtarget)."\"";
if( !empty($this->csimwintarget) ) {
$this->csimareas .= " target=\"".$this->csimwintarget."\" ";
}
if( !empty($this->csimalt) ) {
$tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue);
$this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" ";
}
$this->csimareas .= " />\n";
}
// Stroke title
$this->title->Align("center","top");
$this->title->Stroke($img,$x,$y+round($dh/2));
return;
}
$weight = $this->weight;
$dx=round($width/2,0);
$dy=round($width/2,0);
$pts=0;
switch( $this->type ) {
case MARK_SQUARE:
$c[]=$x-$dx;$c[]=$y-$dy;
$c[]=$x+$dx;$c[]=$y-$dy;
$c[]=$x+$dx;$c[]=$y+$dy;
$c[]=$x-$dx;$c[]=$y+$dy;
$c[]=$x-$dx;$c[]=$y-$dy;
$pts=5;
break;
case MARK_UTRIANGLE:
++$dx;++$dy;
$c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
$c[]=$x;$c[]=$y-0.87*$dy;
$c[]=$x+$dx;$c[]=$y+0.87*$dy;
$c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
$pts=4;
break;
case MARK_DTRIANGLE:
++$dx;++$dy;
$c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
$c[]=$x-$dx;$c[]=$y-0.87*$dy;
$c[]=$x+$dx;$c[]=$y-0.87*$dy;
$c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
$pts=4;
break;
case MARK_DIAMOND:
$c[]=$x;$c[]=$y+$dy;
$c[]=$x-$dx;$c[]=$y;
$c[]=$x;$c[]=$y-$dy;
$c[]=$x+$dx;$c[]=$y;
$c[]=$x;$c[]=$y+$dy;
$pts=5;
break;
case MARK_LEFTTRIANGLE:
$c[]=$x;$c[]=$y;
$c[]=$x;$c[]=$y+2*$dy;
$c[]=$x+$dx*2;$c[]=$y;
$c[]=$x;$c[]=$y;
$pts=4;
break;
case MARK_RIGHTTRIANGLE:
$c[]=$x-$dx*2;$c[]=$y;
$c[]=$x;$c[]=$y+2*$dy;
$c[]=$x;$c[]=$y;
$c[]=$x-$dx*2;$c[]=$y;
$pts=4;
break;
case MARK_FLASH:
$dy *= 2;
$c[]=$x+$dx/2; $c[]=$y-$dy;
$c[]=$x-$dx+$dx/2; $c[]=$y+$dy*0.7-$dy;
$c[]=$x+$dx/2; $c[]=$y+$dy*1.3-$dy;
$c[]=$x-$dx+$dx/2; $c[]=$y+2*$dy-$dy;
$img->SetLineWeight($weight);
$img->SetColor($color);
$img->Polygon($c);
$img->SetLineWeight(1);
$this->AddCSIMPoly($c);
break;
}
if( $pts>0 ) {
$this->AddCSIMPoly($c);
$img->SetLineWeight($weight);
$img->SetColor($fcolor);
$img->FilledPolygon($c);
$img->SetColor($color);
$img->Polygon($c);
$img->SetLineWeight(1);
}
elseif( $this->type==MARK_CIRCLE ) {
$img->SetColor($color);
$img->Circle($x,$y,$width);
$this->AddCSIMCircle($x,$y,$width);
}
elseif( $this->type==MARK_FILLEDCIRCLE ) {
$img->SetColor($fcolor);
$img->FilledCircle($x,$y,$width);
$img->SetColor($color);
$img->Circle($x,$y,$width);
$this->AddCSIMCircle($x,$y,$width);
}
elseif( $this->type==MARK_CROSS ) {
// Oversize by a pixel to match the X
$img->SetColor($color);
$img->SetLineWeight($weight);
$img->Line($x,$y+$dy+1,$x,$y-$dy-1);
$img->Line($x-$dx-1,$y,$x+$dx+1,$y);
$this->AddCSIMCircle($x,$y,$dx);
}
elseif( $this->type==MARK_X ) {
$img->SetColor($color);
$img->SetLineWeight($weight);
$img->Line($x+$dx,$y+$dy,$x-$dx,$y-$dy);
$img->Line($x-$dx,$y+$dy,$x+$dx,$y-$dy);
$this->AddCSIMCircle($x,$y,$dx+$dy);
}
elseif( $this->type==MARK_STAR ) {
$img->SetColor($color);
$img->SetLineWeight($weight);
$img->Line($x+$dx,$y+$dy,$x-$dx,$y-$dy);
$img->Line($x-$dx,$y+$dy,$x+$dx,$y-$dy);
// Oversize by a pixel to match the X
$img->Line($x,$y+$dy+1,$x,$y-$dy-1);
$img->Line($x-$dx-1,$y,$x+$dx+1,$y);
$this->AddCSIMCircle($x,$y,$dx+$dy);
}
// Stroke title
$this->title->Align("center","center");
$this->title->Stroke($img,$x,$y);
}
} // Class
//========================================================================
// CLASS ImgData
// Description: Base class for all image data classes that contains the
// real image data.
//========================================================================
class ImgData {
protected $name = ''; // Each subclass gives a name
protected $an = array(); // Data array names
protected $colors = array(); // Available colors
protected $index = array(); // Index for colors
protected $maxidx = 0 ; // Max color index
protected $anchor_x=0.5, $anchor_y=0.5 ; // Where is the center of the image
function __construct() {
// Empty
}
// Create a GD image from the data and return a GD handle
function GetImg($aMark,$aIdx) {
$n = $this->an[$aMark];
if( is_string($aIdx) ) {
if( !in_array($aIdx,$this->colors) ) {
JpGraphError::RaiseL(23001,$this->name,$aIdx);//('This marker "'.($this->name).'" does not exist in color: '.$aIdx);
}
$idx = $this->index[$aIdx];
}
elseif( !is_integer($aIdx) ||
(is_integer($aIdx) && $aIdx > $this->maxidx ) ) {
JpGraphError::RaiseL(23002,$this->name);//('Mark color index too large for marker "'.($this->name).'"');
}
else
$idx = $aIdx ;
return Image::CreateFromString(base64_decode($this->{$n}[$idx][1]));
}
function GetAnchor() {
return array($this->anchor_x,$this->anchor_y);
}
}
// Keep a global flag cache to reduce memory usage
$_gFlagCache=array(
1 => null,
2 => null,
3 => null,
4 => null,
);
// Only supposed to b called as statics
class FlagCache {
static function GetFlagImgByName($aSize,$aName) {
global $_gFlagCache;
require_once('jpgraph_flags.php');
if( $_gFlagCache[$aSize] === null ) {
$_gFlagCache[$aSize] = new FlagImages($aSize);
}
$f = $_gFlagCache[$aSize];
$idx = $f->GetIdxByName($aName,$aFullName);
return $f->GetImgByIdx($idx);
}
}
?>

View File

@ -1,921 +0,0 @@
<?php
/**
* jpgraph_polar.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_POLAR.PHP
// Description: Polar plot extension for JpGraph
// Created: 2003-02-02
// Ver: $Id: jpgraph_polar.php 1796 2009-09-07 09:37:19Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once ('jpgraph_plotmark.inc.php');
require_once "jpgraph_log.php";
define('POLAR_360',1);
define('POLAR_180',2);
//
// Note. Don't attempt to make sense of this code.
// In order not to have to be able to inherit the scaling code
// from the main graph package we have had to make some "tricks" since
// the original scaling and axis was not designed to do what is
// required here.
// There were two option. 1: Re-implement everything and get a clean design
// and 2: do some "small" trickery and be able to inherit most of
// the functionlity from the main graph package.
// We choose 2: here in order to save some time.
//
//--------------------------------------------------------------------------
// class PolarPlot
//--------------------------------------------------------------------------
class PolarPlot {
public $line_style='solid',$mark;
public $legendcsimtarget='';
public $legendcsimalt='';
public $legend="";
public $csimtargets=array(); // Array of targets for CSIM
public $csimareas=""; // Resultant CSIM area tags
public $csimalts=null; // ALT:s for corresponding target
public $scale=null;
private $numpoints=0;
private $iColor='navy',$iFillColor='';
private $iLineWeight=1;
private $coord=null;
function __construct($aData) {
$n = count($aData);
if( $n & 1 ) {
JpGraphError::RaiseL(17001);
//('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).');
}
$this->numpoints = $n/2;
$this->coord = $aData;
$this->mark = new PlotMark();
}
function SetWeight($aWeight) {
$this->iLineWeight = $aWeight;
}
function SetColor($aColor){
$this->iColor = $aColor;
}
function SetFillColor($aColor){
$this->iFillColor = $aColor;
}
function Max() {
$m = $this->coord[1];
$i=1;
while( $i < $this->numpoints ) {
$m = max($m,$this->coord[2*$i+1]);
++$i;
}
return $m;
}
// Set href targets for CSIM
function SetCSIMTargets($aTargets,$aAlts=null) {
$this->csimtargets=$aTargets;
$this->csimalts=$aAlts;
}
// Get all created areas
function GetCSIMareas() {
return $this->csimareas;
}
function SetLegend($aLegend,$aCSIM="",$aCSIMAlt="") {
$this->legend = $aLegend;
$this->legendcsimtarget = $aCSIM;
$this->legendcsimalt = $aCSIMAlt;
}
// Private methods
function Legend($aGraph) {
$color = $this->iColor ;
if( $this->legend != "" ) {
if( $this->iFillColor!='' ) {
$color = $this->iFillColor;
$aGraph->legend->Add($this->legend,$color,$this->mark,0,
$this->legendcsimtarget,$this->legendcsimalt);
}
else {
$aGraph->legend->Add($this->legend,$color,$this->mark,$this->line_style,
$this->legendcsimtarget,$this->legendcsimalt);
}
}
}
function Stroke($img,$scale) {
$i=0;
$p=array();
$this->csimareas='';
while($i < $this->numpoints) {
list($x1,$y1) = $scale->PTranslate($this->coord[2*$i],$this->coord[2*$i+1]);
$p[2*$i] = $x1;
$p[2*$i+1] = $y1;
if( isset($this->csimtargets[$i]) ) {
$this->mark->SetCSIMTarget($this->csimtargets[$i]);
$this->mark->SetCSIMAlt($this->csimalts[$i]);
$this->mark->SetCSIMAltVal($this->coord[2*$i], $this->coord[2*$i+1]);
$this->mark->Stroke($img,$x1,$y1);
$this->csimareas .= $this->mark->GetCSIMAreas();
}
else {
$this->mark->Stroke($img,$x1,$y1);
}
++$i;
}
if( $this->iFillColor != '' ) {
$img->SetColor($this->iFillColor);
$img->FilledPolygon($p);
}
$img->SetLineWeight($this->iLineWeight);
$img->SetColor($this->iColor);
$img->Polygon($p,$this->iFillColor!='');
}
}
//--------------------------------------------------------------------------
// class PolarAxis
//--------------------------------------------------------------------------
class PolarAxis extends Axis {
private $angle_step=15,$angle_color='lightgray',$angle_label_color='black';
private $angle_fontfam=FF_FONT1,$angle_fontstyle=FS_NORMAL,$angle_fontsize=10;
private $angle_fontcolor = 'navy';
private $gridminor_color='lightgray',$gridmajor_color='lightgray';
private $show_minor_grid = false, $show_major_grid = true ;
private $show_angle_mark=true, $show_angle_grid=true, $show_angle_label=true;
private $angle_tick_len=3, $angle_tick_len2=3, $angle_tick_color='black';
private $show_angle_tick=true;
private $radius_tick_color='black';
function __construct($img,$aScale) {
parent::__construct($img,$aScale);
}
function ShowAngleDegreeMark($aFlg=true) {
$this->show_angle_mark = $aFlg;
}
function SetAngleStep($aStep) {
$this->angle_step=$aStep;
}
function HideTicks($aFlg=true,$aAngleFlg=true) {
parent::HideTicks($aFlg,$aFlg);
$this->show_angle_tick = !$aAngleFlg;
}
function ShowAngleLabel($aFlg=true) {
$this->show_angle_label = $aFlg;
}
function ShowGrid($aMajor=true,$aMinor=false,$aAngle=true) {
$this->show_minor_grid = $aMinor;
$this->show_major_grid = $aMajor;
$this->show_angle_grid = $aAngle ;
}
function SetAngleFont($aFontFam,$aFontStyle=FS_NORMAL,$aFontSize=10) {
$this->angle_fontfam = $aFontFam;
$this->angle_fontstyle = $aFontStyle;
$this->angle_fontsize = $aFontSize;
}
function SetColor($aColor,$aRadColor='',$aAngleColor='') {
if( $aAngleColor == '' )
$aAngleColor=$aColor;
parent::SetColor($aColor,$aRadColor);
$this->angle_fontcolor = $aAngleColor;
}
function SetGridColor($aMajorColor,$aMinorColor='',$aAngleColor='') {
if( $aMinorColor == '' )
$aMinorColor = $aMajorColor;
if( $aAngleColor == '' )
$aAngleColor = $aMajorColor;
$this->gridminor_color = $aMinorColor;
$this->gridmajor_color = $aMajorColor;
$this->angle_color = $aAngleColor;
}
function SetTickColors($aRadColor,$aAngleColor='') {
$this->radius_tick_color = $aRadColor;
$this->angle_tick_color = $aAngleColor;
}
// Private methods
function StrokeGrid($pos) {
$x = round($this->img->left_margin + $this->img->plotwidth/2);
$this->scale->ticks->Stroke($this->img,$this->scale,$pos);
// Stroke the minor arcs
$pmin = array();
$p = $this->scale->ticks->ticks_pos;
$n = count($p);
$i = 0;
$this->img->SetColor($this->gridminor_color);
while( $i < $n ) {
$r = $p[$i]-$x+1;
$pmin[]=$r;
if( $this->show_minor_grid ) {
$this->img->Circle($x,$pos,$r);
}
$i++;
}
$limit = max($this->img->plotwidth,$this->img->plotheight)*1.4 ;
while( $r < $limit ) {
$off = $r;
$i=1;
$r = $off + round($p[$i]-$x+1);
while( $r < $limit && $i < $n ) {
$r = $off+$p[$i]-$x;
$pmin[]=$r;
if( $this->show_minor_grid ) {
$this->img->Circle($x,$pos,$r);
}
$i++;
}
}
// Stroke the major arcs
if( $this->show_major_grid ) {
// First determine how many minor step on
// every major step. We have recorded the minor radius
// in pmin and use these values. This is done in order
// to avoid rounding errors if we were to recalculate the
// different major radius.
$pmaj = $this->scale->ticks->maj_ticks_pos;
$p = $this->scale->ticks->ticks_pos;
if( $this->scale->name == 'lin' ) {
$step=round(($pmaj[1] - $pmaj[0])/($p[1] - $p[0]));
}
else {
$step=9;
}
$n = round(count($pmin)/$step);
$i = 0;
$this->img->SetColor($this->gridmajor_color);
$limit = max($this->img->plotwidth,$this->img->plotheight)*1.4 ;
$off = $r;
$i=0;
$r = $pmin[$i*$step];
while( $r < $limit && $i < $n ) {
$r = $pmin[$i*$step];
$this->img->Circle($x,$pos,$r);
$i++;
}
}
// Draw angles
if( $this->show_angle_grid ) {
$this->img->SetColor($this->angle_color);
$d = max($this->img->plotheight,$this->img->plotwidth)*1.4 ;
$a = 0;
$p = $this->scale->ticks->ticks_pos;
$start_radius = $p[1]-$x;
while( $a < 360 ) {
if( $a == 90 || $a == 270 ) {
// Make sure there are no rounding problem with
// exactly vertical lines
$this->img->Line($x+$start_radius*cos($a/180*M_PI)+1,
$pos-$start_radius*sin($a/180*M_PI),
$x+$start_radius*cos($a/180*M_PI)+1,
$pos-$d*sin($a/180*M_PI));
}
else {
$this->img->Line($x+$start_radius*cos($a/180*M_PI)+1,
$pos-$start_radius*sin($a/180*M_PI),
$x+$d*cos($a/180*M_PI),
$pos-$d*sin($a/180*M_PI));
}
$a += $this->angle_step;
}
}
}
function StrokeAngleLabels($pos,$type) {
if( !$this->show_angle_label )
return;
$x0 = round($this->img->left_margin+$this->img->plotwidth/2)+1;
$d = max($this->img->plotwidth,$this->img->plotheight)*1.42;
$a = $this->angle_step;
$t = new Text();
$t->SetColor($this->angle_fontcolor);
$t->SetFont($this->angle_fontfam,$this->angle_fontstyle,$this->angle_fontsize);
$xright = $this->img->width - $this->img->right_margin;
$ytop = $this->img->top_margin;
$xleft = $this->img->left_margin;
$ybottom = $this->img->height - $this->img->bottom_margin;
$ha = 'left';
$va = 'center';
$w = $this->img->plotwidth/2;
$h = $this->img->plotheight/2;
$xt = $x0; $yt = $pos;
$margin=5;
$tl = $this->angle_tick_len ; // Outer len
$tl2 = $this->angle_tick_len2 ; // Interior len
$this->img->SetColor($this->angle_tick_color);
$rot90 = $this->img->a == 90 ;
if( $type == POLAR_360 ) {
// Corner angles of the four corners
$ca1 = atan($h/$w)/M_PI*180;
$ca2 = 180-$ca1;
$ca3 = $ca1+180;
$ca4 = 360-$ca1;
$end = 360;
while( $a < $end ) {
$ca = cos($a/180*M_PI);
$sa = sin($a/180*M_PI);
$x = $d*$ca;
$y = $d*$sa;
$xt=1000;$yt=1000;
if( $a <= $ca1 || $a >= $ca4 ) {
$yt = $pos - $w * $y/$x;
$xt = $xright + $margin;
if( $rot90 ) {
$ha = 'center';
$va = 'top';
}
else {
$ha = 'left';
$va = 'center';
}
$x1=$xright-$tl2; $x2=$xright+$tl;
$y1=$y2=$yt;
}
elseif( $a > $ca1 && $a < $ca2 ) {
$xt = $x0 + $h * $x/$y;
$yt = $ytop - $margin;
if( $rot90 ) {
$ha = 'left';
$va = 'center';
}
else {
$ha = 'center';
$va = 'bottom';
}
$y1=$ytop+$tl2;$y2=$ytop-$tl;
$x1=$x2=$xt;
}
elseif( $a >= $ca2 && $a <= $ca3 ) {
$yt = $pos + $w * $y/$x;
$xt = $xleft - $margin;
if( $rot90 ) {
$ha = 'center';
$va = 'bottom';
}
else {
$ha = 'right';
$va = 'center';
}
$x1=$xleft+$tl2;$x2=$xleft-$tl;
$y1=$y2=$yt;
}
else {
$xt = $x0 - $h * $x/$y;
$yt = $ybottom + $margin;
if( $rot90 ) {
$ha = 'right';
$va = 'center';
}
else {
$ha = 'center';
$va = 'top';
}
$y1=$ybottom-$tl2;$y2=$ybottom+$tl;
$x1=$x2=$xt;
}
if( $a != 0 && $a != 180 ) {
$t->Align($ha,$va);
if( $this->scale->clockwise ) {
$t->Set(360-$a);
}
else {
$t->Set($a);
}
if( $this->show_angle_mark && $t->font_family > 4 ) {
$a .= SymChar::Get('degree');
}
$t->Stroke($this->img,$xt,$yt);
if( $this->show_angle_tick ) {
$this->img->Line($x1,$y1,$x2,$y2);
}
}
$a += $this->angle_step;
}
}
else {
// POLAR_HALF
$ca1 = atan($h/$w*2)/M_PI*180;
$ca2 = 180-$ca1;
$end = 180;
while( $a < $end ) {
$ca = cos($a/180*M_PI);
$sa = sin($a/180*M_PI);
$x = $d*$ca;
$y = $d*$sa;
if( $a <= $ca1 ) {
$yt = $pos - $w * $y/$x;
$xt = $xright + $margin;
if( $rot90 ) {
$ha = 'center';
$va = 'top';
}
else {
$ha = 'left';
$va = 'center';
}
$x1=$xright-$tl2; $x2=$xright+$tl;
$y1=$y2=$yt;
}
elseif( $a > $ca1 && $a < $ca2 ) {
$xt = $x0 + 2*$h * $x/$y;
$yt = $ytop - $margin;
if( $rot90 ) {
$ha = 'left';
$va = 'center';
}
else {
$ha = 'center';
$va = 'bottom';
}
$y1=$ytop+$tl2;$y2=$ytop-$tl;
$x1=$x2=$xt;
}
elseif( $a >= $ca2 ) {
$yt = $pos + $w * $y/$x;
$xt = $xleft - $margin;
if( $rot90 ) {
$ha = 'center';
$va = 'bottom';
}
else {
$ha = 'right';
$va = 'center';
}
$x1=$xleft+$tl2;$x2=$xleft-$tl;
$y1=$y2=$yt;
}
$t->Align($ha,$va);
if( $this->show_angle_mark && $t->font_family > 4 ) {
$a .= SymChar::Get('degree');
}
$t->Set($a);
$t->Stroke($this->img,$xt,$yt);
if( $this->show_angle_tick ) {
$this->img->Line($x1,$y1,$x2,$y2);
}
$a += $this->angle_step;
}
}
}
function Stroke($pos,$dummy=true) {
$this->img->SetLineWeight($this->weight);
$this->img->SetColor($this->color);
$this->img->SetFont($this->font_family,$this->font_style,$this->font_size);
if( !$this->hide_line ) {
$this->img->FilledRectangle($this->img->left_margin,$pos,
$this->img->width-$this->img->right_margin,
$pos+$this->weight-1);
}
$y=$pos+$this->img->GetFontHeight()+$this->title_margin+$this->title->margin;
if( $this->title_adjust=="high" ) {
$this->title->SetPos($this->img->width-$this->img->right_margin,$y,"right","top");
}
elseif( $this->title_adjust=="middle" || $this->title_adjust=="center" ) {
$this->title->SetPos(($this->img->width-$this->img->left_margin-$this->img->right_margin)/2+$this->img->left_margin,
$y,"center","top");
}
elseif($this->title_adjust=="low") {
$this->title->SetPos($this->img->left_margin,$y,"left","top");
}
else {
JpGraphError::RaiseL(17002,$this->title_adjust);
//('Unknown alignment specified for X-axis title. ('.$this->title_adjust.')');
}
if (!$this->hide_labels) {
$this->StrokeLabels($pos,false);
}
$this->img->SetColor($this->radius_tick_color);
$this->scale->ticks->Stroke($this->img,$this->scale,$pos);
//
// Mirror the positions for the left side of the scale
//
$mid = 2*($this->img->left_margin+$this->img->plotwidth/2);
$n = count($this->scale->ticks->ticks_pos);
$i=0;
while( $i < $n ) {
$this->scale->ticks->ticks_pos[$i] =
$mid-$this->scale->ticks->ticks_pos[$i] ;
++$i;
}
$n = count($this->scale->ticks->maj_ticks_pos);
$i=0;
while( $i < $n ) {
$this->scale->ticks->maj_ticks_pos[$i] =
$mid-$this->scale->ticks->maj_ticks_pos[$i] ;
++$i;
}
$n = count($this->scale->ticks->maj_ticklabels_pos);
$i=1;
while( $i < $n ) {
$this->scale->ticks->maj_ticklabels_pos[$i] =
$mid-$this->scale->ticks->maj_ticklabels_pos[$i] ;
++$i;
}
// Draw the left side of the scale
$n = count($this->scale->ticks->ticks_pos);
$yu = $pos - $this->scale->ticks->direction*$this->scale->ticks->GetMinTickAbsSize();
// Minor ticks
if( ! $this->scale->ticks->supress_minor_tickmarks ) {
$i=1;
while( $i < $n/2 ) {
$x = round($this->scale->ticks->ticks_pos[$i]) ;
$this->img->Line($x,$pos,$x,$yu);
++$i;
}
}
$n = count($this->scale->ticks->maj_ticks_pos);
$yu = $pos - $this->scale->ticks->direction*$this->scale->ticks->GetMajTickAbsSize();
// Major ticks
if( ! $this->scale->ticks->supress_tickmarks ) {
$i=1;
while( $i < $n/2 ) {
$x = round($this->scale->ticks->maj_ticks_pos[$i]) ;
$this->img->Line($x,$pos,$x,$yu);
++$i;
}
}
if (!$this->hide_labels) {
$this->StrokeLabels($pos,false);
}
$this->title->Stroke($this->img);
}
}
class PolarScale extends LinearScale {
private $graph;
public $clockwise=false;
function __construct($aMax,$graph,$aClockwise) {
parent::__construct(0,$aMax,'x');
$this->graph = $graph;
$this->clockwise = $aClockwise;
}
function SetClockwise($aFlg) {
$this->clockwise = $aFlg;
}
function _Translate($v) {
return parent::Translate($v);
}
function PTranslate($aAngle,$aRad) {
$m = $this->scale[1];
$w = $this->graph->img->plotwidth/2;
$aRad = $aRad/$m*$w;
$a = $aAngle/180 * M_PI;
if( $this->clockwise ) {
$a = 2*M_PI-$a;
}
$x = cos($a) * $aRad;
$y = sin($a) * $aRad;
$x += $this->_Translate(0);
if( $this->graph->iType == POLAR_360 ) {
$y = ($this->graph->img->top_margin + $this->graph->img->plotheight/2) - $y;
}
else {
$y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y;
}
return array($x,$y);
}
}
class PolarLogScale extends LogScale {
private $graph;
public $clockwise=false;
function __construct($aMax,$graph,$aClockwise=false) {
parent::__construct(0,$aMax,'x');
$this->graph = $graph;
$this->ticks->SetLabelLogType(LOGLABELS_MAGNITUDE);
$this->clockwise = $aClockwise;
}
function SetClockwise($aFlg) {
$this->clockwise = $aFlg;
}
function PTranslate($aAngle,$aRad) {
if( $aRad == 0 )
$aRad = 1;
$aRad = log10($aRad);
$m = $this->scale[1];
$w = $this->graph->img->plotwidth/2;
$aRad = $aRad/$m*$w;
$a = $aAngle/180 * M_PI;
if( $this->clockwise ) {
$a = 2*M_PI-$a;
}
$x = cos( $a ) * $aRad;
$y = sin( $a ) * $aRad;
$x += $w+$this->graph->img->left_margin;//$this->_Translate(0);
if( $this->graph->iType == POLAR_360 ) {
$y = ($this->graph->img->top_margin + $this->graph->img->plotheight/2) - $y;
}
else {
$y = ($this->graph->img->top_margin + $this->graph->img->plotheight) - $y;
}
return array($x,$y);
}
}
class PolarGraph extends Graph {
public $scale;
public $axis;
public $iType=POLAR_360;
private $iClockwise=false;
function __construct($aWidth=300,$aHeight=200,$aCachedName="",$aTimeOut=0,$aInline=true) {
parent::__construct($aWidth,$aHeight,$aCachedName,$aTimeOut,$aInline) ;
$this->SetDensity(TICKD_DENSE);
$this->SetBox();
$this->SetMarginColor('white');
}
function SetDensity($aDense) {
$this->SetTickDensity(TICKD_NORMAL,$aDense);
}
function SetClockwise($aFlg) {
$this->scale->SetClockwise($aFlg);
}
function Set90AndMargin($lm=0,$rm=0,$tm=0,$bm=0) {
$adj = ($this->img->height - $this->img->width)/2;
$this->SetAngle(90);
$lm2 = -$adj + ($lm-$rm+$tm+$bm)/2;
$rm2 = -$adj + (-$lm+$rm+$tm+$bm)/2;
$tm2 = $adj + ($tm-$bm+$lm+$rm)/2;
$bm2 = $adj + (-$tm+$bm+$lm+$rm)/2;
$this->SetMargin($lm2, $rm2, $tm2, $bm2);
$this->axis->SetLabelAlign('right','center');
}
function SetScale($aScale,$rmax=0,$dummy1=1,$dummy2=1,$dummy3=1) {
if( $aScale == 'lin' ) {
$this->scale = new PolarScale($rmax,$this,$this->iClockwise);
}
elseif( $aScale == 'log' ) {
$this->scale = new PolarLogScale($rmax,$this,$this->iClockwise);
}
else {
JpGraphError::RaiseL(17004);//('Unknown scale type for polar graph. Must be "lin" or "log"');
}
$this->axis = new PolarAxis($this->img,$this->scale);
$this->SetMargin(40,40,50,40);
}
function SetType($aType) {
$this->iType = $aType;
}
function SetPlotSize($w,$h) {
$this->SetMargin(($this->img->width-$w)/2,($this->img->width-$w)/2,
($this->img->height-$h)/2,($this->img->height-$h)/2);
}
// Private methods
function GetPlotsMax() {
$n = count($this->plots);
$m = $this->plots[0]->Max();
$i=1;
while($i < $n) {
$m = max($this->plots[$i]->Max(),$m);
++$i;
}
return $m;
}
function Stroke($aStrokeFileName="") {
// Start by adjusting the margin so that potential titles will fit.
$this->AdjustMarginsForTitles();
// If the filename is the predefined value = '_csim_special_'
// we assume that the call to stroke only needs to do enough
// to correctly generate the CSIM maps.
// We use this variable to skip things we don't strictly need
// to do to generate the image map to improve performance
// a best we can. Therefor you will see a lot of tests !$_csim in the
// code below.
$_csim = ($aStrokeFileName===_CSIM_SPECIALFILE);
// We need to know if we have stroked the plot in the
// GetCSIMareas. Otherwise the CSIM hasn't been generated
// and in the case of GetCSIM called before stroke to generate
// CSIM without storing an image to disk GetCSIM must call Stroke.
$this->iHasStroked = true;
//Check if we should autoscale axis
if( !$this->scale->IsSpecified() && count($this->plots)>0 ) {
$max = $this->GetPlotsMax();
$t1 = $this->img->plotwidth;
$this->img->plotwidth /= 2;
$t2 = $this->img->left_margin;
$this->img->left_margin += $this->img->plotwidth+1;
$this->scale->AutoScale($this->img,0,$max,
$this->img->plotwidth/$this->xtick_factor/2);
$this->img->plotwidth = $t1;
$this->img->left_margin = $t2;
}
else {
// The tick calculation will use the user suplied min/max values to determine
// the ticks. If auto_ticks is false the exact user specifed min and max
// values will be used for the scale.
// If auto_ticks is true then the scale might be slightly adjusted
// so that the min and max values falls on an even major step.
//$min = 0;
$max = $this->scale->scale[1];
$t1 = $this->img->plotwidth;
$this->img->plotwidth /= 2;
$t2 = $this->img->left_margin;
$this->img->left_margin += $this->img->plotwidth+1;
$this->scale->AutoScale($this->img,0,$max,
$this->img->plotwidth/$this->xtick_factor/2);
$this->img->plotwidth = $t1;
$this->img->left_margin = $t2;
}
if( $this->iType == POLAR_180 ) {
$pos = $this->img->height - $this->img->bottom_margin;
}
else {
$pos = $this->img->plotheight/2 + $this->img->top_margin;
}
if( !$_csim ) {
$this->StrokePlotArea();
}
$this->iDoClipping = true;
if( $this->iDoClipping ) {
$oldimage = $this->img->CloneCanvasH();
}
if( !$_csim ) {
$this->axis->StrokeGrid($pos);
}
// Stroke all plots for Y1 axis
for($i=0; $i < count($this->plots); ++$i) {
$this->plots[$i]->Stroke($this->img,$this->scale);
}
if( $this->iDoClipping ) {
// Clipping only supports graphs at 0 and 90 degrees
if( $this->img->a == 0 ) {
$this->img->CopyCanvasH($oldimage,$this->img->img,
$this->img->left_margin,$this->img->top_margin,
$this->img->left_margin,$this->img->top_margin,
$this->img->plotwidth+1,$this->img->plotheight+1);
}
elseif( $this->img->a == 90 ) {
$adj1 = round(($this->img->height - $this->img->width)/2);
$adj2 = round(($this->img->width - $this->img->height)/2);
$lm = $this->img->left_margin;
$rm = $this->img->right_margin;
$tm = $this->img->top_margin;
$bm = $this->img->bottom_margin;
$this->img->CopyCanvasH($oldimage,$this->img->img,
$adj2 + round(($lm-$rm+$tm+$bm)/2),
$adj1 + round(($tm-$bm+$lm+$rm)/2),
$adj2 + round(($lm-$rm+$tm+$bm)/2),
$adj1 + round(($tm-$bm+$lm+$rm)/2),
$this->img->plotheight+1,
$this->img->plotwidth+1);
}
$this->img->Destroy();
$this->img->SetCanvasH($oldimage);
}
if( !$_csim ) {
$this->axis->Stroke($pos);
$this->axis->StrokeAngleLabels($pos,$this->iType);
}
if( !$_csim ) {
$this->StrokePlotBox();
$this->footer->Stroke($this->img);
// The titles and legends never gets rotated so make sure
// that the angle is 0 before stroking them
$aa = $this->img->SetAngle(0);
$this->StrokeTitles();
}
for($i=0; $i < count($this->plots) ; ++$i ) {
$this->plots[$i]->Legend($this);
}
$this->legend->Stroke($this->img);
if( !$_csim ) {
$this->StrokeTexts();
$this->img->SetAngle($aa);
// Draw an outline around the image map
if(_JPG_DEBUG)
$this->DisplayClientSideaImageMapAreas();
// If the filename is given as the special "__handle"
// then the image handler is returned and the image is NOT
// streamed back
if( $aStrokeFileName == _IMG_HANDLER ) {
return $this->img->img;
}
else {
// Finally stream the generated picture
$this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName);
}
}
}
}
?>

View File

@ -1,885 +0,0 @@
<?php
/**
* jpgraph_radar.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_RADAR.PHP
// Description: Radar plot extension for JpGraph
// Created: 2001-02-04
// Ver: $Id: jpgraph_radar.php 1783 2009-08-25 11:41:01Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once('jpgraph_plotmark.inc.php');
//===================================================
// CLASS RadarLogTicks
// Description: Logarithmic ticks
//===================================================
class RadarLogTicks extends Ticks {
function __construct() {
// Empty
}
function Stroke($aImg,&$grid,$aPos,$aAxisAngle,$aScale,&$aMajPos,&$aMajLabel) {
$start = $aScale->GetMinVal();
$limit = $aScale->GetMaxVal();
$nextMajor = 10*$start;
$step = $nextMajor / 10.0;
$count=1;
$ticklen_maj=5;
$dx_maj=round(sin($aAxisAngle)*$ticklen_maj);
$dy_maj=round(cos($aAxisAngle)*$ticklen_maj);
$ticklen_min=3;
$dx_min=round(sin($aAxisAngle)*$ticklen_min);
$dy_min=round(cos($aAxisAngle)*$ticklen_min);
$aMajPos=array();
$aMajLabel=array();
if( $this->supress_first ) {
$aMajLabel[] = '';
}
else {
$aMajLabel[]=$start;
}
$yr=$aScale->RelTranslate($start);
$xt=round($yr*cos($aAxisAngle))+$aScale->scale_abs[0];
$yt=$aPos-round($yr*sin($aAxisAngle));
$aMajPos[]=$xt+2*$dx_maj;
$aMajPos[]=$yt-$aImg->GetFontheight()/2;
$grid[]=$xt;
$grid[]=$yt;
$aImg->SetLineWeight($this->weight);
for($y=$start; $y<=$limit; $y+=$step,++$count ) {
$yr=$aScale->RelTranslate($y);
$xt=round($yr*cos($aAxisAngle))+$aScale->scale_abs[0];
$yt=$aPos-round($yr*sin($aAxisAngle));
if( $count % 10 == 0 ) {
$grid[]=$xt;
$grid[]=$yt;
$aMajPos[]=$xt+2*$dx_maj;
$aMajPos[]=$yt-$aImg->GetFontheight()/2;
if( !$this->supress_tickmarks ) {
if( $this->majcolor != '' ) {
$aImg->PushColor($this->majcolor);
}
$aImg->Line($xt+$dx_maj,$yt+$dy_maj,$xt-$dx_maj,$yt-$dy_maj);
if( $this->majcolor != '' ) {
$aImg->PopColor();
}
}
if( $this->label_formfunc != '' ) {
$f=$this->label_formfunc;
$l = call_user_func($f,$nextMajor);
}
else {
$l = $nextMajor;
}
$aMajLabel[]=$l;
$nextMajor *= 10;
$step *= 10;
$count=1;
}
else {
if( !$this->supress_minor_tickmarks ) {
if( $this->mincolor != '' ) {
$aImg->PushColor($this->mincolor);
}
$aImg->Line($xt+$dx_min,$yt+$dy_min,$xt-$dx_min,$yt-$dy_min);
if( $this->mincolor != '' ) {
$aImg->PopColor();
}
}
}
}
}
}
//===================================================
// CLASS RadarLinear
// Description: Linear ticks
//===================================================
class RadarLinearTicks extends Ticks {
private $minor_step=1, $major_step=2;
private $xlabel_offset=0,$xtick_offset=0;
function __construct() {
// Empty
}
// Return major step size in world coordinates
function GetMajor() {
return $this->major_step;
}
// Return minor step size in world coordinates
function GetMinor() {
return $this->minor_step;
}
// Set Minor and Major ticks (in world coordinates)
function Set($aMajStep,$aMinStep=false) {
if( $aMinStep==false ) {
$aMinStep=$aMajStep;
}
if( $aMajStep <= 0 || $aMinStep <= 0 ) {
JpGraphError::RaiseL(25064);
//JpGraphError::Raise(" Minor or major step size is 0. Check that you haven't got an accidental SetTextTicks(0) in your code. If this is not the case you might have stumbled upon a bug in JpGraph. Please report this and if possible include the data that caused the problem.");
}
$this->major_step=$aMajStep;
$this->minor_step=$aMinStep;
$this->is_set = true;
}
function Stroke($aImg,&$grid,$aPos,$aAxisAngle,$aScale,&$aMajPos,&$aMajLabel) {
// Prepare to draw linear ticks
$maj_step_abs = abs($aScale->scale_factor*$this->major_step);
$min_step_abs = abs($aScale->scale_factor*$this->minor_step);
$nbrmaj = round($aScale->world_abs_size/$maj_step_abs);
$nbrmin = round($aScale->world_abs_size/$min_step_abs);
$skip = round($nbrmin/$nbrmaj); // Don't draw minor on top of major
// Draw major ticks
$ticklen2=$this->major_abs_size;
$dx=round(sin($aAxisAngle)*$ticklen2);
$dy=round(cos($aAxisAngle)*$ticklen2);
$label=$aScale->scale[0]+$this->major_step;
$aImg->SetLineWeight($this->weight);
$aMajPos = array();
$aMajLabel = array();
for($i=1; $i<=$nbrmaj; ++$i) {
$xt=round($i*$maj_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0];
$yt=$aPos-round($i*$maj_step_abs*sin($aAxisAngle));
if( $this->label_formfunc != '' ) {
$f=$this->label_formfunc;
$l = call_user_func($f,$label);
}
else {
$l = $label;
}
$aMajLabel[]=$l;
$label += $this->major_step;
$grid[]=$xt;
$grid[]=$yt;
$aMajPos[($i-1)*2]=$xt+2*$dx;
$aMajPos[($i-1)*2+1]=$yt-$aImg->GetFontheight()/2;
if( !$this->supress_tickmarks ) {
if( $this->majcolor != '' ) {
$aImg->PushColor($this->majcolor);
}
$aImg->Line($xt+$dx,$yt+$dy,$xt-$dx,$yt-$dy);
if( $this->majcolor != '' ) {
$aImg->PopColor();
}
}
}
// Draw minor ticks
$ticklen2=$this->minor_abs_size;
$dx=round(sin($aAxisAngle)*$ticklen2);
$dy=round(cos($aAxisAngle)*$ticklen2);
if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) {
if( $this->mincolor != '' ) {
$aImg->PushColor($this->mincolor);
}
for($i=1; $i<=$nbrmin; ++$i) {
if( ($i % $skip) == 0 ) {
continue;
}
$xt=round($i*$min_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0];
$yt=$aPos-round($i*$min_step_abs*sin($aAxisAngle));
$aImg->Line($xt+$dx,$yt+$dy,$xt-$dx,$yt-$dy);
}
if( $this->mincolor != '' ) {
$aImg->PopColor();
}
}
}
}
//===================================================
// CLASS RadarAxis
// Description: Implements axis for the radar graph
//===================================================
class RadarAxis extends AxisPrototype {
public $title=null;
private $title_color='navy';
private $len=0;
function __construct($img,$aScale,$color=array(0,0,0)) {
parent::__construct($img,$aScale,$color);
$this->len = $img->plotheight;
$this->title = new Text();
$this->title->SetFont(FF_FONT1,FS_BOLD);
$this->color = array(0,0,0);
}
// Stroke the axis
// $pos = Vertical position of axis
// $aAxisAngle = Axis angle
// $grid = Returns an array with positions used to draw the grid
// $lf = Label flag, TRUE if the axis should have labels
function Stroke($pos,$aAxisAngle,&$grid,$title,$lf) {
$this->img->SetColor($this->color);
// Determine end points for the axis
$x=round($this->scale->world_abs_size*cos($aAxisAngle)+$this->scale->scale_abs[0]);
$y=round($pos-$this->scale->world_abs_size*sin($aAxisAngle));
// Draw axis
$this->img->SetColor($this->color);
$this->img->SetLineWeight($this->weight);
if( !$this->hide ) {
$this->img->Line($this->scale->scale_abs[0],$pos,$x,$y);
}
$this->scale->ticks->Stroke($this->img,$grid,$pos,$aAxisAngle,$this->scale,$majpos,$majlabel);
$ncolor=0;
if( isset($this->ticks_label_colors) ) {
$ncolor=count($this->ticks_label_colors);
}
// Draw labels
if( $lf && !$this->hide ) {
$this->img->SetFont($this->font_family,$this->font_style,$this->font_size);
$this->img->SetTextAlign('left','top');
$this->img->SetColor($this->label_color);
// majpos contains (x,y) coordinates for labels
if( ! $this->hide_labels ) {
$n = floor(count($majpos)/2);
for($i=0; $i < $n; ++$i) {
// Set specific label color if specified
if( $ncolor > 0 ) {
$this->img->SetColor($this->ticks_label_colors[$i % $ncolor]);
}
if( $this->ticks_label != null && isset($this->ticks_label[$i]) ) {
$this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$this->ticks_label[$i]);
}
else {
$this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$majlabel[$i]);
}
}
}
}
$this->_StrokeAxisTitle($pos,$aAxisAngle,$title);
}
function _StrokeAxisTitle($pos,$aAxisAngle,$title) {
$this->title->Set($title);
$marg=6+$this->title->margin;
$xt=round(($this->scale->world_abs_size+$marg)*cos($aAxisAngle)+$this->scale->scale_abs[0]);
$yt=round($pos-($this->scale->world_abs_size+$marg)*sin($aAxisAngle));
// Position the axis title.
// dx, dy is the offset from the top left corner of the bounding box that sorrounds the text
// that intersects with the extension of the corresponding axis. The code looks a little
// bit messy but this is really the only way of having a reasonable position of the
// axis titles.
if( $this->title->iWordwrap > 0 ) {
$title = wordwrap($title,$this->title->iWordwrap,"\n");
}
$h=$this->img->GetTextHeight($title)*1.2;
$w=$this->img->GetTextWidth($title)*1.2;
while( $aAxisAngle > 2*M_PI )
$aAxisAngle -= 2*M_PI;
// Around 3 a'clock
if( $aAxisAngle>=7*M_PI/4 || $aAxisAngle <= M_PI/4 ) $dx=-0.15; // Small trimming to make the dist to the axis more even
// Around 12 a'clock
if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dx=($aAxisAngle-M_PI/4)*2/M_PI;
// Around 9 a'clock
if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dx=1;
// Around 6 a'clock
if( $aAxisAngle>=5*M_PI/4 && $aAxisAngle <= 7*M_PI/4 ) $dx=(1-($aAxisAngle-M_PI*5/4)*2/M_PI);
if( $aAxisAngle>=7*M_PI/4 ) $dy=(($aAxisAngle-M_PI)-3*M_PI/4)*2/M_PI;
if( $aAxisAngle<=M_PI/12 ) $dy=(0.5-$aAxisAngle*2/M_PI);
if( $aAxisAngle<=M_PI/4 && $aAxisAngle > M_PI/12) $dy=(1-$aAxisAngle*2/M_PI);
if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dy=1;
if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dy=(1-($aAxisAngle-3*M_PI/4)*2/M_PI);
if( $aAxisAngle>=5*M_PI/4 && $aAxisAngle <= 7*M_PI/4 ) $dy=0;
if( !$this->hide ) {
$this->title->Stroke($this->img,$xt-$dx*$w,$yt-$dy*$h,$title);
}
}
} // Class
//===================================================
// CLASS RadarGrid
// Description: Draws grid for the radar graph
//===================================================
class RadarGrid { //extends Grid {
private $type='solid';
private $grid_color='#DDDDDD';
private $show=false, $weight=1;
function __construct() {
// Empty
}
function SetColor($aMajColor) {
$this->grid_color = $aMajColor;
}
function SetWeight($aWeight) {
$this->weight=$aWeight;
}
// Specify if grid should be dashed, dotted or solid
function SetLineStyle($aType) {
$this->type = $aType;
}
// Decide if both major and minor grid should be displayed
function Show($aShowMajor=true) {
$this->show=$aShowMajor;
}
function Stroke($img,$grid) {
if( !$this->show ) {
return;
}
$nbrticks = count($grid[0])/2;
$nbrpnts = count($grid);
$img->SetColor($this->grid_color);
$img->SetLineWeight($this->weight);
for($i=0; $i<$nbrticks; ++$i) {
for($j=0; $j<$nbrpnts; ++$j) {
$pnts[$j*2]=$grid[$j][$i*2];
$pnts[$j*2+1]=$grid[$j][$i*2+1];
}
for($k=0; $k<$nbrpnts; ++$k ){
$l=($k+1)%$nbrpnts;
if( $this->type == 'solid' )
$img->Line($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1]);
elseif( $this->type == 'dotted' )
$img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],1,6);
elseif( $this->type == 'dashed' )
$img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],2,4);
elseif( $this->type == 'longdashed' )
$img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],8,6);
}
$pnts=array();
}
}
} // Class
//===================================================
// CLASS RadarPlot
// Description: Plot a radarplot
//===================================================
class RadarPlot {
public $mark=null;
public $legend='';
public $legendcsimtarget='';
public $legendcsimalt='';
public $csimtargets=array(); // Array of targets for CSIM
public $csimareas=""; // Resultant CSIM area tags
public $csimalts=null; // ALT:s for corresponding target
private $data=array();
private $fill=false, $fill_color=array(200,170,180);
private $color=array(0,0,0);
private $weight=1;
private $linestyle='solid';
//---------------
// CONSTRUCTOR
function __construct($data) {
$this->data = $data;
$this->mark = new PlotMark();
}
function Min() {
return Min($this->data);
}
function Max() {
return Max($this->data);
}
function SetLegend($legend) {
$this->legend=$legend;
}
function SetLineStyle($aStyle) {
$this->linestyle=$aStyle;
}
function SetLineWeight($w) {
$this->weight=$w;
}
function SetFillColor($aColor) {
$this->fill_color = $aColor;
$this->fill = true;
}
function SetFill($f=true) {
$this->fill = $f;
}
function SetColor($aColor,$aFillColor=false) {
$this->color = $aColor;
if( $aFillColor ) {
$this->SetFillColor($aFillColor);
$this->fill = true;
}
}
// Set href targets for CSIM
function SetCSIMTargets($aTargets,$aAlts=null) {
$this->csimtargets=$aTargets;
$this->csimalts=$aAlts;
}
// Get all created areas
function GetCSIMareas() {
return $this->csimareas;
}
function Stroke($img, $pos, $scale, $startangle) {
$nbrpnts = count($this->data);
$astep=2*M_PI/$nbrpnts;
$a=$startangle;
for($i=0; $i<$nbrpnts; ++$i) {
// Rotate each non null point to the correct axis-angle
$cs=$scale->RelTranslate($this->data[$i]);
$x=round($cs*cos($a)+$scale->scale_abs[0]);
$y=round($pos-$cs*sin($a));
$pnts[$i*2]=$x;
$pnts[$i*2+1]=$y;
// If the next point is null then we draw this polygon segment
// to the center, skip the next and draw the next segment from
// the center up to the point on the axis with the first non-null
// value and continues from that point. Some additoinal logic is necessary
// to handle the boundary conditions
if( $i < $nbrpnts-1 ) {
if( is_null($this->data[$i+1]) ) {
$cs = 0;
$x=round($cs*cos($a)+$scale->scale_abs[0]);
$y=round($pos-$cs*sin($a));
$pnts[$i*2]=$x;
$pnts[$i*2+1]=$y;
$a += $astep;
}
}
$a += $astep;
}
if( $this->fill ) {
$img->SetColor($this->fill_color);
$img->FilledPolygon($pnts);
}
$img->SetLineWeight($this->weight);
$img->SetColor($this->color);
$img->SetLineStyle($this->linestyle);
$pnts[] = $pnts[0];
$pnts[] = $pnts[1];
$img->Polygon($pnts);
$img->SetLineStyle('solid'); // Reset line style to default
// Add plotmarks on top
if( $this->mark->show ) {
for($i=0; $i < $nbrpnts; ++$i) {
if( isset($this->csimtargets[$i]) ) {
$this->mark->SetCSIMTarget($this->csimtargets[$i]);
$this->mark->SetCSIMAlt($this->csimalts[$i]);
$this->mark->SetCSIMAltVal($pnts[$i*2], $pnts[$i*2+1]);
$this->mark->Stroke($img, $pnts[$i*2], $pnts[$i*2+1]);
$this->csimareas .= $this->mark->GetCSIMAreas();
}
else {
$this->mark->Stroke($img,$pnts[$i*2],$pnts[$i*2+1]);
}
}
}
}
function GetCount() {
return count($this->data);
}
function Legend($graph) {
if( $this->legend == '' ) {
return;
}
if( $this->fill ) {
$graph->legend->Add($this->legend,$this->fill_color,$this->mark);
} else {
$graph->legend->Add($this->legend,$this->color,$this->mark);
}
}
} // Class
//===================================================
// CLASS RadarGraph
// Description: Main container for a radar graph
//===================================================
class RadarGraph extends Graph {
public $grid,$axis=null;
private $posx,$posy;
private $len;
private $axis_title=null;
function __construct($width=300,$height=200,$cachedName="",$timeout=0,$inline=1) {
parent::__construct($width,$height,$cachedName,$timeout,$inline);
$this->posx = $width/2;
$this->posy = $height/2;
$this->len = min($width,$height)*0.35;
$this->SetColor(array(255,255,255));
$this->SetTickDensity(TICKD_NORMAL);
$this->SetScale('lin');
$this->SetGridDepth(DEPTH_FRONT);
}
function HideTickMarks($aFlag=true) {
$this->axis->scale->ticks->SupressTickMarks($aFlag);
}
function ShowMinorTickmarks($aFlag=true) {
$this->yscale->ticks->SupressMinorTickMarks(!$aFlag);
}
function SetScale($axtype,$ymin=1,$ymax=1,$dummy1=null,$dumy2=null) {
if( $axtype != 'lin' && $axtype != 'log' ) {
JpGraphError::RaiseL(18003,$axtype);
//("Illegal scale for radarplot ($axtype). Must be \"lin\" or \"log\"");
}
if( $axtype == 'lin' ) {
$this->yscale = new LinearScale($ymin,$ymax);
$this->yscale->ticks = new RadarLinearTicks();
$this->yscale->ticks->SupressMinorTickMarks();
}
elseif( $axtype == 'log' ) {
$this->yscale = new LogScale($ymin,$ymax);
$this->yscale->ticks = new RadarLogTicks();
}
$this->axis = new RadarAxis($this->img,$this->yscale);
$this->grid = new RadarGrid();
}
function SetSize($aSize) {
if( $aSize < 0.1 || $aSize>1 ) {
JpGraphError::RaiseL(18004,$aSize);
//("Radar Plot size must be between 0.1 and 1. (Your value=$s)");
}
$this->len=min($this->img->width,$this->img->height)*$aSize/2;
}
function SetPlotSize($aSize) {
$this->SetSize($aSize);
}
function SetTickDensity($densy=TICKD_NORMAL,$dummy1=null) {
$this->ytick_factor=25;
switch( $densy ) {
case TICKD_DENSE:
$this->ytick_factor=12;
break;
case TICKD_NORMAL:
$this->ytick_factor=25;
break;
case TICKD_SPARSE:
$this->ytick_factor=40;
break;
case TICKD_VERYSPARSE:
$this->ytick_factor=70;
break;
default:
JpGraphError::RaiseL(18005,$densy);
//("RadarPlot Unsupported Tick density: $densy");
}
}
function SetPos($px,$py=0.5) {
$this->SetCenter($px,$py);
}
function SetCenter($px,$py=0.5) {
if( $px >= 0 && $px <= 1 ) {
$this->posx = $this->img->width*$px;
}
else {
$this->posx = $px;
}
if( $py >= 0 && $py <= 1 ) {
$this->posy = $this->img->height*$py;
}
else {
$this->posy = $py;
}
}
function SetColor($aColor) {
$this->SetMarginColor($aColor);
}
function SetTitles($aTitleArray) {
$this->axis_title = $aTitleArray;
}
function Add($aPlot) {
if( $aPlot == null ) {
JpGraphError::RaiseL(25010);//("Graph::Add() You tried to add a null plot to the graph.");
}
if( is_array($aPlot) && count($aPlot) > 0 ) {
$cl = $aPlot[0];
}
else {
$cl = $aPlot;
}
if( $cl instanceof Text ) $this->AddText($aPlot);
elseif( class_exists('IconPlot',false) && ($cl instanceof IconPlot) ) $this->AddIcon($aPlot);
else {
$this->plots[] = $aPlot;
}
}
function GetPlotsYMinMax($aPlots) {
$min=$aPlots[0]->Min();
$max=$aPlots[0]->Max();
foreach( $this->plots as $p ) {
$max=max($max,$p->Max());
$min=min($min,$p->Min());
}
if( $min < 0 ) {
JpGraphError::RaiseL(18006,$min);
//("Minimum data $min (Radar plots should only be used when all data points > 0)");
}
return array($min,$max);
}
function StrokeIcons() {
if( $this->iIcons != null ) {
$n = count($this->iIcons);
for( $i=0; $i < $n; ++$i ) {
$this->iIcons[$i]->Stroke($this->img);
}
}
}
function StrokeTexts() {
if( $this->texts != null ) {
$n = count($this->texts);
for( $i=0; $i < $n; ++$i ) {
$this->texts[$i]->Stroke($this->img);
}
}
}
// Stroke the Radar graph
function Stroke($aStrokeFileName='') {
// If the filename is the predefined value = '_csim_special_'
// we assume that the call to stroke only needs to do enough
// to correctly generate the CSIM maps.
// We use this variable to skip things we don't strictly need
// to do to generate the image map to improve performance
// a best we can. Therefor you will see a lot of tests !$_csim in the
// code below.
$_csim = ( $aStrokeFileName === _CSIM_SPECIALFILE );
// We need to know if we have stroked the plot in the
// GetCSIMareas. Otherwise the CSIM hasn't been generated
// and in the case of GetCSIM called before stroke to generate
// CSIM without storing an image to disk GetCSIM must call Stroke.
$this->iHasStroked = true;
$n = count($this->plots);
// Set Y-scale
if( !$this->yscale->IsSpecified() && count($this->plots) > 0 ) {
list($min,$max) = $this->GetPlotsYMinMax($this->plots);
$this->yscale->AutoScale($this->img,0,$max,$this->len/$this->ytick_factor);
}
elseif( $this->yscale->IsSpecified() &&
( $this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified()) ) {
// The tick calculation will use the user suplied min/max values to determine
// the ticks. If auto_ticks is false the exact user specifed min and max
// values will be used for the scale.
// If auto_ticks is true then the scale might be slightly adjusted
// so that the min and max values falls on an even major step.
$min = $this->yscale->scale[0];
$max = $this->yscale->scale[1];
$this->yscale->AutoScale($this->img,$min,$max,
$this->len/$this->ytick_factor,
$this->yscale->auto_ticks);
}
// Set start position end length of scale (in absolute pixels)
$this->yscale->SetConstants($this->posx,$this->len);
// We need as many axis as there are data points
$nbrpnts=$this->plots[0]->GetCount();
// If we have no titles just number the axis 1,2,3,...
if( $this->axis_title==null ) {
for($i=0; $i < $nbrpnts; ++$i ) {
$this->axis_title[$i] = $i+1;
}
}
elseif( count($this->axis_title) < $nbrpnts) {
JpGraphError::RaiseL(18007);
// ("Number of titles does not match number of points in plot.");
}
for( $i=0; $i < $n; ++$i ) {
if( $nbrpnts != $this->plots[$i]->GetCount() ) {
JpGraphError::RaiseL(18008);
//("Each radar plot must have the same number of data points.");
}
}
if( !$_csim ) {
if( $this->background_image != '' ) {
$this->StrokeFrameBackground();
}
else {
$this->StrokeFrame();
$this->StrokeBackgroundGrad();
}
}
$astep=2*M_PI/$nbrpnts;
if( !$_csim ) {
if( $this->iIconDepth == DEPTH_BACK ) {
$this->StrokeIcons();
}
// Prepare legends
for($i=0; $i < $n; ++$i) {
$this->plots[$i]->Legend($this);
}
$this->legend->Stroke($this->img);
$this->footer->Stroke($this->img);
}
if( !$_csim ) {
if( $this->grid_depth == DEPTH_BACK ) {
// Draw axis and grid
for( $i=0,$a=M_PI/2; $i < $nbrpnts; ++$i, $a += $astep ) {
$this->axis->Stroke($this->posy,$a,$grid[$i],$this->axis_title[$i],$i==0);
}
$this->grid->Stroke($this->img,$grid);
}
if( $this->iIconDepth == DEPTH_BACK ) {
$this->StrokeIcons();
}
}
// Plot points
$a=M_PI/2;
for($i=0; $i < $n; ++$i ) {
$this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a);
}
if( !$_csim ) {
if( $this->grid_depth != DEPTH_BACK ) {
// Draw axis and grid
for( $i=0,$a=M_PI/2; $i < $nbrpnts; ++$i, $a += $astep ) {
$this->axis->Stroke($this->posy,$a,$grid[$i],$this->axis_title[$i],$i==0);
}
$this->grid->Stroke($this->img,$grid);
}
$this->StrokeTitles();
$this->StrokeTexts();
if( $this->iIconDepth == DEPTH_FRONT ) {
$this->StrokeIcons();
}
}
// Should we do any final image transformation
if( $this->iImgTrans && !$_csim ) {
if( !class_exists('ImgTrans',false) ) {
require_once('jpgraph_imgtrans.php');
}
$tform = new ImgTrans($this->img->img);
$this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist,
$this->iImgTransDirection,$this->iImgTransHighQ,
$this->iImgTransMinSize,$this->iImgTransFillColor,
$this->iImgTransBorder);
}
if( !$_csim ) {
// If the filename is given as the special "__handle"
// then the image handler is returned and the image is NOT
// streamed back
if( $aStrokeFileName == _IMG_HANDLER ) {
return $this->img->img;
}
else {
// Finally stream the generated picture
$this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName);
}
}
}
} // Class
/* EOF */
?>

View File

@ -1,239 +0,0 @@
<?php
/**
* jpgraph_regstat.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_REGSTAT.PHP
// Description: Regression and statistical analysis helper classes
// Created: 2002-12-01
// Ver: $Id: jpgraph_regstat.php 1131 2009-03-11 20:08:24Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
//------------------------------------------------------------------------
// CLASS Spline
// Create a new data array from an existing data array but with more points.
// The new points are interpolated using a cubic spline algorithm
//------------------------------------------------------------------------
class Spline {
// 3:rd degree polynom approximation
private $xdata,$ydata; // Data vectors
private $y2; // 2:nd derivate of ydata
private $n=0;
function __construct($xdata,$ydata) {
$this->y2 = array();
$this->xdata = $xdata;
$this->ydata = $ydata;
$n = count($ydata);
$this->n = $n;
if( $this->n !== count($xdata) ) {
JpGraphError::RaiseL(19001);
//('Spline: Number of X and Y coordinates must be the same');
}
// Natural spline 2:derivate == 0 at endpoints
$this->y2[0] = 0.0;
$this->y2[$n-1] = 0.0;
$delta[0] = 0.0;
// Calculate 2:nd derivate
for($i=1; $i < $n-1; ++$i) {
$d = ($xdata[$i+1]-$xdata[$i-1]);
if( $d == 0 ) {
JpGraphError::RaiseL(19002);
//('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.');
}
$s = ($xdata[$i]-$xdata[$i-1])/$d;
$p = $s*$this->y2[$i-1]+2.0;
$this->y2[$i] = ($s-1.0)/$p;
$delta[$i] = ($ydata[$i+1]-$ydata[$i])/($xdata[$i+1]-$xdata[$i]) -
($ydata[$i]-$ydata[$i-1])/($xdata[$i]-$xdata[$i-1]);
$delta[$i] = (6.0*$delta[$i]/($xdata[$i+1]-$xdata[$i-1])-$s*$delta[$i-1])/$p;
}
// Backward substitution
for( $j=$n-2; $j >= 0; --$j ) {
$this->y2[$j] = $this->y2[$j]*$this->y2[$j+1] + $delta[$j];
}
}
// Return the two new data vectors
function Get($num=50) {
$n = $this->n ;
$step = ($this->xdata[$n-1]-$this->xdata[0]) / ($num-1);
$xnew=array();
$ynew=array();
$xnew[0] = $this->xdata[0];
$ynew[0] = $this->ydata[0];
for( $j=1; $j < $num; ++$j ) {
$xnew[$j] = $xnew[0]+$j*$step;
$ynew[$j] = $this->Interpolate($xnew[$j]);
}
return array($xnew,$ynew);
}
// Return a single interpolated Y-value from an x value
function Interpolate($xpoint) {
$max = $this->n-1;
$min = 0;
// Binary search to find interval
while( $max-$min > 1 ) {
$k = ($max+$min) / 2;
if( $this->xdata[$k] > $xpoint )
$max=$k;
else
$min=$k;
}
// Each interval is interpolated by a 3:degree polynom function
$h = $this->xdata[$max]-$this->xdata[$min];
if( $h == 0 ) {
JpGraphError::RaiseL(19002);
//('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.');
}
$a = ($this->xdata[$max]-$xpoint)/$h;
$b = ($xpoint-$this->xdata[$min])/$h;
return $a*$this->ydata[$min]+$b*$this->ydata[$max]+
(($a*$a*$a-$a)*$this->y2[$min]+($b*$b*$b-$b)*$this->y2[$max])*($h*$h)/6.0;
}
}
//------------------------------------------------------------------------
// CLASS Bezier
// Create a new data array from a number of control points
//------------------------------------------------------------------------
class Bezier {
/**
* @author Thomas Despoix, openXtrem company
* @license released under QPL
* @abstract Bezier interoplated point generation,
* computed from control points data sets, based on Paul Bourke algorithm :
* http://local.wasp.uwa.edu.au/~pbourke/geometry/bezier/index2.html
*/
private $datax = array();
private $datay = array();
private $n=0;
function __construct($datax, $datay, $attraction_factor = 1) {
// Adding control point multiple time will raise their attraction power over the curve
$this->n = count($datax);
if( $this->n !== count($datay) ) {
JpGraphError::RaiseL(19003);
//('Bezier: Number of X and Y coordinates must be the same');
}
$idx=0;
foreach($datax as $datumx) {
for ($i = 0; $i < $attraction_factor; $i++) {
$this->datax[$idx++] = $datumx;
}
}
$idx=0;
foreach($datay as $datumy) {
for ($i = 0; $i < $attraction_factor; $i++) {
$this->datay[$idx++] = $datumy;
}
}
$this->n *= $attraction_factor;
}
/**
* Return a set of data points that specifies the bezier curve with $steps points
* @param $steps Number of new points to return
* @return array($datax, $datay)
*/
function Get($steps) {
$datax = array();
$datay = array();
for ($i = 0; $i < $steps; $i++) {
list($datumx, $datumy) = $this->GetPoint((double) $i / (double) $steps);
$datax[$i] = $datumx;
$datay[$i] = $datumy;
}
$datax[] = end($this->datax);
$datay[] = end($this->datay);
return array($datax, $datay);
}
/**
* Return one point on the bezier curve. $mu is the position on the curve where $mu is in the
* range 0 $mu < 1 where 0 is tha start point and 1 is the end point. Note that every newly computed
* point depends on all the existing points
*
* @param $mu Position on the bezier curve
* @return array($x, $y)
*/
function GetPoint($mu) {
$n = $this->n - 1;
$k = 0;
$kn = 0;
$nn = 0;
$nkn = 0;
$blend = 0.0;
$newx = 0.0;
$newy = 0.0;
$muk = 1.0;
$munk = (double) pow(1-$mu,(double) $n);
for ($k = 0; $k <= $n; $k++) {
$nn = $n;
$kn = $k;
$nkn = $n - $k;
$blend = $muk * $munk;
$muk *= $mu;
$munk /= (1-$mu);
while ($nn >= 1) {
$blend *= $nn;
$nn--;
if ($kn > 1) {
$blend /= (double) $kn;
$kn--;
}
if ($nkn > 1) {
$blend /= (double) $nkn;
$nkn--;
}
}
$newx += $this->datax[$k] * $blend;
$newy += $this->datay[$k] * $blend;
}
return array($newx, $newy);
}
}
// EOF
?>

View File

@ -1,639 +0,0 @@
<?php
/**
* jpgraph_rgb.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_RGB.INC.PHP
// Description: Class to handle RGb color space specification and
// named colors
// Created: 2001-01-08 (Refactored to separate file 2008-08-01)
// Ver: $Id: jpgraph_rgb.inc.php 1893 2009-10-02 23:15:25Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
/*===================================================
// CLASS RGB
// Description: Color definitions as RGB triples
//===================================================
*/
class RGB {
public $rgb_table;
public $img;
function __construct($aImg=null) {
$this->img = $aImg;
// Conversion array between color names and RGB
$this->rgb_table = array(
'aqua'=> array(0,255,255),
'lime'=> array(0,255,0),
'teal'=> array(0,128,128),
'whitesmoke'=>array(245,245,245),
'gainsboro'=>array(220,220,220),
'oldlace'=>array(253,245,230),
'linen'=>array(250,240,230),
'antiquewhite'=>array(250,235,215),
'papayawhip'=>array(255,239,213),
'blanchedalmond'=>array(255,235,205),
'bisque'=>array(255,228,196),
'peachpuff'=>array(255,218,185),
'navajowhite'=>array(255,222,173),
'moccasin'=>array(255,228,181),
'cornsilk'=>array(255,248,220),
'ivory'=>array(255,255,240),
'lemonchiffon'=>array(255,250,205),
'seashell'=>array(255,245,238),
'mintcream'=>array(245,255,250),
'azure'=>array(240,255,255),
'aliceblue'=>array(240,248,255),
'lavender'=>array(230,230,250),
'lavenderblush'=>array(255,240,245),
'mistyrose'=>array(255,228,225),
'white'=>array(255,255,255),
'black'=>array(0,0,0),
'darkslategray'=>array(47,79,79),
'dimgray'=>array(105,105,105),
'slategray'=>array(112,128,144),
'lightslategray'=>array(119,136,153),
'gray'=>array(190,190,190),
'lightgray'=>array(211,211,211),
'midnightblue'=>array(25,25,112),
'navy'=>array(0,0,128),
'indigo'=>array(75,0,130),
'electricindigo'=>array(102,0,255),
'deepindigo'=>array(138,43,226),
'pigmentindigo'=>array(75,0,130),
'indigodye'=>array(0,65,106),
'cornflowerblue'=>array(100,149,237),
'darkslateblue'=>array(72,61,139),
'slateblue'=>array(106,90,205),
'mediumslateblue'=>array(123,104,238),
'lightslateblue'=>array(132,112,255),
'mediumblue'=>array(0,0,205),
'royalblue'=>array(65,105,225),
'blue'=>array(0,0,255),
'dodgerblue'=>array(30,144,255),
'deepskyblue'=>array(0,191,255),
'skyblue'=>array(135,206,235),
'lightskyblue'=>array(135,206,250),
'steelblue'=>array(70,130,180),
'lightred'=>array(211,167,168),
'lightsteelblue'=>array(176,196,222),
'lightblue'=>array(173,216,230),
'powderblue'=>array(176,224,230),
'paleturquoise'=>array(175,238,238),
'darkturquoise'=>array(0,206,209),
'mediumturquoise'=>array(72,209,204),
'turquoise'=>array(64,224,208),
'cyan'=>array(0,255,255),
'lightcyan'=>array(224,255,255),
'cadetblue'=>array(95,158,160),
'mediumaquamarine'=>array(102,205,170),
'aquamarine'=>array(127,255,212),
'darkgreen'=>array(0,100,0),
'darkolivegreen'=>array(85,107,47),
'darkseagreen'=>array(143,188,143),
'seagreen'=>array(46,139,87),
'mediumseagreen'=>array(60,179,113),
'lightseagreen'=>array(32,178,170),
'palegreen'=>array(152,251,152),
'springgreen'=>array(0,255,127),
'lawngreen'=>array(124,252,0),
'green'=>array(0,255,0),
'chartreuse'=>array(127,255,0),
'mediumspringgreen'=>array(0,250,154),
'greenyellow'=>array(173,255,47),
'limegreen'=>array(50,205,50),
'yellowgreen'=>array(154,205,50),
'forestgreen'=>array(34,139,34),
'olivedrab'=>array(107,142,35),
'darkkhaki'=>array(189,183,107),
'khaki'=>array(240,230,140),
'palegoldenrod'=>array(238,232,170),
'lightgoldenrodyellow'=>array(250,250,210),
'lightyellow'=>array(255,255,200),
'yellow'=>array(255,255,0),
'gold'=>array(255,215,0),
'lightgoldenrod'=>array(238,221,130),
'goldenrod'=>array(218,165,32),
'darkgoldenrod'=>array(184,134,11),
'rosybrown'=>array(188,143,143),
'indianred'=>array(205,92,92),
'saddlebrown'=>array(139,69,19),
'sienna'=>array(160,82,45),
'peru'=>array(205,133,63),
'burlywood'=>array(222,184,135),
'beige'=>array(245,245,220),
'wheat'=>array(245,222,179),
'sandybrown'=>array(244,164,96),
'tan'=>array(210,180,140),
'chocolate'=>array(210,105,30),
'firebrick'=>array(178,34,34),
'brown'=>array(165,42,42),
'darksalmon'=>array(233,150,122),
'salmon'=>array(250,128,114),
'lightsalmon'=>array(255,160,122),
'orange'=>array(255,165,0),
'darkorange'=>array(255,140,0),
'coral'=>array(255,127,80),
'lightcoral'=>array(240,128,128),
'tomato'=>array(255,99,71),
'orangered'=>array(255,69,0),
'red'=>array(255,0,0),
'hotpink'=>array(255,105,180),
'deeppink'=>array(255,20,147),
'pink'=>array(255,192,203),
'lightpink'=>array(255,182,193),
'palevioletred'=>array(219,112,147),
'maroon'=>array(176,48,96),
'mediumvioletred'=>array(199,21,133),
'violetred'=>array(208,32,144),
'magenta'=>array(255,0,255),
'violet'=>array(238,130,238),
'plum'=>array(221,160,221),
'orchid'=>array(218,112,214),
'mediumorchid'=>array(186,85,211),
'darkorchid'=>array(153,50,204),
'darkviolet'=>array(148,0,211),
'blueviolet'=>array(138,43,226),
'purple'=>array(160,32,240),
'mediumpurple'=>array(147,112,219),
'thistle'=>array(216,191,216),
'snow1'=>array(255,250,250),
'snow2'=>array(238,233,233),
'snow3'=>array(205,201,201),
'snow4'=>array(139,137,137),
'seashell1'=>array(255,245,238),
'seashell2'=>array(238,229,222),
'seashell3'=>array(205,197,191),
'seashell4'=>array(139,134,130),
'AntiqueWhite1'=>array(255,239,219),
'AntiqueWhite2'=>array(238,223,204),
'AntiqueWhite3'=>array(205,192,176),
'AntiqueWhite4'=>array(139,131,120),
'bisque1'=>array(255,228,196),
'bisque2'=>array(238,213,183),
'bisque3'=>array(205,183,158),
'bisque4'=>array(139,125,107),
'peachPuff1'=>array(255,218,185),
'peachpuff2'=>array(238,203,173),
'peachpuff3'=>array(205,175,149),
'peachpuff4'=>array(139,119,101),
'navajowhite1'=>array(255,222,173),
'navajowhite2'=>array(238,207,161),
'navajowhite3'=>array(205,179,139),
'navajowhite4'=>array(139,121,94),
'lemonchiffon1'=>array(255,250,205),
'lemonchiffon2'=>array(238,233,191),
'lemonchiffon3'=>array(205,201,165),
'lemonchiffon4'=>array(139,137,112),
'ivory1'=>array(255,255,240),
'ivory2'=>array(238,238,224),
'ivory3'=>array(205,205,193),
'ivory4'=>array(139,139,131),
'honeydew'=>array(193,205,193),
'lavenderblush1'=>array(255,240,245),
'lavenderblush2'=>array(238,224,229),
'lavenderblush3'=>array(205,193,197),
'lavenderblush4'=>array(139,131,134),
'mistyrose1'=>array(255,228,225),
'mistyrose2'=>array(238,213,210),
'mistyrose3'=>array(205,183,181),
'mistyrose4'=>array(139,125,123),
'azure1'=>array(240,255,255),
'azure2'=>array(224,238,238),
'azure3'=>array(193,205,205),
'azure4'=>array(131,139,139),
'slateblue1'=>array(131,111,255),
'slateblue2'=>array(122,103,238),
'slateblue3'=>array(105,89,205),
'slateblue4'=>array(71,60,139),
'royalblue1'=>array(72,118,255),
'royalblue2'=>array(67,110,238),
'royalblue3'=>array(58,95,205),
'royalblue4'=>array(39,64,139),
'dodgerblue1'=>array(30,144,255),
'dodgerblue2'=>array(28,134,238),
'dodgerblue3'=>array(24,116,205),
'dodgerblue4'=>array(16,78,139),
'steelblue1'=>array(99,184,255),
'steelblue2'=>array(92,172,238),
'steelblue3'=>array(79,148,205),
'steelblue4'=>array(54,100,139),
'deepskyblue1'=>array(0,191,255),
'deepskyblue2'=>array(0,178,238),
'deepskyblue3'=>array(0,154,205),
'deepskyblue4'=>array(0,104,139),
'skyblue1'=>array(135,206,255),
'skyblue2'=>array(126,192,238),
'skyblue3'=>array(108,166,205),
'skyblue4'=>array(74,112,139),
'lightskyblue1'=>array(176,226,255),
'lightskyblue2'=>array(164,211,238),
'lightskyblue3'=>array(141,182,205),
'lightskyblue4'=>array(96,123,139),
'slategray1'=>array(198,226,255),
'slategray2'=>array(185,211,238),
'slategray3'=>array(159,182,205),
'slategray4'=>array(108,123,139),
'lightsteelblue1'=>array(202,225,255),
'lightsteelblue2'=>array(188,210,238),
'lightsteelblue3'=>array(162,181,205),
'lightsteelblue4'=>array(110,123,139),
'lightblue1'=>array(191,239,255),
'lightblue2'=>array(178,223,238),
'lightblue3'=>array(154,192,205),
'lightblue4'=>array(104,131,139),
'lightcyan1'=>array(224,255,255),
'lightcyan2'=>array(209,238,238),
'lightcyan3'=>array(180,205,205),
'lightcyan4'=>array(122,139,139),
'paleturquoise1'=>array(187,255,255),
'paleturquoise2'=>array(174,238,238),
'paleturquoise3'=>array(150,205,205),
'paleturquoise4'=>array(102,139,139),
'cadetblue1'=>array(152,245,255),
'cadetblue2'=>array(142,229,238),
'cadetblue3'=>array(122,197,205),
'cadetblue4'=>array(83,134,139),
'turquoise1'=>array(0,245,255),
'turquoise2'=>array(0,229,238),
'turquoise3'=>array(0,197,205),
'turquoise4'=>array(0,134,139),
'cyan1'=>array(0,255,255),
'cyan2'=>array(0,238,238),
'cyan3'=>array(0,205,205),
'cyan4'=>array(0,139,139),
'darkslategray1'=>array(151,255,255),
'darkslategray2'=>array(141,238,238),
'darkslategray3'=>array(121,205,205),
'darkslategray4'=>array(82,139,139),
'aquamarine1'=>array(127,255,212),
'aquamarine2'=>array(118,238,198),
'aquamarine3'=>array(102,205,170),
'aquamarine4'=>array(69,139,116),
'darkseagreen1'=>array(193,255,193),
'darkseagreen2'=>array(180,238,180),
'darkseagreen3'=>array(155,205,155),
'darkseagreen4'=>array(105,139,105),
'seagreen1'=>array(84,255,159),
'seagreen2'=>array(78,238,148),
'seagreen3'=>array(67,205,128),
'seagreen4'=>array(46,139,87),
'palegreen1'=>array(154,255,154),
'palegreen2'=>array(144,238,144),
'palegreen3'=>array(124,205,124),
'palegreen4'=>array(84,139,84),
'springgreen1'=>array(0,255,127),
'springgreen2'=>array(0,238,118),
'springgreen3'=>array(0,205,102),
'springgreen4'=>array(0,139,69),
'chartreuse1'=>array(127,255,0),
'chartreuse2'=>array(118,238,0),
'chartreuse3'=>array(102,205,0),
'chartreuse4'=>array(69,139,0),
'olivedrab1'=>array(192,255,62),
'olivedrab2'=>array(179,238,58),
'olivedrab3'=>array(154,205,50),
'olivedrab4'=>array(105,139,34),
'darkolivegreen1'=>array(202,255,112),
'darkolivegreen2'=>array(188,238,104),
'darkolivegreen3'=>array(162,205,90),
'darkolivegreen4'=>array(110,139,61),
'khaki1'=>array(255,246,143),
'khaki2'=>array(238,230,133),
'khaki3'=>array(205,198,115),
'khaki4'=>array(139,134,78),
'lightgoldenrod1'=>array(255,236,139),
'lightgoldenrod2'=>array(238,220,130),
'lightgoldenrod3'=>array(205,190,112),
'lightgoldenrod4'=>array(139,129,76),
'yellow1'=>array(255,255,0),
'yellow2'=>array(238,238,0),
'yellow3'=>array(205,205,0),
'yellow4'=>array(139,139,0),
'gold1'=>array(255,215,0),
'gold2'=>array(238,201,0),
'gold3'=>array(205,173,0),
'gold4'=>array(139,117,0),
'goldenrod1'=>array(255,193,37),
'goldenrod2'=>array(238,180,34),
'goldenrod3'=>array(205,155,29),
'goldenrod4'=>array(139,105,20),
'darkgoldenrod1'=>array(255,185,15),
'darkgoldenrod2'=>array(238,173,14),
'darkgoldenrod3'=>array(205,149,12),
'darkgoldenrod4'=>array(139,101,8),
'rosybrown1'=>array(255,193,193),
'rosybrown2'=>array(238,180,180),
'rosybrown3'=>array(205,155,155),
'rosybrown4'=>array(139,105,105),
'indianred1'=>array(255,106,106),
'indianred2'=>array(238,99,99),
'indianred3'=>array(205,85,85),
'indianred4'=>array(139,58,58),
'sienna1'=>array(255,130,71),
'sienna2'=>array(238,121,66),
'sienna3'=>array(205,104,57),
'sienna4'=>array(139,71,38),
'burlywood1'=>array(255,211,155),
'burlywood2'=>array(238,197,145),
'burlywood3'=>array(205,170,125),
'burlywood4'=>array(139,115,85),
'wheat1'=>array(255,231,186),
'wheat2'=>array(238,216,174),
'wheat3'=>array(205,186,150),
'wheat4'=>array(139,126,102),
'tan1'=>array(255,165,79),
'tan2'=>array(238,154,73),
'tan3'=>array(205,133,63),
'tan4'=>array(139,90,43),
'chocolate1'=>array(255,127,36),
'chocolate2'=>array(238,118,33),
'chocolate3'=>array(205,102,29),
'chocolate4'=>array(139,69,19),
'firebrick1'=>array(255,48,48),
'firebrick2'=>array(238,44,44),
'firebrick3'=>array(205,38,38),
'firebrick4'=>array(139,26,26),
'brown1'=>array(255,64,64),
'brown2'=>array(238,59,59),
'brown3'=>array(205,51,51),
'brown4'=>array(139,35,35),
'salmon1'=>array(255,140,105),
'salmon2'=>array(238,130,98),
'salmon3'=>array(205,112,84),
'salmon4'=>array(139,76,57),
'lightsalmon1'=>array(255,160,122),
'lightsalmon2'=>array(238,149,114),
'lightsalmon3'=>array(205,129,98),
'lightsalmon4'=>array(139,87,66),
'orange1'=>array(255,165,0),
'orange2'=>array(238,154,0),
'orange3'=>array(205,133,0),
'orange4'=>array(139,90,0),
'darkorange1'=>array(255,127,0),
'darkorange2'=>array(238,118,0),
'darkorange3'=>array(205,102,0),
'darkorange4'=>array(139,69,0),
'coral1'=>array(255,114,86),
'coral2'=>array(238,106,80),
'coral3'=>array(205,91,69),
'coral4'=>array(139,62,47),
'tomato1'=>array(255,99,71),
'tomato2'=>array(238,92,66),
'tomato3'=>array(205,79,57),
'tomato4'=>array(139,54,38),
'orangered1'=>array(255,69,0),
'orangered2'=>array(238,64,0),
'orangered3'=>array(205,55,0),
'orangered4'=>array(139,37,0),
'deeppink1'=>array(255,20,147),
'deeppink2'=>array(238,18,137),
'deeppink3'=>array(205,16,118),
'deeppink4'=>array(139,10,80),
'hotpink1'=>array(255,110,180),
'hotpink2'=>array(238,106,167),
'hotpink3'=>array(205,96,144),
'hotpink4'=>array(139,58,98),
'pink1'=>array(255,181,197),
'pink2'=>array(238,169,184),
'pink3'=>array(205,145,158),
'pink4'=>array(139,99,108),
'lightpink1'=>array(255,174,185),
'lightpink2'=>array(238,162,173),
'lightpink3'=>array(205,140,149),
'lightpink4'=>array(139,95,101),
'palevioletred1'=>array(255,130,171),
'palevioletred2'=>array(238,121,159),
'palevioletred3'=>array(205,104,137),
'palevioletred4'=>array(139,71,93),
'maroon1'=>array(255,52,179),
'maroon2'=>array(238,48,167),
'maroon3'=>array(205,41,144),
'maroon4'=>array(139,28,98),
'violetred1'=>array(255,62,150),
'violetred2'=>array(238,58,140),
'violetred3'=>array(205,50,120),
'violetred4'=>array(139,34,82),
'magenta1'=>array(255,0,255),
'magenta2'=>array(238,0,238),
'magenta3'=>array(205,0,205),
'magenta4'=>array(139,0,139),
'mediumred'=>array(140,34,34),
'orchid1'=>array(255,131,250),
'orchid2'=>array(238,122,233),
'orchid3'=>array(205,105,201),
'orchid4'=>array(139,71,137),
'plum1'=>array(255,187,255),
'plum2'=>array(238,174,238),
'plum3'=>array(205,150,205),
'plum4'=>array(139,102,139),
'mediumorchid1'=>array(224,102,255),
'mediumorchid2'=>array(209,95,238),
'mediumorchid3'=>array(180,82,205),
'mediumorchid4'=>array(122,55,139),
'darkorchid1'=>array(191,62,255),
'darkorchid2'=>array(178,58,238),
'darkorchid3'=>array(154,50,205),
'darkorchid4'=>array(104,34,139),
'purple1'=>array(155,48,255),
'purple2'=>array(145,44,238),
'purple3'=>array(125,38,205),
'purple4'=>array(85,26,139),
'mediumpurple1'=>array(171,130,255),
'mediumpurple2'=>array(159,121,238),
'mediumpurple3'=>array(137,104,205),
'mediumpurple4'=>array(93,71,139),
'thistle1'=>array(255,225,255),
'thistle2'=>array(238,210,238),
'thistle3'=>array(205,181,205),
'thistle4'=>array(139,123,139),
'gray1'=>array(10,10,10),
'gray2'=>array(40,40,30),
'gray3'=>array(70,70,70),
'gray4'=>array(100,100,100),
'gray5'=>array(130,130,130),
'gray6'=>array(160,160,160),
'gray7'=>array(190,190,190),
'gray8'=>array(210,210,210),
'gray9'=>array(240,240,240),
'darkgray'=>array(100,100,100),
'darkblue'=>array(0,0,139),
'darkcyan'=>array(0,139,139),
'darkmagenta'=>array(139,0,139),
'darkred'=>array(139,0,0),
'silver'=>array(192, 192, 192),
'eggplant'=>array(144,176,168),
'lightgreen'=>array(144,238,144));
}
//----------------
// PUBLIC METHODS
// Colors can be specified as either
// 1. #xxxxxx HTML style
// 2. "colorname" as a named color
// 3. array(r,g,b) RGB triple
// This function translates this to a native RGB format and returns an
// RGB triple.
function Color($aColor) {
if (is_string($aColor)) {
$matches = array();
// this regex will parse a color string and fill the $matches array as such:
// 0: the full match if any
// 1: a hex string preceded by a hash, can be 3 characters (#fff) or 6 (#ffffff) (4 or 5 also accepted but...)
// 2,3,4: r,g,b values in hex if the first character of the string is #
// 5: all alpha-numeric characters at the beginning of the string if string does not start with #
// 6: alpha value prefixed by @ if supplied
// 7: alpha value with @ stripped
// 8: adjust value prefixed with : if supplied
// 9: adjust value with : stripped
$regex = '/(#([0-9a-fA-F]{1,2})([0-9a-fA-F]{1,2})([0-9a-fA-F]{1,2}))?([\w]+)?(@([\d\.,]+))?(:([\d\.,]+))?/';
if(!preg_match($regex, $aColor, $matches)) {
JpGraphError::RaiseL(25078,$aColor);//(" Unknown color: $aColor");
}
if(empty($matches[5])) {
$r = strlen($matches[2]) == 1 ? $matches[2].$matches[2] : $matches[2];
$g = strlen($matches[3]) == 1 ? $matches[3].$matches[3] : $matches[3];
$b = strlen($matches[4]) == 1 ? $matches[4].$matches[4] : $matches[4];
$r = hexdec($r);
$g = hexdec($g);
$b = hexdec($b);
}else {
if(!isset($this->rgb_table[$matches[5]]) ) {
JpGraphError::RaiseL(25078,$aColor);//(" Unknown color: $aColor");
}
$r = $this->rgb_table[$matches[5]][0];
$g = $this->rgb_table[$matches[5]][1];
$b = $this->rgb_table[$matches[5]][2];
}
$alpha = isset($matches[7]) ? str_replace(',','.',$matches[7]) : 0;
$adj = isset($matches[9]) ? str_replace(',','.',$matches[9]) : 1.0;
if( $adj < 0 ) {
JpGraphError::RaiseL(25077);//('Adjustment factor for color must be > 0');
}
// Scale adj so that an adj=2 always
// makes the color 100% white (i.e. 255,255,255.
// and adj=1 neutral and adj=0 black.
if( $adj == 1) {
return array($r,$g,$b,$alpha);
}
elseif( $adj > 1 ) {
$m = ($adj-1.0)*(255-min(255,min($r,min($g,$b))));
return array(min(255,$r+$m), min(255,$g+$m), min(255,$b+$m),$alpha);
}
elseif( $adj < 1 ) {
$m = ($adj-1.0)*max(255,max($r,max($g,$b)));
return array(max(0,$r+$m), max(0,$g+$m), max(0,$b+$m),$alpha);
}
} elseif( is_array($aColor) ) {
if(!isset($aColor[3])) $aColor[3] = 0;
return $aColor;
}
else {
JpGraphError::RaiseL(25079,$aColor,count($aColor));//(" Unknown color specification: $aColor , size=".count($aColor));
}
}
// Compare two colors
// return true if equal
function Equal($aCol1,$aCol2) {
$c1 = $this->Color($aCol1);
$c2 = $this->Color($aCol2);
return $c1[0]==$c2[0] && $c1[1]==$c2[1] && $c1[2]==$c2[2] ;
}
// Allocate a new color in the current image
// Return new color index, -1 if no more colors could be allocated
function Allocate($aColor,$aAlpha=0.0) {
list ($r, $g, $b, $a) = $this->color($aColor);
// If alpha is specified in the color string then this
// takes precedence over the second argument
if( $a > 0 ) {
$aAlpha = $a;
}
if( $aAlpha < 0 || $aAlpha > 1 ) {
JpGraphError::RaiseL(25080);//('Alpha parameter for color must be between 0.0 and 1.0');
}
return imagecolorresolvealpha($this->img, $r, $g, $b, round($aAlpha * 127));
}
// Try to convert an array with three valid numbers to the corresponding hex array
// This is currenly only used in processing the colors for barplots in order to be able
// to handle the case where the color might be specified as an array of colros as well.
// In that case we must be able to find out if an array of values should be interpretated as
// a single color (specifeid as an RGB triple)
static function tryHexConversion($aColor) {
if( is_array( $aColor ) ) {
if( count( $aColor ) == 3 ) {
if( is_numeric($aColor[0]) && is_numeric($aColor[1]) && is_numeric($aColor[2]) ) {
if( ($aColor[0] >= 0 && $aColor[0] <= 255) &&
($aColor[1] >= 0 && $aColor[1] <= 255) &&
($aColor[2] >= 0 && $aColor[2] <= 255) ) {
return sprintf('#%02x%02x%02x',$aColor[0],$aColor[1],$aColor[2]);
}
}
}
}
return $aColor;
}
// Return a RGB tripple corresponding to a position in the normal light spectrum
// The argumen values is in the range [0, 1] where a value of 0 correponds to blue and
// a value of 1 corresponds to red. Values in betwen is mapped to a linear interpolation
// of the constituting colors in the visible color spectra.
// The $aDynamicRange specified how much of the dynamic range we shold use
// a value of 1.0 give the full dyanmic range and a lower value give more dark
// colors. In the extreme of 0.0 then all colors will be black.
static function GetSpectrum($aVal,$aDynamicRange=1.0) {
if( $aVal < 0 || $aVal > 1.0001 ) {
return array(0,0,0); // Invalid case - just return black
}
$sat = round(255*$aDynamicRange);
$a = 0.25;
if( $aVal <= 0.25 ) {
return array(0, round($sat*$aVal/$a), $sat);
}
elseif( $aVal <= 0.5 ) {
return array(0, $sat, round($sat-$sat*($aVal-0.25)/$a));
}
elseif( $aVal <= 0.75 ) {
return array(round($sat*($aVal-0.5)/$a), $sat, 0);
}
else {
return array($sat, round($sat-$sat*($aVal-0.75)/$a), 0);
}
}
} // Class
?>

View File

@ -1,266 +0,0 @@
<?php
/**
* jpgraph_scatter.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_SCATTER.PHP
// Description: Scatter (and impuls) plot extension for JpGraph
// Created: 2001-02-11
// Ver: $Id: jpgraph_scatter.php 1397 2009-06-27 21:34:14Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once ('jpgraph_plotmark.inc.php');
//===================================================
// CLASS FieldArrow
// Description: Draw an arrow at (x,y) with angle a
//===================================================
class FieldArrow {
public $iColor='black';
public $iSize=10; // Length in pixels for arrow
public $iArrowSize = 2;
private $isizespec = array(
array(2,1),array(3,2),array(4,3),array(6,4),array(7,4),array(8,5),array(10,6),array(12,7),array(16,8),array(20,10)
);
function __construct() {
// Empty
}
function SetSize($aSize,$aArrowSize=2) {
$this->iSize = $aSize;
$this->iArrowSize = $aArrowSize;
}
function SetColor($aColor) {
$this->iColor = $aColor;
}
function Stroke($aImg,$x,$y,$a) {
// First rotate the center coordinates
list($x,$y) = $aImg->Rotate($x,$y);
$old_origin = $aImg->SetCenter($x,$y);
$old_a = $aImg->a;
$aImg->SetAngle(-$a+$old_a);
$dx = round($this->iSize/2);
$c = array($x-$dx,$y,$x+$dx,$y);
$x += $dx;
list($dx,$dy) = $this->isizespec[$this->iArrowSize];
$ca = array($x,$y,$x-$dx,$y-$dy,$x-$dx,$y+$dy,$x,$y);
$aImg->SetColor($this->iColor);
$aImg->Polygon($c);
$aImg->FilledPolygon($ca);
$aImg->SetCenter($old_origin[0],$old_origin[1]);
$aImg->SetAngle($old_a);
}
}
//===================================================
// CLASS FieldPlot
// Description: Render a field plot
//===================================================
class FieldPlot extends Plot {
public $arrow = '';
private $iAngles = array();
private $iCallback = '';
function __construct($datay,$datax,$angles) {
if( (count($datax) != count($datay)) )
JpGraphError::RaiseL(20001);//("Fieldplots must have equal number of X and Y points.");
if( (count($datax) != count($angles)) )
JpGraphError::RaiseL(20002);//("Fieldplots must have an angle specified for each X and Y points.");
$this->iAngles = $angles;
parent::__construct($datay,$datax);
$this->value->SetAlign('center','center');
$this->value->SetMargin(15);
$this->arrow = new FieldArrow();
}
function SetCallback($aFunc) {
$this->iCallback = $aFunc;
}
function Stroke($img,$xscale,$yscale) {
// Remeber base color and size
$bc = $this->arrow->iColor;
$bs = $this->arrow->iSize;
$bas = $this->arrow->iArrowSize;
for( $i=0; $i<$this->numpoints; ++$i ) {
// Skip null values
if( $this->coords[0][$i]==="" )
continue;
$f = $this->iCallback;
if( $f != "" ) {
list($cc,$cs,$cas) = call_user_func($f,$this->coords[1][$i],$this->coords[0][$i],$this->iAngles[$i]);
// Fall back on global data if the callback isn't set
if( $cc == "" ) $cc = $bc;
if( $cs == "" ) $cs = $bs;
if( $cas == "" ) $cas = $bas;
$this->arrow->SetColor($cc);
$this->arrow->SetSize($cs,$cas);
}
$xt = $xscale->Translate($this->coords[1][$i]);
$yt = $yscale->Translate($this->coords[0][$i]);
$this->arrow->Stroke($img,$xt,$yt,$this->iAngles[$i]);
$this->value->Stroke($img,$this->coords[0][$i],$xt,$yt);
}
}
// Framework function
function Legend($aGraph) {
if( $this->legend != "" ) {
$aGraph->legend->Add($this->legend,$this->mark->fill_color,$this->mark,0,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
}
}
}
//===================================================
// CLASS ScatterPlot
// Description: Render X and Y plots
//===================================================
class ScatterPlot extends Plot {
public $mark,$link;
private $impuls = false;
//---------------
// CONSTRUCTOR
function __construct($datay,$datax=false) {
if( (count($datax) != count($datay)) && is_array($datax)) {
JpGraphError::RaiseL(20003);//("Scatterplot must have equal number of X and Y points.");
}
parent::__construct($datay,$datax);
$this->mark = new PlotMark();
$this->mark->SetType(MARK_SQUARE);
$this->mark->SetColor($this->color);
$this->value->SetAlign('center','center');
$this->value->SetMargin(0);
$this->link = new LineProperty(1,'black','solid');
$this->link->iShow = false;
}
//---------------
// PUBLIC METHODS
function SetImpuls($f=true) {
$this->impuls = $f;
}
function SetStem($f=true) {
$this->impuls = $f;
}
// Combine the scatter plot points with a line
function SetLinkPoints($aFlag=true,$aColor="black",$aWeight=1,$aStyle='solid') {
$this->link->iShow = $aFlag;
$this->link->iColor = $aColor;
$this->link->iWeight = $aWeight;
$this->link->iStyle = $aStyle;
}
function Stroke($img,$xscale,$yscale) {
$ymin=$yscale->scale_abs[0];
if( $yscale->scale[0] < 0 )
$yzero=$yscale->Translate(0);
else
$yzero=$yscale->scale_abs[0];
$this->csimareas = '';
for( $i=0; $i<$this->numpoints; ++$i ) {
// Skip null values
if( $this->coords[0][$i]==='' || $this->coords[0][$i]==='-' || $this->coords[0][$i]==='x')
continue;
if( isset($this->coords[1]) )
$xt = $xscale->Translate($this->coords[1][$i]);
else
$xt = $xscale->Translate($i);
$yt = $yscale->Translate($this->coords[0][$i]);
if( $this->link->iShow && isset($yt_old) ) {
$img->SetColor($this->link->iColor);
$img->SetLineWeight($this->link->iWeight);
$old = $img->SetLineStyle($this->link->iStyle);
$img->StyleLine($xt_old,$yt_old,$xt,$yt);
$img->SetLineStyle($old);
}
if( $this->impuls ) {
$img->SetColor($this->color);
$img->SetLineWeight($this->weight);
$img->Line($xt,$yzero,$xt,$yt);
}
if( !empty($this->csimtargets[$i]) ) {
if( !empty($this->csimwintargets[$i]) ) {
$this->mark->SetCSIMTarget($this->csimtargets[$i],$this->csimwintargets[$i]);
}
else {
$this->mark->SetCSIMTarget($this->csimtargets[$i]);
}
$this->mark->SetCSIMAlt($this->csimalts[$i]);
}
if( isset($this->coords[1]) ) {
$this->mark->SetCSIMAltVal($this->coords[0][$i],$this->coords[1][$i]);
}
else {
$this->mark->SetCSIMAltVal($this->coords[0][$i],$i);
}
$this->mark->Stroke($img,$xt,$yt);
$this->csimareas .= $this->mark->GetCSIMAreas();
$this->value->Stroke($img,$this->coords[0][$i],$xt,$yt);
$xt_old = $xt;
$yt_old = $yt;
}
}
// Framework function
function Legend($aGraph) {
if( $this->legend != "" ) {
$aGraph->legend->Add($this->legend,$this->mark->fill_color,$this->mark,0,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
}
}
} // Class
/* EOF */
?>

View File

@ -1,222 +0,0 @@
<?php
/**
* jpgraph_stock.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_STOCK.PHP
// Description: Stock plot extension for JpGraph
// Created: 2003-01-27
// Ver: $Id: jpgraph_stock.php 1364 2009-06-24 07:07:44Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
//===================================================
// CLASS StockPlot
//===================================================
class StockPlot extends Plot {
protected $iTupleSize = 4;
private $iWidth=9;
private $iEndLines=1;
private $iStockColor1='white',$iStockColor2='darkred',$iStockColor3='darkred';
//---------------
// CONSTRUCTOR
function __construct($datay,$datax=false) {
if( count($datay) % $this->iTupleSize ) {
JpGraphError::RaiseL(21001,$this->iTupleSize);
//('Data values for Stock charts must contain an even multiple of '.$this->iTupleSize.' data points.');
}
parent::__construct($datay,$datax);
$this->numpoints /= $this->iTupleSize;
}
//---------------
// PUBLIC METHODS
function SetColor($aColor,$aColor1='white',$aColor2='darkred',$aColor3='darkred') {
$this->color = $aColor;
$this->iStockColor1 = $aColor1;
$this->iStockColor2 = $aColor2;
$this->iStockColor3 = $aColor3;
}
function SetWidth($aWidth) {
// Make sure it's odd
$this->iWidth = 2*floor($aWidth/2)+1;
}
function HideEndLines($aHide=true) {
$this->iEndLines = !$aHide;
}
// Gets called before any axis are stroked
function PreStrokeAdjust($graph) {
if( $this->center ) {
$a=0.5; $b=0.5;
$this->numpoints++;
} else {
$a=0; $b=0;
}
$graph->xaxis->scale->ticks->SetXLabelOffset($a);
$graph->SetTextScaleOff($b);
}
// Method description
function Stroke($img,$xscale,$yscale) {
$n=$this->numpoints;
if( $this->center ) $n--;
if( isset($this->coords[1]) ) {
if( count($this->coords[1])!=$n ) {
JpGraphError::RaiseL(2003,count($this->coords[1]),$n);
// ("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
}
else {
$exist_x = true;
}
}
else {
$exist_x = false;
}
if( $exist_x ) {
$xs=$this->coords[1][0];
}
else {
$xs=0;
}
$ts = $this->iTupleSize;
$this->csimareas = '';
for( $i=0; $i<$n; ++$i) {
//If value is NULL, then don't draw a bar at all
if ($this->coords[0][$i*$ts] === null) continue;
if( $exist_x ) {
$x=$this->coords[1][$i];
if ($x === null) continue;
}
else {
$x=$i;
}
$xt = $xscale->Translate($x);
$neg = $this->coords[0][$i*$ts] > $this->coords[0][$i*$ts+1] ;
$yopen = $yscale->Translate($this->coords[0][$i*$ts]);
$yclose = $yscale->Translate($this->coords[0][$i*$ts+1]);
$ymin = $yscale->Translate($this->coords[0][$i*$ts+2]);
$ymax = $yscale->Translate($this->coords[0][$i*$ts+3]);
$dx = floor($this->iWidth/2);
$xl = $xt - $dx;
$xr = $xt + $dx;
if( $neg ) {
$img->SetColor($this->iStockColor3);
}
else {
$img->SetColor($this->iStockColor1);
}
$img->FilledRectangle($xl,$yopen,$xr,$yclose);
$img->SetLineWeight($this->weight);
if( $neg ) {
$img->SetColor($this->iStockColor2);
}
else {
$img->SetColor($this->color);
}
$img->Rectangle($xl,$yopen,$xr,$yclose);
if( $yopen < $yclose ) {
$ytop = $yopen ;
$ybottom = $yclose ;
}
else {
$ytop = $yclose ;
$ybottom = $yopen ;
}
$img->SetColor($this->color);
$img->Line($xt,$ytop,$xt,$ymax);
$img->Line($xt,$ybottom,$xt,$ymin);
if( $this->iEndLines ) {
$img->Line($xl,$ymax,$xr,$ymax);
$img->Line($xl,$ymin,$xr,$ymin);
}
// A chance for subclasses to add things to the bar
// for data point i
$this->ModBox($img,$xscale,$yscale,$i,$xl,$xr,$neg);
// Setup image maps
if( !empty($this->csimtargets[$i]) ) {
$this->csimareas.= '<area shape="rect" coords="'.
round($xl).','.round($ytop).','.
round($xr).','.round($ybottom).'" ';
$this->csimareas .= ' href="'.$this->csimtargets[$i].'"';
if( !empty($this->csimalts[$i]) ) {
$sval=$this->csimalts[$i];
$this->csimareas .= " title=\"$sval\" alt=\"$sval\" ";
}
$this->csimareas.= " />\n";
}
}
return true;
}
// A hook for subclasses to modify the plot
function ModBox($img,$xscale,$yscale,$i,$xl,$xr,$neg) {}
} // Class
//===================================================
// CLASS BoxPlot
//===================================================
class BoxPlot extends StockPlot {
private $iPColor='black',$iNColor='white';
function __construct($datay,$datax=false) {
$this->iTupleSize=5;
parent::__construct($datay,$datax);
}
function SetMedianColor($aPos,$aNeg) {
$this->iPColor = $aPos;
$this->iNColor = $aNeg;
}
function ModBox($img,$xscale,$yscale,$i,$xl,$xr,$neg) {
if( $neg )
$img->SetColor($this->iNColor);
else
$img->SetColor($this->iPColor);
$y = $yscale->Translate($this->coords[0][$i*5+4]);
$img->Line($xl,$y,$xr,$y);
}
}
/* EOF */
?>

View File

@ -1,326 +0,0 @@
<?php
/**
* jpgraph_text.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: JPGRAPH_TEXT.INC.PHP
// Description: Class to handle text as object in the graph.
// The low level text layout engine is handled by the GD class
// Created: 2001-01-08 (Refactored to separate file 2008-08-01)
// Ver: $Id: jpgraph_text.inc.php 1844 2009-09-26 17:05:31Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
//===================================================
// CLASS Text
// Description: Arbitrary text object that can be added to the graph
//===================================================
class Text {
public $t,$margin=0;
public $x=0,$y=0,$halign="left",$valign="top",$color=array(0,0,0);
public $hide=false, $dir=0;
public $iScalePosY=null,$iScalePosX=null;
public $iWordwrap=0;
public $font_family=FF_FONT1,$font_style=FS_NORMAL,$font_size=12;
protected $boxed=false; // Should the text be boxed
protected $paragraph_align="left";
protected $icornerradius=0,$ishadowwidth=3;
protected $fcolor='white',$bcolor='black',$shadow=false;
protected $iCSIMarea='',$iCSIMalt='',$iCSIMtarget='',$iCSIMWinTarget='';
private $iBoxType = 1; // Which variant of filled box around text we want
//---------------
// CONSTRUCTOR
// Create new text at absolute pixel coordinates
function __construct($aTxt="",$aXAbsPos=0,$aYAbsPos=0) {
if( ! is_string($aTxt) ) {
JpGraphError::RaiseL(25050);//('First argument to Text::Text() must be s atring.');
}
$this->t = $aTxt;
$this->x = round($aXAbsPos);
$this->y = round($aYAbsPos);
$this->margin = 0;
}
//---------------
// PUBLIC METHODS
// Set the string in the text object
function Set($aTxt) {
$this->t = $aTxt;
}
// Alias for Pos()
function SetPos($aXAbsPos=0,$aYAbsPos=0,$aHAlign="left",$aVAlign="top") {
//$this->Pos($aXAbsPos,$aYAbsPos,$aHAlign,$aVAlign);
$this->x = $aXAbsPos;
$this->y = $aYAbsPos;
$this->halign = $aHAlign;
$this->valign = $aVAlign;
}
function SetScalePos($aX,$aY) {
$this->iScalePosX = $aX;
$this->iScalePosY = $aY;
}
// Specify alignment for the text
function Align($aHAlign,$aVAlign="top",$aParagraphAlign="") {
$this->halign = $aHAlign;
$this->valign = $aVAlign;
if( $aParagraphAlign != "" )
$this->paragraph_align = $aParagraphAlign;
}
// Alias
function SetAlign($aHAlign,$aVAlign="top",$aParagraphAlign="") {
$this->Align($aHAlign,$aVAlign,$aParagraphAlign);
}
// Specifies the alignment for a multi line text
function ParagraphAlign($aAlign) {
$this->paragraph_align = $aAlign;
}
// Specifies the alignment for a multi line text
function SetParagraphAlign($aAlign) {
$this->paragraph_align = $aAlign;
}
function SetShadow($aShadowColor='gray',$aShadowWidth=3) {
$this->ishadowwidth=$aShadowWidth;
$this->shadow=$aShadowColor;
$this->boxed=true;
}
function SetWordWrap($aCol) {
$this->iWordwrap = $aCol ;
}
// Specify that the text should be boxed. fcolor=frame color, bcolor=border color,
// $shadow=drop shadow should be added around the text.
function SetBox($aFrameColor=array(255,255,255),$aBorderColor=array(0,0,0),$aShadowColor=false,$aCornerRadius=4,$aShadowWidth=3) {
if( $aFrameColor === false ) {
$this->boxed=false;
}
else {
$this->boxed=true;
}
$this->fcolor=$aFrameColor;
$this->bcolor=$aBorderColor;
// For backwards compatibility when shadow was just true or false
if( $aShadowColor === true ) {
$aShadowColor = 'gray';
}
$this->shadow=$aShadowColor;
$this->icornerradius=$aCornerRadius;
$this->ishadowwidth=$aShadowWidth;
}
function SetBox2($aFrameColor=array(255,255,255),$aBorderColor=array(0,0,0),$aShadowColor=false,$aCornerRadius=4,$aShadowWidth=3) {
$this->iBoxType=2;
$this->SetBox($aFrameColor,$aBorderColor,$aShadowColor,$aCornerRadius,$aShadowWidth);
}
// Hide the text
function Hide($aHide=true) {
$this->hide=$aHide;
}
// This looks ugly since it's not a very orthogonal design
// but I added this "inverse" of Hide() to harmonize
// with some classes which I designed more recently (especially)
// jpgraph_gantt
function Show($aShow=true) {
$this->hide=!$aShow;
}
// Specify font
function SetFont($aFamily,$aStyle=FS_NORMAL,$aSize=10) {
$this->font_family=$aFamily;
$this->font_style=$aStyle;
$this->font_size=$aSize;
}
// Center the text between $left and $right coordinates
function Center($aLeft,$aRight,$aYAbsPos=false) {
$this->x = $aLeft + ($aRight-$aLeft )/2;
$this->halign = "center";
if( is_numeric($aYAbsPos) )
$this->y = $aYAbsPos;
}
// Set text color
function SetColor($aColor) {
$this->color = $aColor;
}
function SetAngle($aAngle) {
$this->SetOrientation($aAngle);
}
// Orientation of text. Note only TTF fonts can have an arbitrary angle
function SetOrientation($aDirection=0) {
if( is_numeric($aDirection) )
$this->dir=$aDirection;
elseif( $aDirection=="h" )
$this->dir = 0;
elseif( $aDirection=="v" )
$this->dir = 90;
else
JpGraphError::RaiseL(25051);//(" Invalid direction specified for text.");
}
// Total width of text
function GetWidth($aImg) {
$aImg->SetFont($this->font_family,$this->font_style,$this->font_size);
$w = $aImg->GetTextWidth($this->t,$this->dir);
return $w;
}
// Hight of font
function GetFontHeight($aImg) {
$aImg->SetFont($this->font_family,$this->font_style,$this->font_size);
$h = $aImg->GetFontHeight();
return $h;
}
function GetTextHeight($aImg) {
$aImg->SetFont($this->font_family,$this->font_style,$this->font_size);
$h = $aImg->GetTextHeight($this->t,$this->dir);
return $h;
}
function GetHeight($aImg) {
// Synonym for GetTextHeight()
$aImg->SetFont($this->font_family,$this->font_style,$this->font_size);
$h = $aImg->GetTextHeight($this->t,$this->dir);
return $h;
}
// Set the margin which will be interpretated differently depending
// on the context.
function SetMargin($aMarg) {
$this->margin = $aMarg;
}
function StrokeWithScale($aImg,$axscale,$ayscale) {
if( $this->iScalePosX === null || $this->iScalePosY === null ) {
$this->Stroke($aImg);
}
else {
$this->Stroke($aImg,
round($axscale->Translate($this->iScalePosX)),
round($ayscale->Translate($this->iScalePosY)));
}
}
function SetCSIMTarget($aURITarget,$aAlt='',$aWinTarget='') {
$this->iCSIMtarget = $aURITarget;
$this->iCSIMalt = $aAlt;
$this->iCSIMWinTarget = $aWinTarget;
}
function GetCSIMareas() {
if( $this->iCSIMtarget !== '' ) {
return $this->iCSIMarea;
}
else {
return '';
}
}
// Display text in image
function Stroke($aImg,$x=null,$y=null) {
if( $x !== null ) $this->x = round($x);
if( $y !== null ) $this->y = round($y);
// Insert newlines
if( $this->iWordwrap > 0 ) {
$this->t = wordwrap($this->t,$this->iWordwrap,"\n");
}
// If position been given as a fraction of the image size
// calculate the absolute position
if( $this->x < 1 && $this->x > 0 ) $this->x *= $aImg->width;
if( $this->y < 1 && $this->y > 0 ) $this->y *= $aImg->height;
$aImg->PushColor($this->color);
$aImg->SetFont($this->font_family,$this->font_style,$this->font_size);
$aImg->SetTextAlign($this->halign,$this->valign);
if( $this->boxed ) {
if( $this->fcolor=="nofill" ) {
$this->fcolor=false;
}
$oldweight=$aImg->SetLineWeight(1);
if( $this->iBoxType == 2 && $this->font_family > FF_FONT2+2 ) {
$bbox = $aImg->StrokeBoxedText2($this->x, $this->y,
$this->t, $this->dir,
$this->fcolor,
$this->bcolor,
$this->shadow,
$this->paragraph_align,
2,4,
$this->icornerradius,
$this->ishadowwidth);
}
else {
$bbox = $aImg->StrokeBoxedText($this->x,$this->y,$this->t,
$this->dir,$this->fcolor,$this->bcolor,$this->shadow,
$this->paragraph_align,3,3,$this->icornerradius,
$this->ishadowwidth);
}
$aImg->SetLineWeight($oldweight);
}
else {
$debug=false;
$bbox = $aImg->StrokeText($this->x,$this->y,$this->t,$this->dir,$this->paragraph_align,$debug);
}
// Create CSIM targets
$coords = $bbox[0].','.$bbox[1].','.$bbox[2].','.$bbox[3].','.$bbox[4].','.$bbox[5].','.$bbox[6].','.$bbox[7];
$this->iCSIMarea = "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($this->iCSIMtarget)."\" ";
if( trim($this->iCSIMalt) != '' ) {
$this->iCSIMarea .= " alt=\"".$this->iCSIMalt."\" ";
$this->iCSIMarea .= " title=\"".$this->iCSIMalt."\" ";
}
if( trim($this->iCSIMWinTarget) != '' ) {
$this->iCSIMarea .= " target=\"".$this->iCSIMWinTarget."\" ";
}
$this->iCSIMarea .= " />\n";
$aImg->PopColor($this->color);
}
} // Class
?>

View File

@ -1,641 +0,0 @@
<?php
/**
* jpgraph_ttf.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
//=======================================================================
// File: jpgraph_ttf.inc.php
// Description: Handling of TTF fonts
// Created: 2006-11-19
// Ver: $Id: jpgraph_ttf.inc.php 1858 2009-09-28 14:39:51Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
// TTF Font families
define("FF_COURIER",10);
define("FF_VERDANA",11);
define("FF_TIMES",12);
define("FF_COMIC",14);
define("FF_ARIAL",15);
define("FF_GEORGIA",16);
define("FF_TREBUCHE",17);
// Gnome Vera font
// Available from http://www.gnome.org/fonts/
define("FF_VERA",18);
define("FF_VERAMONO",19);
define("FF_VERASERIF",20);
// Chinese font
define("FF_SIMSUN",30);
define("FF_CHINESE",31);
define("FF_BIG5",32);
// Japanese font
define("FF_MINCHO",40);
define("FF_PMINCHO",41);
define("FF_GOTHIC",42);
define("FF_PGOTHIC",43);
// Hebrew fonts
define("FF_DAVID",44);
define("FF_MIRIAM",45);
define("FF_AHRON",46);
// Dejavu-fonts http://sourceforge.net/projects/dejavu
define("FF_DV_SANSSERIF",47);
define("FF_DV_SERIF",48);
define("FF_DV_SANSSERIFMONO",49);
define("FF_DV_SERIFCOND",50);
define("FF_DV_SANSSERIFCOND",51);
// Extra fonts
// Download fonts from
// http://www.webfontlist.com
// http://www.webpagepublicity.com/free-fonts.html
// http://www.fontonic.com/fonts.asp?width=d&offset=120
// http://www.fontspace.com/category/famous
// define("FF_SPEEDO",71); // This font is also known as Bauer (Used for development gauge fascia)
define("FF_DIGITAL",72); // Digital readout font
define("FF_COMPUTER",73); // The classic computer font
define("FF_CALCULATOR",74); // Triad font
define("FF_USERFONT",90);
define("FF_USERFONT1",90);
define("FF_USERFONT2",91);
define("FF_USERFONT3",92);
// Limits for fonts
define("_FIRST_FONT",10);
define("_LAST_FONT",99);
// TTF Font styles
define("FS_NORMAL",9001);
define("FS_BOLD",9002);
define("FS_ITALIC",9003);
define("FS_BOLDIT",9004);
define("FS_BOLDITALIC",9004);
//Definitions for internal font
define("FF_FONT0",1);
define("FF_FONT1",2);
define("FF_FONT2",4);
//------------------------------------------------------------------------
// Defines for font setup
//------------------------------------------------------------------------
// Actual name of the TTF file used together with FF_CHINESE aka FF_BIG5
// This is the TTF file being used when the font family is specified as
// either FF_CHINESE or FF_BIG5
define('CHINESE_TTF_FONT','bkai00mp.ttf');
// Special unicode greek language support
define("LANGUAGE_GREEK",false);
// If you are setting this config to true the conversion of greek characters
// will assume that the input text is windows 1251
define("GREEK_FROM_WINDOWS",false);
// Special unicode cyrillic language support
define("LANGUAGE_CYRILLIC",false);
// If you are setting this config to true the conversion
// will assume that the input text is windows 1251, if
// false it will assume koi8-r
define("CYRILLIC_FROM_WINDOWS",false);
// The following constant is used to auto-detect
// whether cyrillic conversion is really necessary
// if enabled. Just replace 'windows-1251' with a variable
// containing the input character encoding string
// of your application calling jpgraph.
// A typical such string would be 'UTF-8' or 'utf-8'.
// The comparison is case-insensitive.
// If this charset is not a 'koi8-r' or 'windows-1251'
// derivate then no conversion is done.
//
// This constant can be very important in multi-user
// multi-language environments where a cyrillic conversion
// could be needed for some cyrillic people
// and resulting in just erraneous conversions
// for not-cyrillic language based people.
//
// Example: In the free project management
// software dotproject.net $locale_char_set is dynamically
// set by the language environment the user has chosen.
//
// Usage: define('LANGUAGE_CHARSET', $locale_char_set);
//
// where $locale_char_set is a GLOBAL (string) variable
// from the application including JpGraph.
//
define('LANGUAGE_CHARSET', null);
// Japanese TrueType font used with FF_MINCHO, FF_PMINCHO, FF_GOTHIC, FF_PGOTHIC
// Standard fonts from Infomation-technology Promotion Agency (IPA)
// See http://mix-mplus-ipa.sourceforge.jp/
define('MINCHO_TTF_FONT','ipam.ttf');
define('PMINCHO_TTF_FONT','ipamp.ttf');
define('GOTHIC_TTF_FONT','ipag.ttf');
define('PGOTHIC_TTF_FONT','ipagp.ttf');
// Assume that Japanese text have been entered in EUC-JP encoding.
// If this define is true then conversion from EUC-JP to UTF8 is done
// automatically in the library using the mbstring module in PHP.
define('ASSUME_EUCJP_ENCODING',false);
//=================================================================
// CLASS LanguageConv
// Description:
// Converts various character encoding into proper
// UTF-8 depending on how the library have been configured and
// what font family is being used
//=================================================================
class LanguageConv {
private $g2312 = null ;
function Convert($aTxt,$aFF) {
if( LANGUAGE_GREEK ) {
if( GREEK_FROM_WINDOWS ) {
$unistring = LanguageConv::gr_win2uni($aTxt);
} else {
$unistring = LanguageConv::gr_iso2uni($aTxt);
}
return $unistring;
} elseif( LANGUAGE_CYRILLIC ) {
if( CYRILLIC_FROM_WINDOWS && (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'windows-1251')) ) {
$aTxt = convert_cyr_string($aTxt, "w", "k");
}
if( !defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'koi8-r') || stristr(LANGUAGE_CHARSET, 'windows-1251')) {
$isostring = convert_cyr_string($aTxt, "k", "i");
$unistring = LanguageConv::iso2uni($isostring);
}
else {
$unistring = $aTxt;
}
return $unistring;
}
elseif( $aFF === FF_SIMSUN ) {
// Do Chinese conversion
if( $this->g2312 == null ) {
include_once 'jpgraph_gb2312.php' ;
$this->g2312 = new GB2312toUTF8();
}
return $this->g2312->gb2utf8($aTxt);
}
elseif( $aFF === FF_BIG5 ) {
if( !function_exists('iconv') ) {
JpGraphError::RaiseL(25006);
//('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
}
return iconv('BIG5','UTF-8',$aTxt);
}
elseif( ASSUME_EUCJP_ENCODING &&
($aFF == FF_MINCHO || $aFF == FF_GOTHIC || $aFF == FF_PMINCHO || $aFF == FF_PGOTHIC) ) {
if( !function_exists('mb_convert_encoding') ) {
JpGraphError::RaiseL(25127);
}
return mb_convert_encoding($aTxt, 'UTF-8','EUC-JP');
}
elseif( $aFF == FF_DAVID || $aFF == FF_MIRIAM || $aFF == FF_AHRON ) {
return LanguageConv::heb_iso2uni($aTxt);
}
else
return $aTxt;
}
// Translate iso encoding to unicode
public static function iso2uni ($isoline){
$uniline='';
for ($i=0; $i < strlen($isoline); $i++){
$thischar=substr($isoline,$i,1);
$charcode=ord($thischar);
$uniline.=($charcode>175) ? "&#" . (1040+($charcode-176)). ";" : $thischar;
}
return $uniline;
}
// Translate greek iso encoding to unicode
public static function gr_iso2uni ($isoline) {
$uniline='';
for ($i=0; $i < strlen($isoline); $i++) {
$thischar=substr($isoline,$i,1);
$charcode=ord($thischar);
$uniline.=($charcode>179 && $charcode!=183 && $charcode!=187 && $charcode!=189) ? "&#" . (900+($charcode-180)). ";" : $thischar;
}
return $uniline;
}
// Translate greek win encoding to unicode
public static function gr_win2uni ($winline) {
$uniline='';
for ($i=0; $i < strlen($winline); $i++) {
$thischar=substr($winline,$i,1);
$charcode=ord($thischar);
if ($charcode==161 || $charcode==162) {
$uniline.="&#" . (740+$charcode). ";";
}
else {
$uniline.=(($charcode>183 && $charcode!=187 && $charcode!=189) || $charcode==180) ? "&#" . (900+($charcode-180)). ";" : $thischar;
}
}
return $uniline;
}
public static function heb_iso2uni($isoline) {
$isoline = hebrev($isoline);
$o = '';
$n = strlen($isoline);
for($i=0; $i < $n; $i++) {
$c=ord( substr($isoline,$i,1) );
$o .= ($c > 223) && ($c < 251) ? '&#'.(1264+$c).';' : chr($c);
}
return utf8_encode($o);
}
}
//=============================================================
// CLASS TTF
// Description: Handle TTF font names and mapping and loading of
// font files
//=============================================================
class TTF {
private $font_files,$style_names;
function __construct() {
// String names for font styles to be used in error messages
$this->style_names=array(
FS_NORMAL =>'normal',
FS_BOLD =>'bold',
FS_ITALIC =>'italic',
FS_BOLDITALIC =>'bolditalic');
// File names for available fonts
$this->font_files=array(
FF_COURIER => array(FS_NORMAL =>'cour.ttf',
FS_BOLD =>'courbd.ttf',
FS_ITALIC =>'couri.ttf',
FS_BOLDITALIC =>'courbi.ttf' ),
FF_GEORGIA => array(FS_NORMAL =>'georgia.ttf',
FS_BOLD =>'georgiab.ttf',
FS_ITALIC =>'georgiai.ttf',
FS_BOLDITALIC =>'' ),
FF_TREBUCHE =>array(FS_NORMAL =>'trebuc.ttf',
FS_BOLD =>'trebucbd.ttf',
FS_ITALIC =>'trebucit.ttf',
FS_BOLDITALIC =>'trebucbi.ttf' ),
FF_VERDANA => array(FS_NORMAL =>'verdana.ttf',
FS_BOLD =>'verdanab.ttf',
FS_ITALIC =>'verdanai.ttf',
FS_BOLDITALIC =>'' ),
FF_TIMES => array(FS_NORMAL =>'times.ttf',
FS_BOLD =>'timesbd.ttf',
FS_ITALIC =>'timesi.ttf',
FS_BOLDITALIC =>'timesbi.ttf' ),
FF_COMIC => array(FS_NORMAL =>'comic.ttf',
FS_BOLD =>'comicbd.ttf',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_ARIAL => array(FS_NORMAL =>'arial.ttf',
FS_BOLD =>'arialbd.ttf',
FS_ITALIC =>'ariali.ttf',
FS_BOLDITALIC =>'arialbi.ttf' ) ,
FF_VERA => array(FS_NORMAL =>'Vera.ttf',
FS_BOLD =>'VeraBd.ttf',
FS_ITALIC =>'VeraIt.ttf',
FS_BOLDITALIC =>'VeraBI.ttf' ),
FF_VERAMONO => array(FS_NORMAL =>'VeraMono.ttf',
FS_BOLD =>'VeraMoBd.ttf',
FS_ITALIC =>'VeraMoIt.ttf',
FS_BOLDITALIC =>'VeraMoBI.ttf' ),
FF_VERASERIF=> array(FS_NORMAL =>'VeraSe.ttf',
FS_BOLD =>'VeraSeBd.ttf',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ) ,
/* Chinese fonts */
FF_SIMSUN => array(
FS_NORMAL =>'simsun.ttc',
FS_BOLD =>'simhei.ttf',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_CHINESE => array(
FS_NORMAL =>CHINESE_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_BIG5 => array(
FS_NORMAL =>CHINESE_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
/* Japanese fonts */
FF_MINCHO => array(
FS_NORMAL =>MINCHO_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_PMINCHO => array(
FS_NORMAL =>PMINCHO_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_GOTHIC => array(
FS_NORMAL =>GOTHIC_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_PGOTHIC => array(
FS_NORMAL =>PGOTHIC_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
/* Hebrew fonts */
FF_DAVID => array(
FS_NORMAL =>'DAVIDNEW.TTF',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_MIRIAM => array(
FS_NORMAL =>'MRIAMY.TTF',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_AHRON => array(
FS_NORMAL =>'ahronbd.ttf',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
/* Misc fonts */
FF_DIGITAL => array(
FS_NORMAL =>'DIGIRU__.TTF',
FS_BOLD =>'Digirtu_.ttf',
FS_ITALIC =>'Digir___.ttf',
FS_BOLDITALIC =>'DIGIRT__.TTF' ),
/* This is an experimental font for the speedometer development
FF_SPEEDO => array(
FS_NORMAL =>'Speedo.ttf',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
*/
FF_COMPUTER => array(
FS_NORMAL =>'COMPUTER.TTF',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_CALCULATOR => array(
FS_NORMAL =>'Triad_xs.ttf',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
/* Dejavu fonts */
FF_DV_SANSSERIF => array(
FS_NORMAL =>array('DejaVuSans.ttf'),
FS_BOLD =>array('DejaVuSans-Bold.ttf','DejaVuSansBold.ttf'),
FS_ITALIC =>array('DejaVuSans-Oblique.ttf','DejaVuSansOblique.ttf'),
FS_BOLDITALIC =>array('DejaVuSans-BoldOblique.ttf','DejaVuSansBoldOblique.ttf') ),
FF_DV_SANSSERIFMONO => array(
FS_NORMAL =>array('DejaVuSansMono.ttf','DejaVuMonoSans.ttf'),
FS_BOLD =>array('DejaVuSansMono-Bold.ttf','DejaVuMonoSansBold.ttf'),
FS_ITALIC =>array('DejaVuSansMono-Oblique.ttf','DejaVuMonoSansOblique.ttf'),
FS_BOLDITALIC =>array('DejaVuSansMono-BoldOblique.ttf','DejaVuMonoSansBoldOblique.ttf') ),
FF_DV_SANSSERIFCOND => array(
FS_NORMAL =>array('DejaVuSansCondensed.ttf','DejaVuCondensedSans.ttf'),
FS_BOLD =>array('DejaVuSansCondensed-Bold.ttf','DejaVuCondensedSansBold.ttf'),
FS_ITALIC =>array('DejaVuSansCondensed-Oblique.ttf','DejaVuCondensedSansOblique.ttf'),
FS_BOLDITALIC =>array('DejaVuSansCondensed-BoldOblique.ttf','DejaVuCondensedSansBoldOblique.ttf') ),
FF_DV_SERIF => array(
FS_NORMAL =>array('DejaVuSerif.ttf'),
FS_BOLD =>array('DejaVuSerif-Bold.ttf','DejaVuSerifBold.ttf'),
FS_ITALIC =>array('DejaVuSerif-Italic.ttf','DejaVuSerifItalic.ttf'),
FS_BOLDITALIC =>array('DejaVuSerif-BoldItalic.ttf','DejaVuSerifBoldItalic.ttf') ),
FF_DV_SERIFCOND => array(
FS_NORMAL =>array('DejaVuSerifCondensed.ttf','DejaVuCondensedSerif.ttf'),
FS_BOLD =>array('DejaVuSerifCondensed-Bold.ttf','DejaVuCondensedSerifBold.ttf'),
FS_ITALIC =>array('DejaVuSerifCondensed-Italic.ttf','DejaVuCondensedSerifItalic.ttf'),
FS_BOLDITALIC =>array('DejaVuSerifCondensed-BoldItalic.ttf','DejaVuCondensedSerifBoldItalic.ttf') ),
/* Placeholders for defined fonts */
FF_USERFONT1 => array(
FS_NORMAL =>'',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_USERFONT2 => array(
FS_NORMAL =>'',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_USERFONT3 => array(
FS_NORMAL =>'',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
);
}
//---------------
// PUBLIC METHODS
// Create the TTF file from the font specification
function File($family,$style=FS_NORMAL) {
$fam = @$this->font_files[$family];
if( !$fam ) {
JpGraphError::RaiseL(25046,$family);//("Specified TTF font family (id=$family) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/");
}
$ff = @$fam[$style];
if( is_array($ff) ) {
// There are several optional file names. They are tried in order
// and the first one found is used
$n = count($ff);
} else {
$n = 1;
$ff = array($ff);
}
$i = 0;
do {
$f = $ff[$i];
// All font families are guaranteed to have the normal style
if( $f==='' )
JpGraphError::RaiseL(25047,$this->style_names[$style],$this->font_files[$family][FS_NORMAL]);//('Style "'.$this->style_names[$style].'" is not available for font family '.$this->font_files[$family][FS_NORMAL].'.');
if( !$f ) {
JpGraphError::RaiseL(25048,$fam);//("Unknown font style specification [$fam].");
}
if ($family >= FF_MINCHO && $family <= FF_PGOTHIC) {
$f = MBTTF_DIR.$f;
} else {
$f = TTF_DIR.$f;
}
++$i;
} while( $i < $n && (file_exists($f) === false || is_readable($f) === false) );
if( !file_exists($f) ) {
JpGraphError::RaiseL(25049,$f);//("Font file \"$f\" is not readable or does not exist.");
}
return $f;
}
function SetUserFont($aNormal,$aBold='',$aItalic='',$aBoldIt='') {
$this->font_files[FF_USERFONT] =
array(FS_NORMAL => $aNormal,
FS_BOLD => $aBold,
FS_ITALIC => $aItalic,
FS_BOLDITALIC => $aBoldIt ) ;
}
function SetUserFont1($aNormal,$aBold='',$aItalic='',$aBoldIt='') {
$this->font_files[FF_USERFONT1] =
array(FS_NORMAL => $aNormal,
FS_BOLD => $aBold,
FS_ITALIC => $aItalic,
FS_BOLDITALIC => $aBoldIt ) ;
}
function SetUserFont2($aNormal,$aBold='',$aItalic='',$aBoldIt='') {
$this->font_files[FF_USERFONT2] =
array(FS_NORMAL => $aNormal,
FS_BOLD => $aBold,
FS_ITALIC => $aItalic,
FS_BOLDITALIC => $aBoldIt ) ;
}
function SetUserFont3($aNormal,$aBold='',$aItalic='',$aBoldIt='') {
$this->font_files[FF_USERFONT3] =
array(FS_NORMAL => $aNormal,
FS_BOLD => $aBold,
FS_ITALIC => $aItalic,
FS_BOLDITALIC => $aBoldIt ) ;
}
} // Class
//=============================================================================
// CLASS SymChar
// Description: Code values for some commonly used characters that
// normally isn't available directly on the keyboard, for example
// mathematical and greek symbols.
//=============================================================================
class SymChar {
static function Get($aSymb,$aCapital=FALSE) {
$iSymbols = array(
/* Greek */
array('alpha','03B1','0391'),
array('beta','03B2','0392'),
array('gamma','03B3','0393'),
array('delta','03B4','0394'),
array('epsilon','03B5','0395'),
array('zeta','03B6','0396'),
array('ny','03B7','0397'),
array('eta','03B8','0398'),
array('theta','03B8','0398'),
array('iota','03B9','0399'),
array('kappa','03BA','039A'),
array('lambda','03BB','039B'),
array('mu','03BC','039C'),
array('nu','03BD','039D'),
array('xi','03BE','039E'),
array('omicron','03BF','039F'),
array('pi','03C0','03A0'),
array('rho','03C1','03A1'),
array('sigma','03C3','03A3'),
array('tau','03C4','03A4'),
array('upsilon','03C5','03A5'),
array('phi','03C6','03A6'),
array('chi','03C7','03A7'),
array('psi','03C8','03A8'),
array('omega','03C9','03A9'),
/* Money */
array('euro','20AC'),
array('yen','00A5'),
array('pound','20A4'),
/* Math */
array('approx','2248'),
array('neq','2260'),
array('not','2310'),
array('def','2261'),
array('inf','221E'),
array('sqrt','221A'),
array('int','222B'),
/* Misc */
array('copy','00A9'),
array('para','00A7'),
array('tm','2122'), /* Trademark symbol */
array('rtm','00AE'), /* Registered trademark */
array('degree','00b0'),
array('lte','2264'), /* Less than or equal */
array('gte','2265'), /* Greater than or equal */
);
$n = count($iSymbols);
$i=0;
$found = false;
$aSymb = strtolower($aSymb);
while( $i < $n && !$found ) {
$found = $aSymb === $iSymbols[$i++][0];
}
if( $found ) {
$ca = $iSymbols[--$i];
if( $aCapital && count($ca)==3 )
$s = $ca[2];
else
$s = $ca[1];
return sprintf('&#%04d;',hexdec($s));
}
else
return '';
}
}
?>

View File

@ -1,709 +0,0 @@
<?php
/**
* jpgraph_utils.inc.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
/*=======================================================================
// File: JPGRAPH_UTILS.INC
// Description: Collection of non-essential "nice to have" utilities
// Created: 2005-11-20
// Ver: $Id: jpgraph_utils.inc.php 1777 2009-08-23 17:34:36Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
//===================================================
// CLASS FuncGenerator
// Description: Utility class to help generate data for function plots.
// The class supports both parametric and regular functions.
//===================================================
class FuncGenerator {
private $iFunc='',$iXFunc='',$iMin,$iMax,$iStepSize;
function __construct($aFunc,$aXFunc='') {
$this->iFunc = $aFunc;
$this->iXFunc = $aXFunc;
}
function E($aXMin,$aXMax,$aSteps=50) {
$this->iMin = $aXMin;
$this->iMax = $aXMax;
$this->iStepSize = ($aXMax-$aXMin)/$aSteps;
if( $this->iXFunc != '' )
$t = 'for($i='.$aXMin.'; $i<='.$aXMax.'; $i += '.$this->iStepSize.') {$ya[]='.$this->iFunc.';$xa[]='.$this->iXFunc.';}';
elseif( $this->iFunc != '' )
$t = 'for($x='.$aXMin.'; $x<='.$aXMax.'; $x += '.$this->iStepSize.') {$ya[]='.$this->iFunc.';$xa[]=$x;} $x='.$aXMax.';$ya[]='.$this->iFunc.';$xa[]=$x;';
else
JpGraphError::RaiseL(24001);//('FuncGenerator : No function specified. ');
@eval($t);
// If there is an error in the function specifcation this is the only
// way we can discover that.
if( empty($xa) || empty($ya) )
JpGraphError::RaiseL(24002);//('FuncGenerator : Syntax error in function specification ');
return array($xa,$ya);
}
}
//=============================================================================
// CLASS DateScaleUtils
// Description: Help to create a manual date scale
//=============================================================================
define('DSUTILS_MONTH',1); // Major and minor ticks on a monthly basis
define('DSUTILS_MONTH1',1); // Major and minor ticks on a monthly basis
define('DSUTILS_MONTH2',2); // Major ticks on a bi-monthly basis
define('DSUTILS_MONTH3',3); // Major icks on a tri-monthly basis
define('DSUTILS_MONTH6',4); // Major on a six-monthly basis
define('DSUTILS_WEEK1',5); // Major ticks on a weekly basis
define('DSUTILS_WEEK2',6); // Major ticks on a bi-weekly basis
define('DSUTILS_WEEK4',7); // Major ticks on a quod-weekly basis
define('DSUTILS_DAY1',8); // Major ticks on a daily basis
define('DSUTILS_DAY2',9); // Major ticks on a bi-daily basis
define('DSUTILS_DAY4',10); // Major ticks on a qoud-daily basis
define('DSUTILS_YEAR1',11); // Major ticks on a yearly basis
define('DSUTILS_YEAR2',12); // Major ticks on a bi-yearly basis
define('DSUTILS_YEAR5',13); // Major ticks on a five-yearly basis
class DateScaleUtils {
public static $iMin=0, $iMax=0;
private static $starthour,$startmonth, $startday, $startyear;
private static $endmonth, $endyear, $endday;
private static $tickPositions=array(),$minTickPositions=array();
private static $iUseWeeks = true;
static function UseWeekFormat($aFlg) {
self::$iUseWeeks = $aFlg;
}
static function doYearly($aType,$aMinor=false) {
$i=0; $j=0;
$m = self::$startmonth;
$y = self::$startyear;
if( self::$startday == 1 ) {
self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y);
}
++$m;
switch( $aType ) {
case DSUTILS_YEAR1:
for($y=self::$startyear; $y <= self::$endyear; ++$y ) {
if( $aMinor ) {
while( $m <= 12 ) {
if( !($y == self::$endyear && $m > self::$endmonth) ) {
self::$minTickPositions[$j++] = mktime(0,0,0,$m,1,$y);
}
++$m;
}
$m=1;
}
self::$tickPositions[$i++] = mktime(0,0,0,1,1,$y);
}
break;
case DSUTILS_YEAR2:
$y=self::$startyear;
while( $y <= self::$endyear ) {
self::$tickPositions[$i++] = mktime(0,0,0,1,1,$y);
for($k=0; $k < 1; ++$k ) {
++$y;
if( $aMinor ) {
self::$minTickPositions[$j++] = mktime(0,0,0,1,1,$y);
}
}
++$y;
}
break;
case DSUTILS_YEAR5:
$y=self::$startyear;
while( $y <= self::$endyear ) {
self::$tickPositions[$i++] = mktime(0,0,0,1,1,$y);
for($k=0; $k < 4; ++$k ) {
++$y;
if( $aMinor ) {
self::$minTickPositions[$j++] = mktime(0,0,0,1,1,$y);
}
}
++$y;
}
break;
}
}
static function doDaily($aType,$aMinor=false) {
$m = self::$startmonth;
$y = self::$startyear;
$d = self::$startday;
$h = self::$starthour;
$i=0;$j=0;
if( $h == 0 ) {
self::$tickPositions[$i++] = mktime(0,0,0,$m,$d,$y);
}
$t = mktime(0,0,0,$m,$d,$y);
switch($aType) {
case DSUTILS_DAY1:
while( $t <= self::$iMax ) {
$t = strtotime('+1 day',$t);
self::$tickPositions[$i++] = $t;
if( $aMinor ) {
self::$minTickPositions[$j++] = strtotime('+12 hours',$t);
}
}
break;
case DSUTILS_DAY2:
while( $t <= self::$iMax ) {
$t = strtotime('+1 day',$t);
if( $aMinor ) {
self::$minTickPositions[$j++] = $t;
}
$t = strtotime('+1 day',$t);
self::$tickPositions[$i++] = $t;
}
break;
case DSUTILS_DAY4:
while( $t <= self::$iMax ) {
for($k=0; $k < 3; ++$k ) {
$t = strtotime('+1 day',$t);
if( $aMinor ) {
self::$minTickPositions[$j++] = $t;
}
}
$t = strtotime('+1 day',$t);
self::$tickPositions[$i++] = $t;
}
break;
}
}
static function doWeekly($aType,$aMinor=false) {
$hpd = 3600*24;
$hpw = 3600*24*7;
// Find out week number of min date
$thursday = self::$iMin + $hpd * (3 - (date('w', self::$iMin) + 6) % 7);
$week = 1 + (date('z', $thursday) - (11 - date('w', mktime(0, 0, 0, 1, 1, date('Y', $thursday)))) % 7) / 7;
$daynumber = date('w',self::$iMin);
if( $daynumber == 0 ) $daynumber = 7;
$m = self::$startmonth;
$y = self::$startyear;
$d = self::$startday;
$i=0;$j=0;
// The assumption is that the weeks start on Monday. If the first day
// is later in the week then the first week tick has to be on the following
// week.
if( $daynumber == 1 ) {
self::$tickPositions[$i++] = mktime(0,0,0,$m,$d,$y);
$t = mktime(0,0,0,$m,$d,$y) + $hpw;
}
else {
$t = mktime(0,0,0,$m,$d,$y) + $hpd*(8-$daynumber);
}
switch($aType) {
case DSUTILS_WEEK1:
$cnt=0;
break;
case DSUTILS_WEEK2:
$cnt=1;
break;
case DSUTILS_WEEK4:
$cnt=3;
break;
}
while( $t <= self::$iMax ) {
self::$tickPositions[$i++] = $t;
for($k=0; $k < $cnt; ++$k ) {
$t += $hpw;
if( $aMinor ) {
self::$minTickPositions[$j++] = $t;
}
}
$t += $hpw;
}
}
static function doMonthly($aType,$aMinor=false) {
$monthcount=0;
$m = self::$startmonth;
$y = self::$startyear;
$i=0; $j=0;
// Skip the first month label if it is before the startdate
if( self::$startday == 1 ) {
self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y);
$monthcount=1;
}
if( $aType == 1 ) {
if( self::$startday < 15 ) {
self::$minTickPositions[$j++] = mktime(0,0,0,$m,15,$y);
}
}
++$m;
// Loop through all the years included in the scale
for($y=self::$startyear; $y <= self::$endyear; ++$y ) {
// Loop through all the months. There are three cases to consider:
// 1. We are in the first year and must start with the startmonth
// 2. We are in the end year and we must stop at last month of the scale
// 3. A year in between where we run through all the 12 months
$stopmonth = $y == self::$endyear ? self::$endmonth : 12;
while( $m <= $stopmonth ) {
switch( $aType ) {
case DSUTILS_MONTH1:
// Set minor tick at the middle of the month
if( $aMinor ) {
if( $m <= $stopmonth ) {
if( !($y==self::$endyear && $m==$stopmonth && self::$endday < 15) )
self::$minTickPositions[$j++] = mktime(0,0,0,$m,15,$y);
}
}
// Major at month
// Get timestamp of first hour of first day in each month
self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y);
break;
case DSUTILS_MONTH2:
if( $aMinor ) {
// Set minor tick at start of each month
self::$minTickPositions[$j++] = mktime(0,0,0,$m,1,$y);
}
// Major at every second month
// Get timestamp of first hour of first day in each month
if( $monthcount % 2 == 0 ) {
self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y);
}
break;
case DSUTILS_MONTH3:
if( $aMinor ) {
// Set minor tick at start of each month
self::$minTickPositions[$j++] = mktime(0,0,0,$m,1,$y);
}
// Major at every third month
// Get timestamp of first hour of first day in each month
if( $monthcount % 3 == 0 ) {
self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y);
}
break;
case DSUTILS_MONTH6:
if( $aMinor ) {
// Set minor tick at start of each month
self::$minTickPositions[$j++] = mktime(0,0,0,$m,1,$y);
}
// Major at every third month
// Get timestamp of first hour of first day in each month
if( $monthcount % 6 == 0 ) {
self::$tickPositions[$i++] = mktime(0,0,0,$m,1,$y);
}
break;
}
++$m;
++$monthcount;
}
$m=1;
}
// For the case where all dates are within the same month
// we want to make sure we have at least two ticks on the scale
// since the scale want work properly otherwise
if(self::$startmonth == self::$endmonth && self::$startyear == self::$endyear && $aType==1 ) {
self::$tickPositions[$i++] = mktime(0 ,0 ,0, self::$startmonth + 1, 1, self::$startyear);
}
return array(self::$tickPositions,self::$minTickPositions);
}
static function GetTicks($aData,$aType=1,$aMinor=false,$aEndPoints=false) {
$n = count($aData);
return self::GetTicksFromMinMax($aData[0],$aData[$n-1],$aType,$aMinor,$aEndPoints);
}
static function GetAutoTicks($aMin,$aMax,$aMaxTicks=10,$aMinor=false) {
$diff = $aMax - $aMin;
$spd = 3600*24;
$spw = $spd*7;
$spm = $spd*30;
$spy = $spd*352;
if( self::$iUseWeeks )
$w = 'W';
else
$w = 'd M';
// Decision table for suitable scales
// First value: Main decision point
// Second value: Array of formatting depending on divisor for wanted max number of ticks. <divisor><formatting><format-string>,..
$tt = array(
array($spw, array(1,DSUTILS_DAY1,'d M',2,DSUTILS_DAY2,'d M',-1,DSUTILS_DAY4,'d M')),
array($spm, array(1,DSUTILS_DAY1,'d M',2,DSUTILS_DAY2,'d M',4,DSUTILS_DAY4,'d M',7,DSUTILS_WEEK1,$w,-1,DSUTILS_WEEK2,$w)),
array($spy, array(1,DSUTILS_DAY1,'d M',2,DSUTILS_DAY2,'d M',4,DSUTILS_DAY4,'d M',7,DSUTILS_WEEK1,$w,14,DSUTILS_WEEK2,$w,30,DSUTILS_MONTH1,'M',60,DSUTILS_MONTH2,'M',-1,DSUTILS_MONTH3,'M')),
array(-1, array(30,DSUTILS_MONTH1,'M-Y',60,DSUTILS_MONTH2,'M-Y',90,DSUTILS_MONTH3,'M-Y',180,DSUTILS_MONTH6,'M-Y',352,DSUTILS_YEAR1,'Y',704,DSUTILS_YEAR2,'Y',-1,DSUTILS_YEAR5,'Y')));
$ntt = count($tt);
$nd = floor($diff/$spd);
for($i=0; $i < $ntt; ++$i ) {
if( $diff <= $tt[$i][0] || $i==$ntt-1) {
$t = $tt[$i][1];
$n = count($t)/3;
for( $j=0; $j < $n; ++$j ) {
if( $nd/$t[3*$j] <= $aMaxTicks || $j==$n-1) {
$type = $t[3*$j+1];
$fs = $t[3*$j+2];
list($tickPositions,$minTickPositions) = self::GetTicksFromMinMax($aMin,$aMax,$type,$aMinor);
return array($fs,$tickPositions,$minTickPositions,$type);
}
}
}
}
}
static function GetTicksFromMinMax($aMin,$aMax,$aType,$aMinor=false,$aEndPoints=false) {
self::$starthour = date('G',$aMin);
self::$startmonth = date('n',$aMin);
self::$startday = date('j',$aMin);
self::$startyear = date('Y',$aMin);
self::$endmonth = date('n',$aMax);
self::$endyear = date('Y',$aMax);
self::$endday = date('j',$aMax);
self::$iMin = $aMin;
self::$iMax = $aMax;
if( $aType <= DSUTILS_MONTH6 ) {
self::doMonthly($aType,$aMinor);
}
elseif( $aType <= DSUTILS_WEEK4 ) {
self::doWeekly($aType,$aMinor);
}
elseif( $aType <= DSUTILS_DAY4 ) {
self::doDaily($aType,$aMinor);
}
elseif( $aType <= DSUTILS_YEAR5 ) {
self::doYearly($aType,$aMinor);
}
else {
JpGraphError::RaiseL(24003);
}
// put a label at the very left data pos
if( $aEndPoints ) {
$tickPositions[$i++] = $aData[0];
}
// put a label at the very right data pos
if( $aEndPoints ) {
$tickPositions[$i] = $aData[$n-1];
}
return array(self::$tickPositions,self::$minTickPositions);
}
}
//=============================================================================
// Class ReadFileData
//=============================================================================
Class ReadFileData {
//----------------------------------------------------------------------------
// Desciption:
// Read numeric data from a file.
// Each value should be separated by either a new line or by a specified
// separator character (default is ',').
// Before returning the data each value is converted to a proper float
// value. The routine is robust in the sense that non numeric data in the
// file will be discarded.
//
// Returns:
// The number of data values read on success, FALSE on failure
//----------------------------------------------------------------------------
static function FromCSV($aFile,&$aData,$aSepChar=',',$aMaxLineLength=1024) {
$rh = @fopen($aFile,'r');
if( $rh === false ) {
return false;
}
$tmp = array();
$lineofdata = fgetcsv($rh, 1000, ',');
while ( $lineofdata !== FALSE) {
$tmp = array_merge($tmp,$lineofdata);
$lineofdata = fgetcsv($rh, $aMaxLineLength, $aSepChar);
}
fclose($rh);
// Now make sure that all data is numeric. By default
// all data is read as strings
$n = count($tmp);
$aData = array();
$cnt=0;
for($i=0; $i < $n; ++$i) {
if( $tmp[$i] !== "" ) {
$aData[$cnt++] = floatval($tmp[$i]);
}
}
return $cnt;
}
//----------------------------------------------------------------------------
// Desciption:
// Read numeric data from a file.
// Each value should be separated by either a new line or by a specified
// separator character (default is ',').
// Before returning the data each value is converted to a proper float
// value. The routine is robust in the sense that non numeric data in the
// file will be discarded.
//
// Options:
// 'separator' => ',',
// 'enclosure' => '"',
// 'readlength' => 1024,
// 'ignore_first' => false,
// 'first_as_key' => false
// 'escape' => '\', # PHP >= 5.3 only
//
// Returns:
// The number of lines read on success, FALSE on failure
//----------------------------------------------------------------------------
static function FromCSV2($aFile, &$aData, $aOptions = array()) {
$aDefaults = array(
'separator' => ',',
'enclosure' => chr(34),
'escape' => chr(92),
'readlength' => 1024,
'ignore_first' => false,
'first_as_key' => false
);
$aOptions = array_merge(
$aDefaults, is_array($aOptions) ? $aOptions : array());
if( $aOptions['first_as_key'] ) {
$aOptions['ignore_first'] = true;
}
$rh = @fopen($aFile, 'r');
if( $rh === false ) {
return false;
}
$aData = array();
$aLine = fgetcsv($rh,
$aOptions['readlength'],
$aOptions['separator'],
$aOptions['enclosure']
/*, $aOptions['escape'] # PHP >= 5.3 only */
);
// Use numeric array keys for the columns by default
// If specified use first lines values as assoc keys instead
$keys = array_keys($aLine);
if( $aOptions['first_as_key'] ) {
$keys = array_values($aLine);
}
$num_lines = 0;
$num_cols = count($aLine);
while ($aLine !== false) {
if( is_array($aLine) && count($aLine) != $num_cols ) {
JpGraphError::RaiseL(24004);
// 'ReadCSV2: Column count mismatch in %s line %d'
}
// fgetcsv returns NULL for empty lines
if( !is_null($aLine) ) {
$num_lines++;
if( !($aOptions['ignore_first'] && $num_lines == 1) && is_numeric($aLine[0]) ) {
for( $i = 0; $i < $num_cols; $i++ ) {
$aData[ $keys[$i] ][] = floatval($aLine[$i]);
}
}
}
$aLine = fgetcsv($rh,
$aOptions['readlength'],
$aOptions['separator'],
$aOptions['enclosure']
/*, $aOptions['escape'] # PHP >= 5.3 only*/
);
}
fclose($rh);
if( $aOptions['ignore_first'] ) {
$num_lines--;
}
return $num_lines;
}
// Read data from two columns in a plain text file
static function From2Col($aFile, $aCol1, $aCol2, $aSepChar=' ') {
$lines = @file($aFile,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
if( $lines === false ) {
return false;
}
$s = '/[\s]+/';
if( $aSepChar == ',' ) {
$s = '/[\s]*,[\s]*/';
}
elseif( $aSepChar == ';' ) {
$s = '/[\s]*;[\s]*/';
}
foreach( $lines as $line => $datarow ) {
$split = preg_split($s,$datarow);
$aCol1[] = floatval(trim($split[0]));
$aCol2[] = floatval(trim($split[1]));
}
return count($lines);
}
// Read data from one columns in a plain text file
static function From1Col($aFile, $aCol1) {
$lines = @file($aFile,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
if( $lines === false ) {
return false;
}
foreach( $lines as $line => $datarow ) {
$aCol1[] = floatval(trim($datarow));
}
return count($lines);
}
static function FromMatrix($aFile,$aSepChar=' ') {
$lines = @file($aFile,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
if( $lines === false ) {
return false;
}
$mat = array();
$reg = '/'.$aSepChar.'/';
foreach( $lines as $line => $datarow ) {
$row = preg_split($reg,trim($datarow));
foreach ($row as $key => $cell ) {
$row[$key] = floatval(trim($cell));
}
$mat[] = $row;
}
return $mat;
}
}
define('__LR_EPSILON', 1.0e-8);
//=============================================================================
// Class LinearRegression
//=============================================================================
class LinearRegression {
private $ix=array(),$iy=array();
private $ib=0, $ia=0;
private $icalculated=false;
public $iDet=0, $iCorr=0, $iStdErr=0;
public function __construct($aDataX,$aDataY) {
if( count($aDataX) !== count($aDataY) ) {
JpGraph::Raise('LinearRegression: X and Y data array must be of equal length.');
}
$this->ix = $aDataX;
$this->iy = $aDataY;
}
public function Calc() {
$this->icalculated = true;
$n = count($this->ix);
$sx2 = 0 ;
$sy2 = 0 ;
$sxy = 0 ;
$sx = 0 ;
$sy = 0 ;
for( $i=0; $i < $n; ++$i ) {
$sx2 += $this->ix[$i] * $this->ix[$i];
$sy2 += $this->iy[$i] * $this->iy[$i];
$sxy += $this->ix[$i] * $this->iy[$i];
$sx += $this->ix[$i];
$sy += $this->iy[$i];
}
if( $n*$sx2 - $sx*$sx > __LR_EPSILON ) {
$this->ib = ($n*$sxy - $sx*$sy) / ( $n*$sx2 - $sx*$sx );
$this->ia = ( $sy - $this->ib*$sx ) / $n;
$sx = $this->ib * ( $sxy - $sx*$sy/$n );
$sy2 = $sy2 - $sy*$sy/$n;
$sy = $sy2 - $sx;
$this->iDet = $sx / $sy2;
$this->iCorr = sqrt($this->iDet);
if( $n > 2 ) {
$this->iStdErr = sqrt( $sy / ($n-2) );
}
else {
$this->iStdErr = NAN ;
}
}
else {
$this->ib = 0;
$this->ia = 0;
}
}
public function GetAB() {
if( $this->icalculated == false )
$this->Calc();
return array($this->ia, $this->ib);
}
public function GetStat() {
if( $this->icalculated == false )
$this->Calc();
return array($this->iStdErr, $this->iCorr, $this->iDet);
}
public function GetY($aMinX, $aMaxX, $aStep=1) {
if( $this->icalculated == false )
$this->Calc();
$yy = array();
$i = 0;
for( $x=$aMinX; $x <= $aMaxX; $x += $aStep ) {
$xx[$i ] = $x;
$yy[$i++] = $this->ia + $this->ib * $x;
}
return array($xx,$yy);
}
}
?>

View File

@ -1,542 +0,0 @@
<?php
/*=======================================================================
// File: DE.INC.PHP
// Description: German language file for error messages
// Created: 2006-03-06
// Author: Timo Leopold (timo@leopold-hh.de)
// Johan Persson (ljp@localhost.nil)
// Ver: $Id: de.inc.php 1886 2009-10-01 23:30:16Z ljp $
//
// Copyright (c)
//========================================================================
*/
// Notiz: Das Format fuer jede Fehlermeldung ist array(<Fehlermeldung>,<Anzahl der Argumente>)
$_jpg_messages = array(
/*
** Headers wurden bereits gesendet - Fehler. Dies wird als HTML formatiert, weil es direkt als text zurueckgesendet wird
*/
10 => array('<table border="1"><tr><td style="color:darkred;font-size:1.2em;"><b>JpGraph Fehler:</b>
HTTP header wurden bereits gesendet.<br>Fehler in der Datei <b>%s</b> in der Zeile <b>%d</b>.</td></tr><tr><td><b>Erklärung:</b><br>HTTP header wurden bereits zum Browser gesendet, wobei die Daten als Text gekennzeichnet wurden, bevor die Bibliothek die Chance hatte, seinen Bild-HTTP-Header zum Browser zu schicken. Dies verhindert, dass die Bibliothek Bilddaten zum Browser schicken kann (weil sie vom Browser als Text interpretiert würden und daher nur Mist dargestellt würde).<p>Wahrscheinlich steht Text im Skript bevor <i>Graph::Stroke()</i> aufgerufen wird. Wenn dieser Text zum Browser gesendet wird, nimmt dieser an, dass die gesamten Daten aus Text bestehen. Such nach irgendwelchem Text, auch nach Leerzeichen und Zeilenumbrüchen, die eventuell bereits zum Browser gesendet wurden. <p>Zum Beispiel ist ein oft auftretender Fehler, eine Leerzeile am Anfang der Datei oder vor <i>Graph::Stroke()</i> zu lassen."<b>&lt;?php</b>".</td></tr></table>',2),
/*
** Setup Fehler
*/
11 => array('Es wurde kein Pfad für CACHE_DIR angegeben. Bitte gib einen Pfad CACHE_DIR in der Datei jpg-config.inc an.',0),
12 => array('Es wurde kein Pfad für TTF_DIR angegeben und der Pfad kann nicht automatisch ermittelt werden. Bitte gib den Pfad in der Datei jpg-config.inc an.',0),
13 => array('The installed PHP version (%s) is not compatible with this release of the library. The library requires at least PHP version %s',2),
/*
** jpgraph_bar
*/
2001 => array('Die Anzahl der Farben ist nicht gleich der Anzahl der Vorlagen in BarPlot::SetPattern().',0),
2002 => array('Unbekannte Vorlage im Aufruf von BarPlot::SetPattern().',0),
2003 => array('Anzahl der X- und Y-Koordinaten sind nicht identisch. Anzahl der X-Koordinaten: %d; Anzahl der Y-Koordinaten: %d.',2),
2004 => array('Alle Werte für ein Balkendiagramm (barplot) müssen numerisch sein. Du hast den Wert nr [%d] == %s angegeben.',2),
2005 => array('Du hast einen leeren Vektor für die Schattierungsfarben im Balkendiagramm (barplot) angegeben.',0),
2006 => array('Unbekannte Position für die Werte der Balken: %s.',1),
2007 => array('Kann GroupBarPlot nicht aus einem leeren Vektor erzeugen.',0),
2008 => array('GroupBarPlot Element nbr %d wurde nicht definiert oder ist leer.',0),
2009 => array('Eins der Objekte, das an GroupBar weitergegeben wurde ist kein Balkendiagramm (BarPlot). Versichere Dich, dass Du den GroupBarPlot aus einem Vektor von Balkendiagrammen (barplot) oder AccBarPlot-Objekten erzeugst. (Class = %s)',1),
2010 => array('Kann AccBarPlot nicht aus einem leeren Vektor erzeugen.',0),
2011 => array('AccBarPlot-Element nbr %d wurde nicht definiert oder ist leer.',1),
2012 => array('Eins der Objekte, das an AccBar weitergegeben wurde ist kein Balkendiagramm (barplot). Versichere Dich, dass Du den AccBar-Plot aus einem Vektor von Balkendiagrammen (barplot) erzeugst. (Class=%s)',1),
2013 => array('Du hast einen leeren Vektor für die Schattierungsfarben im Balkendiagramm (barplot) angegeben.',0),
2014 => array('Die Anzahl der Datenpunkte jeder Datenreihe in AccBarPlot muss gleich sein.',0),
2015 => array('Individual bar plots in an AccBarPlot or GroupBarPlot can not have specified X-coordinates',0),
/*
** jpgraph_date
*/
3001 => array('Es ist nur möglich, entweder SetDateAlign() oder SetTimeAlign() zu benutzen, nicht beides!',0),
/*
** jpgraph_error
*/
4002 => array('Fehler bei den Eingabedaten von LineErrorPlot. Die Anzahl der Datenpunkte mus ein Mehrfaches von drei sein!',0),
/*
** jpgraph_flags
*/
5001 => array('Unbekannte Flaggen-Größe (%d).',1),
5002 => array('Der Flaggen-Index %s existiert nicht.',1),
5003 => array('Es wurde eine ungültige Ordnungszahl (%d) für den Flaggen-Index angegeben.',1),
5004 => array('Der Landesname %s hat kein korrespondierendes Flaggenbild. Die Flagge mag existieren, abr eventuell unter einem anderen Namen, z.B. versuche "united states" statt "usa".',1),
/*
** jpgraph_gantt
*/
6001 => array('Interner Fehler. Die Höhe für ActivityTitles ist < 0.',0),
6002 => array('Es dürfen keine negativen Werte für die Gantt-Diagramm-Dimensionen angegeben werden. Verwende 0, wenn die Dimensionen automatisch ermittelt werden sollen.',0),
6003 => array('Ungültiges Format für den Bedingungs-Parameter bei Index=%d in CreateSimple(). Der Parameter muss bei index 0 starten und Vektoren in der Form (Row,Constrain-To,Constrain-Type) enthalten.',1),
6004 => array('Ungültiges Format für den Fortschritts-Parameter bei Index=%d in CreateSimple(). Der Parameter muss bei Index 0 starten und Vektoren in der Form (Row,Progress) enthalten.',1),
6005 => array('SetScale() ist nicht sinnvoll bei Gantt-Diagrammen.',0),
6006 => array('Das Gantt-Diagramm kann nicht automatisch skaliert werden. Es existieren keine Aktivitäten mit Termin. [GetBarMinMax() start >= n]',0),
6007 => array('Plausibiltätsprüfung für die automatische Gantt-Diagramm-Größe schlug fehl. Entweder die Breite (=%d) oder die Höhe (=%d) ist größer als MAX_GANTTIMG_SIZE. Dies kann möglicherweise durch einen falschen Wert bei einer Aktivität hervorgerufen worden sein.',2),
6008 => array('Du hast eine Bedingung angegeben von Reihe=%d bis Reihe=%d, die keine Aktivität hat.',2),
6009 => array('Unbekannter Bedingungstyp von Reihe=%d bis Reihe=%d',2),
6010 => array('Ungültiger Icon-Index für das eingebaute Gantt-Icon [%d]',1),
6011 => array('Argument für IconImage muss entweder ein String oder ein Integer sein.',0),
6012 => array('Unbekannter Typ bei der Gantt-Objekt-Title-Definition.',0),
6015 => array('Ungültige vertikale Position %d',1),
6016 => array('Der eingegebene Datums-String (%s) für eine Gantt-Aktivität kann nicht interpretiert werden. Versichere Dich, dass es ein gültiger Datumsstring ist, z.B. 2005-04-23 13:30',1),
6017 => array('Unbekannter Datumstyp in GanttScale (%s).',1),
6018 => array('Intervall für Minuten muss ein gerader Teiler einer Stunde sein, z.B. 1,5,10,12,15,20,30, etc. Du hast ein Intervall von %d Minuten angegeben.',1),
6019 => array('Die vorhandene Breite (%d) für die Minuten ist zu klein, um angezeigt zu werden. Bitte benutze die automatische Größenermittlung oder vergrößere die Breite des Diagramms.',1),
6020 => array('Das Intervall für die Stunden muss ein gerader Teiler eines Tages sein, z.B. 0:30, 1:00, 1:30, 4:00, etc. Du hast ein Intervall von %d eingegeben.',1),
6021 => array('Unbekanntes Format für die Woche.',0),
6022 => array('Die Gantt-Skala wurde nicht eingegeben.',0),
6023 => array('Wenn Du sowohl Stunden als auch Minuten anzeigen lassen willst, muss das Stunden-Interval gleich 1 sein (anderenfalls ist es nicht sinnvoll, Minuten anzeigen zu lassen).',0),
6024 => array('Das CSIM-Ziel muss als String angegeben werden. Der Start des Ziels ist: %d',1),
6025 => array('Der CSIM-Alt-Text muss als String angegeben werden. Der Beginn des Alt-Textes ist: %d',1),
6027 => array('Der Fortschrittswert muss im Bereich [0, 1] liegen.',0),
6028 => array('Die eingegebene Höhe (%d) für GanttBar ist nicht im zulässigen Bereich.',1),
6029 => array('Der Offset für die vertikale Linie muss im Bereich [0,1] sein.',0),
6030 => array('Unbekannte Pfeilrichtung für eine Verbindung.',0),
6031 => array('Unbekannter Pfeiltyp für eine Verbindung.',0),
6032 => array('Interner Fehler: Unbekannter Pfadtyp (=%d) für eine Verbindung.',1),
6033 => array('Array of fonts must contain arrays with 3 elements, i.e. (Family, Style, Size)',0),
/*
** jpgraph_gradient
*/
7001 => array('Unbekannter Gradiententyp (=%d).',1),
/*
** jpgraph_iconplot
*/
8001 => array('Der Mix-Wert für das Icon muss zwischen 0 und 100 sein.',0),
8002 => array('Die Ankerposition für Icons muss entweder "top", "bottom", "left", "right" oder "center" sein.',0),
8003 => array('Es ist nicht möglich, gleichzeitig ein Bild und eine Landesflagge für dasselbe Icon zu definieren',0),
8004 => array('Wenn Du Landesflaggen benutzen willst, musst Du die Datei "jpgraph_flags.php" hinzufügen (per include).',0),
/*
** jpgraph_imgtrans
*/
9001 => array('Der Wert für die Bildtransformation ist außerhalb des zulässigen Bereichs. Der verschwindende Punkt am Horizont muss als Wert zwischen 0 und 1 angegeben werden.',0),
/*
** jpgraph_lineplot
*/
10001 => array('Die Methode LinePlot::SetFilled() sollte nicht mehr benutzt werden. Benutze lieber SetFillColor()',0),
10002 => array('Der Plot ist zu kompliziert für FastLineStroke. Benutze lieber den StandardStroke()',0),
10003 => array('Each plot in an accumulated lineplot must have the same number of data points.',0),
/*
** jpgraph_log
*/
11001 => array('Deine Daten enthalten nicht-numerische Werte.',0),
11002 => array('Negative Werte können nicht für logarithmische Achsen verwendet werden.',0),
11003 => array('Deine Daten enthalten nicht-numerische Werte.',0),
11004 => array('Skalierungsfehler für die logarithmische Achse. Es gibt ein Problem mit den Daten der Achse. Der größte Wert muss größer sein als Null. Es ist mathematisch nicht möglich, einen Wert gleich Null in der Skala zu haben.',0),
11005 => array('Das Tick-Intervall für die logarithmische Achse ist nicht definiert. Lösche jeden Aufruf von SetTextLabelStart() oder SetTextTickInterval() bei der logarithmischen Achse.',0),
/*
** jpgraph_mgraph
*/
12001 => array("Du benutzt GD 2.x und versuchst ein Nicht-Truecolor-Bild als Hintergrundbild zu benutzen. Um Hintergrundbilder mit GD 2.x zu benutzen, ist es notwendig Truecolor zu aktivieren, indem die USE_TRUECOLOR-Konstante auf TRUE gesetzt wird. Wegen eines Bugs in GD 2.0.1 ist die Qualität der Truetype-Schriften sehr schlecht, wenn man Truetype-Schriften mit Truecolor-Bildern verwendet.",0),
12002 => array('Ungültiger Dateiname für MGraph::SetBackgroundImage() : %s. Die Datei muss eine gültige Dateierweiterung haben (jpg,gif,png), wenn die automatische Typerkennung verwendet wird.',1),
12003 => array('Unbekannte Dateierweiterung (%s) in MGraph::SetBackgroundImage() für Dateiname: %s',2),
12004 => array('Das Bildformat des Hintergrundbildes (%s) wird von Deiner System-Konfiguration nicht unterstützt. ',1),
12005 => array('Das Hintergrundbild kann nicht gelesen werden: %s',1),
12006 => array('Es wurden ungültige Größen für Breite oder Höhe beim Erstellen des Bildes angegeben, (Breite=%d, Höhe=%d)',2),
12007 => array('Das Argument für MGraph::Add() ist nicht gültig für GD.',0),
12008 => array('Deine PHP- (und GD-lib-) Installation scheint keine bekannten Bildformate zu unterstützen.',0),
12009 => array('Deine PHP-Installation unterstützt das gewählte Bildformat nicht: %s',1),
12010 => array('Es konnte kein Bild als Datei %s erzeugt werden. Überprüfe, ob Du die entsprechenden Schreibrechte im aktuellen Verzeichnis hast.',1),
12011 => array('Es konnte kein Truecolor-Bild erzeugt werden. Überprüfe, ob Du wirklich die GD2-Bibliothek installiert hast.',0),
12012 => array('Es konnte kein Bild erzeugt werden. Überprüfe, ob Du wirklich die GD2-Bibliothek installiert hast.',0),
/*
** jpgraph_pie3d
*/
14001 => array('Pie3D::ShowBorder(). Missbilligte Funktion. Benutze Pie3D::SetEdge(), um die Ecken der Tortenstücke zu kontrollieren.',0),
14002 => array('PiePlot3D::SetAngle() 3D-Torten-Projektionswinkel muss zwischen 5 und 85 Grad sein.',0),
14003 => array('Interne Festlegung schlug fehl. Pie3D::Pie3DSlice',0),
14004 => array('Tortenstück-Startwinkel muss zwischen 0 und 360 Grad sein.',0),
14005 => array('Pie3D Interner Fehler: Versuch, zweimal zu umhüllen bei der Suche nach dem Startindex.',0,),
14006 => array('Pie3D Interner Fehler: Z-Sortier-Algorithmus für 3D-Tortendiagramme funktioniert nicht einwandfrei (2). Versuch, zweimal zu umhüllen beim Erstellen des Bildes.',0),
14007 => array('Die Breite für das 3D-Tortendiagramm ist 0. Gib eine Breite > 0 an.',0),
/*
** jpgraph_pie
*/
15001 => array('PiePLot::SetTheme() Unbekannter Stil: %s',1),
15002 => array('Argument für PiePlot::ExplodeSlice() muss ein Integer-Wert sein',0),
15003 => array('Argument für PiePlot::Explode() muss ein Vektor mit Integer-Werten sein.',0),
15004 => array('Tortenstück-Startwinkel muss zwischen 0 und 360 Grad sein.',0),
15005 => array('PiePlot::SetFont() sollte nicht mehr verwendet werden. Benutze stattdessen PiePlot->value->SetFont().',0),
15006 => array('PiePlot::SetSize() Radius für Tortendiagramm muss entweder als Bruch [0, 0.5] der Bildgröße oder als Absoluwert in Pixel im Bereich [10, 1000] angegeben werden.',0),
15007 => array('PiePlot::SetFontColor() sollte nicht mehr verwendet werden. Benutze stattdessen PiePlot->value->SetColor()..',0),
15008 => array('PiePlot::SetLabelType() der Typ für Tortendiagramme muss entweder 0 or 1 sein (nicht %d).',1),
15009 => array('Ungültiges Tortendiagramm. Die Summe aller Daten ist Null.',0),
15010 => array('Die Summe aller Daten ist Null.',0),
15011 => array('Um Bildtransformationen benutzen zu können, muss die Datei jpgraph_imgtrans.php eingefügt werden (per include).',0),
/*
** jpgraph_plotband
*/
16001 => array('Die Dichte für das Pattern muss zwischen 1 und 100 sein. (Du hast %f eingegeben)',1),
16002 => array('Es wurde keine Position für das Pattern angegeben.',0),
16003 => array('Unbekannte Pattern-Definition (%d)',0),
16004 => array('Der Mindeswert für das PlotBand ist größer als der Maximalwert. Bitte korrigiere dies!',0),
/*
** jpgraph_polar
*/
17001 => array('PolarPlots müssen eine gerade Anzahl von Datenpunkten haben. Jeder Datenpunkt ist ein Tupel (Winkel, Radius).',0),
17002 => array('Unbekannte Ausrichtung für X-Achsen-Titel. (%s)',1),
//17003 => array('Set90AndMargin() wird für PolarGraph nicht unterstützt.',0),
17004 => array('Unbekannter Achsentyp für PolarGraph. Er muss entweder \'lin\' oder \'log\' sein.',0),
/*
** jpgraph_radar
*/
18001 => array('ClientSideImageMaps werden für RadarPlots nicht unterstützt.',0),
18002 => array('RadarGraph::SupressTickMarks() sollte nicht mehr verwendet werden. Benutze stattdessen HideTickMarks().',0),
18003 => array('Ungültiger Achsentyp für RadarPlot (%s). Er muss entweder \'lin\' oder \'log\' sein.',1),
18004 => array('Die RadarPlot-Größe muss zwischen 0.1 und 1 sein. (Dein Wert=%f)',1),
18005 => array('RadarPlot: nicht unterstützte Tick-Dichte: %d',1),
18006 => array('Minimum Daten %f (RadarPlots sollten nur verwendet werden, wenn alle Datenpunkte einen Wert > 0 haben).',1),
18007 => array('Die Anzahl der Titel entspricht nicht der Anzahl der Datenpunkte.',0),
18008 => array('Jeder RadarPlot muss die gleiche Anzahl von Datenpunkten haben.',0),
/*
** jpgraph_regstat
*/
19001 => array('Spline: Anzahl der X- und Y-Koordinaten muss gleich sein.',0),
19002 => array('Ungültige Dateneingabe für Spline. Zwei oder mehr aufeinanderfolgende X-Werte sind identisch. Jeder eigegebene X-Wert muss unterschiedlich sein, weil vom mathematischen Standpunkt ein Eins-zu-Eins-Mapping vorliegen muss, d.h. jeder X-Wert korrespondiert mit exakt einem Y-Wert.',0),
19003 => array('Bezier: Anzahl der X- und Y-Koordinaten muss gleich sein.',0),
/*
** jpgraph_scatter
*/
20001 => array('Fieldplots müssen die gleiche Anzahl von X und Y Datenpunkten haben.',0),
20002 => array('Bei Fieldplots muss ein Winkel für jeden X und Y Datenpunkt angegeben werden.',0),
20003 => array('Scatterplots müssen die gleiche Anzahl von X- und Y-Datenpunkten haben.',0),
/*
** jpgraph_stock
*/
21001 => array('Die Anzahl der Datenwerte für Stock-Charts müssen ein Mehrfaches von %d Datenpunkten sein.',1),
/*
** jpgraph_plotmark
*/
23001 => array('Der Marker "%s" existiert nicht in der Farbe: %d',2),
23002 => array('Der Farb-Index ist zu hoch für den Marker "%s"',1),
23003 => array('Ein Dateiname muss angegeben werden, wenn Du den Marker-Typ auf MARK_IMG setzt.',0),
/*
** jpgraph_utils
*/
24001 => array('FuncGenerator : Keine Funktion definiert. ',0),
24002 => array('FuncGenerator : Syntax-Fehler in der Funktionsdefinition ',0),
24003 => array('DateScaleUtils: Unknown tick type specified in call to GetTicks()',0),
24004 => array('ReadCSV2: Die anzahl der spalten fehler in %s reihe %d',2),
/*
** jpgraph
*/
25001 => array('Diese PHP-Installation ist nicht mit der GD-Bibliothek kompiliert. Bitte kompiliere PHP mit GD-Unterstützung neu, damit JpGraph funktioniert. (Weder die Funktion imagetypes() noch imagecreatefromstring() existiert!)',0),
25002 => array('Diese PHP-Installation scheint nicht die benötigte GD-Bibliothek zu unterstützen. Bitte schau in der PHP-Dokumentation nach, wie man die GD-Bibliothek installiert und aktiviert.',0),
25003 => array('Genereller PHP Fehler : Bei %s:%d : %s',3),
25004 => array('Genereller PHP Fehler : %s ',1),
25005 => array('PHP_SELF, die PHP-Global-Variable kann nicht ermittelt werden. PHP kann nicht von der Kommandozeile gestartet werden, wenn der Cache oder die Bilddateien automatisch benannt werden sollen.',0),
25006 => array('Die Benutzung der FF_CHINESE (FF_BIG5) Schriftfamilie benötigt die iconv() Funktion in Deiner PHP-Konfiguration. Dies wird nicht defaultmäßig in PHP kompiliert (benötigt "--width-iconv" bei der Konfiguration).',0),
25007 => array('Du versuchst das lokale (%s) zu verwenden, was von Deiner PHP-Installation nicht unterstützt wird. Hinweis: Benutze \'\', um das defaultmäßige Lokale für diese geographische Region festzulegen.',1),
25008 => array('Die Bild-Breite und Höhe in Graph::Graph() müssen numerisch sein',0),
25009 => array('Die Skalierung der Achsen muss angegeben werden mit Graph::SetScale()',0),
25010 => array('Graph::Add() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0),
25011 => array('Graph::AddY2() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0),
25012 => array('Graph::AddYN() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0),
25013 => array('Es können nur Standard-Plots zu multiplen Y-Achsen hinzugefügt werden',0),
25014 => array('Graph::AddText() Du hast versucht, einen leeren Text zum Graph hinzuzufügen.',0),
25015 => array('Graph::AddLine() Du hast versucht, eine leere Linie zum Graph hinzuzufügen.',0),
25016 => array('Graph::AddBand() Du hast versucht, ein leeres Band zum Graph hinzuzufügen.',0),
25017 => array('Du benutzt GD 2.x und versuchst, ein Hintergrundbild in einem Truecolor-Bild zu verwenden. Um Hintergrundbilder mit GD 2.x zu verwenden, ist es notwendig, Truecolor zu aktivieren, indem die USE_TRUECOLOR-Konstante auf TRUE gesetzt wird. Wegen eines Bugs in GD 2.0.1 ist die Qualität der Schrift sehr schlecht, wenn Truetype-Schrift in Truecolor-Bildern verwendet werden.',0),
25018 => array('Falscher Dateiname für Graph::SetBackgroundImage() : "%s" muss eine gültige Dateinamenerweiterung (jpg,gif,png) haben, wenn die automatische Dateityperkennung verwenndet werden soll.',1),
25019 => array('Unbekannte Dateinamenerweiterung (%s) in Graph::SetBackgroundImage() für Dateiname: "%s"',2),
25020 => array('Graph::SetScale(): Dar Maximalwert muss größer sein als der Mindestwert.',0),
25021 => array('Unbekannte Achsendefinition für die Y-Achse. (%s)',1),
25022 => array('Unbekannte Achsendefinition für die X-Achse. (%s)',1),
25023 => array('Nicht unterstützter Y2-Achsentyp: "%s" muss einer von (lin,log,int) sein.',1),
25024 => array('Nicht unterstützter X-Achsentyp: "%s" muss einer von (lin,log,int) sein.',1),
25025 => array('Nicht unterstützte Tick-Dichte: %d',1),
25026 => array('Nicht unterstützter Typ der nicht angegebenen Y-Achse. Du hast entweder: 1. einen Y-Achsentyp für automatisches Skalieren definiert, aber keine Plots angegeben. 2. eine Achse direkt definiert, aber vergessen, die Tick-Dichte zu festzulegen.',0),
25027 => array('Kann cached CSIM "%s" zum Lesen nicht öffnen.',1),
25028 => array('Apache/PHP hat keine Schreibrechte, in das CSIM-Cache-Verzeichnis (%s) zu schreiben. Überprüfe die Rechte.',1),
25029 => array('Kann nicht in das CSIM "%s" schreiben. Überprüfe die Schreibrechte und den freien Speicherplatz.',1),
25030 => array('Fehlender Skriptname für StrokeCSIM(). Der Name des aktuellen Skriptes muss als erster Parameter von StrokeCSIM() angegeben werden.',0),
25031 => array('Der Achsentyp muss mittels Graph::SetScale() angegeben werden.',0),
25032 => array('Es existieren keine Plots für die Y-Achse nbr:%d',1),
25033 => array('',0),
25034 => array('Undefinierte X-Achse kann nicht gezeichnet werden. Es wurden keine Plots definiert.',0),
25035 => array('Du hast Clipping aktiviert. Clipping wird nur für Diagramme mit 0 oder 90 Grad Rotation unterstützt. Bitte verändere Deinen Rotationswinkel (=%d Grad) dementsprechend oder deaktiviere Clipping.',1),
25036 => array('Unbekannter Achsentyp AxisStyle() : %s',1),
25037 => array('Das Bildformat Deines Hintergrundbildes (%s) wird von Deiner System-Konfiguration nicht unterstützt. ',1),
25038 => array('Das Hintergrundbild scheint von einem anderen Typ (unterschiedliche Dateierweiterung) zu sein als der angegebene Typ. Angegebenen: %s; Datei: %s',2),
25039 => array('Hintergrundbild kann nicht gelesen werden: "%s"',1),
25040 => array('Es ist nicht möglich, sowohl ein Hintergrundbild als auch eine Hintergrund-Landesflagge anzugeben.',0),
25041 => array('Um Landesflaggen als Hintergrund benutzen zu können, muss die Datei "jpgraph_flags.php" eingefügt werden (per include).',0),
25042 => array('Unbekanntes Hintergrundbild-Layout',0),
25043 => array('Unbekannter Titelhintergrund-Stil.',0),
25044 => array('Automatisches Skalieren kann nicht verwendet werden, weil es unmöglich ist, einen gültigen min/max Wert für die Y-Achse zu ermitteln (nur Null-Werte).',0),
25045 => array('Die Schriftfamilien FF_HANDWRT und FF_BOOK sind wegen Copyright-Problemen nicht mehr verfügbar. Diese Schriften können nicht mehr mit JpGraph verteilt werden. Bitte lade Dir Schriften von http://corefonts.sourceforge.net/ herunter.',0),
25046 => array('Angegebene TTF-Schriftfamilie (id=%d) ist unbekannt oder existiert nicht. Bitte merke Dir, dass TTF-Schriften wegen Copyright-Problemen nicht mit JpGraph mitgeliefert werden. Du findest MS-TTF-Internetschriften (arial, courier, etc.) zum Herunterladen unter http://corefonts.sourceforge.net/',1),
25047 => array('Stil %s ist nicht verfügbar für Schriftfamilie %s',2),
25048 => array('Unbekannte Schriftstildefinition [%s].',1),
25049 => array('Schriftdatei "%s" ist nicht lesbar oder existiert nicht.',1),
25050 => array('Erstes Argument für Text::Text() muss ein String sein.',0),
25051 => array('Ungültige Richtung angegeben für Text.',0),
25052 => array('PANIK: Interner Fehler in SuperScript::Stroke(). Unbekannte vertikale Ausrichtung für Text.',0),
25053 => array('PANIK: Interner Fehler in SuperScript::Stroke(). Unbekannte horizontale Ausrichtung für Text.',0),
25054 => array('Interner Fehler: Unbekannte Grid-Achse %s',1),
25055 => array('Axis::SetTickDirection() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetTickSide().',0),
25056 => array('SetTickLabelMargin() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetLabelMargin().',0),
25057 => array('SetTextTicks() sollte nicht mehr verwendet werden. Benutze stattdessen SetTextTickInterval().',0),
25058 => array('TextLabelIntevall >= 1 muss angegeben werden.',0),
25059 => array('SetLabelPos() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetLabelSide().',0),
25060 => array('Unbekannte Ausrichtung angegeben für X-Achsentitel (%s).',1),
25061 => array('Unbekannte Ausrichtung angegeben für Y-Achsentitel (%s).',1),
25062 => array('Label unter einem Winkel werden für die Y-Achse nicht unterstützt.',0),
25063 => array('Ticks::SetPrecision() sollte nicht mehr verwendet werden. Benutze stattdessen Ticks::SetLabelFormat() (oder Ticks::SetFormatCallback()).',0),
25064 => array('Kleinere oder größere Schrittgröße ist 0. Überprüfe, ob Du fälschlicherweise SetTextTicks(0) in Deinem Skript hast. Wenn dies nicht der Fall ist, bist Du eventuell über einen Bug in JpGraph gestolpert. Bitte sende einen Report und füge den Code an, der den Fehler verursacht hat.',0),
25065 => array('Tick-Positionen müssen als array() angegeben werden',0),
25066 => array('Wenn die Tick-Positionen und -Label von Hand eingegeben werden, muss die Anzahl der Ticks und der Label gleich sein.',0),
25067 => array('Deine von Hand eingegebene Achse und Ticks sind nicht korrekt. Die Skala scheint zu klein zu sein für den Tickabstand.',0),
25068 => array('Ein Plot hat eine ungültige Achse. Dies kann beispielsweise der Fall sein, wenn Du automatisches Text-Skalieren verwendest, um ein Liniendiagramm zu zeichnen mit nur einem Datenpunkt, oder wenn die Bildfläche zu klein ist. Es kann auch der Fall sein, dass kein Datenpunkt einen numerischen Wert hat (vielleicht nur \'-\' oder \'x\').',0),
25069 => array('Grace muss größer sein als 0',0),
25070 => array('Deine Daten enthalten nicht-numerische Werte.',0),
25071 => array('Du hast mit SetAutoMin() einen Mindestwert angegeben, der größer ist als der Maximalwert für die Achse. Dies ist nicht möglich.',0),
25072 => array('Du hast mit SetAutoMax() einen Maximalwert angegeben, der kleiner ist als der Minimalwert der Achse. Dies ist nicht möglich.',0),
25073 => array('Interner Fehler. Der Integer-Skalierungs-Algorithmus-Vergleich ist außerhalb der Grenzen (r=%f).',1),
25074 => array('Interner Fehler. Der Skalierungsbereich ist negativ (%f) [für %s Achse]. Dieses Problem könnte verursacht werden durch den Versuch, \'ungültige\' Werte in die Daten-Vektoren einzugeben (z.B. nur String- oder NULL-Werte), was beim automatischen Skalieren einen Fehler erzeugt.',2),
25075 => array('Die automatischen Ticks können nicht gesetzt werden, weil min==max.',0),
25077 => array('Einstellfaktor für die Farbe muss größer sein als 0',0),
25078 => array('Unbekannte Farbe: %s',1),
25079 => array('Unbekannte Farbdefinition: %s, Größe=%d',2),
25080 => array('Der Alpha-Parameter für Farben muss zwischen 0.0 und 1.0 liegen.',0),
25081 => array('Das ausgewählte Grafikformat wird entweder nicht unterstützt oder ist unbekannt [%s]',1),
25082 => array('Es wurden ungültige Größen für Breite und Höhe beim Erstellen des Bildes definiert (Breite=%d, Höhe=%d).',2),
25083 => array('Es wurde eine ungültige Größe beim Kopieren des Bildes angegeben. Die Größe für das kopierte Bild wurde auf 1 Pixel oder weniger gesetzt.',0),
25084 => array('Fehler beim Erstellen eines temporären GD-Canvas. Möglicherweise liegt ein Arbeitsspeicherproblem vor.',0),
25085 => array('Ein Bild kann nicht aus dem angegebenen String erzeugt werden. Er ist entweder in einem nicht unterstützen Format oder er represäntiert ein kaputtes Bild.',0),
25086 => array('Du scheinst nur GD 1.x installiert zu haben. Um Alphablending zu aktivieren, ist GD 2.x oder höher notwendig. Bitte installiere GD 2.x oder versichere Dich, dass die Konstante USE_GD2 richtig gesetzt ist. Standardmäßig wird die installierte GD-Version automatisch erkannt. Ganz selten wird GD2 erkannt, obwohl nur GD1 installiert ist. Die Konstante USE_GD2 muss dann zu "false" gesetzt werden.',0),
25087 => array('Diese PHP-Version wurde ohne TTF-Unterstützung konfiguriert. PHP muss mit TTF-Unterstützung neu kompiliert und installiert werden.',0),
25088 => array('Die GD-Schriftunterstützung wurde falsch konfiguriert. Der Aufruf von imagefontwidth() ist fehlerhaft.',0),
25089 => array('Die GD-Schriftunterstützung wurde falsch konfiguriert. Der Aufruf von imagefontheight() ist fehlerhaft.',0),
25090 => array('Unbekannte Richtung angegeben im Aufruf von StrokeBoxedText() [%s].',1),
25091 => array('Die interne Schrift untestützt das Schreiben von Text in einem beliebigen Winkel nicht. Benutze stattdessen TTF-Schriften.',0),
25092 => array('Es liegt entweder ein Konfigurationsproblem mit TrueType oder ein Problem beim Lesen der Schriftdatei "%s" vor. Versichere Dich, dass die Datei existiert und Leserechte und -pfad vergeben sind. (wenn \'basedir\' restriction in PHP aktiviert ist, muss die Schriftdatei im Dokumentwurzelverzeichnis abgelegt werden). Möglicherweise ist die FreeType-Bibliothek falsch installiert. Versuche, mindestens zur FreeType-Version 2.1.13 zu aktualisieren und kompiliere GD mit einem korrekten Setup neu, damit die FreeType-Bibliothek gefunden werden kann.',1),
25093 => array('Die Schriftdatei "%s" kann nicht gelesen werden beim Aufruf von Image::GetBBoxTTF. Bitte versichere Dich, dass die Schrift gesetzt wurde, bevor diese Methode aufgerufen wird, und dass die Schrift im TTF-Verzeichnis installiert ist.',1),
25094 => array('Die Textrichtung muss in einem Winkel zwischen 0 und 90 engegeben werden.',0),
25095 => array('Unbekannte Schriftfamilien-Definition. ',0),
25096 => array('Der Farbpalette können keine weiteren Farben zugewiesen werden. Dem Bild wurde bereits die größtmögliche Anzahl von Farben (%d) zugewiesen und die Palette ist voll. Verwende stattdessen ein TrueColor-Bild',0),
25097 => array('Eine Farbe wurde als leerer String im Aufruf von PushColor() angegegeben.',0),
25098 => array('Negativer Farbindex. Unpassender Aufruf von PopColor().',0),
25099 => array('Die Parameter für Helligkeit und Kontrast sind außerhalb des zulässigen Bereichs [-1,1]',0),
25100 => array('Es liegt ein Problem mit der Farbpalette und dem GD-Setup vor. Bitte deaktiviere anti-aliasing oder verwende GD2 mit TrueColor. Wenn die GD2-Bibliothek installiert ist, versichere Dich, dass die Konstante USE_GD2 auf "true" gesetzt und TrueColor aktiviert ist.',0),
25101 => array('Ungültiges numerisches Argument für SetLineStyle(): (%d)',1),
25102 => array('Ungültiges String-Argument für SetLineStyle(): %s',1),
25103 => array('Ungültiges Argument für SetLineStyle %s',1),
25104 => array('Unbekannter Linientyp: %s',1),
25105 => array('Es wurden NULL-Daten für ein gefülltes Polygon angegeben. Sorge dafür, dass keine NULL-Daten angegeben werden.',0),
25106 => array('Image::FillToBorder : es können keine weiteren Farben zugewiesen werden.',0),
25107 => array('In Datei "%s" kann nicht geschrieben werden. Überprüfe die aktuellen Schreibrechte.',1),
25108 => array('Das Bild kann nicht gestreamt werden. Möglicherweise liegt ein Fehler im PHP/GD-Setup vor. Kompiliere PHP neu und verwende die eingebaute GD-Bibliothek, die mit PHP angeboten wird.',0),
25109 => array('Deine PHP- (und GD-lib-) Installation scheint keine bekannten Grafikformate zu unterstützen. Sorge zunächst dafür, dass GD als PHP-Modul kompiliert ist. Wenn Du außerdem JPEG-Bilder verwenden willst, musst Du die JPEG-Bibliothek installieren. Weitere Details sind in der PHP-Dokumentation zu finden.',0),
25110 => array('Dein PHP-Installation unterstützt das gewählte Grafikformat nicht: %s',1),
25111 => array('Das gecachete Bild %s kann nicht gelöscht werden. Problem mit den Rechten?',1),
25112 => array('Das Datum der gecacheten Datei (%s) liegt in der Zukunft.',1),
25113 => array('Das gecachete Bild %s kann nicht gelöscht werden. Problem mit den Rechten?',1),
25114 => array('PHP hat nicht die erforderlichen Rechte, um in die Cache-Datei %s zu schreiben. Bitte versichere Dich, dass der Benutzer, der PHP anwendet, die entsprechenden Schreibrechte für die Datei hat, wenn Du das Cache-System in JPGraph verwenden willst.',1),
25115 => array('Berechtigung für gecachetes Bild %s kann nicht gesetzt werden. Problem mit den Rechten?',1),
25116 => array('Datei kann nicht aus dem Cache %s geöffnet werden',1),
25117 => array('Gecachetes Bild %s kann nicht zum Lesen geöffnet werden.',1),
25118 => array('Verzeichnis %s kann nicht angelegt werden. Versichere Dich, dass PHP die Schreibrechte in diesem Verzeichnis hat.',1),
25119 => array('Rechte für Datei %s können nicht gesetzt werden. Problem mit den Rechten?',1),
25120 => array('Die Position für die Legende muss als Prozentwert im Bereich 0-1 angegeben werden.',0),
25121 => array('Eine leerer Datenvektor wurde für den Plot eingegeben. Es muss wenigstens ein Datenpunkt vorliegen.',0),
25122 => array('Stroke() muss als Subklasse der Klasse Plot definiert sein.',0),
25123 => array('Du kannst keine Text-X-Achse mit X-Koordinaten verwenden. Benutze stattdessen eine "int" oder "lin" Achse.',0),
25124 => array('Der Eingabedatenvektor mus aufeinanderfolgende Werte von 0 aufwärts beinhalten. Der angegebene Y-Vektor beginnt mit leeren Werten (NULL).',0),
25125 => array('Ungültige Richtung für statische Linie.',0),
25126 => array('Es kann kein TrueColor-Bild erzeugt werden. Überprüfe, ob die GD2-Bibliothek und PHP korrekt aufgesetzt wurden.',0),
25127 => array('The library has been configured for automatic encoding conversion of Japanese fonts. This requires that PHP has the mb_convert_encoding() function. Your PHP installation lacks this function (PHP needs the "--enable-mbstring" when compiled).',0),
25128 => array('The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.',0),
25129 => array('Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines.',0),
25130 => array('Too small plot area. (%d x %d). With the given image size and margins there is to little space left for the plot. Increase the plot size or reduce the margins.',2),
25131 => array('StrokeBoxedText2() only supports TTF fonts and not built-in bitmap fonts.',0),
/*
** jpgraph_led
*/
25500 => array('Multibyte strings must be enabled in the PHP installation in order to run the LED module so that the function mb_strlen() is available. See PHP documentation for more information.',0),
/*
**---------------------------------------------------------------------------------------------
** Pro-version strings
**---------------------------------------------------------------------------------------------
*/
/*
** jpgraph_table
*/
27001 => array('GTextTable: Ungültiges Argument für Set(). Das Array-Argument muss 2-- dimensional sein.',0),
27002 => array('GTextTable: Ungültiges Argument für Set()',0),
27003 => array('GTextTable: Falsche Anzahl von Argumenten für GTextTable::SetColor()',0),
27004 => array('GTextTable: Angegebener Zellenbereich, der verschmolzen werden soll, ist ungültig.',0),
27005 => array('GTextTable: Bereits verschmolzene Zellen im Bereich (%d,%d) bis (%d,%d) können nicht ein weiteres Mal verschmolzen werden.',4),
27006 => array('GTextTable: Spalten-Argument = %d liegt außerhalb der festgelegten Tabellengröße.',1),
27007 => array('GTextTable: Zeilen-Argument = %d liegt außerhalb der festgelegten Tabellengröße.',1),
27008 => array('GTextTable: Spalten- und Zeilengröße müssen zu den Dimensionen der Tabelle passen.',0),
27009 => array('GTextTable: Die Anzahl der Tabellenspalten oder -zeilen ist 0. Versichere Dich, dass die Methoden Init() oder Set() aufgerufen werden.',0),
27010 => array('GTextTable: Es wurde keine Ausrichtung beim Aufruf von SetAlign() angegeben.',0),
27011 => array('GTextTable: Es wurde eine unbekannte Ausrichtung beim Aufruf von SetAlign() abgegeben. Horizontal=%s, Vertikal=%s',2),
27012 => array('GTextTable: Interner Fehler. Es wurde ein ungültiges Argument festgeleget %s',1),
27013 => array('GTextTable: Das Argument für FormatNumber() muss ein String sein.',0),
27014 => array('GTextTable: Die Tabelle wurde weder mit einem Aufruf von Set() noch von Init() initialisiert.',0),
27015 => array('GTextTable: Der Zellenbildbedingungstyp muss entweder TIMG_WIDTH oder TIMG_HEIGHT sein.',0),
/*
** jpgraph_windrose
*/
22001 => array('Die Gesamtsumme der prozentualen Anteile aller Windrosenarme darf 100%% nicht überschreiten!\n(Aktuell max: %d)',1),
22002 => array('Das Bild ist zu klein für eine Skala. Bitte vergrößere das Bild.',0),
22004 => array('Die Etikettendefinition für Windrosenrichtungen müssen 16 Werte haben (eine für jede Kompassrichtung).',0),
22005 => array('Der Linientyp für radiale Linien muss einer von ("solid","dotted","dashed","longdashed") sein.',0),
22006 => array('Es wurde ein ungültiger Windrosentyp angegeben.',0),
22007 => array('Es wurden zu wenig Werte für die Bereichslegende angegeben.',0),
22008 => array('Interner Fehler: Versuch, eine freie Windrose zu plotten, obwohl der Typ keine freie Windrose ist.',0),
22009 => array('Du hast die gleiche Richtung zweimal angegeben, einmal mit einem Winkel und einmal mit einer Kompassrichtung (%f Grad).',0),
22010 => array('Die Richtung muss entweder ein numerischer Wert sein oder eine der 16 Kompassrichtungen',0),
22011 => array('Der Windrosenindex muss ein numerischer oder Richtungswert sein. Du hast angegeben Index=%d',1),
22012 => array('Die radiale Achsendefinition für die Windrose enthält eine nicht aktivierte Richtung.',0),
22013 => array('Du hast dasselbe Look&Feel für die gleiche Kompassrichtung zweimal engegeben, einmal mit Text und einmal mit einem Index (Index=%d)',1),
22014 => array('Der Index für eine Kompassrichtung muss zwischen 0 und 15 sein.',0),
22015 => array('Du hast einen unbekannten Windrosenplottyp angegeben.',0),
22016 => array('Der Windrosenarmindex muss ein numerischer oder ein Richtungswert sein.',0),
22017 => array('Die Windrosendaten enthalten eine Richtung, die nicht aktiviert ist. Bitte berichtige, welche Label angezeigt werden sollen.',0),
22018 => array('Du hast für dieselbe Kompassrichtung zweimal Daten angegeben, einmal mit Text und einmal mit einem Index (Index=%d)',1),
22019 => array('Der Index für eine Richtung muss zwischen 0 und 15 sein. Winkel dürfen nicht für einen regelmäßigen Windplot angegeben werden, sondern entweder ein Index oder eine Kompassrichtung.',0),
22020 => array('Der Windrosenplot ist zu groß für die angegebene Bildgröße. Benutze entweder WindrosePlot::SetSize(), um den Plot kleiner zu machen oder vergrößere das Bild im ursprünglichen Aufruf von WindroseGraph().',0),
22021 => array('It is only possible to add Text, IconPlot or WindrosePlot to a Windrose Graph',0),
/*
** jpgraph_odometer
*/
13001 => array('Unbekannter Nadeltypstil (%d).',1),
13002 => array('Ein Wert für das Odometer (%f) ist außerhalb des angegebenen Bereichs [%f,%f]',3),
/*
** jpgraph_barcode
*/
1001 => array('Unbekannte Kodier-Specifikation: %s',1),
1002 => array('datenvalidierung schlug fehl. [%s] kann nicht mittels der Kodierung "%s" kodiert werden',2),
1003 => array('Interner Kodierfehler. Kodieren von %s ist nicht möglich in Code 128',1),
1004 => array('Interner barcode Fehler. Unbekannter UPC-E Kodiertyp: %s',1),
1005 => array('Interner Fehler. Das Textzeichen-Tupel (%s, %s) kann nicht im Code-128 Zeichensatz C kodiert werden.',2),
1006 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, CTRL in CHARSET != A zu kodieren.',0),
1007 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, DEL in CHARSET != B zu kodieren.',0),
1008 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, kleine Buchstaben in CHARSET != B zu kodieren.',0),
1009 => array('Kodieren mittels CODE 93 wird noch nicht unterstützt.',0),
1010 => array('Kodieren mittels POSTNET wird noch nicht unterstützt.',0),
1011 => array('Nicht untrstütztes Barcode-Backend für den Typ %s',1),
/*
** PDF417
*/
26000 => array('PDF417: The PDF417 module requires that the PHP installation must support the function bcmod(). This is normally enabled at compile time. See documentation for more information.',0),
26001 => array('PDF417: Die Anzahl der Spalten muss zwischen 1 und 30 sein.',0),
26002 => array('PDF417: Der Fehler-Level muss zwischen 0 und 8 sein.',0),
26003 => array('PDF417: Ungültiges Format für Eingabedaten, um sie mit PDF417 zu kodieren.',0),
26004 => array('PDF417: die eigebenen Daten können nicht mit Fehler-Level %d und %d spalten kodiert werden, weil daraus zu viele Symbole oder mehr als 90 Zeilen resultieren.',2),
26005 => array('PDF417: Die Datei "%s" kann nicht zum Schreiben geöffnet werden.',1),
26006 => array('PDF417: Interner Fehler. Die Eingabedatendatei für PDF417-Cluster %d ist fehlerhaft.',1),
26007 => array('PDF417: Interner Fehler. GetPattern: Ungültiger Code-Wert %d (Zeile %d)',2),
26008 => array('PDF417: Interner Fehler. Modus wurde nicht in der Modusliste!! Modus %d',1),
26009 => array('PDF417: Kodierfehler: Ungültiges Zeichen. Zeichen kann nicht mit ASCII-Code %d kodiert werden.',1),
26010 => array('PDF417: Interner Fehler: Keine Eingabedaten beim Dekodieren.',0),
26011 => array('PDF417: Kodierfehler. Numerisches Kodieren bei nicht-numerischen Daten nicht möglich.',0),
26012 => array('PDF417: Interner Fehler. Es wurden für den Binary-Kompressor keine Daten zum Dekodieren eingegeben.',0),
26013 => array('PDF417: Interner Fehler. Checksum Fehler. Koeffiziententabellen sind fehlerhaft.',0),
26014 => array('PDF417: Interner Fehler. Es wurden keine Daten zum Berechnen von Kodewörtern eingegeben.',0),
26015 => array('PDF417: Interner Fehler. Ein Eintrag 0 in die Statusübertragungstabellen ist nicht NULL. Eintrag 1 = (%s)',1),
26016 => array('PDF417: Interner Fehler: Nichtregistrierter Statusübertragungsmodus beim Dekodieren.',0),
/*
** jpgraph_contour
*/
28001 => array('Dritten parameter fur Contour muss ein vector der fargen sind.',0),
28002 => array('Die anzahlen der farges jeder isobar linien muss gleich sein.',0),
28003 => array('ContourPlot Interner Fehler: isobarHCrossing: Spalten index ist zu hoch (%d)',1),
28004 => array('ContourPlot Interner Fehler: isobarHCrossing: Reihe index ist zu hoch (%d)',1),
28005 => array('ContourPlot Interner Fehler: isobarVCrossing: Reihe index ist zu hoch (%d)',1),
28006 => array('ContourPlot Interner Fehler: isobarVCrossing: Spalten index ist zu hoch (%d)',1),
28007 => array('ContourPlot. Interpolation faktor ist zu hoch (>5)',0),
/*
* jpgraph_matrix and colormap
*/
29201 => array('Min range value must be less or equal to max range value for colormaps',0),
29202 => array('The distance between min and max value is too small for numerical precision',0),
29203 => array('Number of color quantification level must be at least %d',1),
29204 => array('Number of colors (%d) is invalid for this colormap. It must be a number that can be written as: %d + k*%d',3),
29205 => array('Colormap specification out of range. Must be an integer in range [0,%d]',1),
29206 => array('Invalid object added to MatrixGraph',0),
29207 => array('Empty input data specified for MatrixPlot',0),
29208 => array('Unknown side specifiction for matrix labels "%s"',1),
29209 => array('CSIM Target matrix must be the same size as the data matrix (csim=%d x %d, data=%d x %d)',4),
29210 => array('CSIM Target for matrix labels does not match the number of labels (csim=%d, labels=%d)',2),
);
?>

View File

@ -1,536 +0,0 @@
<?php
/*=======================================================================
// File: EN.INC.PHP
// Description: English language file for error messages
// Created: 2006-01-25
// Ver: $Id: en.inc.php 1886 2009-10-01 23:30:16Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
// Note: Format of each error message is array(<error message>,<number of arguments>)
$_jpg_messages = array(
/*
** Headers already sent error. This is formatted as HTML different since this will be sent back directly as text
*/
10 => array('<table border="1"><tr><td style="color:darkred; font-size:1.2em;"><b>JpGraph Error:</b>
HTTP headers have already been sent.<br>Caused by output from file <b>%s</b> at line <b>%d</b>.</td></tr><tr><td><b>Explanation:</b><br>HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it\'s image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).<p>Most likely you have some text in your script before the call to <i>Graph::Stroke()</i>. If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser. <p>For example it is a common mistake to leave a blank line before the opening "<b>&lt;?php</b>".</td></tr></table>',2),
/*
** Setup errors
*/
11 => array('No path specified for CACHE_DIR. Please specify CACHE_DIR manually in jpg-config.inc',0),
12 => array('No path specified for TTF_DIR and path can not be determined automatically. Please specify TTF_DIR manually (in jpg-config.inc).',0),
13 => array('The installed PHP version (%s) is not compatible with this release of the library. The library requires at least PHP version %s',2),
/*
** jpgraph_bar
*/
2001 => array('Number of colors is not the same as the number of patterns in BarPlot::SetPattern()',0),
2002 => array('Unknown pattern specified in call to BarPlot::SetPattern()',0),
2003 => array('Number of X and Y points are not equal. Number of X-points: %d Number of Y-points: %d',2),
2004 => array('All values for a barplot must be numeric. You have specified value nr [%d] == %s',2),
2005 => array('You have specified an empty array for shadow colors in the bar plot.',0),
2006 => array('Unknown position for values on bars : %s',1),
2007 => array('Cannot create GroupBarPlot from empty plot array.',0),
2008 => array('Group bar plot element nbr %d is undefined or empty.',0),
2009 => array('One of the objects submitted to GroupBar is not a BarPlot. Make sure that you create the GroupBar plot from an array of BarPlot or AccBarPlot objects. (Class = %s)',1),
2010 => array('Cannot create AccBarPlot from empty plot array.',0),
2011 => array('Acc bar plot element nbr %d is undefined or empty.',1),
2012 => array('One of the objects submitted to AccBar is not a BarPlot. Make sure that you create the AccBar plot from an array of BarPlot objects. (Class=%s)',1),
2013 => array('You have specified an empty array for shadow colors in the bar plot.',0),
2014 => array('Number of datapoints for each data set in accbarplot must be the same',0),
2015 => array('Individual bar plots in an AccBarPlot or GroupBarPlot can not have specified X-coordinates',0),
/*
** jpgraph_date
*/
3001 => array('It is only possible to use either SetDateAlign() or SetTimeAlign() but not both',0),
/*
** jpgraph_error
*/
4002 => array('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3',0),
/*
** jpgraph_flags
*/
5001 => array('Unknown flag size (%d).',1),
5002 => array('Flag index %s does not exist.',1),
5003 => array('Invalid ordinal number (%d) specified for flag index.',1),
5004 => array('The (partial) country name %s does not have a corresponding flag image. The flag may still exist but under another name, e.g. instead of "usa" try "united states".',1),
/*
** jpgraph_gantt
*/
6001 => array('Internal error. Height for ActivityTitles is < 0',0),
6002 => array('You can\'t specify negative sizes for Gantt graph dimensions. Use 0 to indicate that you want the library to automatically determine a dimension.',0),
6003 => array('Invalid format for Constrain parameter at index=%d in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Constrain-To,Constrain-Type)',1),
6004 => array('Invalid format for Progress parameter at index=%d in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Progress)',1),
6005 => array('SetScale() is not meaningful with Gantt charts.',0),
6006 => array('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]',0),
6007 => array('Sanity check for automatic Gantt chart size failed. Either the width (=%d) or height (=%d) is larger than MAX_GANTTIMG_SIZE. This could potentially be caused by a wrong date in one of the activities.',2),
6008 => array('You have specified a constrain from row=%d to row=%d which does not have any activity',2),
6009 => array('Unknown constrain type specified from row=%d to row=%d',2),
6010 => array('Illegal icon index for Gantt builtin icon [%d]',1),
6011 => array('Argument to IconImage must be string or integer',0),
6012 => array('Unknown type in Gantt object title specification',0),
6015 => array('Illegal vertical position %d',1),
6016 => array('Date string (%s) specified for Gantt activity can not be interpretated. Please make sure it is a valid time string, e.g. 2005-04-23 13:30',1),
6017 => array('Unknown date format in GanttScale (%s).',1),
6018 => array('Interval for minutes must divide the hour evenly, e.g. 1,5,10,12,15,20,30 etc You have specified an interval of %d minutes.',1),
6019 => array('The available width (%d) for minutes are to small for this scale to be displayed. Please use auto-sizing or increase the width of the graph.',1),
6020 => array('Interval for hours must divide the day evenly, e.g. 0:30, 1:00, 1:30, 4:00 etc. You have specified an interval of %d',1),
6021 => array('Unknown formatting style for week.',0),
6022 => array('Gantt scale has not been specified.',0),
6023 => array('If you display both hour and minutes the hour interval must be 1 (Otherwise it doesn\'t make sense to display minutes).',0),
6024 => array('CSIM Target must be specified as a string. Start of target is: %d',1),
6025 => array('CSIM Alt text must be specified as a string. Start of alt text is: %d',1),
6027 => array('Progress value must in range [0, 1]',0),
6028 => array('Specified height (%d) for gantt bar is out of range.',1),
6029 => array('Offset for vertical line must be in range [0,1]',0),
6030 => array('Unknown arrow direction for link.',0),
6031 => array('Unknown arrow type for link.',0),
6032 => array('Internal error: Unknown path type (=%d) specified for link.',1),
6033 => array('Array of fonts must contain arrays with 3 elements, i.e. (Family, Style, Size)',0),
/*
** jpgraph_gradient
*/
7001 => array('Unknown gradient style (=%d).',1),
/*
** jpgraph_iconplot
*/
8001 => array('Mix value for icon must be between 0 and 100.',0),
8002 => array('Anchor position for icons must be one of "top", "bottom", "left", "right" or "center"',0),
8003 => array('It is not possible to specify both an image file and a country flag for the same icon.',0),
8004 => array('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.',0),
/*
** jpgraph_imgtrans
*/
9001 => array('Value for image transformation out of bounds. Vanishing point on horizon must be specified as a value between 0 and 1.',0),
/*
** jpgraph_lineplot
*/
10001 => array('LinePlot::SetFilled() is deprecated. Use SetFillColor()',0),
10002 => array('Plot too complicated for fast line Stroke. Use standard Stroke()',0),
10003 => array('Each plot in an accumulated lineplot must have the same number of data points.',0),
/*
** jpgraph_log
*/
11001 => array('Your data contains non-numeric values.',0),
11002 => array('Negative data values can not be used in a log scale.',0),
11003 => array('Your data contains non-numeric values.',0),
11004 => array('Scale error for logarithmic scale. You have a problem with your data values. The max value must be greater than 0. It is mathematically impossible to have 0 in a logarithmic scale.',0),
11005 => array('Specifying tick interval for a logarithmic scale is undefined. Remove any calls to SetTextLabelStart() or SetTextTickInterval() on the logarithmic scale.',0),
/*
** jpgraph_mgraph
*/
12001 => array("You are using GD 2.x and are trying to use a background images on a non truecolor image. To use background images with GD 2.x it is necessary to enable truecolor by setting the USE_TRUECOLOR constant to TRUE. Due to a bug in GD 2.0.1 using any truetype fonts with truecolor images will result in very poor quality fonts.",0),
12002 => array('Incorrect file name for MGraph::SetBackgroundImage() : %s Must have a valid image extension (jpg,gif,png) when using auto detection of image type',1),
12003 => array('Unknown file extension (%s) in MGraph::SetBackgroundImage() for filename: %s',2),
12004 => array('The image format of your background image (%s) is not supported in your system configuration. ',1),
12005 => array('Can\'t read background image: %s',1),
12006 => array('Illegal sizes specified for width or height when creating an image, (width=%d, height=%d)',2),
12007 => array('Argument to MGraph::Add() is not a valid GD image handle.',0),
12008 => array('Your PHP (and GD-lib) installation does not appear to support any known graphic formats.',0),
12009 => array('Your PHP installation does not support the chosen graphic format: %s',1),
12010 => array('Can\'t create or stream image to file %s Check that PHP has enough permission to write a file to the current directory.',1),
12011 => array('Can\'t create truecolor image. Check that you really have GD2 library installed.',0),
12012 => array('Can\'t create image. Check that you really have GD2 library installed.',0),
/*
** jpgraph_pie3d
*/
14001 => array('Pie3D::ShowBorder() . Deprecated function. Use Pie3D::SetEdge() to control the edges around slices.',0),
14002 => array('PiePlot3D::SetAngle() 3D Pie projection angle must be between 5 and 85 degrees.',0),
14003 => array('Internal assertion failed. Pie3D::Pie3DSlice',0),
14004 => array('Slice start angle must be between 0 and 360 degrees.',0),
14005 => array('Pie3D Internal error: Trying to wrap twice when looking for start index',0,),
14006 => array('Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.',0),
14007 => array('Width for 3D Pie is 0. Specify a size > 0',0),
/*
** jpgraph_pie
*/
15001 => array('PiePLot::SetTheme() Unknown theme: %s',1),
15002 => array('Argument to PiePlot::ExplodeSlice() must be an integer',0),
15003 => array('Argument to PiePlot::Explode() must be an array with integer distances.',0),
15004 => array('Slice start angle must be between 0 and 360 degrees.',0),
15005 => array('PiePlot::SetFont() is deprecated. Use PiePlot->value->SetFont() instead.',0),
15006 => array('PiePlot::SetSize() Radius for pie must either be specified as a fraction [0, 0.5] of the size of the image or as an absolute size in pixels in the range [10, 1000]',0),
15007 => array('PiePlot::SetFontColor() is deprecated. Use PiePlot->value->SetColor() instead.',0),
15008 => array('PiePlot::SetLabelType() Type for pie plots must be 0 or 1 (not %d).',1),
15009 => array('Illegal pie plot. Sum of all data is zero for Pie Plot',0),
15010 => array('Sum of all data is 0 for Pie.',0),
15011 => array('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.',0),
/*
** jpgraph_plotband
*/
16001 => array('Density for pattern must be between 1 and 100. (You tried %f)',1),
16002 => array('No positions specified for pattern.',0),
16003 => array('Unknown pattern specification (%d)',0),
16004 => array('Min value for plotband is larger than specified max value. Please correct.',0),
/*
** jpgraph_polar
*/
17001 => array('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).',0),
17002 => array('Unknown alignment specified for X-axis title. (%s)',1),
//17003 => array('Set90AndMargin() is not supported for polar graphs.',0),
17004 => array('Unknown scale type for polar graph. Must be "lin" or "log"',0),
/*
** jpgraph_radar
*/
18001 => array('Client side image maps not supported for RadarPlots.',0),
18002 => array('RadarGraph::SupressTickMarks() is deprecated. Use HideTickMarks() instead.',0),
18003 => array('Illegal scale for radarplot (%s). Must be \'lin\' or \'log\'',1),
18004 => array('Radar Plot size must be between 0.1 and 1. (Your value=%f)',1),
18005 => array('RadarPlot Unsupported Tick density: %d',1),
18006 => array('Minimum data %f (Radar plots should only be used when all data points > 0)',1),
18007 => array('Number of titles does not match number of points in plot.',0),
18008 => array('Each radar plot must have the same number of data points.',0),
/*
** jpgraph_regstat
*/
19001 => array('Spline: Number of X and Y coordinates must be the same',0),
19002 => array('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.',0),
19003 => array('Bezier: Number of X and Y coordinates must be the same',0),
/*
** jpgraph_scatter
*/
20001 => array('Fieldplots must have equal number of X and Y points.',0),
20002 => array('Fieldplots must have an angle specified for each X and Y points.',0),
20003 => array('Scatterplot must have equal number of X and Y points.',0),
/*
** jpgraph_stock
*/
21001 => array('Data values for Stock charts must contain an even multiple of %d data points.',1),
/*
** jpgraph_plotmark
*/
23001 => array('This marker "%s" does not exist in color with index: %d',2),
23002 => array('Mark color index too large for marker "%s"',1),
23003 => array('A filename must be specified if you set the mark type to MARK_IMG.',0),
/*
** jpgraph_utils
*/
24001 => array('FuncGenerator : No function specified. ',0),
24002 => array('FuncGenerator : Syntax error in function specification ',0),
24003 => array('DateScaleUtils: Unknown tick type specified in call to GetTicks()',0),
24004 => array('ReadCSV2: Column count mismatch in %s line %d',2),
/*
** jpgraph
*/
25001 => array('This PHP installation is not configured with the GD library. Please recompile PHP with GD support to run JpGraph. (Neither function imagetypes() nor imagecreatefromstring() does exist)',0),
25002 => array('Your PHP installation does not seem to have the required GD library. Please see the PHP documentation on how to install and enable the GD library.',0),
25003 => array('General PHP error : At %s:%d : %s',3),
25004 => array('General PHP error : %s ',1),
25005 => array('Can\'t access PHP_SELF, PHP global variable. You can\'t run PHP from command line if you want to use the \'auto\' naming of cache or image files.',0),
25006 => array('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).',0),
25007 => array('You are trying to use the locale (%s) which your PHP installation does not support. Hint: Use \'\' to indicate the default locale for this geographic region.',1),
25008 => array('Image width/height argument in Graph::Graph() must be numeric',0),
25009 => array('You must specify what scale to use with a call to Graph::SetScale()',0),
25010 => array('Graph::Add() You tried to add a null plot to the graph.',0),
25011 => array('Graph::AddY2() You tried to add a null plot to the graph.',0),
25012 => array('Graph::AddYN() You tried to add a null plot to the graph.',0),
25013 => array('You can only add standard plots to multiple Y-axis',0),
25014 => array('Graph::AddText() You tried to add a null text to the graph.',0),
25015 => array('Graph::AddLine() You tried to add a null line to the graph.',0),
25016 => array('Graph::AddBand() You tried to add a null band to the graph.',0),
25017 => array('You are using GD 2.x and are trying to use a background images on a non truecolor image. To use background images with GD 2.x it is necessary to enable truecolor by setting the USE_TRUECOLOR constant to TRUE. Due to a bug in GD 2.0.1 using any truetype fonts with truecolor images will result in very poor quality fonts.',0),
25018 => array('Incorrect file name for Graph::SetBackgroundImage() : "%s" Must have a valid image extension (jpg,gif,png) when using auto detection of image type',1),
25019 => array('Unknown file extension (%s) in Graph::SetBackgroundImage() for filename: "%s"',2),
25020 => array('Graph::SetScale(): Specified Max value must be larger than the specified Min value.',0),
25021 => array('Unknown scale specification for Y-scale. (%s)',1),
25022 => array('Unknown scale specification for X-scale. (%s)',1),
25023 => array('Unsupported Y2 axis type: "%s" Must be one of (lin,log,int)',1),
25024 => array('Unsupported Y axis type: "%s" Must be one of (lin,log,int)',1),
25025 => array('Unsupported Tick density: %d',1),
25026 => array('Can\'t draw unspecified Y-scale. You have either: 1. Specified an Y axis for auto scaling but have not supplied any plots. 2. Specified a scale manually but have forgot to specify the tick steps',0),
25027 => array('Can\'t open cached CSIM "%s" for reading.',1),
25028 => array('Apache/PHP does not have permission to write to the CSIM cache directory (%s). Check permissions.',1),
25029 => array('Can\'t write CSIM "%s" for writing. Check free space and permissions.',1),
25030 => array('Missing script name in call to StrokeCSIM(). You must specify the name of the actual image script as the first parameter to StrokeCSIM().',0),
25031 => array('You must specify what scale to use with a call to Graph::SetScale().',0),
25032 => array('No plots for Y-axis nbr:%d',1),
25033 => array('',0),
25034 => array('Can\'t draw unspecified X-scale. No plots specified.',0),
25035 => array('You have enabled clipping. Clipping is only supported for graphs at 0 or 90 degrees rotation. Please adjust you current angle (=%d degrees) or disable clipping.',1),
25036 => array('Unknown AxisStyle() : %s',1),
25037 => array('The image format of your background image (%s) is not supported in your system configuration. ',1),
25038 => array('Background image seems to be of different type (has different file extension) than specified imagetype. Specified: %s File: %s',2),
25039 => array('Can\'t read background image: "%s"',1),
25040 => array('It is not possible to specify both a background image and a background country flag.',0),
25041 => array('In order to use Country flags as backgrounds you must include the "jpgraph_flags.php" file.',0),
25042 => array('Unknown background image layout',0),
25043 => array('Unknown title background style.',0),
25044 => array('Cannot use auto scaling since it is impossible to determine a valid min/max value of the Y-axis (only null values).',0),
25045 => array('Font families FF_HANDWRT and FF_BOOK are no longer available due to copyright problem with these fonts. Fonts can no longer be distributed with JpGraph. Please download fonts from http://corefonts.sourceforge.net/',0),
25046 => array('Specified TTF font family (id=%d) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/',1),
25047 => array('Style %s is not available for font family %s',2),
25048 => array('Unknown font style specification [%s].',1),
25049 => array('Font file "%s" is not readable or does not exist.',1),
25050 => array('First argument to Text::Text() must be a string.',0),
25051 => array('Invalid direction specified for text.',0),
25052 => array('PANIC: Internal error in SuperScript::Stroke(). Unknown vertical alignment for text',0),
25053 => array('PANIC: Internal error in SuperScript::Stroke(). Unknown horizontal alignment for text',0),
25054 => array('Internal error: Unknown grid axis %s',1),
25055 => array('Axis::SetTickDirection() is deprecated. Use Axis::SetTickSide() instead',0),
25056 => array('SetTickLabelMargin() is deprecated. Use Axis::SetLabelMargin() instead.',0),
25057 => array('SetTextTicks() is deprecated. Use SetTextTickInterval() instead.',0),
25058 => array('Text label interval must be specified >= 1.',0),
25059 => array('SetLabelPos() is deprecated. Use Axis::SetLabelSide() instead.',0),
25060 => array('Unknown alignment specified for X-axis title. (%s)',1),
25061 => array('Unknown alignment specified for Y-axis title. (%s)',1),
25062 => array('Labels at an angle are not supported on Y-axis',0),
25063 => array('Ticks::SetPrecision() is deprecated. Use Ticks::SetLabelFormat() (or Ticks::SetFormatCallback()) instead',0),
25064 => array('Minor or major step size is 0. Check that you haven\'t got an accidental SetTextTicks(0) in your code. If this is not the case you might have stumbled upon a bug in JpGraph. Please report this and if possible include the data that caused the problem',0),
25065 => array('Tick positions must be specified as an array()',0),
25066 => array('When manually specifying tick positions and labels the number of labels must be the same as the number of specified ticks.',0),
25067 => array('Your manually specified scale and ticks is not correct. The scale seems to be too small to hold any of the specified tick marks.',0),
25068 => array('A plot has an illegal scale. This could for example be that you are trying to use text auto scaling to draw a line plot with only one point or that the plot area is too small. It could also be that no input data value is numeric (perhaps only \'-\' or \'x\')',0),
25069 => array('Grace must be larger then 0',0),
25070 => array('Either X or Y data arrays contains non-numeric values. Check that the data is really specified as numeric data and not as strings. It is an error to specify data for example as \'-2345.2\' (using quotes).',0),
25071 => array('You have specified a min value with SetAutoMin() which is larger than the maximum value used for the scale. This is not possible.',0),
25072 => array('You have specified a max value with SetAutoMax() which is smaller than the minimum value used for the scale. This is not possible.',0),
25073 => array('Internal error. Integer scale algorithm comparison out of bound (r=%f)',1),
25074 => array('Internal error. The scale range is negative (%f) [for %s scale] This problem could potentially be caused by trying to use \"illegal\" values in the input data arrays (like trying to send in strings or only NULL values) which causes the auto scaling to fail.',2),
25075 => array('Can\'t automatically determine ticks since min==max.',0),
25077 => array('Adjustment factor for color must be > 0',0),
25078 => array('Unknown color: %s',1),
25079 => array('Unknown color specification: %s, size=%d',2),
25080 => array('Alpha parameter for color must be between 0.0 and 1.0',0),
25081 => array('Selected graphic format is either not supported or unknown [%s]',1),
25082 => array('Illegal sizes specified for width or height when creating an image, (width=%d, height=%d)',2),
25083 => array('Illegal image size when copying image. Size for copied to image is 1 pixel or less.',0),
25084 => array('Failed to create temporary GD canvas. Possible Out of memory problem.',0),
25085 => array('An image can not be created from the supplied string. It is either in a format not supported or the string is representing an corrupt image.',0),
25086 => array('You only seem to have GD 1.x installed. To enable Alphablending requires GD 2.x or higher. Please install GD or make sure the constant USE_GD2 is specified correctly to reflect your installation. By default it tries to auto detect what version of GD you have installed. On some very rare occasions it may falsely detect GD2 where only GD1 is installed. You must then set USE_GD2 to false.',0),
25087 => array('This PHP build has not been configured with TTF support. You need to recompile your PHP installation with FreeType support.',0),
25088 => array('You have a misconfigured GD font support. The call to imagefontwidth() fails.',0),
25089 => array('You have a misconfigured GD font support. The call to imagefontheight() fails.',0),
25090 => array('Unknown direction specified in call to StrokeBoxedText() [%s]',1),
25091 => array('Internal font does not support drawing text at arbitrary angle. Use TTF fonts instead.',0),
25092 => array('There is either a configuration problem with TrueType or a problem reading font file "%s" Make sure file exists and is in a readable place for the HTTP process. (If \'basedir\' restriction is enabled in PHP then the font file must be located in the document root.). It might also be a wrongly installed FreeType library. Try upgrading to at least FreeType 2.1.13 and recompile GD with the correct setup so it can find the new FT library.',1),
25093 => array('Can not read font file "%s" in call to Image::GetBBoxTTF. Please make sure that you have set a font before calling this method and that the font is installed in the TTF directory.',1),
25094 => array('Direction for text most be given as an angle between 0 and 90.',0),
25095 => array('Unknown font font family specification. ',0),
25096 => array('Can\'t allocate any more colors in palette image. Image has already allocated maximum of %d colors and the palette is now full. Change to a truecolor image instead',0),
25097 => array('Color specified as empty string in PushColor().',0),
25098 => array('Negative Color stack index. Unmatched call to PopColor()',0),
25099 => array('Parameters for brightness and Contrast out of range [-1,1]',0),
25100 => array('Problem with color palette and your GD setup. Please disable anti-aliasing or use GD2 with true-color. If you have GD2 library installed please make sure that you have set the USE_GD2 constant to true and truecolor is enabled.',0),
25101 => array('Illegal numeric argument to SetLineStyle(): (%d)',1),
25102 => array('Illegal string argument to SetLineStyle(): %s',1),
25103 => array('Illegal argument to SetLineStyle %s',1),
25104 => array('Unknown line style: %s',1),
25105 => array('NULL data specified for a filled polygon. Check that your data is not NULL.',0),
25106 => array('Image::FillToBorder : Can not allocate more colors',0),
25107 => array('Can\'t write to file "%s". Check that the process running PHP has enough permission.',1),
25108 => array('Can\'t stream image. This is most likely due to a faulty PHP/GD setup. Try to recompile PHP and use the built-in GD library that comes with PHP.',0),
25109 => array('Your PHP (and GD-lib) installation does not appear to support any known graphic formats. You need to first make sure GD is compiled as a module to PHP. If you also want to use JPEG images you must get the JPEG library. Please see the PHP docs for details.',0),
25110 => array('Your PHP installation does not support the chosen graphic format: %s',1),
25111 => array('Can\'t delete cached image %s. Permission problem?',1),
25112 => array('Cached imagefile (%s) has file date in the future.',1),
25113 => array('Can\'t delete cached image "%s". Permission problem?',1),
25114 => array('PHP has not enough permissions to write to the cache file "%s". Please make sure that the user running PHP has write permission for this file if you wan to use the cache system with JpGraph.',1),
25115 => array('Can\'t set permission for cached image "%s". Permission problem?',1),
25116 => array('Cant open file from cache "%s"',1),
25117 => array('Can\'t open cached image "%s" for reading.',1),
25118 => array('Can\'t create directory "%s". Make sure PHP has write permission to this directory.',1),
25119 => array('Can\'t set permissions for "%s". Permission problems?',1),
25120 => array('Position for legend must be given as percentage in range 0-1',0),
25121 => array('Empty input data array specified for plot. Must have at least one data point.',0),
25122 => array('Stroke() must be implemented by concrete subclass to class Plot',0),
25123 => array('You can\'t use a text X-scale with specified X-coords. Use a "int" or "lin" scale instead.',0),
25124 => array('The input data array must have consecutive values from position 0 and forward. The given y-array starts with empty values (NULL)',0),
25125 => array('Illegal direction for static line',0),
25126 => array('Can\'t create truecolor image. Check that the GD2 library is properly setup with PHP.',0),
25127 => array('The library has been configured for automatic encoding conversion of Japanese fonts. This requires that PHP has the mb_convert_encoding() function. Your PHP installation lacks this function (PHP needs the "--enable-mbstring" when compiled).',0),
25128 => array('The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.',0),
25129 => array('Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines.',0),
25130 => array('Too small plot area. (%d x %d). With the given image size and margins there is to little space left for the plot. Increase the plot size or reduce the margins.',2),
25131 => array('StrokeBoxedText2() only supports TTF fonts and not built-in bitmap fonts.',0),
/*
** jpgraph_led
*/
25500 => array('Multibyte strings must be enabled in the PHP installation in order to run the LED module so that the function mb_strlen() is available. See PHP documentation for more information.',0),
/*
**---------------------------------------------------------------------------------------------
** Pro-version strings
**---------------------------------------------------------------------------------------------
*/
/*
** jpgraph_table
*/
27001 => array('GTextTable: Invalid argument to Set(). Array argument must be 2 dimensional',0),
27002 => array('GTextTable: Invalid argument to Set()',0),
27003 => array('GTextTable: Wrong number of arguments to GTextTable::SetColor()',0),
27004 => array('GTextTable: Specified cell range to be merged is not valid.',0),
27005 => array('GTextTable: Cannot merge already merged cells in the range: (%d,%d) to (%d,%d)',4),
27006 => array('GTextTable: Column argument = %d is outside specified table size.',1),
27007 => array('GTextTable: Row argument = %d is outside specified table size.',1),
27008 => array('GTextTable: Column and row size arrays must match the dimensions of the table',0),
27009 => array('GTextTable: Number of table columns or rows are 0. Make sure Init() or Set() is called.',0),
27010 => array('GTextTable: No alignment specified in call to SetAlign()',0),
27011 => array('GTextTable: Unknown alignment specified in SetAlign(). Horizontal=%s, Vertical=%s',2),
27012 => array('GTextTable: Internal error. Invalid alignment specified =%s',1),
27013 => array('GTextTable: Argument to FormatNumber() must be a string.',0),
27014 => array('GTextTable: Table is not initilaized with either a call to Set() or Init()',0),
27015 => array('GTextTable: Cell image constrain type must be TIMG_WIDTH or TIMG_HEIGHT',0),
/*
** jpgraph_windrose
*/
22001 => array('Total percentage for all windrose legs in a windrose plot can not exceed 100%% !\n(Current max is: %d)',1),
22002 => array('Graph is too small to have a scale. Please make the graph larger.',0),
22004 => array('Label specification for windrose directions must have 16 values (one for each compass direction).',0),
22005 => array('Line style for radial lines must be on of ("solid","dotted","dashed","longdashed") ',0),
22006 => array('Illegal windrose type specified.',0),
22007 => array('To few values for the range legend.',0),
22008 => array('Internal error: Trying to plot free Windrose even though type is not a free windrose',0),
22009 => array('You have specified the same direction twice, once with an angle and once with a compass direction (%f degrees)',0),
22010 => array('Direction must either be a numeric value or one of the 16 compass directions',0),
22011 => array('Windrose index must be numeric or direction label. You have specified index=%d',1),
22012 => array('Windrose radial axis specification contains a direction which is not enabled.',0),
22013 => array('You have specified the look&feel for the same compass direction twice, once with text and once with index (Index=%d)',1),
22014 => array('Index for compass direction must be between 0 and 15.',0),
22015 => array('You have specified an undefined Windrose plot type.',0),
22016 => array('Windrose leg index must be numeric or direction label.',0),
22017 => array('Windrose data contains a direction which is not enabled. Please adjust what labels are displayed.',0),
22018 => array('You have specified data for the same compass direction twice, once with text and once with index (Index=%d)',1),
22019 => array('Index for direction must be between 0 and 15. You can\'t specify angles for a Regular Windplot, only index and compass directions.',0),
22020 => array('Windrose plot is too large to fit the specified Graph size. Please use WindrosePlot::SetSize() to make the plot smaller or increase the size of the Graph in the initial WindroseGraph() call.',0),
22021 => array('It is only possible to add Text, IconPlot or WindrosePlot to a Windrose Graph',0),
/*
** jpgraph_odometer
*/
13001 => array('Unknown needle style (%d).',1),
13002 => array('Value for odometer (%f) is outside specified scale [%f,%f]',3),
/*
** jpgraph_barcode
*/
1001 => array('Unknown encoder specification: %s',1),
1002 => array('Data validation failed. Can\'t encode [%s] using encoding "%s"',2),
1003 => array('Internal encoding error. Trying to encode %s is not possible in Code 128',1),
1004 => array('Internal barcode error. Unknown UPC-E encoding type: %s',1),
1005 => array('Internal error. Can\'t encode character tuple (%s, %s) in Code-128 charset C',2),
1006 => array('Internal encoding error for CODE 128. Trying to encode control character in CHARSET != A',0),
1007 => array('Internal encoding error for CODE 128. Trying to encode DEL in CHARSET != B',0),
1008 => array('Internal encoding error for CODE 128. Trying to encode small letters in CHARSET != B',0),
1009 => array('Encoding using CODE 93 is not yet supported.',0),
1010 => array('Encoding using POSTNET is not yet supported.',0),
1011 => array('Non supported barcode backend for type %s',1),
/*
** PDF417
*/
26000 => array('PDF417: The PDF417 module requires that the PHP installation must support the function bcmod(). This is normally enabled at compile time. See documentation for more information.',0),
26001 => array('PDF417: Number of Columns must be >= 1 and <= 30',0),
26002 => array('PDF417: Error level must be between 0 and 8',0),
26003 => array('PDF417: Invalid format for input data to encode with PDF417',0),
26004 => array('PDF417: Can\'t encode given data with error level %d and %d columns since it results in too many symbols or more than 90 rows.',2),
26005 => array('PDF417: Can\'t open file "%s" for writing',1),
26006 => array('PDF417: Internal error. Data files for PDF417 cluster %d is corrupted.',1),
26007 => array('PDF417: Internal error. GetPattern: Illegal Code Value = %d (row=%d)',2),
26008 => array('PDF417: Internal error. Mode not found in mode list!! mode=%d',1),
26009 => array('PDF417: Encode error: Illegal character. Can\'t encode character with ASCII code=%d',1),
26010 => array('PDF417: Internal error: No input data in decode.',0),
26011 => array('PDF417: Encoding error. Can\'t use numeric encoding on non-numeric data.',0),
26012 => array('PDF417: Internal error. No input data to decode for Binary compressor.',0),
26013 => array('PDF417: Internal error. Checksum error. Coefficient tables corrupted.',0),
26014 => array('PDF417: Internal error. No data to calculate codewords on.',0),
26015 => array('PDF417: Internal error. State transition table entry 0 is NULL. Entry 1 = (%s)',1),
26016 => array('PDF417: Internal error: Unrecognized state transition mode in decode.',0),
/*
** jpgraph_contour
*/
28001 => array('Third argument to Contour must be an array of colors.',0),
28002 => array('Number of colors must equal the number of isobar lines specified',0),
28003 => array('ContourPlot Internal Error: isobarHCrossing: Coloumn index too large (%d)',1),
28004 => array('ContourPlot Internal Error: isobarHCrossing: Row index too large (%d)',1),
28005 => array('ContourPlot Internal Error: isobarVCrossing: Row index too large (%d)',1),
28006 => array('ContourPlot Internal Error: isobarVCrossing: Col index too large (%d)',1),
28007 => array('ContourPlot interpolation factor is too large (>5)',0),
/*
* jpgraph_matrix and colormap
*/
29201 => array('Min range value must be less or equal to max range value for colormaps',0),
29202 => array('The distance between min and max value is too small for numerical precision',0),
29203 => array('Number of color quantification level must be at least %d',1),
29204 => array('Number of colors (%d) is invalid for this colormap. It must be a number that can be written as: %d + k*%d',3),
29205 => array('Colormap specification out of range. Must be an integer in range [0,%d]',1),
29206 => array('Invalid object added to MatrixGraph',0),
29207 => array('Empty input data specified for MatrixPlot',0),
29208 => array('Unknown side specifiction for matrix labels "%s"',1),
29209 => array('CSIM Target matrix must be the same size as the data matrix (csim=%d x %d, data=%d x %d)',4),
29210 => array('CSIM Target for matrix labels does not match the number of labels (csim=%d, labels=%d)',2),
);
?>

View File

@ -1,383 +0,0 @@
<?php
/*=======================================================================
// File: PROD.INC.PHP
// Description: Special localization file with the same error messages
// for all errors.
// Created: 2006-02-18
// Ver: $Id: prod.inc.php 1886 2009-10-01 23:30:16Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
// The single error message for all errors
DEFINE('DEFAULT_ERROR_MESSAGE','We are sorry but the system could not generate the requested image. Please contact site support to resolve this problem. Problem no: #');
// Note: Format of each error message is array(<error message>,<number of arguments>)
$_jpg_messages = array(
/*
** Headers already sent error. This is formatted as HTML different since this will be sent back directly as text
*/
10 => array('<table border=1><tr><td><font color=darkred size=4><b>JpGraph Error:</b>
HTTP headers have already been sent.<br>Caused by output from file <b>%s</b> at line <b>%d</b>.</font></td></tr><tr><td><b>Explanation:</b><br>HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it\'s image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).<p>Most likely you have some text in your script before the call to <i>Graph::Stroke()</i>. If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser. <p>For example it is a common mistake to leave a blank line before the opening "<b>&lt;?php</b>".</td></tr></table>',2),
11 => array(DEFAULT_ERROR_MESSAGE.'11',0),
12 => array(DEFAULT_ERROR_MESSAGE.'12',0),
13 => array(DEFAULT_ERROR_MESSAGE.'13',0),
2001 => array(DEFAULT_ERROR_MESSAGE.'2001',0),
2002 => array(DEFAULT_ERROR_MESSAGE.'2002',0),
2003 => array(DEFAULT_ERROR_MESSAGE.'2003',0),
2004 => array(DEFAULT_ERROR_MESSAGE.'2004',0),
2005 => array(DEFAULT_ERROR_MESSAGE.'2005',0),
2006 => array(DEFAULT_ERROR_MESSAGE.'2006',0),
2007 => array(DEFAULT_ERROR_MESSAGE.'2007',0),
2008 => array(DEFAULT_ERROR_MESSAGE.'2008',0),
2009 => array(DEFAULT_ERROR_MESSAGE.'2009',0),
2010 => array(DEFAULT_ERROR_MESSAGE.'2010',0),
2011 => array(DEFAULT_ERROR_MESSAGE.'2011',0),
2012 => array(DEFAULT_ERROR_MESSAGE.'2012',0),
2013 => array(DEFAULT_ERROR_MESSAGE.'2013',0),
2014 => array(DEFAULT_ERROR_MESSAGE.'2014',0),
3001 => array(DEFAULT_ERROR_MESSAGE.'3001',0),
4002 => array(DEFAULT_ERROR_MESSAGE.'4002',0),
5001 => array(DEFAULT_ERROR_MESSAGE.'5001',0),
5002 => array(DEFAULT_ERROR_MESSAGE.'5002',0),
5003 => array(DEFAULT_ERROR_MESSAGE.'5003',0),
5004 => array(DEFAULT_ERROR_MESSAGE.'5004',0),
6001 => array(DEFAULT_ERROR_MESSAGE.'6001',0),
6002 => array(DEFAULT_ERROR_MESSAGE.'6002',0),
6003 => array(DEFAULT_ERROR_MESSAGE.'6003',0),
6004 => array(DEFAULT_ERROR_MESSAGE.'6004',0),
6005 => array(DEFAULT_ERROR_MESSAGE.'6005',0),
6006 => array(DEFAULT_ERROR_MESSAGE.'6006',0),
6007 => array(DEFAULT_ERROR_MESSAGE.'6007',0),
6008 => array(DEFAULT_ERROR_MESSAGE.'6008',0),
6009 => array(DEFAULT_ERROR_MESSAGE.'6009',0),
6010 => array(DEFAULT_ERROR_MESSAGE.'6010',0),
6011 => array(DEFAULT_ERROR_MESSAGE.'6011',0),
6012 => array(DEFAULT_ERROR_MESSAGE.'6012',0),
6015 => array(DEFAULT_ERROR_MESSAGE.'6015',0),
6016 => array(DEFAULT_ERROR_MESSAGE.'6016',0),
6017 => array(DEFAULT_ERROR_MESSAGE.'6017',0),
6018 => array(DEFAULT_ERROR_MESSAGE.'6018',0),
6019 => array(DEFAULT_ERROR_MESSAGE.'6019',0),
6020 => array(DEFAULT_ERROR_MESSAGE.'6020',0),
6021 => array(DEFAULT_ERROR_MESSAGE.'6021',0),
6022 => array(DEFAULT_ERROR_MESSAGE.'6022',0),
6023 => array(DEFAULT_ERROR_MESSAGE.'6023',0),
6024 => array(DEFAULT_ERROR_MESSAGE.'6024',0),
6025 => array(DEFAULT_ERROR_MESSAGE.'6025',0),
6027 => array(DEFAULT_ERROR_MESSAGE.'6027',0),
6028 => array(DEFAULT_ERROR_MESSAGE.'6028',0),
6029 => array(DEFAULT_ERROR_MESSAGE.'6029',0),
6030 => array(DEFAULT_ERROR_MESSAGE.'6030',0),
6031 => array(DEFAULT_ERROR_MESSAGE.'6031',0),
6032 => array(DEFAULT_ERROR_MESSAGE.'6032',0),
6033 => array(DEFAULT_ERROR_MESSAGE.'6033',0),
7001 => array(DEFAULT_ERROR_MESSAGE.'7001',0),
8001 => array(DEFAULT_ERROR_MESSAGE.'8001',0),
8002 => array(DEFAULT_ERROR_MESSAGE.'8002',0),
8003 => array(DEFAULT_ERROR_MESSAGE.'8003',0),
8004 => array(DEFAULT_ERROR_MESSAGE.'8004',0),
9001 => array(DEFAULT_ERROR_MESSAGE.'9001',0),
10001 => array(DEFAULT_ERROR_MESSAGE.'10001',0),
10002 => array(DEFAULT_ERROR_MESSAGE.'10002',0),
10003 => array(DEFAULT_ERROR_MESSAGE.'10003',0),
11001 => array(DEFAULT_ERROR_MESSAGE.'11001',0),
11002 => array(DEFAULT_ERROR_MESSAGE.'11002',0),
11003 => array(DEFAULT_ERROR_MESSAGE.'11003',0),
11004 => array(DEFAULT_ERROR_MESSAGE.'11004',0),
11005 => array(DEFAULT_ERROR_MESSAGE.'11005',0),
12001 => array(DEFAULT_ERROR_MESSAGE.'12001',0),
12002 => array(DEFAULT_ERROR_MESSAGE.'12002',0),
12003 => array(DEFAULT_ERROR_MESSAGE.'12003',0),
12004 => array(DEFAULT_ERROR_MESSAGE.'12004',0),
12005 => array(DEFAULT_ERROR_MESSAGE.'12005',0),
12006 => array(DEFAULT_ERROR_MESSAGE.'12006',0),
12007 => array(DEFAULT_ERROR_MESSAGE.'12007',0),
12008 => array(DEFAULT_ERROR_MESSAGE.'12008',0),
12009 => array(DEFAULT_ERROR_MESSAGE.'12009',0),
12010 => array(DEFAULT_ERROR_MESSAGE.'12010',0),
12011 => array(DEFAULT_ERROR_MESSAGE.'12011',0),
12012 => array(DEFAULT_ERROR_MESSAGE.'12012',0),
14001 => array(DEFAULT_ERROR_MESSAGE.'14001',0),
14002 => array(DEFAULT_ERROR_MESSAGE.'14002',0),
14003 => array(DEFAULT_ERROR_MESSAGE.'14003',0),
14004 => array(DEFAULT_ERROR_MESSAGE.'14004',0),
14005 => array(DEFAULT_ERROR_MESSAGE.'14005',0),
14006 => array(DEFAULT_ERROR_MESSAGE.'14006',0),
14007 => array(DEFAULT_ERROR_MESSAGE.'14007',0),
15001 => array(DEFAULT_ERROR_MESSAGE.'15001',0),
15002 => array(DEFAULT_ERROR_MESSAGE.'15002',0),
15003 => array(DEFAULT_ERROR_MESSAGE.'15003',0),
15004 => array(DEFAULT_ERROR_MESSAGE.'15004',0),
15005 => array(DEFAULT_ERROR_MESSAGE.'15005',0),
15006 => array(DEFAULT_ERROR_MESSAGE.'15006',0),
15007 => array(DEFAULT_ERROR_MESSAGE.'15007',0),
15008 => array(DEFAULT_ERROR_MESSAGE.'15008',0),
15009 => array(DEFAULT_ERROR_MESSAGE.'15009',0),
15010 => array(DEFAULT_ERROR_MESSAGE.'15010',0),
15011 => array(DEFAULT_ERROR_MESSAGE.'15011',0),
16001 => array(DEFAULT_ERROR_MESSAGE.'16001',0),
16002 => array(DEFAULT_ERROR_MESSAGE.'16002',0),
16003 => array(DEFAULT_ERROR_MESSAGE.'16003',0),
16004 => array(DEFAULT_ERROR_MESSAGE.'16004',0),
17001 => array(DEFAULT_ERROR_MESSAGE.'17001',0),
17002 => array(DEFAULT_ERROR_MESSAGE.'17002',0),
17004 => array(DEFAULT_ERROR_MESSAGE.'17004',0),
18001 => array(DEFAULT_ERROR_MESSAGE.'18001',0),
18002 => array(DEFAULT_ERROR_MESSAGE.'18002',0),
18003 => array(DEFAULT_ERROR_MESSAGE.'18003',0),
18004 => array(DEFAULT_ERROR_MESSAGE.'18004',0),
18005 => array(DEFAULT_ERROR_MESSAGE.'18005',0),
18006 => array(DEFAULT_ERROR_MESSAGE.'18006',0),
18007 => array(DEFAULT_ERROR_MESSAGE.'18007',0),
18008 => array(DEFAULT_ERROR_MESSAGE.'18008',0),
19001 => array(DEFAULT_ERROR_MESSAGE.'19001',0),
19002 => array(DEFAULT_ERROR_MESSAGE.'19002',0),
19003 => array(DEFAULT_ERROR_MESSAGE.'19003',0),
20001 => array(DEFAULT_ERROR_MESSAGE.'20001',0),
20002 => array(DEFAULT_ERROR_MESSAGE.'20002',0),
20003 => array(DEFAULT_ERROR_MESSAGE.'20003',0),
21001 => array(DEFAULT_ERROR_MESSAGE.'21001',0),
23001 => array(DEFAULT_ERROR_MESSAGE.'23001',0),
23002 => array(DEFAULT_ERROR_MESSAGE.'23002',0),
23003 => array(DEFAULT_ERROR_MESSAGE.'23003',0),
24001 => array(DEFAULT_ERROR_MESSAGE.'24001',0),
24002 => array(DEFAULT_ERROR_MESSAGE.'24002',0),
24003 => array(DEFAULT_ERROR_MESSAGE.'24003',0),
24004 => array(DEFAULT_ERROR_MESSAGE.'24004',0),
25001 => array(DEFAULT_ERROR_MESSAGE.'25001',0),
25002 => array(DEFAULT_ERROR_MESSAGE.'25002',0),
25003 => array(DEFAULT_ERROR_MESSAGE.'25003',0),
25004 => array(DEFAULT_ERROR_MESSAGE.'25004',0),
25005 => array(DEFAULT_ERROR_MESSAGE.'25005',0),
25006 => array(DEFAULT_ERROR_MESSAGE.'25006',0),
25007 => array(DEFAULT_ERROR_MESSAGE.'25007',0),
25008 => array(DEFAULT_ERROR_MESSAGE.'25008',0),
25009 => array(DEFAULT_ERROR_MESSAGE.'25009',0),
25010 => array(DEFAULT_ERROR_MESSAGE.'25010',0),
25011 => array(DEFAULT_ERROR_MESSAGE.'25011',0),
25012 => array(DEFAULT_ERROR_MESSAGE.'25012',0),
25013 => array(DEFAULT_ERROR_MESSAGE.'25013',0),
25014 => array(DEFAULT_ERROR_MESSAGE.'25014',0),
25015 => array(DEFAULT_ERROR_MESSAGE.'25015',0),
25016 => array(DEFAULT_ERROR_MESSAGE.'25016',0),
25017 => array(DEFAULT_ERROR_MESSAGE.'25017',0),
25018 => array(DEFAULT_ERROR_MESSAGE.'25018',0),
25019 => array(DEFAULT_ERROR_MESSAGE.'25019',0),
25020 => array(DEFAULT_ERROR_MESSAGE.'25020',0),
25021 => array(DEFAULT_ERROR_MESSAGE.'25021',0),
25022 => array(DEFAULT_ERROR_MESSAGE.'25022',0),
25023 => array(DEFAULT_ERROR_MESSAGE.'25023',0),
25024 => array(DEFAULT_ERROR_MESSAGE.'25024',0),
25025 => array(DEFAULT_ERROR_MESSAGE.'25025',0),
25026 => array(DEFAULT_ERROR_MESSAGE.'25026',0),
25027 => array(DEFAULT_ERROR_MESSAGE.'25027',0),
25028 => array(DEFAULT_ERROR_MESSAGE.'25028',0),
25029 => array(DEFAULT_ERROR_MESSAGE.'25029',0),
25030 => array(DEFAULT_ERROR_MESSAGE.'25030',0),
25031 => array(DEFAULT_ERROR_MESSAGE.'25031',0),
25032 => array(DEFAULT_ERROR_MESSAGE.'25032',0),
25033 => array(DEFAULT_ERROR_MESSAGE.'25033',0),
25034 => array(DEFAULT_ERROR_MESSAGE.'25034',0),
25035 => array(DEFAULT_ERROR_MESSAGE.'25035',0),
25036 => array(DEFAULT_ERROR_MESSAGE.'25036',0),
25037 => array(DEFAULT_ERROR_MESSAGE.'25037',0),
25038 => array(DEFAULT_ERROR_MESSAGE.'25038',0),
25039 => array(DEFAULT_ERROR_MESSAGE.'25039',0),
25040 => array(DEFAULT_ERROR_MESSAGE.'25040',0),
25041 => array(DEFAULT_ERROR_MESSAGE.'25041',0),
25042 => array(DEFAULT_ERROR_MESSAGE.'25042',0),
25043 => array(DEFAULT_ERROR_MESSAGE.'25043',0),
25044 => array(DEFAULT_ERROR_MESSAGE.'25044',0),
25045 => array(DEFAULT_ERROR_MESSAGE.'25045',0),
25046 => array(DEFAULT_ERROR_MESSAGE.'25046',0),
25047 => array(DEFAULT_ERROR_MESSAGE.'25047',0),
25048 => array(DEFAULT_ERROR_MESSAGE.'25048',0),
25049 => array(DEFAULT_ERROR_MESSAGE.'25049',0),
25050 => array(DEFAULT_ERROR_MESSAGE.'25050',0),
25051 => array(DEFAULT_ERROR_MESSAGE.'25051',0),
25052 => array(DEFAULT_ERROR_MESSAGE.'25052',0),
25053 => array(DEFAULT_ERROR_MESSAGE.'25053',0),
25054 => array(DEFAULT_ERROR_MESSAGE.'25054',0),
25055 => array(DEFAULT_ERROR_MESSAGE.'25055',0),
25056 => array(DEFAULT_ERROR_MESSAGE.'25056',0),
25057 => array(DEFAULT_ERROR_MESSAGE.'25057',0),
25058 => array(DEFAULT_ERROR_MESSAGE.'25058',0),
25059 => array(DEFAULT_ERROR_MESSAGE.'25059',0),
25060 => array(DEFAULT_ERROR_MESSAGE.'25060',0),
25061 => array(DEFAULT_ERROR_MESSAGE.'25061',0),
25062 => array(DEFAULT_ERROR_MESSAGE.'25062',0),
25063 => array(DEFAULT_ERROR_MESSAGE.'25063',0),
25064 => array(DEFAULT_ERROR_MESSAGE.'25064',0),
25065 => array(DEFAULT_ERROR_MESSAGE.'25065',0),
25066 => array(DEFAULT_ERROR_MESSAGE.'25066',0),
25067 => array(DEFAULT_ERROR_MESSAGE.'25067',0),
25068 => array(DEFAULT_ERROR_MESSAGE.'25068',0),
25069 => array(DEFAULT_ERROR_MESSAGE.'25069',0),
25070 => array(DEFAULT_ERROR_MESSAGE.'25070',0),
25071 => array(DEFAULT_ERROR_MESSAGE.'25071',0),
25072 => array(DEFAULT_ERROR_MESSAGE.'25072',0),
25073 => array(DEFAULT_ERROR_MESSAGE.'25073',0),
25074 => array(DEFAULT_ERROR_MESSAGE.'25074',0),
25075 => array(DEFAULT_ERROR_MESSAGE.'25075',0),
25077 => array(DEFAULT_ERROR_MESSAGE.'25077',0),
25078 => array(DEFAULT_ERROR_MESSAGE.'25078',0),
25079 => array(DEFAULT_ERROR_MESSAGE.'25079',0),
25080 => array(DEFAULT_ERROR_MESSAGE.'25080',0),
25081 => array(DEFAULT_ERROR_MESSAGE.'25081',0),
25082 => array(DEFAULT_ERROR_MESSAGE.'25082',0),
25083 => array(DEFAULT_ERROR_MESSAGE.'25083',0),
25084 => array(DEFAULT_ERROR_MESSAGE.'25084',0),
25085 => array(DEFAULT_ERROR_MESSAGE.'25085',0),
25086 => array(DEFAULT_ERROR_MESSAGE.'25086',0),
25087 => array(DEFAULT_ERROR_MESSAGE.'25087',0),
25088 => array(DEFAULT_ERROR_MESSAGE.'25088',0),
25089 => array(DEFAULT_ERROR_MESSAGE.'25089',0),
25090 => array(DEFAULT_ERROR_MESSAGE.'25090',0),
25091 => array(DEFAULT_ERROR_MESSAGE.'25091',0),
25092 => array(DEFAULT_ERROR_MESSAGE.'25092',0),
25093 => array(DEFAULT_ERROR_MESSAGE.'25093',0),
25094 => array(DEFAULT_ERROR_MESSAGE.'25094',0),
25095 => array(DEFAULT_ERROR_MESSAGE.'25095',0),
25096 => array(DEFAULT_ERROR_MESSAGE.'25096',0),
25097 => array(DEFAULT_ERROR_MESSAGE.'25097',0),
25098 => array(DEFAULT_ERROR_MESSAGE.'25098',0),
25099 => array(DEFAULT_ERROR_MESSAGE.'25099',0),
25100 => array(DEFAULT_ERROR_MESSAGE.'25100',0),
25101 => array(DEFAULT_ERROR_MESSAGE.'25101',0),
25102 => array(DEFAULT_ERROR_MESSAGE.'25102',0),
25103 => array(DEFAULT_ERROR_MESSAGE.'25103',0),
25104 => array(DEFAULT_ERROR_MESSAGE.'25104',0),
25105 => array(DEFAULT_ERROR_MESSAGE.'25105',0),
25106 => array(DEFAULT_ERROR_MESSAGE.'25106',0),
25107 => array(DEFAULT_ERROR_MESSAGE.'25107',0),
25108 => array(DEFAULT_ERROR_MESSAGE.'25108',0),
25109 => array(DEFAULT_ERROR_MESSAGE.'25109',0),
25110 => array(DEFAULT_ERROR_MESSAGE.'25110',0),
25111 => array(DEFAULT_ERROR_MESSAGE.'25111',0),
25112 => array(DEFAULT_ERROR_MESSAGE.'25112',0),
25113 => array(DEFAULT_ERROR_MESSAGE.'25113',0),
25114 => array(DEFAULT_ERROR_MESSAGE.'25114',0),
25115 => array(DEFAULT_ERROR_MESSAGE.'25115',0),
25116 => array(DEFAULT_ERROR_MESSAGE.'25116',0),
25117 => array(DEFAULT_ERROR_MESSAGE.'25117',0),
25118 => array(DEFAULT_ERROR_MESSAGE.'25118',0),
25119 => array(DEFAULT_ERROR_MESSAGE.'25119',0),
25120 => array(DEFAULT_ERROR_MESSAGE.'25120',0),
25121 => array(DEFAULT_ERROR_MESSAGE.'25121',0),
25122 => array(DEFAULT_ERROR_MESSAGE.'25122',0),
25123 => array(DEFAULT_ERROR_MESSAGE.'25123',0),
25124 => array(DEFAULT_ERROR_MESSAGE.'25124',0),
25125 => array(DEFAULT_ERROR_MESSAGE.'25125',0),
25126 => array(DEFAULT_ERROR_MESSAGE.'25126',0),
25127 => array(DEFAULT_ERROR_MESSAGE.'25127',0),
25128 => array(DEFAULT_ERROR_MESSAGE.'25128',0),
25129 => array(DEFAULT_ERROR_MESSAGE.'25129',0),
25130 => array(DEFAULT_ERROR_MESSAGE.'25130',0),
25131 => array(DEFAULT_ERROR_MESSAGE.'25131',0),
25500 => array(DEFAULT_ERROR_MESSAGE.'25500',0),
24003 => array(DEFAULT_ERROR_MESSAGE.'24003',0),
24004 => array(DEFAULT_ERROR_MESSAGE.'24004',0),
24005 => array(DEFAULT_ERROR_MESSAGE.'24005',0),
24006 => array(DEFAULT_ERROR_MESSAGE.'24006',0),
24007 => array(DEFAULT_ERROR_MESSAGE.'24007',0),
24008 => array(DEFAULT_ERROR_MESSAGE.'24008',0),
24009 => array(DEFAULT_ERROR_MESSAGE.'24009',0),
24010 => array(DEFAULT_ERROR_MESSAGE.'24010',0),
24011 => array(DEFAULT_ERROR_MESSAGE.'24011',0),
24012 => array(DEFAULT_ERROR_MESSAGE.'24012',0),
24013 => array(DEFAULT_ERROR_MESSAGE.'24013',0),
24014 => array(DEFAULT_ERROR_MESSAGE.'24014',0),
24015 => array(DEFAULT_ERROR_MESSAGE.'24015',0),
22001 => array(DEFAULT_ERROR_MESSAGE.'22001',0),
22002 => array(DEFAULT_ERROR_MESSAGE.'22002',0),
22004 => array(DEFAULT_ERROR_MESSAGE.'22004',0),
22005 => array(DEFAULT_ERROR_MESSAGE.'22005',0),
22006 => array(DEFAULT_ERROR_MESSAGE.'22006',0),
22007 => array(DEFAULT_ERROR_MESSAGE.'22007',0),
22008 => array(DEFAULT_ERROR_MESSAGE.'22008',0),
22009 => array(DEFAULT_ERROR_MESSAGE.'22009',0),
22010 => array(DEFAULT_ERROR_MESSAGE.'22010',0),
22011 => array(DEFAULT_ERROR_MESSAGE.'22011',0),
22012 => array(DEFAULT_ERROR_MESSAGE.'22012',0),
22013 => array(DEFAULT_ERROR_MESSAGE.'22013',0),
22014 => array(DEFAULT_ERROR_MESSAGE.'22014',0),
22015 => array(DEFAULT_ERROR_MESSAGE.'22015',0),
22016 => array(DEFAULT_ERROR_MESSAGE.'22016',0),
22017 => array(DEFAULT_ERROR_MESSAGE.'22017',0),
22018 => array(DEFAULT_ERROR_MESSAGE.'22018',0),
22019 => array(DEFAULT_ERROR_MESSAGE.'22019',0),
22020 => array(DEFAULT_ERROR_MESSAGE.'22020',0),
13001 => array(DEFAULT_ERROR_MESSAGE.'13001',0),
13002 => array(DEFAULT_ERROR_MESSAGE.'13002',0),
1001 => array(DEFAULT_ERROR_MESSAGE.'1001',0),
1002 => array(DEFAULT_ERROR_MESSAGE.'1002',0),
1003 => array(DEFAULT_ERROR_MESSAGE.'1003',0),
1004 => array(DEFAULT_ERROR_MESSAGE.'1004',0),
1005 => array(DEFAULT_ERROR_MESSAGE.'1005',0),
1006 => array(DEFAULT_ERROR_MESSAGE.'1006',0),
1007 => array(DEFAULT_ERROR_MESSAGE.'1007',0),
1008 => array(DEFAULT_ERROR_MESSAGE.'1008',0),
1009 => array(DEFAULT_ERROR_MESSAGE.'1009',0),
1010 => array(DEFAULT_ERROR_MESSAGE.'1010',0),
1011 => array(DEFAULT_ERROR_MESSAGE.'1011',0),
26000 => array(DEFAULT_ERROR_MESSAGE.'26000',0),
26001 => array(DEFAULT_ERROR_MESSAGE.'26001',0),
26002 => array(DEFAULT_ERROR_MESSAGE.'26002',0),
26003 => array(DEFAULT_ERROR_MESSAGE.'26003',0),
26004 => array(DEFAULT_ERROR_MESSAGE.'26004',0),
26005 => array(DEFAULT_ERROR_MESSAGE.'26005',0),
26006 => array(DEFAULT_ERROR_MESSAGE.'26006',0),
26007 => array(DEFAULT_ERROR_MESSAGE.'26007',0),
26008 => array(DEFAULT_ERROR_MESSAGE.'26008',0),
26009 => array(DEFAULT_ERROR_MESSAGE.'26009',0),
26010 => array(DEFAULT_ERROR_MESSAGE.'26010',0),
26011 => array(DEFAULT_ERROR_MESSAGE.'26011',0),
26012 => array(DEFAULT_ERROR_MESSAGE.'26012',0),
26013 => array(DEFAULT_ERROR_MESSAGE.'26013',0),
26014 => array(DEFAULT_ERROR_MESSAGE.'26014',0),
26015 => array(DEFAULT_ERROR_MESSAGE.'26015',0),
26016 => array(DEFAULT_ERROR_MESSAGE.'26016',0),
27001 => array(DEFAULT_ERROR_MESSAGE.'27001',0),
27002 => array(DEFAULT_ERROR_MESSAGE.'27002',0),
27003 => array(DEFAULT_ERROR_MESSAGE.'27003',0),
27004 => array(DEFAULT_ERROR_MESSAGE.'27004',0),
27005 => array(DEFAULT_ERROR_MESSAGE.'27005',0),
27006 => array(DEFAULT_ERROR_MESSAGE.'27006',0),
27007 => array(DEFAULT_ERROR_MESSAGE.'27007',0),
27008 => array(DEFAULT_ERROR_MESSAGE.'27008',0),
27009 => array(DEFAULT_ERROR_MESSAGE.'27009',0),
27010 => array(DEFAULT_ERROR_MESSAGE.'27010',0),
27011 => array(DEFAULT_ERROR_MESSAGE.'27011',0),
27012 => array(DEFAULT_ERROR_MESSAGE.'27012',0),
27013 => array(DEFAULT_ERROR_MESSAGE.'27013',0),
27014 => array(DEFAULT_ERROR_MESSAGE.'27014',0),
27015 => array(DEFAULT_ERROR_MESSAGE.'27015',0),
28001 => array(DEFAULT_ERROR_MESSAGE.'28001',0),
28002 => array(DEFAULT_ERROR_MESSAGE.'28002',0),
28003 => array(DEFAULT_ERROR_MESSAGE.'28003',0),
28004 => array(DEFAULT_ERROR_MESSAGE.'28004',0),
28005 => array(DEFAULT_ERROR_MESSAGE.'28005',0),
28006 => array(DEFAULT_ERROR_MESSAGE.'28006',0),
28007 => array(DEFAULT_ERROR_MESSAGE.'28007',0),
29201 => array(DEFAULT_ERROR_MESSAGE.'28001',0),
29202 => array(DEFAULT_ERROR_MESSAGE.'28002',0),
29203 => array(DEFAULT_ERROR_MESSAGE.'28003',0),
29204 => array(DEFAULT_ERROR_MESSAGE.'28004',0),
29205 => array(DEFAULT_ERROR_MESSAGE.'28005',0),
29206 => array(DEFAULT_ERROR_MESSAGE.'28006',0),
29207 => array(DEFAULT_ERROR_MESSAGE.'28007',0),
29208 => array(DEFAULT_ERROR_MESSAGE.'28008',0),
29209 => array(DEFAULT_ERROR_MESSAGE.'28009',0),
29210 => array(DEFAULT_ERROR_MESSAGE.'28010',0),
);
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,115 +0,0 @@
TCPDF - README
============================================================
I WISH TO IMPROVE AND EXPAND TCPDF BUT I NEED YOUR SUPPORT.
PLEASE MAKE A DONATION:
http://sourceforge.net/donate/index.php?group_id=128076
------------------------------------------------------------
Name: TCPDF
Version: 6.2.6
Release date: 2015-01-28
Author: Nicola Asuni
Copyright (c) 2002-2015:
Nicola Asuni
Tecnick.com LTD
www.tecnick.com
URLs:
http://www.tcpdf.org
http://www.sourceforge.net/projects/tcpdf
Description:
TCPDF is a PHP class for generating PDF files on-the-fly without requiring external extensions.
This library includes also a class to extract data from existing PDF documents and
classes to generate 1D and 2D barcodes in various formats.
Main Features:
* no external libraries are required for the basic functions;
* all standard page formats, custom page formats, custom margins and units of measure;
* UTF-8 Unicode and Right-To-Left languages;
* TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1 and CID-0 fonts;
* font subsetting;
* methods to publish some XHTML + CSS code, Javascript and Forms;
* images, graphic (geometric figures) and transformation methods;
* supports JPEG, PNG and SVG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick (http: www.imagemagick.org/www/formats.html)
* 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extension, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417;
* JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies;
* automatic page header and footer management;
* document encryption up to 256 bit and digital signature certifications;
* transactions to UNDO commands;
* PDF annotations, including links, text and file attachments;
* text rendering modes (fill, stroke and clipping);
* multiple columns mode;
* no-write page regions;
* bookmarks, named destinations and table of content;
* text hyphenation;
* text stretching and spacing (tracking);
* automatic page break, line break and text alignments including justification;
* automatic page numbering and page groups;
* move and delete pages;
* page compression (requires php-zlib extension);
* XOBject Templates;
* Layers and object visibility.
* PDF/A-1b support.
Installation (full instructions on http: www.tcpdf.org):
1. copy the folder on your Web server
2. set your installation path and other parameters on the config/tcpdf_config.php
3. call the examples/example_001.php page with your browser to see an example
Source Code Documentation:
http://www.tcpdf.org
Additional Documentation:
http://www.tcpdf.org
License:
Copyright (C) 2002-2014 Nicola Asuni - Tecnick.com LTD
TCPDF is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
TCPDF is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the License
along with TCPDF. If not, see
<http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
See LICENSE.TXT file for more information.
Third party fonts:
This library may include third party font files released with different licenses.
All the PHP files on the fonts directory are subject to the general TCPDF license (GNU-LGPLv3),
they do not contain any binary data but just a description of the general properties of a particular font.
These files can be also generated on the fly using the font utilities and TCPDF methods.
All the original binary TTF font files have been renamed for compatibility with TCPDF and compressed using the gzcompress PHP function that uses the ZLIB data format (.z files).
The binary files (.z) that begins with the prefix "free" have been extracted from the GNU FreeFont collection (GNU-GPLv3).
The binary files (.z) that begins with the prefix "pdfa" have been derived from the GNU FreeFont, so they are subject to the same license.
For the details of Copyright, License and other information, please check the files inside the directory fonts/freefont-20120503
Link : http://www.gnu.org/software/freefont/
The binary files (.z) that begins with the prefix "dejavu" have been extracted from the DejaVu fonts 2.33 (Bitstream) collection.
For the details of Copyright, License and other information, please check the files inside the directory fonts/dejavu-fonts-ttf-2.33
Link : http://dejavu-fonts.org
The binary files (.z) that begins with the prefix "ae" have been extracted from the Arabeyes.org collection (GNU-GPLv2).
Link : http://projects.arabeyes.org/
ICC profile:
TCPDF includes the sRGB.icc profile from the icc-profiles-free Debian package:
https://packages.debian.org/source/stable/icc-profiles-free
============================================================

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,355 +0,0 @@
<?php
//============================================================+
// File name : tcpdf_images.php
// Version : 1.0.005
// Begin : 2002-08-03
// Last Update : 2014-11-15
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
// -------------------------------------------------------------------
// Copyright (C) 2002-2014 Nicola Asuni - Tecnick.com LTD
//
// This file is part of TCPDF software library.
//
// TCPDF is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// TCPDF is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the License
// along with TCPDF. If not, see
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description :
// Static image methods used by the TCPDF class.
//
//============================================================+
/**
* @file
* This is a PHP class that contains static image methods for the TCPDF class.<br>
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.005
*/
/**
* @class TCPDF_IMAGES
* Static image methods used by the TCPDF class.
* @package com.tecnick.tcpdf
* @brief PHP class for generating PDF documents without requiring external extensions.
* @version 1.0.005
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF_IMAGES {
/**
* Array of hinheritable SVG properties.
* @since 5.0.000 (2010-05-02)
* @public static
*/
public static $svginheritprop = array('clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'display', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'visibility', 'word-spacing', 'writing-mode');
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
* Return the image type given the file name or array returned by getimagesize() function.
* @param $imgfile (string) image file name
* @param $iminfo (array) array of image information returned by getimagesize() function.
* @return string image type
* @since 4.8.017 (2009-11-27)
* @public static
*/
public static function getImageFileType($imgfile, $iminfo=array()) {
$type = '';
if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) {
$mime = explode('/', $iminfo['mime']);
if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
$type = strtolower(trim($mime[1]));
}
}
if (empty($type)) {
$fileinfo = pathinfo($imgfile);
if (isset($fileinfo['extension']) AND (!TCPDF_STATIC::empty_string($fileinfo['extension']))) {
$type = strtolower(trim($fileinfo['extension']));
}
}
if ($type == 'jpg') {
$type = 'jpeg';
}
return $type;
}
/**
* Set the transparency for the given GD image.
* @param $new_image (image) GD image object
* @param $image (image) GD image object.
* return GD image object.
* @since 4.9.016 (2010-04-20)
* @public static
*/
public static function setGDImageTransparency($new_image, $image) {
// default transparency color (white)
$tcol = array('red' => 255, 'green' => 255, 'blue' => 255);
// transparency index
$tid = imagecolortransparent($image);
$palletsize = imagecolorstotal($image);
if (($tid >= 0) AND ($tid < $palletsize)) {
// get the colors for the transparency index
$tcol = imagecolorsforindex($image, $tid);
}
$tid = imagecolorallocate($new_image, $tcol['red'], $tcol['green'], $tcol['blue']);
imagefill($new_image, 0, 0, $tid);
imagecolortransparent($new_image, $tid);
return $new_image;
}
/**
* Convert the loaded image to a PNG and then return a structure for the PDF creator.
* This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
* @param $image (image) Image object.
* @param $tempfile (string) Temporary file name.
* return image PNG image object.
* @since 4.9.016 (2010-04-20)
* @public static
*/
public static function _toPNG($image, $tempfile) {
// turn off interlaced mode
imageinterlace($image, 0);
// create temporary PNG image
imagepng($image, $tempfile);
// remove image from memory
imagedestroy($image);
// get PNG image data
$retvars = self::_parsepng($tempfile);
// tidy up by removing temporary image
unlink($tempfile);
return $retvars;
}
/**
* Convert the loaded image to a JPEG and then return a structure for the PDF creator.
* This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
* @param $image (image) Image object.
* @param $quality (int) JPEG quality.
* @param $tempfile (string) Temporary file name.
* return image JPEG image object.
* @public static
*/
public static function _toJPEG($image, $quality, $tempfile) {
imagejpeg($image, $tempfile, $quality);
imagedestroy($image);
$retvars = self::_parsejpeg($tempfile);
// tidy up by removing temporary image
unlink($tempfile);
return $retvars;
}
/**
* Extract info from a JPEG file without using the GD library.
* @param $file (string) image file to parse
* @return array structure containing the image data
* @public static
*/
public static function _parsejpeg($file) {
$a = getimagesize($file);
if (empty($a)) {
//Missing or incorrect image file
return false;
}
if ($a[2] != 2) {
// Not a JPEG file
return false;
}
// bits per pixel
$bpc = isset($a['bits']) ? intval($a['bits']) : 8;
// number of image channels
if (!isset($a['channels'])) {
$channels = 3;
} else {
$channels = intval($a['channels']);
}
// default colour space
switch ($channels) {
case 1: {
$colspace = 'DeviceGray';
break;
}
case 3: {
$colspace = 'DeviceRGB';
break;
}
case 4: {
$colspace = 'DeviceCMYK';
break;
}
default: {
$channels = 3;
$colspace = 'DeviceRGB';
break;
}
}
// get file content
$data = file_get_contents($file);
// check for embedded ICC profile
$icc = array();
$offset = 0;
while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) {
// get ICC sequence length
$length = (TCPDF_STATIC::_getUSHORT($data, ($pos - 2)) - 16);
// marker sequence number
$msn = max(1, ord($data[($pos + 12)]));
// number of markers (total of APP2 used)
$nom = max(1, ord($data[($pos + 13)]));
// get sequence segment
$icc[($msn - 1)] = substr($data, ($pos + 14), $length);
// move forward to next sequence
$offset = ($pos + 14 + $length);
}
// order and compact ICC segments
if (count($icc) > 0) {
ksort($icc);
$icc = implode('', $icc);
if ((ord($icc[36]) != 0x61) OR (ord($icc[37]) != 0x63) OR (ord($icc[38]) != 0x73) OR (ord($icc[39]) != 0x70)) {
// invalid ICC profile
$icc = false;
}
} else {
$icc = false;
}
return array('w' => $a[0], 'h' => $a[1], 'ch' => $channels, 'icc' => $icc, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'DCTDecode', 'data' => $data);
}
/**
* Extract info from a PNG file without using the GD library.
* @param $file (string) image file to parse
* @return array structure containing the image data
* @public static
*/
public static function _parsepng($file) {
$f = @fopen($file, 'rb');
if ($f === false) {
// Can't open image file
return false;
}
//Check signature
if (fread($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
// Not a PNG file
return false;
}
//Read header chunk
fread($f, 4);
if (fread($f, 4) != 'IHDR') {
//Incorrect PNG file
return false;
}
$w = TCPDF_STATIC::_freadint($f);
$h = TCPDF_STATIC::_freadint($f);
$bpc = ord(fread($f, 1));
$ct = ord(fread($f, 1));
if ($ct == 0) {
$colspace = 'DeviceGray';
} elseif ($ct == 2) {
$colspace = 'DeviceRGB';
} elseif ($ct == 3) {
$colspace = 'Indexed';
} else {
// alpha channel
fclose($f);
return 'pngalpha';
}
if (ord(fread($f, 1)) != 0) {
// Unknown compression method
fclose($f);
return false;
}
if (ord(fread($f, 1)) != 0) {
// Unknown filter method
fclose($f);
return false;
}
if (ord(fread($f, 1)) != 0) {
// Interlacing not supported
fclose($f);
return false;
}
fread($f, 4);
$channels = ($ct == 2 ? 3 : 1);
$parms = '/DecodeParms << /Predictor 15 /Colors '.$channels.' /BitsPerComponent '.$bpc.' /Columns '.$w.' >>';
//Scan chunks looking for palette, transparency and image data
$pal = '';
$trns = '';
$data = '';
$icc = false;
do {
$n = TCPDF_STATIC::_freadint($f);
$type = fread($f, 4);
if ($type == 'PLTE') {
// read palette
$pal = TCPDF_STATIC::rfread($f, $n);
fread($f, 4);
} elseif ($type == 'tRNS') {
// read transparency info
$t = TCPDF_STATIC::rfread($f, $n);
if ($ct == 0) { // DeviceGray
$trns = array(ord($t[1]));
} elseif ($ct == 2) { // DeviceRGB
$trns = array(ord($t[1]), ord($t[3]), ord($t[5]));
} else { // Indexed
if ($n > 0) {
$trns = array();
for ($i = 0; $i < $n; ++ $i) {
$trns[] = ord($t{$i});
}
}
}
fread($f, 4);
} elseif ($type == 'IDAT') {
// read image data block
$data .= TCPDF_STATIC::rfread($f, $n);
fread($f, 4);
} elseif ($type == 'iCCP') {
// skip profile name
$len = 0;
while ((ord(fread($f, 1)) != 0) AND ($len < 80)) {
++$len;
}
// get compression method
if (ord(fread($f, 1)) != 0) {
// Unknown filter method
fclose($f);
return false;
}
// read ICC Color Profile
$icc = TCPDF_STATIC::rfread($f, ($n - $len - 2));
// decompress profile
$icc = gzuncompress($icc);
fread($f, 4);
} elseif ($type == 'IEND') {
break;
} else {
TCPDF_STATIC::rfread($f, $n + 4);
}
} while ($n);
if (($colspace == 'Indexed') AND (empty($pal))) {
// Missing palette
fclose($f);
return false;
}
fclose($f);
return array('w' => $w, 'h' => $h, 'ch' => $channels, 'icc' => $icc, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'FlateDecode', 'parms' => $parms, 'pal' => $pal, 'trns' => $trns, 'data' => $data);
}
} // END OF TCPDF_IMAGES CLASS
//============================================================+
// END OF FILE
//============================================================+

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,49 +0,0 @@
<?php
//============================================================+
// File name : tcpdf_include.php
// Begin : 2008-05-14
// Last Update : 2014-12-10
//
// Description : Search and include the TCPDF library.
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com LTD
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* Search and include the TCPDF library.
* @package com.tecnick.tcpdf
* @abstract TCPDF - Include the main class.
* @author Nicola Asuni
* @since 2013-05-14
*/
// always load alternative config file for examples
require_once('config/tcpdf_config_alt.php');
// Include the main TCPDF library (search the library on the following directories).
$tcpdf_include_dirs = array(
realpath('../tcpdf.php'),
'/usr/share/php/tcpdf/tcpdf.php',
'/usr/share/tcpdf/tcpdf.php',
'/usr/share/php-tcpdf/tcpdf.php',
'/var/www/tcpdf/tcpdf.php',
'/var/www/html/tcpdf/tcpdf.php',
'/usr/local/apache2/htdocs/tcpdf/tcpdf.php'
);
foreach ($tcpdf_include_dirs as $tcpdf_include_path) {
if (@file_exists($tcpdf_include_path)) {
require_once($tcpdf_include_path);
break;
}
}
//============================================================+
// END OF FILE
//============================================================+

View File

@ -1,812 +0,0 @@
<?php
//============================================================+
// File name : tcpdf_parser.php
// Version : 1.0.15
// Begin : 2011-05-23
// Last Update : 2015-01-24
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
// License : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3
// -------------------------------------------------------------------
// Copyright (C) 2011-2015 Nicola Asuni - Tecnick.com LTD
//
// This file is part of TCPDF software library.
//
// TCPDF is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// TCPDF is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the License
// along with TCPDF. If not, see
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
//
// See LICENSE.TXT file for more information.
// -------------------------------------------------------------------
//
// Description : This is a PHP class for parsing PDF documents.
//
//============================================================+
/**
* @file
* This is a PHP class for parsing PDF documents.<br>
* @package com.tecnick.tcpdf
* @author Nicola Asuni
* @version 1.0.15
*/
// include class for decoding filters
require_once(dirname(__FILE__).'/include/tcpdf_filters.php');
/**
* @class TCPDF_PARSER
* This is a PHP class for parsing PDF documents.<br>
* @package com.tecnick.tcpdf
* @brief This is a PHP class for parsing PDF documents..
* @version 1.0.15
* @author Nicola Asuni - info@tecnick.com
*/
class TCPDF_PARSER {
/**
* Raw content of the PDF document.
* @private
*/
private $pdfdata = '';
/**
* XREF data.
* @protected
*/
protected $xref = array();
/**
* Array of PDF objects.
* @protected
*/
protected $objects = array();
/**
* Class object for decoding filters.
* @private
*/
private $FilterDecoders;
/**
* Array of configuration parameters.
* @private
*/
private $cfg = array(
'die_for_errors' => false,
'ignore_filter_decoding_errors' => true,
'ignore_missing_filter_decoders' => true,
);
// -----------------------------------------------------------------------------
/**
* Parse a PDF document an return an array of objects.
* @param $data (string) PDF data to parse.
* @param $cfg (array) Array of configuration parameters:
* 'die_for_errors' : if true termitate the program execution in case of error, otherwise thows an exception;
* 'ignore_filter_decoding_errors' : if true ignore filter decoding errors;
* 'ignore_missing_filter_decoders' : if true ignore missing filter decoding errors.
* @public
* @since 1.0.000 (2011-05-24)
*/
public function __construct($data, $cfg=array()) {
if (empty($data)) {
$this->Error('Empty PDF data.');
}
// find the pdf header starting position
if (($trimpos = strpos($data, '%PDF-')) === FALSE) {
$this->Error('Invalid PDF data: missing %PDF header.');
}
// get PDF content string
$this->pdfdata = substr($data, $trimpos);
// get length
$pdflen = strlen($this->pdfdata);
// set configuration parameters
$this->setConfig($cfg);
// get xref and trailer data
$this->xref = $this->getXrefData();
// parse all document objects
$this->objects = array();
foreach ($this->xref['xref'] as $obj => $offset) {
if (!isset($this->objects[$obj]) AND ($offset > 0)) {
// decode objects with positive offset
$this->objects[$obj] = $this->getIndirectObject($obj, $offset, true);
}
}
// release some memory
unset($this->pdfdata);
$this->pdfdata = '';
}
/**
* Set the configuration parameters.
* @param $cfg (array) Array of configuration parameters:
* 'die_for_errors' : if true termitate the program execution in case of error, otherwise thows an exception;
* 'ignore_filter_decoding_errors' : if true ignore filter decoding errors;
* 'ignore_missing_filter_decoders' : if true ignore missing filter decoding errors.
* @public
*/
protected function setConfig($cfg) {
if (isset($cfg['die_for_errors'])) {
$this->cfg['die_for_errors'] = !!$cfg['die_for_errors'];
}
if (isset($cfg['ignore_filter_decoding_errors'])) {
$this->cfg['ignore_filter_decoding_errors'] = !!$cfg['ignore_filter_decoding_errors'];
}
if (isset($cfg['ignore_missing_filter_decoders'])) {
$this->cfg['ignore_missing_filter_decoders'] = !!$cfg['ignore_missing_filter_decoders'];
}
}
/**
* Return an array of parsed PDF document objects.
* @return (array) Array of parsed PDF document objects.
* @public
* @since 1.0.000 (2011-06-26)
*/
public function getParsedData() {
return array($this->xref, $this->objects);
}
/**
* Get Cross-Reference (xref) table and trailer data from PDF document data.
* @param $offset (int) xref offset (if know).
* @param $xref (array) previous xref array (if any).
* @return Array containing xref and trailer data.
* @protected
* @since 1.0.000 (2011-05-24)
*/
protected function getXrefData($offset=0, $xref=array()) {
if ($offset == 0) {
// find last startxref
if (preg_match_all('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_SET_ORDER, $offset) == 0) {
$this->Error('Unable to find startxref');
}
$matches = array_pop($matches);
$startxref = $matches[1];
} elseif (strpos($this->pdfdata, 'xref', $offset) == $offset) {
// Already pointing at the xref table
$startxref = $offset;
} elseif (preg_match('/([0-9]+[\s][0-9]+[\s]obj)/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) {
// Cross-Reference Stream object
$startxref = $offset;
} elseif (preg_match('/[\r\n]startxref[\s]*[\r\n]+([0-9]+)[\s]*[\r\n]+%%EOF/i', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset)) {
// startxref found
$startxref = $matches[1][0];
} else {
$this->Error('Unable to find startxref');
}
// check xref position
if (strpos($this->pdfdata, 'xref', $startxref) == $startxref) {
// Cross-Reference
$xref = $this->decodeXref($startxref, $xref);
} else {
// Cross-Reference Stream
$xref = $this->decodeXrefStream($startxref, $xref);
}
if (empty($xref)) {
$this->Error('Unable to find xref');
}
return $xref;
}
/**
* Decode the Cross-Reference section
* @param $startxref (int) Offset at which the xref section starts (position of the 'xref' keyword).
* @param $xref (array) Previous xref array (if any).
* @return Array containing xref and trailer data.
* @protected
* @since 1.0.000 (2011-06-20)
*/
protected function decodeXref($startxref, $xref=array()) {
$startxref += 4; // 4 is the length of the word 'xref'
// skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP)
$offset = $startxref + strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $startxref);
// initialize object number
$obj_num = 0;
// search for cross-reference entries or subsection
while (preg_match('/([0-9]+)[\x20]([0-9]+)[\x20]?([nf]?)(\r\n|[\x20]?[\r\n])/', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
if ($matches[0][1] != $offset) {
// we are on another section
break;
}
$offset += strlen($matches[0][0]);
if ($matches[3][0] == 'n') {
// create unique object index: [object number]_[generation number]
$index = $obj_num.'_'.intval($matches[2][0]);
// check if object already exist
if (!isset($xref['xref'][$index])) {
// store object offset position
$xref['xref'][$index] = intval($matches[1][0]);
}
++$obj_num;
} elseif ($matches[3][0] == 'f') {
++$obj_num;
} else {
// object number (index)
$obj_num = intval($matches[1][0]);
}
}
// get trailer data
if (preg_match('/trailer[\s]*<<(.*)>>/isU', $this->pdfdata, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
$trailer_data = $matches[1][0];
if (!isset($xref['trailer']) OR empty($xref['trailer'])) {
// get only the last updated version
$xref['trailer'] = array();
// parse trailer_data
if (preg_match('/Size[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
$xref['trailer']['size'] = intval($matches[1]);
}
if (preg_match('/Root[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
$xref['trailer']['root'] = intval($matches[1]).'_'.intval($matches[2]);
}
if (preg_match('/Encrypt[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
$xref['trailer']['encrypt'] = intval($matches[1]).'_'.intval($matches[2]);
}
if (preg_match('/Info[\s]+([0-9]+)[\s]+([0-9]+)[\s]+R/i', $trailer_data, $matches) > 0) {
$xref['trailer']['info'] = intval($matches[1]).'_'.intval($matches[2]);
}
if (preg_match('/ID[\s]*[\[][\s]*[<]([^>]*)[>][\s]*[<]([^>]*)[>]/i', $trailer_data, $matches) > 0) {
$xref['trailer']['id'] = array();
$xref['trailer']['id'][0] = $matches[1];
$xref['trailer']['id'][1] = $matches[2];
}
}
if (preg_match('/Prev[\s]+([0-9]+)/i', $trailer_data, $matches) > 0) {
// get previous xref
$xref = $this->getXrefData(intval($matches[1]), $xref);
}
} else {
$this->Error('Unable to find trailer');
}
return $xref;
}
/**
* Decode the Cross-Reference Stream section
* @param $startxref (int) Offset at which the xref section starts.
* @param $xref (array) Previous xref array (if any).
* @return Array containing xref and trailer data.
* @protected
* @since 1.0.003 (2013-03-16)
*/
protected function decodeXrefStream($startxref, $xref=array()) {
// try to read Cross-Reference Stream
$xrefobj = $this->getRawObject($startxref);
$xrefcrs = $this->getIndirectObject($xrefobj[1], $startxref, true);
if (!isset($xref['trailer']) OR empty($xref['trailer'])) {
// get only the last updated version
$xref['trailer'] = array();
$filltrailer = true;
} else {
$filltrailer = false;
}
if (!isset($xref['xref'])) {
$xref['xref'] = array();
}
$valid_crs = false;
$columns = 0;
$sarr = $xrefcrs[0][1];
foreach ($sarr as $k => $v) {
if (($v[0] == '/') AND ($v[1] == 'Type') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == '/') AND ($sarr[($k +1)][1] == 'XRef'))) {
$valid_crs = true;
} elseif (($v[0] == '/') AND ($v[1] == 'Index') AND (isset($sarr[($k +1)]))) {
// first object number in the subsection
$index_first = intval($sarr[($k +1)][1][0][1]);
// number of entries in the subsection
$index_entries = intval($sarr[($k +1)][1][1][1]);
} elseif (($v[0] == '/') AND ($v[1] == 'Prev') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'numeric'))) {
// get previous xref offset
$prevxref = intval($sarr[($k +1)][1]);
} elseif (($v[0] == '/') AND ($v[1] == 'W') AND (isset($sarr[($k +1)]))) {
// number of bytes (in the decoded stream) of the corresponding field
$wb = array();
$wb[0] = intval($sarr[($k +1)][1][0][1]);
$wb[1] = intval($sarr[($k +1)][1][1][1]);
$wb[2] = intval($sarr[($k +1)][1][2][1]);
} elseif (($v[0] == '/') AND ($v[1] == 'DecodeParms') AND (isset($sarr[($k +1)][1]))) {
$decpar = $sarr[($k +1)][1];
foreach ($decpar as $kdc => $vdc) {
if (($vdc[0] == '/') AND ($vdc[1] == 'Columns') AND (isset($decpar[($kdc +1)]) AND ($decpar[($kdc +1)][0] == 'numeric'))) {
$columns = intval($decpar[($kdc +1)][1]);
} elseif (($vdc[0] == '/') AND ($vdc[1] == 'Predictor') AND (isset($decpar[($kdc +1)]) AND ($decpar[($kdc +1)][0] == 'numeric'))) {
$predictor = intval($decpar[($kdc +1)][1]);
}
}
} elseif ($filltrailer) {
if (($v[0] == '/') AND ($v[1] == 'Size') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'numeric'))) {
$xref['trailer']['size'] = $sarr[($k +1)][1];
} elseif (($v[0] == '/') AND ($v[1] == 'Root') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) {
$xref['trailer']['root'] = $sarr[($k +1)][1];
} elseif (($v[0] == '/') AND ($v[1] == 'Info') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) {
$xref['trailer']['info'] = $sarr[($k +1)][1];
} elseif (($v[0] == '/') AND ($v[1] == 'Encrypt') AND (isset($sarr[($k +1)]) AND ($sarr[($k +1)][0] == 'objref'))) {
$xref['trailer']['encrypt'] = $sarr[($k +1)][1];
} elseif (($v[0] == '/') AND ($v[1] == 'ID') AND (isset($sarr[($k +1)]))) {
$xref['trailer']['id'] = array();
$xref['trailer']['id'][0] = $sarr[($k +1)][1][0][1];
$xref['trailer']['id'][1] = $sarr[($k +1)][1][1][1];
}
}
}
// decode data
if ($valid_crs AND isset($xrefcrs[1][3][0])) {
// number of bytes in a row
$rowlen = ($columns + 1);
// convert the stream into an array of integers
$sdata = unpack('C*', $xrefcrs[1][3][0]);
// split the rows
$sdata = array_chunk($sdata, $rowlen);
// initialize decoded array
$ddata = array();
// initialize first row with zeros
$prev_row = array_fill (0, $rowlen, 0);
// for each row apply PNG unpredictor
foreach ($sdata as $k => $row) {
// initialize new row
$ddata[$k] = array();
// get PNG predictor value
$predictor = (10 + $row[0]);
// for each byte on the row
for ($i=1; $i<=$columns; ++$i) {
// new index
$j = ($i - 1);
$row_up = $prev_row[$j];
if ($i == 1) {
$row_left = 0;
$row_upleft = 0;
} else {
$row_left = $row[($i - 1)];
$row_upleft = $prev_row[($j - 1)];
}
switch ($predictor) {
case 10: { // PNG prediction (on encoding, PNG None on all rows)
$ddata[$k][$j] = $row[$i];
break;
}
case 11: { // PNG prediction (on encoding, PNG Sub on all rows)
$ddata[$k][$j] = (($row[$i] + $row_left) & 0xff);
break;
}
case 12: { // PNG prediction (on encoding, PNG Up on all rows)
$ddata[$k][$j] = (($row[$i] + $row_up) & 0xff);
break;
}
case 13: { // PNG prediction (on encoding, PNG Average on all rows)
$ddata[$k][$j] = (($row[$i] + (($row_left + $row_up) / 2)) & 0xff);
break;
}
case 14: { // PNG prediction (on encoding, PNG Paeth on all rows)
// initial estimate
$p = ($row_left + $row_up - $row_upleft);
// distances
$pa = abs($p - $row_left);
$pb = abs($p - $row_up);
$pc = abs($p - $row_upleft);
$pmin = min($pa, $pb, $pc);
// return minimum distance
switch ($pmin) {
case $pa: {
$ddata[$k][$j] = (($row[$i] + $row_left) & 0xff);
break;
}
case $pb: {
$ddata[$k][$j] = (($row[$i] + $row_up) & 0xff);
break;
}
case $pc: {
$ddata[$k][$j] = (($row[$i] + $row_upleft) & 0xff);
break;
}
}
break;
}
default: { // PNG prediction (on encoding, PNG optimum)
$this->Error('Unknown PNG predictor');
break;
}
}
}
$prev_row = $ddata[$k];
} // end for each row
// complete decoding
$sdata = array();
// for every row
foreach ($ddata as $k => $row) {
// initialize new row
$sdata[$k] = array(0, 0, 0);
if ($wb[0] == 0) {
// default type field
$sdata[$k][0] = 1;
}
$i = 0; // count bytes in the row
// for every column
for ($c = 0; $c < 3; ++$c) {
// for every byte on the column
for ($b = 0; $b < $wb[$c]; ++$b) {
if (isset($row[$i])) {
$sdata[$k][$c] += ($row[$i] << (($wb[$c] - 1 - $b) * 8));
}
++$i;
}
}
}
$ddata = array();
// fill xref
if (isset($index_first)) {
$obj_num = $index_first;
} else {
$obj_num = 0;
}
foreach ($sdata as $k => $row) {
switch ($row[0]) {
case 0: { // (f) linked list of free objects
break;
}
case 1: { // (n) objects that are in use but are not compressed
// create unique object index: [object number]_[generation number]
$index = $obj_num.'_'.$row[2];
// check if object already exist
if (!isset($xref['xref'][$index])) {
// store object offset position
$xref['xref'][$index] = $row[1];
}
break;
}
case 2: { // compressed objects
// $row[1] = object number of the object stream in which this object is stored
// $row[2] = index of this object within the object stream
$index = $row[1].'_0_'.$row[2];
$xref['xref'][$index] = -1;
break;
}
default: { // null objects
break;
}
}
++$obj_num;
}
} // end decoding data
if (isset($prevxref)) {
// get previous xref
$xref = $this->getXrefData($prevxref, $xref);
}
return $xref;
}
/**
* Get object type, raw value and offset to next object
* @param $offset (int) Object offset.
* @return array containing object type, raw value and offset to next object
* @protected
* @since 1.0.000 (2011-06-20)
*/
protected function getRawObject($offset=0) {
$objtype = ''; // object type to be returned
$objval = ''; // object value to be returned
// skip initial white space chars: \x00 null (NUL), \x09 horizontal tab (HT), \x0A line feed (LF), \x0C form feed (FF), \x0D carriage return (CR), \x20 space (SP)
$offset += strspn($this->pdfdata, "\x00\x09\x0a\x0c\x0d\x20", $offset);
// get first char
$char = $this->pdfdata[$offset];
// get object type
switch ($char) {
case '%': { // \x25 PERCENT SIGN
// skip comment and search for next token
$next = strcspn($this->pdfdata, "\r\n", $offset);
if ($next > 0) {
$offset += $next;
return $this->getRawObject($offset);
}
break;
}
case '/': { // \x2F SOLIDUS
// name object
$objtype = $char;
++$offset;
if (preg_match('/^([^\x00\x09\x0a\x0c\x0d\x20\s\x28\x29\x3c\x3e\x5b\x5d\x7b\x7d\x2f\x25]+)/', substr($this->pdfdata, $offset, 256), $matches) == 1) {
$objval = $matches[1]; // unescaped value
$offset += strlen($objval);
}
break;
}
case '(': // \x28 LEFT PARENTHESIS
case ')': { // \x29 RIGHT PARENTHESIS
// literal string object
$objtype = $char;
++$offset;
$strpos = $offset;
if ($char == '(') {
$open_bracket = 1;
while ($open_bracket > 0) {
if (!isset($this->pdfdata{$strpos})) {
break;
}
$ch = $this->pdfdata{$strpos};
switch ($ch) {
case '\\': { // REVERSE SOLIDUS (5Ch) (Backslash)
// skip next character
++$strpos;
break;
}
case '(': { // LEFT PARENHESIS (28h)
++$open_bracket;
break;
}
case ')': { // RIGHT PARENTHESIS (29h)
--$open_bracket;
break;
}
}
++$strpos;
}
$objval = substr($this->pdfdata, $offset, ($strpos - $offset - 1));
$offset = $strpos;
}
break;
}
case '[': // \x5B LEFT SQUARE BRACKET
case ']': { // \x5D RIGHT SQUARE BRACKET
// array object
$objtype = $char;
++$offset;
if ($char == '[') {
// get array content
$objval = array();
do {
// get element
$element = $this->getRawObject($offset);
$offset = $element[2];
$objval[] = $element;
} while ($element[0] != ']');
// remove closing delimiter
array_pop($objval);
}
break;
}
case '<': // \x3C LESS-THAN SIGN
case '>': { // \x3E GREATER-THAN SIGN
if (isset($this->pdfdata{($offset + 1)}) AND ($this->pdfdata{($offset + 1)} == $char)) {
// dictionary object
$objtype = $char.$char;
$offset += 2;
if ($char == '<') {
// get array content
$objval = array();
do {
// get element
$element = $this->getRawObject($offset);
$offset = $element[2];
$objval[] = $element;
} while ($element[0] != '>>');
// remove closing delimiter
array_pop($objval);
}
} else {
// hexadecimal string object
$objtype = $char;
++$offset;
if (($char == '<') AND (preg_match('/^([0-9A-Fa-f\x09\x0a\x0c\x0d\x20]+)>/iU', substr($this->pdfdata, $offset), $matches) == 1)) {
// remove white space characters
$objval = strtr($matches[1], "\x09\x0a\x0c\x0d\x20", '');
$offset += strlen($matches[0]);
} elseif (($endpos = strpos($this->pdfdata, '>', $offset)) !== FALSE) {
$offset = $endpos + 1;
}
}
break;
}
default: {
if (substr($this->pdfdata, $offset, 6) == 'endobj') {
// indirect object
$objtype = 'endobj';
$offset += 6;
} elseif (substr($this->pdfdata, $offset, 4) == 'null') {
// null object
$objtype = 'null';
$offset += 4;
$objval = 'null';
} elseif (substr($this->pdfdata, $offset, 4) == 'true') {
// boolean true object
$objtype = 'boolean';
$offset += 4;
$objval = 'true';
} elseif (substr($this->pdfdata, $offset, 5) == 'false') {
// boolean false object
$objtype = 'boolean';
$offset += 5;
$objval = 'false';
} elseif (substr($this->pdfdata, $offset, 6) == 'stream') {
// start stream object
$objtype = 'stream';
$offset += 6;
if (preg_match('/^([\r]?[\n])/isU', substr($this->pdfdata, $offset), $matches) == 1) {
$offset += strlen($matches[0]);
if (preg_match('/(endstream)[\x09\x0a\x0c\x0d\x20]/isU', substr($this->pdfdata, $offset), $matches, PREG_OFFSET_CAPTURE) == 1) {
$objval = substr($this->pdfdata, $offset, $matches[0][1]);
$offset += $matches[1][1];
}
}
} elseif (substr($this->pdfdata, $offset, 9) == 'endstream') {
// end stream object
$objtype = 'endstream';
$offset += 9;
} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+R/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
// indirect object reference
$objtype = 'objref';
$offset += strlen($matches[0]);
$objval = intval($matches[1]).'_'.intval($matches[2]);
} elseif (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+obj/iU', substr($this->pdfdata, $offset, 33), $matches) == 1) {
// object start
$objtype = 'obj';
$objval = intval($matches[1]).'_'.intval($matches[2]);
$offset += strlen ($matches[0]);
} elseif (($numlen = strspn($this->pdfdata, '+-.0123456789', $offset)) > 0) {
// numeric object
$objtype = 'numeric';
$objval = substr($this->pdfdata, $offset, $numlen);
$offset += $numlen;
}
break;
}
}
return array($objtype, $objval, $offset);
}
/**
* Get content of indirect object.
* @param $obj_ref (string) Object number and generation number separated by underscore character.
* @param $offset (int) Object offset.
* @param $decoding (boolean) If true decode streams.
* @return array containing object data.
* @protected
* @since 1.0.000 (2011-05-24)
*/
protected function getIndirectObject($obj_ref, $offset=0, $decoding=true) {
$obj = explode('_', $obj_ref);
if (($obj === false) OR (count($obj) != 2)) {
$this->Error('Invalid object reference: '.$obj);
return;
}
$objref = $obj[0].' '.$obj[1].' obj';
// ignore leading zeros
$offset += strspn($this->pdfdata, '0', $offset);
if (strpos($this->pdfdata, $objref, $offset) != $offset) {
// an indirect reference to an undefined object shall be considered a reference to the null object
return array('null', 'null', $offset);
}
// starting position of object content
$offset += strlen($objref);
// get array of object content
$objdata = array();
$i = 0; // object main index
do {
$oldoffset = $offset;
// get element
$element = $this->getRawObject($offset);
$offset = $element[2];
// decode stream using stream's dictionary information
if ($decoding AND ($element[0] == 'stream') AND (isset($objdata[($i - 1)][0])) AND ($objdata[($i - 1)][0] == '<<')) {
$element[3] = $this->decodeStream($objdata[($i - 1)][1], $element[1]);
}
$objdata[$i] = $element;
++$i;
} while (($element[0] != 'endobj') AND ($offset != $oldoffset));
// remove closing delimiter
array_pop($objdata);
// return raw object content
return $objdata;
}
/**
* Get the content of object, resolving indect object reference if necessary.
* @param $obj (string) Object value.
* @return array containing object data.
* @protected
* @since 1.0.000 (2011-06-26)
*/
protected function getObjectVal($obj) {
if ($obj[0] == 'objref') {
// reference to indirect object
if (isset($this->objects[$obj[1]])) {
// this object has been already parsed
return $this->objects[$obj[1]];
} elseif (isset($this->xref[$obj[1]])) {
// parse new object
$this->objects[$obj[1]] = $this->getIndirectObject($obj[1], $this->xref[$obj[1]], false);
return $this->objects[$obj[1]];
}
}
return $obj;
}
/**
* Decode the specified stream.
* @param $sdic (array) Stream's dictionary array.
* @param $stream (string) Stream to decode.
* @return array containing decoded stream data and remaining filters.
* @protected
* @since 1.0.000 (2011-06-22)
*/
protected function decodeStream($sdic, $stream) {
// get stream length and filters
$slength = strlen($stream);
if ($slength <= 0) {
return array('', array());
}
$filters = array();
foreach ($sdic as $k => $v) {
if ($v[0] == '/') {
if (($v[1] == 'Length') AND (isset($sdic[($k + 1)])) AND ($sdic[($k + 1)][0] == 'numeric')) {
// get declared stream length
$declength = intval($sdic[($k + 1)][1]);
if ($declength < $slength) {
$stream = substr($stream, 0, $declength);
$slength = $declength;
}
} elseif (($v[1] == 'Filter') AND (isset($sdic[($k + 1)]))) {
// resolve indirect object
$objval = $this->getObjectVal($sdic[($k + 1)]);
if ($objval[0] == '/') {
// single filter
$filters[] = $objval[1];
} elseif ($objval[0] == '[') {
// array of filters
foreach ($objval[1] as $flt) {
if ($flt[0] == '/') {
$filters[] = $flt[1];
}
}
}
}
}
}
// decode the stream
$remaining_filters = array();
foreach ($filters as $filter) {
if (in_array($filter, TCPDF_FILTERS::getAvailableFilters())) {
try {
$stream = TCPDF_FILTERS::decodeFilter($filter, $stream);
} catch (Exception $e) {
$emsg = $e->getMessage();
if ((($emsg[0] == '~') AND !$this->cfg['ignore_missing_filter_decoders'])
OR (($emsg[0] != '~') AND !$this->cfg['ignore_filter_decoding_errors'])) {
$this->Error($e->getMessage());
}
}
} else {
// add missing filter to array
$remaining_filters[] = $filter;
}
}
return array($stream, $remaining_filters);
}
/**
* Throw an exception or print an error message and die if the K_TCPDF_PARSER_THROW_EXCEPTION_ERROR constant is set to true.
* @param $msg (string) The error message
* @public
* @since 1.0.000 (2011-05-23)
*/
public function Error($msg) {
if ($this->cfg['die_for_errors']) {
die('<strong>TCPDF_PARSER ERROR: </strong>'.$msg);
} else {
throw new Exception('TCPDF_PARSER ERROR: '.$msg);
}
}
} // END OF TCPDF_PARSER CLASS
//============================================================+
// END OF FILE
//============================================================+

View File

@ -1,7 +1,5 @@
<?php <?php
require 'lib/geshi/geshi.php';
// FIXME svn stuff still using optc etc, won't work, needs updating! // FIXME svn stuff still using optc etc, won't work, needs updating!
if (is_admin()) { if (is_admin()) {
if (!is_array($config['rancid_configs'])) { if (!is_array($config['rancid_configs'])) {

View File

@ -28,7 +28,6 @@ if (strpos($_SERVER['PATH_INFO'], 'debug')) {
$init_modules = array('web', 'auth'); $init_modules = array('web', 'auth');
require realpath(__DIR__ . '/..') . '/includes/init.php'; require realpath(__DIR__ . '/..') . '/includes/init.php';
require $config['install_dir'] . '/html/lib/tcpdf/tcpdf.php';
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

View File

@ -1,4 +1,3 @@
require_once $config['install_dir']."/lib/PhpAmqpLib/autoload.php";
// Configurations // Configurations
$host = $opts["host"]; $host = $opts["host"];

Some files were not shown because too many files have changed in this diff Show More