Imported Upstream version 0.6.24+dfsg1

This commit is contained in:
Mario Fetka
2017-05-20 15:26:21 +02:00
commit 32a360eca6
705 changed files with 87250 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Base path of the web site. If this includes a domain, eg: localhost/kohana/
* then a full URL will be used, eg: http://localhost/kohana/. If it only includes
* the path, and a site_protocol is specified, the domain will be auto-detected.
*/
$config['site_domain'] = BASE_URL;
/**
* Force a default protocol to be used by the site. If no site_protocol is
* specified, then the current protocol is used, or when possible, only an
* absolute path (with no protocol/domain) is used.
*/
$config['site_protocol'] = '';
/**
* Name of the front controller for this application. Default: index.php
*
* This can be removed by using URL rewriting.
*/
$config['index_page'] = '';
/**
* Fake file extension that will be added to all generated URLs. Example: .html
*/
$config['url_suffix'] = '';
/**
* Length of time of the internal cache in seconds. 0 or FALSE means no caching.
* The internal cache stores file paths and config entries across requests and
* can give significant speed improvements at the expense of delayed updating.
*/
$config['internal_cache'] = FALSE;
/**
* Enable or disable gzip output compression. This can dramatically decrease
* server bandwidth usage, at the cost of slightly higher CPU usage. Set to
* the compression level (1-9) that you want to use, or FALSE to disable.
*
* Do not enable this option if you are using output compression in php.ini!
*/
$config['output_compression'] = FALSE;
/**
* Enable or disable global XSS filtering of GET, POST, and SERVER data. This
* option also accepts a string to specify a specific XSS filtering tool.
*/
$config['global_xss_filtering'] = TRUE;
/**
* Enable or disable hooks.
*/
$config['enable_hooks'] = FALSE;
/**
* Log thresholds:
* 0 - Disable logging
* 1 - Errors and exceptions
* 2 - Warnings
* 3 - Notices
* 4 - Debugging
*/
$config['log_threshold'] = 0;
/**
* Message logging directory.
*/
$config['log_directory'] = PNP_LOG_PATH.'/kohana';
/**
* Enable or disable displaying of Kohana error pages. This will not affect
* logging. Turning this off will disable ALL error pages.
*/
$config['display_errors'] = TRUE;
/**
* Enable or disable statistics in the final output. Stats are replaced via
* specific strings, such as {execution_time}.
*
* @see http://docs.kohanaphp.com/general/configuration
*/
$config['render_stats'] = TRUE;
/**
* Filename prefixed used to determine extensions. For example, an
* extension to the Controller class would be named MY_Controller.php.
*/
$config['extension_prefix'] = 'MY_';
/**
* Additional resource paths, or "modules". Each path can either be absolute
* or relative to the docroot. Modules can include any resource that can exist
* in your application directory, configuration files, controllers, views, etc.
*/
$config['modules'] = array
(
// MODPATH.'auth', // Authentication
// MODPATH.'kodoc', // Self-generating documentation
// MODPATH.'gmaps', // Google Maps integration
// MODPATH.'archive', // Archive utility
// MODPATH.'payment', // Online payments
// MODPATH.'unit_test', // Unit testing
);
/**
* PNP Config
*
* pnp_etc_path points to $sysconfdir
*/
$config['pnp_etc_path'] = PNP_ETC_PATH;
/**
* Default Theme
*/
$config['theme'] = 'smoothness';
/*
* Available Doc Languages
*/
$config['doc_language'] = array("en_US", "de_DE");
/*
* Default template dirs
*/
$config['template_dirs'] = array(DOCROOT."/templates",DOCROOT."/templates.dist");
/*
* Default graph dimensions
*/
$config['graph_width'] = "500";
$config['graph_height'] = "100";
$config['zgraph_width'] = "500";
$config['zgraph_height'] = "100";
$config['pdf_width'] = "675";
$config['pdf_height'] = "100";
$config['right_zoom_offset'] = "30";
$config['mobile_devices'] = "iPhone";
$config['pdf_page_size'] = "A4";
$config['pdf_margin_left'] = "17.5";
$config['pdf_margin_right'] = "10";
$config['pdf_margin_top'] = "30";
$config['auth_multisite_enabled'] = "0";
$config['auth_multisite_htpasswd'] = "";
$config['auth_multisite_serials'] = "";
$config['auth_multisite_secret'] = "";
$config['auth_multisite_login_url'] = "/check_mk/login.py";

View File

@@ -0,0 +1,16 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* Default language locale name(s).
* First item must be a valid i18n directory name, subsequent items are alternative locales
* for OS's that don't support the first (e.g. Windows). The first valid locale in the array will be used.
* @see http://php.net/setlocale
*/
$config['language'] = array('en_US', 'de_DE', 'es_ES');
/**
* Locale timezone. Defaults to use the server timezone.
* @see http://php.net/timezones
*/
$config['timezone'] = '';

View File

@@ -0,0 +1,7 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* Sets the default route to "welcome"
*/
$config['_default'] = 'start';

View File

@@ -0,0 +1,47 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Session
*
* Session driver name.
*/
$config['driver'] = 'native';
/**
* Session storage parameter, used by drivers.
*/
$config['storage'] = '';
/**
* Session name.
* It must contain only alphanumeric characters and underscores. At least one letter must be present.
*/
$config['name'] = 'pnp4nagios';
/**
* Session parameters to validate: user_agent, ip_address, expiration.
*/
$config['validate'] = array('user_agent, ip_address');
/**
* Enable or disable session encryption.
* Note: this has no effect on the native session driver.
* Note: the cookie driver always encrypts session data. Set to TRUE for stronger encryption.
*/
$config['encryption'] = FALSE;
/**
* Session lifetime. Number of seconds that each session will last.
* A value of 0 will keep the session active until the browser is closed (with a limit of 24h).
*/
$config['expiration'] = 0;
/**
* Number of page loads before the session id is regenerated.
* A value of 0 will disable automatic session id regeneration.
*/
$config['regenerate'] = 0;
/**
* Percentage probability that the gc (garbage collection) routine is started.
*/
$config['gc_probability'] = 0;

View File

@@ -0,0 +1,148 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Ajax controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Ajax_Controller extends System_Controller {
public function __construct(){
parent::__construct();
// Disable auto-rendering
$this->auto_render = FALSE;
}
public function index(){
url::redirect("start", 302);
}
public function search() {
$query = pnp::clean($this->input->get('term'));
$result = array();
if(strlen($query)>=1) {
$hosts = $this->data->getHosts();
foreach($hosts as $host){
if(preg_match("/$query/i",$host['name'])){
array_push($result,$host['name']);
}
}
echo json_encode($result);
}
}
public function remove($what){
if($what == 'timerange'){
$this->session->delete('start');
$this->session->delete('end');
$this->session->set('timerange-reset', 1);
}
}
public function filter($what){
if($what == 'set-sfilter'){
$this->session->set('sfilter', $_POST['sfilter']);
}elseif($what == 'set-spfilter'){
$this->session->set('spfilter', $_POST['spfilter']);
}elseif($what == 'set-pfilter'){
$this->session->set('pfilter', $_POST['pfilter']);
}
}
public function basket($action=FALSE){
// Disable auto-rendering
$this->auto_render = FALSE;
$host = false;
$service = false;
$basket = array();
if($action == "list"){
$basket = $this->session->get("basket");
if(is_array($basket) && sizeof($basket) > 0){
foreach($basket as $item){
printf("<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
"basket_action_remove",
$item,
$item,
Kohana::lang('common.basket-remove', $item),
url::base(),
pnp::shorten($item)
);
}
}
}elseif($action == "add"){
$item = $_POST['item'];
$basket = $this->session->get("basket");
if(!is_array($basket)){
$basket[] = "$item";
}else{
if(!in_array($item,$basket)){
$basket[] = $item;
}
}
$this->session->set("basket", $basket);
foreach($basket as $item){
printf("<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
"basket_action_remove",
$item,
$item,
Kohana::lang('common.basket-remove', $item),
url::base(),
pnp::shorten($item)
);
}
}elseif($action == "sort"){
$items = $_POST['items'];
$basket = explode(',', $items);
array_pop($basket);
$this->session->set("basket", $basket);
foreach($basket as $item){
printf("<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
"basket_action_remove",
$item,
$item,
Kohana::lang('common.basket-remove', $item),
url::base(),
pnp::shorten($item)
);
}
}elseif($action == "remove"){
$basket = $this->session->get("basket");
$item_to_remove = $_POST['item'];
$new_basket = array();
foreach($basket as $item){
if($item == $item_to_remove){
continue;
}
$new_basket[] = $item;
}
$basket = $new_basket;
$this->session->set("basket", $basket);
foreach($basket as $item){
printf("<li class=\"ui-state-default %s\" id=\"%s\"><a title=\"%s\" id=\"%s\"><img width=12px height=12px src=\"%smedia/images/remove.png\"></a>%s</li>\n",
"basket_action_remove",
$item,
$item,
Kohana::lang('common.basket-remove', $item),
url::base(),
pnp::shorten($item)
);
}
}elseif($action == "clear"){
$this->session->delete("basket");
}else{
echo "Action $action not known";
}
$basket = $this->session->get("basket");
if(is_array($basket) && sizeof($basket) == 0){
echo Kohana::lang('common.basket-empty');
}else{
echo "<div align=\"center\" class=\"p2\">\n";
echo "<button id=\"show\">".Kohana::lang('common.basket-show')."</button>\n";
echo "<button id=\"clear\">".Kohana::lang('common.basket-clear')."</button>\n";
echo "</div>\n";
}
}
}

View File

@@ -0,0 +1,26 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Debug controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Color_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->template = $this->add_view('template');
$this->template->color = $this->add_view('color');
$this->template->color->color_box = $this->add_view('color_box');
$this->template->color->logo_box = $this->add_view('logo_box');
}
public function index()
{
$this->scheme = $this->config->scheme;
}
}

View File

@@ -0,0 +1,66 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Debug controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Debug_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->template = $this->add_view('template');
$this->template->debug = $this->add_view('debug');
}
public function index()
{
$this->data->getTimeRange($this->start,$this->end,$this->view);
if(isset($this->host) && isset($this->service)){
$this->url = "?host=".$this->host."&srv=".$this->service;
if($this->start){
$this->url .= "&start=".$this->start;
$this->session->set("start", $this->start);
}
if($this->end){
$this->url .= "&end=".$this->end;
$this->session->set("end", $this->end);
}
$services = $this->data->getServices($this->host);
$this->data->buildDataStruct($this->host,$this->service,$this->view);
$this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']);
$this->title = "Service Details ". $this->host ." -> " . $this->data->MACRO['DISP_SERVICEDESC'];
}elseif(isset($this->host)){
$this->is_authorized = $this->auth->is_authorized($this->host);
if($this->view == ""){
$this->view = $this->config->conf['overview-range'];
}
if($this->start){
$this->url .= "&start=".$this->start;
$this->session->set("start", $this->start);
}
if($this->end){
$this->url .= "&end=".$this->end;
$this->session->set("end", $this->end);
}
$this->title = "Start $this->host";
$services = $this->data->getServices($this->host);
$this->title = "Service Overview for $this->host";
foreach($services as $service){
if($service['state'] == 'active')
$this->data->buildDataStruct($this->host,$service['name'],$this->view);
}
}else{
if(isset($this->host)){
url::redirect("/graph");
}else{
throw new Kohana_Exception('error.get-first-host');
}
}
}
}

View File

@@ -0,0 +1,80 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Docs controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Docs_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->template = $this->add_view('template');
$this->template->docs = $this->add_view('docs');
$this->template->docs->search_box = $this->add_view('search_box');
$this->template->docs->docs_box = $this->add_view('docs_box');
$this->template->docs->logo_box = $this->add_view('logo_box');
$this->doc_language = $this->config->conf['doc_language'];
}
public function index(){
url::redirect("docs/view/");
}
public function view($lang=FALSE, $page=FALSE){
if($lang == FALSE){
if(!in_array($this->config->conf['lang'],$this->doc_language) ){
$this->lang = $this->doc_language[0];
}else{
$this->lang = $this->config->conf['lang'] ;
}
}else{
if(in_array($lang,$this->doc_language) ){
$this->lang = $lang;
}else{
$this->lang = $this->doc_language[0];
url::redirect("docs/view/");
}
}
if($page == FALSE){
url::redirect("docs/view/".$this->lang."/start");
}
$this->page = $page;
$file = sprintf("documents/%s/%s.html", $this->lang, $this->page);
$file_toc = sprintf("documents/%s/start.html", $this->lang);
if(!file_exists($file)){
url::redirect("docs/view/start");
}
$this->content = file_get_contents($file);
$toc = file( $file_toc );
$this->toc = "";
$in = FALSE;
foreach($toc as $t){
if(preg_match("/SECTION/", $t) ){
$in = ! $in;
continue;
}
if($in == TRUE){
$this->toc .= $t;
}
}
#
# some string replacements
#
$this->toc = str_replace("/de/pnp-0.6/", "", $this->toc);
$this->toc = str_replace("/pnp-0.6/", "", $this->toc);
$this->toc = preg_replace("/<h2>.*<\/h2>/", "" , $this->toc);
$this->content = str_replace("/templates/", "http://docs.pnp4nagios.org/templates/", $this->content);
$this->content = str_replace("/de/pnp-0.6/", "", $this->content);
$this->content = str_replace("/pnp-0.6/", "", $this->content);
$this->content = str_replace("/_media", url::base()."documents/_media", $this->content);
$this->content = str_replace("gallery", "", $this->content);
$this->content = str_replace("/_detail", url::base()."documents/_media", $this->content);
$this->content = str_replace("/lib/images", url::base()."documents/images", $this->content);
$this->graph_width = ($this->config->conf['graph_width'] + 140);
}
}

View File

@@ -0,0 +1,129 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Graph controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Graph_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->template = $this->add_view('template');
if (isset($this->version) && $this->version == "tiny" )
$this->template->graph = $this->add_view('graph_tiny');
else
$this->template->graph = $this->add_view('graph');
$this->template->zoom_header = $this->add_view('zoom_header');
$this->template->zoom_header->graph_width = ($this->config->conf['zgraph_width'] + 140);
$this->template->zoom_header->graph_height = ($this->config->conf['zgraph_height'] + 230);
$this->template->graph->icon_box = $this->add_view('icon_box');
$this->template->graph->icon_box->position = "graph";
$this->template->graph->icon_box->xml_icon = TRUE;
$this->template->graph->icon_box->pdf_icon = TRUE;
}
public function index()
{
$this->template->graph->graph_content = $this->add_view('graph_content');
$this->template->graph->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
$this->template->graph->graph_content->timerange_select = $this->add_view('timerange_select');
$this->template->graph->header = $this->add_view('header');
$this->template->graph->search_box = $this->add_view('search_box');
$this->template->graph->service_box = $this->add_view('service_box');
$this->template->graph->basket_box = $this->add_view('basket_box');
$this->template->graph->widget_menu = $this->add_view('widget_menu');
$this->template->graph->graph_content->widget_graph = $this->add_view('widget_graph');
// Change the status box while multisite theme is in use
if($this->theme == "multisite"){
$this->template->graph->status_box = $this->add_view('multisite_box');
$this->template->graph->status_box->base_url = $this->config->conf['multisite_base_url'];
$this->template->graph->status_box->site = $this->config->conf['multisite_site'];
}else{
$this->template->graph->status_box = $this->add_view('status_box');
}
// Service Details
if($this->host != "" && $this->service != ""){
$this->service = pnp::clean($this->service);
$this->host = pnp::clean($this->host);
$this->url = "?host=".$this->host."&srv=".$this->service;
$services = $this->data->getServices($this->host);
#Landingpage for mobile devices
if($this->isMobileDevice()){
url::redirect( "mobile/host/".urlencode($this->host)."/".urlencode($this->service) );
}
#print Kohana::debug($services);
$this->data->buildDataStruct($this->host,$this->service,$this->view);
$this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']);
$this->title = Kohana::lang('common.service-details') . " ". $this->host ." -> " . $this->data->MACRO['DISP_SERVICEDESC'];
$this->template->graph->graph_content->graph_width = ($this->data->STRUCT[0]['GRAPH_WIDTH'] + 85);
// Status Box Vars
$this->template->graph->status_box->host = $this->data->MACRO['DISP_HOSTNAME'];
$this->template->graph->status_box->lhost = $this->data->MACRO['HOSTNAME'];
$this->template->graph->status_box->service = $this->data->MACRO['DISP_SERVICEDESC'];
$this->template->graph->status_box->lservice = $this->data->MACRO['SERVICEDESC'];
$this->template->graph->status_box->timet = date($this->config->conf['date_fmt'],intval($this->data->MACRO['TIMET']));
// Service Box Vars
$this->template->graph->service_box->services = $services;
$this->template->graph->service_box->host = $this->host;
// Timerange Box Vars
$this->template->graph->timerange_box = $this->add_view('timerange_box');
$this->template->graph->timerange_box->timeranges = $this->data->TIMERANGE;
//
// Host Overview
}elseif($this->host != ""){
$this->is_authorized = $this->auth->is_authorized($this->host);
$this->host = pnp::clean($this->host);
#Landingpage for mobile devices
if($this->isMobileDevice()){
url::redirect( "mobile/host/".urlencode($this->host) );
}
if($this->view == ""){
$this->view = $this->config->conf['overview-range'];
}
$this->url = "?host=".$this->host;
$this->title = Kohana::lang('common.start'). " ". $this->host;
$services = $this->data->getServices($this->host);
// Status Box Vars
$this->template->graph->status_box->host = $this->data->MACRO['DISP_HOSTNAME'];
$this->template->graph->status_box->lhost = $this->data->MACRO['HOSTNAME'];
$this->template->graph->status_box->shost = pnp::shorten($this->data->MACRO['DISP_HOSTNAME']);
$this->template->graph->status_box->timet = date($this->config->conf['date_fmt'],intval($this->data->MACRO['TIMET']));
// Service Box Vars
$this->template->graph->service_box->services = $services;
$this->template->graph->service_box->host = $this->host;
// Timerange Box Vars
$this->template->graph->timerange_box = $this->add_view('timerange_box');
$this->template->graph->timerange_box->timeranges = $this->data->TIMERANGE;
$this->template->graph->icon_box->xml_icon = FALSE;
$this->title = Kohana::lang('common.service-overview', $this->host);
foreach($services as $service){
if($service['state'] == 'active')
$this->data->buildDataStruct($this->host,$service['name'],$this->view);
}
}else{
#Landingpage for mobile devices
if($this->isMobileDevice()){
url::redirect("mobile");
return;
}
if($this->isAuthorizedFor('host_overview' ) ){
$this->host = $this->data->getFirstHost();
if(isset($this->host)){
url::redirect("graph?host=".$this->host);
}else{
throw new Kohana_Exception('error.get-first-host');
}
}else{
throw new Kohana_Exception('error.not_authorized_for_host_overview');
}
}
$this->template->graph->logo_box = $this->add_view('logo_box');
$this->template->graph->header->title = $this->title;
}
}

View File

@@ -0,0 +1,56 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Image controller.
*
* @package pnp4nagios
* @author Joerg Linge
* @license GPL
*/
class Image_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
// Disable auto-rendering
$this->auto_render = FALSE;
if($this->input->get('w') != "" )
$this->rrdtool->config->conf['graph_width'] = intval($this->input->get('w'));
if($this->input->get('graph_width') != "" )
$this->rrdtool->config->conf['graph_width'] = intval($this->input->get('graph_width'));
if($this->input->get('h') != "" )
$this->rrdtool->config->conf['graph_height'] = intval($this->input->get('h'));
if($this->input->get('graph_height') != "" )
$this->rrdtool->config->conf['graph_height'] = intval($this->input->get('graph_height'));
$this->data->getTimeRange($this->start,$this->end,$this->view);
if($this->tpl != ""){
$this->data->buildDataStruct('__special',$this->tpl,$this->view,$this->source);
#print Kohana::debug($this->data->STRUCT);
$image = $this->rrdtool->doImage($this->data->STRUCT[0]['RRD_CALL']);
$this->rrdtool->streamImage($image);
}elseif(isset($this->host) && isset($this->service)){
$this->data->buildDataStruct($this->host,$this->service,$this->view,$this->source);
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE)
$this->rrdtool->streamImage("ERROR: NOT_AUTHORIZED");
#print Kohana::debug($this->data->STRUCT);
if(sizeof($this->data->STRUCT) > 0){
$image = $this->rrdtool->doImage($this->data->STRUCT[0]['RRD_CALL']);
}else{
$image = FALSE;
}
$this->rrdtool->streamImage($image);
}else{
url::redirect("start", 302);
}
}
}

View File

@@ -0,0 +1,75 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Json controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Json_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
}
public function index(){
// Disable auto-rendering
$this->auto_render = FALSE;
// Service Details
if($this->host != "" && $this->service != ""){
$services = $this->data->getServices($this->host);
$this->data->buildDataStruct($this->host,$this->service,$this->view);
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
print json_encode("not authorized");
exit;
}
$i = 0;
$json = array();
foreach($this->data->STRUCT as $struct){
$json[$i]['image_url'] = "host=".$struct['MACRO']['HOSTNAME']."&srv=".$struct['MACRO']['SERVICEDESC']."&source=".$struct['SOURCE']."&view=".$struct['VIEW'];
$json[$i]['ds_name'] = $struct['ds_name'];
$json[$i]['start'] = $struct['TIMERANGE']['start'];
$json[$i]['end'] = $struct['TIMERANGE']['end'];
$json[$i]['title'] = $struct['TIMERANGE']['title'];
$i++;
}
print json_encode($json);
// Host Overview
}elseif($this->host != ""){
if($this->auth->is_authorized($this->host) === FALSE){
print json_encode("not authorized");
exit;
}
$services = $this->data->getServices($this->host);
foreach($services as $service){
if($service['state'] == 'active'){
$this->data->buildDataStruct($this->host,$service['name'],$this->view);
}
}
$i = 0;
$json = array();
foreach($this->data->STRUCT as $struct){
$json[$i]['image_url'] = "host=".$struct['MACRO']['HOSTNAME']."&srv=".$struct['MACRO']['SERVICEDESC']."&source=".$struct['SOURCE']."&view=".$struct['VIEW'];
$json[$i]['servicedesc'] = $struct['MACRO']['SERVICEDESC'];
$json[$i]['ds_name'] = $struct['ds_name'];
$json[$i]['start'] = $struct['TIMERANGE']['start'];
$json[$i]['end'] = $struct['TIMERANGE']['end'];
$json[$i]['title'] = $struct['TIMERANGE']['title'];
$i++;
}
print json_encode($json);
}else{
$this->hosts = $this->data->getHosts();
$i = 0;
$json = array();
foreach($this->hosts as $host){
if($host['state'] == "active"){
$json[$i]['hostname'] = $host['name'];
$i++;
}
}
print json_encode($json);
}
}
}

View File

@@ -0,0 +1,93 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Mobile controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Mobile_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->session->set('classic-ui',0);
$this->template = $this->add_view('mobile');
}
public function index()
{
$this->template->home = $this->add_view('mobile_home');
}
public function about()
{
$this->template->about = $this->add_view('mobile_about');
}
public function overview()
{
$this->template->overview = $this->add_view('mobile_overview');
$this->template->overview->hosts = $this->data->getHosts();
}
public function host($host=NULL)
{
$this->template->host = $this->add_view('mobile_host');
$this->is_authorized = $this->auth->is_authorized($host);
$this->template->host->hostname = $host;
$this->template->host->services = $this->data->getServices($host);
}
public function graph($host=NULL, $service=NULL)
{
$this->template->graph = $this->add_view('mobile_graph');
$this->data->buildDataStruct($host,$service,$this->view);
$this->is_authorized = $this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']);
}
public function search()
{
$this->template->query = $this->add_view('mobile_search');
$query = pnp::clean($this->input->post('term'));
$result = array();
if(strlen($query)>=1) {
$hosts = $this->data->getHosts();
foreach($hosts as $host){
if(preg_match("/$query/i",$host['name'])){
array_push($result,$host['name']);
}
}
}
$this->result = $result;
}
public function pages($page=NULL)
{
$this->is_authorized=TRUE;
if($this->view == ""){
$this->view = $this->config->conf['overview-range'];
}
$this->page = $page;
if(is_null($this->page) ){
$this->template->pages = $this->add_view('mobile_pages');
$this->template->pages->pages = $this->data->getPages();
return;
}
$this->data->buildPageStruct($this->page,$this->view);
$this->template->pages = $this->add_view('mobile_graph');
}
public function special($tpl=NULL)
{
$this->tpl = $tpl;
if(is_null($this->tpl) ){
$this->template->special = $this->add_view('mobile_special');
$this->template->special->templates = $this->data->getSpecialTemplates();
return;
}
$this->data->buildDataStruct('__special',$this->tpl,$this->view);
$this->template->special = $this->add_view('mobile_graph_special');
}
public function go($goto=FALSE)
{
if($goto == 'classic'){
$this->session->set('classic-ui',1);
url::redirect("graph");
}
}
}

View File

@@ -0,0 +1,80 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Graph controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Page_Controller extends System_Controller {
public function __construct(){
parent::__construct();
$this->template = $this->add_view('template');
$this->template->page = $this->add_view('page');
$this->template->zoom_header = $this->add_view('zoom_header');
$this->template->zoom_header->graph_width = ($this->config->conf['graph_width'] + 140);
$this->template->zoom_header->graph_height = ($this->config->conf['graph_height'] + 230);
$this->template->page->graph_content = $this->add_view('graph_content');
$this->template->page->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
$this->template->page->graph_content->timerange_select = $this->add_view('timerange_select');
$this->template->page->header = $this->add_view('header');
$this->template->page->search_box = $this->add_view('search_box');
$this->template->page->logo_box = $this->add_view('logo_box');
$this->is_authorized=TRUE;
}
public function index(){
if( !$this->isAuthorizedFor('pages') ){
throw new Kohana_Exception('error.auth-pages');
}
$this->page = pnp::clean($this->input->get('page'));
if($this->page == ""){
$this->page = $this->data->getFirstPage();
}
if($this->page == ""){
throw new Kohana_Exception('error.page-config-dir', $this->config->conf['page_dir']);
}
if($this->view == ""){
$this->view = $this->config->conf['overview-range'];
}
$this->data->buildPageStruct($this->page,$this->view);
$this->template->page->header->title = Kohana::lang('common.page',$this->data->PAGE_DEF['page_name']);
$this->url = "?page&page=$this->page";
// Timerange Box Vars
$this->template->page->timerange_box = $this->add_view('timerange_box');
$this->template->page->timerange_box->timeranges = $this->data->TIMERANGE;
// Pages Box
$this->pages = $this->data->getPages();
$this->template->page->pages_box = $this->add_view('pages_box');
$this->template->page->pages_box->pages = $this->pages;
// Basket Box
$this->template->page->basket_box = $this->add_view('basket_box');
// Icon Box
$this->template->page->icon_box = $this->add_view('icon_box');
$this->template->page->icon_box->position = "page";
}
public function basket(){
$basket = $this->session->get("basket");
if(is_array($basket) && sizeof($basket) > 0){
$this->data->buildBasketStruct($basket,$this->view);
$this->template->page->basket_box = $this->add_view('basket_box');
$this->template->page->header->title = Kohana::lang('common.page-basket');
$this->url = "basket?";
// Timerange Box Vars
$this->template->page->timerange_box = $this->add_view('timerange_box');
$this->template->page->timerange_box->timeranges = $this->data->TIMERANGE;
// Pages Box
$this->pages = $this->data->getPages();
$this->template->page->pages_box = $this->add_view('pages_box');
$this->template->page->pages_box->pages = $this->pages;
// Icon Box
$this->template->page->icon_box = $this->add_view('icon_box');
$this->template->page->icon_box->position = "basket";
}else{
url::redirect("start", 302);
}
}
}

View File

@@ -0,0 +1,280 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* PDF controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Pdf_Controller extends System_Controller {
public function __construct(){
parent::__construct();
$this->use_bg = 0;
$this->bg = $this->config->conf['background_pdf'];
$this->pdf_page_size = $this->config->conf['pdf_page_size'];
$this->pdf_margin_left = $this->config->conf['pdf_margin_left'];
$this->pdf_margin_top = $this->config->conf['pdf_margin_top'];
$this->pdf_margin_right = $this->config->conf['pdf_margin_right'];
// Define PDF background per url option
if(isset($this->bg) && $this->bg != ""){
if( is_readable( Kohana::config( 'core.pnp_etc_path')."/".$this->bg ) ){
$this->bg = Kohana::config('core.pnp_etc_path')."/".$this->bg;
}else{
$this->bg = $this->config->conf['background_pdf'];
}
}
// Use PDF background if readable
if(is_readable($this->bg)){
$this->use_bg = 1;
}
}
public function index(){
$this->tpl = pnp::clean($this->input->get('tpl'));
$this->type = "normal";
$this->data->getTimeRange($this->start,$this->end,$this->view);
// Service Details
if($this->host != "" && $this->service != ""){
$this->data->buildDataStruct($this->host,$this->service,$this->view);
// Host Overview
}elseif($this->host != ""){
if($this->view == ""){
$this->view = $this->config->conf['overview-range'];
}
$services = $this->data->getServices($this->host);
foreach($services as $service){
if($service['state'] == 'active')
$this->data->buildDataStruct($this->host,$service['name'],$this->view);
}
// Special Templates
}elseif($this->tpl != ""){
$this->data->buildDataStruct('__special',$this->tpl,$this->view);
$this->type = 'special';
}else{
$this->host = $this->data->getFirstHost();
if(isset($this->host)){
url::redirect("/graph?host=$this->host");
}else{
throw new Kohana_User_Exception('Hostname not set ;-)', "RTFM my Friend, RTFM!");
}
}
#throw new Kohana_Exception(print_r($this->data->STRUCT,TRUE));
/*
* PDF Output
*/
$pdf = new PDF("P", "mm", $this->pdf_page_size);
$pdf->AliasNbPages();
$pdf->SetAutoPageBreak('off');
$pdf->SetMargins($this->pdf_margin_left,$this->pdf_margin_top,$this->pdf_margin_right);
$pdf->AddPage();
if($this->use_bg){
$pdf->setSourceFile($this->bg);
$tplIdx = $pdf->importPage(1,'/MediaBox');
$pdf->useTemplate($tplIdx);
}
$pdf->SetCreator('Created with PNP');
$pdf->SetFont('Arial', '', 10);
// Title
$header = TRUE;
foreach($this->data->STRUCT as $key=>$data){
if($key != 0){
$header = FALSE;
}
if ($pdf->GetY() > 200) {
$pdf->AddPage();
if($this->use_bg){$pdf->useTemplate($tplIdx);}
}
if($this->type == 'normal'){
if($data['LEVEL'] == 0){
$pdf->SetFont('Arial', '', 12);
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME']." -- ".$data['MACRO']['DISP_SERVICEDESC'], 0, 1);
$pdf->SetFont('Arial', '', 10);
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
$pdf->SetFont('Arial', '', 8);
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
}else{
$pdf->SetFont('Arial', '', 8);
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
}
}elseif($this->type == 'special'){
if($header){
$pdf->SetFont('Arial', '', 12);
$pdf->CELL(120, 10, $data['MACRO']['TITLE'], 0, 1);
$pdf->SetFont('Arial', '', 10);
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
$pdf->SetFont('Arial', '', 8);
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
}else{
$pdf->SetFont('Arial', '', 10);
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
$pdf->SetFont('Arial', '', 8);
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
}
}
$image = $this->rrdtool->doImage($data['RRD_CALL'],$out='PDF');
$img = $this->rrdtool->saveImage($image);
$Y = $pdf->GetY();
$cell_height = ($img['height'] * 0.23);
$cell_width = ($img['width'] * 0.23);
$pdf->Image($img['file'], $this->pdf_margin_left, $Y, $cell_width, $cell_height, 'PNG');
$pdf->CELL(120, $cell_height, '', 0, 1);
unlink($img['file']);
}
$pdf->Output("pnp4nagios.pdf","I");
}
public function page($page){
$this->start = $this->input->get('start');
$this->end = $this->input->get('end');
$this->view = "";
if(isset($_GET['view']) && $_GET['view'] != "" ){
$this->view = pnp::clean($_GET['view']);
}
$this->data->getTimeRange($this->start,$this->end,$this->view);
$this->data->buildPageStruct($page,$this->view);
// Define PDF background per url option
if(isset($this->data->PAGE_DEF['background_pdf'])){
if( is_readable( Kohana::config( 'core.pnp_etc_path')."/".$this->data->PAGE_DEF['background_pdf'] ) ){
$this->bg = Kohana::config('core.pnp_etc_path')."/".$this->data->PAGE_DEF['background_pdf'];
}
}
/*
* PDF Output
*/
$pdf = new PDF("P", "mm", $this->pdf_page_size);
$pdf->AliasNbPages();
$pdf->SetAutoPageBreak('off');
$pdf->SetMargins($this->pdf_margin_left,$this->pdf_margin_top,$this->pdf_margin_right);
$pdf->AddPage();
if($this->use_bg){
$pdf->setSourceFile($this->bg);
$tplIdx = $pdf->importPage(1,'/MediaBox');
$pdf->useTemplate($tplIdx);
}
$pdf->SetCreator('Created with PNP');
$pdf->SetFont('Arial', '', 10);
// Title
foreach($this->data->STRUCT as $data){
if ($pdf->GetY() > 200) {
$pdf->AddPage();
if($this->use_bg){$pdf->useTemplate($tplIdx);}
}
if($data['LEVEL'] == 0){
$pdf->SetFont('Arial', '', 12);
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME']." -- ".$data['MACRO']['DISP_SERVICEDESC'], 0, 1);
$pdf->SetFont('Arial', '', 10);
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
$pdf->SetFont('Arial', '', 8);
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
}else{
$pdf->SetFont('Arial', '', 8);
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
}
$image = $this->rrdtool->doImage($data['RRD_CALL'],$out='PDF');
$img = $this->rrdtool->saveImage($image);
$Y = $pdf->GetY();
$cell_height = ($img['height'] * 0.23);
$cell_width = ($img['width'] * 0.23);
$pdf->Image($img['file'], $this->pdf_margin_left, $Y, $cell_width, $cell_height, 'PNG');
$pdf->CELL(120, $cell_height, '', 0, 1);
unlink($img['file']);
}
$pdf->Output("pnp4nagios.pdf","I");
}
public function basket(){
$this->start = $this->input->get('start');
$this->end = $this->input->get('end');
$this->view = "";
if(isset($_GET['view']) && $_GET['view'] != "" ){
$this->view = pnp::clean($_GET['view']);
}
$this->data->getTimeRange($this->start,$this->end,$this->view);
$basket = $this->session->get("basket");
if(is_array($basket) && sizeof($basket) > 0){
$this->data->buildBasketStruct($basket,$this->view);
}
//echo Kohana::debug($this->data->STRUCT);
/*
* PDF Output
*/
$pdf = new PDF("P", "mm", $this->pdf_page_size);
$pdf->AliasNbPages();
$pdf->SetAutoPageBreak('off');
$pdf->SetMargins($this->pdf_margin_left,$this->pdf_margin_top,$this->pdf_margin_right);
$pdf->AddPage();
if($this->use_bg){
$pdf->setSourceFile($this->config->conf['background_pdf']);
$tplIdx = $pdf->importPage(1,'/MediaBox');
$pdf->useTemplate($tplIdx);
}
$pdf->SetCreator('Created with PNP');
$pdf->SetFont('Arial', '', 10);
// Title
foreach($this->data->STRUCT as $data){
if ($pdf->GetY() > 200) {
$pdf->AddPage();
if($this->use_bg){$pdf->useTemplate($tplIdx);}
}
if($data['LEVEL'] == 0){
$pdf->SetFont('Arial', '', 12);
$pdf->CELL(120, 10, $data['MACRO']['DISP_HOSTNAME']." -- ".$data['MACRO']['DISP_SERVICEDESC'], 0, 1);
$pdf->SetFont('Arial', '', 10);
$pdf->CELL(120, 5, $data['TIMERANGE']['title']." (".$data['TIMERANGE']['f_start']." - ".$data['TIMERANGE']['f_end'].")", 0, 1);
$pdf->SetFont('Arial', '', 8);
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
}else{
$pdf->SetFont('Arial', '', 8);
$pdf->CELL(120, 5, "Datasource ".$data["ds_name"], 0, 1);
}
$image = $this->rrdtool->doImage($data['RRD_CALL'],$out='PDF');
$img = $this->rrdtool->saveImage($image);
$Y = $pdf->GetY();
$cell_height = ($img['height'] * 0.23);
$cell_width = ($img['width'] * 0.23);
$pdf->Image($img['file'], $this->pdf_margin_left, $Y, $cell_width, $cell_height, 'PNG');
$pdf->CELL(120, $cell_height, '', 0, 1);
unlink($img['file']);
}
$pdf->Output("pnp4nagios.pdf","I");
}
}
/*
+
*
*/
require Kohana::find_file('vendor/fpdf', 'fpdf');
require Kohana::find_file('vendor/fpdf', 'fpdi');
class PDF extends FPDI {
//Page header
function Header() {
//Arial bold 10
$this->SetFont('Arial', 'B', 10);
}
//Page footer
function Footer() {
//Position at 1.5 cm from bottom
$this->SetY(-20);
//Arial italic 8
$this->SetFont('Arial', 'I', 8);
//Page number
$this->Cell(0, 10, $this->PageNo() . '/{nb}', 0, 0, 'C');
}
}

View File

@@ -0,0 +1,41 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Popup controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Popup_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->template = $this->add_view('popup');
}
public function index()
{
if ( $this->view == "" ){
$this->view = $this->config->conf['overview-range'];
}
$this->imgwidth = pnp::clean($this->input->get('width',$this->config->conf['popup-width']));
$this->data->getTimeRange($this->start,$this->end,$this->view);
if(isset($this->host) && isset($this->service)){
$this->data->buildDataStruct($this->host,$this->service,$this->view,$this->source);
$this->template->host = $this->host;
$this->template->srv = $this->service;
$this->template->view = $this->view;
$this->template->source = $this->source;
$this->template->end = $this->end;
$this->template->start = $this->start;
$this->template->imgwidth = $this->imgwidth;
}else{
url::redirect("/graph");
}
}
}

View File

@@ -0,0 +1,52 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Graph controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Special_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->template = $this->add_view('template');
$this->template->graph = $this->add_view('graph');
$this->templates = $this->data->getSpecialTemplates();
$this->data->GRAPH_TYPE = 'special';
if($this->tpl == ''){
if($this->templates)
$this->tpl = $this->templates[0];
url::redirect('special?tpl='.$this->tpl, 302);
}
}
public function index(){
$this->url = "?tpl=".$this->tpl;
$this->template->zoom_header = $this->add_view('zoom_header');
$this->template->zoom_header->graph_width = ($this->config->conf['graph_width'] + 140);
$this->template->zoom_header->graph_height = ($this->config->conf['graph_height'] + 230);
$this->template->graph->graph_content = $this->add_view('graph_content_special');
$this->template->graph->graph_content->graph_width = ($this->config->conf['graph_width'] + 85);
$this->template->graph->graph_content->timerange_select = $this->add_view('timerange_select');
$this->template->graph->header = $this->add_view('header');
$this->template->graph->search_box = $this->add_view('search_box');
$this->template->graph->service_box = $this->add_view('special_templates_box');
#$this->template->graph->status_box = $this->add_view('status_box');
#$this->template->graph->basket_box = $this->add_view('basket_box');
$this->template->graph->widget_menu = $this->add_view('widget_menu');
$this->template->graph->graph_content->widget_graph = $this->add_view('widget_graph');
#print Kohana::debug($services);
$this->data->buildDataStruct('__special',$this->tpl,$this->view);
$this->template->graph->icon_box = $this->add_view('icon_box');
$this->template->graph->icon_box->position = "special";
$this->template->graph->logo_box = $this->add_view('logo_box');
// Timerange Box Vars
$this->template->graph->timerange_box = $this->add_view('timerange_box');
$this->template->graph->timerange_box->timeranges = $this->data->TIMERANGE;
$this->template->graph->header->title = $this->data->MACRO['TITLE'];
//print Kohana::debug($this->data);
}
}

View File

@@ -0,0 +1,21 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Default controller.
*
* @package pnp4nagios
* @author Joerg Linge
* @license GPL
*/
class Start_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
url::redirect("graph", 302);
}
}

View File

@@ -0,0 +1,210 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* system controller.
*
* @package pnp4nagios
* @author Joerg Linge
* @license GPL
*/
class System_Controller extends Template_Controller {
public function __construct()
{
parent::__construct();
$this->data = new Data_Model();
$this->config = new Config_Model();
$this->rrdtool = new Rrdtool_Model();
$this->auth = new Auth_Model();
#$this->system = new System_Model();
$this->config->read_config();
Kohana::config_set('locale.language',$this->config->conf['lang']);
// Check for mod_rewrite
$this->check_mod_rewrite();
$this->start = pnp::clean($this->input->get('start',FALSE));
$this->end = pnp::clean($this->input->get('end',FALSE));
$this->theme = pnp::clean($this->input->get('theme',FALSE));
$this->view = pnp::clean($this->input->get('view', ""));
$this->host = pnp::clean($this->input->get('host',NULL));
$this->service = pnp::clean($this->input->get('srv',NULL));
$this->source = pnp::clean($this->input->get('source',0));
$this->version = pnp::clean($this->input->get('version',NULL));
$this->tpl = pnp::clean($this->input->get('tpl'));
$this->controller = Router::$controller;
$this->data->getTimeRange($this->start,$this->end,$this->view);
if(Router::$controller != "image" && Router::$controller != "image_special"){
$this->session = Session::instance();
# Session withou theme info
if($this->session->get("theme","new") == "new"){
if($this->theme){
# store $this->theme if available
Kohana::config_set('core.theme',$this->theme);
$this->session->set('theme', $this->theme );
}else{
# set $this->theme to default value
$this->theme = $this->config->conf['ui-theme'];
Kohana::config_set('core.theme',$this->theme);
}
# Sesion with theme info
}else{
if($this->theme && $this->theme != 'default'){
# store $this->theme if available
$this->session->set('theme', $this->theme );
Kohana::config_set('core.theme',$this->theme);
}elseif($this->theme == 'default'){
# reset to default theme
$this->theme = $this->config->conf['ui-theme'];
$this->session->set('theme', $this->theme );
Kohana::config_set('core.theme',$this->theme);
}else{
# set $this->theme with session infos
$this->theme = $this->session->get('theme');
Kohana::config_set('core.theme',$this->theme);
}
}
if($this->start && $this->end ){
if($this->session->get('timerange-reset',0) == 0){
$this->session->set("start", $this->start);
$this->session->set("end", $this->end);
}else{
$this->session->set('timerange-reset', 0);
}
}
if($this->start && !$this->end){
if($this->session->get('timerange-reset',0) == 0){
$this->session->set("start", $this->start);
$this->session->set("end", "");
}else{
$this->session->set('timerange-reset', 0);
}
}
if($this->end && !$this->start){
if($this->session->get('timerange-reset',0) == 0){
$this->session->set("end", $this->end);
$this->session->set("start", "");
}else{
$this->session->set('timerange-reset', 0);
}
}
}
}
public function __call($method, $arguments)
{
// Disable auto-rendering
$this->auto_render = FALSE;
// By defining a __call method, all pages routed to this controller
// that result in 404 errors will be handled by this method, instead of
// being displayed as "Page Not Found" errors.
echo $this->_("The requested page doesn't exist") . " ($method)";
}
/**
* Handle paths to current theme etc
*
*/
public function add_view($view=false)
{
$view = trim($view);
if (empty($view)) {
return false;
}
if (!file_exists(APPPATH."/views/".$view.".php")) {
return false;
}
#return new View($this->theme_path.$view);
return new View($view);
}
public function check_mod_rewrite(){
if(!function_exists('apache_get_modules')){
// Add index.php to every URL while not running withn apache mod_php
Kohana::config_set('core.index_page','index.php');
return TRUE;
}
if(!in_array('mod_rewrite', apache_get_modules())){
// Add index.php to every URL while mod_rewrite is not available
Kohana::config_set('core.index_page','index.php');
}
if ( $this->config->conf['use_url_rewriting'] == 0 ){
Kohana::config_set('core.index_page','index.php');
}
}
public function isAuthorizedFor($auth) {
$conf = $this->config->conf;
if ($auth == "service_links") {
$users = explode(",", $conf['allowed_for_service_links']);
if (in_array('EVERYONE', $users)) {
return 1;
}
elseif (in_array('NONE', $users)) {
return 0;
}
elseif (in_array($this->auth->REMOTE_USER, $users)) {
return 1;
} else {
return 0;
}
}
if ($auth == "host_search") {
$users = explode(",", $conf['allowed_for_host_search']);
if (in_array('EVERYONE', $users)) {
return 1;
}
elseif (in_array('NONE', $users)) {
return 0;
}
elseif (in_array($this->auth->REMOTE_USER, $users)) {
return 1;
} else {
return 0;
}
}
if ($auth == "host_overview") {
$users = explode(",", $conf['allowed_for_host_overview']);
if (in_array('EVERYONE', $users)) {
return 1;
}
elseif (in_array('NONE', $users)) {
return 0;
}
elseif (in_array($this->auth->REMOTE_USER, $users)) {
return 1;
} else {
return 0;
}
}
if ($auth == "pages") {
$users = explode(",", $conf['allowed_for_pages']);
if (in_array('EVERYONE', $users)) {
return 1;
}
elseif (in_array('NONE', $users)) {
return 0;
}
elseif (in_array($this->auth->REMOTE_USER, $users)) {
return 1;
} else {
return 0;
}
}
}
public function isMobileDevice (){
if( $this->session->get('classic-ui',0) == 1){
return FALSE;
}
if ( preg_match('/'.$this->config->conf['mobile_devices'].'/', $_SERVER['HTTP_USER_AGENT'] ) ){
return TRUE;
}else{
return FALSE;
}
}
}

View File

@@ -0,0 +1,48 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Xml controller.
*
* @package PNP4Nagios
* @author Jorg Linge
* @license GPL
*/
class Xml_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->config->read_config();
}
public function index()
{
$this->auto_render = FALSE;
if($this->service == "" && $this->host == ""){
url::redirect("graph", 302);
}
$this->data->readXML($this->host, $this->service);
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
header('Content-Type: application/xml');
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
print "<NAGIOS>\n";
print "<ERROR>not authorized</ERROR>\n";
print "</NAGIOS>\n";
exit;
}else{
$xmlfile = $this->config->conf['rrdbase'].$this->host."/".$this->service.".xml";
if(is_readable($xmlfile)){
$fh = fopen($xmlfile, 'r');
header('Content-Type: application/xml');
fpassthru($fh);
fclose($fh);
exit;
}else{
header('Content-Type: application/xml');
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
print "<NAGIOS>\n";
print "<ERROR>file not found</ERROR>\n";
print "</NAGIOS>\n";
}
}
}
}

View File

@@ -0,0 +1,74 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Xport controller.
*
* @package pnp4nagios
* @author Joerg Linge
* @license GPL
*/
class Xport_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
// Disable auto-rendering
$this->auto_render = FALSE;
$this->data->getTimeRange($this->start,$this->end,$this->view);
}
public function xml(){
if(isset($this->host) && isset($this->service)){
$this->data->buildXport($this->host,$this->service);
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
header('Content-Type: application/xml');
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
print "<NAGIOS>\n";
print "<ERROR>not authorized</ERROR>\n";
print "</NAGIOS>\n";
exit;
}
$data = $this->rrdtool->doXport($this->data->XPORT);
header('Content-Type: application/xml');
print $data;
}else{
throw new Kohana_Exception('error.xport-host-service');
}
}
public function json(){
if(isset($this->host) && isset($this->service)){
$this->data->buildXport($this->host,$this->service);
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
header('Content-type: application/json');
print json_encode("not authorized");
exit;
}
$data = $this->rrdtool->doXport($this->data->XPORT);
$json = json_encode(simplexml_load_string($data));
header('Content-type: application/json');
print $json;
}else{
throw new Kohana_Exception('error.xport-host-service');
}
}
public function csv(){
if(isset($this->host) && isset($this->service)){
$this->data->buildXport($this->host,$this->service);
if($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE){
header("Content-Type: text/plain; charset=UTF-8");
print "not authorized";
exit;
}
$data = $this->rrdtool->doXport($this->data->XPORT);
$csv = $this->data->xml2csv($data);
header("Content-Type: text/plain; charset=UTF-8");
print $csv;
}else{
throw new Kohana_Exception('error.xport-host-service');
}
}
}

View File

@@ -0,0 +1,80 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Zoom controller.
*
* @package PNP4Nagios
* @author Joerg Linge
* @license GPL
*/
class Zoom_Controller extends System_Controller {
public function __construct()
{
parent::__construct();
$this->template = $this->add_view('zoom');
#$this->tpl = $this->input->get('tpl');
$this->graph_width = $this->config->conf['zgraph_width'];
$this->graph_height = $this->config->conf['zgraph_height'];
}
public function index()
{
#$this->source = intval($this->input->get('source'));
#$this->view = "";
#if(isset($_GET['view']) && $_GET['view'] != "" ){
# $this->view = pnp::clean($_GET['view']);
#}else{
# $this->view = $this->config->conf['overview-range'];
#}
#
# Limit startto 2000/01/01
#
$start_limit = strtotime("2000/01/01");
$this->start = abs((int)$this->start);
if($this->start < $start_limit)
$this->start = $start_limit;
#
# Limit end to now + one hour
#
$end_limit = time() + 3600;
$this->end = abs((int)$this->end);
if($this->end > $end_limit)
$this->end = $end_limit;
$this->data->getTimeRange($this->start,$this->end,$this->view);
if(isset($this->tpl) && $this->tpl != 'undefined' ){
if($this->start && $this->end ){
$this->session->set("start", $this->start);
$this->session->set("end", $this->end);
}
$this->template->tpl = $this->tpl;
$this->template->view = $this->view;
$this->template->source = $this->source;
$this->template->end = $this->end;
$this->template->start = $this->start;
$this->url = "?tpl=".$this->tpl;
$this->template->graph_height = $this->graph_height;
$this->template->graph_width = $this->graph_width;
}elseif(isset($this->host) && isset($this->service)){
if($this->start && $this->end ){
$this->session->set("start", $this->start);
$this->session->set("end", $this->end);
}
$this->template->host = $this->host;
$this->template->srv = $this->service;
$this->template->view = $this->view;
$this->template->source = $this->source;
$this->template->end = $this->end;
$this->template->start = $this->start;
$this->url = "?host=".$this->host."&srv=".$this->service;
$this->template->graph_height = $this->graph_height;
$this->template->graph_width = $this->graph_width;
}else{
url::redirect("/graph");
}
}
}

View File

@@ -0,0 +1,58 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
*
*
*/
class nagios_Core {
public static function SummaryLink($hostname,$start,$end){
$config = new Config_Model();
$config->read_config();
$smon = date('m' , $start);
$sday = date('d' , $start);
$syear = date('Y' , $start);
$shour = date('G' , $start);
$smin = date('i' , $start);
$ssec = date('s' , $start);
$emon = date('m' , $end);
$eday = date('d' , $end);
$eyear = date('Y' , $end);
$ehour = date('G' , $end);
$emin = date('i' , $end);
$esec = date('s' , $end);
$nagios_base = $config->conf['nagios_base'];
print "<a href=\"$nagios_base/summary.cgi?report=1&displaytype=1&timeperiod=custom&smon=$smon&sday=$sday&syear=$syear&shour=$shour&smin=$smin&ssec=$ssec&emon=$emon&eday=$eday&eyear=$eyear&ehour=$ehour&emin=$emin&esec=$esec&hostgroup=all&servicegroup=all&host=$hostname&alerttypes=3&statetypes=3&hoststates=7&servicestates=120&limit=999\"";
print " title=\"".Kohana::lang('common.nagios-summary-link-title')."\"><img src=\"".url::base()."media/images/notify.gif\"></a>\n";
}
public static function AvailLink($hostname,$servicedesc,$start,$end){
$config = new Config_Model();
$config->read_config();
$hostname = urlencode($hostname);
$servicedesc = urlencode($servicedesc);
$smon = date('m' , $start);
$sday = date('d' , $start);
$syear = date('Y' , $start);
$shour = date('G' , $start);
$smin = date('i' , $start);
$ssec = date('s' , $start);
$emon = date('m' , $end);
$eday = date('d' , $end);
$eyear = date('Y' , $end);
$ehour = date('G' , $end);
$emin = date('i' , $end);
$esec = date('s' , $end);
$nagios_base = $config->conf['nagios_base'];
if($servicedesc == "Host+Perfdata"){
print "<a href=\"$nagios_base/avail.cgi?show_log_entries=&host=$hostname&timeperiod=custom&smon=$smon&sday=$sday&syear=$syear&shour=$shour&smin=$smin&ssec=$ssec&emon=$emon&eday=$eday&eyear=$eyear&ehour=$ehour&emin=$emin&esec=$esec&rpttimeperiod=&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringnotrunning=yes&includesoftstates=yes&initialassumedservicestate=6&backtrack=4\"";
}else{
print "<a href=\"$nagios_base/avail.cgi?show_log_entries=&host=$hostname&service=$servicedesc&timeperiod=custom&smon=$smon&sday=$sday&syear=$syear&shour=$shour&smin=$smin&ssec=$ssec&emon=$emon&eday=$eday&eyear=$eyear&ehour=$ehour&emin=$emin&esec=$esec&rpttimeperiod=&assumeinitialstates=yes&assumestateretention=yes&assumestatesduringnotrunning=yes&includesoftstates=yes&initialassumedservicestate=6&backtrack=4\"";
}
print " title=\"".Kohana::lang('common.nagios-avail-link-title')."\"><img src=\"".url::base()."media/images/trends.gif\" ></a>\n";
}
}

View File

@@ -0,0 +1,150 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
*
*
*/
class pnp_Core {
public static function clean($string = FALSE){
if($string === FALSE){
return;
}
if($string == ""){
return $string;
}
$string = preg_replace('/[ :\/\\\]/', "_", $string);
$string = htmlspecialchars($string);
return $string;
}
public static function shorten($string = FALSE, $length = 25){
if($string === FALSE){
return;
}
if(strlen($string) > $length){
$string = substr($string, 0, $length) . "...";
}
return $string;
}
/*
*
*/
public static function xml_version_check($string = FALSE){
if($string === FALSE){
return FALSE;
}
if( $string == XML_STRUCTURE_VERSION ){
$string = "valid";
}else{
$string = Kohana::lang('error.xml-structure-mismatch', $string, XML_STRUCTURE_VERSION);
}
return $string;
}
/*
*
*/
public static function zoom_icon($host,$service,$start,$end,$source,$view,$graph_width,$graph_height){
print "<a href=\"javascript:Gzoom('".url::base(TRUE)."zoom?host=$host&srv=$service&view=$view&source=$source&end=$end&start=$start&graph_width=$graph_width&graph_height=$graph_height');\" title=\"Zoom into the Graph\"><img src=\"".url::base()."media/images/zoom.png\"></a>\n";
}
/*
*
*/
public static function zoom_icon_special($tpl,$start,$end,$source,$view,$graph_width,$graph_height){
print "<a href=\"javascript:Gzoom('".url::base(TRUE)."zoom?tpl=$tpl&view=$view&source=$source&end=$end&start=$start&graph_width=$graph_width&graph_height=$graph_height');\" title=\"Zoom into the Graph\"><img src=\"".url::base()."media/images/zoom.png\"></a>\n";
}
/*
*
*/
public static function add_to_basket_icon($host,$service,$source=FALSE){
if($source === FALSE){
print "<span id=\"basket_action_add\"><a title=\"".Kohana::lang('common.basket-add-service')."\" id=\"".$host."::".$service."\"><img width=12px height=12px src=\"".url::base()."media/images/add.png\"></a></span>\n";
}else{
print "<span id=\"basket_action_add\"><a title=\"".Kohana::lang('common.basket-add-item')."\" id=\"".$host."::".$service."::".$source."\"><img width=16px height=16px src=\"".url::base()."media/images/add.png\"></a></span>\n";
}
}
/*
*
*/
public static function multisite_link($base_url=FALSE,$site=FALSE,$host=FALSE,$service=FALSE){
if($host && $service){
$link = sprintf("'%s/view.py?view_name=service&site=%s&host=%s&service=%s'", $base_url,$site,urlencode($host),urlencode($service));
return $link;
}
if($host){
$link = sprintf("'%s/view.py?view_name=host&site=%s&host=%s'", $base_url,$site,urlencode($host));
return $link;
}
}
public static function addToUri($fields = array(),$base = True){
if(!is_array($fields)){
return false;
}
$get = $_GET;
if($base === True){
$uri = url::base(TRUE);
$uri .= Router::$current_uri;
}else{
$uri = "";
}
$uri .= '?';
foreach($fields as $key=>$value){
$get[$key] = $value;
}
foreach($get as $key=>$value){
if($value === ''){
continue;
}
$uri .= $key."=".urlencode($value)."&";
}
return rtrim($uri,"&");
}
/* "normalize" and adjust value / unit (similar to format string %s in RRDtool)
* Parameters in:
* value := number, maybe suffixed by unit string
* examples: 1234, 1.234, 1234M, 1234Kb
* base := base of value (1000, e.g. traffic or 1024, e.g. disk size)
* format := format string
* Parameters out:
* val_unit := formatted value (including unit)
* val_fmt := formatted value (without leading blanks and unit)
* unit := adjusted unit
* divisor := number used to "normalize" value
*/
public static function adjust_unit($value,$base=1000,$format='%.3lf'){
preg_match('/^(-?[0-9\.,]+)\s*(\S?)(\S?)/',$value,$matches);
$mag = 0;
while ($value >= $base){
$value /= $base;
$mag++;
}
$pos = 0;
if ($matches[2] == "%") {
$unit = '%';
} else {
if ($matches[2] == "") {
$matches[2] = " ";
}
if (($matches[2] == "B") or ($matches[2] == "b")) {
$matches[3] = $matches[2];
$matches[2] = " ";
}
$pos = strpos(' KMGTP',strtoupper($matches[2]));
$unit = substr(' KMGTP',$mag+$pos,1).$matches[3];
}
$val_unit = sprintf ("$format %s", $value, $unit);
$val_fmt = sprintf ($format, $value);
$val_fmt = str_replace(' ','',$val_fmt);
return array ($val_unit,$val_fmt,$unit,pow($base,$mag));
}
public static function print_version(){
return PNP_NAME . "-" . PNP_VERSION . " [ " . PNP_REL_DATE . " ]";
}
}

