/**
 * BoldKeywordInStr()
 * 
 * @param mixed $str
 * @param mixed $keyword
 * @return
 */
function BoldKeywordInStr($str, $keyword, $logic)
{
    global $db;
    $str = nv_br2nl($str);
    $str = nv_nl2br($str, " ");
    $str = nv_unhtmlspecialchars(strip_tags(trim($str)));
    $str = $db->unfixdb($str);
    $pos = false;
    if ($logic == 'AND') {
        $array_keyword = array($keyword, nv_EncString($keyword));
    } else {
        $keyword .= " " . nv_EncString($keyword);
        $array_keyword = explode(" ", $keyword);
        $array_keyword = array_unique($array_keyword);
    }
    foreach ($array_keyword as $k) {
        unset($matches);
        if (preg_match("/^(.*?)" . preg_quote($k) . "/uis", $str, $matches)) {
            $strlen = nv_strlen($str);
            $kstrlen = nv_strlen($k);
            $residual = $strlen - 300;
            if ($residual > 0) {
                $lstrlen = nv_strlen($matches[1]);
                $rstrlen = $strlen - $lstrlen - $kstrlen;
                $medium = round((300 - $kstrlen) / 2);
                if ($lstrlen <= $medium) {
                    $str = nv_clean60($str, 300);
                } elseif ($rstrlen <= $medium) {
                    $str = nv_substr($str, $residual, 300);
                    $str = nv_substr_clean($str, 'l');
                } else {
                    $str = nv_substr($str, $lstrlen - $medium, $strlen - $lstrlen + $medium);
                    $str = nv_substr($str, 0, 300);
                    $str = nv_substr_clean($str, 'lr');
                }
            }
            $pos = true;
            break;
        }
    }
    if (!$pos) {
        return nv_clean60($str, 300);
    }
    $pattern = array();
    foreach ($array_keyword as $k) {
        $pattern[] = "/(" . preg_quote($k) . ")/uis";
    }
    $str = preg_replace($pattern, "{\\1}", $str);
    $str = str_replace(array("{", "}"), array("<span class=\"keyword\">", "</span>"), $str);
    return $str;
}
Beispiel #2
0
/**
 * BoldKeywordInStr()
 *
 * @param mixed $str
 * @param mixed $keyword
 * @return
 */
function BoldKeywordInStr($str, $keyword, $logic)
{
    $str = nv_br2nl($str);
    $str = nv_nl2br($str, ' ');
    $str = nv_unhtmlspecialchars(strip_tags(trim($str)));
    $pos = false;
    if ($logic == 'AND') {
        $array_keyword = array($keyword, nv_EncString($keyword));
    } else {
        $keyword .= ' ' . nv_EncString($keyword);
        $array_keyword = explode(' ', $keyword);
        $array_keyword = array_unique($array_keyword);
    }
    foreach ($array_keyword as $k) {
        if (preg_match('/^(.*?)' . nv_preg_quote($k) . '/uis', $str, $matches)) {
            $strlen = nv_strlen($str);
            $kstrlen = nv_strlen($k);
            $residual = $strlen - 300;
            if ($residual > 0) {
                $lstrlen = nv_strlen($matches[1]);
                $rstrlen = $strlen - $lstrlen - $kstrlen;
                $medium = round((300 - $kstrlen) / 2);
                if ($lstrlen <= $medium) {
                    $str = nv_clean60($str, 300);
                } elseif ($rstrlen <= $medium) {
                    $str = nv_substr($str, $residual, 300);
                    $str = nv_substr_clean($str, 'l');
                } else {
                    $str = nv_substr($str, $lstrlen - $medium, $strlen - $lstrlen + $medium);
                    $str = nv_substr($str, 0, 300);
                    $str = nv_substr_clean($str, 'lr');
                }
            }
            $pos = true;
            break;
        }
    }
    if (!$pos) {
        return nv_clean60($str, 300);
    }
    $pattern = array();
    foreach ($array_keyword as $k) {
        $pattern[] = '/(' . nv_preg_quote($k) . ')/uis';
    }
    $str = preg_replace($pattern, '{\\1}', $str);
    $str = str_replace(array('{', '}'), array('<span class="keyword">', '</span>'), $str);
    return $str;
}
Beispiel #3
0
/**
 * is_serialized_string()
 *
 * @param mixed $data
 * @return
 */
