35 $user_name =
"Default User";
36 $sql =
"select user_pk from users where user_name='$user_name'";
39 if (pg_num_rows($result) == 0)
43 $sql =
"INSERT INTO users (user_name,user_desc,user_seed,user_pass,user_perm,user_email,root_folder_fk)
44 VALUES ('$user_name','Default User when nobody is logged in','Seed','Pass',$Perm,NULL,1);";
48 pg_free_result($result);
52 $sql =
"select user_pk from users where user_name='$user_name'";
55 if (pg_num_rows($result) == 0)
59 $Seed = random_int(0, getrandmax()) . random_int(0, getrandmax());
60 $Hash = sha1($Seed . $user_name);
61 $sql =
"INSERT INTO users (user_name,user_desc,user_seed,user_pass,user_perm,user_email,root_folder_fk)
62 VALUES ('$user_name','Default Administrator','$Seed','$Hash',$Perm,'y',1);";
66 pg_free_result($result);
69 $sql =
"select user_pk, user_name, root_folder_fk from users";
70 $UserResult = pg_query(
$PG_CONN, $sql);
78 while($UserRow = pg_fetch_assoc($UserResult))
80 $user_name = $UserRow[
'user_name'];
81 $user_pk = $UserRow[
'user_pk'];
82 $root_folder_fk = $UserRow[
'root_folder_fk'];
83 $sql =
"select group_pk from groups where group_name='$user_name'";
84 $GroupResult = pg_query(
$PG_CONN, $sql);
86 if (pg_num_rows($GroupResult) == 0)
88 pg_free_result($GroupResult);
90 $sql =
"insert into groups(group_name) values ('$user_name')";
94 $sql =
"select group_pk from groups where group_name='$user_name'";
95 $GroupResult = pg_query(
$PG_CONN, $sql);
98 $GroupRow = pg_fetch_assoc($GroupResult);
99 $group_pk = $GroupRow[
'group_pk'];
100 pg_free_result($GroupResult);
103 $sql =
"select * from group_user_member where group_fk='$group_pk' and user_fk='$user_pk'";
104 $GroupUserResult = pg_query(
$PG_CONN, $sql);
106 if (pg_num_rows($GroupUserResult) == 0)
109 $sql =
"insert into group_user_member(group_fk, user_fk, group_perm) values($group_pk, $user_pk, 1)";
113 pg_free_result($GroupUserResult);
118 $sql =
"select upload_pk from upload where user_fk='$user_pk'";
119 $UploadResult = pg_query(
$PG_CONN, $sql);
121 while($UploadRow = pg_fetch_assoc($UploadResult))
123 $upload_pk = $UploadRow[
'upload_pk'];
124 $sql =
"select perm_upload_pk from perm_upload where group_fk='$group_pk' and upload_fk='$upload_pk'";
125 $PermUploadResult = pg_query(
$PG_CONN, $sql);
127 if (pg_num_rows($PermUploadResult) == 0)
130 $sql =
"insert into perm_upload(perm, upload_fk, group_fk) values($perm_admin, $upload_pk, $group_pk)";
134 pg_free_result($PermUploadResult);
136 pg_free_result($UploadResult);
139 pg_free_result($UserResult);
143 $sql =
"delete from sysconfig where variablename = 'GlobalBrowse'";
146 pg_free_result($result);
149 $sql =
"SELECT conname from pg_constraint where conname= 'license_ref_rf_shortname_key';";
150 $conresult = pg_query(
$PG_CONN, $sql);
152 $tt = pg_num_rows($conresult);
153 if (pg_num_rows($conresult) == 0) {
154 $sql =
"ALTER TABLE license_ref ADD CONSTRAINT license_ref_rf_shortname_key UNIQUE (rf_shortname); ";
157 pg_free_result($result);
159 pg_free_result($conresult);
162 $sql =
"CREATE VIEW uploadtree_a_upload AS SELECT uploadtree_pk,upload_fk,upload_pk FROM uploadtree_a LEFT OUTER JOIN upload ON upload_fk=upload_pk;
163 DELETE FROM uploadtree_a WHERE uploadtree_pk IN (SELECT uploadtree_pk FROM uploadtree_a_upload WHERE upload_pk IS NULL);
164 DROP VIEW uploadtree_a_upload;";
167 pg_free_result($result);
169 $sql =
"SELECT conname from pg_constraint where conname= 'uploadtree_a_upload_fk_fkey';";
170 $conresult = pg_query(
$PG_CONN, $sql);
172 if (pg_num_rows($conresult) == 0) {
173 $sql =
"ALTER TABLE uploadtree_a ADD CONSTRAINT uploadtree_a_upload_fk_fkey FOREIGN KEY (upload_fk) REFERENCES upload (upload_pk) ON DELETE CASCADE; ";
176 pg_free_result($result);
178 pg_free_result($conresult);
183 $command =
"$MODDIR/nomos/agent/nomos -V";
184 $version = exec($command, $out, $return_var);
185 if (0 == $return_var)
187 $pattern =
'/r\((\w+)\)/';
188 preg_match($pattern, $version, $matches);
193 if (empty($matches[1]) || (5 > strlen($matches[1]) && $matches[1] <= $version230)) {
194 require_once(
"$LIBEXECDIR/fo_mapping_license.php");
195 print
"Rename license in $LIBEXECDIR\n";
202 print
"Clear out the report cache.\n";
203 $sql =
"DELETE FROM report_cache;";
206 pg_free_result($result);
Contains the constants and helpers for authentication of user.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Migrate_21_22($Verbose)
Create new groups, group_user_member, perm_upload and perm_folder records to support 2....
renameLicenses21to22($verbose)
Create map of old_shortname to new_shortname for 2.1 to 2.2 and call renameLicenses.
#define PERM_ADMIN
Administrator.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN