FOSSology  4.4.0
Open Source License Compliance by Open Source Software
mk_fmdirs.php
1 #!/usr/bin/php
2 
3 <?php
4 /*
5  mk_fmdirs.php
6  SPDX-FileCopyrightText: © 2007 Hewlett-Packard Development Company, L.P.
7 
8  SPDX-License-Identifier: GPL-2.0-only
9 */
10 
20 // NOTE: This code is not really used anymore !!!!!!!!!!!!!!!!!!!!!!
21 
22 // For now, assume previous process has determined if the archive has changed
23 // and just calls this routine to do the load. That is, this routine is
24 // not expected to determine if the archive has changed.
25 
26 //issues:
27 // what to do if all the data is not present. For example, osrb projects
28 // may not have a version, rank, or other data that is there for projects
29 // from freshmeat. Talk with Bob, use some sort of 'default' if there
30 // is no data.
31 
32 # 1. process parameter(s) and sanity check.
33 # 2. connect to db
34 # 3. If folder doesn't exist, create it.
35 # is it possible to make this recursive and do subfolders as well?
36 # 4. After all needed folders are created,
37 # things are a bit fuzzy below....
38 # 5. create upload record.
39 # 6. unpack
40 # 7. schedule nomos...
41 # What else?
42 /*
43  * general process is: createfolders, then use createfoldercontents to
44  * associate folders with each other....
45  */
46 
47 require_once("FIXMETOBERELATIVE/pathinclude.php");
48 /* the items below no longer exist, my this code is old.... */
49 require_once("$PHPDIR/webcommon.h.php");
50 require_once("$PHPDIR/jobs.h.php");
51 require_once("$PHPDIR/db_postgres.h.php");
52 
53 // if you do it yourself....use the lib...
54 #$_pg_conn = pg_connect(str_replace(";", " ",
55 # file_get_contents("{$SYSCONFDIR}/{$PROJECT}/Db.conf")));
56 
57 $path = "{$SYSCONFDIR}/$PROJECT}/Db.conf";
58 $alpha_buckets = array('a-c',
59  'd-f',
60  'g-i',
61  'j-l',
62  'm-o',
63  'p-r',
64  's-u',
65  'v-z'
66  );
67 db_init($path);
68 
69 if (!$_pg_conn) {
70  echo "ERROR: could not connect to DB\n";
71  exit(1);
72 }
73 
74 /*
75  * Steps are:
76  * 1. create top folder
77  * using value returned from cratefolder,
78  * 2. use that in a loop to create the other folders.
79  * 3. Other folders are created with
80  * createrfolder, and then associated with parent folder with
81  * createfoldercontents.
82  */
83 
84 
85 $sql = 'select users.root_folder_fk from users';
86 
87 // who is my parent?
88 $pfolder4user = db_query1($sql);
89 
90 // Create top level folder 'Freshmeat'
91 $f_pk = createfolder($pfolder4user, 'Freshmeat',
92  "Top folder for FM Archives");
93 
94 $sql_fm =
95  "select folder_pk, folder_name from folder where folder_name='Freshmeat'";
96 $fm_pk = db_query1($sql_fm);
97 
98 // Create the alpha bucket folders and associate them with the
99 // Freshmeat folder.
100 for ($num=0; $num < count($alpha_buckets); $num++){
101 #echo "arraychunks: {$alpha_buckets[$num]}\n";
102 
103 $folder_pk = createfolder(
104  $fm_pk, "{$alpha_buckets[$num]}", "Holds Freshmeat archives");
105 
106 $fold_cont_pk = createfoldercontents($fm_pk, $folder_pk, 1);
107 }