function is_serialized_string($data)
{
    if (!is_string($data)) {
        return false;
    }
    $data = trim($data);
    $length = nv_strlen($data);
    if ($length < 4) {
        return false;
    } elseif ($data[1] !== ':') {
        return false;
    } elseif ($data[0] !== 'a') {
        return false;
    } else {
        return true;
    }
}
     $value = nv_nl2br($value, '<br />');
     if ($row_f['match_type'] == 'regex') {
         if (!preg_match("/" . $row_f['match_regex'] . "/", $value)) {
             $error = sprintf($lang_module['field_match_type_error'], $row_f['title']);
         }
     } elseif ($row_f['match_type'] == 'callback') {
         if (function_exists($row_f['func_callback'])) {
             if (!call_user_func($row_f['func_callback'], $value)) {
                 $error = sprintf($lang_module['field_match_type_error'], $row_f['title']);
             }
         } else {
             $error = "error function not exists " . $row_f['func_callback'];
         }
     }
     $value = $row_f['question_type'] == 'textarea' ? nv_nl2br($value, '<br />') : nv_editor_nl2br($value);
     $strlen = nv_strlen($value);
     if ($strlen < $row_f['min_length'] or $strlen > $row_f['max_length']) {
         $error = sprintf($lang_module['field_min_max_error'], $row_f['title'], $row_f['min_length'], $row_f['max_length']);
     }
 } elseif ($row_f['question_type'] == 'checkbox' or $row_f['question_type'] == 'multiselect') {
     $temp_value = array();
     $row_f['question_choices'] = unserialize($row_f['question_choices']);
     foreach ($value as $value_i) {
         if (isset($row_f['question_choices'][$value_i])) {
             $temp_value[] = $value_i;
         }
     }
     $value = implode(',', $temp_value);
 } elseif ($row_f['question_type'] == 'select' or $row_f['question_type'] == 'radio') {
     $row_f['question_choices'] = unserialize($row_f['question_choices']);
     if (!isset($row_f['question_choices'][$value])) {
Beispiel #5
0
/**
 * nv_clean60()
 *
 * @param mixed $string
 * @param integer $num
 * @return
 */
function nv_clean60($string, $num = 60, $specialchars = false)
{
    global $global_config;
    $string = nv_unhtmlspecialchars($string);
    $len = nv_strlen($string);
    if ($num and $num < $len) {
        if (ord(nv_substr($string, $num, 1)) == 32) {
            $string = nv_substr($string, 0, $num) . '...';
        } elseif (strpos($string, ' ') === false) {
            $string = nv_substr($string, 0, $num);
        } else {
            $string = nv_clean60($string, $num - 1);
        }
    }
    if ($specialchars) {
        $string = nv_htmlspecialchars($string);
    }
    return $string;
}
Beispiel #6
0
$logic = filter_text_input('logic', 'get', 'OR');
if ($logic != 'AND') {
    $logic = 'OR';
}
$checkss = filter_text_input('search_ss', 'get', '', 1, 32);
$ss = md5($client_info['session_id'] . $global_config['sitekey']);
if (!preg_match("/^[a-z0-9]{32}\$/", $checkss) or $checkss != $ss) {
    $key = "";
} else {
    $key = nv_unhtmlspecialchars($key);
    if ($logic == 'OR') {
        $key = preg_replace(array("/^([\\S]{1})\\s/uis", "/\\s([\\S]{1})\\s/uis", "/\\s([\\S]{1})\$/uis"), " ", $key);
    }
    $key = strip_punctuation($key);
    $key = trim($key);
    $len_key = nv_strlen($key);
    $key = nv_htmlspecialchars($key);
}
if ($len_key < NV_MIN_SEARCH_LENGTH) {
    die('&nbsp;&nbsp;');
}
$pages = $nv_Request->get_int('page', 'get', 0);
$contents = "";
$ss = md5($client_info['session_id'] . $global_config['sitekey']);
foreach ($mods as $m_name => $m_values) {
    $all_page = 0;
    $result_array = array();
    $dbkeyword = $db->dblikeescape($key);
    include NV_ROOTDIR . "/modules/" . $m_values['module_file'] . "/search.php";
    if (!empty($all_page) and !empty($result_array)) {
        $contents .= result_theme($result_array, $m_name, $m_values['custom_title'], $key, $logic, $ss, $is_generate_page, $pages, $limit, $all_page);
Beispiel #7
0
 }
 if ($search['page'] > 1) {
     $base_url_rewrite .= '&page=' . $search['page'];
 }
 $base_url_rewrite = nv_url_rewrite($base_url_rewrite, true);
 $request_uri = urldecode($_SERVER['REQUEST_URI']);
 if ($request_uri != $base_url_rewrite and NV_MAIN_DOMAIN . $request_uri != $base_url_rewrite) {
     Header('Location: ' . $base_url_rewrite);
     die;
 }
 if (!empty($search['key'])) {
     if (!$search['logic']) {
         $search['key'] = preg_replace(array("/^([\\S]{1})\\s/uis", "/\\s([\\S]{1})\\s/uis", "/\\s([\\S]{1})\$/uis"), " ", $search['key']);
     }
     $search['key'] = trim($search['key']);
     $search['len_key'] = nv_strlen($search['key']);
 }
 if ($search['len_key'] < NV_MIN_SEARCH_LENGTH) {
     $search['is_error'] = true;
     $search['errorInfo'] = sprintf($lang_module['searchQueryError'], NV_MIN_SEARCH_LENGTH);
 } else {
     if (!empty($search['mod']) and isset($array_mod[$search['mod']])) {
         $mods = array($search['mod'] => $array_mod[$search['mod']]);
         $limit = 10;
         $is_generate_page = true;
     } else {
         $mods = $array_mod;
         $limit = 3;
         $is_generate_page = false;
     }
     $dbkeyword = $db->dblikeescape($search['key']);
Beispiel #8
0
$page_title = $lang_module['keywordRank'];
$contents = '';
$xtpl = new XTemplate('keywordRank.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
$xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE);
$xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE);
$xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
$xtpl->assign('LANG', $lang_module);
$xtpl->assign('TITLE', sprintf($lang_module['keywordFormTitle'], NV_SERVER_NAME));
if ($nv_Request->isset_request('i', 'get')) {
    $i = $nv_Request->get_string('i', 'get');
    if ($i == 'process') {
        $keyword = nv_substr($nv_Request->get_title('k', 'get', '', 0), 0, 60);
        $keyword = nv_unhtmlspecialchars($keyword);
        $keyword = strip_punctuation($keyword);
        $keyword = trim($keyword);
        $len_key = nv_strlen($keyword);
        //$keyword = nv_htmlspecialchars( $keyword );
        $lang = $nv_Request->get_title('l', 'get', '');
        $accuracy = $nv_Request->get_title('a', 'get', '');
        if ($len_key < 3 or $len_key > 60) {
            $xtpl->assign('ERROR', $lang_module['keywordInfo']);
            $xtpl->parse('process.error');
        } else {
            $myDomain = NV_SERVER_NAME;
            // $myDomain = 'nukeviet.vn';
            $from = 'google';
            $tempFile = md5($keyword . $lang . $accuracy . $from . $myDomain);
            $tempFile = NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . NV_TEMPNAM_PREFIX . $tempFile;
            if (file_exists($tempFile) and @filemtime($tempFile) > NV_CURRENTTIME - 600) {
                $info = file_get_contents($tempFile);
                $info = unserialize($info);
Beispiel #9
0
/**
 * nv_get_keywords()
 *
 * @param string $content
 * @return
 */
function nv_get_keywords($content, $keyword_limit = 20)
{
    $content = strip_tags($content);
    $content = nv_unhtmlspecialchars($content);
    $content = strip_punctuation($content);
    $content = trim($content);
    $content = nv_strtolower($content);
    $content = ' ' . $content . ' ';
    $keywords_return = array();
    $memoryLimitMB = (int) ini_get('memory_limit');
    if ($memoryLimitMB > 60 and file_exists(NV_ROOTDIR . '/includes/keywords/' . NV_LANG_DATA . '.php')) {
        require NV_ROOTDIR . '/includes/keywords/' . NV_LANG_DATA . '.php';
        $content_array = explode(' ', $content);
        $a = 0;
        $b = sizeof($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, $array_keywords_3)) {
                $keywords_return[] = $key3;
                $i = $i + 2;
            } elseif (array_search($key2, $array_keywords_2)) {
                $keywords_return[] = $key2;
                $i = $i + 1;
            }
            $keywords_return = array_unique($keywords_return);
            if (sizeof($keywords_return) > $keyword_limit) {
                break;
            }
        }
    } else {
        $pattern_word = array();
        if (NV_SITEWORDS_MIN_3WORDS_LENGTH > 0 and NV_SITEWORDS_MIN_3WORDS_PHRASE_OCCUR > 0) {
            $pattern_word[] = "/[\\s]+([\\S]{" . NV_SITEWORDS_MIN_3WORDS_LENGTH . ",}\\s[\\S]{" . NV_SITEWORDS_MIN_3WORDS_LENGTH . ",}\\s[\\S]{" . NV_SITEWORDS_MIN_3WORDS_LENGTH . ",})[\\s]+/uis";
        }
        if (NV_SITEWORDS_MIN_2WORDS_LENGTH > 0 and NV_SITEWORDS_MIN_2WORDS_PHRASE_OCCUR > 0) {
            $pattern_word[] = "/[\\s]+([\\S]{" . NV_SITEWORDS_MIN_2WORDS_LENGTH . ",}\\s[\\S]{" . NV_SITEWORDS_MIN_2WORDS_LENGTH . ",})[\\s]+/uis";
        }
        if (NV_SITEWORDS_MIN_WORD_LENGTH > 0 and NV_SITEWORDS_MIN_WORD_OCCUR > 0) {
            $pattern_word[] = "/[\\s]+([\\S]{" . NV_SITEWORDS_MIN_WORD_LENGTH . ",})[\\s]+/uis";
        }
        if (empty($pattern_word)) {
            return '';
        }
        $lenght = 0;
        $max_strlen = min(NV_SITEWORDS_MAX_STRLEN, 300);
        foreach ($pattern_word as $pattern) {
            while (preg_match($pattern, $content, $matches)) {
                $keywords_return[] = $matches[1];
                $lenght += nv_strlen($matches[1]);
                $content = preg_replace("/[\\s]+(" . preg_quote($matches[1]) . ")[\\s]+/uis", ' ', $content);
                if ($lenght >= $max_strlen) {
                    break;
                }
            }
            if ($lenght >= $max_strlen) {
                break;
            }
        }
        $keywords_return = array_unique($keywords_return);
    }
    return implode(',', $keywords_return);
}
/**
 * nv_strrpos()
 * 
 * @param mixed $haystack
 * @param mixed $needle
 * @param mixed $offset
 * @return
 */
function nv_strrpos($haystack, $needle, $offset = null)
{
    if (is_null($offset)) {
        $ar = explode($needle, $haystack);
        if (count($ar) > 1) {
            array_pop($ar);
            $haystack = join($needle, $ar);
            return nv_strlen($haystack);
        }
        return false;
    } else {
        if (!is_int($offset)) {
            trigger_error('nv_strrpos expects parameter 3 to be long', E_USER_WARNING);
            return false;
        }
        $haystack = nv_substr($haystack, $offset);
        if (false !== ($pos = nv_strrpos($haystack, $needle))) {
            return $pos + $offset;
        }
        return false;
    }
}
     $uemail = $user_info['email'];
     $post_id = $user_info['userid'];
 }
 if (!nv_capcha_txt($seccode)) {
     $error[] = $lang_module['comment_error2'];
 }
 if (empty($uname) or nv_strlen($uname) < 3) {
     $error[] = $lang_module['comment_error3'];
 }
 if (($validemail = nv_check_valid_email($uemail)) != "") {
     $error[] = $validemail;
 }
 if (empty($subject) or nv_strlen($subject) < 3) {
     $error[] = $lang_module['comment_error4'];
 }
 if (empty($content) or nv_strlen($content) < 3) {
     $error[] = $lang_module['comment_error5'];
 }
 $download_config = initial_config_data();
 if ($download_config['is_autocomment_allow']) {
     $status = 1;
 } else {
     $status = 0;
 }
 if (!empty($error)) {
     echo implode("\n", $error);
     die;
 }
 $content = nv_nl2br($content, "<br />");
 $sql = "INSERT INTO `" . NV_PREFIXLANG . "_" . $module_data . "_comments` VALUES (\r\n                    NULL, \r\n                    " . $id . ", \r\n                    " . $db->dbescape($subject) . ", \r\n                    " . $post_id . ", \r\n                    " . $db->dbescape($uname) . ", \r\n                    " . $db->dbescape($uemail) . ", \r\n                    " . $db->dbescape($client_info['ip']) . ", \r\n                    " . NV_CURRENTTIME . ", \r\n                    " . $db->dbescape($content) . ", \r\n                    '', 0, " . $status . ")";
 if (!$db->sql_query_insert_id($sql)) {
Beispiel #12
0
$adb = new albumdb();
if ($id != 0) {
    $result = $adb->getAllAlbumCotent($id);
    $data = $db->sql_fetchrow($result);
    if (!empty($data['path_img']) and file_exists(NV_UPLOADS_REAL_DIR . "/" . $module_name . $data['path_img'])) {
        $data['path_img'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $module_name . $data['path_img'];
    }
}
if ($nv_Request->get_int('add', 'post') == 1) {
    $data['name'] = filter_text_input('name', 'post', '', 1);
    $alias = change_alias($data['name']);
    $data['description'] = filter_text_textarea('description', '', NV_ALLOWED_HTML_TAGS);
    $data['path_img'] = filter_text_input('pic_path', 'post', '', 0);
    $data['active'] = filter_text_input('active', 'post', '0', 0);
    if (!nv_is_url($data['path_img']) and is_file(NV_DOCUMENT_ROOT . $data['path_img'])) {
        $lu = nv_strlen(NV_BASE_SITEURL . NV_UPLOADS_DIR . "/" . $module_name);
        $data['path_img'] = substr($data['path_img'], $lu);
    } elseif (!empty($data['path_img']) and !nv_is_url($data['path_img'])) {
        $data['path_img'] = "";
        $error = $lang_module['wrong_path'];
    }
    if (empty($data['name'])) {
        $error = $lang_module['err_null_name'];
    } elseif (empty($error)) {
        if ($id == 0) {
            $num_ab = $db->sql_numrows($adb->getAllalbums());
            if ($adb->addNewAlbum($num_ab + 1, $data['name'], $data['description'], $data['path_img'], $alias, $data['active'])) {
                $adb->freeResult();
                Header("Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "");
                die;
            } else {
/**
 * nv_substr_clean()
 *
 * @param mixed $string
 * @param string $mode
 * @return
 */
function nv_substr_clean($string, $mode = 'lr')
{
    $strlen = nv_strlen($string);
    $pos_bg = nv_strpos($string, " ") + 1;
    $pos_en = nv_strrpos($string, " ");
    if ($mode == 'l') {
        $string = "..." . nv_substr($string, $pos_bg, $strlen - $pos_bg);
    } elseif ($mode == 'r') {
        $string = nv_substr($string, 0, $strlen - $pos_en) . "...";
    } elseif ($mode == 'lr') {
        $string = "..." . nv_substr($string, $pos_bg, $pos_en - $pos_bg) . "...";
    }
    return $string;
}
/**
 * nv_clean60()
 * 
 * @param mixed $string
 * @param integer $num
 * @return
 */
function nv_clean60($string, $num = 60)
{
    global $global_config;
    $len = nv_strlen($string);
    if ($num and $num < $len) {
        if (ord(nv_substr($string, $num, 1)) == 32) {
            $string = nv_substr($string, 0, $num) . '...';
        } elseif (strpos($string, " ") === false) {
            $string = nv_substr($string, 0, $num);
        } else {
            $string = nv_clean60($string, $num - 1);
        }
    }
    return $string;
}