Immortal |
01-29-2006 01:44 AM |
Quote:
Originally Posted by 10sion
Hey Immortal, I must say thanks for this great hack, it seams to be running great except for one minor thing.
It only SEOs the first thread in every forum... Have any idea why?
Example:
General Forum
>whoa new post! -thread
>who likes cheese? -thread
>sweet! -thread
It only rewrites the first thread (whoa new post!) and not the others. Any quick fix? Thanks a lot.
|
It's weird..Try overwritting your code in Plugin Manager->vRewrite under global_complete with this:
PHP Code:
if($vbulletin->options['vRewrite_on'])
{
if($vbulletin->options['vRewrite_forumrewrite'] == "2") {
#------------------------------
# Replace Forums
#------------------------------
$found = preg_match_all('#<a href="forumdisplay\.php\?f=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT forumid, title FROM " . TABLE_PREFIX . "forum WHERE forumid IN($ids)");
while($f = $vbulletin->db->fetch_array($res))
{
$title = urlize($f['title']);
$fid = $f['forumid'];
$title = str_replace("-","",$title);
$output = str_replace("<a href=\"forumdisplay.php?f=$fid\"", "<a href=\"siteforums/$title-$fid.html\"", $output);
}
}
}
#------------------------------
# Replace Forums
#------------------------------
$found = preg_match_all('#<a href="forumdisplay\.php\?f=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT forumid, title FROM " . TABLE_PREFIX . "forum WHERE forumid IN($ids)");
while($f = $vbulletin->db->fetch_array($res))
{
$title = urlize($f['title']);
$fid = $f['forumid'];
$output = str_replace("<a href=\"forumdisplay.php?f=$fid\"", "<a href=\"f-$title-$fid.html\"", $output);
}
}
if($vbulletin->options['vRewrite_memberrewrite'] == "2") {
#------------------------------
# Replace User
#------------------------------
$found = preg_match_all('#member\.php\?u=([0-9]+)#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE userid IN($ids)");
while($u = $vbulletin->db->fetch_array($res))
{
$username = urlize($u['username']);
$uid = $u['userid'];
$output = str_replace("member.php?u=$uid", "members/$username-$uid.html", $output);
}
}
}
#------------------------------
# Replace User
#------------------------------
$found = preg_match_all('#member\.php\?u=([0-9]+)#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE userid IN($ids)");
while($u = $vbulletin->db->fetch_array($res))
{
$username = urlize($u['username']);
$uid = $u['userid'];
$output = str_replace("member.php?u=$uid", "u-$username-$uid.html", $output);
}
}
#------------------------------
# Replace showthread.php?goto=newpost
#------------------------------
$found = preg_match_all('#<a href="showthread\.php\?goto=newpost&t=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT threadid, title, forumid FROM " . TABLE_PREFIX . "thread WHERE threadid IN($ids)");
while($n = $vbulletin->db->fetch_array($res))
{
$title = urlize($n['title']);
$tid = $n['threadid'];
$fid = $n['forumid'];
$output = str_replace("<a href=\"showthread.php?goto=newpost&t=$tid\"", "<a href=\"$title-$tid-newpost.html\"", $output);
}
}
#------------------------------
# Replace Last Post User (Forum)
#------------------------------
$found = preg_match_all('#<a href="member\.php\?find=lastposter&f=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT lastposter, forumid FROM " . TABLE_PREFIX . "forum WHERE forumid IN($ids)");
while($f = $vbulletin->db->fetch_array($res))
{
$lp = $f['lastposter'];
$lpidinfo = $vbulletin->db->query_first("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE username='$lp'");
$lp = urlize($lpidinfo['username']);
$lpid = $lpidinfo['userid'];
$fid = $f['forumid'];
$output = str_replace("<a href=\"member.php?find=lastposter&f=$fid\"", "<a href=\"u-$lp-$lpid.html\"", $output);
}
}
#------------------------------
# Replace Last Post User (Thread)
#------------------------------
$found = preg_match_all('#<a href="member\.php\?find=lastposter&t=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT lastposter, threadid FROM " . TABLE_PREFIX . "thread WHERE threadid IN($ids)");
while($f = $vbulletin->db->fetch_array($res))
{
$lp = $f['lastposter'];
$lpidinfo = $vbulletin->db->query_first("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE username='$lp'");
$lp = urlize($lpidinfo['username']);
$lpid = $lpidinfo['userid'];
$tid = $f['threadid'];
$output = str_replace("<a href=\"member.php?find=lastposter&t=$tid\"", "<a href=\"u-$lp-$lpid.html\"", $output);
}
}
#-----------------------------------
# DO NOT REMOVE OTHERWISE YOU
# WILL BE SENT A DMCA FOR COPYRIGHT
# INFRINGEMENT YOU MAY NOT USE THIS
# PLUGIN WITHOUT THIS LINE OF CODE
# IF YOU WISE TO REMOVE THIS AND
# ADD IT TO YOUR STYLE, FEEL FREE
# AS LONG AS THE COPYRIGHT REMAINS
#-----------------------------------
$output .= '<div align="center" class="smallfont">SEOed URLs completed by <a href="http://www.techhelpforum.com">Tech Help Forum</a>.</div>';
if($vbulletin->options['vRewrite_showthreadrewrite'] == "2") {
#------------------------------
# SHOWTHREAD
#------------------------------
$found = preg_match_all('#<a href="showthread\.php\?t=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT threadid, forumid, title FROM " . TABLE_PREFIX . "thread WHERE threadid IN($ids)");
while($t = $vbulletin->db->fetch_array($res))
{
$title = urlize($t['title']);
$tid = $t['threadid'];
$fid = $t['forumid'];
$foruminfo = $vbulletin->db->query_first("SELECT title FROM " . TABLE_PREFIX . "forum WHERE forumid='$fid'");
$fname = urlize($foruminfo['title']);
$fname = str_replace("-","",$fname);
$title = str_replace("-"," ",$title);
$output = str_replace("<a href=\"showthread.php?t=$tid\"", "<a href=\"$fname/$title-$tid.html\"", $output);
}
}
}
#------------------------------
# SHOWTHREAD
#------------------------------
$found = preg_match_all('#<a href="showthread\.php\?t=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT threadid, forumid, title FROM " . TABLE_PREFIX . "thread WHERE threadid IN($ids)");
while($t = $vbulletin->db->fetch_array($res))
{
$title = urlize($t['title']);
$tid = $t['threadid'];
$fid = $t['forumid'];
$foruminfo = $vbulletin->db->query_first("SELECT title FROM " . TABLE_PREFIX . "forum WHERE forumid='$fid'");
$fname = urlize($foruminfo['title']);
$output = str_replace("<a href=\"showthread.php?t=$tid\"", "<a href=\"$fname/t-$title-$tid.html\"", $output);
}
}
#------------------------------
# SHOWTHREAD and page
#------------------------------
$found = preg_match_all('#showthread\.php\?t=([0-9]+)&page=([0-9]+)#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
// Keep track of page nums that go with tid's
$temp = array();
for($i = 0; $i < $found; $i++)
{
// $temp[<threadid>] = <page>
$temp[ $matches[1][$i] ] = $matches[2][$i];
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT threadid, forumid, title FROM " . TABLE_PREFIX . "thread WHERE threadid IN($ids)");
while($t = $vbulletin->db->fetch_array($res))
{
$title = urlize($t['title']);
$tid = $t['threadid'];
$fid = $t['forumid'];
$foruminfo = $vbulletin->db->query_first("SELECT title FROM " . TABLE_PREFIX . "forum WHERE forumid='$fid'");
$fname = urlize($foruminfo['title']);
$page = $temp[$tid];
$output = str_replace("showthread.php?t=$tid&page=$page", "$fname/t-$title-$tid-page-$page.html", $output);
}
}
#------------------------------
# showpost
#------------------------------
$found = preg_match_all('#<a href="showpost\.php\?p=([0-9]+)&postcount=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
$temp[ $matches[1][$i] ] = $matches[2][$i];
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT postid, title FROM " . TABLE_PREFIX . "post WHERE postid IN($ids)");
while($p = $vbulletin->db->fetch_array($res))
{
$pid = $p['postid'];
$postcount = $temp[$pid];
$output = str_replace("<a href=\"showpost.php?p=$pid&postcount=$postcount\"", "<a href=\"p-$pid.html\"", $output); }
}
#------------------------------
# Print SHOWTHREAD
#------------------------------
$found = preg_match_all('#<a href="printthread\.php\?t=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT threadid, title FROM " . TABLE_PREFIX . "thread WHERE threadid IN($ids)");
while($t = $vbulletin->db->fetch_array($res))
{
$title = urlize($t['title']);
$tid = $t['threadid'];
$output = str_replace("<a href=\"printthread.php?t=$tid\"", "<a href=\"print-$title-$tid.html\"", $output);
}
}
#------------------------------
# Email SHOWTHREAD
#------------------------------
$found = preg_match_all('#<a href="sendmessage\.php\?do=sendtofriend&t=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT threadid, title FROM " . TABLE_PREFIX . "thread WHERE threadid IN($ids)");
while($t = $vbulletin->db->fetch_array($res))
{
$title = urlize($t['title']);
$tid = $t['threadid'];
$output = str_replace("<a href=\"sendmessage.php?do=sendtofriend&t=$tid\"", "<a href=\"sendtofriend-$title-$tid.html\"", $output);
}
}
#------------------------------
# New Thread
#------------------------------
$found = preg_match_all('#<a href="newthread\.php\?do=newthread&f=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT forumid, title FROM " . TABLE_PREFIX . "forum WHERE forumid IN($ids)");
while($f = $vbulletin->db->fetch_array($res))
{
$title = urlize($f['title']);
$fid = $f['forumid'];
$output = str_replace("<a href=\"newthread.php?do=newthread&f=$fid\"", "<a href=\"$title-$fid/newthread.php\"", $output);
}
}
#------------------------------
# New Post
#------------------------------
$found = preg_match_all('#<a href="newreply\.php\?do=newreply&noquote=1&p=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT threadid, postid FROM " . TABLE_PREFIX . "post WHERE postid IN($ids)");
while($t = $vbulletin->db->fetch_array($res))
{
$tid = $t['threadid'];
$pid = $t['postid'];
$threadinfo = $vbulletin->db->query_first("SELECT title, forumid FROM " . TABLE_PREFIX . "thread WHERE threadid='$tid'");
$title = urlize($threadinfo['title']);
$fid = $threadinfo['forumid'];
$f = fetch_foruminfo($fid);
$fname = urlize($f['title']);
$output = str_replace("<a href=\"newreply.php?do=newreply&noquote=1&p=$pid\"", "<a href=\"$fname/newpostnoquote-$pid.php\"", $output);
}
}
#------------------------------
# New Post
#------------------------------
$found = preg_match_all('#<a href="newreply\.php\?do=newreply&p=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT threadid, postid FROM " . TABLE_PREFIX . "post WHERE postid IN($ids)");
while($t = $vbulletin->db->fetch_array($res))
{
$tid = $t['threadid'];
$pid = $t['postid'];
$threadinfo = $vbulletin->db->query_first("SELECT title, forumid FROM " . TABLE_PREFIX . "thread WHERE threadid='$tid'");
$title = urlize($threadinfo['title']);
$fid = $threadinfo['forumid'];
$f = fetch_foruminfo($fid);
$fname = urlize($f['title']);
$output = str_replace("<a href=\"newreply.php?do=newreply&p=$pid\"", "<a href=\"$fname/newpost-$pid.php\"", $output);
}
}
#------------------------------
# Search
#------------------------------
$found = preg_match_all('#<a href="search\.php\?searchid=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
if(is_numeric($matches[1][$i]))
$ids[] = $matches[1][$i];
}
$ids = implode(',', $ids);
// Go through each
$res = $vbulletin->db->query_read("SELECT userid, searchid FROM " . TABLE_PREFIX . "search WHERE searchid IN($ids)");
while($s = $vbulletin->db->fetch_array($res))
{
$userid = $s['userid'];
$searchid = $s['searchid'];
$output = str_replace("search.php?searchid=$searchid", "search-$userid-$searchid.html", $output);
}
}
#------------------------------
# misc pages
#------------------------------
$output = str_replace("search.php?do=getnew","search-getnew.html",$output);
$output = str_replace("search.php?do=getdaily","search-getdaily.html",$output);
$output = str_replace("forumdisplay.php?do=markread","markread.html",$output);
}
/**
* Turn a string into a URL friendly string
*
* @param string $txt The string to work on
* @return string The new string
*/
function urlize($txt)
{
$txt = unaccent($txt);
$txt = html_entity_decode($txt);
$txt = str_replace(' ', '-', $txt);
$txt = preg_replace('#[^a-zA-Z0-9_\-]+#', '', $txt);
$txt = preg_replace('#[\-]+#', '-', $txt);
return strtolower($txt);
}
/**
* Turn accented characters into normal characters
*
* @param string $txt The string to remove the accents from
* @return string Your new clean string
*/
function unaccent($txt)
{
$trans = get_html_translation_table(HTML_ENTITIES);
foreach($trans as $literal => $entity)
{
if(ord($literal) >= 192)
{
$search[] = $literal;
$replace[] = substr($entity, 1, 1);
}
}
return str_replace($search, $replace, $txt);
}
Let me know if that works for you :)
Quote:
Originally Posted by in'dira
Hello, Can you explain more precisely how and what to make at the time of the 3rd stage of the installation with $headinclude and < bases href="$vboptions[bburl ]/"/> please ?
Thx lot
|
You want to add the base href after the $headinclude in the templates it mentions. Does that help?
|