Example #1
0
 function end_upgrade()
 {
     require_once 'ossim_db.inc';
     $dbsock = new ossim_db();
     $db = $dbsock->connect();
     $configxml = "/etc/ossim/server/config.xml";
     $name = "Not found";
     // Check server name
     if (file_exists($configxml)) {
         $lines = file($configxml);
         foreach ($lines as $line) {
             if (preg_match("/\\<server.*name=\"([^\"]+)\"/", $line, $found)) {
                 $name = $found[1];
             }
         }
     }
     // Search in DB for name
     $sql = "SELECT * FROM server_role WHERE name=\"{$name}\"";
     if (!($rs = $db->Execute($sql))) {
         print $db->ErrorMsg();
     } elseif (!$rs->EOF) {
         // Found -> Update
         $correlate = $rs->fields['correlate'] ? "yes" : "no";
         $cross_correlate = $rs->fields['cross_correlate'] ? "yes" : "no";
         $store = $rs->fields['store'] ? "yes" : "no";
         $qualify = $rs->fields['qualify'] ? "yes" : "no";
         $resend_alarm = $rs->fields['resend_alarm'] ? "yes" : "no";
         $resend_event = $rs->fields['resend_event'] ? "yes" : "no";
         $sign = $rs->fields['sign'] ? "yes" : "no";
         $sem = $rs->fields['sem'] ? "yes" : "no";
         $sim = $rs->fields['sim'] ? "yes" : "no";
         $alarms_to_syslog = $rs->fields['alarms_to_syslog'] ? "yes" : "no";
         require_once 'classes/Config.inc';
         $conf = new Config();
         $conf->update("server_correlate", $correlate);
         $conf->update("server_cross_correlate", $cross_correlate);
         $conf->update("server_store", $store);
         $conf->update("server_qualify", $qualify);
         $conf->update("server_forward_alarm", $resend_alarm);
         $conf->update("server_forward_event", $resend_event);
         $conf->update("server_sign", $sign);
         $conf->update("server_sem", $sem);
         $conf->update("server_sim", $sim);
         $conf->update("server_alarms_to_syslog", $alarms_to_syslog);
     }
     exec("sudo /etc/init.d/ossim-server restart");
     //
     // Reload ACLS
     //
     $this->reload_acls();
     return true;
 }
function ShowChatConfigPage()
{
    global $LNG, $USER;
    $CONF = Config::getAll(NULL, 1);
    if (!empty($_POST)) {
        $config_before = array('chat_closed' => $CONF['chat_closed'], 'chat_allowchan' => $CONF['chat_allowchan'], 'chat_allowmes' => $CONF['chat_allowmes'], 'chat_allowdelmes' => $CONF['chat_allowdelmes'], 'chat_logmessage' => $CONF['chat_logmessage'], 'chat_nickchange' => $CONF['chat_nickchange'], 'chat_botname' => $CONF['chat_botname'], 'chat_channelname' => $CONF['chat_channelname']);
        $chat_allowchan = isset($_POST['chat_allowchan']) && $_POST['chat_allowchan'] == 'on' ? 1 : 0;
        $chat_allowmes = isset($_POST['chat_allowmes']) && $_POST['chat_allowmes'] == 'on' ? 1 : 0;
        $chat_allowdelmes = isset($_POST['chat_allowdelmes']) && $_POST['chat_allowdelmes'] == 'on' ? 1 : 0;
        $chat_logmessage = isset($_POST['chat_logmessage']) && $_POST['chat_logmessage'] == 'on' ? 1 : 0;
        $chat_nickchange = isset($_POST['chat_nickchange']) && $_POST['chat_nickchange'] == 'on' ? 1 : 0;
        $chat_closed = isset($_POST['chat_closed']) && $_POST['chat_closed'] == 'on' ? 1 : 0;
        $chat_channelname = HTTP::_GP('chat_channelname', '', true);
        $chat_botname = HTTP::_GP('chat_botname', '', true);
        $config_after = array('chat_closed' => $chat_closed, 'chat_allowchan' => $chat_allowchan, 'chat_allowmes' => $chat_allowmes, 'chat_allowdelmes' => $chat_allowdelmes, 'chat_logmessage' => $chat_logmessage, 'chat_nickchange' => $chat_nickchange, 'chat_botname' => $chat_botname, 'chat_channelname' => $chat_channelname);
        Config::update($config_after);
        $CONF = Config::getAll(NULL, 1);
        $LOG = new Log(3);
        $LOG->target = 3;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
    }
    $template = new template();
    $template->assign_vars(array('chat_closed' => $CONF['chat_closed'], 'chat_allowchan' => $CONF['chat_allowchan'], 'chat_allowmes' => $CONF['chat_allowmes'], 'chat_logmessage' => $CONF['chat_logmessage'], 'chat_nickchange' => $CONF['chat_nickchange'], 'chat_botname' => $CONF['chat_botname'], 'chat_channelname' => $CONF['chat_channelname'], 'se_server_parameters' => $LNG['se_server_parameters'], 'se_save_parameters' => $LNG['se_save_parameters'], 'ch_closed' => $LNG['ch_closed'], 'ch_allowchan' => $LNG['ch_allowchan'], 'ch_allowmes' => $LNG['ch_allowmes'], 'ch_allowdelmes' => $LNG['ch_allowdelmes'], 'ch_logmessage' => $LNG['ch_logmessage'], 'ch_nickchange' => $LNG['ch_nickchange'], 'ch_botname' => $LNG['ch_botname'], 'ch_channelname' => $LNG['ch_channelname']));
    $template->show('ChatConfigBody.tpl');
}
Example #3
0
function ShowUpdatePage()
{
    global $LNG, $CONF;
    $template = new template();
    $template->message('<p>This Site is currently under construction, because the update system brings somtimes inconsistent game installations.</p><p>Alternate update process: <a href="http://2moons.cc/b4-support/b7-installation-update-und-konvertierung/t1721-howto-update-your-2moons-game-with-private-modifications-without-edit-files-one-by-one/" target="blank"><u>2moons.cc Board</u></a></p><p>We apologize for any inconvenience.</p>');
    exit;
    if (!function_exists('curl_init')) {
        $template = new template();
        $template->message($LNG['up_need_curl']);
    }
    if (isset($_REQUEST['version'])) {
        $Temp = explode('.', $_REQUEST['version']);
        $Temp = array_map('intval', $Temp);
        if (count(GetLogs($Temp[2]), COUNT_RECURSIVE) > 8) {
            Config::update(array('VERSION' => $Temp[0] . '.' . $Temp[1] . '.' . $Temp[2]));
        }
    }
    $ACTION = HTTP::_GP('action', '');
    switch ($ACTION) {
        case "download":
            DownloadUpdates();
            break;
        case "check":
            CheckPermissions();
            break;
        case "update":
            ExecuteUpdates();
            break;
        default:
            DisplayUpdates();
            break;
    }
}
Example #4
0
 function indexAction()
 {
     $config_table = new Config();
     $modules_table = new Modules("core");
     $request = new Bolts_Request($this->getRequest());
     if ($request->has('modid')) {
         $modid = $request->modid;
     } else {
         $modid = 'bolts';
     }
     if ($this->_request->isPost()) {
         //we are posting
         $config_params = $this->_request->getParams();
         foreach ($config_params as $ckey => $value) {
             $data = array('value' => $value);
             $config_table->update($data, "ckey = '" . $ckey . "' and module='" . $modid . "'");
         }
         $this->view->success = $this->_T('Configuration Updated.');
         $config_table->cache();
         $params = array();
         $this->_Bolts_plugin->doAction($this->_mca . '_post_save', $params);
         // ACTION HOOK
     }
     $config = $config_table->fetchAll($config_table->select()->where('module = ?', $modid));
     if (count($config) > 0) {
         $config = $config->toArray();
         sort($config);
         $this->view->config = $config;
     }
     $modules = $modules_table->getEnabledModules();
     sort($modules);
     $this->view->modules = $modules;
     $this->view->current = $modid;
     $this->view->modid = $modid;
 }
 function run()
 {
     require_once 'includes/classes/class.statbuilder.php';
     $stat = new Statbuilder();
     $result = $stat->MakeStats();
     Config::update(array('stat_last_update' => TIMESTAMP));
 }
