HEX
Server: Apache
System: Linux c119.dattaweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: c1190199 (57165)
PHP: 7.4.33
Disabled: mail, system, shell, exec, system_exec, shell_exec, mysql_pconnect, passthru, popen, proc_open, proc_close, proc_nice, proc_terminate, proc_get_status, escapeshellarg, escapeshellcmd, eval, dl, imap_mail, libvirt_connect, gnupg_init, unsetenv, apache_setenv, pcntl_exec, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_get_handler, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_getpriority, pcntl_setpriority, pcntl_async_signals, opcache_get_status, opcache_reset, opcache_get_configuration
Upload Files
File: /home/c1190199/public_html/_alex/wp-content/themes/portada/class/Theme.Comment.class.php
<?php

/******************************************************************************/
/******************************************************************************/

class Portada_ThemeComment
{
	
	/**************************************************************************/
	
	function __construct()
	{		
		global $cpage;
		
		if(array_key_exists('cpage',$_GET))
		{
			$this->page=(int)$_GET['cpage']<=0 ? 1 : (int)$_GET['cpage'];
		}
		else $this->page=(int)$cpage<=0 ? 1 : (int)$cpage;
		
		$this->thread_comments=(int)get_option('thread_comments');
		$this->comment_moderation=(int)get_option('comment_moderation') ? 0 : 1;
		$this->comments_per_page=(int)get_option('page_comments')==1 ? (int)get_option('comments_per_page') : -1;
	}
	
	/**************************************************************************/
	
	function addComment()
	{
		global $wpdb;
		$Validation=new Portada_ThemeValidation();
		
		$response=array('error'=>0,'info'=>null,'changeURL'=>'');
		$data=array('author'=>null,'email'=>null,'url'=>null,'comment'=>null,'comment_post_ID'=>0,'comment_parent'=>0);

		foreach($data as $index=>$value) 
		{
			if(array_key_exists($index,$_POST))
				$data[$index]=$_POST[$index];
		}
		
		if(!is_user_logged_in())
		{
			if(($Validation->isEmpty($data['author'])) && (get_option('require_name_email')==1))
			{
				$response['error']=1;
				$response['info'][]=array('fieldId'=>'author','message'=>esc_html__('Please enter your name.','portada'));
			}

			if((!$Validation->isEmailAddress($data['email'])) && (get_option('require_name_email')==1))
			{
				$response['error']=1;	
				$response['info'][]=array('fieldId'=>'email','message'=>esc_html__('Please enter valid e-mail address.','portada'));
			}

			if(!$Validation->isURL($data['url'],true))
			{
				$response['error']=1;	
				$response['info'][]=array('fieldId'=>'url','message'=>esc_html__('Please enter valid URL address.','portada'));
			}
		}
	
		if($Validation->isEmpty($data['comment']))
		{
			$response['error']=1;
			$response['info'][]=array('fieldId'=>'comment','message'=>esc_html__('Please enter your message.','portada'));
		}	
	
		if($response['error']==1) $this->createResponse($response);
		$data=Portada_ThemeHelper::stripslashesPOST($data);
		
		$insertData=array
		(
			'comment_post_ID'		=> (int)$data['comment_post_ID'],
			'comment_content'		=> $data['comment'],
			'comment_parent'		=> (int)$data['comment_parent'],
			'comment_date'			=> current_time('mysql'),
			'comment_approved'		=> $this->comment_moderation
		);

		if(!is_user_logged_in())
		{
			$insertData['comment_author']=$data['author'];
			$insertData['comment_author_url']=Portada_ThemeHelper::addProtocolName($data['url']);
			$insertData['comment_author_email']=$data['email'];
		}
		else
		{
			$user=wp_get_current_user();
			$insertData['comment_author']=$user->display_name;
			$insertData['comment_author_email']=$user->user_email;
		}

		$commentId=wp_insert_comment($insertData);

		if($commentId)	
		{
            do_action('comment_post',$commentId);
			query_posts('p='.(int)$data['comment_post_ID'].'&post_type=any');
			if(have_posts())
			{
				the_post();
				
				if((int)$data['comment_parent']==0 || $this->thread_comments==0)
				{
					$query=$wpdb->prepare('select count(*) as count from '.$wpdb->comments.' where comment_approved=1 and comment_post_ID=%d',(int)get_the_ID()).($this->thread_comments==1 ? " and comment_parent=0" : null);
					$parent=$wpdb->get_row($query);
					
					if($this->comments_per_page>0)
						$_GET['cpage']=ceil($parent->count/$this->comments_per_page);
					else $_GET['cpage']=1;
					
					$response['changeURL']='#cpage-'.$_GET['cpage'];
				}
				else $_GET['cpage']=(int)$_POST['cpage'];
				
				$response['cpage']=(int)$_GET['cpage'];
				$response['commentId']=(int)$commentId;
				
				ob_start();
				comments_template();
				$response['html']=ob_get_contents();
				ob_end_clean();
			}
			
			$response['comment_id']=$commentId;
			
			$response['error']=0;
			$response['info'][]=array('fieldId'=>'submit','message'=>esc_html__('Your comment has been added.','portada'));
		}
		else
		{
			$response['error']=1;
			$response['info'][]=array('fieldId'=>'submit','message'=>esc_html__('Your comment could not be added.','portada'));
		}
		
		$this->createResponse($response);
	}
	
	/**************************************************************************/
	
    function isGPC()
    {
        return((bool)ini_get('magic_quotes_gpc'));
    }

	/**************************************************************************/

    function createResponse($response)
    {
		echo json_encode($response);
        exit;
    }
	
	/**************************************************************************/
	
	function createComment($comment,$args,$depth)
	{
		$ret=null;
		$reply=null;
		
		$GLOBALS['comment']=$comment;
		
		if((int)$comment->comment_parent>0)
		{
			$parent=get_comment($comment->comment_parent);
			
			$reply=
			'
				<h6 class="theme-comment-meta-reply-to">
					<a href="#comment-'.(int)$comment->comment_parent.'">
						<span>'.esc_html__(' to','portada').'</span> '.$parent->comment_author.'
					</a>
				</h6>
			';
		}
		
		$ret.=
		'
			<li '.comment_class('theme-clear-fix',$comment->comment_ID,$comment->comment_post_ID,false).' id="comment-'.$comment->comment_ID.'">
				<div class="theme-comment-inner">
					<div class="theme-comment-avatar">
						'.get_avatar($comment->comment_author_email,80).'
					</div>
					<div class="theme-comment-meta theme-clear-fix">
						<h6 class="theme-comment-meta-author">'.get_comment_author_link().'</h6>
						'.$reply.'
						<br/>
						<div class="theme-comment-meta-date">'.sprintf(esc_html__(' %1$s at %2$s','portada'),get_comment_date(),get_comment_time()).'</div>
						<a class="theme-comment-meta-reply-button theme-button-2" href="#comment-'.(int)$comment->comment_ID.'">'.esc_html__('Reply','portada').'</a>
					</div>
					<div class="theme-comment-content theme-clear-fix">
						<p>'.$this->getCommentContent().'</p>
						<div class="theme-comment-divider"></div>
					</div>
				</div>
		';

		echo $ret;
	}
	
	/**************************************************************************/
	
	function getComment()
	{
		$response=array('html'=>'','cpage'=>$this->page);
		
		query_posts('p='.(int)$_GET['comment_form_post_id'].'&post_type=any&orderby=date&order='.get_option('comment_order'));
		if(have_posts())
		{
			the_post();
			ob_start();
			comments_template();
			$response['html']=ob_get_contents();
			ob_end_clean();
		}

		echo @json_encode($response);
		exit;
	}
	
	/**************************************************************************/
	
	function getCommentContent($commentId=0)
	{
		$comment=get_comment($commentId);
		$content=strip_tags($comment->comment_content);
		$contentArray=explode(' ', $content);
	
		if(count($contentArray)>Portada_ThemeOption::getOption('comment_automatic_excerpt_length'))
		{
			$length=Portada_ThemeOption::getOption('comment_automatic_excerpt_length');
			$useReadMore=true;
		} 
		else 
		{
			$length=count($contentArray);
			$useReadMore=false;
        }
	
        $excerpt='';
		for($i=0;$i<$length;$i++) 
			$excerpt.=$contentArray[$i].' ';
	
		if($useReadMore)
		{
			$content=
			'
				<span class="theme-comment-content-excerpt">'.trim($excerpt).'&nbsp;[&hellip;]&nbsp;</span><a class="theme-comment-content-read-more-link" href="#">'.esc_html__('Read More','portada').'</a><span class="theme-comment-content-content">'.trim($content).'&nbsp;</span><a class="theme-comment-content-read-less-link" href="#">'.esc_html__('Read Less','portada').'</a>
			';
		}
		else $content='<span>'.$content.'</span>';
		
		return($content);	
	}

	/**************************************************************************/
}
	
/******************************************************************************/
/******************************************************************************/