コード例 #1
0
ファイル: client.php プロジェクト: lscgzwd/jegarn
         $authPacket->setContent($packet->getContent());
         switch ($authPacket->getStatus()) {
             case AuthPacket::STATUS_NEED_AUTH:
                 $authPacket->setAccount(G::$account);
                 $authPacket->setPassword(G::$password);
                 $cli->send(serializePacket($authPacket));
                 break;
             case AuthPacket::STATUS_AUTH_FAILED:
                 echo "error: auth failed\n";
                 break;
             case AuthPacket::STATUS_AUTH_SUCCESS:
                 echo "auth success\n";
                 G::$auth = true;
                 G::$uid = $authPacket->getUid();
                 sendChatPacket();
                 sendGroupMessage();
                 sendChatroomMessage();
                 break;
             default:
                 echo "error: auth status undefined!\n";
                 exit;
         }
     } else {
         echo "error: first message from server is not auth message!\n";
         exit;
     }
 }
 echo "---------RECEIVE----------------------------\n";
 echo "from: ", $packet->getFrom(), "\n";
 echo "to: ", $packet->getTo(), "\n";
 echo "type: ", $packet->getType(), "\n";
コード例 #2
0
ファイル: functions.php プロジェクト: NullYing/mtpt
/**
* 当删除种子时对所有下载者和做种者发送删除的消息
*
* @param int $id torrent id
* @return null
* @author SamuraiMe,2013.05.17
*/	
function sendDelMsg($id, $reason = "", $mode = "recycle")
{
	global $CURUSER;	
	$downloaders = array();
	$seeders = array();
	$finished = array();

	
	if ($reason) {
		$reason = ",原因是:{$reason}";
	}
	if ($mode == "recycle") {
		$mode = "扔进回收站了";
	} else {
		$mode = "被删除了";
	}

	$result = sql_query("SELECT name, owner FROM torrents WHERE id = $id") or sqlerr();
	$row = mysql_fetch_row($result);
	$torrentName = $row[0];
	$owner = $row[1];
	
	$result = sql_query("SELECT userid, seeder FROM peers WHERE torrent = $id") or sqlerr();
	while ($row = mysql_fetch_row($result)) {
		if  ($row[0] != $owner && $row[0] != $CURUSER['id'])
		{
		if (strtolower(trim($row[1])) == "yes") 
			$seeders[] = $row[0];
		else
			$downloaders[] = $row[0];
		}
	}

	$result = sql_query("SELECT userid FROM snatched WHERE torrentid = $id AND finished = 'yes'") or sqlerr();
	while ($row = mysql_fetch_row($result)) {
		$finished[] = $row[0];
	}
	if($mode == "扔进回收站了"){$torrenturll = "[url=details.php?id=$id]";$torrenturlr="[/url]";}
	if($owner != $CURUSER['id']) 
	sendMessage(0, $owner, "你发布的种子被$mode", "你发布的id为{$id}的种子[b]$torrenturll{$torrentName}$torrenturlr [/b]被[url=userdetails.php?id={$CURUSER['id']}]{$CURUSER['username']}[/url]$mode{$reason}");
	sendGroupMessage(0, $seeders, "你正在做种的种子被$mode", "你正在做种的id为{$id}的种子[b]$torrenturll{$torrentName}$torrenturlr [/b]被[url=userdetails.php?id={$CURUSER['id']}]{$CURUSER['username']}[/url]$mode{$reason}");
	sendGroupMessage(0, $downloaders, "你正在下载的种子被$mode", "你正在下载的id为{$id}的种子[b]$torrenturll{$torrentName}$torrenturlr [/b]被[url=userdetails.php?id={$CURUSER['id']}]{$CURUSER['username']}[/url]$mode{$reason}");	
	sendGroupMessage(0, $downloaders, "你下载完成的种子被$mode", "你下载完成的id为{$id}的种子[b]$torrenturll{$torrentName}$torrenturlr [/b]被[url=userdetails.php?id={$CURUSER['id']}]{$CURUSER['username']}[/url]$mode{$reason}");	
	
}