Esempio n. 1
0
        //
        //	Change some defaults in the template file
        //
        //$contents=str_replace('<domain>',$sys_default_domain,$contents);
        //$contents=str_replace('<project_description>',$g->getDescription(),$contents);
        //$contents=str_replace('<project_name>',$g->getPublicName(),$contents);
        //$contents=str_replace('<group_id>',$g->getID(),$contents);
        //$contents=str_replace('<group_name>',$g->getUnixName(),$contents);
        //
        //	Write the file back out to the project home dir
        //
        $fw = fopen($groupdir_prefix . "/" . $group . "/htdocs/index.php", 'w');
        fwrite($fw, $contents);
        fclose($fw);
    }
    /*$resgroupadmin=db_query("SELECT u.user_name FROM users u,user_group ug,groups g
    		WHERE u.user_id=ug.user_id 
    		AND ug.group_id=g.group_id 
    		AND g.unix_group_name='$group'
    		AND ug.admin_flags='A'
    		AND u.status='A'");
    	if (!$resgroupadmin || db_numrows($resgroupadmin) < 1) {
    		//group has no members, so cannot create dir
    	} else {
    		$user=db_result($resgroupadmin,0,'user_name');
    		system("chown -R $user:$group $groupdir_prefix/$group");
    	}*/
    system("chown -R {$sys_apache_user}:{$sys_apache_group} {$groupdir_prefix}/{$group}");
}
cron_entry(25, $err);
Esempio n. 2
0
}
function add_svn_mail_to_repository($unix_group_name, $repos)
{
    global $sys_lists_host, $file_owner, $sys_plugins_path;
    if (file_exists($repos . '/hooks/post-commit')) {
        $FOut = fopen($repos . '/hooks/post-commit', "a+");
    } else {
        $FOut = fopen($repos . '/hooks/post-commit', "w");
        $Line = '#!/bin/sh' . "\n";
        // add this line to first line or else the script fails
    }
    if ($FOut) {
        $Line .= '
#begin added by svncommitemail
php ' . $sys_plugins_path . '/svncommitemail/bin/commit-email.php ' . $repos . ' "$2" ' . $unix_group_name . '-commits@' . $sys_lists_host . '
#end added by svncommitemail';
        fwrite($FOut, $Line);
        `chmod +x {$repos}'/hooks/post-commit'`;
        `chmod 700 {$repos}'/hooks/post-commit'`;
        `chown {$file_owner} {$repos}'/hooks/post-commit'`;
        fclose($FOut);
    }
}
if ($one_repository) {
    passthru("cd {$repos_co} && {$svn_path}/svn commit -m\"\"");
}
system("chown {$file_owner} -R {$svn}");
#system("cd $svn/ && find -type d -exec chmod 700 {} \;");
#system("cd $svn/ && find -type f -exec chmod 600 {} \;");
cron_entry(21, $err);
Esempio n. 3
0
                        $debug_info .= 'Group ID: ' . $group->getID() . "\n";
                        if ($group->getID() != $last_group) {
                            echo $group->getPublicName() . ":\n";
                        }
                        if ($projectGroup->getID() != $last_projectgroup) {
                            echo $projectGroup->getName() . ":\n";
                        }
                        echo html_entity_decode($task->getSummary()) . ":\n";
                        echo '***' . ($now > $task->getEndDate() ? 'overdue' : "due {$end_date}") . "***\n";
                        echo util_make_url('/pm/task.php?func=detailtask&project_task_id=' . $task->getID() . '&group_id=' . $group->getID() . '&group_project_id=' . $projectGroup->getID());
                        echo "\n\n";
                        $last_group = $group->getID();
                        $last_projectgroup = $projectGroup->getID();
                        $valid_tasks++;
                    }
                }
                $debug_info .= "------------\n";
            }
            $messagebody = ob_get_contents();
            ob_end_clean();
            if ($valid_tasks > 0) {
                util_send_message($email, $subject, $messagebody);
            }
            /* else {
            				echo $debug_info."\n";
            			}*/
        }
    }
}
cron_entry(22, $err);
Esempio n. 4
0
        // Do yesterday
        $local_time = localtime();
        // Start at midnight last night.
        $day_end = gmmktime(0, 0, 0, $local_time[4] + 1, $local_time[3], $local_time[5]);
        // go until midnight yesterday.
        $day_begin = $day_end - 86400;
        $rollback = process_day($day_begin, $day_end);
    }
}
if ($rollback) {
    db_rollback();
} else {
    db_commit();
}
// lenp Not sure about this...
cron_entry(24, $err);
function process_day($day_begin = 0, $day_end = 0)
{
    global $err;
    global $pluginid;
    global $svnroot;
    global $svn_bin;
    global $start_time;
    global $end_time;
    global $date_key;
    global $time_ok;
    global $last_time;
    global $user_list;
    global $usr_adds, $usr_deletes, $usr_updates, $adds, $deletes, $updates, $commits;
    $start_time = $day_begin;
    $end_time = $day_end;
function send_pending_tracker_items_mail()
{
    /* first, get all the items that are considered overdue */
    $time = time();
    $sql = 'SELECT artifact_id, submitted_by, group_id, assigned_to, summary,  details, description,  assigned_realname, submitted_realname, status_name, category_name, group_name, group_artifact_id, open_date	FROM artifact_vw a NATURAL JOIN artifact_group_list agl	WHERE (agl.due_period+a.open_date) < ' . $time . ' AND	a.status_id=1';
    $res = db_query($sql);
    for ($tmp = 0; $tmp < db_numrows($res); $tmp++) {
        $realopendate = date(_('Y-m-d H:i'), db_result($res, $tmp, 'open_date'));
        $status_name = db_result($res, $tmp, 'status_name');
        $details = db_result($res, $tmp, 'detail');
        $summary = db_result($res, $tmp, 'summary');
        $users = '(' . db_result($res, $tmp, "submitted_by") . ',' . db_result($res, $tmp, "assigned_to") . ')';
        $hyperlink = util_make_url('/tracker/index.php?func=detail&aid=' . db_result($res, $tmp, "artifact_id") . '&group_id=' . db_result($res, $tmp, "group_id") . '&atid=' . db_result($res, $tmp, "group_artifact_id"));
        $artifact = db_result($res, $tmp, "artifact_id");
        $opendate = db_result($res, $tmp, "open_date");
        /* now, get all the users */
        $sql2 = 'select * from users where user_id in ' . $users . ' and user_id>100';
        $userres = db_query($sql2);
        for ($usercount = 0; $usercount < db_numrows($userres); $usercount++) {
            $mailto = db_result($userres, $usercount, "email");
            $language = db_result($userres, $usercount, "language");
            setup_gettext_from_language_id($language);
            $subject = _('Pending tracker items notification');
            $messagebody = stripcslashes(sprintf(_('This mail is sent to you to remind you of pending/overdue tracker items. The item #%1$s is pending:
Summary: %3$s
Status: %5$s
Open Date:%6$s
Assigned To: %7$s
Submitted by: %8$s
Details: %9$s


Click here to visit the item: %4$s'), $artifact, $opendate, $summary, $hyperlink, $status_name, $realopendate, db_result($res, $tmp, 'assigned_realname'), db_result($res, $tmp, 'submitted_realname'), db_result($res, $tmp, 'details')));
            /* and finally send the email */
            util_send_message($mailto, $subject, $messagebody);
        }
    }
    cron_entry(19, db_error());
}
Esempio n. 6
0
$sql = "INSERT INTO project_sums_agg ";
if ($sys_database_type == 'mysql') {
    $sql .= "SELECT forum_group_list.group_id,'fmsg' AS type, count(forum.msg_id) AS count ";
} else {
    $sql .= "SELECT forum_group_list.group_id,'fmsg'::text AS type, count(forum.msg_id) AS count ";
}
$sql .= "\n\tFROM forum,forum_group_list \n\tWHERE forum.group_forum_id=forum_group_list.group_forum_id \n\tAND forum_group_list.is_public=1\n\tGROUP BY group_id,type;";
$res = db_query($sql);
$err .= db_error();
/*
	Forum count
*/
$sql = "INSERT INTO project_sums_agg ";
if ($sys_database_type == 'mysql') {
    $sql .= "SELECT group_id,'fora' AS type, count(*) AS count ";
} else {
    $sql .= "SELECT group_id,'fora'::text AS type, count(*) AS count ";
}
$sql .= "\n\tFROM forum_group_list \n\tWHERE is_public=1\n\tGROUP BY group_id,type;";
$res = db_query($sql);
$err .= db_error();
db_commit();
$err .= db_error();
if ($sys_database_type != 'mysql') {
    db_query("VACUUM ANALYZE project_sums_agg;");
    if (db_error()) {
        $err .= "Error: " . db_error();
    }
}
cron_entry(3, $err);
Esempio n. 7
0
//
$res = db_query("SELECT user_name,email FROM users WHERE status = 'A' AND email != ''");
$err .= db_error();
$rows = db_numrows($res);
for ($i = 0; $i < $rows; $i++) {
    $user = db_result($res, $i, 0);
    $email = db_result($res, $i, 1);
    if (array_key_exists($user, $aliases)) {
        // A GForge alias was found outside the markers
        unset($aliases[$user]);
    }
    $gforge_aliases[$user] = $email;
}
//
// Now write all the aliases
//
$fh = fopen("/etc/aliases" . FILE_EXTENSION, "w");
foreach ($aliases as $aliasname => $alias) {
    fwrite($fh, "{$aliasname}: \t\t {$alias}\n");
}
fputs($fh, "#GFORGEBEGIN\n");
foreach ($gforge_aliases as $aliasname => $alias) {
    fwrite($fh, "{$aliasname}: \t\t {$alias}\n");
}
fputs($fh, "#GFORGEEND\n");
fclose($fh);
db_free_result($res);
$ok = `newaliases`;
$err .= $ok;
cron_entry(17, $err);
Esempio n. 8
0
        }
        system("mv -f {$cvsdir_prefix}/{$deleted_group_name}/ {$cvsdir_prefix}/.deleted/");
        system("chown -R root:root {$cvsdir_prefix}/.deleted/{$deleted_group_name}");
        system("chmod -R o-rwx {$cvsdir_prefix}/.deleted/{$deleted_group_name}");
        $res9 = db_query("UPDATE deleted_groups set isdeleted = 1 WHERE unix_group_name = '{$deleted_group_name}';");
        $err .= db_error();
    }
}
/*
	Loop through and create/update each repository for every project 
	that uses SCMCVS plugin
*/
$err = "";
if (is_dir($cvsdir_prefix)) {
    update_cvs_repositories();
} else {
    if (is_file($cvsdir_prefix)) {
        $err .= "{$cvsdir_prefix} exists but is a file\n";
        exit;
    } else {
        if (mkdir($cvsdir_prefix)) {
            //need to update group permissions using chmod
            update_cvs_repositories();
        } else {
            $err .= "unable to make {$cvsdir_prefix} directory\n";
            exit;
        }
    }
}
cron_entry(13, $err);
Esempio n. 9
0
    $gforge_lines_group[] = $line;
}
// Generate the contents of /etc/group
$group_contents = implode("\n", $unmanaged_lines_group);
$group_contents .= "\n";
$group_contents .= "#GFORGEBEGIN\n";
$group_contents .= implode("\n", $gforge_lines_group);
$group_contents .= "\n#GFORGEEND\n";
/*************************************************************************
 * Step 4: Write all the data
 *************************************************************************/