Example #6
0
 private function CheckUniverseAccounts($UniData)
 {
     $UniData = $UniData + array_combine($this->Unis, array_fill(1, count($this->Unis), 0));
     foreach ($UniData as $Uni => $Amount) {
         Config::update(array('users_amount' => $Amount), $Uni);
     }
 }
Example #7
0
function ShowDisclamerPage()
{
    global $LNG, $USER;
    $CONF = Config::getAll(NULL, $_SESSION['adminuni']);
    if (!empty($_POST)) {
        $config_before = array('disclamerAddress' => $CONF['disclamerAddress'], 'disclamerPhone' => $CONF['disclamerPhone'], 'disclamerMail' => $CONF['disclamerMail'], 'disclamerNotice' => $CONF['disclamerNotice']);
        $disclamerAddress = HTTP::_GP('disclamerAddress', '', true);
        $disclamerPhone = HTTP::_GP('disclamerPhone', '', true);
        $disclamerMail = HTTP::_GP('disclamerMail', '', true);
        $disclamerNotice = HTTP::_GP('disclamerNotice', '', true);
        $config_after = array('disclamerAddress' => $disclamerAddress, 'disclamerPhone' => $disclamerPhone, 'disclamerMail' => $disclamerMail, 'disclamerNotice' => $disclamerNotice);
        Config::update($config_after);
        $CONF = Config::getAll(NULL, $_SESSION['adminuni']);
        $LOG = new Log(3);
        $LOG->target = 5;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
    }
    $template = new template();
    $template->loadscript('../base/jquery.autosize-min.js');
    $template->execscript('$(\'textarea\').autosize();');
    $template->assign_vars(array('disclamerAddress' => $CONF['disclamerAddress'], 'disclamerPhone' => $CONF['disclamerPhone'], 'disclamerMail' => $CONF['disclamerMail'], 'disclamerNotice' => $CONF['disclamerNotice'], 'se_server_parameters' => $LNG['mu_disclamer'], 'se_save_parameters' => $LNG['se_save_parameters'], 'se_disclamerAddress' => $LNG['se_disclamerAddress'], 'se_disclamerPhone' => $LNG['se_disclamerPhone'], 'se_disclamerMail' => $LNG['se_disclamerMail'], 'se_disclamerNotice' => $LNG['se_disclamerNotice']));
    $template->show('DisclamerConfigBody.tpl');
}
function ShowFleetsConfPage()
{
    global $LNG;
    $CONF = Config::getAll(NULL, 1);
    if (!empty($_POST)) {
        $pay_before = array('fleetconf' => $CONF['fleetconf']);
        $fleetconf = TIMESTAMP + $_POST['days'] * 24 * 60 * 60;
        $pay_after = array('fleetconf' => $fleetconf);
        Config::update($pay_after, 1);
        $CONF = Config::getAll(NULL, 1);
        $LOG = new Log(3);
        $LOG->target = 1;
        $LOG->old = $pay_before;
        $LOG->new = $pay_after;
        $LOG->save();
        require_once 'includes/functions/BBCode.php';
        $Time = TIMESTAMP;
        $Message = '<span class="admin">All promotional fleets and defence have been unlocked until ' . date("d.m.Y - H:i:s", $CONF['fleetconf']) . '. - <a href="?page=shipyard&mode=fleet">Fleet</a> - <a href="?page=shipyard&mode=defence">Defence</a>';
        $From = '<span class="admin">"Antimatter"</span>';
        $pmSubject = '<span class="admin">"Purchase Bonus"</span>';
        $pmMessage = '<span class="admin">' . bbcode($Message) . '</span>';
        $USERS = $GLOBALS['DATABASE']->query("SELECT `id`, `username` FROM " . USERS . " WHERE `universe` = '1';");
        while ($UserData = $GLOBALS['DATABASE']->fetch_array($USERS)) {
            $sendMessage = str_replace('{USERNAME}', $UserData['username'], $pmMessage);
            SendSimpleMessage($UserData['id'], $USER['id'], TIMESTAMP, 50, $From, $pmSubject, $sendMessage);
        }
    }
    $template = new template();
    $template->assign_vars(array('fleetconf' => $CONF['fleetconf'], 'bonus_next_active' => $CONF['fleetconf'] > TIMESTAMP ? $CONF['fleetconf'] - TIMESTAMP : 0, 'bonus_next_active_timer' => $CONF['fleetconf'] > TIMESTAMP ? date("d.m.Y H:i:s", $CONF['fleetconf']) : 0));
    $template->show('fleetconf.tpl');
}
Example #9
0
 /**
  * Will call events as close as it gets to one hour. Event handlers
  * which use this MUST be as quick as possible, maybe only adding a
  * queue item to be handled later or something. Otherwise execution
  * will timeout for PHP - or at least cause unnecessary delays for
  * the unlucky user who visits the site exactly at one of these events.
  */
 public function callTimedEvents()
 {
     $timers = array('minutely' => 60, 'hourly' => 3600, 'daily' => 86400, 'weekly' => 604800);
     foreach ($timers as $name => $interval) {
         $run = false;
         $lastrun = new Config();
         $lastrun->section = 'cron';
         $lastrun->setting = 'last_' . $name;
         $found = $lastrun->find(true);
         if (!$found) {
             $lastrun->value = time();
             if ($lastrun->insert() === false) {
                 common_log(LOG_WARNING, "Could not save 'cron' setting '{$name}'");
                 continue;
             }
             $run = true;
         } elseif ($lastrun->value < time() - $interval) {
             $orig = clone $lastrun;
             $lastrun->value = time();
             $lastrun->update($orig);
             $run = true;
         }
         if ($run === true) {
             // such as CronHourly, CronDaily, CronWeekly
             Event::handle('Cron' . ucfirst($name));
         }
     }
 }
