Advertisement
Kimossab

DDI/AI - Exame 2008

Jan 8th, 2016
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 12.32 KB | None | 0 0
  1. <!--1)
  2. http://www.w3schools.com/css/box-model.gif
  3.  
  4. o box model é as "caixas" que estão à volta de um elemento HTML. Este contem o conteúdo, padding, borda e margem.
  5. O padding é o espaço que é "consumido" na caixa do conteúdo. É transparente
  6. A Borda é a caixaque está entre a margem e o padding, que normalmente tem o seu proprio estilo.
  7. Margin é a area de fora do elemento que afasta do outro elemento a que esteja ligado. É transparente.
  8.  
  9. ???? IE?????
  10. Por defeito alguns browsers têm um padding e margem por defeito. O IE 8 e anterior incluia automaticamente um padding e borda na propriedade width dos elementos.
  11. -->
  12.  
  13. <!--2)-->
  14. <!--HTML-->
  15. <html>
  16.     <head>
  17.         <title>Perfect To Do List</title>
  18.         <link rel="stylesheet" type="text/css" href="style.css">
  19.     </head>
  20.     <body>
  21.         <div class="principal">
  22.             <div class="header">
  23.                 <div class="title">
  24.                     <p>Perfect To Do List</p>
  25.                 </div>
  26.             </div>
  27.             <div class="head2">
  28.                 <p class="sel">Select Project:&nbsp;</p>
  29.                 <select id="projsel" name="projsel" class="sel">
  30.                 </select>
  31.                 <p id="welcome" name="welcome" class="welcome">Welcome pedro.silva</p>
  32.             </div>
  33.            
  34.             <div class="tasks">
  35.                 <p class="pendtitle">Pending Tasks</p>
  36.                 <p class="inst"><i>Check tasks done or add a new task:</i></p>
  37.                 <form class="checkas" method="post" action="">
  38.                     <input type="checkbox" value="Kick-off">Kick-off meeting</br>
  39.                     <input type="checkbox" value="Analysis">Analysis report</br>
  40.                     <input type="checkbox" value="Design">Design report</br>
  41.                     <input type="checkbox" value="Functional">Functional requirements report</br>
  42.                     <input type="checkbox" value="Coding">Coding</br>
  43.                     <input type="checkbox" value="Test">Testing</br>
  44.                     <p class="ntask">New task:</p>
  45.                     <textarea class="textar">
  46.                     </textarea></br>
  47.                     <input class="butao" type="submit" value="OK">
  48.                 </form>
  49.             </div>
  50.            
  51.             <div class="tasks2" method="post" action="">
  52.                 <p class="conctitle">Concluded Tasks</p>
  53.                 <p class="inst"><i>Select tasks you want to send back to the Pending list.</i></p>
  54.                 <form class="checkas" action="undo.php">
  55.                     <input type="checkbox" value="Meet">First meeting with client</br>
  56.                     <input type="checkbox" value="Bizz">Business Proposal</br>
  57.                     <input type="checkbox" value="WinP">Win Project</br>
  58.                     <input class="butao2" type="submit" value="Undo">
  59.                 </form>
  60.             </div>
  61.         </div>
  62.     </body>
  63. </html>
  64. <!--css-->
  65. body{
  66.     background-color:grey;
  67.     padding:0;
  68.     margin:0;
  69. }
  70.  
  71. div{
  72.     margin:0;
  73.     padding:0;
  74. }
  75.  
  76. p{
  77.     font-family:Arial;
  78.     font-size:14px;
  79.     margin:0;
  80.     padding:0;
  81. }
  82.  
  83. br{
  84.     margin:10px;
  85. }
  86.  
  87. .principal{
  88.     margin-left:100px;
  89.     width:800px;
  90.     height:800px;
  91.     background-color: white;
  92. }
  93. .header{
  94.     width:780px;
  95.     background-color:lightgrey;
  96.     height:80px;
  97.     padding:10px;
  98. }
  99. .head2{
  100.     width:780px;
  101.     height:35px;
  102.     margin-bottom:10px;
  103. }
  104. .title{
  105.     width:350px;
  106.     background-color:darkgrey;
  107.     padding:10px;
  108. }
  109. .title p{
  110.     color:white;
  111. }
  112. .sel{
  113.     float:left;
  114.     margin:10px;
  115. }
  116. .welcome{
  117.     float:right;
  118.     margin:10px;
  119. }
  120.  
  121. .tasks{
  122.     float:left;
  123.     width:395px;
  124. }
  125. .pendtitle{
  126.     background-color:darkgrey;
  127.     padding-top:10px;
  128.     padding-bottom:10px;
  129.     padding-left:10px;
  130.     width:385px;
  131. }
  132. .inst{
  133.     margin:10px 10px 10px 20px;
  134.     font-size:12px;
  135. }
  136. .checkas{
  137.     margin:10px 10px 10px 20px;
  138. }
  139. .ntask{
  140.     margin:10px;
  141. }
  142. .textar{
  143.     margin-left:10px;
  144.     width:345px;
  145. }
  146. .butao{
  147.     margin:10px;
  148.     float:right;
  149.     width:100px;
  150. }
  151.  
  152. .tasks2{
  153.     float:right;
  154.     width:395px;
  155. }
  156. .conctitle{
  157.     background-color:darkgrey;
  158.     padding-top:10px;
  159.     padding-bottom:10px;
  160.     padding-left:10px;
  161.     width:385px;
  162. }
  163. .butao2{
  164.     margin:10px;
  165.     float:left;
  166.     width:100px;
  167. }
  168.  
  169. <!--3)-->
  170. <!--index.php-->
  171. <?php
  172.    if(!session_id())
  173.    {
  174.        session_start();
  175.    }
  176.    if(!isset($_SESSION['user-login']))
  177.    {
  178.        header('Location: login.php');
  179.        die();
  180.    }
  181.    
  182.    $conn = mysqli_connect('localhost', 'root', '', 'todolist');
  183.    
  184.    if ($_SERVER["REQUEST_METHOD"] == "POST")
  185.    {
  186.        if($_POST['action'] == 'pending')
  187.        {
  188.            $aux=0;
  189.            $sql = "SELECT count(*) as `cnt` FROM `pending_tasks` WHERE `project_id` = " . $checkedproj;
  190.            $res = mysqli_query($sql,$conn);
  191.            $row = mysqli_fetch_assoc($res);
  192.            if($res)
  193.            {
  194.                while($aux < $row['cnt'])
  195.                {
  196.                    if(isset($_POST[$aux]))
  197.                    {
  198.                        $sql = "INSERT INTO `concluded_tasks` count(*) (`text`,`project_id) VALUES(SELECT `text`,`project_id` FROM `pending_tasks` WHERE `text` LIKE " . $_POST[$aux] . ")";
  199.                        mysqli_query($sql,$conn);
  200.                        $sql = "DELETE FROM `concluded_tasks` WHERE `text` LIKE " . $_POST[$aux];
  201.                        mysqli_query($sql,$conn);
  202.                    }
  203.                    $aux++;
  204.                }
  205.            }
  206.        }
  207.        else if($_POST['action'] == 'concluded')
  208.        {
  209.            $aux=0;
  210.            $sql = "SELECT count(*) as `cnt` FROM `concluded_tasks` WHERE `project_id` = " . $checkedproj;
  211.            $res = mysqli_query($sql,$conn);
  212.            $row = mysqli_fetch_assoc($res);
  213.            if($res)
  214.            {
  215.                while($aux < $row['cnt'])
  216.                {
  217.                    if(isset($_POST[$aux]))
  218.                    {
  219.                        $sql = "INSERT INTO `pending_tasks` count(*) (`text`,`project_id) VALUES(SELECT `text`,`project_id` FROM `concluded_tasks` WHERE `text` LIKE " . $_POST[$aux] . ")";
  220.                        mysqli_query($sql,$conn);
  221.                        $sql = "DELETE FROM `pending_tasks` WHERE `text` LIKE " . $_POST[$aux];
  222.                        mysqli_query($sql,$conn);
  223.                    }
  224.                    $aux++;
  225.                }
  226.            }
  227.        }
  228.        else if($_POST['action'] == 'project')
  229.        {
  230.            $checkedproj = $_POST['projsel'];
  231.        }
  232.    }
  233. ?>
  234. <html>
  235.     <head>
  236.         <title>Perfect To Do List</title>
  237.         <link rel="stylesheet" type="text/css" href="style.css">
  238.     </head>
  239.     <body>
  240.         <div class="principal">
  241.             <div class="header">
  242.                 <div class="title">
  243.                     <p>Perfect To Do List</p>
  244.                 </div>
  245.             </div>
  246.             <div class="head2">
  247.                 <p class="sel">Select Project:&nbsp;</p>
  248.                 <form action="" method="post">
  249.                     <input type="hidden" name="project">;
  250.                     <select id="projsel" name="projsel" class="sel">
  251.                         <?php
  252.                            $sql = "SELECT * FROM `projects` WHERE `user_id` = " . $_SESSION['user-login'];
  253.                            $res = mysqli_query($sql,$conn);
  254.                            if($res)
  255.                            {
  256.                                $aux=0;
  257.                                while($row = mysqli_fetch_assoc($res))
  258.                                {
  259.                                    if($aux === $checkedproj)
  260.                                        echo "<option value=\"" . $row['id'] . "\" selected>". $row['project_name'];
  261.  
  262.                                     echo "<option value=\"" . $row['id'] . "\">". $row['project_name'];
  263.  
  264.                                     $aux++;
  265.                                 }
  266.                             }
  267.                         ?>
  268.                     </select>
  269.                 </form>
  270.                 <p id="welcome" name="welcome" class="welcome">Welcome <?php echo $_SESSION['user-login']?></p>
  271.             </div>
  272.            
  273.             <div class="tasks">
  274.                 <p class="pendtitle">Pending Tasks</p>
  275.                 <p class="inst"><i>Check tasks done or add a new task:</i></p>
  276.                 <form class="checkas" method="post" action="">
  277.                     <input type="hidden" name="action" value="pending" />
  278.                     <?php
  279.                        if($checkedproj !== '')
  280.                        {
  281.                            $sql = "SELECT * FROM `pending_tasks` WHERE `project_id` = " . $checkedproj;
  282.                            $res = mysqli_query($sql,$conn);
  283.                            if($res)
  284.                            {
  285.                                while($row = mysqli_fetch_assoc($res))
  286.                                {
  287.                                    echo "<input type=\"checkbox\" value=\"" . $row['text'] . "\">". $row['text'];
  288.                                 }
  289.                             }
  290.                         }
  291.                     ?>
  292.                     <p class="ntask">New task:</p>
  293.                     <textarea class="textar">
  294.                     </textarea></br>
  295.                     <input class="butao" type="submit" value="OK">
  296.                 </form>
  297.             </div>
  298.            
  299.             <div class="tasks2" >
  300.                 <p class="conctitle">Concluded Tasks</p>
  301.                 <p class="inst"><i>Select tasks you want to send back to the Pending list.</i></p>
  302.                 <form class="checkas" method="post" action="">
  303.                     <input type="hidden" name="action" value="concluded" />
  304.                     <?php
  305.                        if($checkedproj !== '')
  306.                        {
  307.                            $sql = "SELECT * FROM `concluded_tasks` WHERE `project_id` = " . $checkedproj;
  308.                            $res = mysqli_query($sql,$conn);
  309.                            if($res)
  310.                            {
  311.                                while($row = mysqli_fetch_assoc($res))
  312.                                {
  313.                                    echo "<input type=\"checkbox\" value=\"" . $row['text'] . "\">". $row['text'];
  314.                                 }
  315.                             }
  316.                         }
  317.                     ?>
  318.                 </form>
  319.             </div>
  320.         </div>
  321.     </body>
  322. </html>
  323.  
  324. <!--login.php-->
  325. <?php
  326.    if(!session_id())
  327.    {
  328.        session_start();
  329.    }
  330.    if(isset($_SESSION['user-login']))
  331.    {
  332.        header('index.php');
  333.        die();
  334.    }
  335.    
  336.    $mess = '';
  337.    
  338.    $conn = mysqli_connect('localhost', 'todolist', '12345', 'todolist');
  339.    
  340.    if ($_SERVER["REQUEST_METHOD"] == "POST")
  341.    {
  342.        if($_POST['name'] !== '' && $_POST['pass'] !== '')
  343.        {
  344.            $sql = "SELECT `Password` FROM `users` WHERE `Username` LIKE ".$_POST['name'];
  345.            $res = mysqli_query($sql,$conn);
  346.            if($res)
  347.            {
  348.                $row = mysqli_fetch_assoc($res);
  349.                if(password_verify($_POST['pass'],$row['Password']))
  350.                {
  351.                    $_SESSION['user-login'] = $_POST['name'];
  352.                    header('Location: index.php');
  353.                    die();
  354.                }
  355.                else
  356.                {
  357.                    $mess='Wrong Password';
  358.                }
  359.            }
  360.            else
  361.            {
  362.                $mess="User Name Doesn't Exist.";
  363.            }
  364.        }
  365.        else
  366.        {
  367.            $mess="Please fill all fields.";
  368.        }
  369.    }
  370. ?>
  371. <html>
  372.     <head>
  373.         <title>Login</title>
  374.         <link rel="stylesheet" type="text/css" href="style.css">
  375.     </head>
  376.     <body>
  377.         <div class="principal">
  378.             <?php
  379.            if($mess !== '')
  380.            {
  381.                echo "<p>".$mess."</p>";
  382.             }
  383.             ?>
  384.             <form class="checkas" method="post" action="">
  385.                 <p>Username:</p><input type="text" name="name"><br>
  386.                 <p>Password:</p><input type="password" name="pass"><br>
  387.                 <input type="submit" value="Login">
  388.             </form>
  389.         </div>
  390.     </body>
  391. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement