403Webshell
Server IP : 195.130.67.5  /  Your IP : 216.73.216.231
Web Server : Microsoft-IIS/10.0
System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586
User : IUSR ( 0)
PHP Version : 7.4.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/inetpub/wwwroot/Civil/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/inetpub/wwwroot/Civil/includes/Comments.php
<?
////////////////////////////////////////////////////////////////////////////////////////
// Class: Comments
// Purpose: Κλάση σχολίων άρθρων
///////////////////////////////////////////////////////////////////////////////////////

class Comments
{
	private $connector;
	private $system;

	public function __construct($db, $system)
	{
		$this->connector = $db;
		$this->system = $system;
	}

	// Άντληση σχολίου με το δοσμένο id
	public function getCommentById($id)
	{
		$result = $this->connector->query("SELECT * FROM comments WHERE id=$id");
		return $this->connector->fetchArray($result);	
	}

	// Άντληση σχολίων για δεδομένο άρθρο (αν δοθεί $content_id=0 επιστρέφει όλα τα σχόλια όλων των άρθρων).
	// Έχει τη δυνατότητα και για αναδρομική άντληση των δεδομένων έτσι ώστε αμέσως μετά από ένα σχόλιο να ακολουθούν όλες οι απαντήσεις και οι απαντήσεις των απαντήσεων κ.ο.κ.
	public function getCommentsByContentId($content_id, $table_ordering="created", $order_type="ASC", $state=1, $recursive=true, $parent_id=0, $depth=0)
	{
		$comments_array = array();
		$children_array = array();

		$where = array();
		
		if (!empty($content_id))
			$where[] = "content_id=".$content_id;

		if ($state==0 or $state==1)
			$where[] = "state=".$state;
		
		if ($recursive==true)
		{
			$where[] = "parent_id=".$parent_id;
		}

		if (count($where)>0)
		{
			$where = "WHERE ".implode(" and ", $where);
		}
		else
		{
			$where = "";
		}

		$result = $this->connector->query("SELECT * FROM comments $where ORDER BY ".$table_ordering." ".$order_type);

		while ($myrow = $this->connector->fetchArray($result))
		{		
			$myrow["depth"] = $depth;
			$comments_array[] = $myrow;
			
			if ($recursive==true)
			{
				$children_array = $this->getCommentsByContentId($content_id, $table_ordering, $order_type, $state, $recursive, $myrow["id"], ($depth+1));
				
				if (count($children_array)>0)
					$comments_array = array_merge($comments_array, $children_array);
			}
		}
		
		return $comments_array;
	}

	// Εισάγει στη βάση νέο σχόλιο
	public function insertComment($parent_id, $content_id, $userid, $name, $email, $homepage, $comment, $ip, $created, $state)
	{
		$sql = "INSERT INTO comments (parent_id, content_id, userid, name, email, homepage, comment, ip, created, state) VALUES ($parent_id,$content_id,$userid,'$name','$email','$homepage','$comment','$ip','$created',$state)";

		$result = $this->connector->query($sql);
		return $result;
	}

	// Ενημερώνει ένα ήδη υπάρχον άρθρο ή σύνδεσμο
	public function updateComment($id, $comment)
	{
		$sql = "UPDATE comments SET comment='$comment' WHERE id=$id";

		$result = $this->connector->query($sql);
		return $result;
	}

	// Διαγράφει το περιεχόμενο με το συγκεκριμένο id
	public function deleteComment($id)
	{
		$result = $this->connector->query("DELETE FROM comments WHERE id=$id");
		return $result;
	}

	// Εναλλάσει τη κατάσταση (ενεργό/ανενεργό) του σχολίου το συγκεκριμένο id
	public function toggleCommentState($id)
	{
		$myrow = $this->getCommentById($id);
		
		if ($myrow["state"]==1)
			$new_state = 0;
		else
			$new_state = 1;

		$result = $this->connector->query("UPDATE comments SET state='$new_state' WHERE id=".$myrow["id"]);
		return $result;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit