Exemplo n.º 1
0
function do_posts($link)
{
    global $globals;
    $info = SitesMgr::get_info();
    $properties = SitesMgr::get_extended_properties();
    syslog(LOG_INFO, "Meneame, posting {$link->uri}");
    $url = $link->get_permalink($info->sub);
    echo "Posting {$url}: " . $globals['server_name'] . "\n";
    // NEW format
    $image = false;
    if ($link->has_thumb()) {
        $media = $link->get_media();
        if ($media && file_exists($media->pathname())) {
            $image = $media->pathname();
        }
    }
    if ($globals['url_shortener']) {
        $short_url = $link->get_short_permalink();
    } else {
        $short_url = $url;
    }
    if (!empty($properties['twitter_token']) && !empty($properties['twitter_token_secret']) && !empty($properties['twitter_consumer_key']) && !empty($properties['twitter_consumer_secret'])) {
        $r = false;
        $tries = 0;
        while (!$r && $tries < 4) {
            $r = twitter_post($properties, $link->title, $url, $image);
            $tries++;
            if (!$r) {
                sleep(4);
            }
        }
    }
    if (!empty($properties['facebook_token']) && !empty($properties['facebook_key']) && !empty($properties['facebook_secret'])) {
        $r = false;
        $tries = 0;
        while (!$r && $tries < 4) {
            $r = facebook_post($properties, $link);
            $tries++;
            if (!$r) {
                sleep(4);
            }
        }
    }
    /*
    if ($globals['pubsub']) {
    	pubsub_post();
    }
    */
}
Exemplo n.º 2
0
 public function twitter_write()
 {
     // Æ®À§ÅÍ·Î ±Û ¾²±â »ùÇÃÀÔ´Ï´Ù.
     if ($_REQUEST["cont"]) {
         // ±Û ³»¿ëÀ» ¹Þ¾Æ¿É´Ï´Ù.
         $cont = $_REQUEST["cont"];
         // Æ®À§ÅÍ ÄÁ½´¸Ó key/secret À» ¹Þ¾Æ¿É´Ï´Ù.
         // »ùÇÿ¡¼­´Â ¼¼¼Ç¿¡ ÀúÀåµÇ¾úÀ¸¹Ç·Î ¼¼¼ÇÀÇ ³»¿ëÀ» ¹Þ¾Æ¿É´Ï´Ù.
         // º¸ÅëÀº, DB¿¡ ÀúÀåÇÏ°í DB¿¡¼­ ºÒ·¯¿À´Â °ÍÀÌ ÀϹÝÀûÀÔ´Ï´Ù.
         $key = $_SESSION["tf_twitter"]["twitter_key"];
         $secret = $_SESSION["tf_twitter"]["twitter_secret"];
         // sns_utils ¿¡ Æ÷ÇÔµÈ twitter_post ¸¦ ºÎ¸¨´Ï´Ù.
         // twitter_post´Â ³»¿ëÀ» ÀÚµ¿À¸·Î 140ÀÚ·Î ¸ÂÃçÁֹǷÎ, º°´Ù¸¥ 󸮴Â
         // ÇÊ¿äÄ¡ ¾Ê½À´Ï´Ù.
         // ÀÛ¼º ¼º°ø½Ã ÀÛ¼º ±ÛÀÇ tid ¸¦ ¹ÝȯÇÕ´Ï´Ù. (½ÇÆнà false ¹Ýȯ)
         $this->assigns["writed"] = twitter_post($key, $secret, $cont);
         $this->assigns["screen_name"] = $_SESSION["tf_twitter"]["screen_name"];
     }
 }
