Walking Trip …

Walking Trip

Walking Trip

Offenbach's Suite ... Warts 'n All

Offenbach's Suite ... Warts 'n All

 📅  

If this was interesting you may be interested in this too.

Posted in Photography, Trips | Tagged , , | 34 Comments

Document Root Relative Folder Listing Media Pairings Tutorial

Document Root Relative Folder Listing Media Pairings Tutorial

Document Root Relative Folder Listing Media Pairings Tutorial

Onto the day before yesterday’s Document Root Relative Folder Listing Links Video Tutorial, and it’s work with …

  • “assemblies” … as an image media multiple selection (set of “widget”) ideas … as per list below … it’s time, today, to remember Document Root Relative Folder Listing Links Assemblies Tutorial‘s …

    To us, these are user driven (is it widgets) they create by selecting multiple media (today images, but down the line, other combinations) from the left hand table cell’s listing links.

    … and it’s invitation to broaden the scope … so that today we start down the road towards the concept of what we’ll call …

  • “assembly media pairings” … where, so far, two, media selections get used to create another “widget” creation … so far …

… trying …

  1. audio and video … ffmpeg helps add an audio soundtrack onto a video
  2. text and image … textarea element with image background
  3. audio and image … audio element with image background
  4. video and image … video element with image background

… using the PHP …

<?php

if (isset($_GET['nonims']) && isset($_GET['nonimsname'])) {
$htmlassembly='';
$vis='';
$tis='';
$mis='';
$sis='';
$zis='';
$iis='';
$listis=str_replace('+',' ',urldecode($_GET['nonims']));
$hashis='';
if (strpos($listis, '#') !== false) {
if (strpos(str_replace('#audio/','',str_replace('#video/','',$listis)), '#') === false) {
// ffmpeg -i video.mp4 -i audio.aac -c:v copy -c:a copy output.mp4
$vis=$_SERVER['DOCUMENT_ROOT'] . explode(',', explode('#video/', $listis)[0])[-1 + sizeof( explode(',', explode('#video/', $listis)[0]))];
$ais=$_SERVER['DOCUMENT_ROOT'] . explode(',', explode('#audio/', $listis)[0])[-1 + sizeof( explode(',', explode('#audio/', $listis)[0]))];
//file_put_contents('xx.xx',$fconvprefix . 'ffmpeg -i ' . $vis . ' -i ' . $ais . ' -c:v copy -c:a copy ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
//exec($fconvprefix . 'ffmpeg -i ' . $vis . ' -i ' . $ais . ' -c:v copy -c:a copy ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))) . ' 2> ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . "x.err" . ' > ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . "x.ok");
exec($fconvprefix . 'ffmpeg -i ' . $vis . ' -i ' . $ais . ' -c:v copy -c:a copy ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
} else if (strpos(str_replace('#text/','',str_replace('#image/','',$listis)), '#') === false) {
$mis=str_replace('jpg','jpeg',explode(',',explode('#image/', $listis)[1])[0]);
$tis=$_SERVER['DOCUMENT_ROOT'] . explode(',', explode('#text/', $listis)[0])[-1 + sizeof( explode(',', explode('#text/', $listis)[0]))];
$iis=$_SERVER['DOCUMENT_ROOT'] . explode(',', explode('#image/', $listis)[0])[-1 + sizeof( explode(',', explode('#image/', $listis)[0]))];
} else if (strpos(str_replace('#audio/','',str_replace('#image/','',$listis)), '#') === false) {
$mis=str_replace('jpg','jpeg',explode(',',explode('#image/', $listis)[1])[0]);
$ais=str_replace('jpg','jpeg',explode(',',explode('#audio/', $listis)[1])[0]);
$sis=$_SERVER['DOCUMENT_ROOT'] . explode(',', explode('#audio/', $listis)[0])[-1 + sizeof( explode(',', explode('#audio/', $listis)[0]))];
$iis=$_SERVER['DOCUMENT_ROOT'] . explode(',', explode('#image/', $listis)[0])[-1 + sizeof( explode(',', explode('#image/', $listis)[0]))];
} else if (strpos(str_replace('#video/','',str_replace('#image/','',$listis)), '#') === false) {
$mis=str_replace('jpg','jpeg',explode(',',explode('#image/', $listis)[1])[0]);
$ais=str_replace('jpg','jpeg',explode(',',explode('#video/', $listis)[1])[0]);
$zis=$_SERVER['DOCUMENT_ROOT'] . explode(',', explode('#video/', $listis)[0])[-1 + sizeof( explode(',', explode('#video/', $listis)[0]))];
$iis=$_SERVER['DOCUMENT_ROOT'] . explode(',', explode('#image/', $listis)[0])[-1 + sizeof( explode(',', explode('#image/', $listis)[0]))];
}
}
$origname=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['nonimsname']));
//file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['nonimsname'])), $htmlassembly);
//if (strpos(('' . $origname . '~'), '.cba~') !== false && $origname != $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['nonimsname']))) {
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['nonimsname'])));
//}
if ($zis != '') {
echo '<html><body style="background:linear-gradient(rgba(255,255,255,0.6),rgba(255,255,255,0.6)),url(data:image/' . $mis . ';base64,' . base64_encode(file_get_contents($iis)) . ');background-repeat:no-repeat;background-size:contain;background-position:right top;"><video style=opacity:0.7; controls><source type=video/' . $ais . ' src="data:video/' . $ais . ';base64,' . base64_encode(file_get_contents($zis)) . '"></source></video></body></html>';
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
} else if ($sis != '') {
echo '<html><body style="background:url(data:image/' . $mis . ';base64,' . base64_encode(file_get_contents($iis)) . ');background-repeat:no-repeat;background-size:contain;background-position:right bottom;"><audio controls><source type=audio/' . $ais . ' src="data:audio/' . $ais . ';base64,' . base64_encode(file_get_contents($sis)) . '"></source></audio></body></html>';
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
} else if ($tis != '') {
echo '<html><body><textarea style="text-shadow:-1px 1px 1px #ff2d95;width:99%;height:99%;background:linear-gradient(rgba(255,255,255,0.6),rgba(255,255,255,0.6)),url(data:image/' . $mis . ';base64,' . base64_encode(file_get_contents($iis)) . ');background-repeat:no-repeat;background-size:contain;">' . file_get_contents($tis) . '</textarea></body></html>';
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
} else if ($vis != '') {
if (531 == 53) {
echo '<html><body><video style=width:80%; controls><source type=video/mp4 src="' . str_replace($_SERVER['DOCUMENT_ROOT'],'',$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname']))))) . '"></source></video></body></html>';
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
} else if (5 == 5) {
echo '<html><body><video style=width:80%; controls><source type=video/mp4 src="data:video/mp4;base64,' . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))))) . '"></source></video></body></html>';
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
} else if (1 == 1) {
//file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_GET['nonimsname'])), $htmlassembly);

// header video/mp4
header('Content-Type: video/mp4');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname']))))));
header("Content-Disposition: inline; filename=" . basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname']))))));
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('.cba','.mp4',basename(str_replace('+',' ',urldecode($_GET['nonimsname'])))));
exit;

} else {
echo "<html><body onload=\"var woowoo=window.open('','_blank','top=200,left=200,width=500,height=500'); woowoo.document.write('<html><body>" . $htmlassembly . "</body></html>');\"></body></html>";
}
}
exit;
}

?>

… along the way in the “twelfth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below.


Previous relevant Document Root Relative Folder Listing Links Video Tutorial is shown below.

Document Root Relative Folder Listing Links Video Tutorial

Document Root Relative Folder Listing Links Video Tutorial

Onto yesterday’s Document Root Relative Folder Listing Links Animated GIF Tutorial‘s “assembly” list of …

  • Javascript (setTimeout) image animation
  • PDF
  • PowerPoint
  • Word
  • Animated GIF … today, we present …
  • Video

… “assembly” functionality, turning to the great ffmpeg product’s command line …


ffmpeg -f concat -safe 0 -i list.txt -r 25 -pix_fmt yuv420p output.mp4

… used within the procedure involving our Document Root Relative Folder Listing web application …

  • we open within a popup window in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Video *.mp4 data via (exec called) …

    ffmpeg -f concat -safe 0 -i list.txt -r 25 -pix_fmt yuv420p output.mp4

    … and from there …
  • the PHP uses the header arrangements
    <?php

    if (isset($_GET['avideolist']) && isset($_GET['avideoname'])) {
    $dname="input.mp4";
    $_GET['avideolist']=oururlencode($_GET['avideolist']);
    $themd=str_replace(",","'\nduration 10\nfile '" . $_SERVER['DOCUMENT_ROOT'], "file '" . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['avideolist']))) . "'";
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".mp4",".vvv",str_replace('+',' ',urldecode($_GET['avideoname'])))), $themd);
    exec($fconvprefix . 'ffmpeg -f concat -safe 0 -i ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".mp4",".vvv",str_replace('+',' ',urldecode($_GET['avideoname'])))) . ' -r 25 -pix_fmt yuv420p ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))));
    $hsofar="<html><body><video controls><source src=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['avideoname']))) . "\" type=\"video/mp4\" data-base=data:video/mp4;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))))) . "></source></video></body></html>";
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".mp4",".vvv",str_replace('+',' ',urldecode($_GET['avideoname'])))));
    if (4 == 4) {
    header('Content-Type: video/mp4');
    header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
    header('Pragma: public');
    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))))));
    header("Content-Disposition: inline; filename=" . $dname);

    echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))));
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))));
    exit;
    } else {
    echo $hsofar;
    $thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname'])));
    register_shutdown_function('shutdown');
    //sleep(45);
    //unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))));
    shutdown() and exit;
    }
    }

    ?>
    …implied by the code above … and here it …
  • is able to display the Video (as a video/mp4 mimetype data) arrangement

… means by which we can offer a Video “assembly” now in the “eleventh draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, filibusters and crime busters and ghost busters, attendees and abstainers, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Animated GIF Tutorial is shown below.

Document Root Relative Folder Listing Links Animated GIF Tutorial

Document Root Relative Folder Listing Links Animated GIF Tutorial

We continue on from yesterday’s PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial “useful sidestep”, to add to the current crop of “assemblies” …

  • Javascript (setTimeout) image animation
  • PDF
  • PowerPoint
  • Word … whereas, today, we are offering …
  • Animated GIF

… “assembly” functionality, turning back to ImageMagick‘s brilliant “convert” command line command idea …

convert -delay 1000 -loop 0 [space limited list of image filenames] output.gif

… used within the procedure involving our Document Root Relative Folder Listing web application …

  • we open within a popup window in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Animated GIF *.gif data via (exec called) …

    convert -delay 1000 -loop 0 [space delimited list of image filenames] output.gif

    … and from there …
  • the PHP uses the header arrangements
    <?php

    if (isset($_GET['agiflist']) && isset($_GET['agifname'])) {
    $dname="input.gif";
    $_GET['agiflist']=oururlencode($_GET['agiflist']);
    $dname=explode('.', basename(explode(',', str_replace('+',' ',urldecode($_GET['agiflist'])))[0]))[0] . '_et-al_' . sizeof(explode(',',str_replace('+',' ',urldecode($_GET['agiflist'])))) . '.gif';
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname'])))), str_replace(","," " . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['agiflist']))));
    exec($convprefix . 'convert -delay 1000 -loop 0 ' . file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname']))))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    $hsofar="<html><body><img src=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['agifname']))) . "\" data-base=data:image/gif;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))))) . "></img></body></html>";
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname'])))));
    if (4 == 4) {
    header('Content-Type: image/gif');
    header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
    header('Pragma: public');
    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))))));
    header("Content-Disposition: inline; filename=" . $dname);

    echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    exit;
    } else {
    echo $hsofar;
    $thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname'])));
    register_shutdown_function('shutdown');
    //sleep(45);
    //unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    shutdown() and exit;
    }
    }

    ?>
    …implied by the code above … and here it …
  • is able to display the Animated GIF (as an image/gif mimetype data) arrangement

… means by which we can offer an Animated GIF “assembly” now in the “tenth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, filibusters and crime busters, townfolk and countryfolk alike, like.


Previous relevant PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial is shown below.

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

Yesterday’s Document Root Relative Folder Listing Links Caption Tutorial work had within it’s changes features to do with …

after process unneeded web server file cleanup

… issues where in the past we may have resorted to a …

  • crontab (and maybe curl) means to a solution … but we prefer, where possible …
  • there and then procedures within the PHP (ie. it has to be PHP to help) … as much as anything, because that way, all the parts to any solution, are self contained

… and for security purposes that PHP solution is best done using a form method=POST methodology, or, as we are sprouting here today (and we like a lot, and think it could help us out later with other such scenarios) … and our apologies for the tautology

PHP Javascript Ajax Asynchronous Sleep Cleanup

… thinking we start explaining at the changed Javascript Ajax (to the original block of code) as per …

<?php echo ”

var gincv='', ganidn='';

function ajaxpdfit(incv) {
if (4 == 4) {
var anidn='' + incv.replace(/\\\\/g,'/').split(',')[0].split('/')[eval(-1 + incv.replace(/\\\\/g,'/').split(',')[0].split('/').length)].split('.')[0] + '_et-al_' + incv.split(',').length; // + '.pdf';
if (pdfwoo) {
if (!pdfwoo.closed) { pdfwoo.close(); pdfwoo=null; } else { pdfwoo.close(); pdfwoo=null; }
}
if (pptxwoo) {
if (!pptxwoo.closed) { pptxwoo.close(); pptxwoo=null; } else { pptxwoo.close(); pptxwoo=null; }
}
if (mswoo) {
if (!mswoo.closed) { mswoo.close(); mswoo=null; } else { mswoo.close(); mswoo=null; }
}
//incv=incv.replace(/\~\~/g, String.fromCharCode(92) + String.fromCharCode(10)); // new idea
if (('' + document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent(anidn + '.pdf')).length > 800) {
pdfzhr = new XMLHttpRequest();
pdfzform = new FormData();
pdfzform.append('anidnlist', incv);
pdfzform.append('anidn', anidn + '.abc');
//pdfzhr.onreadystatechange=noNeedToHangAround;
pdfzhr.open('post', './one_line_find.php', true);
pdfzhr.send(pdfzform);

ganidn=anidn;
gincv=noh(incv); // strips out any hashtagged caption data
setTimeout(function(){
pdfwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(gincv) + '&apdfname=' + encodeURIComponent(ganidn + '.pdf'),'_blank','top=20,left=' + eval(-700 + screen.width) + ',width=700,height=700');
pdfwoo.document.title='PDF (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
pptxwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?applist=' + encodeURIComponent(gincv) + '&appname=' + encodeURIComponent(ganidn + '.pptx'),'_blank','top=' + eval(-400 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
pptxwoo.document.title='PowerPoint (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
mswoo=window.open(document.URL.split('?')[0].split('#')[0] + '?amslist=' + encodeURIComponent(gincv) + '&amsname=' + encodeURIComponent(ganidn + '.docx'),'_blank','top=' + eval(-200 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
mswoo.document.title='Word (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
}, 5000);
} else {

pdfwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent(anidn + '.pdf'),'_blank','top=20,left=' + eval(-700 + screen.width) + ',width=700,height=700');
pdfwoo.document.title='PDF (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
pptxwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?applist=' + encodeURIComponent(incv) + '&appname=' + encodeURIComponent(anidn + '.pptx'),'_blank','top=' + eval(-400 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
pptxwoo.document.title='PowerPoint (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
mswoo=window.open(document.URL.split('?')[0].split('#')[0] + '?amslist=' + encodeURIComponent(incv) + '&amsname=' + encodeURIComponent(anidn + '.docx'),'_blank','top=' + eval(-200 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
mswoo.document.title='Word (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';

}
} else if (4 == 46) {
document.getElementById('apdflist').value=incv;
document.getElementById('apdfname').value='pdf' + Math.floor(Math.random() * 19897654) + '.pdf';
document.getElementById('thepdf').style.display='block';
document.getElementById('pdfsub').click();
} else if (4 == 47) {
document.getElementById('thepdf').style.display='block';
document.getElementById('thepdf').src=document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent('pdf' + Math.floor(Math.random() * 19897654) + '.pdf');
} else {
pdfzhr = new XMLHttpRequest();
pdfzform = new FormData();
pdfzform.append('apdflist', incv);
pdfzform.append('apdfname', 'pdf' + Math.floor(Math.random() * 19897654) + '.pdf');
pdfzhr.onreadystatechange=statePdfChanged;
pdfzhr.open('post', './one_line_find.php', true);
pdfzhr.send(pdfzform);
}
}

“; ?>

… begging the question, at least for us, being …

What’s the go with …
//pdfzhr.onreadystatechange=noNeedToHangAround;
?

Well, the “A” of Ajax stands for “Asynchronous”, as a useful aspect to Javascript where logic does not have to flow from start to finish linearly, and jobs can multitask. That onreadystatechange idea analyzes what the recipient PHP replies, but in the case of a file cleanup …

  1. it is optional (but preferable) if it happens at all, in the way we roll around here …
  2. and that means as far as file cleanup goes, immediately the interim ascii flat file (used to flesh out the following $_GET[] array work …
    <?php

    $commentaries=[];

    function oururlencode($instis) {
    global $commentaries;
    $interim=urldecode($instis);
    $origim=str_replace('+',' ',$interim);
    $intcs=explode(',', $interim);
    $found=false;
    for ($j=0; $j<sizeof($intcs); $j++) {
    if ($j == 0) {
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(explode('#',$intcs[$j])[0]) . '_et-al_' . sizeof($intcs) . '.abc')) {
    $instis=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(explode('#',$intcs[$j])[0]) . '_et-al_' . sizeof($intcs) . '.abc');
    $interim=urldecode($instis);
    $origim=str_replace('+',' ',$interim);
    $intcs=explode(',', $interim);
    }

    }
    array_push($commentaries, '');
    }
    for ($j=0; $j<sizeof($intcs); $j++) {
    $found=false;
    if (strpos($intcs[$j], '#') !== false) {
    $oneword=explode(' ',trim(explode('#', $intcs[$j])[1]))[0];
    if ($oneword != '' && strpos($oneword, '.') !== false && substr($oneword . ' ',0,1) == '/') {
    if (strpos($origim, $oneword) != '') {
    $found=true;
    }
    }
    if ($found) {
    $commentaries[$j].=' ' . str_replace("~~",chr(92) . chr(10),substr(trim(explode('#', $intcs[$j])[1]),strlen($oneword))); // fix perhaps
    }
    }
    }
    for ($j=0; $j<sizeof($intcs); $j++) {
    $jj=0;
    while ($commentaries[$jj] != '') {
    $jj++;
    }
    $found=false;
    if (strpos($intcs[$j], '#') !== false) {
    $oneword=explode(' ',trim(explode('#', $intcs[$j])[1]))[0];
    if ($oneword != '' && strpos($oneword, '.') !== false && substr($oneword . ' ',0,1) == '/') {
    if (strpos($origim, $oneword) != '') {
    $found=true;
    }
    }
    if (!$found) {
    $commentaries[$jj].=' ' . str_replace("~~",chr(92) . chr(10),explode('#', $intcs[$j])[1]); // fix perhaps
    }
    $interim=str_replace($intcs[$j],explode('#', $intcs[$j])[0],$interim);
    }
    }
    return urlencode($interim);
    }

    ?>
    …with hashtagged caption data that made the job too long for $_GET[] based navigation from the start) can be created by our recipient PHP Ajax “called upon” … then …
  3. the PHP can sleep
    <?php

    if (isset($_POST['anidnlist']) && isset($_POST['anidn'])) {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['anidn'])), str_replace('+',' ',urldecode($_POST['anidnlist'])));
    sleep(60);
    if (strpos(('' . str_replace('+',' ',urldecode($_POST['anidn'])) . '~'), '.abc~') !== false) {
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['anidn'])));
    }

    exit;
    }

    ?>
  4. leaving the $_GET[] pass (we wait back at the client Javascript 5 seconds for via setTimeout logics, while the PHP sleeps much longer) time to avail themselves back up at the server with the use of that interim ascii flat file (while the asynchronous, and not waited upon, Ajax called PHP sleeps … presumably among the lions) … while …
  5. back at the Ajax called PHP, having slept, and the interim file has lost it’s value, it can be deletedsorrrrrryyyyyyy “interim file”

… as one example of how this “PHP Javascript Ajax Asynchronous Sleep Cleanup” idea set could be implemented.


Previous relevant Document Root Relative Folder Listing Links Caption Tutorial is shown below.

Document Root Relative Folder Listing Links Caption Tutorial

Document Root Relative Folder Listing Links Caption Tutorial

After yesterday’s Document Root Relative Folder Listing Links Word Tutorial we had both …

  • PowerPoint
  • Word

… output document formats, created via pandoc, with the ability, in pandoc, to tailor slide “captions”, which, until today, had been hardwired to be the image slide filename.

We’ve decided to hashtag such user caption tailoring in hashtag data after the filenames passed over to the recipient PHP (which is the same as the originating PHP in “here’s looking at you” mode of thinking).

So where can the user enter these? The first option …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow or PDF or PowerPoint or Word via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; data-onblur=process(this); data-multiple><option id=firsttext onclick=addcommentary(); value=\"\">:</option></select>')

“; ?>

… of that relatively new dropdown for this is where we have decided to intervene …

<?php echo ”

var commentaries=[];

function addcommentary() {
needten=1;
var commadd=prompt('Optionally add to commentary. For new lines use ~~ characters. For multiple entries separate by , (ie. two blanks comma two blanks).', '');
if (commadd != null) {
var coms=commadd.split(' , ');
for (var ic=0; ic<coms.length; ic++) {
if (coms[ic].trim() != '') {
commentaries.push('#' + encodeURIComponent(coms[ic]));
}
}
}
}


“; ?>

And so, the “ninth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Word Tutorial is shown below.

Document Root Relative Folder Listing Links Word Tutorial

Document Root Relative Folder Listing Links Word Tutorial

The word is, in workplaces all around Earth now, workers are unwrapping their Mars Bars and shaping to use …


Word

huh?! Isn’t that a coincidence?! Who would have thunk it. They are constructing documents. So that being the case, do you think …

The barsoomian is, in workplaces all around Mars now, martians are unwrapping their Earth Bars and shaping to use …


Word


… to write haikus

? But if not, why not?!

As such, the creation of a “Word assembly” is our “fourth cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we PowerPointized yesterday with Document Root Relative Folder Listing Links PowerPoint Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$pconvprefix='/bin/';
if (file_exists('/usr/local/bin/pandoc')) {
$pconvprefix='/usr/local/bin/';
} else if (!file_exists('/bin/pandoc')) {
$pconvprefix='';
}

if (isset($_GET['amslist']) && isset($_GET['amsname'])) {
$dname="input.docx";
$themd=str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['amslist'])));
$thelines=explode("\n", $themd);
$themd="";
for ($i=0; $i<sizeof($thelines); $i++) {
if ($i == 0) {
$dname=explode('.', basename($thelines[$i]))[0] . '_et-al_' . sizeof($thelines) . '.docx';
}
if ($i == (-1 + sizeof($thelines))) {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")";
} else {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")\n\n---\n\n";
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))), $themd);
exec($pconvprefix . 'pandoc ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))) . ' -o ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['amsname']))) . "\" type=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\" data-base=data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))));
if (4 == 4) {
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))));
header("Content-Disposition: inline; filename=" . $dname);
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
shutdown() and exit;
}
}

?>

… engendering that same frisson of excitement we got yesterday, with Document Root Relative Folder Listing Links PowerPoint Tutorial … as (for us here on macOS) …

  • we open a popup in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Word *.docx data via (exec called) …

    pandoc presentation.md -o output.docx

    … and from there …
  • the PHP uses the header arrangements implied by the code above … but where it …
  • is unable to display, but still shows a download link …
  • we click …
  • showing a new Downloads folder file …
  • we get to in Finder …
  • we hover over that *.docx and see an Open With …
  • LibreOffice choice we select …
  • displaying the Word document containing the images selected

Cute, huh?!?!

The “eighth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links PDF Tutorial is shown below.

Document Root Relative Folder Listing Links PDF Tutorial

Document Root Relative Folder Listing Links PDF Tutorial

Hopefully, all around the world, the idea of a …


PDF

… display is replacing the “paper hungry” “hardcopy printout” concept. As such, the creation of a “PDF assembly” is our “second cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we started yesterday with Document Root Relative Folder Listing Links Assemblies Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$thingtoattendto='';

function shutdown() {
global $thingtoattendto;
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.

if ($thingtoattendto != '') {
sleep(145);
unlink($thingtoattendto);
}
}

$convprefix='/bin/';
if (file_exists('/usr/local/bin/convert')) {
$convprefix='/usr/local/bin/';
} else if (!file_exists('/bin/convert')) {
$convprefix='';
}

if (isset($_GET['apdflist']) && isset($_GET['apdfname'])) {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))), str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['apdflist']))));
exec($convprefix . 'convert @' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['apdfname']))) . "\" type=\"application/pdf\" data-base=data:application/pdf;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))));
if (4 == 4) {
header('Content-Type: application/pdf');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))));
header("Content-Disposition: inline; filename=input.pdf");
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
shutdown() and exit;
}
}

?>

… using ImageMagick‘s brilliant “convert” command line command idea …

convert @list.txt output.pdf

as the backbone as to how in the “sixth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Assemblies Tutorial is shown below.

Document Root Relative Folder Listing Links Assemblies Tutorial

Document Root Relative Folder Listing Links Assemblies Tutorial

So far, with the Document Root Relative Folder Listing work of recent times, up until the day before yesterday’s Document Root Relative Folder Listing Links Ajax Tutorial, it’s been mainly …

  • reporting … and …
  • display … but we want to move on to the user being able to create their own what we are referring to as …
  • assemblies

To us, these are user driven (is it widgets) they create by selecting multiple media (today images, but down the line, other combinations) from the left hand table cell’s listing links. We do not ask anymore of that left hand cell’s workings, as it will get too complex, but we have a penchant for adding intelligence to hardcodings, and the hardcoding …

https://www.rjmprogramming.com.au/

… is ripe for the picking, with that “just moseying along there innocently” …

:

… a candidate for a new multiple mode select (ie dropdown) element …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')

“; ?>

… means by which a user can specify “assembly components”.

Our simplest first “cab off the rank” here is a Javascript animated sequence, so far 4 second duration slides in a slideshow popup window, as per …

<?php echo ”

var lastretval='', origprefix='', wesayso=false, needten=0, sofarval='', woo=null;

function agifit(incsv) {
if (incsv != '') {
var myimgs=incsv.split(',');
if (woo) {
if (!woo.closed) { woo=woo; } else { woo.close(); woo=null; }
}
if (!woo) {
woo=window.open('','_blank','top=50,left=50,width=800,height=800');
woo.document.write('<ht' + 'ml><he' + 'ad>' + myimgs[0] + '<ti' + 'tle></ti' + 'tle><scr' + 'ipt type=text/javascript> var jimg=0, imgs=(\"' + incsv + '\").split(String.fromCharCode(44)), kimg=eval(\"\" + imgs.length); function startit() { jimg++; jimg=eval(jimg % kimg); document.body.style.background=' + \"'url(' + imgs[jimg] + ')'\" + '; document.title=' + \"'' + imgs[jimg] + ''\" + '; document.body.style.backgroundRepeat=\"no-repeat\"; document.body.style.backgroundSize=\"contain\"; } setInterval(startit,4000); </scri' + 'pt></head><body id=xbody style=background:url(' + myimgs[0] + ');background-repeat:no-repeat;background-size:contain;></body></html>');
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
return woo;
}
}
needten=0;
return null;
}

function monitorsel() {
var yesdo=true;
if (needten > 10) { setTimeout(monitorsel, 2000); return ''; }
var osel=document.getElementById('compsel');
var retval='', delim='';
if (sofarval != '') { delim=','; retval=sofarval; }
for (var i=0; i<osel.length; i++) { if (osel.options[i].selected) { if (osel.options[i].value != '') { if ((',' + sofarval + ',').indexOf(',' + osel.options[i].value + ',') == -1) { retval+=delim + osel.options[i].value; delim=','; } } } }
if (document.getElementById('compsel')) {
if (retval != '') {
if (retval != '' && retval.indexOf(',') == -1) {
needten=0;
}
if (lastretval != retval) {
lastretval=retval;
sofarval=retval;
needten=0;
} else if (needten < 10) {
needten++;
} else {
yesdo=false;
needten++;
if (agifit(sofarval)) {
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
}
}
}
if (yesdo) { setTimeout(monitorsel, 2000); }
}
}

function thismultiple(osel) {
if (document.getElementById('lefttd').outerHTML.split('>')[0].indexOf('overflow') == -1 || wesayso) {
wesayso=false;
document.getElementById('lefttd').style.overflowY='visible';
osel.style.height='30px';
osel.setAttribute('multiple', 'true');
setTimeout(monitorsel, 2000);
}
}


function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[], addthese='';
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
if (document.getElementById('prefix') && !document.getElementById('compsel')) {
if (document.getElementById('prefix').innerHTML.replace('p://','s://').indexOf('s://') != -1) {
document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')
}
}
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
//alert('0:' + outwo('/' + uids[2]) + ' ... ' + '/' + uids[2]);
if (outwo('/' + uids[2]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"/' + uids[2] + '\">/' + uids[2] + '</option>';
}

if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
//alert('1:' + outwo((ihis.split('%20-')[0].split(' -')[0])) + ' ... ' + (ihis.split('%20-')[0].split(' -')[0]));
if (outwo(ihis.split('%20-')[0].split(' -')[0]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"' + (ihis.split('%20-')[0].split(' -')[0]) + '\">' + (ihis.split('%20-')[0].split(' -')[0]) + '</option>';
}

if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
if (addthese != '') {
document.getElementById('compsel').innerHTML+=addthese;
origprefix=document.getElementById('prefix').innerHTML; //.replace(' data-multiple', ' multiple data-multiple');
}

setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

“; ?>

… in the “fifth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, like.


Previous relevant Document Root Relative Folder Listing Links Ajax Tutorial is shown below.

Document Root Relative Folder Listing Links Ajax Tutorial

Document Root Relative Folder Listing Links Ajax Tutorial

It was “faux Ajax day” with yesterday’s Document Root Relative Folder Listing Links Before and On Click Tutorial, but today …

It’s Ajax Day … yayyyyy!!!!

Howevvvvvvvver, just to confuse, there is no onmouseover involved, but the Ajax work does, at least for non-mobile users, sort of, affect display data, in that when hovering over a link, they may see within the title attribute of that link, whatevvvvvvvvver …


file "[a link href]"

… can “value add”, via Ajax logic, into the “up until now just an ls (underlying operating system command) based file listing” report.

Ajax is great here, as helping a subprocess that can be …

  • spawned off …
  • working away as a secondary (optional) process

… supplementing the primary workflow, if you will, but probably not too impactive, we’re hoping

<?php echo ”

var ajaxs=[], zhr=null, zform=null;

function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[];
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

function stateChanged() {
if (zhr.readyState == 4) {
if (zhr.status == 200) {
var rawhtml = zhr.response;
var spans=rawhtml.split('</span');
var ps=rawhtml.split('</p');
if (eval('' + ps.length) == 2 && eval('' + spans.length) == 2) {
document.getElementById(spans[0].split('>')[eval(-1 + spans[0].split('>').length)]).title+=ps[0].split('>')[eval(-1 + ps[0].split('>').length)];
}
setTimeout(doajaxs, 1000);
}
}
}

function doajaxs() {
var nexttogo='';
for (var ii=0; ii<ajaxs.length; ii++) {
if (nexttogo == '' && ajaxs[ii] != '') {
nexttogo=ajaxs[ii];
ajaxs[ii]='';
}
}
if (nexttogo != '') {
zhr = new XMLHttpRequest();
zform = new FormData();
zform.append('ajaxid', encodeURIComponent(nexttogo));
zform.append('ajaxurl', nexttogo);
zhr.onreadystatechange=stateChanged;
zhr.open('post', './one_line_find.php', true);
zhr.send(zform);
}
}


“; ?>

… Javascript calling logic using PHP recipient code …

<?php

if (isset($_POST['ajaxurl']) && isset($_POST['ajaxid'])) {
echo "<html><body><span>" . $_POST['ajaxid'] . '</span><p>' . str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('file "' . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_POST['ajaxurl'])) . '"')) . "</p></body></html>";
exit;
}

?>

… in the “fourth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, like.


Previous relevant Document Root Relative Folder Listing Links Before and On Click Tutorial is shown below.

Document Root Relative Folder Listing Links Before and On Click Tutorial

Document Root Relative Folder Listing Links Before and On Click Tutorial

Today’s work has an Ajax feel to it, despite the fact we use no Ajax type Javascript code, onto yesterday’s Document Root Relative Folder Listing Links Tutorial onclick event logics, we guess, because …

  • coding for the non-mobile onmouseover event, with display change logic, has a very Ajaxy feel to it … and …
  • on mobile we code for ontouchmove (feeding into user click actions)

