Exemple #1
0
function deletetopic()
{
	global $CONF;
	$user = $_SESSION['user'];

	if (!isset($_GET['topicid_deletetopic']) || empty($_GET['topicid_deletetopic']))
		return array('ok'=>'false','error'=>'no id');
	elseif ($user->isAnon())
		return array('ok'=>false,'error'=>'anon cannot delete topic');
	else {

		$topic = new Topic();
		$topic->setId($_GET['topicid_deletetopic']);
		$topic->load();
		if (
		    (!$topic->getUser()->isAnon() && $topic->getUser()->getId() == $user->getId()) ||
		    ($topic->getChannel()->getUser()->getId() == $user->getId())
		   )
		{
			$topic->delete();
			return array('ok'=>true,'error'=>'');
		}
		return array('ok'=>false,'error'=>'you cannot delete this topic');
	}
}
Exemple #2
0
function update_topic()
{
	global $user;
	global $CONF;

//	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);
//		}
//
//	}

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

	$user = $_SESSION['user'];	

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

	//$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 = unescape_ampersand($_POST['msg_update_topic']);
	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']);
	$topic->setMsg($msg);

	if ($topic->save()=='ok'){
		//$topic->follow();
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'problems with this topic');
}
Exemple #3
0
 $count = 0;
 foreach ($fileC as $line) {
     $temp = new Post($line);
     $userId = $temp->getUser()->getUserId();
     $fileC = file("db/Users/" . $userId . ".dat", FILE_IGNORE_NEW_LINES);
     $fileC[4] = trim($fileC[4]) - 1;
     $str = "";
     foreach ($fileC as $temp) {
         $str .= $temp . "\n";
     }
     file_put_contents("db/Users/" . $userId . ".dat", $str);
     $count++;
 }
 //******************************
 $topic = new Topic(file_get_contents("db/Topics/" . $_GET['topicId'] . "/topic.dat", FILE_IGNORE_NEW_LINES));
 $fileC = file("db/Users/" . $topic->getUser()->getUserId() . ".dat", FILE_IGNORE_NEW_LINES);
 $fileC[3] = trim($fileC[3]) - 1;
 $str = "";
 foreach ($fileC as $temp) {
     $str .= $temp . "\n";
 }
 file_put_contents("db/Users/" . $topic->getUser()->getUserId() . ".dat", $str);
 //*******************************
 $fileC = file("db/forumStatistics.dat", FILE_IGNORE_NEW_LINES);
 $fileC[1] = $fileC[1] - 1;
 $fileC[2] = $fileC[2] - $count;
 $str = "";
 foreach ($fileC as $temp) {
     $str .= $temp . "\n";
 }
 file_put_contents("db/forumStatistics.dat", $str);