<?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 novetats</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ó Tesis: Cercar</h2>
        <!-- Començament del cos -->
        <?php require("../private/connect.inc");
              require("../private/ident.inc");
              ident();
              autoritzar($_COOKIE["login"], "novetats");
              $link=Conectar();
              $lang = $_REQUEST["lang"];
              if ($lang == "es") {
                $taula = "novetats_es";
              } else if ($lang == "en") {
                $taula = "novetats_en";
              } else {
                $taula = "novetats";
              }
              if (!strcmp($_POST["type"], "titol")) {
                $titol=addslashes($_POST["titol"]);
                $result=mysql_query("SELECT * FROM ". $taula . " WHERE titol LIKE 
                '%$titol%'", $link);
              } elseif (!strcmp($_POST["type"], "contingut")) {
                $contingut=addslashes($_POST["contingut"]);
                $result=mysql_query("SELECT * FROM ". $taula ." WHERE bodytext
                LIKE '%$contingut%'", $link);
              } else {
                die;
              }
              echo("<table border=\"0\" width=\"90%\" align=\"left\">");
              echo("<tr bgcolor=black><td><b>Data</b></td><td><b>Titol</b></td>
                    </tr>");
              // Mostrem les noticies mes noves
              while($row = mysql_fetch_array($result)) {
                $dd = substr($row["date"], 6, 2);
                $mm = substr($row["date"], 4, 2);
                $yy = substr($row["date"], 0, 4);
                $nid = $row["nid"];
                echo("<tr><td align=\"left\"> <div align=\"left\">" . $dd . "-" . $mm
                              . "-" . $yy . "</td>");
                printf("<td><b>&nbsp; %s</b>&nbsp;&nbsp;&nbsp;</td>",
                        htmlspecialchars($row["titol"]));


                echo("<td><form action=\"modificar-reg.php\" method=\"post\"><input
                      type=\"hidden\" name=\"nid\" value=\"" . htmlspecialchars($nid) ."\">
                      <input  type=\"hidden\" name=\"lang\" value=\"". $lang ."\">");
                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=\"nid\" value=\"" . htmlspecialchars($nid) ."\">
                      <input type=\"hidden\" name=\"lang\" value=\"" . $lang . "\">");
                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>

