Article 5AQDR Trying(again) to get shell_exec() to work inside Firefox

Trying(again) to get shell_exec() to work inside Firefox

by
pizzipie
from LinuxQuestions.org on (#5AQDR)
There is something I'm missing or don't just get!!

Process:

# I am using AJAX to call xxx.php(pass 1) which creates a select box.
# Select file and use AJAX to call xxx.php(pass 2)
# If file has extension ".sql.gz" use the shell_exec() function to unzip file
# When file is unzipped use the shell_exec() function to restore the MySql database file.

frontend code:

Code: $(document).ready(function(){
$('#selbox').on('change',function(){
var choice= $("#selbox option:selected").text();
var verify=confirm("Restore - "+choice+"?");
if (verify) {
$.ajax({
type: "POST",
url: "pizselectdb2.php",
data: {"pass":2, "file":choice},
dataType: "text"
})

.done(function (result) {
alert(result);

location.href="PizziFrontEnd.php";
});
} // verify
else {
location.href="PizziFrontEnd.php"
}

}); // change
}); //readyxxx.php code:

Code:elseif($_POST['pass']==2) {

$ext = strstr($filetosav, ".");

if($ext == ".sql.gz") {
$zip="unzip";
}
elseif ($ext == "sql") {
$zip="no-unzip";
}

if($zip == "unzip") {
$cmd="gunzip ".$dir."/".$filetosav;
$x=shell_exec($cmd);

}Problem:shell_exec() function will not execute the command!

See attachment for output of Alert(result).
File directory ownership is www-data:rick as are files within.
Attached Thumbnailsattachment.php?attachmentid=34642&stc=1& latest?d=yIl2AUoC8zA latest?i=x3lDTv7gsFY:ZIjwoZyjYK0:F7zBnMy latest?i=x3lDTv7gsFY:ZIjwoZyjYK0:V_sGLiP latest?d=qj6IDK7rITs latest?i=x3lDTv7gsFY:ZIjwoZyjYK0:gIN9vFwx3lDTv7gsFY
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments