Revize 483
Přidáno uživatelem Jiří Sviták před asi 15 roky(ů)
freenetis/trunk/kohana/application/models/subnet.php | ||
---|---|---|
$where = '';
|
||
foreach($filter_values as $key => $value)
|
||
{
|
||
if ($key == 'name')
|
||
$key = 's.name';
|
||
if($key!='submit')
|
||
{
|
||
if ($where == '')
|
||
... | ... | |
$where .= ' AND '.$key.' LIKE \'%'.$value.'%\' COLLATE utf8_general_ci';
|
||
}
|
||
}
|
||
return self::$db->query("SELECT subnets.*, segments.name as segment
|
||
FROM subnets
|
||
LEFT JOIN segments ON subnets.segment_id = segments.id
|
||
return self::$db->query("SELECT s.*, se.name as segment
|
||
FROM subnets s
|
||
LEFT JOIN segments se ON s.segment_id = se.id
|
||
$where
|
||
ORDER BY $order_by $order_by_direction
|
||
LIMIT $limit_from, $limit_results
|
freenetis/trunk/kohana/application/controllers/tools.php | ||
---|---|---|
|
||
function index()
|
||
{
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Tools');
|
||
$view->content = new View('tools/index');
|
||
$view->content->headline = url_lang::lang('texts.Tools');
|
||
$view->render(TRUE);
|
||
if (!$this->acl_check_edit('Devices_Controller', 'tools'))
|
||
Controller::error(ACCESS);
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Tools');
|
||
$view->content = new View('tools/index');
|
||
$view->content->headline = url_lang::lang('texts.Tools');
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
function ssh($ip = NULL, $port = NULL)
|
||
function ssh($ip = NULL, $port = NULL)
|
||
{
|
||
if (!isset($ip))
|
||
if (!valid::ip($ip))
|
||
$ip = '';
|
||
if (!$this->acl_check_edit('Devices_Controller', 'tools'))
|
||
Controller::error(ACCESS);
|
||
if (!isset($ip))
|
||
if (!valid::ip($ip))
|
||
$ip = '';
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.ssh');
|
||
$view->content = new View('tools/ssh');
|
||
$view->content->headline = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.ssh');
|
||
$view->content->ip = $ip;
|
||
$view->render(TRUE);
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.ssh');
|
||
$view->content = new View('tools/ssh');
|
||
$view->content->headline = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.ssh');
|
||
$view->content->ip = $ip;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
function telnet($ip = NULL, $port = NULL)
|
||
function telnet($ip = NULL, $port = NULL)
|
||
{
|
||
if (!isset($ip))
|
||
if (!valid::ip($ip))
|
||
$ip = '';
|
||
if (!$this->acl_check_edit('Devices_Controller', 'tools'))
|
||
Controller::error(ACCESS);
|
||
if (!isset($ip))
|
||
if (!valid::ip($ip))
|
||
$ip = '';
|
||
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.telnet');
|
||
$view->content = new View('tools/telnet');
|
||
$view->content->headline = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.telnet');
|
||
$view->content->ip = $ip;
|
||
$view->render(TRUE);
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.telnet');
|
||
$view->content = new View('tools/telnet');
|
||
$view->content->headline = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.telnet');
|
||
$view->content->ip = $ip;
|
||
$view->render(TRUE);
|
||
|
||
}
|
||
|
||
function whois($hostname = NULL)
|
||
function whois($hostname = NULL)
|
||
{
|
||
if (!$this->input->post('query') == NULL)
|
||
$hostname = $this->input->post('query');
|
||
if (!$this->acl_check_edit('Devices_Controller', 'tools'))
|
||
Controller::error(ACCESS);
|
||
if (!$this->input->post('query') == NULL)
|
||
$hostname = $this->input->post('query');
|
||
|
||
$winfo = '';
|
||
$winfo = '';
|
||
|
||
if (isset($hostname))
|
||
{
|
||
require_once(APPPATH.'vendors/phpwhois/whois.main.php');
|
||
include_once(APPPATH.'vendors/phpwhois/whois.utils.php');
|
||
if (isset($hostname))
|
||
{
|
||
require_once(APPPATH.'vendors/phpwhois/whois.main.php');
|
||
include_once(APPPATH.'vendors/phpwhois/whois.utils.php');
|
||
|
||
$whois = new Whois();
|
||
$query = $hostname;
|
||
$result = $whois->Lookup($query);
|
||
$whois = new Whois();
|
||
$query = $hostname;
|
||
$result = $whois->Lookup($query);
|
||
|
||
if (!empty($result['rawdata']))
|
||
{
|
||
$utils = new utils;
|
||
$winfo = $utils->showHTML($result);
|
||
}
|
||
else
|
||
{
|
||
if (isset($whois->Query['errstr']))
|
||
$winfo = implode($whois->Query['errstr'],"\n<br></br>");
|
||
else
|
||
$winfo = url_lang::lang('texts.Unexpected error');
|
||
}
|
||
}
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.whois');
|
||
$view->content = new View('tools/whois');
|
||
$view->content->headline = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.whois');
|
||
$view->content->hostname = $hostname;
|
||
$view->content->winfo = $winfo;
|
||
$view->render(TRUE);
|
||
if (!empty($result['rawdata']))
|
||
{
|
||
$utils = new utils;
|
||
$winfo = $utils->showHTML($result);
|
||
}
|
||
else
|
||
{
|
||
if (isset($whois->Query['errstr']))
|
||
$winfo = implode($whois->Query['errstr'],"\n<br></br>");
|
||
else
|
||
$winfo = url_lang::lang('texts.Unexpected error');
|
||
}
|
||
}
|
||
$view = new View('main');
|
||
$view->title = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.whois');
|
||
$view->content = new View('tools/whois');
|
||
$view->content->headline = url_lang::lang('texts.Tools').' - '.url_lang::lang('texts.whois');
|
||
$view->content->hostname = $hostname;
|
||
$view->content->winfo = $winfo;
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
|
freenetis/trunk/kohana/application/controllers/transfers.php | ||
---|---|---|
$view->render(TRUE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Function deducts member fees.
|
||
* @return unknown_type
|
||
*/
|
||
function deduct_fees()
|
||
{
|
||
// access rights
|
||
if (!$this->acl_check_new('Accounts_Controller', 'transfers'))
|
||
Controller::error(ACCESS);
|
||
// content of dropdown for months
|
||
for ($i = 1; $i <= 12; $i++)
|
||
$arr_months[$i] = $i;
|
||
// content of dropdown for years
|
||
$year_from = date('Y') - 20;
|
||
for ($i = 1; $i <= 20; $i++)
|
||
$arr_years[$i] = $year_from + $i;
|
||
$form = new Forge(url_lang::base().'transfers/deduct_fees', '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->dropdown('year')->label(url_lang::lang('texts.Year').':')->rules('required')->options($arr_years)->selected(20);
|
||
$form->dropdown('month')->label(url_lang::lang('texts.Month from').':')->rules('required')->options($arr_months)->selected(1);
|
||
$form->dropdown('months')->label(url_lang::lang('texts.Number of months').':')->rules('required')->options($arr_months)->selected(1)->callback(array($this, 'valid_months'));
|
||
$form->input('fee')->label(url_lang::lang('texts.Monthly member fee').':')->rules('required|valid_numeric');
|
||
$form->input('text')->label(url_lang::lang('texts.Text').':');
|
||
$form->submit('submit')->value(url_lang::lang('texts.Deduct'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
// form validation
|
||
if ($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
foreach($form_data as $key => $value)
|
||
{
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
$year = $arr_years[$form_data['year']];
|
||
$month = $form_data['month'];
|
||
$months = $form_data['months'];
|
||
$fee = $form_data['fee'];
|
||
$text = $form_data['text'];
|
||
// all transfers should have the same date and time of creation
|
||
$creation_datetime = date('Y-m-d H:i:s');
|
||
// and all transfers should have the same date of deduct start
|
||
$datetime = date('Y-m-d H:i:s', mktime(0, 0, 0, $month, 1, $year));
|
||
// database models
|
||
$transfer = new Transfer_Model();
|
||
$member_model = new Member_Model();
|
||
$account_model = new Account_Model();
|
||
$mi_model = new Membership_interrupt_Model();
|
||
// it gets ids and member ids of all credit accounts
|
||
$credit_accounts = $account_model->get_accounts_of_regular_members();
|
||
// it gets id of operating account, the only destination account
|
||
$oa = ORM::factory('account')->find_by_account_attribute_id(Account_attribute_Model::$operating);
|
||
// it supposes that everything will be ok, if a transfer couldn't be created, it sets to false
|
||
$save_successful = true;
|
||
// it is suppossed that thousands of transfers will be generated, transaction processing required
|
||
$db = new Database();
|
||
$db->query("BEGIN;");
|
||
// it goes through all credit accounts and it creates their outbound transfers to operating account
|
||
foreach($credit_accounts as $ca)
|
||
{
|
||
// starting month
|
||
$start = $month;
|
||
// finishing month
|
||
$finish = $month + $months - 1;
|
||
// member fee info includes entrance date, leaving date and member type
|
||
$member_fee_info = $member_model->get_fee_information($ca->id);
|
||
// for every account it gets entrance year and month of its owning member
|
||
$entrance = date_parse($member_fee_info->entrance_date);
|
||
// entrance date is rounded
|
||
$entrance = date_parse(date::round_month($entrance['day'], $entrance['month'], $entrance['year']));
|
||
$e_year = $entrance['year'];
|
||
$e_month = $entrance['month'];
|
||
$e_day = $entrance['day'];
|
||
// fee is deducted only if membership exists before upper date of deducting interval
|
||
$e_okay = ($e_year < $year) || ($e_year == $year && $e_month <= $finish);
|
||
// if member entered association after start of deducting interval
|
||
if ($e_year == $year && $e_month > $start)
|
||
{
|
||
$start = $e_month;
|
||
}
|
||
// for every account it gets leaving year and month of its owning member
|
||
$leaving_date = date_parse($member_fee_info->leaving_date);
|
||
// if leaving date was set
|
||
if ($leaving_date['year'] != '0')
|
||
{
|
||
// leaving date is rounded
|
||
$leaving_date = date_parse(date::round_month($leaving_date['day'], $leaving_date['month'], $leaving_date['year']));
|
||
$l_year = $leaving_date['year'];
|
||
$l_month = $leaving_date['month'];
|
||
$l_day = $leaving_date['day'];
|
||
// fee is deducted only if membership exists before upper date of deducting interval
|
||
$l_okay = ($l_year > $year) || ($l_year == $year && $l_month > $start);
|
||
// if member left before end of deducting interval
|
||
if ($l_year == $year && $l_month <= $finish)
|
||
{
|
||
// leaving month is not included in deduction
|
||
$finish = $l_month - 1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$l_okay = true;
|
||
}
|
||
// for every member it searches interrupts of membership
|
||
$mis = $mi_model->get_mi($ca->member_id);
|
||
// defualt number of months with interrupted membership
|
||
$interrupted = 0;
|
||
foreach ($mis as $mi)
|
||
{
|
||
$from = date_parse($mi->from);
|
||
$from = date_parse(date::round_month($from['day'], $from['month'], $from['year']));
|
||
$to = date_parse($mi->to);
|
||
$to = date_parse(date::round_month($to['day'], $to['month'], $to['year']));
|
||
// membership was interrupted before starting month and interrupt lasted after finishing one
|
||
if ((($from['year'] < $year) || ($from['year'] == $year && $from['month'] <= $start))
|
||
&& (($to['year'] > $year) || ($to['year'] == $year && $to['month'] >= $finish)))
|
||
{
|
||
// all months will be interrupted, no fee is deducted
|
||
$interrupted += $finish - $start;
|
||
}
|
||
// membership was interrupted before starting month,
|
||
// but interrupt ended after starting one and before finishing one
|
||
else if ((($from['year'] < $year) || ($from['year'] == $year && $from['month'] < $start))
|
||
&& ($to['year'] == $year && $to['month'] >= $start)
|
||
&& ($to['year'] == $year && $to['month'] < $finish))
|
||
{
|
||
$interrupted += $to['month'] - $start;
|
||
}
|
||
// membership was interrupted after starting month and before finishing month,
|
||
// and interrupt ended after finishing month
|
||
else if (($from['year'] == $year && $from['month'] > $start)
|
||
&& ($from['year'] == $year && $from['month'] <= $finish)
|
||
&& (($to['year'] > $year) || ($to['year'] == $year && $to['month'] > $finish)))
|
||
{
|
||
$interrupted += $finish - $from['month'];
|
||
}
|
||
// membership was interrupted after starting month and before finishing month
|
||
else if (($from['year'] == $year && $from['month'] >= $start)
|
||
&& ($to['year'] == $year && $to['month'] <= $finish))
|
||
{
|
||
$interrupted += $to['month'] - $from['month'];
|
||
}
|
||
}
|
||
// total months to deduct fees
|
||
$total_months = $finish - $start + 1 - $interrupted;
|
||
// if deducting interval is between entrance and leaving date, transfer will be generated
|
||
if ($e_okay && $l_okay && $total_months > 0)
|
||
{
|
||
// trying to find existing transfer of given year
|
||
$existing = $transfer->get_deduct_transfer($year, $ca->id);
|
||
if (is_object($existing))
|
||
$transfer = new Transfer_Model($existing->id);
|
||
else
|
||
$transfer = new Transfer_Model();
|
||
$transfer->origin_id = $ca->id;
|
||
$transfer->destination_id = $oa->id;
|
||
$transfer->user_id = $this->session->get('user_id');
|
||
$transfer->type = Transfer_Model::$deduct_member_fee;
|
||
$transfer->datetime = $datetime;
|
||
$transfer->creation_datetime = $creation_datetime;
|
||
$transfer->text = $text;
|
||
$transfer->amount = $total_months * $fee;
|
||
// money transfer is saved and checked
|
||
if (!$transfer->save())
|
||
$save_successful = false;
|
||
}
|
||
}
|
||
// end of transaction processing
|
||
if ($save_successful)
|
||
{
|
||
$db->query("COMMIT;");
|
||
$this->session->set_flash('message', url_lang::lang('texts.Fees have been successfully deducted.'));
|
||
}
|
||
else
|
||
{
|
||
$db->query("ROLLBACK;");
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - some fees have not been deducted.'));
|
||
}
|
||
url::redirect(url_lang::base().'transfers/show_all');
|
||
}
|
||
else
|
||
{
|
||
$headline = url_lang::lang('texts.Deduction of member fees');
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->content = new View('form');
|
||
$view->content->headline = $headline;
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = html::anchor(url_lang::base().'transfers/show_all',url_lang::lang('texts.Back to day book'));
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Function returns true if member has to pay fee in given month, else it returns false.
|
||
* @param $member_id
|
||
* @param $month
|
||
* @return unknown_type
|
||
*/
|
||
private function has_to_pay($member_id = null, $month = null)
|
||
{
|
||
if ($member_id == null || $month == null)
|
||
Controller::error(RECORD, 'unexpected error in transfers/has_to_pay function');
|
||
$member = new Member_Model($member_id);
|
||
if ($member->id == 0)
|
||
Controller::error(RECORD);
|
||
// entrance date
|
||
$entrance = $member->entrance_date <= $month;
|
||
// leaving date
|
||
$leaving = $member->leaving_date > $month;
|
||
}
|
||
|
||
public function pokus()
|
||
{
|
||
echo '2009-08-07'<='2010-09-04';
|
||
}
|
||
|
||
/**
|
||
* Function deducts member fees.
|
||
* @return unknown_type
|
||
*/
|
||
/*
|
||
function deduct_fees()
|
||
{
|
||
// access rights
|
||
... | ... | |
$view->render(TRUE);
|
||
}
|
||
}
|
||
*/
|
||
|
||
/**
|
||
* Function deducts entrance fees. This fee is deducted only one once to each member.
|
freenetis/trunk/kohana/application/controllers/voip.php | ||
---|---|---|
|
||
function show_all($limit_results = 500, $order_by = 'user_id', $order_by_direction = 'asc', $page_word = null, $page = 1)
|
||
{
|
||
if (!$this->acl_check_view('VoIP_Controller', 'voip'))
|
||
Controller::error(ACCESS);
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
... | ... | |
function show($user_id = NULL)
|
||
{
|
||
if (!isset($user_id))
|
||
Controller::warning(1);
|
||
Controller::warning(PARAMETER);
|
||
|
||
$voip_sip = new Voip_sip_Model();
|
||
$voip = $voip_sip->get_record_by_user_limited($user_id);
|
||
|
||
// misto toho zkus toto
|
||
// $voip_sip = ORM::factory('voip_sip')->find_by_user($user_id);
|
||
// a pro prava
|
||
// if (!this->acl_check_view('VoIP_Controller', 'voip', $voip_sip->user->member_id)) Controller:error(ACCESS);
|
||
|
||
if ($voip->count() == 0)
|
||
Controller::error(4);
|
||
Controller::error(RECORD);
|
||
|
||
$config = new Config_Model();
|
||
$config->get_value_from_name('voip_sip_server');
|
Také k dispozici: Unified diff
Oprava chyby ve filtru podsiti. Pridany prava do tools, neco do voip.