2012-04-12 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* include/javascript/jquery.pandora.js
	 extensions/update_manager.php
	 extensions/update_manager/settings.php: Added modal window with UM
	 license info.
	
	* extensions/update_license_info.php: Added extension with UM 
	license info.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5960 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2012-04-12 14:43:26 +00:00
parent ccdf37d90e
commit c88ead7e99
5 changed files with 292 additions and 0 deletions

View File

@ -1,3 +1,13 @@
2012-04-12 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/javascript/jquery.pandora.js
extensions/update_manager.php
extensions/update_manager/settings.php: Added modal window with UM
license info.
* extensions/update_license_info.php: Added extension with UM
license info.
2012-04-12 Miguel de Dios <miguel.dedios@artica.es>
* include/styles/pandora.css: add changes for the new standarized messages.

View File

@ -0,0 +1,128 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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; 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.
if (! check_acl ($config['id_user'], 0, 'PM')) {
db_pandora_audit("ACL Violation", "Trying to use Open Update Manager extension");
include ("general/noaccess.php");
return;
}
function update_manage_license_info_main() {
update_manage_license_info();
}
function update_manage_license_info(){
ui_print_page_header (__('Update manager').' - '. __('License info'), "images/extensions.png", false, "", true, "" );
global $config;
include_once("include/functions_db.php");
// Return the order of the given char in ("A".."Z", 0-9)
function license_char_ord ($char) {
$ascii_ord = ord ($char);
if ($ascii_ord >= ord ('A') && $ascii_ord <= ord ('Z')) {
return $ascii_ord - ord ('A');
}
if ($ascii_ord >= ord ('0') && $ascii_ord <= ord ('9')) {
return sizeof (range ('A','Z')) + $ascii_ord - ord ('0');
}
return -1;
}
// Un-shift a string given a key: string[i] = shifted_string[i] - key[i] mod |Alphabet|
$Alphabet = array_merge (range ('A','Z'), range('0', '9'));
$AlphabetSize = sizeof ($Alphabet);
function license_unshift_string ($string, $key) {
global $Alphabet;
global $AlphabetSize;
// Get the minimum length
$string_length = strlen ($string);
$key_length = strlen ($key);
if ($string_length < $key_length) {
$min_length = $string_length;
} else {
$min_length = $key_length;
}
// Shift the string
$unshifted_string = '';
for ($i = 0; $i < $min_length; $i++) {
$unshifted_string .= $Alphabet[($AlphabetSize + license_char_ord ($string[$i]) - license_char_ord ($key[$i])) % $AlphabetSize];
}
return $unshifted_string;
}
function show_check_pandora_license ($license) {
if (strlen ($license) != 32) {
return array ("Invalid license!", '', '', '', '', '', '');
}
$company_name = trim (substr ($license, 0, 4), "0");
$random_string = substr ($license, 4, 8);
$max_agents = (int) license_unshift_string (substr ($license, 12, 6), $random_string);
$license_mode_string = license_unshift_string (substr ($license, 18, 6), $random_string);
$license_mode = (int) substr ($license_mode_string, 0, 1);
$expiry_date_string = license_unshift_string (substr ($license, 24, 8), $random_string);
$expiry_year = substr ($expiry_date_string, 0, 4);
$expiry_month = substr ($expiry_date_string, 4, 2);
$expiry_day = substr ($expiry_date_string, 6, 2);
return array ("Valid license.", $company_name, $max_agents, $expiry_day, $expiry_month, $expiry_year, $license_mode);
}
$license = db_get_value_sql ('SELECT value FROM tupdate_settings WHERE `key`="customer_key"');
if ($license === false) {
echo "<p>License not available</p>";
return;
}
$license_info = array();
$license_info = show_check_pandora_license($license);
$table->width = '98%';
$table->data = array ();
$table->data[0][0] = '<strong>'.__('Company').'</strong>';
$table->data[0][1] = $license_info[1];
$table->data[1][0] = '<strong>'.__('Expires').'</strong>';
$table->data[1][1] = $license_info[3] . ' / ' . $license_info[4] . ' / ' . $license_info[5];
$table->data[2][0] = '<strong>'.__('Platform Limit').'</strong>';
$table->data[2][1] = $license_info[2];
$table->data[3][0] = '<strong>'.__('Current Platform Count').'</strong>';
$count_agents = db_get_value_sql ('SELECT count(*) FROM tagente');
$table->data[3][1] = $count_agents;
$table->data[4][0] = '<strong>'.__('License Mode').'</strong>';
if ($license_info[6] == 1)
$license_mode_string = 'Client';
else
$license_mode_string = 'Trial';
$table->data[4][1] = $license_mode_string;
html_print_table ($table);
}
extensions_add_godmode_menu_option (__('Update manager license info'), 'PM');
extensions_add_godmode_function ('update_manage_license_info_main');

View File

