-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathutils.php
58 lines (52 loc) · 1.87 KB
/
utils.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
<?php
class Utils {
var $url;
/**
* Finds the key in given multi-dimensional array.
*/
public static function findByKey($array = array(), $searchKey = '') {
while (list($key, $value) = each($array)) {
if ($key == $searchKey) {
return $value;
}
}
return '';
}
/**
* Returns the cached video from database.
*/
public static function getCachedVideo($videoSource = '', $videoId) {
global $wpdb;
return $wpdb->get_row("SELECT * FROM ".$wpdb->prefix."proplayer WHERE (VIDEO_SOURCE='$videoSource') AND (VIDEO_ID='$videoId')");
}
/**
* Adds a video to the cache table.
*/
public static function addCachedVideo($videoSource = '', $videoId = '', $videoUrl = '', $previewImage = '', $title = 'Pro Player') {
global $wpdb;
return $wpdb->query("INSERT INTO ".$wpdb->prefix."proplayer
VALUES (
'',
'$videoSource',
'$videoId',
'$videoUrl',
'$previewImage',
'".addslashes($title)."',
'".date("Y-m-d H:i:s", strtotime("now"))."'
)
");
}
/**
* Removes video from the cache table.
*/
public static function removeCachedVideo($videoSource = '', $videoId = '') {
global $wpdb;
return $wpdb->query("DELETE FROM ".$wpdb->prefix."proplayer
WHERE (
(VIDEO_SOURCE = '$videoSource')
AND (VIDEO_ID = '$videoId')
)
");
}
}
?>