mirror of
https://github.com/Deutscher-Tischfussballbund/com_sportsmanager.git
synced 2026-06-10 06:27:52 +00:00
fix: add labels, init variables, replace deprecated joomla 3 classes, add return types, removed commented code, removed unused parameters
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2,15 +2,25 @@
|
|||||||
/*
|
/*
|
||||||
* Sports Manager API Extension
|
* Sports Manager API Extension
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use JetBrains\PhpStorm\NoReturn;
|
||||||
|
use Joomla\CMS\Application\SiteApplication;
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\CMS\User\UserFactory;
|
||||||
|
use Joomla\Input\Input;
|
||||||
|
use Joomla\Registry\Registry;
|
||||||
|
|
||||||
defined("_JEXEC") or die();
|
defined("_JEXEC") or die();
|
||||||
|
|
||||||
//$secret = JFactory::$config['secret'];
|
require_once JPATH_SITE . '/components/com_sportsmanager/database/init.php';
|
||||||
|
|
||||||
$secret = \Joomla\CMS\Factory::getConfig();
|
Factory::getContainer()->set(Registry::class, function () {
|
||||||
|
return new Registry();
|
||||||
|
});
|
||||||
|
|
||||||
$secret = $secret->get("secret");
|
$secret = Factory::getContainer()->get(Registry::class)->get("secret");
|
||||||
|
|
||||||
function abortWithError($error)
|
#[NoReturn] function abortWithError($error): void
|
||||||
{
|
{
|
||||||
if (isJson()) {
|
if (isJson()) {
|
||||||
header("content-type: application/json");
|
header("content-type: application/json");
|
||||||
@@ -20,22 +30,23 @@ function abortWithError($error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isJson() {
|
function isJson(): bool
|
||||||
$jinput = JFactory::getApplication()->input;
|
{
|
||||||
|
$jInput = Factory::getContainer()->get(SiteApplication::class)->getInput();
|
||||||
return $jinput->get('format') === 'json';
|
return $jInput->get('format') === 'json';
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyChange($data) {
|
function notifyChange($data): void
|
||||||
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$db = &getDatabase();
|
$db = getDatabase();
|
||||||
$query = "SELECT wert from #__sportsmanager_einstellungen WHERE name='api_push_key'";
|
$query = "SELECT wert from #__sportsmanager_einstellungen WHERE name='api_push_key'";
|
||||||
$db->setQuery($query);
|
$db->setQuery($query);
|
||||||
$push_key = $db->loadResult();
|
$push_key = $db->loadResult();
|
||||||
$push_server = !empty($push_key) && isset(_payload($push_key)->aud) ? _payload($push_key)->aud : '';
|
$push_server = !empty($push_key) && isset(_payload($push_key)->aud) ? _payload($push_key)->aud : '';
|
||||||
if ($push_server != '' && $push_key != '') {
|
if ($push_server != '' && $push_key != '') {
|
||||||
$url = $push_server . (substr($push_server, -1) == '/' ? '' : '/') . 'v1/notifications/send';
|
$url = $push_server . (str_ends_with($push_server, '/') ? '' : '/') . 'v1/notifications/send';
|
||||||
$key = 'key=' . $push_key;
|
$key = 'key=' . $push_key;
|
||||||
|
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
@@ -51,7 +62,7 @@ function notifyChange($data) {
|
|||||||
CURLOPT_POSTFIELDS => json_encode($data),
|
CURLOPT_POSTFIELDS => json_encode($data),
|
||||||
));
|
));
|
||||||
$resp = curl_exec($ch);
|
$resp = curl_exec($ch);
|
||||||
if ($resp == FALSE) {
|
if (!$resp) {
|
||||||
error_log("failed to send notification");
|
error_log("failed to send notification");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +71,8 @@ function notifyChange($data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function begegnungChanged($begegnung, $begegnung_vorher, $modus, $heim_team, $gast_team, $spiele) {
|
function begegnungChanged($begegnung, $begegnung_vorher, $modus, $heim_team, $gast_team, $spiele): void
|
||||||
|
{
|
||||||
notifyChange(['payload' => [
|
notifyChange(['payload' => [
|
||||||
'begegnung' => $begegnung,
|
'begegnung' => $begegnung,
|
||||||
'begegnung_vorher' => $begegnung_vorher,
|
'begegnung_vorher' => $begegnung_vorher,
|
||||||
@@ -71,7 +83,8 @@ function begegnungChanged($begegnung, $begegnung_vorher, $modus, $heim_team, $ga
|
|||||||
], 'type' => 'FIXTURE_RESULT_CHANGED']);
|
], 'type' => 'FIXTURE_RESULT_CHANGED']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function begegnungTischChanged($begegnung, $heim_team, $gast_team) {
|
function begegnungTischChanged($begegnung, $heim_team, $gast_team): void
|
||||||
|
{
|
||||||
notifyChange(['payload' => [
|
notifyChange(['payload' => [
|
||||||
'begegnung' => $begegnung,
|
'begegnung' => $begegnung,
|
||||||
'heim_team' => $heim_team,
|
'heim_team' => $heim_team,
|
||||||
@@ -79,7 +92,8 @@ function begegnungTischChanged($begegnung, $heim_team, $gast_team) {
|
|||||||
], 'type' => 'TABLE_CHANGED']);
|
], 'type' => 'TABLE_CHANGED']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function begegnungVerlegenNotify($begegnung, $users, $vorschlagendes_team_id, $heim_team, $gast_team) {
|
function begegnungVerlegenNotify($begegnung, $users, $vorschlagendes_team_id, $heim_team, $gast_team): void
|
||||||
|
{
|
||||||
notifyChange([
|
notifyChange([
|
||||||
'payload' => [
|
'payload' => [
|
||||||
'begegnung' => $begegnung,
|
'begegnung' => $begegnung,
|
||||||
@@ -97,7 +111,8 @@ function begegnungVerlegenNotify($begegnung, $users, $vorschlagendes_team_id, $h
|
|||||||
* @reponse body
|
* @reponse body
|
||||||
* { data: { token: "reqest_token", access_for_team: ["team_id_1", "team_id_2"]}, expires: 1520013747000}
|
* { data: { token: "reqest_token", access_for_team: ["team_id_1", "team_id_2"]}, expires: 1520013747000}
|
||||||
*/
|
*/
|
||||||
function userToken() {
|
#[NoReturn] function userToken(): void
|
||||||
|
{
|
||||||
global $secret;
|
global $secret;
|
||||||
if (!isJson()) {
|
if (!isJson()) {
|
||||||
abortWithError("JSON Request only");
|
abortWithError("JSON Request only");
|
||||||
@@ -105,19 +120,21 @@ function userToken() {
|
|||||||
if (isExternalDatabase()) {
|
if (isExternalDatabase()) {
|
||||||
abortWithError("Local Database only");
|
abortWithError("Local Database only");
|
||||||
}
|
}
|
||||||
$jinput = JFactory::getApplication()->input->json;
|
$container = Factory::getContainer();
|
||||||
$access_key = $jinput->getString('access_key');
|
$jInput = $container->get(SiteApplication::class)->getInput()->json;
|
||||||
|
$access_key = $jInput->getString('access_key');
|
||||||
|
|
||||||
$user_id = _payload($access_key)->sub;
|
$user_id = _payload($access_key)->sub;
|
||||||
$user = JFactory::getUser($user_id);
|
$user = $container->get(UserFactory::class)->loadUserById($user_id);
|
||||||
|
|
||||||
if (!jwt_validate($access_key, $secret.$user->password)) {
|
if (!jwt_validate($access_key, $secret . $user->password)) {
|
||||||
abortWithError('Access Key is invalid');
|
abortWithError('Access Key is invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$expires = new DateTime();
|
$expires = new DateTime();
|
||||||
$expires->modify('+16 hours');
|
$expires->modify('+16 hours');
|
||||||
$db = &getDatabase();
|
$db = getDatabase();
|
||||||
$query = "SELECT berechtigt_team_id from #__sportsmanager_berechtigt_fuer_team where berechtigt_user_id = $user_id";
|
$query = "SELECT berechtigt_team_id from #__sportsmanager_berechtigt_fuer_team where berechtigt_user_id = $user_id";
|
||||||
$db->setQuery($query);
|
$db->setQuery($query);
|
||||||
if (!$db->execute()) {
|
if (!$db->execute()) {
|
||||||
@@ -129,9 +146,15 @@ function userToken() {
|
|||||||
'sub' => $user_id,
|
'sub' => $user_id,
|
||||||
'exp' => $expires->getTimestamp(),
|
'exp' => $expires->getTimestamp(),
|
||||||
], $secret),
|
], $secret),
|
||||||
'access_for_teams' => array_map(function($item) { return $item->berechtigt_team_id; }, $team_id),
|
'access_for_teams' => array_map(function ($item) {
|
||||||
|
return $item->berechtigt_team_id;
|
||||||
|
}, $team_id),
|
||||||
'expires' => $expires->getTimestamp() * 1000, //
|
'expires' => $expires->getTimestamp() * 1000, //
|
||||||
]);
|
]);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
error_log($ex);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -139,7 +162,8 @@ function userToken() {
|
|||||||
* @response body
|
* @response body
|
||||||
* { data: { token: "api_acccess_token" }}
|
* { data: { token: "api_acccess_token" }}
|
||||||
*/
|
*/
|
||||||
function userAuth() {
|
#[NoReturn] function userAuth(): void
|
||||||
|
{
|
||||||
global $secret;
|
global $secret;
|
||||||
if (!isJson()) {
|
if (!isJson()) {
|
||||||
die();
|
die();
|
||||||
@@ -147,43 +171,48 @@ function userAuth() {
|
|||||||
if (isExternalDatabase()) {
|
if (isExternalDatabase()) {
|
||||||
abortWithError("Local Database only");
|
abortWithError("Local Database only");
|
||||||
}
|
}
|
||||||
$jinput = JFactory::getApplication()->input->json;
|
$container = Factory::getContainer();
|
||||||
$username = $jinput->getString('username');
|
$jInput = $container->get(SiteApplication::class)->getInput()->json;
|
||||||
$password = $jinput->getString('password');
|
$username = $jInput->getString('username');
|
||||||
|
$password = $jInput->getString('password');
|
||||||
|
|
||||||
$db = &getDatabase();
|
$db = getDatabase();
|
||||||
$query = $db->getQuery(true);
|
$query = $db->getQuery(true);
|
||||||
$query->select('id')->from('#__users')->where('username = "' . $username . '"')->limit(1);
|
$query->select('id')->from('#__users')->where('username = "' . $username . '"')->limit(1);
|
||||||
$db->setQuery($query);
|
$db->setQuery($query);
|
||||||
$user_id = $db->loadResult();
|
$user_id = $db->loadResult();
|
||||||
$user = JFactory::getUser($user_id);
|
$user = $container->get(UserFactory::class)->loadUserById($user_id);
|
||||||
|
|
||||||
if (JUserHelper::verifyPassword($password, $user->password, $user->id)) {
|
//TODO: pw verification modernising: use php native methods, however this also needs new pw hashing. maybe force a pw reset on all accounts
|
||||||
|
if (password_verify($password, $user->password)) {
|
||||||
|
|
||||||
JSON_sportsmanager::JSON([
|
JSON_sportsmanager::JSON([
|
||||||
'token' => jwt_token([
|
'token' => jwt_token([
|
||||||
'sub' => $user_id,
|
'sub' => $user_id,
|
||||||
'iat' => (new DateTime())->getTimestamp(),
|
'iat' => (new DateTime())->getTimestamp(),
|
||||||
], $secret.$user->password)
|
], $secret . $user->password)
|
||||||
]);
|
]);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
abortWithError('Wrong credentials');
|
abortWithError('Wrong credentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserID() {
|
function getUserID(): int
|
||||||
|
{
|
||||||
global $secret;
|
global $secret;
|
||||||
$token = JFactory::getApplication()->input->server->getString('HTTP_SECRET', NULL);
|
$container = Factory::getContainer();
|
||||||
|
$input = $container->get(Input::class);
|
||||||
|
$token = $input->server->getString('HTTP_SECRET', NULL);
|
||||||
|
|
||||||
return $token != NULL && jwt_validate($token, $secret) && isset(_payload($token)->sub)
|
return $token != NULL && jwt_validate($token, $secret) && isset(_payload($token)->sub)
|
||||||
? (int) _payload($token)->sub
|
? (int)_payload($token)->sub
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getColorOfImage($image) {
|
function getColorOfImage($image)
|
||||||
|
{
|
||||||
if ($image != NULL) {
|
if ($image != NULL) {
|
||||||
|
|
||||||
if (strpos($image, '.png') !== false) {
|
if (str_contains($image, '.png')) {
|
||||||
$img = imagecreatefrompng($image);
|
$img = imagecreatefrompng($image);
|
||||||
} else {
|
} else {
|
||||||
$img = imagecreatefromjpeg($image);
|
$img = imagecreatefromjpeg($image);
|
||||||
@@ -215,7 +244,8 @@ function getColorOfImage($image) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function colorKey($rgb) {
|
function colorKey($rgb): string
|
||||||
|
{
|
||||||
|
|
||||||
$r = (int)($rgb['red'] / 100);
|
$r = (int)($rgb['red'] / 100);
|
||||||
$g = (int)($rgb['green'] / 100);
|
$g = (int)($rgb['green'] / 100);
|
||||||
@@ -224,7 +254,8 @@ function colorKey($rgb) {
|
|||||||
return $r . '-' . $g . '-' . $b;
|
return $r . '-' . $g . '-' . $b;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hex($rgb) {
|
function hex($rgb): ?string
|
||||||
|
{
|
||||||
$r = $rgb['red'];
|
$r = $rgb['red'];
|
||||||
$g = $rgb['green'];
|
$g = $rgb['green'];
|
||||||
$b = $rgb['blue'];
|
$b = $rgb['blue'];
|
||||||
@@ -249,14 +280,16 @@ function hex($rgb) {
|
|||||||
/*
|
/*
|
||||||
* sign string with secret
|
* sign string with secret
|
||||||
*/
|
*/
|
||||||
function _sign($data, $secret, $algo = 'sha256') {
|
function _sign($data, $secret): string
|
||||||
|
{
|
||||||
return base64_encode(hash_hmac('sha256', $data, $secret));
|
return base64_encode(hash_hmac('sha256', $data, $secret));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get payload from jwt token
|
* get payload from jwt token
|
||||||
*/
|
*/
|
||||||
function _payload($token) {
|
function _payload($token)
|
||||||
|
{
|
||||||
$jwt = explode('.', $token);
|
$jwt = explode('.', $token);
|
||||||
return json_decode(base64_decode($jwt[0]));
|
return json_decode(base64_decode($jwt[0]));
|
||||||
}
|
}
|
||||||
@@ -264,7 +297,8 @@ function _payload($token) {
|
|||||||
/*
|
/*
|
||||||
* headless signed jwt token
|
* headless signed jwt token
|
||||||
*/
|
*/
|
||||||
function jwt_token($payload, $secret) {
|
function jwt_token($payload, $secret): string
|
||||||
|
{
|
||||||
$data = base64_encode(json_encode($payload));
|
$data = base64_encode(json_encode($payload));
|
||||||
|
|
||||||
return $data . '.' . _sign($data, $secret);
|
return $data . '.' . _sign($data, $secret);
|
||||||
@@ -273,7 +307,8 @@ function jwt_token($payload, $secret) {
|
|||||||
/*
|
/*
|
||||||
* validate token
|
* validate token
|
||||||
*/
|
*/
|
||||||
function jwt_validate($token, $secret) {
|
function jwt_validate($token, $secret): bool
|
||||||
|
{
|
||||||
$jwt = explode('.', $token);
|
$jwt = explode('.', $token);
|
||||||
if (sizeof($jwt) == 2 && $jwt[1] == _sign($jwt[0], $secret)) {
|
if (sizeof($jwt) == 2 && $jwt[1] == _sign($jwt[0], $secret)) {
|
||||||
if (isset(_payload($token)->exp)) {
|
if (isset(_payload($token)->exp)) {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -4,58 +4,68 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// kein direkter Zugriff
|
// kein direkter Zugriff
|
||||||
|
use JetBrains\PhpStorm\NoReturn;
|
||||||
|
use Joomla\CMS\Application\SiteApplication;
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\CMS\Log\Log;
|
||||||
|
use Joomla\CMS\Router\Route;
|
||||||
|
use Joomla\CMS\Uri\Uri;
|
||||||
|
use Joomla\CMS\User\User;
|
||||||
|
use Joomla\CMS\Version;
|
||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
require_once (JPATH_COMPONENT.DIRECTORY_SEPARATOR.'mathparser.php');
|
require_once JPATH_SITE . '/components/com_sportsmanager/mathparser.php';
|
||||||
|
require_once JPATH_SITE . '/components/com_sportsmanager/database/init.php';
|
||||||
|
|
||||||
function mathParserVerteilung($rohpunkte, $platz, $teilnehmer, $multiplikator) {
|
class MathParserSM extends MathParser
|
||||||
return max(round($multiplikator * round(((($rohpunkte - 1) * (-log($platz / $teilnehmer) * (1 - ($platz / $teilnehmer)))) / (-log(1 / $teilnehmer) * (1 - (1 / $teilnehmer)))) + 1)), 1);
|
{
|
||||||
}
|
|
||||||
|
|
||||||
function mathParserVerteilungR($rohpunkte, $platz, $teilnehmer, $multiplikator) {
|
|
||||||
return max(round(((($multiplikator * $rohpunkte - 1) * (-log($platz / $teilnehmer) * (1 - ($platz / $teilnehmer)))) / (-log(1 / $teilnehmer) * (1 - (1 / $teilnehmer)))) + 1), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
class MathParserSM extends MathParser {
|
|
||||||
// Verteilung nach Klostermann/Wahle
|
// Verteilung nach Klostermann/Wahle
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
MathParser::__construct();
|
{
|
||||||
|
parent::__construct();
|
||||||
|
try {
|
||||||
$this->createFunc("ROUND", 'round', 1);
|
$this->createFunc("ROUND", 'round', 1);
|
||||||
$this->createFunc("VERTEILUNG", 'mathParserVerteilung', 4);
|
$this->createFunc("VERTEILUNG", 'mathParserVerteilung', 4);
|
||||||
$this->createFunc("VERTEILUNGR", 'mathParserVerteilungR', 4);
|
$this->createFunc("VERTEILUNGR", 'mathParserVerteilungR', 4);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::add('an error occurred: ' . $e->getMessage(), Log::ERROR, 'com_sportsmanager');
|
||||||
|
throw new RuntimeException('An error occurred.', 500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function keinZugriff($login = FALSE) {
|
#[NoReturn] function keinZugriff($login = FALSE): void
|
||||||
|
{
|
||||||
if (isJson()) {
|
if (isJson()) {
|
||||||
abortWithError(401 . ' Unauthorized');
|
abortWithError(401 . ' Unauthorized');
|
||||||
}
|
}
|
||||||
if (!$login || JFactory::getUser()->id) {
|
if (!$login || Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id) {
|
||||||
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
|
Log::add('an error occurred', Log::ERROR, 'com_sportsmanager');
|
||||||
jexit();
|
throw new RuntimeException('An error occurred.', 500);
|
||||||
}
|
}
|
||||||
$version = new JVersion;
|
$version = new Version();
|
||||||
$joomla = $version->getShortVersion();
|
$joomla = $version->getShortVersion();
|
||||||
//$u =& JFactory::getURI();
|
$u = Uri::getInstance();
|
||||||
$u = JURI::getInstance();
|
|
||||||
$redirectUrl = urlencode(base64_encode($u->toString()));
|
$redirectUrl = urlencode(base64_encode($u->toString()));
|
||||||
$redirectUrl = '&return='.$redirectUrl;
|
$redirectUrl = '&return=' . $redirectUrl;
|
||||||
$joomlaLoginUrl = 'index.php?option=' . (substr($joomla, 0, 3) != '1.5' ? 'com_users' : 'com_user') . '&view=login';
|
$joomlaLoginUrl = 'index.php?option=' . (!str_starts_with($joomla, '1.5') ? 'com_users' : 'com_user') . '&view=login';
|
||||||
$finalUrl = $joomlaLoginUrl . $redirectUrl;
|
$finalUrl = $joomlaLoginUrl . $redirectUrl;
|
||||||
$app = JFactory::getApplication();
|
$app = Factory::getContainer()->get(SiteApplication::class);
|
||||||
$app->redirect(JRoute::_($finalUrl));
|
$app->redirect(Route::_($finalUrl));
|
||||||
jexit();
|
jexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function bereinigterDateiname($dateiname) {
|
function bereinigterDateiname($dateiname): array|string
|
||||||
|
{
|
||||||
$_convertTable = array(
|
$_convertTable = array(
|
||||||
'&' => 'and', '@' => 'at', '©' => 'c', '®' => 'r', 'À' => 'a',
|
'&' => 'and', '@' => 'at', '©' => 'c', '®' => 'r', 'À' => 'a',
|
||||||
'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'Å' => 'a', 'Æ' => 'ae','Ç' => 'c',
|
'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'Å' => 'a', 'Æ' => 'ae', 'Ç' => 'c',
|
||||||
'È' => 'e', 'É' => 'e', 'Ë' => 'e', 'Ì' => 'i', 'Í' => 'i', 'Î' => 'i',
|
'È' => 'e', 'É' => 'e', 'Ë' => 'e', 'Ì' => 'i', 'Í' => 'i', 'Î' => 'i',
|
||||||
'Ï' => 'i', 'Ò' => 'o', 'Ó' => 'o', 'Ô' => 'o', 'Õ' => 'o', 'Ö' => 'o',
|
'Ï' => 'i', 'Ò' => 'o', 'Ó' => 'o', 'Ô' => 'o', 'Õ' => 'o', 'Ö' => 'o',
|
||||||
'Ø' => 'o', 'Ù' => 'u', 'Ú' => 'u', 'Û' => 'u', 'Ü' => 'u', 'Ý' => 'y',
|
'Ø' => 'o', 'Ù' => 'u', 'Ú' => 'u', 'Û' => 'u', 'Ü' => 'u', 'Ý' => 'y',
|
||||||
'ß' => 'ss','à' => 'a', 'á' => 'a', 'â' => 'a', 'ä' => 'a', 'å' => 'a',
|
'ß' => 'ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ä' => 'a', 'å' => 'a',
|
||||||
'æ' => 'ae','ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e',
|
'æ' => 'ae', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e',
|
||||||
'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ò' => 'o', 'ó' => 'o',
|
'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ò' => 'o', 'ó' => 'o',
|
||||||
'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u',
|
'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u',
|
||||||
'û' => 'u', 'ü' => 'u', 'ý' => 'y', 'þ' => 'p', 'ÿ' => 'y', 'Ā' => 'a',
|
'û' => 'u', 'ü' => 'u', 'ý' => 'y', 'þ' => 'p', 'ÿ' => 'y', 'Ā' => 'a',
|
||||||
@@ -67,12 +77,12 @@ function bereinigterDateiname($dateiname) {
|
|||||||
'ğ' => 'g', 'Ġ' => 'g', 'ġ' => 'g', 'Ģ' => 'g', 'ģ' => 'g', 'Ĥ' => 'h',
|
'ğ' => 'g', 'Ġ' => 'g', 'ġ' => 'g', 'Ģ' => 'g', 'ģ' => 'g', 'Ĥ' => 'h',
|
||||||
'ĥ' => 'h', 'Ħ' => 'h', 'ħ' => 'h', 'Ĩ' => 'i', 'ĩ' => 'i', 'Ī' => 'i',
|
'ĥ' => 'h', 'Ħ' => 'h', 'ħ' => 'h', 'Ĩ' => 'i', 'ĩ' => 'i', 'Ī' => 'i',
|
||||||
'ī' => 'i', 'Ĭ' => 'i', 'ĭ' => 'i', 'Į' => 'i', 'į' => 'i', 'İ' => 'i',
|
'ī' => 'i', 'Ĭ' => 'i', 'ĭ' => 'i', 'Į' => 'i', 'į' => 'i', 'İ' => 'i',
|
||||||
'ı' => 'i', 'IJ' => 'ij','ij' => 'ij','Ĵ' => 'j', 'ĵ' => 'j', 'Ķ' => 'k',
|
'ı' => 'i', 'IJ' => 'ij', 'ij' => 'ij', 'Ĵ' => 'j', 'ĵ' => 'j', 'Ķ' => 'k',
|
||||||
'ķ' => 'k', 'ĸ' => 'k', 'Ĺ' => 'l', 'ĺ' => 'l', 'Ļ' => 'l', 'ļ' => 'l',
|
'ķ' => 'k', 'ĸ' => 'k', 'Ĺ' => 'l', 'ĺ' => 'l', 'Ļ' => 'l', 'ļ' => 'l',
|
||||||
'Ľ' => 'l', 'ľ' => 'l', 'Ŀ' => 'l', 'ŀ' => 'l', 'Ł' => 'l', 'ł' => 'l',
|
'Ľ' => 'l', 'ľ' => 'l', 'Ŀ' => 'l', 'ŀ' => 'l', 'Ł' => 'l', 'ł' => 'l',
|
||||||
'Ń' => 'n', 'ń' => 'n', 'Ņ' => 'n', 'ņ' => 'n', 'Ň' => 'n', 'ň' => 'n',
|
'Ń' => 'n', 'ń' => 'n', 'Ņ' => 'n', 'ņ' => 'n', 'Ň' => 'n', 'ň' => 'n',
|
||||||
'ʼn' => 'n', 'Ŋ' => 'n', 'ŋ' => 'n', 'Ō' => 'o', 'ō' => 'o', 'Ŏ' => 'o',
|
'ʼn' => 'n', 'Ŋ' => 'n', 'ŋ' => 'n', 'Ō' => 'o', 'ō' => 'o', 'Ŏ' => 'o',
|
||||||
'ŏ' => 'o', 'Ő' => 'o', 'ő' => 'o', 'Œ' => 'oe','œ' => 'oe','Ŕ' => 'r',
|
'ŏ' => 'o', 'Ő' => 'o', 'ő' => 'o', 'Œ' => 'oe', 'œ' => 'oe', 'Ŕ' => 'r',
|
||||||
'ŕ' => 'r', 'Ŗ' => 'r', 'ŗ' => 'r', 'Ř' => 'r', 'ř' => 'r', 'Ś' => 's',
|
'ŕ' => 'r', 'Ŗ' => 'r', 'ŗ' => 'r', 'Ř' => 'r', 'ř' => 'r', 'Ś' => 's',
|
||||||
'ś' => 's', 'Ŝ' => 's', 'ŝ' => 's', 'Ş' => 's', 'ş' => 's', 'Š' => 's',
|
'ś' => 's', 'Ŝ' => 's', 'ŝ' => 's', 'Ş' => 's', 'ş' => 's', 'Š' => 's',
|
||||||
'š' => 's', 'Ţ' => 't', 'ţ' => 't', 'Ť' => 't', 'ť' => 't', 'Ŧ' => 't',
|
'š' => 's', 'Ţ' => 't', 'ţ' => 't', 'Ť' => 't', 'ť' => 't', 'Ŧ' => 't',
|
||||||
@@ -84,19 +94,19 @@ function bereinigterDateiname($dateiname) {
|
|||||||
'ư' => 'u', 'Ǎ' => 'a', 'ǎ' => 'a', 'Ǐ' => 'i', 'ǐ' => 'i', 'Ǒ' => 'o',
|
'ư' => 'u', 'Ǎ' => 'a', 'ǎ' => 'a', 'Ǐ' => 'i', 'ǐ' => 'i', 'Ǒ' => 'o',
|
||||||
'ǒ' => 'o', 'Ǔ' => 'u', 'ǔ' => 'u', 'Ǖ' => 'u', 'ǖ' => 'u', 'Ǘ' => 'u',
|
'ǒ' => 'o', 'Ǔ' => 'u', 'ǔ' => 'u', 'Ǖ' => 'u', 'ǖ' => 'u', 'Ǘ' => 'u',
|
||||||
'ǘ' => 'u', 'Ǚ' => 'u', 'ǚ' => 'u', 'Ǜ' => 'u', 'ǜ' => 'u', 'Ǻ' => 'a',
|
'ǘ' => 'u', 'Ǚ' => 'u', 'ǚ' => 'u', 'Ǜ' => 'u', 'ǜ' => 'u', 'Ǻ' => 'a',
|
||||||
'ǻ' => 'a', 'Ǽ' => 'ae','ǽ' => 'ae','Ǿ' => 'o', 'ǿ' => 'o', 'ə' => 'e',
|
'ǻ' => 'a', 'Ǽ' => 'ae', 'ǽ' => 'ae', 'Ǿ' => 'o', 'ǿ' => 'o', 'ə' => 'e',
|
||||||
'Ё' => 'jo','Є' => 'e', 'І' => 'i', 'Ї' => 'i', 'А' => 'a', 'Б' => 'b',
|
'Ё' => 'jo', 'Є' => 'e', 'І' => 'i', 'Ї' => 'i', 'А' => 'a', 'Б' => 'b',
|
||||||
'В' => 'v', 'Г' => 'g', 'Д' => 'd', 'Е' => 'e', 'Ж' => 'zh','З' => 'z',
|
'В' => 'v', 'Г' => 'g', 'Д' => 'd', 'Е' => 'e', 'Ж' => 'zh', 'З' => 'z',
|
||||||
'И' => 'i', 'Й' => 'j', 'К' => 'k', 'Л' => 'l', 'М' => 'm', 'Н' => 'n',
|
'И' => 'i', 'Й' => 'j', 'К' => 'k', 'Л' => 'l', 'М' => 'm', 'Н' => 'n',
|
||||||
'О' => 'o', 'П' => 'p', 'Р' => 'r', 'С' => 's', 'Т' => 't', 'У' => 'u',
|
'О' => 'o', 'П' => 'p', 'Р' => 'r', 'С' => 's', 'Т' => 't', 'У' => 'u',
|
||||||
'Ф' => 'f', 'Х' => 'h', 'Ц' => 'c', 'Ч' => 'ch','Ш' => 'sh','Щ' => 'sch',
|
'Ф' => 'f', 'Х' => 'h', 'Ц' => 'c', 'Ч' => 'ch', 'Ш' => 'sh', 'Щ' => 'sch',
|
||||||
'Ъ' => '-', 'Ы' => 'y', 'Ь' => '-', 'Э' => 'je','Ю' => 'ju','Я' => 'ja',
|
'Ъ' => '-', 'Ы' => 'y', 'Ь' => '-', 'Э' => 'je', 'Ю' => 'ju', 'Я' => 'ja',
|
||||||
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e',
|
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e',
|
||||||
'ж' => 'zh','з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l',
|
'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l',
|
||||||
'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's',
|
'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's',
|
||||||
'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch',
|
'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch',
|
||||||
'ш' => 'sh','щ' => 'sch','ъ' => '-','ы' => 'y', 'ь' => '-', 'э' => 'je',
|
'ш' => 'sh', 'щ' => 'sch', 'ъ' => '-', 'ы' => 'y', 'ь' => '-', 'э' => 'je',
|
||||||
'ю' => 'ju','я' => 'ja','ё' => 'jo','є' => 'e', 'і' => 'i', 'ї' => 'i',
|
'ю' => 'ju', 'я' => 'ja', 'ё' => 'jo', 'є' => 'e', 'і' => 'i', 'ї' => 'i',
|
||||||
'Ґ' => 'g', 'ґ' => 'g', 'א' => 'a', 'ב' => 'b', 'ג' => 'g', 'ד' => 'd',
|
'Ґ' => 'g', 'ґ' => 'g', 'א' => 'a', 'ב' => 'b', 'ג' => 'g', 'ד' => 'd',
|
||||||
'ה' => 'h', 'ו' => 'v', 'ז' => 'z', 'ח' => 'h', 'ט' => 't', 'י' => 'i',
|
'ה' => 'h', 'ו' => 'v', 'ז' => 'z', 'ח' => 'h', 'ט' => 't', 'י' => 'i',
|
||||||
'ך' => 'k', 'כ' => 'k', 'ל' => 'l', 'ם' => 'm', 'מ' => 'm', 'ן' => 'n',
|
'ך' => 'k', 'כ' => 'k', 'ל' => 'l', 'ם' => 'm', 'מ' => 'm', 'ן' => 'n',
|
||||||
@@ -104,65 +114,69 @@ function bereinigterDateiname($dateiname) {
|
|||||||
'צ' => 'c', 'ק' => 'q', 'ר' => 'r', 'ש' => 'w', 'ת' => 't', '™' => 'tm',
|
'צ' => 'c', 'ק' => 'q', 'ר' => 'r', 'ש' => 'w', 'ת' => 't', '™' => 'tm',
|
||||||
);
|
);
|
||||||
$bad = array_merge(
|
$bad = array_merge(
|
||||||
array_map('chr', range(0,31)),
|
array_map('chr', range(0, 31)),
|
||||||
array("<", ">", ":", '"', "/", "\\", "|", "?", "*"));
|
array("<", ">", ":", '"', "/", "\\", "|", "?", "*"));
|
||||||
|
|
||||||
return str_replace($bad, "", strtr($dateiname, $_convertTable));
|
return str_replace($bad, "", strtr($dateiname, $_convertTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMinMemoryLimit($memDestSize) {
|
function setMinMemoryLimit($memDestSize): void
|
||||||
|
{
|
||||||
if (getBytes(ini_get('memory_limit')) < getBytes($memDestSize))
|
if (getBytes(ini_get('memory_limit')) < getBytes($memDestSize))
|
||||||
ini_set('memory_limit', $memDestSize);
|
ini_set('memory_limit', $memDestSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBytes($val) {
|
function getBytes($val): int|string
|
||||||
|
{
|
||||||
$val = trim($val);
|
$val = trim($val);
|
||||||
$numeric = substr($val, 0, strlen($val) -1);
|
$numeric = substr($val, 0, strlen($val) - 1);
|
||||||
$last = strtolower($val[strlen($val) - 1]);
|
$last = strtolower($val[strlen($val) - 1]);
|
||||||
switch($last) {
|
switch ($last) {
|
||||||
// The 'G' modifier is available since PHP 5.1.0
|
// The 'G' modifier is available since PHP 5.1.0
|
||||||
case 'g':
|
|
||||||
$numeric *= 1024;
|
|
||||||
case 'm':
|
case 'm':
|
||||||
$numeric *= 1024;
|
case 'g':
|
||||||
case 'k':
|
case 'k':
|
||||||
$numeric *= 1024;
|
$numeric *= 1024;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $numeric;
|
return $numeric;
|
||||||
}
|
}
|
||||||
|
|
||||||
function encrypt($str, $key){
|
function encrypt($str, $key): string
|
||||||
$result="";
|
{
|
||||||
for($i=0; $i<strlen($str); $i++) {
|
$result = "";
|
||||||
|
for ($i = 0; $i < strlen($str); $i++) {
|
||||||
$char = substr($str, $i, 1);
|
$char = substr($str, $i, 1);
|
||||||
$keychar = substr($key, ($i % strlen($key))-1, 1);
|
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
|
||||||
$char = chr(ord($char)+ord($keychar));
|
$char = chr(ord($char) + ord($keychar));
|
||||||
$result.=$char;
|
$result .= $char;
|
||||||
}
|
}
|
||||||
return base64_encode($result);
|
return base64_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function decrypt($str, $key){
|
function decrypt($str, $key): string
|
||||||
|
{
|
||||||
$str = base64_decode($str);
|
$str = base64_decode($str);
|
||||||
$result="";
|
$result = "";
|
||||||
for($i=0; $i<strlen($str); $i++) {
|
for ($i = 0; $i < strlen($str); $i++) {
|
||||||
$char = substr($str, $i, 1);
|
$char = substr($str, $i, 1);
|
||||||
$keychar = substr($key, ($i % strlen($key))-1, 1);
|
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
|
||||||
$char = chr(ord($char)-ord($keychar));
|
$char = chr(ord($char) - ord($keychar));
|
||||||
$result.=$char;
|
$result .= $char;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function individualwettbewerbFilter($prefix) {
|
function individualwettbewerbFilter($prefix): string
|
||||||
$db =& getDatabase();
|
{
|
||||||
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id;
|
$user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
|
||||||
return " " . $prefix . " (SELECT berechtigt_individualwettbewerb_id FROM #__sportsmanager_berechtigt_fuer_individualwettbewerb INNER JOIN #__sportsmanager_individualwettbewerb ON individualwettbewerb_id = berechtigt_individualwettbewerb_id WHERE berechtigt_user_id = $user_id) ";
|
return " " . $prefix . " (SELECT berechtigt_individualwettbewerb_id FROM #__sportsmanager_berechtigt_fuer_individualwettbewerb INNER JOIN #__sportsmanager_individualwettbewerb ON individualwettbewerb_id = berechtigt_individualwettbewerb_id WHERE berechtigt_user_id = $user_id) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
function kategorieFilter($prefix, $suffix = "") {
|
function kategorieFilter($prefix, $suffix = ""): string
|
||||||
|
{
|
||||||
global $params;
|
global $params;
|
||||||
$kategorien = explode(",", $params->get( 'kategorien' ));
|
$kategorien = explode(",", $params->get('kategorien'));
|
||||||
$filter = "";
|
$filter = "";
|
||||||
foreach ($kategorien as $s) {
|
foreach ($kategorien as $s) {
|
||||||
$kategorie = intval(trim($s));
|
$kategorie = intval(trim($s));
|
||||||
@@ -175,76 +189,78 @@ function kategorieFilter($prefix, $suffix = "") {
|
|||||||
return empty($filter) ? "" : (" " . $prefix . " (" . $filter . ") " . $suffix);
|
return empty($filter) ? "" : (" " . $prefix . " (" . $filter . ") " . $suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
function turnierFilter($prefix) {
|
function turnierFilter($prefix): string
|
||||||
$db =& getDatabase();
|
{
|
||||||
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id;
|
$user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
|
||||||
return " " . $prefix . " (SELECT berechtigt_turnier_id FROM #__sportsmanager_berechtigt_fuer_turnier WHERE berechtigt_user_id = $user_id AND DATEDIFF(letzter_tag, NOW()) >= -14) ";
|
return " " . $prefix . " (SELECT berechtigt_turnier_id FROM #__sportsmanager_berechtigt_fuer_turnier WHERE berechtigt_user_id = $user_id AND DATEDIFF(letzter_tag, NOW()) >= -14) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
function vereinFilter($prefix) {
|
function vereinFilter($prefix): string
|
||||||
$db =& getDatabase();
|
{
|
||||||
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id;
|
$user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
|
||||||
return " " . $prefix . " (SELECT berechtigt_verein_id FROM #__sportsmanager_berechtigt_fuer_verein INNER JOIN #__sportsmanager_verein ON berechtigt_verein_id = verein_id WHERE berechtigt_user_id = $user_id AND NOT ausgetreten) ";
|
return " " . $prefix . " (SELECT berechtigt_verein_id FROM #__sportsmanager_berechtigt_fuer_verein INNER JOIN #__sportsmanager_verein ON berechtigt_verein_id = verein_id WHERE berechtigt_user_id = $user_id AND NOT ausgetreten) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
function veranstalterFilter($prefix) {
|
function veranstalterFilter($prefix): string
|
||||||
$db =& getDatabase();
|
{
|
||||||
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id;
|
$user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
|
||||||
return " " . $prefix . " (SELECT berechtigt_veranstalter_id FROM #__sportsmanager_berechtigt_fuer_veranstalter WHERE berechtigt_user_id = $user_id) ";
|
return " " . $prefix . " (SELECT berechtigt_veranstalter_id FROM #__sportsmanager_berechtigt_fuer_veranstalter WHERE berechtigt_user_id = $user_id) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
function veranstaltungFilter($prefix) {
|
function veranstaltungFilter($prefix): string
|
||||||
$db =& getDatabase();
|
{
|
||||||
$user_id = isExternalDatabase() ? 0 : JFactory::getUser()->id;
|
$user_id = isExternalDatabase() ? 0 : Factory::getContainer()->get(SiteApplication::class)->getIdentity()->id;
|
||||||
return " " . $prefix . " (SELECT berechtigt_veranstaltung_id FROM #__sportsmanager_berechtigt_fuer_veranstaltung INNER JOIN #__sportsmanager_veranstaltung ON veranstaltung_id = berechtigt_veranstaltung_id WHERE berechtigt_user_id = $user_id AND DATEDIFF(letzter_tag, NOW()) >= -14) ";
|
return " " . $prefix . " (SELECT berechtigt_veranstaltung_id FROM #__sportsmanager_berechtigt_fuer_veranstaltung INNER JOIN #__sportsmanager_veranstaltung ON veranstaltung_id = berechtigt_veranstaltung_id WHERE berechtigt_user_id = $user_id AND DATEDIFF(letzter_tag, NOW()) >= -14) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechnet Datum zum Montag der ersten Kalenderwoche eines Jahres
|
// Berechnet Datum zum Montag der ersten Kalenderwoche eines Jahres
|
||||||
function firstkw($jahr) {
|
function firstkw($jahr): bool|int
|
||||||
$erster = mktime(0,0,0,1,1,$jahr);
|
{
|
||||||
$wtag = date('w',$erster);
|
$erster = mktime(0, 0, 0, 1, 1, $jahr);
|
||||||
|
$wtag = date('w', $erster);
|
||||||
if ($wtag <= 4) {
|
if ($wtag <= 4) {
|
||||||
/**
|
/**
|
||||||
* Donnerstag oder kleiner: auf den Montag zurückrechnen.
|
* Donnerstag oder kleiner: auf den Montag zurückrechnen.
|
||||||
*/
|
*/
|
||||||
$montag = mktime(0,0,0,1,1-($wtag-1),$jahr);
|
$montag = mktime(0, 0, 0, 1, 1 - ($wtag - 1), $jahr);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
/**
|
/**
|
||||||
* auf den Montag nach vorne rechnen.
|
* auf den Montag nach vorne rechnen.
|
||||||
*/
|
*/
|
||||||
$montag = mktime(0,0,0,1,1+(7-$wtag+1),$jahr);
|
$montag = mktime(0, 0, 0, 1, 1 + (7 - $wtag + 1), $jahr);
|
||||||
}
|
}
|
||||||
return $montag;
|
return $montag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechnet Wochentag über Kalenderwoche, Jahr und Wochentag (0 = Montag, ..., 6 = Sonntag)
|
// Berechnet Wochentag über Kalenderwoche, Jahr und Wochentag (0 = Montag, ..., 6 = Sonntag)
|
||||||
function mondaykw($kw, $jahr, $weekday) {
|
function mondaykw($kw, $jahr, $weekday): bool|int
|
||||||
|
{
|
||||||
$firstmonday = firstkw($jahr);
|
$firstmonday = firstkw($jahr);
|
||||||
$mon_monat = date('m',$firstmonday);
|
$mon_monat = date('m', $firstmonday);
|
||||||
$mon_jahr = date('Y',$firstmonday);
|
$mon_jahr = date('Y', $firstmonday);
|
||||||
$mon_tage = date('d',$firstmonday);
|
$mon_tage = (int)date('d', $firstmonday);
|
||||||
$tage = ($kw-1)*7;
|
$tage = ($kw - 1) * 7;
|
||||||
$daykw = mktime(0,0,0,$mon_monat,$mon_tage+$tage+$weekday,$mon_jahr);
|
return mktime(0, 0, 0, $mon_monat, $mon_tage + $tage + $weekday, $mon_jahr);
|
||||||
return $daykw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berechnet Termin am Wochentag (0 = Montag, ..., 6 = Sonntag) in Kalenderwoche zum Datum
|
// Berechnet Termin am Wochentag (0 = Montag, ..., 6 = Sonntag) in Kalenderwoche zum Datum
|
||||||
function geaenderterWochentag($datum, $wochentag) {
|
function geaenderterWochentag($datum, $wochentag): bool|int
|
||||||
|
{
|
||||||
$wtag = date('w', $datum);
|
$wtag = date('w', $datum);
|
||||||
if ($wtag == 0) // Sonntag
|
if ($wtag == 0) // Sonntag
|
||||||
$wtag = 7;
|
$wtag = 7;
|
||||||
$mon_monat = date('m', $datum);
|
$mon_monat = date('m', $datum);
|
||||||
$mon_jahr = date('Y', $datum);
|
$mon_jahr = date('Y', $datum);
|
||||||
$mon_tage = date('d', $datum);
|
$mon_tage = (int)date('d', $datum);
|
||||||
return mktime(0,0,0, $mon_monat, $mon_tage + 1 - $wtag + $wochentag, $mon_jahr);
|
return mktime(0, 0, 0, $mon_monat, $mon_tage + 1 - $wtag + $wochentag, $mon_jahr);
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalisiertesDatum($datum) {
|
function normalisiertesDatum($datum): ?string
|
||||||
|
{
|
||||||
if ($datum == NULL)
|
if ($datum == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (strpos($datum, "-") !== false)
|
if (str_contains($datum, "-"))
|
||||||
$trennzeichen = "-";
|
$trennzeichen = "-";
|
||||||
else
|
else
|
||||||
$trennzeichen = ".";
|
$trennzeichen = ".";
|
||||||
@@ -258,37 +274,35 @@ function normalisiertesDatum($datum) {
|
|||||||
$jahr = intval(substr($s, 0, 4));
|
$jahr = intval(substr($s, 0, 4));
|
||||||
$monat = intval(substr($s, 4, 2));
|
$monat = intval(substr($s, 4, 2));
|
||||||
$tag = intval(substr($s, 6, 2));
|
$tag = intval(substr($s, 6, 2));
|
||||||
}
|
} else if ($n == 3) {
|
||||||
else if ($n == 3) {
|
|
||||||
if ($trennzeichen != ".") {
|
if ($trennzeichen != ".") {
|
||||||
$jahr = intval($t[0]);
|
$jahr = intval($t[0]);
|
||||||
if (strlen($t[0]) <= 2)
|
if (strlen($t[0]) <= 2)
|
||||||
$jahr += 1900;
|
$jahr += 1900;
|
||||||
$monat = intval($t[1]);
|
$monat = intval($t[1]);
|
||||||
$tag = intval($t[2]);
|
$tag = intval($t[2]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$tag = intval($t[0]);
|
$tag = intval($t[0]);
|
||||||
$monat = intval($t[1]);
|
$monat = intval($t[1]);
|
||||||
$jahr = intval($t[2]);
|
$jahr = intval($t[2]);
|
||||||
if (strlen($t[2]) <= 2)
|
if (strlen($t[2]) <= 2)
|
||||||
$jahr += 1900;
|
$jahr += 1900;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!checkdate($monat, $tag, $jahr))
|
if (!checkdate($monat, $tag, $jahr))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return sprintf("%04d-%02d-%02d", $jahr, $monat, $tag);;
|
return sprintf("%04d-%02d-%02d", $jahr, $monat, $tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalisierteUhrzeit($uhrzeit) {
|
function normalisierteUhrzeit($uhrzeit): ?string
|
||||||
|
{
|
||||||
if ($uhrzeit == NULL)
|
if ($uhrzeit == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (strpos($uhrzeit, "-") !== FALSE)
|
if (str_contains($uhrzeit, "-"))
|
||||||
$trennzeichen = "-";
|
$trennzeichen = "-";
|
||||||
else
|
else
|
||||||
$trennzeichen = ":";
|
$trennzeichen = ":";
|
||||||
@@ -303,22 +317,21 @@ function normalisierteUhrzeit($uhrzeit) {
|
|||||||
$stunden = intval(substr($s, 0, 2));
|
$stunden = intval(substr($s, 0, 2));
|
||||||
$minuten = intval(substr($s, 2, 2));
|
$minuten = intval(substr($s, 2, 2));
|
||||||
$sekunden = $len != 6 ? 0 : intval(substr($s, 4, 2));
|
$sekunden = $len != 6 ? 0 : intval(substr($s, 4, 2));
|
||||||
}
|
} else if ($n == 2 || $n == 3) {
|
||||||
else if ($n == 2 || $n == 3) {
|
|
||||||
$stunden = intval($t[0]);
|
$stunden = intval($t[0]);
|
||||||
$minuten = intval($t[1]);
|
$minuten = intval($t[1]);
|
||||||
$sekunden = $n != 3 ? 0 : intval($t[2]);
|
$sekunden = $n != 3 ? 0 : intval($t[2]);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ($stunden < 0 || $stunden > 23 || $minuten < 0 || $minuten > 59 || $sekunden < 0 || $sekunden > 59)
|
if ($stunden < 0 || $stunden > 23 || $minuten < 0 || $minuten > 59 || $sekunden < 0 || $sekunden > 59)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return sprintf("%02d:%02d:%02d", $stunden, $minuten, $sekunden);;
|
return sprintf("%02d:%02d:%02d", $stunden, $minuten, $sekunden);
|
||||||
}
|
}
|
||||||
|
|
||||||
function runden_detailliert_invers($runden) {
|
function runden_detailliert_invers($runden): ?string
|
||||||
|
{
|
||||||
if ($runden == null)
|
if ($runden == null)
|
||||||
return null;
|
return null;
|
||||||
$runden_invers = "";
|
$runden_invers = "";
|
||||||
@@ -332,7 +345,8 @@ function runden_detailliert_invers($runden) {
|
|||||||
return $runden_invers;
|
return $runden_invers;
|
||||||
}
|
}
|
||||||
|
|
||||||
function runden_detailliert_auswertung($runden) {
|
function runden_detailliert_auswertung($runden): array
|
||||||
|
{
|
||||||
$ergebnis = 0;
|
$ergebnis = 0;
|
||||||
$heim_saetze = 0;
|
$heim_saetze = 0;
|
||||||
$unentschieden_saetze = 0;
|
$unentschieden_saetze = 0;
|
||||||
@@ -362,29 +376,30 @@ function runden_detailliert_auswertung($runden) {
|
|||||||
|
|
||||||
// pass two file names
|
// pass two file names
|
||||||
// returns TRUE if files are the same, FALSE otherwise
|
// returns TRUE if files are the same, FALSE otherwise
|
||||||
function files_identical($fn1, $fn2) {
|
function files_identical($fn1, $fn2): bool
|
||||||
if(!is_file($fn1) || !is_file($fn2))
|
{
|
||||||
|
if (!is_file($fn1) || !is_file($fn2))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if(filesize($fn1) !== filesize($fn2))
|
if (filesize($fn1) !== filesize($fn2))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if(!$fp1 = fopen($fn1, 'rb'))
|
if (!$fp1 = fopen($fn1, 'rb'))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if(!$fp2 = fopen($fn2, 'rb')) {
|
if (!$fp2 = fopen($fn2, 'rb')) {
|
||||||
fclose($fp1);
|
fclose($fp1);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$same = TRUE;
|
$same = TRUE;
|
||||||
while (!feof($fp1) and !feof($fp2))
|
while (!feof($fp1) and !feof($fp2))
|
||||||
if(fread($fp1, 4096) !== fread($fp2, 4096)) {
|
if (fread($fp1, 4096) !== fread($fp2, 4096)) {
|
||||||
$same = FALSE;
|
$same = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(feof($fp1) !== feof($fp2))
|
if (feof($fp1) !== feof($fp2))
|
||||||
$same = FALSE;
|
$same = FALSE;
|
||||||
|
|
||||||
fclose($fp1);
|
fclose($fp1);
|
||||||
@@ -392,4 +407,4 @@ function files_identical($fn1, $fn2) {
|
|||||||
|
|
||||||
return $same;
|
return $same;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use JetBrains\PhpStorm\NoReturn;
|
||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
require_once(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'views/sportsmanager/view_tools.php');
|
require_once JPATH_SITE . '/components/com_sportsmanager/views/sportsmanager/view_tools.php';
|
||||||
|
require_once JPATH_SITE . '/components/com_sportsmanager/util/image.php';
|
||||||
|
|
||||||
|
|
||||||
class JSON_sportsmanager {
|
class JSON_sportsmanager
|
||||||
|
{
|
||||||
|
|
||||||
static function mannschaften($veranstaltung, $rows) {
|
static function mannschaften($veranstaltung, $rows): array
|
||||||
|
{
|
||||||
$teams = [];
|
$teams = [];
|
||||||
foreach ($rows as $team) {
|
foreach ($rows as $team) {
|
||||||
$team->teambild = teamImage($team->team_id, $team->verein_id);
|
$team->teambild = teamImage($team->team_id, $team->verein_id);
|
||||||
@@ -22,7 +28,8 @@ class JSON_sportsmanager {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function tabelleAnzeigen($veranstaltung, $modus, $teams, $spieltag, $spieltage, $alleine_angezeigt, $praesentation) {
|
static function tabelleAnzeigen($modus, $teams): array
|
||||||
|
{
|
||||||
foreach ($teams as $team) {
|
foreach ($teams as $team) {
|
||||||
$team->teambild = teamImage($team->team_id, $team->verein_id);
|
$team->teambild = teamImage($team->team_id, $team->verein_id);
|
||||||
}
|
}
|
||||||
@@ -33,8 +40,9 @@ class JSON_sportsmanager {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function tabelleEigeneAnzeigen($veranstaltung, $modus, $teams, $alleine_angezeigt, $praesentation) {
|
static function tabelleEigeneAnzeigen($modus, $teams): array
|
||||||
foreach($teams as $team) {
|
{
|
||||||
|
foreach ($teams as $team) {
|
||||||
$team->teambild = teamImage($team->team_id, $team->verein_id);
|
$team->teambild = teamImage($team->team_id, $team->verein_id);
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
@@ -43,7 +51,8 @@ class JSON_sportsmanager {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function _getPlayerDetails($game, $home_player_map, $away_player_map) {
|
static function _getPlayerDetails($game, $home_player_map, $away_player_map): void
|
||||||
|
{
|
||||||
// TODO dynamisch machen
|
// TODO dynamisch machen
|
||||||
$game->heim_spieler_1_vorname = isset($home_player_map[$game->heim_spieler_1_id])
|
$game->heim_spieler_1_vorname = isset($home_player_map[$game->heim_spieler_1_id])
|
||||||
? $home_player_map[$game->heim_spieler_1_id]->vorname
|
? $home_player_map[$game->heim_spieler_1_id]->vorname
|
||||||
@@ -87,7 +96,8 @@ class JSON_sportsmanager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function adminEditBegegnungSpielplan($bestaetigen, $veranstaltung, $begegnung, $heim_team, $gast_team, $spiele, $heim_spieler, $gast_spieler, $teamspiel_modus, $encrypted_pin, $count_verlegen_aktionen, $erneut_oeffnen, $aus_uebersicht) {
|
static function adminEditBegegnungSpielplan($bestaetigen, $veranstaltung, $begegnung, $heim_team, $gast_team, $spiele, $heim_spieler, $gast_spieler, $teamspiel_modus): array
|
||||||
|
{
|
||||||
$heim_team->teambild = teamImage($heim_team->team_id, $heim_team->verein_id);
|
$heim_team->teambild = teamImage($heim_team->team_id, $heim_team->verein_id);
|
||||||
$gast_team->teambild = teamImage($gast_team->team_id, $gast_team->verein_id);
|
$gast_team->teambild = teamImage($gast_team->team_id, $gast_team->verein_id);
|
||||||
$heim_spieler_map = [];
|
$heim_spieler_map = [];
|
||||||
@@ -119,7 +129,8 @@ class JSON_sportsmanager {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function mannschaftDetails($veranstaltung, $team, $mitglieder, $mailverteiler, $mitglieder_statistiken, $teamansprechpartner, $begegnungen, $vorheriges_team_id, $naechstes_team_id, $team_moderator, $details_anzeigen, $ansprechpartner_anzeigen, $weitere_veranstaltungen, $veranstaltungsbezeichnungen, $spielberechtigungen, $ansicht_vereinigt, $ist_vergangen) {
|
static function mannschaftDetails($veranstaltung, $team, $mitglieder, $teamansprechpartner, $begegnungen, $ansprechpartner_anzeigen, $veranstaltungsbezeichnungen): array
|
||||||
|
{
|
||||||
global $sportsmanager_joomla_path;
|
global $sportsmanager_joomla_path;
|
||||||
global $sportsmanager_joomla_url;
|
global $sportsmanager_joomla_url;
|
||||||
|
|
||||||
@@ -156,25 +167,27 @@ class JSON_sportsmanager {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function JSON($data, $meta = NULL) {
|
#[NoReturn] static function JSON($data, $meta = NULL): void
|
||||||
|
{
|
||||||
$response = [
|
$response = [
|
||||||
'data' => $data
|
'data' => $data
|
||||||
];
|
];
|
||||||
if ($meta != NULL) {
|
if ($meta != NULL) {
|
||||||
$response['meta'] = $meta;
|
$response['meta'] = $meta;
|
||||||
}
|
}
|
||||||
header('Content-Type: application/json; charset=utf-8', true);
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
jexit();
|
jexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function spielerstatistik($spielerstatistik, $spielerstatistik_punkte, $allein_angezeigt, $filter_saison_id, $vorherige_spielerstatistik_id, $naechste_spielerstatistik_id, $details_anzeigen) {
|
#[NoReturn] static function spielerstatistik($spielerstatistik_punkte): void
|
||||||
|
{
|
||||||
$rank = 1;
|
$rank = 1;
|
||||||
foreach ($spielerstatistik_punkte as $s) {
|
foreach ($spielerstatistik_punkte as $s) {
|
||||||
$s->spieler_bild = playerImage($s->spieler_id, $s->geschlecht);
|
$s->spieler_bild = playerImage($s->spieler_id, $s->geschlecht);
|
||||||
$s->spieler_2_bild= playerImage($s->spieler_2_id, $s->geschlecht_2);
|
$s->spieler_2_bild = playerImage($s->spieler_2_id, $s->geschlecht_2);
|
||||||
$s->quote = ($s->spielpunkte_gewonnen > 0 || $s->spielpunkte_verloren > 0)
|
$s->quote = ($s->spielpunkte_gewonnen > 0 || $s->spielpunkte_verloren > 0)
|
||||||
? round($s->spielpunkte_gewonnen * 100 / ($s->spielpunkte_gewonnen + $s->spielpunkte_verloren), 0) . '%'
|
? round($s->spielpunkte_gewonnen * 100 / ($s->spielpunkte_gewonnen + $s->spielpunkte_verloren)) . '%'
|
||||||
: '-';
|
: '-';
|
||||||
$s->rank = '' . $rank;
|
$s->rank = '' . $rank;
|
||||||
$rank++;
|
$rank++;
|
||||||
@@ -182,23 +195,24 @@ class JSON_sportsmanager {
|
|||||||
self::JSON($spielerstatistik_punkte);
|
self::JSON($spielerstatistik_punkte);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function spielerDetails($spieler, $vereine, $veranstalter, $spieler_elo_verlauf_einzel, $spieler_elo_verlauf_doppel, $spielerNamen, $teamNamen, $veranstaltungBezeichnungen, $turnierdisziplinBezeichnungen, $individualwettbewerbBezeichnungen, $ranglistenplatzierungen, $turnierplatzierungen, $teams, $sortierung, $vorheriger_spieler_id, $naechster_spieler_id, $elo_detailliert, $statistik, $beginn, $kategorie, $einstufungen, $filter, $veranstaltungid, $veranstalterid, $einstufungid, $unabhaengige_ansicht, $details_anzeigen) {
|
#[NoReturn] static function spielerDetails($spieler, $vereine, $veranstalter, $spieler_elo_verlauf_einzel, $spieler_elo_verlauf_doppel, $spielerNamen, $teamNamen, $veranstaltungBezeichnungen, $turnierdisziplinBezeichnungen, $individualwettbewerbBezeichnungen, $ranglistenplatzierungen, $turnierplatzierungen, $teams, $elo_detailliert, $statistik, $einstufungen): void
|
||||||
|
{
|
||||||
$letzte_einzel = [];
|
$letzte_einzel = [];
|
||||||
$spieler->bild = playerImage($spieler->spieler_id, $spieler->geschlecht);
|
$spieler->bild = playerImage($spieler->spieler_id, $spieler->geschlecht);
|
||||||
for ($i = sizeof($spieler_elo_verlauf_einzel) - 1; $i >= max(sizeof($spieler_elo_verlauf_einzel)-10, 0); $i--) {
|
for ($i = sizeof($spieler_elo_verlauf_einzel) - 1; $i >= max(sizeof($spieler_elo_verlauf_einzel) - 10, 0); $i--) {
|
||||||
$e = $spieler_elo_verlauf_einzel[$i];
|
$e = $spieler_elo_verlauf_einzel[$i];
|
||||||
$letzte_einzel[] = [
|
$letzte_einzel[] = [
|
||||||
'datum' => $e['z'],
|
'datum' => $e['z'],
|
||||||
'spieler_1' => isset($spielerNamen[$e['h1']]) ? [
|
'spieler_1' => isset($spielerNamen[$e['h1']]) ? [
|
||||||
'spieler_id' => $e['h1'],
|
'spieler_id' => $e['h1'],
|
||||||
'bild' => playerImage($e['h1'], 'M'),
|
'bild' => playerImage($e['h1'], 'M'),
|
||||||
'vorname' => explode(', ',$spielerNamen[$e['h1']])[1],
|
'vorname' => explode(', ', $spielerNamen[$e['h1']])[1],
|
||||||
'nachname' => explode(', ',$spielerNamen[$e['h1']])[0],
|
'nachname' => explode(', ', $spielerNamen[$e['h1']])[0],
|
||||||
] : NULL,
|
] : NULL,
|
||||||
'spieler_team' => isset($e['th']) ? [
|
'spieler_team' => isset($e['th']) ? [
|
||||||
'id' => $e['th'],
|
'id' => $e['th'],
|
||||||
'name' => $teamNamen[$e['th']],
|
'name' => $teamNamen[$e['th']],
|
||||||
]: NULL,
|
] : NULL,
|
||||||
'gegner_1' => isset($spielerNamen[$e['g1']]) ? [
|
'gegner_1' => isset($spielerNamen[$e['g1']]) ? [
|
||||||
'spieler_id' => $e['g1'],
|
'spieler_id' => $e['g1'],
|
||||||
'bild' => playerImage($e['g1'], 'M'),
|
'bild' => playerImage($e['g1'], 'M'),
|
||||||
@@ -252,7 +266,7 @@ class JSON_sportsmanager {
|
|||||||
'bild' => playerImage($d['g2'], 'M'),
|
'bild' => playerImage($d['g2'], 'M'),
|
||||||
'vorname' => explode(', ', $spielerNamen[$d['g2']])[1],
|
'vorname' => explode(', ', $spielerNamen[$d['g2']])[1],
|
||||||
'nachname' => explode(', ', $spielerNamen[$d['g2']])[0],
|
'nachname' => explode(', ', $spielerNamen[$d['g2']])[0],
|
||||||
]: NULL,
|
] : NULL,
|
||||||
'gegner_team' => isset($d['th']) && isset($d['tg']) ?
|
'gegner_team' => isset($d['th']) && isset($d['tg']) ?
|
||||||
[
|
[
|
||||||
'id' => $d['tg'],
|
'id' => $d['tg'],
|
||||||
@@ -272,7 +286,7 @@ class JSON_sportsmanager {
|
|||||||
'spieler' => $spieler,
|
'spieler' => $spieler,
|
||||||
'vereine' => $vereine,
|
'vereine' => $vereine,
|
||||||
'teams' => $teams,
|
'teams' => $teams,
|
||||||
'veranstalter'=> $veranstalter,
|
'veranstalter' => $veranstalter,
|
||||||
'ranglisten_platzierungen' => $ranglistenplatzierungen,
|
'ranglisten_platzierungen' => $ranglistenplatzierungen,
|
||||||
'turnier_platzierungen' => $turnierplatzierungen,
|
'turnier_platzierungen' => $turnierplatzierungen,
|
||||||
'statistik' => $statistik,
|
'statistik' => $statistik,
|
||||||
@@ -285,13 +299,14 @@ class JSON_sportsmanager {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function begegnungVerlegen($veranstaltung, $begegnung, $heim_team, $gast_team, $verlegen_aktionen, $berechtigt_fuer_akzeptieren, $aus_uebersicht, $vorschlagendes_team_id) {
|
#[NoReturn] static function begegnungVerlegen($veranstaltung, $verlegen_aktionen, $berechtigt_fuer_akzeptieren, $vorschlagendes_team_id): void
|
||||||
|
{
|
||||||
$letzte_aktionen = array();
|
$letzte_aktionen = array();
|
||||||
foreach ($verlegen_aktionen as $aktion) {
|
foreach ($verlegen_aktionen as $aktion) {
|
||||||
if ($aktion->aktion == 1 || $aktion->aktion == 5 || $aktion == 10) {
|
if ($aktion->aktion == 1 || $aktion->aktion == 5 || $aktion == 10) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
array_push($letzte_aktionen, $aktion);
|
$letzte_aktionen[] = $aktion;
|
||||||
}
|
}
|
||||||
$termine = array();
|
$termine = array();
|
||||||
if (count($letzte_aktionen) > 0) {
|
if (count($letzte_aktionen) > 0) {
|
||||||
@@ -300,7 +315,7 @@ class JSON_sportsmanager {
|
|||||||
if ($aktion->eingetragen != $eingetragen || $aktion->aktion != 0 || $aktion->zeitpunkt == NULL) {
|
if ($aktion->eingetragen != $eingetragen || $aktion->aktion != 0 || $aktion->zeitpunkt == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
array_push($termine, $aktion);
|
$termine[] = $aktion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,10 +331,10 @@ class JSON_sportsmanager {
|
|||||||
$anzahl_termine = $veranstaltung->termine_maximal == 0 ? 3 : $veranstaltung->termine_maximal;
|
$anzahl_termine = $veranstaltung->termine_maximal == 0 ? 3 : $veranstaltung->termine_maximal;
|
||||||
|
|
||||||
for ($termin = 1; $termin <= $anzahl_termine; $termin++) {
|
for ($termin = 1; $termin <= $anzahl_termine; $termin++) {
|
||||||
if (isset($termine[$termin-1])) {
|
if (isset($termine[$termin - 1])) {
|
||||||
$response[] = [
|
$response[] = [
|
||||||
'begegnung_historie_id' => $termine[$termin-1]->begegnung_historie_id,
|
'begegnung_historie_id' => $termine[$termin - 1]->begegnung_historie_id,
|
||||||
'zeitpunkt' => $termine[$termin-1]->zeitpunkt
|
'zeitpunkt' => $termine[$termin - 1]->zeitpunkt
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,7 +343,7 @@ class JSON_sportsmanager {
|
|||||||
'termine' => $response,
|
'termine' => $response,
|
||||||
'berechtigt_anfordern' => $berechtigt_anfordern,
|
'berechtigt_anfordern' => $berechtigt_anfordern,
|
||||||
'berechtigt_ablehnen' => $berechtigt_ablehnen,
|
'berechtigt_ablehnen' => $berechtigt_ablehnen,
|
||||||
'berechtigt_akzeptieren' => $berechtigt_fuer_akzeptieren ? TRUE : FALSE,
|
'berechtigt_akzeptieren' => (bool)$berechtigt_fuer_akzeptieren,
|
||||||
'termine_minimal' => $veranstaltung->termine_minimal,
|
'termine_minimal' => $veranstaltung->termine_minimal,
|
||||||
'termine_maximal' => $veranstaltung->termine_maximal,
|
'termine_maximal' => $veranstaltung->termine_maximal,
|
||||||
]);
|
]);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,29 +3,32 @@
|
|||||||
* Sports Manager (C) 2006-2020, Sven Nickel
|
* Sports Manager (C) 2006-2020, Sven Nickel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Joomla\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Router\Route;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
use Joomla\CMS\Uri\Uri;
|
||||||
|
|
||||||
// kein direkter Zugriff
|
// kein direkter Zugriff
|
||||||
defined("_JEXEC") or die("Restricted access");
|
defined("_JEXEC") or die("Restricted access");
|
||||||
|
|
||||||
function htmlentities_utf8($s) {
|
function htmlentities_utf8($s): string
|
||||||
|
{
|
||||||
return htmlentities($s, ENT_QUOTES, "UTF-8");
|
return htmlentities($s, ENT_QUOTES, "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
function htmlentities_noquotes_utf8($s) {
|
function addOnLoad($function): void
|
||||||
return htmlentities($s, ENT_NOQUOTES, "UTF-8");
|
{
|
||||||
}
|
|
||||||
|
|
||||||
function addOnLoad($function) {
|
|
||||||
?>
|
?>
|
||||||
<script language="JavaScript">
|
<script language="JavaScript">
|
||||||
function addLoadEvent(func) {
|
function addLoadEvent(func) {
|
||||||
var oldonload = window.onload;
|
const oldOnload = window.onload;
|
||||||
if (typeof window.onload != 'function') {
|
if (typeof window.onload != 'function') {
|
||||||
window.onload = func;
|
window.onload = func;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
if (oldonload) {
|
if (oldOnload) {
|
||||||
oldonload();
|
oldOnload();
|
||||||
}
|
}
|
||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
@@ -37,17 +40,17 @@ function addOnLoad($function) {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function SportsManagerURL($weitereParameter = null, $ssl = 0)
|
function SportsManagerURL($weitereParameter = null, $ssl = 0): ?string
|
||||||
{
|
{
|
||||||
$urlPath = handleFilter($weitereParameter);
|
$urlPath = handleFilter($weitereParameter);
|
||||||
$joomlaBaseUrl = JUri::getInstance()->toString([
|
$joomlaBaseUrl = Uri::getInstance()->toString([
|
||||||
"scheme",
|
"scheme",
|
||||||
"host",
|
"host",
|
||||||
"port",
|
"port",
|
||||||
"path",
|
"path",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (strpos($joomlaBaseUrl, "?") !== false) {
|
if (str_contains($joomlaBaseUrl, "?")) {
|
||||||
// Base URL already contains a query string, append with '&'
|
// Base URL already contains a query string, append with '&'
|
||||||
$finalUrl = $joomlaBaseUrl . "&" . ltrim($urlPath, "&");
|
$finalUrl = $joomlaBaseUrl . "&" . ltrim($urlPath, "&");
|
||||||
} else {
|
} else {
|
||||||
@@ -55,15 +58,15 @@ function SportsManagerURL($weitereParameter = null, $ssl = 0)
|
|||||||
$finalUrl = $joomlaBaseUrl . "?" . ltrim($urlPath, "&");
|
$finalUrl = $joomlaBaseUrl . "?" . ltrim($urlPath, "&");
|
||||||
}
|
}
|
||||||
|
|
||||||
return \Joomla\CMS\Router\Route::_($finalUrl, false, $ssl);
|
return Route::_($finalUrl, false, $ssl);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleFilter($urlPart)
|
function handleFilter($urlPart)
|
||||||
{
|
{
|
||||||
// Check if both '&filter=' and '#' are present in the URL part
|
// Check if both '&filter=' and '#' are present in the URL part
|
||||||
if (
|
if (
|
||||||
strpos($urlPart, "&filter=") !== false &&
|
str_contains($urlPart, "&filter=") &&
|
||||||
strpos($urlPart, "#") !== false
|
str_contains($urlPart, "#")
|
||||||
) {
|
) {
|
||||||
// Split the string by '#' to remove the hash part
|
// Split the string by '#' to remove the hash part
|
||||||
$parts = explode("#", $urlPart, 2);
|
$parts = explode("#", $urlPart, 2);
|
||||||
@@ -76,9 +79,7 @@ function handleFilter($urlPart)
|
|||||||
unset($queryParams["filter"]);
|
unset($queryParams["filter"]);
|
||||||
|
|
||||||
// Rebuild the query string without the 'filter' parameter
|
// Rebuild the query string without the 'filter' parameter
|
||||||
$newQuery = http_build_query($queryParams);
|
return http_build_query($queryParams);
|
||||||
|
|
||||||
return $newQuery;
|
|
||||||
} else {
|
} else {
|
||||||
// Return the original URL part if either '&filter=' or '#' is not present
|
// Return the original URL part if either '&filter=' or '#' is not present
|
||||||
return $urlPart;
|
return $urlPart;
|
||||||
@@ -98,42 +99,27 @@ function hervorheben($titel) {
|
|||||||
return $titel . " *";
|
return $titel . " *";
|
||||||
}
|
}
|
||||||
|
|
||||||
function Laenderkennungen() {
|
function Laenderkennungen(): array
|
||||||
$kennungen = array("AUT", "BEL", "BUL", "CZE", "DEN", "FRA", "GBR", "GER", "LUX", "NED", "SUI", "USA");
|
{
|
||||||
|
return array("AUT", "BEL", "BUL", "CZE", "DEN", "FRA", "GBR", "GER", "LUX", "NED", "SUI", "USA");
|
||||||
return $kennungen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function rundenstufe($stufe) {
|
function rundenstufe($stufe): string
|
||||||
switch ($stufe) {
|
{
|
||||||
case 0:
|
return match ($stufe) {
|
||||||
$bezeichnung = JText::_("COM_SPORTSMANAGER_FINAL_RANKS");
|
0 => Text::_("COM_SPORTSMANAGER_FINAL_RANKS"),
|
||||||
break;
|
1 => Text::_("COM_SPORTSMANAGER_MAIN_ROUND"),
|
||||||
case 1:
|
2 => Text::_("COM_SPORTSMANAGER_ADDITIONAL_ROUND"),
|
||||||
$bezeichnung = JText::_("COM_SPORTSMANAGER_MAIN_ROUND");
|
3 => Text::_("COM_SPORTSMANAGER_2ND_ADDITIONAL_ROUND"),
|
||||||
break;
|
10 => Text::_("COM_SPORTSMANAGER_PRELIMINARY_ROUND"),
|
||||||
case 2:
|
20 => Text::_("COM_SPORTSMANAGER_REGISTRATIONS"),
|
||||||
$bezeichnung = JText::_("COM_SPORTSMANAGER_ADDITIONAL_ROUND");
|
default => "",
|
||||||
break;
|
};
|
||||||
case 3:
|
|
||||||
$bezeichnung = JText::_("COM_SPORTSMANAGER_2ND_ADDITIONAL_ROUND");
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
$bezeichnung = JText::_("COM_SPORTSMANAGER_PRELIMINARY_ROUND");
|
|
||||||
break;
|
|
||||||
case 20:
|
|
||||||
$bezeichnung = JText::_("COM_SPORTSMANAGER_REGISTRATIONS");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$bezeichnung = "";
|
|
||||||
} // switch
|
|
||||||
|
|
||||||
return $bezeichnung;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function StringsZusammenfassen($titel1, $titel2, $ersatz = null, $separator = " / ") {
|
function StringsZusammenfassen($titel1, $titel2, $ersatz = null, $separator = " / ") {
|
||||||
if ($ersatz == null) {
|
if ($ersatz == null) {
|
||||||
$ersatz = JText::_("COM_SPORTSMANAGER_NONE");
|
$ersatz = Text::_("COM_SPORTSMANAGER_NONE");
|
||||||
}
|
}
|
||||||
$t1 = NichtLeererString($titel1, $ersatz);
|
$t1 = NichtLeererString($titel1, $ersatz);
|
||||||
$t2 = NichtLeererString($titel2, $ersatz);
|
$t2 = NichtLeererString($titel2, $ersatz);
|
||||||
@@ -144,76 +130,59 @@ function StringsZusammenfassen($titel1, $titel2, $ersatz = null, $separator = "
|
|||||||
function Rundenbezeichnung($runde, $spieltag = false, $bezeichnung_verstecken = false, $kurzform = false) {
|
function Rundenbezeichnung($runde, $spieltag = false, $bezeichnung_verstecken = false, $kurzform = false) {
|
||||||
if ($kurzform) {
|
if ($kurzform) {
|
||||||
if ($runde >= 20000)
|
if ($runde >= 20000)
|
||||||
return JText::sprintf("COM_SPORTSMANAGER_PLACE_FROM_TO_SHORTCUT", 99 - $runde % 100, 99 - floor(($runde - 20000) / 100) + 99 - ($runde % 100));
|
return Text::sprintf("COM_SPORTSMANAGER_PLACE_FROM_TO_SHORTCUT", 99 - $runde % 100, 99 - floor(($runde - 20000) / 100) + 99 - ($runde % 100));
|
||||||
|
|
||||||
switch ($runde) {
|
return match ($runde) {
|
||||||
case 0:
|
0 => $spieltag
|
||||||
return $spieltag
|
? Text::_("COM_SPORTSMANAGER_MATCH_DAY_NONE")
|
||||||
? JText::_("COM_SPORTSMANAGER_MATCH_DAY_NONE")
|
: Text::_("COM_SPORTSMANAGER_ROUND_NONE"),
|
||||||
: JText::_("COM_SPORTSMANAGER_ROUND_NONE");
|
19999 => Text::_("COM_SPORTSMANAGER_FINAL_SHORTCUT"),
|
||||||
case 19999:
|
19998 => Text::_("COM_SPORTSMANAGER_3RD_PLACE_SHORTCUT"),
|
||||||
return JText::_("COM_SPORTSMANAGER_FINAL_SHORTCUT");
|
19997 => Text::_("COM_SPORTSMANAGER_HALF_FINAL_SHORTCUT"),
|
||||||
case 19998:
|
19996 => Text::_("COM_SPORTSMANAGER_QUARTER_FINAL_SHORTCUT"),
|
||||||
return JText::_("COM_SPORTSMANAGER_3RD_PLACE_SHORTCUT");
|
19995 => Text::_("COM_SPORTSMANAGER_ROUND_OF_16_SHORTCUT"),
|
||||||
case 19997:
|
19994 => Text::_("COM_SPORTSMANAGER_ROUND_OF_32_SHORTCUT"),
|
||||||
return JText::_("COM_SPORTSMANAGER_HALF_FINAL_SHORTCUT");
|
19993 => Text::_("COM_SPORTSMANAGER_ROUND_OF_64_SHORTCUT"),
|
||||||
case 19996:
|
19992 => Text::_("COM_SPORTSMANAGER_ROUND_OF_128_SHORTCUT"),
|
||||||
return JText::_("COM_SPORTSMANAGER_QUARTER_FINAL_SHORTCUT");
|
default => $bezeichnung_verstecken ? $runde : Text::sprintf($spieltag ? "COM_SPORTSMANAGER_MATCH_DAY_NR_SHORTCUT" : "COM_SPORTSMANAGER_ROUND_NR_SHORTCUT", $runde),
|
||||||
case 19995:
|
};
|
||||||
return JText::_("COM_SPORTSMANAGER_ROUND_OF_16_SHORTCUT");
|
|
||||||
case 19994:
|
|
||||||
return JText::_("COM_SPORTSMANAGER_ROUND_OF_32_SHORTCUT");
|
|
||||||
case 19993:
|
|
||||||
return JText::_("COM_SPORTSMANAGER_ROUND_OF_64_SHORTCUT");
|
|
||||||
case 19992:
|
|
||||||
return JText::_("COM_SPORTSMANAGER_ROUND_OF_128_SHORTCUT");
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bezeichnung_verstecken ? $runde : JText::sprintf($spieltag ? "COM_SPORTSMANAGER_MATCH_DAY_NR_SHORTCUT" : "COM_SPORTSMANAGER_ROUND_NR_SHORTCUT", $runde);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($runde >= 20000)
|
if ($runde >= 20000)
|
||||||
return JText::sprintf("COM_SPORTSMANAGER_PLACE_FROM_TO", 99 - $runde % 100, 99 - floor(($runde - 20000) / 100) + 99 - ($runde % 100));
|
return Text::sprintf("COM_SPORTSMANAGER_PLACE_FROM_TO", 99 - $runde % 100, 99 - floor(($runde - 20000) / 100) + 99 - ($runde % 100));
|
||||||
|
|
||||||
switch ($runde) {
|
return match ($runde) {
|
||||||
case 0:
|
0 => $spieltag
|
||||||
return $spieltag
|
? Text::_("COM_SPORTSMANAGER_MATCH_DAY_NONE")
|
||||||
? JText::_("COM_SPORTSMANAGER_MATCH_DAY_NONE")
|
: Text::_("COM_SPORTSMANAGER_ROUND_NONE"),
|
||||||
: JText::_("COM_SPORTSMANAGER_ROUND_NONE");
|
19999 => Text::_("COM_SPORTSMANAGER_FINAL"),
|
||||||
case 19999:
|
19998 => Text::_("COM_SPORTSMANAGER_3RD_PLACE"),
|
||||||
return JText::_("COM_SPORTSMANAGER_FINAL");
|
19997 => Text::_("COM_SPORTSMANAGER_HALF_FINAL"),
|
||||||
case 19998:
|
19996 => Text::_("COM_SPORTSMANAGER_QUARTER_FINAL"),
|
||||||
return JText::_("COM_SPORTSMANAGER_3RD_PLACE");
|
19995 => Text::_("COM_SPORTSMANAGER_ROUND_OF_16"),
|
||||||
case 19997:
|
19994 => Text::_("COM_SPORTSMANAGER_ROUND_OF_32"),
|
||||||
return JText::_("COM_SPORTSMANAGER_HALF_FINAL");
|
19993 => Text::_("COM_SPORTSMANAGER_ROUND_OF_64"),
|
||||||
case 19996:
|
19992 => Text::_("COM_SPORTSMANAGER_ROUND_OF_128"),
|
||||||
return JText::_("COM_SPORTSMANAGER_QUARTER_FINAL");
|
default => $bezeichnung_verstecken
|
||||||
case 19995:
|
|
||||||
return JText::_("COM_SPORTSMANAGER_ROUND_OF_16");
|
|
||||||
case 19994:
|
|
||||||
return JText::_("COM_SPORTSMANAGER_ROUND_OF_32");
|
|
||||||
case 19993:
|
|
||||||
return JText::_("COM_SPORTSMANAGER_ROUND_OF_64");
|
|
||||||
case 19992:
|
|
||||||
return JText::_("COM_SPORTSMANAGER_ROUND_OF_128");
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bezeichnung_verstecken
|
|
||||||
? $runde
|
? $runde
|
||||||
: JText::sprintf(
|
: Text::sprintf(
|
||||||
$spieltag
|
$spieltag
|
||||||
? "COM_SPORTSMANAGER_MATCH_DAY_NR"
|
? "COM_SPORTSMANAGER_MATCH_DAY_NR"
|
||||||
: "COM_SPORTSMANAGER_ROUND_NR",
|
: "COM_SPORTSMANAGER_ROUND_NR",
|
||||||
$runde
|
$runde
|
||||||
);
|
),
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormatiertesDatum($s, $zeit_anzeigen = true, $wochentag_anzeigen = true) {
|
function FormatiertesDatum($s, $zeit_anzeigen = true, $wochentag_anzeigen = true): string
|
||||||
|
{
|
||||||
if ($s != null && strlen($s) > 0) {
|
if ($s != null && strlen($s) > 0) {
|
||||||
$ts = getdate(strtotime($s));
|
$ts = getdate(strtotime($s));
|
||||||
if ($wochentag_anzeigen) {
|
if ($wochentag_anzeigen) {
|
||||||
$wochentage = array(JText::_("COM_SPORTSMANAGER_DAY_0_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_1_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_2_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_3_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_4_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_5_SHORTCUT"), JText::_("COM_SPORTSMANAGER_DAY_6_SHORTCUT"));
|
$wochentage = array(Text::_("COM_SPORTSMANAGER_DAY_0_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_1_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_2_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_3_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_4_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_5_SHORTCUT"), Text::_("COM_SPORTSMANAGER_DAY_6_SHORTCUT"));
|
||||||
if ($zeit_anzeigen)
|
if ($zeit_anzeigen)
|
||||||
return sprintf("%s, %02d.%02d.%04d %02d:%02d", $wochentage[$ts["wday"]], $ts["mday"], $ts["mon"], $ts["year"], $ts["hours"], $ts["minutes"]);
|
return sprintf("%s, %02d.%02d.%04d %02d:%02d", $wochentage[$ts["wday"]], $ts["mday"], $ts["mon"], $ts["year"], $ts["hours"], $ts["minutes"]);
|
||||||
|
|
||||||
@@ -225,10 +194,11 @@ function FormatiertesDatum($s, $zeit_anzeigen = true, $wochentag_anzeigen = true
|
|||||||
return sprintf("%02d.%02d.%04d", $ts["mday"], $ts["mon"], $ts["year"]);
|
return sprintf("%02d.%02d.%04d", $ts["mday"], $ts["mon"], $ts["year"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return JText::_("COM_SPORTSMANAGER_DATE_NONE");
|
return Text::_("COM_SPORTSMANAGER_DATE_NONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormatierterTermin($erster_tag, $letzter_tag, $jahr_anzeigen = false, $filter_jahr = null) {
|
function FormatierterTermin($erster_tag, $letzter_tag, $jahr_anzeigen = false, $filter_jahr = null): string
|
||||||
|
{
|
||||||
$erster_ts = getdate(strtotime($erster_tag));
|
$erster_ts = getdate(strtotime($erster_tag));
|
||||||
$letzter_ts = getdate(strtotime($letzter_tag));
|
$letzter_ts = getdate(strtotime($letzter_tag));
|
||||||
if (!empty($filter_jahr))
|
if (!empty($filter_jahr))
|
||||||
@@ -246,401 +216,12 @@ function FormatierterTermin($erster_tag, $letzter_tag, $jahr_anzeigen = false, $
|
|||||||
return $erster_termin . "-" . $letzter_termin;
|
return $erster_termin . "-" . $letzter_termin;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bildLoeschen($typ, $id) {
|
function terminDokumentname($id): bool|string
|
||||||
global $sportsmanager_joomla_path;
|
|
||||||
$typ_exploded = explode("/", $typ);
|
|
||||||
$typ = $typ_exploded[0];
|
|
||||||
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
|
|
||||||
$bilder_pfad = $sportsmanager_joomla_path . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'sportsmanager' . DIRECTORY_SEPARATOR . $typ;
|
|
||||||
$pfad = $bilder_pfad . '/' . $typ_prefix . $id . ".";
|
|
||||||
if (!is_file($pfad . 'png') && !is_file($pfad . 'jpg'))
|
|
||||||
return;
|
|
||||||
$alte_bilder = JFolder::files($bilder_pfad, '^' . $typ_prefix . $id . '\.|^' . $typ_prefix . 'I' . $id . 'T');
|
|
||||||
foreach ($alte_bilder as $fn)
|
|
||||||
JFile::delete($bilder_pfad . DIRECTORY_SEPARATOR . $fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
function bildIdentisch($typ1, $id1, $typ2, $id2) {
|
|
||||||
global $sportsmanager_joomla_path;
|
|
||||||
$typ1_exploded = explode("/", $typ1);
|
|
||||||
$typ1 = $typ1_exploded[0];
|
|
||||||
$typ1_prefix = count($typ1_exploded) > 1 ? $typ1_exploded[1] : "";
|
|
||||||
$bilder_pfad1 = $sportsmanager_joomla_path . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'sportsmanager' . DIRECTORY_SEPARATOR . $typ1;
|
|
||||||
$pfad1 = $bilder_pfad1 . '/' . $typ1_prefix . $id1 . ".";
|
|
||||||
if (is_file($pfad1 . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad1 . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else
|
|
||||||
$ext = "";
|
|
||||||
$pfad1 .= $ext;
|
|
||||||
|
|
||||||
$typ2_exploded = explode("/", $typ2);
|
|
||||||
$typ2 = $typ2_exploded[0];
|
|
||||||
$typ2_prefix = count($typ2_exploded) > 1 ? $typ2_exploded[1] : "";
|
|
||||||
$bilder_pfad2 = $sportsmanager_joomla_path . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'sportsmanager' . DIRECTORY_SEPARATOR . $typ2;
|
|
||||||
$pfad2 = $bilder_pfad2 . '/' . $typ2_prefix . $id2 . "." . $ext;
|
|
||||||
|
|
||||||
return files_identical($pfad1, $pfad2);
|
|
||||||
}
|
|
||||||
|
|
||||||
function teamImage($teamId, $vereinId, $width = 240, $height = 240) {
|
|
||||||
$url = bildURL("mannschaften", $teamId, 0, 0, $width, $height);
|
|
||||||
|
|
||||||
if ($url == null) {
|
|
||||||
$url = bildURL("vereine", $vereinId, 0, 0, $width, $height);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
function playerImage($playerId, $gender, $width = 180, $height = 240) {
|
|
||||||
$url = bildURL("spieler", $playerId, $width, $height, 0,0,'', $gender == 'M' ? 'm' : 'w');
|
|
||||||
if ($url == null) {
|
|
||||||
$url = bildURL("mannschaftsmitglieder", $playerId, $width, $height, 0,0,'');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function bildURL($typ, $id, $fixed_width = 0, $fixed_height = 0, $max_width = 0, $max_height = 0, $zusatz = "", $alternativ = "") {
|
|
||||||
global $sportsmanager_joomla_path;
|
|
||||||
global $sportsmanager_joomla_url;
|
|
||||||
|
|
||||||
$typ_exploded = explode("/", $typ);
|
|
||||||
$typ = $typ_exploded[0];
|
|
||||||
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
|
|
||||||
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
|
|
||||||
if (is_file($pfad . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else if (!empty($alternativ)) {
|
|
||||||
$id = $alternativ;
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
|
|
||||||
if (is_file($pfad . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
|
|
||||||
$time = filemtime($pfad . $ext);
|
|
||||||
|
|
||||||
if ($fixed_width > 0 && $fixed_height > 0) {
|
|
||||||
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . $fixed_width . "H" . $fixed_height . "." . $ext;
|
|
||||||
if (is_file($pfad_angepasst)) {
|
|
||||||
return $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$size = getimagesize($pfad . $ext);
|
|
||||||
$width = $size[0];
|
|
||||||
$height = $size[1];
|
|
||||||
|
|
||||||
$max_width = $fixed_width > 0 ? $fixed_width : $max_width;
|
|
||||||
$max_height = $fixed_height > 0 ? $fixed_height : $max_height;
|
|
||||||
|
|
||||||
if (($fixed_width == 0 || $width == $fixed_width) && ($fixed_height == 0 || $height == $fixed_height) && ($fixed_width != 0 || $max_width == 0 || $width <= $max_width) && ($fixed_height != 0 || $max_height == 0 || $height <= $max_height)) {
|
|
||||||
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . $width . "H" . $height . "." . $ext;
|
|
||||||
if (!is_file($pfad_angepasst)) {
|
|
||||||
if (!copy($pfad . $ext, $pfad_angepasst))
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst);
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_width = $width;
|
|
||||||
$new_height = $height;
|
|
||||||
|
|
||||||
if ($max_height > 0 && $new_height > $max_height) {
|
|
||||||
$new_width = max(round($new_width * $max_height / $new_height), 1);
|
|
||||||
$new_height = $max_height;
|
|
||||||
}
|
|
||||||
if ($max_width > 0 && $new_width > $max_width) {
|
|
||||||
$new_height = max(round($new_height * $max_width / $new_width), 1);
|
|
||||||
$new_width = $max_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($max_width > 0 && (($max_width - $new_width) % 2) == 1) // Toleranz bei nur 1 Pixel Unterschied
|
|
||||||
$new_width += 1;
|
|
||||||
if ($max_height > 0 && (($max_height - $new_height) % 2) == 1) // Toleranz bei nur 1 Pixel Unterschied
|
|
||||||
$new_height += 1;
|
|
||||||
|
|
||||||
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . max($fixed_width, $new_width) . "H" . max($fixed_height, $new_height) . "." . $ext;
|
|
||||||
|
|
||||||
if (!is_file($pfad_angepasst)) {
|
|
||||||
$image = $ext == "png" ? imagecreatefrompng($pfad . $ext) : imagecreatefromjpeg($pfad . $ext);
|
|
||||||
if ($image === false)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
$image_resized = imagecreatetruecolor(max($fixed_width, $new_width), max($fixed_height, $new_height));
|
|
||||||
$color = $ext == "png" ? imagecolorallocatealpha($image_resized, 0, 0, 0, 127) : imagecolorallocate($image_resized, 64, 64, 64);
|
|
||||||
imagefill($image_resized, 0, 0, $color);
|
|
||||||
imagecopyresampled($image_resized, $image, round((imagesx($image_resized) - $new_width) / 2), round((imagesy($image_resized) - $new_height) / 2), 0, 0, $new_width, $new_height, $width, $height);
|
|
||||||
if ($ext == "png") {
|
|
||||||
imagesavealpha($image_resized, true);
|
|
||||||
imagepng($image_resized, $pfad_angepasst);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
imagejpeg($image_resized, $pfad_angepasst);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* #resize=250
|
|
||||||
#resize=250,250,blue
|
|
||||||
#resize=250,250,blue
|
|
||||||
#resize=250,250&sizes=60%,80%,200%
|
|
||||||
#resize=250,250,cover&sizes=60%,80%,200%
|
|
||||||
#resize=250,250,fill&sizes=60%,80%,200%
|
|
||||||
#crop=250,250,center,top
|
|
||||||
#crop=250,250
|
|
||||||
#crop=250,250,center,bottom
|
|
||||||
#crop=250,250,left
|
|
||||||
#crop=250,250,right
|
|
||||||
*/
|
|
||||||
function yoothemeBild($typ, $id, $resize = '', $zusatz = "", $alternativ)
|
|
||||||
{
|
{
|
||||||
global $sportsmanager_joomla_path;
|
global $sportsmanager_joomla_path;
|
||||||
global $sportsmanager_joomla_url;
|
|
||||||
|
|
||||||
$typ_exploded = explode("/", $typ);
|
|
||||||
$typ = $typ_exploded[0];
|
|
||||||
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
|
|
||||||
|
|
||||||
if (is_file($pfad . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else if (!empty($alternativ)) {
|
|
||||||
$id = $alternativ;
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
|
|
||||||
if (is_file($pfad . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
|
|
||||||
$time = filemtime($pfad . $ext);
|
|
||||||
|
|
||||||
$bildpfad = "images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . "." . $ext;
|
|
||||||
|
|
||||||
|
|
||||||
return '<img class="el-image" data-src="' . $bildpfad . $resize . '" ' . $zusatz . ' uk-img />';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Quick and dirty DTFL Logo Bilder
|
|
||||||
*/
|
|
||||||
|
|
||||||
function logoBilder($typ, $id, $resize = '', $zusatz = "", $alternativ)
|
|
||||||
{
|
|
||||||
global $sportsmanager_joomla_path;
|
|
||||||
global $sportsmanager_joomla_url;
|
|
||||||
|
|
||||||
$typ_exploded = explode("/", $typ);
|
|
||||||
$typ = $typ_exploded[0];
|
|
||||||
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
|
|
||||||
|
|
||||||
if (is_file($pfad . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else if (!empty($alternativ)) {
|
|
||||||
$id = $alternativ;
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
|
|
||||||
if (is_file($pfad . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
|
|
||||||
$time = filemtime($pfad . $ext);
|
|
||||||
|
|
||||||
$bildpfad = "images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . "." . $ext;
|
|
||||||
|
|
||||||
|
|
||||||
return '<img class="el-image" data-src="' . $bildpfad . $resize . '" ' . $zusatz . ' uk-img />';
|
|
||||||
}
|
|
||||||
|
|
||||||
function bildHTML($typ, $id, $fixed_width = 0, $fixed_height = 0, $max_width = 0, $max_height = 0, $zusatz = "", $alternativ = "") {
|
|
||||||
global $sportsmanager_joomla_path;
|
|
||||||
global $sportsmanager_joomla_url;
|
|
||||||
|
|
||||||
$typ_exploded = explode("/", $typ);
|
|
||||||
$typ = $typ_exploded[0];
|
|
||||||
$typ_prefix = count($typ_exploded) > 1 ? $typ_exploded[1] : "";
|
|
||||||
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
|
|
||||||
if (is_file($pfad . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else if (!empty($alternativ)) {
|
|
||||||
$id = $alternativ;
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . $id . ".";
|
|
||||||
if (is_file($pfad . "png"))
|
|
||||||
$ext = "png";
|
|
||||||
else if (is_file($pfad . "jpg"))
|
|
||||||
$ext = "jpg";
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
|
|
||||||
$time = filemtime($pfad . $ext);
|
|
||||||
|
|
||||||
if ($fixed_width > 0 && $fixed_height > 0) {
|
|
||||||
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . $fixed_width . "H" . $fixed_height . "." . $ext;
|
|
||||||
if (is_file($pfad_angepasst)) {
|
|
||||||
return '<img src="' . $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst) . '" width="' . $fixed_width . '" height="' . $fixed_height . '" ' . $zusatz . ' />';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$size = getimagesize($pfad . $ext);
|
|
||||||
$width = $size[0];
|
|
||||||
$height = $size[1];
|
|
||||||
|
|
||||||
$max_width = $fixed_width > 0 ? $fixed_width : $max_width;
|
|
||||||
$max_height = $fixed_height > 0 ? $fixed_height : $max_height;
|
|
||||||
|
|
||||||
if (($fixed_width == 0 || $width == $fixed_width) && ($fixed_height == 0 || $height == $fixed_height) && ($fixed_width != 0 || $max_width == 0 || $width <= $max_width) && ($fixed_height != 0 || $max_height == 0 || $height <= $max_height)) {
|
|
||||||
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . $width . "H" . $height . "." . $ext;
|
|
||||||
if (!is_file($pfad_angepasst)) {
|
|
||||||
if (!copy($pfad . $ext, $pfad_angepasst))
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<img src="' . $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst) . '" width="' . $width . '" height="' . $height . '" ' . $zusatz . ' />';
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_width = $width;
|
|
||||||
$new_height = $height;
|
|
||||||
|
|
||||||
if ($max_height > 0 && $new_height > $max_height) {
|
|
||||||
$new_width = max(round($new_width * $max_height / $new_height), 1);
|
|
||||||
$new_height = $max_height;
|
|
||||||
}
|
|
||||||
if ($max_width > 0 && $new_width > $max_width) {
|
|
||||||
$new_height = max(round($new_height * $max_width / $new_width), 1);
|
|
||||||
$new_width = $max_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($max_width > 0 && (($max_width - $new_width) % 2) == 1) // Toleranz bei nur 1 Pixel Unterschied
|
|
||||||
$new_width += 1;
|
|
||||||
if ($max_height > 0 && (($max_height - $new_height) % 2) == 1) // Toleranz bei nur 1 Pixel Unterschied
|
|
||||||
$new_height += 1;
|
|
||||||
|
|
||||||
$pfad_angepasst = $sportsmanager_joomla_path . "/images/sportsmanager/" . $typ . "/" . $typ_prefix . "I" . $id . "T" . $time . "W" . max($fixed_width, $new_width) . "H" . max($fixed_height, $new_height) . "." . $ext;
|
|
||||||
|
|
||||||
if (!is_file($pfad_angepasst)) {
|
|
||||||
$image = $ext == "png" ? imagecreatefrompng($pfad . $ext) : imagecreatefromjpeg($pfad . $ext);
|
|
||||||
if ($image === false)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
$image_resized = imagecreatetruecolor(max($fixed_width, $new_width), max($fixed_height, $new_height));
|
|
||||||
$color = $ext == "png" ? imagecolorallocatealpha($image_resized, 0, 0, 0, 127) : imagecolorallocate($image_resized, 64, 64, 64);
|
|
||||||
imagefill($image_resized, 0, 0, $color);
|
|
||||||
imagecopyresampled($image_resized, $image, round((imagesx($image_resized) - $new_width) / 2), round((imagesy($image_resized) - $new_height) / 2), 0, 0, $new_width, $new_height, $width, $height);
|
|
||||||
if ($ext == "png") {
|
|
||||||
imagesavealpha($image_resized, true);
|
|
||||||
imagepng($image_resized, $pfad_angepasst);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
imagejpeg($image_resized, $pfad_angepasst);
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<img src="' . $sportsmanager_joomla_url . 'images/sportsmanager/' . $typ . '/' . basename($pfad_angepasst) . '" width="' . max($fixed_width, $new_width) . '" height="' . max($fixed_height, $new_height) . '" ' . $zusatz . ' />';
|
|
||||||
}
|
|
||||||
|
|
||||||
function terminDokumentname($id) {
|
|
||||||
global $sportsmanager_joomla_path;
|
|
||||||
|
|
||||||
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/termine";
|
$pfad = $sportsmanager_joomla_path . "/images/sportsmanager/termine";
|
||||||
$dokumente = JFolder::files($pfad, '^' . $id . ' ');
|
$dokumente = Folder::files($pfad, '^' . $id . ' ');
|
||||||
|
|
||||||
return !empty($dokumente) ? substr($dokumente[0], strlen((string) $id) + 1) : false;
|
return !empty($dokumente) ? substr($dokumente[0], strlen((string) $id) + 1) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function lightBoxJSShow($lightbox_class = "lightbox") {
|
|
||||||
return "show" . $lightbox_class . "();";
|
|
||||||
}
|
|
||||||
|
|
||||||
function lightBoxJSHide($lightbox_class = "lightbox") {
|
|
||||||
return "hide" . $lightbox_class . "();";
|
|
||||||
}
|
|
||||||
|
|
||||||
function lightBoxClassHide($lightbox_class = "lightbox") {
|
|
||||||
return $lightbox_class . "_close";
|
|
||||||
}
|
|
||||||
|
|
||||||
function lightBoxHeader($lightbox_class = "lightbox") {
|
|
||||||
?>
|
|
||||||
<style type="text/css">
|
|
||||||
div<?php echo "#" . $lightbox_class; ?> {
|
|
||||||
position: fixed;
|
|
||||||
left: 50px;
|
|
||||||
right: 50px;
|
|
||||||
top: 50px;
|
|
||||||
bottom: 50px;
|
|
||||||
border: 1px solid #999999;
|
|
||||||
overflow: scroll;
|
|
||||||
background-color: #e4e4e4;
|
|
||||||
padding: 20px;
|
|
||||||
display: none;
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
div<?php echo "#" . $lightbox_class . "_close"; ?> {
|
|
||||||
position: fixed;
|
|
||||||
right: 0px;
|
|
||||||
top: 0px;
|
|
||||||
bottom: 0px;
|
|
||||||
left: 0px;
|
|
||||||
overflow: hidden;
|
|
||||||
display: none;
|
|
||||||
visibility: hidden;
|
|
||||||
background-color: rgba(0, 0, 0, 0.8);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
//<!--
|
|
||||||
function show<?php echo $lightbox_class; ?>() {
|
|
||||||
document.getElementById("<?php echo $lightbox_class; ?>").style.display = "inline";
|
|
||||||
document.getElementById("<?php echo $lightbox_class; ?>").style.visibility = "visible";
|
|
||||||
document.getElementById("<?php echo $lightbox_class . "_close"; ?>").style.display = "inline";
|
|
||||||
document.getElementById("<?php echo $lightbox_class . "_close"; ?>").style.visibility = "visible";
|
|
||||||
}
|
|
||||||
|
|
||||||
function hide<?php echo $lightbox_class; ?>() {
|
|
||||||
document.getElementById("<?php echo $lightbox_class; ?>").style.display = "none";
|
|
||||||
document.getElementById("<?php echo $lightbox_class; ?>").style.visibility = "hidden";
|
|
||||||
document.getElementById("<?php echo $lightbox_class . "_close"; ?>").style.display = "none";
|
|
||||||
document.getElementById("<?php echo $lightbox_class . "_close"; ?>").style.visibility = "hidden";
|
|
||||||
}
|
|
||||||
|
|
||||||
//-->
|
|
||||||
</script>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|||||||
+240
-218
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user