true, 'text' => null); $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' => '', 'last_installed' => '', 'last_contact' => '', 'download_mode' => 'wget'); $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); $values = array('token' => 'update_pandora_conf_download_mode', 'value' => $conf_update_pandora['download_mode']); $return = db_process_sql_insert('tconfig', $values); if (!$return) { $return_var['return'] = false; $return_var['text'][] = __('Unsuccesful store conf data in DB.'); } } $dir = $config['attachment_store'] . '/update_pandora/'; if (!is_dir($dir)) { $return = mkdir($dir); if (!$return) { $return_var['return'] = false; $return_var['text'][] = __('Unsuccesful create a dir to save package in Pandora Console'); } } return $return_var; } 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_update('tconfig', $values, array('token' => 'update_pandora_conf_last_contact')); $values = array('value' => $conf_update_pandora['download_mode']); $return = db_process_sql_update('tconfig', $values, array('token' => 'update_pandora_conf_download_mode')); return $return; } function update_pandora_get_list_downloaded_packages($mode = 'operation') { global $config; global $conf_update_pandora; $dir = dir($conf_update_pandora['dir']); if ($dir === false) { ui_print_error_message(sprintf( __('Error reading the dir of packages in "%s".'), $conf_update_pandora['dir'])); return; } $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 { $time_file = date($config["date_format"], filemtime($conf_update_pandora['dir'] . $entry)); if ($conf_update_pandora['last_installed'] == $entry) { $packages[] = array('name' => $entry, 'current' => true, 'time' => $time_file); } else { $packages[] = array('name' => $entry, 'current' => false, 'time' => $time_file); } } } } } if (empty($packages)) { if ($mode == 'operation') { $packages[] = array('name' => __('There are not downloaded packages in your Pandora Console.'), 'time' => ''); } else { $packages[] = array('empty' => true, 'name' => __('There are not downloaded packages in your Pandora Console.'), 'time' => ''); } } return $packages; } function update_pandora_print_javascript() { $extension_php_file = 'extensions/update_pandora'; ?> open($_FILES["fileloaded"]['tmp_name']) === TRUE) { $zip->extractTo($tempDir); $zip->close(); } else { $error = ui_print_error_message(__('Update cannot be opened')); } $package = um_package_info_from_paths ($tempDir); if ($package === false) { ui_print_error_message( __('Error, the file package is empty or corrupted.')); } else { $settings = um_db_load_settings (); if ($settings->current_update >= $package->id) { ui_print_error_message( __('Your system version is higher or equal than the loaded package')); } else { $binary_paths = um_client_get_files ($tempDir."binary/"); foreach ($binary_paths as $key => $paths) { foreach($paths as $index => $path) { $tempDir_scaped = preg_replace('/\//', '\/', $tempDir."binary"); $binary_paths[$key][$index] = preg_replace('/^'.$tempDir_scaped.'/', ' ', $path); } } $code_paths = um_client_get_files ($tempDir."code/"); foreach ($code_paths as $key => $paths) { foreach($paths as $index => $path) { $tempDir_scaped = preg_replace('/\//', '\/', $tempDir."code"); $code_paths[$key][$index] = preg_replace('/^'.$tempDir_scaped.'/', ' ', $path); } } $sql_paths = um_client_get_files ($tempDir); foreach ($sql_paths as $key => $paths) { foreach ($paths as $index => $path) { if ($path != $tempDir || ($key == 'info_package' && $path == $tempDir)) { unset($sql_paths[$key]); } } } $updates_binary = array(); $updates_code = array(); $updates_sql = array(); if (!empty($binary_paths)) { $updates_binary = um_client_update_from_paths ($binary_paths, $tempDir, $package->id, 'binary'); } if (!empty($code_paths)) { $updates_code = um_client_update_from_paths ($code_paths, $tempDir, $package->id, 'code'); } if (!empty($sql_paths)) { $updates_sql = um_client_update_from_paths ($sql_paths, $tempDir, $package->id, 'sql'); } um_delete_directory($tempDir); $updates= array_merge((array) $updates_binary, (array) $updates_code, (array) $updates_sql); $package->updates = $updates; $settings = um_db_load_settings (); if (um_client_upgrade_to_package($package, $settings, true)) { ui_print_success_message( __('Successfully upgraded')); //Refresh the settings object. $settings = um_db_load_settings (); } else { ui_print_error_message(__('Cannot be upgraded')); } } } } } else { ui_print_error_message(__('File cannot be uploaded')); } } ?>