Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.24 KB | None | 0 0
  1. <!-- ###########################################################################
  2. VERIFICACAO DA SESSION -->
  3. <?php session_start();
  4. if (!isset ($_SESSION['uid']))
  5. header('location: login.php'); ?>
  6. <?php require_once '../style/navigation.php'; ?>
  7.  
  8. <?php
  9. include '../scripts/checkTop.php';
  10. include '../dataBase/countKeywords.php';
  11. include '../dataBase/bdConnection.php';
  12. include '../dataBase/allCandidato.php'
  13. ?>
  14. <!DOCTYPE html>
  15. <html lang="en" dir="ltr">
  16. <head>
  17. <meta charset="utf-8">
  18. <title>Resulta da Pesquisa</title>
  19. </head>
  20. <?php
  21. /* ###########################################################################
  22. VERIFICACAO DOS PARES DE INFORMAÇÃO VÁLIDOS */
  23. if(isset($_POST['kw'],$_POST['vl'])){
  24. $kw = $_POST['kw'];
  25. $vl = $_POST['vl'];
  26. $struct= array();
  27. $parametros = array();
  28. for ($i=0; $i < count($kw) ; $i++) { // VERIFICACAO DOS CAMPOS
  29. if ((!empty($kw[$i] and $vl[$i])) and is_numeric($vl[$i])) {
  30. array_push($parametros,strtolower($kw[$i]));
  31. array_push($parametros,$vl[$i]);
  32. }
  33. }
  34.  
  35. /* ###########################################################################
  36. CRIAÇÃO DO QUERY COM OS PARAMETROS VÁLIDOS */
  37.  
  38. for ($i=0; $i < count($parametros) ; $i+=2) {
  39. array_push($struct,"(LENGTH(Content) - LENGTH(REPLACE (Content, ' $parametros[$i] ', '')))/LENGTH(' $parametros[$i] ') as $parametros[$i]");
  40. }
  41. /* ###########################################################################
  42. QUERY PARA IS BUCACAR O TABELA CANDIDATO */
  43. $listaDeCandidatos = allCandidato();
  44. $struct = implode(",",$struct);
  45. if (count($parametros)<2) {
  46. header('location: definirParametros.php');
  47.  
  48. }else{
  49. $listaDeOcorrencias = countKeywords ($struct);
  50.  
  51. }
  52.  
  53.  
  54. for ($i=0; $i <count($listaDeOcorrencias) ; $i++) {
  55. echo $listaDeCandidatos[$i]['CandidatoID']." = ";
  56. for ($k=0; $k <count($parametros) ; $k+=2) {
  57.  
  58. echo $listaDeOcorrencias[$i][$parametros[$k]]." - ";
  59. }
  60. echo "<br>";
  61. }
  62. /* ###########################################################################
  63. CALCULO DO SCORE VÁLIDOS */
  64. $listaDeScore = array();
  65. for ($i=0; $i <count($listaDeOcorrencias) ; $i++) {
  66. $temp=0;
  67. for ($k=0; $k <count($parametros) ; $k+=2) {
  68. $temp += $listaDeOcorrencias[$i][$parametros[$k]]*$parametros[$k+1];
  69. }
  70. $listaDeScore[$listaDeCandidatos[$i]['CandidatoID']]=$temp;
  71. }
  72. /* ###########################################################################
  73. ORDENAÇÃO DO SCORE POR ORDEM DECRESCENTE */
  74. arsort($listaDeScore);
  75. }
  76. ?>
  77. <body>
  78. <!--
  79. <div class='col' style='margin-top:2rem;' >
  80. <div class='row text-center'style='min-width:75rem!important;'>
  81. <div class='col defCabeca'style='margin-left:0.95rem;'>
  82. <th>ID</th>
  83. </div>
  84. <div class='col defCabeca'>
  85. <th>Nome</th>
  86. </div>
  87. <div class='col defCabeca'>
  88. <th>Apelido</th>
  89. </div>
  90. <div class='col defCabeca'>
  91.  
  92. </div>
  93. <div class='col defCabeca'>
  94. </div>
  95. <div class='col defCabeca'>
  96. <th>Email</th>
  97. </div>
  98. <div class='col defCabeca'>
  99. </div>
  100. <div class='col defCabeca'>
  101. <th>Score</th>
  102. </div>
  103. <div class='col defCabeca'>
  104. <th>Editar</th>
  105. </div>
  106. <div class='col defCabeca'>
  107. <th>Download</th>
  108. </div>
  109. <div class='col defCabeca'style='margin-right:4.7rem;'>
  110. </div>
  111. </div>
  112. -->
  113.  
  114. <?php
  115. $limit = 2;
  116. $query = "SELECT * FROM Candidato";
  117.  
  118. $s = $conn->prepare($query);
  119. $s->execute();
  120. $total_results = $s->rowCount();
  121. $total_pages = ceil($total_results/$limit);
  122.  
  123. if (!isset($_GET['page'])) {
  124. $page = 1;
  125. } else{
  126. $page = $_GET['page'];
  127. }
  128.  
  129.  
  130.  
  131. $starting_limit = ($page-1)*$limit;
  132. $show = "SELECT * FROM Candidato ORDER BY CandidatoID DESC LIMIT $starting_limit, $limit";
  133.  
  134. $r = $conn->prepare($show);
  135. $r->execute();
  136. $lista = array();
  137. $lista[39] = "CV 39";
  138. $lista[38] = "CV 38";
  139.  
  140. $i=0;?>
  141. <div class="container">
  142. <div class="row">
  143. <div class="col">
  144.  
  145. </div>
  146. <div class='col' style='margin-top:2rem;' >
  147. <div class='row text-center'style='min-width:75rem!important;'>
  148. <div class='col defCabeca'style='margin-left:0.95rem;'>
  149. <th>ID</th>
  150. </div>
  151. <div class='col defCabeca'>
  152. <th>Nome</th>
  153. </div>
  154. <div class='col defCabeca'>
  155. <th>Apelido</th>
  156. </div>
  157. <div class='col defCabeca'>
  158. <th>Email</th>
  159. </div>
  160. <div class='col defCabeca'>
  161. <th>Score</th>
  162. </div>
  163. <div class='col defCabeca'>
  164. <th>Editar</th>
  165. </div>
  166. <div class='col defCabeca'>
  167. <th>Download</th>
  168. </div>
  169. <div class='col defCabeca'style='margin-right:4.7rem;'>
  170. </div>
  171. </div>
  172. <div class="container addScrollAreaGestao" style="padding-right:0!important;padding-left:0!important;">
  173. <table class='table table-hover table-striped table-bordered'>
  174. <?php
  175. while($res = $r->fetch(PDO::FETCH_ASSOC)):
  176.  
  177. echo '<tr>';
  178. echo"<td>".$res['CandidatoID']."</td>";
  179. echo"<td>".$res['FirstName']."</td>";
  180. echo"<td>".$res['LastName']."</td>";
  181. echo"<td>".$res['Email']."</td>";
  182.  
  183. echo"<td>".$res['CandidatoID']."</td>";
  184.  
  185. if ($res['Automatic']== 1) {
  186. echo "<td><a href='editCandidato.php?id=".$res['CandidatoID']."' id='valor' class='btn btn-info'>Editar</a></td>";
  187.  
  188. }else {
  189. echo "<td> - </td>";
  190. }
  191. echo "<td><a href='../scripts/download.php?ic=".$res['CandidatoID']."' id='valor' class='btn btn-info'>Download</a></td>";
  192. echo"</tr>";
  193.  
  194. endwhile;
  195. ?>
  196.  
  197. </table>
  198. </div>
  199. <div class="container text-center">
  200. <div class="row">
  201. <?php
  202. for ($page=1; $page <= $total_pages ; $page++):
  203.  
  204. echo "<a href=?page=".$page." class='links'>". $page."</a>";
  205.  
  206. endfor;
  207. ?>
  208.  
  209. </div>
  210. </div>
  211. </div>
  212. <div class="col">
  213. </div>
  214. </div>
  215. </div>
  216. </body>
  217. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement