C:\xampp\htdocs\kptv\backup_ro\func\util.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
<?php
    
function getContentFct($data)
    {        
        
$ret = array();
        
preg_match_all('/\[\{(.*)\}\]/'$data$matches);
        if(
array_key_exists(1$matches)) {
            for(
$i 0$i count($matches[1]); $i++) {                
                
preg_match('/([\w\_\d]+)\(([\w\W]*)\)/'$matches[1][$i], $fctDef);                
                foreach(
$fctDef as $index => $value) {                    
                    
$params explode(","$value);                    
                    foreach(
$params as $paramIndex=>$paramVal) {                        
                        
$params[$paramIndex] = str_replace('&quot;'''$paramVal);
                    }
                    
array_unshift($params$fctDef[1]); // add function name at the beginning
                
}                
                
$ret[$matches[0][$i]] = $params;
            }
        }        
        return 
$ret;        
    }

    function 
processContentFct($fctArr$dbConn)     
    {        
        
$ret = array();
        foreach(
$fctArr as $fctSignature=>$fctParams) {            
            switch(
$fctParams[0]) {
                case 
'youtube':                    
                    
$retFct _fctCall_youtube($fctParams);
                    if(
$ret !== FALSE) {
                        
$ret[$fctSignature] = $retFct;
                    }
                break;
                case 
'playlist':
                    
$retFct _fctCall_playlist($fctParams$dbConn);
                    if(
$ret !== FALSE) {
                        
$ret[$fctSignature] = $retFct;
                    }                
                break;
            }
        }        
        return 
$ret;
    }

    function 
updatePageData($replaceArr$content) {        
        foreach(
$replaceArr as $str=>$value) {    
            
$content str_replace($str$value$content);
        }
        return 
$content;
    }

    function 
_fctCall_youtube($params)
    {           
        
$videoId = isset($params[1]) ? $params[1]:null;        
        if(
$videoId === null) {            
            return 
FALSE;
        }
          
        
$contentStr '<iframe 
           width="{width}"
            height="{height}"
            frameborder="0"
            allow="accelerometer; encrypted-media; gyroscope; picture-in-picture"          
            src="https://www.youtube.com/embed/'
.$videoId.' "></iframe>'
        
        
$width = isset($params[2]) ? $params[2]:"100%";
        
$height = isset($params[3]) ? $params[3]:"100%";
        
        
$contentStr str_replace ("{width}"$width$contentStr);
        
$contentStr str_replace ("{height}"$height$contentStr);        

        return 
$contentStr;
    }

    function 
_fctCall_playlist($params$dbConn)
    {
        
        
$sql "SELECT * from playlist where playlist_id = " $params[1] . " order by display_order asc";

        if(!
$dbConn->query($sql)) {
            return 
FALSE;            
        }

        
$itemsIds = array();
        for(
$i 0$i $dbConn->result->rows$i++) {
            
$row mysql_fetch_assoc($dbConn->result->result);            
            
$itemsIds[] = $row['id'];
        }
        
//print_r($itemsIds);

        
$ip $_SERVER['REMOTE_ADDR'];   
        
$playlistItemsVoted = array();      
        
$retVotesByIp mysql_query("SELECT playlist_item_id FROM playlist_votes WHERE voter_ip = '$ip' and playlist_item_id in (" implode($itemsIds","). ")");
        while(
$row mysql_fetch_array($retVotesByIp)) {          
          
$playlistItemsVoted[] = $row['playlist_item_id'];          
        }
        
        
mysql_data_seek($dbConn->result->result0);

        
$contentStr '
        <div class="tsl_item tsl_item_1 "> 
        <div alignment="left" class="tsl_left"> 
          <div class="tsl_thumb"> 
            <div class="tsl_video"> 
              <div id="{videoid}" style="width: 250px; height: 200px;" class="youtube"> 
                <div><img class="thumb" src="http://i.ytimg.com/vi/{videoid}/default.jpg" /></div> 
              </div> 
              <div class="tsl_img_credit"></div> 
            </div> 
          </div> 
        </div> 
        <div class="tsl_right "> 
          <div> 
            <div class="tsl_number tsl_number_2dig  button">{order}</div> 
            
              <div class="tsl_title tsl_title_middle" ><strong>{artist}<br></strong><span class="playlist_subtitle">{subtitle}</span></div>               
            
            <div class="tsl_clear">&nbsp;</div> 
          </div> 
          <div class="tsl_iGap"> &nbsp;</div> 
          <div class="tsl_descr"><p>{shortdescription}</p></div> 
          <div class="tsl_links"> 
            <div class="tsl_link">{vote_button}</div> 
            <div class="tsl_clear"> &nbsp;</div> 
          </div> 
        </div> 
        <div class="tsl_clear"> &nbsp;</div> 
      </div>'
;

//<a target="_blank" href="{video_url}" shape="rect">Hear "{artist}"</a>
        
$retContent "";
        for(
$i 0$i $dbConn->result->rows$i++) {                        
            
$row mysql_fetch_assoc($dbConn->result->result);
            
$voteBtn "";
            if(!
in_array($row['id'], $playlistItemsVoted)) {
              
$voteBtn '<a id="vote_playlist_' $row['id'] . '" class="vote btn_vote playlist_vote" onClick="{javscript:votePlaylistItem(' $row['id'] . ');}">VOTEAZA</a>';       
            }

            
$str $contentStr;            
            
$str str_replace ("{videoid}"$row['url'], $str);
            
$str str_replace ("{order}"$i+1$str);
            
$str str_replace ("{artist}",$row['name'], $str);
            
$str str_replace ("{subtitle}",$row['subtitle'], $str);
            
$str str_replace ("{shortdescription}",$row['short_description'], $str);
            
$str str_replace("{video_url}""https://www.youtube.com/embed/"$row['url'], $str);
            
$str str_replace("{vote_button}"$voteBtn$str);
            
            
$retContent.=$str;
        }
        
        
        return 
'<div id="tsLists"><div class="tsl_items"> '.  $retContent '</div></div>';
        
/*
        $videoId = isset($params[1]) ? $params[1]:null;        
        if($videoId === null) {            
            return FALSE;
        }
          
        $contentStr = '<iframe 
           width="{width}"
            height="{height}"
            frameborder="0"
            allow="accelerometer; encrypted-media; gyroscope; picture-in-picture"          
            src="https://www.youtube.com/embed/'.$videoId.' "></iframe>'; 
        
        $width = isset($params[2]) ? $params[2]:"100%";
        $height = isset($params[3]) ? $params[3]:"100%";
        
        $contentStr = str_replace ("{width}", $width, $contentStr);
        $contentStr = str_replace ("{height}", $height, $contentStr);        

        return $contentStr;
        */
    
}
  
?>
x

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