calling via

<?php echo ”

tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a target="_blank" onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');

“; ?>

… calling on …

<?php echo ”

function showit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
if (ioi.outerHTML.indexOf('<span') != -1) {
outwo(ioi.getAttribute('data-href'));
} else {
outwo(ioi.href);
}
}

function hideit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
}

function hideitlater(ioi) {
if (2 == 5) {
setTimeout(function(){
document.getElementById('mymediatr').innerHTML=mytrih;
}, 15000);
}
}

“; ?>

Along the way we decided, in very Ajaxy thinking, on mobile, to be less disruptive with navigations after a click, so as to stay on the original webpage more often, in the “third draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you like.


Previous relevant Document Root Relative Folder Listing Links Tutorial is shown below.

Document Root Relative Folder Listing Links Tutorial

Document Root Relative Folder Listing Links Tutorial

Regular readers will “know the drill” with today’s work, on top of yesterday’s Document Root Relative Folder Listing Tutorial.

The new word in the posting title is …


Links

… and those regular readers would know …

  • yesterday’s Document Root Relative Folder Listing output was placed into a textarea element … clue 1
  • that textarea element we all admire for it’s textual data line feed talents and it’s talents for resizing capabilities … clue 2
  • that textarea element textual data is unembellishable (if that is a word) … clue 3
  • whereas your meek and mild div element, say, could overlay that textarea element, except for the right hand resizer, that is … clue 4
  • and the div element could latch onto that textarea basis of content and enhance filenames into filename links too (but am not sure about the Singing Glasses idea in the “talent quest section” … that seems a bridge too far) … clue 5

… leaving us clueless as to what else to say … chortle, chortle?!

Also helpful would be, to our minds …

  • still restrict the file specification to a “buttoned down” setting (because of security concerns) … but …
  • add complexity to the extension part …
    <?php

    $extbit='*.[tjpmwag][xpnopaid][etgvf34]*';

    ?>
    …to allow relatively innocent media files and PDFs reach the file listing (tweaked a bit too) now …
    <?php

    $resis=str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('ls -lhgo ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $offdr . $extbit));

    ?>

… in the “second draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, again, if you like.


Previous relevant Document Root Relative Folder Listing Tutorial is shown below.

Document Root Relative Folder Listing Tutorial

Document Root Relative Folder Listing Tutorial

The Apache web server has, for it’s PHP environment, if that is it’s server language, the concept of …


Document Root

… so that, for the website of the webpage you are reading from now, a URL such as our RJM Programming’s Landing Page’s URL …


https://www.rjmprogramming.com.au/

… scours that Document Root folder to find the index.php webpage code to display that Landing Page.

You can “abstract”, and we do also with our Difference Reporting, what that Document Root is as a folder path … bit forlorn we know, as we’ve shown what it is, probably, in many tutorial images … but the thing here is that a URL such as …


/index.php

… is understood and gets you to our Landing Page as well, because to the public, Document Root is the limit of where they are allowed to surf … if you like Document Root is the left hand beach flag at Surfers Paradise (or perhaps the right hand beach flag in the Todd River … when it gets water, that is?!).

Okay, that’s one theme of today’s new PHP web application. The other we wrote out to ourself was …

One line ls -clt https://www.rjmprogramming.com.au/*.txt via find $_SERVER[‘DOCUMENT_ROOT’] -type d -name ‘*’

… as a presentation idea whereby just the one table row of data is used to present …

  • https://www.rjmprogramming.com.au/
  • dropdown of list of folders off Document Root (“abstracting” Document Root itself … ie. relative referencing)
  • a file specification (minus the path) of interest … we are, for now, locking in as …

    *.txt

    … as the input data, to the output data that is …
  • output folder listing (as for Linux and macOS)

The concept of “one table row” for a multiple file listing is a mute point, but in our defence …

  • the textarea it is presented in (via rows=1) is user resizable
  • the textarea it is presented in is given a title with line feeds for the whole report so that non-mobile users can see this on hovering over the textarea

This was a PHP project definitely needing the mildly better outcomes of PHP shell_exec (where multiple line outputs are possible) as distinct from exec where only the last output line is returned, but is the usual method we use around here.

Keeping the report to one row also asks for …

  • use of elements that have CSS styling display:inline; as a default (eg. span element) … or …
  • user supplying CSS display:inline; or display:inline-block; as applicable … and …
  • table cell text-align:right; came in handy … as well as …
  • select element “dynamic shrinker” …

    function resizeSelect(sel) { // thanks to https://www.google.com/search?q=make+select+element+width+in+sympathy+with+length+of+its+value&rlz=1C5OZZY_en&oq=make+select+element+width+in+sympathy+with+length+of+its+value&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTI3MzEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8
    // 1. Create a temporary span to measure text width
    var tempSpan = document.createElement('span');
    tempSpan.style.visibility = 'hidden';
    tempSpan.style.position = 'absolute';
    tempSpan.style.whiteSpace = 'pre';
    // 2. Set font styles to match the select box
    tempSpan.style.font = window.getComputedStyle(sel).font;
    // 3. Set content to selected text
    tempSpan.innerText = sel.options[sel.selectedIndex].text;
    document.body.appendChild(tempSpan);

    // 4. Update width (with extra space for the dropdown arrow)
    sel.style.width = (tempSpan.offsetWidth + 30) + 'px';
    document.body.removeChild(tempSpan);
    }

… in the “proof of concept” one_line_find.php first draft Document Root Relative Folder Listing web application you can “crank up” below if you like …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Animation, eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

SVG Emoji Favicon Aesthetics CSS Tutorial

SVG Emoji Favicon Aesthetics CSS Tutorial

SVG Emoji Favicon Aesthetics CSS Tutorial

The recent SVG Emoji Favicon HTML Entities Tutorial had us adding user interaction, but we think especially as far as the input type submit buttons were concerned, lacking style.

Especially on mobile platforms, on occasions without attention, and you add a background colour to your input type submit buttons you can end up with …

  • too small a button
  • white font

double whammy bad scenario, which prompted us to get interested in some CSS …

<?php echo ”

<style>

input[type=\"submit\"] {
font-color: blue;
color: blue;
font-size: 24px;
height: 50px;
border-radius: 55px;
border: 1px dotted red;
background-color: yellow;
text-shadow: -1px 1px 1px #952dff;
}

textarea {
background-color: #f0f0f0;
}

input[type=\"text\"] {
background-color: #e0e0e0;
}

</style>

“; ?>

… for this project in the changed emojiicon.php web application you can try for yourself below.


Previous relevant SVG Emoji Favicon HTML Entities Tutorial is shown below.

SVG Emoji Favicon HTML Entities Tutorial

SVG Emoji Favicon HTML Entities Tutorial

Yesterday’s SVG Emoji Favicon Textarea Tutorial

  • textarea SVG … adding onto …
  • numerical codepoint definition means to an Emoji definition in terms of web browser tab icon creation capabilities

… shone a light, a “lightbulb moment” for us, in terms of the fact that so many Emojis of interest are actually multiple HTML entity ones (eg. all the national flag emojis are actually made up of four HTML entities) and our initial textbox design of …

<?php echo ”

<input title='Emoji codepoint as web browser tab icon (ie. look up to see after clicking display)' type=number onchange=emnone(); onblur=emnone(); id=codepoint name=codepoint step='1' value='-1' min='-1'></input>

“; ?>

… should be able to become the more savvy (for multiple emojis now possible because of the logics behind the new textbox mentioned below) via this new Javascript …

<?php echo ”

/**
* Convert a string to HTML entities ... thanks to https://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript
*/
String.prototype.toHtmlEntities = function() {
return this.replace(/./gm, function(s) {
// return \"&#\" + s.charCodeAt(0) + \";\";
return (s.match(/[a-z0-9\s]+/i)) ? s : \"&#\" + s.charCodeAt(0) + \";\";
});
};

function emnone() {
document.getElementById('anemoji').value='';
}

function cpit(otb) {
if (otb.value != '') {
if (otb.value.toHtmlEntities().indexOf('&#x') != -1) {
} else if (otb.value.toHtmlEntities().indexOf('&#') != -1) {
document.getElementById('codepoint').type='text';
//alert('' + otb.value.toHtmlEntities().replace(/^\&\#/g,'').replace(/\;$/g,'').replace(/\;\&\#/g,'.'));
document.getElementById('codepoint').value='' + otb.value.toHtmlEntities().replace(/^\&\#/g,'').replace(/\;$/g,'').replace(/\;\&\#/g,'.');
} else {
document.getElementById('codepoint').value='';
for (var jj=0; jj<otb.value.length; jj++) {
if (document.getElementById('codepoint').value == '') {
document.getElementById('codepoint').value='' + otb.value.substring(jj).substring(0,1).charCodeAt();
} else {
document.getElementById('codepoint').type='text';
document.getElementById('codepoint').value+='.' + otb.value.substring(jj).substring(0,1).charCodeAt();
}
}
}
//alert(otb.value.toHtmlEntities());
}
}

“; ?>

… that supplements the web application user interaction possibilities via a new HTML textbox definition …

<?php echo ”

<input type=text placeholder=Emoji onblur=cpit(this); maxlength=4 value='' id=anemoji title='Emoji ... perhaps via control-command-space for macOS or Mac OS X, logo key + . (period) for Windows, control=space for iOS, top left + for Android keyboard ... but please note not all International codes work with XML 1.0'></input>

“; ?>

… and the new intelligence catered for via the more astute PHP …

<?php

if (isset($_GET['mysvg'])) {
$usuffix='_' . server_remote_addr();
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', str_replace(' ',' + ',str_replace('+',' ',$_GET['mysvg'])));
if ($iponl != '' && file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
$iponl=massage(" onload=\" if (window.parent) { if (parent.document.body.outerHTML.split('>')[0].indexOf(' data-ip=') == -1) { parent.document.body.setAttribute('data-ip', '_" . $rma . "'); parent.document.body.setAttribute('data-firstip', 'y'); } } \"");
}
} else if (isset($_GET['codepoint'])) {
if (strlen($_GET['codepoint']) > 0) {
if (isset($_GET['ishex']) || isset($_GET['tohex']) || isset($_GET['hex'])) {
$usuffix='_' . server_remote_addr();
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', str_replace('&#x1f1e6;','&#127462;&#127465;','<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">&#x' . str_replace('.',';&#x',str_replace(',',';&#x',str_replace(';','',str_replace('&#','',str_replace('+',' ',urldecode($_GET['codepoint'])))))) . ';</text></svg>'));
} else {
$usuffix='_' . server_remote_addr();
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">&#' . str_replace('.',';&#',str_replace(',',';&#',str_replace(';','',str_replace('&#','',str_replace('+',' ',urldecode($_GET['codepoint'])))))) . ';</text></svg>');
}
} else if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
$usuffix='_' . server_remote_addr();
} else {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">X</text></svg>');
if ($iponl != '' && file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
$iponl=massage(" onload=\" if (window.parent) { if (parent.document.body.outerHTML.split('>')[0].indexOf(' data-ip=') == -1) { parent.document.body.setAttribute('data-ip', '_" . $rma . "'); parent.document.body.setAttribute('data-firstip', 'y'); } } \"");
}
}
} else if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
$usuffix='_' . server_remote_addr();
} else {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">X</text></svg>');
if ($iponl != '' && file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
$iponl=massage(" onload=\" if (window.parent) { if (parent.document.body.outerHTML.split('>')[0].indexOf(' data-ip=') == -1) { parent.document.body.setAttribute('data-ip', '_" . $rma . "'); parent.document.body.setAttribute('data-firstip', 'y'); } } \"");
}
}

?>

… in the changed emojiicon.php web application you can try for yourself below.


Previous relevant SVG Emoji Favicon Textarea Tutorial is shown below.

SVG Emoji Favicon Textarea Tutorial

SVG Emoji Favicon Textarea Tutorial

You can surmise that if a blog posting title contains the word textarea then it is likely to be about user input, further to the SVG Emoji Favicon and Title Uniquify Tutorial back in May, 2025.

Basically, we only offered cryptic (ie. address bar) ways the user could control the look of their web browser (but some, like Safari, do not support SVG content based) tab icon via …

  • codepoint number based emoji SVG icon content … and, as of today, also available to the user in the user input parts to the web application involves the optional use of a …
  • textarea … default “red hexagon” … based SVG that may work as suitable for a web browser tab icon (ie. not too big)

Is there anything as easy to arrange as the great HTML textarea element as far as “programming code as data” navigational purposes the way the static innerHTML …


<textarea rows=9 cols=120 id=mysvg><?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100" height="100" viewbox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="-50" y="-50" width="100" height="100" id="square" fill="red" transform="translate(50, 50) rotate(45)"></rect>
</svg></textarea>

… where you can plug just about anything, as is, into, at the onload event, and which can be magically converted into an appropriate textarea value attribute, the contents of which, is encodeURIComponent encrypted by the HTML form element hosting to arrive at the recipient in good condition?

You can try the changed emojiicon.php web application

… to see what we mean here.


Previous relevant SVG Emoji Favicon and Title Tutorial is shown below.

SVG Emoji Favicon and Title Tutorial

SVG Emoji Favicon and Title Tutorial

The recent SVG Network Clock Start Local Time Favicon Tutorial talked about …

  • SVG data basis …
  • emoji data content …
  • favicon web browser tab icon … SVG type not accepted by all browsers and platforms …
  • dynamism … and today we start with another offshoot of thought regarding this, as well as …
  • document.title also showing in the web browser tab icon … universally accepted …

… ideas we wanted to get into by writing a pretty simple generic PHP helper emojiicon.php, we got a great heads up from regarding its logic, thanks, to dynamically create favicon.svg, currently looking like …

… in our nominated folder (so, so far not catering for a lot of online traffic … we’ll see) …


<?php
// emojiicon.php
// RJM Programming
// March, 2025

if (isset($_GET['codepoint'])) {
if (strlen($_GET['codepoint']) > 0) {
if (isset($_GET['ishex']) || isset($_GET['tohex']) || isset($_GET['hex'])) {
//file_put_contents('xxx.xxx', str_replace('+',' ',urldecode($_GET['codepoint'])));
//file_put_contents('xx.xx', '<svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">&#x' . str_replace(',',';&#x',str_replace(';','',str_replace('&#','',str_replace('+',' ',urldecode($_GET['codepoint']))))) . ';</text></svg>');
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon.svg', str_replace('🇦','🇦🇩','<svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">&#x' . str_replace(',',';&#x',str_replace(';','',str_replace('&#','',str_replace('+',' ',urldecode($_GET['codepoint']))))) . ';</text></svg>'));
} else {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon.svg', '<svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">&#' . str_replace(',',';&#',str_replace(';','',str_replace('&#','',str_replace('+',' ',urldecode($_GET['codepoint']))))) . ';</text></svg>');
}
}
}

echo "<html>
<head>
<link rel='icon' href='/emojiicon/favicon.svg?rand=" . rand(0,3456789) . "' sizes='any' type='image/svg+xml'>
</head>
<body>
<h1>Emoji Icon - RJM Programming - March, 2025</h1>
</body>
</html>";
?>

… used in a changed emoji_widget_idea.htm content live run.


Previous relevant SVG Network Clock Start Local Time Favicon Tutorial is shown below.

SVG Network Clock Start Local Time Favicon Tutorial

SVG Network Clock Start Local Time Favicon Tutorial

Today we’re revisiting the SVG Network Clock we last talked about with SVG Network Clock Minimize Tutorial. Why?

Well, we were re-researching the topic of Favicon (those images on the tabs of your web browser tabs) that we talked about when we presented Gimp Favicon via Logo Primer Tutorial, but we realize now, things have moved on with the web browsers supporting SVG svg+xml “favicons” so much better these days, that we’d better “get with the plan”, so to speak (though it might be better if I give that a rest for a minute).












Okay, minutes up!

With increased usage of SVG svg+xml text element solutions for things around here lately, we wondered whether there was a dynamic way to start using these SVG favicons, in some way. Then we thought of our SVG Clock work. At first we thought a favicon that is a relevant timestamp, but realized the impost on the web server is too big for that, and so we set out to present a local start time of the SVG Clock for a user of this web application. The SVG favicon basis is so simple …


<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="32" height="32" version="1.1" xmlns="http://www.w3.org/2000/svg" style="background-color:white; letter-spacing:-1px; transform:scale(1,1.6);>
<text x="0%" y="65%" stroke="black" stroke-width="1" fill="red" font-size="16px">11:54</text>
</svg>

Stick the SVG file in Document Root folder, and replace “11:54” with the relevant timestamp and we’re away, right? Yes, sort of, but there is the little matter of the relevant favicon link statement existing as a non-dynamic call to that SVG in the head section of the webpage.

Bit onerous, huh? But, what did work for us was to have a static starting wrong favicon SVG link (in head) statement that now goes in the parental svg_clock.html SVG Network Clock

<head>


<link id='mylink' rel='icon' href='/faviJUNKcon.svg' sizes='any' type='image/svg+xml'>

</head>

… and set up the changed cldate.php PHP now called …

<body>

<script type='text/javascript'>
var pwo=null;
var analoguesuffix='';
var bothsuffix='';
if (document.URL.indexOf('analogue=') != -1) { analoguesuffix=' selected'; }
if (document.URL.indexOf('both=') != -1) { bothsuffix=' selected'; }
var pretzlist='';
var tzlist="<option value='Africa/Abidjan' data-geo='5.31666,-4.03334,GMT,CI,+0'>Africa/Abidjan</option><option value='Africa/Accra' data-geo='5.55,-0.21667,GMT,GH,+0'>Africa/Accra</option>"; // etcetera etcetera etcetera

if (tz != "") {
document.write("<h1 title='Clock clicks popup Colour Wheel, Separator click for Timezone Info, Separator right click for Google Geo Chart Map, Flag text click for Google Maps and right click for concatenated Google Map Chart' id=myh1>SVG Network Clock</h1><h3>RJM Programming <button title='- for here and toggle to + for to right' id=lhmode onclick='this.innerHTML=this.innerHTML.replace(String.fromCharCode(45),String.fromCharCode(93)).replace(String.fromCharCode(43),String.fromCharCode(45)).replace(String.fromCharCode(93),String.fromCharCode(43));'>-</button> January, 2020</h3><h4 onclick='woit(this.title);' id=myh4 title='" + sih + "'>Enter toggles fullscreen mode and thanks to The PHP Anthology Volume II: Applications by Harry Fuecks</h4><p>The <select id=mysel onchange=gonext(this.value);>" + ("<option value='GMT'>GMT</option><option value='localtime'>Localtime</option>" + setpretz() + tzlist).replace('>' + tz.substring(0,1).toUpperCase() + tz.substring(1) + '<',' selected>' + tz.substring(0,1).toUpperCase() + tz.substring(1) + '<') + "</select> <select style='display:inline-block;' onchange=\"locationhref=(document.URL.replace('analogue=','x=').replace('both=','y=') + ('&' + this.value + '=y').replace('&=y','')).replace('.html&','.html?').replace('.htm&','.htm?') + lh; lhit(prevmysel,this);\"><option value=''>digital clock</option><option value=analogue" + analoguesuffix + ">analogue clock</option><option value=both" + bothsuffix + ">digital and analogue clock</option></select> sponsored by SVG is<br><hr id=myhr style='height:3px;' title='Click here for any Daylight Saving Time information' onclick=\"window.open('http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=" + encodeURIComponent(tz) + "','_blank','top=50,left=50,width=500,height=500');\"><br><object id=myclock data='svg_clock.php?timezone=" + encodeURIComponent(tz + loct) + uprefix + "' width='" + nh + "' height='530' type='image/svg+xml' /></p>" + es);
} else {
document.write("<h1 title='Clock clicks popup Colour Wheel, Separator click for Timezone Info, Separator right click for Google Geo Chart Map, Flag text click for Google Maps and right click for concatenated Google Map Chart' id=myh1>SVG Network Clock</h1><h3>RJM Programming <button title='- for here and toggle to + for to right' id=lhmode onclick='this.innerHTML=this.innerHTML.replace(String.fromCharCode(45),String.fromCharCode(93)).replace(String.fromCharCode(43),String.fromCharCode(45)).replace(String.fromCharCode(93),String.fromCharCode(43));'>-</button> January, 2020</h3><h4 onclick='woit(this.title);' id=myh4 title='" + sih + "'>Enter toggles fullscreen mode and thanks to The PHP Anthology Volume II: Applications by Harry Fuecks</h4><p>The <select id=mysel onchange=gonext(this.value);>" + ("<option value='GMT'>GMT</option><option value='localtime'>Localtime</option>" + setpretz() + tzlist).replace('>' + tz.substring(0,1).toUpperCase() + tz.substring(1) + '<',' selected>' + tz.substring(0,1).toUpperCase() + tz.substring(1) + '<') + "</select> <select style='display:inline-block;' onchange=\"locationhref=(document.URL.replace('analogue=','x=').replace('both=','y=') + ('&' + this.value + '=y').replace('&=y','')).replace('.html&','.html?').replace('.htm&','.htm?') + lh; lhit(prevmysel,this);\"><option value=''>digital clock</option><option value=analogue" + analoguesuffix + ">analogue clock</option><option value=both" + bothsuffix + ">digital and analogue clock</option></select> sponsored by SVG is<br><br><br><object id=myclock data='svg_clock.php" + uprefix.replace('&','?') + "' width='" + nh + "' height='530' type='image/svg+xml' /></p>");
}
document.write("<iframe style=height:60vh; frameborder=0 id='loces' onload='getmelt(this);' src='cldate.php?localtime=y&firstcall=" + ('' + Intl.DateTimeFormat().resolvedOptions().timeZone) + '&nowis=' + ('0' + (new Date().getHours())).slice(-2) + ':' + ('0' + (new Date().getMinutes())).slice(-2) + "'></iframe>");
</script>
<!--iframe style=height:60vh; frameborder=0 id='loces' onload='getmelt(this);' src='cldate.php?localtime=y'></iframe-->

</body>

… “helper” code to create the amended favicon.svg and amend the parent to use the new favicon.svg as per …

<?php

$pdt="";

if (strpos(('' . $_SERVER['QUERY_STRING']), "localtime") !== false) {
if (strpos(('' . $_SERVER['QUERY_STRING']), "firstcall") !== false) {
if (strpos(('' . $_SERVER['QUERY_STRING']), "nowis=") !== false) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'favicon.svg')) {
$fsvg=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'favicon.svg');
if (strpos($fsvg, '</text>') !== false) {
$curts=explode('>', explode('</text>', $fsvg)[0])[-1 + sizeof(explode('>', explode('</text>', $fsvg)[0]))];
if (strpos($fsvg, '>' . $curts . '</text>')) {
$pdt=" parent.document.title+=' you started at " . str_replace('+',' ',urldecode($_GET['nowis'])) . " local time'; parent.document.getElementById('myh1').innerHTML+='<font size=1> ... you started at " . str_replace('+',' ',urldecode($_GET['nowis'])) . " local time</font>'; ";
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'favicon.svg', str_replace('>' . $curts . '</text>', '>' . str_replace('+',' ',urldecode($_GET['nowis'])) . '</text>', $fsvg));
}
}
}
} else {
$localtime = localtime();
if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'favicon.svg')) {
$fsvg=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'favicon.svg');
if (strpos($fsvg, '</text>') !== false) {
$curts=explode('>', explode('</text>', $fsvg)[0])[-1 + sizeof(explode('>', explode('</text>', $fsvg)[0]))];
if (strpos($fsvg, '>' . $curts . '</text>')) {
$pdt=" parent.document.title+=' you started at " . substr(('0' . $localtime[2]),-2,2) . ':' . substr(('0' . $localtime[1]),-2,2) . " local time'; parent.document.getElementById('myh1').innerHTML+='<font size=1> ... you started at " . str_replace('+',' ',urldecode($_GET['nowis'])) . " local time</font>'; ";
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'favicon.svg', str_replace('>' . $curts . '</text>', '>' . substr(('0' . $localtime[2]),-2,2) . ':' . substr(('0' . $localtime[1]),-2,2) . '</text>', $fsvg));
}
}
}
}

}
echo "<html><head><script type='text/javascript'> var iwois=null; </script></head><body><div id=mydiv></div><script type='text/javascript'>
var asuff='" . $midbit . $csuff . "';
var adate = new Date();
var dow=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var his=eval('' + adate.getHours());
var mis=eval('' + adate.getMinutes());
var sis=eval('' + adate.getSeconds());
var ssuff='';
if (('' + adate).indexOf(' GMT') != -1) { ssuff=' GMT' + ('' + adate).split(' GMT')[1]; }
if (1 == 1) {
document.getElementById('mydiv').innerHTML=dow[eval('' + adate.getDay())] + ' ' + ('0' + his).slice(-2) + ':' + ('0' + mis).slice(-2) + ':' + ('0' + sis).split('.')[0].slice(-2) + ' ' + ('0' + adate.getDate()).slice(-2) + ' ' + ('0' + eval(1 + eval('' + adate.getMonth()))).slice(-2).replace('01','Jan').replace('02','Feb').replace('03','Mar').replace('04','Apr').replace('05','May').replace('06','Jun').replace('07','Jul').replace('08','Aug').replace('09','Sep').replace('10','Oct').replace('11','Nov').replace('12','Dec') + ' ' + ('' + adate.getFullYear()) + ' ' + ssuff + asuff;
} else {
document.write(dow[eval('' + adate.getDay())] + ' ' + ('0' + his).slice(-2) + ':' + ('0' + mis).slice(-2) + ':' + ('0' + sis).split('.')[0].slice(-2) + ' ' + ('0' + adate.getDate()).slice(-2) + ' ' + ('0' + eval(1 + eval('' + adate.getMonth()))).slice(-2).replace('01','Jan').replace('02','Feb').replace('03','Mar').replace('04','Apr').replace('05','May').replace('06','Jun').replace('07','Jul').replace('08','Aug').replace('09','Sep').replace('10','Oct').replace('11','Nov').replace('12','Dec') + ' ' + ('' + adate.getFullYear()) + ' ' + ssuff + asuff);
}
var myl=parent.document.getElementById('mylink').href;
if (myl.indexOf('JUNK') != -1) { parent.document.getElementById('mylink').href='/favicon.svg?rand=" . rand(0, 4534567) . "'; " . $pdt . " }

</script></body></html>";
}

?>

Interesting, huh?!


Previous relevant SVG Network Clock Minimize Tutorial is shown below.

SVG Network Clock Minimize Tutorial

SVG Network Clock Minimize Tutorial

Today’s blog posting’s underlying SVG Network Clock web application (we last talked about with Colour Wheel Size and Spoke Colour Tutorial’>Colour Wheel Size and Spoke Colour Tutorial) shares a couple of commonalities with yesterday’s MAMP Timekeeping Web Application Visibility Tutorial, those being …

… those Page Visibility API ideas you might equate to “minimize” concepts, that originated when GUIs were left to deal with how to present the representation of an application when it is no longer front and center in front of the user as an opened up window. We’d “minimize” back down to the desktop icon or toolbar view of the application. Web browsers can have tabs for this equivalent purpose, and we can improve the usefulness of a web application that can still be useful when “minimized” out of the top viewing tab. Date and time themed web applications can be your more obvious candidate for usefulness here. Just present a form of “digital clock readout” and your web applications like our SVG Network Clock can still be a source of information, even when “minimized”. We think that is an improvement?!

As you might have noticed with the last application of Page Visibility API “smarts”, this API is not hard to use, but for the first time we can remember, making changes just to the changed HTML supervisor svg_clock.html SVG Network Clock supervisor HTML and Javascript, and only changed to see in a new external Javascript svg_clock.js helper, we saved coding time by being able to …

  • scrutinize the DOM …
  • within an “object” HTML element’s …
  • SVG … featuring in some new Javascript with its own Page Visibility API reference

    function huhcont() {
    var dtidea='';
    var dotwis=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
    if (document.title != origdtis || ishd == ishd.toUpperCase()) { setTimeout(huhcont, 1000); }
    ishd == ishd.toLowerCase();
    if (document.getElementById('myclock') && ('' + document.visibilityState) == 'hidden') {
    if (document.getElementById('myclock').contentDocument.documentElement.outerHTML.indexOf(' id="sclock"') != -1) {
    console.log('predtidea');
    dtidea=document.getElementById('myclock').contentDocument.documentElement.outerHTML.split(' id="sclock"')[1].split('<')[0].split('>')[1].trim();
    console.log('dtidea=' + dtidea + ' ... ' + document.URL);
    if (dtidea != '') {
    document.title=dtidea;
    } else if (document.URL.indexOf('timezone=') != -1) {
    document.title=('' + new Date().toLocaleString("en-US", {timeZone: (location.search.split('timezone=')[1] ? decodeURIComponent(location.search.split('timezone=')[1].split('&')[0]) : "")}) + ' ' + (location.search.split('timezone=')[1] ? decodeURIComponent(location.search.split('timezone=')[1].split('&')[0]) : "") + ' ' + (location.search.split('emflag=')[1] ? decodeURIComponent(location.search.split('emflag=')[1].split('&')[0]) : ""));
    } else {
    document.title=new Date().toLocaleString("en-US", {timeZone: "GMT"});
    }
    } else {
    console.log('Why?');
    }
    }
    }

    … where we’d like to thank this useful link, thanks, for the heads up

Interesting, huh?!


Previous relevant MAMP Timekeeping Web Application Desktop Application Tutorial is shown below.

MAMP Timekeeping Web Application Desktop Application Tutorial

MAMP Timekeeping Web Application Desktop Application Tutorial

We figured that an improvement on the progress with our Timekeeping web application of the recent MAMP Timekeeping Web Application Audio Broadcast Tutorial would be to mention what macOS or Mac OS X Desktop Application is topmost when the screenshot is taken. When thinking about solutions for this, there was not much time before thinking turned to …

  • Apple Script, which has its GUI Apple “look” … but also …
  • Apple Script PHP shell_exec and (macOS Terminal) command line accessible osascript command line “look” too

… and excellent resources such as this excellent one to read that made us realize a PHP codeline such as …

<?php

$tma="";
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'script.jxa')) {
// Thanks to https://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title
$scris="var seApp = Application(\"System Events\");
var oProcess = seApp.processes.whose({frontmost: true})[0];
var appName = oProcess.displayedName();

var url;
var title;

switch(appName) {
case \"Safari\":
url = Application(appName).documents[0].url();
title = Application(appName).documents[0].name();
break;
case \"Opera\":
url = Application(appName).windows[0].activeTab().url();
title = Application(appName).windows[0].activeTab().name();
break;
case \"Google Chrome\":
url = Application(appName).windows[0].activeTab().url();
title = Application(appName).windows[0].activeTab().name();
break;
case \"Google Chrome Canary\", \"Chromium\":
url = Application(appName).windows[0].activeTab().url();
title = Application(appName).windows[0].activeTab().name();
break;
default:
title = oProcess.
windows().
find(w => w.attributes.byName(\"AXMain\").value() === true).
attributes.
byName(\"AXTitle\").
value()
}

JSON.stringify({
appname: appName,
url: url,
title: title
});";
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'script.jxa', $scris);
}
$tma=shell_exec('osascript -l JavaScript ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'script.jxa');

?>

… can glean such useful JSON results such as …


{"appname":"Safari","url":"http://localhost:8888/HTMLCSS/quarter_hour_timer.php?tz=Australia%2FSydney&qs=e&audiosave=%20-v%20Victoria%20%20-o%20out.aiff%20%20Screenshot%20%20at%20Monday%20July%2025%202022%2021%2030%20AEST","title":"‎localhost:8888/HTMLCSS/quarter_hour_timer.php?tz=Australia%2FSydney&qs=e&audiosave=%20-v%20Victoria%20%20-o%20out.aiff%20%20Screenshot%20%20at%20Monday%20July%2025%202022%2021%2030%20AEST"}

… well, it almost makes us speechless!

This change affected …

… and we hope you try it for yourself!


Previous relevant MAMP Timekeeping Web Application Audio Broadcast Tutorial is shown below.

MAMP Timekeeping Web Application Audio Broadcast Tutorial

MAMP Timekeeping Web Application Audio Broadcast Tutorial

We thought what could be a benefit to the Timekeeping web application of the recent MAMP Timekeeping Web Application Web Share Personalization Tutorial would be to …

  • offer an optional audio broadcasting piece of functionality … presented via a new 📢 (&#128226;) emoji button, that might accompany …
  • notifications

… when a screenshot is taken. As good as notifications are, it could be that the user is beavering away with their head down at work as the screenshot is taken, but welcome the audio queue that a Timekeeping screenshot has been taken. As well as that, with this new audio broadcasting, the *.aiff audio files created are available to share via email or SMS using the Web Share API interfacing code. This involved changes to …


Previous relevant MAMP Timekeeping Web Application Web Share Personalization Tutorial is shown below.

MAMP Timekeeping Web Application Web Share Personalization Tutorial

MAMP Timekeeping Web Application Web Share Personalization Tutorial

Your words, helped out by some computer derived detail data, can help personalize your work using the Quarter Hour Timekeeping web application of yesterday’s MAMP Timekeeping Web Application Web Share API Tutorial which, at least with the Safari browser (and a whole lot of other macOS conditions), now integrates with the Web Share API to attach images to prepared emails with a “body blurb”. It is that prepared “body blurb” we are trying to refine, today, should the user attach any of those Timekeeper screenshot files created via macOS screencapture command.

This is because these screenshot file names, by our convention, are of the format …


screen-yyyymmdd-hhmi.jpg

… within the macOS MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] folder (though the path to the file is unavailable to File API File object programmers).

That, teamed with the fact that individual user comments linked to any one quarter hour screenshot image has an ID attribute of the form …


tatd_yyyymmdd_hhmi

… and you have modified Javascript helping the user to tailor better personalized and detail email or SMS communications using the changed macos_say_record.js external Javascript via …


var wsadate=new Date();
var lfd=String.fromCharCode(10);

function getwsadate(dd, mm, yyyy, hh, mi) {
wsadate=new Date(yyyy, eval(-1 + eval('' + mm)), dd, hh, mi, 0, 0);
var outdstr=wsadate.toDateString() + ' ' + wsadate.toTimeString();
outdstr=outdstr.replace('Sun ', 'Sunday ').replace('Mon ', 'Monday ').replace('Tue ', 'Tuesday ').replace('Wed ', 'Wednesday ').replace('Thu ', 'Thursday ').replace('Fri ', 'Friday ').replace('Sat ', 'Saturday ');
outdstr=outdstr.replace(':00 ', ' ').replace(' Jan ', ' January ').replace(' Feb ', ' February ').replace(' Mar ', ' March ').replace(' Apr ', ' April ').replace(' Jun ', ' June ').replace(' Jul ', ' July ').replace(' Aug ', ' August ').replace(' Sep ', ' September ').replace(' Oct ', ' October ').replace(' Nov ', ' November ').replace(' Dec ', ' December ');
//console.log('tatd_' + yyyy + mm + dd + '_' + hh + mi);
if (document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi)) {
//console.log('yes tatd_' + yyyy + mm + dd + '_' + hh + mi);
if (document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi).value.trim() != '') {
outdstr+=' ' + String.fromCharCode(10) + '"' + document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi).value + '"';
} else if (document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi).innerHTML.trim() != '') {
outdstr+=' ' + String.fromCharCode(10) + '"' + document.getElementById('tatd_' + yyyy + mm + dd + '_' + hh + mi).innerHTML + '"';
}
}
lfd='';
return outdstr + String.fromCharCode(10);
}


