Esempio n. 1
0
 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 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);
         }
Esempio n. 2
0
function nv_filters($urlink, $urlimages, $tieude, $linktd, $tomtat, $hinhanh, $chitiet, $thoigian, $e)
{
    global $folder, $module, $module_name, $module_config, $global_config;
    $title = $e->find($tieude, 0)->innertext;
    $title = trim(nv_unhtmlspecialchars(strip_tags($title)));
    $link = $urlink . $e->find($linktd, 0)->href;
    $alias = change_alias($title);
    if ($e->find($tomtat, 0)) {
        $hometext = $e->find($tomtat, 0)->innertext;
        $hometext = trim($hometext);
    } else {
        $hometext = '';
    }
    $getContent = new UrlGetContents($global_config);
    $link_t = $getContent->get($link);
    $html = str_get_html($link_t);
    $date = $html->find($thoigian, 0)->plaintext;
    $number = preg_replace("/[^0-9]/", "", $date);
    $image = array();
    $homeimgthumb = "";
    if ($html->find($chitiet, 0)->find('img')) {
        foreach ($html->find($chitiet, 0)->find('img') as $img) {
            if (!nv_is_url($img)) {
                $abc = $img->src = $urlimages . $img->src;
            } else {
                $abc = $img->src;
            }
            $image[] = $abc;
            if ($module_config[$module_name]['load_image'] == 1) {
                $images = filter_images($folder, $abc);
                $img->src = NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $module . "/" . $images;
            }
        }
    }
    if ($html->find($chitiet, 0)->find('a')) {
        foreach ($html->find($chitiet, 0)->find('a') as $href) {
            if (substr($href->href, 0, 1) == "/") {
                $href->href = $urlink . $href->href;
            }
        }
    }
    if ($image) {
        $homeimg = filter_images($folder, $image[0]);
        $homeimgfile = NV_UPLOADS_REAL_DIR . "/" . $module . "/" . $homeimg;
        if (file_exists($homeimgfile)) {
            require_once NV_ROOTDIR . "/includes/class/image.class.php";
            $basename = basename($homeimgfile);
            $image = new image($homeimgfile, NV_MAX_WIDTH, NV_MAX_HEIGHT);
            $thumb_basename = $basename;
            $i = 1;
            while (file_exists(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/thumb/' . $thumb_basename)) {
                $thumb_basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
                ++$i;
            }
            $image->resizeXY($module_config[$module]['homewidth'], $module_config[$module]['homeheight']);
            $image->save(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/thumb', $thumb_basename);
            $image_info = $image->create_Image_info;
            $thumb_name = str_replace(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/', '', $image_info['src']);
            $block_basename = $basename;
            $i = 1;
            while (file_exists(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/block/' . $block_basename)) {
                $block_basename = preg_replace('/(.*)(\\.[a-zA-Z]+)$/', '\\1_' . $i . '\\2', $basename);
                ++$i;
            }
            $image->resizeXY($module_config[$module]['blockwidth'], $module_config[$module]['blockheight']);
            $image->save(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/block', $block_basename);
            $image_info = $image->create_Image_info;
            $block_name = str_replace(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module . '/', '', $image_info['src']);
            $image->close();
            $homeimgthumb = $thumb_name . "|" . $block_name;
        }
    } else {
        if ($e->find($hinhanh, 0)) {
            $homeimg1 = $e->find($hinhanh, 0)->src;
            if (nv_is_url($homeimg1)) {
                $home_img = $urlimages . $homeimg1;
            } else {
                $home_img = $homeimg1;
            }
            if ($module_config[$module_name]['load_image'] == 1) {
                $homeimg = filter_images($folder, $home_img);
            } else {
                $homeimg = $home_img;
            }
        } else {
            $homeimg = "";
        }
    }
    $bodyhtml = $html->find($chitiet, 0)->innertext;
    $html->clear();
    unset($html);
    $bodyhtml = nv_unhtmlspecialchars($bodyhtml);
    $content = array($title, $link, $alias, $hometext, $homeimg, $homeimgthumb, $number, $bodyhtml);
    return $content;
}
function get_version($updatetime = 3600)
{
    global $global_config;
    $my_file = NV_ROOTDIR . '/' . NV_CACHEDIR . '/nukeviet.version.xml';
    $xmlcontent = false;
    if (file_exists($my_file) and filemtime($my_file) > NV_CURRENTTIME - $updatetime) {
        $xmlcontent = simplexml_load_file($my_file);
    } else {
        include NV_ROOTDIR . "/includes/class/geturl.class.php";
        $getContent = new UrlGetContents($global_config);
        $content = $getContent->get('http://update.nukeviet.vn/nukeviet.version.xml');
        if ($content) {
            $xmlcontent = simplexml_load_string($content);
            if ($xmlcontent != false) {
                file_put_contents($my_file, $content);
            }
        }
    }
    return $xmlcontent;
}
Esempio n. 4
0
     $upload = new upload($admin_info['allow_files_type'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
     $upload_info = $upload->save_file($_FILES['fileupload'], NV_ROOTDIR . '/' . $imgfolder, false);
     if (!empty($upload_info['error'])) {
         $errors[] = $upload_info['error'];
     } else {
         $selectedfile = $upload_info['basename'];
     }
 } elseif (!empty($imgurl)) {
     $prover = @getimagesize($imgurl);
     if ($prover) {
         $imgname = end(explode("/", $imgurl));
         $imgname = str_replace('%', '_', $imgname);
         $file_type = strtolower($types[$prover[2]]);
         if (in_array($file_type, $allowed_extensions)) {
             include NV_ROOTDIR . "/includes/class/geturl.class.php";
             $getContent = new UrlGetContents($global_config);
             $content = '';
             $content = $getContent->get($imgurl);
             $handle2 = @fopen(NV_ROOTDIR . '/' . $imgfolder . '/' . basename($imgname), 'wb');
             if ($handle2 && !empty($content)) {
                 @fwrite($handle2, $content);
                 @fclose($handle2);
                 $datakod = time();
                 $img_name = $datakod . $imgname;
                 @rename(NV_ROOTDIR . '/' . $imgfolder . '/' . $imgname, NV_ROOTDIR . '/' . $imgfolder . '/' . $img_name);
             } else {
                 $errors[] = $lang_module['upload_file_error_movefile'];
             }
         } else {
             $errors[] = $lang_module['upload_file_error_movefile'];
         }
Esempio n. 5
0
/**
 * NukevietChange_getContents()
 *
 * @param bool $refresh
 * @return
 */
function NukevietChange_getContents($refresh = false)
{
    global $global_config;
    $url = "http://code.google.com/feeds/p/nuke-viet/svnchanges/basic";
    $xmlfile = "nukevietGoogleCode.cache";
    $load = false;
    $p = NV_CURRENTTIME - 18000;
    $p2 = NV_CURRENTTIME - 120;
    if (!file_exists(NV_ROOTDIR . "/" . NV_CACHEDIR . "/" . $xmlfile)) {
        $load = true;
    } else {
        $filemtime = @filemtime(NV_ROOTDIR . "/" . NV_CACHEDIR . "/" . $xmlfile);
        if ($filemtime < $p) {
            $load = true;
        } elseif ($refresh and $filemtime < $p2) {
            $load = true;
        }
    }
    if ($load) {
        include NV_ROOTDIR . '/includes/class/geturl.class.php';
        $UrlGetContents = new UrlGetContents($global_config);
        $content = $UrlGetContents->get($url);
        if (!empty($content)) {
            if (nv_function_exists('mb_convert_encoding')) {
                $content = mb_convert_encoding($content, "utf-8");
            }
            $content = simplexml_load_string($content);
            $content = nv_object2array($content);
            if (!empty($content)) {
                $code = array();
                $code['updated'] = strtotime($content['updated']);
                $code['link'] = $content['link'][0]['@attributes']['href'];
                $code['entry'] = array();
                if (isset($content['entry']) and !empty($content['entry'])) {
                    foreach ($content['entry'] as $entry) {
                        unset($matches);
                        $cont = $entry['content'];
                        preg_match_all("/(modify|add|delete)[^a-z0-9\\/\\.\\-\\_]+(\\/trunk\\/nukeviet\\/)([a-z0-9\\/\\.\\-\\_]+)/mi", $cont, $matches, PREG_SET_ORDER);
                        $cont = array();
                        if (!empty($matches)) {
                            foreach ($matches as $matche) {
                                $key = strtolower($matche[1]);
                                if (!isset($cont[$key])) {
                                    $cont[$key] = array();
                                }
                                $cont[$key][] = $matche[3];
                            }
                        }
                        unset($matches2);
                        preg_match("/Revision[\\s]+([\\d]*)[\\s]*\\:[\\s]+(.*?)/Uis", $entry['title'], $matches2);
                        $code['entry'][] = array('updated' => strtotime($entry['updated']), 'title' => $matches2[2], 'id' => $matches2[1], 'link' => $entry['link']['@attributes']['href'], 'author' => $entry['author']['name'], 'content' => $cont);
                    }
                    nv_set_cache($xmlfile, serialize($code));
                    return $code;
                }
            }
        }
    }
    $content = nv_get_cache($xmlfile);
    if (!$content) {
        return false;
    }
    $content = unserialize($content);
    return $content;
}
Esempio n. 6
0
 /**
  * nv_get_rss()
  * 
  * @param mixed $url
  * @return
  */
 function nv_get_rss($url)
 {
     global $global_config;
     $array_data = array();
     $cache_file = NV_LANG_DATA . "_rss_" . md5($url) . "_" . NV_CACHE_PREFIX . ".cache";
     if (file_exists(NV_ROOTDIR . "/" . NV_CACHEDIR . "/" . $cache_file) and filemtime(NV_ROOTDIR . "/" . NV_CACHEDIR . "/" . $cache_file) > NV_CURRENTTIME - 1200) {
         if (($cache = nv_get_cache($cache_file)) != false) {
             $array_data = unserialize($cache);
         }
     }
     if (empty($array_data)) {
         include_once NV_ROOTDIR . "/includes/class/geturl.class.php";
         $getContent = new 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_set_cache($cache_file, $cache);
     }
     return $array_data;
 }