2,3c2,52
< // macos_ffmpeg_convert.php
< // Supervise macOS (via PHP exec) ffmpeg (command line) audio/video conversions
---
> // macos_textutil_convert.php
> // Supervise macOS (via PHP exec) textutil (command line) conversions
> /*
> textutil: [command_option] [other_options] file...
> Command options are (-help is the default):
> -help show this message and exit
> -info display information about each file
> -convert fmt convert each input file to format (txt, rtf, rtfd,
> html, doc, docx, odt, wordml, or webarchive)
> -cat fmt concatenate input files into one output file
> There are some additional optional arguments:
> -extension ext alternate extension for all output files
> -output path alternate file name for first output file
> -stdin read from stdin instead of files
> -stdout send first output file to stdout
> -encoding IANA_name|NSStringEncoding
> encoding used for plain text or html output files
> (default encoding is UTF-8)
> -inputencoding IANA_name|NSStringEncoding
> encoding used to interpret plain text input files
> (by default encoding will be detected from BOM)
> -format fmt force input files to be interpreted in this format
> -font font specify font used for converting plain to rich text
> -fontsize size specify font size for converting plain to rich text
> -- specifies that all further arguments are file names
>
> -noload do not load subsidiary resources for html files
> -nostore do not write out subsidiary resources for html files
> -baseurl url base URL for subsidiary resources in html files
> -timeout t time in seconds to wait for html resources to load
> -textsizemultiplier x
> factor to apply to font sizes in html files
> -excludedelements "(tag1, tag2, ...)"
> html elements to exclude from html output files
> -prefixspaces n
> number of spaces to indent nested html output
>
> -strip do not copy metadata attributes to output files
> -title val title metadata attribute for output files
> -author val author metadata attribute for output files
> -subject val subject metadata attribute for output files
> -keywords "(val1, val2, ...)"
> keywords metadata attribute for output files
> -comment val comment metadata attribute for output files
> -editor val last editor metadata attribute for output files
> -company val company metadata attribute for output files
> -creationtime yyyy-mm-ddThh:mm:ssZ
> creation time metadata attribute for output files
> -modificationtime yyyy-mm-ddThh:mm:ssZ
> modification time metadata attribute for output files
> */
12,18c61,63
< $verb="ffmpeg";
< $switchone="-i";
< $switchtwo="";
<
< if (file_exists("/usr/local/bin/ffmpeg")) {
< $verb="/usr/local/bin/ffmpeg";
< }
---
> $verb="textutil";
> $switchone="-convert";
> $switchtwo="-output";
24,25c69
< $title="
Audio/Video Conversions via ffmpeg ";
< $avtypes="";
---
> $title="Document Conversions via pandoc or textutil ";
27,40d70
< $types = ["audio/x-m4r","audio/wav","audio/x-wav","audio/x-pn-realaudio","audio/x-mpegurl","audio/x-aiff","audio/mpeg","audio/mid",
< "audio/basic","audio/ogg","video/x-sgi-movie","video/x-msvideo","video/quicktime","audio/mp3","video/mp4","video/mpeg",
< "video/x-la-asf","video/ogg","video/webm","audio/mp4", "image/jpeg", "image/jpeg", "image/png", "image/gif", "image/bmp", "image/tif",
< "text/html", "text/html", "text/html", "text/javascript", "text/css", "text/plain", "text/xml", "text/csv",
< "application/vnd.ms-word", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/x-php", "application/pdf",
< "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.ms-powerpoint",
< "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
< $exts = [".m4r",".wav",".wav",".ram",".m3u",".aiff",".mp3",".rmi",
< ".snd",".ogg",".movie",".avi",".mov",".mp3",".m4v",".mpeg",
< ".lsx",".ogv",".webm",".m4a", ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tif",
< ".htm", ".html", ".htmls", ".js", ".css", ".txt", ".xml", ".csv",
< ".doc", ".docx", ".php", ".pdf",
< ".pptx", ".ppt",
< ".xls", ".xlsx"];
41a72,90
> if ( !file_exists( "/usr/local/bin" ) && !is_dir( "/usr/local/bin" ) ) {
> if (get_env("USERPROFILE")) {
> if (file_exists(get_env("USERPROFILE") . "\\AppData\\Local\\Pandoc\\pandoc.exe")) {
> $verb=get_env("USERPROFILE") . "\\AppData\\Local\\Pandoc\\pandoc.exe";
> $switchone="-t";
> $switchtwo="-o";
> $panplus="pandoc or ";
> }
> }
> } else {
> //exec("which pandoc > lookup_pandoc.txt 2>>&1");
> //shell_exec("/usr/local/bin/pandoc --version > lookup_pandoc.txt 2>&1");
> if (file_exists("/usr/local/bin/pandoc")) {
> $verb="/usr/local/bin/pandoc";
> $switchone="-t";
> $switchtwo="-o";
> $panplus="pandoc or ";
> }
> }
47c96
< echo '$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then Audio/Video Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then Audio/Video Output File Extension below ...' . "\n";
---
> echo '$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then *.pdf,*.doc,*.docx,*.htm,*.html,*.txt Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then .pdf,.doc,.docx,.htm,.html,.txt Output File Extension below ...' . "\n";
56c105
< $line = readline('$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then Audio/Video Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) thenAudio/Video Output File Extension below ...' . "\n");
---
> $line = readline('$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then *.pdf,*.doc,*.docx,*.htm,*.html,*.txt Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then .pdf,.doc,.docx,.htm,.html,.txt Output File Extension below ...' . "\n");
64a114,122
> if ($verb != "textutil" && explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] == "pdf") {
> if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) {
> $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex";
> } else if (file_exists("/Library/TeX/texbin/pdflatex")) {
> $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex";
> } else {
> $cmdsuff=" --pdf-engine=pdflatex";
> }
> }
94,99c152,156
< //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err");
< echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err \n");
< exec($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err; cat macos_ffmpeg_convert.err");
< //passthru($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err");
< if (file_exists("macos_ffmpeg_convert.out") && file_exists("macos_ffmpeg_convert.err")) {
< if (7 == 6 && filesize("macos_ffmpeg_convert.out") == 0 && filesize("macos_ffmpeg_convert.err") != 0) {
---
> //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");
> echo ($verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err \n");
> exec($verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");
> if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) {
> if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) {
104c161
< echo "\n\n" . file_get_contents("macos_ffmpeg_convert.err") . "\n\n";
---
> echo "\n\n" . file_get_contents("macos_textutil_convert.err") . "\n\n";
131a189,197
> if ($verb != "textutil" && explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] == "pdf") {
> if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) {
> $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex";
> } else if (file_exists("/Library/TeX/texbin/pdflatex")) {
> $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex";
> } else {
> $cmdsuff=" --pdf-engine=pdflatex";
> }
> }
148,153c214,218
< //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err");
< echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err \n");
< exec($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err; cat macos_ffmpeg_convert.err");
< //passthru($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err");
< if (file_exists("macos_ffmpeg_convert.out") && file_exists("macos_ffmpeg_convert.err")) {
< if (8 == 9 && filesize("macos_ffmpeg_convert.out") == 0 && filesize("macos_ffmpeg_convert.err") != 0) {
---
> //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");
> echo ($verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err \n");
> exec($verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");
> if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) {
> if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) {
158c223
< echo "\n\n" . file_get_contents("macos_ffmpeg_convert.err") . "\n\n";
---
> echo "\n\n" . file_get_contents("macos_textutil_convert.err") . "\n\n";
215c280
< $accfoutext=".m4v";
---
> $accfoutext=".html";
233,240d297
<
< for ($iav=0; $iavConvert to " . strtoupper(substr($types[$iav],0,1)) . str_replace("/"," ",substr($types[$iav],1)) . "";
< }
< }
< }
286c343
< echo "';
---
> echo "';
306,307c363
< //if (PHP_OS == "Darwin" || $verb != "textutil" || isset($_GET['emailanyway'])) {
< if (PHP_OS == "Darwin" || isset($_GET['emailanyway'])) {
---
> if (PHP_OS == "Darwin" || $verb != "textutil" || isset($_GET['emailanyway'])) {
322,346c378,388
< //echo ($verb . " " . $switchone . " " . ourstr_replace("+"," ",$thewords) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err \n");
< exec($verb . " " . $switchone . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err; cat macos_ffmpeg_convert.err");
< //passthru($verb . " " . $switchone . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $cmdsuff . " > macos_ffmpeg_convert.out 2> macos_ffmpeg_convert.err");
<
<
< $thecontent="";
< $mimetypeis="";
< for ($jia=0; $jia" . ourstr_replace("+"," ",$thewords) . " to " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . " via ffmpeg ... " . ourstr_replace("+"," ",$thewords) . " to " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . " via ffmpeg ... <" . explode("/",$mimetypeis)[0] . " controls> " . explode("/",$mimetypeis)[0] . ">