Revize 1034
Přidáno uživatelem Michal Kliment před více než 13 roky(ů)
freenetis/trunk/kohana/application/helpers/callback.php | ||
---|---|---|
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function amount_field($item, $name)
|
||
public static function amount_field($item, $name)
|
||
{
|
||
if ($item->amount > 0)
|
||
echo '<span style="color:green">'.number_format((float)$item->amount, 2, ',', ' ').'</span>';
|
||
... | ... | |
* @param $item
|
||
* @param $name
|
||
*/
|
||
static function origin_account_field($item, $name)
|
||
public static function origin_account_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base().'transfers/show_by_account/'.$item->oa_id, $item->oa_name);
|
||
}
|
||
... | ... | |
* @param $item
|
||
* @param $name
|
||
*/
|
||
static function destination_account_field($item, $name)
|
||
public static function destination_account_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base().'transfers/show_by_account/'.$item->da_id, $item->da_name);
|
||
}
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function redirect_field($item, $name)
|
||
public static function redirect_field($item, $name)
|
||
{
|
||
$redirstr = '';
|
||
// membership Interrupt redirection - letter I
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
static function member_type_name_field($item, $name)
|
||
public static function member_type_name_field($item, $name)
|
||
{
|
||
$abbreviation = '';
|
||
$words = explode(' ', $item->type_name);
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function member_field($item, $name, $args = array())
|
||
public static function member_field($item, $name, $args = array())
|
||
{
|
||
if ($item->member_id)
|
||
echo html::anchor(url_lang::base()."members/show/$item->member_id", $item->member_name);
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function subnet_field($item, $name)
|
||
public static function subnet_field($item, $name)
|
||
{
|
||
if ($item->subnet_id)
|
||
echo html::anchor(url_lang::base()."subnets/show/$item->subnet_id", $item->subnet_name);
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function ip_address_field($item, $name, $args = array())
|
||
public static function ip_address_field($item, $name, $args = array())
|
||
{
|
||
$ip_address = (isset($args[0]) && $args[0]) ? $item->ip_address.'/'.$item->subnet_range : $item->ip_address;
|
||
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function segment_field($item, $name)
|
||
public static function segment_field($item, $name)
|
||
{
|
||
if ($item->segment_id)
|
||
echo html::anchor(url_lang::base()."segments/show/$item->segment_id", $item->segment_name);
|
||
... | ... | |
* @param $item
|
||
* @param $name
|
||
*/
|
||
static function device_field($item, $name)
|
||
public static function device_field($item, $name)
|
||
{
|
||
if ($item->device_id)
|
||
echo html::anchor(url_lang::base()."devices/show/$item->device_id", $item->device_name);
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function device_type_field($item, $name)
|
||
public static function device_type_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base()."devices/show/$item->device_id", $item->type);
|
||
}
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function device_price_field($item, $name)
|
||
public static function device_price_field($item, $name)
|
||
{
|
||
if (!$item->price)
|
||
return;
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function iface_field($item, $name)
|
||
public static function iface_field($item, $name)
|
||
{
|
||
if ($item->iface_id)
|
||
echo html::anchor(url_lang::base()."ifaces/show/$item->iface_id", $item->mac);
|
||
... | ... | |
* @param $item
|
||
* @param $name
|
||
*/
|
||
static function user_field($item, $name)
|
||
public static function user_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base()."users/show/$item->user_id", $item->user_name);
|
||
}
|
||
... | ... | |
* @param unknown_type $item
|
||
* @param unknown_type $name
|
||
*/
|
||
static function user_login_field($item, $name)
|
||
public static function user_login_field($item, $name)
|
||
{
|
||
echo html::anchor(url_lang::base()."users/show/$item->user_id", $item->user_login);
|
||
}
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
public function active_field($item, $name)
|
||
public static function active_field($item, $name)
|
||
{
|
||
// 1 => active, 0 => inactive
|
||
switch ($item->$name)
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
public function used_field ($item, $name)
|
||
public static function used_field ($item, $name)
|
||
{
|
||
$color = '';
|
||
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
public function iface_vlan_iface_field ($item, $name)
|
||
public static function iface_vlan_iface_field ($item, $name)
|
||
{
|
||
if ($item->iface_id)
|
||
echo html::anchor (url_lang::base().'ifaces/show/'.$item->iface_id, $item->iface_name, array('title' => url_lang::lang('texts.Show interface')));
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
public function vlan_field ($item, $name)
|
||
public static function vlan_field ($item, $name)
|
||
{
|
||
echo html::anchor (url_lang::base().'vlans/show/'.$item->vlan_id, $item->vlan_name, array('title' => url_lang::lang('texts.Show VLAN')));
|
||
}
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
public function vlan_iface_field ($item, $name)
|
||
public static function vlan_iface_field ($item, $name)
|
||
{
|
||
echo html::anchor (url_lang::base().'vlan_ifaces/show/'.$item->vlan_iface_id, $item->vlan_iface_name, array('title' => url_lang::lang('texts.Show VLAN interface')));
|
||
}
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
public function port_field ($item, $name)
|
||
public static function port_field ($item, $name)
|
||
{
|
||
echo html::anchor (url_lang::base().'ports/show/'.$item->port_id, $item->port_name, array('title' => url_lang::lang('texts.Show port')));
|
||
}
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
public function iface_id_field ($item, $name)
|
||
public static function iface_id_field ($item, $name)
|
||
{
|
||
echo html::anchor (url_lang::base().'ifaces/show/'.$item->iface_id, $item->iface_id, array('title' => url_lang::lang('texts.Show interface')));
|
||
}
|
||
... | ... | |
* @param <type> $name
|
||
* @param array $args
|
||
*/
|
||
public function edit_field ($item, $name, $args = array())
|
||
public static function edit_field ($item, $name, $args = array())
|
||
{
|
||
if (Session::instance()->get('user_id') == $item->user_id)
|
||
echo html::anchor (url_lang::base().$args[0].'/edit/'.$item->id, url_lang::lang('texts.Edit'));
|
||
... | ... | |
* @param <type> $name
|
||
* @param array $args
|
||
*/
|
||
public function delete_field ($item, $name, $args = array())
|
||
public static function delete_field ($item, $name, $args = array())
|
||
{
|
||
if (Session::instance()->get('user_id') == $item->user_id)
|
||
echo html::anchor (url_lang::base().$args[0].'/delete/'.$item->id, url_lang::lang('texts.Delete'), array('class' => 'delete_link'));
|
||
... | ... | |
* @param <type> $item
|
||
* @param <type> $name
|
||
*/
|
||
public function comments_field ($item, $name)
|
||
public static function comments_field ($item, $name)
|
||
{
|
||
echo $item->comments_count;
|
||
if ($item->comments_count)
|
||
... | ... | |
*/
|
||
public static function segment_medium_field ($item, $name)
|
||
{
|
||
echo url_lang::lang('texts.'.Segment_Model::$types[$item->medium_id]);;
|
||
echo url_lang::lang('texts.'.Segment_Model::$types[$item->medium_id]);
|
||
}
|
||
|
||
/**
|
||
... | ... | |
* @param <type> $name
|
||
* @param <type> $args
|
||
*/
|
||
public function enabled_field($item, $name, $args = array())
|
||
public static function enabled_field($item, $name, $args = array())
|
||
{
|
||
// 1 => active, 0 => inactive
|
||
switch ($item->$name)
|
freenetis/trunk/kohana/application/models/iface.php | ||
---|---|---|
<?php
|
||
<?php
|
||
class Iface_Model extends ORM {
|
||
|
||
|
||
protected $belongs_to = array('segment','device');
|
||
protected $has_many = array('vlan_ifaces','ip_addresses');
|
||
protected $has_one = array('wireless_setting');
|
||
... | ... | |
{
|
||
return $this->db->where('device_id', $device_id)->count_records('ifaces');
|
||
}
|
||
|
||
|
||
/**
|
||
* Function gets all interfaces.
|
||
* @param $limit_from
|
||
... | ... | |
LIMIT $limit_from, $limit_results
|
||
");
|
||
}
|
||
|
||
|
||
/**
|
||
* Function counts all interfaces.
|
||
* @return unknown_type
|
||
*/
|
||
public function count_all_ifaces($filter_values = array())
|
||
public function count_all_ifaces($filter_values = array())
|
||
{
|
||
//return $this->db->count_records('ifaces');
|
||
$where = '';
|
||
... | ... | |
$where
|
||
")->current()->total;
|
||
}
|
||
|
||
|
||
public function get_ifaces_of_segment($segment_id)
|
||
{
|
||
return $this->db->query("
|
||
... | ... | |
WHERE i.segment_id = $segment_id
|
||
");
|
||
}
|
||
|
||
|
||
/**
|
||
* Function gets count of specified mac address. Used for testing existence of that mac.
|
||
* @param $mac searched mac address
|
||
... | ... | |
{
|
||
return $this->db->where('mac', $mac)->count_records('ifaces');
|
||
}
|
||
|
||
|
||
/**
|
||
* Function gets interfaces of given device, used for deleting.
|
||
* @param $device_id
|
||
... | ... | |
public function get_all_ifaces_of_device ($device_id)
|
||
{
|
||
return $this->db->query("
|
||
SELECT i.id, i.id AS iface_id, i.segment_id, sg.name AS segment_name, i.mac, i.name, i.comment, ip.subnet_id, sb.name as subnet_name, ip.id AS ip_address_id, ip.ip_address, 32-log2((~inet_aton(sb.netmask) & 0xffffffff) + 1) AS subnet_range
|
||
SELECT i.id, i.id AS iface_id, i.segment_id, sg.name AS segment_name, i.mac, i.name, i.comment, ip.subnet_id, sb.name as subnet_name, ip.id AS ip_address_id, ip.ip_address, 32-log2((~INET_ATON(sb.netmask) & 0xffffffff) + 1) AS subnet_range
|
||
FROM ifaces i
|
||
LEFT JOIN ip_addresses ip ON ip.iface_id = i.id
|
||
LEFT JOIN segments sg ON i.segment_id = sg.id
|
||
LEFT JOIN subnets sb ON ip.subnet_id = sb.id
|
||
WHERE i.device_id = ?
|
||
ORDER BY inet_aton (ip.ip_address)
|
||
ORDER BY INET_ATON(ip.ip_address)
|
||
", array($device_id));
|
||
}
|
||
|
||
|
||
public function count_ws_of_iface($iface_id)
|
||
{
|
||
return $this->db->query("SELECT count(*) as total
|
||
... | ... | |
}
|
||
}
|
||
|
||
?>
|
||
?>
|
freenetis/trunk/kohana/application/models/vlan_iface.php | ||
---|---|---|
<?php
|
||
<?php
|
||
class Vlan_iface_Model extends ORM {
|
||
|
||
|
||
protected $belongs_to = array('iface','vlan');
|
||
protected $has_many = array('ip_addresses');
|
||
|
||
public function count_all_vlan_ifaces()
|
||
public function count_all_vlan_ifaces()
|
||
{
|
||
return $this->db->count_records('vlan_ifaces');
|
||
}
|
||
... | ... | |
i.name AS iface_name,
|
||
ip.id AS ip_address_id,
|
||
ip.ip_address,
|
||
32-log2((~inet_aton(s.netmask) & 0xffffffff) + 1) AS subnet_range
|
||
32-log2((~INET_ATON(s.netmask) & 0xffffffff) + 1) AS subnet_range
|
||
FROM vlan_ifaces vi
|
||
LEFT JOIN vlans v ON vi.vlan_id = v.id
|
||
LEFT JOIN ifaces i ON vi.iface_id = i.id
|
||
LEFT JOIN ip_addresses ip ON vi.id = ip.vlan_iface_id
|
||
LEFT JOIN subnets s ON ip.subnet_id = s.id
|
||
WHERE i.device_id = ?
|
||
ORDER BY inet_aton (ip.ip_address)
|
||
ORDER BY INET_ATON(ip.ip_address)
|
||
", array ($device_id));
|
||
}
|
||
}
|
||
|
||
?>
|
||
?>
|
freenetis/trunk/kohana/application/controllers/redirect.php | ||
---|---|---|
|
||
|
||
/**
|
||
* Function tests redirection.
|
||
* @todo old version
|
||
* @author Jiri Svitak
|
||
* @param $redir
|
||
* @return unknown_type
|
||
* Test method to view given type of redirect
|
||
*
|
||
* @author Michal Kliment
|
||
* @param integer$redir
|
||
*/
|
||
function test($redir = 0)
|
||
{
|
||
... | ... | |
$continue = 0;
|
||
$device_engineers = array();
|
||
$device_admins = array();
|
||
switch ($redir)
|
||
// trying to find ip remote ip address in database
|
||
$ip = server::remote_addr();
|
||
$member = ORM::factory('member')->get_member_by_ip_address($ip);
|
||
$ip_address = ORM::factory('ip_address')->find_redirect_by_ip_address($ip);
|
||
// ip address is not in database, choosing content of message
|
||
if ($redir == 0)
|
||
{
|
||
case 0:
|
||
$content = $this->settings->get('unknown_device');
|
||
break;
|
||
case 1:
|
||
$content = $this->settings->get('interrupt');
|
||
break;
|
||
case 2:
|
||
$content = $this->settings->get('debtor');
|
||
break;
|
||
case 4:
|
||
$content = $this->settings->get('payment_notice');
|
||
$continue = -1;
|
||
break;
|
||
case 8:
|
||
$content = $this->settings->get('optional_message');
|
||
$continue = -1;
|
||
break;
|
||
$content = $this->settings->get('unknown_device');
|
||
}
|
||
// optional message redirection
|
||
elseif ($redir == 8)
|
||
{
|
||
$content = $this->settings->get('optional_message');
|
||
$continue = 8;
|
||
}
|
||
// payment notice redirection
|
||
elseif ($redir == 4)
|
||
{
|
||
$content = $this->settings->get('payment_notice');
|
||
$continue = 4;
|
||
}
|
||
// debtor redirection
|
||
elseif ($redir == 2)
|
||
{
|
||
$content = $this->settings->get('debtor');
|
||
}
|
||
// membership interrupt redirection
|
||
elseif ($redir == 1)
|
||
{
|
||
$content = $this->settings->get('interrupt');
|
||
}
|
||
// no reason to redirect, this shouldn't happen
|
||
else
|
||
{
|
||
$content = $this->settings->get('website_after_redirection');
|
||
}
|
||
// engineer of user's device, owner of ip address - if available
|
||
if ($member && $member->id)
|
||
{
|
||
$member_name = $member->name;
|
||
$login = $member->login;
|
||
$device = ORM::factory('device')->get_by_ip_address($ip);
|
||
if ($device && $device->id)
|
||
{
|
||
$device_engineer_model = new Device_engineer_Model();
|
||
$device_engineers = $device_engineer_model->get_device_engineers($device->id);
|
||
}
|
||
|
||
}
|
||
// trying to find subnet of visitor's ip address
|
||
$subnet_model = new Subnet_Model();
|
||
$subnet = $subnet_model->get_subnet_of_ip_address($ip);
|
||
// remote ip address belongs to some subnet
|
||
if ($subnet !== false)
|
||
{
|
||
//$subnet = $arr_subnets[0];
|
||
$subnet_name = $subnet->name;
|
||
// finding subnet's gateway
|
||
$gw = ORM::factory('device')->get_gateway_of_subnet($subnet->id);
|
||
// admin of access point - only if ap exists
|
||
if ($gw && $gw->id)
|
||
$device_admins = ORM::factory('device_admin')->get_device_admins($gw->id);
|
||
}
|
||
// view
|
||
|
||
$view = new View('redirect');
|
||
$view->title = url_lang::lang('texts.Redirection');
|
||
$view->ip_address = $ip;
|
||
$view->subnet_name = $subnet_name;
|
||
$view->member_name = $member_name;
|
||
$view->login = $login;
|
||
$view->device_engineers = $device_engineers;
|
||
$view->device_admins = $device_admins;
|
||
$view->content = $content;
|
||
$view->content = stripslashes($content);
|
||
$view->continue = $continue;
|
||
$view->render(true);
|
||
$view->render(true);
|
||
}
|
||
|
||
/**
|
freenetis/trunk/kohana/application/libraries/Forge.php | ||
---|---|---|
$form->inputs = $this->inputs;
|
||
}
|
||
|
||
return $form;
|
||
return $form->render();
|
||
}
|
||
|
||
/**
|
freenetis/trunk/kohana/application/libraries/MY_Controller.php | ||
---|---|---|
url_lang::current() != 'registration' &&
|
||
url_lang::current()!='scheduler/run' &&
|
||
strpos(url_lang::current(), 'redirect')===false &&
|
||
url_lang::current(TRUE)!='web_interface' &&
|
||
url_lang::current()!='installation')
|
||
{
|
||
// Not logged in - redirect to login page
|
freenetis/trunk/kohana/application/views/devices_show_by_user.php | ||
---|---|---|
<a name="device_<?php echo $id ?>_link" href="<?php echo url_lang::base() ?>devices/show/<?php echo $id ?>" title="<?php echo url_lang::lang('texts.Show device') ?>"><?php echo url_lang::lang('texts.device') ?> <?php echo $device['name'] ?> (<?php echo $device['type'] ?>)</a>
|
||
<img src="<?php echo url::base() ?>media/images/ico_minus.gif" id="device_<?php echo $id ?>_button" class="device_button">
|
||
<?php echo html::anchor (url_lang::base().'devices/edit/'.$id, html::image(array('src' => url::base().'media/images/icons/gtk_edit.png')), array('title' => url_lang::lang('texts.Edit device'))) ?>
|
||
<?php echo html::anchor (url_lang::base().'devices/delete_whole/'.$id, html::image(array('src' => url::base().'media/images/icons/delete.png')), array('title' => url_lang::lang('texts.Delete device'), 'class' => 'delete_link')) ?>
|
||
<?php echo html::anchor (url_lang::base().'devices/delete_whole/'.$id, html::image(array('src' => url::base().'media/images/icons/delete.png', 'class' => 'delete_link')), array('title' => url_lang::lang('texts.Delete device'), 'class' => 'delete_link')) ?>
|
||
</h3><br />
|
||
|
||
<div id="device_<?php echo $id ?>" class="device">
|
Také k dispozici: Unified diff
Commit do trunku - pouze opraveny chyby na starsim PHP 5.2.6 (Debian Lenny), nove veci zatim ponechany v testingu...