예제 #1
0
function ZimAPI_resetNetwork()
{
    $CI =& get_instance();
    $CI->load->helper(array('corestatus'));
    if (!DectectOS_checkWindows()) {
        try {
            $command = '';
            $output = NULL;
            $ret_val = 0;
            ZimAPI_setHostname("zim");
            exec(ZIMAPI_CMD_RESET_NETWORK, $output, $ret_val);
            if ($ret_val != ERROR_NORMAL_RC_OK) {
                return ERROR_INTERNAL;
            } else {
                // 				$retry_once = TRUE;
                // 				do {
                // 					exec(ZIMAPI_CMD_RESTART_WEB, $output, $ret_val);
                // 				} while (($ret_val != ERROR_NORMAL_RC_OK)
                // 						&& ($retry_once == TRUE) && ($retry_once = FALSE));
                // we can not get return value because of '&'
                ZimAPI_restartNetwork();
            }
        } catch (Exception $e) {
            return ERROR_INTERNAL;
        }
    }
    $ret_val = CoreStatus_wantConnection();
    if ($ret_val == FALSE) {
        $CI->load->helper('printerlog');
        PrinterLog_logError('want connection in reset error', __FILE__, __LINE__);
        return ERROR_INTERNAL;
    }
    return ERROR_OK;
}
예제 #2
0
 public function wifipswd()
 {
     $template_data = array();
     $body_page = NULL;
     $valid = TRUE;
     $this->load->library(array('parser', 'form_validation'));
     $this->load->helper(array('zimapi', 'corestatus'));
     $this->lang->load('connection/master', $this->config->item('language'));
     $this->lang->load('connection/wifipswd', $this->config->item('language'));
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $this->form_validation->set_rules('password_confirm', 'Password confirmation', 'matches[password]');
         $valid = $this->form_validation->run();
         $ssid = $this->input->post('ssid');
         $mode = $this->input->post('mode');
         if ($valid != FALSE) {
             $passwd = $this->input->post('password');
             $ret_val = ZimAPI_setcWifi($ssid, $passwd);
             if ($ret_val != ERROR_OK) {
                 // 				$error = t('invalid data');
                 $this->output->set_header("Location:/connection/wifissid" . ($mode == 'wizard') ? '/wizard' : NULL);
                 return;
             } else {
                 //$this->confirmation();
                 if ($mode == 'wizard') {
                     // 					$this->confirmation_wizard();
                     // 					$this->in_progress();
                     if (!CoreStatus_wantActivation()) {
                         $this->load->helper('printerlog');
                         PrinterLog_logError('can not set need activation status', __FILE__, __LINE__);
                     }
                     ZimAPI_restartNetwork();
                     $this->output->set_header("Location:/connection/in_progress/" . rawurlencode($ssid));
                     return;
                 } else {
                     if (!CoreStatus_wantHostname()) {
                         $this->load->helper('printerlog');
                         PrinterLog_logError('can not set need hostname status', __FILE__, __LINE__);
                     }
                     $this->output->set_header("Location:/printerstate/sethostname");
                     return;
                 }
             }
         }
     } else {
         $ssid = $this->input->get('ssid');
         $mode = $this->input->get('mode');
     }
     $template_data = array('title' => htmlspecialchars(t("network", $ssid)), 'ssid' => $ssid, 'label' => htmlspecialchars(t("network password")), 'back' => t('Back'), 'submit' => htmlspecialchars(t("OK")), 'mode' => $mode == 'wizard' ? 'wizard' : 'normal', 'confirm_password' => t('confirm_password'), 'show_password' => t('show_password'), 'err_msg' => $valid == FALSE ? t('err_msg') : "");
     $body_page = $this->parser->parse('connection/wifipswd', $template_data, TRUE);
     // parse all page
     $this->_generate_framePage($body_page);
     return;
 }