async function atclick() {
const files = document.getElementById('files').files;
var moressi='', ifl=0, lessssi='';

if (files.length === 0) {
shareurl();
document.getElementById('output').textContent = 'No files selected.';
return;
} else {
for (ifl=0; ifl<files.length; ifl++) {
if (('' + files[ifl].name).indexOf('screen-') != -1) {
if (('' + files[ifl].name).split('screen-')[1].split('-')[0].length == 8) {
if (('' + files[ifl].name).split('screen-')[1].split('-')[1].split('.')[0].length == 4) {
moressi+=lfd + ' on ' + getwsadate(('' + files[ifl].name).split('screen-')[1].split('-')[0].slice(-2), ('' + files[ifl].name).split('screen-')[1].split('-')[0].slice(-4).substring(0,2), ('' + files[ifl].name).split('screen-')[1].split('-')[0].substring(0,4), ('' + files[ifl].name).split('screen-')[1].split('-')[1].split('.')[0].substring(0,2), ('' + files[ifl].name).split('screen-')[1].split('-')[1].split('.')[0].slice(-2));
}
}
}
}

}

lessssi=moressi;
while (lessssi.indexOf(String.fromCharCode(10)) != -1) {
lessssi=lessssi.replace(String.fromCharCode(10), ' ');
}


// feature detecting navigator.canShare() also implies
// the same for the navigator.share()
if (!navigator.canShare) {
//if (document.URL.indexOf('localhost') != -1) { alert('Can not share'); }
document.getElementById('output').textContent = `Your browser doesn't support the Web Share API.`;
return;
//} else {
//if (document.URL.indexOf('localhost') != -1) { alert('Can Share'); }
}

if (navigator.canShare({ files })) {
try {
console.log('Can share');
await navigator.share({
files,
title: 'Timekeeping screenshots' + lessssi + ' or media or documents',
text: 'Timekeeping screenshots' + moressi + ' perhaps?! Take a look at media or documents below' + String.fromCharCode(10) + String.fromCharCode(10)
});
document.getElementById('output').textContent = 'Shared!';
} catch (error) {
document.getElementById('output').textContent = `Error: ${error.message}`;
}
} else {
//if (document.URL.indexOf('localhost') != -1) { alert('Cannot share'); }
document.getElementById('output').textContent = `Your system doesn't support sharing these files.`;
}
lfd=String.fromCharCode(10);
}


Previous relevant MAMP Timekeeping Web Application Web Share API Tutorial is shown below.

MAMP Timekeeping Web Application Web Share API Tutorial

MAMP Timekeeping Web Application Web Share API Tutorial

Adding onto yesterday’s MAMP Timekeeping Web Application Audio Commentary Tutorial

  • Timekeeping Web Application newish Text to Audio (via macOS say via MAMP “Intranet feel”) … today, we have …
  • Timekeeping Web Application new Web Share API (public domain Document Root external Javascript Web Share API) Javascript logic

This got us decoupling what can become …

… but as we’ve warned before you may need all these for total success for the Timekeeping Quarter Hour Timer web application (that can screenshot, can create notification when screenshot taken, and have audio commentary, and share screenshot image(s) or Timekeeper URL) …


Previous relevant MAMP Timekeeping Web Application Audio Commentary Tutorial is shown below.

MAMP Timekeeping Web Application Audio Commentary Tutorial

MAMP Timekeeping Web Application Audio Commentary Tutorial

The recent MAMP Timekeeping Web Application PHP Notifications Tutorial‘s Timekeeping via Screenshots changed HTML and Javascript quarter_hour_timer.html (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) Web Application supervisor is another very suitable candidate for interfacing to our recent Webpage Audio Commentary functionality. Both …

… share an …

  • underlying macOS or Mac OS X operating system dependence …
  • underlying local web server such as MAMP …
  • downloaded into that local web server Document Root folder PHP code

… set of interest points for full and useful functionality, because of two macOS or Mac OS X commands, respectively …

We add the changed macos_say_record.js external Javascript call into the supervisory HTML and Javascript <head></head> webpage section via …


<script type='text/javascript' src='//www.rjmprogramming.com.au/macos_say_record.js?ongoing=1721156687576' defer></script>

… sitting up at the Document Root of your public domain, that “?ongoing=” based $_GET[‘ongoing’] argument deliberate, effectively asking the code to look out for “on the fly” HTML elements created within an execution run of the webpage.

We add some “smarts” to those global data attribute usage we talked about at Webpage macOS Say Audio Commentary Access Count Tutorial, allowing some “date extraction” templating via the supervisory HTML and Javascript array declaration as per


<script type='text/javascript'>
var commentary_array=['textarea', 'You can enter comments about this screenshot here %value%outerHTML%@yyyymmdd%hhmm%.', 'img', 'Timekeeper screenshot here %id%@yyyymmdd%hhmm%.'];
</script>

… where the first field describes an HTML element attribute to first look at, the optional second is a stand by attribute, followed by “date extraction” fields to match with numerical data found so as to substitute the blue parts with a “date and timestamp” string.


Previous relevant MAMP Timekeeping Web Application PHP Notifications Tutorial is shown below.

MAMP Timekeeping Web Application PHP Notifications Tutorial

MAMP Timekeeping Web Application PHP Notifications Tutorial

Today we’re revisiting the macOS (or Mac OS X) or Windows timekeeping web application of 2016’s Mac OS MAMP Timekeeping Web Application PHP Calendar Aesthetics Tutorial. Why? Well, given our recent work with Notifications API based web applications you can read about at Notification API Hidden Popup Tutorial, the timekeeping one is a great candidate for functionality improvement here, it being a web application that …

  • can work behind the scenes …
  • not necessarily frontmost … but benefitting from any …
  • notification reminders separate from web activities and webpage focus issues can help tell the user when they might want to turn back attention to the timekeeping screenshot recording

This needs PHP to work and it needs real access via PHP exec function to underlying operating system commands. When this happens, we still try to offer a public RJM Programming interface but this interface is far less useful if you have not downloaded to your local Apache/PHP/MySql local web server (such as a MAMP one) as per …

  1. the changed quarter_hour_timer.php (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) Timekeeping Web Application suited to macOS (or Mac OS X) “screencapture” command line usage
  2. the unchanged (from tutorial below, supervisory HTML and Javascript) quarter_hour_timer.html (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) Timekeeping Web Application
  3. the “how we got there” PHP notifications_ideas.php (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] subfolder) Notification API functionality PHP web application

… in what we like to call an “Intranet feeling” scenario.

Up at the public RJM Programming domain, as far as the Notification API functionality supervisor webpage goes, the changed HTML and Javascript notifications_ideas.html Notification API functionality HTML and Javascript web application is worth trying.


Previous relevant Mac OS MAMP Timekeeping Web Application PHP Calendar Aesthetics Tutorial is shown below.

Mac OS MAMP Timekeeping Web Application PHP Calendar Aesthetics Tutorial

Mac OS MAMP Timekeeping Web Application PHP Calendar Aesthetics Tutorial

To finish up our revisit to the Timekeeping web application of the recent Mac OS MAMP Timekeeping Web Application PHP Calendar Iframe Tutorial we …

  • make some styling calendar tweaks

    <style>
    td { vertical-align: top; }
    #divmc { background-color: #ffffff; }
    p:not(:empty) { border: 1px dotted red; }
    td { text-align: center; vertical-align: top; }
    th { background-color: cyan; }
    #thyear { background-color: pink; }
    div { word-wrap: break-word; }
    .adaNOte { border: 3px solid pink; border-radius: 7px; }
    a.adate { border:2px solid transparent; background-color:lightgreen; border-radius:50px; }

    </style>
  • settle for mobile platforms never being able to screenshot, on this round of looking, and redirecting to the “Monthly Chronicler” web application (of (the unchanged) monthly_chronicler.html we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder)

    <script>
    if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPod|iPad|Opera Mini|IEMobile/i)) {
    document.write("<scri" + "pt> location.href='./monthly_chronicler.html'; </scr" + "ipt> <style> a.adate { border:1px solid green; background-color:#f0f0f0; border-radius:50px; } </style> <table id=mtable style=display:none;width:95%;><tr><th><input style=width:450px; placeholder='' id=iask type=text value=''></input><</th><th><input onclick=\" document.getElementById('mtable').style.display='none'; document.getElementById('mybod').style.opacity='1.0'; postask(document.getElementById('iask'));\" type=button value=OK></input></th><th><input onclick=\"document.getElementById('iask').value=''; document.getElementById('mtable').style.display='none'; document.getElementById('mybod').style.opacity='1.0'; \" type=button value=Cancel></input></th></tr></table>");
    }
    </script>

    … dumbing down, but working more reliably, using “Javascript writes Javascript” methodology

Again, feel free to try the changed quarter_hour_timer.html (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) Timekeeping Web Application suited to macOS (or Mac OS X) “screencapture” command line usage, is helped out by a “mobile platform check” changed quarter_hour_timer.php PHP (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) for you to try out on your MAMP macOS environment, or all showing up at an RJM Programming public domain webpage, in an iframe element, visible now.


Previous relevant Mac OS MAMP Timekeeping Web Application PHP Calendar Windows Tutorial is shown below.

Mac OS MAMP Timekeeping Web Application PHP Calendar Windows Tutorial

Mac OS MAMP Timekeeping Web Application PHP Calendar Windows Tutorial

Did you notice that the “Timekeeping” PHP did not have to change for yesterday’s Mac OS MAMP Timekeeping Web Application PHP Calendar iCal Integration Tutorial?

But the PHP is the change agent for Windows (client) integration called quarter_hour_timer.php today …

<?php

// blah top
$lportbit=":8888";

$user_agent = $_SERVER["HTTP_USER_AGENT"];
function getOS() { // thanks to https://www.daniweb.com/programming/web-development/threads/495588/getting-users-os-info-out-of-server-http-user-agent
global $user_agent, $lportbit;
$os_platform = "win Unknown OS Platform";
$os_array = array(
'/windows nt 10/i' => 'Windows 10',
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
'/windows nt 5.1/i' => 'Windows XP',
'/windows xp/i' => 'Windows XP',
'/windows nt 5.0/i' => 'Windows 2000',
'/windows me/i' => 'Windows ME',
'/win98/i' => 'Windows 98',
'/win95/i' => 'Windows 95',
'/win16/i' => 'Windows 3.11',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
);

foreach ($os_array as $regex => $value) {

if (preg_match($regex, $user_agent)) {
$os_platform = $value;
}

}

return $os_platform;
}

$callornot="call ";
$precmds="";
$impreexe="screenCapture"; //"import";
$switches=""; //" -window root ";
if (substr(strtoupper(getOS()),0,3) === 'WIN') {
$lportbit="";
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "\\" . $impreexe . ".exe")) {
$precmds=$_SERVER['DOCUMENT_ROOT'] . "\\";
} else {
foreach (glob("C:\\Users\\*\\" . $impreexe . ".exe") as $infl) {
$precmds=explode($impreexe . ".exe", $infl)[0];
}
}
}

// blah blah some other PHP functions

if (isset($_GET['yourta'])) {
// calendar work
} else if (isset($_GET['myta'])) {
// embed image metadata
} else if (isset($_POST['myta'])) {
// parse image metadata
} else if ($lportbit != "") {
exec("/usr/sbin/screencapture -Cd -tjpg " . $_SERVER['DOCUMENT_ROOT'] . "/screen-`date +\"%Y%m%d-%H%M\"`.jpg");
} else {
if (isset($_GET['tz'])) {
$tzis=str_replace('+','_',urldecode($_GET['tz']));
if (strpos($tzis, "/") !== false) { date_default_timezone_set($tzis); }
}
$dateis = date('Ymd-Hi');
if (file_exists($_SERVER['DOCUMENT_ROOT'] . "\\screenCapture.jpg")) {
exec('copy ' . '"' . $_SERVER['DOCUMENT_ROOT'] . "\\screenCapture.jpg" . '" "' . $_SERVER['DOCUMENT_ROOT'] . "\\screen-" . $dateis . '.jpg"');
// exec('erase ' . '"' . $_SERVER['DOCUMENT_ROOT'] . "\\screenCapture.jpg" . '"');
} else {
exec($callornot . '"' . $precmds . $impreexe . '.exe" ' . $switches . ' "' . $_SERVER['DOCUMENT_ROOT'] . "\\screen-" . $dateis . '.jpg"');
}
}

exit;

?>

… which you may glean has a Windows “fallback” position (with that “copy” codeline). Why? Well, we found a .Net framework “exe creation via bat” using ScreenCapture.bat (thanks to this useful link) created black screen shots. Probably a privilege thing or PHP exec thing, but we’ve opted for the workaround, which is just “Windows talk” …

  • write Windows batch scapcontinuous.bat as a continuous fifteen minute user of the .Net Framework (ScreenCapture.exe) derived from above
  • set up a task via “Task Schedular” (please ignore the warts ‘n all “garden path” schtask ideas in the video below) that has an action “C:\MAMP\htdocs\scapcontinuous.bat” and starts when the Windows user logs in and takes (successful) screen shots at 14 and 29 and 44 and 59 minutes (in the hour) times

Take a more detailed look at “warts ‘n all” crab progression towards the Windows (client) solution, below …


Previous relevant Mac OS MAMP Timekeeping Web Application PHP Calendar iCal Integration Tutorial is shown below.

Mac OS MAMP Timekeeping Web Application PHP Calendar iCal Integration Tutorial

Mac OS MAMP Timekeeping Web Application PHP Calendar iCal Integration Tutorial

Yesterday’s Mac OS MAMP Timekeeping Web Application PHP Calendar Contenteditable Tutorial‘s “Calendar Past” improvements don’t have to be the end of the story regarding “calendar timings”. There is an Apple iCal standard interfacing format that can drive calendar integrations with many well known online Calendar applications.

You may recall us talking about this with Calendar Location Services Integration Tutorial and we tweak the changed ics_attachment.php (which we’d ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “PHP” subfolder) and its standalone ical creator to better integrate with the changed quarter_hour_timer.html (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) Timekeeping Web Application suited to macOS (or Mac OS X) “screencapture” command line usage.

This bit of functionality works (interfacing) both with MAMP and with the public RJM Programming domain incarnation of the Timekeeping web application, so that could be interesting. It can interface via …

… modes of use. In action, should you create an iCal file this way, the web application will download the resultant .ics file into your Downloads folder and to interface into your default online Calendar application double click that Downloads folder file to complete the Calendar integration …


function icalpostit(tl, tg) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
var hh = today.getHours();
var minm = today.getMinutes(); //January is 0!
//if (icalavailable) { alert('is ' + ('' + yyyy + ('00' + mm).slice(-2) + ('00' + dd).slice(-2) ) + ' >= ' + tl.substring(1)); }
if ((document.getElementById('yics').value.indexOf('all') != -1 || tl.substring(1) >= ('' + yyyy + ('00' + mm).slice(-2) + ('00' + dd).slice(-2) )) && icalavailable && document.getElementById('yics').value != '') {
if (document.getElementById('yics').value.indexOf('nw') != -1) {
icald=tl.substring(1) + ':' + ('00' + hh).slice(-2) + ('00' + minm).slice(-2) + '59';
icalg=tg;
if (icalwo != null) { icalwo.close(); icalwo=null; }
icalwo=window.open('../PHP/ics_attachment.php','_blank','top=100,left=100,width=740,height=800');
if (1 == 1) {
setTimeout(icalw, 3000);
} else {
icalwo.document.getElementById('datestart').value=icald;
icalwo.document.getElementById('dateend').value=icald;
icalwo.document.getElementById('eventwords').value=icalg.replace(/\<br\>/g, String.fromCharCode(10)).replace(/\<Br\>/g, String.fromCharCode(10)).replace(/\<BR\>/g, String.fromCharCode(10));
if (document.URL.indexOf('localhost') != -1) {
var jcald=icalg.replace(/\<br\>/g, String.fromCharCode(10)).replace(/\<Br\>/g, String.fromCharCode(10)).replace(/\<BR\>/g, String.fromCharCode(10)).replace(/\ \;>/g, ' ');
while (jcald.indexOf(String.fromCharCode(10)) != -1) { jcald=jcald.replace(String.fromCharCode(10),' '); }
icalwo.document.getElementById('title').value=jcald;
} else {
icalwo.document.getElementById('title').value='Calendar event at ' + icald;
}
icalwo.document.getElementById('description').value='Calendar event at ' + icald;
icalwo.document.getElementById('address').value=document.URL.split('?')[0].split('#')[0];
icalwo.document.getElementById('mmdatestart').value=icald.substring(4,6);
icalwo.document.getElementById('mmdateend').value=icald.substring(4,6);
icalwo.document.getElementById('dddatestart').value=icald.substring(6,8);
icalwo.document.getElementById('dddateend').value=icald.substring(6,8);
icalwo.document.getElementById('ssdatestart').value='59';
icalwo.document.getElementById('ssdateend').value='59';
icalwo.document.getElementById('yyyydatestart').value=icald.substring(0,4);
icalwo.document.getElementById('yyyydateend').value=icald.substring(0,4);
if ( ('' + today.getTimezoneOffset()).replace('null','').replace('undefined','') != '' ) {
//alert(('' + eval(eval('' + qd.getTimezoneOffset()) / 60.0)).replace('.00','').replace('.0',''));
icalwo.document.getElementById('tz').value=('' + eval(eval('' + today.getTimezoneOffset()) / 60.0)).replace('.00','').replace('.0','');
}
//icalwo.document.getElementById('pform').onsubmit=function() { window.opener.document.getElementById('icalstatus').innerHTML=' '; return true; };

}
} else if (document.getElementById('yics').value.indexOf('if') != -1) {
icald=tl.substring(1) + ':' + ('00' + hh).slice(-2) + ('00' + minm).slice(-2) + '59';
icalg=tg;
document.getElementById('divics').style.display='block';
document.getElementById('divics').style.width='100%';
document.getElementById('divics').style.height='800px';
document.getElementById('icslocit').style.display='block';
document.getElementById('icslocit').style.width='100%';
document.getElementById('icslocit').style.height='800px';
document.getElementById('icslocit').src='../PHP/ics_attachment.php?rand=' + Math.floor(Math.random() * 19876564);
} else {
var xzhr = new XMLHttpRequest();
var xform=new FormData();
xform.append('icald',tl.substring(1) + ':' + ('00' + hh).slice(-2) + ('00' + minm).slice(-2) + '59');
xform.append('icalc',tg);
xzhr.open('post','./quarter_hour_timer.php',true);
xzhr.send(xform);
}
}
}


Previous relevant Mac OS MAMP Timekeeping Web Application PHP Calendar Contenteditable Tutorial is shown below.

Mac OS MAMP Timekeeping Web Application PHP Calendar Contenteditable Tutorial

Mac OS MAMP Timekeeping Web Application PHP Calendar Contenteditable Tutorial

We’ve spoken quite a bit in the past about the joys of involving the “contenteditable=true” attribute for HTML elements that have an “innerHTML” (ie. they have a formalized end tag arrangement eg. div, span, p, td, th etcetera) and with today’s work which extends that started with yesterday’s Mac OS MAMP Timekeeping Web Application PHP Calendar Past Tutorial it is the turn of a set of “p” elements it helps out today.

The scenario is that yesterday’s work did not allow for “orphaned screenshots” of the past be allowed to be brought back into play to “annotate them” and in so doing “give them a home”. This led us to …

  • allow for a new “Infill Earlier Days All Screenshots” button augment yesterday‘s “Infill Earlier Days Just Annotated Screenshots” button …
  • the pressing of that new “Infill Earlier Days All Screenshots” button causes all screenshot 15 minute entries relevant to the current year be displayed in the calendar … but then it occurred to us users might want to “annotate them” … but how? …
  • in the PHP we introduced code
    <?php

    if (isset($_GET['yourta'])) {
    $dru="http://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . "/";
    $cet="";
    if (strlen($_GET['yourta']) != 0) { $cet=" contenteditable=true onblur=repostit(this); onfocus=wopen(event,false); "; }

    // blah blah blah
    $ccpre="" . $cet . " onclick=this.innerHTML+=String.fromCharCode(60)+String.fromCharCode(98)+String.fromCharCode(114)+String.fromCharCode(62); style=background-color:orange;background-repeat:no-repeat;background-size:contain;background-image:linear-gradient(rgba(255,255,255,0.3),rgba(255,255,255,0.3)),URL(" . $dru . str_replace('_','-',str_replace('itd_','screen-',$myf)) . ".jpg" . "); onmouseover=wopen(event,true); onmouseout=wopen(event,false); title=" . substr(str_replace('td','p',$cali),-4,2) . ":" . substr(str_replace('td','p',$cali),-2,2) . "++ id=" . str_replace('td','p',$cali) . ">";
    // blah blah blah
    }

    ?>
    … to, when an “orphaned” screen shot image is happened upon, allows …
  • contenteditable=true “does its stuff” turning might might have been a pretty unintelligent HTML element into a “textarea” type collector of user input, and then that onblur event logic’s “midair feeling” Ajax/FormData “recursive feeling” methodology …

    function repostit(ih) {
    var ihis=(ih.innerText || ih.contentWindow || ih.contentDocument);
    var pathpart=ih.id;
    if (ihis != '') {
    var xzhr = new XMLHttpRequest();
    var xform=new FormData();
    xform.append('myta',ihis);
    xform.append(pathpart.split('.')[0].replace('ip_','screen-').replace('_','-'),'');
    xzhr.open('post','./quarter_hour_timer.php',true);
    xzhr.send(xform);
    }
    }

    … which can cement that (newly user entered) annotation into future permanency in the “Yearly Report Calendar” section

… of the changed quarter_hour_timer.html (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) Timekeeping Web Application suited to macOS (or Mac OS X) “screencapture” command line usage, is helped out by a contenteditable=true changed quarter_hour_timer.php PHP (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) for you to try out on your MAMP macOS environment.


Previous relevant Mac OS MAMP Timekeeping Web Application PHP Calendar Past Tutorial is shown below.

Mac OS MAMP Timekeeping Web Application PHP Calendar Past Tutorial

Mac OS MAMP Timekeeping Web Application PHP Calendar Past Tutorial

If you’ve been using the Timekeeping web application as of yesterday’s Mac OS MAMP Timekeeping Web Application PHP Calendar Tutorial you would have noticed a very …

  • first person
  • present tense

… feel to it all. Today, we improve on the latter “restrictiveness” issue, within yesterday’s “Yearly Report Calendar” new functionality, by looking back into the current calendar year’s “past” with respect to the date of using the web application, whether that be …

  • screen captures from days in the current calendar year’s “past”
  • text entries made and remembered (in window.localStorage) in the current calendar year’s “past”

… to infill and flesh out that “Yearly Report Calendar” better. This involved bringing over a lot of (the unchanged) monthly_chronicler.html‘s Javascript logic into the changed quarter_hour_timer.html (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) Timekeeping Web Application suited to macOS (or Mac OS X) “screencapture” command line usage, is helped out by a calendar’s past integrationally changed quarter_hour_timer.php PHP (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) for you to try out on your MAMP macOS environment.

<?php

// quarter_hour_timer.php
// RJM Programming
// December, 2021

if (isset($_GET['yourta'])) {
$dru="HTTP://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . "/";
$contis=str_replace('+',' ',urldecode($_GET['yourta']));
//file_put_contents('xx.xx', $contis);
$htmlis='';
$myf='';
$backi='';
$cali='';
$taback='';
$bcontis="'" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "' + String.fromCharCode(10) + '", str_replace("\r\n", "' + String.fromCharCode(10) + '", str_replace("'", "' + String.fromCharCode(39) + '", $contis)))) . "'";
if (substr(($bcontis . ' '),0,3) == "' + ") { $bcontis=$bcontis.substr(3); }
if (substr((' ' . $bcontis),-3,3) == " + '") { $bcontis=$bcontis.substr(0,(-3 + strlen($bcontis))); }
foreach ($_GET as $name=>$val) {
if ($name != 'yourta') { // && $val == '') {
//echo $name;
$orig=$name;
$myf=$name;
for ($imh=12; $imh>=1; $imh--) {
for ($idd=31; $idd>=1; $idd--) {
//file_put_contents('xz.xz',$orig . ' Is ' . substr('00' . $imh,-2,2) . substr('00' . $idd,-2,2) . ' less than ' . $val);
if (substr('00' . $imh,-2,2) . substr('00' . $idd,-2,2) < $val) {
for ($ihh=0; $ihh<=23; $ihh++) {
for ($imm=0; $imm<=45; $imm+=15) {
//if ($ihh != 0 || $imm != 0) {
$myf=str_replace("0101_", substr('00' . $imh,-2,2) . substr('00' . $idd,-2,2) . "_",$orig);
$myf=str_replace("_0000", "_" . substr('00' . $ihh,-2,2) . substr('00' . $imm,-2,2),$myf);
//}
$taback=str_replace('-','_',str_replace('itd','tatd',$myf));
$backi=str_replace('-','_',str_replace('screen-','itd_',$myf));
$cali=str_replace('-','',str_replace('screen-','td',$myf));
$idcali=explode('-',explode('_',str_replace('screen-','td',str_replace('itd_','td',$myf)))[0])[0];

// Thanks to https://doc.bccnsoft.com/docs/php-docs-7-en/function.iptcembed.html

// Path to jpeg file
$path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . str_replace('_','-',str_replace('itd_','screen-',$myf)) . '.jpg';
//file_put_contents('x.x',$path);
if (file_exists($path)) {
$capt = ""; // Thanks to https://www.php.net/manual/en/function.iptcparse.php
$size = getimagesize( $path, $info );
if (isset($info["APP13"])) {
//file_put_contents('xx.xx',$path);
if ($iptc = iptcparse( $info["APP13"] ) ) {
//file_put_contents('xxx.xxx',$path);
$capt = str_replace( "\000", "", $iptc["2#120"][0] );
//file_put_contents('xxxx.xxxx',$capt);
}
}
$bcontis="" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "' + String.fromCharCode(10) + '", str_replace("\r\n", "' + String.fromCharCode(10) + '", str_replace("'", "' + String.fromCharCode(39) + '", $capt)))) . "";
$ccpre="<p onclick=this.innerHTML+=String.fromCharCode(60)+String.fromCharCode(98)+String.fromCharCode(114)+String.fromCharCode(62); style=background-color:orange;background-repeat:no-repeat;background-size:contain;background-image:linear-gradient(rgba(255,255,255,0.3),rgba(255,255,255,0.3)),URL(" . $dru . str_replace('_','-',str_replace('itd_','screen-',$myf)) . ".jpg" . "); onmouseover=wopen(event,true); onmouseout=wopen(event,false); title=" . substr(str_replace('td','p',$cali),-4,2) . ":" . substr(str_replace('td','p',$cali),-2,2) . "++ id=" . str_replace('td','p',$cali) . ">";
$ccpost="</p>";
$ccontis="<br><p style='background-color:orange; title='" . str_replace('td','p',$cali) . "' id=" . str_replace('td','p',$cali) . ">" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "<br>", str_replace("\r\n", "<br>", str_replace("'", "' + String.fromCharCode(39) + '", $capt)))) . "</p>";
//file_put_contents('xxxxx.xxxxx',$bcontis);
//file_put_contents('xxxxxx.xxxxxx',$taback . ' ... ' . $backi);
//file_put_contents('xxxxxxx.xxxxxxx',"parent.document.getElementById('" . $backi . "').title='" . $bcontis . "'; parent.document.getElementById('" . $taback . "').value='" . $bcontis . "'; ");

}

if ($bcontis != "''" && $bcontis != "") {
if ($htmlis == '') {
$htmlis="<html><head><script type=text/javascript> var imois=null, iwo=null; function wopen(event,overvsout) { if (!overvsout) { if (imois == event.target) { imois=null; } return; } imois=event.target; setTimeout(postwopen, 2000); } function postwopen() { var pois=imois; if (pois.outerHTML.indexOf('URL(') != -1) { window.open(pois.outerHTML.split('URL(')[1].split(')')[0].replace(String.fromCharCode(34),'').replace(String.fromCharCode(34),''),'_blank','top=50,left=50,width=600,height=600'); } }</script></head><body onload=\" var huhg=''; if (parent.document.getElementById('" . $idcali . "')) { huhg='" . $ccpre . $bcontis . $ccpost . "'; while (huhg.indexOf(String.fromCharCode(10)) != -1) { huhg=huhg.replace(String.fromCharCode(10),'<br>'); } parent.document.getElementById('" . $idcali . "').innerHTML+=huhg; } \"></body></html>";
} else if (strpos($htmlis, $bcontis) === false) {
$htmlis=str_replace("+=huhg; }", "+=huhg; huhg='" . $ccpre . $bcontis . $ccpost . "'; while (huhg.indexOf(String.fromCharCode(10)) != -1) { huhg=huhg.replace(String.fromCharCode(10),'<br>'); } parent.document.getElementById('" . $idcali . "').innerHTML+=huhg; }", $htmlis);
}
}

}
}

if ($htmlis != "") { echo $htmlis; }

}
}
}
}
}
}

// blah else if blah else if blah

?>

… which you may notice implements a “long hover” window.open scenario (using non-mobile platforms) for screenshot images on the calendar by combining the use of …

  • global variables …

    var imois=null;
    var iwo=null;
  • onmouseover event logic …
    Call
    onmouseover=wopen(event,true);
  • setTimeout delays …
    Called

    function wopen(event,overvsout) {
    if (!overvsout) {
    if (imois == event.target) {
    imois=null;
    }
    return;
    }
    imois=event.target;
    setTimeout(postwopen, 2000);
    }


    function postwopen() { //pois) {
    if (imois) {
    var pois=imois;
    if (pois.outerHTML.indexOf('URL(') != -1) {
    if (iwo) { iwo.close(); iwo=null; }
    iwo = window.open(pois.outerHTML.split('URL(')[1].split(')')[0].replace(String.fromCharCode(34), '').replace(String.fromCharCode(34), ''), '_blank', 'top=50,left=50,width=600,height=600');
    }
    }
    }
  • onmouseout event logic …
    Call
    onmouseout=wopen(event,false);

… so that this logic is not responsible for clobbering the default “hover” shows of the “p” element “title” attribute with the onmouseover event for non-mobile platforms.


Previous relevant Mac OS MAMP Timekeeping Web Application PHP Calendar Tutorial is shown below.