// Write /etc/passwd
$passwd_file = fopen("/etc/passwd" . FILE_EXTENSION, "w");
if ($passwd_file) {
    fwrite($passwd_file, $passwd_contents);
    fclose($passwd_file);
}
// Write /etc/shadow
$shadow_file = fopen("/etc/shadow" . FILE_EXTENSION, "w");
if ($shadow_file) {
    fwrite($shadow_file, $shadow_contents);
    fclose($shadow_file);
}
// Write /etc/group
$group_file = fopen("/etc/group" . FILE_EXTENSION, "w");
if ($group_file) {
    fwrite($group_file, $group_contents);
    fclose($group_file);
}
cron_entry(16, $err);
Esempio n. 10
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */
require dirname(__FILE__) . '/../www/env.inc.php';
require $gfwww . 'include/squal_pre.php';
require $gfcommon . 'include/cron_utils.php';
$err = '';
#
#    aggregate the ratings
#
db_begin();
$rel = db_query("DELETE FROM survey_rating_aggregate;");
$err .= db_error();
$query = "INSERT INTO survey_rating_aggregate SELECT type,id,avg(response),count(*) FROM survey_rating_response GROUP BY type,id;";
$rel = db_query($query);
db_commit();
if (db_error()) {
    $err .= "Error: " . db_error();
}
cron_entry(9, $err);
Esempio n. 11
0
            echo date('Y-m-d', $day) . "\n";
            db_begin();
            if (process_day($day, $day + 86400)) {
                db_rollback();
            } else {
                db_commit();
            }
        }
    } else {
        $local_time = localtime();
        ## Start at midnight last night.
        $day_end = gmmktime(0, 0, 0, $local_time[4] + 1, $local_time[3], $local_time[5]);
        //	$day_end = gmmktime( 0, 0, 0, (gmtime( time() ))[3,4,5] );
        ## go until midnight yesterday.
        $day_begin = $day_end - 86400;
        //	$day_begin = timegm( 0, 0, 0, (gmtime( time() - 86400 ))[3,4,5] );
        db_begin();
        if (process_day($day_begin, $day_end)) {
            db_rollback();
        } else {
            db_commit();
        }
    }
}
if ($rollback) {
    db_rollback();
} else {
    db_commit();
}
cron_entry(14, $err);
Esempio n. 12
0
        $perm =& $project->getPermission($user);
        if ($perm->isCVSWriter()) {
            $result .= $user->getUnixName() . "= rw\n";
        } else {
            if ($perm->isCVSReader()) {
                $result .= $user->getUnixName() . "= r\n";
            }
        }
    }
    if ($project->enableAnonSCM()) {
        $result .= "anonsvn= r\n";
        $result .= "* = r\n";
    }
    $result .= "\n";
    return $result;
}
function writeAccessFile($fileName, $access_file_content)
{
    $myFile = fopen($fileName, "w");
    fwrite($myFile, $access_file_content);
    fclose($myFile);
}
function writePasswordFile($fileName, $password_file_contents)
{
    $myFile = fopen($fileName, "w");
    fwrite($myFile, $password_file_contents);
    fwrite($myFile, 'anonsvn:$apr1$Kfr69/..$J08mbyNpD81y42x7xlFDm.' . "\n");
    fclose($myFile);
}
cron_entry(26, $err);
Esempio n. 13
0
function m_exit($mess = '')
{
    global $err;
    if (!cron_remove_lock(__FILE__)) {
        $err .= "Could not remove lock\n";
    }
    if (!cron_entry(6, $mess . $err)) {
        # rely on crond to report the error
        echo "cron_entry error: " . db_error() . "\n";
    }
    exit;
}
Esempio n. 14
0
 * GForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
require dirname(__FILE__) . '/../www/env.inc.php';
require $gfwww . 'include/squal_pre.php';
require $gfcommon . 'include/cron_utils.php';
require $gfcommon . 'reporting/ReportSetup.class.php';
$err = '';
$report = new ReportSetup();
if ($report->isError()) {
    $err .= $report->getErrorMessage();
}
db_begin();
if (!$report->dailyData()) {
    $err .= $report->getErrorMessage();
}
db_commit();
$err .= "Done: " . date('Ymd H:i') . ' - ' . db_error();
cron_entry(20, $err);
    $sql .= "SELECT ranking,100-(100*((ranking-1)/{$counts})),group_id ";
} else {
    $sql .= "SELECT ranking,100-(100*((ranking::float-1)/{$counts})),group_id ";
}
$sql .= "\nFROM project_metric_weekly_tmp1\nORDER BY ranking ASC";
$rel = db_query($sql);
if (!$rel) {
    $err .= "\n\n***ERROR: {$sql}\n\n" . db_error();
}
//
//	Now archive the metric
//
db_query("DELETE FROM stats_project_metric WHERE month='{$this_year}{$this_month}' AND day='{$this_day}'");
$sql = "INSERT INTO stats_project_metric (month,day,group_id,ranking,percentile) ";
if ($sys_database_type == 'mysql') {
    $sql .= "SELECT '{$this_year}{$this_month}', '{$this_day}',group_id,ranking,percentile ";
} else {
    $sql .= "SELECT '{$this_year}{$this_month}'::int, '{$this_day}'::int,group_id,ranking,percentile ";
}
$sql .= "\n\tFROM project_weekly_metric";
$rel = db_query($sql);
if (!$rel) {
    $err .= "\n\n***ERROR: {$sql}\n\n" . db_error();
}
$err .= db_error();
db_drop_sequence_if_exists("project_metric_weekly_seq");
db_drop_table_if_exists("project_counts_weekly_tmp");
db_drop_table_if_exists("project_metric_weekly_tmp1");
db_drop_sequence_if_exists("project_metric_week_ranking_seq");
cron_entry(8, $err);
Esempio n. 16
0
        }
        chdir($sys_scm_root_path);
        while (false !== ($file = readdir($handle))) {
            chdir($sys_scm_root_path);
            if ($file != "." && $file != ".." && is_dir($file) && $file != "cvs-locks" && $file != '.deleted') {
                if ($verbose) {
                    echo "Creating {$sys_scm_tarballs_path}/{$file}-{$scmname}.tar.gz\n";
                }
                mkdir("{$sys_scm_tarballs_path}/{$file}");
                chdir($sys_scm_root_path);
                exec("{$hot_backup} {$file} {$sys_scm_tarballs_path}/{$file} 2>&1", $output);
                chdir($sys_scm_tarballs_path);
                exec("tar czf {$sys_scm_tarballs_path}/{$file}-{$scmname}.tar.gz.new {$file} 2>&1", $output);
                if (is_file("{$sys_scm_tarballs_path}/{$file}-{$scmname}.tar.gz.new")) {
                    rename("{$sys_scm_tarballs_path}/{$file}-{$scmname}.tar.gz.new", "{$sys_scm_tarballs_path}/{$file}-{$scmname}.tar.gz");
                    rename("{$sys_scm_tarballs_path}/{$file}", "{$sys_scm_tarballs_path}/{$file}.done_by_cron");
                    system("rm -rf {$sys_scm_tarballs_path}/{$file}.done_by_cron");
                }
            }
        }
        closedir($handle);
    }
    if ($output) {
        $err = implode("\n", $output);
    }
    if (empty($err)) {
        $err = 'SCM tarballs generated';
    }
}
cron_entry(19, $err);
Esempio n. 17
0
    //number of children of this trove_cat
    $rows = count(@$parent_list[$cat_id]);
    for ($i = 0; $i < $rows; $i++) {
        $count += get_trove_sub_projects($parent_list[$cat_id][$i]);
    }
    $sum_totals["{$cat_id}"] = $count;
    return $count;
}
//start the recursive function at the top of the trove tree
$res2 = db_query("SELECT trove_cat_id FROM trove_cat WHERE parent=0", -1, 0, SYS_DB_TROVE);
for ($i = 0; $i < db_numrows($res2); $i++) {
    get_trove_sub_projects(db_result($res2, $i, 0));
}
db_begin(SYS_DB_TROVE);
db_query("DELETE FROM trove_treesums", -1, 0, SYS_DB_TROVE);
$err .= db_error(SYS_DB_TROVE);
//$err .= "<table>";
while (list($k, $v) = each($sum_totals)) {
    $res = db_query("INSERT INTO trove_treesums (trove_cat_id,subprojects) \n\t\tVALUES ({$k},{$v})", -1, 0, SYS_DB_TROVE);
    if (!$res || db_affected_rows($res) != 1) {
        $err .= db_error(SYS_DB_TROVE);
    }
    //	$err .= "<tr><td>$k</td><td>$v</td></tr>\n";
}
//$err .= "</table>";
db_commit(SYS_DB_TROVE);
if (db_error(SYS_DB_TROVE)) {
    $err .= "Error: " . db_error(SYS_DB_TROVE);
}
cron_entry(5, $err);
Esempio n. 18
0
require dirname(__FILE__) . '/../../env.inc.php';
require_once $gfwww . 'include/squal_pre.php';
require $gfcommon . 'include/cron_utils.php';
$err = '';
$res = db_query("SELECT user_name,user_id,authorized_keys \n\tFROM users \n\tWHERE authorized_keys != ''\n\tAND status='A'");
for ($i = 0; $i < db_numrows($res); $i++) {
    $ssh_key = db_result($res, $i, 'authorized_keys');
    $username = db_result($res, $i, 'user_name');
    $dir = $homedir_prefix . '/' . $username;
    if (util_is_root_dir($dir)) {
        $err .= "Error! homedir_prefix/username Points To Root Directory!";
        continue;
    }
    $uid = db_result($res, $i, 'user_id');
    $ssh_key = str_replace('###', "\n", $ssh_key);
    $uid += 1000;
    $ssh_dir = "{$homedir_prefix}/{$username}/.ssh";
    if (!is_dir($ssh_dir)) {
        mkdir($ssh_dir, 0755);
    }
    $h8 = fopen("{$ssh_dir}/authorized_keys", "w");
    fwrite($h8, '# This file is automatically generated from your account settings.' . "\n");
    fwrite($h8, $ssh_key);
    fclose($h8);
    system("chown {$username}:users {$homedir_prefix}/{$username}");
    system("chown {$username}:users {$ssh_dir}");
    system("chmod 0644 {$ssh_dir}/authorized_keys");
    system("chown {$username}:users {$ssh_dir}/authorized_keys");
}
cron_entry(15, $err);
Esempio n. 19
0
 * This file is part of GForge.
 *
 * GForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */
