26if (!defined(
'NOSESSION')) {
27 define(
'NOSESSION',
'1');
30$sapi_type = php_sapi_name();
31$script_file = basename(__FILE__);
35if (substr($sapi_type, 0, 3) ==
'cgi') {
36 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
41define(
'EVEN_IF_ONLY_LOGIN_ALLOWED', 1);
44require_once $path.
"../../htdocs/master.inc.php";
45require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
46require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
47require_once DOL_DOCUMENT_ROOT.
"/core/lib/images.lib.php";
55$version = DOL_VERSION;
59$hookmanager->initHooks(array(
'cli'));
65print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" *****\n";
66dol_syslog($script_file.
" launched with arg ".join(
',', $argv));
69 print
"Usage: $script_file subdirtoscan\n";
70 print
"Example: $script_file produit\n";
74print
'--- start'.
"\n";
78if (empty($dir) || empty($subdir)) {
83 print
'Directory '.$dir.
'/'.$subdir.
' not found.'.
"\n";
87$filearray =
dol_dir_list($dir.
'/'.$subdir,
"directories", 0,
'',
'temp$');
89global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
91foreach ($filearray as $keyf => $valf) {
92 $ref = basename($valf[
'name']);
93 $filearrayimg =
dol_dir_list($valf[
'fullname'],
"files", 0,
'(\.gif|\.png|\.jpg|\.jpeg|\.bmp|\.webp)$',
'(\.meta|_preview.*\.png)$');
94 foreach ($filearrayimg as $keyi => $vali) {
95 print
'Process image for ref '.$ref.
' : '.$vali[
'name'].
"\n";
99 $imgThumbSmall =
vignette($vali[
'fullname'], $maxwidthsmall, $maxheightsmall,
'_small', 50,
"thumbs");
100 if (preg_match(
'/Error/', $imgThumbSmall)) {
101 print $imgThumbSmall.
"\n";
106 $imgThumbMini =
vignette($vali[
'fullname'], $maxwidthmini, $maxheightmini,
'_mini', 50,
"thumbs");
107 if (preg_match(
'/Error/', $imgThumbMini)) {
108 print $imgThumbMini.
"\n";
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
vignette($file, $maxWidth=160, $maxHeight=120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0)
Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp).