Start GPC application

This commit is contained in:
nemunaire 2013-12-31 11:40:02 +01:00
parent ad51d9da73
commit 4de88fb175
10 changed files with 2091 additions and 0 deletions

View File

@ -0,0 +1,8 @@
function Album(elt)
{
this.id = elt.getAttribute("id");
this.type = parseInt(elt.getAttribute("type"));
this.titre = elt.getAttribute("titre");
if (elt.hasAttribute("couleur"))
this.color = elt.getAttribute("couleur");
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
<?php
//Définition de la constante anti-hacking
define("INDEX", 1);
ob_start();
//Inclusion de l'API Onyx
require_once(trim(file_get_contents('../../.onyx')));
require_once(ONYX.'include/functions.php');
$SESS = new Session();
ob_end_clean();
$nom = gpc('auteur', 'post');
$bdd = new BDD();
$bdd->escape($nom);
$chanteurs = $bdd->query("SELECT artiste FROM gsm_titres WHERE artiste LIKE '$nom%' GROUP BY artiste;");
$bdd->deconnexion();
if (!empty($chanteurs) && !empty($nom))
{
print "<ul>\n";
foreach ($chanteurs as $chanteur)
{
print ' <li>'.$chanteur["artiste"]."</li>\n";
}
print "</ul>";
}
?>

View File

@ -0,0 +1,45 @@
function Chanson(elt)
{
this.albums = new Array();
if (elt)
{
this.id = elt.getAttribute("id");
this.titre = elt.getAttribute("titre");
this.artiste = elt.getAttribute("artiste");
for (var albm in elt.getElementsByTagName("inalbum"))
{
if (albm.isInt())
this.albums.push(elt.getElementsByTagName("inalbum")[albm].getAttribute("id"));
}
}
}
Chanson.prototype.inAlbum = function(idAlbum, types)
{
for (var i = 0; i < this.albums.length; i++)
{
if (
(typeof(idAlbum) == 'undefined' || this.albums[i] == idAlbum) &&
(typeof(types) == 'undefined' || types.in_array(GSM_liste_CDs[this.albums[i]].type))
)
return true;
}
return false;
}
Chanson.prototype.search = function(titre, artiste, album, types)
{
if (
(titre == '' || this.titre.toLowerCase().indexOf(titre.toLowerCase()) >= 0) &&
(artiste == '' || this.artiste.toLowerCase().indexOf(artiste.toLowerCase()) >= 0)
)
{
for (var i = 0; i < this.albums.length; i++)
{
if (album == '' || GSM_liste_CDs[this.albums[i]].titre.toLowerCase().indexOf(album.toLowerCase()) >= 0)
return (types.length == 0 || types.in_array(GSM_liste_CDs[this.albums[i]].type));
}
}
return false;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

View File

@ -0,0 +1,101 @@
.front
{
border: solid 1px black;
display: table-cell;
height: 12cm;
text-align: center;
vertical-align: middle;
width: 12cm;
}
.front .title, .front .cd
{
font-size: 60px;
font-family: sans-serif;
font-weight: bolder;
text-transform: uppercase;
}
.sp
{
margin: 1cm 0;
}
.back
{
border: solid 1px black;
display: table;
height: 11.8cm;
width: 15.3cm;
}
.back .title
{
font-variant: small-caps
}
.back .center .title
{
font-size: 14px;
font-weight: bolder;
}
.back .left, .back .right
{
display: block;
height: 11.8cm;
text-align: left;
vertical-align: top;
width: 0.8cm;
}
.back .left
{
border-right: dashed 1px gray;
float: left;
}
.back .right
{
border-left: dashed 1px gray;
float: right;
}
.back .left .title, .back .right .title
{
font-size: 13pt;
font-weight: bolder;
margin-top: 5.5cm;
margin-left: -5.15cm;
position: absolute;
}
.back .left .title
{
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transform: rotate(-90deg);
text-align: center;
width: 11.1cm;
}
.back .right .title
{
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
transform: rotate(90deg);
text-align: center;
width: 11cm;
}
.back .center
{
text-align: center;
}
.back ol
{
text-align: left;
}
.back .author
{
float: right;
width: 45%;
}

View File

@ -0,0 +1,24 @@
body
{
font-family: serif;
font-size: 10px;
margin: auto;
width: 18cm;
}
h1 {
display: none;
}
menu {
display: none;
}
.back .center
{
overflow:hidden;
height: 11.1cm;
}
.back .center ol
{
-webkit-margin-before: 0.5em;
}

View File

@ -0,0 +1,345 @@
html {
height: 100%;
}
body {
background: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.31, #ffa2a1),
color-stop(0.90, #ffd3d3)
);
background: -moz-linear-gradient(
center bottom,
#ffa2a1 31%,
#ffd3d3 90%
);
font-family: serif;
margin-bottom: 10px;
min-height: 80%;
}
a:link, a:visited {
text-decoration: none;
color:#000000;
}
h1 {
text-align: center;
margin-left: 250px;
}
.pagination a:link, .pagination a:visited {
text-decoration: none;
color:#FFFFFF;
}
.pagination a:hover, a:hover {
text-decoration: underline;
}
.news {
background: -webkit-gradient(
linear,
left top,
right bottom,
color-stop(0.31, #ffa2a1),
color-stop(0.66, #ffdcdb)
);
background: -moz-linear-gradient(
right bottom,
#ffa2a1 31%,
#ffdcdb 66%
);
border: 2px solid #ff6062;
border-radius: 17px;
box-shadow: 3px 4px 5px #444466;
height: 127px;
margin: auto;
padding: 20px;
text-align: left;
width: 75%;
}
.vp {
color: orange;
}
menu {
background: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.31, #ffa2a1),
color-stop(0.90, #ffd3d3)
);
background: -moz-linear-gradient(
center bottom,
#ffa2a1 31%,
#ffd3d3 90%
);
border-right: 2px dotted white;
color:#FFFFFF;
font-weight: bold;
height: 100%;
left: 0px;
list-style: none;
margin: 0;
padding: 0;
position: fixed;
text-align: center;
top: 0px;
width: 250px;
}
menu h2 {
margin-left: 69px;
}
menu > li {
margin-bottom: 40px;
text-align: center;
width: 250px;
}
menu > li ul {
margin-left: 20px;
}
menu > li li {
margin-top: 5px;
}
menu li[onclick] {
cursor: pointer;
}
menu li[onclick]:hover {
text-decoration: underline;
}
label {
font-weight: bold;
}
label:hover {
text-decoration: underline;
}
form {
background: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0.31, #cc6d1d),
color-stop(0.95, #ff8f26)
);
background: -moz-linear-gradient(
center bottom,
#cc6d1d 31%,
#ff8f26 95%
);
border: 1px solid #ff9b42;
border-radius: 25px;
box-shadow: 2px 2px 5px #553333;
}
form#addAlbms, form#rechTitles {
margin: auto;
padding: 13px;
text-align: left;
width: 400px;
}
form#addAlbms div, form#rechTitles div {
text-align: center;
}
form#rechTitles input[type=text] {
width: 234px;
}
form#rechTitles input[type=checkbox] {
margin-left: 120px;
}
form#addAlbms div label, form#rechTitles div label {
margin-right: 4px;
}
form#addAlbms div#testColor {
background-color: black;
border: solid 1px black;
display: inline-block;
height: 1em;
margin-left: 5px;
margin-bottom: -4px;
width: 2em;
}
form#ajout {
height: 182px;
margin: 10px auto;
padding: 13px;
text-align: left;
width: 642px;
}
form#ajout input[type=text] {
width: 444px;
}
form#ajout select {
margin-right: 10px;
}
form#ajout label {
float: left;
display: block;
font-weight: bold;
margin: 10px 7px 10px 0;
text-align: right;
width: 110px;
}
form#ajout label:hover {
text-decoration: underline;
}
input[type=text], select {
margin: 10px 0;
transition: background 0.75s;
-moz-transition: background 0.75s;
-webkit-transition: background 0.75s;
-o-transition: background 0.75s;
}
input, select {
background: #FF6600;
border: #CA2A20 solid 1px;
border-radius: 3px;
margin-top: 5px;
}
input:hover, input:focus, select:hover, select:focus {
background: #CC6600;
}
input.erreur, select.erreur {
background: #CC0000;
}
div#GSM_menu {
background: url(backmenu.png);
color:#FFFFFF;
top: 0px;
font-weight: bold;
height: 1200px;
padding-top: 30px;
position: fixed;
text-align: center;
left: 0px;
width: 250px;
}
div#GSM_menu h2 {
margin-bottom: 40px;
}
div#contenu {
margin-left: 250px;
text-align: center;
}
.table {
border: 1px solid black;
border-radius: 10px;
box-shadow: 3px 3px 5px #666666;
margin: auto;
}
.table .body div {
transition: background 500ms;
-moz-transition: background 500ms;
-webkit-transition: background 500ms;
-o-transition: background 500ms;
}
.table .body div.elt0 {
background: #ec7d60;
}
.table .body div.elt1 {
background: #f68063;
}
.table .body div:hover {
background: #fa8022;
}
.table.cols2 div span {
display: inline-block;
width: 40%;
}
.table.cols3 div span {
display: inline-block;
width: 40%;
}
.table.cols3 div span+span+span {
width: 20%;
}
.table div.lign {
display: inline-block;
width: 100%;
}
.table .head {
background: #f26340;
border-bottom: 1px solid black;
border-radius: 10px 10px 0 0;
font-weight: bolder;
display: block;
text-align: center;
width: 100%;
}
.table .foot { border-radius: 0 0 10px 10px; }
.table.stats {
float: left;
margin: 0 1%;
width: 31%;
}
.table#list {
width: 83%;
}
.table#list .head {
cursor: pointer;
}
.table .body div {
cursor: pointer;
}
.pagination {
background: #f26340;
border: 1px solid black;
color: white;
margin: auto;
width: 442px;
}
.pagination.top {
border-radius: 10px 10px 0 0;
border-bottom: none;
}
.pagination.bottom {
border-top: none;
border-radius: 0 0 10px 10px;
box-shadow: 0px 2px 7px #666666;
}
.pagination a {
cursor: pointer;
padding: 0 5px;
}
.front, .back
{
background: white;
}
.back .center
{
overflow:auto;
}
.back ol li:hover
{
background-color: teal;
}
div.autocomplete
{
margin-top: 20px;
margin-left: 6px;
}

