Exemplo n.º 1
0
function add_message()
{
	global $CONF;
	$user = $_SESSION['user'];

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

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

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

	}

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

	$user = $_SESSION['user'];
	$userto=new RegUser();
	if (isset($_POST['user_to_id'])) $userto->setId($_POST['user_to_id']);
	elseif (isset($_POST['user_to_email'])) $userto->setEmail($_POST['user_to_email']);
	elseif (isset($_POST['user_to_nickname'])) $userto->setNickname($_POST['user_to_nickname']);
	else return array('ok'=>false, 'error'=>'undefined user to send');

	$message = new Message();

	$message->setUserFrom($user);
	$message->setUserTo($userto);

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

	$msg = unescape_ampersand($_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);
	$message->setMsg($msg);

	$result = $message->save();
	if ($result=='ok'){
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'problems with this message: '.$result);
}
Exemplo n.º 2
0
function add_post()
{
	global $CONF;
	$user = $_SESSION['user'];

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

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

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

	}

	$post = new Post();

	$topic = new Topic(); $topic->setId($_GET['topicid_add_post']);

	if (!$topic->getChannel()->canIPost())
		return array('ok'=>false, 'error'=>'you cant create post in this channel');

	$post->setTopic($topic);
	$post->setUser($user);

	$msg = unescape_ampersand($_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);
	$post->setPost($msg);

	if ($post->save()=='ok'){
		$_SESSION['post_last_flood_time']=time();	

		$topic->follow();
		$topic->setId($topic->getId());	$topic->load(); //update topic->counter
		$topic->visit();
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'Problem with this post.');
}
Exemplo n.º 3
0
function update_channel()
{
	global $user;
	global $CONF;

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

	$user = $_SESSION['user'];	

	$channel = new Channel();
	if (isset($_GET['channelid_update_channel'])){
		$channel->setId($_GET['channelid_update_channel']);
		$channel->load();
		if ( ($user->getId()!=$channel->getUser()->getId()) || ($user->isAnon()) )
			return array('ok'=>false, 'error'=>'you are not the owner');
	} else {
		return array('ok'=>false, 'error'=>'no id');
	}

	$description = unescape_ampersand($_POST['description']);
	$description = strip_tags($description, $CONF['permitted_tags_msg']);
	$description = text_linkify($description);
	$description = str_replace('&nbsp;',' ',$description);
	$channel->setDescription($description);

	//system("echo \"$description\" > log.txt");

	if (isset($_POST['lang']) && !empty($_POST['lang']))
		$channel->setLang($_POST['lang']);

	if (isset($_POST['asktofollow'])) $channel->setAsktofollow($_POST['asktofollow']);
	if (isset($_POST['perm_member'])) $channel->setPermMember($_POST['perm_member']);
	if (isset($_POST['perm_reguser'])) $channel->setPermReguser($_POST['perm_reguser']);
	if (isset($_POST['perm_anon'])) $channel->setPermAnon($_POST['perm_anon']);

	if ($channel->save()=='ok'){
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'problems with this channel');
}
Exemplo n.º 4
0
function add_channel()
{
	global $CONF;
	global $LANGALL;
	$user = $_SESSION['user'];

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

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

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

	}

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

	$user = $_SESSION['user'];	
	if ($user->isAnon())
		return array('ok'=>false, 'error'=>'anonymous cannot create channel');

	$channel = new Channel();
	$channel->setUser($user);

	$name = strip_tags($_POST['name']);
	if (strlen(str_replace(' ', '', $name)) < $CONF['channel_min_name'])
		return array('ok'=>false, 'error'=>'too short name');
	$channel->setName($name);

	$description = $_POST['description'];
	$description = strip_tags($description, $CONF['permitted_tags_msg']);
	$description = text_linkify($description);
	$description = str_replace('&nbsp;',' ',$description);
	$channel->setDescription($description);

	if (isset($_POST['lang']) && !empty($_POST['lang']))
		$channel->setLang($_POST['lang']);

	if (!isset($_POST['urlname']))
		$channel->setUrlname( Channel::prettyUrlAvailable($_POST['name']) );
	else {
		if ($_POST['urlname']!=Channel::prettyUrlAvailable($_POST['urlname']))
			return array('ok'=>false, 'error'=>'invalid urlname');
		else
			$channel->setUrlname($_POST['urlname']);
	}

	if (isset($_POST['asktofollow'])) $channel->setAsktofollow($_POST['asktofollow']);
	if (isset($_POST['perm_member'])) $channel->setPermMember($_POST['perm_member']);
	if (isset($_POST['perm_reguser'])) $channel->setPermReguser($_POST['perm_reguser']);
	if (isset($_POST['perm_anon'])) $channel->setPermAnon($_POST['perm_anon']);

	$result=$channel->save();
	if ($result=='ok'){
		$channel->follow();

		/*if ($channel->getLang()=='pt_br'){
			$title=$LANGALL['pt_br']['addchannel_welcome_title'];
			$message=$LANGALL['pt_br']['addchannel_welcome_message'];
		} else {
			$title=$LANGALL['en_us']['addchannel_welcome_title'];
			$message=$LANGALL['en_us']['addchannel_welcome_message'];
		}
		require_once('class/Topic.php');
		require_once('class/User.php');
		$user=new RegUser();
		$user->setId(1);
		$topic=new Topic();
		$topic->setSubject($title);
		$topic->setMsg($message);
		$topic->setChannel($channel);
		$topic->setUser($user);
		$topic->save();*/
		
		return array('ok'=>true, 'error'=>'', 'id'=>$channel->getId());
	}
	elseif ($result=='error channel already exists'){
		return array('ok'=>false, 'error'=>'error channel already exists','id'=>null);
	} elseif ($result=='error you created many channels'){
		return array('ok'=>false, 'error'=>'error you created many channels','id'=>null);
	} elseif ($result=='error user anon'){
		return array('ok'=>false, 'error'=>'error user anon','id'=>null);
	} else
		return array('ok'=>false, 'error'=>'problems with this channel - '.$result,'id'=>null);
}
Exemplo n.º 5
0
        echo base_url() . "profile/" . $username;
        ?>
"><?php 
        echo display_image("", "", asset_profiles() . $user_id . "/medium_", $image, asset_profiles() . "medium_nopicture.png", "");
        ?>
 </a>
			</span>
			<span class="status_text">
				<b><a href="<?php 
        echo base_url() . "profile/" . $username;
        ?>
"><?php 
        echo $name;
        ?>
</a></b> <?php 
        echo text_linkify($status->text);
        ?>
				<span class="status_meta"><?php 
        echo standard_date("SIMPLE_TIME", $status->created_at);
        ?>
</span>
			</span>	
			<ul class="status_actions">
				<?php 
        if ($user_id == $this->session->userdata('user_id')) {
            ?>
				<li><span class="status_actions delete"><a href="#">Delete</a></span></li>
				<?php 
        } else {
            ?>
				<li><span class="status_actions reply"><a href="#">Reply</a></span></li>
Exemplo n.º 6
0
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.');
}