Ejemplo n.º 1
0
function save_data_auto($catid, $blockcat, $title, $alias, $hometext, $bodytext, $sourceid, $publtime, $homefile, $homeimgthumb, $link, $array_block_cat_module)
{
    global $db, $module_config;
    $error = "";
    $module = $module_config['getnews']['module'];
    $mod_data = str_replace('-', '_', $module);
    if ($hometext != "") {
        $keywords = nv_get_keywords($hometext);
    } else {
        $keywords = nv_get_keywords(nv_fil_tag($bodytext));
    }
    $row = array("id" => "", "author" => "");
    $hitstotal = rand(1, 5);
    $query = "INSERT INTO `" . NV_PREFIXLANG . "_" . $mod_data . "_rows` \n\t\t(`id`, `catid`, `listcatid`, `topicid`, `admin_id`, `author`, `sourceid`, `addtime`, `edittime`, `status`, `publtime`, `exptime`, `archive`, `title`, `alias`, `hometext`, `homeimgfile`, `homeimgalt`, `homeimgthumb`, `inhome`, `allowed_comm`, `allowed_rating`, `hitstotal`, `hitscm`, `total_rating`, `click_rating`, `keywords`) VALUES \n\t\t(NULL, \n\t\t" . intval($catid) . ",\n\t\t" . $db->dbescape_string($catid) . ",\n\t\t" . intval(0) . ",\n\t\t" . intval(1) . ",\n\t\t" . $db->dbescape_string($row['author']) . ",\n\t\t" . intval($sourceid) . ",\n\t\t" . intval($publtime) . ",\n\t\t" . intval($publtime) . ",\n\t\t" . intval($module_config['getnews']['active']) . ",\n\t\t" . intval($publtime) . ",\n\t\t" . intval(0) . ", \n\t\t" . intval(2) . ",\n\t\t" . $db->dbescape_string($title) . ",\n\t\t" . $db->dbescape_string($alias) . ",\n\t\t" . $db->dbescape_string($hometext) . ",\n\t\t" . $db->dbescape_string($homefile) . ",\n\t\t" . $db->dbescape_string($title) . ",\n\t\t" . $db->dbescape_string($homeimgthumb) . ",\n\t\t" . intval(1) . ",  \n\t\t" . intval(2) . ", \n\t\t" . intval(1) . ", \n\t\t" . intval($hitstotal) . ",  \n\t\t" . intval(0) . ",  \n\t\t" . intval(0) . ",  \n\t\t" . intval(0) . ",  \n\t\t" . $db->dbescape_string($keywords) . ")";
    $row['id'] = $db->sql_query_insert_id($query);
    if ($row['id'] > 0) {
        $bodytext2 = nv_news_get_bodytext(nv_convert($bodytext));
        $ct_query = array();
        $tbhtml = NV_PREFIXLANG . "_" . $mod_data . "_bodyhtml_" . ceil($row['id'] / 2000);
        $db->sql_query("CREATE TABLE IF NOT EXISTS `" . $tbhtml . "` (`id` int(11) unsigned NOT NULL, `bodyhtml` longtext NOT NULL, `sourcetext` varchar(255) NOT NULL default '', `imgposition` tinyint(1) NOT NULL default '1', `copyright` tinyint(1) NOT NULL default '0', `allowed_send` tinyint(1) NOT NULL default '0', `allowed_print` tinyint(1) NOT NULL default '0', `allowed_save` tinyint(1) NOT NULL default '0', PRIMARY KEY  (`id`)) ENGINE=MyISAM");
        $ct_query[] = (int) $db->sql_query("INSERT INTO `" . $tbhtml . "` VALUES \n\t\t(\n\t\t\t" . $row['id'] . ", \n\t\t\t" . $db->dbescape_string(nv_convert($bodytext)) . ", \n\t\t\t" . $db->dbescape_string($link) . ",\n\t\t\t" . intval($module_config['getnews']['imgposition']) . ",\n\t\t\t" . intval(0) . ",  \n\t\t\t" . intval(1) . ",  \n\t\t\t" . intval(1) . ",  \n\t\t\t" . intval(1) . "\t\t\t\t\t\n\t\t)");
        $ct_query[] = (int) $db->sql_query("INSERT INTO `" . NV_PREFIXLANG . "_" . $mod_data . "_" . $catid . "` SELECT * FROM `" . NV_PREFIXLANG . "_" . $module . "_rows` WHERE `id`=" . $row['id'] . "");
        $ct_query[] = (int) $db->sql_query("INSERT INTO `" . NV_PREFIXLANG . "_" . $mod_data . "_bodytext` VALUES (" . $row['id'] . ", " . $db->dbescape_string($bodytext2) . ")");
        if (array_sum($ct_query) != sizeof($ct_query)) {
            $error .= "Lỗi khi lưu 1";
        }
        unset($ct_query);
    } else {
        $error .= $query;
    }
    $id_block_content = explode("|", $blockcat);
    $id_block_content = array_unique($id_block_content);
    $id_block_content = array_filter($id_block_content);
    foreach ($id_block_content as $bid_i) {
        $db->sql_query("INSERT INTO `" . NV_PREFIXLANG . "_" . $mod_data . "_block` (`bid`, `id`, `weight`) VALUES ('" . $bid_i . "', '" . $row['id'] . "', '0')");
    }
    $id_block_content[] = 0;
    $db->sql_query("DELETE FROM `" . NV_PREFIXLANG . "_" . $mod_data . "_block` WHERE `id` = " . $row['id'] . " AND `bid` NOT IN (" . implode(",", $id_block_content) . ")");
    $id_block_content = array_keys($array_block_cat_module);
    foreach ($id_block_content as $bid_i) {
        nv_news_fix_blocks($bid_i, false);
    }
    $db->sql_freeresult();
    unset($bodytext);
    return $error;
}
Ejemplo n.º 2
0
 $rowcontent['homeimgalt'] = $nv_Request->get_title('homeimgalt', 'post', '', 1);
 $rowcontent['bodyhtml'] = $nv_Request->get_editor('bodyhtml', '', NV_ALLOWED_HTML_TAGS);
 $rowcontent['copyright'] = (int) $nv_Request->get_bool('copyright', 'post');
 $rowcontent['inhome'] = (int) $nv_Request->get_bool('inhome', 'post');
 $_groups_post = $nv_Request->get_array('allowed_comm', 'post', array());
 $rowcontent['allowed_comm'] = !empty($_groups_post) ? implode(',', nv_groups_post(array_intersect($_groups_post, array_keys($groups_list)))) : '';
 $rowcontent['allowed_rating'] = (int) $nv_Request->get_bool('allowed_rating', 'post');
 $rowcontent['allowed_send'] = (int) $nv_Request->get_bool('allowed_send', 'post');
 $rowcontent['allowed_save'] = (int) $nv_Request->get_bool('allowed_save', 'post');
 $rowcontent['gid'] = $nv_Request->get_int('gid', 'post', 0);
 $rowcontent['keywords'] = $nv_Request->get_array('keywords', 'post', '');
 $rowcontent['keywords'] = implode(', ', $rowcontent['keywords']);
 // Tu dong xac dinh keywords
 if ($rowcontent['keywords'] == '' and !empty($module_config[$module_name]['auto_tags'])) {
     $keywords = $rowcontent['hometext'] != '' ? $rowcontent['hometext'] : $rowcontent['bodyhtml'];
     $keywords = nv_get_keywords($keywords, 100);
     $keywords = explode(',', $keywords);
     // Ưu tiên lọc từ khóa theo các từ khóa đã có trong tags thay vì đọc từ từ điển
     $keywords_return = array();
     foreach ($keywords as $keyword_i) {
         $sth = $db->prepare('SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_tags_id where keyword = :keyword');
         $sth->bindParam(':keyword', $keyword_i, PDO::PARAM_STR);
         $sth->execute();
         if ($sth->fetchColumn()) {
             $keywords_return[] = $keyword_i;
             if (sizeof($keywords_return) > 20) {
                 break;
             }
         }
     }
     if (sizeof($keywords_return) < 20) {
Ejemplo n.º 3
0
/**
 * update_keywords()
 * 
 * @param mixed $catid
 * @param mixed $faq
 * @return
 */
function update_keywords($catid, $faq)
{
    global $db, $module_data;
    $content = array();
    foreach ($faq as $row) {
        $content[] = $row['title'] . " " . $row['question'] . " " . $row['answer'];
    }
    $content = implode(" ", $content);
    $keywords = nv_get_keywords($content);
    if (!empty($keywords)) {
        $db->query("UPDATE " . NV_PREFIXLANG . "_" . $module_data . "_categories SET keywords=" . $db->quote($keywords) . " WHERE id=" . $catid);
    }
    return $keywords;
}
Ejemplo n.º 4
0
 $row['description'] = $nv_Request->get_textarea('description', '', 'br', 1);
 $row['bodytext'] = $nv_Request->get_editor('bodytext', '', NV_ALLOWED_HTML_TAGS);
 $row['keywords'] = nv_strtolower($nv_Request->get_title('keywords', 'post', '', 0));
 $row['socialbutton'] = $nv_Request->get_int('socialbutton', 'post', 0);
 $row['layout_func'] = $nv_Request->get_title('layout_func', 'post', '');
 $row['gid'] = $nv_Request->get_int('gid', 'post', 0);
 $_groups_post = $nv_Request->get_array('activecomm', 'post', array());
 $row['activecomm'] = !empty($_groups_post) ? implode(',', nv_groups_post(array_intersect($_groups_post, array_keys($groups_list)))) : '';
 if (empty($row['title'])) {
     $error = $lang_module['empty_title'];
 } elseif (strip_tags($row['bodytext']) == '') {
     $error = $lang_module['empty_bodytext'];
 } elseif (empty($row['layout_func']) or in_array('layout.' . $row['layout_func'] . '.tpl', $layout_array)) {
     $row['alias'] = empty($row['alias']) ? change_alias($row['title']) : change_alias($row['alias']);
     if (empty($row['keywords'])) {
         $row['keywords'] = nv_get_keywords($row['title']);
         if (empty($row['keywords'])) {
             $row['keywords'] = nv_unhtmlspecialchars($row['keywords']);
             $row['keywords'] = strip_punctuation($row['keywords']);
             $row['keywords'] = trim($row['keywords']);
             $row['keywords'] = nv_strtolower($row['keywords']);
             $row['keywords'] = preg_replace('/[ ]+/', ',', $row['keywords']);
         }
     }
     if ($id) {
         $_sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $module_data . ' SET title = :title, alias = :alias, image = :image, imagealt = :imagealt, imageposition = :imageposition, description = :description, bodytext = :bodytext, keywords = :keywords, socialbutton = :socialbutton, activecomm = :activecomm, layout_func = :layout_func, gid = :gid, admin_id = :admin_id, edit_time = ' . NV_CURRENTTIME . ' WHERE id =' . $id;
         $publtime = $row['add_time'];
     } else {
         if ($page_config['news_first']) {
             $weight = 1;
         } else {
Ejemplo n.º 5
0
         die;
     }
     $canonicalUrl = $base_url_rewrite;
 }
 if (!empty($rowdetail['image']) && !nv_is_url($rowdetail['image'])) {
     $imagesize = @getimagesize(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $rowdetail['image']);
     $rowdetail['image'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $rowdetail['image'];
     $rowdetail['imageWidth'] = $imagesize[0] > 500 ? 500 : $imagesize[0];
 }
 $rowdetail['add_time'] = nv_date('H:i T l, d/m/Y', $rowdetail['add_time']);
 $rowdetail['edit_time'] = nv_date('H:i T l, d/m/Y', $rowdetail['edit_time']);
 $module_info['layout_funcs'][$op_file] = !empty($rowdetail['layout_func']) ? $rowdetail['layout_func'] : $module_info['layout_funcs'][$op_file];
 if (!empty($rowdetail['keywords'])) {
     $key_words = $rowdetail['keywords'];
 } else {
     $key_words = nv_get_keywords($rowdetail['bodytext']);
     if (empty($key_words)) {
         $key_words = nv_unhtmlspecialchars($rowdetail['title']);
         $key_words = strip_punctuation($key_words);
         $key_words = trim($key_words);
         $key_words = nv_strtolower($key_words);
         $key_words = preg_replace('/[ ]+/', ',', $key_words);
     }
 }
 $page_title = $mod_title = $rowdetail['title'];
 $description = $rowdetail['description'];
 $id_profile_googleplus = $rowdetail['gid'];
 // Hiển thị các bài liên quan mới nhất.
 $other_links = array();
 $related_articles = intval($page_config['related_articles']);
 if ($related_articles) {
Ejemplo n.º 6
0
<?php

/**
 * @Project NUKEVIET 4.x
 * @Author VINADES.,JSC (contact@vinades.vn)
 * @Copyright (C) 2014 VINADES.,JSC. All rights reserved
 * @License GNU/GPL version 2 or any later version
 * @Createdate 2-10-2010 18:49
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
$content = $nv_Request->get_title('content', 'post', '', 1);
$keywords = nv_get_keywords($content);
include NV_ROOTDIR . '/includes/header.php';
echo $keywords;
include NV_ROOTDIR . '/includes/footer.php';
Ejemplo n.º 7
0
/**
 * nv_update_keywords()
 * 
 * @param mixed $catid
 * @return
 */
function nv_update_keywords($catid)
{
    global $db, $module_data;
    $content = array();
    $sql = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `catid`=" . $catid . " AND `status`=1";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $content[] = $row['title'] . " " . $row['question'] . " " . $row['answer'];
    }
    $content = implode(" ", $content);
    $keywords = nv_get_keywords($content);
    if (!empty($keywords)) {
        $db->sql_query("UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_categories` SET `keywords`=" . $db->dbescape($keywords) . " WHERE `id`=" . $catid);
    }
    return $keywords;
}
Ejemplo n.º 8
0
     $contents = $cache['contents'];
 } else {
     $cache = array();
     $sql = "SELECT `id`,`title`,`alias`,`bodytext`,`keywords`,`add_time`,`edit_time` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `status`=1 AND `id`=" . $id;
     $query = $db->sql_query($sql);
     $row = $db->sql_fetchrow($query);
     $row['add_time'] = nv_date("H:i T l, d/m/Y", $row['add_time']);
     $row['edit_time'] = nv_date("H:i T l, d/m/Y", $row['edit_time']);
     $contents = $cache['contents'] = nv_about_main($row, $ab_links);
     $cache['bodytext'] = strip_tags($row['bodytext']);
     $cache['bodytext'] = nv_clean60($cache['bodytext'], 300);
     $page_title = $mod_title = $cache['page_title'] = $row['title'];
     if (!empty($row['keywords'])) {
         $key_words = $cache['keywords'] = $row['keywords'];
     } else {
         $key_words = nv_get_keywords($row['bodytext']);
         if (empty($key_words)) {
             $key_words = nv_unhtmlspecialchars($row['title']);
             $key_words = strip_punctuation($key_words);
             $key_words = trim($key_words);
             $key_words = nv_strtolower($key_words);
             $key_words = preg_replace("/[ ]+/", ",", $key_words);
         }
         $cache['keywords'] = $key_words;
         $query = "UPDATE`" . NV_PREFIXLANG . "_" . $module_data . "` SET `keywords`=" . $db->dbescape($key_words) . " WHERE `id` =" . $id;
         $db->sql_query($query);
     }
     $cache['alias'] = $row['alias'];
     //Dung cho Block
     $cache = serialize($cache);
     nv_set_cache($cache_file, $cache);
Ejemplo n.º 9
0
}
$error = "";
if ($nv_Request->get_int('save', 'post') == '1') {
    $title = filter_text_input('title', 'post', '', 1);
    $alias = filter_text_input('alias', 'post', '', 1);
    $bodytext = nv_editor_filter_textarea('bodytext', '', NV_ALLOWED_HTML_TAGS);
    $keywords = nv_strtolower(filter_text_input('keywords', 'post', '', 0));
    if (empty($title)) {
        $error = $lang_module['aabout9'];
    } elseif (strip_tags($bodytext) == "") {
        $error = $lang_module['aabout10'];
    } else {
        $bodytext = nv_editor_nl2br($bodytext);
        $alias = empty($alias) ? change_alias($title) : change_alias($alias);
        if (empty($keywords)) {
            $keywords = nv_get_keywords($bodytext);
            if (empty($keywords)) {
                $keywords = nv_unhtmlspecialchars($title);
                $keywords = strip_punctuation($keywords);
                $keywords = trim($keywords);
                $keywords = nv_strtolower($keywords);
                $keywords = preg_replace("/[ ]+/", ",", $keywords);
            }
        }
        if ($id) {
            $sql = "UPDATE`" . NV_PREFIXLANG . "_" . $module_data . "` SET \n            `title`=" . $db->dbescape($title) . ", `alias` =  " . $db->dbescape($alias) . ", \n            `bodytext`=" . $db->dbescape($bodytext) . ", `keywords`=" . $db->dbescape($keywords) . ", `edit_time`=" . NV_CURRENTTIME . " WHERE `id` =" . $id;
            $db->sql_query($sql);
            $publtime = $row['add_time'];
        } else {
            list($weight) = $db->sql_fetchrow($db->sql_query("SELECT MAX(`weight`) FROM `" . NV_PREFIXLANG . "_" . $module_data . "`"));
            $weight = intval($weight) + 1;
Ejemplo n.º 10
0
 $array['pubtime'] = $nv_Request->get_string('pubtime', 'post', '');
 $array['pubtime_h'] = $nv_Request->get_int('pubtime_h', 'post', 0);
 $array['pubtime_m'] = $nv_Request->get_int('pubtime_m', 'post', 0);
 $array['exptime'] = $nv_Request->get_string('exptime', 'post', '');
 $array['exptime_h'] = $nv_Request->get_int('exptime_h', 'post', 0);
 $array['exptime_m'] = $nv_Request->get_int('exptime_m', 'post', 0);
 $array['expmode'] = $nv_Request->get_int('expmode', 'post', 0);
 $newsletters = $nv_Request->get_int('newsletters', 'post', 0);
 $isAutoKeywords = $nv_Request->get_int('isAutoKeywords', 'post', 0);
 // Chuẩn hóa google author
 if (!preg_match("/^([0-9]{1,30})\$/", $array['postgoogleid'])) {
     $array['postgoogleid'] = $BL->setting['sysGoogleAuthor'];
 }
 // Tự động lấy từ khóa
 if (!empty($isAutoKeywords) and empty($array['keywords'])) {
     $array['keywords'] = nv_get_keywords($array['bodyhtml']);
 }
 // Chuan hoa tu khoa
 $array['keywords'] = $array['keywords'] ? implode(", ", array_filter(array_unique(array_map("trim", explode(",", $array['keywords']))))) : "";
 // Chinh duong dan anh
 if (!empty($array['images'])) {
     if (preg_match("/^\\//i", $array['images'])) {
         $array['images'] = substr($array['images'], strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $module_name));
     }
 }
 // Chinh duong dan media
 if (!empty($array['mediavalue'])) {
     if (preg_match("/^\\//i", $array['mediavalue'])) {
         $array['mediavalue'] = substr($array['mediavalue'], strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $module_name));
     }
 }
Ejemplo n.º 11
0
 $addtime = NV_CURRENTTIME - mt_rand(60, 1000);
 $hometext = (isset($item['hometext']) and $item['hometext']) ? nv_htmlspecialchars(str_replace('\'', '"', strip_tags($item['hometext']))) : '';
 $item['bodyhtml'] = defined('NV_EDITOR') ? nv_nl2br($item['bodyhtml'], '') : nv_nl2br(nv_htmlspecialchars(strip_tags($item['bodyhtml'])), '<br />');
 $bodyhtml = (isset($item['bodyhtml']) and $item['bodyhtml']) ? str_replace('\'', '"', $item['bodyhtml']) : '';
 $bodytext = nv_news_get_bodytext($bodyhtml);
 $sourcetext = (isset($item['sourcetext']) and $item['sourcetext']) ? nv_htmlspecialchars(str_replace('\'', '"', strip_tags($item['sourcetext']))) : '';
 $sourceid = (isset($item['sourceid']) and $item['sourceid']) ? $item['sourceid'] : 0;
 $homeimgfile = (isset($item['homeimgfile']) and $item['homeimgfile']) ? $item['homeimgfile'] : '';
 $homeimgthumb = (isset($item['image_url']) and $item['image_url']) ? 'thumb/' . basename($item['image_url']) : '';
 $homeimgalt = (isset($item['homeimgalt']) and $item['homeimgalt']) ? nv_htmlspecialchars(str_replace('\'', '"', strip_tags($item['homeimgalt']))) : '';
 $author = (isset($item['author']) and $item['author']) ? nv_htmlspecialchars(str_replace('\'', '"', strip_tags($item['author']))) : '';
 $keywords = "";
 if ($hometext != "") {
     $keywords = nv_get_keywords($hometext);
 } else {
     $keywords = nv_get_keywords(nv_fil_tag($bodyhtml));
 }
 /* 	các bảng cần chèn dữ liệu gồm:
  **	NV_PREFIXLANG."_".$table_name."_rows"
  **	NV_PREFIXLANG."_".$table_name."_".$item['catid']
  **	NV_PREFIXLANG."_".$table_name."_bodyhtml_*"
  **	NV_PREFIXLANG."_".$table_name."_bodytext"
  **	NV_PREFIXLANG."_".$table_name."_block"
  */
 $query = "INSERT INTO " . NV_PREFIXLANG . "_" . $table_name . "_rows (id, catid, listcatid, topicid, admin_id, author, sourceid, addtime, edittime, status, publtime, exptime, archive, title, alias, hometext, homeimgfile, homeimgalt, homeimgthumb, inhome, allowed_comm, allowed_rating, hitstotal, hitscm, total_rating, click_rating) VALUES \n\t\t\t\t(NULL, " . $item['catid'] . ", '" . $item['catid'] . "', 0, 1, '" . $author . "', " . $sourceid . ", " . $addtime . ", " . $addtime . ", " . $item['status'] . ", " . $addtime . ", 0, 2, '" . $item['title'] . "', '" . $item['alias'] . "', '" . $hometext . "', '" . $homeimgfile . "', '" . $homeimgalt . "', '" . $homeimgthumb . "', 1, 2, 1, 1, 0, 0, 0);";
 // Lưu vào NV_PREFIXLANG."_".$table_name."_rows"
 //if( $id=$db->query_insert_id( $query ) ){
 if ($id = $db->insert_id($query, 'id', array())) {
     // Lưu vào NV_PREFIXLANG."_".$table_name."_".$item['catid']
     $query = "INSERT INTO " . NV_PREFIXLANG . "_" . $table_name . "_" . $item['catid'] . " (id, catid, listcatid, topicid, admin_id, author, sourceid, addtime, edittime, status, publtime, exptime, archive, title, alias, hometext, homeimgfile, homeimgalt, homeimgthumb, inhome, allowed_comm, allowed_rating, hitstotal, hitscm, total_rating, click_rating) VALUES \n\t\t\t\t\t(" . $id . ", " . $item['catid'] . ", '" . $item['catid'] . "', 0, 1, '" . $author . "', " . $sourceid . ", " . $addtime . ", " . $addtime . ", " . $item['status'] . ", " . $addtime . ", 0, 2, '" . $item['title'] . "', '" . $item['alias'] . "', '" . $hometext . "', '" . $homeimgfile . "', '" . $homeimgalt . "', 2, 1, 2, 1, 1, 0, 0, 0);";
     $db->query($query);
Ejemplo n.º 12
0
function nv_content_keywords($content)
{
    global $db, $db_config, $lang_module, $module_name, $op, $global_config, $sys_info;
    $keywords = "n/a";
    if ($content != "") {
        $arrkw = array();
        $memoryLimitMB = (int) ini_get('memory_limit');
        if ($memoryLimitMB > 60 and file_exists(NV_ROOTDIR . "/includes/keywords/" . NV_LANG_DATA . ".txt")) {
            require_once NV_ROOTDIR . "/includes/keywords/" . NV_LANG_DATA . ".txt";
        }
        $keywords_return = array();
        if (!empty($arrkw)) {
            //echo "test1";die;
            nv_internal_encoding($global_config['site_charset']);
            $content = nv_strtolower($content);
            $content = str_replace(array('&quot;', '&copy;', '&gt;', '&lt;', '&nbsp;'), " ", $content);
            $content = str_replace(array(',', ')', '(', '.', "'", '"', '<', '>', ';', '!', '?', '/', '-', '_', '[', ']', ':', '+', '=', '#', '$', chr(10), chr(13), chr(9)), " ", $content);
            $content = preg_replace('/ {2,}/si', " ", $content);
            $content_array = explode(" ", $content);
            $a = 0;
            $b = count($content_array);
            for ($i = 0; $i < $b - 3; $i++) {
                $key3 = $content_array[$i] . " " . $content_array[$i + 1] . " " . $content_array[$i + 2];
                $key2 = $content_array[$i] . " " . $content_array[$i + 1];
                if (array_search($key3, $arrkw)) {
                    $keywords_return[] = $key3;
                } elseif (array_search($key2, $arrkw)) {
                    $keywords_return[] = $key2;
                }
                $keywords_return = array_unique($keywords_return);
                if (count($keywords_return) > 20) {
                    break;
                }
            }
            $keywords = implode(", ", $keywords_return);
        } else {
            //echo "test2";die;
            $keywords = nv_get_keywords($content);
            if (empty($keywords)) {
                $keywords = "n/a";
            }
        }
    }
    return $keywords;
}
Ejemplo n.º 13
0
         }
     } else {
         list($rowcontent['sourceid']) = $db->sql_fetchrow($db->sql_query("SELECT `sourceid` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_sources` WHERE `title`=" . $db->dbescape($rowcontent['sourcetext'])));
         if (empty($rowcontent['sourceid'])) {
             list($weight) = $db->sql_fetchrow($db->sql_query("SELECT max(`weight`) FROM `" . NV_PREFIXLANG . "_" . $module_data . "_sources`"));
             $weight = intval($weight) + 1;
             $query = "INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "_sources` (`sourceid`, `title`, `link`, `logo`, `weight`, `add_time`, `edit_time`) VALUES (NULL, " . $db->dbescape($rowcontent['sourcetext']) . ", '', '', " . $db->dbescape($weight) . ", UNIX_TIMESTAMP( ), UNIX_TIMESTAMP( ))";
             $rowcontent['sourceid'] = $db->sql_query_insert_id($query);
         }
     }
 }
 if ($rowcontent['keywords'] == "") {
     if ($rowcontent['hometext'] != "") {
         $rowcontent['keywords'] = nv_get_keywords($rowcontent['hometext']);
     } else {
         $rowcontent['keywords'] = nv_get_keywords($rowcontent['bodyhtml']);
     }
 }
 // Xu ly anh minh hoa
 $rowcontent['homeimgthumb'] = "";
 if (!nv_is_url($rowcontent['homeimgfile']) and file_exists(NV_DOCUMENT_ROOT . $rowcontent['homeimgfile'])) {
     $lu = strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $module_name . "/");
     $rowcontent['homeimgfile'] = substr($rowcontent['homeimgfile'], $lu);
 } elseif (!nv_is_url($rowcontent['homeimgfile'])) {
     $rowcontent['homeimgfile'] = "";
 }
 $check_thumb = false;
 if ($rowcontent['id'] > 0) {
     list($homeimgfile, $homeimgthumb) = $db->sql_fetchrow($db->sql_query("SELECT `homeimgfile`, `homeimgthumb` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `id`=" . $rowcontent['id']));
     if ($rowcontent['homeimgfile'] != $homeimgfile) {
         $check_thumb = true;
Ejemplo n.º 14
0
/**
 * nv_update_keywords()
 * 
 * @param mixed $catid
 * @return
 */
function nv_update_keywords($catid)
{
    global $db, $module_data;
    $content = array();
    $sql = "SELECT * FROM " . NV_PREFIXLANG . "_" . $module_data . " WHERE catid=" . $catid . " AND status=1";
    $result = $db->query($sql);
    while ($row = $result->fetch()) {
        $content[] = $row['title'] . " " . $row['question'] . " " . $row['answer'];
    }
    $content = implode(" ", $content);
    $keywords = nv_get_keywords($content);
    if (!empty($keywords)) {
        $db->query("UPDATE " . NV_PREFIXLANG . "_" . $module_data . "_categories SET keywords=" . $db->quote($keywords) . " WHERE id=" . $catid);
    }
    return $keywords;
}