require dirname(__FILE__) . '/../www/env.inc.php';
require $gfwww . 'include/squal_pre.php';
require $gfcommon . 'include/cron_utils.php';
$err = '';
$today_formatted = date('Ymd', time() - 30 * 60 * 60 * 24);
$sql = '';
db_begin();
$sql = "DELETE FROM activity_log WHERE day < {$today_formatted}";
$err .= $sql;
$rel = db_query($sql);
$err .= db_error();
db_commit();
$err .= " Done: " . date('Ymd H:i') . ' - ' . db_error();
cron_entry(10, $err);
Esempio n. 20
0
//
//	insert the number of developers per project into history table
//
$err .= "\n\nBeginning stats_project_developers " . date('Ymd H:i:s', time());
$rel = db_query("DELETE FROM stats_project_developers WHERE month='{$year}{$month}' AND day='{$day}'");
$err .= db_error();
$sql = "INSERT INTO stats_project_developers (month,day,group_id,developers) ";
if ($sys_database_type == 'mysql') {
    $sql .= "SELECT '{$year}{$month}' AS month,'{$day}' AS day,group_id,count(*) AS count";
} else {
    $sql .= "SELECT '{$year}{$month}'::int AS month,'{$day}'::int AS day,group_id,count(*) AS count";
}
$sql .= "\n\t\tFROM user_group \n\t\tGROUP BY month,day,group_id";
$rel = db_query($sql);
$err .= db_error();
db_commit();
$err .= db_error();
//
//	populate stats_site table
//
$err .= "\n\nBeginning stats_site " . date('Ymd H:i:s', time());
include 'cronjobs/stats_site.inc';
site_stats_day($year, $month, $day);
//
//	populate stats_project table
//
$err .= "\n\nBeginning stats_project " . date('Ymd H:i:s', time());
include 'cronjobs/stats_projects.inc';
project_stats_day($year, $month, $day);
cron_entry(11, $err);
Esempio n. 21
0
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */
require dirname(__FILE__) . '/../www/env.inc.php';
require $gfwww . 'include/squal_pre.php';
require $gfcommon . 'include/cron_utils.php';
$err = '';
//
//	PG 7.1 and earlier
//
//$res = db_query("VACUUM ANALYZE;");
//
//	PG 7.2 and 7.3
//
if ($sys_database_type != 'mysql') {
    $res = db_query("VACUUM FULL ANALYZE;");
    if (!$res) {
        $err .= "Error on DB1: " . db_error();
    }
}
cron_entry(12, $err);
//
//delete mailing lists
//
$res = db_query("SELECT mailing_list_name FROM deleted_mailing_lists WHERE isdeleted = 0;");
$err .= db_error();
$rows = db_numrows($res);
for ($k = 0; $k < $rows; $k++) {
    $deleted_mail_list = db_result($res, $k, 'mailing_list_name');
    exec($sys_path_to_mailman . "/bin/rmlist -a {$deleted_mail_list}", $output);
    $success = false;
    foreach ($output as $line) {
        // Mailman 2.1.x
        if (preg_match("/to finish removing/i", $line)) {
            $success = true;
            break;
        }
        // Mailman 2.1.0
        if (preg_match("/removing list info/i", $line)) {
            $success = true;
            break;
        }
    }
    if ($success) {
        $res1 = db_query("UPDATE deleted_mailing_lists SET isdeleted = 1 WHERE mailing_list_name = '{$deleted_mail_list}'");
        $err .= db_error();
    } else {
        $err .= "Could not remove the list {$deleted_mail_list} \n";
    }
}
cron_entry(18, $err);
Esempio n. 23
0
$then = time() - 3600;
db_query("DELETE FROM groups WHERE status='I' and register_time < '{$then}'");
$err .= db_error();
#one week ago for users
$then = time() - 604800;
db_query("DELETE FROM user_group WHERE EXISTS (SELECT user_id FROM users " . "WHERE status='P' and add_date < '{$then}' AND users.user_id=user_group.user_id)");
$err .= db_error();
db_query("DELETE FROM users WHERE status='P' and add_date < '{$then}'");
$err .= db_error();
#30 days ago for sessions
$then = time() - 30 * 60 * 60 * 24;
db_query("DELETE FROM user_session WHERE time < '{$then}'");
$err .= db_error();
#one month ago for preferences
$then = time() - 604800 * 4;
db_query("DELETE FROM user_preferences WHERE set_date < '{$then}'");
$err .= db_error();
#3 weeks ago for jobs
$then = time() - 604800 * 3;
db_query("UPDATE people_job SET status_id = '3' where post_date < '{$then}'");
$err .= db_error();
#1 day ago for form keys
$then = time() - 60 * 60 * 24;
db_query("DELETE FROM form_keys WHERE creation_date < '{$then}'");
$err .= db_error();
db_commit();
if (db_error()) {
    $err .= "Error: " . db_error();
}
cron_entry(7, $err);
Esempio n. 24
0
 */
