public function test_quotes_to_entities()
 {
     $strs = array('"me oh my!"' => '"me oh my!"', "it's a winner!" => 'it's a winner!');
     foreach ($strs as $str => $expect) {
         $this->assertEquals($expect, quotes_to_entities($str));
     }
 }
Example #2
0
 public function inserir($tarefa)
 {
     $this->load->helper('string');
     // hack pra converter data do input html5 no formato mysql
     $ano = date("Y", strtotime($tarefa['data_inicio']));
     $mes = date("m", strtotime($tarefa['data_inicio']));
     $dia = date("d", strtotime($tarefa['data_inicio']));
     $anop = date("Y", strtotime($tarefa['data_prazo']));
     $mesp = date("m", strtotime($tarefa['data_prazo']));
     $diap = date("d", strtotime($tarefa['data_prazo']));
     // instancia o objeto
     $this->codigo = NULL;
     $this->titulo = $tarefa['titulo'];
     $this->descricao = quotes_to_entities($tarefa['descricao']);
     $this->prioridade = $tarefa['prioridade'];
     $this->data_inicio = $ano . '-' . $mes . '-' . $dia;
     $this->data_prazo = $anop . '-' . $mesp . '-' . $diap;
     $this->data_fim = NULL;
     $this->criado_por = $tarefa['criado_por'];
     $this->codigo_projeto = $tarefa['codigo_projeto'];
     $this->codigo_usuario = $tarefa['lider'][0];
     // usuário ativo
     $this->codigo_status = $tarefa['codigo_status'];
     // echo "<pre>";
     //   var_dump($this);
     // echo "</pre>";
     if ($this->db->insert('tarefa', $this)) {
         $inserido = $this->db->insert_id();
         return true;
         //<br>Código: " . $inserido;
     } else {
         return false;
     }
 }
Example #3
0
 function acceptData($value)
 {
     foreach ($value as $key => $val) {
         $data[$val] = $this->SV->input->post($val, TRUE);
         if (!is_array($data[$val])) {
             $data[$val] = strip_image_tags($data[$val]);
             $data[$val] = quotes_to_entities($data[$val]);
             $data[$val] = encode_php_tags($data[$val]);
             $data[$val] = trim($data[$val]);
         }
     }
     return $data;
 }
 function create($id)
 {
     $this->load->model('EventReview_model');
     $userName = $this->input->post('userName');
     $event_id = $this->input->post('event_id');
     $rating = $this->input->post('rating');
     $reviewContent = $this->input->post('reviewContent');
     $reviewContent = nl2br($reviewContent);
     $reviewContent = quotes_to_entities($reviewContent);
     if ($userName && $event_id && $rating && $reviewContent) {
         $this->EventReview_model->create_event_review($userName, $event_id, $rating, $reviewContent);
     }
     $data['result'] = $this->EventReview_model->get_all_event_reviews();
     redirect('event/view_event_reviewed/' . $id);
 }
Example #5
0
 function edit_bar()
 {
     if ($this->session->userdata('admin') != TRUE) {
         redirect('dashboard/index');
     }
     $this->load->model('Bar_model');
     $name = $this->input->post('name');
     $description = $this->input->post('description');
     $description = nl2br($description);
     $description = quotes_to_entities($description);
     $address = $this->input->post('address');
     $weburl = $this->input->post('weburl');
     if ($name) {
         $this->Bar_model->edit_bar($name, $description, $address, $weburl);
     }
     $data['result'] = $this->Bar_model->get_all_bars();
     $this->load->view('header');
     $this->load->view('Bar/Bar_view', $data);
     $this->load->view('footer');
 }
 function create($name)
 {
     $this->load->model('BarReview_model');
     $userName = $this->input->post('userName');
     $barName = $this->input->post('barName');
     $approvedByAdmin = $this->input->post('approvedByAdmin');
     $rating = $this->input->post('rating');
     $reviewContent = $this->input->post('reviewContent');
     $reviewContent = nl2br($reviewContent);
     $reviewContent = quotes_to_entities($reviewContent);
     $ts = $this->input->post('ts');
     if ($userName && $barName && $approvedByAdmin && $rating && $reviewContent && $ts) {
         $this->BarReview_model->create_barreview($userName, $barName, $approvedByAdmin, $rating, $reviewContent, $ts);
     } else {
         if ($userName && $barName && $rating && $reviewContent) {
             $this->BarReview_model->create_barreview_simple($userName, $barName, $rating, $reviewContent);
         }
     }
     $data['result'] = $this->BarReview_model->get_all_barreviews();
     redirect('bar/viewBarReviewed/' . $name);
 }
 function create($name)
 {
     $this->load->model('drink_review_model');
     $user_name = $this->input->post('user_name');
     $drink_name = $this->input->post('drink_name');
     $approved_by_admin = $this->input->post('approved_by_admin');
     $rating = $this->input->post('rating');
     $review_content = $this->input->post('review_content');
     $review_content = nl2br($review_content);
     $review_content = quotes_to_entities($review_content);
     $ts = $this->input->post('ts');
     if ($user_name && $drink_name && $approved_by_admin && $rating && $review_content && $ts) {
         $this->drink_review_model->create_drink_review($user_name, $drink_name, $approved_by_admin, $rating, $review_content, $ts);
     } else {
         if ($user_name && $drink_name && $rating && $review_content) {
             $this->drink_review_model->create_drink_review_simple($user_name, $drink_name, $rating, $review_content);
         }
     }
     $data['result'] = $this->drink_review_model->get_all_drink_reviews();
     redirect('Drink/view_drink_reviewed/' . $name);
 }
Example #8
0
 /**
  * Save (Create/Edit) a Member Field
  * @param  array  $data Associative array of data matching columns in
  *                      exp_member_fields
  * @return array        Modified $data associative array, containing
  *                      defaults and sanitized values
  */
 public function save_field($data = array())
 {
     if (!is_array($data)) {
         throw new Exception('Data passed to Member_field_model::save() must be an array');
     }
     // Sanitize fields allowed
     $fields = ee()->db->list_fields('member_fields');
     $data = array_intersect_key($data, array_flip($fields));
     // Clean up field list items
     if (isset($data['m_field_list_items']) && $data['m_field_list_items'] != '') {
         $data['m_field_list_items'] = quotes_to_entities($data['m_field_list_items']);
     }
     // Determine field order
     if (empty($data['m_field_order']) or !is_numeric($data['m_field_order'])) {
         ee()->load->model('member_model');
         $count = ee()->member_model->count_records('member_fields');
         $data['m_field_order'] = $count + 1;
     }
     // Set a default max length
     $data['m_field_maxl'] = is_numeric($data['m_field_maxl']) ? $data['m_field_maxl'] : 100;
     // Ensure defaults are there
     $defaults = array('m_field_description' => '', 'm_field_list_items' => '');
     $data = array_merge($defaults, $data);
     // New Field
     ee()->load->dbforge();
     if (!isset($data['m_field_id'])) {
         ee()->db->insert($this->table_fields, $data);
         ee()->dbforge->add_column($this->table_data, $this->_field_settings(ee()->db->insert_id(), $data['m_field_type'], $data['m_field_maxl']));
     } else {
         // Alter column if field type changed
         $previous_data = $this->get_field_information($data['m_field_id']);
         if ($previous_data['m_field_type'] !== $data['m_field_type']) {
             ee()->dbforge->modify_column($this->table_data, $this->_field_settings($data['m_field_id'], $data['m_field_type'], $data['m_field_maxl'], FALSE));
         }
         ee()->db->update($this->table_fields, $data, array('m_field_id' => $data['m_field_id']));
     }
     return $data;
 }
Example #9
0
 function strip_slashes($input)
 {
     $this->load->helper('string');
     if (is_array($input)) {
         foreach ($input as $k => $v) {
             $input[$k] = quotes_to_entities($v);
         }
     } else {
         $input = quotes_to_entities($input);
     }
     return $input;
 }
Example #10
0
 public function set_TDK($array, $add = FALSE)
 {
     if (count($array) > 0) {
         if (isset($array['seo_title'])) {
             $this->add_title(quotes_to_entities($array['seo_title']), $add);
         }
         if (isset($array['seo_description'])) {
             $this->add_description(quotes_to_entities($array['seo_description']), $add);
         }
         if (isset($array['seo_keywords'])) {
             $this->add_keywords(quotes_to_entities($array['seo_keywords']), $add);
         }
     }
     return $this;
 }
Example #11
0
 /**
  * Редактирование
  * 	выделенных серверов
  * 	игровых серверов
  * 	игр
  * 	типов игр
  * 
  * @param string - тип
  * 			dedicated_servers - выделенные серверы
  * 			game_servers - игровые серверы
  * 			games - игры
  * 			type_games - типы игр
  * 
  * @param string - служит для передачи дополнительных параметров
  * @param string
  * 
  * 
  */
 public function edit($type = 'dedicated_servers', $id = false, $param_2 = false)
 {
     $local_tpl = array();
     $error_msg = false;
     switch ($type) {
         case 'dedicated_servers':
             /* --------------------------------------------	*/
             /* 				Выделенные серверы 				*/
             /* --------------------------------------------	*/
             $this->load->model('servers/dedicated_servers');
             if (!$this->dedicated_servers->get_ds_list(array('id' => $id), 1)) {
                 $this->_show_message(lang('adm_servers_server_not_found'), site_url('adm_servers/view/dedicated_servers'));
                 return false;
             }
             // Файл шаблона с формой
             $tpl_file_edit = 'adm_servers/dedicated_servers_control.html';
             $tpl_list = $this->dedicated_servers->tpl_data_ds();
             $local_tpl = $tpl_list[0];
             //if(in_array('ssh2', get_loaded_extensions()));
             $options = array('gdaemon' => 'GameAP Daemon', 'ssh' => 'SSH', 'telnet' => 'Telnet');
             if ($this->dedicated_servers->ds_list['0']['control_protocol'] == 'local') {
                 // Поле Local отображается лишь для локального сервера
                 // Однако можно вручную подменить значения в html коде,
                 // но в этом нет ничего страшного
                 $options['local'] = 'Local';
             }
             $local_tpl['control_protocol'] = form_dropdown('control_protocol', $options, $this->dedicated_servers->ds_list['0']['control_protocol']);
             // Скрипты
             $local_tpl['script_start'] = quotes_to_entities($this->dedicated_servers->ds_list['0']['script_start']);
             $local_tpl['script_stop'] = quotes_to_entities($this->dedicated_servers->ds_list['0']['script_stop']);
             $local_tpl['script_restart'] = quotes_to_entities($this->dedicated_servers->ds_list['0']['script_restart']);
             $local_tpl['script_status'] = quotes_to_entities($this->dedicated_servers->ds_list['0']['script_status']);
             $local_tpl['script_get_console'] = quotes_to_entities($this->dedicated_servers->ds_list['0']['script_get_console']);
             $local_tpl['script_send_command'] = quotes_to_entities($this->dedicated_servers->ds_list['0']['script_send_command']);
             $local_tpl['script_path'] = $this->dedicated_servers->ds_list['0']['script_path'];
             $local_tpl['steamcmd_path'] = $this->dedicated_servers->ds_list['0']['steamcmd_path'];
             $local_tpl['gdaemon_host'] = $this->dedicated_servers->ds_list['0']['gdaemon_host'];
             $local_tpl['gdaemon_key'] = $this->dedicated_servers->ds_list['0']['gdaemon_key'];
             $local_tpl['ssh_host'] = $this->dedicated_servers->ds_list['0']['ssh_host'];
             $local_tpl['ssh_login'] = $this->dedicated_servers->ds_list['0']['ssh_login'];
             $local_tpl['ssh_path'] = $this->dedicated_servers->ds_list['0']['ssh_path'];
             $local_tpl['telnet_host'] = $this->dedicated_servers->ds_list['0']['telnet_host'];
             $local_tpl['telnet_login'] = $this->dedicated_servers->ds_list['0']['telnet_login'];
             $local_tpl['telnet_path'] = $this->dedicated_servers->ds_list['0']['telnet_path'];
             $local_tpl['ftp_host'] = $this->dedicated_servers->ds_list['0']['ftp_host'];
             $local_tpl['ftp_login'] = $this->dedicated_servers->ds_list['0']['ftp_login'];
             $local_tpl['ftp_path'] = $this->dedicated_servers->ds_list['0']['ftp_path'];
             $local_tpl['disabled_checkbox'] = form_checkbox('disabled', 'accept', $this->dedicated_servers->ds_list['0']['disabled']);
             // Получаем список серверов на DS
             $gs = $this->servers->get_game_servers_list(array('ds_id' => $id));
             $local_tpl['servers_list'] = $this->servers->tpl_data();
             /* 
              * Правила для формы
              * 
              * Документация:
              * http://cidocs.ru/213/libraries/form_validation.html
              * 
              */
             $this->form_validation->set_rules('name', lang('title'), 'trim|required|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('os', lang('operationg_system'), 'trim|required|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('location', lang('adm_servers_location'), 'trim|required|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('provider', 'adm_servers_provider', 'trim|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('ip', 'IP', 'trim|required|xss_clean');
             $this->form_validation->set_rules('ram', 'RAM', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('cpu', 'CPU', 'trim|max_length[64]|xss_clean');
             // Скрипты
             $this->form_validation->set_rules('script_start', lang('adm_servers_command_start'), 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('script_stop', lang('adm_servers_command_stop'), 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('script_restart', lang('adm_servers_command_restart'), 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('script_status', lang('adm_servers_command_status'), 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('script_get_console', lang('adm_servers_command_get_console'), 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('script_send_command', lang('adm_servers_send_command'), 'trim|max_length[256]|xss_clean');
             // Редактирование данных доступа к серверу (пароли ftp, ssh)
             $this->form_validation->set_rules('steamcmd_path', lang('adm_servers_steamcmd_path'), 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('script_path', lang('adm_servers_script_path'), 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('gdaemon_host', lang('adm_servers_gdaemon_host'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('gdaemon_key', lang('adm_servers_gdaemon_key'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('ssh_host', lang('adm_servers_ftp_host'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('ssh_login', 'SSH login', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('ssh_password', 'SSH password', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('ssh_path', 'Path SSH', 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('telnet_host', lang('adm_servers_telnet_host'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('telnet_login', 'Telnet login', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('telnet_password', 'Telnet password', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('telnet_path', 'Path Telnet', 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('ftp_host', lang('adm_servers_ftp_host'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('ftp_login', 'FTP login', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('ftp_password', 'FTP password', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('ftp_path', 'Path FTP', 'trim|max_length[256]|xss_clean');
             $this->form_validation->set_rules('control_protocol', lang('adm_servers_control_protocol'), 'trim|min_length[3]|max_length[16]|xss_clean');
             break;
         case 'game_servers':
             /* --------------------------------------------	*/
             /* 				Игровые серверы					*/
             /* --------------------------------------------	*/
             $this->load->model('servers/dedicated_servers');
             $this->load->model('servers/games');
             $this->load->model('servers/game_types');
             $this->load->helper('form');
             //if(!$game_servers_list = $this->servers->get_game_servers_list(array('id' => $id), 1)){
             //	$this->_show_message('Сервера с таким ID не существует', '/adm_servers/view/game_servers');
             //	return false;
             //}
             if (!$this->servers->get_server_data($id)) {
                 $this->_show_message(lang('adm_servers_server_not_found'), site_url('adm_servers/view/game_servers'));
                 return false;
             }
             // Файл шаблона с формой
             $tpl_file_edit = 'adm_servers/game_servers_control.html';
             $servers_list = $this->servers->tpl_data();
             $local_tpl = $servers_list[0];
             $local_tpl['information'] = array();
             // Для tpl
             $local_tpl['screen_name'] = $this->servers->server_data['screen_name'];
             $local_tpl['su_user'] = $this->servers->server_data['su_user'];
             $local_tpl['server_dir'] = $this->servers->server_data['dir'];
             $local_tpl['game_type_id'] = $this->servers->server_data['game_type'];
             $local_tpl['server_start_code'] = $this->servers->server_data['start_code'];
             $local_tpl['start_command'] = $this->servers->server_data['start_command'];
             // Замена фигурных скобок, чтобы в параметрах запуска шоткоды команды не считались за шоткоды шаблона
             $local_tpl['start_command'] = str_replace('{', '&#123;', $local_tpl['start_command']);
             $local_tpl['start_command'] = str_replace('}', '&#125;', $local_tpl['start_command']);
             $local_tpl['query_port'] = $this->servers->server_data['query_port'];
             $local_tpl['rcon_port'] = $this->servers->server_data['rcon_port'];
             $local_tpl['cpu_limit'] = $this->servers->server_data['cpu_limit'];
             $local_tpl['ram_limit'] = $this->servers->server_data['ram_limit'];
             $local_tpl['net_limit'] = $this->servers->server_data['net_limit'];
             /* Получаем абсолютный путь к корневой директории с сервером и к исполняемым файлам */
             $local_tpl['full_server_path'] = $this->servers->server_data['script_path'] . '/' . $this->servers->server_data['dir'];
             $local_tpl['script_path'] = $this->servers->server_data['script_path'];
             // Модификация
             $where = array('game_code' => $this->servers->server_data['game']);
             $gametypes_list = $this->game_types->get_gametypes_list($where);
             $options = array();
             $i = 0;
             foreach ($gametypes_list as $list) {
                 $options[$list['id']] = $list['name'];
                 /* Узнаем ключ в массиве модификации которой принадлежит этот сервер */
                 if ($list['id'] == $this->servers->server_data['game_type']) {
                     $gt_key = $i;
                 }
                 $i++;
             }
             $local_tpl['game_type_dropdown'] = array();
             $local_tpl['aliases_list'] = array();
             $server_aliases = $this->servers->server_data['aliases'];
             $local_tpl['game_type_dropdown'] = form_dropdown('game_type', $options, $this->servers->server_data['game_type']);
             $local_tpl['server_enabled_checkbox'] = form_checkbox('enabled', 'accept', $this->servers->server_data['enabled']);
             // Заменяем двойные кавычки на html символы
             $local_tpl['start_command'] = str_replace('"', '&quot;', $local_tpl['start_command']);
             /* Информация о DS */
             if ($this->servers->server_data['ds_id']) {
                 $local_tpl['ds_name'] = $this->dedicated_servers->ds_list[0]['name'];
                 $local_tpl['ds_id'] = $this->dedicated_servers->ds_list[0]['id'];
                 $local_tpl['ds_location'] = $this->dedicated_servers->ds_list[0]['location'];
                 $local_tpl['ds_provider'] = $this->dedicated_servers->ds_list[0]['provider'];
             } else {
                 // Сервер локальный
                 $local_tpl['ds_name'] = lang('adm_servers_local_server');
                 $local_tpl['ds_id'] = 0;
             }
             /* Получение последних действий с сервером
              *  
              * количество получаемых логов = 50
              * количество отображаемых логов = 10
              * 
              * Некоторые из получаемых логов могут не относиться к серверам, из-за этого
              * таблица может быть пустой
              * 
              */
             $where = array('server_id' => $id);
             $server_plogs = $this->panel_log->get_log($where, 100);
             // Логи сервера в админпанели
             $local_tpl['log_list'] = array();
             $log_num = 0;
             $i = 0;
             $count_i = count($server_plogs);
             while ($i < $count_i) {
                 if ($log_num == 15) {
                     break;
                 }
                 $local_tpl['log_list'][$i]['log_id'] = $server_plogs[$i]['id'];
                 $local_tpl['log_list'][$i]['log_date'] = unix_to_human($server_plogs[$i]['date'], true, 'eu');
                 $local_tpl['log_list'][$i]['log_server_id'] = $server_plogs[$i]['server_id'];
                 $local_tpl['log_list'][$i]['log_user_name'] = $server_plogs[$i]['user_name'];
                 $local_tpl['log_list'][$i]['log_command'] = $server_plogs[$i]['command'];
                 /* Код действия на понятный язык */
                 switch ($server_plogs[$i]['type']) {
                     case 'server_rcon':
                         $local_tpl['log_list'][$i]['log_type'] = lang('server_control_rcon_send');
                         $log_num++;
                         break;
                     case 'server_command':
                         $local_tpl['log_list'][$i]['log_type'] = lang('server_control_command');
                         $log_num++;
                         break;
                     case 'server_update':
                         $local_tpl['log_list'][$i]['log_type'] = lang('server_control_update');
                         $log_num++;
                         break;
                     case 'server_task':
                         $local_tpl['log_list'][$i]['log_type'] = lang('server_control_srv_task');
                         $log_num++;
                         break;
                     case 'server_settings':
                         $local_tpl['log_list'][$i]['log_type'] = lang('server_control_settings');
                         $log_num++;
                         break;
                     case 'server_files':
                         $local_tpl['log_list'][$i]['log_type'] = lang('server_control_file_operation');
                         $log_num++;
                         break;
                     default:
                         // Тип лога неизвестен, удаляем его из списка (не из базы)
                         unset($local_tpl['log_list'][$i]);
                         break;
                 }
                 $i++;
             }
             /* ------------------------------ */
             /* Различная информация о сервере */
             /* ------------------------------ */
             if ($this->servers->server_data['installed'] == '0') {
                 $local_tpl['information'][]['text'] = lang('adm_servers_serv_not_installed') . '<br />';
             } elseif ($this->servers->server_data['installed'] == '1') {
                 $local_tpl['information'][]['text'] = lang('adm_servers_serv_installed') . '<br />';
             } elseif ($this->servers->server_data['installed'] == '2') {
                 $local_tpl['information'][]['text'] = lang('adm_servers_serv_installed_proccess') . '<br />';
             }
             /* 
              * --------------------------------------------
              * Проверка, имеются ли параметры в настройках 
              * --------------------------------------------
              */
             /* Допустимые алиасы */
             $allowable_aliases = isset($this->servers->server_data['aliases_list']) ? json_decode($this->servers->server_data['aliases_list'], true) : false;
             /* Значения алиасов на сервере */
             $server_aliases = $this->servers->server_data['aliases'];
             /* Прогон по алиасам */
             $empty_alias = '';
             if ($allowable_aliases && !empty($allowable_aliases)) {
                 /* Если параметр пуст, то выводим сообщение с предупреждением */
                 $i = 0;
                 foreach ($allowable_aliases as $alias) {
                     $local_tpl['aliases_list'][$i]['alias'] = $alias['alias'];
                     $local_tpl['aliases_list'][$i]['desc'] = $alias['desc'];
                     if (!isset($server_aliases[$alias['alias']]) or empty($server_aliases[$alias['alias']])) {
                         $empty_alias .= '"' . $alias['desc'] . '", ';
                         $local_tpl['aliases_list'][$i]['alias_value'] = '<' . lang('value_not_set') . '>';
                     } else {
                         $local_tpl['aliases_list'][$i]['alias_value'] = $server_aliases[$alias['alias']];
                     }
                     $i++;
                 }
             }
             if ($empty_alias != '') {
                 $local_tpl['information'][]['text'] = lang('adm_servers_gs_empty_settings') . ': ' . $empty_alias;
             }
             /* 
              * --------------------------------------------
              * Правила для формы
              * --------------------------------------------
              */
             $this->form_validation->set_rules('name', lang('name'), 'trim|required|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('server_ip', lang('ip'), 'trim|max_length[64]|min_length[4]|xss_clean');
             $this->form_validation->set_rules('server_port', lang('port'), 'trim|required|integer|max_length[6]|min_length[2]|xss_clean');
             $this->form_validation->set_rules('query_port', lang('adm_servers_query_port'), 'trim|integer|max_length[6]|min_length[2]|xss_clean');
             $this->form_validation->set_rules('rcon_port', lang('adm_servers_rcon_port'), 'trim|integer|max_length[6]|min_length[2]|xss_clean');
             $this->form_validation->set_rules('rcon', 'RCON password', 'trim|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('game_type', lang('adm_servers_game_type'), 'trim|required|integer|xss_clean');
             $this->form_validation->set_rules('dir', lang('adm_servers_server_dir'), 'trim|required|max_length[64]|xss_clean');
             $this->form_validation->set_rules('screen_name', lang('adm_servers_screen_name'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('su_user', lang('adm_servers_user_start'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('start_command', lang('adm_servers_command_start'), 'trim|max_length[512]|xss_clean');
             $this->form_validation->set_rules('cpu_limit', lang('adm_servers_cpu_limit'), 'trim|integer|less_than[100]|xss_clean');
             $this->form_validation->set_rules('ram_limit', lang('adm_servers_ram_limit'), 'trim|integer|xss_clean');
             $this->form_validation->set_rules('net_limit', lang('adm_servers_net_limit'), 'trim|integer|xss_clean');
             break;
         case 'games':
             /* --------------------------------------------	*/
             /* 				Игры							*/
             /* --------------------------------------------	*/
             $this->load->model('servers/games');
             $this->load->model('servers/game_types');
             if (!$this->games->get_games_list(array('code' => $id), 1)) {
                 $this->_show_message(lang('adm_servers_game_not_found'), site_url('adm_servers/view/games'));
                 return false;
             }
             // Файл шаблона с формой
             $tpl_file_edit = 'adm_servers/games_control.html';
             $tpl_list = $this->games->tpl_data_games();
             $local_tpl = $tpl_list[0];
             // Список модификаций
             $local_tpl['gt_list'] = $this->game_types->tpl_data_game_types(array('game_code' => $id));
             /* Правила для проверки формы */
             $this->form_validation->set_rules('name', lang('name'), 'trim|required|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('code', lang('adm_servers_game_code'), 'trim|required|max_length[32]|min_length[2]|xss_clean');
             $this->form_validation->set_rules('start_code', lang('adm_servers_game_start_code'), 'trim|required|max_length[64]|min_length[2]|xss_clean');
             $this->form_validation->set_rules('engine', lang('adm_servers_engine'), 'trim|required|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('engine_version', lang('adm_servers_engine_version'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('app_id', 'app_id', 'trim|integer|max_length[32]|xss_clean');
             $this->form_validation->set_rules('app_set_config', 'app_set_config', 'trim|max_length[32]|xss_clean');
             $this->form_validation->set_rules('local_repository', lang('adm_servers_local_repository'), 'trim|xss_clean');
             $this->form_validation->set_rules('remote_repository', lang('adm_servers_remote_repository'), 'trim|xss_clean');
             break;
         case 'game_types':
             /* --------------------------------------------	*/
             /* 				Игровые модификации				*/
             /* --------------------------------------------	*/
             $this->load->model('servers/game_types');
             $this->load->model('servers/games');
             if (!($gt_list = $this->game_types->get_gametypes_list(array('id' => $id)))) {
                 $this->_show_message(lang('adm_servers_game_type_not_found'), site_url('adm_servers/view/game_types'));
                 return false;
             }
             // Файл шаблона с формой
             $tpl_file_edit = 'adm_servers/game_types_control.html';
             $tpl_list = $this->game_types->tpl_data_game_types();
             $local_tpl = $tpl_list[0];
             $local_tpl['game_code'] = $gt_list[0]['game_code'];
             /* Делаем список с играми */
             $games_list = $this->games->get_games_list();
             foreach ($games_list as $list) {
                 $options[$list['code']] = $list['name'];
             }
             $local_tpl['gt_code'] = form_dropdown('game_code', $options, $gt_list[0]['game_code']);
             $local_tpl['frcon_list'] = array();
             $local_tpl['aliases_list'] = array();
             $local_tpl['frcon_count'] = 0;
             $local_tpl['aliases_count'] = 0;
             if ($json_decode = json_decode($gt_list[0]['fast_rcon'], true)) {
                 $i = 0;
                 foreach ($json_decode as $array) {
                     $local_tpl['frcon_list'][$i]['id'] = $i;
                     $local_tpl['frcon_list'][$i]['desc'] = form_input('frcon_desc[]', $array['desc']);
                     $local_tpl['frcon_list'][$i]['rcon_command'] = form_input('frcon_command[]', $array['rcon_command']);
                     $i++;
                 }
                 $local_tpl['frcon_count'] = $i;
             }
             if ($json_decode = json_decode($gt_list[0]['aliases'], true)) {
                 $i = 0;
                 foreach ($json_decode as $array) {
                     isset($array['default_value']) or $array['default_value'] = '';
                     $local_tpl['aliases_list'][$i]['id'] = $i;
                     $local_tpl['aliases_list'][$i]['alias'] = form_input('alias_name[]', $array['alias']);
                     $local_tpl['aliases_list'][$i]['desc'] = form_input('alias_desc[]', $array['desc']);
                     $local_tpl['aliases_list'][$i]['default_value'] = form_input('default_value[]', $array['default_value']);
                     $local_tpl['aliases_list'][$i]['only_admins'] = form_checkbox('alias_only_admins[' . $i . ']', 'accept', $array['only_admins']);
                     $i++;
                 }
                 $local_tpl['aliases_count'] = $i;
             }
             /*
              * Данные для проверки формы 
              */
             $this->form_validation->set_rules('name', lang('name'), 'trim|required|max_length[64]|min_length[3]|xss_clean');
             $this->form_validation->set_rules('game_code', lang('adm_servers_game_code'), 'trim|required|max_length[32]|min_length[2]|xss_clean');
             /* Сведения о fast rcon командах */
             $this->form_validation->set_rules('frcon_desc[]', 'описание fast rcon команды', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('frcon_command[]', 'fast rcon команда', 'trim|max_length[64]|xss_clean');
             /* Сведения об алиасах */
             $this->form_validation->set_rules('alias_name[]', 'имя алиаса', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('alias_desc[]', 'описание алиаса', 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('alias_only_admins[]', 'только для администраторов', 'trim|xss_clean');
             /* Сведения для управления игроками */
             $this->form_validation->set_rules('kick_cmd', lang('adm_servers_kick_cmd'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('ban_cmd', lang('adm_servers_ban_cmd'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('chname_cmd', lang('adm_servers_chname_cmd'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('srestart_cmd', lang('adm_servers_srestart_cmd'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('chmap_cmd', lang('adm_servers_chmap_cmd'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('sendmsg_cmd', lang('adm_servers_sendmsg_cmd'), 'trim|max_length[64]|xss_clean');
             $this->form_validation->set_rules('passwd_cmd', lang('adm_servers_passwd_cmd'), 'trim|max_length[64]|xss_clean');
             /* Репозитории */
             $this->form_validation->set_rules('local_repository', lang('adm_servers_local_repository'), 'trim|xss_clean');
             $this->form_validation->set_rules('remote_repository', lang('adm_servers_remote_repository'), 'trim|xss_clean');
             break;
         default:
             redirect('');
             break;
     }
     /* 
      * Проверка заполненной формы, если все в порядке,
      * то добавляем данные в базу.
      * Если не в порядке, то отображаем форму
      */
     if ($this->form_validation->run() == false) {
         if (validation_errors()) {
             $this->_show_message(validation_errors());
             return false;
         }
         $this->tpl_data['content'] .= $this->parser->parse($tpl_file_edit, $local_tpl, true);
     } else {
         // Форма проверена, все впорядке
         switch ($type) {
             case 'dedicated_servers':
                 /* --------------------------------------------	*/
                 /* 				Выделенные серверы 				*/
                 /* --------------------------------------------	*/
                 // Форма проверена, все хорошо, добавляем сервер
                 $sql_data['name'] = $this->input->post('name');
                 $sql_data['os'] = $this->input->post('os');
                 $sql_data['location'] = $this->input->post('location');
                 $sql_data['provider'] = $this->input->post('provider');
                 $sql_data['ram'] = (int) $this->input->post('ram');
                 $sql_data['cpu'] = (int) $this->input->post('cpu');
                 $sql_data['disabled'] = (int) (bool) $this->input->post('disabled');
                 /* Обработка списка IP адресов */
                 $ip_list = explode(',', str_replace(' ', '', $this->input->post('ip')));
                 $sql_data['ip'] = json_encode($ip_list);
                 // Скрипты
                 $sql_data['script_start'] = $this->input->post('script_start');
                 $sql_data['script_stop'] = $this->input->post('script_stop');
                 $sql_data['script_restart'] = $this->input->post('script_restart');
                 $sql_data['script_status'] = $this->input->post('script_status');
                 $sql_data['script_get_console'] = $this->input->post('script_get_console');
                 $sql_data['script_send_command'] = $this->input->post('script_send_command');
                 // Редактирование данных доступа к серверу (пароли ftp, ssh)
                 $sql_data['steamcmd_path'] = $this->input->post('steamcmd_path');
                 //~ $sql_data['script_path'] 		= $this->input->post('script_path');
                 $sql_data['control_protocol'] = $this->input->post('control_protocol');
                 $sql_data['gdaemon_host'] = $this->input->post('gdaemon_host');
                 $sql_data['gdaemon_key'] = $this->input->post('gdaemon_key');
                 $sql_data['ssh_host'] = $this->input->post('ssh_host');
                 $sql_data['ssh_login'] = $this->input->post('ssh_login');
                 $sql_data['ssh_password'] = $this->input->post('ssh_password');
                 $sql_data['ssh_path'] = $this->input->post('script_path');
                 $sql_data['telnet_host'] = $this->input->post('telnet_host');
                 $sql_data['telnet_login'] = $this->input->post('telnet_login');
                 $sql_data['telnet_password'] = $this->input->post('telnet_password');
                 $sql_data['telnet_path'] = $this->input->post('script_path');
                 $sql_data['ftp_host'] = $this->input->post('ftp_host');
                 $sql_data['ftp_login'] = $this->input->post('ftp_login');
                 $sql_data['ftp_password'] = $this->input->post('ftp_password');
                 $sql_data['ftp_path'] = $this->input->post('ftp_path');
                 /* 
                  * Проверка указандых данных ssh, telnet, ftp
                  * чтобы пароль подходил
                  */
                 // GDaemon
                 if (!empty($sql_data['gdaemon_host'])) {
                     /* Ключ не задан, берем из базы */
                     if (empty($sql_data['gdaemon_key'])) {
                         $gdaemon_key = $this->dedicated_servers->ds_list['0']['gdaemon_key'];
                     } else {
                         $gdaemon_key = $sql_data['gdaemon_key'];
                     }
                     if (false == $this->_check_gdaemon($sql_data['gdaemon_host'], $gdaemon_key)) {
                         $this->_show_message(lang('adm_servers_gdaemon_data_unavailable'), 'javascript:history.back()');
                         return false;
                     }
                 }
                 // SSH
                 if (!empty($sql_data['ssh_host'])) {
                     /* Пароль не задан, берем из базы */
                     if (empty($sql_data['ssh_password'])) {
                         $ssh_password = $this->dedicated_servers->ds_list['0']['ssh_password'];
                     } else {
                         $ssh_password = $sql_data['ssh_password'];
                     }
                     if (false == $this->_check_ssh($sql_data['ssh_host'], $sql_data['ssh_login'], $ssh_password)) {
                         $this->_show_message(lang('adm_servers_ssh_data_unavailable'), 'javascript:history.back()');
                         return false;
                     }
                     $ssh_host = explode(':', $sql_data['ssh_host']);
                     $ssh_host[1] = isset($ssh_host[1]) ? (int) $ssh_host[1] : 22;
                     $sftp_config['hostname'] = $ssh_host[0];
                     $sftp_config['port'] = $ssh_host[1];
                     $sftp_config['username'] = $sql_data['ssh_login'];
                     $sftp_config['password'] = $ssh_password;
                     $sftp_config['debug'] = false;
                     if (!($sql_data['ssh_path'] = $this->_found_sftp_path($sql_data['ssh_path'], $sftp_config))) {
                         $this->_show_message(lang('adm_servers_sftp_path_not_found'), 'javascript:history.back()');
                         return false;
                     }
                 }
                 // FTP
                 if (!empty($sql_data['ftp_host'])) {
                     /* Пароль не задан, берем из базы */
                     if (empty($sql_data['ftp_password'])) {
                         $ftp_password = $this->dedicated_servers->ds_list['0']['ftp_password'];
                     } else {
                         $ftp_password = $sql_data['ftp_password'];
                     }
                     if (false == $this->_check_ftp($sql_data['ftp_host'], $sql_data['ftp_login'], $ftp_password)) {
                         $this->_show_message(lang('adm_servers_ftp_data_unavailable'), 'javascript:history.back()');
                         return false;
                     }
                     if (!($sql_data['ftp_path'] = $this->_found_ftp_path($sql_data['ftp_path']))) {
                         $this->_show_message(lang('adm_servers_ftp_path_not_found'), 'javascript:history.back()');
                         return false;
                     }
                 }
                 // TELNET
                 if (!empty($sql_data['telnet_host'])) {
                     /* Пароль не задан, берем из базы */
                     if (empty($sql_data['telnet_password'])) {
                         $telnet_password = $this->dedicated_servers->ds_list['0']['telnet_password'];
                     } else {
                         $telnet_password = $sql_data['telnet_password'];
                     }
                     if (false == $this->_check_telnet($sql_data['telnet_host'], $sql_data['telnet_login'], $telnet_password, strtolower($sql_data['os']))) {
                         $this->_show_message(lang('adm_servers_telnet_data_unavailable'), 'javascript:history.back()');
                         return false;
                     }
                 }
                 if ($this->dedicated_servers->edit_dedicated_server($id, $sql_data)) {
                     $local_tpl['message'] = lang('adm_servers_server_data_changed');
                 } else {
                     $local_tpl['message'] = lang('adm_servers_error_server_edit');
                 }
                 // Записываем логи
                 $log_data['type'] = 'adm_servers';
                 $log_data['command'] = 'edit_ds';
                 $log_data['server_id'] = 0;
                 $log_data['user_name'] = $this->users->auth_login;
                 $log_data['msg'] = $local_tpl['message'];
                 $log_data['log_data'] = 'ID: ' . $id;
                 $this->panel_log->save_log($log_data);
                 $local_tpl['link'] = site_url('adm_servers/view/dedicated_servers');
                 $local_tpl['back_link_txt'] = lang('adm_servers_back_to_servers');
                 break;
             case 'game_servers':
                 /* --------------------------------------------	*/
                 /* 				Игровые серверы					*/
                 /* --------------------------------------------	*/
                 $sql_data['name'] = $this->input->post('name');
                 $sql_data['server_ip'] = $this->input->post('server_ip');
                 $sql_data['server_port'] = $this->input->post('server_port');
                 $sql_data['query_port'] = $this->input->post('query_port');
                 $sql_data['rcon_port'] = $this->input->post('rcon_port');
                 //$sql_data['game'] = $this->input->post('code');
                 $sql_data['dir'] = $this->input->post('dir');
                 $sql_data['game_type'] = $this->input->post('game_type');
                 $sql_data['enabled'] = (int) (bool) $this->input->post('enabled');
                 //$sql_data['ds_id'] = $this->input->post('ds_id');
                 $sql_data['screen_name'] = $this->input->post('screen_name');
                 $sql_data['su_user'] = $this->input->post('su_user');
                 $sql_data['start_command'] = $this->input->post('start_command');
                 $sql_data['cpu_limit'] = $this->input->post('cpu_limit');
                 $sql_data['ram_limit'] = $this->input->post('ram_limit');
                 $sql_data['net_limit'] = $this->input->post('net_limit');
                 /* Чтобы ид модификации был правильный и подходил для выбранной игры */
                 $where = array('id' => $sql_data['game_type'], 'game_code' => $this->servers->server_data['game']);
                 if (!$this->game_types->get_gametypes_list($where, 1)) {
                     $this->_show_message(lang('adm_servers_game_type_select_wrong'));
                     return false;
                 }
                 /* RCON */
                 if ($this->input->post('rcon') != '') {
                     /* Собственно смена rcon пароля */
                     $this->servers->change_rcon($this->input->post('rcon'), null, false);
                     $sql_data['rcon'] = $this->input->post('rcon');
                 }
                 if ($this->servers->edit_game_server($id, $sql_data)) {
                     $local_tpl['message'] = lang('adm_servers_server_data_changed');
                 } else {
                     $local_tpl['message'] = lang('adm_servers_error_server_edit');
                 }
                 // Записываем логи
                 $log_data['type'] = 'adm_servers';
                 $log_data['command'] = 'edit_game_server';
                 $log_data['server_id'] = $id;
                 $log_data['user_name'] = $this->users->auth_login;
                 $log_data['msg'] = $local_tpl['message'];
                 $log_data['log_data'] = 'ID: ' . $id;
                 $this->panel_log->save_log($log_data);
                 $local_tpl['link'] = site_url('adm_servers/view/game_servers');
                 $local_tpl['back_link_txt'] = lang('adm_servers_back_to_servers');
                 break;
             case 'games':
                 /* --------------------------------------------	*/
                 /* 				Игры			 				*/
                 /* --------------------------------------------	*/
                 $sql_data['name'] = $this->input->post('name');
                 $sql_data['code'] = $this->input->post('code');
                 $sql_data['start_code'] = $this->input->post('start_code');
                 $sql_data['engine'] = $this->input->post('engine');
                 $sql_data['engine_version'] = $this->input->post('engine_version');
                 $sql_data['app_id'] = $this->input->post('app_id');
                 $sql_data['app_set_config'] = $this->input->post('app_set_config');
                 $sql_data['local_repository'] = $this->input->post('local_repository');
                 $sql_data['remote_repository'] = $this->input->post('remote_repository');
                 // Проверка наличия файла в удалённом репозитории
                 if (!remote_file_exists($sql_data['remote_repository'])) {
                     $this->_show_message('adm_servers_rep_file_not_exists');
                     return false;
                 }
                 // Проверяем наличие Query класса
                 if (!file_exists(APPPATH . 'libraries/gameq/protocols/' . strtolower($sql_data['engine']) . '.php')) {
                     $this->_show_message('adm_servers_unknown_engine');
                     return false;
                 }
                 /* Убираем кавычки из app_set_config */
                 $sql_data['app_set_config'] = str_replace('\'', '', $sql_data['app_set_config']);
                 $sql_data['app_set_config'] = str_replace('"', '', $sql_data['app_set_config']);
                 $sql_data['app_set_config'] = str_replace('	', '', $sql_data['app_set_config']);
                 if ($this->games->edit_game($id, $sql_data)) {
                     $local_tpl['message'] = lang('adm_servers_game_data_changed');
                 } else {
                     $local_tpl['message'] = lang('adm_servers_error_game_edit');
                 }
                 // Записываем логи
                 $log_data['type'] = 'adm_servers';
                 $log_data['command'] = 'edit_game';
                 $log_data['server_id'] = 0;
                 $log_data['user_name'] = $this->users->auth_login;
                 $log_data['msg'] = $local_tpl['message'];
                 $log_data['log_data'] = 'ID: ' . $id;
                 $this->panel_log->save_log($log_data);
                 $local_tpl['link'] = site_url('adm_servers/view/games');
                 $local_tpl['back_link_txt'] = lang('adm_servers_back_to_games');
                 break;
             case 'game_types':
                 /* --------------------------------------------	*/
                 /* 				Игровые модификации				*/
                 /* --------------------------------------------	*/
                 $sql_data['name'] = $this->input->post('name');
                 $sql_data['game_code'] = $this->input->post('game_code');
                 $sql_data['kick_cmd'] = $this->input->post('kick_cmd');
                 $sql_data['ban_cmd'] = $this->input->post('ban_cmd');
                 $sql_data['chname_cmd'] = $this->input->post('chname_cmd');
                 $sql_data['srestart_cmd'] = $this->input->post('srestart_cmd');
                 $sql_data['chmap_cmd'] = $this->input->post('chmap_cmd');
                 $sql_data['sendmsg_cmd'] = $this->input->post('sendmsg_cmd');
                 $sql_data['passwd_cmd'] = $this->input->post('passwd_cmd');
                 $sql_data['local_repository'] = $this->input->post('local_repository');
                 $sql_data['remote_repository'] = $this->input->post('remote_repository');
                 // Проверка наличия файла в удалённом репозитории
                 if (!remote_file_exists($sql_data['remote_repository'])) {
                     $this->_show_message('adm_servers_rep_file_not_exists');
                     return false;
                 }
                 /*
                  * ----------------------------
                  * 	Перебор frcon комманд
                  * ----------------------------
                  */
                 $frcon_list['desc'] = $this->input->post('frcon_desc');
                 $frcon_list['command'] = $this->input->post('frcon_command');
                 $frcon_list['delete'] = $this->input->post('frcon_delete');
                 if (!empty($frcon_list['command'])) {
                     $i = -1;
                     foreach ($frcon_list['command'] as $command) {
                         $i++;
                         /* Пустые значения выкидываем */
                         if ($command == '') {
                             continue;
                         }
                         /* Пустые значения выкидываем */
                         if ($frcon_list['desc'][$i] == '') {
                             continue;
                         }
                         /* Значение должно быть удалено */
                         if (isset($frcon_list['delete'][$i])) {
                             continue;
                         }
                         $fast_rcon[$i]['desc'] = $frcon_list['desc'][$i];
                         $fast_rcon[$i]['rcon_command'] = $command;
                     }
                     if (isset($fast_rcon)) {
                         $sql_data['fast_rcon'] = json_encode(array_values($fast_rcon));
                     }
                 }
                 /*
                  * ----------------------------
                  * 	Перебор алиасов
                  * ----------------------------
                  */
                 $aliases_list['alias'] = $this->input->post('alias_name');
                 $aliases_list['desc'] = $this->input->post('alias_desc');
                 $aliases_list['default_value'] = $this->input->post('default_value');
                 $aliases_list['only_admins'] = $this->input->post('alias_only_admins');
                 $aliases_list['delete'] = $this->input->post('alias_delete');
                 /* Массив с системными алиасами. Их использовать нельзя */
                 $sys_aliases = array('id', 'script_path', 'command', 'game_dir', 'dir', 'name', 'ip', 'port', 'game', 'user');
                 if (!empty($aliases_list['alias'])) {
                     $i = -1;
                     foreach ($aliases_list['alias'] as $alias) {
                         $i++;
                         /* Пустые значения выкидываем */
                         if ($alias == '') {
                             continue;
                         }
                         /* Пустые значения выкидываем */
                         if ($aliases_list['desc'][$i] == '') {
                             continue;
                         }
                         /* Пустые значения выкидываем */
                         if (empty($aliases_list['only_admins'][$i])) {
                             $aliases_list['only_admins'][$i] = false;
                         }
                         /* Значение должно быть удалено */
                         if (isset($aliases_list['delete'][$i])) {
                             continue;
                         }
                         /* Алиас не должен быть системным */
                         if (in_array($alias, $sys_aliases)) {
                             continue;
                         }
                         $aliases[$i]['alias'] = $alias;
                         $aliases[$i]['desc'] = $aliases_list['desc'][$i];
                         $aliases[$i]['default_value'] = $aliases_list['default_value'][$i];
                         $aliases[$i]['only_admins'] = (bool) $aliases_list['only_admins'][$i];
                     }
                     if (isset($aliases)) {
                         $sql_data['aliases'] = json_encode(array_values($aliases));
                     }
                 }
                 if ($this->game_types->edit_game_type($id, $sql_data)) {
                     $local_tpl['message'] = lang('adm_servers_game_type_data_changed');
                 } else {
                     $local_tpl['message'] = lang('adm_servers_error_game_type_edit');
                 }
                 // Записываем логи
                 $log_data['type'] = 'adm_servers';
                 $log_data['command'] = 'edit_game_type';
                 $log_data['server_id'] = 0;
                 $log_data['user_name'] = $this->users->auth_login;
                 $log_data['msg'] = $local_tpl['message'];
                 $log_data['log_data'] = 'ID: ' . $id;
                 $this->panel_log->save_log($log_data);
                 $local_tpl['link'] = site_url('adm_servers/edit/game_types/' . $id);
                 $local_tpl['back_link_txt'] = lang('adm_servers_back_to_game_types');
                 break;
         }
         $this->tpl_data['content'] = $this->parser->parse('info.html', $local_tpl, true);
     }
     $this->parser->parse('main.html', $this->tpl_data);
 }
 public function _parse_single($key, $val, $string)
 {
     $newval = $val;
     $find = "/" . $this->l_delim . "" . $key . ".*" . $this->r_delim . "/U";
     preg_match($find, $string, $matches);
     if (!empty($matches)) {
         $temp = trim($matches[0], "{}");
         $res = explode(":", $temp);
         // var_dump($res);
         if (count($res) > 1) {
             switch ($res[1]) {
                 case "allcaps":
                     $newval = strtoupper($val);
                     break;
                 case "money":
                     $newval = number_format((int) $val, 2, ".", ",");
                     break;
                 case "caps":
                     $newval = ucwords(strtolower($val));
                     break;
                 case "nocaps":
                     $newval = strtolower($val);
                     break;
                 case "ucfirst":
                     $newval = ucfirst($val);
                     break;
                 case "bool1":
                     $newval = $val == 1 ? "True" : "False";
                     break;
                 case "bool2":
                     $newval = $val == 1 ? "Yes" : "No";
                     break;
                 case "bool3":
                     $newval = $val == 1 ? "Active" : "Inactive";
                     break;
                 case "climit":
                     $int = count($res) < 3 ? 128 : $res[2];
                     $newval = character_limiter($val, $int);
                     break;
                 case "htmlchars":
                     $newval = quotes_to_entities($val);
                     break;
                 case "wlimit":
                     $int = count($res) < 3 ? 25 : $res[2];
                     $newval = word_limiter($val, $int);
                     break;
                 case "wrap":
                     $int = count($res) < 3 ? 76 : $res[2];
                     $newval = word_wrap($val, $int);
                     break;
                 case "hilite":
                     $str = count($res) < 3 ? "" : $res[2];
                     $color = count($res) < 4 ? "#990000" : $res[3];
                     $newval = highlight_phrase($val, $str, "<span style=\"color:{$color}\">", "</span>");
                     break;
                 case "safe_mailto":
                     $alt_text = count($res) < 3 ? "" : $res[2];
                     $newval = safe_mailto($val, $alt_text);
                     break;
                 case "url_title":
                     $sep = count($res) < 3 ? "dash" : $res[2];
                     $newval = url_title($val, $sep);
                     break;
                 case "remove_img":
                     $newval = strip_image_tags($val);
                     break;
                 case "hash":
                     $hash = count($res) < 3 ? "md5" : $res[2];
                     $newval = dohash($val, $hash);
                     break;
                 case "stripslashes":
                     $newval = stripslashes($val);
                     break;
                 case "strip_tags":
                     $allowed = count($res) < 3 ? "" : $res[2];
                     $newval = strip_tags($val, $allowed);
                     break;
                     /** other output string format options here **/
             }
             return str_replace($matches[0], $newval, $string);
         }
     }
     return parent::_parse_single($key, $val, $string);
 }
Example #13
0
	
<?php 
echo jquery_tab_open(array('main' => 'Site', 'shifts' => 'Shift Times', 'assignments' => 'Staff', 'workingdays' => 'Working Days'));
echo jquery_tab_page_open('main');
?>
<table class='DataRow' cellpadding='0' cellspacing='0'>
<tr><th>Id:</th><td><?php 
echo $row->id;
?>
</td></tr>
<tr><th>Name:</th><td><?php 
echo form_input('name', quotes_to_entities($row->name), 'size="60"');
?>
</td></tr>
<tr><th>Code:</th><td><?php 
echo form_input('code', quotes_to_entities($row->code), 'size="60"');
?>
</td></tr>
<tr><th>Street Number:</th><td><?php 
echo form_input('street_number', $row->street_number, 'size="20"');
?>
</td></tr>
<tr><th>Street Name:</th><td><?php 
echo form_input('street_name', $row->street_name, 'size="60"');
?>
</td></tr>
<tr><th>Unit Number:</th><td><?php 
echo form_input('unit_number', $row->unit_number, 'size="20"');
?>
</td></tr>
<tr><th>City:</th><td><?php 
Example #14
0
?>
</td></tr>
<tr><th>Address:</th><td><?php 
echo form_textarea('address', $row->address, 'cols="60"');
?>
</td></tr>
<tr><th>Send Birthday Greetings:</th><td><?php 
echo form_checkbox('dob_alert', 'True', $row->dob_alert == 'True');
?>
</td></tr>
<tr><th>Call Preference:</th><td><?php 
echo form_dropdown('call_type', $call_type_list, $row->call_type);
?>
</td></tr>
<tr><th>Call before shift:</th><td><?php 
echo form_input('call_minutes', quotes_to_entities($row->call_minutes), 'size="10"');
?>
 Minutes</td></tr>
<tr><th>Published:</th><td><?php 
echo form_checkbox('is_published', 'True', $row->is_published == 'True');
?>
</td></tr>
<tr><th>Update Time:</th><td><?php 
echo format_datetime($row->update_time);
?>
</td></tr>
</th></tr>
</table>

<?php 
echo jquery_tab_page_close();
Example #15
0
if(isset($albums))
{
?>
<div class="albums_block">
<?php 
	if(isset($pages)) echo $this->load->view('pagination_pages', $pages, TRUE);	
		foreach($albums as $ms)
		{
		?>
		<div class="block">
			<div class="img_block">
				<?php
				if(isset($ms['timage']))
				{
				?>
					<a <?php if(isset($ms['detail_url'])) echo 'href="'.$ms['detail_url'].'"';?> class="img_href"><img src="<?=$ms['timage']?>" title="<?=quotes_to_entities($ms['image_title'])?>" alt="<?=quotes_to_entities($ms['image_alt'])?>"></a>
				<?php
				}
				?>
			</div>
			<div class="name"><span><?=$ms['name']?></span></div>
			<span class="description"><?=$ms['short_description']?></span>
			<?php if(isset($ms['detail_url'])) echo '<div class="detail_link"><a href="'.$ms['detail_url'].'" ><span>'.$this->lang->line('base_detail_link_text').'</span></a></div>';?>
			<div class="clear_both"></div>
		</div>
		<?
		}
	if(isset($pages)) echo $this->load->view('pagination_pages', $pages, TRUE);
?>
</div>
<?
Example #16
0
<?php 
foreach ($news as $ms) {
    ?>
		<div class="block">
        	<div class="last_news_img">
            	<?php 
    if (isset($ms['timage'])) {
        ?>
						<div align="center"><img src="<?php 
        echo $ms['timage'];
        ?>
" title="<?php 
        echo quotes_to_entities($ms['image_title']);
        ?>
" alt="<?php 
        echo quotes_to_entities($ms['image_alt']);
        ?>
"></div>
					<?php 
    }
    ?>
            </div>
            <div class="last_news_text" align="left">
                <div class="last_news_name"><?php 
    echo $ms['name'];
    ?>
</div>
                <div class="last_news_date"><?php 
    echo $ms['date'];
    ?>
</div><br>
Example #17
0
echo toolbar_close();
echo message_note();
?>

<div class='content'>
<table class='DataRow' cellpadding='0' cellspacing='0'>
<tr><th>Id:</th><td><?php 
echo $row->id;
?>
</td></tr>
<tr><th>Number:</th><td><?php 
echo form_input('number', quotes_to_entities($row->number), 'size="10"');
?>
</td></tr>
<tr><th>Title:</th><td><?php 
echo form_input('title', quotes_to_entities($row->title), 'size="60"');
?>
</td></tr>
<tr><th>Code:</th><td><?php 
echo form_input('code', quotes_to_entities($row->code), 'size="10"');
?>
</td></tr>
<tr><th>Color:</th><td><?php 
echo jscolor_picker('background_color', quotes_to_entities($row->background_color), 'size="12"');
?>
</td></tr>
</table>
</div>

<?php 
echo form_close();
Example #18
0
 function update_custom_category_fields()
 {
     $this->_restrict_prefs_access();
     // Are we editing or creating?
     $edit = (($field_id = $this->input->get_post('field_id')) !== FALSE and is_numeric($field_id)) ? TRUE : FALSE;
     $group_id = $this->input->get_post('group_id');
     if ($group_id == '' or !is_numeric($group_id)) {
         show_error(lang('unauthorized_access'));
     }
     unset($_POST['custom_field_edit']);
     // submit button
     // Check for required fields
     $error = array();
     if ($_POST['field_name'] == '') {
         $error[] = lang('no_field_name');
     } else {
         // Is the field one of the reserved words?
         if (in_array($_POST['field_name'], $this->cp->invalid_custom_field_names())) {
             $error[] = lang('reserved_word');
         }
         $field_name = $_POST['field_name'];
     }
     if ($_POST['field_label'] == '') {
         $error[] = lang('no_field_label');
     }
     // Does field name contain invalid characters?
     if (preg_match('/[^a-z0-9\\_\\-]/i', $_POST['field_name'])) {
         $error[] = lang('invalid_characters');
     }
     // Field name must be unique for across category groups
     if ($edit == FALSE) {
         $query = $this->db->query("SELECT COUNT(*) AS count FROM exp_category_fields WHERE site_id = '" . $this->db->escape_str($this->config->item('site_id')) . "' AND field_name = '" . $this->db->escape_str($_POST['field_name']) . "'");
         if ($query->row('count') > 0) {
             $error[] = lang('duplicate_field_name');
         }
     }
     // Are there errors to display?
     if (count($error) > 0) {
         $str = '';
         foreach ($error as $msg) {
             $str .= $msg . BR;
         }
         show_error($str);
     }
     if ($_POST['field_list_items'] != '') {
         $_POST['field_list_items'] = quotes_to_entities($_POST['field_list_items']);
     }
     if (!in_array($_POST['field_type'], array('text', 'textarea', 'select'))) {
         $_POST['field_text_direction'] = 'ltr';
     }
     // Construct the query based on whether we are updating or inserting
     if ($edit === TRUE) {
         // validate field id
         $query = $this->db->query("SELECT field_id FROM exp_category_fields WHERE group_id = '" . $this->db->escape_str($group_id) . "' AND field_id = '" . $this->db->escape_str($field_id) . "'");
         if ($query->num_rows() == 0) {
             return FALSE;
         }
         // Update the formatting for all existing entries
         if (isset($_POST['update_formatting'])) {
             $this->db->query("UPDATE exp_category_field_data SET field_ft_{$field_id} = '" . $this->db->escape_str($_POST['field_default_fmt']) . "'");
         }
         unset($_POST['group_id']);
         unset($_POST['update_formatting']);
         $this->db->query($this->db->update_string('exp_category_fields', $_POST, "field_id='" . $field_id . "'"));
         $cp_message = lang('cat_field_edited');
     } else {
         unset($_POST['update_formatting']);
         if ($_POST['field_order'] == 0 or $_POST['field_order'] == '') {
             $query = $this->db->query("SELECT COUNT(*) AS count FROM exp_category_fields WHERE group_id = '" . $this->db->escape_str($group_id) . "'");
             $_POST['field_order'] = $query->num_rows() + 1;
         }
         $_POST['site_id'] = $this->config->item('site_id');
         $this->db->insert('category_fields', $_POST);
         $insert_id = $this->db->insert_id();
         $this->db->query("ALTER TABLE exp_category_field_data ADD COLUMN field_id_{$insert_id} text NULL");
         $this->db->query("ALTER TABLE exp_category_field_data ADD COLUMN field_ft_{$insert_id} varchar(40) NULL default 'none'");
         $this->db->query("UPDATE exp_category_field_data SET field_ft_{$insert_id} = '" . $this->db->escape_str($_POST['field_default_fmt']) . "'");
         $cp_message = lang('cat_field_created');
     }
     $this->functions->clear_caching('all', '');
     $this->session->set_flashdata('message_success', $cp_message . ' ' . $field_name);
     $this->functions->redirect(BASE . AMP . 'C=admin_content' . AMP . 'M=category_custom_field_group_manager' . AMP . 'group_id=' . $group_id);
 }
 /**
  * Search Trash
  *
  * Lets you list the records in the database as oer the given search criteria
  * All records that are in trash are listed.
  *
  * @access	public
  * @param	integer - default set to 0 for pagination
  */
 function search_trash($per_page = 0)
 {
     if (isset($_POST['search_filter'])) {
         $search_filter = get_param("search_filter");
     } else {
         $search_filter = $this->session->userdata('search_filter');
     }
     $search_filter = trim(quotes_to_entities($search_filter));
     if (empty($search_filter)) {
         redirect($this->page_name . "/show_trash_list");
     }
     $data = array("pagetitle" => "Search results for '" . $search_filter . "' in trash", "search_filter" => $search_filter, "mode" => "search", "msg" => $this->msg, "errors" => $this->errors);
     // load pagination library
     $this->load->library('Digg_Pagination');
     //********************SET UP PAGINATION VALUES****************************
     //set up per_page_value, per_page_seg, cur_page_seg and $data['pbase_url']
     //************************************************************************
     $this->load->plugin('pagination');
     $per_page_value = 50;
     //default - unless overridden later
     $per_page_seg = 4;
     //the uri segment for the per page value
     $cur_page_seg = 5;
     //the url segment for the current page value (generally +1 of per page seg)
     $per_page = get_per_page($per_page_value, $per_page_seg);
     $offset = get_offset($cur_page_seg, $per_page);
     //generate the query
     $where = "status =  2";
     $where_or_like = array("page_name" => $search_filter, "page_meta_keywords" => $search_filter, "page_meta_description" => $search_filter, "page_h1" => $search_filter, "page_title_tag" => $search_filter, "page_html_data" => $search_filter);
     $data['users_result'] = $this->db_interaction->get_records_use_query($where, $where_or_like, $offset, $per_page, "id , page_name");
     //find out the total amount of records
     $total_rows = count($this->db_interaction->get_records_use_query($where, $where_or_like));
     $data['pbase_url'] = site_url($this->page_name . "/search_trash/");
     $data['pagination'] = init_paginate($cur_page_seg, $total_rows, $per_page, $per_page_seg, $data['pbase_url']);
     // get total no. of user in trash
     $where_trash_rows = array("status !=" => 2);
     $data['total_rows_items'] = $this->db_interaction->get_num_records_where($where_trash_rows);
     // get all pages
     $data['all_pages'] = $this->_get_all_pages();
     // load view and add additional data
     $this->_display("trash", $data);
     // Set the search result in a session array
     $this->session->set_userdata('search_filter', $search_filter);
 }
Example #20
0
<?php

echo form_open('admin/staff/staffurl_save');
echo toolbar_open('PLRD Active Staff');
echo toolbar_item('staffurl_save', 'Save');
echo toolbar_cancel();
echo toolbar_close();
echo message_note();
?>

<div class='content'>
    <table class='DataRow' cellpadding='0' cellspacing='0'>
        <tr><th><i class="glyphicon-1x glyphicon-asterisk text-danger"></i> URL:</th><td><?php 
echo form_input('staff_url', quotes_to_entities($url), 'size="100"');
?>
</td></tr>
    </table>
    </div>

<?php 
echo form_close();
Example #21
0
					</div>
					<div class="base_center">
						<div class="base_center_left"></div><div class="base_center_right"></div>
						<div class="base_center_repeat">
							<div class="carousel_product_block">
								<?php
								if(isset($ms['timage']))
								{
									?>
									<div class="image_block">
									<a href="<?=$ms['bimage']?>" title="<?=quotes_to_entities($ms['image_name'])?>" class="highslide" onclick="return hs.expand(this, pr_config_highslide_new_products)">
									<?
									if($ms['bestseller']) echo '<div class="over_top">'.$this->lang->line('products_bestseller').'</div>';
									if($ms['new']) echo '<div class="over_bot">'.$this->lang->line('products_new').'</div>';
									?>
									<img src="<?=$ms['timage']?>" title="<?=quotes_to_entities($ms['image_title'])?>" alt="<?=quotes_to_entities($ms['image_alt'])?>" />
									</a>
									</div>
									<?
								}
								?>
								<div class="product_name"><a href="<?=$ms['detail_url']?>"><?=$ms['name']?></a></div>
								<div class="product_sku"><?=$this->lang->line('products_sku')?> :<span><?=$ms['sku']?></span></div>
								<div class="sale_stock">
									<?php
									if($ms['sale'])
									{
										?><div class="not_in_stock"><span><?=$this->lang->line('products_sale')?></span></div><?
									}
									?>
								</div>
Example #22
0
</td></tr>
        <tr><th><i class="glyphicon-1x glyphicon-asterisk text-danger"></i> Timezone:</th><td>
                <select name="sys_timezone">
                    <option value="">Select Timezone</option>
                    <?php 
foreach ($timezone as $z) {
    $sel = $z->id == $row->sys_timezone ? 'selected' : '';
    ?>
                        <option value="<?php 
    echo $z->id;
    ?>
" <?php 
    echo $sel;
    ?>
><?php 
    echo $z->timezone;
    ?>
</option>
                    <?php 
}
?>
                </select></td></tr>
        <tr><th><i class="glyphicon-1x glyphicon-asterisk text-danger"></i> Control Room Phone# :</th><td><?php 
echo form_input('ofc_number', quotes_to_entities($row->ofc_number), 'size="30"');
?>
 </td></tr>
</table>
    </div>

<?php 
echo form_close();
Example #23
0
 public function string_helper()
 {
     $this->load->helper('string');
     $this->htmlp(random_string('alnum', 16));
     $this->htmlp(increment_string('file', '_'));
     // "file_1"
     $this->htmlp(increment_string('file', '-', 2));
     // "file-2"
     $this->htmlp(increment_string('file_4'));
     // "file_5"
     for ($i = 0; $i < 10; $i++) {
         $this->htmlp(alternator('one', 'two', 'three', 'four', 'five'));
     }
     $string = "|repeat";
     $this->htmlp(repeater($string, 30));
     // DEPRECATED
     $string = "http://example.com//index.php";
     $this->htmlp(reduce_double_slashes($string));
     // results in "http://example.com/index.php"
     $string = "/this/that/theother/";
     $this->htmlp(trim_slashes($string));
     // results in this/that/theother
     $string = "Fred, Bill,, Joe, Jimmy";
     $string = reduce_multiples($string, ",");
     //results in "Fred, Bill, Joe, Jimmy"
     $this->htmlp($string);
     $string = ",Fred, Bill,, Joe, Jimmy,";
     $string = reduce_multiples($string, ", ", TRUE);
     //results in "Fred, Bill, Joe, Jimmy"
     $this->htmlp($string);
     $string = "Joe's \"dinner\"";
     $string = quotes_to_entities($string);
     //results in "Joe&#39;s &quot;dinner&quot;"
     $this->htmlp($string);
     $string = "Joe's \"dinner\"";
     $string = strip_quotes($string);
     //results in "Joes dinner"
     $this->htmlp($string);
 }
 function create_field($channel_id, $group_id, $mfield)
 {
     $this->EE->lang->loadfile('admin_content');
     $this->EE->load->library('api');
     $this->EE->api->instantiate('channel_fields');
     // If the $field_id variable has data we are editing an
     // existing group, otherwise we are creating a new one
     $edit = FALSE;
     // Check for required fields
     $error = array();
     $this->EE->load->model('field_model');
     // Is the field name taken?
     $this->EE->db->select('*');
     $this->EE->db->where('site_id', $this->EE->config->item('site_id'));
     $this->EE->db->where('field_name', 'mbr_' . $mfield->m_field_name);
     $query = $this->EE->db->get('channel_fields');
     if ($query->num_rows() > 0) {
         return $query->row('field_id');
     }
     $field_type = $mfield->m_field_type;
     // Are there errors to display?
     if (count($error) > 0) {
         $str = '';
         foreach ($error as $msg) {
             $str .= $msg . BR;
         }
         return array("errors" => $str);
     }
     $native = array('field_id', 'site_id', 'group_id', 'field_name', 'field_label', 'field_instructions', 'field_type', 'field_list_items', 'field_pre_populate', 'field_pre_channel_id', 'field_pre_field_id', 'field_ta_rows', 'field_maxl', 'field_required', 'field_text_direction', 'field_search', 'field_is_hidden', 'field_fmt', 'field_show_fmt', 'field_order');
     if (version_compare(APP_VER, '2.6.0', '<')) {
         $native = array_merge($native, array('field_related_id', 'field_related_orderby', 'field_related_sort', 'field_related_max'));
     }
     $_posted = array();
     $_field_posted = preg_grep('/^' . $field_type . '_.*/', array_keys($_POST));
     $_keys = array_merge($native, $_field_posted);
     foreach ($_keys as $key) {
         if (isset($_POST[$key])) {
             $_posted[$key] = $this->input->post($key);
         }
     }
     // Get the field type settings
     $this->EE->api_channel_fields->fetch_all_fieldtypes();
     $this->EE->api_channel_fields->setup_handler($field_type);
     $ft_settings = $this->EE->api_channel_fields->apply('save_settings', array($_posted));
     // Default display options
     foreach (array('smileys', 'glossary', 'spellcheck', 'formatting_btns', 'file_selector', 'writemode') as $key) {
         $ft_settings['field_show_' . $key] = 'n';
     }
     $native_settings['field_id'] = '';
     $native_settings['site_id'] = $this->EE->config->item('site_id');
     $native_settings['group_id'] = $group_id;
     $native_settings['field_name'] = "mbr_" . $mfield->m_field_name;
     $native_settings['field_label'] = $mfield->m_field_label;
     $native_settings['field_instructions'] = $mfield->m_field_description;
     $native_settings['field_type'] = $mfield->m_field_type;
     $native_settings['field_content_type'] = $mfield->m_field_type;
     $native_settings['field_list_items'] = $mfield->m_field_list_items;
     $native_settings['field_pre_populate'] = 'n';
     $native_settings['field_pre_channel_id'] = '';
     $native_settings['field_pre_field_id'] = '';
     if (version_compare(APP_VER, '2.6.0', '<')) {
         $native_settings['field_related_id'] = '';
         $native_settings['field_related_orderby'] = '';
         $native_settings['field_related_sort'] = '';
         $native_settings['field_related_max'] = '';
     }
     $native_settings['field_ta_rows'] = $mfield->m_field_ta_rows;
     if (isset($mfield->m_field_maxl)) {
         $native_settings['field_maxl'] = $mfield->m_field_maxl;
     }
     $native_settings['field_required'] = $mfield->m_field_required;
     $native_settings['field_text_direction'] = 'ltr';
     $native_settings['field_search'] = $mfield->m_field_search;
     $native_settings['field_is_hidden'] = 'n';
     $native_settings['field_fmt'] = $mfield->m_field_fmt;
     $native_settings['field_show_fmt'] = 'n';
     $native_settings['field_order'] = '';
     if ($native_settings['field_list_items'] != '') {
         // This results in double encoding later on
         $this->EE->load->helper('string');
         $native_settings['field_list_items'] = quotes_to_entities($native_settings['field_list_items']);
     }
     //
     // if ($native_settings['field_pre_populate'] == 'y')
     // {
     // 	$x = explode('_', $this->_get_ft_post_data($field_type, 'field_pre_populate_id'));
     //
     // 	$native_settings['field_pre_channel_id']	= $x['0'];
     // 	$native_settings['field_pre_field_id'] = $x['1'];
     // }
     // If they returned a native field value as part of their settings instead of changing the post array,
     // we'll merge those changes into our native settings
     foreach ($ft_settings as $key => $val) {
         if (in_array($key, $native)) {
             if ($val != '') {
                 unset($ft_settings[$key]);
                 $native_settings[$key] = $val;
             }
         }
     }
     $native_settings['field_settings'] = base64_encode(serialize($ft_settings));
     //
     $cp_message = lang('custom_field_created');
     $query = $this->EE->db->select('COUNT(*) as COUNT')->where('group_id', (int) $group_id)->get('channel_fields');
     $native_settings['field_order'] = $query->row('COUNT') + 1;
     if (!$native_settings['field_ta_rows']) {
         $native_settings['field_ta_rows'] = 0;
     }
     // as its new, there will be no field id, unset it to prevent an empty string from attempting to pass
     unset($native_settings['field_id']);
     $this->EE->db->insert('channel_fields', $native_settings);
     $insert_id = $this->EE->db->insert_id();
     $native_settings['field_id'] = $insert_id;
     $this->EE->api_channel_fields->add_datatype($insert_id, $native_settings);
     $this->EE->db->update('channel_data', array('field_ft_' . $insert_id => $native_settings['field_fmt']));
     foreach (array('none', 'br', 'xhtml') as $val) {
         $f_data = array('field_id' => $insert_id, 'field_fmt' => $val);
         $this->EE->db->insert('field_formatting', $f_data);
     }
     $collapse = $native_settings['field_is_hidden'] == 'y' ? TRUE : FALSE;
     $buttons = $ft_settings['field_show_formatting_btns'] == 'y' ? TRUE : FALSE;
     $field_info['publish'][$insert_id] = array('visible' => 'true', 'collapse' => $collapse, 'htmlbuttons' => $buttons, 'width' => '100%');
     // Add to any custom layouts
     $query = $this->EE->field_model->get_assigned_channels($group_id);
     if ($query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             $channel_ids[] = $row->channel_id;
         }
         $this->EE->load->library('layout');
         $this->EE->layout->add_layout_fields($field_info, $channel_ids);
     }
     $_final_settings = array_merge($native_settings, $ft_settings);
     unset($_final_settings['field_settings']);
     $this->EE->api_channel_fields->set_settings($native_settings['field_id'], $_final_settings);
     $this->EE->api_channel_fields->setup_handler($native_settings['field_id']);
     $this->EE->api_channel_fields->apply('post_save_settings', array($_posted));
     $this->EE->functions->clear_caching('all', '', TRUE);
     return $insert_id;
     $strlen = strlen($native_settings['field_name']);
     if ($strlen > 32) {
         $this->EE->session->set_flashdata('message_failure', lang('field_name_too_lrg'));
     } else {
         $this->EE->session->set_flashdata('message_success', $cp_message);
     }
     //$this->functions->redirect(BASE.AMP.'C=addons_modules'.AMP.'M=field_management'.AMP.'group_id='.$group_id);
 }
Example #25
0
        ?>
</em></td>
			</tr>
		<?php 
    } else {
        ?>
			<?php 
        foreach ($position['candidates'] as $candidate) {
            ?>
				<?php 
            $name = $candidate['first_name'];
            if (!empty($candidate['alias'])) {
                $name .= ' "' . $candidate['alias'] . '"';
            }
            $name .= ' ' . $candidate['last_name'];
            $name = quotes_to_entities($name);
            ?>
				<?php 
            if ($candidate['voted']) {
                ?>
				<tr class="selected">
				<?php 
            } else {
                ?>
				<tr>
				<?php 
            }
            ?>
					<td class="w5" align="center">
						<?php 
            if ($candidate['voted']) {
 function image($image, $title = null, $width = 0, $height = 0, $parameters = null)
 {
     if (empty($image)) {
         return false;
     }
     if (!is_numeric($width)) {
         $width = 0;
     }
     if (!is_numeric($height)) {
         $height = 0;
     }
     $image = '<img src="' . str_replace('admin/', '', base_url(quotes_to_entities($image))) . '" border="0" alt="' . quotes_to_entities($title) . '"';
     if (!empty($title)) {
         $image .= ' title="' . quotes_to_entities($title) . '"';
     }
     if ($width > 0) {
         $image .= ' width="' . (int) $width . '"';
     }
     if ($height > 0) {
         $image .= ' height="' . (int) $height . '"';
     }
     if (!empty($parameters)) {
         $image .= ' ' . $parameters;
     }
     $image .= ' />';
     return $image;
 }
Example #27
0
					<div class="sale">
					</div>
				<?
				}
				?>
		</div>
		<div class="fblock">
			<div class="img_block">
				<div style="clear:both;"></div>
				<?php
					if(isset($images))
					{
						foreach($images as $ms)
						{
							?>
							<a oncontextmenu="return false;" href="<?=$ms['bimage']?>" title="<?=quotes_to_entities($ms['image_name'])?>" class="highslide" onclick="return hs.expand(this)"><img onclick="contextmenu();" src="<?=$ms['timage']?>" class="prod_img_src" title="<?=quotes_to_entities($ms['image_title'])?>" alt="<?=quotes_to_entities($ms['image_alt'])?>" /></a>
							<div style="clear:both;"></div>
							<?
							
						}
					}
				?>
			</div>
			<div class="desc_block">
				<div class="name">
					<?=$product['name']?>
				</div>
				<div style="color:#CC0000;font-size:17px;font-weight:bold;">
					Товар продается только оптом.
				</div>
				<?php
Example #28
0
 /**
  * Update Profile Fields
  *
  * This function alters the "exp_member_data" table, adding
  * the new custom fields.
  *
  * @return	mixed
  */
 public function update_profile_fields()
 {
     if (!$this->cp->allowed_group('can_access_members') or !$this->cp->allowed_group('can_admin_members')) {
         show_error(lang('unauthorized_access'));
     }
     // If the $field_id variable is present we are editing an
     // existing field, otherwise we are creating a new one
     $edit = (isset($_POST['m_field_id']) and $_POST['m_field_id'] != '') ? TRUE : FALSE;
     $this->_validate_custom_field($edit);
     if ($this->form_validation->run() === FALSE) {
         return $this->edit_profile_field();
     }
     $this->lang->loadfile('admin_content');
     $this->load->model('member_model');
     unset($_POST['cur_field_name']);
     if ($this->input->post('m_field_list_items') != '') {
         // Load the string helper
         $this->load->helper('string');
         $_POST['m_field_list_items'] = quotes_to_entities($_POST['m_field_list_items']);
     }
     // Construct the query based on whether we are updating or inserting
     if ($edit === TRUE) {
         $n = $_POST['m_field_maxl'];
         if ($_POST['m_field_type'] == 'text') {
             if (!is_numeric($n) or $n == '' or $n == 0) {
                 $n = '100';
             }
             $f_type = 'varchar(' . $n . ') NULL DEFAULT NULL';
         } else {
             $f_type = 'text NULL DEFAULT NULL';
         }
         $this->db->query("ALTER table exp_member_data CHANGE m_field_id_" . $_POST['m_field_id'] . " m_field_id_" . $_POST['m_field_id'] . " {$f_type}");
         $id = $_POST['m_field_id'];
         unset($_POST['m_field_id']);
         $this->db->query($this->db->update_string('exp_member_fields', $_POST, 'm_field_id=' . $id));
     } else {
         if ($_POST['m_field_order'] == 0 or $_POST['m_field_order'] == '') {
             $query = $this->member_model->count_records('member_fields');
             $total = $query->row('count') + 1;
             $_POST['m_field_order'] = $total;
         }
         $n = $_POST['m_field_maxl'];
         if ($_POST['m_field_type'] == 'text') {
             if (!is_numeric($n) or $n == '' or $n == 0) {
                 $n = '100';
             }
             $f_type = 'varchar(' . $n . ') NULL DEFAULT NULL';
         } else {
             $f_type = 'text NULL DEFAULT NULL';
         }
         unset($_POST['m_field_id']);
         $this->db->query($this->db->insert_string('exp_member_fields', $_POST));
         $this->db->query('ALTER table exp_member_data add column m_field_id_' . $this->db->insert_id() . ' ' . $f_type);
         $sql = "SELECT exp_members.member_id\n\t\t\t\t\tFROM exp_members\n\t\t\t\t\tLEFT JOIN exp_member_data ON exp_members.member_id = exp_member_data.member_id\n\t\t\t\t\tWHERE exp_member_data.member_id IS NULL\n\t\t\t\t\tORDER BY exp_members.member_id";
         $query = $this->db->query($sql);
         if ($query->num_rows() > 0) {
             foreach ($query->result_array() as $row) {
                 $this->db->query("INSERT INTO exp_member_data (member_id) values ('{$row['member_id']}')");
             }
         }
     }
     $cp_message = $edit ? lang('field_updated') : lang('field_created');
     $this->session->set_flashdata('message_success', $cp_message);
     $this->functions->redirect(BASE . AMP . 'C=members' . AMP . 'M=custom_profile_fields');
 }
 public function getParamStringAdmin($param)
 {
     return addslashes(isset($_REQUEST[$param]) ? $this->str_equal(quotes_to_entities($_REQUEST[$param])) : '');
 }
Example #30
0
        </div>
<?php
if(isset($products))
{
	foreach($products as $ms)
	{
	?>
    	

			<div class="block">
            	<div class="img_block">
					<?php
                    if(isset($ms['timage']))
                    {
                        ?>
                            <a href="<?=$ms['bimage']?>" title="<?=quotes_to_entities($ms['image_name'])?>" class="highslide" onclick="return hs.expand(this)"><img src="<?=$ms['timage']?>" title="<?=quotes_to_entities($ms['image_title'])?>" alt="<?=quotes_to_entities($ms['image_alt'])?>" height="100"  /></a>
                        <?php
                    }
                    ?>
                </div>
                <a href="<?=$ms['detail_url']?>"><div class="sale_name"><?=$ms['name']?></div></a>
                <div class="sale_price">
                    <?=$ms['price']?>
                </div>
            </div>
			

	<?
	}
}
?>