public static function searchForRules($query, $showInternalInformation = false, $AHUser = null)
 {
     $conn = mysqli_connect(\AHContentBlockerServer\DATABASE_HOST, \AHContentBlockerServer\DATABASE_USERNAME, \AHContentBlockerServer\DATABASE_PASSWORD, \AHContentBlockerServer\DATABASE_NAME);
     if (!$conn || $conn->connect_errno) {
         throw new \AHContentBlockerServer\AHException('Could not connect to database.', \AHContentBlockerServer\AHException::DATABASE_CONNECTION_FAILED);
     }
     $results = mysqli_query($conn, $query) or die(mysqli_error($conn));
     $returnInfo = [];
     while ($row = mysqli_fetch_assoc($results)) {
         $rule = new \AHContentBlockerServer\Rules\Rule(null, $AHUser);
         $rule->loadFromID($row['id']);
         $returnInfo[] = $rule->arrayFromRule($showInternalInformation);
     }
     return $returnInfo;
 }
<?php

require_once __DIR__ . '/../../../requirements/config.php';
session_start();
header('Content-Type: application/json');
try {
    parse_str(file_get_contents("php://input"), $request_params);
    $server = new \AHContentBlockerServer\OAuth\Server();
    $server->checkUserAuthentication(true, $request_params);
    $user = $server->getCurrentUser();
    if (!is_null($user)) {
        $userID = $user->getUserID();
    } else {
        $userID = 0;
    }
    $rule = new \AHContentBlockerServer\Rules\Rule($request_params);
    $rule->save($userID);
} catch (Exception $e) {
    die(json_encode(['error' => ['message' => $e->getMessage()]]));
}
echo json_encode(['success' => true]);