Revize 1100
Přidáno uživatelem Michal Kliment před více než 13 roky(ů)
freenetis/branches/testing/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'ip addresses' => 'IP adresy',
|
||
'ip_address' => 'IP adresa',
|
||
'is' => 'je',
|
||
'is in' => 'je v',
|
||
'is not' => 'není',
|
||
'is not in' => 'není v',
|
||
'it can means that username/password/host are bad or host is unavailable' => 'To může znamenat, že uživatelské jméno/heslo/hostitel je špatné nebo je hostitel nedostupný.',
|
||
'it is not possible delete used template' => 'Není možné smazat použitou šablonu.',
|
||
'it is not possible delete item of used template' => 'Není možné smazat položku použité šablony.',
|
freenetis/branches/testing/application/vendors/unit_tester/unit_testing_config.xml | ||
---|---|---|
<input></input>
|
||
</values>
|
||
</method>
|
||
<method name="subnet_name" autogenerate="on">
|
||
<attributes></attributes>
|
||
<values>
|
||
<input></input>
|
||
</values>
|
||
</method>
|
||
</controller>
|
||
<controller name="languages">
|
||
<method name="index" autogenerate="on">
|
||
... | ... | |
</attributes>
|
||
<values>
|
||
</values>
|
||
</method></helper>
|
||
</method>
|
||
<method name="cidr_field" autogenerate="off">
|
||
<attributes>
|
||
<attribute name="item" default_value="" />
|
||
<attribute name="name" default_value="" />
|
||
</attributes>
|
||
<values>
|
||
</values>
|
||
</method>
|
||
</helper>
|
||
<helper name="cookie">
|
||
<method name="set" autogenerate="on">
|
||
<attributes>
|
freenetis/branches/testing/application/helpers/callback.php | ||
---|---|---|
{
|
||
echo strftime('%B', mktime(0,0,0,$item->month));
|
||
}
|
||
|
||
/**
|
||
* Callback function to print network address in CIDR format
|
||
*
|
||
* @author Michal Kliment
|
||
* @param type $item
|
||
* @param type $name
|
||
*/
|
||
public static function cidr_field ($item, $name)
|
||
{
|
||
$last_ip = long2ip(ip2long($item->network_address) + (~ip2long($item->netmask) & 0xffffffff));
|
||
|
||
echo "<span class='help' title='$item->network_address - $last_ip'>$item->cidr_address</span>";
|
||
}
|
||
}
|
freenetis/branches/testing/application/helpers/arr.php | ||
---|---|---|
if ( ! is_array($haystack))
|
||
return array();
|
||
|
||
if (($key = array_search($needle, $haystack)) != FALSE)
|
||
$key = array_search($needle, $haystack);
|
||
if ($key !== FALSE)
|
||
return $key;
|
||
|
||
foreach ($haystack as $key => $value)
|
freenetis/branches/testing/application/models/subnet.php | ||
---|---|---|
* @param array $filter_values
|
||
* @return integer
|
||
*/
|
||
public function count_all_subnets($filter_values = array())
|
||
public function count_all_subnets($filter_sql = '')
|
||
{
|
||
$where = '';
|
||
if (is_array($filter_values))
|
||
{
|
||
foreach($filter_values as $key => $value)
|
||
{
|
||
if ($key == 'redirect')
|
||
{
|
||
if (!$value) continue;
|
||
|
||
if ($value == 2) $value = 0;
|
||
|
||
$key = 's.redirect';
|
||
}
|
||
else if (!$this->has_column($key))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
if($key != 'submit')
|
||
{
|
||
if ($where == '')
|
||
$where = 'WHERE '.$key.' LIKE '.$this->db->escape("%$value%")
|
||
. ' COLLATE utf8_general_ci';
|
||
else
|
||
$where .= ' AND '.$key.' LIKE '.$this->db->escape("%$value%")
|
||
. ' COLLATE utf8_general_ci';
|
||
}
|
||
}
|
||
}
|
||
|
||
// filter
|
||
if ($filter_sql != '')
|
||
$where = "WHERE $filter_sql";
|
||
|
||
// query
|
||
return $this->db->query("
|
||
SELECT COUNT(*) AS total
|
||
SELECT COUNT(*) AS total FROM
|
||
(
|
||
SELECT s.id AS subnet_id, s.redirect, s.name AS subnet_name,
|
||
CONCAT(network_address,'/', 32-log2((~inet_aton(netmask) & 0xffffffff) + 1)) AS cidr_address,
|
||
INET_ATON(network_address) AS cidr,
|
||
network_address, netmask,
|
||
ROUND((
|
||
SELECT COUNT(*)
|
||
FROM ip_addresses
|
||
WHERE subnet_id = s.id
|
||
)/((~inet_aton(s.netmask) & 0xffffffff)-1)*100,1) AS used,
|
||
m.id AS member_id, m.name AS member_name
|
||
FROM subnets s
|
||
$where
|
||
LEFT JOIN subnets_owners so ON s.id = so.subnet_id
|
||
LEFT JOIN members m ON so.member_id = m.id
|
||
) s
|
||
$where
|
||
")->current()->total;
|
||
}
|
||
|
||
... | ... | |
* @return unknown_type
|
||
*/
|
||
public function get_all_subnets($limit_from = 0, $limit_results = 50,
|
||
$order_by = 'id', $order_by_direction = 'ASC', $filter_values = array())
|
||
$order_by = 'id', $order_by_direction = 'ASC', $filter_sql = '')
|
||
{
|
||
$where = '';
|
||
// order by check
|
||
if ($order_by == "cidr")
|
||
{
|
||
$order_by = 'inet_aton(network_address)';
|
||
}
|
||
else
|
||
{
|
||
$order_by = $this->db->escape_column($order_by);
|
||
}
|
||
|
||
$order_by = $this->db->escape_column($order_by);
|
||
|
||
// order by direction check
|
||
if (strtolower($order_by_direction) != 'desc')
|
||
{
|
||
$order_by_direction = 'asc';
|
||
}
|
||
|
||
// filter
|
||
if (is_array($filter_values))
|
||
{
|
||
foreach($filter_values as $key => $value)
|
||
{
|
||
if ($key == 'redirect')
|
||
{
|
||
if (!$value) continue;
|
||
|
||
if ($value == 2) $value = 0;
|
||
|
||
$key = 's.redirect';
|
||
}
|
||
if($key != 'submit')
|
||
{
|
||
if ($key == 'name')
|
||
$key = 's.name';
|
||
else if ($key == 'id')
|
||
$key = 's.id';
|
||
|
||
if ($where == '')
|
||
$where = 'WHERE ' . $this->db->escape_column($key)
|
||
. ' LIKE ' . $this->db->escape("%$value%")
|
||
. ' COLLATE utf8_general_ci';
|
||
else
|
||
$where .= ' AND ' . $this->db->escape_column($key)
|
||
. ' LIKE '.$this->db->escape("%$value%")
|
||
. ' COLLATE utf8_general_ci';
|
||
}
|
||
}
|
||
}
|
||
if ($filter_sql != '')
|
||
$where = "WHERE $filter_sql";
|
||
|
||
// query
|
||
return $this->db->query("
|
||
SELECT * FROM
|
||
(
|
||
SELECT s.id AS subnet_id, s.redirect, s.name AS subnet_name,
|
||
CONCAT(network_address,'/', 32-log2((~inet_aton(netmask) & 0xffffffff) + 1)) AS cidr,
|
||
CONCAT(network_address,'/', 32-log2((~inet_aton(netmask) & 0xffffffff) + 1)) AS cidr_address,
|
||
INET_ATON(network_address) AS cidr,
|
||
network_address, netmask,
|
||
ROUND((
|
||
SELECT COUNT(*)
|
||
... | ... | |
FROM subnets s
|
||
LEFT JOIN subnets_owners so ON s.id = so.subnet_id
|
||
LEFT JOIN members m ON so.member_id = m.id
|
||
$where
|
||
ORDER BY $order_by $order_by_direction
|
||
LIMIT ".intval($limit_from) . "," . intval($limit_results) . "
|
||
) s
|
||
$where
|
||
ORDER BY $order_by $order_by_direction
|
||
LIMIT ".intval($limit_from) . "," . intval($limit_results) . "
|
||
");
|
||
}
|
||
|
freenetis/branches/testing/application/controllers/subnets.php | ||
---|---|---|
Controller::error(ACCESS);
|
||
}
|
||
|
||
$filter_form = new Filter_form('s');
|
||
|
||
$filter_form->add('subnet_name')
|
||
->callback('json/subnet_name');
|
||
|
||
$filter_form->add('network_address')
|
||
->type('network_address')
|
||
->class(array
|
||
(
|
||
Filter_form::OPER_IS => 'ip_address',
|
||
Filter_form::OPER_IS_NOT => 'ip_address',
|
||
Filter_form::OPER_NETWORK_IS_IN => 'cidr',
|
||
Filter_form::OPER_NETWORK_IS_NOT_IN => 'cidr',
|
||
));
|
||
|
||
$filter_form->add('redirect')
|
||
->type('select')
|
||
->label('Redirection')
|
||
->values(array
|
||
(
|
||
1 => url_lang::lang('texts.Yes'),
|
||
0 => url_lang::lang('texts.No')
|
||
));
|
||
|
||
$filter_form->add('member_name')
|
||
->label('Owner')
|
||
->type('combo')
|
||
->callback('json/member_name');
|
||
|
||
$filter_form->add('used')
|
||
->type('number');
|
||
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page')))
|
||
{
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
}
|
||
|
||
// creates fields for filtering members
|
||
$filter = new Table_Form(url_lang::base().'subnets/show_all', 'get', array
|
||
(
|
||
new Table_Form_Item('text','name','Name'),
|
||
new Table_Form_Item('text','network_address','Network address'),
|
||
"tr",
|
||
new Table_Form_Item('select','redirect','Redirection', array
|
||
(
|
||
0 => '-----' ,
|
||
1 => url_lang::lang('texts.Enabled'),
|
||
2 => url_lang::lang('texts.Disabled')
|
||
)),
|
||
new Table_Form_Item('submit','submit','Filter')
|
||
));
|
||
|
||
// get query string
|
||
$arr_gets = array();
|
||
foreach ($this->input->get() as $key => $value)
|
||
{
|
||
$arr_gets[] = $key.'='.$value;
|
||
}
|
||
$query_string = '?'.implode('&',$arr_gets);
|
||
|
||
// get count of records
|
||
$subnet_model = new Subnet_Model();
|
||
$total_subnets = $subnet_model->count_all_subnets($filter->values());
|
||
$total_subnets = $subnet_model->count_all_subnets($filter_form->as_sql());
|
||
|
||
// offset check
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_subnets)
|
||
... | ... | |
// get records
|
||
$query = $subnet_model->get_all_subnets(
|
||
$sql_offset, (int) $limit_results, $order_by,
|
||
$order_by_direction, $filter->values()
|
||
$order_by_direction, $filter_form->as_sql()
|
||
);
|
||
|
||
// grid
|
||
... | ... | |
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results,
|
||
'query_string' => $query_string,
|
||
'filter' => $filter->view
|
||
'filter' => $filter_form
|
||
));
|
||
|
||
if ($this->acl_check_new('Devices_Controller', 'subnet'))
|
||
... | ... | |
->label(url_lang::lang('texts.Name'))
|
||
->callback('callback::subnet_field');
|
||
|
||
$grid->order_field('cidr')
|
||
->label(url_lang::lang('texts.Network address'));
|
||
$grid->order_callback_field('cidr')
|
||
->label(url_lang::lang('texts.Network address'))
|
||
->callback('callback::cidr_field');
|
||
|
||
$grid->order_callback_field('member_id')
|
||
->label(url_lang::lang('texts.Owner').' '.help::hint('subnet_owner'))
|
freenetis/branches/testing/application/controllers/json.php | ||
---|---|---|
|
||
echo json_encode($arr_devices);
|
||
}
|
||
|
||
/**
|
||
* Callback AJAX function to filter's whisper for subnet name
|
||
*
|
||
* @author Michal Kliment
|
||
*/
|
||
public function subnet_name()
|
||
{
|
||
$term = $this->input->get('term');
|
||
|
||
$subnet_model = new subnet_Model();
|
||
|
||
$subnets = $subnet_model->like('name', $term)->groupby('name')->orderby('name')->find_all();
|
||
|
||
$arr_subnets = array();
|
||
foreach ($subnets as $subnet)
|
||
$arr_subnets[] = $subnet->name;
|
||
|
||
echo json_encode($arr_subnets);
|
||
}
|
||
}
|
freenetis/branches/testing/application/libraries/Filter_form.php | ||
---|---|---|
/**
|
||
* Definition of constants
|
||
*/
|
||
const OPER_CONTAINS = 1;
|
||
const OPER_CONTAINS_NOT = 2;
|
||
const OPER_IS = 3;
|
||
const OPER_IS_NOT = 4;
|
||
const OPER_EQUAL = 5;
|
||
const OPER_EQUAL_NOT = 6;
|
||
const OPER_SMALLER = 7;
|
||
const OPER_SMALLER_OR_EQUAL = 8;
|
||
const OPER_GREATER = 9;
|
||
const OPER_GREATER_OR_EQUAL = 10;
|
||
const OPER_BIT_IS = 11;
|
||
const OPER_BIT_IS_NOT = 12;
|
||
const OPER_NETWORK_IS_IN = 13;
|
||
const OPER_NETWORK_IS_NOT_IN = 14;
|
||
|
||
/**
|
||
* Array with definition of all operations
|
||
* @var array
|
||
*/
|
||
protected $opers = array(
|
||
1 => array(
|
||
'name' => 'contains',
|
||
'sql' => "LIKE '%{VALUE}%' COLLATE utf8_general_ci",
|
||
),
|
||
2 => array(
|
||
'name' => 'contains not',
|
||
'sql' => "NOT LIKE '%{VALUE}%' COLLATE utf8_general_ci",
|
||
),
|
||
3 => array(
|
||
'name' => 'is',
|
||
'sql' => "LIKE '{VALUE}' COLLATE utf8_general_ci"
|
||
),
|
||
4 => array(
|
||
'name' => 'is not',
|
||
'sql' => "NOT LIKE '{VALUE}' COLLATE utf8_general_ci" ,
|
||
),
|
||
5 => array(
|
||
'name' => '=',
|
||
'sql' => "= '{VALUE}'",
|
||
),
|
||
6 => array(
|
||
'name' => '!=',
|
||
'sql' => "<> '{VALUE}'",
|
||
),
|
||
7 => array(
|
||
'name' => '<',
|
||
'sql' => "< '{VALUE}'",
|
||
),
|
||
8 => array(
|
||
'name' => '<=',
|
||
'sql' => "<= '{VALUE}'",
|
||
),
|
||
9 => array(
|
||
'name' => '>',
|
||
'sql' => "> '{VALUE}'",
|
||
),
|
||
10 => array(
|
||
'name' => '>=',
|
||
'sql' => ">= '{VALUE}'",
|
||
),
|
||
11 => array(
|
||
'name' => 'is',
|
||
'sql' => "& {VALUE} > 0",
|
||
|
||
),
|
||
12 => array(
|
||
'name' => 'is not',
|
||
'sql' => "& {VALUE} = 0",
|
||
)
|
||
protected $opers = array
|
||
(
|
||
self::OPER_CONTAINS => array
|
||
(
|
||
'name' => 'contains',
|
||
'sql' => "LIKE '%{VALUE}%' COLLATE utf8_general_ci",
|
||
),
|
||
self::OPER_CONTAINS_NOT => array
|
||
(
|
||
'name' => 'contains not',
|
||
'sql' => "NOT LIKE '%{VALUE}%' COLLATE utf8_general_ci",
|
||
),
|
||
self::OPER_IS => array
|
||
(
|
||
'name' => 'is',
|
||
'sql' => "LIKE '{VALUE}' COLLATE utf8_general_ci"
|
||
),
|
||
self::OPER_IS_NOT => array
|
||
(
|
||
'name' => 'is not',
|
||
'sql' => "NOT LIKE '{VALUE}' COLLATE utf8_general_ci" ,
|
||
),
|
||
self::OPER_EQUAL => array
|
||
(
|
||
'name' => '=',
|
||
'sql' => "= '{VALUE}'",
|
||
),
|
||
self::OPER_EQUAL_NOT => array
|
||
(
|
||
'name' => '!=',
|
||
'sql' => "<> '{VALUE}'",
|
||
),
|
||
self::OPER_SMALLER => array
|
||
(
|
||
'name' => '<',
|
||
'sql' => "< '{VALUE}'",
|
||
),
|
||
self::OPER_SMALLER_OR_EQUAL => array
|
||
(
|
||
'name' => '<=',
|
||
'sql' => "<= '{VALUE}'",
|
||
),
|
||
self::OPER_GREATER => array
|
||
(
|
||
'name' => '>',
|
||
'sql' => "> '{VALUE}'",
|
||
),
|
||
self::OPER_GREATER_OR_EQUAL => array
|
||
(
|
||
'name' => '>=',
|
||
'sql' => ">= '{VALUE}'",
|
||
),
|
||
self::OPER_BIT_IS => array
|
||
(
|
||
'name' => 'is',
|
||
'sql' => "& {VALUE} > 0",
|
||
),
|
||
self::OPER_BIT_IS_NOT => array
|
||
(
|
||
'name' => 'is not',
|
||
'sql' => "& {VALUE} = 0",
|
||
),
|
||
self::OPER_NETWORK_IS_IN => array
|
||
(
|
||
'name' => 'is in',
|
||
'pattern' => '/^(?P<VALUE1>((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9]))\/(?P<VALUE2>(3[0-2])|(2[0-9])|(1[0-9])|([0-9]))$/',
|
||
'sql' => "& (0xffffffff<<(32-{VALUE2}) & 0xffffffff) = inet_aton('{VALUE1}')",
|
||
'function' => 'inet_aton'
|
||
),
|
||
self::OPER_NETWORK_IS_NOT_IN => array
|
||
(
|
||
'name' => 'is not in',
|
||
'pattern' => '/^(?P<VALUE1>((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9]))\/(?P<VALUE2>(3[0-2])|(2[0-9])|(1[0-9])|([0-9]))$/',
|
||
'sql' => "& (0xffffffff<<(32-{VALUE2}) & 0xffffffff) <> inet_aton('{VALUE1}')",
|
||
'function' => 'inet_aton'
|
||
)
|
||
);
|
||
|
||
/**
|
||
... | ... | |
* @var array
|
||
*/
|
||
protected $operation_types = array(
|
||
'combo' => array(3,4,1,2),
|
||
'select' => array(3,4),
|
||
'text' => array(1,2,3,4),
|
||
'number' => array(5,6,7,8,9,10),
|
||
'bit' => array(11,12),
|
||
'date' => array(5,6,7,8,9,10),
|
||
'select_number' => array(3,4,5,6,7,8,9,10),
|
||
'combo' => array
|
||
(
|
||
self::OPER_IS,
|
||
self::OPER_IS_NOT,
|
||
self::OPER_CONTAINS,
|
||
self::OPER_CONTAINS_NOT
|
||
),
|
||
'select' => array
|
||
(
|
||
self::OPER_IS,
|
||
self::OPER_IS_NOT
|
||
),
|
||
'text' => array
|
||
(
|
||
self::OPER_CONTAINS,
|
||
self::OPER_CONTAINS_NOT,
|
||
self::OPER_IS,
|
||
self::OPER_IS_NOT
|
||
),
|
||
'number' => array
|
||
(
|
||
self::OPER_EQUAL,
|
||
self::OPER_EQUAL_NOT,
|
||
self::OPER_SMALLER,
|
||
self::OPER_SMALLER_OR_EQUAL,
|
||
self::OPER_GREATER,
|
||
self::OPER_GREATER_OR_EQUAL
|
||
),
|
||
'bit' => array
|
||
(
|
||
self::OPER_BIT_IS,
|
||
self::OPER_BIT_IS_NOT
|
||
),
|
||
'date' => array
|
||
(
|
||
self::OPER_EQUAL,
|
||
self::OPER_EQUAL_NOT,
|
||
self::OPER_SMALLER,
|
||
self::OPER_SMALLER_OR_EQUAL,
|
||
self::OPER_GREATER,
|
||
self::OPER_GREATER_OR_EQUAL
|
||
),
|
||
'select_number' => array
|
||
(
|
||
self::OPER_IS,
|
||
self::OPER_IS_NOT,
|
||
self::OPER_EQUAL,
|
||
self::OPER_EQUAL_NOT,
|
||
self::OPER_SMALLER,
|
||
self::OPER_SMALLER_OR_EQUAL,
|
||
self::OPER_GREATER,
|
||
self::OPER_GREATER_OR_EQUAL
|
||
),
|
||
'network_address' => array
|
||
(
|
||
self::OPER_IS,
|
||
self::OPER_IS_NOT,
|
||
self::OPER_CONTAINS,
|
||
self::OPER_CONTAINS_NOT,
|
||
self::OPER_NETWORK_IS_IN,
|
||
self::OPER_NETWORK_IS_NOT_IN
|
||
)
|
||
);
|
||
|
||
/**
|
||
... | ... | |
'text' => 1,
|
||
'bit' => 0,
|
||
'date' => 1,
|
||
'select_number' => 0
|
||
'select_number' => 0,
|
||
'network_address' => 1
|
||
);
|
||
|
||
/**
|
||
... | ... | |
* @var array
|
||
*/
|
||
protected $returns = array(
|
||
'combo' => 'value',
|
||
'combo' => 'value',
|
||
'select' => 'key',
|
||
'text' => 'value',
|
||
'bit' => 'key',
|
||
'number' => 'value',
|
||
'date' => 'value',
|
||
'select_number' => 'key',
|
||
'network_address' => 'value'
|
||
);
|
||
|
||
/**
|
||
... | ... | |
$withouts[$filter->name] = 1;
|
||
|
||
$tables[$filter->name] = $filter->table;
|
||
|
||
$classes[$filter->name] = $filter->class;
|
||
|
||
if (is_array($filter->class))
|
||
$classes[$filter->name] = $filter->class;
|
||
else
|
||
$classes[$filter->name] = array('all' => $filter->class);
|
||
}
|
||
|
||
$operations = array();
|
||
... | ... | |
$queries = array();
|
||
foreach ($this->types as $i => $type)
|
||
{
|
||
$filter = $this->filters[$type];
|
||
$filter = $this->filters[$type];
|
||
|
||
$value = trim($this->values[$i]);
|
||
$value = trim($this->values[$i]);
|
||
|
||
if ($this->returns[$filter->type] == 'key' && arr::search($value, $filter->values) !== FALSE)
|
||
$value = arr::search($value, $filter->values);
|
||
if ($this->returns[$filter->type] == 'key' && arr::search($value, $filter->values) !== FALSE)
|
||
$value = arr::search($value, $filter->values);
|
||
|
||
$queries[] = "$filter->table.$filter->name ".str_replace("{VALUE}", mysql_real_escape_string($value), $this->opers[$this->operations[$i]]['sql']);
|
||
$sql = $this->opers[$this->operations[$i]]['sql'];
|
||
|
||
if (isset($this->opers[$this->operations[$i]]['pattern']))
|
||
{
|
||
if (!preg_match($this->opers[$this->operations[$i]]['pattern'], mysql_real_escape_string($value), $matches))
|
||
continue;
|
||
|
||
foreach ($matches as $key => $value)
|
||
$sql = str_replace('{'.$key.'}', mysql_real_escape_string($value), $sql);
|
||
}
|
||
|
||
if (isset($this->opers[$this->operations[$i]]['function']))
|
||
$queries[] = $this->opers[$this->operations[$i]]['function']."($filter->table.$filter->name) ".str_replace("{VALUE}", mysql_real_escape_string($value), $sql);
|
||
else
|
||
$queries[] = "$filter->table.$filter->name ".str_replace("{VALUE}", mysql_real_escape_string($value), $sql);
|
||
}
|
||
|
||
return implode (" AND ", $queries);
|
freenetis/branches/testing/application/libraries/Filter.php | ||
---|---|---|
* Basic data of object
|
||
* @var array
|
||
*/
|
||
protected $data = array(
|
||
'type' => 'text',
|
||
'default' => array()
|
||
protected $data = array
|
||
(
|
||
'type' => 'text',
|
||
'default' => array()
|
||
);
|
||
|
||
/**
|
||
... | ... | |
*/
|
||
public function __get ($key)
|
||
{
|
||
if (isset ($this->data[$key]))
|
||
{
|
||
return $this->data[$key];
|
||
}
|
||
if (isset ($this->data[$key]))
|
||
{
|
||
return $this->data[$key];
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Method to set label of filter
|
||
*
|
||
* @author Michal Kliment
|
||
* @param string $label
|
||
* @param boolean $use_translation
|
||
* @return Filter
|
||
*/
|
||
public function label ($label, $use_translation = TRUE)
|
||
{
|
||
if ($use_translation)
|
||
$this->data['label'] = url_lang::lang('texts.'.$label);
|
||
else
|
||
$this->data['label'] = $label;
|
||
|
||
return $this;
|
||
}
|
||
|
||
/**
|
||
* Magic method to set some basic data
|
freenetis/branches/testing/application/views/main.php | ||
---|---|---|
$.validator.addMethod('ip_address', function(value) {
|
||
return value.match(/^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])$/);
|
||
}, '<?php echo url_lang::lang('texts.Invalid IP address') ?>');
|
||
|
||
$.validator.addMethod('cidr', function(value) {
|
||
var result = value.match(/^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9][0-9])|[0-9])\/((3[0-2])|(2[0-9])|(1[0-9])|([0-9]))$/);
|
||
if (!result)
|
||
return false;
|
||
var s = value.split("/");
|
||
return ((ip2long(s[0]) & (0xffffffff<<(32-s[1]) & 0xffffffff)) == ip2long(s[0]));
|
||
}, '<?php echo url_lang::lang('texts.Invalid IP address') ?>');
|
||
|
||
$.validator.addMethod('mac_address', function(value) {
|
||
return value.match(/^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/);
|
freenetis/branches/testing/application/views/filter_form_template.php | ||
---|---|---|
type_values[i][$(this).val()] = (typeof(values[0]) != 'string' && values[0] != undefined) ? values[0][$(this).next().val()] : values[0];
|
||
|
||
$(this).next().next().val(type_values[i][$(this).val()]);
|
||
|
||
|
||
var without = withouts[$(this).val()];
|
||
$(this).next().next().attr ('class', 'v '+types[$(this).val()]+' '+classes[$(this).val()]);
|
||
|
||
if (classes[$(this).val()][$(this).next().val()] != undefined)
|
||
$(this).next().next().attr ('class', 'v '+types[$(this).val()]+' '+classes[$(this).val()][$(this).next().val()]);
|
||
else if (classes[$(this).val()]['all'] != undefined)
|
||
$(this).next().next().attr ('class', 'v '+types[$(this).val()]+' '+classes[$(this).val()]['all']);
|
||
else
|
||
$(this).next().next().attr ('class', 'v '+types[$(this).val()]);
|
||
|
||
if (without)
|
||
{
|
||
$(this).next().next().addClass('without_select_button');
|
||
... | ... | |
<?php endforeach; ?>
|
||
}
|
||
|
||
var classes = {
|
||
<?php foreach ($classes as $name => $class): ?>
|
||
'<?php echo $name ?>': ["<?php echo $class ?>"],
|
||
classes = {
|
||
<?php foreach ($classes as $name => $oper_class): ?>
|
||
'<?php echo $name ?>': {
|
||
<?php foreach ($oper_class as $oper => $class): ?>
|
||
'<?php echo $oper ?>': ["<?php echo $class ?>"],
|
||
<?php endforeach ?>
|
||
},
|
||
<?php endforeach ?>
|
||
}
|
||
|
Také k dispozici: Unified diff
Implementace noveho filtru u podsiti...