/** * nv_get_rss() * * @param mixed $url * @return * */ function nv_get_rss($url) { global $global_config, $nv_Cache; $array_data = array(); $cache_file = NV_LANG_DATA . '_' . md5($url) . '_' . NV_CACHE_PREFIX . '.cache'; if (($cache = $nv_Cache->getItem('rss', $cache_file)) != false) { $array_data = unserialize($cache); } else { $getContent = new NukeViet\Client\UrlGetContents($global_config); $xml_source = $getContent->get($url); $allowed_html_tags = array_map('trim', explode(',', NV_ALLOWED_HTML_TAGS)); $allowed_html_tags = '<' . implode('><', $allowed_html_tags) . '>'; if ($xml = simplexml_load_string($xml_source)) { $a = 0; if (isset($xml->channel)) { foreach ($xml->channel->item as $item) { $array_data[$a]['title'] = strip_tags($item->title); $array_data[$a]['description'] = strip_tags($item->description, $allowed_html_tags); $array_data[$a]['link'] = strip_tags($item->link); $array_data[$a]['pubDate'] = nv_date('l - d/m/Y H:i', strtotime($item->pubDate)); ++$a; } } elseif (isset($xml->entry)) { foreach ($xml->entry as $item) { $urlAtt = $item->link->attributes(); $url = $urlAtt['href']; $array_data[$a]['title'] = strip_tags($item->title); $array_data[$a]['description'] = strip_tags($item->content, $allowed_html_tags); $array_data[$a]['link'] = strip_tags($urlAtt['href']); $array_data[$a]['pubDate'] = nv_date('l - d/m/Y H:i', strtotime($item->updated)); ++$a; } } } $cache = serialize($array_data); $nv_Cache->setItem('rss', $cache_file, $cache); } return $array_data; }
switch ($type) { case 'country': $onetype = 'click_country'; break; case 'browser': $onetype = 'click_browse_name'; break; case 'os': $onetype = 'click_os_name'; break; case 'date': $onetype = 'click_time'; break; } $process = $data = array(); $geturl = new NukeViet\Client\UrlGetContents(); $result = $db->query("SELECT a." . $onetype . " FROM " . NV_BANNERS_GLOBALTABLE . "_click a INNER JOIN " . NV_BANNERS_GLOBALTABLE . "_rows b ON a.bid=b.id WHERE b.clid= " . $banner_client_info['id'] . " AND a.click_time <= " . $enddate . " AND a.click_time >= " . $firstdate . " AND a.bid=" . $ads . " ORDER BY click_time ASC"); while ($row = $result->fetch()) { if ($type == 'date') { $row[$onetype] = date('d/m', $row[$onetype]); } $data[] = $row[$onetype]; } if (sizeof($data) > 0) { $statics = array_count_values($data); foreach ($statics as $country => $quantity) { if ($type == 'date') { $process[$country . '(' . $quantity . ' click)'] = $quantity; } else { $process[$country . '(' . round(intval($quantity) * 100 / $total, 2) . '%)'] = round(intval($quantity) * 100 / $total, 2); }