Revize ed986471
Přidáno uživatelem Ondřej Fibich před téměř 6 roky(ů)
application/controllers/setup_config.php | ||
---|---|---|
}
|
||
else
|
||
{
|
||
if (Settings::get('db_schema_version'))
|
||
{
|
||
Settings::set('index_page', 0);
|
||
}
|
||
|
||
$this->redirect('setup_config/setup');
|
||
}
|
||
|
||
... | ... | |
$form_data = $form->as_array(FALSE);
|
||
|
||
// test connection to database
|
||
$con = @mysql_connect(
|
||
$form_data['db_host'],
|
||
$form_data['db_user'],
|
||
$form_data['db_password']
|
||
);
|
||
|
||
$db = @mysql_select_db($form_data['db_name'], $con);
|
||
|
||
if (!$db)
|
||
$database = new Database(array
|
||
(
|
||
'type' => (defined('PHP_VERSION_ID') && PHP_VERSION_ID >= 60000) ? 'mysqli' : 'mysql',
|
||
'host' => $form_data['db_host'],
|
||
'user' => $form_data['db_user'],
|
||
'pass' => $form_data['db_password'],
|
||
'database' => $form_data['db_name'],
|
||
'port' => FALSE,
|
||
'socket' => FALSE
|
||
));
|
||
|
||
try
|
||
{
|
||
$result = @mysql_query("
|
||
CREATE DATABASE `" . mysql_escape_string($form_data['db_name']) . "`
|
||
CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||
", $con);
|
||
|
||
if ($result)
|
||
{
|
||
$db = @mysql_select_db($form_data['db_name'], $con);
|
||
}
|
||
$database->connect();
|
||
$con = TRUE;
|
||
}
|
||
catch (Exception $ex)
|
||
{
|
||
$con = FALSE;
|
||
$error_cause = $ex->getMessage();
|
||
}
|
||
|
||
$view = new View('setup_config/main');
|
||
$view->content = new View('setup_config/setup');
|
||
|
||
// cannot connect to database => form data are bad
|
||
if (!$con OR !$db)
|
||
if (!$con)
|
||
{
|
||
$view->content->error_cause = $error_cause;
|
||
$view->content->error = TRUE;
|
||
}
|
||
// successfully connect to database, we can create config file
|
application/libraries/MY_Controller.php | ||
---|---|---|
// This part only needs to be run once
|
||
if (self::$instance === NULL)
|
||
{
|
||
// init settings
|
||
$this->settings = new Settings();
|
||
|
||
$not_setup = !file_exists('config.php') || !file_exists('.htaccess');
|
||
|
||
// change setting for non-setup in order to prevent database init
|
||
// in Settings
|
||
if ($not_setup)
|
||
{
|
||
Settings::set_offline_mode(TRUE);
|
||
|
||
$this->settings->set('index_page', !file_exists('.htaccess'));
|
||
// Choose all automatically for setup (see url helper)
|
||
$this->settings->set('domain', '');
|
||
$this->settings->set('suffix', '');
|
||
$this->settings->set('protocol', '');
|
||
}
|
||
|
||
// init sessions
|
||
$this->session = Session::instance();
|
||
|
||
... | ... | |
// Die
|
||
die();
|
||
}
|
||
|
||
// init settings
|
||
$this->settings = new Settings();
|
||
|
||
// if true, freenetis will run in popup mode (without header and menu)
|
||
$this->popup = (isset($_GET['popup']) && $_GET['popup']) ? 1 : 0;
|
||
... | ... | |
$this->noredirect = ($this->input->get('noredirect') || $this->input->post('noredirect'));
|
||
|
||
// config file doesn't exist, we must create it
|
||
if (!file_exists('config.php') || !file_exists('.htaccess'))
|
||
if ($not_setup)
|
||
{
|
||
// protection before loop
|
||
if (url_lang::current(1) == 'setup_config')
|
||
return;
|
||
|
||
if (!file_exists('.htaccess'))
|
||
{
|
||
Settings::set('index_page', 1);
|
||
}
|
||
|
||
url::redirect('setup_config');
|
||
}
|
||
|
application/libraries/Settings.php | ||
---|---|---|
* @var Config_Model
|
||
*/
|
||
private static $config_model = NULL;
|
||
|
||
/**
|
||
* When turned ON no DB queries are performed. Useful for non-setup
|
||
* environment.
|
||
*
|
||
* @var bool
|
||
*/
|
||
private static $offline_mode = FALSE;
|
||
|
||
/**
|
||
* Variable for cache
|
||
... | ... | |
// not connected? connect!
|
||
if (!self::$config_model)
|
||
{
|
||
if (self::$offline_mode)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
try
|
||
{
|
||
// create config model
|
||
... | ... | |
{
|
||
// init
|
||
self::init();
|
||
|
||
|
||
// if cache is enabled, return it from it
|
||
if ($cache && isset(self::$cache[$key]))
|
||
{
|
||
return self::$cache[$key];
|
||
}
|
||
|
||
$value = '';
|
||
|
||
// try if query return exception, for example config table doesn't exist
|
||
try
|
||
{
|
||
$value = self::$config_model->get_value_from_name($key);
|
||
if (!self::$offline_mode)
|
||
{
|
||
$value = self::$config_model->get_value_from_name($key);
|
||
}
|
||
}
|
||
catch (Kohana_Database_Exception $e)
|
||
{
|
||
$value = '';
|
||
}
|
||
|
||
// if we find not-null value, return it
|
||
... | ... | |
*/
|
||
public static function set($key, $value)
|
||
{
|
||
if (self::$offline_mode)
|
||
{
|
||
self::cache_value_set($key, $value);
|
||
return FALSE;
|
||
}
|
||
|
||
// init
|
||
self::init();
|
||
|
application/vendors/deb/debianization.sh | ||
---|---|---|
|
||
NAMES=(freenetis freenetis-monitoring freenetis-redirection freenetis-dhcp \
|
||
freenetis-ssh-keys freenetis-qos)
|
||
DEBIANS=(lenny squeeze wheezy jessie)
|
||
DEBIANS=(lenny squeeze wheezy jessie stretch)
|
||
VERSION=$1
|
||
|
||
if [ $# -eq 2 ] || [ $# -eq 3 ]; then
|
application/vendors/deb/freenetis/control.stretch | ||
---|---|---|
Priority: optional
|
||
Section: web
|
||
Pre-Depends: debconf (>= 0.5) | debconf-2.0
|
||
Depends: coreutils (>= 6.10-6), wget (>= 1.11-4.1), grep (>= 2.5.3), apache2, php, php-curl, libapache2-mod-php, php-mysql, mysql-client, php-mcrypt, php-mbstring, php-gd, php-snmp, php-imap, cron | anacron | cron-daemon, locales
|
||
Suggests: mysql-server (>= 5.0.0), mysql-client
|
||
Architecture: all
|
||
Maintainer: Ondrej Fibich <ondrej.fibich@gmail.com>
|
||
Homepage: http://www.freenetis.org
|
||
Description: Information system for managing non-profit networks
|
||
FreenetIS is multilingual information system for managing non-profit networks.
|
||
.
|
||
It is capable to manage:
|
||
- users and their groups;
|
||
- double-entry accounting system (payments, double-entry transfers,
|
||
bank transfers, accounts, bank accounts, cash flow);
|
||
- network infrastructure (devices, segments, interfaces, IP addresses,
|
||
subnets, VLANs, VLAN interfaces, bridges, ports);
|
||
- network management (device monitoring, DHCP servers configuration,
|
||
traffic statistics, QoS);
|
||
- notifications of users (traffic redirection, e-mail messages, SMS messages);
|
||
- work reporting of active users and work approval;
|
||
- lists of calls and billing of VoIP;
|
||
- etc.
|
||
Description-cs.UTF-8: Informační systém pro počítačové sítě, provozované neziskovou organizací
|
||
FreenetIS je vícejazyčný informační systém pro počítačové sítě, provozované
|
||
neziskovou organizací.
|
||
.
|
||
Je schopen spravovat:
|
||
- uživatele a jejich skupiny;
|
||
- podvojné účty organizace (platby, podvojné převody, bankovní převody,
|
||
bankovní účty, cash flow);
|
||
- síťová infrastruktura (zařízení, segmenty, rozhraní, IP adresy, podsítě,
|
||
VLANy, VLAN rozhraní, bridge, porty);
|
||
- správa sítě (monitorování zařízení, konfigurace DHCP serverů,
|
||
statistiky provozu, QoS);
|
||
- upozorňování uživatelů (přesměrování provozu, e-mailové zprávy, SMS zprávy);
|
||
- práce aktivních uživatelů a jejich schvalování;
|
||
- výpisy volání a placení VoIP po napojení na ústřednu;
|
||
- atd.
|
application/vendors/deb/freenetis/debianization.sh | ||
---|---|---|
echo "Package: ${NAME}" >> DEBIAN/control
|
||
echo "Version: ${VERSION}-${DEBIAN}" >> DEBIAN/control
|
||
echo "Installed-Size: ${SIZE}" >> DEBIAN/control
|
||
cat ../../${NAME}/control >> DEBIAN/control
|
||
if [ $DEBIAN = "stretch" ]; then
|
||
cat ../../${NAME}/control.stretch >> DEBIAN/control
|
||
else
|
||
cat ../../${NAME}/control >> DEBIAN/control
|
||
fi
|
||
|
||
# scripts ######################################################################
|
||
|
||
cp -a -f ../../${NAME}/preinst DEBIAN/preinst
|
||
if [ $DEBIAN = "jessie" ]; then
|
||
if [ $DEBIAN = "jessie" ] || [ $DEBIAN = "stretch" ]; then
|
||
cp -a -f ../../${NAME}/postinst.jessie DEBIAN/postinst
|
||
else
|
||
cp -a -f ../../${NAME}/postinst DEBIAN/postinst
|
||
fi
|
||
cp -a -f ../../${NAME}/prerm DEBIAN/prerm
|
||
if [ $DEBIAN = "jessie" ]; then
|
||
if [ $DEBIAN = "jessie" ] || [ $DEBIAN = "stretch" ]; then
|
||
cp -a -f ../../${NAME}/postrm.jessie DEBIAN/postrm
|
||
else
|
||
cp -a -f ../../${NAME}/postrm DEBIAN/postrm
|
application/views/setup_config/setup.php | ||
---|---|---|
<?php if (isset($error) && $error): ?>
|
||
<h2><?php echo __('Cannot connect to database') ?></h2>
|
||
<?php if (isset($error_cause) && $error_cause): ?>
|
||
<p class="error"><?php echo __('Error') . ': ' . $error_cause ?></p>
|
||
<?php endif ?>
|
||
<p><?php echo __('It can means that username/password/host are bad or host is unavailable.') ?></p>
|
||
<ul>
|
||
<li><?php echo __('Are you really sure that you use correct username and password?') ?></li>
|
db_upgrades/upgrade_1.1.0.php | ||
---|---|---|
`comments_thread_id` INT NULL DEFAULT NULL ,
|
||
PRIMARY KEY ( `id` ),
|
||
FOREIGN KEY `closed_by_user_id_fk` (`closed_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
|
||
FOREIGN KEY `comments_thread_id_fk` (`comments_thread_id`) REFERENCES `comments_threads` (`id`) ON DELETE SET NULL
|
||
FOREIGN KEY `log_queues_comments_thread_id_fk` (`comments_thread_id`) REFERENCES `comments_threads` (`id`) ON DELETE SET NULL
|
||
) ENGINE = InnoDB;",
|
||
|
||
/**
|
||
... | ... | |
PRIMARY KEY (`id`),
|
||
INDEX `since_index` (`since`),
|
||
INDEX `until` (`until`),
|
||
FOREIGN KEY `member_id_fk` (`member_id`) REFERENCES `members` (`id`) ON DELETE CASCADE
|
||
FOREIGN KEY `members_whitelists_member_id_fk` (`member_id`) REFERENCES `members` (`id`) ON DELETE CASCADE
|
||
) ENGINE = InnoDB COMMENT = 'Redirection member white list.';",
|
||
/* Import old data */
|
||
// association
|
tests/deb_package_check.sh | ||
---|---|---|
MODULE=freenetis
|
||
VERSION=`cat version.php | grep "FREENETIS_VERSION" | cut -d"'" -f 4`
|
||
DEB_PREFIX=deb_packages/freenetis_${VERSION}
|
||
DEBIANS="lenny squeeze wheezy jessie"
|
||
DEBIANS="lenny squeeze wheezy jessie stretch"
|
||
|
||
cd application/vendors/deb/freenetis
|
||
mkdir ../deb_packages 2>/dev/null || true # fix in source
|
Také k dispozici: Unified diff
Refs #1101: Support for Debian Stretch (PHP 7.0 + Maria DB 15.1). Improved setup that no longer support database creation (in Maria DB it is hard to do so from non-root user due to security restrictions), database setup error cause was added, disabling Settings DB queries in non-setup environment. In order to fix DB init some FK indexes/constrains must have been renamed in 1.1.0 SQL script (Maria DB enforces uniqueness on FK names).