static function isAvailable()
 {
     $extensionName = 'zlib';
     if (!extension_loaded($extensionName)) {
         $dlExtension = eZSys::osType() == 'win32' ? '.dll' : '.so';
         @dl($extensionName . $dlExtension);
     }
     return extension_loaded($extensionName);
 }
 /**
  * Instanciantes the image converter with a set of filters
  *
  * @param array(ezcImageFilter) $filter Filters to add to the image converter
  * @return void
  * @throws ezcBaseSettingValueException Error adding the transformation
  */
 public function __construct($filter)
 {
     $imageINI = eZINI::instance('image.ini');
     // we get an array of handlers, where order of entries in array gives priority
     // for each entry, we need to check if the matching handler is enabled, and this has to be manual
     $imageHandlers = $imageINI->variable('ImageConverterSettings', 'ImageConverters');
     foreach ($imageHandlers as $imageHandler) {
         switch ($imageHandler) {
             case 'ImageMagick':
                 $hasImageMagick = $imageINI->variable('ImageMagick', 'IsEnabled') == 'true';
                 if ($hasImageMagick) {
                     break 2;
                 }
                 break;
                 // GD2 is required for the image editor
                 // @todo Make the image editor degrade as nicely as possible if GD is not bundled
             // GD2 is required for the image editor
             // @todo Make the image editor degrade as nicely as possible if GD is not bundled
             case 'GD':
                 $hasGD2 = $imageINI->variable('GD', 'IsEnabled') == 'true' && $imageINI->variable('GDSettings', 'HasGD2' == 'true');
                 if ($hasGD2) {
                     break 2;
                 }
                 break;
         }
     }
     if ($hasImageMagick) {
         // we need to use the ImageMagick path configured in the image.ini file
         $executable = $imageINI->variable('ImageMagick', 'Executable');
         if (eZSys::osType() == 'win32' && $imageINI->hasVariable('ImageMagick', 'ExecutableWin32')) {
             $executable = $imageINI->variable('ImageMagick', 'ExecutableWin32');
         } else {
             if (eZSys::osType() == 'mac' && $imageINI->hasVariable('ImageMagick', 'ExecutableMac')) {
                 $executable = $imageINI->variable('ImageMagick', 'ExecutableMac');
             } else {
                 if (eZSys::osType() == 'unix' && $imageINI->hasVariable('ImageMagick', 'ExecutableUnix')) {
                     $executable = $imageINI->variable('ImageMagick', 'ExecutableUnix');
                 }
             }
         }
         if ($imageINI->hasVariable('ImageMagick', 'ExecutablePath') && $imageINI->variable('ImageMagick', 'ExecutablePath')) {
             $executable = $imageINI->variable('ImageMagick', 'ExecutablePath') . eZSys::fileSeparator() . $executable;
         }
         // @todo Remove if ezc indeed do it automatically
         // if ( eZSys::osType() == 'win32' )
         //    $executable = "\"$executable\"";
         $imageHandlerSettings = new ezcImageHandlerSettings('ImageMagick', 'eZIEEzcImageMagickHandler', array('binary' => $executable));
         $settings = new ezcImageConverterSettings(array($imageHandlerSettings));
     } else {
         $settings = new ezcImageConverterSettings(array(new ezcImageHandlerSettings('GD', 'eZIEEzcGDHandler')));
     }
     $this->converter = new ezcImageConverter($settings);
     $mimeType = $imageINI->variable('OutputSettings', 'AllowedOutputFormat');
     $this->converter->createTransformation('transformation', $filter, $mimeType);
 }
