diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
new file mode 100644
index 0000000..3286099
--- /dev/null
+++ b/.github/copilot-instructions.md
@@ -0,0 +1,23 @@
+# Cacti cycle Plugin AI Instructions
+
+## Project Overview
+This is a Cacti plugin. It integrates with the Cacti monitoring platform via the plugin hook architecture.
+
+## Technology Stack
+- PHP 7.4+ (targeting Cacti 1.2.x compatibility)
+- MySQL/MariaDB via Cacti's DB abstraction layer
+- PSR-12 coding standards
+
+## Key Rules
+- Use prepared statements (db_execute_prepared, db_fetch_row_prepared, etc.) for ALL queries with variables
+- Use get_request_var() / get_filter_request_var() for ALL user input, never raw $_REQUEST/$_GET/$_POST
+- Use html_escape() / htmlspecialchars() for ALL output of DB/user values in HTML context
+- Use cacti_escapeshellarg() for ALL shell command arguments
+- No PHP 8.0+ features (str_contains, match, union types, named args) - target PHP 7.4
+- Use ?? and ??= operators (PHP 7.4) instead of isset() ternary patterns
+- All unserialize() calls must use allowed_classes => false
+
+## Testing
+- Tests in tests/ directory
+- Use Pest PHP or PHPUnit
+- php -l lint check required before commit
diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml
new file mode 100644
index 0000000..8888dd9
--- /dev/null
+++ b/.github/workflows/plugin-ci-workflow.yml
@@ -0,0 +1,225 @@
+# +-------------------------------------------------------------------------+
+# | Copyright (C) 2004-2026 The Cacti Group |
+# | |
+# | This program is free software; you can redistribute it and/or |
+# | modify it under the terms of the GNU General Public License |
+# | as published by the Free Software Foundation; either version 2 |
+# | of the License, or (at your option) any later version. |
+# | |
+# | This program is distributed in the hope that it will be useful, |
+# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+# | GNU General Public License for more details. |
+# +-------------------------------------------------------------------------+
+# | Cacti: The Complete RRDtool-based Graphing Solution |
+# +-------------------------------------------------------------------------+
+# | This code is designed, written, and maintained by the Cacti Group. See |
+# | about.php and/or the AUTHORS file for specific developer information. |
+# +-------------------------------------------------------------------------+
+# | http://www.cacti.net/ |
+# +-------------------------------------------------------------------------+
+
+name: Plugin Integration Tests
+
+on:
+ push:
+ branches:
+ - main
+ - develop
+ pull_request:
+ branches:
+ - main
+ - develop
+
+jobs:
+ integration-test:
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ fail-fast: false
+ matrix:
+ php: ['8.1', '8.2', '8.3', '8.4']
+ os: [ubuntu-latest]
+
+ services:
+ mariadb:
+ image: mariadb:10.6
+ env:
+ MYSQL_ROOT_PASSWORD: cactiroot
+ MYSQL_DATABASE: cacti
+ MYSQL_USER: cactiuser
+ MYSQL_PASSWORD: cactiuser
+ ports:
+ - 3306:3306
+ options: >-
+ --health-cmd="mysqladmin ping"
+ --health-interval=10s
+ --health-timeout=5s
+ --health-retries=3
+
+ name: PHP ${{ matrix.php }} Integration Test on ${{ matrix.os }}
+
+ steps:
+ - name: Checkout Cacti
+ uses: actions/checkout@v4
+ with:
+ repository: Cacti/cacti
+ path: cacti
+
+ - name: Checkout cycle Plugin
+ uses: actions/checkout@v4
+ with:
+ path: cacti/plugins/cycle
+
+ - name: Install PHP ${{ matrix.php }}
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring
+ ini-values: "post_max_size=256M, max_execution_time=60, date.timezone=America/New_York"
+
+ - name: Check PHP version
+ run: php -v
+
+ - name: Run apt-get update
+ run: sudo apt-get update
+
+ - name: Install System Dependencies
+ run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping
+
+ - name: Start SNMPD Agent and Test
+ run: |
+ sudo systemctl start snmpd
+ sudo snmpwalk -c public -v2c -On localhost .1.3.6.1.2.1.1
+
+ - name: Setup Permissions
+ run: |
+ sudo chown -R www-data:runner ${{ github.workspace }}/cacti
+ sudo find ${{ github.workspace }}/cacti -type d -exec chmod 775 {} \;
+ sudo find ${{ github.workspace }}/cacti -type f -exec chmod 664 {} \;
+ sudo chmod +x ${{ github.workspace }}/cacti/cmd.php
+ sudo chmod +x ${{ github.workspace }}/cacti/poller.php
+
+ - name: Create MySQL Config
+ run: |
+ echo -e "[client]\nuser = root\npassword = cactiroot\nhost = 127.0.0.1\n" > ~/.my.cnf
+ cat ~/.my.cnf
+
+ - name: Initialize Cacti Database
+ env:
+ MYSQL_AUTH_USR: '--defaults-file=~/.my.cnf'
+ run: |
+ mysql $MYSQL_AUTH_USR -e 'CREATE DATABASE IF NOT EXISTS cacti;'
+ mysql $MYSQL_AUTH_USR -e "CREATE USER IF NOT EXISTS 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';"
+ mysql $MYSQL_AUTH_USR -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';"
+ mysql $MYSQL_AUTH_USR -e "GRANT SELECT ON mysql.time_zone_name TO 'cactiuser'@'localhost';"
+ mysql $MYSQL_AUTH_USR -e "FLUSH PRIVILEGES;"
+ mysql $MYSQL_AUTH_USR cacti < ${{ github.workspace }}/cacti/cacti.sql
+ mysql $MYSQL_AUTH_USR -e "INSERT INTO settings (name, value) VALUES ('path_php_binary', '/usr/bin/php')" cacti
+
+ - name: Validate composer files
+ run: |
+ cd ${{ github.workspace }}/cacti
+ if [ -f composer.json ]; then
+ composer validate --strict || true
+ fi
+
+ - name: Install Composer Dependencies
+ run: |
+ cd ${{ github.workspace }}/cacti
+ if [ -f composer.json ]; then
+ sudo composer install --prefer-dist --no-progress
+ fi
+
+ - name: Create Cacti config.php
+ run: |
+ cat ${{ github.workspace }}/cacti/include/config.php.dist | \
+ sed -r "s/localhost/127.0.0.1/g" | \
+ sed -r "s/'cacti'/'cacti'/g" | \
+ sed -r "s/'cactiuser'/'cactiuser'/g" | \
+ sed -r "s/'cactiuser'/'cactiuser'/g" > ${{ github.workspace }}/cacti/include/config.php
+ sudo chmod 664 ${{ github.workspace }}/cacti/include/config.php
+
+ - name: Configure Apache
+ run: |
+ cat << 'EOF' | sed 's#GITHUB_WORKSPACE#${{ github.workspace }}#g' > /tmp/cacti.conf
+
+ ServerAdmin webmaster@localhost
+ DocumentRoot GITHUB_WORKSPACE/cacti
+
+
+ Options Indexes FollowSymLinks
+ AllowOverride All
+ Require all granted
+
+
+ ErrorLog ${APACHE_LOG_DIR}/error.log
+ CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+ EOF
+ sudo cp /tmp/cacti.conf /etc/apache2/sites-available/000-default.conf
+ sudo systemctl restart apache2
+
+ - name: Install Cacti via CLI
+ run: |
+ cd ${{ github.workspace }}/cacti
+ sudo php cli/install_cacti.php --accept-eula --install --force
+
+ - name: Install cycle Plugin
+ run: |
+ cd ${{ github.workspace }}/cacti
+ sudo php cli/plugin_manage.php --plugin=cycle --install --enable
+
+# - name: import cycle Plugin Sample Data
+# run: |
+# cd ${{ github.workspace }}/cacti/plugins/cycle
+# sudo php cli_import.php --filename=.github/workflows/cycle_sample_data.xml
+# if [ $? -ne 0 ]; then
+# echo "Failed to import Thold sample data"
+# exit 1
+# fi
+
+ - name: Check PHP Syntax for Plugin
+ run: |
+ cd ${{ github.workspace }}/cacti/plugins/cycle
+ if find . -name '*.php' -exec php -l {} 2>&1 \; | grep -iv 'no syntax errors detected'; then
+ echo "Syntax errors found!"
+ exit 1
+ fi
+
+ - name: Remove the plugins directory exclusion from the .phpstan.neon
+ run: sed '/plugins/d' -i .phpstan.neon
+ working-directory: ${{ github.workspace }}/cacti
+
+ - name: Mark composer scripts executable
+ run: sudo chmod +x ${{ github.workspace }}/cacti/include/vendor/bin/*
+
+ - name: Run Linter on base code
+ run: composer run-script lint ${{ github.workspace }}/cacti/plugins/cycle
+ working-directory: ${{ github.workspace }}/cacti
+
+ - name: Checking coding standards on base code
+ run: composer run-script phpcsfixer ${{ github.workspace }}/cacti/plugins/cycle
+ working-directory: ${{ github.workspace }}/cacti
+
+# - name: Run PHPStan at Level 6 on base code outside of Composer due to technical issues
+# run: ./include/vendor/bin/phpstan analyze --level 6 ${{ github.workspace }}/cacti/plugins/cycle
+# working-directory: ${{ github.workspace }}/cacti
+
+ - name: Run Cacti Poller
+ run: |
+ cd ${{ github.workspace }}/cacti
+ sudo php poller.php --poller=1 --force --debug
+ if ! grep -q "SYSTEM STATS" log/cacti.log; then
+ echo "Cacti poller did not finish successfully"
+ cat log/cacti.log
+ exit 1
+ fi
+
+ - name: View Cacti Logs
+ if: always()
+ run: |
+ if [ -f ${{ github.workspace }}/cacti/log/cacti.log ]; then
+ echo "=== Cacti Log ==="
+ sudo cat ${{ github.workspace }}/cacti/log/cacti.log
+ fi
diff --git a/cycle.php b/cycle.php
index fc996d1..5e10a7a 100644
--- a/cycle.php
+++ b/cycle.php
@@ -42,18 +42,18 @@
validate_request_vars();
switch(get_request_var('action')) {
-case 'save':
- save_settings();
+ case 'save':
+ save_settings();
- break;
-case 'graphs':
- cycle_graphs();
+ break;
+ case 'graphs':
+ cycle_graphs();
- break;
-default:
- cycle();
+ break;
+ default:
+ cycle();
- break;
+ break;
}
function cycle_graphs() {
@@ -73,11 +73,16 @@ function cycle_graphs() {
$width = get_request_var('width');
$height = get_request_var('height');
- if (empty($tree_id)) $tree_id = db_fetch_cell('SELECT id FROM graph_tree ORDER BY name LIMIT 1');
- if (empty($id)) $id = -1;
+ if (empty($tree_id)) {
+ $tree_id = db_fetch_cell('SELECT id FROM graph_tree ORDER BY name LIMIT 1');
+ }
+
+ if (empty($id)) {
+ $id = -1;
+ }
- /* get the start and end times for the graph */
- $timespan = array();
+ // get the start and end times for the graph
+ $timespan = [];
$first_weekdayid = read_user_setting('first_weekdayid');
get_timespan($timespan, time(), get_request_var('timespan'), $first_weekdayid);
@@ -87,31 +92,32 @@ function cycle_graphs() {
get_next_graphid($graphpp, $rfilter, $graph_tree, $leaf_id);
- /* create the graph structure and output */
+ // create the graph structure and output
$out = '
@@ -401,4 +431,3 @@ function cycle() {
bottom_footer();
}
-
diff --git a/functions.php b/functions.php
index e3ef928..e087e83 100644
--- a/functions.php
+++ b/functions.php
@@ -24,38 +24,38 @@
include_once(__DIR__ . '/setup.php');
-$graphs_ppage = array(
- 1 => __('%d Graph', 1, 'cycle'),
- 2 => __('%d Graphs', 2, 'cycle'),
- 4 => __('%d Graphs', 4, 'cycle'),
- 6 => __('%d Graphs', 6, 'cycle'),
- 8 => __('%d Graphs', 8, 'cycle'),
- 9 => __('%d Graphs', 9, 'cycle'),
- 10 => __('%d Graphs', 10, 'cycle'),
- 12 => __('%d Graphs', 12, 'cycle'),
- 15 => __('%d Graphs', 15, 'cycle'),
- 16 => __('%d Graphs', 16, 'cycle'),
- 18 => __('%d Graphs', 18, 'cycle'),
- 20 => __('%d Graphs', 20, 'cycle'),
- 24 => __('%d Graphs', 24, 'cycle'),
- 25 => __('%d Graphs', 25, 'cycle'),
- 28 => __('%d Graphs', 28, 'cycle'),
- 30 => __('%d Graphs', 30, 'cycle'),
- 32 => __('%d Graphs', 32, 'cycle'),
- 35 => __('%d Graphs', 35, 'cycle'),
- 36 => __('%d Graphs', 36, 'cycle'),
- 40 => __('%d Graphs', 40, 'cycle'),
- 42 => __('%d Graphs', 42, 'cycle'),
- 48 => __('%d Graphs', 48, 'cycle'),
- 50 => __('%d Graphs', 50, 'cycle'),
- 60 => __('%d Graphs', 60, 'cycle'),
- 70 => __('%d Graphs', 70, 'cycle'),
- 80 => __('%d Graphs', 80, 'cycle'),
- 90 => __('%d Graphs', 90, 'cycle'),
- 100 => __('%d Graphs', 100, 'cycle')
-);
-
-$graph_cols = array(
+$graphs_ppage = [
+ 1 => __('%d Graph', 1, 'cycle'),
+ 2 => __('%d Graphs', 2, 'cycle'),
+ 4 => __('%d Graphs', 4, 'cycle'),
+ 6 => __('%d Graphs', 6, 'cycle'),
+ 8 => __('%d Graphs', 8, 'cycle'),
+ 9 => __('%d Graphs', 9, 'cycle'),
+ 10 => __('%d Graphs', 10, 'cycle'),
+ 12 => __('%d Graphs', 12, 'cycle'),
+ 15 => __('%d Graphs', 15, 'cycle'),
+ 16 => __('%d Graphs', 16, 'cycle'),
+ 18 => __('%d Graphs', 18, 'cycle'),
+ 20 => __('%d Graphs', 20, 'cycle'),
+ 24 => __('%d Graphs', 24, 'cycle'),
+ 25 => __('%d Graphs', 25, 'cycle'),
+ 28 => __('%d Graphs', 28, 'cycle'),
+ 30 => __('%d Graphs', 30, 'cycle'),
+ 32 => __('%d Graphs', 32, 'cycle'),
+ 35 => __('%d Graphs', 35, 'cycle'),
+ 36 => __('%d Graphs', 36, 'cycle'),
+ 40 => __('%d Graphs', 40, 'cycle'),
+ 42 => __('%d Graphs', 42, 'cycle'),
+ 48 => __('%d Graphs', 48, 'cycle'),
+ 50 => __('%d Graphs', 50, 'cycle'),
+ 60 => __('%d Graphs', 60, 'cycle'),
+ 70 => __('%d Graphs', 70, 'cycle'),
+ 80 => __('%d Graphs', 80, 'cycle'),
+ 90 => __('%d Graphs', 90, 'cycle'),
+ 100 => __('%d Graphs', 100, 'cycle')
+];
+
+$graph_cols = [
1 => __('%d Column', 1, 'cycle'),
2 => __('%d Columns', 2, 'cycle'),
3 => __('%d Columns', 3, 'cycle'),
@@ -64,44 +64,52 @@
6 => __('%d Columns', 6, 'cycle'),
7 => __('%d Columns', 7, 'cycle'),
8 => __('%d Columns', 8, 'cycle')
-);
+];
function save_settings() {
validate_request_vars();
if (sizeof($_REQUEST)) {
- foreach($_REQUEST as $var => $value) {
+ foreach ($_REQUEST as $var => $value) {
switch($var) {
- case 'timespan':
- set_user_setting('cycle_timespan', get_request_var('timespan'));
- break;
- case 'refresh':
- set_user_setting('cycle_delay', get_request_var('refresh'));
- break;
- case 'graphs':
- set_user_setting('cycle_graphs', get_request_var('graphs'));
- break;
- case 'cols':
- set_user_setting('cycle_columns', get_request_var('cols'));
- break;
- case 'height':
- set_user_setting('cycle_height', get_request_var('height'));
- break;
- case 'width':
- set_user_setting('cycle_width', get_request_var('width'));
- break;
- case 'legend':
- if ($value == 'true') {
- $value = 'on';
- } else {
- $value = '';
- }
+ case 'timespan':
+ set_user_setting('cycle_timespan', get_request_var('timespan'));
+
+ break;
+ case 'refresh':
+ set_user_setting('cycle_delay', get_request_var('refresh'));
+
+ break;
+ case 'graphs':
+ set_user_setting('cycle_graphs', get_request_var('graphs'));
+
+ break;
+ case 'cols':
+ set_user_setting('cycle_columns', get_request_var('cols'));
+
+ break;
+ case 'height':
+ set_user_setting('cycle_height', get_request_var('height'));
+
+ break;
+ case 'width':
+ set_user_setting('cycle_width', get_request_var('width'));
+
+ break;
+ case 'legend':
+ if ($value == 'true') {
+ $value = 'on';
+ } else {
+ $value = '';
+ }
+
+ set_user_setting('cycle_legend', $value);
- set_user_setting('cycle_legend', $value);
- break;
- case 'rfilter':
- set_user_setting('cycle_filter', get_request_var('rfilter'));
- break;
+ break;
+ case 'rfilter':
+ set_user_setting('cycle_filter', get_request_var('rfilter'));
+
+ break;
}
}
}
@@ -112,93 +120,93 @@ function save_settings() {
function validate_request_vars($force = false) {
cycle_config_settings(true);
- /* ================= input validation and session storage ================= */
- $filters = array(
- 'id' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ // ================= input validation and session storage =================
+ $filters = [
+ 'id' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => '-1'
- ),
- 'tree_id' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ ],
+ 'tree_id' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => read_config_option('cycle_custom_graphs_tree', $force),
- ),
- 'leaf_id' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ ],
+ 'leaf_id' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => '-2'
- ),
- 'graphs' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ ],
+ 'graphs' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => read_user_setting('cycle_graphs', read_config_option('cycle_graphs'), $force)
- ),
- 'cols' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ ],
+ 'cols' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => read_user_setting('cycle_columns', read_config_option('cycle_columns'), $force)
- ),
- 'width' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ ],
+ 'width' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => read_user_setting('cycle_width', read_config_option('cycle_width'), $force)
- ),
- 'height' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ ],
+ 'height' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => read_user_setting('cycle_height', read_config_option('cycle_height'), $force)
- ),
- 'timespan' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ ],
+ 'timespan' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => read_user_setting('cycle_timespan', read_config_option('cycle_timespan'), $force)
- ),
- 'delay' => array(
- 'filter' => FILTER_VALIDATE_INT,
+ ],
+ 'delay' => [
+ 'filter' => FILTER_VALIDATE_INT,
'default' => read_user_setting('cycle_delay', read_config_option('cycle_delay'), $force)
- ),
- 'legend' => array(
- 'filter' => FILTER_CALLBACK,
+ ],
+ 'legend' => [
+ 'filter' => FILTER_CALLBACK,
'default' => read_user_setting('cycle_legend', read_config_option('cycle_legend'), $force),
- 'options' => array('options' => 'sanitize_search_string')
- ),
- 'rfilter' => array(
- 'filter' => FILTER_VALIDATE_IS_REGEX,
+ 'options' => ['options' => 'sanitize_search_string']
+ ],
+ 'rfilter' => [
+ 'filter' => FILTER_VALIDATE_IS_REGEX,
'pageset' => true,
'default' => read_user_setting('cycle_filter', '', $force),
- 'options' => array('options' => 'sanitize_search_string')
- )
- );
+ 'options' => ['options' => 'sanitize_search_string']
+ ]
+ ];
validate_store_request_vars($filters, 'sess_cycle');
- /* ================= input validation ================= */
+ // ================= input validation =================
}
function cycle_set_defaults() {
$user = $_SESSION['sess_user_id'];
if (!isset($_SESSION['sess_cycle_defaults'])) {
- $defaults = array(
- 'cycle_delay' => '60',
- 'cycle_timespan' => '5',
- 'cycle_columns' => '2',
- 'cycle_graphs' => '4',
- 'cycle_height' => '100',
- 'cycle_width' => '400',
- 'cycle_font_size' => '8',
- 'cycle_font_face' => '',
- 'max_length' => '100',
- 'cycle_filter' => '',
- 'cycle_font_color' => '1',
- 'cycle_legend' => '',
+ $defaults = [
+ 'cycle_delay' => '60',
+ 'cycle_timespan' => '5',
+ 'cycle_columns' => '2',
+ 'cycle_graphs' => '4',
+ 'cycle_height' => '100',
+ 'cycle_width' => '400',
+ 'cycle_font_size' => '8',
+ 'cycle_font_face' => '',
+ 'max_length' => '100',
+ 'cycle_filter' => '',
+ 'cycle_font_color' => '1',
+ 'cycle_legend' => '',
'cycle_custom_graphs_type' => '2'
- );
+ ];
- foreach($defaults as $name => $value) {
+ foreach ($defaults as $name => $value) {
$current = db_fetch_cell_prepared('SELECT value
FROM settings_user
WHERE name = ?
AND user_id = ?',
- array($name, $user));
+ [$name, $user]);
if ($current === false) {
db_execute_prepared('REPLACE INTO settings_user
(user_id, name, value)
VALUES (?, ?, ?)',
- array($user, $name, $value));
+ [$user, $name, $value]);
}
}
@@ -209,81 +217,83 @@ function cycle_set_defaults() {
function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {
global $id, $graph_id, $graphs, $next_graph_id, $prev_graph_id;
- /* if no default graph list has been specified, default to 0 */
+ // if no default graph list has been specified, default to 0
$type = read_config_option('cycle_custom_graphs_type');
$list = read_config_option('cycle_custom_graphs_list');
+
if ($type == 1 && $list == '') {
$type = 0;
}
switch($type) {
- case '0':
- case '1':
- case '2':
- $graph_id = $id;
+ case '0':
+ case '1':
+ case '2':
+ $graph_id = $id;
- if ($graph_id <= 0) {
- $graph_id = 0;
- }
-
- $sql_where = "WHERE gl.id>=$graph_id";
+ if ($graph_id <= 0) {
+ $graph_id = 0;
+ }
- if ($filter != '') {
- $sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " gtg.title_cache RLIKE '$filter'";
- }
+ $sql_where = "WHERE gl.id>=$graph_id";
- if ($type == 1) {
- $cases = explode(',', read_config_option('cycle_custom_graphs_list'));
- sort($cases);
- $newcase = '';
- foreach($cases as $case) {
- $newcase .= (is_numeric($case) ? (strlen($newcase) ? ',':'') . $case:'');
+ if ($filter != '') {
+ $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' gtg.title_cache RLIKE ' . db_qstr($filter);
}
- if (strlen($newcase)) {
- $sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " gl.id IN($newcase)";
- }
- }elseif ($type == 2) {
- $newcase = '';
- $graph_data = get_tree_graphs($graph_tree, $leaf_id);
- $local_graph_ids = array();
-
- if (sizeof($graph_data)) {
- $local_graph_ids = array_keys($graph_data);
- sort($local_graph_ids);
- }
+ if ($type == 1) {
+ $cases = explode(',', read_config_option('cycle_custom_graphs_list'));
+ sort($cases);
+ $newcase = '';
- if (sizeof($local_graph_ids)) {
- $sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . ' gl.id IN(' . implode(',', $local_graph_ids) . ')';
- }else{
- break;
+ foreach ($cases as $case) {
+ $newcase .= (is_numeric($case) ? (strlen($newcase) ? ',' : '') . $case : '');
+ }
+
+ if (strlen($newcase)) {
+ $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " gl.id IN($newcase)";
+ }
+ } elseif ($type == 2) {
+ $newcase = '';
+ $graph_data = get_tree_graphs($graph_tree, $leaf_id);
+ $local_graph_ids = [];
+
+ if (sizeof($graph_data)) {
+ $local_graph_ids = array_keys($graph_data);
+ sort($local_graph_ids);
+ }
+
+ if (sizeof($local_graph_ids)) {
+ $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' gl.id IN(' . implode(',', $local_graph_ids) . ')';
+ } else {
+ break;
+ }
}
- }
- $done = false;
- $next_found = false;
- $start = 0;
- $next_graph_id = 0;
- $prev_graph_id = 0;
- $title = '';
- $graphs = array();
- $i = 0;
-
- /* Build a graphs array of the number of graphs requested
- * this graph array will be used for rendering. In addition
- * when the user hit's next, or the graphs cycle, we need
- * to know the next graph id to display. Calculate that
- * based upon the offset $graphpp. If we overflow, start
- * from the beginning, which is the second section until
- * we either run out of rows, or reach the $graphpp limit.
- *
- * Finally, don't try to grap all graphs at once. It takes
- * too much memory on big systems.
- */
-
- /* first pass is moving up in ids */
- while (!$done) {
- $sql = "SELECT
+ $done = false;
+ $next_found = false;
+ $start = 0;
+ $next_graph_id = 0;
+ $prev_graph_id = 0;
+ $title = '';
+ $graphs = [];
+ $i = 0;
+
+ /* Build a graphs array of the number of graphs requested
+ * this graph array will be used for rendering. In addition
+ * when the user hit's next, or the graphs cycle, we need
+ * to know the next graph id to display. Calculate that
+ * based upon the offset $graphpp. If we overflow, start
+ * from the beginning, which is the second section until
+ * we either run out of rows, or reach the $graphpp limit.
+ *
+ * Finally, don't try to grap all graphs at once. It takes
+ * too much memory on big systems.
+ */
+
+ // first pass is moving up in ids
+ while (!$done) {
+ $sql = "SELECT
gl.id,
gtg.title_cache
FROM graph_local AS gl
@@ -293,70 +303,70 @@ function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {
ORDER BY gl.id ASC
LIMIT $start, $graphpp";
- $rows = db_fetch_assoc($sql);
+ $rows = db_fetch_assoc($sql);
- if ($graph_id > 0) {
- $curr_found = true;
- }else{
- $curr_found = false;
- }
+ if ($graph_id > 0) {
+ $curr_found = true;
+ } else {
+ $curr_found = false;
+ }
- if (sizeof($rows)) {
- foreach ($rows as $row) {
- if (is_graph_allowed($row['id'])) {
- if (!$curr_found) {
- $graph_id = $row['id'];
- $title = $row['title_cache'];
- $curr_found = true;
-
- $graphs[$graph_id]['graph_id'] = $graph_id;
- $i++;
- }else{
- if (sizeof($graphs) < $graphpp) {
- $graphs[$row['id']]['graph_id'] = $row['id'];
- $i++;
- }else{
- $next_graph_id = $row['id'];
- $next_found = true;
-
- break;
+ if (sizeof($rows)) {
+ foreach ($rows as $row) {
+ if (is_graph_allowed($row['id'])) {
+ if (!$curr_found) {
+ $graph_id = $row['id'];
+ $title = $row['title_cache'];
+ $curr_found = true;
+
+ $graphs[$graph_id]['graph_id'] = $graph_id;
+ $i++;
+ } else {
+ if (sizeof($graphs) < $graphpp) {
+ $graphs[$row['id']]['graph_id'] = $row['id'];
+ $i++;
+ } else {
+ $next_graph_id = $row['id'];
+ $next_found = true;
+
+ break;
+ }
+ }
}
}
}
- }
- }
- if ($next_graph_id > 0) {
- $done = true;
- }elseif (sizeof($rows) == 0) {
- $done = true;
- }else{
- $start += $graphpp;
+ if ($next_graph_id > 0) {
+ $done = true;
+ } elseif (sizeof($rows) == 0) {
+ $done = true;
+ } else {
+ $start += $graphpp;
+ }
}
- }
- /* If we did not find all the graphs requested,
- * move backwards from lowest graph id until the
- * array is fully populated or we run out of graphs.
- */
- if (sizeof($graphs) < $graphpp || $next_graph_id == 0) {
- $sql_where = '';
+ /* If we did not find all the graphs requested,
+ * move backwards from lowest graph id until the
+ * array is fully populated or we run out of graphs.
+ */
+ if (sizeof($graphs) < $graphpp || $next_graph_id == 0) {
+ $sql_where = '';
- /* setup the standard filters less the starting range, in other words start from the first graph */
- if ($filter != '') {
- $sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " gtg.title_cache RLIKE '$filter'";
- }
+ // setup the standard filters less the starting range, in other words start from the first graph
+ if ($filter != '') {
+ $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' gtg.title_cache RLIKE ' . db_qstr($filter);
+ }
- if (isset($local_graph_ids) && sizeof($local_graph_ids)) {
- $sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . ' gl.id IN(' . implode(',', $local_graph_ids) . ')';
- }
+ if (isset($local_graph_ids) && sizeof($local_graph_ids)) {
+ $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' gl.id IN(' . implode(',', $local_graph_ids) . ')';
+ }
- $start = 0;
- $done = false;
- $next_found = false;
+ $start = 0;
+ $done = false;
+ $next_found = false;
- while (!$done) {
- $sql = "SELECT
+ while (!$done) {
+ $sql = "SELECT
gl.id,
gtg.title_cache
FROM graph_local AS gl
@@ -366,67 +376,67 @@ function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {
ORDER BY gl.id ASC
LIMIT $start, $graphpp";
- $rows = db_fetch_assoc($sql);
-
- if (sizeof($rows)) {
- foreach ($rows as $row) {
- if (is_graph_allowed($row['id'])) {
- if (!$curr_found) {
- $graph_id = $row['id'];
- $title = $row['title_cache'];
- $curr_found = true;
- $graphs[$graph_id]['graph_id'] = $graph_id;
- $i++;
- }else{
- if (sizeof($graphs) < $graphpp) {
- $graphs[$row['id']]['graph_id'] = $row['id'];
- $i++;
- }else{
- $next_graph_id = $row['id'];
- $next_found = true;
-
- break;
+ $rows = db_fetch_assoc($sql);
+
+ if (sizeof($rows)) {
+ foreach ($rows as $row) {
+ if (is_graph_allowed($row['id'])) {
+ if (!$curr_found) {
+ $graph_id = $row['id'];
+ $title = $row['title_cache'];
+ $curr_found = true;
+ $graphs[$graph_id]['graph_id'] = $graph_id;
+ $i++;
+ } else {
+ if (sizeof($graphs) < $graphpp) {
+ $graphs[$row['id']]['graph_id'] = $row['id'];
+ $i++;
+ } else {
+ $next_graph_id = $row['id'];
+ $next_found = true;
+
+ break;
+ }
+ }
}
}
}
- }
- }
- if ($next_graph_id > 0) {
- $done = true;
- }elseif (sizeof($rows) == 0) {
- $done = true;
- }else{
- $start += $graphpp;
+ if ($next_graph_id > 0) {
+ $done = true;
+ } elseif (sizeof($rows) == 0) {
+ $done = true;
+ } else {
+ $start += $graphpp;
+ }
}
}
- }
- /* When a user hits the 'Prev' button, we have to go backwards.
- * Therefore, find the graph_id that would have to be used as
- * the starting point if the user were to hit the 'Prev' button.
- *
- * Just like the 'Next' button, we need to scan the database until
- * we reach the $graphpp variable or until we run out of rows. We
- * also have to adjust for underflow in this case.
- */
- $sql_where = "WHERE gl.id < $graph_id";
-
- /* setup the standard filters less the starting range, in other words start from the first graph */
- if ($filter != '') {
- $sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " gtg.title_cache RLIKE '$filter'";
- }
+ /* When a user hits the 'Prev' button, we have to go backwards.
+ * Therefore, find the graph_id that would have to be used as
+ * the starting point if the user were to hit the 'Prev' button.
+ *
+ * Just like the 'Next' button, we need to scan the database until
+ * we reach the $graphpp variable or until we run out of rows. We
+ * also have to adjust for underflow in this case.
+ */
+ $sql_where = "WHERE gl.id < $graph_id";
+
+ // setup the standard filters less the starting range, in other words start from the first graph
+ if ($filter != '') {
+ $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' gtg.title_cache RLIKE ' . db_qstr($filter);
+ }
- if (isset($local_graph_ids) && sizeof($local_graph_ids)) {
- $sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . ' gl.id IN(' . implode(',', $local_graph_ids) . ')';
- }
+ if (isset($local_graph_ids) && sizeof($local_graph_ids)) {
+ $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' gl.id IN(' . implode(',', $local_graph_ids) . ')';
+ }
- $done = false;
- $start = 0;
- $pgraphs = array();
+ $done = false;
+ $start = 0;
+ $pgraphs = [];
- while (!$done) {
- $sql = "SELECT gl.id,
+ while (!$done) {
+ $sql = "SELECT gl.id,
gtg.title_cache
FROM graph_local AS gl
INNER JOIN graph_templates_graph AS gtg
@@ -435,46 +445,47 @@ function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {
ORDER BY id DESC
LIMIT $start, $graphpp";
- $rows = db_fetch_assoc($sql);
+ $rows = db_fetch_assoc($sql);
- if (sizeof($rows)) {
- foreach ($rows as $row) {
- if (is_graph_allowed($row['id'])) {
- if (sizeof($pgraphs) < ($graphpp-1)) {
- $pgraphs[] = $row['id'];
- }else{
- $prev_graph_id = $row['id'];
- break;
+ if (sizeof($rows)) {
+ foreach ($rows as $row) {
+ if (is_graph_allowed($row['id'])) {
+ if (sizeof($pgraphs) < ($graphpp - 1)) {
+ $pgraphs[] = $row['id'];
+ } else {
+ $prev_graph_id = $row['id'];
+
+ break;
+ }
+ }
}
}
- }
- }
- if ($prev_graph_id > 0) {
- $done = true;
- }elseif (sizeof($rows) == 0) {
- $done = true;
- }else{
- $start += $graphpp;
+ if ($prev_graph_id > 0) {
+ $done = true;
+ } elseif (sizeof($rows) == 0) {
+ $done = true;
+ } else {
+ $start += $graphpp;
+ }
}
- }
- /* Now handle the underflow case, when we have not
- * completed building the $pgraphs array to the
- * correct size.
- */
- if ($prev_graph_id == 0) {
- $sql_where = '';
+ /* Now handle the underflow case, when we have not
+ * completed building the $pgraphs array to the
+ * correct size.
+ */
+ if ($prev_graph_id == 0) {
+ $sql_where = '';
- if ($filter != '') {
- $sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " gtg.title_cache RLIKE '$filter'";
- }
+ if ($filter != '') {
+ $sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' gtg.title_cache RLIKE ' . db_qstr($filter);
+ }
- $start = 0;
- $done = false;
+ $start = 0;
+ $done = false;
- while (!$done) {
- $sql = "SELECT gl.id,
+ while (!$done) {
+ $sql = "SELECT gl.id,
gtg.title_cache
FROM graph_local AS gl
INNER JOIN graph_templates_graph AS gtg
@@ -483,46 +494,47 @@ function get_next_graphid($graphpp, $filter, $graph_tree, $leaf_id) {
ORDER BY id DESC
LIMIT $start, $graphpp";
- $rows = db_fetch_assoc($sql);
+ $rows = db_fetch_assoc($sql);
- if (sizeof($rows)) {
- foreach ($rows as $row) {
- if (is_graph_allowed($row['id'])) {
- if (sizeof($pgraphs) < ($graphpp-1)) {
- $pgraphs[] = $row['id'];
- }else{
- $prev_graph_id = $row['id'];
- break;
+ if (sizeof($rows)) {
+ foreach ($rows as $row) {
+ if (is_graph_allowed($row['id'])) {
+ if (sizeof($pgraphs) < ($graphpp - 1)) {
+ $pgraphs[] = $row['id'];
+ } else {
+ $prev_graph_id = $row['id'];
+
+ break;
+ }
+ }
}
}
- }
- }
- if ($prev_graph_id > 0) {
- $done = true;
- }elseif (sizeof($rows) == 0) {
- $done = true;
- }else{
- $start += $graphpp;
+ if ($prev_graph_id > 0) {
+ $done = true;
+ } elseif (sizeof($rows) == 0) {
+ $done = true;
+ } else {
+ $start += $graphpp;
+ }
}
}
- }
- break;
+ break;
}
}
function get_tree_graphs($tree_id, $leaf_id) {
- $graphs = array();
- $hosts = array();
- $outArray = array();
+ $graphs = [];
+ $hosts = [];
+ $outArray = [];
if (is_tree_allowed($tree_id)) {
if ($leaf_id == -2) {
$sql_leaf = 'parent=0 AND';
- }elseif ($leaf_id > 0) {
+ } elseif ($leaf_id > 0) {
$sql_leaf = 'parent=' . $leaf_id . ' AND';
- }else{
+ } else {
$sql_leaf = '';
}
@@ -532,12 +544,12 @@ function get_tree_graphs($tree_id, $leaf_id) {
$items = db_fetch_assoc($sql);
if (sizeof($items)) {
- foreach($items as $i) {
- if ((empty($i['title'])) && ($i['local_graph_id'] > 0 )) {
+ foreach ($items as $i) {
+ if ((empty($i['title'])) && ($i['local_graph_id'] > 0)) {
$graphs[$i['local_graph_id']] = $i['local_graph_id'];
} elseif ($i['host_id'] > 0 && is_device_allowed($i['host_id'])) {
$hosts[$i['host_id']] = $i['host_id'];
- }elseif ($leaf_id > -2) {
+ } elseif ($leaf_id > -2) {
$outArray += get_tree_graphs($tree_id, $i['id']);
}
}
@@ -545,19 +557,18 @@ function get_tree_graphs($tree_id, $leaf_id) {
if (sizeof($hosts) && sizeof($graphs)) {
$graphs = get_allowed_graphs('(h.id IN(' . implode(',', $hosts) . ') OR gl.id IN(' . implode(',', $graphs) . '))');
- }elseif(sizeof($hosts)) {
+ } elseif (sizeof($hosts)) {
$graphs = get_allowed_graphs('(h.id IN(' . implode(',', $hosts) . '))');
- }elseif(sizeof($graphs)) {
+ } elseif (sizeof($graphs)) {
$graphs = get_allowed_graphs('(gl.id IN(' . implode(',', $graphs) . '))');
}
}
if (isset($graphs) && sizeof($graphs)) {
- foreach($graphs as $i) {
+ foreach ($graphs as $i) {
$outArray[$i['local_graph_id']] = $i['title_cache'];
}
}
- return($outArray);
+ return ($outArray);
}
-
diff --git a/locales/LC_MESSAGES/index.php b/locales/LC_MESSAGES/index.php
index 2e22b8c..828ecbe 100644
--- a/locales/LC_MESSAGES/index.php
+++ b/locales/LC_MESSAGES/index.php
@@ -22,4 +22,4 @@
+-------------------------------------------------------------------------+
*/
-header("Location:../index.php");
+header('Location:../index.php');
diff --git a/locales/index.php b/locales/index.php
index 2e22b8c..828ecbe 100644
--- a/locales/index.php
+++ b/locales/index.php
@@ -22,4 +22,4 @@
+-------------------------------------------------------------------------+
*/
-header("Location:../index.php");
+header('Location:../index.php');
diff --git a/setup.php b/setup.php
index 46b0b14..0aca2b1 100644
--- a/setup.php
+++ b/setup.php
@@ -33,30 +33,33 @@ function plugin_cycle_install() {
api_plugin_register_realm('cycle', 'cycle.php,cycle_ajax.php', __('Plugin -> Cycle Graphs', 'cycle'), 1);
- cycle_setup_table_new ();
+ cycle_setup_table_new();
}
-function plugin_cycle_uninstall () {
- /* Do any extra Uninstall stuff here */
+function plugin_cycle_uninstall() {
+ // Do any extra Uninstall stuff here
}
-function plugin_cycle_check_config () {
- /* Here we will check to ensure everything is configured */
+function plugin_cycle_check_config() {
+ // Here we will check to ensure everything is configured
cycle_check_upgrade();
+
return true;
}
-function plugin_cycle_upgrade () {
- /* Here we will upgrade to the newest version */
+function plugin_cycle_upgrade() {
+ // Here we will upgrade to the newest version
cycle_check_upgrade();
+
return false;
}
-function cycle_check_upgrade () {
+function cycle_check_upgrade() {
global $config;
- $files = array('index.php', 'plugins.php', 'cycle.php');
- if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
+ $files = ['index.php', 'plugins.php', 'cycle.php'];
+
+ if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files, true)) {
return;
}
@@ -65,23 +68,24 @@ function cycle_check_upgrade () {
$old = db_fetch_row("SELECT * FROM plugin_config WHERE directory='cycle'");
if (cacti_sizeof($old) && $current != $old['version']) {
- /* if the plugin is installed and/or active */
+ // if the plugin is installed and/or active
if ($old['status'] == 1 || $old['status'] == 4) {
- /* re-register the hooks */
+ // re-register the hooks
plugin_cycle_install();
- /* perform a database upgrade */
+ // perform a database upgrade
cycle_database_upgrade();
}
if ($old < '1.0') {
api_plugin_register_realm('cycle', 'cycle.php,cycle_ajax.php', 'Plugin -> Cycle Graphs', 1);
- /* get the realm id's and change from old to new */
- $user = db_fetch_cell("SELECT id FROM plugin_realms WHERE file='cycle.php'")+100;
+ // get the realm id's and change from old to new
+ $user = db_fetch_cell("SELECT id FROM plugin_realms WHERE file='cycle.php'") + 100;
$users = db_fetch_assoc('SELECT user_id FROM user_auth_realm WHERE realm_id=42');
+
if (sizeof($users)) {
- foreach($users as $u) {
+ foreach ($users as $u) {
db_execute('INSERT INTO user_auth_realm
(realm_id, user_id) VALUES (' . $user . ', ' . $u['user_id'] . ')
ON DUPLICATE KEY UPDATE realm_id=VALUES(realm_id)');
@@ -92,20 +96,20 @@ function cycle_check_upgrade () {
}
}
- /* update the plugin information */
+ // update the plugin information
$id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='cycle'");
- /* remove legacy hook */
+ // remove legacy hook
db_execute('DELETE FROM plugin_hooks WHERE name="cycle" AND hook="config_form"');
db_execute_prepared('UPDATE plugin_config
SET name = ?, author = ?, webpage = ?, version = ?
WHERE id = ?',
- array($info['longname'], $info['author'], $info['homepage'], $info['version'], $id));
+ [$info['longname'], $info['author'], $info['homepage'], $info['version'], $id]);
}
}
-function cycle_database_upgrade () {
+function cycle_database_upgrade() {
}
function cycle_check_dependencies() {
@@ -114,159 +118,161 @@ function cycle_check_dependencies() {
return true;
}
-function cycle_setup_table_new () {
+function cycle_setup_table_new() {
}
-function plugin_cycle_version () {
+function plugin_cycle_version() {
global $config;
$info = parse_ini_file($config['base_path'] . '/plugins/cycle/INFO', true);
+
return $info['info'];
}
-function cycle_page_head () {
+function cycle_page_head() {
}
-function cycle_config_settings ($force = false) {
+function cycle_config_settings($force = false) {
global $tabs, $settings, $tabs_graphs, $settings_user, $page_refresh_interval, $graph_timespans;
global $cycle_width, $cycle_height, $cycle_cols, $cycle_graphs;
- /* check for an upgrade */
+ // check for an upgrade
plugin_cycle_check_config();
if ($force === false && isset($_SERVER['PHP_SELF']) &&
basename($_SERVER['PHP_SELF']) != 'settings.php' &&
- basename($_SERVER['PHP_SELF']) != 'auth_profile.php')
+ basename($_SERVER['PHP_SELF']) != 'auth_profile.php') {
return;
+ }
- $tabs['cycle'] = __('Cycle', 'cycle');
+ $tabs['cycle'] = __('Cycle', 'cycle');
$tabs_graphs['cycle'] = __('Cycle', 'cycle');
- $treeList = array_rekey(get_allowed_trees(), 'id', 'name');
- $tempHeader = array('cycle_header' => array(
+ $treeList = array_rekey(get_allowed_trees(), 'id', 'name');
+ $tempHeader = ['cycle_header' => [
'friendly_name' => __('Cycle Graphs', 'cycle'),
- 'method' => 'spacer',
- ));
- $temp = array(
- 'cycle_delay' => array(
+ 'method' => 'spacer',
+ ]];
+ $temp = [
+ 'cycle_delay' => [
'friendly_name' => __('Delay Interval', 'cycle'),
- 'description' => __('This is the time in seconds before the next graph is displayed.', 'cycle'),
- 'method' => 'drop_array',
- 'default' => 60,
- 'array' => $page_refresh_interval
- ),
- 'cycle_timespan' => array(
+ 'description' => __('This is the time in seconds before the next graph is displayed.', 'cycle'),
+ 'method' => 'drop_array',
+ 'default' => 60,
+ 'array' => $page_refresh_interval
+ ],
+ 'cycle_timespan' => [
'friendly_name' => __('Graph Timespan', 'cycle'),
- 'description' => __('This is the default timespan that will be displayed on the page.', 'cycle'),
- 'method' => 'drop_array',
- 'default' => 5,
- 'array' => $graph_timespans
- ),
- 'cycle_columns' => array(
+ 'description' => __('This is the default timespan that will be displayed on the page.', 'cycle'),
+ 'method' => 'drop_array',
+ 'default' => 5,
+ 'array' => $graph_timespans
+ ],
+ 'cycle_columns' => [
'friendly_name' => __('Column Count', 'cycle'),
- 'description' => __('In Tree Mode this is the number of columns that will be used.', 'cycle'),
- 'method' => 'drop_array',
- 'default' => 2,
- 'array' => $cycle_cols
- ),
- 'cycle_graphs' => array(
+ 'description' => __('In Tree Mode this is the number of columns that will be used.', 'cycle'),
+ 'method' => 'drop_array',
+ 'default' => 2,
+ 'array' => $cycle_cols
+ ],
+ 'cycle_graphs' => [
'friendly_name' => __('Number of Graphs per Page', 'cycle'),
- 'description' => __('Select the number of graphs to display per page', 'cycle'),
- 'method' => 'drop_array',
- 'default' => '4',
- 'array' => $cycle_graphs,
- ),
- 'cycle_height' => array(
+ 'description' => __('Select the number of graphs to display per page', 'cycle'),
+ 'method' => 'drop_array',
+ 'default' => '4',
+ 'array' => $cycle_graphs,
+ ],
+ 'cycle_height' => [
'friendly_name' => __('Graph Height', 'cycle'),
- 'description' => __('This sets the graph height for the displayed graphs.', 'cycle'),
- 'method' => 'drop_array',
- 'default' => '100',
- 'array' => $cycle_height
- ),
- 'cycle_width' => array(
+ 'description' => __('This sets the graph height for the displayed graphs.', 'cycle'),
+ 'method' => 'drop_array',
+ 'default' => '100',
+ 'array' => $cycle_height
+ ],
+ 'cycle_width' => [
'friendly_name' => __('Graph Width', 'cycle'),
- 'description' => __('This sets the graph width for the displayed graphs.', 'cycle'),
- 'method' => 'drop_array',
- 'default' => '400',
- 'array' => $cycle_width
- ),
- 'cycle_legend' => array(
+ 'description' => __('This sets the graph width for the displayed graphs.', 'cycle'),
+ 'method' => 'drop_array',
+ 'default' => '400',
+ 'array' => $cycle_width
+ ],
+ 'cycle_legend' => [
'friendly_name' => __('Display Legend', 'cycle'),
- 'description' => __('Check this to display legend.', 'cycle'),
- 'method' => 'checkbox',
- 'default' => ''
- ),
- 'cycle_cheader' => array(
+ 'description' => __('Check this to display legend.', 'cycle'),
+ 'method' => 'checkbox',
+ 'default' => ''
+ ],
+ 'cycle_cheader' => [
'friendly_name' => __('Predefined Rotations', 'cycle'),
- 'method' => 'spacer',
- ),
- 'cycle_custom_graphs_type' => array(
+ 'method' => 'spacer',
+ ],
+ 'cycle_custom_graphs_type' => [
'friendly_name' => __('Rotation Type', 'cycle'),
- 'description' => __('Select which method to use for custom graph rotation. If you select \'Specific List\', you must define a list of Graph ID\'s', 'cycle'),
- 'method' => 'drop_array',
- 'default' => '1',
- 'array' => array(0 => __('Legacy (All)', 'cycle'), 1 => __('Specific List', 'cycle'), 2 => __('Tree Mode', 'cycle')),
- ),
- 'cycle_custom_graphs_list' => array(
+ 'description' => __('Select which method to use for custom graph rotation. If you select \'Specific List\', you must define a list of Graph ID\'s', 'cycle'),
+ 'method' => 'drop_array',
+ 'default' => '1',
+ 'array' => [0 => __('Legacy (All)', 'cycle'), 1 => __('Specific List', 'cycle'), 2 => __('Tree Mode', 'cycle')],
+ ],
+ 'cycle_custom_graphs_list' => [
'friendly_name' => __('Custom Graph List', 'cycle'),
- 'description' => __('This must be a comma delimited list of Graph ID\'s to cycle through. For example \'1,2,3,4\'', 'cycle'),
- 'method' => 'textbox',
- 'max_length' => 255,
- ),
- 'cycle_custom_graphs_tree' => array(
+ 'description' => __('This must be a comma delimited list of Graph ID\'s to cycle through. For example \'1,2,3,4\'', 'cycle'),
+ 'method' => 'textbox',
+ 'max_length' => 255,
+ ],
+ 'cycle_custom_graphs_tree' => [
'friendly_name' => __('Default Tree', 'cycle'),
- 'description' => __('Select the graph tree to cycle if Tree Mode is selected', 'cycle'),
- 'method' => 'drop_array',
- 'default' => 'None',
- 'array' => $treeList,
- )
- );
+ 'description' => __('Select the graph tree to cycle if Tree Mode is selected', 'cycle'),
+ 'method' => 'drop_array',
+ 'default' => 'None',
+ 'array' => $treeList,
+ ]
+ ];
if (isset($settings['cycle'])) {
$settings['cycle'] = array_merge($settings['cycle'], $tempHeader, $temp);
- }else {
+ } else {
$settings['cycle'] = array_merge($tempHeader, $temp);
}
if (isset($settings_user['cycle'])) {
$settings_user['cycle'] = array_merge($settings_user['cycle'], $temp);
- }else {
+ } else {
$settings_user['cycle'] = $temp;
}
}
-function cycle_show_tab () {
+function cycle_show_tab() {
global $config;
if (api_user_realm_auth('cycle.php')) {
if (substr_count($_SERVER['REQUEST_URI'], 'cycle.php')) {
print ' ';
- }else{
+ } else {
print ' ';
}
}
}
-function cycle_config_arrays () {
+function cycle_config_arrays() {
global $cycle_graphs, $cycle_cols, $cycle_width, $cycle_height;
- $cycle_graphs = array(
+ $cycle_graphs = [
1 => __('%d Graph', 1, 'cycle'),
2 => __('%d Graphs', 2, 'cycle'),
4 => __('%d Graphs', 4, 'cycle'),
6 => __('%d Graphs', 6, 'cycle'),
8 => __('%d Graphs', 8, 'cycle'),
10 => __('%d Graphs', 10, 'cycle')
- );
+ ];
- $cycle_cols = array(
+ $cycle_cols = [
1 => __('%d Column', 1, 'cycle'),
2 => __('%d Columns', 2, 'cycle'),
3 => __('%d Columns', 3, 'cycle'),
4 => __('%d Columns', 4, 'cycle'),
5 => __('%d Columns', 5, 'cycle')
- );
+ ];
- $cycle_height = array(
+ $cycle_height = [
75 => __('%d Pixels', 75, 'cycle'),
100 => __('%d Pixels', 100, 'cycle'),
125 => __('%d Pixels', 125, 'cycle'),
@@ -278,9 +284,9 @@ function cycle_config_arrays () {
350 => __('%d Pixels', 350, 'cycle'),
400 => __('%d Pixels', 400, 'cycle'),
500 => __('%d Pixels', 500, 'cycle')
- );
+ ];
- $cycle_width = array(
+ $cycle_width = [
100 => __('%d Pixels', 100, 'cycle'),
125 => __('%d Pixels', 125, 'cycle'),
150 => __('%d Pixels', 150, 'cycle'),
@@ -295,19 +301,20 @@ function cycle_config_arrays () {
600 => __('%d Pixels', 600, 'cycle'),
650 => __('%d Pixels', 650, 'cycle'),
700 => __('%d Pixels', 700, 'cycle')
- );
+ ];
return true;
}
-function cycle_draw_navigation_text ($nav) {
- $nav['cycle.php:'] = array('title' => __('Cycling', 'cycle'), 'mapping' => '', 'url' => 'cycle.php', 'level' => '1');
- $nav['cycle.php:view'] = array('title' => __('Cycling', 'cycle'), 'mapping' => '', 'url' => 'cycle.php', 'level' => '1');
- $nav['cycle.php:graphs'] = array('title' => __('Cycling', 'cycle'), 'mapping' => '', 'url' => 'cycle.php', 'level' => '1');
- $nav['cycle.php:save'] = array('title' => __('Cycling', 'cycle'), 'mapping' => '', 'url' => 'cycle.php', 'level' => '1');
+function cycle_draw_navigation_text($nav) {
+ $nav['cycle.php:'] = ['title' => __('Cycling', 'cycle'), 'mapping' => '', 'url' => 'cycle.php', 'level' => '1'];
+ $nav['cycle.php:view'] = ['title' => __('Cycling', 'cycle'), 'mapping' => '', 'url' => 'cycle.php', 'level' => '1'];
+ $nav['cycle.php:graphs'] = ['title' => __('Cycling', 'cycle'), 'mapping' => '', 'url' => 'cycle.php', 'level' => '1'];
+ $nav['cycle.php:save'] = ['title' => __('Cycling', 'cycle'), 'mapping' => '', 'url' => 'cycle.php', 'level' => '1'];
+
return $nav;
}
-function cycle_api_graph_save ($save) {
+function cycle_api_graph_save($save) {
}
?>
|