Revize 1115
Přidáno uživatelem Jiří Sviták před asi 13 roky(ů)
freenetis/branches/redirection/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'action logs of object' => 'Logy akcí objektu',
|
||
'action logs of user' => 'Logy akcí uživatele',
|
||
'activate' => 'Aktivovat',
|
||
'activate redirection' => 'Aktivovat přesměrování',
|
||
'activate redirection to member' => 'Aktivovat členovi přesměrování',
|
||
'activated number has not been changed' => 'Aktivované číslo již nelze změnit',
|
||
'activated redirection' => 'Aktivované přesměrování',
|
||
'activated redirections' => 'Aktivovaná přesměrování',
|
||
'activation date' => 'Datum aktivace',
|
||
'active' => 'Aktivní',
|
||
'active member' => 'Aktivní člen',
|
||
'active members' => 'Aktivní členové',
|
||
'active message' => 'Aktivní zpráva',
|
||
'active redirection' => 'Aktivní přesměrování',
|
||
'active redirections' => 'Aktivní přesměrování',
|
||
'actual' => 'Aktuální',
|
||
'actual download' => 'Aktuální download',
|
||
'actual traffic' => 'Aktuální provoz',
|
||
... | ... | |
'redirection logo url' => 'URL pro logo na stránce přesměrování',
|
||
'redirection logs' => 'Logy přesměrování',
|
||
'redirection "%s" for %d ip addresses have been activated' => 'Přesměrování "%s" pro %d IP adres bylo aktivováno.',
|
||
'redirection of ip address' => 'Přesměrování IP adresy',
|
||
'redirection records' => 'Záznamy přesměrování',
|
||
'redirection settings' => 'Nastavení přesměrování',
|
||
'redirection settings have been successfully updated' => 'Nastavení přesměrování bylo úspěšně upraveno.',
|
freenetis/branches/redirection/application/i18n/cs_CZ/help.php | ||
---|---|---|
'accounting_system' => 'Účetní osnova je hlavní pomocník pro účetního sdružení. Zobrazuje sumu peněz na účtu z pohledu účetní osnovy. Ve výchozím stavu je to částka za celou dobu fungování sdružení, lze ovšem vyfiltrovat převody za zvolené období, např. od data 2009-01-01 do data 2009-12-31.',
|
||
'action_logs_active' => 'Logy akcí je nástroj pro detekci akcí koncových uživatelů na data v systému.',
|
||
'activate_redirection_to_member' => 'Umožňuje ručně aktivovat vybrané přesměrování všem IP adresám člena. Zda si může člen sám přesměrování zrušit nebo ne, je dáno vlastností vybrané zprávy. Ruční rušení přesměrování je možné provádět v tabulce.',
|
||
'activated_redirection' => 'Zobrazuje přesměrovaní aktivovaná pro IP adresy. Jedna IP adresa může mít aktivováno více přesměrování, uživateli je jako první zobrazeno to, které je v tabulce pro danou IP adresu nejvýše. Pořadí je určeno tím, jestli je zpráva samozrušitelná a pak datem a časem aktivace.',
|
||
'actual_traffic %s' => 'Jedná se o provoz člena získaný z poslední aktualizace ulogd (%s). Viz Nastavení - Logování - Ulogd - Interval aktualizace.',
|
||
'add_new_bank_transfer' => 'Umožňuje přidat ručně nový bankovní převod, který ma zdrojový i cílový účet. Typicky jde o fakturu nebo členský příspěvek. V běžném provozu využívejte automatický import výpisů. Ruční přidávání je tu pouze z důvodu, že byla potřeba dát do systému staré platby, které již byly jen v textovém formátu a nebylo možné je parsovat.',
|
||
'add_new_bank_transfer_without_counteraccount' => 'Umožňuje přidat bankovní převod bez protiúčtu, jde typicky o vklad, úrok bance apod. V běžném provozu využívejte automatický import výpisů. Ruční přidávání je tu pouze z důvodu, že byla potřeba dát do systému staré platby, které již nebylo možné parsovat.',
|
||
... | ... | |
'recalculate_account_balances' => 'Primárním zdrojem o stavu financí v systému jsou převody. Zůstatky na účtech byly dříve pokaždé počítány na požádání z převodů. Nyní si každý účet ukládá svůj zůstatek kvůli vyšší rychlosti. Tuto funkci použijete v případě přechodu na verzi systému, která tuto optimalizaci obsahuje.',
|
||
'recalculate_fees' => 'Pro primární strhávání členských příspěvků používejte funkci pro globální strhávání členských příspěvků v Účetním deníku. Tuto funkci používejte opatrně a to jen v případě, že máte správně strženy všechny členské příspěvky pro všechny členy od založení sdružení až po současné datum. Pak můžete tomuto členovi přepočítat stržení členských příspěvků v případě, že u něj došlo k nutnosti je přepočítat, např. chybné datum vstupu, vznikla nutnost přidat přerušení členství apod.',
|
||
'recalculate_entrance_fees' => 'Pro primární strhávání vstupních příspěvků používejte funkci pro globální strhávání v účetním deníku. Tuto funkci používejte jen v případě, že došlo k nějakému omylu, například, že měl zaplatit vstupní a pak se ukázalo, že nemusel.',
|
||
'redirection_preview' => 'Náhled zobrazí stránku přesně tak, jak se zobrazí dané IP adrese. V případě více aktivovaných přesměrování najednou pro jednu IP adresu se zobrazí jen to, které se členovi zobrazí jako první.',
|
||
'registration_logo' => 'Jedná se o logo sdružení, které se zobrazí v levém horním rohu vyexportované přihlášky',
|
||
'self_cancel' => 'Je-li daná zpráva samozrušitelná, znamená to, že při jejím zobrazení členovi se v patičce stránky objeví odkaz, který mu umožní přesměrování vypnout. Vhodné pro zprávy informativního charakteru. Rozlišuje se samozrušitelnost pro jednu IP adresu anebo pro všechny IP adresy člena.',
|
||
'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.',
|
||
... | ... | |
'ulogd_update_interval' => 'Interval aktualizace ulogd v sekundách. Po uplynutí této doby se zaktualizují počítadla provozu členů a najdou se příliš aktivní členové. Výchozí hodnota je 1800 sekund (30 minut).',
|
||
'unidentified_transfers' => 'Neidentifikované platby jsou všechny příchozí bankovní platby, které nebyl náš systém schopen z různých důvodů automaticky rozpoznat. Typicky se jedná o platby s chybným variabilním symbolem. Pokud zde svoji platbu najdete, pak kontaktujte hospodáře sdružení pro její správné přiřazení.',
|
||
'variable_symbol' => 'Variabilní symbol slouží k jednoznačnému určení příchozí platby člena.',
|
||
'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.',
|
||
);
|
freenetis/branches/redirection/application/helpers/callback.php | ||
---|---|---|
echo html::anchor(url_lang::base()."users/show/$item->user_id", $item->user_login);
|
||
}
|
||
|
||
public static function redirection_preview_field($item, $name)
|
||
{
|
||
echo html::anchor(url::base().'redirection/?ip_address='.$item->ip_address, url_lang::lang('texts.Show'));
|
||
}
|
||
|
||
/**
|
||
* Callback field for canceling redirection of one IP address on member's profile screen.
|
||
* @author Jiri Svitak
|
freenetis/branches/redirection/application/models/ip_address.php | ||
---|---|---|
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 = $member_id
|
||
ORDER BY inet_aton(ip.ip_address) ASC, m.self_cancel DESC, mip.datetime ASC
|
||
");
|
||
}
|
||
|
||
/**
|
||
* Returns ip addresses from database including their additional information.
|
||
* Ip addresses are selected by their string form saved in array. This
|
||
* array was received by HTTP POST from central gateway.
|
||
* @author Jiri Svitak
|
||
* @param <type> $ip_address_array
|
||
* @return <type>
|
||
*/
|
||
function get_ip_addresses_from_array($ip_address_array)
|
||
{
|
||
$ips_cancelable_by_member = $this->db->query("
|
||
SELECT * FROM
|
||
(
|
||
SELECT * FROM
|
||
(
|
||
SELECT ip.id AS ip_address_id, m.self_cancel, m2.id AS member_id
|
||
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
|
||
JOIN ifaces i ON i.id = ip.iface_id
|
||
JOIN devices d ON d.id = i.device_id
|
||
JOIN users u ON u.id = d.user_id
|
||
JOIN members m2 ON m2.id = u.member_id
|
||
WHERE ip.ip_address IN ('".implode("','", $ip_address_array)."')
|
||
ORDER BY m.self_cancel DESC, mip.datetime ASC
|
||
) q
|
||
GROUP BY q.ip_address_id
|
||
) p
|
||
WHERE p.self_cancel = ".Message_Model::$self_cancel_member."
|
||
");
|
||
$member_array = array();
|
||
foreach($ips_cancelable_by_member as $ip)
|
||
{
|
||
$member_array[] = $ip->member_id;
|
||
}
|
||
//print_r($member_array);
|
||
$query_for_received_ips = "SELECT ip.id AS ip_address_id
|
||
FROM ip_addresses ip
|
||
WHERE ip.ip_address IN ('".implode("','", $ip_address_array)."')";
|
||
$query_for_member_ips = "SELECT DISTINCT ip.id AS ip_address_id
|
||
FROM ip_addresses ip
|
||
JOIN ifaces i ON i.id = ip.iface_id
|
||
JOIN devices d ON d.id = i.device_id
|
||
JOIN users u ON u.id = d.user_id
|
||
JOIN members m ON m.id = u.member_id
|
||
WHERE m.id IN (".implode(",", $member_array).")";
|
||
$query = $query_for_received_ips.(empty($member_array) ? '' : ' UNION '.$query_for_member_ips);
|
||
//echo '<br>'.$query;
|
||
$ips = $this->db->query($query);
|
||
return $ips;
|
||
}
|
||
|
||
|
||
/**
|
||
* Deletes all redirections containing IP address in array from redirection junction table.
|
||
* @author Jiri Svitak
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Function gets current active redirection for given IP address.
|
||
* Function gets current activated redirection for given IP address.
|
||
* @author Jiri Svitak
|
||
* @param <type> $ip_address
|
||
*/
|
||
function get_current_redirection_of_ip_address($ip_address)
|
||
{
|
||
return $this->db->query("
|
||
SELECT m.id, m.text, m.self_cancel, ip.ip_address, ip.whitelisted, s.name AS subnet_name,
|
||
members.name AS member_name, members.id AS member_id,
|
||
members.variable_symbol, a.balance, mip.comment
|
||
FROM messages m
|
||
JOIN messages_ip_addresses mip ON m.id = mip.message_id
|
||
SELECT ms.id, ms.text, ms.self_cancel, ip.ip_address, ip.whitelisted, s.name AS subnet_name,
|
||
mm.name AS member_name, mm.id AS member_id,
|
||
mm.variable_symbol, a.balance, mip.comment
|
||
FROM messages ms
|
||
JOIN messages_ip_addresses mip ON ms.id = mip.message_id
|
||
JOIN ip_addresses ip ON ip.id = mip.ip_address_id
|
||
JOIN ifaces i ON i.id = ip.iface_id
|
||
JOIN devices d ON d.id = i.device_id
|
||
JOIN users u ON u.id = d.user_id
|
||
JOIN members ON members.id = u.member_id
|
||
JOIN members mm ON mm.id = u.member_id
|
||
JOIN accounts a ON a.member_id = m.id AND m.id <> 1
|
||
JOIN subnets s ON s.id = ip.subnet_id
|
||
WHERE ip.ip_address = '$ip_address'
|
||
ORDER BY m.self_cancel DESC, mip.datetime ASC
|
||
ORDER BY ms.self_cancel DESC, mip.datetime ASC
|
||
LIMIT 1
|
||
");
|
||
/*return $this->db->query("
|
||
SELECT *
|
||
FROM
|
||
(
|
||
SELECT m.id, m.text, m.self_cancel, ip.ip_address, ip.whitelisted, s.name AS subnet_name,
|
||
members.name AS member_name, members.id AS member_id,
|
||
members.variable_symbol, a.balance, mip.comment
|
||
FROM messages m
|
||
JOIN messages_ip_addresses mip ON m.id = mip.message_id
|
||
JOIN ip_addresses ip ON ip.id = mip.ip_address_id
|
||
JOIN ifaces i ON i.id = ip.iface_id
|
||
JOIN devices d ON d.id = i.device_id
|
||
JOIN users u ON u.id = d.user_id
|
||
JOIN members ON members.id = u.member_id
|
||
JOIN accounts a ON a.member_id = m.id AND m.id <> 1
|
||
JOIN subnets s ON s.id = ip.subnet_id
|
||
WHERE ip.ip_address = '$ip_address'
|
||
ORDER BY m.self_cancel DESC, mip.datetime ASC
|
||
) q
|
||
GROUP BY q.id
|
||
");
|
||
*/
|
||
}
|
||
|
||
/**
|
freenetis/branches/redirection/application/models/message.php | ||
---|---|---|
|
||
|
||
/**
|
||
* Counts all active redirections from junction table messages_ip_addresses.
|
||
* Counts all activated redirections from junction table messages_ip_addresses.
|
||
* @author Jiri Svitak
|
||
* @return unknown_type
|
||
*/
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Gets all active redirections from junction table messages_ip_addresses.
|
||
* Gets all activated redirections from junction table messages_ip_addresses.
|
||
* @return unknown_type
|
||
*/
|
||
public function get_all_redirections($limit_from = 0, $limit_results = 20, $order_by = 'ip_address', $order_by_direction = 'ASC', $filter_values = array())
|
||
{
|
||
if ($order_by == 'ip_address')
|
||
$order_by = 'inet_aton(ip_address)';
|
||
{
|
||
//$order_by = 'inet_aton(ip_address)';
|
||
$order_by = 'inet_aton(ip.ip_address) ASC, m.self_cancel DESC, mip.datetime ASC';
|
||
$order_by_direction = "";
|
||
}
|
||
return $this->db->query("
|
||
SELECT mip.ip_address_id, ip.ip_address, m.name AS message, mip.datetime, mip.comment, m.type
|
||
SELECT mip.ip_address_id, ip.ip_address, m.name AS message, mip.datetime, mip.comment, m.type, m.self_cancel
|
||
FROM messages_ip_addresses mip
|
||
LEFT JOIN ip_addresses ip ON ip.id = mip.ip_address_id
|
||
LEFT JOIN messages m ON m.id = mip.message_id
|
freenetis/branches/redirection/application/controllers/ip_addresses.php | ||
---|---|---|
if ($this->acl_check_edit('Devices_Controller','ip_address'))
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Edit'))->url(url_lang::base().'ip_addresses/edit')->action(url_lang::lang('texts.Edit'))->class('center');
|
||
//if ($this->acl_check_edit('Devices_Controller','ip_address'))
|
||
// $grid->action_field('id')->label(url_lang::lang('texts.Redir'))->url(url_lang::base().'redirect/add')->action(url_lang::lang('texts.Redirect'))->class('center');
|
||
// $grid->action_field('id')->label(url_lang::lang('texts.Redir'))->url(url_lang::base().'redirect/activate_to_ip_address')->action(url_lang::lang('texts.Redirect'))->class('center');
|
||
//if ($this->acl_check_edit('Devices_Controller','ip_address'))
|
||
// $grid->action_field('id')->label(url_lang::lang('texts.Smokeping'))->url(url_lang::base().'monitoring/add_smokeping')->action(url_lang::lang('texts.Monitor'))->class('center');
|
||
if ($this->acl_check_delete('Devices_Controller','ip_address'))
|
||
... | ... | |
$whitelist_types = array(Ip_address_Model::$no_whitelist => url_lang::lang('texts.No whitelist'),
|
||
Ip_address_Model::$permanent_whitelist => url_lang::lang('texts.Permanent whitelist'), Ip_address_Model::$temporary_whitelist => url_lang::lang('texts.Temporary whitelist'));
|
||
|
||
// active redirections for this IP address
|
||
// activated redirections for this IP address
|
||
/*$mip_model = new Messages_ip_addresses_Model();
|
||
$messages = $mip_model->get_redirections_of_ip_address($ip_address_id);
|
||
$grid = new Grid(url_lang::base().'ip_addresses', url_lang::lang('texts.Active redirections'),array(
|
||
$grid = new Grid(url_lang::base().'ip_addresses', url_lang::lang('texts.Activated redirections'),array(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
freenetis/branches/redirection/application/controllers/members.php | ||
---|---|---|
$membership_interrupts_grid->action_field('id') ->label(url_lang::lang('texts.Membership interrupts'))->url(url_lang::base().'membership_interrupts/delete')->action(url_lang::lang('texts.Delete'))->class('delete_link');
|
||
$membership_interrupts_grid->datasource($membership_interrupts);
|
||
|
||
// active redirections of member, including short statistic of whitelisted IP addresses
|
||
// activated redirections of member, including short statistic of whitelisted IP addresses
|
||
$ip_model = new Ip_address_Model();
|
||
$ip_addresses = $ip_model->get_ips_and_redirections_of_member($member_id);
|
||
$redir_grid = new Grid(url_lang::base().'members', null, array(
|
||
... | ... | |
$redir_grid->add_new_button(url_lang::base().'redirect/set_whitelist/'.$member_id, url_lang::lang('texts.Set whitelist to member'), array(), help::hint('set_whitelist_to_member'));
|
||
}
|
||
$redir_grid->callback_field('ip_address')->label(url_lang::lang('texts.IP address'))->callback('callback::ip_address_field');
|
||
$redir_grid->callback_field('whitelisted')->label(url_lang::lang('texts.Whitelist'))->callback('callback::whitelisted_field');
|
||
$redir_grid->callback_field('message')->label(url_lang::lang('texts.Active redirection'))->callback('callback::message_field');
|
||
$redir_grid->callback_field('whitelisted')->label(url_lang::lang('texts.Whitelist').' '.help::hint('whitelist'))->callback('callback::whitelisted_field');
|
||
$redir_grid->callback_field('message')->label(url_lang::lang('texts.Activated redirection').' '.help::hint('activated_redirection'))->callback('callback::message_field');
|
||
$redir_grid->callback_field('ip_address')->label(url_lang::lang('texts.Preview').' '.help::hint('redirection_preview'))->callback('callback::redirection_preview_field');
|
||
if ($this->acl_check_delete('Messages_Controller', 'ip_address'))
|
||
$redir_grid->callback_field('redirection')->label(url_lang::lang('texts.Canceling of message for redirection'))->callback("callback::cancel_redirection_of_member");
|
||
$redir_grid->datasource($ip_addresses);
|
freenetis/branches/redirection/application/controllers/redirect.php | ||
---|---|---|
class Redirect_Controller extends Controller
|
||
{
|
||
/**
|
||
* Shows all active redirections.
|
||
* Shows all activated redirections.
|
||
* @author Jiri Svitak
|
||
* @param $limit_results
|
||
* @param $order_by
|
||
... | ... | |
$sql_offset = 0;
|
||
$redirections = $message_model->get_all_redirections($sql_offset, (int)$limit_results, $order_by, $order_by_direction);
|
||
|
||
$headline = url_lang::lang('texts.Active redirections');
|
||
$headline = url_lang::lang('texts.Activated redirections');
|
||
$grid = new Grid(url_lang::base().'redirect', null, array(
|
||
//'separator' => '<br />-----------',
|
||
//'use_paginator' => false,
|
||
... | ... | |
|
||
/*
|
||
$grid->add_new_button(url_lang::base().'messages/show_all', url_lang::lang('texts.Messages for redirection'));
|
||
$grid->add_new_button(url_lang::base().'redirect/show_all', url_lang::lang('texts.Active Redirections'));
|
||
$grid->add_new_button(url_lang::base().'redirect/show_all', url_lang::lang('texts.Activated Redirections'));
|
||
$grid->add_new_button(url_lang::base().'redirect/settings', url_lang::lang('texts.Settings'));
|
||
*/
|
||
$grid->order_callback_field('ip_address')->label(url_lang::lang('texts.IP address'))->callback('callback::ip_address_field');
|
||
$grid->order_callback_field('message')->label(url_lang::lang('texts.Name'))->callback('callback::message_field');
|
||
$grid->order_callback_field('message')->label(url_lang::lang('texts.Activated redirection').' '.help::hint('activated_redirection'))->callback('callback::message_field');
|
||
$grid->order_field('datetime')->label(url_lang::lang('texts.Date and time'));
|
||
$grid->order_field('comment')->label(url_lang::lang('texts.Comment'));
|
||
$grid->datasource($redirections);
|
||
$grid->callback_field('ip_address')->label(url_lang::lang('texts.Preview').' '.help::hint('redirection_preview'))->callback('callback::redirection_preview_field');
|
||
$grid->datasource($redirections);
|
||
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
... | ... | |
* @param $ip_address_id
|
||
* @return unknown_type
|
||
*/
|
||
function add($ip_address_id = null)
|
||
function activate_to_ip_address($ip_address_id = null)
|
||
{
|
||
// access rights
|
||
if (!$this->acl_check_edit('Messages_Controller', 'ip_address'))
|
||
... | ... | |
foreach($messages as $message)
|
||
{
|
||
// whitelisted IP addresses can be redirected only by redirections which ignore whitelist
|
||
if ($ip->whitelisted && !$message->ignore_whitelist)
|
||
continue;
|
||
//if ($ip->whitelisted && !$message->ignore_whitelist)
|
||
// continue;
|
||
// IP address can be manually redirected only to user message, interrupted membership message, debtor message, payment notice message
|
||
if ($message->type == Message_Model::$user_message ||
|
||
$message->type == Message_Model::$interrupted_membership_message ||
|
||
$message->type == Message_Model::$debtor_message ||
|
||
$message->type == Message_Model::$payment_notice_message)
|
||
{
|
||
$message_array[$message->id] = $message->name;
|
||
$message_array[$message->id] = url_lang::lang('texts.'.$message->name);
|
||
}
|
||
}
|
||
// no redirection possible for ip address?
|
||
... | ... | |
url::redirect(url_lang::base().'ip_addresses/show/'.$ip_address_id);
|
||
}
|
||
// form
|
||
$form = new Forge(url_lang::base().'redirect/add/'.$ip_address_id, '', 'POST', array('id' => 'article_form'));
|
||
$form = new Forge(url_lang::base().'redirect/activate_to_ip_address/'.$ip_address_id, '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->group('')->label(url_lang::lang('texts.Redirection'));
|
||
$form->group('')->label(url_lang::lang('texts.Redirection of IP address'));
|
||
$form->dropdown('message_id')->label(url_lang::lang('texts.Redirection').':')->options($message_array);
|
||
$form->textarea('comment')->label(url_lang::lang('texts.Comment of admin shown to user').':');
|
||
$form->submit('submit')->value(url_lang::lang('texts.Redirect'));
|
||
$form->submit('submit')->value(url_lang::lang('texts.Activate'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
// validation
|
||
if ($form->validate())
|
||
... | ... | |
$db->insert('messages_ip_addresses', array('message_id' => $form_data['message_id'],
|
||
'ip_address_id' => $ip->id, 'user_id' => $this->session->get('user_id'),
|
||
'comment' => $form_data['comment'], 'datetime' => date('Y-m-d H:i:s')));
|
||
// generate html page
|
||
self::update($ip->ip_address);
|
||
// set flash message
|
||
$this->session->set_flash('message', url_lang::lang('texts.Redirection has been successfully set.'));
|
||
url::redirect(url_lang::base().'ip_addresses/show/'.$ip_address_id);
|
||
... | ... | |
else
|
||
{
|
||
// view
|
||
$headline = url_lang::lang('texts.Redirection');
|
||
$headline = url_lang::lang('texts.Redirection of IP address');
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
... | ... | |
foreach($messages as $message)
|
||
{
|
||
// whitelisted IP addresses can be redirected only by redirections which ignore whitelist
|
||
if ($ip->whitelisted && !$message->ignore_whitelist)
|
||
continue;
|
||
//if ($ip->whitelisted && !$message->ignore_whitelist)
|
||
// continue;
|
||
// IP address can be manually redirected only to user message, interrupted membership message, debtor message, payment notice message
|
||
if ($message->type == Message_Model::$user_message ||
|
||
$message->type == Message_Model::$interrupted_membership_message ||
|
||
... | ... | |
$db = new Database();
|
||
foreach($ips as $ip)
|
||
{
|
||
// delete old redirection if present
|
||
$db->delete('messages_ip_addresses', array('message_id' => $form_data['message_id'], 'ip_address_id' => $ip->id));
|
||
if ($ip->whitelisted == Ip_address_Model::$no_whitelist || $message->ignore_whitelist)
|
||
{
|
||
//if ($ip->whitelisted == Ip_address_Model::$no_whitelist || $message->ignore_whitelist)
|
||
//{
|
||
// delete old redirection if present
|
||
$db->delete('messages_ip_addresses', array('message_id' => $form_data['message_id'], 'ip_address_id' => $ip->id));
|
||
// database insert sets redirection for ip address
|
||
$db->insert('messages_ip_addresses', array('message_id' => $form_data['message_id'],
|
||
'ip_address_id' => $ip->id, 'user_id' => $this->session->get('user_id'),
|
||
'comment' => $form_data['comment'], 'datetime' => date('Y-m-d H:i:s')));
|
||
}
|
||
//}
|
||
}
|
||
// set flash message
|
||
$this->session->set_flash('message', url_lang::lang('texts.Redirection has been successfully set.'));
|
freenetis/branches/redirection/application/views/ip_addresses_show.php | ||
---|---|---|
if ($this->acl_check_delete('Devices_Controller', 'ip_address'))
|
||
$links[] = html::anchor(url_lang::base().'ip_addresses/delete/'.$ip_address->id, url_lang::lang('texts.Delete'));
|
||
if ($this->acl_check_new('Messages_Controller', 'ip_address'))
|
||
$links[] = html::anchor(url_lang::base().'redirect/add/'.$ip_address->id, url_lang::lang('texts.Redirect'));
|
||
$links[] = html::anchor(url_lang::base().'redirect/activate_to_ip_address/'.$ip_address->id, url_lang::lang('texts.Activate redirection'));
|
||
|
||
echo implode(' | ', $links);
|
||
?>
|
freenetis/branches/redirection/application/views/menu.php | ||
---|---|---|
<?php if ($this->acl_check_view('Messages_Controller', 'message')) { ?>
|
||
<li class="redirection"><h2><?php echo url_lang::lang('texts.Redirection') ?></h2>
|
||
<ul>
|
||
<li><?php echo html::anchor(url_lang::base().'redirect/show_all', url_lang::lang('texts.Active redirections')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'redirect/show_all', url_lang::lang('texts.Activated redirections')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'redirect/show_whitelisted_members', url_lang::lang('texts.Whitelist')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'messages/show_all', url_lang::lang('texts.Messages')) ?></li>
|
||
<li><?php echo html::anchor(url_lang::base().'redirect/settings', url_lang::lang('texts.Settings')) ?></li>
|
freenetis/branches/redirection/redirection/cancel.php | ||
---|---|---|
|
||
// content of redirection message
|
||
$message_query = "
|
||
SELECT m.id, m.text, m.self_cancel, ip.ip_address, ip.whitelisted, s.name AS subnet_name,
|
||
SELECT m.id AS message_id, m.text, m.self_cancel, ip.ip_address, ip.whitelisted, s.name AS subnet_name,
|
||
members.name AS member_name, members.id AS member_id,
|
||
members.variable_symbol, a.balance, mip.comment
|
||
FROM messages m
|
||
... | ... | |
LIMIT 1";
|
||
$message_result = mysql_query($message_query, $link) or die(mysql_error());
|
||
$message = mysql_fetch_array($message_result);
|
||
//print_r($message);
|
||
//echo '<br><br>';
|
||
// no redirection found - perhaps visiting this page by mistake?
|
||
if (!$message)
|
||
{
|
||
echo 'No redirection found, so there is nothing to be canceled.';
|
||
die();
|
||
}
|
||
// cannot be canceled
|
||
if ($message['self_cancel'] == 0)
|
||
{
|
||
echo 'message cannot be canceled by user';
|
||
echo 'This redirection cannot be canceled by user.';
|
||
die();
|
||
}
|
||
|
||
// canceling of redirection
|
||
if ($message['self_cancel'] == 1)
|
||
{
|
||
echo 'redirection canceled to all ip addresses of member';
|
||
// gets ip addresses and redirection of member
|
||
$ip_query = "SELECT ip.id AS ip_address_id, ip.ip_address, ip.whitelisted,
|
||
m.id AS message_id, m.name AS message, m.type,
|
||
".$message['member_id']." AS member_id
|
||
FROM ip_addresses ip
|
||
JOIN ifaces i ON ip.iface_id = i.id
|
||
JOIN devices d ON i.device_id = d.id
|
||
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 = ".$message['member_id'];
|
||
$ip_result = mysql_query($ip_query, $link);
|
||
$ip_id_array = array();
|
||
while($item = mysql_fetch_array($ip_result))
|
||
{
|
||
$ip_id_array[] = $item['ip_address_id'];
|
||
}
|
||
//print_r($ip_id_array);
|
||
//echo '<br>';
|
||
//print_r($message);
|
||
$d_query = "DELETE FROM messages_ip_addresses WHERE ip_address_id IN (".implode(",",$ip_id_array).")
|
||
AND message_id = ".$message['message_id'];
|
||
//echo '<br>'.$d_query;
|
||
mysql_query($d_query, $link);
|
||
echo 'Redirection has been canceled to all ip addresses of member.';
|
||
}
|
||
else
|
||
{
|
||
echo 'redirection canceled just to this ip address';
|
||
$d_query = "DELETE FROM messages_ip_addresses WHERE ip_address_id = ".$message['ip_address_id'].
|
||
" AND message_id = ".$message['message_id'];
|
||
mysql_query($d_query, $link);
|
||
echo 'Redirection has been canceled just to this ip address.';
|
||
}
|
||
|
||
?>
|
freenetis/branches/redirection/redirection/index.php | ||
---|---|---|
mysql_query("SET CHARACTER SET utf8", $link) or die(mysql_error());
|
||
mysql_query("SET NAMES utf8", $link) or die(mysql_error());
|
||
mysql_select_db($config['db_name']) or die(mysql_error());
|
||
// obtain remote ip address
|
||
$ip_address = $_SERVER['REMOTE_ADDR'];
|
||
// obtain ip address
|
||
// preview of redirection can be viewed by passing GET argument
|
||
if (isset($_GET['ip_address']))
|
||
{
|
||
$ip_address = $_GET['ip_address'];
|
||
}
|
||
// otherwise it is real redirection, we have to use ip address of remote visitor
|
||
else
|
||
{
|
||
$ip_address = $_SERVER['REMOTE_ADDR'];
|
||
}
|
||
// check validity of ip address
|
||
if (!preg_match ("/^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])$/", $ip_address))
|
||
{
|
||
echo 'Invalid IP address.';
|
||
die();
|
||
}
|
||
// content of redirection message
|
||
$message_query = "
|
||
SELECT m.id, m.text, m.self_cancel, ip.ip_address, ip.whitelisted, s.name AS subnet_name,
|
||
members.name AS member_name, members.id AS member_id,
|
||
members.variable_symbol, a.balance, mip.comment
|
||
FROM messages m
|
||
JOIN messages_ip_addresses mip ON m.id = mip.message_id
|
||
SELECT ms.id, ms.text, ms.self_cancel, ip.ip_address, ip.whitelisted, s.name AS subnet_name,
|
||
mm.name AS member_name, mm.id AS member_id,
|
||
mm.variable_symbol, a.balance, mip.comment
|
||
FROM messages ms
|
||
JOIN messages_ip_addresses mip ON ms.id = mip.message_id
|
||
JOIN ip_addresses ip ON ip.id = mip.ip_address_id
|
||
JOIN subnets s ON s.id = ip.subnet_id
|
||
JOIN ifaces i ON i.id = ip.iface_id
|
||
JOIN devices d ON d.id = i.device_id
|
||
JOIN users u ON u.id = d.user_id
|
||
JOIN members ON members.id = u.member_id
|
||
LEFT JOIN accounts a ON a.member_id = m.id AND m.id <> 1
|
||
JOIN members mm ON mm.id = u.member_id
|
||
LEFT JOIN accounts a ON a.member_id = mm.id AND mm.id <> 1
|
||
WHERE ip.ip_address = '$ip_address'
|
||
ORDER BY m.self_cancel DESC, mip.datetime ASC
|
||
ORDER BY ms.self_cancel DESC, mip.datetime ASC
|
||
LIMIT 1";
|
||
$message_result = mysql_query($message_query, $link) or die(mysql_error());
|
||
$message = mysql_fetch_array($message_result);
|
Také k dispozici: Unified diff
ladeni chyb, psani programove dokumentace, nahledy presmerovani