2012-04-02 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_html.php: added into function "html_debug_print" the
	equal output to log file, this is with more data.
	
	* include/functions_db.php: cleaned source code style.
	
	* extensions/update_pandora/functions.ajax.php,
	extensions/update_pandora/functions.php,
	extensions/update_manager/lib/libupdate_manager.php,
	extensions/update_pandora.php: added extension to update pandora from the
	targz of Sourceforge.
	
	Merged from the branch pandora_4.0



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5874 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-04-02 15:57:48 +00:00
parent 93acabc833
commit c3879f3c50
6 changed files with 845 additions and 15 deletions

View File

@ -1,3 +1,18 @@
2012-04-02 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php: added into function "html_debug_print" the
equal output to log file, this is with more data.
* include/functions_db.php: cleaned source code style.
* extensions/update_pandora/functions.ajax.php,
extensions/update_pandora/functions.php,
extensions/update_manager/lib/libupdate_manager.php,
extensions/update_pandora.php: added extension to update pandora from the
targz of Sourceforge.
Merged from the branch pandora_4.0
2012-04-02 Dario Rodriguez <dario.rodriguez@artica.es>
* operation/menu.php: Fixed an error selecting the correct menu option

View File

@ -0,0 +1,184 @@
<?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.
require_once('update_pandora/functions.php');
if (is_ajax ()) {
require_once('update_pandora/functions.ajax.php');
$get_packages_online = (bool) get_parameter('get_packages_online');
$download_package = (bool) get_parameter('download_package');
$check_download_package = (bool) get_parameter('check_download_package');
$install_package = (bool) get_parameter('install_package');
$check_install_package = (bool) get_parameter('check_install_package');
if ($get_packages_online)
update_pandora_get_packages_online_ajax();
if ($download_package)
update_pandora_download_package();
if ($check_download_package)
update_pandora_check_download_package();
if ($install_package)
update_pandora_install_package();
if ($check_install_package)
update_pandora_check_install_package();
return;
}
function update_pandora_operation() {
global $conf_update_pandora;
ui_print_page_header(__('Update Pandora'), "images/extensions.png");
if (!update_pandora_check_installation()) {
ui_print_error_message(__('First execution of Update Pandora or lost configuration.'));
update_pandora_installation();
}
$conf_update_pandora = update_pandora_get_conf();
if (empty($conf_update_pandora['last_installed'])) {
ui_print_error_message(__('Your Pandora FMS Console never have been update.'));
}
else {
$text = sprintf(__('The last package for Pandora FMS Console is %s'),
$conf_update_pandora['last_installed']);
ui_print_success_message($text);
}
echo "<h3>" . __('Downloaded Packages') . "</h3>";
$list_downloaded_packages = update_pandora_get_list_downloaded_packages('operation');
$table = null;
$table->width = '80%';
$table->head = array(__('Packages'));
$table->data = $list_downloaded_packages;
html_print_table($table);
echo "<h3>" . __('Online Packages') . "</h3>";
$table = null;
$table->id = 'online_packages';
$table->width = '80%';
$table->head = array(__('Packages'));
$table->rowclass[0] = 'spinner_row';
$table->data[0][0] = __('Get list online Packages') . html_print_image('images/spinner.gif', true);
html_print_table($table);
update_pandora_print_javascript();
}
function update_pandora_administration() {
global $conf_update_pandora;
ui_print_page_header(__('Update Pandora'), "images/extensions.png", false, "", true);
if (!update_pandora_check_installation()) {
ui_print_error_message(__('First execution of Update Pandora'));
update_pandora_installation();
}
$conf_update_pandora = update_pandora_get_conf();
echo "<h3>" . __('Downloaded Packages') . "</h3>";
$list_downloaded_packages = update_pandora_get_list_downloaded_packages('administration');
$table = null;
$table->width = '80%';
$table->size = array('80%', '50px');
$table->head = array(__('Packages'), __('Action'));
$table->align = array('left', 'center');
$table->data = array();
foreach ($list_downloaded_packages as $package) {
$actions = '';
if (!isset($package['empty'])) {
if (!$package['current']) {
$actions = '<a href="javascript: ajax_start_install_package(\'' . $package['name'] . '\');">' .
html_print_image('images/b_white.png', true, array('alt'=>
__('Install this version'), 'title' => __('Install this version'))) .
'</a>';
}
else {
$actions = '<a href="javascript: ajax_start_install_package(\'' . $package['name'] . '\');">' .
html_print_image('images/b_yellow.png', true, array('alt'=>
__('Reinstall this version'), 'title' => __('Reinstall this version'))) .
'</a>';
}
}
$table->data[] = array($package['name'], $actions);
}
html_print_table($table);
echo "<h3>" . __('Online Package') . "</h3>";
echo '<table id="online_packages" class="databox" width="80%" cellspacing="4" cellpadding="4" border="0" style="">';
echo '<thead><tr>
<th class="header c0" scope="col">' . __('Package') . '</th>
<th class="header c1" scope="col">' . __('Action') . '</th>
</tr></thead>';
echo '<tbody>
<tr id="online_packages-0" class="spinner_row" style="">
<td id="online_packages-0-0" style=" text-align:left; width:80%;">' .
__('Get list online Package') . " " . html_print_image('images/spinner.gif', true) .
'</td>
<td id="online_packages-0-1" style=" text-align:center; width:50px;"></td>
</tr>
</tbody>';
echo '</table>';
?>
<div id="dialog_download" title="<?php echo __('Process packge'); ?>"
style="display:none; -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)'; filter: alpha(opacity=50);">
<div style="position:absolute; top:20%; text-align: center; left:0%; right:0%; width:600px;">
<?php
echo '<h2 id="title_downloading_update_pandora">' . __('Downloading <span class="package_name">package</span> in progress') . " ";
html_print_image('images/spinner.gif');
echo '</h2>';
echo '<h2 style="display: none;" id="title_installing_update_pandora">' . __('Installing <span class="package_name">package</span> in progress') . " ";
html_print_image('images/spinner.gif');
echo '</h2>';
echo '<h2 style="display: none;" id="title_installed_update_pandora">' . __('Installed <span class="package_name">package</span> in progress') . '</h2>';
echo '<br /><br />';
echo "<div id='progress_bar_img'>";
echo progress_bar(0, 300, 20, 0 . '%', 1, false, "#00ff00");
echo "</div>";
echo "<div style='padding-top: 20px; display: none;' id='info_text'>
<b>Size:</b> 666/666 kbytes <b>Speed:</b> 666 bytes/second
</div>";
?>
<div id="button_close_download" style="display: none; position: absolute; top:280px; right:43%;">
<?php
html_print_submit_button(__("Close"), 'hide_download_dialog', false, 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only" style="width:100px;"');
?>
</div>
</div>
</div>
<?php
ui_require_css_file ('dialog');
ui_require_jquery_file ('ui.core');
ui_require_jquery_file ('ui.dialog');
update_pandora_print_javascript_admin();
}
extensions_add_godmode_function('update_pandora_administration');
extensions_add_godmode_menu_option (__('Pandora Update'), 'PM','gsetup');
extensions_add_main_function('update_pandora_operation');
extensions_add_operation_menu_option(__('Pandora Update'));
?>

View File

@ -0,0 +1,233 @@
<?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.
function update_pandora_get_packages_online_ajax() {
global $config;
$last = get_parameter('last', 0);
//TODO Make all code, at the moment I uknown the method to get list.
global $conf_update_pandora;
if (empty($conf_update_pandora))
$conf_update_pandora = update_pandora_get_conf();
$conf_update_pandora['last_contact'] = time();
update_pandora_update_conf();
$last++;
sleep(1);
$return = array('correct' => 0);
$return['last'] = $last;
$return['correct'] = 1;
$return['package'] = uniqid();
$return['end'] = 0;
if ($last == 1) {
$return['end'] = 1;
}
echo json_encode($return);
////////////////////////////////////////////////////////////////////
}
function update_pandora_download_package() {
global $config;
$dir = $config['attachment_store'] . '/update_pandora/';
$package = get_parameter('package', '');
//TODO Make all code, at the moment.
$url = 'http://sourceforge.net/projects/pandora/files/Pandora%20FMS%204.0.1/Pandora_FMS_4.0.1_OpenSource.i686-0.0.3.vmx.tar.gz/download';
$url = 'http://sourceforge.net/projects/pandora/files/Nightly/Tarball/pandorafms_console-4.1dev-120330.tar.gz/download';
$url = 'http://sourceforge.net/projects/pandora/files/Nightly/Tarball/pandorafms_server-4.1dev-120330.tar.gz/download';
preg_match_all('/Tarball\/(.*.tar.gz)/i', $url, $targz);
$targz = $targz[1][0];
$url = 'http://127.0.0.1/test000.tar.gz';
$url = 'http://127.0.0.1/test001.tar.gz';
$targz = 'test001.tar.gz';
////////////////////////////////////////////////////////////////////
$file = fopen($dir . $targz, "w");
$mch = curl_multi_init();
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($c, CURLOPT_FILE, $file);
curl_multi_add_handle($mch ,$c);
$running = null;
do {
curl_multi_exec($mch ,$running);
$info = curl_getinfo ($c);
$data = array();
$data['filename'] = $targz;
$data['size'] = $info['download_content_length'];
$data['size_download'] = $info['size_download'];
$data['speed_download'] = $info['speed_download'];
$info_json = json_encode($data);
file_put_contents('/tmp/' . $package . '.info.txt', $info_json, LOCK_EX);
sleep(1);
}
while($running > 0);
$return = array('correct' => 1);
echo json_encode($return);
}
function update_pandora_check_download_package() {
global $config;
require_once ($config["homedir"] . '/include/functions_graph.php');
sleep(1);
$package = get_parameter('package', '');
$return = array('correct' => 1,
'info_download' => "<b>Size:</b> %s/%s bytes <b>Speed:</b> %s bytes/second",
'progres_bar' => progress_bar(0, 300, 20, '0%', 1, false, "#00ff00"),
'progres_bar_text' => '0%',
'percent' => 0);
$info_json = @file_get_contents('/tmp/' . $package . '.info.txt');
$info = json_decode($info_json, true);
$percent = 0;
$size_download = 0;
$size = 0;
$speed_download = 0;
if ($info['size_download'] > 0) {
$percent = format_numeric(
($info['size_download'] / $info['size']) * 100, 2);
$return['percent'] = $percent;
$size_download = $info['size_download'];
$size = $info['size'];
$speed_download = $info['speed_download'];
$return['info_download'] = sprintf($return['info_download'],
format_for_graph($size_download, 2), format_for_graph($size, 2),
format_for_graph($speed_download, 2));
}
else {
$return['info_download'] = __('<b>Starting: </b> connect to server');
}
$img = progress_bar($percent, 300, 20, $percent . '%', 1, false, "#00ff00");
$return['progres_bar'] = $img;
preg_match_all('/src=[\'\"]([^\"^\']*)[\'\"]/i', $img, $attr);
$return['progres_bar_src'] = $attr[1];
preg_match_all('/alt=[\'\"]([^\"^\']*)[\'\"]/i', $img, $attr);
$return['progres_bar_alt'] = $attr[1];
preg_match_all('/title=[\'\"]([^\"^\']*)[\'\"]/i', $img, $attr);
$return['progres_bar_title'] = $attr[1];
$return['filename'] = $info['filename'];
echo json_encode($return);
}
function update_pandora_install_package() {
global $config;
global $conf_update_pandora;
if (empty($conf_update_pandora))
$conf_update_pandora = update_pandora_get_conf();
$dir = $config['attachment_store'] . '/update_pandora/';
$package = get_parameter('package', '');
$filename = get_parameter('filename', '');
//Get total files
$command = 'tar tzvf ' . $dir . $filename . '| wc -l > /tmp/' . $package . '.info.txt';
exec($command, $output, $status);
html_debug_print($command, true);
$command = 'tar xzvf ' . $dir . $filename . ' -C ' . $config['homedir'] . ' 1>/tmp/' . $package . '.files.info.txt';
html_debug_print($command, true);
//Maybe this line run for seconds or minutes
exec($command, $output, $status);
if (($status == 0) || ($status == 2)) {
$conf_update_pandora['last_installed'] = $filename;
update_pandora_update_conf();
echo json_encode(array('correct' => 1));
}
else {
echo json_encode(array('correct' => 0));
}
}
function update_pandora_check_install_package() {
global $config;
require_once ($config["homedir"] . '/include/functions_graph.php');
sleep(1);
$package = get_parameter('package', '');
$filename = get_parameter('filename', '');
//TODO MAYBE THE FILE OF FILES DON'T EXIST AT THE MOMENT
$files = @file('/tmp/' . $package . '.files.info.txt');
if (empty($files))
$files = array();
$total = (int)file_get_contents('/tmp/' . $package . '.info.txt');
$return = array('correct' => 1,
'info' => "<div id='list_files_install'
style='text-align: left; margin: 10px; padding: 5px; width: 90%%; height: 100px;
overflow: scroll; border: 1px solid #666'>%s</div>",
'src' => progress_bar(0, 300, 20, '0%', 1, false, "#0000ff"),
'alt' => '0%',
'percent' => 0);
$percent = 0;
if ((count($files) > 0) && ($total > 0)) {
$percent = format_numeric((count($files) / $total) * 100, 2);
if ($percent > 100)
$percent = 100;
}
$files_txtbox = (string)implode("<br />", $files);
$return['info'] = sprintf($return['info'], $files_txtbox);
$img = progress_bar($percent, 300, 20, $percent . '%', 1, false, "#0000ff");
$return['percent'] = $percent;
preg_match_all('/src=[\'\"]([^\"^\']*)[\'\"]/i', $img, $attr);
$return['src'] = $attr[1];
preg_match_all('/alt=[\'\"]([^\"^\']*)[\'\"]/i', $img, $attr);
$return['alt'] = $attr[1];
preg_match_all('/title=[\'\"]([^\"^\']*)[\'\"]/i', $img, $attr);
$return['title'] = $attr[1];
if ($percent == 100) {
unlink('/tmp/' . $package . '.files.info.txt');
unlink('/tmp/' . $package . '.info.txt');
}
echo json_encode($return);
}
?>

View File

@ -0,0 +1,393 @@
<?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.
function update_pandora_check_installation() {
global $config;
$conf_update_pandora = db_get_row('tconfig', 'token', 'update_pandora_conf_url');
$dir = $config['attachment_store'] . '/update_pandora/';
if (empty($conf_update_pandora) || !is_dir($dir))
return false;
else
return true;
}
function update_pandora_get_conf() {
global $config;
$conf = array();
$row = db_get_row('tconfig', 'token', 'update_pandora_conf_url');
$conf['url'] = $row['value'];
$row = db_get_row('tconfig', 'token', 'update_pandora_conf_last_installed');
$conf['last_installed'] = $row['value'];
$row = db_get_row('tconfig', 'token', 'update_pandora_conf_last_contact');
$conf['last_contact'] = $row['value'];
$conf['dir'] = $config['attachment_store'] . '/update_pandora/';
return $conf;
}
function update_pandora_installation() {
global $config;
$row = db_get_row_filter('tconfig', array('token' => 'update_pandora_conf_url'));
if (empty($row)) {
//The url of update manager.
$conf_update_pandora = array('url' => 'http://192.168.70.213/pandora.tar.gz',
'last_installed' => '',
'last_contact' => '');
$values = array('token' => 'update_pandora_conf_url',
'value' => $conf_update_pandora['url']);
$return = db_process_sql_insert('tconfig', $values);
$values = array('token' => 'update_pandora_conf_last_installed',
'value' => $conf_update_pandora['last_installed']);
$return = db_process_sql_insert('tconfig', $values);
$values = array('token' => 'update_pandora_conf_last_contact',
'value' => $conf_update_pandora['last_contact']);
$return = db_process_sql_insert('tconfig', $values);
ui_print_result_message($return, __('Succesful store conf data in DB.'),
__('Unsuccesful store conf data in DB.'));
}
else {
ui_print_message(__('Conf data have been in the DB.'));
}
$dir = $config['attachment_store'] . '/update_pandora/';
if (!is_dir($dir)) {
$result = mkdir($dir);
ui_print_result_message($result, __('Succesful create a dir to save package in Pandora Console'),
__('Unsuccesful create a dir to save package in Pandora Console'));
}
else {
ui_print_message(__('The directory for save package have been in Pandora Console.'));
}
}
function update_pandora_update_conf() {
global $config;
global $conf_update_pandora;
$values = array('value' => $conf_update_pandora['last_installed']);
$return = db_process_sql_update('tconfig', $values,
array('token' => 'update_pandora_conf_last_installed'));
$values = array('value' => $conf_update_pandora['last_contact']);
$return = db_process_sql_insert('tconfig', $values,
array('token' => 'update_pandora_conf_last_contact'));
return $return;
}
function update_pandora_get_list_downloaded_packages($mode = 'operation') {
global $config;
global $conf_update_pandora;
$dir = dir($conf_update_pandora['dir']);
$packages = array();
while (false !== ($entry = $dir->read())) {
if (is_file($conf_update_pandora['dir'] . $entry)
&& is_readable($conf_update_pandora['dir'] . $entry)) {
if (strstr($entry, '.tar.gz') !== false) {
if ($mode == 'operation') {
$packages[] = $entry;
}
else {
if ($conf_update_pandora['last_installed'] == $entry) {
$packages[] = array('name' => $entry,
'current' => true);
}
else {
$packages[] = array('name' => $entry,
'current' => false);
}
}
}
}
}
if (empty($packages)) {
if ($mode == 'operation') {
$packages[] = array('name' =>
__('There are not downloaded packages in your Pandora Console.'));
}
else {
$packages[] = array('empty' => true, 'name' =>
__('There are not downloaded packages in your Pandora Console.'));
}
}
return $packages;
}
function update_pandora_print_javascript() {
$extension_php_file = 'extensions/update_pandora';
?>
<script type="text/javascript">
var last = 0;
$(document).ready(function() {
ajax_get_online_package_list();
});
function ajax_get_online_package_list() {
var parameters = {};
parameters['page'] = "<?php echo $extension_php_file;?>";
parameters['get_packages_online'] = 1;
parameters['last'] = last;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
if (data['correct'] == 1) {
var row = $("<tr class='package'></tr>")
.append().html('<td>' + data['package'] + '</td>');
$("tbody", "#online_packages").append($(row));
last = data['last'];
if (data['end'] == 1) {
$(".spinner_row", "#online_packages").remove();
}
else {
ajax_get_online_package_list();
}
}
}
});
}
</script>
<?php
}
function update_pandora_print_javascript_admin() {
$extension_php_file = 'extensions/update_pandora';
?>
<script type="text/javascript">
var last = 0;
$(document).ready(function() {
ajax_get_online_package_list_admin();
$("#submit-hide_download_dialog").click (function () {
//Better than fill the downloaded packages
location.reload();
//$("#dialog_download" ).dialog('close');
});
});
function ajax_start_install_package(package) {
$(".package_name").html(package);
$("#dialog_download").dialog({
resizable: false,
draggable: false,
modal: true,
height: 400,
width: 600,
overlay: {
opacity: 0.5,
background: "black"
},
bgiframe: jQuery.browser.msie
});
$(".ui-dialog-titlebar-close").hide();
$("#dialog_download").show();
$("#title_downloading_update_pandora").hide();
$("#title_installing_update_pandora").show();
install_package(package, package);
}
function ajax_start_download_package(package) {
$(".package_name").html(package);
$("#dialog_download").dialog({
resizable: false,
draggable: false,
modal: true,
height: 400,
width: 600,
overlay: {
opacity: 0.5,
background: "black"
},
bgiframe: jQuery.browser.msie
});
$(".ui-dialog-titlebar-close").hide();
$("#dialog_download").show();
var parameters = {};
parameters['page'] = "<?php echo $extension_php_file;?>";
parameters['download_package'] = 1;
parameters['package'] = package;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
}
});
check_download_package(package);
}
function check_download_package(package) {
var parameters = {};
parameters['page'] = "<?php echo $extension_php_file;?>";
parameters['check_download_package'] = 1;
parameters['package'] = package;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
if (data['correct'] == 1) {
$("#info_text").show();
$("#info_text").html(data['info_download']);
$("#progress_bar_img img").attr('src', data['progres_bar_src']);
$("#progress_bar_img img").attr('alt', data['progres_bar_alt']);
$("#progress_bar_img img").attr('title', data['progres_bar_title']);
if (data['percent'] < 100) {
check_download_package(package);
}
else {
install_package(package, data['filename']);
}
}
}
});
}
function install_package(package, filename) {
var parameters = {};
parameters['page'] = "<?php echo $extension_php_file;?>";
parameters['install_package'] = 1;
parameters['package'] = package;
parameters['filename'] = filename;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
}
});
$("#title_downloading_update_pandora").hide();
$("#title_installing_update_pandora").show();
check_install_package(package, filename);
}
function check_install_package(package, filename) {
var parameters = {};
parameters['page'] = "<?php echo $extension_php_file;?>";
parameters['check_install_package'] = 1;
parameters['package'] = package;
parameters['filename'] = filename;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
if (data['correct'] == 1) {
$("#info_text").show();
$("#info_text").html(data['info']);
$("#list_files_install").scrollTop(
$("#list_files_install").attr("scrollHeight"));
$("#progress_bar_img img").attr('src', data['src']);
$("#progress_bar_img img").attr('alt', data['alt']);
$("#progress_bar_img img").attr('title', data['title']);
if (data['percent'] < 100) {
check_install_package(package, filename);
}
else {
$("#title_installing_update_pandora").hide();
$("#title_installed_update_pandora").show();
$("#button_close_download").show();
}
}
}
})
}
function ajax_get_online_package_list_admin() {
var parameters = {};
parameters['page'] = "<?php echo $extension_php_file;?>";
parameters['get_packages_online'] = 1;
parameters['last'] = last;
$.ajax({
type: 'POST',
url: 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
if (data['correct'] == 1) {
$("tbody", "#online_packages").append(
'<tr class="package_' + data['package'] + '">' +
'<td style=" text-align:left; width:80%;" class="name_package">' +
data['package'] +
'</td>' +
'<td style=" text-align:center; width:50px;">' +
'<a href="javascript: ajax_start_download_package(\'' + data['package'] + '\')">' +
'<?php html_print_image('images/down.png', false,
array('alt' => __('Download and install'), 'title' => __('Download and install'))); ?>' +
'</a>' +
'</td>' +
'</tr>');
last = data['last'];
if (data['end'] == 1) {
$(".spinner_row", "#online_packages").remove();
}
else {
ajax_get_online_package_list_admin();
}
}
}
});
}
</script>
<?php
}
?>

