2008-08-28 Esteban Sanchez <estebans@artica.es>

* extensions/update_manager.php: Added function to update Update
        Manager settings.

        * extensions/update_manager/load_updatemanager.php: Added user key
        generation function. Update manager free extension do not use a keygen
        binary file.

        * extensions/update_manager/main.php: Changes to key generation,
        because free extension do not use keygen.

        * extensions/update_manager/settings.php: Removed configuration of
        keygen and upgrading directory.

        * extensions/update_manager/lib/libupdate_manager.php,
        extensions/update_manager/lib/libupdate_manager_utils.php: Updated to
        latest version of Update Manager.

        * extensions/update_manager/lib/libupdate_manager_client.php: Removed
        debug flag and errors to be less intrusive for the user. Updated to
        latest version of Update Manager.

        * extensions/update_manager/sql/update_manager.sql: Changed default 
        settings.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1047 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2008-08-29 07:54:17 +00:00
parent 853aecefb9
commit 46ee66c2c3
9 changed files with 94 additions and 78 deletions

View File

@ -1,3 +1,29 @@
2008-08-28 Esteban Sanchez <estebans@artica.es>
* extensions/update_manager.php: Added function to update Update
Manager settings.
* extensions/update_manager/load_updatemanager.php: Added user key
generation function. Update manager free extension do not use a keygen
binary file.
* extensions/update_manager/main.php: Changes to key generation,
because free extension do not use keygen.
* extensions/update_manager/settings.php: Removed configuration of
keygen and upgrading directory.
* extensions/update_manager/lib/libupdate_manager.php,
extensions/update_manager/lib/libupdate_manager_utils.php: Updated to
latest version of Update Manager.
* extensions/update_manager/lib/libupdate_manager_client.php: Removed
debug flag and errors to be less intrusive for the user. Updated to
latest version of Update Manager.
* extensions/update_manager/sql/update_manager.sql: Changed default
settings.
2008-08-28 Evi Vanoost <vanooste@rcbi.rochester.edu>
* extensions/update_manager.php: Check for an empty variable so it

View File

