#!/usr/bin/php . // Copyright © 2007-2014 Erwan Briand // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, version 3 only. // // This program 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 Affero General Public // License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . set_time_limit(0); // Find were we are $base = dirname(__FILE__); $whereis = '/scripts/miscellaneous'; $length = -mb_strlen($whereis); if (mb_substr($base, $length, mb_strlen($base)) == $whereis) { // Set the CodingTeam basedir $basedir = mb_substr($base, 0, $length); define('CT_BASEDIR', $basedir); require($basedir.'/inc/globalFunctions.php'); // Check if the configuration file exist if (!file_exists($basedir.'/inc/codingteam.cfg')) die ('There are no configuration file. CodingTeam cannot start.'); // Check if the configuration file is well formed $xml = new DomDocument(); $xml->load($basedir.'/inc/codingteam.cfg'); if (!$xml->schemaValidate($basedir.'/inc/codingteam-conf.xsd')) exit('XMPP NOTIFICATIONS SCRIPT FAILED'); // Import configuration $xml = simplexml_load_file($basedir.'/inc/codingteam.cfg'); $db_type = $xml->db->type; $db_hostname = $xml->db->hostname; $db_database = $xml->db->database; $db_username = $xml->db->username; $db_password = $xml->db->password; // Database connection require($basedir.'/inc/classes/db.php'); $ct_db = new Database($db_type, $db_hostname, $db_database, $db_username, $db_password); $cfg = getClass('config', $ct_db); $notifs_allowed = $cfg->get('jabber', 'allow-notifications'); if (!$notifs_allowed) exit('XMPP NOTIFICATIONS DISABLED'); $notifs = getClass('notifications', $ct_db); $notifs->periodic_send(); } ?>