Example #10
0
function DeleteSelectedUser($userID)
{
    global $db, $CONF;
    if (ROOT_USER == $userID) {
        return false;
    }
    $userData = $GLOBALS['DATABASE']->getFirstRow("SELECT universe, ally_id FROM " . USERS . " WHERE id = '" . $userID . "';");
    $SQL = "";
    if ($userData['ally_id'] != 0) {
        $memberCount = $GLOBALS['DATABASE']->getFirstCell("SELECT ally_members FROM " . ALLIANCE . " WHERE id = " . $userData['ally_id'] . ";");
        if ($memberCount >= 2) {
            $SQL .= "UPDATE " . ALLIANCE . " SET ally_members = ally_members - 1 WHERE id = " . $userData['ally_id'] . ";";
        } else {
            $SQL .= "DELETE FROM " . ALLIANCE . " WHERE id = " . $userData['ally_id'] . ";";
            $SQL .= "DELETE FROM " . STATPOINTS . " WHERE stat_type = '2' AND id_owner = " . $userID . ";";
            $SQL .= "UPDATE " . STATPOINTS . " SET id_ally = 0 WHERE id_ally = " . $userData['ally_id'] . ";";
        }
    }
    $SQL .= "DELETE FROM " . ALLIANCE_REQUEST . " WHERE userID = " . $userID . ";";
    $SQL .= "DELETE FROM " . BUDDY . " WHERE owner = " . $userID . " OR sender = " . $userID . ";";
    $SQL .= "DELETE FROM " . FLEETS . " WHERE fleet_owner = " . $userID . ";";
    $SQL .= "DELETE FROM " . MESSAGES . " WHERE message_owner = " . $userID . ";";
    $SQL .= "DELETE FROM " . NOTES . " WHERE owner = " . $userID . ";";
    $SQL .= "DELETE FROM " . PLANETS . " WHERE id_owner = " . $userID . ";";
    $SQL .= "DELETE FROM " . USERS . " WHERE id = " . $userID . ";";
    $SQL .= "DELETE FROM " . STATPOINTS . " WHERE stat_type = '1' AND id_owner = " . $userID . ";";
    $GLOBALS['DATABASE']->multi_query($SQL);
    $fleetData = $GLOBALS['DATABASE']->query("SELECT fleet_id FROM " . FLEETS . " WHERE fleet_target_owner = " . $userID . ";");
    while ($FleetID = $GLOBALS['DATABASE']->fetch_array($fleetData)) {
        FleetFunctions::SendFleetBack($userID, $FleetID['fleet_id']);
    }
    $GLOBALS['DATABASE']->free_result($fleetData);
    Config::update(array('users_amount' => Config::get('users_amount') - 1), $userData['universe']);
}
Example #11
0
function ShowPaybonusPage()
{
    global $LNG;
    $CONF = Config::getAll(NULL, 1);
    if (!empty($_POST)) {
        $pay_before = array('bonus_button' => $CONF['bonus_button'], 'academy_bonus' => $CONF['academy_bonus'], 'premium' => $CONF['premium'], 'stardust_bonus' => $CONF['stardust_bonus'], 'purchase_bonus' => $CONF['purchase_bonus'], 'purchase_bonus_timer' => $CONF['purchase_bonus_timer'], 'cosmonaute' => $CONF['cosmonaute'], 'fleetconf' => $CONF['fleetconf'], 'new_year' => $CONF['new_year']);
        $purchase_bonus = $_POST['percent'];
        $academy_bonus = $_POST['academy_bonus'];
        $bonus_button = $_POST['bonus_button'];
        $premium = $_POST['premium'];
        $stardust_bonus = $_POST['stardust_bonus'];
        $stardust_bonus = $_POST['stardust_bonus'];
        $fleetconf = isset($_POST['fleetconf']) && $_POST['fleetconf'] == 'on' ? 1 : 0;
        $cosmonaute = isset($_POST['cosmonaute']) && $_POST['cosmonaute'] == 'on' ? 1 : 0;
        $new_year = isset($_POST['new_year']) && $_POST['new_year'] == 'on' ? 1 : 0;
        $purchase_bonus_timer = TIMESTAMP + $_POST['days'] * 24 * 60 * 60;
        $pay_after = array('bonus_button' => $bonus_button, 'academy_bonus' => $academy_bonus, 'premium' => $premium, 'stardust_bonus' => $stardust_bonus, 'purchase_bonus' => $purchase_bonus, 'purchase_bonus_timer' => $purchase_bonus_timer, 'fleetconf' => $fleetconf, 'cosmonaute' => $cosmonaute, 'new_year' => $new_year);
        Config::update($pay_after, 1);
        $CONF = Config::getAll(NULL, 1);
        $LOG = new Log(3);
        $LOG->target = 1;
        $LOG->old = $pay_before;
        $LOG->new = $pay_after;
        $LOG->save();
    }
    $template = new template();
    $template->assign_vars(array('academy_bonus' => $CONF['academy_bonus'], 'cosmonaute' => $CONF['cosmonaute'], 'new_year' => $CONF['new_year'], 'bonus_button' => $CONF['bonus_button'], 'fleetconf' => $CONF['fleetconf'], 'premium' => $CONF['premium'], 'stardust_bonus' => $CONF['stardust_bonus'], 'purchase_bonus' => $CONF['purchase_bonus'], 'purchase_bonus_timer' => $CONF['purchase_bonus_timer'], 'bonus_next_active' => $CONF['purchase_bonus_timer'] > TIMESTAMP ? $CONF['purchase_bonus_timer'] - TIMESTAMP : 0, 'bonus_next_active_timer' => $CONF['purchase_bonus_timer'] > TIMESTAMP ? date("d.m.Y H:i:s", $CONF['purchase_bonus_timer']) : 0));
    $template->show('paybonus.tpl');
}
Example #12
0
function ShowTeamspeakPage()
{
    global $LNG, $USER;
    $CONF = Config::getAll(NULL, $_SESSION['adminuni']);
    if ($_POST) {
        $config_before = array('ts_timeout' => $CONF['ts_timeout'], 'ts_modon' => $CONF['ts_modon'], 'ts_server' => $CONF['ts_server'], 'ts_tcpport' => $CONF['ts_tcpport'], 'ts_udpport' => $CONF['ts_udpport'], 'ts_version' => $CONF['ts_version'], 'ts_login' => $CONF['ts_login'], 'ts_password' => $CONF['ts_password'], 'ts_cron_interval' => $CONF['ts_cron_interval']);
        $ts_modon = isset($_POST['ts_on']) && $_POST['ts_on'] == 'on' ? 1 : 0;
        $ts_server = HTTP::_GP('ts_ip', '');
        $ts_tcpport = HTTP::_GP('ts_tcp', 0);
        $ts_udpport = HTTP::_GP('ts_udp', 0);
        $ts_timeout = HTTP::_GP('ts_to', 0);
        $ts_version = HTTP::_GP('ts_v', 0);
        $ts_login = HTTP::_GP('ts_login', '');
        $ts_password = HTTP::_GP('ts_password', '', true);
        $ts_cron_interval = HTTP::_GP('ts_cron', 0);
        $config_after = array('ts_timeout' => $ts_timeout, 'ts_modon' => $ts_modon, 'ts_server' => $ts_server, 'ts_tcpport' => $ts_tcpport, 'ts_udpport' => $ts_udpport, 'ts_version' => $ts_version, 'ts_login' => $ts_login, 'ts_password' => $ts_password, 'ts_cron_interval' => $ts_cron_interval);
        Config::update($config_after);
        $GLOBALS['DATABASE']->query("UPDATE " . CRONJOBS . " SET isActive = " . $ts_modon . ", `lock` = NULL, nextTime = 0 WHERE name = 'teamspeak';");
        $CONF = Config::getAll(NULL, $_SESSION['adminuni']);
        $LOG = new Log(3);
        $LOG->target = 4;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
    }
    $template = new template();
    $template->assign_vars(array('se_save_parameters' => $LNG['se_save_parameters'], 'ts_tcpport' => $LNG['ts_tcpport'], 'ts_serverip' => $LNG['ts_serverip'], 'ts_version' => $LNG['ts_version'], 'ts_active' => $LNG['ts_active'], 'ts_settings' => $LNG['ts_settings'], 'ts_udpport' => $LNG['ts_udpport'], 'ts_timeout' => $LNG['ts_timeout'], 'ts_server_query' => $LNG['ts_server_query'], 'ts_sq_login' => $LNG['ts_login'], 'ts_sq_pass' => $LNG['ts_pass'], 'ts_lng_cron' => $LNG['ts_cron'], 'ts_to' => $CONF['ts_timeout'], 'ts_on' => $CONF['ts_modon'], 'ts_ip' => $CONF['ts_server'], 'ts_tcp' => $CONF['ts_tcpport'], 'ts_udp' => $CONF['ts_udpport'], 'ts_v' => $CONF['ts_version'], 'ts_login' => $CONF['ts_login'], 'ts_password' => $CONF['ts_password'], 'ts_cron' => $CONF['ts_cron_interval']));
    $template->show('TeamspeakPage.tpl');
}
Example #13
0
 protected function setUp()
 {
     global $CFG_GLPI;
     $this->http_client = new GuzzleHttp\Client();
     $this->base_uri = trim($CFG_GLPI['url_base_api'], "/") . "/";
     // enable api config
     $config = new Config();
     $config->update(array('id' => 1, 'enable_api' => true, 'enable_api_login_credentials' => true, 'enable_api_login_external_token' => true));
 }
 function run()
 {
     require_once ROOT_PATH . 'includes/classes/class.statbuilder.php';
     $stat = new Statbuilder();
     $result = $stat->MakeStats();
     Config::update(array('stat_last_update' => TIMESTAMP));
     $Data = $GLOBALS['DATABASE']->query("SELECT id_owner, universe, tech_points, build_points, defs_points, fleet_points, popu_points, total_points, total_rank FROM " . STATPOINTS . " WHERE stat_type = 1;");
     $InsertData = array();
     while ($i = $GLOBALS['DATABASE']->fetch_array($Data)) {
         $InsertData[] = "('" . $i['id_owner'] . "','" . TIMESTAMP . "','" . $i['universe'] . "','" . $i['build_points'] . "','" . $i['tech_points'] . "','" . $i['defs_points'] . "','" . $i['fleet_points'] . "','" . $i['popu_points'] . "','" . $i['total_points'] . "','" . $i['total_rank'] . "')";
     }
     $InsertSQL = "TRUNCATE " . STATHISTORY . ";INSERT INTO " . STATHISTORY . " (`id_owner` ,`time` ,`universe` ,`history_build_points` ,`history_tech_points` ,`history_defs_points` ,`history_fleet_points`, `history_popu_points` , `history_total_points`, `history_total_rank`) VALUES " . implode(',', $InsertData) . ";";
     $GLOBALS['DATABASE']->multi_query($InsertSQL);
 }
