function get_services($params) { if (isset($params['projectId']) == false || $params['projectId'] == null) { $query = json_decode(httpResponse(dbUrl() . '/services', null, null), true); } else { $query = json_decode(httpResponse(dbUrl() . '/projects/' . $params['projectId'] . '/services', null, null), true); } if (isset($params['sort'])) { if (isset($params['order']) == false) { $params['order'] = 'DESC'; } if ($params['sort'] == 'name') { if ($params['order'] == 'DESC') { usort($query, 'sortByTitleDESC'); } else { usort($query, 'sortByTitleASC'); } } else { if ($params['sort'] == 'project') { if ($params['order'] == 'DESC') { usort($query, 'sortByProjectDESC'); } else { usort($query, 'sortByProjectASC'); } } else { if ($params['sort'] === 'status') { if ($params['order'] == 'DESC') { usort($query, 'sortByStatusDESC'); } else { usort($query, 'sortByStatusASC'); } } else { if ($params['sort'] === 'start') { if ($params['order'] == 'DESC') { usort($query, 'sortByStartDESC'); } else { usort($query, 'sortByStartASC'); } } } } } } if (isset($params['ids'])) { if (is_array($params['ids']) && count($params['ids']) > 0) { $arr = array(); for ($i = 0; $i < count($query); ++$i) { if (in_array(intval($query[$i]['id']), $params['ids'])) { array_push($arr, $query[$i]); } } $query = $arr; } else { $query = array(); } } $query = searchByName($params["filterData"]["text"], $query, "title"); $checkFeatures = (isset($params['checkFeatures']) and isset($params["filterData"]['companyId']) and $params['checkFeatures'] == true ? true : false); $features = getFeaturesIds($params["filterData"]['companyId'], $checkFeatures); for ($i = 0; $i < count($query); ++$i) { if (in_array(intval($query[$i]['id']), $features['services'])) { $query[$i]['inFeatured'] = true; } } $count = count($query); $countTypes = array('analytical' => 0, 'solid' => 0, 'data' => 0); if (isset($params["filterData"]['type']) && in_array($params["filterData"]['type'], array('analytical', 'solid', 'data'))) { $arr = array(); for ($i = 0; $i < count($query); ++$i) { $countTypes[$query[$i]['serviceType']] += 1; if ($query[$i]['serviceType'] === $params["filterData"]['type']) { array_push($arr, $query[$i]); } } $query = $arr; } else { for ($i = 0; $i < count($query); ++$i) { $countTypes[$query[$i]['serviceType']] += 1; } } if (isset($params['offset']) == false) { $params['offset'] = 0; } if (isset($params['limit'])) { $query = array_slice($query, $params['offset'], $params['limit']); } for ($i = 0; $i < count($query); ++$i) { $query[$i]['type'] = 'service'; $query[$i]['favorite'] = isFavoriteProduct($query[$i]['id'], $query[$i]['type'], null); $query[$i] = addMore($query[$i]); } $result = array('result' => $query, 'count' => $count, 'countTypes' => $countTypes); return json_encode($result); }
<?php session_start(); include_once $_SERVER['DOCUMENT_ROOT'] . "/app/etc/dbconfig.php"; if (isset($_GET)) { $term = trim(strip_tags($_GET['term'])); $searchKey = $_GET['searchkey']; switch ($searchKey) { case 'name': $searchData = searchByName($term); echo json_encode($searchData); break; case 'email': $searchData = searchByEmail($term); echo json_encode($searchData); break; case 'role': $searchData = searchByUserRoleName($term); echo json_encode($searchData); break; case 'shop': $searchData = searchByShopName($term); echo json_encode($searchData); break; default: break; } } function searchByName($term) { $query = "SELECT u.entity_id,u.firstname,u.lastname,u.email, s.shop_name , r.role_id, r.role_name from pos_user_entity as u, pos_shop_entity as s, pos_user_roles r where s.entity_id = u.shop_id and r.role_id = u.role_id AND ( u.lastname LIKE '%{$term}%' OR u.firstname LIKE '%{$term}%' )";
unlink($file); } if (move_uploaded_file($_FILES['profile_pic_upload']['tmp_name'], $FileDir)) { $connectedUser->_setPhoto(true); } } } setcookie("color", $_POST['editColor'], time() + 100000); setcookie("police", $_POST['editPolice'], time() + 100000); updateTouitos($bd, $connectedUser); } include 'nav.php'; ?> <div id="pageDisplay"> <?php if (isset($_GET['user'])) { $th = new TouitosHandler($bd); $usr = $th->getByAttr("pseudo", $_GET['user'], PDO::PARAM_STR); if ($usr != null) { show_profile($usr, $bd); } } else { searchByName("", $bd); } ?> </div> </body> </html>
<?php require_once "config/connexion.php"; require_once 'fonctions.php'; require_once 'classes/touite.class.php'; if (isset($_GET['search']) && !isset($_GET['moreSearch'])) { searchByName($_GET['search'], $bd); } else { if (isset($_GET['moreSearch'])) { moreSearchResult($_GET['search'], $bd, $_GET['offset']); } else { if (!empty($_SESSION['id']) and !empty($_GET['remove'])) { delete_message($_GET['id'], $_SESSION['id'], $bd); } else { if (!empty($_GET['id']) and !empty($_GET['voirMessage'])) { voir_message($_GET['id'], $bd); } else { if (!empty($_SESSION['id']) && !empty($_POST['discution'])) { $touite = array("texte" => $_POST['message'], "idAuteur" => $_SESSION['id']); envoyer_reponse($_POST['id'], new Touite($touite), $bd); } else { if (!empty($_POST['message']) && !isset($_POST['sendDiscussion'])) { $touite = array("texte" => $_POST['message'], "idAuteur" => $_SESSION['id']); if (!empty($_POST['id_message'])) { $touite['id_message'] = $_POST['id_message']; $message = new Touite($touite); //réponse } else { $message = new Touite($touite); $message->setLadate(date("Y-m-d H:i:s")); addTouite($message, $bd); $th = new touitosHandler($bd);
<?php if (isset($_SERVER['HTTP_ORIGIN'])) { header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Max-Age: 86400'); // cache for 1 day header('Content-type: application/json'); } $data = $_POST["data"]; $type = $_POST["type"]; switch ($type) { case 'name': searchByName($data); break; case 'type': searchByType($data); break; default: searchByID($data); break; } function searchByID($id) { if ($id == "") { $id = 130; } $data = ["ID", "Nombre", "Tipo 1", "Tipo 2", "Generacion", "Descripcion", "Altura", "Peso", "Imagen", "Miniatura", "Sonido"]; $con = mysqli_connect("mysql.hostinger.es", "u439733712_swiol", "17091991", "u439733712_pokem"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error();