27if (!defined(
'NOSESSION')) {
28 define(
'NOSESSION',
'1');
31$sapi_type = php_sapi_name();
32$script_file = basename(__FILE__);
36if (substr($sapi_type, 0, 3) ==
'cgi') {
37 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
42define(
'EVEN_IF_ONLY_LOGIN_ALLOWED', 1);
45require_once $path.
"../../htdocs/master.inc.php";
46require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
47require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
55$version = DOL_VERSION;
59print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" *****\n";
60dol_syslog($script_file.
" launched with arg ".join(
',', $argv));
62if (!isset($argv[1]) || $argv[1] !=
'product') {
63 print
"Usage: $script_file product\n";
67print
'--- start'.
"\n";
70if ($argv[1] ==
'product') {
73 $sql =
"SELECT rowid as pid from ".MAIN_DB_PREFIX.
"product";
74 $resql = $db->query($sql);
76 while ($obj = $db->fetch_object($resql)) {
77 $product->fetch($obj->pid);
78 print
" migrating product id=".$product->id.
" ref=".$product->ref.
"\n";
82 print
"\n sql error ".$sql;
101 $dir = $conf->product->multidir_output[$product->entity];
102 $conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO = 1;
103 $origin = $dir.
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
113 $handle = opendir($origin_osencoded);
114 if (is_resource($handle)) {
115 while (($file = readdir($handle)) !==
false) {
116 if ($file !=
'.' && $file !=
'..' && is_dir($origin_osencoded.
'/'.$file)) {
117 $thumbs = opendir($origin_osencoded.
'/'.$file);
118 if (is_resource($thumbs)) {
120 while (($thumb = readdir($thumbs)) !==
false) {
121 dol_move($origin.
'/'.$file.
'/'.$thumb, $destin.
'/'.$file.
'/'.$thumb);
127 dol_move($origin.
'/'.$file, $destin.
'/'.$file);
Class to manage products or services.
dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array())
Move a file into another name.
dol_is_file($pathoffile)
Return if path is a file.
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_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
migrate_product_photospath($product)
Migrate file from old path to new one for product $product.