0) { $f = fopen($file, "a"); ob_start(); echo date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info . "\n"; print_r($var); echo "\n\n"; $output = ob_get_clean(); fprintf($f,"%s",$output); fclose($f); } else { echo "
" .
				date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info .
				"
"; echo "
";print_r($var);echo "
"; } } public function createPage($title = null, $page_name = null) { if (!isset($title)) { $this->title = __('Pandora FMS mobile'); } else { $this->title = $title; } if (!isset($page_name)) { $this->page_name = 'main_page'; } else { $this->page_name = $page_name; } $this->html = ''; $this->endHeader = false; $this->header = array(); $this->endContent = false; $this->content = array(); $this->noFooter = false; $this->endFooter = false; $this->footer = array(); $this->form = array(); $this->grid = array(); $this->collapsible = array(); $this->endForm = true; $this->endGrid = true; $this->endCollapsible = true; $this->dialog = ''; $this->dialogs = array(); } public function showFooter($show = true) { $this->noFooter = !$show; } public function beginHeader() { $this->header = array(); $this->header['button_left'] = ''; $this->header['button_right'] = ''; $this->header['title'] = __('Pandora FMS mobile'); $this->endHeader = false; } public function endHeader() { $this->endHeader = true; } public function createHeader($title = null, $buttonLeft = null, $buttonRight = null) { $this->beginHeader(); $this->headerTitle($title); $this->headerAddButtonLeft($buttonLeft); $this->headerAddButtonRight($buttonRight); $this->endHeader(); } public function headerTitle($title = null) { if (isset($title)) { $this->header['title'] = $title; } } public function headerAddButtonLeft($button = null) { if (isset($button)) { $this->header['button_left'] = $button; } } public function headerAddButtonRight($button = null) { if (isset($button)) { $this->header['button_right'] = $button; } } public function createHeaderButton($options) { return $this->createButton($options); } public function createDefaultHeader($title = false, $left_button = false) { if ($title === false) { $title = __('Pandora FMS mobile'); } if ($left_button === false) { $left_button = $this->createHeaderButton( array('icon' => 'back', 'pos' => 'left', 'text' => __('Logout'), 'href' => 'index.php?action=logout')); } $this->createHeader( $title, $left_button, $this->createHeaderButton( array('icon' => 'home', 'pos' => 'right', 'text' => __('Home'), 'href' => 'index.php?page=home'))); } public function createButton($options) { $return = 'footer = array(); $this->endFooter = false; } public function endFooter() { $this->endFooter = true; } public function createFooter($text = "") { $this->footerText($text); } public function footerText($text = null) { if (!isset($text)) { $this->footer['text'] = ''; } else { $this->footer['text'] = $text; } $this->endFooter(); } public function defaultFooter() { global $pandora_version, $build_version; if (isset($_SERVER['REQUEST_TIME'])) { $time = $_SERVER['REQUEST_TIME']; } else { $time = get_system_time (); } return ""; } public function beginContent() { $this->content = array(); $this->endContent = false; } public function endContent() { $this->endContent = true; } public function contentAddHtml($html) { $this->content[] = $html; } public function contentBeginGrid($mode = 'responsive') { $this->endGrid = false; $this->grid = array(); $this->grid['mode'] = $mode; $this->grid['cells'] = array(); } public function contentGridAddCell($html, $key = false) { $k = uniqid('cell_'); if ($key !== false) { $k = $key; } $this->grid['cells'][$k] = $html; } public function contentEndGrid() { $this->endGrid = true; //TODO Make others modes, only responsible mode $convert_columns_jquery_grid = array( 2 => 'a', 3 => 'b', 4 => 'c', 5 => 'd'); $convert_cells_jquery_grid = array('a', 'b', 'c', 'd', 'e'); $html = "
\n"; reset($convert_cells_jquery_grid); foreach ($this->grid['cells'] as $key => $cell) { switch ($this->grid['mode']) { default: case 'responsive': $html .= "
\n"; break; } next($convert_cells_jquery_grid); $html .= "
\n"; $html .= $cell; $html .= "
\n"; $html .= "
\n"; } $html .= "
\n"; $this->contentAddHtml($html); $this->grid = array(); } public function contentBeginCollapsible($title = " ") { $this->endCollapsible = false; $this->collapsible = array(); $this->collapsible['items'] = array(); $this->collapsible['title'] = $title; } public function contentCollapsibleAddItem($html) { $this->collapsible['items'][] = $html; } public function contentEndCollapsible() { $this->endCollapsible = true; $html = "
\n"; $html .= "

" . $this->collapsible['title'] . "

\n"; $html .= "\n"; $html .= "
\n"; $this->contentAddHtml($html); $this->collapsible = array(); } public function beginForm($action = "index.php", $method = "post") { $this->form = array(); $this->endForm = false; $this->form['action'] = $action; $this->form['method'] = $method; } public function endForm() { $this->contentAddHtml($this->getEndForm()); } public function getEndForm() { $this->endForm = true; $html = "
\n"; foreach ($this->form['fields'] as $field) { $html .= $field . "\n"; } $html .= "
\n"; $this->form = array(); return $html; } public function formAddHtml($html) { $this->form['fields'][] = $html; } public function formAddInput($options) { $this->formAddHtml($this->getInput($options)); } public function getInput($options) { if (empty($options['name'])) { $options['name'] = uniqid('input'); } if (empty($options['id'])) { $options['id'] = 'text-' . $options['name']; } $html = "
\n"; $html .= "
\n"; if (!empty($options['label'])) { $html .= "\n"; } //Erase other options and only for the input unset($options['label']); $html .= " $value) { $html .= " " . $option . "='" . $value . "' "; } $html .= ">\n"; $html .= "
\n"; $html .= "
\n"; return $html; } public function formAddInputPassword($options) { $options['type'] = 'password'; $this->formAddInput($options); } public function formAddInputText($options) { $options['type'] = 'text'; $this->formAddInput($options); } public function formAddInputSearch($options) { $options['type'] = 'search'; $this->formAddInput($options); } public function formAddInpuDate($options) { $options['type'] = 'date'; $options['data-clear-btn'] = "false"; $this->formAddInput($options); } public function formAddCheckbox($options) { $options['type'] = 'checkbox'; if (isset($options['checked'])) { if ($options['checked']) { $options['checked'] = 'checked'; } else { unset($options['checked']); } } $this->formAddInput($options); } public function formAddSubmitButton($options) { $options['type'] = 'submit'; if (isset($options['icon'])) { $options['data-icon'] = $options['icon']; unset($options['icon']); } if (isset($options['icon_pos'])) { $options['data-iconpos'] = $options['icon_pos']; unset($options['icon_pos']); } if (isset($options['text'])) { $options['value'] = $options['text']; unset($options['text']); } $this->formAddInput($options); } public function formAddSelectBox($options) { $html = ''; if (empty($options['name'])) { $options['name'] = uniqid('input'); } if (empty($options['id'])) { $options['id'] = 'select-' . $options['name']; } $html = "
\n"; $html .= "
\n"; if (!empty($options['label'])) { $html .= "\n"; } $html .= "\n"; $html .= "
\n"; $html .= "
\n"; $this->formAddHtml($html); } public function formAddSlider($options) { $options['type'] = 'range'; $this->formAddInput($options); // } public function addDialog($options) { $type = 'hidden'; $dialog_id = uniqid('dialog_'); $dialog_class = ''; $title_close_button = false; $title_text = ''; $content_id = uniqid('content_'); $content_class = ''; $content_text = ''; $button_close = true; $button_text = __('Close'); if (is_array($options)) { if (isset($options['type'])) $type = $options['type']; if (isset($options['dialog_id'])) $dialog_id = $options['dialog_id']; if (isset($options['dialog_class'])) $dialog_class = $options['dialog_class']; if (isset($options['title_close_button'])) $title_close_button = $options['title_close_button']; if (isset($options['title_text'])) $title_text = $options['title_text']; if (isset($options['content_id'])) $content_id = $options['content_id']; if (isset($options['content_class'])) $content_class = $options['content_class']; if (isset($options['content_text'])) $content_text = $options['content_text']; if (isset($options['button_close'])) $button_close = $options['button_close']; if (isset($options['button_text'])) $button_text = $options['button_text']; } $html_title_close_button = ""; if ($title_close_button) { $html_title_close_button = "data-close-btn='yes'"; } $dialogHtml = "
\n"; $dialogHtml .= "
\n"; $dialogHtml .= "

