4 * Copyright (C) 2010 Olaf Lenz
6 * This file is part of FusionForge.
8 * FusionForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with FusionForge; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /** This script will automatically create the image upload
24 directories for all mediawiki instances.
26 It is intended to be started in a cronjob with root permissions.
29 include dirname(__FILE__) . '/../../env.inc.php';
30 require_once $gfwww.'include/pre.php';
31 include $gfcommon.'include/cron_utils.php';
32 include $gfplugins . 'mediawiki/common/config-vars.php';
34 if (forge_get_config('enable_uploads', 'mediawiki')) {
35 $upload_dir_basename = "images";
36 $projects_path = forge_get_config('projects_path', 'mediawiki');
38 # Owner of files - apache
39 $dir_owner = forge_get_config('apache_user');
40 $dir_group = forge_get_config('apache_group');
42 # Get all projects that use the mediawiki plugin
43 $project_res = db_query_params ("SELECT g.unix_group_name from groups g, group_plugin gp, plugins p where g.group_id = gp.group_id and gp.plugin_id = p.plugin_id and p.plugin_name = $1;", array("mediawiki"));
45 $err = "Error: Database Query Failed: ".db_error();
51 # Loop over all projects that use the plugin
52 while ( $row = db_fetch_array($project_res) ) {
53 $project = $row['unix_group_name'];
54 $project_dir = "$projects_path/$project";
55 cron_debug("Checking $project...");
57 // Create the image directory if necessary
58 $upload_dir = "$project_dir/$upload_dir_basename";
59 if (!is_dir($upload_dir)) {
60 cron_debug(" Creating upload dir $upload_dir.");
61 mkdir($upload_dir, 0700);
63 cron_debug(" Upload dir $upload_dir exists.");
65 cron_debug(" Changing owner ($dir_owner), group ($dir_group) and permission (0775) of upload dir $upload_dir.");
66 chown($upload_dir, $dir_owner);
67 chgrp($upload_dir, $dir_group);
68 chmod($upload_dir, 0775);
71 cron_debug("Mediawiki uploads not enabled, quitting create-imagedirs.php!");
75 // c-file-style: "bsd"