<?php



function checkLinks($link)

{

	$search = WEB_ROOT.'/';

	$replace = '';

	$toCheck = str_replace($search, '', $link);

	$Check = trim($toCheck);



	$db = Database::getDatabase(true);

	$Check = addslashes($Check);

	$fileDetails = $db->getRow("SELECT * FROM file WHERE shortUrl = '$Check'");

	

	switch($fileDetails['statusId'])

	{

		case '1':

			// Good link

			echo '<img src="'.WEB_ROOT.'/plugins/linkchecker/assets/img/link_active.png" alt="Active" style="vertical-align:middle;" title="';

			echo $fileDetails['originalFilename'];

			echo '" /> - <a href="'.$link.'" title="';

			echo $fileDetails['originalFilename']; 

			echo '">'.$link.'</a>';

		break;



		case '2':

			// User Deleted The File

			echo '<img src="'.WEB_ROOT.'/plugins/linkchecker/assets/img/link_deleted.png" alt="Deleted - User Removed The File" style="vertical-align:middle;" title="';

			$fileDetails['originalFilename'];

			echo '" /> - <del>'.$link.'</del>';

		break;



		case '3':

			// Admin Removed The File

			echo '<img src="'.WEB_ROOT.'/plugins/linkchecker/assets/img/link_deleted.png" alt="Deleted - Admin Removal" style="vertical-align:middle;" title="';

			$fileDetails['originalFilename'];

			echo '" /> - <del>'.$link.'</del>';

		break;



		case '4':

			// Copyright Complaint

			echo '<img src="'.WEB_ROOT.'/plugins/linkchecker/assets/img/link_deleted.png" alt="Deleted - Copyright Removal" style="vertical-align:middle;" title="';

			$fileDetails['originalFilename'];

			echo '" /> - <del>'.$link.'</del>';

		break;



		case '5':

			// System Deleted The File - Expired

			echo '<img src="'.WEB_ROOT.'/plugins/linkchecker/assets/img/link_deleted.png" alt="Deleted - System Deleted" style="vertical-align:middle;" title="';

			$fileDetails['originalFilename'];

			echo '" /> - <del>'.$link.'</del>';

		break;



		default:

			// File Not Found On That Link

			echo '<img src="'.WEB_ROOT.'/plugins/linkchecker/assets/img/link_deleted.png" alt="Link Not Found" style="vertical-align:middle;" title="';

			$fileDetails['originalFilename'];

			echo '" /> - <del>'.$link.'</del>';

		break;

	}

}



?>