" . $title_text . "

\n"; $dialogHtml .= "
\n"; $dialogHtml .= "
\n"; $dialogHtml .= $content_text; if ($button_close) { $dialogHtml .= ""; if (empty($button_text)) { $dialogHtml .= __('Close'); } else { $dialogHtml .= $button_text; } $dialogHtml .= "

\n"; } $dialogHtml .= "
\n"; $dialogHtml .= "
\n"; $this->dialogs[$type][] = $dialogHtml; } public function showError($msg) { echo $msg; } public function showPage() { if (!$this->endHeader) { $this->showError(__('Not found header.')); } else if (!$this->endContent) { $this->showError(__('Not found content.')); } else if ((!$this->endFooter) && (!$this->noFooter)) { $this->showError(__('Not found footer.')); } else if (!$this->endForm) { $this->showError(__('Incorrect form.')); } else if (!$this->endGrid) { $this->showError(__('Incorrect grid.')); } else if (!$this->endCollapsible) { $this->showError(__('Incorrect collapsible.')); } ob_start (); echo "\n"; echo "\n"; echo " \n"; echo " " . $this->title . "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; //echo " \n"; echo " \n"; echo " \n"; //echo " \n"; echo " \n"; echo " \n"; echo "
"; if (!empty($this->dialogs)) { if (!empty($this->dialogs['onStart'])) { foreach ($this->dialogs['onStart'] as $dialog) { echo " " . $dialog . "\n"; } } } echo "
\n"; echo "
\n"; echo "

