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';
33 if (forge_get_config('enable_uploads', 'mediawiki')) {
34 $upload_dir_basename = "images";
35 $projects_path = forge_get_config('projects_path', 'mediawiki');
37 # Owner of files - apache
38 $dir_owner = forge_get_config('apache_user');
39 $dir_group = forge_get_config('apache_group');
41 # Get all projects that use the mediawiki plugin
42 $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"));
44 $err = "Error: Database Query Failed: ".db_error();
50 # Loop over all projects that use the plugin
51 while ( $row = db_fetch_array($project_res) ) {
52 $project = $row['unix_group_name'];
53 $project_dir = "$projects_path/$project";
54 cron_debug("Checking $project...");
56 // Create the image directory if necessary
57 $upload_dir = "$project_dir/$upload_dir_basename";
58 if (!is_dir($upload_dir)) {
59 cron_debug(" Creating upload dir $upload_dir.");
60 mkdir($upload_dir, 0700);
62 cron_debug(" Upload dir $upload_dir exists.");
64 cron_debug(" Changing owner ($dir_owner), group ($dir_group) and permission (0775) of upload dir $upload_dir.");
65 chown($upload_dir, $dir_owner);
66 chgrp($upload_dir, $dir_group);
67 chmod($upload_dir, 0775);
70 cron_debug("Mediawiki uploads not enabled, quitting create-imagedirs.php!");
74 // c-file-style: "bsd"