Example #3
0
 /**
  * Search text in files using regexps (recursively through folders).
  * Assumes egrep is available if not on windows
  */
 static function searchInFiles($searchtext, $cachedir, $is_regexp = true)
 {
     //$fileHandler = eZClusterFileHandler::instance();
     $result = array();
     if (eZSys::osType() != 'win32') {
         if ($is_regexp) {
             exec('egrep -s -R -l "' . str_replace('"', '\\"', $searchtext) . "\" \"{$cachedir}\"", $result);
         } else {
             exec('fgrep -s -R -l "' . str_replace('"', '\\"', $searchtext) . "\" \"{$cachedir}\"", $result);
         }
     } else {
         $files = @scandir($cachedir);
         if ($files === false) {
             return false;
         }
         foreach ($files as $file) {
             if ($file != '.' && $file != '..') {
                 if (is_dir($cachedir . '/' . $file)) {
                     $result = array_merge($result, self::searchInFiles($searchtext, $cachedir . '/' . $file, $is_regexp));
                 } else {
                     $txt = @file_get_contents($cachedir . '/' . $file);
                     /// @todo escape properly #
                     if ($is_regexp) {
                         if (preg_match("#" . $searchtext . "#", $txt)) {
                             $result[] = $cachedir . '/' . $file;
                         }
                     } else {
                         if (strpos($txt, $searchtext) !== false) {
                             $result[] = $cachedir . '/' . $file;
                         }
                     }
                     $txt = false;
                     // free memory asap
                 }
             }
         }
     }
     return $result;
 }
Example #4
0
function eZSetupTestFileUpload($type)
{
    $uploadEnabled = ini_get('file_uploads') != 0;
    $uploadDir = ini_get('upload_tmp_dir');
    $uploadDirExists = true;
    $uploadDirWriteable = true;
    $uploadDirCreateFile = true;
    $uploadIsRoot = false;
    // Empty upload_tmp_dir variable means that the system
    // default is used. However the system default variable is hidden
    // from PHP code and must be guessed.
    // See: http://www.php.net/manual/en/ini.sect.file-uploads.php#ini.upload-tmp-dir
    if (strlen(trim($uploadDir)) == 0) {
        $osType = eZSys::osType();
        if ($osType == 'win32') {
            // Windows machines use the TEMP and TMP env variable.
            // TEMP is checked first.
            $uploadDir = eZSys::hasEnvironmentVariable('TEMP') ? eZSys::environmentVariable('TEMP') : '';
            if ($uploadDir === '') {
                $uploadDir = eZSys::hasEnvironmentVariable('TMP') ? eZSys::environmentVariable('TMP') : '';
            }
            // When TEMP/TMP is not set we have to guess the directory
            // The only valid guess is %SYSTEMROOT%/TEMP
            // If %SYSTEMROOT% is missing we keep the string empty
            if ($uploadDir === '') {
                if (eZSys::hasEnvironmentVariable('SYSTEMROOT')) {
                    $uploadDir = eZSys::environmentVariable('SYSTEMROOT') . '/TEMP';
                }
            }
        } else {
            if ($osType == 'unix' or $osType == 'mac') {
                $uploadDir = eZSys::hasEnvironmentVariable('TMPDIR') ? eZSys::environmentVariable('TMPDIR') : '';
                // When TMPDIR is not set we have to guess the directory
                // On Unix systems we expect /tmp to be used
                if (strlen($uploadDir) == 0) {
                    $uploadDir = '/tmp';
                }
            }
        }
    }
    $uploadDirs = array();
    if (strlen($uploadDir) > 0) {
        $uploadDirExists = file_exists($uploadDir);
        $uploadDirWriteable = eZDir::isWriteable($uploadDir);
        if ($uploadDirExists and $uploadDirWriteable) {
            $uploadDirCreateFile = false;
            $tmpFile = 'ezsetuptmp_' . md5(microtime()) . '.tmp';
            $tmpFilePath = $uploadDir . '/' . $tmpFile;
            if ($fd = @fopen($tmpFilePath, 'w')) {
                $uploadDirCreateFile = true;
                @fclose($fd);
                unlink($tmpFilePath);
            }
        }
        $splitDirs = explode('/', trim($uploadDir, '/'));
        $dirPath = '';
        foreach ($splitDirs as $splitDir) {
            $dirPath .= '/' . $splitDir;
            $uploadDirs[] = $dirPath;
        }
        if (substr($uploadDir, 0, 5) == '/root') {
            $uploadIsRoot = true;
        }
    }
    $result = ($uploadEnabled and $uploadDirExists and $uploadDirWriteable and $uploadDirCreateFile);
    $userInfo = eZSetupPrvPosixExtension();
    return array('result' => $result, 'php_upload_is_enabled' => $uploadEnabled, 'php_upload_is_root' => $uploadIsRoot, 'php_upload_dir' => $uploadDir, 'php_upload_split_dirs' => $uploadDirs, 'upload_dir_exists' => $uploadDirExists, 'upload_dir_writeable' => $uploadDirWriteable, 'upload_dir_create_file' => $uploadDirCreateFile, 'user_info' => $userInfo, 'persistent_data' => array('result' => array('value' => $result)));
}
Example #5
0
 static function linkCopy( $sourceFilename, $destinationFilename, $symbolicLink = true )
 {
     if ( in_array( eZSys::osType(),
                    array( 'unix', 'linux', 'mac' ) ) )
     {
         if ( $symbolicLink )
             $result = eZFileHandler::symlink( $sourceFilename, $destinationFilename );
         else
             $result = eZFileHandler::link( $sourceFilename, $destinationFilename );
         if ( $result )
             return $result;
         return eZFileHandler::copy( $sourceFilename, $destinationFilename );
     }
     else
     {
         return eZFileHandler::copy( $sourceFilename, $destinationFilename );
     }
 }
