function ZimAPI_setNetwork($string_json) { $array_config = json_decode($string_json); if ($array_config) { if (isset($array_config[ZIMAPI_TITLE_TOPOLOGY]) && isset($array_config[ZIMAPI_TITLE_MEDIUM])) { if ($array_config[ZIMAPI_TITLE_MEDIUM] == ZIMAPI_VALUE_WIFI) { if (!isset($array_config[ZIMAPI_TITLE_SSID]) || !isset($array_config[ZIMAPI_TITLE_PASSWD])) { return ERROR_MISS_PRM; } $ssid = $array_config[ZIMAPI_TITLE_SSID]; $pwd = $array_config[ZIMAPI_TITLE_PASSWD]; if ($array_config[ZIMAPI_TITLE_TOPOLOGY] == ZIMAPI_VALUE_NETWORK) { return ZimAPI_setcWifi($ssid, $pwd); } else { if ($array_config[ZIMAPI_TITLE_TOPOLOGY] == ZIMAPI_VALUE_P2P) { return ZimAPI_setsWifi($ssid, $pwd); } else { return ERROR_WRONG_PRM; } } } else { if ($array_config[ZIMAPI_TITLE_MEDIUM] == ZIMAPI_VALUE_ETH && $array_config[ZIMAPI_TITLE_TOPOLOGY] == ZIMAPI_VALUE_NETWORK) { if (isset($array_config[ZIMAPI_TITLE_CUS_IP]) || isset($array_config[ZIMAPI_TITLE_CUS_GW]) || isset($array_config[ZIMAPI_TITLE_CUS_MK])) { if (!isset($array_config[ZIMAPI_TITLE_CUS_IP]) || !isset($array_config[ZIMAPI_TITLE_CUS_GW]) || !isset($array_config[ZIMAPI_TITLE_CUS_MK])) { return ERROR_MISS_PRM; } $ip = $array_config[ZIMAPI_TITLE_CUS_IP]; $gateway = $array_config[ZIMAPI_TITLE_CUS_GW]; $mask = $array_config = $array_config[ZIMAPI_TITLE_CUS_MK]; return ZimAPI_setcEth($ip, $mask, $gateway); } else { return ZimAPI_setpEth(); } } else { return ERROR_WRONG_PRM; } } } else { return ERROR_MISS_PRM; } } else { return ERROR_WRONG_PRM; } }
public function wiredadvanced() { // global $CFG; $template_data = array(); $body_page = NULL; $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); $this->lang->load('connection/master', $this->config->item('language')); $this->lang->load('connection/wiredadvanced', $this->config->item('language')); $this->template->set('lang', $this->config->item('language_abbr')); $this->template->set('header', "<title>" . t('ZeePro Personal Printer 21 - Connection configuration') . "</title>"); $this->form_validation->set_rules('ip', 'ip error', 'callback_ip_check'); $this->form_validation->set_message('ip_check', t("ip error")); $this->form_validation->set_rules('mask', 'mask error', 'callback_mask_check'); $this->form_validation->set_message('mask_check', t("mask error")); $this->form_validation->set_rules('gateway', 'gateway error', 'callback_gateway_check'); $this->form_validation->set_message('gateway_check', t("gateway error")); $this->form_validation->set_rules('dns', 'dns error', 'callback_ip_check'); $this->form_validation->set_message('ip_check', t("dns error")); $this->form_validation->set_error_delimiters('<i>', '</i>'); if ($this->form_validation->run() == FALSE) { $this->load->library('parser'); // $this->template->load ( 'connectionmaster', 'connectionwiredadvanced', $data ); $template_data = array('title' => t('Advanced wired network connection'), 'back' => t('Back'), 'ip_label' => htmlspecialchars(t("ip")), 'ip_value' => set_value('ip'), 'ip_hint' => htmlspecialchars(t("ip ex")), 'ip_error' => form_error('ip'), 'mask_label' => htmlspecialchars(t("mask")), 'mask_value' => set_value('mask'), 'mask_hint' => htmlspecialchars(t("mask ex")), 'mask_error' => form_error('mask'), 'gateway_label' => htmlspecialchars(t("gateway")), 'gateway_value' => set_value('gateway'), 'gateway_hint' => htmlspecialchars(t("gateway ex")), 'gateway_error' => form_error('gateway'), 'dns_label' => htmlspecialchars(t("dns")), 'dns_value' => set_value('dns'), 'dns_hint' => htmlspecialchars(t("dns ex")), 'dns_error' => form_error('dns'), 'submit' => htmlspecialchars(t("OK"))); $body_page = $this->parser->parse('connection/wiredadvanced', $template_data, TRUE); // parse all page $this->_generate_framePage($body_page); } else { $cr = 0; $ip = $this->input->post('ip'); $mask = $this->input->post('mask'); $gateWay = $this->input->post('gateway'); $cr = ZimAPI_setcEth($ip, $mask, $gateWay); if ($cr != ERROR_OK) { $this->output->set_header("Location:/connection/advanced"); } else { //$this->confirmation(); $this->output->set_header("Location:/printerstate/sethostname"); if (!CoreStatus_wantHostname()) { $this->load->helper('printerlog'); PrinterLog_logError('can not set need hostname status', __FILE__, __LINE__); } } } return; }