Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1686

Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)

Merge oprav v 1.1 vetvi do testingu
--------------------------------------------------------------------------------------------------------------------------------

Upravy:

- v knihove Database umozneno pripojovat se do jine DB (aktulne to slo jen do DB nastavene v config.php)
- vylepseno vyhledavani a pridavani ulic a mest (get_street, get_town)

Opravy:

- #305: Grid IP adress u profilu clena nezvlada velke mnozstvi IP adres
- #309: Nelze zobrazit IP adresu pokud nema rozhrani
- #310: Nekontrolovani kompatibility linky s novym typem rozhrani u editace rozhrani
- opraveny callbacky pro presmerovaci zpéravu u zobrazeni IP adres

Zobrazit rozdíly:

freenetis/branches/testing/application/helpers/callback.php
{
if (empty($item->message_id))
{
echo ' ';
echo ' - ';
}
else
{
......
public static function message_field($item, $name)
{
// system messages
if ($item->type >= 0)
if ($item->type > 0)
{
// system messages
echo __($item->message);
}
elseif ($item->type == 0)
else if ($item->type === 0)
{
// user messages
echo $item->message;
......
else
{
// null value means no message
echo __('No redirection');
echo '<span style="color: #999">' . __('No redirection') . '</span>';
}
}
......
if ($message->type == Message_Model::CONTACT_INFORMATION ||
$message->type == Message_Model::CANCEL_MESSAGE ||
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE)
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE ||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
{
echo '&nbsp;';
}
......
if ($message->type == Message_Model::CONTACT_INFORMATION ||
$message->type == Message_Model::CANCEL_MESSAGE ||
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE)
$message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE ||
$message->type == Message_Model::RECEIVED_PAYMENT_NOTICE_MESSAGE)
{
echo '&nbsp;';
}
......
{
$message = new Message_Model($item->id);
echo html::anchor(
url::base().'redirection/?id='.$message->id,
__('Preview'), array('target' => '_blank')
);
if (empty($message->text))
{
echo '<span class="red">' . __('Empty') . '</span>';
}
else
{
echo html::anchor(
url::base().'redirection/?id='.$message->id,
__('Preview'), array('target' => '_blank')
);
}
}
/**
freenetis/branches/testing/application/models/town.php
* Not exists - create it a return it
*
* @author Michal Kliment
* @param string $zip_code zip code
* @param string $zip_code zip code (if set to FALSE, do not search by ZIP code)
* @param string $town town
* @param string $quarter quarter
* @return Town_Model
*/
public function get_town($zip_code = NULL, $town = NULL, $quarter = NULL)
{
$towns = $this->where(array
(
'zip_code' => $zip_code,
'town' => $town,
'quarter' => $quarter
))->find_all();
if ($zip_code === FALSE) // do not search
{
$zip_code_where = '';
}
else if (empty($zip_code))
{
$zip_code_where = ' AND zip_code IS NULL';
}
else
{
$zip_code_where = ' AND LOWER(zip_code) = ' . $this->db->escape(strtolower($zip_code));
}
if (empty($quarter))
{
$quarter_where = ' AND quarter IS NULL';
}
else
{
$quarter_where = ' AND LOWER(quarter) = ' . $this->db->escape(strtolower($quarter));
}
$towns = $this->db->query("
SELECT *
FROM towns
WHERE LOWER(town) = ? $zip_code_where $quarter_where
", strtolower($town));
if (count($towns) == 0)
{
freenetis/branches/testing/application/models/ip_address.php
* @property bool $service
* @property integer $whitelisted
* @property integer $member_id
* @property Member_Model $member
*/
class Ip_address_Model extends ORM
{
protected $belongs_to = array('iface', 'subnet');
protected $belongs_to = array('iface', 'subnet', 'member');
/**
* No whitelist means, that is ip address can be redirected in any time
......
", Message_Model::SELF_CANCEL_DISABLED);
}
/**
* Gets all ip addresses including their redirections.
* Used in member's profile screen.
*
* @author Jiri Svitak
* @param integer $member_id
* @param integer $sql_offset
* @param integer $limit_results
* @param string $order_by
* @param string $order_by_direction
* @return Mysql_Result
*/
public function get_ips_and_redirections_of_member($member_id)
public function get_ips_and_redirections_of_member(
$member_id, $sql_offset, $limit_results,
$order_by, $order_by_direction)
{
// order by
if (strtolower($order_by) == 'ip_address')
{
$order_by = 'inet_aton(ip.ip_address)';
}
else
{
$order_by = $this->db->escape_column($order_by);
}
// order by direction
if (strtolower($order_by_direction) != 'asc')
{
$order_by_direction = 'desc';
}
return $this->db->query("
SELECT ip.id AS ip_address_id, ip.ip_address, ip.whitelisted,
m.id AS message_id, m.name AS message, m.type, ? AS member_id
m.id AS message_id, m.name AS message, m.type, ? AS member_id,
mip.datetime AS active_redir_datetime
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
......
LEFT JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
LEFT JOIN messages m ON m.id = mip.message_id
WHERE u.member_id = ? OR ip.member_id = ?
ORDER BY inet_aton(ip.ip_address) ASC,
ORDER BY $order_by $order_by_direction,
m.self_cancel DESC, mip.datetime ASC
LIMIT " . intval($sql_offset) . ", " . intval($limit_results) . "
", $member_id, $member_id, $member_id);
}
/**
* Gets count of all ip addresses including their redirections.
* Used in member's profile screen.
*
* @author Ondřej Fibich
* @param integer $member_id
* @return integer
*/
public function count_ips_and_redirections_of_member($member_id)
{
return $this->db->query("
SELECT COUNT(*) AS total
FROM ip_addresses ip
LEFT JOIN ifaces i ON ip.iface_id = i.id
LEFT JOIN devices d ON i.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
LEFT JOIN messages_ip_addresses mip ON mip.ip_address_id = ip.id
LEFT JOIN messages m ON m.id = mip.message_id
WHERE u.member_id = ? OR ip.member_id = ?
", $member_id, $member_id, $member_id)->current()->total;
}
/**
* Counts all ip addresses by member and subnet
freenetis/branches/testing/application/models/street.php
*/
public function get_street($street = NULL, $town_id = NULL)
{
$streets = $this->where(array
(
'street' => $street,
'town_id' => $town_id
))->find_all();
$streets = $this->db->query("
SELECT *
FROM streets
WHERE town_id = ? AND LOWER(street) = ?
", $town_id, strtolower($street));
if (count($streets) == 0)
{
freenetis/branches/testing/application/controllers/ifaces.php
try
{
$iface->transaction_start();
$old_type = $iface->type;
$iface->name = $form_data['name'];
$iface->type = $form_data['itype'];
......
$im_connect_to->link_id = $lm->id;
$im_connect_to->save_throwable();
}
// disconnect
else if (isset($_POST['change_link']) && $_POST['change_link'])
{
$iface->link_id = null;
}
// do not changes link commonly, but if type changed we must
// look if the current link can be used on new type
// this code resolves (#310)
else if ($old_type != $iface->type)
{
$mediums = $iface->get_types_has_link_with_medium($iface->type);
if ($iface->link_id &&
!array_key_exists($iface->link->medium, $mediums))
{
$iface->link_id = null;
}
}
}
else
{
freenetis/branches/testing/application/controllers/members.php
* @param string $order_by_direction sorting direction
*/
public function show(
$member_id = NULL, $order_by = 'member_id',
$order_by_direction = 'ASC')
$member_id = NULL, $limit_results = 20, $order_by = 'ip_address',
$order_by_direction = 'ASC', $page_word = null, $page = 1)
{
// parameter is wrong
if (!$member_id || !is_numeric($member_id))
......
(
'separator' => '<br /><br />',
'use_paginator' => false,
'use_selector' => false,
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'variables' => $member_id.'/'
'use_selector' => false
));
$voip_grid->field('id')
......
$membership_interrupts_grid->datasource($membership_interrupts);
// activated redirections of member, including short statistic of whitelisted IP addresses
$ip_model = new Ip_address_Model();
$ip_addresses = $ip_model->get_ips_and_redirections_of_member($member_id);
$total_ips = $ip_model->count_ips_and_redirections_of_member($member_id);
// get new selector
if (is_numeric($this->input->get('record_per_page')))
$limit_results = (int) $this->input->get('record_per_page');
// limit check
if (($sql_offset = ($page - 1) * $limit_results) > $total_ips)
$sql_offset = 0;
$ip_addresses = $ip_model->get_ips_and_redirections_of_member(
$member_id, $sql_offset, $limit_results,
$order_by, $order_by_direction
);
$redir_grid = new Grid('members', null, array
(
'use_paginator' => false,
'use_selector' => false
'selector_increace' => 20,
'selector_min' => 20,
'selector_max_multiplier' => 10,
'current' => $limit_results,
'base_url' => Config::get('lang'). '/members/show/' . $member_id . '/'
. $limit_results.'/'.$order_by.'/'.$order_by_direction,
'uri_segment' => 'page',
'total_items' => $total_ips,
'items_per_page' => $limit_results,
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results,
'variables' => $member_id . '/',
'url_array_ofset' => 1,
'query_string' => $this->input->get(),
));
if ($this->acl_check_new('Messages_Controller', 'member'))
if ($this->acl_check_new('Messages_Controller', 'member') &&
$total_ips < 1000) // limited count
{
$redir_grid->add_new_button(
'redirect/activate_to_member/'.$member_id,
......
);
}
$redir_grid->callback_field('ip_address')
$redir_grid->order_callback_field('ip_address')
->label(__('IP address'))
->callback('callback::ip_address_field');
$redir_grid->callback_field('whitelisted')
$redir_grid->order_callback_field('whitelisted')
->label(__('Whitelist').'&nbsp;'.help::hint('whitelist'))
->callback('callback::whitelisted_field');
$redir_grid->callback_field('message')
$redir_grid->order_callback_field('message')
->label(__('Activated redirection').'&nbsp;'.help::hint('activated_redirection'))
->callback('callback::message_field');
......
{
$redir_grid->callback_field('redirection')
->label(__('Canceling of message for redirection'))
->callback("callback::cancel_redirection_of_member");
->callback('callback::cancel_redirection_of_member');
}
$redir_grid->datasource($ip_addresses);
freenetis/branches/testing/application/controllers/settings.php
// set logs checkbox value to db
Settings::set('action_logs_active', $action_logs_active);
//$config_model->update_variable('ulogd_enabled', $ulogd_enabled);
Settings::set('ulogd_enabled', $ulogd_enabled);
Settings::set('syslog_ng_mysql_api_enabled', $syslog_ng_mysql_api_enabled);
$issaved = true;
......
{
Members_traffic_Model::create_tables(TRUE);
Ulog2_ct_Model::create_functions();
Settings::set('ulogd_enabled', 1);
}
catch (Exception $e)
{
......
else
{
Ulog2_ct_Model::destroy_functions();
Settings::set('ulogd_enabled', 0);
}
foreach ($form_data as $name => $value)
freenetis/branches/testing/system/libraries/Database.php
*/
public function __construct($config = array())
{
// Parse the DSN, creating an array to hold the connection parameters
$db = array
(
'type' => 'mysql',
'user' => FALSE,
'pass' => FALSE,
'host' => FALSE,
'port' => FALSE,
'socket' => FALSE,
'database' => FALSE
);
if (!is_array($config) && count($config))
{
// Parse the DSN, creating an array to hold the connection parameters
$db = array
(
'type' => 'mysql',
'user' => FALSE,
'pass' => FALSE,
'host' => FALSE,
'port' => FALSE,
'socket' => FALSE,
'database' => FALSE
);
// Reset the connection array to the database config
$this->config['connection'] = $db;
// Reset the connection array to the database config
$this->config['connection'] = $db;
if (Config::get('db_type') != '')
$this->config['connection']['type'] = Config::get('db_type');
if (Config::get('db_type') != '')
$this->config['connection']['type'] = Config::get('db_type');
$this->config['connection']['user'] = Config::get('db_user');
$this->config['connection']['pass'] = Config::get('db_password');
$this->config['connection']['host'] = Config::get('db_host');
$this->config['connection']['database'] = Config::get('db_name');
$this->config['connection']['user'] = Config::get('db_user');
$this->config['connection']['pass'] = Config::get('db_password');
$this->config['connection']['host'] = Config::get('db_host');
$this->config['connection']['database'] = Config::get('db_name');
$this->config['table_prefix'] = Config::get('db_table_prefix');
$this->config['table_prefix'] = Config::get('db_table_prefix');
}
else
{
$this->config['connection'] = $config;
}
// Set driver name
$driver = 'Database_'.ucfirst($this->config['connection']['type']).'_Driver';

Také k dispozici: Unified diff