-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor.php
61 lines (47 loc) · 1.26 KB
/
color.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
function http_response($ch, $url)
{
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return $httpCode . ' - ' . $response;
}
$value = $_GET['value'];
echo $value;
if(!preg_match('![a-fA-F0-9]{6}!', $value)) {
$value = 'ffffff';
echo 'fail' . "\n";
}
$mode = $_GET['mode'];
if(!in_array($mode, ['s', 'y', 'f'])) {
$mode = 's';
}
$stromstoss = $_GET['stromstoss'];
if(!$stromstoss==1) {
$stromstoss = 0;
}
$red = hexdec(substr($value, 0, 2));
$green = hexdec(substr($value, 2, 2));
$blue = hexdec(substr($value, 4, 2));
$baseUrl = 'http://netio.chch.lan.ffc/ecmd?';
$url = $baseUrl . 'channel%20';
$ch = curl_init();
$step = intval($_GET['fadestep']);
if(is_int($step)) {
echo http_response($ch, $baseUrl . 'fadestep' . '%20' . $step);
echo "\n";
}
if($stromstoss==0) {
$red=$red;
$green=$green*200/255;
$blue=$blue*128/255;
}
echo $url . '5' . '%20' . $red . '%20' . $mode . "\n";
echo http_response($ch, $url . '5' . '%20' . $red . '%20' . $mode);
echo "\n";
echo http_response($ch, $url . '4' . '%20' . $green . '%20' . $mode);
echo "\n";
echo http_response($ch, $url . '3' . '%20' . $blue . '%20' . $mode);
echo "\n";
curl_close($ch);