forked from stevoduhhero/YGOSiM-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexportygoprodb.php
More file actions
61 lines (53 loc) · 1.65 KB
/
exportygoprodb.php
File metadata and controls
61 lines (53 loc) · 1.65 KB
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
<?php
//remove limits on: execution time, memory usage
ini_set('max_execution_time', 0);
ini_set('memory_limit', '-1');
//create connection
echo 'var db = {';
$servername = "localhost";
$username = "root";
$password = "";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_select_db($conn, "ygosimhelper");
function dequote($txt) {return str_replace('"', '\\"', $txt);}
function deline($txt) {return str_replace(array("\r\n", "\r", "\n"), "\\n", $txt);}
$result = $conn->query("SELECT * FROM datas");
while($row = $result->fetch_assoc()) {
$id = $row["id"];
$ot = $row["ot"];
$alias = $row["alias"];
$setcode = $row["setcode"];
$type = $row["type"];
$atk = $row["atk"];
$def = $row["def"];
$level = $row["level"];
$race = $row["race"];
$attribute = $row["attribute"];
$category = $row["category"];
//name, description, str1-16
$textRes = $conn->query("SELECT * FROM texts WHERE id='$id' LIMIT 1");
$textData = $textRes->fetch_assoc();
$name = dequote($textData["name"]);
$desc = $textData["description"];
//add strs to desc
$str = "";
$i = 1;
while ($i <= 16) {
$key = "str" . $i;
$i++;
$val = $textData[$key];
if ($val == '' || $val == ' ') continue;
$str = $str . $val . "`";
}
$str = rtrim($str, "`");
$textRes->free_result();
$desc = $desc . "~" . $str;
$desc = dequote(deline($desc));
echo $id . ': ["' . $name . '", "' . $desc . '", ' . $ot . ', ' . $alias . ', ' . $setcode . ', ' . $type . ', ' . $atk . ', ' . $def . ', ' . $level . ', ' . $race . ', ' . $attribute . ', ' . $category . '],';
}
$result->free_result();
echo '};';
?>