@ -20,6 +20,18 @@ function load_update_manager_lib () {
require_once ('update_manager/load_updatemanager.php');
}
function update_settings_database_connection () {
global $config;
global $db;
$db =& um_db_connect ('mysql', $config['dbhost'], $config['dbuser'],
$config['dbpass'], $config['dbname']);
um_db_update_setting ('dbname', $config['dbname']);
um_db_update_setting ('dbuser', $config['dbuser']);
um_db_update_setting ('dbpass', $config['dbpass']);
um_db_update_setting ('dbhost', $config['dbhost']);
}
function pandora_update_manager_install () {
global $config;
global $db;
@ -44,10 +56,7 @@ function pandora_update_manager_install () {
$config['dbpass'], $config['dbname']);
um_db_update_setting ('updating_code_path',
dirname ($_SERVER['SCRIPT_FILENAME']));
um_db_update_setting ('dbname', $config['dbname']);
um_db_update_setting ('dbuser', $config['dbuser']);
um_db_update_setting ('dbpass', $config['dbpass']);
um_db_update_setting ('dbhost', $config['dbhost']);
update_settings_database_connection ();
}
function pandora_update_manager_uninstall () {
@ -63,6 +72,7 @@ function pandora_update_manager_main () {
global $db;
load_update_manager_lib ();
update_settings_database_connection ();
require_once ('update_manager/main.php');
}

View File

@ -197,11 +197,11 @@ function um_db_get_package_updates ($id_package) {
return $updates;
}
function um_db_create_package_log ($id_package, $id_auth, $ip_address = '') {
function um_db_create_package_log ($id_package, $client_key, $user_package, $result = 'query', $user_subscription = '') {
global $db;
$values = array ($id_package, $id_auth, $ip_address);
$sql =& $db->prepare ('INSERT INTO tupdate_package_log (id_update_package, id_auth, ip_address) VALUES (?, ?, ?)');
$values = array ($id_package, $client_key, $_SERVER['REMOTE_ADDR'], $user_package, $user_subscription, $result);
$sql =& $db->prepare ('INSERT INTO tupdate_package_log (id_update_package, client_key, ip_address, user_package, user_subscription, result) VALUES (?, ?, ?, ?, ?, ?)');
$result =& $db->execute ($sql, $values);
if (PEAR::isError ($result)) {
return false;
@ -209,6 +209,22 @@ function um_db_create_package_log ($id_package, $id_auth, $ip_address = '') {
return true;
}
function um_db_get_all_package_logs () {
global $db;
$result =& $db->query ('SELECT * FROM tupdate_package_log ORDER BY `timestamp` DESC');
if (PEAR::isError ($result)) {
echo '<strong>Error</strong>: '.$result->getMessage ().'<br />';
return array ();
}
$logs = array ();
while ($result->fetchInto ($log)) {
$logs[$log->id] = $log;
}
return $logs;
}
function um_db_create_component ($type, $name, $path = '') {
global $db;
@ -502,10 +518,10 @@ function um_component_db_connect () {
function um_get_package_status () {
$status = array ();
$status['development'] = 'Development';
$status['testing'] = 'Testing';
$status['public'] = 'Public';
$status['disabled'] = 'Disabled';
$status['development'] = __('Development');
$status['testing'] = __('Testing');
$status['public'] = __('Public');
$status['disabled'] = __('Disabled');
return $status;
}
@ -513,8 +529,8 @@ function um_get_package_status () {
function um_get_component_types () {
$types = array ();
$types['database'] = 'Database';
$types['directory'] = 'Code / binary directory';
$types['database'] = __('Database');
$types['directory'] = __('Code / binary directory');
return $types;
}

View File

@ -6,8 +6,6 @@ if ((include_once ('XML/RPC.php')) != 1)
error_reporting ($prev_level);
unset ($prev_level);
define ('XMLRPC_DEBUG', 0);
function um_xml_rpc_client_call ($server_host, $server_path, $server_port, $function, $parameters) {
$msg = new XML_RPC_Message ($function, $parameters);
$client = new XML_RPC_Client ($server_path, $server_host, $server_port);
@ -15,12 +13,7 @@ function um_xml_rpc_client_call ($server_host, $server_path, $server_port, $func
$client->setDebug (XMLRPC_DEBUG);
$result = $client->send ($msg);
if (! $result) {
trigger_error ('<strong>Open Update Manager</strong> Server comunication error. '.$client->errstr);
return false;
}
if ($result->faultCode ()) {
trigger_error ('<strong>Open Update Manager</strong> XML-RPC error. '.$result->faultString ());
if (! $result || $result->faultCode ()) {
return false;
}
@ -153,14 +146,15 @@ function um_client_db_save_update ($update) {
}
function um_client_apply_update_file ($update, $destiny_filename, $force = false) {
if (! is_writable ($destiny_filename)) {
return false;
}
@mkdir (dirname ($destiny_filename), 0777, true);
if (file_exists ($destiny_filename)) {
if (! is_writable ($destiny_filename)) {
return false;
}
$checksum = md5_file ($destiny_filename);
if (! $force &&$update->previous_checksum != '') {
if ($update->previous_checksum != $checksum)
if (! $force && $update->previous_checksum != '') {
if ($update->previous_checksum != $checksum)
/* Local changes in the file. Don't update */
return false;
}
@ -251,7 +245,11 @@ function um_client_print_update ($update, $settings) {
echo '<ul>';
echo '<li><em>Type</em>: '.$update->type.'</li>';
if ($update->type == 'code' || $update->type == 'binary') {
$realpath = realpath ($settings->updating_code_path.'/'.$update->filename);
if ($update->type == 'code') {
$realpath = realpath ($settings->updating_code_path.'/'.$update->filename);
} else {
$realpath = realpath ($settings->updating_binary_path.'/'.$update->filename);
}
echo '<li><em>Filename</em>: '.$update->filename.'</li>';
echo '<li><em>Realpath</em>: '.$realpath.'</li>';
echo '<li><em>Checksum</em>: '.$update->checksum.'</li>';

View File

@ -6,9 +6,9 @@ function add_prefix (&$string, $key, $prefix) {
function is_binary ($filepath) {
$output = array ();
exec ('file -b -e soft '.$filepath, $output);
exec ('file -b -i '.$filepath.' | cut -f1 -d"/"', $output);
if (isset ($output[0]))
return $output[0] == 'data';
return $output[0] != 'text';
return false;
}

View File

@ -13,5 +13,14 @@ if (! extension_loaded ('mysql'))
require_once ('lib/libupdate_manager.php');
function get_user_key () {
/* We only want to know this for statistics records.
Feel free to disable if you want. We don't want to hide anything.
*/
$user_key = get_db_value ('COUNT(`id_agente`)', 'tagente', 'disabled', 0);
return $user_key;
}
flush ();
?>

View File

@ -34,29 +34,7 @@ $settings = um_db_load_settings ();
echo '<h3>'.__('Update manager').'</h3>';
if (! file_exists ($settings->keygen_path)) {
echo '<h3 class="error">'.__('Keygen file does not exists')."</h3>";
return;
}
if (! is_executable ($settings->keygen_path)) {
echo '<h3 class="error">'.__('Keygen is not executable')."</h3>";
return;
}
$user_key = exec ($settings->keygen_path);
$update_package = (bool) get_parameter_post ('update_package');
if ($update_package) {
echo 'Updating...';
flush ();
$force = (bool) get_parameter_post ('force_update');
um_client_upgrade_to_latest ($user_key, $force);
/* TODO: Meter una noticia en tnews*/
}
$settings = um_db_load_settings ();
$user_key = get_user_key ();
$package = um_client_check_latest_update ($settings, $user_key);
if (is_int ($package) && $package == 1) {
@ -69,27 +47,12 @@ if (is_int ($package) && $package == 1) {
echo '<h5 class="suc">'.__('There\'s a new update for Pandora')."</h5>";
$table->width = '50%';
$table->head = array ();
$table->data = array ();
$table->data[0][0] = '<strong>'.__('Id').'</strong>';
$table->data[0][1] = $package->id;
$table->data[1][0] = '<strong>'.__('Timestamp').'</strong>';
$table->data[1][1] = $package->timestamp;
$table->data[2][0] = '<strong>'.__('Description').'</strong>';
$table->data[2][1] = html_entity_decode ($package->description);
$table->head[0] = '<strong>'.__('Description').'</strong>';
$table->data[0][0] = html_entity_decode ($package->description);
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form method="post">';
echo __('Overwrite local changes');
print_checkbox ('force_update', '1', false);
echo '<p />';
print_input_hidden ('update_package', 1);
print_submit_button (__('Update'), 'update_button', false, 'class="sub upd"');
echo '</form>';
echo '</div>';
}
echo '<h4>'.__('Your system version number is').': '.$settings->current_update.'</h4>';

View File

@ -58,12 +58,6 @@ $table->data[2][1] = print_input_text ('keys[update_server_path]', $settings->up
$table->data[3][0] = '<strong>'.__('Update server port').'</strong>';
$table->data[3][1] = print_input_text ('keys[update_server_port]', $settings->update_server_port, '', 5, 5, true);
$table->data[4][0] = '<strong>'.__('Binary input path').'</strong>';
$table->data[4][1] = print_input_text ('keys[updating_binary_path]', $settings->updating_binary_path, '', 40, 255, true);
$table->data[5][0] = '<strong>'.__('Keygen path').'</strong>';
$table->data[5][1] = print_input_text ('keys[keygen_path]', $settings->keygen_path, '', 40, 255, true);
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_input_hidden ('update_settings', 1);

View File

@ -1,5 +1,5 @@
CREATE TABLE `tupdate_settings` ( `key` varchar(255) default '', `value` varchar(255) default '', PRIMARY KEY (`key`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `tupdate_settings` VALUES ('current_update', '0'), ('customer_key', 'Insert your customer key here'), ('keygen_path', ''), ('update_server_host', ''), ('update_server_port', '80'), ('update_server_path', ''), ('updating_binary_path', 'Path where the updated binary files will be stored'), ('updating_code_path', 'Path where the updated code is stored'), ('dbname', ''), ('dbhost', ''), ('dbpass', ''), ('dbuser', '');
INSERT INTO `tupdate_settings` VALUES ('current_update', '0'), ('customer_key', 'PANDORA-FREE'), ('keygen_path', ''), ('update_server_host', 'artica.homelinux.com'), ('update_server_port', '80'), ('update_server_path', 'pandoraupdate/server.php'), ('updating_binary_path', 'Path where the updated binary files will be stored'), ('updating_code_path', 'Path where the updated code is stored'), ('dbname', ''), ('dbhost', ''), ('dbpass', ''), ('dbuser', '');
CREATE TABLE `tupdate_package` ( id int(11) unsigned NOT NULL auto_increment, timestamp datetime NOT NULL, description mediumtext NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `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 default '', data_rollback LONGTEXT default '', description TEXT default '', 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;
CREATE TABLE `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;