forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.abstract.php
438 lines (350 loc) · 11.2 KB
/
Plugin.abstract.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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<?php
require_once $global['systemRootPath'] . 'objects/plugin.php';
abstract class PluginAbstract {
static $dataObject = array();
/**
* the plugin identification, that is what differ one prlugin from other, so it needs to be unique
* return the universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems
* if you not sure get one here https://www.uuidgenerator.net/
*/
abstract function getUUID();
/**
* most of the cases it must be the same name as the plugin
* return the name ot the plugin
*/
abstract function getName();
/**
* return the description of the plugin
*/
abstract function getDescription();
/**
* return the version of the plugin
*/
public function getPluginVersion() {
return "1.0";
}
public function updateScript() {
return false;
}
public function getFooterCode() {
return "";
}
public function getHeadCode() {
return "";
}
public function getHelp() {
return "";
}
public function getHTMLBody() {
return "";
}
public function getHTMLMenuLeft() {
return "";
}
public function getHTMLMenuRight() {
return "";
}
public function getChartContent() {
return "";
}
public function getPluginMenu() {
return "";
}
public function getJSFiles() {
return array();
}
public function getCSSFiles() {
return array();
}
public function getVideosManagerListButton() {
return "";
}
public function getUsersManagerListButton() {
return "";
}
public function getTags() {
}
public function getGallerySection() {
return "";
}
public function getDataObject() {
if (empty(PluginAbstract::$dataObject[$this->getUUID()])) {
$obj = Plugin::getPluginByUUID($this->getUUID());
//echo $obj['object_data'];
$o = array();
if (!empty($obj['object_data'])) {
$o = json_decode(stripslashes($obj['object_data']));
switch (json_last_error()) {
case JSON_ERROR_NONE:
//echo ' - No errors';
break;
default:
error_log('getDataObject - JSON error');
error_log($obj['object_data']);
error_log('striped slashes');
error_log(stripslashes($obj['object_data']));
case JSON_ERROR_DEPTH:
error_log(' - Maximum stack depth exceeded');
break;
case JSON_ERROR_STATE_MISMATCH:
error_log(' - Underflow or the modes mismatch');
break;
case JSON_ERROR_CTRL_CHAR:
error_log(' - Unexpected control character found');
break;
case JSON_ERROR_SYNTAX:
error_log(' - Syntax error, malformed JSON');
error_log($obj['object_data']);
error_log('striped slashes');
error_log(stripslashes($obj['object_data']));
break;
case JSON_ERROR_UTF8:
error_log(' - Malformed UTF-8 characters, possibly incorrectly encoded');
break;
}
}
$eo = $this->getEmptyDataObject();
$wholeObjects = array_merge((array) $eo, (array) $o);
$disabledPlugins = plugin::getAllDisabled();
foreach ($disabledPlugins as $value) {
$p = YouPHPTubePlugin::loadPlugin($value['dirName']);
if (is_object($p)) {
$foreginObjects = $p->getCustomizeAdvancedOptions();
if ($foreginObjects) {
foreach ($foreginObjects as $optionName => $defaultValue)
if (isset($wholeObjects[$optionName]))
unset($wholeObjects[$optionName]);
}
}
}
PluginAbstract::$dataObject[$this->getUUID()] = $wholeObjects;
}else {
$wholeObjects = PluginAbstract::$dataObject[$this->getUUID()];
}
//var_dump($obj['object_data']);
//var_dump($eo, $o, (object) array_merge((array) $eo, (array) $o));exit;
return (object) $wholeObjects;
}
public function setDataObject($object) {
$pluginRow = Plugin::getPluginByUUID($this->getUUID());
$obj = new Plugin($pluginRow['id']);
$obj->setObject_data(addcslashes(json_encode($object),'\\'));
return $obj->save();
}
public function getEmptyDataObject() {
$obj = new stdClass();
return $obj;
}
public function getFirstPage() {
return false;
}
public function afterNewVideo($videos_id) {
return false;
}
public function afterNewComment($comments_id) {
return false;
}
public function afterNewResponse($comments_id) {
return false;
}
public function xsendfilePreVideoPlay() {
return false;
}
public function getLogin() {
$obj = new stdClass();
$obj->class = ""; // btn btn-primary btn-block
$obj->icon = ""; // fab fa-facebook-square
$obj->type = ""; // Facebook, Google, etc
$obj->linkToDevelopersPage = ""; //https://console.developers.google.com/apis/credentials , https://developers.facebook.com/apps
return $obj;
}
public function getWatchActionButton($videos_id) {
return "";
}
public function getNetflixActionButton($videos_id) {
return "";
}
public function getGalleryActionButton($videos_id) {
return "";
}
public function getStart() {
return false;
}
public function getEnd() {
return false;
}
public function canEditPlugin() {
global $global;
return empty($global['disableAdvancedConfigurations']);
}
public function hidePlugin() {
return false;
}
public function getChannelButton() {
return "";
}
public function getVideoManagerButton() {
return "";
}
public function getLivePanel() {
return "";
}
public function getPlayListButtons($playlist_id) {
return "";
}
public function getMyAccount($users_id) {
return "";
}
/**
*
* @return type array(array("key"=>'live key', "users"=>false, "name"=>$userName, "user"=>$user, "photo"=>$photo, "UserPhoto"=>$UserPhoto, "title"=>''));
*/
public function getLiveApplicationArray() {
return array();
}
public function addRoutes() {
return false;
}
public function addView($videos_id, $total) {
return false;
}
public function getCustomizeAdvancedOptions() {
return false;
}
public function getUserOptions() {
return array();
}
public function getModeYouTube($videos_id) {
return false;
}
/**
* Loads a channel before display the channel page, usefull to create customized channel pages
* @param type $user is an database array from channels owner
* @return boolean
*/
public function getChannel($user_id, $user) {
return false;
}
/**
*
* @return type return a list of IDs of the user groups
*/
public function getDynamicUserGroupsId($users_id) {
return array();
}
public function navBarButtons() {
return "";
}
public function navBar() {
return "";
}
public function isReady($pluginsList) {
$return = array('ready' => array(), 'missing' => array());
foreach ($pluginsList as $name) {
$plugin = YouPHPTubePlugin::loadPlugin($name);
$uuid = $plugin->getUUID();
if (!YouPHPTubePlugin::isEnabled($uuid)) {
$return['missing'][] = array('name' => $name, 'uuid' => $uuid);
} else {
$return['ready'][] = array('name' => $name, 'uuid' => $uuid);
}
}
return $return;
}
public function isReadyLabel($pluginsList) {
$desc = "<br>";
$ready = $this->isReady($pluginsList);
foreach ($ready['ready'] as $value) {
$desc .= "<span class='btn btn-success btn-sm btn-xs' onclick='$(\"#enable{$value['uuid']}\").prop(\"checked\", false);$(\"#enable{$value['uuid']}\").trigger(\"change\");'>{$value['name']}</span> ";
}
foreach ($ready['missing'] as $value) {
$desc .= "<span class='btn btn-danger btn-sm btn-xs' onclick='$(\"#enable{$value['uuid']}\").prop(\"checked\", true);$(\"#enable{$value['uuid']}\").trigger(\"change\");'>{$value['name']}</span> ";
}
return $desc;
}
public function getAllVideosExcludeVideosIDArray() {
return array();
}
/**
*
* @param type $users_id
* @param type $videos_id
* @return 0 = I dont know, -1 = can not watch, 1 = can watch
*/
public function userCanWatchVideo($users_id, $videos_id) {
return 0;
}
public function userCanWatchVideoWithAds($users_id, $videos_id) {
return 0;
}
/**
* temporary, to avoid error on old secureVideosDirectory plugins
* @return boolean
*/
function verifyEmbedSecurity() {
return true;
}
function showAds($videos_id) {
return true;
}
function getVideo() {
return null;
}
public function onUserSignIn($users_id){
return null;
}
public function onUserSignup($users_id){
return null;
}
public function onLiveStream($users_id){
return null;
}
public function thumbsOverlay($videos_id){
return "";
}
public static function profileTabName($users_id){
return "";
}
public static function profileTabContent($users_id){
return "";
}
public static function getVideoWhereClause(){
return "";
}
public static function getManagerVideosAddNew(){
return "";
}
public static function saveVideosAddNew($post, $videos_id){
return true;
}
public static function getManagerVideosReset(){
return "";
}
public static function getManagerVideosEdit(){
return "";
}
public static function getManagerVideosEditField(){
return "";
}
public static function getManagerVideosJavaScripts(){
return "";
}
public static function getManagerVideosTab(){
return "";
}
public static function getManagerVideosBody(){
return "";
}
public static function getAllVideosArray($videos_id){
return array();
}
public static function getVideoTags($videos_id){
return array();
}
public function getMobileInfo(){
return null;
}
public function getUploadMenuButton(){
return "";
}
}