public function insertOrUpdateProduct($post) { parent::createConnection(); $house_no = $post['house_no']; $street_name = parent::getEscaped($post['street_name']); $apartment_no = parent::getEscaped($post['apartment_no']); $city = parent::getEscaped(ucwords($post['city'])); $state = $post['state']; $country = $post['country']; $zip = strtoupper($post['zip']); $type = $post['range']; $description = parent::getEscaped($post['description']); $room_no = $post['rooms']; $bath_no = $post['bathrooms']; $living_room_no = $post['living_rooms']; $price = parent::getEscaped($post['price']); $rangeType = $post['rangeType']; $loginObj = new Login(); $user_id = $loginObj->getUserId(); if (isset($post['upload']) && isset($_FILES['files'])) { $query1 = "INSERT INTO address_info VALUES (DEFAULT, '{$house_no}', '{$street_name}', '{$apartment_no}', '{$city}', '{$state}', '{$zip}', '{$country}')"; parent::executeSqlQuery($query1); $addressId = parent::getLastId(); $query = "INSERT INTO dwellings VALUES (DEFAULT, '{$addressId}', '{$user_id}', '{$type}', '{$description}', '{$room_no}', '{$bath_no}', '{$living_room_no}', '{$price}', '{$rangeType}')"; parent::executeSqlQuery($query); $this->uploadImages($_FILES); } elseif (isset($post['update'])) { $dwelling_Id = $post['hiddenID']; $address_id = $this->getAddressId($dwelling_Id); $updateDwellings = "UPDATE dwellings SET type \t\t \t\t= '{$type}', \t\tdescription \t= '{$description}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t no_of_rooms \t\t= '{$room_no}', \t\tno_of_bathrooms\t= '{$bath_no}', \t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t no_of_living_rooms = '{$living_room_no}',price \t\t\t= '{$price}'\n\t\t\t\t\t\t\t\t\t\t\t\t WHERE dwelling_Id = {$dwelling_Id}"; $updateAddress = "UPDATE address_info SET house_no \t\t\t= '{$house_no}', \t\tstreet_name \t\t= '{$street_name}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t apartment_no \t\t= '{$apartment_no}', \tcity \t\t \t\t= '{$city}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t province \t\t\t= '{$state}', \t\tzip_code \t \t\t= '{$zip}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t country\t\t\t\t= '{$country}'\n\t\t\t\t\t\t\t\t\t\t\t WHERE address_id \t= '{$address_id}'"; parent::executeSqlQuery($updateDwellings); parent::executeSqlQuery($updateAddress); } }
function add_cart() { $this->doNotRenderHeader = 1; $user_id = Login::getUserId(); $tourists_id = Login::getTouristsId(); $m = new Cart(); $data = $m->save_cart($user_id, $tourists_id); $this->assign('message', '1'); $this->setReturnType('message'); }
function edituserinfo() { $user_id = Login::getUserId(); $this->doNotRenderHeader = 1; $name = get_post_value('name'); $sex = get_post_value('sex'); $field = array('name' => trim($name), 'sex' => $sex); $m = new Login(); $m->clear(); $m->setField($field); $m->setTable('vcb_user'); $m->setWhere('user_id', '=', $user_id); $data = $m->update(); if (!empty($data)) { header("location:info_success"); } else { echo '信息修改失败'; } }
include 'classes/loginClass.php'; include 'classes/productClass.php'; include 'classes/conversationClass.php'; include 'classes/adminClass.php'; $databaseObj = new Database(); $loginObj = new Login(); $productObj = new Product(); $conversationObj = new Conversation(); $adminObj = new Admin(); session_start(); $range = null; $user_id = null; $bannedUser = null; if (isset($_SESSION['USERNAME'])) { $range = $loginObj->getRangeType($_SESSION['USERNAME']); $user_id = $loginObj->getUserId(); $bannedUser = $loginObj->checkBannedUsers($user_id); } if ($loginObj->isLoggedIn() && count($bannedUser) == 1) { ?> <aside id="loggedMenu" > <button type="button" onClick="window.location.href='logout.php'">Logout</button> </aside> <?php } elseif ($loginObj->isLoggedIn() && strcmp($range, "Regular") === 0) { ?> <aside id="loggedMenu" > <button type="button" onClick="window.location.href='index.php'">Home</button> <button type="button" onClick="window.location.href='userProfile.php'">Profile</button> <button type="button" onClick="window.location.href='messenger.php'">Messages</button> <button type="button" onClick="window.location.href='product.php'" >Upload</button>
// Instantiating the class object $login = new Login(); # Class configuration methods: // Setting the user table of mysql database $login->setDatabaseUsersTable('admin'); // Setting the crypting method for passwords, can be set as 'sha1' or 'md5' $login->setCryptMethod('sha1'); // Setting if class messages will be shown $login->setShowMessage(true); # Setting login session: $login->setLoginSession(); # Showing login informations if login is done: // Logged username echo "Welcome: " . $login->getUserName() . "<br>"; // Logged ID echo "Your id is: " . $login->getUserId() . "<br>"; // Logged user activation status echo "Your activation status is: " . $login->getUserActive() . "<br>"; if (isset($_GET['action']) && $_GET['action'] == 1) { // Logout $login->unsetLoginSession(); } } ?> <head> <style> h1 { color: #555; font-size: 16px;
/** * 返回购物车列表 */ function getCartList() { $user_id = Login::getUserId(); $tourists_id = Login::getTouristsId(); $field = array('cart_id', 'shop_username', 'shop_url', 'product_url', 'product_id', 'product', 'image_url', 'product', 'price', 'sku_name', 'qty'); $orderby = array('shop_username', 'cart_id'); $this->clear(); $this->setField($field); $this->setTable('vcb_cart'); $this->setWhere('user_id', '=', $user_id); if ($user_id == null) { $this->setWhere('tourists_id', '=', $tourists_id); } $this->setWhere('status', '=', '10000'); // /$this->setGroupBy('shop_username'); $this->setOrderBy($orderby); $data = $this->select(); $count = count($data); for ($i = 0; $i < $count; $i++) { $data[$i]['price_cn'] = $data[$i]['price']; $data[$i]['price_th'] = $data[$i]['price'] * RATE; } return $data; }
function __construct() { parent::__construct(); $this->_user_id = Login::getUserId(); }