Skip to content

Commit 480b7af

Browse files
Fixes Bug 782 Dä Chnopf updated # Lost Posts nicht
1 parent d1682d3 commit 480b7af

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

www/actions/comments_readall.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,24 @@
1111

1212
if($user->id > 0)
1313
{
14-
$sql = 'DELETE from comments_unread WHERE user_id = '.$user->id;
15-
$rs = $db->query($sql, __FILE__, __LINE__);
16-
$num = $db->num($rs);
17-
18-
$sql = 'UPDATE user SET button_use = button_use+1, posts_lost = posts_lost+'.$num.' WHERE id = '.$user->id;
19-
$db->query($sql,__FILE__,__LINE__);
14+
/** Get current # unread comments */
15+
$currNumUnreads = Forum::getNumunreadposts($user->id);
16+
if (false !== $currNumUnreads && $currNumUnreads > 0)
17+
{
18+
if (DEVELOPMENT) error_log(sprintf('[DEBUG] <%s:%d> To delete comments_unread for user #%d : %d', __FILE__, __LINE__, $user->id, $currNumUnreads));
2019

21-
header("Location: /forum.php?".session_name()."=".session_id());
20+
/** Delete all unread posts */
21+
$sqlDel = 'DELETE FROM comments_unread WHERE user_id = '.$user->id;
22+
$rsDel = $db->query($sqlDel, __FILE__, __LINE__, 'DELETE comments_unread for user '.$user->id);
23+
24+
/** Updated user's total number of button-of-shame and lost posts */
25+
$sqlUpd = sprintf('UPDATE user SET button_use=button_use+1, posts_lost=posts_lost+%d WHERE id=%d', $currNumUnreads, $user->id);
26+
$rsUpd = $db->query($sqlUpd,__FILE__,__LINE__, 'UPDATE user SET button_use + posts_lost for user '.$user->id);
27+
}
28+
29+
header('Location: /forum.php');
2230
exit;
23-
31+
2432
} else {
2533
echo 'Du bist nicht eingeloggt.';
2634
}

www/includes/mysql.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ function query($sql, $file='', $line=0, $funktion='') {
115115
}
116116

117117
try {
118-
$result = mysqli_query($this->conn, $sql); // DEPRECATED - PHP5 only
118+
$result = mysqli_query($this->conn, $sql);
119119
$sql_query_type = strtolower(substr($sql,0,6)); // first 6 chars of $sql = e.g. INSERT or UPDATE
120-
if ($sql_query_type == 'insert') {
120+
if ($sql_query_type === 'insert') {
121121
$sql_insert_id = mysqli_insert_id($this->conn);
122122
return (is_numeric($sql_insert_id) && $sql_insert_id !== 0 ? $sql_insert_id : ($sql_insert_id !== false ? true : false));
123-
} elseif ($sql_query_type == 'update') {
123+
} elseif ($sql_query_type === 'update' || $sql_query_type === 'delete') {
124124
$sql_affected_rows = mysqli_affected_rows($this->conn);
125125
return (is_numeric($sql_affected_rows) && $sql_affected_rows !== 0 ? $sql_affected_rows : ($sql_affected_rows !== false ? true : false));
126126
} elseif ($result === false && $this->display_error == 1) {

www/includes/sunrise.inc.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ class Astro_Sunrise
104104
* @var array Array containing sunrise/sunset, civil twilight, nautical twilight, astronomical twilight
105105
*/
106106
var $twilight = array(
107-
'effective' => -.0145439, // sunrise/sunset
107+
'effective' => -.0145439, // sunrise/sunset
108108
'civil' => -.104528, // civil twilight
109109
'nautical' => -.207912, // nautical twilight
110-
'astronomical' => -.309017 // astronomical twilight
110+
'astronomical' => -.309017 // astronomical twilight
111111
);
112112

113113
/**
@@ -243,7 +243,7 @@ function calcSunrise($isRise) {
243243

244244
// multiples of pi
245245
$A = 0.5 * M_PI; // Quarter circle
246-
$B = M_PI; // Half circle
246+
$B = M_PI; // Half circle
247247
$C = 1.5 * M_PI; // 3/4 circle
248248
$D = 2 * M_PI; // Full circle
249249

@@ -281,7 +281,7 @@ function calcSunrise($isRise) {
281281
$S /= cos($Q) * cos($E);
282282

283283
if (abs($S) > 1)
284-
return "(Mitternachtssonne/Dauernacht)";
284+
return '(Mitternachtssonne/Dauernacht)';
285285

286286
$S /= sqrt(-$S * $S + 1);
287287
$S = $A - atan2($S, 1);
@@ -302,15 +302,15 @@ function calcSunrise($isRise) {
302302
$V *= 24 / $D;
303303

304304
// Universal time
305-
$hour = intval($U);
305+
$hour = intval($U);
306306
$U = ($U - $hour) * 60;
307307
$min = intval($U);
308308
$U = ($U - $min) * 60;
309309
$sec = intval($U);
310310
$this->last_utc = gmmktime($hour, $min, $sec, $this->month, $this->mday, $this->year);
311311

312312
// Local time
313-
$hour = intval($V);
313+
$hour = intval($V);
314314
$min = intval(($V - $hour) * 60 + 0.5);
315315

316316
return sprintf('%02d:%02d', $hour, $min);
@@ -346,8 +346,8 @@ function norm($a, $b) { // normalize $a to be in [0, $b)
346346
ON co.country_code = ci.country_code
347347
WHERE
348348
ci.ip_from >= '.$user_ip.' AND ci.ip_to <= '.$user_ip.'
349-
OR ci.ip_from >= '.$user_ip.' AND ci.ip_to <= '.($user_ip+200000000).'
350-
LIMIT 1'; // little trick to have more often a match
349+
OR ci.ip_from >= '.$user_ip.' AND ci.ip_to <= '.($user_ip+200000000).'
350+
LIMIT 1'; // little trick to have more often a match
351351
$result = $db->query($sql,__FILE__,__LINE__);
352352
$rs = $db->fetch($result);
353353

@@ -362,7 +362,7 @@ function norm($a, $b) { // normalize $a to be in [0, $b)
362362

363363
$suncalc = new Astro_Sunrise();
364364
$suncalc->setCoords($lat, $lon);
365-
$suncalc->setTimezone(round($lon/15.0)+date("I"));
365+
$suncalc->setTimezone(round($lon/15.0)+date('I'));
366366
$suncalc->setTimestamp(time()+(3600*round($lon/15.0)+date('I')));
367367
$sunrise = $suncalc->getSunrise();
368368
$sunset = $suncalc->getSunset();

0 commit comments

Comments
 (0)