certalert-bot/php/bootstrap.php

22 lines
628 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);
2020-05-13 11:53:58 +02:00
$mysql_user = 'mysql_user';
$mysql_pass = 'mysql_password';
2020-04-22 11:05:09 +02:00
$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);
}