Преглед изворни кода

Activity edition screen reworked.

Iñigo Valentin пре 9 година
родитељ
комит
cbead20c13

+ 1 - 0
.gitignore

@@ -29,6 +29,7 @@ sql/*row*.sql
 www/.htpasswd
 www-admin/.htpasswd
 www/.htaccess_local
+www-admin/.htaccess_local
 
 #Photos and unnecessary images
 www/img/actividades/script

+ 196 - 0
www-admin/actividades/edit.php

@@ -0,0 +1,196 @@
+<?php
+    include("../functions.php");
+    $http_host = $_SERVER["HTTP_HOST"];
+    $proto = getProtocol();
+    $default_host = substr($http_host, 0, strpos($http_host, ":"));
+    $server = "$proto$http_host";
+    $default_server = "$proto$default_host";
+    $con = startdb();
+    if (!checkSession($con)){
+        header("Location: /index.php");
+        exit (-1);
+    }
+    else{
+        $id = mysqli_real_escape_string($con, $_GET["id"]);
+        $q = mysqli_query($con, "SELECT * FROM activity WHERE id = $id");
+        if (mysqli_num_rows($q) != 1){
+            header("Location: /actividades/");
+            exit (-1);
+        }
+        else{
+            $r = mysqli_fetch_array($q);
+?>
+<html>
+    <head>
+        <meta content='text/html; charset=windows-1252' http-equiv='content-type'/>
+        <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'>
+        <title><?=$r["title_es"]?> - Administracion</title>
+        <!-- CSS files -->
+        <link rel='stylesheet' type='text/css' href='/css/ui.css'/>
+        <link rel='stylesheet' type='text/css' href='/css/actividades.css'/>
+        <!-- CSS for mobile version -->
+        <link rel='stylesheet' type='text/css' media='(max-width : 990px)' href='/css/m/ui.css'/>
+        <link rel='stylesheet' type='text/css' media='(max-width : 990px)' href='/css/m/actividades.css'/>
+        <!-- Script files -->
+        <script type='text/javascript' src='/script/ui.js'></script>
+        <script type='text/javascript' src='/ckeditor/ckeditor.js'></script>
+        <script type='text/javascript' src='script.js'></script>
+    </head>
+    <body>
+<?php
+        include("../toolbar.php");
+?>
+        <div id='content'>
+            <div class='section'>
+                <h3 class='section_title'>Editar informaci&oacute;n</h3>
+                <div class='entry'>
+                    <h4>Detalles</h4>
+                    Fecha:
+                    <input id='date' type='text' placeholder='yyyy/mm/dd' length='10' onChange='updateActivityDate("<?=$server?>", <?=$id?>, this);'/>
+                    &nbsp;&nbsp;&nbsp;&nbsp;<br class='mobile'/>
+                    Ciudad:
+                    <input id='city' type='text' placeholder='Ciudad' lendth='32' value='<?=$r["city"]?>' onChange='dbUpdate("<?=$server?>", "activity", "city", "VARCHAR", <?=$id?>, this);'/>
+                    <div id='lang_tabs'>
+                        <table>
+                            <tr>
+                                <td class='pointer lang_tabs_active' id='lang_tab_es' onclick='showLanguage("es");'>
+                                    Castellano
+                                </td>
+                                <td class='pointer' id='lang_tab_eu' onclick='showLanguage("eu");'>
+                                    Euskera
+                                </td>
+                                <td class='pointer' id='lang_tab_en' onclick='showLanguage("en");'>
+                                    Ingl&eacute;s
+                                </td>
+                            </tr>
+                        </table>
+                    </div>
+                    <div id='content_lang_es' class='activity_add_language'>
+                        <h4>T&iacute;tulo (castellano)</h4>
+                        <input name='title' placeholder='T&iacute;tulo' type='text' value='<?=$r["title_es"]?>' onChange='dbUpdate("<?=$server?>", "activity", "title_es", "VARCHAR", <?=$id?>, this);'/>
+                        <br/>
+                        <h4>Texto (castellano)</h4>
+                        <textarea name='text_es' id='text_es' placeholder='Texto' onChange='dbUpdate("<?=$server?>", "activity", "text_es", "VARCHAR", <?=$id?>, this);'><?=$r["text_es"]?></textarea>
+                        <script>CKEDITOR.replace('text_es');</script>
+                        <br/>
+                        <h4>Texto para despu&eacute;s (castellano)<h4>
+                        <textarea name='after_es' id='after_es' placeholder='Texto para despu&eacute;s' onChange='dbUpdate("<?=$server?>", "activity", "after_es", "VARCHAR", <?=$id?>, this);'><?=$r["after_es"]?></textarea>
+                        <script>CKEDITOR.replace('after_es');</script>
+                    </div>
+                    <div id='content_lang_eu' class='activity_add_language' style='display:none;'>
+                        <h4>T&iacute;tulo (euskera)</h4>
+                        <input name='title' placeholder='T&iacute;tulo' type='text' value='<?=$r["title_eu"]?>' onChange='dbUpdate("<?=$server?>", "activity", "title_eu", "VARCHAR", <?=$id?>, this);'/>
+                        <br/>
+                        <h4>Texto (euskera)</h4>
+                        <textarea name='text_eu' id='text_eu' placeholder='Texto' onChange='dbUpdate("<?=$server?>", "activity", "text_eu", "VARCHAR", <?=$id?>, this)'><?=$r["text_eu"]?></textarea>
+                        <script>CKEDITOR.replace('text_eu');</script>
+                        <br/>
+                        <h4>Texto para despu&eacute;s (euskera)</h4>
+                        <textarea name='after_eu' id='after_eu' placeholder='Texto para despu&eacute;s' onChange='dbUpdate("<?=$server?>", "activity", "after_eu", "VARCHAR", <?=$id?>, this);'><?=$r["after_eu"]?></textarea>
+                        <script>CKEDITOR.replace('after_eu');</script>
+                    </div>
+                    <div id='content_lang_en' class='activity_add_language' style='display:none;'>
+                        <h4>T&iacute;tulo (ingl&eacute;s)</h4>
+                        <input name='title' placeholder='T&iacute;tulo' type='text' value='<?=$r["title_en"]?>' onChange='dbUpdate("<?=$server?>", "activity", "title_en", "VARCHAR", <?=$id?>, this);'/>
+                        <br/>
+                        <h4>Texto (ingl&eacute;s)</h4>
+                        <textarea name='text_en' id='text_en' placeholder='Texto' onChange='dbUpdate("<?=$server?>", "activity", "text_en", "VARCHAR", <?=$id?>, this);'><?=$r["text_en"]?></textarea>
+                        <script>CKEDITOR.replace('text_en');</script>
+                        <br/>
+                        <h4>Texto para despu&eacute;s (ingl&eacute;s)</h4>
+                        <textarea name='after_en' id='after_en' placeholder='Texto para despu&eacute;s' onChange='dbUpdate("<?=$server?>", "activity", "after_en", "VARCHAR", <?=$id?>, this);'><?=$r["after_en"]?></textarea>
+                        <script>CKEDITOR.replace('after_en');</script>
+                    </div>
+                </div> <!-- .entry -->
+                <div class='entry'>
+                    <h3>Itinerario</h3>
+<?php
+                    $q_i = mysqli_query($con, "SELECT * FROM activity_itinerary WHERE activity = $id ORDER BY start;");
+                    $q_p = mysqli_query($con, "SELECT id, name_es FROM place ORDER by name_es");
+                    $q_r = mysqli_query($con, "SELECT id, name FROM route;");
+                    while ($r_i = mysqli_fetch_array($q_i)){
+?>
+                        <div class='itinerary'>
+                            Inicio:
+                            <input type='text' class='time' length='5' value='<?=substr($r_i["start"], 11, 5)?>' placeholder='HH:MM' onchange='updateItineraryStart("<?=$server?>", <?=$r_i["id"]?>, this)'/>
+                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fin (opcional):
+                            <input type='text' class='time' length='5' value='<?=substr($r_i["end"], 11, 5)?>' placeholder='HH:MM' onchange='updateItineraryEnd("<?=$server?>", <?=$r_i["id"]?>, this)'/>
+                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br class='mobile'/>Localizaci&oacute;n:
+                            <select onChange='togglePlaceRoute(<?=$r_i["id"]?>, this);'>
+                                <option value='place' selected>Un lugar</option>
+                                <option value='route'>Recorrido (opcional)</option>
+                            </select>
+                            <select id='select_itinerary_<?=$r_i["id"]?>_place' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "place", "NUMBER", <?=$r_i["id"]?>, this);'>
+                                <option value=''></option>
+<?php
+                                mysqli_data_seek($q_p, 0);
+                                while ($r_p = mysqli_fetch_array($q_p)){
+                                    $str_sel = "";
+                                    if ($r_i["place"] == $r_p["id"]){
+                                        $str_sel = "selected";
+                                    }
+?>
+                                    <option value='<?=$r_p["id"]?>' <?=$str_sel?>><?=$r_p["name_es"]?></option>
+<?php
+                                }
+?>
+                            </select>
+                            <select id='select_itinerary_<?=$r_i["id"]?>_route' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "route", "NUMBER", <?=$r_i["id"]?>, this);' style='display:none;'>
+                                <option value=''></option>
+<?php
+                                mysqli_data_seek($q_r, 0);
+                                while ($r_r = mysqli_fetch_array($q_r)){
+                                    $str_sel = "";
+                                    if ($r_i["route"] == $r_r["id"]){
+                                        $str_sel = "selected";
+                                    }
+?>
+                                    <option value='<?=$r_r["id"]?>' <?=$str_sel?>><?=$r_r["name"]?></option>
+<?php
+                                }
+?>
+                            </select>
+                            <br/>
+                            <table>
+                                <tr>
+                                    <td class='itinerary_language'>Castellano<br/>(obligatorio)</td>
+                                    <td class='itinerary_name'>
+                                        <input class='itinerary_name' type='text' value='<?=$r_i["name_es"]?>' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "name_es", "VARCHAR", <?=$r_i["id"]?>, this);'/>
+                                    </td>
+                                    <td class='itinerary_description'>
+                                        <textarea class='itinerary_description' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "description_es", "VARCHAR", <?=$r_i["id"]?>, this);'><?=$r_i["description_es"]?></textarea>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td class='itinerary_language'>Euskera<br/>(opcional)</td>
+                                    <td class='itinerary_name'>
+                                        <input class='itinerary_name' type='text' value='<?=$r_i["name_eu"]?>' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "name_eu", "VARCHAR", <?=$r_i["id"]?>, this);'/>
+                                    </td>
+                                    <td class='itinerary_description'>
+                                        <textarea class='itinerary_description' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "description_eu", "VARCHAR", <?=$r_i["id"]?>, this);'><?=$r_i["description_eu"]?></textarea>
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <td class='itinerary_language'>Ingl&eacute;s<br/>(opcional)</td>
+                                    <td class='itinerary_name'>
+                                        <input class='itinerary_name' type='text' value='<?=$r_i["name_en"]?>' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "name_en", "VARCHAR", <?=$r_i["id"]?>, this);'/>
+                                    </td>
+                                    <td class='itinerary_description'>
+                                        <textarea class='itinerary_description' onChange='dbUpdate("<?=$server?>", "activity_itinerary", "description_en", "VARCHAR", <?=$r_i["id"]?>, this);'><?=$r_i["description_en"]?></textarea>
+                                    </td>
+                                </tr>
+                            </table>
+
+                        </div> <!-- .itinerary -->
+<?php
+                    }
+?>
+                </div>
+            </div> <!-- .section -->
+        </div> <!-- #content -->
+    </body>
+</html>
+<?php
+        }
+    }
+?>

+ 0 - 17
www-admin/actividades/edit/edit.php

@@ -1,17 +0,0 @@
-<?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    include("../../functions.php");
-    $con = startdb();
-    if (!checkSession($con)){
-        header("Location: /index.php");
-        exit (-1);
-    }
-    else{
-        $id = mysqli_real_escape_string($con, $_GET['id']);
-        $column = mysqli_real_escape_string($con, $_GET['column']);
-        $type = mysqli_real_escape_string($con, $_GET['type']);
-        $value = mysqli_real_escape_string($con, $_GET['value']);
-
-        //TODO
-    }
-?>

+ 0 - 29
www-admin/actividades/edit/index.php

@@ -1,29 +0,0 @@
-<?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    include("../../functions.php");
-    $con = startdb();
-    if (!checkSession($con)){
-        header("Location: /index.php");
-        exit (-1);
-    }
-    else{?>
-<html>
-    <head>
-        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-        <title>Nuevo post - Administracion</title>
-        <!-- CSS files -->
-        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-        <link rel="stylesheet" type="text/css" href="/css/blog.css"/>
-        <!-- CSS for mobile version -->
-        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/blog.css"/>
-        <!-- Script files -->
-        <script type="text/javascript" src="/script/ui.js"></script>
-    </head>
-    <body>
-    </body>
-</html>
-<?php
-    }
-?>

+ 35 - 29
www-admin/actividades/index.php

@@ -1,7 +1,10 @@
 <?php
-    $http_host = $_SERVER['HTTP_HOST'];
-    $default_host = substr($http_host, 0, strpos($http_host, ':'));
     include("../functions.php");
+    $http_host = $_SERVER["HTTP_HOST"];
+    $proto = getProtocol();
+    $default_host = substr($http_host, 0, strpos($http_host, ":"));
+    $server = "$proto$http_host";
+    $default_server = "$proto$default_host";
     $con = startdb();
     if (!checkSession($con)){
         header("Location: /index.php");
@@ -11,26 +14,26 @@
 ?>
 <html>
     <head>
-        <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+        <meta content='text/html; charset=windows-1252' http-equiv='content-type'/>
+        <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'>
         <title>Actividades - Administracion</title>
         <!-- CSS files -->
-        <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-        <link rel="stylesheet" type="text/css" href="/css/actividades.css"/>
+        <link rel='stylesheet' type='text/css' href='/css/ui.css'/>
+        <link rel='stylesheet' type='text/css' href='/css/actividades.css'/>
         <!-- CSS for mobile version -->
-        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-        <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/activiadades.css"/>
+        <link rel='stylesheet' type='text/css' media='(max-width : 990px)' href='/css/m/ui.css'/>
+        <link rel='stylesheet' type='text/css' media='(max-width : 990px)' href='/css/m/activiadades.css'/>
         <!-- Script files -->
-        <script type="text/javascript" src="/script/ui.js"></script>
+        <script type='text/javascript' src='/script/ui.js'></script>
     </head>
     <body>
 <?php
-        include('../toolbar.php');
+        include("../toolbar.php");
 ?>
         <div id='content'>
-            <div class="section">
-                <h3 class="section_title">Actividades - <a href="/actividades/add/">Anadir nueva</a></h3>
-                <div class="entry">
+            <div class='section'>
+                <h3 class='section_title'>Actividades - <a href='/actividades/add/'>Anadir nueva</a></h3>
+                <div class='entry'>
                     <table id='activity_list'>
                         <tr>
                             <th>Titulo / Fecha</th>
@@ -46,9 +49,9 @@
                             <tr>
                                 <td class='activity_column_title'>
                                     <?=cutText($r['title_es'], 35, '', '')?>
-                                    <br/>$r[dat]
-                                </td>";
-                                <td class='activity_column_text'><?=str_replace('<br/>', ' ', cutText($r['text_es'], 60, '', ''))?>
+                                    <br/><?=$r["dat"]?>
+                                </td>
+                                <td class='activity_column_text'><?=str_replace('<br/>', ' ', cutText($r["text_es"], 60, "", ""))?>
 <?php
                                     //Images
                                     $q_image = mysqli_query($con, "SELECT image FROM activity_image WHERE activity = $r[id] ORDER BY idx;");
@@ -58,7 +61,7 @@
 <?php
                                         while ($r_image = mysqli_fetch_array($q_image)){
 ?>
-                                            <img src='http://$default_host/img/actividades/miniature/<?=$r_image["image"]?>'\>
+                                            <img src='<?=$default_server?>/img/actividades/miniature/<?=$r_image["image"]?>'\>
 <?php
                                         }
                                     }
@@ -66,14 +69,14 @@
                                     //Itinerary
                                     $q_itinerary = mysqli_query($con, "SELECT count(id) AS count FROM activity_itinerary WHERE activity = $r[id]");
                                     $r_itinerary = mysqli_fetch_array($q_itinerary);
-                                    if ($r_itinerary['count'] == 0){
+                                    if ($r_itinerary["count"] == 0){
 ?>
                                         <ul>
                                             <li>Sin itinerario.</li>
                                         </ul>
 <?php
                                     }
-                                    elseif ($r_itinerary['count'] == 1){
+                                    elseif ($r_itinerary["count"] == 1){
 ?>
                                         <ul>
                                             <li>1 entrada de itinerario.</li>
@@ -100,7 +103,7 @@
                                     <br/>
                                     Comentarios:
 <?php
-                                    if ($r['comments'] == 1){
+                                    if ($r["comments"] == 1){
                                         $q_comments = mysqli_query($con, "SELECT id FROM activity_comment WHERE activity = $r[id];");
 ?>
                                         S&iacute; (<?=mysqli_num_rows($q_comments)?>)
@@ -115,21 +118,21 @@
                                     <br/>
                                     Visible:
 <?php
-                                    if ($r['visible'] == 1){
+                                    if ($r["visible"] == 1){
 ?>
                                         S&iacute;
-<?php                                }
+<?php                               }
                                     else{
 ?>
                                         No
 <?php
                                     }
-?>s
+?>
                                 </td>
                                 <td class='activity_column_translations'>
                                     Euskera:
 <?php
-                                    if (strlen($r['text_eu']) == 0 || $r['text_eu'] == $r['text_es']){
+                                    if (strlen($r["text_eu"]) == 0 || $r["text_eu"] == $r["text_es"]){
 ?>
                                         No
 <?php
@@ -137,13 +140,13 @@
                                     else{
 ?>
                                         S&iacute;
-<?php                                
+<?php
                                     }
 ?>
                                     <br/>
                                     Ingl&eacute;s:
 <?php
-                                    if (strlen($r['text_en']) == 0 || $r['text_en'] == $r['text_es']){
+                                    if (strlen($r["text_en"]) == 0 || $r["text_en"] == $r["text_es"]){
 ?>
                                         No
 <?php
@@ -151,18 +154,21 @@
                                     else{
 ?>
                                         S&iacute;
-<?php                                
+<?php
                                     }
 ?>
                                 </td>
                                 <td class='activity_column_action'>
-                                    <form action='/activity/edit/edit.php?p=<?=$r[id]?>'>
+                                    <form method='get' action='/actividades/edit.php'>
+                                        <input type='hidden' name='id' value='<?=$r["id"]?>'/>
                                         <input type='submit' value='Editar / Traducir'/>
                                     </form>
                                     <input type='button' onClick='delete_activity(<?=$r["id"]?>, "<?=$r["title_es"]?>");' value='Borrar'/>
-                                    <form action='/activity/moderate/moderate.php?p<?=$r["id"]?>'>
+                                    <!-- TODO: Uncomment when activity comments are implemented.
+                                    <form action='/actividades/moderate/moderate.php?p<?=$r["id"]?>'>
                                         <input type='submit' value='Moderar comentarios'/>
                                     </form>
+                                    -->
                                 </td>
                             </tr>
 <?php

+ 30 - 0
www-admin/actividades/script.js

@@ -0,0 +1,30 @@
+function togglePlaceRoute(id, src){
+    if (src.value == "route"){
+        document.getElementById("select_itinerary_" + id + "_place").style.display = 'none';
+        document.getElementById("select_itinerary_" + id + "_route").style.display = 'inline';
+    }
+    else{
+        document.getElementById("select_itinerary_" + id + "_place").style.display = 'inline';
+        document.getElementById("select_itinerary_" + id + "_route").style.display = 'none';
+    }
+}
+
+function updateActivityDate(server, id, src){
+    // TODO: Validate date.
+    dbUpdate(server, "activity", "date", "DATE", id, src);
+}
+
+function dbUpdate(server, table, column, type, id, src){
+    var value = src.value;
+    var x = new XMLHttpRequest();
+    x.open("GET", server + "/functions/db_update.php?table=" + table + "&column=" + column + "&type=" + type + "&id=" + id + "&value=" + encodeURI(value), true);
+    x.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+    x.onreadystatechange = function(){
+        if(x.readyState == 4){
+            console.log("STATUS: " + x.status);
+            if(x.status == 200){
+                // TODO; Update!
+            }
+        }
+    }
+}

+ 60 - 0
www-admin/css/actividades.css

@@ -306,3 +306,63 @@ div#translate_controls input{
     width:        100%;
     margin-top:    1em;
 }
+
+
+/* /actividades/edit.php */
+
+input#date{
+    width: 8em;
+}
+
+input#city{
+    width: 16em;
+}
+
+div.activity_add_language h4{
+    margin-left: 1em;
+}
+
+div.activity_add_language input[type="text"], div.cke{
+    width: 80%;
+    margin: 0 10% 3em 10%;
+}
+
+div.itinerary{
+    margin: 1em;
+    border-radius: 0.5em;
+    padding: 0.5em;
+    border-left: solid 0.4em #0078ff;
+}
+
+div.itinerary input.time{
+    width: 5em;
+}
+
+div.itinerary table{
+    width: 100%;
+}
+
+div.itinerary table td{
+    border: 0.1em solid #aaaaaa;
+}
+
+div.itinerary table td.itinerary_language{
+    width: 15%;
+}
+
+div.itinerary table td.itinerary_name{
+    width: 25%;
+}
+
+div.itinerary table td.itinerary_description{
+    width: 60%;
+}
+
+div.itinerary table td textarea.itinerary_description, input.itinerary_name{
+    width: 100%;
+}
+
+div.itinerary table td textarea.itinerary_description{
+    height: 4em;
+    resize: vertical;
+}

+ 22 - 0
www-admin/css/m/actividades.css

@@ -0,0 +1,22 @@
+/* /actividades/edit.php */
+
+input#date{
+    width: 8em;
+}
+
+input#city{
+    width: 16em;
+}
+
+div.activity_add_language h4{
+    margin-left: 1em;
+}
+
+div.activity_add_language input[type="text"], div.cke{
+    width: 90%;
+    margin: 0 5% 4em 5%;
+}
+
+div.itinerary table td textarea.itinerary_description{
+    resize: none;
+}

+ 9 - 218
www-admin/css/m/ui.css

@@ -3,163 +3,11 @@
 * show elements for mobile.               *
 ******************************************/
 .mobile{
-    display:    initial;
+    display: initial;
 }
 
 .desktop{
-    display:    none !important;
-}
-
-
-/******************************************
-* Styles for the site header that is      *
-* always visible.                         *
-******************************************/
-
-/* Header top container */
-div#header_m{
-    width:        100%;
-    margin:        0;
-    padding:    0;
-    transition:    max-height 0.9s ease-in-out;
-}
-
-/* Main image of the header, contains the logo */
-div#header_m img#mobile_logo{
-    float:            left;
-    width:            4em;
-    margin-right:    -4em;
-    -webkit-filter:    drop-shadow(0 0 0.2em #336);
-    filter:            url(#drop-shadow);
-    filter:            drop-shadow(0 0 0.2em #336);
-    -ms-filter:        "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#444')";
-    filter:            "progid:DXImageTransform.Microsoft.Dropshadow(OffX=0, OffY=0, Color='#444')";
-    border:            0.05em solid #000011;
-    border-radius:    100%;
-}
-
-div#header_menu_m div{
-    padding-top:        0.6em;
-    font-weight:        bold;
-    text-align:            center;
-    background-color:    #aaaaaa;
-    border:                1px solid #000000;
-}
-
-div#header_menu_m div#header_m_slider{
-    display:            none;
-    background-color:    #0078ff;
-}
-
-div#header_menu_m div#header_m_slider img{
-    height: 1em;
-    width:    1em;
-    margin: auto;
-}
-
-div#header_menu_m div#header_m_title{
-    vertical-align:        middle;
-    color:                #ffffff;
-    max-height:            3.5em;
-    padding-top:        0.75em;
-    transition:            max-height 0.3s ease-in-out;
-    overflow:            hidden;
-    padding:            0;
-    background-color:    #0078ff
-}
-
-div#header_menu_m div#header_m_title span {
-    display:    block;
-    margin:        0.4em;
-}
-
-div#header_menu_m div#header_m_title span img{
-    vertical-align:    middle;
-}
-
-div#header_menu_m div#header_m_title img{
-    height: 1.9em;
-    width:    1.9em;
-    float:    center;
-}
-
-div#header_menu_m div.header_m_link{
-/*     display:            none; */
-    max-height:            0;
-    padding:            0;
-    border:                0;
-    overflow:            hidden;
-    transition:            max-height 0.3s ease-in-out;
-    background-color:    #0078ff;
-}
-
-div#header_menu_m div.header_m_link a{
-    color:            #ffffff;
-    text-shadow:    0 0 0.5em #444444;
-    display:        block;
-    width:            100%;
-    height:            2.8em;
-}
-
-/******************************************
-* Styles for the site footer that is      *
-* always visible.                         *
-******************************************/
-
-/* Table containing the footer elemnts */
-div#footer div#footer_table{
-    display:    block;
-}
-
-div#footer div#footer_table div.tr{
-    display:    block;
-}
-
-/* Each main section of the footer */
-div#footer div#footer_table div.td{
-    width:            100%;
-    display:        block;
-    text-align:        center;
-    margin-bottom:    1em;
-    margin:            0;
-    padding:        0;
-}
-
-/* Images for language selection */
-img.lang{
-    height:            1.5em;
-    margin:            0.5em 1em 0.5em 1em;
-    border-radius:    0.2em;
-    border:            0.1em solid #222222;
-    box-shadow:        0 0 0.3em #333333;
-}
-
-img.lang:hover{
-     box-shadow:        0 0 0.3em #333333; /*NONE*/
-}
-
-/* Mobile app link image in the footer */
-img.app{
-    height:            1.5em;
-    margin:            0.5em 1em 0.5em 1em;
-    border-radius:    0.2em;
-    border:            0.1em solid #222222;
-    box-shadow:        0 0 0.3em #333333;
-}
-
-img.app:hover{
-    box-shadow:    0 0 0.5em #666666; /*NONE*/
-}
-
-/* Each of the social links in the footer */
-img.footer_social_icon{
-    height:            3em;
-    margin:            0.25em;
-}
-
-img.footer_social_icon:hover{
-    -webkit-filter:    drop-shadow(0 0 0.2em #444444);/*NONE*/
-    filter:            drop-shadow(0 0 0.2em #444444);/*NONE*/
+    display: none !important;
 }
 
 
@@ -171,70 +19,13 @@ img.footer_social_icon:hover{
 
 /* Content */
 div#content{
-    margin:        auto;
-    width:        95%;
-    max-width:    initial;
-    min-width:    initial;
+    margin: 2em auto auto auto;
+    width: 95%;
+    max-width: initial;
+    min-width: initial;
 }
 
-/******************************************
-* Styles for the ad window.               *
-******************************************/
-div#ad{
-    width:        70%;
-    position:    fixed;
-    bottom:        -25em;
-    left:        15%;
-    right:        15%
-}
-
-div#ad h3{
-    margin-top:    0.3em;
-}
-
-div#ad div#ad_details{
-    font-size:        90%;
-    margin:            0.3em;
-}
-
-div#ad div#ad_details img{
-    height:            1.2em;
-    width:            1.2em;
-    margin:         0 0.5em 0 0.5em;
-}
-
-div#ad div.entry div#ad_image_container{
-    max-height:    9.5em;
-    margin:        0.5em 0.6em 0.5em 0.6em;
-    text-align:    center;
-}
-
-div#ad div.entry a{
-    font-size:        100%;
-}
-
-/******************************************
-* Styles for the annoying cookie popup.   *
-******************************************/
-div#cookie_popup{
-    font-size:                    80%;
-    color:                        #dddddd;
-    text-align:                    center;
-    position:                    fixed;
-    background-color:            #4c9ed8;
-    border:                        0.5em solid #265774;
-    padding:                    1em 4em 1em 4em;
-    left:                        0em;
-    right:                        0em;
-    bottom:                        0em;
-    -ms-transform:                rotate(0deg); /* IE 9 */
-    -ms-transform-origin:        0% 0%; /* IE 9 */
-    -webkit-transform:            rotate(00deg); /* Chrome, Safari, Opera */
-    -webkit-transform-origin:    0% 0%; /* Chrome, Safari, Opera */
-    -moz-transform:                rotate(00deg); 
-    -moz-transform-origin:        0% 0%; /* Chrome, Safari, Opera */
-    transform:                    rotate(00deg);
-    transform-origin:            0% 0%;
-    box-shadow:                    0 0 3em #265774;
-    transition:                    bottom .5s ease-in-out;
+div#toolbar img{
+    margin-bottom: -1em;
+    opacity: 0.3;
 }

+ 12 - 12
www-admin/css/ui.css

@@ -145,10 +145,10 @@ img.slid{
 
 /* Content */
 div#content{
-    margin:        3em auto auto auto;
-    width:        90%;
-    max-width:    80em;
-    min-width:    60em;
+    margin: 3em auto auto auto;
+    width: 90%;
+    max-width: 80em;
+    min-width: 60em;
 }
 
 /* Sections */
@@ -211,14 +211,14 @@ div#toolbar img{
 }
 
 div#toolbar table{
-    width:                90%;
-    height:                100%;
-    margin-left:        auto;
-    margin-right:        auto;
-    border-spacing:        0;
-    border-collapse:    collapse;
-    margin:                0;
-    table-layout:        fixed;
+    width: 100%;
+    height: 100%;
+    margin-left: auto;
+    margin-right: auto;
+    border-spacing: 0;
+    border-collapse: collapse;
+    margin: 0;
+    table-layout: fixed;
 }
 
 div#toolbar td{

BIN
www-admin/font/FreeSans.ttf


BIN
www-admin/font/FreeSansBold.ttf


BIN
www-admin/font/FreeSansBoldOblique.ttf


BIN
www-admin/font/FreeSansOblique.ttf


BIN
www-admin/font/Vera.ttf


BIN
www-admin/font/VeraBI.ttf


