Exemple #1
0
}
if (!empty($tb_url) && !empty($title) && !empty($tb_url)) {
    header('Content-Type: text/xml; charset=UTF-8');
    $title = htmlspecialchars(strip_tags($title));
    $title = strlen($title) > 150 ? substr($title, 0, 150) . '...' : $title;
    $excerpt = strip_tags($excerpt);
    $excerpt = strlen($excerpt) > 200 ? substr($excerpt, 0, 200) . '...' : $excerpt;
    $trackres = new Trackback();
    $trackres->link = $tb_id;
    $trackres->type = 'in';
    $trackres->url = $tb_url;
    $dupe = $trackres->read();
    if ($dupe) {
        trackback_response(1, $main_smarty->get_config_vars('PLIGG_Visual_Trackback_AlreadyPing'));
    }
    $contents = @file_get_contents($tb_url);
    if (!$contents) {
        trackback_response(1, $main_smarty->get_config_vars('PLIGG_Visual_Trackback_BadURL'));
    }
    $permalink = get_permalink($tb_id);
    $permalink_q = preg_quote($permalink, '/');
    $pattern = "/<\\s*a.*href\\s*=[\"'\\s]*" . $permalink_q . "[\"'\\s]*.*>.*<\\s*\\/\\s*a\\s*>/i";
    if (!preg_match($pattern, $contents)) {
        trackback_response(1, $main_smarty->get_config_vars('PLIGG_Visual_Trackback_NoReturnLink'));
    }
    $trackres->title = $title;
    $trackres->content = $excerpt;
    $trackres->status = 'ok';
    $trackres->store();
    trackback_response(0);
}
Exemple #2
0
 function enqueue()
 {
     global $db, $globals, $current_user;
     // Check this one was not already queued
     if ($this->votes == 0 && $this->author == $current_user->user_id && $this->status != 'queued') {
         $this->status = 'queued';
         $this->sent_date = $this->date = time();
         $this->get_uri();
         $db->transaction();
         if (!$this->store()) {
             $db->rollback();
             return false;
         }
         $this->insert_vote($current_user->user_karma);
         // Add the new link log/event
         Log::conditional_insert('link_new', $this->id, $this->author);
         $db->query("delete from links where link_author = {$this->author} and link_date > date_sub(now(), interval 30 minute) and link_status='discard' and link_votes=0");
         if (!empty($_POST['trackback'])) {
             $trackres = new Trackback();
             $trackres->url = clean_input_url($_POST['trackback']);
             $trackres->link_id = $this->id;
             $trackres->link = $this->url;
             $trackres->author = $this->author;
             $trackres->status = 'pendent';
             $trackres->store();
         }
         $db->commit();
         fork("backend/send_pingbacks.php?id={$this->id}");
     }
 }
