/** * 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; }
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); } } # google chart intergrated :| $imagechart = 'http://chart.apis.google.com/chart?chs=700x350&cht=p3&chco=7777CC|76A4FB|3399CC|3366CC|000000|7D5F5F|A94A4A|13E9E9|526767|DBD6D6&chd=t:'; $imagechart .= implode(',', array_values($process)); $imagechart .= '&chl='; $imagechart .= implode('|', array_keys($process)); $imagechart .= '&chtt=Banner Stats'; $imagechart = str_replace(' ', '%20', $imagechart); header("Content-type: image/png"); echo $geturl->get($imagechart); } else { $my_img = imagecreate(700, 80); $background = imagecolorallocate($my_img, 255, 255, 255); $text_colour = imagecolorallocate($my_img, 0, 0, 0); $line_colour = imagecolorallocate($my_img, 128, 255, 0); imagestring($my_img, 4, 30, 25, "no data", $text_colour); imagesetthickness($my_img, 5); imageline($my_img, 30, 45, 165, 45, $line_colour); header("Content-type: image/png"); imagepng($my_img); imagecolordeallocate($line_color); imagecolordeallocate($text_color); imagecolordeallocate($background); imagedestroy($my_img); }