Mac OS MAMP Timekeeping Web Application PHP Calendar Tutorial

Mac OS MAMP Timekeeping Web Application PHP Calendar Tutorial

Okay then, yesterday’s Mac OS MAMP Timekeeping Web Application PHP Image Metadata Tutorial “image metadata smarts” puts us in a position to get onto the “bells and whistles” side of our Timekeeping (macOS and Mac OS X only at this stage) web application. We channel the calendar display talents of Monthly Chronicler LocalStorage Tutorial in thought and act (its web application is opened in an iframe … hence our need to ask you to download monthly_chronicler.html to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) to offer a new (“reveal”) piece of details/summary hosted “Yearly Report Calendar” functionality.

<?php

// quarter_hour_timer.php
// RJM Programming
// December, 2021

// iptc_make_tag() function by Thies C. Arntzen
function iptc_make_tag($rec, $data, $value) {
$length = strlen($value);
$retval = chr(0x1C) . chr($rec) . chr($data);

if($length < 0x8000)
{
$retval .= chr($length >> 8) . chr($length & 0xFF);
}
else
{
$retval .= chr(0x80) .
chr(0x04) .
chr(($length >> 24) & 0xFF) .
chr(($length >> 16) & 0xFF) .
chr(($length >> 8) & 0xFF) .
chr($length & 0xFF);
}

return $retval . $value;
}

if (isset($_GET['myta'])) {
$dru="HTTP://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . "/";
$contis=str_replace('+',' ',urldecode($_GET['myta']));
//file_put_contents('xx.xx', $contis);
$myf='';
$backi='';
$cali='';
$taback='';
$bcontis="'" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "' + String.fromCharCode(10) + '", str_replace("\r\n", "' + String.fromCharCode(10) + '", str_replace("'", "' + String.fromCharCode(39) + '", $contis)))) . "'";
if (substr(($bcontis . ' '),0,3) == "' + ") { $bcontis=$bcontis.substr(3); }
if (substr((' ' . $bcontis),-3,3) == " + '") { $bcontis=$bcontis.substr(0,(-3 + strlen($bcontis))); }
foreach ($_GET as $name=>$val) {
if ($name != 'myta' && $val == '') {
//echo $name;
$myf=$name;
$taback=str_replace('-','_',str_replace('itd','tatd',$myf));
$backi=str_replace('-','_',str_replace('screen-','itd_',$myf));
$cali=str_replace('-','',str_replace('screen-','td',$myf));
$idcali=explode('-',explode('_',str_replace('screen-','td',str_replace('itd_','td',$myf)))[0])[0];


// Thanks to https://doc.bccnsoft.com/docs/php-docs-7-en/function.iptcembed.html

// Path to jpeg file
$path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . str_replace('_','-',str_replace('itd_','screen-',$myf)) . '.jpg';
//file_put_contents('x.x',$path);

$capt = ""; // Thanks to https://www.php.net/manual/en/function.iptcparse.php
$size = getimagesize( $path, $info );
if (isset($info["APP13"])) {
//file_put_contents('xx.xx',$path);
if ($iptc = iptcparse( $info["APP13"] ) ) {
//file_put_contents('xxx.xxx',$path);
$capt = str_replace( "\000", "", $iptc["2#120"][0] );
//file_put_contents('xxxx.xxxx',$capt);
}
}
$bcontis="" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "' + String.fromCharCode(10) + '", str_replace("\r\n", "' + String.fromCharCode(10) + '", str_replace("'", "' + String.fromCharCode(39) + '", $capt)))) . "";
$ccpre="<p onclick=this.innerHTML+=String.fromCharCode(60)+String.fromCharCode(98)+String.fromCharCode(114)+String.fromCharCode(62); style=background-color:orange;background-size:contain;background-image:linear-gradient(rgba(255,255,255,0.3),rgba(255,255,255,0.3)),URL(" . $dru . str_replace('_','-',str_replace('itd_','screen-',$myf)) . ".jpg" . "); title=" . substr(str_replace('td','p',$cali),-4,2) . ":" . substr(str_replace('td','p',$cali),-2,2) . "++ id=" . str_replace('td','p',$cali) . ">";
$ccpost="</p>";
$ccontis="<br><p style='background-color:orange; title='" . str_replace('td','p',$cali) . "' id=" . str_replace('td','p',$cali) . ">" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "<br>", str_replace("\r\n", "<br>", str_replace("'", "' + String.fromCharCode(39) + '", $capt)))) . "</p>";

//file_put_contents('xxxxx.xxxxx',$bcontis);
//file_put_contents('xxxxxx.xxxxxx',$taback . ' ... ' . $backi);
//file_put_contents('xxxxxxx.xxxxxxx',"parent.document.getElementById('" . $backi . "').title='" . $bcontis . "'; parent.document.getElementById('" . $taback . "').value='" . $bcontis . "'; ");

}
if ($bcontis != "''") { echo "<html><body onload=\" parent.document.getElementById('" . $backi . "').title='" . $bcontis . "'; parent.document.getElementById('" . $taback . "').value='" . $bcontis . "'; if (parent.document.getElementById('" . $idcali . "')) { var huhg='" . $ccpre . "' + parent.document.getElementById('" . $taback . "').value + '" . $ccpost . "'; while (huhg.indexOf(String.fromCharCode(10)) != -1) { huhg=huhg.replace(String.fromCharCode(10),'<br>'); } parent.document.getElementById('" . $idcali . "').innerHTML+=huhg; } \"></body></html>"; }
}
} else if (isset($_POST['myta'])) {
$dru="HTTP://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . "/";
$contis=str_replace('+',' ',urldecode($_POST['myta']));
//file_put_contents('xx.xx', $contis);
$myf='';
$backi='';
$cali='';
$bcontis="'" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "' + String.fromCharCode(10) + '", str_replace("\r\n", "' + String.fromCharCode(10) + '", str_replace("'", "' + String.fromCharCode(39) + '", $contis)))) . "'";


$ccpre="<p onclick=this.innerHTML+=String.fromCharCode(60)+String.fromCharCode(98)+String.fromCharCode(114)+String.fromCharCode(62); style=background-color:orange;background-size:contain;background-image:linear-gradient(rgba(255,255,255,0.3),rgba(255,255,255,0.3)),URL(" . $dru . str_replace('_','-',str_replace('itd_','screen-',$myf)) . ".jpg" . "); title=" . substr(str_replace('td','p',$cali),-4,2) . ":" . substr(str_replace('td','p',$cali),-2,2) . "++ id=" . str_replace('td','p',$cali) . ">";
$ccpost="</p>";
$ccontis="<br><p style='background-color:orange; title='" . str_replace('td','p',$cali) . "' id=" . str_replace('td','p',$cali) . ">" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "<br>", str_replace("\r\n", "<br>", str_replace("'", "' + String.fromCharCode(39) + '", $capt)))) . "</p>";


if (substr(($bcontis . ' '),0,3) == "' + ") { $bcontis=$bcontis.substr(3); }
if (substr((' ' . $bcontis),-3,3) == " + '") { $bcontis=$bcontis.substr(0,(-3 + strlen($bcontis))); }
foreach ($_POST as $name=>$val) {
if ($name != 'myta') {
$myf=$name;
$backi=str_replace('-','_',str_replace('screen-','itd_',$myf));
$taback=str_replace('tatd','tatd_',substr(str_replace('-','',str_replace('_','',str_replace('itd','tatd',str_replace('screen','tatd',$myf)))),0,12)) . '_' . substr(str_replace('-','',str_replace('_','',str_replace('itd','tatd',str_replace('screen','tatd',$myf)))),-4,4);
$pback=str_replace('tatd','ip',$taback);
$cali=str_replace('-','',str_replace('screen-','td',$myf));
$idcali=explode('-',explode('_',str_replace('screen-','td',str_replace('itd_','td',$myf)))[0])[0];


// Thanks to https://doc.bccnsoft.com/docs/php-docs-7-en/function.iptcembed.html

// Path to jpeg file
$path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $myf . '.jpg';

//file_put_contents('x.x', $path);

// Set the IPTC tags
$iptc = array(
'2#120' => $contis,
'2#116' => 'Copyright 2021, RJM Programming'
);

// Convert the IPTC tags into binary code
$data = '';

foreach($iptc as $tag => $string) {
$tag = substr($tag, 2);
$data .= iptc_make_tag(2, $tag, $string);
}

// Embed the IPTC data
$content = iptcembed($data, $path);

// Write the new image data out to the file.
$fp = fopen($path, "wb");
fwrite($fp, $content);
fclose($fp);

}
echo "<html><body onload=\" parent.document.getElementById('" . $backi . "').title=" . $bcontis . "; if (parent.document.getElementById('" . $idcali . "')) { var huhg='" . $ccpre . "' + parent.document.getElementById('" . $taback . "').value + '" . $ccpost . "'; if (parent.document.getElementById('" . $pback . "')) { huhg=parent.document.getElementById('" . $taback . "').value; } while (huhg.indexOf(String.fromCharCode(10)) != -1) { huhg=huhg.replace(String.fromCharCode(10),'<br>'); } if (parent.document.getElementById('" . $pback . "')) { parent.document.getElementById('" . $pback . "').innerHTML=huhg; } else { parent.document.getElementById('" . $idcali . "').innerHTML+=huhg; } } \"></body></html>";
}
} else {
exec("/usr/sbin/screencapture -Cd -tjpg /Applications/MAMP/htdocs/screen-`date +\"%Y%m%d-%H%M\"`.jpg");
}
exit;

?>

And so, again, our changed quarter_hour_timer.html (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) Timekeeping Web Application suited to macOS (or Mac OS X) “screencapture” command line usage, is helped out by a calendar integrationally changed quarter_hour_timer.php PHP (we ask you to download to MAMP‘s $_SERVER[‘DOCUMENT_ROOT’] “HTMLCSS” subfolder) for you to try out on your MAMP macOS environment.


Previous relevant Mac OS MAMP Timekeeping Web Application PHP Image Metadata Tutorial is shown below.

Mac OS MAMP Timekeeping Web Application PHP Image Metadata Tutorial

Mac OS MAMP Timekeeping Web Application PHP Image Metadata Tutorial

In our opinion, what would make the day before yesterday’s Mac OS MAMP Timekeeping Web Application PHP Intranet Tutorial “Timekeeping Web Application” cooler would be to add to the intelligence of the screen capture images, ahead of other data related improvements to come.

We’ve spoken in the past about Exif in that respect but PHP has Iptc image metadata functions we can call on …

  • iptcembed to embed new metadata into an existant image from those associated “caption” textarea elements we offer
  • iptcparse to extract old metadata from an existant image into those associated “caption” textarea elements we offer

This metadata can be like a database source we use moving forward on this project, meaning the one image data entity can suffice for both visual and textual usage purposes.

And so our changed quarter_hour_timer.html Timekeeping Web Application suited to macOS (or Mac OS X) “screencapture” command line usage, is helped out by a much more usefully changed quarter_hour_timer.php PHP …

<?php

// quarter_hour_timer.php
// RJM Programming
// December, 2021

// iptc_make_tag() function by Thies C. Arntzen
function iptc_make_tag($rec, $data, $value) {
$length = strlen($value);
$retval = chr(0x1C) . chr($rec) . chr($data);

if($length < 0x8000)
{
$retval .= chr($length >> 8) . chr($length & 0xFF);
}
else
{
$retval .= chr(0x80) .
chr(0x04) .
chr(($length >> 24) & 0xFF) .
chr(($length >> 16) & 0xFF) .
chr(($length >> 8) & 0xFF) .
chr($length & 0xFF);
}

return $retval . $value;
}

if (isset($_GET['myta'])) {
$contis=str_replace('+',' ',urldecode($_GET['myta']));
//file_put_contents('xx.xx', $contis);
$myf='';
$backi='';
$taback='';
$bcontis="'" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "' + String.fromCharCode(10) + '", str_replace("\r\n", "' + String.fromCharCode(10) + '", str_replace("'", "' + String.fromCharCode(39) + '", $contis)))) . "'";
if (substr(($bcontis . ' '),0,3) == "' + ") { $bcontis=$bcontis.substr(3); }
if (substr((' ' . $bcontis),-3,3) == " + '") { $bcontis=$bcontis.substr(0,(-3 + strlen($bcontis))); }
foreach ($_GET as $name=>$val) {
if ($name != 'myta' && $val == '') {
//echo $name;
$myf=$name;
$taback=str_replace('-','_',str_replace('itd','tatd',$myf));
$backi=str_replace('-','_',str_replace('screen-','itd_',$myf));

// Thanks to https://doc.bccnsoft.com/docs/php-docs-7-en/function.iptcembed.html

// Path to jpeg file
$path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . str_replace('_','-',str_replace('itd_','screen-',$myf)) . '.jpg';
//file_put_contents('x.x',$path);

$capt = ""; // Thanks to https://www.php.net/manual/en/function.iptcparse.php
$size = getimagesize( $path, $info );
if (isset($info["APP13"])) {
//file_put_contents('xx.xx',$path);
if ($iptc = iptcparse( $info["APP13"] ) ) {
//file_put_contents('xxx.xxx',$path);
$capt = str_replace( "\000", "", $iptc["2#120"][0] );
//file_put_contents('xxxx.xxxx',$capt);
}
}
$bcontis="" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "' + String.fromCharCode(10) + '", str_replace("\r\n", "' + String.fromCharCode(10) + '", str_replace("'", "' + String.fromCharCode(39) + '", $capt)))) . "";
//file_put_contents('xxxxx.xxxxx',$bcontis);
//file_put_contents('xxxxxx.xxxxxx',$taback . ' ... ' . $backi);
//file_put_contents('xxxxxxx.xxxxxxx',"parent.document.getElementById('" . $backi . "').title='" . $bcontis . "'; parent.document.getElementById('" . $taback . "').value='" . $bcontis . "'; ");

}
if ($bcontis != "''") { echo "<html><body onload=\" parent.document.getElementById('" . $backi . "').title='" . $bcontis . "'; parent.document.getElementById('" . $taback . "').value='" . $bcontis . "'; \"><p>parent.document.getElementById('" . $backi . "').title='" . $bcontis . "'; parent.document.getElementById('" . $taback . "').value='" . $bcontis . "';</p></body></html>"; }
}
} else if (isset($_POST['myta'])) {
$contis=str_replace('+',' ',urldecode($_POST['myta']));
//file_put_contents('xx.xx', $contis);
$myf='';
$backi='';
$bcontis="'" . str_replace(chr(34), "' + String.fromCharCode(34) + '", str_replace("\n", "' + String.fromCharCode(10) + '", str_replace("\r\n", "' + String.fromCharCode(10) + '", str_replace("'", "' + String.fromCharCode(39) + '", $contis)))) . "'";
if (substr(($bcontis . ' '),0,3) == "' + ") { $bcontis=$bcontis.substr(3); }
if (substr((' ' . $bcontis),-3,3) == " + '") { $bcontis=$bcontis.substr(0,(-3 + strlen($bcontis))); }
foreach ($_POST as $name=>$val) {
if ($name != 'myta') {
$myf=$name;
$backi=str_replace('-','_',str_replace('screen-','itd_',$myf));

// Thanks to https://doc.bccnsoft.com/docs/php-docs-7-en/function.iptcembed.html

// Path to jpeg file
$path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $myf . '.jpg';

//file_put_contents('x.x', $path);

// Set the IPTC tags
$iptc = array(
'2#120' => $contis,
'2#116' => 'Copyright 2021, RJM Programming'
);

// Convert the IPTC tags into binary code
$data = '';

foreach($iptc as $tag => $string) {
$tag = substr($tag, 2);
$data .= iptc_make_tag(2, $tag, $string);
}

// Embed the IPTC data
$content = iptcembed($data, $path);

// Write the new image data out to the file.
$fp = fopen($path, "wb");
fwrite($fp, $content);
fclose($fp);

}
echo "<html><body onload=\" parent.document.getElementById('" . $backi . "').title=" . $bcontis . "; \"></body></html>";
}
} else {
exec("/usr/sbin/screencapture -Cd -tjpg /Applications/MAMP/htdocs/screen-`date +\"%Y%m%d-%H%M\"`.jpg");
}
exit;

?>


Previous relevant Mac OS X MAMP Timekeeping Web Application Email Tutorial is shown below.

Mac OS X MAMP Timekeeping Web Application Email Tutorial

Mac OS X MAMP Timekeeping Web Application Email Tutorial

The practicalities of yesterday’s (Mac OS X MAMP Timekeeping Web Application Primer Tutorial) timekeeping Mac OS X Web Application, left as they are, would leave you with a somewhat useful web application whose use is only for the here and now, but what if you want it to be more accountable? Well, that is when we, here, at RJM Programming, like to use that tried and trusted email form of communication.

Today’s email methods spurn the use of server-side intervention, at least for now. So what is available to us as tools, if we don’t include Ajax nor jQuery in that list? Well, we have, to our minds …

  • mailto links (get us to the email client) +
  • the body section of that email can have a clipboard image pasted into it, for which we can utilize HTML5 canvas element’s toDataURL() method, teamed up with a window.open popup window of the toDataURL image data, which can be selected and copied, optionally, by the user themselves, should they wish this to make their email more self explanatory

We last discussed this thinking with Canvas Annotation Email Attachment Clipboard Tutorial.

We rely on the crontab functionality, being as there is no server-side help, to create the image file, whose contents eventually go to make up the contents that can be selected and copied and pasted by the user into the body section of the email (and sent off to whosoever they feel like sending it too, as you have the full power of the email client available to you with the interaction you have with an actual email client program).

Here is the HTML and Javascript quarter_hour_timer.html which changed to cater for today’s email functionality in this way, and, as per the Stop Press from yesterday, we’ll also have a live run link here today.


Previous relevant Mac OS X MAMP Timekeeping Web Application Primer Tutorial is shown below.

Mac OS X MAMP Timekeeping Web Application Primer Tutorial

Mac OS X MAMP Timekeeping Web Application Primer Tutorial

Sometimes when you program, especially for administrative type functionality, there are useful programs to write, that are able to become web applications, but in a limited set of platforms. So it is today with our timekeeping web application that relies on …

  • Mac OS X operating system +
  • Existance of [/usr/sbin/]screencapture +
  • crontab active and editable via crontab -e +
  • One of …
    1. MAMP installed to, in our case, /Applications/MAMP/htdocs/ (as is mentioned in the relevant crontab background task that snapshots the user’s screen every quarter hour) that maps to the MAMP web application URL http://localhost:8888/ … or …
    2. crontab directory mention that corresponds to a URL call of our web application like for our Google Chrome example (where the directory below, used, could be a place of your choosing (that matches what is in your crontab task entry)) …

      file:///Applications/MAMP/htdocs/quarter_hour_timer.html?localplace=

      … or just, via the web browser’s File -> Open File menu …

      file:///Applications/MAMP/htdocs/quarter_hour_timer.html

… pretty restrictive, huh? … but pretty useful for our quarter hour timekeeping purposes today.

We want to have a web application that is running at the user’s discretion, and when first fired up, looks for outputs from crontab tasks above …


0,15,30,45 * * * * /usr/sbin/screencapture -Cd -tjpg /Applications/MAMP/htdocs/screen-`date +"\%Y\%m\%d-\%H\%M"`.jpg

… for the current day in question and if existant show …

  1. a date and time stamp +
  2. the snapshot of what you were doing at the quarter hour, that is clickable to make bigger for more in depth viewing +
  3. an HTML textarea element in which you can optionally type in more specifics about that quarter hour

So, as much as we like to think of Mac OS X Terminal application’s BSD (a unix derivative) operating system, as being a lot like Linux, there are some commands and usage that …

  • adds Mac OS X specific command line functionality to a Linux or unix base set of functionality, like for today’s screencapture command … and we’ve included another such example, below, with the command say featuring in Mac OS X Text to English Speech Primer Tutorial as shown below
  • changes switches on Linux or unix commands
  • won’t have some Linux or unix commands that other platforms do

In the great tradition of behoving … we behove … we behove thee quarter_hour_timer.html if you like, my liege. On this occasion you’ll have gleaned that there is no live run link, because the RJM Programming web server is not Mac OS X … so command line screencapture has no meaning for a CentOS web server’s operating system command line. You’ll see in the code that rather than use “Client Pre-emptive Iframe” concepts to check for existence of crontab screen capture images, we, instead use the onerror event for HTML img elements to check for non-existance.

Stop Press

Just noticed that, perhaps, after all, a live run from the RJM Programming website can make sense if you have a Mac OS X laptop, for instance, that is running that suggested crontab entry as explained in tutorial above. That type of live run managed to latch on to our local crontab screencaptures on my MacBook Pro.


Previous relevant Mac OS X Text to English Speech Primer Tutorial is shown below.

Mac OS X Text to English Speech Primer Tutorial

Mac OS X Text to English Speech Primer Tutorial

We’ve got a few new ideas today …

  1. Text to English Speech via Mac OS X’s command line say command used by PHP via exec to make say.php (which is useful as a download to a Mac OS X laptop using MAMP) which, today, does not have a live run because the web server of domain rjmprogramming.com.au is a CentOS Linux server … Linux equivalent of Mac OS X’s say? … read here
  2. Trying to present this brought up the usual movie production problem with iMovie overlaying the audio on top of the video (though you may want to try, and you could start reading with this link) versus QuickTime Player talent to catch both audio and video tracks (and that we ended up using), but not of the “screen goings on”, alas versus MPlayer OSX Extended which can play separately but not two tracks on top and doesn’t do any reconstituting … so …
  3. Improved on our inhouse Video/Audio synchronizing efforts by allowing audio_video.html supervisor (changed in this way) be able to be called to press one of its preconceived synchronization buttons onload which we do with (the newly added) Macbeth Act 1 Scene 1 … in a small celebration of the Bard … who, am thinking (in that Falstaff way), would have got a huge chuckle out of “anonymous” instead of “anon” during the Three Witches scene … we had to do something to say Happy Birthday

Along the way we tried filming the MacBook Pro with the iPad to a YouTube

… but weren’t happy with the audio quality, alas (too/two).

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Document Root Relative Folder Listing Links Video Tutorial

Document Root Relative Folder Listing Links Video Tutorial

Document Root Relative Folder Listing Links Video Tutorial

Onto yesterday’s Document Root Relative Folder Listing Links Animated GIF Tutorial‘s “assembly” list of …

  • Javascript (setTimeout) image animation
  • PDF
  • PowerPoint
  • Word
  • Animated GIF … today, we present …
  • Video

… “assembly” functionality, turning to the great ffmpeg product’s command line …


ffmpeg -f concat -safe 0 -i list.txt -r 25 -pix_fmt yuv420p output.mp4

… used within the procedure involving our Document Root Relative Folder Listing web application …

  • we open within a popup window in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Video *.mp4 data via (exec called) …

    ffmpeg -f concat -safe 0 -i list.txt -r 25 -pix_fmt yuv420p output.mp4

    … and from there …
  • the PHP uses the header arrangements
    <?php

    if (isset($_GET['avideolist']) && isset($_GET['avideoname'])) {
    $dname="input.mp4";
    $_GET['avideolist']=oururlencode($_GET['avideolist']);
    $themd=str_replace(",","'\nduration 10\nfile '" . $_SERVER['DOCUMENT_ROOT'], "file '" . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['avideolist']))) . "'";
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".mp4",".vvv",str_replace('+',' ',urldecode($_GET['avideoname'])))), $themd);
    exec($fconvprefix . 'ffmpeg -f concat -safe 0 -i ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".mp4",".vvv",str_replace('+',' ',urldecode($_GET['avideoname'])))) . ' -r 25 -pix_fmt yuv420p ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))));
    $hsofar="<html><body><video controls><source src=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['avideoname']))) . "\" type=\"video/mp4\" data-base=data:video/mp4;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))))) . "></source></video></body></html>";
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".mp4",".vvv",str_replace('+',' ',urldecode($_GET['avideoname'])))));
    if (4 == 4) {
    header('Content-Type: video/mp4');
    header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
    header('Pragma: public');
    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))))));
    header("Content-Disposition: inline; filename=" . $dname);

    echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))));
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))));
    exit;
    } else {
    echo $hsofar;
    $thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname'])));
    register_shutdown_function('shutdown');
    //sleep(45);
    //unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['avideoname']))));
    shutdown() and exit;
    }
    }

    ?>
    …implied by the code above … and here it …
  • is able to display the Video (as a video/mp4 mimetype data) arrangement

… means by which we can offer a Video “assembly” now in the “eleventh draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, filibusters and crime busters and ghost busters, attendees and abstainers, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Animated GIF Tutorial is shown below.

Document Root Relative Folder Listing Links Animated GIF Tutorial

Document Root Relative Folder Listing Links Animated GIF Tutorial

We continue on from yesterday’s PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial “useful sidestep”, to add to the current crop of “assemblies” …

  • Javascript (setTimeout) image animation
  • PDF
  • PowerPoint
  • Word … whereas, today, we are offering …
  • Animated GIF

… “assembly” functionality, turning back to ImageMagick‘s brilliant “convert” command line command idea …

convert -delay 1000 -loop 0 [space limited list of image filenames] output.gif

… used within the procedure involving our Document Root Relative Folder Listing web application …

  • we open within a popup window in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Animated GIF *.gif data via (exec called) …

    convert -delay 1000 -loop 0 [space delimited list of image filenames] output.gif

    … and from there …
  • the PHP uses the header arrangements
    <?php

    if (isset($_GET['agiflist']) && isset($_GET['agifname'])) {
    $dname="input.gif";
    $_GET['agiflist']=oururlencode($_GET['agiflist']);
    $dname=explode('.', basename(explode(',', str_replace('+',' ',urldecode($_GET['agiflist'])))[0]))[0] . '_et-al_' . sizeof(explode(',',str_replace('+',' ',urldecode($_GET['agiflist'])))) . '.gif';
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname'])))), str_replace(","," " . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['agiflist']))));
    exec($convprefix . 'convert -delay 1000 -loop 0 ' . file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname']))))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    $hsofar="<html><body><img src=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['agifname']))) . "\" data-base=data:image/gif;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))))) . "></img></body></html>";
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname'])))));
    if (4 == 4) {
    header('Content-Type: image/gif');
    header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
    header('Pragma: public');
    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))))));
    header("Content-Disposition: inline; filename=" . $dname);

    echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    exit;
    } else {
    echo $hsofar;
    $thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname'])));
    register_shutdown_function('shutdown');
    //sleep(45);
    //unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    shutdown() and exit;
    }
    }

    ?>
    …implied by the code above … and here it …
  • is able to display the Animated GIF (as an image/gif mimetype data) arrangement

… means by which we can offer an Animated GIF “assembly” now in the “tenth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, filibusters and crime busters, townfolk and countryfolk alike, like.


Previous relevant PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial is shown below.

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

Yesterday’s Document Root Relative Folder Listing Links Caption Tutorial work had within it’s changes features to do with …

after process unneeded web server file cleanup

… issues where in the past we may have resorted to a …

  • crontab (and maybe curl) means to a solution … but we prefer, where possible …
  • there and then procedures within the PHP (ie. it has to be PHP to help) … as much as anything, because that way, all the parts to any solution, are self contained

… and for security purposes that PHP solution is best done using a form method=POST methodology, or, as we are sprouting here today (and we like a lot, and think it could help us out later with other such scenarios) … and our apologies for the tautology

PHP Javascript Ajax Asynchronous Sleep Cleanup

… thinking we start explaining at the changed Javascript Ajax (to the original block of code) as per …

<?php echo ”

var gincv='', ganidn='';

function ajaxpdfit(incv) {
if (4 == 4) {
var anidn='' + incv.replace(/\\\\/g,'/').split(',')[0].split('/')[eval(-1 + incv.replace(/\\\\/g,'/').split(',')[0].split('/').length)].split('.')[0] + '_et-al_' + incv.split(',').length; // + '.pdf';
if (pdfwoo) {
if (!pdfwoo.closed) { pdfwoo.close(); pdfwoo=null; } else { pdfwoo.close(); pdfwoo=null; }
}
if (pptxwoo) {
if (!pptxwoo.closed) { pptxwoo.close(); pptxwoo=null; } else { pptxwoo.close(); pptxwoo=null; }
}
if (mswoo) {
if (!mswoo.closed) { mswoo.close(); mswoo=null; } else { mswoo.close(); mswoo=null; }
}
//incv=incv.replace(/\~\~/g, String.fromCharCode(92) + String.fromCharCode(10)); // new idea
if (('' + document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent(anidn + '.pdf')).length > 800) {
pdfzhr = new XMLHttpRequest();
pdfzform = new FormData();
pdfzform.append('anidnlist', incv);
pdfzform.append('anidn', anidn + '.abc');
//pdfzhr.onreadystatechange=noNeedToHangAround;
pdfzhr.open('post', './one_line_find.php', true);
pdfzhr.send(pdfzform);

ganidn=anidn;
gincv=noh(incv); // strips out any hashtagged caption data
setTimeout(function(){
pdfwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(gincv) + '&apdfname=' + encodeURIComponent(ganidn + '.pdf'),'_blank','top=20,left=' + eval(-700 + screen.width) + ',width=700,height=700');
pdfwoo.document.title='PDF (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
pptxwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?applist=' + encodeURIComponent(gincv) + '&appname=' + encodeURIComponent(ganidn + '.pptx'),'_blank','top=' + eval(-400 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
pptxwoo.document.title='PowerPoint (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
mswoo=window.open(document.URL.split('?')[0].split('#')[0] + '?amslist=' + encodeURIComponent(gincv) + '&amsname=' + encodeURIComponent(ganidn + '.docx'),'_blank','top=' + eval(-200 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
mswoo.document.title='Word (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
}, 5000);
} else {

pdfwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent(anidn + '.pdf'),'_blank','top=20,left=' + eval(-700 + screen.width) + ',width=700,height=700');
pdfwoo.document.title='PDF (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
pptxwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?applist=' + encodeURIComponent(incv) + '&appname=' + encodeURIComponent(anidn + '.pptx'),'_blank','top=' + eval(-400 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
pptxwoo.document.title='PowerPoint (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
mswoo=window.open(document.URL.split('?')[0].split('#')[0] + '?amslist=' + encodeURIComponent(incv) + '&amsname=' + encodeURIComponent(anidn + '.docx'),'_blank','top=' + eval(-200 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
mswoo.document.title='Word (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';

}
} else if (4 == 46) {
document.getElementById('apdflist').value=incv;
document.getElementById('apdfname').value='pdf' + Math.floor(Math.random() * 19897654) + '.pdf';
document.getElementById('thepdf').style.display='block';
document.getElementById('pdfsub').click();
} else if (4 == 47) {
document.getElementById('thepdf').style.display='block';
document.getElementById('thepdf').src=document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent('pdf' + Math.floor(Math.random() * 19897654) + '.pdf');
} else {
pdfzhr = new XMLHttpRequest();
pdfzform = new FormData();
pdfzform.append('apdflist', incv);
pdfzform.append('apdfname', 'pdf' + Math.floor(Math.random() * 19897654) + '.pdf');
pdfzhr.onreadystatechange=statePdfChanged;
pdfzhr.open('post', './one_line_find.php', true);
pdfzhr.send(pdfzform);
}
}

“; ?>

… begging the question, at least for us, being …

What’s the go with …
//pdfzhr.onreadystatechange=noNeedToHangAround;
?

Well, the “A” of Ajax stands for “Asynchronous”, as a useful aspect to Javascript where logic does not have to flow from start to finish linearly, and jobs can multitask. That onreadystatechange idea analyzes what the recipient PHP replies, but in the case of a file cleanup …

  1. it is optional (but preferable) if it happens at all, in the way we roll around here …
  2. and that means as far as file cleanup goes, immediately the interim ascii flat file (used to flesh out the following $_GET[] array work …
    <?php

    $commentaries=[];

    function oururlencode($instis) {
    global $commentaries;
    $interim=urldecode($instis);
    $origim=str_replace('+',' ',$interim);
    $intcs=explode(',', $interim);
    $found=false;
    for ($j=0; $j<sizeof($intcs); $j++) {
    if ($j == 0) {
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(explode('#',$intcs[$j])[0]) . '_et-al_' . sizeof($intcs) . '.abc')) {
    $instis=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(explode('#',$intcs[$j])[0]) . '_et-al_' . sizeof($intcs) . '.abc');
    $interim=urldecode($instis);
    $origim=str_replace('+',' ',$interim);
    $intcs=explode(',', $interim);
    }

    }
    array_push($commentaries, '');
    }
    for ($j=0; $j<sizeof($intcs); $j++) {
    $found=false;
    if (strpos($intcs[$j], '#') !== false) {
    $oneword=explode(' ',trim(explode('#', $intcs[$j])[1]))[0];
    if ($oneword != '' && strpos($oneword, '.') !== false && substr($oneword . ' ',0,1) == '/') {
    if (strpos($origim, $oneword) != '') {
    $found=true;
    }
    }
    if ($found) {
    $commentaries[$j].=' ' . str_replace("~~",chr(92) . chr(10),substr(trim(explode('#', $intcs[$j])[1]),strlen($oneword))); // fix perhaps
    }
    }
    }
    for ($j=0; $j<sizeof($intcs); $j++) {
    $jj=0;
    while ($commentaries[$jj] != '') {
    $jj++;
    }
    $found=false;
    if (strpos($intcs[$j], '#') !== false) {
    $oneword=explode(' ',trim(explode('#', $intcs[$j])[1]))[0];
    if ($oneword != '' && strpos($oneword, '.') !== false && substr($oneword . ' ',0,1) == '/') {
    if (strpos($origim, $oneword) != '') {
    $found=true;
    }
    }
    if (!$found) {
    $commentaries[$jj].=' ' . str_replace("~~",chr(92) . chr(10),explode('#', $intcs[$j])[1]); // fix perhaps
    }
    $interim=str_replace($intcs[$j],explode('#', $intcs[$j])[0],$interim);
    }
    }
    return urlencode($interim);
    }

    ?>
    …with hashtagged caption data that made the job too long for $_GET[] based navigation from the start) can be created by our recipient PHP Ajax “called upon” … then …
  3. the PHP can sleep
    <?php

    if (isset($_POST['anidnlist']) && isset($_POST['anidn'])) {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['anidn'])), str_replace('+',' ',urldecode($_POST['anidnlist'])));
    sleep(60);
    if (strpos(('' . str_replace('+',' ',urldecode($_POST['anidn'])) . '~'), '.abc~') !== false) {
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['anidn'])));
    }

    exit;
    }

    ?>
  4. leaving the $_GET[] pass (we wait back at the client Javascript 5 seconds for via setTimeout logics, while the PHP sleeps much longer) time to avail themselves back up at the server with the use of that interim ascii flat file (while the asynchronous, and not waited upon, Ajax called PHP sleeps … presumably among the lions) … while …
  5. back at the Ajax called PHP, having slept, and the interim file has lost it’s value, it can be deletedsorrrrrryyyyyyy “interim file”

