language: AWK (mawk) (mawk-1.3.3)
date: 845 days 14 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
ob_start();
session_start();
if (!isset($_SESSION['admin'])){
        echo "<script type='text/javascript'> alert('Utilizador não realizou o login!')</script>";
        echo "<script type='text/javascript'> window.location='index.php'</script>";
}elseif ($_SESSION['admin']==0){
        echo "<script type='text/javascript'> alert('Utilizador não tem premissões para aceder a esta página!')</script>";
        echo "<script type='text/javascript'> window.location='index.php'</script>";
}else{
?>
 
<html>
<head>
<title>Filmes</title>
<style type="text/css">
<!--
 
#titulo {
                color: #000000;
                text-decoration: none;
                font-size:28px;
}
 
#alterar {
                color: #CD9B1D;
                text-decoration: none;
                font-size:14px;
}
 
a:link {
        color: #000000;
        text-decoration: none;
}
a:visited {
        text-decoration: none;
        color: #666666;
}
a:hover {
        text-decoration: none;
        color: #999999;
        font-size:20px;
}
a:active {
        text-decoration: none;
        color: #CCCCCC;
}
-->
</style></head>
 
<body>
 
<center>
    <p><b><a id="titulo" href='index.php'>VideoClub</a></b><p><p>
        <table width="80%" border="0">
                <tr>
                        <strong><td width="16%" height="25"><div align="center"><h5>Filmes</h5></div></td>
                        <td width="19%"><div align="center"><a href="ltalugueres.php">Alugueres</a></div></td>
                        <td width="17%"><div align="center"><a href="utilizadores.php">Utilizadores</a></div></td>
                        <td width="19%"><div align="center"><a href="actores.php">Actores</a></div></td>
                        <td width="19%"><div align="center"><a href="realizadores.php">Realizadores</a></div></td>
                        </strong>               </tr>
        </table>
        <p>
        <table >
                <tr>
                        <td></td>
                </tr>
        </table>
        
        <table width="80%" border="0">
                <tr>
                        <th style="border:3px solid black;background-color:#A4C639;color:white;" width="6%">Código</th>
                        <th style="border:3px solid black;background-color:#A4C639;color:white;" width="9%">Título Original</th>
                        <th style="border:3px solid black;background-color:#A4C639;color:white;" width="7%">Título Português</th>
                        <th style="border:3px solid black;background-color:#A4C639;color:white;" width="1%">Ano</th>
                        <th style="border:3px solid black;background-color:#A4C639;color:white;" width="1%">Duração</th>
                        <th style="border:3px solid black;background-color:#A4C639;color:white;" width="8%">Idioma</th>
                        <th style="border:3px solid black;background-color:#A4C639;color:white;" width="8%">Classificação</th>
                        <th style="border:3px solid black;background-color:#A4C639;color:white;">Sinopse</th>
                </tr>
        <?php
        $con = mysql_connect("localhost","root","");
        if (!$con){
          die('Could not connect: ' . mysql_error());
          }
        mysql_select_db("videoclub", $con);
        
        $alt = $_REQUEST['alt'];
        if ($_REQUEST['del']==1){
                mysql_query("delete from tblfilmes where codigo_filme=$alt");
                unset($_REQUEST['del'],$_REQUEST['alt']);
        }
 
        $add = $_REQUEST['abc'];
        if ($add==1){
                $titulo_original=$_POST['titulo_original'];
                $titulo_portugues=$_POST['titulo_portugues'];
                $ano=$_POST['ano'];
                $duracao=$_POST['duracao'];
                $idioma=$_POST['idioma'];
                $classificacao=$_POST['classificacao'];
                $sinopse=$_POST['sinopse'];
                
                if ($titulo_original=="" || $ano=="" || $duracao=="" || $sinopse==""){
                        echo "<script type='text/javascript'> alert('Todos os dados relativos ao filme são obrigatórios, à excepção do Titulo em Português!')</script>";
                }elseif (!is_numeric($ano)||!is_numeric($duracao)){
                        echo "<script type='text/javascript'> alert('O Ano e a Duração têm de ser numeros inteiros!')</script>";
                }elseif ($alt!=""){
                        mysql_query("update tblfilmes  set titulo_original='$titulo_original',titulo_portugues='$titulo_portugues',ano='$ano',duracao='$duracao',idioma='$idioma',classificacao='$classificacao',sinopse='$sinopse' where codigo_filme='$alt'");
                        unset($_REQUEST['alt']);
                }else{
                        mysql_query("INSERT INTO tblfilmes  VALUES (0,'$titulo_original','$titulo_portugues','$ano','$duracao','$idioma','$classificacao','$sinopse')");
                }
        }
        
        $result = mysql_query("SELECT * FROM tblfilmes");
        if (mysql_numrows($result)==0){
                echo "<tr><td style='border:2px solid black;' align=center colspan=8>Não existem filmes na base de dados!</td></tr>";
        }else{
                while($row = mysql_fetch_array($result))
                  {
                        echo "<tr>";
                        echo "<td style='border:2px solid black;' align=right><b><a href='filmes.php?alt=" . $row['codigo_filme'] . "' id=alterar>" . $row['codigo_filme'] . " </a></b></td>";
                        echo "<td style='border:2px solid black;'>" . $row['titulo_original'] . "</td>";
                        echo "<td style='border:2px solid black;'>" . $row['titulo_portugues'] . "</td>";
                        echo "<td style='border:2px solid black;'>" . $row['ano'] . "</td>";
                        echo "<td style='border:2px solid black;'>" . $row['duracao'] . "</td>";
                        echo "<td style='border:2px solid black;'>" . $row['idioma'] . "</td>";
                        echo "<td style='border:2px solid black;'>" . $row['classificacao'] . "</td>";
                        echo "<td style='border:2px solid black;'>" . $row['sinopse'] . "</td>";
                        echo "</tr>";
                        //<div align=right><a href='filmes.php?del=" . $row['codigo_filme'] . "' id='alterar'>Eliminar</a></div>
                  }
                }
                ?>
        <tr style='height:1px;'>
                <td colspan=8 style='border:1px solid black;'><h></td>
        </tr>
        <form method="post" action='filmes.php?abc=1&alt=<?php echo $_REQUEST['alt']?>'>
        <tr>    
                <td style='border:2px solid black;' align=right><?php
                        if ($_REQUEST['alt']!=""){
                                echo $_REQUEST['alt'];
                        }else{
                        echo "+";
                        }
                ?></td>
                <?php
                if ($_REQUEST['alt']!=""){
                        $result = mysql_query("SELECT * FROM tblfilmes where codigo_filme='" . $_REQUEST['alt'] . "'");
                        while($row = mysql_fetch_array($result)){
                                $t1=$row['titulo_original'];
                                $t2=$row['titulo_portugues'];
                                $a=$row['ano'];
                                $d=$row['duracao'];
                                $i=$row['idioma'];
                                $c=$row['classificacao'];
                                $s=$row['sinopse'];
                                $aaa=1;
                        }
                }
                ?>
                <td style='border:2px solid black;' align="center"><input type="text" size="15" name="titulo_original" value="<?php if($aaa=1) echo $t1; ?>"/></td>
                <td style='border:2px solid black;' align="center"><input type="text" size="15" name="titulo_portugues" value="<?php if($aaa=1) echo $t2; ?>"/></td>
                <td style='border:2px solid black;' align="center"><input type="text" size="1" maxlength="4" name="ano" value="<?php if($aaa=1) echo $a; ?>"/></td>
                <td style='border:2px solid black;'  align="center"><input type="text" size="3" maxlength="3" name="duracao" value="<?php if($aaa=1) echo $d; ?>"/></td>
                <td style='border:2px solid black;' align="center">
                        <select name="idioma">
                          <?php
                          $result = mysql_query("SELECT * FROM tblidiomas");
                          while($row = mysql_fetch_array($result)){
                                if ($i==$row['idioma']){
                                        echo "<option selected='selected'>" . $row['idioma'] . "</option>";
                                }else{
                                        echo "<option>" . $row['idioma'] . "</option>";
                                }
                                }
                          ?>
                        </select>
                </td>
                <td style='border:2px solid black;' align="center">
                        <select name="classificacao">
                          <?php
                          $result = mysql_query("SELECT * FROM tblclassificacao");
                          while($row = mysql_fetch_array($result)){
                                  if ($c==$row['classificacao']){
                                                echo "<option selected='selected'>" . $row['classificacao'] . "</option>";
                                        }else{
                                                echo "<option>" . $row['classificacao'] . "</option>";
                                        }
                          }
                          ?>
                        </select>
                </td>
                <td style='border:2px solid black;' align="center"><input type="text" size="50" name="sinopse" value="<?php if($aaa=1) echo $s; ?>"/></td>
        </tr>
        <tr>
                <td colspan=7></td>
                <td align=center>
                        <input type="submit" size="50" name="Guardar" value="Guardar"/>  
                        <input type="button" size="50" name="Eliminar" value="Eliminar" <?php if($_REQUEST['alt']=="") echo 'disabled';?> onClick="window.location='filmes.php?del=1&alt=<?php echo $_REQUEST['alt']?>'"/>     
                        <input type="reset" size="50" name="Limpar" value="Limpar"/>  
                        <input type="button" size="50" name="Cancelar" value="Cancelar" onClick="window.location='filmes.php'"/>
                </td>
        <tr>
        </form>
        </table>
</center>
</body>
</html>
<?php
}?>