2014-06-02 18:01:39 +02:00
< ? php
2019-05-22 18:50:51 +02:00
/**
* License form .
*
* @ category Form
* @ package Pandora FMS
* @ subpackage Enterprise
* @ version 1.0 . 0
* @ license See below
*
* ______ ___ _______ _______ ________
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
* Copyright ( c ) 2005 - 2019 Artica Soluciones Tecnologicas
* Please see http :// pandorafms . org for full contribution list
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* ============================================================================
*/
// File begin.
2014-06-02 18:01:39 +02:00
global $config ;
2019-01-30 16:18:44 +01:00
check_login ();
2014-06-02 18:01:39 +02:00
2019-01-30 16:18:44 +01:00
if ( ! check_acl ( $config [ 'id_user' ], 0 , 'PM' )) {
db_pandora_audit ( 'ACL Violation' , 'Trying to change License settings' );
include 'general/noaccess.php' ;
return ;
2014-06-02 18:01:39 +02:00
}
2019-01-30 16:18:44 +01:00
$update_settings = ( bool ) get_parameter_post ( 'update_settings' );
2014-06-02 18:01:39 +02:00
2019-05-22 18:50:51 +02:00
if ( is_metaconsole ()) {
// Metaconsole.
ui_require_javascript_file_enterprise ( 'load_enterprise' , true );
enterprise_include_once ( 'include/functions_license.php' );
} else {
ui_print_page_header (
__ ( 'License management' ),
'images/extensions.png' ,
false ,
'' ,
true
);
ui_require_javascript_file_enterprise ( 'load_enterprise' );
enterprise_include_once ( 'include/functions_license.php' );
}
2014-06-02 18:01:39 +02:00
if ( $update_settings ) {
2019-05-22 18:50:51 +02:00
if ( ! is_metaconsole ()) {
// Node.
foreach ( $_POST [ 'keys' ] as $key => $value ) {
db_process_sql_update (
'tupdate_settings' ,
[ db_escape_key_identifier ( 'value' ) => $value ],
[ db_escape_key_identifier ( 'key' ) => $key ]
);
}
ui_print_success_message ( __ ( 'License updated' ));
2019-01-30 16:18:44 +01:00
}
2014-06-02 18:01:39 +02:00
}
$license = enterprise_hook ( 'license_get_info' );
2014-06-13 14:14:34 +02:00
$rows = db_get_all_rows_in_table ( 'tupdate_settings' );
$settings = new StdClass ;
foreach ( $rows as $row ) {
2019-01-30 16:18:44 +01:00
$settings -> { $row [ 'key' ]} = $row [ 'value' ];
2014-06-13 14:14:34 +02:00
}
2014-06-02 18:01:39 +02:00
echo '<script type="text/javascript">' ;
2019-01-30 16:18:44 +01:00
if ( enterprise_installed ()) {
print_js_var_enteprise ();
}
2014-06-02 18:01:39 +02:00
echo '</script>' ;
echo '<form method="post">' ;
2019-05-22 18:50:51 +02:00
// Retrieve UM url configured (or default).
$url = get_um_url ();
2014-06-02 18:01:39 +02:00
2015-06-25 10:40:35 +02:00
$table = new stdClass ();
2015-06-16 16:09:50 +02:00
$table -> width = '100%' ;
$table -> class = 'databox filters' ;
2019-05-22 18:50:51 +02:00
if ( is_metaconsole ()) {
$table -> head [ 0 ] = __ ( 'Licence' );
$table -> head_colspan [ 0 ] = 3 ;
$table -> headstyle [ 0 ] = 'text-align: center' ;
$table -> style [ 0 ] = 'font-weight: bold;' ;
}
2019-01-30 16:18:44 +01:00
$table -> data = [];
2014-06-02 18:01:39 +02:00
$table -> data [ 0 ][ 0 ] = '<strong>' . __ ( 'Customer key' ) . '</strong>' ;
2019-01-30 16:18:44 +01:00
$table -> data [ 0 ][ 1 ] = html_print_textarea ( 'keys[customer_key]' , 10 , 255 , $settings -> customer_key , 'style="height:50px; width:450px;"' , true );
2014-06-02 18:01:39 +02:00
2019-09-18 13:35:11 +02:00
$table -> data [ 1 ][ 0 ] = '<strong>' . __ ( $license [ 'expiry_caption' ]) . '</strong>' ;
2014-06-02 18:01:39 +02:00
$table -> data [ 1 ][ 1 ] = html_print_input_text ( 'expires' , $license [ 'expiry_date' ], '' , 10 , 255 , true , true );
$table -> data [ 2 ][ 0 ] = '<strong>' . __ ( 'Platform Limit' ) . '</strong>' ;
2019-01-30 16:18:44 +01:00
$table -> data [ 2 ][ 1 ] = html_print_input_text ( 'expires' , $license [ 'limit' ], '' , 10 , 255 , true , true ) . ' ' . ( $license [ 'limit_mode' ] == 0 ? __ ( 'agents' ) : __ ( 'modules' ));
2014-06-02 18:01:39 +02:00
$table -> data [ 3 ][ 0 ] = '<strong>' . __ ( 'Current Platform Count' ) . '</strong>' ;
2019-01-30 16:18:44 +01:00
$table -> data [ 3 ][ 1 ] = html_print_input_text ( 'expires' , $license [ 'count' ], '' , 10 , 255 , true , true ) . ' ' . ( $license [ 'limit_mode' ] == 0 ? __ ( 'agents' ) : __ ( 'modules' ));
2014-06-02 18:01:39 +02:00
2016-08-18 11:10:45 +02:00
$table -> data [ 4 ][ 0 ] = '<strong>' . __ ( 'Current Platform Count (enabled: items)' ) . '</strong>' ;
2019-01-30 16:18:44 +01:00
$table -> data [ 4 ][ 1 ] = html_print_input_text ( 'expires' , $license [ 'count_enabled' ], '' , 10 , 255 , true , true ) . ' ' . ( $license [ 'limit_mode' ] == 0 ? __ ( 'agents' ) : __ ( 'modules' ));
2014-06-02 18:01:39 +02:00
2016-08-18 11:10:45 +02:00
$table -> data [ 5 ][ 0 ] = '<strong>' . __ ( 'Current Platform Count (disabled: items)' ) . '</strong>' ;
2019-01-30 16:18:44 +01:00
$table -> data [ 5 ][ 1 ] = html_print_input_text ( 'expires' , $license [ 'count_disabled' ], '' , 10 , 255 , true , true ) . ' ' . ( $license [ 'limit_mode' ] == 0 ? __ ( 'agents' ) : __ ( 'modules' ));
2015-09-18 12:58:04 +02:00
2016-08-18 11:10:45 +02:00
$table -> data [ 6 ][ 0 ] = '<strong>' . __ ( 'License Mode' ) . '</strong>' ;
$table -> data [ 6 ][ 1 ] = html_print_input_text ( 'expires' , $license [ 'license_mode' ], '' , 10 , 255 , true , true );
$table -> data [ 7 ][ 0 ] = '<strong>' . __ ( 'NMS' ) . '</strong>' ;
$table -> data [ 7 ][ 1 ] = html_print_input_text ( 'expires' , ( $license [ 'nms' ] == 1 ? __ ( 'enabled' ) : __ ( 'disabled' )), '' , 10 , 255 , true , true );
$table -> data [ 8 ][ 0 ] = '<strong>' . __ ( 'Satellite' ) . '</strong>' ;
$table -> data [ 8 ][ 1 ] = html_print_input_text ( 'expires' , ( $license [ 'dhpm' ] == 1 ? __ ( 'enabled' ) : __ ( 'disabled' )), '' , 10 , 255 , true , true );
$table -> data [ 9 ][ 0 ] = '<strong>' . __ ( 'Licensed to' ) . '</strong>' ;
$table -> data [ 9 ][ 1 ] = html_print_input_text ( 'licensed_to' , $license [ 'licensed_to' ], '' , 64 , 255 , true , true );
2015-09-18 12:58:04 +02:00
2019-01-30 16:18:44 +01:00
html_print_table ( $table );
2019-06-18 11:35:59 +02:00
// If DESTDIR is defined the enterprise license is expired.
if ( enterprise_installed () || defined ( 'DESTDIR' )) {
2019-01-30 16:18:44 +01:00
echo '<div class="action-buttons" style="width: ' . $table -> width . '">' ;
html_print_input_hidden ( 'update_settings' , 1 );
html_print_submit_button ( __ ( 'Validate' ), 'update_button' , false , 'class="sub upd"' );
echo ' ' ;
2019-05-22 18:50:51 +02:00
html_print_button ( __ ( 'Request new license' ), '' , false , 'generate_request_code()' , 'class="sub next"' );
2019-01-30 16:18:44 +01:00
echo '</div>' ;
2014-07-07 12:32:45 +02:00
}
2019-01-30 16:18:44 +01:00
2019-05-22 18:50:51 +02:00
if ( is_metaconsole ()) {
ui_require_css_file ( 'pandora_enterprise' , '../../' . ENTERPRISE_DIR . '/include/styles/' );
ui_require_css_file ( 'register' , '../../include/styles/' );
} else {
ui_require_css_file ( 'pandora' );
ui_require_css_file ( 'pandora_enterprise' , ENTERPRISE_DIR . '/include/styles/' );
ui_require_css_file ( 'register' );
2019-05-16 12:00:49 +02:00
}
if ( enterprise_hook ( 'print_activate_licence_dialog' ) == ENTERPRISE_NOT_HOOK ) {
echo '</form>' ;
echo '<div id="code_license_dialog" style="display: none; text-align: left;" title="' . __ ( 'Request new license' ) . '">' ;
echo '<div id="logo">' ;
html_print_image ( ui_get_custom_header_logo ( true ));
echo '</div>' ;
echo '' . __ ( 'To get your <b>%s Enterprise License</b>:' , get_product_name ()) . '<br />' ;
echo '<ul>' ;
echo '<li>' ;
2019-05-22 18:50:51 +02:00
echo '' . sprintf ( __ ( 'Go to %s' ), '<a target="_blank" href="' . $url . '/index.php?section=generate_key_client">' . $url . 'index.php?section=generate_key_client</a>' );
2019-05-16 12:00:49 +02:00
echo '</li>' ;
echo '<li>' ;
echo '' . __ ( 'Enter the <b>auth key</b> and the following <b>request key</b>:' );
echo '</li>' ;
echo '</ul>' ;
echo '<div id="code"></div>' ;
echo '<ul>' ;
echo '<li>' ;
echo '' . __ ( 'Enter your name (or a company name) and a contact email address.' );
echo '</li>' ;
echo '<li>' ;
echo '' . __ ( 'Click on <b>Generate</b>.' );
echo '</li>' ;
echo '<li>' ;
echo '' . __ ( 'Click <a href="javascript: close_code_license_dialog();">here</a>, enter the generated license key and click on <b>Validate</b>.' );
echo '</li>' ;
echo '</ul>' ;
echo '</div>' ;
}