View File

@ -0,0 +1,276 @@
<?php
//Fichier appelé pour afficher l'application
$p = strtolower(gpc("p"));
function format_list($cuilleres, $xml, $xml_root)
{
if (!empty($cuilleres))
{
foreach($cuilleres as $cuillere)
{
$c = $cuillere[0];
if (empty($c["id"]))
continue;
$cuil = $xml->createElement("cuillere");
$cuil->setAttribute("id", $c["id"]);
$cuil->setAttribute("name", $c["name"]);
$cuil->setAttribute("category", $c["category"]);
$xml_root->appendChild($cuil);
}
}
}
if ($p == "liste")
{
$bdd = new BDD();
$req = $bdd->query("SELECT P.id, P.name, C.categ AS category FROM gpc_pc P LEFT JOIN gpc_categ C ON C.id = P.id_categ;");
$req["nombre"] = $bdd->num_rows;
$bdd->deconnexion();
format_list($req, $xml, $xml_root);
}
elseif ($p == "add" && ($type = intval(gpc("type", "post"))) && ($title = gpc("title", "post")))
{
$color = hexdec(gpc("color", "post"));
$bdd = new BDD();
$bdd->escape($title);
$bdd->query("INSERT INTO `gsm_albums` (type, titre, color) VALUES ($type, '$title', $color);");
$id = $bdd->insert_id();
if ($id == 0)
{
$res = $bdd->unique_query("SELECT id FROM `gsm_albums` WHERE type = $type AND titre = '$title';");
$id = $res["id"];
}
$req = $bdd->unique_query("SELECT COUNT(*) AS nombre FROM gsm_in");
$bdd->deconnexion();
if ($id != 0)
$xml_root->appendChild($xml->createElement("id", $id));
}
elseif ($p == "del" && $id = intval(gpc("id", "post")))
{
$alb = intval(gpc("alb", "post"));
$bdd = new BDD();
if (empty($alb))
$bdd->query("DELETE FROM `gsm_in` WHERE id_titre = $id;");
else
$bdd->query("DELETE FROM `gsm_in` WHERE id_titre = $id AND id_album = $alb;");
$res = $bdd->unique_query("SELECT COUNT(*) AS c FROM `gsm_in` WHERE id_titre = $id;");
if ($res["c"] <= 0)
$bdd->query("DELETE FROM `gsm_titres` WHERE id = $id;");
$req = $bdd->unique_query("SELECT COUNT(*) AS nombre FROM gsm_in");
$bdd->deconnexion();
}
elseif ($p == "color" && ($type = intval(gpc("type", "get"))) && ($idAlbum = intval(gpc("id", "get"))))
{
$bdd = new BDD();
$res = $bdd->unique_query("SELECT color FROM `gsm_albums` WHERE id = $idAlbum;");
$req = $bdd->unique_query("SELECT COUNT(*) AS nombre FROM gsm_in;");
$bdd->deconnexion();
$xml_root->appendChild($xml->createElement("color", sprintf("#%06X", $res["color"])));
$color2R = ($res["color"] >> 16) & 255;
if ($color2R >= 25)
$color2R -= 25;
$color2G = ($res["color"] >> 8) & 255;
if ($color2G >= 25)
$color2G -= 25;
$color2B = ($res["color"]) & 255;
if ($color2B >= 25)
$color2B -= 25;
$xml_root->appendChild($xml->createElement("color", sprintf("#%02X%02X%02X", $color2R, $color2G, $color2B)));
}
elseif ($p == "rech")
{
$where = "TRUE";
$type = array();
$bdd = new BDD();
foreach($_POST as $key => $val)
{
$v = gpc($key, "post");
$bdd->escape($v);
if ($key == "titre")
$where .= " AND T.titre LIKE = '%".$v."%'";
else if ($key == "artiste")
$where .= " AND T.artiste LIKE = '%".$v."%'";
else if ($key == "album")
$where .= " AND A.titre LIKE = '%".$v."%'";
else if (preg_match($key, "#^type([0-9]+)$#", $out) && gpc($key, "post") == "1")
$type[] = intval($out[1]);
}
if (count($type) > 0)
{
$where .= " AND (FALSE";
foreach($type as $t)
$where .= " OR A.type = ".$t;
$where .= ")";
}
$rech = $bdd->query("SELECT T.*, A.id AS id_album, A.type, A.titre AS nom FROM gsm_titres T RIGHT OUTER JOIN gsm_in I ON T.id = I.id_titre RIGHT OUTER JOIN gsm_albums A ON A.id = I.id_album WHERE ".$where);
$req = $bdd->unique_query("SELECT COUNT(*) AS nombre FROM gsm_in");
$bdd->deconnexion();
format_list(build_list($rech), $xml, $xml_root);
$xml_cds = $xml->createElement("album");
if (!empty($rech))
{
foreach($rech as $ligne)
{
$chan = $xml->createElement("chanson");
$chan->setAttribute("id", $ligne["id"]);
$chan->setAttribute("titre", $ligne["titre"]);
$chan->setAttribute("chanteur", $ligne["chanteur"]);
$chan->setAttribute("CD_decenie", $ligne["CDDeca"]);
$chan->setAttribute("CD_annee", $ligne["CDAnnee"]);
$chan->setAttribute("CD_interprete", $ligne["CDChanteur"]);
$xml_cds->appendChild($chan);
}
}
$xml_root->appendChild($xml_cds);
}
elseif ($p == "stats")
{
$cds = array();
$bdd = new BDD();
$cds["annees"] = $bdd->query("SELECT A.id, A.titre AS nom, COUNT(A.id) AS nombre FROM gsm_albums A RIGHT OUTER JOIN gsm_in I ON A.id = I.id_album WHERE A.type = 1 GROUP BY A.id ORDER BY nom DESC;");
$cds["interpretes"] = $bdd->query("SELECT A.id, A.titre AS nom, COUNT(A.id) AS nombre FROM gsm_albums A RIGHT OUTER JOIN gsm_in I ON A.id = I.id_album WHERE A.type = 3 GROUP BY A.id ORDER BY nom ASC;");
$cds["decenies"] = $bdd->query("SELECT A.id, A.titre AS nom, COUNT(A.id) AS nombre FROM gsm_albums A RIGHT OUTER JOIN gsm_in I ON A.id = I.id_album WHERE A.type = 2 GROUP BY A.id ORDER BY nom ASC;");
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm_in");
$bdd->deconnexion();
if (!empty($cds["annees"]))
{
foreach($cds["annees"] as $ligne)
{
$cd = $xml->createElement("annee");
$cd->setAttribute("id", $ligne["id"]);
$cd->setAttribute("nbTitles", $ligne["nombre"]);
$xml_root->appendChild($cd);
}
}
if (!empty($cds["interpretes"]))
{
foreach($cds["interpretes"] as $ligne)
{
$cd = $xml->createElement("interprete");
$cd->setAttribute("id", $ligne["id"]);
$cd->setAttribute("nbTitles", $ligne["nombre"]);
$xml_root->appendChild($cd);
}
}
if (!empty($cds["decenies"]))
{
foreach($cds["decenies"] as $ligne)
{
$cd = $xml->createElement("decenie");
$cd->setAttribute("id", $ligne["id"]);
$cd->setAttribute("nbTitles", $ligne["nombre"]);
$xml_root->appendChild($cd);
}
}
}
elseif ($p == "cds")
{
$bdd = new BDD();
$cds["decenies"] = $bdd->query("SELECT A.*, COUNT(T.id) AS nombre FROM gsm_cddece A LEFT OUTER JOIN gsm T ON A.id = T.CDDeca GROUP BY A.nom;");
$cds["interpretes"] = $bdd->query("SELECT A.*, COUNT(T.id) AS nombre FROM gsm_cdchant A LEFT OUTER JOIN gsm T ON A.id = T.CDChanteur GROUP BY A.nom;");
$cds["annees"] = $bdd->query("SELECT A.*, COUNT(T.id) AS nombre FROM gsm_cdannee A LEFT OUTER JOIN gsm T ON A.id = T.CDAnnee GROUP BY A.nom;");
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm_in");
$bdd->deconnexion();
$xml_cds = $xml->createElement("decenies");
if (!empty($cds["decenies"]))
{
foreach($cds["decenies"] as $ligne)
{
$cd = $xml->createElement("cd");
$cd->setAttribute("id", $ligne["id"]);
$cd->setAttribute("nom", $ligne["nom"]);
$cd->setAttribute("nombre_titres", $ligne["nombre"]);
$xml_cds->appendChild($cd);
}
}
$xml_root->appendChild($xml_cds);
$xml_cds = $xml->createElement("interpretes");
if (!empty($cds["interpretes"]))
{
foreach($cds["interpretes"] as $ligne)
{
$cd = $xml->createElement("cd");
$cd->setAttribute("id", $ligne["id"]);
$cd->setAttribute("nom", $ligne["nom"]);
$cd->setAttribute("nombre_titres", $ligne["nombre"]);
$xml_cds->appendChild($cd);
}
}
$xml_root->appendChild($xml_cds);
$xml_cds = $xml->createElement("annees");
if (!empty($cds["annees"]))
{
foreach($cds["annees"] as $ligne)
{
$cd = $xml->createElement("cd");
$cd->setAttribute("id", $ligne["id"]);
$cd->setAttribute("nom", $ligne["nom"]);
$cd->setAttribute("nombre_titres", $ligne["nombre"]);
$xml_cds->appendChild($cd);
}
}
$xml_root->appendChild($xml_cds);
}
elseif (!empty($titre) && !empty($auteur))
{
$alb = intval(gpc("alb", "post"));
$type = intval(gpc("type", "post"));
$id = intval(gpc("id"));
$bdd = new BDD();
$bdd->escape($titre);
$bdd->escape($auteur);
if ($id)
$bdd->query("UPDATE gsm_titres SET titre = '$titre', artiste = '$auteur' WHERE id = $id;");
else
{
$bdd->query("INSERT INTO gsm_titres (titre, artiste) VALUES ('$titre', '$auteur');");
$res = $bdd->insert_id();
if (empty($res))
{
$res = $bdd->unique_query("SELECT id FROM gsm_titres WHERE titre = '$titre' AND artiste = '$auteur';");
$res = $res["id"];
}
if (!empty($alb))
$bdd->query("INSERT INTO gsm_in (id_titre, id_album) VALUES ($res, $alb);");
}
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm_titres");
$bdd->deconnexion();
$xml_root->appendChild($xml->createElement("id", $res));
}
else
{
$bdd = new BDD();
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm_titres");
$bdd->deconnexion();
}
$json["nombre"] = $req["nombre"];
?>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<application active="1">
<property value="name">Gérer ses petites cuillères</property>
<property value="description">Cette application vous permet de gérer facilement vos petites-cuillères.</property>
<property value="etatAvancement">alpha</property>
<property value="version">0.1</property>
<property value="lang">fr_FR</property>
<property value="developpeur"><![CDATA[<span style="font-variant: small-caps">Mercier</span> Pierre-Olivier]]></property>
<property value="corps">contenu</property>
<security type="users" default="restricted">
<user>1</user>
<user>3</user>
</security>
<display value="logo">0</display>
<display value="css" media="all">main.css</display>
<display value="css" media="screen">style.css</display>
<display value="css" media="print">print.css</display>
<display value="script">album.js</display>
<display value="script">chanson.js</display>
<display value="script">app.js</display>
<display value="body">
<![CDATA[
<h1>Bienvenue dans la gestion des petites cuillères</h1>
<menu>
<li><h2>Petites cuillères</h2></li>
<li onclick="GPC_add();">Ajouter une cuillère</li>
<li onclick="GPC_listCateg();">Liste</li>
<li>Nombre de petite-cuillères enregistrées : <span id="nbpc"></span></li>
</menu>
<div id="contenu"></div>
]]>
</display>
<display value="js">
<![CDATA[
function runApplication(property, display, json)
{
$('logo').style.display = 'none';
$('contenu').innerHTML = "";
news = document.createElement("div");
news.className = "news";
news.innerHTML = "<h3>Bienvenue dans la version béta de GPC pour Pommultimédia For Home !</h3>Cette nouvelle version est plus rapide que la version précédente et a une meilleur intégration avec Pommultimédia For Home.<br />N'hésitez pas à nous faire part de vos commentaires ;)";
$('contenu').appendChild(news);
}
]]>
</display>
<config value="table_bdd">gpc</config>
</application>