function block_users() { $users = get_blocked_users(); $ip_address = $_SERVER["REMOTE_ADDR"]; if (!($_SERVER["REQUEST_URI"] === "/blocked" || $_SERVER["REQUEST_URI"] === "/blocked/") && strpos($_SERVER["REQUEST_URI"], "/res") === false && !is_owner()) { foreach ($users as $user) { if ($user["ip"] == $ip_address) { header("Location: /blocked"); } } } }
<thead><tr> <td>Block ID</td> <td>IP Address</td> <td>Reason</td> <td>Unblock</td> </tr></thead> <tbody></tbody> </table> </div> </div> <script> var data = [ <?php // What a horrible piece of code this is. Yes, I'm writing JavaScript in PHP. $blocked = get_blocked_users(); foreach ($blocked as $block) { echo "["; echo "'" . $block["id"] . "',"; echo "'" . $block["ip"] . "',"; echo "'" . str_replace("'", "\\'", $block["reason"]) . "',"; echo "'<a href=\\'#\\' class=\\'error admin-action\\' data-url=\\'/admin/users/unblock_user.php\\' data-request-type=\\'POST\\' data-desc=\\'unblock this IP address\\' data-id=\\'" . $block["id"] . "\\'>Unblock</a>'"; echo "],"; } ?> ]; </script> <?php include $_SERVER["DOCUMENT_ROOT"] . "/../includes/content.resources.php"; ?>
echo "graph_info Displays the sum of users, as well as disabled count, in your Drupal site\n"; echo "users_total.label total users\n"; echo "users_blocked.label blocked users\n"; echo "users_total.min 0\n"; echo "users_blocked.min 0\n"; exit(0); } // Connect to database $dbh = new mysqli($host, $user, $pass, $db, $port); if (mysqli_connect_errno()) { echo "Connecction failed: " . mysqli_connect_error() . PHP_EOL; exit(1); } // Print out the actual values $users_total = (int) get_total_users($dbh); $users_blocked = (int) get_blocked_users($dbh); echo "users_total.value {$users_total}\n"; echo "users_blocked.value {$users_blocked}\n"; $dbh->close(); /** * Get count for all users * @return integer $count total users */ function get_total_users(&$dbh = NULL) { $table_prefix = getenv('table_prefix'); $sql = "SELECT COUNT(uid) AS count FROM {$table_prefix}users"; $result = $dbh->query($sql); $row = $result->fetch_assoc(); return (int) $row['count']; }