function getUserById($uid, $hash, $userId) { if (!($uid > 0)) { return -1; } if (!($userId > 0)) { return -1; } if (!checkCookies($uid, $hash)) { return -1; } $colsArray = array("users" => array(1, 2, 4, 5, 6, 7, 8)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `users` WHERE `uid`={$userId};"; $data = array(); if ($result = mysql_query($query)) { while ($res = mysql_fetch_array($result)) { $data["user"] = getSqlData($colsArray, $res); } } $colsArray = array("item" => array(1, 3, 4, 11)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `item` WHERE `item`.`uid`={$userId};"; if ($result = mysql_query($query)) { $inndata = array(); while ($res = mysql_fetch_array($result)) { array_push($inndata, getSqlData($colsArray, $res)); } $data["items"] = $inndata; } return $data; }
function getNotification($uid, $hash) { if (!($uid > 0)) { return -1; } if (!checkCookies($uid, $hash)) { return false; } $colsArray = array("borrow" => array(1, 2, 3, 4, 5, 6, 7), "item" => array(1, 3, 4)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `item`, `borrow` WHERE `borrow`.`iid`=`item`.`iid` AND `item`.`uid`={$uid} AND `item`.`status`=1;"; $data = array(); if ($result = mysql_query($query)) { while ($res = mysql_fetch_array($result)) { $data[$res["bid"]] = getSqlData($colsArray, $res); } } return $data; }
function getReply($iid) { // $colsArray = array("replycomment" => array(1, 3, 4, 5, 6)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `replycomment` WHERE `iid`={$iid};"; if ($result = mysql_query($query)) { $comments = array(); while ($res = mysql_fetch_array($result)) { if (!isset($comments[$res["cid"]])) { $comments[$res["cid"]] = array(); } $comments[$res["cid"]][$res["rcid"]] = getSqlData($colsArray, $res); } return $comments; } }
function getUsersBySearch($q) { $q = mysql_real_escape_string($q); $colsArray = array("users" => array(1, 2, 4, 5, 6)); $colStr = getSqlColumns($colsArray); $query = "SELECT {$colStr} FROM `users` WHERE (`users`.`email` LIKE '%{$q}%') OR (`users`.`uname` LIKE '%{$q}%') OR (`users`.`fname` LIKE '%{$q}%') OR (`users`.`contact` LIKE '%{$q}%');"; $items = array(); if ($result = mysql_query($query)) { while ($res = mysql_fetch_assoc($result)) { $item = getSqlData($colsArray, $res); $items[] = $item; } } return $items; }
function genContent($authResult = 0) { global $nomConvivialAmap; global $language; global $link; global $dbName; global $messageAccueil; echo '<div id = "news" class="news"></div><div id="authResult"><p>' . $messageAccueil . '</p></div> <div class="main"><p class="amapTitle" id = "mainTitle" style="width:100%; text-align:left">' . $nomConvivialAmap . '.</p></div>'; switch ($authResult) { case 0: switch ($language) { case 'fr': $text1 = 'utilisateur'; $text2 = 'mot de passe'; break; default: $text1 = 'username'; $text2 = 'password'; break; } genMenu(0); echo ' <div class="main"> <form class = "auth" name="auth" method="post" action="./login.php"> <table> <tr><td rowspan=3><img src = "./customize/images/' . $dbName . 'Logo_s.png" style = "padding:0px 0px 0px 0px; border:2px solid dodgerblue; border-radius : 15px; margin:0px 5px 0px 0px; width:65%; padding: 3px 3px 3px 3px; background-color:white; height=50%"/></td><td style="text-align : left">' . $text1 . '</td><td><input type="text" name="username" required/></td></tr> <tr><td style="text-align:left">' . $text2 . '</td><td><input type="password" name="password" required/></td></tr> <tr><td colspan = 2><input style="width:100%" type="submit" name="submit" value="connexion"/><img src="smallrad.png" style = "height : 150px; width:79px; display : none" alt=""/></td></tr> </table> </form>'; switch ($language) { case 'fr': $text1 = 'mot de passe oublié ?'; $text2 = 'créez votre compte'; break; default: $text1 = 'forgot you password ?'; $text2 = 'new visitor : sign up !'; break; } #echo '<div class="g-signin2" data-onsuccess="onSignIn"></div>'; echo '<p><a style="font-size:.6em" href="./frgtPwd.php">' . $text1 . '</a><br/> <a style="font-size:.6em" href="./newAcc.php">' . $text2 . '</a></p> </div>'; break; case 1: $isProdRqt = "select isProd from adherents where idadherent = " . $_SESSION['idAdherent'] . ";"; $isProdResult = getSqlData($isProdRqt, "fetch_row", "0"); echo '<div id = "navbar">'; switch ($isProdResult) { case 1: switch ($language) { case 'fr': $text = 'Voir les commandes sur mes offres en cours.'; break; default: $text = 'See the ongoing orders on my current offers.'; break; } echo '<ul><li><a href = "./viewAll.php">' . $text . '</a></li>'; switch ($language) { case 'fr': $text = 'Historique de toutes les commandes'; break; default: $text = '"All offers" history'; break; } echo '<li><i><a href = "./synthAll.php">' . $text . '</a></i></li></ul><br/>'; switch ($language) { case 'fr': $text1 = 'Offres et Produits'; $text2 = 'créer produit(s)'; $text3 = 'créer offre'; $text4 = 'alimenter offre'; $text5 = 'Modification'; $text6 = 'modifier produit(s)'; break; default: $text1 = 'offers and products'; $text2 = 'create product(s)'; $text3 = 'create offer'; $text4 = 'buil offer'; $text5 = 'modification'; $text6 = 'modify products'; break; } echo ' <p> <ol><h1><u>' . $text1 . '</u></h1> <li><a href = "./addProd.php">' . $text2 . '<a></li> <li><a href = "./newOffr.php">' . $text3 . '</a></li> <li><a href = "./choixOffre.php">' . $text4 . '</a></li> </ol> <ul><h1><u>' . $text5 . '</u></h1> <li><a href = "./seeProd.php">' . $text6 . '</a></li> </ul> </p> </div>'; break; case 0: #recherche du nombre de commandes en cours $ongoingCmdRqt = 'select count(distinct b.idOffre) from produits b inner join commandes a on a.prodId = b.id where a.status < 3 and a.idAdherent = ' . $_SESSION['idAdherent'] . ' group by b.idOffre having sum(a.qte)>0;'; $ongoingCmdResult = getSqlData($ongoingCmdRqt, 'num_rows', '0'); echo '<p><ul>'; switch ($language) { case 'fr': $text1 = 'Passer une commande'; $text2 = 'mes commandes en cours'; $text2_2 = 'Mettre à jour mes décoches'; break; default: $text1 = 'place an order'; $text2 = 'my ongoing orders'; $text2_2 = 'Mettre à jour mes décoches'; break; } echo ' <li><a href = "./setMyOrd.php">' . $text1 . '</a></li> <li><a href="./seeMyCmd.php">' . $text2 . ' (<strong>' . $ongoingCmdResult . '</strong>)</a>'; # ids des commandes actives $activCmdIdsRqt = 'SELECT concat(c.nom, \' (\', d.prenom, \' \', d.nomF, \')\') FROM commandes a, produits b, offres c, adherents d WHERE a.idAdherent = ' . $_SESSION['idAdherent'] . ' AND d.idAdherent = c.idProducteur AND a.status <3 AND a.prodId = b.id AND c.idOffre = b.idOffre GROUP BY c.nom HAVING sum( a.qte ) >0 ;'; $superUserRqt = 'select superviseur from adherents where idAdherent = ' . $_SESSION['idAdherent'] . ';'; $superUserRqtResult = mysql_query($superUserRqt, $link); while ($row = mysql_fetch_row($superUserRqtResult)) { $isSU = $row[0]; } $activCmdIdsResult = mysql_query($activCmdIdsRqt, $link); echo '<ul>'; while ($row = mysql_fetch_row($activCmdIdsResult)) { foreach ($row as $var) { echo '<li>' . $var . '</li>'; } } echo '</ul></li>'; //décoches if ($dbName == 'amap') { $isMainAcc = getUserInfo($_SESSION['idAdherent'], 'mainAcc', 'adherents'); if ($isMainAcc == 1) { echo '<li><a href="./calDec.php">' . $text2_2 . '</a></li>'; } else { echo '<li title="vous devez d\'abord configurer votre compte dans Mes Infos"><a href="./mesInfos.php">' . $text2_2 . '</a></li>'; } } echo '</ul>'; echo '</p>'; if ($isSU == 1) { echo '<p><ul>'; switch ($language) { case 'fr': $text1 = 'SUPERVue :-)'; $text2 = 'SUPERVueDétaillée :-)'; $text2_2 = 'SUPERVision décoches !'; break; default: $text1 = 'SUPERView :-)'; $text2 = 'detailedSUPERView :-)'; $text2_2 = 'SUPERVision décoches !'; break; } echo '<li class="super"><a href = "./synthAll.php">' . $text1 . '</a></li>'; echo '<li class="super"><a href = "./viewAll.php">' . $text2 . '</a></li>'; echo '<li class="super"><a href = "./manDec.php">' . $text2_2 . '</a></li>'; echo '</ul></p>'; } echo '</div>'; break; } switch ($language) { case 'fr': $text1 = 'mes infos'; $text2 = 'se déconnecter'; break; default: $text1 = 'my info'; $text2 = 'log out'; break; } echo '<div class = "main"><img style = "width:431px; height:655px" src="./customize/images/' . $dbName . 'Logo.png"/></div> <div id = "discodiv"> <ul> <li> <a href="mesInfos.php">' . $text1 . '</a> </li> <li> <a href="./disconnect.php">' . $text2 . '</a> </li> </ul> </div>'; } }