public function wizard_confirm($mode = NULL) { $body_page = NULL; $hint_txt = NULL; $hint_title = NULL; $hostname = NULL; $template_data = array(); $this->load->library('parser'); $this->load->helper(array('corestatus', 'zimapi')); $this->lang->load('activation/activation_wizard', $this->config->item('language')); if (!CoreStatus_finishActivation()) { $this->load->helper('printerlog'); PrinterLog_LogError('can not finish need activation mode', __FILE__, __LINE__); } if (ERROR_OK != ZimAPI_getHostname($hostname)) { $this->load->helper('printerlog'); PrinterLog_logError('can not get hostname', __FILE__, __LINE__); } switch ($mode) { case NULL: $hint_txt = t('wizard_success_hint', array($hostname, $hostname, $hostname)); $hint_title = t('hint_title_success'); // send email $email = $this->session->userdata('email'); @file_get_contents('https://sso.zeepro.com/sendtipsmail.ashx?email=' . $email); break; case 'fail': $hint_txt = t('wizard_fail_hint', array($hostname, $hostname)); $hint_title = t('hint_title'); break; case 'skip': $this->output->set_header("Location: /menu_home"); return; default: if ($mode != 'skip') { $this->load->helper('printerlog'); PrinterLog_LogError('unknown mode for wizard, mode: ' . $mode, __FILE__, __LINE__); } $hint_txt = t('wizard_skip_hint', array($hostname, $hostname)); break; } $template_data = array('hint_title' => $hint_title, 'hint_txt' => $hint_txt, 'button_ok' => t('button_ok')); $body_page = $this->parser->parse('template/activation/activation_wizard', $template_data, TRUE); // parse all page $template_data = array('lang' => $this->config->item('language_abbr'), 'headers' => '<title>' . t('ZeePro Personal Printer 21 - Activation') . '</title>', 'contents' => $body_page); $this->parser->parse('basetemplate', $template_data); return; }
private function _assign_wizard($email, $password) { $context = NULL; $printer_name = NULL; $cr = 0; $option = array(); $this->load->helper('zimapi'); if (ERROR_OK != ZimAPI_getHostname($printer_name)) { $printer_name = 'zim'; } $data = array('email' => $email, 'password' => $password, 'printersn' => ZimAPI_getSerial(), 'printername' => $printer_name); $options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data))); $context = stream_context_create($options); @file_get_contents('https://sso.zeepro.com/addprinter.ashx', false, $context); $result = substr($http_response_header[0], 9, 3); if ($result == 200) { ZimAPI_setPrinterSSOName($printer_name); return TRUE; } return FALSE; }
public function sethostname() { $template_data = array(); $error = ''; $ret_val = 0; $hostname = NULL; $restart = NULL; $this->load->library('parser'); $this->lang->load('printerstate/sethostname', $this->config->item('language')); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $hostname = $this->input->post('hostname'); $restart = $this->input->post('restart'); $returnUrl = $this->input->post('returnUrl'); if ((int) $restart == 0) { $restart = FALSE; } else { $restart = TRUE; } if ($hostname) { $this->load->helper('zimapi'); $code = ZimAPI_setHostname($hostname, $restart); if (!CoreStatus_finishHostname()) { $this->load->helper('printerlog'); PrinterLog_logError('can not remove need hostname status', __FILE__, __LINE__); } if ($code == ERROR_OK) { $hint_message = NULL; $network_info = array(); $err = ZimAPI_getNetworkInfoAsArray($network_info); if ($err != ERROR_OK) { $this->load->helper('printerlog'); PrinterLog_logError('can not retrieve connection info array', __FILE__, __LINE__); $error = t("network_array_error"); } else { if ($network_info[ZIMAPI_TITLE_TOPOLOGY] == ZIMAPI_VALUE_P2P) { $hint_message = t('p2p', $network_info[ZIMAPI_TITLE_SSID]); } else { if ($restart == TRUE) { $hint_message = t('finish_hint', array($hostname, $hostname, $hostname, $hostname)); } else { $hint_message = t('finish_hint_norestart', array($hostname, $hostname)); } } //parse the main body $template_data = array('hint' => $hint_message); // parse all page $this->_parseBaseTemplate(t('page_title'), $this->parser->parse('printerstate/sethostname_finish', $template_data, TRUE)); return; } } else { if ($code == ERROR_WRONG_PRM) { $error = t('bad_char'); } else { $error = t('set_error'); } } } else { $error = t('no_input'); } } if ($restart === NULL) { if (FALSE === $this->input->get('norestart')) { $restart = TRUE; } else { $restart = FALSE; } } $ret_val = ZimAPI_getHostname($hostname); if ($ret_val != ERROR_OK) { $hostname = 'zim'; } // parse the main body $template_data = array('hint' => t('set_hint'), 'set_button' => t('set_button'), 'error' => $error, 'back' => t('back'), 'home_button' => t('home_button'), 'hostname' => $hostname, 'info_text' => t('info_text'), 'length_error' => t('length_error'), 'restart' => $restart ? 1 : 0); // parse all page $this->_parseBaseTemplate(t('page_title'), $this->parser->parse('printerstate/sethostname', $template_data, TRUE)); return; }
function PrinterState_getInfoAsArray() { $CI =& get_instance(); $CI->load->helper('zimapi'); $version_marlin = NULL; $name_sso = NULL; $hostname = NULL; $network_data = array(); $platform_size = array(); $array_return = array(); $cr = 0; $cr = PrinterState_getMarlinVersion($version_marlin); if ($cr != ERROR_OK) { $version_marlin = 'N/A'; } $cr = ZimAPI_getHostname($hostname); if ($cr != ERROR_OK) { $hostname = 'N/A'; } PrinterState_getPrintSize($platform_size); $cr = ZimAPI_getNetworkInfoAsArray($network_data); $array_return = array(PRINTERSTATE_TITLE_VERSION => ZimAPI_getVersion(), PRINTERSTATE_TITLE_VERSION_N => ZimAPI_getVersion(TRUE), PRINTERSTATE_TITLE_TYPE => ZimAPI_getType(), PRINTERSTATE_TITLE_SERIAL => ZimAPI_getSerial(), PRINTERSTATE_TITLE_NB_EXTRUD => $CI->config->item('nb_extruder'), PRINTERSTATE_TITLE_VER_MARLIN => $version_marlin, PRINTERSTATE_TITLE_HOSTNAME => $hostname, ZIMAPI_TITLE_IP => $cr == ERROR_OK && isset($network_data[ZIMAPI_TITLE_IP]) ? $network_data[ZIMAPI_TITLE_IP] : 'N/A', ZIMAPI_TITLE_IPV6 => $cr == ERROR_OK && isset($network_data[ZIMAPI_TITLE_IPV6]) ? $network_data[ZIMAPI_TITLE_IPV6] : 'N/A'); foreach ($platform_size as $key => $value) { $array_return[$key] = $value; } $cr = ZimAPI_getPrinterSSOName($name_sso); if ($cr == ERROR_OK && $name_sso != NULL) { $array_return[PRINTERSTATE_TITLE_SSO_NAME] = $name_sso; } return $array_return; }
public function in_progress($ssid = NULL) { $template_data = array(); $body_page = NULL; $hostname = NULL; $this->load->library('parser'); $this->load->helper('zimapi'); $this->lang->load('connection/master', $this->config->item('language')); $this->lang->load('connection/in_progress', $this->config->item('language')); if (ERROR_OK != ZimAPI_getHostname($hostname)) { $this->load->helper('printerlog'); PrinterLog_logError('cannot get hostname', __FILE__, __LINE__); } $template_data = array('hostname' => $hostname, 'printersn' => ZimAPI_getSerial(), 'config_printer' => t('config_printer'), 'connect_error_msg' => t('connect_error_msg'), 'popup' => t('popup', $ssid ? urldecode($ssid) : "XXX")); $body_page = $this->parser->parse('connection/in_progress', $template_data, TRUE); $this->_generate_framePage($body_page); return; }