Revize 1263
Přidáno uživatelem Ondřej Fibich před asi 13 roky(ů)
freenetis/branches/testing/application/vendors/unit_tester/unit_testing_config.xml | ||
---|---|---|
</input>
|
||
</values>
|
||
</method>
|
||
<method name="get_allowed_ip_addresses" autogenerate="on">
|
||
<attributes></attributes>
|
||
<values>
|
||
<input></input>
|
||
</values>
|
||
</method>
|
||
<method name="get_ip_addresses_of_member" autogenerate="off">
|
||
<attributes>
|
||
<attribute name="member_id" default_value=""/>
|
||
... | ... | |
</input>
|
||
</values>
|
||
</method>
|
||
<method name="get_active_traffic_members_ip_addresses" autogenerate="on">
|
||
<attributes></attributes>
|
||
<values>
|
||
<input></input>
|
||
</values>
|
||
</method>
|
||
<method name="get_registered_members" autogenerate="on">
|
||
<attributes></attributes>
|
||
<values>
|
||
... | ... | |
</input>
|
||
</values>
|
||
</method>
|
||
<method name="get_redirected_ranges" autogenerate="on">
|
||
<attributes></attributes>
|
||
<values>
|
||
<input></input>
|
||
</values>
|
||
</method>
|
||
<method name="count_all_subnets" autogenerate="on">
|
||
<attributes>
|
||
<attribute name="filter_sql" default_value="" />
|
||
... | ... | |
</input>
|
||
</values>
|
||
</method>
|
||
<method name="get_voip_sip_by_name" autogenerate="on">
|
||
<attributes>
|
||
<attribute name="name" default_value="" />
|
||
</attributes>
|
||
<values>
|
||
<input>
|
||
<param value="" />
|
||
</input>
|
||
</values>
|
||
</method>
|
||
<method name="get_record_by_user_limited" autogenerate="off">
|
||
<attributes>
|
||
<attribute name="user_id" default_value=""/>
|
freenetis/branches/testing/application/models/subnet.php | ||
---|---|---|
)->where('id', $subnet_id)
|
||
->find();
|
||
}
|
||
|
||
/**
|
||
* Gets redirected ranges.
|
||
* Any IP address belonging to these subnet ranges can be redirected.
|
||
*
|
||
* @see Web_interface_Controller
|
||
* @return ORM_Iterator
|
||
*/
|
||
public function get_redirected_ranges()
|
||
{
|
||
return $this->db->query("
|
||
SELECT DISTINCT CONCAT(
|
||
network_address, '/',
|
||
32-log2((~inet_aton(netmask) & 0xffffffff) + 1)
|
||
) AS subnet_range
|
||
FROM subnets
|
||
WHERE redirect = 1
|
||
");
|
||
}
|
||
|
||
/**
|
||
* Function counts all subnets specified by filter.
|
freenetis/branches/testing/application/models/ip_address.php | ||
---|---|---|
}
|
||
|
||
/**
|
||
* Gets all allowed IP addresses.
|
||
* These are registered IP addresses, which have no redirection set.
|
||
* Unknown IP addresses (not present in system) and
|
||
* IP addresses with a redirection set are not exported.
|
||
*
|
||
* @see Web_interface_Controller#allowed_ip_addresses
|
||
* @return ORM_Iterator
|
||
*/
|
||
public function get_allowed_ip_addresses()
|
||
{
|
||
return $this->db->query("
|
||
SELECT DISTINCT ip.ip_address
|
||
FROM ip_addresses ip
|
||
LEFT JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
|
||
WHERE mip.ip_address_id IS NULL OR
|
||
(
|
||
whitelisted > 0 AND ip_address NOT IN
|
||
(
|
||
SELECT DISTINCT ip.ip_address
|
||
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
|
||
WHERE m.ignore_whitelist = 1
|
||
)
|
||
)
|
||
");
|
||
}
|
||
|
||
/**
|
||
* Function gets all ip address of interfaces of devices of users of given member.
|
||
*
|
||
* @param integer $member_id
|
freenetis/branches/testing/application/models/voip_sip.php | ||
---|---|---|
FROM voip_sips WHERE id = ?
|
||
", $id);
|
||
}
|
||
|
||
|
||
/**
|
||
* Gets VoIP SIP with name.
|
||
*
|
||
* @param string $name VoIP number
|
||
* @return ORM_Iterator
|
||
*/
|
||
public function get_voip_sip_by_name($name)
|
||
{
|
||
return $this->db->query("
|
||
SELECT DISTINCT name, secret
|
||
FROM voip_sips
|
||
WHERE name = ?
|
||
", $name);
|
||
}
|
||
|
||
/**
|
||
* Function gets one record by user.
|
||
*
|
||
* @param integer $user_id
|
freenetis/branches/testing/application/models/member.php | ||
---|---|---|
*/
|
||
class Member_Model extends ORM
|
||
{
|
||
protected $has_one = array('allowed_subnets_count', 'members_traffic','members_domicile');
|
||
protected $has_one = array
|
||
(
|
||
'allowed_subnets_count', 'members_traffic', 'members_domicile'
|
||
);
|
||
|
||
protected $has_many = array
|
||
(
|
||
'allowed_subnets', 'invoices', 'users', 'accounts',
|
||
'transfers', 'bank_accounts', 'membership_interrupts'
|
||
);
|
||
protected $belongs_to = array('address_point','user');
|
||
|
||
protected $belongs_to = array('address_point', 'user');
|
||
|
||
const TYPE_APPLICANT = 1;
|
||
const TYPE_HONORARY = 3;
|
||
... | ... | |
|
||
return NULL;
|
||
}
|
||
|
||
/**
|
||
* Returns IP addresses of the most traffic-active members
|
||
*
|
||
* @see Web_interface_Controller#active_traffic_members_ip_addresses
|
||
* @author Michal Kliment
|
||
* @return ORM_Iterator
|
||
*/
|
||
public function get_active_traffic_members_ip_addresses()
|
||
{
|
||
return $this->db->query("
|
||
SELECT IFNULL(ip.ip_address, vip.ip_address) AS ip_address FROM
|
||
(
|
||
SELECT member_id FROM members_traffics
|
||
WHERE active = 1
|
||
) AS t
|
||
JOIN users u ON u.member_id = t.member_id
|
||
JOIN devices d ON d.user_id = u.id
|
||
LEFT JOIN ifaces i ON i.device_id = d.id
|
||
LEFT JOIN vlan_ifaces vi ON vi.iface_id = i.id
|
||
LEFT JOIN ip_addresses ip ON ip.iface_id = i.id
|
||
LEFT JOIN ip_addresses vip ON vip.vlan_iface_id = vi.id
|
||
WHERE ip.ip_address IS NOT NULL OR vip.ip_address IS NOT NULL
|
||
");
|
||
}
|
||
|
||
/**
|
||
* Function gets list of all members from database.
|
freenetis/branches/testing/application/controllers/web_interface.php | ||
---|---|---|
* for example network gateways, routers, access points etc.
|
||
*
|
||
* @author Jiri Svitak
|
||
* @todo REWRITE TO PROPER ARCHITECTURE
|
||
* @package Controller
|
||
*/
|
||
class Web_interface_Controller extends Controller
|
||
{
|
||
|
||
public function __construct()
|
||
{
|
||
parent::__construct();
|
||
$this->db = Database::instance();
|
||
}
|
||
|
||
/**
|
||
* Index prints about message
|
||
*/
|
||
public function index()
|
||
{
|
||
echo __('Interface for communication over http protocol with remote devices');
|
||
}
|
||
|
||
/**
|
||
* Prints to output all subnets which have enabled redirection. Any IP address belonging to these
|
||
* subnet ranges can be redirected.
|
||
* Prints to output all subnets which have enabled redirection.
|
||
* Any IP address belonging to these subnet ranges can be redirected.
|
||
*
|
||
* @author Jiri Svitak
|
||
* @return unknown_type
|
||
*/
|
||
public function redirected_ranges()
|
||
{
|
||
$ranges = $this->db->query("
|
||
SELECT DISTINCT CONCAT(
|
||
network_address, '/',
|
||
32-log2((~inet_aton(netmask) & 0xffffffff) + 1)
|
||
) AS subnet_range
|
||
FROM subnets
|
||
WHERE redirect = 1
|
||
");
|
||
$ranges = ORM::factory('subnet')->get_redirected_ranges();
|
||
|
||
foreach ($ranges as $range)
|
||
{
|
||
echo "$range->subnet_range\n";
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Prints all allowed IP addresses. These are registered IP addresses, which have no redirection set.
|
||
* Unknown IP addresses (not present in system) and IP addresses with a redirection set are not exported.
|
||
* Prints all allowed IP addresses.
|
||
* These are registered IP addresses, which have no redirection set.
|
||
* Unknown IP addresses (not present in system) and
|
||
* IP addresses with a redirection set are not exported.
|
||
*
|
||
* @author Jiri Svitak
|
||
* @return unknown_type
|
||
*/
|
||
public function allowed_ip_addresses()
|
||
{
|
||
$ips = $this->db->query("
|
||
SELECT DISTINCT ip.ip_address
|
||
FROM ip_addresses ip
|
||
LEFT JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
|
||
WHERE mip.ip_address_id IS NULL OR
|
||
(
|
||
whitelisted > 0 AND ip_address NOT IN
|
||
(
|
||
SELECT DISTINCT ip.ip_address
|
||
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
|
||
WHERE m.ignore_whitelist = 1
|
||
)
|
||
)
|
||
");
|
||
$ips = ORM::factory('ip_address')->get_allowed_ip_addresses();
|
||
|
||
foreach ($ips as $ip)
|
||
{
|
||
echo "$ip->ip_address\n";
|
||
... | ... | |
exit;
|
||
}
|
||
|
||
$voip = $this->db->query('
|
||
SELECT DISTINCT name, secret
|
||
FROM voip_sips
|
||
WHERE name = ?
|
||
', $user);
|
||
$voip = ORM::factory('voip_sip')->get_voip_sip_by_name($user);
|
||
|
||
if (count($voip) == 0 || $voip->current()->secret != $pass)
|
||
{
|
||
... | ... | |
*/
|
||
public function active_traffic_members_ip_addresses()
|
||
{
|
||
$ips = $this->db->query("
|
||
SELECT IFNULL(ip.ip_address, vip.ip_address) AS ip_address FROM
|
||
(
|
||
SELECT member_id FROM members_traffics
|
||
WHERE active = 1
|
||
) AS t
|
||
JOIN users u ON u.member_id = t.member_id
|
||
JOIN devices d ON d.user_id = u.id
|
||
LEFT JOIN ifaces i ON i.device_id = d.id
|
||
LEFT JOIN vlan_ifaces vi ON vi.iface_id = i.id
|
||
LEFT JOIN ip_addresses ip ON ip.iface_id = i.id
|
||
LEFT JOIN ip_addresses vip ON vip.vlan_iface_id = vi.id
|
||
WHERE ip.ip_address IS NOT NULL OR vip.ip_address IS NOT NULL
|
||
");
|
||
$ips = ORM::factory('member')->get_active_traffic_members_ip_addresses();
|
||
|
||
foreach ($ips as $ip)
|
||
{
|
freenetis/branches/testing/application/controllers/voip_calls.php | ||
---|---|---|
* @param string $area
|
||
* @return string
|
||
*/
|
||
protected static function parse_number($number, $area = '')
|
||
public static function parse_number($number, $area = '')
|
||
{
|
||
// uses static variables to save memory
|
||
static $contact_model, $country_model;
|
||
... | ... | |
}
|
||
else
|
||
{ // it couldn't find number in anywhere, prints it in pretty format
|
||
if ($user_id == $this->session->get('user_id'))
|
||
if ($user_id == Session::get('user_id'))
|
||
{
|
||
return $pretty_number . ' ' . html::anchor(
|
||
'private_phone_contacts/add/' .
|
Také k dispozici: Unified diff
Uprava:
- uprava architektonicky chybneho web_interface controlleru, prace s databazi presunuta do modelu
Oprava:
- oprava chyby ve VoIPu zanesena predchozimi commity