function scanner($path) { global $REGISTERED_MEDIA_EXTENSION, $FROM_DIR, $TO_DIR; $handle = opendir($path); while ($f = readdir($handle)) { if (filetype($path . $f) == 'dir') { if ($f != '.' && $f != '..') { $dir = $path . $f; $new_dir = str_replace($FROM_DIR, $TO_DIR, $dir); if (!file_exists($new_dir)) { mkdir($new_dir); } scanner($path . $f . "/"); } } elseif (filetype($path . $f) == 'file') { if (preg_match("/\\.(" . $REGISTERED_MEDIA_EXTENSION . ")\$/i", $f)) { $file = $path . $f; $file = preg_replace("/\\.(" . $REGISTERED_MEDIA_EXTENSION . ")\$/i", ".mp4", $file); if (!file_exists(str_replace($FROM_DIR, $TO_DIR, $file))) { convert($path . $f, str_replace($FROM_DIR, $TO_DIR, $file)); } } } else { echo "unknown\n"; } } closedir($handle); }
function scanner($path) { global $REGISTERED_MEDIA_EXTENSION, $FROM_DIR, $TO_DIR, $count; $handle = opendir($path); while ($f = readdir($handle)) { if (filetype($path . $f) == 'dir') { if ($f != '.' && $f != '..') { scanner($path . $f . "/"); } } elseif (filetype($path . $f) == 'file') { if (preg_match("/\\.(" . $REGISTERED_MEDIA_EXTENSION . ")\$/i", $f)) { $count++; $file = $path . $f; if (viewInfo($file) && preg_match("/\\.mp4\$/i", $file)) { echo "File true \n"; } else { $tofile = str_replace(".mp4", "_.mp4", $file); $tofile = preg_replace("/\\.(" . $REGISTERED_MEDIA_EXTENSION . ")\$/i", ".mp4", $tofile); convert($file, $tofile); } echo "\n"; } } else { echo "\t\tUnknown file\n"; } } closedir($handle); }
<?php /** * Main object. * @author Kikapp * @version 1.0 */ $win = new SDPanel(); $win->setCaption("Scanner API"); $mainTable = new Table(); $button = new Button(); $button->setCaption("Scan!"); $button->onTap(scanner()); $mainTable->addControl($button, 1, 1); $win->addControl($mainTable); function scanner() { $code = new InputText(); $code = ScannerAPI::ScanBarcode(); echo "code " . $code; }
function scanner($path) { global $REGISTERED_MEDIA_EXTENSION, $FROM_DIR, $TO_DIR; $handle = opendir($path); while ($f = readdir($handle)) { if (filetype($path . $f) == 'dir') { if ($f != '.' && $f != '..') { scanner($path . $f . "/"); } } elseif (filetype($path . $f) == 'file') { if (preg_match("/\\.(" . $REGISTERED_MEDIA_EXTENSION . ")\$/i", $f)) { viewInfo($path . $f); } } else { echo "\t\tUnknown file\n"; } } closedir($handle); }