Грешка в php код

nortrant

Well-Known Member
На последният ред:
Parse error: syntax error, unexpected '[' in /home/site/public_html/backlinkCheck.php on line 185

HTML:
<?php
/**
 * @author: Jordan DeLozier
 * @date: 10/18/2010
 * @license: www.webmastertalkforums.com
 *
 * @description: Cron based CLI script which detects
 *   if backlinks are still present on websites. If not
 *   a text based report is sent to an email.
 *
 * Visit http://www.webmastertalkforums.com for more info
 *
 * @used fopen with URL ability
 */
 
 /*
 * Your Website URL. Leave out the http://
 * and only include the base domain
 */
$url = 'webmastertalkforums.com';

/*
 * Your email, the place you want the report
 * to arrive at
 */
$email   = '[email protected]';

/* 
 * Email the report is being sent from
 */
$fromEmail = '[email protected]';

/*
 * Subject of the report email when a backlink
 * is not found on a source
 */
$subject = "Backlink not found on Source: $url";

/*
 * Body header text
 */ 
$body = "Hai, a source that was suppose to contain a backlink to your website no longer does. Please see below.\r\n\r\n";


/*
 * Backlink Sources
 */
$backlinkSources = array ('http://google.com/',
						  'http://yahoo.com/',
						  'http://www.webmastertalkforums.com' 
						 );

/*
 * This is a place holder variable which will
 * be used to hold the true/false variables
 * for report generation
 */
$reportArray = array();

/* 
 * Bool value used to determine if any false
 * values are found
 */
$falseFound = false;

/*
 * Begin checking the backlinks for the target
 * URL
 */
foreach ($backlinkSources as $source) {
	// Get the HTML source Code
	$html = file_get_contents ( $source );

	// Extract all Links
	$links = ExtractHrefLinks($html);
	
	// Determine if the links contain your site URL
	if (CheckForTargetUrl($links, $url) === false) {
		$falseFound = true;
		$reportArray[$source] = 0;
	} else {
		$reportArray[$source] = 1;
	}
}

/*
 * Dump our results for browser output
 */
print_r($reportArray);

/*
 * If a backlink is not found on a source,
 * Generate an email.
 */
if ($falseFound === true) {
	GenerateReportEmail($email, $fromEmail, $subject, $body, $url, $reportArray);
}


/**
 * Send the report email when a source is found that does
 * not have a backlink
 *
 * @var email string
 * @var fromEmail string
 * @var subject string
 * @var body string
 * @var url string
 * @var reportArray array
 *
 * @return null
 */
function GenerateReportEmail($email, $fromEmail, $subject, $body, $url, $reportArray) {
	// Create an email header
	$header = "From: " . $fromEmail . "\r\n"; //optional headerfields
	
	/*
	 * Loop through the results to form the
	 * report
	 */
	foreach ($reportArray as $key => $report) {
		if ($report == false) {
			$body .= "Backlink to $url not found on: $key\n";
		}
	}
	
	// Send the email
	mail($email, $subject, $body, $header);
}

/**
 * Determine if the array of links contain the 
 * target URL (your URL)
 *
 * @var links array of source URLs
 * @var target URL of target website (your website)
 * @return bool
 */
function CheckForTargetUrl($links, $target) {	
	/*
	 * Loop through all of the links in the array. Use
	 * strpos to test if string is found in link text
	 */
	foreach ($links as $link) {
		if (strpos($link, $target) !== false) {
			return true;
		}
	}

	// Return
	return false;
} 
						  
/**
 * Extract all href Links from an HTML
 * document/text
 *
 * @vars html source code of site
 * @return array 
 */
function ExtractHrefLinks($html) {
	//Create a new DOM document
	$dom = new DOMDocument;
	$linkUrls = array();
	 
	/*
	 * Parse the HTML. The @ is used to suppress any parsing errors
	 * that will be thrown if the $html string isn't valid XHTML.
	 */
	@$dom->loadHTML($html);
	 
	/*
	 * Get all links. You could also use any other tag name here,
	 * like 'img' or 'table', to extract other tags.
	 */
	$links = $dom->getElementsByTagName('a');
	 
	//Iterate over the extracted links and display their URLs
	foreach ($links as $link){
		//Extract and show the "href" attribute. 
		$linkUrls[] = $link->getAttribute('href');
	}
	
	return $linkUrls;
}[/php]

за този скрипт май се изисква cron job , да не би от там да идва проблема?
 

Горе