当前位置: 首页>>代码示例>>PHP>>正文


PHP Connector::getInstance方法代码示例

本文整理汇总了PHP中Connector::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Connector::getInstance方法的具体用法?PHP Connector::getInstance怎么用?PHP Connector::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connector的用法示例。


在下文中一共展示了Connector::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: msgRaidList

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'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:29,代码来源:message_raid_list.php

示例2: msgQueryLocations

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'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:32,代码来源:message_query_locations.php

示例3: msgQueryNewRaidData

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'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:26,代码来源:message_query_newraid.php

示例4: register

 /**
  * This method must be called to make class "PC" available
  * @param Connector|null $connector
  * @param Handler|null $handler
  * @throws \Exception
  * @return Connector
  */
 public static function register(Connector $connector = null, Handler $handler = null)
 {
     if (static::$connector) {
         throw new \Exception('Helper already registered');
     }
     self::$handler = $handler;
     self::$connector = $connector ?: Connector::getInstance();
     self::$isActive = self::$connector->isActiveClient();
     return self::$connector;
 }
开发者ID:phpsong,项目名称:hotel-information-system,代码行数:17,代码来源:Helper.php

示例5: gc

 function gc()
 {
     $con = Connector::getInstance();
     try {
         $con->beginTransaction();
         $st = $con->prepare('DELETE FROM sessions WHERE expires < ?');
         $st->execute(array(time()));
         $con->commit();
     } catch (Exception $e) {
         $st->rollback();
     }
     return true;
 }
开发者ID:kperson,项目名称:Connect4,代码行数:13,代码来源:sessions.php

示例6: api_query_location

function api_query_location($aParameter)
{
    $aGames = getParamFrom($aParameter, 'games', '');
    $aUTF8 = getParamFrom($aParameter, 'utf8', false);
    $Parameters = array();
    $Conditions = array();
    // Filter games
    if ($aGames != '') {
        $Games = explode(',', $aGames);
        $GameOptions = array();
        foreach ($Games as $Game) {
            array_push($GameOptions, 'Game=?');
            array_push($Parameters, $Game);
        }
        array_push($Conditions, $GameOptions);
    }
    // Build where clause
    $WhereString = '';
    if (count($Conditions) > 0) {
        foreach ($Conditions as &$Part) {
            if (is_array($Part)) {
                $Part = '(' . implode(' OR ', $Part) . ')';
            }
        }
        $WhereString = 'WHERE ' . implode(' AND ', $Conditions) . ' ';
    }
    // Query
    $Connector = Connector::getInstance();
    $LocationQuery = $Connector->prepare('SELECT * FROM `' . RP_TABLE_PREFIX . 'Location` ' . $WhereString . ' ORDER BY Name');
    foreach ($Parameters as $Index => $Value) {
        if (is_numeric($Value)) {
            $LocationQuery->bindValue($Index + 1, $Value, PDO::PARAM_INT);
        } else {
            $LocationQuery->bindValue($Index + 1, $Value, PDO::PARAM_STR);
        }
    }
    // Build result
    $Result = array();
    $LocationQuery->loop(function ($LocationRow) use(&$Result, $aUTF8) {
        array_push($Result, array('Id' => $LocationRow['LocationId'], 'Name' => $aUTF8 ? xmlToUTF8($LocationRow['Name']) : $LocationRow['Name'], 'GameId' => $LocationRow['Game'], 'Image' => $LocationRow['Image']));
    });
    return $Result;
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:43,代码来源:api_location.php

示例7: serialize

 public function serialize()
 {
     $Connector = Connector::getInstance();
     // Get existing settings
     $TestQuery = $Connector->prepare('SELECT * FROM `' . RP_TABLE_PREFIX . 'Setting`');
     $ExistingValues = array();
     $TestQuery->loop(function ($Row) use(&$ExistingValues) {
         $ExistingValues[$Row['Name']] = $Row;
     });
     $ExistingSettings = array_keys($ExistingValues);
     // Update / insert settings
     foreach ($this->Property as $Name => $Property) {
         $Index = array_search($Name, $ExistingSettings);
         $IntValue = isset($Property['IntValue']) ? intval($Property['IntValue']) : 0;
         $TextValue = isset($Property['TextValue']) ? strval($Property['TextValue']) : '';
         if ($Index === false) {
             $InsertQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Setting` (Name, IntValue, TextValue) VALUES (:Name, :IntValue, :TextValue)');
             $InsertQuery->bindValue(':IntValue', $IntValue, PDO::PARAM_INT);
             $InsertQuery->bindValue(':TextValue', $TextValue, PDO::PARAM_STR);
             $InsertQuery->bindValue(':Name', $Name, PDO::PARAM_STR);
             $InsertQuery->execute();
         } else {
             $CurrentValue = $ExistingValues[$Name];
             if (isset($Property['IntValue']) && $CurrentValue['IntValue'] != $Property['IntValue'] || isset($Property['TextValue']) && $CurrentValue['TextValue'] != $Property['TextValue']) {
                 $UpdateQuery = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Setting` SET IntValue=:IntValue, TextValue=:TextValue WHERE Name=:Name LIMIT 1');
                 $UpdateQuery->bindValue(':IntValue', $IntValue, PDO::PARAM_INT);
                 $UpdateQuery->bindValue(':TextValue', $TextValue, PDO::PARAM_STR);
                 $UpdateQuery->bindValue(':Name', $Name, PDO::PARAM_STR);
                 $UpdateQuery->execute();
             }
             array_splice($ExistingSettings, $Index, 1);
         }
     }
     // Remove settings
     foreach ($ExistingSettings as $Setting) {
         $DropQuery = $Connector->prepare('DELETE FROM `' . RP_TABLE_PREFIX . 'Setting` WHERE Name=:Name LIMIT 1');
         $DropQuery->bindValue(':Name', $Setting, PDO::PARAM_STR);
         $DropQuery->execute();
     }
 }
开发者ID:zatoshi,项目名称:raidplaner,代码行数:40,代码来源:settings.class.php

示例8: msgQueryCalendar

function msgQueryCalendar($aRequest)
{
    if (validUser()) {
        global $gGame;
        loadGameSettings();
        $Out = Out::getInstance();
        $Connector = Connector::getInstance();
        $ListRaidQuery = $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 . 'Raid.Start <= FROM_UNIXTIME(:End) ' . 'AND ' . RP_TABLE_PREFIX . 'Location.Game = :Game ' . 'ORDER BY ' . RP_TABLE_PREFIX . 'Raid.Start, ' . RP_TABLE_PREFIX . 'Raid.RaidId');
        // Calculate the correct start end end times
        $StartDay = getCalStartDay();
        $StartUTC = mktime(0, 0, 0, $aRequest['Month'], 1, $aRequest['Year']);
        $StartDate = getdate($StartUTC);
        if ($StartDate['wday'] != $StartDay) {
            // Calculate the first day displayed in the calendar
            $Offset = $StartDate['wday'] < $StartDay ? 7 - ($StartDay - $StartDate['wday']) : $StartDate['wday'] - $StartDay;
            $StartUTC -= 60 * 60 * 24 * $Offset;
            $StartDate = getdate($StartUTC);
        }
        // Calculate the last day displayed in the calendar
        $EndUTC = $StartUTC + 60 * 60 * 24 * 7 * 6;
        // + 6 weeks
        // Query and return
        $ListRaidQuery->bindValue(':Start', $StartUTC, PDO::PARAM_INT);
        $ListRaidQuery->bindValue(':End', intval($EndUTC), PDO::PARAM_INT);
        $ListRaidQuery->bindValue(':Game', $gGame['GameId'], PDO::PARAM_STR);
        $Session = Session::get();
        $Session['Calendar'] = array('month' => intval($aRequest['Month']), 'year' => intval($aRequest['Year']));
        $Out->pushValue('startDay', $StartDate['mday']);
        $Out->pushValue('startMonth', $StartDate['mon']);
        $Out->pushValue('startYear', $StartDate['year']);
        $Out->pushValue('startOfWeek', $StartDay);
        $Out->pushValue('displayMonth', $aRequest['Month']);
        $Out->pushValue('displayYear', $aRequest['Year']);
        parseRaidQuery($aRequest, $ListRaidQuery, 0);
    } else {
        $Out = Out::getInstance();
        $Out->pushError(L('AccessDenied'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:39,代码来源:message_query_calendar.php

示例9: msgCommentupdate

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'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:38,代码来源:message_comment_update.php

示例10: msgRaidDelete

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'));
    }
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:37,代码来源:message_raid_delete.php

示例11: L

?>
</h2>

<?php 
echo L("AdminPasswordSetup");
?>
<br/>
<?php 
echo L("AdminNotMoveable");
?>
<br/>

<br/>

<?php 
$Connector = Connector::getInstance();
$NameQuery = $Connector->prepare("SELECT Login FROM `" . RP_TABLE_PREFIX . "User` WHERE UserId=1 LIMIT 1");
$UserData = $NameQuery->fetchFirst();
$AdminName = $NameQuery->getAffectedRows() == 0 ? "admin" : $UserData["Login"];
?>

<input type="text" id="name" value="<?php 
echo $AdminName;
?>
"/> <?php 
echo L("AdminName");
?>
<br/>
<input type="password" id="password"/> <?php 
echo L("AdminPassword");
?>
开发者ID:zatoshi,项目名称:raidplaner,代码行数:31,代码来源:install_password.php

示例12: msgQuerySettings

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);
//.........这里部分代码省略.........
开发者ID:zatoshi,项目名称:raidplaner,代码行数:101,代码来源:message_query_settings.php

示例13: getConnector

 /**
  * @return Connector
  */
 public function getConnector()
 {
     return Connector::getInstance();
 }
开发者ID:beardedlinuxgeek,项目名称:php-console,代码行数:7,代码来源:OldVersionAdapter.php

示例14: tryGetUserLink

function tryGetUserLink($UserId)
{
    $Connector = Connector::getInstance();
    $UserProxy = UserProxy::getInstance();
    $UserQuery = $Connector->prepare('Select * FROM `' . RP_TABLE_PREFIX . 'User` WHERE UserId=:UserId LIMIT 1');
    $UserQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT);
    $UserData = $UserQuery->fetchFirst();
    if ($UserData == null) {
        return null;
    }
    // ### return, failed ###
    // Try to find a fitting binding
    // External binding is still set.
    // Finding the user is trivial
    if ($UserData['ExternalBinding'] != 'none') {
        return $UserProxy->getUserInfoById($UserData['ExternalBinding'], $UserData['ExternalId']);
        // ### return, success ###
    }
    // External id is still set.
    // Finding the user is trivial if there is only one binding
    if ($UserData['ExternalId'] != 0) {
        $Candidates = UserProxy::getAllUserInfosById($UserData['ExternalId']);
        if (count($Candidates) > 1) {
            // More than one binding, check the username and
            // reduce the array to username matches
            $Filtered = array();
            foreach ($Candidates as $BindingName => $UserInfo) {
                if ($UserInfo->UserName == $UserData['Login']) {
                    $Filtered[$BindingName] = $UserInfo;
                }
            }
            // If filtering was successfull, switch arrays
            if (count($Filtered) > 0) {
                $Candidates = $Filtered;
            }
        }
        // Use the first match. Having multiple matches is very unlikely as two (or more)
        // forums need to have a user with the same username AND id.
        if (count($Candidates) > 0) {
            reset($Candidates);
            list($BindingName, $UserInfo) = each($Candidates);
            // fetch the first entry
            return $UserInfo;
            // ### return, success ###
        }
    }
    // All checks failed
    // Search for user by name
    $Candidates = $UserProxy->getAllUserInfosByName($UserData['Login']);
    // Use the first match.
    // This may lead to the wrong user, but searching by name is basically wild guessing anyway.
    // Note that there is always at least one candidate with the binding 'none'.
    if (count($Candidates) > 1) {
        reset($Candidates);
        list($BindingName, $UserInfo) = each($Candidates);
        // first entry is 'none'
        list($BindingName, $UserInfo) = each($Candidates);
        // this is the first external binding
        return $UserInfo;
        // ### return, success ###
    }
    return null;
}
开发者ID:zatoshi,项目名称:raidplaner,代码行数:63,代码来源:message_user_link.php

