function bind() { //get the leaflet $search = factory::create("search"); $result = $search->search("leaflet", array(array("leaflet_id", "=", $this->leaflet_id), array('live', '=', 1)), 'AND', array(array("party", "inner"))); $leaflet = null; if (count($result) != 1) { throw_404(); } else { $leaflet = $result[0]; } //get images $leaflet_images = $search->search("leaflet_image", array(array("leaflet_id", "=", $this->leaflet_id)), 'AND', null, array(array("sequence", "ASC"))); //get categories $leaflet_categories = $search->search("category", array(array("leaflet_category.leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("leaflet_category", 'inner'))); //get tags $leaflet_tags = $search->search("tag", array(array("leaflet_tag.leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("leaflet_tag", 'inner'))); //get parties attacked $leaflet_parties_attacked = $search->search("party", array(array("leaflet_party_attack.leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("leaflet_party_attack", 'inner'))); //get constituencies $leaflet_constituencies = $search->search("constituency", array(array("leaflet_constituency.leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("leaflet_constituency", 'inner'))); //js $this->onloadscript = "showMap('" . MAP_PROVIDER . "', " . number_format($leaflet->lng, 2) . ", " . number_format($leaflet->lat, 2) . ");"; //assign $this->page_title = $leaflet->title . " (an election leaflet published by " . $leaflet->party_name . ")"; $this->has_map = true; $this->assign("leaflet", $leaflet); $this->assign("leaflet_images", $leaflet_images); $this->assign("leaflet_categories", $leaflet_categories); $this->assign("leaflet_tags", $leaflet_tags); $this->assign("constituency", $leaflet_constituencies[0]); $this->assign("leaflet_parties_attacked", $leaflet_parties_attacked); }
public function index($slug) { $product = \CI::Products()->slug($slug); //echo '<pre>'; print_r($product);exit; if (!$product) { throw_404(); } else { $product->images = json_decode($product->images, true); if ($product->images) { $product->images = array_values($product->images); } else { $product->images = []; } // get documents $data['documents'] = \CI::Products()->get_documents($product->id); //echo \CI::db()->last_query(); print_r($data['documents']);exit; //echo $product->manufacturers;exit; // get parameter of product $data['get_parameters_of_product'] = \CI::Products()->get_parameters_of_product($product->id, $product->primary_category, $product->manufacturers); //echo '<pre>'; print_r($data['documents']);exit; //set product options $data['options'] = \CI::ProductOptions()->getProductOptions($product->id); $data['posted_options'] = \CI::session()->flashdata('option_values'); //get related items $data['related'] = $product->related_products; //create view variable $data['page_title'] = $product->name; $data['meta'] = $product->meta; $data['seo_title'] = !empty($product->seo_title) ? $product->seo_title : $product->name; $data['product'] = $product; //load the view $this->view('product', $data); } }
function bind() { $this->onloadscript = "setupRate();"; //get name $name = session_read("analysis_name"); $tmp = split(' ', $name); $name = $tmp[0]; //get user count $user_count = tableclass_rate_value::user_count(session_read("analysis_email"), false); //get the leaflet $search = factory::create("search"); $result = $search->search("leaflet", array(array("live", "=", 1), array("date_uploaded", ">", STAT_ZERO_DATE)), 'AND', null, array(array('RAND()', 'DESC')), 1); $leaflet = null; if (count($result) != 1) { throw_404(); } else { $leaflet = $result[0]; } //get images $leaflet_images = $search->search("leaflet_image", array(array("leaflet_id", "=", $leaflet->leaflet_id)), 'AND', null, array(array("sequence", "ASC"))); //get rate types $rate_types = $search->search("rate_type", array(array("1", "=", "1"))); //assign $this->page_title = "Rate '" . $leaflet->title . "'"; $this->assign("leaflet", $leaflet); $this->assign("leaflet_images", $leaflet_images); $this->assign("hide_header", true); $this->assign("leaflet_id", $leaflet->leaflet_id); $this->assign("rate_types", $rate_types); $this->assign("name", $name); $this->assign("user_count", $user_count); }
function bind() { //add a cache header //TODO: make this generic and add to config file $expires = 60 * 60 * 5; header("Pragma: public"); header("Cache-Control: maxage=" . $expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); //output $this->reset_smarty(TEMPLATE_DIR . "/api/" . $this->output . ".tpl"); $result = $this->get_data(); // Add JSONP callback. Not sure if urlencode needed - better safe than sorry?? $this->assign('callback', urlencode($this->all_arguments['callback'])); if ($this->method == 'constituency' || $this->method == 'party' || $this->method == 'latest') { if ($this->success) { $this->assign("leaflets", $result); $this->assign("method", $this->method); $this->assign("has_leaflets", count($result) > 0); } else { throw_404(); } } else { $this->assign("result", $result); } }
public function index($slug) { $product = \CI::Products()->slug($slug); if (!$product) { throw_404(); } else { $product->images = json_decode($product->images, true); if ($product->images) { $product->images = array_values($product->images); } else { $product->images = []; } //set product options $data['options'] = \CI::ProductOptions()->getProductOptions($product->id); $data['posted_options'] = \CI::session()->flashdata('option_values'); //get related items $data['related'] = $product->related_products; //create view variable $data['page_title'] = $product->name; $data['meta'] = $product->meta; $data['seo_title'] = !empty($product->seo_title) ? $product->seo_title : $product->name; $data['product'] = $product; //load the view $this->view('product', $data); } }
public function index($slug, $sort = 'id', $dir = "ASC", $page = 0) { \CI::lang()->load('categories'); //define the URL for pagination $pagination_base_url = site_url('category/' . $slug . '/' . $sort . '/' . $dir); //how many products do we want to display per page? //this is configurable from the admin settings page. $per_page = config_item('products_per_page'); //grab the categories $categories = \CI::Categories()->get($slug, $sort, $dir, $page, $per_page); //no category? show 404 if (!$categories) { throw_404(); return; } $categories['sort'] = $sort; $categories['dir'] = $dir; $categories['slug'] = $slug; $categories['page'] = $page; //load up the pagination library \CI::load()->library('pagination'); $config['base_url'] = $pagination_base_url; $config['uri_segment'] = 5; $config['per_page'] = $per_page; $config['num_links'] = 3; $config['total_rows'] = $categories['total_products']; \CI::pagination()->initialize($config); //load the view $this->view('categories/category', $categories); }
public function index($slug = false, $show_title = true) { $page = false; //this means there's a slug, lets see what's going on. foreach ($this->pages['all'] as $p) { if ($p->slug == $slug) { $page = $p; continue; } } if (!$page) { throw_404(); } else { //create view variable $data['page_title'] = false; if ($show_title) { $data['page_title'] = $page->title; } $data['meta'] = $page->meta; $data['seo_title'] = !empty($page->seo_title) ? $page->seo_title : $page->title; $data['page'] = $page; $data['is_home'] = false; //load the view $this->view('page', $data); } }
public function downloadFile($filename) { if ($this->verifyContent($filename)) { \CI::load()->helper('download'); force_download($filename, file_get_contents('uploads/digital_products/' . $filename)); } else { throw_404(); } }
function bind() { $leaflets = $this->get_data(); if ($this->success) { $this->reset_smarty(TEMPLATE_DIR . "/api/" . $this->output . ".tpl"); $this->assign("leaflets", $leaflets); } else { throw_404(); } }
public function orderComplete($orderNumber) { $order = \CI::Orders()->getOrder($orderNumber); $orderCustomer = \CI::Customers()->get_customer($order->customer_id); if ($orderCustomer->is_guest || $orderCustomer->id == $this->customer->id) { $this->view('orderComplete', ['order' => $order]); } else { if (!\CI::Login()->isLoggedIn(false, false)) { redirect('login'); } else { throw_404(); } } }
function bind() { //get the leaflet $search = factory::create("search"); $result = $search->search("leaflet", array(array("leaflet_id", "=", $this->viewstate['leaflet_id']))); $leaflet = null; if (count($result) != 1) { throw_404(); } else { $leaflet = $result[0]; } $this->assign("leaflet", $leaflet); $this->assign("message_sent", $this->viewstate['message_sent']); }
function load() { $upload_key = get_http_var('q'); if (!isset($upload_key) || $upload_key == null) { throw_404(); } else { $search = factory::create('search'); $image_que_items = $search->search("image_que", array(array("upload_key", "=", $upload_key)), "AND", null, array(array("uploaded_date", "ASC"))); if (count($image_que_items) > 0) { redirect(WWW_SERVER . '/addinfo.php?key=' . urlencode($upload_key)); } else { throw_404(); } } }
function setup() { $party_id = get_http_var('p'); if (isset($party_id) && $party_id != '') { $search = factory::create('search'); $results = $search->search_cached('party', array(array('url_id', '=', $party_id))); if (count($results) != 1) { throw_404(); } if ($results[0]->major != 1) { throw_404(); } $this->party = $results[0]; } }
function setup() { $this->confirm_id = get_http_var('q'); if (!isset($this->confirm_id)) { throw_404(); } else { //make sure ID exists $search = factory::create('search'); $results = $search->search("email_alert", array(array("confirm_id", "=", $this->confirm_id), array("activated", '=', 0))); if (count($results) != 1) { throw_404(); } else { $this->email_alert = $results[0]; } } }
function load() { $election_id = get_http_var('id'); if (!isset($election_id)) { throw_404(); } else { $this->election_id = $election_id; $search = factory::create('search'); $result = $search->search("election", array(array("election_id", "=", $this->election_id))); $election_details = null; if (count($result) != 1) { throw_404(); } else { $this->election_details = $result[0]; } } }
function load() { $this->confirm_id = get_http_var('q'); if (!isset($this->confirm_id)) { throw_404(); } else { if ($this->viewstate['state'] != 'deleted') { //make sure ID exists $search = factory::create('search'); $results = $search->search("email_alert", array(array("confirm_id", "=", $this->confirm_id))); if (count($results) != 1) { throw_404(); } else { $this->email_alert = $results[0]; } } } }
function bind() { //get the leaflet $search = factory::create("search"); $result = $search->search("leaflet", array(array("leaflet_id", "=", $this->leaflet_id)), 'AND', array(array("party", "inner"))); $leaflet = null; if (count($result) != 1) { throw_404(); } else { $leaflet = $result[0]; } //get images $leaflet_images = $search->search("leaflet_image", array(array("leaflet_id", "=", $this->leaflet_id)), 'AND', null, array(array("sequence", "ASC"))); //assign $this->page_title = "Full image of " . $leaflet->title . " ( election leaflet published by " . $leaflet->party_name . ")"; $this->assign("leaflet", $leaflet); $this->assign("leaflet_images", $leaflet_images); }
function bind() { //get the leaflet $search = factory::create("search"); $result = $search->search("leaflet", array(array("live", "=", 1)), 'AND', null, array(array('RAND()', 'DESC')), 1); $leaflet = null; if (count($result) != 1) { throw_404(); } else { $leaflet = $result[0]; } //get images $leaflet_images = $search->search("leaflet_image", array(array("leaflet_id", "=", $leaflet->leaflet_id)), 'AND', null, array(array("sequence", "ASC"))); //assign $this->page_title = $leaflet->title; $this->assign("leaflet", $leaflet); $this->assign("leaflet_images", $leaflet_images); $this->assign("leaflet_id", $leaflet->leaflet_id); $this->assign("rate_types", $rate_types); }
public function download($fileId, $orderId) { //get the order. $order = \CI::db()->where('orders.id', $orderId)->join('customers', 'customers.id = orders.customer_id')->get('orders')->row(); $file = \CI::db()->where('order_item_files.id', $fileId)->join('digital_products', 'digital_products.id = order_item_files.file_id')->get('order_item_files')->row(); if ($order && $file) { if ($order->is_guest || $order->customer_id == $this->customer->id) { if ($file->max_downloads == 0 || $file->downloads_used < $file->max_downloads) { \CI::DigitalProducts()->touchDownload($fileId); \CI::DigitalProducts()->downloadFile($file->filename); } } else { //send to login page if (\CI::Login()->isLoggedIn(false, false)) { redirect('login'); } else { throw_404(); } } } else { //move along nothing to see here throw_404(); } }
$image_size = get_http_var('s'); //check vars passed if (!isset($image_id) || $image_size != 't' && $image_size != 'm' && $image_size != 'l' && $image_size != 'o') { throw_404(); } //get file name $file_name = IMAGES_DIR; if ($image_size == 't') { $file_name .= "/thumbnail/"; } if ($image_size == 'm') { $file_name .= "/medium/"; } if ($image_size == 'l') { $file_name .= "/large/"; } /* if($image_size == 'o'){ $file_name .= "/original/"; } */ $file_name .= $image_id . ".jpg"; //check file exists if (file_exists($file_name)) { //output image header('Content-Type: image/jpeg'); $image = imagecreatefromjpeg($file_name); imagejpeg($image); } else { throw_404(); }
private function get_vars() { $search_term = get_http_var("q"); if (isset($search_term) && $search_term != '') { $this->search_term = trim($search_term); } $publisher_party_id = get_http_var("p"); if (isset($publisher_party_id) && $publisher_party_id != '') { $this->leaflet_search->publisher_party_id = trim($publisher_party_id); } $category_id = get_http_var("c"); if (isset($category_id) && $category_id != '') { $this->leaflet_search->category_id = trim($category_id); } $tag = get_http_var("t"); if (isset($tag) && $tag != '') { $this->leaflet_search->tag = trim($tag); } $party_attack_id = get_http_var("a"); if (isset($party_attack_id) && $party_attack_id != '') { $this->leaflet_search->party_attack_id = trim($party_attack_id); } $constituency_url_id = trim(get_http_var("n")); if (isset($constituency_url_id) && $constituency_url_id != '') { $search = factory::create('search'); $results = $search->search_cached('constituency', array(array('url_id', '=', $constituency_url_id))); if (count($results) != 1) { throw_404(); } $this->leaflet_search->constituency_id = $results[0]->constituency_id; } $is_rss = get_http_var("rss"); if (isset($is_rss) && $is_rss != '') { $this->is_rss = true; } }
private function get_vars() { $election_id = get_election_id(); //page count $page = get_http_var("page"); if (isset($page) && is_numeric($page) && $page > 0) { $page = floor($page); } else { $page = 1; } $this->leaflet_search->start = (floor($page) - 1) * PAGE_ITEMS_COUNT; //search term $search_term = get_http_var("q"); if (isset($search_term) && $search_term != '') { $this->search_term = trim($search_term); } $publisher_party_url_id = get_http_var("p"); if (isset($publisher_party_url_id) && $publisher_party_url_id != '') { $search = factory::create('search'); $results = $search->search_cached('party', array(array('url_id', '=', $publisher_party_url_id))); if (count($results) != 1) { throw_404(); } $this->leaflet_search->publisher_party_id = $results[0]->party_id; } $category_id = get_http_var("c"); if (isset($category_id) && $category_id != '') { $this->leaflet_search->category_id = trim($category_id); } $tag = get_http_var("t"); if (isset($tag) && $tag != '') { $this->leaflet_search->tag = trim($tag); } $party_attack_id = get_http_var("a"); if (isset($party_attack_id) && $party_attack_id != '') { $this->leaflet_search->party_attack_id = trim($party_attack_id); } $constituency_url_id = trim(get_http_var("n")); if (isset($constituency_url_id) && $constituency_url_id != '') { $search = factory::create('search'); $results = $search->search_cached('constituency', array(array("url_id", "=", $constituency_url_id), array("constituency_election.election_id", "=", $election_id)), "AND", array(array("constituency_election", "inner"))); if (count($results) != 1) { throw_404(); } $this->leaflet_search->constituency_id = $results[0]->constituency_id; } $is_rss = get_http_var("rss"); if (isset($is_rss) && $is_rss != '') { $this->is_rss = true; } // If RSS, get a different number of items if ($this->is_rss) { $this->leaflet_search->number = RSS_ITEMS_COUNT; } else { $this->leaflet_search->number = PAGE_ITEMS_COUNT; } }
public function init() { $this->load->helper('url'); if (!file_exists(APPPATH . '/config/database.php')) { redirect('install'); exit; } session_start(); //set the session userdata if non-existant if (!isset($_SESSION['userdata'])) { $_SESSION['userdata'] = []; } //set newFlashdata if non-existent if (!isset($_SESSION['newFlashdata'])) { $_SESSION['newFlashdata'] = []; } //empty out the "oldFlashdata" field $_SESSION['oldFlashdata'] = []; //shift newFlashdata over to oldFlashdata $_SESSION['oldFlashdata'] = $_SESSION['newFlashdata']; $_SESSION['newFlashdata'] = []; //module list $GLOBALS['modules'] = []; if (!file_exists(APPPATH . 'config/manifest.php')) { $this->load->helper('file'); $manifest = "<?php defined('BASEPATH') OR exit('No direct script access allowed');\n//DO NOT EDIT THIS FILE\n\n"; $this->classMap = []; $paths = [FCPATH . 'addons', APPPATH . 'modules', APPPATH . 'libraries', APPPATH . 'core']; $paymentModules = []; $shippingModules = []; $themeShortcodes = []; $routes = []; $modules = []; //just modules $moduleDirectories = [APPPATH . 'modules', FCPATH . 'addons']; foreach ($moduleDirectories as $moduleDirectory) { foreach (array_diff(scandir($moduleDirectory), ['..', '.']) as $availableModule) { if (is_dir($moduleDirectory . '/' . $availableModule)) { //create a codeigniter package path to the module. //$this->load->add_package_path($moduleDirectory.'/'.$availableModule); $modules[] = $moduleDirectory . '/' . $availableModule; } } } foreach ($paths as $path) { $dir_iterator = new RecursiveDirectoryIterator($path); $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $file) { if (!is_dir($file)) { $ext = pathinfo($file, PATHINFO_EXTENSION); $filename = pathinfo($file, PATHINFO_FILENAME); if ($ext == 'php') { if ($filename == 'manifest') { include $file; } $this->getPhpClasses((string) $file); } } } } $manifest .= '//ClassMap for autoloader' . "\n" . '$classes = ' . var_export($this->classMap, true) . ';'; $manifest .= "\n\n" . '//Available Payment Modules' . "\n" . '$GLOBALS[\'paymentModules\'] =' . var_export($paymentModules, true) . ';'; $manifest .= "\n\n" . '//Available Shipping Modules' . "\n" . '$GLOBALS[\'shippingModules\'] = ' . var_export($shippingModules, true) . ';'; $manifest .= "\n\n" . '//Theme Shortcodes' . "\n" . '$GLOBALS[\'themeShortcodes\'] = ' . var_export($themeShortcodes, true) . ';'; $manifest .= "\n\n" . '//Complete Module List' . "\n" . '$GLOBALS[\'modules\'] = ' . var_export($modules, true) . ';'; $manifest .= "\n\n" . '//Defined Routes' . "\n" . '$routes = ' . var_export($routes, true) . ';'; //generate the autoload file write_file(APPPATH . 'config/manifest.php', $manifest); } require APPPATH . 'config/manifest.php'; //load in the database. $this->load->database(); //set up routing... $router = new \AltoRouter(); $base = trim($_SERVER['BASE'], '/'); if ($base != '') { $router->setBasePath('/' . $base); } //set the homepage route $router->map('GET|POST', '/', 'GoCart\\Controller\\Page#homepage'); //map the routes from the manifest. foreach ($routes as $route) { $router->map($route[0], $route[1], $route[2]); } foreach ($GLOBALS['modules'] as $module) { $this->load->add_package_path($module); } //autoloader for Modules spl_autoload_register(function ($class) use($classes) { if (isset($classes[$class])) { include $classes[$class]; } }); //autoload some libraries here. $this->load->model('Settings'); $this->load->library(['session', 'auth', 'form_validation']); $this->load->helper(['file', 'string', 'html', 'language', 'form', 'formatting']); //get settings from the DB $settings = $this->Settings->get_settings('gocart'); //loop through the settings and set them in the config library foreach ($settings as $key => $setting) { //special for the order status settings if ($key == 'order_statuses') { $setting = json_decode($setting, true); } //other config items get set directly to the config class $this->config->set_item($key, $setting); } date_default_timezone_set(config_item('timezone')); //if SSL is enabled in config force it here. if (config_item('ssl_support') && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off')) { $this->config->set_item('base_url', str_replace('http://', 'https://', config_item('base_url'))); redirect(\CI::uri()->uri_string()); } //do we have a dev username & password in place? //if there is a username and password for dev, require them if (config_item('stage_username') != '' && config_item('stage_password') != '') { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Login to restricted area"'); header('HTTP/1.0 401 Unauthorized'); echo config_item('company_name') . ' Restricted Location'; exit; } else { if (config_item('stage_username') != $_SERVER['PHP_AUTH_USER'] || config_item('stage_password') != $_SERVER['PHP_AUTH_PW']) { header('WWW-Authenticate: Basic realm="Login to restricted area"'); header('HTTP/1.0 401 Unauthorized'); echo 'Restricted Location'; exit; } } } // lets run the routes $match = $router->match(); // call a closure if ($match && is_callable($match['target'])) { call_user_func_array($match['target'], $match['params']); } elseif ($match && is_string($match['target'])) { $target = explode('#', $match['target']); try { $class = new $target[0](); call_user_func_array([$class, $target[1]], $match['params']); } catch (Exception $e) { var_dump($e); throw_404(); } } else { throw_404(); } }