define('UPLOAD_FOLDER', BASE_FOLDER . '/uploads/'); define('IMPRINT_FILE', BASE_FOLDER . '/generated/imprint.php'); define('TEMPLATES_FOLDER', BASE_FOLDER . '/templates'); define('PROFPIC_UPLOADFOLDER', UPLOAD_FOLDER . 'users'); // dependencies include GLOBAL_CONFIG_FILE; if (!isset($conf)) { header('location: install/index.php'); exit; } $page = null; $action = null; $block = null; // init application try { $website = WebSoccer::getInstance(); if (!file_exists(CONFIGCACHE_FILE_FRONTEND)) { $website->resetConfigCache(); } } catch (Exception $e) { // write to log try { $log = new FileWriter('errorlog.txt'); $log->writeLine('Website Configuration Error: ' . $e->getMessage()); $log->close(); } catch (Exception $e) { // ignore } header('HTTP/1.0 500 Error'); die; }
private static function _throwException($messageKey, $parameter = null) { $websoccer = WebSoccer::getInstance(); $i18n = I18n::getInstance($websoccer->getConfig('supported_languages')); throw new Exception($i18n->getMessage($messageKey, $parameter)); }
/** * Renders a selection field for a data table entry. * Up to 20 items will be displayed as usual selection box. Above as Autocomplete field. * * @param I18n $i18n Messages context. * @param string $fieldId ID of field. * @param array $fieldInfo assoc. array with at least keys 'entity', 'jointable' and 'labelcolumns'. * @param int $fieldValue pre-selected ID. */ public static function createForeignKeyField($i18n, $fieldId, $fieldInfo, $fieldValue) { $website = WebSoccer::getInstance(); $db = DbConnection::getInstance(); $fromTable = $website->getConfig('db_prefix') . '_' . $fieldInfo['jointable']; // count total items $result = $db->querySelect('COUNT(*) AS hits', $fromTable, '1=1', ''); $items = $result->fetch_array(); $result->free(); // render usual selection box if ($items['hits'] <= 20) { echo '<select id=\'' . $fieldId . '\' name=\'' . $fieldId . '\'>'; echo '<option value=\'\'>' . $i18n->getMessage('manage_select_placeholder') . '</option>'; $whereCondition = '1=1 ORDER BY ' . $fieldInfo['labelcolumns'] . ' ASC'; $result = $db->querySelect('id, ' . $fieldInfo['labelcolumns'], $fromTable, $whereCondition, '', 2000); while ($row = $result->fetch_array()) { $labels = explode(',', $fieldInfo['labelcolumns']); $label = ''; $first = TRUE; foreach ($labels as $labelColumn) { if (!$first) { $label .= ' - '; } $first = FALSE; $label .= $row[trim($labelColumn)]; } echo '<option value=\'' . $row['id'] . '\''; if ($fieldValue == $row['id']) { echo ' selected'; } echo '>' . escapeOutput($label) . '</option>'; } $result->free(); echo '</select>'; // render AJAXified item picker } else { echo '<input type=\'hidden\' class=\'pkpicker\' id=\'' . $fieldId . '\' name=\'' . $fieldId . '\' value=\'' . $fieldValue . '\' data-dbtable=\'' . $fieldInfo['jointable'] . '\' data-labelcolumns=\'' . $fieldInfo['labelcolumns'] . '\' data-placeholder=\'' . $i18n->getMessage('manage_select_placeholder') . '\'>'; } echo ' <a href=\'?site=manage&entity=' . $fieldInfo['entity'] . '&show=add\' title=\'' . $i18n->getMessage('manage_add') . '\'><i class=\'icon-plus-sign\'></i></a>'; }
/** * Check if there are pending substitutions at the specified minute and execute them. * * @param SimulationMatch $match * @param SimulationTeam $team * @param array array of ISimulatorObserver instances. */ public static function checkAndExecuteSubstitutions(SimulationMatch $match, SimulationTeam $team, $observers) { $substitutions = $team->substitutions; if (!count($substitutions)) { return; } foreach ($substitutions as $substitution) { if ($substitution->minute == $match->minute && !isset($team->removedPlayers[$substitution->playerOut->id]) && isset($team->playersOnBench[$substitution->playerIn->id])) { // check condition if ($substitution->condition == SUB_CONDITION_TIE && $match->homeTeam->getGoals() != $match->guestTeam->getGoals() || $substitution->condition == SUB_CONDITION_LEADING && $team->getGoals() <= self::getOpponentTeamOfTeam($team, $match)->getGoals() || $substitution->condition == SUB_CONDITION_DEFICIT && $team->getGoals() >= self::getOpponentTeamOfTeam($team, $match)->getGoals()) { // set minute as unreachable, so that it could be replaced by an unplanned substitution. // do not simply remove it, because it might become out of sync with DB table entry on state saving. $substitution->minute = 999; continue; } $team->removePlayer($substitution->playerOut); // determine main position. // first: is it specified at substition config? // second: has the player a main position? Note that youth players have main position "-" // third: add player to his general position, without any main position if (strlen($substitution->position)) { $mainPosition = $substitution->position; } else { if (strlen($substitution->playerIn->mainPosition) && $substitution->playerIn->mainPosition != "-") { $mainPosition = $substitution->playerIn->mainPosition; } else { $mainPosition = NULL; } } // determine general position if ($mainPosition == NULL) { $position = $substitution->playerIn->position; } else { $positionMapping = self::getPositionsMapping(); $position = $positionMapping[$mainPosition]; } // strength deduction needed? $strength = $substitution->playerIn->strength; if ($position != $substitution->playerIn->position) { $strength = round($strength * (1 - WebSoccer::getInstance()->getConfig("sim_strength_reduction_wrongposition") / 100)); } else { if ($mainPosition != NULL && $mainPosition != $substitution->playerIn->mainPosition) { $strength = round($strength * (1 - WebSoccer::getInstance()->getConfig("sim_strength_reduction_secondary") / 100)); } } // updates values $substitution->playerIn->position = $position; $substitution->playerIn->strength = $strength; $substitution->playerIn->mainPosition = $mainPosition; // add to playground $team->positionsAndPlayers[$substitution->playerIn->position][] = $substitution->playerIn; // remove from bench unset($team->playersOnBench[$substitution->playerIn->id]); foreach ($observers as $observer) { $observer->onSubstitution($match, $substitution); } } } }
/** * Is current user also a registered admin user? Will be determined by e-mail address. * * @return boolean TRUE if user is an admin user, FALSE otherwise. */ public function isAdmin() { if ($this->_isAdmin === NULL) { $websoccer = WebSoccer::getInstance(); $db = DbConnection::getInstance(); $result = $db->querySelect('id', $websoccer->getConfig('db_prefix') . '_admin', 'email = \'%s\' AND r_admin = \'1\'', $this->email); if ($result->num_rows) { $this->_isAdmin = TRUE; } else { $this->_isAdmin = FALSE; } $result->free(); } return $this->_isAdmin; }