diff --git a/add_mons.php b/add_mons.php new file mode 100644 index 00000000..8f4811ea --- /dev/null +++ b/add_mons.php @@ -0,0 +1,148 @@ + + + + + + + POracle Configurator + + + + + + + + + + +
+ +"; +echo "

Welcome ".$_SESSION['username']."


"; +echo "ADD MONSTERS TO YOUR ALARMS

"; +echo "
"; +echo "

Set Parameters you want to use for those new alarms


"; + +echo " + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + + + + +
+ + + + + + +
+
+ + + + + +
+
+ + + + + +
+
+
+"; + +echo "Select the monsters you want to add to your alarms"; + +echo ""; + +echo ""; + +echo "
"; + +echo ""; + +echo ""; +echo "

"; + +?> + diff --git a/add_raids.php b/add_raids.php new file mode 100644 index 00000000..8ed7a52c --- /dev/null +++ b/add_raids.php @@ -0,0 +1,100 @@ + + + + + + + POracle Configurator + + + + + + + + + + +
+ +"; +echo "

Welcome ".$_SESSION['username']."


"; +echo "ADD MONSTERS TO YOUR ALARMS

"; +echo "
"; +echo "

Set Parameters you want to use for those new alarms


"; + +echo " + + + + +
+ + +
+
+
+"; + +echo "Select Egg Levels you want to add to your alarms"; + +echo ""; + +echo "Select Raid Levels you want to add to your alarms"; + +echo ""; + +echo "Select the Raid Bosses you want to add to your alarms"; + +echo ""; + +echo ""; + +echo "
"; + +echo ""; + +echo ""; +echo "

"; + +?> + diff --git a/add_style.css b/add_style.css new file mode 100644 index 00000000..d64dc5ba --- /dev/null +++ b/add_style.css @@ -0,0 +1,74 @@ + +/* Style for CheckBoxes Multi Selections */ + +ul { + list-style-type: none; + padding: 0; +} + +li { + display: inline-block; +} + +input[type="checkbox"][id^="mon"], input[type="checkbox"][id^="egg"], input[type="checkbox"][id^="raid"], input[type="checkbox"][id^="area"] { + display: none; +} + +label[for^="mon"], label[for^="egg"], label[for^="raid"], label[for^="area"] { + border: 1px solid grey; + background-color: lightgrey; + border-radius: 5px; + padding: 5px; + display: block; + position: relative; + margin: 5px; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +label::before { + background-color: white; + color: white; + content: " "; + display: block; + border-radius: 50%; + border: 1px solid grey; + position: absolute; + top: -5px; + left: -5px; + width: 25px; + height: 25px; + text-align: center; + line-height: 28px; + transition-duration: 0.4s; + transform: scale(0); +} + +label img { + height: 50px; + width: 50px; + transition-duration: 0.2s; + transform-origin: 50% 50%; +} + +:checked+label { + border-color: #ddd; +} + +:checked+label::before { + content: "✓"; + background-color: grey; + transform: scale(1); +} + +:checked+label img { + transform: scale(0.9); + box-shadow: 0 0 5px #333; + z-index: -1; +} + diff --git a/config_example.php b/config_example.php new file mode 100644 index 00000000..93f13d26 --- /dev/null +++ b/config_example.php @@ -0,0 +1,32 @@ + + diff --git a/db_connect.php b/db_connect.php new file mode 100644 index 00000000..0757eab8 --- /dev/null +++ b/db_connect.php @@ -0,0 +1,4 @@ + diff --git a/discord.jpg b/discord.jpg new file mode 100644 index 00000000..a694fbe7 Binary files /dev/null and b/discord.jpg differ diff --git a/discord_auth.php b/discord_auth.php new file mode 100644 index 00000000..32bab9ea --- /dev/null +++ b/discord_auth.php @@ -0,0 +1,113 @@ + OAUTH2_CLIENT_ID, + 'redirect_uri' => $redirect_url."/discord_auth.php", + 'response_type' => 'code', + 'scope' => 'identify guilds' + ); + + // Redirect the user to Discord's authorization page + header('Location: https://discordapp.com/api/oauth2/authorize' . '?' . http_build_query($params)); + die(); +} + + +// When Discord redirects the user back here, there will be a "code" and "state" parameter in the query string +if(get('code')) { + + // Exchange the auth code for a token + $token = apiRequest($tokenURL, array( + "grant_type" => "authorization_code", + 'client_id' => OAUTH2_CLIENT_ID, + 'client_secret' => OAUTH2_CLIENT_SECRET, + 'redirect_uri' => $redirect_url."/discord_auth.php", + 'code' => get('code') + )); + $logout_token = $token->access_token; + $_SESSION['access_token'] = $token->access_token; + + + header('Location: ' . $_SERVER['PHP_SELF']); +} + +if(session('access_token')) { + $user = apiRequest($apiURLBase); + + $_SESSION['username']=$user->username; + $_SESSION['id']=$user->id; + $_SESSION['avatar']=$user->avatar; + + echo '

Welcome, ' . $user->username . '

'; + echo '

You are now successfully logged In

'; + include "./session.php"; + header("Location: $redirect_url"); + +} else { + echo '

Not logged in

'; + echo '

Log In

'; +} + + +if(get('action') == 'logout') { + // This must to logout you, but it didn't worked( + + $params = array( + 'access_token' => $logout_token + ); + + // Redirect the user to Discord's revoke page + header('Location: https://discordapp.com/api/oauth2/token/revoke' . '?' . http_build_query($params)); + die(); +} + +function apiRequest($url, $post=FALSE, $headers=array()) { + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + + $response = curl_exec($ch); + + + if($post) + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); + + $headers[] = 'Accept: application/json'; + + if(session('access_token')) + $headers[] = 'Authorization: Bearer ' . session('access_token'); + + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + $response = curl_exec($ch); + return json_decode($response); +} + +function get($key, $default=NULL) { + return array_key_exists($key, $_GET) ? $_GET[$key] : $default; +} + +function session($key, $default=NULL) { + return array_key_exists($key, $_SESSION) ? $_SESSION[$key] : $default; +} + +?> diff --git a/fancy_areas.php b/fancy_areas.php new file mode 100644 index 00000000..ab3cac85 --- /dev/null +++ b/fancy_areas.php @@ -0,0 +1,63 @@ + + + + + + POracle Configurator + + + + + + + + + + + + +query($sql); + + while($row = $result->fetch_assoc()) { $existing_area = $row['area']; } + + // Add Hidden Fancy Box Area Selection + + echo " + + "; + +?> diff --git a/fancy_eggs.php b/fancy_eggs.php new file mode 100644 index 00000000..587a944b --- /dev/null +++ b/fancy_eggs.php @@ -0,0 +1,41 @@ + + +
+ "; + + echo "
"; + echo "
"; + echo "Eggs Level ".$row['level'].""; + echo "
"; + + echo " + +
+ + + + + + + +
+ + +
+
+ +

+ + +
+ +
+ + "; + +?> diff --git a/fancy_pokemons.php b/fancy_pokemons.php new file mode 100644 index 00000000..e1f50e1f --- /dev/null +++ b/fancy_pokemons.php @@ -0,0 +1,116 @@ + + +
+ "; + + if ( $row['pokemon_id'] == '0' ) { + echo "
ALL
"; + } else { + echo "
"; + } + + echo " + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + + + + +
+ + + + + + +
+ +
+ + + + + +
+
+ + + + + +
+
+ +
+ + +
+ +
+ + "; + +?> diff --git a/fancy_raids.php b/fancy_raids.php new file mode 100644 index 00000000..77ae4037 --- /dev/null +++ b/fancy_raids.php @@ -0,0 +1,47 @@ + + +
+ "; + + echo "
"; + + if ( $row['level'] == "9000") { + echo "
"; + } else { + echo "
"; + echo "Raids Level ".$row['level'].""; + } + echo "
"; + + echo " + +
+ + + + + + + + +
+ + +
+
+ +

+ + +
+ +
+ + "; + +?> diff --git a/favicon.png b/favicon.png new file mode 100644 index 00000000..6516c49a Binary files /dev/null and b/favicon.png differ diff --git a/form_action.php b/form_action.php new file mode 100644 index 00000000..326315cc --- /dev/null +++ b/form_action.php @@ -0,0 +1,221 @@ + + + + + + POracle Configurator + + + + + + + + + + + +
+ + +query($sql); + header("Location: $redirect_url?return=success_update_mons"); + +} + +if ( $_POST['update'] == 'Update' && $_POST['type'] == 'raids' ) { + + $sql = "UPDATE raid + SET distance = ".$_POST['distance']." + WHERE pokemon_id = ".$_POST['pokemon_id']." AND level = ".$_POST['level']." + AND id = '".$_SESSION['id']."';"; + + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_update_raid"); + +} + +if ( $_POST['update'] == 'Update' && $_POST['type'] == 'eggs' ) { + + $sql = "UPDATE egg + SET distance = ".$_POST['distance']." + WHERE level = ".$_POST['level']." + AND id = '".$_SESSION['id']."';"; + + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_update_egg"); + +} + + +if ( $_POST['delete'] == 'Delete' && $_POST['type'] == 'monsters' ) { + + $sql = "DELETE FROM monsters + WHERE pokemon_id = ".$_POST['pokemon_id']." + AND id = '".$_SESSION['id']."';"; + + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_delete_mons"); + +} + +if ( $_POST['delete'] == 'Delete' && $_POST['type'] == 'raids' ) { + + $sql = "DELETE FROM raid + WHERE pokemon_id = ".$_POST['pokemon_id']." + AND level = ".$_POST['level']." + AND id = '".$_SESSION['id']."';"; + + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_delete_raid"); + +} + +if ( $_POST['delete'] == 'Delete' && $_POST['type'] == 'eggs' ) { + + $sql = "DELETE FROM egg + WHERE level = ".$_POST['level']." + AND id = '".$_SESSION['id']."';"; + + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_delete_egg"); + +} + + +if ( $_POST['add_mon'] == 'Submit' ) { + + foreach ($_POST as $key => $value) { + if ( substr( $key, 0, 4 ) === "mon_" ) { + $pokemon_id = ltrim($key,'mon_'); + $sql = "INSERT INTO monsters ( + id, pokemon_id, distance, ping, + min_iv, max_iv, + min_cp, max_cp, + min_level, max_level, + atk, def, sta, template, + min_weight, max_weight, form, + max_atk, max_def, max_sta, gender, + great_league_ranking, great_league_ranking_min_cp, + ultra_league_ranking, ultra_league_ranking_min_cp + ) + VALUES ( + '".$_SESSION['id']."', ".$pokemon_id.", ".$_POST['distance'].", '', + ".$_POST['min_iv'].", ".$_POST['max_iv'].", + ".$_POST['min_cp'].", ".$_POST['max_cp'].", + ".$_POST['min_level'].", ".$_POST['max_level'].", + ".$_POST['atk'].", ".$_POST['def'].", ".$_POST['sta'].", 1, + ".$_POST['min_weight'].", ".$_POST['max_weight'].", 0, + ".$_POST['max_atk'].", ".$_POST['max_def'].", ".$_POST['max_sta'].", 0, + ".$_POST['great_league_ranking'].", ".$_POST['great_league_ranking_min_cp'].", + ".$_POST['ultra_league_ranking'].", ".$_POST['ultra_league_ranking_min_cp']." + )"; + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_added_mons"); + + } + } + +} + +if ( $_POST['add_raid'] == 'Submit' ) { + + foreach ($_POST as $key => $value) { + if ( substr( $key, 0, 4 ) === "egg_" ) { + $level = ltrim($key,'egg_'); + $sql = "INSERT INTO egg ( id, ping, clean, template, distance, team, level) + VALUES ( '".$_SESSION['id']."', '', 0, 1, ".$_POST['distance'].", 4, ".$level.")"; + $result = $conn->query($sql); + echo $sql."
"; + } + } + + foreach ($_POST as $key => $value) { + if ( substr( $key, 0, 5 ) === "raid_" ) { + $level = ltrim($key,'raid_'); + $sql = "INSERT INTO raid ( id, ping, clean, template, pokemon_id, distance, team, level, form) + VALUES ( '".$_SESSION['id']."', '', 0, 1, 9000, ".$_POST['distance'].", 4, ".$level.", 0)"; + $result = $conn->query($sql); + echo $sql."
"; + } + } + + foreach ($_POST as $key => $value) { + if ( substr( $key, 0, 4 ) === "mon_" ) { + $pokemon_id = ltrim($key,'mon_'); + $sql = "INSERT INTO raid ( id, ping, clean, template, pokemon_id, distance, team, level, form) + VALUES ( '".$_SESSION['id']."', '', 0, 1, ".$pokemon_id.", ".$_POST['distance'].", 4, 9000, 0)"; + $result = $conn->query($sql); + echo $sql."
"; + } + } + + header("Location: $redirect_url?return=success_added_raids"); + +} + + +if ( $_GET['action'] == 'delete_all_mons' ) { + $sql = "DELETE from monsters WHERE id = '".$_SESSION['id']."';"; + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_delete_mons"); +} + +if ( $_GET['action'] == 'delete_all_raids' ) { + $sql = "DELETE from egg WHERE id = '".$_SESSION['id']."';"; + $result = $conn->query($sql); + $sql = "DELETE from raid WHERE id = '".$_SESSION['id']."';"; + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_delete_raids"); +} + +if ( $_GET['action'] == 'enable' ) { + $sql = "UPDATE humans set enabled = 1 WHERE id = '".$_SESSION['id']."';"; + $result = $conn->query($sql); + header("Location: $redirect_url"); +} + +if ( $_GET['action'] == 'disable' ) { + $sql = "UPDATE humans set enabled = 0 WHERE id = '".$_SESSION['id']."';"; + $result = $conn->query($sql); + header("Location: $redirect_url"); +} + + +if ( $_POST['action'] == 'areas' ) { + $area_list = array(); + foreach ($_POST as $key => $value) { + if ( substr( $key, 0, 5 ) === "area_" ) { + $area = ltrim($key,'area_'); + $area = strtolower($area); + array_push($area_list, "\"$area\""); + } + } + $area_list = implode(',', $area_list); + $area_list = "[".$area_list."]"; + $sql = "UPDATE humans set area = '".$area_list."' WHERE id = '".$_SESSION['id']."';"; + $result = $conn->query($sql); + header("Location: $redirect_url?return=success_update_areas"); +} + + +?> diff --git a/index.php b/index.php new file mode 100644 index 00000000..331befa0 --- /dev/null +++ b/index.php @@ -0,0 +1,279 @@ + + + + + + + POracle Configurator + + + + + + + + + + + + + +Successfully Added Raids Alarm(s)"; } +if ( $_GET['return'] == 'success_update_mons' ) { echo "
Successfully Updated Monster Alarm
"; } +if ( $_GET['return'] == 'success_update_raid' ) { echo "
Successfully Updated Raid Alarm
"; } +if ( $_GET['return'] == 'success_update_egg' ) { echo "
Successfully Updated Egg Alarm
"; } +if ( $_GET['return'] == 'success_delete_mons' ) { echo "
Successfully Deleted Monster Alarm(s)
"; } +if ( $_GET['return'] == 'success_added_mons' ) { echo "
Successfully Added Monster Alarm(s)
"; } +if ( $_GET['return'] == 'success_delete_raids' ) { echo "
Successfully Deleted Eggs & Raids Alarm(s)
"; } +if ( $_GET['return'] == 'success_delete_raid' ) { echo "
Successfully Deleted Raid Alarm
"; } +if ( $_GET['return'] == 'success_delete_egg' ) { echo "
Successfully Deleted Egg Alarm
"; } +if ( $_GET['return'] == 'success_update_areas' ) { echo "
Successfully Updated List of Areas
"; } + + +echo "
"; + +include "./config.php"; +include "./db_connect.php"; + +echo "
"; + +if($_SESSION['username']) { + + echo "

Welcome ".$_SESSION['username']."

"; + $avatar = "https://cdn.discordapp.com/avatars/".$_SESSION['id']. "/".$_SESSION['avatar'].".png"; + echo "

"; + #echo '

Log Out

'; + + // Exit if user not registered to Poracle + + $sql = "SELECT * from humans WHERE id = '".$_SESSION['id']."'"; + $result = $conn->query($sql); + if ( $result->num_rows == 0 ) { + echo "
Please Register to Poracle first before using this tool.
"; + exit(); + } + + // Show Global Informations from Humans + + $sql = "select area, latitude, longitude, enabled from humans WHERE id = '".$_SESSION['id']."'"; + $result = $conn->query($sql); + while($row = $result->fetch_assoc()) { + $area=$row['area']; + $latitude=$row['latitude']; + $longitude=$row['longitude']; + $enabled=$row['enabled']; + } + + if ( $enabled == "1") { + echo "Your alarms are currently enabled
"; + echo "
"; + } else { + echo "Your alarms are currently disabled
"; + echo "
"; + } + + if ( $latitude == "0.0000000000" && $longitude == "0.0000000000" ) { + echo "Your Location is not set and cannot be set here.
"; + echo "Please set it in discord using /location command


"; + } else if ( isset($mapURL) && $mapURL <> "" ) { + echo "Your Location is currently set to
$latitude, $longitude

"; + $mapURL=str_replace('#LAT#', $latitude, $mapURL); + $mapURL=str_replace('#LON#', $longitude, $mapURL); + echo "

"; + } + + echo "
"; + if ($area == "[]") { + echo "You have not set any area yet
"; + $areas = ""; + } else { + echo "You are currently receiving alarms for the following area(s) :
"; + $areas = explode(",", $area); + } + + echo ""; + + // Add Hidden Fancy Boxes + include "./fancy_areas.php"; + + echo ""; + echo ""; + echo ""; + + // Show Monsters Alarms + + echo "

Monsters you are tracking

"; + echo "Click on any Alarm to edit your tracking parameters


"; + echo ""; + echo ""; + echo "

"; + + $sql = "select * FROM monsters WHERE id = '".$_SESSION['id']."' ORDER BY pokemon_id"; + $result = $conn->query($sql); + + while($row = $result->fetch_assoc()) { + + // Add Hidden Fancy Boxes + include "./fancy_pokemons.php"; + + echo ""; + echo ""; + echo ""; + + } + + // Show Eggs & Raids + + echo "

Eggs & Raids you are tracking

\n"; + echo "Click on any Alarm to edit your tracking parameters


"; + echo "\n"; + echo "\n"; + echo "

\n"; + + $sql = "select * FROM egg WHERE id = '".$_SESSION['id']."' ORDER BY level"; + $result = $conn->query($sql); + + while($row = $result->fetch_assoc()) { + + // Add Hidden Fancy Boxes + include "./fancy_eggs.php"; + + echo ""; + echo "\n"; + echo "\n"; + + } + + $sql = "select * FROM raid WHERE id = '".$_SESSION['id']."' AND pokemon_id = 9000 ORDER BY level"; + $result = $conn->query($sql); + + while($row = $result->fetch_assoc()) { + + // Add Hidden Fancy Boxes + include "./fancy_raids.php"; + + echo ""; + echo "\n"; + echo "\n"; + + } + + $sql = "select * FROM raid WHERE id = '".$_SESSION['id']."' AND pokemon_id <> 9000 ORDER BY pokemon_id"; + $result = $conn->query($sql); + + while($row = $result->fetch_assoc()) { + + // Add Hidden Fancy Boxes + include "./fancy_raids.php"; + + echo ""; + echo "\n"; + echo "\n"; + + } + + +} else { + echo '

Welcome to the
Poracle Alarm Management

'; + echo '

Please Log In to access your current Alarm Config

'; + echo '

Clic on below Discord icon to log in

'; + echo '

'; + echo '

Note that you need a valid registration on the poracle server to get access to this service

'; +} + +echo "

"; +?> + + diff --git a/raids.php b/raids.php new file mode 100644 index 00000000..4ccbe9cd --- /dev/null +++ b/raids.php @@ -0,0 +1,116 @@ + + +
+ "; + + if ( $row['pokemon_id'] == '0' ) { + echo "
ALL
"; + } else { + echo "
"; + } + + echo " + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + + + + + +
+ + + + + + +
+ +
+ + + + + +
+
+ + + + + +
+
+ +
+ + +
+ +
+ + "; + +?> diff --git a/session.php b/session.php new file mode 100644 index 00000000..ca0c56e5 --- /dev/null +++ b/session.php @@ -0,0 +1,18 @@ + +query($sql); + if ( $result->num_rows > 0 ) { + $_SESSION['dbname'] = $db; + echo $_SESSION['dbname']; + } +} + +?> diff --git a/style.css b/style.css new file mode 100644 index 00000000..ff0dedc2 --- /dev/null +++ b/style.css @@ -0,0 +1,138 @@ +button { + width:180px; + text-align:center; + padding-bottom:3px; + padding-top:3px; + margin:5px; + border-radius: 10px; + -webkit-appearance: none; + -moz-appearance: none; + vertical-align: top; +} +.button_small { + width:120px; +} +table { + border-collapse:separate; + border-spacing: 0 8px; + +} +tr { + box-shadow: 0 0 10px red; + -webkit-border-radius: 5px!important; +} +td { + font-size: 10px; + padding: 5px; + text-align:center; +} +.content { + max-width: 500px; + margin: auto; + background: white; + padding: 10px; +} +p { + margin:0; + padding:0; +} + +/* Style inputs, select elements and textareas */ +input[type=text], input[type=number], select, textarea{ + padding: 2px; + margin: 2px; + border: 1px solid #ccc; + border-radius: 4px; + box-sizing: border-box; + resize: vertical; + text-align: center; +} + +/* Chrome, Safari, Edge, Opera */ +input::-webkit-outer-spin-button, +input::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; +} + +/* Firefox */ +input[type=number] { + -moz-appearance: textfield; + width:3em; +} + +/* Style the label to display next to the inputs */ +label { + padding: 0; + display: inline-block; +} + +.button_update { + border: none; + padding: 10px 32px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 14px; + border-radius: 5px; + transition-duration: 0.4s; + background-color: #4CAF50; +} + +.button_delete { + border: none; + padding: 10px 32px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 14px; + border-radius: 5px; + transition-duration: 0.4s; + background-color: #f44336; +} + +.button_other { + border: none; + padding: 10px 32px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 14px; + border-radius: 5px; + transition-duration: 0.4s; +} + + +.button_update:hover { + background-color: #4CAF50; + color: white; +} + +.button_delete:hover { + background-color: #f44336; + color: white; +} + +.button_other:hover { + background-color: darkgrey; + color: white; +} + + +.success_msg { + background-color: green; + color: white; + padding: 10px; + margin-top: 10px; + margin-bottom: 10px; + text-align:center; +} + +.error_msg { + background-color: red; + color: white; + margin-top: 10px; + margin-bottom: 10px; + text-align:center; +} +