Example #15
0
function ShowFacebookPage()
{
    global $LNG;
    if ($_POST) {
        $fb_on = isset($_POST['fb_on']) && $_POST['fb_on'] == 'on' && !empty($_POST['fb_skey']) && !empty($_POST['fb_apikey']) ? 1 : 0;
        $fb_apikey = HTTP::_GP('fb_apikey', '');
        $fb_skey = HTTP::_GP('fb_skey', '');
        Config::update(array('fb_on' => $fb_on, 'fb_apikey' => $fb_apikey, 'fb_skey' => $fb_skey));
    }
    $CONF = Config::getAll(NULL, $_SESSION['adminuni']);
    $template = new template();
    $template->assign_vars(array('se_save_parameters' => $LNG['se_save_parameters'], 'fb_info' => $LNG['fb_info'], 'fb_secrectkey' => $LNG['fb_secrectkey'], 'fb_api_key' => $LNG['fb_api_key'], 'fb_active' => $LNG['fb_active'], 'fb_settings' => $LNG['fb_settings'], 'fb_on' => $CONF['fb_on'], 'fb_apikey' => $CONF['fb_apikey'], 'fb_skey' => $CONF['fb_skey'], 'fb_curl' => function_exists('curl_init') ? 1 : 0, 'fb_curl_info' => function_exists('curl_init') ? $LNG['fb_curl_yes'] : $LNG['fb_curl_no']));
    $template->show('FacebookPage.tpl');
}
Example #16
0
 function config($params = array())
 {
     // if saving...
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         // loop through all the other data and reorganise them properly
         foreach ($params as $k => $v) {
             // exit if the values is empty (but not false)?
             if (empty($v) && $v != "0") {
                 continue;
             }
             // get the controller from the field name
             $name = explode("|", $k);
             if (count($name) < 2) {
                 continue;
             }
             $table = $name[0];
             $key = $name[1];
             //#25 - encrypting 'password' fields
             $cipher = is_null(CIPHER) ? $v : CIPHER;
             $value = $key == "admin_password" ? crypt($v, $cipher) : $v;
             // only save the data that has changed
             if ($GLOBALS["config"][$table][$key] != $value) {
                 $config = new Config(0, $table);
                 // find the entry with the right key
                 $config->retrieve_one("key=?", $key);
                 //$config->pkname = 'key';
                 $config->set('key', $key);
                 $config->set('value', $value);
                 // update model
                 $config->update();
                 // update memory
                 $GLOBALS["config"][$table][$key] = $value;
             }
         }
         // generate the humans.txt file
         $humans = $this->humansText();
         // redirect back to the configuration page
         header('Location: ' . url('admin/config'));
     } else {
         // show the configuration
         //$this->data['body']['admin']=View::do_fetch( getPath('views/admin/config.php'),$this->data);
         $data['view'] = getPath('views/admin/config.php');
         $this->data['status'] = "config";
         $this->data['body'][] = $data;
         $this->data['template'] = ADMIN_TEMPLATE;
         // display the page
         Template::output($this->data);
     }
 }
 /**
  * Run the controller.
  */
 public function run()
 {
     // user have to be authenticated
     $this->User->authenticate();
     // disable Avisota
     if ($this->Input->get('disable')) {
         $inactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules'], true);
         $inactiveModules[] = 'Avisota';
         $this->Config->update("\$GLOBALS['TL_CONFIG']['inactiveModules']", serialize($inactiveModules));
         $this->Config->save();
         $_SESSION[TL_INFO][] = $GLOBALS['TL_LANG']['avisotaCompatibilityController']['disabled'];
         $this->redirect('contao/main.php');
     }
     $template = new BackendTemplate('be_avisota_compatibility_controller');
     $template->theme = $this->getTheme();
     $template->base = $this->Environment->base;
     $template->language = $GLOBALS['TL_LANGUAGE'];
     $template->title = $GLOBALS['TL_CONFIG']['websiteTitle'];
     $template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
     $template->request = ampersand($this->Environment->request);
     $template->top = $GLOBALS['TL_LANG']['MSC']['backToTop'];
     $template->mysqlVersion = \Database::getInstance()->query('SHOW VARIABLES WHERE Variable_name = \'version\'')->Value;
     $template->output();
 }
