Ejemplo n.º 1
0
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;
    }
}
Ejemplo n.º 2
0
 public function wiredauto()
 {
     $cr = 0;
     $this->load->helper(array('zimapi'));
     $cr = ZimAPI_setpEth();
     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;
 }