… as one example of how this “PHP Javascript Ajax Asynchronous Sleep Cleanup” idea set could be implemented.


Previous relevant Document Root Relative Folder Listing Links Caption Tutorial is shown below.

Document Root Relative Folder Listing Links Caption Tutorial

Document Root Relative Folder Listing Links Caption Tutorial

After yesterday’s Document Root Relative Folder Listing Links Word Tutorial we had both …

  • PowerPoint
  • Word

… output document formats, created via pandoc, with the ability, in pandoc, to tailor slide “captions”, which, until today, had been hardwired to be the image slide filename.

We’ve decided to hashtag such user caption tailoring in hashtag data after the filenames passed over to the recipient PHP (which is the same as the originating PHP in “here’s looking at you” mode of thinking).

So where can the user enter these? The first option …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow or PDF or PowerPoint or Word via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; data-onblur=process(this); data-multiple><option id=firsttext onclick=addcommentary(); value=\"\">:</option></select>')

“; ?>

… of that relatively new dropdown for this is where we have decided to intervene …

<?php echo ”

var commentaries=[];

function addcommentary() {
needten=1;
var commadd=prompt('Optionally add to commentary. For new lines use ~~ characters. For multiple entries separate by , (ie. two blanks comma two blanks).', '');
if (commadd != null) {
var coms=commadd.split(' , ');
for (var ic=0; ic<coms.length; ic++) {
if (coms[ic].trim() != '') {
commentaries.push('#' + encodeURIComponent(coms[ic]));
}
}
}
}


“; ?>

And so, the “ninth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Word Tutorial is shown below.

Document Root Relative Folder Listing Links Word Tutorial

Document Root Relative Folder Listing Links Word Tutorial

The word is, in workplaces all around Earth now, workers are unwrapping their Mars Bars and shaping to use …


Word

huh?! Isn’t that a coincidence?! Who would have thunk it. They are constructing documents. So that being the case, do you think …

The barsoomian is, in workplaces all around Mars now, martians are unwrapping their Earth Bars and shaping to use …


Word


… to write haikus

? But if not, why not?!

As such, the creation of a “Word assembly” is our “fourth cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we PowerPointized yesterday with Document Root Relative Folder Listing Links PowerPoint Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$pconvprefix='/bin/';
if (file_exists('/usr/local/bin/pandoc')) {
$pconvprefix='/usr/local/bin/';
} else if (!file_exists('/bin/pandoc')) {
$pconvprefix='';
}

if (isset($_GET['amslist']) && isset($_GET['amsname'])) {
$dname="input.docx";
$themd=str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['amslist'])));
$thelines=explode("\n", $themd);
$themd="";
for ($i=0; $i<sizeof($thelines); $i++) {
if ($i == 0) {
$dname=explode('.', basename($thelines[$i]))[0] . '_et-al_' . sizeof($thelines) . '.docx';
}
if ($i == (-1 + sizeof($thelines))) {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")";
} else {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")\n\n---\n\n";
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))), $themd);
exec($pconvprefix . 'pandoc ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))) . ' -o ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['amsname']))) . "\" type=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\" data-base=data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))));
if (4 == 4) {
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))));
header("Content-Disposition: inline; filename=" . $dname);
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
shutdown() and exit;
}
}

?>

… engendering that same frisson of excitement we got yesterday, with Document Root Relative Folder Listing Links PowerPoint Tutorial … as (for us here on macOS) …

  • we open a popup in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Word *.docx data via (exec called) …

    pandoc presentation.md -o output.docx

    … and from there …
  • the PHP uses the header arrangements implied by the code above … but where it …
  • is unable to display, but still shows a download link …
  • we click …
  • showing a new Downloads folder file …
  • we get to in Finder …
  • we hover over that *.docx and see an Open With …
  • LibreOffice choice we select …
  • displaying the Word document containing the images selected

Cute, huh?!?!

The “eighth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links PDF Tutorial is shown below.

Document Root Relative Folder Listing Links PDF Tutorial

Document Root Relative Folder Listing Links PDF Tutorial

Hopefully, all around the world, the idea of a …


PDF

… display is replacing the “paper hungry” “hardcopy printout” concept. As such, the creation of a “PDF assembly” is our “second cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we started yesterday with Document Root Relative Folder Listing Links Assemblies Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$thingtoattendto='';

function shutdown() {
global $thingtoattendto;
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.

if ($thingtoattendto != '') {
sleep(145);
unlink($thingtoattendto);
}
}

$convprefix='/bin/';
if (file_exists('/usr/local/bin/convert')) {
$convprefix='/usr/local/bin/';
} else if (!file_exists('/bin/convert')) {
$convprefix='';
}

if (isset($_GET['apdflist']) && isset($_GET['apdfname'])) {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))), str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['apdflist']))));
exec($convprefix . 'convert @' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['apdfname']))) . "\" type=\"application/pdf\" data-base=data:application/pdf;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))));
if (4 == 4) {
header('Content-Type: application/pdf');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))));
header("Content-Disposition: inline; filename=input.pdf");
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
shutdown() and exit;
}
}

?>

… using ImageMagick‘s brilliant “convert” command line command idea …

convert @list.txt output.pdf

as the backbone as to how in the “sixth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Assemblies Tutorial is shown below.

Document Root Relative Folder Listing Links Assemblies Tutorial

Document Root Relative Folder Listing Links Assemblies Tutorial

So far, with the Document Root Relative Folder Listing work of recent times, up until the day before yesterday’s Document Root Relative Folder Listing Links Ajax Tutorial, it’s been mainly …

  • reporting … and …
  • display … but we want to move on to the user being able to create their own what we are referring to as …
  • assemblies

To us, these are user driven (is it widgets) they create by selecting multiple media (today images, but down the line, other combinations) from the left hand table cell’s listing links. We do not ask anymore of that left hand cell’s workings, as it will get too complex, but we have a penchant for adding intelligence to hardcodings, and the hardcoding …

https://www.rjmprogramming.com.au/

… is ripe for the picking, with that “just moseying along there innocently” …

:

… a candidate for a new multiple mode select (ie dropdown) element …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')

“; ?>

… means by which a user can specify “assembly components”.

Our simplest first “cab off the rank” here is a Javascript animated sequence, so far 4 second duration slides in a slideshow popup window, as per …

<?php echo ”

var lastretval='', origprefix='', wesayso=false, needten=0, sofarval='', woo=null;

function agifit(incsv) {
if (incsv != '') {
var myimgs=incsv.split(',');
if (woo) {
if (!woo.closed) { woo=woo; } else { woo.close(); woo=null; }
}
if (!woo) {
woo=window.open('','_blank','top=50,left=50,width=800,height=800');
woo.document.write('<ht' + 'ml><he' + 'ad>' + myimgs[0] + '<ti' + 'tle></ti' + 'tle><scr' + 'ipt type=text/javascript> var jimg=0, imgs=(\"' + incsv + '\").split(String.fromCharCode(44)), kimg=eval(\"\" + imgs.length); function startit() { jimg++; jimg=eval(jimg % kimg); document.body.style.background=' + \"'url(' + imgs[jimg] + ')'\" + '; document.title=' + \"'' + imgs[jimg] + ''\" + '; document.body.style.backgroundRepeat=\"no-repeat\"; document.body.style.backgroundSize=\"contain\"; } setInterval(startit,4000); </scri' + 'pt></head><body id=xbody style=background:url(' + myimgs[0] + ');background-repeat:no-repeat;background-size:contain;></body></html>');
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
return woo;
}
}
needten=0;
return null;
}

function monitorsel() {
var yesdo=true;
if (needten > 10) { setTimeout(monitorsel, 2000); return ''; }
var osel=document.getElementById('compsel');
var retval='', delim='';
if (sofarval != '') { delim=','; retval=sofarval; }
for (var i=0; i<osel.length; i++) { if (osel.options[i].selected) { if (osel.options[i].value != '') { if ((',' + sofarval + ',').indexOf(',' + osel.options[i].value + ',') == -1) { retval+=delim + osel.options[i].value; delim=','; } } } }
if (document.getElementById('compsel')) {
if (retval != '') {
if (retval != '' && retval.indexOf(',') == -1) {
needten=0;
}
if (lastretval != retval) {
lastretval=retval;
sofarval=retval;
needten=0;
} else if (needten < 10) {
needten++;
} else {
yesdo=false;
needten++;
if (agifit(sofarval)) {
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
}
}
}
if (yesdo) { setTimeout(monitorsel, 2000); }
}
}

function thismultiple(osel) {
if (document.getElementById('lefttd').outerHTML.split('>')[0].indexOf('overflow') == -1 || wesayso) {
wesayso=false;
document.getElementById('lefttd').style.overflowY='visible';
osel.style.height='30px';
osel.setAttribute('multiple', 'true');
setTimeout(monitorsel, 2000);
}
}


function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[], addthese='';
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
if (document.getElementById('prefix') && !document.getElementById('compsel')) {
if (document.getElementById('prefix').innerHTML.replace('p://','s://').indexOf('s://') != -1) {
document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')
}
}
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
//alert('0:' + outwo('/' + uids[2]) + ' ... ' + '/' + uids[2]);
if (outwo('/' + uids[2]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"/' + uids[2] + '\">/' + uids[2] + '</option>';
}

if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
//alert('1:' + outwo((ihis.split('%20-')[0].split(' -')[0])) + ' ... ' + (ihis.split('%20-')[0].split(' -')[0]));
if (outwo(ihis.split('%20-')[0].split(' -')[0]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"' + (ihis.split('%20-')[0].split(' -')[0]) + '\">' + (ihis.split('%20-')[0].split(' -')[0]) + '</option>';
}

if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
if (addthese != '') {
document.getElementById('compsel').innerHTML+=addthese;
origprefix=document.getElementById('prefix').innerHTML; //.replace(' data-multiple', ' multiple data-multiple');
}

setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

“; ?>

… in the “fifth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, like.


Previous relevant Document Root Relative Folder Listing Links Ajax Tutorial is shown below.

Document Root Relative Folder Listing Links Ajax Tutorial

Document Root Relative Folder Listing Links Ajax Tutorial

It was “faux Ajax day” with yesterday’s Document Root Relative Folder Listing Links Before and On Click Tutorial, but today …

It’s Ajax Day … yayyyyy!!!!

Howevvvvvvvver, just to confuse, there is no onmouseover involved, but the Ajax work does, at least for non-mobile users, sort of, affect display data, in that when hovering over a link, they may see within the title attribute of that link, whatevvvvvvvvver …


file "[a link href]"

… can “value add”, via Ajax logic, into the “up until now just an ls (underlying operating system command) based file listing” report.

Ajax is great here, as helping a subprocess that can be …

  • spawned off …
  • working away as a secondary (optional) process

… supplementing the primary workflow, if you will, but probably not too impactive, we’re hoping

<?php echo ”

var ajaxs=[], zhr=null, zform=null;

function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[];
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

function stateChanged() {
if (zhr.readyState == 4) {
if (zhr.status == 200) {
var rawhtml = zhr.response;
var spans=rawhtml.split('</span');
var ps=rawhtml.split('</p');
if (eval('' + ps.length) == 2 && eval('' + spans.length) == 2) {
document.getElementById(spans[0].split('>')[eval(-1 + spans[0].split('>').length)]).title+=ps[0].split('>')[eval(-1 + ps[0].split('>').length)];
}
setTimeout(doajaxs, 1000);
}
}
}

function doajaxs() {
var nexttogo='';
for (var ii=0; ii<ajaxs.length; ii++) {
if (nexttogo == '' && ajaxs[ii] != '') {
nexttogo=ajaxs[ii];
ajaxs[ii]='';
}
}
if (nexttogo != '') {
zhr = new XMLHttpRequest();
zform = new FormData();
zform.append('ajaxid', encodeURIComponent(nexttogo));
zform.append('ajaxurl', nexttogo);
zhr.onreadystatechange=stateChanged;
zhr.open('post', './one_line_find.php', true);
zhr.send(zform);
}
}


“; ?>

… Javascript calling logic using PHP recipient code …

<?php

if (isset($_POST['ajaxurl']) && isset($_POST['ajaxid'])) {
echo "<html><body><span>" . $_POST['ajaxid'] . '</span><p>' . str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('file "' . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_POST['ajaxurl'])) . '"')) . "</p></body></html>";
exit;
}

?>

… in the “fourth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, like.


Previous relevant Document Root Relative Folder Listing Links Before and On Click Tutorial is shown below.

Document Root Relative Folder Listing Links Before and On Click Tutorial

Document Root Relative Folder Listing Links Before and On Click Tutorial

Today’s work has an Ajax feel to it, despite the fact we use no Ajax type Javascript code, onto yesterday’s Document Root Relative Folder Listing Links Tutorial onclick event logics, we guess, because …

  • coding for the non-mobile onmouseover event, with display change logic, has a very Ajaxy feel to it … and …
  • on mobile we code for ontouchmove (feeding into user click actions)

calling via

<?php echo ”

tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a target="_blank" onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');

“; ?>

… calling on …

<?php echo ”

function showit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
if (ioi.outerHTML.indexOf('<span') != -1) {
outwo(ioi.getAttribute('data-href'));
} else {
outwo(ioi.href);
}
}

function hideit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
}

function hideitlater(ioi) {
if (2 == 5) {
setTimeout(function(){
document.getElementById('mymediatr').innerHTML=mytrih;
}, 15000);
}
}

“; ?>

Along the way we decided, in very Ajaxy thinking, on mobile, to be less disruptive with navigations after a click, so as to stay on the original webpage more often, in the “third draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you like.


Previous relevant Document Root Relative Folder Listing Links Tutorial is shown below.

Document Root Relative Folder Listing Links Tutorial

Document Root Relative Folder Listing Links Tutorial

Regular readers will “know the drill” with today’s work, on top of yesterday’s Document Root Relative Folder Listing Tutorial.

The new word in the posting title is …


Links

… and those regular readers would know …

  • yesterday’s Document Root Relative Folder Listing output was placed into a textarea element … clue 1
  • that textarea element we all admire for it’s textual data line feed talents and it’s talents for resizing capabilities … clue 2
  • that textarea element textual data is unembellishable (if that is a word) … clue 3
  • whereas your meek and mild div element, say, could overlay that textarea element, except for the right hand resizer, that is … clue 4
  • and the div element could latch onto that textarea basis of content and enhance filenames into filename links too (but am not sure about the Singing Glasses idea in the “talent quest section” … that seems a bridge too far) … clue 5

… leaving us clueless as to what else to say … chortle, chortle?!

Also helpful would be, to our minds …

  • still restrict the file specification to a “buttoned down” setting (because of security concerns) … but …
  • add complexity to the extension part …
    <?php

    $extbit='*.[tjpmwag][xpnopaid][etgvf34]*';

    ?>
    …to allow relatively innocent media files and PDFs reach the file listing (tweaked a bit too) now …
    <?php

    $resis=str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('ls -lhgo ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $offdr . $extbit));

    ?>

… in the “second draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, again, if you like.


Previous relevant Document Root Relative Folder Listing Tutorial is shown below.

Document Root Relative Folder Listing Tutorial

Document Root Relative Folder Listing Tutorial

The Apache web server has, for it’s PHP environment, if that is it’s server language, the concept of …


Document Root

… so that, for the website of the webpage you are reading from now, a URL such as our RJM Programming’s Landing Page’s URL …


https://www.rjmprogramming.com.au/

… scours that Document Root folder to find the index.php webpage code to display that Landing Page.

You can “abstract”, and we do also with our Difference Reporting, what that Document Root is as a folder path … bit forlorn we know, as we’ve shown what it is, probably, in many tutorial images … but the thing here is that a URL such as …


/index.php

… is understood and gets you to our Landing Page as well, because to the public, Document Root is the limit of where they are allowed to surf … if you like Document Root is the left hand beach flag at Surfers Paradise (or perhaps the right hand beach flag in the Todd River … when it gets water, that is?!).

Okay, that’s one theme of today’s new PHP web application. The other we wrote out to ourself was …

One line ls -clt https://www.rjmprogramming.com.au/*.txt via find $_SERVER[‘DOCUMENT_ROOT’] -type d -name ‘*’

… as a presentation idea whereby just the one table row of data is used to present …

  • https://www.rjmprogramming.com.au/
  • dropdown of list of folders off Document Root (“abstracting” Document Root itself … ie. relative referencing)
  • a file specification (minus the path) of interest … we are, for now, locking in as …

    *.txt

    … as the input data, to the output data that is …
  • output folder listing (as for Linux and macOS)

The concept of “one table row” for a multiple file listing is a mute point, but in our defence …

  • the textarea it is presented in (via rows=1) is user resizable
  • the textarea it is presented in is given a title with line feeds for the whole report so that non-mobile users can see this on hovering over the textarea

This was a PHP project definitely needing the mildly better outcomes of PHP shell_exec (where multiple line outputs are possible) as distinct from exec where only the last output line is returned, but is the usual method we use around here.

Keeping the report to one row also asks for …

  • use of elements that have CSS styling display:inline; as a default (eg. span element) … or …
  • user supplying CSS display:inline; or display:inline-block; as applicable … and …
  • table cell text-align:right; came in handy … as well as …
  • select element “dynamic shrinker” …

    function resizeSelect(sel) { // thanks to https://www.google.com/search?q=make+select+element+width+in+sympathy+with+length+of+its+value&rlz=1C5OZZY_en&oq=make+select+element+width+in+sympathy+with+length+of+its+value&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTI3MzEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8
    // 1. Create a temporary span to measure text width
    var tempSpan = document.createElement('span');
    tempSpan.style.visibility = 'hidden';
    tempSpan.style.position = 'absolute';
    tempSpan.style.whiteSpace = 'pre';
    // 2. Set font styles to match the select box
    tempSpan.style.font = window.getComputedStyle(sel).font;
    // 3. Set content to selected text
    tempSpan.innerText = sel.options[sel.selectedIndex].text;
    document.body.appendChild(tempSpan);

    // 4. Update width (with extra space for the dropdown arrow)
    sel.style.width = (tempSpan.offsetWidth + 30) + 'px';
    document.body.removeChild(tempSpan);
    }

… in the “proof of concept” one_line_find.php first draft Document Root Relative Folder Listing web application you can “crank up” below if you like …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Ajax, Animation, eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Document Root Relative Folder Listing Links Animated GIF Tutorial

Document Root Relative Folder Listing Links Animated GIF Tutorial

Document Root Relative Folder Listing Links Animated GIF Tutorial

We continue on from yesterday’s PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial “useful sidestep”, to add to the current crop of “assemblies” …

  • Javascript (setTimeout) image animation
  • PDF
  • PowerPoint
  • Word … whereas, today, we are offering …
  • Animated GIF

… “assembly” functionality, turning back to ImageMagick‘s brilliant “convert” command line command idea …

convert -delay 1000 -loop 0 [space limited list of image filenames] output.gif

… used within the procedure involving our Document Root Relative Folder Listing web application …

  • we open within a popup window in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Animated GIF *.gif data via (exec called) …

    convert -delay 1000 -loop 0 [space limited list of image filenames] output.gif

    … and from there …
  • the PHP uses the header arrangements
    <?php

    if (isset($_GET['agiflist']) && isset($_GET['agifname'])) {
    $dname="input.gif";
    $_GET['agiflist']=oururlencode($_GET['agiflist']);
    $dname=explode('.', basename(explode(',', str_replace('+',' ',urldecode($_GET['agiflist'])))[0]))[0] . '_et-al_' . sizeof(explode(',',str_replace('+',' ',urldecode($_GET['agiflist'])))) . '.gif';
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname'])))), str_replace(","," " . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['agiflist']))));
    exec($convprefix . 'convert -delay 1000 -loop 0 ' . file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname']))))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    $hsofar="<html><body><img src=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['agifname']))) . "\" data-base=data:image/gif;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))))) . "></img></body></html>";
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".gif",".uuu",str_replace('+',' ',urldecode($_GET['agifname'])))));
    if (4 == 4) {
    header('Content-Type: image/gif');
    header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
    header('Pragma: public');
    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))))));
    header("Content-Disposition: inline; filename=" . $dname);

    echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    exit;
    } else {
    echo $hsofar;
    $thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname'])));
    register_shutdown_function('shutdown');
    //sleep(45);
    //unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['agifname']))));
    shutdown() and exit;
    }
    }

    ?>
    …implied by the code above … and here it …
  • is able to display the Animated GIF (as an image/gif mimetype data) arrangement

… means by which we can offer an Animated GIF “assembly” now in the “tenth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, filibusters and crime busters and ghost busters, townfolk and countryfolk alike, like.


Previous relevant PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial is shown below.

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

Yesterday’s Document Root Relative Folder Listing Links Caption Tutorial work had within it’s changes features to do with …

after process unneeded web server file cleanup

… issues where in the past we may have resorted to a …

  • crontab (and maybe curl) means to a solution … but we prefer, where possible …
  • there and then procedures within the PHP (ie. it has to be PHP to help) … as much as anything, because that way, all the parts to any solution, are self contained

… and for security purposes that PHP solution is best done using a form method=POST methodology, or, as we are sprouting here today (and we like a lot, and think it could help us out later with other such scenarios) … and our apologies for the tautology

PHP Javascript Ajax Asynchronous Sleep Cleanup

… thinking we start explaining at the changed Javascript Ajax (to the original block of code) as per …

<?php echo ”

var gincv='', ganidn='';

function ajaxpdfit(incv) {
if (4 == 4) {
var anidn='' + incv.replace(/\\\\/g,'/').split(',')[0].split('/')[eval(-1 + incv.replace(/\\\\/g,'/').split(',')[0].split('/').length)].split('.')[0] + '_et-al_' + incv.split(',').length; // + '.pdf';
if (pdfwoo) {
if (!pdfwoo.closed) { pdfwoo.close(); pdfwoo=null; } else { pdfwoo.close(); pdfwoo=null; }
}
if (pptxwoo) {
if (!pptxwoo.closed) { pptxwoo.close(); pptxwoo=null; } else { pptxwoo.close(); pptxwoo=null; }
}
if (mswoo) {
if (!mswoo.closed) { mswoo.close(); mswoo=null; } else { mswoo.close(); mswoo=null; }
}
//incv=incv.replace(/\~\~/g, String.fromCharCode(92) + String.fromCharCode(10)); // new idea
if (('' + document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent(anidn + '.pdf')).length > 800) {
pdfzhr = new XMLHttpRequest();
pdfzform = new FormData();
pdfzform.append('anidnlist', incv);
pdfzform.append('anidn', anidn + '.abc');
//pdfzhr.onreadystatechange=noNeedToHangAround;
pdfzhr.open('post', './one_line_find.php', true);
pdfzhr.send(pdfzform);

ganidn=anidn;
gincv=noh(incv); // strips out any hashtagged caption data
setTimeout(function(){
pdfwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(gincv) + '&apdfname=' + encodeURIComponent(ganidn + '.pdf'),'_blank','top=20,left=' + eval(-700 + screen.width) + ',width=700,height=700');
pdfwoo.document.title='PDF (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
pptxwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?applist=' + encodeURIComponent(gincv) + '&appname=' + encodeURIComponent(ganidn + '.pptx'),'_blank','top=' + eval(-400 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
pptxwoo.document.title='PowerPoint (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
mswoo=window.open(document.URL.split('?')[0].split('#')[0] + '?amslist=' + encodeURIComponent(gincv) + '&amsname=' + encodeURIComponent(ganidn + '.docx'),'_blank','top=' + eval(-200 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
mswoo.document.title='Word (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
}, 5000);
} else {

pdfwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent(anidn + '.pdf'),'_blank','top=20,left=' + eval(-700 + screen.width) + ',width=700,height=700');
pdfwoo.document.title='PDF (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
pptxwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?applist=' + encodeURIComponent(incv) + '&appname=' + encodeURIComponent(anidn + '.pptx'),'_blank','top=' + eval(-400 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
pptxwoo.document.title='PowerPoint (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
mswoo=window.open(document.URL.split('?')[0].split('#')[0] + '?amslist=' + encodeURIComponent(incv) + '&amsname=' + encodeURIComponent(anidn + '.docx'),'_blank','top=' + eval(-200 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
mswoo.document.title='Word (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';

}
} else if (4 == 46) {
document.getElementById('apdflist').value=incv;
document.getElementById('apdfname').value='pdf' + Math.floor(Math.random() * 19897654) + '.pdf';
document.getElementById('thepdf').style.display='block';
document.getElementById('pdfsub').click();
} else if (4 == 47) {
document.getElementById('thepdf').style.display='block';
document.getElementById('thepdf').src=document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent('pdf' + Math.floor(Math.random() * 19897654) + '.pdf');
} else {
pdfzhr = new XMLHttpRequest();
pdfzform = new FormData();
pdfzform.append('apdflist', incv);
pdfzform.append('apdfname', 'pdf' + Math.floor(Math.random() * 19897654) + '.pdf');
pdfzhr.onreadystatechange=statePdfChanged;
pdfzhr.open('post', './one_line_find.php', true);
pdfzhr.send(pdfzform);
}
}

“; ?>

… begging the question, at least for us, being …

What’s the go with …
//pdfzhr.onreadystatechange=noNeedToHangAround;
?

Well, the “A” of Ajax stands for “Asynchronous”, as a useful aspect to Javascript where logic does not have to flow from start to finish linearly, and jobs can multitask. That onreadystatechange idea analyzes what the recipient PHP replies, but in the case of a file cleanup …

  1. it is optional (but preferable) if it happens at all, in the way we roll around here …
  2. and that means as far as file cleanup goes, immediately the interim ascii flat file (used to flesh out the following $_GET[] array work …
    <?php

    $commentaries=[];

    function oururlencode($instis) {
    global $commentaries;
    $interim=urldecode($instis);
    $origim=str_replace('+',' ',$interim);
    $intcs=explode(',', $interim);
    $found=false;
    for ($j=0; $j<sizeof($intcs); $j++) {
    if ($j == 0) {
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(explode('#',$intcs[$j])[0]) . '_et-al_' . sizeof($intcs) . '.abc')) {
    $instis=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(explode('#',$intcs[$j])[0]) . '_et-al_' . sizeof($intcs) . '.abc');
    $interim=urldecode($instis);
    $origim=str_replace('+',' ',$interim);
    $intcs=explode(',', $interim);
    }

    }
    array_push($commentaries, '');
    }
    for ($j=0; $j<sizeof($intcs); $j++) {
    $found=false;
    if (strpos($intcs[$j], '#') !== false) {
    $oneword=explode(' ',trim(explode('#', $intcs[$j])[1]))[0];
    if ($oneword != '' && strpos($oneword, '.') !== false && substr($oneword . ' ',0,1) == '/') {
    if (strpos($origim, $oneword) != '') {
    $found=true;
    }
    }
    if ($found) {
    $commentaries[$j].=' ' . str_replace("~~",chr(92) . chr(10),substr(trim(explode('#', $intcs[$j])[1]),strlen($oneword))); // fix perhaps
    }
    }
    }
    for ($j=0; $j<sizeof($intcs); $j++) {
    $jj=0;
    while ($commentaries[$jj] != '') {
    $jj++;
    }
    $found=false;
    if (strpos($intcs[$j], '#') !== false) {
    $oneword=explode(' ',trim(explode('#', $intcs[$j])[1]))[0];
    if ($oneword != '' && strpos($oneword, '.') !== false && substr($oneword . ' ',0,1) == '/') {
    if (strpos($origim, $oneword) != '') {
    $found=true;
    }
    }
    if (!$found) {
    $commentaries[$jj].=' ' . str_replace("~~",chr(92) . chr(10),explode('#', $intcs[$j])[1]); // fix perhaps
    }
    $interim=str_replace($intcs[$j],explode('#', $intcs[$j])[0],$interim);
    }
    }
    return urlencode($interim);
    }

    ?>
    …with hashtagged caption data that made the job too long for $_GET[] based navigation from the start) can be created by our recipient PHP Ajax “called upon” … then …
  3. the PHP can sleep
    <?php

    if (isset($_POST['anidnlist']) && isset($_POST['anidn'])) {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['anidn'])), str_replace('+',' ',urldecode($_POST['anidnlist'])));
    sleep(60);
    if (strpos(('' . str_replace('+',' ',urldecode($_POST['anidn'])) . '~'), '.abc~') !== false) {
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['anidn'])));
    }

    exit;
    }

    ?>
  4. leaving the $_GET[] pass (we wait back at the client Javascript 5 seconds for via setTimeout logics, while the PHP sleeps much longer) time to avail themselves back up at the server with the use of that interim ascii flat file (while the asynchronous, and not waited upon, Ajax called PHP sleeps … presumably among the lions) … while …
  5. back at the Ajax called PHP, having slept, and the interim file has lost it’s value, it can be deletedsorrrrrryyyyyyy “interim file”

… as one example of how this “PHP Javascript Ajax Asynchronous Sleep Cleanup” idea set could be implemented.


Previous relevant Document Root Relative Folder Listing Links Caption Tutorial is shown below.

Document Root Relative Folder Listing Links Caption Tutorial

Document Root Relative Folder Listing Links Caption Tutorial

After yesterday’s Document Root Relative Folder Listing Links Word Tutorial we had both …

  • PowerPoint
  • Word

… output document formats, created via pandoc, with the ability, in pandoc, to tailor slide “captions”, which, until today, had been hardwired to be the image slide filename.

We’ve decided to hashtag such user caption tailoring in hashtag data after the filenames passed over to the recipient PHP (which is the same as the originating PHP in “here’s looking at you” mode of thinking).

So where can the user enter these? The first option …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow or PDF or PowerPoint or Word via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; data-onblur=process(this); data-multiple><option id=firsttext onclick=addcommentary(); value=\"\">:</option></select>')

“; ?>

… of that relatively new dropdown for this is where we have decided to intervene …

<?php echo ”

var commentaries=[];

function addcommentary() {
needten=1;
var commadd=prompt('Optionally add to commentary. For new lines use ~~ characters. For multiple entries separate by , (ie. two blanks comma two blanks).', '');
if (commadd != null) {
var coms=commadd.split(' , ');
for (var ic=0; ic<coms.length; ic++) {
if (coms[ic].trim() != '') {
commentaries.push('#' + encodeURIComponent(coms[ic]));
}
}
}
}


“; ?>

And so, the “ninth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Word Tutorial is shown below.

Document Root Relative Folder Listing Links Word Tutorial

Document Root Relative Folder Listing Links Word Tutorial

The word is, in workplaces all around Earth now, workers are unwrapping their Mars Bars and shaping to use …


Word

huh?! Isn’t that a coincidence?! Who would have thunk it. They are constructing documents. So that being the case, do you think …

The barsoomian is, in workplaces all around Mars now, martians are unwrapping their Earth Bars and shaping to use …


Word


… to write haikus

? But if not, why not?!

