public static function initBindings() { $NativeBinding = new NativeBinding(); self::$Bindings = array($NativeBinding); self::$BindingsByName[$NativeBinding->getName()] = $NativeBinding; PluginRegistry::ForEachBinding(function ($PluginInstance) { UserProxy::registerInstance($PluginInstance); }); }
<?php header("Content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; echo "<bindings>"; define("LOCALE_SETUP", true); require_once "../../lib/private/connector.class.php"; require_once "../../lib/private/userproxy.class.php"; PluginRegistry::ForEachBinding(function ($PluginInstance) { $Binding = $PluginInstance->getName(); $Version = intval($_REQUEST[$Binding . "_ver_major"]) * 10000 + intval($_REQUEST[$Binding . "_ver_minor"]) * 100 + intval($_REQUEST[$Binding . "_ver_patch"]); $PluginInstance->writeConfig($_REQUEST[$Binding . "_allow"] == "true", $_REQUEST[$Binding . "_database"], $_REQUEST[$Binding . "_prefix"], $_REQUEST[$Binding . "_user"], $_REQUEST[$Binding . "_password"], $_REQUEST[$Binding . "_autologin"] == "true", $_REQUEST[$Binding . "_postto"], $_REQUEST[$Binding . "_postas"], $_REQUEST[$Binding . "_member"], $_REQUEST[$Binding . "_raidlead"], $_REQUEST[$Binding . "_cookie"], $Version); }); echo "</bindings>";
function msgRaidCreate($aRequest) { if (validRaidlead()) { global $gGame; loadGameSettings(); $Connector = Connector::getInstance(); $LocationId = $aRequest['locationId']; // Create location if ($LocationId == 0) { $NewLocationQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Location`' . '(Game, Name, Image) VALUES (:Game, :Name, :Image)'); $NewLocationQuery->bindValue(':Name', requestToXML($aRequest['locationName'], ENT_COMPAT, 'UTF-8'), PDO::PARAM_STR); $NewLocationQuery->bindValue(':Image', $aRequest['raidImage'], PDO::PARAM_STR); $NewLocationQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); if (!$NewLocationQuery->execute()) { return; } // ### return, location could not be created ### $LocationId = $Connector->lastInsertId(); } // Create raid if ($LocationId != 0) { // First raid time calculation $StartHour = intval($aRequest['startHour']); $StartMinute = intval($aRequest['startMinute']); $StartDay = intval($aRequest['startDay']); $StartMonth = intval($aRequest['startMonth']); $StartYear = intval($aRequest['startYear']); $EndHour = intval($aRequest['endHour']); $EndMinute = intval($aRequest['endMinute']); $EndDay = intval($aRequest['endDay']); $EndMonth = intval($aRequest['endMonth']); $EndYear = intval($aRequest['endYear']); // Get users on vacation $UserSettingsQuery = $Connector->prepare('SELECT UserId, Name, IntValue, TextValue FROM `' . RP_TABLE_PREFIX . 'UserSetting` ' . 'WHERE Name = "VacationStart" OR Name = "VacationEnd" OR Name = "VacationMessage" ORDER BY UserId'); $VactionUsers = array(); $UserSettingsQuery->loop(function ($Settings) use(&$VactionUsers) { if (!isset($VactionUsers[$Settings['UserId']])) { $VactionUsers[$Settings['UserId']] = array('Message' => ''); } switch ($Settings['Name']) { case 'VacationStart': $VactionUsers[$Settings['UserId']]['Start'] = $Settings['IntValue']; break; case 'VacationEnd': $VactionUsers[$Settings['UserId']]['End'] = $Settings['IntValue']; break; case 'VacationMessage': $VactionUsers[$Settings['UserId']]['Message'] = $Settings['TextValue']; break; default: break; } }); // Prepare posting raids to forum $PostTargets = array(); PluginRegistry::ForEachBinding(function ($PluginInstance) use(&$PostTargets) { if ($PluginInstance->isActive() && $PluginInstance->postRequested()) { array_push($PostTargets, $PluginInstance); } }); $LocationData = null; if (count($PostTargets) > 0) { loadSiteSettings(); $LocationQuery = $Connector->prepare('SELECT * FROM `' . RP_TABLE_PREFIX . 'Location` WHERE LocationId = :LocationId LIMIT 1'); $LocationQuery->bindValue(':LocationId', $LocationId, PDO::PARAM_INT); $LocationData = $LocationQuery->fetchFirst(); } // Get opt-out list or auto attend users $AutoAttendUsers = array(); if (strtolower($aRequest['mode'] == 'optout')) { $UserQuery = $Connector->prepare('SELECT UserId, CharacterId, Class, Role1 FROM `' . RP_TABLE_PREFIX . 'User` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Character` USING(UserId) ' . 'WHERE Mainchar="true" AND Game=:Game'); $UserQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $UserQuery->loop(function ($aUser) use(&$AutoAttendUsers) { array_push($AutoAttendUsers, $aUser); }); } else { $UserQuery = $Connector->prepare('SELECT UserId, CharacterId, Class, Role1 FROM `' . RP_TABLE_PREFIX . 'UserSetting` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Character` USING(UserId) ' . 'WHERE `' . RP_TABLE_PREFIX . 'UserSetting`.Name="AutoAttend" AND Mainchar="true" AND Game=:Game'); $UserQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR); $UserQuery->loop(function ($aUser) use(&$AutoAttendUsers) { array_push($AutoAttendUsers, $aUser); }); } // Create raids(s) $Repeat = max(0, intval($aRequest['repeat'])) + 1; // repeat at least once $GroupInfo = $gGame['Groups'][$aRequest['locationSize']]; $SlotRoles = implode(':', array_keys($GroupInfo)); $SlotCount = implode(':', $GroupInfo); $RaidMode = $aRequest['mode'] == 'optout' ? 'manual' : $aRequest['mode']; for ($rc = 0; $rc < $Repeat; ++$rc) { $NewRaidQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Raid` ' . '(LocationId, Size, Start, End, Mode, Description, SlotRoles, SlotCount ) ' . 'VALUES (:LocationId, :Size, FROM_UNIXTIME(:Start), FROM_UNIXTIME(:End), :Mode, :Description, ' . ':SlotRoles, :SlotCount)'); $StartDateTime = mktime($StartHour, $StartMinute, 0, $StartMonth, $StartDay, $StartYear); $EndDateTime = mktime($EndHour, $EndMinute, 0, $EndMonth, $EndDay, $EndYear); // Convert to UTC $StartDateTime += $aRequest['startOffset'] * 60; $EndDateTime += $aRequest['endOffset'] * 60; $NewRaidQuery->bindValue(':LocationId', $LocationId, PDO::PARAM_INT); $NewRaidQuery->bindValue(':Size', $aRequest['locationSize'], PDO::PARAM_INT); $NewRaidQuery->bindValue(':Start', $StartDateTime, PDO::PARAM_INT); $NewRaidQuery->bindValue(':End', $EndDateTime, PDO::PARAM_INT); $NewRaidQuery->bindValue(':Mode', $RaidMode, PDO::PARAM_STR); $NewRaidQuery->bindValue(':Description', requestToXML($aRequest['description'], ENT_COMPAT, 'UTF-8'), PDO::PARAM_STR); $NewRaidQuery->bindValue(':SlotRoles', $SlotRoles, PDO::PARAM_STR); $NewRaidQuery->bindValue(':SlotCount', $SlotCount, PDO::PARAM_STR); $NewRaidQuery->execute(); $RaidId = $Connector->lastInsertId(); // Attend players when mode is optout if (count($AutoAttendUsers > 0)) { $Status = $RaidMode == 'all' || $RaidMode == 'attend' ? 'ok' : 'available'; foreach ($AutoAttendUsers as $User) { $UserId = intval($User['UserId']); if (isset($VactionUsers[$UserId]) && ($StartDateTime >= $VactionUsers[$UserId]['Start'] && $StartDateTime <= $VactionUsers[$UserId]['End'])) { continue; // ### continue, user is on vacation ### } $Classes = explode(':', $User['Class']); $ClassId = $Classes[0]; $RoleId = $gGame['ClassMode'] == 'multi' ? $gGame['Classes'][$ClassId]['roles'][0] : $User['Role1']; $AttendQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Attendance` (UserId, RaidId, CharacterId, Class, Role, Status) ' . 'VALUES (:UserId, :RaidId, :CharId, :Class, :Role, :Status)'); $AttendQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT); $AttendQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT); $AttendQuery->bindValue(':CharId', $User['CharacterId'], PDO::PARAM_INT); $AttendQuery->bindValue(':Class', $ClassId, PDO::PARAM_STR); $AttendQuery->bindValue(':Role', $RoleId, PDO::PARAM_STR); $AttendQuery->bindValue(':Status', $Status, PDO::PARAM_STR); $AttendQuery->execute(); } if ($RaidMode == 'attend') { removeOverbooked($RaidId, $SlotRoles, $SlotCount); } } // Set vacation attendances foreach ($VactionUsers as $UserId => $Settings) { if ($StartDateTime >= $Settings['Start'] && $StartDateTime <= $Settings['End']) { $AbsentQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Attendance` (UserId, RaidId, Status, Comment) ' . 'VALUES (:UserId, :RaidId, "unavailable", :Message)'); $AbsentQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT); $AbsentQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT); $AbsentQuery->bindValue(':Message', $Settings['Message'], PDO::PARAM_STR); $AbsentQuery->execute(); } } // Post raids to forum if (count($PostTargets) > 0) { $RaidQuery = $Connector->prepare('SELECT * FROM `' . RP_TABLE_PREFIX . 'Raid` WHERE RaidId=:RaidId LIMIT 1'); $RaidQuery->bindValue(':RaidId', $RaidId, PDO::PARAM_INT); $RaidData = $RaidQuery->fetchFirst(); $MessageData = Binding::generateMessage($RaidData, $LocationData); try { foreach ($PostTargets as $PluginInstance) { $PluginInstance->post($MessageData['subject'], $MessageData['message']); } } catch (PDOException $Exception) { Out::getInstance()->pushError($Exception->getMessage()); } } // Call plugins PluginRegistry::ForEachPlugin(function ($PluginInstance) use($RaidId) { $PluginInstance->onRaidCreate($RaidId); }); // Increment start/end switch ($aRequest['stride']) { case 'day': ++$StartDay; ++$EndDay; break; case 'week': $StartDay += 7; $EndDay += 7; break; case 'month': ++$StartMonth; ++$EndMonth; break; default: case 'once': $rc = $Repeat; // Force done break; } } // reload calendar $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')); } }
} else { if ($_REQUEST["user"] == "") { $Out->pushError(L($LocalePrefix . "UserEmpty")); } else { if ($_REQUEST["password"] == "") { $Out->pushError(L($LocalePrefix . "PasswordEmpty")); } else { PluginRegistry::ForEachBinding(function ($PluginInstance) use($BindingName, $Out) { if ($PluginInstance->getName() == $BindingName) { $Config = $PluginInstance->getConfig(); try { if ($Config->HasGroupConfig) { $Groups = $PluginInstance->getGroups($_REQUEST["database"], $_REQUEST["prefix"], $_REQUEST["user"], $_REQUEST["password"], true); $Out->pushValue("groups", $Groups); } if ($Config->HasForumConfig) { $Forums = $PluginInstance->getForums($_REQUEST["database"], $_REQUEST["prefix"], $_REQUEST["user"], $_REQUEST["password"], true); $Out->pushValue("forums", $Forums); $Users = $PluginInstance->getUsers($_REQUEST["database"], $_REQUEST["prefix"], $_REQUEST["user"], $_REQUEST["password"], true); $Out->pushValue("users", $Users); } } catch (PDOException $Exception) { $Out->pushError($Exception->getMessage()); } return false; } }); } } } $Out->flushJSON();
<?php define("LOCALE_SETUP", true); require_once dirname(__FILE__) . "/../lib/private/locale.php"; require_once dirname(__FILE__) . "/../lib/config/config.php"; require_once dirname(__FILE__) . "/../lib/private/userproxy.class.php"; // Load bindings $gBindings = array(); PluginRegistry::ForEachBinding(function ($PluginInstance) use(&$gBindings) { array_push($gBindings, $PluginInstance); }); readfile("layout/header.html"); ?> <?php if (isset($_REQUEST["single"])) { ?> <script type="text/javascript"> $(document).ready( function() { $(".button_back").click( function() { open("index.php"); }); $(".button_next").click( function() { CheckBindingForm("index.php"); }); }); </script> <?php } else { ?> <script type="text/javascript"> $(document).ready( function() { $(".button_back").click( function() { open("install_password.php"); }); $(".button_next").click( function() { CheckBindingForm("install_done.php"); }); });
<?php header("Content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; define("LOCALE_SETUP", true); require_once dirname(__FILE__) . "/../../lib/config/config.php"; require_once "../../lib/private/connector.class.php"; require_once "../../lib/private/userproxy.class.php"; $Out = Out::getInstance(); echo "<test>"; PluginRegistry::ForEachBinding(function ($PluginInstance) use($Out) { $Binding = $PluginInstance->getName(); if ($_REQUEST[$Binding . "_check"] == "true") { echo "<name>" . $Binding . "</name>"; try { $PluginInstance->getGroups($_REQUEST[$Binding . "_database"], $_REQUEST[$Binding . "_prefix"], $_REQUEST[$Binding . "_user"], $_REQUEST[$Binding . "_password"], true); } catch (PDOException $Exception) { $Out->pushError($Exception->getMessage()); } $Out->FlushXML(""); } }); echo "</test>";
echo "<span class=\"check_result\" style=\"color: red\">" . L("NotWriteable") . " (lib/config)</span>"; } // Main config file check echo "<br/><span class=\"check_field\">" . L("MainConfigFile") . "</span>"; $ConfigFileState = !file_exists("../lib/config/config.php") && $ConfigFolderState || is_writable("../lib/config/config.php"); if ($ConfigFileState) { echo "<span class=\"check_result\" style=\"color: green\">" . L("Ok") . "</span>"; } else { ++$TestsFailed; echo "<span class=\"check_result\" style=\"color: red\">" . L("NotWriteable") . " (lib/config/config.php)</span>"; } // Plugin config files check PluginRegistry::ForEachBinding(function ($PluginInstance) use(&$TestsFailed) { $Binding = $PluginInstance->getName(); if (!$PluginInstance->isConfigWriteable()) { ++$TestsFailed; echo "<br/><span class=\"check_field\">" . L($Binding . "_ConfigFile") . "</span>"; echo "<span class=\"check_result\" style=\"color: red\">" . L("NotWriteable") . " (lib/config/config." . $Binding . ".php)</span>"; } }); ?> </div> <div class="bottom_navigation"> <div class="button_back" style="background-image: url(layout/install_white.png)"><?php echo L("Back"); ?> </div> <?php if ($TestsFailed == 0) { ?> <div class="button_next" style="background-image: url(layout/config_white.png)"><?php echo L("Continue");
<?php define("LOCALE_SETUP", true); require_once dirname(__FILE__) . "/../../lib/config/config.php"; require_once dirname(__FILE__) . "/../../lib/private/connector.class.php"; require_once dirname(__FILE__) . "/../../lib/private/userproxy.class.php"; require_once dirname(__FILE__) . "/../../lib/private/out.class.php"; $Out = Out::getInstance(); header("Content-type: application/json"); header("Cache-Control: no-cache, max-age=0, s-maxage=0"); // Check fields $BindingName = $_REQUEST["binding"]; $LocalePrefix = $BindingName . "_"; $Out->pushValue("binding", $BindingName); PluginRegistry::ForEachBinding(function ($PluginInstance) use($BindingName, $Out) { if ($PluginInstance->getName() == $BindingName) { $Value = $PluginInstance->getExternalConfig($_REQUEST["path"]); if ($Value != null) { $Out->pushValue("settings", $Value); } return false; } }); $Out->flushJSON();