certalert-bot/php/bootstrap.php

22 lines
604 B
PHP
Raw Normal View History

2020-04-22 11:05:09 +02:00
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$mysql_user = '';
$mysql_pass = '';
$db = new PDO('mysql:host=127.0.0.1;dbname=certalertbot;charset=utf8mb4', $mysql_user, $mysql_pass);
$stmt = $db->prepare("SELECT id, chatid, type, value FROM rules");
$stmt->execute();
$rules = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rules as $rule) {
$toadd = array();
$id = $rule["id"];
$toadd["id"] = $id;
$toadd["value"] = array("t" => $rule["type"], "v" => $rule["value"], "c" => $rule["chatid"]);
$toadd = json_encode($toadd, JSON_NUMERIC_CHECK);
$redis->rPush('toadd', $toadd);
}