C:\xampp\htdocs\unchained\unchainedServices\services\controller\CowatchUid.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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<?php
namespace controller;

class 
CowatchUid {
    
    var 
$TOTAL_PARTICIPANTS 201;
    var 
$ACCOUNT_ID "6e83fe48-5829-4306-9c11-";
    
    
    public function 
resetCowatch($cowatchId$time) {
        
$fName $cowatchId ".json";
        
        
$cowatchData = array(            
            
"prevCmdTmsp"=>time(),
            
"cmd"=>array("state"=> "pause""data"=>$time));        
        
        
file_put_contents($fNamejson_encode($cowatchData));        
        
        return 
1;
        
    }
    
    public function 
avatar($account_id) {
        
    }
    
    public function 
postCowatchSync($cowatchId) {
        
$fName $cowatchId ".json";
        
        
$body file_get_contents('php://input');
                
        
$requstOb json_decode($body,true);
        if(
array_key_exists("body"$requstOb) === TRUE) {
            
$requstOb json_decode($requstOb['body'], true);
        }
        
        
$cowatchData = array("prevCmdTmsp"=>time(), "cmd"=>array("state"=> "pause""data"=>-30));                    
                
        
// we got an explicit command from client organiser, ignore everything set it and return it as new state
        
if(array_key_exists("state"$requstOb) === TRUE) {            
            
$cowatchData = array(            
                
"prevCmdTmsp"=>time(),
                
"cmd"=>array("state"=> $requstOb['state'], "data"=>$requstOb["data"]));
            
            
file_put_contents($fNamejson_encode($cowatchData));
        } 
        
        
$ret = array("state"=> $requstOb['state'], "data"=>$requstOb["data"]);            
        return 
json_encode($ret);    
            
    }
    
    public function 
getCowatchSync($cowatchId) {
        
        
$fName $cowatchId ".json";
        
        
$body file_get_contents('php://input');
                
        
$requstOb json_decode($body,true);
        if(
array_key_exists("body"$requstOb) === TRUE) {
            
$requstOb json_decode($requstOb['body'], true);
        }
        
        
$cowatchData = array("prevCmdTmsp"=>time(), "cmd"=>array("state"=> "pause""data"=>-30));                    
                
        
// we got an explicit command from client organiser, ignore everything set it and return it as new state
        
if(array_key_exists("state"$requstOb) === TRUE) {            
            
$cowatchData = array(            
                
"prevCmdTmsp"=>time(),
                
"cmd"=>array("state"=> $requstOb['state'], "data"=>$requstOb["data"]));
            
            
file_put_contents($fNamejson_encode($cowatchData));
            
$ret = array("state"=> $requstOb['state'], "data"=>$requstOb["data"]);            
            return 
json_encode($ret);            
        } 
        
        
        if(
file_exists($fName)) {
            
$cowatchLoadedData file_get_contents($fName);                    
            
$cowatchData json_decode($cowatchLoadedDatatrue);    
        }            
    


        
$currentCmd $cowatchData['cmd'];        
        
        
$currentCmdTime $cowatchData['prevCmdTmsp'];
        
$timeDiff time() - $currentCmdTime;
                
        
        if(
$currentCmd['state'] === "pause") {
            if(
$currentCmd['data'] < 0) {
                
                if(
$currentCmd['data'] + $timeDiff >= 0) { // switch to play
                    // switch to play
                    
$currentCmd['state'] = "play";
                    
$currentCmd['data'] = $currentCmd['data'] + $timeDiff;
                } else {
                    
// still in negative pause
                    
$currentCmd['state'] = "pause";
                    
$currentCmd['data'] = $currentCmd['data'] + $timeDiff;
                }
            }             
        } else if(
$currentCmd['state'] === "ended") {
            
$currentCmd['state'] = "ended";
            
$currentCmd['data'] = $currentCmd['data'] + $timeDiff;
        }
        else {
            
$currentCmd['data'] = $currentCmd['data'] + $timeDiff;
        }    
        
                
        
$cowatchData['prevCmdTmsp'] = time();
        
$cowatchData['cmd'] = $currentCmd;
                        
        
file_put_contents($fNamejson_encode($cowatchData));        
        
        
$ret = array("state"=>$cowatchData['cmd']);
        return 
json_encode($currentCmd);
    }
    
            
    
// GET /socialstore/follow/suggestions?size=50&offset=100
    
public function getCowatchUsers($cowatchId) {
        
$db = \MysqliDb::getInstance();        
        
        
$limit $_GET['size'];
        if(
$limit $_GET['offset'] > $this->TOTAL_PARTICIPANTS) {
            
$limit $this->TOTAL_PARTICIPANTS $_GET['offset'];
        }
        
        
$params = Array($limit$_GET['offset']);
        
        
$users $db->rawQuery("SELECT id, name FROM actors where id > 10 ORDER BY id ASC LIMIT ? OFFSET ? "$params);

        
$items array_map(function($item) {
            return array(
                
'account_id' => $this->ACCOUNT_ID $item['id'],
                
'user_name' => $item['name'],                
            );
        }, 
$users);
        
        
$data = array("items"=>$items"total_items"=>$this->TOTAL_PARTICIPANTS);
        
        return 
json_encode(array("success"=> true'data'=>$data));    
    }
    
    public function 
searchCowatchUsers($cowatchId
    {
        
$db = \MysqliDb::getInstance();        
        
        
$body file_get_contents('php://input');
        
$requstOb json_decode($body,true);        
        
        
//,
        
$params = Array( $_GET['size'], $_GET['offset']);
        
//$users = $db->rawQuery("SELECT id, name FROM actors where id > 10 and name LIKE '%" . $requstOb['data']['nickname'] . "%' ORDER BY id ASC LIMIT ? OFFSET ? ", $params);
        
$users $db->rawQuery("SELECT id, name FROM actors where id > 10 and name LIKE '%" $requstOb['data']['nickname'] . "%' ORDER BY id ASC"$params);
        
        
$total count($users);
        if(
$total $this->TOTAL_PARTICIPANTS) {
            
$total $this->TOTAL_PARTICIPANTS;
        }
        
        
$start $_GET['offset'];
        
$end  $start $_GET['size'];
        if(
$end $total) {
            
$end $total;
        }
        
        
$items = [];
        for(
$i $start$i $end$i++) {
            
$items[] = array(
                
'account_id' => $this->ACCOUNT_ID $users[$i]['id'],
                
'user_name' => $users[$i]['name'],
            );
        }
        
        
$data = array("items"=>$items"total_items"=>$total);
        
        return 
json_encode(array("success"=> true'data'=>$data));
    }
    
    
    public function 
getCowatchDetailsCinema($cowatchId)
    {      
        if(
$cowatchId === null) {
            
$cowatchId 12312312;
        }
        
$cid  0
        if(
$cowatchId 6) {
        
            if(
file_exists('cid.txt')) {
                
$cid = (int)file_get_contents('cid.txt');
            } else {
                
$cid 7;
            }
            
$cid++;
            if(
$cid >= 28) {
                
$cid 7;
            }

            
file_put_contents("cid.txt"$cid);
        }
        else {
            
$cid $cowatchId;
        }
    
        
//$startTimestamp = strtotime('now');
        
$startTimestamp 1586598000;
        
$duration 2*60*60;
        
        
$userName "User name " $cid;
        
        
$users = ["""Mihai Crasneanu""Paul A. Thomas""Crystal A. Heron""S_Perrineau""Maurice M. Morales"];
        if(
$cid && $cid 0) {
            
$userName $users[$cid];
        }
    
        
$ret = array(
                
"success"=> true,    
                
                
'account_id' => $this->ACCOUNT_ID $cid,
                
'user_name' => $userName,
                
                
"data"=> array(
                    
"id"=> 123,
                    
"type"=>2,
                    
"short_description"=> "You think you know all about “The Matrix”? There are still plenty of dark corners in the backstory of the movie that popularized the special effects phenomenon dubbed “bullet time”.",
                    
"description"=> "Geoffrey will take us through the iconic scenes of the movie and explain to us in great detail not only how things were made at that time and how they made The Matrix so unique, but he will reveal and discuss the ways in which the movie changed Hollywood and how the tremendous visual effects came together. Topics covered will include: Having a camera pan around characters who are nearly frozen in super slo-mo wasn’t something The Matrix invented but the effect was immediately copied everywhere in movies and on TV. A new way of doing stunt work was born with The Matrix with its carefully coreographed fight scenes that required six months of training with the actors and the stunt performers. A breakdown of innovative visuals and special effects such as wall-scaling, digital compositing, virtual backgrounds, airborne kung fu and shoot-outs. And much more. Two additional Visual Effects experts will join us for the Q&A section",
                    
"start_tmsp"=> $startTimestamp,
                    
"duration"=> 60*60*2,
                    
// "totalParticipants" => $this->TOTAL_PARTICIPANTS,
                    
"backdrop" => "1.png",
                    
                    
"asset"=> array(
                        
"release_year"=> 1999,
                        
"title"=> "The Matrix",                    
                    )
                ),
            );        

        return 
json_encode($ret);
    }    
    

    public function 
getCowatchDetails($cowatchId)
    {      
        if(
$cowatchId === null) {
            
$cowatchId 12312312;
        }
        
        
$cid  0
        if(
$cowatchId 6) {        
            if(
file_exists('cid.txt')) {
                
$cid = (int)file_get_contents('cid.txt');
            } else {
                
$cid 7;
            }
            
$cid++;
            if(
$cid >= 28) {
                
$cid 7;
            }

            
file_put_contents("cid.txt"$cid);
        }
        else {
            
$cid $cowatchId;
        }

        
$presenters = array();

        
$presenters[] = 
            array(                
                
"role"=> 1,
                
"account_id"=> $this->ACCOUNT_ID 1,
                
"user_name"=> "Mihai Crasneanu",
                
"location"=> "Los Angeles, LA"
            
);
        
        
$presenters[] = 
            array(                
                
"role"=> 2,
                
"account_id"=> $this->ACCOUNT_ID 2,                
                
"user_name"=> "Paul A. Thomas",
                
"location"=> "Targu Mures"
        
);

        
        
$presenters[] = 
        array(            
            
"role"=> 3,
            
"account_id"=> $this->ACCOUNT_ID 4,            
            
"user_name"=> "S_Perrineau",
            
"location"=> "New York, NY"
        
);
    
    
$presenters[] = 
        array(
            
"role"=> 3,
            
"account_id"=> $this->ACCOUNT_ID 5,            
            
"user_name"=> "Maurice M. Morales",
            
"location"=> "Pennsylvania, Harrisburg - USA"
    
);
    
    
$presenters[] = 
            array(                
                
"role"=> 3,
                
"account_id"=> $this->ACCOUNT_ID 3,
                
"user_name"=> "Crystal A. Heron",
                
"location"=> "Targu Mures"
        
);    
    
        
// $startTimestamp = strtotime('now');
        
$startTimestamp 1586599000;
        
$duration 2*60*60;
        
        
$userName "User name " $cid;
        
        
$users = ["""Mihai Crasneanu""Paul A. Thomas""Crystal A. Heron""S_Perrineau""Maurice M. Morales"];
        if(
$cid && $cid 0) {
            
$userName $users[$cid];
        }
    
        
$ret = array(
                
"success"=> true,    
                
                
'account_id' => $this->ACCOUNT_ID $cid,
                
'user_name' => $userName,
                
                
"data"=> array(
                    
"id"=> 123,
                    
"type"=>1,
                    
"title"=> "Dissecting the Visual Effects 20 years later.",
                    
"short_description"=> "You think you know all about “The Matrix”? There are still plenty of dark corners in the backstory of the movie that popularized the special effects phenomenon dubbed “bullet time”.",
                    
"description"=> "Geoffrey will take us through the iconic scenes of the movie and explain to us in great detail not only how things were made at that time and how they made The Matrix so unique, but he will reveal and discuss the ways in which the movie changed Hollywood and how the tremendous visual effects came together. Topics covered will include: Having a camera pan around characters who are nearly frozen in super slo-mo wasn’t something The Matrix invented but the effect was immediately copied everywhere in movies and on TV. A new way of doing stunt work was born with The Matrix with its carefully coreographed fight scenes that required six months of training with the actors and the stunt performers. A breakdown of innovative visuals and special effects such as wall-scaling, digital compositing, virtual backgrounds, airborne kung fu and shoot-outs. And much more. Two additional Visual Effects experts will join us for the Q&A section",
                    
"start_tmsp"=> $startTimestamp,
                    
"duration"=> 60*60*2,
                    
// "totalParticipants" => $this->TOTAL_PARTICIPANTS,
                    
"backdrop" => "1.png",
                    
                    
"agenda" => array(
                        array(
"time"=>"7:15 PM""description"=>"We will start playing some scenes from the movie while everyone joins"),
                        array(
"time"=>"7:35 PM""description"=>"Geoffrey will join us via webcam. We will talk a bit about his experience and achievements, from The Day Before Tomorrow to Black Panther and his BAFTA coronation"),
                        array(
"time"=>"8:00 PM""description"=>"Geoffrey will begin his presentation and walk us through the movie"),
                        array(
"time"=>"8:30 PM""description"=>"Q&A with two additional guests"),
                        array(
"time"=>"9:00 PM""description"=>"Geoff wants have to leave. But you can stay in the chat room with me for more discussions among us and we can see more scenes of the movie"),
                        array(
"time"=>"9:30 PM""description"=>"The end")
                    ),
                
                    
"presenters"=> $presenters,
                
                    
"asset"=> array(
                        
"release_year"=> 1999,
                        
"title"=> "The Matrix",
                    )
                )
            
            );        

        return 
json_encode($ret);
    }    
}
?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586