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 wifip2p() { $ret_val = 0; $error = ''; $template_data = array(); $body_page = NULL; $this->load->helper(array('zimapi')); $this->lang->load('connection/wifip2p', $this->config->item('language')); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->load->library('form_validation'); $this->form_validation->set_rules('ssid', 'SSID', 'required'); if ($this->form_validation->run() == FALSE) { // Here is where you do stuff when the submitted form is invalid. $error = t('invalid SSID'); } else { $ssid = $this->input->post('ssid'); $passwd = $this->input->post('pwd'); if (!ctype_print($ssid) || $passwd && !ctype_print($passwd)) { $error = t('invalid data (special character)'); } else { $ret_val = ZimAPI_setsWifi($ssid, $passwd); if ($ret_val != ERROR_OK) { $error = t('invalid data'); } else { // $this->output->set_header("Location:/connection/confirmation"); // $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; // end generating if successed } } } } // generate form to submit when not in post method $this->load->library('parser'); // parse the main body $template_data = array('title' => t('Personalize the printer\'s network'), 'ssid_title' => t('Write your network\'s name'), 'pwd_title' => t('Write your password'), 'error' => $error, 'ok' => t('OK'), 'show_password' => t('show_password'), 'back' => t('back')); $body_page = $this->parser->parse('connection/wifip2p', $template_data, TRUE); // parse all page $this->_generate_framePage($body_page); return; }