/** This script will automatically dump Mediawiki databases to an XML file.
 *
 * It is intended to be started in a cronjob.
 */
require_once dirname(__FILE__) . '/../../../www/env.inc.php';
require_once $gfcommon . 'include/pre.php';
require_once $gfcommon . 'include/cron_utils.php';
$src_path = forge_get_config('src_path', 'mediawiki');
$master_path = forge_get_config('master_path', 'mediawiki');
// Get all projects that use the mediawiki plugin
$project_res = db_query_params("SELECT g.unix_group_name,g.group_id 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"));
if (!$project_res) {
    $err = "Error: Database Query Failed: " . db_error();
    cron_debug($err);
    cron_entry(23, $err);
    exit;
}
// Loop over all projects that use the plugin
while ($row = db_fetch_array($project_res)) {
    $project = $row['unix_group_name'];
    $project_id = $row['group_id'];
    $dump_file = forge_get_config('data_path') . "/plugins/mediawiki/dumps/{$project}.xml";
    $ra = RoleAnonymous::getInstance();
    if ($ra->hasPermission('plugin_mediawiki_read', $project_id)) {
        cron_debug("Dumping {$project}...");
        $mwwrapper = forge_get_config('source_path') . "/plugins/mediawiki/bin/mw-wrapper.php";
        $tmp = tempnam(forge_get_config('data_path') . "/plugins/mediawiki/dumps/", "tmp");
        system("{$mwwrapper} {$project} dumpBackup.php --current --quiet > {$tmp}");
        chmod($tmp, 0644);
        rename($tmp, $dump_file);
Esempio n. 25
0
//
//  main site page views by month
//
db_begin(SYS_DB_STATS);
$err .= "\n\nBeginning stats_site_pages_by_month: " . date('Y-m-d H:i:s', time());
$rel = db_query("DELETE FROM stats_site_pages_by_month;", -1, 0, SYS_DB_STATS);
$err .= db_error(SYS_DB_STATS);
$rel = db_query("INSERT INTO stats_site_pages_by_month\nselect month,sum(site_page_views) as site_page_views\n    from stats_site_pages_by_day group by month;\n", -1, 0, SYS_DB_STATS);
if (!$rel) {
    $err .= "ERROR IN stats_site_pages_by_month";
}
$err .= db_error(SYS_DB_STATS);
db_commit(SYS_DB_STATS);
if ($sys_database_type != 'mysql') {
    db_query("VACUUM ANALYZE stats_site_pages_by_month;", -1, 0, SYS_DB_STATS);
}
//
//  sitewide stats in last 30 days
//
db_begin(SYS_DB_STATS);
$err .= "\n\nBeginning stats_site_months: " . date('Y-m-d H:i:s', time());
$rel = db_query("DELETE FROM stats_site_months;", -1, 0, SYS_DB_STATS);
$err .= db_error(SYS_DB_STATS);
$rel = db_query("INSERT INTO stats_site_months\nSELECT spm.month,\n\tsspbm.site_page_views,\n\tSUM(spm.downloads) AS downloads,\n\tSUM(spm.subdomain_views) AS subdomain_views,\n\tSUM(spm.msg_posted) AS msg_posted,\n\tSUM(spm.bugs_opened) AS bugs_opened,\n\tSUM(spm.bugs_closed) AS bugs_closed,\n\tSUM(spm.support_opened) AS support_opened,\n\tSUM(spm.support_closed) AS support_closed,\n\tSUM(spm.patches_opened) AS patches_opened,\n\tSUM(spm.patches_closed) AS patches_closed,\n\tSUM(spm.artifacts_opened) AS artifacts_opened,\n\tSUM(spm.artifacts_closed) AS artifacts_closed,\n\tSUM(spm.tasks_opened) AS tasks_opened,\n\tSUM(spm.tasks_closed) AS tasks_closed,\n\tSUM(spm.help_requests) AS help_requests,\n\tSUM(spm.cvs_checkouts) AS cvs_checkouts,\n\tSUM(spm.cvs_commits) AS cvs_commits,\n\tSUM(spm.cvs_adds) AS cvs_adds\n\tFROM stats_project_months spm, stats_site_pages_by_month sspbm\n\tWHERE spm.month=sspbm.month\n\tGROUP BY spm.month,sspbm.site_page_views\n\tORDER BY spm.month ASC;\n", -1, 0, SYS_DB_STATS);
$err .= db_error(SYS_DB_STATS);
db_commit(SYS_DB_STATS);
if ($sys_database_type != 'mysql') {
    db_query("VACUUM ANALYZE stats_site_months;", -1, 0, SYS_DB_STATS);
}
cron_entry(4, $err);