" . $this->header['title'] . "

\n"; echo " " . $this->header['button_left'] . "\n"; echo " " . $this->header['button_right'] . "\n"; echo "
\n"; echo "
\n"; foreach ($this->content as $content) { echo " " . $content . "\n"; } echo "
\n"; if (!$this->noFooter) { echo "
\n"; if (!empty($this->footer['text'])) { echo " " . $this->footer['text'] . "\n"; } else { echo " " . $this->defaultFooter() . "\n"; } } echo "
\n"; echo "
\n"; if (!empty($this->dialogs)) { if (!empty($this->dialogs['hidden'])) { foreach ($this->dialogs['hidden'] as $dialog) { echo " " . $dialog . "\n"; } } } echo ""; echo " \n"; echo ""; ob_end_flush(); } // // } class Table { private $head = array(); private $rows = array(); public $id = ''; private $rowClass = array(); private $class_table = ''; private $row_heads = array(); public $row_keys_as_head_row = false; public function __construct() { $this->init(); } public function init() { $this->id = uniqid(); $this->head = array(); $this->rows = array(); $this->rowClass = array(); $this->class_table = ''; $this->row_heads = array(); $this->row_keys_as_head_row = false; } public function addHeader($head) { $this->head = $head; } public function addRowHead($key, $head_text) { $this->row_heads[$key] = $head_text; } public function addRow($row = array(), $key = false) { if ($key !== false) { $this->rows[$key] = $row; } else { $this->rows[] = $row; } } public function importFromHash($data) { foreach ($data as $id => $row) { $table_row = array(); foreach ($row as $key => $value) { if (!in_array($key, $this->head)) { $this->head[] = $key; } $cell_key = array_search($key, $this->head); $table_row[$cell_key] = $value; } $this->rows[$id] = $table_row; } } public function setClass($class = '') { $this->class_table = $class; } public function setId($id = false) { if (empty($id)) { $this->id = uniqid(); } else { $this->id = $id; } } public function setRowClass($class = '', $pos = false) { if (is_array($class)) { $this->rowClass = $class; } else { if ($pos !== false) { $this->rowClass[$pos] = $class; } else { $this->rowClass = array_fill(0, count($this->rows), $class); } } } public function getHTML() { $html = ''; $html = "\n"; $html .= "\n"; $html .= "\n"; //Empty head for white space between rows in the responsive vertical layout $html .= "\n"; foreach ($this->head as $head) { $html .= "\n"; } $html .= "\n"; $html .= "\n"; $html .= "\n"; foreach ($this->rows as $key => $row) { $class = ''; if (isset($this->rowClass[$key])) { $class = $this->rowClass[$key]; } $html .= "\n"; //Empty head for white space between rows in the responsive vertical layout if (isset($this->row_heads[$key])) { $html .= "\n"; } elseif ($this->row_keys_as_head_row) { $html .= "\n"; } else { $html .= "\n"; } foreach ($row as $key_cell => $cell) { $html .= "\n"; } $html .= "\n"; } $html .= "\n"; $html .= "
" . $head . "
" . $this->row_heads[$key] . "" . $key . "" . $cell . "
\n"; return $html; } } ?>