Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 147

Přidáno uživatelem Michal Kliment před více než 15 roky(ů)

Pridan novy kontroler redirect - je dostupny i pro neprihlasene uzivatele.
Je urcen pro presmerovani - zatim funguje pouze metoda ip_info, ktera ukaze
uzivatelovi zakladni info o pc (ip adresa, nazvy segmentu a subnetu, ...).

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'aditional contacts successfully updated' => 'Další kontakty úspěšně uloženy',
'administrate additional contacts' => 'Přidávání/editace dalších kontaktních informací',
'administration of additional contacts' => 'Přidávání/editace dalších kontaktních informací',
'administration of members registrations' => 'Administrace přihlášek členů',
'administration of members registrations' => 'Administrace přihlášek členů',
'admins' => 'Správci',
'amount' => 'Částka',
'amount have to be more than 0!' => 'Částka musí být větší než 0',
'arrival'=> 'Příchozí',
......
'error' => 'Chyba',
'fee'=> 'Poplatek',
'fee or penalty comment'=> 'Komentář k poplatku/pokutě',
'from/to'=> 'Od/komu',
'from/to'=> 'Od/komu',
'gateway ip address' => 'IP adresa brány',
'gps' => 'GPS souřadnice',
'regular member'=> 'Řádný člen',
'change'=> 'Změnit',
......
'in database can be only one master bank account.'=> 'V databázi může být pouze jeden hlavní bankovní účet',
'in database can be only one operating account.'=> 'V databázi může být pouze jeden operační účet.',
'in database can be only one suppliers account.'=> 'V databázi může být pouze jeden účet dodavatelů.',
'in database can be only one unidentified account.'=> 'V databázi může být pouze jeden neidentifikovaný účet.',
'in database can be only one unidentified account.'=> 'V databázi může být pouze jeden neidentifikovaný účet.',
'information' => 'Informace',
'infrastructure account' => 'Účet infrastruktury',
'interface detail' => 'Detail rozhraní',
'interface is successfully saved' => 'Rozhraní bylo úspěšně uloženo.',
......
'type of contact'=> 'Typ kontaktu',
'type' => 'Typ',
'unconfirmed works' => 'Nepotvrzené práce',
'unidentified transfers' => 'Neidentifikované platby',
'unidentified transfers' => 'Neidentifikované platby',
'unknown ip address' => 'Neznámá IP adresa',
'unlogged user' => 'Nepřihlášený uživatel',
'update' => 'Upravit',
'user identification'=> 'Identifikace uživatele',
'user successfully added.'=> 'Uživatel úspěšně přidán',
freenetis/trunk/kohana/application/models/contact.php
<?php
class Contact_Model extends ORM {
protected $belongs_to = array('user');
public function __construct($id = false)
{
parent::__construct($id);
}
public function delete_contacts($id)
{
freenetis/trunk/kohana/application/models/user.php
class User_Model extends ORM {
protected $belongs_to = array('member');
protected $has_many = array('jobs');
protected $has_many = array('contacts','jobs');
public $arr_sql = array('id' => 'u.id', 'name' => 'u.name', 'surname' => 'u.surname', 'email' => 'u.email', 'phone' => 'u.phone', 'login' => 'u.login', 'member_name' => 'm.name');
freenetis/trunk/kohana/application/controllers/redirect.php
<?php
class Redirect_Controller extends Controller {
function index()
{
url::redirect(url::base());
}
function ip_unknown($ip_address = NULL)
{
$view = new View('template');
$view->header = new View('base/header');
$view->header->title = url_lang::lang('texts.Unknown IP address');
$view->header->menu = '';
$view->content = new View('redirect/ip_unknown');
$view->content->ip_address = $ip_address;
$view->footer = new View('base/footer');
$view->render(TRUE);
}
function ip_info()
{
$ip_address = server::remote_addr();
$ip = ip2long($ip_address);
$subnet_model = new Subnet_Model();
$subnets = $subnet_model
->select("id","name","network_address as net_str",
"inet_aton(network_address) as net",
"32-log2((~inet_aton(netmask) & 0xffffffff) + 1) as mask")
->find_all();
$arr_subnets = Array();
foreach($subnets as $subnet)
{
$mask=0xffffffff<<(32-$subnet->mask) & 0xffffffff;
if(($ip & $mask)==$subnet->net) $arr_subnets[] = $subnet;
}
if (count($arr_subnets)==0) url::redirect(url::base());
$subnet = $arr_subnets[0];
$arr_ip = explode('.', $subnet->net_str);
$arr_ip[3]++;
$gateway_ip = implode('.',$arr_ip);
$ip_model = new Ip_address_Model();
$ap = $ip_model->where('IP_address',$gateway_ip)->find();
if ($ap->iface_id!=NULL)
{
$segment_name = $ap->iface->segment->name;
$gateway_name = $ap->iface->device->name;
$device_id = $ap->iface->device->id;
}
else if ($ap->vlan_iface_id!=NULL)
{
$segment_name = $ap->vlan_iface->iface->segment->name;
$gateway_name = $ap->vlan_iface->iface->device->name;
$device_id = $ap->vlan_iface->iface->device->id;
}
$device_admin_model = new Device_admin_Model();
$device_admins = $device_admin_model->where('device_id',$device_id)->find_all();
$admins = Array();
$contact_model = new Contact_Model();
$contacts = array();
foreach($device_admins as $device_admin)
{
$admins[] = $device_admin->user;
$contacts[$device_admin->user->id] = $contact_model->where('user_id',$device_admin->user->id)->find_all();
}
$contact_type_names = Array();
$enum_type_model = new Enum_type_Model();
$translation_model = new Translation_Model();
$contact_types = $enum_type_model->where('type_id',Enum_type_Model::id_type_of_contact)->find_all();
foreach ($contact_types as $contact_type)
{
$contact_type_names[$contact_type->id] = $translation_model->get_translation($contact_type->value);
}
$view = new View('template');
$view->header = new View('base/header');
$view->header->title = url_lang::lang('texts.Information');
$view->header->menu = '';
$view->content = new View('redirect/ip_info');
$view->content->ip_address = $ip_address;
$view->content->subnet_name = $subnet->name;
$view->content->segment_name = $segment_name;
$view->content->gateway_name = $gateway_name;
$view->content->gateway_ip = $gateway_ip;
$view->content->admins = $admins;
$view->content->contacts = $contacts;
$view->content->contact_types = $contact_type_names;
$view->footer = new View('base/footer');
$view->render(TRUE);
}
public function __call($method, $arguments)
{
url::redirect(url::base());
}
}
?>
freenetis/trunk/kohana/application/libraries/MY_Controller.php
parent::__construct();
//authentication goes here for example
if (!$this->session->get('user_id', 0) && url_lang::current()!='login' && url_lang::current()!='registration' && url_lang::current()!='scheduler/run')
if (!$this->session->get('user_id', 0) && url_lang::current()!='login' && url_lang::current()!='registration' && url_lang::current()!='scheduler/run' && substr(url_lang::current(),0,9)!='redirect/')
{
// Not logged in - redirect to login page
$this->session->set_flash('err_message', url_lang::lang('texts.Must be logged in'));
freenetis/trunk/kohana/application/views/redirect/ip_info.php
<h2><?php echo url_lang::lang('texts.Information') ?></h2><br />
<b><?php echo url_lang::lang('texts.IP address') . ':' ?></b> <?php echo $ip_address ?><br />
<b><?php echo url_lang::lang('texts.Subnet name') . ':' ?></b> <?php echo $subnet_name ?><br />
<b><?php echo url_lang::lang('texts.Gateway name') . ':' ?></b> <?php echo $gateway_name ?><br />
<b><?php echo url_lang::lang('texts.Gateway IP address') . ':' ?></b> <?php echo $gateway_ip ?><br />
<b><?php echo url_lang::lang('texts.Segment name') . ':' ?></b> <?php echo $segment_name ?><br /><br />
<?php echo (count($admins)>0) ? '<h3>'.url_lang::lang('texts.Admins').'</h3>' : '' ?>
<?php foreach ($admins as $admin): ?>
<b><?php echo $admin->surname . ' '. $admin->name ?></b><br />
<?php echo $admin->member->street ?> <?php echo $admin->member->street_number ?>, <?php echo $admin->member->town ?><br />
<?php echo url_lang::lang('texts.Phone') ?>: <?php echo $admin->phone ?><br />
E-mail: <?php echo $admin->email ?><br />
<?php foreach ($contacts[$admin->id] as $contact): ?>
<?php echo $contact_types[$contact->type] ?>: <?php echo $contact->value ?><br />
<?php endforeach ?>
<br />
<?php endforeach ?>
freenetis/trunk/kohana/application/views/redirect/ip_unknown.php
<h2><?php echo url_lang::lang('texts.Unknown IP address') ?></h2><br />
<?php echo $ip_address ?>
freenetis/trunk/kohana/application/views/base/header.php
<h1><span>FreeNetIS</span></h1>
<div class="separator1"></div>
<div class="status">
<span><?php echo url_lang::lang('texts.Logged user') ?></span>&nbsp;
<span><?php echo $this->session->get('user_id', 0) ? url_lang::lang('texts.Logged user') : url_lang::lang('texts.Unlogged user') ?></span>&nbsp;
<?php echo special::create_language_flags(array('cs' => 'Česky', 'en' => 'English')) ?>
<table>
<tr>
<td class="orange"><?php echo url_lang::lang('texts.Name') ?>:</td>
<td class="orange"><?php echo $this->session->get('user_id', 0) ? url_lang::lang('texts.Name').':' : '' ?></td>
<td class="bold">&nbsp;<?php echo $this->session->get('user_name') ?></td>
</tr>
<tr>
<td class="orange"><?php echo url_lang::lang('texts.Surname') ?>:</td>
<td class="orange"><?php echo $this->session->get('user_id', 0) ? url_lang::lang('texts.Surname').':' : '' ?></td>
<td class="bold">&nbsp;<?php echo $this->session->get('user_surname') ?></td>
</tr>
</table>
</div>
<div class="map"></div>
<div class="logout"><span><?php echo html::anchor(url_lang::base().'login/logout/', url_lang::lang('texts.Logout')) ?></span></div>
<div class="logout"><span><?php echo $this->session->get('user_id', 0) ? html::anchor(url_lang::base().'login/logout/', url_lang::lang('texts.Logout')) : html::anchor(url_lang::base().'login', url_lang::lang('texts.Login')) ?></span></div>
</div>
<div id="middle">

Také k dispozici: Unified diff