function msgQueryLocations($aRequest) { global $gSite; global $gGame; loadGameSettings(); $Out = Out::getInstance(); if (validRaidlead()) { $Connector = Connector::getInstance(); // Locations $ListLocations = $Connector->prepare('Select * FROM `' . RP_TABLE_PREFIX . 'Location` WHERE Game = :Game ORDER BY Name'); $ListLocations->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $Locations = array(); $ListLocations->loop(function ($Data) use(&$Locations) { $LocationData = array('id' => $Data['LocationId'], 'name' => $Data['Name'], 'image' => $Data['Image']); array_push($Locations, $LocationData); }); $Out->pushValue('location', $Locations); // Images $Images = @scandir('../themes/icons/' . $gSite['Iconset'] . '/raidsmall'); $ImageList = array(); if ($Images != null) { foreach ($Images as $Image) { if (strripos($Image, '.png') !== false) { array_push($ImageList, $Image); } } } $Out->pushValue('locationimage', $ImageList); } else { $Out->pushError(L('AccessDenied')); } }
function msgQueryLocale($aRequest) { global $gLocale; global $gGame; loadGameSettings(); $EncodedLocale = array(); $LocaleName = getLocaleName(); $Flags = PHP_VERSION_ID >= 50400 ? ENT_COMPAT | ENT_XHTML : ENT_COMPAT; $Flags = PHP_VERSION_ID >= 50300 ? $Flags | ENT_IGNORE : $Flags; // Hardcoded strings foreach ($gLocale as $Key => $Value) { if ($Value != null) { $Encoded = getUTF8($Value); //htmlentities(getUTF8($Value), $Flags, 'UTF-8'); $EncodedLocale[$Key] = $Encoded; } } // Game based strings if (isset($gGame['Locales'][$LocaleName])) { foreach ($gGame['Locales'][$LocaleName] as $Key => $Value) { if ($Value != null) { $Encoded = getUTF8($Value); //htmlentities(getUTF8($Value), $Flags, 'UTF-8'); $EncodedLocale[$Key] = $Encoded; } } } Out::getInstance()->pushValue('locale', $EncodedLocale); }
function msgQueryNewRaidData($aRequest) { $Out = Out::getInstance(); if (validRaidlead()) { $Connector = Connector::getInstance(); // Settings $NewRaidSettings = $Connector->prepare('SELECT Name, IntValue, TextValue FROM `' . RP_TABLE_PREFIX . 'Setting`'); $IntOfInterest = array('RaidSize', 'RaidStartHour', 'RaidStartMinute', 'RaidEndHour', 'RaidEndMinute', 'StartOfWeek'); $TextOfInterest = array('RaidMode'); $Settings = array(); $NewRaidSettings->loop(function ($Data) use(&$Settings, $IntOfInterest, $TextOfInterest) { $KeyValue = array('name' => $Data['Name'], 'value' => null); if (in_array($Data['Name'], $IntOfInterest)) { $KeyValue['value'] = $Data['IntValue']; } elseif (in_array($Data['Name'], $TextOfInterest)) { $KeyValue['value'] = $Data['TextValue']; } array_push($Settings, $KeyValue); }); $Out->pushValue('setting', $Settings); // Locations msgQueryLocations($aRequest); } else { $Out->pushError(L('AccessDenied')); } }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/config.php'; $DataPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/data'; if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } @(include_once $ConfigPath); if (!defined('EQDKP_INSTALLED')) { $Out->pushError(L('NoValidConfig')); return null; } $Version = 10000; $DataFolder = scandir($DataPath); foreach ($DataFolder as $Candidate) { $LocalConfPath = $DataPath . '/' . $Candidate . '/eqdkp/config/localconf.php'; if (file_exists($LocalConfPath)) { define('EQDKP_INC', 1); @(include_once $LocalConfPath); $VersionParts = explode('.', $localconf['plus_version']); $Version = intval($VersionParts[0]) * 10000 + intval($VersionParts[1]) * 100 + intval($VersionParts[2]); break; } } return array('database' => $dbname, 'user' => $dbuser, 'password' => $dbpass, 'prefix' => $table_prefix, 'cookie' => null, 'version' => $Version); }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/sites'; $BootstrapPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/includes/bootstrap.inc'; if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } @(include_once $BootstrapPath); $Version = 70000; if (defined('VERSION')) { $VersionParts = explode('.', VERSION); $Version = intval($VersionParts[0]) * 10000 + intval($VersionParts[1]) * 100; } $Sites = scandir($ConfigPath); foreach ($Sites as $SiteDir) { if (is_dir($ConfigPath . '/' . $SiteDir) && file_exists($ConfigPath . '/' . $SiteDir . '/settings.php')) { @(include_once $ConfigPath . '/' . $SiteDir . '/settings.php'); if (isset($databases) && isset($databases['default']['default'])) { $DbConfig = $databases['default']['default']; return array('database' => $DbConfig['database'], 'user' => $DbConfig['username'], 'password' => $DbConfig['password'], 'prefix' => $DbConfig['prefix'], 'cookie' => isset($base_url) ? $base_url : 'http://' . $_SERVER['HTTP_HOST'] . '/' . $aRelativePath, 'version' => $Version); } } } $Out->pushError(L('NoValidConfig')); return null; }
public function prepare($aStatement, $aDriverOptions = array()) { $StatementObj = parent::prepare($aStatement, $aDriverOptions); if ($StatementObj === false) { $Out = Out::getInstance(); foreach (parent::errorInfo() as $ErrorLine) { $Out->pushError(strval($ErrorLine)); } $Out->writeJSONandStop(); } return new Query($StatementObj); }
function msgQueryLocalCredentialsById($aRequest) { $Credentials = UserProxy::getInstance()->getUserCredentialsById($aRequest['UserId'], 'none'); $Out = Out::getInstance(); if ($Credentials == null) { $Out->pushError(L('NoSuchUser')); } else { $Out->pushValue('salt', $Credentials['salt']); $Out->pushValue('pubkey', $Credentials['key']); $Out->pushValue('method', $Credentials['method']); } }
function msgQueryConfig($aRequest) { global $gSite; global $gGame; $Out = Out::getInstance(); loadGameSettings(); $Config = array(); $Config['AllowRegistration'] = defined('ALLOW_REGISTRATION') && ALLOW_REGISTRATION; // Push unset($gGame['Locales']); $Out->pushValue('site', array_merge($gSite, $Config)); $Out->pushValue('game', $gGame); }
function api_help($aRequest) { global $gApiHelp; $Out = Out::getInstance(); $Topic = strtolower($aRequest['help']); if (isset($gApiHelp[$Topic])) { foreach ($gApiHelp[$Topic] as $Name => $Value) { $Out->pushValue($Name, $Value); } } else { $Out->pushError('Unknown help topic.'); } }
function msgUserLink($aRequest) { $Out = Out::getInstance(); if (validAdmin()) { $UserInfo = tryGetUserLink($aRequest['userId']); if ($UserInfo != null) { $Out->pushValue('syncActive', !defined('ALLOW_GROUP_SYNC') || ALLOW_GROUP_SYNC); $Out->pushValue('userid', $aRequest['userId']); $Out->pushValue('binding', $UserInfo->BindingName); $Out->pushValue('group', $UserInfo->Group); } } else { $Out->pushError(L('AccessDenied')); } }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/wcf/config.inc.php'; if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } @(include_once $ConfigPath); // Read cookie $Connector = new Connector(SQL_HOST, $dbName, $dbUser, $dbPassword, false); $OptionQuery = $Connector->prepare('SELECT optionValue FROM `wcf' . WCF_N . '_option` ' . 'WHERE optionName = "cookie_prefix" AND categoryName = "general.system.cookie" LIMIT 1'); $OptionData = $OptionQuery->fetchFirst(); // Build result return array('database' => $dbName, 'user' => $dbUser, 'password' => $dbPassword, 'prefix' => WCF_N, 'cookie' => $OptionData['optionValue'], 'version' => 40000); }
function InstallDB($Prefix) { global $gDatabaseLayout; $Out = Out::getInstance(); $Connector = Connector::getInstance(); foreach ($gDatabaseLayout as $Name => $Rows) { $QueryString = "CREATE TABLE IF NOT EXISTS `" . $Prefix . $Name . "` ("; $FirstRow = true; foreach ($Rows as $Row) { $QueryString .= ($FirstRow ? "" : ",") . $Row->CreateText(); $FirstRow = false; } $QueryString .= ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; $Connector->exec($QueryString); } }
function msgUserCreate($aRequest) { require_once dirname(__FILE__) . '/../config/config.php'; $Out = Out::getInstance(); if (ALLOW_REGISTRATION) { $Salt = UserProxy::generateKey32(); $NativeBinding = new NativeBinding(); $HashedPassword = $NativeBinding->hash($aRequest['pass'], $Salt, 'none'); $PublicMode = defined('PUBLIC_MODE') && PUBLIC_MODE; $DefaultGroup = $PublicMode ? 'member' : 'none'; $Out->pushValue('publicmode', $PublicMode); if (!UserProxy::createUser($DefaultGroup, 0, 'none', $aRequest['name'], $HashedPassword, $Salt)) { $Out->pushError(L('NameInUse')); } } else { $Out->pushError(L('AccessDenied')); } }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/wp-config.php'; if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } define('SHORTINIT', true); @(include_once $ConfigPath); if (!isset($table_prefix)) { $Out->pushError(L('NoValidConfig')); return null; } $VersionElements = explode('.', $wp_version); $Version = $VersionElements[0] * 10000 + (isset($VersionElements[1]) ? $VersionElements[1] * 100 : 0) + (isset($VersionElements[2]) ? $VersionElements[2] : 0); return array('database' => DB_NAME, 'user' => DB_USER, 'password' => DB_PASSWORD, 'prefix' => $table_prefix, 'cookie' => LOGGED_IN_KEY . LOGGED_IN_SALT, 'version' => $Version); }
function msgQueryUser($aRequest) { $Out = Out::getInstance(); if (registeredUser()) { $CurrentUser = UserProxy::getInstance(); $CharacterIds = array(); $CharacterGames = array(); $CharacterNames = array(); $CharacterClasses = array(); $CharacterRoles1 = array(); $CharacterRoles2 = array(); $Settings = array(); foreach ($CurrentUser->Characters as $Character) { array_push($CharacterIds, $Character->CharacterId); array_push($CharacterGames, $Character->Game); array_push($CharacterNames, $Character->Name); array_push($CharacterClasses, explode(':', $Character->ClassName)); array_push($CharacterRoles1, $Character->Role1); array_push($CharacterRoles2, $Character->Role2); } $Out->pushValue('registeredUser', true); $Out->pushValue('id', $CurrentUser->UserId); $Out->pushValue('name', $CurrentUser->UserName); $Out->pushValue('characterIds', $CharacterIds); $Out->pushValue('characterGames', $CharacterGames); $Out->pushValue('characterNames', $CharacterNames); $Out->pushValue('characterClass', $CharacterClasses); $Out->pushValue('role1', $CharacterRoles1); $Out->pushValue('role2', $CharacterRoles2); $Out->pushValue('validUser', validUser()); $Out->pushValue('isRaidlead', validRaidlead()); $Out->pushValue('isAdmin', validAdmin()); $Out->pushValue('settings', $CurrentUser->Settings); $Session = Session::get(); if (isset($Session['Calendar'])) { $Out->pushValue('calendar', $Session['Calendar']); } else { $Out->pushValue('calendar', null); } } else { $Out->pushValue('registeredUser', false); } }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $DefaultsPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/conf/config-defaults.php'; $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/conf/config.php'; $IndexPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/index.php'; if (!file_exists($DefaultsPath)) { $Out->pushError($DefaultsPath . ' ' . L('NotExisting') . '.'); return null; } if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } $Version = 20000; if (file_exists($IndexPath)) { $Index = file_get_contents($IndexPath); $AppIdx = strpos($Index, 'APPLICATION_VERSION'); if ($AppIdx !== false) { $StripIdx = strpos($Index, ';', $AppIdx); $Index = substr($Index, 0, $StripIdx + 1); $Index = substr($Index, strpos($Index, '<?php') + 5); eval($Index); $VersionParts = explode('.', APPLICATION_VERSION); $Version = intval($VersionParts[0]) * 10000 + intval($VersionParts[1]) * 100 + intval($VersionParts[2]); } } if (!defined('APPLICATION')) { define('APPLICATION', 'Vanilla'); } define('PATH_CACHE', ''); @(include_once $DefaultsPath); @(include_once $ConfigPath); if (!isset($Configuration)) { $Out->pushError(L('NoValidConfig')); return null; } $CookieConf = $Configuration['Garden']['Cookie']; $DbConf = $Configuration['Database']; return array('database' => $DbConf['Name'], 'user' => $DbConf['User'], 'password' => $DbConf['Password'], 'prefix' => $DbConf['DatabasePrefix'], 'cookie' => $CookieConf['Name'] . ',' . $CookieConf['HashMethod'] . ',' . $CookieConf['Salt'], 'version' => $Version); }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/Configuration.php'; $VersionPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/libraries/cms/version/version.php'; if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } @(include_once $ConfigPath); define('JPATH_PLATFORM', ''); define('_JEXEC', ''); @(include_once $VersionPath); $Version = 30000; if (class_exists("JVersion")) { $VersionClass = new JVersion(); $VersionParts = explode('.', $VersionClass->RELEASE); $Version = intval($VersionParts[0]) * 10000 + intval($VersionParts[1]) * 100 + intval($VersionClass->DEV_LEVEL); } $Config = new JConfig(); return array('database' => $Config->db, 'user' => $Config->user, 'password' => $Config->password, 'prefix' => $Config->dbprefix, 'cookie' => $Config->secret, 'version' => $Version); }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/includes/config.php'; $CorePath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/includes/class_core.php'; if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } @(include_once $ConfigPath); @(include_once $CorePath); if (!isset($config)) { $Out->pushError(L('NoValidConfig')); return null; } $Version = 30000; if (defined('FILE_VERSION')) { $VersionParts = explode('.', FILE_VERSION); $Version = intval($VersionParts[0]) * 10000 + intval($VersionParts[1]) * 100 + intval($VersionParts[2]); } return array('database' => $config['Database']['dbname'], 'user' => $config['MasterServer']['username'], 'password' => $config['MasterServer']['password'], 'prefix' => $config['Database']['tableprefix'], 'cookie' => $config['Misc']['cookieprefix'], 'version' => $Version); }
public function getExternalConfig($aRelativePath) { $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/Settings.php'; if (!file_exists($ConfigPath)) { Out::getInstance()->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } @(include_once $ConfigPath); if (!isset($mbname)) { Out::getInstance()->pushError(L('NoValidConfig')); return null; } $Version = 20000; $Connector = new Connector(SQL_HOST, $db_name, $db_user, $db_passwd, false); if ($Connector != null) { $VersionQuery = $Connector->prepare('SELECT value FROM `' . $db_prefix . 'settings` WHERE variable="smfVersion" LIMIT 1'); $VersionData = $VersionQuery->fetchFirst(); $VersionParts = explode('.', $VersionData['value']); $Version = intval($VersionParts[0]) * 10000 + intval($VersionParts[1]) * 100 + intval($VersionParts[2]); } return array('database' => $db_name, 'user' => $db_user, 'password' => $db_passwd, 'prefix' => $db_prefix, 'cookie' => isset($cookiename) ? $cookiename : 'SMFCookie956', 'version' => $Version); }
function msgCommentupdate($aRequest) { if (validUser()) { $Connector = Connector::getInstance(); $RaidId = intval($aRequest['raidId']); $UserId = UserProxy::getInstance()->UserId; $CheckQuery = $Connector->prepare('SELECT UserId FROM `' . RP_TABLE_PREFIX . 'Attendance` WHERE UserId = :UserId AND RaidId = :RaidId LIMIT 1'); $CheckQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT); $CheckQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT); if ($CheckQuery->execute()) { $UpdateQuery = null; if ($CheckQuery->getAffectedRows() > 0) { $UpdateQuery = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Attendance` ' . 'SET comment = :Comment, LastUpdate = FROM_UNIXTIME(:Timestamp) ' . 'WHERE RaidId = :RaidId AND UserId = :UserId LIMIT 1'); $UpdateQuery->bindValue(':Timestamp', time(), PDO::PARAM_INT); } else { $UpdateQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Attendance` ( CharacterId, UserId, RaidId, Status, Role, Comment ) ' . 'VALUES ( :CharacterId, :UserId, :RaidId, :Status, :Role, :Comment )'); $UpdateQuery->bindValue(':CharacterId', 0, PDO::PARAM_INT); $UpdateQuery->bindValue(':Role', '', PDO::PARAM_STR); $UpdateQuery->bindValue(':Status', 'undecided', PDO::PARAM_STR); } $UpdateQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT); $UpdateQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT); $UpdateQuery->bindValue(':Comment', requestToXML($aRequest['comment'], ENT_COMPAT, 'UTF-8'), PDO::PARAM_STR); $UpdateQuery->execute(); } // reload calendar $RaidQuery = $Connector->prepare('SELECT Start FROM `' . RP_TABLE_PREFIX . 'Raid` WHERE RaidId = :RaidId LIMIT 1'); $RaidQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT); $RaidData = $RaidQuery->fetchFirst(); $Session = Session::get(); $ShowMonth = isset($Session['Calendar']) && isset($Session['Calendar']['month']) ? $Session['Calendar']['month'] : intval(substr($RaidData['Start'], 5, 2)); $ShowYear = isset($Session['Calendar']) && isset($Session['Calendar']['year']) ? $Session['Calendar']['year'] : intval(substr($RaidData['Start'], 0, 4)); msgQueryCalendar(prepareCalRequest($ShowMonth, $ShowYear)); } else { $Out = Out::getInstance(); $Out->pushError(L('AccessDenied')); } }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/inc/config.php'; $CorePath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/inc/class_core.php'; if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } @(include_once $ConfigPath); if (!isset($config)) { $Out->pushError(L('NoValidConfig')); return null; } include_once $CorePath; $Version = 10600; if (class_exists("MyBB")) { $VersionClass = new MyBB(); $VersionParts = explode('.', $VersionClass->version); $Version = intval($VersionParts[0]) * 10000 + intval($VersionParts[1]) * 100 + intval($VersionParts[2]); } return array('database' => $config['database']['database'], 'user' => $config['database']['username'], 'password' => $config['database']['password'], 'prefix' => $config['database']['table_prefix'], 'cookie' => null, 'version' => $Version); }
public function getExternalConfig($aRelativePath) { $Out = Out::getInstance(); $ConfigPath = $_SERVER['DOCUMENT_ROOT'] . '/' . $aRelativePath . '/config.php'; if (!file_exists($ConfigPath)) { $Out->pushError($ConfigPath . ' ' . L('NotExisting') . '.'); return null; } @(include_once $ConfigPath); if (!defined('PHPBB_INSTALLED')) { $Out->pushError(L('NoValidConfig')); return null; } $Version = 30000; $Connector = new Connector(SQL_HOST, $dbname, $dbuser, $dbpasswd, false); if ($Connector != null) { $VersionQuery = $Connector->prepare('SELECT config_value FROM `' . $table_prefix . 'config` WHERE config_name="version" LIMIT 1'); $VersionData = $VersionQuery->fetchFirst(); $VersionParts = explode('.', $VersionData['config_value']); $Version = intval($VersionParts[0]) * 10000 + intval($VersionParts[1]) * 100 + intval($VersionParts[2]); } return array('database' => $dbname, 'user' => $dbuser, 'password' => $dbpasswd, 'prefix' => $table_prefix, 'cookie' => null, 'version' => $Version); }
function msgRaidDelete($aRequest) { if (validRaidlead()) { $Connector = Connector::getInstance(); // Call plugins $RaidId = intval($aRequest['id']); PluginRegistry::ForEachPlugin(function ($PluginInstance) use($RaidId) { $PluginInstance->onRaidRemove($RaidId); }); do { // Delete raid $Connector->beginTransaction(); $DeleteRaidQuery = $Connector->prepare('DELETE FROM `' . RP_TABLE_PREFIX . 'Raid` WHERE RaidId = :RaidId LIMIT 1'); $DeleteRaidQuery->bindValue(':RaidId', $aRequest['id'], PDO::PARAM_INT); if (!$DeleteRaidQuery->execute()) { $Connector->rollBack(); return; // ### return, error ### } // Delete attendance $DeleteAttendanceQuery = $Connector->prepare('DELETE FROM `' . RP_TABLE_PREFIX . 'Attendance` WHERE RaidId = :RaidId'); $DeleteAttendanceQuery->bindValue(':RaidId', $aRequest['id'], PDO::PARAM_INT); if (!$DeleteAttendanceQuery->execute()) { $Connector->rollBack(); return; // ### return, error ### } } while (!$Connector->commit()); $Session = Session::get(); $ShowMonth = isset($Session['Calendar']) && isset($Session['Calendar']['month']) ? $Session['Calendar']['month'] : $aRequest['month']; $ShowYear = isset($Session['Calendar']) && isset($Session['Calendar']['year']) ? $Session['Calendar']['year'] : $aRequest['year']; msgQueryCalendar(prepareCalRequest($ShowMonth, $ShowYear)); } else { $Out = Out::getInstance(); $Out->pushError(L('AccessDenied')); } }
function msgQueryProfile($aRequest) { if (validUser()) { global $gGame; loadGameSettings(); $Out = Out::getInstance(); $UserId = UserProxy::getInstance()->UserId; if (validAdmin() && isset($aRequest['userId']) && $aRequest['userId'] != 0) { $UserId = intval($aRequest['userId']); } $Connector = Connector::getInstance(); $Out->pushValue('show', $aRequest['showPanel']); // Admintool relevant data $Users = $Connector->prepare('SELECT Login, UNIX_TIMESTAMP(Created) AS CreatedUTC, ExternalBinding, BindingActive FROM `' . RP_TABLE_PREFIX . 'User` WHERE UserId = :UserId LIMIT 1'); $Users->bindValue(':UserId', $UserId, PDO::PARAM_INT); $Data = $Users->fetchFirst(); if ($Data != null) { $Out->pushValue('userid', $UserId); $Out->pushValue('name', $Data['Login']); $Out->pushValue('bindingActive', $Data['BindingActive'] == 'true'); $Out->pushValue('binding', $Data['ExternalBinding']); $CreatedUTC = $Data['CreatedUTC']; } // Load settings $SettingsQuery = $Connector->prepare('SELECT * FROM `' . RP_TABLE_PREFIX . 'UserSetting` WHERE UserId = :UserId'); $SettingsQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT); $UserSettings = array(); $SettingsQuery->loop(function ($Data) use(&$UserSettings) { $UserSettings[$Data['Name']] = array('number' => $Data['IntValue'], 'text' => $Data['TextValue']); }); $Out->pushValue('settings', $UserSettings); // Load characters $Characters = array(); if ($UserId == UserProxy::getInstance()->UserId) { foreach (UserProxy::getInstance()->Characters as $Data) { if ($Data->Game == $gGame['GameId']) { $Character = array('id' => $Data->CharacterId, 'name' => $Data->Name, 'classname' => explode(':', $Data->ClassName), 'mainchar' => $Data->IsMainChar, 'role1' => $Data->Role1, 'role2' => $Data->Role2); array_push($Characters, $Character); } } } else { $CharacterQuery = $Connector->prepare('SELECT * FROM `' . RP_TABLE_PREFIX . 'Character` ' . 'WHERE UserId = :UserId AND Game = :Game ' . 'ORDER BY Mainchar, Name'); $CharacterQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT); $CharacterQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $CharacterQuery->loop(function ($Row) use(&$Characters) { $Character = array('id' => $Row['CharacterId'], 'name' => $Row['Name'], 'classname' => explode(':', $Row['Class']), 'mainchar' => $Row['Mainchar'] == 'true', 'role1' => $Row['Role1'], 'role2' => $Row['Role2']); array_push($Characters, $Character); }); } $Out->pushValue('character', $Characters); // Total raid count $NumRaids = 0; $RaidsQuery = $Connector->prepare('SELECT COUNT(RaidId) AS `NumberOfRaids` FROM `' . RP_TABLE_PREFIX . 'Raid` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Location` USING(LocationId) ' . 'WHERE Start > FROM_UNIXTIME(:Created) AND Start < FROM_UNIXTIME(:Now) AND Game = :Game'); $RaidsQuery->bindValue(':Now', time(), PDO::PARAM_INT); $RaidsQuery->bindValue(':Created', $CreatedUTC, PDO::PARAM_STR); $RaidsQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $Data = $RaidsQuery->fetchFirst(); if ($Data != null) { $NumRaids = $Data['NumberOfRaids']; } // Load attendance $AttendanceQuery = $Connector->prepare('Select `Status`, `Role`, COUNT(RaidId) AS `Count` ' . 'FROM `' . RP_TABLE_PREFIX . 'Attendance` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Raid` USING(RaidId) ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Location` USING(LocationId) ' . 'WHERE UserId = :UserId AND Start > FROM_UNIXTIME(:Created) AND Start < FROM_UNIXTIME(:Now) AND Game = :Game ' . 'GROUP BY `Status`, `Role` ORDER BY Status'); $AttendanceQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT); $AttendanceQuery->bindValue(':Created', $CreatedUTC, PDO::PARAM_INT); $AttendanceQuery->bindValue(':Now', time(), PDO::PARAM_INT); $AttendanceQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $AttendanceData = array('raids' => $NumRaids, 'available' => 0, 'unavailable' => 0, 'ok' => 0, 'roles' => array()); // Pull data $AttendanceQuery->loop(function ($Data) use(&$AttendanceData) { if ($Data['Status'] != 'undecided') { $AttendanceData[$Data['Status']] += $Data['Count']; } if ($Data['Status'] == 'ok') { $RoleId = $Data['Role']; if (isset($AttendanceData['roles'][$RoleId])) { $AttendanceData['roles'][$RoleId] += $Data['Count']; } else { $AttendanceData['roles'][$RoleId] = $Data['Count']; } } }); $Out->pushValue('attendance', $AttendanceData); } else { $Out = Out::getInstance(); $Out->pushError(L('AccessDenied')); } }
<?php define('LOCALE_SETUP', true); require_once dirname(__FILE__) . '/locale.php'; require_once dirname(__FILE__) . '/out.class.php'; $Out = Out::getInstance(); header('Content-type: application/json'); function DelTree($aFolder) { $Files = array_diff(scandir($aFolder), array('.', '..')); foreach ($Files as $File) { $FullPath = $aFolder . DIRECTORY_SEPARATOR . $File; $Success = is_dir($FullPath) ? DelTree($FullPath) : @unlink($FullPath); if (!$Success) { return false; } } return @rmdir($aFolder); } if (!DelTree(realpath(dirname(__FILE__) . '/../../setup'))) { $Out->pushError(L('FailedRemoveSetup')); $Out->pushError(error_get_last()['message']); } $Out->flushJSON();
public static function exceptionHandlerXML($aException) { self::exceptionHandler($aException); Out::getInstance()->writeXMLandStop(); return false; }
public function postErrorMessage() { if ($this->OutputHTML) { $this->postHTMLErrorMessage(); } else { $Out = Out::getInstance(); $Out->pushError(L('DatabaseError') . "\n"); $ErrorInfo = $this->PDO->errorInfo(); foreach ($ErrorInfo as $Info) { $Out->pushError(strval($Info) . "\n"); } } }
function parseRaidQuery($aRequest, $aQueryResult, $aLimit) { $Out = Out::getInstance(); $RaidData = array(); $RoleInfo = array(); $NumAttends = array(); $aQueryResult->loop(function ($Data) use(&$RaidData, &$RoleInfo, &$NumAttends) { array_push($RaidData, $Data); $RaidId = $Data['RaidId']; // Create used slot counts if (!isset($RoleInfo[$RaidId])) { $RoleInfo[$RaidId] = array(); } if (!isset($NumAttends[$RaidId])) { $NumAttends[$RaidId] = 0; } // Count used slots if ($Data['Status'] == 'ok' || $Data['Status'] == 'available') { $Role = $Data['Role']; if (!isset($RoleInfo[$RaidId][$Role])) { $RoleInfo[$RaidId][$Role] = 0; } ++$NumAttends[$RaidId]; ++$RoleInfo[$RaidId][$Role]; } }); $LastRaidId = -1; $RaidDataCount = count($RaidData); $NumRaids = 0; $Raids = array(); for ($DataIdx = 0; $DataIdx < $RaidDataCount; ++$DataIdx) { $Data = $RaidData[$DataIdx]; $RaidId = $Data['RaidId']; if ($LastRaidId != $RaidId) { // If no user assigned for this raid // or row belongs to this user // or it's the last entry // or the next entry is a different raid $IsCorrectUser = $Data['UserId'] == UserProxy::getInstance()->UserId; if ($IsCorrectUser || $Data['UserId'] == NULL || $DataIdx + 1 == $RaidDataCount || $RaidData[$DataIdx + 1]['RaidId'] != $RaidId) { $Status = 'notset'; $AttendanceIndex = 0; $Role = ''; $Class = ''; $Comment = ''; if ($IsCorrectUser) { $Status = $Data['Status']; $AttendanceIndex = $Status == 'unavailable' ? -1 : intval($Data['CharacterId']); $Role = $Data['Role']; $Class = $Data['Class']; $Comment = $Data['Comment']; } $StartDate = getdate($Data['StartUTC']); $EndDate = getdate($Data['EndUTC']); $Raid = array('id' => $RaidId, 'location' => $Data['Name'], 'game' => $Data['Game'], 'stage' => $Data['Stage'], 'size' => $Data['Size'], 'startDate' => $StartDate['year'] . '-' . leadingZero10($StartDate['mon']) . '-' . leadingZero10($StartDate['mday']), 'start' => leadingZero10($StartDate['hours']) . ':' . leadingZero10($StartDate['minutes']), 'endDate' => $EndDate['year'] . '-' . leadingZero10($EndDate['mon']) . '-' . leadingZero10($EndDate['mday']), 'end' => leadingZero10($EndDate['hours']) . ':' . leadingZero10($EndDate['minutes']), 'image' => $Data['Image'], 'description' => $Data['Description'], 'status' => $Status, 'attendanceIndex' => $AttendanceIndex, 'comment' => $Comment, 'role' => $Role, 'classId' => $Class, 'slotMax' => array(), 'slotCount' => array(), 'attended' => $NumAttends[$RaidId], 'mode' => $Data['Mode']); $Roles = explode(':', $Data['SlotRoles']); $Count = explode(':', $Data['SlotCount']); for ($i = 0; $i < count($Roles); ++$i) { $RoleId = $Roles[$i]; $Raid['slotMax'][$RoleId] = $Count[$i]; $Raid['slotCount'][$RoleId] = isset($RoleInfo[$RaidId][$RoleId]) ? $RoleInfo[$RaidId][$RoleId] : 0; } array_push($Raids, $Raid); $LastRaidId = $RaidId; ++$NumRaids; if ($aLimit > 0 && $NumRaids == $aLimit) { break; } } } } $Out->pushValue('raid', $Raids); }
function msgQuerySettings($aRequest) { if (validAdmin()) { global $gGame; loadGameSettings(); $Out = Out::getInstance(); $Connector = Connector::getInstance(); // Pass through parameter $Out->pushValue('show', $aRequest['showPanel']); $Out->pushValue('syncActive', !defined('ALLOW_GROUP_SYNC') || ALLOW_GROUP_SYNC); // Load users $UserQuery = $Connector->prepare('SELECT * FROM `' . RP_TABLE_PREFIX . 'User` ORDER BY Login, `Group`'); $Users = array(); $UserQuery->loop(function ($Data) use(&$Users) { $UserData = array('id' => $Data['UserId'], 'login' => xmlentities($Data['Login'], ENT_COMPAT, 'UTF-8'), 'bindingActive' => $Data['BindingActive'], 'binding' => $Data['ExternalBinding'], 'group' => $Data['Group']); array_push($Users, $UserData); }); $Out->pushValue('user', $Users); // Load settings $Settings = Settings::getInstance(); $SettingsJS = array(); Api::getPrivateToken(); foreach ($Settings->getProperties() as $Name => $Data) { array_push($SettingsJS, array('name' => $Name, 'intValue' => isset($Data['IntValue']) ? $Data['IntValue'] : 0, 'textValue' => isset($Data['TextValue']) ? $Data['TextValue'] : '')); } $Out->pushValue('setting', $SettingsJS); // Load games $GameFiles = scandir('../themes/games'); $Games = array(); foreach ($GameFiles as $GameFileName) { try { if (substr($GameFileName, -4) === '.xml') { $Game = @new SimpleXMLElement(file_get_contents('../themes/games/' . $GameFileName)); $SimpleGameFileName = substr($GameFileName, 0, strrpos($GameFileName, '.')); if ($Game->name != '') { $GameName = strval($Game->name); } else { $GameName = str_replace('_', ' ', $SimpleGameFileName); } $Groups = array(); foreach ($Game->groups->group as $Group) { array_push($Groups, intval($Group['count'])); } array_push($Games, array('name' => $GameName, 'family' => strval($Game->family), 'file' => $SimpleGameFileName, 'groups' => $Groups)); } } catch (Exception $e) { $Out->pushError('Error parsing gameconfig ' . $GameFileName . ': ' . $e->getMessage()); } } $Out->pushValue('game', $Games); // Load themes $ThemeFiles = scandir('../themes/themes'); $Themes = array(); foreach ($ThemeFiles as $ThemeFileName) { try { if (substr($ThemeFileName, -4) === '.xml') { $Theme = @new SimpleXMLElement(file_get_contents('../themes/themes/' . $ThemeFileName)); $SimpleThemeFileName = substr($ThemeFileName, 0, strrpos($ThemeFileName, '.')); $Family = isset($Theme->family) ? explode(',', strtolower($Theme->family)) : 'wow'; if ($Theme->name != '') { $ThemeName = strval($Theme->name); } else { $ThemeName = str_replace('_', ' ', $SimpleThemeFileName); } array_push($Themes, array('name' => $ThemeName, 'family' => $Family, 'file' => $SimpleThemeFileName)); } } catch (Exception $e) { $Out->pushError('Error parsing themefile ' . $ThemeFileName . ': ' . $e->getMessage()); } } $Out->pushValue('theme', $Themes); // Query attendance $AttendanceString = 'SELECT ' . '`' . RP_TABLE_PREFIX . 'User`.UserId, ' . '`' . RP_TABLE_PREFIX . 'Character`.Name, ' . '`' . RP_TABLE_PREFIX . 'Attendance`.`Status`, ' . 'UNIX_TIMESTAMP(`' . RP_TABLE_PREFIX . 'User`.Created) AS CreatedUTC, ' . 'COUNT(`' . RP_TABLE_PREFIX . 'Raid`.RaidId) AS Count ' . 'FROM `' . RP_TABLE_PREFIX . 'User` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Attendance` USING(UserId) ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Raid` USING(RaidId) ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Location` USING(LocationId) ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Character` ON `' . RP_TABLE_PREFIX . 'User`.UserId = `' . RP_TABLE_PREFIX . 'Character`.UserId ' . 'WHERE `' . RP_TABLE_PREFIX . 'Character`.Mainchar = "true" ' . 'AND `' . RP_TABLE_PREFIX . 'Raid`.Start > `' . RP_TABLE_PREFIX . 'User`.Created ' . 'AND `' . RP_TABLE_PREFIX . 'Raid`.Start < FROM_UNIXTIME(:Now) ' . 'AND `' . RP_TABLE_PREFIX . 'Location`.Game = :Game ' . 'AND `' . RP_TABLE_PREFIX . 'Character`.Game = :Game ' . 'GROUP BY `' . RP_TABLE_PREFIX . 'User`.UserId, `Status`'; $Attendance = $Connector->prepare($AttendanceString); $Attendance->bindValue(':Now', time(), PDO::PARAM_INT); $Attendance->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $UserId = 0; $NumRaidsRemain = 0; $MainCharName = ''; $StateCounts = array('undecided' => 0, 'available' => 0, 'unavailable' => 0, 'ok' => 0); $Attendances = array(); $Attendance->loop(function ($Data) use(&$gGame, &$Connector, &$UserId, &$NumRaidsRemain, &$MainCharName, &$StateCounts, &$Attendances) { if ($UserId != $Data['UserId']) { if ($UserId > 0) { $AttendanceData = array('id' => $UserId, 'name' => $MainCharName, 'ok' => $StateCounts['ok'], 'available' => $StateCounts['available'], 'unavailable' => $StateCounts['unavailable'], 'undecided' => $StateCounts['undecided'] + $NumRaidsRemain); array_push($Attendances, $AttendanceData); } // Clear cache $StateCounts['ok'] = 0; $StateCounts['available'] = 0; $StateCounts['unavailable'] = 0; $StateCounts['undecided'] = 0; $NumRaidsRemain = 0; $UserId = $Data['UserId']; $MainCharName = $Data['Name']; // Fetch number of attendable raids $Raids = $Connector->prepare('SELECT COUNT(RaidId) AS `NumberOfRaids` ' . 'FROM `' . RP_TABLE_PREFIX . 'Raid` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Location` USING(LocationId) ' . 'WHERE Start > FROM_UNIXTIME(:Created) ' . 'AND Start < FROM_UNIXTIME(:Now) ' . 'AND Game = :Game'); $Raids->bindValue(':Now', time(), PDO::PARAM_INT); $Raids->bindValue(':Created', $Data['CreatedUTC'], PDO::PARAM_INT); $Raids->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $RaidCountData = $Raids->fetchFirst(); $NumRaidsRemain = $RaidCountData == null ? 0 : $RaidCountData['NumberOfRaids']; } $StateCounts[$Data['Status']] += $Data['Count']; $NumRaidsRemain -= $Data['Count']; }); // Push last user if ($UserId != 0) { $AttendanceData = array('id' => $UserId, 'name' => $MainCharName, 'ok' => $StateCounts['ok'], 'available' => $StateCounts['available'], 'unavailable' => $StateCounts['unavailable'], 'undecided' => $StateCounts['undecided'] + $NumRaidsRemain); array_push($Attendances, $AttendanceData); } $Out->pushValue('attendance', $Attendances); // Locations msgQueryLocations($aRequest); } else { $Out = Out::getInstance(); $Out->pushError(L('AccessDenied')); } }
function msgRaidList($aRequest) { if (validUser()) { global $gGame; loadGameSettings(); $Out = Out::getInstance(); $Connector = Connector::getInstance(); // Get next 6 raids $NextRaidQuery = $Connector->prepare('Select ' . RP_TABLE_PREFIX . 'Raid.*, ' . RP_TABLE_PREFIX . 'Location.*, ' . RP_TABLE_PREFIX . 'Attendance.CharacterId, ' . RP_TABLE_PREFIX . 'Attendance.UserId, ' . RP_TABLE_PREFIX . 'Attendance.Status, ' . RP_TABLE_PREFIX . 'Attendance.Class, ' . RP_TABLE_PREFIX . 'Attendance.Role, ' . RP_TABLE_PREFIX . 'Attendance.Comment, ' . 'UNIX_TIMESTAMP(' . RP_TABLE_PREFIX . 'Raid.Start) AS StartUTC, ' . 'UNIX_TIMESTAMP(' . RP_TABLE_PREFIX . 'Raid.End) AS EndUTC ' . 'FROM `' . RP_TABLE_PREFIX . 'Raid` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Location` USING(LocationId) ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Attendance` USING(RaidId) ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Character` USING (CharacterId) ' . 'WHERE ' . RP_TABLE_PREFIX . 'Raid.Start >= FROM_UNIXTIME(:Start) ' . 'AND ' . RP_TABLE_PREFIX . 'Location.Game = :Game ' . 'ORDER BY ' . RP_TABLE_PREFIX . 'Raid.Start, ' . RP_TABLE_PREFIX . 'Raid.RaidId'); $NextRaidQuery->bindValue(':Start', mktime(0, 0, 0), PDO::PARAM_INT); $NextRaidQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); parseRaidQuery($aRequest, $NextRaidQuery, 6); // Load raid history $RaidHistoryQuery = $Connector->prepare('Select ' . RP_TABLE_PREFIX . 'Raid.*, ' . RP_TABLE_PREFIX . 'Location.*, ' . 'UNIX_TIMESTAMP(' . RP_TABLE_PREFIX . 'Raid.Start) AS StartUTC, ' . 'UNIX_TIMESTAMP(' . RP_TABLE_PREFIX . 'Raid.End) AS EndUTC ' . 'FROM `' . RP_TABLE_PREFIX . 'Raid` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Location` USING(LocationId) ' . 'WHERE ' . RP_TABLE_PREFIX . 'Raid.Start < FROM_UNIXTIME(:Start) ' . 'AND ' . RP_TABLE_PREFIX . 'Location.Game = :Game ' . 'ORDER BY Start DESC LIMIT ' . intval($aRequest['offset']) . ', ' . intval($aRequest['count'])); $RaidHistoryQuery->bindValue(':Start', mktime(0, 0, 0), PDO::PARAM_INT); $RaidHistoryQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $RaidList = array(); $RaidHistoryQuery->loop(function ($Data) use(&$RaidList) { $StartDate = getdate($Data['StartUTC']); $EndDate = getdate($Data['EndUTC']); $Raid = array('id' => $Data['RaidId'], 'location' => $Data['Name'], 'stage' => $Data['Stage'], 'image' => $Data['Image'], 'size' => $Data['Size'], 'startDate' => $StartDate['year'] . '-' . leadingZero10($StartDate['mon']) . '-' . leadingZero10($StartDate['mday']), 'start' => leadingZero10($StartDate['hours']) . ':' . leadingZero10($StartDate['minutes']), 'endDate' => $EndDate['year'] . '-' . leadingZero10($EndDate['mon']) . '-' . leadingZero10($EndDate['mday']), 'end' => leadingZero10($EndDate['hours']) . ':' . leadingZero10($EndDate['minutes'])); array_push($RaidList, $Raid); }); $Out->pushValue('history', $RaidList); } else { $Out = Out::getInstance(); $Out->pushError(L('AccessDenied')); } }