Προς το περιεχόμενο

Προτεινόμενες αναρτήσεις

Δημοσ.

Λοιπόν, έχουμε ένα addon σε vBulletin που κάνει το εξής: αν ας πούμε υπάρχει το link του site μου σε ένα άλλο site και κάποιος το πατήσει, αυτό το άλλο site (πλήρης σύνδεσμος), καταγράφεται στους referrers.
Το βασικό globally plugin που κάνει αυτή τη δουλειά είναι το εξής (δεν χρειάζονται ιδιαίτερες γνώσεις πάνω στη μηχανή vBulletin, just PHP) :
 

if ($vbulletin->options['referrers_onoff'] && $_SERVER['HTTP_REFERER'])
{
	// Shorten the referrer to just the domain
	// BUG NOTE: Don't use ltrim(http://www.), it removes t,h,p from the first letters of domains for some reason. Something to do with the //
	$referrer_short = $_SERVER['HTTP_REFERER'];
	
	// Trim down to the domain
	$referrer_short = preg_replace('#^[a-z]+://(?:www.)?#iU', '', $referrer_short);
	
	// Use the (almost) full referrer for writing to save doing the trimming twice
	$referrer = $referrer_short;
	
	$referrer_short = explode('/', $referrer);
	
	// Some might have a trailing / in their forum URL, some might not so do the same
	$bburl_match = $vbulletin->options['bburl'];
	
	// Trim down to the domain
	$bburl_match = preg_replace('#^[a-z]+://(?:www.)?#iU', '', $bburl_match);
	
	$bburl_match = explode('/', $bburl_match);

	// If the referrer is not the forum itself, go.
	if ($referrer_short['0'] != $bburl_match['0'])
	{
		// Trim the extraneous http://www. bit and if the URL is too long for the db entry or the admin wants it, trim the variables off the end first. 
		if (strlen($referrer) > 250 || $vbulletin->options['referrers_rtrim'])
		{
			$referrer = explode('?', $referrer);
			$referrer = $referrer['0'];
		}
		if ($vbulletin->options['referrers_rtrim_domain'])
		{
			$referrer= explode('/', $referrer);
			$referrer = $referrer['0'];
		}
		
		// Encode for the db.
		$referrer = $vbulletin->db->escape_string(urlencode(htmlspecialchars_uni($referrer)));

		// Db pullers
		$referrers_db_select = "url, count";
		$referrers_db_values = "'$referrer', 1";
		
		// Check if the referrer exists in the db.
		$this_referrer = $vbulletin->db->query_first("
			SELECT " . $referrers_db_select . "
			FROM " . TABLE_PREFIX . "referrers
			WHERE url='$referrer'
		");

		// If this is a new referrer, add it.
		if (!$this_referrer['url'])
		{
			// Check if any of the block words are in the domain. To be server-friendly, this will only be checked at initial write.
			if ($vbulletin->options['referrers_blockwords'])
			{
				$blockwords = explode(',', $vbulletin->options['referrers_blockwords']);
				foreach ($blockwords AS $blockedwords)
				{
					$pos = strpos($_SERVER['HTTP_REFERER'], $blockedwords);
					if ($pos !== False)
					{
						$blockthis++;
					}
				}
			}
				
			// Blockthis is empty, go.
			if (!$blockthis)
			{
				// Get the page title of the referrer
				if ($vbulletin->options['referrers_titles'])
				{
					// Decode the URL back from the db
					$referred = urldecode($referrer);		
					
					// Get the title from the referrer
					$referrer_title = @fopen("http://" . $referred . "", r);
					if ($referrer_title)
					{
						$page = '';
						while(!feof($referrer_title))
						{
							$title = fgets($referrer_title, 100);
							$page .= $title;
						}
						preg_match("/<title>(.*)<\/title>/s", $page, $title);
						$title = $vbulletin->db->escape_string(urlencode($title['1']));
						
						// Tack on the extra db requests
						$referrers_db_select .= ", title";
						$referrers_db_values .= ", '$title'";
						
						fclose($referrer_title);						
					}				
				}
				
				if ($vbulletin->options['referrers_referrerids'] && strpos($_SERVER['REQUEST_URI'], 'referrerid='))
				{
					// Tack on the extra db requests
					$referrers_db_select .= ", referrerid";
					$referrers_db_values .= ", 1";
				}
				
				$db->query_write("
					INSERT INTO " . TABLE_PREFIX . "referrers
						(" . $referrers_db_select . ")
					VALUES
						(" . $referrers_db_values . ") ON DUPLICATE KEY UPDATE count = count + 1
				");
			}
		}
		// Otherwise just up the count by 1
		else
		{
			$vbulletin->db->query("
				UPDATE " . TABLE_PREFIX . "referrers
				SET count = count + 1
				WHERE url = '$referrer'
			"); 
		}
	}
}

Έχω όμως την εξής απορία: πολλές φορές βλέπω referrers (ολοκληρωμένο/ συγκεκριμένο σύνδεσμο, όχι απλά ένα domain) και όταν τους επισκέπτομαι για να δω που κάνανε αναφορά στο site μου, δεν βλέπω καμία αναφορά. Οπότε πως είναι δυνατόν να καταγράφεται κάτι τέτοιο;

Και δεν μιλάμε για τίποτα "παράξενα" sites εξωτερικού, τα πιο πολλά είναι ελληνικά και γνωστά websites (links προς άρθρα τους κτλ).

Μάλιστα, αν δεν βρω τον σύνδεσμο του site μου κάνοντας αναζήτησης μέσω του browser, κοιτάω και τον πηγαίο κώδικα, αλλά και πάλι τίποτα.
Βλέπετε κάποιο bug στον κώδικα ή επιδέχεται κάποιας άλλης ερμηνείας το θέμα;

Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε

Πρέπει να είστε μέλος για να αφήσετε σχόλιο

Δημιουργία λογαριασμού

Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!

Δημιουργία νέου λογαριασμού

Σύνδεση

Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.

Συνδεθείτε τώρα
  • Δημιουργία νέου...