-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcarddbfromxml.php
127 lines (108 loc) · 3.64 KB
/
carddbfromxml.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
include("users.php");
if(isset($_SESSION['username']))
{
if($_SESSION['username'] != $admin)
{
die("You are not authorized to run that command.");
}
}
else
{
die("You must be logged in to run that.");
}
$cardxml = 'carddata.xml';
if(file_exists($cardxml))
{
$carddoc = simplexml_load_file($cardxml);
}
else
{
echo("<p>Unable to open the card data xml at this time.</p>");
exit('Failed to open card data xml');
}
echo("<p>DROPPING CURRENT DATA...</p>");
mysql_query("DELETE FROM lotrtcg_cards_decipher");
echo("...complete.");
echo("<p>BEGIN XML TO SQL CARD DUMP:<p><br>");
$error = false;
foreach($carddoc->card as $ccard)
{
$id = $ccard['id'];
$collinfo = $ccard['collectors_info'];
$title = mysql_real_escape_string($ccard['title']);
$subtitle = mysql_real_escape_string($ccard['subtitle']);
if($subtitle == "")
{
$cardname = $title;
}
else
{
$cardname = "$title, $subtitle";
}
$image = $ccard['image'];
$side = $ccard['side'];
$culture = $ccard['culture'];
$cardtype = $ccard['card_type'];
$twilight = $ccard['twilight'];
$str = $ccard['str'];
$vit = $ccard['vit'];
$res = $ccard['res'];
$signet = $ccard['signet'];
$sitenum = $ccard['site_number'];
$arrowdir = $ccard['arrow_dir'];
$unique = $ccard['unique'];
$set = $ccard['set'];
$rarity = $ccard['rarity'];
$number = $ccard['number'];
$notes = mysql_real_escape_string($ccard['notes']);
$lore = mysql_real_escape_string($ccard['lore']);
$gametext = mysql_real_escape_string($ccard['game_text']);
echo("<p>PROCESSING CARD: $id: $title, $subtitle ($collinfo)...");
echo('<br>');
$sql="INSERT INTO lotrtcg_cards_decipher SET " .
"id=$id, " .
"collectors_info='$collinfo', " .
"card_name='$cardname', " .
"title='$title', " .
"subtitle='$subtitle', " .
"image='$image', " .
"side=$side, " .
"culture=$culture, " .
"card_type=$cardtype, " .
"twilight=$twilight, " .
"strength=$str, " .
"vitality=$vit, " .
"resistance=$res, " .
"signet='$signet', " .
"site_number=$sitenum, " .
"arrow_dir=$arrowdir, " .
"uniqueness=$unique, " .
"set_number=$set, " .
"rarity='$rarity', " .
"number=$number, " .
"notes='$notes', " .
"lore='$lore', " .
"game_text='$gametext';";
if(mysql_query($sql))
{
echo('<p><FONT COLOR="00FF00">...TRANSFER COMPLETE</FONT>');
}
else
{
$error = true;
echo('<p><FONT COLOR="FF0000">ERROR PERFORMING INSERT: </FONT>' .
mysql_error() .'</p>');
echo("id: $id, collinfo: $collinfo, cardname: $cardname, title: $title, subtitle: $subtitle, image: $image, " .
"side: $side, culture: $culture, cardtype: $cardtype twilight: $twilight, str: $str, vit: $vit, res: $res, " .
"signet: $signet, sitenum: $sitenum, arrowdir: $arrowdir, unique: $unique, set: $set, rarity: $rarity, " .
"number: $number, notes: $notes, lore: $lore, gametext: $gametext");
echo('<br>');
echo('<br>');
}
}
if(!$error)
{
header ("Location: ".$_POST['page']);
}
?>