| 
                                
                                    @@ 94-140 (lines=47) @@
                                 | 
                            
                                                            
                                    | 91 | 
                                     | 
                                         * @param array $args numeric array containing the parameter for "sql_slave"  | 
                                
                                                            
                                    | 92 | 
                                     | 
                                         * @return object mysql result used by smarty assign_rs  | 
                                
                                                            
                                    | 93 | 
                                     | 
                                         */  | 
                                
                                                            
                                    | 94 | 
                                     | 
                                        private function cacheRs($args = null)  | 
                                
                                                            
                                    | 95 | 
                                     | 
                                        { | 
                                
                                                            
                                    | 96 | 
                                     | 
                                            global $opt;  | 
                                
                                                            
                                    | 97 | 
                                     | 
                                     | 
                                
                                                            
                                    | 98 | 
                                     | 
                                            if ($args === null || !is_array($args)) { | 
                                
                                                            
                                    | 99 | 
                                     | 
                                                $args = [  | 
                                
                                                            
                                    | 100 | 
                                     | 
                                                    $this->get_userCountry(),  | 
                                
                                                            
                                    | 101 | 
                                     | 
                                                    $opt['template']['locale'],  | 
                                
                                                            
                                    | 102 | 
                                     | 
                                                    10,  | 
                                
                                                            
                                    | 103 | 
                                     | 
                                                ];  | 
                                
                                                            
                                    | 104 | 
                                     | 
                                            }  | 
                                
                                                            
                                    | 105 | 
                                     | 
                                     | 
                                
                                                            
                                    | 106 | 
                                     | 
                                            return sql_slave(  | 
                                
                                                            
                                    | 107 | 
                                     | 
                                                "SELECT `user`.`user_id` `user_id`,  | 
                                
                                                            
                                    | 108 | 
                                     | 
                                                    `user`.`username` `username`,  | 
                                
                                                            
                                    | 109 | 
                                     | 
                                                    `caches`.`cache_id` `cache_id`,  | 
                                
                                                            
                                    | 110 | 
                                     | 
                                                    `caches`.`name` `name`,  | 
                                
                                                            
                                    | 111 | 
                                     | 
                                                    `caches`.`date_created` `date_created`,  | 
                                
                                                            
                                    | 112 | 
                                     | 
                                                    `caches`.`type`,  | 
                                
                                                            
                                    | 113 | 
                                     | 
                                                    `caches`.`longitude` `longitude`,  | 
                                
                                                            
                                    | 114 | 
                                     | 
                                                    `caches`.`latitude` `latitude`,  | 
                                
                                                            
                                    | 115 | 
                                     | 
                                                    IFNULL(`sys_trans_text`.`text`,`countries`.`en`) AS `adm1`,  | 
                                
                                                            
                                    | 116 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm2`,'') `adm2`,  | 
                                
                                                            
                                    | 117 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm3`,'') `adm3`,  | 
                                
                                                            
                                    | 118 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm4`,'') `adm4`,  | 
                                
                                                            
                                    | 119 | 
                                     | 
                                                    `ca`.`attrib_id` IS NOT NULL AS `oconly`  | 
                                
                                                            
                                    | 120 | 
                                     | 
                                                FROM `caches`  | 
                                
                                                            
                                    | 121 | 
                                     | 
                                                INNER JOIN `user`  | 
                                
                                                            
                                    | 122 | 
                                     | 
                                                  ON `user`.`user_id`=`caches`.`user_id`  | 
                                
                                                            
                                    | 123 | 
                                     | 
                                                LEFT JOIN `cache_location`  | 
                                
                                                            
                                    | 124 | 
                                     | 
                                                  ON `caches`.`cache_id`=`cache_location`.`cache_id`  | 
                                
                                                            
                                    | 125 | 
                                     | 
                                                LEFT JOIN `countries`  | 
                                
                                                            
                                    | 126 | 
                                     | 
                                                  ON `countries`.`short`=`caches`.`country`  | 
                                
                                                            
                                    | 127 | 
                                     | 
                                                LEFT JOIN `sys_trans_text`  | 
                                
                                                            
                                    | 128 | 
                                     | 
                                                  ON `sys_trans_text`.`trans_id`=`countries`.`trans_id`  | 
                                
                                                            
                                    | 129 | 
                                     | 
                                                  AND `sys_trans_text`.`lang`='&2'  | 
                                
                                                            
                                    | 130 | 
                                     | 
                                                LEFT JOIN `caches_attributes` `ca`  | 
                                
                                                            
                                    | 131 | 
                                     | 
                                                  ON `ca`.`cache_id`=`caches`.`cache_id`  | 
                                
                                                            
                                    | 132 | 
                                     | 
                                                  AND `ca`.`attrib_id`=6  | 
                                
                                                            
                                    | 133 | 
                                     | 
                                                WHERE `caches`.`country`='&1'  | 
                                
                                                            
                                    | 134 | 
                                     | 
                                                  AND `caches`.`type` != 6  | 
                                
                                                            
                                    | 135 | 
                                     | 
                                                  AND `caches`.`status` = 1  | 
                                
                                                            
                                    | 136 | 
                                     | 
                                                ORDER BY `caches`.`date_created` DESC  | 
                                
                                                            
                                    | 137 | 
                                     | 
                                                LIMIT 0, &3",  | 
                                
                                                            
                                    | 138 | 
                                     | 
                                                $args  | 
                                
                                                            
                                    | 139 | 
                                     | 
                                            );  | 
                                
                                                            
                                    | 140 | 
                                     | 
                                        }  | 
                                
                                                            
                                    | 141 | 
                                     | 
                                     | 
                                
                                                            
                                    | 142 | 
                                     | 
                                        /**  | 
                                
                                                            
                                    | 143 | 
                                     | 
                                         * eventRs executes the database statements for type "event"  | 
                                
                                                                                
                                 | 
                                
                                    @@ 148-192 (lines=45) @@
                                 | 
                            
                                                            
                                    | 145 | 
                                     | 
                                         * @param array $args numeric array containing the parameter for "sql_slave"  | 
                                
                                                            
                                    | 146 | 
                                     | 
                                         * @return object mysql result used by smarty assign_rs  | 
                                
                                                            
                                    | 147 | 
                                     | 
                                         */  | 
                                
                                                            
                                    | 148 | 
                                     | 
                                        private function eventRs($args = null)  | 
                                
                                                            
                                    | 149 | 
                                     | 
                                        { | 
                                
                                                            
                                    | 150 | 
                                     | 
                                            global $opt;  | 
                                
                                                            
                                    | 151 | 
                                     | 
                                     | 
                                
                                                            
                                    | 152 | 
                                     | 
                                            if ($args === null || !is_array($args)) { | 
                                
                                                            
                                    | 153 | 
                                     | 
                                                $args = [  | 
                                
                                                            
                                    | 154 | 
                                     | 
                                                    $this->get_userCountry(),  | 
                                
                                                            
                                    | 155 | 
                                     | 
                                                    $opt['template']['locale'],  | 
                                
                                                            
                                    | 156 | 
                                     | 
                                                    10,  | 
                                
                                                            
                                    | 157 | 
                                     | 
                                                ];  | 
                                
                                                            
                                    | 158 | 
                                     | 
                                            }  | 
                                
                                                            
                                    | 159 | 
                                     | 
                                     | 
                                
                                                            
                                    | 160 | 
                                     | 
                                            return sql_slave(  | 
                                
                                                            
                                    | 161 | 
                                     | 
                                                "SELECT `user`.`user_id` `user_id`,  | 
                                
                                                            
                                    | 162 | 
                                     | 
                                                    `user`.`username` `username`,  | 
                                
                                                            
                                    | 163 | 
                                     | 
                                                    `caches`.`cache_id` `cache_id`,  | 
                                
                                                            
                                    | 164 | 
                                     | 
                                                    `caches`.`name` `name`,  | 
                                
                                                            
                                    | 165 | 
                                     | 
                                                    `caches`.`date_hidden`,  | 
                                
                                                            
                                    | 166 | 
                                     | 
                                                    IFNULL(`sys_trans_text`.`text`,`countries`.`en`) AS `adm1`,  | 
                                
                                                            
                                    | 167 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm2`,'') `adm2`,  | 
                                
                                                            
                                    | 168 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm3`,'') `adm3`,  | 
                                
                                                            
                                    | 169 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm4`,'') `adm4`,  | 
                                
                                                            
                                    | 170 | 
                                     | 
                                                    `ca`.`attrib_id` IS NOT NULL AS `oconly`  | 
                                
                                                            
                                    | 171 | 
                                     | 
                                                FROM `caches`  | 
                                
                                                            
                                    | 172 | 
                                     | 
                                                INNER JOIN `user`  | 
                                
                                                            
                                    | 173 | 
                                     | 
                                                  ON `user`.`user_id`=`caches`.`user_id`  | 
                                
                                                            
                                    | 174 | 
                                     | 
                                                LEFT JOIN `cache_location`  | 
                                
                                                            
                                    | 175 | 
                                     | 
                                                  ON `caches`.`cache_id`=`cache_location`.`cache_id`  | 
                                
                                                            
                                    | 176 | 
                                     | 
                                                LEFT JOIN `countries`  | 
                                
                                                            
                                    | 177 | 
                                     | 
                                                  ON `countries`.`short`=`caches`.`country`  | 
                                
                                                            
                                    | 178 | 
                                     | 
                                                LEFT JOIN `sys_trans_text`  | 
                                
                                                            
                                    | 179 | 
                                     | 
                                                  ON `sys_trans_text`.`trans_id`=`countries`.`trans_id`  | 
                                
                                                            
                                    | 180 | 
                                     | 
                                                  AND `sys_trans_text`.`lang`='&2'  | 
                                
                                                            
                                    | 181 | 
                                     | 
                                                LEFT JOIN `caches_attributes` `ca`  | 
                                
                                                            
                                    | 182 | 
                                     | 
                                                  ON `ca`.`cache_id`=`caches`.`cache_id`  | 
                                
                                                            
                                    | 183 | 
                                     | 
                                                  AND `ca`.`attrib_id`=6  | 
                                
                                                            
                                    | 184 | 
                                     | 
                                                WHERE `caches`.`country`='&1'  | 
                                
                                                            
                                    | 185 | 
                                     | 
                                                  AND `caches`.`date_hidden` >= curdate()  | 
                                
                                                            
                                    | 186 | 
                                     | 
                                                  AND `caches`.`type` = 6  | 
                                
                                                            
                                    | 187 | 
                                     | 
                                                  AND `caches`.`status`=1  | 
                                
                                                            
                                    | 188 | 
                                     | 
                                                ORDER BY `date_hidden` ASC  | 
                                
                                                            
                                    | 189 | 
                                     | 
                                                LIMIT 0, &3",  | 
                                
                                                            
                                    | 190 | 
                                     | 
                                                $args  | 
                                
                                                            
                                    | 191 | 
                                     | 
                                            );  | 
                                
                                                            
                                    | 192 | 
                                     | 
                                        }  | 
                                
                                                            
                                    | 193 | 
                                     | 
                                     | 
                                
                                                            
                                    | 194 | 
                                     | 
                                        /**  | 
                                
                                                            
                                    | 195 | 
                                     | 
                                         * ratingDays returns the number of days used for top rating calculation  | 
                                
                                                                                
                                 | 
                                
                                    @@ 220-270 (lines=51) @@
                                 | 
                            
                                                            
                                    | 217 | 
                                     | 
                                         * @param array $args numeric array containing the parameter for "sql_slave"  | 
                                
                                                            
                                    | 218 | 
                                     | 
                                         * @return object mysql result used by smarty assign_rs  | 
                                
                                                            
                                    | 219 | 
                                     | 
                                         */  | 
                                
                                                            
                                    | 220 | 
                                     | 
                                        private function ratingRs($args = null)  | 
                                
                                                            
                                    | 221 | 
                                     | 
                                        { | 
                                
                                                            
                                    | 222 | 
                                     | 
                                            global $opt;  | 
                                
                                                            
                                    | 223 | 
                                     | 
                                     | 
                                
                                                            
                                    | 224 | 
                                     | 
                                            // check $args and set defaults  | 
                                
                                                            
                                    | 225 | 
                                     | 
                                            if ($args === null || !is_array($args)) { | 
                                
                                                            
                                    | 226 | 
                                     | 
                                                $args = [  | 
                                
                                                            
                                    | 227 | 
                                     | 
                                                    $this->get_userCountry(),  | 
                                
                                                            
                                    | 228 | 
                                     | 
                                                    $opt['template']['locale'],  | 
                                
                                                            
                                    | 229 | 
                                     | 
                                                    10,  | 
                                
                                                            
                                    | 230 | 
                                     | 
                                                    $this->ratingDays(),  | 
                                
                                                            
                                    | 231 | 
                                     | 
                                                ];  | 
                                
                                                            
                                    | 232 | 
                                     | 
                                            }  | 
                                
                                                            
                                    | 233 | 
                                     | 
                                     | 
                                
                                                            
                                    | 234 | 
                                     | 
                                            // execute sql  | 
                                
                                                            
                                    | 235 | 
                                     | 
                                            // 2012-08-24 following  | 
                                
                                                            
                                    | 236 | 
                                     | 
                                            //   optimized by adding rating_date field to cache_rating, so we don't need the log table.  | 
                                
                                                            
                                    | 237 | 
                                     | 
                                            return sql_slave(  | 
                                
                                                            
                                    | 238 | 
                                     | 
                                                "SELECT COUNT(`cache_rating`.`user_id`) AS `cRatings`,  | 
                                
                                                            
                                    | 239 | 
                                     | 
                                                    MAX(`cache_rating`.`rating_date`) AS `dLastLog`,  | 
                                
                                                            
                                    | 240 | 
                                     | 
                                                    `user`.`user_id` AS `user_id`,  | 
                                
                                                            
                                    | 241 | 
                                     | 
                                                    `user`.`username` AS `username`,  | 
                                
                                                            
                                    | 242 | 
                                     | 
                                                    `caches`.`cache_id` AS `cache_id`,  | 
                                
                                                            
                                    | 243 | 
                                     | 
                                                    `caches`.`name` AS `name`,  | 
                                
                                                            
                                    | 244 | 
                                     | 
                                                    `caches`.`type`,  | 
                                
                                                            
                                    | 245 | 
                                     | 
                                                    IFNULL(`sys_trans_text`.`text`,`countries`.`en`) AS `adm1`,  | 
                                
                                                            
                                    | 246 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm2`,'') `adm2`,  | 
                                
                                                            
                                    | 247 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm3`,'') `adm3`,  | 
                                
                                                            
                                    | 248 | 
                                     | 
                                                    IF(`caches`.`country`=`cache_location`.`code1`,`cache_location`.`adm4`,'') `adm4`,  | 
                                
                                                            
                                    | 249 | 
                                     | 
                                                    `ca`.`attrib_id` IS NOT NULL AS `oconly`  | 
                                
                                                            
                                    | 250 | 
                                     | 
                                                FROM `cache_rating`  | 
                                
                                                            
                                    | 251 | 
                                     | 
                                                    INNER JOIN `caches` ON `caches`.`cache_id`=`cache_rating`.`cache_id`  | 
                                
                                                            
                                    | 252 | 
                                     | 
                                                    INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`  | 
                                
                                                            
                                    | 253 | 
                                     | 
                                                    LEFT JOIN `cache_location` ON `cache_rating`.`cache_id`=`cache_location`.`cache_id`  | 
                                
                                                            
                                    | 254 | 
                                     | 
                                                    LEFT JOIN `countries` ON `countries`.`short`=`caches`.`country`  | 
                                
                                                            
                                    | 255 | 
                                     | 
                                                    LEFT JOIN `sys_trans_text`  | 
                                
                                                            
                                    | 256 | 
                                     | 
                                                      ON `sys_trans_text`.`trans_id`=`countries`.`trans_id`  | 
                                
                                                            
                                    | 257 | 
                                     | 
                                                      AND `sys_trans_text`.`lang`='&2'  | 
                                
                                                            
                                    | 258 | 
                                     | 
                                                    LEFT JOIN `caches_attributes` `ca` ON `ca`.`cache_id`=`caches`.`cache_id` AND `ca`.`attrib_id`=6  | 
                                
                                                            
                                    | 259 | 
                                     | 
                                                WHERE `caches`.`country`='&1' AND  | 
                                
                                                            
                                    | 260 | 
                                     | 
                                                    `cache_rating`.`rating_date`>DATE_SUB(NOW(), INTERVAL &4 DAY) AND  | 
                                
                                                            
                                    | 261 | 
                                     | 
                                                    `caches`.`type`!=6 AND  | 
                                
                                                            
                                    | 262 | 
                                     | 
                                                    `caches`.`status`=1  | 
                                
                                                            
                                    | 263 | 
                                     | 
                                                GROUP BY `cache_rating`.`cache_id`  | 
                                
                                                            
                                    | 264 | 
                                     | 
                                                ORDER BY `cRatings` DESC,  | 
                                
                                                            
                                    | 265 | 
                                     | 
                                                    `dLastLog` DESC,  | 
                                
                                                            
                                    | 266 | 
                                     | 
                                                    `cache_id` DESC  | 
                                
                                                            
                                    | 267 | 
                                     | 
                                                LIMIT 0, &3",  | 
                                
                                                            
                                    | 268 | 
                                     | 
                                                $args  | 
                                
                                                            
                                    | 269 | 
                                     | 
                                            );  | 
                                
                                                            
                                    | 270 | 
                                     | 
                                        }  | 
                                
                                                            
                                    | 271 | 
                                     | 
                                     | 
                                
                                                            
                                    | 272 | 
                                     | 
                                        /**  | 
                                
                                                            
                                    | 273 | 
                                     | 
                                         * blogFeed executes the RSSParser for type "blog"  |