-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.php
63 lines (51 loc) · 1.48 KB
/
start.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
60
61
62
63
<?php
use MagicObject\Database\PicoDatabaseCredentials;
use MagicObject\Util\PicoEnvironmentVariable;
use MusicProductionManager\Config\ConfigApp;
use MusicProductionManager\Util\WebsocketClient;
require_once "inc/app.php";
$env = new PicoEnvironmentVariable();
// Prepare app configuration
$iniApp = parse_ini_file(__DIR__."/wsserver/dashboard.ini");
$conf = new ConfigApp();
foreach($iniApp as $key=>$val)
{
$value = $env->replaceWithEnvironmentVariable($val);
$conf->set($key, $value);
}
// Prepare app configuration
$dbconf = new PicoDatabaseCredentials();
// time_zone_system=Asia/Jakarta
$timeZone = $dbconf->getTimeZoneSystem();
if($timeZone != null && !empty($timeZone))
{
// Update time zone
date_default_timezone_set($timeZone);
}
$host = $conf->getServerHostAdmin();
$port = $conf->getServerPortAdmin();
$path = "/";
$ssl = false;
$timeout = 30;
$username = 'endang';
$password = 'endang';
$persistant = false;
$context = null;
$headers = array(
'Authorization: Basic '.base64_encode($username.':'.$password)
);
$websocketAdmin = WebsocketClient::websocketOpen($host, $port, $headers, $error_string, $timeout, $ssl, $persistant, $path, $context);
if($websocketAdmin !== false)
{
$message = json_encode(
array(
'command'=>'forward',
'recipient'=>'endang',
'data'=>array(
'apa'=>'iya'
)
)
);
WebsocketClient::websocketWrite($websocketAdmin, $message);
fclose($websocketAdmin);
}