https://t.me/RX1948
Server : Apache/2.4.18 (Ubuntu)
System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64
User : oppastar ( 1041)
PHP Version : 7.0.33-0ubuntu0.16.04.15
Disable Function : 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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Directory :  /var/www/rabbithabit.com/public_html/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/rabbithabit.com/public_html/application/controllers/Product_review.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Product_review extends Public_Controller {

	public function __construct() {
		parent::__construct();
	}

	public function add_review() { 

		if(!isset($_POST['submit_review'])) { show_404(); }

		if($this->session->userdata('customer')['customer_id'] != NULL) {

			//check if this product_id and customer_id already reviewed...
			$this->db->select('product_id, customer_id')
			->from('product_review')
			->where('Product_id', $this->input->post('product_id'))
			->where('customer_id', $this->session->userdata('customer')['customer_id']);
			$count_review = $this->db->get()->num_rows();

			if($count_review == 0) {
				//review not yet...can proceed..
				$data = array(
				'product_id' => $this->input->post('product_id'),
				'customer_id' => $this->session->userdata('customer')['customer_id'],
				'rating' => $this->input->post('rating'),
				'review' => $this->security->xss_clean($this->input->post('review')),
				'subject' => $this->security->xss_clean($this->input->post('subject')),
				'display_name' =>$this->security->xss_clean($this->input->post('display_name'))
			);

			$insert = $this->db->insert('product_review', $data);

			if($insert){
				$jumdata = $this->db->select('*')->from('product_review')->where('product_id', $this->input->post('product_id'))->get()->num_rows();

			    if($jumdata > 0){
			      $start = $this->db->select('sum(rating) as jumrating')->from('product_review')->where('product_id', $this->input->post('product_id'))->get()->row();
			      $tstart = $jumdata.' Review';
			      $jstar = floor($start->jumrating / $jumdata);
			    } else {
			      $tstart = '0 Review';
			      $jstar = 0;
			    }

				$data_rating = array(
					'rating' => $jstar
				);

				$this->db->where('id_products', $this->input->post('product_id'));
				$this->db->update('products', $data_rating); 

				$this->session->set_flashdata('product_review', '<p style="color:green"><strong>ULASAN BERHASIL DITAMBAHKAN</strong><br><br></p>');
			} else {
				$this->session->set_flashdata('product_review', '<p style="color:green"><strong>ULASAN GAGAL DITAMBAHKAN</strong><br><br></p>');
			}

			} else {
				//review already...
				$this->session->set_flashdata('product_review', '<p style="color:green"><strong>ANDA SUDAH PERNAH MENGULAS PRODUK INI</strong><br><br></p>');
			}

			redirect('product/' . $this->input->post('product_alias'));


		}
		
	}

	public function hitungreview(){
		$product = $this->db->select('*')->from('product_review')->group_by('product_id')->get()->result();

		foreach ($product as $value) {
			$jumdata = $this->db->select('*')->from('product_review')->where('product_id', $value->product_id)->get()->num_rows();

		    if($jumdata > 0){
		      $start = $this->db->select('sum(rating) as jumrating')->from('product_review')->where('product_id', $value->product_id)->get()->row();
		      $tstart = $jumdata.' Review';
		      $jstar = floor($start->jumrating / $jumdata);
		    } else {
		      $tstart = '0 Review';
		      $jstar = 0;
		    }

			$data_rating = array(
				'rating' => $jstar
			);

			$this->db->where('id_products', $value->product_id);
			$this->db->update('products', $data_rating);

			echo $value->product_id.' *'.$jstar.' / '.$jumdata.' Review - DONE<br>';
		}
	}
}

https://t.me/RX1948 - 2025