Пример #1
0
 function getFileList($p_filelist)
 {
     $startTime = microtime(true);
     $v_result = 1;
     // ----- Reset the error handler
     $this->privErrorReset();
     // ----- Set default values
     $v_options = array();
     $v_options[IWP_PCLZIP_OPT_NO_COMPRESSION] = FALSE;
     $v_options[IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15 * 1024 * 1024 * 1024;
     // ----- Look for variable options arguments
     $v_size = func_num_args();
     // ----- Look for arguments
     if ($v_size > 1) {
         // ----- Get the arguments
         $v_arg_list = func_get_args();
         // ----- Remove form the options list the first argument
         array_shift($v_arg_list);
         $v_size--;
         // ----- Look for first arg
         if (is_integer($v_arg_list[0]) && $v_arg_list[0] > 77000) {
             // ----- Parse the options
             $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(IWP_PCLZIP_OPT_REMOVE_PATH => 'optional', IWP_PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', IWP_PCLZIP_OPT_ADD_PATH => 'optional', IWP_PCLZIP_CB_PRE_ADD => 'optional', IWP_PCLZIP_CB_POST_ADD => 'optional', IWP_PCLZIP_OPT_NO_COMPRESSION => 'optional', IWP_PCLZIP_OPT_COMMENT => 'optional', IWP_PCLZIP_OPT_ADD_COMMENT => 'optional', IWP_PCLZIP_OPT_PREPEND_COMMENT => 'optional', IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', IWP_PCLZIP_OPT_TEMP_FILE_ON => 'optional', IWP_PCLZIP_OPT_TEMP_FILE_OFF => 'optional', IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE => 'optional', IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional', IWP_PCLZIP_OPT_HISTORY_ID => 'optional', IWP_PCLZIP_OPT_IWP_EXCLUDE => 'optional', IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT => 'optional'));
             if ($v_result != 1) {
                 return 0;
             }
         } else {
             // ----- Get the first argument
             $v_options[IWP_PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
             // ----- Look for the optional second argument
             if ($v_size == 2) {
                 $v_options[IWP_PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
             } else {
                 if ($v_size > 2) {
                     // ----- Error log
                     IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
                     // ----- Return
                     return 0;
                 }
             }
         }
     }
     // ----- Look for default option values
     $this->privOptionDefaultThreshold($v_options);
     // ----- Init
     $v_string_list = array();
     $v_att_list = array();
     $v_filedescr_list = array();
     $p_result_list = array();
     // ----- Look if the $p_filelist is really an array
     if (is_array($p_filelist)) {
         // ----- Look if the first element is also an array
         //       This will mean that this is a file description entry
         if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
             $v_att_list = $p_filelist;
         } else {
             $v_string_list = $p_filelist;
         }
     } else {
         if (is_string($p_filelist)) {
             // ----- Create a list from the string
             $v_string_list = explode(IWP_PCLZIP_SEPARATOR, $p_filelist);
         } else {
             IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '" . gettype($p_filelist) . "' for p_filelist");
             return 0;
         }
     }
     // ----- Reformat the string list
     if (sizeof($v_string_list) != 0) {
         foreach ($v_string_list as $v_string) {
             $v_att_list[][IWP_PCLZIP_ATT_FILE_NAME] = $v_string;
         }
     }
     // ----- For each file in the list check the attributes
     $v_supported_attributes = array(IWP_PCLZIP_ATT_FILE_NAME => 'mandatory', IWP_PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional', IWP_PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional', IWP_PCLZIP_ATT_FILE_MTIME => 'optional', IWP_PCLZIP_ATT_FILE_CONTENT => 'optional', IWP_PCLZIP_ATT_FILE_COMMENT => 'optional');
     foreach ($v_att_list as $v_entry) {
         $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes);
         if ($v_result != 1) {
             return 0;
         }
     }
     // ----- Expand the filelist (expand directories)
     $startTImeForlist = microtime(true);
     $prevFileList = array();
     $next_file_index = 0;
     $complete_folder_list = array();
     $historyID = $v_options[IWP_PCLZIP_OPT_HISTORY_ID];
     if ($historyID) {
         $backupObj = new IWP_MMB_Backup_Multicall();
         $responseParams = $backupObj->getRequiredData($historyID, "responseParams");
     }
     if (!empty($responseParams)) {
         $prevFileList = isset($responseParams['response_data']['p_filedescr_list']) ? $responseParams['response_data']['p_filedescr_list'] : array();
         $next_file_index = isset($responseParams['response_data']['next_file_index']) ? $responseParams['response_data']['next_file_index'] : 0;
         $complete_folder_list = isset($responseParams['response_data']['complete_folder_list']) ? $responseParams['response_data']['complete_folder_list'] : array();
     } else {
     }
     if (!$prevFileList) {
         $prevFileList = array();
     }
     if (!$next_file_index) {
         $next_file_index = 0;
     }
     if (!$complete_folder_list) {
         $complete_folder_list = array();
     }
     $new_complete_folder_list = array();
     $folder_list_result = array();
     manual_debug('', 'pclbeforeGettingFileListFirst', 0);
     //if(empty($complete_folder_list))
     if (true) {
         global $total_count;
         $old_next_file_index = $next_file_index;
         /* $folder_list_result = $this->getFolderListManual('F:\\wamp\\www\\plugin_for_bugs/wp-dark/', $v_options, $next_file_index);
         		if(!empty($folder_list_result) && $folder_list_result['break']){
         			$next_file_index = $folder_list_result['loop_count'];
         		} */
         //first am getting the number of directories and its list
         foreach ($v_filedescr_list as $value) {
             $folder_list = array();
             if (is_dir($value['filename'])) {
                 //$folder_list = $this->getFolderList($value['filename']);
                 $folder_list_result = $this->getFolderListManual($value['filename'], $v_options, $old_next_file_index);
                 if (!empty($folder_list_result) && $folder_list_result['break']) {
                     $next_file_index = $folder_list_result['loop_count'];
                     break;
                 }
             } else {
                 global $total_count;
                 $folder_list_result = $this->fileDetailsExpandManual($value['filename'], $v_options, $next_file_index);
                 if (!empty($folder_list_result) && $folder_list_result['break']) {
                     $next_file_index = $folder_list_result['loop_count'];
                     break;
                 }
             }
         }
     }
     if (empty($folder_list_result)) {
         $next_file_index = 0;
     }
     $timeTaken65 = microtime(true) - $startTImeForlist;
     manual_debug('', 'pclAfterGettingFileListFirst', 0);
     //for the file list prepared am doing the pclZip file preparation
     //manual_debug('', 'pclbeforeGettingFileListSecond', 0);
     $prevlistCount = count($prevFileList);
     $current_file_array = array();
     $current_file_array = $prevFileList;
     $file_list_result = array();
     $file_list_result['status'] = 'completed';
     $file_list_result['next_file_index'] = $next_file_index;
     if (!empty($folder_list_result) && !empty($folder_list_result['break'])) {
         $file_list_result['status'] = 'partiallyCompleted';
         $file_list_result['next_file_index'] = $next_file_index + 1;
     }
     $file_list_result['p_filedescr_list'] = array();
     global $total_FL_count;
     $file_list_result['total_FL_count'] = $total_FL_count;
     if ($v_result != 1) {
         return 0;
     }
     // ----- Call the create fct
     /* $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
        if ($v_result != 1) {
          return 0;
        } */
     // ----- Return
     //return $file_list_iwp;
     return $file_list_result;
 }
Пример #2
0
 function getFileList($p_filelist)
 {
     $startTime = microtime(true);
     $v_result = 1;
     // ----- Reset the error handler
     $this->privErrorReset();
     // ----- Set default values
     $v_options = array();
     $v_options[IWP_PCLZIP_OPT_NO_COMPRESSION] = FALSE;
     $v_options[IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE] = 15 * 1024 * 1024 * 1024;
     // ----- Look for variable options arguments
     $v_size = func_num_args();
     // ----- Look for arguments
     if ($v_size > 1) {
         // ----- Get the arguments
         $v_arg_list = func_get_args();
         // ----- Remove form the options list the first argument
         array_shift($v_arg_list);
         $v_size--;
         // ----- Look for first arg
         if (is_integer($v_arg_list[0]) && $v_arg_list[0] > 77000) {
             // ----- Parse the options
             $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(IWP_PCLZIP_OPT_REMOVE_PATH => 'optional', IWP_PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', IWP_PCLZIP_OPT_ADD_PATH => 'optional', IWP_PCLZIP_CB_PRE_ADD => 'optional', IWP_PCLZIP_CB_POST_ADD => 'optional', IWP_PCLZIP_OPT_NO_COMPRESSION => 'optional', IWP_PCLZIP_OPT_COMMENT => 'optional', IWP_PCLZIP_OPT_ADD_COMMENT => 'optional', IWP_PCLZIP_OPT_PREPEND_COMMENT => 'optional', IWP_PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', IWP_PCLZIP_OPT_TEMP_FILE_ON => 'optional', IWP_PCLZIP_OPT_TEMP_FILE_OFF => 'optional', IWP_PCLZIP_OPT_CHUNK_BLOCK_SIZE => 'optional', IWP_PCLZIP_OPT_FILE_EXCLUDE_SIZE => 'optional', IWP_PCLZIP_OPT_HISTORY_ID => 'optional', IWP_PCLZIP_OPT_IWP_EXCLUDE => 'optional', IWP_PCLZIP_OPT_IWP_EXCLUDE_EXT => 'optional'));
             if ($v_result != 1) {
                 return 0;
             }
         } else {
             // ----- Get the first argument
             $v_options[IWP_PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
             // ----- Look for the optional second argument
             if ($v_size == 2) {
                 $v_options[IWP_PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
             } else {
                 if ($v_size > 2) {
                     // ----- Error log
                     IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
                     // ----- Return
                     return 0;
                 }
             }
         }
     }
     // ----- Look for default option values
     $this->privOptionDefaultThreshold($v_options);
     // ----- Init
     $v_string_list = array();
     $v_att_list = array();
     $v_filedescr_list = array();
     $p_result_list = array();
     // ----- Look if the $p_filelist is really an array
     if (is_array($p_filelist)) {
         // ----- Look if the first element is also an array
         //       This will mean that this is a file description entry
         if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
             $v_att_list = $p_filelist;
         } else {
             $v_string_list = $p_filelist;
         }
     } else {
         if (is_string($p_filelist)) {
             // ----- Create a list from the string
             $v_string_list = explode(IWP_PCLZIP_SEPARATOR, $p_filelist);
         } else {
             IWPPclZip::privErrorLog(IWP_PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '" . gettype($p_filelist) . "' for p_filelist");
             return 0;
         }
     }
     // ----- Reformat the string list
     if (sizeof($v_string_list) != 0) {
         foreach ($v_string_list as $v_string) {
             $v_att_list[][IWP_PCLZIP_ATT_FILE_NAME] = $v_string;
         }
     }
     // ----- For each file in the list check the attributes
     $v_supported_attributes = array(IWP_PCLZIP_ATT_FILE_NAME => 'mandatory', IWP_PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional', IWP_PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional', IWP_PCLZIP_ATT_FILE_MTIME => 'optional', IWP_PCLZIP_ATT_FILE_CONTENT => 'optional', IWP_PCLZIP_ATT_FILE_COMMENT => 'optional');
     foreach ($v_att_list as $v_entry) {
         $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes);
         if ($v_result != 1) {
             return 0;
         }
     }
     // ----- Expand the filelist (expand directories)
     $startTImeForlist = microtime(true);
     $prevFileList = array();
     $next_file_index = 0;
     $complete_folder_list = array();
     $historyID = $v_options[IWP_PCLZIP_OPT_HISTORY_ID];
     if ($historyID) {
         $backupObj = new IWP_MMB_Backup_Multicall();
         $responseParams = $backupObj->getRequiredData($historyID, "responseParams");
     }
     if (!empty($responseParams)) {
         $prevFileList = isset($responseParams['response_data']['p_filedescr_list']) ? $responseParams['response_data']['p_filedescr_list'] : array();
         $next_file_index = isset($responseParams['response_data']['next_file_index']) ? $responseParams['response_data']['next_file_index'] : 0;
         $complete_folder_list = isset($responseParams['response_data']['complete_folder_list']) ? $responseParams['response_data']['complete_folder_list'] : array();
     } else {
     }
     if (!$prevFileList) {
         $prevFileList = array();
     }
     if (!$next_file_index) {
         $next_file_index = 0;
     }
     if (!$complete_folder_list) {
         $complete_folder_list = array();
     }
     if (empty($complete_folder_list)) {
         //first am getting the number of directories and its list
         foreach ($v_filedescr_list as $value) {
             $folder_list = array();
             if (is_dir($value['filename'])) {
                 $folder_list = $this->getFolderList($value['filename']);
                 $complete_folder_list = $folder_list;
             } else {
                 $folder_list = $value['filename'];
                 //$folder_list = array_merge($complete_folder_list, array( 0 => array( 0 => $value)));
                 //$folder_list = array_merge($complete_folder_list, $value);
                 $complete_folder_list[][] = $value;
             }
             //$complete_folder_list = $folder_list;
         }
         //then am getting all the files in each folder
         /* $dirs_iwp = array();
         		$files_iwp = array();
         		foreach($complete_folder_list as $value)
         		{
         			if(is_dir($value))
         			{
         				$this->getFilesListForCurrentDir($value, $dirs_iwp, $files_iwp);
         			}
         		} */
     }
     $timeTaken65 = microtime(true) - $startTImeForlist;
     //for the file list prepared am doing the pclZip file preparation
     $prevlistCount = count($prevFileList);
     $current_file_array = array();
     $current_file_array = $prevFileList;
     $file_list_result = array();
     $file_list_result['status'] = 'completed';
     $file_list_result['next_file_index'] = $next_file_index;
     foreach ($complete_folder_list as $keyy => $value) {
         if ($keyy < $next_file_index) {
             continue;
         }
         $current_file_array_temp = $value;
         $v_result = $this->privFileDescrExpand($current_file_array_temp, $v_options, "getFileList");
         if (!empty($current_file_array_temp)) {
             foreach ($current_file_array_temp as $thisVal) {
                 $current_file_array[] = $thisVal;
             }
         }
         unset($current_file_array_temp);
         $endTime = microtime(true);
         $timeTaken = $endTime - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'];
         //if(count($current_file_array) >= ($prevlistCount + 500))
         if ($timeTaken >= 11) {
             $file_list_result['status'] = 'partiallyCompleted';
             $file_list_result['next_file_index'] = $keyy + 1;
             $file_list_result['complete_folder_list'] = $complete_folder_list;
             break;
         } else {
             $file_list_result['next_file_index'] = 0;
         }
         iwp_mmb_auto_print("fileListLoop");
     }
     $file_list_result['p_filedescr_list'] = $current_file_array;
     if ($v_result != 1) {
         return 0;
     }
     // ----- Call the create fct
     /* $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
        if ($v_result != 1) {
          return 0;
        } */
     // ----- Return
     //return $file_list_iwp;
     return $file_list_result;
 }