예제 #1
0
/**
 * Runs the upgrader
 *
 * @since 1.1
 * @package facileManager
 */
function upgradeFM($url, $data)
{
    global $argv, $module_name, $proto;
    addLogEntry('Performing client upgrade');
    $message = 'Installed version: ' . $data['server_client_version'] . "\n";
    echo fM($message);
    addLogEntry($message);
    $raw_data = getPostData($url, $data);
    $raw_data = $data['compress'] ? @unserialize(gzuncompress($raw_data)) : @unserialize($raw_data);
    if (!is_array($raw_data)) {
        echo fM($raw_data);
        addLogEntry($raw_data);
        exit(1);
    }
    extract($raw_data);
    echo fM('Latest version: ' . $latest_module_version . "\n");
    /** Download latest core files */
    echo fM("Downloading ");
    $core_file = 'facilemanager-core-' . $latest_core_version . '.tar.gz';
    downloadfMFile($core_file);
    /** Download latest module files */
    echo fM("Downloading ");
    $module_file = strtolower($module_name) . '-' . $latest_module_version . '.tar.gz';
    downloadfMFile($module_file, true);
    /** Extract client files */
    $message = "Extracting client files\n";
    echo fM($message);
    addLogEntry($message);
    extractFiles(array(sys_get_temp_dir() . '/' . $core_file, sys_get_temp_dir() . '/' . $module_file));
    /** Cleanup */
    $message = "Cleaning up\n";
    echo fM($message);
    addLogEntry($message);
    @unlink(sys_get_temp_dir() . '/' . $core_file);
    @unlink(sys_get_temp_dir() . '/' . $module_file);
    $message = "Client upgrade complete\n";
    echo fM($message);
    addLogEntry($message);
    /** Update the database with the new version */
    $data['server_client_version'] = $latest_module_version;
    $raw_data = getPostData($url, $data);
    die;
}
 function upgradeCore()
 {
     global $application;
     //5. Turn the store off line
     modApiFunc('Configuration', 'setValue', array("store_online" => 0));
     //CCacheFactory::clearAll();
     //6. Backup database and avactis system folder
     /*$backup_dir = $application->getAppIni('PATH_BACKUP_DIR');
     		  $system_dir = $application->getAppIni('PATH_SYSTEM_DIR');
     		  $backup_filename = "avactis_system_backup.zip";
     		  $db_backup_file = "avactis_db_backup.sql";
     		  $exclude = array("backup","cache"); //exclude cache and backup directories from creating backup
     		  $db_backup = backupDB_tables($backup_dir,$db_backup_file,"*");
     
     		  if ($db_backup){
     		  $file_backup = createZip($system_dir ,$backup_dir,$backup_filename,$exclude);
     		  if($file_backup){	*/
     //7. Move zip at store root
     //8. Unzip and clear cache
     $response = array();
     $upgrade_file = "avactis-upgrade.zip";
     $store_root_path = $application->getAppIni('PATH_ASC_ROOT');
     $cachedir = $application->getAppIni('PATH_CACHE_DIR');
     $returnCode = copy($cachedir . $upgrade_file, $store_root_path . $upgrade_file);
     if ($returnCode) {
         unlink($cachedir . $upgrade_file);
         $extracted = extractFiles($store_root_path . $upgrade_file, $store_root_path);
         if ($extracted) {
             unlink($store_root_path . $upgrade_file);
             //Make a test call to store, if okie then make a call to server for checking folder size,
             //If any issues, revert back to old system and db rollback
             //Else upgrade successful.
             $response = true;
         } else {
             $response['err_msg'] = "ERR_EXTRACT_FAILED";
         }
     } else {
         $response['err_msg'] = "ERR_MOVE_FAILED";
     }
     /*}else{
       $response['err_msg'] = "ERR_FILE_BACKUP_FAILED";
       }
       }else{
       $response['err_msg'] = "ERR_DB_BACKUP_FAILED";
       }*/
     //Turning store back online
     modApiFunc('Configuration', 'setValue', array("store_online" => 1));
     //
     return $response['err_msg'];
 }
예제 #3
0
    case "evt_serveuretatspatient":
    case "evt_frais_divers":
        $version = str_replace(".", "", $version);
        extractFiles("serveurActivitePmsi_v{$version}", "schemaServeurActivitePmsi_v{$version}.zip", true);
        break;
    case "evt_serveurintervention":
        $version = str_replace(".", "", $version);
        extractFiles("serveurActivitePmsi_v{$version}", "schemaServeurActivitePmsi_v{$version}.zip", true);
        break;
    case "evt_patients":
        $version = str_replace(".", "", $version);
        extractFiles("patients", "schemaEvenementPatient_v{$version}.zip", true);
        break;
    case "evt_mvtStock":
        $version = str_replace(".", "", $version);
        extractFiles("mvtStock", "schemaEvenementMvtStock_v{$version}.zip", true);
        break;
    default:
        echo "<div class='error'>Action '", CMbString::purifyHTML($evenement), "' inconnue</div>";
}
/**
 * Extract files
 *
 * @param string $schemaDir  Schema directory
 * @param string $schemaFile Schema files
 * @param bool   $delOldDir  Delete old directory
 *
 * @return void
 */
function extractFiles($schemaDir, $schemaFile, $delOldDir = false)
{