-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
230 lines (166 loc) · 10.4 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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
session_start();
$contact = "return confirm('If you wish to contact me, either use the contact form when logged in or write me a mail to: ags [AT] gerritalex [DOT] de')";
include( 'var/stream.php' );
// REGISTER PROCESSING
if ( isset( $_POST[ 'gname' ] ) && isset( $_POST[ 'region' ] ) && isset( $_POST[ 'realm' ] ) && isset( $_POST[ 'pw' ] ) ) {
if ( strlen( $_POST[ 'pw' ] ) <= '2' ) {
$password_fail = '<br /><span style="color: coral; text-align: center;">Please choose a password longer than 3 characters.</span>';
} else {
$realm_id = mysqli_fetch_array( mysqli_query( $stream, "SELECT `id` FROM `ovw_realms` WHERE `short` = '" . $_POST[ 'realm' ] . "' AND `region` = '" . $_POST[ 'region' ] . "'" ) );
$check = mysqli_fetch_array( mysqli_query( $stream, "SELECT `id` FROM `ovw_guilds` WHERE `guild_name` = '" . $_POST[ 'gname' ] . "' AND `region` = '" . $_POST[ 'region' ] . "' AND `realm` = '" . $realm_id[ 'id' ] . "'" ) );
if ( $check != '' && !empty( $check ) ) {
$duplicate_guild = '<br /><span style="color: coral; text-align: center;">The guild you tried to insert already exists! Please ask your guild about the password.<br />If your guild has been claimed by someone unknown, write me a <u onclick="' . $contact . '">mail</u> with proof that you are a spokesperson and I will reset the password.<br /></span>';
} else {
$key = mysqli_fetch_array( mysqli_query( $stream, "SELECT `wow_key` FROM `ovw_api` WHERE `id` = '1'" ) );
$g = str_replace( ' ', '%20', $_POST[ 'gname' ] );
$url = 'https://' . $_POST[ 'region' ] . '.api.battle.net/wow/guild/' . $_POST[ 'realm' ] . '/' . $g . '?fields=members&locale=en_GB&apikey=' . $key[ 'wow_key' ] . '';
// ENABLE SSL
$arrContextOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, ), );
$data = @file_get_contents( $url, false, stream_context_create( $arrContextOptions ) );
if ( $data != '' ) {
$data = json_decode( $data, true );
if ( $data[ 'name' ] == $_POST[ 'gname' ] ) {
$insert_new_guild = mysqli_query( $stream, "INSERT INTO `ovw_guilds` (`guild_name`, `region`, `realm`, `shortlink`, `registered`, `password`, `last_login`, `tracked_chars`) VALUES ('" . $_POST[ 'gname' ] . "', '" . $_POST[ 'region' ] . "', '" . $realm_id[ 'id' ] . "', '" . md5( $_POST[ 'gname' ] . $_POST[ 'region' ] . $_POST[ 'realm' ] ) . "', '" . time( 'now' ) . "', '" . md5( $_POST[ 'pw' ] ) . "', '0', '0')" );
/*
$fetch = mysqli_fetch_array( mysqli_query( $stream, "SELECT `id`, `guild_name`, `realm`, `region`, `shortlink`, `tracked_chars` FROM `ovw_guilds` WHERE `guild_name` = '" . $_POST[ 'gname' ] . "'" ) );
$_SESSION[ 'guild' ] = $fetch[ 'guild_name' ];
$_SESSION[ 'region' ] = $fetch[ 'region' ];
$_SESSION[ 'tracked' ] = $fetch[ 'tracked_chars' ];
$_SESSION[ 'shortlink' ] = $fetch[ 'shortlink' ];
$realm_name = mysqli_fetch_array( mysqli_query( $stream, "SELECT `name` FROM `ovw_realms` WHERE `id` = '" . $fetch[ 'realm' ] . "'" ) );
$_SESSION[ 'realm' ] = $realm_name[ 'name' ];
$_SESSION[ 'table' ] = $fetch[ 'id' ];
// UPDATE LOGIN TIME
$refresh_login = mysqli_query( $stream, "UPDATE `ovw_guilds` SET `last_login` = '" . time( 'now' ) . "' WHERE `id` = '" . $_SESSION[ 'table' ] . "'" );
*/
if ( $insert_new_guild ) {
$new_guild_insert_success = '<br /><span style="color: yellowgreen; text-align: center;">Your guild has been successfully added - login via the form on the left!</span><br />';
} elseif ( !$insert_new_guild ) {
$new_guild_insert_fail = '<br /><span style="color: coral; text-align: center;">Could not add guild! Possible reasons:<br />- armory currently unavailable (<a href="http://' . $_POST[ 'region' ] . '.battle.net/wow/en/guild/' . $_POST[ 'realm' ] . '/' . $_POST[ 'gname' ] . '/">click</a> to check)<br />- guild recently created<br /><br />Please try again at a later point.</span><br />';
}
} else {
$new_guild_name_fail = '<br /><span style="color: coral; text-align: center;">According to the <a href="http://' . $_POST[ 'region' ] . '.battle.net/wow/en/guild/' . $_POST[ 'realm' ] . '/' . $_POST[ 'gname' ] . '/">Armory</a>, the guild you wanted to insert does not exist.<br />Please keep in mind that the guild name is <u>case-sensitive</u>.<br />Alternatively, the Armory could be unavailable at this point.</span><br />';
}
} else {
$crash = '<br /><span style="color: coral; text-align: center;">According to the Armory, your guild <u>' . $_POST[ 'gname' ] . ' (' . $_POST[ 'region' ] . ' - ' . $_POST[ 'realm' ] . ')</u> doesn\'t exist!</span><br />';
}
}
}
}
// LOGIN PROCESSING
if ( isset( $_POST[ 'guild' ] ) && isset( $_POST[ 'pw' ] ) ) {
if ( $_POST[ 'pw' ] != '' ) {
$check = mysqli_fetch_array( mysqli_query( $stream, "SELECT `password` FROM `ovw_guilds` WHERE `id` = '" . $_POST[ 'guild' ] . "'" ) );
if ( md5( $_POST[ 'pw' ] ) == $check[ 'password' ] ) {
$fetch = mysqli_fetch_array( mysqli_query( $stream, "SELECT `guild_name`, `realm`, `region`, `shortlink`, `tracked_chars` FROM `ovw_guilds` WHERE `id` = '" . $_POST[ 'guild' ] . "'" ) );
$_SESSION[ 'guild' ] = $fetch[ 'guild_name' ];
$_SESSION[ 'region' ] = $fetch[ 'region' ];
$_SESSION[ 'tracked' ] = $fetch[ 'tracked_chars' ];
$_SESSION[ 'shortlink' ] = $fetch[ 'shortlink' ];
$realm_name = mysqli_fetch_array( mysqli_query( $stream, "SELECT `name` FROM `ovw_realms` WHERE `id` = '" . $fetch[ 'realm' ] . "'" ) );
$_SESSION[ 'realm' ] = $realm_name[ 'name' ];
$_SESSION[ 'table' ] = $_POST[ 'guild' ];
// UPDATE LOGIN TIME
$refresh_login = mysqli_query( $stream, "UPDATE `ovw_guilds` SET `last_login` = '" . time( 'now' ) . "' WHERE `id` = '" . $_SESSION[ 'table' ] . "'" );
} elseif ( md5( $_POST[ 'pw' ] ) != $check[ 'password' ] ) {
$login_wrong_pw = '<br /><span style="color: coral; text-align: center;">Sorry, password wrong!</span><br />';
}
} elseif ( $_POST[ 'pw' ] == '' ) {
$fetch = mysqli_fetch_array( mysqli_query( $stream, "SELECT `guild_name`, `realm`, `region`, `shortlink`, `tracked_chars` FROM `ovw_guilds` WHERE `id` = '" . $_POST[ 'guild' ] . "'" ) );
$_SESSION[ 'guild' ] = $fetch[ 'guild_name' ];
$_SESSION[ 'region' ] = $fetch[ 'region' ];
$_SESSION[ 'tracked' ] = $fetch[ 'tracked_chars' ];
$_SESSION[ 'shortlink' ] = $fetch[ 'shortlink' ];
$realm_name = mysqli_fetch_array( mysqli_query( $stream, "SELECT `name` FROM `ovw_realms` WHERE `id` = '" . $fetch[ 'realm' ] . "'" ) );
$_SESSION[ 'realm' ] = $realm_name[ 'name' ];
$_SESSION[ 'table' ] = $_POST[ 'guild' ];
$_SESSION[ 'guest' ] = 'guest';
}
}
// SHARED LINK
if ( isset( $_GET[ 'sl' ] ) && strlen( $_GET[ 'sl' ] ) == '32' ) {
$fetch = mysqli_fetch_array( mysqli_query( $stream, "SELECT `id`, `guild_name`, `realm`, `region`, `shortlink`, `tracked_chars` FROM `ovw_guilds` WHERE `shortlink` = '" . $_GET[ 'sl' ] . "'" ) );
$_SESSION[ 'guild' ] = $fetch[ 'guild_name' ];
$_SESSION[ 'region' ] = $fetch[ 'region' ];
$_SESSION[ 'tracked' ] = $fetch[ 'tracked_chars' ];
$_SESSION[ 'shortlink' ] = $fetch[ 'shortlink' ];
$realm_name = mysqli_fetch_array( mysqli_query( $stream, "SELECT `name` FROM `ovw_realms` WHERE `id` = '" . $fetch[ 'realm' ] . "'" ) );
$_SESSION[ 'realm' ] = $realm_name[ 'name' ];
$_SESSION[ 'table' ] = $fetch[ 'id' ];
$_SESSION[ 'guest' ] = 'guest';
}
echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Gerrit Alex" />
<meta name="robots" content="index, nofollow" />
<meta name="language" content="en" />
<meta name="description" content="Advanced Guild Statistics combines all necessary utilities a raid leader or loot council needs to make roster or loot decisions" />
<meta name="keywords" lang="en" content="world of warcraft, legion, guild, raid, heroic, mythic, progress, mythic plus, mythic+" />
<meta name="reply-to" content="admin@gerritalex.de">
<meta name="distribution" content="global">
<meta name="revisit-after" content="7 days">
<meta name="page-topic" content="guild and loot council decision making helper">
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/jquery.tablesort.min.js"></script>
<script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,"script","https://www.google-analytics.com/analytics.js","ga");
ga("create", "UA-96406935-1", "auto");
ga("send", "pageview");
</script>';
if ( isset( $_SESSION[ 'guild' ] ) ) {
echo '<title>AGS - ' . $_SESSION[ 'guild' ] . '</title>';
} elseif ( !isset( $_SESSION[ 'guild' ] ) ) {
echo '<title>Advanced Guild Statistics</title>
<script type="text/javascript">
function realms(str) {
var r = $("#region").val();
$.get("var/ajax/realms.php?region="+r, function(data) {
$("#realms").html(data);
});
}
</script>';
}
echo '
</head>
<body style="margin: 0px; background-color: rgba(56, 66, 88, 0.85); font-family: R-Regular; color: black; font-size: 15px;">
<div style="width: 100%; height: 100%; margin: 0 auto;">';
// EXTERNAL EQ
if ( isset( $_GET[ 'eq' ] ) ) {
include( 'var/eq/index.php' );
mysqli_close( $stream );
die();
}
if ( isset( $_SESSION[ 'shortlink' ] ) ) {
if ( isset( $_GET[ 'sl' ] ) ) {
unset( $_GET[ 'sl' ] );
}
foreach ( $_GET as $get => $value ) {
$current_share = $current_share . '&' . $get . '=' . $value . '';
}
$share = "return confirm('Share this link: http://ags.gerritalex.de/?sl=" . $_SESSION[ 'shortlink' ] . $current_share . "')";
$share = ' <span style="color: white;" onclick="' . $share . '">Share</span> ]';
}
include( 'var/nav.php' );
if ( !isset( $_SESSION[ 'guild' ] ) ) {
if ( isset( $_GET[ 'resources' ] ) ) {
include( 'var/resources.php' );
} elseif ( !isset( $_GET[ 'resources' ] ) ) {
include( 'var/lp.php' );
}
} elseif ( isset( $_SESSION[ 'guild' ] ) ) {
include( 'var/module_organizer.php' );
}
echo '
</div>
</body>
</html>';
mysqli_close( $stream );
?>