function generate_user_table($query) { // If the query includes FORMAT(creation_date, '...') AS formatted_creation, add that to the standard table // Note that this does not work for SELECT * - it searches for the string 'creation_date' in the query $creation_date_th = ''; $add_creation_date = false; if (strpos($query, 'formatted_creation')) { $creation_date_th = "\n <th>Account Creation</th>"; $add_creation_date = true; } $html_table = <<<HEREDOC <table class="contrasting"> <tr> <th>Name</th> <th>Email Address</th> <th>YOG</th>{$creation_date_th} </tr> HEREDOC; $result = DB::queryRaw($query); if (mysqli_num_rows($result) == 0) { if ($add_creation_date) { $html_table .= " <tr><td colspan=\"4\" class=\"text-centered\">None</td></tr>\n"; } else { $html_table .= " <tr><td colspan=\"3\" class=\"text-centered\">None</td></tr>\n"; } // if no results returned } else { $row = mysqli_fetch_assoc($result); while ($row) { $creation_date_td = ''; $trimmed_email = trim_email($row['email']); if ($add_creation_date) { $creation_date_td = "\n <td>{$row['formatted_creation']}</td>"; } $html_table .= <<<HEREDOC \t <tr> \t <td><a href="View_User?ID={$row['id']}">{$row['name']}</a></td> \t <td><a href="mailto:{$row['email']}" rel="external">{$trimmed_email}</a></td> \t <td>{$row['yog']}</td>{$creation_date_td} \t </tr> \t HEREDOC; $row = mysqli_fetch_assoc($result); } } $html_table .= " </table><br />\n"; return $html_table; }
function show_detail_page() { page_title('Registration Log'); $ip = htmlentities($_GET['IP']); echo <<<HEREDOC <h1>Registration Log</h1> <a href="Registration_Log" class="small">< Back to Full List</a><br /><br /> <span class="i">IP addresses that are spamming the site can be banned by editing /.lib/CONFIG.php</span><br /><br /> <span class="b">Accounts Created From {$ip}</span> <table class="visible"> <tr> <th>Name</th> <th>Email Address</th> <th>YOG</th> <th>Account Creation</th> <th>Status</th> </tr> HEREDOC; $query = 'SELECT name, email, yog, creation_date, DATE_FORMAT(creation_date, "%M %e, %Y") AS formatted_creation, approved FROM users WHERE registration_ip="' . mysqli_real_escape_string(DB::get(), $_GET['IP']) . '" ORDER BY creation_date DESC'; $result = DB::queryRaw($query); $row = mysqli_fetch_assoc($result); while ($row) { $color = '#a00'; $status = 'Banned'; if ($row['approved'] == 0) { $color = '#000'; $status = 'Pending'; } else { if ($row['approved'] == 1) { $color = '#0a0'; $status = 'Approved'; } } $email = trim_email($row['email']); echo <<<HEREDOC <tr> <td>{$row['name']}</td> <td>{$email}</td> <td>{$row['yog']}</td> <td>{$row['formatted_creation']}</td> <td style="color: {$color}">{$status}</td> </tr> HEREDOC; $row = mysqli_fetch_assoc($result); } echo " </table>\n"; }