<?php setcookie("login", $_COOKIE["login"] , time()+3600, "/", "deim.etse.urv.es", 1 ); ?>
<?php setcookie("sessio", $_COOKIE["sessio"] , time()+3600, "/", "deim.etse.urv.es", 1 ); ?>
<html>
  <head>
    <link rel="stylesheet" href="../estils/hoja.css" type="text/css" />
    <title>Cercar usuaris</title>
  </head>

  <body leftmargin="0" topmargin="0" bgcolor="#8F0000">
    <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
      <tr>
        <!-- Menú dret -->
        <td align="left" valign="top" width="100" bgcolor="#4F0000">
          <?php include("../menu.inc") ?>
        </td>

        <!-- Capçalera -->
        <td align="left" valign="top" width="100%" class="centered">
        <h2>Departament d'Enginyeria Informàtica i Matemàtiques</h2>
        <img src="images/separador.gif">
        <br><br>
        <div align="left"><blockquote>
        <h2>Administració Usuaris: Cercar</h2>
        <!-- Començament del cos -->
        <?php require("../private/connect.inc");
              require("../private/ident.inc");
              require("../private/func.inc");
              ident();
              autoritzar($_COOKIE["login"], "novetats");
              $link=Conectar();
              if (!strcmp($_POST["type"], "login")) {
                $login=addslashes($_POST["login"]);
                $result=mysql_query("SELECT * FROM usuaris WHERE login LIKE 
                '%$login%'", $link);
              } elseif (!strcmp($_POST["type"], "id")) {
                $id=id(addslashes($_POST["id"]));
                $link=Conectar();
                $result=mysql_query("SELECT * FROM usuaris WHERE id = '$id'", $link);
              } elseif (!strcmp($_POST["type"], "privilegis")) {
                $sql = "";
                if ($_POST["novetats"] == "true") {
                  if ($sql==""){
                    $sql = "SELECT * FROM usuaris WHERE novetats=\"true\"";
                  } else {
                    $sql = $sql . " AND novetats=\"true\"";
                  }
                }
                if ($_POST["personal"] == "true") {
                  if ($sql==""){
                    $sql = "SELECT * FROM usuaris WHERE personal=\"true\"";
                  } else {
                    $sql = $sql . " AND personal=\"true\"";
                  }
                }
                if ($_POST["personal_propi"] == "true") {
                  if ($sql==""){
                    $sql = "SELECT * FROM usuaris WHERE personal_propi=\"true\"";
                  } else {
                    $sql = $sql . " AND personal_propi=\"true\"";
                  }
                }
                if ($_POST["tesis_total"] == "true") {
                  if ($sql==""){
                    $sql = "SELECT * FROM usuaris WHERE tesis_total=\"true\"";
                  } else {
                    $sql = $sql . " AND tesis_total=\"true\"";
                  }
                }
                if ($_POST["tesis_propies"] == "true") {
                  if ($sql==""){
                    $sql = "SELECT * FROM usuaris WHERE tesis_propies=\"true\"";
                  } else {
                    $sql = $sql . " AND tesis_propies=\"true\"";
                  }
                }
                if ($_POST["deiminaris"] == "true") {
                  if ($sql==""){
                    $sql = "SELECT * FROM usuaris WHERE deiminaris=\"true\"";
                  } else {
                    $sql = $sql . " AND deiminaris=\"true\"";
                  }
                }
                if ($_POST["usuaris"] == "true") {
                  if ($sql==""){
                    $sql = "SELECT * FROM usuaris WHERE usuaris=\"true\"";
                  } else {
                    $sql = $sql . " AND usuaris=\"true\"";
                  }
                }
                if ($_POST["cercador"] == "true") {
                  if ($sql==""){
                    $sql = "SELECT * FROM usuaris WHERE cercador=\"true\"";
                  } else {
                    $sql = $sql . " AND cercador=\"true\"";
                  }
                }
                $result=mysql_query($sql, $link);
              }
              echo("<table border=\"0\" width=\"90%\" align=\"left\">");
              echo("<tr bgcolor=black><td><b>Login</b></td><td><b>Responsable</b></td>
                    </tr>");
              // Mostrem les noticies mes noves
              while($row = mysql_fetch_array($result)) {
                if ($row["login"]!="admin"){
                  echo("<tr><td align=\"left\"> <div align=\"left\">" . $row["login"] . "</td>");
                  printf("<td><b>&nbsp; %s</b>&nbsp;&nbsp;&nbsp;</td>",
                        nom($row["id"]));


                  echo("<td><form action=\"modificar-reg.php\" method=\"post\"><input
                      type=\"hidden\" name=\"login\" value=\"" .
                      htmlspecialchars($row["login"]) ."\">");
                  echo("<input type=\"image\" border=0 src=\"images/modificar.jpg\"></form></td>");
                  echo("<td><form action=\"esborrar-reg.php\" method=\"post\"><input
                      type=\"hidden\" name=\"login\" value=\"" .
                      htmlspecialchars($row["login"]) ."\">");
                  echo("<input type=\"image\" border=0 src=\"images/esborrar.jpg\"></form></td></tr>");
                }
              }

              mysql_free_result($result);
        ?>
        <td colspan="5"><br><input type="image" onClick="history.go(-1)"
        src="images/tornar.jpg"></td>
        </table>
        </blockquote></div>
        </td>
      </tr>
    </table>
  </body>
</html>

