diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d9f41def67..5128200eed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,4 +3,5 @@ variables: test: script: - - docker run --rm -h pandorafms -t -v "$CI_PROJECT_DIR:/tmp/pandorafms" pandorafms/pandorafms-base /tmp/pandorafms/tests/test.sh + - docker pull pandorafms/pandorafms-base:centos6 + - docker run --rm -h pandorafms -t -v "$CI_PROJECT_DIR:/tmp/pandorafms" pandorafms/pandorafms-base:centos6 /tmp/pandorafms/tests/test.sh diff --git a/README.md b/README.md index 74825e8419..2a6c68fc2b 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ [![Build Status](https://travis-ci.org/pandorafms/pandorafms.svg?branch=develop)](https://travis-ci.org/pandorafms/pandorafms) -[![Pandora logo](http://wolf359.artica.es/public_images/logo_pandora_community.png)](http://pandorafms.org) +![logo Pandora-FMS](https://user-images.githubusercontent.com/8567291/151817953-dc9c4c88-5f3c-459b-98a7-da0534930a2c.png) -Pandora FMS is a monitoring software for IT infrastructure management which includes network equipment, Windows and Unix servers, virtual infrastructure and all different kind of applications. It has a large amount of features, making it a new generation software which discovers all the monitoring issues that an organization may need. +With more than 50,000 customer installations across the five continents, Pandora FMS is an out-of-the-box monitoring solution: profitable and scalable, covering most infrastructure deployment options. + +Pandora FMS gives you the agility to find and solve problems quickly, scaling them so they can be derived from any source, on-premise, multi cloud or both of them mixed. Now you have that capability across your entire IT stack and analytics to find any problem, even the ones that are hard to find. + +Thanks to more than 500 plugins available, you can control and manage any application and technology, from SAP, Oracle, Lotus, Citrix or Jboss to VMware, AWS, SQL Server, Redhat, Websphere, etc. ### Support -For community support you can visit our forums at http://forums.pandorafms.org. Visit our community page at http://pandorafms.org and if you need commercial information or/and professional support visit http://pandorafms.com. +For community support you can visit our forums at https://pandorafms.com/community/ and if you need commercial information or/and professional support visit https://pandorafms.com ### How to install Pandora FMS diff --git a/extras/deploy-scripts/pandora_agent_deploy.sh b/extras/deploy-scripts/pandora_agent_deploy.sh index fbd349e8b9..74db9d7c72 100644 --- a/extras/deploy-scripts/pandora_agent_deploy.sh +++ b/extras/deploy-scripts/pandora_agent_deploy.sh @@ -82,10 +82,10 @@ execute_cmd "[ $PANDORA_SERVER_IP ]" 'Check Server IP Address' 'Please define e # Check OS. OS=$([[ $(grep '^ID_LIKE=' /etc/os-release) ]] && grep ^ID_LIKE= /etc/os-release | cut -d '=' -f2 | tr -d '"' || grep ^ID= /etc/os-release | cut -d '=' -f2 | tr -d '"') -[[ $OS == 'rhel fedora' ]] && OS_RELEASE=$OS -[[ $OS == 'fedora' ]] && OS_RELEASE=$OS -[[ $OS == 'centos rhel fedora' ]] && OS_RELEASE=$OS -[[ $OS == 'debian' ]] && OS_RELEASE=$OS +[[ $OS =~ 'rhel' ]] && OS_RELEASE=$OS +[[ $OS =~ 'debian' ]] && OS_RELEASE=$OS +#[[ $OS == 'rhel fedora' ]] && OS_RELEASE=$OS +#[[ $OS == 'centos rhel fedora' ]] && OS_RELEASE=$OS # initialice logfile execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE" @@ -113,7 +113,7 @@ execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_d # Downloading and installing packages -if [[ $OS_RELEASE == 'rhel fedora' ]] || [[ $OS_RELEASE == 'centos rhel fedora' ]]; then +if [[ $OS_RELEASE =~ 'rhel' ]]; then yum install -y perl wget curl perl-Sys-Syslog unzip &>> $LOGFILE echo -e "${cyan}Instaling agent dependencies...${reset}" ${green}OK${reset} diff --git a/extras/deploy-scripts/pandora_deploy_community.sh b/extras/deploy-scripts/pandora_deploy_community.sh index 7f70addfec..d3415bf019 100644 --- a/extras/deploy-scripts/pandora_deploy_community.sh +++ b/extras/deploy-scripts/pandora_deploy_community.sh @@ -1,20 +1,33 @@ #!/bin/bash +####################################################### +# PandoraFMS Community online installation script +####################################################### +## Tested versions ## +# Centos 7.9 -# define variables +#Constants PANDORA_CONSOLE=/var/www/html/pandora_console -CONSOLE_PATH=/var/www/html/pandora_console PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf -PANDORA_SERVER_BIN=/usr/bin/pandora_server -PANDORA_HA_BIN=/usr/bin/pandora_ha -PANDORA_TABLES_MIN=160 -DBHOST=127.0.0.1 -DBNAME=pandora -DBUSER=pandora -DBPASS=pandora -DBPORT=3306 -S_VERSION='2021012801' +PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf + + +S_VERSION='2022020801' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" +# define default variables +[ "$TZ" ] || TZ="Europe/Madrid" +[ "$DBHOST" ] || DBHOST=127.0.0.1 +[ "$DBNAME" ] || DBNAME=pandora +[ "$DBUSER" ] || DBUSER=pandora +[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPORT" ] || DBPORT=3306 +[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$SKIP_PRECHECK" ] || SKIP_PRECHECK=0 +[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 +[ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 +[ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") +[ "$PANDORA_BETA" ] || PANDORA_BETA=0 + # Ansi color code variables red="\e[0;91m" green="\e[0;92m" @@ -60,7 +73,7 @@ check_pre_pandora () { echo -en "${cyan}Checking environment ... ${reset}" rpm -qa | grep pandora &>> /dev/null && local fail=true - [ -d "$CONSOLE_PATH" ] && local fail=true + [ -d "$PANDORA_CONSOLE" ] && local fail=true [ -f /usr/bin/pandora_server ] && local fail=true echo "use $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST &>> /dev/null && local fail=true @@ -98,6 +111,10 @@ fi execute_cmd "grep -i centos /etc/redhat-release" "Checking Centos" 'Error This is not a Centos Base system' +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" + echo -en "${cyan}Check Centos Version...${reset}" [ $(sed -nr 's/VERSION_ID+=\s*"([0-9])"$/\1/p' /etc/os-release) -eq '7' ] check_cmd_status 'Error OS version, Centos 7 is expected' @@ -111,7 +128,10 @@ echo "Community installer version: $S_VERSION" >> $LOGFILE check_root_permissions # Pre installed pandora -check_pre_pandora +[ "$SKIP_PRECHECK" == 1 ] || check_pre_pandora + +#advicing BETA PROGRAM +[ "$PANDORA_BETA" -ne '0' ] && echo -e "${red}BETA version enable using nightly PandoraFMS packages${reset}" # Connectivity check_repo_connection @@ -125,6 +145,9 @@ execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" # Check disk size at least 10 Gb free space execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)' +# Setting timezone +execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ" + # Execute tools check execute_cmd "awk --version" 'Checking needed tools: awk' execute_cmd "grep --version" 'Checking needed tools: grep' @@ -148,10 +171,10 @@ http://rpms.remirepo.net/enterprise/remi-release-7.rpm \ https://repo.percona.com/yum/percona-release-latest.noarch.rpm" execute_cmd "yum install -y $extra_repos" "Installing extra repositories" -execute_cmd "yum-config-manager --enable remi-php73" "Configuring PHP" +execute_cmd "yum-config-manager --enable remi-php74" "Configuring PHP" # Install percona Database -[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf +#[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf execute_cmd "yum install -y Percona-Server-server-57" "Installing Percona Server" # Console dependencies @@ -256,6 +279,7 @@ server_dependencies=" \ perl(XML::Twig) \ expect \ openssh-clients \ + java \ http://firefly.artica.es/centos7/xprobe2-0.3-12.2.x86_64.rpm \ http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm" execute_cmd "yum install -y $server_dependencies" "Installing Pandora FMS Server dependencies" @@ -275,32 +299,61 @@ execute_cmd "yum install -y $vmware_dependencies" "Installing SDK VMware perl de oracle_dependencies=" \ https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm \ https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm" -execute_cmd "yum install -y $oracle_dependencies" "Installing Oracle Instant client" +execute_cmd "yum install -y $oracle_dependencies || yum reinstall -y $oracle_dependencies" "Installing Oracle Instant client" + +#ipam dependencies +ipam_dependencies=" \ + http://firefly.artica.es/centos7/xprobe2-0.3-12.2.x86_64.rpm \ + perl(NetAddr::IP) \ + perl(Sys::Syslog) \ + perl(DBI) \ + perl(XML::Simple) \ + perl(Geo::IP) \ + perl(IO::Socket::INET6) \ + perl(XML::Twig)" +execute_cmd "yum install -y $ipam_dependencies" "Installing IPAM Instant client" + +# MSSQL dependencies el7 +execute_cmd "curl https://packages.microsoft.com/config/rhel/7/prod.repo -o /etc/yum.repos.d/mssql-release.repo" "Configuring Microsoft repositories" +execute_cmd "yum remove unixODBC-utf16 unixODBC-utf16-devel" "Removing default unixODBC packages" +execute_cmd "env ACCEPT_EULA=Y yum install -y msodbcsql17" "Installing ODBC Driver for Microsoft(R) SQL Server(R)" +MS_ID=$(head -1 /etc/odbcinst.ini | tr -d '[]') &>> "$LOGFILE" +#yum config-manager --set-disable packages-microsoft-com-prod # Disabling SELINUX and firewalld setenforce 0 sed -i -e "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config systemctl disable firewalld --now &>> $LOGFILE +# Adding standar cnf for initial setup. +cat > /etc/my.cnf << EO_CONFIG_TMP +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +symbolic-links=0 +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid +EO_CONFIG_TMP #Configuring Database +if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then execute_cmd "systemctl start mysqld" "Starting database engine" export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev) echo """ SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Pandor4!'); UNINSTALL PLUGIN validate_password; - SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pandora'); - """ | mysql --connect-expired-password -uroot - -export MYSQL_PWD=$DBPASS + SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$DBROOTPASS'); + """ | mysql --connect-expired-password -uroot &>> "$LOGFILE" +fi +export MYSQL_PWD=$DBROOTPASS echo -en "${cyan}Creating Pandora FMS database...${reset}" echo "create database $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST -check_cmd_status 'Error creating database pandora, is this an empty node? if you have a previus installation please contact with support.' +check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support." echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%' identified by \"$DBPASS\"" | mysql -uroot -P$DBPORT -h$DBHOST +export MYSQL_PWD=$DBPASS #Generating my.cnf -POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") cat > /etc/my.cnf << EO_CONFIG_F [mysqld] datadir=/var/lib/mysql @@ -347,10 +400,21 @@ EO_CONFIG_F execute_cmd "systemctl restart mysqld" "Configuring database engine" +#Define packages +if [ "$PANDORA_BETA" -eq '0' ] ; then + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" +elif [ "$PANDORA_BETA" -ne '0' ] ; then + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest.x86_64.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://pandorafms.com/community/community-console-rpm-beta/" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" +fi + # Downloading Pandora Packages -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" "Downloading Pandora FMS Server community" -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" "Downloading Pandora FMS Console community" -execute_cmd "wget http://firefly.artica.es/centos7/pandorafms_agent_unix-7.0NG.751_x86_64.rpm" "Downloading Pandora FMS Agent community" +execute_cmd "curl -LSs --output pandorafms_server-7.0NG.noarch.rpm ${PANDORA_SERVER_PACKAGE}" "Downloading Pandora FMS Server community" +execute_cmd "curl -LSs --output pandorafms_console-7.0NG.noarch.rpm ${PANDORA_CONSOLE_PACKAGE}" "Downloading Pandora FMS Console community" +execute_cmd "curl -LSs --output pandorafms_agent_unix-7.0NG.noarch.rpm ${PANDORA_AGENT_PACKAGE}" "Downloading Pandora FMS Agent community" # Install Pandora execute_cmd "yum install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "installing PandoraFMS packages" @@ -374,13 +438,13 @@ mysql -u$DBUSER -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb_data.sq check_cmd_status 'Error Loading database schema data' # Configure console -cat > $CONSOLE_PATH/include/config.php << EO_CONFIG_F +cat > $PANDORA_CONSOLE/include/config.php << EO_CONFIG_F /etc/pandora/pandora_server.env << 'EOF_ENV' @@ -459,7 +527,7 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/$VERSION/client64/lib export ORACLE_HOME=/usr/lib/oracle/$VERSION/client64 EOF_ENV -# Kernel optimization +if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then cat >> /etc/sysctl.conf <> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab ## Enabling agent systemctl enable pandora_agent_daemon &>> $LOGFILE -execute_cmd "systemctl start pandora_agent_daemon" "starting Pandora FMS Agent" +execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" #SSH banner [ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me) @@ -593,4 +662,4 @@ execute_cmd "rm -rf $HOME/pandora_deploy_tmp" "Removing temporary files" GREEN='\033[01;32m' NONE='\033[0m' printf " -> Go to Public ${green}http://"$ipplublic"/pandora_console${reset} to manage this server" -ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use this credentials to login in the console "g"[ User: admin / Password: pandora ]"n" \n"}' \ No newline at end of file +ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use these credentials to log in Pandora Console "g"[ User: admin / Password: pandora ]"n" \n"}' \ No newline at end of file diff --git a/extras/deploy-scripts/pandora_deploy_community_el8.sh b/extras/deploy-scripts/pandora_deploy_community_el8.sh index b5b2935192..9fb91bac8a 100644 --- a/extras/deploy-scripts/pandora_deploy_community_el8.sh +++ b/extras/deploy-scripts/pandora_deploy_community_el8.sh @@ -1,17 +1,36 @@ #!/bin/bash +####################################################### +# PandoraFMS Community online installation script +####################################################### +## Tested versions ## +# Centos 8.4, 8.5 +# Rocky 8.4, 8.5 +# Almalinuz 8.4, 8.5 +# RedHat 8.5 -# define variables +#Constants PANDORA_CONSOLE=/var/www/html/pandora_console -CONSOLE_PATH=/var/www/html/pandora_console PANDORA_SERVER_CONF=/etc/pandora/pandora_server.conf -DBHOST=127.0.0.1 -DBNAME=pandora -DBUSER=pandora -DBPASS=pandora -DBPORT=3306 -S_VERSION='2021070101' +PANDORA_AGENT_CONF=/etc/pandora/pandora_agent.conf + + +S_VERSION='2022020801' LOGFILE="/tmp/pandora-deploy-community-$(date +%F).log" +# define default variables +[ "$TZ" ] || TZ="Europe/Madrid" +[ "$DBHOST" ] || DBHOST=127.0.0.1 +[ "$DBNAME" ] || DBNAME=pandora +[ "$DBUSER" ] || DBUSER=pandora +[ "$DBPASS" ] || DBPASS=pandora +[ "$DBPORT" ] || DBPORT=3306 +[ "$DBROOTPASS" ] || DBROOTPASS=pandora +[ "$SKIP_PRECHECK" ] || SKIP_PRECHECK=0 +[ "$SKIP_DATABASE_INSTALL" ] || SKIP_DATABASE_INSTALL=0 +[ "$SKIP_KERNEL_OPTIMIZATIONS" ] || SKIP_KERNEL_OPTIMIZATIONS=0 +[ "$POOL_SIZE" ] || POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") +[ "$PANDORA_BETA" ] || PANDORA_BETA=0 + # Ansi color code variables red="\e[0;91m" green="\e[0;92m" @@ -56,7 +75,7 @@ check_pre_pandora () { echo -en "${cyan}Checking environment ... ${reset}" rpm -qa | grep pandora &>> /dev/null && local fail=true - [ -d "$CONSOLE_PATH" ] && local fail=true + [ -d "$PANDORA_CONSOLE" ] && local fail=true [ -f /usr/bin/pandora_server ] && local fail=true echo "use $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST &>> /dev/null && local fail=true @@ -74,7 +93,7 @@ check_root_permissions () { echo -en "${cyan}Checking root account... ${reset}" if [ "$(whoami)" != "root" ]; then echo -e "${red}Fail${reset}" - echo "Please use a root account or sudo for installing PandoraFMS" + echo "Please use a root account or sudo for installing Pandora FMS" echo "Error installing Pandora FMS for detailed error please check log: $LOGFILE" exit 1 @@ -87,15 +106,19 @@ check_root_permissions () { echo "Starting PandoraFMS Community deployment EL8 ver. $S_VERSION" # Centos Version -if [ ! "$(grep -Ei 'centos|rocky' /etc/redhat-release)" ]; then - printf "\n ${red}Error this is not a Centos/Rocky Base system, this installer is compatible with Centos/Rocky systems only${reset}\n" +if [ ! "$(grep -Ei 'centos|rocky|Almalinux|Red Hat Enterprise' /etc/redhat-release)" ]; then + printf "\n ${red}Error this is not a Centos/Rocky/Almalinux Base system, this installer is compatible with RHEL/Almalinux/Centos/Rockylinux systems only${reset}\n" exit 1 fi echo -en "${cyan}Check Centos Version...${reset}" [ $(sed -nr 's/VERSION_ID+=\s*"([0-9]).*"$/\1/p' /etc/os-release) -eq '8' ] -check_cmd_status 'Error OS version, Centos/Rocky 8+ is expected' +check_cmd_status 'Error OS version, RHEL/Almalinux/Centos/Rockylinux 8+ is expected' + +#Detect OS +os_name=$(grep ^PRETTY_NAME= /etc/os-release | cut -d '=' -f2 | tr -d '"') +execute_cmd "echo $os_name" "OS detected: ${os_name}" # initialice logfile execute_cmd "echo 'Starting community deployment' > $LOGFILE" "All installer activity is logged on $LOGFILE" @@ -106,7 +129,10 @@ echo "Community installer version: $S_VERSION" >> "$LOGFILE" check_root_permissions # Pre installed pandora -check_pre_pandora +[ "$SKIP_PRECHECK" == 1 ] || check_pre_pandora + +#advicing BETA PROGRAM +[ "$PANDORA_BETA" -ne '0' ] && echo -e "${red}BETA version enable using nightly PandoraFMS packages${reset}" # Connectivity check_repo_connection @@ -120,6 +146,10 @@ execute_cmd "[ $(grep MemTotal /proc/meminfo | awk '{print $2}') -ge 1700000 ]" # Check disk size at least 10 Gb free space execute_cmd "[ $(df -BM / | tail -1 | awk '{print $4}' | tr -d M) -gt 10000 ]" 'Checking Disk (required: 10 GB free min)' +# Setting timezone +rm -rf /etc/localtime &>> "$LOGFILE" +execute_cmd "timedatectl set-timezone $TZ" "Setting Timezone $TZ" + # Execute tools check execute_cmd "awk --version" 'Checking needed tools: awk' execute_cmd "grep --version" 'Checking needed tools: grep' @@ -131,25 +161,57 @@ rm -rf "$HOME"/pandora_deploy_tmp/*.rpm* &>> "$LOGFILE" mkdir "$HOME"/pandora_deploy_tmp &>> "$LOGFILE" execute_cmd "cd $HOME/pandora_deploy_tmp" "Moving to workspace: $HOME/pandora_deploy_tmp" +## Extra steps on redhat envs +if [ "$(grep -Ei 'Red Hat Enterprise' /etc/redhat-release)" ]; then + ## In case REDHAT + # Check susbscription manager status: + echo -en "${cyan}Checking Red Hat Enterprise subscription... ${reset}" + subscription-manager status &>> "$LOGFILE" + subscription-manager list &>> "$LOGFILE" + subscription-manager list | grep 'Status:' | grep Subscribed &>> "$LOGFILE" + check_cmd_status 'Error checking subscription status, make sure your server is activated and suscribed to Red Hat Enterprise repositories' + + # Ckeck repolist + dnf repolist &>> "$LOGFILE" + echo -en "${cyan}Checking Red Hat Enterprise repolist... ${reset}" + dnf repolist | grep 'rhel-8-for-x86_64-baseos-rpms' &>> "$LOGFILE" + check_cmd_status 'Error checking repositories status, could try a subscription-manager attach command or contact sysadmin' + + #install extra repos + extra_repos=" \ + tar \ + dnf-utils \ + https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \ + http://rpms.remirepo.net/enterprise/remi-release-8.rpm \ + https://repo.percona.com/yum/percona-release-latest.noarch.rpm" + + execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" + execute_cmd "subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms" "Enabling subscription to codeready-builder" +else + # For alma/rocky/centos + extra_repos=" \ + tar \ + dnf-utils \ + epel-release \ + http://rpms.remirepo.net/enterprise/remi-release-8.rpm \ + https://repo.percona.com/yum/percona-release-latest.noarch.rpm" + + execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" + execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools" +fi + + #Installing wget execute_cmd "dnf install -y wget" "Installing wget" #Installing extra repositiries -extra_repos=" \ - tar \ - dnf-utils \ - epel-release \ - http://rpms.remirepo.net/enterprise/remi-release-8.rpm \ - https://repo.percona.com/yum/percona-release-latest.noarch.rpm" -execute_cmd "dnf install -y $extra_repos" "Installing extra repositories" -execute_cmd "dnf config-manager --set-enabled powertools" "Configuring Powertools" execute_cmd "dnf module reset -y php " "Disabling standard PHP module" -execute_cmd "dnf module install -y php:remi-7.3" "Configuring PHP" +execute_cmd "dnf module install -y php:remi-7.4" "Configuring PHP" # Install percona Database execute_cmd "dnf module disable -y mysql" "Disabiling mysql module" -rm -rf /etc/my.cnf +#rm -rf /etc/my.cnf execute_cmd "dnf install -y Percona-Server-server-57" "Installing Percona Server" # Console dependencies @@ -231,6 +293,7 @@ console_dependencies=" \ xorg-x11-fonts-misc \ poppler-data \ php-yaml \ + mod_ssl \ http://firefly.artica.es/centos8/perl-Net-Telnet-3.04-1.el8.noarch.rpm \ http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm \ http://firefly.artica.es/centos8/phantomjs-2.1.1-1.el7.x86_64.rpm" @@ -255,7 +318,8 @@ server_dependencies=" \ perl(IO::Socket::INET6) \ perl(XML::Twig) \ expect \ - openssh-clients \ + openssh-clients \ + java \ http://firefly.artica.es/centos7/xprobe2-0.3-12.2.x86_64.rpm \ http://firefly.artica.es/centos7/wmic-1.4-1.el7.x86_64.rpm" execute_cmd "dnf install -y $server_dependencies" "Installing Pandora FMS Server dependencies" @@ -281,6 +345,7 @@ oracle_dependencies=" \ https://download.oracle.com/otn_software/linux/instantclient/19800/oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm" execute_cmd "dnf install -y $oracle_dependencies" "Installing Oracle Instant client" +#ipam dependencies ipam_dependencies=" \ http://firefly.artica.es/centos7/xprobe2-0.3-12.2.x86_64.rpm \ perl(NetAddr::IP) \ @@ -290,32 +355,49 @@ ipam_dependencies=" \ perl(Geo::IP) \ perl(IO::Socket::INET6) \ perl(XML::Twig)" -execute_cmd "dnf install -y $ipam_dependencies" "Installing Oracle Instant client" +execute_cmd "dnf install -y $ipam_dependencies" "Installing IPAM Instant client" + +# MSSQL dependencies el8 +execute_cmd "curl https://packages.microsoft.com/config/rhel/8/prod.repo -o /etc/yum.repos.d/mssql-release.repo" "Configuring Microsoft repositories" +execute_cmd "dnf remove unixODBC-utf16 unixODBC-utf16-devel" "Removing default unixODBC packages" +execute_cmd "env ACCEPT_EULA=Y dnf install -y msodbcsql17" "Installing ODBC Driver for Microsoft(R) SQL Server(R)" +MS_ID=$(head -1 /etc/odbcinst.ini | tr -d '[]') &>> "$LOGFILE" +#dnf config-manager --set-disable packages-microsoft-com-prod # Disabling SELINUX and firewalld setenforce 0 &>> "$LOGFILE" sed -i -e "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config &>> "$LOGFILE" systemctl disable firewalld --now &>> "$LOGFILE" +# Adding standar cnf for initial setup. +cat > /etc/my.cnf << EO_CONFIG_TMP +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +symbolic-links=0 +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid +EO_CONFIG_TMP #Configuring Database +if [ "$SKIP_DATABASE_INSTALL" -eq '0' ] ; then execute_cmd "systemctl start mysqld" "Starting database engine" export MYSQL_PWD=$(grep "temporary password" /var/log/mysqld.log | rev | cut -d' ' -f1 | rev) echo """ SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Pandor4!'); UNINSTALL PLUGIN validate_password; - SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pandora'); - """ | mysql --connect-expired-password -uroot - -export MYSQL_PWD=$DBPASS + SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$DBROOTPASS'); + """ | mysql --connect-expired-password -uroot &>> "$LOGFILE" +fi +export MYSQL_PWD=$DBROOTPASS echo -en "${cyan}Creating Pandora FMS database...${reset}" echo "create database $DBNAME" | mysql -uroot -P$DBPORT -h$DBHOST -check_cmd_status 'Error creating database pandora, is this an empty node? if you have a previus installation please contact with support.' +check_cmd_status "Error creating database $DBNAME, is this an empty node? if you have a previus installation please contact with support." echo "GRANT ALL PRIVILEGES ON $DBNAME.* TO \"$DBUSER\"@'%' identified by \"$DBPASS\"" | mysql -uroot -P$DBPORT -h$DBHOST +export MYSQL_PWD=$DBPASS #Generating my.cnf -POOL_SIZE=$(grep -i total /proc/meminfo | head -1 | awk '{printf "%.2f \n", $(NF-1)*0.4/1024}' | sed "s/\\..*$/M/g") cat > /etc/my.cnf << EO_CONFIG_F [mysqld] datadir=/var/lib/mysql @@ -362,13 +444,25 @@ EO_CONFIG_F execute_cmd "systemctl restart mysqld" "Configuring database engine" + +#Define packages +if [ "$PANDORA_BETA" -eq '0' ] ; then + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" +elif [ "$PANDORA_BETA" -ne '0' ] ; then + [ "$PANDORA_SERVER_PACKAGE" ] || PANDORA_SERVER_PACKAGE="http://firefly.artica.es/pandora_enterprise_nightlies/pandorafms_server-latest.x86_64.rpm" + [ "$PANDORA_CONSOLE_PACKAGE" ] || PANDORA_CONSOLE_PACKAGE="https://pandorafms.com/community/community-console-rpm-beta/" + [ "$PANDORA_AGENT_PACKAGE" ] || PANDORA_AGENT_PACKAGE="http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_agent_unix-7.0NG.noarch.rpm" +fi + # Downloading Pandora Packages -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_server-7.0NG.noarch.rpm" "Downloading Pandora FMS Server community" -execute_cmd "wget http://firefly.artica.es/pandorafms/latest/RHEL_CentOS/pandorafms_console-7.0NG.noarch.rpm" "Downloading Pandora FMS Console community" -execute_cmd "wget http://firefly.artica.es/centos7/pandorafms_agent_unix-7.0NG.751_x86_64.rpm" "Downloading Pandora FMS Agent community" +execute_cmd "curl -LSs --output pandorafms_server-7.0NG.noarch.rpm ${PANDORA_SERVER_PACKAGE}" "Downloading Pandora FMS Server community" +execute_cmd "curl -LSs --output pandorafms_console-7.0NG.noarch.rpm ${PANDORA_CONSOLE_PACKAGE}" "Downloading Pandora FMS Console community" +execute_cmd "curl -LSs --output pandorafms_agent_unix-7.0NG.noarch.rpm ${PANDORA_AGENT_PACKAGE}" "Downloading Pandora FMS Agent community" # Install Pandora -execute_cmd "dnf install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "installing PandoraFMS packages" +execute_cmd "dnf install -y $HOME/pandora_deploy_tmp/pandorafms*.rpm" "Installing Pandora FMS packages" # Copy gotty utility execute_cmd "wget https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_amd64.tar.gz" 'Dowloading gotty util' @@ -391,13 +485,13 @@ mysql -u$DBUSER -P$DBPORT -h$DBHOST $DBNAME < $PANDORA_CONSOLE/pandoradb_data.sq check_cmd_status 'Error Loading database schema data' # Configure console -cat > $CONSOLE_PATH/include/config.php << EO_CONFIG_F +cat > $PANDORA_CONSOLE/include/config.php << EO_CONFIG_F > "$LOGFILE" # Prepare php.ini sed -i -e "s/^max_input_time.*/max_input_time = -1/g" /etc/php.ini @@ -466,6 +560,10 @@ sed -i -e "s/^dbname.*/dbname $DBNAME/g" $PANDORA_SERVER_CONF sed -i -e "s/^dbuser.*/dbuser $DBUSER/g" $PANDORA_SERVER_CONF sed -i -e "s|^dbpass.*|dbpass $DBPASS|g" $PANDORA_SERVER_CONF sed -i -e "s/^dbport.*/dbport $DBPORT/g" $PANDORA_SERVER_CONF +sed -i -e "s/^#.mssql_driver.*/mssql_driver $MS_ID/g" $PANDORA_SERVER_CONF + +# Enable agent remote config +sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF # Set Oracle environment for pandora_server cat > /etc/pandora/pandora_server.env << 'EOF_ENV' @@ -477,6 +575,8 @@ export ORACLE_HOME=/usr/lib/oracle/$VERSION/client64 EOF_ENV # Kernel optimization + +if [ "$SKIP_KERNEL_OPTIMIZATIONS" -eq '0' ] ; then cat >> /etc/sysctl.conf <> "$LOGFILE" chmod +x /etc/init.d/pandora_websocket_engine # Start Websocket engine @@ -569,7 +670,7 @@ systemctl enable pandora_websocket_engine &>> "$LOGFILE" # Enable pandora ha service systemctl enable pandora_server --now &>> "$LOGFILE" -execute_cmd "systemctl start pandora_server" "Starting Pandora FMS Server" +execute_cmd "/etc/init.d/pandora_server start" "Starting Pandora FMS Server" # starting tentacle server systemctl enable tentacle_serverd &>> "$LOGFILE" @@ -580,7 +681,7 @@ execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://12 echo "* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab ## Enabling agent systemctl enable pandora_agent_daemon &>> "$LOGFILE" -execute_cmd "systemctl start pandora_agent_daemon" "starting Pandora FMS Agent" +execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent" #SSH banner [ "$(curl -s ifconfig.me)" ] && ipplublic=$(curl -s ifconfig.me) @@ -610,4 +711,4 @@ execute_cmd "rm -rf $HOME/pandora_deploy_tmp" "Removing temporary files" GREEN='\033[01;32m' NONE='\033[0m' printf " -> Go to Public ${green}http://"$ipplublic"/pandora_console${reset} to manage this server" -ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use this credentials to login in the console "g"[ User: admin / Password: pandora ]"n" \n"}' \ No newline at end of file +ip addr | grep -w "inet" | grep -v "127.0.0.1" | grep -v -e "172.1[0-9].0.1" | awk '{print $2}' | awk -v g=$GREEN -v n=$NONE -F '/' '{printf "\n -> Go to Local "g"http://"$1"/pandora_console"n" to manage this server \n -> Use these credentials to log in Pandora Console "g"[ User: admin / Password: pandora ]"n" \n"}' \ No newline at end of file diff --git a/pandora_agents/pc/AIX/pandora_agent.conf b/pandora_agents/pc/AIX/pandora_agent.conf index 4295aca180..3976644df1 100644 --- a/pandora_agents/pc/AIX/pandora_agent.conf +++ b/pandora_agents/pc/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759, AIX version +# Version 7.0NG.760, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/FreeBSD/pandora_agent.conf b/pandora_agents/pc/FreeBSD/pandora_agent.conf index 87e2ef836e..b63f7aec82 100644 --- a/pandora_agents/pc/FreeBSD/pandora_agent.conf +++ b/pandora_agents/pc/FreeBSD/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759, FreeBSD Version +# Version 7.0NG.760, FreeBSD Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/HP-UX/pandora_agent.conf b/pandora_agents/pc/HP-UX/pandora_agent.conf index 778354dd8d..237f959062 100644 --- a/pandora_agents/pc/HP-UX/pandora_agent.conf +++ b/pandora_agents/pc/HP-UX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759, HP-UX Version +# Version 7.0NG.760, HP-UX Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Linux/pandora_agent.conf b/pandora_agents/pc/Linux/pandora_agent.conf index 28fd762459..1d8f5320a3 100644 --- a/pandora_agents/pc/Linux/pandora_agent.conf +++ b/pandora_agents/pc/Linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759, GNU/Linux +# Version 7.0NG.760, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/NT4/pandora_agent.conf b/pandora_agents/pc/NT4/pandora_agent.conf index cb695d1576..2d9b24af39 100644 --- a/pandora_agents/pc/NT4/pandora_agent.conf +++ b/pandora_agents/pc/NT4/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759, GNU/Linux +# Version 7.0NG.760, GNU/Linux # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/SunOS/pandora_agent.conf b/pandora_agents/pc/SunOS/pandora_agent.conf index a364c0a2a3..9f8024d1c9 100644 --- a/pandora_agents/pc/SunOS/pandora_agent.conf +++ b/pandora_agents/pc/SunOS/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759, Solaris Version +# Version 7.0NG.760, Solaris Version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/pc/Win32/pandora_agent.conf b/pandora_agents/pc/Win32/pandora_agent.conf index 25a0990de9..391dbab129 100644 --- a/pandora_agents/pc/Win32/pandora_agent.conf +++ b/pandora_agents/pc/Win32/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2021 Artica Soluciones Tecnologicas -# Version 7.0NG.759 +# Version 7.0NG.760 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software # Foundation; either version 2 of the Licence or any later version diff --git a/pandora_agents/shellscript/aix/pandora_agent.conf b/pandora_agents/shellscript/aix/pandora_agent.conf index 6625e8df39..f2a45c14bc 100644 --- a/pandora_agents/shellscript/aix/pandora_agent.conf +++ b/pandora_agents/shellscript/aix/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.759, AIX version +# Version 7.0NG.760, AIX version # General Parameters # ================== diff --git a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf index 00fbcaa402..b3ebd56efd 100644 --- a/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf +++ b/pandora_agents/shellscript/bsd-ipso/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.759 +# Version 7.0NG.760 # FreeBSD/IPSO version # Licenced under GPL licence, 2003-2007 Sancho Lerena diff --git a/pandora_agents/shellscript/hp-ux/pandora_agent.conf b/pandora_agents/shellscript/hp-ux/pandora_agent.conf index 550aff27b6..aef52478b8 100644 --- a/pandora_agents/shellscript/hp-ux/pandora_agent.conf +++ b/pandora_agents/shellscript/hp-ux/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.759, HPUX Version +# Version 7.0NG.760, HPUX Version # General Parameters # ================== diff --git a/pandora_agents/shellscript/linux/pandora_agent.conf b/pandora_agents/shellscript/linux/pandora_agent.conf index 27759232f2..3d0ffc64af 100644 --- a/pandora_agents/shellscript/linux/pandora_agent.conf +++ b/pandora_agents/shellscript/linux/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759 +# Version 7.0NG.760 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/mac_osx/pandora_agent.conf b/pandora_agents/shellscript/mac_osx/pandora_agent.conf index 97562cb0f8..256317e7d8 100644 --- a/pandora_agents/shellscript/mac_osx/pandora_agent.conf +++ b/pandora_agents/shellscript/mac_osx/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759 +# Version 7.0NG.760 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/openWRT/pandora_agent.conf b/pandora_agents/shellscript/openWRT/pandora_agent.conf index d5ee8fd0f6..11e6a0a34c 100644 --- a/pandora_agents/shellscript/openWRT/pandora_agent.conf +++ b/pandora_agents/shellscript/openWRT/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759 +# Version 7.0NG.760 # Licensed under GPL license v2, # please visit http://pandora.sourceforge.net diff --git a/pandora_agents/shellscript/solaris/pandora_agent.conf b/pandora_agents/shellscript/solaris/pandora_agent.conf index cb3a1d9f48..6f7610f014 100644 --- a/pandora_agents/shellscript/solaris/pandora_agent.conf +++ b/pandora_agents/shellscript/solaris/pandora_agent.conf @@ -1,6 +1,6 @@ # Fichero de configuracion base de agentes de Pandora # Base config file for Pandora agents -# Version 7.0NG.759, Solaris version +# Version 7.0NG.760, Solaris version # General Parameters # ================== diff --git a/pandora_agents/unix/AIX/pandora_agent.conf b/pandora_agents/unix/AIX/pandora_agent.conf index 7029f01578..33a4c0651a 100644 --- a/pandora_agents/unix/AIX/pandora_agent.conf +++ b/pandora_agents/unix/AIX/pandora_agent.conf @@ -1,5 +1,5 @@ # Base config file for Pandora FMS agents -# Version 7.0NG.759, AIX version +# Version 7.0NG.760, AIX version # Licensed under GPL license v2, # Copyright (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index f1adc4aced..d2d5541589 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.759-220202 +Version: 7.0NG.760-220218 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index e50e34915e..488ed66b12 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.759-220202" +pandora_version="7.0NG.760-220218" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh index 48eaf0083a..b765ffa768 100644 --- a/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh +++ b/pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh @@ -31,7 +31,7 @@ fi if [ "$#" -ge 2 ]; then VERSION="$2" else - VERSION="7.0NG.759" + VERSION="7.0NG.760" fi # Path for the generated DMG file diff --git a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml index 303518623a..9d3a9d92b4 100644 --- a/pandora_agents/unix/Darwin/dmg/extras/distribution.xml +++ b/pandora_agents/unix/Darwin/dmg/extras/distribution.xml @@ -19,11 +19,11 @@ - pandorafms_src.pdk + pandorafms_src.pdk - pandorafms_uninstall.pdk + pandorafms_uninstall.pdk "; - } while( a[0] ); - - return v > 4 ? v : !v; -})(); - -function fixedPosition() { - var w = window, - ua = navigator.userAgent, - platform = navigator.platform, - // Rendering engine is Webkit, and capture major version - wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ), - wkversion = !!wkmatch && wkmatch[ 1 ], - ffmatch = ua.match( /Fennec\/([0-9]+)/ ), - ffversion = !!ffmatch && ffmatch[ 1 ], - operammobilematch = ua.match( /Opera Mobi\/([0-9]+)/ ), - omversion = !!operammobilematch && operammobilematch[ 1 ]; - - if ( - // iOS 4.3 and older : Platform is iPhone/Pad/Touch and Webkit version is less than 534 (ios5) - ( ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1 || platform.indexOf( "iPod" ) > -1 ) && wkversion && wkversion < 534 ) || - // Opera Mini - ( w.operamini && ({}).toString.call( w.operamini ) === "[object OperaMini]" ) || - ( operammobilematch && omversion < 7458 ) || - //Android lte 2.1: Platform is Android and Webkit version is less than 533 (Android 2.2) - ( ua.indexOf( "Android" ) > -1 && wkversion && wkversion < 533 ) || - // Firefox Mobile before 6.0 - - ( ffversion && ffversion < 6 ) || - // WebOS less than 3 - ( "palmGetResource" in window && wkversion && wkversion < 534 ) || - // MeeGo - ( ua.indexOf( "MeeGo" ) > -1 && ua.indexOf( "NokiaBrowser/8.5.0" ) > -1 ) ) { - return false; - } - - return true; -} - -$.extend( $.support, { - // Note, Chrome for iOS has an extremely quirky implementation of popstate. - // We've chosen to take the shortest path to a bug fix here for issue #5426 - // See the following link for information about the regex chosen - // https://developers.google.com/chrome/mobile/docs/user-agent#chrome_for_ios_user-agent - pushState: "pushState" in history && - "replaceState" in history && - // When running inside a FF iframe, calling replaceState causes an error - !( window.navigator.userAgent.indexOf( "Firefox" ) >= 0 && window.top !== window ) && - ( window.navigator.userAgent.search(/CriOS/) === -1 ), - - mediaquery: $.mobile.media( "only all" ), - cssPseudoElement: !!propExists( "content" ), - touchOverflow: !!propExists( "overflowScrolling" ), - cssTransform3d: transform3dTest(), - boxShadow: !!propExists( "boxShadow" ) && !bb, - fixedPosition: fixedPosition(), - scrollTop: ("pageXOffset" in window || - "scrollTop" in document.documentElement || - "scrollTop" in fakeBody[ 0 ]) && !webos && !operamini, - - dynamicBaseTag: baseTagTest(), - cssPointerEvents: cssPointerEventsTest(), - boundingRect: boundingRect(), - inlineSVG: inlineSVG -}); - -fakeBody.remove(); - -// $.mobile.ajaxBlacklist is used to override ajaxEnabled on platforms that have known conflicts with hash history updates (BB5, Symbian) -// or that generally work better browsing in regular http for full page refreshes (Opera Mini) -// Note: This detection below is used as a last resort. -// We recommend only using these detection methods when all other more reliable/forward-looking approaches are not possible -nokiaLTE7_3 = (function() { - - var ua = window.navigator.userAgent; - - //The following is an attempt to match Nokia browsers that are running Symbian/s60, with webkit, version 7.3 or older - return ua.indexOf( "Nokia" ) > -1 && - ( ua.indexOf( "Symbian/3" ) > -1 || ua.indexOf( "Series60/5" ) > -1 ) && - ua.indexOf( "AppleWebKit" ) > -1 && - ua.match( /(BrowserNG|NokiaBrowser)\/7\.[0-3]/ ); -})(); - -// Support conditions that must be met in order to proceed -// default enhanced qualifications are media query support OR IE 7+ - -$.mobile.gradeA = function() { - return ( ( $.support.mediaquery && $.support.cssPseudoElement ) || $.mobile.browser.oldIE && $.mobile.browser.oldIE >= 8 ) && ( $.support.boundingRect || $.fn.jquery.match(/1\.[0-7+]\.[0-9+]?/) !== null ); -}; - -$.mobile.ajaxBlacklist = - // BlackBerry browsers, pre-webkit - window.blackberry && !window.WebKitPoint || - // Opera Mini - operamini || - // Symbian webkits pre 7.3 - nokiaLTE7_3; - -// Lastly, this workaround is the only way we've found so far to get pre 7.3 Symbian webkit devices -// to render the stylesheets when they're referenced before this script, as we'd recommend doing. -// This simply reappends the CSS in place, which for some reason makes it apply -if ( nokiaLTE7_3 ) { - $(function() { - $( "head link[rel='stylesheet']" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" ); - }); -} - -// For ruling out shadows via css -if ( !$.support.boxShadow ) { - $( "html" ).addClass( "ui-noboxshadow" ); -} - -})( jQuery ); - - -(function( $, undefined ) { - var $win = $.mobile.window, self, - dummyFnToInitNavigate = function() { - }; - - $.event.special.beforenavigate = { - setup: function() { - $win.on( "navigate", dummyFnToInitNavigate ); - }, - - teardown: function() { - $win.off( "navigate", dummyFnToInitNavigate ); - } - }; - - $.event.special.navigate = self = { - bound: false, - - pushStateEnabled: true, - - originalEventName: undefined, - - // If pushstate support is present and push state support is defined to - // be true on the mobile namespace. - isPushStateEnabled: function() { - return $.support.pushState && - $.mobile.pushStateEnabled === true && - this.isHashChangeEnabled(); - }, - - // !! assumes mobile namespace is present - isHashChangeEnabled: function() { - return $.mobile.hashListeningEnabled === true; - }, - - // TODO a lot of duplication between popstate and hashchange - popstate: function( event ) { - var newEvent = new $.Event( "navigate" ), - beforeNavigate = new $.Event( "beforenavigate" ), - state = event.originalEvent.state || {}; - - beforeNavigate.originalEvent = event; - $win.trigger( beforeNavigate ); - - if ( beforeNavigate.isDefaultPrevented() ) { - return; - } - - if ( event.historyState ) { - $.extend(state, event.historyState); - } - - // Make sure the original event is tracked for the end - // user to inspect incase they want to do something special - newEvent.originalEvent = event; - - // NOTE we let the current stack unwind because any assignment to - // location.hash will stop the world and run this event handler. By - // doing this we create a similar behavior to hashchange on hash - // assignment - setTimeout(function() { - $win.trigger( newEvent, { - state: state - }); - }, 0); - }, - - hashchange: function( event /*, data */ ) { - var newEvent = new $.Event( "navigate" ), - beforeNavigate = new $.Event( "beforenavigate" ); - - beforeNavigate.originalEvent = event; - $win.trigger( beforeNavigate ); - - if ( beforeNavigate.isDefaultPrevented() ) { - return; - } - - // Make sure the original event is tracked for the end - // user to inspect incase they want to do something special - newEvent.originalEvent = event; - - // Trigger the hashchange with state provided by the user - // that altered the hash - $win.trigger( newEvent, { - // Users that want to fully normalize the two events - // will need to do history management down the stack and - // add the state to the event before this binding is fired - // TODO consider allowing for the explicit addition of callbacks - // to be fired before this value is set to avoid event timing issues - state: event.hashchangeState || {} - }); - }, - - // TODO We really only want to set this up once - // but I'm not clear if there's a beter way to achieve - // this with the jQuery special event structure - setup: function( /* data, namespaces */ ) { - if ( self.bound ) { - return; - } - - self.bound = true; - - if ( self.isPushStateEnabled() ) { - self.originalEventName = "popstate"; - $win.bind( "popstate.navigate", self.popstate ); - } else if ( self.isHashChangeEnabled() ) { - self.originalEventName = "hashchange"; - $win.bind( "hashchange.navigate", self.hashchange ); - } - } - }; -})( jQuery ); - - - -(function( $, undefined ) { - var path, $base, dialogHashKey = "&ui-state=dialog"; - - $.mobile.path = path = { - uiStateKey: "&ui-state", - - // This scary looking regular expression parses an absolute URL or its relative - // variants (protocol, site, document, query, and hash), into the various - // components (protocol, host, path, query, fragment, etc that make up the - // URL as well as some other commonly used sub-parts. When used with RegExp.exec() - // or String.match, it parses the URL into a results array that looks like this: - // - // [0]: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content - // [1]: http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread - // [2]: http://jblas:password@mycompany.com:8080/mail/inbox - // [3]: http://jblas:password@mycompany.com:8080 - // [4]: http: - // [5]: // - // [6]: jblas:password@mycompany.com:8080 - // [7]: jblas:password - // [8]: jblas - // [9]: password - // [10]: mycompany.com:8080 - // [11]: mycompany.com - // [12]: 8080 - // [13]: /mail/inbox - // [14]: /mail/ - // [15]: inbox - // [16]: ?msg=1234&type=unread - // [17]: #msg-content - // - urlParseRE: /^\s*(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/, - - // Abstraction to address xss (Issue #4787) by removing the authority in - // browsers that auto-decode it. All references to location.href should be - // replaced with a call to this method so that it can be dealt with properly here - getLocation: function( url ) { - var parsedUrl = this.parseUrl( url || location.href ), - uri = url ? parsedUrl : location, - - // Make sure to parse the url or the location object for the hash because using - // location.hash is autodecoded in firefox, the rest of the url should be from - // the object (location unless we're testing) to avoid the inclusion of the - // authority - hash = parsedUrl.hash; - - // mimic the browser with an empty string when the hash is empty - hash = hash === "#" ? "" : hash; - - return uri.protocol + - parsedUrl.doubleSlash + - uri.host + - - // The pathname must start with a slash if there's a protocol, because you - // can't have a protocol followed by a relative path. Also, it's impossible to - // calculate absolute URLs from relative ones if the absolute one doesn't have - // a leading "/". - ( ( uri.protocol !== "" && uri.pathname.substring( 0, 1 ) !== "/" ) ? - "/" : "" ) + - uri.pathname + - uri.search + - hash; - }, - - //return the original document url - getDocumentUrl: function( asParsedObject ) { - return asParsedObject ? $.extend( {}, path.documentUrl ) : path.documentUrl.href; - }, - - parseLocation: function() { - return this.parseUrl( this.getLocation() ); - }, - - //Parse a URL into a structure that allows easy access to - //all of the URL components by name. - parseUrl: function( url ) { - // If we're passed an object, we'll assume that it is - // a parsed url object and just return it back to the caller. - if ( $.type( url ) === "object" ) { - return url; - } - - var matches = path.urlParseRE.exec( url || "" ) || []; - - // Create an object that allows the caller to access the sub-matches - // by name. Note that IE returns an empty string instead of undefined, - // like all other browsers do, so we normalize everything so its consistent - // no matter what browser we're running on. - return { - href: matches[ 0 ] || "", - hrefNoHash: matches[ 1 ] || "", - hrefNoSearch: matches[ 2 ] || "", - domain: matches[ 3 ] || "", - protocol: matches[ 4 ] || "", - doubleSlash: matches[ 5 ] || "", - authority: matches[ 6 ] || "", - username: matches[ 8 ] || "", - password: matches[ 9 ] || "", - host: matches[ 10 ] || "", - hostname: matches[ 11 ] || "", - port: matches[ 12 ] || "", - pathname: matches[ 13 ] || "", - directory: matches[ 14 ] || "", - filename: matches[ 15 ] || "", - search: matches[ 16 ] || "", - hash: matches[ 17 ] || "" - }; - }, - - //Turn relPath into an asbolute path. absPath is - //an optional absolute path which describes what - //relPath is relative to. - makePathAbsolute: function( relPath, absPath ) { - var absStack, - relStack, - i, d; - - if ( relPath && relPath.charAt( 0 ) === "/" ) { - return relPath; - } - - relPath = relPath || ""; - absPath = absPath ? absPath.replace( /^\/|(\/[^\/]*|[^\/]+)$/g, "" ) : ""; - - absStack = absPath ? absPath.split( "/" ) : []; - relStack = relPath.split( "/" ); - - for ( i = 0; i < relStack.length; i++ ) { - d = relStack[ i ]; - switch ( d ) { - case ".": - break; - case "..": - if ( absStack.length ) { - absStack.pop(); - } - break; - default: - absStack.push( d ); - break; - } - } - return "/" + absStack.join( "/" ); - }, - - //Returns true if both urls have the same domain. - isSameDomain: function( absUrl1, absUrl2 ) { - return path.parseUrl( absUrl1 ).domain.toLowerCase() === - path.parseUrl( absUrl2 ).domain.toLowerCase(); - }, - - //Returns true for any relative variant. - isRelativeUrl: function( url ) { - // All relative Url variants have one thing in common, no protocol. - return path.parseUrl( url ).protocol === ""; - }, - - //Returns true for an absolute url. - isAbsoluteUrl: function( url ) { - return path.parseUrl( url ).protocol !== ""; - }, - - //Turn the specified realtive URL into an absolute one. This function - //can handle all relative variants (protocol, site, document, query, fragment). - makeUrlAbsolute: function( relUrl, absUrl ) { - if ( !path.isRelativeUrl( relUrl ) ) { - return relUrl; - } - - if ( absUrl === undefined ) { - absUrl = this.documentBase; - } - - var relObj = path.parseUrl( relUrl ), - absObj = path.parseUrl( absUrl ), - protocol = relObj.protocol || absObj.protocol, - doubleSlash = relObj.protocol ? relObj.doubleSlash : ( relObj.doubleSlash || absObj.doubleSlash ), - authority = relObj.authority || absObj.authority, - hasPath = relObj.pathname !== "", - pathname = path.makePathAbsolute( relObj.pathname || absObj.filename, absObj.pathname ), - search = relObj.search || ( !hasPath && absObj.search ) || "", - hash = relObj.hash; - - return protocol + doubleSlash + authority + pathname + search + hash; - }, - - //Add search (aka query) params to the specified url. - addSearchParams: function( url, params ) { - var u = path.parseUrl( url ), - p = ( typeof params === "object" ) ? $.param( params ) : params, - s = u.search || "?"; - return u.hrefNoSearch + s + ( s.charAt( s.length - 1 ) !== "?" ? "&" : "" ) + p + ( u.hash || "" ); - }, - - convertUrlToDataUrl: function( absUrl ) { - var result = absUrl, - u = path.parseUrl( absUrl ); - - if ( path.isEmbeddedPage( u ) ) { - // For embedded pages, remove the dialog hash key as in getFilePath(), - // and remove otherwise the Data Url won't match the id of the embedded Page. - result = u.hash - .split( dialogHashKey )[0] - .replace( /^#/, "" ) - .replace( /\?.*$/, "" ); - } else if ( path.isSameDomain( u, this.documentBase ) ) { - result = u.hrefNoHash.replace( this.documentBase.domain, "" ).split( dialogHashKey )[0]; - } - - return window.decodeURIComponent( result ); - }, - - //get path from current hash, or from a file path - get: function( newPath ) { - if ( newPath === undefined ) { - newPath = path.parseLocation().hash; - } - return path.stripHash( newPath ).replace( /[^\/]*\.[^\/*]+$/, "" ); - }, - - //set location hash to path - set: function( path ) { - location.hash = path; - }, - - //test if a given url (string) is a path - //NOTE might be exceptionally naive - isPath: function( url ) { - return ( /\// ).test( url ); - }, - - //return a url path with the window's location protocol/hostname/pathname removed - clean: function( url ) { - return url.replace( this.documentBase.domain, "" ); - }, - - //just return the url without an initial # - stripHash: function( url ) { - return url.replace( /^#/, "" ); - }, - - stripQueryParams: function( url ) { - return url.replace( /\?.*$/, "" ); - }, - - //remove the preceding hash, any query params, and dialog notations - cleanHash: function( hash ) { - return path.stripHash( hash.replace( /\?.*$/, "" ).replace( dialogHashKey, "" ) ); - }, - - isHashValid: function( hash ) { - return ( /^#[^#]+$/ ).test( hash ); - }, - - //check whether a url is referencing the same domain, or an external domain or different protocol - //could be mailto, etc - isExternal: function( url ) { - var u = path.parseUrl( url ); - - return !!( u.protocol && - ( u.domain.toLowerCase() !== this.documentUrl.domain.toLowerCase() ) ); - }, - - hasProtocol: function( url ) { - return ( /^(:?\w+:)/ ).test( url ); - }, - - isEmbeddedPage: function( url ) { - var u = path.parseUrl( url ); - - //if the path is absolute, then we need to compare the url against - //both the this.documentUrl and the documentBase. The main reason for this - //is that links embedded within external documents will refer to the - //application document, whereas links embedded within the application - //document will be resolved against the document base. - if ( u.protocol !== "" ) { - return ( !this.isPath(u.hash) && u.hash && ( u.hrefNoHash === this.documentUrl.hrefNoHash || ( this.documentBaseDiffers && u.hrefNoHash === this.documentBase.hrefNoHash ) ) ); - } - return ( /^#/ ).test( u.href ); - }, - - squash: function( url, resolutionUrl ) { - var href, cleanedUrl, search, stateIndex, docUrl, - isPath = this.isPath( url ), - uri = this.parseUrl( url ), - preservedHash = uri.hash, - uiState = ""; - - // produce a url against which we can resolve the provided path - if ( !resolutionUrl ) { - if ( isPath ) { - resolutionUrl = path.getLocation(); - } else { - docUrl = path.getDocumentUrl( true ); - if ( path.isPath( docUrl.hash ) ) { - resolutionUrl = path.squash( docUrl.href ); - } else { - resolutionUrl = docUrl.href; - } - } - } - - // If the url is anything but a simple string, remove any preceding hash - // eg #foo/bar -> foo/bar - // #foo -> #foo - cleanedUrl = isPath ? path.stripHash( url ) : url; - - // If the url is a full url with a hash check if the parsed hash is a path - // if it is, strip the #, and use it otherwise continue without change - cleanedUrl = path.isPath( uri.hash ) ? path.stripHash( uri.hash ) : cleanedUrl; - - // Split the UI State keys off the href - stateIndex = cleanedUrl.indexOf( this.uiStateKey ); - - // store the ui state keys for use - if ( stateIndex > -1 ) { - uiState = cleanedUrl.slice( stateIndex ); - cleanedUrl = cleanedUrl.slice( 0, stateIndex ); - } - - // make the cleanedUrl absolute relative to the resolution url - href = path.makeUrlAbsolute( cleanedUrl, resolutionUrl ); - - // grab the search from the resolved url since parsing from - // the passed url may not yield the correct result - search = this.parseUrl( href ).search; - - // TODO all this crap is terrible, clean it up - if ( isPath ) { - // reject the hash if it's a path or it's just a dialog key - if ( path.isPath( preservedHash ) || preservedHash.replace("#", "").indexOf( this.uiStateKey ) === 0) { - preservedHash = ""; - } - - // Append the UI State keys where it exists and it's been removed - // from the url - if ( uiState && preservedHash.indexOf( this.uiStateKey ) === -1) { - preservedHash += uiState; - } - - // make sure that pound is on the front of the hash - if ( preservedHash.indexOf( "#" ) === -1 && preservedHash !== "" ) { - preservedHash = "#" + preservedHash; - } - - // reconstruct each of the pieces with the new search string and hash - href = path.parseUrl( href ); - href = href.protocol + href.doubleSlash + href.host + href.pathname + search + - preservedHash; - } else { - href += href.indexOf( "#" ) > -1 ? uiState : "#" + uiState; - } - - return href; - }, - - isPreservableHash: function( hash ) { - return hash.replace( "#", "" ).indexOf( this.uiStateKey ) === 0; - }, - - // Escape weird characters in the hash if it is to be used as a selector - hashToSelector: function( hash ) { - var hasHash = ( hash.substring( 0, 1 ) === "#" ); - if ( hasHash ) { - hash = hash.substring( 1 ); - } - return ( hasHash ? "#" : "" ) + hash.replace( /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g, "\\$1" ); - }, - - // return the substring of a filepath before the dialogHashKey, for making a server - // request - getFilePath: function( path ) { - return path && path.split( dialogHashKey )[0]; - }, - - // check if the specified url refers to the first page in the main - // application document. - isFirstPageUrl: function( url ) { - // We only deal with absolute paths. - var u = path.parseUrl( path.makeUrlAbsolute( url, this.documentBase ) ), - - // Does the url have the same path as the document? - samePath = u.hrefNoHash === this.documentUrl.hrefNoHash || - ( this.documentBaseDiffers && - u.hrefNoHash === this.documentBase.hrefNoHash ), - - // Get the first page element. - fp = $.mobile.firstPage, - - // Get the id of the first page element if it has one. - fpId = fp && fp[0] ? fp[0].id : undefined; - - // The url refers to the first page if the path matches the document and - // it either has no hash value, or the hash is exactly equal to the id - // of the first page element. - return samePath && - ( !u.hash || - u.hash === "#" || - ( fpId && u.hash.replace( /^#/, "" ) === fpId ) ); - }, - - // Some embedded browsers, like the web view in Phone Gap, allow - // cross-domain XHR requests if the document doing the request was loaded - // via the file:// protocol. This is usually to allow the application to - // "phone home" and fetch app specific data. We normally let the browser - // handle external/cross-domain urls, but if the allowCrossDomainPages - // option is true, we will allow cross-domain http/https requests to go - // through our page loading logic. - isPermittedCrossDomainRequest: function( docUrl, reqUrl ) { - return $.mobile.allowCrossDomainPages && - (docUrl.protocol === "file:" || docUrl.protocol === "content:") && - reqUrl.search( /^https?:/ ) !== -1; - } - }; - - path.documentUrl = path.parseLocation(); - - $base = $( "head" ).find( "base" ); - - path.documentBase = $base.length ? - path.parseUrl( path.makeUrlAbsolute( $base.attr( "href" ), path.documentUrl.href ) ) : - path.documentUrl; - - path.documentBaseDiffers = (path.documentUrl.hrefNoHash !== path.documentBase.hrefNoHash); - - //return the original document base url - path.getDocumentBase = function( asParsedObject ) { - return asParsedObject ? $.extend( {}, path.documentBase ) : path.documentBase.href; - }; - - // DEPRECATED as of 1.4.0 - remove in 1.5.0 - $.extend( $.mobile, { - - //return the original document url - getDocumentUrl: path.getDocumentUrl, - - //return the original document base url - getDocumentBase: path.getDocumentBase - }); -})( jQuery ); - - - -(function( $, undefined ) { - $.mobile.History = function( stack, index ) { - this.stack = stack || []; - this.activeIndex = index || 0; - }; - - $.extend($.mobile.History.prototype, { - getActive: function() { - return this.stack[ this.activeIndex ]; - }, - - getLast: function() { - return this.stack[ this.previousIndex ]; - }, - - getNext: function() { - return this.stack[ this.activeIndex + 1 ]; - }, - - getPrev: function() { - return this.stack[ this.activeIndex - 1 ]; - }, - - // addNew is used whenever a new page is added - add: function( url, data ) { - data = data || {}; - - //if there's forward history, wipe it - if ( this.getNext() ) { - this.clearForward(); - } - - // if the hash is included in the data make sure the shape - // is consistent for comparison - if ( data.hash && data.hash.indexOf( "#" ) === -1) { - data.hash = "#" + data.hash; - } - - data.url = url; - this.stack.push( data ); - this.activeIndex = this.stack.length - 1; - }, - - //wipe urls ahead of active index - clearForward: function() { - this.stack = this.stack.slice( 0, this.activeIndex + 1 ); - }, - - find: function( url, stack, earlyReturn ) { - stack = stack || this.stack; - - var entry, i, length = stack.length, index; - - for ( i = 0; i < length; i++ ) { - entry = stack[i]; - - if ( decodeURIComponent(url) === decodeURIComponent(entry.url) || - decodeURIComponent(url) === decodeURIComponent(entry.hash) ) { - index = i; - - if ( earlyReturn ) { - return index; - } - } - } - - return index; - }, - - closest: function( url ) { - var closest, a = this.activeIndex; - - // First, take the slice of the history stack before the current index and search - // for a url match. If one is found, we'll avoid avoid looking through forward history - // NOTE the preference for backward history movement is driven by the fact that - // most mobile browsers only have a dedicated back button, and users rarely use - // the forward button in desktop browser anyhow - closest = this.find( url, this.stack.slice(0, a) ); - - // If nothing was found in backward history check forward. The `true` - // value passed as the third parameter causes the find method to break - // on the first match in the forward history slice. The starting index - // of the slice must then be added to the result to get the element index - // in the original history stack :( :( - // - // TODO this is hyper confusing and should be cleaned up (ugh so bad) - if ( closest === undefined ) { - closest = this.find( url, this.stack.slice(a), true ); - closest = closest === undefined ? closest : closest + a; - } - - return closest; - }, - - direct: function( opts ) { - var newActiveIndex = this.closest( opts.url ), a = this.activeIndex; - - // save new page index, null check to prevent falsey 0 result - // record the previous index for reference - if ( newActiveIndex !== undefined ) { - this.activeIndex = newActiveIndex; - this.previousIndex = a; - } - - // invoke callbacks where appropriate - // - // TODO this is also convoluted and confusing - if ( newActiveIndex < a ) { - ( opts.present || opts.back || $.noop )( this.getActive(), "back" ); - } else if ( newActiveIndex > a ) { - ( opts.present || opts.forward || $.noop )( this.getActive(), "forward" ); - } else if ( newActiveIndex === undefined && opts.missing ) { - opts.missing( this.getActive() ); - } - } - }); -})( jQuery ); - - - -(function( $, undefined ) { - var path = $.mobile.path, - initialHref = location.href; - - $.mobile.Navigator = function( history ) { - this.history = history; - this.ignoreInitialHashChange = true; - - $.mobile.window.bind({ - "popstate.history": $.proxy( this.popstate, this ), - "hashchange.history": $.proxy( this.hashchange, this ) - }); - }; - - $.extend($.mobile.Navigator.prototype, { - squash: function( url, data ) { - var state, href, hash = path.isPath(url) ? path.stripHash(url) : url; - - href = path.squash( url ); - - // make sure to provide this information when it isn't explicitly set in the - // data object that was passed to the squash method - state = $.extend({ - hash: hash, - url: href - }, data); - - // replace the current url with the new href and store the state - // Note that in some cases we might be replacing an url with the - // same url. We do this anyways because we need to make sure that - // all of our history entries have a state object associated with - // them. This allows us to work around the case where $.mobile.back() - // is called to transition from an external page to an embedded page. - // In that particular case, a hashchange event is *NOT* generated by the browser. - // Ensuring each history entry has a state object means that onPopState() - // will always trigger our hashchange callback even when a hashchange event - // is not fired. - window.history.replaceState( state, state.title || document.title, href ); - - return state; - }, - - hash: function( url, href ) { - var parsed, loc, hash, resolved; - - // Grab the hash for recording. If the passed url is a path - // we used the parsed version of the squashed url to reconstruct, - // otherwise we assume it's a hash and store it directly - parsed = path.parseUrl( url ); - loc = path.parseLocation(); - - if ( loc.pathname + loc.search === parsed.pathname + parsed.search ) { - // If the pathname and search of the passed url is identical to the current loc - // then we must use the hash. Otherwise there will be no event - // eg, url = "/foo/bar?baz#bang", location.href = "http://example.com/foo/bar?baz" - hash = parsed.hash ? parsed.hash : parsed.pathname + parsed.search; - } else if ( path.isPath(url) ) { - resolved = path.parseUrl( href ); - // If the passed url is a path, make it domain relative and remove any trailing hash - hash = resolved.pathname + resolved.search + (path.isPreservableHash( resolved.hash )? resolved.hash.replace( "#", "" ) : ""); - } else { - hash = url; - } - - return hash; - }, - - // TODO reconsider name - go: function( url, data, noEvents ) { - var state, href, hash, popstateEvent, - isPopStateEvent = $.event.special.navigate.isPushStateEnabled(); - - // Get the url as it would look squashed on to the current resolution url - href = path.squash( url ); - - // sort out what the hash sould be from the url - hash = this.hash( url, href ); - - // Here we prevent the next hash change or popstate event from doing any - // history management. In the case of hashchange we don't swallow it - // if there will be no hashchange fired (since that won't reset the value) - // and will swallow the following hashchange - if ( noEvents && hash !== path.stripHash(path.parseLocation().hash) ) { - this.preventNextHashChange = noEvents; - } - - // IMPORTANT in the case where popstate is supported the event will be triggered - // directly, stopping further execution - ie, interupting the flow of this - // method call to fire bindings at this expression. Below the navigate method - // there is a binding to catch this event and stop its propagation. - // - // We then trigger a new popstate event on the window with a null state - // so that the navigate events can conclude their work properly - // - // if the url is a path we want to preserve the query params that are available on - // the current url. - this.preventHashAssignPopState = true; - window.location.hash = hash; - - // If popstate is enabled and the browser triggers `popstate` events when the hash - // is set (this often happens immediately in browsers like Chrome), then the - // this flag will be set to false already. If it's a browser that does not trigger - // a `popstate` on hash assignement or `replaceState` then we need avoid the branch - // that swallows the event created by the popstate generated by the hash assignment - // At the time of this writing this happens with Opera 12 and some version of IE - this.preventHashAssignPopState = false; - - state = $.extend({ - url: href, - hash: hash, - title: document.title - }, data); - - if ( isPopStateEvent ) { - popstateEvent = new $.Event( "popstate" ); - popstateEvent.originalEvent = { - type: "popstate", - state: null - }; - - this.squash( url, state ); - - // Trigger a new faux popstate event to replace the one that we - // caught that was triggered by the hash setting above. - if ( !noEvents ) { - this.ignorePopState = true; - $.mobile.window.trigger( popstateEvent ); - } - } - - // record the history entry so that the information can be included - // in hashchange event driven navigate events in a similar fashion to - // the state that's provided by popstate - this.history.add( state.url, state ); - }, - - // This binding is intended to catch the popstate events that are fired - // when execution of the `$.navigate` method stops at window.location.hash = url; - // and completely prevent them from propagating. The popstate event will then be - // retriggered after execution resumes - // - // TODO grab the original event here and use it for the synthetic event in the - // second half of the navigate execution that will follow this binding - popstate: function( event ) { - var hash, state; - - // Partly to support our test suite which manually alters the support - // value to test hashchange. Partly to prevent all around weirdness - if ( !$.event.special.navigate.isPushStateEnabled() ) { - return; - } - - // If this is the popstate triggered by the actual alteration of the hash - // prevent it completely. History is tracked manually - if ( this.preventHashAssignPopState ) { - this.preventHashAssignPopState = false; - event.stopImmediatePropagation(); - return; - } - - // if this is the popstate triggered after the `replaceState` call in the go - // method, then simply ignore it. The history entry has already been captured - if ( this.ignorePopState ) { - this.ignorePopState = false; - return; - } - - // If there is no state, and the history stack length is one were - // probably getting the page load popstate fired by browsers like chrome - // avoid it and set the one time flag to false. - // TODO: Do we really need all these conditions? Comparing location hrefs - // should be sufficient. - if ( !event.originalEvent.state && - this.history.stack.length === 1 && - this.ignoreInitialHashChange ) { - this.ignoreInitialHashChange = false; - - if ( location.href === initialHref ) { - event.preventDefault(); - return; - } - } - - // account for direct manipulation of the hash. That is, we will receive a popstate - // when the hash is changed by assignment, and it won't have a state associated. We - // then need to squash the hash. See below for handling of hash assignment that - // matches an existing history entry - // TODO it might be better to only add to the history stack - // when the hash is adjacent to the active history entry - hash = path.parseLocation().hash; - if ( !event.originalEvent.state && hash ) { - // squash the hash that's been assigned on the URL with replaceState - // also grab the resulting state object for storage - state = this.squash( hash ); - - // record the new hash as an additional history entry - // to match the browser's treatment of hash assignment - this.history.add( state.url, state ); - - // pass the newly created state information - // along with the event - event.historyState = state; - - // do not alter history, we've added a new history entry - // so we know where we are - return; - } - - // If all else fails this is a popstate that comes from the back or forward buttons - // make sure to set the state of our history stack properly, and record the directionality - this.history.direct({ - url: (event.originalEvent.state || {}).url || hash, - - // When the url is either forward or backward in history include the entry - // as data on the event object for merging as data in the navigate event - present: function( historyEntry, direction ) { - // make sure to create a new object to pass down as the navigate event data - event.historyState = $.extend({}, historyEntry); - event.historyState.direction = direction; - } - }); - }, - - // NOTE must bind before `navigate` special event hashchange binding otherwise the - // navigation data won't be attached to the hashchange event in time for those - // bindings to attach it to the `navigate` special event - // TODO add a check here that `hashchange.navigate` is bound already otherwise it's - // broken (exception?) - hashchange: function( event ) { - var history, hash; - - // If hashchange listening is explicitly disabled or pushstate is supported - // avoid making use of the hashchange handler. - if (!$.event.special.navigate.isHashChangeEnabled() || - $.event.special.navigate.isPushStateEnabled() ) { - return; - } - - // On occasion explicitly want to prevent the next hash from propogating because we only - // with to alter the url to represent the new state do so here - if ( this.preventNextHashChange ) { - this.preventNextHashChange = false; - event.stopImmediatePropagation(); - return; - } - - history = this.history; - hash = path.parseLocation().hash; - - // If this is a hashchange caused by the back or forward button - // make sure to set the state of our history stack properly - this.history.direct({ - url: hash, - - // When the url is either forward or backward in history include the entry - // as data on the event object for merging as data in the navigate event - present: function( historyEntry, direction ) { - // make sure to create a new object to pass down as the navigate event data - event.hashchangeState = $.extend({}, historyEntry); - event.hashchangeState.direction = direction; - }, - - // When we don't find a hash in our history clearly we're aiming to go there - // record the entry as new for future traversal - // - // NOTE it's not entirely clear that this is the right thing to do given that we - // can't know the users intention. It might be better to explicitly _not_ - // support location.hash assignment in preference to $.navigate calls - // TODO first arg to add should be the href, but it causes issues in identifying - // embeded pages - missing: function() { - history.add( hash, { - hash: hash, - title: document.title - }); - } - }); - } - }); -})( jQuery ); - - - -(function( $, undefined ) { - // TODO consider queueing navigation activity until previous activities have completed - // so that end users don't have to think about it. Punting for now - // TODO !! move the event bindings into callbacks on the navigate event - $.mobile.navigate = function( url, data, noEvents ) { - $.mobile.navigate.navigator.go( url, data, noEvents ); - }; - - // expose the history on the navigate method in anticipation of full integration with - // existing navigation functionalty that is tightly coupled to the history information - $.mobile.navigate.history = new $.mobile.History(); - - // instantiate an instance of the navigator for use within the $.navigate method - $.mobile.navigate.navigator = new $.mobile.Navigator( $.mobile.navigate.history ); - - var loc = $.mobile.path.parseLocation(); - $.mobile.navigate.history.add( loc.href, {hash: loc.hash} ); -})( jQuery ); - - -(function( $, undefined ) { - var props = { - "animation": {}, - "transition": {} - }, - testElement = document.createElement( "a" ), - vendorPrefixes = [ "", "webkit-", "moz-", "o-" ]; - - $.each( [ "animation", "transition" ], function( i, test ) { - - // Get correct name for test - var testName = ( i === 0 ) ? test + "-" + "name" : test; - - $.each( vendorPrefixes, function( j, prefix ) { - if ( testElement.style[ $.camelCase( prefix + testName ) ] !== undefined ) { - props[ test ][ "prefix" ] = prefix; - return false; - } - }); - - // Set event and duration names for later use - props[ test ][ "duration" ] = - $.camelCase( props[ test ][ "prefix" ] + test + "-" + "duration" ); - props[ test ][ "event" ] = - $.camelCase( props[ test ][ "prefix" ] + test + "-" + "end" ); - - // All lower case if not a vendor prop - if ( props[ test ][ "prefix" ] === "" ) { - props[ test ][ "event" ] = props[ test ][ "event" ].toLowerCase(); - } - }); - - // If a valid prefix was found then the it is supported by the browser - $.support.cssTransitions = ( props[ "transition" ][ "prefix" ] !== undefined ); - $.support.cssAnimations = ( props[ "animation" ][ "prefix" ] !== undefined ); - - // Remove the testElement - $( testElement ).remove(); - - // Animation complete callback - $.fn.animationComplete = function( callback, type, fallbackTime ) { - var timer, duration, - that = this, - eventBinding = function() { - - // Clear the timer so we don't call callback twice - clearTimeout( timer ); - callback.apply( this, arguments ); - }, - animationType = ( !type || type === "animation" ) ? "animation" : "transition"; - - // Make sure selected type is supported by browser - if ( ( $.support.cssTransitions && animationType === "transition" ) || - ( $.support.cssAnimations && animationType === "animation" ) ) { - - // If a fallback time was not passed set one - if ( fallbackTime === undefined ) { - - // Make sure the was not bound to document before checking .css - if ( $( this ).context !== document ) { - - // Parse the durration since its in second multiple by 1000 for milliseconds - // Multiply by 3 to make sure we give the animation plenty of time. - duration = parseFloat( - $( this ).css( props[ animationType ].duration ) - ) * 3000; - } - - // If we could not read a duration use the default - if ( duration === 0 || duration === undefined || isNaN( duration ) ) { - duration = $.fn.animationComplete.defaultDuration; - } - } - - // Sets up the fallback if event never comes - timer = setTimeout( function() { - $( that ).off( props[ animationType ].event, eventBinding ); - callback.apply( that ); - }, duration ); - - // Bind the event - return $( this ).one( props[ animationType ].event, eventBinding ); - } else { - - // CSS animation / transitions not supported - // Defer execution for consistency between webkit/non webkit - setTimeout( $.proxy( callback, this ), 0 ); - return $( this ); - } - }; - - // Allow default callback to be configured on mobileInit - $.fn.animationComplete.defaultDuration = 1000; -})( jQuery ); - -// This plugin is an experiment for abstracting away the touch and mouse -// events so that developers don't have to worry about which method of input -// the device their document is loaded on supports. -// -// The idea here is to allow the developer to register listeners for the -// basic mouse events, such as mousedown, mousemove, mouseup, and click, -// and the plugin will take care of registering the correct listeners -// behind the scenes to invoke the listener at the fastest possible time -// for that device, while still retaining the order of event firing in -// the traditional mouse environment, should multiple handlers be registered -// on the same element for different events. -// -// The current version exposes the following virtual events to jQuery bind methods: -// "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel" - -(function( $, window, document, undefined ) { - -var dataPropertyName = "virtualMouseBindings", - touchTargetPropertyName = "virtualTouchID", - virtualEventNames = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split( " " ), - touchEventProps = "clientX clientY pageX pageY screenX screenY".split( " " ), - mouseHookProps = $.event.mouseHooks ? $.event.mouseHooks.props : [], - mouseEventProps = $.event.props.concat( mouseHookProps ), - activeDocHandlers = {}, - resetTimerID = 0, - startX = 0, - startY = 0, - didScroll = false, - clickBlockList = [], - blockMouseTriggers = false, - blockTouchTriggers = false, - eventCaptureSupported = "addEventListener" in document, - $document = $( document ), - nextTouchID = 1, - lastTouchID = 0, threshold, - i; - -$.vmouse = { - moveDistanceThreshold: 10, - clickDistanceThreshold: 10, - resetTimerDuration: 1500 -}; - -function getNativeEvent( event ) { - - while ( event && typeof event.originalEvent !== "undefined" ) { - event = event.originalEvent; - } - return event; -} - -function createVirtualEvent( event, eventType ) { - - var t = event.type, - oe, props, ne, prop, ct, touch, i, j, len; - - event = $.Event( event ); - event.type = eventType; - - oe = event.originalEvent; - props = $.event.props; - - // addresses separation of $.event.props in to $.event.mouseHook.props and Issue 3280 - // https://github.com/jquery/jquery-mobile/issues/3280 - if ( t.search( /^(mouse|click)/ ) > -1 ) { - props = mouseEventProps; - } - - // copy original event properties over to the new event - // this would happen if we could call $.event.fix instead of $.Event - // but we don't have a way to force an event to be fixed multiple times - if ( oe ) { - for ( i = props.length, prop; i; ) { - prop = props[ --i ]; - event[ prop ] = oe[ prop ]; - } - } - - // make sure that if the mouse and click virtual events are generated - // without a .which one is defined - if ( t.search(/mouse(down|up)|click/) > -1 && !event.which ) { - event.which = 1; - } - - if ( t.search(/^touch/) !== -1 ) { - ne = getNativeEvent( oe ); - t = ne.touches; - ct = ne.changedTouches; - touch = ( t && t.length ) ? t[0] : ( ( ct && ct.length ) ? ct[ 0 ] : undefined ); - - if ( touch ) { - for ( j = 0, len = touchEventProps.length; j < len; j++) { - prop = touchEventProps[ j ]; - event[ prop ] = touch[ prop ]; - } - } - } - - return event; -} - -function getVirtualBindingFlags( element ) { - - var flags = {}, - b, k; - - while ( element ) { - - b = $.data( element, dataPropertyName ); - - for ( k in b ) { - if ( b[ k ] ) { - flags[ k ] = flags.hasVirtualBinding = true; - } - } - element = element.parentNode; - } - return flags; -} - -function getClosestElementWithVirtualBinding( element, eventType ) { - var b; - while ( element ) { - - b = $.data( element, dataPropertyName ); - - if ( b && ( !eventType || b[ eventType ] ) ) { - return element; - } - element = element.parentNode; - } - return null; -} - -function enableTouchBindings() { - blockTouchTriggers = false; -} - -function disableTouchBindings() { - blockTouchTriggers = true; -} - -function enableMouseBindings() { - lastTouchID = 0; - clickBlockList.length = 0; - blockMouseTriggers = false; - - // When mouse bindings are enabled, our - // touch bindings are disabled. - disableTouchBindings(); -} - -function disableMouseBindings() { - // When mouse bindings are disabled, our - // touch bindings are enabled. - enableTouchBindings(); -} - -function startResetTimer() { - clearResetTimer(); - resetTimerID = setTimeout( function() { - resetTimerID = 0; - enableMouseBindings(); - }, $.vmouse.resetTimerDuration ); -} - -function clearResetTimer() { - if ( resetTimerID ) { - clearTimeout( resetTimerID ); - resetTimerID = 0; - } -} - -function triggerVirtualEvent( eventType, event, flags ) { - var ve; - - if ( ( flags && flags[ eventType ] ) || - ( !flags && getClosestElementWithVirtualBinding( event.target, eventType ) ) ) { - - ve = createVirtualEvent( event, eventType ); - - $( event.target).trigger( ve ); - } - - return ve; -} - -function mouseEventCallback( event ) { - var touchID = $.data( event.target, touchTargetPropertyName ), - ve; - - if ( !blockMouseTriggers && ( !lastTouchID || lastTouchID !== touchID ) ) { - ve = triggerVirtualEvent( "v" + event.type, event ); - if ( ve ) { - if ( ve.isDefaultPrevented() ) { - event.preventDefault(); - } - if ( ve.isPropagationStopped() ) { - event.stopPropagation(); - } - if ( ve.isImmediatePropagationStopped() ) { - event.stopImmediatePropagation(); - } - } - } -} - -function handleTouchStart( event ) { - - var touches = getNativeEvent( event ).touches, - target, flags, t; - - if ( touches && touches.length === 1 ) { - - target = event.target; - flags = getVirtualBindingFlags( target ); - - if ( flags.hasVirtualBinding ) { - - lastTouchID = nextTouchID++; - $.data( target, touchTargetPropertyName, lastTouchID ); - - clearResetTimer(); - - disableMouseBindings(); - didScroll = false; - - t = getNativeEvent( event ).touches[ 0 ]; - startX = t.pageX; - startY = t.pageY; - - triggerVirtualEvent( "vmouseover", event, flags ); - triggerVirtualEvent( "vmousedown", event, flags ); - } - } -} - -function handleScroll( event ) { - if ( blockTouchTriggers ) { - return; - } - - if ( !didScroll ) { - triggerVirtualEvent( "vmousecancel", event, getVirtualBindingFlags( event.target ) ); - } - - didScroll = true; - startResetTimer(); -} - -function handleTouchMove( event ) { - if ( blockTouchTriggers ) { - return; - } - - var t = getNativeEvent( event ).touches[ 0 ], - didCancel = didScroll, - moveThreshold = $.vmouse.moveDistanceThreshold, - flags = getVirtualBindingFlags( event.target ); - - didScroll = didScroll || - ( Math.abs( t.pageX - startX ) > moveThreshold || - Math.abs( t.pageY - startY ) > moveThreshold ); - - if ( didScroll && !didCancel ) { - triggerVirtualEvent( "vmousecancel", event, flags ); - } - - triggerVirtualEvent( "vmousemove", event, flags ); - startResetTimer(); -} - -function handleTouchEnd( event ) { - if ( blockTouchTriggers ) { - return; - } - - disableTouchBindings(); - - var flags = getVirtualBindingFlags( event.target ), - ve, t; - triggerVirtualEvent( "vmouseup", event, flags ); - - if ( !didScroll ) { - ve = triggerVirtualEvent( "vclick", event, flags ); - if ( ve && ve.isDefaultPrevented() ) { - // The target of the mouse events that follow the touchend - // event don't necessarily match the target used during the - // touch. This means we need to rely on coordinates for blocking - // any click that is generated. - t = getNativeEvent( event ).changedTouches[ 0 ]; - clickBlockList.push({ - touchID: lastTouchID, - x: t.clientX, - y: t.clientY - }); - - // Prevent any mouse events that follow from triggering - // virtual event notifications. - blockMouseTriggers = true; - } - } - triggerVirtualEvent( "vmouseout", event, flags); - didScroll = false; - - startResetTimer(); -} - -function hasVirtualBindings( ele ) { - var bindings = $.data( ele, dataPropertyName ), - k; - - if ( bindings ) { - for ( k in bindings ) { - if ( bindings[ k ] ) { - return true; - } - } - } - return false; -} - -function dummyMouseHandler() {} - -function getSpecialEventObject( eventType ) { - var realType = eventType.substr( 1 ); - - return { - setup: function(/* data, namespace */) { - // If this is the first virtual mouse binding for this element, - // add a bindings object to its data. - - if ( !hasVirtualBindings( this ) ) { - $.data( this, dataPropertyName, {} ); - } - - // If setup is called, we know it is the first binding for this - // eventType, so initialize the count for the eventType to zero. - var bindings = $.data( this, dataPropertyName ); - bindings[ eventType ] = true; - - // If this is the first virtual mouse event for this type, - // register a global handler on the document. - - activeDocHandlers[ eventType ] = ( activeDocHandlers[ eventType ] || 0 ) + 1; - - if ( activeDocHandlers[ eventType ] === 1 ) { - $document.bind( realType, mouseEventCallback ); - } - - // Some browsers, like Opera Mini, won't dispatch mouse/click events - // for elements unless they actually have handlers registered on them. - // To get around this, we register dummy handlers on the elements. - - $( this ).bind( realType, dummyMouseHandler ); - - // For now, if event capture is not supported, we rely on mouse handlers. - if ( eventCaptureSupported ) { - // If this is the first virtual mouse binding for the document, - // register our touchstart handler on the document. - - activeDocHandlers[ "touchstart" ] = ( activeDocHandlers[ "touchstart" ] || 0) + 1; - - if ( activeDocHandlers[ "touchstart" ] === 1 ) { - $document.bind( "touchstart", handleTouchStart ) - .bind( "touchend", handleTouchEnd ) - - // On touch platforms, touching the screen and then dragging your finger - // causes the window content to scroll after some distance threshold is - // exceeded. On these platforms, a scroll prevents a click event from being - // dispatched, and on some platforms, even the touchend is suppressed. To - // mimic the suppression of the click event, we need to watch for a scroll - // event. Unfortunately, some platforms like iOS don't dispatch scroll - // events until *AFTER* the user lifts their finger (touchend). This means - // we need to watch both scroll and touchmove events to figure out whether - // or not a scroll happenens before the touchend event is fired. - - .bind( "touchmove", handleTouchMove ) - .bind( "scroll", handleScroll ); - } - } - }, - - teardown: function(/* data, namespace */) { - // If this is the last virtual binding for this eventType, - // remove its global handler from the document. - - --activeDocHandlers[ eventType ]; - - if ( !activeDocHandlers[ eventType ] ) { - $document.unbind( realType, mouseEventCallback ); - } - - if ( eventCaptureSupported ) { - // If this is the last virtual mouse binding in existence, - // remove our document touchstart listener. - - --activeDocHandlers[ "touchstart" ]; - - if ( !activeDocHandlers[ "touchstart" ] ) { - $document.unbind( "touchstart", handleTouchStart ) - .unbind( "touchmove", handleTouchMove ) - .unbind( "touchend", handleTouchEnd ) - .unbind( "scroll", handleScroll ); - } - } - - var $this = $( this ), - bindings = $.data( this, dataPropertyName ); - - // teardown may be called when an element was - // removed from the DOM. If this is the case, - // jQuery core may have already stripped the element - // of any data bindings so we need to check it before - // using it. - if ( bindings ) { - bindings[ eventType ] = false; - } - - // Unregister the dummy event handler. - - $this.unbind( realType, dummyMouseHandler ); - - // If this is the last virtual mouse binding on the - // element, remove the binding data from the element. - - if ( !hasVirtualBindings( this ) ) { - $this.removeData( dataPropertyName ); - } - } - }; -} - -// Expose our custom events to the jQuery bind/unbind mechanism. - -for ( i = 0; i < virtualEventNames.length; i++ ) { - $.event.special[ virtualEventNames[ i ] ] = getSpecialEventObject( virtualEventNames[ i ] ); -} - -// Add a capture click handler to block clicks. -// Note that we require event capture support for this so if the device -// doesn't support it, we punt for now and rely solely on mouse events. -if ( eventCaptureSupported ) { - document.addEventListener( "click", function( e ) { - var cnt = clickBlockList.length, - target = e.target, - x, y, ele, i, o, touchID; - - if ( cnt ) { - x = e.clientX; - y = e.clientY; - threshold = $.vmouse.clickDistanceThreshold; - - // The idea here is to run through the clickBlockList to see if - // the current click event is in the proximity of one of our - // vclick events that had preventDefault() called on it. If we find - // one, then we block the click. - // - // Why do we have to rely on proximity? - // - // Because the target of the touch event that triggered the vclick - // can be different from the target of the click event synthesized - // by the browser. The target of a mouse/click event that is synthesized - // from a touch event seems to be implementation specific. For example, - // some browsers will fire mouse/click events for a link that is near - // a touch event, even though the target of the touchstart/touchend event - // says the user touched outside the link. Also, it seems that with most - // browsers, the target of the mouse/click event is not calculated until the - // time it is dispatched, so if you replace an element that you touched - // with another element, the target of the mouse/click will be the new - // element underneath that point. - // - // Aside from proximity, we also check to see if the target and any - // of its ancestors were the ones that blocked a click. This is necessary - // because of the strange mouse/click target calculation done in the - // Android 2.1 browser, where if you click on an element, and there is a - // mouse/click handler on one of its ancestors, the target will be the - // innermost child of the touched element, even if that child is no where - // near the point of touch. - - ele = target; - - while ( ele ) { - for ( i = 0; i < cnt; i++ ) { - o = clickBlockList[ i ]; - touchID = 0; - - if ( ( ele === target && Math.abs( o.x - x ) < threshold && Math.abs( o.y - y ) < threshold ) || - $.data( ele, touchTargetPropertyName ) === o.touchID ) { - // XXX: We may want to consider removing matches from the block list - // instead of waiting for the reset timer to fire. - e.preventDefault(); - e.stopPropagation(); - return; - } - } - ele = ele.parentNode; - } - } - }, true); -} -})( jQuery, window, document ); - - -(function( $, window, undefined ) { - var $document = $( document ), - supportTouch = $.mobile.support.touch, - scrollEvent = "touchmove scroll", - touchStartEvent = supportTouch ? "touchstart" : "mousedown", - touchStopEvent = supportTouch ? "touchend" : "mouseup", - touchMoveEvent = supportTouch ? "touchmove" : "mousemove"; - - // setup new event shortcuts - $.each( ( "touchstart touchmove touchend " + - "tap taphold " + - "swipe swipeleft swiperight " + - "scrollstart scrollstop" ).split( " " ), function( i, name ) { - - $.fn[ name ] = function( fn ) { - return fn ? this.bind( name, fn ) : this.trigger( name ); - }; - - // jQuery < 1.8 - if ( $.attrFn ) { - $.attrFn[ name ] = true; - } - }); - - function triggerCustomEvent( obj, eventType, event, bubble ) { - var originalType = event.type; - event.type = eventType; - if ( bubble ) { - $.event.trigger( event, undefined, obj ); - } else { - $.event.dispatch.call( obj, event ); - } - event.type = originalType; - } - - // also handles scrollstop - $.event.special.scrollstart = { - - enabled: true, - setup: function() { - - var thisObject = this, - $this = $( thisObject ), - scrolling, - timer; - - function trigger( event, state ) { - scrolling = state; - triggerCustomEvent( thisObject, scrolling ? "scrollstart" : "scrollstop", event ); - } - - // iPhone triggers scroll after a small delay; use touchmove instead - $this.bind( scrollEvent, function( event ) { - - if ( !$.event.special.scrollstart.enabled ) { - return; - } - - if ( !scrolling ) { - trigger( event, true ); - } - - clearTimeout( timer ); - timer = setTimeout( function() { - trigger( event, false ); - }, 50 ); - }); - }, - teardown: function() { - $( this ).unbind( scrollEvent ); - } - }; - - // also handles taphold - $.event.special.tap = { - tapholdThreshold: 750, - emitTapOnTaphold: true, - setup: function() { - var thisObject = this, - $this = $( thisObject ), - isTaphold = false; - - $this.bind( "vmousedown", function( event ) { - isTaphold = false; - if ( event.which && event.which !== 1 ) { - return false; - } - - var origTarget = event.target, - timer; - - function clearTapTimer() { - clearTimeout( timer ); - } - - function clearTapHandlers() { - clearTapTimer(); - - $this.unbind( "vclick", clickHandler ) - .unbind( "vmouseup", clearTapTimer ); - $document.unbind( "vmousecancel", clearTapHandlers ); - } - - function clickHandler( event ) { - clearTapHandlers(); - - // ONLY trigger a 'tap' event if the start target is - // the same as the stop target. - if ( !isTaphold && origTarget === event.target ) { - triggerCustomEvent( thisObject, "tap", event ); - } else if ( isTaphold ) { - event.preventDefault(); - } - } - - $this.bind( "vmouseup", clearTapTimer ) - .bind( "vclick", clickHandler ); - $document.bind( "vmousecancel", clearTapHandlers ); - - timer = setTimeout( function() { - if ( !$.event.special.tap.emitTapOnTaphold ) { - isTaphold = true; - } - triggerCustomEvent( thisObject, "taphold", $.Event( "taphold", { target: origTarget } ) ); - }, $.event.special.tap.tapholdThreshold ); - }); - }, - teardown: function() { - $( this ).unbind( "vmousedown" ).unbind( "vclick" ).unbind( "vmouseup" ); - $document.unbind( "vmousecancel" ); - } - }; - - // Also handles swipeleft, swiperight - $.event.special.swipe = { - - // More than this horizontal displacement, and we will suppress scrolling. - scrollSupressionThreshold: 30, - - // More time than this, and it isn't a swipe. - durationThreshold: 1000, - - // Swipe horizontal displacement must be more than this. - horizontalDistanceThreshold: 30, - - // Swipe vertical displacement must be less than this. - verticalDistanceThreshold: 30, - - getLocation: function ( event ) { - var winPageX = window.pageXOffset, - winPageY = window.pageYOffset, - x = event.clientX, - y = event.clientY; - - if ( event.pageY === 0 && Math.floor( y ) > Math.floor( event.pageY ) || - event.pageX === 0 && Math.floor( x ) > Math.floor( event.pageX ) ) { - - // iOS4 clientX/clientY have the value that should have been - // in pageX/pageY. While pageX/page/ have the value 0 - x = x - winPageX; - y = y - winPageY; - } else if ( y < ( event.pageY - winPageY) || x < ( event.pageX - winPageX ) ) { - - // Some Android browsers have totally bogus values for clientX/Y - // when scrolling/zooming a page. Detectable since clientX/clientY - // should never be smaller than pageX/pageY minus page scroll - x = event.pageX - winPageX; - y = event.pageY - winPageY; - } - - return { - x: x, - y: y - }; - }, - - start: function( event ) { - var data = event.originalEvent.touches ? - event.originalEvent.touches[ 0 ] : event, - location = $.event.special.swipe.getLocation( data ); - return { - time: ( new Date() ).getTime(), - coords: [ location.x, location.y ], - origin: $( event.target ) - }; - }, - - stop: function( event ) { - var data = event.originalEvent.touches ? - event.originalEvent.touches[ 0 ] : event, - location = $.event.special.swipe.getLocation( data ); - return { - time: ( new Date() ).getTime(), - coords: [ location.x, location.y ] - }; - }, - - handleSwipe: function( start, stop, thisObject, origTarget ) { - if ( stop.time - start.time < $.event.special.swipe.durationThreshold && - Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold && - Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) { - var direction = start.coords[0] > stop.coords[ 0 ] ? "swipeleft" : "swiperight"; - - triggerCustomEvent( thisObject, "swipe", $.Event( "swipe", { target: origTarget, swipestart: start, swipestop: stop }), true ); - triggerCustomEvent( thisObject, direction,$.Event( direction, { target: origTarget, swipestart: start, swipestop: stop } ), true ); - return true; - } - return false; - - }, - - // This serves as a flag to ensure that at most one swipe event event is - // in work at any given time - eventInProgress: false, - - setup: function() { - var events, - thisObject = this, - $this = $( thisObject ), - context = {}; - - // Retrieve the events data for this element and add the swipe context - events = $.data( this, "mobile-events" ); - if ( !events ) { - events = { length: 0 }; - $.data( this, "mobile-events", events ); - } - events.length++; - events.swipe = context; - - context.start = function( event ) { - - // Bail if we're already working on a swipe event - if ( $.event.special.swipe.eventInProgress ) { - return; - } - $.event.special.swipe.eventInProgress = true; - - var stop, - start = $.event.special.swipe.start( event ), - origTarget = event.target, - emitted = false; - - context.move = function( event ) { - if ( !start || event.isDefaultPrevented() ) { - return; - } - - stop = $.event.special.swipe.stop( event ); - if ( !emitted ) { - emitted = $.event.special.swipe.handleSwipe( start, stop, thisObject, origTarget ); - if ( emitted ) { - - // Reset the context to make way for the next swipe event - $.event.special.swipe.eventInProgress = false; - } - } - // prevent scrolling - if ( Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.scrollSupressionThreshold ) { - event.preventDefault(); - } - }; - - context.stop = function() { - emitted = true; - - // Reset the context to make way for the next swipe event - $.event.special.swipe.eventInProgress = false; - $document.off( touchMoveEvent, context.move ); - context.move = null; - }; - - $document.on( touchMoveEvent, context.move ) - .one( touchStopEvent, context.stop ); - }; - $this.on( touchStartEvent, context.start ); - }, - - teardown: function() { - var events, context; - - events = $.data( this, "mobile-events" ); - if ( events ) { - context = events.swipe; - delete events.swipe; - events.length--; - if ( events.length === 0 ) { - $.removeData( this, "mobile-events" ); - } - } - - if ( context ) { - if ( context.start ) { - $( this ).off( touchStartEvent, context.start ); - } - if ( context.move ) { - $document.off( touchMoveEvent, context.move ); - } - if ( context.stop ) { - $document.off( touchStopEvent, context.stop ); - } - } - } - }; - $.each({ - scrollstop: "scrollstart", - taphold: "tap", - swipeleft: "swipe.left", - swiperight: "swipe.right" - }, function( event, sourceEvent ) { - - $.event.special[ event ] = { - setup: function() { - $( this ).bind( sourceEvent, $.noop ); - }, - teardown: function() { - $( this ).unbind( sourceEvent ); - } - }; - }); - -})( jQuery, this ); - - - // throttled resize event - (function( $ ) { - $.event.special.throttledresize = { - setup: function() { - $( this ).bind( "resize", handler ); - }, - teardown: function() { - $( this ).unbind( "resize", handler ); - } - }; - - var throttle = 250, - handler = function() { - curr = ( new Date() ).getTime(); - diff = curr - lastCall; - - if ( diff >= throttle ) { - - lastCall = curr; - $( this ).trigger( "throttledresize" ); - - } else { - - if ( heldCall ) { - clearTimeout( heldCall ); - } - - // Promise a held call will still execute - heldCall = setTimeout( handler, throttle - diff ); - } - }, - lastCall = 0, - heldCall, - curr, - diff; - })( jQuery ); - - -(function( $, window ) { - var win = $( window ), - event_name = "orientationchange", - get_orientation, - last_orientation, - initial_orientation_is_landscape, - initial_orientation_is_default, - portrait_map = { "0": true, "180": true }, - ww, wh, landscape_threshold; - - // It seems that some device/browser vendors use window.orientation values 0 and 180 to - // denote the "default" orientation. For iOS devices, and most other smart-phones tested, - // the default orientation is always "portrait", but in some Android and RIM based tablets, - // the default orientation is "landscape". The following code attempts to use the window - // dimensions to figure out what the current orientation is, and then makes adjustments - // to the to the portrait_map if necessary, so that we can properly decode the - // window.orientation value whenever get_orientation() is called. - // - // Note that we used to use a media query to figure out what the orientation the browser - // thinks it is in: - // - // initial_orientation_is_landscape = $.mobile.media("all and (orientation: landscape)"); - // - // but there was an iPhone/iPod Touch bug beginning with iOS 4.2, up through iOS 5.1, - // where the browser *ALWAYS* applied the landscape media query. This bug does not - // happen on iPad. - - if ( $.support.orientation ) { - - // Check the window width and height to figure out what the current orientation - // of the device is at this moment. Note that we've initialized the portrait map - // values to 0 and 180, *AND* we purposely check for landscape so that if we guess - // wrong, , we default to the assumption that portrait is the default orientation. - // We use a threshold check below because on some platforms like iOS, the iPhone - // form-factor can report a larger width than height if the user turns on the - // developer console. The actual threshold value is somewhat arbitrary, we just - // need to make sure it is large enough to exclude the developer console case. - - ww = window.innerWidth || win.width(); - wh = window.innerHeight || win.height(); - landscape_threshold = 50; - - initial_orientation_is_landscape = ww > wh && ( ww - wh ) > landscape_threshold; - - // Now check to see if the current window.orientation is 0 or 180. - initial_orientation_is_default = portrait_map[ window.orientation ]; - - // If the initial orientation is landscape, but window.orientation reports 0 or 180, *OR* - // if the initial orientation is portrait, but window.orientation reports 90 or -90, we - // need to flip our portrait_map values because landscape is the default orientation for - // this device/browser. - if ( ( initial_orientation_is_landscape && initial_orientation_is_default ) || ( !initial_orientation_is_landscape && !initial_orientation_is_default ) ) { - portrait_map = { "-90": true, "90": true }; - } - } - - $.event.special.orientationchange = $.extend( {}, $.event.special.orientationchange, { - setup: function() { - // If the event is supported natively, return false so that jQuery - // will bind to the event using DOM methods. - if ( $.support.orientation && !$.event.special.orientationchange.disabled ) { - return false; - } - - // Get the current orientation to avoid initial double-triggering. - last_orientation = get_orientation(); - - // Because the orientationchange event doesn't exist, simulate the - // event by testing window dimensions on resize. - win.bind( "throttledresize", handler ); - }, - teardown: function() { - // If the event is not supported natively, return false so that - // jQuery will unbind the event using DOM methods. - if ( $.support.orientation && !$.event.special.orientationchange.disabled ) { - return false; - } - - // Because the orientationchange event doesn't exist, unbind the - // resize event handler. - win.unbind( "throttledresize", handler ); - }, - add: function( handleObj ) { - // Save a reference to the bound event handler. - var old_handler = handleObj.handler; - - handleObj.handler = function( event ) { - // Modify event object, adding the .orientation property. - event.orientation = get_orientation(); - - // Call the originally-bound event handler and return its result. - return old_handler.apply( this, arguments ); - }; - } - }); - - // If the event is not supported natively, this handler will be bound to - // the window resize event to simulate the orientationchange event. - function handler() { - // Get the current orientation. - var orientation = get_orientation(); - - if ( orientation !== last_orientation ) { - // The orientation has changed, so trigger the orientationchange event. - last_orientation = orientation; - win.trigger( event_name ); - } - } - - // Get the current page orientation. This method is exposed publicly, should it - // be needed, as jQuery.event.special.orientationchange.orientation() - $.event.special.orientationchange.orientation = get_orientation = function() { - var isPortrait = true, elem = document.documentElement; - - // prefer window orientation to the calculation based on screensize as - // the actual screen resize takes place before or after the orientation change event - // has been fired depending on implementation (eg android 2.3 is before, iphone after). - // More testing is required to determine if a more reliable method of determining the new screensize - // is possible when orientationchange is fired. (eg, use media queries + element + opacity) - if ( $.support.orientation ) { - // if the window orientation registers as 0 or 180 degrees report - // portrait, otherwise landscape - isPortrait = portrait_map[ window.orientation ]; - } else { - isPortrait = elem && elem.clientWidth / elem.clientHeight < 1.1; - } - - return isPortrait ? "portrait" : "landscape"; - }; - - $.fn[ event_name ] = function( fn ) { - return fn ? this.bind( event_name, fn ) : this.trigger( event_name ); - }; - - // jQuery < 1.8 - if ( $.attrFn ) { - $.attrFn[ event_name ] = true; - } - -}( jQuery, this )); - - - - -(function( $, undefined ) { - - // existing base tag? - var baseElement = $( "head" ).children( "base" ), - - // base element management, defined depending on dynamic base tag support - // TODO move to external widget - base = { - - // define base element, for use in routing asset urls that are referenced - // in Ajax-requested markup - element: ( baseElement.length ? baseElement : - $( "", { href: $.mobile.path.documentBase.hrefNoHash } ).prependTo( $( "head" ) ) ), - - linkSelector: "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]", - - // set the generated BASE element's href to a new page's base path - set: function( href ) { - - // we should do nothing if the user wants to manage their url base - // manually - if ( !$.mobile.dynamicBaseEnabled ) { - return; - } - - // we should use the base tag if we can manipulate it dynamically - if ( $.support.dynamicBaseTag ) { - base.element.attr( "href", - $.mobile.path.makeUrlAbsolute( href, $.mobile.path.documentBase ) ); - } - }, - - rewrite: function( href, page ) { - var newPath = $.mobile.path.get( href ); - - page.find( base.linkSelector ).each(function( i, link ) { - var thisAttr = $( link ).is( "[href]" ) ? "href" : - $( link ).is( "[src]" ) ? "src" : "action", - theLocation = $.mobile.path.parseLocation(), - thisUrl = $( link ).attr( thisAttr ); - - // XXX_jblas: We need to fix this so that it removes the document - // base URL, and then prepends with the new page URL. - // if full path exists and is same, chop it - helps IE out - thisUrl = thisUrl.replace( theLocation.protocol + theLocation.doubleSlash + - theLocation.host + theLocation.pathname, "" ); - - if ( !/^(\w+:|#|\/)/.test( thisUrl ) ) { - $( link ).attr( thisAttr, newPath + thisUrl ); - } - }); - }, - - // set the generated BASE element's href to a new page's base path - reset: function(/* href */) { - base.element.attr( "href", $.mobile.path.documentBase.hrefNoSearch ); - } - }; - - $.mobile.base = base; - -})( jQuery ); - - -(function( $, undefined ) { -$.mobile.widgets = {}; - -var originalWidget = $.widget, - - // Record the original, non-mobileinit-modified version of $.mobile.keepNative - // so we can later determine whether someone has modified $.mobile.keepNative - keepNativeFactoryDefault = $.mobile.keepNative; - -$.widget = (function( orig ) { - return function() { - var constructor = orig.apply( this, arguments ), - name = constructor.prototype.widgetName; - - constructor.initSelector = ( ( constructor.prototype.initSelector !== undefined ) ? - constructor.prototype.initSelector : ":jqmData(role='" + name + "')" ); - - $.mobile.widgets[ name ] = constructor; - - return constructor; - }; -})( $.widget ); - -// Make sure $.widget still has bridge and extend methods -$.extend( $.widget, originalWidget ); - -// For backcompat remove in 1.5 -$.mobile.document.on( "create", function( event ) { - $( event.target ).enhanceWithin(); -}); - -$.widget( "mobile.page", { - options: { - theme: "a", - domCache: false, - - // Deprecated in 1.4 remove in 1.5 - keepNativeDefault: $.mobile.keepNative, - - // Deprecated in 1.4 remove in 1.5 - contentTheme: null, - enhanced: false - }, - - // DEPRECATED for > 1.4 - // TODO remove at 1.5 - _createWidget: function() { - $.Widget.prototype._createWidget.apply( this, arguments ); - this._trigger( "init" ); - }, - - _create: function() { - // If false is returned by the callbacks do not create the page - if ( this._trigger( "beforecreate" ) === false ) { - return false; - } - - if ( !this.options.enhanced ) { - this._enhance(); - } - - this._on( this.element, { - pagebeforehide: "removeContainerBackground", - pagebeforeshow: "_handlePageBeforeShow" - }); - - this.element.enhanceWithin(); - // Dialog widget is deprecated in 1.4 remove this in 1.5 - if ( $.mobile.getAttribute( this.element[0], "role" ) === "dialog" && $.mobile.dialog ) { - this.element.dialog(); - } - }, - - _enhance: function () { - var attrPrefix = "data-" + $.mobile.ns, - self = this; - - if ( this.options.role ) { - this.element.attr( "data-" + $.mobile.ns + "role", this.options.role ); - } - - this.element - .attr( "tabindex", "0" ) - .addClass( "ui-page ui-page-theme-" + this.options.theme ); - - // Manipulation of content os Deprecated as of 1.4 remove in 1.5 - this.element.find( "[" + attrPrefix + "role='content']" ).each( function() { - var $this = $( this ), - theme = this.getAttribute( attrPrefix + "theme" ) || undefined; - self.options.contentTheme = theme || self.options.contentTheme || ( self.options.dialog && self.options.theme ) || ( self.element.jqmData("role") === "dialog" && self.options.theme ); - $this.addClass( "ui-content" ); - if ( self.options.contentTheme ) { - $this.addClass( "ui-body-" + ( self.options.contentTheme ) ); - } - // Add ARIA role - $this.attr( "role", "main" ).addClass( "ui-content" ); - }); - }, - - bindRemove: function( callback ) { - var page = this.element; - - // when dom caching is not enabled or the page is embedded bind to remove the page on hide - if ( !page.data( "mobile-page" ).options.domCache && - page.is( ":jqmData(external-page='true')" ) ) { - - // TODO use _on - that is, sort out why it doesn't work in this case - page.bind( "pagehide.remove", callback || function( e, data ) { - - //check if this is a same page transition and if so don't remove the page - if( !data.samePage ){ - var $this = $( this ), - prEvent = new $.Event( "pageremove" ); - - $this.trigger( prEvent ); - - if ( !prEvent.isDefaultPrevented() ) { - $this.removeWithDependents(); - } - } - }); - } - }, - - _setOptions: function( o ) { - if ( o.theme !== undefined ) { - this.element.removeClass( "ui-page-theme-" + this.options.theme ).addClass( "ui-page-theme-" + o.theme ); - } - - if ( o.contentTheme !== undefined ) { - this.element.find( "[data-" + $.mobile.ns + "='content']" ).removeClass( "ui-body-" + this.options.contentTheme ) - .addClass( "ui-body-" + o.contentTheme ); - } - }, - - _handlePageBeforeShow: function(/* e */) { - this.setContainerBackground(); - }, - // Deprecated in 1.4 remove in 1.5 - removeContainerBackground: function() { - this.element.closest( ":mobile-pagecontainer" ).pagecontainer({ "theme": "none" }); - }, - // Deprecated in 1.4 remove in 1.5 - // set the page container background to the page theme - setContainerBackground: function( theme ) { - this.element.parent().pagecontainer( { "theme": theme || this.options.theme } ); - }, - // Deprecated in 1.4 remove in 1.5 - keepNativeSelector: function() { - var options = this.options, - keepNative = $.trim( options.keepNative || "" ), - globalValue = $.trim( $.mobile.keepNative ), - optionValue = $.trim( options.keepNativeDefault ), - - // Check if $.mobile.keepNative has changed from the factory default - newDefault = ( keepNativeFactoryDefault === globalValue ? - "" : globalValue ), - - // If $.mobile.keepNative has not changed, use options.keepNativeDefault - oldDefault = ( newDefault === "" ? optionValue : "" ); - - // Concatenate keepNative selectors from all sources where the value has - // changed or, if nothing has changed, return the default - return ( ( keepNative ? [ keepNative ] : [] ) - .concat( newDefault ? [ newDefault ] : [] ) - .concat( oldDefault ? [ oldDefault ] : [] ) - .join( ", " ) ); - } -}); -})( jQuery ); - -(function( $, undefined ) { - - $.widget( "mobile.pagecontainer", { - options: { - theme: "a" - }, - - initSelector: false, - - _create: function() { - this._trigger( "beforecreate" ); - this.setLastScrollEnabled = true; - - this._on( this.window, { - // disable an scroll setting when a hashchange has been fired, - // this only works because the recording of the scroll position - // is delayed for 100ms after the browser might have changed the - // position because of the hashchange - navigate: "_disableRecordScroll", - - // bind to scrollstop for the first page, "pagechange" won't be - // fired in that case - scrollstop: "_delayedRecordScroll" - }); - - // TODO consider moving the navigation handler OUT of widget into - // some other object as glue between the navigate event and the - // content widget load and change methods - this._on( this.window, { navigate: "_filterNavigateEvents" }); - - // TODO move from page* events to content* events - this._on({ pagechange: "_afterContentChange" }); - - // handle initial hashchange from chrome :( - this.window.one( "navigate", $.proxy(function() { - this.setLastScrollEnabled = true; - }, this)); - }, - - _setOptions: function( options ) { - if ( options.theme !== undefined && options.theme !== "none" ) { - this.element.removeClass( "ui-overlay-" + this.options.theme ) - .addClass( "ui-overlay-" + options.theme ); - } else if ( options.theme !== undefined ) { - this.element.removeClass( "ui-overlay-" + this.options.theme ); - } - - this._super( options ); - }, - - _disableRecordScroll: function() { - this.setLastScrollEnabled = false; - }, - - _enableRecordScroll: function() { - this.setLastScrollEnabled = true; - }, - - // TODO consider the name here, since it's purpose specific - _afterContentChange: function() { - // once the page has changed, re-enable the scroll recording - this.setLastScrollEnabled = true; - - // remove any binding that previously existed on the get scroll - // which may or may not be different than the scroll element - // determined for this page previously - this._off( this.window, "scrollstop" ); - - // determine and bind to the current scoll element which may be the - // window or in the case of touch overflow the element touch overflow - this._on( this.window, { scrollstop: "_delayedRecordScroll" }); - }, - - _recordScroll: function() { - // this barrier prevents setting the scroll value based on - // the browser scrolling the window based on a hashchange - if ( !this.setLastScrollEnabled ) { - return; - } - - var active = this._getActiveHistory(), - currentScroll, minScroll, defaultScroll; - - if ( active ) { - currentScroll = this._getScroll(); - minScroll = this._getMinScroll(); - defaultScroll = this._getDefaultScroll(); - - // Set active page's lastScroll prop. If the location we're - // scrolling to is less than minScrollBack, let it go. - active.lastScroll = currentScroll < minScroll ? defaultScroll : currentScroll; - } - }, - - _delayedRecordScroll: function() { - setTimeout( $.proxy(this, "_recordScroll"), 100 ); - }, - - _getScroll: function() { - return this.window.scrollTop(); - }, - - _getMinScroll: function() { - return $.mobile.minScrollBack; - }, - - _getDefaultScroll: function() { - return $.mobile.defaultHomeScroll; - }, - - _filterNavigateEvents: function( e, data ) { - var url; - - if ( e.originalEvent && e.originalEvent.isDefaultPrevented() ) { - return; - } - - url = e.originalEvent.type.indexOf( "hashchange" ) > -1 ? data.state.hash : data.state.url; - - if ( !url ) { - url = this._getHash(); - } - - if ( !url || url === "#" || url.indexOf( "#" + $.mobile.path.uiStateKey ) === 0 ) { - url = location.href; - } - - this._handleNavigate( url, data.state ); - }, - - _getHash: function() { - return $.mobile.path.parseLocation().hash; - }, - - // TODO active page should be managed by the container (ie, it should be a property) - getActivePage: function() { - return this.activePage; - }, - - // TODO the first page should be a property set during _create using the logic - // that currently resides in init - _getInitialContent: function() { - return $.mobile.firstPage; - }, - - // TODO each content container should have a history object - _getHistory: function() { - return $.mobile.navigate.history; - }, - - _getActiveHistory: function() { - return this._getHistory().getActive(); - }, - - // TODO the document base should be determined at creation - _getDocumentBase: function() { - return $.mobile.path.documentBase; - }, - - back: function() { - this.go( -1 ); - }, - - forward: function() { - this.go( 1 ); - }, - - go: function( steps ) { - - //if hashlistening is enabled use native history method - if ( $.mobile.hashListeningEnabled ) { - window.history.go( steps ); - } else { - - //we are not listening to the hash so handle history internally - var activeIndex = $.mobile.navigate.history.activeIndex, - index = activeIndex + parseInt( steps, 10 ), - url = $.mobile.navigate.history.stack[ index ].url, - direction = ( steps >= 1 )? "forward" : "back"; - - //update the history object - $.mobile.navigate.history.activeIndex = index; - $.mobile.navigate.history.previousIndex = activeIndex; - - //change to the new page - this.change( url, { direction: direction, changeHash: false, fromHashChange: true } ); - } - }, - - // TODO rename _handleDestination - _handleDestination: function( to ) { - var history; - - // clean the hash for comparison if it's a url - if ( $.type(to) === "string" ) { - to = $.mobile.path.stripHash( to ); - } - - if ( to ) { - history = this._getHistory(); - - // At this point, 'to' can be one of 3 things, a cached page - // element from a history stack entry, an id, or site-relative / - // absolute URL. If 'to' is an id, we need to resolve it against - // the documentBase, not the location.href, since the hashchange - // could've been the result of a forward/backward navigation - // that crosses from an external page/dialog to an internal - // page/dialog. - // - // TODO move check to history object or path object? - to = !$.mobile.path.isPath( to ) ? ( $.mobile.path.makeUrlAbsolute( "#" + to, this._getDocumentBase() ) ) : to; - } - return to || this._getInitialContent(); - }, - - _transitionFromHistory: function( direction, defaultTransition ) { - var history = this._getHistory(), - entry = ( direction === "back" ? history.getLast() : history.getActive() ); - - return ( entry && entry.transition ) || defaultTransition; - }, - - _handleDialog: function( changePageOptions, data ) { - var to, active, activeContent = this.getActivePage(); - - // If current active page is not a dialog skip the dialog and continue - // in the same direction - // Note: The dialog widget is deprecated as of 1.4.0 and will be removed in 1.5.0. - // Thus, as of 1.5.0 activeContent.data( "mobile-dialog" ) will always evaluate to - // falsy, so the second condition in the if-statement below can be removed altogether. - if ( activeContent && !activeContent.data( "mobile-dialog" ) ) { - // determine if we're heading forward or backward and continue - // accordingly past the current dialog - if ( data.direction === "back" ) { - this.back(); - } else { - this.forward(); - } - - // prevent changePage call - return false; - } else { - // if the current active page is a dialog and we're navigating - // to a dialog use the dialog objected saved in the stack - to = data.pageUrl; - active = this._getActiveHistory(); - - // make sure to set the role, transition and reversal - // as most of this is lost by the domCache cleaning - $.extend( changePageOptions, { - role: active.role, - transition: this._transitionFromHistory( - data.direction, - changePageOptions.transition ), - reverse: data.direction === "back" - }); - } - - return to; - }, - - _handleNavigate: function( url, data ) { - //find first page via hash - // TODO stripping the hash twice with handleUrl - var to = $.mobile.path.stripHash( url ), history = this._getHistory(), - - // transition is false if it's the first page, undefined - // otherwise (and may be overridden by default) - transition = history.stack.length === 0 ? "none" : - this._transitionFromHistory( data.direction ), - - // default options for the changPage calls made after examining - // the current state of the page and the hash, NOTE that the - // transition is derived from the previous history entry - changePageOptions = { - changeHash: false, - fromHashChange: true, - reverse: data.direction === "back" - }; - - $.extend( changePageOptions, data, { - transition: transition - }); - - // TODO move to _handleDestination ? - // If this isn't the first page, if the current url is a dialog hash - // key, and the initial destination isn't equal to the current target - // page, use the special dialog handling - if ( history.activeIndex > 0 && - to.indexOf( $.mobile.dialogHashKey ) > -1 ) { - - to = this._handleDialog( changePageOptions, data ); - - if ( to === false ) { - return; - } - } - - this._changeContent( this._handleDestination( to ), changePageOptions ); - }, - - _changeContent: function( to, opts ) { - $.mobile.changePage( to, opts ); - }, - - _getBase: function() { - return $.mobile.base; - }, - - _getNs: function() { - return $.mobile.ns; - }, - - _enhance: function( content, role ) { - // TODO consider supporting a custom callback, and passing in - // the settings which includes the role - return content.page({ role: role }); - }, - - _include: function( page, settings ) { - // append to page and enhance - page.appendTo( this.element ); - - // use the page widget to enhance - this._enhance( page, settings.role ); - - // remove page on hide - page.page( "bindRemove" ); - }, - - _find: function( absUrl ) { - // TODO consider supporting a custom callback - var fileUrl = this._createFileUrl( absUrl ), - dataUrl = this._createDataUrl( absUrl ), - page, initialContent = this._getInitialContent(); - - // Check to see if the page already exists in the DOM. - // NOTE do _not_ use the :jqmData pseudo selector because parenthesis - // are a valid url char and it breaks on the first occurence - page = this.element - .children( "[data-" + this._getNs() + - "url='" + $.mobile.path.hashToSelector( dataUrl ) + "']" ); - - // If we failed to find the page, check to see if the url is a - // reference to an embedded page. If so, it may have been dynamically - // injected by a developer, in which case it would be lacking a - // data-url attribute and in need of enhancement. - if ( page.length === 0 && dataUrl && !$.mobile.path.isPath( dataUrl ) ) { - page = this.element.children( $.mobile.path.hashToSelector("#" + dataUrl) ) - .attr( "data-" + this._getNs() + "url", dataUrl ) - .jqmData( "url", dataUrl ); - } - - // If we failed to find a page in the DOM, check the URL to see if it - // refers to the first page in the application. Also check to make sure - // our cached-first-page is actually in the DOM. Some user deployed - // apps are pruning the first page from the DOM for various reasons. - // We check for this case here because we don't want a first-page with - // an id falling through to the non-existent embedded page error case. - if ( page.length === 0 && - $.mobile.path.isFirstPageUrl( fileUrl ) && - initialContent && - initialContent.parent().length ) { - page = $( initialContent ); - } - - return page; - }, - - _getLoader: function() { - return $.mobile.loading(); - }, - - _showLoading: function( delay, theme, msg, textonly ) { - // This configurable timeout allows cached pages a brief - // delay to load without showing a message - if ( this._loadMsg ) { - return; - } - - this._loadMsg = setTimeout($.proxy(function() { - this._getLoader().loader( "show", theme, msg, textonly ); - this._loadMsg = 0; - }, this), delay ); - }, - - _hideLoading: function() { - // Stop message show timer - clearTimeout( this._loadMsg ); - this._loadMsg = 0; - - // Hide loading message - this._getLoader().loader( "hide" ); - }, - - _showError: function() { - // make sure to remove the current loading message - this._hideLoading(); - - // show the error message - this._showLoading( 0, $.mobile.pageLoadErrorMessageTheme, $.mobile.pageLoadErrorMessage, true ); - - // hide the error message after a delay - // TODO configuration - setTimeout( $.proxy(this, "_hideLoading"), 1500 ); - }, - - _parse: function( html, fileUrl ) { - // TODO consider allowing customization of this method. It's very JQM specific - var page, all = $( "
" ); - - //workaround to allow scripts to execute when included in page divs - all.get( 0 ).innerHTML = html; - - page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first(); - - //if page elem couldn't be found, create one and insert the body element's contents - if ( !page.length ) { - page = $( "
" + - ( html.split( /<\/?body[^>]*>/gmi )[1] || "" ) + - "
" ); - } - - // TODO tagging a page with external to make sure that embedded pages aren't - // removed by the various page handling code is bad. Having page handling code - // in many places is bad. Solutions post 1.0 - page.attr( "data-" + this._getNs() + "url", this._createDataUrl( fileUrl ) ) - .attr( "data-" + this._getNs() + "external-page", true ); - - return page; - }, - - _setLoadedTitle: function( page, html ) { - //page title regexp - var newPageTitle = html.match( /]*>([^<]*)/ ) && RegExp.$1; - - if ( newPageTitle && !page.jqmData("title") ) { - newPageTitle = $( "
" + newPageTitle + "
" ).text(); - page.jqmData( "title", newPageTitle ); - } - }, - - _isRewritableBaseTag: function() { - return $.mobile.dynamicBaseEnabled && !$.support.dynamicBaseTag; - }, - - _createDataUrl: function( absoluteUrl ) { - return $.mobile.path.convertUrlToDataUrl( absoluteUrl ); - }, - - _createFileUrl: function( absoluteUrl ) { - return $.mobile.path.getFilePath( absoluteUrl ); - }, - - _triggerWithDeprecated: function( name, data, page ) { - var deprecatedEvent = $.Event( "page" + name ), - newEvent = $.Event( this.widgetName + name ); - - // DEPRECATED - // trigger the old deprecated event on the page if it's provided - ( page || this.element ).trigger( deprecatedEvent, data ); - - // use the widget trigger method for the new content* event - this._trigger( name, newEvent, data ); - - return { - deprecatedEvent: deprecatedEvent, - event: newEvent - }; - }, - - // TODO it would be nice to split this up more but everything appears to be "one off" - // or require ordering such that other bits are sprinkled in between parts that - // could be abstracted out as a group - _loadSuccess: function( absUrl, triggerData, settings, deferred ) { - var fileUrl = this._createFileUrl( absUrl ); - - return $.proxy(function( html, textStatus, xhr ) { - //pre-parse html to check for a data-url, - //use it as the new fileUrl, base path, etc - var content, - - // TODO handle dialogs again - pageElemRegex = new RegExp( "(<[^>]+\\bdata-" + this._getNs() + "role=[\"']?page[\"']?[^>]*>)" ), - - dataUrlRegex = new RegExp( "\\bdata-" + this._getNs() + "url=[\"']?([^\"'>]*)[\"']?" ); - - // data-url must be provided for the base tag so resource requests - // can be directed to the correct url. loading into a temprorary - // element makes these requests immediately - if ( pageElemRegex.test( html ) && - RegExp.$1 && - dataUrlRegex.test( RegExp.$1 ) && - RegExp.$1 ) { - fileUrl = $.mobile.path.getFilePath( $("
" + RegExp.$1 + "
").text() ); - - // We specify that, if a data-url attribute is given on the page div, its value - // must be given non-URL-encoded. However, in this part of the code, fileUrl is - // assumed to be URL-encoded, so we URL-encode the retrieved value here - fileUrl = this.window[ 0 ].encodeURIComponent( fileUrl ); - } - - //dont update the base tag if we are prefetching - if ( settings.prefetch === undefined ) { - this._getBase().set( fileUrl ); - } - - content = this._parse( html, fileUrl ); - - this._setLoadedTitle( content, html ); - - // Add the content reference and xhr to our triggerData. - triggerData.xhr = xhr; - triggerData.textStatus = textStatus; - - // DEPRECATED - triggerData.page = content; - - triggerData.content = content; - - triggerData.toPage = content; - - // If the default behavior is prevented, stop here! - // Note that it is the responsibility of the listener/handler - // that called preventDefault(), to resolve/reject the - // deferred object within the triggerData. - if ( this._triggerWithDeprecated( "load", triggerData ).event.isDefaultPrevented() ) { - return; - } - - // rewrite src and href attrs to use a base url if the base tag won't work - if ( this._isRewritableBaseTag() && content ) { - this._getBase().rewrite( fileUrl, content ); - } - - this._include( content, settings ); - - // Remove loading message. - if ( settings.showLoadMsg ) { - this._hideLoading(); - } - - deferred.resolve( absUrl, settings, content ); - }, this); - }, - - _loadDefaults: { - type: "get", - data: undefined, - - // DEPRECATED - reloadPage: false, - - reload: false, - - // By default we rely on the role defined by the @data-role attribute. - role: undefined, - - showLoadMsg: false, - - // This delay allows loads that pull from browser cache to - // occur without showing the loading message. - loadMsgDelay: 50 - }, - - load: function( url, options ) { - // This function uses deferred notifications to let callers - // know when the content is done loading, or if an error has occurred. - var deferred = ( options && options.deferred ) || $.Deferred(), - - // Examining the option "reloadPage" passed by the user is deprecated as of 1.4.0 - // and will be removed in 1.5.0. - // Copy option "reloadPage" to "reload", but only if option "reload" is not present - reloadOptionExtension = - ( ( options && options.reload === undefined && - options.reloadPage !== undefined ) ? - { reload: options.reloadPage } : {} ), - - // The default load options with overrides specified by the caller. - settings = $.extend( {}, this._loadDefaults, options, reloadOptionExtension ), - - // The DOM element for the content after it has been loaded. - content = null, - - // The absolute version of the URL passed into the function. This - // version of the URL may contain dialog/subcontent params in it. - absUrl = $.mobile.path.makeUrlAbsolute( url, this._findBaseWithDefault() ), - fileUrl, dataUrl, pblEvent, triggerData; - - // If the caller provided data, and we're using "get" request, - // append the data to the URL. - if ( settings.data && settings.type === "get" ) { - absUrl = $.mobile.path.addSearchParams( absUrl, settings.data ); - settings.data = undefined; - } - - // If the caller is using a "post" request, reload must be true - if ( settings.data && settings.type === "post" ) { - settings.reload = true; - } - - // The absolute version of the URL minus any dialog/subcontent params. - // In otherwords the real URL of the content to be loaded. - fileUrl = this._createFileUrl( absUrl ); - - // The version of the Url actually stored in the data-url attribute of - // the content. For embedded content, it is just the id of the page. For - // content within the same domain as the document base, it is the site - // relative path. For cross-domain content (Phone Gap only) the entire - // absolute Url is used to load the content. - dataUrl = this._createDataUrl( absUrl ); - - content = this._find( absUrl ); - - // If it isn't a reference to the first content and refers to missing - // embedded content reject the deferred and return - if ( content.length === 0 && - $.mobile.path.isEmbeddedPage(fileUrl) && - !$.mobile.path.isFirstPageUrl(fileUrl) ) { - deferred.reject( absUrl, settings ); - return deferred.promise(); - } - - // Reset base to the default document base - // TODO figure out why we doe this - this._getBase().reset(); - - // If the content we are interested in is already in the DOM, - // and the caller did not indicate that we should force a - // reload of the file, we are done. Resolve the deferrred so that - // users can bind to .done on the promise - if ( content.length && !settings.reload ) { - this._enhance( content, settings.role ); - deferred.resolve( absUrl, settings, content ); - - //if we are reloading the content make sure we update - // the base if its not a prefetch - if ( !settings.prefetch ) { - this._getBase().set(url); - } - - return deferred.promise(); - } - - triggerData = { - url: url, - absUrl: absUrl, - toPage: url, - prevPage: options ? options.fromPage : undefined, - dataUrl: dataUrl, - deferred: deferred, - options: settings - }; - - // Let listeners know we're about to load content. - pblEvent = this._triggerWithDeprecated( "beforeload", triggerData ); - - // If the default behavior is prevented, stop here! - if ( pblEvent.deprecatedEvent.isDefaultPrevented() || - pblEvent.event.isDefaultPrevented() ) { - return deferred.promise(); - } - - if ( settings.showLoadMsg ) { - this._showLoading( settings.loadMsgDelay ); - } - - // Reset base to the default document base. - // only reset if we are not prefetching - if ( settings.prefetch === undefined ) { - this._getBase().reset(); - } - - if ( !( $.mobile.allowCrossDomainPages || - $.mobile.path.isSameDomain($.mobile.path.documentUrl, absUrl ) ) ) { - deferred.reject( absUrl, settings ); - return deferred.promise(); - } - - // Load the new content. - $.ajax({ - url: fileUrl, - type: settings.type, - data: settings.data, - contentType: settings.contentType, - dataType: "html", - success: this._loadSuccess( absUrl, triggerData, settings, deferred ), - error: this._loadError( absUrl, triggerData, settings, deferred ) - }); - - return deferred.promise(); - }, - - _loadError: function( absUrl, triggerData, settings, deferred ) { - return $.proxy(function( xhr, textStatus, errorThrown ) { - //set base back to current path - this._getBase().set( $.mobile.path.get() ); - - // Add error info to our triggerData. - triggerData.xhr = xhr; - triggerData.textStatus = textStatus; - triggerData.errorThrown = errorThrown; - - // Let listeners know the page load failed. - var plfEvent = this._triggerWithDeprecated( "loadfailed", triggerData ); - - // If the default behavior is prevented, stop here! - // Note that it is the responsibility of the listener/handler - // that called preventDefault(), to resolve/reject the - // deferred object within the triggerData. - if ( plfEvent.deprecatedEvent.isDefaultPrevented() || - plfEvent.event.isDefaultPrevented() ) { - return; - } - - // Remove loading message. - if ( settings.showLoadMsg ) { - this._showError(); - } - - deferred.reject( absUrl, settings ); - }, this); - }, - - _getTransitionHandler: function( transition ) { - transition = $.mobile._maybeDegradeTransition( transition ); - - //find the transition handler for the specified transition. If there - //isn't one in our transitionHandlers dictionary, use the default one. - //call the handler immediately to kick-off the transition. - return $.mobile.transitionHandlers[ transition ] || $.mobile.defaultTransitionHandler; - }, - - // TODO move into transition handlers? - _triggerCssTransitionEvents: function( to, from, prefix ) { - var samePage = false; - - prefix = prefix || ""; - - // TODO decide if these events should in fact be triggered on the container - if ( from ) { - - //Check if this is a same page transition and tell the handler in page - if( to[0] === from[0] ){ - samePage = true; - } - - //trigger before show/hide events - // TODO deprecate nextPage in favor of next - this._triggerWithDeprecated( prefix + "hide", { - - // Deprecated in 1.4 remove in 1.5 - nextPage: to, - toPage: to, - prevPage: from, - samePage: samePage - }, from ); - } - - // TODO deprecate prevPage in favor of previous - this._triggerWithDeprecated( prefix + "show", { - prevPage: from || $( "" ), - toPage: to - }, to ); - }, - - // TODO make private once change has been defined in the widget - _cssTransition: function( to, from, options ) { - var transition = options.transition, - reverse = options.reverse, - deferred = options.deferred, - TransitionHandler, - promise; - - this._triggerCssTransitionEvents( to, from, "before" ); - - // TODO put this in a binding to events *outside* the widget - this._hideLoading(); - - TransitionHandler = this._getTransitionHandler( transition ); - - promise = ( new TransitionHandler( transition, reverse, to, from ) ).transition(); - - promise.done( $.proxy( function() { - this._triggerCssTransitionEvents( to, from ); - }, this )); - - // TODO temporary accomodation of argument deferred - promise.done(function() { - deferred.resolve.apply( deferred, arguments ); - }); - }, - - _releaseTransitionLock: function() { - //release transition lock so navigation is free again - isPageTransitioning = false; - if ( pageTransitionQueue.length > 0 ) { - $.mobile.changePage.apply( null, pageTransitionQueue.pop() ); - } - }, - - _removeActiveLinkClass: function( force ) { - //clear out the active button state - $.mobile.removeActiveLinkClass( force ); - }, - - _loadUrl: function( to, triggerData, settings ) { - // preserve the original target as the dataUrl value will be - // simplified eg, removing ui-state, and removing query params - // from the hash this is so that users who want to use query - // params have access to them in the event bindings for the page - // life cycle See issue #5085 - settings.target = to; - settings.deferred = $.Deferred(); - - this.load( to, settings ); - - settings.deferred.done($.proxy(function( url, options, content ) { - isPageTransitioning = false; - - // store the original absolute url so that it can be provided - // to events in the triggerData of the subsequent changePage call - options.absUrl = triggerData.absUrl; - - this.transition( content, triggerData, options ); - }, this)); - - settings.deferred.fail($.proxy(function(/* url, options */) { - this._removeActiveLinkClass( true ); - this._releaseTransitionLock(); - this._triggerWithDeprecated( "changefailed", triggerData ); - }, this)); - }, - - _triggerPageBeforeChange: function( to, triggerData, settings ) { - var returnEvents; - - triggerData.prevPage = this.activePage; - $.extend( triggerData, { - toPage: to, - options: settings - }); - - // NOTE: preserve the original target as the dataUrl value will be - // simplified eg, removing ui-state, and removing query params from - // the hash this is so that users who want to use query params have - // access to them in the event bindings for the page life cycle - // See issue #5085 - if ( $.type(to) === "string" ) { - // if the toPage is a string simply convert it - triggerData.absUrl = $.mobile.path.makeUrlAbsolute( to, this._findBaseWithDefault() ); - } else { - // if the toPage is a jQuery object grab the absolute url stored - // in the loadPage callback where it exists - triggerData.absUrl = settings.absUrl; - } - - // Let listeners know we're about to change the current page. - returnEvents = this._triggerWithDeprecated( "beforechange", triggerData ); - - // If the default behavior is prevented, stop here! - if ( returnEvents.event.isDefaultPrevented() || - returnEvents.deprecatedEvent.isDefaultPrevented() ) { - return false; - } - - return true; - }, - - change: function( to, options ) { - // If we are in the midst of a transition, queue the current request. - // We'll call changePage() once we're done with the current transition - // to service the request. - if ( isPageTransitioning ) { - pageTransitionQueue.unshift( arguments ); - return; - } - - var settings = $.extend( {}, $.mobile.changePage.defaults, options ), - triggerData = {}; - - // Make sure we have a fromPage. - settings.fromPage = settings.fromPage || this.activePage; - - // if the page beforechange default is prevented return early - if ( !this._triggerPageBeforeChange(to, triggerData, settings) ) { - return; - } - - // We allow "pagebeforechange" observers to modify the to in - // the trigger data to allow for redirects. Make sure our to is - // updated. We also need to re-evaluate whether it is a string, - // because an object can also be replaced by a string - to = triggerData.toPage; - - // If the caller passed us a url, call loadPage() - // to make sure it is loaded into the DOM. We'll listen - // to the promise object it returns so we know when - // it is done loading or if an error ocurred. - if ( $.type(to) === "string" ) { - // Set the isPageTransitioning flag to prevent any requests from - // entering this method while we are in the midst of loading a page - // or transitioning. - isPageTransitioning = true; - - this._loadUrl( to, triggerData, settings ); - } else { - this.transition( to, triggerData, settings ); - } - }, - - transition: function( toPage, triggerData, settings ) { - var fromPage, url, pageUrl, fileUrl, - active, activeIsInitialPage, - historyDir, pageTitle, isDialog, - alreadyThere, newPageTitle, - params, cssTransitionDeferred, - beforeTransition; - - // If we are in the midst of a transition, queue the current request. - // We'll call changePage() once we're done with the current transition - // to service the request. - if ( isPageTransitioning ) { - // make sure to only queue the to and settings values so the arguments - // work with a call to the change method - pageTransitionQueue.unshift( [toPage, settings] ); - return; - } - - // DEPRECATED - this call only, in favor of the before transition - // if the page beforechange default is prevented return early - if ( !this._triggerPageBeforeChange(toPage, triggerData, settings) ) { - return; - } - - triggerData.prevPage = settings.fromPage; - // if the (content|page)beforetransition default is prevented return early - // Note, we have to check for both the deprecated and new events - beforeTransition = this._triggerWithDeprecated( "beforetransition", triggerData ); - if (beforeTransition.deprecatedEvent.isDefaultPrevented() || - beforeTransition.event.isDefaultPrevented() ) { - return; - } - - // Set the isPageTransitioning flag to prevent any requests from - // entering this method while we are in the midst of loading a page - // or transitioning. - isPageTransitioning = true; - - // If we are going to the first-page of the application, we need to make - // sure settings.dataUrl is set to the application document url. This allows - // us to avoid generating a document url with an id hash in the case where the - // first-page of the document has an id attribute specified. - if ( toPage[ 0 ] === $.mobile.firstPage[ 0 ] && !settings.dataUrl ) { - settings.dataUrl = $.mobile.path.documentUrl.hrefNoHash; - } - - // The caller passed us a real page DOM element. Update our - // internal state and then trigger a transition to the page. - fromPage = settings.fromPage; - url = ( settings.dataUrl && $.mobile.path.convertUrlToDataUrl(settings.dataUrl) ) || - toPage.jqmData( "url" ); - - // The pageUrl var is usually the same as url, except when url is obscured - // as a dialog url. pageUrl always contains the file path - pageUrl = url; - fileUrl = $.mobile.path.getFilePath( url ); - active = $.mobile.navigate.history.getActive(); - activeIsInitialPage = $.mobile.navigate.history.activeIndex === 0; - historyDir = 0; - pageTitle = document.title; - isDialog = ( settings.role === "dialog" || - toPage.jqmData( "role" ) === "dialog" ) && - toPage.jqmData( "dialog" ) !== true; - - // By default, we prevent changePage requests when the fromPage and toPage - // are the same element, but folks that generate content - // manually/dynamically and reuse pages want to be able to transition to - // the same page. To allow this, they will need to change the default - // value of allowSamePageTransition to true, *OR*, pass it in as an - // option when they manually call changePage(). It should be noted that - // our default transition animations assume that the formPage and toPage - // are different elements, so they may behave unexpectedly. It is up to - // the developer that turns on the allowSamePageTransitiona option to - // either turn off transition animations, or make sure that an appropriate - // animation transition is used. - if ( fromPage && fromPage[0] === toPage[0] && - !settings.allowSamePageTransition ) { - - isPageTransitioning = false; - this._triggerWithDeprecated( "transition", triggerData ); - this._triggerWithDeprecated( "change", triggerData ); - - // Even if there is no page change to be done, we should keep the - // urlHistory in sync with the hash changes - if ( settings.fromHashChange ) { - $.mobile.navigate.history.direct({ url: url }); - } - - return; - } - - // We need to make sure the page we are given has already been enhanced. - toPage.page({ role: settings.role }); - - // If the changePage request was sent from a hashChange event, check to - // see if the page is already within the urlHistory stack. If so, we'll - // assume the user hit the forward/back button and will try to match the - // transition accordingly. - if ( settings.fromHashChange ) { - historyDir = settings.direction === "back" ? -1 : 1; - } - - // Kill the keyboard. - // XXX_jblas: We need to stop crawling the entire document to kill focus. - // Instead, we should be tracking focus with a delegate() - // handler so we already have the element in hand at this - // point. - // Wrap this in a try/catch block since IE9 throw "Unspecified error" if - // document.activeElement is undefined when we are in an IFrame. - try { - if ( document.activeElement && - document.activeElement.nodeName.toLowerCase() !== "body" ) { - - $( document.activeElement ).blur(); - } else { - $( "input:focus, textarea:focus, select:focus" ).blur(); - } - } catch( e ) {} - - // Record whether we are at a place in history where a dialog used to be - - // if so, do not add a new history entry and do not change the hash either - alreadyThere = false; - - // If we're displaying the page as a dialog, we don't want the url - // for the dialog content to be used in the hash. Instead, we want - // to append the dialogHashKey to the url of the current page. - if ( isDialog && active ) { - // on the initial page load active.url is undefined and in that case - // should be an empty string. Moving the undefined -> empty string back - // into urlHistory.addNew seemed imprudent given undefined better - // represents the url state - - // If we are at a place in history that once belonged to a dialog, reuse - // this state without adding to urlHistory and without modifying the - // hash. However, if a dialog is already displayed at this point, and - // we're about to display another dialog, then we must add another hash - // and history entry on top so that one may navigate back to the - // original dialog - if ( active.url && - active.url.indexOf( $.mobile.dialogHashKey ) > -1 && - this.activePage && - !this.activePage.hasClass( "ui-dialog" ) && - $.mobile.navigate.history.activeIndex > 0 ) { - - settings.changeHash = false; - alreadyThere = true; - } - - // Normally, we tack on a dialog hash key, but if this is the location - // of a stale dialog, we reuse the URL from the entry - url = ( active.url || "" ); - - // account for absolute urls instead of just relative urls use as hashes - if ( !alreadyThere && url.indexOf("#") > -1 ) { - url += $.mobile.dialogHashKey; - } else { - url += "#" + $.mobile.dialogHashKey; - } - } - - // if title element wasn't found, try the page div data attr too - // If this is a deep-link or a reload ( active === undefined ) then just - // use pageTitle - newPageTitle = ( !active ) ? pageTitle : toPage.jqmData( "title" ) || - toPage.children( ":jqmData(role='header')" ).find( ".ui-title" ).text(); - if ( !!newPageTitle && pageTitle === document.title ) { - pageTitle = newPageTitle; - } - if ( !toPage.jqmData( "title" ) ) { - toPage.jqmData( "title", pageTitle ); - } - - // Make sure we have a transition defined. - settings.transition = settings.transition || - ( ( historyDir && !activeIsInitialPage ) ? active.transition : undefined ) || - ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition ); - - //add page to history stack if it's not back or forward - if ( !historyDir && alreadyThere ) { - $.mobile.navigate.history.getActive().pageUrl = pageUrl; - } - - // Set the location hash. - if ( url && !settings.fromHashChange ) { - - // rebuilding the hash here since we loose it earlier on - // TODO preserve the originally passed in path - if ( !$.mobile.path.isPath( url ) && url.indexOf( "#" ) < 0 ) { - url = "#" + url; - } - - // TODO the property names here are just silly - params = { - transition: settings.transition, - title: pageTitle, - pageUrl: pageUrl, - role: settings.role - }; - - if ( settings.changeHash !== false && $.mobile.hashListeningEnabled ) { - $.mobile.navigate( this.window[ 0 ].encodeURI( url ), params, true); - } else if ( toPage[ 0 ] !== $.mobile.firstPage[ 0 ] ) { - $.mobile.navigate.history.add( url, params ); - } - } - - //set page title - document.title = pageTitle; - - //set "toPage" as activePage deprecated in 1.4 remove in 1.5 - $.mobile.activePage = toPage; - - //new way to handle activePage - this.activePage = toPage; - - // If we're navigating back in the URL history, set reverse accordingly. - settings.reverse = settings.reverse || historyDir < 0; - - cssTransitionDeferred = $.Deferred(); - - this._cssTransition(toPage, fromPage, { - transition: settings.transition, - reverse: settings.reverse, - deferred: cssTransitionDeferred - }); - - cssTransitionDeferred.done($.proxy(function( name, reverse, $to, $from, alreadyFocused ) { - $.mobile.removeActiveLinkClass(); - - //if there's a duplicateCachedPage, remove it from the DOM now that it's hidden - if ( settings.duplicateCachedPage ) { - settings.duplicateCachedPage.remove(); - } - - // despite visibility: hidden addresses issue #2965 - // https://github.com/jquery/jquery-mobile/issues/2965 - if ( !alreadyFocused ) { - $.mobile.focusPage( toPage ); - } - - this._releaseTransitionLock(); - this._triggerWithDeprecated( "transition", triggerData ); - this._triggerWithDeprecated( "change", triggerData ); - }, this)); - }, - - // determine the current base url - _findBaseWithDefault: function() { - var closestBase = ( this.activePage && - $.mobile.getClosestBaseUrl( this.activePage ) ); - return closestBase || $.mobile.path.documentBase.hrefNoHash; - } - }); - - // The following handlers should be bound after mobileinit has been triggered - // the following deferred is resolved in the init file - $.mobile.navreadyDeferred = $.Deferred(); - - //these variables make all page containers use the same queue and only navigate one at a time - // queue to hold simultanious page transitions - var pageTransitionQueue = [], - - // indicates whether or not page is in process of transitioning - isPageTransitioning = false; - -})( jQuery ); - -(function( $, undefined ) { - - // resolved on domready - var domreadyDeferred = $.Deferred(), - - // resolved and nulled on window.load() - loadDeferred = $.Deferred(), - - // function that resolves the above deferred - pageIsFullyLoaded = function() { - - // Resolve and null the deferred - loadDeferred.resolve(); - loadDeferred = null; - }, - - documentUrl = $.mobile.path.documentUrl, - - // used to track last vclicked element to make sure its value is added to form data - $lastVClicked = null; - - /* Event Bindings - hashchange, submit, and click */ - function findClosestLink( ele ) { - while ( ele ) { - // Look for the closest element with a nodeName of "a". - // Note that we are checking if we have a valid nodeName - // before attempting to access it. This is because the - // node we get called with could have originated from within - // an embedded SVG document where some symbol instance elements - // don't have nodeName defined on them, or strings are of type - // SVGAnimatedString. - if ( ( typeof ele.nodeName === "string" ) && ele.nodeName.toLowerCase() === "a" ) { - break; - } - ele = ele.parentNode; - } - return ele; - } - - $.mobile.loadPage = function( url, opts ) { - var container; - - opts = opts || {}; - container = ( opts.pageContainer || $.mobile.pageContainer ); - - // create the deferred that will be supplied to loadPage callers - // and resolved by the content widget's load method - opts.deferred = $.Deferred(); - - // Preferring to allow exceptions for uninitialized opts.pageContainer - // widgets so we know if we need to force init here for users - container.pagecontainer( "load", url, opts ); - - // provide the deferred - return opts.deferred.promise(); - }; - - //define vars for interal use - - /* internal utility functions */ - - // NOTE Issue #4950 Android phonegap doesn't navigate back properly - // when a full page refresh has taken place. It appears that hashchange - // and replacestate history alterations work fine but we need to support - // both forms of history traversal in our code that uses backward history - // movement - $.mobile.back = function() { - var nav = window.navigator; - - // if the setting is on and the navigator object is - // available use the phonegap navigation capability - if ( this.phonegapNavigationEnabled && - nav && - nav.app && - nav.app.backHistory ) { - nav.app.backHistory(); - } else { - $.mobile.pageContainer.pagecontainer( "back" ); - } - }; - - // Direct focus to the page title, or otherwise first focusable element - $.mobile.focusPage = function ( page ) { - var autofocus = page.find( "[autofocus]" ), - pageTitle = page.find( ".ui-title:eq(0)" ); - - if ( autofocus.length ) { - autofocus.focus(); - return; - } - - if ( pageTitle.length ) { - pageTitle.focus(); - } else{ - page.focus(); - } - }; - - // No-op implementation of transition degradation - $.mobile._maybeDegradeTransition = $.mobile._maybeDegradeTransition || function( transition ) { - return transition; - }; - - // Exposed $.mobile methods - - $.mobile.changePage = function( to, options ) { - $.mobile.pageContainer.pagecontainer( "change", to, options ); - }; - - $.mobile.changePage.defaults = { - transition: undefined, - reverse: false, - changeHash: true, - fromHashChange: false, - role: undefined, // By default we rely on the role defined by the @data-role attribute. - duplicateCachedPage: undefined, - pageContainer: undefined, - showLoadMsg: true, //loading message shows by default when pages are being fetched during changePage - dataUrl: undefined, - fromPage: undefined, - allowSamePageTransition: false - }; - - $.mobile._registerInternalEvents = function() { - var getAjaxFormData = function( $form, calculateOnly ) { - var url, ret = true, formData, vclickedName, method; - if ( !$.mobile.ajaxEnabled || - // test that the form is, itself, ajax false - $form.is( ":jqmData(ajax='false')" ) || - // test that $.mobile.ignoreContentEnabled is set and - // the form or one of it's parents is ajax=false - !$form.jqmHijackable().length || - $form.attr( "target" ) ) { - return false; - } - - url = ( $lastVClicked && $lastVClicked.attr( "formaction" ) ) || - $form.attr( "action" ); - method = ( $form.attr( "method" ) || "get" ).toLowerCase(); - - // If no action is specified, browsers default to using the - // URL of the document containing the form. Since we dynamically - // pull in pages from external documents, the form should submit - // to the URL for the source document of the page containing - // the form. - if ( !url ) { - // Get the @data-url for the page containing the form. - url = $.mobile.getClosestBaseUrl( $form ); - - // NOTE: If the method is "get", we need to strip off the query string - // because it will get replaced with the new form data. See issue #5710. - if ( method === "get" ) { - url = $.mobile.path.parseUrl( url ).hrefNoSearch; - } - - if ( url === $.mobile.path.documentBase.hrefNoHash ) { - // The url we got back matches the document base, - // which means the page must be an internal/embedded page, - // so default to using the actual document url as a browser - // would. - url = documentUrl.hrefNoSearch; - } - } - - url = $.mobile.path.makeUrlAbsolute( url, $.mobile.getClosestBaseUrl( $form ) ); - - if ( ( $.mobile.path.isExternal( url ) && !$.mobile.path.isPermittedCrossDomainRequest( documentUrl, url ) ) ) { - return false; - } - - if ( !calculateOnly ) { - formData = $form.serializeArray(); - - if ( $lastVClicked && $lastVClicked[ 0 ].form === $form[ 0 ] ) { - vclickedName = $lastVClicked.attr( "name" ); - if ( vclickedName ) { - // Make sure the last clicked element is included in the form - $.each( formData, function( key, value ) { - if ( value.name === vclickedName ) { - // Unset vclickedName - we've found it in the serialized data already - vclickedName = ""; - return false; - } - }); - if ( vclickedName ) { - formData.push( { name: vclickedName, value: $lastVClicked.attr( "value" ) } ); - } - } - } - - ret = { - url: url, - options: { - type: method, - data: $.param( formData ), - transition: $form.jqmData( "transition" ), - reverse: $form.jqmData( "direction" ) === "reverse", - reloadPage: true - } - }; - } - - return ret; - }; - - //bind to form submit events, handle with Ajax - $.mobile.document.delegate( "form", "submit", function( event ) { - var formData; - - if ( !event.isDefaultPrevented() ) { - formData = getAjaxFormData( $( this ) ); - if ( formData ) { - $.mobile.changePage( formData.url, formData.options ); - event.preventDefault(); - } - } - }); - - //add active state on vclick - $.mobile.document.bind( "vclick", function( event ) { - var $btn, btnEls, target = event.target, needClosest = false; - // if this isn't a left click we don't care. Its important to note - // that when the virtual event is generated it will create the which attr - if ( event.which > 1 || !$.mobile.linkBindingEnabled ) { - return; - } - - // Record that this element was clicked, in case we need it for correct - // form submission during the "submit" handler above - $lastVClicked = $( target ); - - // Try to find a target element to which the active class will be applied - if ( $.data( target, "mobile-button" ) ) { - // If the form will not be submitted via AJAX, do not add active class - if ( !getAjaxFormData( $( target ).closest( "form" ), true ) ) { - return; - } - // We will apply the active state to this button widget - the parent - // of the input that was clicked will have the associated data - if ( target.parentNode ) { - target = target.parentNode; - } - } else { - target = findClosestLink( target ); - if ( !( target && $.mobile.path.parseUrl( target.getAttribute( "href" ) || "#" ).hash !== "#" ) ) { - return; - } - - // TODO teach $.mobile.hijackable to operate on raw dom elements so the - // link wrapping can be avoided - if ( !$( target ).jqmHijackable().length ) { - return; - } - } - - // Avoid calling .closest by using the data set during .buttonMarkup() - // List items have the button data in the parent of the element clicked - if ( !!~target.className.indexOf( "ui-link-inherit" ) ) { - if ( target.parentNode ) { - btnEls = $.data( target.parentNode, "buttonElements" ); - } - // Otherwise, look for the data on the target itself - } else { - btnEls = $.data( target, "buttonElements" ); - } - // If found, grab the button's outer element - if ( btnEls ) { - target = btnEls.outer; - } else { - needClosest = true; - } - - $btn = $( target ); - // If the outer element wasn't found by the our heuristics, use .closest() - if ( needClosest ) { - $btn = $btn.closest( ".ui-btn" ); - } - - if ( $btn.length > 0 && - !( $btn.hasClass( "ui-state-disabled" || - - // DEPRECATED as of 1.4.0 - remove after 1.4.0 release - // only ui-state-disabled should be present thereafter - $btn.hasClass( "ui-disabled" ) ) ) ) { - $.mobile.removeActiveLinkClass( true ); - $.mobile.activeClickedLink = $btn; - $.mobile.activeClickedLink.addClass( $.mobile.activeBtnClass ); - } - }); - - // click routing - direct to HTTP or Ajax, accordingly - $.mobile.document.bind( "click", function( event ) { - if ( !$.mobile.linkBindingEnabled || event.isDefaultPrevented() ) { - return; - } - - var link = findClosestLink( event.target ), - $link = $( link ), - - //remove active link class if external (then it won't be there if you come back) - httpCleanup = function() { - window.setTimeout(function() { $.mobile.removeActiveLinkClass( true ); }, 200 ); - }, - baseUrl, href, - useDefaultUrlHandling, isExternal, - transition, reverse, role; - - // If a button was clicked, clean up the active class added by vclick above - if ( $.mobile.activeClickedLink && - $.mobile.activeClickedLink[ 0 ] === event.target.parentNode ) { - httpCleanup(); - } - - // If there is no link associated with the click or its not a left - // click we want to ignore the click - // TODO teach $.mobile.hijackable to operate on raw dom elements so the link wrapping - // can be avoided - if ( !link || event.which > 1 || !$link.jqmHijackable().length ) { - return; - } - - //if there's a data-rel=back attr, go back in history - if ( $link.is( ":jqmData(rel='back')" ) ) { - $.mobile.back(); - return false; - } - - baseUrl = $.mobile.getClosestBaseUrl( $link ); - - //get href, if defined, otherwise default to empty hash - href = $.mobile.path.makeUrlAbsolute( $link.attr( "href" ) || "#", baseUrl ); - - //if ajax is disabled, exit early - if ( !$.mobile.ajaxEnabled && !$.mobile.path.isEmbeddedPage( href ) ) { - httpCleanup(); - //use default click handling - return; - } - - // XXX_jblas: Ideally links to application pages should be specified as - // an url to the application document with a hash that is either - // the site relative path or id to the page. But some of the - // internal code that dynamically generates sub-pages for nested - // lists and select dialogs, just write a hash in the link they - // create. This means the actual URL path is based on whatever - // the current value of the base tag is at the time this code - // is called. - if ( href.search( "#" ) !== -1 && - !( $.mobile.path.isExternal( href ) && $.mobile.path.isAbsoluteUrl( href ) ) ) { - - href = href.replace( /[^#]*#/, "" ); - if ( !href ) { - //link was an empty hash meant purely - //for interaction, so we ignore it. - event.preventDefault(); - return; - } else if ( $.mobile.path.isPath( href ) ) { - //we have apath so make it the href we want to load. - href = $.mobile.path.makeUrlAbsolute( href, baseUrl ); - } else { - //we have a simple id so use the documentUrl as its base. - href = $.mobile.path.makeUrlAbsolute( "#" + href, documentUrl.hrefNoHash ); - } - } - - // Should we handle this link, or let the browser deal with it? - useDefaultUrlHandling = $link.is( "[rel='external']" ) || $link.is( ":jqmData(ajax='false')" ) || $link.is( "[target]" ); - - // Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR - // requests if the document doing the request was loaded via the file:// protocol. - // This is usually to allow the application to "phone home" and fetch app specific - // data. We normally let the browser handle external/cross-domain urls, but if the - // allowCrossDomainPages option is true, we will allow cross-domain http/https - // requests to go through our page loading logic. - - //check for protocol or rel and its not an embedded page - //TODO overlap in logic from isExternal, rel=external check should be - // moved into more comprehensive isExternalLink - isExternal = useDefaultUrlHandling || ( $.mobile.path.isExternal( href ) && !$.mobile.path.isPermittedCrossDomainRequest( documentUrl, href ) ); - - if ( isExternal ) { - httpCleanup(); - //use default click handling - return; - } - - //use ajax - transition = $link.jqmData( "transition" ); - reverse = $link.jqmData( "direction" ) === "reverse" || - // deprecated - remove by 1.0 - $link.jqmData( "back" ); - - //this may need to be more specific as we use data-rel more - role = $link.attr( "data-" + $.mobile.ns + "rel" ) || undefined; - - $.mobile.changePage( href, { transition: transition, reverse: reverse, role: role, link: $link } ); - event.preventDefault(); - }); - - //prefetch pages when anchors with data-prefetch are encountered - $.mobile.document.delegate( ".ui-page", "pageshow.prefetch", function() { - var urls = []; - $( this ).find( "a:jqmData(prefetch)" ).each(function() { - var $link = $( this ), - url = $link.attr( "href" ); - - if ( url && $.inArray( url, urls ) === -1 ) { - urls.push( url ); - - $.mobile.loadPage( url, { role: $link.attr( "data-" + $.mobile.ns + "rel" ),prefetch: true } ); - } - }); - }); - - // TODO ensure that the navigate binding in the content widget happens at the right time - $.mobile.pageContainer.pagecontainer(); - - //set page min-heights to be device specific - $.mobile.document.bind( "pageshow", function() { - - // We need to wait for window.load to make sure that styles have already been rendered, - // otherwise heights of external toolbars will have the wrong value - if ( loadDeferred ) { - loadDeferred.done( $.mobile.resetActivePageHeight ); - } else { - $.mobile.resetActivePageHeight(); - } - }); - $.mobile.window.bind( "throttledresize", $.mobile.resetActivePageHeight ); - - };//navreadyDeferred done callback - - $( function() { domreadyDeferred.resolve(); } ); - - // Account for the possibility that the load event has already fired - if ( document.readyState === "complete" ) { - pageIsFullyLoaded(); - } else { - $.mobile.window.load( pageIsFullyLoaded ); - } - - $.when( domreadyDeferred, $.mobile.navreadyDeferred ).done( function() { $.mobile._registerInternalEvents(); } ); -})( jQuery ); - - -(function( $, window, undefined ) { - - // TODO remove direct references to $.mobile and properties, we should - // favor injection with params to the constructor - $.mobile.Transition = function() { - this.init.apply( this, arguments ); - }; - - $.extend($.mobile.Transition.prototype, { - toPreClass: " ui-page-pre-in", - - init: function( name, reverse, $to, $from ) { - $.extend(this, { - name: name, - reverse: reverse, - $to: $to, - $from: $from, - deferred: new $.Deferred() - }); - }, - - cleanFrom: function() { - this.$from - .removeClass( $.mobile.activePageClass + " out in reverse " + this.name ) - .height( "" ); - }, - - // NOTE overridden by child object prototypes, noop'd here as defaults - beforeDoneIn: function() {}, - beforeDoneOut: function() {}, - beforeStartOut: function() {}, - - doneIn: function() { - this.beforeDoneIn(); - - this.$to.removeClass( "out in reverse " + this.name ).height( "" ); - - this.toggleViewportClass(); - - // In some browsers (iOS5), 3D transitions block the ability to scroll to the desired location during transition - // This ensures we jump to that spot after the fact, if we aren't there already. - if ( $.mobile.window.scrollTop() !== this.toScroll ) { - this.scrollPage(); - } - if ( !this.sequential ) { - this.$to.addClass( $.mobile.activePageClass ); - } - this.deferred.resolve( this.name, this.reverse, this.$to, this.$from, true ); - }, - - doneOut: function( screenHeight, reverseClass, none, preventFocus ) { - this.beforeDoneOut(); - this.startIn( screenHeight, reverseClass, none, preventFocus ); - }, - - hideIn: function( callback ) { - // Prevent flickering in phonegap container: see comments at #4024 regarding iOS - this.$to.css( "z-index", -10 ); - callback.call( this ); - this.$to.css( "z-index", "" ); - }, - - scrollPage: function() { - // By using scrollTo instead of silentScroll, we can keep things better in order - // Just to be precautios, disable scrollstart listening like silentScroll would - $.event.special.scrollstart.enabled = false; - //if we are hiding the url bar or the page was previously scrolled scroll to hide or return to position - if ( $.mobile.hideUrlBar || this.toScroll !== $.mobile.defaultHomeScroll ) { - window.scrollTo( 0, this.toScroll ); - } - - // reenable scrollstart listening like silentScroll would - setTimeout( function() { - $.event.special.scrollstart.enabled = true; - }, 150 ); - }, - - startIn: function( screenHeight, reverseClass, none, preventFocus ) { - this.hideIn(function() { - this.$to.addClass( $.mobile.activePageClass + this.toPreClass ); - - // Send focus to page as it is now display: block - if ( !preventFocus ) { - $.mobile.focusPage( this.$to ); - } - - // Set to page height - this.$to.height( screenHeight + this.toScroll ); - - if ( !none ) { - this.scrollPage(); - } - }); - - this.$to - .removeClass( this.toPreClass ) - .addClass( this.name + " in " + reverseClass ); - - if ( !none ) { - this.$to.animationComplete( $.proxy(function() { - this.doneIn(); - }, this )); - } else { - this.doneIn(); - } - - }, - - startOut: function( screenHeight, reverseClass, none ) { - this.beforeStartOut( screenHeight, reverseClass, none ); - - // Set the from page's height and start it transitioning out - // Note: setting an explicit height helps eliminate tiling in the transitions - this.$from - .height( screenHeight + $.mobile.window.scrollTop() ) - .addClass( this.name + " out" + reverseClass ); - }, - - toggleViewportClass: function() { - $.mobile.pageContainer.toggleClass( "ui-mobile-viewport-transitioning viewport-" + this.name ); - }, - - transition: function() { - // NOTE many of these could be calculated/recorded in the constructor, it's my - // opinion that binding them as late as possible has value with regards to - // better transitions with fewer bugs. Ie, it's not guaranteed that the - // object will be created and transition will be run immediately after as - // it is today. So we wait until transition is invoked to gather the following - var none, - reverseClass = this.reverse ? " reverse" : "", - screenHeight = $.mobile.getScreenHeight(), - maxTransitionOverride = $.mobile.maxTransitionWidth !== false && - $.mobile.window.width() > $.mobile.maxTransitionWidth; - - this.toScroll = $.mobile.navigate.history.getActive().lastScroll || $.mobile.defaultHomeScroll; - - none = !$.support.cssTransitions || !$.support.cssAnimations || - maxTransitionOverride || !this.name || this.name === "none" || - Math.max( $.mobile.window.scrollTop(), this.toScroll ) > - $.mobile.getMaxScrollForTransition(); - - this.toggleViewportClass(); - - if ( this.$from && !none ) { - this.startOut( screenHeight, reverseClass, none ); - } else { - this.doneOut( screenHeight, reverseClass, none, true ); - } - - return this.deferred.promise(); - } - }); -})( jQuery, this ); - - -(function( $ ) { - - $.mobile.SerialTransition = function() { - this.init.apply(this, arguments); - }; - - $.extend($.mobile.SerialTransition.prototype, $.mobile.Transition.prototype, { - sequential: true, - - beforeDoneOut: function() { - if ( this.$from ) { - this.cleanFrom(); - } - }, - - beforeStartOut: function( screenHeight, reverseClass, none ) { - this.$from.animationComplete($.proxy(function() { - this.doneOut( screenHeight, reverseClass, none ); - }, this )); - } - }); - -})( jQuery ); - - -(function( $ ) { - - $.mobile.ConcurrentTransition = function() { - this.init.apply(this, arguments); - }; - - $.extend($.mobile.ConcurrentTransition.prototype, $.mobile.Transition.prototype, { - sequential: false, - - beforeDoneIn: function() { - if ( this.$from ) { - this.cleanFrom(); - } - }, - - beforeStartOut: function( screenHeight, reverseClass, none ) { - this.doneOut( screenHeight, reverseClass, none ); - } - }); - -})( jQuery ); - - -(function( $ ) { - - // generate the handlers from the above - var defaultGetMaxScrollForTransition = function() { - return $.mobile.getScreenHeight() * 3; - }; - - //transition handler dictionary for 3rd party transitions - $.mobile.transitionHandlers = { - "sequential": $.mobile.SerialTransition, - "simultaneous": $.mobile.ConcurrentTransition - }; - - // Make our transition handler the public default. - $.mobile.defaultTransitionHandler = $.mobile.transitionHandlers.sequential; - - $.mobile.transitionFallbacks = {}; - - // If transition is defined, check if css 3D transforms are supported, and if not, if a fallback is specified - $.mobile._maybeDegradeTransition = function( transition ) { - if ( transition && !$.support.cssTransform3d && $.mobile.transitionFallbacks[ transition ] ) { - transition = $.mobile.transitionFallbacks[ transition ]; - } - - return transition; - }; - - // Set the getMaxScrollForTransition to default if no implementation was set by user - $.mobile.getMaxScrollForTransition = $.mobile.getMaxScrollForTransition || defaultGetMaxScrollForTransition; - -})( jQuery ); - -/* -* fallback transition for flip in non-3D supporting browsers (which tend to handle complex transitions poorly in general -*/ - -(function( $, window, undefined ) { - -$.mobile.transitionFallbacks.flip = "fade"; - -})( jQuery, this ); - -/* -* fallback transition for flow in non-3D supporting browsers (which tend to handle complex transitions poorly in general -*/ - -(function( $, window, undefined ) { - -$.mobile.transitionFallbacks.flow = "fade"; - -})( jQuery, this ); - -/* -* fallback transition for pop in non-3D supporting browsers (which tend to handle complex transitions poorly in general -*/ - -(function( $, window, undefined ) { - -$.mobile.transitionFallbacks.pop = "fade"; - -})( jQuery, this ); - -/* -* fallback transition for slide in non-3D supporting browsers (which tend to handle complex transitions poorly in general -*/ - -(function( $, window, undefined ) { - -// Use the simultaneous transitions handler for slide transitions -$.mobile.transitionHandlers.slide = $.mobile.transitionHandlers.simultaneous; - -// Set the slide transitions's fallback to "fade" -$.mobile.transitionFallbacks.slide = "fade"; - -})( jQuery, this ); - -/* -* fallback transition for slidedown in non-3D supporting browsers (which tend to handle complex transitions poorly in general -*/ - -(function( $, window, undefined ) { - -$.mobile.transitionFallbacks.slidedown = "fade"; - -})( jQuery, this ); - -/* -* fallback transition for slidefade in non-3D supporting browsers (which tend to handle complex transitions poorly in general -*/ - -(function( $, window, undefined ) { - -// Set the slide transitions's fallback to "fade" -$.mobile.transitionFallbacks.slidefade = "fade"; - -})( jQuery, this ); - -/* -* fallback transition for slideup in non-3D supporting browsers (which tend to handle complex transitions poorly in general -*/ - -(function( $, window, undefined ) { - -$.mobile.transitionFallbacks.slideup = "fade"; - -})( jQuery, this ); - -/* -* fallback transition for turn in non-3D supporting browsers (which tend to handle complex transitions poorly in general -*/ - -(function( $, window, undefined ) { - -$.mobile.transitionFallbacks.turn = "fade"; - -})( jQuery, this ); - - -(function( $, undefined ) { - -$.mobile.degradeInputs = { - color: false, - date: false, - datetime: false, - "datetime-local": false, - email: false, - month: false, - number: false, - range: "number", - search: "text", - tel: false, - time: false, - url: false, - week: false -}; -// Backcompat remove in 1.5 -$.mobile.page.prototype.options.degradeInputs = $.mobile.degradeInputs; - -// Auto self-init widgets -$.mobile.degradeInputsWithin = function( target ) { - - target = $( target ); - - // Degrade inputs to avoid poorly implemented native functionality - target.find( "input" ).not( $.mobile.page.prototype.keepNativeSelector() ).each(function() { - var element = $( this ), - type = this.getAttribute( "type" ), - optType = $.mobile.degradeInputs[ type ] || "text", - html, hasType, findstr, repstr; - - if ( $.mobile.degradeInputs[ type ] ) { - html = $( "
" ).html( element.clone() ).html(); - // In IE browsers, the type sometimes doesn't exist in the cloned markup, so we replace the closing tag instead - hasType = html.indexOf( " type=" ) > -1; - findstr = hasType ? /\s+type=["']?\w+['"]?/ : /\/?>/; - repstr = " type=\"" + optType + "\" data-" + $.mobile.ns + "type=\"" + type + "\"" + ( hasType ? "" : ">" ); - - element.replaceWith( html.replace( findstr, repstr ) ); - } - }); - -}; - -})( jQuery ); - -(function( $, window, undefined ) { - -$.widget( "mobile.page", $.mobile.page, { - options: { - - // Accepts left, right and none - closeBtn: "left", - closeBtnText: "Close", - overlayTheme: "a", - corners: true, - dialog: false - }, - - _create: function() { - this._super(); - if ( this.options.dialog ) { - - $.extend( this, { - _inner: this.element.children(), - _headerCloseButton: null - }); - - if ( !this.options.enhanced ) { - this._setCloseBtn( this.options.closeBtn ); - } - } - }, - - _enhance: function() { - this._super(); - - // Class the markup for dialog styling and wrap interior - if ( this.options.dialog ) { - this.element.addClass( "ui-dialog" ) - .wrapInner( $( "
", { - - // ARIA role - "role" : "dialog", - "class" : "ui-dialog-contain ui-overlay-shadow" + - ( this.options.corners ? " ui-corner-all" : "" ) - })); - } - }, - - _setOptions: function( options ) { - var closeButtonLocation, closeButtonText, - currentOpts = this.options; - - if ( options.corners !== undefined ) { - this._inner.toggleClass( "ui-corner-all", !!options.corners ); - } - - if ( options.overlayTheme !== undefined ) { - if ( $.mobile.activePage[ 0 ] === this.element[ 0 ] ) { - currentOpts.overlayTheme = options.overlayTheme; - this._handlePageBeforeShow(); - } - } - - if ( options.closeBtnText !== undefined ) { - closeButtonLocation = currentOpts.closeBtn; - closeButtonText = options.closeBtnText; - } - - if ( options.closeBtn !== undefined ) { - closeButtonLocation = options.closeBtn; - } - - if ( closeButtonLocation ) { - this._setCloseBtn( closeButtonLocation, closeButtonText ); - } - - this._super( options ); - }, - - _handlePageBeforeShow: function () { - if ( this.options.overlayTheme && this.options.dialog ) { - this.removeContainerBackground(); - this.setContainerBackground( this.options.overlayTheme ); - } else { - this._super(); - } - }, - - _setCloseBtn: function( location, text ) { - var dst, - btn = this._headerCloseButton; - - // Sanitize value - location = "left" === location ? "left" : "right" === location ? "right" : "none"; - - if ( "none" === location ) { - if ( btn ) { - btn.remove(); - btn = null; - } - } else if ( btn ) { - btn.removeClass( "ui-btn-left ui-btn-right" ).addClass( "ui-btn-" + location ); - if ( text ) { - btn.text( text ); - } - } else { - dst = this._inner.find( ":jqmData(role='header')" ).first(); - btn = $( "", { - "href": "#", - "class": "ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-" + location - }) - .attr( "data-" + $.mobile.ns + "rel", "back" ) - .text( text || this.options.closeBtnText || "" ) - .prependTo( dst ); - } - - this._headerCloseButton = btn; - } -}); - -})( jQuery, this ); - -(function( $, window, undefined ) { - -$.widget( "mobile.dialog", { - options: { - - // Accepts left, right and none - closeBtn: "left", - closeBtnText: "Close", - overlayTheme: "a", - corners: true - }, - - // Override the theme set by the page plugin on pageshow - _handlePageBeforeShow: function() { - this._isCloseable = true; - if ( this.options.overlayTheme ) { - this.element - .page( "removeContainerBackground" ) - .page( "setContainerBackground", this.options.overlayTheme ); - } - }, - - _handlePageBeforeHide: function() { - this._isCloseable = false; - }, - - // click and submit events: - // - clicks and submits should use the closing transition that the dialog - // opened with unless a data-transition is specified on the link/form - // - if the click was on the close button, or the link has a data-rel="back" - // it'll go back in history naturally - _handleVClickSubmit: function( event ) { - var attrs, - $target = $( event.target ).closest( event.type === "vclick" ? "a" : "form" ); - - if ( $target.length && !$target.jqmData( "transition" ) ) { - attrs = {}; - attrs[ "data-" + $.mobile.ns + "transition" ] = - ( $.mobile.navigate.history.getActive() || {} )[ "transition" ] || - $.mobile.defaultDialogTransition; - attrs[ "data-" + $.mobile.ns + "direction" ] = "reverse"; - $target.attr( attrs ); - } - }, - - _create: function() { - var elem = this.element, - opts = this.options; - - // Class the markup for dialog styling and wrap interior - elem.addClass( "ui-dialog" ) - .wrapInner( $( "
", { - - // ARIA role - "role" : "dialog", - "class" : "ui-dialog-contain ui-overlay-shadow" + - ( !!opts.corners ? " ui-corner-all" : "" ) - })); - - $.extend( this, { - _isCloseable: false, - _inner: elem.children(), - _headerCloseButton: null - }); - - this._on( elem, { - vclick: "_handleVClickSubmit", - submit: "_handleVClickSubmit", - pagebeforeshow: "_handlePageBeforeShow", - pagebeforehide: "_handlePageBeforeHide" - }); - - this._setCloseBtn( opts.closeBtn ); - }, - - _setOptions: function( options ) { - var closeButtonLocation, closeButtonText, - currentOpts = this.options; - - if ( options.corners !== undefined ) { - this._inner.toggleClass( "ui-corner-all", !!options.corners ); - } - - if ( options.overlayTheme !== undefined ) { - if ( $.mobile.activePage[ 0 ] === this.element[ 0 ] ) { - currentOpts.overlayTheme = options.overlayTheme; - this._handlePageBeforeShow(); - } - } - - if ( options.closeBtnText !== undefined ) { - closeButtonLocation = currentOpts.closeBtn; - closeButtonText = options.closeBtnText; - } - - if ( options.closeBtn !== undefined ) { - closeButtonLocation = options.closeBtn; - } - - if ( closeButtonLocation ) { - this._setCloseBtn( closeButtonLocation, closeButtonText ); - } - - this._super( options ); - }, - - _setCloseBtn: function( location, text ) { - var dst, - btn = this._headerCloseButton; - - // Sanitize value - location = "left" === location ? "left" : "right" === location ? "right" : "none"; - - if ( "none" === location ) { - if ( btn ) { - btn.remove(); - btn = null; - } - } else if ( btn ) { - btn.removeClass( "ui-btn-left ui-btn-right" ).addClass( "ui-btn-" + location ); - if ( text ) { - btn.text( text ); - } - } else { - dst = this._inner.find( ":jqmData(role='header')" ).first(); - btn = $( "", { - "role": "button", - "href": "#", - "class": "ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-" + location - }) - .text( text || this.options.closeBtnText || "" ) - .prependTo( dst ); - this._on( btn, { click: "close" } ); - } - - this._headerCloseButton = btn; - }, - - // Close method goes back in history - close: function() { - var hist = $.mobile.navigate.history; - - if ( this._isCloseable ) { - this._isCloseable = false; - // If the hash listening is enabled and there is at least one preceding history - // entry it's ok to go back. Initial pages with the dialog hash state are an example - // where the stack check is necessary - if ( $.mobile.hashListeningEnabled && hist.activeIndex > 0 ) { - $.mobile.back(); - } else { - $.mobile.pageContainer.pagecontainer( "back" ); - } - } - } -}); - -})( jQuery, this ); - -(function( $, undefined ) { - -var rInitialLetter = /([A-Z])/g, - - // Construct iconpos class from iconpos value - iconposClass = function( iconpos ) { - return ( "ui-btn-icon-" + ( iconpos === null ? "left" : iconpos ) ); - }; - -$.widget( "mobile.collapsible", { - options: { - enhanced: false, - expandCueText: null, - collapseCueText: null, - collapsed: true, - heading: "h1,h2,h3,h4,h5,h6,legend", - collapsedIcon: null, - expandedIcon: null, - iconpos: null, - theme: null, - contentTheme: null, - inset: null, - corners: null, - mini: null - }, - - _create: function() { - var elem = this.element, - ui = { - accordion: elem - .closest( ":jqmData(role='collapsible-set')," + - ":jqmData(role='collapsibleset')" + - ( $.mobile.collapsibleset ? ", :mobile-collapsibleset" : - "" ) ) - .addClass( "ui-collapsible-set" ) - }; - - this._ui = ui; - this._renderedOptions = this._getOptions( this.options ); - - if ( this.options.enhanced ) { - ui.heading = this.element.children( ".ui-collapsible-heading" ); - ui.content = ui.heading.next(); - ui.anchor = ui.heading.children(); - ui.status = ui.anchor.children( ".ui-collapsible-heading-status" ); - } else { - this._enhance( elem, ui ); - } - - this._on( ui.heading, { - "tap": function() { - ui.heading.find( "a" ).first().addClass( $.mobile.activeBtnClass ); - }, - - "click": function( event ) { - this._handleExpandCollapse( !ui.heading.hasClass( "ui-collapsible-heading-collapsed" ) ); - event.preventDefault(); - event.stopPropagation(); - } - }); - }, - - // Adjust the keys inside options for inherited values - _getOptions: function( options ) { - var key, - accordion = this._ui.accordion, - accordionWidget = this._ui.accordionWidget; - - // Copy options - options = $.extend( {}, options ); - - if ( accordion.length && !accordionWidget ) { - this._ui.accordionWidget = - accordionWidget = accordion.data( "mobile-collapsibleset" ); - } - - for ( key in options ) { - - // Retrieve the option value first from the options object passed in and, if - // null, from the parent accordion or, if that's null too, or if there's no - // parent accordion, then from the defaults. - options[ key ] = - ( options[ key ] != null ) ? options[ key ] : - ( accordionWidget ) ? accordionWidget.options[ key ] : - accordion.length ? $.mobile.getAttribute( accordion[ 0 ], - key.replace( rInitialLetter, "-$1" ).toLowerCase() ): - null; - - if ( null == options[ key ] ) { - options[ key ] = $.mobile.collapsible.defaults[ key ]; - } - } - - return options; - }, - - _themeClassFromOption: function( prefix, value ) { - return ( value ? ( value === "none" ? "" : prefix + value ) : "" ); - }, - - _enhance: function( elem, ui ) { - var iconclass, - opts = this._renderedOptions, - contentThemeClass = this._themeClassFromOption( "ui-body-", opts.contentTheme ); - - elem.addClass( "ui-collapsible " + - ( opts.inset ? "ui-collapsible-inset " : "" ) + - ( opts.inset && opts.corners ? "ui-corner-all " : "" ) + - ( contentThemeClass ? "ui-collapsible-themed-content " : "" ) ); - ui.originalHeading = elem.children( this.options.heading ).first(), - ui.content = elem - .wrapInner( "
" ) - .children( ".ui-collapsible-content" ), - ui.heading = ui.originalHeading; - - // Replace collapsibleHeading if it's a legend - if ( ui.heading.is( "legend" ) ) { - ui.heading = $( "
"+ ui.heading.html() +"
" ); - ui.placeholder = $( "
" ).insertBefore( ui.originalHeading ); - ui.originalHeading.remove(); - } - - iconclass = ( opts.collapsed ? ( opts.collapsedIcon ? "ui-icon-" + opts.collapsedIcon : "" ): - ( opts.expandedIcon ? "ui-icon-" + opts.expandedIcon : "" ) ); - - ui.status = $( "" ); - ui.anchor = ui.heading - .detach() - //modify markup & attributes - .addClass( "ui-collapsible-heading" ) - .append( ui.status ) - .wrapInner( "" ) - .find( "a" ) - .first() - .addClass( "ui-btn " + - ( iconclass ? iconclass + " " : "" ) + - ( iconclass ? iconposClass( opts.iconpos ) + - " " : "" ) + - this._themeClassFromOption( "ui-btn-", opts.theme ) + " " + - ( opts.mini ? "ui-mini " : "" ) ); - - //drop heading in before content - ui.heading.insertBefore( ui.content ); - - this._handleExpandCollapse( this.options.collapsed ); - - return ui; - }, - - refresh: function() { - this._applyOptions( this.options ); - this._renderedOptions = this._getOptions( this.options ); - }, - - _applyOptions: function( options ) { - var isCollapsed, newTheme, oldTheme, hasCorners, hasIcon, - elem = this.element, - currentOpts = this._renderedOptions, - ui = this._ui, - anchor = ui.anchor, - status = ui.status, - opts = this._getOptions( options ); - - // First and foremost we need to make sure the collapsible is in the proper - // state, in case somebody decided to change the collapsed option at the - // same time as another option - if ( options.collapsed !== undefined ) { - this._handleExpandCollapse( options.collapsed ); - } - - isCollapsed = elem.hasClass( "ui-collapsible-collapsed" ); - - // We only need to apply the cue text for the current state right away. - // The cue text for the alternate state will be stored in the options - // and applied the next time the collapsible's state is toggled - if ( isCollapsed ) { - if ( opts.expandCueText !== undefined ) { - status.text( opts.expandCueText ); - } - } else { - if ( opts.collapseCueText !== undefined ) { - status.text( opts.collapseCueText ); - } - } - - // Update icon - - // Is it supposed to have an icon? - hasIcon = - - // If the collapsedIcon is being set, consult that - ( opts.collapsedIcon !== undefined ? opts.collapsedIcon !== false : - - // Otherwise consult the existing option value - currentOpts.collapsedIcon !== false ); - - - // If any icon-related options have changed, make sure the new icon - // state is reflected by first removing all icon-related classes - // reflecting the current state and then adding all icon-related - // classes for the new state - if ( !( opts.iconpos === undefined && - opts.collapsedIcon === undefined && - opts.expandedIcon === undefined ) ) { - - // Remove all current icon-related classes - anchor.removeClass( [ iconposClass( currentOpts.iconpos ) ] - .concat( ( currentOpts.expandedIcon ? - [ "ui-icon-" + currentOpts.expandedIcon ] : [] ) ) - .concat( ( currentOpts.collapsedIcon ? - [ "ui-icon-" + currentOpts.collapsedIcon ] : [] ) ) - .join( " " ) ); - - // Add new classes if an icon is supposed to be present - if ( hasIcon ) { - anchor.addClass( - [ iconposClass( opts.iconpos !== undefined ? - opts.iconpos : currentOpts.iconpos ) ] - .concat( isCollapsed ? - [ "ui-icon-" + ( opts.collapsedIcon !== undefined ? - opts.collapsedIcon : - currentOpts.collapsedIcon ) ] : - [ "ui-icon-" + ( opts.expandedIcon !== undefined ? - opts.expandedIcon : - currentOpts.expandedIcon ) ] ) - .join( " " ) ); - } - } - - if ( opts.theme !== undefined ) { - oldTheme = this._themeClassFromOption( "ui-btn-", currentOpts.theme ); - newTheme = this._themeClassFromOption( "ui-btn-", opts.theme ); - anchor.removeClass( oldTheme ).addClass( newTheme ); - } - - if ( opts.contentTheme !== undefined ) { - oldTheme = this._themeClassFromOption( "ui-body-", - currentOpts.contentTheme ); - newTheme = this._themeClassFromOption( "ui-body-", - opts.contentTheme ); - ui.content.removeClass( oldTheme ).addClass( newTheme ); - } - - if ( opts.inset !== undefined ) { - elem.toggleClass( "ui-collapsible-inset", opts.inset ); - hasCorners = !!( opts.inset && ( opts.corners || currentOpts.corners ) ); - } - - if ( opts.corners !== undefined ) { - hasCorners = !!( opts.corners && ( opts.inset || currentOpts.inset ) ); - } - - if ( hasCorners !== undefined ) { - elem.toggleClass( "ui-corner-all", hasCorners ); - } - - if ( opts.mini !== undefined ) { - anchor.toggleClass( "ui-mini", opts.mini ); - } - }, - - _setOptions: function( options ) { - this._applyOptions( options ); - this._super( options ); - this._renderedOptions = this._getOptions( this.options ); - }, - - _handleExpandCollapse: function( isCollapse ) { - var opts = this._renderedOptions, - ui = this._ui; - - ui.status.text( isCollapse ? opts.expandCueText : opts.collapseCueText ); - ui.heading - .toggleClass( "ui-collapsible-heading-collapsed", isCollapse ) - .find( "a" ).first() - .toggleClass( "ui-icon-" + opts.expandedIcon, !isCollapse ) - - // logic or cause same icon for expanded/collapsed state would remove the ui-icon-class - .toggleClass( "ui-icon-" + opts.collapsedIcon, ( isCollapse || opts.expandedIcon === opts.collapsedIcon ) ) - .removeClass( $.mobile.activeBtnClass ); - - this.element.toggleClass( "ui-collapsible-collapsed", isCollapse ); - ui.content - .toggleClass( "ui-collapsible-content-collapsed", isCollapse ) - .attr( "aria-hidden", isCollapse ) - .trigger( "updatelayout" ); - this.options.collapsed = isCollapse; - this._trigger( isCollapse ? "collapse" : "expand" ); - }, - - expand: function() { - this._handleExpandCollapse( false ); - }, - - collapse: function() { - this._handleExpandCollapse( true ); - }, - - _destroy: function() { - var ui = this._ui, - opts = this.options; - - if ( opts.enhanced ) { - return; - } - - if ( ui.placeholder ) { - ui.originalHeading.insertBefore( ui.placeholder ); - ui.placeholder.remove(); - ui.heading.remove(); - } else { - ui.status.remove(); - ui.heading - .removeClass( "ui-collapsible-heading ui-collapsible-heading-collapsed" ) - .children() - .contents() - .unwrap(); - } - - ui.anchor.contents().unwrap(); - ui.content.contents().unwrap(); - this.element - .removeClass( "ui-collapsible ui-collapsible-collapsed " + - "ui-collapsible-themed-content ui-collapsible-inset ui-corner-all" ); - } -}); - -// Defaults to be used by all instances of collapsible if per-instance values -// are unset or if nothing is specified by way of inheritance from an accordion. -// Note that this hash does not contain options "collapsed" or "heading", -// because those are not inheritable. -$.mobile.collapsible.defaults = { - expandCueText: " click to expand contents", - collapseCueText: " click to collapse contents", - collapsedIcon: "plus", - contentTheme: "inherit", - expandedIcon: "minus", - iconpos: "left", - inset: true, - corners: true, - theme: "inherit", - mini: false -}; - -})( jQuery ); - -(function( $, undefined ) { - -var uiScreenHiddenRegex = /\bui-screen-hidden\b/; -function noHiddenClass( elements ) { - var index, - length = elements.length, - result = []; - - for ( index = 0; index < length; index++ ) { - if ( !elements[ index ].className.match( uiScreenHiddenRegex ) ) { - result.push( elements[ index ] ); - } - } - - return $( result ); -} - -$.mobile.behaviors.addFirstLastClasses = { - _getVisibles: function( $els, create ) { - var visibles; - - if ( create ) { - visibles = noHiddenClass( $els ); - } else { - visibles = $els.filter( ":visible" ); - if ( visibles.length === 0 ) { - visibles = noHiddenClass( $els ); - } - } - - return visibles; - }, - - _addFirstLastClasses: function( $els, $visibles, create ) { - $els.removeClass( "ui-first-child ui-last-child" ); - $visibles.eq( 0 ).addClass( "ui-first-child" ).end().last().addClass( "ui-last-child" ); - if ( !create ) { - this.element.trigger( "updatelayout" ); - } - }, - - _removeFirstLastClasses: function( $els ) { - $els.removeClass( "ui-first-child ui-last-child" ); - } -}; - -})( jQuery ); - -(function( $, undefined ) { - -var childCollapsiblesSelector = ":mobile-collapsible, " + $.mobile.collapsible.initSelector; - -$.widget( "mobile.collapsibleset", $.extend( { - - // The initSelector is deprecated as of 1.4.0. In 1.5.0 we will use - // :jqmData(role='collapsibleset') which will allow us to get rid of the line - // below altogether, because the autoinit will generate such an initSelector - initSelector: ":jqmData(role='collapsible-set'),:jqmData(role='collapsibleset')", - - options: $.extend( { - enhanced: false - }, $.mobile.collapsible.defaults ), - - _handleCollapsibleExpand: function( event ) { - var closestCollapsible = $( event.target ).closest( ".ui-collapsible" ); - - if ( closestCollapsible.parent().is( ":mobile-collapsibleset, :jqmData(role='collapsible-set')" ) ) { - closestCollapsible - .siblings( ".ui-collapsible:not(.ui-collapsible-collapsed)" ) - .collapsible( "collapse" ); - } - }, - - _create: function() { - var elem = this.element, - opts = this.options; - - $.extend( this, { - _classes: "" - }); - - if ( !opts.enhanced ) { - elem.addClass( "ui-collapsible-set " + - this._themeClassFromOption( "ui-group-theme-", opts.theme ) + " " + - ( opts.corners && opts.inset ? "ui-corner-all " : "" ) ); - this.element.find( $.mobile.collapsible.initSelector ).collapsible(); - } - - this._on( elem, { collapsibleexpand: "_handleCollapsibleExpand" } ); - }, - - _themeClassFromOption: function( prefix, value ) { - return ( value ? ( value === "none" ? "" : prefix + value ) : "" ); - }, - - _init: function() { - this._refresh( true ); - - // Because the corners are handled by the collapsible itself and the default state is collapsed - // That was causing https://github.com/jquery/jquery-mobile/issues/4116 - this.element - .children( childCollapsiblesSelector ) - .filter( ":jqmData(collapsed='false')" ) - .collapsible( "expand" ); - }, - - _setOptions: function( options ) { - var ret, hasCorners, - elem = this.element, - themeClass = this._themeClassFromOption( "ui-group-theme-", options.theme ); - - if ( themeClass ) { - elem - .removeClass( this._themeClassFromOption( "ui-group-theme-", this.options.theme ) ) - .addClass( themeClass ); - } - - if ( options.inset !== undefined ) { - hasCorners = !!( options.inset && ( options.corners || this.options.corners ) ); - } - - if ( options.corners !== undefined ) { - hasCorners = !!( options.corners && ( options.inset || this.options.inset ) ); - } - - if ( hasCorners !== undefined ) { - elem.toggleClass( "ui-corner-all", hasCorners ); - } - - ret = this._super( options ); - this.element.children( ":mobile-collapsible" ).collapsible( "refresh" ); - return ret; - }, - - _destroy: function() { - var el = this.element; - - this._removeFirstLastClasses( el.children( childCollapsiblesSelector ) ); - el - .removeClass( "ui-collapsible-set ui-corner-all " + - this._themeClassFromOption( "ui-group-theme-", this.options.theme ) ) - .children( ":mobile-collapsible" ) - .collapsible( "destroy" ); - }, - - _refresh: function( create ) { - var collapsiblesInSet = this.element.children( childCollapsiblesSelector ); - - this.element.find( $.mobile.collapsible.initSelector ).not( ".ui-collapsible" ).collapsible(); - - this._addFirstLastClasses( collapsiblesInSet, this._getVisibles( collapsiblesInSet, create ), create ); - }, - - refresh: function() { - this._refresh( false ); - } -}, $.mobile.behaviors.addFirstLastClasses ) ); - -})( jQuery ); - -(function( $, undefined ) { - -// Deprecated in 1.4 -$.fn.fieldcontain = function(/* options */) { - return this.addClass( "ui-field-contain" ); -}; - -})( jQuery ); - -(function( $, undefined ) { - -$.fn.grid = function( options ) { - return this.each(function() { - - var $this = $( this ), - o = $.extend({ - grid: null - }, options ), - $kids = $this.children(), - gridCols = { solo:1, a:2, b:3, c:4, d:5 }, - grid = o.grid, - iterator, - letter; - - if ( !grid ) { - if ( $kids.length <= 5 ) { - for ( letter in gridCols ) { - if ( gridCols[ letter ] === $kids.length ) { - grid = letter; - } - } - } else { - grid = "a"; - $this.addClass( "ui-grid-duo" ); - } - } - iterator = gridCols[grid]; - - $this.addClass( "ui-grid-" + grid ); - - $kids.filter( ":nth-child(" + iterator + "n+1)" ).addClass( "ui-block-a" ); - - if ( iterator > 1 ) { - $kids.filter( ":nth-child(" + iterator + "n+2)" ).addClass( "ui-block-b" ); - } - if ( iterator > 2 ) { - $kids.filter( ":nth-child(" + iterator + "n+3)" ).addClass( "ui-block-c" ); - } - if ( iterator > 3 ) { - $kids.filter( ":nth-child(" + iterator + "n+4)" ).addClass( "ui-block-d" ); - } - if ( iterator > 4 ) { - $kids.filter( ":nth-child(" + iterator + "n+5)" ).addClass( "ui-block-e" ); - } - }); -}; -})( jQuery ); - -(function( $, undefined ) { - -$.widget( "mobile.navbar", { - options: { - iconpos: "top", - grid: null - }, - - _create: function() { - - var $navbar = this.element, - $navbtns = $navbar.find( "a, button" ), - iconpos = $navbtns.filter( ":jqmData(icon)" ).length ? this.options.iconpos : undefined; - - $navbar.addClass( "ui-navbar" ) - .attr( "role", "navigation" ) - .find( "ul" ) - .jqmEnhanceable() - .grid({ grid: this.options.grid }); - - $navbtns - .each( function() { - var icon = $.mobile.getAttribute( this, "icon" ), - theme = $.mobile.getAttribute( this, "theme" ), - classes = "ui-btn"; - - if ( theme ) { - classes += " ui-btn-" + theme; - } - if ( icon ) { - classes += " ui-icon-" + icon + " ui-btn-icon-" + iconpos; - } - $( this ).addClass( classes ); - }); - - $navbar.delegate( "a", "vclick", function( /* event */ ) { - var activeBtn = $( this ); - - if ( !( activeBtn.hasClass( "ui-state-disabled" ) || - - // DEPRECATED as of 1.4.0 - remove after 1.4.0 release - // only ui-state-disabled should be present thereafter - activeBtn.hasClass( "ui-disabled" ) || - activeBtn.hasClass( $.mobile.activeBtnClass ) ) ) { - - $navbtns.removeClass( $.mobile.activeBtnClass ); - activeBtn.addClass( $.mobile.activeBtnClass ); - - // The code below is a workaround to fix #1181 - $( document ).one( "pagehide", function() { - activeBtn.removeClass( $.mobile.activeBtnClass ); - }); - } - }); - - // Buttons in the navbar with ui-state-persist class should regain their active state before page show - $navbar.closest( ".ui-page" ).bind( "pagebeforeshow", function() { - $navbtns.filter( ".ui-state-persist" ).addClass( $.mobile.activeBtnClass ); - }); - } -}); - -})( jQuery ); - -(function( $, undefined ) { - -var getAttr = $.mobile.getAttribute; - -$.widget( "mobile.listview", $.extend( { - - options: { - theme: null, - countTheme: null, /* Deprecated in 1.4 */ - dividerTheme: null, - icon: "carat-r", - splitIcon: "carat-r", - splitTheme: null, - corners: true, - shadow: true, - inset: false - }, - - _create: function() { - var t = this, - listviewClasses = ""; - - listviewClasses += t.options.inset ? " ui-listview-inset" : ""; - - if ( !!t.options.inset ) { - listviewClasses += t.options.corners ? " ui-corner-all" : ""; - listviewClasses += t.options.shadow ? " ui-shadow" : ""; - } - - // create listview markup - t.element.addClass( " ui-listview" + listviewClasses ); - - t.refresh( true ); - }, - - // TODO: Remove in 1.5 - _findFirstElementByTagName: function( ele, nextProp, lcName, ucName ) { - var dict = {}; - dict[ lcName ] = dict[ ucName ] = true; - while ( ele ) { - if ( dict[ ele.nodeName ] ) { - return ele; - } - ele = ele[ nextProp ]; - } - return null; - }, - // TODO: Remove in 1.5 - _addThumbClasses: function( containers ) { - var i, img, len = containers.length; - for ( i = 0; i < len; i++ ) { - img = $( this._findFirstElementByTagName( containers[ i ].firstChild, "nextSibling", "img", "IMG" ) ); - if ( img.length ) { - $( this._findFirstElementByTagName( img[ 0 ].parentNode, "parentNode", "li", "LI" ) ).addClass( img.hasClass( "ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" ); - } - } - }, - - _getChildrenByTagName: function( ele, lcName, ucName ) { - var results = [], - dict = {}; - dict[ lcName ] = dict[ ucName ] = true; - ele = ele.firstChild; - while ( ele ) { - if ( dict[ ele.nodeName ] ) { - results.push( ele ); - } - ele = ele.nextSibling; - } - return $( results ); - }, - - _beforeListviewRefresh: $.noop, - _afterListviewRefresh: $.noop, - - refresh: function( create ) { - var buttonClass, pos, numli, item, itemClass, itemTheme, itemIcon, icon, a, - isDivider, startCount, newStartCount, value, last, splittheme, splitThemeClass, spliticon, - altButtonClass, dividerTheme, li, - o = this.options, - $list = this.element, - ol = !!$.nodeName( $list[ 0 ], "ol" ), - start = $list.attr( "start" ), - itemClassDict = {}, - countBubbles = $list.find( ".ui-li-count" ), - countTheme = getAttr( $list[ 0 ], "counttheme" ) || this.options.countTheme, - countThemeClass = countTheme ? "ui-body-" + countTheme : "ui-body-inherit"; - - if ( o.theme ) { - $list.addClass( "ui-group-theme-" + o.theme ); - } - - // Check if a start attribute has been set while taking a value of 0 into account - if ( ol && ( start || start === 0 ) ) { - startCount = parseInt( start, 10 ) - 1; - $list.css( "counter-reset", "listnumbering " + startCount ); - } - - this._beforeListviewRefresh(); - - li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" ); - - for ( pos = 0, numli = li.length; pos < numli; pos++ ) { - item = li.eq( pos ); - itemClass = ""; - - if ( create || item[ 0 ].className.search( /\bui-li-static\b|\bui-li-divider\b/ ) < 0 ) { - a = this._getChildrenByTagName( item[ 0 ], "a", "A" ); - isDivider = ( getAttr( item[ 0 ], "role" ) === "list-divider" ); - value = item.attr( "value" ); - itemTheme = getAttr( item[ 0 ], "theme" ); - - if ( a.length && a[ 0 ].className.search( /\bui-btn\b/ ) < 0 && !isDivider ) { - itemIcon = getAttr( item[ 0 ], "icon" ); - icon = ( itemIcon === false ) ? false : ( itemIcon || o.icon ); - - // TODO: Remove in 1.5 together with links.js (links.js / .ui-link deprecated in 1.4) - a.removeClass( "ui-link" ); - - buttonClass = "ui-btn"; - - if ( itemTheme ) { - buttonClass += " ui-btn-" + itemTheme; - } - - if ( a.length > 1 ) { - itemClass = "ui-li-has-alt"; - - last = a.last(); - splittheme = getAttr( last[ 0 ], "theme" ) || o.splitTheme || getAttr( item[ 0 ], "theme", true ); - splitThemeClass = splittheme ? " ui-btn-" + splittheme : ""; - spliticon = getAttr( last[ 0 ], "icon" ) || getAttr( item[ 0 ], "icon" ) || o.splitIcon; - altButtonClass = "ui-btn ui-btn-icon-notext ui-icon-" + spliticon + splitThemeClass; - - last - .attr( "title", $.trim( last.getEncodedText() ) ) - .addClass( altButtonClass ) - .empty(); - - // Reduce to the first anchor, because only the first gets the buttonClass - a = a.first(); - } else if ( icon ) { - buttonClass += " ui-btn-icon-right ui-icon-" + icon; - } - - // Apply buttonClass to the (first) anchor - a.addClass( buttonClass ); - } else if ( isDivider ) { - dividerTheme = ( getAttr( item[ 0 ], "theme" ) || o.dividerTheme || o.theme ); - - itemClass = "ui-li-divider ui-bar-" + ( dividerTheme ? dividerTheme : "inherit" ); - - item.attr( "role", "heading" ); - } else if ( a.length <= 0 ) { - itemClass = "ui-li-static ui-body-" + ( itemTheme ? itemTheme : "inherit" ); - } - if ( ol && value ) { - newStartCount = parseInt( value , 10 ) - 1; - - item.css( "counter-reset", "listnumbering " + newStartCount ); - } - } - - // Instead of setting item class directly on the list item - // at this point in time, push the item into a dictionary - // that tells us what class to set on it so we can do this after this - // processing loop is finished. - - if ( !itemClassDict[ itemClass ] ) { - itemClassDict[ itemClass ] = []; - } - - itemClassDict[ itemClass ].push( item[ 0 ] ); - } - - // Set the appropriate listview item classes on each list item. - // The main reason we didn't do this - // in the for-loop above is because we can eliminate per-item function overhead - // by calling addClass() and children() once or twice afterwards. This - // can give us a significant boost on platforms like WP7.5. - - for ( itemClass in itemClassDict ) { - $( itemClassDict[ itemClass ] ).addClass( itemClass ); - } - - countBubbles.each( function() { - $( this ).closest( "li" ).addClass( "ui-li-has-count" ); - }); - if ( countThemeClass ) { - countBubbles.not( "[class*='ui-body-']" ).addClass( countThemeClass ); - } - - // Deprecated in 1.4. From 1.5 you have to add class ui-li-has-thumb or ui-li-has-icon to the LI. - this._addThumbClasses( li ); - this._addThumbClasses( li.find( ".ui-btn" ) ); - - this._afterListviewRefresh(); - - this._addFirstLastClasses( li, this._getVisibles( li, create ), create ); - } -}, $.mobile.behaviors.addFirstLastClasses ) ); - -})( jQuery ); - -(function( $, undefined ) { - -function defaultAutodividersSelector( elt ) { - // look for the text in the given element - var text = $.trim( elt.text() ) || null; - - if ( !text ) { - return null; - } - - // create the text for the divider (first uppercased letter) - text = text.slice( 0, 1 ).toUpperCase(); - - return text; -} - -$.widget( "mobile.listview", $.mobile.listview, { - options: { - autodividers: false, - autodividersSelector: defaultAutodividersSelector - }, - - _beforeListviewRefresh: function() { - if ( this.options.autodividers ) { - this._replaceDividers(); - this._superApply( arguments ); - } - }, - - _replaceDividers: function() { - var i, lis, li, dividerText, - lastDividerText = null, - list = this.element, - divider; - - list.children( "li:jqmData(role='list-divider')" ).remove(); - - lis = list.children( "li" ); - - for ( i = 0; i < lis.length ; i++ ) { - li = lis[ i ]; - dividerText = this.options.autodividersSelector( $( li ) ); - - if ( dividerText && lastDividerText !== dividerText ) { - divider = document.createElement( "li" ); - divider.appendChild( document.createTextNode( dividerText ) ); - divider.setAttribute( "data-" + $.mobile.ns + "role", "list-divider" ); - li.parentNode.insertBefore( divider, li ); - } - - lastDividerText = dividerText; - } - } -}); - -})( jQuery ); - -(function( $, undefined ) { - -var rdivider = /(^|\s)ui-li-divider($|\s)/, - rhidden = /(^|\s)ui-screen-hidden($|\s)/; - -$.widget( "mobile.listview", $.mobile.listview, { - options: { - hideDividers: false - }, - - _afterListviewRefresh: function() { - var items, idx, item, hideDivider = true; - - this._superApply( arguments ); - - if ( this.options.hideDividers ) { - items = this._getChildrenByTagName( this.element[ 0 ], "li", "LI" ); - for ( idx = items.length - 1 ; idx > -1 ; idx-- ) { - item = items[ idx ]; - if ( item.className.match( rdivider ) ) { - if ( hideDivider ) { - item.className = item.className + " ui-screen-hidden"; - } - hideDivider = true; - } else { - if ( !item.className.match( rhidden ) ) { - hideDivider = false; - } - } - } - } - } -}); - -})( jQuery ); - -(function( $, undefined ) { - -$.mobile.nojs = function( target ) { - $( ":jqmData(role='nojs')", target ).addClass( "ui-nojs" ); -}; - -})( jQuery ); - -(function( $, undefined ) { - -$.mobile.behaviors.formReset = { - _handleFormReset: function() { - this._on( this.element.closest( "form" ), { - reset: function() { - this._delay( "_reset" ); - } - }); - } -}; - -})( jQuery ); - -/* -* "checkboxradio" plugin -*/ - -(function( $, undefined ) { - -var escapeId = $.mobile.path.hashToSelector; - -$.widget( "mobile.checkboxradio", $.extend( { - - initSelector: "input:not( :jqmData(role='flipswitch' ) )[type='checkbox'],input[type='radio']:not( :jqmData(role='flipswitch' ))", - - options: { - theme: "inherit", - mini: false, - wrapperClass: null, - enhanced: false, - iconpos: "left" - - }, - _create: function() { - var input = this.element, - o = this.options, - inheritAttr = function( input, dataAttr ) { - return input.jqmData( dataAttr ) || - input.closest( "form, fieldset" ).jqmData( dataAttr ); - }, - label = this.options.enhanced ? - { - element: this.element.siblings( "label" ), - isParent: false - } : - this._findLabel(), - inputtype = input[0].type, - checkedClass = "ui-" + inputtype + "-on", - uncheckedClass = "ui-" + inputtype + "-off"; - - if ( inputtype !== "checkbox" && inputtype !== "radio" ) { - return; - } - - if ( this.element[0].disabled ) { - this.options.disabled = true; - } - - o.iconpos = inheritAttr( input, "iconpos" ) || - label.element.attr( "data-" + $.mobile.ns + "iconpos" ) || o.iconpos, - - // Establish options - o.mini = inheritAttr( input, "mini" ) || o.mini; - - // Expose for other methods - $.extend( this, { - input: input, - label: label.element, - labelIsParent: label.isParent, - inputtype: inputtype, - checkedClass: checkedClass, - uncheckedClass: uncheckedClass - }); - - if ( !this.options.enhanced ) { - this._enhance(); - } - - this._on( label.element, { - vmouseover: "_handleLabelVMouseOver", - vclick: "_handleLabelVClick" - }); - - this._on( input, { - vmousedown: "_cacheVals", - vclick: "_handleInputVClick", - focus: "_handleInputFocus", - blur: "_handleInputBlur" - }); - - this._handleFormReset(); - this.refresh(); - }, - - _findLabel: function() { - var parentLabel, label, isParent, - input = this.element, - labelsList = input[ 0 ].labels; - - if( labelsList && labelsList.length > 0 ) { - label = $( labelsList[ 0 ] ); - isParent = $.contains( label[ 0 ], input[ 0 ] ); - } else { - parentLabel = input.closest( "label" ); - isParent = ( parentLabel.length > 0 ); - - // NOTE: Windows Phone could not find the label through a selector - // filter works though. - label = isParent ? parentLabel : - $( this.document[ 0 ].getElementsByTagName( "label" ) ) - .filter( "[for='" + escapeId( input[ 0 ].id ) + "']" ) - .first(); - } - - return { - element: label, - isParent: isParent - }; - }, - - _enhance: function() { - this.label.addClass( "ui-btn ui-corner-all"); - - if ( this.labelIsParent ) { - this.input.add( this.label ).wrapAll( this._wrapper() ); - } else { - //this.element.replaceWith( this.input.add( this.label ).wrapAll( this._wrapper() ) ); - this.element.wrap( this._wrapper() ); - this.element.parent().prepend( this.label ); - } - - // Wrap the input + label in a div - - this._setOptions({ - "theme": this.options.theme, - "iconpos": this.options.iconpos, - "mini": this.options.mini - }); - - }, - - _wrapper: function() { - return $( "
" ); - }, - - _handleInputFocus: function() { - this.label.addClass( $.mobile.focusClass ); - }, - - _handleInputBlur: function() { - this.label.removeClass( $.mobile.focusClass ); - }, - - _handleInputVClick: function() { - // Adds checked attribute to checked input when keyboard is used - this.element.prop( "checked", this.element.is( ":checked" ) ); - this._getInputSet().not( this.element ).prop( "checked", false ); - this._updateAll( true ); - }, - - _handleLabelVMouseOver: function( event ) { - if ( this.label.parent().hasClass( "ui-state-disabled" ) ) { - event.stopPropagation(); - } - }, - - _handleLabelVClick: function( event ) { - var input = this.element; - - if ( input.is( ":disabled" ) ) { - event.preventDefault(); - return; - } - - this._cacheVals(); - - input.prop( "checked", this.inputtype === "radio" && true || !input.prop( "checked" ) ); - - // trigger click handler's bound directly to the input as a substitute for - // how label clicks behave normally in the browsers - // TODO: it would be nice to let the browser's handle the clicks and pass them - // through to the associate input. we can swallow that click at the parent - // wrapper element level - input.triggerHandler( "click" ); - - // Input set for common radio buttons will contain all the radio - // buttons, but will not for checkboxes. clearing the checked status - // of other radios ensures the active button state is applied properly - this._getInputSet().not( input ).prop( "checked", false ); - - this._updateAll(); - return false; - }, - - _cacheVals: function() { - this._getInputSet().each( function() { - $( this ).attr("data-" + $.mobile.ns + "cacheVal", this.checked ); - }); - }, - - // Returns those radio buttons that are supposed to be in the same group as - // this radio button. In the case of a checkbox or a radio lacking a name - // attribute, it returns this.element. - _getInputSet: function() { - var selector, formId, - radio = this.element[ 0 ], - name = radio.name, - form = radio.form, - doc = this.element.parents().last().get( 0 ), - - // A radio is always a member of its own group - radios = this.element; - - // Only start running selectors if this is an attached radio button with a name - if ( name && this.inputtype === "radio" && doc ) { - selector = "input[type='radio'][name='" + escapeId( name ) + "']"; - - // If we're inside a form - if ( form ) { - formId = form.getAttribute( "id" ); - - // If the form has an ID, collect radios scattered throught the document which - // nevertheless are part of the form by way of the value of their form attribute - if ( formId ) { - radios = $( selector + "[form='" + escapeId( formId ) + "']", doc ); - } - - // Also add to those the radios in the form itself - radios = $( form ).find( selector ).filter( function() { - - // Some radios inside the form may belong to some other form by virtue of - // having a form attribute defined on them, so we must filter them out here - return ( this.form === form ); - }).add( radios ); - - // If we're outside a form - } else { - - // Collect all those radios which are also outside of a form and match our name - radios = $( selector, doc ).filter( function() { - return !this.form; - }); - } - } - return radios; - }, - - _updateAll: function( changeTriggered ) { - var self = this; - - this._getInputSet().each( function() { - var $this = $( this ); - - if ( ( this.checked || self.inputtype === "checkbox" ) && !changeTriggered ) { - $this.trigger( "change" ); - } - }) - .checkboxradio( "refresh" ); - }, - - _reset: function() { - this.refresh(); - }, - - // Is the widget supposed to display an icon? - _hasIcon: function() { - var controlgroup, controlgroupWidget, - controlgroupConstructor = $.mobile.controlgroup; - - // If the controlgroup widget is defined ... - if ( controlgroupConstructor ) { - controlgroup = this.element.closest( - ":mobile-controlgroup," + - controlgroupConstructor.prototype.initSelector ); - - // ... and the checkbox is in a controlgroup ... - if ( controlgroup.length > 0 ) { - - // ... look for a controlgroup widget instance, and ... - controlgroupWidget = $.data( controlgroup[ 0 ], "mobile-controlgroup" ); - - // ... if found, decide based on the option value, ... - return ( ( controlgroupWidget ? controlgroupWidget.options.type : - - // ... otherwise decide based on the "type" data attribute. - controlgroup.attr( "data-" + $.mobile.ns + "type" ) ) !== "horizontal" ); - } - } - - // Normally, the widget displays an icon. - return true; - }, - - refresh: function() { - var isChecked = this.element[ 0 ].checked, - active = $.mobile.activeBtnClass, - iconposClass = "ui-btn-icon-" + this.options.iconpos, - addClasses = [], - removeClasses = []; - - if ( this._hasIcon() ) { - removeClasses.push( active ); - addClasses.push( iconposClass ); - } else { - removeClasses.push( iconposClass ); - ( isChecked ? addClasses : removeClasses ).push( active ); - } - - if ( isChecked ) { - addClasses.push( this.checkedClass ); - removeClasses.push( this.uncheckedClass ); - } else { - addClasses.push( this.uncheckedClass ); - removeClasses.push( this.checkedClass ); - } - - this.widget().toggleClass( "ui-state-disabled", this.element.prop( "disabled" ) ); - - this.label - .addClass( addClasses.join( " " ) ) - .removeClass( removeClasses.join( " " ) ); - }, - - widget: function() { - return this.label.parent(); - }, - - _setOptions: function( options ) { - var label = this.label, - currentOptions = this.options, - outer = this.widget(), - hasIcon = this._hasIcon(); - - if ( options.disabled !== undefined ) { - this.input.prop( "disabled", !!options.disabled ); - outer.toggleClass( "ui-state-disabled", !!options.disabled ); - } - if ( options.mini !== undefined ) { - outer.toggleClass( "ui-mini", !!options.mini ); - } - if ( options.theme !== undefined ) { - label - .removeClass( "ui-btn-" + currentOptions.theme ) - .addClass( "ui-btn-" + options.theme ); - } - if ( options.wrapperClass !== undefined ) { - outer - .removeClass( currentOptions.wrapperClass ) - .addClass( options.wrapperClass ); - } - if ( options.iconpos !== undefined && hasIcon ) { - label.removeClass( "ui-btn-icon-" + currentOptions.iconpos ).addClass( "ui-btn-icon-" + options.iconpos ); - } else if ( !hasIcon ) { - label.removeClass( "ui-btn-icon-" + currentOptions.iconpos ); - } - this._super( options ); - } - -}, $.mobile.behaviors.formReset ) ); - -})( jQuery ); - -(function( $, undefined ) { - -$.widget( "mobile.button", { - - initSelector: "input[type='button'], input[type='submit'], input[type='reset']", - - options: { - theme: null, - icon: null, - iconpos: "left", - iconshadow: false, /* TODO: Deprecated in 1.4, remove in 1.5. */ - corners: true, - shadow: true, - inline: null, - mini: null, - wrapperClass: null, - enhanced: false - }, - - _create: function() { - - if ( this.element.is( ":disabled" ) ) { - this.options.disabled = true; - } - - if ( !this.options.enhanced ) { - this._enhance(); - } - - $.extend( this, { - wrapper: this.element.parent() - }); - - this._on( { - focus: function() { - this.widget().addClass( $.mobile.focusClass ); - }, - - blur: function() { - this.widget().removeClass( $.mobile.focusClass ); - } - }); - - this.refresh( true ); - }, - - _enhance: function() { - this.element.wrap( this._button() ); - }, - - _button: function() { - var options = this.options, - iconClasses = this._getIconClasses( this.options ); - - return $("
" + this.element.val() + "
" ); - }, - - widget: function() { - return this.wrapper; - }, - - _destroy: function() { - this.element.insertBefore( this.wrapper ); - this.wrapper.remove(); - }, - - _getIconClasses: function( options ) { - return ( options.icon ? ( "ui-icon-" + options.icon + - ( options.iconshadow ? " ui-shadow-icon" : "" ) + /* TODO: Deprecated in 1.4, remove in 1.5. */ - " ui-btn-icon-" + options.iconpos ) : "" ); - }, - - _setOptions: function( options ) { - var outer = this.widget(); - - if ( options.theme !== undefined ) { - outer - .removeClass( this.options.theme ) - .addClass( "ui-btn-" + options.theme ); - } - if ( options.corners !== undefined ) { - outer.toggleClass( "ui-corner-all", options.corners ); - } - if ( options.shadow !== undefined ) { - outer.toggleClass( "ui-shadow", options.shadow ); - } - if ( options.inline !== undefined ) { - outer.toggleClass( "ui-btn-inline", options.inline ); - } - if ( options.mini !== undefined ) { - outer.toggleClass( "ui-mini", options.mini ); - } - if ( options.disabled !== undefined ) { - this.element.prop( "disabled", options.disabled ); - outer.toggleClass( "ui-state-disabled", options.disabled ); - } - - if ( options.icon !== undefined || - options.iconshadow !== undefined || /* TODO: Deprecated in 1.4, remove in 1.5. */ - options.iconpos !== undefined ) { - outer - .removeClass( this._getIconClasses( this.options ) ) - .addClass( this._getIconClasses( - $.extend( {}, this.options, options ) ) ); - } - - this._super( options ); - }, - - refresh: function( create ) { - var originalElement, - isDisabled = this.element.prop( "disabled" ); - - if ( this.options.icon && this.options.iconpos === "notext" && this.element.attr( "title" ) ) { - this.element.attr( "title", this.element.val() ); - } - if ( !create ) { - originalElement = this.element.detach(); - $( this.wrapper ).text( this.element.val() ).append( originalElement ); - } - if ( this.options.disabled !== isDisabled ) { - this._setOptions({ disabled: isDisabled }); - } - } -}); - -})( jQuery ); - -(function( $ ) { - var meta = $( "meta[name=viewport]" ), - initialContent = meta.attr( "content" ), - disabledZoom = initialContent + ",maximum-scale=1, user-scalable=no", - enabledZoom = initialContent + ",maximum-scale=10, user-scalable=yes", - disabledInitially = /(user-scalable[\s]*=[\s]*no)|(maximum-scale[\s]*=[\s]*1)[$,\s]/.test( initialContent ); - - $.mobile.zoom = $.extend( {}, { - enabled: !disabledInitially, - locked: false, - disable: function( lock ) { - if ( !disabledInitially && !$.mobile.zoom.locked ) { - meta.attr( "content", disabledZoom ); - $.mobile.zoom.enabled = false; - $.mobile.zoom.locked = lock || false; - } - }, - enable: function( unlock ) { - if ( !disabledInitially && ( !$.mobile.zoom.locked || unlock === true ) ) { - meta.attr( "content", enabledZoom ); - $.mobile.zoom.enabled = true; - $.mobile.zoom.locked = false; - } - }, - restore: function() { - if ( !disabledInitially ) { - meta.attr( "content", initialContent ); - $.mobile.zoom.enabled = true; - } - } - }); - -}( jQuery )); - -(function( $, undefined ) { - -$.widget( "mobile.textinput", { - initSelector: "input[type='text']," + - "input[type='search']," + - ":jqmData(type='search')," + - "input[type='number']," + - ":jqmData(type='number')," + - "input[type='password']," + - "input[type='email']," + - "input[type='url']," + - "input[type='tel']," + - "textarea," + - "input[type='time']," + - "input[type='date']," + - "input[type='month']," + - "input[type='week']," + - "input[type='datetime']," + - "input[type='datetime-local']," + - "input[type='color']," + - "input:not([type])," + - "input[type='file']", - - options: { - theme: null, - corners: true, - mini: false, - // This option defaults to true on iOS devices. - preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1, - wrapperClass: "", - enhanced: false - }, - - _create: function() { - - var options = this.options, - isSearch = this.element.is( "[type='search'], :jqmData(type='search')" ), - isTextarea = this.element[ 0 ].tagName === "TEXTAREA", - isRange = this.element.is( "[data-" + ( $.mobile.ns || "" ) + "type='range']" ), - inputNeedsWrap = ( (this.element.is( "input" ) || - this.element.is( "[data-" + ( $.mobile.ns || "" ) + "type='search']" ) ) && - !isRange ); - - if ( this.element.prop( "disabled" ) ) { - options.disabled = true; - } - - $.extend( this, { - classes: this._classesFromOptions(), - isSearch: isSearch, - isTextarea: isTextarea, - isRange: isRange, - inputNeedsWrap: inputNeedsWrap - }); - - this._autoCorrect(); - - if ( !options.enhanced ) { - this._enhance(); - } - - this._on( { - "focus": "_handleFocus", - "blur": "_handleBlur" - }); - - }, - - refresh: function() { - this.setOptions({ - "disabled" : this.element.is( ":disabled" ) - }); - }, - - _enhance: function() { - var elementClasses = []; - - if ( this.isTextarea ) { - elementClasses.push( "ui-input-text" ); - } - - if ( this.isTextarea || this.isRange ) { - elementClasses.push( "ui-shadow-inset" ); - } - - //"search" and "text" input widgets - if ( this.inputNeedsWrap ) { - this.element.wrap( this._wrap() ); - } else { - elementClasses = elementClasses.concat( this.classes ); - } - - this.element.addClass( elementClasses.join( " " ) ); - }, - - widget: function() { - return ( this.inputNeedsWrap ) ? this.element.parent() : this.element; - }, - - _classesFromOptions: function() { - var options = this.options, - classes = []; - - classes.push( "ui-body-" + ( ( options.theme === null ) ? "inherit" : options.theme ) ); - if ( options.corners ) { - classes.push( "ui-corner-all" ); - } - if ( options.mini ) { - classes.push( "ui-mini" ); - } - if ( options.disabled ) { - classes.push( "ui-state-disabled" ); - } - if ( options.wrapperClass ) { - classes.push( options.wrapperClass ); - } - - return classes; - }, - - _wrap: function() { - return $( "" ); - }, - - _autoCorrect: function() { - // XXX: Temporary workaround for issue 785 (Apple bug 8910589). - // Turn off autocorrect and autocomplete on non-iOS 5 devices - // since the popup they use can't be dismissed by the user. Note - // that we test for the presence of the feature by looking for - // the autocorrect property on the input element. We currently - // have no test for iOS 5 or newer so we're temporarily using - // the touchOverflow support flag for jQM 1.0. Yes, I feel dirty. - // - jblas - if ( typeof this.element[0].autocorrect !== "undefined" && - !$.support.touchOverflow ) { - - // Set the attribute instead of the property just in case there - // is code that attempts to make modifications via HTML. - this.element[0].setAttribute( "autocorrect", "off" ); - this.element[0].setAttribute( "autocomplete", "off" ); - } - }, - - _handleBlur: function() { - this.widget().removeClass( $.mobile.focusClass ); - if ( this.options.preventFocusZoom ) { - $.mobile.zoom.enable( true ); - } - }, - - _handleFocus: function() { - // In many situations, iOS will zoom into the input upon tap, this - // prevents that from happening - if ( this.options.preventFocusZoom ) { - $.mobile.zoom.disable( true ); - } - this.widget().addClass( $.mobile.focusClass ); - }, - - _setOptions: function ( options ) { - var outer = this.widget(); - - this._super( options ); - - if ( !( options.disabled === undefined && - options.mini === undefined && - options.corners === undefined && - options.theme === undefined && - options.wrapperClass === undefined ) ) { - - outer.removeClass( this.classes.join( " " ) ); - this.classes = this._classesFromOptions(); - outer.addClass( this.classes.join( " " ) ); - } - - if ( options.disabled !== undefined ) { - this.element.prop( "disabled", !!options.disabled ); - } - }, - - _destroy: function() { - if ( this.options.enhanced ) { - return; - } - if ( this.inputNeedsWrap ) { - this.element.unwrap(); - } - this.element.removeClass( "ui-input-text " + this.classes.join( " " ) ); - } -}); - -})( jQuery ); - -(function( $, undefined ) { - -$.widget( "mobile.slider", $.extend( { - initSelector: "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')", - - widgetEventPrefix: "slide", - - options: { - theme: null, - trackTheme: null, - corners: true, - mini: false, - highlight: false - }, - - _create: function() { - - // TODO: Each of these should have comments explain what they're for - var self = this, - control = this.element, - trackTheme = this.options.trackTheme || $.mobile.getAttribute( control[ 0 ], "theme" ), - trackThemeClass = trackTheme ? " ui-bar-" + trackTheme : " ui-bar-inherit", - cornerClass = ( this.options.corners || control.jqmData( "corners" ) ) ? " ui-corner-all" : "", - miniClass = ( this.options.mini || control.jqmData( "mini" ) ) ? " ui-mini" : "", - cType = control[ 0 ].nodeName.toLowerCase(), - isToggleSwitch = ( cType === "select" ), - isRangeslider = control.parent().is( ":jqmData(role='rangeslider')" ), - selectClass = ( isToggleSwitch ) ? "ui-slider-switch" : "", - controlID = control.attr( "id" ), - $label = $( "[for='" + controlID + "']" ), - labelID = $label.attr( "id" ) || controlID + "-label", - min = !isToggleSwitch ? parseFloat( control.attr( "min" ) ) : 0, - max = !isToggleSwitch ? parseFloat( control.attr( "max" ) ) : control.find( "option" ).length-1, - step = window.parseFloat( control.attr( "step" ) || 1 ), - domHandle = document.createElement( "a" ), - handle = $( domHandle ), - domSlider = document.createElement( "div" ), - slider = $( domSlider ), - valuebg = this.options.highlight && !isToggleSwitch ? (function() { - var bg = document.createElement( "div" ); - bg.className = "ui-slider-bg " + $.mobile.activeBtnClass; - return $( bg ).prependTo( slider ); - })() : false, - options, - wrapper, - j, length, - i, optionsCount, origTabIndex, - side, activeClass, sliderImg; - - $label.attr( "id", labelID ); - this.isToggleSwitch = isToggleSwitch; - - domHandle.setAttribute( "href", "#" ); - domSlider.setAttribute( "role", "application" ); - domSlider.className = [ this.isToggleSwitch ? "ui-slider ui-slider-track ui-shadow-inset " : "ui-slider-track ui-shadow-inset ", selectClass, trackThemeClass, cornerClass, miniClass ].join( "" ); - domHandle.className = "ui-slider-handle"; - domSlider.appendChild( domHandle ); - - handle.attr({ - "role": "slider", - "aria-valuemin": min, - "aria-valuemax": max, - "aria-valuenow": this._value(), - "aria-valuetext": this._value(), - "title": this._value(), - "aria-labelledby": labelID - }); - - $.extend( this, { - slider: slider, - handle: handle, - control: control, - type: cType, - step: step, - max: max, - min: min, - valuebg: valuebg, - isRangeslider: isRangeslider, - dragging: false, - beforeStart: null, - userModified: false, - mouseMoved: false - }); - - if ( isToggleSwitch ) { - // TODO: restore original tabindex (if any) in a destroy method - origTabIndex = control.attr( "tabindex" ); - if ( origTabIndex ) { - handle.attr( "tabindex", origTabIndex ); - } - control.attr( "tabindex", "-1" ).focus(function() { - $( this ).blur(); - handle.focus(); - }); - - wrapper = document.createElement( "div" ); - wrapper.className = "ui-slider-inneroffset"; - - for ( j = 0, length = domSlider.childNodes.length; j < length; j++ ) { - wrapper.appendChild( domSlider.childNodes[j] ); - } - - domSlider.appendChild( wrapper ); - - // slider.wrapInner( "
" ); - - // make the handle move with a smooth transition - handle.addClass( "ui-slider-handle-snapping" ); - - options = control.find( "option" ); - - for ( i = 0, optionsCount = options.length; i < optionsCount; i++ ) { - side = !i ? "b" : "a"; - activeClass = !i ? "" : " " + $.mobile.activeBtnClass; - sliderImg = document.createElement( "span" ); - - sliderImg.className = [ "ui-slider-label ui-slider-label-", side, activeClass ].join( "" ); - sliderImg.setAttribute( "role", "img" ); - sliderImg.appendChild( document.createTextNode( options[i].innerHTML ) ); - $( sliderImg ).prependTo( slider ); - } - - self._labels = $( ".ui-slider-label", slider ); - - } - - // monitor the input for updated values - control.addClass( isToggleSwitch ? "ui-slider-switch" : "ui-slider-input" ); - - this._on( control, { - "change": "_controlChange", - "keyup": "_controlKeyup", - "blur": "_controlBlur", - "vmouseup": "_controlVMouseUp" - }); - - slider.bind( "vmousedown", $.proxy( this._sliderVMouseDown, this ) ) - .bind( "vclick", false ); - - // We have to instantiate a new function object for the unbind to work properly - // since the method itself is defined in the prototype (causing it to unbind everything) - this._on( document, { "vmousemove": "_preventDocumentDrag" }); - this._on( slider.add( document ), { "vmouseup": "_sliderVMouseUp" }); - - slider.insertAfter( control ); - - // wrap in a div for styling purposes - if ( !isToggleSwitch && !isRangeslider ) { - wrapper = this.options.mini ? "
" : "
"; - - control.add( slider ).wrapAll( wrapper ); - } - - // bind the handle event callbacks and set the context to the widget instance - this._on( this.handle, { - "vmousedown": "_handleVMouseDown", - "keydown": "_handleKeydown", - "keyup": "_handleKeyup" - }); - - this.handle.bind( "vclick", false ); - - this._handleFormReset(); - - this.refresh( undefined, undefined, true ); - }, - - _setOptions: function( options ) { - if ( options.theme !== undefined ) { - this._setTheme( options.theme ); - } - - if ( options.trackTheme !== undefined ) { - this._setTrackTheme( options.trackTheme ); - } - - if ( options.corners !== undefined ) { - this._setCorners( options.corners ); - } - - if ( options.mini !== undefined ) { - this._setMini( options.mini ); - } - - if ( options.highlight !== undefined ) { - this._setHighlight( options.highlight ); - } - - if ( options.disabled !== undefined ) { - this._setDisabled( options.disabled ); - } - this._super( options ); - }, - - _controlChange: function( event ) { - // if the user dragged the handle, the "change" event was triggered from inside refresh(); don't call refresh() again - if ( this._trigger( "controlchange", event ) === false ) { - return false; - } - if ( !this.mouseMoved ) { - this.refresh( this._value(), true ); - } - }, - - _controlKeyup: function(/* event */) { // necessary? - this.refresh( this._value(), true, true ); - }, - - _controlBlur: function(/* event */) { - this.refresh( this._value(), true ); - }, - - // it appears the clicking the up and down buttons in chrome on - // range/number inputs doesn't trigger a change until the field is - // blurred. Here we check thif the value has changed and refresh - _controlVMouseUp: function(/* event */) { - this._checkedRefresh(); - }, - - // NOTE force focus on handle - _handleVMouseDown: function(/* event */) { - this.handle.focus(); - }, - - _handleKeydown: function( event ) { - var index = this._value(); - if ( this.options.disabled ) { - return; - } - - // In all cases prevent the default and mark the handle as active - switch ( event.keyCode ) { - case $.mobile.keyCode.HOME: - case $.mobile.keyCode.END: - case $.mobile.keyCode.PAGE_UP: - case $.mobile.keyCode.PAGE_DOWN: - case $.mobile.keyCode.UP: - case $.mobile.keyCode.RIGHT: - case $.mobile.keyCode.DOWN: - case $.mobile.keyCode.LEFT: - event.preventDefault(); - - if ( !this._keySliding ) { - this._keySliding = true; - this.handle.addClass( "ui-state-active" ); /* TODO: We don't use this class for styling. Do we need to add it? */ - } - - break; - } - - // move the slider according to the keypress - switch ( event.keyCode ) { - case $.mobile.keyCode.HOME: - this.refresh( this.min ); - break; - case $.mobile.keyCode.END: - this.refresh( this.max ); - break; - case $.mobile.keyCode.PAGE_UP: - case $.mobile.keyCode.UP: - case $.mobile.keyCode.RIGHT: - this.refresh( index + this.step ); - break; - case $.mobile.keyCode.PAGE_DOWN: - case $.mobile.keyCode.DOWN: - case $.mobile.keyCode.LEFT: - this.refresh( index - this.step ); - break; - } - }, // remove active mark - - _handleKeyup: function(/* event */) { - if ( this._keySliding ) { - this._keySliding = false; - this.handle.removeClass( "ui-state-active" ); /* See comment above. */ - } - }, - - _sliderVMouseDown: function( event ) { - // NOTE: we don't do this in refresh because we still want to - // support programmatic alteration of disabled inputs - if ( this.options.disabled || !( event.which === 1 || event.which === 0 || event.which === undefined ) ) { - return false; - } - if ( this._trigger( "beforestart", event ) === false ) { - return false; - } - this.dragging = true; - this.userModified = false; - this.mouseMoved = false; - - if ( this.isToggleSwitch ) { - this.beforeStart = this.element[0].selectedIndex; - } - - this.refresh( event ); - this._trigger( "start" ); - return false; - }, - - _sliderVMouseUp: function() { - if ( this.dragging ) { - this.dragging = false; - - if ( this.isToggleSwitch ) { - // make the handle move with a smooth transition - this.handle.addClass( "ui-slider-handle-snapping" ); - - if ( this.mouseMoved ) { - // this is a drag, change the value only if user dragged enough - if ( this.userModified ) { - this.refresh( this.beforeStart === 0 ? 1 : 0 ); - } else { - this.refresh( this.beforeStart ); - } - } else { - // this is just a click, change the value - this.refresh( this.beforeStart === 0 ? 1 : 0 ); - } - } - - this.mouseMoved = false; - this._trigger( "stop" ); - return false; - } - }, - - _preventDocumentDrag: function( event ) { - // NOTE: we don't do this in refresh because we still want to - // support programmatic alteration of disabled inputs - if ( this._trigger( "drag", event ) === false) { - return false; - } - if ( this.dragging && !this.options.disabled ) { - - // this.mouseMoved must be updated before refresh() because it will be used in the control "change" event - this.mouseMoved = true; - - if ( this.isToggleSwitch ) { - // make the handle move in sync with the mouse - this.handle.removeClass( "ui-slider-handle-snapping" ); - } - - this.refresh( event ); - - // only after refresh() you can calculate this.userModified - this.userModified = this.beforeStart !== this.element[0].selectedIndex; - return false; - } - }, - - _checkedRefresh: function() { - if ( this.value !== this._value() ) { - this.refresh( this._value() ); - } - }, - - _value: function() { - return this.isToggleSwitch ? this.element[0].selectedIndex : parseFloat( this.element.val() ) ; - }, - - _reset: function() { - this.refresh( undefined, false, true ); - }, - - refresh: function( val, isfromControl, preventInputUpdate ) { - // NOTE: we don't return here because we want to support programmatic - // alteration of the input value, which should still update the slider - - var self = this, - parentTheme = $.mobile.getAttribute( this.element[ 0 ], "theme" ), - theme = this.options.theme || parentTheme, - themeClass = theme ? " ui-btn-" + theme : "", - trackTheme = this.options.trackTheme || parentTheme, - trackThemeClass = trackTheme ? " ui-bar-" + trackTheme : " ui-bar-inherit", - cornerClass = this.options.corners ? " ui-corner-all" : "", - miniClass = this.options.mini ? " ui-mini" : "", - left, width, data, tol, - pxStep, percent, - control, isInput, optionElements, min, max, step, - newval, valModStep, alignValue, percentPerStep, - handlePercent, aPercent, bPercent, - valueChanged; - - self.slider[0].className = [ this.isToggleSwitch ? "ui-slider ui-slider-switch ui-slider-track ui-shadow-inset" : "ui-slider-track ui-shadow-inset", trackThemeClass, cornerClass, miniClass ].join( "" ); - if ( this.options.disabled || this.element.prop( "disabled" ) ) { - this.disable(); - } - - // set the stored value for comparison later - this.value = this._value(); - if ( this.options.highlight && !this.isToggleSwitch && this.slider.find( ".ui-slider-bg" ).length === 0 ) { - this.valuebg = (function() { - var bg = document.createElement( "div" ); - bg.className = "ui-slider-bg " + $.mobile.activeBtnClass; - return $( bg ).prependTo( self.slider ); - })(); - } - this.handle.addClass( "ui-btn" + themeClass + " ui-shadow" ); - - control = this.element; - isInput = !this.isToggleSwitch; - optionElements = isInput ? [] : control.find( "option" ); - min = isInput ? parseFloat( control.attr( "min" ) ) : 0; - max = isInput ? parseFloat( control.attr( "max" ) ) : optionElements.length - 1; - step = ( isInput && parseFloat( control.attr( "step" ) ) > 0 ) ? parseFloat( control.attr( "step" ) ) : 1; - - if ( typeof val === "object" ) { - data = val; - // a slight tolerance helped get to the ends of the slider - tol = 8; - - left = this.slider.offset().left; - width = this.slider.width(); - pxStep = width/((max-min)/step); - if ( !this.dragging || - data.pageX < left - tol || - data.pageX > left + width + tol ) { - return; - } - if ( pxStep > 1 ) { - percent = ( ( data.pageX - left ) / width ) * 100; - } else { - percent = Math.round( ( ( data.pageX - left ) / width ) * 100 ); - } - } else { - if ( val == null ) { - val = isInput ? parseFloat( control.val() || 0 ) : control[0].selectedIndex; - } - percent = ( parseFloat( val ) - min ) / ( max - min ) * 100; - } - - if ( isNaN( percent ) ) { - return; - } - - newval = ( percent / 100 ) * ( max - min ) + min; - - //from jQuery UI slider, the following source will round to the nearest step - valModStep = ( newval - min ) % step; - alignValue = newval - valModStep; - - if ( Math.abs( valModStep ) * 2 >= step ) { - alignValue += ( valModStep > 0 ) ? step : ( -step ); - } - - percentPerStep = 100/((max-min)/step); - // Since JavaScript has problems with large floats, round - // the final value to 5 digits after the decimal point (see jQueryUI: #4124) - newval = parseFloat( alignValue.toFixed(5) ); - - if ( typeof pxStep === "undefined" ) { - pxStep = width / ( (max-min) / step ); - } - if ( pxStep > 1 && isInput ) { - percent = ( newval - min ) * percentPerStep * ( 1 / step ); - } - if ( percent < 0 ) { - percent = 0; - } - - if ( percent > 100 ) { - percent = 100; - } - - if ( newval < min ) { - newval = min; - } - - if ( newval > max ) { - newval = max; - } - - this.handle.css( "left", percent + "%" ); - - this.handle[0].setAttribute( "aria-valuenow", isInput ? newval : optionElements.eq( newval ).attr( "value" ) ); - - this.handle[0].setAttribute( "aria-valuetext", isInput ? newval : optionElements.eq( newval ).getEncodedText() ); - - this.handle[0].setAttribute( "title", isInput ? newval : optionElements.eq( newval ).getEncodedText() ); - - if ( this.valuebg ) { - this.valuebg.css( "width", percent + "%" ); - } - - // drag the label widths - if ( this._labels ) { - handlePercent = this.handle.width() / this.slider.width() * 100; - aPercent = percent && handlePercent + ( 100 - handlePercent ) * percent / 100; - bPercent = percent === 100 ? 0 : Math.min( handlePercent + 100 - aPercent, 100 ); - - this._labels.each(function() { - var ab = $( this ).hasClass( "ui-slider-label-a" ); - $( this ).width( ( ab ? aPercent : bPercent ) + "%" ); - }); - } - - if ( !preventInputUpdate ) { - valueChanged = false; - - // update control"s value - if ( isInput ) { - valueChanged = parseFloat( control.val() ) !== newval; - control.val( newval ); - } else { - valueChanged = control[ 0 ].selectedIndex !== newval; - control[ 0 ].selectedIndex = newval; - } - if ( this._trigger( "beforechange", val ) === false) { - return false; - } - if ( !isfromControl && valueChanged ) { - control.trigger( "change" ); - } - } - }, - - _setHighlight: function( value ) { - value = !!value; - if ( value ) { - this.options.highlight = !!value; - this.refresh(); - } else if ( this.valuebg ) { - this.valuebg.remove(); - this.valuebg = false; - } - }, - - _setTheme: function( value ) { - this.handle - .removeClass( "ui-btn-" + this.options.theme ) - .addClass( "ui-btn-" + value ); - - var currentTheme = this.options.theme ? this.options.theme : "inherit", - newTheme = value ? value : "inherit"; - - this.control - .removeClass( "ui-body-" + currentTheme ) - .addClass( "ui-body-" + newTheme ); - }, - - _setTrackTheme: function( value ) { - var currentTrackTheme = this.options.trackTheme ? this.options.trackTheme : "inherit", - newTrackTheme = value ? value : "inherit"; - - this.slider - .removeClass( "ui-body-" + currentTrackTheme ) - .addClass( "ui-body-" + newTrackTheme ); - }, - - _setMini: function( value ) { - value = !!value; - if ( !this.isToggleSwitch && !this.isRangeslider ) { - this.slider.parent().toggleClass( "ui-mini", value ); - this.element.toggleClass( "ui-mini", value ); - } - this.slider.toggleClass( "ui-mini", value ); - }, - - _setCorners: function( value ) { - this.slider.toggleClass( "ui-corner-all", value ); - - if ( !this.isToggleSwitch ) { - this.control.toggleClass( "ui-corner-all", value ); - } - }, - - _setDisabled: function( value ) { - value = !!value; - this.element.prop( "disabled", value ); - this.slider - .toggleClass( "ui-state-disabled", value ) - .attr( "aria-disabled", value ); - - this.element.toggleClass( "ui-state-disabled", value ); - } - -}, $.mobile.behaviors.formReset ) ); - -})( jQuery ); - -(function( $, undefined ) { - -var popup; - -function getPopup() { - if ( !popup ) { - popup = $( "
", { - "class": "ui-slider-popup ui-shadow ui-corner-all" - }); - } - return popup.clone(); -} - -$.widget( "mobile.slider", $.mobile.slider, { - options: { - popupEnabled: false, - showValue: false - }, - - _create: function() { - this._super(); - - $.extend( this, { - _currentValue: null, - _popup: null, - _popupVisible: false - }); - - this._setOption( "popupEnabled", this.options.popupEnabled ); - - this._on( this.handle, { "vmousedown" : "_showPopup" } ); - this._on( this.slider.add( this.document ), { "vmouseup" : "_hidePopup" } ); - this._refresh(); - }, - - // position the popup centered 5px above the handle - _positionPopup: function() { - var dstOffset = this.handle.offset(); - - this._popup.offset( { - left: dstOffset.left + ( this.handle.width() - this._popup.width() ) / 2, - top: dstOffset.top - this._popup.outerHeight() - 5 - }); - }, - - _setOption: function( key, value ) { - this._super( key, value ); - - if ( key === "showValue" ) { - this.handle.html( value && !this.options.mini ? this._value() : "" ); - } else if ( key === "popupEnabled" ) { - if ( value && !this._popup ) { - this._popup = getPopup() - .addClass( "ui-body-" + ( this.options.theme || "a" ) ) - .hide() - .insertBefore( this.element ); - } - } - }, - - // show value on the handle and in popup - refresh: function() { - this._super.apply( this, arguments ); - this._refresh(); - }, - - _refresh: function() { - var o = this.options, newValue; - - if ( o.popupEnabled ) { - // remove the title attribute from the handle (which is - // responsible for the annoying tooltip); NB we have - // to do it here as the jqm slider sets it every time - // the slider's value changes :( - this.handle.removeAttr( "title" ); - } - - newValue = this._value(); - if ( newValue === this._currentValue ) { - return; - } - this._currentValue = newValue; - - if ( o.popupEnabled && this._popup ) { - this._positionPopup(); - this._popup.html( newValue ); - } - - if ( o.showValue && !this.options.mini ) { - this.handle.html( newValue ); - } - }, - - _showPopup: function() { - if ( this.options.popupEnabled && !this._popupVisible ) { - this.handle.html( "" ); - this._popup.show(); - this._positionPopup(); - this._popupVisible = true; - } - }, - - _hidePopup: function() { - var o = this.options; - - if ( o.popupEnabled && this._popupVisible ) { - if ( o.showValue && !o.mini ) { - this.handle.html( this._value() ); - } - this._popup.hide(); - this._popupVisible = false; - } - } -}); - -})( jQuery ); - -(function( $, undefined ) { - -$.widget( "mobile.flipswitch", $.extend({ - - options: { - onText: "On", - offText: "Off", - theme: null, - enhanced: false, - wrapperClass: null, - corners: true, - mini: false - }, - - _create: function() { - if ( !this.options.enhanced ) { - this._enhance(); - } else { - $.extend( this, { - flipswitch: this.element.parent(), - on: this.element.find( ".ui-flipswitch-on" ).eq( 0 ), - off: this.element.find( ".ui-flipswitch-off" ).eq(0), - type: this.element.get( 0 ).tagName - }); - } - - this._handleFormReset(); - - // Transfer tabindex to "on" element and make input unfocusable - this._originalTabIndex = this.element.attr( "tabindex" ); - if ( this._originalTabIndex != null ) { - this.on.attr( "tabindex", this._originalTabIndex ); - } - this.element.attr( "tabindex", "-1" ); - this._on({ - "focus" : "_handleInputFocus" - }); - - if ( this.element.is( ":disabled" ) ) { - this._setOptions({ - "disabled": true - }); - } - - this._on( this.flipswitch, { - "click": "_toggle", - "swipeleft": "_left", - "swiperight": "_right" - }); - - this._on( this.on, { - "keydown": "_keydown" - }); - - this._on( { - "change": "refresh" - }); - }, - - _handleInputFocus: function() { - this.on.focus(); - }, - - widget: function() { - return this.flipswitch; - }, - - _left: function() { - this.flipswitch.removeClass( "ui-flipswitch-active" ); - if ( this.type === "SELECT" ) { - this.element.get( 0 ).selectedIndex = 0; - } else { - this.element.prop( "checked", false ); - } - this.element.trigger( "change" ); - }, - - _right: function() { - this.flipswitch.addClass( "ui-flipswitch-active" ); - if ( this.type === "SELECT" ) { - this.element.get( 0 ).selectedIndex = 1; - } else { - this.element.prop( "checked", true ); - } - this.element.trigger( "change" ); - }, - - _enhance: function() { - var flipswitch = $( "
" ), - options = this.options, - element = this.element, - theme = options.theme ? options.theme : "inherit", - - // The "on" button is an anchor so it's focusable - on = $( "", { - "href": "#" - }), - off = $( "" ), - type = element.get( 0 ).tagName, - onText = ( type === "INPUT" ) ? - options.onText : element.find( "option" ).eq( 1 ).text(), - offText = ( type === "INPUT" ) ? - options.offText : element.find( "option" ).eq( 0 ).text(); - - on - .addClass( "ui-flipswitch-on ui-btn ui-shadow ui-btn-inherit" ) - .text( onText ); - off - .addClass( "ui-flipswitch-off" ) - .text( offText ); - - flipswitch - .addClass( "ui-flipswitch ui-shadow-inset " + - "ui-bar-" + theme + " " + - ( options.wrapperClass ? options.wrapperClass : "" ) + " " + - ( ( element.is( ":checked" ) || - element - .find( "option" ) - .eq( 1 ) - .is( ":selected" ) ) ? "ui-flipswitch-active" : "" ) + - ( element.is(":disabled") ? " ui-state-disabled": "") + - ( options.corners ? " ui-corner-all": "" ) + - ( options.mini ? " ui-mini": "" ) ) - .append( on, off ); - - element - .addClass( "ui-flipswitch-input" ) - .after( flipswitch ) - .appendTo( flipswitch ); - - $.extend( this, { - flipswitch: flipswitch, - on: on, - off: off, - type: type - }); - }, - - _reset: function() { - this.refresh(); - }, - - refresh: function() { - var direction, - existingDirection = this.flipswitch.hasClass( "ui-flipswitch-active" ) ? "_right" : "_left"; - - if ( this.type === "SELECT" ) { - direction = ( this.element.get( 0 ).selectedIndex > 0 ) ? "_right": "_left"; - } else { - direction = this.element.prop( "checked" ) ? "_right": "_left"; - } - - if ( direction !== existingDirection ) { - this[ direction ](); - } - }, - - _toggle: function() { - var direction = this.flipswitch.hasClass( "ui-flipswitch-active" ) ? "_left" : "_right"; - - this[ direction ](); - }, - - _keydown: function( e ) { - if ( e.which === $.mobile.keyCode.LEFT ) { - this._left(); - } else if ( e.which === $.mobile.keyCode.RIGHT ) { - this._right(); - } else if ( e.which === $.mobile.keyCode.SPACE ) { - this._toggle(); - e.preventDefault(); - } - }, - - _setOptions: function( options ) { - if ( options.theme !== undefined ) { - var currentTheme = options.theme ? options.theme : "inherit", - newTheme = options.theme ? options.theme : "inherit"; - - this.widget() - .removeClass( "ui-bar-" + currentTheme ) - .addClass( "ui-bar-" + newTheme ); - } - if ( options.onText !== undefined ) { - this.on.text( options.onText ); - } - if ( options.offText !== undefined ) { - this.off.text( options.offText ); - } - if ( options.disabled !== undefined ) { - this.widget().toggleClass( "ui-state-disabled", options.disabled ); - } - if ( options.mini !== undefined ) { - this.widget().toggleClass( "ui-mini", options.mini ); - } - if ( options.corners !== undefined ) { - this.widget().toggleClass( "ui-corner-all", options.corners ); - } - - this._super( options ); - }, - - _destroy: function() { - if ( this.options.enhanced ) { - return; - } - if ( this._originalTabIndex != null ) { - this.element.attr( "tabindex", this._originalTabIndex ); - } else { - this.element.removeAttr( "tabindex" ); - } - this.on.remove(); - this.off.remove(); - this.element.unwrap(); - this.flipswitch.remove(); - this.removeClass( "ui-flipswitch-input" ); - } - -}, $.mobile.behaviors.formReset ) ); - -})( jQuery ); - -(function( $, undefined ) { - $.widget( "mobile.rangeslider", $.extend( { - - options: { - theme: null, - trackTheme: null, - corners: true, - mini: false, - highlight: true - }, - - _create: function() { - var $el = this.element, - elClass = this.options.mini ? "ui-rangeslider ui-mini" : "ui-rangeslider", - _inputFirst = $el.find( "input" ).first(), - _inputLast = $el.find( "input" ).last(), - _label = $el.find( "label" ).first(), - _sliderWidgetFirst = $.data( _inputFirst.get( 0 ), "mobile-slider" ) || - $.data( _inputFirst.slider().get( 0 ), "mobile-slider" ), - _sliderWidgetLast = $.data( _inputLast.get(0), "mobile-slider" ) || - $.data( _inputLast.slider().get( 0 ), "mobile-slider" ), - _sliderFirst = _sliderWidgetFirst.slider, - _sliderLast = _sliderWidgetLast.slider, - firstHandle = _sliderWidgetFirst.handle, - _sliders = $( "
" ).appendTo( $el ); - - _inputFirst.addClass( "ui-rangeslider-first" ); - _inputLast.addClass( "ui-rangeslider-last" ); - $el.addClass( elClass ); - - _sliderFirst.appendTo( _sliders ); - _sliderLast.appendTo( _sliders ); - _label.insertBefore( $el ); - firstHandle.prependTo( _sliderLast ); - - $.extend( this, { - _inputFirst: _inputFirst, - _inputLast: _inputLast, - _sliderFirst: _sliderFirst, - _sliderLast: _sliderLast, - _label: _label, - _targetVal: null, - _sliderTarget: false, - _sliders: _sliders, - _proxy: false - }); - - this.refresh(); - this._on( this.element.find( "input.ui-slider-input" ), { - "slidebeforestart": "_slidebeforestart", - "slidestop": "_slidestop", - "slidedrag": "_slidedrag", - "slidebeforechange": "_change", - "blur": "_change", - "keyup": "_change" - }); - this._on({ - "mousedown":"_change" - }); - this._on( this.element.closest( "form" ), { - "reset":"_handleReset" - }); - this._on( firstHandle, { - "vmousedown": "_dragFirstHandle" - }); - }, - _handleReset: function() { - var self = this; - //we must wait for the stack to unwind before updateing other wise sliders will not have updated yet - setTimeout( function() { - self._updateHighlight(); - },0); - }, - - _dragFirstHandle: function( event ) { - //if the first handle is dragged send the event to the first slider - $.data( this._inputFirst.get(0), "mobile-slider" ).dragging = true; - $.data( this._inputFirst.get(0), "mobile-slider" ).refresh( event ); - $.data( this._inputFirst.get(0), "mobile-slider" )._trigger( "start" ); - return false; - }, - - _slidedrag: function( event ) { - var first = $( event.target ).is( this._inputFirst ), - otherSlider = ( first ) ? this._inputLast : this._inputFirst; - - this._sliderTarget = false; - //if the drag was initiated on an extreme and the other handle is focused send the events to - //the closest handle - if ( ( this._proxy === "first" && first ) || ( this._proxy === "last" && !first ) ) { - $.data( otherSlider.get(0), "mobile-slider" ).dragging = true; - $.data( otherSlider.get(0), "mobile-slider" ).refresh( event ); - return false; - } - }, - - _slidestop: function( event ) { - var first = $( event.target ).is( this._inputFirst ); - - this._proxy = false; - //this stops dragging of the handle and brings the active track to the front - //this makes clicks on the track go the the last handle used - this.element.find( "input" ).trigger( "vmouseup" ); - this._sliderFirst.css( "z-index", first ? 1 : "" ); - }, - - _slidebeforestart: function( event ) { - this._sliderTarget = false; - //if the track is the target remember this and the original value - if ( $( event.originalEvent.target ).hasClass( "ui-slider-track" ) ) { - this._sliderTarget = true; - this._targetVal = $( event.target ).val(); - } - }, - - _setOptions: function( options ) { - if ( options.theme !== undefined ) { - this._setTheme( options.theme ); - } - - if ( options.trackTheme !== undefined ) { - this._setTrackTheme( options.trackTheme ); - } - - if ( options.mini !== undefined ) { - this._setMini( options.mini ); - } - - if ( options.highlight !== undefined ) { - this._setHighlight( options.highlight ); - } - - if ( options.disabled !== undefined ) { - this._setDisabled( options.disabled ); - } - - this._super( options ); - this.refresh(); - }, - - refresh: function() { - var $el = this.element, - o = this.options; - - if ( this._inputFirst.is( ":disabled" ) || this._inputLast.is( ":disabled" ) ) { - this.options.disabled = true; - } - - $el.find( "input" ).slider({ - theme: o.theme, - trackTheme: o.trackTheme, - disabled: o.disabled, - corners: o.corners, - mini: o.mini, - highlight: o.highlight - }).slider( "refresh" ); - this._updateHighlight(); - }, - - _change: function( event ) { - if ( event.type === "keyup" ) { - this._updateHighlight(); - return false; - } - - var self = this, - min = parseFloat( this._inputFirst.val(), 10 ), - max = parseFloat( this._inputLast.val(), 10 ), - first = $( event.target ).hasClass( "ui-rangeslider-first" ), - thisSlider = first ? this._inputFirst : this._inputLast, - otherSlider = first ? this._inputLast : this._inputFirst; - - if ( ( this._inputFirst.val() > this._inputLast.val() && event.type === "mousedown" && !$(event.target).hasClass("ui-slider-handle")) ) { - thisSlider.blur(); - } else if ( event.type === "mousedown" ) { - return; - } - if ( min > max && !this._sliderTarget ) { - //this prevents min from being greater then max - thisSlider.val( first ? max: min ).slider( "refresh" ); - this._trigger( "normalize" ); - } else if ( min > max ) { - //this makes it so clicks on the target on either extreme go to the closest handle - thisSlider.val( this._targetVal ).slider( "refresh" ); - - //You must wait for the stack to unwind so first slider is updated before updating second - setTimeout( function() { - otherSlider.val( first ? min: max ).slider( "refresh" ); - $.data( otherSlider.get(0), "mobile-slider" ).handle.focus(); - self._sliderFirst.css( "z-index", first ? "" : 1 ); - self._trigger( "normalize" ); - }, 0 ); - this._proxy = ( first ) ? "first" : "last"; - } - //fixes issue where when both _sliders are at min they cannot be adjusted - if ( min === max ) { - $.data( thisSlider.get(0), "mobile-slider" ).handle.css( "z-index", 1 ); - $.data( otherSlider.get(0), "mobile-slider" ).handle.css( "z-index", 0 ); - } else { - $.data( otherSlider.get(0), "mobile-slider" ).handle.css( "z-index", "" ); - $.data( thisSlider.get(0), "mobile-slider" ).handle.css( "z-index", "" ); - } - - this._updateHighlight(); - - if ( min >= max ) { - return false; - } - }, - - _updateHighlight: function() { - var min = parseInt( $.data( this._inputFirst.get(0), "mobile-slider" ).handle.get(0).style.left, 10 ), - max = parseInt( $.data( this._inputLast.get(0), "mobile-slider" ).handle.get(0).style.left, 10 ), - width = (max - min); - - this.element.find( ".ui-slider-bg" ).css({ - "margin-left": min + "%", - "width": width + "%" - }); - }, - - _setTheme: function( value ) { - this._inputFirst.slider( "option", "theme", value ); - this._inputLast.slider( "option", "theme", value ); - }, - - _setTrackTheme: function( value ) { - this._inputFirst.slider( "option", "trackTheme", value ); - this._inputLast.slider( "option", "trackTheme", value ); - }, - - _setMini: function( value ) { - this._inputFirst.slider( "option", "mini", value ); - this._inputLast.slider( "option", "mini", value ); - this.element.toggleClass( "ui-mini", !!value ); - }, - - _setHighlight: function( value ) { - this._inputFirst.slider( "option", "highlight", value ); - this._inputLast.slider( "option", "highlight", value ); - }, - - _setDisabled: function( value ) { - this._inputFirst.prop( "disabled", value ); - this._inputLast.prop( "disabled", value ); - }, - - _destroy: function() { - this._label.prependTo( this.element ); - this.element.removeClass( "ui-rangeslider ui-mini" ); - this._inputFirst.after( this._sliderFirst ); - this._inputLast.after( this._sliderLast ); - this._sliders.remove(); - this.element.find( "input" ).removeClass( "ui-rangeslider-first ui-rangeslider-last" ).slider( "destroy" ); - } - - }, $.mobile.behaviors.formReset ) ); - -})( jQuery ); - -(function( $, undefined ) { - - $.widget( "mobile.textinput", $.mobile.textinput, { - options: { - clearBtn: false, - clearBtnText: "Clear text" - }, - - _create: function() { - this._super(); - - if ( this.isSearch ) { - this.options.clearBtn = true; - } - - if ( !!this.options.clearBtn && this.inputNeedsWrap ) { - this._addClearBtn(); - } - }, - - clearButton: function() { - return $( "" ) - .attr( "title", this.options.clearBtnText ) - .text( this.options.clearBtnText ); - }, - - _clearBtnClick: function( event ) { - this.element.val( "" ) - .focus() - .trigger( "change" ); - - this._clearBtn.addClass( "ui-input-clear-hidden" ); - event.preventDefault(); - }, - - _addClearBtn: function() { - - if ( !this.options.enhanced ) { - this._enhanceClear(); - } - - $.extend( this, { - _clearBtn: this.widget().find("a.ui-input-clear") - }); - - this._bindClearEvents(); - - this._toggleClear(); - - }, - - _enhanceClear: function() { - - this.clearButton().appendTo( this.widget() ); - this.widget().addClass( "ui-input-has-clear" ); - - }, - - _bindClearEvents: function() { - - this._on( this._clearBtn, { - "click": "_clearBtnClick" - }); - - this._on({ - "keyup": "_toggleClear", - "change": "_toggleClear", - "input": "_toggleClear", - "focus": "_toggleClear", - "blur": "_toggleClear", - "cut": "_toggleClear", - "paste": "_toggleClear" - - }); - - }, - - _unbindClear: function() { - this._off( this._clearBtn, "click"); - this._off( this.element, "keyup change input focus blur cut paste" ); - }, - - _setOptions: function( options ) { - this._super( options ); - - if ( options.clearBtn !== undefined && - !this.element.is( "textarea, :jqmData(type='range')" ) ) { - if ( options.clearBtn ) { - this._addClearBtn(); - } else { - this._destroyClear(); - } - } - - if ( options.clearBtnText !== undefined && this._clearBtn !== undefined ) { - this._clearBtn.text( options.clearBtnText ) - .attr("title", options.clearBtnText); - } - }, - - _toggleClear: function() { - this._delay( "_toggleClearClass", 0 ); - }, - - _toggleClearClass: function() { - this._clearBtn.toggleClass( "ui-input-clear-hidden", !this.element.val() ); - }, - - _destroyClear: function() { - this.widget().removeClass( "ui-input-has-clear" ); - this._unbindClear(); - this._clearBtn.remove(); - }, - - _destroy: function() { - this._super(); - if ( this.options.clearBtn ) { - this._destroyClear(); - } - } - - }); - -})( jQuery ); - -(function( $, undefined ) { - - $.widget( "mobile.textinput", $.mobile.textinput, { - options: { - autogrow:true, - keyupTimeoutBuffer: 100 - }, - - _create: function() { - this._super(); - - if ( this.options.autogrow && this.isTextarea ) { - this._autogrow(); - } - }, - - _autogrow: function() { - this.element.addClass( "ui-textinput-autogrow" ); - - this._on({ - "keyup": "_timeout", - "change": "_timeout", - "input": "_timeout", - "paste": "_timeout" - }); - - // Attach to the various you-have-become-visible notifications that the - // various framework elements emit. - // TODO: Remove all but the updatelayout handler once #6426 is fixed. - this._on( true, this.document, { - - // TODO: Move to non-deprecated event - "pageshow": "_handleShow", - "popupbeforeposition": "_handleShow", - "updatelayout": "_handleShow", - "panelopen": "_handleShow" - }); - }, - - // Synchronously fix the widget height if this widget's parents are such - // that they show/hide content at runtime. We still need to check whether - // the widget is actually visible in case it is contained inside multiple - // such containers. For example: panel contains collapsible contains - // autogrow textinput. The panel may emit "panelopen" indicating that its - // content has become visible, but the collapsible is still collapsed, so - // the autogrow textarea is still not visible. - _handleShow: function( event ) { - if ( $.contains( event.target, this.element[ 0 ] ) && - this.element.is( ":visible" ) ) { - - if ( event.type !== "popupbeforeposition" ) { - this.element - .addClass( "ui-textinput-autogrow-resize" ) - .animationComplete( - $.proxy( function() { - this.element.removeClass( "ui-textinput-autogrow-resize" ); - }, this ), - "transition" ); - } - this._prepareHeightUpdate(); - } - }, - - _unbindAutogrow: function() { - this.element.removeClass( "ui-textinput-autogrow" ); - this._off( this.element, "keyup change input paste" ); - this._off( this.document, - "pageshow popupbeforeposition updatelayout panelopen" ); - }, - - keyupTimeout: null, - - _prepareHeightUpdate: function( delay ) { - if ( this.keyupTimeout ) { - clearTimeout( this.keyupTimeout ); - } - if ( delay === undefined ) { - this._updateHeight(); - } else { - this.keyupTimeout = this._delay( "_updateHeight", delay ); - } - }, - - _timeout: function() { - this._prepareHeightUpdate( this.options.keyupTimeoutBuffer ); - }, - - _updateHeight: function() { - var paddingTop, paddingBottom, paddingHeight, scrollHeight, clientHeight, - borderTop, borderBottom, borderHeight, height, - scrollTop = this.window.scrollTop(); - this.keyupTimeout = 0; - - // IE8 textareas have the onpage property - others do not - if ( !( "onpage" in this.element[ 0 ] ) ) { - this.element.css({ - "height": 0, - "min-height": 0, - "max-height": 0 - }); - } - - scrollHeight = this.element[ 0 ].scrollHeight; - clientHeight = this.element[ 0 ].clientHeight; - borderTop = parseFloat( this.element.css( "border-top-width" ) ); - borderBottom = parseFloat( this.element.css( "border-bottom-width" ) ); - borderHeight = borderTop + borderBottom; - height = scrollHeight + borderHeight + 15; - - // Issue 6179: Padding is not included in scrollHeight and - // clientHeight by Firefox if no scrollbar is visible. Because - // textareas use the border-box box-sizing model, padding should be - // included in the new (assigned) height. Because the height is set - // to 0, clientHeight == 0 in Firefox. Therefore, we can use this to - // check if padding must be added. - if ( clientHeight === 0 ) { - paddingTop = parseFloat( this.element.css( "padding-top" ) ); - paddingBottom = parseFloat( this.element.css( "padding-bottom" ) ); - paddingHeight = paddingTop + paddingBottom; - - height += paddingHeight; - } - - this.element.css({ - "height": height, - "min-height": "", - "max-height": "" - }); - - this.window.scrollTop( scrollTop ); - }, - - refresh: function() { - if ( this.options.autogrow && this.isTextarea ) { - this._updateHeight(); - } - }, - - _setOptions: function( options ) { - - this._super( options ); - - if ( options.autogrow !== undefined && this.isTextarea ) { - if ( options.autogrow ) { - this._autogrow(); - } else { - this._unbindAutogrow(); - } - } - } - - }); -})( jQuery ); - -(function( $, undefined ) { - -$.widget( "mobile.selectmenu", $.extend( { - initSelector: "select:not( :jqmData(role='slider')):not( :jqmData(role='flipswitch') )", - - options: { - theme: null, - icon: "carat-d", - iconpos: "right", - inline: false, - corners: true, - shadow: true, - iconshadow: false, /* TODO: Deprecated in 1.4, remove in 1.5. */ - overlayTheme: null, - dividerTheme: null, - hidePlaceholderMenuItems: true, - closeText: "Close", - nativeMenu: true, - // This option defaults to true on iOS devices. - preventFocusZoom: /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1, - mini: false - }, - - _button: function() { - return $( "
" ); - }, - - _setDisabled: function( value ) { - this.element.attr( "disabled", value ); - this.button.attr( "aria-disabled", value ); - return this._setOption( "disabled", value ); - }, - - _focusButton : function() { - var self = this; - - setTimeout( function() { - self.button.focus(); - }, 40); - }, - - _selectOptions: function() { - return this.select.find( "option" ); - }, - - // setup items that are generally necessary for select menu extension - _preExtension: function() { - var inline = this.options.inline || this.element.jqmData( "inline" ), - mini = this.options.mini || this.element.jqmData( "mini" ), - classes = ""; - // TODO: Post 1.1--once we have time to test thoroughly--any classes manually applied to the original element should be carried over to the enhanced element, with an `-enhanced` suffix. See https://github.com/jquery/jquery-mobile/issues/3577 - /* if ( $el[0].className.length ) { - classes = $el[0].className; - } */ - if ( !!~this.element[0].className.indexOf( "ui-btn-left" ) ) { - classes = " ui-btn-left"; - } - - if ( !!~this.element[0].className.indexOf( "ui-btn-right" ) ) { - classes = " ui-btn-right"; - } - - if ( inline ) { - classes += " ui-btn-inline"; - } - if ( mini ) { - classes += " ui-mini"; - } - - this.select = this.element.removeClass( "ui-btn-left ui-btn-right" ).wrap( "
" ); - this.selectId = this.select.attr( "id" ) || ( "select-" + this.uuid ); - this.buttonId = this.selectId + "-button"; - this.label = $( "label[for='"+ this.selectId +"']" ); - this.isMultiple = this.select[ 0 ].multiple; - }, - - _destroy: function() { - var wrapper = this.element.parents( ".ui-select" ); - if ( wrapper.length > 0 ) { - if ( wrapper.is( ".ui-btn-left, .ui-btn-right" ) ) { - this.element.addClass( wrapper.hasClass( "ui-btn-left" ) ? "ui-btn-left" : "ui-btn-right" ); - } - this.element.insertAfter( wrapper ); - wrapper.remove(); - } - }, - - _create: function() { - this._preExtension(); - - this.button = this._button(); - - var self = this, - - options = this.options, - - iconpos = options.icon ? ( options.iconpos || this.select.jqmData( "iconpos" ) ) : false, - - button = this.button - .insertBefore( this.select ) - .attr( "id", this.buttonId ) - .addClass( "ui-btn" + - ( options.icon ? ( " ui-icon-" + options.icon + " ui-btn-icon-" + iconpos + - ( options.iconshadow ? " ui-shadow-icon" : "" ) ) : "" ) + /* TODO: Remove in 1.5. */ - ( options.theme ? " ui-btn-" + options.theme : "" ) + - ( options.corners ? " ui-corner-all" : "" ) + - ( options.shadow ? " ui-shadow" : "" ) ); - - this.setButtonText(); - - // Opera does not properly support opacity on select elements - // In Mini, it hides the element, but not its text - // On the desktop,it seems to do the opposite - // for these reasons, using the nativeMenu option results in a full native select in Opera - if ( options.nativeMenu && window.opera && window.opera.version ) { - button.addClass( "ui-select-nativeonly" ); - } - - // Add counter for multi selects - if ( this.isMultiple ) { - this.buttonCount = $( "" ) - .addClass( "ui-li-count ui-body-inherit" ) - .hide() - .appendTo( button.addClass( "ui-li-has-count" ) ); - } - - // Disable if specified - if ( options.disabled || this.element.attr( "disabled" )) { - this.disable(); - } - - // Events on native select - this.select.change(function() { - self.refresh(); - - if ( !!options.nativeMenu ) { - self._delay( function() { - self.select.blur(); - }); - } - }); - - this._handleFormReset(); - - this._on( this.button, { - keydown: "_handleKeydown" - }); - - this.build(); - }, - - build: function() { - var self = this; - - this.select - .appendTo( self.button ) - .bind( "vmousedown", function() { - // Add active class to button - self.button.addClass( $.mobile.activeBtnClass ); - }) - .bind( "focus", function() { - self.button.addClass( $.mobile.focusClass ); - }) - .bind( "blur", function() { - self.button.removeClass( $.mobile.focusClass ); - }) - .bind( "focus vmouseover", function() { - self.button.trigger( "vmouseover" ); - }) - .bind( "vmousemove", function() { - // Remove active class on scroll/touchmove - self.button.removeClass( $.mobile.activeBtnClass ); - }) - .bind( "change blur vmouseout", function() { - self.button.trigger( "vmouseout" ) - .removeClass( $.mobile.activeBtnClass ); - }); - - // In many situations, iOS will zoom into the select upon tap, this prevents that from happening - self.button.bind( "vmousedown", function() { - if ( self.options.preventFocusZoom ) { - $.mobile.zoom.disable( true ); - } - }); - self.label.bind( "click focus", function() { - if ( self.options.preventFocusZoom ) { - $.mobile.zoom.disable( true ); - } - }); - self.select.bind( "focus", function() { - if ( self.options.preventFocusZoom ) { - $.mobile.zoom.disable( true ); - } - }); - self.button.bind( "mouseup", function() { - if ( self.options.preventFocusZoom ) { - setTimeout(function() { - $.mobile.zoom.enable( true ); - }, 0 ); - } - }); - self.select.bind( "blur", function() { - if ( self.options.preventFocusZoom ) { - $.mobile.zoom.enable( true ); - } - }); - - }, - - selected: function() { - return this._selectOptions().filter( ":selected" ); - }, - - selectedIndices: function() { - var self = this; - - return this.selected().map(function() { - return self._selectOptions().index( this ); - }).get(); - }, - - setButtonText: function() { - var self = this, - selected = this.selected(), - text = this.placeholder, - span = $( document.createElement( "span" ) ); - - this.button.children( "span" ).not( ".ui-li-count" ).remove().end().end().prepend( (function() { - if ( selected.length ) { - text = selected.map(function() { - return $( this ).text(); - }).get().join( ", " ); - } else { - text = self.placeholder; - } - - if ( text ) { - span.text( text ); - } else { - - // Set the contents to   which we write as   to be XHTML compliant - see gh-6699 - span.html( " " ); - } - - // TODO possibly aggregate multiple select option classes - return span - .addClass( self.select.attr( "class" ) ) - .addClass( selected.attr( "class" ) ) - .removeClass( "ui-screen-hidden" ); - })()); - }, - - setButtonCount: function() { - var selected = this.selected(); - - // multiple count inside button - if ( this.isMultiple ) { - this.buttonCount[ selected.length > 1 ? "show" : "hide" ]().text( selected.length ); - } - }, - - _handleKeydown: function( /* event */ ) { - this._delay( "_refreshButton" ); - }, - - _reset: function() { - this.refresh(); - }, - - _refreshButton: function() { - this.setButtonText(); - this.setButtonCount(); - }, - - refresh: function() { - this._refreshButton(); - }, - - // open and close preserved in native selects - // to simplify users code when looping over selects - open: $.noop, - close: $.noop, - - disable: function() { - this._setDisabled( true ); - this.button.addClass( "ui-state-disabled" ); - }, - - enable: function() { - this._setDisabled( false ); - this.button.removeClass( "ui-state-disabled" ); - } -}, $.mobile.behaviors.formReset ) ); - -})( jQuery ); - -(function( $, undefined ) { - -$.mobile.links = function( target ) { - - //links within content areas, tests included with page - $( target ) - .find( "a" ) - .jqmEnhanceable() - .filter( ":jqmData(rel='popup')[href][href!='']" ) - .each( function() { - // Accessibility info for popups - var element = this, - idref = element.getAttribute( "href" ).substring( 1 ); - - if ( idref ) { - element.setAttribute( "aria-haspopup", true ); - element.setAttribute( "aria-owns", idref ); - element.setAttribute( "aria-expanded", false ); - } - }) - .end() - .not( ".ui-btn, :jqmData(role='none'), :jqmData(role='nojs')" ) - .addClass( "ui-link" ); - -}; - -})( jQuery ); - - -(function( $, undefined ) { - -function fitSegmentInsideSegment( windowSize, segmentSize, offset, desired ) { - var returnValue = desired; - - if ( windowSize < segmentSize ) { - // Center segment if it's bigger than the window - returnValue = offset + ( windowSize - segmentSize ) / 2; - } else { - // Otherwise center it at the desired coordinate while keeping it completely inside the window - returnValue = Math.min( Math.max( offset, desired - segmentSize / 2 ), offset + windowSize - segmentSize ); - } - - return returnValue; -} - -function getWindowCoordinates( theWindow ) { - return { - x: theWindow.scrollLeft(), - y: theWindow.scrollTop(), - cx: ( theWindow[ 0 ].innerWidth || theWindow.width() ), - cy: ( theWindow[ 0 ].innerHeight || theWindow.height() ) - }; -} - -$.widget( "mobile.popup", { - options: { - wrapperClass: null, - theme: null, - overlayTheme: null, - shadow: true, - corners: true, - transition: "none", - positionTo: "origin", - tolerance: null, - closeLinkSelector: "a:jqmData(rel='back')", - closeLinkEvents: "click.popup", - navigateEvents: "navigate.popup", - closeEvents: "navigate.popup pagebeforechange.popup", - dismissible: true, - enhanced: false, - - // NOTE Windows Phone 7 has a scroll position caching issue that - // requires us to disable popup history management by default - // https://github.com/jquery/jquery-mobile/issues/4784 - // - // NOTE this option is modified in _create! - history: !$.mobile.browser.oldIE - }, - - // When the user depresses the mouse/finger on an element inside the popup while the popup is - // open, we ignore resize events for a short while. This prevents #6961. - _handleDocumentVmousedown: function( theEvent ) { - if ( this._isOpen && $.contains( this._ui.container[ 0 ], theEvent.target ) ) { - this._ignoreResizeEvents(); - } - }, - - _create: function() { - var theElement = this.element, - myId = theElement.attr( "id" ), - currentOptions = this.options; - - // We need to adjust the history option to be false if there's no AJAX nav. - // We can't do it in the option declarations because those are run before - // it is determined whether there shall be AJAX nav. - currentOptions.history = currentOptions.history && $.mobile.ajaxEnabled && $.mobile.hashListeningEnabled; - - this._on( this.document, { - "vmousedown": "_handleDocumentVmousedown" - }); - - // Define instance variables - $.extend( this, { - _scrollTop: 0, - _page: theElement.closest( ".ui-page" ), - _ui: null, - _fallbackTransition: "", - _currentTransition: false, - _prerequisites: null, - _isOpen: false, - _tolerance: null, - _resizeData: null, - _ignoreResizeTo: 0, - _orientationchangeInProgress: false - }); - - if ( this._page.length === 0 ) { - this._page = $( "body" ); - } - - if ( currentOptions.enhanced ) { - this._ui = { - container: theElement.parent(), - screen: theElement.parent().prev(), - placeholder: $( this.document[ 0 ].getElementById( myId + "-placeholder" ) ) - }; - } else { - this._ui = this._enhance( theElement, myId ); - this._applyTransition( currentOptions.transition ); - } - this - ._setTolerance( currentOptions.tolerance ) - ._ui.focusElement = this._ui.container; - - // Event handlers - this._on( this._ui.screen, { "vclick": "_eatEventAndClose" } ); - this._on( this.window, { - orientationchange: $.proxy( this, "_handleWindowOrientationchange" ), - resize: $.proxy( this, "_handleWindowResize" ), - keyup: $.proxy( this, "_handleWindowKeyUp" ) - }); - this._on( this.document, { "focusin": "_handleDocumentFocusIn" } ); - }, - - _enhance: function( theElement, myId ) { - var currentOptions = this.options, - wrapperClass = currentOptions.wrapperClass, - ui = { - screen: $( "
" ), - placeholder: $( "
" ), - container: $( "
" ) - }, - fragment = this.document[ 0 ].createDocumentFragment(); - - fragment.appendChild( ui.screen[ 0 ] ); - fragment.appendChild( ui.container[ 0 ] ); - - if ( myId ) { - ui.screen.attr( "id", myId + "-screen" ); - ui.container.attr( "id", myId + "-popup" ); - ui.placeholder - .attr( "id", myId + "-placeholder" ) - .html( "" ); - } - - // Apply the proto - this._page[ 0 ].appendChild( fragment ); - // Leave a placeholder where the element used to be - ui.placeholder.insertAfter( theElement ); - theElement - .detach() - .addClass( "ui-popup " + - this._themeClassFromOption( "ui-body-", currentOptions.theme ) + " " + - ( currentOptions.shadow ? "ui-overlay-shadow " : "" ) + - ( currentOptions.corners ? "ui-corner-all " : "" ) ) - .appendTo( ui.container ); - - return ui; - }, - - _eatEventAndClose: function( theEvent ) { - theEvent.preventDefault(); - theEvent.stopImmediatePropagation(); - if ( this.options.dismissible ) { - this.close(); - } - return false; - }, - - // Make sure the screen covers the entire document - CSS is sometimes not - // enough to accomplish this. - _resizeScreen: function() { - var screen = this._ui.screen, - popupHeight = this._ui.container.outerHeight( true ), - screenHeight = screen.removeAttr( "style" ).height(), - - // Subtracting 1 here is necessary for an obscure Andrdoid 4.0 bug where - // the browser hangs if the screen covers the entire document :/ - documentHeight = this.document.height() - 1; - - if ( screenHeight < documentHeight ) { - screen.height( documentHeight ); - } else if ( popupHeight > screenHeight ) { - screen.height( popupHeight ); - } - }, - - _handleWindowKeyUp: function( theEvent ) { - if ( this._isOpen && theEvent.keyCode === $.mobile.keyCode.ESCAPE ) { - return this._eatEventAndClose( theEvent ); - } - }, - - _expectResizeEvent: function() { - var windowCoordinates = getWindowCoordinates( this.window ); - - if ( this._resizeData ) { - if ( windowCoordinates.x === this._resizeData.windowCoordinates.x && - windowCoordinates.y === this._resizeData.windowCoordinates.y && - windowCoordinates.cx === this._resizeData.windowCoordinates.cx && - windowCoordinates.cy === this._resizeData.windowCoordinates.cy ) { - // timeout not refreshed - return false; - } else { - // clear existing timeout - it will be refreshed below - clearTimeout( this._resizeData.timeoutId ); - } - } - - this._resizeData = { - timeoutId: this._delay( "_resizeTimeout", 200 ), - windowCoordinates: windowCoordinates - }; - - return true; - }, - - _resizeTimeout: function() { - if ( this._isOpen ) { - if ( !this._expectResizeEvent() ) { - if ( this._ui.container.hasClass( "ui-popup-hidden" ) ) { - // effectively rapid-open the popup while leaving the screen intact - this._ui.container.removeClass( "ui-popup-hidden ui-popup-truncate" ); - this.reposition( { positionTo: "window" } ); - this._ignoreResizeEvents(); - } - - this._resizeScreen(); - this._resizeData = null; - this._orientationchangeInProgress = false; - } - } else { - this._resizeData = null; - this._orientationchangeInProgress = false; - } - }, - - _stopIgnoringResizeEvents: function() { - this._ignoreResizeTo = 0; - }, - - _ignoreResizeEvents: function() { - if ( this._ignoreResizeTo ) { - clearTimeout( this._ignoreResizeTo ); - } - this._ignoreResizeTo = this._delay( "_stopIgnoringResizeEvents", 1000 ); - }, - - _handleWindowResize: function(/* theEvent */) { - if ( this._isOpen && this._ignoreResizeTo === 0 ) { - if ( ( this._expectResizeEvent() || this._orientationchangeInProgress ) && - !this._ui.container.hasClass( "ui-popup-hidden" ) ) { - // effectively rapid-close the popup while leaving the screen intact - this._ui.container - .addClass( "ui-popup-hidden ui-popup-truncate" ) - .removeAttr( "style" ); - } - } - }, - - _handleWindowOrientationchange: function(/* theEvent */) { - if ( !this._orientationchangeInProgress && this._isOpen && this._ignoreResizeTo === 0 ) { - this._expectResizeEvent(); - this._orientationchangeInProgress = true; - } - }, - - // When the popup is open, attempting to focus on an element that is not a - // child of the popup will redirect focus to the popup - _handleDocumentFocusIn: function( theEvent ) { - var target, - targetElement = theEvent.target, - ui = this._ui; - - if ( !this._isOpen ) { - return; - } - - if ( targetElement !== ui.container[ 0 ] ) { - target = $( targetElement ); - if ( !$.contains( ui.container[ 0 ], targetElement ) ) { - $( this.document[ 0 ].activeElement ).one( "focus", $.proxy( function() { - this._safelyBlur( targetElement ); - }, this ) ); - ui.focusElement.focus(); - theEvent.preventDefault(); - theEvent.stopImmediatePropagation(); - return false; - } else if ( ui.focusElement[ 0 ] === ui.container[ 0 ] ) { - ui.focusElement = target; - } - } - - this._ignoreResizeEvents(); - }, - - _themeClassFromOption: function( prefix, value ) { - return ( value ? ( value === "none" ? "" : ( prefix + value ) ) : ( prefix + "inherit" ) ); - }, - - _applyTransition: function( value ) { - if ( value ) { - this._ui.container.removeClass( this._fallbackTransition ); - if ( value !== "none" ) { - this._fallbackTransition = $.mobile._maybeDegradeTransition( value ); - if ( this._fallbackTransition === "none" ) { - this._fallbackTransition = ""; - } - this._ui.container.addClass( this._fallbackTransition ); - } - } - - return this; - }, - - _setOptions: function( newOptions ) { - var currentOptions = this.options, - theElement = this.element, - screen = this._ui.screen; - - if ( newOptions.wrapperClass !== undefined ) { - this._ui.container - .removeClass( currentOptions.wrapperClass ) - .addClass( newOptions.wrapperClass ); - } - - if ( newOptions.theme !== undefined ) { - theElement - .removeClass( this._themeClassFromOption( "ui-body-", currentOptions.theme ) ) - .addClass( this._themeClassFromOption( "ui-body-", newOptions.theme ) ); - } - - if ( newOptions.overlayTheme !== undefined ) { - screen - .removeClass( this._themeClassFromOption( "ui-overlay-", currentOptions.overlayTheme ) ) - .addClass( this._themeClassFromOption( "ui-overlay-", newOptions.overlayTheme ) ); - - if ( this._isOpen ) { - screen.addClass( "in" ); - } - } - - if ( newOptions.shadow !== undefined ) { - theElement.toggleClass( "ui-overlay-shadow", newOptions.shadow ); - } - - if ( newOptions.corners !== undefined ) { - theElement.toggleClass( "ui-corner-all", newOptions.corners ); - } - - if ( newOptions.transition !== undefined ) { - if ( !this._currentTransition ) { - this._applyTransition( newOptions.transition ); - } - } - - if ( newOptions.tolerance !== undefined ) { - this._setTolerance( newOptions.tolerance ); - } - - if ( newOptions.disabled !== undefined ) { - if ( newOptions.disabled ) { - this.close(); - } - } - - return this._super( newOptions ); - }, - - _setTolerance: function( value ) { - var tol = { t: 30, r: 15, b: 30, l: 15 }, - ar; - - if ( value !== undefined ) { - ar = String( value ).split( "," ); - - $.each( ar, function( idx, val ) { ar[ idx ] = parseInt( val, 10 ); } ); - - switch( ar.length ) { - // All values are to be the same - case 1: - if ( !isNaN( ar[ 0 ] ) ) { - tol.t = tol.r = tol.b = tol.l = ar[ 0 ]; - } - break; - - // The first value denotes top/bottom tolerance, and the second value denotes left/right tolerance - case 2: - if ( !isNaN( ar[ 0 ] ) ) { - tol.t = tol.b = ar[ 0 ]; - } - if ( !isNaN( ar[ 1 ] ) ) { - tol.l = tol.r = ar[ 1 ]; - } - break; - - // The array contains values in the order top, right, bottom, left - case 4: - if ( !isNaN( ar[ 0 ] ) ) { - tol.t = ar[ 0 ]; - } - if ( !isNaN( ar[ 1 ] ) ) { - tol.r = ar[ 1 ]; - } - if ( !isNaN( ar[ 2 ] ) ) { - tol.b = ar[ 2 ]; - } - if ( !isNaN( ar[ 3 ] ) ) { - tol.l = ar[ 3 ]; - } - break; - - default: - break; - } - } - - this._tolerance = tol; - return this; - }, - - _clampPopupWidth: function( infoOnly ) { - var menuSize, - windowCoordinates = getWindowCoordinates( this.window ), - // rectangle within which the popup must fit - rectangle = { - x: this._tolerance.l, - y: windowCoordinates.y + this._tolerance.t, - cx: windowCoordinates.cx - this._tolerance.l - this._tolerance.r, - cy: windowCoordinates.cy - this._tolerance.t - this._tolerance.b - }; - - if ( !infoOnly ) { - // Clamp the width of the menu before grabbing its size - this._ui.container.css( "max-width", rectangle.cx ); - } - - menuSize = { - cx: this._ui.container.outerWidth( true ), - cy: this._ui.container.outerHeight( true ) - }; - - return { rc: rectangle, menuSize: menuSize }; - }, - - _calculateFinalLocation: function( desired, clampInfo ) { - var returnValue, - rectangle = clampInfo.rc, - menuSize = clampInfo.menuSize; - - // Center the menu over the desired coordinates, while not going outside - // the window tolerances. This will center wrt. the window if the popup is - // too large. - returnValue = { - left: fitSegmentInsideSegment( rectangle.cx, menuSize.cx, rectangle.x, desired.x ), - top: fitSegmentInsideSegment( rectangle.cy, menuSize.cy, rectangle.y, desired.y ) - }; - - // Make sure the top of the menu is visible - returnValue.top = Math.max( 0, returnValue.top ); - - // If the height of the menu is smaller than the height of the document - // align the bottom with the bottom of the document - - returnValue.top -= Math.min( returnValue.top, - Math.max( 0, returnValue.top + menuSize.cy - this.document.height() ) ); - - return returnValue; - }, - - // Try and center the overlay over the given coordinates - _placementCoords: function( desired ) { - return this._calculateFinalLocation( desired, this._clampPopupWidth() ); - }, - - _createPrerequisites: function( screenPrerequisite, containerPrerequisite, whenDone ) { - var prerequisites, - self = this; - - // It is important to maintain both the local variable prerequisites and - // self._prerequisites. The local variable remains in the closure of the - // functions which call the callbacks passed in. The comparison between the - // local variable and self._prerequisites is necessary, because once a - // function has been passed to .animationComplete() it will be called next - // time an animation completes, even if that's not the animation whose end - // the function was supposed to catch (for example, if an abort happens - // during the opening animation, the .animationComplete handler is not - // called for that animation anymore, but the handler remains attached, so - // it is called the next time the popup is opened - making it stale. - // Comparing the local variable prerequisites to the widget-level variable - // self._prerequisites ensures that callbacks triggered by a stale - // .animationComplete will be ignored. - - prerequisites = { - screen: $.Deferred(), - container: $.Deferred() - }; - - prerequisites.screen.then( function() { - if ( prerequisites === self._prerequisites ) { - screenPrerequisite(); - } - }); - - prerequisites.container.then( function() { - if ( prerequisites === self._prerequisites ) { - containerPrerequisite(); - } - }); - - $.when( prerequisites.screen, prerequisites.container ).done( function() { - if ( prerequisites === self._prerequisites ) { - self._prerequisites = null; - whenDone(); - } - }); - - self._prerequisites = prerequisites; - }, - - _animate: function( args ) { - // NOTE before removing the default animation of the screen - // this had an animate callback that would resolve the deferred - // now the deferred is resolved immediately - // TODO remove the dependency on the screen deferred - this._ui.screen - .removeClass( args.classToRemove ) - .addClass( args.screenClassToAdd ); - - args.prerequisites.screen.resolve(); - - if ( args.transition && args.transition !== "none" ) { - if ( args.applyTransition ) { - this._applyTransition( args.transition ); - } - if ( this._fallbackTransition ) { - this._ui.container - .addClass( args.containerClassToAdd ) - .removeClass( args.classToRemove ) - .animationComplete( $.proxy( args.prerequisites.container, "resolve" ) ); - return; - } - } - this._ui.container.removeClass( args.classToRemove ); - args.prerequisites.container.resolve(); - }, - - // The desired coordinates passed in will be returned untouched if no reference element can be identified via - // desiredPosition.positionTo. Nevertheless, this function ensures that its return value always contains valid - // x and y coordinates by specifying the center middle of the window if the coordinates are absent. - // options: { x: coordinate, y: coordinate, positionTo: string: "origin", "window", or jQuery selector - _desiredCoords: function( openOptions ) { - var offset, - dst = null, - windowCoordinates = getWindowCoordinates( this.window ), - x = openOptions.x, - y = openOptions.y, - pTo = openOptions.positionTo; - - // Establish which element will serve as the reference - if ( pTo && pTo !== "origin" ) { - if ( pTo === "window" ) { - x = windowCoordinates.cx / 2 + windowCoordinates.x; - y = windowCoordinates.cy / 2 + windowCoordinates.y; - } else { - try { - dst = $( pTo ); - } catch( err ) { - dst = null; - } - if ( dst ) { - dst.filter( ":visible" ); - if ( dst.length === 0 ) { - dst = null; - } - } - } - } - - // If an element was found, center over it - if ( dst ) { - offset = dst.offset(); - x = offset.left + dst.outerWidth() / 2; - y = offset.top + dst.outerHeight() / 2; - } - - // Make sure x and y are valid numbers - center over the window - if ( $.type( x ) !== "number" || isNaN( x ) ) { - x = windowCoordinates.cx / 2 + windowCoordinates.x; - } - if ( $.type( y ) !== "number" || isNaN( y ) ) { - y = windowCoordinates.cy / 2 + windowCoordinates.y; - } - - return { x: x, y: y }; - }, - - _reposition: function( openOptions ) { - // We only care about position-related parameters for repositioning - openOptions = { - x: openOptions.x, - y: openOptions.y, - positionTo: openOptions.positionTo - }; - this._trigger( "beforeposition", undefined, openOptions ); - this._ui.container.offset( this._placementCoords( this._desiredCoords( openOptions ) ) ); - }, - - reposition: function( openOptions ) { - if ( this._isOpen ) { - this._reposition( openOptions ); - } - }, - - _safelyBlur: function( currentElement ){ - if ( currentElement !== this.window[ 0 ] && - currentElement.nodeName.toLowerCase() !== "body" ) { - $( currentElement ).blur(); - } - }, - - _openPrerequisitesComplete: function() { - var id = this.element.attr( "id" ), - firstFocus = this._ui.container.find( ":focusable" ).first(); - - this._ui.container.addClass( "ui-popup-active" ); - this._isOpen = true; - this._resizeScreen(); - - // Check to see if currElement is not a child of the container. If it's not, blur - if ( !$.contains( this._ui.container[ 0 ], this.document[ 0 ].activeElement ) ) { - this._safelyBlur( this.document[ 0 ].activeElement ); - } - if ( firstFocus.length > 0 ) { - this._ui.focusElement = firstFocus; - } - this._ignoreResizeEvents(); - if ( id ) { - this.document.find( "[aria-haspopup='true'][aria-owns='" + id + "']" ).attr( "aria-expanded", true ); - } - this._trigger( "afteropen" ); - }, - - _open: function( options ) { - var openOptions = $.extend( {}, this.options, options ), - // TODO move blacklist to private method - androidBlacklist = ( function() { - var ua = navigator.userAgent, - // Rendering engine is Webkit, and capture major version - wkmatch = ua.match( /AppleWebKit\/([0-9\.]+)/ ), - wkversion = !!wkmatch && wkmatch[ 1 ], - androidmatch = ua.match( /Android (\d+(?:\.\d+))/ ), - andversion = !!androidmatch && androidmatch[ 1 ], - chromematch = ua.indexOf( "Chrome" ) > -1; - - // Platform is Android, WebKit version is greater than 534.13 ( Android 3.2.1 ) and not Chrome. - if ( androidmatch !== null && andversion === "4.0" && wkversion && wkversion > 534.13 && !chromematch ) { - return true; - } - return false; - }()); - - // Count down to triggering "popupafteropen" - we have two prerequisites: - // 1. The popup window animation completes (container()) - // 2. The screen opacity animation completes (screen()) - this._createPrerequisites( - $.noop, - $.noop, - $.proxy( this, "_openPrerequisitesComplete" ) ); - - this._currentTransition = openOptions.transition; - this._applyTransition( openOptions.transition ); - - this._ui.screen.removeClass( "ui-screen-hidden" ); - this._ui.container.removeClass( "ui-popup-truncate" ); - - // Give applications a chance to modify the contents of the container before it appears - this._reposition( openOptions ); - - this._ui.container.removeClass( "ui-popup-hidden" ); - - if ( this.options.overlayTheme && androidBlacklist ) { - /* TODO: The native browser on Android 4.0.X ("Ice Cream Sandwich") suffers from an issue where the popup overlay appears to be z-indexed above the popup itself when certain other styles exist on the same page -- namely, any element set to `position: fixed` and certain types of input. These issues are reminiscent of previously uncovered bugs in older versions of Android's native browser: https://github.com/scottjehl/Device-Bugs/issues/3 - This fix closes the following bugs ( I use "closes" with reluctance, and stress that this issue should be revisited as soon as possible ): - https://github.com/jquery/jquery-mobile/issues/4816 - https://github.com/jquery/jquery-mobile/issues/4844 - https://github.com/jquery/jquery-mobile/issues/4874 - */ - - // TODO sort out why this._page isn't working - this.element.closest( ".ui-page" ).addClass( "ui-popup-open" ); - } - this._animate({ - additionalCondition: true, - transition: openOptions.transition, - classToRemove: "", - screenClassToAdd: "in", - containerClassToAdd: "in", - applyTransition: false, - prerequisites: this._prerequisites - }); - }, - - _closePrerequisiteScreen: function() { - this._ui.screen - .removeClass( "out" ) - .addClass( "ui-screen-hidden" ); - }, - - _closePrerequisiteContainer: function() { - this._ui.container - .removeClass( "reverse out" ) - .addClass( "ui-popup-hidden ui-popup-truncate" ) - .removeAttr( "style" ); - }, - - _closePrerequisitesDone: function() { - var container = this._ui.container, - id = this.element.attr( "id" ); - - // remove the global mutex for popups - $.mobile.popup.active = undefined; - - // Blur elements inside the container, including the container - $( ":focus", container[ 0 ] ).add( container[ 0 ] ).blur(); - - if ( id ) { - this.document.find( "[aria-haspopup='true'][aria-owns='" + id + "']" ).attr( "aria-expanded", false ); - } - - // alert users that the popup is closed - this._trigger( "afterclose" ); - }, - - _close: function( immediate ) { - this._ui.container.removeClass( "ui-popup-active" ); - this._page.removeClass( "ui-popup-open" ); - - this._isOpen = false; - - // Count down to triggering "popupafterclose" - we have two prerequisites: - // 1. The popup window reverse animation completes (container()) - // 2. The screen opacity animation completes (screen()) - this._createPrerequisites( - $.proxy( this, "_closePrerequisiteScreen" ), - $.proxy( this, "_closePrerequisiteContainer" ), - $.proxy( this, "_closePrerequisitesDone" ) ); - - this._animate( { - additionalCondition: this._ui.screen.hasClass( "in" ), - transition: ( immediate ? "none" : ( this._currentTransition ) ), - classToRemove: "in", - screenClassToAdd: "out", - containerClassToAdd: "reverse out", - applyTransition: true, - prerequisites: this._prerequisites - }); - }, - - _unenhance: function() { - if ( this.options.enhanced ) { - return; - } - - // Put the element back to where the placeholder was and remove the "ui-popup" class - this._setOptions( { theme: $.mobile.popup.prototype.options.theme } ); - this.element - // Cannot directly insertAfter() - we need to detach() first, because - // insertAfter() will do nothing if the payload div was not attached - // to the DOM at the time the widget was created, and so the payload - // will remain inside the container even after we call insertAfter(). - // If that happens and we remove the container a few lines below, we - // will cause an infinite recursion - #5244 - .detach() - .insertAfter( this._ui.placeholder ) - .removeClass( "ui-popup ui-overlay-shadow ui-corner-all ui-body-inherit" ); - this._ui.screen.remove(); - this._ui.container.remove(); - this._ui.placeholder.remove(); - }, - - _destroy: function() { - if ( $.mobile.popup.active === this ) { - this.element.one( "popupafterclose", $.proxy( this, "_unenhance" ) ); - this.close(); - } else { - this._unenhance(); - } - - return this; - }, - - _closePopup: function( theEvent, data ) { - var parsedDst, toUrl, - currentOptions = this.options, - immediate = false; - - if ( ( theEvent && theEvent.isDefaultPrevented() ) || $.mobile.popup.active !== this ) { - return; - } - - // restore location on screen - window.scrollTo( 0, this._scrollTop ); - - if ( theEvent && theEvent.type === "pagebeforechange" && data ) { - // Determine whether we need to rapid-close the popup, or whether we can - // take the time to run the closing transition - if ( typeof data.toPage === "string" ) { - parsedDst = data.toPage; - } else { - parsedDst = data.toPage.jqmData( "url" ); - } - parsedDst = $.mobile.path.parseUrl( parsedDst ); - toUrl = parsedDst.pathname + parsedDst.search + parsedDst.hash; - - if ( this._myUrl !== $.mobile.path.makeUrlAbsolute( toUrl ) ) { - // Going to a different page - close immediately - immediate = true; - } else { - theEvent.preventDefault(); - } - } - - // remove nav bindings - this.window.off( currentOptions.closeEvents ); - // unbind click handlers added when history is disabled - this.element.undelegate( currentOptions.closeLinkSelector, currentOptions.closeLinkEvents ); - - this._close( immediate ); - }, - - // any navigation event after a popup is opened should close the popup - // NOTE the pagebeforechange is bound to catch navigation events that don't - // alter the url (eg, dialogs from popups) - _bindContainerClose: function() { - this.window - .on( this.options.closeEvents, $.proxy( this, "_closePopup" ) ); - }, - - widget: function() { - return this._ui.container; - }, - - // TODO no clear deliniation of what should be here and - // what should be in _open. Seems to be "visual" vs "history" for now - open: function( options ) { - var url, hashkey, activePage, currentIsDialog, hasHash, urlHistory, - self = this, - currentOptions = this.options; - - // make sure open is idempotent - if ( $.mobile.popup.active || currentOptions.disabled ) { - return this; - } - - // set the global popup mutex - $.mobile.popup.active = this; - this._scrollTop = this.window.scrollTop(); - - // if history alteration is disabled close on navigate events - // and leave the url as is - if ( !( currentOptions.history ) ) { - self._open( options ); - self._bindContainerClose(); - - // When histoy is disabled we have to grab the data-rel - // back link clicks so we can close the popup instead of - // relying on history to do it for us - self.element - .delegate( currentOptions.closeLinkSelector, currentOptions.closeLinkEvents, function( theEvent ) { - self.close(); - theEvent.preventDefault(); - }); - - return this; - } - - // cache some values for min/readability - urlHistory = $.mobile.navigate.history; - hashkey = $.mobile.dialogHashKey; - activePage = $.mobile.activePage; - currentIsDialog = ( activePage ? activePage.hasClass( "ui-dialog" ) : false ); - this._myUrl = url = urlHistory.getActive().url; - hasHash = ( url.indexOf( hashkey ) > -1 ) && !currentIsDialog && ( urlHistory.activeIndex > 0 ); - - if ( hasHash ) { - self._open( options ); - self._bindContainerClose(); - return this; - } - - // if the current url has no dialog hash key proceed as normal - // otherwise, if the page is a dialog simply tack on the hash key - if ( url.indexOf( hashkey ) === -1 && !currentIsDialog ) { - url = url + (url.indexOf( "#" ) > -1 ? hashkey : "#" + hashkey); - } else { - url = $.mobile.path.parseLocation().hash + hashkey; - } - - // swallow the the initial navigation event, and bind for the next - this.window.one( "beforenavigate", function( theEvent ) { - theEvent.preventDefault(); - self._open( options ); - self._bindContainerClose(); - }); - - this.urlAltered = true; - $.mobile.navigate( url, { role: "dialog" } ); - - return this; - }, - - close: function() { - // make sure close is idempotent - if ( $.mobile.popup.active !== this ) { - return this; - } - - this._scrollTop = this.window.scrollTop(); - - if ( this.options.history && this.urlAltered ) { - $.mobile.back(); - this.urlAltered = false; - } else { - // simulate the nav bindings having fired - this._closePopup(); - } - - return this; - } -}); - -// TODO this can be moved inside the widget -$.mobile.popup.handleLink = function( $link ) { - var offset, - path = $.mobile.path, - - // NOTE make sure to get only the hash from the href because ie7 (wp7) - // returns the absolute href in this case ruining the element selection - popup = $( path.hashToSelector( path.parseUrl( $link.attr( "href" ) ).hash ) ).first(); - - if ( popup.length > 0 && popup.data( "mobile-popup" ) ) { - offset = $link.offset(); - popup.popup( "open", { - x: offset.left + $link.outerWidth() / 2, - y: offset.top + $link.outerHeight() / 2, - transition: $link.jqmData( "transition" ), - positionTo: $link.jqmData( "position-to" ) - }); - } - - //remove after delay - setTimeout( function() { - $link.removeClass( $.mobile.activeBtnClass ); - }, 300 ); -}; - -// TODO move inside _create -$.mobile.document.on( "pagebeforechange", function( theEvent, data ) { - if ( data.options.role === "popup" ) { - $.mobile.popup.handleLink( data.options.link ); - theEvent.preventDefault(); - } -}); - -})( jQuery ); - -/* -* custom "selectmenu" plugin -*/ - -(function( $, undefined ) { - -var unfocusableItemSelector = ".ui-disabled,.ui-state-disabled,.ui-li-divider,.ui-screen-hidden,:jqmData(role='placeholder')", - goToAdjacentItem = function( item, target, direction ) { - var adjacent = item[ direction + "All" ]() - .not( unfocusableItemSelector ) - .first(); - - // if there's a previous option, focus it - if ( adjacent.length ) { - target - .blur() - .attr( "tabindex", "-1" ); - - adjacent.find( "a" ).first().focus(); - } - }; - -$.widget( "mobile.selectmenu", $.mobile.selectmenu, { - _create: function() { - var o = this.options; - - // Custom selects cannot exist inside popups, so revert the "nativeMenu" - // option to true if a parent is a popup - o.nativeMenu = o.nativeMenu || ( this.element.parents( ":jqmData(role='popup'),:mobile-popup" ).length > 0 ); - - return this._super(); - }, - - _handleSelectFocus: function() { - this.element.blur(); - this.button.focus(); - }, - - _handleKeydown: function( event ) { - this._super( event ); - this._handleButtonVclickKeydown( event ); - }, - - _handleButtonVclickKeydown: function( event ) { - if ( this.options.disabled || this.isOpen || this.options.nativeMenu ) { - return; - } - - if (event.type === "vclick" || - event.keyCode && (event.keyCode === $.mobile.keyCode.ENTER || event.keyCode === $.mobile.keyCode.SPACE)) { - - this._decideFormat(); - if ( this.menuType === "overlay" ) { - this.button.attr( "href", "#" + this.popupId ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "popup" ); - } else { - this.button.attr( "href", "#" + this.dialogId ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "dialog" ); - } - this.isOpen = true; - // Do not prevent default, so the navigation may have a chance to actually open the chosen format - } - }, - - _handleListFocus: function( e ) { - var params = ( e.type === "focusin" ) ? - { tabindex: "0", event: "vmouseover" }: - { tabindex: "-1", event: "vmouseout" }; - - $( e.target ) - .attr( "tabindex", params.tabindex ) - .trigger( params.event ); - }, - - _handleListKeydown: function( event ) { - var target = $( event.target ), - li = target.closest( "li" ); - - // switch logic based on which key was pressed - switch ( event.keyCode ) { - // up or left arrow keys - case 38: - goToAdjacentItem( li, target, "prev" ); - return false; - // down or right arrow keys - case 40: - goToAdjacentItem( li, target, "next" ); - return false; - // If enter or space is pressed, trigger click - case 13: - case 32: - target.trigger( "click" ); - return false; - } - }, - - _handleMenuPageHide: function() { - - // After the dialog's done, we may want to trigger change if the value has actually changed - this._delayedTrigger(); - - // TODO centralize page removal binding / handling in the page plugin. - // Suggestion from @jblas to do refcounting - // - // TODO extremely confusing dependency on the open method where the pagehide.remove - // bindings are stripped to prevent the parent page from disappearing. The way - // we're keeping pages in the DOM right now sucks - // - // rebind the page remove that was unbound in the open function - // to allow for the parent page removal from actions other than the use - // of a dialog sized custom select - // - // doing this here provides for the back button on the custom select dialog - this.thisPage.page( "bindRemove" ); - }, - - _handleHeaderCloseClick: function() { - if ( this.menuType === "overlay" ) { - this.close(); - return false; - } - }, - - _handleListItemClick: function( event ) { - var listItem = $( event.target ).closest( "li" ), - - // Index of option tag to be selected - oldIndex = this.select[ 0 ].selectedIndex, - newIndex = $.mobile.getAttribute( listItem, "option-index" ), - option = this._selectOptions().eq( newIndex )[ 0 ]; - - // Toggle selected status on the tag for multi selects - option.selected = this.isMultiple ? !option.selected : true; - - // Toggle checkbox class for multiple selects - if ( this.isMultiple ) { - listItem.find( "a" ) - .toggleClass( "ui-checkbox-on", option.selected ) - .toggleClass( "ui-checkbox-off", !option.selected ); - } - - // If it's not a multiple select, trigger change after it has finished closing - if ( !this.isMultiple && oldIndex !== newIndex ) { - this._triggerChange = true; - } - - // Trigger change if it's a multiple select - // Hide custom select for single selects only - otherwise focus clicked item - // We need to grab the clicked item the hard way, because the list may have been rebuilt - if ( this.isMultiple ) { - this.select.trigger( "change" ); - this.list.find( "li:not(.ui-li-divider)" ).eq( newIndex ) - .find( "a" ).first().focus(); - } - else { - this.close(); - } - - event.preventDefault(); - }, - - build: function() { - var selectId, popupId, dialogId, label, thisPage, isMultiple, menuId, - themeAttr, overlayTheme, overlayThemeAttr, dividerThemeAttr, - menuPage, listbox, list, header, headerTitle, menuPageContent, - menuPageClose, headerClose, - o = this.options; - - if ( o.nativeMenu ) { - return this._super(); - } - - selectId = this.selectId; - popupId = selectId + "-listbox"; - dialogId = selectId + "-dialog"; - label = this.label; - thisPage = this.element.closest( ".ui-page" ); - isMultiple = this.element[ 0 ].multiple; - menuId = selectId + "-menu"; - themeAttr = o.theme ? ( " data-" + $.mobile.ns + "theme='" + o.theme + "'" ) : ""; - overlayTheme = o.overlayTheme || o.theme || null; - overlayThemeAttr = overlayTheme ? ( " data-" + $.mobile.ns + - "overlay-theme='" + overlayTheme + "'" ) : ""; - dividerThemeAttr = ( o.dividerTheme && isMultiple ) ? ( " data-" + $.mobile.ns + "divider-theme='" + o.dividerTheme + "'" ) : ""; - menuPage = $( "
" + - "
" + - "
"+ - "
"+ - "
"+ - "
" ); - listbox = $( "
" ) - .insertAfter( this.select ) - .popup(); - list = $( "" ).appendTo( listbox ); - header = $( "
" ).prependTo( listbox ); - headerTitle = $( "

" ).appendTo( header ); - - if ( this.isMultiple ) { - headerClose = $( "", { - "role": "button", - "text": o.closeText, - "href": "#", - "class": "ui-btn ui-corner-all ui-btn-left ui-btn-icon-notext ui-icon-delete" - }).appendTo( header ); - } - - $.extend( this, { - selectId: selectId, - menuId: menuId, - popupId: popupId, - dialogId: dialogId, - thisPage: thisPage, - menuPage: menuPage, - label: label, - isMultiple: isMultiple, - theme: o.theme, - listbox: listbox, - list: list, - header: header, - headerTitle: headerTitle, - headerClose: headerClose, - menuPageContent: menuPageContent, - menuPageClose: menuPageClose, - placeholder: "" - }); - - // Create list from select, update state - this.refresh(); - - if ( this._origTabIndex === undefined ) { - // Map undefined to false, because this._origTabIndex === undefined - // indicates that we have not yet checked whether the select has - // originally had a tabindex attribute, whereas false indicates that - // we have checked the select for such an attribute, and have found - // none present. - this._origTabIndex = ( this.select[ 0 ].getAttribute( "tabindex" ) === null ) ? false : this.select.attr( "tabindex" ); - } - this.select.attr( "tabindex", "-1" ); - this._on( this.select, { focus : "_handleSelectFocus" } ); - - // Button events - this._on( this.button, { - vclick: "_handleButtonVclickKeydown" - }); - - // Events for list items - this.list.attr( "role", "listbox" ); - this._on( this.list, { - "focusin": "_handleListFocus", - "focusout": "_handleListFocus", - "keydown": "_handleListKeydown", - "click li:not(.ui-disabled,.ui-state-disabled,.ui-li-divider)": "_handleListItemClick" - }); - - // button refocus ensures proper height calculation - // by removing the inline style and ensuring page inclusion - this._on( this.menuPage, { pagehide: "_handleMenuPageHide" } ); - - // Events on the popup - this._on( this.listbox, { popupafterclose: "_popupClosed" } ); - - // Close button on small overlays - if ( this.isMultiple ) { - this._on( this.headerClose, { click: "_handleHeaderCloseClick" } ); - } - - return this; - }, - - _popupClosed: function() { - this.close(); - this._delayedTrigger(); - }, - - _delayedTrigger: function() { - if ( this._triggerChange ) { - this.element.trigger( "change" ); - } - this._triggerChange = false; - }, - - _isRebuildRequired: function() { - var list = this.list.find( "li" ), - options = this._selectOptions().not( ".ui-screen-hidden" ); - - // TODO exceedingly naive method to determine difference - // ignores value changes etc in favor of a forcedRebuild - // from the user in the refresh method - return options.text() !== list.text(); - }, - - selected: function() { - return this._selectOptions().filter( ":selected:not( :jqmData(placeholder='true') )" ); - }, - - refresh: function( force ) { - var self, indices; - - if ( this.options.nativeMenu ) { - return this._super( force ); - } - - self = this; - if ( force || this._isRebuildRequired() ) { - self._buildList(); - } - - indices = this.selectedIndices(); - - self.setButtonText(); - self.setButtonCount(); - - self.list.find( "li:not(.ui-li-divider)" ) - .find( "a" ).removeClass( $.mobile.activeBtnClass ).end() - .attr( "aria-selected", false ) - .each(function( i ) { - var item = $( this ); - if ( $.inArray( i, indices ) > -1 ) { - - // Aria selected attr - item.attr( "aria-selected", true ); - - // Multiple selects: add the "on" checkbox state to the icon - if ( self.isMultiple ) { - item.find( "a" ).removeClass( "ui-checkbox-off" ).addClass( "ui-checkbox-on" ); - } else { - if ( item.hasClass( "ui-screen-hidden" ) ) { - item.next().find( "a" ).addClass( $.mobile.activeBtnClass ); - } else { - item.find( "a" ).addClass( $.mobile.activeBtnClass ); - } - } - } else if ( self.isMultiple ) { - item.find( "a" ).removeClass( "ui-checkbox-on" ).addClass( "ui-checkbox-off" ); - } - }); - }, - - close: function() { - if ( this.options.disabled || !this.isOpen ) { - return; - } - - var self = this; - - if ( self.menuType === "page" ) { - self.menuPage.dialog( "close" ); - self.list.appendTo( self.listbox ); - } else { - self.listbox.popup( "close" ); - } - - self._focusButton(); - // allow the dialog to be closed again - self.isOpen = false; - }, - - open: function() { - this.button.click(); - }, - - _focusMenuItem: function() { - var selector = this.list.find( "a." + $.mobile.activeBtnClass ); - if ( selector.length === 0 ) { - selector = this.list.find( "li:not(" + unfocusableItemSelector + ") a.ui-btn" ); - } - selector.first().focus(); - }, - - _decideFormat: function() { - var self = this, - $window = this.window, - selfListParent = self.list.parent(), - menuHeight = selfListParent.outerHeight(), - scrollTop = $window.scrollTop(), - btnOffset = self.button.offset().top, - screenHeight = $window.height(); - - if ( menuHeight > screenHeight - 80 || !$.support.scrollTop ) { - - self.menuPage.appendTo( $.mobile.pageContainer ).page(); - self.menuPageContent = self.menuPage.find( ".ui-content" ); - self.menuPageClose = self.menuPage.find( ".ui-header a" ); - - // prevent the parent page from being removed from the DOM, - // otherwise the results of selecting a list item in the dialog - // fall into a black hole - self.thisPage.unbind( "pagehide.remove" ); - - //for WebOS/Opera Mini (set lastscroll using button offset) - if ( scrollTop === 0 && btnOffset > screenHeight ) { - self.thisPage.one( "pagehide", function() { - $( this ).jqmData( "lastScroll", btnOffset ); - }); - } - - self.menuPage.one( { - pageshow: $.proxy( this, "_focusMenuItem" ), - pagehide: $.proxy( this, "close" ) - }); - - self.menuType = "page"; - self.menuPageContent.append( self.list ); - self.menuPage - .find( "div .ui-title" ) - .text( self.label.getEncodedText() || self.placeholder ); - } else { - self.menuType = "overlay"; - - self.listbox.one( { popupafteropen: $.proxy( this, "_focusMenuItem" ) } ); - } - }, - - _buildList: function() { - var self = this, - o = this.options, - placeholder = this.placeholder, - needPlaceholder = true, - dataIcon = "false", - $options, numOptions, select, - dataPrefix = "data-" + $.mobile.ns, - dataIndexAttr = dataPrefix + "option-index", - dataIconAttr = dataPrefix + "icon", - dataRoleAttr = dataPrefix + "role", - dataPlaceholderAttr = dataPrefix + "placeholder", - fragment = document.createDocumentFragment(), - isPlaceholderItem = false, - optGroup, - i, - option, $option, parent, text, anchor, classes, - optLabel, divider, item; - - self.list.empty().filter( ".ui-listview" ).listview( "destroy" ); - $options = this._selectOptions(); - numOptions = $options.length; - select = this.select[ 0 ]; - - for ( i = 0; i < numOptions;i++, isPlaceholderItem = false) { - option = $options[i]; - $option = $( option ); - - // Do not create options based on ui-screen-hidden select options - if ( $option.hasClass( "ui-screen-hidden" ) ) { - continue; - } - - parent = option.parentNode; - classes = []; - - // Although using .text() here raises the risk that, when we later paste this into the - // list item we end up pasting possibly malicious things like \n"; echo " \n"; - echo " \n"; + // echo " \n"; + echo " \n"; echo " \n"; echo " \n"; @@ -828,12 +837,12 @@ class Ui } echo "
\n"; - echo "
\n"; - echo '

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

\n"; + echo "
\n"; + echo '

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

\n"; echo ' '.$this->header['button_left']."\n"; echo ' '.$this->header['button_right']."\n"; echo "
\n"; - echo "
\n"; + echo "
\n"; foreach ($this->content as $content) { echo ' '.$content."\n"; } diff --git a/pandora_console/mobile/include/user.class.php b/pandora_console/mobile/include/user.class.php index 29196eaf4f..627c99dbb2 100644 --- a/pandora_console/mobile/include/user.class.php +++ b/pandora_console/mobile/include/user.class.php @@ -397,10 +397,11 @@ class User $left_button = $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Logout'), - 'href' => 'index.php?action=logout', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Logout'), + 'href' => 'index.php?action=logout', + 'class' => 'header-button-left ui-icon-back', ] ); $ui->createHeader('', $left_button); diff --git a/pandora_console/mobile/operation/agent.php b/pandora_console/mobile/operation/agent.php index 9524f1ee74..35b2155d07 100644 --- a/pandora_console/mobile/operation/agent.php +++ b/pandora_console/mobile/operation/agent.php @@ -125,10 +125,11 @@ class Agent sprintf('%s', $agent_alias), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=agents'.$agents_filter_q_param, + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=agents'.$agents_filter_q_param, + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/agents.php b/pandora_console/mobile/operation/agents.php index da07d31edf..545f8dc38d 100644 --- a/pandora_console/mobile/operation/agents.php +++ b/pandora_console/mobile/operation/agents.php @@ -186,10 +186,11 @@ class Agents __('Agents'), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=home', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/alerts.php b/pandora_console/mobile/operation/alerts.php index b04943fbe3..d898b7584b 100644 --- a/pandora_console/mobile/operation/alerts.php +++ b/pandora_console/mobile/operation/alerts.php @@ -176,10 +176,11 @@ class Alerts __('Alerts'), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=home', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php index 8f097c36c4..cd2616ebb4 100644 --- a/pandora_console/mobile/operation/events.php +++ b/pandora_console/mobile/operation/events.php @@ -609,10 +609,11 @@ class Events __('Events'), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=home', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/groups.php b/pandora_console/mobile/operation/groups.php index ee8ecf0f84..3c7088fd4e 100644 --- a/pandora_console/mobile/operation/groups.php +++ b/pandora_console/mobile/operation/groups.php @@ -77,10 +77,11 @@ class Groups __('Groups'), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=home', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/home.php b/pandora_console/mobile/operation/home.php index 0fa872df7a..f6ea3e60f1 100644 --- a/pandora_console/mobile/operation/home.php +++ b/pandora_console/mobile/operation/home.php @@ -45,19 +45,19 @@ class Home 'name' => __('Tactical view'), 'filename' => 'tactical.php', 'menu_item' => true, - 'icon' => 'tactical_view', + 'icon' => 'ui-icon-tactical_view ui-widget-icon-floatbeginning', ]; $items['events'] = [ 'name' => __('Events'), 'filename' => 'events.php', 'menu_item' => true, - 'icon' => 'events', + 'icon' => 'ui-icon-events ui-widget-icon-floatbeginning', ]; $items['groups'] = [ 'name' => __('Groups'), 'filename' => 'groups.php', 'menu_item' => true, - 'icon' => 'groups', + 'icon' => 'ui-icon-groups ui-widget-icon-floatbeginning', ]; if ((bool) $system->getConfig('legacy_vc', false) === false) { @@ -66,7 +66,7 @@ class Home 'name' => __('Visual consoles'), 'filename' => 'visualmaps.php', 'menu_item' => true, - 'icon' => 'visual_console', + 'icon' => 'ui-icon-visual_console ui-widget-icon-floatbeginning', ]; } @@ -74,21 +74,21 @@ class Home 'name' => __('Alerts'), 'filename' => 'alerts.php', 'menu_item' => true, - 'icon' => 'alerts', + 'icon' => 'ui-icon-alerts ui-widget-icon-floatbeginning', ]; $items['agents'] = [ 'name' => __('Agents'), 'filename' => 'agents.php', 'menu_item' => true, - 'icon' => 'agents', + 'icon' => 'ui-icon-agents ui-widget-icon-floatbeginning', ]; $items['modules'] = [ 'name' => __('Modules'), 'filename' => 'modules.php', 'menu_item' => true, - 'icon' => 'modules', + 'icon' => 'ui-icon-modules ui-widget-icon-floatbeginning', ]; // Not in home. @@ -118,10 +118,11 @@ class Home foreach ($this->pagesItems as $page => $data) { if ($data['menu_item']) { $options = [ - 'icon' => $data['icon'], - 'pos' => 'right', - 'text' => $data['name'], - 'href' => "index.php?page=$page", + 'icon' => $data['icon'], + 'pos' => 'right', + 'text' => $data['name'], + 'href' => "index.php?page=$page", + 'class' => $data['class'], ]; $ui->contentAddHtml($ui->createButton($options)); } @@ -142,10 +143,11 @@ class Home } else { $left_button = $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Logout'), - 'href' => 'index.php?action=logout', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Logout'), + 'href' => 'index.php?action=logout', + 'class' => 'header-button-left', ] ); } diff --git a/pandora_console/mobile/operation/module_graph.php b/pandora_console/mobile/operation/module_graph.php index 2b7a4e06a9..1a1874a234 100644 --- a/pandora_console/mobile/operation/module_graph.php +++ b/pandora_console/mobile/operation/module_graph.php @@ -359,10 +359,11 @@ class ModuleGraph sprintf(__('%s: %s'), get_product_name(), $this->module['nombre']), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=agent&id='.$this->id_agent, + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=agent&id='.$this->id_agent, + 'class' => 'header-button-left', ] ) ); @@ -371,10 +372,11 @@ class ModuleGraph sprintf(__('%s: %s'), get_product_name(), $this->module['nombre']), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=modules', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=modules', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/modules.php b/pandora_console/mobile/operation/modules.php index 052c6aa619..1d0b91bcb5 100644 --- a/pandora_console/mobile/operation/modules.php +++ b/pandora_console/mobile/operation/modules.php @@ -218,10 +218,11 @@ class Modules __('Modules'), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=home', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/tactical.php b/pandora_console/mobile/operation/tactical.php index e88287da6c..51709c9abb 100755 --- a/pandora_console/mobile/operation/tactical.php +++ b/pandora_console/mobile/operation/tactical.php @@ -97,10 +97,11 @@ class Tactical __('Tactical view'), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=home', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/visualmap.php b/pandora_console/mobile/operation/visualmap.php index 1313fc0f24..33043407e0 100644 --- a/pandora_console/mobile/operation/visualmap.php +++ b/pandora_console/mobile/operation/visualmap.php @@ -278,10 +278,11 @@ class Visualmap ), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=visualmaps', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=visualmaps', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/mobile/operation/visualmaps.php b/pandora_console/mobile/operation/visualmaps.php index 1159e14409..905776c816 100644 --- a/pandora_console/mobile/operation/visualmaps.php +++ b/pandora_console/mobile/operation/visualmaps.php @@ -177,10 +177,11 @@ class Visualmaps __('Visual consoles'), $ui->createHeaderButton( [ - 'icon' => 'back', - 'pos' => 'left', - 'text' => __('Back'), - 'href' => 'index.php?page=home', + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=home', + 'class' => 'header-button-left', ] ) ); diff --git a/pandora_console/operation/agentes/agent_fields.php b/pandora_console/operation/agentes/agent_fields.php index bb27bd3f43..3b1c18f7ad 100755 --- a/pandora_console/operation/agentes/agent_fields.php +++ b/pandora_console/operation/agentes/agent_fields.php @@ -27,7 +27,7 @@ if ($id_agente === -1) { if (! check_acl($config['id_user'], $agent['id_grupo'], 'AR')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent General Information' ); include_once 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index 0f89992d3f..63619c80b1 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -82,7 +82,7 @@ if ($user_tag_array) { foreach ($tag_param_validate as $key => $value) { if (!in_array($value, $user_tag_array)) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Alert view' ); include 'general/noaccess.php'; @@ -135,7 +135,10 @@ if ($idAgent != 0) { } if (!check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') && !check_acl_one_of_groups($config['id_user'], $id_group, 'AW')) { - db_pandora_audit('ACL Violation', 'Trying to access alert view'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access alert view' + ); include 'general/noaccess.php'; exit; } @@ -157,7 +160,10 @@ if ($idAgent != 0) { $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); if (!$agent_a && !$agent_w) { - db_pandora_audit('ACL Violation', 'Trying to access alert view'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access alert view' + ); include 'general/noaccess.php'; return; } diff --git a/pandora_console/operation/agentes/custom_fields.php b/pandora_console/operation/agentes/custom_fields.php index ac7501312d..e336826d1f 100644 --- a/pandora_console/operation/agentes/custom_fields.php +++ b/pandora_console/operation/agentes/custom_fields.php @@ -32,7 +32,7 @@ if (!isset($all_groups)) { if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent General Information' ); include_once 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/datos_agente.php b/pandora_console/operation/agentes/datos_agente.php index ed1a328526..e484815650 100755 --- a/pandora_console/operation/agentes/datos_agente.php +++ b/pandora_console/operation/agentes/datos_agente.php @@ -44,7 +44,7 @@ $time_to = (string) get_parameter('time_to', date(TIME_FORMAT)); if (! check_acl($config['id_user'], $group, 'AR') || $module_id == 0) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent Data view' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/ehorus.php b/pandora_console/operation/agentes/ehorus.php index 2529031e2a..eb624bfe5f 100644 --- a/pandora_console/operation/agentes/ehorus.php +++ b/pandora_console/operation/agentes/ehorus.php @@ -34,7 +34,10 @@ if (empty($agent_id)) { $group_id = db_get_value('id_grupo', 'tagente', 'id_agente', $agent_id); if ($group_id === false || (!check_acl($config['id_user'], $group_id, 'AW') && !is_user_admin($config['id_user']))) { - db_pandora_audit('ACL Violation', 'Trying to access eHorus'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access eHorus' + ); include 'general/noaccess.php'; return; } diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 1127cd59b5..8e5590b76a 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -40,7 +40,10 @@ enterprise_include_once('include/functions_config_agents.php'); check_login(); if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) { - db_pandora_audit('ACL Violation', 'Trying to access agent main list view'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access agent main list view' + ); include 'general/noaccess.php'; return; @@ -126,7 +129,7 @@ if (is_ajax()) { $id_agent = (int) modules_get_agentmodule_agent((int) $id_module); if (! check_acl_one_of_groups($config['id_user'], agents_get_all_groups_agent($id_agent), 'AR')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access agent main list view' ); echo json_encode(false); diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 7261944afb..ac2e112347 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -67,7 +67,7 @@ if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') && ! check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') ) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent General Information' ); include_once 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 241cd5aee8..02f683154f 100755 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -139,7 +139,7 @@ if (is_ajax()) { if (!isset($id_agente)) { // This page is included, $id_agente should be passed to it. db_pandora_audit( - 'HACK Attempt', + AUDIT_LOG_HACK_ATTEMPT, 'Trying to get the monitor list without id_agent passed' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/export_csv.php b/pandora_console/operation/agentes/export_csv.php index ea01889713..9b2632db98 100644 --- a/pandora_console/operation/agentes/export_csv.php +++ b/pandora_console/operation/agentes/export_csv.php @@ -31,7 +31,7 @@ if (isset($_GET['agentmodule']) && isset($_GET['agent'])) { $agentmodule_name = modules_get_agentmodule_name($id_agentmodule); if (! check_acl($config['id_user'], agents_get_agent_group($id_agent), 'AR')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent Export Data' ); include '../../general/noaccess.php'; diff --git a/pandora_console/operation/agentes/gis_view.php b/pandora_console/operation/agentes/gis_view.php index a0be08eccd..9f4a11f575 100644 --- a/pandora_console/operation/agentes/gis_view.php +++ b/pandora_console/operation/agentes/gis_view.php @@ -19,7 +19,10 @@ global $config; check_login(); if (! check_acl($config['id_user'], 0, 'MR') && ! check_acl($config['id_user'], 0, 'MW') && ! check_acl($config['id_user'], 0, 'MM') && ! is_user_admin($config['id_user'])) { - db_pandora_audit('ACL Violation', 'Trying to access GIS Agent view'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access GIS Agent view' + ); include 'general/noaccess.php'; return; } diff --git a/pandora_console/operation/agentes/graphs.php b/pandora_console/operation/agentes/graphs.php index 288c6ab5c7..99ae7337bd 100644 --- a/pandora_console/operation/agentes/graphs.php +++ b/pandora_console/operation/agentes/graphs.php @@ -20,7 +20,7 @@ ui_require_javascript_file('calendar'); if (! check_acl($config['id_user'], $id_grupo, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access (read) to agent '.agents_get_name($id_agente) ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 6b39fe2978..9ec0782e1f 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -40,7 +40,7 @@ $agent_w = check_acl($config['id_user'], 0, 'AW'); if (!$agent_a && !$agent_w) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent view (Grouped)' ); include 'general/noaccess.php'; @@ -66,7 +66,10 @@ if (isset($_GET['update_netgroup'])) { ); } } else { - db_pandora_audit('ACL Violation', 'Trying to set flag for groups'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to set flag for groups' + ); include 'general/noaccess.php'; exit; } diff --git a/pandora_console/operation/agentes/interface_view.php b/pandora_console/operation/agentes/interface_view.php index 4f20c459f3..5a76a6afe3 100644 --- a/pandora_console/operation/agentes/interface_view.php +++ b/pandora_console/operation/agentes/interface_view.php @@ -33,7 +33,7 @@ check_login(); if (check_acl($config['id_user'], 0, 'AR') === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent Management' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/networkmap.dinamic.php b/pandora_console/operation/agentes/networkmap.dinamic.php index 29651ca1ad..bd2ed02160 100644 --- a/pandora_console/operation/agentes/networkmap.dinamic.php +++ b/pandora_console/operation/agentes/networkmap.dinamic.php @@ -42,7 +42,7 @@ if (defined('_activeTab_') && _activeTab_ != '_activeTab_') { // Networkmap id required if (!isset($id)) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access node graph builder' ); include 'general/noaccess.php'; @@ -54,7 +54,7 @@ if (!isset($store_group)) { $store_group = db_get_value('id_group', 'tmap', 'id', $id); if ($store_group === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to accessnode graph builder' ); include 'general/noaccess.php'; @@ -77,7 +77,7 @@ if (!isset($networkmap_manage)) { if (!$networkmap_read && !$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access node graph builder' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/pandora_networkmap.editor.php b/pandora_console/operation/agentes/pandora_networkmap.editor.php index ac80801962..9a31923308 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.editor.php +++ b/pandora_console/operation/agentes/pandora_networkmap.editor.php @@ -89,7 +89,7 @@ if ($edit_networkmap) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index c6b5ea71b9..91204eb11e 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -40,7 +40,7 @@ $networkmaps_manage = (bool) check_acl($config['id_user'], 0, 'MM'); if ($networkmaps_read === false && $networkmaps_write === false && $networkmaps_manage === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include $config['homedir'].'/general/noaccess.php'; @@ -76,7 +76,7 @@ if ($save_empty_networkmap === true) { if ($networkmap_write === false && $networkmap_manage === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; @@ -113,7 +113,7 @@ if ($save_empty_networkmap === true) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; @@ -164,7 +164,7 @@ if ($save_empty_networkmap === true) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; @@ -228,7 +228,7 @@ if ($new_networkmap || $save_networkmap) { return; } else { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; @@ -247,7 +247,7 @@ if ($new_networkmap || $save_networkmap) { if ($networkmap_write === false && $networkmap_manage === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; @@ -341,7 +341,7 @@ if ($new_networkmap || $save_networkmap) { if ($networkmap_write === false && $networkmap_manage === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; @@ -409,7 +409,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) { // Networkmap id required if (empty($id)) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; @@ -421,7 +421,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) { if ($id_group_map_old === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to accessnode graph builder' ); include 'general/noaccess.php'; @@ -433,7 +433,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) { if ($networkmap_write === false && $networkmap_manage === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; @@ -453,7 +453,7 @@ else if ($update_networkmap || $copy_networkmap || $delete) { if ($networkmap_write === false && $networkmap_manage === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 7747c0cbdc..de7ef79c77 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -488,7 +488,7 @@ if (is_ajax() === true) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); echo json_encode($return); @@ -550,7 +550,7 @@ if (is_ajax() === true) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); echo json_encode($return); @@ -595,7 +595,7 @@ if (is_ajax() === true) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); echo json_encode($return); @@ -637,7 +637,7 @@ if (is_ajax() === true) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); echo json_encode($return); @@ -952,7 +952,7 @@ if (is_ajax() === true) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); echo json_encode($return); @@ -2020,7 +2020,7 @@ if (is_ajax() === true) { if (!$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); echo json_encode($return); @@ -2244,7 +2244,7 @@ if ($networkmap === false) { if (!$networkmap_read && !$networkmap_write && !$networkmap_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access networkmap' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 5e5ab2b43f..96d1ba3c3f 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -36,7 +36,7 @@ if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], 0, 'AM') ) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent Management' ); include 'general/noaccess.php'; @@ -1777,6 +1777,13 @@ $table->data[4][0] .= __('Not condition').' '.ui_print_help_tip(__('If you } if (!is_snapshot_data($row['datos'])) { + if ($tresholds === true || $graph_type === 'boolean') { + unset($graph_params['histogram']); + } + + $graph_params_str = http_build_query($graph_params); + + $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; $data[8] .= ''.html_print_image('images/chart.png', true, ['border' => '0', 'alt' => '', 'class' => 'invert_filter']).''; } diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index c1274fdc47..7efefea155 100755 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -39,7 +39,7 @@ check_login(); if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Agent view (Grouped)' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/url_address.php b/pandora_console/operation/agentes/url_address.php index 23b2f25eae..d21cade534 100644 --- a/pandora_console/operation/agentes/url_address.php +++ b/pandora_console/operation/agentes/url_address.php @@ -18,7 +18,7 @@ check_login(); if (! check_acl($config['id_user'], $id_grupo, 'AW', $id_agente)) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access agent manager' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 50ba2a7f9c..07e9614857 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -1274,7 +1274,7 @@ $all_groups = agents_get_all_groups_agent($id_agente, $id_grupo); if (! check_acl_one_of_groups($config['id_user'], $all_groups, 'AR') && ! check_acl_one_of_groups($config['id_user'], $all_groups, 'AW', $id_agente)) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access (read) to agent '.agents_get_name($id_agente) ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 047166c887..ec41980b23 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -55,7 +55,7 @@ if (! $event_a && ! $event_m ) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access event viewer' ); if (is_ajax()) { @@ -1003,7 +1003,7 @@ if (is_metaconsole() !== true) { ) { if ($config['show_events_in_local'] == 0) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access event viewer. View disabled due event replication.' ); ui_print_info_message( diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index dc4a0333a9..d5dbc2a13c 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -59,7 +59,7 @@ $access = ($event_a == true) ? 'ER' : (($event_w == true) ? 'EW' : (($event_m == if (!$event_a && !$event_w && !$event_m) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access event viewer' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index 8959ae2f47..0772577784 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -46,7 +46,10 @@ if (check_acl($config['id_user'], 0, 'ER') === false && check_acl($config['id_user'], 0, 'EW') === false && check_acl($config['id_user'], 0, 'EM') === false ) { - db_pandora_audit('ACL Violation', 'Trying to access event viewer'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access event viewer' + ); include 'general/noaccess.php'; return; diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index 8b3455fbf0..6ecb1ed6a4 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -34,7 +34,10 @@ $confMapDefaultUrlFull = json_decode($confMapDefault['conection_data'], true); $confMapUrlDefault = $confMapDefaultFull['url']; if (! check_acl($config['id_user'], $map['group_id'], 'MR') && ! check_acl($config['id_user'], $map['group_id'], 'MW') && ! check_acl($config['id_user'], $map['group_id'], 'MM')) { - db_pandora_audit('ACL Violation', 'Trying to access map builder'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access map builder' + ); include 'general/noaccess.php'; return; } @@ -139,7 +142,7 @@ if ($has_management_acl) { $hash = md5($config['dbpass'].$idMap.$config['id_user']); $buttons['public_link']['text'] = ''.html_print_image('images/camera_mc.png', true, ['title' => __('Show link to public Visual Console'), 'class' => 'invert_filter']).''; + ).'" target="_blank">'.html_print_image('images/camera_mc.png', true, ['title' => __('Show link to public GIS map'), 'class' => 'invert_filter']).''; } $times = [ diff --git a/pandora_console/operation/netflow/netflow_explorer.php b/pandora_console/operation/netflow/netflow_explorer.php index baff5da32f..e191118855 100644 --- a/pandora_console/operation/netflow/netflow_explorer.php +++ b/pandora_console/operation/netflow/netflow_explorer.php @@ -25,7 +25,7 @@ check_login(); // ACL Check. if (! check_acl($config['id_user'], 0, 'AR')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Netflow explorer' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index dcc9e4065e..442b1b2fa5 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -30,7 +30,7 @@ ui_require_javascript_file('calendar'); check_login(); if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access event viewer' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index 2c51c663e2..700f94e01e 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -23,7 +23,7 @@ check_login(); // ACL Check. if (! check_acl($config['id_user'], 0, 'AR')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Network report.' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index 5a91e0563b..8af9ccd485 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -31,7 +31,7 @@ ui_print_page_header(__('Network usage map')); // ACL Check. if (! check_acl($config['id_user'], 0, 'AR')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Network usage map.' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/reporting/graph_viewer.php b/pandora_console/operation/reporting/graph_viewer.php index 4c42ed2ad7..956958a719 100644 --- a/pandora_console/operation/reporting/graph_viewer.php +++ b/pandora_console/operation/reporting/graph_viewer.php @@ -69,7 +69,10 @@ if ($delete_graph) { echo $result; } else { - db_pandora_audit('ACL Violation', 'Trying to delete a graph from access graph builder'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to delete a graph from access graph builder' + ); include 'general/noaccess.php'; exit; } @@ -150,7 +153,7 @@ if ($view_graph) { $name = $graph['name']; if (($graph['private'] == 1) && ($graph['id_user'] != $id_user)) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access to a custom graph not allowed' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index d932a5f477..c1ae891e41 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -21,7 +21,7 @@ $id_report = (int) get_parameter('id'); if (! $id_report) { db_pandora_audit( - 'HACK Attempt', + AUDIT_LOG_HACK_ATTEMPT, 'Trying to access report viewer withoud ID' ); include 'general/noaccess.php'; @@ -36,7 +36,10 @@ enterprise_include_once('include/functions_reporting.php'); if (!reporting_user_can_see_report($id_report)) { - db_pandora_audit('ACL Violation', 'Trying to access report viewer'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access report viewer' + ); include 'general/noaccess.php'; exit; } diff --git a/pandora_console/operation/reporting/reporting_xml.php b/pandora_console/operation/reporting/reporting_xml.php index 6d7a8bfeb2..df8a1644e9 100755 --- a/pandora_console/operation/reporting/reporting_xml.php +++ b/pandora_console/operation/reporting/reporting_xml.php @@ -69,13 +69,17 @@ if (isset($_GET['direct']) && $_GET['direct']) { db_logon($nick, $_SERVER['REMOTE_ADDR']); $_SESSION['id_usuario'] = $nick; $config['id_user'] = $nick; - // Remove everything that might have to do with people's passwords or logins + // Remove everything that might have to do with people's passwords or logins. unset($_GET['pass'], $pass, $_POST['pass'], $_REQUEST['pass'], $login_good); } else { - // User not known + // User not known. $login_failed = true; include_once 'general/login_page.php'; - db_pandora_audit('Logon Failed', 'Invalid login: '.$nick, $nick); + db_pandora_audit( + AUDIT_LOG_USER_REGISTRATION, + 'Invalid login: '.$nick, + $nick + ); exit; } } else { diff --git a/pandora_console/operation/servers/recon_view.php b/pandora_console/operation/servers/recon_view.php index 2cb71042c9..001ede9465 100644 --- a/pandora_console/operation/servers/recon_view.php +++ b/pandora_console/operation/servers/recon_view.php @@ -18,7 +18,7 @@ check_login(); if (! check_acl($config['id_user'], 0, 'PM')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access recon task viewer' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/snmpconsole/snmp_browser.php b/pandora_console/operation/snmpconsole/snmp_browser.php index 39451616e7..d8e8b9e497 100644 --- a/pandora_console/operation/snmpconsole/snmp_browser.php +++ b/pandora_console/operation/snmpconsole/snmp_browser.php @@ -35,7 +35,10 @@ ui_require_jquery_file('pandora.controls'); // Check login and ACLs. check_login(); if (!check_acl($config['id_user'], 0, 'AR')) { - db_pandora_audit('ACL Violation', 'Trying to access SNMP Console'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access SNMP Console' + ); include 'general/noaccess.php'; exit(); } diff --git a/pandora_console/operation/snmpconsole/snmp_mib_uploader.php b/pandora_console/operation/snmpconsole/snmp_mib_uploader.php index fdaff50428..1e5482b016 100644 --- a/pandora_console/operation/snmpconsole/snmp_mib_uploader.php +++ b/pandora_console/operation/snmpconsole/snmp_mib_uploader.php @@ -32,7 +32,10 @@ global $config; check_login(); if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit('ACL Violation', 'Trying to access MIB uploader'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access MIB uploader' + ); include 'general/noaccess.php'; return; } diff --git a/pandora_console/operation/snmpconsole/snmp_statistics.php b/pandora_console/operation/snmpconsole/snmp_statistics.php index ca1a3ce6e7..ff041c3d5d 100755 --- a/pandora_console/operation/snmpconsole/snmp_statistics.php +++ b/pandora_console/operation/snmpconsole/snmp_statistics.php @@ -23,7 +23,7 @@ check_login(); // ACL if (! check_acl($config['id_user'], 0, 'AR')) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access SNMP Console' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index 2641cc51fb..e68a6a16f2 100755 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -40,7 +40,7 @@ $agent_w = check_acl($config['id_user'], 0, 'AW'); $access = ($agent_a == true) ? 'AR' : (($agent_w == true) ? 'AW' : 'AR'); if (!$agent_a && !$agent_w) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access SNMP Console' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/users/user_edit_header.php b/pandora_console/operation/users/user_edit_header.php index 4e28945e04..8f61ef3fb3 100644 --- a/pandora_console/operation/users/user_edit_header.php +++ b/pandora_console/operation/users/user_edit_header.php @@ -55,7 +55,7 @@ if ((!check_acl($config['id_user'], users_get_groups($id), 'UM')) && ($id != $config['id_user']) ) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to view a user without privileges' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/visual_console/legacy_public_view.php b/pandora_console/operation/visual_console/legacy_public_view.php index f7c23f8d00..40ae10e4bc 100644 --- a/pandora_console/operation/visual_console/legacy_public_view.php +++ b/pandora_console/operation/visual_console/legacy_public_view.php @@ -68,7 +68,7 @@ $config['id_user'] = get_parameter('id_user'); // Check input hash. if (User::validatePublicHash($hash) !== true) { db_pandora_audit( - 'Invalid public visual console', + AUDIT_LOG_HACK_ATTEMPT, 'Trying to access public visual console' ); include 'general/noaccess.php'; @@ -79,7 +79,10 @@ $refr = (int) get_parameter('refr', $config['refr']); $layout = db_get_row('tlayout', 'id', $id_layout); if (! $layout) { - db_pandora_audit('ACL Violation', 'Trying to access visual console without id layout'); + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access visual console without id layout' + ); include $config['homedir'].'/general/noaccess.php'; exit; } diff --git a/pandora_console/operation/visual_console/legacy_view.php b/pandora_console/operation/visual_console/legacy_view.php index 3dab575425..a0e4ac2493 100644 --- a/pandora_console/operation/visual_console/legacy_view.php +++ b/pandora_console/operation/visual_console/legacy_view.php @@ -72,7 +72,7 @@ if (isset($config['vc_refr']) && $config['vc_refr'] != 0) { // Get input parameter for layout id if (! $id_layout) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access visual console without id layout' ); include 'general/noaccess.php'; @@ -83,7 +83,7 @@ $layout = db_get_row('tlayout', 'id', $id_layout); if (! $layout) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access visual console without id layout' ); include 'general/noaccess.php'; @@ -105,7 +105,7 @@ $vconsole_manage = check_acl_restricted_all($config['id_user'], $id_group, 'VM') if (! $vconsole_read && !$vconsole_write && !$vconsole_manage) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access visual console without group access' ); include 'general/noaccess.php'; diff --git a/pandora_console/operation/visual_console/public_view.php b/pandora_console/operation/visual_console/public_view.php index 36ec6bf722..f87f3f2d17 100644 --- a/pandora_console/operation/visual_console/public_view.php +++ b/pandora_console/operation/visual_console/public_view.php @@ -72,7 +72,7 @@ if (!isset($config['pure'])) { // Check input hash. if (User::validatePublicHash($hash) !== true) { db_pandora_audit( - 'Invalid public visual console', + AUDIT_LOG_VISUAL_CONSOLE_MANAGEMENT, 'Trying to access public visual console' ); include 'general/noaccess.php'; @@ -86,7 +86,7 @@ try { $visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId]); } catch (Throwable $e) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access visual console without Id' ); include $config['homedir'].'/general/noaccess.php'; diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index 7e18e8ad30..45be07fbcb 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -87,7 +87,7 @@ try { $visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId]); } catch (Throwable $e) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access visual console without Id' ); include 'general/noaccess.php'; @@ -105,7 +105,7 @@ $aclManage = (bool) check_acl_restricted_all($config['id_user'], $groupId, 'VM') if ($aclRead === false && $aclWrite === false && $aclManage === false) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access visual console without group access' ); include 'general/noaccess.php'; diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 02ec7bfc6b..e0de6ec030 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -2,8 +2,8 @@ # Pandora FMS Console # %define name pandorafms_console -%define version 7.0NG.759 -%define release 220202 +%define version 7.0NG.760 +%define release 220218 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 8b4a21c56d..c616d7f589 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -2,8 +2,8 @@ # Pandora FMS Console # %define name pandorafms_console -%define version 7.0NG.759 -%define release 220202 +%define version 7.0NG.760 +%define release 220218 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 1e5d3b7f81..71e63dc895 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -2,8 +2,8 @@ # Pandora FMS Console # %define name pandorafms_console -%define version 7.0NG.759 -%define release 220202 +%define version 7.0NG.760 +%define release 220218 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandora_console_install b/pandora_console/pandora_console_install index 4d9d48f54b..e83befc836 100644 --- a/pandora_console/pandora_console_install +++ b/pandora_console/pandora_console_install @@ -9,7 +9,7 @@ # This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.759" +PI_VERSION="7.0NG.760" FORCE=0 DESTDIR="" LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 1d02f020ed..212a2b3efa 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -28,153 +28,153 @@ -- Table `taddress` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `taddress` ( - `id_a` int(10) unsigned NOT NULL auto_increment, - `ip` varchar(60) NOT NULL default '', - `ip_pack` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id_a`), - KEY `ip` (`ip`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_a` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `ip` VARCHAR(60) NOT NULL DEFAULT '', + `ip_pack` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_a`), + KEY `ip` (`ip`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `taddress_agent` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `taddress_agent` ( - `id_ag` bigint(20) unsigned NOT NULL auto_increment, - `id_a` bigint(20) unsigned NOT NULL default '0', - `id_agent` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`id_ag`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_ag` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_a` BIGINT UNSIGNED NOT NULL DEFAULT 0, + `id_agent` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_ag`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tagente` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente` ( - `id_agente` int(10) unsigned NOT NULL auto_increment, - `nombre` varchar(600) BINARY NOT NULL default '', - `direccion` varchar(100) default NULL, - `comentarios` varchar(255) default '', - `id_grupo` int(10) unsigned NOT NULL default '0', - `ultimo_contacto` datetime NOT NULL default '1970-01-01 00:00:00', - `modo` tinyint(1) NOT NULL default '0', - `intervalo` int(11) unsigned NOT NULL default '300', - `id_os` int(10) unsigned default '0', - `os_version` varchar(100) default '', - `agent_version` varchar(100) default '', - `ultimo_contacto_remoto` datetime default '1970-01-01 00:00:00', - `disabled` tinyint(2) NOT NULL default '0', - `remote` tinyint(1) NOT NULL default 0, - `id_parent` int(10) unsigned default '0', - `custom_id` varchar(255) default '', - `server_name` varchar(100) default '', - `cascade_protection` tinyint(2) NOT NULL default '0', - `cascade_protection_module` int(10) unsigned NOT NULL default '0', - `timezone_offset` TINYINT(2) NULL DEFAULT '0' COMMENT 'nuber of hours of diference with the server timezone' , - `icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' , - `update_gis_data` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it' , - `url_address` mediumtext NULL, - `quiet` tinyint(1) NOT NULL default '0', - `normal_count` bigint(20) NOT NULL default '0', - `warning_count` bigint(20) NOT NULL default '0', - `critical_count` bigint(20) NOT NULL default '0', - `unknown_count` bigint(20) NOT NULL default '0', - `notinit_count` bigint(20) NOT NULL default '0', - `total_count` bigint(20) NOT NULL default '0', - `fired_count` bigint(20) NOT NULL default '0', - `update_module_count` tinyint(1) NOT NULL default '0', - `update_alert_count` tinyint(1) NOT NULL default '0', - `update_secondary_groups` tinyint(1) NOT NULL default '0', - `alias` varchar(600) BINARY NOT NULL default '', - `transactional_agent` tinyint(1) NOT NULL default '0', - `alias_as_name` tinyint(2) NOT NULL default '0', - `safe_mode_module` int(10) unsigned NOT NULL default '0', - `cps` int NOT NULL default 0, - PRIMARY KEY (`id_agente`), - KEY `nombre` (`nombre`(255)), - KEY `direccion` (`direccion`), - KEY `disabled` (`disabled`), - KEY `id_grupo` (`id_grupo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; + `id_agente` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(600) NOT NULL DEFAULT '', + `direccion` VARCHAR(100) DEFAULT NULL, + `comentarios` VARCHAR(255) DEFAULT '', + `id_grupo` INT UNSIGNED NOT NULL DEFAULT 0, + `ultimo_contacto` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `modo` TINYINT NOT NULL DEFAULT 0, + `intervalo` INT UNSIGNED NOT NULL DEFAULT 300, + `id_os` INT UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '', + `agent_version` VARCHAR(100) DEFAULT '', + `ultimo_contacto_remoto` DATETIME DEFAULT '1970-01-01 00:00:00', + `disabled` TINYINT NOT NULL DEFAULT 0, + `remote` TINYINT NOT NULL DEFAULT 0, + `id_parent` INT UNSIGNED DEFAULT 0, + `custom_id` VARCHAR(255) DEFAULT '', + `server_name` VARCHAR(100) DEFAULT '', + `cascade_protection` TINYINT NOT NULL DEFAULT 0, + `cascade_protection_module` INT UNSIGNED NOT NULL DEFAULT 0, + `timezone_offset` TINYINT NULL DEFAULT 0 COMMENT 'nuber of hours of diference with the server timezone', + `icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' , + `update_gis_data` TINYINT NOT NULL DEFAULT 1 COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it', + `url_address` MEDIUMTEXT NULL, + `quiet` TINYINT NOT NULL DEFAULT 0, + `normal_count` BIGINT NOT NULL DEFAULT 0, + `warning_count` BIGINT NOT NULL DEFAULT 0, + `critical_count` BIGINT NOT NULL DEFAULT 0, + `unknown_count` BIGINT NOT NULL DEFAULT 0, + `notinit_count` BIGINT NOT NULL DEFAULT 0, + `total_count` BIGINT NOT NULL DEFAULT 0, + `fired_count` BIGINT NOT NULL DEFAULT 0, + `update_module_count` TINYINT NOT NULL DEFAULT 0, + `update_alert_count` TINYINT NOT NULL DEFAULT 0, + `update_secondary_groups` TINYINT NOT NULL DEFAULT 0, + `alias` VARCHAR(600) NOT NULL DEFAULT '', + `transactional_agent` TINYINT NOT NULL DEFAULT 0, + `alias_as_name` TINYINT NOT NULL DEFAULT 0, + `safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0, + `cps` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_agente`), + KEY `nombre` (`nombre`(255)), + KEY `direccion` (`direccion`), + KEY `disabled` (`disabled`), + KEY `id_grupo` (`id_grupo`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 ; -- --------------------------------------------------------------------- -- Table `tagente_datos` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente_datos` ( - `id_agente_modulo` int(10) unsigned NOT NULL default '0', - `datos` double(50,5) default NULL, - `utimestamp` bigint(20) default '0', - KEY `data_index1` (`id_agente_modulo`, `utimestamp`), - KEY `idx_utimestamp` USING BTREE (`utimestamp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; + `id_agente_modulo` INT UNSIGNED NOT NULL DEFAULT 0, + `datos` DOUBLE DEFAULT NULL, + `utimestamp` BIGINT DEFAULT 0, + KEY `data_index1` (`id_agente_modulo`, `utimestamp`), + KEY `idx_utimestamp` USING BTREE (`utimestamp`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 ; -- --------------------------------------------------------------------- -- Table `tagente_datos_inc` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente_datos_inc` ( - `id_agente_modulo` int(10) unsigned NOT NULL default '0', - `datos` double(50,5) default NULL, - `utimestamp` int(20) unsigned default '0', - KEY `data_inc_index_1` (`id_agente_modulo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agente_modulo` INT UNSIGNED NOT NULL DEFAULT 0, + `datos` DOUBLE DEFAULT NULL, + `utimestamp` INT UNSIGNED DEFAULT 0, + KEY `data_inc_index_1` (`id_agente_modulo`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tagente_datos_string` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente_datos_string` ( - `id_agente_modulo` int(10) unsigned NOT NULL default '0', - `datos` mediumtext NOT NULL, - `utimestamp` int(20) unsigned NOT NULL default 0, - KEY `data_string_index_1` (`id_agente_modulo`, `utimestamp`), - KEY `idx_utimestamp` USING BTREE (`utimestamp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agente_modulo` INT UNSIGNED NOT NULL DEFAULT 0, + `datos` MEDIUMTEXT, + `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, + KEY `data_string_index_1` (`id_agente_modulo`, `utimestamp`), + KEY `idx_utimestamp` USING BTREE (`utimestamp`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tagente_datos_log4x` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente_datos_log4x` ( - `id_tagente_datos_log4x` bigint(20) unsigned NOT NULL auto_increment, - `id_agente_modulo` int(10) unsigned NOT NULL default '0', - - `severity` text NOT NULL, - `message` text NOT NULL, - `stacktrace` text NOT NULL, - - `utimestamp` int(20) unsigned NOT NULL default 0, - PRIMARY KEY (`id_tagente_datos_log4x`), - KEY `data_log4x_index_1` (`id_agente_modulo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_tagente_datos_log4x` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agente_modulo` INT UNSIGNED NOT NULL DEFAULT 0, + + `severity` TEXT, + `message` TEXT, + `stacktrace` TEXT, + + `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_tagente_datos_log4x`), + KEY `data_log4x_index_1` (`id_agente_modulo`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tagente_estado` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente_estado` ( - `id_agente_estado` int(10) unsigned NOT NULL auto_increment, - `id_agente_modulo` int(10) NOT NULL default '0', - `datos` mediumtext NOT NULL, - `timestamp` datetime NOT NULL default '1970-01-01 00:00:00', - `estado` int(4) NOT NULL default '0', - `known_status` tinyint(4) default 0, - `id_agente` int(10) NOT NULL default '0', - `last_try` datetime default NULL, - `utimestamp` bigint(20) NOT NULL default '0', - `current_interval` int(8) unsigned NOT NULL default '0', - `running_by` smallint(4) unsigned default '0', - `last_execution_try` bigint(20) NOT NULL default '0', - `status_changes` tinyint(4) unsigned default 0, - `last_status` tinyint(4) default 0, - `last_known_status` tinyint(4) default 0, - `last_error` int(4) NOT NULL default '0', - `ff_start_utimestamp` bigint(20) default 0, - `ff_normal` int(4) unsigned default '0', - `ff_warning` int(4) unsigned default '0', - `ff_critical` int(4) unsigned default '0', - `last_dynamic_update` bigint(20) NOT NULL default '0', - `last_unknown_update` bigint(20) NOT NULL default '0', - `last_status_change` bigint(20) NOT NULL default '0', - PRIMARY KEY (`id_agente_estado`), - KEY `status_index_1` (`id_agente_modulo`), - KEY `idx_agente` (`id_agente`), - KEY `running_by` (`running_by`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agente_estado` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agente_modulo` INT NOT NULL DEFAULT 0, + `datos` MEDIUMTEXT, + `timestamp` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `estado` INT NOT NULL DEFAULT 0, + `known_status` TINYINT DEFAULT 0, + `id_agente` INT NOT NULL DEFAULT 0, + `last_try` DATETIME DEFAULT NULL, + `utimestamp` BIGINT NOT NULL DEFAULT 0, + `current_interval` INT UNSIGNED NOT NULL DEFAULT 0, + `running_by` SMALLINT UNSIGNED DEFAULT 0, + `last_execution_try` BIGINT NOT NULL DEFAULT 0, + `status_changes` TINYINT UNSIGNED DEFAULT 0, + `last_status` TINYINT DEFAULT 0, + `last_known_status` TINYINT DEFAULT 0, + `last_error` INT NOT NULL DEFAULT 0, + `ff_start_utimestamp` BIGINT DEFAULT 0, + `ff_normal` INT UNSIGNED DEFAULT 0, + `ff_warning` INT UNSIGNED DEFAULT 0, + `ff_critical` INT UNSIGNED DEFAULT 0, + `last_dynamic_update` BIGINT NOT NULL DEFAULT 0, + `last_unknown_update` BIGINT NOT NULL DEFAULT 0, + `last_status_change` BIGINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_agente_estado`), + KEY `status_index_1` (`id_agente_modulo`), + KEY `idx_agente` (`id_agente`), + KEY `running_by` (`running_by`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- Probably last_execution_try index is not useful and loads more than benefits -- ----------------------------------------------------- @@ -190,534 +190,535 @@ CREATE TABLE IF NOT EXISTS `tagente_estado` ( -- 7 - WEB Server (enteprise) CREATE TABLE IF NOT EXISTS `tagente_modulo` ( - `id_agente_modulo` int(10) unsigned NOT NULL auto_increment, - `id_agente` int(10) unsigned NOT NULL default '0', - `id_tipo_modulo` smallint(5) NOT NULL default '0', - `descripcion` TEXT NOT NULL, - `extended_info` TEXT NOT NULL, - `nombre` text NOT NULL, - `unit` text, - `id_policy_module` INTEGER unsigned NOT NULL default '0', - `max` bigint(20) default '0', - `min` bigint(20) default '0', - `module_interval` int(4) unsigned default '0', - `cron_interval` varchar(100) default '', - `module_ff_interval` int(4) unsigned default '0', - `tcp_port` int(4) unsigned default '0', - `tcp_send` TEXT, - `tcp_rcv` TEXT, - `snmp_community` varchar(100) default '', - `snmp_oid` varchar(255) default '0', - `ip_target` varchar(100) default '', - `id_module_group` int(4) unsigned default '0', - `flag` tinyint(1) unsigned default '1', - `id_modulo` int(10) unsigned default '0', - `disabled` tinyint(1) unsigned NOT NULL default '0', - `id_export` smallint(4) unsigned default '0', - `plugin_user` text, - `plugin_pass` text, - `plugin_parameter` text, - `id_plugin` int(10) default '0', - `post_process` double(24,15) default 0, - `prediction_module` bigint(14) default '0', - `max_timeout` int(4) unsigned default '0', - `max_retries` int(4) unsigned default '0', - `custom_id` varchar(255) default '', - `history_data` tinyint(1) unsigned default '1', - `min_warning` double(18,2) default 0, - `max_warning` double(18,2) default 0, - `str_warning` text, - `min_critical` double(18,2) default 0, - `max_critical` double(18,2) default 0, - `str_critical` text, - `min_ff_event` int(4) unsigned default '0', - `delete_pending` int(1) unsigned default 0, - `policy_linked` tinyint(1) unsigned not null default 0, - `policy_adopted` tinyint(1) unsigned not null default 0, - `custom_string_1` mediumtext, - `custom_string_2` text, - `custom_string_3` text, - `custom_integer_1` int(10) default 0, - `custom_integer_2` int(10) default 0, - `wizard_level` enum('basic','advanced','nowizard') default 'nowizard', - `macros` text, - `critical_instructions` text NOT NULL, - `warning_instructions` text NOT NULL, - `unknown_instructions` text NOT NULL, - `quiet` tinyint(1) NOT NULL default '0', - `critical_inverse` tinyint(1) unsigned default '0', - `warning_inverse` tinyint(1) unsigned default '0', - `id_category` int(10) default 0, - `disabled_types_event` TEXT NOT NULL, - `module_macros` TEXT NOT NULL, - `min_ff_event_normal` int(4) unsigned default '0', - `min_ff_event_warning` int(4) unsigned default '0', - `min_ff_event_critical` int(4) unsigned default '0', - `ff_type` tinyint(1) unsigned default '0', - `each_ff` tinyint(1) unsigned default '0', - `ff_timeout` int(4) unsigned default '0', - `dynamic_interval` int(4) unsigned default '0', - `dynamic_max` int(4) default '0', - `dynamic_min` int(4) default '0', - `dynamic_next` bigint(20) NOT NULL default '0', - `dynamic_two_tailed` tinyint(1) unsigned default '0', - `prediction_sample_window` int(10) default 0, - `prediction_samples` int(4) default 0, - `prediction_threshold` int(4) default 0, - `parent_module_id` int(10) unsigned NOT NULL default 0, - `cps` int NOT NULL default 0, - `debug_content` TEXT, - `percentage_critical` tinyint(1) unsigned default '0', - `percentage_warning` tinyint(1) unsigned default '0', - PRIMARY KEY (`id_agente_modulo`), - KEY `main_idx` (`id_agente_modulo`,`id_agente`), - KEY `tam_agente` (`id_agente`), - KEY `id_tipo_modulo` (`id_tipo_modulo`), - KEY `disabled` (`disabled`), - KEY `module` (`id_modulo`), - KEY `nombre` (`nombre` (255)), - KEY `module_group` (`id_module_group`) using btree -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agente_modulo` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agente` INT UNSIGNED NOT NULL DEFAULT 0, + `id_tipo_modulo` SMALLINT NOT NULL DEFAULT 0, + `descripcion` TEXT, + `extended_info` TEXT, + `nombre` TEXT, + `unit` TEXT, + `id_policy_module` INT UNSIGNED NOT NULL DEFAULT 0, + `max` BIGINT DEFAULT 0, + `min` BIGINT DEFAULT 0, + `module_interval` INT UNSIGNED DEFAULT 0, + `cron_interval` VARCHAR(100) DEFAULT '', + `module_ff_interval` INT UNSIGNED DEFAULT 0, + `tcp_port` INT UNSIGNED DEFAULT 0, + `tcp_send` TEXT, + `tcp_rcv` TEXT, + `snmp_community` VARCHAR(100) DEFAULT '', + `snmp_oid` VARCHAR(255) DEFAULT '0', + `ip_target` VARCHAR(100) DEFAULT '', + `id_module_group` INT UNSIGNED DEFAULT 0, + `flag` TINYINT UNSIGNED DEFAULT 1, + `id_modulo` INT UNSIGNED DEFAULT 0, + `disabled` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_export` SMALLINT UNSIGNED DEFAULT 0, + `plugin_user` TEXT, + `plugin_pass` TEXT, + `plugin_parameter` TEXT, + `id_plugin` INT DEFAULT 0, + `post_process` DOUBLE DEFAULT 0, + `prediction_module` BIGINT DEFAULT 0, + `max_timeout` INT UNSIGNED DEFAULT 0, + `max_retries` INT UNSIGNED DEFAULT 0, + `custom_id` VARCHAR(255) DEFAULT '', + `history_data` TINYINT UNSIGNED DEFAULT 1, + `min_warning` DOUBLE DEFAULT 0, + `max_warning` DOUBLE DEFAULT 0, + `str_warning` TEXT, + `min_critical` DOUBLE DEFAULT 0, + `max_critical` DOUBLE DEFAULT 0, + `str_critical` TEXT, + `min_ff_event` INT UNSIGNED DEFAULT 0, + `delete_pending` INT UNSIGNED DEFAULT 0, + `policy_linked` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `policy_adopted` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `custom_string_1` MEDIUMTEXT, + `custom_string_2` TEXT, + `custom_string_3` TEXT, + `custom_integer_1` INT DEFAULT 0, + `custom_integer_2` INT DEFAULT 0, + `wizard_level` ENUM('basic','advanced','nowizard') DEFAULT 'nowizard', + `macros` TEXT, + `critical_instructions` TEXT, + `warning_instructions` TEXT, + `unknown_instructions` TEXT, + `quiet` TINYINT NOT NULL DEFAULT 0, + `critical_inverse` TINYINT UNSIGNED DEFAULT 0, + `warning_inverse` TINYINT UNSIGNED DEFAULT 0, + `id_category` INT DEFAULT 0, + `disabled_types_event` TEXT, + `module_macros` TEXT, + `min_ff_event_normal` INT UNSIGNED DEFAULT 0, + `min_ff_event_warning` INT UNSIGNED DEFAULT 0, + `min_ff_event_critical` INT UNSIGNED DEFAULT 0, + `ff_type` TINYINT UNSIGNED DEFAULT 0, + `each_ff` TINYINT UNSIGNED DEFAULT 0, + `ff_timeout` INT UNSIGNED DEFAULT 0, + `dynamic_interval` INT UNSIGNED DEFAULT 0, + `dynamic_max` INT DEFAULT 0, + `dynamic_min` INT DEFAULT 0, + `dynamic_next` BIGINT NOT NULL DEFAULT 0, + `dynamic_two_tailed` TINYINT UNSIGNED DEFAULT 0, + `prediction_sample_window` INT DEFAULT 0, + `prediction_samples` INT DEFAULT 0, + `prediction_threshold` INT DEFAULT 0, + `parent_module_id` INT UNSIGNED NOT NULL DEFAULT 0, + `cps` INT NOT NULL DEFAULT 0, + `debug_content` TEXT, + `percentage_critical` TINYINT UNSIGNED DEFAULT 0, + `percentage_warning` TINYINT UNSIGNED DEFAULT 0, + PRIMARY KEY (`id_agente_modulo`), + KEY `main_idx` (`id_agente_modulo`,`id_agente`), + KEY `tam_agente` (`id_agente`), + KEY `id_tipo_modulo` (`id_tipo_modulo`), + KEY `disabled` (`disabled`), + KEY `module` (`id_modulo`), + KEY `nombre` (`nombre` (255)), + KEY `module_group` (`id_module_group`) using btree +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- snmp_oid is also used for WMI query -- ----------------------------------------------------- -- Table `tagent_access` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagent_access` ( - `id_agent` int(10) unsigned NOT NULL default '0', - `utimestamp` bigint(20) NOT NULL default '0', - KEY `agent_index` (`id_agent`), - KEY `idx_utimestamp` USING BTREE (`utimestamp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agent` INT UNSIGNED NOT NULL DEFAULT 0, + `utimestamp` BIGINT NOT NULL DEFAULT 0, + KEY `agent_index` (`id_agent`), + KEY `idx_utimestamp` USING BTREE (`utimestamp`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_snmp` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_snmp` ( - `id_as` int(10) unsigned NOT NULL auto_increment, - `id_alert` int(10) unsigned NOT NULL default '0', - `al_field1` text NOT NULL, - `al_field2` text NOT NULL, - `al_field3` text NOT NULL, - `al_field4` text NOT NULL, - `al_field5` text NOT NULL, - `al_field6` text NOT NULL, - `al_field7` text NOT NULL, - `al_field8` text NOT NULL, - `al_field9` text NOT NULL, - `al_field10` text NOT NULL, - `al_field11` text NOT NULL, - `al_field12` text NOT NULL, - `al_field13` text NOT NULL, - `al_field14` text NOT NULL, - `al_field15` text NOT NULL, - `al_field16` text NOT NULL, - `al_field17` text NOT NULL, - `al_field18` text NOT NULL, - `al_field19` text NOT NULL, - `al_field20` text NOT NULL, - `description` varchar(255) default '', - `alert_type` int(2) unsigned NOT NULL default '0', - `agent` varchar(100) default '', - `custom_oid` text, - `oid` varchar(255) NOT NULL default '', - `time_threshold` int(11) NOT NULL default '0', - `times_fired` int(2) unsigned NOT NULL default '0', - `last_fired` datetime NOT NULL default '1970-01-01 00:00:00', - `max_alerts` int(11) NOT NULL default '1', - `min_alerts` int(11) NOT NULL default '1', - `internal_counter` int(2) unsigned NOT NULL default '0', - `priority` tinyint(4) default '0', - `_snmp_f1_` text, - `_snmp_f2_` text, - `_snmp_f3_` text, - `_snmp_f4_` text, - `_snmp_f5_` text, - `_snmp_f6_` text, - `_snmp_f7_` text, - `_snmp_f8_` text, - `_snmp_f9_` text, - `_snmp_f10_` text, - `_snmp_f11_` text, - `_snmp_f12_` text, - `_snmp_f13_` text, - `_snmp_f14_` text, - `_snmp_f15_` text, - `_snmp_f16_` text, - `_snmp_f17_` text, - `_snmp_f18_` text, - `_snmp_f19_` text, - `_snmp_f20_` text, - `trap_type` int(11) NOT NULL default '-1', - `single_value` varchar(255) default '', - `position` int(10) unsigned NOT NULL default '0', - `disable_event` tinyint(1) default 0, - `id_group` int(10) unsigned NOT NULL default '0', - `order_1` int(10) unsigned NOT NULL default 1, - `order_2` int(10) unsigned NOT NULL default 2, - `order_3` int(10) unsigned NOT NULL default 3, - `order_4` int(10) unsigned NOT NULL default 4, - `order_5` int(10) unsigned NOT NULL default 5, - `order_6` int(10) unsigned NOT NULL default 6, - `order_7` int(10) unsigned NOT NULL default 7, - `order_8` int(10) unsigned NOT NULL default 8, - `order_9` int(10) unsigned NOT NULL default 9, - `order_10` int(10) unsigned NOT NULL default 10, - `order_11` int(10) unsigned NOT NULL default 11, - `order_12` int(10) unsigned NOT NULL default 12, - `order_13` int(10) unsigned NOT NULL default 13, - `order_14` int(10) unsigned NOT NULL default 14, - `order_15` int(10) unsigned NOT NULL default 15, - `order_16` int(10) unsigned NOT NULL default 16, - `order_17` int(10) unsigned NOT NULL default 17, - `order_18` int(10) unsigned NOT NULL default 18, - `order_19` int(10) unsigned NOT NULL default 19, - `order_20` int(10) unsigned NOT NULL default 20, - PRIMARY KEY (`id_as`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_as` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_alert` INT UNSIGNED NOT NULL DEFAULT 0, + `al_field1` TEXT, + `al_field2` TEXT, + `al_field3` TEXT, + `al_field4` TEXT, + `al_field5` TEXT, + `al_field6` TEXT, + `al_field7` TEXT, + `al_field8` TEXT, + `al_field9` TEXT, + `al_field10` TEXT, + `al_field11` TEXT, + `al_field12` TEXT, + `al_field13` TEXT, + `al_field14` TEXT, + `al_field15` TEXT, + `al_field16` TEXT, + `al_field17` TEXT, + `al_field18` TEXT, + `al_field19` TEXT, + `al_field20` TEXT, + `description` VARCHAR(255) DEFAULT '', + `alert_type` INT UNSIGNED NOT NULL DEFAULT 0, + `agent` VARCHAR(100) DEFAULT '', + `custom_oid` TEXT, + `oid` VARCHAR(255) NOT NULL DEFAULT '', + `time_threshold` INT NOT NULL DEFAULT 0, + `times_fired` INT UNSIGNED NOT NULL DEFAULT 0, + `last_fired` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `max_alerts` INT NOT NULL DEFAULT 1, + `min_alerts` INT NOT NULL DEFAULT 1, + `internal_counter` INT UNSIGNED NOT NULL DEFAULT 0, + `priority` TINYINT DEFAULT 0, + `_snmp_f1_` TEXT, + `_snmp_f2_` TEXT, + `_snmp_f3_` TEXT, + `_snmp_f4_` TEXT, + `_snmp_f5_` TEXT, + `_snmp_f6_` TEXT, + `_snmp_f7_` TEXT, + `_snmp_f8_` TEXT, + `_snmp_f9_` TEXT, + `_snmp_f10_` TEXT, + `_snmp_f11_` TEXT, + `_snmp_f12_` TEXT, + `_snmp_f13_` TEXT, + `_snmp_f14_` TEXT, + `_snmp_f15_` TEXT, + `_snmp_f16_` TEXT, + `_snmp_f17_` TEXT, + `_snmp_f18_` TEXT, + `_snmp_f19_` TEXT, + `_snmp_f20_` TEXT, + `trap_type` INT NOT NULL DEFAULT -1, + `single_value` VARCHAR(255) DEFAULT '', + `position` INT UNSIGNED NOT NULL DEFAULT 0, + `disable_event` TINYINT DEFAULT 0, + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `order_1` INT UNSIGNED NOT NULL DEFAULT 1, + `order_2` INT UNSIGNED NOT NULL DEFAULT 2, + `order_3` INT UNSIGNED NOT NULL DEFAULT 3, + `order_4` INT UNSIGNED NOT NULL DEFAULT 4, + `order_5` INT UNSIGNED NOT NULL DEFAULT 5, + `order_6` INT UNSIGNED NOT NULL DEFAULT 6, + `order_7` INT UNSIGNED NOT NULL DEFAULT 7, + `order_8` INT UNSIGNED NOT NULL DEFAULT 8, + `order_9` INT UNSIGNED NOT NULL DEFAULT 9, + `order_10` INT UNSIGNED NOT NULL DEFAULT 10, + `order_11` INT UNSIGNED NOT NULL DEFAULT 11, + `order_12` INT UNSIGNED NOT NULL DEFAULT 12, + `order_13` INT UNSIGNED NOT NULL DEFAULT 13, + `order_14` INT UNSIGNED NOT NULL DEFAULT 14, + `order_15` INT UNSIGNED NOT NULL DEFAULT 15, + `order_16` INT UNSIGNED NOT NULL DEFAULT 16, + `order_17` INT UNSIGNED NOT NULL DEFAULT 17, + `order_18` INT UNSIGNED NOT NULL DEFAULT 18, + `order_19` INT UNSIGNED NOT NULL DEFAULT 19, + `order_20` INT UNSIGNED NOT NULL DEFAULT 20, + PRIMARY KEY (`id_as`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_commands` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_commands` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `command` text, - `id_group` mediumint(8) unsigned NULL default 0, - `description` text, - `internal` tinyint(1) default 0, - `fields_descriptions` TEXT, - `fields_values` TEXT, - `fields_hidden` TEXT, - `previous_name` text, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `command` TEXT, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `description` TEXT, + `internal` TINYINT DEFAULT 0, + `fields_descriptions` TEXT, + `fields_values` TEXT, + `fields_hidden` TEXT, + `previous_name` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_actions` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_actions` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` text, - `id_alert_command` int(10) unsigned NULL default 0, - `field1` text NOT NULL, - `field2` text NOT NULL, - `field3` text NOT NULL, - `field4` text NOT NULL, - `field5` text NOT NULL, - `field6` text NOT NULL, - `field7` text NOT NULL, - `field8` text NOT NULL, - `field9` text NOT NULL, - `field10` text NOT NULL, - `field11` text NOT NULL, - `field12` text NOT NULL, - `field13` text NOT NULL, - `field14` text NOT NULL, - `field15` text NOT NULL, - `field16` text NOT NULL, - `field17` text NOT NULL, - `field18` text NOT NULL, - `field19` text NOT NULL, - `field20` text NOT NULL, - `id_group` mediumint(8) unsigned NULL default 0, - `action_threshold` int(10) NOT NULL default '0', - `field1_recovery` text NOT NULL, - `field2_recovery` text NOT NULL, - `field3_recovery` text NOT NULL, - `field4_recovery` text NOT NULL, - `field5_recovery` text NOT NULL, - `field6_recovery` text NOT NULL, - `field7_recovery` text NOT NULL, - `field8_recovery` text NOT NULL, - `field9_recovery` text NOT NULL, - `field10_recovery` text NOT NULL, - `field11_recovery` text NOT NULL, - `field12_recovery` text NOT NULL, - `field13_recovery` text NOT NULL, - `field14_recovery` text NOT NULL, - `field15_recovery` text NOT NULL, - `field16_recovery` text NOT NULL, - `field17_recovery` text NOT NULL, - `field18_recovery` text NOT NULL, - `field19_recovery` text NOT NULL, - `field20_recovery` text NOT NULL, - `previous_name` text, - `create_wu_integria` tinyint(1) default NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TEXT, + `id_alert_command` INT UNSIGNED NULL DEFAULT 0, + `field1` TEXT, + `field2` TEXT, + `field3` TEXT, + `field4` TEXT, + `field5` TEXT, + `field6` TEXT, + `field7` TEXT, + `field8` TEXT, + `field9` TEXT, + `field10` TEXT, + `field11` TEXT, + `field12` TEXT, + `field13` TEXT, + `field14` TEXT, + `field15` TEXT, + `field16` TEXT, + `field17` TEXT, + `field18` TEXT, + `field19` TEXT, + `field20` TEXT, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `action_threshold` INT NOT NULL DEFAULT 0, + `field1_recovery` TEXT, + `field2_recovery` TEXT, + `field3_recovery` TEXT, + `field4_recovery` TEXT, + `field5_recovery` TEXT, + `field6_recovery` TEXT, + `field7_recovery` TEXT, + `field8_recovery` TEXT, + `field9_recovery` TEXT, + `field10_recovery` TEXT, + `field11_recovery` TEXT, + `field12_recovery` TEXT, + `field13_recovery` TEXT, + `field14_recovery` TEXT, + `field15_recovery` TEXT, + `field16_recovery` TEXT, + `field17_recovery` TEXT, + `field18_recovery` TEXT, + `field19_recovery` TEXT, + `field20_recovery` TEXT, + `previous_name` TEXT, + `create_wu_integria` TINYINT DEFAULT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_templates` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_templates` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` text, - `description` mediumtext, - `id_alert_action` int(10) unsigned NULL, - `field1` text NOT NULL, - `field2` text NOT NULL, - `field3` text NOT NULL, - `field4` text NOT NULL, - `field5` text NOT NULL, - `field6` text NOT NULL, - `field7` text NOT NULL, - `field8` text NOT NULL, - `field9` text NOT NULL, - `field10` text NOT NULL, - `field11` text NOT NULL, - `field12` text NOT NULL, - `field13` text NOT NULL, - `field14` text NOT NULL, - `field15` text NOT NULL, - `field16` text NOT NULL, - `field17` text NOT NULL, - `field18` text NOT NULL, - `field19` text NOT NULL, - `field20` text NOT NULL, - `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown', 'always', 'not_normal'), - `value` varchar(255) default '', - `matches_value` tinyint(1) default 0, - `max_value` double(18,2) default NULL, - `min_value` double(18,2) default NULL, - `time_threshold` int(10) NOT NULL default '0', - `max_alerts` int(4) unsigned NOT NULL default '1', - `min_alerts` int(4) unsigned NOT NULL default '0', - `time_from` time default '00:00:00', - `time_to` time default '00:00:00', - `monday` tinyint(1) default 1, - `tuesday` tinyint(1) default 1, - `wednesday` tinyint(1) default 1, - `thursday` tinyint(1) default 1, - `friday` tinyint(1) default 1, - `saturday` tinyint(1) default 1, - `sunday` tinyint(1) default 1, - `recovery_notify` tinyint(1) default '0', - `field1_recovery` text NOT NULL, - `field2_recovery` text NOT NULL, - `field3_recovery` text NOT NULL, - `field4_recovery` text NOT NULL, - `field5_recovery` text NOT NULL, - `field6_recovery` text NOT NULL, - `field7_recovery` text NOT NULL, - `field8_recovery` text NOT NULL, - `field9_recovery` text NOT NULL, - `field10_recovery` text NOT NULL, - `field11_recovery` text NOT NULL, - `field12_recovery` text NOT NULL, - `field13_recovery` text NOT NULL, - `field14_recovery` text NOT NULL, - `field15_recovery` text NOT NULL, - `field16_recovery` text NOT NULL, - `field17_recovery` text NOT NULL, - `field18_recovery` text NOT NULL, - `field19_recovery` text NOT NULL, - `field20_recovery` text NOT NULL, - `priority` tinyint(4) default '0', - `id_group` mediumint(8) unsigned NULL default 0, - `special_day` tinyint(1) default 0, - `wizard_level` enum('basic','advanced','nowizard') default 'nowizard', - `min_alerts_reset_counter` tinyint(1) default 0, - `disable_event` tinyint(1) default 0, - `previous_name` text, - PRIMARY KEY (`id`), - KEY `idx_template_action` (`id_alert_action`), - FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) - ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TEXT, + `description` MEDIUMTEXT, + `id_alert_action` INT UNSIGNED NULL, + `field1` TEXT, + `field2` TEXT, + `field3` TEXT, + `field4` TEXT, + `field5` TEXT, + `field6` TEXT, + `field7` TEXT, + `field8` TEXT, + `field9` TEXT, + `field10` TEXT, + `field11` TEXT, + `field12` TEXT, + `field13` TEXT, + `field14` TEXT, + `field15` TEXT, + `field16` TEXT, + `field17` TEXT, + `field18` TEXT, + `field19` TEXT, + `field20` TEXT, + `type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal', 'warning', 'critical', 'onchange', 'unknown', 'always', 'not_normal'), + `value` VARCHAR(255) DEFAULT '', + `matches_value` TINYINT DEFAULT 0, + `max_value` DOUBLE DEFAULT NULL, + `min_value` DOUBLE DEFAULT NULL, + `time_threshold` INT NOT NULL DEFAULT 0, + `max_alerts` INT UNSIGNED NOT NULL DEFAULT 1, + `min_alerts` INT UNSIGNED NOT NULL DEFAULT 0, + `time_from` time DEFAULT '00:00:00', + `time_to` time DEFAULT '00:00:00', + `monday` TINYINT DEFAULT 1, + `tuesday` TINYINT DEFAULT 1, + `wednesday` TINYINT DEFAULT 1, + `thursday` TINYINT DEFAULT 1, + `friday` TINYINT DEFAULT 1, + `saturday` TINYINT DEFAULT 1, + `sunday` TINYINT DEFAULT 1, + `recovery_notify` TINYINT DEFAULT 0, + `field1_recovery` TEXT, + `field2_recovery` TEXT, + `field3_recovery` TEXT, + `field4_recovery` TEXT, + `field5_recovery` TEXT, + `field6_recovery` TEXT, + `field7_recovery` TEXT, + `field8_recovery` TEXT, + `field9_recovery` TEXT, + `field10_recovery` TEXT, + `field11_recovery` TEXT, + `field12_recovery` TEXT, + `field13_recovery` TEXT, + `field14_recovery` TEXT, + `field15_recovery` TEXT, + `field16_recovery` TEXT, + `field17_recovery` TEXT, + `field18_recovery` TEXT, + `field19_recovery` TEXT, + `field20_recovery` TEXT, + `priority` TINYINT DEFAULT 0, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `special_day` TINYINT DEFAULT 0, + `wizard_level` ENUM('basic','advanced','nowizard') DEFAULT 'nowizard', + `min_alerts_reset_counter` TINYINT DEFAULT 0, + `disable_event` TINYINT DEFAULT 0, + `previous_name` TEXT, + `schedule` TEXT, + PRIMARY KEY (`id`), + KEY `idx_template_action` (`id_alert_action`), + FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) + ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_template_modules` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_template_modules` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_agent_module` int(10) unsigned NOT NULL, - `id_alert_template` int(10) unsigned NOT NULL, - `id_policy_alerts` int(10) unsigned NOT NULL default '0', - `internal_counter` int(4) default '0', - `last_fired` bigint(20) NOT NULL default '0', - `last_reference` bigint(20) NOT NULL default '0', - `times_fired` int(3) NOT NULL default '0', - `disabled` tinyint(1) default '0', - `standby` tinyint(1) default '0', - `priority` tinyint(4) default '0', - `force_execution` tinyint(1) default '0', - PRIMARY KEY (`id`), - KEY `idx_template_module` (`id_agent_module`), - FOREIGN KEY (`id_agent_module`) REFERENCES tagente_modulo(`id_agente_modulo`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`id_alert_template`) REFERENCES talert_templates(`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - UNIQUE (`id_agent_module`, `id_alert_template`), - INDEX force_execution (`force_execution`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agent_module` INT UNSIGNED NOT NULL, + `id_alert_template` INT UNSIGNED NOT NULL, + `id_policy_alerts` INT UNSIGNED NOT NULL DEFAULT 0, + `internal_counter` INT DEFAULT 0, + `last_fired` BIGINT NOT NULL DEFAULT 0, + `last_reference` BIGINT NOT NULL DEFAULT 0, + `times_fired` INT NOT NULL DEFAULT 0, + `disabled` TINYINT DEFAULT 0, + `standby` TINYINT DEFAULT 0, + `priority` TINYINT DEFAULT 0, + `force_execution` TINYINT DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_template_module` (`id_agent_module`), + FOREIGN KEY (`id_agent_module`) REFERENCES tagente_modulo(`id_agente_modulo`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`id_alert_template`) REFERENCES talert_templates(`id`) + ON DELETE CASCADE ON UPDATE CASCADE, + UNIQUE (`id_agent_module`, `id_alert_template`), + INDEX force_execution (`force_execution`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_template_module_actions` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_template_module_actions` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_alert_template_module` int(10) unsigned NOT NULL, - `id_alert_action` int(10) unsigned NOT NULL, - `fires_min` int(3) unsigned default 0, - `fires_max` int(3) unsigned default 0, - `module_action_threshold` int(10) NOT NULL default '0', - `last_execution` bigint(20) NOT NULL default '0', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_alert_template_module` INT UNSIGNED NOT NULL, + `id_alert_action` INT UNSIGNED NOT NULL, + `fires_min` INT UNSIGNED DEFAULT 0, + `fires_max` INT UNSIGNED DEFAULT 0, + `module_action_threshold` INT NOT NULL DEFAULT 0, + `last_execution` BIGINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_calendar` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_calendar` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(100) NOT NULL default '', - `id_group` INT(10) NOT NULL DEFAULT 0, - `description` text, - PRIMARY KEY (`id`), - UNIQUE (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `id_group` INT NOT NULL DEFAULT 0, + `description` TEXT, + PRIMARY KEY (`id`), + UNIQUE (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_special_days` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_special_days` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_calendar` int(10) unsigned NOT NULL DEFAULT 1, - `id_group` INT(10) NOT NULL DEFAULT 0, - `date` date NOT NULL DEFAULT '1970-01-01', - `day_code` tinyint(2) NOT NULL, - `description` text, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_calendar`) REFERENCES talert_calendar(`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_calendar` INT UNSIGNED NOT NULL DEFAULT 1, + `id_group` INT NOT NULL DEFAULT 0, + `date` date NOT NULL DEFAULT '1970-01-01', + `day_code` TINYINT NOT NULL, + `description` TEXT, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_calendar`) REFERENCES talert_calendar(`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `talert_execution_queue` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_execution_queue` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_alert_template_module` int(10) unsigned NOT NULL, - `alert_mode` tinyint(1) NOT NULL, - `data` mediumtext NOT NULL, - `extra_macros` text, - `utimestamp` bigint(20) NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_alert_template_module` INT UNSIGNED NOT NULL, + `alert_mode` TINYINT NOT NULL, + `data` MEDIUMTEXT, + `extra_macros` TEXT, + `utimestamp` BIGINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tattachment` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tattachment` ( - `id_attachment` int(10) unsigned NOT NULL auto_increment, - `id_incidencia` int(10) unsigned NOT NULL default '0', - `id_usuario` varchar(60) NOT NULL default '', - `filename` varchar(255) NOT NULL default '', - `description` varchar(150) default '', - `size` bigint(20) unsigned NOT NULL default '0', - PRIMARY KEY (`id_attachment`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_attachment` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_incidencia` INT UNSIGNED NOT NULL DEFAULT 0, + `id_usuario` VARCHAR(60) NOT NULL DEFAULT '', + `filename` VARCHAR(255) NOT NULL DEFAULT '', + `description` VARCHAR(150) DEFAULT '', + `size` BIGINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_attachment`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tconfig` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tconfig` ( - `id_config` int(10) unsigned NOT NULL auto_increment, - `token` varchar(100) NOT NULL default '', - `value` text NOT NULL, - PRIMARY KEY (`id_config`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_config` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `token` VARCHAR(100) NOT NULL DEFAULT '', + `value` TEXT, + PRIMARY KEY (`id_config`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tconfig_os` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tconfig_os` ( - `id_os` int(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `description` varchar(250) default '', - `icon_name` varchar(100) default '', - `previous_name` text NULL, - PRIMARY KEY (`id_os`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_os` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `description` VARCHAR(250) DEFAULT '', + `icon_name` VARCHAR(100) DEFAULT '', + `previous_name` TEXT NULL, + PRIMARY KEY (`id_os`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tcontainer` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tcontainer` ( - `id_container` mediumint(4) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `parent` mediumint(4) unsigned NOT NULL default 0, - `disabled` tinyint(3) unsigned NOT NULL default 0, - `id_group` mediumint(8) unsigned NULL default 0, - `description` TEXT NOT NULL, - PRIMARY KEY (`id_container`), - KEY `parent_index` (`parent`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_container` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `parent` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `disabled` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `description` TEXT, + PRIMARY KEY (`id_container`), + KEY `parent_index` (`parent`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tcontainer_item` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tcontainer_item` ( - `id_ci` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_container` mediumint(4) unsigned NOT NULL default 0, - `type` varchar(30) default 'simple_graph', - `id_agent` int(10) unsigned NOT NULL default 0, - `id_agent_module` bigint(14) unsigned NULL default NULL, - `time_lapse` int(11) NOT NULL default 0, - `id_graph` INTEGER UNSIGNED default 0, - `only_average` tinyint (1) unsigned default 0 not null, - `id_group` INT (10) unsigned NOT NULL DEFAULT 0, - `id_module_group` INT (10) unsigned NOT NULL DEFAULT 0, - `agent` varchar(100) NOT NULL default '', - `module` varchar(100) NOT NULL default '', - `id_tag` integer(10) unsigned NOT NULL DEFAULT 0, - `type_graph` tinyint(1) unsigned NOT NULL DEFAULT 0, - `fullscale` tinyint(1) UNSIGNED NOT NULL default 0, - PRIMARY KEY(`id_ci`), - FOREIGN KEY (`id_container`) REFERENCES tcontainer(`id_container`) - ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_ci` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_container` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `type` VARCHAR(30) DEFAULT 'simple_graph', + `id_agent` INT UNSIGNED NOT NULL DEFAULT 0, + `id_agent_module` BIGINT UNSIGNED NULL DEFAULT NULL, + `time_lapse` INT NOT NULL DEFAULT 0, + `id_graph` INT UNSIGNED DEFAULT 0, + `only_average` TINYINT UNSIGNED DEFAULT 0 NOT NULL, + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `id_module_group` INT UNSIGNED NOT NULL DEFAULT 0, + `agent` VARCHAR(100) NOT NULL DEFAULT '', + `module` VARCHAR(100) NOT NULL DEFAULT '', + `id_tag` INT UNSIGNED NOT NULL DEFAULT 0, + `type_graph` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `fullscale` TINYINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id_ci`), + FOREIGN KEY (`id_container`) REFERENCES `tcontainer`(`id_container`) + ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tevento` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tevento` ( - `id_evento` bigint(20) unsigned NOT NULL auto_increment, - `id_agente` int(10) NOT NULL default '0', - `id_usuario` varchar(100) NOT NULL default '0', - `id_grupo` mediumint(4) NOT NULL default '0', - `estado` tinyint(3) unsigned NOT NULL default '0', - `timestamp` datetime NOT NULL default '1970-01-01 00:00:00', - `evento` text NOT NULL, - `utimestamp` bigint(20) NOT NULL default '0', - `event_type` enum('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change', 'ncm') default 'unknown', - `id_agentmodule` int(10) NOT NULL default '0', - `id_alert_am` int(10) NOT NULL default '0', - `criticity` int(4) unsigned NOT NULL default '0', - `user_comment` text NOT NULL, - `tags` text NOT NULL, - `source` tinytext NOT NULL, - `id_extra` tinytext NOT NULL, - `critical_instructions` text NOT NULL, - `warning_instructions` text NOT NULL, - `unknown_instructions` text NOT NULL, - `owner_user` VARCHAR(100) NOT NULL DEFAULT '', - `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', - `custom_data` TEXT NOT NULL, - `data` tinytext default NULL, - `module_status` int(4) NOT NULL default '0', - PRIMARY KEY (`id_evento`), - KEY `idx_agente` (`id_agente`), - KEY `idx_agentmodule` (`id_agentmodule`), - KEY `idx_utimestamp` USING BTREE (`utimestamp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_evento` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agente` INT NOT NULL DEFAULT 0, + `id_usuario` VARCHAR(100) NOT NULL DEFAULT '0', + `id_grupo` MEDIUMINT NOT NULL DEFAULT 0, + `estado` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `timestamp` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `evento` TEXT, + `utimestamp` BIGINT NOT NULL DEFAULT 0, + `event_type` ENUM('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change', 'ncm') DEFAULT 'unknown', + `id_agentmodule` INT NOT NULL DEFAULT 0, + `id_alert_am` INT NOT NULL DEFAULT 0, + `criticity` INT UNSIGNED NOT NULL DEFAULT 0, + `user_comment` TEXT, + `tags` TEXT, + `source` TINYTEXT, + `id_extra` TINYTEXT, + `critical_instructions` TEXT, + `warning_instructions` TEXT, + `unknown_instructions` TEXT, + `owner_user` VARCHAR(100) NOT NULL DEFAULT '', + `ack_utimestamp` BIGINT NOT NULL DEFAULT 0, + `custom_data` TEXT, + `data` TINYTEXT, + `module_status` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_evento`), + KEY `idx_agente` (`id_agente`), + KEY `idx_agentmodule` (`id_agentmodule`), + KEY `idx_utimestamp` USING BTREE (`utimestamp`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- Criticity: 0 - Maintance (grey) -- Criticity: 1 - Informational (blue) -- Criticity: 2 - Normal (green) (status 0) @@ -728,102 +729,102 @@ CREATE TABLE IF NOT EXISTS `tevento` ( -- Table `tevent_extended` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tevent_extended` ( - `id` serial PRIMARY KEY, - `id_evento` bigint(20) unsigned NOT NULL, - `external_id` bigint(20) unsigned, - `utimestamp` bigint(20) NOT NULL default '0', - `description` text, - FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` serial PRIMARY KEY, + `id_evento` BIGINT UNSIGNED NOT NULL, + `external_id` BIGINT UNSIGNED, + `utimestamp` BIGINT NOT NULL DEFAULT 0, + `description` TEXT, + FOREIGN KEY `tevent_ext_fk`(`id_evento`) REFERENCES `tevento`(`id_evento`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tgrupo` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgrupo` ( - `id_grupo` mediumint(4) unsigned NOT NULL auto_increment, - `nombre` varchar(100) NOT NULL default '', - `icon` varchar(50) default 'world', - `parent` mediumint(4) unsigned NOT NULL default '0', - `propagate` tinyint(1) unsigned NOT NULL default '0', - `disabled` tinyint(3) unsigned NOT NULL default '0', - `custom_id` varchar(255) default '', - `id_skin` int(10) unsigned NOT NULL default '0', - `description` text, - `contact` text, - `other` text, - `password` varchar(45) default '', - `max_agents` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id_grupo`), - KEY `parent_index` (`parent`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_grupo` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(100) NOT NULL DEFAULT '', + `icon` VARCHAR(50) DEFAULT 'world', + `parent` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `propagate` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `disabled` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `custom_id` VARCHAR(255) DEFAULT '', + `id_skin` INT UNSIGNED NOT NULL DEFAULT 0, + `description` TEXT, + `contact` TEXT, + `other` TEXT, + `password` VARCHAR(45) DEFAULT '', + `max_agents` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_grupo`), + KEY `parent_index` (`parent`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tcredential_store` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tcredential_store` ( - `identifier` varchar(100) NOT NULL, - `id_group` mediumint(4) unsigned NOT NULL DEFAULT 0, - `product` enum('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP') default 'CUSTOM', - `username` text, - `password` text, - `extra_1` text, - `extra_2` text, - PRIMARY KEY (`identifier`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `identifier` VARCHAR(100) NOT NULL, + `id_group` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `product` ENUM('CUSTOM', 'AWS', 'AZURE', 'GOOGLE', 'SAP') DEFAULT 'CUSTOM', + `username` TEXT, + `password` TEXT, + `extra_1` TEXT, + `extra_2` TEXT, + PRIMARY KEY (`identifier`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tincidencia` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tincidencia` ( - `id_incidencia` bigint(6) unsigned zerofill NOT NULL auto_increment, - `inicio` datetime NOT NULL default '1970-01-01 00:00:00', - `cierre` datetime NOT NULL default '1970-01-01 00:00:00', - `titulo` text NOT NULL, - `descripcion` text NOT NULL, - `id_usuario` varchar(60) NOT NULL default '', - `origen` varchar(100) NOT NULL default '', - `estado` int(10) NOT NULL default '0', - `prioridad` int(10) NOT NULL default '0', - `id_grupo` mediumint(4) unsigned NOT NULL default '0', - `actualizacion` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `id_creator` varchar(60) default NULL, - `id_lastupdate` varchar(60) default NULL, - `id_agente_modulo` bigint(100) NOT NULL, - `notify_email` tinyint(3) unsigned NOT NULL default '0', - `id_agent` int(10) unsigned NULL default 0, - PRIMARY KEY (`id_incidencia`), - KEY `incident_index_1` (`id_usuario`,`id_incidencia`), - KEY `id_agente_modulo` (`id_agente_modulo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_incidencia` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `inicio` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `cierre` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `titulo` TEXT, + `descripcion` TEXT, + `id_usuario` VARCHAR(60) NOT NULL DEFAULT '', + `origen` VARCHAR(100) NOT NULL DEFAULT '', + `estado` INT NOT NULL DEFAULT 0, + `prioridad` INT NOT NULL DEFAULT 0, + `id_grupo` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `actualizacion` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `id_creator` VARCHAR(60) DEFAULT NULL, + `id_lastupdate` VARCHAR(60) DEFAULT NULL, + `id_agente_modulo` BIGINT NOT NULL, + `notify_email` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_agent` INT UNSIGNED NULL DEFAULT 0, + PRIMARY KEY (`id_incidencia`), + KEY `incident_index_1` (`id_usuario`,`id_incidencia`), + KEY `id_agente_modulo` (`id_agente_modulo`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tlanguage` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlanguage` ( - `id_language` varchar(6) NOT NULL default '', - `name` varchar(100) NOT NULL default '', - PRIMARY KEY (`id_language`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_language` VARCHAR(6) NOT NULL DEFAULT '', + `name` VARCHAR(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id_language`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tlink` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlink` ( - `id_link` int(10) unsigned zerofill NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `link` varchar(255) NOT NULL default '', - PRIMARY KEY (`id_link`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_link` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `link` VARCHAR(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id_link`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tmodule_group` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmodule_group` ( - `id_mg` tinyint(4) unsigned NOT NULL auto_increment, - `name` varchar(150) NOT NULL default '', - PRIMARY KEY (`id_mg`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_mg` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(150) NOT NULL DEFAULT '', + PRIMARY KEY (`id_mg`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- This table was moved cause the `tmodule_relationship` will add -- a foreign key for the trecon_task(id_rt) @@ -831,331 +832,331 @@ CREATE TABLE IF NOT EXISTS `tmodule_group` ( -- Table `trecon_task` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `trecon_task` ( - `id_rt` int(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `description` varchar(250) NOT NULL default '', - `subnet` text NOT NULL, - `id_network_profile` text, - `review_mode` tinyint(1) unsigned NOT NULL default 1, - `id_group` int(10) unsigned NOT NULL default 1, - `utimestamp` bigint(20) unsigned NOT NULL default 0, - `status` tinyint(4) NOT NULL default 0, - `interval_sweep` int(10) unsigned NOT NULL default 0, - `id_recon_server` int(10) unsigned NOT NULL default 0, - `id_os` tinyint(4) NOT NULL default 0, - `recon_ports` varchar(250) NOT NULL default '', - `snmp_community` varchar(64) NOT NULL default 'public', - `id_recon_script` int(10), - `field1` text NOT NULL, - `field2` varchar(250) NOT NULL default '', - `field3` varchar(250) NOT NULL default '', - `field4` varchar(250) NOT NULL default '', - `os_detect` tinyint(1) unsigned default 0, - `resolve_names` tinyint(1) unsigned default 0, - `parent_detection` tinyint(1) unsigned default 0, - `parent_recursion` tinyint(1) unsigned default 0, - `disabled` tinyint(1) unsigned NOT NULL DEFAULT 0, - `macros` TEXT, - `alias_as_name` tinyint(2) NOT NULL default 0, - `snmp_enabled` tinyint(1) unsigned default 0, - `vlan_enabled` tinyint(1) unsigned default 0, - `snmp_version` varchar(5) NOT NULL default 1, - `snmp_auth_user` varchar(255) NOT NULL default '', - `snmp_auth_pass` varchar(255) NOT NULL default '', - `snmp_auth_method` varchar(25) NOT NULL default '', - `snmp_privacy_method` varchar(25) NOT NULL default '', - `snmp_privacy_pass` varchar(255) NOT NULL default '', - `snmp_security_level` varchar(25) NOT NULL default '', - `wmi_enabled` tinyint(1) unsigned DEFAULT 0, - `rcmd_enabled` tinyint(1) unsigned DEFAULT 0, - `auth_strings` text, - `auto_monitor` TINYINT(1) UNSIGNED DEFAULT 1, - `autoconfiguration_enabled` tinyint(1) unsigned default 0, - `summary` text, - `type` int NOT NULL default 0, - `subnet_csv` TINYINT(1) UNSIGNED DEFAULT 0, - PRIMARY KEY (`id_rt`), - KEY `recon_task_daemon` (`id_recon_server`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_rt` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `description` VARCHAR(250) NOT NULL DEFAULT '', + `subnet` TEXT, + `id_network_profile` TEXT, + `review_mode` TINYINT UNSIGNED NOT NULL DEFAULT 1, + `id_group` INT UNSIGNED NOT NULL DEFAULT 1, + `utimestamp` BIGINT UNSIGNED NOT NULL DEFAULT 0, + `status` TINYINT NOT NULL DEFAULT 0, + `interval_sweep` INT UNSIGNED NOT NULL DEFAULT 0, + `id_recon_server` INT UNSIGNED NOT NULL DEFAULT 0, + `id_os` TINYINT NOT NULL DEFAULT 0, + `recon_ports` VARCHAR(250) NOT NULL DEFAULT '', + `snmp_community` VARCHAR(64) NOT NULL DEFAULT 'public', + `id_recon_script` INT, + `field1` TEXT, + `field2` VARCHAR(250) NOT NULL DEFAULT '', + `field3` VARCHAR(250) NOT NULL DEFAULT '', + `field4` VARCHAR(250) NOT NULL DEFAULT '', + `os_detect` TINYINT UNSIGNED DEFAULT 0, + `resolve_names` TINYINT UNSIGNED DEFAULT 0, + `parent_detection` TINYINT UNSIGNED DEFAULT 0, + `parent_recursion` TINYINT UNSIGNED DEFAULT 0, + `disabled` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `macros` TEXT, + `alias_as_name` TINYINT NOT NULL DEFAULT 0, + `snmp_enabled` TINYINT UNSIGNED DEFAULT 0, + `vlan_enabled` TINYINT UNSIGNED DEFAULT 0, + `snmp_version` VARCHAR(5) NOT NULL DEFAULT 1, + `snmp_auth_user` VARCHAR(255) NOT NULL DEFAULT '', + `snmp_auth_pass` VARCHAR(255) NOT NULL DEFAULT '', + `snmp_auth_method` VARCHAR(25) NOT NULL DEFAULT '', + `snmp_privacy_method` VARCHAR(25) NOT NULL DEFAULT '', + `snmp_privacy_pass` VARCHAR(255) NOT NULL DEFAULT '', + `snmp_security_level` VARCHAR(25) NOT NULL DEFAULT '', + `wmi_enabled` TINYINT UNSIGNED DEFAULT 0, + `rcmd_enabled` TINYINT UNSIGNED DEFAULT 0, + `auth_strings` TEXT, + `auto_monitor` TINYINT UNSIGNED DEFAULT 1, + `autoconfiguration_enabled` TINYINT UNSIGNED DEFAULT 0, + `summary` TEXT, + `type` INT NOT NULL DEFAULT 0, + `subnet_csv` TINYINT UNSIGNED DEFAULT 0, + PRIMARY KEY (`id_rt`), + KEY `recon_task_daemon` (`id_recon_server`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tdiscovery_tmp` -- ---------------------------------------------------------------------- -CREATE TABLE `tdiscovery_tmp_agents` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_rt` int(10) unsigned NOT NULL, - `label` varchar(600) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', - `data` MEDIUMTEXT, - `review_date` datetime DEFAULT NULL, - `created` datetime DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `id_rt` (`id_rt`), - INDEX `label` (`label`), - CONSTRAINT `tdta_trt` FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tdiscovery_tmp_agents` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_rt` INT UNSIGNED NOT NULL, + `label` VARCHAR(600) NOT NULL DEFAULT '', + `data` MEDIUMTEXT, + `review_date` DATETIME DEFAULT NULL, + `created` DATETIME DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `id_rt` (`id_rt`), + INDEX `label` (`label`), + CONSTRAINT `tdta_trt` FOREIGN KEY (`id_rt`) REFERENCES `trecon_task` (`id_rt`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -CREATE TABLE `tdiscovery_tmp_connections` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_rt` int(10) unsigned NOT NULL, - `dev_1` text, - `dev_2` text, - `if_1` text, - `if_2` text, +CREATE TABLE IF NOT EXISTS `tdiscovery_tmp_connections` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_rt` INT UNSIGNED NOT NULL, + `dev_1` TEXT, + `dev_2` TEXT, + `if_1` TEXT, + `if_2` TEXT, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tmodule_relationship` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmodule_relationship` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_rt` int(10) unsigned DEFAULT NULL, - `id_server` varchar(100) NOT NULL DEFAULT '', - `module_a` int(10) unsigned NOT NULL, - `module_b` int(10) unsigned NOT NULL, - `disable_update` tinyint(1) unsigned NOT NULL default '0', - `type` ENUM('direct', 'failover') DEFAULT 'direct', - PRIMARY KEY (`id`), - FOREIGN KEY (`module_a`) REFERENCES tagente_modulo(`id_agente_modulo`) - ON DELETE CASCADE, - FOREIGN KEY (`module_b`) REFERENCES tagente_modulo(`id_agente_modulo`) - ON DELETE CASCADE, - FOREIGN KEY (`id_rt`) REFERENCES trecon_task(`id_rt`) - ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_rt` INT UNSIGNED DEFAULT NULL, + `id_server` VARCHAR(100) NOT NULL DEFAULT '', + `module_a` INT UNSIGNED NOT NULL, + `module_b` INT UNSIGNED NOT NULL, + `disable_update` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `type` ENUM('direct', 'failover') DEFAULT 'direct', + PRIMARY KEY (`id`), + FOREIGN KEY (`module_a`) REFERENCES tagente_modulo(`id_agente_modulo`) + ON DELETE CASCADE, + FOREIGN KEY (`module_b`) REFERENCES tagente_modulo(`id_agente_modulo`) + ON DELETE CASCADE, + FOREIGN KEY (`id_rt`) REFERENCES trecon_task(`id_rt`) + ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnetwork_component` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetwork_component` ( - `id_nc` int(10) unsigned NOT NULL auto_increment, - `name` text NOT NULL, - `description` TEXT NOT NULL, - `id_group` int(6) NOT NULL default '1', - `type` smallint(6) NOT NULL default '6', - `max` bigint(20) NOT NULL default '0', - `min` bigint(20) NOT NULL default '0', - `module_interval` mediumint(8) unsigned NOT NULL default '0', - `tcp_port` int(10) unsigned NOT NULL default '0', - `tcp_send` text NOT NULL, - `tcp_rcv` text NOT NULL, - `snmp_community` varchar(255) NOT NULL default 'NULL', - `snmp_oid` varchar(400) NOT NULL, - `id_module_group` tinyint(4) unsigned NOT NULL default '0', - `id_modulo` int(10) unsigned default '0', - `id_plugin` INTEGER unsigned default '0', - `plugin_user` text, - `plugin_pass` text, - `plugin_parameter` text, - `max_timeout` int(4) unsigned default '0', - `max_retries` int(4) unsigned default '0', - `history_data` tinyint(1) unsigned default '1', - `min_warning` double(18,2) default 0, - `max_warning` double(18,2) default 0, - `str_warning` text, - `min_critical` double(18,2) default 0, - `max_critical` double(18,2) default 0, - `str_critical` text, - `min_ff_event` int(4) unsigned default '0', - `custom_string_1` text, - `custom_string_2` text, - `custom_string_3` text, - `custom_integer_1` int(10) default 0, - `custom_integer_2` int(10) default 0, - `post_process` double(24,15) default 0, - `unit` text, - `wizard_level` enum('basic','advanced','nowizard') default 'nowizard', - `macros` text, - `critical_instructions` text NOT NULL, - `warning_instructions` text NOT NULL, - `unknown_instructions` text NOT NULL, - `critical_inverse` tinyint(1) unsigned default '0', - `warning_inverse` tinyint(1) unsigned default '0', - `id_category` int(10) default 0, - `tags` text NOT NULL, - `disabled_types_event` TEXT NOT NULL, - `module_macros` TEXT NOT NULL, - `min_ff_event_normal` int(4) unsigned default '0', - `min_ff_event_warning` int(4) unsigned default '0', - `min_ff_event_critical` int(4) unsigned default '0', - `ff_type` tinyint(1) unsigned default '0', - `each_ff` tinyint(1) unsigned default '0', - `dynamic_interval` int(4) unsigned default '0', - `dynamic_max` int(4) default '0', - `dynamic_min` int(4) default '0', - `dynamic_next` bigint(20) NOT NULL default '0', - `dynamic_two_tailed` tinyint(1) unsigned default '0', - `module_type` tinyint(1) unsigned NOT NULL DEFAULT 1, - `protocol` tinytext NOT NULL, - `manufacturer_id` varchar(200) NOT NULL, - `execution_type` tinyint(1) unsigned NOT NULL DEFAULT 1, - `scan_type` tinyint(1) unsigned NOT NULL DEFAULT 1, - `value` text NOT NULL, - `value_operations` text NOT NULL, - `module_enabled` tinyint(1) unsigned DEFAULT 0, - `name_oid` varchar(255) NOT NULL, - `query_class` varchar(200) NOT NULL, - `query_key_field` varchar(200) NOT NULL, - `scan_filters` text NOT NULL, - `query_filters` text NOT NULL, - `enabled` tinyint(1) UNSIGNED DEFAULT 1, - `percentage_critical` tinyint(1) unsigned default '0', - `percentage_warning` tinyint(1) unsigned default '0', - PRIMARY KEY (`id_nc`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_nc` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TEXT, + `description` TEXT, + `id_group` INT NOT NULL DEFAULT 1, + `type` SMALLINT NOT NULL DEFAULT 6, + `max` BIGINT NOT NULL DEFAULT 0, + `min` BIGINT NOT NULL DEFAULT 0, + `module_interval` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `tcp_port` INT UNSIGNED NOT NULL DEFAULT 0, + `tcp_send` TEXT, + `tcp_rcv` TEXT, + `snmp_community` VARCHAR(255) NOT NULL DEFAULT 'NULL', + `snmp_oid` VARCHAR(400) NOT NULL, + `id_module_group` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_modulo` INT UNSIGNED DEFAULT 0, + `id_plugin` INT unsigned DEFAULT 0, + `plugin_user` TEXT, + `plugin_pass` TEXT, + `plugin_parameter` TEXT, + `max_timeout` INT UNSIGNED DEFAULT 0, + `max_retries` INT UNSIGNED DEFAULT 0, + `history_data` TINYINT UNSIGNED DEFAULT 1, + `min_warning` DOUBLE DEFAULT 0, + `max_warning` DOUBLE DEFAULT 0, + `str_warning` TEXT, + `min_critical` DOUBLE DEFAULT 0, + `max_critical` DOUBLE DEFAULT 0, + `str_critical` TEXT, + `min_ff_event` INT UNSIGNED DEFAULT 0, + `custom_string_1` TEXT, + `custom_string_2` TEXT, + `custom_string_3` TEXT, + `custom_integer_1` INT DEFAULT 0, + `custom_integer_2` INT DEFAULT 0, + `post_process` DOUBLE DEFAULT 0, + `unit` TEXT, + `wizard_level` ENUM('basic','advanced','nowizard') DEFAULT 'nowizard', + `macros` TEXT, + `critical_instructions` TEXT, + `warning_instructions` TEXT, + `unknown_instructions` TEXT, + `critical_inverse` TINYINT UNSIGNED DEFAULT 0, + `warning_inverse` TINYINT UNSIGNED DEFAULT 0, + `id_category` INT DEFAULT 0, + `tags` TEXT, + `disabled_types_event` TEXT, + `module_macros` TEXT, + `min_ff_event_normal` INT UNSIGNED DEFAULT 0, + `min_ff_event_warning` INT UNSIGNED DEFAULT 0, + `min_ff_event_critical` INT UNSIGNED DEFAULT 0, + `ff_type` TINYINT UNSIGNED DEFAULT 0, + `each_ff` TINYINT UNSIGNED DEFAULT 0, + `dynamic_interval` INT UNSIGNED DEFAULT 0, + `dynamic_max` INT DEFAULT 0, + `dynamic_min` INT DEFAULT 0, + `dynamic_next` BIGINT NOT NULL DEFAULT 0, + `dynamic_two_tailed` TINYINT UNSIGNED DEFAULT 0, + `module_type` TINYINT UNSIGNED NOT NULL DEFAULT 1, + `protocol` TINYTEXT, + `manufacturer_id` VARCHAR(200), + `execution_type` TINYINT UNSIGNED NOT NULL DEFAULT 1, + `scan_type` TINYINT UNSIGNED NOT NULL DEFAULT 1, + `value` TEXT, + `value_operations` TEXT, + `module_enabled` TINYINT UNSIGNED DEFAULT 0, + `name_oid` VARCHAR(255) DEFAULT '', + `query_class` VARCHAR(200) DEFAULT '', + `query_key_field` VARCHAR(200) DEFAULT '', + `scan_filters` TEXT, + `query_filters` TEXT, + `enabled` TINYINT UNSIGNED DEFAULT 1, + `percentage_critical` TINYINT UNSIGNED DEFAULT 0, + `percentage_warning` TINYINT UNSIGNED DEFAULT 0, + PRIMARY KEY (`id_nc`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnetwork_component_group` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetwork_component_group` ( - `id_sg` int(10) unsigned NOT NULL auto_increment, - `name` varchar(200) NOT NULL default '', - `parent` mediumint(8) unsigned NOT NULL default '0', - PRIMARY KEY (`id_sg`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_sg` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(200) NOT NULL DEFAULT '', + `parent` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_sg`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnetwork_profile` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetwork_profile` ( - `id_np` int(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `description` varchar(250) default '', - PRIMARY KEY (`id_np`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_np` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `description` VARCHAR(250) DEFAULT '', + PRIMARY KEY (`id_np`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnetwork_profile_component` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetwork_profile_component` ( - `id_nc` mediumint(8) unsigned NOT NULL default '0', - `id_np` mediumint(8) unsigned NOT NULL default '0', - KEY `id_np` (`id_np`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_nc` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `id_np` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + KEY `id_np` (`id_np`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tpen` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpen` ( - `pen` int(10) unsigned NOT NULL, + `pen` INT UNSIGNED NOT NULL, `manufacturer` TEXT, `description` TEXT, PRIMARY KEY (`pen`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnetwork_profile_pen` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetwork_profile_pen` ( - `pen` int(10) unsigned NOT NULL, - `id_np` int(10) unsigned NOT NULL, + `pen` INT UNSIGNED NOT NULL, + `id_np` INT UNSIGNED NOT NULL, CONSTRAINT `fk_network_profile_pen_pen` FOREIGN KEY (`pen`) - REFERENCES `tpen` (`pen`) ON DELETE CASCADE ON UPDATE CASCADE, + REFERENCES `tpen` (`pen`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_network_profile_pen_id_np` FOREIGN KEY (`id_np`) - REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnota` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnota` ( - `id_nota` bigint(6) unsigned zerofill NOT NULL auto_increment, - `id_incident` bigint(6) unsigned zerofill NOT NULL, - `id_usuario` varchar(100) NOT NULL default '0', - `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, - `nota` mediumtext NOT NULL, - PRIMARY KEY (`id_nota`), - KEY `id_incident` (`id_incident`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_nota` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_incident` BIGINT UNSIGNED NOT NULL, + `id_usuario` VARCHAR(100) NOT NULL DEFAULT '0', + `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `nota` MEDIUMTEXT, + PRIMARY KEY (`id_nota`), + KEY `id_incident` (`id_incident`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `torigen` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `torigen` ( - `origen` varchar(100) NOT NULL default '' -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `origen` VARCHAR(100) NOT NULL DEFAULT '' +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tperfil` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tperfil` ( - `id_perfil` int(10) unsigned NOT NULL auto_increment, - `name` TEXT NOT NULL, - `agent_view` tinyint(1) NOT NULL DEFAULT 0, - `agent_edit` tinyint(1) NOT NULL DEFAULT 0, - `alert_edit` tinyint(1) NOT NULL DEFAULT 0, - `user_management` tinyint(1) NOT NULL DEFAULT 0, - `db_management` tinyint(1) NOT NULL DEFAULT 0, - `alert_management` tinyint(1) NOT NULL DEFAULT 0, - `pandora_management` tinyint(1) NOT NULL DEFAULT 0, - `report_view` tinyint(1) NOT NULL DEFAULT 0, - `report_edit` tinyint(1) NOT NULL DEFAULT 0, - `report_management` tinyint(1) NOT NULL DEFAULT 0, - `event_view` tinyint(1) NOT NULL DEFAULT 0, - `event_edit` tinyint(1) NOT NULL DEFAULT 0, - `event_management` tinyint(1) NOT NULL DEFAULT 0, - `agent_disable` tinyint(1) NOT NULL DEFAULT 0, - `map_view` tinyint(1) NOT NULL DEFAULT 0, - `map_edit` tinyint(1) NOT NULL DEFAULT 0, - `map_management` tinyint(1) NOT NULL DEFAULT 0, - `vconsole_view` tinyint(1) NOT NULL DEFAULT 0, - `vconsole_edit` tinyint(1) NOT NULL DEFAULT 0, - `vconsole_management` tinyint(1) NOT NULL DEFAULT 0, - `network_config_view`tinyint(1) NOT NULL DEFAULT 0, - `network_config_edit`tinyint(1) NOT NULL DEFAULT 0, - `network_config_management`tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`id_perfil`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_perfil` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TEXT, + `agent_view` TINYINT NOT NULL DEFAULT 0, + `agent_edit` TINYINT NOT NULL DEFAULT 0, + `alert_edit` TINYINT NOT NULL DEFAULT 0, + `user_management` TINYINT NOT NULL DEFAULT 0, + `db_management` TINYINT NOT NULL DEFAULT 0, + `alert_management` TINYINT NOT NULL DEFAULT 0, + `pandora_management` TINYINT NOT NULL DEFAULT 0, + `report_view` TINYINT NOT NULL DEFAULT 0, + `report_edit` TINYINT NOT NULL DEFAULT 0, + `report_management` TINYINT NOT NULL DEFAULT 0, + `event_view` TINYINT NOT NULL DEFAULT 0, + `event_edit` TINYINT NOT NULL DEFAULT 0, + `event_management` TINYINT NOT NULL DEFAULT 0, + `agent_disable` TINYINT NOT NULL DEFAULT 0, + `map_view` TINYINT NOT NULL DEFAULT 0, + `map_edit` TINYINT NOT NULL DEFAULT 0, + `map_management` TINYINT NOT NULL DEFAULT 0, + `vconsole_view` TINYINT NOT NULL DEFAULT 0, + `vconsole_edit` TINYINT NOT NULL DEFAULT 0, + `vconsole_management` TINYINT NOT NULL DEFAULT 0, + `network_config_view`TINYINT NOT NULL DEFAULT 0, + `network_config_edit`TINYINT NOT NULL DEFAULT 0, + `network_config_management`TINYINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_perfil`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `trecon_script` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `trecon_script` ( - `id_recon_script` int(10) NOT NULL auto_increment, - `name` varchar(100) default '', - `description` TEXT, - `script` varchar(250) default '', - `macros` TEXT, - `type` int NOT NULL default 0, - PRIMARY KEY (`id_recon_script`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_recon_script` INT NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) DEFAULT '', + `description` TEXT, + `script` VARCHAR(250) DEFAULT '', + `macros` TEXT, + `type` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_recon_script`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tserver` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tserver` ( - `id_server` int(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `ip_address` varchar(100) NOT NULL default '', - `status` int(11) NOT NULL default '0', - `laststart` datetime NOT NULL default '1970-01-01 00:00:00', - `keepalive` datetime NOT NULL default '1970-01-01 00:00:00', - `snmp_server` tinyint(3) unsigned NOT NULL default '0', - `network_server` tinyint(3) unsigned NOT NULL default '0', - `data_server` tinyint(3) unsigned NOT NULL default '0', - `master` tinyint(3) unsigned NOT NULL default '0', - `checksum` tinyint(3) unsigned NOT NULL default '0', - `description` varchar(255) default NULL, - `recon_server` tinyint(3) unsigned NOT NULL default '0', - `version` varchar(25) NOT NULL default '', - `plugin_server` tinyint(3) unsigned NOT NULL default '0', - `prediction_server` tinyint(3) unsigned NOT NULL default '0', - `wmi_server` tinyint(3) unsigned NOT NULL default '0', - `export_server` tinyint(3) unsigned NOT NULL default '0', - `server_type` tinyint(3) unsigned NOT NULL default '0', - `queued_modules` int(5) unsigned NOT NULL default '0', - `threads` int(5) unsigned NOT NULL default '0', - `lag_time` int(11) NOT NULL default 0, - `lag_modules` int(11) NOT NULL default 0, - `total_modules_running` int(11) NOT NULL default 0, - `my_modules` int(11) NOT NULL default 0, - `server_keepalive` int(11) NOT NULL default 0, - `stat_utimestamp` bigint(20) NOT NULL default '0', - `exec_proxy` tinyint(1) UNSIGNED NOT NULL default 0, - `port` int(5) unsigned NOT NULL default 0, - PRIMARY KEY (`id_server`), - KEY `name` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_server` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `ip_address` VARCHAR(100) NOT NULL DEFAULT '', + `status` INT NOT NULL DEFAULT 0, + `laststart` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `keepalive` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `snmp_server` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `network_server` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `data_server` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `master` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `checksum` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `description` VARCHAR(255) DEFAULT NULL, + `recon_server` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `version` VARCHAR(25) NOT NULL DEFAULT '', + `plugin_server` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `prediction_server` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `wmi_server` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `export_server` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `server_type` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `queued_modules` INT UNSIGNED NOT NULL DEFAULT 0, + `threads` INT UNSIGNED NOT NULL DEFAULT 0, + `lag_time` INT NOT NULL DEFAULT 0, + `lag_modules` INT NOT NULL DEFAULT 0, + `total_modules_running` INT NOT NULL DEFAULT 0, + `my_modules` INT NOT NULL DEFAULT 0, + `server_keepalive` INT NOT NULL DEFAULT 0, + `stat_utimestamp` BIGINT NOT NULL DEFAULT 0, + `exec_proxy` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `port` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_server`), + KEY `name` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- server types: -- 0 data -- 1 network @@ -1173,1221 +1174,1211 @@ CREATE TABLE IF NOT EXISTS `tserver` ( -- Table `tsesion` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tsesion` ( - `id_sesion` bigint(20) unsigned NOT NULL auto_increment, - `id_usuario` varchar(60) NOT NULL default '0', - `ip_origen` varchar(100) NOT NULL default '', - `accion` varchar(100) NOT NULL default '', - `descripcion` text NOT NULL, - `fecha` datetime NOT NULL default '1970-01-01 00:00:00', - `utimestamp` bigint(20) unsigned NOT NULL default '0', - PRIMARY KEY (`id_sesion`), - KEY `idx_user` (`id_usuario`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_sesion` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_usuario` VARCHAR(60) NOT NULL DEFAULT '0', + `ip_origen` VARCHAR(100) NOT NULL DEFAULT '', + `accion` VARCHAR(100) NOT NULL DEFAULT '', + `descripcion` TEXT, + `fecha` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `utimestamp` BIGINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_sesion`), + KEY `idx_user` (`id_usuario`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `ttipo_modulo` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `ttipo_modulo` ( - `id_tipo` smallint(5) unsigned NOT NULL auto_increment, - `nombre` varchar(100) NOT NULL default '', - `categoria` int(11) NOT NULL default '0', - `descripcion` varchar(100) NOT NULL default '', - `icon` varchar(100) default NULL, - PRIMARY KEY (`id_tipo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_tipo` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, + `nombre` VARCHAR(100) NOT NULL DEFAULT '', + `categoria` INT NOT NULL DEFAULT 0, + `descripcion` VARCHAR(100) NOT NULL DEFAULT '', + `icon` VARCHAR(100) DEFAULT NULL, + PRIMARY KEY (`id_tipo`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `ttrap` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `ttrap` ( - `id_trap` bigint(20) unsigned NOT NULL auto_increment, - `source` varchar(50) NOT NULL default '', - `oid` text NOT NULL, - `oid_custom` text, - `type` int(11) NOT NULL default '0', - `type_custom` varchar(100) default '', - `value` text, - `value_custom` text, - `alerted` smallint(6) NOT NULL default '0', - `status` smallint(6) NOT NULL default '0', - `id_usuario` varchar(150) default '', - `timestamp` datetime NOT NULL default '1970-01-01 00:00:00', - `priority` tinyint(4) unsigned NOT NULL default '2', - `text` varchar(255) default '', - `description` varchar(255) default '', - `severity` tinyint(4) unsigned NOT NULL default '2', - PRIMARY KEY (`id_trap`), - INDEX timestamp (`timestamp`), - INDEX status (`status`), - INDEX source (`source`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_trap` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `source` VARCHAR(50) NOT NULL DEFAULT '', + `oid` TEXT, + `oid_custom` TEXT, + `type` INT NOT NULL DEFAULT 0, + `type_custom` VARCHAR(100) DEFAULT '', + `value` TEXT, + `value_custom` TEXT, + `alerted` SMALLINT NOT NULL DEFAULT 0, + `status` SMALLINT NOT NULL DEFAULT 0, + `id_usuario` VARCHAR(150) DEFAULT '', + `timestamp` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `priority` TINYINT UNSIGNED NOT NULL DEFAULT 2, + `text` VARCHAR(255) DEFAULT '', + `description` VARCHAR(255) DEFAULT '', + `severity` TINYINT UNSIGNED NOT NULL DEFAULT 2, + PRIMARY KEY (`id_trap`), + INDEX timestamp (`timestamp`), + INDEX status (`status`), + INDEX source (`source`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tevent_filter` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tevent_filter` ( - `id_filter` int(10) unsigned NOT NULL auto_increment, - `id_group_filter` int(10) NOT NULL default 0, - `id_name` varchar(600) NOT NULL, - `id_group` int(10) NOT NULL default 0, - `event_type` text NOT NULL, - `severity` text NOT NULL, - `status` int(10) NOT NULL default -1, - `search` TEXT, - `text_agent` TEXT, - `id_agent` int(10) default 0, - `id_agent_module` int(10) default 0, - `pagination` int(10) NOT NULL default 25, - `event_view_hr` int(10) NOT NULL default 8, - `id_user_ack` TEXT, - `group_rep` int(10) NOT NULL default 0, - `tag_with` text NOT NULL, - `tag_without` text NOT NULL, - `filter_only_alert` int(10) NOT NULL default -1, - `date_from` date default NULL, - `date_to` date default NULL, - `source` tinytext NOT NULL, - `id_extra` tinytext NOT NULL, - `user_comment` text NOT NULL, - `id_source_event` int(10) NULL default 0, - `server_id` int(10) NOT NULL default 0, - `time_from` TIME NULL, - `time_to` TIME NULL, - PRIMARY KEY (`id_filter`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_group_filter` INT NOT NULL DEFAULT 0, + `id_name` VARCHAR(600) NOT NULL, + `id_group` INT NOT NULL DEFAULT 0, + `event_type` TEXT, + `severity` TEXT, + `status` INT NOT NULL DEFAULT -1, + `search` TEXT, + `text_agent` TEXT, + `id_agent` INT DEFAULT 0, + `id_agent_module` INT DEFAULT 0, + `pagination` INT NOT NULL DEFAULT 25, + `event_view_hr` INT NOT NULL DEFAULT 8, + `id_user_ack` TEXT, + `group_rep` INT NOT NULL DEFAULT 0, + `tag_with` TEXT, + `tag_without` TEXT, + `filter_only_alert` INT NOT NULL DEFAULT -1, + `date_from` date DEFAULT NULL, + `date_to` date DEFAULT NULL, + `source` TINYTEXT, + `id_extra` TINYTEXT, + `user_comment` TEXT, + `id_source_event` INT NULL DEFAULT 0, + `server_id` INT NOT NULL DEFAULT 0, + `time_from` TIME NULL, + `time_to` TIME NULL, + PRIMARY KEY (`id_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tusuario` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tusuario` ( - `id_user` varchar(60) NOT NULL default '0', - `fullname` varchar(255) NOT NULL, - `firstname` varchar(255) NOT NULL, - `lastname` varchar(255) NOT NULL, - `middlename` varchar(255) NOT NULL, - `password` varchar(45) default NULL, - `comments` varchar(200) default NULL, - `last_connect` bigint(20) NOT NULL default '0', - `registered` bigint(20) NOT NULL default '0', - `email` varchar(100) default NULL, - `phone` varchar(100) default NULL, - `is_admin` tinyint(1) unsigned NOT NULL default '0', - `language` varchar(10) default NULL, - `timezone` varchar(50) default '', - `block_size` int(4) NOT NULL DEFAULT 20, - `id_skin` int(10) unsigned NOT NULL DEFAULT 0, - `disabled` int(4) NOT NULL DEFAULT 0, - `shortcut` tinyint(1) DEFAULT 0, - `shortcut_data` text, - `section` TEXT NOT NULL, - `data_section` TEXT NOT NULL, - `force_change_pass` tinyint(1) unsigned NOT NULL default 0, - `last_pass_change` DATETIME NOT NULL DEFAULT 0, - `last_failed_login` DATETIME NOT NULL DEFAULT 0, - `failed_attempt` int(4) NOT NULL DEFAULT 0, - `login_blocked` tinyint(1) unsigned NOT NULL default 0, - `metaconsole_access` enum('basic','advanced') default 'basic', - `not_login` tinyint(1) unsigned NOT NULL DEFAULT 0, - `local_user` tinyint(1) unsigned NOT NULL DEFAULT 0, - `metaconsole_agents_manager` tinyint(1) unsigned NOT NULL default 0, - `metaconsole_assigned_server` int(10) unsigned NOT NULL default 0, - `metaconsole_access_node` tinyint(1) unsigned NOT NULL default 0, - `strict_acl` tinyint(1) unsigned NOT NULL DEFAULT 0, - `id_filter` int(10) unsigned NULL default NULL, - `session_time` int(10) signed NOT NULL default 0, - `default_event_filter` int(10) unsigned NOT NULL default 0, - `autorefresh_white_list` text not null default '', - `time_autorefresh` int(5) unsigned NOT NULL default '30', - `default_custom_view` int(10) unsigned NULL default '0', - `ehorus_user_level_user` VARCHAR(60), - `ehorus_user_level_pass` VARCHAR(45), - `ehorus_user_level_enabled` TINYINT(1), - `integria_user_level_user` VARCHAR(60), - `integria_user_level_pass` VARCHAR(45), - CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL, - UNIQUE KEY `id_user` (`id_user`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_user` VARCHAR(60) NOT NULL DEFAULT '0', + `fullname` VARCHAR(255) NOT NULL, + `firstname` VARCHAR(255) NOT NULL, + `lastname` VARCHAR(255) NOT NULL, + `middlename` VARCHAR(255) NOT NULL, + `password` VARCHAR(45) DEFAULT NULL, + `comments` VARCHAR(200) DEFAULT NULL, + `last_connect` BIGINT NOT NULL DEFAULT 0, + `registered` BIGINT NOT NULL DEFAULT 0, + `email` VARCHAR(100) DEFAULT NULL, + `phone` VARCHAR(100) DEFAULT NULL, + `is_admin` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `language` VARCHAR(10) DEFAULT NULL, + `timezone` VARCHAR(50) DEFAULT '', + `block_size` INT NOT NULL DEFAULT 20, + `id_skin` INT UNSIGNED NOT NULL DEFAULT 0, + `disabled` INT NOT NULL DEFAULT 0, + `shortcut` TINYINT DEFAULT 0, + `shortcut_data` TEXT, + `section` TEXT, + `data_section` TEXT, + `force_change_pass` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `last_pass_change` DATETIME, + `last_failed_login` DATETIME, + `failed_attempt` INT NOT NULL DEFAULT 0, + `login_blocked` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `metaconsole_access` ENUM('basic','advanced') DEFAULT 'basic', + `not_login` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `local_user` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `metaconsole_agents_manager` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `metaconsole_assigned_server` INT UNSIGNED NOT NULL DEFAULT 0, + `metaconsole_access_node` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `strict_acl` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_filter` INT UNSIGNED NULL DEFAULT NULL, + `session_time` INT signed NOT NULL DEFAULT 0, + `default_event_filter` INT UNSIGNED NOT NULL DEFAULT 0, + `autorefresh_white_list` TEXT , + `time_autorefresh` INT UNSIGNED NOT NULL DEFAULT 30, + `default_custom_view` INT UNSIGNED NULL DEFAULT 0, + `ehorus_user_level_user` VARCHAR(60), + `ehorus_user_level_pass` VARCHAR(45), + `ehorus_user_level_enabled` TINYINT, + `integria_user_level_user` VARCHAR(60), + `integria_user_level_pass` VARCHAR(45), + CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL, + UNIQUE KEY `id_user` (`id_user`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tusuario_perfil` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tusuario_perfil` ( - `id_up` bigint(10) unsigned NOT NULL auto_increment, - `id_usuario` varchar(100) NOT NULL default '', - `id_perfil` int(10) unsigned NOT NULL default '0', - `id_grupo` int(10) NOT NULL default '0', - `no_hierarchy` tinyint(1) NOT NULL default 0, - `assigned_by` varchar(100) NOT NULL default '', - `id_policy` int(10) unsigned NOT NULL default '0', - `tags` text NOT NULL, - PRIMARY KEY (`id_up`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_up` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_usuario` VARCHAR(100) NOT NULL DEFAULT '', + `id_perfil` INT UNSIGNED NOT NULL DEFAULT 0, + `id_grupo` INT NOT NULL DEFAULT 0, + `no_hierarchy` TINYINT NOT NULL DEFAULT 0, + `assigned_by` VARCHAR(100) NOT NULL DEFAULT '', + `id_policy` INT UNSIGNED NOT NULL DEFAULT 0, + `tags` TEXT, + PRIMARY KEY (`id_up`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tuser_double_auth` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tuser_double_auth` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_user` varchar(60) NOT NULL, - `secret` varchar(20) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE (`id_user`), - FOREIGN KEY (`id_user`) REFERENCES tusuario(`id_user`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(60) NOT NULL, + `secret` VARCHAR(20) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE (`id_user`), + FOREIGN KEY (`id_user`) REFERENCES tusuario(`id_user`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `treset_pass_history` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `treset_pass_history` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_user` varchar(60) NOT NULL, - `reset_moment` datetime NOT NULL, - `success` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(60) NOT NULL, + `reset_moment` DATETIME NOT NULL, + `success` TINYINT NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tnotification_source` -- ----------------------------------------------------- -CREATE TABLE `tnotification_source` ( - `id` serial, - `description` VARCHAR(255) DEFAULT NULL, - `icon` text, - `max_postpone_time` int(11) DEFAULT NULL, - `enabled` int(1) DEFAULT NULL, - `user_editable` int(1) DEFAULT NULL, - `also_mail` int(1) DEFAULT NULL, - `subtype_blacklist` TEXT, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tnotification_source` ( + `id` SERIAL, + `description` VARCHAR(255) DEFAULT NULL, + `icon` TEXT, + `max_postpone_time` INT DEFAULT NULL, + `enabled` INT DEFAULT NULL, + `user_editable` INT DEFAULT NULL, + `also_mail` INT DEFAULT NULL, + `subtype_blacklist` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tmensajes` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmensajes` ( - `id_mensaje` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, - `id_usuario_origen` VARCHAR(60) NOT NULL DEFAULT '', - `mensaje` TEXT NOT NULL, - `timestamp` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', - `subject` VARCHAR(255) NOT NULL DEFAULT '', - `estado` INT(4) UNSIGNED NOT NULL DEFAULT '0', - `url` TEXT, - `response_mode` VARCHAR(200) DEFAULT NULL, - `citicity` INT(10) UNSIGNED DEFAULT '0', - `id_source` BIGINT(20) UNSIGNED NOT NULL, - `subtype` VARCHAR(255) DEFAULT '', - `hidden_sent` TINYINT(1) UNSIGNED DEFAULT 0, - PRIMARY KEY (`id_mensaje`), - UNIQUE KEY `id_mensaje` (`id_mensaje`), - KEY `tsource_fk` (`id_source`), - CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; + `id_mensaje` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_usuario_origen` VARCHAR(60) NOT NULL DEFAULT '', + `mensaje` TEXT, + `timestamp` BIGINT UNSIGNED NOT NULL DEFAULT 0, + `subject` VARCHAR(255) NOT NULL DEFAULT '', + `estado` INT UNSIGNED NOT NULL DEFAULT 0, + `url` TEXT, + `response_mode` VARCHAR(200) DEFAULT NULL, + `citicity` INT UNSIGNED DEFAULT 0, + `id_source` BIGINT UNSIGNED NOT NULL, + `subtype` VARCHAR(255) DEFAULT '', + `hidden_sent` TINYINT UNSIGNED DEFAULT 0, + PRIMARY KEY (`id_mensaje`), + UNIQUE KEY `id_mensaje` (`id_mensaje`), + KEY `tsource_fk` (`id_source`), + CONSTRAINT `tsource_fk` FOREIGN KEY (`id_source`) REFERENCES `tnotification_source` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnotification_user` -- ---------------------------------------------------------------------- -CREATE TABLE `tnotification_user` ( - `id_mensaje` INT(10) UNSIGNED NOT NULL, - `id_user` VARCHAR(60) NOT NULL, - `utimestamp_read` BIGINT(20), - `utimestamp_erased` BIGINT(20), - `postpone` INT, - PRIMARY KEY (`id_mensaje`,`id_user`), - FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) - ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tnotification_user` ( + `id_mensaje` INT UNSIGNED NOT NULL, + `id_user` VARCHAR(60) NOT NULL, + `utimestamp_read` BIGINT, + `utimestamp_erased` BIGINT, + `postpone` INT, + PRIMARY KEY (`id_mensaje`,`id_user`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnotification_group` -- ---------------------------------------------------------------------- -CREATE TABLE `tnotification_group` ( - `id_mensaje` INT(10) UNSIGNED NOT NULL, - `id_group` mediumint(4) UNSIGNED NOT NULL, - PRIMARY KEY (`id_mensaje`,`id_group`), - FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tnotification_group` ( + `id_mensaje` INT UNSIGNED NOT NULL, + `id_group` MEDIUMINT UNSIGNED NOT NULL, + PRIMARY KEY (`id_mensaje`,`id_group`), + FOREIGN KEY (`id_mensaje`) REFERENCES `tmensajes`(`id_mensaje`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnotification_source_user` -- ---------------------------------------------------------------------- -CREATE TABLE `tnotification_source_user` ( - `id_source` BIGINT(20) UNSIGNED NOT NULL, - `id_user` VARCHAR(60), - `enabled` INT(1) DEFAULT NULL, - `also_mail` INT(1) DEFAULT NULL, - PRIMARY KEY (`id_source`,`id_user`), - FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) - ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tnotification_source_user` ( + `id_source` BIGINT UNSIGNED NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT DEFAULT NULL, + `also_mail` INT DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnotification_source_group` -- ---------------------------------------------------------------------- -CREATE TABLE `tnotification_source_group` ( - `id_source` BIGINT(20) UNSIGNED NOT NULL, - `id_group` mediumint(4) unsigned NOT NULL, - PRIMARY KEY (`id_source`,`id_group`), - INDEX (`id_group`), - FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tnotification_source_group` ( + `id_source` BIGINT UNSIGNED NOT NULL, + `id_group` MEDIUMINT UNSIGNED NOT NULL, + PRIMARY KEY (`id_source`,`id_group`), + INDEX (`id_group`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnotification_source_user` -- ---------------------------------------------------------------------- -CREATE TABLE `tnotification_source_group_user` ( - `id_source` BIGINT(20) UNSIGNED NOT NULL, - `id_group` mediumint(4) unsigned NOT NULL, - `id_user` VARCHAR(60), - `enabled` INT(1) DEFAULT NULL, - `also_mail` INT(1) DEFAULT NULL, - PRIMARY KEY (`id_source`,`id_user`), - FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) - ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) - ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tnotification_source_group_user` ( + `id_source` BIGINT UNSIGNED NOT NULL, + `id_group` MEDIUMINT UNSIGNED NOT NULL, + `id_user` VARCHAR(60), + `enabled` INT DEFAULT NULL, + `also_mail` INT DEFAULT NULL, + PRIMARY KEY (`id_source`,`id_user`), + FOREIGN KEY (`id_source`) REFERENCES `tnotification_source`(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES `tusuario`(`id_user`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_group`) REFERENCES `tnotification_source_group`(`id_group`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnews` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnews` ( - `id_news` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `author` varchar(255) NOT NULL DEFAULT '', - `subject` varchar(255) NOT NULL DEFAULT '', - `text` TEXT NOT NULL, - `timestamp` DATETIME NOT NULL DEFAULT 0, - `id_group` int(10) NOT NULL default 0, - `modal` tinyint(1) DEFAULT 0, - `expire` tinyint(1) DEFAULT 0, - `expire_timestamp` DATETIME NOT NULL DEFAULT 0, - PRIMARY KEY(`id_news`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_news` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `author` VARCHAR(255) NOT NULL DEFAULT '', + `subject` VARCHAR(255) NOT NULL DEFAULT '', + `text` TEXT, + `timestamp` DATETIME, + `id_group` INT NOT NULL DEFAULT 0, + `modal` TINYINT DEFAULT 0, + `expire` TINYINT DEFAULT 0, + `expire_timestamp` DATETIME, + PRIMARY KEY(`id_news`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tgraph` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgraph` ( - `id_graph` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_user` varchar(100) NOT NULL default '', - `name` varchar(150) NOT NULL default '', - `description` TEXT NOT NULL, - `period` int(11) NOT NULL default '0', - `width` smallint(5) UNSIGNED NOT NULL DEFAULT 0, - `height` smallint(5) UNSIGNED NOT NULL DEFAULT 0, - `private` tinyint(1) UNSIGNED NOT NULL default 0, - `events` tinyint(1) UNSIGNED NOT NULL default 0, - `stacked` tinyint(1) UNSIGNED NOT NULL default 0, - `id_group` mediumint(8) unsigned NULL default 0, - `id_graph_template` int(11) NOT NULL default 0, - `percentil` tinyint(1) UNSIGNED NOT NULL default 0, - `summatory_series` tinyint(1) UNSIGNED NOT NULL default 0, - `average_series` tinyint(1) UNSIGNED NOT NULL default 0, - `modules_series` tinyint(1) UNSIGNED NOT NULL default 0, - `fullscale` tinyint(1) UNSIGNED NOT NULL default 0, - PRIMARY KEY(`id_graph`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_graph` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(100) NOT NULL DEFAULT '', + `name` VARCHAR(150) NOT NULL DEFAULT '', + `description` TEXT, + `period` INT NOT NULL DEFAULT 0, + `width` SMALLINT UNSIGNED NOT NULL DEFAULT 0, + `height` SMALLINT UNSIGNED NOT NULL DEFAULT 0, + `private` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `events` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `stacked` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `id_graph_template` INT NOT NULL DEFAULT 0, + `percentil` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `summatory_series` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `average_series` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `modules_series` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `fullscale` TINYINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id_graph`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tgraph_source` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgraph_source` ( - `id_gs` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_graph` int(11) NOT NULL default 0, - `id_server` int(11) NOT NULL default 0, - `id_agent_module` int(11) NOT NULL default 0, - `weight` float(8,3) NOT NULL DEFAULT 0, - `label` varchar(150) DEFAULT '', - `field_order` int(10) DEFAULT 0, - PRIMARY KEY(`id_gs`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_gs` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_graph` INT NOT NULL DEFAULT 0, + `id_server` INT NOT NULL DEFAULT 0, + `id_agent_module` INT NOT NULL DEFAULT 0, + `weight` DOUBLE NOT NULL DEFAULT 0, + `label` VARCHAR(150) DEFAULT '', + `field_order` INT DEFAULT 0, + PRIMARY KEY(`id_gs`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `treport` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport` ( - `id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_user` varchar(100) NOT NULL default '', - `name` varchar(150) NOT NULL default '', - `description` TEXT NOT NULL, - `private` tinyint(1) UNSIGNED NOT NULL default 0, - `id_group` mediumint(8) unsigned NULL default NULL, - `custom_logo` varchar(200) default NULL, - `header` MEDIUMTEXT, - `first_page` MEDIUMTEXT, - `footer` MEDIUMTEXT, - `custom_font` varchar(200) default NULL, - `id_template` INTEGER UNSIGNED DEFAULT 0, - `id_group_edit` mediumint(8) unsigned NULL DEFAULT 0, - `metaconsole` tinyint(1) DEFAULT 0, - `non_interactive` tinyint(1) UNSIGNED NOT NULL default 0, - `hidden` tinyint(1) DEFAULT 0, - `orientation` varchar(25) NOT NULL default 'vertical', - `cover_page_render` tinyint(1) NOT NULL DEFAULT 1, - `index_render` tinyint(1) NOT NULL DEFAULT 1, - PRIMARY KEY(`id_report`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_report` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(100) NOT NULL DEFAULT '', + `name` VARCHAR(150) NOT NULL DEFAULT '', + `description` TEXT, + `private` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT NULL, + `custom_logo` VARCHAR(200) DEFAULT NULL, + `header` MEDIUMTEXT, + `first_page` MEDIUMTEXT, + `footer` MEDIUMTEXT, + `custom_font` VARCHAR(200) DEFAULT NULL, + `id_template` INT UNSIGNED DEFAULT 0, + `id_group_edit` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `metaconsole` TINYINT DEFAULT 0, + `non_interactive` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `hidden` TINYINT DEFAULT 0, + `orientation` VARCHAR(25) NOT NULL DEFAULT 'vertical', + `cover_page_render` TINYINT NOT NULL DEFAULT 1, + `index_render` TINYINT NOT NULL DEFAULT 1, + PRIMARY KEY(`id_report`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `treport_content` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport_content` ( - `id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_report` INTEGER UNSIGNED NOT NULL default 0, - `id_gs` INTEGER UNSIGNED NULL default NULL, - `id_agent_module` bigint(14) unsigned NULL default NULL, - `type` varchar(30) default 'simple_graph', - `period` int(11) NOT NULL default 0, - `order` int (11) NOT NULL default 0, - `name` varchar(300) NULL, - `description` mediumtext, - `id_agent` int(10) unsigned NOT NULL default 0, - `text` TEXT, - `external_source` mediumtext, - `treport_custom_sql_id` INTEGER UNSIGNED default 0, - `header_definition` TinyText, - `column_separator` TinyText, - `line_separator` TinyText, - `time_from` time default '00:00:00', - `time_to` time default '00:00:00', - `monday` tinyint(1) default 1, - `tuesday` tinyint(1) default 1, - `wednesday` tinyint(1) default 1, - `thursday` tinyint(1) default 1, - `friday` tinyint(1) default 1, - `saturday` tinyint(1) default 1, - `sunday` tinyint(1) default 1, - `only_display_wrong` tinyint (1) unsigned default 0 not null, - `top_n` INT NOT NULL default 0, - `top_n_value` INT NOT NULL default 10, - `exception_condition` INT NOT NULL default 0, - `exception_condition_value` DOUBLE (18,6) NOT NULL default 0, - `show_resume` INT NOT NULL default 0, - `order_uptodown` INT NOT NULL default 0, - `show_graph` INT NOT NULL default 0, - `group_by_agent` INT NOT NULL default 0, - `style` TEXT NOT NULL, - `id_group` INT (10) unsigned NOT NULL DEFAULT 0, - `id_module_group` INT (10) unsigned NOT NULL DEFAULT 0, - `server_name` text, - `historical_db` tinyint(1) UNSIGNED NOT NULL default 0, - `lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0', - `lapse` int(11) UNSIGNED NOT NULL default '300', - `visual_format` tinyint(1) UNSIGNED NOT NULL default '0', - `hide_no_data` tinyint(1) default 0, - `recursion` tinyint(1) default NULL, - `show_extended_events` tinyint(1) default '0', - `total_time` TINYINT(1) DEFAULT '1', - `time_failed` TINYINT(1) DEFAULT '1', - `time_in_ok_status` TINYINT(1) DEFAULT '1', - `time_in_warning_status` TINYINT(1) DEFAULT '0', - `time_in_unknown_status` TINYINT(1) DEFAULT '1', - `time_of_not_initialized_module` TINYINT(1) DEFAULT '1', - `time_of_downtime` TINYINT(1) DEFAULT '1', - `total_checks` TINYINT(1) DEFAULT '1', - `checks_failed` TINYINT(1) DEFAULT '1', - `checks_in_ok_status` TINYINT(1) DEFAULT '1', - `checks_in_warning_status` TINYINT(1) DEFAULT '0', - `unknown_checks` TINYINT(1) DEFAULT '1', - `agent_max_value` TINYINT(1) DEFAULT '1', - `agent_min_value` TINYINT(1) DEFAULT '1', - `current_month` TINYINT(1) DEFAULT '1', - `failover_mode` tinyint(1) DEFAULT '1', - `failover_type` tinyint(1) DEFAULT '1', - `uncompressed_module` TINYINT DEFAULT '0', - `summary` tinyint(1) DEFAULT 0, - `landscape` tinyint(1) UNSIGNED NOT NULL default 0, - `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0, - `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0, - `graph_render` tinyint(1) UNSIGNED NOT NULL default 0, - `ipam_network_filter` int(10) UNSIGNED DEFAULT 0, - `ipam_alive_ips` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `ipam_ip_not_assigned_to_agent` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - PRIMARY KEY(`id_rc`), - FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_rc` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_report` INT UNSIGNED NOT NULL DEFAULT 0, + `id_gs` INT UNSIGNED NULL DEFAULT NULL, + `id_agent_module` BIGINT UNSIGNED NULL DEFAULT NULL, + `type` VARCHAR(30) DEFAULT 'simple_graph', + `period` INT NOT NULL DEFAULT 0, + `order` INT NOT NULL DEFAULT 0, + `name` VARCHAR(300) NULL, + `description` MEDIUMTEXT, + `id_agent` INT UNSIGNED NOT NULL DEFAULT 0, + `text` TEXT, + `external_source` MEDIUMTEXT, + `treport_custom_sql_id` INT UNSIGNED DEFAULT 0, + `header_definition` TINYTEXT, + `column_separator` TINYTEXT, + `line_separator` TINYTEXT, + `time_from` time DEFAULT '00:00:00', + `time_to` time DEFAULT '00:00:00', + `monday` TINYINT DEFAULT 1, + `tuesday` TINYINT DEFAULT 1, + `wednesday` TINYINT DEFAULT 1, + `thursday` TINYINT DEFAULT 1, + `friday` TINYINT DEFAULT 1, + `saturday` TINYINT DEFAULT 1, + `sunday` TINYINT DEFAULT 1, + `only_display_wrong` TINYINT unsigned DEFAULT 0 NOT NULL, + `top_n` INT NOT NULL DEFAULT 0, + `top_n_value` INT NOT NULL DEFAULT 10, + `exception_condition` INT NOT NULL DEFAULT 0, + `exception_condition_value` DOUBLE NOT NULL DEFAULT 0, + `show_resume` INT NOT NULL DEFAULT 0, + `order_uptodown` INT NOT NULL DEFAULT 0, + `show_graph` INT NOT NULL DEFAULT 0, + `group_by_agent` INT NOT NULL DEFAULT 0, + `style` TEXT, + `id_group` INT unsigned NOT NULL DEFAULT 0, + `id_module_group` INT unsigned NOT NULL DEFAULT 0, + `server_name` TEXT, + `historical_db` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `lapse_calc` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `lapse` INT UNSIGNED NOT NULL DEFAULT 300, + `visual_format` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `hide_no_data` TINYINT DEFAULT 0, + `recursion` TINYINT DEFAULT NULL, + `show_extended_events` TINYINT DEFAULT 0, + `total_time` TINYINT DEFAULT 1, + `time_failed` TINYINT DEFAULT 1, + `time_in_ok_status` TINYINT DEFAULT 1, + `time_in_warning_status` TINYINT DEFAULT 0, + `time_in_unknown_status` TINYINT DEFAULT 1, + `time_of_not_initialized_module` TINYINT DEFAULT 1, + `time_of_downtime` TINYINT DEFAULT 1, + `total_checks` TINYINT DEFAULT 1, + `checks_failed` TINYINT DEFAULT 1, + `checks_in_ok_status` TINYINT DEFAULT 1, + `checks_in_warning_status` TINYINT DEFAULT 0, + `unknown_checks` TINYINT DEFAULT 1, + `agent_max_value` TINYINT DEFAULT 1, + `agent_min_value` TINYINT DEFAULT 1, + `current_month` TINYINT DEFAULT 1, + `failover_mode` TINYINT DEFAULT 1, + `failover_type` TINYINT DEFAULT 1, + `uncompressed_module` TINYINT DEFAULT 0, + `summary` TINYINT DEFAULT 0, + `landscape` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `pagebreak` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `compare_work_time` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `graph_render` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `ipam_network_filter` INT UNSIGNED DEFAULT 0, + `ipam_alive_ips` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `ipam_ip_not_assigned_to_agent` TINYINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id_rc`), + FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `treport_content_sla_combined` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport_content_sla_combined` ( - `id` INTEGER UNSIGNED NOT NULL auto_increment, - `id_report_content` INTEGER UNSIGNED NOT NULL, - `id_agent_module` int(10) unsigned NOT NULL, - `id_agent_module_failover` int(10) unsigned NOT NULL, - `sla_max` double(18,2) NOT NULL default 0, - `sla_min` double(18,2) NOT NULL default 0, - `sla_limit` double(18,2) NOT NULL default 0, - `server_name` text, - PRIMARY KEY(`id`), - FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_report_content` INT UNSIGNED NOT NULL, + `id_agent_module` INT UNSIGNED NOT NULL, + `id_agent_module_failover` INT UNSIGNED NOT NULL, + `sla_max` DOUBLE NOT NULL DEFAULT 0, + `sla_min` DOUBLE NOT NULL DEFAULT 0, + `sla_limit` DOUBLE NOT NULL DEFAULT 0, + `server_name` TEXT, + PRIMARY KEY(`id`), + FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `treport_content_item` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport_content_item` ( - `id` INTEGER UNSIGNED NOT NULL auto_increment, - `id_report_content` INTEGER UNSIGNED NOT NULL, - `id_agent_module` int(10) unsigned NOT NULL, - `id_agent_module_failover` int(10) unsigned NOT NULL DEFAULT 0, - `server_name` text, - `operation` text, - PRIMARY KEY(`id`), - FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_report_content` INT UNSIGNED NOT NULL, + `id_agent_module` INT UNSIGNED NOT NULL, + `id_agent_module_failover` INT UNSIGNED NOT NULL DEFAULT 0, + `server_name` TEXT, + `operation` TEXT, + PRIMARY KEY(`id`), + FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `treport_custom_sql` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport_custom_sql` ( - `id` INTEGER UNSIGNED NOT NULL auto_increment, - `name` varchar(150) NOT NULL default '', - `sql` TEXT, - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET = utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(150) NOT NULL DEFAULT '', + `sql` TEXT, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tlayout` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(600) NOT NULL, - `id_group` INTEGER UNSIGNED NOT NULL, - `background` varchar(200) NOT NULL, - `height` INTEGER UNSIGNED NOT NULL default 0, - `width` INTEGER UNSIGNED NOT NULL default 0, - `background_color` varchar(50) NOT NULL default '#FFF', - `is_favourite` INTEGER UNSIGNED NOT NULL default 0, - `auto_adjust` INTEGER UNSIGNED NOT NULL default 0, - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(600) NOT NULL, + `id_group` INT UNSIGNED NOT NULL, + `background` VARCHAR(200) NOT NULL, + `height` INT UNSIGNED NOT NULL DEFAULT 0, + `width` INT UNSIGNED NOT NULL DEFAULT 0, + `background_color` VARCHAR(50) NOT NULL DEFAULT '#FFF', + `is_favourite` INT UNSIGNED NOT NULL DEFAULT 0, + `auto_adjust` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tlayout_data` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_data` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_layout` INTEGER UNSIGNED NOT NULL default 0, - `pos_x` INTEGER UNSIGNED NOT NULL default 0, - `pos_y` INTEGER UNSIGNED NOT NULL default 0, - `height` INTEGER UNSIGNED NOT NULL default 0, - `width` INTEGER UNSIGNED NOT NULL default 0, - `label` TEXT, - `image` varchar(200) DEFAULT "", - `type` tinyint(1) UNSIGNED NOT NULL default 0, - `period` INTEGER UNSIGNED NOT NULL default 3600, - `id_agente_modulo` mediumint(8) unsigned NOT NULL default '0', - `id_agent` int(10) unsigned NOT NULL default 0, - `id_layout_linked` INTEGER unsigned NOT NULL default '0', - `parent_item` INTEGER UNSIGNED NOT NULL default 0, - `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, - `id_metaconsole` int(10) NOT NULL default 0, - `id_group` INTEGER UNSIGNED NOT NULL default 0, - `id_custom_graph` INTEGER UNSIGNED NOT NULL default 0, - `border_width` INTEGER UNSIGNED NOT NULL default 0, - `type_graph` varchar(50) NOT NULL default 'area', - `label_position` varchar(50) NOT NULL default 'down', - `border_color` varchar(200) DEFAULT "", - `fill_color` varchar(200) DEFAULT "", - `show_statistics` tinyint(2) NOT NULL default '0', - `linked_layout_node_id` INT(10) NOT NULL default 0, - `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default', - `id_layout_linked_weight` int(10) NOT NULL default '0', - `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0, - `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0, - `element_group` int(10) NOT NULL default '0', - `show_on_top` tinyint(1) NOT NULL default '0', - `clock_animation` varchar(60) NOT NULL default "analogic_1", - `time_format` varchar(60) NOT NULL default "time", - `timezone` varchar(60) NOT NULL default "Europe/Madrid", - `show_last_value` tinyint(1) UNSIGNED NULL default '0', - `cache_expiration` INTEGER UNSIGNED NOT NULL default 0, - `title` TEXT default '', - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_layout` INT UNSIGNED NOT NULL DEFAULT 0, + `pos_x` INT UNSIGNED NOT NULL DEFAULT 0, + `pos_y` INT UNSIGNED NOT NULL DEFAULT 0, + `height` INT UNSIGNED NOT NULL DEFAULT 0, + `width` INT UNSIGNED NOT NULL DEFAULT 0, + `label` TEXT, + `image` VARCHAR(200) DEFAULT '', + `type` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `period` INT UNSIGNED NOT NULL DEFAULT 3600, + `id_agente_modulo` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `id_agent` INT UNSIGNED NOT NULL DEFAULT 0, + `id_layout_linked` INT unsigned NOT NULL DEFAULT 0, + `parent_item` INT UNSIGNED NOT NULL DEFAULT 0, + `enable_link` TINYINT UNSIGNED NOT NULL DEFAULT 1, + `id_metaconsole` INT NOT NULL DEFAULT 0, + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `id_custom_graph` INT UNSIGNED NOT NULL DEFAULT 0, + `border_width` INT UNSIGNED NOT NULL DEFAULT 0, + `type_graph` VARCHAR(50) NOT NULL DEFAULT 'area', + `label_position` VARCHAR(50) NOT NULL DEFAULT 'down', + `border_color` VARCHAR(200) DEFAULT '', + `fill_color` VARCHAR(200) DEFAULT '', + `show_statistics` TINYINT NOT NULL DEFAULT 0, + `linked_layout_node_id` INT NOT NULL DEFAULT 0, + `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default', + `id_layout_linked_weight` INT NOT NULL DEFAULT 0, + `linked_layout_status_as_service_warning` DOUBLE NOT NULL DEFAULT 0, + `linked_layout_status_as_service_critical` DOUBLE NOT NULL DEFAULT 0, + `element_group` INT NOT NULL DEFAULT 0, + `show_on_top` TINYINT NOT NULL DEFAULT 0, + `clock_animation` VARCHAR(60) NOT NULL DEFAULT 'analogic_1', + `time_format` VARCHAR(60) NOT NULL DEFAULT 'time', + `timezone` VARCHAR(60) NOT NULL DEFAULT 'Europe/Madrid', + `show_last_value` TINYINT UNSIGNED NULL DEFAULT 0, + `cache_expiration` INT UNSIGNED NOT NULL DEFAULT 0, + `title` TEXT , + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tplugin` -- --------------------------------------------------------------------- --- The fields "net_dst_opt", "net_port_opt", "user_opt" and --- "pass_opt" are deprecated for the 5.1. +-- The fields 'net_dst_opt', 'net_port_opt', 'user_opt' and +-- 'pass_opt' are deprecated for the 5.1. CREATE TABLE IF NOT EXISTS `tplugin` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(200) NOT NULL, - `description` mediumtext, - `max_timeout` int(4) UNSIGNED NOT NULL default 0, - `max_retries` int(4) UNSIGNED NOT NULL default 0, - `execute` varchar(250) NOT NULL, - `net_dst_opt` varchar(50) default '', - `net_port_opt` varchar(50) default '', - `user_opt` varchar(50) default '', - `pass_opt` varchar(50) default '', - `plugin_type` int(2) UNSIGNED NOT NULL default 0, - `macros` text, - `parameters` text, - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(200) NOT NULL, + `description` MEDIUMTEXT, + `max_timeout` INT UNSIGNED NOT NULL DEFAULT 0, + `max_retries` INT UNSIGNED NOT NULL DEFAULT 0, + `execute` VARCHAR(250) NOT NULL, + `net_dst_opt` VARCHAR(50) DEFAULT '', + `net_port_opt` VARCHAR(50) DEFAULT '', + `user_opt` VARCHAR(50) DEFAULT '', + `pass_opt` VARCHAR(50) DEFAULT '', + `plugin_type` INT UNSIGNED NOT NULL DEFAULT 0, + `macros` TEXT, + `parameters` TEXT, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tmodule` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmodule` ( - `id_module` int(11) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - PRIMARY KEY (`id_module`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_module` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id_module`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tserver_export` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tserver_export` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` varchar(600) BINARY NOT NULL default '', - `preffix` varchar(100) NOT NULL default '', - `interval` int(5) unsigned NOT NULL default '300', - `ip_server` varchar(100) NOT NULL default '', - `connect_mode` enum ('tentacle', 'ssh', 'local') default 'local', - `id_export_server` int(10) unsigned default NULL, - `user` varchar(100) NOT NULL default '', - `pass` varchar(100) NOT NULL default '', - `port` int(4) unsigned default '0', - `directory` varchar(100) NOT NULL default '', - `options` varchar(100) NOT NULL default '', - `timezone_offset` TINYINT(2) NULL DEFAULT '0' COMMENT 'Number of hours of diference with the server timezone' , - PRIMARY KEY (`id`), - INDEX id_export_server (`id_export_server`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(600) NOT NULL DEFAULT '', + `preffix` VARCHAR(100) NOT NULL DEFAULT '', + `interval` INT UNSIGNED NOT NULL DEFAULT 300, + `ip_server` VARCHAR(100) NOT NULL DEFAULT '', + `connect_mode` enum ('tentacle', 'ssh', 'local') DEFAULT 'local', + `id_export_server` INT UNSIGNED DEFAULT NULL, + `user` VARCHAR(100) NOT NULL DEFAULT '', + `pass` VARCHAR(100) NOT NULL DEFAULT '', + `port` INT UNSIGNED DEFAULT 0, + `directory` VARCHAR(100) NOT NULL DEFAULT '', + `options` VARCHAR(100) NOT NULL DEFAULT '', + `timezone_offset` TINYINT NULL DEFAULT 0 COMMENT 'Number of hours of difference with the server timezone', + PRIMARY KEY (`id`), + INDEX id_export_server (`id_export_server`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tserver_export_data` -- --------------------------------------------------------------------- -- id_export_server is real pandora fms export server process that manages this server --- id is the "destination" server to export +-- id is the 'destination' server to export CREATE TABLE IF NOT EXISTS `tserver_export_data` ( - `id` int(20) unsigned NOT NULL auto_increment, - `id_export_server` int(10) unsigned default NULL, - `agent_name` varchar(100) NOT NULL default '', - `module_name` varchar(600) NOT NULL default '', - `module_type` varchar(100) NOT NULL default '', - `data` varchar(255) default NULL, - `timestamp` datetime NOT NULL default '1970-01-01 00:00:00', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_export_server` INT UNSIGNED DEFAULT NULL, + `agent_name` VARCHAR(100) NOT NULL DEFAULT '', + `module_name` VARCHAR(600) NOT NULL DEFAULT '', + `module_type` VARCHAR(100) NOT NULL DEFAULT '', + `data` VARCHAR(255) DEFAULT NULL, + `timestamp` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tplanned_downtime` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tplanned_downtime` ( - `id` MEDIUMINT( 8 ) NOT NULL AUTO_INCREMENT, - `name` VARCHAR( 100 ) NOT NULL, - `description` TEXT NOT NULL, - `date_from` bigint(20) NOT NULL default '0', - `date_to` bigint(20) NOT NULL default '0', - `executed` tinyint(1) UNSIGNED NOT NULL default 0, - `id_group` mediumint(8) unsigned NULL default 0, - `only_alerts` tinyint(1) UNSIGNED NOT NULL default 0, - `monday` tinyint(1) default 0, - `tuesday` tinyint(1) default 0, - `wednesday` tinyint(1) default 0, - `thursday` tinyint(1) default 0, - `friday` tinyint(1) default 0, - `saturday` tinyint(1) default 0, - `sunday` tinyint(1) default 0, - `periodically_time_from` time NULL default NULL, - `periodically_time_to` time NULL default NULL, - `periodically_day_from` int(100) unsigned default NULL, - `periodically_day_to` int(100) unsigned default NULL, - `type_downtime` varchar(100) NOT NULL default 'disabled_agents_alerts', - `type_execution` varchar(100) NOT NULL default 'once', - `type_periodicity` varchar(100) NOT NULL default 'weekly', - `id_user` varchar(100) NOT NULL default '0', - PRIMARY KEY ( `id` ) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` MEDIUMINT NOT NULL AUTO_INCREMENT, + `name` VARCHAR( 100 ) NOT NULL, + `description` TEXT, + `date_from` BIGINT NOT NULL DEFAULT 0, + `date_to` BIGINT NOT NULL DEFAULT 0, + `executed` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `only_alerts` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `monday` TINYINT DEFAULT 0, + `tuesday` TINYINT DEFAULT 0, + `wednesday` TINYINT DEFAULT 0, + `thursday` TINYINT DEFAULT 0, + `friday` TINYINT DEFAULT 0, + `saturday` TINYINT DEFAULT 0, + `sunday` TINYINT DEFAULT 0, + `periodically_time_from` time NULL DEFAULT NULL, + `periodically_time_to` time NULL DEFAULT NULL, + `periodically_day_from` INT UNSIGNED DEFAULT NULL, + `periodically_day_to` INT UNSIGNED DEFAULT NULL, + `type_downtime` VARCHAR(100) NOT NULL DEFAULT 'disabled_agents_alerts', + `type_execution` VARCHAR(100) NOT NULL DEFAULT 'once', + `type_periodicity` VARCHAR(100) NOT NULL DEFAULT 'weekly', + `id_user` VARCHAR(100) NOT NULL DEFAULT '0', + PRIMARY KEY ( `id` ) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tplanned_downtime_agents` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tplanned_downtime_agents` ( - `id` int(20) unsigned NOT NULL auto_increment, - `id_agent` mediumint(8) unsigned NOT NULL default '0', - `id_downtime` mediumint(8) NOT NULL default '0', - `all_modules` tinyint(1) default 1, - `manually_disabled` tinyint(1) default 0, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`) - ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agent` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `id_downtime` MEDIUMINT NOT NULL DEFAULT 0, + `all_modules` TINYINT DEFAULT 1, + `manually_disabled` TINYINT DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`) + ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tplanned_downtime_modules` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tplanned_downtime_modules` ( - `id` int(20) unsigned NOT NULL auto_increment, - `id_agent` mediumint(8) unsigned NOT NULL default '0', - `id_agent_module` int(10) NOT NULL, - `id_downtime` mediumint(8) NOT NULL default '0', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`) - ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agent` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `id_agent_module` INT NOT NULL, + `id_downtime` MEDIUMINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_downtime`) REFERENCES tplanned_downtime(`id`) + ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- GIS extension Tables -- ---------------------------------------------------------------------- -- Table `tgis_data_history` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgis_data_history` ( - `id_tgis_data` INT NOT NULL AUTO_INCREMENT COMMENT 'key of the table' , - `longitude` DOUBLE NOT NULL , - `latitude` DOUBLE NOT NULL , - `altitude` DOUBLE NULL , - `start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'timestamp on wich the agente started to be in this position' , - `end_timestamp` TIMESTAMP NULL COMMENT 'timestamp on wich the agent was placed for last time on this position' , - `description` TEXT NULL COMMENT 'description of the region correoponding to this placemnt' , - `manual_placement` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '0 to show that the position cames from the agent, 1 to show that the position was established manualy' , - `number_of_packages` INT NOT NULL DEFAULT 1 COMMENT 'Number of data packages received with this position from the start_timestampa to the_end_timestamp' , - `tagente_id_agente` INT(10) UNSIGNED NOT NULL COMMENT 'reference to the agent' , - PRIMARY KEY (`id_tgis_data`) , - INDEX `start_timestamp_index` USING BTREE (`start_timestamp` ASC), - INDEX `end_timestamp_index` USING BTREE (`end_timestamp` ASC) ) -ENGINE = InnoDB -COMMENT = 'Table to store historical GIS information of the agents'; + `id_tgis_data` INT NOT NULL AUTO_INCREMENT COMMENT 'key of the table' , + `longitude` DOUBLE NOT NULL , + `latitude` DOUBLE NOT NULL , + `altitude` DOUBLE NULL , + `start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'timestamp on wich the agente started to be in this position' , + `end_timestamp` TIMESTAMP NULL COMMENT 'timestamp on wich the agent was placed for last time on this position' , + `description` TEXT NULL COMMENT 'description of the region correoponding to this placemnt' , + `manual_placement` TINYINT NOT NULL DEFAULT 0 COMMENT '0 to show that the position cames from the agent, 1 to show that the position was established manualy' , + `number_of_packages` INT NOT NULL DEFAULT 1 COMMENT 'Number of data packages received with this position from the start_timestampa to the_end_timestamp' , + `tagente_id_agente` INT UNSIGNED NOT NULL COMMENT 'reference to the agent' , + PRIMARY KEY (`id_tgis_data`) , + INDEX `start_timestamp_index` USING BTREE (`start_timestamp` ASC), + INDEX `end_timestamp_index` USING BTREE (`end_timestamp` ASC) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 COMMENT='Table to store historical GIS information of the agents'; -- ---------------------------------------------------------------------- -- Table `tgis_data_status` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgis_data_status` ( - `tagente_id_agente` INT(10) UNSIGNED NOT NULL COMMENT 'Reference to the agent' , - `current_longitude` DOUBLE NOT NULL COMMENT 'Last received longitude', - `current_latitude` DOUBLE NOT NULL COMMENT 'Last received latitude', - `current_altitude` DOUBLE NULL COMMENT 'Last received altitude', - `stored_longitude` DOUBLE NOT NULL COMMENT 'Reference longitude to see if the agent has moved', - `stored_latitude` DOUBLE NOT NULL COMMENT 'Reference latitude to see if the agent has moved', - `stored_altitude` DOUBLE NULL COMMENT 'Reference altitude to see if the agent has moved', - `number_of_packages` INT NOT NULL DEFAULT 1 COMMENT 'Number of data packages received with this position since start_timestampa' , - `start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp on wich the agente started to be in this position' , - `manual_placement` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '0 to show that the position cames from the agent, 1 to show that the position was established manualy' , - `description` TEXT NULL COMMENT 'description of the region correoponding to this placemnt' , - PRIMARY KEY (`tagente_id_agente`) , - INDEX `start_timestamp_index` USING BTREE (`start_timestamp` ASC), - INDEX `fk_tgisdata_tagente1` (`tagente_id_agente` ASC) , - CONSTRAINT `fk_tgisdata_tagente1` - FOREIGN KEY (`tagente_id_agente` ) - REFERENCES `tagente` (`id_agente` ) - ON DELETE CASCADE - ON UPDATE NO ACTION) -ENGINE = InnoDB -COMMENT = 'Table to store last GIS information of the agents'; + `tagente_id_agente` INT UNSIGNED NOT NULL COMMENT 'Reference to the agent' , + `current_longitude` DOUBLE NOT NULL COMMENT 'Last received longitude', + `current_latitude` DOUBLE NOT NULL COMMENT 'Last received latitude', + `current_altitude` DOUBLE NULL COMMENT 'Last received altitude', + `stored_longitude` DOUBLE NOT NULL COMMENT 'Reference longitude to see if the agent has moved', + `stored_latitude` DOUBLE NOT NULL COMMENT 'Reference latitude to see if the agent has moved', + `stored_altitude` DOUBLE NULL COMMENT 'Reference altitude to see if the agent has moved', + `number_of_packages` INT NOT NULL DEFAULT 1 COMMENT 'Number of data packages received with this position since start_timestampa' , + `start_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp on wich the agente started to be in this position' , + `manual_placement` TINYINT NOT NULL DEFAULT 0 COMMENT '0 to show that the position cames from the agent, 1 to show that the position was established manualy' , + `description` TEXT NULL COMMENT 'description of the region correoponding to this placemnt' , + PRIMARY KEY (`tagente_id_agente`) , + INDEX `start_timestamp_index` USING BTREE (`start_timestamp` ASC), + INDEX `fk_tgisdata_tagente1` (`tagente_id_agente` ASC) , + CONSTRAINT `fk_tgisdata_tagente1` + FOREIGN KEY (`tagente_id_agente` ) + REFERENCES `tagente` (`id_agente` ) + ON DELETE CASCADE + ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 COMMENT='Table to store last GIS information of the agents'; -- ---------------------------------------------------------------------- -- Table `tgis_map` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgis_map` ( - `id_tgis_map` INT NOT NULL AUTO_INCREMENT COMMENT 'table identifier' , - `map_name` VARCHAR(63) NOT NULL COMMENT 'Name of the map' , - `initial_longitude` DOUBLE NULL COMMENT "longitude of the center of the map when it\'s loaded" , - `initial_latitude` DOUBLE NULL COMMENT "latitude of the center of the map when it\'s loaded" , - `initial_altitude` DOUBLE NULL COMMENT "altitude of the center of the map when it\'s loaded" , - `zoom_level` TINYINT(2) NULL DEFAULT '1' COMMENT 'Zoom level to show when the map is loaded.' , - `map_background` VARCHAR(127) NULL COMMENT 'path on the server to the background image of the map' , - `default_longitude` DOUBLE NULL COMMENT 'default longitude for the agents placed on the map' , - `default_latitude` DOUBLE NULL COMMENT 'default latitude for the agents placed on the map' , - `default_altitude` DOUBLE NULL COMMENT 'default altitude for the agents placed on the map' , - `group_id` INT(10) NOT NULL DEFAULT 0 COMMENT 'Group that owns the map' , - `default_map` TINYINT(1) NULL DEFAULT 0 COMMENT '1 if this is the default map, 0 in other case', - PRIMARY KEY (`id_tgis_map`), - INDEX `map_name_index` (`map_name` ASC) -) -ENGINE = InnoDB -COMMENT = 'Table containing information about a gis map'; + `id_tgis_map` INT NOT NULL AUTO_INCREMENT COMMENT 'table identifier' , + `map_name` VARCHAR(63) NOT NULL COMMENT 'Name of the map' , + `initial_longitude` DOUBLE NULL COMMENT "longitude of the center of the map when it\'s loaded", + `initial_latitude` DOUBLE NULL COMMENT "latitude of the center of the map when it\'s loaded", + `initial_altitude` DOUBLE NULL COMMENT "altitude of the center of the map when it\'s loaded", + `zoom_level` TINYINT NULL DEFAULT 1 COMMENT 'Zoom level to show when the map is loaded.', + `map_background` VARCHAR(127) NULL COMMENT 'path on the server to the background image of the map', + `default_longitude` DOUBLE NULL COMMENT 'DEFAULT longitude for the agents placed on the map', + `default_latitude` DOUBLE NULL COMMENT 'DEFAULT latitude for the agents placed on the map', + `default_altitude` DOUBLE NULL COMMENT 'DEFAULT altitude for the agents placed on the map', + `group_id` INT NOT NULL DEFAULT 0 COMMENT 'Group that owns the map' , + `default_map` TINYINT NULL DEFAULT 0 COMMENT '1 if this is the DEFAULT map, 0 in other case', + PRIMARY KEY (`id_tgis_map`), + INDEX `map_name_index` (`map_name` ASC) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 COMMENT='Table containing information about a gis map'; -- --------------------------------------------------------------------- -- Table `tgis_map_connection` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgis_map_connection` ( - `id_tmap_connection` INT NOT NULL AUTO_INCREMENT COMMENT 'table id' , - `conection_name` VARCHAR(45) NULL COMMENT 'Name of the connection (name of the base layer)' , - `connection_type` VARCHAR(45) NULL COMMENT 'Type of map server to connect' , - `conection_data` TEXT NULL COMMENT 'connection information (this can probably change to fit better the possible connection parameters)' , - `num_zoom_levels` TINYINT(2) NULL COMMENT 'Number of zoom levels available' , - `default_zoom_level` TINYINT(2) NOT NULL DEFAULT 16 COMMENT 'Default Zoom Level for the connection' , - `default_longitude` DOUBLE NULL COMMENT 'default longitude for the agents placed on the map' , - `default_latitude` DOUBLE NULL COMMENT 'default latitude for the agents placed on the map' , - `default_altitude` DOUBLE NULL COMMENT 'default altitude for the agents placed on the map' , - `initial_longitude` DOUBLE NULL COMMENT "longitude of the center of the map when it\'s loaded" , - `initial_latitude` DOUBLE NULL COMMENT "latitude of the center of the map when it\'s loaded" , - `initial_altitude` DOUBLE NULL COMMENT "altitude of the center of the map when it\'s loaded" , - `group_id` INT(10) NOT NULL DEFAULT 0 COMMENT 'Group that owns the map', - PRIMARY KEY (`id_tmap_connection`) ) -ENGINE = InnoDB -COMMENT = 'Table to store the map connection information'; + `id_tmap_connection` INT NOT NULL AUTO_INCREMENT COMMENT 'table id', + `conection_name` VARCHAR(45) NULL COMMENT 'Name of the connection (name of the base layer)', + `connection_type` VARCHAR(45) NULL COMMENT 'Type of map server to connect', + `conection_data` TEXT NULL COMMENT 'connection information (this can probably change to fit better the possible connection parameters)', + `num_zoom_levels` TINYINT NULL COMMENT 'Number of zoom levels available', + `default_zoom_level` TINYINT NOT NULL DEFAULT 16 COMMENT 'DEFAULT Zoom Level for the connection', + `default_longitude` DOUBLE NULL COMMENT 'DEFAULT longitude for the agents placed on the map', + `default_latitude` DOUBLE NULL COMMENT 'DEFAULT latitude for the agents placed on the map', + `default_altitude` DOUBLE NULL COMMENT 'DEFAULT altitude for the agents placed on the map', + `initial_longitude` DOUBLE NULL COMMENT "longitude of the center of the map when it\'s loaded", + `initial_latitude` DOUBLE NULL COMMENT "latitude of the center of the map when it\'s loaded", + `initial_altitude` DOUBLE NULL COMMENT "altitude of the center of the map when it\'s loaded", + `group_id` INT NOT NULL DEFAULT 0 COMMENT 'Group that owns the map', + PRIMARY KEY (`id_tmap_connection`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 COMMENT='Table to store the map connection information'; -- ----------------------------------------------------- -- Table `tgis_map_has_tgis_map_con` (tgis_map_has_tgis_map_connection) -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgis_map_has_tgis_map_con` ( - `tgis_map_id_tgis_map` INT NOT NULL COMMENT 'reference to tgis_map', - `tgis_map_con_id_tmap_con` INT NOT NULL COMMENT 'reference to tgis_map_connection', - `modification_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Last Modification Time of the Connection', - `default_map_connection` TINYINT(1) NULL DEFAULT FALSE COMMENT 'Flag to mark the default map connection of a map', - PRIMARY KEY (`tgis_map_id_tgis_map`, `tgis_map_con_id_tmap_con`), - INDEX `fk_tgis_map_has_tgis_map_connection_tgis_map1` (`tgis_map_id_tgis_map` ASC), - INDEX `fk_tgis_map_has_tgis_map_connection_tgis_map_connection1` (`tgis_map_con_id_tmap_con` ASC), - CONSTRAINT `fk_tgis_map_has_tgis_map_connection_tgis_map1` - FOREIGN KEY (`tgis_map_id_tgis_map`) - REFERENCES `tgis_map` (`id_tgis_map`) - ON DELETE CASCADE - ON UPDATE NO ACTION, - CONSTRAINT `fk_tgis_map_has_tgis_map_connection_tgis_map_connection1` - FOREIGN KEY (`tgis_map_con_id_tmap_con`) - REFERENCES `tgis_map_connection` (`id_tmap_connection`) - ON DELETE CASCADE - ON UPDATE NO ACTION) -ENGINE = InnoDB -COMMENT = 'Table to asociate a connection to a gis map'; + `tgis_map_id_tgis_map` INT NOT NULL COMMENT 'reference to tgis_map', + `tgis_map_con_id_tmap_con` INT NOT NULL COMMENT 'reference to tgis_map_connection', + `modification_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Last Modification Time of the Connection', + `default_map_connection` TINYINT NULL DEFAULT FALSE COMMENT 'Flag to mark the DEFAULT map connection of a map', + PRIMARY KEY (`tgis_map_id_tgis_map`, `tgis_map_con_id_tmap_con`), + INDEX `fk_tgis_map_has_tgis_map_connection_tgis_map1` (`tgis_map_id_tgis_map` ASC), + INDEX `fk_tgis_map_has_tgis_map_connection_tgis_map_connection1` (`tgis_map_con_id_tmap_con` ASC), + CONSTRAINT `fk_tgis_map_has_tgis_map_connection_tgis_map1` + FOREIGN KEY (`tgis_map_id_tgis_map`) + REFERENCES `tgis_map` (`id_tgis_map`) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_tgis_map_has_tgis_map_connection_tgis_map_connection1` + FOREIGN KEY (`tgis_map_con_id_tmap_con`) + REFERENCES `tgis_map_connection` (`id_tmap_connection`) + ON DELETE CASCADE + ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 COMMENT='Table to asociate a connection to a gis map'; -- ----------------------------------------------------- -- Table `tgis_map_layer` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgis_map_layer` ( - `id_tmap_layer` INT NOT NULL AUTO_INCREMENT COMMENT 'table id' , - `layer_name` VARCHAR(45) NOT NULL COMMENT 'Name of the layer ' , - `view_layer` TINYINT(1) NOT NULL DEFAULT TRUE COMMENT 'True if the layer must be shown' , - `layer_stack_order` TINYINT(3) NULL DEFAULT 0 COMMENT 'Number of order of the layer in the layer stack, bigger means upper on the stack.\n' , - `tgis_map_id_tgis_map` INT NOT NULL COMMENT 'reference to the map containing the layer' , - `tgrupo_id_grupo` MEDIUMINT(4) NOT NULL COMMENT 'reference to the group shown in the layer' , - PRIMARY KEY (`id_tmap_layer`) , - INDEX `fk_tmap_layer_tgis_map1` (`tgis_map_id_tgis_map` ASC) , - CONSTRAINT `fk_tmap_layer_tgis_map1` - FOREIGN KEY (`tgis_map_id_tgis_map` ) - REFERENCES `tgis_map` (`id_tgis_map` ) - ON DELETE CASCADE - ON UPDATE NO ACTION) -ENGINE = InnoDB -COMMENT = 'Table containing information about the map layers'; + `id_tmap_layer` INT NOT NULL AUTO_INCREMENT COMMENT 'table id', + `layer_name` VARCHAR(45) NOT NULL COMMENT 'Name of the layer ', + `view_layer` TINYINT NOT NULL DEFAULT TRUE COMMENT 'True if the layer must be shown', + `layer_stack_order` TINYINT NULL DEFAULT 0 COMMENT 'Number of order of the layer in the layer stack, bigger means upper on the stack.', + `tgis_map_id_tgis_map` INT NOT NULL COMMENT 'reference to the map containing the layer', + `tgrupo_id_grupo` MEDIUMINT NOT NULL COMMENT 'reference to the group shown in the layer', + PRIMARY KEY (`id_tmap_layer`), + INDEX `fk_tmap_layer_tgis_map1` (`tgis_map_id_tgis_map` ASC), + CONSTRAINT `fk_tmap_layer_tgis_map1` + FOREIGN KEY (`tgis_map_id_tgis_map` ) + REFERENCES `tgis_map` (`id_tgis_map` ) + ON DELETE CASCADE + ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 COMMENT='Table containing information about the map layers'; -- ----------------------------------------------------- -- Table `tgis_map_layer_has_tagente` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgis_map_layer_has_tagente` ( - `tgis_map_layer_id_tmap_layer` INT NOT NULL , - `tagente_id_agente` INT(10) UNSIGNED NOT NULL , - PRIMARY KEY (`tgis_map_layer_id_tmap_layer`, `tagente_id_agente`) , - INDEX `fk_tgis_map_layer_has_tagente_tgis_map_layer1` (`tgis_map_layer_id_tmap_layer` ASC) , - INDEX `fk_tgis_map_layer_has_tagente_tagente1` (`tagente_id_agente` ASC) , - CONSTRAINT `fk_tgis_map_layer_has_tagente_tgis_map_layer1` - FOREIGN KEY (`tgis_map_layer_id_tmap_layer` ) - REFERENCES `tgis_map_layer` (`id_tmap_layer` ) - ON DELETE CASCADE - ON UPDATE NO ACTION, - CONSTRAINT `fk_tgis_map_layer_has_tagente_tagente1` - FOREIGN KEY (`tagente_id_agente` ) - REFERENCES `tagente` (`id_agente` ) - ON DELETE CASCADE - ON UPDATE NO ACTION) -ENGINE = InnoDB -COMMENT = 'Table to define wich agents are shown in a layer'; + `tgis_map_layer_id_tmap_layer` INT NOT NULL, + `tagente_id_agente` INT UNSIGNED NOT NULL, + PRIMARY KEY (`tgis_map_layer_id_tmap_layer`, `tagente_id_agente`), + INDEX `fk_tgis_map_layer_has_tagente_tgis_map_layer1` (`tgis_map_layer_id_tmap_layer` ASC), + INDEX `fk_tgis_map_layer_has_tagente_tagente1` (`tagente_id_agente` ASC), + CONSTRAINT `fk_tgis_map_layer_has_tagente_tgis_map_layer1` + FOREIGN KEY (`tgis_map_layer_id_tmap_layer` ) + REFERENCES `tgis_map_layer` (`id_tmap_layer` ) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_tgis_map_layer_has_tagente_tagente1` + FOREIGN KEY (`tagente_id_agente` ) + REFERENCES `tagente` (`id_agente` ) + ON DELETE CASCADE + ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 COMMENT='Table to define wich agents are shown in a layer'; -- ----------------------------------------------------- -- Table `tgis_map_layer_groups` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgis_map_layer_groups` ( - `layer_id` INT NOT NULL, - `group_id` MEDIUMINT(4) UNSIGNED NOT NULL, - `agent_id` INT(10) UNSIGNED NOT NULL COMMENT 'Used to link the position to the group', - PRIMARY KEY (`layer_id`, `group_id`), - FOREIGN KEY (`layer_id`) - REFERENCES `tgis_map_layer` (`id_tmap_layer`) - ON DELETE CASCADE, - FOREIGN KEY (`group_id`) - REFERENCES `tgrupo` (`id_grupo`) - ON DELETE CASCADE, - FOREIGN KEY (`agent_id`) - REFERENCES `tagente` (`id_agente`) - ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `layer_id` INT NOT NULL, + `group_id` MEDIUMINT UNSIGNED NOT NULL, + `agent_id` INT UNSIGNED NOT NULL COMMENT 'Used to link the position to the group', + PRIMARY KEY (`layer_id`, `group_id`), + FOREIGN KEY (`layer_id`) + REFERENCES `tgis_map_layer` (`id_tmap_layer`) + ON DELETE CASCADE, + FOREIGN KEY (`group_id`) + REFERENCES `tgrupo` (`id_grupo`) + ON DELETE CASCADE, + FOREIGN KEY (`agent_id`) + REFERENCES `tagente` (`id_agente`) + ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tgroup_stat` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgroup_stat` ( - `id_group` int(10) unsigned NOT NULL default '0', - `modules` int(10) unsigned NOT NULL default '0', - `normal` int(10) unsigned NOT NULL default '0', - `critical` int(10) unsigned NOT NULL default '0', - `warning` int(10) unsigned NOT NULL default '0', - `unknown` int(10) unsigned NOT NULL default '0', - `non-init` int(10) unsigned NOT NULL default '0', - `alerts` int(10) unsigned NOT NULL default '0', - `alerts_fired` int(10) unsigned NOT NULL default '0', - `agents` int(10) unsigned NOT NULL default '0', - `agents_unknown` int(10) unsigned NOT NULL default '0', - `utimestamp` int(20) unsigned NOT NULL default 0, - PRIMARY KEY (`id_group`) -) ENGINE=InnoDB -COMMENT = 'Table to store global system stats per group' -DEFAULT CHARSET=utf8; + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `modules` INT UNSIGNED NOT NULL DEFAULT 0, + `normal` INT UNSIGNED NOT NULL DEFAULT 0, + `critical` INT UNSIGNED NOT NULL DEFAULT 0, + `warning` INT UNSIGNED NOT NULL DEFAULT 0, + `unknown` INT UNSIGNED NOT NULL DEFAULT 0, + `non-init` INT UNSIGNED NOT NULL DEFAULT 0, + `alerts` INT UNSIGNED NOT NULL DEFAULT 0, + `alerts_fired` INT UNSIGNED NOT NULL DEFAULT 0, + `agents` INT UNSIGNED NOT NULL DEFAULT 0, + `agents_unknown` INT UNSIGNED NOT NULL DEFAULT 0, + `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id_group`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 COMMENT = 'Table to store global system stats per group'; -- ---------------------------------------------------------------------- -- Table `tnetwork_map` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetwork_map` ( - `id_networkmap` INT UNSIGNED NOT NULL AUTO_INCREMENT, - `id_user` VARCHAR(60) NOT NULL, - `name` VARCHAR(100) NOT NULL, - `type` VARCHAR(20) NOT NULL, - `layout` VARCHAR(20) NOT NULL, - `nooverlap` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `simple` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `regenerate` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, - `font_size` INT UNSIGNED NOT NULL DEFAULT 12, - `id_group` INT NOT NULL DEFAULT 0, - `id_module_group` INT NOT NULL DEFAULT 0, - `id_policy` INT NOT NULL DEFAULT 0, - `depth` VARCHAR(20) NOT NULL, - `only_modules_with_alerts` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `hide_policy_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `zoom` FLOAT UNSIGNED NOT NULL DEFAULT 1, - `distance_nodes` FLOAT UNSIGNED NOT NULL DEFAULT 2.5, - `center` INT UNSIGNED NOT NULL DEFAULT 0, - `contracted_nodes` TEXT, - `show_snmp_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `text_filter` VARCHAR(100) NOT NULL DEFAULT "", - `dont_show_subgroups` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `pandoras_children` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `show_groups` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `show_modules` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `id_agent` INT NOT NULL DEFAULT 0, - `server_name` VARCHAR(100) NOT NULL, - `show_modulegroup` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `l2_network` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `id_tag` int(11) DEFAULT 0, - `store_group` int(11) DEFAULT 0, - PRIMARY KEY (`id_networkmap`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_networkmap` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(60) NOT NULL, + `name` VARCHAR(100) NOT NULL, + `type` VARCHAR(20) NOT NULL, + `layout` VARCHAR(20) NOT NULL, + `nooverlap` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `simple` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `regenerate` TINYINT UNSIGNED NOT NULL DEFAULT 1, + `font_size` INT UNSIGNED NOT NULL DEFAULT 12, + `id_group` INT NOT NULL DEFAULT 0, + `id_module_group` INT NOT NULL DEFAULT 0, + `id_policy` INT NOT NULL DEFAULT 0, + `depth` VARCHAR(20) NOT NULL, + `only_modules_with_alerts` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `hide_policy_modules` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `zoom` DOUBLE NOT NULL DEFAULT 1, + `distance_nodes` DOUBLE NOT NULL DEFAULT 2.5, + `center` INT UNSIGNED NOT NULL DEFAULT 0, + `contracted_nodes` TEXT, + `show_snmp_modules` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `text_filter` VARCHAR(100) NOT NULL DEFAULT '', + `dont_show_subgroups` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `pandoras_children` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `show_groups` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `show_modules` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_agent` INT NOT NULL DEFAULT 0, + `server_name` VARCHAR(100) NOT NULL, + `show_modulegroup` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `l2_network` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_tag` INT DEFAULT 0, + `store_group` INT DEFAULT 0, + PRIMARY KEY (`id_networkmap`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tsnmp_filter` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tsnmp_filter` ( - `id_snmp_filter` int(10) unsigned NOT NULL auto_increment, - `description` varchar(255) default '', - `filter` varchar(255) default '', - `unified_filters_id` int(10) not null default 0, - PRIMARY KEY (`id_snmp_filter`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_snmp_filter` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `description` VARCHAR(255) DEFAULT '', + `filter` VARCHAR(255) DEFAULT '', + `unified_filters_id` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_snmp_filter`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tagent_custom_fields` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagent_custom_fields` ( - `id_field` int(10) unsigned NOT NULL auto_increment, - `name` varchar(45) NOT NULL default '', - `display_on_front` tinyint(1) NOT NULL default 0, - `is_password_type` tinyint(1) NOT NULL default 0, - `combo_values` TEXT NOT NULL DEFAULT '', - PRIMARY KEY (`id_field`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_field` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(45) NOT NULL DEFAULT '', + `display_on_front` TINYINT NOT NULL DEFAULT 0, + `is_password_type` TINYINT NOT NULL DEFAULT 0, + `combo_values` TEXT , + PRIMARY KEY (`id_field`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tagent_custom_data` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagent_custom_data` ( - `id_field` int(10) unsigned NOT NULL, - `id_agent` int(10) unsigned NOT NULL, - `description` text, - FOREIGN KEY (`id_field`) REFERENCES tagent_custom_fields(`id_field`) - ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) - ON UPDATE CASCADE ON DELETE CASCADE, - PRIMARY KEY (`id_field`, `id_agent`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_field` INT UNSIGNED NOT NULL, + `id_agent` INT UNSIGNED NOT NULL, + `description` TEXT, + FOREIGN KEY (`id_field`) REFERENCES tagent_custom_fields(`id_field`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`) + ON UPDATE CASCADE ON DELETE CASCADE, + PRIMARY KEY (`id_field`, `id_agent`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `ttag` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `ttag` ( - `id_tag` integer(10) unsigned NOT NULL auto_increment, - `name` text NOT NULL default '', - `description` text NOT NULL, - `url` mediumtext NOT NULL, - `email` text NULL, - `phone` text NULL, - `previous_name` text NULL, - PRIMARY KEY (`id_tag`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_tag` INT unsigned NOT NULL AUTO_INCREMENT, + `name` TEXT , + `description` TEXT, + `url` MEDIUMTEXT, + `email` TEXT NULL, + `phone` TEXT NULL, + `previous_name` TEXT NULL, + PRIMARY KEY (`id_tag`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `ttag_module` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `ttag_module` ( - `id_tag` int(10) NOT NULL, - `id_agente_modulo` int(10) NOT NULL DEFAULT 0, - `id_policy_module` int(10) NOT NULL DEFAULT 0, - PRIMARY KEY (id_tag, id_agente_modulo), - KEY `idx_id_agente_modulo` (`id_agente_modulo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_tag` INT NOT NULL, + `id_agente_modulo` INT NOT NULL DEFAULT 0, + `id_policy_module` INT NOT NULL DEFAULT 0, + PRIMARY KEY (id_tag, id_agente_modulo), + KEY `idx_id_agente_modulo` (`id_agente_modulo`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `ttag_policy_module` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `ttag_policy_module` ( - `id_tag` int(10) NOT NULL, - `id_policy_module` int(10) NOT NULL DEFAULT 0, - PRIMARY KEY (id_tag, id_policy_module), - KEY `idx_id_policy_module` (`id_policy_module`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_tag` INT NOT NULL, + `id_policy_module` INT NOT NULL DEFAULT 0, + PRIMARY KEY (id_tag, id_policy_module), + KEY `idx_id_policy_module` (`id_policy_module`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tnetflow_filter` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetflow_filter` ( - `id_sg` int(10) unsigned NOT NULL auto_increment, - `id_name` varchar(600) NOT NULL default '0', - `id_group` int(10), - `ip_dst` TEXT NOT NULL, - `ip_src` TEXT NOT NULL, - `dst_port` TEXT NOT NULL, - `src_port` TEXT NOT NULL, - `router_ip` TEXT NOT NULL, - `advanced_filter` TEXT NOT NULL, - `filter_args` TEXT NOT NULL, - `aggregate` varchar(60), - PRIMARY KEY (`id_sg`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_sg` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_name` VARCHAR(600) NOT NULL DEFAULT '0', + `id_group` INT, + `ip_dst` TEXT, + `ip_src` TEXT, + `dst_port` TEXT, + `src_port` TEXT, + `router_ip` TEXT, + `advanced_filter` TEXT, + `filter_args` TEXT, + `aggregate` VARCHAR(60), + PRIMARY KEY (`id_sg`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tnetflow_report` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetflow_report` ( - `id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_name` varchar(150) NOT NULL default '', - `description` TEXT NOT NULL, - `id_group` int(10), - `server_name` TEXT NOT NULL, - PRIMARY KEY(`id_report`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_report` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_name` VARCHAR(150) NOT NULL DEFAULT '', + `description` TEXT, + `id_group` INT, + `server_name` TEXT, + PRIMARY KEY(`id_report`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tnetflow_report_content` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetflow_report_content` ( - `id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_report` INTEGER UNSIGNED NOT NULL default 0, - `id_filter` INTEGER UNSIGNED NOT NULL default 0, - `description` TEXT NOT NULL, - `date` bigint(20) NOT NULL default '0', - `period` int(11) NOT NULL default 0, - `max` int (11) NOT NULL default 0, - `show_graph` varchar(60), - `order` int (11) NOT NULL default 0, - PRIMARY KEY(`id_rc`), - FOREIGN KEY (`id_report`) REFERENCES tnetflow_report(`id_report`) - ON DELETE CASCADE, - FOREIGN KEY (`id_filter`) REFERENCES tnetflow_filter(`id_sg`) - ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_rc` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_report` INT UNSIGNED NOT NULL DEFAULT 0, + `id_filter` INT UNSIGNED NOT NULL DEFAULT 0, + `description` TEXT, + `date` BIGINT NOT NULL DEFAULT 0, + `period` INT NOT NULL DEFAULT 0, + `max` INT NOT NULL DEFAULT 0, + `show_graph` VARCHAR(60), + `order` INT NOT NULL DEFAULT 0, + PRIMARY KEY(`id_rc`), + FOREIGN KEY (`id_report`) REFERENCES tnetflow_report(`id_report`) + ON DELETE CASCADE, + FOREIGN KEY (`id_filter`) REFERENCES tnetflow_filter(`id_sg`) + ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tpassword_history` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpassword_history` ( - `id_pass` int(10) unsigned NOT NULL auto_increment, - `id_user` varchar(60) NOT NULL, - `password` varchar(45) default NULL, - `date_begin` DATETIME NOT NULL DEFAULT 0, - `date_end` DATETIME NOT NULL DEFAULT 0, - PRIMARY KEY (`id_pass`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_pass` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(60) NOT NULL, + `password` VARCHAR(45) DEFAULT NULL, + `date_begin` DATETIME, + `date_end` DATETIME, + PRIMARY KEY (`id_pass`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tevent_response` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tevent_response` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` varchar(600) NOT NULL default '', - `description` TEXT NOT NULL, - `target` TEXT NOT NULL, - `type` varchar(60) NOT NULL, - `id_group` MEDIUMINT(4) NOT NULL default 0, - `modal_width` INTEGER NOT NULL DEFAULT 0, - `modal_height` INTEGER NOT NULL DEFAULT 0, - `new_window` TINYINT(4) NOT NULL DEFAULT 0, - `params` TEXT NOT NULL, - `server_to_exec` int(10) unsigned NOT NULL DEFAULT 0, - `command_timeout` int(5) unsigned NOT NULL DEFAULT 90, - `display_command` tinyint(1) DEFAULT 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(600) NOT NULL DEFAULT '', + `description` TEXT, + `target` TEXT, + `type` VARCHAR(60) NOT NULL, + `id_group` MEDIUMINT NOT NULL DEFAULT 0, + `modal_width` INT NOT NULL DEFAULT 0, + `modal_height` INT NOT NULL DEFAULT 0, + `new_window` TINYINT NOT NULL DEFAULT 0, + `params` TEXT NOT NULL, + `server_to_exec` INT UNSIGNED NOT NULL DEFAULT 0, + `command_timeout` INT UNSIGNED NOT NULL DEFAULT 90, + `display_command` TINYINT DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tcategory` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tcategory` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` varchar(600) NOT NULL default '', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(600) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tupdate_settings` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tupdate_settings` ( - `key` varchar(255) default '', - `value` varchar(255) default '', PRIMARY KEY (`key`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `key` VARCHAR(255) DEFAULT '', + `value` VARCHAR(255) DEFAULT '', PRIMARY KEY (`key`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tupdate_package` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tupdate_package` ( - id int(11) unsigned NOT NULL auto_increment, - timestamp datetime NOT NULL, - description varchar(255) default '', PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + timestamp DATETIME NOT NULL, + description VARCHAR(255) DEFAULT '', PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tupdate` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tupdate` ( - id int(11) unsigned NOT NULL auto_increment, - type enum('code', 'db_data', 'db_schema', 'binary'), - id_update_package int(11) unsigned NOT NULL default 0, - filename varchar(250) default '', - checksum varchar(250) default '', - previous_checksum varchar(250) default '', - svn_version int(4) unsigned NOT NULL default 0, - data LONGTEXT, - data_rollback LONGTEXT, - description TEXT, - db_table_name varchar(140) default '', - db_field_name varchar(140) default '', - db_field_value varchar(1024) default '', PRIMARY KEY (`id`), - FOREIGN KEY (`id_update_package`) REFERENCES tupdate_package(`id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + type ENUM('code', 'db_data', 'db_schema', 'binary'), + id_update_package INT UNSIGNED NOT NULL DEFAULT 0, + filename VARCHAR(250) DEFAULT '', + checksum VARCHAR(250) DEFAULT '', + previous_checksum VARCHAR(250) DEFAULT '', + svn_version INT UNSIGNED NOT NULL DEFAULT 0, + data LONGTEXT, + data_rollback LONGTEXT, + description TEXT, + db_table_name VARCHAR(140) DEFAULT '', + db_field_name VARCHAR(140) DEFAULT '', + db_field_value VARCHAR(1024) DEFAULT '', PRIMARY KEY (`id`), + FOREIGN KEY (`id_update_package`) REFERENCES tupdate_package(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tupdate_journal` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tupdate_journal` ( - id int(11) unsigned NOT NULL auto_increment, - id_update int(11) unsigned NOT NULL default 0, PRIMARY KEY (`id`), - FOREIGN KEY (`id_update`) REFERENCES tupdate(`id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + id INT UNSIGNED NOT NULL AUTO_INCREMENT, + id_update INT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`), + FOREIGN KEY (`id_update`) REFERENCES tupdate(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `talert_snmp_action` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `talert_snmp_action` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_alert_snmp` int(10) unsigned NOT NULL default '0', - `alert_type` int(2) unsigned NOT NULL default '0', - `al_field1` text NOT NULL, - `al_field2` text NOT NULL, - `al_field3` text NOT NULL, - `al_field4` text NOT NULL, - `al_field5` text NOT NULL, - `al_field6` text NOT NULL, - `al_field7` text NOT NULL, - `al_field8` text NOT NULL, - `al_field9` text NOT NULL, - `al_field10` text NOT NULL, - `al_field11` text NOT NULL, - `al_field12` text NOT NULL, - `al_field13` text NOT NULL, - `al_field14` text NOT NULL, - `al_field15` text NOT NULL, - `al_field16` text NOT NULL, - `al_field17` text NOT NULL, - `al_field18` text NOT NULL, - `al_field19` text NOT NULL, - `al_field20` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_alert_snmp` INT UNSIGNED NOT NULL DEFAULT 0, + `alert_type` INT UNSIGNED NOT NULL DEFAULT 0, + `al_field1` TEXT, + `al_field2` TEXT, + `al_field3` TEXT, + `al_field4` TEXT, + `al_field5` TEXT, + `al_field6` TEXT, + `al_field7` TEXT, + `al_field8` TEXT, + `al_field9` TEXT, + `al_field10` TEXT, + `al_field11` TEXT, + `al_field12` TEXT, + `al_field13` TEXT, + `al_field14` TEXT, + `al_field15` TEXT, + `al_field16` TEXT, + `al_field17` TEXT, + `al_field18` TEXT, + `al_field19` TEXT, + `al_field20` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tsessions_php` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tsessions_php` ( - `id_session` CHAR(52) NOT NULL, - `last_active` INTEGER NOT NULL, - `data` TEXT, - PRIMARY KEY (`id_session`) -)ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_session` CHAR(52) NOT NULL, + `last_active` INT NOT NULL, + `data` TEXT, + PRIMARY KEY (`id_session`) +)ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tmap` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmap` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_group` int(10) unsigned NOT NULL default 0, - `id_user` varchar(250) NOT NULL default '', - `type` int(10) unsigned NOT NULL default 0, - `subtype` int(10) unsigned NOT NULL default 0, - `name` varchar(250) default '', - `description` TEXT, - `height` INTEGER UNSIGNED NOT NULL default 0, - `width` INTEGER UNSIGNED NOT NULL default 0, - `center_x` INTEGER NOT NULL default 0, - `center_y` INTEGER NOT NULL default 0, - `background` varchar(250) default '', - `background_options` INTEGER UNSIGNED NOT NULL default 0, - `source_period` INTEGER UNSIGNED NOT NULL default 0, - `source` INTEGER UNSIGNED NOT NULL default 0, - `source_data` varchar(250) default '', - `generation_method` INTEGER UNSIGNED NOT NULL default 0, - `generated` INTEGER UNSIGNED NOT NULL default 0, - `filter` TEXT, - `id_group_map` INT(10) UNSIGNED NOT NULL default 0, - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `id_user` VARCHAR(250) NOT NULL DEFAULT '', + `type` INT UNSIGNED NOT NULL DEFAULT 0, + `subtype` INT UNSIGNED NOT NULL DEFAULT 0, + `name` VARCHAR(250) DEFAULT '', + `description` TEXT, + `height` INT UNSIGNED NOT NULL DEFAULT 0, + `width` INT UNSIGNED NOT NULL DEFAULT 0, + `center_x` INT NOT NULL DEFAULT 0, + `center_y` INT NOT NULL DEFAULT 0, + `background` VARCHAR(250) DEFAULT '', + `background_options` INT UNSIGNED NOT NULL DEFAULT 0, + `source_period` INT UNSIGNED NOT NULL DEFAULT 0, + `source` INT UNSIGNED NOT NULL DEFAULT 0, + `source_data` VARCHAR(250) DEFAULT '', + `generation_method` INT UNSIGNED NOT NULL DEFAULT 0, + `generated` INT UNSIGNED NOT NULL DEFAULT 0, + `filter` TEXT, + `id_group_map` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `titem` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `titem` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_map` int(10) unsigned NOT NULL default 0, - `x` INTEGER NOT NULL default 0, - `y` INTEGER NOT NULL default 0, - `z` INTEGER NOT NULL default 0, - `deleted` INTEGER(1) unsigned NOT NULL default 0, - `type` INTEGER UNSIGNED NOT NULL default 0, - `refresh` INTEGER UNSIGNED NOT NULL default 0, - `source` INTEGER UNSIGNED NOT NULL default 0, - `source_data` varchar(250) default '', - `options` TEXT, - `style` TEXT, - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_map` INT UNSIGNED NOT NULL DEFAULT 0, + `x` INT NOT NULL DEFAULT 0, + `y` INT NOT NULL DEFAULT 0, + `z` INT NOT NULL DEFAULT 0, + `deleted` INT unsigned NOT NULL DEFAULT 0, + `type` INT UNSIGNED NOT NULL DEFAULT 0, + `refresh` INT UNSIGNED NOT NULL DEFAULT 0, + `source` INT UNSIGNED NOT NULL DEFAULT 0, + `source_data` VARCHAR(250) DEFAULT '', + `options` TEXT, + `style` TEXT, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `trel_item` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `trel_item` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_parent` int(10) unsigned NOT NULL default 0, - `id_child` int(10) unsigned NOT NULL default 0, - `id_map` int(10) unsigned NOT NULL default 0, - `id_parent_source_data` int(10) unsigned NOT NULL default 0, - `id_child_source_data` int(10) unsigned NOT NULL default 0, - `parent_type` int(10) unsigned NOT NULL default 0, - `child_type` int(10) unsigned NOT NULL default 0, - `id_item` int(10) unsigned NOT NULL default 0, - `deleted` int(1) unsigned NOT NULL default 0, - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_parent` INT UNSIGNED NOT NULL DEFAULT 0, + `id_child` INT UNSIGNED NOT NULL DEFAULT 0, + `id_map` INT UNSIGNED NOT NULL DEFAULT 0, + `id_parent_source_data` INT UNSIGNED NOT NULL DEFAULT 0, + `id_child_source_data` INT UNSIGNED NOT NULL DEFAULT 0, + `parent_type` INT UNSIGNED NOT NULL DEFAULT 0, + `child_type` INT UNSIGNED NOT NULL DEFAULT 0, + `id_item` INT UNSIGNED NOT NULL DEFAULT 0, + `deleted` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tlocal_component` @@ -2395,488 +2386,488 @@ CREATE TABLE IF NOT EXISTS `trel_item` ( -- tlocal_component is a repository of local modules for -- physical agents on Windows / Unix physical agents CREATE TABLE IF NOT EXISTS `tlocal_component` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` text NOT NULL, - `data` mediumtext NOT NULL, - `description` varchar(1024) default NULL, - `id_os` int(10) unsigned default '0', - `os_version` varchar(100) default '', - `id_network_component_group` int(10) unsigned NOT NULL default 0, - `type` smallint(6) NOT NULL default '6', - `max` bigint(20) NOT NULL default '0', - `min` bigint(20) NOT NULL default '0', - `module_interval` mediumint(8) unsigned NOT NULL default '0', - `id_module_group` tinyint(4) unsigned NOT NULL default '0', - `history_data` tinyint(1) unsigned default '1', - `min_warning` double(18,2) default 0, - `max_warning` double(18,2) default 0, - `str_warning` text, - `min_critical` double(18,2) default 0, - `max_critical` double(18,2) default 0, - `str_critical` text, - `min_ff_event` int(4) unsigned default '0', - `post_process` double(24,15) default 0, - `unit` text, - `wizard_level` enum('basic','advanced','nowizard') default 'nowizard', - `macros` text, - `critical_instructions` text NOT NULL default '', - `warning_instructions` text NOT NULL default '', - `unknown_instructions` text NOT NULL default '', - `critical_inverse` tinyint(1) unsigned default '0', - `warning_inverse` tinyint(1) unsigned default '0', - `id_category` int(10) default 0, - `tags` text NOT NULL default '', - `disabled_types_event` TEXT NOT NULL DEFAULT '', - `min_ff_event_normal` int(4) unsigned default '0', - `min_ff_event_warning` int(4) unsigned default '0', - `min_ff_event_critical` int(4) unsigned default '0', - `ff_type` tinyint(1) unsigned default '0', - `each_ff` tinyint(1) unsigned default '0', - `ff_timeout` int(4) unsigned default '0', - `dynamic_interval` int(4) unsigned default '0', - `dynamic_max` int(4) default '0', - `dynamic_min` int(4) default '0', - `dynamic_next` bigint(20) NOT NULL default '0', - `dynamic_two_tailed` tinyint(1) unsigned default '0', - `prediction_sample_window` int(10) default 0, - `prediction_samples` int(4) default 0, - `prediction_threshold` int(4) default 0, - `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0, - `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_network_component_group`) REFERENCES tnetwork_component_group(`id_sg`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TEXT, + `data` MEDIUMTEXT, + `description` VARCHAR(1024) DEFAULT NULL, + `id_os` INT UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '', + `id_network_component_group` INT UNSIGNED NOT NULL DEFAULT 0, + `type` SMALLINT NOT NULL DEFAULT 6, + `max` BIGINT NOT NULL DEFAULT 0, + `min` BIGINT NOT NULL DEFAULT 0, + `module_interval` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, + `id_module_group` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `history_data` TINYINT UNSIGNED DEFAULT 1, + `min_warning` DOUBLE DEFAULT 0, + `max_warning` DOUBLE DEFAULT 0, + `str_warning` TEXT, + `min_critical` DOUBLE DEFAULT 0, + `max_critical` DOUBLE DEFAULT 0, + `str_critical` TEXT, + `min_ff_event` INT UNSIGNED DEFAULT 0, + `post_process` DOUBLE DEFAULT 0, + `unit` TEXT, + `wizard_level` ENUM('basic','advanced','nowizard') DEFAULT 'nowizard', + `macros` TEXT, + `critical_instructions` TEXT , + `warning_instructions` TEXT , + `unknown_instructions` TEXT , + `critical_inverse` TINYINT UNSIGNED DEFAULT 0, + `warning_inverse` TINYINT UNSIGNED DEFAULT 0, + `id_category` INT DEFAULT 0, + `tags` TEXT , + `disabled_types_event` TEXT , + `min_ff_event_normal` INT UNSIGNED DEFAULT 0, + `min_ff_event_warning` INT UNSIGNED DEFAULT 0, + `min_ff_event_critical` INT UNSIGNED DEFAULT 0, + `ff_type` TINYINT UNSIGNED DEFAULT 0, + `each_ff` TINYINT UNSIGNED DEFAULT 0, + `ff_timeout` INT UNSIGNED DEFAULT 0, + `dynamic_interval` INT UNSIGNED DEFAULT 0, + `dynamic_max` INT DEFAULT 0, + `dynamic_min` INT DEFAULT 0, + `dynamic_next` BIGINT NOT NULL DEFAULT 0, + `dynamic_two_tailed` TINYINT UNSIGNED DEFAULT 0, + `prediction_sample_window` INT DEFAULT 0, + `prediction_samples` INT DEFAULT 0, + `prediction_threshold` INT DEFAULT 0, + `percentage_critical` TINYINT UNSIGNED DEFAULT 0, + `percentage_warning` TINYINT UNSIGNED DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_network_component_group`) REFERENCES tnetwork_component_group(`id_sg`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tpolicy_modules` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_modules` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_policy` int(10) unsigned NOT NULL default '0', - `configuration_data` mediumtext NOT NULL, - `id_tipo_modulo` smallint(5) NOT NULL default '0', - `description` varchar(1024) NOT NULL default '', - `name` varchar(200) NOT NULL default '', - `unit` text default '', - `max` bigint(20) default '0', - `min` bigint(20) default '0', - `module_interval` int(4) unsigned default '0', - `ip_target` varchar(100) default '', - `tcp_port` int(4) unsigned default '0', - `tcp_send` text default '', - `tcp_rcv` text default '', - `snmp_community` varchar(100) default '', - `snmp_oid` varchar(255) default '0', - `id_module_group` int(4) unsigned default '0', - `flag` tinyint(1) unsigned default '1', - `id_module` int(10) default '0', - `disabled` tinyint(1) unsigned NOT NULL default '0', - `id_export` smallint(4) unsigned default '0', - `plugin_user` text default '', - `plugin_pass` text default '', - `plugin_parameter` text, - `id_plugin` int(10) default '0', - `post_process` double(24,15) default 0, - `prediction_module` bigint(14) default '0', - `max_timeout` int(4) unsigned default '0', - `max_retries` int(4) unsigned default '0', - `custom_id` varchar(255) default '', - `history_data` tinyint(1) unsigned default '1', - `min_warning` double(18,2) default 0, - `max_warning` double(18,2) default 0, - `str_warning` text default '', - `min_critical` double(18,2) default 0, - `max_critical` double(18,2) default 0, - `str_critical` text default '', - `min_ff_event` int(4) unsigned default '0', - `custom_string_1` text default '', - `custom_string_2` text default '', - `custom_string_3` text default '', - `custom_integer_1` int(10) default 0, - `custom_integer_2` int(10) default 0, - `pending_delete` tinyint(1) default '0', - `critical_instructions` text NOT NULL default '', - `warning_instructions` text NOT NULL default '', - `unknown_instructions` text NOT NULL default '', - `critical_inverse` tinyint(1) unsigned default '0', - `warning_inverse` tinyint(1) unsigned default '0', - `id_category` int(10) default 0, - `module_ff_interval` int(4) unsigned default '0', - `quiet` tinyint(1) NOT NULL default '0', - `cron_interval` varchar(100) default '', - `macros` text, - `disabled_types_event` TEXT NOT NULL default '', - `module_macros` TEXT NOT NULL default '', - `min_ff_event_normal` int(4) unsigned default '0', - `min_ff_event_warning` int(4) unsigned default '0', - `min_ff_event_critical` int(4) unsigned default '0', - `ff_type` tinyint(1) unsigned default '0', - `each_ff` tinyint(1) unsigned default '0', - `ff_timeout` int(4) unsigned default '0', - `dynamic_interval` int(4) unsigned default '0', - `dynamic_max` int(4) default '0', - `dynamic_min` int(4) default '0', - `dynamic_next` bigint(20) NOT NULL default '0', - `dynamic_two_tailed` tinyint(1) unsigned default '0', - `prediction_sample_window` int(10) default 0, - `prediction_samples` int(4) default 0, - `prediction_threshold` int(4) default 0, - `cps` int NOT NULL DEFAULT 0, - `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0, - `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0, - PRIMARY KEY (`id`), - KEY `main_idx` (`id_policy`), - UNIQUE (`id_policy`, `name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_policy` INT UNSIGNED NOT NULL DEFAULT 0, + `configuration_data` MEDIUMTEXT, + `id_tipo_modulo` SMALLINT NOT NULL DEFAULT 0, + `description` VARCHAR(1024) NOT NULL DEFAULT '', + `name` VARCHAR(200) NOT NULL DEFAULT '', + `unit` TEXT , + `max` BIGINT DEFAULT 0, + `min` BIGINT DEFAULT 0, + `module_interval` INT UNSIGNED DEFAULT 0, + `ip_target` VARCHAR(100) DEFAULT '', + `tcp_port` INT UNSIGNED DEFAULT 0, + `tcp_send` TEXT , + `tcp_rcv` TEXT , + `snmp_community` VARCHAR(100) DEFAULT '', + `snmp_oid` VARCHAR(255) DEFAULT '0', + `id_module_group` INT UNSIGNED DEFAULT 0, + `flag` TINYINT UNSIGNED DEFAULT 1, + `id_module` INT DEFAULT 0, + `disabled` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_export` SMALLINT UNSIGNED DEFAULT 0, + `plugin_user` TEXT , + `plugin_pass` TEXT , + `plugin_parameter` TEXT, + `id_plugin` INT DEFAULT 0, + `post_process` DOUBLE DEFAULT 0, + `prediction_module` BIGINT DEFAULT 0, + `max_timeout` INT UNSIGNED DEFAULT 0, + `max_retries` INT UNSIGNED DEFAULT 0, + `custom_id` VARCHAR(255) DEFAULT '', + `history_data` TINYINT UNSIGNED DEFAULT 1, + `min_warning` DOUBLE DEFAULT 0, + `max_warning` DOUBLE DEFAULT 0, + `str_warning` TEXT , + `min_critical` DOUBLE DEFAULT 0, + `max_critical` DOUBLE DEFAULT 0, + `str_critical` TEXT , + `min_ff_event` INT UNSIGNED DEFAULT 0, + `custom_string_1` TEXT , + `custom_string_2` TEXT , + `custom_string_3` TEXT , + `custom_integer_1` INT DEFAULT 0, + `custom_integer_2` INT DEFAULT 0, + `pending_delete` TINYINT DEFAULT 0, + `critical_instructions` TEXT , + `warning_instructions` TEXT , + `unknown_instructions` TEXT , + `critical_inverse` TINYINT UNSIGNED DEFAULT 0, + `warning_inverse` TINYINT UNSIGNED DEFAULT 0, + `id_category` INT DEFAULT 0, + `module_ff_interval` INT UNSIGNED DEFAULT 0, + `quiet` TINYINT NOT NULL DEFAULT 0, + `cron_interval` VARCHAR(100) DEFAULT '', + `macros` TEXT, + `disabled_types_event` TEXT , + `module_macros` TEXT , + `min_ff_event_normal` INT UNSIGNED DEFAULT 0, + `min_ff_event_warning` INT UNSIGNED DEFAULT 0, + `min_ff_event_critical` INT UNSIGNED DEFAULT 0, + `ff_type` TINYINT UNSIGNED DEFAULT 0, + `each_ff` TINYINT UNSIGNED DEFAULT 0, + `ff_timeout` INT UNSIGNED DEFAULT 0, + `dynamic_interval` INT UNSIGNED DEFAULT 0, + `dynamic_max` INT DEFAULT 0, + `dynamic_min` INT DEFAULT 0, + `dynamic_next` BIGINT NOT NULL DEFAULT 0, + `dynamic_two_tailed` TINYINT UNSIGNED DEFAULT 0, + `prediction_sample_window` INT DEFAULT 0, + `prediction_samples` INT DEFAULT 0, + `prediction_threshold` INT DEFAULT 0, + `cps` INT NOT NULL DEFAULT 0, + `percentage_warning` TINYINT UNSIGNED DEFAULT 0, + `percentage_critical` TINYINT UNSIGNED DEFAULT 0, + PRIMARY KEY (`id`), + KEY `main_idx` (`id_policy`), + UNIQUE (`id_policy`, `name`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tpolicies` -- --------------------------------------------------------------------- -- 'status' could be 0 (without changes, updated), 1 (needy update only database) or 2 (needy update database and conf files) CREATE TABLE IF NOT EXISTS `tpolicies` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` text NOT NULL default '', - `description` varchar(255) NOT NULL default '', - `id_group` int(10) unsigned default '0', - `status` int(10) unsigned NOT NULL default 0, - `force_apply` tinyint(1) default 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TEXT , + `description` VARCHAR(255) NOT NULL DEFAULT '', + `id_group` INT UNSIGNED DEFAULT 0, + `status` INT UNSIGNED NOT NULL DEFAULT 0, + `force_apply` TINYINT DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tpolicy_alerts` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_alerts` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_policy` int(10) unsigned NOT NULL default '0', - `id_policy_module` int(10) unsigned default '0', - `id_alert_template` int(10) unsigned default '0', - `name_extern_module` TEXT NOT NULL default '', - `disabled` tinyint(1) default '0', - `standby` tinyint(1) default '0', - `pending_delete` tinyint(1) default '0', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_alert_template`) REFERENCES talert_templates(`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`id_policy`) REFERENCES tpolicies(`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_policy` INT UNSIGNED NOT NULL DEFAULT 0, + `id_policy_module` INT UNSIGNED DEFAULT 0, + `id_alert_template` INT UNSIGNED DEFAULT 0, + `name_extern_module` TEXT , + `disabled` TINYINT DEFAULT 0, + `standby` TINYINT DEFAULT 0, + `pending_delete` TINYINT DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_alert_template`) REFERENCES talert_templates(`id`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`id_policy`) REFERENCES tpolicies(`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tpolicy_agents` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_agents` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_policy` int(10) unsigned default '0', - `id_agent` int(10) unsigned default '0', - `policy_applied` tinyint(1) unsigned default '0', - `pending_delete` tinyint(1) unsigned default '0', - `last_apply_utimestamp` int(10) unsigned NOT NULL default 0, - `id_node` int(10) NOT NULL default 0, - PRIMARY KEY (`id`), - UNIQUE (`id_policy`, `id_agent`, `id_node`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_policy` INT UNSIGNED DEFAULT 0, + `id_agent` INT UNSIGNED DEFAULT 0, + `policy_applied` TINYINT UNSIGNED DEFAULT 0, + `pending_delete` TINYINT UNSIGNED DEFAULT 0, + `last_apply_utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, + `id_node` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE (`id_policy`, `id_agent`, `id_node`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tpolicy_groups` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_groups` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_policy` int(10) unsigned default '0', - `id_group` int(10) unsigned default '0', - `policy_applied` tinyint(1) unsigned default '0', - `pending_delete` tinyint(1) unsigned default '0', - `last_apply_utimestamp` int(10) unsigned NOT NULL default 0, - PRIMARY KEY (`id`), - UNIQUE (`id_policy`, `id_group`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_policy` INT UNSIGNED DEFAULT 0, + `id_group` INT UNSIGNED DEFAULT 0, + `policy_applied` TINYINT UNSIGNED DEFAULT 0, + `pending_delete` TINYINT UNSIGNED DEFAULT 0, + `last_apply_utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE (`id_policy`, `id_group`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tdashboard` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tdashboard` ( - `id` int(20) unsigned NOT NULL auto_increment, - `name` varchar(60) NOT NULL default '', - `id_user` varchar(60) NOT NULL default '', - `id_group` int(10) NOT NULL default 0, - `active` tinyint(1) NOT NULL default 0, - `cells` int(10) unsigned default 0, - `cells_slideshow` TINYINT(1) NOT NULL default 0, - PRIMARY KEY (`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(60) NOT NULL DEFAULT '', + `id_user` VARCHAR(60) NOT NULL DEFAULT '', + `id_group` INT NOT NULL DEFAULT 0, + `active` TINYINT NOT NULL DEFAULT 0, + `cells` INT UNSIGNED DEFAULT 0, + `cells_slideshow` TINYINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tdatabase` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tdatabase` ( - `id` INT(10) unsigned NOT NULL auto_increment, - `host` VARCHAR(255) default '', - `label` VARCHAR(255) default '', - `os_port` INT UNSIGNED NOT NULL DEFAULT 22, - `os_user` VARCHAR(255) default '', - `db_port` INT UNSIGNED NOT NULL DEFAULT 3306, - `status` tinyint(1) unsigned default '0', - `action` tinyint(1) unsigned default '0', - `ssh_key` TEXT, - `ssh_pubkey` TEXT, - `last_error` TEXT, - PRIMARY KEY (`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `host` VARCHAR(255) DEFAULT '', + `label` VARCHAR(255) DEFAULT '', + `os_port` INT UNSIGNED NOT NULL DEFAULT 22, + `os_user` VARCHAR(255) DEFAULT '', + `db_port` INT UNSIGNED NOT NULL DEFAULT 3306, + `status` TINYINT UNSIGNED DEFAULT 0, + `action` TINYINT UNSIGNED DEFAULT 0, + `ssh_key` TEXT, + `ssh_pubkey` TEXT, + `last_error` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 ; -- ----------------------------------------------------- -- Table `twidget` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `twidget` ( - `id` int(20) unsigned NOT NULL auto_increment, - `class_name` varchar(60) NOT NULL default '', - `unique_name` varchar(60) NOT NULL default '', - `description` text NOT NULL default '', - `options` text NOT NULL default '', - `page` varchar(120) NOT NULL default '', - PRIMARY KEY (`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `class_name` VARCHAR(60) NOT NULL DEFAULT '', + `unique_name` VARCHAR(60) NOT NULL DEFAULT '', + `description` TEXT , + `options` TEXT , + `page` VARCHAR(120) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `twidget_dashboard` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `twidget_dashboard` ( - `id` int(20) unsigned NOT NULL auto_increment, - `position` TEXT NOT NULL default '', - `options` LONGTEXT NOT NULL default '', - `order` int(3) NOT NULL default 0, - `id_dashboard` int(20) unsigned NOT NULL default 0, - `id_widget` int(20) unsigned NOT NULL default 0, - `prop_width` float(5,3) NOT NULL default 0.32, - `prop_height` float(5,3) NOT NULL default 0.32, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_dashboard`) REFERENCES tdashboard(`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `position` TEXT , + `options` LONGTEXT , + `order` INT NOT NULL DEFAULT 0, + `id_dashboard` INT UNSIGNED NOT NULL DEFAULT 0, + `id_widget` INT UNSIGNED NOT NULL DEFAULT 0, + `prop_width` DOUBLE NOT NULL DEFAULT 0.32, + `prop_height` DOUBLE NOT NULL DEFAULT 0.32, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_dashboard`) REFERENCES tdashboard(`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tmodule_inventory` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmodule_inventory` ( - `id_module_inventory` int(10) NOT NULL auto_increment, - `id_os` int(10) unsigned default NULL, - `name` text default '', - `description` text default '', - `interpreter` varchar(100) default '', - `data_format` text default '', - `code` BLOB NOT NULL, - `block_mode` int(3) NOT NULL default 0, - PRIMARY KEY (`id_module_inventory`), - FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_module_inventory` INT NOT NULL AUTO_INCREMENT, + `id_os` INT UNSIGNED DEFAULT NULL, + `name` TEXT , + `description` TEXT , + `interpreter` VARCHAR(100) DEFAULT '', + `data_format` TEXT , + `code` BLOB NOT NULL, + `block_mode` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_module_inventory`), + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tagent_module_inventory` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagent_module_inventory` ( - `id_agent_module_inventory` int(10) NOT NULL auto_increment, - `id_agente` int(10) unsigned NOT NULL, - `id_module_inventory` int(10) NOT NULL, - `target` varchar(100) default '', - `interval` int(10) unsigned NOT NULL default '3600', - `username` varchar(100) default '', - `password` varchar(100) default '', - `data` MEDIUMBLOB NOT NULL, - `timestamp` datetime default '1970-01-01 00:00:00', - `utimestamp` bigint(20) default '0', - `flag` tinyint(1) unsigned default '1', - `id_policy_module_inventory` int(10) NOT NULL default '0', - `custom_fields` MEDIUMBLOB NOT NULL, - PRIMARY KEY (`id_agent_module_inventory`), - FOREIGN KEY (`id_agente`) REFERENCES tagente(`id_agente`) - ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agent_module_inventory` INT NOT NULL AUTO_INCREMENT, + `id_agente` INT UNSIGNED NOT NULL, + `id_module_inventory` INT NOT NULL, + `target` VARCHAR(100) DEFAULT '', + `interval` INT UNSIGNED NOT NULL DEFAULT 3600, + `username` VARCHAR(100) DEFAULT '', + `password` VARCHAR(100) DEFAULT '', + `data` MEDIUMBLOB NOT NULL, + `timestamp` DATETIME DEFAULT '1970-01-01 00:00:00', + `utimestamp` BIGINT DEFAULT 0, + `flag` TINYINT UNSIGNED DEFAULT 1, + `id_policy_module_inventory` INT NOT NULL DEFAULT 0, + `custom_fields` MEDIUMBLOB NOT NULL, + PRIMARY KEY (`id_agent_module_inventory`), + FOREIGN KEY (`id_agente`) REFERENCES tagente(`id_agente`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tinventory_alert` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tinventory_alert`( - `id` int UNSIGNED NOT NULL auto_increment, - `id_module_inventory` int(10) NOT NULL, - `actions` text NOT NULL default '', - `id_group` mediumint(8) unsigned NULL default 0, - `condition` enum('WHITE_LIST', 'BLACK_LIST', 'MATCH') NOT NULL default 'WHITE_LIST', - `value` text NOT NULL default '', - `name` tinytext NOT NULL default '', - `description` text NOT NULL default '', - `time_threshold` int(10) NOT NULL default '0', - `last_fired` text NOT NULL default '', - `disable_event` tinyint(1) UNSIGNED default 0, - `enabled` tinyint(1) UNSIGNED default 1, - `alert_groups` text NOT NULL default '', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`) - ON DELETE CASCADE ON UPDATE CASCADE -) engine=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_module_inventory` INT NOT NULL, + `actions` TEXT , + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `condition` ENUM('WHITE_LIST', 'BLACK_LIST', 'MATCH') NOT NULL DEFAULT 'WHITE_LIST', + `value` TEXT , + `name` TINYTEXT , + `description` TEXT , + `time_threshold` INT NOT NULL DEFAULT 0, + `last_fired` TEXT , + `disable_event` TINYINT UNSIGNED DEFAULT 0, + `enabled` TINYINT UNSIGNED DEFAULT 1, + `alert_groups` TEXT , + PRIMARY KEY (`id`), + FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`) + ON DELETE CASCADE ON UPDATE CASCADE +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tpolicy_modules_inventory` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_modules_inventory` ( - `id` int(10) NOT NULL auto_increment, - `id_policy` int(10) unsigned NOT NULL, - `id_module_inventory` int(10) NOT NULL, - `interval` int(10) unsigned NOT NULL default '3600', - `username` varchar(100) default '', - `password` varchar(100) default '', - `pending_delete` tinyint(1) default '0', - `custom_fields` MEDIUMBLOB NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_policy`) REFERENCES tpolicies(`id`) - ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT NOT NULL AUTO_INCREMENT, + `id_policy` INT UNSIGNED NOT NULL, + `id_module_inventory` INT NOT NULL, + `interval` INT UNSIGNED NOT NULL DEFAULT 3600, + `username` VARCHAR(100) DEFAULT '', + `password` VARCHAR(100) DEFAULT '', + `pending_delete` TINYINT DEFAULT 0, + `custom_fields` MEDIUMBLOB NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_policy`) REFERENCES tpolicies(`id`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tagente_datos_inventory` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagente_datos_inventory` ( - `id_agent_module_inventory` int(10) NOT NULL, - `data` MEDIUMBLOB NOT NULL, - `utimestamp` bigint(20) default '0', - `timestamp` datetime default '1970-01-01 00:00:00', - KEY `idx_id_agent_module` (`id_agent_module_inventory`), - KEY `idx_utimestamp` USING BTREE (`utimestamp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agent_module_inventory` INT NOT NULL, + `data` MEDIUMBLOB NOT NULL, + `utimestamp` BIGINT DEFAULT 0, + `timestamp` DATETIME DEFAULT '1970-01-01 00:00:00', + KEY `idx_id_agent_module` (`id_agent_module_inventory`), + KEY `idx_utimestamp` USING BTREE (`utimestamp`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `ttrap_custom_values` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `ttrap_custom_values` ( - `id` int(10) NOT NULL auto_increment, - `oid` varchar(255) NOT NULL default '', - `custom_oid` varchar(255) NOT NULL default '', - `text` varchar(255) default '', - `description` varchar(255) default '', - `severity` tinyint(4) unsigned NOT NULL default '2', - CONSTRAINT oid_custom_oid UNIQUE(oid, custom_oid), - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT NOT NULL AUTO_INCREMENT, + `oid` VARCHAR(255) NOT NULL DEFAULT '', + `custom_oid` VARCHAR(255) NOT NULL DEFAULT '', + `text` VARCHAR(255) DEFAULT '', + `description` VARCHAR(255) DEFAULT '', + `severity` TINYINT UNSIGNED NOT NULL DEFAULT 2, + CONSTRAINT oid_custom_oid UNIQUE(oid, custom_oid), + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tmetaconsole_setup` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` ( - `id` int(10) NOT NULL auto_increment, - `server_name` text, - `server_url` text, - `dbuser` text, - `dbpass` text, - `dbhost` text, - `dbport` text, - `dbname` text, - `meta_dbuser` text, - `meta_dbpass` text, - `meta_dbhost` text, - `meta_dbport` text, - `meta_dbname` text, - `auth_token` text, - `id_group` int(10) unsigned NOT NULL default 0, - `api_password` text NOT NULL, - `disabled` tinyint(1) unsigned NOT NULL default 0, - `unified` tinyint(1) unsigned NOT NULL default 0, - `last_event_replication` bigint(20) default 0, - `server_uid` text NOT NULL default '', - PRIMARY KEY (`id`) + `id` INT NOT NULL AUTO_INCREMENT, + `server_name` TEXT, + `server_url` TEXT, + `dbuser` TEXT, + `dbpass` TEXT, + `dbhost` TEXT, + `dbport` TEXT, + `dbname` TEXT, + `meta_dbuser` TEXT, + `meta_dbpass` TEXT, + `meta_dbhost` TEXT, + `meta_dbport` TEXT, + `meta_dbname` TEXT, + `auth_token` TEXT, + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `api_password` TEXT, + `disabled` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `unified` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `last_event_replication` BIGINT DEFAULT 0, + `server_uid` TEXT , + PRIMARY KEY (`id`) ) ENGINE=InnoDB COMMENT = 'Table to store metaconsole sources' -DEFAULT CHARSET=utf8; +DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tprofile_view` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tprofile_view` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_profile` int(10) unsigned NOT NULL default 0, - `sec` text default '', - `sec2` text default '', - `sec3` text default '', - PRIMARY KEY (`id`) + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_profile` INT UNSIGNED NOT NULL DEFAULT 0, + `sec` TEXT , + `sec2` TEXT , + `sec3` TEXT , + PRIMARY KEY (`id`) ) ENGINE=InnoDB -COMMENT = 'Table to define by each profile defined in Pandora, to which sec/page has access independently of its ACL (for showing in the console or not). By default have access to all pages allowed by ACL, if forbidden here, then pages are not shown.' -DEFAULT CHARSET=utf8; +COMMENT = 'Table to define by each profile defined in Pandora, to which sec/page has access independently of its ACL (for showing in the console or not). By DEFAULT have access to all pages allowed by ACL, if forbidden here, then pages are not shown.' +DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tservice` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tservice` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `description` text NOT NULL default '', - `id_group` int(10) unsigned NOT NULL default 0, - `critical` float(20,3) NOT NULL default 0, - `warning` float(20,3) NOT NULL default 0, - `unknown_as_critical` tinyint(1) NOT NULL default 0, - `service_interval` float(20,3) NOT NULL default 0, - `service_value` float(20,3) NOT NULL default 0, - `status` tinyint(3) NOT NULL default -1, - `utimestamp` int(10) unsigned NOT NULL default 0, - `auto_calculate` tinyint(1) unsigned NOT NULL default 1, - `id_agent_module` int(10) unsigned NOT NULL default 0, - `sla_interval` float(20,3) NOT NULL default 0, - `sla_id_module` int(10) unsigned NOT NULL default 0, - `sla_value_id_module` int(10) unsigned NOT NULL default 0, - `sla_limit` float(20,3) NOT NULL default 100, - `id_template_alert_warning` int(10) unsigned NOT NULL default 0, - `id_template_alert_critical` int(10) unsigned NOT NULL default 0, - `id_template_alert_unknown` int(10) unsigned NOT NULL default 0, - `id_template_alert_critical_sla` int(10) unsigned NOT NULL default 0, - `quiet` tinyint(1) NOT NULL default 0, - `cps` int NOT NULL default 0, - `cascade_protection` tinyint(1) NOT NULL default 0, - `evaluate_sla` int(1) NOT NULL default 0, - `is_favourite` tinyint(1) NOT NULL default 0, - PRIMARY KEY (`id`) + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `description` TEXT , + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `critical` DOUBLE NOT NULL DEFAULT 0, + `warning` DOUBLE NOT NULL DEFAULT 0, + `unknown_as_critical` TINYINT NOT NULL DEFAULT 0, + `service_interval` DOUBLE NOT NULL DEFAULT 0, + `service_value` DOUBLE NOT NULL DEFAULT 0, + `status` TINYINT NOT NULL DEFAULT -1, + `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, + `auto_calculate` TINYINT UNSIGNED NOT NULL DEFAULT 1, + `id_agent_module` INT UNSIGNED NOT NULL DEFAULT 0, + `sla_interval` DOUBLE NOT NULL DEFAULT 0, + `sla_id_module` INT UNSIGNED NOT NULL DEFAULT 0, + `sla_value_id_module` INT UNSIGNED NOT NULL DEFAULT 0, + `sla_limit` DOUBLE NOT NULL DEFAULT 100, + `id_template_alert_warning` INT UNSIGNED NOT NULL DEFAULT 0, + `id_template_alert_critical` INT UNSIGNED NOT NULL DEFAULT 0, + `id_template_alert_unknown` INT UNSIGNED NOT NULL DEFAULT 0, + `id_template_alert_critical_sla` INT UNSIGNED NOT NULL DEFAULT 0, + `quiet` TINYINT NOT NULL DEFAULT 0, + `cps` INT NOT NULL DEFAULT 0, + `cascade_protection` TINYINT NOT NULL DEFAULT 0, + `evaluate_sla` INT NOT NULL DEFAULT 0, + `is_favourite` TINYINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) ) ENGINE=InnoDB COMMENT = 'Table to define services to monitor' -DEFAULT CHARSET=utf8; +DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tservice_element` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tservice_element` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_service` int(10) unsigned NOT NULL, - `weight_ok` float(20,3) NOT NULL default 0, - `weight_warning` float(20,3) NOT NULL default 0, - `weight_critical` float(20,3) NOT NULL default 0, - `weight_unknown` float(20,3) NOT NULL default 0, - `description` text NOT NULL default '', - `id_agente_modulo` int(10) unsigned NOT NULL default 0, - `id_agent` int(10) unsigned NOT NULL default 0, - `id_service_child` int(10) unsigned NOT NULL default 0, - `id_server_meta` int(10) unsigned NOT NULL default 0, - `rules` text, - PRIMARY KEY (`id`), - INDEX `IDX_tservice_element` (`id_service`,`id_agente_modulo`) + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_service` INT UNSIGNED NOT NULL, + `weight_ok` DOUBLE NOT NULL DEFAULT 0, + `weight_warning` DOUBLE NOT NULL DEFAULT 0, + `weight_critical` DOUBLE NOT NULL DEFAULT 0, + `weight_unknown` DOUBLE NOT NULL DEFAULT 0, + `description` TEXT , + `id_agente_modulo` INT UNSIGNED NOT NULL DEFAULT 0, + `id_agent` INT UNSIGNED NOT NULL DEFAULT 0, + `id_service_child` INT UNSIGNED NOT NULL DEFAULT 0, + `id_server_meta` INT unsigned NOT NULL DEFAULT 0, + `rules` TEXT, + PRIMARY KEY (`id`), + INDEX `IDX_tservice_element` (`id_service`,`id_agente_modulo`) ) ENGINE=InnoDB COMMENT = 'Table to define the modules and the weights of the modules that define a service' -DEFAULT CHARSET=utf8; +DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tcollection` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tcollection` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL default '', - `short_name` varchar(100) NOT NULL default '', - `id_group` int(10) unsigned NOT NULL default 0, - `description` mediumtext, - `status` int(4) unsigned NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + `short_name` VARCHAR(100) NOT NULL DEFAULT '', + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `description` MEDIUMTEXT, + `status` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- status: 0 - Not apply -- status: 1 - Applied @@ -2884,466 +2875,471 @@ CREATE TABLE IF NOT EXISTS `tcollection` ( -- Table `tpolicy_collections` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_collections` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_policy` int(10) unsigned NOT NULL default '0', - `id_collection` int(10) unsigned default '0', - `pending_delete` tinyint(1) default '0', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_policy`) REFERENCES `tpolicies` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`id_collection`) REFERENCES `tcollection` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_policy` INT UNSIGNED NOT NULL DEFAULT 0, + `id_collection` INT UNSIGNED DEFAULT 0, + `pending_delete` TINYINT DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_policy`) REFERENCES `tpolicies` (`id`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`id_collection`) REFERENCES `tcollection` (`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tpolicy_alerts_actions` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_alerts_actions` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_policy_alert` int(10) unsigned NOT NULL, - `id_alert_action` int(10) unsigned NOT NULL, - `fires_min` int(3) unsigned default 0, - `fires_max` int(3) unsigned default 0, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_policy_alert`) REFERENCES `tpolicy_alerts` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`id_alert_action`) REFERENCES `talert_actions` (`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_policy_alert` INT UNSIGNED NOT NULL, + `id_alert_action` INT UNSIGNED NOT NULL, + `fires_min` INT UNSIGNED DEFAULT 0, + `fires_max` INT UNSIGNED DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_policy_alert`) REFERENCES `tpolicy_alerts` (`id`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`id_alert_action`) REFERENCES `talert_actions` (`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tpolicy_plugins` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_plugins` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_policy` int(10) unsigned default '0', - `plugin_exec` TEXT, - `pending_delete` tinyint(1) default '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_policy` INT UNSIGNED DEFAULT 0, + `plugin_exec` TEXT, + `pending_delete` TINYINT DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tsesion_extended` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tsesion_extended` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_sesion` int(10) unsigned NOT NULL, - `extended_info` TEXT default '', - `hash` varchar(255) default '', - PRIMARY KEY (`id`), - KEY idx_session (id_sesion) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_sesion` INT UNSIGNED NOT NULL, + `extended_info` TEXT , + `hash` VARCHAR(255) DEFAULT '', + PRIMARY KEY (`id`), + KEY idx_session (id_sesion) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tskin` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tskin` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` TEXT NOT NULL DEFAULT '', - `relative_path` TEXT NOT NULL DEFAULT '', - `description` text NOT NULL DEFAULT '', - `disabled` tinyint(2) NOT NULL default '0', - PRIMARY KEY (id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TEXT , + `relative_path` TEXT , + `description` TEXT , + `disabled` TINYINT NOT NULL DEFAULT 0, + PRIMARY KEY (id) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tpolicy_queue` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tpolicy_queue` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_policy` int(10) unsigned NOT NULL default '0', - `id_agent` int(10) unsigned NOT NULL default '0', - `operation` varchar(15) default '', - `progress` int(10) NOT NULL default '0', - `end_utimestamp` int(10) unsigned NOT NULL default 0, - `priority` int(10) unsigned NOT NULL default '0', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_policy` INT UNSIGNED NOT NULL DEFAULT 0, + `id_agent` INT UNSIGNED NOT NULL DEFAULT 0, + `operation` VARCHAR(15) DEFAULT '', + `progress` INT NOT NULL DEFAULT 0, + `end_utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, + `priority` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tevent_rule` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tevent_rule` ( - `id_event_rule` int(10) unsigned NOT NULL auto_increment, - `id_event_alert` int(10) unsigned NOT NULL, - `operation` enum('NOP', 'AND','OR','XOR','NAND','NOR','NXOR'), - `order` int(10) unsigned default '0', - `window` int(10) NOT NULL default '0', - `count` int(4) NOT NULL default '1', - `agent` text, - `id_usuario` text, - `id_grupo` text, - `evento` text, - `event_type` text, - `module` text, - `alert` text, - `criticity` text, - `user_comment` text, - `id_tag` text, - `name` text, - `group_recursion` text, - `log_content` text, - `log_source` text, - `log_agent` text, - `operator_agent` text COMMENT 'Operator for agent', - `operator_id_usuario` text COMMENT 'Operator for id_usuario', - `operator_id_grupo` text COMMENT 'Operator for id_grupo', - `operator_evento` text COMMENT 'Operator for evento', - `operator_event_type` text COMMENT 'Operator for event_type', - `operator_module` text COMMENT 'Operator for module', - `operator_alert` text COMMENT 'Operator for alert', - `operator_criticity` text COMMENT 'Operator for criticity', - `operator_user_comment` text COMMENT 'Operator for user_comment', - `operator_id_tag` text COMMENT 'Operator for id_tag', - `operator_log_content` text COMMENT 'Operator for log_content', - `operator_log_source` text COMMENT 'Operator for log_source', - `operator_log_agent` text COMMENT 'Operator for log_agent', - PRIMARY KEY (`id_event_rule`), - KEY `idx_id_event_alert` (`id_event_alert`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_event_rule` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_event_alert` INT UNSIGNED NOT NULL, + `operation` ENUM('NOP', 'AND','OR','XOR','NAND','NOR','NXOR'), + `order` INT UNSIGNED DEFAULT 0, + `window` INT NOT NULL DEFAULT 0, + `count` INT NOT NULL DEFAULT 1, + `agent` TEXT, + `id_usuario` TEXT, + `id_grupo` TEXT, + `evento` TEXT, + `event_type` TEXT, + `module` TEXT, + `alert` TEXT, + `criticity` TEXT, + `user_comment` TEXT, + `id_tag` TEXT, + `name` TEXT, + `group_recursion` TEXT, + `log_content` TEXT, + `log_source` TEXT, + `log_agent` TEXT, + `operator_agent` TEXT COMMENT 'Operator for agent', + `operator_id_usuario` TEXT COMMENT 'Operator for id_usuario', + `operator_id_grupo` TEXT COMMENT 'Operator for id_grupo', + `operator_evento` TEXT COMMENT 'Operator for evento', + `operator_event_type` TEXT COMMENT 'Operator for event_type', + `operator_module` TEXT COMMENT 'Operator for module', + `operator_alert` TEXT COMMENT 'Operator for alert', + `operator_criticity` TEXT COMMENT 'Operator for criticity', + `operator_user_comment` TEXT COMMENT 'Operator for user_comment', + `operator_id_tag` TEXT COMMENT 'Operator for id_tag', + `operator_log_content` TEXT COMMENT 'Operator for log_content', + `operator_log_source` TEXT COMMENT 'Operator for log_source', + `operator_log_agent` TEXT COMMENT 'Operator for log_agent', + PRIMARY KEY (`id_event_rule`), + KEY `idx_id_event_alert` (`id_event_alert`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tevent_alert` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tevent_alert` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` text default '', - `description` mediumtext, - `order` int(10) unsigned default 0, - `mode` enum('PASS','DROP'), - `field1` text NOT NULL default '', - `field2` text NOT NULL default '', - `field3` text NOT NULL default '', - `field4` text NOT NULL default '', - `field5` text NOT NULL default '', - `field6` text NOT NULL default '', - `field7` text NOT NULL default '', - `field8` text NOT NULL default '', - `field9` text NOT NULL default '', - `field10` text NOT NULL default '', - `time_threshold` int(10) NOT NULL default 86400, - `max_alerts` int(4) unsigned NOT NULL default '1', - `min_alerts` int(4) unsigned NOT NULL default '0', - `time_from` time default '00:00:00', - `time_to` time default '00:00:00', - `monday` tinyint(1) default 1, - `tuesday` tinyint(1) default 1, - `wednesday` tinyint(1) default 1, - `thursday` tinyint(1) default 1, - `friday` tinyint(1) default 1, - `saturday` tinyint(1) default 1, - `sunday` tinyint(1) default 1, - `recovery_notify` tinyint(1) default '0', - `field2_recovery` text NOT NULL default '', - `field3_recovery` text NOT NULL, - `id_group` mediumint(8) unsigned NULL default 0, - `internal_counter` int(4) default '0', - `last_fired` bigint(20) NOT NULL default '0', - `last_reference` bigint(20) NOT NULL default '0', - `times_fired` int(3) NOT NULL default '0', - `disabled` tinyint(1) default '0', - `standby` tinyint(1) default '0', - `priority` tinyint(4) default '0', - `force_execution` tinyint(1) default '0', - `group_by` enum ('','id_agente','id_agentmodule','id_alert_am','id_grupo') default '', - `special_days` tinyint(1) default 0, - `disable_event` tinyint(1) default 0, - `id_template_conditions` int(10) unsigned NOT NULL default 0, - `id_template_fields` int(10) unsigned NOT NULL default 0, - `last_evaluation` bigint(20) NOT NULL default 0, - `pool_occurrences` int unsigned not null default 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TEXT , + `description` MEDIUMTEXT, + `order` INT UNSIGNED DEFAULT 0, + `mode` ENUM('PASS','DROP'), + `field1` TEXT , + `field2` TEXT , + `field3` TEXT , + `field4` TEXT , + `field5` TEXT , + `field6` TEXT , + `field7` TEXT , + `field8` TEXT , + `field9` TEXT , + `field10` TEXT , + `time_threshold` INT NOT NULL DEFAULT 86400, + `max_alerts` INT UNSIGNED NOT NULL DEFAULT 1, + `min_alerts` INT UNSIGNED NOT NULL DEFAULT 0, + `time_from` time DEFAULT '00:00:00', + `time_to` time DEFAULT '00:00:00', + `monday` TINYINT DEFAULT 1, + `tuesday` TINYINT DEFAULT 1, + `wednesday` TINYINT DEFAULT 1, + `thursday` TINYINT DEFAULT 1, + `friday` TINYINT DEFAULT 1, + `saturday` TINYINT DEFAULT 1, + `sunday` TINYINT DEFAULT 1, + `recovery_notify` TINYINT DEFAULT 0, + `field2_recovery` TEXT , + `field3_recovery` TEXT, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `internal_counter` INT DEFAULT 0, + `last_fired` BIGINT NOT NULL DEFAULT 0, + `last_reference` BIGINT NOT NULL DEFAULT 0, + `times_fired` INT NOT NULL DEFAULT 0, + `disabled` TINYINT DEFAULT 0, + `standby` TINYINT DEFAULT 0, + `priority` TINYINT DEFAULT 0, + `force_execution` TINYINT DEFAULT 0, + `group_by` enum ('','id_agente','id_agentmodule','id_alert_am','id_grupo') DEFAULT '', + `special_days` TINYINT DEFAULT 0, + `disable_event` TINYINT DEFAULT 0, + `id_template_conditions` INT UNSIGNED NOT NULL DEFAULT 0, + `id_template_fields` INT UNSIGNED NOT NULL DEFAULT 0, + `last_evaluation` BIGINT NOT NULL DEFAULT 0, + `pool_occurrences` INT UNSIGNED NOT NULL DEFAULT 0, + `schedule` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tevent_alert_action` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tevent_alert_action` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_event_alert` int(10) unsigned NOT NULL, - `id_alert_action` int(10) unsigned NOT NULL, - `fires_min` int(3) unsigned default 0, - `fires_max` int(3) unsigned default 0, - `module_action_threshold` int(10) NOT NULL default '0', - `last_execution` bigint(20) NOT NULL default '0', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_event_alert`) REFERENCES tevent_alert(`id`) - ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_event_alert` INT UNSIGNED NOT NULL, + `id_alert_action` INT UNSIGNED NOT NULL, + `fires_min` INT UNSIGNED DEFAULT 0, + `fires_max` INT UNSIGNED DEFAULT 0, + `module_action_threshold` INT NOT NULL DEFAULT 0, + `last_execution` BIGINT NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_event_alert`) REFERENCES tevent_alert(`id`) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tmodule_synth` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmodule_synth` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_agent_module_source` int(10) unsigned NOT NULL DEFAULT 0, - `id_agent_module_target` int(10) unsigned NOT NULL DEFAULT 0, - `fixed_value` float NOT NULL DEFAULT 0, - `operation` enum ('ADD', 'SUB', 'DIV', 'MUL', 'AVG', 'NOP') NOT NULL DEFAULT 'NOP', - `order` int(11) NOT NULL DEFAULT '0', - FOREIGN KEY (`id_agent_module_target`) REFERENCES tagente_modulo(`id_agente_modulo`) - ON DELETE CASCADE ON UPDATE CASCADE, - PRIMARY KEY (id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agent_module_source` INT UNSIGNED NOT NULL DEFAULT 0, + `id_agent_module_target` INT UNSIGNED NOT NULL DEFAULT 0, + `fixed_value` DOUBLE NOT NULL DEFAULT 0, + `operation` enum ('ADD', 'SUB', 'DIV', 'MUL', 'AVG', 'NOP') NOT NULL DEFAULT 'NOP', + `order` INT NOT NULL DEFAULT 0, + FOREIGN KEY (`id_agent_module_target`) REFERENCES tagente_modulo(`id_agente_modulo`) + ON DELETE CASCADE ON UPDATE CASCADE, + PRIMARY KEY (id) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tnetworkmap_enterprise` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetworkmap_enterprise` ( - `id` int(10) unsigned NOT NULL auto_increment, - `name` varchar(500) default '', - `id_group` int(10) unsigned NOT NULL default 0, - `options` text default '', - PRIMARY KEY (id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(500) DEFAULT '', + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `options` TEXT , + PRIMARY KEY (id) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tnetworkmap_enterprise_nodes` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetworkmap_enterprise_nodes` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_networkmap_enterprise` int(10) unsigned NOT NULL, - `x` int(10) default 0, - `y` int(10) default 0, - `z` int(10) default 0, - `id_agent` int(10) default 0, - `id_module` int(10) default 0, - `id_agent_module` int(10) default 0, - `parent` int(10) default 0, - `options` text default '', - `deleted` int(10) default 0, - `state` varchar(150) NOT NULL default '', - PRIMARY KEY (id), - FOREIGN KEY (`id_networkmap_enterprise`) REFERENCES tnetworkmap_enterprise(`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_networkmap_enterprise` INT UNSIGNED NOT NULL, + `x` INT DEFAULT 0, + `y` INT DEFAULT 0, + `z` INT DEFAULT 0, + `id_agent` INT DEFAULT 0, + `id_module` INT DEFAULT 0, + `id_agent_module` INT DEFAULT 0, + `parent` INT DEFAULT 0, + `options` TEXT , + `deleted` INT DEFAULT 0, + `state` VARCHAR(150) NOT NULL DEFAULT '', + PRIMARY KEY (id), + FOREIGN KEY (`id_networkmap_enterprise`) REFERENCES tnetworkmap_enterprise(`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tnetworkmap_ent_rel_nodes` (Before `tnetworkmap_enterprise_relation_nodes`) -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetworkmap_ent_rel_nodes` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_networkmap_enterprise` int(10) unsigned NOT NULL, - `parent` int(10) default 0, - `parent_type` varchar(30) default 'node', - `child` int(10) default 0, - `child_type` varchar(30) default 'node', - `deleted` int(10) default 0, - PRIMARY KEY (id, id_networkmap_enterprise), - FOREIGN KEY (`id_networkmap_enterprise`) REFERENCES tnetworkmap_enterprise(`id`) - ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_networkmap_enterprise` INT UNSIGNED NOT NULL, + `parent` INT DEFAULT 0, + `parent_type` VARCHAR(30) DEFAULT 'node', + `child` INT DEFAULT 0, + `child_type` VARCHAR(30) DEFAULT 'node', + `deleted` INT DEFAULT 0, + PRIMARY KEY (id, id_networkmap_enterprise), + FOREIGN KEY (`id_networkmap_enterprise`) REFERENCES tnetworkmap_enterprise(`id`) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `treport_template` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport_template` ( - `id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_user` varchar(100) NOT NULL default '', - `name` varchar(150) NOT NULL default '', - `description` TEXT NOT NULL, - `private` tinyint(1) UNSIGNED NOT NULL default 0, - `id_group` mediumint(8) unsigned NULL default NULL, - `custom_logo` varchar(200) default NULL, - `header` MEDIUMTEXT default NULL, - `first_page` MEDIUMTEXT default NULL, - `footer` MEDIUMTEXT default NULL, - `custom_font` varchar(200) default NULL, - `metaconsole` tinyint(1) DEFAULT 0, - `agent_regex` varchar(600) BINARY NOT NULL default '', - `cover_page_render` tinyint(1) NOT NULL DEFAULT 1, - `index_render` tinyint(1) NOT NULL DEFAULT 1, - PRIMARY KEY(`id_report`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_report` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(100) NOT NULL DEFAULT '', + `name` VARCHAR(150) NOT NULL DEFAULT '', + `description` TEXT, + `private` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT NULL, + `custom_logo` VARCHAR(200) DEFAULT NULL, + `header` MEDIUMTEXT , + `first_page` MEDIUMTEXT , + `footer` MEDIUMTEXT , + `custom_font` VARCHAR(200) DEFAULT NULL, + `metaconsole` TINYINT DEFAULT 0, + `agent_regex` VARCHAR(600) NOT NULL DEFAULT '', + `cover_page_render` TINYINT NOT NULL DEFAULT 1, + `index_render` TINYINT NOT NULL DEFAULT 1, + PRIMARY KEY(`id_report`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `treport_content_template` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport_content_template` ( - `id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_report` INTEGER UNSIGNED NOT NULL default 0, - `id_gs` INTEGER UNSIGNED NULL default NULL, - `text_agent_module` text, - `type` varchar(30) default 'simple_graph', - `period` int(11) NOT NULL default 0, - `order` int (11) NOT NULL default 0, - `description` mediumtext, - `text_agent` text, - `text` TEXT, - `external_source` mediumtext, - `treport_custom_sql_id` INTEGER UNSIGNED default 0, - `header_definition` TinyText default NULL, - `column_separator` TinyText default NULL, - `line_separator` TinyText default NULL, - `time_from` time default '00:00:00', - `time_to` time default '00:00:00', - `monday` tinyint(1) default 1, - `tuesday` tinyint(1) default 1, - `wednesday` tinyint(1) default 1, - `thursday` tinyint(1) default 1, - `friday` tinyint(1) default 1, - `saturday` tinyint(1) default 1, - `sunday` tinyint(1) default 1, - `only_display_wrong` tinyint (1) unsigned default 0 not null, - `top_n` INT NOT NULL default 0, - `top_n_value` INT NOT NULL default 10, - `exception_condition` INT NOT NULL default 0, - `exception_condition_value` DOUBLE (18,6) NOT NULL default 0, - `show_resume` INT NOT NULL default 0, - `order_uptodown` INT NOT NULL default 0, - `show_graph` INT NOT NULL default 0, - `group_by_agent` INT NOT NULL default 0, - `style` TEXT NOT NULL, - `id_group` INT (10) unsigned NOT NULL DEFAULT 0, - `id_module_group` INT (10) unsigned NOT NULL DEFAULT 0, - `server_name` text, - `exact_match` tinyint(1) default 0, - `module_names` TEXT, - `module_free_text` TEXT, - `each_agent` tinyint(1) default 1, - `historical_db` tinyint(1) UNSIGNED NOT NULL default 0, - `lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0', - `lapse` int(11) UNSIGNED NOT NULL default '300', - `visual_format` tinyint(1) UNSIGNED NOT NULL default '0', - `hide_no_data` tinyint(1) default 0, - `total_time` TINYINT(1) DEFAULT '1', - `time_failed` TINYINT(1) DEFAULT '1', - `time_in_ok_status` TINYINT(1) DEFAULT '1', - `time_in_warning_status` TINYINT(1) DEFAULT '0', - `time_in_unknown_status` TINYINT(1) DEFAULT '1', - `time_of_not_initialized_module` TINYINT(1) DEFAULT '1', - `time_of_downtime` TINYINT(1) DEFAULT '1', - `total_checks` TINYINT(1) DEFAULT '1', - `checks_failed` TINYINT(1) DEFAULT '1', - `checks_in_ok_status` TINYINT(1) DEFAULT '1', - `checks_in_warning_status` TINYINT(1) DEFAULT '0', - `unknown_checks` TINYINT(1) DEFAULT '1', - `agent_max_value` TINYINT(1) DEFAULT '1', - `agent_min_value` TINYINT(1) DEFAULT '1', - `current_month` TINYINT(1) DEFAULT '1', - `failover_mode` tinyint(1) DEFAULT '1', - `failover_type` tinyint(1) DEFAULT '1', - `summary` tinyint(1) DEFAULT 0, - `uncompressed_module` TINYINT DEFAULT '0', - `landscape` tinyint(1) UNSIGNED NOT NULL default 0, - `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0, - `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0, - `graph_render` tinyint(1) UNSIGNED NOT NULL default 0, - `ipam_network_filter` int(10) UNSIGNED DEFAULT 0, - `ipam_alive_ips` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - `ipam_ip_not_assigned_to_agent` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, - PRIMARY KEY(`id_rc`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_rc` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_report` INT UNSIGNED NOT NULL DEFAULT 0, + `id_gs` INT UNSIGNED NULL DEFAULT NULL, + `text_agent_module` TEXT, + `type` VARCHAR(30) DEFAULT 'simple_graph', + `period` INT NOT NULL DEFAULT 0, + `order` INT NOT NULL DEFAULT 0, + `description` MEDIUMTEXT, + `text_agent` TEXT, + `text` TEXT, + `external_source` MEDIUMTEXT, + `treport_custom_sql_id` INT UNSIGNED DEFAULT 0, + `header_definition` TINYTEXT , + `column_separator` TINYTEXT , + `line_separator` TINYTEXT , + `time_from` time DEFAULT '00:00:00', + `time_to` time DEFAULT '00:00:00', + `monday` TINYINT DEFAULT 1, + `tuesday` TINYINT DEFAULT 1, + `wednesday` TINYINT DEFAULT 1, + `thursday` TINYINT DEFAULT 1, + `friday` TINYINT DEFAULT 1, + `saturday` TINYINT DEFAULT 1, + `sunday` TINYINT DEFAULT 1, + `only_display_wrong` TINYINT unsigned DEFAULT 0 NOT NULL, + `top_n` INT NOT NULL DEFAULT 0, + `top_n_value` INT NOT NULL DEFAULT 10, + `exception_condition` INT NOT NULL DEFAULT 0, + `exception_condition_value` DOUBLE NOT NULL DEFAULT 0, + `show_resume` INT NOT NULL DEFAULT 0, + `order_uptodown` INT NOT NULL DEFAULT 0, + `show_graph` INT NOT NULL DEFAULT 0, + `group_by_agent` INT NOT NULL DEFAULT 0, + `style` TEXT, + `id_group` INT unsigned NOT NULL DEFAULT 0, + `id_module_group` INT unsigned NOT NULL DEFAULT 0, + `server_name` TEXT, + `exact_match` TINYINT DEFAULT 0, + `module_names` TEXT, + `module_free_text` TEXT, + `each_agent` TINYINT DEFAULT 1, + `historical_db` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `lapse_calc` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `lapse` INT UNSIGNED NOT NULL DEFAULT 300, + `visual_format` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `hide_no_data` TINYINT DEFAULT 0, + `total_time` TINYINT DEFAULT 1, + `time_failed` TINYINT DEFAULT 1, + `time_in_ok_status` TINYINT DEFAULT 1, + `time_in_warning_status` TINYINT DEFAULT 0, + `time_in_unknown_status` TINYINT DEFAULT 1, + `time_of_not_initialized_module` TINYINT DEFAULT 1, + `time_of_downtime` TINYINT DEFAULT 1, + `total_checks` TINYINT DEFAULT 1, + `checks_failed` TINYINT DEFAULT 1, + `checks_in_ok_status` TINYINT DEFAULT 1, + `checks_in_warning_status` TINYINT DEFAULT 0, + `unknown_checks` TINYINT DEFAULT 1, + `agent_max_value` TINYINT DEFAULT 1, + `agent_min_value` TINYINT DEFAULT 1, + `current_month` TINYINT DEFAULT 1, + `failover_mode` TINYINT DEFAULT 1, + `failover_type` TINYINT DEFAULT 1, + `summary` TINYINT DEFAULT 0, + `uncompressed_module` TINYINT DEFAULT 0, + `landscape` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `pagebreak` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `compare_work_time` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `graph_render` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `ipam_network_filter` INT UNSIGNED DEFAULT 0, + `ipam_alive_ips` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `ipam_ip_not_assigned_to_agent` TINYINT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id_rc`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `treport_content_sla_com_temp` (treport_content_sla_combined_template) -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport_content_sla_com_temp` ( - `id` INTEGER UNSIGNED NOT NULL auto_increment, - `id_report_content` INTEGER UNSIGNED NOT NULL, - `text_agent` text, - `text_agent_module` text, - `sla_max` double(18,2) NOT NULL default 0, - `sla_min` double(18,2) NOT NULL default 0, - `sla_limit` double(18,2) NOT NULL default 0, - `server_name` text, - `exact_match` tinyint(1) default 0, - PRIMARY KEY(`id`), - FOREIGN KEY (`id_report_content`) REFERENCES treport_content_template(`id_rc`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_report_content` INT UNSIGNED NOT NULL, + `text_agent` TEXT, + `text_agent_module` TEXT, + `sla_max` DOUBLE NOT NULL DEFAULT 0, + `sla_min` DOUBLE NOT NULL DEFAULT 0, + `sla_limit` DOUBLE NOT NULL DEFAULT 0, + `server_name` TEXT, + `exact_match` TINYINT DEFAULT 0, + PRIMARY KEY(`id`), + FOREIGN KEY (`id_report_content`) REFERENCES treport_content_template(`id_rc`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `treport_content_item_temp` (treport_content_item_template) -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `treport_content_item_temp` ( - `id` INTEGER UNSIGNED NOT NULL auto_increment, - `id_report_content` INTEGER UNSIGNED NOT NULL, - `text_agent` text, - `text_agent_module` text, - `server_name` text, - `exact_match` tinyint(1) default 0, - `operation` text, - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_report_content` INT UNSIGNED NOT NULL, + `text_agent` TEXT, + `text_agent_module` TEXT, + `server_name` TEXT, + `exact_match` TINYINT DEFAULT 0, + `operation` TEXT, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tgraph_template` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgraph_template` ( - `id_graph_template` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_user` TEXT NOT NULL, - `name` TEXT NOT NULL, - `description` TEXT NOT NULL, - `period` int(11) NOT NULL default '0', - `width` smallint(5) UNSIGNED NOT NULL DEFAULT 0, - `height` smallint(5) UNSIGNED NOT NULL DEFAULT 0, - `private` tinyint(1) UNSIGNED NOT NULL default 0, - `events` tinyint(1) UNSIGNED NOT NULL default 0, - `stacked` tinyint(1) UNSIGNED NOT NULL default 0, - `id_group` mediumint(8) unsigned NULL default 0, - PRIMARY KEY(`id_graph_template`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_graph_template` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` TEXT, + `name` TEXT, + `description` TEXT, + `period` INT NOT NULL DEFAULT 0, + `width` SMALLINT UNSIGNED NOT NULL DEFAULT 0, + `height` SMALLINT UNSIGNED NOT NULL DEFAULT 0, + `private` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `events` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `stacked` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + PRIMARY KEY(`id_graph_template`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tgraph_source_template` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tgraph_source_template` ( - `id_gs_template` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_template` int(11) NOT NULL default 0, - `agent` TEXT, - `module` TEXT, - `weight` FLOAT(5,3) NOT NULL DEFAULT 2, - `exact_match` tinyint(1) default 0, - PRIMARY KEY(`id_gs_template`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id_gs_template` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_template` INT NOT NULL DEFAULT 0, + `agent` TEXT, + `module` TEXT, + `weight` DOUBLE NOT NULL DEFAULT 2, + `exact_match` TINYINT DEFAULT 0, + PRIMARY KEY(`id_gs_template`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tmetaconsole_event` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmetaconsole_event` ( - `id_evento` bigint(20) unsigned NOT NULL auto_increment, - `id_source_event` bigint(20) unsigned NOT NULL, - `id_agente` int(10) NOT NULL default '0', - `agent_name` varchar(600) BINARY NOT NULL default '', - `id_usuario` varchar(100) NOT NULL default '0', - `id_grupo` mediumint(4) NOT NULL default '0', - `group_name` varchar(100) NOT NULL default '', - `estado` tinyint(3) unsigned NOT NULL default '0', - `timestamp` datetime NOT NULL default '1970-01-01 00:00:00', - `evento` text NOT NULL, - `utimestamp` bigint(20) NOT NULL default '0', - `event_type` enum('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change') default 'unknown', - `id_agentmodule` int(10) NOT NULL default '0', - `module_name` varchar(600) NOT NULL, - `id_alert_am` int(10) NOT NULL default '0', - `alert_template_name` text, - `criticity` int(4) unsigned NOT NULL default '0', - `user_comment` text NOT NULL, - `tags` text NOT NULL, - `source` tinytext NOT NULL, - `id_extra` tinytext NOT NULL, - `critical_instructions` text NOT NULL default '', - `warning_instructions` text NOT NULL default '', - `unknown_instructions` text NOT NULL default '', - `owner_user` VARCHAR(100) NOT NULL DEFAULT '', - `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', - `server_id` int(10) NOT NULL, - `custom_data` TEXT NOT NULL DEFAULT '', - `data` tinytext default NULL, - `module_status` int(4) NOT NULL default '0', - PRIMARY KEY (`id_evento`), - KEY `idx_agente` (`id_agente`), - KEY `idx_agentmodule` (`id_agentmodule`), - KEY `server_id` (`server_id`), - KEY `idx_utimestamp` USING BTREE (`utimestamp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_evento` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_source_event` BIGINT UNSIGNED NOT NULL, + `id_agente` INT NOT NULL DEFAULT 0, + `agent_name` VARCHAR(600) NOT NULL DEFAULT '', + `id_usuario` VARCHAR(100) NOT NULL DEFAULT '0', + `id_grupo` MEDIUMINT NOT NULL DEFAULT 0, + `group_name` VARCHAR(100) NOT NULL DEFAULT '', + `estado` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `timestamp` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `evento` TEXT, + `utimestamp` BIGINT NOT NULL DEFAULT 0, + `event_type` ENUM('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change') DEFAULT 'unknown', + `id_agentmodule` INT NOT NULL DEFAULT 0, + `module_name` VARCHAR(600) NOT NULL, + `id_alert_am` INT NOT NULL DEFAULT 0, + `alert_template_name` TEXT, + `criticity` INT UNSIGNED NOT NULL DEFAULT 0, + `user_comment` TEXT, + `tags` TEXT, + `source` TINYTEXT, + `id_extra` TINYTEXT, + `critical_instructions` TEXT , + `warning_instructions` TEXT , + `unknown_instructions` TEXT , + `owner_user` VARCHAR(100) NOT NULL DEFAULT '', + `ack_utimestamp` BIGINT NOT NULL DEFAULT 0, + `server_id` INT NOT NULL, + `custom_data` TEXT , + `data` TINYTEXT , + `module_status` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_evento`), + KEY `idx_agente` (`id_agente`), + KEY `idx_agentmodule` (`id_agentmodule`), + KEY `server_id` (`server_id`), + KEY `idx_utimestamp` USING BTREE (`utimestamp`), + KEY `tme_timestamp_idx` (`timestamp`), + KEY `tme_module_status_idx` (`module_status`), + KEY `tme_criticity_idx` (`criticity`), + KEY `tme_agent_name_idx` (`agent_name`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- Criticity: 0 - Maintance (grey) -- Criticity: 1 - Informational (blue) -- Criticity: 2 - Normal (green) (status 0) @@ -3352,50 +3348,47 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event` ( -- Criticity: 5 - Minor -- Criticity: 6 - Major -ALTER TABLE tmetaconsole_event ADD INDEX `tme_timestamp_idx` (`timestamp`); -ALTER TABLE tmetaconsole_event ADD INDEX `tme_module_status_idx` (`module_status`); -ALTER TABLE tmetaconsole_event ADD INDEX `tme_criticity_idx` (`criticity`); -ALTER TABLE tmetaconsole_event ADD INDEX `tme_agent_name_idx` (`agent_name`); - -- --------------------------------------------------------------------- -- Table `tmetaconsole_event_history` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmetaconsole_event_history` ( - `id_evento` bigint(20) unsigned NOT NULL auto_increment, - `id_source_event` bigint(20) unsigned NOT NULL, - `id_agente` int(10) NOT NULL default '0', - `agent_name` varchar(600) BINARY NOT NULL default '', - `id_usuario` varchar(100) NOT NULL default '0', - `id_grupo` mediumint(4) NOT NULL default '0', - `group_name` varchar(100) NOT NULL default '', - `estado` tinyint(3) unsigned NOT NULL default '0', - `timestamp` datetime NOT NULL default '1970-01-01 00:00:00', - `evento` text NOT NULL, - `utimestamp` bigint(20) NOT NULL default '0', - `event_type` enum('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change') default 'unknown', - `id_agentmodule` int(10) NOT NULL default '0', - `module_name` varchar(600) NOT NULL, - `id_alert_am` int(10) NOT NULL default '0', - `alert_template_name` text, - `criticity` int(4) unsigned NOT NULL default '0', - `user_comment` text NOT NULL, - `tags` text NOT NULL, - `source` tinytext NOT NULL, - `id_extra` tinytext NOT NULL, - `critical_instructions` text NOT NULL default '', - `warning_instructions` text NOT NULL default '', - `unknown_instructions` text NOT NULL default '', - `owner_user` VARCHAR(100) NOT NULL DEFAULT '', - `ack_utimestamp` BIGINT(20) NOT NULL DEFAULT '0', - `server_id` int(10) NOT NULL, - `custom_data` TEXT NOT NULL DEFAULT '', - `data` double(50,5) default NULL, - `module_status` int(4) NOT NULL default '0', - PRIMARY KEY (`id_evento`), - KEY `idx_agente` (`id_agente`), - KEY `idx_agentmodule` (`id_agentmodule`), - KEY `idx_utimestamp` USING BTREE (`utimestamp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_evento` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_source_event` BIGINT UNSIGNED NOT NULL, + `id_agente` INT NOT NULL DEFAULT 0, + `agent_name` VARCHAR(600) NOT NULL DEFAULT '', + `id_usuario` VARCHAR(100) NOT NULL DEFAULT '0', + `id_grupo` MEDIUMINT NOT NULL DEFAULT 0, + `group_name` VARCHAR(100) NOT NULL DEFAULT '', + `estado` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `timestamp` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `evento` TEXT, + `utimestamp` BIGINT NOT NULL DEFAULT 0, + `event_type` ENUM('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change') DEFAULT 'unknown', + `id_agentmodule` INT NOT NULL DEFAULT 0, + `module_name` VARCHAR(600) NOT NULL, + `id_alert_am` INT NOT NULL DEFAULT 0, + `alert_template_name` TEXT, + `criticity` INT UNSIGNED NOT NULL DEFAULT 0, + `user_comment` TEXT, + `tags` TEXT, + `source` TINYTEXT, + `id_extra` TINYTEXT, + `critical_instructions` TEXT , + `warning_instructions` TEXT , + `unknown_instructions` TEXT , + `owner_user` VARCHAR(100) NOT NULL DEFAULT '', + `ack_utimestamp` BIGINT NOT NULL DEFAULT 0, + `server_id` INT NOT NULL, + `custom_data` TEXT , + `data` DOUBLE DEFAULT NULL, + `module_status` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_evento`), + KEY `idx_agente` (`id_agente`), + KEY `idx_agentmodule` (`id_agentmodule`), + KEY `idx_utimestamp` USING BTREE (`utimestamp`), + KEY `tmeh_estado_idx` (`estado`), + KEY `tmeh_timestamp_idx` (`timestamp`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- Criticity: 0 - Maintance (grey) -- Criticity: 1 - Informational (blue) -- Criticity: 2 - Normal (green) (status 0) @@ -3404,823 +3397,820 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_event_history` ( -- Criticity: 5 - Minor -- Criticity: 6 - Major -ALTER TABLE tmetaconsole_event_history ADD INDEX `tmeh_estado_idx` (`estado`); -ALTER TABLE tmetaconsole_event_history ADD INDEX `tmeh_timestamp_idx` (`timestamp`); - -- --------------------------------------------------------------------- -- Table `textension_translate_string` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `textension_translate_string` ( - `id` int(10) unsigned NOT NULL auto_increment, - `lang` VARCHAR(10) NOT NULL , - `string` TEXT NOT NULL DEFAULT '' , - `translation` TEXT NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - KEY `lang_index` (`lang`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `lang` VARCHAR(10) NOT NULL , + `string` TEXT , + `translation` TEXT , + PRIMARY KEY (`id`), + KEY `lang_index` (`lang`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tagent_module_log` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagent_module_log` ( - `id_agent_module_log` int(10) NOT NULL AUTO_INCREMENT, - `id_agent` int(10) unsigned NOT NULL, - `source` text NOT NULL, - `timestamp` datetime DEFAULT '1970-01-01 00:00:00', - `utimestamp` bigint(20) DEFAULT '0', - PRIMARY KEY (`id_agent_module_log`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agent_module_log` INT NOT NULL AUTO_INCREMENT, + `id_agent` INT UNSIGNED NOT NULL, + `source` TEXT, + `timestamp` DATETIME DEFAULT '1970-01-01 00:00:00', + `utimestamp` BIGINT DEFAULT 0, + PRIMARY KEY (`id_agent_module_log`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tevent_custom_field` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tevent_custom_field` ( - `id_group` mediumint(4) unsigned NOT NULL, - `value` text NOT NULL, - PRIMARY KEY (`id_group`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_group` MEDIUMINT UNSIGNED NOT NULL, + `value` TEXT, + PRIMARY KEY (`id_group`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tmetaconsole_agent` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` ( - `id_agente` int(10) unsigned NOT NULL auto_increment, - `id_tagente` int(10) unsigned NOT NULL, - `id_tmetaconsole_setup` int(10) NOT NULL, - `nombre` varchar(600) BINARY NOT NULL default '', - `direccion` varchar(100) default NULL, - `comentarios` varchar(255) default '', - `id_grupo` int(10) unsigned NOT NULL default '0', - `ultimo_contacto` datetime NOT NULL default '1970-01-01 00:00:00', - `modo` tinyint(1) NOT NULL default '0', - `intervalo` int(11) unsigned NOT NULL default '300', - `id_os` int(10) unsigned default '0', - `os_version` varchar(100) default '', - `agent_version` varchar(100) default '', - `ultimo_contacto_remoto` datetime default '1970-01-01 00:00:00', - `disabled` tinyint(2) NOT NULL default '0', - `remote` tinyint(1) NOT NULL default '0', - `id_parent` int(10) unsigned default '0', - `custom_id` varchar(255) default '', - `server_name` varchar(100) default '', - `cascade_protection` tinyint(2) NOT NULL default '0', - `cascade_protection_module` int(10) unsigned default '0', - `timezone_offset` TINYINT(2) NULL DEFAULT '0' COMMENT 'number of hours of diference with the server timezone' , - `icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' , - `update_gis_data` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it' , - `url_address` mediumtext NULL, - `quiet` tinyint(1) NOT NULL default '0', - `normal_count` bigint(20) NOT NULL default '0', - `warning_count` bigint(20) NOT NULL default '0', - `critical_count` bigint(20) NOT NULL default '0', - `unknown_count` bigint(20) NOT NULL default '0', - `notinit_count` bigint(20) NOT NULL default '0', - `total_count` bigint(20) NOT NULL default '0', - `fired_count` bigint(20) NOT NULL default '0', - `update_module_count` tinyint(1) NOT NULL default '0', - `update_alert_count` tinyint(1) NOT NULL default '0', - `update_secondary_groups` tinyint(1) NOT NULL default '0', - `transactional_agent` tinyint(1) NOT NULL default '0', - `alias` varchar(600) BINARY NOT NULL default '', - `alias_as_name` tinyint(2) NOT NULL default '0', - `safe_mode_module` int(10) unsigned NOT NULL default '0', - `cps` int NOT NULL default 0, - PRIMARY KEY (`id_agente`), - KEY `nombre` (`nombre`(255)), - KEY `direccion` (`direccion`), - KEY `id_tagente_idx` (`id_tagente`), - KEY `disabled` (`disabled`), - KEY `id_grupo` (`id_grupo`), - FOREIGN KEY (`id_tmetaconsole_setup`) REFERENCES tmetaconsole_setup(`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE tmetaconsole_agent ADD INDEX `tma_id_os_idx` (`id_os`); -ALTER TABLE tmetaconsole_agent ADD INDEX `tma_server_name_idx` (`server_name`); + `id_agente` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_tagente` INT UNSIGNED NOT NULL, + `id_tmetaconsole_setup` INT NOT NULL, + `nombre` VARCHAR(600) NOT NULL DEFAULT '', + `direccion` VARCHAR(100) DEFAULT NULL, + `comentarios` VARCHAR(255) DEFAULT '', + `id_grupo` INT UNSIGNED NOT NULL DEFAULT 0, + `ultimo_contacto` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `modo` TINYINT NOT NULL DEFAULT 0, + `intervalo` INT UNSIGNED NOT NULL DEFAULT 300, + `id_os` INT UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '', + `agent_version` VARCHAR(100) DEFAULT '', + `ultimo_contacto_remoto` DATETIME DEFAULT '1970-01-01 00:00:00', + `disabled` TINYINT NOT NULL DEFAULT 0, + `remote` TINYINT NOT NULL DEFAULT 0, + `id_parent` INT UNSIGNED DEFAULT 0, + `custom_id` VARCHAR(255) DEFAULT '', + `server_name` VARCHAR(100) DEFAULT '', + `cascade_protection` TINYINT NOT NULL DEFAULT 0, + `cascade_protection_module` INT UNSIGNED DEFAULT 0, + `timezone_offset` TINYINT NULL DEFAULT 0 COMMENT 'number of hours of diference with the server timezone', + `icon_path` VARCHAR(127) NULL DEFAULT NULL COMMENT 'path in the server to the image of the icon representing the agent' , + `update_gis_data` TINYINT NOT NULL DEFAULT 1 COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it', + `url_address` MEDIUMTEXT NULL, + `quiet` TINYINT NOT NULL DEFAULT 0, + `normal_count` BIGINT NOT NULL DEFAULT 0, + `warning_count` BIGINT NOT NULL DEFAULT 0, + `critical_count` BIGINT NOT NULL DEFAULT 0, + `unknown_count` BIGINT NOT NULL DEFAULT 0, + `notinit_count` BIGINT NOT NULL DEFAULT 0, + `total_count` BIGINT NOT NULL DEFAULT 0, + `fired_count` BIGINT NOT NULL DEFAULT 0, + `update_module_count` TINYINT NOT NULL DEFAULT 0, + `update_alert_count` TINYINT NOT NULL DEFAULT 0, + `update_secondary_groups` TINYINT NOT NULL DEFAULT 0, + `transactional_agent` TINYINT NOT NULL DEFAULT 0, + `alias` VARCHAR(600) NOT NULL DEFAULT '', + `alias_as_name` TINYINT NOT NULL DEFAULT 0, + `safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0, + `cps` INT NOT NULL DEFAULT 0, + PRIMARY KEY (`id_agente`), + KEY `nombre` (`nombre`(255)), + KEY `direccion` (`direccion`), + KEY `id_tagente_idx` (`id_tagente`), + KEY `disabled` (`disabled`), + KEY `id_grupo` (`id_grupo`), + KEY `tma_id_os_idx` (`id_os`), + KEY `tma_server_name_idx` (`server_name`), + FOREIGN KEY (`id_tmetaconsole_setup`) REFERENCES tmetaconsole_setup(`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `ttransaction` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `ttransaction` ( - `transaction_id` int unsigned NOT NULL auto_increment, - `agent_id` int(10) unsigned NOT NULL, - `group_id` int(10) unsigned NOT NULL default '0', - `description` text, - `name` varchar(250) NOT NULL, - `loop_interval` int unsigned NOT NULL default 40, - `ready` int unsigned NOT NULL default 0, - `running` int unsigned NOT NULL default 0, - PRIMARY KEY (`transaction_id`) -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `ttransaction` ( + `transaction_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `agent_id` INT UNSIGNED NOT NULL, + `group_id` INT UNSIGNED NOT NULL DEFAULT 0, + `description` TEXT, + `name` VARCHAR(250) NOT NULL, + `loop_interval` INT UNSIGNED NOT NULL DEFAULT 40, + `ready` INT UNSIGNED NOT NULL DEFAULT 0, + `running` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`transaction_id`) +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tphase` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tphase`( - `phase_id` int unsigned not null auto_increment, - `transaction_id` int unsigned not null, - `agent_id` int(10) unsigned not null, - `name` varchar(250) not null, - `idx` int unsigned not null, - `dependencies` text, - `enables` text, - `launch` text, - `retries` int unsigned default null, - `timeout` int unsigned default null, - PRIMARY KEY (`phase_id`,`transaction_id`) -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tphase`( + `phase_id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `transaction_id` INT UNSIGNED NOT NULL, + `agent_id` INT UNSIGNED NOT NULL, + `name` VARCHAR(250) NOT NULL, + `idx` INT UNSIGNED NOT NULL, + `dependencies` TEXT, + `enables` TEXT, + `launch` TEXT, + `retries` INT UNSIGNED DEFAULT null, + `timeout` INT UNSIGNED DEFAULT null, + PRIMARY KEY (`phase_id`,`transaction_id`) +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; CREATE TABLE IF NOT EXISTS `treset_pass` ( - `id` bigint(10) unsigned NOT NULL auto_increment, - `id_user` varchar(100) NOT NULL default '', - `cod_hash` varchar(100) NOT NULL default '', - `reset_time` int(10) unsigned NOT NULL default 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` VARCHAR(100) NOT NULL DEFAULT '', + `cod_hash` VARCHAR(100) NOT NULL DEFAULT '', + `reset_time` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tcluster` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tcluster`( - `id` int unsigned not null auto_increment, - `name` tinytext not null default '', - `cluster_type` enum('AA','AP') not null default 'AA', - `description` text not null default '', - `group` int(10) unsigned NOT NULL default '0', - `id_agent` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`) -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tcluster`( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TINYTEXT , + `cluster_type` ENUM('AA','AP') NOT NULL DEFAULT 'AA', + `description` TEXT , + `group` INT UNSIGNED NOT NULL DEFAULT 0, + `id_agent` INT UNSIGNED NOT NULL, + PRIMARY KEY (`id`) +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tcluster_item` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tcluster_item`( - `id` int unsigned not null auto_increment, - `name` tinytext not null default '', - `item_type` enum('AA','AP') not null default 'AA', - `critical_limit` int unsigned NOT NULL default '0', - `warning_limit` int unsigned NOT NULL default '0', - `is_critical` tinyint(2) unsigned NOT NULL default '0', - `id_cluster` int unsigned, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`) - ON DELETE SET NULL ON UPDATE CASCADE -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tcluster_item`( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` TINYTEXT , + `item_type` ENUM('AA','AP') NOT NULL DEFAULT 'AA', + `critical_limit` INT UNSIGNED NOT NULL DEFAULT 0, + `warning_limit` INT UNSIGNED NOT NULL DEFAULT 0, + `is_critical` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_cluster` INT UNSIGNED, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`) + ON DELETE SET NULL ON UPDATE CASCADE +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tcluster_agent` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tcluster_agent`( - `id_cluster` int unsigned not null, - `id_agent` int(10) unsigned not null, - PRIMARY KEY (`id_cluster`,`id_agent`), - FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`) - ON UPDATE CASCADE -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tcluster_agent`( + `id_cluster` INT UNSIGNED NOT NULL, + `id_agent` INT UNSIGNED NOT NULL, + PRIMARY KEY (`id_cluster`,`id_agent`), + FOREIGN KEY (`id_cluster`) REFERENCES tcluster(`id`) + ON UPDATE CASCADE +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tprovisioning` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tprovisioning`( - `id` int unsigned NOT NULL auto_increment, - `name` varchar(100) NOT NULL, - `description` TEXT default '', - `order` int(11) NOT NULL default 0, - `config` TEXT default '', - PRIMARY KEY (`id`) -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tprovisioning`( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL, + `description` TEXT , + `order` INT NOT NULL DEFAULT 0, + `config` TEXT , + PRIMARY KEY (`id`) +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tprovisioning_rules` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tprovisioning_rules`( - `id` int unsigned NOT NULL auto_increment, - `id_provisioning` int unsigned NOT NULL, - `order` int(11) NOT NULL default 0, - `operator` enum('AND','OR') default 'OR', - `type` enum('alias','ip-range') default 'alias', - `value` varchar(100) NOT NULL default '', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_provisioning`) REFERENCES tprovisioning(`id`) - ON DELETE CASCADE -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tprovisioning_rules`( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_provisioning` INT UNSIGNED NOT NULL, + `order` INT NOT NULL DEFAULT 0, + `operator` ENUM('AND','OR') DEFAULT 'OR', + `type` ENUM('alias','ip-range') DEFAULT 'alias', + `value` VARCHAR(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + FOREIGN KEY (`id_provisioning`) REFERENCES tprovisioning(`id`) + ON DELETE CASCADE +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tmigration_queue` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tmigration_queue`( - `id` int unsigned not null auto_increment, - `id_source_agent` int unsigned not null, - `id_target_agent` int unsigned not null, - `id_source_node` int unsigned not null, - `id_target_node` int unsigned not null, - `priority` int unsigned default 0, - `step` int default 0, - `running` tinyint(2) default 0, - `active_db_only` tinyint(2) default 0, - PRIMARY KEY(`id`) -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tmigration_queue`( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_source_agent` INT UNSIGNED NOT NULL, + `id_target_agent` INT UNSIGNED NOT NULL, + `id_source_node` INT UNSIGNED NOT NULL, + `id_target_node` INT UNSIGNED NOT NULL, + `priority` INT UNSIGNED DEFAULT 0, + `step` INT DEFAULT 0, + `running` TINYINT DEFAULT 0, + `active_db_only` TINYINT DEFAULT 0, + PRIMARY KEY(`id`) +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tmigration_module_queue` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tmigration_module_queue`( - `id` int unsigned not null auto_increment, - `id_migration` int unsigned not null, - `id_source_agentmodule` int unsigned not null, - `id_target_agentmodule` int unsigned not null, - `last_replication_timestamp` bigint(20) NOT NULL default 0, - PRIMARY KEY(`id`), - FOREIGN KEY(`id_migration`) REFERENCES tmigration_queue(`id`) - ON DELETE CASCADE - ON UPDATE CASCADE -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tmigration_module_queue`( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_migration` INT UNSIGNED NOT NULL, + `id_source_agentmodule` INT UNSIGNED NOT NULL, + `id_target_agentmodule` INT UNSIGNED NOT NULL, + `last_replication_timestamp` BIGINT NOT NULL DEFAULT 0, + PRIMARY KEY(`id`), + FOREIGN KEY(`id_migration`) REFERENCES tmigration_queue(`id`) + ON DELETE CASCADE + ON UPDATE CASCADE +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tagent_secondary_group` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tagent_secondary_group`( - `id` int unsigned not null auto_increment, - `id_agent` int(10) unsigned NOT NULL, - `id_group` mediumint(4) unsigned NOT NULL, - PRIMARY KEY(`id`), - FOREIGN KEY(`id_agent`) REFERENCES tagente(`id_agente`) - ON DELETE CASCADE, - FOREIGN KEY(`id_group`) REFERENCES tgrupo(`id_grupo`) - ON DELETE CASCADE -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tagent_secondary_group`( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agent` INT UNSIGNED NOT NULL, + `id_group` MEDIUMINT UNSIGNED NOT NULL, + PRIMARY KEY(`id`), + FOREIGN KEY(`id_agent`) REFERENCES tagente(`id_agente`) + ON DELETE CASCADE, + FOREIGN KEY(`id_group`) REFERENCES tgrupo(`id_grupo`) + ON DELETE CASCADE +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tmetaconsole_agent_secondary_group` -- --------------------------------------------------------------------- -create table IF NOT EXISTS `tmetaconsole_agent_secondary_group`( - `id` int unsigned not null auto_increment, - `id_agent` int(10) unsigned NOT NULL, - `id_tagente` int(10) unsigned NOT NULL, - `id_tmetaconsole_setup` int(10) NOT NULL, - `id_group` mediumint(4) unsigned NOT NULL, - PRIMARY KEY(`id`), - KEY `id_tagente` (`id_tagente`), - FOREIGN KEY(`id_agent`) REFERENCES tmetaconsole_agent(`id_agente`) - ON DELETE CASCADE, - FOREIGN KEY(`id_group`) REFERENCES tgrupo(`id_grupo`) - ON DELETE CASCADE, - FOREIGN KEY (`id_tmetaconsole_setup`) REFERENCES tmetaconsole_setup(`id`) - ON DELETE CASCADE -) engine=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tmetaconsole_agent_secondary_group`( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_agent` INT UNSIGNED NOT NULL, + `id_tagente` INT UNSIGNED NOT NULL, + `id_tmetaconsole_setup` INT NOT NULL, + `id_group` MEDIUMINT UNSIGNED NOT NULL, + PRIMARY KEY(`id`), + KEY `id_tagente` (`id_tagente`), + FOREIGN KEY(`id_agent`) REFERENCES tmetaconsole_agent(`id_agente`) + ON DELETE CASCADE, + FOREIGN KEY(`id_group`) REFERENCES tgrupo(`id_grupo`) + ON DELETE CASCADE, + FOREIGN KEY (`id_tmetaconsole_setup`) REFERENCES tmetaconsole_setup(`id`) + ON DELETE CASCADE +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tautoconfig` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tautoconfig` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(100) NOT NULL, - `order` int(11) NOT NULL DEFAULT '0', - `description` text, + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL, + `order` INT NOT NULL DEFAULT 0, + `description` TEXT, + `disabled` TINYINT DEFAULT 0, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tautoconfig_rules` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_autoconfig` int(10) unsigned NOT NULL, - `order` int(11) NOT NULL DEFAULT '0', - `operator` enum('AND','OR') DEFAULT 'OR', - `type` enum('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias', - `value` text, - `custom` text, + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_autoconfig` INT UNSIGNED NOT NULL, + `order` INT NOT NULL DEFAULT 0, + `operator` ENUM('AND','OR') DEFAULT 'OR', + `type` ENUM('alias','ip-range','group','os','custom-field','script','server-name') DEFAULT 'alias', + `value` TEXT, + `custom` TEXT, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tautoconfig_actions` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_autoconfig` int(10) unsigned NOT NULL, - `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', - `value` text, - `custom` text, + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_autoconfig` INT UNSIGNED NOT NULL, + `order` INT NOT NULL DEFAULT 0, + `action_type` ENUM('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` TEXT, + `custom` TEXT, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tlayout_template` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `name` varchar(600) NOT NULL, - `id_group` INTEGER UNSIGNED NOT NULL, - `background` varchar(200) NOT NULL, - `height` INTEGER UNSIGNED NOT NULL default 0, - `width` INTEGER UNSIGNED NOT NULL default 0, - `background_color` varchar(50) NOT NULL default '#FFF', - `is_favourite` INTEGER UNSIGNED NOT NULL default 0, - `auto_adjust` INTEGER UNSIGNED NOT NULL default 0, - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(600) NOT NULL, + `id_group` INT UNSIGNED NOT NULL, + `background` VARCHAR(200) NOT NULL, + `height` INT UNSIGNED NOT NULL DEFAULT 0, + `width` INT UNSIGNED NOT NULL DEFAULT 0, + `background_color` VARCHAR(50) NOT NULL DEFAULT '#FFF', + `is_favourite` INT UNSIGNED NOT NULL DEFAULT 0, + `auto_adjust` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tlayout_template_data` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_layout_template` INTEGER UNSIGNED NOT NULL, - `pos_x` INTEGER UNSIGNED NOT NULL default 0, - `pos_y` INTEGER UNSIGNED NOT NULL default 0, - `height` INTEGER UNSIGNED NOT NULL default 0, - `width` INTEGER UNSIGNED NOT NULL default 0, - `label` TEXT, - `image` varchar(200) DEFAULT "", - `type` tinyint(1) UNSIGNED NOT NULL default 0, - `period` INTEGER UNSIGNED NOT NULL default 3600, - `module_name` text NOT NULL, - `agent_name` varchar(600) BINARY NOT NULL default '', - `id_layout_linked` INTEGER unsigned NOT NULL default '0', - `parent_item` INTEGER UNSIGNED NOT NULL default 0, - `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, - `id_metaconsole` int(10) NOT NULL default 0, - `id_group` INTEGER UNSIGNED NOT NULL default 0, - `id_custom_graph` INTEGER UNSIGNED NOT NULL default 0, - `border_width` INTEGER UNSIGNED NOT NULL default 0, - `type_graph` varchar(50) NOT NULL default 'area', - `label_position` varchar(50) NOT NULL default 'down', - `border_color` varchar(200) DEFAULT "", - `fill_color` varchar(200) DEFAULT "", - `show_statistics` tinyint(2) NOT NULL default '0', - `linked_layout_node_id` INT(10) NOT NULL default 0, - `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default', - `id_layout_linked_weight` int(10) NOT NULL default '0', - `linked_layout_status_as_service_warning` FLOAT(20, 3) NOT NULL default 0, - `linked_layout_status_as_service_critical` FLOAT(20, 3) NOT NULL default 0, - `element_group` int(10) NOT NULL default '0', - `show_on_top` tinyint(1) NOT NULL default '0', - `clock_animation` varchar(60) NOT NULL default "analogic_1", - `time_format` varchar(60) NOT NULL default "time", - `timezone` varchar(60) NOT NULL default "Europe/Madrid", - `show_last_value` tinyint(1) UNSIGNED NULL default '0', - `cache_expiration` INTEGER UNSIGNED NOT NULL default 0, - PRIMARY KEY(`id`), - FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_layout_template` INT UNSIGNED NOT NULL, + `pos_x` INT UNSIGNED NOT NULL DEFAULT 0, + `pos_y` INT UNSIGNED NOT NULL DEFAULT 0, + `height` INT UNSIGNED NOT NULL DEFAULT 0, + `width` INT UNSIGNED NOT NULL DEFAULT 0, + `label` TEXT, + `image` VARCHAR(200) DEFAULT '', + `type` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `period` INT UNSIGNED NOT NULL DEFAULT 3600, + `module_name` TEXT, + `agent_name` VARCHAR(600) NOT NULL DEFAULT '', + `id_layout_linked` INT unsigned NOT NULL DEFAULT 0, + `parent_item` INT UNSIGNED NOT NULL DEFAULT 0, + `enable_link` TINYINT UNSIGNED NOT NULL DEFAULT 1, + `id_metaconsole` INT NOT NULL DEFAULT 0, + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, + `id_custom_graph` INT UNSIGNED NOT NULL DEFAULT 0, + `border_width` INT UNSIGNED NOT NULL DEFAULT 0, + `type_graph` VARCHAR(50) NOT NULL DEFAULT 'area', + `label_position` VARCHAR(50) NOT NULL DEFAULT 'down', + `border_color` VARCHAR(200) DEFAULT '', + `fill_color` VARCHAR(200) DEFAULT '', + `show_statistics` TINYINT NOT NULL DEFAULT 0, + `linked_layout_node_id` INT NOT NULL DEFAULT 0, + `linked_layout_status_type` ENUM ('default', 'weight', 'service') DEFAULT 'default', + `id_layout_linked_weight` INT NOT NULL DEFAULT 0, + `linked_layout_status_as_service_warning` DOUBLE NOT NULL DEFAULT 0, + `linked_layout_status_as_service_critical` DOUBLE NOT NULL DEFAULT 0, + `element_group` INT NOT NULL DEFAULT 0, + `show_on_top` TINYINT NOT NULL DEFAULT 0, + `clock_animation` VARCHAR(60) NOT NULL DEFAULT 'analogic_1', + `time_format` VARCHAR(60) NOT NULL DEFAULT 'time', + `timezone` VARCHAR(60) NOT NULL DEFAULT 'Europe/Madrid', + `show_last_value` TINYINT UNSIGNED NULL DEFAULT 0, + `cache_expiration` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id`), + FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tlog_graph_models` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlog_graph_models` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `title` TEXT NOT NULL, - `regexp` TEXT NOT NULL, - `fields` TEXT NOT NULL, - `average` tinyint(1) NOT NULL default '0', - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `title` TEXT, + `regexp` TEXT, + `fields` TEXT, + `average` TINYINT NOT NULL DEFAULT 0, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tagent_custom_fields_filter` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(600) NOT NULL, - `id_group` int(10) unsigned default '0', - `id_custom_field` varchar(600) default '', - `id_custom_fields_data` varchar(600) default '', - `id_status` varchar(600) default '', - `module_search` varchar(600) default '', - `module_status` varchar(600) default '', - `recursion` int(1) unsigned default '0', - `group_search` int(10) unsigned default '0', - PRIMARY KEY(`id`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(600) NOT NULL, + `id_group` INT UNSIGNED DEFAULT 0, + `id_custom_field` VARCHAR(600) DEFAULT '', + `id_custom_fields_data` VARCHAR(600) DEFAULT '', + `id_status` VARCHAR(600) DEFAULT '', + `module_search` VARCHAR(600) DEFAULT '', + `module_status` VARCHAR(600) DEFAULT '', + `recursion` INT UNSIGNED DEFAULT 0, + `group_search` INT UNSIGNED DEFAULT 0, + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ----------------------------------------------------- -- Table `tnetwork_matrix` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `tnetwork_matrix` ( - `id` int(10) unsigned NOT NULL auto_increment, - `source` varchar(60) default '', - `destination` varchar(60) default '', - `utimestamp` bigint(20) default 0, - `bytes` int(18) unsigned default 0, - `pkts` int(18) unsigned default 0, - PRIMARY KEY (`id`), - UNIQUE (`source`, `destination`, `utimestamp`) -) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `source` VARCHAR(60) DEFAULT '', + `destination` VARCHAR(60) DEFAULT '', + `utimestamp` BIGINT DEFAULT 0, + `bytes` INT UNSIGNED DEFAULT 0, + `pkts` INT UNSIGNED DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE (`source`, `destination`, `utimestamp`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4 ; -- --------------------------------------------------------------------- -- Table `user_task` -- --------------------------------------------------------------------- -CREATE TABLE `tuser_task` ( - `id` int(20) unsigned NOT NULL auto_increment, - `function_name` varchar(80) NOT NULL default '', - `parameters` text NOT NULL default '', - `name` varchar(60) NOT NULL default '', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tuser_task` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `function_name` VARCHAR(80) NOT NULL DEFAULT '', + `parameters` TEXT , + `name` VARCHAR(60) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `user_task_scheduled` -- --------------------------------------------------------------------- -CREATE TABLE `tuser_task_scheduled` ( - `id` int(20) unsigned NOT NULL auto_increment, - `id_usuario` varchar(60) NOT NULL default '0', - `id_user_task` int(20) unsigned NOT NULL default '0', - `args` TEXT NOT NULL, - `scheduled` enum('no','hourly','daily','weekly','monthly','yearly','custom') default 'no', - `last_run` int(20) unsigned default '0', - `custom_data` int(10) NULL default '0', - `flag_delete` tinyint(1) UNSIGNED NOT NULL default 0, - `id_grupo` int(10) unsigned NOT NULL default 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tuser_task_scheduled` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_usuario` VARCHAR(60) NOT NULL DEFAULT '0', + `id_user_task` INT UNSIGNED NOT NULL DEFAULT 0, + `args` TEXT, + `scheduled` ENUM('no','hourly','daily','weekly','monthly','yearly','custom') DEFAULT 'no', + `last_run` INT UNSIGNED DEFAULT 0, + `custom_data` INT NULL DEFAULT 0, + `flag_delete` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `id_grupo` INT UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tvisual_console_items_cache` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tvisual_console_elements_cache` ( - `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `vc_id` INTEGER UNSIGNED NOT NULL, - `vc_item_id` INTEGER UNSIGNED NOT NULL, - `user_id` VARCHAR(60) DEFAULT NULL, - `data` TEXT NOT NULL, - `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `expiration` INTEGER UNSIGNED NOT NULL COMMENT 'Seconds to expire', - PRIMARY KEY(`id`), - FOREIGN KEY(`vc_id`) REFERENCES `tlayout`(`id`) - ON DELETE CASCADE, - FOREIGN KEY(`vc_item_id`) REFERENCES `tlayout_data`(`id`) - ON DELETE CASCADE, - FOREIGN KEY (`user_id`) REFERENCES `tusuario`(`id_user`) - ON DELETE CASCADE - ON UPDATE CASCADE -) engine=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `vc_id` INT UNSIGNED NOT NULL, + `vc_item_id` INT UNSIGNED NOT NULL, + `user_id` VARCHAR(60) DEFAULT NULL, + `data` TEXT, + `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + `expiration` INT UNSIGNED NOT NULL COMMENT 'Seconds to expire', + PRIMARY KEY(`id`), + FOREIGN KEY(`vc_id`) REFERENCES `tlayout`(`id`) + ON DELETE CASCADE, + FOREIGN KEY(`vc_item_id`) REFERENCES `tlayout_data`(`id`) + ON DELETE CASCADE, + FOREIGN KEY (`user_id`) REFERENCES `tusuario`(`id_user`) + ON DELETE CASCADE + ON UPDATE CASCADE +) engine=InnoDB DEFAULT CHARSET=UTF8MB4; -- --------------------------------------------------------------------- -- Table `tagent_repository` -- --------------------------------------------------------------------- -CREATE TABLE `tagent_repository` ( +CREATE TABLE IF NOT EXISTS `tagent_repository` ( `id` SERIAL, - `id_os` INT(10) UNSIGNED DEFAULT 0, + `id_os` INT UNSIGNED DEFAULT 0, `arch` ENUM('x64', 'x86') DEFAULT 'x64', `version` VARCHAR(10) DEFAULT '', - `path` text, + `path` TEXT, `deployment_timeout` INT UNSIGNED DEFAULT 600, `uploaded_by` VARCHAR(100) DEFAULT '', - `uploaded` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was uploaded", - `last_err` text, + `uploaded` BIGINT NOT NULL DEFAULT 0 COMMENT 'When it was uploaded', + `last_err` TEXT, PRIMARY KEY (`id`), FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tdeployment_hosts` -- ---------------------------------------------------------------------- -CREATE TABLE `tdeployment_hosts` ( +CREATE TABLE IF NOT EXISTS `tdeployment_hosts` ( `id` SERIAL, `id_cs` VARCHAR(100), `ip` VARCHAR(100) NOT NULL UNIQUE, - `id_os` INT(10) UNSIGNED DEFAULT 0, - `os_version` VARCHAR(100) DEFAULT '' COMMENT "OS version in STR format", + `id_os` INT UNSIGNED DEFAULT 0, + `os_version` VARCHAR(100) DEFAULT '' COMMENT 'OS version in STR format', `arch` ENUM('x64', 'x86') DEFAULT 'x64', - `current_agent_version` VARCHAR(100) DEFAULT '' COMMENT "String latest installed agent", + `current_agent_version` VARCHAR(100) DEFAULT '' COMMENT 'String latest installed agent', `target_agent_version_id` BIGINT UNSIGNED, - `deployed` bigint(20) NOT NULL DEFAULT 0 COMMENT "When it was deployed", - `server_ip` varchar(100) default NULL COMMENT "Where to point target agent", - `last_err` text, + `deployed` BIGINT NOT NULL DEFAULT 0 COMMENT 'When it was deployed', + `server_ip` VARCHAR(100) DEFAULT NULL COMMENT 'Where to point target agent', + `last_err` TEXT, PRIMARY KEY (`id`), FOREIGN KEY (`id_cs`) REFERENCES `tcredential_store`(`identifier`) - ON UPDATE CASCADE ON DELETE SET NULL, + ON UPDATE CASCADE ON DELETE SET NULL, FOREIGN KEY (`id_os`) REFERENCES `tconfig_os`(`id_os`) - ON UPDATE CASCADE ON DELETE CASCADE, + ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (`target_agent_version_id`) REFERENCES `tagent_repository`(`id`) - ON UPDATE CASCADE ON DELETE SET NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tremote_command` -- ---------------------------------------------------------------------- -CREATE TABLE `tremote_command` ( +CREATE TABLE IF NOT EXISTS `tremote_command` ( `id` SERIAL, - `name` varchar(150) NOT NULL, - `timeout` int(10) unsigned NOT NULL default 30, - `retries` int(10) unsigned NOT NULL default 3, - `preconditions` text, - `script` text, - `postconditions` text, - `utimestamp` int(20) unsigned NOT NULL default 0, - `id_group` int(10) unsigned NOT NULL default 0, + `name` VARCHAR(150) NOT NULL, + `timeout` INT UNSIGNED NOT NULL DEFAULT 30, + `retries` INT UNSIGNED NOT NULL DEFAULT 3, + `preconditions` TEXT, + `script` TEXT, + `postconditions` TEXT, + `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, + `id_group` INT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tremote_command_target` -- ---------------------------------------------------------------------- -CREATE TABLE `tremote_command_target` ( +CREATE TABLE IF NOT EXISTS `tremote_command_target` ( `id` SERIAL, - `rcmd_id` bigint unsigned NOT NULL, - `id_agent` int(10) unsigned NOT NULL, - `utimestamp` int(20) unsigned NOT NULL default 0, + `rcmd_id` BIGINT UNSIGNED NOT NULL, + `id_agent` INT UNSIGNED NOT NULL, + `utimestamp` INT UNSIGNED NOT NULL DEFAULT 0, `stdout` MEDIUMTEXT, `stderr` MEDIUMTEXT, - `errorlevel` int(10) unsigned NOT NULL default 0, + `errorlevel` INT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id`), FOREIGN KEY (`rcmd_id`) REFERENCES `tremote_command`(`id`) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tnode_relations` -- ---------------------------------------------------------------------- -CREATE TABLE `tnode_relations` ( - `id` int(10) unsigned NOT NULL auto_increment, - `gateway` VARCHAR(100) NOT NULL, - `imei` VARCHAR(100) NOT NULL, - `node_address` VARCHAR(60) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `tnode_relations` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `gateway` VARCHAR(100) NOT NULL, + `imei` VARCHAR(100) NOT NULL, + `node_address` VARCHAR(60) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tipam_network_location` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tipam_network_location` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(100) NOT NULL default '', - PRIMARY KEY (`id`), - UNIQUE (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tipam_sites` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tipam_sites` ( - `id` serial, - `name` varchar(100) UNIQUE NOT NULL default '', - `description` text, - `parent` bigint unsigned null, - PRIMARY KEY (`id`), - FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `name` VARCHAR(100) UNIQUE NOT NULL DEFAULT '', + `description` TEXT, + `parent` BIGINT UNSIGNED null, + PRIMARY KEY (`id`), + FOREIGN KEY (`parent`) REFERENCES `tipam_sites`(`id`) ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tipam_network` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tipam_network` ( - `id` bigint(20) unsigned NOT NULL auto_increment, - `network` varchar(100) NOT NULL default '', - `name_network` varchar(255) default '', - `description` text NOT NULL, - `location` int(10) unsigned NULL, - `id_recon_task` int(10) unsigned NOT NULL, - `scan_interval` tinyint(2) default 1, - `monitoring` tinyint(2) default 0, - `id_group` mediumint(8) unsigned NULL default 0, - `lightweight_mode` tinyint(2) default 0, - `users_operator` text, - `id_site` bigint unsigned, - `vrf` int(10) unsigned, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE, - FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE, - FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `network` VARCHAR(100) NOT NULL DEFAULT '', + `name_network` VARCHAR(255) DEFAULT '', + `description` TEXT, + `location` INT UNSIGNED NULL, + `id_recon_task` INT UNSIGNED NOT NULL, + `scan_interval` TINYINT DEFAULT 1, + `monitoring` TINYINT DEFAULT 0, + `id_group` MEDIUMINT UNSIGNED NULL DEFAULT 0, + `lightweight_mode` TINYINT DEFAULT 0, + `users_operator` TEXT, + `id_site` BIGINT UNSIGNED, + `vrf` INT UNSIGNED, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_recon_task`) REFERENCES trecon_task(`id_rt`) ON DELETE CASCADE, + FOREIGN KEY (`location`) REFERENCES `tipam_network_location`(`id`) ON DELETE CASCADE, + FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE, + FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tipam_ip` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tipam_ip` ( - `id` bigint(20) unsigned NOT NULL auto_increment, - `id_network` bigint(20) unsigned NOT NULL default 0, - `id_agent` int(10) unsigned NOT NULL, - `forced_agent` tinyint(2) NOT NULL default '0', - `ip` varchar(100) NOT NULL default '', - `ip_dec` int(10) unsigned NOT NULL, - `id_os` int(10) unsigned NOT NULL, - `forced_os` tinyint(2) NOT NULL default '0', - `hostname` tinytext NOT NULL, - `forced_hostname` tinyint(2) NOT NULL default '0', - `comments` text NOT NULL, - `alive` tinyint(2) NOT NULL default '0', - `managed` tinyint(2) NOT NULL default '0', - `reserved` tinyint(2) NOT NULL default '0', - `time_last_check` datetime NOT NULL default '1970-01-01 00:00:00', - `time_create` datetime NOT NULL default '1970-01-01 00:00:00', - `users_operator` text, - `time_last_edit` datetime NOT NULL default '1970-01-01 00:00:00', - `enabled` tinyint(2) NOT NULL default '1', - `generate_events` tinyint(2) NOT NULL default '0', - `leased` tinyint(2) DEFAULT '0', - `leased_expiration` bigint(20) DEFAULT '0', - `mac_address` varchar(20) DEFAULT NULL, - `leased_mode` tinyint(2) DEFAULT '0', - PRIMARY KEY (`id`), - FOREIGN KEY (`id_network`) REFERENCES tipam_network(`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_network` BIGINT UNSIGNED NOT NULL DEFAULT 0, + `id_agent` INT UNSIGNED NOT NULL, + `forced_agent` TINYINT NOT NULL DEFAULT 0, + `ip` VARCHAR(100) NOT NULL DEFAULT '', + `ip_dec` INT UNSIGNED NOT NULL, + `id_os` INT UNSIGNED NOT NULL, + `forced_os` TINYINT NOT NULL DEFAULT 0, + `hostname` TINYTEXT, + `forced_hostname` TINYINT NOT NULL DEFAULT 0, + `comments` TEXT, + `alive` TINYINT NOT NULL DEFAULT 0, + `managed` TINYINT NOT NULL DEFAULT 0, + `reserved` TINYINT NOT NULL DEFAULT 0, + `time_last_check` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `time_create` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `users_operator` TEXT, + `time_last_edit` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', + `enabled` TINYINT NOT NULL DEFAULT 1, + `generate_events` TINYINT NOT NULL DEFAULT 0, + `leased` TINYINT DEFAULT 0, + `leased_expiration` BIGINT DEFAULT 0, + `mac_address` VARCHAR(20) DEFAULT NULL, + `leased_mode` TINYINT DEFAULT 0, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_network`) REFERENCES tipam_network(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tipam_vlan` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tipam_vlan` ( - `id` bigint(20) unsigned NOT NULL auto_increment, - `name` varchar(250) NOT NULL, - `description` text, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(250) NOT NULL, + `description` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tipam_vlan_network` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tipam_vlan_network` ( - `id` bigint(20) unsigned NOT NULL auto_increment, - `id_vlan` bigint(20) unsigned NOT NULL, - `id_network` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_vlan`) REFERENCES tipam_vlan(`id`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_network`) REFERENCES tipam_network(`id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_vlan` BIGINT UNSIGNED NOT NULL, + `id_network` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_vlan`) REFERENCES `tipam_vlan`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_network`) REFERENCES `tipam_network`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tipam_supernet` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tipam_supernet` ( - `id` bigint(20) unsigned NOT NULL auto_increment, - `name` varchar(250) NOT NULL, - `description` text default '', - `address` varchar(250) NOT NULL, - `mask` varchar(250) NOT NULL, - `subneting_mask` varchar(250) default '', - `id_site` bigint unsigned, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(250) NOT NULL, + `description` TEXT , + `address` VARCHAR(250) NOT NULL, + `mask` VARCHAR(250) NOT NULL, + `subneting_mask` VARCHAR(250) DEFAULT '', + `id_site` BIGINT UNSIGNED, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tipam_supernet_network` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tipam_supernet_network` ( - `id` bigint(20) unsigned NOT NULL auto_increment, - `id_supernet` bigint(20) unsigned NOT NULL, - `id_network` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_supernet`) REFERENCES tipam_supernet(`id`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_network`) REFERENCES tipam_network(`id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `id_supernet` BIGINT UNSIGNED NOT NULL, + `id_network` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_supernet`) REFERENCES `tipam_supernet`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_network`) REFERENCES `tipam_network`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tsync_queue` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tsync_queue` ( - `id` serial, - `sql` MEDIUMTEXT, - `target` bigint(20) unsigned NOT NULL, - `utimestamp` bigint(20) default '0', - `operation` text, - `table` text, - `error` MEDIUMTEXT, - `result` TEXT, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `sql` MEDIUMTEXT, + `target` BIGINT UNSIGNED NOT NULL, + `utimestamp` BIGINT DEFAULT 0, + `operation` TEXT, + `table` TEXT, + `error` MEDIUMTEXT, + `result` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_vendor` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_vendor` ( - `id` serial, - `name` varchar(255) UNIQUE, - `icon` varchar(255) DEFAULT '', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `name` VARCHAR(255) UNIQUE, + `icon` VARCHAR(255) DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_model` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_model` ( - `id` serial, - `id_vendor` bigint(20) unsigned NOT NULL, - `name` varchar(255) UNIQUE, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_vendor`) REFERENCES `tncm_vendor`(`id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `id_vendor` BIGINT UNSIGNED NOT NULL, + `name` VARCHAR(255) UNIQUE, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_vendor`) REFERENCES `tncm_vendor`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_template` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_template` ( - `id` serial, - `name` text, - `vendors` text, - `models` text, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `name` TEXT, + `vendors` TEXT, + `models` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_script` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_script` ( - `id` serial, - `type` int unsigned not null default 0, - `content` text, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `type` INT UNSIGNED NOT NULL DEFAULT 0, + `content` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_template_scripts` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_template_scripts` ( - `id` serial, - `id_template` bigint(20) unsigned NOT NULL, - `id_script` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `id_template` BIGINT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_agent` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_agent` ( - `id_agent` int(10) unsigned NOT NULL, - `id_vendor` bigint(20) unsigned, - `id_model` bigint(20) unsigned, - `protocol` int unsigned not null default 0, - `cred_key` varchar(100), - `adv_key` varchar(100), - `port` int(4) unsigned default 22, - `status` int(4) NOT NULL default 5, - `updated_at` bigint(20) NOT NULL default 0, - `config_backup_id` bigint(20) UNSIGNED DEFAULT NULL, - `id_template` bigint(20) unsigned, - `execute_type` int(2) UNSIGNED NOT NULL default 0, - `execute` int(2) UNSIGNED NOT NULL default 0, - `cron_interval` varchar(100) default '', - `event_on_change` int unsigned default null, - `last_error` text, - PRIMARY KEY (`id_agent`), - FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL, - FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_vendor`) REFERENCES `tncm_vendor`(`id`) ON UPDATE CASCADE ON DELETE SET NULL, - FOREIGN KEY (`id_model`) REFERENCES `tncm_model`(`id`) ON UPDATE CASCADE ON DELETE SET NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id_agent` INT UNSIGNED NOT NULL, + `id_vendor` BIGINT UNSIGNED, + `id_model` BIGINT UNSIGNED, + `protocol` INT UNSIGNED NOT NULL DEFAULT 0, + `cred_key` VARCHAR(100), + `adv_key` VARCHAR(100), + `port` INT UNSIGNED DEFAULT 22, + `status` INT NOT NULL DEFAULT 5, + `updated_at` BIGINT NOT NULL DEFAULT 0, + `config_backup_id` BIGINT UNSIGNED DEFAULT NULL, + `id_template` BIGINT UNSIGNED, + `execute_type` INT UNSIGNED NOT NULL DEFAULT 0, + `execute` INT UNSIGNED NOT NULL DEFAULT 0, + `cron_interval` VARCHAR(100) DEFAULT '', + `event_on_change` INT UNSIGNED DEFAULT null, + `last_error` TEXT, + PRIMARY KEY (`id_agent`), + FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_vendor`) REFERENCES `tncm_vendor`(`id`) ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_model`) REFERENCES `tncm_model`(`id`) ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_agent_data` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_agent_data` ( - `id` serial, - `id_agent` int(10) unsigned NOT NULL, - `script_type` int unsigned not null, - `data` LONGBLOB, - `status` int(4) NOT NULL default 5, - `updated_at` bigint(20) NOT NULL default 0, - FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `id_agent` INT UNSIGNED NOT NULL, + `script_type` INT UNSIGNED NOT NULL, + `data` LONGBLOB, + `status` INT NOT NULL DEFAULT 5, + `updated_at` BIGINT NOT NULL DEFAULT 0, + FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_queue` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_queue` ( - `id` SERIAL, - `id_agent` INT(10) UNSIGNED NOT NULL, - `id_script` BIGINT(20) UNSIGNED NOT NULL, - `utimestamp` INT UNSIGNED NOT NULL, - `scheduled` INT UNSIGNED DEFAULT NULL, - FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `id_agent` INT UNSIGNED NOT NULL, + `id_script` BIGINT UNSIGNED NOT NULL, + `utimestamp` INT UNSIGNED NOT NULL, + `scheduled` INT UNSIGNED DEFAULT NULL, + FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_snippet` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_snippet` ( - `id` SERIAL, - `name` TEXT, - `content` TEXT, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `name` TEXT, + `content` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; -- ---------------------------------------------------------------------- -- Table `tncm_firmware` -- ---------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tncm_firmware` ( - `id` SERIAL, - `name` varchar(255), - `shortname` varchar(255) unique, - `vendor` bigint(20) unsigned, - `models` text, - `path` text, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `id` SERIAL, + `name` VARCHAR(255), + `shortname` VARCHAR(255) unique, + `vendor` BIGINT UNSIGNED, + `models` TEXT, + `path` TEXT, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 95e9b98dc6..a59e5d6912 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 51), +('MR', 52), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package', 759), +('current_package', 760), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.00097656250000":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'), ('custom_docs_logo', 'default_docs.png'), ('custom_support_logo', 'default_support.png'), @@ -1145,13 +1145,14 @@ INSERT INTO `talert_actions` (`id`, `name`, `id_alert_command`, `field1`, `field (3,'Monitoring Event',3,'_agent_ _module_ generated an event alert (_data_)','alert_fired','pandora','','4','','','','','',0,0,'RECOVERED: _agent_ _module_ generated event alert (_data_)','alert_ceased','pandora','','4','','','','',''); -- alert templates (default) +INSERT INTO `talert_templates` (`id`,`name`,`description`,`id_alert_action`,`field1`,`field2`,`field3`,`field4`,`field5`,`field6`,`field7`,`field8`,`field9`,`field10`,`field11`,`field12`,`field13`,`field14`,`field15`,`field16`,`field17`,`field18`,`field19`,`field20`,`type`,`value`,`matches_value`,`max_value`,`min_value`,`time_threshold`,`max_alerts`,`min_alerts`,`time_from`,`time_to`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`,`sunday`,`recovery_notify`,`field1_recovery`,`field2_recovery`,`field3_recovery`,`field4_recovery`,`field5_recovery`,`field6_recovery`,`field7_recovery`,`field8_recovery`,`field9_recovery`,`field10_recovery`,`field11_recovery`,`field12_recovery`,`field13_recovery`,`field14_recovery`,`field15_recovery`,`field16_recovery`,`field17_recovery`,`field18_recovery`,`field19_recovery`,`field20_recovery`,`priority`,`id_group`,`special_day`,`wizard_level`,`min_alerts_reset_counter`,`disable_event`,`previous_name`, `schedule`) +VALUES (1,'Critical condition','This is a generic alert template to fire on condition CRITICAL',1,'','','<style type="text/css"> /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } </style> <style type="text/css" media="screen"> @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } </style> <style type="text/css" media="only screen and (max-width: 600px)"> /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } </style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>bad news</strong> for you. Something is on <strong>CRITICAL</strong> status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_roja.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','','','','','','','','','','','','critical','',1,0.00,0.00,86400,1,0,'00:00:00','00:00:00',1,1,1,1,1,1,1,1,'','[PANDORA] Alert RECOVERED for CRITICAL status on _agent_ / _module_','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','','','','','','','','','','','',4,0,0,'basic',0,0,NULL,'{\"monday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"tuesday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"wednesday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"thursday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"friday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"saturday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"sunday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}]}'); -INSERT INTO `talert_templates` (`id`, `name`, `description`, `id_alert_action`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `type`, `value`, `matches_value`, `max_value`, `min_value`, `time_threshold`, `max_alerts`, `min_alerts`, `time_from`, `time_to`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday`, `recovery_notify`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`, `priority`, `id_group`, `special_day`, `wizard_level`) -VALUES (1,'Critical condition','This is a generic alert template to fire on condition CRITICAL',1,'','','<style type="text/css"> /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } </style> <style type="text/css" media="screen"> @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } </style> <style type="text/css" media="only screen and (max-width: 600px)"> /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } </style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>bad news</strong> for you. Something is on <strong>CRITICAL</strong> status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_roja.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','','critical','',1,0.00,0.00,86400,1,0,'12:00:00','12:00:00',1,1,1,1,1,1,1,1,'','[PANDORA] Alert RECOVERED for CRITICAL status on _agent_ / _module_','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','',4,0,0,'basic'); -INSERT INTO `talert_templates` (`id`, `name`, `description`, `id_alert_action`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `type`, `value`, `matches_value`, `max_value`, `min_value`, `time_threshold`, `max_alerts`, `min_alerts`, `time_from`, `time_to`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday`, `recovery_notify`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`, `priority`, `id_group`, `special_day`, `wizard_level`) -VALUES (2,'Manual alert','This is a template used to fire manual alerts, condition defined here never will be executed. Use this template to assign to your actions/commands used to do remote management (Agent restart, execute commands on server, etc).',NULL,'','','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','','max_min','',1,0.00,1.00,86400,1,0,'12:00:00','12:00:00',1,1,1,1,1,1,1,0,'','','','','','','','','','',1,0,0,'basic'); -INSERT INTO `talert_templates` (`id`, `name`, `description`, `id_alert_action`, `field1`, `field2`, `field3`, `field4`, `field5`, `field6`, `field7`, `field8`, `field9`, `field10`, `type`, `value`, `matches_value`, `max_value`, `min_value`, `time_threshold`, `max_alerts`, `min_alerts`, `time_from`, `time_to`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday`, `recovery_notify`, `field1_recovery`, `field2_recovery`, `field3_recovery`, `field4_recovery`, `field5_recovery`, `field6_recovery`, `field7_recovery`, `field8_recovery`, `field9_recovery`, `field10_recovery`, `priority`, `id_group`, `special_day`, `wizard_level`) -VALUES (3,'Warning condition','This is a generic alert template to fire on WARNING condition.',1,'','','<style type="text/css"> /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } </style> <style type="text/css" media="screen"> @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } </style> <style type="text/css" media="only screen and (max-width: 600px)"> /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } </style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>bad news</strong> for you. Something is on <strong>CRITICAL</strong> status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_roja.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','','warning','',1,0.00,0.00,86400,1,0,'12:00:00','12:00:00',1,1,1,1,1,1,1,1,'','[PANDORA] Alert RECOVERED for WARNING status on _agent_ / _module_','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','',3,0,0,'basic'); +INSERT INTO `talert_templates` (`id`,`name`,`description`,`id_alert_action`,`field1`,`field2`,`field3`,`field4`,`field5`,`field6`,`field7`,`field8`,`field9`,`field10`,`field11`,`field12`,`field13`,`field14`,`field15`,`field16`,`field17`,`field18`,`field19`,`field20`,`type`,`value`,`matches_value`,`max_value`,`min_value`,`time_threshold`,`max_alerts`,`min_alerts`,`time_from`,`time_to`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`,`sunday`,`recovery_notify`,`field1_recovery`,`field2_recovery`,`field3_recovery`,`field4_recovery`,`field5_recovery`,`field6_recovery`,`field7_recovery`,`field8_recovery`,`field9_recovery`,`field10_recovery`,`field11_recovery`,`field12_recovery`,`field13_recovery`,`field14_recovery`,`field15_recovery`,`field16_recovery`,`field17_recovery`,`field18_recovery`,`field19_recovery`,`field20_recovery`,`priority`,`id_group`,`special_day`,`wizard_level`,`min_alerts_reset_counter`,`disable_event`,`previous_name`, `schedule`) +VALUES (2,'Manual alert','This is a template used to fire manual alerts, condition defined here never will be executed. Use this template to assign to your actions/commands used to do remote management (Agent restart, execute commands on server, etc).',NULL,'','','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','','','','','','','','','','','','max_min','',1,0.00,1.00,86400,1,0,'00:00:00','00:00:00',1,1,1,1,1,1,1,0,'','','','','','','','','','','','','','','','','','','','',1,0,0,'basic',0,0,NULL,'{\"monday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"tuesday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"wednesday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"thursday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"friday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"saturday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"sunday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}]}'); + +INSERT INTO `talert_templates` (`id`,`name`,`description`,`id_alert_action`,`field1`,`field2`,`field3`,`field4`,`field5`,`field6`,`field7`,`field8`,`field9`,`field10`,`field11`,`field12`,`field13`,`field14`,`field15`,`field16`,`field17`,`field18`,`field19`,`field20`,`type`,`value`,`matches_value`,`max_value`,`min_value`,`time_threshold`,`max_alerts`,`min_alerts`,`time_from`,`time_to`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`,`sunday`,`recovery_notify`,`field1_recovery`,`field2_recovery`,`field3_recovery`,`field4_recovery`,`field5_recovery`,`field6_recovery`,`field7_recovery`,`field8_recovery`,`field9_recovery`,`field10_recovery`,`field11_recovery`,`field12_recovery`,`field13_recovery`,`field14_recovery`,`field15_recovery`,`field16_recovery`,`field17_recovery`,`field18_recovery`,`field19_recovery`,`field20_recovery`,`priority`,`id_group`,`special_day`,`wizard_level`,`min_alerts_reset_counter`,`disable_event`,`previous_name`, `schedule`) +VALUES (3,'Warning condition','This is a generic alert template to fire on WARNING condition.',1,'','','<style type="text/css"> /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } </style> <style type="text/css" media="screen"> @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } </style> <style type="text/css" media="only screen and (max-width: 600px)"> /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } </style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>bad news</strong> for you. Something is on <strong>CRITICAL</strong> status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_roja.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','','','','','','','','','','','','warning','',1,0.00,0.00,86400,1,0,'00:00:00','00:00:00',1,1,1,1,1,1,1,1,'','[PANDORA] Alert RECOVERED for WARNING status on _agent_ / _module_','<style type="text/css"><!-- /* Take care of image borders and formatting */ img { max-width: 600px; outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; } a { border: 0; outline: none; } a img { border: none; } /* General styling */ td, h1, h2, h3 { font-family: Helvetica, Arial, sans-serif; font-weight: 400; } td { font-size: 14px; line-height: 150%; text-align: left; } body { -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:none; width: 100%; height: 100%; color: #37302d; background: #ffffff; } table { border-collapse: collapse !important; } h1, h2, h3 { padding: 0; margin: 0; color: #444444; font-weight: 400; line-height: 110%; } h1 { font-size: 35px; } h2 { font-size: 30px; } h3 { font-size: 24px; } h4 { font-size: 18px; font-weight: normal; } .important-font { color: #21BEB4; font-weight: bold; } .hide { display: none !important; } .force-full-width { width: 100% !important; } --></style> <style type="text/css" media="screen"><!-- @media screen { @import url(http://fonts.googleapis.com/css?family=Open+Sans:400); /* Thanks Outlook 2013! */ td, h1, h2, h3 { font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif !important; } } --></style> <style type="text/css" media="only screen and (max-width: 600px)"><!-- /* Mobile styles */ @media only screen and (max-width: 600px) { table[class="w320"] { width: 320px !important; } table[class="w300"] { width: 300px !important; } table[class="w290"] { width: 290px !important; } td[class="w320"] { width: 320px !important; } td[class~="mobile-padding"] { padding-left: 14px !important; padding-right: 14px !important; } td[class*="mobile-padding-left"] { padding-left: 14px !important; } td[class*="mobile-padding-right"] { padding-right: 14px !important; } td[class*="mobile-block"] { display: block !important; width: 100% !important; text-align: left !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 15px !important; } td[class*="mobile-no-padding-bottom"] { padding-bottom: 0 !important; } td[class~="mobile-center"] { text-align: center !important; } table[class*="mobile-center-block"] { float: none !important; margin: 0 auto !important; } *[class*="mobile-hide"] { display: none !important; width: 0 !important; height: 0 !important; line-height: 0 !important; font-size: 0 !important; } td[class*="mobile-border"] { border: 0 !important; } } --></style> <table style="width: 100%;" cellspacing="0" cellpadding="0" align="center"> <tbody> <tr> <td align="center" valign="top" bgcolor="#ffffff" width="100%"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="background: #1f1f1f; height: 70px;" width="100%"><center> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-block mobile-no-padding-bottom mobile-center" style="background: #1f1f1f; padding: 10px 10px 10px 20px;" valign="top" width="270"><a style="text-decoration: none;" href="#"> <img src="https://pandorafms.com/images/logo_pandora_email.png" alt="Your Logo" width="200"> </a></td> <td class="mobile-block mobile-center" style="background: #1f1f1f; padding: 17px 15px 10px 10px;" valign="top" width="270">&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="border-bottom: 1px solid #e7e7e7;"><center style="padding-bottom: 20px;"> <table class="w320" style="width: 600px;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" align="left"><br class="mobile-hide"> <h2>Pandora FMS alert system</h2> <br> Dear customer,<br><br> We have <strong>good news</strong> for you. Alert has been <strong>RECOVERED</strong>&nbsp;status!<br> <br> <table style="width: 100%;" cellspacing="0" cellpadding="0" bgcolor="#ffffff"> <tbody> <tr> <td style="width: 100px; background: #D84A38;"> <div><!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="#" style="height:33px;v-text-anchor:middle;width:100px;" stroke="f" fillcolor="#D84A38"> <w:anchorlock/> <center> <![endif]--> <a style="background-color: #1f1f1f; color: whitesmoke; display: inline-block; font-family: sans-serif; font-size: 13px; font-weight: bold; line-height: 33px; text-align: center; text-decoration: none; width: 250px; -webkit-text-size-adjust: none;" href="_homeurl_">Go to Pandora FMS Console</a> <!--[if mso]> </center> </v:rect> <![endif]--></div> </td> <td style="background-color: #ffffff; font-size: 0; line-height: 0;" width="281">&nbsp;</td> </tr> </tbody> </table> </td> <td class="mobile-hide" style="padding-top: 20px; padding-bottom: 0; vertical-align: bottom;" valign="bottom"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-bottom: 0px; vertical-align: bottom;" align="right" valign="bottom"><img style="vertical-align: bottom; padding-bottom: 10px;" src="https://pandorafms.com/images/alerta_verde.png" alt="" width="130"></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #f8f8f8; border-bottom: 1px solid #e7e7e7; padding-top: 10px;" valign="top"><center> <table class="w320" style="height: 100%; width: 600px;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="mobile-padding" style="padding: 20px;" valign="top"> <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-right: 20px;" colspan="2"><strong>Monitoring details</strong></td> </tr> <tr> <td style="padding-top: 25px; width: 150px; border-top: 1px solid #E7E7E7; vertical-align: top;"><strong>Data</strong></td> <td style="padding-top: 25px; padding-right: 20px; border-top: 1px solid #E7E7E7; vertical-align: top;">_data_ <em>(_modulestatus_)</em></td> </tr> <tr> <td><strong>Agent</strong></td> <td>_agent_ <em>_address_</em></td> </tr> <tr> <td><strong>Module</strong></td> <td>_module_ <em>_moduledescription_ </em></td> </tr> <tr> <td><strong>Timestamp</strong></td> <td>_timestamp_</td> </tr> </tbody> </table> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="padding-top: 20px;"> <table style="width: 100%;" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="vertical-align: top;" width="350">This is a graph of latest 24hr data for this module: <br><br> _modulegraph_24h_</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center></td> </tr> <tr> <td style="background-color: #1f1f1f;"><center> <table class="w320" style="height: 100%; color: #ffffff; width: 600px;" border="0" cellspacing="0" cellpadding="0" bgcolor="#1f1f1f"> <tbody> <tr> <td class="mobile-padding" style="font-size: 12px; padding: 20px; background-color: #1f1f1f; color: #ffffff; text-align: center;" align="right" valign="middle"><a style="color: #ffffff;" href="https://pandorafms.com/company/contact/">Contact Us</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://forums.pandorafms.com/">Support</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a style="color: #ffffff;" href="https://pandorafms.com/manual/">Docs</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td> </tr> </tbody> </table> </center></td> </tr> </tbody> </table> </td> </tr> </tbody> </table>','','','','','','','','','','','','','','','','','',3,0,0,'basic',0,0,NULL,'{\"monday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"tuesday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"wednesday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"thursday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"friday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"saturday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}],\"sunday\":[{\"start\":\"00:00:00\",\"end\":\"00:00:00\"}]}'); -- treport_custom_sql Data INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (1, 'Monitoring Report Agent', 'select direccion, alias, comentarios, (select nombre from tgrupo where tgrupo.id_grupo = tagente.id_grupo) as `group` from tagente;'); diff --git a/pandora_plugins/intel_dcm/extensions/intel_dcm_setup.php b/pandora_plugins/intel_dcm/extensions/intel_dcm_setup.php index d446365ace..cd820dd587 100644 --- a/pandora_plugins/intel_dcm/extensions/intel_dcm_setup.php +++ b/pandora_plugins/intel_dcm/extensions/intel_dcm_setup.php @@ -62,7 +62,7 @@ function main_intel_dcm() ) ) { db_pandora_audit( - 'ACL Violation', + AUDIT_LOG_ACL_VIOLATION, 'Trying to access Setup Management' ); include 'general/noaccess.php'; diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index fcfe4472c7..673dbbb536 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.759-220202 +Version: 7.0NG.760-220218 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index b5eabdbbb2..646d4a913a 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.759-220202" +pandora_version="7.0NG.760-220218" package_cpan=0 package_pandora=1 diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 7dc311915c..4c51a9a166 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -1,7 +1,7 @@ ############################################################################# # Pandora FMS Server Parameters # Pandora FMS, the Flexible Monitoring System. -# Version 7.0NG.759 +# Version 7.0NG.760 # Licensed under GPL license v2, # (c) 2003-2021 Artica Soluciones Tecnologicas # http://www.pandorafms.com @@ -662,8 +662,8 @@ wuxserver 0 # Force closing previous sessions on remote wux_host, only for Selenium Grid server 3. #clean_wux_sessions 1 -# Enable (1) or disable (0) the Pandora FMS Syslog Server (PANDORA FMS ENTERPRISE ONLY). -syslogserver 1 +# Enable (1) or disable (0) the Pandora FMS Syslog Server (PANDORA FMS ENTERPRISE ONLY) disabled by default. +syslogserver 0 # Full path to syslog's output file (PANDORA FMS ENTERPRISE ONLY). syslog_file /var/log/messages diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 607f0a1e20..e6f4c3265f 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,8 +45,8 @@ our @EXPORT = qw( ); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.759"; -my $pandora_build = "220202"; +my $pandora_version = "7.0NG.760"; +my $pandora_build = "220218"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 3136055549..289a246b30 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -550,16 +550,32 @@ sub pandora_evaluate_alert ($$$$$$$;$$$$) { else { return $status if ($alert->{$DayNames[$wday]} != 1); } - - # Check time slot + + my $schedule = PandoraFMS::Tools::p_decode_json($pa_config, $alert->{'schedule'}); + + return $status unless defined($schedule) && ref $schedule eq "HASH"; + + return $status unless defined($schedule->{$DayNames[$wday]}); + + return $status unless ref($schedule->{$DayNames[$wday]}) eq "ARRAY"; + my $time = sprintf ("%.2d:%.2d:%.2d", $hour, $min, $sec); - if (($alert->{'time_from'} ne $alert->{'time_to'})) { - if ($alert->{'time_from'} lt $alert->{'time_to'}) { - return $status if (($time le $alert->{'time_from'}) || ($time ge $alert->{'time_to'})); - } else { - return $status if (($time le $alert->{'time_from'}) && ($time ge $alert->{'time_to'})); + + # + # Check time slots + # + my $inSlot = 0; + foreach my $timeBlock (@{$schedule->{$DayNames[$wday]}}) { + if ($timeBlock->{'start'} eq $timeBlock->{'end'}) { + # All day. + $inSlot = 1; + } elsif ($timeBlock->{'start'} le $time && $timeBlock->{'end'} ge $time) { + # In range. + $inSlot = 1; } } + + return $status if $inSlot eq 0; # Check time threshold my $limit_utimestamp = $alert->{'last_reference'} + $alert->{'time_threshold'}; @@ -1413,7 +1429,7 @@ sub pandora_execute_action ($$$$$$$$$;$$) { my $return_code = ($? >> 8) & 0xff; logger($pa_config, "Command '$command_timeout' for action '" . safe_output($action->{'name'}) . "' alert '". safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'alias'}) : 'N/A') . "' returned with errorlevel " . $return_code, 8); if ($return_code != 0) { - logger ($pa_config, "Action '" . safe_output($action->{'name'}) . "' alert '" . safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'alias'}) : 'N/A') . "' exceeded the global alert timeout " . $pa_config->{'global_alert_timeout'} . " seconds" , 8); + logger ($pa_config, "Action '" . safe_output($action->{'name'}) . "' alert '" . safe_output($alert->{'name'}) . "' agent '" . (defined ($agent) ? safe_output($agent->{'alias'}) : 'N/A') . "' exceeded the global alert timeout " . $pa_config->{'global_alert_timeout'} . " seconds" , 3); } } }; diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm index 2595cdcaea..55e52ac1e8 100644 --- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm +++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm @@ -190,6 +190,8 @@ sub data_consumer ($$) { } eval { + local $SIG{__DIE__}; + my @subnets = split(/,/, safe_output($task->{'subnet'})); my @communities = split(/,/, safe_output($task->{'snmp_community'})); my @auth_strings = (); diff --git a/pandora_server/lib/PandoraFMS/PluginServer.pm b/pandora_server/lib/PandoraFMS/PluginServer.pm index 72312961aa..ba7a14f95f 100644 --- a/pandora_server/lib/PandoraFMS/PluginServer.pm +++ b/pandora_server/lib/PandoraFMS/PluginServer.pm @@ -297,7 +297,7 @@ sub data_consumer ($$) { elsif ($ReturnCode == 2){ $module_data = 0; } - elsif ($ReturnCode == 3 || $ReturnCode == 124){ + elsif ($ReturnCode == 3 || $ReturnCode == 124 || $ReturnCode == 137){ # 124 should be a exit code of the timeout command (command times out) $module_data = ''; # not defined = Uknown } @@ -305,7 +305,15 @@ sub data_consumer ($$) { $module_data = 1; } } + } else { + # Timeout. + if ($ReturnCode == 124 || $ReturnCode == 137) { + logger($pa_config, "Plug-in module " . $module->{'nombre'} . " for agent " . $agent->{'nombre'} . " timed out.", 3); + pandora_update_module_on_error ($pa_config, $module, $dbh); + return; + } } + if (! defined $module_data || $module_data eq '') { logger ( $pa_config, diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index eb071b0421..3bd57b8194 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -33,8 +33,8 @@ use base 'Exporter'; our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only -my $pandora_version = "7.0NG.759"; -my $pandora_build = "220202"; +my $pandora_version = "7.0NG.760"; +my $pandora_build = "220218"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index b832a7e51c..d6b1453c1c 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -2,8 +2,8 @@ # Pandora FMS Server # %define name pandorafms_server -%define version 7.0NG.759 -%define release 220202 +%define version 7.0NG.760 +%define release 220218 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index f31e34d589..6e3f0c415f 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -2,8 +2,8 @@ # Pandora FMS Server # %define name pandorafms_server -%define version 7.0NG.759 -%define release 220202 +%define version 7.0NG.760 +%define release 220218 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index e5116ee74c..454cbbbb41 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -8,8 +8,8 @@ # This code is licensed under GPL 2.0 license. # ********************************************************************** -PI_VERSION="7.0NG.759" -PI_BUILD="220202" +PI_VERSION="7.0NG.760" +PI_BUILD="220218" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index f342b2738c..597169ea7b 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.759 Build 220202"; +my $version = "7.0NG.760 Build 220218"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 29eda42575..9ad847edae 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.759 Build 220202"; +my $version = "7.0NG.760 Build 220218"; # save program name for logging my $progname = basename($0);