return 'Nur der Leader, Co-Leader oder freigeschaltete Mitglieder können Herausforderungen anderer Clans annehmen!!';
}
$sql = 'SELECT * FROM clan_challenge_requests WHERE clan_challenged = ' .$user['clan'] . ' AND clan_requester = ' .$challenged_clan . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())';
@ -184,7 +185,7 @@ function acceptChallengeRequest($challenged_clan, array $user) {
// now calculate how many open fights we currently had or have! // FIXME: Good idea to pach this in a semaphore?
$sql = 'select count(*) as anzahl from (SELECT count(*) as anz FROM clan_challenges c inner join clan_challenge_clans ccc on c.clan_challenge_id = ccc.clan_challenge_id where calculated = 0 or TIMESTAMPADD(day, -1, now()) <enddateandclan_idIN('.$clan_challenge['clan_challenged'].','.$clan_challenge['clan_requester'].')groupbyclan_id)kwherek.anz>= ' . CLANFIGHTS_MAX_FIGHTS_PER_24H;
// echo $sql . '<br>';
// echo $sql . '<br>';
$row = mysql_fetch_assoc(mysql_query($sql));
if($row['anzahl'] > 0) {
@ -241,8 +242,8 @@ function denyChallengeRequest($challenged_clan, array $user) {
return 'Nur der Leader, Co-Leader oder freigeschaltete Mitglieder können Herausforderungen anderer Clans ablehnen!!';
}
$clan_challenge = mysql_fetch_assoc(mysql_query('SELECT * FROM clan_challenge_requests WHERE clan_challenged = ' .$user['clan'] . ' AND clan_requester = ' .$challenged_clan . ' AND active = TRUE AND challenged_time > TIMESTAMPADD(day, -1, now())'));
@ -275,7 +276,7 @@ function getChallenge($challenge_id, $buffer = TRUE) {
$qry = mysql_query('SELECT * from clan_challenges WHERE clan_challenge_id = ' .$challenge_id);
return $GLOBALS['clan_challenge_buffered_instances'][$challenge_id]; // okay, we already buffered the clan :)
}
}
function getOpenChallengeRequests($clanid) {
$array = array();
@ -284,7 +285,7 @@ function getOpenChallengeRequests($clanid) {
}
$sql = 'SELECT * from clan_challenge_requests WHERE challenged_time > TIMESTAMPADD(day, -1, now()) and active = TRUE AND (clan_requester = '.$clanid.' OR clan_challenged = '.$clanid.')';
// echo $sql . '<br>';
// echo $sql . '<br>';
$qry = mysql_query($sql);
while($row = mysql_fetch_assoc($qry)) {
$array[] = $row;
@ -297,7 +298,7 @@ function getOpenChallengeRequestCount($clanid) {
return 0;
}
$sql = 'SELECT count(*) from clan_challenge_requests where challenged_time > TIMESTAMPADD(day, -1, now()) and active = TRUE AND (clan_requester = '.$clanid.' OR clan_challenged = '.$clanid.')';
// echo $sql . '<br>';
// echo $sql . '<br>';
$row = mysql_fetch_row(mysql_query($sql));
return $row[0];
}
@ -368,8 +369,8 @@ function isClanLocked($clanid) {
return true;
}
// we really want to know if we are locked at the moment. So readout everything at once ;), right join so we always have a row :D
$sql = 'SELECT *, locked_until > now() as `lock`, (Select count(id) from user where clan = c2.id) as members FROM clan_locked right join clan c2 on c2.id = clan_locked.clanid where c2.id = ' . $clanid;
// echo $sql.'<br>';
$lock = mysql_fetch_assoc(mysql_query($sql));
if($lock['lock'] == 0) { // don't matter if it is 0 or NULL
@ -385,12 +386,12 @@ function isClanLocked($clanid) {
} else if($lock['lock'] === NULL){ // we need to insert a row
// INSERT
$sql = 'INSERT INTO clan_locked(clanid, locked_until) values('.$clanid.', TIMESTAMPADD(HOUR, 24, CURRENT_TIMESTAMP))';