public function loginCustomer($email, $password, $remember = false) { $customer = CI::db()->where('is_guest', 0)->where('email', $email)->where('active', 1)->where('password', $password)->limit(1)->get('customers')->row(); if ($customer && !(bool) $customer->is_guest) { // Set up any group discount if ($customer->group_id != 0) { $group = CI::Customers()->get_group($customer->group_id); if ($group) { $customer->group = $group; } } if ($remember) { $loginCred = json_encode(array('email' => $customer->email, 'password' => $customer->password)); $loginCred = base64_encode($this->aes256Encrypt($loginCred)); //remember the user for 6 months $this->generateCookie($loginCred, strtotime('+6 months')); } //combine cart items if ($this->customer()) { $oldCustomer = $this->customer(); CI::session()->set_userdata('customer', $customer); \GC::combineCart($oldCustomer); // send the logged-in customer data } return true; } else { return false; } }
public static function instance() { if (!self::$i) { self::$i = new GoCart(); } return self::$i; }
public function getTaxes() { $rate = $this->getTaxRate(); $orderPrice = GC::getTaxableTotal(); //send the price of the taxes back return round($orderPrice * $rate, 2); }
public function getProduct($id) { //do this again right here since it can be used for combining the cart. We want to make sure it's fresh. $this->customer = \GC::getCustomer(); //find the product $product = CI::db()->select('*, saleprice_' . $this->customer->group_id . ' as saleprice, price_' . $this->customer->group_id . ' as price')->where('id', $id)->where('enabled_' . $this->customer->group_id, '1')->get('products')->row(); $product = $this->processImageDecoding($product); return $product; }
function processPayment() { $errors = \GC::checkOrder(); if (count($errors) > 0) { echo json_encode(['errors' => $errors]); return false; } else { $payment = ['order_id' => \GC::getAttribute('id'), 'amount' => \GC::getGrandTotal(), 'status' => 'processed', 'payment_module' => 'Cod', 'description' => lang('charge_on_delivery')]; \CI::Orders()->savePaymentInfo($payment); $orderId = \GC::submitOrder(); //send the order ID echo json_encode(['orderId' => $orderId]); return false; } }
public function cambiarImagenUsuario() { $file = $_FILES['uploadedfile']; $id = $_POST['id']; $ruta = __DIR__ . "/../assets/img/users/"; try { $res = GC::subirImagen($file, $id, $ruta); print "Archivo subido exitosamente a: " . $res; $extension = explode('.', $res)[1]; $newName = Usuario::actualizarImagen($id, $extension); if (rename($ruta . $res, $ruta . $newName)) { print " Se renombro exisotosamente. '" . explode('.', $res)[0] . "'"; } else { print "ERROR"; } } catch (Exception $e) { print "ERROR: " . $e->getMessage() . '<br>'; } sleep(4); header("Location: usuarios"); }
public function submitGiftCard() { //get the giftcards from the database $giftCard = \CI::GiftCards()->getGiftCard(\CI::input()->post('gift_card')); if (!$giftCard) { echo json_encode(['error' => lang('gift_card_not_exist')]); } else { //does the giftcard have any value left? if (\CI::GiftCards()->isValid($giftCard)) { $message = \GC::addGiftCard($giftCard); if ($message['success']) { \GC::saveCart(); echo json_encode(['message' => lang('gift_card_balance_applied')]); } else { echo json_encode($message); } } else { echo json_encode(['error' => lang('gift_card_zero_balance')]); } } }
//reprocess $.each(checks, function(key, val) { $('#cartItem-'+key).addClass('errorAlert').prepend('<div class="summaryStockAlert">'+val+'</div>'); }); } setInventoryErrors(inventoryCheck); updateItemCount(<?php echo GC::totalItems(); ?> ); var closeBtn = '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'; var newGrandTotalTest = <?php echo GC::getGrandTotal() > 0 ? 1 : 0; ?> ; if(newGrandTotalTest != grandTotalTest) { getPaymentMethods(); grandTotalTest = newGrandTotalTest; //reset grand total test. } $('.quantityInput').bind('blur keyup', function(e){ if(e.type === 'blur' || e.which === 13) { updateItem($(this).attr('data-product-id'), $(this).val(), $(this).attr('data-orig-val')); } }).bind('focus', function(e){ lastInput = $(this);
<h3><?php echo lang('payment_methods'); ?> </h3> </div> <?php if (count($modules) == 0) { ?> <div class="alert alert-danger" role="alert"> <?php echo lang('error_no_payment_method'); ?> </div> <?php } elseif (GC::getGrandTotal() == 0) { ?> <div class="alert alert-danger" role="alert"> <?php echo lang('no_payment_needed'); ?> </div> <button class="btn btn-main" onclick="SubmitNoPaymentOrder()"><?php echo lang('submit_order'); ?> </button> <script> function SubmitNoPaymentOrder() {
public function index($offset = 0) { //make sure they're logged in \CI::Login()->isLoggedIn('my-account'); $data['customer'] = (array) \CI::Customers()->get_customer($this->customer->id); $data['addresses'] = \CI::Customers()->get_address_list($this->customer->id); $data['customer_addresses'] = \CI::Customers()->get_address_list($this->customer->id); // load other page content //\CI::load()->model('banner_model'); \CI::load()->helper('directory'); \CI::load()->helper('date'); // paginate the orders \CI::load()->library('pagination'); $config['base_url'] = site_url('my_account'); $config['total_rows'] = \CI::Orders()->countCustomerOrders($this->customer->id); $config['per_page'] = '15'; $config['first_link'] = 'First'; $config['first_tag_open'] = '<li>'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last'; $config['last_tag_open'] = '<li>'; $config['last_tag_close'] = '</li>'; $config['full_tag_open'] = '<div class="pagination"><ul>'; $config['full_tag_close'] = '</ul></div>'; $config['cur_tag_open'] = '<li class="active"><a href="#">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li>'; $config['num_tag_close'] = '</li>'; $config['prev_link'] = '«'; $config['prev_tag_open'] = '<li>'; $config['prev_tag_close'] = '</li>'; $config['next_link'] = '»'; $config['next_tag_open'] = '<li>'; $config['next_tag_close'] = '</li>'; \CI::pagination()->initialize($config); $data['orders_pagination'] = \CI::pagination()->create_links(); $data['orders'] = \CI::Orders()->getCustomerOrders($this->customer->id, $offset); //print_r($offset); \CI::load()->library('form_validation'); // \CI::form_validation()->set_rules('company', 'lang:address_company', 'trim|max_length[128]'); \CI::form_validation()->set_rules('firstname', 'lang:address_firstname', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('lastname', 'lang:address_lastname', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('email', 'lang:address_email', ['trim', 'required', 'valid_email', 'max_length[128]', ['check_email_callable', function ($str) { return $this->check_email($str); }]]); \CI::form_validation()->set_rules('phone', 'lang:address_phone', 'trim|required|max_length[32]'); \CI::form_validation()->set_rules('email_subscribe', 'lang:account_newsletter_subscribe', 'trim|numeric|max_length[1]'); if (\CI::input()->post('password') != '' || \CI::input()->post('confirm') != '') { \CI::form_validation()->set_rules('password', 'Password', 'required|min_length[6]|sha1'); \CI::form_validation()->set_rules('confirm', 'Confirm Password', 'required|matches[password]'); } else { \CI::form_validation()->set_rules('password', 'Password'); \CI::form_validation()->set_rules('confirm', 'Confirm Password'); } if (\CI::form_validation()->run() == FALSE) { $this->view('my_account', $data); } else { $customer = []; $customer['id'] = $this->customer->id; // $customer['company'] = \CI::input()->post('company'); $customer['firstname'] = \CI::input()->post('firstname'); $customer['lastname'] = \CI::input()->post('lastname'); $customer['email'] = \CI::input()->post('email'); $customer['phone'] = \CI::input()->post('phone'); $customer['email_subscribe'] = intval((bool) \CI::input()->post('email_subscribe')); if (\CI::input()->post('password') != '') { $customer['password'] = \CI::input()->post('password'); } \GC::save_customer($this->customer); \CI::Customers()->save($customer); \CI::session()->set_flashdata('message', lang('message_account_updated')); redirect('my-account'); } }
public function repriceItems() { $this->getCart(true); // refresh the cart and items again. $options = CI::Orders()->getItemOptions(GC::getCart()->id); foreach ($this->items as $item) { if ($item->type == 'product') { //grab the product from the database $product = \CI::Products()->getProduct($item->product_id); if (empty($product)) { //product can no longer be found. remove it $this->removeItem($item->id); continue; } //Clean up the product for the orderItems database $product = $this->cleanProduct($product); $totalPrice = 0; if ($product->{'saleprice_' . $this->customer->group_id} > 0) { //if it's on sale, give it the sale price $totalPrice = $product->{'saleprice_' . $this->customer->group_id}; } else { //not on sale give it the normal price $totalPrice = $product->{'price_' . $this->customer->group_id}; } if (isset($options[$item->id])) { foreach ($options[$item->id] as $option) { $totalPrice += $option->price; } } $product->id = $item->id; $product->hash = $item->hash; $product->total_price = $totalPrice; //updated price \CI::Orders()->saveItem((array) $product); } } $this->getCart(true); // refresh the cart and items just one more time. }
<li><a href="<?php echo site_url('login'); ?> "><?php echo lang('login'); ?> </a></li> <?php } ?> <li> <a href="<?php echo site_url('checkout'); ?> "><i class="icon-cart"></i>(<span id="itemCount"><?php echo GC::totalItems(); ?> </span>)</a> </li> </ul> </nav> <!-- <?php echo form_open('search', 'class="navbar-search pull-right"'); ?> <div class="btn-group"> <div><input type="text" name="term" class="search-query" placeholder="<?php echo lang('search'); ?> "/></div>
/** * Return true if a transform exists at the location for a file. * * @param AssetFileModel $file * @param $location * @return mixed */ public function transformExists(AssetFileModel $file, $location) { $this->_prepareForRequests(); return (bool) @$this->_googleCloud->getObjectInfo($this->getSettings()->bucket, $this->_getPathPrefix() . $file->getFolder()->fullPath . $location . '/' . $file->filename); }
/** * Prepare the S3 connection for requests to this bucket. * * @param $settings * * @return null */ private function _prepareForRequests($settings = null) { if (is_null($settings)) { $settings = $this->getSettings(); } if (is_null($this->_googleCloud)) { $this->_googleCloud = new \GC($settings->keyId, $settings->secret); } \GC::setAuth($settings->keyId, $settings->secret); }
<td> <?php echo format_address($a, true); ?> </td> <td> <label><?php $checked = GC::getCart()->billing_address_id == $a['id'] ? true : false; echo form_radio(['name' => 'billing_address', 'value' => $a['id'], 'checked' => $checked]); echo lang('billing'); ?> </label> </td> <td> <label><?php $checked = GC::getCart()->shipping_address_id == $a['id'] ? true : false; echo form_radio(['name' => 'shipping_address', 'value' => $a['id'], 'checked' => $checked]); ?> <?php echo lang('shipping'); ?> </label> </td> <td> <i class="fa fa-pencil fa-lg text-white-blue" onclick="editAddress(<?php echo $a['id']; ?> )"></i> <i class="fa fa-times fa-lg text-red" onclick="deleteAddress(<?php echo $a['id']; ?>
<?php session_start(); header("Content-Type: text/html;charset=utf-8"); require_once 'connection.php'; require_once 'controllers/GlobalController.php'; if (isset($_GET['controller']) && isset($_GET['action'])) { GC::$controller = $_GET['controller']; GC::$action = $_GET['action']; } else { GC::$controller = 'main'; GC::$action = 'main'; } // if(isset($_GET['lang'])){ // GC::$lang = $_GET['lang']; // }else{ GC::$lang = 'es'; // } $_SESSION['action'] = GC::$action; require_once 'routes.php';
/** * This function assists with freeing, releasing, and resetting unmanaged * resources. * * @access public * @override * @param boolean $disposing whether managed resources can be disposed * in addition to unmanaged resources */ public function dispose($disposing = TRUE) { if (!$this->disposed) { unset($this->adaptors); unset($this->aliases); unset($this->fields); unset($this->relations); if ($disposing) { GC::collect(); } $this->disposed = TRUE; } }
public static function obtUsuario($id) { $db = Db::getInstance(); $req = $db->prepare('SELECT usuario.foto as foto, usuario.nombre as nombre, tipousuario.tipoUsuario as tipo FROM usuario INNER JOIN tipousuario on tipousuario.idTipoUsuario = usuario.idTipoUsuario WHERE idUsuario = :id'); $req->execute(array('id' => $id)); return GC::arrayToObject($req->fetch()); }
public function setShippingMethod() { $rates = \GC::getShippingMethodOptions(); $hash = \CI::input()->post('method'); foreach ($rates as $key => $rate) { $test = md5(json_encode(['key' => $key, 'rate' => $rate])); if ($hash == $test) { \GC::setShippingMethod($key, $rate, $hash); //save the cart \GC::saveCart(); echo json_encode(['success' => true]); return false; } } echo json_encode(['error' => lang('shipping_method_is_no_longer_valid')]); }
public function __construct() { parent::__construct(); }
/** * Get the S3 response * @param $url override the target URL * * @return object | false */ public function getResponse($url = '') { $query = ''; if (sizeof($this->parameters) > 0) { $query = substr($this->uri, -1) !== '?' ? '?' : '&'; foreach ($this->parameters as $var => $value) { if ($value == null || $value == '') { $query .= $var . '&'; } else { $query .= $var . '=' . rawurlencode($value) . '&'; } } $query = substr($query, 0, -1); $this->uri .= $query; if (array_key_exists('acl', $this->parameters) || array_key_exists('location', $this->parameters) || array_key_exists('torrent', $this->parameters) || array_key_exists('website', $this->parameters) || array_key_exists('logging', $this->parameters)) { $this->resource .= $query; } } if (empty($url)) { $url = (GC::$useSSL ? 'https://' : 'http://') . ($this->headers['Host'] !== '' ? $this->headers['Host'] : $this->endpoint) . $this->uri; } //var_dump('bucket: ' . $this->bucket, 'uri: ' . $this->uri, 'resource: ' . $this->resource, 'url: ' . $url); // Basic setup $curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, 'S3/php'); if (GC::$useSSL) { // SSL Validation can now be optional for those with broken OpenSSL installations curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, GC::$useSSLValidation ? 1 : 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, GC::$useSSLValidation ? 1 : 0); if (GC::$sslKey !== null) { curl_setopt($curl, CURLOPT_SSLKEY, GC::$sslKey); } if (GC::$sslCert !== null) { curl_setopt($curl, CURLOPT_SSLCERT, GC::$sslCert); } if (GC::$sslCACert !== null) { curl_setopt($curl, CURLOPT_CAINFO, GC::$sslCACert); } } curl_setopt($curl, CURLOPT_URL, $url); if (GC::$proxy != null && isset(GC::$proxy['host'])) { curl_setopt($curl, CURLOPT_PROXY, GC::$proxy['host']); curl_setopt($curl, CURLOPT_PROXYTYPE, GC::$proxy['type']); if (isset(GC::$proxy['user'], GC::$proxy['pass']) && GC::$proxy['user'] != null && GC::$proxy['pass'] != null) { curl_setopt($curl, CURLOPT_PROXYUSERPWD, sprintf('%s:%s', GC::$proxy['user'], GC::$proxy['pass'])); } } // Headers $headers = array(); $amz = array(); foreach ($this->amzHeaders as $header => $value) { if (strlen($value) > 0) { $headers[] = $header . ': ' . $value; } } foreach ($this->headers as $header => $value) { if (strlen($value) > 0) { $headers[] = $header . ': ' . $value; } } // Collect AMZ headers for signature foreach ($this->amzHeaders as $header => $value) { if (strlen($value) > 0) { $amz[] = strtolower($header) . ':' . $value; } } // AMZ headers must be sorted if (sizeof($amz) > 0) { //sort($amz); usort($amz, array(&$this, '__sortMetaHeadersCmp')); $amz = "\n" . implode("\n", $amz); } else { $amz = ''; } if (GC::hasAuth()) { // Authorization string (CloudFront stringToSign should only contain a date) if ($this->headers['Host'] == 'cloudfront.amazonaws.com') { $headers[] = 'Authorization: ' . GC::__getSignature($this->headers['Date']); } else { $headers[] = 'Authorization: ' . GC::__getSignature($this->verb . "\n" . $this->headers['Content-MD5'] . "\n" . $this->headers['Content-Type'] . "\n" . $this->headers['Date'] . $amz . "\n" . $this->resource); } } curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, false); curl_setopt($curl, CURLOPT_WRITEFUNCTION, array(&$this, '__responseWriteCallback')); curl_setopt($curl, CURLOPT_HEADERFUNCTION, array(&$this, '__responseHeaderCallback')); //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // Request types switch ($this->verb) { case 'GET': break; case 'PUT': case 'POST': // POST only used for CloudFront if ($this->fp !== false) { curl_setopt($curl, CURLOPT_PUT, true); curl_setopt($curl, CURLOPT_INFILE, $this->fp); if ($this->size >= 0) { curl_setopt($curl, CURLOPT_INFILESIZE, $this->size); } } elseif ($this->data !== false) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb); curl_setopt($curl, CURLOPT_POSTFIELDS, $this->data); } else { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $this->verb); } break; case 'HEAD': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD'); curl_setopt($curl, CURLOPT_NOBODY, true); break; case 'DELETE': curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); break; default: break; } // Execute, grab errors if (curl_exec($curl)) { $this->response->code = curl_getinfo($curl, CURLINFO_HTTP_CODE); } else { $this->response->error = array('code' => curl_errno($curl), 'message' => curl_error($curl), 'resource' => $this->resource); } // workaround so we can avoid using CURLOPT_FOLLOWLOCATION, since some hosts disable it if ($this->response->code == '301' or $this->response->code == '302') { static $redirect_count = 0; if (++$redirect_count > 5) { throw new Exception('Redirect error for S3 library'); } $info = curl_getinfo($curl); if (!empty($info['redirect_url'])) { return $this->getResponse($info['redirect_url']); } } @curl_close($curl); // Parse body into XML if ($this->response->error === false && isset($this->response->headers['type']) && ($this->response->headers['type'] == 'application/xml' || $this->response->headers['type'] == 'application/xml; charset=UTF-8') && isset($this->response->body)) { $this->response->body = simplexml_load_string($this->response->body); // Grab S3 errors if (!in_array($this->response->code, array(200, 204, 206)) && isset($this->response->body->Code, $this->response->body->Message)) { $this->response->error = array('code' => (string) $this->response->body->Code, 'message' => (string) $this->response->body->Message); if (isset($this->response->body->Resource)) { $this->response->error['resource'] = (string) $this->response->body->Resource; } unset($this->response->body); } } // Clean up file resources if ($this->fp !== false && is_resource($this->fp)) { fclose($this->fp); } return $this->response; }
<div> <h3><?php echo lang('shipping'); ?> </h3> </div> <?php if ($requiresShipping) { ?> <div class="shippingError"></div> <table class="table"> <?php $selectedShippingMethod = \GC::getShippingMethod(); foreach ($rates as $key => $rate) { $hash = md5(json_encode(['key' => $key, 'rate' => $rate])); ?> <tr onclick="$(this).find('input').prop('checked', true).trigger('change');"> <td style="width:20px;"><input type="radio" name="shippingMethod" value="<?php echo $hash; ?> " <?php echo is_object($selectedShippingMethod) && $hash == $selectedShippingMethod->description ? 'checked' : ''; ?> ></td> <td><?php echo $key; ?> </td> <td><?php echo format_currency($rate);