-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathssCommon.php
More file actions
163 lines (151 loc) · 4.7 KB
/
ssCommon.php
File metadata and controls
163 lines (151 loc) · 4.7 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!--
ssCommon.php
part of Quinn Ebert's "Zedom8or" software project
PURPOSE:
Common server-side code utilities used by the various
interfaces in the Zedom8or Project.
-->
<?php
/*
CONFIGURATION:
Set the IP or hostname of your VSX-1022-K below, indicate if you want the
alert to successful command send dialog to appear, and enjoy!
*/
// Network address where your TiVo can be reached:
if ( ! isset($tivobox) ) $tivobox = '192.168.1.5';
// ^ Let $tivobox be overridden by external apps (like Zedom8or/"Z8"):
if (isset($_GET['tivobox'])) $tivobox = $_GET['tivobox'];
/*
* CODE BELOW
*/
require(dirname(__FILE__).'/Z8DevCfg.php');
require(dirname(__FILE__).'/Z8Config.php');
require_once(dirname(__FILE__).'/irtFuncs.php');
require_once(dirname(__FILE__).'/PioneerRebel/pioneer.lib.php');
// Load in stuff from 'DevicesLibrary' for any phpClass-using devices:
foreach ($devices as $device) {
if ($device['control'] == 'phpClass') {
$useFile = dirname(__FILE__).'/DevicesLibrary/'.$device['class'].'.php';
if (!file_exists($useFile))
die('FATAL: the "'.$useFile.'" class file couldn\'t be loaded!');
require_once($useFile);
}
}
if (!function_exists('strhasprefix')) {
function strhasprefix($haystack,$needle) {
return (strstr($haystack,$needle)==$haystack);
}
}
if (!function_exists('z8_render_ctl_command')) {
function z8_render_ctl_command($control,$callback_name) {
if (strhasprefix($control['type'],'button_oneshot')) {
return '<input type="button" name="'.$control['name'].'" value="'.$control['name'].'" onclick="javascript:z8_js_button_oneshot(\''.$callback_name.'\',\''.str_replace('\'',"\\".'\'',$control['command']).'\');" />';
}
return 'Foo';
}
}
if (!function_exists('z8_render_ctl_table')) {
function z8_render_ctl_table($title,$controls,$callback_name) {
/* NOTE TO MYSELF:
$controls should be any array like:
$controls = array(
[0] => array(
'device_link' => ...'link_as' name for device (used for JS linkage)...,
'type' => ...command type...,
'name' => ...command name...,
'command' => ...command string...,
)
);
*/
$returns = '<table class="ctlTable" border="3"><tr><td>'.$title.'</td></tr><tr><td>';
$lastDev = (count($controls)-1);
for ($i = 0; $i <= $lastDev; $i++) {
$returns .= z8_render_ctl_command($controls[$i],$callback_name);
if ($i < $lastDev)
$returns .= '<br />';
}
$returns .= '</td></tr></table>';
return $returns;
}
}
if (!function_exists('primeRPi')) {
function primeRPi() {
require(dirname(__FILE__).'/Z8Config.php');
if (!isset($primePi)) $primePi = false;
if ($primePi) {
ob_start();
$notUsed = lirc_get_remote_names();
ob_end_clean();
}
}
}
//FIXME: this was only originally meant for testing!
if ( isset($_GET['VizioTV_GoVGA']) ) {
primeRPi();
ob_start();
system('irsend SEND_START BS_Vizio KEY_TRAIN');
sleep(1);
system('irsend SEND_STOP BS_Vizio KEY_TRAIN');
sleep(10);
for ($i = 1; $i <= 6; $i++) {
system('irsend SEND_START BS_Vizio KEY_INPUT');
sleep(1);
system('irsend SEND_STOP BS_Vizio KEY_INPUT');
}
ob_end_clean();
header('Content-Type: text/xml');
die("<vzTryOut>\n <status>OK</status>\n</vzTryOut>\n");
}
//FIXME: this was only originally meant for testing!
if ( isset($_GET['VizioTV_GoPioneer']) ) {
primeRPi();
ob_start();
system('irsend SEND_START BS_Vizio KEY_TRAIN');
sleep(1);
system('irsend SEND_STOP BS_Vizio KEY_TRAIN');
sleep(10);
for ($i = 1; $i <= 7; $i++) {
system('irsend SEND_START BS_Vizio KEY_INPUT');
sleep(1);
system('irsend SEND_STOP BS_Vizio KEY_INPUT');
}
ob_end_clean();
header('Content-Type: text/xml');
die("<vzTryOut>\n <status>OK</status>\n</vzTryOut>\n");
}
if ( isset($_GET['VizioTV_GoTaKa']) ) {
primeRPi();
ob_start();
system('irsend SEND_START BS_Vizio KEY_TRAIN');
sleep(1);
system('irsend SEND_STOP BS_Vizio KEY_TRAIN');
sleep(10);
for ($i = 1; $i <= 9; $i++) {
system('irsend SEND_START BS_Vizio KEY_INPUT');
sleep(1);
system('irsend SEND_STOP BS_Vizio KEY_INPUT');
}
ob_end_clean();
header('Content-Type: text/xml');
die("<vzTryOut>\n <status>OK</status>\n</vzTryOut>\n");
}
//FIXME: this was only originally meant for testing!
if ( isset($_GET['powerOff_VizioTV']) ) {
primeRPi();
ob_start();
system("irsend SEND_START 'BS_Vizio' 'KEY_POWER'");
sleep(3);
system("irsend SEND_STOP 'BS_Vizio' 'KEY_POWER'");
ob_end_clean();
header('Content-Type: text/xml');
die("<vzTryOut>\n <status>OK</status>\n</vzTryOut>\n");
}
//FIXME: this was only originally meant for testing!
if ( isset($_GET['powerOn_ViewsonicTV']) ) {
ob_start();
system('./pjd7820hd.py');
ob_end_clean();
header('Content-Type: text/xml');
die("<vsTryOut>\n <status>OK</status>\n</vsTryOut>\n");
}
?>