create_rar_archive.php

<?php

function createRarArchive($archive_name,
                          
$file_name,
                          
$password FALSE,
                          
$security 'none'){



        if (
$password && ($security != 'encrypt')){
          
$security 'password';
          }
          

        
$command 'rar a';


        switch(
$security){
          case 
'password' $command.= " -p{$password}";
          break;
          case 
'encrypt' $command.= " -hp{$password}";
          break;
        }


        
// add archive location (TO BE REPLACED BY $ARCHIVE_NAME)
        
$command.= " c:/test/test";

        
// add file to archive
        
$command.= " ".$file_name;

        
$cwd getcwd();

        
// change working directory to the WinRAR directory
        
chdir('c:/program files/winrar');

        
// execute WinRAR command
        
$res shell_exec($command);

        echo 
$res;

        
// restore working directory to webroot
        
chdir($cwd);


}


createRarArchive('archive.rar','C:/test/stopwords.csv''pass','encrypt');






?>

Paul's Code Library

Categories

Home

AJAX

classes

database_functions

date_functions

file_functions

googlevideo_and_youtube_api

htaccess

image_functions

string_functions