/var/www/hkosl.com/dashboard/index.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
<?php
    
include_once("webadmin/configure.php");

    if (!isset(
$_GET["langcode"])) {
        
$langcode             "en";
        
$_SESSION["langcode"] = "en";
    } else {
        
$langcode             $_GET["langcode"];
        
$_SESSION["langcode"] = $langcode;
    }

    
$polling_time 3000//millisecond

    //config
    
$sql        "select * from config where deleted = 0 order by id ASC";
    
$parameters = array();
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    if (!
$sth->execute($parameters)) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    
$config_info $sth->fetchAll();

    foreach (
$config_info as $this_config) {
        if (
$this_config{"id"} == 1)
            
$slide_speed $this_config['config_value'];
        else if (
$this_config{"id"} == 2)
            
$rolling_text_font_size $this_config['config_value'];
        else if (
$this_config{"id"} == 3)
            
$rolling_text_font_color $this_config['config_value'];
        else if (
$this_config{"id"} == 4)
            
$animtype $this_config['config_value'];
        else if (
$this_config{"id"} == 5)
            
$slide_animation_duration $this_config['config_value'];
    }

    
$sql        "select * from config order by lastupdate DESC limit 1";
    
$parameters = array();
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    if (!
$sth->execute($parameters)) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }
    
$result            $sth->fetch(PDO::FETCH_ASSOC);
    
$config_lastupdate $result["lastupdate"];

    
//slideshow
    
$sql        "select * from slideshow where status = 1 and deleted = 0 order by sort ASC";
    
$parameters = array();
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    if (!
$sth->execute($parameters)) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    
$all_slideshow_info $sth->fetchAll();

    
$sql        "select * from slideshow order by lastupdate DESC limit 1";
    
$parameters = array();
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    if (!
$sth->execute($parameters)) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }
    
$result               $sth->fetch(PDO::FETCH_ASSOC);
    
$slideshow_lastupdate $result["lastupdate"];

    
// rolling text
    
$sql        "select * from rolling_text where status = 1 and deleted = 0 order by sort ASC";
    
$parameters = array();
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    if (!
$sth->execute($parameters)) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    
$all_rolling_text_info $sth->fetchAll();

    
$sql        "select * from rolling_text order by lastupdate DESC limit 1";
    
$parameters = array();
    if (!(
$sth $dbh->prepare($sql))) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }

    if (!
$sth->execute($parameters)) {
        throw new 
Exception('[' $sth->errorCode() . ']: ' print_r($sth->errorInfo()));
    }
    
$result                  $sth->fetch(PDO::FETCH_ASSOC);
    
$rolling_text_lastupdate $result["lastupdate"];
?>

<!DOCTYPE html>
<!--[if lt IE 7 ]>
<html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>
<html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>
<html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="en"> <!--<![endif]-->
<head>
    <title>Demo</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <link href="css/style.css" rel="stylesheet" type="text/css" media="screen">
    <script src="js/jquery-1.11.1.min.js"></script>

    <link rel="stylesheet" href="js/owl.carousel.2.0.0-beta.2.4/owl.carousel.css">
    <script src="js/owl.carousel.2.0.0-beta.2.4/owl.carousel.min.js"></script>

    <!-- Jquery Marquee -->
    <script defer src="js/jquery.marquee.js"></script>
    <script type="text/javascript">

        $(function () {
            $('.marquee').marquee('pointer').mouseover(function () {
                $(this).trigger('stop');
            }).mouseout(function () {
                $(this).trigger('start');
            }).mousemove(function (event) {
                /*if ($(this).data('drag') == true) {
                 this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
                 }*/
            }).mousedown(function (event) {
                //$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
            }).mouseup(function () {
                //$(this).data('drag', false);
            });
        });
    </script>

    <script type="text/javascript">


        var config_lastupdate = '<?=$config_lastupdate?>';
        var slideshow_lastupdate = '<?=$slideshow_lastupdate?>';
        var rolling_text_lastupdate = '<?=$rolling_text_lastupdate?>';

        function check_config(config_lastupdate) {
            $.ajax({
                url: '_ajax.php?for=config',
                type: 'POST',
                data: {lastupdate: config_lastupdate},
                dataType: 'html',
                timeout: 1000,
                error: function () {
                    //alert('Error loading PHP document');
                    check_config();
                },
                success: function (result) {
                    if (result != "") {
                        location.reload();
                    }
                }
            });
        }

        function check_slideshow(slideshow_lastupdate) {
            $.ajax({
                url: '_ajax.php?for=slideshow',
                type: 'POST',
                data: {lastupdate: slideshow_lastupdate},
                dataType: 'html',
                timeout: 1000,
                error: function () {
                    //alert('Error loading PHP document');
                    check_slideshow();
                },
                success: function (result) {
                    //console.log(result);
                    if (result != "") {

                        location.reload();

                        //slideshow_container
                        $("#slideshow_container").empty();
                        $("#slideshow_container").html(result);

                        //recall function

                    }
                }
            });
        }

        function check_rolling_text(rolling_text_lastupdate) {
            $.ajax({
                url: '_ajax.php?for=rolling_text',
                type: 'POST',
                data: {lastupdate: rolling_text_lastupdate},
                dataType: 'html',
                timeout: 1000,
                error: function () {
                    //alert('Error loading PHP document');
                    check_rolling_text();
                },
                success: function (result) {
                    if (result != "") {
                        //marquee_list
                        $(".marquee_list").empty();
                        $(".marquee_list").html(result);
                    }
                }
            });
        }

        setInterval(function () {
            check_config(config_lastupdate);
        }, <?=$polling_time?>);

        setInterval(function () {
            check_slideshow(slideshow_lastupdate);
        }, <?=$polling_time?>);

        setInterval(function () {
            check_rolling_text(rolling_text_lastupdate);
        }, <?=$polling_time?>);
    </script>


    <script type="text/javascript">
        $(function () {
            $('#slideshow_container').owlCarousel({
                loop:true,
                items:1,
                autoplay:true,
                autoplayTimeout: <?=(int)($slide_speed?>,
                animateOut: 'fadeOut',
                animateIn: 'fadeIn',
                smartSpeed:250
            });
        });
    </script>
</head>
<!--style="overflow-x: hidden;overflow-y: hidden; "-->
<body class="bg">

<div class="container">

    <div id="slideshow_container">
        <?php
            
foreach ($all_slideshow_info as $this_slide) {
                if (!empty(
$this_slide{"slideimg_" $_SESSION["langcode"]})) {
                    echo 
'<div class="item">
                        <div class="slideshow_img" style="background: url(images/slideshow/' 
$this_slide{"slideimg_" $_SESSION["langcode"]} . ') center center no-repeat; background-size:contain;"></div>
                        </div>'
;
                }
            }
        
?>
    </div>

    <div id="marquee_container">
        <div id="marquee_container_bg">
            <div id="marquee_wrapper">

                <nav class="marquee">
                    <ul class="marquee_list" style="font-size: <?= $rolling_text_font_size?>px; color: <?= $rolling_text_font_color?>; ">
                        <?php
                            
foreach ($all_rolling_text_info as $rolling_text_info) {
                                echo 
'<li>' $rolling_text_info{"content_en"} . '</li>';
                            }
                        
?>
                    </ul>
                </nav><!-- .marquee ends /******/ -->

            </div><!-- /// #marquee_wrapper ends /// -->
        </div>

    </div>

    <div class="clearfix"></div>

</div>

</body>
</html>