<?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>Afegir tesi</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>

        <!-- Començament del cos -->
        <?php require("../private/connect.inc");
              require("../private/ident.inc");
              require("../private/func.inc");
              ident();
      	      autoritzar($_COOKIE["login"], "tesis");
              $link=Conectar();
              $titol=addslashes($_POST["titol"]);
              $keywords=addslashes($_POST["keywords"]);
              $id1=addslashes($_POST["id1"]);
              $result=mysql_query("SELECT id FROM personal WHERE nom LIKE '$id1'", $link);
              $row = mysql_fetch_array($result);
              $id1 = $row["id"];
              mysql_free_result($result);
              $id2=addslashes($_POST["id2"]);
              if ($id2 != "Cap"){
                $result=mysql_query("SELECT id FROM personal WHERE nom LIKE '$id2'", $link);
                $row = mysql_fetch_array($result);
                $id2 = $row["id"];
                mysql_free_result($result);
              } else {
                $id2 = "0";
              }
              $id3=addslashes($_POST["id3"]);
              if ($id3 != "Cap"){
                $result=mysql_query("SELECT id FROM personal WHERE nom LIKE '$id3'", $link);
                $row = mysql_fetch_array($result);
                $id3 = $row["id"];
                mysql_free_result($result);
              } else {
                $id3 = "0";
              }
              if (permis($_COOKIE["login"], "tesis_total")!="true"){
                // Comprovem que li pertany algun dels ids
                es_el_seu_id123($id1, $id2, $id3);
              }

              if ($_POST["idioma"]=="Castellano"){
                $taula="tesis_es";
              } elseif($_POST["idioma"]=="English") {
                $taula="tesis_en";
              } else {
                $taula="tesis";
              }

              $link=Conectar();
              $categoria=$_POST["categoria"];
              $result=mysql_query("SELECT cid FROM categories WHERE titol LIKE
              '$categoria'", $link);
              $row = mysql_fetch_array($result);
              $categoria = $row["cid"];
              mysql_free_result($result);

              $assignatures_rel=$_POST["assignatures_rel"];
              $resum=$_POST["resum"];
              $sql="INSERT INTO " . $taula . "
              (titol,keywords,id1,id2,id3,resum,assignatures_rel,categoria) VALUES
              ('" . addslashes($titol) . "','" . addslashes($keywords) . "','" .
              addslashes($id1) . "','" . addslashes($id2) . "','" . addslashes($id3) . "','"
              . addslashes($resum) . "','" . addslashes($assignatures_rel) . "','" .
              addslashes($categoria) . "')";
              mysql_query($sql, $link) or die ("Error a la BD!");
        ?>
        <h2>Administració Tesis: Afegir</h2>
        Registre afegit!!<br>
        <font size="-1"><i>En 3 segons tornará al menú d'administració</i></font>
        </blockquote></div>
        </td>
        <td align="left" valign="top" width="100">
          <br />
          <br />
          <br />
          <br />
          <a href="../desconectar.php" class="link2"><img src="images/tancar.jpg" border="0"></a>
        </td>
      </tr>
    </table>
    <script languaje='JavaScript'>
      setTimeout('location.href="../login.php"', 3000)
    </script>
  </body>
</html>