Example #6
0
 static function isWriteable($filename)
 {
     if (eZSys::osType() != 'win32') {
         return is_writable($filename);
     }
     /* PHP function is_writable() doesn't work correctly on Windows NT descendants.
      * So we have to use the following hack on those OSes.
      */
     if (!($fd = @fopen($filename, 'a'))) {
         return FALSE;
     }
     fclose($fd);
     return TRUE;
 }
Example #7
0
 private function installPackage($package)
 {
     $persistentData = array();
     $persistentData['package_name'] = $package->attribute('name');
     $persistentData['currentItem'] = 0;
     $persistentData['doItemInstall'] = true;
     $persistentData['error'] = array();
     $persistentData['error_default_actions'] = array();
     $installItemArray = $package->installItemsList(false, eZSys::osType());
     foreach ($installItemArray as $installItem) {
         $installer = eZPackageInstallationHandler::instance($package, $installItem['type'], $installItem);
         if (!$installer || isset($persistentData['error']['choosen_action'])) {
             $result = $package->installItem($installItem, $persistentData);
             if (!$result) {
                 $templateName = "design:package/install_error.tpl";
                 break;
             } else {
                 $persistentData['error'] = array();
             }
         } else {
             $persistentData['doItemInstall'] = false;
             $installer->generateStepMap($package, $persistentData);
             $displayStep = true;
             break;
         }
     }
     $package->setInstalled();
 }
Example #8
0
    $persistentData = array();
    $persistentData['package_name'] = $packageName;
    $persistentData['currentItem'] = $currentItem;
    $persistentData['doItemInstall'] = false;
    $persistentData['error'] = array();
    $persistentData['error_default_actions'] = array();
}

if ( !eZPackage::canUsePolicyFunction( 'install' ) )
    return $module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );

$package = eZPackage::fetch( $packageName );
if ( !$package )
    return $module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' );

$installItemArray = $package->installItemsList( false, eZSys::osType() );

$tpl = eZTemplate::factory();