BIN
www-admin/font/VeraBd.ttf


BIN
www-admin/font/VeraIt.ttf


BIN
www-admin/font/VeraMoBI.ttf


BIN
www-admin/font/VeraMoBd.ttf


BIN
www-admin/font/VeraMoIt.ttf


BIN
www-admin/font/VeraMono.ttf


BIN
www-admin/font/VeraSe.ttf


BIN
www-admin/font/VeraSeBd.ttf


BIN
www-admin/font/texgyreadventor-bold.otf


BIN
www-admin/font/texgyreadventor-bolditalic.otf


BIN
www-admin/font/texgyreadventor-italic.otf


BIN
www-admin/font/texgyreadventor-regular.otf


+ 24 - 12
www-admin/functions.php

@@ -247,7 +247,7 @@
             return true;
         }
         else{
-            error_log("Invalid login. username = $_SESSION[name], id = $_SESSION[id]");
+            error_log("Invalid login. username = $user, id = $id");
             return false;
         }
     }
@@ -265,16 +265,28 @@
         }
     }
 
-
-
-    /****************************************************
-    * Increases version value in table settings by one. *
-    * Helpfull for the app to know when to perform a    *
-    * full sync. Must be called after every INSERT,     *
-    * UPDATE or DELETE query to the database.           *
-     ****************************************************/
-    function version(){
-        $con = startdb('rw');
-        mysqli_query($con, 'UPDATE settings SET value = value + 1 WHERE name = "version";');
+    function db_update($con, $s_table, $s_column, $type, $s_value, $id){
+        $table = mysqli_real_escape_string($con, $s_table);
+        $column = mysqli_real_escape_string($con, $s_column);
+        switch (strtoupper($type)){
+            case "NULL":
+                $value = "null";
+                break;
+            case "VARCHAR":
+                $value = "'" . mysqli_real_escape_string($con, $s_value) . "'";
+                break;
+            case "NUMBER":
+                $value = intval(mysqli_real_escape_string($con, $s_value));
+                break;
+            case "DATE":
+                // TODO: Format date
+                $value = mysqli_real_escape_string($con, $s_value);
+                break;
+            default:
+                return -1;
+        }
+        error_log("IVV db_update    UPDATE $table SET $column = $value WHERE id = $id;");
+        $q = mysqli_query($con, "UPDATE $table SET $column = $value WHERE id = $id;");
+        return 0;
     }
 ?>

+ 16 - 0
www-admin/functions/db_update.php

@@ -0,0 +1,16 @@
+<?php
+    include("../functions.php");
+    $con = startdb("rw");
+    error_log("IVV    update_db starting now");
+    if (!checkSession($con)){
+        error_log("Error updating $_GET[table].$_GET[column] : Session has expired.");
+        http_response_code(403); // Forbidden
+        exit (-1);
+    }
+    else{
+        if (db_update($con, $_GET["table"], $_GET["column"], $_GET["type"], $_GET["value"], $_GET["id"]) != 0){
+            error_log("Error updating $_GET[table].$_GET[column] ($_GET[type]) to '$_GET[value] for id $_GET[id]' : Bad request");
+            http_response_code(400); // Bad request
+        }
+    }
+?>

+ 4 - 4
www-admin/login.php

@@ -1,9 +1,9 @@
 <?php
-    include('functions.php');
+    include("functions.php");
     $con = startdb();
-    $user = mysqli_real_escape_string($con, $_POST['user']);
-    $pass = mysqli_real_escape_string($con, $_POST['pass']);
-        $pass = sha1($pass);
+    $user = mysqli_real_escape_string($con, $_POST["user"]);
+    $pass = mysqli_real_escape_string($con, $_POST["pass"]);
+    $pass = sha1($pass);
     if (login($con, $user, $pass)){
         header("Location: /main.php");
     }