-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
44 lines (40 loc) · 1.62 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
function getCurlData($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16");
$curlData = curl_exec($curl);
curl_close($curl);
return $curlData;
}
function webhook($webhook, $url, $title, $description, $embedColor, $timestamp, $footerIcon, $footerText, $authorName, $iconUrl, $botName, $botAvatar, $content) {
if(isset($embedColor)) {
if(strpos($embedColor, "#") > -1) {
$c=str_replace("#", "", $embedColor);
if (!preg_match("/#([a-fA-F0-9]{3}){1,2}\b/", $c)) {
$color = hexdec( strtolower($c) );
}
}
} else {
$color = 0;
}
$sys["content"] = $content;
$sys["username"] = $botName;
$sys["avatar_url"] = $botAvatar;
$footer = array("icon_url" => $footerIcon, "text" => $footerText);
$author = array("url" => "", "name" => "$authorName", "icon_url" => $iconUrl);
$embed = array("url" => $url, "title" => $title, "description" => $description, "color" => $color, "timestamp" => $timestamp, "footer" => $footer, "author" => $author);
$sys["embeds"] = array(0 => $embed);
$curl = curl_init($webhook);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($sys));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
}
$conn = new mysqli($config['dbHost'], $config['dbUser'], $config['dbPass'], $config['dbTable']);
if ($conn->connect_error) {
die("Oop's, Somethings broken!");
}
?>