As such, the creation of a “Word assembly” is our “fourth cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we PowerPointized yesterday with Document Root Relative Folder Listing Links PowerPoint Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$pconvprefix='/bin/';
if (file_exists('/usr/local/bin/pandoc')) {
$pconvprefix='/usr/local/bin/';
} else if (!file_exists('/bin/pandoc')) {
$pconvprefix='';
}

if (isset($_GET['amslist']) && isset($_GET['amsname'])) {
$dname="input.docx";
$themd=str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['amslist'])));
$thelines=explode("\n", $themd);
$themd="";
for ($i=0; $i<sizeof($thelines); $i++) {
if ($i == 0) {
$dname=explode('.', basename($thelines[$i]))[0] . '_et-al_' . sizeof($thelines) . '.docx';
}
if ($i == (-1 + sizeof($thelines))) {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")";
} else {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")\n\n---\n\n";
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))), $themd);
exec($pconvprefix . 'pandoc ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))) . ' -o ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['amsname']))) . "\" type=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\" data-base=data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))));
if (4 == 4) {
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))));
header("Content-Disposition: inline; filename=" . $dname);
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
shutdown() and exit;
}
}

?>

… engendering that same frisson of excitement we got yesterday, with Document Root Relative Folder Listing Links PowerPoint Tutorial … as (for us here on macOS) …

  • we open a popup in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Word *.docx data via (exec called) …

    pandoc presentation.md -o output.docx

    … and from there …
  • the PHP uses the header arrangements implied by the code above … but where it …
  • is unable to display, but still shows a download link …
  • we click …
  • showing a new Downloads folder file …
  • we get to in Finder …
  • we hover over that *.docx and see an Open With …
  • LibreOffice choice we select …
  • displaying the Word document containing the images selected

Cute, huh?!?!

The “eighth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links PDF Tutorial is shown below.

Document Root Relative Folder Listing Links PDF Tutorial

Document Root Relative Folder Listing Links PDF Tutorial

Hopefully, all around the world, the idea of a …


PDF

… display is replacing the “paper hungry” “hardcopy printout” concept. As such, the creation of a “PDF assembly” is our “second cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we started yesterday with Document Root Relative Folder Listing Links Assemblies Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$thingtoattendto='';

function shutdown() {
global $thingtoattendto;
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.

if ($thingtoattendto != '') {
sleep(145);
unlink($thingtoattendto);
}
}

$convprefix='/bin/';
if (file_exists('/usr/local/bin/convert')) {
$convprefix='/usr/local/bin/';
} else if (!file_exists('/bin/convert')) {
$convprefix='';
}

if (isset($_GET['apdflist']) && isset($_GET['apdfname'])) {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))), str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['apdflist']))));
exec($convprefix . 'convert @' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['apdfname']))) . "\" type=\"application/pdf\" data-base=data:application/pdf;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))));
if (4 == 4) {
header('Content-Type: application/pdf');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))));
header("Content-Disposition: inline; filename=input.pdf");
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
shutdown() and exit;
}
}

?>

… using ImageMagick‘s brilliant “convert” command line command idea …

convert @list.txt output.pdf

as the backbone as to how in the “sixth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Assemblies Tutorial is shown below.

Document Root Relative Folder Listing Links Assemblies Tutorial

Document Root Relative Folder Listing Links Assemblies Tutorial

So far, with the Document Root Relative Folder Listing work of recent times, up until the day before yesterday’s Document Root Relative Folder Listing Links Ajax Tutorial, it’s been mainly …

  • reporting … and …
  • display … but we want to move on to the user being able to create their own what we are referring to as …
  • assemblies

To us, these are user driven (is it widgets) they create by selecting multiple media (today images, but down the line, other combinations) from the left hand table cell’s listing links. We do not ask anymore of that left hand cell’s workings, as it will get too complex, but we have a penchant for adding intelligence to hardcodings, and the hardcoding …

https://www.rjmprogramming.com.au/

… is ripe for the picking, with that “just moseying along there innocently” …

:

… a candidate for a new multiple mode select (ie dropdown) element …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')

“; ?>

… means by which a user can specify “assembly components”.

Our simplest first “cab off the rank” here is a Javascript animated sequence, so far 4 second duration slides in a slideshow popup window, as per …

<?php echo ”

var lastretval='', origprefix='', wesayso=false, needten=0, sofarval='', woo=null;

function agifit(incsv) {
if (incsv != '') {
var myimgs=incsv.split(',');
if (woo) {
if (!woo.closed) { woo=woo; } else { woo.close(); woo=null; }
}
if (!woo) {
woo=window.open('','_blank','top=50,left=50,width=800,height=800');
woo.document.write('<ht' + 'ml><he' + 'ad>' + myimgs[0] + '<ti' + 'tle></ti' + 'tle><scr' + 'ipt type=text/javascript> var jimg=0, imgs=(\"' + incsv + '\").split(String.fromCharCode(44)), kimg=eval(\"\" + imgs.length); function startit() { jimg++; jimg=eval(jimg % kimg); document.body.style.background=' + \"'url(' + imgs[jimg] + ')'\" + '; document.title=' + \"'' + imgs[jimg] + ''\" + '; document.body.style.backgroundRepeat=\"no-repeat\"; document.body.style.backgroundSize=\"contain\"; } setInterval(startit,4000); </scri' + 'pt></head><body id=xbody style=background:url(' + myimgs[0] + ');background-repeat:no-repeat;background-size:contain;></body></html>');
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
return woo;
}
}
needten=0;
return null;
}

function monitorsel() {
var yesdo=true;
if (needten > 10) { setTimeout(monitorsel, 2000); return ''; }
var osel=document.getElementById('compsel');
var retval='', delim='';
if (sofarval != '') { delim=','; retval=sofarval; }
for (var i=0; i<osel.length; i++) { if (osel.options[i].selected) { if (osel.options[i].value != '') { if ((',' + sofarval + ',').indexOf(',' + osel.options[i].value + ',') == -1) { retval+=delim + osel.options[i].value; delim=','; } } } }
if (document.getElementById('compsel')) {
if (retval != '') {
if (retval != '' && retval.indexOf(',') == -1) {
needten=0;
}
if (lastretval != retval) {
lastretval=retval;
sofarval=retval;
needten=0;
} else if (needten < 10) {
needten++;
} else {
yesdo=false;
needten++;
if (agifit(sofarval)) {
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
}
}
}
if (yesdo) { setTimeout(monitorsel, 2000); }
}
}

function thismultiple(osel) {
if (document.getElementById('lefttd').outerHTML.split('>')[0].indexOf('overflow') == -1 || wesayso) {
wesayso=false;
document.getElementById('lefttd').style.overflowY='visible';
osel.style.height='30px';
osel.setAttribute('multiple', 'true');
setTimeout(monitorsel, 2000);
}
}


function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[], addthese='';
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
if (document.getElementById('prefix') && !document.getElementById('compsel')) {
if (document.getElementById('prefix').innerHTML.replace('p://','s://').indexOf('s://') != -1) {
document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')
}
}
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
//alert('0:' + outwo('/' + uids[2]) + ' ... ' + '/' + uids[2]);
if (outwo('/' + uids[2]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"/' + uids[2] + '\">/' + uids[2] + '</option>';
}

if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
//alert('1:' + outwo((ihis.split('%20-')[0].split(' -')[0])) + ' ... ' + (ihis.split('%20-')[0].split(' -')[0]));
if (outwo(ihis.split('%20-')[0].split(' -')[0]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"' + (ihis.split('%20-')[0].split(' -')[0]) + '\">' + (ihis.split('%20-')[0].split(' -')[0]) + '</option>';
}

if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
if (addthese != '') {
document.getElementById('compsel').innerHTML+=addthese;
origprefix=document.getElementById('prefix').innerHTML; //.replace(' data-multiple', ' multiple data-multiple');
}

setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

“; ?>

… in the “fifth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, like.


Previous relevant Document Root Relative Folder Listing Links Ajax Tutorial is shown below.

Document Root Relative Folder Listing Links Ajax Tutorial

Document Root Relative Folder Listing Links Ajax Tutorial

It was “faux Ajax day” with yesterday’s Document Root Relative Folder Listing Links Before and On Click Tutorial, but today …

It’s Ajax Day … yayyyyy!!!!

Howevvvvvvvver, just to confuse, there is no onmouseover involved, but the Ajax work does, at least for non-mobile users, sort of, affect display data, in that when hovering over a link, they may see within the title attribute of that link, whatevvvvvvvvver …


file "[a link href]"

… can “value add”, via Ajax logic, into the “up until now just an ls (underlying operating system command) based file listing” report.

Ajax is great here, as helping a subprocess that can be …

  • spawned off …
  • working away as a secondary (optional) process

… supplementing the primary workflow, if you will, but probably not too impactive, we’re hoping

<?php echo ”

var ajaxs=[], zhr=null, zform=null;

function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[];
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

function stateChanged() {
if (zhr.readyState == 4) {
if (zhr.status == 200) {
var rawhtml = zhr.response;
var spans=rawhtml.split('</span');
var ps=rawhtml.split('</p');
if (eval('' + ps.length) == 2 && eval('' + spans.length) == 2) {
document.getElementById(spans[0].split('>')[eval(-1 + spans[0].split('>').length)]).title+=ps[0].split('>')[eval(-1 + ps[0].split('>').length)];
}
setTimeout(doajaxs, 1000);
}
}
}

function doajaxs() {
var nexttogo='';
for (var ii=0; ii<ajaxs.length; ii++) {
if (nexttogo == '' && ajaxs[ii] != '') {
nexttogo=ajaxs[ii];
ajaxs[ii]='';
}
}
if (nexttogo != '') {
zhr = new XMLHttpRequest();
zform = new FormData();
zform.append('ajaxid', encodeURIComponent(nexttogo));
zform.append('ajaxurl', nexttogo);
zhr.onreadystatechange=stateChanged;
zhr.open('post', './one_line_find.php', true);
zhr.send(zform);
}
}


“; ?>

… Javascript calling logic using PHP recipient code …

<?php

if (isset($_POST['ajaxurl']) && isset($_POST['ajaxid'])) {
echo "<html><body><span>" . $_POST['ajaxid'] . '</span><p>' . str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('file "' . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_POST['ajaxurl'])) . '"')) . "</p></body></html>";
exit;
}

?>

… in the “fourth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, like.


Previous relevant Document Root Relative Folder Listing Links Before and On Click Tutorial is shown below.

Document Root Relative Folder Listing Links Before and On Click Tutorial

Document Root Relative Folder Listing Links Before and On Click Tutorial

Today’s work has an Ajax feel to it, despite the fact we use no Ajax type Javascript code, onto yesterday’s Document Root Relative Folder Listing Links Tutorial onclick event logics, we guess, because …

  • coding for the non-mobile onmouseover event, with display change logic, has a very Ajaxy feel to it … and …
  • on mobile we code for ontouchmove (feeding into user click actions)

calling via

<?php echo ”

tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a target="_blank" onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');

“; ?>

… calling on …

<?php echo ”

function showit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
if (ioi.outerHTML.indexOf('<span') != -1) {
outwo(ioi.getAttribute('data-href'));
} else {
outwo(ioi.href);
}
}

function hideit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
}

function hideitlater(ioi) {
if (2 == 5) {
setTimeout(function(){
document.getElementById('mymediatr').innerHTML=mytrih;
}, 15000);
}
}

“; ?>

Along the way we decided, in very Ajaxy thinking, on mobile, to be less disruptive with navigations after a click, so as to stay on the original webpage more often, in the “third draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you like.


Previous relevant Document Root Relative Folder Listing Links Tutorial is shown below.

Document Root Relative Folder Listing Links Tutorial

Document Root Relative Folder Listing Links Tutorial

Regular readers will “know the drill” with today’s work, on top of yesterday’s Document Root Relative Folder Listing Tutorial.

The new word in the posting title is …


Links

… and those regular readers would know …

  • yesterday’s Document Root Relative Folder Listing output was placed into a textarea element … clue 1
  • that textarea element we all admire for it’s textual data line feed talents and it’s talents for resizing capabilities … clue 2
  • that textarea element textual data is unembellishable (if that is a word) … clue 3
  • whereas your meek and mild div element, say, could overlay that textarea element, except for the right hand resizer, that is … clue 4
  • and the div element could latch onto that textarea basis of content and enhance filenames into filename links too (but am not sure about the Singing Glasses idea in the “talent quest section” … that seems a bridge too far) … clue 5

… leaving us clueless as to what else to say … chortle, chortle?!

Also helpful would be, to our minds …

  • still restrict the file specification to a “buttoned down” setting (because of security concerns) … but …
  • add complexity to the extension part …
    <?php

    $extbit='*.[tjpmwag][xpnopaid][etgvf34]*';

    ?>
    …to allow relatively innocent media files and PDFs reach the file listing (tweaked a bit too) now …
    <?php

    $resis=str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('ls -lhgo ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $offdr . $extbit));

    ?>

… in the “second draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, again, if you like.


Previous relevant Document Root Relative Folder Listing Tutorial is shown below.

Document Root Relative Folder Listing Tutorial

Document Root Relative Folder Listing Tutorial

The Apache web server has, for it’s PHP environment, if that is it’s server language, the concept of …


Document Root

… so that, for the website of the webpage you are reading from now, a URL such as our RJM Programming’s Landing Page’s URL …


https://www.rjmprogramming.com.au/

… scours that Document Root folder to find the index.php webpage code to display that Landing Page.

You can “abstract”, and we do also with our Difference Reporting, what that Document Root is as a folder path … bit forlorn we know, as we’ve shown what it is, probably, in many tutorial images … but the thing here is that a URL such as …


/index.php

… is understood and gets you to our Landing Page as well, because to the public, Document Root is the limit of where they are allowed to surf … if you like Document Root is the left hand beach flag at Surfers Paradise (or perhaps the right hand beach flag in the Todd River … when it gets water, that is?!).

Okay, that’s one theme of today’s new PHP web application. The other we wrote out to ourself was …

One line ls -clt https://www.rjmprogramming.com.au/*.txt via find $_SERVER[‘DOCUMENT_ROOT’] -type d -name ‘*’

… as a presentation idea whereby just the one table row of data is used to present …

  • https://www.rjmprogramming.com.au/
  • dropdown of list of folders off Document Root (“abstracting” Document Root itself … ie. relative referencing)
  • a file specification (minus the path) of interest … we are, for now, locking in as …

    *.txt

    … as the input data, to the output data that is …
  • output folder listing (as for Linux and macOS)

The concept of “one table row” for a multiple file listing is a mute point, but in our defence …

  • the textarea it is presented in (via rows=1) is user resizable
  • the textarea it is presented in is given a title with line feeds for the whole report so that non-mobile users can see this on hovering over the textarea

This was a PHP project definitely needing the mildly better outcomes of PHP shell_exec (where multiple line outputs are possible) as distinct from exec where only the last output line is returned, but is the usual method we use around here.

Keeping the report to one row also asks for …

  • use of elements that have CSS styling display:inline; as a default (eg. span element) … or …
  • user supplying CSS display:inline; or display:inline-block; as applicable … and …
  • table cell text-align:right; came in handy … as well as …
  • select element “dynamic shrinker” …

    function resizeSelect(sel) { // thanks to https://www.google.com/search?q=make+select+element+width+in+sympathy+with+length+of+its+value&rlz=1C5OZZY_en&oq=make+select+element+width+in+sympathy+with+length+of+its+value&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTI3MzEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8
    // 1. Create a temporary span to measure text width
    var tempSpan = document.createElement('span');
    tempSpan.style.visibility = 'hidden';
    tempSpan.style.position = 'absolute';
    tempSpan.style.whiteSpace = 'pre';
    // 2. Set font styles to match the select box
    tempSpan.style.font = window.getComputedStyle(sel).font;
    // 3. Set content to selected text
    tempSpan.innerText = sel.options[sel.selectedIndex].text;
    document.body.appendChild(tempSpan);

    // 4. Update width (with extra space for the dropdown arrow)
    sel.style.width = (tempSpan.offsetWidth + 30) + 'px';
    document.body.removeChild(tempSpan);
    }

… in the “proof of concept” one_line_find.php first draft Document Root Relative Folder Listing web application you can “crank up” below if you like …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Ajax, Animation, eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

PHP Javascript Ajax Asynchronous Sleep Cleanup Tutorial

Yesterday’s Document Root Relative Folder Listing Links Caption Tutorial work had within it’s changes features to do with …

after process unneeded web server file cleanup

… issues where in the past we may have resorted to a …

  • crontab (and maybe curl) means to a solution … but we prefer, where possible …
  • there and then procedures within the PHP (ie. it has to be PHP to help) … as much as anything, because that way, all the parts to any solution, are self contained

… and for security purposes that PHP solution is best done using a form method=POST methodology, or, as we are sprouting here today (and we like a lot, and think it could help us out later with other such scenarios) … and our apologies for the tautology

PHP Javascript Ajax Asynchronous Sleep Cleanup

… thinking we start explaining at the changed Javascript Ajax (to the original block of code) as per …

<?php echo ”

var gincv='', ganidn='';

function ajaxpdfit(incv) {
if (4 == 4) {
var anidn='' + incv.replace(/\\\\/g,'/').split(',')[0].split('/')[eval(-1 + incv.replace(/\\\\/g,'/').split(',')[0].split('/').length)].split('.')[0] + '_et-al_' + incv.split(',').length; // + '.pdf';
if (pdfwoo) {
if (!pdfwoo.closed) { pdfwoo.close(); pdfwoo=null; } else { pdfwoo.close(); pdfwoo=null; }
}
if (pptxwoo) {
if (!pptxwoo.closed) { pptxwoo.close(); pptxwoo=null; } else { pptxwoo.close(); pptxwoo=null; }
}
if (mswoo) {
if (!mswoo.closed) { mswoo.close(); mswoo=null; } else { mswoo.close(); mswoo=null; }
}
//incv=incv.replace(/\~\~/g, String.fromCharCode(92) + String.fromCharCode(10)); // new idea
if (('' + document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent(anidn + '.pdf')).length > 800) {
pdfzhr = new XMLHttpRequest();
pdfzform = new FormData();
pdfzform.append('anidnlist', incv);
pdfzform.append('anidn', anidn + '.abc');
//pdfzhr.onreadystatechange=noNeedToHangAround;
pdfzhr.open('post', './one_line_find.php', true);
pdfzhr.send(pdfzform);

ganidn=anidn;
gincv=noh(incv); // strips out any hashtagged caption data
setTimeout(function(){
pdfwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(gincv) + '&apdfname=' + encodeURIComponent(ganidn + '.pdf'),'_blank','top=20,left=' + eval(-700 + screen.width) + ',width=700,height=700');
pdfwoo.document.title='PDF (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
pptxwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?applist=' + encodeURIComponent(gincv) + '&appname=' + encodeURIComponent(ganidn + '.pptx'),'_blank','top=' + eval(-400 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
pptxwoo.document.title='PowerPoint (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
mswoo=window.open(document.URL.split('?')[0].split('#')[0] + '?amslist=' + encodeURIComponent(gincv) + '&amsname=' + encodeURIComponent(ganidn + '.docx'),'_blank','top=' + eval(-200 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
mswoo.document.title='Word (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
}, 5000);
} else {

pdfwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent(anidn + '.pdf'),'_blank','top=20,left=' + eval(-700 + screen.width) + ',width=700,height=700');
pdfwoo.document.title='PDF (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
pptxwoo=window.open(document.URL.split('?')[0].split('#')[0] + '?applist=' + encodeURIComponent(incv) + '&appname=' + encodeURIComponent(anidn + '.pptx'),'_blank','top=' + eval(-400 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
pptxwoo.document.title='PowerPoint (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';
mswoo=window.open(document.URL.split('?')[0].split('#')[0] + '?amslist=' + encodeURIComponent(incv) + '&amsname=' + encodeURIComponent(anidn + '.docx'),'_blank','top=' + eval(-200 + screen.height) + ',left=' + eval(-500 + screen.width) + ',width=300,height=200');
mswoo.document.title='Word (if not appearing try Download icon at top right and try opening via Open As from Downloads folder newest file)';

}
} else if (4 == 46) {
document.getElementById('apdflist').value=incv;
document.getElementById('apdfname').value='pdf' + Math.floor(Math.random() * 19897654) + '.pdf';
document.getElementById('thepdf').style.display='block';
document.getElementById('pdfsub').click();
} else if (4 == 47) {
document.getElementById('thepdf').style.display='block';
document.getElementById('thepdf').src=document.URL.split('?')[0].split('#')[0] + '?apdflist=' + encodeURIComponent(incv) + '&apdfname=' + encodeURIComponent('pdf' + Math.floor(Math.random() * 19897654) + '.pdf');
} else {
pdfzhr = new XMLHttpRequest();
pdfzform = new FormData();
pdfzform.append('apdflist', incv);
pdfzform.append('apdfname', 'pdf' + Math.floor(Math.random() * 19897654) + '.pdf');
pdfzhr.onreadystatechange=statePdfChanged;
pdfzhr.open('post', './one_line_find.php', true);
pdfzhr.send(pdfzform);
}
}

“; ?>

… begging the question, at least for us, being …

What’s the go with …
//pdfzhr.onreadystatechange=noNeedToHangAround;
?

Well, the “A” of Ajax stands for “Asynchronous”, as a useful aspect to Javascript where logic does not have to flow from start to finish linearly, and jobs can multitask. That onreadystatechange idea analyzes what the recipient PHP replies, but in the case of a file cleanup …

  1. it is optional (but preferable) if it happens at all, in the way we roll around here …
  2. and that means as far as file cleanup goes, immediately the interim ascii flat file (used to flesh out the following $_GET[] array work …
    <?php

    $commentaries=[];

    function oururlencode($instis) {
    global $commentaries;
    $interim=urldecode($instis);
    $origim=str_replace('+',' ',$interim);
    $intcs=explode(',', $interim);
    $found=false;
    for ($j=0; $j<sizeof($intcs); $j++) {
    if ($j == 0) {
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(explode('#',$intcs[$j])[0]) . '_et-al_' . sizeof($intcs) . '.abc')) {
    $instis=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(explode('#',$intcs[$j])[0]) . '_et-al_' . sizeof($intcs) . '.abc');
    $interim=urldecode($instis);
    $origim=str_replace('+',' ',$interim);
    $intcs=explode(',', $interim);
    }

    }
    array_push($commentaries, '');
    }
    for ($j=0; $j<sizeof($intcs); $j++) {
    $found=false;
    if (strpos($intcs[$j], '#') !== false) {
    $oneword=explode(' ',trim(explode('#', $intcs[$j])[1]))[0];
    if ($oneword != '' && strpos($oneword, '.') !== false && substr($oneword . ' ',0,1) == '/') {
    if (strpos($origim, $oneword) != '') {
    $found=true;
    }
    }
    if ($found) {
    $commentaries[$j].=' ' . str_replace("~~",chr(92) . chr(10),substr(trim(explode('#', $intcs[$j])[1]),strlen($oneword))); // fix perhaps
    }
    }
    }
    for ($j=0; $j<sizeof($intcs); $j++) {
    $jj=0;
    while ($commentaries[$jj] != '') {
    $jj++;
    }
    $found=false;
    if (strpos($intcs[$j], '#') !== false) {
    $oneword=explode(' ',trim(explode('#', $intcs[$j])[1]))[0];
    if ($oneword != '' && strpos($oneword, '.') !== false && substr($oneword . ' ',0,1) == '/') {
    if (strpos($origim, $oneword) != '') {
    $found=true;
    }
    }
    if (!$found) {
    $commentaries[$jj].=' ' . str_replace("~~",chr(92) . chr(10),explode('#', $intcs[$j])[1]); // fix perhaps
    }
    $interim=str_replace($intcs[$j],explode('#', $intcs[$j])[0],$interim);
    }
    }
    return urlencode($interim);
    }

    ?>
    …with hashtagged caption data that made the job too long for $_GET[] based navigation from the start) can be created by our recipient PHP Ajax “called upon” … then …
  3. the PHP can sleep
    <?php

    if (isset($_POST['anidnlist']) && isset($_POST['anidn'])) {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['anidn'])), str_replace('+',' ',urldecode($_POST['anidnlist'])));
    sleep(60);
    if (strpos(('' . str_replace('+',' ',urldecode($_POST['anidn'])) . '~'), '.abc~') !== false) {
    unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode($_POST['anidn'])));
    }

    exit;
    }

    ?>
  4. leaving the $_GET[] pass (we wait back at the client Javascript 5 seconds for via setTimeout logics, while the PHP sleeps much longer) time to avail themselves back up at the server with the use of that interim ascii flat file (while the asynchronous, and not waited upon, Ajax called PHP sleeps … presumably among the lions) … while …
  5. back at the Ajax called PHP, having slept, and the interim file has lost it’s value, it can be deletedsorrrrrryyyyyyy “interim file”

… as one example of how this “PHP Javascript Ajax Asynchronous Sleep Cleanup” idea set could be implemented.


Previous relevant Document Root Relative Folder Listing Links Caption Tutorial is shown below.

Document Root Relative Folder Listing Links Caption Tutorial

Document Root Relative Folder Listing Links Caption Tutorial

After yesterday’s Document Root Relative Folder Listing Links Word Tutorial we had both …

  • PowerPoint
  • Word

… output document formats, created via pandoc, with the ability, in pandoc, to tailor slide “captions”, which, until today, had been hardwired to be the image slide filename.

We’ve decided to hashtag such user caption tailoring in hashtag data after the filenames passed over to the recipient PHP (which is the same as the originating PHP in “here’s looking at you” mode of thinking).

So where can the user enter these? The first option …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow or PDF or PowerPoint or Word via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; data-onblur=process(this); data-multiple><option id=firsttext onclick=addcommentary(); value=\"\">:</option></select>')

“; ?>

… of that relatively new dropdown for this is where we have decided to intervene …

<?php echo ”

var commentaries=[];

function addcommentary() {
needten=1;
var commadd=prompt('Optionally add to commentary. For new lines use ~~ characters. For multiple entries separate by , (ie. two blanks comma two blanks).', '');
if (commadd != null) {
var coms=commadd.split(' , ');
for (var ic=0; ic<coms.length; ic++) {
if (coms[ic].trim() != '') {
commentaries.push('#' + encodeURIComponent(coms[ic]));
}
}
}
}


“; ?>

And so, the “ninth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Word Tutorial is shown below.

Document Root Relative Folder Listing Links Word Tutorial

Document Root Relative Folder Listing Links Word Tutorial

The word is, in workplaces all around Earth now, workers are unwrapping their Mars Bars and shaping to use …


Word

huh?! Isn’t that a coincidence?! Who would have thunk it. They are constructing documents. So that being the case, do you think …

The barsoomian is, in workplaces all around Mars now, martians are unwrapping their Earth Bars and shaping to use …


Word


… to write haikus

? But if not, why not?!

As such, the creation of a “Word assembly” is our “fourth cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we PowerPointized yesterday with Document Root Relative Folder Listing Links PowerPoint Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$pconvprefix='/bin/';
if (file_exists('/usr/local/bin/pandoc')) {
$pconvprefix='/usr/local/bin/';
} else if (!file_exists('/bin/pandoc')) {
$pconvprefix='';
}

if (isset($_GET['amslist']) && isset($_GET['amsname'])) {
$dname="input.docx";
$themd=str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['amslist'])));
$thelines=explode("\n", $themd);
$themd="";
for ($i=0; $i<sizeof($thelines); $i++) {
if ($i == 0) {
$dname=explode('.', basename($thelines[$i]))[0] . '_et-al_' . sizeof($thelines) . '.docx';
}
if ($i == (-1 + sizeof($thelines))) {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")";
} else {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")\n\n---\n\n";
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))), $themd);
exec($pconvprefix . 'pandoc ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))) . ' -o ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['amsname']))) . "\" type=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\" data-base=data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))));
if (4 == 4) {
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))));
header("Content-Disposition: inline; filename=" . $dname);
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
shutdown() and exit;
}
}

?>

… engendering that same frisson of excitement we got yesterday, with Document Root Relative Folder Listing Links PowerPoint Tutorial … as (for us here on macOS) …

  • we open a popup in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Word *.docx data via (exec called) …

    pandoc presentation.md -o output.docx

    … and from there …
  • the PHP uses the header arrangements implied by the code above … but where it …
  • is unable to display, but still shows a download link …
  • we click …
  • showing a new Downloads folder file …
  • we get to in Finder …
  • we hover over that *.docx and see an Open With …
  • LibreOffice choice we select …
  • displaying the Word document containing the images selected

Cute, huh?!?!

The “eigth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links PDF Tutorial is shown below.

Document Root Relative Folder Listing Links PDF Tutorial

Document Root Relative Folder Listing Links PDF Tutorial

Hopefully, all around the world, the idea of a …


PDF

… display is replacing the “paper hungry” “hardcopy printout” concept. As such, the creation of a “PDF assembly” is our “second cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we started yesterday with Document Root Relative Folder Listing Links Assemblies Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$thingtoattendto='';

function shutdown() {
global $thingtoattendto;
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.

if ($thingtoattendto != '') {
sleep(145);
unlink($thingtoattendto);
}
}

$convprefix='/bin/';
if (file_exists('/usr/local/bin/convert')) {
$convprefix='/usr/local/bin/';
} else if (!file_exists('/bin/convert')) {
$convprefix='';
}

if (isset($_GET['apdflist']) && isset($_GET['apdfname'])) {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))), str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['apdflist']))));
exec($convprefix . 'convert @' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['apdfname']))) . "\" type=\"application/pdf\" data-base=data:application/pdf;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))));
if (4 == 4) {
header('Content-Type: application/pdf');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))));
header("Content-Disposition: inline; filename=input.pdf");
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
shutdown() and exit;
}
}

?>

… using ImageMagick‘s brilliant “convert” command line command idea …

convert @list.txt output.pdf

as the backbone as to how in the “sixth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Assemblies Tutorial is shown below.

Document Root Relative Folder Listing Links Assemblies Tutorial

Document Root Relative Folder Listing Links Assemblies Tutorial

So far, with the Document Root Relative Folder Listing work of recent times, up until the day before yesterday’s Document Root Relative Folder Listing Links Ajax Tutorial, it’s been mainly …

  • reporting … and …
  • display … but we want to move on to the user being able to create their own what we are referring to as …
  • assemblies

To us, these are user driven (is it widgets) they create by selecting multiple media (today images, but down the line, other combinations) from the left hand table cell’s listing links. We do not ask anymore of that left hand cell’s workings, as it will get too complex, but we have a penchant for adding intelligence to hardcodings, and the hardcoding …

https://www.rjmprogramming.com.au/

… is ripe for the picking, with that “just moseying along there innocently” …

:

… a candidate for a new multiple mode select (ie dropdown) element …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')

“; ?>

… means by which a user can specify “assembly components”.

Our simplest first “cab off the rank” here is a Javascript animated sequence, so far 4 second duration slides in a slideshow popup window, as per …

<?php echo ”

var lastretval='', origprefix='', wesayso=false, needten=0, sofarval='', woo=null;