if ( $module->isCurrentAction( 'SkipPackage' ) )
{
    $http->removeSessionVariable( 'eZPackageInstallerData' );
    return $module->redirectToView( 'view', array( 'full', $package->attribute( 'name' ) ) );
}
elseif ( $module->isCurrentAction( 'InstallPackage' ) )
{
    $persistentData['doItemInstall'] = true;
}
elseif ( $module->isCurrentAction( 'HandleError' ) )
{
    $persistentData['doItemInstall'] = true;
Example #9
0
    static function isWriteable( $dirname )
    {
        if ( eZSys::osType() != 'win32' )
            return is_writable( $dirname );

        /* PHP function is_writable() doesn't work correctly on Windows NT descendants.
         * So we have to use the following hack on those OSes.
         */
        $tmpfname = $dirname . eZSys::fileSeparator() . "ezsetup_" . md5( microtime() ) . ".tmp";

        // try to create temporary file
        if ( !( $fp = @fopen( $tmpfname, "w" ) ) )
            return FALSE;

        fclose( $fp );
        unlink( $tmpfname );

        return TRUE;
    }
Example #10
0
 function convert($manager, $sourceMimeData, &$destinationMimeData, $filters = false)
 {
     $argumentList = array();
     $executable = $this->Executable;
     if (eZSys::osType() == 'win32' and $this->ExecutableWin32) {
         $executable = $this->ExecutableWin32;
     } else {
         if (eZSys::osType() == 'mac' and $this->ExecutableMac) {
             $executable = $this->ExecutableMac;
         } else {
             if (eZSys::osType() == 'unix' and $this->ExecutableUnix) {
                 $executable = $this->ExecutableUnix;
             }
         }
     }
     if ($this->Path) {
         $executable = $this->Path . eZSys::fileSeparator() . $executable;
     }
     if (eZSys::osType() == 'win32') {
         $executable = "\"{$executable}\"";
     }
     $argumentList[] = $executable;
     if ($this->PreParameters) {
         $argumentList[] = $this->PreParameters;
     }
     $frameRangeParameters = $this->FrameRangeParameters;
     if ($frameRangeParameters && isset($frameRangeParameters[$sourceMimeData['name']])) {
         $sourceMimeData['url'] .= $frameRangeParameters[$sourceMimeData['name']];
     }
     $argumentList[] = eZSys::escapeShellArgument($sourceMimeData['url']);
     $qualityParameters = $this->QualityParameters;
     if ($qualityParameters and isset($qualityParameters[$destinationMimeData['name']])) {
         $qualityParameter = $qualityParameters[$destinationMimeData['name']];
         $outputQuality = $manager->qualityValue($destinationMimeData['name']);
         if ($outputQuality) {
             $qualityArgument = eZSys::createShellArgument($qualityParameter, array('%1' => $outputQuality));
             $argumentList[] = $qualityArgument;
         }
     }
     if ($filters !== false) {
         foreach ($filters as $filterData) {
             $argumentList[] = $this->textForFilter($filterData);
         }
     }
     $destinationURL = $destinationMimeData['url'];
     if ($this->UseTypeTag) {
         $destinationURL = $this->tagForMIMEType($destinationMimeData) . $this->UseTypeTag . $destinationURL;
     }
     $argumentList[] = eZSys::escapeShellArgument($destinationURL);
     if ($this->PostParameters) {
         $argumentList[] = $this->PostParameters;
     }
     $systemString = implode(' ', $argumentList);
     system($systemString, $returnCode);
     if ($returnCode == 0) {
         if (!file_exists($destinationMimeData['url'])) {
             eZDebug::writeError('Unknown destination file: ' . $destinationMimeData['url'] . " when executing '{$systemString}'", 'eZImageShellHandler(' . $this->HandlerName . ')');
             return false;
         }
         $this->changeFilePermissions($destinationMimeData['url']);
         return true;
     } else {
         eZDebug::writeWarning("Failed executing: {$systemString}, Error code: {$returnCode}", __METHOD__);
         return false;
     }
 }
 function convert($manager, $sourceMimeData, &$destinationMimeData, $filters = false)
 {
     $argumentList = array();
     $executable = $this->Executable;
     if (eZSys::osType() == 'win32' and $this->ExecutableWin32) {
         $executable = $this->ExecutableWin32;
     } else {
         if (eZSys::osType() == 'mac' and $this->ExecutableMac) {
             $executable = $this->ExecutableMac;
         } else {
             if (eZSys::osType() == 'unix' and $this->ExecutableUnix) {
                 $executable = $this->ExecutableUnix;
             }
         }
     }
     if ($this->Path) {
         $executable = $this->Path . eZSys::fileSeparator() . $executable;
     }
     if (eZSys::osType() == 'win32') {
         $executable = "\"{$executable}\"";
     }
     $argumentList[] = $executable;
     if ($this->PreParameters) {
         $argumentList[] = $this->PreParameters;
     }
     $frameRangeParameters = $this->FrameRangeParameters;
     if ($frameRangeParameters && isset($frameRangeParameters[$sourceMimeData['name']])) {
         $sourceMimeData['url'] .= $frameRangeParameters[$sourceMimeData['name']];
     }
     // Issue EZP-21357:
     // ImageMagick has it's own meta-characters support, hence:
     //     $ convert 'File*.jpg'' ...
     // Still expand File*.jpg as the shell would do, however, this is only true for the file's basename part and not
     // for the whole path.
     $argumentList[] = eZSys::escapeShellArgument($sourceMimeData['dirpath'] . DIRECTORY_SEPARATOR . addcslashes($sourceMimeData['filename'], '~*?[]{}<>'));
     $qualityParameters = $this->QualityParameters;
     if ($qualityParameters and isset($qualityParameters[$destinationMimeData['name']])) {
         $qualityParameter = $qualityParameters[$destinationMimeData['name']];
         $outputQuality = $manager->qualityValue($destinationMimeData['name']);
         if ($outputQuality) {
             $qualityArgument = eZSys::createShellArgument($qualityParameter, array('%1' => $outputQuality));
             $argumentList[] = $qualityArgument;
         }
     }
     if ($filters !== false) {
         foreach ($filters as $filterData) {
             $argumentList[] = $this->textForFilter($filterData);
         }
     }
     $destinationURL = $destinationMimeData['url'];
     if ($this->UseTypeTag) {
         $destinationURL = $this->tagForMIMEType($destinationMimeData) . $this->UseTypeTag . $destinationURL;
     }
     $argumentList[] = eZSys::escapeShellArgument($destinationURL);
     if ($this->PostParameters) {
         $argumentList[] = $this->PostParameters;
     }
     $systemString = implode(' ', $argumentList);
     system($systemString, $returnCode);
     if ($returnCode == 0) {
         if (!file_exists($destinationMimeData['url'])) {
             eZDebug::writeError('Unknown destination file: ' . $destinationMimeData['url'] . " when executing '{$systemString}'", 'eZImageShellHandler(' . $this->HandlerName . ')');
             return false;
         }
         $this->changeFilePermissions($destinationMimeData['url']);
         return true;
     } else {
         eZDebug::writeWarning("Failed executing: {$systemString}, Error code: {$returnCode}", __METHOD__);
         return false;
     }
 }
Example #12
0
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2012.8
 * @package kernel
 */
$cli->output("Checking link ...");
$cronjobIni = eZINI::instance('cronjob.ini');
$siteURLs = $cronjobIni->variable('linkCheckSettings', 'SiteURL');
$linkList = eZURL::fetchList(array('only_published' => true));
foreach ($linkList as $link) {
    $linkID = $link->attribute('id');
    $url = $link->attribute('url');
    $isValid = $link->attribute('is_valid');
    $cli->output("check-" . $cli->stylize('emphasize', $url) . " ", false);
    if (preg_match("/^(http:)/i", $url) or preg_match("/^(ftp:)/i", $url) or preg_match("/^(https:)/i", $url) or preg_match("/^(file:)/i", $url) or preg_match("/^(mailto:)/i", $url)) {
        if (preg_match("/^(mailto:)/i", $url)) {
            if (eZSys::osType() != 'win32') {
                $url = trim(preg_replace("/^mailto:(.+)/i", "\\1", $url));
                list($userName, $host) = explode('@', $url);
                list($host, $junk) = explode('?', $host);
                $dnsCheck = checkdnsrr($host, "MX");
                if (!$dnsCheck) {
                    if ($isValid) {
                        eZURL::setIsValid($linkID, false);
                    }
                    $cli->output($cli->stylize('warning', "invalid"));
                } else {
                    if (!$isValid) {
                        eZURL::setIsValid($linkID, true);
                    }
                    $cli->output($cli->stylize('success', "valid"));
                }
/**
* NOTE: What if other data is also in the db? Either we do not convert it and
*       have it most likely corrupted, or we convert it - and leave to the client
*       for the other apps to set up NLS_LANG correctly to keep working.
*
*       We could use the csalter script iff we where sure that db version was > 9...
*
*       Oracle 9 exp exports data using the DB charset
*
* From http://www.experts-exchange.com/Database/Oracle/Q_22836430.html

May be the best procedure is the following one:
On PROD Database:
1. export full=y rows=n file=export_db_structure.dmp
2. export full=y file=export_db_date.dmp
On TEST Database:
1. create tablespaces with the same name on PROD
2. import full=y file=export_db_structure.dmp ignore=y
Now we have users of PROD, on TEST database. SYSTEM user is not imported, because already exists.
3. import fromuser=user1,user2,user3 touser=user1,user2,user3  file=export_db_data.dmp ignore=y
now we have user1..3 data on their tables...

*       Unfortunately even if we do that, Oracle will nto let us convert a db from
*       latin1 to utf8 charsets. The only way is to drop the db and creater it
*       from scratch. Since we have no clue about db storage, we will let the admin
*       take care of that part, and only do the export/import parts.
*
* @todo oracle servers might use UTF8 charset instead of AL32UTF8: check before executing!
*
* @todo using dbname as file name does not work with easy conection naming
*
* @todo log somewhere results of imp, exp commands for better understanding of errors
*/
function changeDBCharsetORACLE($charset, $collation)
{
    global $db, $oracleDbaAccount, $oracleHome, $eZDir;
    //$db = eZDB::instance( false, array( 'user' => $oracleDbaAccount['user'], 'password' => $oracleDbaAccount['password'] ), true );
    // since we are here, we should be connected with a dba account (extra conditions check did it)
    $oracleCharset = $db->arrayQuery("select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET'");
    $oracleCharset = $oracleCharset[0]['value'];
    //$oracleLocale = $db->arrayQuery("select language||'_'||territory as locale from (select value as language from nls_database_parameters where parameter = 'NLS_LANGUAGE'), (select value as territory from nls_database_parameters where parameter = 'NLS_TERRITORY')");
    //$oracleLocale = $oracleLocale[0]['locale'];
    /*$users = $db->arrayQuery("select username from all_users where username not in ('SYS', 'SYSTEM')");
      $oracleUsers = array();
      foreach( $users as $row )
      {
          $oracleUsers[] = $row['username'];
      }*/
    if ($oracleCharset == 'AL32UTF8') {
        // lucky case: client was configued to use another charset, but db was internally utf8 already!
        showMessage3("  database charset is already UTF8: skipping.");
    } else {
        // get database name
        $dbName = $db->DB;
        //$dbversion = $db->databaseServerVersion();
        // get connection params
        //$host = $db->Server;
        //$port = $db->Port;
        //$user = $db->User;
        //$pass = $db->Password;
        $connectionParams = $oracleDbaAccount['user'] . '/' . $oracleDbaAccount['password'] . "@{$dbName}";
        // get temporary dir to store dumps
        $ini = eZINI::instance();
        $dumpDir = $ini->variable('FileSettings', 'TemporaryDir') . basename(__FILE__, '.php');
        $dumpFile1 = $dbName . "_structure_export.dmp";
        $dumpPath1 = "{$dumpDir}/{$dumpFile1}";
        $dumpFile2 = $dbName . "_full_export.dmp";
        $dumpPath2 = "{$dumpDir}/{$dumpFile2}";
        $commandPath = "{$dumpDir}/{$dbName}" . "_cmd.sql";
        $logPath = "{$dumpDir}/{$dbName}" . "_cmd.log";
        $users = implode(',', $oracleUsers);
        //$ora_charset = "";
        // prepare utility commands
        $exe = eZSys::osType() == 'win32' ? '.exe' : '';
        $exec = eZSys::osType() == 'win32' ? '' : './';
        $expdb1 = "{$exec}exp{$exe} {$connectionParams} CONSISTENT=Y FULL=Y ROWS=N  FILE={$dumpPath1}";
        $expdb2 = "{$exec}exp{$exe} {$connectionParams} CONSISTENT=Y FULL=Y FILE={$dumpPath2}";
        $impdb1 = "{$exec}imp{$exe} {$connectionParams} FULL=Y IGNORE=Y BUFFER=30960 FILE={$dumpPath1}";
        $impdb2 = "{$exec}imp{$exe} {$connectionParams} FROMUSER={$users} TOUSER={$users} IGNORE=Y BUFFER=30960 FILE={$dumpPath2}";
        /*
        $alterdb = "SET ECHO ON
        SPOOL $logPath;
        WHENEVER SQLERROR EXIT FAILURE;
        WHENEVER OSERROR EXIT FAILURE;";
        if ( $dbversion['string'][0] == '8' )
        {
            /// @todo: check if using oracle < 8.1.5: we have touse svrmgrl then, as sqlplus was not good enough yet
            $sqlplus = "{$exec}sqlplus{$exe} $connectionParams";
            $alterdb .= "
        CONNECT $connectionParams AS SYSDBA";
        }
        else
        {
            $sqlplus = "{$exec}sqlplus{$exe} -L $connectionParams as sysdba";
        }
        
        //$dropdb = "dropdb $connectionParams";
        //$createdb = "createdb $connectionParams";
        foreach( $oracleUsers as $user )
        {
            $alterdb .= "
        DROP USER $user CASCADE;";
        }
        $alterdb .= "
        SHUTDOWN IMMEDIATE;
        STARTUP MOUNT;
        ALTER SYSTEM ENABLE RESTRICTED SESSION;
        ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
        ALTER SYSTEM SET AQ_TM_PROCESSES=0;
        ALTER DATABASE OPEN;
        ALTER DATABASE CHARACTER SET AL32UTF8;
        SHUTDOWN IMMEDIATE; -- or SHUTDOWN NORMAL;
        STARTUP;
        EXIT;
        ";
        */
        // finalizing changes. Note that since we asked for admin connection before,
        // disconnecting and reconnecting, this is surely a NOOP
        //showMessage3( 'finalizing current changes' );
        //$db->commit();
        /// @todo add a database logfile switch or checkpoint here? it would be nice...
        // close current connection
        $db->close();
        showMessage3('  sleeping..');
        sleep(5);
        // dump db
        showMessage3("  taking the db dump, tmp storage is '{$dumpPath1}', '{$dumpPath2}'");
        eZDir::mkdir($dumpDir, false, true);
        chdir($oracleHome . '/bin');
        eZExecuteShellCommand($expdb1, "failed to dump db schema. tried command '{$expdb1}'", true, true);
        eZExecuteShellCommand($expdb2, "failed to dump db data. tried command '{$expdb2}'", true, true);
        chdir($eZDir);
        // verify that dump files exist
        if (!file_exists($dumpPath1) || !file_exists($dumpPath2)) {
            showError("DB Dump files cannot be found. Aborting...");
        }
        /*
        showMessage3( "altering db with charset '$charset'" );
        $command = $sqlplus . " @$commandPath";
        file_put_contents( $commandPath, $alterdb );
        eZExecuteShellCommand( $command, "failed to alter db. tried command '$command'");
        */
        showMessage3('');
        showMessage3("Now you will have to alter the database character set.");
        showMessage3("The recommended way is to create a new database from scratch");
        showMessage3("using AL32UTF8 as character set (THIS IS VERY IMPORTANT),");
        showMessage3("and delete the existing one.");
        showMessage3("The new database should be empty (all schemas will be recreated by this script)");
        showMessage3("and have the same DBA account as the old one.");
        showMessage3("It should also use the same connect identifier as the old one.");
        showMessage3('');
        showMessage3("PLEASE do not terminate this php script while doing that,");
        showMessage3("use a different command line shell.");
        showMessage3('');
        $continue = eZGetUserInput("Press Y when you are ready to continue... ");
        if ($continue != 'y' && $continue != 'Y') {
            showError("Aborting");
        }
        // connect to new db with dba account, check that charset is OK
        while (true) {
            $db = eZDB::instance(false, array('user' => $oracleDbaAccount['user'], 'password' => $oracleDbaAccount['password']), true);
            if (!$db->isConnected()) {
                showWarning("Cannot connect to the new database.\n" . "Please check that it is up and running before continuing");
            } else {
                $oracleCharset = $db->arrayQuery("select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET'");
                $oracleCharset = $oracleCharset[0]['value'];
                $db->close();
                if ($oracleCharset == 'AL32UTF8') {
                    break;
                } else {
                    showWarning("The new database uses the {$oracleCharset} character set instead of AL32UTF8.\n" . "Please recreate the database using AL32UTF8 before continuing");
                }
            }
            $continue = eZGetUserInput("Press Y when you are ready to continue. Any other letter to abort ");
            if ($continue != 'y' && $continue != 'Y') {
                showError("Aborting");
            }
        }
        // restore dump into newly created db
        showMessage3("  restoring db dump");
        chdir($oracleHome . '/bin');
        eZExecuteShellCommand($impdb1, "failed to restore db dump. tried command '{$impdb1}'");
        eZExecuteShellCommand($impdb2, "failed to restore db dump. tried command '{$impdb2}'");
        chdir($eZDir);
        showMessage3("  cleaning up");
        // clean up
        eZDir::recursiveDelete($dumpPath1);
        eZDir::recursiveDelete($dumpPath2);
    }
    // re-initialize db interface, *** this time in UTF8 - with the standard user ***
    $db = eZDB::instance(false, array('charset' => 'utf8'), true);
    if (!$db->isConnected()) {
        showError("Cannot reconnect to DB. Aborting...");
    }
    //$db->begin();
}