Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1856

Přidáno uživatelem Ondřej Fibich před více než 11 roky(ů)

Novinky:
- fixes #35: Moznost casoveho vymezeni platnosti docasne bile listiny

Upravy:
- upravy CSS menu (roztazeni)

Zobrazit rozdíly:

freenetis/branches/1.1/db_upgrades/upgrade_1.1.0~alpha11.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* This upgrade is not equal to any of previos upgrades
*
* @author Ondřej Fibich <ondrej.fibich@gmail.com>
*/
$upgrade_equal_to['1.1.0~alpha11'] = array();
/**
* Whitelist (#35)
*
* @author Ondřej Fibich <ondrej.fibich@gmail.com>
*/
$upgrade_sql['1.1.0~alpha11'] = array
(
/* Create new structure */
"CREATE TABLE `members_whitelists` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`member_id` INT(11) NOT NULL,
`permanent` TINYINT(1) NOT NULL,
`since` DATE NOT NULL,
`until` DATE NOT NULL,
`comment` TEXT,
PRIMARY KEY (`id`),
INDEX `since_index` (`since`),
INDEX `until` (`until`),
FOREIGN KEY `member_id_fk` (`member_id`) REFERENCES `members` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB COMMENT = 'Redirection member white list.';",
/* Import old data */
// association
"INSERT INTO `members_whitelists` (`id`, `member_id`, `permanent`, `since`, `until`)
SELECT NULL, m.id, 1, entrance_date AS since, '9999-12-31' AS until
FROM members m
WHERE m.id = 1",
// add permanent whitelists from current IP address settings
"INSERT INTO `members_whitelists` (`id`, `member_id`, `permanent`, `since`, `until`)
SELECT NULL, m.id, 1, '" . date('Y-m-d') . "' AS since, '9999-12-31' AS until
FROM (
SELECT me.id
FROM members me
JOIN users u ON u.member_id = me.id
JOIN devices d ON d.user_id = u.id
JOIN ifaces i ON i.device_id = d.id
JOIN ip_addresses ip ON ip.iface_id = i.id
WHERE ip.whitelisted = 1
UNION
SELECT me.id
FROM members me
JOIN ip_addresses ip ON ip.member_id = me.id
WHERE ip.whitelisted = 1
UNION
SELECT uu.member_id
FROM users uu
JOIN users_contacts uc ON uc.user_id = uu.id
WHERE uc.whitelisted = 1
) m
GROUP BY m.id",
// add temporal whitelists from current IP address settings (for one week)
"INSERT INTO `members_whitelists` (`id`, `member_id`, `permanent`, `since`, `until`)
SELECT NULL, m.id, 0, '" . date('Y-m-d') . "' AS since, '" . date('Y-m-d', time() + 604800) . "' AS until
FROM (
SELECT me.id
FROM members me
JOIN users u ON u.member_id = me.id
JOIN devices d ON d.user_id = u.id
JOIN ifaces i ON i.device_id = d.id
JOIN ip_addresses ip ON ip.iface_id = i.id
WHERE ip.whitelisted = 2
UNION
SELECT me.id
FROM members me
JOIN ip_addresses ip ON ip.member_id = me.id
WHERE ip.whitelisted = 2
UNION
SELECT uu.member_id
FROM users uu
JOIN users_contacts uc ON uc.user_id = uu.id
WHERE uc.whitelisted = 2
) m
GROUP BY m.id",
/* Clean old structure */
// remove old columns
"ALTER TABLE `ip_addresses` DROP `whitelisted`",
"ALTER TABLE `users_contacts` DROP `whitelisted`",
/* Speed enhance for member_fees */
"ALTER TABLE `members_fees` ADD INDEX ( `activation_date` , `deactivation_date` ) ;",
);
freenetis/branches/1.1/media/css/style.css
color:#544A5C;
font-size:140%;
font-weight:normal;
padding-bottom:5px;
padding-bottom:10px;
padding-left: 15px;
}
#menu li.account, #menu li.transfer, #menu li.users, #menu li.approval, #menu li.networks, #menu li.administration, #menu li.redirection, #menu li.backup, #menu li.help {
padding-left:45px;
padding-left:30px;
padding-top:10px;
list-style-type:none;
background: #FFFFFF url(../images/layout/bg-gray2.gif) repeat-x;
freenetis/branches/1.1/application/i18n/cs_CZ/texts.php
'add new vlan interface to interface' => 'Přidat nové VLAN rozhraní k rozhraní',
'add new vlan' => 'Přidat nový VLAN',
'add new voip transfer' => 'Přidat nový VoIP převod',
'add new whitelist' => 'Přidat novou bílou listinu',
'add new whole device' => 'Přidat nové celé zařízení',
'add new whole device for user' => 'Přidat nové celé zařízení pro uživatele',
'add new wireless interface' => 'Přidat nové bezdrátové rozhraní',
......
'connected to interface' => 'Připojeno k rozhraní',
'connecting place' => 'Přípojné místo',
'connection request' => 'Žádost o připojení',
'list of connection requests' => 'Seznam žádostí o připojení',
'connection owner' => 'Vlastník připojení',
'connection request has been rejected' => 'Požadavek na připojení byl zamítnut.',
'connection request has been succesfully edited' => 'Žádost o připojení byla úspěšně editována.',
......
'edit work report' => 'Upravit pracovní výkaz',
'editable' => 'Upravitelné',
'edit wireless setting' => 'Upravit bezdrátové nastavení',
'edit whitelist' => 'Upravit bílou listinu',
'edited' => 'Upravil',
'editing of account' => 'Úprava účtu',
'editing of address point' => 'Úprava adresního bodu',
......
'interval is required' => 'Interval je povinný',
'interval of interruption collides with another interruption of this member' => 'Interval přerušení koliduje s jiným přerušením tohoto člena',
'interval of loop' => 'Interval opakování',
'interval of whitelist collides with another whitelist of this member' => 'Interval bílé listiny koliduje s jinou bílou listinou člena.',
'interval of update' => 'Interval aktualizace',
'invalid connect to interface - already has different link' => 'Nelze se připojit k rozhraní - již má jinou linku',
'invalid date' => 'Neplatné datum!',
......
'list of all users' => 'Seznam všech uživatelů',
'list of calls' => 'Výpis hovorů',
'list of calls for account' => 'Výpis hovorů pro účet',
'list of connection requests' => 'Seznam žádostí o připojení',
'list of members calls' => 'Výpis hovorů člena',
'list of members whitelists' => 'Seznam bílých listin člena',
'list of routerboard backups' => 'Seznam záloh routerboardů',
'list of users of member' => 'Seznam uživatelů člena',
'list of tariffs of member' => 'Seznam tarifů člena',
......
'weekend' => 'Víkend',
'whitelist' => 'Bílá listina',
'whitelist setting has been successfully set' => 'Bílá listina byla úspěšně nastavena.',
'whitelist has been succesfully added' => 'Bílá listina byla úspěšně přidána',
'whitelist has been succesfully edited' => 'Bílá listina byla úspěšně upravena',
'whitelist has been succesfully deleted' => 'Bílá listina byla úspěšně smazána',
'whitelist has not been added' => 'Bílá listina nebyla přidána',
'whitelist has not been edited' => 'Bílá listina nebyla upravena',
'whitelist has not been deleted' => 'Bílá listina nebyla smazána',
'whitelists' => 'Bílé listiny',
'whole d' => 'Celé z.',
'without change' => 'Beze změny',
'without prefixes' => 'Bez předčíslí',
freenetis/branches/1.1/application/i18n/cs_CZ/help.php
'axo_count' => 'Jedná se o počet položek AXO objektů přiřazených k pravidlu. AXO objekt označuje objekty, nad kterými lze provádět operace.',
'bank_accounts' => 'Bankovní účty jsou primárně vytvářeny automaticky během importu bankovního výpisu. V případě úspěšného rozpoznání platby je rovnou tento bankovní účet svázán s rozpoznaným členem. V případě, že člen v budoucnu splete variabilní symbol, pak toto ukládání bankovních účtů usnadňuje identifikaci platby v případě, že opět platil ze stejného účtu. Ruční přidávání bankovních účtů je vyhrazeno pro nestandardní případy.',
'bank_accounts_of_association' => 'Sdružení může mít více bankovních účtů, jeden je vždy založen po instalaci, nicméně je časem možné přidávat další. Na příslušném bankovním účtu pak lze provádět import výpisů.',
'clean_temp_whitelist' => 'Po importu vymaže členy z dočasné bílé listiny',
'connection_request_device_type' => 'Obvykle zařízení, se kterým se snažíte přistoupit na internet (PC, notebook, mobil).',
'connection_request_info' => 'Pro připojení neregistrované přípojky/zařízení vyplňte prosím tento formulář.<br/>Rozhodnutí o vyhovění/zamítnutí Vaší žádosti Vám bude zasláno na Vaši e-mailovou adresu.',
'connection_request_info_short' => 'Pro připojení neregistrované přípojky/zařízení vyplňte prosím tento formulář.',
......
'fio_view_name' => 'Název pohledu, je potřeba si vytvořit vlastní pohled (filtr) v internetovém bankovnictví, ve kterém budou zobrazeny všechny dostupné sloupce (celkem 18).',
'gateway' => 'Určuje, zda-li je tato IP adresa bránou ve své podsíti. Typicky má toto nastavena každá IP adresa končící na jedničku v síti s prefixem 24.',
'gps_coordinates' => 'GPS souřadnice může být ve tvaru desetinného čísla, nebo: hodiny°minuty\'sekundy&quot.',
'ignore_whitelist' => 'Umožňuje této zprávě, je-li aktivována, ignorovat bílou listinu. Určeno pro velmi speciální případy, například pokud je připojen městský úřad, který je na trvalé bílé listině, aby nebyl obtěžován a i přesto chceme jeho počítače přesměrovat kvůli informaci o výpadku.',
'ignore_whitelist' => 'Umožňuje této zprávě, je-li aktivována, ignorovat bílou listinu. Určeno pro velmi speciální případy, například pokud je připojen městský úřad, který je na trvalé bílé listině, aby nebyl obtěžován a i přesto chceme jeho počítače přesměrovat nebo upozornit kvůli informaci o výpadku.',
'initial_immunity' => 'Počet dní, po které nemá být nový člen upozorňován na placení. Výchozí hodnota je 14 dní.',
'initial_debtor_immunity' => 'Počet dní, po které nemá být nový člen blokován a upozorňován jako dlužník. Výchozí hodnota je 35 dní.',
'log_queues_info' => 'Byly zaznamenány chyby (systému nebo některých síťových prvků), %s prosím a proveďte nezbytné akce pro jejich nápravu.',
......
'self_cancel_text' => 'Text pro odkaz určený k zrušení přesměrování členem. Tento text se zobrazuje v patičce stránky přesměrovanému členovi.',
'self_cancel_url' => 'Je to adresa na centrální bráně, na které běží lighthttpd web server. Pravidla firewallu na centrální bráně takto poznají uživatelův úmysl ukončit přesměrování. Stránka tedy může obsahovat stručnou informaci pro uživatele o ukončení přesměrování a případný rozcestník.',
'service' => 'Je-li pro tuto IP adresu zapnuta služba, pak je tato IP adresa využívána pro Radius. Typicky jde o IP adresy aktivních síťových prvků, na které je se možné pomocí Radiusu přihlásit.',
'set_whitelist_to_member' => 'Trvalá bílá listina je seznam takových IP adres, pro které neplatí přesměrování. Jde například o důležitou partnerskou instituci zapojenou do sítě, například městský úřad apod. Všechna systémová přesměrování tedy nemohou ve výchozím stavu obtěžovat počítače s IP adresou na bílé listině. Lze ovšem vytvořit takové zprávy, které budou ignorovat tuto listinu, např. informování o nadcházejícím výpadku. Pro dočasnou bílou listinu platí to samé, ale IP adresy v ní jsou po určeném čase z této listiny mazány. Např. uživatel byl přesměrován kvůli neplacení a chceme mu umožnit krátkodobý přístup na internet do internetového bankovnictví.',
'set_whitelist_to_member' => 'Trvalá bílá listina je seznam členů, pro které neplatí přesměrování. Jde například o důležitou partnerskou instituci zapojenou do sítě, například městský úřad apod. Všechna systémová přesměrování tedy nemohou ve výchozím stavu obtěžovat počítače s IP adresou na bílé listině. Lze ovšem vytvořit takové zprávy, které budou ignorovat tuto listinu, např. informování o nadcházejícím výpadku. Pro dočasnou bílou listinu platí to samé, ale IP adresy v ní jsou po určeném čase z této listiny mazány. Např. uživatel byl přesměrován kvůli neplacení a chceme mu umožnit krátkodobý přístup na internet do internetového bankovnictví.',
'sms_enabled' => 'Určuje zda-li zasílání SMS zpráv ze systému do sítě tohoto operátora je povoleno.',
'ssh' => 'Klíč je použit pro přístup k zařízením, která spravuje tento uživatel.',
'subnet_dhcp' => 'Ukazatel, zda-li je na podsíti spuštěn DHCP server. Využívá se pro export zařízení.',
......
'variable_symbol' => 'Variabilní symbol slouží k jednoznačnému určení příchozí platby člena.',
'voip_login_data' => 'Níže uvedené údaje využijte pro nastavení vašeho VoIP telefonu. Login použijte pro požadované přihlašovací či zobrazovací jméno, heslo pro heslo k účtu a adresa proxy serveru odpovídá adrese telefonní ústředny. Údaj CLIPS je jen dodatečná informace pro příjemce hovoru, pokud vás nemá v seznamu. Doporučujeme nastavit stejné jako je vaše číslo.',
'voip_status' => 'Stav Registrovaný znamená, že telefonní klient ať už fyzický či softwarový je zapnut a správně připojen k ústředně. Stav Neregistrovaný platí pro opak. Pro VoIP telefon registrovaný v ústředně se pak zobrazuje jeho aktuální IP adresa, port a čas vypršení registrace.',
'whitelist' => 'IP adresám, které jsou umístěny na bílé listině, je sice možné aktivovat přesměrování, ale nebudou odeslány na centrální router. Tedy nebudou přesměrovány, dokud nebudou odebrány z bílé listiny. Dočasná bílá listina se od trvalé liší v tom, že je pravidelně promazávána.',
'whitelist' => 'Členům, kteří jsou umístěny na bílé listině, je sice možné aktivovat přesměrování (upozornění), ale nebudou odeslány na centrální router (odeslány zprávy). Tedy nebudou přesměrovány (upozorněni), dokud nebudou odebráni z bílé listiny. Dočasná bílá listina se od trvalé liší v tom, že je stanovena jen pro určitý časový interval.',
'your mysql password' => 'Vaše MySQL heslo.',
'your mysql username' => 'Vaše MySQL uživatelské jméno.',
);
freenetis/branches/1.1/application/i18n/en_US/help.php
'approval_state' => 'State with the format in Agree / Disagree / Abstain.',
'bank_accounts' => 'Bank accounts are primarily created automatically during import bank statement. In case of successful recognition of payment is equal to the bank account linked with recognized member. In the event that a member makes a mistake in the future variable symbol, then the saving bank accounts, facilitating identification of the payment in case the back pay from the same account. Manually adding a bank account is reserved for unusual cases.',
'bank_accounts_of_association' => 'The Association may have multiple bank accounts, one is always based upon the installation, however, it is possible to add more time. The relevant bank account can then perform the import statements.',
'clean_temp_whitelist' => 'Removes members from temporary whilelist after import',
'connection_request_device_type' => 'Typically the device that you are trying to access the internet (PC, laptop, mobile, ...).',
'connection_request_info' => 'To connect unregistered connections/device please fill out this form.<br/>Decision on the pass/rejection of your request will be sent to your e-mail address.',
'connection_request_info_short' => 'To connect unregistered connections/device please fill out this form.',
......
'self_cancel_text' => 'The text for link is designed to cancel mamber redirection. This text is displayed in the bottom of the page redirected member.',
'self_cancel_url' => 'It addresses the central gate, which runs lighthttpd web server. Firewall rules on the central gate thus identify the user\'s intention to terminate redirection. Page therefore may contain brief information for the user to terminate any links and redirects.',
'service' => 'If the IP address for this service is enabled, then this IP address used for the Radius. Typically, these IP addresses of active network elements on which it is possible to log on via Radius.',
'set_whitelist_to_member' => 'Permanent white list is a list of such IP addresses for which it does not redirect. This is such an important partner institution involved in the network, such as municipal authorities, etc. Any diversion system is not in default bother computer with an IP address on the white list. But you can create a message that will ignore this list, such as informing of impending failure. For temporary whitelist does the same, but IP addresses in it after a specified time from the instrument clean. Eg. user was redirected due to non-payment and we want him to allow short-term Internet access to internet banking.',
'set_whitelist_to_member' => 'Permanent white list is a list of members for which it does not redirect. This is such an important partner institution involved in the network, such as municipal authorities, etc. Any diversion system is not in default bother computer with an IP address on the white list. But you can create a message that will ignore this list, such as informing of impending failure. For temporary whitelist does the same, but IP addresses in it after a specified time from the instrument clean. Eg. user was redirected due to non-payment and we want him to allow short-term Internet access to internet banking.',
'sms_enabled' => 'Specifies whether to send SMS messages from the system into a network of this operator is allowed.',
'ssh' => 'Key is used for accessing devices, which are administrated by this user.',
'subnet_dhcp' => 'Indicator whether there is a running dhcp server on this subnet. It is used for export of devices.',
......
'variable_symbol' => 'Variable symbol is used to unambiguously determine the incoming payments member.',
'voip_login_data' => 'Following settings are used to set up your VoIP phone. Login is for your login name or display name, password is for your account password and proxy server address is address of your telephone exchange. We recommend setting CLIP the same as your phone number. CLIP is displayed to receiver as your additional identification.',
'voip_status' => 'State Registered means that client either hardware or software is turned on and correctly connected to telephone exchange. Otherwise the state is Unregistered. For successfully registered VoIP phone is shown its IP address, port and timeout of registration.',
'whitelist' => 'IP addresses, which are located on the white list, you may be able to activate the redirect, but not sent to the central router. Will not be diverted until removed from the white list. Temporary White List from the persistent differ in that it is regularly lubricated.',
'whitelist' => 'Members, whose are located on the white list, you may be able to activate the redirect (notification), but not sent to the central router (messages sended). Will not be diverted until removed from the white list. Temporary White List from the persistent differ in that it is valid just for a specified time interval.',
);
freenetis/branches/1.1/application/helpers/callback.php
{
echo strftime('%B', mktime(0,0,0,$item->month));
}
/**
* Callback function to print form field for notification action
* @param type $item
......
break;
case Message_Model::UNALLOWED_CONNECTING_PLACE_MESSAGE:
if (!$item->allowed && (!$item->interrupt || ($name == 'redirection' && $item->interrupt)))
$selected = Notifications_Controller::ACTIVATE;
break;
case Message_Model::USER_MESSAGE:
if ((!$item->interrupt || ($name == 'redirection' && $item->interrupt)) && (!$item->whitelisted || ($item->whitelisted && $args[1]==1)))
......
{
switch ($item->whitelisted)
{
case Ip_address_Model::PERNAMENT_WHITELIST:
case Ip_address_Model::PERMANENT_WHITELIST:
echo __('Permanent whitelist');
break;
case Ip_address_Model::TEMPORARY_WHITELIST:
freenetis/branches/1.1/application/models/ip_address.php
* @property string $ip_address
* @property bool $dhcp
* @property bool $gateway
* @property bool $service
* @property integer $whitelisted
* @property bool $service
* @property integer $member_id
* @property Member_Model $member
*/
......
* IP address is in permanent whitelist - it is never redirected (useful for
* special members), can be redirected only by message which ignores whitelist
*/
const PERNAMENT_WHITELIST = 1;
const PERMANENT_WHITELIST = 1;
/**
* IP address is in temporary whitelist - for limited period of time it is
......
public static $whitelist_types = array
(
self::NO_WHITELIST => 'No whitelist',
self::PERNAMENT_WHITELIST => 'Permanent whitelist',
self::PERMANENT_WHITELIST => 'Permanent whitelist',
self::TEMPORARY_WHITELIST => 'Temporary whitelist'
);
......
}
/**
* Gets translated whitelist types
*
* @param integer $white_list_type
* @return string
*/
public function get_whitelist_type($white_list_type = NULL)
{
if (empty($white_list_type) && $this->id)
{
$white_list_type = $this->whitelisted;
}
if (array_key_exists($white_list_type, self::$whitelist_types))
{
return __(self::$whitelist_types[$white_list_type]);
}
return __(self::$whitelist_types[self::NO_WHITELIST]);
}
/**
* Gives IP address is string is writted
*
* @return string
......
(
SELECT ip.*, ip.id AS ip_address_id,
i.name AS iface_name, s.name as subnet_name,
d.id AS device_id, d.name AS device_name
d.id AS device_id, d.name AS device_name,
IF(mw.id IS NULL, 0, 2-mw.permanent) AS whitelisted
FROM ip_addresses ip
LEFT JOIN ifaces i ON i.id = ip.iface_id
LEFT JOIN ifaces_vlans iv ON iv.iface_id = i.id
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN subnets s ON s.id = ip.subnet_id
LEFT JOIN users u ON u.id = d.user_id
LEFT JOIN members_whitelists mw ON mw.member_id = u.member_id
AND mw.since <= CURDATE() AND mw.until >= CURDATE()
WHERE ip.member_id IS NULL
GROUP BY ip.id
) ip
$where
ORDER BY $order_by $order_by_direction
......
(
SELECT ip.*, ip.id AS ip_address_id,
i.name AS iface_name, s.name as subnet_name,
d.id AS device_id, d.name AS device_name
d.id AS device_id, d.name AS device_name,
IF(mw.id IS NULL, 0, 2-mw.permanent) AS whitelisted
FROM ip_addresses ip
LEFT JOIN ifaces i ON i.id = ip.iface_id
LEFT JOIN ifaces_vlans iv ON iv.iface_id = i.id
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN subnets s ON s.id = ip.subnet_id
LEFT JOIN users u ON u.id = d.user_id
LEFT JOIN members m ON m.id = u.member_id
LEFT JOIN members_whitelists mw ON mw.member_id = m.id AND
mw.since <= CURDATE() AND mw.until >= CURDATE()
WHERE ip.member_id IS NULL
) ip
$where
......
SELECT DISTINCT ip.ip_address
FROM ip_addresses ip
LEFT JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
WHERE mip.ip_address_id IS NULL OR
(
whitelisted > 0 AND ip_address NOT IN
(
SELECT DISTINCT ip.ip_address
FROM ip_addresses ip
JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
JOIN messages m ON m.id = mip.message_id
WHERE m.ignore_whitelist = 1
)
LEFT JOIN messages m ON mip.message_id = m.id
LEFT JOIN ifaces i ON i.id = ip.iface_id
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN users u ON u.id = d.user_id
LEFT JOIN members_whitelists mw ON
mw.member_id = IFNULL(ip.member_id, u.member_id) AND
mw.since <= CURDATE() AND mw.until >= CURDATE()
WHERE mip.ip_address_id IS NULL OR (
mw.id IS NOT NULL AND m.ignore_whitelist = 1
)
ORDER BY INET_ATON(ip_address)
");
}
......
public function get_unallowed_ip_addresses()
{
return $this->db->query("
SELECT ip_address
SELECT DISTINCT ip.ip_address
FROM ip_addresses ip
JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
JOIN messages m ON mip.message_id = m.id
WHERE IFNULL(ip.whitelisted,0) = 0 OR m.ignore_whitelist = 1
GROUP BY ip.id
ORDER BY INET_ATON(ip_address)
LEFT JOIN ifaces i ON i.id = ip.iface_id
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN users u ON u.id = d.user_id
LEFT JOIN members_whitelists mw ON
mw.member_id = IFNULL(ip.member_id, u.member_id) AND
mw.since <= CURDATE() AND mw.until >= CURDATE()
WHERE mw.id IS NULL OR m.ignore_whitelist = 1
");
}
......
}
/**
* Gets all IDs of IP addresses of member who have currently interrupted
* membership. These IP addresses are redirected.
*
* @author Jiri Svitak
* @return Mysql_Result
*/
public function get_ip_addresses_with_interrupted_membership()
{
return $this->db->query("
SELECT ip.id
FROM
(
SELECT ip.id, ip.ip_address, ip.whitelisted,
s.name AS subnet_name,
IFNULL(u.member_id, ip.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN subnets s ON s.id = ip.subnet_id
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN users u ON u.id = d.user_id
) ip
JOIN members m ON m.id = ip.member_id
JOIN membership_interrupts mi ON mi.member_id = m.id
JOIN members_fees mf ON mi.members_fee_id = mf.id
JOIN fees f ON f.id = mf.fee_id
JOIN accounts a ON a.member_id = m.id
WHERE mf.activation_date <= CURDATE() AND f.special_type_id = ? AND
CURDATE() <= mf.deactivation_date
", Fee_Model::MEMBERSHIP_INTERRUPT);
}
/**
* Returns all IDs of IP addresses with unallowed connecting place
*
* @author Michal Kliment
......
)
");
}
/**
* Gets all IP addresses of members who have credit negative credit status.
*
* @author Jiri Svitak
* @param duble $debtor_boundary
* @return Mysql_Result
*/
public function get_ip_addresses_of_debtors($debtor_boundary)
{
return $this->db->query("
SELECT ip.id, ip.ip_address, ip.whitelisted, subnet_name,
m.name AS member_name, a.balance,
(
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
LEFT JOIN accounts a ON a.id = vs.account_id
WHERE a.member_id = m.id
) AS variable_symbol
FROM
(
SELECT ip.id, ip.ip_address, ip.whitelisted, s.name AS subnet_name,
IFNULL(u.member_id, ip.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
JOIN subnets s ON s.id = ip.subnet_id
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN users u ON u.id = d.user_id
) ip
JOIN members m ON m.id = ip.member_id
JOIN accounts a ON a.member_id = m.id AND m.id <> ?
WHERE a.balance < ?
AND DATEDIFF(CURDATE(), m.entrance_date) >= ?
AND (ip.whitelisted IS NULL OR ip.whitelisted = 0)
", array
(
Member_Model::ASSOCIATION, $debtor_boundary,
Settings::get('initial_debtor_immunity')
));
}
/**
* Gets all IP addresses of members who have low credit and should pay
* in short time.
*
* @author Jiri Svitak
* @param double $payment_notice_boundary
* @param double $debtor_boundary
* @return Mysql_Result
*/
public function get_ip_addresses_of_almostdebtors($payment_notice_boundary, $debtor_boundary)
{
return $this->db->query("
SELECT ip.id, ip.ip_address, ip.whitelisted, subnet_name,
m.name AS member_name, a.balance,
(
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
LEFT JOIN accounts a ON a.id = vs.account_id
WHERE a.member_id = m.id
) AS variable_symbol
FROM
(
SELECT ip.id, ip.ip_address, ip.whitelisted,
s.name AS subnet_name,
IFNULL(u.member_id, ip.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
JOIN subnets s ON s.id = ip.subnet_id
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN users u ON u.id = d.user_id
) ip
JOIN members m ON m.id = ip.member_id
JOIN accounts a ON a.member_id = m.id AND m.id <> ?
WHERE (
DATEDIFF(CURDATE(), m.entrance_date) >= ? AND
a.balance >= ? OR DATEDIFF(CURDATE(), m.entrance_date) < ? AND
DATEDIFF(CURDATE(), m.entrance_date) >= ?
)
AND a.balance < ?
AND (ip.whitelisted IS NULL OR ip.whitelisted = 0)
", array
(
Member_Model::ASSOCIATION, Settings::get('initial_debtor_immunity'),
$debtor_boundary, Settings::get('initial_debtor_immunity'),
Settings::get('initial_immunity'), $payment_notice_boundary
));
}
/**
* Returns all ip addresses which can cancel redirect by themselves
*
......
return $this->db->query("
SELECT ip.id AS ip_address_id, ip.ip_address, ip.whitelisted,
m.id AS message_id, m.name AS message, m.type, ? AS member_id,
mip.datetime AS active_redir_datetime
SELECT ip.id AS ip_address_id, ip.ip_address, m.id AS message_id,
m.name AS message, m.type, ? AS member_id,
mip.datetime AS active_redir_datetime,
IF(mw.id IS NULL, 0, 2 - mw.permanent) AS whitelisted
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
LEFT JOIN members_whitelists mw ON mw.member_id = u.member_id
LEFT JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
LEFT JOIN messages m ON m.id = mip.message_id
WHERE u.member_id = ? OR ip.member_id = ?
GROUP BY ip.id
ORDER BY $order_by $order_by_direction,
m.self_cancel DESC, mip.datetime ASC
LIMIT " . intval($sql_offset) . ", " . intval($limit_results) . "
......
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
LEFT JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
LEFT JOIN messages m ON m.id = mip.message_id
WHERE u.member_id = ? OR ip.member_id = ?
", $member_id, $member_id, $member_id)->current()->total;
GROUP BY ip.id
", $member_id, $member_id)->current()->total;
}
/**
......
ORDER BY id ASC
", array($iface_id));
}
/**
* Removes all IP addresses from temporary whitelist. Used when bank statement
* is imported, then all whitelisted whould have payed their fees, so they are
* no longer protected from redirection.
*
* @author Jiri Svitak
*/
public function clean_temporary_whitelist()
{
$this->db->query("
UPDATE ip_addresses
SET whitelisted = ?
WHERE whitelisted = ?
", self::NO_WHITELIST, self::TEMPORARY_WHITELIST);
}
/**
* Deletes all IP addresses by given subnet and member
......
}
/**
* Sets whitelist
*
* @param ineteger $whitelist
* @param integer $ip_address_id
* @return boolean
*/
public function set_whitelist($whitelist, $ip_address_id = NULL)
{
if (!$ip_address_id && isset($this))
$ip_address_id = $this->id;
return $this->db->query("
UPDATE ip_addresses ip
SET whitelisted = ?
WHERE id = ?
", array($whitelist, $ip_address_id));
}
/**
* Returns ip addresses of members with set-up qos ceil or rate
*
* @author Michal Kliment
freenetis/branches/1.1/application/models/message.php
/**
* user message, can be added and deleted by user
*/
const USER_MESSAGE = 0;
const USER_MESSAGE = 0;
/**
* not exactly message, it is content of side panel,
* should be used for information for all redirections
*/
const CONTACT_INFORMATION = 1;
const CONTACT_INFORMATION = 1;
/**
* content of page shown after canceling redirection
......
$type == self::USER_MESSAGE ||
$type == self::INTERRUPTED_MEMBERSHIP_MESSAGE ||
$type == self::DEBTOR_MESSAGE ||
$type == self::PAYMENT_NOTICE_MESSAGE ||
$type == self::UNALLOWED_CONNECTING_PLACE_MESSAGE
$type == self::PAYMENT_NOTICE_MESSAGE
);
}
......
$type != self::CONNECTION_REQUEST_APPROVE &&
$type != self::CONNECTION_REQUEST_REFUSE &&
$type != self::CONNECTION_REQUEST_INFO &&
$type != self::UNALLOWED_CONNECTING_PLACE_MESSAGE &&
$type != self::MONITORING_HOST_DOWN &&
$type != self::MONITORING_HOST_UP
);
freenetis/branches/1.1/application/models/users_contacts.php
*/
class Users_contacts_Model extends Model
{
/** Contact is not whitelisted */
const NO_WHITELIST = 0;
/** Contact is under pernament whitelisted */
const PERMANENT_WHITELIST = 1;
/** Contact is under temporary whitelisted */
const TEMPORARY_WHITELIST = 2;
/**
* Sets whitelist flag for member's conntact
*
* @author Michal Kliment
* @param integer $whitelist
* @param integer $member_id
* @param integer $type
*/
public function set_whitelist_by_member_and_type($whitelist, $member_id, $type)
{
$this->db->query("
UPDATE users_contacts uc, contacts c, users u
SET uc.whitelisted = ?
WHERE
uc.contact_id = c.id
AND c.type = ?
AND uc.user_id = u.id
AND u.member_id = ?
", $whitelist, $type, $member_id);
}
/**
* Cleans temporary whitelist for contacts
*
* @author Michal Kliment
*/
public function clean_temporary_whitelist()
{
$this->db->query("
UPDATE users_contacts uc
SET uc.whitelisted = ?
WHERE uc.whitelisted = ?
", self::NO_WHITELIST, self::TEMPORARY_WHITELIST);
}
/**
* Returns all contacts of debtors by type
*
* @author Michal Kliment
* @param double $debtor_boundary
* @param integer $type
* @return Mysql_Result
*/
public function get_contacts_of_debtors_by_type($debtor_boundary, $type)
{
return $this->db->query("
SELECT
c.value, a.balance, m.id AS member_id, m.name AS member_name,
(
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
WHERE vs.account_id = a.id
) AS variable_symbol, u.login, cou.country_code
FROM members m
JOIN accounts a ON a.member_id = m.id AND m.id <> 1
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
LEFT JOIN contacts_countries cc ON cc.contact_id = c.id
LEFT JOIN countries cou ON cou.id = cc.country_id
WHERE uc.whitelisted = ? AND m.type <> ? AND m.id NOT IN
(
SELECT m.id
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
) AND DATEDIFF(CURDATE(), m.entrance_date) >= ".intval(Settings::get('initial_debtor_immunity'))."
AND a.balance < ".intval($debtor_boundary)."
", $type, self::NO_WHITELIST, Member_Model::TYPE_FORMER);
}
/**
* Returns all contacts of almost-debtors
*
* @author Michal Kliment
* @param double $payment_notice_boundary
* @param double $debtor_boundary
* @param integer $type
* @return Mysql_Result
*/
public function get_contacts_of_almostdebtors_by_type(
$payment_notice_boundary, $debtor_boundary, $type)
{
return $this->db->query("
SELECT
c.value, a.balance, m.id AS member_id, m.name AS member_name,
(
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
WHERE vs.account_id = a.id
) AS variable_symbol, u.login, cou.country_code
FROM members m
JOIN accounts a ON a.member_id = m.id AND m.id <> 1
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
LEFT JOIN contacts_countries cc ON cc.contact_id = c.id
LEFT JOIN countries cou ON cou.id = cc.country_id
WHERE uc.whitelisted = ? AND m.type <> ? AND m.id NOT IN
(
SELECT m.id
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
)
AND a.balance < ".intval($payment_notice_boundary)."
AND
(
DATEDIFF(CURDATE(), m.entrance_date) >= ".intval(Settings::get('initial_debtor_immunity'))."
AND a.balance >= ".intval($debtor_boundary)."
OR DATEDIFF(CURDATE(), m.entrance_date) < ".intval(Settings::get('initial_debtor_immunity'))."
AND DATEDIFF(CURDATE(), m.entrance_date) >= ".intval(Settings::get('initial_immunity'))."
)
",
array
(
$type,
self::NO_WHITELIST,
Member_Model::TYPE_FORMER
));
}
/**
* Returns all contacts of members by type
*
* @author Michal Kliment
......
public function get_contacts_by_member_and_type (
$member_id, $type, $ignore_whitelisted = FALSE)
{
if ($ignore_whitelisted)
$whitelisted = "";
else
$whitelisted = "AND uc.whitelisted = 0";
$args = array($type, $member_id, Member_Model::TYPE_FORMER, $member_id);
$whitelisted = '';
if (!$ignore_whitelisted)
{
$whitelisted = "AND m.id NOT IN
(
SELECT mw.member_id
FROM members_whitelists mw
WHERE mw.member_id = ? AND mw.since <= CURDATE()
AND mw.until >= CURDATE()
)";
$args[] = $member_id;
}
return $this->db->query("
SELECT c.value, a.balance, m.id AS member_id, m.name AS member_name,
(
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
WHERE vs.account_id = a.id
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
WHERE vs.account_id = a.id
) AS variable_symbol, u.login, cou.country_code
FROM members m
JOIN accounts a ON a.member_id = m.id
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id $whitelisted
JOIN users_contacts uc ON uc.user_id = u.id
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
LEFT JOIN contacts_countries cc ON cc.contact_id = c.id
LEFT JOIN countries cou ON cou.id = cc.country_id
WHERE m.id = ? AND m.type <> ? AND m.id NOT in
WHERE m.id = ? AND m.type <> ? $whitelisted AND m.id NOT IN
(
SELECT m.id
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
SELECT mi.member_id
FROM membership_interrupts mi
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
WHERE mi.member_id = ? AND mf.activation_date <= CURDATE()
AND mf.deactivation_date >= CURDATE()
)
GROUP BY c.id
", $type, $member_id, Member_Model::TYPE_FORMER);
", $args);
}
/**
......
*/
public function get_all_contacts_by_type ($type, $ignore_whitelisted = FALSE)
{
if ($ignore_whitelisted)
$whitelisted = "";
else
$whitelisted = "AND uc.whitelisted = 0";
$whitelisted = '';
if (!$ignore_whitelisted)
{
$whitelisted = "AND m.id NOT IN
(
SELECT mw.member_id
FROM members_whitelists mw
WHERE mw.since <= CURDATE() AND mw.until >= CURDATE()
)";
}
return $this->db->query("
SELECT c.value, a.balance, m.id AS member_id, m.name AS member_name,
(
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
WHERE vs.account_id = a.id
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
WHERE vs.account_id = a.id
) AS variable_symbol, u.login, cou.country_code
FROM contacts c
JOIN users_contacts uc ON uc.contact_id = c.id $whitelisted
JOIN users_contacts uc ON uc.contact_id = c.id
JOIN users u ON uc.user_id = u.id
JOIN members m ON u.member_id = m.id
JOIN accounts a ON a.member_id = m.id
LEFT JOIN contacts_countries cc ON cc.contact_id = c.id
LEFT JOIN countries cou ON cou.id = cc.country_id
WHERE m.type <> ? AND c.type = ? AND m.id NOT in
WHERE m.type <> ? AND c.type = ? $whitelisted AND m.id NOT IN
(
SELECT m.id
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
SELECT mi.member_id
FROM membership_interrupts mi
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
WHERE mf.activation_date <= CURDATE() AND
mf.deactivation_date >= CURDATE()
)
GROUP BY c.id
", array(Member_Model::TYPE_FORMER, $type));
freenetis/branches/1.1/application/models/member.php
) ms ON ms.member_id = m.id
LEFT JOIN
(
SELECT IFNULL(ip.whitelisted,0) AS whitelisted, ip.member_id
FROM
(
SELECT ip.whitelisted, IFNULL(u.member_id, ip.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
ORDER BY ip.whitelisted DESC
) ip
GROUP BY member_id
SELECT m2.id AS member_id, IF(mw.member_id IS NULL, 0, 2 - mw.permanent) AS whitelisted
FROM members m2
LEFT JOIN members_whitelists mw ON mw.member_id = m2.id
AND mw.since <= CURDATE() AND mw.until >= CURDATE()
) ip ON ip.member_id = m.id
$join_cloud
$where
......
ms.type AS redirect_type_id,
IF(ms.type = 4, ? ,IF(ms.type = 5, ?, IF(ms.type = 6, ?, ?))) AS redirect_type,
IF(ms.type = 4, ?,IF(ms.type = 5, ?, IF(ms.type = 6, ?, ?))) AS redirect_type_text,
IFNULL(u.member_id,ms.member_id) AS member_id, whitelisted
IFNULL(u.member_id, ms.member_id) AS member_id
FROM
(
SELECT ms.*, i.device_id, ip.member_id, ip.whitelisted
SELECT ms.*, i.device_id, ip.member_id
FROM messages ms
LEFT JOIN messages_ip_addresses mip ON mip.message_id = ms.id
LEFT JOIN ip_addresses ip ON mip.ip_address_id = ip.id
......
) ms ON ms.member_id = m.id
LEFT JOIN
(
SELECT IFNULL(ip.whitelisted,0) AS whitelisted, ip.member_id
FROM
(
SELECT ip.whitelisted, IFNULL(u.member_id,ip.member_id) AS member_id
FROM
(
SELECT ip.whitelisted, i.device_id, ip.member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
) ip
LEFT JOIN devices d ON ip.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
ORDER BY ip.whitelisted DESC
) ip
GROUP BY member_id
SELECT m2.id AS member_id, IF(mw.member_id IS NULL, 0, 2 - mw.permanent) AS whitelisted
FROM members m2
LEFT JOIN members_whitelists mw ON mw.member_id = m2.id
AND mw.since <= CURDATE() AND mw.until >= CURDATE()
) ip ON ip.member_id = m.id
$join_cloud
$where
......
Config::get('lang'),
User_Model::MAIN_USER
));
die($this->db->last_query());
}
/**
......
AND mf.deactivation_date >= CURDATE()
LEFT JOIN
(
SELECT *
FROM
(
SELECT
IFNULL(ip.whitelisted,0) AS whitelisted,
IFNULL(ip.member_id,u.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
UNION
SELECT IFNULL(uc.whitelisted,0) AS whitelisted, u.member_id
FROM users u
LEFT JOIN users_contacts uc ON uc.user_id = u.id
ORDER BY whitelisted DESC
) w
GROUP BY member_id
SELECT m2.id AS member_id, IF(mw.member_id IS NULL, 0, 2 - mw.permanent) AS whitelisted
FROM members m2
LEFT JOIN members_whitelists mw ON mw.member_id = m2.id
AND mw.since <= CURDATE() AND mw.until >= CURDATE()
) w ON w.member_id = m.id
LEFT JOIN
(
......
AND mf.deactivation_date >= CURDATE()
LEFT JOIN
(
SELECT *
FROM
(
SELECT IFNULL(ip.whitelisted,0) AS whitelisted, IFNULL(ip.member_id,u.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
UNION
SELECT IFNULL(uc.whitelisted,0) AS whitelisted, u.member_id
FROM users u
LEFT JOIN users_contacts uc ON uc.user_id = u.id
ORDER BY whitelisted DESC
) w
GROUP BY member_id
SELECT m2.id AS member_id, IF(mw.member_id IS NULL, 0, 2 - mw.permanent) AS whitelisted
FROM members m2
LEFT JOIN members_whitelists mw ON mw.member_id = m2.id
AND mw.since <= CURDATE() AND mw.until >= CURDATE()
) w ON w.member_id = m.id
GROUP BY m.id
ORDER BY $order_by
......
AND mf.deactivation_date >= CURDATE()
LEFT JOIN
(
SELECT *
FROM
(
SELECT IFNULL(ip.whitelisted,0) AS whitelisted, IFNULL(ip.member_id,u.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
UNION
SELECT IFNULL(uc.whitelisted,0) AS whitelisted, u.member_id
FROM users u
LEFT JOIN users_contacts uc ON uc.user_id = u.id
ORDER BY whitelisted DESC
) w
GROUP BY member_id
SELECT m2.id AS member_id, IF(mw.member_id IS NULL, 0, 2 - mw.permanent) AS whitelisted
FROM members m2
LEFT JOIN members_whitelists mw ON mw.member_id = m2.id
AND mw.since <= CURDATE() AND mw.until >= CURDATE()
) w ON w.member_id = m.id
GROUP BY m.id
ORDER BY $order_by
......
return NULL;
}
/**
* Returns all members belongs to link
*
* @author Michal Kliment
* @param integer $link_id
* @param boolean $with_assoc with association or without association
* @return MySQL iterator object
*/
public function get_all_by_segment($link_id, $with_assoc = TRUE)
{
$where = (!$with_assoc) ? ' AND m.id <> 1' : '';
return $this->db->query("
SELECT m.id
FROM members m
JOIN users u ON u.member_id = m.id
JOIN devices d ON d.user_id = u.id
JOIN ifaces i ON i.device_id = d.id
WHERE i.link_id = ? $where
GROUP BY m.id
", array($link_id));
}
/**
* Gets all entrance and leaving dates
......
DELETE FROM accounts WHERE member_id = ?
", $member_id);
}
/**
* Gets members whose at least one ip address is set as whitelisted.
* @author Jiri Svitak
* @return Mysql_Result
*/
public function get_whitelisted_members(
$limit_from = 0, $limit_results = 50, $order_by = 'id',
$order_by_direction = 'asc', $filter_sql = "")
{
$where = "";
if ($filter_sql)
$where = "WHERE $filter_sql";
// order by direction check
if (strtolower($order_by_direction) != 'desc')
{
$order_by_direction = 'asc';
}
return $this->db->query("
SELECT
m.*, COUNT(m.id) AS items_count,
GROUP_CONCAT(ip_address ORDER BY INET_ATON(ip_address) SEPARATOR ', \n')
AS items_count_title, a_comment
FROM
(
SELECT
m.id, IFNULL(f.translated_term, e.value) AS type,
m.name, m.name AS member_name, a.balance,
a.id AS aid, a.comments_thread_id AS a_comments_thread_id,
ip.whitelisted, ip.ip_address, ip.id AS ip_address_id,
a_comment
FROM
(
SELECT ip.id, ip.whitelisted, ip.ip_address,
IFNULL(u.member_id, ip.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
WHERE ip.whitelisted > 0
) ip
JOIN members m ON ip.member_id = m.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN
(
SELECT c.comments_thread_id,
GROUP_CONCAT(CONCAT(u.surname,' ',u.name,' (',SUBSTRING(c.datetime,1,10),'):\n',c.text)
ORDER BY datetime DESC SEPARATOR ', \n\n') AS a_comment
FROM comments c
JOIN users u ON c.user_id = u.id
GROUP BY c.comments_thread_id
) c ON a.comments_thread_id = c.comments_thread_id
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN enum_types e ON m.type = e.id
LEFT JOIN translations f ON e.value = f.original_term AND lang = ?
WHERE ip.whitelisted > 0
) m
$where
GROUP BY m.id
ORDER BY " . $this->db->escape_column($order_by) . " $order_by_direction
LIMIT " . intval($limit_from) . ", " . intval($limit_results) . "
", Config::get('lang'));
}
/**
* Counts members whose at least one ip address is set as whitelisted.
* @author Jiri Svitak
* @return integer
*/
public function count_whitelisted_members($filter_sql = '')
{
$where = "";
if ($filter_sql)
{
$where = "WHERE $filter_sql";
}
return $this->db->query("
SELECT COUNT(*) AS total FROM
(
SELECT m.id FROM
(
SELECT
m.id, IFNULL(f.translated_term, e.value) AS type,
m.name AS member_name, ip.whitelisted, a.balance
FROM
(
SELECT ip.id, ip.whitelisted, ip.ip_address,
IFNULL(u.member_id, ip.member_id) AS member_id
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
WHERE ip.whitelisted > 0
) ip
JOIN members m ON ip.member_id = m.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN enum_types e ON m.type = e.id
LEFT JOIN translations f ON e.value = f.original_term AND lang = ?
WHERE ip.whitelisted > 0
) m
$where
GROUP BY m.id
) m
", Config::get('lang'))->current()->total;
}
/**
* Returns balance of current member
freenetis/branches/1.1/application/models/members_whitelist.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is release under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Members redirection whitelist
*
* @package Model
*
* @property integer $id
* @property integer $member_id
* @property Member_Model $member
* @property date $since
* @property date $until
* @property bool $permanent
* @property string $comment
*/
class Members_whitelist_Model extends ORM
{
protected $belongs_to = array('member');
/**
* Gets members whose are whitelisted.
*
* @author Jiri Svitak
* @return Mysql_Result
*/
public function get_whitelisted_members(
$limit_from = 0, $limit_results = 50, $order_by = 'id',
$order_by_direction = 'asc', $filter_sql = "")
{
$where = "";
if ($filter_sql)
$where = "WHERE $filter_sql";
// order by direction check
if (strtolower($order_by_direction) != 'desc')
{
$order_by_direction = 'asc';
}
return $this->db->query("
SELECT m.*
FROM
(
SELECT
m.id, IFNULL(f.translated_term, e.value) AS type,
m.name, m.name AS member_name, a.balance,
a.id AS aid, a.comments_thread_id AS a_comments_thread_id,
IF(mw.permanent > 0, 1, 2) AS whitelisted, a_comment
FROM members m
JOIN members_whitelists mw ON mw.member_id = m.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN
(
SELECT c.comments_thread_id,
GROUP_CONCAT(CONCAT(u.surname,' ',u.name,' (',SUBSTRING(c.datetime,1,10),'):\n',c.text)
ORDER BY datetime DESC SEPARATOR ', \n\n') AS a_comment
FROM comments c
JOIN users u ON c.user_id = u.id
GROUP BY c.comments_thread_id
) c ON a.comments_thread_id = c.comments_thread_id
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN enum_types e ON m.type = e.id
LEFT JOIN translations f ON e.value = f.original_term AND lang = ?
WHERE mw.since <= CURDATE() AND mw.until >= CURDATE()
) m
$where
GROUP BY m.id
ORDER BY " . $this->db->escape_column($order_by) . " $order_by_direction
LIMIT " . intval($limit_from) . ", " . intval($limit_results) . "
", Config::get('lang'));
}
/**
* Counts members whose are whitelisted.
*
* @author Jiri Svitak
* @return integer
*/
public function count_whitelisted_members($filter_sql = '')
{
$where = "";
if ($filter_sql)
{
$where = "WHERE $filter_sql";
}
return $this->db->query("
SELECT COUNT(*) AS total FROM
(
SELECT m.id FROM
(
SELECT
m.id, IFNULL(f.translated_term, e.value) AS type,
m.name AS member_name, a.balance,
IF(mw.permanent > 0, 1, 2) AS whitelisted
FROM members m
JOIN members_whitelists mw ON mw.member_id = m.id
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
LEFT JOIN comments_threads ct ON a.comments_thread_id = ct.id
LEFT JOIN enum_types e ON m.type = e.id
LEFT JOIN translations f ON e.value = f.original_term AND lang = ?
WHERE mw.since <= CURDATE() AND mw.until >= CURDATE()
) m
$where
GROUP BY m.id
) m
", Config::get('lang'))->current()->total;
}
/**
* Gets whitelists of a given member
*
* @param integer $member_id
*/
public function get_member_whitelists($member_id)
{
return $this->db->query("
SELECT mw.*, IF(mw.since <= CURDATE() AND mw.until >= CURDATE(), 1, 0) AS active
FROM members_whitelists mw
WHERE mw.member_id = ?
ORDER BY permanent DESC, until DESC, since DESC
", $member_id);
}
/**
* Checks if the given interval is unique in users whitelists
*
* @param indeger $member_id Owner ID
* @param boolean $permanent
* @param string $since Date
* @param string $until Date
* @param integer $mw_id ID of member whitelist on editing or null on adding
* @return boolean
*/
public function exists($member_id, $permanent, $since, $until, $mw_id = NULL)
{
$cond = '';
if (intval($mw_id))
{
$cond = ' AND id <> ' . intval($mw_id);
}
if ($permanent)
{
$cond .= ' AND permanent > 0';
}
else
{
$cond .= ' AND ((
? BETWEEN since AND until OR ? BETWEEN since AND until
) OR (
since BETWEEN ? and ? AND until BETWEEN ? AND ?
))';
}
return $this->db->query("
SELECT COUNT(*) AS c
FROM members_whitelists mw
WHERE mw.member_id = ? $cond
", array
(
$member_id,
$since, $until,
$since, $until,
$since, $until
))->current()->c > 0;
}
}
freenetis/branches/1.1/application/controllers/installation.php
$default_penalty->deactivation_date = $to;
$default_penalty->priority = 1;
$default_penalty->save_throwable();
// permament whitelist
$members_whitelist = new Members_whitelist_Model();
$members_whitelist->member_id = $member->id;
$members_whitelist->permament = 1;
$members_whitelist->since = date('Y-m-d');
$members_whitelist->until = '9999-12-31';
$members_whitelist->save_throwable();
// system settings
Settings::set('title', $form_data['title']);
freenetis/branches/1.1/application/controllers/notifications.php
{
if ($message->type == Message_Model::INTERRUPTED_MEMBERSHIP_MESSAGE ||
$message->type == Message_Model::DEBTOR_MESSAGE ||
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE ||
$message->type == Message_Model::UNALLOWED_CONNECTING_PLACE_MESSAGE)
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE)
{
$arr_messages[$message->id] = __($message->name);
}
......
{
if ($message->type == Message_Model::INTERRUPTED_MEMBERSHIP_MESSAGE ||
$message->type == Message_Model::DEBTOR_MESSAGE ||
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE ||
$message->type == Message_Model::UNALLOWED_CONNECTING_PLACE_MESSAGE)
$message->type == Message_Model::PAYMENT_NOTICE_MESSAGE)
{
$arr_messages[$message->id] = __($message->name);
}
......
$order_by = 'whitelisted DESC, interrupt DESC';
break;
case Message_Model::UNALLOWED_CONNECTING_PLACE_MESSAGE:
$order_by = 'whitelisted DESC, allowed ASC';
break;
default:
$order_by = 'whitelisted DESC, id ASC';
break;
......
->class('center');
}
if ($message->type == Message_Model::UNALLOWED_CONNECTING_PLACE_MESSAGE ||
$message->type == Message_Model::USER_MESSAGE)
if ($message->type == Message_Model::USER_MESSAGE)
{
$grid->callback_field('allowed')
->label(__('Allowed subnet'))
......
{
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff