Switch from using command line RAR to using RarArchive pecl module
This commit is contained in:
		
							parent
							
								
									d593369c14
								
							
						
					
					
						commit
						8b5949d1d0
					
				| 
						 | 
					@ -8,6 +8,7 @@ $data = array();
 | 
				
			||||||
$data["error"] = false;
 | 
					$data["error"] = false;
 | 
				
			||||||
$data["message"] = "";
 | 
					$data["message"] = "";
 | 
				
			||||||
$data["validated"] = $validated;
 | 
					$data["validated"] = $validated;
 | 
				
			||||||
 | 
					$data["filename"] = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ( !$validated ) {
 | 
					if ( !$validated ) {
 | 
				
			||||||
    $data["error"] = true;
 | 
					    $data["error"] = true;
 | 
				
			||||||
| 
						 | 
					@ -19,6 +20,7 @@ if ( !$validated ) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ( isset($_REQUEST['comic']) ) {
 | 
					if ( isset($_REQUEST['comic']) ) {
 | 
				
			||||||
   $comicfull = realpath(COMICSDIR . base64_decode(urldecode($_REQUEST['comic'])));
 | 
					   $comicfull = realpath(COMICSDIR . base64_decode(urldecode($_REQUEST['comic'])));
 | 
				
			||||||
 | 
					   $data["filename"] = basename($comicfull);
 | 
				
			||||||
   if ( $comicfull === false ) exit();
 | 
					   if ( $comicfull === false ) exit();
 | 
				
			||||||
   if ( substr($comicfull, 0, strlen(COMICSDIR)) != COMICSDIR ) exit();
 | 
					   if ( substr($comicfull, 0, strlen(COMICSDIR)) != COMICSDIR ) exit();
 | 
				
			||||||
   $comic = substr($comicfull, strlen(COMICSDIR));
 | 
					   $comic = substr($comicfull, strlen(COMICSDIR));
 | 
				
			||||||
| 
						 | 
					@ -58,7 +60,7 @@ if ( $ext == "cbz" ) {
 | 
				
			||||||
      //$myext = substr($imgname, -3);
 | 
					      //$myext = substr($imgname, -3);
 | 
				
			||||||
      if ( ! isset(pathinfo($imgname)['extension']) ) continue;
 | 
					      if ( ! isset(pathinfo($imgname)['extension']) ) continue;
 | 
				
			||||||
      $myext = strtolower(pathinfo($imgname)['extension']);
 | 
					      $myext = strtolower(pathinfo($imgname)['extension']);
 | 
				
			||||||
      if ( ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
 | 
					      if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
 | 
				
			||||||
         $imgname = str_replace("#", "", $imgname);
 | 
					         $imgname = str_replace("#", "", $imgname);
 | 
				
			||||||
         $imgcontents = $zip->getFromIndex($i);
 | 
					         $imgcontents = $zip->getFromIndex($i);
 | 
				
			||||||
         $written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
 | 
					         $written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
 | 
				
			||||||
| 
						 | 
					@ -66,20 +68,18 @@ if ( $ext == "cbz" ) {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
} elseif ( $ext == "cbr" ) {
 | 
					} elseif ( $ext == "cbr" ) {
 | 
				
			||||||
   $junk = `/usr/local/bin/rar e -ep -o+ "$comicfull" "$comicoutputfull"`;
 | 
					   $rar = RarArchive::open($comicfull);
 | 
				
			||||||
   $fh = opendir($comicoutputfull);
 | 
					   $entries = $rar->getEntries();
 | 
				
			||||||
   while ( false !== ($file = readdir($fh)) ) {
 | 
					   foreach ( $entries as $entry ) {
 | 
				
			||||||
      $myfile = $comicoutputfull . $file;
 | 
					      $outfile = str_replace("#", "", basename($entry->getName()));
 | 
				
			||||||
      $mynewfile = $comicoutputfull . str_replace("#", "", $file);
 | 
					      $entry->extract(false, $comicoutputfull . $outfile);
 | 
				
			||||||
      //$myext = strtolower(substr($file, -3));
 | 
					      if ( ! isset(pathinfo($outfile)['extension']) ) continue;
 | 
				
			||||||
      if ( ! isset(pathinfo($myfile)['extension']) ) continue;
 | 
					      $myext = strtolower(pathinfo($outfile)['extension']);
 | 
				
			||||||
      $myext = strtolower(pathinfo($myfile)['extension']);
 | 
					      if ( ($myext == "jpeg") || ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
 | 
				
			||||||
      if ( ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
 | 
					         $files[] = basename($outfile);
 | 
				
			||||||
         rename($myfile, $mynewfile);
 | 
					 | 
				
			||||||
         $files[] = basename($mynewfile);
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
   closedir($fh);
 | 
					   unset($entry);
 | 
				
			||||||
} else {
 | 
					} else {
 | 
				
			||||||
   exit();
 | 
					   exit();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user