Jump to content

[SOLVED] vBulletin Link Checker


Stephen

Recommended Posts

Okay well I attempted to make a script that should check the links of a thread and make sure they work (like the bot on a phpbb forum).

 

For some reason it can't do alot of threads, only like 20 or something.

 

If you have vbulletin and a section with RS/MU etc. links you can try this and tell me what it gets to D: And if it's a programming problem can someone help me?

 

<?php
///////////////////////////////////////////////////////////
// Script created by: Stephen (aka AADude) ////////////////////
// Use: Checking to see if links are dead or not //////////////////
//////////////////////////////////////////////////////////
function ss_link_check($_url,$_type="RS") {
  //RS = RapidShare; MU = MegaUpload; ES = EasyShare; FF = FileFactory; SS = SendSpace;
  $_sites=array(
  "RS" => "Error",
  "MU" => "Unfortunately, the link you have clicked is not available.",
  "ES" => "File not found",
  "FF" => "Sorry, this file is no longer available. It may have been deleted by the uploader, or has expired.",
  "SS" => "Sorry, the file you requested is not available.",
  "FFFH" => "Your requested file is not found"
  );
  
  $_fgc=file_get_contents($_url);
  if (preg_match("/".$_sites[$_type]."/",$_fgc) or $_fgc=="") {
    $_correct=false;
  }
  else {
    $_correct=true;
  }
  
  return $_correct;
}

//Include the vBulletin configuration file
include ("../config.php");

//Search the DB
if ($config['MasterServer']['usepconnect']==1) {
  $_connection=mysql_pconnect(
  $config['MasterServer']['servername'].":".$config['MasterServer']['port'],
  $config['MasterServer']['username'],
  $config['MasterServer']['password']);
}
else {
  $_connection=mysql_connect(
  $config['MasterServer']['servername'].":".$config['MasterServer']['port'],
  $config['MasterServer']['username'],
  $config['MasterServer']['password']);
}

mysql_select_db(
$config['Database']['dbname'],
$_connection);

$_boards_array=array(
1 => "16",
2 => "20",
3 => "23",
4 => "26",
5 => "28",
6 => "32",
7 => "18"
);

foreach ($_boards_array as $_key => $_cboard) {
  echo("<b>Board ID:</b> ".$_cboard."<br />");
  
  $_query1=mysql_query('SELECT * FROM '.$config['Database']['tableprefix'].'thread WHERE forumid="'.$_cboard.'" ORDER BY threadid DESC');
  while ($_rows1=mysql_fetch_array($_query1)) {
    $_threadid=$_rows1["threadid"];
    $_firstpostid=$_rows1["firstpostid"];
  
    $_query2=mysql_query('SELECT * FROM '.$config['Database']['tableprefix'].'post WHERE postid="'.$_firstpostid.'"');
    while ($_rows2=mysql_fetch_array($_query2)) {
      $_pagetext=$_rows2["pagetext"];
      $_link=preg_match_all("@\[(?i)url\](.*?)\[/(?i)url\]@si",$_pagetext,$_url,PREG_SET_ORDER);
  	  $_replace=preg_replace("@\[(?i)url\](.*?)\[/(?i)url\]@si","@\[(?i)url\](.*?)\[/(?i)url\]@si",$_pagetext,-1,$_count);
  $_not_working=0;

  foreach ($_url as $_key2 => $_site) {
    if (preg_match("/rapidshare/",$_url[$_key2][1])) {
      $_type="RS";
    }
    else if (preg_match("/megaupload/",$_url[$_key2][1])) {
      $_type="MU";
    }
    else if (preg_match("/easyshare/",$_url[$_key2][1])) {
      $_type="ES";
    }
    else if (preg_match("/filefactory/",$_url[$_key2][1])) {
      $_type="FF";
    }
    else if (preg_match("/sendspace/",$_url[$_key2][1])) {
      $_type="SS";
    }
    else if (preg_match("/fastfreefilehosting/",$_url[$_key2][1])) {
      $_type="FFFH";
    }
    else {
      $_type=0;
    }
    
	$phper=error_get_last();
	$message=$phper[2];
    echo($_url[$_key2][1]." / ".mysql_error($_connection)." / ".$message."<br />");
    if ($_type!==0) {
      if (ss_link_check($_url[$_key2][1],$_type)) {
        //blah
      }
      else {
	    $_not_working+=1;
      }
    }
  }

  $_delete=$_not_working/$_count;
  $_delete=$_delete*100;

  if ($_delete > 60) {
    mysql_query('UPDATE '.$config['Database']['tableprefix'].'thread SET forumid="14" WHERE threadid="'.$_threadid.'"');
	mysql_query('UPDATE '.$config['Database']['tableprefix'].'post SET pagetext="'.$_pagetext.'[quote]One or more links were found dead. If you want this moved back please report this post or PM Stephen.[/quote]" WHERE postid="'.$_firstpostid.'"');
  }
    }
  }
}
?>

 

VB 3.7.x btw.

I put this in includes/cron/ folder.

Okay, my problem is that the script suddenly stops the loop before all of the threads in all 7 of the boards were checked.

 

I posted this on another site too.

 

EDIT: If you want to see a hosted example please PM me and I will give you a link.

Link to comment
Share on other sites

  • 11 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.