public function login() { Hooks::addHook('js', 'Controllers\\auth@js'); Hooks::addHook('css', 'Controllers\\auth@css'); $error = 'hi'; $success = 'hi'; if (Session::get('loggedin')) { Url::redirect(); } if (isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; //validation if (Password::verify($password, $this->_model->getHash($username)) == false) { $error[] = 'Wrong username or password'; } //if validation has passed carry on if (!$error) { Session::set('loggedin', true); Session::set('username', $username); Session::set('memberID', $this->_model->getID($username)); $data = array('lastLogin' => date('Y-m-d G:i:s')); $where = array('memberID' => $this->_model->getID($username)); $this->_model->update($data, $where); $error = 'hi'; Url::redirect(); } } $data['title'] = 'Login'; View::rendertemplate('header', $data); View::render('auth/login', $data, $error, $success); View::rendertemplate('footer', $data); }
public function index() { if (!Session::get('loggedin')) { Url::redirect('login'); } if (isset($_POST['submit']) && $_FILES['fileToUpload']['size'] > 0) { $name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName']; $price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']); $description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription']; $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if (isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if ($check !== false) { //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { //echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { $error = "Sorry, file already exists." . $error; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $error = "Sorry, your file is too large." . $error; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $error = "Sorry, your file was not uploaded." . $error; // if everything is ok, try to upload file } else { //if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], str_replace(' ','-',strtolower($target_file)))) { //echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; $product['product'] = array('name' => $name, 'price' => $price, 'description' => $description, 'lastUpdate' => date('Y-m-d G:i:s')); $product['image'] = array('image' => file_get_contents($_FILES['fileToUpload']['tmp_name']), 'size' => $_FILES["fileToUpload"]["size"], 'type' => $imageFileType); $this->_model->insertProduct($product); //unlink(str_replace(' ','-',strtolower($target_file))); } } Hooks::addHook('js', 'Controllers\\menu@indexJS'); Hooks::addHook('css', 'Controllers\\menu@indexCss'); $data['title'] = 'index'; $data['username'] = Session::get('username'); View::rendertemplate('header', $data); View::render('menu/index', $data, $error); View::rendertemplate('footer', $data); }
public function GetUser($id_contato, $messages = []) { $data['name'] = $this->contatos->getOneName($id_contato); $data['mail'] = $this->contatos->getOneMail($id_contato); $data['mail_type'] = $this->contatos->getMailType(); $data['phone'] = $this->contatos->getOnePhone($id_contato); $data['phone_type'] = $this->contatos->getPhoneType(); $data['messages'] = $messages; Hooks::addHook('js', '\\Controllers\\PainelContatoUsuario@scripts'); // var_dump($data['mail_type']); // var_dump('aaa'); // die(); View::renderTemplate('header', $data); View::render('painel_contato_usuario/edit_contato_usuario', $data); View::renderTemplate('footer', $data); }
public function login() { Hooks::addHook('js', 'Controllers\\auth@js'); Hooks::addHook('css', 'Controllers\\auth@css'); // if(Session::get('loggedin')){ // Url::redirect(); // } $currentUser = ParseUser::getCurrentUser(); if ($currentUser) { // do stuff with the user Url::redirect(); } else { // show the signup or login page } //==============Sign Up Manually========================== // $user = new ParseUser(); // $user->set("username", "yoak"); // $user->set("password", "yoakyoak"); // $user->set("email", "*****@*****.**"); // // other fields can be set just like with ParseObject // $user->set("phone", "0909814465"); // try { // $user->signUp(); // // Hooray! Let them use the app now. // $error = 'Hooray! Let them use the app now.'; // } catch (ParseException $ex) { // // Show the error message somewhere and let the user try again. // echo "Error: " . $ex->getCode() . " " . $ex->getMessage(); // } //==============Sign Up Manually========================== if (isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; try { $user = ParseUser::logIn($username, $password); Url::redirect(); // Do stuff after successful login. } catch (ParseException $ex) { // The login failed. Check error to see why. $error = "ParseException: " . $ex->getCode() . " " . $ex->getMessage(); } } $data['title'] = 'Login'; View::rendertemplate('header', $data); View::render('auth/login', $data, $error); View::rendertemplate('footer', $data); }
<?php use Helpers\Hooks; Hooks::addHook('routes', 'Modules\\Blog\\Controllers\\Blog@routes');
<?php use Helpers\Hooks; Hooks::addHook('sidebar', 'Modules\\Members\\Controllers\\Members@index'); Hooks::addHook('routes', 'Modules\\Members\\Controllers\\Members@routes');
<?php use Helpers\Hooks; Hooks::addHook('sidebar', 'Modules\\Members\\Controllers\\Members@index'); Hooks::addHook('routes', 'Modules\\Members\\Controllers\\Members@routes'); Hooks::addHook('navbar', 'Modules\\Members\\Controllers\\Members@navbar');
public function order() { $currentUser = ParseUser::getCurrentUser(); if ($currentUser) { // do stuff with the user } else { // show the signup or login page Url::redirect('login'); } if (isset($_POST['table'])) { View::render('inventory/order-table', $data, $error); } elseif (isset($_POST['del']) && isset($_POST['objectId'])) { $objectId = $_POST['objectId']; $query = new ParseQuery('Order'); try { $data = 1; } catch (ParseException $ex) { $data = $ex; } $query->equalTo('objectId', $objectId); $order = $query->first(); $order->destroy(); header('Content-type: application/json; charset=utf-8'); echo json_encode(array('result' => $data)); } elseif (isset($_POST['update'])) { $objectId = !isset($_POST['objectId']) || trim($_POST['objectId']) == '' ? '' : $_POST['objectId']; $productId = !isset($_POST['productId']) || trim($_POST['productId']) == '' ? '' : $_POST['productId']; $productName = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName']; $customerId = !isset($_POST['customerId']) || trim($_POST['customerId']) == '' ? '' : $_POST['customerId']; $customerName = !isset($_POST['customerName']) || trim($_POST['customerName']) == '' ? '' : $_POST['customerName']; $lineId = !isset($_POST['lineId']) || trim($_POST['lineId']) == '' ? '' : $_POST['lineId']; $facebook = !isset($_POST['facebook']) || trim($_POST['facebook']) == '' ? '' : $_POST['facebook']; $telephone = !isset($_POST['telephone']) || trim($_POST['telephone']) == '' ? '' : $_POST['telephone']; $transportDate = !isset($_POST['transportDate']) || trim($_POST['transportDate']) == '' ? null : DateTime::createFromFormat('d/m/Y', $_POST['transportDate']); $address = !isset($_POST['address']) || trim($_POST['address']) == '' ? '' : $_POST['address']; $transportStatus = !isset($_POST['transportStatus']) || trim($_POST['transportStatus']) == '' ? '' : $_POST['transportStatus']; $transferStatus = !isset($_POST['transferStatus']) || trim($_POST['transferStatus']) == '' ? '' : $_POST['transferStatus']; $trackingNumber = !isset($_POST['trackingNumber']) || trim($_POST['trackingNumber']) == '' ? '' : $_POST['trackingNumber']; $contact = ['telephone' => $telephone, 'lineId' => $lineId, 'facebook' => $facebook]; if ($_FILES['fileToUpload']['size'] > 0) { $target_file = basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if ($check !== false) { //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { //echo "File is not an image."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $error = "Sorry, your file is too large." . $error; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $error = "Sorry, your file was not uploaded." . $error; // if everything is ok, try to upload file } else { $imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file); $query = new ParseQuery('Order'); $query->equalTo('objectId', $objectId); $order = $query->first(); $order->set('productId', $productId); $order->set('productName', $productName); $order->set('customerName', $customerName); $order->set('customerId', $customerId); $order->setAssociativeArray('contact', $contact); $order->set('slipPayin', $imageFile); $order->set('transportDate', $transportDate); $order->set('address', $address); $order->set('transportStatus', $transportStatus); $order->set('transferStatus', $transferStatus); $order->set('trackingNumber', $trackingNumber); $order->save(); } } else { $query = new ParseQuery('Order'); $query->equalTo('objectId', $objectId); $order = $query->first(); $order->set('productId', $productId); $order->set('productName', $productName); $order->set('customerName', $customerName); $order->set('customerId', $customerId); $order->setAssociativeArray('contact', $contact); $order->set('transportDate', $transportDate); $order->set('address', $address); $order->set('transportStatus', $transportStatus); $order->set('transferStatus', $transferStatus); $order->set('trackingNumber', $trackingNumber); $order->save(); } } else { if (isset($_POST['submit'])) { $productId = !isset($_POST['productId']) || trim($_POST['productId']) == '' ? '' : $_POST['productId']; $productName = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName']; $customerId = !isset($_POST['customerId']) || trim($_POST['customerId']) == '' ? '' : $_POST['customerId']; $customerName = !isset($_POST['customerName']) || trim($_POST['customerName']) == '' ? '' : $_POST['customerName']; $lineId = !isset($_POST['lineId']) || trim($_POST['lineId']) == '' ? '' : $_POST['lineId']; $facebook = !isset($_POST['facebook']) || trim($_POST['facebook']) == '' ? '' : $_POST['facebook']; $telephone = !isset($_POST['telephone']) || trim($_POST['telephone']) == '' ? '' : $_POST['telephone']; $transportDate = !isset($_POST['transportDate']) || trim($_POST['transportDate']) == '' ? null : DateTime::createFromFormat('d/m/Y', $_POST['transportDate']); $transportStatus = !isset($_POST['transportStatus']) || trim($_POST['transportStatus']) == '' ? '' : $_POST['transportStatus']; $transferStatus = !isset($_POST['transferStatus']) || trim($_POST['transferStatus']) == '' ? '' : $_POST['transferStatus']; $trackingNumber = !isset($_POST['trackingNumber']) || trim($_POST['trackingNumber']) == '' ? '' : $_POST['trackingNumber']; $contact = ['telephone' => $telephone, 'lineId' => $lineId, 'facebook' => $facebook]; if ($_FILES['fileToUpload']['size'] > 0) { $target_file = basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if ($check !== false) { //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { //echo "File is not an image."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $error = "Sorry, your file is too large." . $error; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $error = "Sorry, your file was not uploaded." . $error; // if everything is ok, try to upload file } else { $imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file); $order = new ParseObject('Order'); $order->set('productId', $productId); $order->set('productName', $productName); $order->set('customerName', $customerName); $order->set('customerId', $customerId); $order->setAssociativeArray('contact', $contact); $order->set('slipPayin', $imageFile); $order->set('transportDate', $transportDate); $order->set('address', $address); $order->set('transportStatus', $transportStatus); $order->set('transferStatus', $transferStatus); $order->set('trackingNumber', $trackingNumber); $order->save(); } } else { $order = new ParseObject('Order'); $order->set('productId', $productId); $order->set('productName', $productName); $order->set('customerName', $customerName); $order->set('customerId', $customerId); $order->setAssociativeArray('contact', $contact); $order->set('transportDate', $transportDate); $order->set('address', $address); $order->set('transportStatus', $transportStatus); $order->set('transferStatus', $transferStatus); $order->set('trackingNumber', $trackingNumber); $order->save(); } Url::redirect('order'); } $sidemenu = new ParseQuery('SideMenu'); $result = $sidemenu->find(); Hooks::addHook('js', 'Controllers\\inventory\\Order@JS'); Hooks::addHook('css', 'Controllers\\inventory\\Order@CSS'); $data['title'] = 'รายการสั่งซื้อสินค้า'; $data['username'] = $currentUser->get('username'); $data['sidemenu'] = $result; View::rendertemplate('header', $data); View::render('inventory/order', $data, $error); View::rendertemplate('footer', $data); } }
<?php use Helpers\Hooks; //use Modules\Search\Controllers\Config as config; Hooks::addHook('routes', 'Modules\\Search\\Controllers\\Main@routes');
public function product() { // if(!Session::get('loggedin')){ // Url::redirect('login'); // } $currentUser = ParseUser::getCurrentUser(); if ($currentUser) { // do stuff with the user } else { // show the signup or login page Url::redirect('login'); } if (isset($_POST['table'])) { View::render('inventory/product-table', $data, $error); } elseif (isset($_POST['del']) && isset($_POST['objectId'])) { $objectId = $_POST['objectId']; $query = new ParseQuery('Product'); try { $data = 1; } catch (ParseException $ex) { $data = $ex; } $query->equalTo('objectId', $objectId); $product = $query->first(); $product->destroy(); header('Content-type: application/json; charset=utf-8'); echo json_encode(array('result' => $data)); } elseif (isset($_POST['update'])) { $objectId = !isset($_POST['objectId']) || trim($_POST['objectId']) == '' ? '' : $_POST['objectId']; $name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName']; $price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']); $description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription']; if ($_FILES['fileToUpload']['size'] > 0) { $target_file = basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if ($check !== false) { //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { //echo "File is not an image."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $error = "Sorry, your file is too large." . $error; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $error = "Sorry, your file was not uploaded." . $error; // if everything is ok, try to upload file } else { $imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file); $query = new ParseQuery('Product'); $query->equalTo('objectId', $objectId); $product = $query->first(); $product->set('name', $_POST['productName']); $product->set('price', $price); $product->set('description', $description); $product->set('picture', $imageFile); $product->save(); } } else { $query = new ParseQuery('Product'); $query->equalTo('objectId', $objectId); $product = $query->first(); $product->set('name', $name); $product->set('price', $price); $product->set('description', $description); $product->save(); } } else { if (isset($_POST['submit'])) { $name = !isset($_POST['productName']) || trim($_POST['productName']) == '' ? '' : $_POST['productName']; $price = !isset($_POST['productPrice']) || trim($_POST['productPrice']) == '' ? 0 : floatval($_POST['productPrice']); $description = !isset($_POST['productDescription']) || trim($_POST['productDescription']) == '' ? '' : $_POST['productDescription']; if ($_FILES['fileToUpload']['size'] > 0) { $target_file = basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if ($check !== false) { //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { //echo "File is not an image."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $error = "Sorry, your file is too large." . $error; $uploadOk = 0; } // Allow certain file formats if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $error = "Sorry, only JPG, JPEG, PNG & GIF files are allowed." . $error; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $error = "Sorry, your file was not uploaded." . $error; // if everything is ok, try to upload file } else { $imageFile = ParseFile::createFromData(file_get_contents($_FILES['fileToUpload']['tmp_name']), $target_file); $product = new ParseObject('Product'); $product->set('name', $name); $product->set('price', $price); $product->set('description', $description); $product->set('picture', $imageFile); $product->save(); } } else { $product = new ParseObject('Product'); $product->set('name', $name); $product->set('price', $price); $product->set('description', $description); $product->save(); } Url::redirect('product'); } $sidemenu = new ParseQuery('SideMenu'); $result = $sidemenu->find(); Hooks::addHook('js', 'Controllers\\inventory\\Product@JS'); Hooks::addHook('css', 'Controllers\\inventory\\Product@CSS'); $data['title'] = 'สินค้า'; $data['username'] = $currentUser->get('username'); $data['sidemenu'] = $result; View::rendertemplate('header', $data); View::render('inventory/product', $data, $error); View::rendertemplate('footer', $data); } }