コード例 #1
0
ファイル: autoopentopic.php プロジェクト: rczeus/Rapid-Coffee
	//require_once("class/Addthis.php");

	global $CONF;

	$user=$_SESSION['user'];	

	if (isset($_GET['topicid']))
	{
		$topic = new Topic();
		$topic->setId($_GET['topicid']);		

		$channel = $topic->getChannel();
		$channel->load();

		$OG['topic_title'] = $topic->getSubject();
		$OG['topic_msg'] = $topic->getSubsumedMsg();

		if ($channel->getId()>0)
		{
			$OG['request'] = 'openchannel';
			$OG['channel_name'] = $channel->getName();
			$OG['channel_desc'] = $channel->getDescription();
			$OG['channel_logo'] = $CONF['url_path'] . $channel->getLogoFile('big');

		}

		if (isset($_GET['sms_ss'])){
			$db = clone $GLOBALS['maindb'];
			$_anon=($user->isAnon())?'true':'false';
			$_channelid=($channel->getId()>0)?$channel->getId():0;
コード例 #2
0
        $this->username = $username;
    }
    public function getUsername()
    {
        return $this->username;
    }
}
class Topic
{
    private $member;
    private $subject;
    public function __construct($member, $subject)
    {
        $this->member = $member;
        $this->subject = $subject;
    }
    public function getSubject()
    {
        return $this->subject;
    }
    public function __call($method, $arguments)
    {
        return $this->member->{$method}($arguments);
    }
}
$aMember = new Member("fred");
$aTopic = new Topic($aMember, "Hello everybody!");
echo $aTopic->getSubject() . "<br>";
// отобразит "Hello everybody!"
echo $aTopic->getUsername() . "<br>";
// отобразит "fred"
コード例 #3
0
ファイル: add_topic.php プロジェクト: rczeus/Rapid-Coffee
function add_topic()
{
	global $CONF;
	$user = $_SESSION['user'];

	if ($user->getBanned()>0){
		return array('ok'=>false, 'error'=>'banned '.$user->getBanned());
	}

	if (isset($_SESSION['topic_last_flood_time'])){

		if ((time() - $_SESSION['topic_last_flood_time']) < $CONF['topic_time_to_wait_flood']){
			$time_to_wait = $CONF['topic_time_to_wait_flood'] - (time() - $_SESSION['topic_last_flood_time']);
			return array('ok'=>false, 'error'=>'flood '.$time_to_wait);
		}

	}

	$user = $_SESSION['user'];	

	$topic = new Topic();

	if (isset($_GET['channelid_add_topic'])){
		$channel = new Channel();
		$channel->setId($_GET['channelid_add_topic']);
		if (!$channel->canITopic())
			return array('ok'=>false, 'error'=>'you cant create topic in this channel');
		$topic->setChannel($channel);
	}

	$topic->setUser($user);

	$subject = strip_tags($_POST['subject']);
	if (strlen(str_replace(' ', '', $subject)) < $CONF['min_msg_chars'])
		return array('ok'=>false, 'error'=>'too short subject');
	$topic->setSubject($subject);

	$msg = $_POST['msg'];
	if (strlen(str_replace(' ', '', strip_tags($msg))) < $CONF['min_msg_chars'])
		return array('ok'=>false, 'error'=>'too short message');

	$msg = strip_tags($msg, $CONF['permitted_tags_msg']);
	//$msg = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a target=\"_BLANK\" href=\"\\0\">\\0</a>", $msg); //detectando URLs
	$msg = text_linkify($msg);
	$msg = str_replace('&nbsp;',' ',$msg);
	$topic->setMsg($msg);

	if ($topic->save()=='ok'){

		$_SESSION['topic_last_flood_time']=time();

		$topic->follow();


		$headers  = "MIME-Version: 1.0\r\n";
		$headers .= "Content-type: text/html; charset=UTF-8\r\n";
		$headers .= "From: {$CONF['email_from']}\r\n";
		$headers .= "To: YOU <you>\r\n";
		$_pretty=Topic::prettyUrl($topic->getSubject());
		$body='Acesse: <a href="http://rapidcoffee.com//'.$topic->getId().'/'.$_pretty.'">http://rapidcoffee.com//'.$topic->getId().'/'.$_pretty.'</a>';
		//system("echo \"".$body."\" > email.html");
		//mail('lucasvendramin85@gmail.com, danilo.horta@gmail.com', "Rapidcoffee-NOVO TOPICO", $body, $headers);
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'Problems with this topic.');
}