Exemplo n.º 3
0
function do_posts($link)
{
    global $globals;
    syslog(LOG_INFO, "Meneame, posting {$link->uri}");
    // echo "Posting $link->uri: ".$globals['server_name']. "--".$globals["site_shortname"]."---". $globals['twitter_consumer_key'] ."\n"; die;
    $url = $link->get_permalink();
    if ($globals['url_shortener']) {
        $short_url = $link->get_short_permalink();
    } else {
        $short_url = $url;
    }
    if ($globals['twitter_token'] && $globals['twitter_token_secret']) {
        twitter_post($link->title, $url);
    }
    if ($globals['facebook_token']) {
        facebook_post($link);
    }
    if ($globals['jaiku_user'] && $globals['jaiku_key']) {
        jaiku_post($link->title, $short_url);
    }
    if ($globals['pubsub']) {
        pubsub_post();
    }
}
Exemplo n.º 4
0
if (!$res) {
    exit(0);
}
$comment = Comment::from_db($res->comment_id);
if (!$comment) {
    exit(2);
}
$image = false;
if ($comment->media_size > 0) {
    $media = new Upload('comment', $comment->id);
    if ($media->read()) {
        $image = $media->pathname();
        $maxlen -= 24;
    }
}
$url = $globals[scheme] . '//' . get_server_name() . $comment->get_relative_individual_permalink();
syslog(LOG_INFO, "Meneame, posting comment {$url}");
//  Store in cache
if ($previous) {
    $ids = explode(',', $previous);
    if (count($ids) > 10) {
        array_shift($ids);
    }
} else {
    $ids = array();
}
$ids[] = $comment->id;
$previous = implode(',', $ids);
Annotation::store_text($key, $previous, time() + 86400);
twitter_post($properties, '&#x1f4ac; ' . $comment->content, $url, $image);
Exemplo n.º 5
0
}
$tops = explode(',', $a_tops->text);
$a_history = new Annotation('top-link-history-' . $site_name);
if ($a_history->read()) {
    $history = explode(',', $a_history->text);
} else {
    $history = array();
}
if (!in_array($tops[0], $history)) {
    if (!($link = Link::from_db($tops[0]))) {
        echo "Error reading link " . $tops[0] . "\n";
        exit;
    }
    $url = $link->get_permalink($info->sub);
    if ($globals['url_shortener']) {
        $short_url = $link->get_short_permalink();
    } else {
        $short_url = $url;
    }
    $intro = '#' . _('destacada');
    $text = "{$intro} {$link->title}";
    // Save the history
    array_push($history, intval($tops[0]));
    while (count($history) > 10) {
        array_shift($history);
    }
    $a_history->text = implode(',', $history);
    $a_history->store();
    twitter_post($properties, $text, $url);
    facebook_post($properties, $link, $intro);
}
Exemplo n.º 6
0
 public function add_timeline()
 {
     $result["data"] = $this->Board->add($_REQUEST);
     if ($_REQUEST["image"]) {
         $new_i = $this->settings->root_path . "media/board/" . $result["data"] . ".jpg";
         $ori_i = $this->settings->root_path . substr($_REQUEST["image"], 1);
         GD2_make_thumb_x(600, "", $ori_i);
         copy($ori_i, $new_i);
         unlink(substr($_REQUEST["image"], 1));
         $_arr["id"] = $result["data"];
         $_arr["image"] = "/media/board/" . $result["data"] . ".jpg";
         $this->Board->add_image($_arr);
     }
     //activity
     if ($_REQUEST["p_type"] != 3) {
         $wr = $this->Members->get($_REQUEST["user_id"]);
         if ($_REQUEST["p_type"] == 1) {
             $rc = $this->Members->get($_REQUEST["p_id"]);
             $m = "<a href='/member/" . $wr["ids"] . "'>" . $wr["name"] . "</a>님이 <a href='/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님의 <a href='/member/" . $rc["ids"] . "?tab=profile-content-wall'>방명록</a>에 글을 남겼습니다.";
             if ($_REQUEST["p_id"] == $_REQUEST["user_id"]) {
                 $m = "<a href='/member/" . $wr["ids"] . "'>" . $wr["name"] . "</a>님이 프로필 페이지에 <a href='/member/" . $rc["ids"] . "?tab=profile-content-update'>새 글</a>을 남겼습니다.";
             }
             if (!$_REQUEST["is_hidden"]) {
                 add_activity("1", $wr["id"], "1", $wr["id"], "", $m);
             }
         }
         if ($_REQUEST["p_type"] == 2) {
             $rc = $this->Startup->get($_REQUEST["p_id"]);
             $m = "<a href='/member/" . $wr["ids"] . "'>" . $wr["name"] . "</a>님이 <a href='/startup/" . $rc["id"] . "'>" . $rc["name"] . "</a>의 <a href='/startup/" . $rc["id"] . "?tab=profile-content-wall'>방명록</a>에 글을 남겼습니다.";
             if ($this->Startup_member->get_first($_REQUEST["p_id"], $_REQUEST["user_id"])) {
                 $m = "<a href='/member/" . $wr["ids"] . "'>" . $wr["name"] . "</a>님이 <a href='/startup/" . $rc["id"] . "'>" . $rc["name"] . "</a> 페이지에 <a href='/startup/" . $rc["id"] . "?tab=profile-content-wall'>새 글</a>을 남겼습니다.";
             }
             if (!$_REQUEST["is_hidden"]) {
                 add_activity("1", $wr["id"], "1", $wr["id"], "", $m);
             }
         }
         if ($rc["id"] != $wr["id"]) {
             $arr["com_type"] = 1;
             $arr["com_id"] = $rc["id"];
             $arr["act_type"] = 1;
             $arr["act_id"] = $wr["id"];
             $arr["msg"] = $m;
             $this->Activity->add($arr);
             if ($_REQUEST["p_type"] == 1 && $rc["email_rec"]) {
                 $m = new TF_mailer($this->settings);
                 $m->mailto = $rc["email"];
                 $m->subject = "[D.CAMP] " . $wr["name"] . "님이 " . $rc["name"] . "님의 '방명록'에 글을 작성하였습니다.";
                 $m->tpl_name = "timeline";
                 $m->assigns["wr"] = $wr;
                 $m->assigns["rc"] = $rc;
                 $m->assigns["contents"] = $_REQUEST["contents"];
                 $m->assigns["main_service_url"] = $this->globals->my_host;
                 $m->assigns["main_service_domain"] = $_SERVER['SERVER_NAME'];
                 $m->send();
             }
         }
         if (!$_REQUEST["is_hidden"]) {
             if ($_REQUEST["fb"]) {
                 if ($_SESSION["s"]["fb"]["public"]) {
                     $APP_ID = $this->settings->FACEBOOK_API_KEY;
                     $APP_SECRET = $this->settings->FACEBOOK_SECRET;
                     FacebookSession::setDefaultApplication($APP_ID, $APP_SECRET);
                     $session = new FacebookSession($_SESSION["s"]["fb"]["secret"]);
                     $request = new FacebookRequest($session, 'POST', '/me/feed', array('message' => $_REQUEST["contents"], 'link' => "http://" . $_SERVER["HTTP_HOST"] . "/timeline/" . $result["data"]));
                     $response = $request->execute();
                     $graphObject = $response->getGraphObject();
                 }
             }
             if ($_REQUEST["tw"]) {
                 twitter_post($_SESSION["s"]["tw"]["key_"], $_SESSION["s"]["tw"]["secret"], cut_multi($_REQUEST["contents"], 100) . " http://dcamp.kr/timeline/" . $result["data"]);
             }
         }
     }
     if ($_REQUEST["p_type"] == 3 || $_REQUEST["p_type"] == 7 || $_REQUEST["p_type"] == 6 || $_REQUEST["p_type"] == 4) {
         $rc = $this->Members->get($_SESSION["s"]["id"]);
         if ($_REQUEST["p_type"] == 3) {
             //event
             $ev = $this->Event->get_detail($_REQUEST["p_id"]);
             $m = "<a href='/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님이 \"<a href='/event/apply/" . $ev["id"] . "#comment'>" . $ev["title"] . "</a>\" 이벤트에 댓글을 달았습니다.";
             $mailto = $ev["memail"];
             $subject = "[D.CAMP] " . $rc["name"] . "님이 \"" . $ev["title"] . "\" 이벤트에 댓글을 달았습니다.";
             $title = "<a href='http://dcamp.kr/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님이 \"<a href='http://dcamp.kr/event/apply/" . $ev["id"] . "'>" . $ev["title"] . "</a>\" 이벤트에 댓글을 달았습니다.";
             $url = "/event/apply/" . $ev["id"] . "#comment";
             $cid = $ev["user_id"];
         } else {
             if ($_REQUEST["p_type"] == 7) {
                 // challenge, competition
                 $ev = $this->Competitions->get($_REQUEST["p_id"]);
                 $m = "<a href='/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님이 \"<a href='/competition/views/" . $ev["id"] . "#comment'>" . $ev["subject"] . "</a>\" 경진대회에 댓글을 달았습니다.";
                 $mailto = $ev["memail"];
                 $subject = "[D.CAMP] " . $rc["name"] . "님이 \"" . $ev["subject"] . "\" 경진대회에 댓글을 달았습니다.";
                 $title = "<a href='http://dcamp.kr/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님이 \"<a href='http://dcamp.kr/competition/views/" . $ev["id"] . "'>" . $ev["subject"] . "</a>\" 경진대회에 댓글을 달았습니다.";
                 $url = "/competition/views/" . $ev["id"] . "#comment";
                 $cid = $ev["user_id"];
             } else {
                 if ($_REQUEST["p_type"] == 6) {
                     // blog
                     $ev = $this->Content->get($_REQUEST["p_id"]);
                     $m = "<a href='/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님이 \"<a href='/contents/views/" . $ev["id"] . "#comment'>" . $ev["subject"] . "</a>\" Blog에 댓글을 달았습니다.";
                     $mailto = $ev["memail"];
                     $subject = "[D.CAMP] " . $rc["name"] . "님이 \"" . $ev["subject"] . "\" Blog에 댓글을 달았습니다.";
                     $title = "<a href='http://dcamp.kr/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님이 \"<a href='http://dcamp.kr/contents/views/" . $ev["id"] . "'>" . $ev["subject"] . "</a>\" Blog에 댓글을 달았습니다.";
                     $url = "/contents/views/" . $ev["id"] . "#comment";
                     $cid = $ev["mid"];
                 } else {
                     if ($_REQUEST["p_type"] == 4) {
                         // recruit
                         $ev = $this->Recruit->get($_REQUEST["p_id"]);
                         $m = "<a href='/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님이 \"<a href='/recruit/views/" . $ev["id"] . "#comment'>" . $ev["title"] . "</a>\" 채용정보에 댓글을 달았습니다.";
                         $mailto = $ev["memail"];
                         $subject = "[D.CAMP] " . $rc["name"] . "님이 \"" . $ev["title"] . "\" 채용정보에 댓글을 달았습니다.";
                         $title = "<a href='http://dcamp.kr/member/" . $rc["ids"] . "'>" . $rc["name"] . "</a>님이 \"<a href='http://dcamp.kr/recruit/views/" . $ev["id"] . "'>" . $ev["title"] . "</a>\" 채용정보에 댓글을 달았습니다.";
                         $url = "/recruit/views/" . $ev["id"] . "#comment";
                         $cid = $ev["mid"];
                     }
                 }
             }
         }
         // noti
         $arr1["com_type"] = 1;
         $arr1["com_id"] = $cid;
         $arr1["act_type"] = 1;
         $arr1["act_id"] = $rc["id"];
         $arr1["msg"] = $m;
         $this->Activity->add($arr1);
         // maill
         $m = new TF_mailer($this->settings);
         $m->mailto = $mailto;
         $m->subject = $subject;
         $m->tpl_name = "timeline_act";
         $m->assigns["title"] = $title;
         $m->assigns["url"] = $url;
         $m->assigns["rc"] = $rc;
         $m->assigns["content"] = $_REQUEST["contents"];
         $m->assigns["main_service_url"] = $this->globals->my_host;
         $m->assigns["main_service_domain"] = $_SERVER['SERVER_NAME'];
         $m->send();
     }
     $this->tpl_name = "";
     echo json_encode($result);
 }
Exemplo n.º 7
0
function publish(&$link)
{
    global $globals, $db;
    global $users_karma_avg;
    // Calculate votes average
    // it's used to calculate and check future averages
    $votes_avg = (double) $db->get_var("select SQL_NO_CACHE avg(vote_value) from votes, users where vote_type='links' AND vote_link_id={$link->id} and vote_user_id > 0 and vote_value > 0 and vote_user_id = user_id and user_level !='disabled'");
    if ($votes_avg < $users_karma_avg) {
        $link->votes_avg = max($votes_avg, $users_karma_avg * 0.97);
    } else {
        $link->votes_avg = $votes_avg;
    }
    $link->status = 'published';
    $link->date = $link->published_date = time();
    $link->store_basic();
    // Increase user's karma
    $user = new User();
    $user->id = $link->author;
    if ($user->read()) {
        $user->karma = min(20, $user->karma + 1);
        $user->store();
        $annotation = new Annotation("karma-{$user->id}");
        $annotation->append(_('Noticia publicada') . ": +1, karma: {$user->karma}\n");
    }
    // Add the publish event/log
    log_insert('link_publish', $link->id, $link->author);
    $short_url = fon_gs($link->get_permalink());
    if ($globals['twitter_user'] && $globals['twitter_password']) {
        twitter_post($link, $short_url);
    }
    if ($globals['jaiku_user'] && $globals['jaiku_key']) {
        jaiku_post($link, $short_url);
    }
}
Exemplo n.º 8
0
            if ($user->read()) {
                $user->karma -= $globals['instant_karma_per_depublished'];
                echo "{$user->username}: {$user->karma}\n";
                $user->store();
                $annotation = new Annotation("karma-{$user->id}");
                $annotation->append(_('Retirada de portada') . ": -" . $globals['instant_karma_per_depublished'] . ", karma: {$user->karma}\n");
            }
            if ($globals['twitter_user'] || $globals['jaiku_user']) {
                if ($globals['url_shortener']) {
                    $short_url = $l->get_short_permalink();
                } else {
                    $short_url = fon_gs($l->get_permalink());
                }
                $text = _('Retirada de portada') . ': ';
                if ($globals['twitter_user'] && $globals['twitter_password']) {
                    twitter_post($text, $short_url);
                }
                if ($globals['jaiku_user'] && $globals['jaiku_key']) {
                    jaiku_post($text, $short_url);
                }
            }
        }
    }
}
punish_comments();
// Discard links
$negatives = $db->get_results("select SQL_NO_CACHE link_id, link_karma, link_votes, link_negatives, link_author from links where link_date > {$min_date} and link_status = 'queued' and link_karma < 0 and (link_date < {$max_date} or link_karma < -100) and (link_karma < -link_votes*2 or (link_negatives > 20 and link_negatives > link_votes/2)) and (link_negatives > 20 or (link_negatives > 4 and link_negatives > link_votes) )");
//$db->debug();
if (!$negatives) {
    echo "no negatives to analyze\n";
    die;
Exemplo n.º 9
0
function publish($link) {
	global $globals, $db, $client;

	//return;
	if (DEBUG) return;

	// Calculate votes average
	// it's used to calculate and check future averages
	$votes_avg = (float) $db->get_var("select SQL_NO_CACHE avg(vote_value) from votes, users where vote_type='links' AND vote_link_id=$link->id and vote_user_id > 0 and vote_value > 0 and vote_user_id = user_id and user_level !='disabled'");
	if ($votes_avg < $globals['users_karma_avg']) $link->votes_avg = max($votes_avg, $globals['users_karma_avg']*0.97);
	else $link->votes_avg = $votes_avg;

	$link->status = 'published';
	$link->date = $link->published_date=time();
	$db->query("update links set link_status='published', link_date=now(), link_votes_avg=$link->votes_avg where link_id=$link->id");

	// Increase user's karma
	$user = new User;
	$user->id = $link->author;
	if ($user->read()) {
		$user->karma = min(20, $user->karma + $globals['instant_karma_per_published']);
		$user->store();
		$annotation = new Annotation("karma-$user->id");
		$annotation->append(_('noticia publicada').": +". $globals['instant_karma_per_published'] .", karma: $user->karma\n");
	}

	// Add the publish event/log
	log_insert('link_publish', $link->id, $link->author);
	$link->annotation .= _('publicación'). "<br/>";
	$link->save_annotation('link-karma');

	if ($globals['url_shortener']) {
		$short_url = $link->get_short_permalink();
	} else {
		$short_url = fon_gs($link->get_permalink());
	}
	if ($globals['twitter_user'] && $globals['twitter_password']) {
		twitter_post($link->title, $short_url); 
	}
	if ($globals['jaiku_user'] && $globals['jaiku_key']) {
		jaiku_post($link->title, $short_url); 
	}
	if ($globals['pubsub']) {
		pubsub_post();
	}

  if ($link->start_date) {
    createEvent($client, $link->title, $link->content, $link->start_date, $link->end_date);
  }

}
Exemplo n.º 10
0
    }
    $link = new Link();
    $link->id = $res->id;
    if ($link->read()) {
        $url = $link->get_permalink();
        if ($globals['url_shortener']) {
            $short_url = $link->get_short_permalink();
        } else {
            //$short_url = fon_gs($link->get_permalink());
            $short_url = $url;
        }
        if ($hours < 72) {
            $intro = "{$key} {$hours}h";
        } else {
            $days = intval($hours / 24);
            $intro = "{$key} {$days}d";
        }
        $text = "{$intro}: {$link->title}";
        if ($globals['twitter_token']) {
            twitter_post($text, $url);
        }
        if ($globals['jaiku_user'] && $globals['jaiku_key']) {
            jaiku_post($text, $short_url);
        }
        if ($globals['facebook_token']) {
            facebook_post($link, $intro);
        }
        echo "{$text} {$short_url}\n";
        continue;
    }
}