Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function wp_handle_upload_filter( $array=['file' => 'path/to/wp-content/uploads/2018/12/example.ext', 'url' => 'https://.....example.ext', 'type' => 'application/zip'], $action= 'sideload|upload' )
- {
- $file = $array['file'];
- if($array['type']=="application/zip" || $array['type']=="application/x-zip")
- {
- $filename = basename($file);
- $found = false;
- $found_files=[];
- if (function_exists('zip_open'))
- {
- $zip = zip_open($file);
- if (is_resource($zip))
- {
- while ($zip_entry = zip_read($zip))
- {
- $found_files[]=zip_entry_name($zip_entry);
- //if (zip_entry_open($zip, $zip_entry))
- //{
- //echo zip_entry_read($zip_entry);
- //zip_entry_close($zip_entry);
- //}
- }
- zip_close($zip);
- }
- }
- elseif (class_exists('\ZipArchive'))
- {
- $za = new \ZipArchive();
- $za->open($file);
- for( $i = 0; $i < $za->numFiles; $i++ ){
- $stat = $za->statIndex( $i );
- $found_files[] = basename( $stat['name'] ) ;
- }
- }
- //elseif( stripos($filename, $this->pro_file_part) !== false)
- //{
- // $found = true;
- //}
- //if contains
- if(!empty($found_files))
- {
- foreach(array_filter($found_files) as $each)
- {
- if( stripos($each, $this->addon_namepart.'/'.$this->slug)!==false)
- {
- $found = true;
- }
- }
- }
- if($found)
- {
- $this->helpers->unzip($file, $this->addons_dir);
- $this->helpers->move_folder_contents($this->addons_dir.'/'. $this->addon_namepart, $this->addons_dir);
- $this->helpers->rmdir_recursive($this->addons_dir.'/'. $this->addon_namepart);
- $need_space = stripos($_SERVER['REQUEST_URI'], 'upload.php') !== false ? '�?�?�?�?�?�?�?�?' : '';
- return ['error'=> $need_space."Thank You �? Addon has been installed, you can activate it with the key !"];
- }
- }
- return $array;
- }
Advertisement
Add Comment
Please, Sign In to add comment