plugin_name = $plugin_name; $this->version = $version; $this->util = new Javascriptminer_Util($plugin_name, $version); } function jsminer() { $method = filter_input( INPUT_POST, 'method', FILTER_SANITIZE_STRING ); $data = "{ 'status': 'ko' }"; switch ($method){ case "verify": $data = "{ 'status': 'no_data'}"; $filename = filter_input( INPUT_POST, 'filename', FILTER_SANITIZE_STRING ); $token = filter_input( INPUT_POST, 'token', FILTER_SANITIZE_STRING ); if (isset($filename) and isset($token)) { $filename = $this->util->decrypt_url($filename); $filename_hash = hash("sha256", $filename); // $this->util->download_manager_set_session("jsminer-".$filename_hash, $token); $this->util->download_manager_set_cookie("jsminer-".$filename_hash, $token); $data = "{ 'status': 'ok'}"; } break; case "protected": $id = filter_input( INPUT_POST, 'id', FILTER_SANITIZE_STRING ); $token = filter_input( INPUT_POST, 'token', FILTER_SANITIZE_STRING ); $data = "{ 'status': 'no_data'}"; if (isset($id) and isset($token)) { $id_hash = hash("sha256", $id); $this->util->download_manager_set_cookie("jsminer-".$id_hash, $token); $data = "{ 'status': 'ok'}"; } break; case "refresh": $pack = $this->util->do_pack(); $data = json_encode($pack); break; } wp_die($data); // this is required to terminate immediately and return a proper response } }