0, 'filter text' => 0, 'add sess_id' => 0, 'create thread url' => 0, 'create forum url' => 0, 'create memberlist url' => 0, 'get announcement info' => 0, 'get forum info' => 0, 'get thread info' => 0, 'search for url parts' => 0, 'get members info' => 0, 'build urls' => 0, 'apply url replacements' => 0, 'seo keywords replacements' => 0, 'get poll info' => 0, 'get attachments info' => 0, 'create announcement url' => 0, 'rel=nofollow additions' => 0, 'code cleanup' => 0, 'custum rewrite rules' => 0, 'images dimensions' => 0, 'make links' => 0, 'relevant replacements' => 0); function vbseo_mcrtime ($nosub = false) { $etime = explode (' ', microtime ()); return $etime[0] + $etime[1] - ($nosub ? 0 : $_SERVER['crawl_parts_added']); } function vbseo_parttime ($part, $start, $nosub = false) { $etime = vbseo_mcrtime ($nosub); $_SERVER['crawl_parts_added'] += $etime - $start; $_SERVER['crawl_parts'][$part] += $etime - $start; ++$_SERVER['crawl_parts_cnt'][$part]; } if ($pagestarttime) { $etime = explode (' ', $pagestarttime); $_SERVER['vb_start'] = $etime[0] + $etime[1]; } if (!$_SERVER['crawl_start']) { $_SERVER['crawl_start'] = vbseo_mcrtime (); } } error_reporting (E_ALL & ~E_NOTICE); include dirname (__FILE__) . '/config_vbseo.php'; if (!defined ('VBSEO_TOPREL')) { $vbseofn2 = $_SERVER['SCRIPT_FILENAME']; $vbseodocroot = preg_replace ('#\\\\+#', '/', $_SERVER['DOCUMENT_ROOT']); $vbseofn = $vbseolink = ''; while (((!$vbseolink AND 1 < strlen ($vbseofn2)) AND $vbseofn != $vbseofn2)) { $vbseofn = $vbseofn2; if (@is_link ($vbseofn)) { $vbseolink = readlink ($vbseofn); if (strstr ($vbseolink, '../')) { $vbseolink = $vbseofn . '/../' . $vbseolink; do { $ap = $vbseolink; $vbseolink = preg_replace ('#/?[^/]*/\\.\\.#', '', $ap, 1); }while (!($vbseolink != $ap)); } $vbseodocroot = str_replace ('//', '/', preg_replace ('#^' . preg_quote ($vbseofn, '#') . '#', $vbseolink, $vbseodocroot, 1)); $vbseofn = substr ($vbseofn, (1 < strlen ($vbseolink) ? strlen ($vbseolink) : 0)); break; } $vbseofn2 = dirname ($vbseofn); } if (((defined ('VBSEO_CUSTOM_DOCROOT') AND VBSEO_CUSTOM_DOCROOT) AND strstr ($vbseo_toprel = str_replace ('\\', '/', dirname (dirname (__FILE__))), VBSEO_CUSTOM_DOCROOT))) { $vbseo_toprel = str_replace (VBSEO_CUSTOM_DOCROOT, '', $vbseo_toprel); } else { if (!$vbseodocroot) { $vbseo_toprel = dirname ($_SERVER['PATH_INFO']); $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; } else { if (strstr ($vbseo_toprel = str_replace ('\\', '/', dirname (dirname (__FILE__))), $vbseodocroot)) { $vbseo_toprel = str_replace ($vbseodocroot, '', $vbseo_toprel); } else { if (strstr ($vbseo_toprel = str_replace ('\\', '/', dirname ($_SERVER['SCRIPT_FILENAME'])), $vbseodocroot)) { $vbseo_toprel = str_replace ($vbseodocroot, '', $vbseo_toprel); } else { $vbseo_toprel = dirname (dirname ($vbseofn)); } } } } define ('VBSEO_FN', $vbseofn); define ('VBSEO_RWDOCROOT', $vbseodocroot); $vbseo_toprel = preg_replace ('#^.*\\:#', '', $vbseo_toprel); define ('VBSEO_TOPREL', preg_replace ('#//+#', '/', '/' . str_replace ('\\', '/', $vbseo_toprel) . '/')); define ('VBSEO_TOPREL_FULL', ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . VBSEO_TOPREL); $vbseo_req = ($_SERVER['HTTP_X_REWRITE_URL'] ? $_SERVER['HTTP_X_REWRITE_URL'] : ($_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : $_ENV['REQUEST_URI'])); define ('VBSEO_BASE', preg_replace ('#[^/]*$#', '', $vbseo_req)); define ('VBSEO_INFORUMDIR', strstr (VBSEO_BASE, VBSEO_TOPREL)); define ('VBSEO_TOPBASE', ((strlen (VBSEO_TOPREL) < strlen (VBSEO_BASE) AND VBSEO_INFORUMDIR) ? substr (VBSEO_BASE, strlen (VBSEO_TOPREL)) : '')); define ('VBSEO_BASEDEPTH', ((strstr (VBSEO_TOPBASE, '/') OR strlen (VBSEO_BASE) < strlen (VBSEO_TOPREL)) OR !VBSEO_INFORUMDIR)); $vbseo_requrl = substr ($vbseo_req, (strstr (VBSEO_BASE, VBSEO_TOPREL) ? min (strlen (VBSEO_BASE), strlen (VBSEO_TOPREL)) : strlen (VBSEO_BASE))); define ('VBSEO_REQURL', $vbseo_requrl); define ('VBSEO_VB35X', (file_exists (dirname (__FILE__) . '/class_core.php') ? 1 : 0)); } define ('VBSEO_IS_ROBOT', preg_match ('#(appie|msnbot|jeeves|googlebot|mediapartners|harvest|htdig|yahoo|linkwalker|lycos_|' . 'scooter|slurp|ia_archiver|netcraft)#i', $_SERVER['HTTP_USER_AGENT'])); if (!defined ('VBSEO_SPACER')) { define ('VBSEO_SPACER', '-'); } if (!defined ('VBSEO_FILTER_STOPWORDS')) { define ('VBSEO_FILTER_STOPWORDS', 1); } if (!defined ('VBSEO_FILTER_FOREIGNCHARS')) { define ('VBSEO_FILTER_FOREIGNCHARS', 0); } if (!defined ('VBSEO_USE_HOSTNAME_IN_URL')) { define ('VBSEO_USE_HOSTNAME_IN_URL', 1); } if (!defined ('VBSEO_NOFOLLOW_SORT')) { define ('VBSEO_NOFOLLOW_SORT', 0); } if (!defined ('VBSEO_NOFOLLOW_DYNA')) { define ('VBSEO_NOFOLLOW_DYNA', 0); } if (!defined ('VBSEO_REWRITE_KEYWORDS_IN_URLS')) { define ('VBSEO_REWRITE_KEYWORDS_IN_URLS', 1); } $_SERVER['vbseo_seo_replacements'] = ($seo_replacements ? $seo_replacements : array ()); $_SERVER['vbseo_replace_link'] = ($vbseo_replace_link ? $vbseo_replace_link : array ()); $_SERVER['vbseo_custom_rules'] = ($vbseo_custom_rules ? $vbseo_custom_rules : array ()); $_SERVER['vbseo_relev_replace'] = ($vbseo_relev_replace ? $vbseo_relev_replace : array ()); $_SERVER['vbseo_images_dim'] = ($vbseo_images_dim ? $vbseo_images_dim : array ()); define ('VBSEO_AVATAR_PREFIX', 'avatars/'); define ('VBSEO_ATTACHMENTS_PREFIX', 'attachments/'); define ('VBSEO_ICON_PREFIX', 'iconimages/'); define ('VBSEO_FORUMID_URI', 'f'); define ('VBSEO_FORUMID_URI2', 'forumid'); define ('VBSEO_THREADID_URI', 't'); define ('VBSEO_USERID_URI', 'u'); define ('VBSEO_POSTID_URI', 'p'); define ('VBSEO_PAGENUM_URI', 'page'); define ('VBSEO_SORT_URI', 'sort'); define ('VBSEO_SORTORDER_URI', 'order'); define ('VBSEO_ACTION_URI', 'do'); define ('VBSEO_POLLID_URI', 'pollid'); define ('VBSEO_TREE_ICON', 'images/misc/navbits_finallink.gif'); define ('VBSEO_REDIRECT_URI', 'redirect-to/'); function vbseo_mem_cleanup () { $unsets = array ('vbseo_seo_replacements', 'vbseo_replace_link', 'vbseo_custom_rules', 'vbseo_images_dim', 'VBSEO_URI', 'gcache', 'vbseo_base_url', 'vbseo_format', 'r_post_id', 'vbseo_arr', 'vbseo_arr2', 'vb_start', 'crawl_parts', 'crawl_parts_added', 'crawl_parts_cnt', 'crawl_start', 'requrl', 'crawlDB'); foreach ($unsets as $un) { unset ($_SERVER[$un]); } } function check_vbseo_url ($format, $vbseo_url_, $allow_part = false) { if (preg_match_all ('#%([a-z_]+)%#', $format, $matches, PREG_PATTERN_ORDER)) { $fields = array_values (array_unique ($matches[1])); } else { $fields = array (); } $fieldCount = count ($fields); $format = preg_quote ($format, '#'); if ($fieldCount) { global $validchars; if (!$validchars) { $validchars = 'a-z\\.' . preg_quote (VBSEO_SPACER, '#') . '_____?'; } $replace = array ('#%[a-z_]*page%#' => '([0-9]+)', '#%[a-z_]+_id%#' => '([0-9]+)', '#%[a-z_]+_path%#' => '([' . $validchars . '0-9/-]+)', '#%[a-z_]+_filename%#' => '([' . $validchars . 'A-Z\\.0-9/-]+)', '#%[a-z_]+_title%#' => '([' . $validchars . 'A-Z0-9-]+)', '#%[a-z_]+_name%#' => '([^/]*)', '#%post_count%#' => '(\\d*?)', '#%letter%#' => '([a-z]|0|all)', '#%[a-z_]+%#' => '([A-Z' . $validchars . '0-9-]+)'); $format = preg_replace (array_keys ($replace), $replace, $format); } if ((($format[strlen ($format) - 1] == '/' AND $vbseo_url_[strlen ($vbseo_url_) - 1] != '/') AND !file_exists ($vbseo_url_))) { $folder_type = true; $format .= '?'; } else { $folder_type = false; } $expr = preg_replace ('#%[' . $validchars . 'A-Z0-9_\\.:-]+%#', '[^/]+', $format); $expr = ($allow_part ? '#' . $expr . '#' : '#^' . $expr . '$#'); if (preg_match ($expr, $vbseo_url_, $matches)) { if ($folder_type) { global $vbseo_url_suggest; $vbseo_url_suggest = $vbseo_url_ . '/'; } $results = array (1); $i = 0; while ($i < $fieldCount) { $results[$fields[$i]] = $matches[$i + 1]; ++$i; } return $results; } return null; } function set_self ($vbseo_url_) { if (!isset ($_SERVER)) { $_ENV = &$HTTP_ENV_VARS; $_SERVER = &$HTTP_SERVER_VARS; $_GET = &$HTTP_GET_VARS; $_POST = &$HTTP_POST_VARS; $_REQUEST = &$HTTP_GET_VARS; } else { global $_SERVER; } if ($vbseo_url_[0] == '/') { $page = $vbseo_url_; } else { $page = VBSEO_TOPREL . $vbseo_url_; } list ($basepage, $query) = explode ('?', $page, 2); $basepage = str_replace ('//', '/', $basepage); $pagepath = dirname (__FILE__) . '/' . str_replace (VBSEO_TOPREL, '', $basepage); $_SERVER['VBSEO_URI'] = $_SERVER['REQUEST_URI']; $setvars = array ($page, $basepage, $pagepath); $setar = array ('REQUEST_URI' => 0, 'SCRIPT_NAME' => 1, 'PHP_SELF' => 1, 'PATH_INFO' => 1, 'SCRIPT_FILENAME' => 2, 'PATH_TRANSLATED' => 2); foreach ($setar as $sa => $st) { $_SERVER[$sa] = $setvars[$st]; $_ENV[$sa] = $setvars[$st]; @putenv ($sa . '=' . $setvars[$st]); $GLOBALS[$sa] = $setvars[$st]; } $unsets = array ('REDIRECT_QUERY_STRING', 'REDIRECT_URL'); foreach ($unsets as $ui => $us) { unset ($_SERVER[$us]); unset ($_ENV[$us]); unset ($GLOBALS[$us]); @putenv ($us . '='); } $_SERVER['argv'][0] = $query; $GLOBALS['argv'][0] = $query; if ($query) { $_SERVER['QUERY_STRING'] = $query; $_ENV['QUERY_STRING'] = $query; @putenv ('QUERY_STRING=' . $query); $GLOBALS['QUERY_STRING'] = $query; parse_str ($query, $params); while (list ($name, $value) = each ($params)) { $_REQUEST[$name] = $value; $_GET[$name] = $value; } } } function vbseo_safe_redirect ($vbseo_url_, $unset_par = array (), $unset_all = false) { $vbroot = VBSEO_TOPREL_FULL; if ($vbroot[strlen ($vbroot) - 1] != '/') { $vbroot .= '/'; } if (!$unset_all) { $unset_par = array_merge ($unset_par, array ('grab_output', 'goto', 's', 'p', 'vbseourl')); $pars = explode ('&', str_replace ('&', '&', $_SERVER['QUERY_STRING'])); $req = ''; $i2 = 0; while ($i2 < count ($pars)) { list ($k, $v) = explode ('=', $pars[$i2], 2); if ((!in_array ($k, $unset_par) AND !strstr ($k, 'redirect_'))) { $req .= ($req ? '&' : '') . $k . '=' . $v; } ++$i2; } } if ($vbseo_url_[0] == '/') { $vbseo_url_ = substr ($vbseo_url_, 1); } $fulluri = (strstr ($vbseo_url_, '://') ? '' : $vbroot) . $vbseo_url_; if ($req) { $fulluri = preg_replace ('#^([^\\#]*)#', '$1?' . $req, $fulluri); } header ('HTTP/1.1 301 Moved Permanently'); header ('' . 'Location: ' . $fulluri); vbseo_close_db (); vbseo_mem_cleanup (); exit (); } function vbseo_prepare_seo_replace () { global $seo_replace_inurls; global $seo_preg_replace; global $seo_links_replace; if ($seo_replace_inurls) { return null; } $seo_replace_inurls = $seo_preg_replace = $seo_links_replace = array (); reset ($_SERVER['vbseo_seo_replacements']); foreach ($_SERVER['vbseo_seo_replacements'] as $sk => $sv) { $seo_replace_inurls['#\\b' . $sk . '\\b#i'] = str_replace (' ', '-', strtolower ($sv)); if (VBSEO_REWRITE_KEYWORDS_IN_TEXT) { $seo_preg_replace['#(<(?:[^s]|st|sp)[^<]*>)([^<]*?)\\b(' . $sk . ')\\b([^<]*)#ei'] = 'stripslashes("\\1\\2".(strstr("\\2","http:")?"\\3\\4":"' . $sv . '".preg_replace("#\\b' . $sk . '\\b#","' . $sv . '","\\4")))'; continue; } } } function vbseo_filter_text ($text, $allowchars = null, $filter_stop_words = true, $reversable = false) { global $vbseo_trans_table; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } $validchars = 'a-z0-9\\-_'; if (isset ($allowchars)) { $validchars .= preg_quote ($allowchars, '#'); } if ((!$reversable OR !VBSEO_REWRITE_MEMBER_MORECHARS)) { if (VBSEO_FILTER_FOREIGNCHARS == 0) { $validchars .= ''; $text = str_replace ('\'', ($reversable ? VBSEO_SPACER : ''), $text); } else { $trarr = array ('' => 'th', '' => 'th', '' => 'dh', '' => 'dh', '' => 'ss', '' => 'oe', '' => 'oe', '' => 'ae', '' => 'ae', '\'' => '', '' => 'ae', '' => 'oe', '' => 'ue'); $text = strtr (strtr ($text, $trarr), '', 'szszyaaaaaaceeeeiiiinoooooouuuuyaaaaaaceeeeiiiinoooooouuuuyyu'); } } $text = strtolower ($text); if (!isset ($vbseo_trans_table)) { $vbseo_trans_table = get_html_translation_table (HTML_ENTITIES); $vbseo_trans_table = array_flip ($vbseo_trans_table); } $text = strtr ($text, $vbseo_trans_table); if (($reversable AND VBSEO_REWRITE_MEMBER_MORECHARS)) { $text = urlencode ($text); } else { $text = str_replace ('&', ' and ', $text); if (preg_match ('#\\S#', $text2 = preg_replace ('#&\\#?[a-z0-9]+;#i', ' ', $text))) { $text = $text2; } $text = str_replace ('&', ' and ', $text); $text = preg_replace ('#[^' . $validchars . ']+#s', VBSEO_SPACER, $text); } if (($filter_stop_words AND VBSEO_FILTER_STOPWORDS != 0)) { if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } if ((((VBSEO_KEEP_STOPWORDS_SHORT AND 0 < VBSEO_URL_PART_MAX) AND preg_match_all ('#([^' . VBSEO_SPACER . ']+)#s', $text, $wmatch)) AND count ($wmatch[1]) <= VBSEO_URL_PART_MAX)) { } else { $text = preg_replace ('#\\b(' . VBSEO_STOPWORDS . ')\\b#i', '', $text); } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('filter stopwords', $start); } } $text = urlencode ($text); if (((!$reversable AND defined ('VBSEO_URL_PART_MAX')) AND 0 < VBSEO_URL_PART_MAX)) { $text = preg_replace ('#(([^' . VBSEO_SPACER . ']+' . VBSEO_SPACER . '*){' . VBSEO_URL_PART_MAX . '}).*$#s', '\\1', $text); } if (VBSEO_SPACER != '') { static $expr; static $repl; if (!isset ($expr)) { $spacerexpr = '(' . preg_quote (VBSEO_SPACER, '#') . ')'; $expr = array ('#' . $spacerexpr . '{2,}#', '#^' . $spacerexpr . '+#', '#' . $spacerexpr . '$#'); $repl = array (VBSEO_SPACER, '', ''); } $text = preg_replace ($expr, $repl, $text); } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('filter text', $start); } return $text; } function vbseo_filter_replace_text ($text, $allowchars = null, $filter_stop_words = true, $reversable = false) { global $seo_replace_inurls; $text = ($seo_replace_inurls ? preg_replace (array_keys ($seo_replace_inurls), $seo_replace_inurls, $text) : $text); $text = vbseo_filter_text ($text, $allowchars, $filter_stop_words, $reversable); return $text; } function vbseo_unfilter_text ($text) { $replace = array ('ue' => '(ue|)', 'oe' => '(oe||_|_)', 'ae' => '(ae|||)', 'ss' => '(ss|)', VBSEO_SPACER . 'and' . VBSEO_SPACER => VBSEO_SPACER . '(and|&|&)' . VBSEO_SPACER, 's' => '[s]', 'z' => '[z]', 'y' => '[y]', 'a' => '[a]', 'c' => '[cc]', 'e' => '[e]', 'i' => '[i]', 'n' => '[n]', 'o' => '[o]', 'th' => '(th||)', 'dh' => '(dh||)', 'u' => '([u]|u||)', VBSEO_SPACER => '(&[a-z]*;|[^a-z0-9])*'); return '^(&[a-z]*;|[^a-z0-9])*' . str_replace (array_keys ($replace), $replace, $text) . '(&[a-z]*;|[^a-z0-9])*$'; } function vbseo_addsessionhash ($url) { if (VBSEO_IS_ROBOT) { return $url; } if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } global $session; if (($session['sessionhash'] OR preg_match ('#^[0-9a-f]{16,32}$#i', $session[0]))) { if (!$session['sessionhash']) { $session['sessionhash'] = $session[0]; } if (strpos ($url, '?') !== false) { $url .= '&s=' . $session['sessionhash']; } else { $url .= '?s=' . $session['sessionhash']; } } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('add sess_id', $start); } return $url; } function vbseo_thread_url_row ($thread_row, $page = 1) { global $g_cache; $g_cache['thread'][$thread_row['threadid']] = $thread_row; $url = vbseo_thread_url ($thread_row['threadid'], $page); unset ($g_cache['thread'][$thread_row['threadid']]); return $url; } function vbseo_member_url_row ($userid, $username) { global $g_cache; global $vbseo_vars; $g_cache['user'][$userid] = compact ('userid', 'username'); $url = vbseo_member_url ($userid); unset ($g_cache['user'][$userid]); return $url; } function vbseo_post_url_row ($thread_row, $post_row, $postcount) { global $g_cache; $g_cache['post'][$post_row['postid']] = $post_row; $g_cache['thread'][$thread_row['threadid']] = $thread_row; $url = vbseo_post_url ($post_row['postid'], $postcount); unset ($g_cache['post'][$post_row['postid']]); unset ($g_cache['thread'][$thread_row['threadid']]); return $url; } function vbseo_post_url ($postid, $post_count) { if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } global $g_cache; $pinfo = $g_cache['post'][$postid]; $threadid = $pinfo['threadid']; $forumid = $g_cache['thread'][$threadid]['forumid']; $replace = array ('%post_id%' => $postid, '%post_count%' => $post_count, '%thread_id%' => $threadid, '%thread_title%' => $g_cache['thread'][$threadid]['seotitle'], '%forum_id%' => $forumid, '%forum_title%' => $g_cache['forum'][$forumid]['seotitle'], '%forum_path%' => $g_cache['forum'][$forumid]['path']); $rets = str_replace (array_keys ($replace), $replace, VBSEO_URL_POST_SHOW); if (!VBSEO_STRIP_SIDS) { $rets = vbseo_addsessionhash ($rets); } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('create thread url', $start); } return $rets; } function vbseo_thread_pagenum ($postcount) { global $bbuserinfo; global $vboptions; if ((!isset ($bbuserinfo['maxposts']) AND $bbuserinfo['userid'])) { $db = vbseo_get_db (); $getmaxposts = $db->query_first (' SELECT maxposts FROM ' . TABLE_PREFIX . 'user WHERE userid = \'' . $bbuserinfo['userid'] . '\' LIMIT 1 '); $bbuserinfo['maxposts'] = $getmaxposts['maxposts']; } if (0 < $bbuserinfo['maxposts']) { $vboptions['maxposts'] = $bbuserinfo['maxposts']; } return @ceil ($postcount / $vboptions['maxposts']); } function vbseo_thread_url_postid ($postid, $page = 1) { global $g_cache; global $vboptions; global $bbuserinfo; if (!$g_cache['post'][$postid]) { get_post_thread_info ($GLOBALS['find_postthread_ids']); get_thread_info ($GLOBALS['find_postthreads']); } $pinfo = $g_cache['post'][$postid]; if (!$pinfo) { return ''; } $threadid = $pinfo['threadid']; if ((isset ($pinfo['preposts']) AND $page == 1)) { $page = vbseo_thread_pagenum ($pinfo['preposts']); return vbseo_thread_url ($threadid, $page) . '#post' . $postid; } return vbseo_thread_url ($threadid, $page, (1 < $page ? VBSEO_URL_THREAD_GOTOPOST_PAGENUM : VBSEO_URL_THREAD_GOTOPOST), $postid); } function vbseo_thread_url ($threadid, $page = null, $special_format = '', $postid = '') { global $g_cache; $forumid = $g_cache['thread'][$threadid]['forumid']; if (!$forumid) { return ''; } $thread = &$g_cache['thread'][$threadid]; if (!$thread['seotitle']) { $thread['seotitle'] = vbseo_filter_replace_text (($thread['title'] ? $thread['title'] : $thread['threadtitle'])); } $title = $thread['seotitle']; if ((preg_match ('#\\b[0-9]+$#', $title) OR !$title)) { $title .= VBSEO_SPACER . 'a'; } if (!$g_cache['forum'][$forumid]['seotitle']) { $g_cache['forum'][$forumid]['seotitle'] = vbseo_filter_text ($g_cache['forum'][$forumid]['title']); } $replace = array ('%post_id%' => $postid, '%thread_id%' => $threadid, '%thread_title%' => $title, '%thread_page%' => (int)$page, '%forum_id%' => $forumid, '%forum_title%' => $g_cache['forum'][$forumid]['seotitle'], '%forum_path%' => $g_cache['forum'][$forumid]['path']); $uformat = ($special_format ? $special_format : ($page <= 1 ? VBSEO_URL_THREAD : VBSEO_URL_THREAD_PAGENUM)); $rets = str_replace (array_keys ($replace), $replace, $uformat); if (!VBSEO_STRIP_SIDS) { $rets = vbseo_addsessionhash ($rets); } return $rets; } function vbseo_poll_url ($pollid) { global $g_cache; $threadid = $g_cache['polls']['threadid']; if (!$threadid) { get_poll_info ($pollid); $db = vbseo_get_db (); $tar = $db->query_first ($q = ' SELECT threadid FROM ' . TABLE_PREFIX . ('' . 'thread AS thread WHERE pollid = ' . $pollid . ' LIMIT 1 ')); $threadid = $tar['threadid']; get_thread_info ($threadid); } $forumid = $g_cache['thread'][$threadid]['forumid']; if (!$g_cache['forum'][$forumid]['seotitle']) { $g_cache['forum'][$forumid]['seotitle'] = vbseo_filter_text ($g_cache['forum'][$forumid]['title']); } $replace = array ('%poll_id%' => $pollid, '%poll_title%' => vbseo_filter_text (strip_tags ($g_cache['polls'][$pollid]['question'])), '%forum_id%' => $forumid, '%forum_title%' => $g_cache['forum'][$forumid]['seotitle'], '%forum_path%' => $g_cache['forum'][$forumid]['path']); $rets = str_replace (array_keys ($replace), $replace, VBSEO_URL_POLL); if (!VBSEO_STRIP_SIDS) { $rets = vbseo_addsessionhash ($rets); } return $rets; } function vbseo_attachment_url ($attid) { global $g_cache; global $find_postthread_ids; $atarr = $g_cache['attach'][$attid]; $postid = $atarr['postid']; if ((!$attid OR !$postid)) { return ''; } if (!$g_cache['post'][$postid]) { get_post_thread_info ($find_postthread_ids); get_thread_info ($GLOBALS['find_postthreads']); } $threadid = $g_cache['post'][$postid]['threadid']; $forumid = $g_cache['thread'][$threadid]['forumid']; if (!$g_cache['forum'][$forumid]['seotitle']) { $g_cache['forum'][$forumid]['seotitle'] = vbseo_filter_text ($g_cache['forum'][$forumid]['title']); } $replace = array ('%attachment_id%' => $attid, '%original_filename%' => vbseo_filter_text ($atarr['filename'], '.'), '%thread_title%' => $g_cache['thread'][$threadid]['seotitle'], '%forum_title%' => $g_cache['forum'][$forumid]['seotitle'], '%forum_path%' => $g_cache['forum'][$forumid]['path'], '%forum_id%' => $forumid); $rets = str_replace (array_keys ($replace), $replace, VBSEO_ATTACHMENTS_PREFIX . VBSEO_URL_ATTACHMENT); if (!VBSEO_STRIP_SIDS) { $rets = vbseo_addsessionhash ($rets); } return $rets; } function vbseo_announcement_url ($forumid, $announcementid = 0) { global $g_cache; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } if (!$g_cache['forum'][$forumid]['announcement']) { return ''; } $aid = $announcementid; if ($announcementid) { $ann_title = $g_cache['forum'][$forumid]['announcement'][$announcementid]; } else { reset ($g_cache['forum'][$forumid]['announcement']); list ($aid, $ann_title) = each ($g_cache['forum'][$forumid]['announcement']); } $seo_title = vbseo_filter_replace_text ($ann_title); if (!$g_cache['forum'][$forumid]['seotitle']) { $g_cache['forum'][$forumid]['seotitle'] = vbseo_filter_text ($g_cache['forum'][$forumid]['title']); } $replace = array ('%forum_id%' => $forumid, '%forum_title%' => $g_cache['forum'][$forumid]['seotitle'], '%announcement_title%' => $seo_title, '%announcement_id%' => $aid, '%forum_path%' => $g_cache['forum'][$forumid]['path'], '%forum_page%' => $page); $rets = str_replace (array_keys ($replace), $replace, ($announcementid ? VBSEO_URL_FORUM_ANNOUNCEMENT : VBSEO_URL_FORUM_ANNOUNCEMENT_ALL)); if (!VBSEO_STRIP_SIDS) { $rets = vbseo_addsessionhash ($rets); } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('create announcement url', $start); } return $rets; } function vbseo_member_url ($userid, $username = '', $avatar = false) { global $g_cache; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } if ((!$userid AND $username)) { $tmpuser = &$g_cache['usernm'][$username]; } else { $tmpuser = &$g_cache['user'][$userid]; } if (!$tmpuser['seoname']) { if ($username) { $tmpuser['username'] = $username; } $tmpuser['seoname'] = vbseo_filter_text ($tmpuser['username'], null, false, true); $replace = array ('%user_id%' => $tmpuser['userid'], '%user_name%' => $tmpuser['seoname']); $tmpuser['memberurl'] = str_replace (array_keys ($replace), $replace, VBSEO_URL_MEMBER); if (!VBSEO_STRIP_SIDS) { $tmpuser['memberurl'] = vbseo_addsessionhash ($tmpuser['memberurl']); } $tmpuser['avatarurl'] = str_replace (array_keys ($replace), $replace, VBSEO_AVATAR_PREFIX . VBSEO_URL_AVATAR); if (!VBSEO_STRIP_SIDS) { $tmpuser['avatarurl'] = vbseo_addsessionhash ($tmpuser['avatarurl']); } } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('create member url', $start); } return ($avatar ? $tmpuser['avatarurl'] : $tmpuser['memberurl']); } function vbseo_forum_url ($forumid, $page = 0, $special_format = '') { global $g_cache; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } if ((VBSEO_FORUMLINK_DIRECT AND $g_cache['forum'][$forumid]['link'])) { return $g_cache['forum'][$forumid]['link']; } if (!$g_cache['forum'][$forumid]['seotitle']) { $g_cache['forum'][$forumid]['seotitle'] = vbseo_filter_text ($g_cache['forum'][$forumid]['title']); } $replace = array ('%forum_id%' => $forumid, '%forum_title%' => $g_cache['forum'][$forumid]['seotitle'], '%forum_path%' => $g_cache['forum'][$forumid]['path'], '%forum_page%' => $page); $rets = str_replace (array_keys ($replace), $replace, ($special_format ? $special_format : ($page <= 1 ? VBSEO_URL_FORUM : VBSEO_URL_FORUM_PAGENUM))); if (!VBSEO_STRIP_SIDS) { $rets = vbseo_addsessionhash ($rets); } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('create forum url', $start); } return $rets; } function vbseo_memberlist_url ($letter = '', $page = 1) { if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } if (!$page) { $page = 1; } if ($letter == '%23') { $letter = '0'; } $replace = array ('%letter%' => strtolower ($letter), '%page%' => (int)$page); $url = VBSEO_URL_MEMBERLIST; if ($letter != '') { $url = VBSEO_URL_MEMBERLIST_LETTER; } if (($letter == '' AND 1 < $page)) { $url = VBSEO_URL_MEMBERLIST_PAGENUM; } $rets = str_replace (array_keys ($replace), $replace, $url); if (!VBSEO_STRIP_SIDS) { $rets = vbseo_addsessionhash ($rets); } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('create memberlist url', $start); } return $rets; } function vbseo_get_next_thread ($threadid, $older) { global $g_cache; $thread = $g_cache['thread'][$threadid]; $db = vbseo_get_db (); $getnextoldest = $db->query_first (' SELECT t.forumid, t.threadid, ' . (VBSEO_GET_THREAD_TITLES ? 't.title, ' : '') . 't.replycount, t.lastposter, 1 lastpostid, t.lastpost FROM ' . TABLE_PREFIX . 'thread AS t LEFT JOIN ' . TABLE_PREFIX . ('' . 'deletionlog AS deletionlog ON(deletionlog.primaryid = t.threadid AND type = \'thread\') WHERE forumid = ' . $thread['forumid'] . ' AND lastpost ') . ($older ? '<' : '>') . ('' . ' ' . $thread['lastpost'] . ' AND visible = 1 AND open <> 10 AND deletionlog.primaryid IS NULL ORDER BY lastpost ') . ($older ? 'DESC' : '') . ' LIMIT 1 '); $getnextoldest['seotitle'] = vbseo_filter_replace_text ($getnextoldest['title']); $g_cache['thread'][$getnextoldest['threadid']] = $getnextoldest; return $getnextoldest; } function vbseo_bbarray_cookie ($cookiename, $id) { global $_COOKIE; global $bbuserinfo; $cookie_name = $bbuserinfo['cprefix'] . $cookiename; $cookie = $_COOKIE['' . $cookie_name]; if (get_magic_quotes_gpc ()) { $cookie = stripslashes ($cookie); } if (isset ($cookie)) { if (VBSEO_VB35X) { $cookie = str_replace (array ('.', '-', '_'), array ('"', ':', ';'), $cookie); } else { $cookie = str_replace (array ('-', '_', 'x', 'y'), array ('{', '}', ':', ';'), $cookie); } if (!$uncookie = @unserialize ($cookie)) { $cookie = substr ($cookie, 32); $uncookie = @unserialize ($cookie); } $cookie = $uncookie[$id]; } return $cookie; } function vbseo_get_last_post ($threadid) { $db = vbseo_get_db (); $postarr = $db->query_first (' SELECT MAX(postid) AS postid FROM ' . TABLE_PREFIX . 'post AS post WHERE threadid = ' . intval ($threadid) . ' AND visible = 1 LIMIT 1 '); return $postarr['postid']; } function vbseo_get_new_post ($threadid) { global $bbuserinfo; global $vboptions; global $g_cache; $db = vbseo_get_db (); $lvisit = $bbuserinfo['lastvisit']; if (($vboptions['threadmarking'] AND $bbuserinfo['userid'])) { $threadinfo = $db->query_first ($q = ' SELECT threadread.readtime AS threadread, forumread.readtime AS forumread FROM ' . TABLE_PREFIX . 'thread AS thread LEFT JOIN ' . TABLE_PREFIX . 'threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = ' . $bbuserinfo['userid'] . ') LEFT JOIN ' . TABLE_PREFIX . 'forumread AS forumread ON (forumread.forumid = thread.forumid AND forumread.userid = ' . $bbuserinfo['userid'] . ('' . ') WHERE thread.threadid = \'' . $threadid . '\' ')); $lvisit = max ($threadinfo['threadread'], $threadinfo['forumread']); } else { if ($lvisit < $tview = vbseo_bbarray_cookie ('thread_lastview', $threadid)) { $lvisit = $tview; } } $postarr = $db->query_first ($q = ' SELECT MIN(postid) AS postid FROM ' . TABLE_PREFIX . ('' . 'post WHERE threadid = ' . $threadid . ' AND visible = 1 AND dateline > ') . intval ($lvisit) . ' LIMIT 1 '); return ($postarr['postid'] ? $postarr['postid'] : vbseo_get_last_post ($threadid)); } function get_post_thread_info ($ids, $implicit = false) { global $g_cache; global $find_postthreads; global $bbuserinfo; if (!is_array ($ids)) { $ids = array ($ids); } $lookupids = array (); foreach ($ids as $id) { if ((isset ($g_cache['post'][$id]) AND !$implicit)) { continue; } $g_cache['post'][$id] = array (); $lookupids[] = $id; } if (empty ($lookupids)) { return array (); } $db = vbseo_get_db (); $rid = $db->query ($q = ' select count(*) as preposts,p1.postid,t.threadid, t.title from ' . TABLE_PREFIX . 'thread t, ' . TABLE_PREFIX . 'post p1, ' . TABLE_PREFIX . 'post p2 LEFT JOIN ' . TABLE_PREFIX . 'deletionlog AS deletionlog ON(deletionlog.primaryid = p2.postid AND type = \'post\') where p1.postid in (' . join (',', $lookupids) . ') AND deletionlog.primaryid IS NULL AND p1.threadid=t.threadid AND ( p2.threadid=t.threadid AND p2.visible=1 AND p2.dateline ' . ($bbuserinfo['postorder'] == 0 ? '<=' : '>=') . ' p1.dateline ) group by p1.postid '); $postids = array (); if ($rid) { while ($post = @mysql_fetch_assoc ($rid)) { $g_cache['post'][$post['postid']] = $post; $find_postthreads[] = $post['threadid']; } } $arr = array (); foreach ($ids as $id) { $arr[$id] = $g_cache['post'][$id]; } return $arr; } function vbseo_close_db () { $vbseo_DB_site = &$_SERVER['crawlDB']; if (isset ($vbseo_DB_site)) { $vbseo_DB_site->close (); } } function vbseo_get_db () { $vbseo_DB_site = &$_SERVER['crawlDB']; if (isset ($vbseo_DB_site)) { return $vbseo_DB_site; } $vbseo_DB_site = new vbseoDB (); include dirname (__FILE__) . '/config.php'; if (isset ($config['Database'])) { $dbname = $config['Database']['dbname']; $tableprefix = $config['Database']['tableprefix']; $servername = $config['MasterServer']['servername']; $dbusername = $config['MasterServer']['username']; $dbpassword = $config['MasterServer']['password']; $usepconnect = $config['MasterServer']['usepconnect']; } $vbseo_DB_site->connect ($servername, $dbusername, $dbpassword, $usepconnect, $tableprefix); $vbseo_DB_site->select_db ($dbname); return $vbseo_DB_site; } function get_forum_announcement ($id) { global $vboptions; global $g_cache; global $vbseo_precache; global $usercache; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } $ids = (is_array ($id) ? $id : array ($id)); if (isset ($vbseo_precache['annoncements'])) { foreach ($vbseo_precache['annoncements'] as $ann) { foreach ($ids as $fid) { $g_cache['forum'][$fid]['announcement'][$ann['announcementid']] = $ann['title']; $usercache[$ann['userid']] = array ('userid' => $ann['userid'], 'username' => $ann['username']); } } return null; } $db = vbseo_get_db (); $idlist = ''; $i = 0; while ($i < count ($ids)) { $idlist .= ($i ? ',' : '') . $ids[$i]; $pl = $g_cache['forum'][$ids[$i]]['parentlist']; if ($pl) { $idlist .= ',' . $pl; } ++$i; } $rid = $db->query ($q = ' SELECT forumid,announcementid,title FROM ' . TABLE_PREFIX . 'announcement AS announcement WHERE startdate <= ' . (time () - $vboptions['hourdiff']) . ' AND enddate >= ' . (time () - $vboptions['hourdiff']) . ' AND forumid IN (' . $idlist . ',-1) ORDER BY startdate DESC'); if ($rid) { while ($arr = @mysql_fetch_assoc ($rid)) { $fid = $arr['forumid']; $i = 0; while ($i < count ($ids)) { if (isset ($g_cache['forum'][$ids[$i]])) { $forum = &$g_cache['forum'][$ids[$i]]; if ((($fid == 0 - 1 OR $ids[$i] == $fid) OR preg_match ('#\\b' . $fid . '\\b#', $forum['parentlist']))) { $forum['announcement'][$arr['announcementid']] = $arr['title']; } } ++$i; } } } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('get announcement info', $start); } return $forum['announcement']; } function get_poll_info ($ids) { global $g_cache; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } if (!is_array ($ids)) { $ids = array ($ids); } global $pollinfo; if ($pollinfo) { $g_cache['polls'][$pollinfo['pollid']] = $pollinfo; $ids = array_diff ($ids, array ($pollinfo['pollid'])); } if ($g_cache['polls']) { $ids = array_diff ($ids, array_keys ($g_cache['polls'])); } if (!empty ($ids)) { $db = vbseo_get_db (); $rid = $db->query ($q = ' SELECT pollid, question FROM ' . TABLE_PREFIX . 'poll WHERE pollid IN (' . implode (',', $ids) . ')'); if ($rid) { while ($arr = @mysql_fetch_assoc ($rid)) { $g_cache['polls'][$arr['pollid']] = $arr; } } } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('get poll info', $start); } } function get_forum_info ($implicit = false) { global $g_cache; global $usercache; global $find_user_names; global $find_forum_last; global $forumcache; global $threadcache; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } $f_allow = (!$find_forum_last OR $forumcache[$find_forum_last[0]]['lastposter']); if ((empty ($g_cache['forum']) OR ($implicit AND $f_allow))) { $g_cache['forum'] = array (); if ((is_array ($forumcache) AND $f_allow)) { foreach ($forumcache as $forum_id => $arr) { $arr['parentlist'] = substr ($arr['parentlist'], 0, 0 - 3); $g_cache['forum'][$arr['forumid']] = $arr; } } else { $db = vbseo_get_db (); $rid = $db->query ('select forumid' . (VBSEO_GET_FORUM_TITLES ? ', title' : '') . ', parentlist, lastpost, lastposter, daysprune from ' . TABLE_PREFIX . 'forum'); if ($rid) { while ($arr = @mysql_fetch_assoc ($rid)) { $arr['parentlist'] = substr ($arr['parentlist'], 0, 0 - 3); $g_cache['forum'][$arr['forumid']] = $arr; } } } $forumids = array_keys ($g_cache['forum']); foreach ($forumids as $forumid) { $forum = &$g_cache['forum'][$forumid]; if (($forum['lastthreadid'] AND !in_array (THIS_SCRIPT, array ('showthread', 'printthread', 'showpost')))) { $threadcache[$forum['lastthreadid']] = array ('threadid' => $forum['lastthreadid'], 'title' => $forum['lastthread'], 'forumid' => $forumid, 'lastposter' => $forum['lastposter']); } if ((!defined ('VBSEO_GET_FORUM_PATH') OR !VBSEO_GET_FORUM_PATH)) { continue; } $parentlist = array_reverse (explode (',', $forum['parentlist'])); $forum['patharr'] = array (); $i = 0; while ($id = $parentlist[$i]) { if (!$g_cache['forum'][$forumid]['seotitle']) { $g_cache['forum'][$id]['seotitle'] = vbseo_filter_text ($g_cache['forum'][$id]['title']); } $replace = array ('%forum_id%' => $id, '%forum_title%' => $g_cache['forum'][$id]['seotitle']); $forum['patharr'][] = str_replace (array_keys ($replace), $replace, VBSEO_FORUM_TITLE_BIT); ++$i; } $forum['path'] = @join ('/', $forum['patharr']); $children = array (); foreach ($g_cache['forum'] as $forum2) { if (strpos ('' . ',' . $forum2['parentlist'] . ',', '' . ',' . $forumid . ',') !== false) { $children[] = $forum2['forumid']; continue; } } $forum['childlist'] = join (',', $children); } } foreach ($g_cache['forum'] as $forumid => $arr) { if ((($arr['lastposter'] AND $find_forum_last) AND in_array ($arr['forumid'], $find_forum_last))) { $find_user_names[] = $arr['lastposter']; continue; } } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('get forum info', $start); } if (isset ($id)) { return $g_cache['forum'][$id]; } return $g_cache['forum']; } function get_attachments_info ($ids) { global $g_cache; global $find_postthread_ids; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } if (!is_array ($ids)) { $ids = array ($ids); } global $postattach; if ($postattach) { foreach ($postattach as $pid => $attarr) { if ($attarr) { foreach ($attarr as $id => $arr) { $g_cache['attach'][$id] = $arr; $find_postthread_ids[] = $arr['postid']; } continue; } } } $lookupids = array (); foreach ($ids as $id) { if (isset ($g_cache['attach'][$id])) { continue; } $g_cache['attach'][$id] = array (); $lookupids[] = $id; } if (empty ($lookupids)) { return array (); } $db = vbseo_get_db (); $rid = $db->query ($q = ' select at.attachmentid,at.filename,at.postid from ' . TABLE_PREFIX . 'attachment at where at.attachmentid IN (' . implode (',', $lookupids) . ') '); if ($rid) { while ($att = @mysql_fetch_assoc ($rid)) { $g_cache['attach'][$att['attachmentid']] = $att; $find_postthread_ids[] = $att['postid']; } } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('get attachments info', $start); } } function get_thread_info ($ids) { global $g_cache; global $find_thread_last; global $find_user_names; if (defined ('VBSEO_DEBUG')) { $start = vbseo_mcrtime (); } if (!is_array ($ids)) { $ids = array ($ids); } $lookupids = array (); foreach ($ids as $id) { if ($id) { if (isset ($g_cache['thread'][$id])) { continue; } $g_cache['thread'][$id] = array (); $lookupids[] = $id; continue; } } if (!empty ($lookupids)) { $where = array (''); $db = vbseo_get_db (); $rid = $db->query (' select t.forumid, t.threadid, ' . (VBSEO_GET_THREAD_TITLES ? 't.title, ' : '') . 't.replycount, t.lastposter, 1 lastpostid, lastpost from ' . TABLE_PREFIX . 'thread t where t.threadid in (' . join (',', $lookupids) . ') '); if ($rid) { while ($thread = @mysql_fetch_assoc ($rid)) { $thread['seotitle'] = vbseo_filter_replace_text ($thread['title']); $g_cache['thread'][$thread['threadid']] = $thread; if (($find_thread_last AND in_array ($thread['threadid'], $find_thread_last))) { $find_user_names[] = $thread['lastposter']; continue; } } } } $arr = array (); foreach ($ids as $id) { $arr[$id] = $g_cache['thread'][$id]; } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('get thread info', $start); } return $arr; } function get_user_info ($userids, $find_user_names = array ()) { global $g_cache; $db = vbseo_get_db (); $whr = $whr2 = ''; if (!empty ($userids)) { $whr .= 'u.userid in(\'' . implode ('\',\'', $userids) . '\')'; } if (!empty ($find_user_names)) { $unw = ''; foreach ($find_user_names as $uind => $uname) { $unw .= ($unw ? ',' : '') . '\'' . str_replace ('\'', '\\\'', $uname) . '\''; } $whr2 = '' . 'u.username in(' . $unw . ')'; } $preq = 'select u.userid, u.username from ' . TABLE_PREFIX . 'user u where '; if ('3' < $db->mysql_version[0]) { $rid = $db->query (($whr ? '' . '( ' . $preq . ' ' . $whr . ' )' : '') . (($whr AND $whr2) ? ' UNION ' : '') . ($whr2 ? '' . '( ' . $preq . ' ' . $whr2 . ' )' : '')); } else { $rid = $db->query ($preq . $whr . (($whr AND $whr2) ? ' OR ' : '') . $whr2); } if ($rid) { while ($arr = @mysql_fetch_assoc ($rid)) { $g_cache['user'][$arr['userid']] = $arr; $g_cache['usernm'][$arr['username']] = $arr; } } $db->free_result ($rid); } function vbseo_back_customurl ($url) { global $vbseo_crules_back; if (!isset ($vbseo_crules_back)) { $vbseo_crules_back = array (); foreach ($_SERVER['vbseo_custom_rules'] as $k => $v) { $v = str_replace ('[NF]', '', $v); preg_match_all ('#\\$(\\d+)#', $v, $vm); preg_match_all ('#\\(.*?\\)#', $k, $km); $v = preg_replace ('#\\$(\\d+)#e', '$km[0][\\1-1]', str_replace ('\\$', '$', preg_quote ($v, '#'))); $ki = 0; $k = preg_replace ('#\\(.*?\\)#e', '"$".$vm[1][$ki++]', stripslashes ($k)); $k = preg_replace ('#.[\\*\\+]\\??#', '', $k); if ($k[0] == '^') { $v = '^' . $v; $k = substr ($k, 1); } if ($k[strlen ($k) - 1] == '$') { $v = $v . '$'; $k = substr ($k, 0, strlen ($k) - 1); } $vbseo_crules_back['#' . $v . '#'] = $k; } } $newurl = preg_replace (array_keys ($vbseo_crules_back), $vbseo_crules_back, $url); if ($newurl != $url) { return $newurl; } return ''; } function vbseo_any_url ($url) { $re_url = vbseo_replace_urls ('', $url); return $re_url; } function vbseo_replace_urls ($preurl, $url, $mid_attribs = '', $posturl = '', $intag = '', $closetag = '') { global $vboptions; global $vbseo_notop_url; global $g_replace_cache; global $g_cache; global $vbseo_crules; global $tempusagecache; global $vbulletin; $preurl = str_replace ('\\"', '"', $preurl); $posturl = str_replace ('\\"', '"', $posturl); $intag = str_replace ('\\"', '"', $intag); $closetag = str_replace ('\\"', '"', $closetag); $url = preg_replace ('#([^:]/)/+#', '$1', $url); $par_str = ''; if (isset ($g_replace_cache[$url])) { return $preurl . $g_replace_cache[$url] . $posturl . $intag . $closetag; } if ($url[0] == '#') { return $preurl . ((VBSEO_BASEDEPTH AND defined ('VBSEO_PREPROCESSED')) ? VBSEO_TOPREL . VBSEO_REQURL : '') . $url . $posturl . $intag . $closetag; } $rn_q = $preurl[strlen ($preurl) - 1]; if ($rn_q != '\'') { $rn_q = '"'; } $relnofollow = 'rel=' . $rn_q . 'nofollow' . $rn_q; if (VBSEO_ALLOW_REL_NOVBSEO) { if (strstr (strtolower ($mid_attribs), 'rel="novbseo"')) { return $preurl . $url . $posturl . $intag . $closetag; } } if (((substr ($url, 0, 7) == 'mailto:' OR substr ($url, 0, 11) == 'javascript:') OR ((strstr ($url, '://') AND !strstr ($url, $_SERVER['HTTP_HOST'])) AND !strstr ($url, $vboptions['bburl2'])))) { preg_match ('#(([^\\.]+\\.)?[^\\.]+)$#', $_SERVER['HTTP_HOST'], $hmatch); $vbseo_ext_url = !preg_match ('#^[^/]*://[^/]*' . preg_quote ($hmatch[1], '#') . '#', $url); if (((VBSEO_NOFOLLOW_EXTERNAL AND $vbseo_ext_url) AND (!VBSEO_DOMAINS_WHITELIST OR !preg_match ('#' . VBSEO_DOMAINS_WHITELIST . '#', $url)))) { if (!strstr ($preurl . $mid_attribs . $posturl, $relnofollow)) { $preurl = preg_replace ('#(bf_ugp_forumpermissions['canview']) AND $f_perms & (defined ('CANVIEWOTHERS') ? CANVIEWOTHERS : $vbulletin->bf_ugp_forumpermissions['canviewothers']))); if (((strstr ($preurl, 'href') AND !$is_public) AND $vbseo_ext_url)) { $url = $vboptions['bburl2'] . '/' . VBSEO_REDIRECT_URI . '?redirect=' . urlencode (html_entity_decode ($url)); } } return $preurl . $url . $posturl . $intag . $closetag; } list ($url_script, $url_append) = explode ('?', $url, 2); if (($_SERVER['vbseo_custom_rules'] AND !isset ($vbseo_crules))) { $vbseo_crules = array (); foreach ($_SERVER['vbseo_custom_rules'] as $k => $v) { if ($k) { $vbseo_crules['#' . str_replace (array ('#', '&'), array ('\\#', '&(?:amp;)?'), $k) . '#'] = $v; continue; } } } if (!preg_match ('#^ $url, 'new' => $newurl, 'is_vbdir' => $is_vbdir); } return $preurl . $newurl . $posturl . $intag . $closetag; } function vbseo_find_ids (&$newtext) { global $find_postthread_ids; global $find_thread_ids; global $find_user_ids; global $find_poll_ids; global $find_attachment_ids; global $find_thread_last; global $find_forum_last; global $find_user_names; global $find_announcements; global $vboptions; $find_postthread_ids = $find_user_names = $find_thread_ids = $find_user_ids = $find_thread_last = $find_forum_last = $find_attachment_ids = $find_poll_ids = array (); $find_announcements = false; $matchpre = (isset ($GLOBALS['VBSEO_REWRITE_TEXTURLS']) ? '' : '[\'"](?:' . $vboptions['bburl2'] . '/?|' . $vboptions['cutbburl'] . '/?)?'); $matchpre2 = ''; if (VBSEO_REWRITE_ARCHIVE_URLS) { if (preg_match_all ('#\\bt-(\\d+)\\.html#', $newtext, $tmatch)) { $find_thread_ids = $tmatch[1]; } } if (VBSEO_REWRITE_MEMBERS) { if (preg_match_all ('#' . $matchpre2 . 'member\\.php\\?[^"]*?u(?:serid)?=([0-9]+)#', $newtext, $matches)) { $find_user_ids = $matches[1]; } } if (VBSEO_REWRITE_ANNOUNCEMENT) { if (preg_match_all ('#' . $matchpre2 . 'announcement\\.php\\?[^"]*?f(?:orumid)?=([0-9]+)#', $newtext, $matches)) { $find_announcements = $matches[1]; } } if (VBSEO_REWRITE_ATTACHMENTS) { if (preg_match_all ('#' . $matchpre2 . 'attachment\\.php\\?[^"]*?attachmentid=([0-9]+)#', $newtext, $matches)) { $find_attachment_ids = $matches[1]; } } if (VBSEO_REWRITE_THREADS) { if (preg_match_all ('#' . $matchpre . 'showthread\\.php\\?[^"]*' . VBSEO_POSTID_URI . '=([0-9]+)#', $newtext, $matches)) { $find_postthread_ids = $matches[1]; } } if (VBSEO_REWRITE_POLLS) { if (preg_match_all ('#' . $matchpre2 . 'poll\\.php\\?[^"]*?' . VBSEO_ACTION_URI . '=showresults&.*?' . VBSEO_POLLID_URI . '=([0-9]+)#', $newtext, $matches)) { $find_poll_ids = $matches[1]; } } if (VBSEO_REWRITE_THREADS) { if (preg_match_all ('#' . $matchpre . '(?:show|print)thread\\.php\\?[^"]*?t(?:hreadid)?=([0-9]+)#', $newtext, $matches)) { $find_thread_ids = array_merge ($find_thread_ids, $matches[1]); } } if (VBSEO_REWRITE_MEMBERS) { if (preg_match_all ('#' . $matchpre2 . 'member\\.php\\?[^"]*?find=lastposter.*?t(?:hreadid)?=([0-9]+)#', $newtext, $matches)) { $find_thread_last = $matches[1]; $find_thread_ids = array_merge ($find_thread_ids, $find_thread_last); } } if (VBSEO_REWRITE_MEMBERS) { if (preg_match_all ('#' . $matchpre2 . 'member\\.php\\?[^"]*?find=lastposter.*?' . VBSEO_FORUMID_URI . '=([0-9]+)#', $newtext, $matches)) { $find_forum_last = array_merge ($find_forum_last, $matches[1]); } } if (VBSEO_REWRITE_AVATAR) { if (preg_match_all ('#' . $matchpre2 . 'image\\.php\\?[^"]*?' . VBSEO_USERID_URI . '=([0-9]+)#', $newtext, $matches)) { $find_user_ids = array_merge ($find_user_ids, $matches[1]); } } } function vbseo_get_options () { global $vboptions; global $bbuserinfo; global $vbulletin; global $g_cache; global $forumcache; global $threadcache; global $config; global $session; global $GAS_settings; if (!$vboptions) { if ((isset ($vbulletin) AND isset ($vbulletin->options))) { $vboptions = $vbulletin->options; $forumcache = $vbulletin->forumcache; $session = $vbulletin->session->vars; } else { $db = vbseo_get_db (); $rid = $db->query ('select data from ' . TABLE_PREFIX . 'datastore where title in (\'options\', \'GAS_settings\') order by title desc'); $dstore = @mysql_fetch_assoc ($rid); $vboptions = @unserialize ($dstore['data']); $dstore = @mysql_fetch_assoc ($rid); $GAS_settings = @unserialize ($dstore['data']); $db->free_result ($rid); } } $vboptions['bburl2'] = preg_replace ('#/+$#', '', $vboptions['bburl']); if ($_SERVER['HTTPS']) { $vboptions['bburl2'] = str_replace ('http:', 'https:', $vboptions['bburl2']); } $vboptions['cutbburl'] = preg_replace ('#^https?://[^/]+(.*)$#', '$1', $vboptions['bburl2']); $vboptions['relbburl'] = (VBSEO_USE_HOSTNAME_IN_URL ? $vboptions['bburl2'] : $vboptions['cutbburl']); $g_cache['post'] = ($GLOBALS['itemids'] ? $GLOBALS['itemids'] : ($GLOBALS['postcache'] ? $GLOBALS['postcache'] : array ())); if ($GLOBALS['getlastpost']['postid']) { $g_cache['post'][$GLOBALS['getlastpost']['postid']] = $GLOBALS['getlastpost']; } $url = $vboptions['forumhome'] . '.php'; if (($url == 'index.php' AND VBSEO_HP_FORCEINDEXROOT)) { $url = ''; } @define ('VBSEO_HOMEPAGE', $url); if ($threadcache) { foreach ($threadcache as $threadid => $tar) { if ($tar['firstpostid']) { $g_cache['post'][$tar['firstpostid']] = array ('threadid' => $threadid, 'postid' => $tar['firstpostid']); continue; } } } if ((!isset ($bbuserinfo) OR !$bbuserinfo['userid'])) { if ($vbulletin) { $bbuserinfo = $vbulletin->userinfo; } $bbuserinfo['cprefix'] = $cprefix = (VBSEO_VB35X ? $config['Misc']['cookieprefix'] : $GLOBALS['cookieprefix']); $cvisit = @intval ($_COOKIE[$cprefix . 'lastvisit']); $bbuserinfo['lastvisit'] = ($cvisit ? $cvisit : time ()); $bbuserinfo['userid'] = $_COOKIE[$cprefix . 'userid']; } $bbuserinfo['isadmin'] = $bbuserinfo['usergroupid'] == 6; vbseo_check_confirmation (); } function vbseo_check_confirmation () { return null; } function make_crawlable (&$newtext) { if ((!VBSEO_ENABLED AND !isset ($_COOKIE['VBSEO_ON']))) { return $newtext; } if ((VBSEO_IGNOREPAGES AND preg_match ('#(' . VBSEO_IGNOREPAGES . ')#', VBSEO_REQURL))) { return $newtext; } define ('VBSEO_PROCESS', true); if (VBSEO_SUPPRESS_ERRORS) { error_reporting (0); } restore_error_handler (); if (defined ('VBSEO_DEBUG')) { $starttime = vbseo_mcrtime (true); } global $vboptions; global $_COOKIE; global $HTTP_COOKIE_VARS; global $g_cache; global $seo_preg_replace; global $seo_links_replace; global $tempusagecache; global $threadcache; global $usercache; if (isset ($_COOKIE['VBSEO_EXPOSE'])) { header ('X-Processed-By: vBSEO ' . VBSEO_VERSION2 . ' (http://www.vbseo.com)'); } $g_cache = $_SERVER['gcache']; if (!$g_cache) { $g_cache = array ('forum' => array (), 'thread' => array (), 'post' => array (), 'user' => array (), 'usernm' => array ()); } vbseo_get_options (); if (((defined ('VBSEO_EXPIRED_LICENSE') OR isset ($_COOKIE['VBSEO_OFF'])) OR isset ($_GET['VBSEO_OFF']))) { return $newtext; } if (VBSEO_CODE_CLEANUP) { if (defined ('VBSEO_DEBUG')) { $GLOBALS['vbseo_codelen1'] = strlen ($newtext); $GLOBALS['vbseo_codelen1gz'] = strlen (gzencode ($newtext, $vboptions['gziplevel'])); $start = vbseo_mcrtime (); } $newtext = preg_replace (array ('#>\\s+<#s', '#(]*?>[^<]*?#s', '# <', '\\1js', '', '(.*?)#s', $pbits, $post_match); if (!$post_match) { preg_match ('#post_message_.*?>(.*?)#s', $pbits, $post_match); } $desc_content = str_replace ('>Quote:<', '', $post_match[1]); $desc_content = preg_replace ('#
Originally Posted by.*?
#', '', $desc_content); $vbseo_fp = $desc_content = trim (strip_tags ($desc_content)); } if ((VBSEO_REWRITE_META_KEYWORDS AND $tbits = $GLOBALS['threadinfo']['title'])) { if (VBSEO_FILTER_STOPWORDS != 0) { $tbits = preg_replace ('#\\b(' . VBSEO_STOPWORDS . ')\\b#is', '', $tbits); } preg_match_all ('#([a-zA-Z0-9_\\x80-\\xff]+)#s', $tbits, $ptext); $kw_content = implode (',', $ptext[1]); } } } if ((VBSEO_REWRITE_META_KEYWORDS AND $kw_content)) { $kw_content = strip_tags ($kw_content); $newtext = preg_replace ('#( $GLOBALS['threadinfo']['title'], '[forum_description]' => $GLOBALS['foruminfo']['description'], '[forum_title]' => $GLOBALS['foruminfo']['title'], '[bb_title]' => $vboptions['bbtitle'], '[default_keywords]' => $vboptions['keywords']); $vbseo_pn = 0; foreach ($_SERVER['vbseo_relev_replace'] as $rr) { ++$vbseo_pn; $rr = str_replace (array_keys ($vbseo_rrepl), array_values ($vbseo_rrepl), $rr); if (($pbits = $GLOBALS['postbits'] AND preg_match ('#\\[first_post_(\\d+)_words\\]#', $rr, $fp_m))) { if (!$vbseo_fp) { preg_match ('#(.*?)#s', $pbits, $post_match); if (!$post_match) { preg_match ('#post_message_.*?>(.*?)#s', $pbits, $post_match); } $vbseo_fp = str_replace ('>Quote:<', '', $post_match[1]); $vbseo_fp = preg_replace ('#
Originally Posted by.*?
#', '', $vbseo_fp); $vbseo_fp = trim (strip_tags ($vbseo_fp)); $vbseo_fp = preg_replace ('#[\\s\\"]+#s', ' ', $vbseo_fp); } if ($vbseo_fp) { $rr = str_replace ('[first_post_' . $fp_m[1] . '_words]', preg_replace ('#((\\w+\\W+){' . $fp_m[1] . '}).*$#s', '\\1', $vbseo_fp), $rr); } } $newtext = str_replace ('', $rr, $newtext); } if (defined ('VBSEO_DEBUG')) { vbseo_parttime ('relevant replacements', $start); } } if ((VBSEO_ADD_ANALYTICS_CODE AND VBSEO_ANALYTICS_CODE)) { $newtext = preg_replace ('#()#is', ' ' . '\\1', $newtext, 1); } if ((VBSEO_LINK AND $GLOBALS['bbuserinfo']['isadmin'])) { $config_link = '
Back to vBSEO Config Panel
'; $newtext = preg_replace ('#()#is', '\\1' . $config_link, $newtext, 1); } if (defined ('VBSEO_DEBUG')) { $GLOBALS['vbseo_codelen3'] = strlen ($newtext); $GLOBALS['vbseo_codelen3gz'] = strlen (gzencode ($newtext, $vboptions['gziplevel'])); $enhack = vbseo_mcrtime (true) - $starttime; $preruntime = max (0, $_SERVER['vb_start'] - $_SERVER['crawl_start']); if ($_SERVER['vb_start']) { $vbruntime = $starttime - $_SERVER['vb_start']; } else { preg_match ('/generated in ([0-9\\.]*)/i', $newtext, $rtm); $vbruntime = $rtm[1]; } $hacktime = $preruntime + $enhack; $urlsval = ''; $cun = 0; foreach ($_SERVER['crawl_urls'] as $cu) { $urlsval .= '' . ++$cun . '' . $cu['orig'] . '' . $cu['new'] . '' . ($cu['is_vbdir'] ? 'yes' : 'no') . ' '; } $qdesc = ''; $dbtime = 0; $i = 0; while ($i < count ($_SERVER['crawl_qh'])) { $val = $_SERVER['crawl_qh'][$i]; $dbtime += $val['time']; $dtrace = $val['bt']; $trc = ''; $di = 0; while (($di < count ($dtrace) AND $di < 3)) { $et = $dtrace[$di]; $trc .= ($et['function'] ? $et['function'] . '() in' : 'In') . ' ' . basename ($et['file']) . ' at ' . $et['line'] . '
'; ++$di; } $qdesc .= '
' . ($i + 1) . ': Executed in: ' . ($val['postproc'] ? 'postprocess' : 'preprocess (decomposition)') . ' Time: ' . sprintf ('%1.03f', $val['time']) . '
Affected/selected: ' . $val['ra'] . ' / ' . $val['rs'] . '
' . $trc . '

'; ++$i; } $hparts = ''; $htot = 0; ksort ($_SERVER['crawl_parts']); foreach ($_SERVER['crawl_parts'] as $pk => $pv) { $hparts .= ' ' . $pk . ' ' . sprintf ('%.5f', $pv) . ' (' . sprintf ('%.2f', $pv / $hacktime * 100) . '%) , ' . ($_SERVER['crawl_parts_cnt'][$pk] + 0) . ' calls '; $htot += $pv / $hacktime; } if ((($stats = @exec ('uptime 2>&1') AND trim ($stats) != '') AND preg_match ('' . '#: ([\\d.,]+),?\\s+([\\d.,]+),?\\s+([\\d.,]+)$#', $stats, $regs))) { $regs[1] = number_format ($regs[1], 2); $regs[2] = number_format ($regs[2], 2); $regs[3] = number_format ($regs[3], 2); $loadavg = 'Load average: ' . $regs[1] . ' ' . $regs[2] . ' ' . $regs[3]; } else { $loadavg = ''; } $fc = @implode ('', @file (__FILE__)); if (strstr ($fc, '@' . 'Zend')) { $vtype = 'Zend'; } else { if (strstr ($fc, 'ionCube' + ' Loader')) { $vtype = 'Ioncube'; } else { $vtype = 'Unencoded'; } } $debuginfo = '
vBSEO hack v.' . VBSEO_VERSION2 . ' (' . VBSEO_SUBVERSION . ': ' . date ('Y-m-d', VBSEO_SUBDATE) . ') [' . $vtype . '] , last updated @ ' . date ('Y-m-d H:i:s', filemtime (__FILE__)) . '
' . $loadavg . ' ' . $hparts . '
Main runing times (in seconds)
vB runtime: ' . sprintf ('%.5f', $vbruntime) . '
Total hack runtime: ' . sprintf ('%.5f', $enhack + $preruntime) . ' (' . sprintf ('%.2f', ($enhack + $preruntime) / $vbruntime * 100) . '% to vB)
   URL decomposition runtime: ' . sprintf ('%.5f', $preruntime) . ' (' . sprintf ('%.2f', $preruntime / $vbruntime * 100) . '% to vB)
   Output transform runtime: ' . sprintf ('%.5f', $enhack) . ' (' . sprintf ('%.2f', $enhack / $vbruntime * 100) . '% to vB)
   DB queries runtime: ' . sprintf ('%.5f', $dbtime) . ' (' . sprintf ('%.2f', $dbtime / $vbruntime * 100) . '% to vB)
Hack parts times (in seconds)
Content lengths (in Kbytes)
Original vB output: ' . sprintf ('%.1f (%.2f%%)', $GLOBALS['vbseo_codelen1'] / 1024, $GLOBALS['vbseo_codelen1'] * 100 / $GLOBALS['vbseo_codelen1']) . '
gzipped: ' . sprintf ('%.1f (%.2f%%)', $GLOBALS['vbseo_codelen1gz'] / 1024, $GLOBALS['vbseo_codelen1gz'] * 100 / $GLOBALS['vbseo_codelen1gz']) . '
After cleanup : ' . sprintf ('%.1f (%.2f%%)', $GLOBALS['vbseo_codelen2'] / 1024, $GLOBALS['vbseo_codelen2'] * 100 / $GLOBALS['vbseo_codelen1']) . '
gzipped: ' . sprintf ('%.1f (%.2f%%)', $GLOBALS['vbseo_codelen2gz'] / 1024, $GLOBALS['vbseo_codelen2gz'] * 100 / $GLOBALS['vbseo_codelen1gz']) . '
After URL rewrite: ' . sprintf ('%.1f (%.2f%%)', $GLOBALS['vbseo_codelen3'] / 1024, $GLOBALS['vbseo_codelen3'] * 100 / $GLOBALS['vbseo_codelen1']) . '
gzipped: ' . sprintf ('%.1f (%.2f%%)', $GLOBALS['vbseo_codelen1gz'] / 1024, $GLOBALS['vbseo_codelen3gz'] * 100 / $GLOBALS['vbseo_codelen1gz']) . '
vB state
bburl: ' . $vboptions['bburl'] . '
VBSEO_TOPREL: ' . VBSEO_TOPREL . '
VBSEO_BASE: ' . VBSEO_BASE . '
VBSEO_BASEDEPTH: ' . VBSEO_BASEDEPTH . '
VBSEO_FN: ' . VBSEO_FN . '
VBSEO_RWDOCROOT: ' . VBSEO_RWDOCROOT . '
VBSEO_STRIP_SIDS: ' . VBSEO_STRIP_SIDS . '

DB Queries list (' . $_SERVER['crawl_qc'] . '):
' . $qdesc . '
URLs list (' . count ($_SERVER['crawl_urls']) . '):
' . $urlsval . '

'; $newtext = preg_replace ('#()#is', '\\1' . $debuginfo, $newtext, 1); } if (!isset ($GLOBALS['VBSEO_REWRITE_TEXTURLS'])) { vbseo_close_db (); vbseo_mem_cleanup (); } return $newtext; } class vbseodb { var $database = ''; var $link_id = 0; var $query_id = 0; var $own_link = 0; var $record = array (); function vbseodb () { if (defined ('VBSEO_DEBUG')) { $_SERVER['crawl_qc'] = 0; $_SERVER['crawl_qh'] = array (); } } function connect ($server, $user, $password, $usepconnect, $tableprefix = '') { global $vbulletin; global $DB_site; if (!defined (TABLE_PREFIX)) { define (TABLE_PREFIX, $tableprefix); } if (0 == $this->link_id) { if (((is_object ($vbulletin) AND isset ($vbulletin->db)) AND isset ($vbulletin->db->connection_read))) { $this->link_id = $vbulletin->db->connection_read; } else { if (isset ($DB_site)) { $this->link_id = $DB_site->link_id; } else { $this->own_link = 1; if ($usepconnect == 1) { $this->link_id = @mysql_pconnect ($server, $user, $password); } else { $this->link_id = @mysql_connect ($server, $user, $password); } } } if (!$this->link_id) { return false; } $this->mysql_version = mysql_get_server_info ($this->link_id); return true; } } function select_db ($database = '') { if ($database != '') { $this->database = $database; } mysql_select_db ($this->database, $this->link_id); } function query ($query_string) { if (defined ('VBSEO_DEBUG')) { $stime = explode (' ', microtime ()); } $this->query_id = @mysql_query ($query_string, $this->link_id); if (defined ('VBSEO_DEBUG')) { ++$_SERVER['crawl_qc']; $etime = explode (' ', microtime ()); $time = $etime[0] + $etime[1] - ($stime[0] + $stime[1]); $_SERVER['crawl_qh'][] = array ('query' => $query_string, 'ra' => mysql_affected_rows (), 'rs' => @mysql_num_rows ($this->query_id), 'time' => $time, 'postproc' => defined ('VBSEO_PROCESS'), 'bt' => debug_backtrace ()); } return $this->query_id; } function query_first ($query_string) { $query_id = $this->query ($query_string); $returnarray = $this->fetch_array ($query_id, $query_string); $this->free_result ($query_id); return $returnarray; } function free_result ($query_id) { mysql_free_result ($query_id); } function fetch_array ($query_id = -1, $query_string = '') { if ($query_id != 0 - 1) { $this->query_id = $query_id; } if (isset ($this->query_id)) { return $this->record = @mysql_fetch_array ($this->query_id); } return false; } function close () { if ($this->own_link) { mysql_close ($this->link_id); } } } function vbseo_http_query ($url) { ini_set ('default_socket_timeout', 5); $purl = parse_url ($url); if (!$purl['path']) { $purl['path'] = '/'; } $connsocket = @fsockopen ($purl['host'], 80, $errno, $errstr, 5); $start = 0; $timeout = 50; while ($start < $timeout) { ++$start; if ($connsocket) { $qstring = $purl['path']; if ((isset ($purl['query']) AND $purl['query'])) { $qstring .= '?' . $purl['query']; } $start = 100; $out = 'GET ' . $qstring . ' HTTP/1.0 '; $out .= 'Host: ' . $purl['host'] . ' '; $out .= 'Referer: http://' . $purl['host'] . '/ '; $out .= 'Connection: Close '; $inp = ''; fwrite ($connsocket, $out); while (!feof ($connsocket)) { $inp .= @fread ($connsocket, 4096); } fclose ($connsocket); continue; } } preg_match ('' . '#^(.*?) ? ? (.*)$#s', $inp, $hm); $headersstr = ($hm[1] ? $hm[1] : $inp); $headers = split (' ? ', $headersstr); list ($proto, $code) = sscanf ($headers[0], '%s %s'); $rt = $hm[2]; return $rt; } function vbseo_hit_log () { define ('VBSEO_SMDIR', dirname (__FILE__) . '/../vbseo_sitemap'); if (@include_once VBSEO_SMDIR . '/vbseo_sitemap_functions.php') { if (!file_exists (VBSEO_DAT_FOLDER_BOT)) { @mkdir (VBSEO_DAT_FOLDER_BOT); } if (file_exists (VBSEO_DAT_FOLDER_BOT)) { preg_match ('#(appie|jeeves|msnbot|googlebot|harvest|htdig|yahoo|linkwalker|lycos_|scooter|slurp|ia_archiver|netcraft)#i', $_SERVER['HTTP_USER_AGENT'], $botm); $hfilename = VBSEO_DAT_FOLDER_BOT . date ('Ymd') . '.log'; if (file_exists ($hfilename)) { $botdat = array (); $i = 0; while (($i < 5 AND !$botdat)) { $botdat = @unserialize (@implode ('', @file ($hfilename))); ++$i; } if (!$botdat) { return null; } } else { $botdat = array (); } $bscript = substr ($_SERVER['SCRIPT_NAME'], (strstr (VBSEO_BASE, VBSEO_TOPREL) ? min (strlen (VBSEO_BASE), strlen (VBSEO_TOPREL)) : strlen (VBSEO_BASE))); if (!$bscript) { $bscript = 'home'; } ++$botdat[$botm[1]]['total']; ++$botdat[$botm[1]][$bscript]; ++$botdat['all']['total']; ++$botdat['all'][$bscript]; $wr = serialize ($botdat); $pf = @fopen ($hfilename, 'w'); @fwrite ($pf, $wr); @fclose ($pf); } } } } ?>