View File

@ -28,7 +28,7 @@ include_once($config['homedir'] . '/include/functions_users.php');
function db_select_engine() {
global $config;
switch ($config["dbtype"]) {
case "mysql":
require_once ($config['homedir'] . '/include/db/mysql.php');

View File

@ -40,25 +40,27 @@ require_once ($config['homedir'].'/include/functions_ui.php');
* Prints the print_r with < pre > tags
*/
function html_debug_print ($var, $file = '') {
$more_info = '';
if (is_string($var)) {
$more_info = 'size: ' . strlen($var);
}
elseif (is_bool($var)) {
$more_info = 'val: ' .
($var ? 'true' : 'false');
}
elseif (is_null($var)) {
$more_info = 'is null';
}
elseif (is_array($var)) {
$more_info = count($var);
}
if ($file === true)
$file = '/tmp/logDebug';
if (strlen($file) > 0) {
$f = fopen($file, "a");
ob_start();
$more_info = '';
if (is_string($var)) {
$more_info = 'size: ' . strlen($var);
}
elseif (is_bool($var)) {
$more_info = 'val: ' .
($var ? 'true' : 'false');
}
elseif (is_null($var)) {
$more_info = 'is null';
}
elseif (is_array($var)) {
$more_info = count($var);
}
echo date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info . "\n";
print_r($var);
echo "\n\n";
@ -67,6 +69,9 @@ function html_debug_print ($var, $file = '') {
fclose($f);
}
else {
echo "<pre>" .
date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info .
"</pre>";
echo "<pre>";print_r($var);echo "</pre>";
}
}