Exemple #3
0
function do_submit3() {
	global $db, $current_user;

	$linkres=new Link;

	$linkres->id=$link_id = intval($_POST['id']);

	if(!check_link_key() || !$linkres->read()) die;

	// Check it is not in the queue already
	if ($linkres->duplicates($linkres->url)) {
		// Write headers, they were not printed yet
		do_header(_("enviar noticia"), "post");
		echo '<div id="singlewrap">' . "\n";
		report_dupe($linkres->url);
		return;
	}

	// Check this one was not already queued
	if($linkres->votes == 0 && $linkres->status != 'queued') {
		$db->transaction();
		$linkres->status='queued';
		$linkres->sent_date = $linkres->date=time();
		$linkres->get_uri();
		$linkres->store();
		$linkres->insert_vote($current_user->user_karma);
		$db->commit();

		// Add the new link log/event
		require_once(mnminclude.'log.php');
		log_conditional_insert('link_new', $linkres->id, $linkres->author);

		$db->query("delete from links where link_author = $linkres->author and link_date > date_sub(now(), interval 30 minute) and link_status='discard' and link_votes=0");
		if(!empty($_POST['trackback'])) {
			$trackres = new Trackback;
			$trackres->url=clean_input_url($_POST['trackback']);
			$trackres->link_id=$linkres->id;
			$trackres->link=$linkres->url;
			$trackres->author=$linkres->author;
			$trackres->status = 'pendent';
			$trackres->store();
		}
		fork("backend/send_pingbacks.php?id=$linkres->id");
	}

	header('Location: '. $linkres->get_permalink());
	die;
	
}
Exemple #4
0
 function pingback_ping($args)
 {
     global $db, $globals;
     $pagelinkedfrom = clean_input_string($args[0]);
     //$pagelinkedfrom = str_replace('&amp;', '&', $pagelinkedfrom);
     $pagelinkedto = clean_input_string($args[1]);
     $title = '';
     $urlfrom = parse_url($pagelinkedfrom);
     $urltest = parse_url($pagelinkedto);
     if (!$urlfrom || !$urltest) {
         return new IXR_Error(0, 'Is there no link to us?');
     }
     if ($urltest['host'] != get_server_name()) {
         return new IXR_Error(0, 'Is there no link to us?');
     }
     $base_uri = preg_quote($globals['base_url'] . $globals['base_story_url'], '/');
     $uri = preg_replace("/^{$base_uri}/", '', $urltest[path]);
     if (check_ban($globals['user_ip'], 'ip')) {
         syslog(LOG_NOTICE, "Meneame: pingback, IP is banned ({$globals['user_ip']}): {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(33, 'IP is banned.');
     }
     // Antispam of sites like xxx.yyy-zzz.info/archives/xxx.php
     if (preg_match('/http:\\/\\/[a-z0-9]\\.[a-z0-9]+-[^\\/]+\\.info\\/archives\\/.+\\.php$/', $pagelinkedfrom)) {
         return new IXR_Error(33, 'Host not allowed.');
     }
     if (check_ban($urlfrom[host], 'hostname', false)) {
         syslog(LOG_NOTICE, "Meneame: pingback, site is banned: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(33, 'Site is banned.');
     }
     $link = new Link();
     $link->uri = preg_replace('/#[\\w\\-\\_]+$/', '', $uri);
     if (empty($uri) || !$link->read('uri')) {
         syslog(LOG_NOTICE, "Meneame: pingback, story does not exist: {$pagelinkedto}");
         return new IXR_Error(33, 'Story doesn\'t exist.');
     }
     if ($link->get_permalink() == $pagelinkedfrom) {
         syslog(LOG_NOTICE, "Meneame: pingback, points to the same post: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(48, 'The pingback points to the same post.');
     }
     if ($link->date < time() - 86400 * 15) {
         syslog(LOG_NOTICE, "Meneame: pingback, story is too old: {$pagelinkedto}");
         return new IXR_Error(33, 'Story is too old for pingbacks.');
     }
     $trackres = new Trackback();
     $trackres->link_id = $link->id;
     $trackres->type = 'in';
     $trackres->link = $pagelinkedfrom;
     $trackres->url = $pagelinkedfrom;
     if ($trackres->abuse()) {
         return new IXR_Error(33, 'Don\'t send so many pings.');
     }
     $dupe = $trackres->read();
     if ($dupe) {
         syslog(LOG_NOTICE, "Meneame: pingback, we already have a ping from that URI for this post: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(48, 'The pingback has already been registered.');
     }
     // very stupid, but gives time to the 'from' server to publish !
     sleep(1);
     // Let's check the remote site
     if (version_compare(phpversion(), '5.1.0') >= 0) {
         $contents = @file_get_contents($pagelinkedfrom, FALSE, NULL, 0, 100000);
     } else {
         $contents = @file_get_contents($pagelinkedfrom);
     }
     if (!$contents) {
         syslog(LOG_NOTICE, "Meneame: pingback, the provided URL does not seem to work: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(16, 'The source URL does not exist.');
     }
     if (preg_match('/charset=([a-zA-Z0-9-_]+)/i', $contents, $matches)) {
         $this->encoding = trim($matches[1]);
         if (strcasecmp($this->encoding, 'utf-8') != 0) {
             $contents = iconv($this->encoding, 'UTF-8//IGNORE', $contents);
         }
     }
     // Check is links back to us
     $permalink = $link->get_permalink();
     $permalink_q = preg_quote($permalink, '/');
     $pattern = "/<\\s*a[^>]+href=[\"']" . $permalink_q . "[#\\/0-9a-z\\-]*[\"'][^>]*>/i";
     if (!preg_match($pattern, $contents)) {
         syslog(LOG_NOTICE, "Meneame: pingback, the provided URL does not have a link back to us: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(17, 'The source URL does not contain a link to the target URL, and so cannot be used as a source.');
     }
     // Search Title
     if (preg_match('/<title[^<>]*>([^<>]*)<\\/title>/si', $contents, $matches)) {
         $url_title = clean_text($matches[1]);
         if (mb_strlen($url_title) > 3) {
             $title = $url_title;
         }
     }
     if (empty($title)) {
         syslog(LOG_NOTICE, "Meneame: pingback, cannot find a title on that page: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(32, 'We cannot find a title on that page.');
     }
     $title = mb_strlen($title) > 120 ? mb_substr($title, 0, 120) . '...' : $title;
     $trackres->title = $title;
     $trackres->status = 'ok';
     $trackres->store();
     syslog(LOG_NOTICE, "Meneame: pingback ok: {$pagelinkedfrom} - {$pagelinkedto}");
     return "Pingback from registered. Keep the web talking! :-)";
 }