View File

@@ -0,0 +1,459 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/*
*
* RRDTool Helper Class
*/
class rrd_Core {
public static function color_inverse($color){
$color = str_replace('#', '', $color);
if (strlen($color) != 6){ return '000000'; }
$rgb = '';
for ($x=0;$x<3;$x++){
$c = 255 - hexdec(substr($color,(2*$x),2));
$c = ($c < 0) ? 0 : dechex($c);
$rgb .= (strlen($c) < 2) ? '0'.$c : $c;
}
return '#'.$rgb;
}
/*
* Color Function
* Concept by Stefan Triep
*/
public static function color($num=0 , $alpha='FF', $scheme=''){
$colors = array();
$value = array('cc','ff','99','66');
$num = intval($num);
# check if colour scheme entry exists
# fall back to old method if not found
if ( isset( $scheme["$num"] ) ){
$color = $scheme["$num"] . $alpha;
return $color;
}
foreach($value as $ri){
for ($z=1;$z<8;$z++) {
$color = "#";
if ( ($z & 4) >= 1 ){
$color .= "$ri";
} else {
$color .= "00";
}
if ( ($z & 2) >= 1 ){
$color .= "$ri";
} else {
$color .= "00";
}
if ( ($z & 1) >= 1 ){
$color .= "$ri";
} else {
$color .= "00";
}
$icolor = rrd::color_inverse($color);
$pos = array_search($color,$colors);
$ipos = array_search($icolor,$colors);
if ( $pos == false ) {
$colors[] = $color . $alpha;
}
if ( $ipos == false ) {
$colors[] = $icolor . $alpha;
}
}
}
if (array_key_exists($num, $colors)) {
return $colors[$num];
} else {
return $colors[0];
}
}
/*
* Gradient Function
* Concept by Stefan Triep
*/
public static function gradient($vname=FALSE, $start_color='#0000a0', $end_color='#f0f0f0', $label=FALSE, $steps=20, $lower=FALSE){
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if(preg_match('/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i',$start_color,$matches)){
$r1=hexdec($matches[1]);
$g1=hexdec($matches[2]);
$b1=hexdec($matches[3]);
}else{
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Wrong Color Format: '".$start_color."'");
}
if(preg_match('/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i',$end_color,$matches)){
$r2=hexdec($matches[1]);
$g2=hexdec($matches[2]);
$b2=hexdec($matches[3]);
}else{
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Wrong Color Format: '".$end_color."'");
}
$diff_r=$r2-$r1;
$diff_g=$g2-$g1;
$diff_b=$b2-$b1;
$spline = "";
$spline_vname = "var".substr(sha1(rand()),1,4);
if(preg_match('/^([0-9]{1,3})%$/', $lower, $matches)){
if($matches[1] > 100)
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Lower gradient start > 100% is not allowed: '".$lower."'");
$lower = $matches[1];
$spline .= sprintf("CDEF:%sminimum=%s,100,/,%d,* ", $vname, $vname, $lower);
}elseif(preg_match('/^([0-9]+)$/', $lower, $matches)){
$lower = $matches[1];
$spline .= sprintf("CDEF:%sminimum=%s,%d,- ", $vname, $vname, $lower);
}else{
$lower = 0;
$spline .= sprintf("CDEF:%sminimum=%s,%s,- ", $vname, $vname, $vname);
}
# debug
# $spline .= sprintf("GPRINT:%sminimum:MAX:\"minumum %%lf\\n\" ",$vname);
for ($i=$steps; $i>0; $i--){
$spline .= sprintf("CDEF:%s%d=%s,%sminimum,-,%d,/,%d,*,%sminimum,+ ",$spline_vname,$i,$vname,$vname,$steps,$i,$vname );
# debug
# $spline .= sprintf("GPRINT:%s%d:MAX:\"%22d %%lf\\n\" ",$spline_vname,$i,$i);
}
for ($i=$steps; $i>0; $i--){
$factor=$i / $steps;
$r=round($r1 + $diff_r * $factor);
$g=round($g1 + $diff_g * $factor);
$b=round($b1 + $diff_b * $factor);
if (($i==$steps) and ($label!=FALSE)){
$spline .= sprintf("AREA:%s%d#%02X%02X%02X:\"%s\" ", $spline_vname,$i,$r,$g,$b,$label);
}else{
$spline .= sprintf("AREA:%s%d#%02X%02X%02X ", $spline_vname,$i,$r,$g,$b);
}
}
return $spline;
}
public static function cut($string, $length=18, $align='left'){
if(strlen($string) > $length){
$string = substr($string,0,($length-3))."...";
}
if($align == 'left'){
$format = "%-".$length."s";
}else{
$format = "%".$length."s";
}
$s = sprintf($format,$string);
return $s;
}
public static function area($vname=FALSE, $color=FALSE, $text=FALSE, $stack=FALSE){
$line = "";
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}else{
$line .= "AREA:".$vname;
}
if($color === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'color' is missing");
}else{
$line .= $color;
}
$line .= ":\"$text\"";
if($stack != FALSE){
$line .= ":STACK";
}
$line .= " ";
return $line;
}
public static function line($type=1,$vname=FALSE, $color=FALSE, $text=FALSE, $stack=FALSE){
$line = "";
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}else{
$line .= "LINE".$type.":".$vname;
}
if($color === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'color' is missing");
}else{
$line .= $color;
}
$line .= ":\"$text\"";
if($stack != FALSE){
$line .= ":STACK";
}
$line .= " ";
return $line;
}
public static function line1($vname=FALSE, $color=FALSE, $text=FALSE, $stack=FALSE){
return rrd::line(1,$vname, $color,$text, $stack);
}
public static function line2($vname=FALSE, $color=FALSE, $text=FALSE, $stack=FALSE){
return rrd::line(2,$vname, $color,$text, $stack);
}
public static function line3($vname=FALSE, $color=FALSE, $text=FALSE, $stack=FALSE){
return rrd::line(3,$vname, $color,$text, $stack);
}
public static function gprint($vname=FALSE, $cf="AVERAGE", $text="%6.2lf %s"){
$line = "";
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if(is_array($cf)){
foreach($cf as $key => $val){
$line .= sprintf("GPRINT:%s:%s:",$vname,$val);
if($key == sizeof($cf)-1){
$line .= '"'.$text.' '.ucfirst(strtolower($val)).'\\l" ';
}else{
$line .= '"'.$text.' '.ucfirst(strtolower($val)).'" ';
}
}
}else{
$line .= sprintf("GPRINT:%s:%s:",$vname,$cf);
$line .= '"'.$text.'" ';
}
return $line;
}
/*
* Function to modify alignment of gprint
*/
public static function gprinta($vname=FALSE, $cf="AVERAGE", $text="%6.2lf %s", $align=""){
$line = "";
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if($align != ""){
$align = '\\' . $align;
}
if(is_array($cf)){
foreach($cf as $key => $val){
$line .= sprintf("GPRINT:%s:%s:",$vname,$val);
if(($key == sizeof($cf)-1)and($align != "")){
$line .= '"'.$text.' '.ucfirst(strtolower($val)).$align.'" ';
}else{
$line .= '"'.$text.' '.ucfirst(strtolower($val)).'" ';
}
}
}else{
$line .= sprintf("GPRINT:%s:%s:",$vname,$cf);
$line .= '"'.$text.'" ';
}
return $line;
}
public static function def($vname=FALSE, $rrdfile=FALSE, $ds=FALSE, $cf="AVERAGE"){
$line = "";
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if($rrdfile === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'rrdfile' is missing");
}
if($rrdfile === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Third Parameter 'ds' is missing");
}
$line = sprintf("DEF:%s=%s:%s:%s ",$vname,$rrdfile,$ds,$cf);
return $line;
}
public static function cdef($vname=FALSE, $rpn=FALSE){
$line = "";
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if($rpn === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'rpn' is missing");
}
$line = sprintf("CDEF:%s=%s ",$vname,$rpn);
return $line;
}
public static function vdef($vname=FALSE, $rpn=FALSE){
$line = "";
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if($rpn === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'rpn' is missing");
}
$line = sprintf("VDEF:%s=%s ",$vname,$rpn);
return $line;
}
public static function hrule($value=FALSE, $color=FALSE, $text=FALSE){
$line = "";
if($value === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ ."() First Parameter 'value' is missing");
}
if($color === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'color' is missing");
}
if($value == "~" ) {
return "";
}
$line = sprintf("HRULE:%s%s:\"%s\" ",$value,$color,$text);
return $line;
}
public static function comment($text=FALSE){
$line = sprintf("COMMENT:\"%s\" ", $text);
return $line;
}
public static function tick($vname=FALSE, $color=FALSE, $fraction=FALSE, $label=FALSE){
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'value' is missing");
}
if($color === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'color' is missing");
}
$line = sprintf("TICK:%s%s",$vname,$color);
if($fraction != FALSE)
$line .= ":$fraction";
if($label != FALSE)
$line .= ":$label";
$line .= " ";
return $line;
}
public static function alerter($vname=FALSE, $label=FALSE, $warning=FALSE, $critical=FALSE, $opacity = 'ff', $unit, $color_green = '#00ff00', $color_btw = '#ffff00', $color_red = '#ff0000', $line_col = '#0000ff') {
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if($label === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'label' is missing");
}
if($warning === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Third Parameter 'warning' is missing");
}
if($critical === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Fourth Parameter 'critical' is missing");
}
$line = "";
$green_vname = "var".substr(sha1(rand()),1,4);
$btw_vname = "var".substr(sha1(rand()),1,4);
$blue_vname = "var".substr(sha1(rand()),1,4);
$red_vname = "var".substr(sha1(rand()),1,4);
if($warning < $critical){
$line .= "CDEF:".$green_vname."=".$vname.",".$warning.",LT,".$vname.",UNKN,IF ";
$line .= "CDEF:".$btw_vname."=".$vname.",".$critical.",LT,".$vname.",UNKN,IF ";
$line .= "CDEF:".$blue_vname."=".$btw_vname.",".$warning.",GE,".$btw_vname.",UNKN,IF ";
$line .= "CDEF:".$red_vname."=".$vname.",".$critical.",GE,".$vname.",UNKN,IF ";
} else {
$line .= "CDEF:".$green_vname."=".$vname.",".$warning.",GT,".$vname.",UNKN,IF ";
$line .= "CDEF:".$btw_vname."=".$vname.",".$critical.",GE,".$vname.",UNKN,IF ";
$line .= "CDEF:".$blue_vname."=".$btw_vname.",".$warning.",LE,".$btw_vname.",UNKN,IF ";
$line .= "CDEF:".$red_vname."=".$vname.",".$critical.",LT,".$vname.",UNKN,IF ";
}
$line .= rrd::area($green_vname, $color_green.$opacity);
$line .= rrd::area($blue_vname, $color_btw.$opacity);
$line .= rrd::area($red_vname, $color_red.$opacity);
$line .= rrd::line1($vname,$line_col,$label);
return $line;
}
public static function alerter_gr($vname=FALSE,$label=FALSE,$warning=FALSE,$critical=FALSE,$opacity='ff',$unit,$color_green='#00ff00',$color_btw='#ffff00',$color_red='#ff0000',$line_col='#0000ff',$start_color="#ffffff") {
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if($label === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'label' is missing");
}
if($warning === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Third Parameter 'warning' is missing");
}
if($critical === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Fourth Parameter 'critical' is missing");
}
$line = "";
$green_vname = "var".substr(sha1(rand()),1,4);
$btw_vname = "var".substr(sha1(rand()),1,4);
$blue_vname = "var".substr(sha1(rand()),1,4);
$red_vname = "var".substr(sha1(rand()),1,4);
$line = "";
if($warning < $critical){
$line .= "CDEF:".$green_vname."=".$vname.",".$warning.",LT,".$vname.",UNKN,IF ";
$line .= "CDEF:".$btw_vname."=".$vname.",".$critical.",LT,".$vname.",UNKN,IF ";
$line .= "CDEF:".$blue_vname."=".$btw_vname.",".$warning.",GE,".$btw_vname.",UNKN,IF ";
$line .= "CDEF:".$red_vname."=".$vname.",".$critical.",GE,".$vname.",UNKN,IF ";
} else {
$line .= "CDEF:".$green_vname."=".$vname.",".$warning.",GT,".$vname.",UNKN,IF ";
$line .= "CDEF:".$btw_vname."=".$vname.",".$critical.",GE,".$vname.",UNKN,IF ";
$line .= "CDEF:".$blue_vname."=".$btw_vname.",".$warning.",LE,".$btw_vname.",UNKN,IF ";
$line .= "CDEF:".$red_vname."=".$vname.",".$critical.",LT,".$vname.",UNKN,IF ";
}
$line .= rrd::gradient($green_vname, $start_color, $color_green.$opacity);
$line .= rrd::gradient($blue_vname, $start_color, $color_btw.$opacity);
$line .= rrd::gradient($red_vname, $start_color, $color_red.$opacity);
$line .= rrd::line1($vname,$line_col,$label);
return $line;
}
public static function ticker($vname=FALSE, $warning=FALSE, $critical=FALSE, $fraction = -0.05, $opacity = 'ff', $color_green = '#00ff00', $color_btw = '#ffff00', $color_red = '#ff0000') {
if($vname === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'vname' is missing");
}
if($warning === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'warning' is missing");
}
if($critical === FALSE){
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Third Parameter 'critical' is missing");
}
$line = "";
$green_vname = "var".substr(sha1(rand()),1,4);
$btw_vname = "var".substr(sha1(rand()),1,4);
$blue_vname = "var".substr(sha1(rand()),1,4);
$red_vname = "var".substr(sha1(rand()),1,4);
$green2_vname = "var".substr(sha1(rand()),1,4);
$line .= "CDEF:".$green_vname."=".$vname.",".$warning.",LT,".$vname.",UNKN,IF ";
$line .= "CDEF:".$btw_vname."=".$vname.",".$critical.",LT,".$vname.",UNKN,IF ";
$line .= "CDEF:".$blue_vname."=".$btw_vname.",".$warning.",GE,".$btw_vname.",UNKN,IF ";
$line .= "CDEF:".$red_vname."=".$vname.",".$critical.",GE,".$vname.",UNKN,IF ";
$line .= "CDEF:".$green2_vname."=".$green_vname.",0,EQ,0.000001,".$green_vname.",IF ";
$line .= rrd::tick($green2_vname, $color_green.$opacity, $fraction);
$line .= rrd::tick($blue_vname, $color_btw.$opacity, $fraction);
$line .= rrd::tick($red_vname, $color_red.$opacity, $fraction);
return $line;
}
public static function darkteint(){
$line = '';
$line .= '--color=BACK#000000 ';
$line .= '--color=FONT#F7F7F7 ';
$line .= '--color=SHADEA#ffffff ';
$line .= '--color=SHADEB#ffffff ';
$line .= '--color=CANVAS#000000 ';
$line .= '--color=GRID#00991A ';
$line .= '--color=MGRID#00991A ';
$line .= '--color=ARROW#00FF00 ';
return $line;
}
public static function debug($data=FALSE){
if($data != FALSE){
ob_start();
var_dump($data);
$var_dump = ob_get_contents();
$var_dump = preg_replace('/(HRULE|VDEF|DEF|CDEF|GPRINT|LINE|AREA|COMMENT)/',"\n\${1}", $var_dump);
ob_end_clean();
throw new Kohana_exception("<pre>".$var_dump."</pre>");
}
}
}

View File

@@ -0,0 +1,59 @@
<?php defined('SYSPATH') OR die('kein direkter Zugang erlaubt.');
$lang = array
(
'host' => 'Host: %s',
'service' => 'Service: %s',
'page' => 'Page: %s',
'page-basket' => 'Page: Basket',
'datasource' => 'Datasource: %s',
'zoom-header' => 'Zoom',
'status-box-header' => 'Status',
'multisite-box-header' => 'Multisite Links',
'search-box-header' => 'Suche',
'icon-box-header' => 'Aktionen',
'basket-box-header' => 'Mein Korb',
'timerange-box-header' => 'Zeitbereiche',
'service-box-header' => 'Services',
'special-templates-box-header' => 'Special Templates',
'pages-box-header' => 'Pages',
'nagios-summary-link-title' => 'aktuellste Alarme f&uuml;r diesen Zeitbereich',
'nagios-avail-link-title' => 'Nagios-Ver&uuml;gbarkeitsbericht für diesen Zeitbereich',
'timerange-selector-legend' => 'Auswahl eines Zeitbereichs',
'timerange-selector-title' => 'Auswahl eines Zeitbereichs',
'timerange-selector-submit-button' => 'absenden',
'timerange-selector-clear-button' => 'l&ouml;schen',
'timerange-selector-link' => 'Spezieller Zeitbereich',
'timerange-selector-overview' => '&Uuml;bersicht',
'start' => 'Start',
'end' => 'Ende',
'service-details' => 'Service-Details',
'service-overview' => 'Service-&Uuml;bersicht f&uuml;r "%s"',
'title-pages-link' => 'Pages anzeigen',
'title-pdf-link' => 'PDF anzeigen',
'title-xml-link' => 'XML anzeigen',
'title-statistics-link' => 'Interne PNP Statistiken',
'title-calendar-link' => 'Einen Zeitbereich definieren',
'title-special-templates-link' => 'Spezial Templates anzeigen',
'title-docs-link' => 'Dokumentation',
'title-home-link' => 'Zu den Graphen',
'title-color-link' => 'View Color Schemes',
'docs-home' => 'Home',
'docs-box-header' => 'Menu',
'docs-header' => 'Dokumentation Version %s',
'back' => 'zur&uuml;ck',
'mobile-all-hosts' => 'Alle Hosts',
'mobile-search-hosts' => 'Hosts suchen',
'mobile-pages' => 'Pages anzeigen',
'mobile-special-templates' => 'Special Templates anzeigen',
'mobile-statistics' => 'Interne PNP Statistiken',
'mobile-go-classic' => 'Classic UI',
'mobile-submit' => 'absenden',
'basket-empty' => 'Basket ist leer',
'basket-show' => 'Zeige Basket',
'basket-clear' => 'Leere Basket',
'basket-remove' => 'Entferne %s',
'basket-add-item' => 'Graphen zum Basket hinzuf&uuml;gen',
'basket-add-service' => 'Alle Graphen zum Basket hinzuf&uuml;gen',
'color-box-header' => 'Colors',
'color-header' => 'Colors Schemes',
);

View File

@@ -0,0 +1,32 @@
<?php defined('SYSPATH') OR die('kein direkter Zugang erlaubt.');
$lang = array
(
'rrdtool-not-found' => '"rrdtool"-Binary nicht in %s gefunden. <a href="http://docs.pnp4nagios.org/de/faq/1">FAQ online lesen</a>',
'config-not-found' => 'Config-Datei %s nicht gefunden. <a href="http://docs.pnp4nagios.org/de/faq/2">FAQ online lesen</a>',
'perfdata-dir-empty' => 'Das perfdata-Verzeichnis "%s" ist leer. Bitte die Nagios-Konfiguration prüfen. <a href="http://docs.pnp4nagios.org/de/faq/3">FAQ online lesen</a>',
'host-perfdata-dir-empty' => 'Das perfdata-Verzeichnis "%s" ist leer. Bitte die Nagios-Konfiguration prüfen. <a href="http://docs.pnp4nagios.org/de/faq/4">FAQ online lesen</a>',
'perfdata-dir-for-host' => 'Das perfdata-Verzeichnis "%s" für Host "%s" existiert nicht. <a href="http://docs.pnp4nagios.org/de/faq/5">FAQ online lesen</a>',
'xml-not-found' => 'XML-Datei "%s" nicht gefunden. <a href="http://docs.pnp4nagios.org/de/faq/6">FAQ online lesen</a>',
'get-first-service' => 'Konnte ersten Service für Host "%s" nicht finden. <a href="http://docs.pnp4nagios.org/de/faq/7">FAQ online lesen</a>',
'get-first-host' => 'Keinen Host gefunden. <a href="http://docs.pnp4nagios.org/de/faq/8">FAQ online lesen</a>',
'xml-structure-mismatch' => 'Version der XML-Struktur ungültig. Fand Version "%d", sollte aber "%d" sein. <a href="http://docs.pnp4nagios.org/de/faq/9">FAQ online lesen</a>',
'save-rrd-image' => 'Speichern des Graphen gescheitert. php fopen("%s") failed. <a href="http://docs.pnp4nagios.org/de/faq/10">FAQ online lesen</a>',
'xml-structure-without-version-tag' => 'Versionshinweis fehlt im XML-File. <a href="http://docs.pnp4nagios.org/de/faq/11">FAQ online lesen</a>',
'template-without-opt' => 'Template %s übergibt Array $opt[] nicht. <a href="http://docs.pnp4nagios.org/de/faq/12">FAQ online lesen</a>',
'template-without-def' => 'Template %s übergibt Array $def[] nicht. <a href="http://docs.pnp4nagios.org/de/faq/13">FAQ online lesen</a>',
'no-data-for-page' => 'Keine Daten für die Page "%s", <a href="http://docs.pnp4nagios.org/de/faq/14">FAQ online lesen</a>',
'page-not-readable' => 'Konfigurationsdatei "%s" ist nicht lesbar oder existiert nicht. <a href="http://docs.pnp4nagios.org/de/faq/15">FAQ online lesen</a>',
'auth-pages' => 'Sie sind nicht berechtigt, "Pages" anzusehen <a href="http://docs.pnp4nagios.org/de/faq/16">FAQ online lesen</a>',
'page-config-dir' => 'Keine page-Konfigurationsdatei in "%s" gefunden <a href="http://docs.pnp4nagios.org/de/faq/17">FAQ online lesen</a>',
'xport-host-service' => 'Xport-Controller benötigt "host"- und "srv"-URL-Parameter. <a href="http://docs.pnp4nagios.org/de/faq/18">FAQ online lesen</a>',
'mod-rewrite' => 'Apache Rewrite Module ist nicht aktiviert. <a href="http://docs.pnp4nagios.org/de/faq/19">Read FAQ online</a>',
'tpl-no-services-found' => 'Es wurden keine Services gefunden "%s". <a href="http://docs.pnp4nagios.org/de/faq/20">Read FAQ online</a>',
'tpl-no-hosts-found' => 'Es wurden keine Hosts gefunden "%s". <a href="http://docs.pnp4nagios.org/de/faq/21">Read FAQ online</a>',
'no-templates-found' => 'Es wurde kein passendes Template gefunden. <a href="http://docs.pnp4nagios.org/de/faq/22">Read FAQ online</a>',
'not_authorized' => 'You are not authorized to view this host/service',
'remote_user_missing' => 'Remote user is missing. Authentication check cancled. <a href="http://docs.pnp4nagios.org/faq/23">Read FAQ online</a>',
'livestatus_socket_error' => 'Livestatus Socket error: %s (%s) <a href="http://docs.pnp4nagios.org/faq/24">Read FAQ online</a>',
'not_authorized_for_host_overview' => 'You are not authorized to access this host overview page.',
'xml-generic_error' => 'XML file "%s" not parsable.<p><strong>XML Errors:</strong>%s</p>',
'gd-missing' => 'PHP GD functions are missing. More on <a href="http://www.php.net/manual/en/book.image.php">www.php.net</a>',
);

View File

@@ -0,0 +1,59 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$lang = array
(
'datasource' => 'Datasource: %s',
'host' => 'Host: %s',
'service' => 'Service: %s',
'page' => 'Page: %s',
'page-basket' => 'Page: Basket',
'zoom-header' => 'Zoom',
'status-box-header' => 'Status',
'multisite-box-header' => 'Multisite links',
'search-box-header' => 'Search',
'icon-box-header' => 'Actions',
'basket-box-header' => 'My basket',
'timerange-box-header' => 'Time ranges',
'service-box-header' => 'Services',
'special-templates-box-header' => 'Special Templates',
'pages-box-header' => 'Pages',
'nagios-summary-link-title' => 'Most recent alerts for this time range',
'nagios-avail-link-title' => 'Nagios availability report for this time range',
'timerange-selector-legend' => 'Select a custom time range',
'timerange-selector-title' => 'Select a custom time range',
'timerange-selector-submit-button' => 'Submit',
'timerange-selector-clear-button' => 'Clear',
'timerange-selector-link' => 'Custom time range',
'timerange-selector-overview' => 'Overview',
'start' => 'Start',
'end' => 'End',
'service-details' => 'Service details',
'service-overview' => 'Service overview for "%s"',
'title-pages-link' => 'View Pages',
'title-pdf-link' => 'View PDF',
'title-xml-link' => 'View XML',
'title-statistics-link' => 'View internal statistics',
'title-calendar-link' => 'Define a custom time range',
'title-special-templates-link' => 'View Special Templates',
'title-docs-link' => 'View Documentation',
'title-home-link' => 'View Graphs',
'title-color-link' => 'View Color Schemes',
'docs-home' => 'Home',
'docs-box-header' => 'Menu',
'docs-header' => 'Documentation Version %s',
'back' => 'back',
'mobile-all-hosts' => 'All Hosts',
'mobile-search-hosts' => 'Search Hosts',
'mobile-pages' => 'View Pages',
'mobile-special-templates' => 'View Special Templates',
'mobile-statistics' => 'View internal statistics',
'mobile-go-classic' => 'Classic UI',
'mobile-submit' => 'Submit',
'basket-empty' => 'Basket is empty',
'basket-show' => 'Show basket',
'basket-clear' => 'Clear basket',
'basket-remove' => 'Remove %s',
'basket-add-item' => 'Add this item to my basket',
'basket-add-service' => 'Add this service to my basket',
'color-box-header' => 'Colors',
'color-header' => 'Colors Schemes',
);

View File