function agifit(incsv) {
if (incsv != '') {
var myimgs=incsv.split(',');
if (woo) {
if (!woo.closed) { woo=woo; } else { woo.close(); woo=null; }
}
if (!woo) {
woo=window.open('','_blank','top=50,left=50,width=800,height=800');
woo.document.write('<ht' + 'ml><he' + 'ad>' + myimgs[0] + '<ti' + 'tle></ti' + 'tle><scr' + 'ipt type=text/javascript> var jimg=0, imgs=(\"' + incsv + '\").split(String.fromCharCode(44)), kimg=eval(\"\" + imgs.length); function startit() { jimg++; jimg=eval(jimg % kimg); document.body.style.background=' + \"'url(' + imgs[jimg] + ')'\" + '; document.title=' + \"'' + imgs[jimg] + ''\" + '; document.body.style.backgroundRepeat=\"no-repeat\"; document.body.style.backgroundSize=\"contain\"; } setInterval(startit,4000); </scri' + 'pt></head><body id=xbody style=background:url(' + myimgs[0] + ');background-repeat:no-repeat;background-size:contain;></body></html>');
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
return woo;
}
}
needten=0;
return null;
}

function monitorsel() {
var yesdo=true;
if (needten > 10) { setTimeout(monitorsel, 2000); return ''; }
var osel=document.getElementById('compsel');
var retval='', delim='';
if (sofarval != '') { delim=','; retval=sofarval; }
for (var i=0; i<osel.length; i++) { if (osel.options[i].selected) { if (osel.options[i].value != '') { if ((',' + sofarval + ',').indexOf(',' + osel.options[i].value + ',') == -1) { retval+=delim + osel.options[i].value; delim=','; } } } }
if (document.getElementById('compsel')) {
if (retval != '') {
if (retval != '' && retval.indexOf(',') == -1) {
needten=0;
}
if (lastretval != retval) {
lastretval=retval;
sofarval=retval;
needten=0;
} else if (needten < 10) {
needten++;
} else {
yesdo=false;
needten++;
if (agifit(sofarval)) {
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
}
}
}
if (yesdo) { setTimeout(monitorsel, 2000); }
}
}

function thismultiple(osel) {
if (document.getElementById('lefttd').outerHTML.split('>')[0].indexOf('overflow') == -1 || wesayso) {
wesayso=false;
document.getElementById('lefttd').style.overflowY='visible';
osel.style.height='30px';
osel.setAttribute('multiple', 'true');
setTimeout(monitorsel, 2000);
}
}


function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[], addthese='';
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
if (document.getElementById('prefix') && !document.getElementById('compsel')) {
if (document.getElementById('prefix').innerHTML.replace('p://','s://').indexOf('s://') != -1) {
document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')
}
}
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
//alert('0:' + outwo('/' + uids[2]) + ' ... ' + '/' + uids[2]);
if (outwo('/' + uids[2]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"/' + uids[2] + '\">/' + uids[2] + '</option>';
}

if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
//alert('1:' + outwo((ihis.split('%20-')[0].split(' -')[0])) + ' ... ' + (ihis.split('%20-')[0].split(' -')[0]));
if (outwo(ihis.split('%20-')[0].split(' -')[0]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"' + (ihis.split('%20-')[0].split(' -')[0]) + '\">' + (ihis.split('%20-')[0].split(' -')[0]) + '</option>';
}

if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
if (addthese != '') {
document.getElementById('compsel').innerHTML+=addthese;
origprefix=document.getElementById('prefix').innerHTML; //.replace(' data-multiple', ' multiple data-multiple');
}

setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

“; ?>

… in the “fifth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, like.


Previous relevant Document Root Relative Folder Listing Links Ajax Tutorial is shown below.

Document Root Relative Folder Listing Links Ajax Tutorial

Document Root Relative Folder Listing Links Ajax Tutorial

It was “faux Ajax day” with yesterday’s Document Root Relative Folder Listing Links Before and On Click Tutorial, but today …

It’s Ajax Day … yayyyyy!!!!

Howevvvvvvvver, just to confuse, there is no onmouseover involved, but the Ajax work does, at least for non-mobile users, sort of, affect display data, in that when hovering over a link, they may see within the title attribute of that link, whatevvvvvvvvver …


file "[a link href]"

… can “value add”, via Ajax logic, into the “up until now just an ls (underlying operating system command) based file listing” report.

Ajax is great here, as helping a subprocess that can be …

  • spawned off …
  • working away as a secondary (optional) process

… supplementing the primary workflow, if you will, but probably not too impactive, we’re hoping

<?php echo ”

var ajaxs=[], zhr=null, zform=null;

function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[];
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

function stateChanged() {
if (zhr.readyState == 4) {
if (zhr.status == 200) {
var rawhtml = zhr.response;
var spans=rawhtml.split('</span');
var ps=rawhtml.split('</p');
if (eval('' + ps.length) == 2 && eval('' + spans.length) == 2) {
document.getElementById(spans[0].split('>')[eval(-1 + spans[0].split('>').length)]).title+=ps[0].split('>')[eval(-1 + ps[0].split('>').length)];
}
setTimeout(doajaxs, 1000);
}
}
}

function doajaxs() {
var nexttogo='';
for (var ii=0; ii<ajaxs.length; ii++) {
if (nexttogo == '' && ajaxs[ii] != '') {
nexttogo=ajaxs[ii];
ajaxs[ii]='';
}
}
if (nexttogo != '') {
zhr = new XMLHttpRequest();
zform = new FormData();
zform.append('ajaxid', encodeURIComponent(nexttogo));
zform.append('ajaxurl', nexttogo);
zhr.onreadystatechange=stateChanged;
zhr.open('post', './one_line_find.php', true);
zhr.send(zform);
}
}


“; ?>

… Javascript calling logic using PHP recipient code …

<?php

if (isset($_POST['ajaxurl']) && isset($_POST['ajaxid'])) {
echo "<html><body><span>" . $_POST['ajaxid'] . '</span><p>' . str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('file "' . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_POST['ajaxurl'])) . '"')) . "</p></body></html>";
exit;
}

?>

… in the “fourth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, like.


Previous relevant Document Root Relative Folder Listing Links Before and On Click Tutorial is shown below.

Document Root Relative Folder Listing Links Before and On Click Tutorial

Document Root Relative Folder Listing Links Before and On Click Tutorial

Today’s work has an Ajax feel to it, despite the fact we use no Ajax type Javascript code, onto yesterday’s Document Root Relative Folder Listing Links Tutorial onclick event logics, we guess, because …

  • coding for the non-mobile onmouseover event, with display change logic, has a very Ajaxy feel to it … and …
  • on mobile we code for ontouchmove (feeding into user click actions)

calling via

<?php echo ”

tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a target="_blank" onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');

“; ?>

… calling on …

<?php echo ”

function showit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
if (ioi.outerHTML.indexOf('<span') != -1) {
outwo(ioi.getAttribute('data-href'));
} else {
outwo(ioi.href);
}
}

function hideit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
}

function hideitlater(ioi) {
if (2 == 5) {
setTimeout(function(){
document.getElementById('mymediatr').innerHTML=mytrih;
}, 15000);
}
}

“; ?>

Along the way we decided, in very Ajaxy thinking, on mobile, to be less disruptive with navigations after a click, so as to stay on the original webpage more often, in the “third draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you like.


Previous relevant Document Root Relative Folder Listing Links Tutorial is shown below.

Document Root Relative Folder Listing Links Tutorial

Document Root Relative Folder Listing Links Tutorial

Regular readers will “know the drill” with today’s work, on top of yesterday’s Document Root Relative Folder Listing Tutorial.

The new word in the posting title is …


Links

… and those regular readers would know …

  • yesterday’s Document Root Relative Folder Listing output was placed into a textarea element … clue 1
  • that textarea element we all admire for it’s textual data line feed talents and it’s talents for resizing capabilities … clue 2
  • that textarea element textual data is unembellishable (if that is a word) … clue 3
  • whereas your meek and mild div element, say, could overlay that textarea element, except for the right hand resizer, that is … clue 4
  • and the div element could latch onto that textarea basis of content and enhance filenames into filename links too (but am not sure about the Singing Glasses idea in the “talent quest section” … that seems a bridge too far) … clue 5

… leaving us clueless as to what else to say … chortle, chortle?!

Also helpful would be, to our minds …

  • still restrict the file specification to a “buttoned down” setting (because of security concerns) … but …
  • add complexity to the extension part …
    <?php

    $extbit='*.[tjpmwag][xpnopaid][etgvf34]*';

    ?>
    …to allow relatively innocent media files and PDFs reach the file listing (tweaked a bit too) now …
    <?php

    $resis=str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('ls -lhgo ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $offdr . $extbit));

    ?>

… in the “second draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, again, if you like.


Previous relevant Document Root Relative Folder Listing Tutorial is shown below.

Document Root Relative Folder Listing Tutorial

Document Root Relative Folder Listing Tutorial

The Apache web server has, for it’s PHP environment, if that is it’s server language, the concept of …


Document Root

… so that, for the website of the webpage you are reading from now, a URL such as our RJM Programming’s Landing Page’s URL …


https://www.rjmprogramming.com.au/

… scours that Document Root folder to find the index.php webpage code to display that Landing Page.

You can “abstract”, and we do also with our Difference Reporting, what that Document Root is as a folder path … bit forlorn we know, as we’ve shown what it is, probably, in many tutorial images … but the thing here is that a URL such as …


/index.php

… is understood and gets you to our Landing Page as well, because to the public, Document Root is the limit of where they are allowed to surf … if you like Document Root is the left hand beach flag at Surfers Paradise (or perhaps the right hand beach flag in the Todd River … when it gets water, that is?!).

Okay, that’s one theme of today’s new PHP web application. The other we wrote out to ourself was …

One line ls -clt https://www.rjmprogramming.com.au/*.txt via find $_SERVER[‘DOCUMENT_ROOT’] -type d -name ‘*’

… as a presentation idea whereby just the one table row of data is used to present …

  • https://www.rjmprogramming.com.au/
  • dropdown of list of folders off Document Root (“abstracting” Document Root itself … ie. relative referencing)
  • a file specification (minus the path) of interest … we are, for now, locking in as …

    *.txt

    … as the input data, to the output data that is …
  • output folder listing (as for Linux and macOS)

The concept of “one table row” for a multiple file listing is a mute point, but in our defence …

  • the textarea it is presented in (via rows=1) is user resizable
  • the textarea it is presented in is given a title with line feeds for the whole report so that non-mobile users can see this on hovering over the textarea

This was a PHP project definitely needing the mildly better outcomes of PHP shell_exec (where multiple line outputs are possible) as distinct from exec where only the last output line is returned, but is the usual method we use around here.

Keeping the report to one row also asks for …

  • use of elements that have CSS styling display:inline; as a default (eg. span element) … or …
  • user supplying CSS display:inline; or display:inline-block; as applicable … and …
  • table cell text-align:right; came in handy … as well as …
  • select element “dynamic shrinker” …

    function resizeSelect(sel) { // thanks to https://www.google.com/search?q=make+select+element+width+in+sympathy+with+length+of+its+value&rlz=1C5OZZY_en&oq=make+select+element+width+in+sympathy+with+length+of+its+value&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTI3MzEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8
    // 1. Create a temporary span to measure text width
    var tempSpan = document.createElement('span');
    tempSpan.style.visibility = 'hidden';
    tempSpan.style.position = 'absolute';
    tempSpan.style.whiteSpace = 'pre';
    // 2. Set font styles to match the select box
    tempSpan.style.font = window.getComputedStyle(sel).font;
    // 3. Set content to selected text
    tempSpan.innerText = sel.options[sel.selectedIndex].text;
    document.body.appendChild(tempSpan);

    // 4. Update width (with extra space for the dropdown arrow)
    sel.style.width = (tempSpan.offsetWidth + 30) + 'px';
    document.body.removeChild(tempSpan);
    }

… in the “proof of concept” one_line_find.php first draft Document Root Relative Folder Listing web application you can “crank up” below if you like …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Ajax, eLearning, Event-Driven Programming, Tutorials | Tagged , , , , , , , , , , , , , , | Leave a comment

Document Root Relative Folder Listing Links Caption Tutorial

Document Root Relative Folder Listing Links Caption Tutorial

Document Root Relative Folder Listing Links Caption Tutorial

After yesterday’s Document Root Relative Folder Listing Links Word Tutorial we had both …

  • PowerPoint
  • Word

… output document formats, created via pandoc, with the ability, in pandoc, to tailor slide “captions”, which, until today, had been hardwired to be the image slide filename.

We’ve decided to hashtag such user caption tailoring in hashtag data after the filenames passed over to the recipient PHP (which is the same as the originating PHP in “here’s looking at you” mode of thinking).

So where can the user enter these? The first option …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow or PDF or PowerPoint or Word via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; data-onblur=process(this); data-multiple><option id=firsttext onclick=addcommentary(); value=\"\">:</option></select>')

“; ?>

… of that relatively new dropdown for this is where we have decided to intervene …

<?php echo ”

var commentaries=[];

function addcommentary() {
needten=1;
var commadd=prompt('Optionally add to commentary. For new lines use ~~ characters. For multiple entries separate by , (ie. two blanks comma two blanks).', '');
if (commadd != null) {
var coms=commadd.split(' , ');
for (var ic=0; ic<coms.length; ic++) {
if (coms[ic].trim() != '') {
commentaries.push('#' + encodeURIComponent(coms[ic]));
}
}
}
}


“; ?>

And so, the “ninth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, commentators and audience, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Word Tutorial is shown below.

Document Root Relative Folder Listing Links Word Tutorial

Document Root Relative Folder Listing Links Word Tutorial

The word is, in workplaces all around Earth now, workers are unwrapping their Mars Bars and shaping to use …


Word

huh?! Isn’t that a coincidence?! Who would have thunk it. They are constructing documents. So that being the case, do you think …

The barsoomian is, in workplaces all around Mars now, martians are unwrapping their Earth Bars and shaping to use …


Word


… to write haikus

? But if not, why not?!

As such, the creation of a “Word assembly” is our “fourth cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we PowerPointized yesterday with Document Root Relative Folder Listing Links PowerPoint Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$pconvprefix='/bin/';
if (file_exists('/usr/local/bin/pandoc')) {
$pconvprefix='/usr/local/bin/';
} else if (!file_exists('/bin/pandoc')) {
$pconvprefix='';
}

if (isset($_GET['amslist']) && isset($_GET['amsname'])) {
$dname="input.docx";
$themd=str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['amslist'])));
$thelines=explode("\n", $themd);
$themd="";
for ($i=0; $i<sizeof($thelines); $i++) {
if ($i == 0) {
$dname=explode('.', basename($thelines[$i]))[0] . '_et-al_' . sizeof($thelines) . '.docx';
}
if ($i == (-1 + sizeof($thelines))) {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")";
} else {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")\n\n---\n\n";
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))), $themd);
exec($pconvprefix . 'pandoc ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))) . ' -o ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['amsname']))) . "\" type=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\" data-base=data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))));
if (4 == 4) {
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))));
header("Content-Disposition: inline; filename=" . $dname);
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
shutdown() and exit;
}
}

?>

… engendering that same frisson of excitement we got yesterday, with Document Root Relative Folder Listing Links PowerPoint Tutorial … as (for us here on macOS) …

  • we open a popup in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Word *.docx data via (exec called) …

    pandoc presentation.md -o output.docx

    … and from there …
  • the PHP uses the header arrangements implied by the code above … but where it …
  • is unable to display, but still shows a download link …
  • we click …
  • showing a new Downloads folder file …
  • we get to in Finder …
  • we hover over that *.docx and see an Open With …
  • LibreOffice choice we select …
  • displaying the Word document containing the images selected

Cute, huh?!?!

The “eighth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links PDF Tutorial is shown below.

Document Root Relative Folder Listing Links PDF Tutorial

Document Root Relative Folder Listing Links PDF Tutorial

Hopefully, all around the world, the idea of a …


PDF

… display is replacing the “paper hungry” “hardcopy printout” concept. As such, the creation of a “PDF assembly” is our “second cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we started yesterday with Document Root Relative Folder Listing Links Assemblies Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$thingtoattendto='';

function shutdown() {
global $thingtoattendto;
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.

if ($thingtoattendto != '') {
sleep(145);
unlink($thingtoattendto);
}
}

$convprefix='/bin/';
if (file_exists('/usr/local/bin/convert')) {
$convprefix='/usr/local/bin/';
} else if (!file_exists('/bin/convert')) {
$convprefix='';
}

if (isset($_GET['apdflist']) && isset($_GET['apdfname'])) {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))), str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['apdflist']))));
exec($convprefix . 'convert @' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['apdfname']))) . "\" type=\"application/pdf\" data-base=data:application/pdf;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))));
if (4 == 4) {
header('Content-Type: application/pdf');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))));
header("Content-Disposition: inline; filename=input.pdf");
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
shutdown() and exit;
}
}

?>

… using ImageMagick‘s brilliant “convert” command line command idea …

convert @list.txt output.pdf

as the backbone as to how in the “sixth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Assemblies Tutorial is shown below.

Document Root Relative Folder Listing Links Assemblies Tutorial

Document Root Relative Folder Listing Links Assemblies Tutorial

So far, with the Document Root Relative Folder Listing work of recent times, up until the day before yesterday’s Document Root Relative Folder Listing Links Ajax Tutorial, it’s been mainly …

  • reporting … and …
  • display … but we want to move on to the user being able to create their own what we are referring to as …
  • assemblies

To us, these are user driven (is it widgets) they create by selecting multiple media (today images, but down the line, other combinations) from the left hand table cell’s listing links. We do not ask anymore of that left hand cell’s workings, as it will get too complex, but we have a penchant for adding intelligence to hardcodings, and the hardcoding …

https://www.rjmprogramming.com.au/

… is ripe for the picking, with that “just moseying along there innocently” …

:

… a candidate for a new multiple mode select (ie dropdown) element …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')

“; ?>

… means by which a user can specify “assembly components”.

Our simplest first “cab off the rank” here is a Javascript animated sequence, so far 4 second duration slides in a slideshow popup window, as per …

<?php echo ”

var lastretval='', origprefix='', wesayso=false, needten=0, sofarval='', woo=null;

function agifit(incsv) {
if (incsv != '') {
var myimgs=incsv.split(',');
if (woo) {
if (!woo.closed) { woo=woo; } else { woo.close(); woo=null; }
}
if (!woo) {
woo=window.open('','_blank','top=50,left=50,width=800,height=800');
woo.document.write('<ht' + 'ml><he' + 'ad>' + myimgs[0] + '<ti' + 'tle></ti' + 'tle><scr' + 'ipt type=text/javascript> var jimg=0, imgs=(\"' + incsv + '\").split(String.fromCharCode(44)), kimg=eval(\"\" + imgs.length); function startit() { jimg++; jimg=eval(jimg % kimg); document.body.style.background=' + \"'url(' + imgs[jimg] + ')'\" + '; document.title=' + \"'' + imgs[jimg] + ''\" + '; document.body.style.backgroundRepeat=\"no-repeat\"; document.body.style.backgroundSize=\"contain\"; } setInterval(startit,4000); </scri' + 'pt></head><body id=xbody style=background:url(' + myimgs[0] + ');background-repeat:no-repeat;background-size:contain;></body></html>');
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
return woo;
}
}
needten=0;
return null;
}

function monitorsel() {
var yesdo=true;
if (needten > 10) { setTimeout(monitorsel, 2000); return ''; }
var osel=document.getElementById('compsel');
var retval='', delim='';
if (sofarval != '') { delim=','; retval=sofarval; }
for (var i=0; i<osel.length; i++) { if (osel.options[i].selected) { if (osel.options[i].value != '') { if ((',' + sofarval + ',').indexOf(',' + osel.options[i].value + ',') == -1) { retval+=delim + osel.options[i].value; delim=','; } } } }
if (document.getElementById('compsel')) {
if (retval != '') {
if (retval != '' && retval.indexOf(',') == -1) {
needten=0;
}
if (lastretval != retval) {
lastretval=retval;
sofarval=retval;
needten=0;
} else if (needten < 10) {
needten++;
} else {
yesdo=false;
needten++;
if (agifit(sofarval)) {
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
}
}
}
if (yesdo) { setTimeout(monitorsel, 2000); }
}
}

function thismultiple(osel) {
if (document.getElementById('lefttd').outerHTML.split('>')[0].indexOf('overflow') == -1 || wesayso) {
wesayso=false;
document.getElementById('lefttd').style.overflowY='visible';
osel.style.height='30px';
osel.setAttribute('multiple', 'true');
setTimeout(monitorsel, 2000);
}
}


function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[], addthese='';
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
if (document.getElementById('prefix') && !document.getElementById('compsel')) {
if (document.getElementById('prefix').innerHTML.replace('p://','s://').indexOf('s://') != -1) {
document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')
}
}
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
//alert('0:' + outwo('/' + uids[2]) + ' ... ' + '/' + uids[2]);
if (outwo('/' + uids[2]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"/' + uids[2] + '\">/' + uids[2] + '</option>';
}

if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
//alert('1:' + outwo((ihis.split('%20-')[0].split(' -')[0])) + ' ... ' + (ihis.split('%20-')[0].split(' -')[0]));
if (outwo(ihis.split('%20-')[0].split(' -')[0]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"' + (ihis.split('%20-')[0].split(' -')[0]) + '\">' + (ihis.split('%20-')[0].split(' -')[0]) + '</option>';
}

if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
if (addthese != '') {
document.getElementById('compsel').innerHTML+=addthese;
origprefix=document.getElementById('prefix').innerHTML; //.replace(' data-multiple', ' multiple data-multiple');
}

setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

“; ?>

… in the “fifth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, like.


Previous relevant Document Root Relative Folder Listing Links Ajax Tutorial is shown below.

Document Root Relative Folder Listing Links Ajax Tutorial

Document Root Relative Folder Listing Links Ajax Tutorial

It was “faux Ajax day” with yesterday’s Document Root Relative Folder Listing Links Before and On Click Tutorial, but today …

It’s Ajax Day … yayyyyy!!!!

Howevvvvvvvver, just to confuse, there is no onmouseover involved, but the Ajax work does, at least for non-mobile users, sort of, affect display data, in that when hovering over a link, they may see within the title attribute of that link, whatevvvvvvvvver …


file "[a link href]"

… can “value add”, via Ajax logic, into the “up until now just an ls (underlying operating system command) based file listing” report.

Ajax is great here, as helping a subprocess that can be …

  • spawned off …
  • working away as a secondary (optional) process

… supplementing the primary workflow, if you will, but probably not too impactive, we’re hoping

<?php echo ”

var ajaxs=[], zhr=null, zform=null;

function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[];
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

function stateChanged() {
if (zhr.readyState == 4) {
if (zhr.status == 200) {
var rawhtml = zhr.response;
var spans=rawhtml.split('</span');
var ps=rawhtml.split('</p');
if (eval('' + ps.length) == 2 && eval('' + spans.length) == 2) {
document.getElementById(spans[0].split('>')[eval(-1 + spans[0].split('>').length)]).title+=ps[0].split('>')[eval(-1 + ps[0].split('>').length)];
}
setTimeout(doajaxs, 1000);
}
}
}

function doajaxs() {
var nexttogo='';
for (var ii=0; ii<ajaxs.length; ii++) {
if (nexttogo == '' && ajaxs[ii] != '') {
nexttogo=ajaxs[ii];
ajaxs[ii]='';
}
}
if (nexttogo != '') {
zhr = new XMLHttpRequest();
zform = new FormData();
zform.append('ajaxid', encodeURIComponent(nexttogo));
zform.append('ajaxurl', nexttogo);
zhr.onreadystatechange=stateChanged;
zhr.open('post', './one_line_find.php', true);
zhr.send(zform);
}
}


“; ?>

… Javascript calling logic using PHP recipient code …

<?php

if (isset($_POST['ajaxurl']) && isset($_POST['ajaxid'])) {
echo "<html><body><span>" . $_POST['ajaxid'] . '</span><p>' . str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('file "' . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_POST['ajaxurl'])) . '"')) . "</p></body></html>";
exit;
}

?>

… in the “fourth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, like.


Previous relevant Document Root Relative Folder Listing Links Before and On Click Tutorial is shown below.

Document Root Relative Folder Listing Links Before and On Click Tutorial

Document Root Relative Folder Listing Links Before and On Click Tutorial

Today’s work has an Ajax feel to it, despite the fact we use no Ajax type Javascript code, onto yesterday’s Document Root Relative Folder Listing Links Tutorial onclick event logics, we guess, because …

  • coding for the non-mobile onmouseover event, with display change logic, has a very Ajaxy feel to it … and …
  • on mobile we code for ontouchmove (feeding into user click actions)

calling via

<?php echo ”

tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a target="_blank" onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');

“; ?>

… calling on …

<?php echo ”

function showit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
if (ioi.outerHTML.indexOf('<span') != -1) {
outwo(ioi.getAttribute('data-href'));
} else {
outwo(ioi.href);
}
}

function hideit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
}

function hideitlater(ioi) {
if (2 == 5) {
setTimeout(function(){
document.getElementById('mymediatr').innerHTML=mytrih;
}, 15000);
}
}

“; ?>

Along the way we decided, in very Ajaxy thinking, on mobile, to be less disruptive with navigations after a click, so as to stay on the original webpage more often, in the “third draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you like.


Previous relevant Document Root Relative Folder Listing Links Tutorial is shown below.

Document Root Relative Folder Listing Links Tutorial

Document Root Relative Folder Listing Links Tutorial

Regular readers will “know the drill” with today’s work, on top of yesterday’s Document Root Relative Folder Listing Tutorial.

The new word in the posting title is …


Links

… and those regular readers would know …

  • yesterday’s Document Root Relative Folder Listing output was placed into a textarea element … clue 1
  • that textarea element we all admire for it’s textual data line feed talents and it’s talents for resizing capabilities … clue 2
  • that textarea element textual data is unembellishable (if that is a word) … clue 3
  • whereas your meek and mild div element, say, could overlay that textarea element, except for the right hand resizer, that is … clue 4
  • and the div element could latch onto that textarea basis of content and enhance filenames into filename links too (but am not sure about the Singing Glasses idea in the “talent quest section” … that seems a bridge too far) … clue 5

… leaving us clueless as to what else to say … chortle, chortle?!

Also helpful would be, to our minds …

  • still restrict the file specification to a “buttoned down” setting (because of security concerns) … but …
  • add complexity to the extension part …
    <?php

    $extbit='*.[tjpmwag][xpnopaid][etgvf34]*';

    ?>
    …to allow relatively innocent media files and PDFs reach the file listing (tweaked a bit too) now …
    <?php

    $resis=str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('ls -lhgo ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $offdr . $extbit));

    ?>

… in the “second draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, again, if you like.


Previous relevant Document Root Relative Folder Listing Tutorial is shown below.

Document Root Relative Folder Listing Tutorial

Document Root Relative Folder Listing Tutorial

The Apache web server has, for it’s PHP environment, if that is it’s server language, the concept of …


Document Root

… so that, for the website of the webpage you are reading from now, a URL such as our RJM Programming’s Landing Page’s URL …


https://www.rjmprogramming.com.au/

… scours that Document Root folder to find the index.php webpage code to display that Landing Page.

You can “abstract”, and we do also with our Difference Reporting, what that Document Root is as a folder path … bit forlorn we know, as we’ve shown what it is, probably, in many tutorial images … but the thing here is that a URL such as …


/index.php

… is understood and gets you to our Landing Page as well, because to the public, Document Root is the limit of where they are allowed to surf … if you like Document Root is the left hand beach flag at Surfers Paradise (or perhaps the right hand beach flag in the Todd River … when it gets water, that is?!).

Okay, that’s one theme of today’s new PHP web application. The other we wrote out to ourself was …

One line ls -clt https://www.rjmprogramming.com.au/*.txt via find $_SERVER[‘DOCUMENT_ROOT’] -type d -name ‘*’

… as a presentation idea whereby just the one table row of data is used to present …

  • https://www.rjmprogramming.com.au/
  • dropdown of list of folders off Document Root (“abstracting” Document Root itself … ie. relative referencing)
  • a file specification (minus the path) of interest … we are, for now, locking in as …

    *.txt

    … as the input data, to the output data that is …
  • output folder listing (as for Linux and macOS)

The concept of “one table row” for a multiple file listing is a mute point, but in our defence …

  • the textarea it is presented in (via rows=1) is user resizable
  • the textarea it is presented in is given a title with line feeds for the whole report so that non-mobile users can see this on hovering over the textarea

This was a PHP project definitely needing the mildly better outcomes of PHP shell_exec (where multiple line outputs are possible) as distinct from exec where only the last output line is returned, but is the usual method we use around here.

Keeping the report to one row also asks for …

  • use of elements that have CSS styling display:inline; as a default (eg. span element) … or …
  • user supplying CSS display:inline; or display:inline-block; as applicable … and …
  • table cell text-align:right; came in handy … as well as …
  • select element “dynamic shrinker” …

    function resizeSelect(sel) { // thanks to https://www.google.com/search?q=make+select+element+width+in+sympathy+with+length+of+its+value&rlz=1C5OZZY_en&oq=make+select+element+width+in+sympathy+with+length+of+its+value&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTI3MzEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8
    // 1. Create a temporary span to measure text width
    var tempSpan = document.createElement('span');
    tempSpan.style.visibility = 'hidden';
    tempSpan.style.position = 'absolute';
    tempSpan.style.whiteSpace = 'pre';
    // 2. Set font styles to match the select box
    tempSpan.style.font = window.getComputedStyle(sel).font;
    // 3. Set content to selected text
    tempSpan.innerText = sel.options[sel.selectedIndex].text;
    document.body.appendChild(tempSpan);

    // 4. Update width (with extra space for the dropdown arrow)
    sel.style.width = (tempSpan.offsetWidth + 30) + 'px';
    document.body.removeChild(tempSpan);
    }

… in the “proof of concept” one_line_find.php first draft Document Root Relative Folder Listing web application you can “crank up” below if you like …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Animation, eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Document Root Relative Folder Listing Links Word Tutorial

Document Root Relative Folder Listing Links Word Tutorial

Document Root Relative Folder Listing Links Word Tutorial

The word is, in workplaces all around Earth now, workers are unwrapping their Mars Bars and shaping to use …


Word

huh?! Isn’t that a coincidence?! Who would have thunk it. They are constructing documents. So that being the case, do you think …

The barsoomian is, in workplaces all around Mars now, martians are unwrapping their Earth Bars and shaping to use …


Word


… to write haikus

? But if not, why not?!

As such, the creation of a “Word assembly” is our “fourth cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we PowerPointized yesterday with Document Root Relative Folder Listing Links PowerPoint Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$pconvprefix='/bin/';
if (file_exists('/usr/local/bin/pandoc')) {
$pconvprefix='/usr/local/bin/';
} else if (!file_exists('/bin/pandoc')) {
$pconvprefix='';
}

if (isset($_GET['amslist']) && isset($_GET['amsname'])) {
$dname="input.docx";
$themd=str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['amslist'])));
$thelines=explode("\n", $themd);
$themd="";
for ($i=0; $i<sizeof($thelines); $i++) {
if ($i == 0) {
$dname=explode('.', basename($thelines[$i]))[0] . '_et-al_' . sizeof($thelines) . '.docx';
}
if ($i == (-1 + sizeof($thelines))) {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")";
} else {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")\n\n---\n\n";
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))), $themd);
exec($pconvprefix . 'pandoc ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))) . ' -o ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['amsname']))) . "\" type=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\" data-base=data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".docx",".yyy",str_replace('+',' ',urldecode($_GET['amsname'])))));
if (4 == 4) {
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))))));
header("Content-Disposition: inline; filename=" . $dname);
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['amsname']))));
shutdown() and exit;
}
}

?>

… engendering that same frisson of excitement we got yesterday, with Document Root Relative Folder Listing Links PowerPoint Tutorial … as (for us here on macOS) …

  • we open a popup in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct Word *.docx data via (exec called) …

    pandoc presentation.md -o output.docx

    … and from there …
  • the PHP uses the header arrangements implied by the code above … but where it …
  • is unable to display, but still shows a download link …
  • we click …
  • showing a new Downloads folder file …
  • we get to in Finder …
  • we hover over that *.docx and see an Open With …
  • LibreOffice choice we select …
  • displaying the Word document containing the images selected

Cute, huh?!?!

The “eighth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, cousins and removalists (to get rid of those pesky second ones), Martians with visas, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links PDF Tutorial is shown below.

Document Root Relative Folder Listing Links PDF Tutorial

Document Root Relative Folder Listing Links PDF Tutorial

Hopefully, all around the world, the idea of a …


PDF

… display is replacing the “paper hungry” “hardcopy printout” concept. As such, the creation of a “PDF assembly” is our “second cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we started yesterday with Document Root Relative Folder Listing Links Assemblies Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$thingtoattendto='';

function shutdown() {
global $thingtoattendto;
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.

if ($thingtoattendto != '') {
sleep(145);
unlink($thingtoattendto);
}
}

$convprefix='/bin/';
if (file_exists('/usr/local/bin/convert')) {
$convprefix='/usr/local/bin/';
} else if (!file_exists('/bin/convert')) {
$convprefix='';
}

if (isset($_GET['apdflist']) && isset($_GET['apdfname'])) {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))), str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['apdflist']))));
exec($convprefix . 'convert @' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['apdfname']))) . "\" type=\"application/pdf\" data-base=data:application/pdf;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))));
if (4 == 4) {
header('Content-Type: application/pdf');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))));
header("Content-Disposition: inline; filename=input.pdf");
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
shutdown() and exit;
}
}

?>

… using ImageMagick‘s brilliant “convert” command line command idea …

convert @list.txt output.pdf

as the backbone as to how in the “sixth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Assemblies Tutorial is shown below.

Document Root Relative Folder Listing Links Assemblies Tutorial

Document Root Relative Folder Listing Links Assemblies Tutorial

So far, with the Document Root Relative Folder Listing work of recent times, up until the day before yesterday’s Document Root Relative Folder Listing Links Ajax Tutorial, it’s been mainly …

  • reporting … and …
  • display … but we want to move on to the user being able to create their own what we are referring to as …
  • assemblies

To us, these are user driven (is it widgets) they create by selecting multiple media (today images, but down the line, other combinations) from the left hand table cell’s listing links. We do not ask anymore of that left hand cell’s workings, as it will get too complex, but we have a penchant for adding intelligence to hardcodings, and the hardcoding …

https://www.rjmprogramming.com.au/

… is ripe for the picking, with that “just moseying along there innocently” …

:

… a candidate for a new multiple mode select (ie dropdown) element …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')

“; ?>

… means by which a user can specify “assembly components”.

Our simplest first “cab off the rank” here is a Javascript animated sequence, so far 4 second duration slides in a slideshow popup window, as per …