Example #18
0
function ShowStatUpdatePage()
{
    global $LNG;
    require_once 'includes/classes/class.statbuilder.php';
    $stat = new statbuilder();
    $result = $stat->MakeStats();
    $memory_p = str_replace(array("%p", "%m"), $result['memory_peak'], $LNG['sb_top_memory']);
    $memory_e = str_replace(array("%e", "%m"), $result['end_memory'], $LNG['sb_final_memory']);
    $memory_i = str_replace(array("%i", "%m"), $result['initial_memory'], $LNG['sb_start_memory']);
    $stats_end_time = sprintf($LNG['sb_stats_update'], $result['totaltime']);
    $stats_sql = sprintf($LNG['sb_sql_counts'], $result['sql_count']);
    Config::update(array('stat_last_update' => $result['stats_time']));
    $template = new template();
    $template->message($LNG['sb_stats_updated'] . $stats_end_time . $memory_i . $memory_e . $memory_p . $stats_sql, false, 0, true);
}
Example #19
0
function ShowModulePage()
{
    global $CONF, $LNG;
    $module = Config::get('moduls');
    if ($_GET['mode']) {
        $module[HTTP::_GP('id', 0)] = $_GET['mode'] == 'aktiv' ? 1 : 0;
        Config::update(array('moduls' => implode(";", $module)));
    }
    $IDs = range(0, MODULE_AMOUNT - 1);
    foreach ($IDs as $ID => $Name) {
        $Modules[$ID] = array('name' => $LNG['modul'][$ID], 'state' => isset($module[$ID]) ? $module[$ID] : 1);
    }
    asort($Modules);
    $template = new template();
    $template->assign_vars(array('Modules' => $Modules, 'mod_module' => $LNG['mod_module'], 'mod_info' => $LNG['mod_info'], 'mod_active' => $LNG['mod_active'], 'mod_deactive' => $LNG['mod_deactive'], 'mod_change_active' => $LNG['mod_change_active'], 'mod_change_deactive' => $LNG['mod_change_deactive']));
    $template->show('ModulePage.tpl');
}
function ShowConfigBasicPage()
{
    global $LNG, $USER;
    $CONF = Config::getAll(NULL, 1);
    if (!empty($_POST)) {
        $config_before = array('ttf_file' => $CONF['ttf_file'], 'game_name' => $CONF['game_name'], 'mail_active' => $CONF['mail_active'], 'mail_use' => $CONF['mail_use'], 'smail_path' => $CONF['smail_path'], 'smtp_host' => $CONF['smtp_host'], 'smtp_port' => $CONF['smtp_port'], 'smtp_user' => $CONF['smtp_user'], 'smtp_pass' => $CONF['smtp_pass'], 'smtp_ssl' => $CONF['smtp_ssl'], 'smtp_sendmail' => $CONF['smtp_sendmail'], 'ga_active' => $CONF['ga_active'], 'ga_key' => $CONF['ga_key'], 'capaktiv' => $CONF['capaktiv'], 'cappublic' => $CONF['cappublic'], 'capprivate' => $CONF['capprivate'], 'del_oldstuff' => $CONF['del_oldstuff'], 'del_user_manually' => $CONF['del_user_manually'], 'del_user_automatic' => $CONF['del_user_automatic'], 'del_user_sendmail' => $CONF['del_user_sendmail'], 'sendmail_inactive' => $CONF['sendmail_inactive'], 'timezone' => $CONF['timezone'], 'dst' => $CONF['dst']);
        $capaktiv = isset($_POST['capaktiv']) && $_POST['capaktiv'] == 'on' ? 1 : 0;
        $ga_active = isset($_POST['ga_active']) && $_POST['ga_active'] == 'on' ? 1 : 0;
        $sendmail_inactive = isset($_POST['sendmail_inactive']) && $_POST['sendmail_inactive'] == 'on' ? 1 : 0;
        $mail_active = isset($_POST['mail_active']) && $_POST['mail_active'] == 'on' ? 1 : 0;
        $ttf_file = HTTP::_GP('ttf_file', '');
        $close_reason = HTTP::_GP('close_reason', '', true);
        $game_name = HTTP::_GP('game_name', '', true);
        $capprivate = HTTP::_GP('capprivate', '');
        $cappublic = HTTP::_GP('cappublic', '');
        $ga_key = HTTP::_GP('ga_key', '', true);
        $mail_use = HTTP::_GP('mail_use', 0);
        $smail_path = HTTP::_GP('smail_path', '');
        $smtp_host = HTTP::_GP('smtp_host', '', true);
        $smtp_port = HTTP::_GP('smtp_port', 0);
        $smtp_user = HTTP::_GP('smtp_user', '', true);
        $smtp_sendmail = HTTP::_GP('smtp_sendmail', '', true);
        $smtp_pass = HTTP::_GP('smtp_pass', '', true);
        $smtp_ssl = HTTP::_GP('smtp_ssl', '');
        $del_oldstuff = HTTP::_GP('del_oldstuff', 0);
        $del_user_manually = HTTP::_GP('del_user_manually', 0);
        $del_user_automatic = HTTP::_GP('del_user_automatic', 0);
        $del_user_sendmail = HTTP::_GP('del_user_sendmail', 0);
        $timezone = HTTP::_GP('timezone', '');
        $dst = HTTP::_GP('dst', 0);
        $config_after = array('ttf_file' => $ttf_file, 'game_name' => $game_name, 'mail_active' => $mail_active, 'mail_use' => $mail_use, 'smail_path' => $smail_path, 'smtp_host' => $smtp_host, 'smtp_port' => $smtp_port, 'smtp_user' => $smtp_user, 'smtp_pass' => $smtp_pass, 'smtp_ssl' => $smtp_ssl, 'smtp_sendmail' => $smtp_sendmail, 'ga_active' => $ga_active, 'ga_key' => $ga_key, 'capaktiv' => $capaktiv, 'cappublic' => $cappublic, 'capprivate' => $capprivate, 'del_oldstuff' => $del_oldstuff, 'del_user_manually' => $del_user_manually, 'del_user_automatic' => $del_user_automatic, 'del_user_sendmail' => $del_user_sendmail, 'sendmail_inactive' => $sendmail_inactive, 'timezone' => $timezone, 'dst' => $dst);
        Config::update($config_after, 1);
        $CONF = Config::getAll(NULL, 1);
        $LOG = new Log(3);
        $LOG->target = 0;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
    }
    $TimeZones = get_timezone_selector();
    $template = new template();
    $template->assign_vars(array('del_oldstuff' => $CONF['del_oldstuff'], 'del_user_manually' => $CONF['del_user_manually'], 'del_user_automatic' => $CONF['del_user_automatic'], 'del_user_sendmail' => $CONF['del_user_sendmail'], 'sendmail_inactive' => $CONF['sendmail_inactive'], 'ttf_file' => $CONF['ttf_file'], 'game_name' => $CONF['game_name'], 'mail_active' => $CONF['mail_active'], 'mail_use' => $CONF['mail_use'], 'smail_path' => $CONF['smail_path'], 'smtp_host' => $CONF['smtp_host'], 'smtp_port' => $CONF['smtp_port'], 'smtp_user' => $CONF['smtp_user'], 'smtp_pass' => $CONF['smtp_pass'], 'smtp_sendmail' => $CONF['smtp_sendmail'], 'smtp_ssl' => $CONF['smtp_ssl'], 'capprivate' => $CONF['capprivate'], 'cappublic' => $CONF['cappublic'], 'capaktiv' => $CONF['capaktiv'], 'ga_active' => $CONF['ga_active'], 'ga_key' => $CONF['ga_key'], 'timezone' => $CONF['timezone'], 'dst' => $CONF['dst'], 'Selector' => array('timezone' => $TimeZones, 'mail' => $LNG['se_mail_sel'], 'encry' => array('' => $LNG['se_smtp_ssl_1'], 'ssl' => $LNG['se_smtp_ssl_2'], 'tls' => $LNG['se_smtp_ssl_3']))));
    $template->show('ConfigBasicBody.tpl');
}
Example #21
0
function ShowTimebonusPage()
{
    global $LNG;
    $CONF = Config::getAll(NULL, 1);
    if (!empty($_POST)) {
        $pay_before = array('timeReward' => $CONF['timeReward'], 'timeRewardFrom' => $CONF['timeRewardFrom'], 'timeRewardTo' => $CONF['timeRewardTo']);
        $timeReward = $_POST['timeReward'];
        $timeRewardFrom = $_POST['timeRewardFrom'];
        $timeRewardTo = $_POST['timeRewardTo'];
        $pay_after = array('timeReward' => $timeReward, 'timeRewardFrom' => $timeRewardFrom, 'timeRewardTo' => $timeRewardTo);
        Config::update($pay_after, 1);
        $CONF = Config::getAll(NULL, 1);
        $LOG = new Log(3);
        $LOG->target = 1;
        $LOG->old = $pay_before;
        $LOG->new = $pay_after;
        $LOG->save();
    }
    $template = new template();
    $template->assign_vars(array('timeReward' => $CONF['timeReward'], 'timeRewardFrom' => $CONF['timeRewardFrom'], 'timeRewardTo' => $CONF['timeRewardTo']));
    $template->show('timebonus.tpl');
}
Example #22
0
	function indexAction()
	{
		$config_table = new Config();
		// $modules_table = new Modules('core');
		$modules_table = new Modules('modules');
		$modules_table_core = new Modules('core');
		$request = new RivetyCore_Request($this->getRequest());
		$modid = $request->has('modid') ? $request->modid : 'default';
		if ($this->_request->isPost())
		{
			$config_params = $this->_request->getParams();
			foreach ($config_params as $ckey => $value)
			{
				$data = array('value' => $value);
				$config_table->update($data, "ckey = '" . $ckey . "' and module = '" . $modid . "'");
			}
			$this->view->success = $this->_T('Configuration Updated.');
			$config_table->cache();
			$params = array();
			$this->_rivety_plugin->doAction($this->_mca . '_post_save', $params); // ACTION HOOK
		}
		$config = $config_table->fetchAll($config_table->select()->where('module = ?', $modid));
		if (count($config) > 0)
		{
			$config = $config->toArray();
			sort($config);
			$this->view->config = $config;
		}
		$modules = $modules_table_core->getEnabledModules();
		sort($modules);
		$this->view->modules = $modules;
		$this->view->current = $modid;
		$this->view->modid = $modid;
		if ($modid == 'default') $mod_cfg = $modules_table_core->parseIni($modid);
		else $mod_cfg = $modules_table->parseIni($modid);
		$this->view->module_title = $mod_cfg['general']['name'];
		$this->view->breadcrumbs = array('Module Config' => null);
	}
