Hi there,
I created my new scripts and they are working fine now. Instead of consulting the database what I did was to create a fixed table containing the old threadid's (importthreadid) and the new ones (threadid). In order to improve performance (bigest issue I had) I created several tables.
First you need to run the script below to create the files (tables).
I am not a real programmer myself, so this code may need a fine tuning, especially on the part that the script looks for a match inside the file, because right now it has to go to each entry until it finds a match instead of going directly to a match (I didn't know how to do differently).
Suggestions are welcome!
Cheers,
Gabriel.
[/SIZE][/SIZE]
I created my new scripts and they are working fine now. Instead of consulting the database what I did was to create a fixed table containing the old threadid's (importthreadid) and the new ones (threadid). In order to improve performance (bigest issue I had) I created several tables.
First you need to run the script below to create the files (tables).
Code:
[SIZE=2] <? $dbhost1 = 'localhost'; $dbusername1 = 'username'; $dbuserpassword1 = 'password'; $vbul1 = mysql_pconnect($dbhost1, $dbusername1, $dbuserpassword1); if (!$vbul1) { die('Could not connect: ' . mysql_error()); } mysql_select_db("vbulletin",$vbul1); $count=0; $step = 1000; $query=mysql_query("SELECT importthreadid FROM thread ORDER BY importthreadid DESC LIMIT 1"); $row=mysql_fetch_row($query); $total=$row[0]; while ($count<$total) { $query=mysql_query("SELECT importthreadid,threadid FROM thread WHERE importthreadid>$count AND importthreadid<$count+$step"); $result=""; while ($row=mysql_fetch_array($query)) { $result .= serialize($row); $result .="\n"; } $cachefile="/www/forum/converter/".$count.".php"; // open the cache file for writing $fp = @fopen($cachefile, 'w'); // save the contents of output buffer to the file @fwrite($fp, $result); // close the file @fclose($fp); $count += $step; } ?>[/SIZE]
Code:
[SIZE=2]// Converter Start
if ($_GET['showtopic'])
{
$showtopic=$_GET['showtopic'];
$file=floor($showtopic/1000)*1000;
$cachefile="/www/forum/converter/".$file.".php";
$dados=file($cachefile);
while (list($key,$value) = each($dados))
{
$row=unserialize($value);
$importthreadid=$row['importthreadid'];
$threadid=$row['threadid'];
if ($importthreadid==$showtopic)
{
break;
}
}
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://forum.clubedohardware.com.br/showthread.php?t=".$threadid);
exit();
}
// Converter End
Then I added the following code at the beginning of my index.php:
Code:
[SIZE=2]
<?
$url=$_SERVER['REQUEST_URI'];
$result=explode("/lofiversion/index.php/t",$url);
$result=explode(".html",$result[1]);
$showtopic=$result[0];
if ($showtopic)
{
$file=floor($showtopic/1000)*1000;
$cachefile="/www/forum/converter/".$file.".php";
$dados=file($cachefile);
while (list($key,$value) = each($dados))
{
$row=unserialize($value);
$importthreadid=$row['importthreadid'];
$threadid=$row['threadid'];
if ($importthreadid==$showtopic)
{
break;
}
}
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://forum.clubedohardware.com.br/showthread.php?t=".$threadid);
}
else
{
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://forum.clubedohardware.com.br");
}
?>
And also created the file below and saved as index.php under /lofiversion:
I am not a real programmer myself, so this code may need a fine tuning, especially on the part that the script looks for a match inside the file, because right now it has to go to each entry until it finds a match instead of going directly to a match (I didn't know how to do differently).
Suggestions are welcome!
Cheers,
Gabriel.
[/SIZE][/SIZE]
Comment