Revize 663
Přidáno uživatelem Jiří Sviták před více než 14 roky(ů)
freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'before getting started, we need some information on the database' => 'Předtím než začneme, potřebujeme několik informací o databázi.',
|
||
'but i can\'t write the configphp file' => 'Ale nemůžu zapisovat do souboru <code>config.php</code>.',
|
||
'but i can\'t write the htaccess file' => 'Ale nemůžu zapisovat do souboru <code>.htaccess</code>.',
|
||
'cancel' => 'Zrušit',
|
||
'caller' => 'Volající',
|
||
'callcon' => 'Volaný',
|
||
'cannot connect to database' => 'Nelze se připojit k databázi',
|
||
... | ... | |
'redirected' => 'Přesměroval',
|
||
'redirection' => 'Přesměrování',
|
||
'redirection enabled' => 'Přesměrování zapnuto',
|
||
'redirection has been successfully canceled' => 'Přesměrování bylo úspěšně zrušeno.',
|
||
'redirection has been successfully update' => 'Přesměrování bylo úspěšně upraveno.',
|
||
'redirection has been successfully set' => 'Přesměrování bylo úspěšně nastaveno.',
|
||
'redirection logs' => 'Logy přesměrování',
|
freenetis/trunk/kohana/application/models/message.php | ||
---|---|---|
<?php
|
||
class Message_Model extends ORM
|
||
{
|
||
// types of messages
|
||
public static $normal_message = 1;
|
||
// user message, can be added and deleted by user
|
||
public static $user_message = 0;
|
||
// not exactly message, it is content of side panel, should be used for information for all redirections
|
||
public static $contact_information = 1;
|
||
// content of page shown after canceling redirection
|
||
public static $cancel_message = 2;
|
||
public static $contact_information = 3;
|
||
// content of page with text for unknown device
|
||
public static $unknown_device_message = 3;
|
||
// content of page for interrupted member, this redirection can be set in system
|
||
public static $interrupted_membership_message = 4;
|
||
// content of page for debtor, this redirection can be set in system
|
||
public static $debtor_message = 5;
|
||
// content of page for payment notice, this redirection can be set in system and can be canceled by user
|
||
public static $payment_notice_message = 6;
|
||
|
||
// self cancel disabled, remote computer cannot cancel this message
|
||
public static $disabled = 0;
|
||
// self cancel enabled, every member's IP address has cancelled given redirection
|
||
// self cancel enabled, every member's IP address will have cancelled given redirection
|
||
public static $member = 1;
|
||
// self cancel enabled, redirection is canceled only for current remote computer
|
||
public static $ip = 2;
|
freenetis/trunk/kohana/application/controllers/web_interface.php | ||
---|---|---|
*/
|
||
class Web_interface_Controller extends Controller
|
||
{
|
||
|
||
protected $db;
|
||
|
||
function __construct()
|
||
{
|
||
parent::__construct();
|
||
$this->db = new Database();
|
||
}
|
||
|
||
function index()
|
||
{
|
||
echo "interface for communication over http protocol with remote devices";
|
||
echo url_lang::lang('texts.Interface for communication over http protocol with remote devices');
|
||
}
|
||
|
||
/**
|
||
... | ... | |
|
||
}
|
||
|
||
/**
|
||
* Generates static html page with name of IP address. Redirection is done by redirecting to this html page.
|
||
* More redirections at the same time may be set. This function determines current active redirection.
|
||
* @param $ip_address
|
||
* @return unknown_type
|
||
*/
|
||
function redirect_content($ip_address = null)
|
||
{
|
||
// load contact information from database
|
||
$contact = '';
|
||
$contact_information = ORM::factory('message')->where(array('type' => Message_Model::$contact_information))->find();
|
||
if ($contact_information)
|
||
{
|
||
$contact = $contact_information->text;
|
||
}
|
||
// load message
|
||
$content = '';
|
||
$footer = '';
|
||
// redirection for known IP address
|
||
if (isset($ip_address))
|
||
{
|
||
$message = $this->db->query("
|
||
SELECT m.text, mip.comment, m.self_cancel
|
||
FROM messages m
|
||
JOIN messages_ip_addresses mip ON mip.message_id = m.id
|
||
JOIN ip_addresses ip ON mip.ip_address_id = ip.id
|
||
WHERE ip.ip_address = '$ip_address'
|
||
ORDER BY m.self_cancel DESC, mip.datetime ASC
|
||
LIMIT 1
|
||
")->current();
|
||
}
|
||
// special page for unknown IP address
|
||
else
|
||
{
|
||
$message = $this->db->query("
|
||
SELECT m.text
|
||
FROM messages m
|
||
WHERE m.type = ".Message_Model::$unknown_device_message."
|
||
")->current();
|
||
}
|
||
// has been active redirection message found for current ip address?
|
||
if ($message)
|
||
{
|
||
$content = $message->text;
|
||
// has been set personal comment from administrator?
|
||
if (isset($message->comment))
|
||
{
|
||
$content = $content.'<br />'.$message->comment;
|
||
}
|
||
// has been set possibility of self-canceling message?
|
||
if (isset($message->self_cancel))
|
||
{
|
||
// is self-cancel truly enabled?
|
||
if ($message->self_cancel == Message_Model::$ip ||
|
||
$message->self_cancel == Message_Model::$member)
|
||
{
|
||
$footer = html::anchor(url_lang::base().'html/self_cancel', url_lang::lang('texts.I accept this message and I want to cancel this redirection.'));
|
||
}
|
||
}
|
||
}
|
||
// view
|
||
$view = new View('redirect_content');
|
||
$view->title = url_lang::lang('texts.Redirection');
|
||
$view->contact = $contact;
|
||
$view->content = $content;
|
||
$view->footer = $footer;
|
||
$view->render(true);
|
||
}
|
||
|
||
}
|
||
?>
|
||
?>
|
freenetis/trunk/kohana/application/controllers/redirect.php | ||
---|---|---|
$messages = $message_model->find_all();
|
||
foreach($messages as $message)
|
||
{
|
||
if ($message->type == Message_Model::$normal_message)
|
||
$message_array[$message->id] = $message->name;
|
||
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;
|
||
}
|
||
}
|
||
|
||
// form
|
||
... | ... | |
if ($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
// message_id, ip_address_id, user_id, comment, datetime
|
||
//$ip->add_redirection($form_data['message_id'], $ip->id, $this->session->get('user_id'), $form_data['comment'], date('Y-m-d'));
|
||
/*
|
||
$redir = new Messages_ip_address_Model();
|
||
$redir->message_id = $form_data['message_id'];
|
||
$redir->ip_address_id = $ip->id;
|
||
$redir->user_id = $this->session->get('user_id');
|
||
$redir->comment = $form_data['comment'];
|
||
$redir->date = date('Y-m-d');
|
||
*/
|
||
|
||
// generate html page
|
||
self::update($ip->ip_address);
|
||
|
||
// save redirection in database
|
||
$db = new Database();
|
||
try
|
||
{
|
||
// 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')));
|
||
'comment' => $form_data['comment'], 'datetime' => date('Y-m-d H:i:s')));
|
||
$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);
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
|
||
/**
|
||
* Deletes information from junction table for redirections.
|
||
* @param $ip_address_id
|
||
* @param $message_id
|
||
* @return unknown_type
|
||
*/
|
||
function delete($ip_address_id = null, $message_id = null)
|
||
{
|
||
if (!isset($ip_address_id) && !isset($message_id))
|
||
{
|
||
Controller::warning(PARAMETER);
|
||
}
|
||
$array = array();
|
||
if (isset($ip_address_id))
|
||
$array['ip_address_id'] = $ip_address_id;
|
||
if (isset($message_id))
|
||
$array['message_id'] = $message_id;
|
||
$db = new Database();
|
||
$db->delete('messages_ip_addresses', $array);
|
||
$ip = new Ip_address_Model($ip_address_id);
|
||
self::update($ip->ip_address);
|
||
$this->session->set_flash('message', url_lang::lang('texts.Redirection has been successfully canceled.'));
|
||
url::redirect(url_lang::base().'ip_addresses/show/'.$ip_address_id);
|
||
}
|
||
|
||
/**
|
||
* Updates static html file with redirection message.
|
||
* @param $ip_address
|
||
* @return unknown_type
|
||
*/
|
||
public static function update($ip_address = null)
|
||
{
|
||
$page = file_get_contents(url_lang::base().'web_interface/redirect_content/'.$ip_address);
|
||
$filename = $ip_address.'.html';
|
||
if (!isset($ip_address))
|
||
{
|
||
$filename = 'response404.html';
|
||
}
|
||
$file = fopen('html/'.$filename,'w+');
|
||
fputs($file, $page);
|
||
fclose($file);
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* Function tests redirection.
|
||
* @todo old version
|
||
* @author Jiri Svitak
|
freenetis/trunk/kohana/application/controllers/ip_addresses.php | ||
---|---|---|
echo html::anchor(url_lang::base()."devices/show/$item->device_id", $item->device_name);
|
||
}
|
||
|
||
|
||
/**
|
||
* Shows details of ip address.
|
||
* @param $ip_address_id id of ip address to show
|
||
... | ... | |
Controller::error(ACCESS);
|
||
$member = new Member_Model($member_id);
|
||
$device = new Device_Model($device_id);
|
||
$iface = new Iface_Model($iface_id);
|
||
$iface = new Iface_Model($iface_id);
|
||
// active redirections for this IP address
|
||
$db = new Database();
|
||
$messages = $db->query("
|
||
SELECT m.id, m.name, mip.ip_address_id, mip.message_id
|
||
FROM messages m
|
||
JOIN messages_ip_addresses mip ON mip.message_id = m.id
|
||
JOIN ip_addresses ip ON mip.ip_address_id = ip.id
|
||
WHERE ip.ip_address = '$ip_address->ip_address'
|
||
");
|
||
$grid = new Grid(url_lang::base().'ip_addresses', url_lang::lang('texts.Active redirections'),array(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
||
$grid->field('name')->label(url_lang::lang('texts.Redirection'));
|
||
// @todo access rights
|
||
$grid->callback_field('redirection')->label(url_lang::lang('texts.Redirection'))->callback("Ip_addresses_Controller::cancel_redirection");
|
||
$grid->datasource($messages);
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.IP address detail').' - '.$ip_address->ip_address;
|
||
$view->content = new View('ip_addresses_show');
|
||
... | ... | |
$view->content->member = $member;
|
||
$view->content->device = $device;
|
||
$view->content->iface = $iface;
|
||
$view->content->grid = $grid;
|
||
$view->content->headline = url_lang::lang('texts.IP address detail').' - '.$ip_address->ip_address;
|
||
$view->render(TRUE);
|
||
} // end of show function
|
||
|
||
public static function cancel_redirection($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base()."redirect/delete/$item->ip_address_id/$item->message_id", url_lang::lang('texts.Cancel'));
|
||
}
|
||
|
||
|
||
/**
|
||
* Adds new ip address to current interface.
|
||
* @return unknown_type
|
freenetis/trunk/kohana/application/controllers/devices.php | ||
---|---|---|
$grid_ips->field('ip_address')->label(url_lang::lang('texts.IP address'));
|
||
$grid_ips->field('subnet_name')->label(url_lang::lang('texts.Subnet name'));
|
||
if ($this->acl_check_view('Devices_Controller', 'ip_address', $member_id))
|
||
$grid_ips->action_field('id')->label(url_lang::lang('texts.IP address')) ->url(url_lang::base().'ip_addresses/show')->action(url_lang::lang('texts.Show'))->class('center');
|
||
$grid_ips->action_field('id')->label(url_lang::lang('texts.IP address'))->url(url_lang::base().'ip_addresses/show')->action(url_lang::lang('texts.Show'))->class('center');
|
||
// @todo access rights
|
||
$grid_ips->action_field('id')->label(url_lang::lang('texts.IP address'))->url(url_lang::base().'redirect/add')->action(url_lang::lang('texts.Redirect'));
|
||
$grid_ips->datasource($ips);
|
||
|
||
// ports of device
|
freenetis/trunk/kohana/application/views/redirect_content.php | ||
---|---|---|
<!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><?php echo $title ?> | <?php echo $this->settings->get('title') ?></title>
|
||
<?php echo str_replace('https', 'http', html::stylesheet('media/css/style.css', 'screen')) ?>
|
||
<style type="text/css">
|
||
#content-padd h2 {text-align: center; 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">
|
||
<?php // echo special::create_language_flags(array('cs' => 'Česky', 'en' => 'English')) ?>
|
||
</div>
|
||
<div class="map"></div>
|
||
</div>
|
||
|
||
<div id="middle">
|
||
<div id="menu">
|
||
<div id="menu-padd">
|
||
<?php echo $contact ?>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="content">
|
||
<div id="content-padd" style="margin:10px">
|
||
<?php echo $content ?>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="clear"></div>
|
||
</div>
|
||
|
||
<div id="footer">
|
||
<div id="footer-padd" style="text-align:center;">
|
||
<strong><?php echo $footer ?></strong>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</body>
|
||
</html>
|
||
|
freenetis/trunk/kohana/application/views/ip_addresses_show.php | ||
---|---|---|
</tr>
|
||
|
||
|
||
</table><br />
|
||
</table>
|
||
<br class="clear"/>
|
||
<br />
|
||
<?php echo $grid ?>
|
freenetis/trunk/kohana/application/views/redirect.php | ||
---|---|---|
<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><?php echo $title ?> | <?php echo $this->settings->get('title') ?></title>
|
||
<?php echo str_replace('https', 'http', html::stylesheet('media/css/style.css', 'screen')) ?>
|
||
<style type="text/css">
|
freenetis/trunk/kohana/html/.htaccess.sample | ||
---|---|---|
|
||
RewriteEngine On
|
||
# condition if requested URL contains in the end html or html/
|
||
RewriteCond %{REQUEST_URI} html/?$
|
||
RewriteCond %{REQUEST_URI} html/$
|
||
# 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/html/%{REMOTE_ADDR} [L]
|
||
RewriteRule .* /freenetis/html/%{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/html/response404
|
||
ErrorDocument 404 /freenetis/html/response404.html
|
Také k dispozici: Unified diff
Generovani obsahu stranek pro presmerovani.