示例15: msgProfileupdate

function msgProfileupdate($aRequest)
{
    if (validUser()) {
        global $gGame;
        loadGameSettings();
        $UserId = UserProxy::getInstance()->UserId;
        if (validAdmin() && isset($aRequest['userId']) && $aRequest['userId'] != 0) {
            $UserId = intval($aRequest['userId']);
        }
        $Connector = Connector::getInstance();
        do {
            $Connector->beginTransaction();
            // Update password
            if (isset($aRequest['newPass']) && $aRequest['oldPass'] != '') {
                if (UserProxy::getInstance()->validateCredentials($aRequest['oldPass'])) {
                    // User authenticated with valid password
                    // change the password of the given id. ChangePassword does a check
                    // for validity (e.g. only admin may change other user's passwords)
                    $Salt = UserProxy::generateKey32();
                    $HashedPassword = NativeBinding::nativeHash($aRequest['newPass'], $Salt, 'none');
                    if (!UserProxy::changePassword($UserId, $HashedPassword, $Salt)) {
                        $Out = Out::getInstance();
                        $Out->pushError(L('PasswordLocked'));
                    }
                } else {
                    $Out = Out::getInstance();
                    $Out->pushError(L('WrongPassword'));
                }
            }
            // Update always log in
            if ($aRequest['autoAttend'] == 'true') {
                $ExistsRequest = $Connector->prepare('SELECT UserSettingId FROM `' . RP_TABLE_PREFIX . 'UserSetting` ' . 'WHERE UserId=:UserId and Name="AutoAttend" LIMIT 1');
                $ExistsRequest->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                if ($ExistsRequest->fetchFirst() == null) {
                    $AttendRequest = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'UserSetting` (UserId, Name) VALUES (:UserId, "AutoAttend")');
                    $AttendRequest->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                    $AttendRequest->execute();
                }
            } else {
                $RemoveQuery = $Connector->prepare('DELETE FROM `' . RP_TABLE_PREFIX . 'UserSetting` WHERE ' . 'UserId = :UserId AND (Name = "AutoAttend") LIMIT 1');
                $RemoveQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                $RemoveQuery->execute();
            }
            // Update vacation settings
            $Ranges = getVacationData($aRequest);
            $VacationMessage = $aRequest['vacationMessage'] == null ? '' : requestToXML($aRequest['vacationMessage'], ENT_COMPAT, 'UTF-8');
            // Revoke ranges that have been removed
            foreach ($Ranges['revoke'] as $RevokeRange) {
                $RevokeQuery = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Raid` LEFT JOIN `' . RP_TABLE_PREFIX . 'Attendance` USING (RaidId) ' . 'SET `' . RP_TABLE_PREFIX . 'Attendance`.Status = "undecided", Comment = "" ' . 'WHERE Start >= FROM_UNIXTIME(:Start) AND Start <= FROM_UNIXTIME(:End) ' . 'AND `' . RP_TABLE_PREFIX . 'Attendance`.Status = "unavailable" AND `' . RP_TABLE_PREFIX . 'Attendance`.UserId = :UserId');
                $RevokeQuery->bindValue(':Start', max($RevokeRange[0], time()), PDO::PARAM_INT);
                $RevokeQuery->bindValue(':End', max($RevokeRange[1], time()), PDO::PARAM_INT);
                $RevokeQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                $RevokeQuery->execute();
            }
            // Update already affected ranges
            foreach ($Ranges['update'] as $UpdateRange) {
                $UpdateQuery = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Raid` LEFT JOIN `' . RP_TABLE_PREFIX . 'Attendance` USING(RaidId) ' . 'SET Comment = :Message ' . 'WHERE Start >= FROM_UNIXTIME(:Start) AND Start <= FROM_UNIXTIME(:End) ' . 'AND UserId = :UserId AND Status = "unavailable"');
                $UpdateQuery->bindValue(':Start', $UpdateRange[0], PDO::PARAM_INT);
                $UpdateQuery->bindValue(':End', $UpdateRange[1], PDO::PARAM_INT);
                $UpdateQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                $UpdateQuery->bindValue(':Message', $VacationMessage, PDO::PARAM_STR);
                $UpdateQuery->execute();
            }
            // Update/Insert new ranges
            foreach ($Ranges['new'] as $NewRange) {
                // Update all raids that already have an attendance record
                $UpdateQuery = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'Raid` LEFT JOIN `' . RP_TABLE_PREFIX . 'Attendance` USING(RaidId) ' . 'SET Status = "unavailable", Comment = :Message ' . 'WHERE Start >= FROM_UNIXTIME(:Start) AND Start <= FROM_UNIXTIME(:End) ' . 'AND UserId = :UserId');
                $UpdateQuery->bindValue(':Start', $NewRange[0], PDO::PARAM_INT);
                $UpdateQuery->bindValue(':End', $NewRange[1], PDO::PARAM_INT);
                $UpdateQuery->bindValue(':UserId', intval($UserId), PDO::PARAM_INT);
                $UpdateQuery->bindValue(':Message', $VacationMessage, PDO::PARAM_STR);
                $UpdateQuery->execute();
                // Find all reaids the do not have an attendance record
                $AffectedQuery = $Connector->prepare('SELECT `' . RP_TABLE_PREFIX . 'Raid`.RaidId FROM `' . RP_TABLE_PREFIX . 'Raid` ' . 'LEFT JOIN `' . RP_TABLE_PREFIX . 'Attendance` ON (`' . RP_TABLE_PREFIX . 'Raid`.RaidId = `' . RP_TABLE_PREFIX . 'Attendance`.RaidId ' . 'AND (`' . RP_TABLE_PREFIX . 'Attendance`.UserId = :UserId OR `' . RP_TABLE_PREFIX . 'Attendance`.UserId IS NULL)) ' . 'WHERE Start >= FROM_UNIXTIME(:Start) AND Start <= FROM_UNIXTIME(:End) ' . 'AND UserId IS NULL ' . 'GROUP BY RaidId');
                $AffectedQuery->bindValue(':Start', $NewRange[0], PDO::PARAM_INT);
                $AffectedQuery->bindValue(':End', $NewRange[1], PDO::PARAM_INT);
                $AffectedQuery->bindValue(':UserId', intval($UserId), PDO::PARAM_INT);
                $AffectedQuery->loop(function ($aRaid) use(&$Connector, $UserId, $VacationMessage) {
                    // Set user to unavailable
                    $InsertQuery = $Connector->prepare('INSERT INTO `' . RP_TABLE_PREFIX . 'Attendance` ' . '(UserId, RaidId, Status, Comment) ' . 'VALUES (:UserId, :RaidId, "unavailable", :Message)');
                    $InsertQuery->bindValue(':UserId', intval($UserId), PDO::PARAM_INT);
                    $InsertQuery->bindValue(':RaidId', $aRaid['RaidId'], PDO::PARAM_INT);
                    $InsertQuery->bindValue(':Message', $VacationMessage, PDO::PARAM_STR);
                    $InsertQuery->execute();
                });
            }
            // Update user settings
            if (count($Ranges['new']) == 0 && count($Ranges['update']) == 0) {
                if (count($Ranges['revoke']) > 0) {
                    $RemoveQuery = $Connector->prepare('DELETE FROM `' . RP_TABLE_PREFIX . 'UserSetting` WHERE ' . 'UserId = :UserId AND (Name = "VacationStart" OR Name = "VacationEnd" OR Name = "VacationMessage") LIMIT 3');
                    $RemoveQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                    $RemoveQuery->execute();
                }
            } else {
                if ($Ranges['SettingsFound']) {
                    $UpdateQuery = $Connector->prepare('UPDATE `' . RP_TABLE_PREFIX . 'UserSetting` SET IntValue = :Start WHERE UserId = :UserId AND Name = "VacationStart" LIMIT 1;' . 'UPDATE `' . RP_TABLE_PREFIX . 'UserSetting` SET IntValue = :End WHERE UserId = :UserId AND Name = "VacationEnd" LIMIT 1;' . 'UPDATE `' . RP_TABLE_PREFIX . 'UserSetting` SET TextValue = :Message WHERE UserId = :UserId AND Name = "VacationMessage" LIMIT 1;');
                    $UpdateQuery->bindValue(':UserId', $UserId, PDO::PARAM_INT);
                    $UpdateQuery->bindValue(':Start', $aRequest['vacationStart'], PDO::PARAM_INT);
                    $UpdateQuery->bindValue(':End', $aRequest['vacationEnd'], PDO::PARAM_INT);
                    $UpdateQuery->bindValue(':Message', $VacationMessage, PDO::PARAM_STR);
//.........这里部分代码省略.........
开发者ID:zatoshi,项目名称:raidplaner,代码行数:101,代码来源:message_profile_update.php


注:本文中的Connector::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。