-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·62 lines (62 loc) · 2.64 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<head>
<title>Curator</title>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="styles.css">
<link rel="apple-touch-icon" href="img/logo.jpg">
</head>
<body>
<center>
<br>
<div class="card shadow">
<span style="font-size: 25px;">Using </span><span style="font-size: 35px;">Curator</span><span style="font-size: 25px;"> is easy!</span>
<ul>
<li>Copy the link to your token.</li><br>
<li>Paste it into the text box below.</li><br>
<li>Tap the 3D model you want to generate.</li><br>
<li>Aim your iPhone at a flat surface (like a table or the floor) and let the camera stabilize.</li>
</ul>
</div>
<br>
<form method="post" action="">
<input type="text" name="opensea_url" id="opensea_url" placeholder="OpenSea token URL:">
<br>
<br>
<button type="submit" name="model" id="model" value="easel">
<img class="thumbnail_image" src="img/thumbnail_easel.png">
<div>Easel</div>
</button>
<button type="submit" name="model" id="model" value="picture_frame">
<img class="thumbnail_image" src="img/thumbnail_picture_frame.png">
<div>Picture frame</div>
</button>
<button type="submit" name="model" id="model" value="">
<img class="thumbnail_image" src="img/thumbnail_placeholder.png">
<div>Treasure chest</div>
</button>
<button type="submit" name="model" id="model" value="wood_block">
<img class="thumbnail_image" src="img/thumbnail_wood_block.png">
<div>Wooden block</div>
</button>
</form>
</center>
<?php
$stripped_chars=array("#", "&", "<", ">", ";", "*", " ", "'", "\"", "\$");
if (!empty($_POST["model"]) && !empty($_POST["opensea_url"])){
$model=str_replace($stripped_chars, "", $_POST["model"]);
$opensea_url=str_replace($stripped_chars, "", $_POST["opensea_url"]);
$url_components=explode("/", $opensea_url);
$token_id=$url_components[count($url_components)-1];
$contract_address=$url_components[count($url_components)-2];
$opensea_api_url="https://api.opensea.io/api/v1/asset/$contract_address/$token_id/?format=json";
$user_agent=$_SERVER["HTTP_USER_AGENT"]??null;
ini_set("user_agent", $user_agent);
$metadata=json_decode(file_get_contents($opensea_api_url), true);
$image_uri=$metadata["image_url"];
shell_exec("cd /var/www/html/ && bash curator.sh $model $image_uri");
echo "<script type='text/javascript'>window.location = 'models/$model/exports/".base64_encode($image_uri).".usdz'</script>";
}
?>
</body>
</html>