@@ -0,0 +1,32 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$lang = array
(
'rrdtool-not-found' => 'RRDTool not found in %s. <a href="http://docs.pnp4nagios.org/faq/1">Read FAQ online</a>',
'config-not-found' => 'Config file %s not found. <a href="http://docs.pnp4nagios.org/faq/2">Read FAQ online</a>',
'perfdata-dir-empty' => 'perfdata directory "%s" is empty. Please check your Nagios config. <a href="http://docs.pnp4nagios.org/faq/3">Read FAQ online</a>',
'host-perfdata-dir-empty' => 'perfdata directory "%s" is empty. Please check your Nagios config. <a href="http://docs.pnp4nagios.org/faq/4">Read FAQ online</a>',
'perfdata-dir-for-host' => 'perfdata directory "%s" for host "%s" does not exist. <a href="http://docs.pnp4nagios.org/faq/5">Read FAQ online</a>',
'xml-not-found' => 'XML file "%s" not found. <a href="http://docs.pnp4nagios.org/faq/6">Read FAQ online</a>',
'get-first-service' => 'Can´t find first service for host "%s". <a href="http://docs.pnp4nagios.org/faq/7">Read FAQ online</a>',
'get-first-host' => 'Can´t find any Host. <a href="http://docs.pnp4nagios.org/faq/8">Read FAQ online</a>',
'xml-structure-mismatch' => 'XML structure mismatch. Found version "%d" but should be "%d". <a href="http://docs.pnp4nagios.org/faq/9">Read FAQ online</a>',
'save-rrd-image' => 'php fopen("%s") failed. <a href="http://docs.pnp4nagios.org/faq/10">Read FAQ online</a>',
'xml-structure-without-version-tag' => 'XML structure mismatch. Version tag not found in "%s". <a href="http://docs.pnp4nagios.org/faq/11">Read FAQ online</a>',
'template-without-opt' => 'Template %s does not provide array $opt[]. <a href="http://docs.pnp4nagios.org/faq/12">Read FAQ online</a>',
'template-without-def' => 'Template %s does not provide array $def[]. <a href="http://docs.pnp4nagios.org/faq/13">Read FAQ online</a>',
'no-data-for-page' => 'Sorry, but we can´t find any data using config file "%s", <a href="http://docs.pnp4nagios.org/faq/14">Read FAQ online</a>',
'page-not-readable' => 'Config file "%s" is not readable or does not exist. <a href="http://docs.pnp4nagios.org/faq/15">Read FAQ online</a>',
'auth-pages' => 'You are not authorized to view "pages" <a href="http://docs.pnp4nagios.org/faq/16">Read FAQ online</a>',
'page-config-dir' => 'No page config file found in "%s" <a href="http://docs.pnp4nagios.org/faq/17">Read FAQ online</a>',
'xport-host-service' => 'Xport controller needs "host" and "srv" URL parameters. <a href="http://docs.pnp4nagios.org/faq/18">Read FAQ online</a>',
'mod-rewrite' => 'Apache Rewrite Module is not enabled. <a href="http://docs.pnp4nagios.org/faq/19">Read FAQ online</a>',
'tpl-no-services-found' => 'No services could be found "%s". <a href="http://docs.pnp4nagios.org/faq/20">Read FAQ online</a>',
'tpl-no-hosts-found' => 'No hosts could be found "%s". <a href="http://docs.pnp4nagios.org/faq/21">Read FAQ online</a>',
'no-templates-found' => 'No templates could be found. <a href="http://docs.pnp4nagios.org/faq/22">Read FAQ online</a>',
'not_authorized' => 'You are not authorized to view this host/service',
'remote_user_missing' => 'Remote user is missing. Authentication check cancled. <a href="http://docs.pnp4nagios.org/faq/23">Read FAQ online</a>',
'livestatus_socket_error' => 'Livestatus Socket error: %s (%s) <a href="http://docs.pnp4nagios.org/faq/24">Read FAQ online</a>',
'not_authorized_for_host_overview' => 'You are not authorized to access this host overview page.',
'xml-generic_error' => 'XML file "%s" not parsable.<p><strong>XML Errors:</strong>%s</p>',
'gd-missing' => 'PHP GD functions are missing. More on <a href="http://www.php.net/manual/en/book.image.php">www.php.net</a>',
);

View File

@@ -0,0 +1,58 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$lang = array
(
'datasource' => 'Fuente de Datos: %s',
'host' => 'Equipo: %s',
'service' => 'Servicio: %s',
'page' => 'Page: %s',
'page-basket' => 'Página: Cesta',
'zoom-header' => 'Zoom',
'status-box-header' => 'Estado',
'multisite-box-header' => 'Multisite links',
'search-box-header' => 'Buscar',
'icon-box-header' => 'Acciones',
'basket-box-header' => 'Mi Cesta',
'timerange-box-header' => 'Intervalos de Tiempo',
'service-box-header' => 'Servicios',
'pages-box-header' => 'Páginas',
'nagios-summary-link-title' => 'Alertas Recientes en el Intervalo de Tiempo',
'nagios-avail-link-title' => 'Informe de Disponibilidad en el Intervalo de Tiempo',
'timerange-selector-legend' => 'Seleccione un intervalo de tiempo personalizado',
'timerange-selector-title' => 'Seleccione un intervalo de tiempo personalizado',
'timerange-selector-submit-button' => 'enviar',
'timerange-selector-clear-button' => 'limpiar',
'timerange-selector-link' => 'Intervalo de tiempo personalizado',
'timerange-selector-overview' => 'Overview',
'start' => 'Comienzo',
'end' => 'Fin',
'service-details' => 'Detalles de Servicio',
'service-overview' => 'Vista General de Servicio para "%s"',
'title-pages-link' => 'Ver páginas',
'title-pdf-link' => 'Ver PDF',
'title-xml-link' => 'Ver XML',
'title-statistics-link' => 'Ver estadísticas internas de PNP',
'title-calendar-link' => 'Definir un intervalo de tiempo personalizado',
'title-special-templates-link' => 'View Special Templates',
'title-docs-link' => 'View Documentation',
'title-home-link' => 'View Graphs',
'title-color-link' => 'View Color Schemes',
'docs-home' => 'Home',
'docs-box-header' => 'Menu',
'docs-header' => 'Documentation Version %s',
'back' => 'back',
'mobile-all-hosts' => 'All Hosts',
'mobile-search-hosts' => 'Search Hosts',
'mobile-pages' => 'View Pages',
'mobile-special-templates' => 'View Special Templates',
'mobile-statistics' => 'View internal statistics',
'mobile-go-classic' => 'Classic UI',
'mobile-submit' => 'Submit',
'basket-empty' => 'Basket is empty',
'basket-show' => 'Show basket',
'basket-clear' => 'Clear basket',
'basket-remove' => 'Remove %s',
'basket-add-item' => 'Add this item to my basket',
'basket-add-service' => 'Add this service to my basket',
'color-box-header' => 'Colors',
'color-header' => 'Colors Schemes',
);

View File

@@ -0,0 +1,32 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$lang = array
(
'rrdtool-not-found' => 'RRDTool no se encuentra en %s. <a href="http://docs.pnp4nagios.org/es/faq/1">Leer FAQ en línea</a>',
'config-not-found' => 'El fichero de configuración %s no se ha encontrado. <a href="http://docs.pnp4nagios.org/es/faq/2">Leer FAQ en línea</a>',
'perfdata-dir-empty' => 'El directorio de Perfdata "%s" está vacío. Compruebe la configuración de Nagios. <a href="http://docs.pnp4nagios.org/es/faq/3">Leer FAQ en línea</a>',
'host-perfdata-dir-empty' => 'El directorio de Perfdata "%s" está vacío. Compruebe la configuración de Nagios. <a href="http://docs.pnp4nagios.org/es/faq/4">Leer FAQ en línea</a>',
'perfdata-dir-for-host' => 'El directorio Perfdata "%s" para el Equipo "%s" no existe. <a href="http://docs.pnp4nagios.org/es/faq/5">Leer FAQ en línea</a>',
'xml-not-found' => 'Fichero XML "%s" no encontrado. <a href="http://docs.pnp4nagios.org/es/faq/6">Leer FAQ en línea</a>',
'get-first-service' => 'No puedo encontrar el primer servicio para el equipo "%s". <a href="http://docs.pnp4nagios.org/es/faq/7">Leer FAQ en línea</a>',
'get-first-host' => 'No puedo encuentrar ningún Equipo. <a href="http://docs.pnp4nagios.org/es/faq/8">Leer FAQ en línea</a>',
'xml-structure-mismatch' => 'Error en la Estructura XML. Versión Encontrada "%d" pero debería ser "%d". <a href="http://docs.pnp4nagios.org/es/faq/9">Read FAQ online</a>',
'save-rrd-image' => 'fallo en php fopen("%s"). <a href="http://docs.pnp4nagios.org/es/faq/10">Leer FAQ en línea</a>',
'xml-structure-without-version-tag' => 'Error en la estructura XML. Etiqueta de Versión no encontrada. <a href="http://docs.pnp4nagios.org/es/faq/11">Leer FAQ en línea</a>',
'template-without-opt' => 'La plantilla %s no tiene el array $opt[]. <a href="http://docs.pnp4nagios.org/es/faq/12">Leer FAQ en línea</a>',
'template-without-def' => 'La plantilla %s no tiene el array $def[]. <a href="http://docs.pnp4nagios.org/es/faq/13">Leer FAQ en línea</a>',
'no-data-for-page' => 'Lo siento, no puedo encontrar ningún dato usando el fichero de configuración "%s", <a href="http://docs.pnp4nagios.org/es/faq/14">Leer FAQ en línea</a>',
'page-not-readable' => 'El fichero de configuración "%s" no es legible o no existe. <a href="http://docs.pnp4nagios.org/es/faq/15">Leer FAQ en línea</a>',
'auth-pages' => 'No está autorizado a ver "páginas" <a href="http://docs.pnp4nagios.org/es/faq/16">Leer FAQ en línea</a>',
'page-config-dir' => 'No hay fichero de configuración de página en "%s" <a href="http://docs.pnp4nagios.org/es/faq/17">Leer FAQ en línea</a>',
'xport-host-service' => 'El controlador Xport necesita los parámetros de URL "host" y "srv". <a href="http://docs.pnp4nagios.org/es/faq/18">Leer FAQ en línea</a>',
'mod-rewrite' => 'El módulo Apache Rewrite no está habilitado. <a href="http://docs.pnp4nagios.org/es/faq/19">Leer FAQ en línea</a>',
'tpl-no-services-found' => 'No services could be found "%s". <a href="http://docs.pnp4nagios.org/faq/20">Read FAQ online</a>',
'tpl-no-hosts-found' => 'No hosts could be found "%s". <a href="http://docs.pnp4nagios.org/faq/21">Read FAQ online</a>',
'no-templates-found' => 'No templates could be found. <a href="http://docs.pnp4nagios.org/faq/22">Read FAQ online</a>',
'not_authorized' => 'You are not authorized to view this host/service',
'remote_user_missing' => 'Remote user is missing. Authentication check cancled. <a href="http://docs.pnp4nagios.org/faq/23">Read FAQ online</a>',
'livestatus_socket_error' => 'Livestatus Socket error: %s (%s) <a href="http://docs.pnp4nagios.org/faq/24">Read FAQ online</a>',
'not_authorized_for_host_overview' => 'You are not authorized to access this host overview page.',
'xml-generic_error' => 'XML file "%s" not parsable.<p><strong>XML Errors:</strong>%s</p>',
'gd-missing' => 'PHP GD functions are missing. More on <a href="http://www.php.net/manual/en/book.image.php">www.php.net</a>',
);

View File

@@ -0,0 +1,59 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$lang = array
(
'datasource' => 'Source de données : %s',
'host' => 'Machine : %s',
'service' => 'Service : %s',
'page' => 'Page : %s',
'page-basket' => 'Page : Panier',
'zoom-header' => 'Zoom',
'status-box-header' => 'État',
'multisite-box-header' => 'Liens multisite',
'search-box-header' => 'Recherche',
'icon-box-header' => 'Actions',
'basket-box-header' => 'Mon panier',
'timerange-box-header' => 'Plage de temps',
'service-box-header' => 'Services',
'special-templates-box-header' => 'Patrons spécifiques',
'pages-box-header' => 'Pages',
'nagios-summary-link-title' => 'Alarmes les plus récentes dans cette plage de temps',
'nagios-avail-link-title' => 'Disponibilité de Nagios pendant cette plage de temps',
'timerange-selector-legend' => 'Selectionner une plage de temps',
'timerange-selector-title' => 'Selectionner une plage de temps',
'timerange-selector-submit-button' => 'démarrer',
'timerange-selector-clear-button' => 'effacer',
'timerange-selector-link' => 'Plage de temps personnalisée',
'timerange-selector-overview' => 'Overview',
'start' => 'Début',
'end' => 'Fin',
'service-details' => 'Détails du service',
'service-overview' => 'Aperçu du service sur "%s"',
'title-pages-link' => 'Voir la page',
'title-pdf-link' => 'Extraction PDF',
'title-xml-link' => 'Extraction XML',
'title-statistics-link' => 'Voir statistiques internes sur PNP',
'title-calendar-link' => 'Définir une plage de temps',
'title-special-templates-link' => 'Voir les patrons',
'title-docs-link' => 'Accèder à la documentation',
'title-home-link' => 'Accèder aux graphiques',
'title-color-link' => 'View Color Schemes',
'docs-home' => 'Accueil',
'docs-box-header' => 'Menu',
'docs-header' => 'Version de la documentation %s',
'back' => 'back',
'mobile-all-hosts' => 'All Hosts',
'mobile-search-hosts' => 'Search Hosts',
'mobile-pages' => 'View Pages',
'mobile-special-templates' => 'View Special Templates',
'mobile-statistics' => 'View internal statistics',
'mobile-go-classic' => 'Classic UI',
'mobile-submit' => 'Submit',
'basket-empty' => 'Basket is empty',
'basket-show' => 'Show basket',
'basket-clear' => 'Clear basket',
'basket-remove' => 'Remove %s',
'basket-add-item' => 'Add this item to my basket',
'basket-add-service' => 'Add this service to my basket',
'color-box-header' => 'Colors',
'color-header' => 'Colors Schemes',
);

View File

@@ -0,0 +1,32 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$lang = array
(
'rrdtool-not-found' => 'RRDTool non trouvé dans %s. <a href="http://docs.pnp4nagios.org/faq/1">Lire la FAQ</a>',
'config-not-found' => 'Fichier de config %s non trouvé. <a href="http://docs.pnp4nagios.org/faq/2">Lire la FAQ</a>',
'perfdata-dir-empty' => 'Répertoire perfdata "%s" vide. Merci de vérifier la configuration de Nagios. <a href="http://docs.pnp4nagios.org/faq/3">Lire la FAQ</a>',
'host-perfdata-dir-empty' => 'Répertoire perfdata "%s" vide. Merci de vérifier la configuration de Nagios. <a href="http://docs.pnp4nagios.org/faq/4">Lire la FAQ</a>',
'perfdata-dir-for-host' => 'Répertoire perfdata "%s" du serveur "%s" n\'existe pas. <a href="http://docs.pnp4nagios.org/faq/5">Lire la FAQ</a>',
'xml-not-found' => 'Fichier XML "%s" non trouvé. <a href="http://docs.pnp4nagios.org/faq/6">Lire la FAQ</a>',
'get-first-service' => 'Impossible de trouver le premier service du serveur "%s". <a href="http://docs.pnp4nagios.org/faq/7">Lire la FAQ</a>',
'get-first-host' => 'Impossible de trouver un serveur. <a href="http://docs.pnp4nagios.org/faq/8">Lire la FAQ</a>',
'xml-structure-mismatch' => 'Structure XML incorrecte. Version trouvé "%d" mais version attendu "%d". <a href="http://docs.pnp4nagios.org/faq/9">Lire la FAQ</a>',
'save-rrd-image' => 'Échec de la fonction php fopen("%s"). <a href="http://docs.pnp4nagios.org/faq/10">Lire la FAQ</a>',
'xml-structure-without-version-tag' => 'Structure XML incorrect. Balise de version introuvable dans "%s". <a href="http://docs.pnp4nagios.org/faq/11">Lire la FAQ</a>',
'template-without-opt' => 'Le template %s ne renvoie pas de tableau $opt[]. <a href="http://docs.pnp4nagios.org/faq/12">Lire la FAQ</a>',
'template-without-def' => 'Le template %s ne renvoie pas de tableau $def[]. <a href="http://docs.pnp4nagios.org/faq/13">Lire la FAQ</a>',
'no-data-for-page' => 'Désolé, mais impossible de trouver des données en utilisant le fichier de configuration "%s", <a href="http://docs.pnp4nagios.org/faq/14">Lire la FAQ</a>',
'page-not-readable' => 'Impossible de lire le fichier de configuration "%s" ou fichier introuvable. <a href="http://docs.pnp4nagios.org/faq/15">Lire la FAQ</a>',
'auth-pages' => 'Vous n\'êtes pas autorisé de voir "pages" <a href="http://docs.pnp4nagios.org/faq/16">Lire la FAQ</a>',
'page-config-dir' => 'Pas de fichier de configuration pour page dans "%s" <a href="http://docs.pnp4nagios.org/faq/17">Lire la FAQ</a>',
'xport-host-service' => 'Le contrôleur Xport nécessite les paramètres "host" et "srv" en paramètres d\'URL. <a href="http://docs.pnp4nagios.org/faq/18">Lire la FAQ</a>',
'mod-rewrite' => 'Module Apache Rewrite désactivé. <a href="http://docs.pnp4nagios.org/faq/19">Lire la FAQ</a>',
'tpl-no-services-found' => 'Impossible de trouver des services "%s". <a href="http://docs.pnp4nagios.org/faq/20">Read FAQ online</a>',
'tpl-no-hosts-found' => 'Impossible de trouver des serveurs "%s". <a href="http://docs.pnp4nagios.org/faq/21">Read FAQ online</a>',
'no-templates-found' => 'Impossible de trouver des modèles. <a href="http://docs.pnp4nagios.org/faq/22">Read FAQ online</a>',
'not_authorized' => 'You are not authorized to view this host/service',
'remote_user_missing' => 'Remote user is missing. Authentication check cancled. <a href="http://docs.pnp4nagios.org/faq/23">Read FAQ online</a>',
'livestatus_socket_error' => 'Livestatus Socket error: %s (%s) <a href="http://docs.pnp4nagios.org/faq/24">Read FAQ online</a>',
'not_authorized_for_host_overview' => 'You are not authorized to access this host overview page.',
'xml-generic_error' => 'XML file "%s" not parsable.<p><strong>XML Errors:</strong>%s</p>',
'gd-missing' => 'PHP GD functions are missing. More on <a href="http://www.php.net/manual/en/book.image.php">www.php.net</a>',
);

View File

@@ -0,0 +1,59 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$lang = array
(
'datasource' => 'Источник данных: %s',
'host' => 'Хост: %s',
'service' => 'Служба: %s',
'page' => 'Страница: %s',
'page-basket' => 'Страница: Мой набор',
'zoom-header' => 'Детализация',
'status-box-header' => 'Статус',
'multisite-box-header' => 'Multisite links',
'search-box-header' => 'Поиск',
'icon-box-header' => 'Действия',
'basket-box-header' => 'Мой набор',
'timerange-box-header' => 'Интервалы времени',
'service-box-header' => 'Службы',
'special-templates-box-header' => 'Специальные шаблоны',
'pages-box-header' => 'Страницы',
'nagios-summary-link-title' => 'Последние алерты за данный промежуток',
'nagios-avail-link-title' => 'Сводка доступности за данный промежуток',
'timerange-selector-legend' => 'Выберите промежуток',
'timerange-selector-title' => 'Установка собственного интервала времени',
'timerange-selector-submit-button' => 'ввести',
'timerange-selector-clear-button' => 'очистить',
'timerange-selector-link' => 'Собственный интервал',
'timerange-selector-overview' => 'Overview',
'start' => 'Начало',
'end' => 'Окончание',
'service-details' => 'Подробности о службе',
'service-overview' => 'Обзор служб для "%s"',
'title-pages-link' => 'Обзор страниц',
'title-pdf-link' => 'Просмотр PDF',
'title-xml-link' => 'Просмотр XML',
'title-statistics-link' => 'Просмотр внутренней статистики PNP',
'title-calendar-link' => 'Установка собственного временного интервала',
'title-special-templates-link' => 'Просмотр специальных шаблонов',
'title-docs-link' => 'Просмотреть документацию',
'title-home-link' => 'Просмотр графиков',
'title-color-link' => 'View Color Schemes',
'docs-home' => 'На главную',
'docs-box-header' => 'Меню',
'docs-header' => 'Версия документации %s',
'back' => 'назад',
'mobile-all-hosts' => 'Все хосты',
'mobile-search-hosts' => 'Поиск хостов',
'mobile-pages' => 'Просмотр страниц',
'mobile-special-templates' => 'Просмотр специальных шаблонов',
'mobile-statistics' => 'Просмотр внутренней статистики',
'mobile-go-classic' => 'Классический UI',
'mobile-submit' => 'Ввести',
'basket-empty' => 'Корзина пуста',
'basket-show' => 'Показать корзину',
'basket-clear' => 'Clear basket',
'basket-remove' => 'Убрать %s',
'basket-add-item' => 'Добавить этот элемент в мою корзину',
'basket-add-service' => 'Добавить эту службу в мою корзину',
'color-box-header' => 'Colors',
'color-header' => 'Colors Schemes',
);

View File

@@ -0,0 +1,32 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$lang = array
(
'rrdtool-not-found' => 'RRDTool не обнаружено в %s. <a href="http://docs.pnp4nagios.org/faq/1">Read FAQ online</a>',
'config-not-found' => 'Файл конфигурации %s не найден. <a href="http://docs.pnp4nagios.org/faq/2">Read FAQ online</a>',
'perfdata-dir-empty' => 'Директория с данными производительности "%s" пуста. Пожалуйста, проверьте конфигурацию Nagios. <a href="http://docs.pnp4nagios.org/faq/3">Read FAQ online</a>',
'host-perfdata-dir-empty' => 'Директория с данными производительности "%s" пуста. Пожалуйста, проверьте конфигурацию Nagios. <a href="http://docs.pnp4nagios.org/faq/4">Read FAQ online</a>',
'perfdata-dir-for-host' => 'Директория с данными производительности "%s" для хоста "%s" не существует. <a href="http://docs.pnp4nagios.org/faq/5">Read FAQ online</a>',
'xml-not-found' => 'XML файл "%s" не найден. <a href="http://docs.pnp4nagios.org/faq/6">Read FAQ online</a>',
'get-first-service' => 'Невозможно определить первую службу для хоста "%s". <a href="http://docs.pnp4nagios.org/faq/7">Read FAQ online</a>',
'get-first-host' => 'Ни по одному хосту данных не обнаружено. <a href="http://docs.pnp4nagios.org/faq/8">Read FAQ online</a>',
'xml-structure-mismatch' => 'Несоответствие структуры данных XML. Обнаружена версия "%d", ожидаемая версия - "%d". <a href="http://docs.pnp4nagios.org/faq/9">Read FAQ online</a>',
'save-rrd-image' => 'Функция php fopen("%s") завершилась неудачей. <a href="http://docs.pnp4nagios.org/faq/10">Read FAQ online</a>',
'xml-structure-without-version-tag' => 'Несоответствие структуры данных XML. Тэг версии не найден в "%s". <a href="http://docs.pnp4nagios.org/faq/11">Read FAQ online</a>',
'template-without-opt' => 'Шаблон %s не предоставляет массив $opt[]. <a href="http://docs.pnp4nagios.org/faq/12">Read FAQ online</a>',
'template-without-def' => 'Шаблон %s не предоставляет массив $def[]. <a href="http://docs.pnp4nagios.org/faq/13">Read FAQ online</a>',
'no-data-for-page' => 'Извините, не удалось обнаружить никаких данных используя конфигурационный файл "%s", <a href="http://docs.pnp4nagios.org/faq/14">Read FAQ online</a>',
'page-not-readable' => 'Конфигурационный файл "%s" не может быть прочитан или не существует. <a href="http://docs.pnp4nagios.org/faq/15">Read FAQ online</a>',
'auth-pages' => 'Вы не авторизованы для просмотра "страниц" <a href="http://docs.pnp4nagios.org/faq/16">Read FAQ online</a>',
'page-config-dir' => 'Файл конфигурации "страниц" не найден в "%s" <a href="http://docs.pnp4nagios.org/faq/17">Read FAQ online</a>',
'xport-host-service' => 'Контроллер Xport требует параметры "host" и "srv" в URL. <a href="http://docs.pnp4nagios.org/faq/18">Read FAQ online</a>',
'mod-rewrite' => 'Модуль Rewrite для Apache не включен. <a href="http://docs.pnp4nagios.org/faq/19">Read FAQ online</a>',
'tpl-no-services-found' => 'Службы "%s" не найдены. <a href="http://docs.pnp4nagios.org/faq/20">Read FAQ online</a>',
'tpl-no-hosts-found' => 'Хосты "%s" не найдены. <a href="http://docs.pnp4nagios.org/faq/21">Read FAQ online</a>',
'no-templates-found' => 'Шаблоны "%s" не найдены. <a href="http://docs.pnp4nagios.org/faq/22">Read FAQ online</a>',
'not_authorized' => 'Вы не авторизованы для просмотра данного хоста/службы',
'remote_user_missing' => 'Удалённый пользователь не указан. Проверка аутентификации отменена. <a href="http://docs.pnp4nagios.org/faq/23">Read FAQ online</a>',
'livestatus_socket_error' => 'Ошибка Livestatus сокета: %s (%s) <a href="http://docs.pnp4nagios.org/faq/24">Read FAQ online</a>',
'not_authorized_for_host_overview' => 'Вы не авторизованы для доступа к странице обзора хоста.',
'xml-generic_error' => 'Не удаётся распарсить XML файл "%s".<p><strong>Ошибки XML:</strong>%s</p>',
'gd-missing' => 'PHP GD functions are missing. More on <a href="http://www.php.net/manual/en/book.image.php">www.php.net</a>',
);

View File

@@ -0,0 +1,806 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 3);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 4);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 5);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 16);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
}
// treat it like a regular array
$elements = array_map(array($this, 'encode'), $var);
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
return '[' . join(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->encode($value);
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
return $this->encode(strval($name)) . ':' . $encoded_value;
}
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
case 'null':
return null;
default:
$m = array();
if (is_numeric($str)) {
// Lookie-loo, it's a number
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
}
}
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} else {
return $obj;
}
}
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
}
}
}
}
/**
* @todo Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
return false;
}
}
if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
} else {
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
}
}
}
?>

View File

@@ -0,0 +1,6 @@
<?php
# In PHP 5.2 or higher we don't need to bring this in
if (!function_exists('json_encode')) {
require_once 'jsonwrapper_inner.php';
}
?>

View File

@@ -0,0 +1,23 @@
<?php
require_once 'json.php';
function json_encode($arg)
{
global $services_json;
if (!isset($services_json)) {
$services_json = new Services_JSON();
}
return $services_json->encode($arg);
}
function json_decode($arg)
{
global $services_json;
if (!isset($services_json)) {
$services_json = new Services_JSON();
}
return $services_json->decode($arg);
}
?>

View File

@@ -0,0 +1,154 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Retrieves the PNP config files
*/
class Auth_Model extends System_Model {
public $SOCKET = NULL;
public $socketPath = NULL;
public $socketDOMAIN = NULL;
public $socketTYPE = NULL;
public $socketHOST = NULL;
public $socketPORT = 0;
public $socketPROTO = NULL;
public $ERR_TXT = "";
public $AUTH_ENABLED = FALSE;
public $REMOTE_USER = NULL;
public function __construct() {
$this->config = new Config_Model;
$this->config->read_config();
if($this->config->conf['auth_enabled'] == 1){
$this->AUTH_ENABLED = TRUE;
$this->socketPath = $this->config->conf['livestatus_socket'];
}
// Try to get the login of the user
if(isset($_SERVER['REMOTE_USER'])){
$this->REMOTE_USER = $_SERVER['REMOTE_USER'];
}
if($this->REMOTE_USER === NULL && $this->config->conf['auth_multisite_enabled'] == 1) {
$MSAUTH = new Auth_Multisite_Model($this->config->conf['auth_multisite_htpasswd'],
$this->config->conf['auth_multisite_serials'],
$this->config->conf['auth_multisite_secret'],
$this->config->conf['auth_multisite_login_url']);
$this->REMOTE_USER = $MSAUTH->check();
if($this->REMOTE_USER !== null)
return;
}
if($this->AUTH_ENABLED === TRUE && $this->REMOTE_USER === NULL){
throw new Kohana_exception("error.remote_user_missing");
}
}
public function __destruct() {
if($this->SOCKET !== NULL) {
socket_close($this->SOCKET);
$this->SOCKET = NULL;
}
}
public function connect(){
$this->getSocketDetails($this->socketPath);
$this->SOCKET = socket_create($this->socketDOMAIN, $this->socketTYPE, $this->socketPROTO);
if($this->SOCKET === FALSE) {
throw new Kohana_exception("error.livestatus_socket_error", socket_strerror(socket_last_error($this->SOCKET)), $this->socketPath);
}
if($this->socketDOMAIN === AF_UNIX){
$result = @socket_connect($this->SOCKET, $this->socketPATH);
}else{
$result = @socket_connect($this->SOCKET, $this->socketHOST, $this->socketPORT);
}
if(!$result) {
throw new Kohana_exception("error.livestatus_socket_error", socket_strerror(socket_last_error($this->SOCKET)), $this->socketPath);
}
}
private function queryLivestatus($query) {
if($this->SOCKET === NULL) {
$this->connect();
}
@socket_write($this->SOCKET, $query."\nOutputFormat: json\n\n");
// Read 16 bytes to get the status code and body size
$read = @socket_read($this->SOCKET,2048);
if(!$read) {
throw new Kohana_exception("error.livestatus_socket_error", socket_strerror(socket_last_error($this->SOCKET)));
}
# print Kohana::debug("read ". $read);
// Catch problem while reading
if($read === false) {
throw new Kohana_exception("error.livestatus_socket_error", socket_strerror(socket_last_error($this->SOCKET)));
}
// Decode the json response
$obj = json_decode(utf8_encode($read));
socket_close($this->SOCKET);
$this->SOCKET = NULL;
return $obj;
}
public function is_authorized($host = FALSE, $service = NULL){
if($this->AUTH_ENABLED === FALSE){
return TRUE;
}
if($host == "pnp-internal"){
return TRUE;
}
if($service === NULL || $service == "_HOST_" || $service == "Host Perfdata"){
$users = explode(",", $this->config->conf['allowed_for_all_hosts']);
if (in_array($this->REMOTE_USER, $users)) {
return TRUE;
}
$query = "GET hosts\nColumns: name\nFilter: name = $host\nAuthUser: ".$this->REMOTE_USER;
$result = $this->queryLivestatus($query);
}else{
$users = explode(",", $this->config->conf['allowed_for_all_services']);
if (in_array($this->REMOTE_USER, $users)) {
return TRUE;
}
$query = "GET services\nColumns: host_name description\nFilter: host_name = $host\nFilter: description = $service\nAuthUser: ".$this->REMOTE_USER;
$result = $this->queryLivestatus($query);
}
if(sizeof($result) > 0){
return TRUE;
}else{
return FALSE;
}
}
public function getSocketDetails($string=FALSE){
if(preg_match('/^unix:(.*)$/',$string,$match) ){
$this->socketDOMAIN = AF_UNIX;
$this->socketTYPE = SOCK_STREAM;
$this->socketPATH = $match[1];
$this->socketPROTO = 0;
return;
}
if(preg_match('/^tcp:([a-zA-Z0-9-\.]+):([0-9]+)$/',$string,$match) ){
$this->socketDOMAIN = AF_INET;
$this->socketTYPE = SOCK_STREAM;
$this->socketHOST = $match[1];
$this->socketPORT = $match[2];
$this->socketPROTO = SOL_TCP;
return;
}
# Fallback
if(preg_match('/^\/.*$/',$string,$match) ){
$this->socketDOMAIN = AF_UNIX;
$this->socketTYPE = SOCK_STREAM;
$this->socketPATH = $string;
$this->socketPROTO = 0;
return;
}
return FALSE;
}
}

View File

@@ -0,0 +1,111 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Auth_Multisite_Model {
private $htpasswdPath;
private $serialsPath;
private $secretPath;
private $authFile;
public function __construct($htpasswdPath, $serialsPath, $secretPath, $loginUrl) {
$this->htpasswdPath = $htpasswdPath;
$this->serialsPath = $serialsPath;
$this->secretPath = $secretPath;
$this->loginUrl = $loginUrl;
// When the auth.serial file exists, use this instead of the htpasswd
// for validating the cookie. The structure of the file is equal, so
// the same code can be used.
if(file_exists($this->serialsPath)) {
$this->authFile = 'serial';
} elseif(file_exists($this->htpasswdPath)) {
$this->authFile = 'htpasswd';
} else {
throw new Kohana_exception("error.auth_multisite_missing_htpasswd");
}
if(!file_exists($this->secretPath)) {
$this->redirectToLogin();
}
}
private function loadAuthFile($path) {
$creds = array();
foreach(file($path) AS $line) {
if(strpos($line, ':') !== false) {
list($username, $secret) = explode(':', $line, 2);
$creds[$username] = rtrim($secret);
}
}
return $creds;
}
private function loadSecret() {
return trim(file_get_contents($this->secretPath));
}
private function generateHash($username, $now, $user_secret) {
$secret = $this->loadSecret();
return md5($username . $now . $user_secret . $secret);
}
private function checkAuthCookie($cookieName) {
if(!isset($_COOKIE[$cookieName]) || $_COOKIE[$cookieName] == '') {
throw new Exception();
}
list($username, $issueTime, $cookieHash) = explode(':', $_COOKIE[$cookieName], 3);
if($this->authFile == 'htpasswd')
$users = $this->loadAuthFile($this->htpasswdPath);
else
$users = $this->loadAuthFile($this->serialsPath);
if(!isset($users[$username])) {
throw new Exception();
}
$user_secret = $users[$username];
// Validate the hash
if($cookieHash != $this->generateHash($username, $issueTime, $user_secret)) {
throw new Exception();
}
// FIXME: Maybe renew the cookie here too
return $username;
}
private function checkAuth() {
// Loop all cookies trying to fetch a valid authentication
// cookie for this installation
foreach(array_keys($_COOKIE) AS $cookieName) {
if(substr($cookieName, 0, 5) != 'auth_') {
continue;
}
try {
$name = $this->checkAuthCookie($cookieName);
return $name;
} catch(Exception $e) {}
}
return '';
}
private function redirectToLogin() {
header('Location:' . $this->loginUrl . '?_origtarget=' . $_SERVER['REQUEST_URI']);
}
public function check() {
$username = $this->checkAuth();
if($username === '') {
$this->redirectToLogin();
exit(0);
}
return $username;
}
}
?>

View File

@@ -0,0 +1,88 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Retrieves the PNP config files
*/
class Config_Model extends System_Model
{
public $conf = array();
public $views = array();
public $scheme = array();
public function read_config(){
if(getenv('PNP_CONFIG_FILE') != ""){
$config = getenv('PNP_CONFIG_FILE');
}elseif(OMD){
$config = OMD_SITE_ROOT.'/etc/pnp4nagios/config';
}else{
$config = Kohana::config('core.pnp_etc_path')."/config";
}
# Default Values
$conf['doc_language'] = Kohana::config('core.doc_language');
$conf['graph_width'] = Kohana::config('core.graph_width');
$conf['graph_height'] = Kohana::config('core.graph_height');
$conf['zgraph_width'] = Kohana::config('core.zgraph_width');
$conf['zgraph_height'] = Kohana::config('core.zgraph_height');
$conf['pdf_width'] = Kohana::config('core.pdf_width');
$conf['pdf_height'] = Kohana::config('core.pdf_height');
$conf['right_zoom_offset'] = Kohana::config('core.right_zoom_offset');
$conf['mobile_devices'] = Kohana::config('core.mobile_devices');
$conf['pdf_page_size'] = Kohana::config('core.pdf_page_size');
$conf['pdf_margin_left'] = Kohana::config('core.pdf_margin_left');
$conf['pdf_margin_right'] = Kohana::config('core.pdf_margin_right');
$conf['pdf_margin_top'] = Kohana::config('core.pdf_margin_top');
$conf['auth_multisite_enabled'] = Kohana::config('core.auth_multisite_enabled');
$conf['auth_multisite_serials'] = Kohana::config('core.auth_multisite_serials');
$conf['auth_multisite_htpasswd'] = Kohana::config('core.auth_multisite_htpasswd');
$conf['auth_multisite_secret'] = Kohana::config('core.auth_multisite_secret');
$conf['auth_multisite_login_url'] = Kohana::config('core.auth_multisite_login_url');
$scheme['Reds'] = array ('#FEE0D2','#FCBBA1','#FC9272','#FB6A4A','#EF3B2C','#CB181D','#A50F15','#67000D');
$views = Kohana::config('core.views');
if (is_readable($config . ".php")) {
include ($config . ".php");
}else {
throw new Kohana_Exception('error.config-not-found', $config.'.php');
}
// Load optional config files
// a) the _local.php config
// b) all .php files which do not start with a "." in config.d/
$custom_configs = array($config . "_local.php");
if (file_exists($config . ".d") && is_dir($config . ".d")) {
$dh = opendir($config . ".d");
while (($file = readdir($dh)) !== false) {
if ($file[0] != '.' && substr($file, -4) == '.php') {
$custom_configs[] = $config . ".d/" .$file;
}
}
closedir($dh);
}
foreach($custom_configs AS $config_file) {
if (is_readable($config_file)) {
$array_a = $views;
$views = array();
include ($config_file);
$array_b = $views;
if(sizeof($views) == 0 ){
$views = $array_a;
}
}
}
// Use graph_height & graph_width from URL if present
// Hint: In Kohana 3 Input class is removed
$input = Input::instance();
if($input->get('h') != "" ) $conf['graph_height'] = intval($input->get('h'));
if($input->get('w') != "" ) $conf['graph_width'] = intval($input->get('w'));
if($input->get('graph_height') != "" ) $conf['graph_height'] = intval($input->get('graph_height'));
if($input->get('graph_width') != "" ) $conf['graph_width'] = intval($input->get('graph_width'));
$this->conf = $conf;
$this->views = $views;
$this->scheme = $scheme;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,243 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Retrieves and manipulates current status of hosts (and services?)
*/
class Rrdtool_Model extends System_Model
{
private $RRD_CMD = FALSE;
/*
*
*
*/
public function __construct(){
$this->config = new Config_Model();
$this->config->read_config();
#print Kohana::debug($this->config->views);
}
private function rrdtool_execute() {
$descriptorspec = array (
0 => array ("pipe","r"), // stdin is a pipe that the child will read from
1 => array ("pipe","w"), // stdout is a pipe that the child will write to
2 => array ("pipe","w") // stderr is a pipe that the child will write to
);
if(!isset($this->config->conf['rrdtool']) )
return FALSE;
if ( !is_executable($this->config->conf['rrdtool']) ) {
$data = "ERROR: ".$this->config->conf['rrdtool']." is not executable by PHP\n\n";
return $data;
}
$rrdtool = $this->config->conf['rrdtool'] . " - ";
$command = $this->RRD_CMD;
$process = proc_open($rrdtool, $descriptorspec, $pipes);
$debug = Array();
$data = "";
if (is_resource($process)) {
fwrite($pipes[0], $command);
fclose($pipes[0]);
stream_set_timeout($pipes[1],1);
$data = stream_get_contents($pipes[1]);
stream_set_timeout($pipes[2],1);
$stderr = stream_get_contents($pipes[2]);
$stdout_meta = stream_get_meta_data($pipes[1]);
if($stdout_meta['timed_out'] == 1){
$data = "ERROR: Timeout while reading rrdtool data.\n\n";
}
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
// Catch STDERR
if($stderr && strlen($stderr) >= 0 ){
$data = "ERROR: STDERR => ".$stderr."\n\n";
return $data;
}
// Catch STDOUT < 50 Characters
if($data && strlen($data) < 50 ){
$data = "ERROR: STDOUT => ".$data."\n\n";
return $data;
}
}else{
$data = "ERROR: proc_open(".$rrdtool." ... failed";
}
return $data;
}
public function doImage($RRD_CMD, $out='STDOUT') {
$conf = $this->config->conf;
# construct $command to rrdtool
if(isset($conf['RRD_DAEMON_OPTS']) && $conf['RRD_DAEMON_OPTS'] != '' ){
$command = " graph --daemon=" . $conf['RRD_DAEMON_OPTS'] . " - ";
}else{
$command = " graph - ";
}
$width = 0;
$height = 0;
if ($out == 'PDF'){
if($conf['pdf_graph_opt']){
$command .= $conf['pdf_graph_opt'];
}
if (isset($conf['pdf_width']) && is_numeric($conf['pdf_width'])){
$width = abs($conf['pdf_width']);
}
if (isset($conf['pdf_height']) && is_numeric($conf['pdf_height'])){
$height = abs($conf['pdf_height']);
}
}else{
if($conf['graph_opt']){
$command .= $conf['graph_opt'];
}
if(is_numeric($conf['graph_width'])){
$width = abs($conf['graph_width']);
}
if(is_numeric($conf['graph_height'])){
$height = abs($conf['graph_height']);
}
}
if ($width > 0){
$command .= " --width=$width";
}
if ($height > 0){
$command .= " --height=$height";
}
if ($height < 81 ){
$command .= " --only-graph ";
}
$command .= $RRD_CMD;
# Force empty vertical label
if( ! preg_match_all('/(-l|--vertical-label)/i',$command,$match)){
$command .= " --vertical-label=' ' ";
}
$this->RRD_CMD = $command;
$data = $this->rrdtool_execute();
if($data){
return $data;
}else{
return FALSE;
}
}
/*
*
*/
public function doXport($RRD_CMD){
$conf = $this->config->conf;
if(isset($conf['RRD_DAEMON_OPTS']) && $conf['RRD_DAEMON_OPTS'] != '' ){
$command = " xport --daemon=" . $conf['RRD_DAEMON_OPTS'];
}else{
$command = " xport ";
}
$command .= $RRD_CMD;
$this->RRD_CMD = $command;
$data = $this->rrdtool_execute();
$data = preg_replace('/OK.*/','',$data);
if($data){
return $data;
}else{
return FALSE;
}
}
public function streamImage($data = FALSE){
if ( $data === FALSE ){
header("Content-type: image/png");
echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A
/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9kCCAoDKSKZ0rEAAAAZdEVYdENv
bW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAADUlEQVQI12NgYGBgAAAABQABXvMqOgAAAABJ
RU5ErkJggg==');
return;
}
if (preg_match('/^ERROR/', $data)) {
if(preg_match('/NOT_AUTHORIZED/', $data)){
// TODO: i18n
$data .= "\n\nYou are not authorized to view this Image";
// Set font size
$font_size = 3;
}else{
$data .= $this->format_rrd_debug( $this->config->conf['rrdtool'] . $this->RRD_CMD) ;
// Set font size
$font_size = 1.5;
}
$ts=explode("\n",$data);
$width=0;
foreach ($ts as $k=>$string) {
$width=max($width,strlen($string));
}
$width = imagefontwidth($font_size)*$width;
if($width <= $this->config->conf['graph_width']+100){
$width = $this->config->conf['graph_width']+100;
}
$height = imagefontheight($font_size)*count($ts);
if($height <= $this->config->conf['graph_height']+60){
$height = $this->config->conf['graph_height']+60;
}
$el=imagefontheight($font_size);
$em=imagefontwidth($font_size);
// Create the image pallette
$img = imagecreatetruecolor($width,$height);
// Dark red background
$bg = imagecolorallocate($img, 0xAA, 0x00, 0x00);
imagefilledrectangle($img, 0, 0,$width ,$height , $bg);
// White font color
$color = imagecolorallocate($img, 255, 255, 255);
foreach ($ts as $k=>$string) {
// Length of the string
$len = strlen($string);
// Y-coordinate of character, X changes, Y is static
$ypos_offset = 5;
$xpos_offset = 5;
// Loop through the string
for($i=0;$i<$len;$i++){
// Position of the character horizontally
$xpos = $i * $em + $ypos_offset;
$ypos = $k * $el + $xpos_offset;
// Draw character
imagechar($img, $font_size, $xpos, $ypos, $string, $color);
// Remove character from string
$string = substr($string, 1);
}
}
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
}else{
header("Content-type: image/png");
echo $data;
}
}
public function saveImage($data = FALSE){
$img = array();
$img['file'] = tempnam($this->config->conf['temp'],"PNP");
if(!$fh = fopen($img['file'],'w') ){
throw new Kohana_Exception('save-rrd-image', $img['file']);
}
fwrite($fh, $data);
fclose($fh);
if (function_exists('imagecreatefrompng')) {
$image = imagecreatefrompng($img['file']);
imagepng($image, $img['file']);
list ($img['width'], $img['height'], $img['type'], $img['attr']) = getimagesize($img['file']);
}else{
throw new Kohana_Exception('error.gd-missing');
}
return $img;
}
private function format_rrd_debug($data) {
$data = preg_replace('/(HRULE|VDEF|DEF|CDEF|GPRINT|LINE|AREA|COMMENT)/',"\n\${1}", $data);
return $data;
}
}

View File

@@ -0,0 +1,14 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Retrieves the PNP config files
*/
class System_Model extends Model {
public $ERROR = NULL;
public function __construct() {
}
}

View File

@@ -0,0 +1,98 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
if (!defined('ORD_z'))
define('ORD_z',ord('z'));
if (!defined('ORD_exclmark'))
define('ORD_exclmark', ord('!'));
if (!defined('ORD_u'))
define('ORD_u', ord('u'));
if (!defined('ORD_tilde'))
define('ORD_tilde', ord('~'));
class FilterASCII85 {
function error($msg) {
die($msg);
}
function decode($in) {
$out = '';
$state = 0;
$chn = null;
$l = strlen($in);
for ($k = 0; $k < $l; ++$k) {
$ch = ord($in[$k]) & 0xff;
if ($ch == ORD_tilde) {
break;
}
if (preg_match('/^\s$/',chr($ch))) {
continue;
}
if ($ch == ORD_z && $state == 0) {
$out .= chr(0).chr(0).chr(0).chr(0);
continue;
}
if ($ch < ORD_exclmark || $ch > ORD_u) {
$this->error('Illegal character in ASCII85Decode.');
}
$chn[$state++] = $ch - ORD_exclmark;
if ($state == 5) {
$state = 0;
$r = 0;
for ($j = 0; $j < 5; ++$j)
$r = $r * 85 + $chn[$j];
$out .= chr($r >> 24);
$out .= chr($r >> 16);
$out .= chr($r >> 8);
$out .= chr($r);
}
}
$r = 0;
if ($state == 1)
$this->error('Illegal length in ASCII85Decode.');
if ($state == 2) {
$r = $chn[0] * 85 * 85 * 85 * 85 + ($chn[1]+1) * 85 * 85 * 85;
$out .= chr($r >> 24);
}
else if ($state == 3) {
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + ($chn[2]+1) * 85 * 85;
$out .= chr($r >> 24);
$out .= chr($r >> 16);
}
else if ($state == 4) {
$r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + $chn[2] * 85 * 85 + ($chn[3]+1) * 85 ;
$out .= chr($r >> 24);
$out .= chr($r >> 16);
$out .= chr($r >> 8);
}
return $out;
}
function encode($in) {
$this->error("ASCII85 encoding not implemented.");
}
}

View File

@@ -0,0 +1,33 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
require_once('FilterASCII85.php');
class FilterASCII85_FPDI extends FilterASCII85 {
var $fpdi;
function FPDI_FilterASCII85(&$fpdi) {
$this->fpdi =& $fpdi;
}
function error($msg) {
$this->fpdi->error($msg);
}
}

View File

@@ -0,0 +1,154 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class FilterLZW {
var $sTable = array();
var $data = null;
var $dataLength = 0;
var $tIdx;
var $bitsToGet = 9;
var $bytePointer;
var $bitPointer;
var $nextData = 0;
var $nextBits = 0;
var $andTable = array(511, 1023, 2047, 4095);
function error($msg) {
die($msg);
}
/**
* Method to decode LZW compressed data.
*
* @param string data The compressed data.
*/
function decode($data) {
if($data[0] == 0x00 && $data[1] == 0x01) {
$this->error('LZW flavour not supported.');
}
$this->initsTable();
$this->data = $data;
$this->dataLength = strlen($data);
// Initialize pointers
$this->bytePointer = 0;
$this->bitPointer = 0;
$this->nextData = 0;
$this->nextBits = 0;
$oldCode = 0;
$string = '';
$uncompData = '';
while (($code = $this->getNextCode()) != 257) {
if ($code == 256) {
$this->initsTable();
$code = $this->getNextCode();
if ($code == 257) {
break;
}
$uncompData .= $this->sTable[$code];
$oldCode = $code;
} else {
if ($code < $this->tIdx) {
$string = $this->sTable[$code];
$uncompData .= $string;
$this->addStringToTable($this->sTable[$oldCode], $string[0]);
$oldCode = $code;
} else {
$string = $this->sTable[$oldCode];
$string = $string.$string[0];
$uncompData .= $string;
$this->addStringToTable($string);
$oldCode = $code;
}
}
}
return $uncompData;
}
/**
* Initialize the string table.
*/
function initsTable() {
$this->sTable = array();
for ($i = 0; $i < 256; $i++)
$this->sTable[$i] = chr($i);
$this->tIdx = 258;
$this->bitsToGet = 9;
}
/**
* Add a new string to the string table.
*/
function addStringToTable ($oldString, $newString='') {
$string = $oldString.$newString;
// Add this new String to the table
$this->sTable[$this->tIdx++] = $string;
if ($this->tIdx == 511) {
$this->bitsToGet = 10;
} else if ($this->tIdx == 1023) {
$this->bitsToGet = 11;
} else if ($this->tIdx == 2047) {
$this->bitsToGet = 12;
}
}
// Returns the next 9, 10, 11 or 12 bits
function getNextCode() {
if ($this->bytePointer == $this->dataLength) {
return 257;
}
$this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
$this->nextBits += 8;
if ($this->nextBits < $this->bitsToGet) {
$this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff);
$this->nextBits += 8;
}
$code = ($this->nextData >> ($this->nextBits - $this->bitsToGet)) & $this->andTable[$this->bitsToGet-9];
$this->nextBits -= $this->bitsToGet;
return $code;
}
function encode($in) {
$this->error("LZW encoding not implemented.");
}
}

View File

@@ -0,0 +1,33 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
require_once('FilterLZW.php');
class FilterLZW_FPDI extends FilterLZW {
var $fpdi;
function FilterLZW_FPDI(&$fpdi) {
$this->fpdi =& $fpdi;
}
function error($msg) {
$this->fpdi->error($msg);
}
}

View File

@@ -0,0 +1,7 @@
<?php
for($i=0;$i<=255;$i++)
$fpdf_charwidths['courier'][chr($i)]=600;
$fpdf_charwidths['courierB']=$fpdf_charwidths['courier'];
$fpdf_charwidths['courierI']=$fpdf_charwidths['courier'];
$fpdf_charwidths['courierBI']=$fpdf_charwidths['courier'];
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['helvetica']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['helveticaB']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['helveticaBI']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['helveticaI']=array(
chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['symbol']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549,
','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722,
'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768,
'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576,
'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0,
chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603,
chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768,
chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042,
chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329,
chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['times']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722,
'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944,
'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333,
chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['timesB']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722,
'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000,
'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833,
'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333,
chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['timesBI']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667,
'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889,
'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333,
chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['timesI']=array(
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675,
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611,
'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833,
'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722,
'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980,
chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333,
chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611,
chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444);
?>

View File

@@ -0,0 +1,15 @@
<?php
$fpdf_charwidths['zapfdingbats']=array(
chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
?>

1732
share/pnp/application/vendor/fpdf/fpdf.php vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,409 @@
<?php
//
// FPDF_TPL - Version 1.1.3
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class FPDF_TPL extends FPDF {
/**
* Array of Tpl-Data
* @var array
*/
var $tpls = array();
/**
* Current Template-ID
* @var int
*/
var $tpl = 0;
/**
* "In Template"-Flag
* @var boolean
*/
var $_intpl = false;
/**
* Nameprefix of Templates used in Resources-Dictonary
* @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an /
*/
var $tplprefix = "/TPL";
/**
* Resources used By Templates and Pages
* @var array
*/
var $_res = array();
/**
* Last used Template data
*
* @var array
*/
var $lastUsedTemplateData = array();
/**
* Start a Template
*
* This method starts a template. You can give own coordinates to build an own sized
* Template. Pay attention, that the margins are adapted to the new templatesize.
* If you want to write outside the template, for example to build a clipped Template,
* you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call.
*
* If no parameter is given, the template uses the current page-size.
* The Method returns an ID of the current Template. This ID is used later for using this template.
* Warning: A created Template is used in PDF at all events. Still if you don't use it after creation!
*
* @param int $x The x-coordinate given in user-unit
* @param int $y The y-coordinate given in user-unit
* @param int $w The width given in user-unit
* @param int $h The height given in user-unit
* @return int The ID of new created Template
*/
function beginTemplate($x=null, $y=null, $w=null, $h=null) {
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if ($x == null)
$x = 0;
if ($y == null)
$y = 0;
if ($w == null)
$w = $this->w;
if ($h == null)
$h = $this->h;
// Save settings
$this->tpl++;
$tpl =& $this->tpls[$this->tpl];
$tpl = array(
'o_x' => $this->x,
'o_y' => $this->y,
'o_AutoPageBreak' => $this->AutoPageBreak,
'o_bMargin' => $this->bMargin,
'o_tMargin' => $this->tMargin,
'o_lMargin' => $this->lMargin,
'o_rMargin' => $this->rMargin,
'o_h' => $this->h,
'o_w' => $this->w,
'buffer' => '',
'x' => $x,
'y' => $y,
'w' => $w,
'h' => $h
);
$this->SetAutoPageBreak(false);
// Define own high and width to calculate possitions correct
$this->h = $h;
$this->w = $w;
$this->_intpl = true;
$this->SetXY($x+$this->lMargin, $y+$this->tMargin);
$this->SetRightMargin($this->w-$w+$this->rMargin);
return $this->tpl;
}
/**
* End Template
*
* This method ends a template and reset initiated variables on beginTemplate.
*
* @return mixed If a template is opened, the ID is returned. If not a false is returned.
*/
function endTemplate() {
if ($this->_intpl) {
$this->_intpl = false;
$tpl =& $this->tpls[$this->tpl];
$this->SetXY($tpl['o_x'], $tpl['o_y']);
$this->tMargin = $tpl['o_tMargin'];
$this->lMargin = $tpl['o_lMargin'];
$this->rMargin = $tpl['o_rMargin'];
$this->h = $tpl['o_h'];
$this->w = $tpl['o_w'];
$this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']);
return $this->tpl;
} else {
return false;
}
}
/**
* Use a Template in current Page or other Template
*
* You can use a template in a page or in another template.
* You can give the used template a new size like you use the Image()-method.
* All parameters are optional. The width or height is calculated automaticaly
* if one is given. If no parameter is given the origin size as defined in
* beginTemplate() is used.
* The calculated or used width and height are returned as an array.
*
* @param int $tplidx A valid template-Id
* @param int $_x The x-position
* @param int $_y The y-position
* @param int $_w The new width of the template
* @param int $_h The new height of the template
* @retrun array The height and width of the template
*/
function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) {
if ($this->page <= 0)
$this->error("You have to add a page to fpdf first!");
if (!isset($this->tpls[$tplidx]))
$this->error("Template does not exist!");
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx];
}
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_x == null)
$_x = 0;
if ($_y == null)
$_y = 0;
$_x += $tpl['x'];
$_y += $tpl['y'];
$wh = $this->getTemplateSize($tplidx, $_w, $_h);
$_w = $wh['w'];
$_h = $wh['h'];
$tData = array(
'x' => $this->x,
'y' => $this->y,
'w' => $_w,
'h' => $_h,
'scaleX' => ($_w/$w),
'scaleY' => ($_h/$h),
'tx' => $_x,
'ty' => ($this->h-$_y-$_h),
'lty' => ($this->h-$_y-$_h) - ($this->h-$h) * ($_h/$h)
);
$this->_out(sprintf("q %.4F 0 0 %.4F %.4F %.4F cm", $tData['scaleX'], $tData['scaleY'], $tData['tx']*$this->k, $tData['ty']*$this->k)); // Translate
$this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx));
$this->lastUsedTemplateData = $tData;
return array("w" => $_w, "h" => $_h);
}
/**
* Get The calculated Size of a Template
*
* If one size is given, this method calculates the other one.
*
* @param int $tplidx A valid template-Id
* @param int $_w The width of the template
* @param int $_h The height of the template
* @return array The height and width of the template
*/
function getTemplateSize($tplidx, $_w=0, $_h=0) {
if (!$this->tpls[$tplidx])
return false;
$tpl =& $this->tpls[$tplidx];
$w = $tpl['w'];
$h = $tpl['h'];
if ($_w == 0 and $_h == 0) {
$_w = $w;
$_h = $h;
}
if($_w==0)
$_w = $_h*$w/$h;
if($_h==0)
$_h = $_w*$h/$w;
return array("w" => $_w, "h" => $_h);
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function SetFont($family, $style='', $size=0, $fontfile='') {
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 3) {
$this->Error('More than 3 arguments for the SetFont method are only available in TCPDF.');
}
/**
* force the resetting of font changes in a template
*/
if ($this->_intpl)
$this->FontFamily = '';
parent::SetFont($family, $style, $size, $fontfile);
$fontkey = $this->FontFamily.$this->FontStyle;
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey];
} else {
$this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey];
}
}
/**
* See FPDF/TCPDF-Documentation ;-)
*/
function Image($file, $x, $y, $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0) {
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 7) {
$this->Error('More than 7 arguments for the Image method are only available in TCPDF.');
}
parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi, $palign, $ismask, $imgmask, $border);
if ($this->_intpl) {
$this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file];
} else {
$this->_res['page'][$this->page]['images'][$file] =& $this->images[$file];
}
}
/**
* See FPDF-Documentation ;-)
*
* AddPage is not available when you're "in" a template.
*/
function AddPage($orientation='', $format='') {
if ($this->_intpl)
$this->Error('Adding pages in templates isn\'t possible!');
parent::AddPage($orientation, $format);
}
/**
* Preserve adding Links in Templates ...won't work
*/
function Link($x, $y, $w, $h, $link, $spaces=0) {
if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 5) {
$this->Error('More than 7 arguments for the Image method are only available in TCPDF.');
}
if ($this->_intpl)
$this->Error('Using links in templates aren\'t possible!');
parent::Link($x, $y, $w, $h, $link, $spaces);
}
function AddLink() {
if ($this->_intpl)
$this->Error('Adding links in templates aren\'t possible!');
return parent::AddLink();
}
function SetLink($link, $y=0, $page=-1) {
if ($this->_intpl)
$this->Error('Setting links in templates aren\'t possible!');
parent::SetLink($link, $y, $page);
}
/**
* Private Method that writes the form xobjects
*/
function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
// llx
$tpl['x'],
// lly
-$tpl['y'],
// urx
($tpl['w']+$tpl['x'])*$this->k,
// ury
($tpl['h']-$tpl['y'])*$this->k
));
if ($tpl['x'] != 0 || $tpl['y'] != 0) {
$this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]',
-$tpl['x']*$this->k*2, $tpl['y']*$this->k*2
));
}
$this->_out('/Resources ');
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
$this->_out('>>');
}
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
}
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
$this->_out('/Length '.strlen($p).' >>');
$this->_putstream($p);
$this->_out('endobj');
}
}
/**
* Overwritten to add _putformxobjects() after _putimages()
*
*/
function _putimages() {
parent::_putimages();
$this->_putformxobjects();
}
function _putxobjectdict() {
parent::_putxobjectdict();
if (count($this->tpls)) {
foreach($this->tpls as $tplidx => $tpl) {
$this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']));
}
}
}
/**
* Private Method
*/
function _out($s) {
if ($this->state==2 && $this->_intpl) {
$this->tpls[$this->tpl]['buffer'] .= $s."\n";
} else {
parent::_out($s);
}
}
}