@ -31,8 +31,132 @@ if (is_ajax ()) {
$checking_online_enterprise_package =
(bool)get_parameter('checking_online_enterprise_package', false);
$get_license_info = get_parameter('get_license_info', 0);
if ($checking_online_enterprise_package) {
checking_online_enterprise_package();
return;
}
if ($get_license_info) {
include_once("include/functions_db.php");
$Alphabet = array_merge (range ('A','Z'), range('0', '9'));
$AlphabetSize = sizeof ($Alphabet);
// Return the order of the given char in ('A'..'Z', 0-9)
function char_ord ($char) {
$ascii_ord = ord ($char);
if ($ascii_ord >= ord ('A') && $ascii_ord <= ord ('Z')) {
return $ascii_ord - ord ('A');
}
if ($ascii_ord >= ord ('0') && $ascii_ord <= ord ('9')) {
return sizeof (range ('A','Z')) + $ascii_ord - ord ('0');
}
return -1;
}
// Generate a random string of the given length
function random_string ($length) {
global $Alphabet, $AlphabetSize;
$random_string = '';
for ($i = 0; $i < $length; $i++) {
$random_string .= $Alphabet[rand (0, $AlphabetSize - 1)];
}
return $random_string;
}
// Shift a string given a key: shifted_string[i] = string[i] + key[i] mod |Alphabet|
function shift_string ($string, $key) {
global $Alphabet, $AlphabetSize;
// Get the minimum length
$string_length = strlen ($string);
$key_length = strlen ($key);
$min_length = $string_length < $key_length ? $string_length : $key_length;
// Shift the string
$shifted_string = '';
for ($i = 0; $i < $min_length; $i++) {
$shifted_string .= $Alphabet[(char_ord ($string[$i]) + char_ord ($key[$i])) % $AlphabetSize];
}
return $shifted_string;
}
// Un-shift a string given a key: string[i] = shifted_string[i] - key[i] mod |Alphabet|
function unshift_string ($string, $key) {
global $Alphabet, $AlphabetSize;
// Get the minimum length
$string_length = strlen ($string);
$key_length = strlen ($key);
$min_length = $string_length < $key_length ? $string_length : $key_length;
// Shift the string
$unshifted_string = '';
for ($i = 0; $i < $min_length; $i++) {
$unshifted_string .= $Alphabet[($AlphabetSize + char_ord ($string[$i]) - char_ord ($key[$i])) % $AlphabetSize];
}
return $unshifted_string;
}
function check_pandora_license ($license) {
if (strlen ($license) != 32) {
return array ("Invalid license!", '', '', '', '', '', '');
}
$company_name = trim (substr ($license, 0, 4), "0");
$random_string = substr ($license, 4, 8);
$max_agents = (int) unshift_string (substr ($license, 12, 6), $random_string);
$license_mode_string = unshift_string (substr ($license, 18, 6), $random_string);
$license_mode = (int) substr ($license_mode_string, 0, 1);
$expiry_date_string = unshift_string (substr ($license, 24, 8), $random_string);
$expiry_year = substr ($expiry_date_string, 0, 4);
$expiry_month = substr ($expiry_date_string, 4, 2);
$expiry_day = substr ($expiry_date_string, 6, 2);
return array ("Valid license.", $company_name, $max_agents, $expiry_day, $expiry_month, $expiry_year, $license_mode);
}
$license = db_get_value_sql ('SELECT value FROM tupdate_settings WHERE `key`="customer_key"');
if ($license === false) {
echo "<p>License not available</p>";
return;
}
$license_info = array();
$license_info = check_pandora_license($license);
$table->width = '98%';
$table->data = array ();
$table->data[0][0] = '<strong>'.__('Company').'</strong>';
$table->data[0][1] = $license_info[1];
$table->data[1][0] = '<strong>'.__('Expires').'</strong>';
$table->data[1][1] = $license_info[3] . ' / ' . $license_info[4] . ' / ' . $license_info[5];
$table->data[2][0] = '<strong>'.__('Platform Limit').'</strong>';
$table->data[2][1] = $license_info[2];
$table->data[3][0] = '<strong>'.__('Current Platform Count').'</strong>';
$count_agents = db_get_value_sql ('SELECT count(*) FROM tagente');
$table->data[3][1] = $count_agents;
$table->data[4][0] = '<strong>'.__('License Mode').'</strong>';
if ($license_info[6] == 1)
$license_mode_string = 'Client';
else
$license_mode_string = 'Trial';
$table->data[4][1] = $license_mode_string;
html_print_table ($table);
return;
}
return;

View File

@ -67,6 +67,8 @@ $table->data = array ();
$table->data[0][0] = '<strong>'.__('Customer key').'</strong>';
$table->data[0][1] = html_print_input_text ('keys[customer_key]', $settings->customer_key, '', 40, 255, true);
$table->data[0][1] .= '&nbsp;<a id="dialog_license_info" title="'.__("License Info").'" href="#">'.html_print_image('images/lock.png', true, array('class' => 'bot', 'title' => __('License info'))).'</a>';
$table->data[0][1] .= '<div id="dialog_show_license" style="display:none"></div>';
$table->data[1][0] = '<strong>'.__('Update server host').'</strong>';
$table->data[1][1] = html_print_input_text ('keys[update_server_host]', $settings->update_server_host, '', 20, 255, true);

View File

@ -106,6 +106,34 @@ $(document).ready (function () {
});
$("a#dialog_license_info").click (function () {
jQuery.get ("ajax.php",
{"page": "extensions/update_manager",
"get_license_info": "1"},
function (data, status) {
$("#dialog_show_license").hide ()
.empty ()
.append (data)
.dialog ({
title: $("a#dialog_license_info").attr ("title"),
resizable: false,
draggable: true,
modal: true,
overlay: {
opacity: 0.5,
background: "black"
},
bgiframe: jQuery.browser.msie,
width: 500,
height: 180
})
.show ();
},
"html"
);
return false;
});
}
);