Example #23
0
function ShowStatsPage()
{
    global $LNG, $USER;
    $CONF = Config::getAll(NULL, $_SESSION['adminuni']);
    if ($_POST) {
        $config_before = array('stat_settings' => $CONF['stat_settings'], 'stat' => $CONF['stat'], 'stat_update_time' => $CONF['stat_update_time'], 'stat_level' => $CONF['stat_level']);
        $stat_settings = HTTP::_GP('stat_settings', 0);
        $stat = HTTP::_GP('stat', 0);
        $stat_update_time = HTTP::_GP('stat_update_time', 0);
        $stat_level = HTTP::_GP('stat_level', 0);
        $config_after = array('stat_settings' => $stat_settings, 'stat' => $stat, 'stat_update_time' => $stat_update_time, 'stat_level' => $stat_level);
        Config::update($config_after);
        $LOG = new Log(3);
        $LOG->target = 2;
        $LOG->old = $config_before;
        $LOG->new = $config_after;
        $LOG->save();
        $CONF = Config::getAll(NULL, $_SESSION['adminuni']);
    }
    $template = new template();
    $template->assign_vars(array('stat_level' => $CONF['stat_level'], 'stat_update_time' => $CONF['stat_update_time'], 'stat' => $CONF['stat'], 'stat_settings' => $CONF['stat_settings'], 'timeact' => date('d. M y H:i:s T', Config::get('stat_last_update')), 'cs_timeact_1' => $LNG['cs_timeact_1'], 'cs_access_lvl' => $LNG['cs_access_lvl'], 'cs_points_to_zero' => $LNG['cs_points_to_zero'], 'cs_time_between_updates' => $LNG['cs_time_between_updates'], 'cs_point_per_resources_used' => $LNG['cs_point_per_resources_used'], 'cs_title' => $LNG['cs_title'], 'cs_resources' => $LNG['cs_resources'], 'cs_minutes' => $LNG['cs_minutes'], 'cs_save_changes' => $LNG['cs_save_changes'], 'Selector' => array(1 => $LNG['cs_yes'], 2 => $LNG['cs_no_view'], 0 => $LNG['cs_no'])));
    $template->show('StatsPage.tpl');
}
Example #24
0
        $tui_status = $track_usage_information > 0 ? TRUE : FALSE;
        $client->system()->set_telemetry($tui_status);
    }
    $config->update('first_login', 'no');
    $db->close();
    $default_user = AV_DEFAULT_ADMIN;
}
// LOGIN
$cnd_1 = !empty($user) && is_string($user);
$cnd_2 = !empty($pass) && is_string($pass);
if ($cnd_1 && $cnd_2) {
    $session = new Session($user, $pass, '');
    $config = new Config();
    //Disable first_login
    if ($accepted == 'yes') {
        $config->update('first_login', 'no');
    }
    $is_disabled = $session->is_user_disabled();
    if ($is_disabled == FALSE) {
        $login_return = $session->login();
        $first_user_login = $session->get_first_login();
        $last_pass_change = $session->last_pass_change();
        $login_exists = $session->is_logged_user_in_db();
        $lockout_duration = intval($conf->get_conf('unlock_user_interval')) * 60;
        if ($login_return != TRUE) {
            $_SESSION['_user'] = '';
            $infolog = array($user);
            Log_action::log(94, $infolog);
            $failed = TRUE;
            $bad_pass = TRUE;
            $failed_retries = $conf->get_conf('failed_retries');
Example #25
0
    function install($vars) {

        $this->errors=$f=array();

        $f['name']          = array('type'=>'string',   'required'=>1, 'error'=>__('Name required'));
        $f['email']         = array('type'=>'email',    'required'=>1, 'error'=>__('Valid email required'));
        $f['fname']         = array('type'=>'string',   'required'=>1, 'error'=>__('First name required'));
        $f['lname']         = array('type'=>'string',   'required'=>1, 'error'=>__('Last name required'));
        $f['admin_email']   = array('type'=>'email',    'required'=>1, 'error'=>__('Valid email required'));
        $f['username']      = array('type'=>'username', 'required'=>1, 'error'=>__('Username required'));
        $f['passwd']        = array('type'=>'password', 'required'=>1, 'error'=>__('Password required'));
        $f['passwd2']       = array('type'=>'password', 'required'=>1, 'error'=>__('Confirm Password'));
        $f['prefix']        = array('type'=>'string',   'required'=>1, 'error'=>__('Table prefix required'));
        $f['dbhost']        = array('type'=>'string',   'required'=>1, 'error'=>__('Host name required'));
        $f['dbname']        = array('type'=>'string',   'required'=>1, 'error'=>__('Database name required'));
        $f['dbuser']        = array('type'=>'string',   'required'=>1, 'error'=>__('Username required'));
        $f['dbpass']        = array('type'=>'string',   'required'=>1, 'error'=>__('Password required'));

        $vars = array_map('trim', $vars);

        if(!Validator::process($f,$vars,$this->errors) && !$this->errors['err'])
            $this->errors['err']=__('Missing or invalid data - correct the errors and try again.');


        //Staff's email can't be same as system emails.
        if($vars['admin_email'] && $vars['email'] && !strcasecmp($vars['admin_email'],$vars['email']))
            $this->errors['admin_email']=__('Conflicts with system email above');
        //Admin's pass confirmation.
        if(!$this->errors && strcasecmp($vars['passwd'],$vars['passwd2']))
            $this->errors['passwd2']=__('Password(s) do not match');
        //Check table prefix underscore required at the end!
        if($vars['prefix'] && substr($vars['prefix'], -1)!='_')
            $this->errors['prefix']=__('Bad prefix. Must have underscore (_) at the end. e.g \'ost_\'');

        //Make sure admin username is not very predictable. XXX: feels dirty but necessary
        if(!$this->errors['username'] && in_array(strtolower($vars['username']),array('admin','admins','username','osticket')))
            $this->errors['username']=__('Bad username');

        // Support port number specified in the hostname with a colon (:)
        list($host, $port) = explode(':', $vars['dbhost']);
        if ($port && is_numeric($port) && ($port < 1 || $port > 65535))
            $this->errors['db'] = __('Invalid database port number');

        //MYSQL: Connect to the DB and check the version & database (create database if it doesn't exist!)
        if(!$this->errors) {
            if(!db_connect($vars['dbhost'],$vars['dbuser'],$vars['dbpass']))
                $this->errors['db']=sprintf(__('Unable to connect to MySQL server: %s'), db_connect_error());
            elseif(explode('.', db_version()) < explode('.', $this->getMySQLVersion()))
                $this->errors['db']=sprintf(__('osTicket requires MySQL %s or later!'),$this->getMySQLVersion());
            elseif(!db_select_database($vars['dbname']) && !db_create_database($vars['dbname'])) {
                $this->errors['dbname']=__("Database doesn't exist");
                $this->errors['db']=__('Unable to create the database.');
            } elseif(!db_select_database($vars['dbname'])) {
                $this->errors['dbname']=__('Unable to select the database');
            } else {
                //Abort if we have another installation (or table) with same prefix.
                $sql = 'SELECT * FROM `'.$vars['prefix'].'config` LIMIT 1';
                if(db_query($sql, false)) {
                    $this->errors['err'] = __('We have a problem - another installation with same table prefix exists!');
                    $this->errors['prefix'] = __('Prefix already in-use');
                } else {
                    //Try changing charset and collation of the DB - no bigie if we fail.
                    db_query('ALTER DATABASE '.$vars['dbname'].' DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci', false);
                }
            }
        }

        //bailout on errors.
        if($this->errors) return false;

        /*************** We're ready to install ************************/
        define('ADMIN_EMAIL',$vars['admin_email']); //Needed to report SQL errors during install.
        define('TABLE_PREFIX',$vars['prefix']); //Table prefix
        Bootstrap::defineTables(TABLE_PREFIX);
        Bootstrap::loadCode();

        $debug = true; // Change it to false to squelch SQL errors.

        //Last minute checks.
        if(!file_exists($this->getConfigFile()) || !($configFile=file_get_contents($this->getConfigFile())))
            $this->errors['err']=__('Unable to read config file. Permission denied! (#2)');
        elseif(!($fp = @fopen($this->getConfigFile(),'r+')))
            $this->errors['err']=__('Unable to open config file for writing. Permission denied! (#3)');

        else {
            $streams = DatabaseMigrater::getUpgradeStreams(INCLUDE_DIR.'upgrader/streams/');
            foreach ($streams as $stream=>$signature) {
                $schemaFile = INC_DIR."streams/$stream/install-mysql.sql";
                if (!file_exists($schemaFile) || !($fp2 = fopen($schemaFile, 'rb')))
                    $this->errors['err'] = sprintf(
                        __('%s: Internal Error - please make sure your download is the latest (#1)'),
                        $stream);
                elseif (
                        // TODO: Make the hash algo configurable in the streams
                        //       configuration ( core : md5 )
                        !($hash = md5(fread($fp2, filesize($schemaFile))))
                        || strcasecmp($signature, $hash))
                    $this->errors['err'] = sprintf(
                        __('%s: Unknown or invalid schema signature (%s .. %s)'),
                        $stream,
                        $signature, $hash);
                elseif (!$this->load_sql_file($schemaFile, $vars['prefix'], true, $debug))
                    $this->errors['err'] = sprintf(
                        __('%s: Error parsing SQL schema! Get help from developers (#4)'),
                        $stream);
            }
        }

        if(!$this->errors) {

            // TODO: Use language selected from install worksheet
            $i18n = new Internationalization($vars['lang_id']);
            $i18n->loadDefaultData();

            Signal::send('system.install', $this);

            $sql='SELECT `id` FROM '.TABLE_PREFIX.'sla ORDER BY `id` LIMIT 1';
            $sla_id_1 = db_result(db_query($sql, false));

            $sql='SELECT `dept_id` FROM '.TABLE_PREFIX.'department ORDER BY `dept_id` LIMIT 1';
            $dept_id_1 = db_result(db_query($sql, false));

            $sql='SELECT `tpl_id` FROM '.TABLE_PREFIX.'email_template_group ORDER BY `tpl_id` LIMIT 1';
            $template_id_1 = db_result(db_query($sql, false));

            $sql='SELECT `group_id` FROM '.TABLE_PREFIX.'groups ORDER BY `group_id` LIMIT 1';
            $group_id_1 = db_result(db_query($sql, false));

            $sql='SELECT `value` FROM '.TABLE_PREFIX.'config WHERE namespace=\'core\' and `key`=\'default_timezone_id\' LIMIT 1';
            $default_timezone = db_result(db_query($sql, false));

            //Create admin user.
            $sql='INSERT INTO '.TABLE_PREFIX.'staff SET created=NOW() '
                .", isactive=1, isadmin=1, group_id='$group_id_1', dept_id='$dept_id_1'"
                .", timezone_id='$default_timezone', max_page_size=25"
                .', email='.db_input($vars['admin_email'])
                .', firstname='.db_input($vars['fname'])
                .', lastname='.db_input($vars['lname'])
                .', username='******'username'])
                .', passwd='.db_input(Passwd::hash($vars['passwd']));
            if(!db_query($sql, false) || !($uid=db_insert_id()))
                $this->errors['err']=__('Unable to create admin user (#6)');
        }

        if(!$this->errors) {
            //Create default emails!
            $email = $vars['email'];
            list(,$domain)=explode('@',$vars['email']);
            $sql='INSERT INTO '.TABLE_PREFIX.'email (`name`,`email`,`created`,`updated`) VALUES '
                    ." ('Support','$email',NOW(),NOW())"
                    .",('osTicket Alerts','alerts@$domain',NOW(),NOW())"
                    .",('','noreply@$domain',NOW(),NOW())";
            $support_email_id = db_query($sql, false) ? db_insert_id() : 0;


            $sql='SELECT `email_id` FROM '.TABLE_PREFIX."email WHERE `email`='alerts@$domain' LIMIT 1";
            $alert_email_id = db_result(db_query($sql, false));

            //Create config settings---default settings!
            $defaults = array(
                'default_email_id'=>$support_email_id,
                'alert_email_id'=>$alert_email_id,
                'default_dept_id'=>$dept_id_1, 'default_sla_id'=>$sla_id_1,
                'default_template_id'=>$template_id_1,
                'admin_email'=>$vars['admin_email'],
                'schema_signature'=>$streams['core'],
                'helpdesk_url'=>URL,
                'helpdesk_title'=>$vars['name']);
            $config = new Config('core');
            if (!$config->updateAll($defaults))
                $this->errors['err']=__('Unable to create config settings').' (#7)';

            // Set company name
            require_once(INCLUDE_DIR.'class.company.php');
            $company = new Company();
            $company->getForm()->setAnswer('name', $vars['name']);
            $company->getForm()->save();

			foreach ($streams as $stream=>$signature) {
				if ($stream != 'core') {
                    $config = new Config($stream);
                    if (!$config->update('schema_signature', $signature))
                        $this->errors['err']=__('Unable to create config settings').' (#8)';
				}
			}
        }

        if($this->errors) return false; //Abort on internal errors.


        //Rewrite the config file - MUST be done last to allow for installer recovery.
        $configFile= str_replace("define('OSTINSTALLED',FALSE);","define('OSTINSTALLED',TRUE);",$configFile);
        $configFile= str_replace('%ADMIN-EMAIL',$vars['admin_email'],$configFile);
        $configFile= str_replace('%CONFIG-DBHOST',$vars['dbhost'],$configFile);
        $configFile= str_replace('%CONFIG-DBNAME',$vars['dbname'],$configFile);
        $configFile= str_replace('%CONFIG-DBUSER',$vars['dbuser'],$configFile);
        $configFile= str_replace('%CONFIG-DBPASS',$vars['dbpass'],$configFile);
        $configFile= str_replace('%CONFIG-PREFIX',$vars['prefix'],$configFile);
        $configFile= str_replace('%CONFIG-SIRI',Misc::randCode(32),$configFile);
        if(!$fp || !ftruncate($fp,0) || !fwrite($fp,$configFile)) {
            $this->errors['err']=__('Unable to write to config file. Permission denied! (#5)');
            return false;
        }
        @fclose($fp);

        /************* Make the system happy ***********************/

        $sql='UPDATE '.TABLE_PREFIX."email SET dept_id=$dept_id_1";
        db_query($sql, false);

        global $cfg;
        $cfg = new OsticketConfig();

        //Create a ticket to make the system warm and happy.
        $errors = array();
        $ticket_vars = $i18n->getTemplate('templates/ticket/installed.yaml')
            ->getData();
        $ticket = Ticket::create($ticket_vars, $errors, 'api', false, false);

        if ($ticket
                && ($org = Organization::objects()->order_by('id')->one())) {

            $user=User::lookup($ticket->getOwnerId());
            $user->setOrganization($org);
        }

        //TODO: create another personalized ticket and assign to admin??

        //Log a message.
        $msg=__("Congratulations osTicket basic installation completed!\n\nThank you for choosing osTicket!");
        $sql='INSERT INTO '.TABLE_PREFIX.'syslog SET created=NOW(), updated=NOW(), log_type="Debug" '
            .', title="osTicket installed!"'
            .', log='.db_input($msg)
            .', ip_address='.db_input($_SERVER['REMOTE_ADDR']);
        db_query($sql, false);

        return true;
    }
Example #26
0
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkSeveralRightsOr(array('notification' => 'r', 'config' => 'w'));
Html::header(_n('Notification', 'Notifications', 2), $_SERVER['PHP_SELF'], "config", "mailing", -1);
if (isset($_POST['activate'])) {
    $config = new Config();
    $tmp['id'] = $CFG_GLPI['id'];
    $tmp['use_mailing'] = 1;
    $config->update($tmp);
    Html::back();
}
if (!$CFG_GLPI['use_mailing']) {
    if (Session::haveRight("config", "w")) {
        echo "<div class='center'>";
        Html::showSimpleForm($_SERVER['PHP_SELF'], 'activate', __('Enable followup via email'));
        echo "</div>";
    }
} else {
    if (!Session::haveRight("config", "r") && Session::haveRight("notification", "r") && $CFG_GLPI['use_mailing']) {
        Html::redirect($CFG_GLPI["root_doc"] . '/front/notification.php');
    } else {
        echo "<table class='tab_cadre'>";
        echo "<tr><th>" . _n('Notification', 'Notifications', 2) . "</th></tr>";
        if (Session::haveRight("config", "r")) {
Example #27
0
    }
    if ($offset != -1) {
        if (restoreMySqlDump($DB, $path . "/" . $_GET["file"], $duree)) {
            echo "<div class='center'>" . "<a href=\"backup.php?file=" . $_GET["file"] . "&amp;duree={$duree}&amp;offset=" . "{$offset}&amp;cpt={$cpt}&amp;donotcheckversion=1\">";
            echo __('Automatic redirection, else click') . "</a>";
            echo "<script language='javascript' type='text/javascript'>" . "window.location=\"backup.php?file=" . $_GET["file"] . "&duree={$duree}&offset={$offset}&cpt={$cpt}&donotcheckversion=1\";" . "</script></div>";
            Html::glpi_flush();
            exit;
        }
    } else {
        DBmysql::optimize_tables(NULL, true);
        // Compatiblity for old version for utf8 complete conversion
        $cnf = new Config();
        $input['id'] = 1;
        $input['utf8_conv'] = 1;
        $cnf->update($input);
    }
}
if (isset($_POST["delfile"])) {
    if (isset($_POST['file']) && $_POST["file"] != "") {
        $filename = $_POST["file"];
        if (is_file($path . "/" . $_POST["file"])) {
            unlink($path . "/" . $_POST["file"]);
            // TRANS: %s is a file name
            echo "<div class ='center spaced'>" . sprintf(__('%s deleted'), $filename) . "</div>";
        }
    }
}
if (Session::haveRight('backup', Backup::CHECKUPDATE)) {
    echo "<div class='center spaced'><table class='tab_glpi'>";
    echo "<tr class='tab_bg_1'><td colspan='4' class='center b'>";
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.

GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkRight("config", READ);
$config = new Config();
$_POST['id'] = 1;
if (!empty($_POST["update_auth"])) {
    $config->update($_POST);
    Html::back();
}
if (!empty($_POST["update"])) {
    $config->update($_POST);
    Html::redirect(Toolbox::getItemTypeFormURL('Config'));
}
Html::header(Config::getTypeName(1), $_SERVER['PHP_SELF'], "config", "config");
$config->display(array('id' => 1));
Html::footer();
 /**
  * Check if new version is available
  *
  * @param $auto                  boolean: check done autically ? (if not display result)
  *                                        (true by default)
  * @param $messageafterredirect  boolean: use message after redirect instead of display
  *                                        (false by default)
  *
  * @return string explaining the result
  **/
 static function checkNewVersionAvailable($auto = true, $messageafterredirect = false)
 {
     global $CFG_GLPI;
     if (!$auto && !Session::haveRight('backup', Backup::CHECKUPDATE)) {
         return false;
     }
     if (!$auto && !$messageafterredirect) {
         echo "<br>";
     }
     $error = "";
     $latest_version = self::getURLContent("http://glpi-project.org/latest_version", $error);
     if (strlen(trim($latest_version)) == 0) {
         if (!$auto) {
             if ($messageafterredirect) {
                 Session::addMessageAfterRedirect($error, true, ERROR);
             } else {
                 echo "<div class='center'>{$error}</div>";
             }
         } else {
             return $error;
         }
     } else {
         $splitted = explode(".", trim($CFG_GLPI["version"]));
         if ($splitted[0] < 10) {
             $splitted[0] .= "0";
         }
         if ($splitted[1] < 10) {
             $splitted[1] .= "0";
         }
         $cur_version = $splitted[0] * 10000 + $splitted[1] * 100;
         if (isset($splitted[2])) {
             if ($splitted[2] < 10) {
                 $splitted[2] .= "0";
             }
             $cur_version += $splitted[2];
         }
         $splitted = explode(".", trim($latest_version));
         if ($splitted[0] < 10) {
             $splitted[0] .= "0";
         }
         if ($splitted[1] < 10) {
             $splitted[1] .= "0";
         }
         $lat_version = $splitted[0] * 10000 + $splitted[1] * 100;
         if (isset($splitted[2])) {
             if ($splitted[2] < 10) {
                 $splitted[2] .= "0";
             }
             $lat_version += $splitted[2];
         }
         if ($cur_version < $lat_version) {
             $config_object = new Config();
             $input["id"] = 1;
             $input["founded_new_version"] = $latest_version;
             $config_object->update($input);
             if (!$auto) {
                 if ($messageafterredirect) {
                     Session::addMessageAfterRedirect(sprintf(__('A new version is available: %s.'), $latest_version));
                     Session::addMessageAfterRedirect(__('You will find it on the GLPI-PROJECT.org site.'));
                 } else {
                     echo "<div class='center'>" . sprintf(__('A new version is available: %s.'), $latest_version) . "</div>";
                     echo "<div class='center'>" . __('You will find it on the GLPI-PROJECT.org site.') . "</div>";
                 }
             } else {
                 if ($messageafterredirect) {
                     Session::addMessageAfterRedirect(sprintf(__('A new version is available: %s.'), $latest_version));
                 } else {
                     return sprintf(__('A new version is available: %s.'), $latest_version);
                 }
             }
         } else {
             if (!$auto) {
                 if ($messageafterredirect) {
                     Session::addMessageAfterRedirect(__('You have the latest available version'));
                 } else {
                     echo "<div class='center'>" . __('You have the latest available version') . "</div>";
                 }
             } else {
                 if ($messageafterredirect) {
                     Session::addMessageAfterRedirect(__('You have the latest available version'));
                 } else {
                     return __('You have the latest available version');
                 }
             }
         }
     }
     return 1;
 }
Example #30
0
 /**
  * Handle the matching route callback
  * 
  * @param string $method HTTP Method
  * @param string $uri    URI/route to match
  * 
  * @return null
  */
 private function routeMatch($method, $uri, $matches = null)
 {
     // given our URI, see if we have a match in our Config & update!
     $config = Config::getConfig('route::' . $uri);
     if ($config !== null) {
         Config::update($config);
     }
     // route match!
     $this->log->log('ROUTE MATCH [' . strtoupper($method) . ']: ' . $uri);
     //see if we have params to match the items to
     if ($matches !== null && isset($this->params[$method][$uri])) {
         $params = $this->params[$method][$uri];
         // match them up
         $tmp = array();
         foreach ($matches as $index => $match) {
             if (isset($params[$index])) {
                 $param = str_replace(':', '', $params[$index]);
                 $tmp[$param] = $match;
             }
         }
         if (!empty($tmp)) {
             $matches = $tmp;
         }
     }
     $routeClosure = $this->routes[$method][$uri]($matches);
     $content = $this->view->render($routeClosure);
     echo $content;
 }