28if (!defined(
'NOSESSION')) {
29 define(
'NOSESSION',
'1');
32$sapi_type = php_sapi_name();
33$script_file = basename(__FILE__);
37if (substr($sapi_type, 0, 3) ==
'cgi') {
38 echo
"Error: You are using PHP for CGI. To execute ".$script_file.
" from command line, you must use PHP for CLI mode.\n";
43define(
'EVEN_IF_ONLY_LOGIN_ALLOWED', 1);
46require_once $path.
"../../htdocs/master.inc.php";
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/functionscli.lib.php';
48require_once DOL_DOCUMENT_ROOT.
"/user/class/user.class.php";
49require_once DOL_DOCUMENT_ROOT.
"/core/lib/files.lib.php";
62$version = DOL_VERSION;
66$hookmanager->initHooks(array(
'cli'));
73print
"***** ".$script_file.
" (".$version.
") pid=".
dol_getmypid().
" *****\n";
74dol_syslog($script_file.
" launched with arg ".join(
',', $argv));
76if (!isset($argv[1]) || $argv[1] !=
'user') {
77 print
"Usage: $script_file user\n";
81print
'--- start'.
"\n";
84if ($argv[1] ==
'user') {
87 $sql =
"SELECT rowid as uid from ".MAIN_DB_PREFIX.
"user";
88 $resql = $db->query($sql);
90 while ($obj = $db->fetch_object($resql)) {
92 print
" migrating user id=".$u->id.
" ref=".$u->ref.
"\n";
96 print
"\n sql error ".$sql;
117 $dir =
$conf->user->dir_output;
118 $origin = $dir.
'/'.
get_exdir($u->id, 2, 0, 0, $u,
'user');
119 $destin = $dir.
'/'.$u->id;
128 $handle = opendir($origin_osencoded);
129 if (is_resource($handle)) {
130 while (($file = readdir($handle)) !==
false) {
131 if ($file !=
'.' && $file !=
'..' && is_dir($origin_osencoded.
'/'.$file)) {
132 $thumbs = opendir($origin_osencoded.
'/'.$file);
133 if (is_resource($thumbs)) {
135 while (($thumb = readdir($thumbs)) !==
false) {
136 dol_move($origin.
'/'.$file.
'/'.$thumb, $destin.
'/'.$file.
'/'.$thumb);
142 dol_move($origin.
'/'.$file, $destin.
'/'.$file);
Class to manage Dolibarr users.
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.
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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
migrate_user_filespath($u)
Migrate file from old path to new one for user $u.