23 require_once(
"$MODDIR/lib/php/common-cli.php");
27 error_reporting(E_NOTICE & E_STRICT);
29 $Usage =
"Usage: " . basename($argv[0]) .
" [options] 30 --username = user name 32 --groupname = a group the user belongs to (default active group) 33 --folderId = id of folder (default root folder of user) 34 --linkFolder= create a link to this folder (id) 35 --linkUpload= create a link to this upload (id)\n";
37 $opts = getopt(
"hc:", array(
"username:",
"groupname:",
39 "password:",
"linkFolder:",
"linkUpload:"));
40 if (array_key_exists(
'h', $opts)) {
45 $user = array_key_exists(
"username", $opts) ? $opts[
"username"] :
'';
46 $group = array_key_exists(
"groupname", $opts) ? $opts[
"groupname"] :
'';
47 $passwd = array_key_exists(
"password", $opts) ? $opts[
"password"] : null;
51 $userId = $_SESSION[Auth::USER_ID] = $SysConf[
'auth'][Auth::USER_ID];
52 $groupId = $_SESSION[Auth::GROUP_ID] = $SysConf[
'auth'][Auth::GROUP_ID];
55 $folderDao = $GLOBALS[
'container']->get(
"dao.folder");
57 if (array_key_exists(
"folderId", $opts)) {
58 $folderId = $opts[
"folderId"];
60 $folderId = $folderDao->getRootFolder($userId)->getId();
63 $linkFolder = array_key_exists(
"linkFolder", $opts) ? $opts[
"linkFolder"] : null;
64 $linkUpload = array_key_exists(
"linkUpload", $opts) ? $opts[
"linkUpload"] : null;
65 if (!empty($linkFolder)) {
66 $folderDao->insertFolderContents($folderId,FolderDao::MODE_FOLDER,$linkFolder);
67 } elseif (!empty($linkUpload)) {
68 $folderDao->insertFolderContents($folderId,FolderDao::MODE_UPLOAD,$linkUpload);
70 $structure = $folderDao->getFolderStructure($folderId);
71 foreach ($structure as $folder) {
72 for ($i = 0; $i < $folder[FolderDao::DEPTH_KEY]; $i++) {
76 $theFolder = $folder[FolderDao::FOLDER_KEY];
77 echo $theFolder->getName().
' (id='.$theFolder->getId().
")\n";
account_check(&$user, &$passwd, &$group="")
check if this account is correct
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...