Files
cwsvJudo/homepage/participo/api/users.php

54 lines
1.6 KiB
PHP

<?php
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/'. PATH_SEPARATOR. '..');
require_once 'config/participo.php';
require_once 'local/cwsvJudo.php';
require_once 'participoLib/participo.php';
if(array_key_exists("HTTP_AUTHORIZATION", $_SERVER)){
if(!empty($_SERVER["HTTP_AUTHORIZATION"])){
$auth = explode(" ", $_SERVER["HTTP_AUTHORIZATION"]);
if($auth[0]="Basic"){
$db = dbConnector::connect(
$cwsvJudoConfig['db']['host'],
$cwsvJudoConfig['db']['name'],
$cwsvJudoConfig['db']['user'],
$cwsvJudoConfig['db']['password']
);
$allowKey = ApiKey::loadFromDb($auth[1]);
}
}
}
if (!$allowKey || !$allowKey->isValidFor('api')) {
die(json_encode(['success' => false]));
}
$wkSqlQuery = "SELECT DISTINCT"
." `wkParticipo_Users`.* "
." FROM `wkParticipo_Users`"
." JOIN `vormundschaft`"
." ON `wkParticipo_Users`.`id` =`vormundschaft`.`userId`"
." JOIN `wkParticipo_user<=>userAttributes`"
." ON `wkParticipo_user<=>userAttributes`.`userId` = `vormundschaft`.`kidId`"
." WHERE `wkParticipo_user<=>userAttributes`.`attributeId` = 4"
." ORDER BY `wkParticipo_Users`.`id` ASC;";
$wkSqlResponse = dbConnector::query($wkSqlQuery);
foreach( $wkSqlResponse as &$user){
$user['eMail'] = explode(",", $user['eMail']);
}
header('Access-Control-Allow-Headers: *');
header('Access-Control-Allow-Origin: *');
echo(
json_encode($wkSqlResponse)
// json_encode(getallheaders())
// json_encode($_SERVER)
);