get_value('doujin_json_'.$gid)) { json_die("success", $Cache->get_value('doujin_json_'.$gid)); } else { $data = json_encode(["method" => "gdata", "gidlist" => [[$gid, $token]], "namespace" => 1]); $curl = curl_init('http://e-hentai.org/api.php'); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Content-Length: '.strlen($data)]); $json = curl_exec($curl); if (empty($json)) { json_die("failure", "Could not get page"); } $json = json_decode($json, true)["gmetadata"][0]; $artists = array(); $tags = array(); $lang = NULL; $circle = NULL; $censored = true; foreach ($json["tags"] as $tag) { if (strpos($tag, ':') !== false) { list($namespace, $tag) = explode(':', $tag); } else { $namespace = ''; } if ($namespace == "artist") { array_push($artists, ucwords($tag)); } else if ($namespace == "language") { $lang = empty($lang) ? ucfirst($tag) : $lang; } else if ($namespace == "group") { $circle = empty($circle) ? ucfirst($tag) : $circle; } else if ($tag == "uncensored") { $censored = false; } else { if ($namespace) { $tag = $tag.':'.$namespace; } array_push($tags, str_replace(' ', '.', $tag)); } } // get the cover for ants $cover = $json['thumb']; // and let's see if we can replace it with something better $gallery_page = file_get_contents($url); $re = '/'.preg_quote('-0px 0 no-repeat">01 $gid, 'title' => html_entity_decode($json['title'], ENT_QUOTES), 'title_jp' => html_entity_decode($json['title_jpn'], ENT_QUOTES), 'artists' => $artists, 'circle' => $circle, 'censored' => $censored, 'year' => NULL, 'tags' => $tags, 'lang' => $lang, 'pages' => $json['filecount'], 'description' => '', 'cover' => $cover ); $Cache->cache_value('doujin_json_'.$gid, $json_str, 86400); json_die("success", $json_str); } ?>