function admin_page_autoupdater() { ?> <div class="wrap"> <?php $auxarray = array(); if (isset($_GET['dzsp_purchase_remove_binded']) && $_GET['dzsp_purchase_remove_binded'] == 'on') { $this->db_mainoptions['dzsp_purchase_code_binded'] = 'off'; update_option($this->dbname_mainoptions, $this->db_mainoptions); } if (isset($_POST['action']) && $_POST['action'] === 'dzsp_update_request') { if (isset($_POST['dzsp_purchase_code'])) { $auxarray = array('dzsp_purchase_code' => $_POST['dzsp_purchase_code']); $auxarray = array_merge($this->db_mainoptions, $auxarray); $this->db_mainoptions = $auxarray; update_option($this->dbname_mainoptions, $auxarray); } } $extra_class = ''; $extra_attr = ''; $form_method = "POST"; $form_action = ""; $disable_button = ''; $lab = 'dzsp_purchase_code'; if ($this->db_mainoptions['dzsp_purchase_code_binded'] == 'on') { $extra_attr = ' disabled'; $disable_button = ' <input type="hidden" name="purchase_code" value="' . $this->db_mainoptions[$lab] . '"/><input type="hidden" name="site_url" value="' . site_url() . '"/><input type="hidden" name="redirect_url" value="' . add_query_arg('dzsp_purchase_remove_binded', 'on', dzs_curr_url()) . '"/><button class="button-secondary" name="action" value="dzsp_purchase_code_disable">' . __("Disable Key") . '</button>'; $form_action = ' action="http://zoomthe.me/updater_dzsp/servezip.php"'; } echo '<form' . $form_action . ' class="mainsettings" method="' . $form_method . '">'; echo ' <div class="setting"> <div class="label">' . __('Purchase Code', 'dzsp') . '</div> ' . DZSHelpers::generate_input_text($lab, array('val' => '', 'seekval' => $this->db_mainoptions[$lab], 'class' => $extra_class, 'extra_attr' => $extra_attr)) . $disable_button . ' <div class="sidenote">' . __('You can <a href="https://lh5.googleusercontent.com/-o4WL83UU4RY/Unpayq3yUvI/AAAAAAAAJ_w/HJmso_FFLNQ/w786-h1179-no/puchase.jpg" target="“_blank”">find it here</a> ', 'dzsp') . '</div> </div>'; if ($this->db_mainoptions['dzsp_purchase_code_binded'] == 'on') { echo '</form><form class="mainsettings" method="post">'; } echo '<p><button class="button-primary" name="action" value="dzsp_update_request">' . __("Update") . '</button></p>'; if (isset($_POST['action']) && $_POST['action'] === 'dzsp_update_request') { // echo 'ceva'; // die(); $aux = 'http://zoomthe.me/updater_dzsp/servezip.php?purchase_code=' . $this->db_mainoptions['dzsp_purchase_code'] . '&site_url=' . site_url(); $res = DZSHelpers::get_contents($aux); // echo 'hmm'; echo strpos($res,'<div class="error">'); echo 'dada'; echo $res; if ($res === false) { echo 'server offline'; } else { if (strpos($res, '<div class="error">') === 0) { echo $res; if (strpos($res, '<div class="error">error: in progress') === 0) { $this->db_mainoptions['dzsp_purchase_code_binded'] = 'on'; update_option($this->dbname_mainoptions, $this->db_mainoptions); } } else { file_put_contents(dirname(__FILE__) . '/update.zip', $res); if (class_exists('ZipArchive')) { $zip = new ZipArchive(); $res = $zip->open(dirname(__FILE__) . '/update.zip'); //test if ($res === TRUE) { // echo 'ok'; $zip->extractTo(dirname(__FILE__)); $zip->close(); $this->db_mainoptions['dzsp_purchase_code_binded'] = 'on'; update_option($this->dbname_mainoptions, $this->db_mainoptions); } else { echo 'failed, code:' . $res; } echo __('Update done.'); } else { echo __('ZipArchive class not found.'); } } } } ?> </form> </div> <?php }