View File

@@ -0,0 +1,505 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
define('FPDI_VERSION','1.3.1');
// Check for TCPDF and remap TCPDF to FPDF
if (class_exists('TCPDF')) {
require_once('fpdi2tcpdf_bridge.php');
}
require_once('fpdf_tpl.php');
require_once('fpdi_pdf_parser.php');
class FPDI extends FPDF_TPL {
/**
* Actual filename
* @var string
*/
var $current_filename;
/**
* Parser-Objects
* @var array
*/
var $parsers;
/**
* Current parser
* @var object
*/
var $current_parser;
/**
* object stack
* @var array
*/
var $_obj_stack;
/**
* done object stack
* @var array
*/
var $_don_obj_stack;
/**
* Current Object Id.
* @var integer
*/
var $_current_obj_id;
/**
* The name of the last imported page box
* @var string
*/
var $lastUsedPageBox;
var $_importedPages = array();
/**
* Set a source-file
*
* @param string $filename a valid filename
* @return int number of available pages
*/
function setSourceFile($filename) {
$this->current_filename = $filename;
$fn =& $this->current_filename;
if (!isset($this->parsers[$fn]))
$this->parsers[$fn] = new fpdi_pdf_parser($fn, $this);
$this->current_parser =& $this->parsers[$fn];
return $this->parsers[$fn]->getPageCount();
}
/**
* Import a page
*
* @param int $pageno pagenumber
* @return int Index of imported page - to use with fpdf_tpl::useTemplate()
*/
function importPage($pageno, $boxName='/CropBox') {
if ($this->_intpl) {
return $this->error('Please import the desired pages before creating a new template.');
}
$fn =& $this->current_filename;
// check if page already imported
$pageKey = $fn.((int)$pageno).$boxName;
if (isset($this->_importedPages[$pageKey]))
return $this->_importedPages[$pageKey];
$parser =& $this->parsers[$fn];
$parser->setPageno($pageno);
$this->tpl++;
$this->tpls[$this->tpl] = array();
$tpl =& $this->tpls[$this->tpl];
$tpl['parser'] =& $parser;
$tpl['resources'] = $parser->getPageResources();
$tpl['buffer'] = $parser->getContent();
if (!in_array($boxName, $parser->availableBoxes))
return $this->Error(sprintf('Unknown box: %s', $boxName));
$pageboxes = $parser->getPageBoxes($pageno);
/**
* MediaBox
* CropBox: Default -> MediaBox
* BleedBox: Default -> CropBox
* TrimBox: Default -> CropBox
* ArtBox: Default -> CropBox
*/
if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox'))
$boxName = '/CropBox';
if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox')
$boxName = '/MediaBox';
if (!isset($pageboxes[$boxName]))
return false;
$this->lastUsedPageBox = $boxName;
$box = $pageboxes[$boxName];
$tpl['box'] = $box;
// To build an array that can be used by PDF_TPL::useTemplate()
$this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl],$box);
// An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects()
$tpl['x'] = 0;
$tpl['y'] = 0;
$page =& $parser->pages[$parser->pageno];
// handle rotated pages
$rotation = $parser->getPageRotation($pageno);
$tpl['_rotationAngle'] = 0;
if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) {
$steps = $angle / 90;
$_w = $tpl['w'];
$_h = $tpl['h'];
$tpl['w'] = $steps % 2 == 0 ? $_w : $_h;
$tpl['h'] = $steps % 2 == 0 ? $_h : $_w;
$tpl['_rotationAngle'] = $angle*-1;
}
$this->_importedPages[$pageKey] = $this->tpl;
return $this->tpl;
}
function getLastUsedPageBox() {
return $this->lastUsedPageBox;
}
function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0, $adjustPageSize=false) {
if ($adjustPageSize == true && is_null($_x) && is_null($_y)) {
$size = $this->getTemplateSize($tplidx, $_w, $_h);
$format = array($size['w'], $size['h']);
if ($format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) {
$this->w=$format[0];
$this->h=$format[1];
$this->wPt=$this->w*$this->k;
$this->hPt=$this->h*$this->k;
$this->PageBreakTrigger=$this->h-$this->bMargin;
$this->CurPageFormat=$format;
$this->PageSizes[$this->page]=array($this->wPt, $this->hPt);
}
}
$this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values
$s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h);
$this->_out('Q');
return $s;
}
/**
* Private method, that rebuilds all needed objects of source files
*/
function _putimportedobjects() {
if (is_array($this->parsers) && count($this->parsers) > 0) {
foreach($this->parsers AS $filename => $p) {
$this->current_parser =& $this->parsers[$filename];
if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) {
while(($n = key($this->_obj_stack[$filename])) !== null) {
$nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c,$this->_obj_stack[$filename][$n][1]);
$this->_newobj($this->_obj_stack[$filename][$n][0]);
if ($nObj[0] == PDF_TYPE_STREAM) {
$this->pdf_write_value ($nObj);
} else {
$this->pdf_write_value ($nObj[1]);
}
$this->_out('endobj');
$this->_obj_stack[$filename][$n] = null; // free memory
unset($this->_obj_stack[$filename][$n]);
reset($this->_obj_stack[$filename]);
}
}
}
}
}
/**
* Private Method that writes the form xobjects
*/
function _putformxobjects() {
$filter=($this->compress) ? '/Filter /FlateDecode ' : '';
reset($this->tpls);
foreach($this->tpls AS $tplidx => $tpl) {
$p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer'];
$this->_newobj();
$cN = $this->n; // TCPDF/Protection: rem current "n"
$this->tpls[$tplidx]['n'] = $this->n;
$this->_out('<<'.$filter.'/Type /XObject');
$this->_out('/Subtype /Form');
$this->_out('/FormType 1');
$this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]',
(isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x'])*$this->k,
(isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y'])*$this->k,
(isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x'])*$this->k,
(isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h']-$tpl['y'])*$this->k
));
$c = 1;
$s = 0;
$tx = 0;
$ty = 0;
if (isset($tpl['box'])) {
$tx = -$tpl['box']['llx'];
$ty = -$tpl['box']['lly'];
if ($tpl['_rotationAngle'] <> 0) {
$angle = $tpl['_rotationAngle'] * M_PI/180;
$c=cos($angle);
$s=sin($angle);
switch($tpl['_rotationAngle']) {
case -90:
$tx = -$tpl['box']['lly'];
$ty = $tpl['box']['urx'];
break;
case -180:
$tx = $tpl['box']['urx'];
$ty = $tpl['box']['ury'];
break;
case -270:
$tx = $tpl['box']['ury'];
$ty = 0;
break;
}
}
} else if ($tpl['x'] != 0 || $tpl['y'] != 0) {
$tx = -$tpl['x']*2;
$ty = $tpl['y']*2;
}
$tx *= $this->k;
$ty *= $this->k;
if ($c != 1 || $s != 0 || $tx != 0 || $ty != 0) {
$this->_out(sprintf('/Matrix [%.5F %.5F %.5F %.5F %.5F %.5F]',
$c, $s, -$s, $c, $tx, $ty
));
}
$this->_out('/Resources ');
if (isset($tpl['resources'])) {
$this->current_parser =& $tpl['parser'];
$this->pdf_write_value($tpl['resources']); // "n" will be changed
} else {
$this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
$this->_out('/Font <<');
foreach($this->_res['tpl'][$tplidx]['fonts'] as $font)
$this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
$this->_out('>>');
}
if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) ||
isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls']))
{
$this->_out('/XObject <<');
if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
foreach($this->_res['tpl'][$tplidx]['images'] as $image)
$this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
}
if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl)
$this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R');
}
$this->_out('>>');
}
$this->_out('>>');
}
$nN = $this->n; // TCPDF: rem new "n"
$this->n = $cN; // TCPDF: reset to current "n"
$this->_out('/Length '.strlen($p).' >>');
$this->_putstream($p);
$this->_out('endobj');
$this->n = $nN; // TCPDF: reset to new "n"
}
$this->_putimportedobjects();
}
/**
* Rewritten to handle existing own defined objects
*/
function _newobj($obj_id=false,$onlynewobj=false) {
if (!$obj_id) {
$obj_id = ++$this->n;
}
//Begin a new object
if (!$onlynewobj) {
$this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer);
$this->_out($obj_id.' 0 obj');
$this->_current_obj_id = $obj_id; // for later use with encryption
}
return $obj_id;
}
/**
* Writes a value
* Needed to rebuild the source document
*
* @param mixed $value A PDF-Value. Structure of values see cases in this method
*/
function pdf_write_value(&$value)
{
if (is_subclass_of($this, 'TCPDF')) {
parent::pdf_write_value($value);
}
switch ($value[0]) {
case PDF_TYPE_TOKEN :
$this->_straightOut($value[1] . ' ');
break;
case PDF_TYPE_NUMERIC :
case PDF_TYPE_REAL :
if (is_float($value[1]) && $value[1] != 0) {
$this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') .' ');
} else {
$this->_straightOut($value[1] . ' ');
}
break;
case PDF_TYPE_ARRAY :
// An array. Output the proper
// structure and move on.
$this->_straightOut('[');
for ($i = 0; $i < count($value[1]); $i++) {
$this->pdf_write_value($value[1][$i]);
}
$this->_out(']');
break;
case PDF_TYPE_DICTIONARY :
// A dictionary.
$this->_straightOut('<<');
reset ($value[1]);
while (list($k, $v) = each($value[1])) {
$this->_straightOut($k . ' ');
$this->pdf_write_value($v);
}
$this->_straightOut('>>');
break;
case PDF_TYPE_OBJREF :
// An indirect object reference
// Fill the object stack if needed
$cpfn =& $this->current_parser->filename;
if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) {
$this->_newobj(false,true);
$this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value);
$this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!!
}
$objid = $this->_don_obj_stack[$cpfn][$value[1]][0];
$this->_out($objid.' 0 R');
break;
case PDF_TYPE_STRING :
// A string.
$this->_straightOut('('.$value[1].')');
break;
case PDF_TYPE_STREAM :
// A stream. First, output the
// stream dictionary, then the
// stream data itself.
$this->pdf_write_value($value[1]);
$this->_out('stream');
$this->_out($value[2][1]);
$this->_out('endstream');
break;
case PDF_TYPE_HEX :
$this->_straightOut('<'.$value[1].'>');
break;
case PDF_TYPE_BOOLEAN :
$this->_straightOut($value[1] ? 'true ' : 'false ');
break;
case PDF_TYPE_NULL :
// The null object.
$this->_straightOut('null ');
break;
}
}
/**
* Modified so not each call will add a newline to the output.
*/
function _straightOut($s) {
if (!is_subclass_of($this, 'TCPDF')) {
if($this->state==2)
$this->pages[$this->page] .= $s;
else
$this->buffer .= $s;
} else {
if ($this->state == 2) {
if (isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) {
// puts data before page footer
$page = substr($this->getPageBuffer($this->page), 0, -$this->footerlen[$this->page]);
$footer = substr($this->getPageBuffer($this->page), -$this->footerlen[$this->page]);
$this->setPageBuffer($this->page, $page.' '.$s."\n".$footer);
} else {
$this->setPageBuffer($this->page, $s, true);
}
} else {
$this->setBuffer($s);
}
}
}
/**
* rewritten to close opened parsers
*
*/
function _enddoc() {
parent::_enddoc();
$this->_closeParsers();
}
/**
* close all files opened by parsers
*/
function _closeParsers() {
if ($this->state > 2 && count($this->parsers) > 0) {
foreach ($this->parsers as $k => $_){
$this->parsers[$k]->closeFile();
$this->parsers[$k] = null;
unset($this->parsers[$k]);
}
return true;
}
return false;
}
}

View File

@@ -0,0 +1,171 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/**
* This class is used as a bridge between TCPDF and FPDI
* and will create the possibility to use both FPDF and TCPDF
* via one FPDI version.
*
* We'll simply remap TCPDF to FPDF again.
*
* It'll be loaded and extended by FPDF_TPL.
*/
class FPDF extends TCPDF {
function __get($name) {
switch ($name) {
case 'PDFVersion':
return $this->PDFVersion;
case 'k':
return $this->k;
default:
// Error handling
$this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name);
}
}
function __set($name, $value) {
switch ($name) {
case 'PDFVersion':
$this->PDFVersion = $value;
break;
default:
// Error handling
$this->Error('Cannot access protected property '.get_class($this).':$'.$name.' / Undefined property: '.get_class($this).'::$'.$name);
}
}
/**
* Encryption of imported data by FPDI
*
* @param array $value
*/
function pdf_write_value(&$value) {
switch ($value[0]) {
case PDF_TYPE_STRING :
if ($this->encrypted) {
$value[1] = $this->_unescape($value[1]);
$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
$value[1] = $this->_escape($value[1]);
}
break;
case PDF_TYPE_STREAM :
if ($this->encrypted) {
$value[2][1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[2][1]);
}
break;
case PDF_TYPE_HEX :
if ($this->encrypted) {
$value[1] = $this->hex2str($value[1]);
$value[1] = $this->_RC4($this->_objectkey($this->_current_obj_id), $value[1]);
// remake hexstring of encrypted string
$value[1] = $this->str2hex($value[1]);
}
break;
}
}
/**
* Unescapes a PDF string
*
* @param string $s
* @return string
*/
function _unescape($s) {
$out = '';
for ($count = 0, $n = strlen($s); $count < $n; $count++) {
if ($s[$count] != '\\' || $count == $n-1) {
$out .= $s[$count];
} else {
switch ($s[++$count]) {
case ')':
case '(':
case '\\':
$out .= $s[$count];
break;
case 'f':
$out .= chr(0x0C);
break;
case 'b':
$out .= chr(0x08);
break;
case 't':
$out .= chr(0x09);
break;
case 'r':
$out .= chr(0x0D);
break;
case 'n':
$out .= chr(0x0A);
break;
case "\r":
if ($count != $n-1 && $s[$count+1] == "\n")
$count++;
break;
case "\n":
break;
default:
// Octal-Values
if (ord($s[$count]) >= ord('0') &&
ord($s[$count]) <= ord('9')) {
$oct = ''. $s[$count];
if (ord($s[$count+1]) >= ord('0') &&
ord($s[$count+1]) <= ord('9')) {
$oct .= $s[++$count];
if (ord($s[$count+1]) >= ord('0') &&
ord($s[$count+1]) <= ord('9')) {
$oct .= $s[++$count];
}
}
$out .= chr(octdec($oct));
} else {
$out .= $s[$count];
}
}
}
}
return $out;
}
/**
* Hexadecimal to string
*
* @param string $hex
* @return string
*/
function hex2str($hex) {
return pack('H*', str_replace(array("\r", "\n", ' '), '', $hex));
}
/**
* String to hexadecimal
*
* @param string $str
* @return string
*/
function str2hex($str) {
return current(unpack('H*', $str));
}
}

View File

@@ -0,0 +1,384 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
require_once('pdf_parser.php');
class fpdi_pdf_parser extends pdf_parser {
/**
* Pages
* Index beginns at 0
*
* @var array
*/
var $pages;
/**
* Page count
* @var integer
*/
var $page_count;
/**
* actual page number
* @var integer
*/
var $pageno;
/**
* PDF Version of imported Document
* @var string
*/
var $pdfVersion;
/**
* FPDI Reference
* @var object
*/
var $fpdi;
/**
* Available BoxTypes
*
* @var array
*/
var $availableBoxes = array('/MediaBox', '/CropBox', '/BleedBox', '/TrimBox', '/ArtBox');
/**
* Constructor
*
* @param string $filename Source-Filename
* @param object $fpdi Object of type fpdi
*/
function fpdi_pdf_parser($filename, &$fpdi) {
$this->fpdi =& $fpdi;
parent::pdf_parser($filename);
// resolve Pages-Dictonary
$pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']);
// Read pages
$this->read_pages($this->c, $pages, $this->pages);
// count pages;
$this->page_count = count($this->pages);
}
/**
* Overwrite parent::error()
*
* @param string $msg Error-Message
*/
function error($msg) {
$this->fpdi->error($msg);
}
/**
* Get pagecount from sourcefile
*
* @return int
*/
function getPageCount() {
return $this->page_count;
}
/**
* Set pageno
*
* @param int $pageno Pagenumber to use
*/
function setPageno($pageno) {
$pageno = ((int) $pageno) - 1;
if ($pageno < 0 || $pageno >= $this->getPageCount()) {
$this->fpdi->error('Pagenumber is wrong!');
}
$this->pageno = $pageno;
}
/**
* Get page-resources from current page
*
* @return array
*/
function getPageResources() {
return $this->_getPageResources($this->pages[$this->pageno]);
}
/**
* Get page-resources from /Page
*
* @param array $obj Array of pdf-data
*/
function _getPageResources ($obj) { // $obj = /Page
$obj = $this->pdf_resolve_object($this->c, $obj);
// If the current object has a resources
// dictionary associated with it, we use
// it. Otherwise, we move back to its
// parent object.
if (isset ($obj[1][1]['/Resources'])) {
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']);
if ($res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
} else {
if (!isset ($obj[1][1]['/Parent'])) {
return false;
} else {
$res = $this->_getPageResources($obj[1][1]['/Parent']);
if ($res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
}
}
}
/**
* Get content of current page
*
* If more /Contents is an array, the streams are concated
*
* @return string
*/
function getContent() {
$buffer = '';
if (isset($this->pages[$this->pageno][1][1]['/Contents'])) {
$contents = $this->_getPageContent($this->pages[$this->pageno][1][1]['/Contents']);
foreach($contents AS $tmp_content) {
$buffer .= $this->_rebuildContentStream($tmp_content).' ';
}
}
return $buffer;
}
/**
* Resolve all content-objects
*
* @param array $content_ref
* @return array
*/
function _getPageContent($content_ref) {
$contents = array();
if ($content_ref[0] == PDF_TYPE_OBJREF) {
$content = $this->pdf_resolve_object($this->c, $content_ref);
if ($content[1][0] == PDF_TYPE_ARRAY) {
$contents = $this->_getPageContent($content[1]);
} else {
$contents[] = $content;
}
} else if ($content_ref[0] == PDF_TYPE_ARRAY) {
foreach ($content_ref[1] AS $tmp_content_ref) {
$contents = array_merge($contents,$this->_getPageContent($tmp_content_ref));
}
}
return $contents;
}
/**
* Rebuild content-streams
*
* @param array $obj
* @return string
*/
function _rebuildContentStream($obj) {
$filters = array();
if (isset($obj[1][1]['/Filter'])) {
$_filter = $obj[1][1]['/Filter'];
if ($_filter[0] == PDF_TYPE_TOKEN) {
$filters[] = $_filter;
} else if ($_filter[0] == PDF_TYPE_ARRAY) {
$filters = $_filter[1];
}
}
$stream = $obj[2][1];
foreach ($filters AS $_filter) {
switch ($_filter[1]) {
case '/FlateDecode':
if (function_exists('gzuncompress')) {
$stream = (strlen($stream) > 0) ? @gzuncompress($stream) : '';
} else {
$this->error(sprintf('To handle %s filter, please compile php with zlib support.',$_filter[1]));
}
if ($stream === false) {
$this->error('Error while decompressing stream.');
}
break;
case '/LZWDecode':
include_once('filters/FilterLZW_FPDI.php');
$decoder = new FilterLZW_FPDI($this->fpdi);
$stream = $decoder->decode($stream);
break;
case '/ASCII85Decode':
include_once('filters/FilterASCII85_FPDI.php');
$decoder = new FilterASCII85_FPDI($this->fpdi);
$stream = $decoder->decode($stream);
break;
case null:
$stream = $stream;
break;
default:
$this->error(sprintf('Unsupported Filter: %s',$_filter[1]));
}
}
return $stream;
}
/**
* Get a Box from a page
* Arrayformat is same as used by fpdf_tpl
*
* @param array $page a /Page
* @param string $box_index Type of Box @see $availableBoxes
* @return array
*/
function getPageBox($page, $box_index) {
$page = $this->pdf_resolve_object($this->c,$page);
$box = null;
if (isset($page[1][1][$box_index]))
$box =& $page[1][1][$box_index];
if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) {
$tmp_box = $this->pdf_resolve_object($this->c,$box);
$box = $tmp_box[1];
}
if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) {
$b =& $box[1];
return array('x' => $b[0][1]/$this->fpdi->k,
'y' => $b[1][1]/$this->fpdi->k,
'w' => abs($b[0][1]-$b[2][1])/$this->fpdi->k,
'h' => abs($b[1][1]-$b[3][1])/$this->fpdi->k,
'llx' => min($b[0][1], $b[2][1])/$this->fpdi->k,
'lly' => min($b[1][1], $b[3][1])/$this->fpdi->k,
'urx' => max($b[0][1], $b[2][1])/$this->fpdi->k,
'ury' => max($b[1][1], $b[3][1])/$this->fpdi->k,
);
} else if (!isset ($page[1][1]['/Parent'])) {
return false;
} else {
return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index);
}
}
function getPageBoxes($pageno) {
return $this->_getPageBoxes($this->pages[$pageno-1]);
}
/**
* Get all Boxes from /Page
*
* @param array a /Page
* @return array
*/
function _getPageBoxes($page) {
$boxes = array();
foreach($this->availableBoxes AS $box) {
if ($_box = $this->getPageBox($page,$box)) {
$boxes[$box] = $_box;
}
}
return $boxes;
}
/**
* Get the page rotation by pageno
*
* @param integer $pageno
* @return array
*/
function getPageRotation($pageno) {
return $this->_getPageRotation($this->pages[$pageno-1]);
}
function _getPageRotation ($obj) { // $obj = /Page
$obj = $this->pdf_resolve_object($this->c, $obj);
if (isset ($obj[1][1]['/Rotate'])) {
$res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Rotate']);
if ($res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
} else {
if (!isset ($obj[1][1]['/Parent'])) {
return false;
} else {
$res = $this->_getPageRotation($obj[1][1]['/Parent']);
if ($res[0] == PDF_TYPE_OBJECT)
return $res[1];
return $res;
}
}
}
/**
* Read all /Page(es)
*
* @param object pdf_context
* @param array /Pages
* @param array the result-array
*/
function read_pages (&$c, &$pages, &$result) {
// Get the kids dictionary
$kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']);
if (!is_array($kids))
$this->error('Cannot find /Kids in current /Page-Dictionary');
foreach ($kids[1] as $v) {
$pg = $this->pdf_resolve_object ($c, $v);
if ($pg[1][1]['/Type'][1] === '/Pages') {
// If one of the kids is an embedded
// /Pages array, resolve it as well.
$this->read_pages ($c, $pg, $result);
} else {
$result[] = $pg;
}
}
}
/**
* Get PDF-Version
*
* And reset the PDF Version used in FPDI if needed
*/
function getPDFVersion() {
parent::getPDFVersion();
$this->fpdi->PDFVersion = max($this->fpdi->PDFVersion, $this->pdfVersion);
}
}

View File

@@ -0,0 +1,6 @@
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software to use, copy, modify, distribute, sublicense, and/or sell
copies of the software, and to permit persons to whom the software is furnished
to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.

View File

