diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php index 5532d00a..84abf502 100644 --- a/scripts/pi-hole/php/teleporter.php +++ b/scripts/pi-hole/php/teleporter.php @@ -89,7 +89,7 @@ function archive_restore_table($file, $table, $flush=false) { $tableExists = $db->querySingle("SELECT name FROM sqlite_master WHERE type='table' AND name='".$table."';"); if ($tableExists) - { + { $db->exec("DELETE FROM \"".$table."\""); array_push($flushed_tables, $table); } @@ -354,6 +354,7 @@ if(isset($_POST["action"])) } $fullfilename = sys_get_temp_dir()."/".$filename; + if(!move_uploaded_file($source, $fullfilename)) { die("Failed moving ".htmlentities($source)." to ".htmlentities($fullfilename)); @@ -603,7 +604,10 @@ else $hostname = gethostname() ? str_replace(".", "_", gethostname())."-" : ""; $tarname = "pi-hole-".$hostname."teleporter_".date("Y-m-d_H-i-s").".tar"; $filename = $tarname.".gz"; - $archive_file_name = sys_get_temp_dir() ."/". $tarname; + $archive_file_name = tempnam(sys_get_temp_dir(), 'pihole_teleporter_'); //create a random file name in the system's tmp dir for the intermediat archive + unlink($archive_file_name); //remove intermediate file created by tempnam() + $archive_file_name .= ".tar"; // Append ".tar" extension + $archive = new PharData($archive_file_name); if ($archive->isWritable() !== TRUE) {