mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Created a function to check post content
This commit is contained in:
		@@ -109,13 +109,7 @@ class postsController {
 | 
			
		||||
		$kind = $_POST['kind'];
 | 
			
		||||
 | 
			
		||||
		//Get the content of the post
 | 
			
		||||
		if(!isset($_POST['content']))
 | 
			
		||||
			Rest_fatal_error(400, "Please specify the content of the post !");
 | 
			
		||||
		$content = $_POST['content'];
 | 
			
		||||
 | 
			
		||||
		//Check the security of the content
 | 
			
		||||
		if(!checkHTMLstring($content))
 | 
			
		||||
			Rest_fatal_error(400, "Your request has been rejected because it has been considered as unsecure !");
 | 
			
		||||
		$content = getPostContent("content");
 | 
			
		||||
 | 
			
		||||
		//Get the visibility of the post
 | 
			
		||||
		$visibility = $this->getPostVisibilityLevel("visibility");
 | 
			
		||||
@@ -350,6 +344,22 @@ class postsController {
 | 
			
		||||
		return array("success" => "The visibility level has been updated !");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Update the content of a post
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @url POST /posts/update_content
 | 
			
		||||
	 */
 | 
			
		||||
	public function update_content(){
 | 
			
		||||
 | 
			
		||||
		user_login_required();
 | 
			
		||||
		
 | 
			
		||||
		//Get the post ID
 | 
			
		||||
		$postID = $this->getFullAccessPostID("postID");
 | 
			
		||||
 | 
			
		||||
		//Get the post content
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Delete post
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
@@ -346,4 +346,26 @@ function check_youtube_id(string $id) : bool {
 | 
			
		||||
	//The video is considered as valid
 | 
			
		||||
	return TRUE;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get some content (for post actually) from a $_POST request
 | 
			
		||||
 * and check its validity
 | 
			
		||||
 * 
 | 
			
		||||
 * @param string $name The name of the $_POST field
 | 
			
		||||
 * @return string The content of the  post
 | 
			
		||||
 */
 | 
			
		||||
function getPostContent($name){
 | 
			
		||||
 | 
			
		||||
	if(!isset($_POST[$name]))
 | 
			
		||||
		Rest_fatal_error(400, "Please specify some content in '"+$name+"' !");
 | 
			
		||||
	$content = $_POST[$name];
 | 
			
		||||
 | 
			
		||||
	//Check the security of the content
 | 
			
		||||
	if(!checkHTMLstring($content))
 | 
			
		||||
		Rest_fatal_error(400, "Your request has been rejected because it has been considered as unsecure !");
 | 
			
		||||
 | 
			
		||||
	//Return new content
 | 
			
		||||
	return $content;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user