<?php echo ”

var lastretval='', origprefix='', wesayso=false, needten=0, sofarval='', woo=null;

function agifit(incsv) {
if (incsv != '') {
var myimgs=incsv.split(',');
if (woo) {
if (!woo.closed) { woo=woo; } else { woo.close(); woo=null; }
}
if (!woo) {
woo=window.open('','_blank','top=50,left=50,width=800,height=800');
woo.document.write('<ht' + 'ml><he' + 'ad>' + myimgs[0] + '<ti' + 'tle></ti' + 'tle><scr' + 'ipt type=text/javascript> var jimg=0, imgs=(\"' + incsv + '\").split(String.fromCharCode(44)), kimg=eval(\"\" + imgs.length); function startit() { jimg++; jimg=eval(jimg % kimg); document.body.style.background=' + \"'url(' + imgs[jimg] + ')'\" + '; document.title=' + \"'' + imgs[jimg] + ''\" + '; document.body.style.backgroundRepeat=\"no-repeat\"; document.body.style.backgroundSize=\"contain\"; } setInterval(startit,4000); </scri' + 'pt></head><body id=xbody style=background:url(' + myimgs[0] + ');background-repeat:no-repeat;background-size:contain;></body></html>');
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
return woo;
}
}
needten=0;
return null;
}

function monitorsel() {
var yesdo=true;
if (needten > 10) { setTimeout(monitorsel, 2000); return ''; }
var osel=document.getElementById('compsel');
var retval='', delim='';
if (sofarval != '') { delim=','; retval=sofarval; }
for (var i=0; i<osel.length; i++) { if (osel.options[i].selected) { if (osel.options[i].value != '') { if ((',' + sofarval + ',').indexOf(',' + osel.options[i].value + ',') == -1) { retval+=delim + osel.options[i].value; delim=','; } } } }
if (document.getElementById('compsel')) {
if (retval != '') {
if (retval != '' && retval.indexOf(',') == -1) {
needten=0;
}
if (lastretval != retval) {
lastretval=retval;
sofarval=retval;
needten=0;
} else if (needten < 10) {
needten++;
} else {
yesdo=false;
needten++;
if (agifit(sofarval)) {
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
}
}
}
if (yesdo) { setTimeout(monitorsel, 2000); }
}
}

function thismultiple(osel) {
if (document.getElementById('lefttd').outerHTML.split('>')[0].indexOf('overflow') == -1 || wesayso) {
wesayso=false;
document.getElementById('lefttd').style.overflowY='visible';
osel.style.height='30px';
osel.setAttribute('multiple', 'true');
setTimeout(monitorsel, 2000);
}
}


function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[], addthese='';
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
if (document.getElementById('prefix') && !document.getElementById('compsel')) {
if (document.getElementById('prefix').innerHTML.replace('p://','s://').indexOf('s://') != -1) {
document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')
}
}
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
//alert('0:' + outwo('/' + uids[2]) + ' ... ' + '/' + uids[2]);
if (outwo('/' + uids[2]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"/' + uids[2] + '\">/' + uids[2] + '</option>';
}

if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
//alert('1:' + outwo((ihis.split('%20-')[0].split(' -')[0])) + ' ... ' + (ihis.split('%20-')[0].split(' -')[0]));
if (outwo(ihis.split('%20-')[0].split(' -')[0]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"' + (ihis.split('%20-')[0].split(' -')[0]) + '\">' + (ihis.split('%20-')[0].split(' -')[0]) + '</option>';
}

if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
if (addthese != '') {
document.getElementById('compsel').innerHTML+=addthese;
origprefix=document.getElementById('prefix').innerHTML; //.replace(' data-multiple', ' multiple data-multiple');
}

setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

“; ?>

… in the “fifth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, like.


Previous relevant Document Root Relative Folder Listing Links Ajax Tutorial is shown below.

Document Root Relative Folder Listing Links Ajax Tutorial

Document Root Relative Folder Listing Links Ajax Tutorial

It was “faux Ajax day” with yesterday’s Document Root Relative Folder Listing Links Before and On Click Tutorial, but today …

It’s Ajax Day … yayyyyy!!!!

Howevvvvvvvver, just to confuse, there is no onmouseover involved, but the Ajax work does, at least for non-mobile users, sort of, affect display data, in that when hovering over a link, they may see within the title attribute of that link, whatevvvvvvvvver …


file "[a link href]"

… can “value add”, via Ajax logic, into the “up until now just an ls (underlying operating system command) based file listing” report.

Ajax is great here, as helping a subprocess that can be …

  • spawned off …
  • working away as a secondary (optional) process

… supplementing the primary workflow, if you will, but probably not too impactive, we’re hoping

<?php echo ”

var ajaxs=[], zhr=null, zform=null;

function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[];
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

function stateChanged() {
if (zhr.readyState == 4) {
if (zhr.status == 200) {
var rawhtml = zhr.response;
var spans=rawhtml.split('</span');
var ps=rawhtml.split('</p');
if (eval('' + ps.length) == 2 && eval('' + spans.length) == 2) {
document.getElementById(spans[0].split('>')[eval(-1 + spans[0].split('>').length)]).title+=ps[0].split('>')[eval(-1 + ps[0].split('>').length)];
}
setTimeout(doajaxs, 1000);
}
}
}

function doajaxs() {
var nexttogo='';
for (var ii=0; ii<ajaxs.length; ii++) {
if (nexttogo == '' && ajaxs[ii] != '') {
nexttogo=ajaxs[ii];
ajaxs[ii]='';
}
}
if (nexttogo != '') {
zhr = new XMLHttpRequest();
zform = new FormData();
zform.append('ajaxid', encodeURIComponent(nexttogo));
zform.append('ajaxurl', nexttogo);
zhr.onreadystatechange=stateChanged;
zhr.open('post', './one_line_find.php', true);
zhr.send(zform);
}
}


“; ?>

… Javascript calling logic using PHP recipient code …

<?php

if (isset($_POST['ajaxurl']) && isset($_POST['ajaxid'])) {
echo "<html><body><span>" . $_POST['ajaxid'] . '</span><p>' . str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('file "' . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_POST['ajaxurl'])) . '"')) . "</p></body></html>";
exit;
}

?>

… in the “fourth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, like.


Previous relevant Document Root Relative Folder Listing Links Before and On Click Tutorial is shown below.

Document Root Relative Folder Listing Links Before and On Click Tutorial

Document Root Relative Folder Listing Links Before and On Click Tutorial

Today’s work has an Ajax feel to it, despite the fact we use no Ajax type Javascript code, onto yesterday’s Document Root Relative Folder Listing Links Tutorial onclick event logics, we guess, because …

  • coding for the non-mobile onmouseover event, with display change logic, has a very Ajaxy feel to it … and …
  • on mobile we code for ontouchmove (feeding into user click actions)

calling via

<?php echo ”

tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a target="_blank" onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');

“; ?>

… calling on …

<?php echo ”

function showit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
if (ioi.outerHTML.indexOf('<span') != -1) {
outwo(ioi.getAttribute('data-href'));
} else {
outwo(ioi.href);
}
}

function hideit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
}

function hideitlater(ioi) {
if (2 == 5) {
setTimeout(function(){
document.getElementById('mymediatr').innerHTML=mytrih;
}, 15000);
}
}

“; ?>

Along the way we decided, in very Ajaxy thinking, on mobile, to be less disruptive with navigations after a click, so as to stay on the original webpage more often, in the “third draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you like.


Previous relevant Document Root Relative Folder Listing Links Tutorial is shown below.

Document Root Relative Folder Listing Links Tutorial

Document Root Relative Folder Listing Links Tutorial

Regular readers will “know the drill” with today’s work, on top of yesterday’s Document Root Relative Folder Listing Tutorial.

The new word in the posting title is …


Links

… and those regular readers would know …

  • yesterday’s Document Root Relative Folder Listing output was placed into a textarea element … clue 1
  • that textarea element we all admire for it’s textual data line feed talents and it’s talents for resizing capabilities … clue 2
  • that textarea element textual data is unembellishable (if that is a word) … clue 3
  • whereas your meek and mild div element, say, could overlay that textarea element, except for the right hand resizer, that is … clue 4
  • and the div element could latch onto that textarea basis of content and enhance filenames into filename links too (but am not sure about the Singing Glasses idea in the “talent quest section” … that seems a bridge too far) … clue 5

… leaving us clueless as to what else to say … chortle, chortle?!

Also helpful would be, to our minds …

  • still restrict the file specification to a “buttoned down” setting (because of security concerns) … but …
  • add complexity to the extension part …
    <?php

    $extbit='*.[tjpmwag][xpnopaid][etgvf34]*';

    ?>
    …to allow relatively innocent media files and PDFs reach the file listing (tweaked a bit too) now …
    <?php

    $resis=str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('ls -lhgo ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $offdr . $extbit));

    ?>

… in the “second draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, again, if you like.


Previous relevant Document Root Relative Folder Listing Tutorial is shown below.

Document Root Relative Folder Listing Tutorial

Document Root Relative Folder Listing Tutorial

The Apache web server has, for it’s PHP environment, if that is it’s server language, the concept of …


Document Root

… so that, for the website of the webpage you are reading from now, a URL such as our RJM Programming’s Landing Page’s URL …


https://www.rjmprogramming.com.au/

… scours that Document Root folder to find the index.php webpage code to display that Landing Page.

You can “abstract”, and we do also with our Difference Reporting, what that Document Root is as a folder path … bit forlorn we know, as we’ve shown what it is, probably, in many tutorial images … but the thing here is that a URL such as …


/index.php

… is understood and gets you to our Landing Page as well, because to the public, Document Root is the limit of where they are allowed to surf … if you like Document Root is the left hand beach flag at Surfers Paradise (or perhaps the right hand beach flag in the Todd River … when it gets water, that is?!).

Okay, that’s one theme of today’s new PHP web application. The other we wrote out to ourself was …

One line ls -clt https://www.rjmprogramming.com.au/*.txt via find $_SERVER[‘DOCUMENT_ROOT’] -type d -name ‘*’

… as a presentation idea whereby just the one table row of data is used to present …

  • https://www.rjmprogramming.com.au/
  • dropdown of list of folders off Document Root (“abstracting” Document Root itself … ie. relative referencing)
  • a file specification (minus the path) of interest … we are, for now, locking in as …

    *.txt

    … as the input data, to the output data that is …
  • output folder listing (as for Linux and macOS)

The concept of “one table row” for a multiple file listing is a mute point, but in our defence …

  • the textarea it is presented in (via rows=1) is user resizable
  • the textarea it is presented in is given a title with line feeds for the whole report so that non-mobile users can see this on hovering over the textarea

This was a PHP project definitely needing the mildly better outcomes of PHP shell_exec (where multiple line outputs are possible) as distinct from exec where only the last output line is returned, but is the usual method we use around here.

Keeping the report to one row also asks for …

  • use of elements that have CSS styling display:inline; as a default (eg. span element) … or …
  • user supplying CSS display:inline; or display:inline-block; as applicable … and …
  • table cell text-align:right; came in handy … as well as …
  • select element “dynamic shrinker” …

    function resizeSelect(sel) { // thanks to https://www.google.com/search?q=make+select+element+width+in+sympathy+with+length+of+its+value&rlz=1C5OZZY_en&oq=make+select+element+width+in+sympathy+with+length+of+its+value&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTI3MzEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8
    // 1. Create a temporary span to measure text width
    var tempSpan = document.createElement('span');
    tempSpan.style.visibility = 'hidden';
    tempSpan.style.position = 'absolute';
    tempSpan.style.whiteSpace = 'pre';
    // 2. Set font styles to match the select box
    tempSpan.style.font = window.getComputedStyle(sel).font;
    // 3. Set content to selected text
    tempSpan.innerText = sel.options[sel.selectedIndex].text;
    document.body.appendChild(tempSpan);

    // 4. Update width (with extra space for the dropdown arrow)
    sel.style.width = (tempSpan.offsetWidth + 30) + 'px';
    document.body.removeChild(tempSpan);
    }

… in the “proof of concept” one_line_find.php first draft Document Root Relative Folder Listing web application you can “crank up” below if you like …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Animation, eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Document Root Relative Folder Listing Links PowerPoint Tutorial

Document Root Relative Folder Listing Links PowerPoint Tutorial

Document Root Relative Folder Listing Links PowerPoint Tutorial

All around the boardrooms of the world, as we speak …


PowerPoint

… slideshow presentations will be taking place. As such, the creation of a “PowerPoint assembly” is our “third cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we PDFized yesterday with Document Root Relative Folder Listing Links PDF Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$pconvprefix='/bin/';
if (file_exists('/usr/local/bin/pandoc')) {
$pconvprefix='/usr/local/bin/';
} else if (!file_exists('/bin/pandoc')) {
$pconvprefix='';
}

if (isset($_GET['applist']) && isset($_GET['appname'])) {
$dname="input.pptx";
$themd=str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['applist'])));
$thelines=explode("\n", $themd);
$themd="";
for ($i=0; $i<sizeof($thelines); $i++) {
if ($i == 0) {
$dname=explode('.', basename($thelines[$i]))[0] . '_et-al_' . sizeof($thelines) . '.pptx';
}
if ($i == (-1 + sizeof($thelines))) {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")";
} else {
$themd.='![' . basename($thelines[$i]) . "](" . $thelines[$i] . ")\n\n---\n\n";
}
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pptx",".zzz",str_replace('+',' ',urldecode($_GET['appname'])))), $themd);
exec($pconvprefix . 'pandoc ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pptx",".zzz",str_replace('+',' ',urldecode($_GET['appname'])))) . ' -o ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['appname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['appname']))) . "\" type=\"application/pptx\" data-base=data:application/pptx;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['appname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pptx",".zzz",str_replace('+',' ',urldecode($_GET['appname'])))));
if (4 == 4) {
header('Content-Type: application/pptx');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['appname']))))));
header("Content-Disposition: inline; filename=" . $dname);
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['appname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['appname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['appname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['appname']))));
shutdown() and exit;
}
}

?>

… exciting to us, here, in that it can work with a web browser such as Google Chrome even though, up at the RJM Programming web server we have no application installed which can display a PowerPoint *.pptx slideshow presentation file, but we do back at macOS because we installed LibreOffice, and so, in our case …

  • we open a popup in Google Chrome (via selected slides) …
  • the recipient PHP constructs the wherewithal to construct PowerPoint *.pptx data via (exec called) …

    pandoc presentation.md -o output.pptx

    … and from there …
  • the PHP uses the header arrangements implied by the code above … but where it …
  • is unable to display, but still shows a download link …
  • we click …
  • showing a new Downloads folder file …
  • we get to in Finder …
  • we hover over that *.pptx and see an Open With …
  • LibreOffice choice we select …
  • displaying the PowerPoint slideshow

Cute, huh?!

The “seventh draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, girls and boys, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links PDF Tutorial is shown below.

Document Root Relative Folder Listing Links PDF Tutorial

Document Root Relative Folder Listing Links PDF Tutorial

Hopefully, all around the world, the idea of a …


PDF

… display is replacing the “paper hungry” “hardcopy printout” concept. As such, the creation of a “PDF assembly” is our “second cab off the rank” as an output format offered to users trying out the recent select (ie. dropdown) “assemblies” we started yesterday with Document Root Relative Folder Listing Links Assemblies Tutorial. We use a window.open popup again, latching onto the PHP recipient code …

<?php

$thingtoattendto='';

function shutdown() {
global $thingtoattendto;
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.

if ($thingtoattendto != '') {
sleep(145);
unlink($thingtoattendto);
}
}

$convprefix='/bin/';
if (file_exists('/usr/local/bin/convert')) {
$convprefix='/usr/local/bin/';
} else if (!file_exists('/bin/convert')) {
$convprefix='';
}

if (isset($_GET['apdflist']) && isset($_GET['apdfname'])) {
file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))), str_replace(",","\n" . $_SERVER['DOCUMENT_ROOT'], $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_GET['apdflist']))));
exec($convprefix . 'convert @' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
$hsofar="<html><body><object data=\"/tmp/" . basename(str_replace('+',' ',urldecode($_GET['apdfname']))) . "\" type=\"application/pdf\" data-base=data:application/pdf;base64," . base64_encode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))) . "></object></body></html>";
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace(".pdf",".xxx",str_replace('+',' ',urldecode($_GET['apdfname'])))));
if (4 == 4) {
header('Content-Type: application/pdf');
header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' . strlen(file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))))));
header("Content-Disposition: inline; filename=input.pdf");
echo file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
exit;
} else {
echo $hsofar;
$thingtoattendto=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname'])));
register_shutdown_function('shutdown');
//sleep(45);
//unlink($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['apdfname']))));
shutdown() and exit;
}
}

?>

… using ImageMagick‘s brilliant “convert” command line command idea …

convert @list.txt output.pdf

as the backbone as to how in the “sixth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, townfolk and countryfolk alike, like.


Previous relevant Document Root Relative Folder Listing Links Assemblies Tutorial is shown below.

Document Root Relative Folder Listing Links Assemblies Tutorial

Document Root Relative Folder Listing Links Assemblies Tutorial

So far, with the Document Root Relative Folder Listing work of recent times, up until the day before yesterday’s Document Root Relative Folder Listing Links Ajax Tutorial, it’s been mainly …

  • reporting … and …
  • display … but we want to move on to the user being able to create their own what we are referring to as …
  • assemblies

To us, these are user driven (is it widgets) they create by selecting multiple media (today images, but down the line, other combinations) from the left hand table cell’s listing links. We do not ask anymore of that left hand cell’s workings, as it will get too complex, but we have a penchant for adding intelligence to hardcodings, and the hardcoding …

https://www.rjmprogramming.com.au/

… is ripe for the picking, with that “just moseying along there innocently” …

:

… a candidate for a new multiple mode select (ie dropdown) element …

<?php echo ”

document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')

“; ?>

… means by which a user can specify “assembly components”.

Our simplest first “cab off the rank” here is a Javascript animated sequence, so far 4 second duration slides in a slideshow popup window, as per …

<?php echo ”

var lastretval='', origprefix='', wesayso=false, needten=0, sofarval='', woo=null;

function agifit(incsv) {
if (incsv != '') {
var myimgs=incsv.split(',');
if (woo) {
if (!woo.closed) { woo=woo; } else { woo.close(); woo=null; }
}
if (!woo) {
woo=window.open('','_blank','top=50,left=50,width=800,height=800');
woo.document.write('<ht' + 'ml><he' + 'ad>' + myimgs[0] + '<ti' + 'tle></ti' + 'tle><scr' + 'ipt type=text/javascript> var jimg=0, imgs=(\"' + incsv + '\").split(String.fromCharCode(44)), kimg=eval(\"\" + imgs.length); function startit() { jimg++; jimg=eval(jimg % kimg); document.body.style.background=' + \"'url(' + imgs[jimg] + ')'\" + '; document.title=' + \"'' + imgs[jimg] + ''\" + '; document.body.style.backgroundRepeat=\"no-repeat\"; document.body.style.backgroundSize=\"contain\"; } setInterval(startit,4000); </scri' + 'pt></head><body id=xbody style=background:url(' + myimgs[0] + ');background-repeat:no-repeat;background-size:contain;></body></html>');
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
return woo;
}
}
needten=0;
return null;
}

function monitorsel() {
var yesdo=true;
if (needten > 10) { setTimeout(monitorsel, 2000); return ''; }
var osel=document.getElementById('compsel');
var retval='', delim='';
if (sofarval != '') { delim=','; retval=sofarval; }
for (var i=0; i<osel.length; i++) { if (osel.options[i].selected) { if (osel.options[i].value != '') { if ((',' + sofarval + ',').indexOf(',' + osel.options[i].value + ',') == -1) { retval+=delim + osel.options[i].value; delim=','; } } } }
if (document.getElementById('compsel')) {
if (retval != '') {
if (retval != '' && retval.indexOf(',') == -1) {
needten=0;
}
if (lastretval != retval) {
lastretval=retval;
sofarval=retval;
needten=0;
} else if (needten < 10) {
needten++;
} else {
yesdo=false;
needten++;
if (agifit(sofarval)) {
if (origprefix != '') { document.getElementById('prefix').innerHTML=origprefix; wesayso=true; needten=0; sofarval=''; lastretval=''; }
}
}
}
if (yesdo) { setTimeout(monitorsel, 2000); }
}
}

function thismultiple(osel) {
if (document.getElementById('lefttd').outerHTML.split('>')[0].indexOf('overflow') == -1 || wesayso) {
wesayso=false;
document.getElementById('lefttd').style.overflowY='visible';
osel.style.height='30px';
osel.setAttribute('multiple', 'true');
setTimeout(monitorsel, 2000);
}
}


function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[], addthese='';
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
if (document.getElementById('prefix') && !document.getElementById('compsel')) {
if (document.getElementById('prefix').innerHTML.replace('p://','s://').indexOf('s://') != -1) {
document.getElementById('prefix').innerHTML=document.getElementById('prefix').innerHTML.replace(':','<select ontouchstart=\"thismultiple(this);\" onmouseover=\"thismultiple(this);\" onclick=\"thismultiple(this);\" size=1 id=compsel title=\"Animated slideshow via slides possible selecting multiple images here.\" style=display:inline-block;width:28px; onblur=process(this); data-multiple><option value=\"\">:</option></select>')
}
}
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
//alert('0:' + outwo('/' + uids[2]) + ' ... ' + '/' + uids[2]);
if (outwo('/' + uids[2]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"/' + uids[2] + '\">/' + uids[2] + '</option>';
}

if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
//alert('1:' + outwo((ihis.split('%20-')[0].split(' -')[0])) + ' ... ' + (ihis.split('%20-')[0].split(' -')[0]));
if (outwo(ihis.split('%20-')[0].split(' -')[0]).replace(' ','IMAGE/') == 'IMAGE/') {
addthese+='<option value=\"' + (ihis.split('%20-')[0].split(' -')[0]) + '\">' + (ihis.split('%20-')[0].split(' -')[0]) + '</option>';
}

if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + ' <a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
if (addthese != '') {
document.getElementById('compsel').innerHTML+=addthese;
origprefix=document.getElementById('prefix').innerHTML; //.replace(' data-multiple', ' multiple data-multiple');
}

setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

“; ?>

… in the “fifth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, along with their family and friends, like.


Previous relevant Document Root Relative Folder Listing Links Ajax Tutorial is shown below.

Document Root Relative Folder Listing Links Ajax Tutorial

Document Root Relative Folder Listing Links Ajax Tutorial

It was “faux Ajax day” with yesterday’s Document Root Relative Folder Listing Links Before and On Click Tutorial, but today …

It’s Ajax Day … yayyyyy!!!!

Howevvvvvvvver, just to confuse, there is no onmouseover involved, but the Ajax work does, at least for non-mobile users, sort of, affect display data, in that when hovering over a link, they may see within the title attribute of that link, whatevvvvvvvvver …


file "[a link href]"

… can “value add”, via Ajax logic, into the “up until now just an ls (underlying operating system command) based file listing” report.

Ajax is great here, as helping a subprocess that can be …

  • spawned off …
  • working away as a secondary (optional) process

… supplementing the primary workflow, if you will, but probably not too impactive, we’re hoping

<?php echo ”

var ajaxs=[], zhr=null, zform=null;

function massage(tv) {
var tscnt=0, itv=0, ihis='', uids=[];
var tlls=tv.split('<br>');
for (itv=eval(-1 + tlls.length); itv>=0; itv--) {
if (tlls[itv].indexOf(' /') != -1) {
uids=tlls[itv].split(' /');
ihis=tlls[itv].replace(tlls[itv].split(' /')[0] + ' ','');
if (eval('' + uids.length) == 3) {
ajaxs.unshift('/' + uids[2]);
if (outwo('/' + uids[2]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent('/' + uids[2]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this) href=\"/' + uids[2] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
} else {
ajaxs.unshift(ihis.split('%20-')[0].split(' -')[0]);
if (outwo(ihis.split('%20-')[0].split(' -')[0]) == 'IMAGE/' && navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && 1 == 1) {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<span id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" style=text-decoration:underline; onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=# data-href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</span>');
} else {
tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a id=\"' + encodeURIComponent(ihis.split('%20-')[0].split(' -')[0]) + '\" title=\"\" target=_blank onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');
}
}
}
}
setInterval(function(){ var onerect=document.getElementById('djc').getBoundingClientRect(), tworect=document.getElementById('jc').getBoundingClientRect(); if (Math.abs(eval(eval(('' + onerect.height) - eval('' + tworect.height)))) > 20) { document.getElementById('djc').style.height='' + tworect.height + 'px'; document.getElementById('djc').style.width='' + eval(-20 + tworect.width) + 'px'; } }, 6000);
setTimeout(doajaxs, 1000);
return tv;
}

function stateChanged() {
if (zhr.readyState == 4) {
if (zhr.status == 200) {
var rawhtml = zhr.response;
var spans=rawhtml.split('</span');
var ps=rawhtml.split('</p');
if (eval('' + ps.length) == 2 && eval('' + spans.length) == 2) {
document.getElementById(spans[0].split('>')[eval(-1 + spans[0].split('>').length)]).title+=ps[0].split('>')[eval(-1 + ps[0].split('>').length)];
}
setTimeout(doajaxs, 1000);
}
}
}

function doajaxs() {
var nexttogo='';
for (var ii=0; ii<ajaxs.length; ii++) {
if (nexttogo == '' && ajaxs[ii] != '') {
nexttogo=ajaxs[ii];
ajaxs[ii]='';
}
}
if (nexttogo != '') {
zhr = new XMLHttpRequest();
zform = new FormData();
zform.append('ajaxid', encodeURIComponent(nexttogo));
zform.append('ajaxurl', nexttogo);
zhr.onreadystatechange=stateChanged;
zhr.open('post', './one_line_find.php', true);
zhr.send(zform);
}
}


“; ?>

… Javascript calling logic using PHP recipient code …

<?php

if (isset($_POST['ajaxurl']) && isset($_POST['ajaxid'])) {
echo "<html><body><span>" . $_POST['ajaxid'] . '</span><p>' . str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('file "' . $_SERVER['DOCUMENT_ROOT'] . str_replace('+',' ',urldecode($_POST['ajaxurl'])) . '"')) . "</p></body></html>";
exit;
}

?>

… in the “fourth draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you, and your ilk, like.


Previous relevant Document Root Relative Folder Listing Links Before and On Click Tutorial is shown below.

Document Root Relative Folder Listing Links Before and On Click Tutorial

Document Root Relative Folder Listing Links Before and On Click Tutorial

Today’s work has an Ajax feel to it, despite the fact we use no Ajax type Javascript code, onto yesterday’s Document Root Relative Folder Listing Links Tutorial onclick event logics, we guess, because …

  • coding for the non-mobile onmouseover event, with display change logic, has a very Ajaxy feel to it … and …
  • on mobile we code for ontouchmove (feeding into user click actions)

calling via

<?php echo ”

tv=tv.replace(tlls[itv].split(' /')[0] + ' ' + ihis, tlls[itv].split(' /')[0] + '&#9;<a target="_blank" onmouseover=showit(this); onmouseout=hideit(this); ontouchmove=showit(this); ontouchend=hideitlater(this); href=\"' + ihis.split('%20-')[0].split(' -')[0] + '\">' + ihis.split('%20-')[0].split(' -')[0] + '</a>');

“; ?>

… calling on …

<?php echo ”

function showit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
if (ioi.outerHTML.indexOf('<span') != -1) {
outwo(ioi.getAttribute('data-href'));
} else {
outwo(ioi.href);
}
}

function hideit(ioi) {
document.getElementById('mymediatr').innerHTML=mytrih;
}

function hideitlater(ioi) {
if (2 == 5) {
setTimeout(function(){
document.getElementById('mymediatr').innerHTML=mytrih;
}, 15000);
}
}

“; ?>

Along the way we decided, in very Ajaxy thinking, on mobile, to be less disruptive with navigations after a click, so as to stay on the original webpage more often, in the “third draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, yet again, if you like.


Previous relevant Document Root Relative Folder Listing Links Tutorial is shown below.

Document Root Relative Folder Listing Links Tutorial

Document Root Relative Folder Listing Links Tutorial

Regular readers will “know the drill” with today’s work, on top of yesterday’s Document Root Relative Folder Listing Tutorial.

The new word in the posting title is …


Links

… and those regular readers would know …

  • yesterday’s Document Root Relative Folder Listing output was placed into a textarea element … clue 1
  • that textarea element we all admire for it’s textual data line feed talents and it’s talents for resizing capabilities … clue 2
  • that textarea element textual data is unembellishable (if that is a word) … clue 3
  • whereas your meek and mild div element, say, could overlay that textarea element, except for the right hand resizer, that is … clue 4
  • and the div element could latch onto that textarea basis of content and enhance filenames into filename links too (but am not sure about the Singing Glasses idea in the “talent quest section” … that seems a bridge too far) … clue 5

… leaving us clueless as to what else to say … chortle, chortle?!

Also helpful would be, to our minds …

  • still restrict the file specification to a “buttoned down” setting (because of security concerns) … but …
  • add complexity to the extension part …
    <?php

    $extbit='*.[tjpmwag][xpnopaid][etgvf34]*';

    ?>
    …to allow relatively innocent media files and PDFs reach the file listing (tweaked a bit too) now …
    <?php

    $resis=str_replace($_SERVER['DOCUMENT_ROOT'],'',shell_exec('ls -lhgo ' . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $offdr . $extbit));

    ?>

… in the “second draft” one_line_find.php Document Root Relative Folder Listing web application you can “crank up” below, again, if you like.


Previous relevant Document Root Relative Folder Listing Tutorial is shown below.

Document Root Relative Folder Listing Tutorial

Document Root Relative Folder Listing Tutorial

The Apache web server has, for it’s PHP environment, if that is it’s server language, the concept of …


Document Root

… so that, for the website of the webpage you are reading from now, a URL such as our RJM Programming’s Landing Page’s URL …


https://www.rjmprogramming.com.au/

… scours that Document Root folder to find the index.php webpage code to display that Landing Page.

You can “abstract”, and we do also with our Difference Reporting, what that Document Root is as a folder path … bit forlorn we know, as we’ve shown what it is, probably, in many tutorial images … but the thing here is that a URL such as …


/index.php

… is understood and gets you to our Landing Page as well, because to the public, Document Root is the limit of where they are allowed to surf … if you like Document Root is the left hand beach flag at Surfers Paradise (or perhaps the right hand beach flag in the Todd River … when it gets water, that is?!).

Okay, that’s one theme of today’s new PHP web application. The other we wrote out to ourself was …

One line ls -clt https://www.rjmprogramming.com.au/*.txt via find $_SERVER[‘DOCUMENT_ROOT’] -type d -name ‘*’

… as a presentation idea whereby just the one table row of data is used to present …

  • https://www.rjmprogramming.com.au/
  • dropdown of list of folders off Document Root (“abstracting” Document Root itself … ie. relative referencing)
  • a file specification (minus the path) of interest … we are, for now, locking in as …

    *.txt

    … as the input data, to the output data that is …
  • output folder listing (as for Linux and macOS)

The concept of “one table row” for a multiple file listing is a mute point, but in our defence …

  • the textarea it is presented in (via rows=1) is user resizable
  • the textarea it is presented in is given a title with line feeds for the whole report so that non-mobile users can see this on hovering over the textarea

This was a PHP project definitely needing the mildly better outcomes of PHP shell_exec (where multiple line outputs are possible) as distinct from exec where only the last output line is returned, but is the usual method we use around here.

Keeping the report to one row also asks for …

  • use of elements that have CSS styling display:inline; as a default (eg. span element) … or …
  • user supplying CSS display:inline; or display:inline-block; as applicable … and …
  • table cell text-align:right; came in handy … as well as …
  • select element “dynamic shrinker” …

    function resizeSelect(sel) { // thanks to https://www.google.com/search?q=make+select+element+width+in+sympathy+with+length+of+its+value&rlz=1C5OZZY_en&oq=make+select+element+width+in+sympathy+with+length+of+its+value&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTI3MzEzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8
    // 1. Create a temporary span to measure text width
    var tempSpan = document.createElement('span');
    tempSpan.style.visibility = 'hidden';
    tempSpan.style.position = 'absolute';
    tempSpan.style.whiteSpace = 'pre';
    // 2. Set font styles to match the select box
    tempSpan.style.font = window.getComputedStyle(sel).font;
    // 3. Set content to selected text
    tempSpan.innerText = sel.options[sel.selectedIndex].text;
    document.body.appendChild(tempSpan);

    // 4. Update width (with extra space for the dropdown arrow)
    sel.style.width = (tempSpan.offsetWidth + 30) + 'px';
    document.body.removeChild(tempSpan);
    }

… in the “proof of concept” one_line_find.php first draft Document Root Relative Folder Listing web application you can “crank up” below if you like …

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Animation, eLearning, Event-Driven Programming, Operating System, Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment