', $cmdis);
$subcmd=explode('-shortest ', trim($precmd[0]));
if (sizeof($subcmd) > 1) {
$outf=$subcmd[1];
if (file_exists($outf)) {
$wassuff='';
while (file_exists($outf . '_was' . $wassuff)) {
if ($wassuff == '') {
$wassuff='0';
} else {
$wassuff='' . (1 + intval('' . $wassuff));
}
}
rename($outf, $outf . '_was' . $wassuff);
}
}
if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$cmdis=str_replace(' > ', ' 2> ', $cmdis);
}
$rs=shell_exec($cmdis);
if ($outf != '') {
if (file_exists($outf)) {
$rs.='
';
if (PHP_OS == "Darwin") {
$rs.='
Video and Audio Files ...
' . str_replace("\n","
",yourshell_exec("file *.* | egrep -B 0 'ISO Media|Audio|WebM|Matroska|.ts:'")) . ' ';
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$rs.='
Video and Audio Files ...
' . str_replace("\n","
",yourshell_exec('"C:\\Program Files (x86)\\GnuWin32\\bin\\file.exe" *.*')) . ' ';
}
}
}
} else if (PHP_OS == "Darwin") {
$rs='Video and Audio Files ...
' . str_replace("\n","
",yourshell_exec("file *.* | egrep -B 0 'ISO Media|Audio|WebM|Matroska|.ts:'")) . ' ';
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$rs='Video and Audio Files ...
' . str_replace("\n","
",yourshell_exec('"C:\\Program Files (x86)\\GnuWin32\\bin\\file.exe" *.*')) . ' ';
}
if (isset($_GET['infilegetsize'])) {
exit;
}
if (isset($_GET['ffmpeg'])) {
$fnd=false;
if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
if (file_exists('./ffmpeg.txt')) {
$pplace=file_get_contents('./ffmpeg.txt');
if (strpos($pplace, 'ffmpeg.exe') !== false) {
$fnd=true;
}
}
if (!$fnd) {
$huhexe=shell_exec("where ffmpeg.exe");
if ($huhexe == '') {
$huhexes=rglob("C:\\ffmpeg.exe"); //shell_exec("where pdfimages.exe");
if (sizeof($huhexes) > 0) {
file_put_contents('./ffmpeg.txt', $huhexes[0]);
if (strpos($huhexes[0], ' ') !== false) {
$huhexes[0]=str_replace('"','',$huhexes[0]);
echo "
";
} else {
$huhexes[0]=str_replace('"','',$huhexes[0]);
echo "";
}
}
}
}
}
exit;
}
$dn='';
$ffmpegpre='';
$ffmpegsuf='';
$whereffmpeg="?infilegetsize=";
if (PHP_OS == "Darwin") {
$dn=' /dev/null';
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
$ffmpegpre="\"C:\\Program Files\\ImageMagick-7.1.0-Q16-HDRI\\";
$ffmpegsuf=".exe\"";
if (!file_exists($ffmpegpre . 'ffmpeg' . $ffmpegsuf)) {
if (file_exists('./ffmpeg.txt')) {
if (!file_exists(file_get_contents('./ffmpeg.txt'))) {
unlink('./ffmpeg.txt');
$whereffmpeg="?ffmpeg=where";
} else {
$ffmpegpre="\"" . str_replace('ffmpeg.exe','',file_get_contents('./ffmpeg.txt')) . "\"";
}
}
if (file_exists('ffmpeg' . $ffmpegsuf)) {
$ffmpegpre="";
} else if (!file_exists('./ffmpeg.txt')) {
$huhexe=shell_exec("where ffmpeg.exe");
if (strpos($huhexe, 'ffmpeg.exe') === false) {
$whereffmpeg="?ffmpeg=where";
} else {
$ffmpegpre=str_replace('ffmpeg.exe','',$huhexe);
}
}
}
$pdfimagespre="\"C:\\MAMP\\htdocs\\xpdf-tools-win-4.04\\bin32\\";
$pdfimagessuf=".exe\"";
if (!file_exists($pdfimagespre . 'pdfimages' . $pdfimagessuf)) {
if (file_exists('./pdfimages.txt')) {
if (!file_exists(file_get_contents('./pdfimages.txt'))) {
unlink('./pdfimages.txt');
$wherepdfimages="?pdfimages=where";
} else {
$pdfimagespre="\"" . str_replace('pdfimages.exe','',file_get_contents('./pdfimages.txt')) . "\"";
}
}
if (file_exists('pdfimages' . $pdfimagessuf)) {
$pdfimagespre="";
} else if (!file_exists('./pdfimages.txt')) {
$huhexe=shell_exec("where pdfimages.exe");
if (strpos($huhexe, 'pdfimages.exe') === false) {
$wherepdfimages="?pdfimages=where";
} else {
$pdfimagespre=str_replace('pdfimages.exe','',$huhexe);
}
}
}
}
function scandir_through($dir, $bname, $bsize) { // thanks to https://www.php.net/manual/en/function.glob.php
$ds=substr((DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR),0,1);
if (strpos(('!@' . strtoupper($dir)), '!@C:') !== false) { $dir=str_replace('/','',$dir); }
if (substr(strrev($dir),0,1) == substr((DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR),0,1)) {
$ds='';
}
$items = glob($dir . $ds . str_replace(' ','*',$bname));
for ($i = 0; $i < count($items); $i++) {
if (is_dir($items[$i])) {
$add = glob($items[$i] . $ds . str_replace(' ','*',$bname));
if (filesize($add) == $bsize) {
//echo $add;
$items = array_merge($items, $add);
} //else {
//echo 'x' . $add . 'x';
//}
}
}
return $items;
}
function yourshell_exec($incm) {
//file_put_contents('xx.xx', $incm);
$blurblines=shell_exec($incm);
//file_put_contents('xxx.xxx', $blurblines);
$outblurb="";
$obs=explode("\n", $blurblines);
for ($iobs=0; $iobs' . explode(';',$obs[$iobs])[0] . ';',$obs[$iobs]) . "\n";
} else {
$outblurb.=str_replace(explode(':',$obs[$iobs])[0] . ':','' . explode(':',$obs[$iobs])[0] . ';',$obs[$iobs]) . "\n";
}
} else if (strpos($obs[$iobs], ';') !== false) {
$outblurb.=str_replace(explode(';',$obs[$iobs])[0] . ';','' . explode(';',$obs[$iobs])[0] . ';',$obs[$iobs]) . "\n";
} else if (strpos($obs[$iobs], ':') !== false) {
$outblurb.=str_replace(explode(':',$obs[$iobs])[0] . ':','' . explode(':',$obs[$iobs])[0] . ';',$obs[$iobs]) . "\n";
} else {
$outblurb.=$obs[$iobs] . "\n";
}
}
}
return $outblurb;
}
function ourshell_exec($onea, $twoa = NULL, $threea = NULL) {
$folder='';
$pattern='';
$size='';
$filesa=[];
if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows' || (strpos(('~@!' . $onea), '~@!forfiles /P "') !== false && strpos(('~@!' . $onea), '/M "') !== false && strpos(('~@!' . $onea), 'find "') !== false)) {
$folder=explode('"', explode('forfiles /P "', $onea)[1])[0]; // . substr(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, 0, 1);
if (7 == 7) {
$folder=explode('"', explode('forfiles /P "', $onea)[1])[0]; // . substr(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, 0, 1);
$pattern=explode('"', explode('/M "', $onea)[1])[0];
$size=explode('"', explode('find "', $onea)[1])[0];
$thiscmd=trim(explode(" | find ", $onea)[0]);
if (strpos($pattern, ' ') === false) { $thiscmd=str_replace('/M "' . $pattern . '"', '/M ' . $pattern, $thiscmd); }
if (strpos($folder, ' ') === false) { $thiscmd=str_replace('/P "' . $folder . '"', '/P ' . $folder, $thiscmd); }
if (strpos($thiscmd, '"cmd /c ') !== false && substr($thiscmd,-1,1) != '"') { $thiscmd.='"'; }
if (strpos($thiscmd, "/P C:\\ ") !== false) {
if (strpos($thiscmd, "/P C:\\ ") !== false) {
if (strpos($pattern, " ") === false) {
$thiscmd="DIR C:\\" . $pattern . " /S /-C";
} else {
$thiscmd="DIR \"C:\\" . $pattern . "\" /S /-C";
}
}
}
//file_put_contents('xxx.xxx',file_get_contents('xxx.xxx'). "\n" . '' . $size . ' ' . $thiscmd);
$nofind=shell_exec($thiscmd . ' 2> nul');
//file_put_contents('xxxx.xxxx',file_get_contents('xxxx.xxxx'). "\n" . '' . $size . ' ' . $nofind);
//exit;
$findings=explode("\n", $nofind);
$bitbefore='';
for ($ifindgs=0; $ifindgs /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
//if ($folder == substr((DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR),0,1)) {
$didea=shell_exec("find \$HOME/Downloads -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
//file_put_contents("xx.ksh", $didea);
if ($didea != '') { return $didea; }
$didea=shell_exec("find " . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
//file_put_contents("xxx.ksh", $didea);
if ($didea != '') { return $didea; }
$xc=getenv('HOME');
if ($xc == '') {
$dirsa = glob('/Users/*', GLOB_ONLYDIR);
for ($ia=0; $ia&1", $outputa, $retz);
$didea=ourshell_exec("forfiles /P \"" . str_replace('//','/',$dirsa[$ia] . "/") . "Downloads\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize | find \"" . $size . "\" 2>&1", $outputa, $retz);
if ($didea != '') { return $didea; }
}
}
if ($didea != '') { return $didea; }
} else {
$didea=ourshell_exec("forfiles /P \"" . $xc . str_replace('//','/',DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . "Downloads\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize | find \"" . $size . "\" 2>&1", $outputa, $retz);
if ($didea != '') { return $didea; }
}
return shell_exec("find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
//file_put_contents('xs8.xs8', '');
$xc=getenv('HOMEDRIVE') . getenv('HOMEPATH');
//file_put_contents('xs88.xs88', $xc);
if ($xc == '') { $xc=getenv('USERPROFILE'); }
//file_put_contents('xs888.xs888', $xc);
$xc='';
if ($xc == '') {
//file_put_contents('xs8888.xs8888', $xc);
$dirsa = glob("C:\\Users\\*", GLOB_ONLYDIR);
for ($ia=0; $ia&1", $outputa, $retz);
if ($didea != '') { return $didea; }
//file_put_contents('xs999.xs999', $dirsa[$ia] . "\\Downloads");
}
}
if ($didea != '') { return $didea; }
} else {
$didea=ourshell_exec("forfiles /P \"" . $xc . str_replace('//','/',DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . "Downloads\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
if ($didea != '') { return $didea; }
}
if ($didea != '') { return $didea; }
//file_put_contents('xs29.xs29', $_SERVER['DOCUMENT_ROOT']);
$didea=ourshell_exec("forfiles /P \"" . $_SERVER['DOCUMENT_ROOT'] . "\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa);
if ($didea != '') { return $didea; }
//file_put_contents('xs39.xs39', 'userp');
$didea=ourshell_exec("forfiles /P \"%USERPROFILE%" . str_replace('//','/',DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . "Downloads\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize | find \"" . $size . "\" 2>&1", $outputa, $retz);
if ($didea != '') { return $didea; }
//$didea=shell_exec('forfiles /P C:' . substr("\\",0,1) . 'Downloads /S /M * /C “cmd /c if @fsize EQU ' . $size . ' if @file EQU ' . $pattern . " echo @path");
//if ($didea != '') { return $didea; }
//$didea=shell_exec('forfiles /P C:' . substr("\\",0,1) . ' /S /M * /C “cmd /c if @fsize EQU ' . $size . ' if @file EQU ' . $pattern . " echo @path 2>nul");
//file_put_contents('xs49.xs49', 'root');
//$didea=ourshell_exec("forfiles /P \"C:" . substr("\\",0,1) . "\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1");
//if ($didea != '') { return $didea; }
$didea=ourshell_exec("forfiles /P \"" . "C:\\\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
if ($didea != '') { return $didea; }
//file_put_contents('xs59.xs59', 'noroot');
}
// echo "QQghfjhg";
//echo "forfiles /P \"" . $_SERVER['DOCUMENT_ROOT'] . "\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize | find \"" . $size . "\" 2>&1";
// exit;
//$iti = new RecursiveDirectoryIterator($folder);
//foreach (new RecursiveIteratorIterator($iti) as $file) {
//foreach (glob($folder . $pattern) as $file) {
// if (strpos($file , $pattern) !== false && filesize($file) == $size) {
// return $file;
// }
//}
return '';
}
// Does not support flag GLOB_BRACE
function rglob($pattern, $flags = 0) { // thanks to https://stackoverflow.com/questions/17160696/php-glob-scan-in-subfolders-for-a-file
$files = glob($pattern, $flags);
foreach (glob(str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR,DIRECTORY_SEPARATOR,dirname($pattern).DIRECTORY_SEPARATOR).'*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge(
[],
[$files, rglob($dir . DIRECTORY_SEPARATOR . basename($pattern), $flags)]
);
}
return $files;
}
function ourbasename($inb) {
return basename(str_replace(' ','_',$inb));
}
function ourrealpath($inb) {
return realpath(str_replace(' ','_',$inb));
}
if (isset($_GET['filename']) && isset($_GET['filesize']) && !isset($_GET['filepath'])) {
//file_put_contents('xj1.xj1','');
if (file_exists(str_replace('+',' ',urldecode($_GET['filename'])))) {
if (filesize(str_replace('+',' ',urldecode($_GET['filename']))) == $_GET['filesize']) {
$filepath=rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['filename']));
//file_put_contents('xj11.xj11','');
}
}
if ($filepath == '') {
$filepath = rsearch(DIRECTORY_SEPARATOR, str_replace('+',' ',urldecode($_GET['filename'])), $_GET['filesize']);
//file_put_contents('xj111.xj111',$filepath);
}
$filepath=str_replace("\n","",$filepath);
if (strpos($filepath, ' ') !== false) {
$filepath='"' . str_replace('"','',$filepath) . '"';
//file_put_contents('xj1111.xj1111','');
}
if (!isset($_GET['inpath'])) {
// echo "";
if (isset($_GET['left'])) {
//file_put_contents('xj11111.xj11111',str_replace("\\","\\\\",$filepath));
//file_put_contents('xj111111.xj111111', "");
echo "";
} else {
echo "";
}
exit;
} else {
$_GET['inpath']=urlencode(str_replace('"','',explode(str_replace('+',' ',urldecode($_GET['filename'])), $filepath)[0]));
//$_GET['convertthis']=$_GET['filename'];
}
} else if (isset($_GET['filename']) && isset($_GET['filesize']) && $_GET['filepath'] == '') {
//file_put_contents('xs0.xs0', '');
if (file_exists(str_replace('+',' ',urldecode($_GET['filename'])))) {
//file_put_contents('xs.xs', '');
if (filesize(str_replace('+',' ',urldecode($_GET['filename']))) == $_GET['filesize']) {
$filepath=rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['filename']));
//file_put_contents('xs.xs1', $filepath);
}
}
if ($filepath == '') {
//file_put_contents('xs.xs3', '');
$filepath = rsearch(DIRECTORY_SEPARATOR, str_replace('+',' ',urldecode($_GET['filename'])), $_GET['filesize']);
//file_put_contents('xs.xs4', $filepath);
}
$filepath=str_replace("\n","",$filepath);
if (strpos($filepath, ' ') !== false) {
$filepath='"' . str_replace('"','',$filepath) . '"';
}
if (!isset($_GET['inpath'])) {
if (isset($_GET['left'])) {
echo "";
} else {
echo "";
}
exit;
} else {
$_GET['inpath']=urlencode(explode(str_replace('+',' ',urldecode($_GET['filename'])), $filepath)[0]);
//$_GET['convertthis']=$_GET['filename'];
}
} else if (isset($_GET['filename']) && isset($_GET['filesize']) && isset($_GET['filepath'])) {
$anyextrac='';
if (substr(str_replace('+',' ',urldecode($_GET['filepath'])), -1, 1) != DIRECTORY_SEPARATOR) {
$anyextrac=DIRECTORY_SEPARATOR;
}
$filepath=str_replace("\n","",$filepath);
if (strpos($filepath, ' ') !== false) {
$filepath='"' . str_replace('"','',$filepath) . '"';
}
if (!isset($_GET['inpath'])) {
if (isset($_GET['left'])) {
echo "";
} else {
echo "";
}
exit;
} else {
$_GET['inpath']=urlencode(str_replace('+',' ',urldecode($_GET['filepath'])) . $anyextac);
//$_GET['convertthis']=$_GET['filename'];
}
}
if ($ffmpegpre != '' && strpos($ffmpegpre, ' ') === false) {
$ffmpegsuf=str_replace('"','',$ffmpegsuf);
$ffmpegpre=str_replace('"','',$ffmpegpre);
}
$crlf="\r\n";
$cr="\r";
$lf="\n";
echo "
Add Voiceover Audio to Video via ffmpeg - RJM Programming - May, 2023
Add Voiceover Audio to Video via ffmpeg
RJM Programming - May, 2023
" . $rs . "
";
?>