Skip to content

Commit

Permalink
Modern AAC Rev 267
Browse files Browse the repository at this point in the history
  • Loading branch information
avuenja committed Jan 4, 2014
1 parent 8dc040c commit 198f393
Show file tree
Hide file tree
Showing 2,025 changed files with 136,119 additions and 0 deletions.
2 changes: 2 additions & 0 deletions API/apiVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo '1.0';
37 changes: 37 additions & 0 deletions API/createAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
require("system/system.php");
require("../config.php");
auth();
require("../system/application/libraries/POT/OTS.php");

/* Status types */
define('OK', 0);
define('MISSING_VAR', 1);
define('ACCOUNTNAME_TAKEN', 2);
define('UNKNOWN', 3);

/* Variable is missing? */
if(!isset($_GET['accountName']) || !isset($_GET['password']) || !isset($_GET['email'])) {
die(json_encode(array('status'=>MISSING_VAR)));
}

$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, array('host' => HOSTNAME, 'user' => USERNAME, 'database' => DATABASE, 'password' => PASSWORD));
$account = new OTS_Account();
$account->find($_GET['accountName']);

/* Account name taken? */
if($account->isLoaded()) {
die(json_encode(array('status'=>ACCOUNTNAME_TAKEN)));
}
$name = $account->createNamed($_GET['accountName']);
$account->setPassword(sha1($_GET['password']));
$account->setEmail($_GET['email']);
$account->setCustomField('premdays', PREMDAYS);
try {
$account->save();
}
catch(Exception $e) {
die(json_encode(array('status'=>UNKNOWN, 'message'=>$e->getMessage())));
}
die(json_encode(array('status'=>OK, 'id'=>$account->getId())));
7 changes: 7 additions & 0 deletions API/getAccountCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
require("system/system.php");
auth();
$db = new database();
$return = array();
$sql = $db->query("SELECT count(1) FROM `accounts` WHERE name != '1'")->fetch_array();
echo $sql[0];
10 changes: 10 additions & 0 deletions API/getBans.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require("system/system.php");
auth();
$db = new database();
$return = array();
$sql = $db->query("SELECT `type`, `value`, `param`, `expires`, `added`, `comment`, `reason`, `action`, `statement` FROM `bans` WHERE `active` = '1'");
while($cmd = $sql->fetch_array()) {
$return[] = $cmd;
}
echo json_encode($return);
7 changes: 7 additions & 0 deletions API/getBansCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
require("system/system.php");
auth();
$db = new database();
$return = array();
$sql = $db->query("SELECT count(1) FROM `bans`")->fetch_array();
echo $sql[0];
9 changes: 9 additions & 0 deletions API/getCities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
require("system/system.php");
require("../config.php");
auth();
$cities = array();
foreach($config['cities'] as $id=>$name) {
$cities[$id] = $name;
}
echo json_encode($cities);
7 changes: 7 additions & 0 deletions API/getGuildsCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
require("system/system.php");
auth();
$db = new database();
$return = array();
$sql = $db->query("SELECT count(1) FROM `guilds`")->fetch_array();
echo $sql[0];
64 changes: 64 additions & 0 deletions API/getHighscore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
require('../config.php');
require("system/system.php");
auth();
$db = new database();
$return = array();

$world = (isset($_GET['world'])?$_GET['world']:0);
$skill = (isset($_GET['skill'])?$_GET['skill']:0);
$config['newchar_vocations'][$world][] = 'Account Manager';
$filter = "'".join("','", $config['newchar_vocations'][$world])."'";
switch(@$skill) {
case 1:
$sql = $db->query('SELECT name,online,level,experience,vocation,promotion, world_id FROM players WHERE players.world_id LIKE "'.$world.'" AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND name NOT IN('.$filter.') ORDER BY level DESC, experience DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Experience";
break;
case 2:
$sql = $db->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world.' AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = 0 AND name NOT IN('.$filter.') ORDER BY value DESC, count DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Fist Fighting";
break;
case 3:
$sql = $db->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world.' AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = 1 AND name NOT IN('.$filter.') ORDER BY value DESC, count DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Club Fighting";
break;
case 4:
$sql = $db->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world.' AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = 2 AND name NOT IN('.$filter.') ORDER BY value DESC, count DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Sword Fighting";
break;
case 5:
$sql = $db->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world.' AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = 3 AND name NOT IN('.$filter.') ORDER BY value DESC, count DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Axe Fighting";
break;
case 6:
$sql = $db->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world.' AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = 4 AND name NOT IN('.$filter.') ORDER BY value DESC, count DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Distance Fighting";
break;
case 7:
$sql = $db->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world.' AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = 5 AND name NOT IN('.$filter.') ORDER BY value DESC, count DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Shielding";
break;
case 8:
$sql = $db->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world.' AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = 6 AND name NOT IN('.$filter.') ORDER BY value DESC, count DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Fishing";
break;
case 9:
$sql = $db->query('SELECT name,online,maglevel,level,vocation,promotion FROM players WHERE players.world_id = '.$world.' AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND name NOT IN('.$filter.') ORDER BY maglevel DESC, manaspent DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Magic level";
break;
default:
$sql = $db->query('SELECT name,online,level,experience,vocation,promotion, world_id FROM players WHERE players.world_id LIKE "'.$world.'" AND players.deleted = 0 AND players.group_id < '.$config['players_group_id_block'].' AND name NOT IN('.$filter.') ORDER BY level DESC, experience DESC LIMIT 50');
while($cmd = $sql->fetch_array()){ $return['players'][] = $cmd; }
$return['type'] = "Experience";
break;
}
echo json_encode($return);
7 changes: 7 additions & 0 deletions API/getHousesCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
require("system/system.php");
auth();
$db = new database();
$return = array();
$sql = $db->query("SELECT count(1) FROM `houses`")->fetch_array();
echo $sql[0];
10 changes: 10 additions & 0 deletions API/getPlayersCount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require('../config.php');
require("system/system.php");
auth();
$db = new database();
$return = array();
$config['newchar_vocations'][0][] = 'Account Manager';
$filter = "'".join("','", $config['newchar_vocations'][0])."'";
$sql = $db->query("SELECT count(1) FROM `players` WHERE name NOT IN ({$filter})")->fetch_array();
echo $sql[0];
10 changes: 10 additions & 0 deletions API/getPlayersOnline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require("system/system.php");
auth();
$db = new database();
$return = array();
$sql = $db->query("SELECT `name`, `level`, `world_id`, `sex`, `vocation` FROM `players` WHERE `online` = '1'");
while($cmd = $sql->fetch_array()) {
$return[] = $cmd;
}
echo json_encode($return);
7 changes: 7 additions & 0 deletions API/getPlayersOnlineAmount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
require("system/system.php");
auth();
$db = new database();
$return = array();
$sql = $db->query("SELECT count(1) FROM `players` WHERE `online` = '1'")->fetch_array();
echo $sql[0];
5 changes: 5 additions & 0 deletions API/getServerName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
require("system/system.php");
require("../config.php");
auth();
echo $config['server_name'];
9 changes: 9 additions & 0 deletions API/getVocations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
require("system/system.php");
require("../config.php");
auth();
$server_vocations = array();
foreach($config['server_vocations'] as $id=>$name) {
$server_vocations[$id] = $name;
}
echo json_encode($server_vocations);
9 changes: 9 additions & 0 deletions API/getWorlds.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
require("system/system.php");
require("../config.php");
auth();
$worlds = array();
foreach($config['worlds'] as $id=>$name) {
$worlds[$id] = $name;
}
echo json_encode($worlds);
1 change: 1 addition & 0 deletions API/isValid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
13 changes: 13 additions & 0 deletions API/system/database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
require("../config.php");
/*Database class for Modern AAC API.*/
class database extends mysqli {
private $status;
public function __construct() {
global $config;
parent::__construct($config['database']['host'],$config['database']['login'],$config['database']['password'],$config['database']['database']);
$this->status = 1;
}
}

?>
11 changes: 11 additions & 0 deletions API/system/system.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
require("system/trusted_list.php");
require("system/database.php");

function auth() {
global $allowed;
if(!in_array($_SERVER['REMOTE_ADDR'], $allowed)) {
exit("This server could not authenticate your request.");
}
else return true;
}
11 changes: 11 additions & 0 deletions API/system/trusted_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/*This list includes allowed server that can request data from API.*/
$allowed = array();
$allowed[] = "127.0.0.1"; // Local server

/* Official servers, these are 100% safe and should not be removed (might lose functionality if you do) */
$allowed[] = gethostbyname("vapus.net"); // VAPus
$allowed[] = "188.40.136.66"; // Old New VAPus
$allowed[] = "188.40.110.66"; // Old VAPus IP (used for the fallback server)
$allowed[] = "188.40.38.144"; // Fallback server for the updater (Might request call to isValid etc)
$allowed[] = "88.208.252.193"; // ModernAAC API Server
5 changes: 5 additions & 0 deletions commands/commands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$commands['/help'] = array('access'=>5, 'path'=>'help/command.php', 'help'=>'help/help.php');

?>
10 changes: 10 additions & 0 deletions commands/scripts/help/command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require("commands/commands.php");

echo "This is example command!";

echo "<br/>The list of arguments passed to it:<pre>";
var_dump($args);
echo "</pre>";

?>
1 change: 1 addition & 0 deletions commands/scripts/help/help.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Help File!
Loading

0 comments on commit 198f393

Please sign in to comment.