/[LeafOK_CVS]/fenglin/bbs/user_score_detail.php
ViewVC logotype

Annotation of /fenglin/bbs/user_score_detail.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Tue Apr 29 11:55:32 2025 UTC (10 months, 2 weeks ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -1 lines
Remove redundant PHP closing tag

1 sysadm 1.1 <?php
2     require_once "../lib/db_open.inc.php";
3     require_once "../lib/common.inc.php";
4     require_once "./session_init.inc.php";
5     require_once "./theme.inc.php";
6    
7     force_login();
8    
9     $result_set = array(
10     "return" => array(
11     "code" => 0,
12     "message" => "",
13     "errorFields" => array(),
14     ),
15     "data" => array(
16     "score" => 0,
17     "transactions" => array(),
18     ),
19     );
20    
21     $sql = "SELECT score FROM user_score where UID = " . $_SESSION["BBS_uid"];
22    
23     $rs = mysqli_query($db_conn, $sql);
24     if ($rs == false)
25     {
26     $result_set["return"]["code"] = -2;
27     $result_set["return"]["message"] = "Query score error: " . mysqli_error($db_conn);
28    
29     mysqli_close($db_conn);
30     exit(json_encode($result_set));
31     }
32    
33     if ($row = mysqli_fetch_array($rs))
34     {
35     $result_set["data"]["score"] = $row["score"];
36     }
37     mysqli_free_result($rs);
38    
39     $sql = "SELECT score_change, reason, dt FROM user_score_log
40     WHERE UID = " . $_SESSION["BBS_uid"] .
41     " AND dt >= SUBDATE(NOW(), INTERVAL 3 YEAR)
42     ORDER BY id DESC";
43    
44     $rs = mysqli_query($db_conn, $sql);
45     if ($rs == false)
46     {
47     $result_set["return"]["code"] = -2;
48     $result_set["return"]["message"] = "Query transactions error: " . mysqli_error($db_conn);
49    
50     mysqli_close($db_conn);
51     exit(json_encode($result_set));
52     }
53    
54     while($row = mysqli_fetch_array($rs))
55     {
56     array_push($result_set["data"]["transactions"], array(
57     "dt" => (new DateTimeImmutable($row["dt"]))->setTimezone($_SESSION["BBS_user_tz"]),
58     "amount" => $row["score_change"],
59     "reason" => $row["reason"],
60     ));
61     }
62     mysqli_free_result($rs);
63    
64     mysqli_close($db_conn);
65    
66     // Output with theme view
67     $theme_view_file = get_theme_file("view/score_detail", $_SESSION["BBS_theme_name"]);
68     if ($theme_view_file == null)
69     {
70     exit(json_encode($result_set)); // Output data in Json
71     }
72     include $theme_view_file;

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1