Can pay $50 paypal if you can help me with a solution. Thank you!
Thanks for the kind words about the plugin. I don’t want any money, this is open source and I’m not able to provide any extensive support.
The problem is not in React but in the PHP code that is searching for image files. Currently, it cannot search subdirectories:
foreach (array_filter(glob($webcam_dir . '*'), 'is_file') as $path) {
$last_filename = basename($path);
}
return $last_filename;
But you can modify the above code right in the installed plugin so that it searches recursively.
I can’t help you more with that, sorry. If you are not capable of changing it on your own, get help from some PHP developer.
mauibrew : I gave the same situation.
Folders are like
…./wp-content/uploads/webcam/
In this folder I have the local IP of the DVR device = 192.168.1.8
In that one, for each day
/2018-11-16
/2018-11-17
In these date named folder, the iage are uploaded with names like
DVR_ch7_20181117001022_T.jpg
My typical image file path is :
/path/to/where/are/your/files/wp-content/uploads/webcam/192.168.1.8/2018-11-17/DVR_ch7_20181117001022_T.jpg
As said, the /2018-11-17/ part changes every day.
I changed the get_last_filename function like this :
function get_last_filename($subdir) {
$upload_dir = wp_upload_dir();
$webcam_dir = $upload_dir['basedir'] . '/' . WEBCAM_DIR . '/' ;
if ($subdir && preg_match('/[a-z0-9]/i', $subdir)) {
$webcam_dir .= $subdir . '/';
}
$files = getDirContents($webcam_dir);
// Return the (relative path to the) file name - without the first '/'
return deleteFirstChar(str_replace(realpath($webcam_dir), '',end($files)));
};
My function getDirContents is like this
function getDirContents($dir, &$results = array()){
$files = scandir( $dir );
foreach($files as $key => $value){
$path = realpath($dir.DIRECTORY_SEPARATOR.$value);
if(!is_dir($path)) {
if (filesize($path) > 0)
$results[] = $path;
} else if($value != "." && $value != "..") {
getDirContents($path, $results);
}
}
return $results;
}
as you already might have noticed, these directories will be filled up.
I advise you to use a cron-like tool to clean them up.
A simple shell script exampe :
#!/bin/sh
find /path/to/where/are/your/files/wp-content/uploads/webcam/192.168.1.8 -depth -mindepth 1 -mmin +60 -uid 1001 -exec rm -rdf {} \;
which runs every day and removes all files and folders older then 60 minutes.
Thanks for sharing your solution.
Hello I couldn’t get into my old acct –
Can you post full updated plugin code (with your code added) so I can just cut and paste?
I’m not great with where to add the new code.
My webcam path is like this – https://website.com/wp-content/uploads/webcam/NGLSPP-371687-PCJWU/2019-3-10/picture/T_20190310181508.jpg
Thank you!
I tried adding this code (to replace the current function get last filename code) and the page just stops loading below the header.
I’m totally puzzled as to how to make this code work, if anyone can help that would be great. Thank you!