public function detail() { $this->data['title'] = lang('heading_title'); $parameters = $this->uri->uri_to_assoc(4); if (sizeof($parameters) > 0 && isset($parameters['product_id']) && $parameters['product_id'] > 0) { $this->data['contact_link'] = base_url() . 'pages/contact'; $this->load->model('tool/image_model'); $this->load->helper('number_format'); $product = $this->product_model->getProduct($parameters['product_id']); $img_small = $this->image_model->resize($product['image'], $this->session->userdata('config_image_additional_width'), $this->session->userdata('config_image_additional_height')); $img_normal = $this->image_model->resize($product['image'], $this->session->userdata('config_image_product_width'), $this->session->userdata('config_image_product_height')); $img_large = $this->image_model->resize($product['image'], $this->session->userdata('config_image_popup_width'), $this->session->userdata('config_image_popup_height')); $this->data['product'] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'price' => format_decimal($product['price']), 'size' => $product['size'], 'color' => $product['color'], 'quantity' => $product['quantity'], 'viewed' => $product['viewed'], 'rating' => $product['rating'], 'stock_status' => $product['stock_status'], 'description' => $product['description'], 'small' => $img_small, 'normal' => $img_normal, 'large' => $img_large, 'href' => base_url() . 'pages/product/detail/product_id/' . $product['product_id']); // additional $this->data['product_images'] = array(); $product_images = $this->product_model->getProductImages($parameters['product_id']); foreach ($product_images as $product_img) { if ($product_img['image'] != 'no_image.jpg') { $img_name_arr = explode("/", $product_img['image']); $this->data['product_images'][] = array('name' => $img_name_arr[1], 'small' => $this->image_model->resize($product_img['image'], $this->session->userdata('config_image_additional_width'), $this->session->userdata('config_image_additional_height')), 'normal' => $this->image_model->resize($product_img['image'], $this->session->userdata('config_image_product_width'), $this->session->userdata('config_image_product_height')), 'large' => $this->image_model->resize($product_img['image'], $this->session->userdata('config_image_popup_width'), $this->session->userdata('config_image_popup_height'))); } } // related $this->data['related_products'] = array(); $related_products = $this->product_model->getProductRelated($parameters['product_id']); foreach ($related_products as $related_product) { $image_name_arr = explode("/", $related_product['image']); $this->data['related_products'][] = array('product_id' => $related_product['product_id'], 'name' => $related_product['name'], 'price' => format_decimal($related_product['price']), 'href' => base_url() . 'pages/product/detail/product_id/' . $related_product['product_id'], 'image' => $this->image_model->resize($related_product['image'], $this->session->userdata('config_image_related_width'), $this->session->userdata('config_image_related_height')), 'atl' => $image_name_arr[1]); } // update viewed $this->product_model->updateViewed($parameters['product_id']); // create captcha $this->data['captcha'] = createCaptcha('captcha_review' . $product['product_id']); // review action $this->data['review_action'] = base_url() . 'pages/product/ajaxReview'; // get review data $this->load->model('catalog/review_model'); $this->data['reviews'] = $this->review_model->getReviewsByProductId($parameters['product_id']); if (isset($this->error['name'])) { $this->data['error_name'] = $this->error['name']; } else { $this->data['error_name'] = ''; } if (isset($this->error['review'])) { $this->data['error_review'] = $this->error['review']; } else { $this->data['error_review'] = ''; } if (isset($this->error['captcha'])) { $this->data['error_captcha'] = $this->error['captcha']; } else { $this->data['error_captcha'] = ''; } } $this->template->build('template/product', $this->data); }
public function index() { $this->data['title'] = lang('heading_title'); $this->load->model('tool/image_model'); $this->data['banners'][] = $this->image_model->resize('data/banner/banner3.jpg', 940, 333); $this->data['banners'][] = $this->image_model->resize('data/banner/banner2.jpg', 940, 333); $this->data['banners'][] = $this->image_model->resize('data/banner/banner1.jpg', 940, 333); // Owner information $this->data['config_name'] = $this->session->userdata('config_name'); $this->data['config_address'] = $this->session->userdata('config_address'); $this->data['config_email'] = $this->session->userdata('config_email'); $this->data['config_telephone'] = $this->session->userdata('config_telephone'); // Generator captcha if (!$this->error) { $this->data['captcha'] = createCaptcha('captcha_contact'); $this->session->set_userdata('captcha_img', $this->data['captcha']); } else { $this->data['captcha'] = $this->session->userdata('captcha_img'); } // Action $this->data['action'] = base_url() . 'pages/contact/register'; if (isset($this->error['name'])) { $this->data['error_name'] = $this->error['name']; } else { $this->data['error_name'] = ''; } if (isset($this->error['email'])) { $this->data['error_email'] = $this->error['email']; } else { $this->data['error_email'] = ''; } if (isset($this->error['title'])) { $this->data['error_title'] = $this->error['title']; } else { $this->data['error_title'] = ''; } if (isset($this->error['content'])) { $this->data['error_content'] = $this->error['content']; } else { $this->data['error_content'] = ''; } if (isset($this->error['captcha'])) { $this->data['error_captcha'] = $this->error['captcha']; } else { $this->data['error_captcha'] = ''; } $this->template->build('template/contact', $this->data); }
$mail->assign('email', $email); $mail->assign('newstopic', $sTopic); $mail->assign('newstext', $newstext); $mail->send(); } sql_free_result($rs); // erfolg anzeigen $tpl->display(); exit; } if ($emailok != true) { $tpl->assign('email_error', 1); } if ($captchaok != true) { $tpl->assign('captcha_error', 1); } } $tpl->assign('newstext', $newstext); $tpl->assign('newshtml', $newshtml); $tpl->assign('email', $email); $tpl->assign('topic', $topicid); // topics erstellen $rs = sql("SELECT `id`, `name` FROM `news_topics` ORDER BY `id` ASC"); $tpl->assign_rs('newsTopics', $rs); sql_free_result($rs); // captcha $captcha = createCaptcha(); $tpl->assign('captcha_id', $captcha['id']); $tpl->assign('captcha_filename', $captcha['filename']); //make the template and send it out $tpl->display();
<?php @session_start(); function createCaptcha() { $md5_hash = md5(rand(0, 999)); $security_code = substr($md5_hash, 15, 6); $_SESSION['captcha'] = $security_code; $width = 110; $height = 35; $image = imagecreate($width, $height); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 222, 26, 76); imagefill($image, 0, 0, $black); imagestring($image, 5, 30, 6, $security_code, $white); header("Content-Type: image/jpeg"); imagejpeg($image); imagedestroy($image); } createCaptcha(); ?> ?>