Advertisement
Guest User

Untitled

a guest
Nov 17th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <?php
  2. require ($_SERVER['DOCUMENT_ROOT'] . '/assets/includes/inc.init.php');
  3.  
  4. $username = $_GET['username'];
  5. $password = hash('sha256', $_GET['password']);
  6.  
  7. echo $ecom->userManagement->doLogin($username, $password) == null;
  8.  
  9. Fatal error: Cannot declare class Ecom, because the name is already in use in /var/www/html/core/class.ecom.php on line 19
  10.  
  11. <?php
  12. ini_set('display_errors', 1);
  13. error_reporting(E_ALL);
  14. date_default_timezone_set("UTC");
  15.  
  16. //TODO: Check Session
  17.  
  18. $config = parse_ini_file('config.ini');
  19.  
  20. $mysqli = new mysqli($config['db_host'], $config['db_user'], $config['db_password'], $config['db_name']);
  21.  
  22. /* check connection */
  23. if ($mysqli->connect_errno) {
  24. printf("Connect failed: %sn", $mysqli->connect_error);
  25. exit();
  26. }
  27.  
  28. require($_SERVER['DOCUMENT_ROOT'] . '/core/class.ecom.php');
  29. $ecom = new Ecom($mysqli);
  30.  
  31. //TODO: Move the creation to when an item is added.
  32. $cart = null;
  33.  
  34. if(isset($_COOKIE['cart_key'])) {
  35. $cart = $ecom->cartManagement->getCart($_COOKIE['cart_key']);
  36.  
  37. if(!$cart->check()) {
  38. $cart->delete();
  39. $cart = $ecom->cartManagement->create($_SERVER['REMOTE_ADDR']);
  40. setcookie('cart_key', $cart->key, time()+60*60*24*365, '/', 'domain.com');
  41. }
  42. } else {
  43. $cart = $ecom->cartManagement->create($_SERVER['REMOTE_ADDR']);
  44. setcookie('cart_key', $cart->key, time()+60*60*24*365, '/', 'domain.com');
  45. }
  46.  
  47. $cart->updateExpiration();
  48. ?>
  49.  
  50. require($_SERVER['DOCUMENT_ROOT'] . '/core/class.ecom.php');
  51. $ecom = new Ecom($mysqli);
  52.  
  53. <?php
  54. require ($_SERVER['DOCUMENT_ROOT'] . '/assets/includes/inc.init.php');
  55.  
  56. $type = $_GET['type'];
  57.  
  58. if($type == "add") {
  59. $cart->addItem($_GET['id']);
  60. }
  61.  
  62. else if($type == "remove") {
  63. $cart->removeItem($_GET['id']);
  64. }
  65.  
  66. else if($type == "update") {
  67. $cart->updateItems();
  68. }
  69.  
  70. echo 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement