Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 936

Přidáno uživatelem Jiří Sviták před více než 13 roky(ů)

nove presmerovani

Zobrazit rozdíly:

freenetis/branches/redirection/application/i18n/cs_CZ/texts.php
'pppoe' => 'pppoe',
'pre title' => 'Tituly před jménem',
'pre-installation check' => 'Předinstalační kontrola',
'preview' => 'Náhled',
'previous' => 'Předchozí',
'previous transfer' => 'Předchozí převod',
'prepaid' => 'Předplacený',
freenetis/branches/redirection/application/i18n/cs_CZ/help.php
'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.',
'self_cancel_url' => 'URL, která bude v odkazu pro zrušení přesměrování, které si může člen zrušit sám. Typicky je to adresa na centrální bráně, na které běží lighthttpd web server, který má na této adrese HTTP temporary redirect, který směřuje na stránku Freenetisu, která informuje člena o ukončení přesměrování. Ovšem kam bude směřovat tento temporary redirect si můžete na stránce nastavit sami.',
'self_cancel_url' => 'URL, která bude v odkazu pro zrušení přesměrování, které si může člen zrušit sám. Typicky 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 o ukončení přesměrování, případně temporary HTTP redirect na jinou informující stránku.',
'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í.',
'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í.',
freenetis/branches/redirection/application/helpers/redirect.php
<?php defined('SYSPATH') or die('No direct script access.');
/**
*
* @package Redirect helper
* @author Jiri Svitak
*/
class redirect_Core
{
/**
* Updates static html file with redirection message.
* @param $ip_address
* @return unknown_type
*/
static function update($ip_address, $contact, $content, $footer)
{
// html code to contact
$to_contact =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php // useful settings for expiration prevent caching of this website ?>
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Cache-Control" content="No-Cache" />
<title>'.url_lang::lang('texts.Redirection').'</title>
'.str_replace('https', 'http', html::stylesheet('media/css/style.css', 'screen')).'
<style type="text/css">
#content-padd h2 {margin: 10px 0px;}
#content-padd h3 {margin: 10px 0px;}
#content-padd li {margin-left: 20px;}
#content-padd a {font-weight: bold;}
td {width: 100px;}
</style>
</head>
<body>
<div id="main">
<div id="header">
<h1 id="logo"><span>Freenetis</span></h1>
<div class="status">
</div>
<div class="map"></div>
</div>
<div id="middle">
<div id="menu">
<div id="menu-padd">';
// html code to content
$to_content =
' </div>
</div>
<div id="content">
<div id="content-padd" style="margin:10px">';
// html code to footer
$to_footer =
' </div>
</div>
<div class="clear"></div>
</div>
<div id="footer">
<div id="footer-padd" style="text-align:center;">';
// html code after footer
$after_footer =
' </div>
</div>
</div>
</body>
</html>';
// generate page
$page = $to_contact.$contact.$to_content.$content.$to_footer.$footer.$after_footer;
// save page to file
$filename = $ip_address.'.html';
$file = fopen('static/'.$filename,'w+');
fputs($file, $page);
fclose($file);
}
static function generate_htaccess()
{
$htaccess =
"
Order deny,allow
# access from internet is denied
Deny from all
# allow access from localhost through IPv6 and IPv4, useful for development
#Allow from ::1
Allow from 127.0.0.1
# allow access from your local network, for example network 10.0.0.0/8
Allow from 10.0.0.0/8
RewriteEngine On
# condition if requested URL contains at the end string 'static'
RewriteCond %{REQUEST_URI} static/$
# this rule causes opening of html file with name of visitor's IP address
# visitor is shown his personalised redirection message (static html page)
RewriteRule .* /freenetis/static/%{REMOTE_ADDR}.html [L]
# if visitor's IP address has not file with its name, then document is not found
# in this case not found page has the meaning that IP address is unidentified
ErrorDocument 404 /freenetis/static/unknown_device_message.html
";
$page = $htaccess;
// save page to file
$file = fopen('static/.htaccess', 'w+');
fputs($file, $page);
fclose($file);
}
}
freenetis/branches/redirection/application/helpers/callback.php
}
}
static function message_preview_field($item, $name)
{
$message = new Message_Model($item->id);
if ($message->type != Message_Model::$contact_information)
{
echo html::anchor(url_lang::base().'messages/preview/'.$message->id, url_lang::lang('texts.Preview'));
}
else
{
echo '&nbsp';
}
}
/**
* Callback for locked private field in phone invoices
* @author Ondřej Fibich
freenetis/branches/redirection/application/models/ip_address.php
function get_ip_addresses_of_debtors($debtor_boundary)
{
return $this->db->query("
SELECT DISTINCT ip.id, ip.ip_address, ip.whitelisted
SELECT ip.id, ip.ip_address, ip.whitelisted, s.name AS subnet_name, m.name AS member_name,
m.variable_symbol, a.balance
FROM ip_addresses ip
JOIN ifaces i ON i.id = ip.iface_id
JOIN devices d ON d.id = i.device_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 m.id = u.member_id
WHERE ip.ip_address IN (".implode(',', $ip_address_array).")
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
......
{
$member_array[] = $ip->member_id;
}
$ips = $this->db->query("
SELECT DISTINCT q.ip_address_id FROM
(
SELECT ip.id AS ip_address_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).")
UNION
SELECT ip.id AS ip_address_id
FROM ip_addresses ip
WHERE ip.ip_address IN (".implode(',', $ip_address_array).")
) q
");
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;
}
......
function delete_ip_addresses_from_array($ip_id_array)
{
return $this->db->query("
DELETE FROM messages_ip_addresses WHERE ip_address_id IN (".implode(',',$ip_id_array).")");
DELETE FROM messages_ip_addresses WHERE ip_address_id IN (".implode(",",$ip_id_array).")");
}
/**
......
");
}
/**
* Function gets current active 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 *
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/controllers/web_interface.php
* @author Jiri Svitak
* @return unknown_type
*/
function whitelist()
function whitelisted_ip_addresses()
{
$ips = $this->db->query("
SELECT DISTINCT ip.ip_address
FROM ip_addresses ip
WHERE ip.whitelisted = 1 AND ip.ip_address NOT IN
WHERE ip.whitelisted > 0 AND ip.ip_address NOT IN
(
SELECT DISTINCT ip.ip_address
FROM ip_addresses ip
......
* @author Jiri Svitak
* @return unknown_type
*/
function already_seen()
function already_seen_ip_addresses()
{
//print_r($_POST); die();
// IP address to cancel redirection
$ip_string = $_POST['self_cancelable'];
$ip_address_array = explode(";", $ip_string);
// select ids of received ip addresses
$ip_model = new Ip_address_Model();
$ips = $ip_model->get_ip_addresses_from_array($ip_address_array);
// deleting redirection
$ip_id_array = array();
foreach ($ips as $ip)
if (!empty($_POST))
{
$ip_id_array[] = $ip->ip_address_id;
// IP address to cancel redirection
$ip_string = $_POST['self_cancelable'];
$ip_address_array = explode(";", $ip_string);
print_r($ip_address_array);
//die();
// select ids of received ip addresses
$ip_model = new Ip_address_Model();
$ips = $ip_model->get_ip_addresses_from_array($ip_address_array);
// deleting redirection
$ip_id_array = array();
foreach ($ips as $ip)
{
$ip_id_array[] = $ip->ip_address_id;
}
$ip_model->delete_ip_addresses_from_array($ip_id_array);
// get new redirections for these ip addresses and generate new pages
$contact_message = ORM::factory('message')->where(array('type' => Message_Model::$contact_information))->find();
$contact = $contact_message->text;
$ips = $ip_model->get_redirected_ip_addresses_from_ids($ip_id_array);
foreach ($ips as $ip)
{
$cancel_link = $ip->self_cancel > 0 ? html::anchor($this->settings->get('self_cancel_url'), url_lang::lang('texts.I accept this message and I want to cancel this redirection')) : '';
Redirect_Controller::update($ip->ip_address, $contact, $ip->text, $cancel_link);
}
}
$ip_model->delete_ip_addresses_from_array($ip_id_array);
// get new redirections for these ip addresses and generate new pages
$contact_message = ORM::factory('message')->where(array('type' => Message_Model::$contact_information))->find();
$contact = $contact_message->text;
$ips = $ip_model->get_redirected_ip_addresses_from_ids($ip_id_array);
foreach ($ips as $ip)
else
{
$cancel_link = $ip->self_cancel > 0 ? html::anchor($this->settings->get('self_cancel_url'), url_lang::lang('texts.I accept this message and I want to cancel this redirection')) : '';
redirect::update($ip->ip_address, $contact, $ip->text, $cancel_link);
$form = new Forge(url_lang::base().'web_interface/already_seen', '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->html_textarea('self_cancelable')->label(url_lang::lang('texts.Selfcancelable IP addresses').':')->rows(5)->cols(100);
$form->submit('submit')->value(url_lang::lang('texts.Send'));
echo $form->html();
}
}
freenetis/branches/redirection/application/controllers/settings.php
'approval' => url_lang::lang('texts.Approval'),
'voip' => url_lang::lang('texts.VoIP'),
'sms' => url_lang::lang('texts.SMS'),
'gateway' => url_lang::lang('texts.Gateway'),
'map' => url_lang::lang('texts.Map'),
'registration_export' => url_lang::lang('texts.Export of registration')
);
......
}
function gateway()
{
// access control
if (!$this->acl_check_edit(get_class($this),'system'))
Controller::error(ACCESS);
// creating of new forge
$this->form = new Forge(url_lang::base()."settings/gateway", '', 'POST', array('id' => 'article_form'));
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
$this->form->group('')->label(url_lang::lang('texts.Gateway'));
$this->form->input('gateway')->label(url_lang::lang('texts.Gateway IP address').':')->value($this->settings->get('gateway'));
$this->form->html_textarea('website_after_redirection')->label(url_lang::lang('texts.Website after redirection').':')->rows(5)->cols(100)->value($this->settings->get('website_after_redirection'));
$this->form->html_textarea('contact')->label(url_lang::lang('texts.Contact list on redirect page').':')->rows(5)->cols(100)->value($this->settings->get('contact'));
$this->form->html_textarea('info')->label(url_lang::lang('texts.Information for members (how to log in)').':')->rows(5)->cols(100)->value($this->settings->get('info'));
$this->form->html_textarea('unknown_device')->label(url_lang::lang('texts.Unknown device text').':')->rows(5)->cols(100)->value($this->settings->get('unknown_device'));
$this->form->html_textarea('interrupt')->label(url_lang::lang('texts.Membership interrupt text').':')->rows(5)->cols(100)->value($this->settings->get('interrupt'));
$this->form->html_textarea('debtor')->label(url_lang::lang('texts.Debtor text').':')->rows(5)->cols(100)->value($this->settings->get('debtor'));
$this->form->html_textarea('payment_notice')->label(url_lang::lang('texts.Payment notice text').':')->rows(5)->cols(100)->value($this->settings->get('payment_notice'));
$this->form->html_textarea('optional_message')->label(url_lang::lang('texts.Optional message text').':')->rows(5)->cols(100)->value($this->settings->get('optional_message'));
$this->form->submit('submit')->value(url_lang::lang('texts.Save'));
special::required_forge_style($this->form, ' *', 'required');
// form validate
if ($this->form->validate())
{
$form_data = $this->form->as_array();
$config_model = new Config_Model();
$issaved = true;
foreach ($form_data as $name => $value)
{
$value = addslashes($value);
// check if variable exists
if ($config_model->check_exist_variable($name))
// update of variable
$issaved = $issaved && $config_model->update_variable($name,$value);
else
// insert new variable
$issaved = $issaved && $config_model->insert_variable($name,$value);
}
if ($issaved)
// if all action were succesfull
$this->session->set_flash('message', url_lang::lang('texts.System variables have been successfully updated').'.');
else
// if not
$this->session->set_flash('message', url_lang::lang('texts.System variables havent been successfully updated').'.');
url::redirect(url_lang::base().'settings/gateway');
}
// create view for this template
$view = new View('main');
$view->title = url_lang::lang('texts.Settings').' - '.url_lang::lang('texts.Gateway');
$view->content = new View('settings');
$view->content->current = 'gateway';
$view->content->content = $this->form->html();
$view->content->headline = url_lang::lang('texts.Gateway');
$view->content->link_back = $this->links;
$message = $this->session->get_once('message');
if (!empty($message))
$view->content->message = $message;
$view->render(TRUE);
}
function registration_export()
{
// access control
freenetis/branches/redirection/application/controllers/messages.php
'limit_results' => $limit_results,
'url_array_ofset' => 1,
));
$grid->order_field('id')->label('ID');
$grid->order_callback_field('message')->label(url_lang::lang('texts.Name'))->callback('callback::message_field');
$grid->callback_field('type')->label(url_lang::lang('texts.Type'))->callback('callback::message_type_field');
//if ($this->acl_check_view('Messages_Controller', 'message'))
// $grid->action_field('id') ->label(url_lang::lang('texts.Message'))->url(url_lang::base().'messages/show')->action(url_lang::lang('texts.Show'));
if ($this->acl_check_view('Messages_Controller', 'message'))
$grid->callback_field('id')->label(url_lang::lang('texts.Preview'))->callback('callback::message_preview_field');
if ($this->acl_check_edit('Messages_Controller', 'message'))
$grid->action_field('id') ->label(url_lang::lang('texts.Edit'))->url(url_lang::base().'messages/edit')->action(url_lang::lang('texts.Edit'));
if ($this->acl_check_edit('Messages_Controller', 'message'))
......
if ($this->acl_check_delete('Messages_Controller', 'message'))
$grid->callback_field('id')->label(url_lang::lang('texts.Delete'))->callback('callback::message_delete_field');
$grid->datasource($messages);
$view = new View('main');
$view->title = $headline;
$view->content = new View('show_all');
......
}
} // end of add
/**
* Function shows preview of redirection message for current IP address.
* @author Jiri Svitak
* @param $message_id
*/
function preview($message_id)
{
$message = new Message_Model($message_id);
$content = $message->text;
// contact information
$contact_message = ORM::factory('message')->where(array('type' => Message_Model::$contact_information))->find();
$contact = $contact_message->text;
$ip_address = $_SERVER['REMOTE_ADDR'];
$cancel_link = html::anchor(settings::get('self_cancel_url'), url_lang::lang('texts.I accept this message and I want to cancel this redirection'));
$footer = $message->self_cancel > 0 ? $cancel_link : '';
echo Redirect_Controller::get_static_page($ip_address, $contact, $content, $footer);
}
/**
* Edits message parameters.
* @author Jiri Svitak
* @param $message_id
......
switch($message->type)
{
case Message_Model::$cancel_message:
redirect::update('cancel_message', $contact, $content, '');
// cancel message must be set somewhere else than in static folder
//Redirection_Controller::update('cancel_message', $contact, $content, '');
break;
case Message_Model::$unknown_device_message:
redirect::update('unknown_device_message', $contact, $content, '');
Redirection_Controller::update('unknown_device_message', $contact, $content, '');
break;
case Message_Model::$interrupted_membership_message:
// delete old redirections
......
// set new redirections in junction table
foreach($ips as $ip)
{
if (!$ip->whitelisted)
// replace special tags
foreach ($ip as $key => $value)
{
// replace special tags
foreach ($ip as $key => $value)
{
$content = str_replace('{'.$key.'}', $value, $content);
}
redirect::update($ip->ip_address, $contact, $content, '');
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
$content = str_replace('{'.$key.'}', $value, $content);
}
Redirection_Controller::update($ip->ip_address, $contact, $content, '');
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
......
// set new redirections in junction table
foreach($ips as $ip)
{
if (!$ip->whitelisted)
// replace special tags
foreach ($ip as $key => $value)
{
// replace special tags
foreach ($ip as $key => $value)
{
$content = str_replace('{'.$key.'}', $value, $content);
}
redirect::update($ip->ip_address, $contact, $content, '');
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
$content = str_replace('{'.$key.'}', $value, $content);
}
Redirection_Controller::update($ip->ip_address, $contact, $content, '');
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
......
// set new redirections in junction table
foreach($ips as $ip)
{
if (!$ip->whitelisted)
// replace special tags
foreach ($ip as $key => $value)
{
// replace special tags
foreach ($ip as $key => $value)
{
$content = str_replace('{'.$key.'}', $value, $content);
}
$cancel_link = html::anchor($this->settings->get('self_cancel_url'), url_lang::lang('texts.I accept this message and I want to cancel this redirection'));
redirect::update($ip->ip_address, $contact, $content, $cancel_link);
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
$content = str_replace('{'.$key.'}', $value, $content);
}
$cancel_link = html::anchor($this->settings->get('self_cancel_url'), url_lang::lang('texts.I accept this message and I want to cancel this redirection'));
Redirection_Controller::update($ip->ip_address, $contact, $content, $cancel_link);
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
freenetis/branches/redirection/application/controllers/redirect.php
* @author Jiri Svitak
* @param unknown_type $member_id
*/
function add_to_member($member_id = null)
function activate_to_member($member_id = null)
{
// access rights
if (!$this->acl_check_edit('Messages_Controller', 'member'))
......
$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);
}
}
}
......
url::redirect(url_lang::base().'members/show/'.$member_id);
}
// form
$form = new Forge(url_lang::base().'redirect/add_to_member/'.$member_id, '', 'POST', array('id' => 'article_form'));
$form = new Forge(url_lang::base().'redirect/activate_to_member/'.$member_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->dropdown('message_id')->label(url_lang::lang('texts.Redirection').':')->options($message_array);
$form->dropdown('message_id')->label(url_lang::lang('texts.Message').':')->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())
......
{
// 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 || $message->ignore_whitelist)
if ($ip->whitelisted == Ip_address_Model::$no_whitelist || $message->ignore_whitelist)
{
// 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')));
// generate html page
self::update($ip->ip_address);
self::find_current_redirection_and_update($ip->ip_address);
}
}
// set flash message
......
else
{
// view
$headline = url_lang::lang('texts.Redirection');
$headline = url_lang::lang('texts.Activate redirection to member');
$view = new View('main');
$view->title = $headline;
$view->content = new View('form');
......
}
}
/**
* Generates .htaccess file in static directory. This .htaccess file is used
* for used for redirecting IP address to proper static html. Selection
......
// access rights
if (!$this->acl_check_new('Messages_Controller', 'message'))
Controller::error(ACCESS);
redirect::generate_htaccess();
$htaccess =
"
Order deny,allow
# access from internet is denied
Deny from all
# allow access from localhost through IPv6 and IPv4, useful for development
#Allow from ::1
Allow from 127.0.0.1
# allow access from your local network, for example network 10.0.0.0/8
Allow from 10.0.0.0/8
RewriteEngine On
# condition if requested URL contains at the end string 'static'
RewriteCond %{REQUEST_URI} static/$
# this rule causes opening of html file with name of visitor's IP address
# visitor is shown his personalised redirection message (static html page)
RewriteRule .* /freenetis/static/%{REMOTE_ADDR}.html [L]
# if visitor's IP address has not file with its name, then document is not found
# in this case not found page has the meaning that IP address is unidentified
ErrorDocument 404 /freenetis/static/unknown_device_message.html
";
$page = $htaccess;
// save page to file
$file = fopen('static/.htaccess', 'w+');
fputs($file, $page);
fclose($file);
}
/**
* Returns string of html page of redirection.
* @author Jiri Svitak
* @param <type> $ip_address
* @param <type> $contact
* @param <type> $content
* @param string $footer
* @return string
*/
static function get_static_page($ip_address, $contact, $content, $footer)
{
// html code to contact
$to_contact =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php // useful settings for expiration prevent caching of this website ?>
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Cache-Control" content="No-Cache" />
<title>'.url_lang::lang('texts.Redirection').'</title>
'.str_replace('https', 'http', html::stylesheet('media/css/style.css', 'screen')).'
<style type="text/css">
#content-padd h2 {margin: 10px 0px;}
#content-padd h3 {margin: 10px 0px;}
#content-padd li {margin-left: 20px;}
#content-padd a {font-weight: bold;}
td {width: 100px;}
</style>
</head>
<body>
<div id="main">
<div id="header">
<h1 id="logo"><span>Freenetis</span></h1>
<div class="status">
</div>
<div class="map"></div>
</div>
<div id="middle">
<div id="menu">
<div id="menu-padd">';
// html code to content
$to_content =
' </div>
</div>
<div id="content">
<div id="content-padd" style="margin:10px">';
// html code to footer
$to_footer =
' </div>
</div>
<div class="clear"></div>
</div>
<div id="footer">
<div id="footer-padd" style="text-align:center;">';
// html code after footer
$after_footer =
' </div>
</div>
</div>
</body>
</html>';
if ($footer != '')
$footer = '<strong>'.$footer.'</strong>';
// generate page
$page = $to_contact.$contact.$to_content.$content.$to_footer.$footer.$after_footer;
return $page;
}
/**
* Updates static html file with redirection message.
* @author Jiri Svitak
* @param $ip_address
* @return unknown_type
*/
static function update($ip_address, $contact, $content, $footer)
{
// save page to file
$filename = $ip_address.'.html';
$file = fopen('static/'.$filename,'w+');
fputs($file, Redirect_Controller::get_static_page($ip_address, $contact, $content, $footer));
fclose($file);
}
/**
* Finds current redirection for given IP address and updates its static html page.
* @author Jiri Svitak
* @param <type> $ip_address
*/
static function find_current_redirection_and_update($ip_address)
{
// contact information
$contact_message = ORM::factory('message')->where(array('type' => Message_Model::$contact_information))->find();
$contact = $contact_message->text;
// find current redirection for ip
$ip_model = new Ip_address_Model();
$messages = $ip_model->get_current_redirection_of_ip_address($ip_address);
if (count($messages) > 0)
{
$message = $messages->current();
$content = $message->text;
foreach ($message as $key => $value)
{
$content = str_replace('{'.$key.'}', $value, $content);
}
$cancel_link = html::anchor(settings::get('self_cancel_url'), url_lang::lang('texts.I accept this message and I want to cancel this redirection'));
self::update($ip_address, $contact, $content, $message->self_cancel > 0 ? $cancel_link : '');
}
}
}
?>
freenetis/branches/redirection/application/views/members_show.php
$links[] = html::anchor(url_lang::base().'members/restore_membership/'.$member_data->member_id, url_lang::lang('texts.Restore membership'), array('onclick' => 'return potvrd(\''.url_lang::lang('texts.Do you want to restore membership of this member').'\')'));
}
}
if (!$former && $this->acl_check_edit('Members_Controller', 'redirect', $member_data->member_id))
$links[] = html::anchor(url_lang::base().'redirect/member/'.$member_data->member_id, url_lang::lang('texts.Redirection'));
$links[] = html::anchor(url_lang::base().'members/registration_export/'.$member_data->member_id, url_lang::lang('texts.Export of registration'));

Také k dispozici: Unified diff