@@ -0,0 +1,97 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
class pdf_context {
/**
* Modi
*
* @var integer 0 = file | 1 = string
*/
var $_mode = 0;
var $file;
var $buffer;
var $offset;
var $length;
var $stack;
// Constructor
function pdf_context(&$f) {
$this->file =& $f;
if (is_string($this->file))
$this->_mode = 1;
$this->reset();
}
// Optionally move the file
// pointer to a new location
// and reset the buffered data
function reset($pos = null, $l = 100) {
if ($this->_mode == 0) {
if (!is_null ($pos)) {
fseek ($this->file, $pos);
}
$this->buffer = $l > 0 ? fread($this->file, $l) : '';
$this->length = strlen($this->buffer);
if ($this->length < $l)
$this->increase_length($l - $this->length);
} else {
$this->buffer = $this->file;
$this->length = strlen($this->buffer);
}
$this->offset = 0;
$this->stack = array();
}
// Make sure that there is at least one
// character beyond the current offset in
// the buffer to prevent the tokenizer
// from attempting to access data that does
// not exist
function ensure_content() {
if ($this->offset >= $this->length - 1) {
return $this->increase_length();
} else {
return true;
}
}
// Forcefully read more data into the buffer
function increase_length($l=100) {
if ($this->_mode == 0 && feof($this->file)) {
return false;
} else if ($this->_mode == 0) {
$totalLength = $this->length + $l;
do {
$this->buffer .= fread($this->file, $totalLength-$this->length);
} while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file));
return true;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,706 @@
<?php
//
// FPDI - Version 1.3.1
//
// Copyright 2004-2009 Setasign - Jan Slabon
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
if (!defined ('PDF_TYPE_NULL'))
define ('PDF_TYPE_NULL', 0);
if (!defined ('PDF_TYPE_NUMERIC'))
define ('PDF_TYPE_NUMERIC', 1);
if (!defined ('PDF_TYPE_TOKEN'))
define ('PDF_TYPE_TOKEN', 2);
if (!defined ('PDF_TYPE_HEX'))
define ('PDF_TYPE_HEX', 3);
if (!defined ('PDF_TYPE_STRING'))
define ('PDF_TYPE_STRING', 4);
if (!defined ('PDF_TYPE_DICTIONARY'))
define ('PDF_TYPE_DICTIONARY', 5);
if (!defined ('PDF_TYPE_ARRAY'))
define ('PDF_TYPE_ARRAY', 6);
if (!defined ('PDF_TYPE_OBJDEC'))
define ('PDF_TYPE_OBJDEC', 7);
if (!defined ('PDF_TYPE_OBJREF'))
define ('PDF_TYPE_OBJREF', 8);
if (!defined ('PDF_TYPE_OBJECT'))
define ('PDF_TYPE_OBJECT', 9);
if (!defined ('PDF_TYPE_STREAM'))
define ('PDF_TYPE_STREAM', 10);
if (!defined ('PDF_TYPE_BOOLEAN'))
define ('PDF_TYPE_BOOLEAN', 11);
if (!defined ('PDF_TYPE_REAL'))
define ('PDF_TYPE_REAL', 12);
require_once('pdf_context.php');
if (!class_exists('pdf_parser')) {
class pdf_parser {
/**
* Filename
* @var string
*/
var $filename;
/**
* File resource
* @var resource
*/
var $f;
/**
* PDF Context
* @var object pdf_context-Instance
*/
var $c;
/**
* xref-Data
* @var array
*/
var $xref;
/**
* root-Object
* @var array
*/
var $root;
/**
* PDF version of the loaded document
* @var string
*/
var $pdfVersion;
/**
* Constructor
*
* @param string $filename Source-Filename
*/
function pdf_parser($filename) {
$this->filename = $filename;
$this->f = @fopen($this->filename, 'rb');
if (!$this->f)
$this->error(sprintf('Cannot open %s !', $filename));
$this->getPDFVersion();
$this->c = new pdf_context($this->f);
// Read xref-Data
$this->xref = array();
$this->pdf_read_xref($this->xref, $this->pdf_find_xref());
// Check for Encryption
$this->getEncryption();
// Read root
$this->pdf_read_root();
}
/**
* Close the opened file
*/
function closeFile() {
if (isset($this->f) && is_resource($this->f)) {
fclose($this->f);
unset($this->f);
}
}
/**
* Print Error and die
*
* @param string $msg Error-Message
*/
function error($msg) {
die('<b>PDF-Parser Error:</b> '.$msg);
}
/**
* Check Trailer for Encryption
*/
function getEncryption() {
if (isset($this->xref['trailer'][1]['/Encrypt'])) {
$this->error('File is encrypted!');
}
}
/**
* Find/Return /Root
*
* @return array
*/
function pdf_find_root() {
if ($this->xref['trailer'][1]['/Root'][0] != PDF_TYPE_OBJREF) {
$this->error('Wrong Type of Root-Element! Must be an indirect reference');
}
return $this->xref['trailer'][1]['/Root'];
}
/**
* Read the /Root
*/
function pdf_read_root() {
// read root
$this->root = $this->pdf_resolve_object($this->c, $this->pdf_find_root());
}
/**
* Get PDF-Version
*
* And reset the PDF Version used in FPDI if needed
*/
function getPDFVersion() {
fseek($this->f, 0);
preg_match('/\d\.\d/',fread($this->f,16),$m);
if (isset($m[0]))
$this->pdfVersion = $m[0];
return $this->pdfVersion;
}
/**
* Find the xref-Table
*/
function pdf_find_xref() {
$toRead = 1500;
$stat = fseek ($this->f, -$toRead, SEEK_END);
if ($stat === -1) {
fseek ($this->f, 0);
}
$data = fread($this->f, $toRead);
$pos = strlen($data) - strpos(strrev($data), strrev('startxref'));
$data = substr($data, $pos);
if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) {
$this->error('Unable to find pointer to xref table');
}
return (int) $matches[1];
}
/**
* Read xref-table
*
* @param array $result Array of xref-table
* @param integer $offset of xref-table
*/
function pdf_read_xref(&$result, $offset) {
fseek($this->f, $o_pos = $offset-20); // set some bytes backwards to fetch errorious docs
$data = fread($this->f, 100);
$xrefPos = strrpos($data, 'xref');
if ($xrefPos === false) {
fseek($this->f, $offset);
$c = new pdf_context($this->f);
$xrefStreamObjDec = $this->pdf_read_value($c);
if (is_array($xrefStreamObjDec) && isset($xrefStreamObjDec[0]) && $xrefStreamObjDec[0] == PDF_TYPE_OBJDEC) {
$this->error(sprintf('This document (%s) probably uses a compression technique which is not supported by the free parser shipped with FPDI.', $this->filename));
} else {
$this->error('Unable to find xref table.');
}
}
if (!isset($result['xref_location'])) {
$result['xref_location'] = $o_pos+$xrefPos;
$result['max_object'] = 0;
}
$cylces = -1;
$bytesPerCycle = 100;
fseek($this->f, $o_pos = $o_pos+$xrefPos+4); // set the handle directly after the "xref"-keyword
$data = fread($this->f, $bytesPerCycle);
while (($trailerPos = strpos($data, 'trailer', max($bytesPerCycle*$cylces++, 0))) === false && !feof($this->f)) {
$data .= fread($this->f, $bytesPerCycle);
}
if ($trailerPos === false) {
$this->error('Trailer keyword not found after xref table');
}
$data = substr($data, 0, $trailerPos);
// get Line-Ending
preg_match_all("/(\r\n|\n|\r)/", substr($data, 0, 100), $m); // check the first 100 bytes for linebreaks
$differentLineEndings = count(array_unique($m[0]));
if ($differentLineEndings > 1) {
$lines = preg_split("/(\r\n|\n|\r)/", $data, -1, PREG_SPLIT_NO_EMPTY);
} else {
$lines = explode($m[0][1], $data);
}
$data = $differentLineEndings = $m = null;
unset($data, $differentLineEndings, $m);
$linesCount = count($lines);
$start = 1;
for ($i = 0; $i < $linesCount; $i++) {
$line = trim($lines[$i]);
if ($line) {
$pieces = explode(' ', $line);
$c = count($pieces);
switch($c) {
case 2:
$start = (int)$pieces[0];
$end = $start+(int)$pieces[1];
if ($end > $result['max_object'])
$result['max_object'] = $end;
break;
case 3:
if (!isset($result['xref'][$start]))
$result['xref'][$start] = array();
if (!array_key_exists($gen = (int) $pieces[1], $result['xref'][$start])) {
$result['xref'][$start][$gen] = $pieces[2] == 'n' ? (int) $pieces[0] : null;
}
$start++;
break;
default:
$this->error('Unexpected data in xref table');
}
}
}
$lines = $pieces = $line = $start = $end = $gen = null;
unset($lines, $pieces, $line, $start, $end, $gen);
fseek($this->f, $o_pos+$trailerPos+7);
$c = new pdf_context($this->f);
$trailer = $this->pdf_read_value($c);
$c = null;
unset($c);
if (!isset($result['trailer'])) {
$result['trailer'] = $trailer;
}
if (isset($trailer[1]['/Prev'])) {
$this->pdf_read_xref($result, $trailer[1]['/Prev'][1]);
}
$trailer = null;
unset($trailer);
return true;
}
/**
* Reads an Value
*
* @param object $c pdf_context
* @param string $token a Token
* @return mixed
*/
function pdf_read_value(&$c, $token = null) {
if (is_null($token)) {
$token = $this->pdf_read_token($c);
}
if ($token === false) {
return false;
}
switch ($token) {
case '<':
// This is a hex string.
// Read the value, then the terminator
$pos = $c->offset;
while(1) {
$match = strpos ($c->buffer, '>', $pos);
// If you can't find it, try
// reading more data from the stream
if ($match === false) {
if (!$c->increase_length()) {
return false;
} else {
continue;
}
}
$result = substr ($c->buffer, $c->offset, $match - $c->offset);
$c->offset = $match + 1;
return array (PDF_TYPE_HEX, $result);
}
break;
case '<<':
// This is a dictionary.
$result = array();
// Recurse into this function until we reach
// the end of the dictionary.
while (($key = $this->pdf_read_token($c)) !== '>>') {
if ($key === false) {
return false;
}
if (($value = $this->pdf_read_value($c)) === false) {
return false;
}
// Catch missing value
if ($value[0] == PDF_TYPE_TOKEN && $value[1] == '>>') {
$result[$key] = array(PDF_TYPE_NULL);
break;
}
$result[$key] = $value;
}
return array (PDF_TYPE_DICTIONARY, $result);
case '[':
// This is an array.
$result = array();
// Recurse into this function until we reach
// the end of the array.
while (($token = $this->pdf_read_token($c)) !== ']') {
if ($token === false) {
return false;
}
if (($value = $this->pdf_read_value($c, $token)) === false) {
return false;
}
$result[] = $value;
}
return array (PDF_TYPE_ARRAY, $result);
case '(' :
// This is a string
$pos = $c->offset;
$openBrackets = 1;
do {
for (; $openBrackets != 0 && $pos < $c->length; $pos++) {
switch (ord($c->buffer[$pos])) {
case 0x28: // '('
$openBrackets++;
break;
case 0x29: // ')'
$openBrackets--;
break;
case 0x5C: // backslash
$pos++;
}
}
} while($openBrackets != 0 && $c->increase_length());
$result = substr($c->buffer, $c->offset, $pos - $c->offset - 1);
$c->offset = $pos;
return array (PDF_TYPE_STRING, $result);
case 'stream':
$o_pos = ftell($c->file)-strlen($c->buffer);
$o_offset = $c->offset;
$c->reset($startpos = $o_pos + $o_offset);
$e = 0; // ensure line breaks in front of the stream
if ($c->buffer[0] == chr(10) || $c->buffer[0] == chr(13))
$e++;
if ($c->buffer[1] == chr(10) && $c->buffer[0] != chr(10))
$e++;
if ($this->actual_obj[1][1]['/Length'][0] == PDF_TYPE_OBJREF) {
$tmp_c = new pdf_context($this->f);
$tmp_length = $this->pdf_resolve_object($tmp_c,$this->actual_obj[1][1]['/Length']);
$length = $tmp_length[1][1];
} else {
$length = $this->actual_obj[1][1]['/Length'][1];
}
if ($length > 0) {
$c->reset($startpos+$e,$length);
$v = $c->buffer;
} else {
$v = '';
}
$c->reset($startpos+$e+$length+9); // 9 = strlen("endstream")
return array(PDF_TYPE_STREAM, $v);
default :
if (is_numeric ($token)) {
// A numeric token. Make sure that
// it is not part of something else.
if (($tok2 = $this->pdf_read_token ($c)) !== false) {
if (is_numeric ($tok2)) {
// Two numeric tokens in a row.
// In this case, we're probably in
// front of either an object reference
// or an object specification.
// Determine the case and return the data
if (($tok3 = $this->pdf_read_token ($c)) !== false) {
switch ($tok3) {
case 'obj' :
return array (PDF_TYPE_OBJDEC, (int) $token, (int) $tok2);
case 'R' :
return array (PDF_TYPE_OBJREF, (int) $token, (int) $tok2);
}
// If we get to this point, that numeric value up
// there was just a numeric value. Push the extra
// tokens back into the stack and return the value.
array_push ($c->stack, $tok3);
}
}
array_push ($c->stack, $tok2);
}
if ($token === (string)((int)$token))
return array (PDF_TYPE_NUMERIC, (int)$token);
else
return array (PDF_TYPE_REAL, (float)$token);
} else if ($token == 'true' || $token == 'false') {
return array (PDF_TYPE_BOOLEAN, $token == 'true');
} else if ($token == 'null') {
return array (PDF_TYPE_NULL);
} else {
// Just a token. Return it.
return array (PDF_TYPE_TOKEN, $token);
}
}
}
/**
* Resolve an object
*
* @param object $c pdf_context
* @param array $obj_spec The object-data
* @param boolean $encapsulate Must set to true, cause the parsing and fpdi use this method only without this para
*/
function pdf_resolve_object(&$c, $obj_spec, $encapsulate = true) {
// Exit if we get invalid data
if (!is_array($obj_spec)) {
$ret = false;
return $ret;
}
if ($obj_spec[0] == PDF_TYPE_OBJREF) {
// This is a reference, resolve it
if (isset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]])) {
// Save current file position
// This is needed if you want to resolve
// references while you're reading another object
// (e.g.: if you need to determine the length
// of a stream)
$old_pos = ftell($c->file);
// Reposition the file pointer and
// load the object header.
$c->reset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]]);
$header = $this->pdf_read_value($c);
if ($header[0] != PDF_TYPE_OBJDEC || $header[1] != $obj_spec[1] || $header[2] != $obj_spec[2]) {
$this->error("Unable to find object ({$obj_spec[1]}, {$obj_spec[2]}) at expected location");
}
// If we're being asked to store all the information
// about the object, we add the object ID and generation
// number for later use
$result = array();
$this->actual_obj =& $result;
if ($encapsulate) {
$result = array (
PDF_TYPE_OBJECT,
'obj' => $obj_spec[1],
'gen' => $obj_spec[2]
);
}
// Now simply read the object data until
// we encounter an end-of-object marker
while(1) {
$value = $this->pdf_read_value($c);
if ($value === false || count($result) > 4) {
// in this case the parser coudn't find an endobj so we break here
break;
}
if ($value[0] == PDF_TYPE_TOKEN && $value[1] === 'endobj') {
break;
}
$result[] = $value;
}
$c->reset($old_pos);
if (isset($result[2][0]) && $result[2][0] == PDF_TYPE_STREAM) {
$result[0] = PDF_TYPE_STREAM;
}
return $result;
}
} else {
return $obj_spec;
}
}
/**
* Reads a token from the file
*
* @param object $c pdf_context
* @return mixed
*/
function pdf_read_token(&$c)
{
// If there is a token available
// on the stack, pop it out and
// return it.
if (count($c->stack)) {
return array_pop($c->stack);
}
// Strip away any whitespace
do {
if (!$c->ensure_content()) {
return false;
}
$c->offset += strspn($c->buffer, " \n\r\t", $c->offset);
} while ($c->offset >= $c->length - 1);
// Get the first character in the stream
$char = $c->buffer[$c->offset++];
switch ($char) {
case '[':
case ']':
case '(':
case ')':
// This is either an array or literal string
// delimiter, Return it
return $char;
case '<':
case '>':
// This could either be a hex string or
// dictionary delimiter. Determine the
// appropriate case and return the token
if ($c->buffer[$c->offset] == $char) {
if (!$c->ensure_content()) {
return false;
}
$c->offset++;
return $char . $char;
} else {
return $char;
}
case '%':
// This is a comment - jump over it!
$pos = $c->offset;
while(1) {
$match = preg_match("/(\r\n|\r|\n)/", $c->buffer, $m, PREG_OFFSET_CAPTURE, $pos);
if ($match === 0) {
if (!$c->increase_length()) {
return false;
} else {
continue;
}
}
$c->offset = $m[0][1]+strlen($m[0][0]);
return $this->pdf_read_token($c);
}
default:
// This is "another" type of token (probably
// a dictionary entry or a numeric value)
// Find the end and return it.
if (!$c->ensure_content()) {
return false;
}
while(1) {
// Determine the length of the token
$pos = strcspn($c->buffer, " %[]<>()\r\n\t/", $c->offset);
if ($c->offset + $pos <= $c->length - 1) {
break;
} else {
// If the script reaches this point,
// the token may span beyond the end
// of the current buffer. Therefore,
// we increase the size of the buffer
// and try again--just to be safe.
$c->increase_length();
}
}
$result = substr($c->buffer, $c->offset - 1, $pos + 1);
$c->offset += $pos;
return $result;
}
}
}
}

View File

@@ -0,0 +1,32 @@
<?php
$basket = $this->session->get('basket');
echo "<div class=\"ui-widget\">\n";
echo "<div class=\"p2 ui-widget-header ui-corner-top\">\n";
echo Kohana::lang('common.basket-box-header')."</div>\n";
echo "<div class=\"p4 ui-widget-content ui-corner-bottom\">\n";
echo "<div id=\"basket_items\">\n";
if(is_array($basket) && sizeof($basket) > 0 ){
foreach($basket as $key=>$item){
echo "<li class=\"ui-state-default basket_action_remove\" id=\"".
$item."\"><a title=\"".Kohana::lang('common.basket-remove', $item)."\"".
"id=\"".$item.
"\"><img width=12px height=12px src=\"".url::base().
"media/images/remove.png\"></a>".
pnp::shorten($item)."</li>\n";
}
}
if(is_array($basket) && sizeof($basket) > 0 ){
echo "<div align=\"center\" class=\"p2\">\n";
echo "<button id=\"basket-show\">".Kohana::lang('common.basket-show')."</button>\n";
echo "<button id=\"basket-clear\">".Kohana::lang('common.basket-clear')."</button>\n";
echo "</div>\n";
#echo "<div><a class=\"multi0\" href=\"".url::base(TRUE)."page/basket\">".Kohana::lang('common.basket-show')."</a></div>\n";
}else{
echo "<div>".Kohana::lang('common.basket-empty')."</div>\n";
}
echo "</div>\n";
echo "</div>\n";
echo "</div><br>\n";
?>
<div id="basket_box"></div>

View File

@@ -0,0 +1,38 @@
<div class="pagebody">
<table class="body">
<tr valign="top"><td>
<div class="left ui-widget">
<div class="p4 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.color-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" style="width: 600px">
<?php if (!empty($this->scheme)) {
foreach( $this->scheme as $key => $colors ){
print "<h3>\"" . $key . "\"</h3><ul class=\"colorscheme\">";
foreach($colors as $color){
print "<li class=\"colorscheme\"><span class=\"colorscheme\" style=\"background-color:".$color."\">" . "</span></li>\n";
}
print "</ul>";
}
print "<br><br>";
} ?>
</div>
</td><td>
<div class="right">
<?php if (!empty($color_box)) {
echo $color_box;
} ?>
<?php if (!empty($logo_box)) {
echo $logo_box;
} ?>
</div>
</td></tr>
<tr valign="top"><td colspan="2">
<div class="cb p4 ui-widget-content ui-corner-all">
<?php echo pnp::print_version(); ?>
</div>
</div>
</td></tr></table>
</div>

View File

@@ -0,0 +1,15 @@
<!-- Docs Menu Start -->
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.icon-box-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" >
<?php
echo "<a title=\"".Kohana::lang('common.title-home-link')."\" href=\"".url::base(TRUE)."graph\"><img class=\"icon\" src=\"".url::base()."media/images/home.png\"></a>\n";
echo "<a title=\"".Kohana::lang('common.title-docs-link')."\" href=\"".url::base(TRUE)."docs\"><img class=\"icon\" src=\"".url::base()."media/images/docs.png\"></a>\n";
echo "<a title=\"".Kohana::lang('common.title-color-link')."\" href=\"".url::base(TRUE)."color\"><img class=\"icon\" src=\"".url::base()."media/images/color.png\"></a>\n";
?>
</div>
</div>
<p>
<!-- Color Box End -->

View File

@@ -0,0 +1,74 @@
<?php
if($this->is_authorized === FALSE){
print "<div class=\"pagebody b1\"><h2>Your are not authorized to view this site</h2></div>";
return;
}
?>
<div class="pagebody b1">
<script type="text/javascript">
jQuery(function() {
jQuery("#tabs").tabs();
});
</script>
<table class="body"><tr><td valign="top">
<div class="gw left ui-corner-all">
<div id="tabs">
<ul>
<li><a href="#tabs-1">Data Structure</a></li>
<li><a href="#tabs-2">RRD Datasource</a></li>
<li><a href="#tabs-3">Nagios Macros</a></li>
<li><a href="#tabs-4">PHP Session </a></li>
</ul>
<div id="tabs-1">
<h3>$this->data->STRUCT</h3>
<pre>
<?php print_r($this->data->STRUCT);?>
</pre>
</div>
<div id="tabs-2">
<h3>$this->data->DS</h3>
<pre>
<?php print_r($this->data->DS);?>
</pre>
</div>
<div id="tabs-3">
<h3>$this->data->MACRO</h3>
<pre>
<?php print_r($this->data->MACRO);?>
</pre>
</div>
<div id="tabs-4">
<h3>$this->session->get()</h3>
<pre>
<?php print_r($this->session->get());?>
</pre>
</div>
</div>
</div>
</td><td valign="top">
<div class="right ui-corner-all">
<?php if (!empty($search_box)) {
echo $search_box;
} ?>
<?php if (!empty($icon_box)) {
echo $icon_box;
} ?>
<?php if (!empty($status_box)) {
echo $status_box;
} ?>
<?php if (!empty($service_box)) {
echo $service_box;
} ?>
</div>
</td></tr></table>
<div class="left w99 cb ui-corner-all">
<?php if (!empty($footer)) {
echo $footer . pnp::print_version();
} ?>
<?php echo pnp::print_version(); ?>
</div>

View File

@@ -0,0 +1,31 @@
<div class="pagebody">
<table class="body">
<tr valign="top"><td>
<div class="left ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.docs-header',PNP_VERSION) ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" style="width: <?php echo $this->graph_width ?>px">
<?php if (!empty($this->content)) {
echo $this->content;
} ?>
</div>
</div>
</td><td>
<div class="right">
<?php if (!empty($docs_box)) {
echo $docs_box;
} ?>
<?php if (!empty($logo_box)) {
echo $logo_box;
} ?>
</div>
</td></tr>
<tr valign="top"><td colspan="2">
<div class="cb p4 ui-widget-content ui-corner-all">
<?php echo pnp::print_version(); ?>
</div>
</td></tr></table>
</div>

View File

@@ -0,0 +1,28 @@
<!-- Docs Menu Start -->
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.icon-box-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" >
<?php
echo "<a title=\"".Kohana::lang('common.title-home-link')."\" href=\"".url::base(TRUE)."graph\"><img class=\"icon\" src=\"".url::base()."media/images/home.png\"></a>\n";
echo "<a title=\"".Kohana::lang('common.title-docs-link')."\" href=\"".url::base(TRUE)."docs\"><img class=\"icon\" src=\"".url::base()."media/images/docs.png\"></a>\n";
echo "<a title=\"".Kohana::lang('common.title-color-link')."\" href=\"".url::base(TRUE)."color\"><img class=\"icon\" src=\"".url::base()."media/images/color.png\"></a>\n";
foreach ( $this->doc_language as $lang ){
echo "<a href=\"".url::base(TRUE)."docs/view/".$lang."/start\"><img class=\"icon\" src=\"".url::base()."media/images/".$lang.".png\"></a> \n";
}
?>
</div>
</div>
<p>
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.docs-box-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" >
<ul><li class="level1"><a href="start"><strong><?php echo Kohana::lang('common.docs-home')?></strong></a></li></ul>
<?php echo $this->toc ?>
</div>
</div>
<p>
<!-- Docs Menu End -->

View File

@@ -0,0 +1,56 @@
<div class="pagebody">
<table class="body"><tr valign="top"><td colspan="2">
<?php if (!empty($header)) {
echo $header;
} ?>
</td></tr>
<tr valign="top"><td>
<div class="left ui-widget-content ui-corner-all">
<?php if (!empty($graph_content)) {
echo $graph_content;
} ?>
</div>
</td><td>
<div class="right ui-widget-content ui-corner-all">
<?php if (!empty($search_box)) {
echo $search_box;
} ?>
<?php if (!empty($icon_box)) {
echo $icon_box;
} ?>
<?php if (!empty($basket_box)) {
echo $basket_box;
} ?>
<?php if (!empty($status_box)) {
echo $status_box;
} ?>
<?php if (!empty($multisite_box)) {
echo $multisite_box;
} ?>
<?php if (!empty($widget_menu)) {
echo $widget_menu;
} ?>
<?php if (!empty($timerange_box)) {
echo $timerange_box;
} ?>
<?php if (!empty($service_box)) {
echo $service_box;
} ?>
<?php if (!empty($logo_box)) {
echo $logo_box;
} ?>
</div>
</td></tr>
<tr valign="top"><td colspan="2">
<div class="cb p4 ui-widget-content ui-corner-all">
<?php echo pnp::print_version()?>
</div>
</td></tr></table>
</div>

View File

@@ -0,0 +1,102 @@
<!-- Graph Content Start-->
<?php
if (!empty($timerange_select)) {
echo $timerange_select;
}
if (!empty($widget_graph)) {
echo $widget_graph;
}
echo "<div class=\"ui-widget\" style=\"min-width:".$graph_width."px\">\n";
if($this->is_authorized == FALSE){
echo "<div style=\"padding: 0pt 0.7em;\" class=\"ui-state-error ui-corner-all\">\n";
echo "<p><span style=\"float: left; margin-right: 0.3em;\" class=\"ui-icon ui-icon-alert\"></span>\n";
echo "<strong>Alert:&nbsp;</strong>".Kohana::lang('error.not_authorized')."</p>\n";
echo "</div></div>\n";
return;
}
if($this->data->ERROR != NULL){
echo "<div style=\"padding: 0pt 0.7em;\" class=\"ui-state-error ui-corner-all\">\n";
echo "<p><span style=\"float: left; margin-right: 0.3em;\" class=\"ui-icon ui-icon-alert\"></span>\n";
echo "<strong>Alert:&nbsp;</strong>".$this->data->ERROR."</p>\n";
echo "</div></div>\n";
return;
}
$count = 0;
foreach($this->data->STRUCT as $key=>$value){
if($value['LEVEL'] == 0){
echo "<strong>Host: </strong>".$value['MACRO']['DISP_HOSTNAME']. " <strong>Service: </strong>".$value['MACRO']['DISP_SERVICEDESC']."<p>\n";
echo "<strong>".$value['TIMERANGE']['title']. "</strong> " .$value['TIMERANGE']['f_start']. " - " . $value['TIMERANGE']['f_end']. "\n";
$count = 0;
}
if($value['VERSION'] != "valid" && $count == 0){
$count++;
echo "<div class=\"ui-widget\">\n";
echo "<div class=\"ui-state-error ui-corner-all\">\n";
echo "<p><span class=\"ui-icon ui-icon-alert\" style=\"float: left;\"></span>".$value['VERSION']."</p>\n";
echo "</div>\n";
echo "</div><br>\n";
}
echo "<div class=\"ui-widget-header ui-corner-top\">";
echo "<table border=0 width=100%><tr>\n";
echo "<td width=100% align=left>";
echo Kohana::lang('common.datasource',$value['ds_name'])."</td>\n";
echo "<td align=right>";
echo nagios::SummaryLink($value['MACRO']['DISP_HOSTNAME'],
$value['TIMERANGE']['start'],
$value['TIMERANGE']['end'])."</td>\n";
echo "<td align=right>";
echo nagios::AvailLink($value['MACRO']['DISP_HOSTNAME'],
$value['MACRO']['DISP_SERVICEDESC'],
$value['TIMERANGE']['start'],
$value['TIMERANGE']['end'])."</td>\n";
echo "<td align=right>";
echo pnp::add_to_basket_icon(
$value['MACRO']['HOSTNAME'],
$value['MACRO']['SERVICEDESC'],
$value['SOURCE']
);
echo "</td>\n";
echo "<td align=right>";
echo pnp::zoom_icon($value['MACRO']['HOSTNAME'],
$value['MACRO']['SERVICEDESC'],
$value['TIMERANGE']['start'],
$value['TIMERANGE']['end'],
$value['SOURCE'],
$value['VIEW'],
$value['GRAPH_WIDTH'],
$value['GRAPH_HEIGHT'])."</td>\n";
echo "</tr></table>\n";
echo "</div>\n";
echo "<div class=\"p4 gh ui-widget-content ui-corner-bottom\">\n";
echo "<div style=\"position:relative;\">\n";
$path = pnp::addToUri( array(
'host' => $value['MACRO']['HOSTNAME'],
'srv' => $value['MACRO']['SERVICEDESC'],
), FALSE
);
echo "<a href=\"".url::base(TRUE)."graph".$path
."\" title=\""
.Kohana::lang('common.host',$value['MACRO']['DISP_HOSTNAME']) . " "
.Kohana::lang('common.service',$value['MACRO']['DISP_SERVICEDESC']) . " "
.Kohana::lang('common.datasource',$value['ds_name']) . " "
."\">\n";
echo "<div start=".$value['TIMERANGE']['start']." end=".$value['TIMERANGE']['end']." style=\"width:".$value['GRAPH_WIDTH']."px; height:".$value['GRAPH_HEIGHT']."px; position:absolute; top:33px\" class=\"graph\" id=\"".$this->url."\" ></div>";
$path = pnp::addToUri( array(
'host' => $value['MACRO']['HOSTNAME'],
'srv' => $value['MACRO']['SERVICEDESC'],
'view' => $value['VIEW'],
'source' => $value['SOURCE'],
'start' => $value['TIMERANGE']['start'],
'end' => $value['TIMERANGE']['end']
), FALSE
);
echo "<img class=\"graph\" src=\"".url::base(TRUE)."image" . $path . "\"></a>\n";
echo "</div>\n";
echo "</div><p>\n";
}
echo "</div>\n";
?>
<!-- Graph Content End-->

View File

@@ -0,0 +1,53 @@
<!-- Graph Content Start-->
<?php
if (!empty($timerange_select)) {
echo $timerange_select;
}
if (!empty($widget_graph)) {
echo $widget_graph;
}
echo "<div class=\"ui-widget\" style=\"min-width:".$graph_width."px\">\n";
$count = 0;
if($this->data->MACRO['TITLE'])
echo "<strong>".$this->data->MACRO['TITLE']."</strong><p>\n";
if($this->data->MACRO['COMMENT'])
echo $this->data->MACRO['COMMENT']."<p>\n";
foreach($this->data->STRUCT as $key=>$value){
if($value['LEVEL'] == 0 ){
echo "<strong>".$value['TIMERANGE']['title']. "</strong> " .$value['TIMERANGE']['f_start']. " - " . $value['TIMERANGE']['f_end']. "\n";
$count = 0;
}
echo "<div class=\"ui-widget-header ui-corner-top\">";
echo "<table border=0 width=100%><tr>\n";
echo "<td width=100% align=left>";
echo Kohana::lang('common.datasource',$value['ds_name'])."</td>\n";
echo "<td align=right>";
echo pnp::zoom_icon_special($this->tpl,
$value['TIMERANGE']['start'],
$value['TIMERANGE']['end'],
$value['SOURCE'],
$value['VIEW'],
$value['GRAPH_WIDTH'],
$value['GRAPH_HEIGHT'])."</td>\n";
echo "</tr></table>\n";
echo "</div>\n";
echo "<div class=\"p4 gh ui-widget-content ui-corner-bottom\">\n";
echo "<div style=\"position:relative;\">\n";
$path = pnp::addToUri( array('tpl' => $this->tpl, 'view' => NULL ) );
echo "<a href=\"". $path . "\">\n";
echo "<div start=".$value['TIMERANGE']['start']." end=".$value['TIMERANGE']['end']." style=\"width:".$value['GRAPH_WIDTH']."px; height:".$value['GRAPH_HEIGHT']."px; position:absolute; top:33px;\" class=\"graph\" id=\"".$this->url."\"></div>\n";
$path = pnp::addToUri( array('tpl' => $this->tpl,
'view' => $value['VIEW'],
'source' => $value['SOURCE'],
'start' => $value['TIMERANGE']['start'],
'end' => $value['TIMERANGE']['end']), FALSE
);
echo "<img class=\"graph\" src=\"".url::base(TRUE)."image" . $path . "\">\n";
echo "</div>\n";
echo "</a></div><p>\n";
}
echo "</div>\n";
?>
<!-- Graph Content End-->

View File

@@ -0,0 +1,19 @@
<div style="padding:4px">
<div style="display: table; margin: 0 auto;">
<table class="body">
<tr valign="top">
<td>
<div class="left ui-widget-content ui-corner-all" align="center">
<?php if (!empty($icon_box)) {
echo $icon_box;
} ?>
<?php if (!empty($graph_content)) {
echo $graph_content;
} ?>
</div>
</td>
</tr>
</table>
</div>
</div>

View File

@@ -0,0 +1,4 @@
<!-- Header Template -->
<div class="p4 ui-widget-header ui-corner-all">
<?php echo $title ?>
</div>

View File

@@ -0,0 +1,11 @@
<div class="left b1 w99">
Status Box<br>
<?php if (!empty($hosts)) {
foreach($hosts as $host){
echo html::anchor('graph?host='.$host['name'], $host['name'], array('class'=>$host['state']))."</p>";
}
}
?>
</div>

View File

@@ -0,0 +1,39 @@
<!-- Icon Box Start -->
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.icon-box-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" >
<?php
$qsa = pnp::addToUri(array('start' => $this->start,'end' => $this->end, 'view' => $this->view), False);
if($this->config->conf['use_calendar']){
echo "<a title=\"".Kohana::lang('common.title-calendar-link')."\" href=\"#\" id=\"button\"><img class=\"icon\" src=\"".url::base()."media/images/calendar.png\"></a>";
}
if($this->config->conf['use_fpdf'] == 1 && ( $position == "graph" || $position == "special") ){
echo "<a title=\"".Kohana::lang('common.title-pdf-link')."\" href=\"".url::base(TRUE)."pdf".$qsa."\"><img class=\"icon\" src=\"".url::base()."media/images/pdf.png\"></a>\n";
}
if($this->config->conf['use_fpdf'] == 1 && $position == "basket"){
echo "<a title=\"".Kohana::lang('common.title-pdf-link')."\" href=\"".url::base(TRUE)."pdf/basket/".$qsa."\"><img class=\"icon\" src=\"".url::base()."media/images/pdf.png\"></a>\n";
}
if($this->config->conf['use_fpdf'] == 1 && $position == "page"){
echo "<a title=\"".Kohana::lang('common.title-pdf-link')."\" href=\"".url::base(TRUE)."pdf/page/".$this->page.$qsa."\"><img class=\"icon\" src=\"".url::base()."media/images/pdf.png\"></a>\n";
}
if($this->config->conf['show_xml_icon'] == 1 && $position == "graph" && $xml_icon == TRUE){
$qsa = pnp::addToUri(array(), False);
echo "<a title=\"".Kohana::lang('common.title-xml-link')."\" href=\"".url::base(TRUE)."xml".$qsa."\"><img class=\"icon\" src=\"".url::base()."media/images/xml.png\"></a>\n";
}
if($this->data->getFirstPage() && $this->isAuthorizedFor('pages') ){
echo "<a title=\"".Kohana::lang('common.title-pages-link')."\" href=\"".url::base(TRUE)."page\"><img class=\"icon\" src=\"".url::base()."media/images/pages.png\"></a>\n";
}
echo "<a title=\"".Kohana::lang('common.title-statistics-link')."\" href=\"".url::base(TRUE)."graph?host=.pnp-internal&srv=runtime\"><img class=\"icon\" src=\"".url::base()."media/images/stats.png\"></a>\n";
if($this->data->getFirstSpecialTemplate() ){
echo "<a title=\"".Kohana::lang('common.title-special-templates-link')."\" href=\"".url::base(TRUE)."special\"><img class=\"icon\" src=\"".url::base()."media/images/special.png\"></a>\n";
}
echo "<a title=\"".Kohana::lang('common.title-docs-link')."\" href=\"".url::base(TRUE)."docs\"><img class=\"icon\" src=\"".url::base()."media/images/docs.png\"></a>\n";
?>
</div>
</div><p>
<!-- Icon Box End -->

View File

@@ -0,0 +1,77 @@
<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php if(isset ( $_SERVER['REQUEST_URI'])):?>
<meta http-equiv="refresh" content="60">
<?php endif ?>
<title><?php echo $error ?></title>
<?php echo html::stylesheet('media/css/common.css') ?>
<?php echo html::stylesheet('media/css/ui-'.Kohana::config('core.theme').'/jquery-ui.css') ?>
<?php echo html::link('media/images/favicon.ico','icon','image/ico') ?>
<?php echo html::script('media/js/jquery-min.js')?>
<?php echo html::script('media/js/jquery-ui.min.js')?>
<style type="text/css">
<?php #include Kohana::find_file('views', 'kohana_errors', FALSE, 'css') ?>
</style>
</head>
<body>
<div class="pagebody">
<table class="body">
<tr valign="top"><td>
<div class="left ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo "PNP4Nagios Version ".PNP_VERSION ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" style="width: 640px">
<div style="padding: 0pt 0.7em;" class="ui-state-error ui-corner-all">
<h3>Please check the documentation for information about the following error.</h3>
<p><?php echo html::specialchars($message) ?></p>
<?php if ( ! empty($line) AND ! empty($file)): ?>
<h3>file [line]:</h3>
<p><?php echo Kohana::lang('core.error_file_line', $file, $line) ?></p>
<?php endif ?>
<?php if ( ! empty($trace)): ?>
<h3><?php echo Kohana::lang('core.stack_trace') ?></h3>
<?php echo $trace ?>
<?php endif ?>
<p>
<a href="javascript:history.back()"><?php echo Kohana::lang('common.back') ?></a>
</div>
</div>
</td><td>
<div class="right">
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.icon-box-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" >
<?php
echo "<a title=\"".Kohana::lang('common.back')."\" href=\"javascript:history.back()\"><img class=\"icon\" src=\"".url::base()."media/images/back.png\"></a>\n";
echo "<a title=\"".Kohana::lang('common.title-home-link')."\" href=\"".url::base(TRUE)."graph\"><img class=\"icon\" src=\"".url::base()."media/images/home.png\"></a>\n";
echo "<a title=\"".Kohana::lang('common.title-docs-link')."\" href=\"".url::base(TRUE)."docs\"><img class=\"icon\" src=\"".url::base()."media/images/docs.png\"></a>\n";
?>
</div>
</div>
</div>
</td></tr>
<tr valign="top"><td colspan="2">
<div class="left">
<div class="cb p4 ui-widget-content ui-corner-all">
<?php echo pnp::print_version(); ?>
</div>
</div>
</div>
</td></tr></table>
</div>
</body>
</html>

View File

@@ -0,0 +1,9 @@
<!-- Logo Box Start -->
<div class="ui-widget">
<div class="logo ui-widget-content ui-corner-all" >
<a href="http://www.pnp4nagios.org"><img src="<?php echo url::base()?>media/images/pnp.png"></a>
<a href="http://www.rrdtool.org"><img src="<?php echo url::base()?>media/images/rrdtool.png"></a>
</div>
</div>
<!-- Logo Box End -->

View File

@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
<?php echo html::link('media/images/home.png', 'apple-touch-icon', "") ?>
<?php echo html::stylesheet('media/css/jquery.mobile.min.css') ?>
<?php echo html::stylesheet('media/css/mobile.css') ?>
<?php echo html::script('media/js/jquery-min.js')?>
<?php echo html::script('media/js/jquery.mobile.min.js')?>
</head>
<body>
<div data-role="page" data-theme="b" data-add-back-btn="true">
<div data-role="header">
<h1>PNP4Nagios</h1>
<a href="<?php echo url::base(TRUE)?>/mobile" data-icon="home" class="ui-btn-right">Home</a>
</div><!-- /header -->
<?php if (!empty($home)) {
echo $home;
} ?>
<?php if (!empty($about)) {
echo $about;
} ?>
<?php if (!empty($overview)) {
echo $overview;
} ?>
<?php if (!empty($host)) {
echo $host;
} ?>
<?php if (!empty($graph)) {
echo $graph;
} ?>
<?php if (!empty($search)) {
echo $search;
} ?>
<?php if (!empty($query)) {
echo $query;
} ?>
<?php if (!empty($pages)){
echo $pages;
} ?>
<?php if (!empty($special)){
echo $special;
} ?>
<div data-role="footer">
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>

View File

@@ -0,0 +1,3 @@
<div data-role="content">
PNP4Nagios mobile interface based on jQuery Mobile
</div>

View File

@@ -0,0 +1,43 @@
<?php
if($this->is_authorized == FALSE){
?>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="e">
<li><strong>Alert:&nbsp;</strong><?php echo Kohana::lang('error.not_authorized')?></li>
</ul>
</div><!-- /content -->
<?php
return;
}
?>
<div data-role="content" data-inset="true">
<?php
$last_view = -1;
foreach($this->data->STRUCT as $d){
if($d['VIEW'] > $last_view){ # a new header begins
if($last_view != -1 ){ # close last div
print "</div>\n";
}
printf("<div class=\"timerange ui-bar-b ui-corner-top\">%s</div>\n", $d['TIMERANGE']['title'] );
printf("<div class=\"datasource ui-bar-c ui-corner-bottom\">%s\n", $d['ds_name']);
printf("<div><img style=\"max-width: 100%%\" src=\"".url::base(TRUE)."image?host=%s&srv=%s&view=%s&source=%s\"></div>\n",
$d['MACRO']['HOSTNAME'],
$d['MACRO']['SERVICEDESC'],
$d['VIEW'],
$d['SOURCE']
);
$last_view++;
}else{
printf("<div>%s</div>\n", $d['ds_name']);
printf("<div><img style=\"max-width: 100%%\" src=\"".url::base(TRUE)."image?host=%s&srv=%s&view=%s&source=%s\"></div>\n",
$d['MACRO']['HOSTNAME'],
$d['MACRO']['SERVICEDESC'],
$d['VIEW'],
$d['SOURCE']
);
}
}
?>
</div>
</div>

View File

@@ -0,0 +1,33 @@
<div data-role="content" data-inset="true">
<?php
if($this->data->MACRO['TITLE'])
echo "<strong>".$this->data->MACRO['TITLE']."</strong><p>\n";
if($this->data->MACRO['COMMENT'])
echo $this->data->MACRO['COMMENT']."<p>\n";
$last_view = -1;
foreach($this->data->STRUCT as $d){
if($d['VIEW'] > $last_view){ # a new header begins
if($last_view != -1 ){ # close last div
print "</div>\n";
}
printf("<div class=\"timerange ui-bar-b ui-corner-top\">%s</div>\n", $d['TIMERANGE']['title'] );
printf("<div class=\"datasource ui-bar-c ui-corner-bottom\">%s\n", $d['ds_name']);
printf("<div><img style=\"max-width: 100%%\" src=\"".url::base(TRUE)."image?tpl=%s&view=%s&source=%s\"></div>\n",
$this->tpl,
$d['VIEW'],
$d['SOURCE']
);
$last_view++;
}else{
printf("<div>%s</div>\n", $d['ds_name']);
printf("<div><img style=\"max-width: 100%%\" src=\"".url::base(TRUE)."image?tpl=%s&view=%s&source=%s\"></div>\n",
$this->tpl,
$d['VIEW'],
$d['SOURCE']
);
}
}
?>
</div>

View File

@@ -0,0 +1,17 @@
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="a">
<li><a href="<?php echo url::base(TRUE)?>mobile/overview" data-transition="pop"><?php echo Kohana::lang('common.mobile-all-hosts')?></a></li>
<li><a href="<?php echo url::base(TRUE)?>mobile/search" data-transition="pop"><?php echo Kohana::lang('common.mobile-search-hosts')?></a></li>
<?php
if($this->data->getFirstPage() && $this->isAuthorizedFor('pages') ){
echo "<li><a href=\"".url::base(TRUE)."mobile/pages\" data-transition=\"pop\">".Kohana::lang('common.mobile-pages')."</a></li>";
}
if($this->data->getFirstSpecialTemplate() ){
echo "<li><a href=\"".url::base(TRUE)."mobile/special\" data-transition=\"pop\">".Kohana::lang('common.mobile-special-templates')."</a></li>";
}
?>
<li><a href="<?php echo url::base(TRUE)?>mobile/graph/.pnp-internal/runtime" data-transition="pop"><?php echo Kohana::lang('common.mobile-statistics')?></a></li>
<li><a href="<?php echo url::base(TRUE)?>mobile/go/classic" data-ajax="false" data-transition="pop"><?php echo Kohana::lang('common.mobile-go-classic')?></a></li>
</ul>
</div><!-- /content -->

View File

@@ -0,0 +1,30 @@
<?php
if($this->is_authorized == FALSE){
?>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="e">
<li><strong>Alert:&nbsp;</strong><?php echo Kohana::lang('error.not_authorized')?></li>
</ul>
</div><!-- /content -->
<?php
return;
}
?>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
<?php
foreach($services as $key=>$service){
if($key == 0)
printf("<li data-role=\"list-divider\">%s</li>\n", $service['hostname'] );
printf("<li><a href=\"".url::base(TRUE)."mobile/graph/%s/%s\" data-transition=\"pop\"><img src=\"".url::base(TRUE)."image?host=%s&srv=%s&h=80&w=80&view=1\">%s</a></li>",
urlencode($service['hostname']),
urlencode($service['name']),
urlencode($service['hostname']),
urlencode($service['name']),
$service['servicedesc']);
}
?>
</ul>
</div><!-- /content -->

View File

@@ -0,0 +1,14 @@
<div data-role="content">
<ul data-filter="true" data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
<?php
$l = '';
foreach($hosts as $host){
if( substr($host['name'], 0, 1) != $l ){
printf("<li data-role=\"list-divider\">%s</li>\n", strtoupper(substr($host['name'], 0, 1)) );
}
printf("<li><a href=\"".url::base(TRUE)."mobile/host/%s\" data-transition=\"pop\">%s</a></li>", $host['name'], $host['name']);
$l = substr($host['name'], 0, 1);
}
?>
</ul>
</div><!-- /content -->

View File

@@ -0,0 +1,10 @@
<div data-role="content">
<ul data-role="listview" data-filter="true" data-inset="true" data-theme="c" data-dividertheme="a">
<?php
foreach($pages as $page){
$this->data->getPageDetails($page);
printf("<li><a href=\"".url::base(TRUE)."mobile/pages/%s\" data-transition=\"pop\">%s</a></li>", $page, $this->data->PAGE_DEF['page_name']);
}
?>
</ul>
</div><!-- /content -->

View File

@@ -0,0 +1,24 @@
<?php if( $this->isAuthorizedFor('host_search') ){ ?>
<!-- Search Box Start -->
<div data-role="content">
<div data-role="fieldcontain">
<form action="search" method="post">
<input type="search" name="term" id="search" value="" />
<button type="submit"><?php echo Kohana::lang('common.mobile-submit')?></button>
</form>
</div>
</div>
<!-- Search Box End -->
<?php } ?>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="a">
<?php
foreach($this->result as $host){
printf("<li><a href=\"".url::base(TRUE)."mobile/host/%s\" data-transition=\"pop\">%s</a></li>", $host, $host);
}
?>
</ul>
</div><!-- /content -->

View File

@@ -0,0 +1,9 @@
<div data-role="content">
<ul data-role="listview" data-filter="true" data-inset="true" data-theme="c" data-dividertheme="a">
<?php
foreach($templates as $template){
printf("<li><a href=\"".url::base(TRUE)."mobile/special/%s\" data-transition=\"pop\">%s</a></li>", $template, $template);
}
?>
</ul>
</div><!-- /content -->

View File

@@ -0,0 +1,17 @@
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.multisite-box-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom">
<?php
if(isset($host)){
echo "<strong>Host: </strong><a href=".pnp::multisite_link($base_url,$site,$host).">".html::specialchars(pnp::shorten($host))."</a><br>\n";
}
if(isset($service) && $service != "Host Perfdata"){
echo "<strong>Service: </strong><a href=".pnp::multisite_link($base_url,$site,$host, $service).">".html::specialchars(pnp::shorten($service))."</a>\n";
}
?>
</div>
</div>
<p>

View File

@@ -0,0 +1,48 @@
<div class="pagebody">
<table class="body"><tr valign="top"><td colspan="2">
<?php if (!empty($header)) {
echo $header;
} ?>
</tr></td>
<tr valign="top"><td>
<div class="left ui-widget-content ui-corner-all">
<?php if (!empty($graph_content)) {
echo $graph_content;
} ?>
</div>
</td><td>
<div class="right ui-widget-content ui-corner-all">
<?php if (!empty($search_box)) {
echo $search_box;
} ?>
<?php if (!empty($icon_box)) {
echo $icon_box;
} ?>
<?php if (!empty($timerange_box)) {
echo $timerange_box;
} ?>
<?php if (!empty($basket_box)) {
echo $basket_box;
} ?>
<?php if (!empty($pages_box)) {
echo $pages_box;
} ?>
<?php if (!empty($service_box)) {
echo $service_box;
} ?>
<?php if (!empty($logo_box)) {
echo $logo_box;
} ?>
</div>
</td></tr>
<tr valign="top"><td colspan="2">
<div class="cb p4 w99 ui-widget-content ui-corner-all">
<?php echo pnp::print_version(); ?>
</div>
</td></tr></table>
</div>

View File

@@ -0,0 +1,29 @@
<?php if (!empty($pages) && $this->isAuthorizedFor('pages') ) { ?>
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.pages-box-header') ?>
</div>
<?php
$filter = $this->session->get('pfilter');
?>
<div class="p4 ui-widget-content">
<?php
echo "<input type=\"text\" name=\"page-filter\" id=\"page-filter\" value=\"".$filter."\" class=\"textbox\" />"
?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" id="pages">
<?php
foreach($pages as $page){
echo "<span id=\"page-".$page."\">";
$this->data->getPageDetails($page);
echo "<a class=\"multi0\" href=\"".url::base(TRUE)."page?page=".$page."\" title=\"".$this->data->PAGE_DEF['page_name']."\">".pnp::shorten($this->data->PAGE_DEF['page_name'])."</a><br>\n";
echo "</span>\n";
}
?>
</div>
</div>
<p>
<?php } ?>

View File

@@ -0,0 +1,10 @@
<table><tr><td>
<?php
foreach ( $this->data->STRUCT as $KEY=>$VAL){
$source = $VAL['SOURCE'];
echo "<tr><td>\n";
echo "<img width=\"".$imgwidth."\" src=\"".url::base(TRUE)."image?host=".urlencode($host)."&srv=".urlencode($srv)."&view=$view&source=$source\">\n";
echo "</td></tr>\n";
}
?>
</table>

View File

@@ -0,0 +1,22 @@
<?php if( $this->isAuthorizedFor('host_search') ){ ?>
<!-- Search Box Start -->
<script type="text/javascript">
jQuery(function() {
jQuery("#query").autocomplete({
source: "<?php echo url::base('true')?>/index.php/ajax/search",
select: function(event, ui) { window.location = "<?php echo url::base('true')?>" + "graph?host=" + ui.item.value }
});
});
</script>
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.search-box-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom">
<input type="text" name="host" id="query" class="textbox" />
</div>
</div>
<p>
<!-- Search Box End -->
<?php } ?>

View File

@@ -0,0 +1,36 @@
<?php if (!empty($services) && $this->isAuthorizedFor('service_links') ) { ?>
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.service-box-header') ?>
</div>
<?php
$filter = $this->session->get('sfilter');
?>
<div class="p4 ui-widget-content">
<?php
echo "<input type=\"text\" name=\"service-filter\" id=\"service-filter\" value=\"".$filter."\" class=\"textbox\" />"
?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" id="services">
<?php
foreach($services as $service){
echo "<span id=\"service-".$service['servicedesc']."\">\n";
$path = pnp::addToUri( array('host' => $host, 'srv' => $service['name']) );
echo pnp::add_to_basket_icon($host,
$service['name']);
echo "<a href=\"".$path."\" class=\"multi".$service['is_multi']. " " . $service['state'].
"\" title=\"".$service['servicedesc'].
"\">";
echo pnp::shorten($service['servicedesc']).
"</a><br>\n";
echo "</span>\n";
}
?>
</div>
</div>
<p>
<?php } ?>

View File

@@ -0,0 +1,31 @@
<?php if (!empty($this->templates) && $this->isAuthorizedFor('service_links') ) { ?>
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.special-templates-box-header') ?>
</div>
<?php
$filter = $this->session->get('spfilter');
?>
<div class="p4 ui-widget-content">
<?php
echo "<input type=\"text\" name=\"special-filter\" id=\"special-filter\" value=\"".$filter."\"class=\"textbox\" />"
?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom" id="special-templates">
<?php
foreach($this->templates as $template){
echo "<span id=\"special-".$template."\">";
$path = pnp::addToUri( array('tpl' => $template) );
echo "<a href=\"".$path."\" class=\"multi0\">".
pnp::shorten($template).
"</a><br>\n";
echo "</span>\n";
}
?>
</div>
</div>
<p>
<?php } ?>

View File

@@ -0,0 +1,19 @@
<div class="ui-widget">
<div class="p2 ui-widget-header ui-corner-top">
<?php echo Kohana::lang('common.status-box-header') ?>
</div>
<div class="p4 ui-widget-content ui-corner-bottom">
<?php if(isset($host)) echo "<strong>Host:&nbsp;</strong>".
html::anchor('graph'.
"?host=".$lhost,
html::specialchars(pnp::shorten($host))."<br>");?>
<?php if(isset($service)) echo "<strong>Service:&nbsp;</strong>" .
html::anchor('graph'.
"?host=".$lhost.
"&srv=".$lservice,
html::specialchars(pnp::shorten($service))."<br>");?>
<?php if(isset($timet)) echo "<strong>Last Check:&nbsp;</strong>$timet<br>"?>
</div>
</div>
<p>

View File

@@ -0,0 +1,221 @@
<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="<?php echo $this->config->conf['refresh'] ?>" />
<title><?php if (isset($this->title)) echo html::specialchars($this->title) ?></title>
<?php echo html::stylesheet('media/css/common.css') ?>
<?php echo html::stylesheet('media/css/imgareaselect-default.css') ?>
<?php echo html::stylesheet('media/css/ui-'.$this->theme.'/jquery-ui.css') ?>
<?php echo html::link('media/images/favicon.ico','icon','image/ico') ?>
<?php echo html::script('media/js/jquery-min.js')?>
<?php echo html::script('media/js/jquery.imgareaselect.min.js')?>
<?php echo html::script('media/js/jquery-ui.min.js')?>
<?php echo html::script('media/js/jquery-ui-timepicker-addon.js')?>
<script type="text/javascript">
jQuery.noConflict();
jQuery(window).load(
function() {
jQuery('div.graph').each(function(){
var img_width = jQuery(this).next('img').width();
var rrd_width = parseInt(jQuery(this).css('width'));
var left = img_width - rrd_width - <?php echo $this->config->conf['right_zoom_offset'] ?>;
jQuery(this).css('left', left);
jQuery(this).css('cursor', 'e-resize');
jQuery(this).attr('title', 'Click to zoom in');
});
jQuery('img.goto').css('visibility', 'visible');
jQuery('div.graph').imgAreaSelect({ handles: false, autoHide: true,
fadeSpeed: 500, onSelectEnd: redirect, minHeight: '<?php echo $this->config->conf['graph_height'] ?>' });
function redirect(img, selection) {
if (!selection.width || !selection.height)
return;
var graph_width = parseInt(jQuery(img).css('width'));
var link = jQuery(img).attr('id');
var ostart = Math.abs(jQuery(img).attr('start'));
var oend = Math.abs(jQuery(img).attr('end'));
var delta = (oend - ostart);
if( delta < 600 )
delta = 600;
var sec_per_px = parseInt( delta / graph_width);
var start = ostart + Math.ceil( selection.x1 * sec_per_px );
var end = ostart + ( selection.x2 * sec_per_px );
window.location = link + '&start=' + start + '&end=' + end ;
}
var sfilter = "<?php echo $this->session->get('sfilter') ?>";
var spfilter = "<?php echo $this->session->get('spfilter') ?>";
var pfilter = "<?php echo $this->session->get('pfilter') ?>";
if(jQuery("#service-filter").length) {
console.log("send keyup")
jQuery("#service-filter").keyup()
}
if(jQuery("#special-filter").length) {
jQuery("#special-filter").keyup()
}
if(jQuery("#page-filter").length) {
jQuery("#page-filter").keyup()
}
});
jQuery(document).ready(function(){
var path = "<?php echo url::base(TRUE)."/"?>";
jQuery("img").fadeIn(1500);
jQuery("#basket_action_add a").live("click", function(){
var item = (this.id)
jQuery.ajax({
type: "POST",
url: path + "ajax/basket/add",
data: { item: item },
success: function(msg){
jQuery("#basket_items").html(msg);
window.location.reload()
}
});
});
jQuery("#basket-clear").live("click", function(){
jQuery.ajax({
type: "POST",
url: path + "ajax/basket/clear",
success: function(msg){
window.location.reload()
}
});
});
jQuery("#basket-show").live("click", function(){
window.location.href = path + 'page/basket'
});
jQuery(".basket_action_remove a").live("click", function(){
var item = (this.id)
jQuery.ajax({
type: "POST",
url: path + "ajax/basket/remove/",
data: { item: item },
success: function(msg){
jQuery("#basket_items").html(msg);
window.location.reload()
}
});
});
jQuery("#basket_items" ).sortable({
update: function(event, ui) {
var items = jQuery(this).sortable('toArray').toString();
jQuery.ajax({
type: "POST",
url: path + "ajax/basket/sort",
data: { items: items },
success: function(msg){
window.location.reload()
}
});
}
});
jQuery("#basket_items" ).disableSelection();
jQuery("#remove_timerange_session").click(function(){
jQuery.ajax({
type: "GET",
url: path + "ajax/remove/timerange",
success: function(){
location.reload();
}
});
});
jQuery("#service-filter").keyup(function () {
var sfilter = jQuery("#service-filter").val();
if(sfilter != "") {
jQuery("#service-filter").css('background-color','#ff9999');
}else{
jQuery("#service-filter").css('background-color','white');
}
jQuery.ajax({
type: "POST",
url: path + "ajax/filter/set-sfilter",
data: { sfilter: sfilter }
});
jQuery("#services span[id^='service']").each(function () {
if (jQuery(this).attr('id').search(new RegExp("service-.*" + sfilter,"i")) == 0) {
jQuery(this).show();
} else {
jQuery(this).hide();
}
});
});
jQuery("#special-filter").keyup(function () {
var spfilter = jQuery("#special-filter").val();
if(spfilter != "") {
jQuery("#special-filter").css('background-color','#ff9999');
}else{
jQuery("#special-filter").css('background-color','white');
}
jQuery.ajax({
type: "POST",
url: path + "ajax/filter/set-spfilter",
data: { spfilter: spfilter }
});
jQuery("#special-templates span[id^='special']").each(function () {
if (jQuery(this).attr('id').search(new RegExp("special-.*" + spfilter,"i")) == 0) {
jQuery(this).show();
} else {
jQuery(this).hide();
};
});
});
jQuery("#page-filter").keyup(function () {
var pfilter = jQuery("#page-filter").val();
if(pfilter != "") {
jQuery("#page-filter").css('background-color','#ff9999');
}else{
jQuery("#page-filter").css('background-color','white');
}
jQuery.ajax({
type: "POST",
url: path + "ajax/filter/set-pfilter",
data: { pfilter: pfilter }
});
jQuery("#pages span[id^='page']").each(function () {
if (jQuery(this).attr('id').search(new RegExp("page-.*" + pfilter,"i")) == 0) {
jQuery(this).show();
} else {
jQuery(this).hide();
};
});
});
});
<?php if (!empty($zoom_header)) {
echo $zoom_header;
} ?>
</script>
</head>
<body>
<?php if (!empty($graph)) {
echo $graph;
} ?>
<?php if (!empty($debug)) {
echo $debug;
} ?>
<?php if (!empty($color)) {
echo $color;
} ?>
<?php if (!empty($zoom)) {
echo $zoom;
} ?>
<?php if (!empty($page)) {
echo $page;
} ?>
<?php if (!empty($docs)) {
echo $docs;
} ?>
</body>
</html>

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