PclZip::delete PHP Method

delete() public method

--------------------------------------------------------------------------------
public delete ( )
    public function delete()
    {
        $v_result = 1;
        // ----- Reset the error handler
        $this->privErrorReset();
        // ----- Check archive
        if (!$this->privCheckFormat()) {
            return 0;
        }
        // ----- Set default values
        $v_options = array();
        // ----- Look for variable options arguments
        $v_size = func_num_args();
        // ----- Look for arguments
        if ($v_size > 0) {
            // ----- Get the arguments
            $v_arg_list = func_get_args();
            // ----- Parse the options
            $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(PCLZIP_OPT_BY_NAME => 'optional', PCLZIP_OPT_BY_EREG => 'optional', PCLZIP_OPT_BY_PREG => 'optional', PCLZIP_OPT_BY_INDEX => 'optional'));
            if ($v_result != 1) {
                return 0;
            }
        }
        // ----- Magic quotes trick
        $this->privDisableMagicQuotes();
        // ----- Call the delete fct
        $v_list = array();
        if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
            $this->privSwapBackMagicQuotes();
            unset($v_list);
            return 0;
        }
        // ----- Magic quotes trick
        $this->privSwapBackMagicQuotes();
        // ----- Return
        return $v_list;
    }

Usage Example

 public function removeConfigFile()
 {
     if (!$this->file || !file_exists($this->file)) {
         return false;
     }
     if ($this->archiver != null) {
     } else {
         if ($this->checkZipConsole()) {
             //todo: implement
         } else {
             if ($this->checkZipSupport()) {
                 $zip = new ZipArchive();
                 $zipRes = $zip->open($this->file);
                 if ($zipRes) {
                     $zip->deleteName('wp-config.php');
                     $zip->deleteName('clone');
                     $zip->close();
                     return true;
                 }
                 return false;
             } else {
                 //use pclzip
                 $zip = new PclZip($this->file);
                 $list = $zip->delete(PCLZIP_OPT_BY_NAME, 'wp-config.php');
                 $list2 = $zip->delete(PCLZIP_OPT_BY_NAME, 'clone');
                 if ($list == 0) {
                     return false;
                 }
                 return true;
             }
         }
     }
     return false;
 }
All Usage Examples Of PclZip::delete