commit c545f8b1a164924f96db6b8fec0cf066682b3dae Author: Aurelien Labate Date: Fri Dec 27 01:57:39 2019 +0100 Initial commit diff --git a/Images/Banniere.png b/Images/Banniere.png new file mode 100644 index 0000000..e77f1f0 Binary files /dev/null and b/Images/Banniere.png differ diff --git a/Images/Navigation.png b/Images/Navigation.png new file mode 100644 index 0000000..c1cf8fe Binary files /dev/null and b/Images/Navigation.png differ diff --git a/Images/Onglet.png b/Images/Onglet.png new file mode 100644 index 0000000..9dac9e4 Binary files /dev/null and b/Images/Onglet.png differ diff --git a/Images/Planete-Casio.png b/Images/Planete-Casio.png new file mode 100644 index 0000000..7cd9bf9 Binary files /dev/null and b/Images/Planete-Casio.png differ diff --git a/Images/TI-Planet.png b/Images/TI-Planet.png new file mode 100644 index 0000000..bd3de94 Binary files /dev/null and b/Images/TI-Planet.png differ diff --git a/Images/ampoule.png b/Images/ampoule.png new file mode 100644 index 0000000..8421ec4 Binary files /dev/null and b/Images/ampoule.png differ diff --git a/Images/attention.png b/Images/attention.png new file mode 100644 index 0000000..12b889e Binary files /dev/null and b/Images/attention.png differ diff --git a/Images/autres.png b/Images/autres.png new file mode 100644 index 0000000..087b66f Binary files /dev/null and b/Images/autres.png differ diff --git a/Images/boucles.png b/Images/boucles.png new file mode 100644 index 0000000..0895754 Binary files /dev/null and b/Images/boucles.png differ diff --git a/Images/buttons.gif b/Images/buttons.gif new file mode 100644 index 0000000..f9f105c Binary files /dev/null and b/Images/buttons.gif differ diff --git a/Images/conditions.png b/Images/conditions.png new file mode 100644 index 0000000..e8d92cf Binary files /dev/null and b/Images/conditions.png differ diff --git a/Images/conversion_algo.png b/Images/conversion_algo.png new file mode 100644 index 0000000..4e4e7a6 Binary files /dev/null and b/Images/conversion_algo.png differ diff --git a/Images/conversion_casio.png b/Images/conversion_casio.png new file mode 100644 index 0000000..590dd9b Binary files /dev/null and b/Images/conversion_casio.png differ diff --git a/Images/conversion_ti.png b/Images/conversion_ti.png new file mode 100644 index 0000000..2f12dc7 Binary files /dev/null and b/Images/conversion_ti.png differ diff --git a/Images/disable.png b/Images/disable.png new file mode 100644 index 0000000..ac639b1 Binary files /dev/null and b/Images/disable.png differ diff --git a/Images/entrees-sorties.png b/Images/entrees-sorties.png new file mode 100644 index 0000000..75aa49a Binary files /dev/null and b/Images/entrees-sorties.png differ diff --git a/Images/executer.png b/Images/executer.png new file mode 100644 index 0000000..f560a59 Binary files /dev/null and b/Images/executer.png differ diff --git a/Images/favicon_ie.ico b/Images/favicon_ie.ico new file mode 100644 index 0000000..192f273 Binary files /dev/null and b/Images/favicon_ie.ico differ diff --git a/Images/mathematiques_magiques.png b/Images/mathematiques_magiques.png new file mode 100644 index 0000000..b9b0eb3 Binary files /dev/null and b/Images/mathematiques_magiques.png differ diff --git a/Images/miniature_festivalgo.png b/Images/miniature_festivalgo.png new file mode 100644 index 0000000..e1c562a Binary files /dev/null and b/Images/miniature_festivalgo.png differ diff --git a/Images/onglet_deroulant.png b/Images/onglet_deroulant.png new file mode 100644 index 0000000..44f78f4 Binary files /dev/null and b/Images/onglet_deroulant.png differ diff --git a/Images/onglet_deroulant_selection.png b/Images/onglet_deroulant_selection.png new file mode 100644 index 0000000..cf9a9d6 Binary files /dev/null and b/Images/onglet_deroulant_selection.png differ diff --git a/Images/pause.png b/Images/pause.png new file mode 100644 index 0000000..ab7a4ef Binary files /dev/null and b/Images/pause.png differ diff --git a/Images/publier.png b/Images/publier.png new file mode 100644 index 0000000..8bd6e68 Binary files /dev/null and b/Images/publier.png differ diff --git a/Images/reset.png b/Images/reset.png new file mode 100644 index 0000000..80f004b Binary files /dev/null and b/Images/reset.png differ diff --git a/Images/schema_algo.png b/Images/schema_algo.png new file mode 100644 index 0000000..91cacd7 Binary files /dev/null and b/Images/schema_algo.png differ diff --git a/Images/schema_condition.png b/Images/schema_condition.png new file mode 100644 index 0000000..6a91a5b Binary files /dev/null and b/Images/schema_condition.png differ diff --git a/Images/signes.png b/Images/signes.png new file mode 100644 index 0000000..4a46d15 Binary files /dev/null and b/Images/signes.png differ diff --git a/Images/support_menus.png b/Images/support_menus.png new file mode 100644 index 0000000..9a75b2b Binary files /dev/null and b/Images/support_menus.png differ diff --git a/Images/tester.png b/Images/tester.png new file mode 100644 index 0000000..d247a65 Binary files /dev/null and b/Images/tester.png differ diff --git a/Images/toolbar.gif b/Images/toolbar.gif new file mode 100644 index 0000000..30ceabd Binary files /dev/null and b/Images/toolbar.gif differ diff --git a/Perrine.php b/Perrine.php new file mode 100644 index 0000000..b6b879c --- /dev/null +++ b/Perrine.php @@ -0,0 +1,41 @@ + + + + + + Compte à rebours :) + + + + + +
+ + + + + diff --git a/Polices/Action_Man/Action_Man-webfont.eot b/Polices/Action_Man/Action_Man-webfont.eot new file mode 100644 index 0000000..33d22b3 Binary files /dev/null and b/Polices/Action_Man/Action_Man-webfont.eot differ diff --git a/Polices/Action_Man/Action_Man-webfont.svg b/Polices/Action_Man/Action_Man-webfont.svg new file mode 100644 index 0000000..8f32301 --- /dev/null +++ b/Polices/Action_Man/Action_Man-webfont.svg @@ -0,0 +1,157 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c Iconian FontsShyFonts Type Foundry 2000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Polices/Action_Man/Action_Man-webfont.ttf b/Polices/Action_Man/Action_Man-webfont.ttf new file mode 100644 index 0000000..8ee2cc3 Binary files /dev/null and b/Polices/Action_Man/Action_Man-webfont.ttf differ diff --git a/Polices/Action_Man/Action_Man-webfont.woff b/Polices/Action_Man/Action_Man-webfont.woff new file mode 100644 index 0000000..17bd0ff Binary files /dev/null and b/Polices/Action_Man/Action_Man-webfont.woff differ diff --git a/Polices/Action_Man/Iconian Fonts License.txt b/Polices/Action_Man/Iconian Fonts License.txt new file mode 100644 index 0000000..e8c5198 --- /dev/null +++ b/Polices/Action_Man/Iconian Fonts License.txt @@ -0,0 +1,23 @@ +By downloading this font package you agree to the following terms +of use: + + - This FONT PACKAGE is FREEWARE and may be distributed ONLY via the + Internet for FREE. Under NO circumstances may this FONT PACKAGE + be sold for a profit nor be included as part of another product or + CD-ROM compilation. If you wish to include this FONT PACKAGE for + FREE distribution on your Web Site, please include all of the fonts + and original documentation supplied with this FONT PACKAGE. + + - You may install and use this FONT PACKAGE on an unlimited + amount of machines. + + - You may NOT rename, edit, or create any alternate variations of + the fonts included in this FONT PACKAGE. + + - This FONT PACKAGE comes "as is" with NO warranty whatsoever. + SHYFONTS accepts NO responsibility for any damages or loss of + any kind due to the use of this FONT PACKAGE. The use of this + FONT PACKAGE is solely your responsibility -- you use this FONT + PACKAGE at your own risk. + +Thank you for downloading this font package and enjoy! \ No newline at end of file diff --git a/Polices/Crete_Round/Crete Round SIL OFL Font License 1.1.txt b/Polices/Crete_Round/Crete Round SIL OFL Font License 1.1.txt new file mode 100644 index 0000000..75d6e1a --- /dev/null +++ b/Polices/Crete_Round/Crete Round SIL OFL Font License 1.1.txt @@ -0,0 +1,94 @@ +Copyright (c) 2011, TypeTogether (www.type-together.com), +with Reserved Font Names "Crete" and "Crete Round" + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/Polices/Crete_Round/CreteRound-Italic-webfont.eot b/Polices/Crete_Round/CreteRound-Italic-webfont.eot new file mode 100644 index 0000000..bd7222c Binary files /dev/null and b/Polices/Crete_Round/CreteRound-Italic-webfont.eot differ diff --git a/Polices/Crete_Round/CreteRound-Italic-webfont.svg b/Polices/Crete_Round/CreteRound-Italic-webfont.svg new file mode 100644 index 0000000..cf52f9e --- /dev/null +++ b/Polices/Crete_Round/CreteRound-Italic-webfont.svg @@ -0,0 +1,189 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 TypeTogether wwwtypetogethercom with Reserved Font Names Crete and Crete Round +Designer : Veronika Burian +Foundry : TypeTogether +Foundry URL : wwwtypetogethercomCrete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Polices/Crete_Round/CreteRound-Italic-webfont.ttf b/Polices/Crete_Round/CreteRound-Italic-webfont.ttf new file mode 100644 index 0000000..4d9c85f Binary files /dev/null and b/Polices/Crete_Round/CreteRound-Italic-webfont.ttf differ diff --git a/Polices/Crete_Round/CreteRound-Italic-webfont.woff b/Polices/Crete_Round/CreteRound-Italic-webfont.woff new file mode 100644 index 0000000..dc1e69d Binary files /dev/null and b/Polices/Crete_Round/CreteRound-Italic-webfont.woff differ diff --git a/Polices/Crete_Round/CreteRound-Regular-webfont.svg b/Polices/Crete_Round/CreteRound-Regular-webfont.svg new file mode 100644 index 0000000..b385f49 --- /dev/null +++ b/Polices/Crete_Round/CreteRound-Regular-webfont.svg @@ -0,0 +1,190 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 TypeTogether wwwtypetogethercom with Reserved Font Names Crete and Crete Round +Designer : Veronika Burian +Foundry : TypeTogether +Foundry URL : wwwtypetogethercomCrete + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Polices/Crete_Round/CreteRound-Regular-webfont.woff b/Polices/Crete_Round/CreteRound-Regular-webfont.woff new file mode 100644 index 0000000..7bde083 Binary files /dev/null and b/Polices/Crete_Round/CreteRound-Regular-webfont.woff differ diff --git a/Polices/Crete_Round/demo.html b/Polices/Crete_Round/demo.html new file mode 100644 index 0000000..ffe6478 --- /dev/null +++ b/Polices/Crete_Round/demo.html @@ -0,0 +1,38 @@ + + + + + + + Font Face Demo + + + + + +
+

Font-face Demo for the Crete Round Font

+ + + +

Crete Round Italic - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+ + + +

Crete Round Regular - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+ +
+ + diff --git a/Polices/Crete_Round/stylesheet.css b/Polices/Crete_Round/stylesheet.css new file mode 100644 index 0000000..12855ce --- /dev/null +++ b/Polices/Crete_Round/stylesheet.css @@ -0,0 +1,28 @@ +/* Generated by Font Squirrel (http://www.fontsquirrel.com) on November 9, 2012 01:39:30 PM America/New_York */ + + + +@font-face { + font-family: 'CreteRoundItalic'; + src: url('CreteRound-Italic-webfont.eot'); + src: url('CreteRound-Italic-webfont.eot?#iefix') format('embedded-opentype'), + url('CreteRound-Italic-webfont.woff') format('woff'), + url('CreteRound-Italic-webfont.ttf') format('truetype'), + url('CreteRound-Italic-webfont.svg#CreteRoundItalic') format('svg'); + font-weight: normal; + font-style: normal; + +} + +@font-face { + font-family: 'CreteRoundRegular'; + src: url('CreteRound-Regular-webfont.eot'); + src: url('CreteRound-Regular-webfont.eot?#iefix') format('embedded-opentype'), + url('CreteRound-Regular-webfont.woff') format('woff'), + url('CreteRound-Regular-webfont.ttf') format('truetype'), + url('CreteRound-Regular-webfont.svg#CreteRoundRegular') format('svg'); + font-weight: normal; + font-style: normal; + +} + diff --git a/a_propos.php b/a_propos.php new file mode 100644 index 0000000..38a3bae --- /dev/null +++ b/a_propos.php @@ -0,0 +1,36 @@ + + + + + + + + + + Festiv'Algo - A propos + + + + + +
+ +
+
+ +


Evènements :

+
+
    +
  • 20/04/13 : Mise en ligne du site.
  • +
  • 9/05/13 : Correction des problèmes de position du curseur dans l'onglet principal.
  • +
  • 20/05/13 : Ajout de la coloration syntaxique pour le debuggage.
  • +
  • 14/12/13 : Changement de serveur et remise en ligne du site après un mois d'indisponibilité.
  • +
+
+
+
+ +
+ + + diff --git a/aide.css b/aide.css new file mode 100644 index 0000000..4b96319 --- /dev/null +++ b/aide.css @@ -0,0 +1,202 @@ +#content +{ + height: 2010px; +} + +article +{ + position: absolute; + width: 980px; + top: 285px; + left: 0px; +} + +h2 +{ + font-family: Normal, Arial; + font-size: 24px; + font-style: bold; + color: black; + text-align: left; + margin-left: 70px; + margin-bottom: 20px; +} + +.partie +{ + margin-bottom: 50px; +} + +.paragraphes +{ + text-align: justify; + background-color: #FFD745; + border: solid; + border-width: 4px; + border-radius: 5px; + border-color: #FAC801; + font-family: Normal, Arial; + font-size: 16px; + font-style: none; + color: black; + padding: 5px 11px 7px 11px; + margin-left: 45px; + margin-right: 45px; +} + +#par1 +{ + width: 455px; +} + +#par3 +{ + width: 515px; +} + +#schema_algo +{ + float: right; + margin-left: 45px; + margin-right: 45px; + margin-top: -44px; +} + +#schema_condition +{ + float: right; + margin-left: 45px; + margin-right: 45px; + margin-top: -44px; +} + +.exemples_code +{ + margin-left: 25px; + margin-bottom: 10px; +} + +#code_condition +{ + height: 68px; +} + +.code_algo +{ + display: inline-block; + background-color: rgb(255, 84, 84); + width: 230px; + height: 22px; + border: solid; + border-radius: 14px; + border-width: 4px; + border-color: rgb(236, 10, 10); + font-family: Verdanna, Arial; + color: rgb(173, 0, 0); + font-size: 14px; + padding-left: 8px; + padding-top: 4px; + margin: 14px -40px 12px 0px; +} + + +.type_algo +{ + font-family: Normal, Arial; + position: relative; + right: 30px; + top: -6px; + font-size: 12px; + color: rgb(218, 7, 7); +} + +.code_casio +{ + display: inline-block; + background-color: rgb(145, 226, 99); + width: 230px; + height: 22px; + border: solid; + border-radius: 14px; + border-width: 4px; + border-color: rgb(66, 167, 66); + font-family: Verdanna, Arial; + color: rgb(62, 139, 10); + font-size: 14px; + padding-left: 8px; + padding-top: 4px; + margin: 14px -7px 12px 0px; +} + +#type_condition +{ + top: -54px; +} + +.type_casio +{ + font-family: Normal, Arial; + position: relative; + right: 31px; + top: -6px; + font-size: 12px; + color: rgb(58, 173, 30); +} + +.code_ti +{ + display: inline-block; + background-color: rgb(155, 148, 248); + width: 230px; + height: 22px; + border: solid; + border-radius: 14px; + border-width: 4px; + border-color: rgb(60, 103, 167); + font-family: Verdanna, Arial; + color: rgb(40, 83, 175); + font-size: 14px; + padding-left: 8px; + padding-top: 4px; + margin: 14px -40px 12px 0px; +} + +.type_ti +{ + font-family: Normal, Arial; + position: relative; + right: -19px; + top: -6px; + font-size: 12px; + color: rgb(12, 26, 99); +} + +.resultats_code +{ + width: 622px; + height: 45px; + background-color: #EED858; + border: solid; + border-width: 4px; + border-radius: 14px; + border-color: #D2A124; + font-family: Normal, Arial; + padding: 0px 0px 8px 12px; + padding-left: 6px; +} + +.resultats_title +{ + font-size: 18px; + color: #DB7517; + margin-top: 0px; +} + +.resultats_content +{ + font-size: 15px; + color: #D29A17; + margin-top: -16px; + margin-left: 8px; +} + diff --git a/aide.php b/aide.php new file mode 100644 index 0000000..e3b932f --- /dev/null +++ b/aide.php @@ -0,0 +1,110 @@ + + + + + + + + + + + Festiv'Algo - Aide pour la programmation d'algorithmes. Tutoriel d'algorithmique, TI Basic et Basic Casio. + + + + + +
+ + +
+
+

• Qu'est-ce qu'un algorithme ?

+ Schéma d'un algorithme +
+ Le mot "algorithme" vient du nom du mathématicien Persan Al-Khuwarizmi, qui inventa une méthode, au début du IXème siècle, pour résoudre des équations pas à pas.
+ Un algorithme est une suite d'opérations appliquées dans un ordre donné. +
+
+
+
+

• Variables et affectation

+
+
+ Dans un algorithme, on commence par l'entrée des données. Chacune de ces données est stockée dans la mémoire de la calculatrice ou de l'ordinateur à un emplacement nommé variable et est repérée par une lettre.
+ Les instructions que l'on peut pratiquer avec une variable sont :

+ + - la saisie : on demande à l'utilisateur de donner une valeur à une variable.
+
+
Saisir A
Algorithme
? → A
Casio
Input A
TI +

Exécution :

+ +
+
+
+
+ + - l'affectation : on donne à la variable une certaine valeur ou le résultat d'un calcul.
+
+
A Prend_la_valeur 3 * 5
Algorithme
3 * 5 → A
Casio
3 * 5 → A
TI +
+
+ + - l'affichage : on affiche le contenu de la variable. +
+
Afficher A
Algorithme
A∠
Casio
Disp A
TI +

Exécution :

+
+ 15 +
+
+
+
+
+
+

• Les conditions

+ Schéma d'une condition +
+ La résolution de certains problèmes conduit parfois à une situation dans laquelle la décision prise est soumise à condition.
+ Si la condition est vérifiée, on effectue une première tâche, sinon on effectue une seconde tâche. +
+

+
+
+
Si A = 1
Alors ...
(Sinon ...)
Fin_si
Algorithme +
If A = 1
Then ...
(Else ...)
IfEnd
Casio +
If A = 1
Then ...
(Else ...)
End
TI +
+ + Le "Sinon" n'est pas systématique. Sans cette instruction, si la condition n'est pas vérifiée, la tâche n'est pas effectuée et l'algorithme passe à l'instruction suivante. +
+
+ +
+

• Les boucles

+
+ Pendant l'exécution d'un programme, il est possible d'avoir à réaliser plusieurs fois de suites la même tâche.
+ Il existe deux types de boucles :

+ + - la boucle conditionelle : on répète les mêmes instructions tant qu'une condition est remplie. +
+
Tant_que A = 1
...
...
Fin_tant_que
Algorithme +
While A = 1
...
...
End
Casio +
While A = 1
...
...
WhileEnd
TI +
+ - la boucle itérative : on répète les mêmes instructions un certain nombre de fois. +
+
Pour A Allant_de 0 à 10
...
...
Fin_pour
Algorithme +
For 0 → A To 10
...
...
Next
Casio +
For(A,0,10)
...
...
End
TI +
+
+
+
+
+ +
+
+ + + diff --git a/algo_soumis.php b/algo_soumis.php new file mode 100644 index 0000000..e00baa7 --- /dev/null +++ b/algo_soumis.php @@ -0,0 +1,52 @@ + + + + + + + + + + + Festiv'Algo - Publier un algorithme + + + +
+ +
+ ".$titre."

".$auteur."
".$mail."


".$description."

".$prog."

>>> Publier <<<
"; + send_mail("bruno-godefroy@sfr.fr", 'Nouvel exemple : '.$titre, $message); + + echo "
Votre algorithme a été soumis. Vous recevrez une réponse par mail prochainement.

Merci de votre participation.
"; + } + else + { + if($_POST['code'] == '') + echo "
Votre algorithme comporte des erreurs.
Corrigez les avant de le publier.
"; + else + echo "
Une erreur s'est produite lors de la soumission de l'algorithme.
"; + } + ?> +
+
+ + + \ No newline at end of file diff --git a/algo_soumis_admin.php b/algo_soumis_admin.php new file mode 100644 index 0000000..74ed9ae --- /dev/null +++ b/algo_soumis_admin.php @@ -0,0 +1,86 @@ + + + + + + + + + + + + Festiv'Algo - Publier un algorithme + + + +
+ +
+ Algorithme soumis avec succès !
"; + + $message = " + Vous avez posté récemment l'algorithme \"".$_POST['titre']."\" sur Festiv'Algo.
+ Félicitations, celui-ci vient d'être publié dans les exemples.

+ Nous avons besoin de vos contributions. N'hésitez donc pas à publier de nouveaux algorithmes.
+ Au plaisir de vous revoir sur Festiv'Algo !

+ Il s'agit d'un mail automatique. Merci de ne pas y répondre. + "; + + send_mail($_POST['mail'], "Publication d'un algorithme sur Festiv'Algo", $message); + + mysql_query('delete from exemples_en_attente where id = "'.$_GET['id'].'"'); + } + else + echo "
Erreur php.
"; + } + else + { + if(isset($_GET['id'], $_GET['case']) && $_POST['mdp'] == "studio3607") + { + $req = mysql_fetch_array(mysql_query('select titre, auteur, mail, description, programme from exemples_en_attente where id = "'.$_GET['id'].'"')); + + if($_GET['case'] == 1) + { + $raisons = " +      - votre algorithme a été jugé sans intêret
+      - votre algorithme contient de la publicité ou un contenu choquant
+ "; + } + else + { + $raisons = " +      - votre algorithme existe déjà dans les exemples
+      - vous avez déjà soumis cet algorithme
+ "; + } + + $message = " + Vous avez posté récemment l'algorithme \"".$req['titre']."\" sur Festiv'Algo. Nous vous remercions pour cette initiative.

+ Cependant, celui-ci n'a pas été publié pour l'une des raisons suivantes :
" + .$raisons. + "
Merci de prendre en compte ces remarques pour vos futures publications.
+ Au plaisir de vous revoir sur Festiv'Algo !

+ Il s'agit d'un mail automatique. Merci de ne pas y répondre. + "; + + send_mail($req['mail'], "Publication d'un algorithme sur Festiv'Algo", $message); + mysql_query('delete from exemples_en_attente where id = "'.$_GET['id'].'"'); + echo "
Email envoyé !
"; + } + else + echo "
Erreur.
"; + } + ?> +
+ + + + \ No newline at end of file diff --git a/bas_de_page.php b/bas_de_page.php new file mode 100644 index 0000000..77f06b5 --- /dev/null +++ b/bas_de_page.php @@ -0,0 +1,26 @@ + + diff --git a/bbcode_function.php b/bbcode_function.php new file mode 100644 index 0000000..361359c --- /dev/null +++ b/bbcode_function.php @@ -0,0 +1,70 @@ +$1', + '$1', + '$1', + '$1', + 'Image', + '$1', + '$4', + '
$1
', + '
$1
', + '
$1
' + ); + $count = count($in)-1; + for($i=0;$i<=$count;$i++) + { + $text = preg_replace($in[$i],$out[$i],$text); + } + return $text; +} +//Fonction permettant de convertir du html en du bbcode +function html_to_bbcode($text) +{ + $text = str_replace('
','',$text); + $in = array( + '#(.*)#Usi', + '#(.*)#Usi', + '#(.*)#Usi', + '#(.*)#Usi', + '#Image#Usi', + '#(.*)#Usi', + '#
(.*)
#Usi', + '#
(.*)
#Usi', + '#
(.*)
#Usi' + ); + $out = array( + '[b]$1[/b]', + '[i]$1[/i]', + '[u]$1[/u]', + '[s]$1[/s]', + '[img]$1[/img]', + '[url=$1]$2[/url]', + '[left]$1[/left]', + '[center]$1[/center]', + '[right]$1[/right]' + ); + $count = count($in)-1; + for($i=0;$i<=$count;$i++) + { + $text = preg_replace($in[$i],$out[$i],$text); + } + return $text; +} +?> \ No newline at end of file diff --git a/class.pop3.php b/class.pop3.php new file mode 100644 index 0000000..f9fd3b2 --- /dev/null +++ b/class.pop3.php @@ -0,0 +1,407 @@ +pop_conn = 0; + $this->connected = false; + $this->error = null; + } + + /** + * Combination of public events - connect, login, disconnect + * @access public + * @param string $host + * @param integer $port + * @param integer $tval + * @param string $username + * @param string $password + */ + public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) { + $this->host = $host; + + // If no port value is passed, retrieve it + if ($port == false) { + $this->port = $this->POP3_PORT; + } else { + $this->port = $port; + } + + // If no port value is passed, retrieve it + if ($tval == false) { + $this->tval = $this->POP3_TIMEOUT; + } else { + $this->tval = $tval; + } + + $this->do_debug = $debug_level; + $this->username = $username; + $this->password = $password; + + // Refresh the error log + $this->error = null; + + // Connect + $result = $this->Connect($this->host, $this->port, $this->tval); + + if ($result) { + $login_result = $this->Login($this->username, $this->password); + + if ($login_result) { + $this->Disconnect(); + + return true; + } + + } + + // We need to disconnect regardless if the login succeeded + $this->Disconnect(); + + return false; + } + + /** + * Connect to the POP3 server + * @access public + * @param string $host + * @param integer $port + * @param integer $tval + * @return boolean + */ + public function Connect ($host, $port = false, $tval = 30) { + // Are we already connected? + if ($this->connected) { + return true; + } + + /* + On Windows this will raise a PHP Warning error if the hostname doesn't exist. + Rather than supress it with @fsockopen, let's capture it cleanly instead + */ + + set_error_handler(array(&$this, 'catchWarning')); + + // Connect to the POP3 server + $this->pop_conn = fsockopen($host, // POP3 Host + $port, // Port # + $errno, // Error Number + $errstr, // Error Message + $tval); // Timeout (seconds) + + // Restore the error handler + restore_error_handler(); + + // Does the Error Log now contain anything? + if ($this->error && $this->do_debug >= 1) { + $this->displayErrors(); + } + + // Did we connect? + if ($this->pop_conn == false) { + // It would appear not... + $this->error = array( + 'error' => "Failed to connect to server $host on port $port", + 'errno' => $errno, + 'errstr' => $errstr + ); + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + + return false; + } + + // Increase the stream time-out + + // Check for PHP 4.3.0 or later + if (version_compare(phpversion(), '5.0.0', 'ge')) { + stream_set_timeout($this->pop_conn, $tval, 0); + } else { + // Does not work on Windows + if (substr(PHP_OS, 0, 3) !== 'WIN') { + socket_set_timeout($this->pop_conn, $tval, 0); + } + } + + // Get the POP3 server response + $pop3_response = $this->getResponse(); + + // Check for the +OK + if ($this->checkResponse($pop3_response)) { + // The connection is established and the POP3 server is talking + $this->connected = true; + return true; + } + + } + + /** + * Login to the POP3 server (does not support APOP yet) + * @access public + * @param string $username + * @param string $password + * @return boolean + */ + public function Login ($username = '', $password = '') { + if ($this->connected == false) { + $this->error = 'Not connected to POP3 server'; + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + } + + if (empty($username)) { + $username = $this->username; + } + + if (empty($password)) { + $password = $this->password; + } + + $pop_username = "USER $username" . $this->CRLF; + $pop_password = "PASS $password" . $this->CRLF; + + // Send the Username + $this->sendString($pop_username); + $pop3_response = $this->getResponse(); + + if ($this->checkResponse($pop3_response)) { + // Send the Password + $this->sendString($pop_password); + $pop3_response = $this->getResponse(); + + if ($this->checkResponse($pop3_response)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Disconnect from the POP3 server + * @access public + */ + public function Disconnect () { + $this->sendString('QUIT'); + + fclose($this->pop_conn); + } + + ///////////////////////////////////////////////// + // Private Methods + ///////////////////////////////////////////////// + + /** + * Get the socket response back. + * $size is the maximum number of bytes to retrieve + * @access private + * @param integer $size + * @return string + */ + private function getResponse ($size = 128) { + $pop3_response = fgets($this->pop_conn, $size); + + return $pop3_response; + } + + /** + * Send a string down the open socket connection to the POP3 server + * @access private + * @param string $string + * @return integer + */ + private function sendString ($string) { + $bytes_sent = fwrite($this->pop_conn, $string, strlen($string)); + + return $bytes_sent; + } + + /** + * Checks the POP3 server response for +OK or -ERR + * @access private + * @param string $string + * @return boolean + */ + private function checkResponse ($string) { + if (substr($string, 0, 3) !== '+OK') { + $this->error = array( + 'error' => "Server reported an error: $string", + 'errno' => 0, + 'errstr' => '' + ); + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + + return false; + } else { + return true; + } + + } + + /** + * If debug is enabled, display the error message array + * @access private + */ + private function displayErrors () { + echo '
';
+
+    foreach ($this->error as $single_error) {
+      print_r($single_error);
+    }
+
+    echo '
'; + } + + /** + * Takes over from PHP for the socket warning handler + * @access private + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + */ + private function catchWarning ($errno, $errstr, $errfile, $errline) { + $this->error[] = array( + 'error' => "Connecting to the POP3 server raised a PHP warning: ", + 'errno' => $errno, + 'errstr' => $errstr + ); + } + + // End of class +} +?> \ No newline at end of file diff --git a/class.smtp.php b/class.smtp.php new file mode 100644 index 0000000..c664d97 --- /dev/null +++ b/class.smtp.php @@ -0,0 +1,814 @@ +smtp_conn = 0; + $this->error = null; + $this->helo_rply = null; + + $this->do_debug = 0; + } + + ///////////////////////////////////////////////// + // CONNECTION FUNCTIONS + ///////////////////////////////////////////////// + + /** + * Connect to the server specified on the port specified. + * If the port is not specified use the default SMTP_PORT. + * If tval is specified then a connection will try and be + * established with the server for that number of seconds. + * If tval is not specified the default is 30 seconds to + * try on the connection. + * + * SMTP CODE SUCCESS: 220 + * SMTP CODE FAILURE: 421 + * @access public + * @return bool + */ + public function Connect($host, $port = 0, $tval = 30) { + // set the error val to null so there is no confusion + $this->error = null; + + // make sure we are __not__ connected + if($this->connected()) { + // already connected, generate error + $this->error = array("error" => "Already connected to a server"); + return false; + } + + if(empty($port)) { + $port = $this->SMTP_PORT; + } + + // connect to the smtp server + $this->smtp_conn = @fsockopen($host, // the host of the server + $port, // the port to use + $errno, // error number if any + $errstr, // error message if any + $tval); // give up after ? secs + // verify we connected properly + if(empty($this->smtp_conn)) { + $this->error = array("error" => "Failed to connect to server", + "errno" => $errno, + "errstr" => $errstr); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '
'; + } + return false; + } + + // SMTP server can take longer to respond, give longer timeout for first read + // Windows does not have support for this timeout function + if(substr(PHP_OS, 0, 3) != "WIN") + socket_set_timeout($this->smtp_conn, $tval, 0); + + // get any announcement + $announce = $this->get_lines(); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '
'; + } + + return true; + } + + /** + * Initiate a TLS communication with the server. + * + * SMTP CODE 220 Ready to start TLS + * SMTP CODE 501 Syntax error (no parameters allowed) + * SMTP CODE 454 TLS not available due to temporary reason + * @access public + * @return bool success + */ + public function StartTLS() { + $this->error = null; # to avoid confusion + + if(!$this->connected()) { + $this->error = array("error" => "Called StartTLS() without being connected"); + return false; + } + + fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; + } + + if($code != 220) { + $this->error = + array("error" => "STARTTLS not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + + // Begin encrypted connection + if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { + return false; + } + + return true; + } + + /** + * Performs SMTP authentication. Must be run after running the + * Hello() method. Returns true if successfully authenticated. + * @access public + * @return bool + */ + public function Authenticate($username, $password) { + // Start authentication + fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "AUTH not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + + // Send encoded username + fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "Username not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + + // Send encoded password + fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 235) { + $this->error = + array("error" => "Password not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + + return true; + } + + /** + * Returns true if connected to a server otherwise false + * @access public + * @return bool + */ + public function Connected() { + if(!empty($this->smtp_conn)) { + $sock_status = socket_get_status($this->smtp_conn); + if($sock_status["eof"]) { + // the socket is valid but we are not connected + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; + } + $this->Close(); + return false; + } + return true; // everything looks good + } + return false; + } + + /** + * Closes the socket and cleans up the state of the class. + * It is not considered good to use this function without + * first trying to use QUIT. + * @access public + * @return void + */ + public function Close() { + $this->error = null; // so there is no confusion + $this->helo_rply = null; + if(!empty($this->smtp_conn)) { + // close the connection and cleanup + fclose($this->smtp_conn); + $this->smtp_conn = 0; + } + } + + ///////////////////////////////////////////////// + // SMTP COMMANDS + ///////////////////////////////////////////////// + + /** + * Issues a data command and sends the msg_data to the server + * finializing the mail transaction. $msg_data is the message + * that is to be send with the headers. Each header needs to be + * on a single line followed by a with the message headers + * and the message body being seperated by and additional . + * + * Implements rfc 821: DATA + * + * SMTP CODE INTERMEDIATE: 354 + * [data] + * . + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 552,554,451,452 + * SMTP CODE FAILURE: 451,554 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + public function Data($msg_data) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Data() without being connected"); + return false; + } + + fputs($this->smtp_conn,"DATA" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; + } + + if($code != 354) { + $this->error = + array("error" => "DATA command not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + + /* the server is ready to accept data! + * according to rfc 821 we should not send more than 1000 + * including the CRLF + * characters on a single line so we will break the data up + * into lines by \r and/or \n then if needed we will break + * each of those into smaller lines to fit within the limit. + * in addition we will be looking for lines that start with + * a period '.' and append and additional period '.' to that + * line. NOTE: this does not count towards limit. + */ + + // normalize the line breaks so we know the explode works + $msg_data = str_replace("\r\n","\n",$msg_data); + $msg_data = str_replace("\r","\n",$msg_data); + $lines = explode("\n",$msg_data); + + /* we need to find a good way to determine is headers are + * in the msg_data or if it is a straight msg body + * currently I am assuming rfc 822 definitions of msg headers + * and if the first field of the first line (':' sperated) + * does not contain a space then it _should_ be a header + * and we can process all lines before a blank "" line as + * headers. + */ + + $field = substr($lines[0],0,strpos($lines[0],":")); + $in_headers = false; + if(!empty($field) && !strstr($field," ")) { + $in_headers = true; + } + + $max_line_length = 998; // used below; set here for ease in change + + while(list(,$line) = @each($lines)) { + $lines_out = null; + if($line == "" && $in_headers) { + $in_headers = false; + } + // ok we need to break this line up into several smaller lines + while(strlen($line) > $max_line_length) { + $pos = strrpos(substr($line,0,$max_line_length)," "); + + // Patch to fix DOS attack + if(!$pos) { + $pos = $max_line_length - 1; + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos); + } else { + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos + 1); + } + + /* if processing headers add a LWSP-char to the front of new line + * rfc 822 on long msg headers + */ + if($in_headers) { + $line = "\t" . $line; + } + } + $lines_out[] = $line; + + // send the lines to the server + while(list(,$line_out) = @each($lines_out)) { + if(strlen($line_out) > 0) + { + if(substr($line_out, 0, 1) == ".") { + $line_out = "." . $line_out; + } + } + fputs($this->smtp_conn,$line_out . $this->CRLF); + } + } + + // message data has been sent + fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; + } + + if($code != 250) { + $this->error = + array("error" => "DATA not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + return true; + } + + /** + * Sends the HELO command to the smtp server. + * This makes sure that we and the server are in + * the same known state. + * + * Implements from rfc 821: HELO + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 501, 504, 421 + * @access public + * @return bool + */ + public function Hello($host = '') { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Hello() without being connected"); + return false; + } + + // if hostname for HELO was not specified send default + if(empty($host)) { + // determine appropriate default to send to server + $host = "localhost"; + } + + // Send extended hello first (RFC 2821) + if(!$this->SendHello("EHLO", $host)) { + if(!$this->SendHello("HELO", $host)) { + return false; + } + } + + return true; + } + + /** + * Sends a HELO/EHLO command. + * @access private + * @return bool + */ + private function SendHello($hello, $host) { + fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '
'; + } + + if($code != 250) { + $this->error = + array("error" => $hello . " not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + + $this->helo_rply = $rply; + + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. + * + * Implements rfc 821: MAIL FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,421 + * @access public + * @return bool + */ + public function Mail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Mail() without being connected"); + return false; + } + + $useVerp = ($this->do_verp ? "XVERP" : ""); + fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; + } + + if($code != 250) { + $this->error = + array("error" => "MAIL not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + return true; + } + + /** + * Sends the quit command to the server and then closes the socket + * if there is no error or the $close_on_error argument is true. + * + * Implements from rfc 821: QUIT + * + * SMTP CODE SUCCESS: 221 + * SMTP CODE ERROR : 500 + * @access public + * @return bool + */ + public function Quit($close_on_error = true) { + $this->error = null; // so there is no confusion + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Quit() without being connected"); + return false; + } + + // send the quit command to the server + fputs($this->smtp_conn,"quit" . $this->CRLF); + + // get any good-bye messages + $byemsg = $this->get_lines(); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '
'; + } + + $rval = true; + $e = null; + + $code = substr($byemsg,0,3); + if($code != 221) { + // use e as a tmp var cause Close will overwrite $this->error + $e = array("error" => "SMTP server rejected quit command", + "smtp_code" => $code, + "smtp_rply" => substr($byemsg,4)); + $rval = false; + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '
'; + } + } + + if(empty($e) || $close_on_error) { + $this->Close(); + } + + return $rval; + } + + /** + * Sends the command RCPT to the SMTP server with the TO: argument of $to. + * Returns true if the recipient was accepted false if it was rejected. + * + * Implements from rfc 821: RCPT TO: + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,552,553,450,451,452 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + public function Recipient($to) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Recipient() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; + } + + if($code != 250 && $code != 251) { + $this->error = + array("error" => "RCPT not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + return true; + } + + /** + * Sends the RSET command to abort and transaction that is + * currently in progress. Returns true if successful false + * otherwise. + * + * Implements rfc 821: RSET + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500,501,504,421 + * @access public + * @return bool + */ + public function Reset() { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Reset() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RSET" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; + } + + if($code != 250) { + $this->error = + array("error" => "RSET failed", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in and send them an email. + * + * Implements rfc 821: SAML FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + public function SendAndMail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendAndMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
'; + } + + if($code != 250) { + $this->error = + array("error" => "SAML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
'; + } + return false; + } + return true; + } + + /** + * This is an optional command for SMTP that this class does not + * support. This method is here to make the RFC821 Definition + * complete for this class and __may__ be implimented in the future + * + * Implements from rfc 821: TURN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 502 + * SMTP CODE ERROR : 500, 503 + * @access public + * @return bool + */ + public function Turn() { + $this->error = array("error" => "This method, TURN, of the SMTP ". + "is not implemented"); + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '
'; + } + return false; + } + + /** + * Get the current error + * @access public + * @return array + */ + public function getError() { + return $this->error; + } + + ///////////////////////////////////////////////// + // INTERNAL FUNCTIONS + ///////////////////////////////////////////////// + + /** + * Read in as many lines as possible + * either before eof or socket timeout occurs on the operation. + * With SMTP we can tell if we have more lines to read if the + * 4th character is '-' symbol. If it is a space then we don't + * need to read anything else. + * @access private + * @return string + */ + private function get_lines() { + $data = ""; + while($str = @fgets($this->smtp_conn,515)) { + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '
'; + echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '
'; + } + $data .= $str; + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '
'; + } + // if 4th character is a space, we are done reading, break the loop + if(substr($str,3,1) == " ") { break; } + } + return $data; + } + +} + +?> \ No newline at end of file diff --git a/compil1.js b/compil1.js new file mode 100644 index 0000000..76a46a6 --- /dev/null +++ b/compil1.js @@ -0,0 +1,1423 @@ +var code = new Array(); +var indices = new Array(); +var erreur_syntaxe = new Array(), nb_erreurs; +var previsions = new Array(); +var type, indice_previsions; +var j, k, for_ti, n; +var conditions_ouvertes, conditions_fermees, alors, boucles_ouvertes, boucles_fermees, pour_ouverts, pour_fermes, ti_ouverts, ti_fermes; +var bug1, bug2, bug3, bug4, bug5; + +function saut_de_ligne(texte) { + while(texte.indexOf("
") != -1) + texte = texte.replace("
","@"); + + while(texte.indexOf(" ") != -1) + texte = texte.replace(" ",""); + + /*while(texte.indexOf(" ") != -1) + texte = texte.replace(" ",""); + + while(texte.indexOf("") != -1) + texte = texte.replace("",""); + + while(texte.indexOf("") != -1) + texte = texte.replace("",""); + + while(texte.indexOf("") != -1) + texte = texte.replace("",""); + + while(texte.indexOf("") != -1) + texte = texte.replace("",""); + + while(texte.indexOf("") != -1) + texte = texte.replace("","");*/ + + var balises = [ + "", start); + + if(start != -1 && end != -1) + texte = texte.substring(0, start) + texte.substring(end + 1, texte.length); + } + } + + do + { + var pos = texte.indexOf(''); + + if(pos != -1) + { + var pos2 = texte.indexOf("", pos); + texte = texte.substring(0, pos2) + texte.substring(pos2 + 7, texte.length); + + texte = texte.replace('',""); + } + } + while(pos != -1); + + while(texte.indexOf(" ") != -1) + texte = texte.replace(" "," "); + + while(texte.indexOf("") == 0) + texte = texte.replace("
", ""); + else + { + while(texte.indexOf("", start); + + if(start != -1 && end != -1) + texte = texte.substring(0, start) + "@" + texte.substring(end + 1, texte.length); + } + } + } + while(texte.indexOf("
") != -1) + texte = texte.replace("",""); + + while(texte.indexOf("") == 0) + texte = texte.replace("", ""); + else + { + while(texte.indexOf("", start); + + if(start != -1 && end != -1) + texte = texte.substring(0, start) + "@" + texte.substring(end + 1, texte.length); + } + } + } + while(texte.indexOf("") != -1) + texte = texte.replace("
",""); + + while(texte.indexOf("", start); + + if(start != -1 && end != -1) + texte = texte.substring(0, start) + "@" + texte.substring(end + 1, texte.length); + } + + while(texte.substring(texte.length - 1, texte.length) == " " || texte.substring(texte.length - 1, texte.length) == "@") + texte = texte.substring(0, texte.length - 1); + + return texte; +} + +function caracteres_speciaux(texte, sens) { // sens = 0 : § → § + var i; // sens = 1 : § → § + var car = [ + " ", "", + "­", "", + "‎", "", + "‏", "", + "»", "«", + "‹", "‹", + "›", "›", + "“", "“", + "”", "”", + "„", "„", + "'", "'", + "‘", "‘", + "’", "’", + "‚", "‚", + "…", "…", + "¡", "¡", + "¿", "¿", + "¨", "¨", + "´", "´", + "ˆ", "ˆ", + "¸", "¸", + "§", "§", + "©", "©", + "®", "®", + "™", "™", + "&", "&", + "←", "←", + "↑", "↑", + "→", "→", + "↓", "↓", + "↔", "↔", + "á", "á", + "Á", "Á", + "â", "â", + "Â", "Â", + "à", "à", + "À", "À", + "ã", "ã", + "ä", "ä", + "æ", "æ", + "ç", "ç", + "Ç", "Ç", + "é", "é", + "É", "É", + "ê", "ê", + "Ê", "Ê", + "È", "È", + "ë", "ë", + "Ë", "Ë", + "î", "î", + "Î", "Î", + "ï", "ï", + "Ï", "Ï", + "ñ", "ñ", + "Ñ", "Ñ", + "ô", "ô", + "Ô", "Ô", + "ø", "ø", + "Ø", "Ø", + "ö", "ö", + "Ö", "Ö", + "œ", "œ", + "ß", "ß", + "ð", "ð", + "ú", "ú", + "Ú", "Ú", + "û", "û", + "ù", "ù", + "ü", "ü", + "Ü", "Ü", + "¤", "¤", + "€", "€", + "¢", "¢", + "£", "£", + "¥", "¥", + "ƒ", "ƒ", + "α", "α", + "Α", "Α", + "β", "β", + "Β", "Β", + "γ", "γ", + "Γ", "Γ", + "δ", "δ", + "Δ", "Δ", + "ε", "ε", + "Ε", "Ε", + "ζ", "ζ", + "Ζ", "Ζ", + "η", "η", + "Η", "Η", + "θ", "θ", + "Θ", "Θ", + "ι", "ι", + "Ι", "Ι", + "κ", "κ", + "Κ", "Κ", + "λ", "λ", + "Λ", "Λ", + "μ", "μ", + "Μ", "Μ", + "ν", "ν", + "Ν", "Ν", + "ξ", "ξ", + "Ξ", "Ξ", + "ο", "ο", + "Ο", "Ο", + "π", "π", + "Π", "Π", + "ρ", "ρ", + "Ρ", "Ρ", + "σ", "σ", + "ς", "ς", + "Σ", "Σ", + "τ", "τ", + "Τ", "Τ", + "υ", "υ", + "Υ", "Υ", + "φ", "φ", + "Φ", "Φ", + "χ", "χ", + "Χ", "Χ", + "ψ", "ψ", + "Ψ", "Ψ", + "ω", "ω", + "Ω", "Ω", + "°", "°", + "µ", "µ", + "<", "<", + ">", ">", + "≤", "≤", + "≥", "≥", + "≈", "≈", + "≠", "≠", + "≡", "≡", + "±", "±", + "−", "−", + "×", "×", + "÷", "÷", + "⁄", "⁄", + "‰", "‰", + "¼", "¼", + "½", "½", + "¾", "¾", + "¹", "¹", + "²", "²", + "³", "³", + "º", "º", + "ª", "ª", + "ƒ", "ƒ", + "′", "′", + "″", "″", + "∂", "∂", + "∏", "∏", + "∑", "∑", + "√", "√", + "∞", "∞", + "¬", "¬", + "∩", "∩", + "∫", "∫" + ] + + for(i = 0; i < 159 * 2; i += 2) + { + while(texte.indexOf(car[i + sens]) != -1) + texte = texte.replace(car[i + sens], car[i + 1 - sens]); + } + + return texte; +} + +function assouplie_syntaxe(texte, langage_source) { + while(texte.indexOf("Hasard()") != -1) + texte = texte.replace("Hasard()", "Hasard(1)"); + while(texte.indexOf("hasard()") != -1) + texte = texte.replace("hasard()", "hasard(1)"); + while(texte.indexOf("Hasard ()") != -1) + texte = texte.replace("Hasard ()", "Hasard(1)"); + while(texte.indexOf("hasard ()") != -1) + texte = texte.replace("hasard ()", "hasard(1)"); + + return texte; +} + +function compilation(langage_source) { + var texte = document.getElementById('saisie').value; + var i, mot = "", dernier_mot = 0, espace_position , mot_en_cours; + var ligne = 1, type; + var calcul_memoire = "undefined", ligne_memoire, chaine = 0; + var texte_compil = escape(texte); + createCookie("last_algo",texte_compil,30); + createCookie("last_language",langage_source,30); + createCookie('exemple','init',30); + debug_efface(); + + // remise à 0 des variables + previsions[0] = "PREV_END"; + indice_previsions = 0; + nb_erreurs = 0; + conditions_ouvertes = 0; + conditions_fermees = 0; + alors = 0; + boucles_ouvertes = 0; + boucles_fermees = 0; + pour_ouverts = 0; + pour_fermes = 0; + ti_ouverts = 0; + ti_fermes = 0; + for_ti = 0; + j = 0; + k = 0; + next = 0; + + while(escape(texte).indexOf("%0A") != -1) + texte = unescape(escape(texte).replace("%0A","")); + + // modifie le texte pour lire les retours à la ligne (@) + texte = saut_de_ligne(texte); + + // remplace les entités html par les caractères spéciaux correspondants + texte = caracteres_speciaux(texte, 0); + + texte = assouplie_syntaxe(texte, langage_source); + + // détection des chaines de caractères + for(i = 0; i < texte.length; i++) + { + mot_en_cours = texte.substring(dernier_mot, i + 1); + + if(chaine == 1 && texte.substring(i, i + 1) == "\"") + { + chaine = 0; + identification(mot_en_cours, ligne, "chaine", langage_source); + mot_en_cours = ""; + dernier_mot = i + 1; + + if(dernier_mot == texte.length) + break; + } + + if(dernier_mot == i && mot_en_cours.substring(0, 1) == "\"") + { + chaine = 1; + if(calcul_memoire != "undefined") + { + identification(calcul_memoire, ligne_memoire, "calcul", langage_source); + calcul_memoire = "undefined"; + } + } + + // détection des instruction (attention : piège si/sinon, if/ifend...) + type = detecte_instruction(mot_en_cours, langage_source); + if((type == "si" && texte.toLowerCase().substring(dernier_mot, i + 4) == "sinon") || (type == "if" && texte.toLowerCase().substring(dernier_mot, i + 4) == "ifend") || (type == "while" && texte.toLowerCase().substring(dernier_mot, i + 4) == "whileend")) + type = "undefined"; + + if(type == "undefined") + { + // détection des signes (>, <, =, ...) + type = detecte_signe(mot_en_cours); + + if(type == "signe" && detecte_signe(texte.substring(dernier_mot, i + 2)) == "signe") + { + i++; + mot_en_cours = texte.substring(dernier_mot, i + 1); + } + } + + if(next == 1) + { + next = 0; + previsions[indice_previsions] = "PREV_END"; + } + + if(mot_en_cours.indexOf("@", 0) >= 0 && previsions[indice_previsions] == "condition_add") + next = 1; + + // découpage en "mots" et traitement + if(((mot_en_cours.indexOf(" ", 0) >= 0 || escape(texte.substring(dernier_mot + 1, i + 2)) == "%u2220" || type != "undefined" || (detecte_signe(texte.substring(i + 1, i + 2)) == "signe" && texte.substring(i, i + 1) != "-") || (escape(texte.substring(i + 1, i + 7)) == "%u2220" && langage_source == 2 && mot_en_cours.length > 0) || (escape(texte.substring(i + 1, i + 3)) == "%u2192" && langage_source != 1)) && chaine == 0) || mot_en_cours.indexOf("@", 0) >= 0 || i + 1 == texte.length || (for_ti == 1 && mot_en_cours.length > 0 && texte.substring(dernier_mot, i + 2).indexOf(",", 0) >= 0) || mot_en_cours == ",") + { + // gère les retours à la ligne + if(mot_en_cours != "@" && mot_en_cours != " ") + { + mot = mot_en_cours; + espace_position = mot.search(" "); + + if(espace_position == -1) + { + espace_position = mot.search("@"); + chaine = 0; + } + + if(espace_position != -1) + { + mot = mot.substring(0, espace_position); + chaine = 0; + } + + // gère les calculs + if(detecte_calculs(mot, langage_source) == "calcul") + { + if(calcul_memoire != "undefined") + { + mot = calcul_memoire + mot; + } + else + ligne_memoire = ligne; + + calcul_memoire = mot; + + if(i + 1 == texte.length || mot_en_cours.indexOf("@", 0) >= 0 || texte.substring(i + 1, i + 2) == "@") + { + identification(calcul_memoire, ligne_memoire, "calcul", langage_source); + calcul_memoire = "undefined"; + } + } + else + { + if(calcul_memoire != "undefined") + { + identification(calcul_memoire, ligne_memoire, "calcul", langage_source); + calcul_memoire = "undefined"; + } + identification(mot, ligne, type, langage_source); + } + } + mot = ""; + dernier_mot = i + 1; + + if(mot_en_cours.indexOf("@", 0) >= 0) + ligne++; + } + } + + // Après la détection, on gère les erreurs si il manque des éléments attendus + if(previsions[indice_previsions] == "tout") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + } + else + { + for(n = 0; n <= indice_previsions; n++) + { + if(previsions[n] == "PREV_END") + { + previsions[indice_previsions] = "PREV_END"; + break; + } + } + if(previsions[indice_previsions] != "PREV_END" && previsions[indice_previsions] != "condition_add") + { + erreur_syntaxe[4 * nb_erreurs] = previsions[indice_previsions]; + ameliore_syntaxe_suggestion(2); + erreur_syntaxe[4 * nb_erreurs + 2] = "manquant"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + //ameliore_syntaxe_suggestion(langage_source); + nb_erreurs++; + } + } + + // on compte les éléments de conditions et de boucles + if((langage_source != 3 && conditions_ouvertes - conditions_fermees != 0) || conditions_ouvertes - alors != 0) + { + erreur_syntaxe[4 * nb_erreurs + 2] = "erreur_conditions"; + nb_erreurs++; + } + + if(langage_source != 3 && (boucles_ouvertes - boucles_fermees != 0 || pour_ouverts - pour_fermes != 0)) + { + erreur_syntaxe[4 * nb_erreurs + 2] = "erreur_boucles"; + nb_erreurs++; + } + + if(langage_source == 3 && ti_ouverts - ti_fermes != 0) + { + erreur_syntaxe[4 * nb_erreurs + 2] = "erreur_ti"; + nb_erreurs++; + } + + // si il y a des erreurs, on les affiche + if(nb_erreurs > 0) + { + texte = affiche_erreurs(texte); + + texte = texte.replace("@","
"); + while(texte.indexOf("@") != -1) + texte = texte.replace("@","
"); + + texte += "
"; + + document.getElementById("saisie").value = texte; + $("#saisie").cleditor()[0].updateFrame().focus(); + return "failed"; + } + else + { + masque_erreurs(); + return "completed"; + } +} + +function identification(mot_recu, ligne, type, langage_source) { + var mot; + mot = mot_recu.toLowerCase(); + + if(mot == ",") + type = ","; + + // on différencie variables et calculs + if(type == "calcul") + { + type = detecte_variable(mot); + if(type != "variable") + type = "calcul"; + } + + // on affiche une erreur si le type reçu est différent du type attendu + if((type != previsions[indice_previsions] && previsions[indice_previsions] != "tout" && !((type == "chaine" || type == "variable" || type == "calcul") && previsions[indice_previsions] == "chaine_variable_calcul") && !((escape(type) == "%u2192" || escape(type) == "%u2220" || type == "prend_la_valeur" || type == "#ran") && previsions[indice_previsions] == "→_ou_∠") && !((type == "variable" || type == "calcul" || type == "signe" || type == "et" || type == "ou" || type == "and" || type == "or") && (previsions[indice_previsions] == "condition" || previsions[indice_previsions] == "condition_alors")) && !(previsions[indice_previsions] == "condition_alors") && !(type == "variable" && previsions[indice_previsions] == "calcul")) && !(escape(type) == "%u2192" && previsions[indice_previsions] == "→") && !(escape(type) == "%u2220" && previsions[indice_previsions] == "∠") && previsions[indice_previsions] != "PREV_END" && previsions[indice_previsions] != "condition_add") + { + erreur_syntaxe[4 * nb_erreurs] = previsions[indice_previsions]; + if(type == "chaine") + mot_recu = mot_recu.substring(1, mot_recu.length - 1); + erreur_syntaxe[4 * nb_erreurs + 1] = mot_recu; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + ameliore_syntaxe_description(); + ameliore_syntaxe_suggestion(langage_source); + nb_erreurs++; + } + + indice_previsions++; + + // gestion des conditions + if(previsions[indice_previsions - 1] == "condition" || previsions[indice_previsions - 1] == "condition_alors" || previsions[indice_previsions - 1] == "condition_add") + { + code[j] = mot; + + if(previsions[indice_previsions - 1] == "condition") + previsions[0] = "condition_add"; + else + previsions[0] = previsions[indice_previsions - 1]; + + previsions[1] = "PREV_END"; + + if(previsions[indice_previsions] == "alors") + previsions[1] = "alors"; + if(previsions[indice_previsions] == "then") + previsions[1] = "then"; + + indice_previsions = 0; + } + + code[j] = "rien"; + + // reconnaissance des fonctions "algorithme" + if(langage_source == 1) + { + switch(type) + { + case "lire": + indices[k] = j; + k++; + code[j] = "lire"; + previsions[0] = "variable"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + break; + + case "afficher": + indices[k] = j; + k++; + code[j] = "afficher"; + previsions[0] = "chaine_variable_calcul"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + break; + + case "si": + indices[k] = j; + k++; + code[j] = "si"; + previsions[0] = "condition"; + previsions[1] = "alors"; + previsions[2] = "PREV_END"; + indice_previsions = 0; + conditions_ouvertes++; + break; + + case "alors": + indices[k] = j; + k++; + code[j] = "alors"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + alors++; + break; + + case "sinon": + indices[k] = j; + k++; + code[j] = "sinon"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + verifie_conditions(mot_recu, ligne); + break; + + case "fin_si": + indices[k] = j; + k++; + code[j] = "fin_si"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + verifie_conditions(mot_recu, ligne); + conditions_fermees++; + break; + + case "tant_que": + indices[k] = j; + k++; + code[j] = "tant_que"; + previsions[0] = "condition"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + boucles_ouvertes++; + break; + + case "fin_tant_que": + indices[k] = j; + k++; + code[j] = "fin_tant_que"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + verifie_boucles(mot_recu, ligne, langage_source); + boucles_fermees++; + break; + + case "pour": + indices[k] = j; + k++; + code[j] = "pour"; + previsions[0] = "variable"; + previsions[1] = "allant_de"; + previsions[2] = "calcul"; + previsions[3] = "à"; + previsions[4] = "calcul"; + previsions[5] = "PREV_END"; + indice_previsions = 0; + pour_ouverts++; + break; + + case "allant_de": + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + code[j] = "allant_de"; + break; + + case "à": + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + code[j] = "à"; + break; + + case "fin_pour": + indices[k] = j; + k++; + code[j] = "fin_pour"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + verifie_pour(mot_recu, ligne, langage_source); + pour_fermes++; + break; + + case "prend_la_valeur": + code[j] = "prend_la_valeur"; + previsions[0] = "calcul"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + break; + + case "et": + code[j] = "et"; + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + break; + + case "ou": + code[j] = "ou"; + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + break; + + case "fin_programme": + indices[k] = j; + k++; + code[j] = "fin_programme"; + if(previsions[indice_previsions - 1] != "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + break; + } + } + + // reconnaissance des fonctions Casio + if(langage_source == 2) + { + switch(type) + { + case "?": + indices[k] = j; + k++; + code[j] = "lire"; + previsions[0] = "→"; + previsions[1] = "variable"; + previsions[2] = "PREV_END"; + indice_previsions = 0; + break; + + case "ifend": + indices[k] = j; + k++; + code[j] = "fin_si"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + verifie_conditions(mot_recu, ligne); + conditions_fermees++; + break; + + case "for": + indices[k] = j; + k++; + code[j] = "pour"; + previsions[0] = "calcul"; + previsions[1] = "→"; + previsions[2] = "variable"; + previsions[3] = "to"; + previsions[4] = "calcul"; + previsions[5] = "PREV_END"; + indice_previsions = 0; + pour_ouverts++; + break; + + case "to": + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + code[j] = "to"; + break; + + case "next": + indices[k] = j; + k++; + code[j] = "fin_pour"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + verifie_pour(mot_recu, ligne, langage_source); + pour_fermes++; + break; + } + } + + // reconnaissance des fonctions TI + if(langage_source == 3) + { + switch(type) + { + case "input": + indices[k] = j; + k++; + code[j] = "lire"; + previsions[0] = "variable"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + break; + + case "disp": + indices[k] = j; + k++; + code[j] = "afficher"; + previsions[0] = "chaine_variable_calcul"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + break; + + case "end": + indices[k] = j; + k++; + code[j] = "fin_si_ou_boucle"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + ti_fermes++; + break; + + case "for(": + indices[k] = j; + k++; + code[j] = "pour"; + previsions[0] = "variable"; + previsions[1] = ","; + previsions[2] = "calcul"; + previsions[3] = ","; + previsions[4] = "calcul"; + previsions[5] = "PREV_END"; + indice_previsions = 0; + for_ti = 1; + ti_ouverts++; + break; + } + } + + // reconnaissance des fonctions communes à Casio et TI + if(langage_source == 2 || langage_source == 3) + { + switch(type) + { + case "if": + indices[k] = j; + k++; + code[j] = "si"; + previsions[0] = "condition"; + previsions[1] = "then"; + previsions[2] = "PREV_END"; + indice_previsions = 0; + conditions_ouvertes++; + ti_ouverts++; + break; + + case "then": + indices[k] = j; + k++; + code[j] = "alors"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + alors++; + break; + + case "else": + indices[k] = j; + k++; + code[j] = "sinon"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + verifie_conditions(mot_recu, ligne); + break; + + case "while": + indices[k] = j; + k++; + code[j] = "tant_que"; + previsions[0] = "condition"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + boucles_ouvertes++; + ti_ouverts++; + break; + + case "whileend": + indices[k] = j; + k++; + code[j] = "fin_tant_que"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + verifie_boucles(mot_recu, ligne, langage_source); + boucles_fermees++; + break; + + case "→": + code[j] = "→"; + if(previsions[indice_previsions] == "PREV_END") + { + previsions[0] = "variable"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + } + break; + + case "and": + code[j] = "et"; + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + break; + + case "or": + code[j] = "ou"; + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + break; + + case "stop": + indices[k] = j; + k++; + code[j] = "fin_programme"; + if(previsions[indice_previsions - 1] != "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + break; + } + + switch(escape(type)) + { + case "%u2192": + code[j] = "→"; + + if(previsions[indice_previsions] == "PREV_END") + { + previsions[0] = "variable"; + previsions[1] = "PREV_END"; + indice_previsions = 0; + } + break; + + case "%u2220": + if(langage_source == 2) + { + code[j] = "∠"; + previsions[0] = "PREV_END"; + indice_previsions = 0; + } + break; + } + } + + // reconnaissance des fonctions communes aux trois langages + switch(type) + { + case "chaine": + if(previsions[indice_previsions - 1] == "PREV_END" || previsions[indice_previsions] == "condition_add") + { + if(langage_source == 2) + { + indices[k] = j; + k++; + previsions[0] = "∠"; + previsions[1] = "PREV_END"; + } + else + { + previsions[0] = "PREV_END"; + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + } + + indice_previsions = 0; + } + code[j] = "chaine"; + j++; + code[j] = mot_recu; + break; + + case "variable": + if(previsions[indice_previsions - 1] == "PREV_END") + { + indices[k] = j; + k++; + code[j] = "variable"; + if(langage_source != 1) + { + if(langage_source == 2) previsions[0] = "→_ou_∠"; + if(langage_source == 3) previsions[0] = "→"; + previsions[1] = "PREV_END"; + } + else + previsions[0] = "PREV_END"; + + indice_previsions = 0; + } + else + code[j] = "variable"; + j++; + code[j] = mot; + break; + + case "calcul": + if(mot == ")" && for_ti == 1) + { + j--; + for_ti = 0; + break; + } + + if(mot == "," && for_ti == 1) + { + j--; + break; + } + + if(previsions[indice_previsions - 1] == "PREV_END" || previsions[indice_previsions] == "condition_add") + { + if(previsions[indice_previsions - 1] == "PREV_END") + { + indices[k] = j; + k++; + } + code[j] = "calcul"; + if(langage_source != 1 && previsions[indice_previsions] != "condition_add") + { + previsions[0] = "→_ou_∠"; + previsions[1] = "PREV_END"; + } + else + previsions[0] = "condition_add"; + + indice_previsions = 0; + } + else + { + code[j] = "calcul"; + } + + if(for_ti == 1 && indice_previsions == 5) + for_ti = 0; + + j++; + code[j] = mot; + break; + + case ",": + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + code[j] = ","; + break; + + case "signe": + if(previsions[indice_previsions - 1] == "PREV_END") + { + erreur_syntaxe[4 * nb_erreurs + 2] = "tout"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + indice_previsions = 0; + } + code[j] = "signe"; + j++; + code[j] = mot; + break; + } + + // en cas de non reconnaissance de l'instruction : erreur + if(code[j] == "rien") + { + erreur_syntaxe[4 * nb_erreurs] = previsions[indice_previsions - 1]; + erreur_syntaxe[4 * nb_erreurs + 1] = mot_recu; + erreur_syntaxe[4 * nb_erreurs + 2] = "non_reconnu"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + nb_erreurs++; + previsions[0] = "PREV_END"; + indice_previsions = 0; + } + + j++; +} + +// affichage des erreurs +function affiche_erreurs(code) { + var a; + + affiche_debug(); + + for(a = nb_erreurs - 1; a >= 0; a--) + { + var expression = 0; + + switch(erreur_syntaxe[4 * a + 2]) + { + case "non_reconnu": + $("#debug_titre").after("

• ligne " + erreur_syntaxe[4 * a + 3] + " : expression \"" + erreur_syntaxe[4 * a + 1] + "\" non reconnue.
Suggestion : vérifiez la syntaxe du mot.

"); + expression = erreur_syntaxe[4 * a + 1]; + break; + + case "manquant": + $("#debug_titre").after("

• ligne " + erreur_syntaxe[4 * a + 3] + " : élément de syntaxe manquant.
Suggestion : ajoutez " + erreur_syntaxe[4 * a] + ".

"); + break; + + case "tout": + $("#debug_titre").after("

• ligne " + erreur_syntaxe[4 * a + 3] + " : élément manquant.

"); + break; + + case "instruction_illegale": + $("#debug_titre").after("

• ligne " + erreur_syntaxe[4 * a + 3] + " : instruction \"" + erreur_syntaxe[4 * a + 1] + "\" inadaptée au contexte.
Suggestion : vérifiez vos " + erreur_syntaxe[4 * a + 4] + ".

"); + expression = erreur_syntaxe[4 * a + 1]; + break; + + case "erreur_conditions": + $("#debug_titre").after("

• Erreur de conditions
Suggestion : vérifiez vos conditions.

"); + break; + + case "erreur_boucles": + $("#debug_titre").after("

• Erreur de boucles
Suggestion : vérifiez vos boucles.

"); + break; + + case "erreur_ti": + $("#debug_titre").after("

• Erreur de structure
Suggestion : vérifiez vos conditions et vos boucles.

"); + break; + + default: + $("#debug_titre").after("

• ligne " + erreur_syntaxe[4 * a + 3] + " : " + erreur_syntaxe[4 * a + 2] + " au contexte.
Suggestion : remplacer \"" + erreur_syntaxe[4 * a + 1] + "\" par " + erreur_syntaxe[4 * a] + ".

"); + expression = erreur_syntaxe[4 * a + 1]; + break; + } + + if(erreur_syntaxe[4 * a + 2] != "erreur_conditions" && erreur_syntaxe[4 * a + 2] != "erreur_boucles" && erreur_syntaxe[4 * a + 2] != "erreur_ti") + code = surligne_erreurs(code, erreur_syntaxe[4 * a + 3], expression); + } + + return code; +} + +// affiche le "debug" +function affiche_debug() { + $('#execution').css('height', '85px'); + $('#debug').show(); +} + +// cache le "debug" +function masque_erreurs() { + $('#debug').hide(); + $('#execution').css('height', '210px'); +} + +// efface le debug +function debug_efface() { + $("").replaceAll('.erreurs'); +} + +function ameliore_syntaxe_description() { + erreur_syntaxe[4 * nb_erreurs + 2] = "expression \"" + erreur_syntaxe[4 * nb_erreurs + 1] + "\" inadaptée"; +} + +function ameliore_syntaxe_suggestion(langage_source) { + var a, nouveau; + + switch(erreur_syntaxe[4 * nb_erreurs]) + { + case "variable": + nouveau = "une variable"; + break; + + case "chaine": + nouveau = "un texte"; + break; + + case "calcul": + nouveau = "une valeur"; + break; + + case "chaine_variable_calcul": + nouveau = "un texte ou une valeur"; + break; + + case "condition": + nouveau = "une condition"; + break; + + case "condition_alors": + if(langage_source == 1) + nouveau = "l'instruction \"Alors\""; + else + nouveau = "l'instruction \"Then\""; + break; + + case "→_ou_∠": + if(langage_source == 2) + nouveau = "\"→\" suivi d'une variable ou de \"∠\""; + else + nouveau = "\"→\" suivi d'une variable"; + break; + + default: + nouveau = "\"" + erreur_syntaxe[4 * nb_erreurs] + "\""; + break; + } + + erreur_syntaxe[4 * nb_erreurs] = nouveau; +} + +function detecte_variable(mot) { + if(mot == "a" || mot == "b" || mot == "c" || mot == "d" || mot == "e" || mot == "f" || mot == "g" || mot == "h" || mot == "i" || mot == "j" || mot == "k" || mot == "l" || mot == "m" || mot == "n" || mot == "o" || mot == "p" || mot == "q" || mot == "r" || mot == "s" || mot == "t" || mot == "u" || mot == "v" || mot == "w" || mot == "x" || mot == "y" || mot == "z") + return "variable"; + else return mot; +} + + +function detecte_calculs(mot, langage_source) { + var lettre, dernier, avant_dernier = "undefined"; + + mot = mot.toLowerCase(); + + for(a = 0; a < mot.length; a++) + { + lettre = mot.substring(a, a + 1); + + if(mot.substring(a, a + 14) == "racine_carrée(") + { + lettre = "+"; + a += 13; + } + + if(mot.substring(a, a + 4) == "exp(") + { + lettre = "+"; + a += 3; + } + + if(mot.substring(a, a + 2) == "ln") + { + lettre = "+"; + a += 1; + } + + if(langage_source == 1) + { + if(mot.substring(a, a + 6) == "hasard") + { + lettre = "+"; + a += 5; + } + + if(mot.substring(a, a + 14) == "partie_entière") + { + lettre = "+"; + a += 13; + } + + if(mot.substring(a, a + 15) == "partie_décimale") + { + lettre = "+"; + a += 14; + } + + if(mot.substring(a, a + 14) == "valeur_absolue") + { + lettre = "+"; + a += 13; + } + } + + if(langage_source == 2) + { + if(mot.substring(a, a + 4) == "#ran") + { + lettre = "+"; + a += 3; + } + + if(mot.substring(a, a + 3) == "int") + { + lettre = "+"; + a += 2; + } + + if(mot.substring(a, a + 4) == "frac") + { + lettre = "+"; + a += 3; + } + + if(mot.substring(a, a + 3) == "abs") + { + lettre = "+"; + a += 2; + } + } + + if(langage_source == 3) + { + if(mot.substring(a, a + 4) == "rand") + { + lettre = "+"; + a += 3; + } + + if(mot.substring(a, a + 4) == "int(") + { + lettre = "+"; + a += 3; + } + + if(mot.substring(a, a + 6) == "fpart(") + { + lettre = "+"; + a += 5; + } + + if(mot.substring(a, a + 4) == "abs(") + { + lettre = "+"; + a += 3; + } + } + + dernier = detecte_variable(lettre); + if((dernier == "variable" && dernier == avant_dernier) || !(detecte_nombre(lettre, 0) == "nombre" || dernier == "variable" || lettre == "+" || lettre == "-" || lettre == "*" || lettre == "%" || lettre == "/" || lettre == "^" || lettre == "(" || lettre == ")" || escape(lettre) == "%u03C0")) + return "undefined"; + + avant_dernier = dernier; + } + + return "calcul"; +} + +function detecte_nombre(mot, lire) { + var a, current, point = 0; + + if(mot == "π") + return "nombre"; + + for(a = 0; a < mot.length; a++) + { + current = mot.substring(a, a + 1); + + if(lire == 1 && a == 0 && (current == "+" || current == "-") && mot.length > 1) + continue; + + if(current == ".") + point++; + + if(point > 1 || !(current == "0" || current == "1" || current == "2" || current == "3" || current == "4" || current == "5" || current == "6" || current == "7" || current == "8" || current == "9" || current == ".")) + return mot; + } + + return "nombre"; +} + +function surligne_erreurs(code, ligne, expression) { + var i; + var begin = 0, end; + + for(i = 1; i < ligne; i++) + { + begin = code.indexOf("@", begin) + 1; + } + + if(expression) + { + begin = code.indexOf(expression, begin); + end = begin + expression.length; + } + else + { + end = code.indexOf("@", begin) + 1; + if(end == -1) + end = code.length; + } + + var newcode = code.substring(0, begin) + "" + code.substring(begin, end) + "" + code.substring(end, code.length); + return newcode; +} diff --git a/compil2.js b/compil2.js new file mode 100644 index 0000000..674a488 --- /dev/null +++ b/compil2.js @@ -0,0 +1,103 @@ +function detecte_instruction(recu, langage_source) { + mot = recu.toLowerCase(); + if(mot == "∠") + mot = unescape("%u2220"); + + if(((mot == "lire" || mot == "afficher" || mot == "si" || mot == "alors" || mot == "sinon" || mot == "fin_si" || mot == "tant_que" || mot == "fin_tant_que" || mot == "pour" || mot == "allant_de" || mot == "à" || mot == "fin_pour" || mot == "prend_la_valeur" || mot == "hasard" || mot == "et" || mot == "ou" || mot == "partie_entière" || mot == "partie_décimale" || mot == "valeur_absolue" || mot == "fin_programme") && langage_source == 1) || ((mot == "?" || escape(mot) == "%u2220" || mot == "ifend" || mot == "for" || mot == "to" || mot == "next" || mot == "#ran" || mot == "int" || mot == "frac" || mot == "abs") && langage_source == 2) || ((mot == "input" || mot == "disp" || mot == "end" || mot == "for(" || mot == "rand" || mot == "int(" || mot == "fpart(" || mot == "abs(") && langage_source == 3) || ((mot == "if" || mot == "then" || mot == "else" || mot == "while" || mot == "whileend" || escape(mot) == "%u2192" || mot == "and" || mot == "or" || mot == "stop") && (langage_source == 2 || langage_source == 3))) + return mot; + else + return "undefined"; +} + +function detecte_signe(mot) { + if(mot == "=" || mot == "<" || mot == ">" || escape(mot) == "%u2265" || escape(mot) == "%u2264" || escape(mot) == "%u2260") + return "signe"; + else + return "undefined"; +} + +function detecte_operation(mot) { + if(mot == "+" || mot == "-" || mot == "*" || mot == "/" ||mot == "%" || mot == "^") + return "operation"; + else + return "undefined"; +} + +function detecte_parenthese(mot) { + if(mot == "(" || mot == ")") + return "parenthese"; + else + return "undefined"; +} + +function detecte_outils(mot, langage_source) { + mot = mot.toLowerCase(); + if(mot == "racine_carrée" || mot == "exp" || mot == "ln" || (langage_source == 1 && (mot == "hasard" || mot == "partie_décimale" || mot == "partie_entière" || mot == "valeur_absolue")) || (langage_source == 2 && (mot == "#ran" || mot == "int" || mot == "frac" || mot == "abs")) || (langage_source == 3 && (mot == "rand" || mot == "int" || mot == "fpart" || mot == "abs"))) + return "outils"; + else + return "undefined"; +} + +function verifie_conditions(mot_recu, ligne) { + if(conditions_ouvertes - conditions_fermees <= 0) + { + erreur_syntaxe[4 * nb_erreurs + 1] = mot_recu; + erreur_syntaxe[4 * nb_erreurs + 2] = "instruction_illegale"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + erreur_syntaxe[4 * nb_erreurs + 4] = "conditions"; + nb_erreurs++; + } +} + +function verifie_boucles(mot_recu, ligne, langage) { + if(boucles_ouvertes - boucles_fermees <= 0) + { + erreur_syntaxe[4 * nb_erreurs + 1] = mot_recu; + erreur_syntaxe[4 * nb_erreurs + 2] = "instruction_illegale"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + if(langage == 1) + erreur_syntaxe[4 * nb_erreurs + 4] = "boucles \"Tant_que\""; + else + erreur_syntaxe[4 * nb_erreurs + 4] = "boucles \"While\""; + nb_erreurs++; + } +} + +function verifie_pour(mot_recu, ligne, langage) { + if(pour_ouverts - pour_fermes <= 0) + { + erreur_syntaxe[4 * nb_erreurs + 1] = mot_recu; + erreur_syntaxe[4 * nb_erreurs + 2] = "instruction_illegale"; + erreur_syntaxe[4 * nb_erreurs + 3] = ligne; + if(langage == 1) + erreur_syntaxe[4 * nb_erreurs + 4] = "boucles \"Pour\""; + else + erreur_syntaxe[4 * nb_erreurs + 4] = "boucles \"For\""; + nb_erreurs++; + } +} + +function affiche_resultats() { + var z, n = 0; + for(z = 0; z < j; z++) + { + if(z == indices[n]) + { + alert("ok"); + n++; + } + alert(code[z]); + } +} + +function createCookie(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value; +} + + diff --git a/config.php b/config.php new file mode 100644 index 0000000..7784be9 --- /dev/null +++ b/config.php @@ -0,0 +1,30 @@ + diff --git a/contact.php b/contact.php new file mode 100644 index 0000000..b4229c1 --- /dev/null +++ b/contact.php @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + Festiv'Algo - Contact + + + +
+ +
+
+
+

Nom

+ +

E-mail

+ +

Objet

+ +

Message

+

+ +
+
+
+
+ + + \ No newline at end of file diff --git a/database.sql b/database.sql new file mode 100644 index 0000000..d635d16 --- /dev/null +++ b/database.sql @@ -0,0 +1,64 @@ +-- -------------------------------------------------------- + +-- +-- Structure de la table `categories` +-- + +CREATE TABLE `categories` ( + `id` smallint(6) NOT NULL, + `name` varchar(256) NOT NULL, + `description` text NOT NULL, + `position` smallint(6) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `pm` +-- + +CREATE TABLE `pm` ( + `id` bigint(20) NOT NULL, + `id2` int(11) NOT NULL, + `title` varchar(256) NOT NULL, + `user1` bigint(20) NOT NULL, + `user2` bigint(20) NOT NULL, + `message` text NOT NULL, + `timestamp` int(10) NOT NULL, + `user1read` varchar(3) NOT NULL, + `user2read` varchar(3) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `topics` +-- + +CREATE TABLE `topics` ( + `parent` smallint(6) NOT NULL, + `id` int(11) NOT NULL, + `id2` int(11) NOT NULL, + `title` varchar(256) NOT NULL, + `message` longtext NOT NULL, + `authorid` int(11) NOT NULL, + `timestamp` int(11) NOT NULL, + `timestamp2` int(11) NOT NULL, + PRIMARY KEY (`id`,`id2`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Structure de la table `users` +-- + +CREATE TABLE `users` ( + `id` bigint(20) NOT NULL, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `email` varchar(255) NOT NULL, + `avatar` text NOT NULL, + `signup_date` int(10) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/delete_category.php b/delete_category.php new file mode 100644 index 0000000..d193b2c --- /dev/null +++ b/delete_category.php @@ -0,0 +1,84 @@ +0) +{ +if(isset($_SESSION['username']) and $_SESSION['username']==$admin) +{ +?> + + + + + + Supprimer une catégorie - <?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?> - forum + + +
+ forum +
+
+ +
+
+ Index du forum > > Supprimer la catégorie +
+ +
+
+"'.$dn1['position'].'"')) + { + ?> +
La catégorie et ses sujets a bien été supprimée.
+ Retourner à l'index du forum
+ +
+ Êtes-vous sûr de vouloir supprimer cette catégorie et l'ensemble de ses sujets? + + +
+ +
+ + + +Vous devez être connecté en tant qu\'administrateur pour accéder à cette page: Connexion - Inscription'; +} +} +else +{ + echo '

La catégorie que vous désirez supprimer n\'existe pas.

'; +} +} +else +{ + echo '

L\'identifiant de la catégorie à supprimer n\'est pas défini

'; +} +?> diff --git a/delete_topic.php b/delete_topic.php new file mode 100644 index 0000000..8e2d700 --- /dev/null +++ b/delete_topic.php @@ -0,0 +1,91 @@ +0) +{ +if($_SESSION['username']==$admin) +{ +?> + + + + + + Supprimer un sujet - <?php echo htmlentities($dn1['title'], ENT_QUOTES, 'UTF-8'); ?> - <?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?> - forum + + +
+ forum +
+
+ +
+
+ Index du forum > > > Supprimer le sujet +
+ +
+
+ +
Le sujet a bien été supprimé.
+ Retourner au sujet
+ +
+ Êtes-vous sûr de vouloir supprimer ce sujet? + + +
+ +
+ + + +Vous n\'avez pas le droit de supprimer ce sujet.'; +} +} +else +{ + echo '

Le sujet que vous désirez supprimer n\'existe pas.

'; +} +} +else +{ + echo '

Vous devez être connecté en tant qu\'administrateur pour accéder à cette page: Connexion - Inscription

'; +} +} +else +{ + echo '

Un identifiant du sujet que vous désirez supprimer n\'est pas défini.

'; +} +?> diff --git a/design_forum/images/black_40p.png b/design_forum/images/black_40p.png new file mode 100644 index 0000000..84feff1 Binary files /dev/null and b/design_forum/images/black_40p.png differ diff --git a/design_forum/images/bluec_30p.png b/design_forum/images/bluec_30p.png new file mode 100644 index 0000000..976e3d1 Binary files /dev/null and b/design_forum/images/bluec_30p.png differ diff --git a/design_forum/images/button.png b/design_forum/images/button.png new file mode 100644 index 0000000..19cb97b Binary files /dev/null and b/design_forum/images/button.png differ diff --git a/design_forum/images/delete.png b/design_forum/images/delete.png new file mode 100644 index 0000000..b42198f Binary files /dev/null and b/design_forum/images/delete.png differ diff --git a/design_forum/images/down.png b/design_forum/images/down.png new file mode 100644 index 0000000..0c82616 Binary files /dev/null and b/design_forum/images/down.png differ diff --git a/design_forum/images/edit.png b/design_forum/images/edit.png new file mode 100644 index 0000000..1f825ea Binary files /dev/null and b/design_forum/images/edit.png differ diff --git a/design_forum/images/up.png b/design_forum/images/up.png new file mode 100644 index 0000000..931e0aa Binary files /dev/null and b/design_forum/images/up.png differ diff --git a/design_forum/style.css b/design_forum/style.css new file mode 100644 index 0000000..7fcab94 --- /dev/null +++ b/design_forum/style.css @@ -0,0 +1,268 @@ +/*****************************************************/ +/****General****/ +/** +{ + margin:0px; + padding:0px; +}*/ + +a +{ + text-decoration:none; + color:#333333; +} +a:hover +{ + color:#000000; +} +img, table, tr, td +{ + border:0px; +} +h1 +{ + text-align:center; + margin:0px; + padding:0px; +} +.clean +{ + clear:both; +} +.left +{ + text-align:left; +} +.center +{ + text-align:center; +} +input[type=text], input[type=submit], input[type=button], input[type=password] +{ + width:150px; +} +input[type=submit] +{ + margin-top: 10px; +} +label +{ + width: 200px; + display: inline-block; + vertical-align: top; + text-align: left; + margin-bottom: 8px; +} +#se_souvenir +{ + width: 351px; +} +.message_buttons input +{ + width:auto; + padding:0px 5px; +} +.button +{ + padding:5px 15px; + vertical-align:middle; + border:1px solid #aaaaaa; + font-weight:bold; + background:url('Images/button.png') repeat-x; + -moz-border-radius:6px; + -webkit-border-radius:6px; + border-radius:6px; + display:inline-block; +} + +#content table +{ + border-spacing:0px; + background:#ffffff; + padding:0px; + width:95%; + margin:5px auto 18px auto; + background-color: rgb(241, 189, 23); + border: solid; + border-width: 4px; + border-radius: 10px; + border-color: rgb(233, 153, 10); +} +tr +{ + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; + margin:0px; +} +td, th +{ + margin:0px; + border:0px; + padding:3px; + text-align:center; +} +/*****************************************************/ +/****Blocks****/ +.header +{ + margin:auto; + margin-top:10px; + padding:15px; + background:url('Images/bluec_30p.png'); + width:60%; + -moz-border-radius:20px; + -webkit-border-radius:20px; + border-radius:20px; + text-align:center; +} +.foot +{ + text-align:center; + background:url('Images/bluec_30p.png'); + width:60%; + -moz-border-radius:15px; + -webkit-border-radius:15px; + border-radius:15px; + padding:10px; + margin:20px auto; +} +.content +{ + background-color: #FFD745; + border: solid; + border-width: 4px; + border-color: #FAC801; + font-family: Normal, Arial; + margin-left: 45px; + margin-right: 45px; + border-radius:20px; + padding:20px; + margin-top:10px; +} +.box_left +{ + float:left; +} +.box_right +{ + float:right; +} +.box +{ + border: solid; + border-width: 4px; + border-radius: 10px; + border-color: #FAC801; + margin:5px auto 30px auto; + padding: 5px 10px 5px 10px; +} +.login +{ + width:355px; + margin:auto; + text-align:left; +} +.box_login +{ + background-color: rgb(250, 184, 43); + border: solid; + border-width: 4px; + border-color: rgb(247, 154, 14); + width:360px; + -moz-border-radius:10px; + -webkit-border-radius:10px; + border-radius:10px; + margin:auto; + padding:20px; + margin-top:20px; + margin-bottom: 38px; + color:#ffffff; +} +/*****************************************************/ +/****Content****/ + +.champs +{ + margin-bottom: 8px; +} + +#memorize +{ + position: absolute; + top: 419px; + left: 510px; +} + +.big +{ + font-size:1.2em; +} +.small +{ + font-size:0.7em; +} +.message +{ + -moz-border-radius:20px; + -webkit-border-radius:20px; + border-radius:20px; + padding:20px; + margin:auto; + width:500px; + background:url('Images/black_40p.png'); + color:#ffffff; + text-align:center; + font-weight:bold; + margin-top:20px; +} +.messages_table td +{ + border-top:1px solid #cccccc; + vertical-align:top; +} +.author +{ + width:150px; + border-right:1px solid #cccccc; +} +.title_cell +{ + width:45%; +} +.date +{ + font-style:italic; + text-align:right; + font-size:0.9em; + margin-right:10px; +} +.edit +{ + float:left; +} +.forum_ntop, .forum_nrep, .forum_act, .forum_auth +{ + width:100px; +} +td.forum_cat, td.forum_tops +{ + padding-left:15px; + text-align:left; +} +.categories_table td, .categories_table th, .topics_table td, .topics_table th, .list_pm td, .list_pm th +{ + border-bottom:1px solid #cccccc; +} +.categories_table tr:last-child td, .topics_table tr:last-child td, .list_pm tr:last-child td +{ + border-bottom:0px; +} +td.forum_cat .title +{ + font-weight:bold; +} +td.forum_cat .description +{ + padding-left:5px; +} diff --git a/edit_category.php b/edit_category.php new file mode 100644 index 0000000..d84760e --- /dev/null +++ b/edit_category.php @@ -0,0 +1,94 @@ +0) +{ +if(isset($_SESSION['username']) and $_SESSION['username']==$admin) +{ +?> + + + + + + Modifier une catégorie - <?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?> - forum + + +
+ forum +
+
+ +
+
+ Index du forum > > Modifier la catégorie +
+ +
+
+ +
La catégorie a bien été modifiée.
+ Retourner à l'index du forum
+ +
+
+ (html accepté)
+
+ +
+ +
+ + + +Vous devez être connecté en tant qu\'administrateur pour accéder à cette page: Connexion - Inscription'; +} +} +else +{ + echo '

La catégorie que vous désirez modifier n\'existe pas.

'; +} +} +else +{ + echo '

L\'identifiant de la catégorie à modifier n\'est pas défini

'; +} +?> diff --git a/edit_message.php b/edit_message.php new file mode 100644 index 0000000..1aa79f8 --- /dev/null +++ b/edit_message.php @@ -0,0 +1,156 @@ +0) +{ +if($_SESSION['userid']==$dn1['authorid'] or $_SESSION['username']==$admin) +{ +include('bbcode_function.php'); +?> + + + + + + + + + + Festiv'Algo - Editer un message + + + +
+ +
+ +
+
+ Index du forum > > > Modifier +
+ +
+
+ +
Le message a bien été modifié.
+ Retourner au sujet
+ +
+ + + +
+
+ +
+
+ +
+ +
+ + +
+ + + +Vous n\'avez pas le droit de modifier ce message.'; +} +} +else +{ + echo '

Le message que vous désirez modifier n\'existe pas.

'; +} +} +else +{ +?> +

Vous devez être connecté pour accéder à cette page:

+ +Un identifiant du message que vous désirez modifier n\'est pas défini.'; +} +?> \ No newline at end of file diff --git a/edit_profile.php b/edit_profile.php new file mode 100644 index 0000000..8d5aa11 --- /dev/null +++ b/edit_profile.php @@ -0,0 +1,163 @@ + + + + + + + Modifier ses informations personnelles + + +
+ Espace Membre +
+
+ +
+
+ Index du forum > Modifier ses informations personnelles +
+ +
+
+=6) + { + if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email'])) + { + $username = mysql_real_escape_string($_POST['username']); + $password = mysql_real_escape_string($_POST['password']); + $email = mysql_real_escape_string($_POST['email']); + $avatar = mysql_real_escape_string($_POST['avatar']); + $dn = mysql_fetch_array(mysql_query('select count(*) as nb from users where username="'.$username.'"')); + if($dn['nb']==0 or $_POST['username']==$_SESSION['username']) + { + if(mysql_query('update users set username="'.$username.'", password="'.$password.'", email="'.$email.'", avatar="'.$avatar.'" where id="'.mysql_real_escape_string($_SESSION['userid']).'"')) + { + $form = false; + unset($_SESSION['username'], $_SESSION['userid']); +?> +
Vos informations ont bien été modififée. Vous devez vous reconnecter.
+Se connecter
+'.$message.''; + } + if(isset($_POST['username'],$_POST['password'],$_POST['email'])) + { + $username = htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8'); + if($_POST['password']==$_POST['passverif']) + { + $password = htmlentities($_POST['password'], ENT_QUOTES, 'UTF-8'); + } + else + { + $password = ''; + } + $email = htmlentities($_POST['email'], ENT_QUOTES, 'UTF-8'); + $avatar = htmlentities($_POST['avatar'], ENT_QUOTES, 'UTF-8'); + } + else + { + $dnn = mysql_fetch_array(mysql_query('select username,password,email,avatar from users where username="'.$_SESSION['username'].'"')); + $username = htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); + $password = htmlentities($dnn['password'], ENT_QUOTES, 'UTF-8'); + $email = htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); + $avatar = htmlentities($dnn['avatar'], ENT_QUOTES, 'UTF-8'); + } +?> +
+ Vous pouvez modifier vos informations:
+
+
+
+
+
+
+ +
+
+ + +
Pour accéder à cette page, vous devez être connecté.
+ + +
+ + + diff --git a/execution.js b/execution.js new file mode 100644 index 0000000..c87ca9a --- /dev/null +++ b/execution.js @@ -0,0 +1,953 @@ +var vitesse_execution = 20; +boucles_pour = new Array(); + +idlire = 1; + +var priorites = [ + "π & variables", "outils", "^", "*/%", "+-" +]; + +var variables = [ + "a", 0, + "b", 0, + "c", 0, + "d", 0, + "e", 0, + "f", 0, + "g", 0, + "h", 0, + "i", 0, + "j", 0, + "k", 0, + "l", 0, + "m", 0, + "n", 0, + "o", 0, + "p", 0, + "q", 0, + "r", 0, + "s", 0, + "t", 0, + "u", 0, + "v", 0, + "w", 0, + "x", 0, + "y", 0, + "z", 0, + "π", 3.141592653 +]; + +var v; + +function execution(langage_source, nb) { + var j, e, result; + + if(nb == 0 || reset == 1) + { + nb = 0; + reset = 0; + pause = 0; + process = 1; + boucles_pour[0] = 1; + execution_init(); + result = compilation(langage_source); + if(result == "failed") + return "failed"; + + $('#executer').hide(); + $('#pause').show(); + + reset_variables(); + $("#saisie").cleditor()[0].disable(true); + } + + instructions(nb, langage_source); +} + +function instructions(nb, langage_source) { + var quit = 0; + + for(v = nb; v < k; v++) + { + if(pause == 1) + { + $('#executer').unbind('click'); + $('#executer').click(function() { + execution(langage_source, nb + 1); + }); + + pause = 0; + return; + } + + if(reset == 1) + { + process = 0; + return; + } + + switch(code[indices[v]]) + { + case "lire": + display(""); + lire_pending = 1; + idlire++; + return; + break; + + case "afficher": + var message; + + switch(code[indices[v] + 1]) + { + case "chaine": + message = code[indices[v] + 2].substring(1, code[indices[v] + 2].length - 1); + break; + case "calcul": + message = execute_calculs(code[indices[v] + 2], langage_source); + break; + case "variable": + message = valeur_variable(code[indices[v] + 2]); + break; + } + display(message); + break; + + case "si": + if(execute_condition(v, langage_source) == "false") + { + var si = 0, ti = 0; + for(v = v + 1; ; v++) + { + if(((langage_source != 3 && si == 0 )|| (langage_source == 3 && ti == 0)) && (code[indices[v]] == "sinon" || code[indices[v]] == "fin_si" || code[indices[v]] == "fin_si_ou_boucle")) + break; + + if(code[indices[v]] == "si") + si++; + if(code[indices[v]] == "fin_si") + si--; + + if(code[indices[v]] == "si" || code[indices[v]] == "tant_que" || code[indices[v]] == "pour") + ti++; + if(code[indices[v]] == "fin_si_ou_boucle") + ti--; + } + } + break; + + case "sinon": + var si = 0, ti = 0; + for(v = v + 1; ; v++) + { + if(((langage_source != 3 && si == 0 ) || (langage_source == 3 && ti == 0)) && (code[indices[v]] == "fin_si_ou_boucle" || code[indices[v]] == "fin_si")) + break; + + if(code[indices[v]] == "si") + si++; + if(code[indices[v]] == "fin_si") + si--; + if(code[indices[v]] == "si" || code[indices[v]] == "tant_que" || code[indices[v]] == "pour") + ti++; + if(code[indices[v]] == "fin_si_ou_boucle") + ti--; + } + break; + + case "tant_que": + if(execute_condition(v, langage_source) == "false") + { + var tant_que = 0, ti = 0; + for(v = v + 1; ; v++) + { + if(((langage_source != 3 && tant_que == 0) || (langage_source == 3 && ti == 0)) && (code[indices[v]] == "fin_tant_que" || code[indices[v]] == "fin_si_ou_boucle")) + break; + + if(code[indices[v]] == "tant_que") + tant_que++; + if(code[indices[v]] == "fin_tant_que") + tant_que--; + if(code[indices[v]] == "si" || code[indices[v]] == "tant_que" || code[indices[v]] == "pour") + ti++; + if(code[indices[v]] == "fin_si_ou_boucle") + ti--; + } + } + break; + + case "fin_tant_que": + case "fin_si_ou_boucle": + var tant_que = 0, ti = 0, mem = v; + + for(v = v - 2; ; v--) + { + if(((langage_source != 3 && tant_que == 0) || (langage_source == 3 && ti == 0)) && (code[indices[v + 1]] == "tant_que" || ((code[indices[v + 1]] == "si" || code[indices[v + 1]] == "pour") && langage_source == 3))) + { + if(code[indices[v + 1]] == "si") + v = mem; + break; + } + + if(code[indices[v + 1]] == "tant_que") + tant_que++; + if(code[indices[v + 1]] == "fin_tant_que") + tant_que--; + if(code[indices[v + 1]] == "si" || code[indices[v + 1]] == "tant_que" || code[indices[v + 1]] == "pour") + ti++; + if(code[indices[v + 1]] == "fin_si_ou_boucle") + ti--; + } + + setTimeout("instructions(" + (v + 1) + ", " + langage_source + ")", vitesse_execution); + quit = 1; + break; + + case "pour": + var new_pour = 0, a; + + for(a = 1; a < boucles_pour[0]; a++) + { + if(boucles_pour[a] == v) + { + new_pour = a; + break; + } + } + + var num = new Array; + switch(langage_source) + { + case 1: + num[0] = 2; + num[1] = 5; + num[2] = 8; + break; + case 2: + num[0] = 5; + num[1] = 2; + num[2] = 8; + break; + case 3: + num[0] = 2; + num[1] = 5; + num[2] = 8; + + if(compte_caract(code[indices[v] + num[2]], "(") + 1 == compte_caract(code[indices[v] + num[2]], ")")) + code[indices[v] + num[2]] = code[indices[v] + num[2]].substring(0, code[indices[v] + num[2]].length - 1); + break; + } + + var indice_var = cherche_variable(code[indices[v] + num[0]]); + if(new_pour == 0) + { + variables[indice_var] = execute_calculs(code[indices[v] + num[1]], langage_source); + boucles_pour[boucles_pour[0]] = v; + boucles_pour[0]++; + } + else + { + if(variables[indice_var] < execute_calculs(code[indices[v] + num[2]], langage_source)) + variables[indice_var]++; + else + { + var pour = 0, ti = 0; + for(v = v + 1; ; v++) + { + if(((langage_source != 3 && pour == 0) || (langage_source == 3 && ti == 0)) && (code[indices[v]] == "fin_pour" || code[indices[v]] == "fin_si_ou_boucle")) + break; + + if(code[indices[v]] == "pour") + pour++; + if(code[indices[v]] == "fin_pour") + pour--; + if(code[indices[v]] == "si" || code[indices[v]] == "tant_que" || code[indices[v]] == "pour") + ti++; + if(code[indices[v]] == "fin_si_ou_boucle") + ti--; + } + boucles_pour[new_pour] = -1; + } + } + affiche_variable(indice_var - 1); + break; + + case "fin_pour": + var pour = 0; + for(v = v - 2; ; v--) + { + if(pour == 0 && code[indices[v + 1]] == "pour") + break; + if(code[indices[v + 1]] == "pour") + pour++; + if(code[indices[v + 1]] == "fin_pour") + pour--; + } + + setTimeout("instructions(" + (v + 1) + ", " + langage_source + ")", vitesse_execution); + quit = 1; + break; + + case "variable": + var indice_var = cherche_variable(code[indices[v] + 1]); + + if(code[indices[v] + 2] == "prend_la_valeur") + variables[indice_var] = execute_calculs(code[indices[v] + 4], langage_source); + else if(code[indices[v] + 2] == "∠") + { + var valeur = execute_calculs(code[indices[v] + 1], langage_source); + variables[indice_var] = valeur; + display(valeur); + } + else if(code[indices[v] + 2] == "→") + { + indice_var = cherche_variable(code[indices[v] + 4]); + variables[indice_var] = execute_calculs(code[indices[v] + 1], langage_source); + } + + affiche_variable(indice_var - 1); + break; + + case "calcul": + if(code[indices[v] + 2] == "∠") + { + var valeur = execute_calculs(code[indices[v] + 1], langage_source); + display(valeur); + } + else if(code[indices[v] + 2] == "→") + { + var indice_var = cherche_variable(code[indices[v] + 4]); + variables[indice_var] = execute_calculs(code[indices[v] + 1], langage_source); + affiche_variable(indice_var - 1); + } + break; + + case "chaine": + message = code[indices[v] + 1].substring(1, code[indices[v] + 1].length - 1); + display(message); + break; + + case "fin_programme": + v = k; + break; + } + + if(quit == 1) + break; + } + + if(v == k) + { + display("Fin de l'exécution"); + process = 0; + $('#pause').hide(); + $('#executer').show(); + $("#saisie").cleditor()[0].disable(false); + } +} + +function lire(myvar, langage_source, nb, id) { + var nombre = document.getElementById("lire" + id).value; + + $('#lire' + id).replaceWith('

' + nombre + '

'); + + if(detecte_nombre(nombre, 1) != "nombre" || nombre.length == 0) + { + display("Erreur : veuillez rentrer un nombre."); + display(""); + document.getElementById("lire" + idlire).focus(); + idlire++; + return; + } + + var indice_var = cherche_variable(myvar); + + variables[indice_var] = nombre; + affiche_variable(indice_var - 1); + + if(pause == 1) + { + $('#executer').hide(); + $('#pause').show(); + } + + pause = 0; + lire_pending = 0; + execution(langage_source, nb + 1); +} + +function paused(langage_source, nb) { + execution(langage_source, nb + 1); +} + +function display(message) { + $('#resultats').append('

' + message + '

'); +} + +function affiche_variable(myvar) { + $('#var_' + variables[myvar]).replaceWith("

" + variables[myvar].toUpperCase() + " = " + variables[myvar + 1] + "

"); +} + +function execute_condition(v, langage_source) { + var compil = new Array(), l; + compil = compil_condition(v, langage_source); + + compil = simplifie_condition(compil, 1, compil[0]); + + for(l = 1; l < compil[0]; l++) + { + if(compil[l] == "true" || compil[l] == "false") + return compil[l]; + } +} + +function compil_condition(v, langage_source) { + var n; + var compil = new Array(); + compil[0] = 1; + + for(n = 1; indices[v] + n < indices[v + 1]; n++) + { + switch(code[indices[v] + n]) + { + case "calcul": + if(compte_caract(code[indices[v] + n + 1], "(") > compte_caract(code[indices[v] + n + 1], ")")) + { + compil[compil[0]] = "("; + compil[0]++; + code[indices[v] + n + 1] = code[indices[v] + n + 1].substring(1, code[indices[v] + n + 1].length); + } + + if(compte_caract(code[indices[v] + n + 1], "(") > compte_caract(code[indices[v] + n + 1], ")")) + { + compil[compil[0]] = "("; + compil[0]++; + code[indices[v] + n + 1] = code[indices[v] + n + 1].substring(1, code[indices[v] + n + 1].length); + } + + if(compte_caract(code[indices[v] + n + 1], "(") < compte_caract(code[indices[v] + n + 1], ")")) + { + code[indices[v] + n + 1] = code[indices[v] + n + 1].substring(0, code[indices[v] + n + 1].length - 1); + compil[compil[0]] = execute_calculs(code[indices[v] + n + 1], langage_source); + compil[0]++; + compil[compil[0]] = ")"; + compil[0]++; + } + else + { + compil[compil[0]] = execute_calculs(code[indices[v] + n + 1], langage_source); + compil[0]++; + } + + if(compte_caract(code[indices[v] + n + 1], "(") < compte_caract(code[indices[v] + n + 1], ")")) + { + compil[compil[0]] = ")"; + compil[0]++; + code[indices[v] + n + 1] = code[indices[v] + n + 1].substring(0, code[indices[v] + n + 1].length - 1); + } + break; + case "variable": + compil[compil[0]] = valeur_variable(code[indices[v] + n + 1]); + compil[0]++; + break; + case "et": + compil[compil[0]] = "et"; + compil[0]++; + break; + case "ou": + compil[compil[0]] = "ou"; + compil[0]++; + break; + case "signe": + compil[compil[0]] = code[indices[v] + n + 1]; + compil[0]++; + break; + } + } + return compil; +} + +function simplifie_condition(compil, min, max) { + /* + // Gestion des parenthèses + */ + var j, l, parenthese; + + for(j = min; j < max; j++) + { + if(compil[j] == "(") + { + parenthese = 1; + for(l = j + 1; l < max; l++) + { + if(compil[l] == "(") + parenthese++; + + if(compil[l] == ")") + parenthese--; + + if(parenthese == 0 && compil[l] == ")") + { + compil[j] = "rien"; + compil[l] = "rien"; + + compil = simplifie_condition(compil, j + 1, l); + break; + } + } + } + + if(compil[j] == "<" || compil[j] == ">" || compil[j] == "=" || escape(compil[j]) == "%u2260" || escape(compil[j]) == "%u2264" || escape(compil[j]) == "%u2265") + { + var last = precedente_valeur(compil, j, 1); + var next = prochaine_valeur(compil, j, 1); + + switch(compil[j]) + { + case "<": + if(compil[last] < compil[next]) + compil[j] = "true"; + else + compil[j] = "false"; + break; + case ">": + if(compil[last] > compil[next]) + compil[j] = "true"; + else + compil[j] = "false"; + break; + case "=": + if(compil[last] == compil[next]) + compil[j] = "true"; + else + compil[j] = "false"; + break; + } + + switch(escape(compil[j])) + { + case "%u2260": + if(compil[last] != compil[next]) + compil[j] = "true"; + else + compil[j] = "false"; + break; + case "%u2264": + if(compil[last] <= compil[next]) + compil[j] = "true"; + else + compil[j] = "false"; + break; + case "%u2265": + if(compil[last] >= compil[next]) + compil[j] = "true"; + else + compil[j] = "false"; + break; + } + + compil[last] = "rien"; + compil[next] = "rien"; + + do + { + var operateur = -1, resultat = -1; + + for(var r = j - 1; r >= 1; r--) + { + if(operateur == -1 && (compil[r] == "et" || compil[r] == "ou")) + operateur = r; + if(operateur != -1 && resultat == -1 && (compil[r] == "true" || compil[r] == "false")) + resultat = r; + if(compil[r] == "(" || compil[r] == ")") + break; + } + + if(operateur != -1 && resultat != -1) + { + if(compil[operateur] == "et") + { + if(compil[j] == "true" && compil[resultat] == "true") + compil[operateur] = "true"; + else + compil[operateur] = "false"; + } + else if(compil[operateur] == "ou") + { + if(compil[j] != compil[resultat] || compil[j] == "true") + compil[operateur] = "true"; + else + compil[operateur] = "false"; + } + + compil[j] = "rien"; + compil[resultat] = "rien"; + + j = operateur; + } + } + while(operateur != -1 && resultat != -1); + } + } + + return compil; +} + +function execute_calculs(calcul, langage_source) { + compil = new Array(); + compil = compil_calculs(calcul, langage_source); + compil = simplifie_calculs(compil, 2, compil[0], langage_source, calcul); + + for(j = 1; j < compil[0]; j++) + { + if(compil[j] != "rien" && compil[j] != "(" && compil[j] != ")" && compil[j] != "parenthese" && compil[j] != "outil" && compil[j] != "undefined") + { + return Math.round(compil[j + 1] * 10e8) / 10e8; + } + } + + return "erreur"; +} + +function compil_calculs(calcul, langage_source) { + var i, current, position = 0, longer, type; + var compil = new Array(); + + compil[0] = 1; + + while(position < calcul.length) + { + type = "autre"; + longer = -1; + + for(i = 0; i < calcul.substring(position, calcul.length).length; i++) + { + current = calcul.substring(position, calcul.length - i); + + if(detecte_calculs2(current, langage_source) == "calcul") + { + longer = calcul.length - i; + break; + } + } + + if(i == calcul.substring(position, calcul.length).length + 1) + alert("erreur"); + if(detecte_nombre(calcul.substring(position, longer), 0) == "nombre") + type = "nombre"; + if(detecte_variable(calcul.substring(position, longer)) == "variable") + type = "variable"; + if(detecte_operation(calcul.substring(position, longer)) == "operation") + type = "operation"; + if(detecte_parenthese(calcul.substring(position, longer)) == "parenthese") + type = "parenthese"; + if(detecte_outils(calcul.substring(position, longer), langage_source) == "outils") + type = "outils"; + + compil[compil[0]] = type; + compil[compil[0] + 1] = calcul.substring(position, longer); + + compil[0] += 2; + + if(compil[compil[0] - 1] == "hasard") + { + compil[compil[0]] = "rien"; + compil[compil[0] + 1] = "rien"; + compil[0] += 2; + } + if(compil[compil[0] - 1] == "#ran") + { + compil[compil[0]] = compil[compil[0] - 2]; + compil[compil[0] + 1] = compil[compil[0] - 1]; + compil[compil[0] - 2] = "rien"; + compil[compil[0] - 1] = "rien"; + compil[0] += 2; + } + + position = longer; + } + + return compil; +} + +function simplifie_calculs(calcul, min, max, langage_source, expression) { + var j, l, parenthese, p, last, next; + + /* + // Gestion des parenthèses + */ + + for(j = min; j < max; j += 2) + { + if(compil[j] == "(" && compte_caract(expression, ")") > 0) + { + parenthese = 1; + for(l = j + 2; l < max; l += 2) + { + if(compil[l] == "(") + parenthese++; + + if(compil[l] == ")") + parenthese--; + + if(parenthese == 0 && compil[l] == ")") + { + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[l - 1] = "rien"; + compil[l] = "rien"; + + compil = simplifie_calculs(compil, j + 2, l - 1, langage_source, ""); + break; + } + } + } + } + + /******************************************************************/ + + for(p = 0; p < 6; p++) + { + for(j = min; j < max; j += 2) + { + last = precedente_valeur(compil, j, 2); + next = prochaine_valeur(compil, j, 2); + + switch(priorites[p]) + { + case "π & variables": + if(escape(compil[j]) == "%u03C0") + compil[j] = "π"; + if(compil[j - 1] == "variable" || compil[j] == "π") + { + compil[j - 1] = "nombre"; + compil[j] = valeur_variable(compil[j]); + } + break; + + case "outils": + if(compil[j - 1] == "outils") + { + if(compil[next - 1] != "nombre" && compil[j] != "#ran") + alert("erreur outils"); + else + { + if(compil[j] == "racine_carrée") + { + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[next] = Math.sqrt(compil[next]); + + if(escape(compil[next]) == "NaN") + alert("erreur domaine de définition racine carrée"); + } + + if(compil[j] == "exp") + { + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[next] = Math.exp(compil[next]); + } + + if(compil[j] == "ln") + { + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[next] = Math.log(compil[next]); + + if(escape(compil[next]) == "NaN") + alert("erreur domaine de définition du logarithme népérien"); + } + + if(compil[j] == "hasard" || compil[j] == "rand") + { + compil[j - 1] = "nombre"; + compil[j] = Math.random(); + compil[j + 1] = "operation"; + compil[j + 2] = "*"; + } + + if(compil[j] == "#ran") + { + compil[j - 1] = "nombre"; + compil[j] = Math.random(); + compil[last + 1] = "operation"; + compil[last + 2] = "*"; + } + + if(compil[j] == "partie_entière" || compil[j] == "int") + { + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[next] = Math.floor(compil[next]); + } + + if(compil[j] == "partie_décimale" || compil[j] == "frac" || compil[j] == "fpart") + { + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[next] -= Math.floor(compil[next]); + } + + if(compil[j] == "valeur_absolue" || compil[j] == "abs") + { + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[next] = Math.abs(compil[next]); + } + } + } + break; + + case "^": + if(compil[j] == "^") + { + if(compil[last - 1] != "nombre" || compil[next - 1] != "nombre") + alert("erreur ^"); + else + { + compil[last] = Math.pow(compil[last], compil[next]); + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[next - 1] = "rien"; + compil[next] = "rien"; + } + } + break; + + case "*/%": + if(compil[j] == "*" || compil[j] == "/" || compil[j] == "%") + { + if(compil[last - 1] != "nombre" || compil[next - 1] != "nombre") + alert("erreur */%"); + else + { + switch(compil[j]) + { + case "*": + compil[last] = compil[last] * compil[next]; + break; + + case "/": + compil[last] = compil[last] / compil[next]; + break; + + case "%": + compil[last] = compil[last] % compil[next]; + break; + } + + if(escape(compil[last]) == "NaN") + alert("erreur */%"); + + if(escape(compil[last]) == "Infinity") + alert("erreur division par 0"); + + compil[j - 1] = "rien"; + compil[j] = "rien"; + compil[next - 1] = "rien"; + compil[next] = "rien"; + } + } + break; + + case "+-": + if(compil[j] == "+" || compil[j] == "-") + { + if(compil[next - 1] != "nombre") + alert("erreur +-"); + else + { + if(compil[last - 1] != "nombre") + { + if(compil[j] == "+") + compil[next] = 1 * compil[next]; + else + compil[next] = - compil[next]; + } + else + { + if(compil[j] == "+") + compil[last] = 1 * compil[last] + 1 * compil[next]; + else + compil[last] = compil[last] - compil[next]; + + compil[next - 1] = "rien"; + compil[next] = "rien"; + } + + compil[j - 1] = "rien"; + compil[j] = "rien"; + } + } + break; + } + } + } + + return compil; +} + +function detecte_calculs2(mot, langage_source) { + mot = mot.toLowerCase(); + + if(detecte_nombre(mot, 0) == "nombre" || detecte_variable(mot) == "variable" || detecte_operation(mot) == "operation" || detecte_parenthese(mot) == "parenthese" || detecte_outils(mot, langage_source) == "outils" || escape(mot) == "%u03C0") + return "calcul"; + else + return "undefined"; +} + +function reset_variables() { + var i; + + for(i = 0; i < 26; i++) + variables[2 * i + 1] = 0; +} + +function valeur_variable(myvar) { + return variables[cherche_variable(myvar)]; +} + +function cherche_variable(myvar) { + var i; + for(i = 0; i < 27; i++) + { + if(variables[2 * i] == myvar) + return 2 * i + 1; + } + alert("variable inconnue"); +} + +function prochaine_valeur(compil, j, pas) { + var i; + for(i = j + pas; i < compil[0]; i += pas) + { + if(compil[i] != "rien" && compil[i] != "true" && compil[i] != "false" && compil[i] != "et" && compil[i] != "ou" && compil[i] != "(" && compil[i] != ")" && compil[i] != "NaN") + return i; + } +} + +function precedente_valeur(compil, j, pas) { + var i; + + for(i = j - pas; i > 0; i -= pas) + { + if(compil[i] != "rien" && compil[i] != "true" && compil[i] != "false" && compil[i] != "et" && compil[i] != "ou" && compil[i] != "(" && compil[i] != ")" && compil[i] != "NaN") + return i; + } +} + +function execution_init() { + $('#resultats').replaceWith('
'); + + for(v = 0; v < 52; v += 2) + $('#var_' + variables[v]).replaceWith("

"); +} + +function compte_caract(chaine, type) { + var i, nb = 0; + for(i = 0; i < chaine.length; i++) + { + if(chaine.substring(i, i + 1) == type) + nb++; + } + return nb; +} \ No newline at end of file diff --git a/exemples.css b/exemples.css new file mode 100644 index 0000000..f90d5b8 --- /dev/null +++ b/exemples.css @@ -0,0 +1,85 @@ +article +{ + margin-top: 30px; +} + +h2 +{ + font-size: 24px; + font-style: bold; + color: black; + text-align: left; + margin: 10px 10px 20px 10px; +} + +h4 +{ + font-size: 12px; + font-style: bold; + color: rgb(255, 143, 0); + text-align: left; + margin: 18px 10px 6px 10px; +} + +#contenu +{ + margin-top: 10px; +} + +.exemples +{ + text-align: justify; + background-color: #FFD745; + border: solid; + border-width: 4px; + border-radius: 5px; + border-color: #FAC801; + font-family: Normal, Arial; + font-size: 16px; + font-style: none; + color: black; + padding: 5px 11px 7px 11px; + margin-left: 45px; + margin-right: 262px; +} + +.auteur +{ + font-size: 14px; + text-align: left; + margin: 0px 10px 10px 20px; +} + +.description +{ + font-size: 14px; + text-align: left; + margin: 0px 10px 10px 20px; +} + +.cleditorMain +{ + position: relative; + top: 0px; + left: 198px; +} + +.tester +{ + margin-left: 444px; +} + +#code +{ + width: 400px; + padding: 3px 0px 4px 8px; + margin-left: 198px; + font-family: Normal, Arial; + color: rgb(206, 133, 4); + text-align: left; + border: solid; + border-width: 4px; + border-radius: 5px; + border-color: rgb(221, 147, 53); + background-color: rgb(247, 226, 119); +} \ No newline at end of file diff --git a/exemples.js b/exemples.js new file mode 100644 index 0000000..6c7fbf0 --- /dev/null +++ b/exemples.js @@ -0,0 +1,27 @@ +$(document).ready(function() { + $('.tester').click(function() { + var texte = $(this).attr('id').substring(4, $(this).attr('id').length); + createCookie("exemple",texte,30); + }); +}); + +function createCookie(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value; +} + +function readCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; +} \ No newline at end of file diff --git a/exemples.php b/exemples.php new file mode 100644 index 0000000..dce4481 --- /dev/null +++ b/exemples.php @@ -0,0 +1,49 @@ + + + + + + + + + + + + Festiv'Algo - Exemples d'algorithmes + + + + + +
+ +
+ +
+
+

+

Auteur :

+

Description :


+ Tester cet algorithme +
+
+ + +
+
+ + + \ No newline at end of file diff --git a/forum.php b/forum.php new file mode 100644 index 0000000..f5c7aca --- /dev/null +++ b/forum.php @@ -0,0 +1,121 @@ + + + + + + + + + + + Festiv'Algo - forum + + + + + +
+ + +
+ + + + + + Nouvelle Catégorie + + + + + + Nouvelle Catégorie + + + + + + + + + + + + + + + + + + + + +
CatégorieSujetsRéponsesAction
+
Delete + 1){ ?>Faire Monter + Faire Descendre + Edit
+
+ +
+ + + diff --git a/functions.js b/functions.js new file mode 100644 index 0000000..a4149e2 --- /dev/null +++ b/functions.js @@ -0,0 +1,28 @@ +function getelem(id) +{ + return document.getElementById(id); +} +function insert(f, e, id) +{ + var scroll = getelem(id).scrollTop; + if(document.selection) + { + getelem(id).focus(); + sel = document.selection.createRange(); + sel.text = f+sel.text+e; + } + else if(getelem(id).selectionStart || getelem(id).selectionStart == '0') + { + var startPos = getelem(id).selectionStart; + var endPos = getelem(id).selectionEnd; + getelem(id).value = getelem(id).value.substring(0, startPos)+f+getelem(id).value.substring(startPos, endPos)+e+getelem(id).value.substring(endPos, getelem(id).value.length); + getelem(id).selectionStart = startPos+f.length; + getelem(id).selectionEnd = startPos+f.length+(endPos-startPos); + } + else + { + getelem(id).value += msg; + } + getelem(id).scrollTop = scroll; + getelem(id).focus(); +} \ No newline at end of file diff --git a/ie.css b/ie.css new file mode 100644 index 0000000..5906a72 --- /dev/null +++ b/ie.css @@ -0,0 +1,19 @@ +#Ecriture_onglet1 +{ + bottom: 75px; +} + +#Ecriture_onglet2 +{ + bottom: 122px; +} + +#Ecriture_onglet3 +{ + bottom: 170px; +} + +#Ecriture_onglet4 +{ + bottom: 217px; +} \ No newline at end of file diff --git a/ie8.php b/ie8.php new file mode 100644 index 0000000..bab0b1b --- /dev/null +++ b/ie8.php @@ -0,0 +1,19 @@ + + + + + + + + + + + Festiv'Algo - Navigateur obsolète + + + + Votre navigateur est obsolète et est incapable d'afficher correctement ce site (comme une majorité de sites).
+ Pour accéder à cette page, merci de le mettre à jour ici.

+ contact@festivalgo.fr + + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..673d003 --- /dev/null +++ b/index.php @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + Festiv'Algo - Programmer, exécuter et traduire des algorithmes pour toutes les calculatrices + + + + + +
+ + + + + + +
+ + + + Entrées/Sorties + Conditions + Boucles + Autres + + + + + + + + + + +

+

+

+

+

+

+

+

+ +

Cliquez sur l'une des icônes, puis sélectionnez une instruction.

+ +
+
+ +

Erreurs de syntaxe :

+
+ + + + + + + + + + +

+

+

+

+

^

+

π

+

e

+

ln

+ +
+

Exécution :

+
+
+
+ + + +
+
+

Variables :

+ +

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+
+ + Publier cet algorithme + +
+
+ + + \ No newline at end of file diff --git a/init.php b/init.php new file mode 100644 index 0000000..1d42a7e --- /dev/null +++ b/init.php @@ -0,0 +1,15 @@ +0) + { + $_SESSION['username'] = $_COOKIE['username']; + $_SESSION['userid'] = $dn_cnn['id']; + } +} +?> \ No newline at end of file diff --git a/interface.js b/interface.js new file mode 100644 index 0000000..beb6ded --- /dev/null +++ b/interface.js @@ -0,0 +1,592 @@ +var process = 0; +var pause = 0; +var reset = 0; +var lire_pending = 0; +var langage_avant_publier = 1; + +$(document).ready(function() { + var TIME = 600; + + var langage = 1; + var time = 0; + + var indices = [ + 0, 2, 6 , 12, + 20, 22, 26, 31, + 39, 41, 45, 48, + 56 + ]; + var instructions = [ + "Lire", "Afficher", "Si", "Alors", "Sinon", "Fin_Si", "Tant_que", "Fin_Tant_que", "Pour", "Allant_de", "à", "Fin_Pour", "Prend_la_valeur", "Hasard", "ET", "OU", "Partie_entière", "Partie_décimale", "Valeur_absolue", "Fin_programme", + "?", "∠", "If", "Then", "Else", "IfEnd", "While", "WhileEnd", "For", "To", "Next", "→", "#Ran", "and", "or", "Int", "Frac", "Abs", "Stop", + "Input", "Disp", "If", "Then", "Else", "End", "While", "For(", "End", "→", "rand", "and", "or", "int(", "fPart(", "abs(", "Stop" + ]; + + function affiche_conversion() { + $('#conversion_algo').show(); + $('#conversion_casio').show(); + $('#conversion_ti').show(); + if(langage == 1) + { + $('#conversion_algo').hide(); + $('#conversion_casio').css('bottom', '-70px').css('right', '264px'); + $('#conversion_ti').css('bottom', '-216px').css('right', '450px'); + } + else if(langage == 2) + { + $('#conversion_casio').hide(); + $('#conversion_ti').css('bottom', '-70px').css('right', '450px'); + $('#conversion_algo').css('bottom', '-216px').css('right', '264px'); + } + else if(langage == 3) + { + $('#conversion_ti').hide(); + $('#conversion_algo').css('bottom', '-70px').css('right', '264px'); + $('#conversion_casio').css('bottom', '-216px').css('right', '450px'); + } + } + + function hide_langage() { + $('.langage_actuel').hide(); + } + + function affiche_langage() { + hide_langage(); + if(langage == 1) + $('#langage_algo').show(); + if(langage == 2) + $('#langage_casio').show(); + if(langage == 3) + $('#langage_ti').show(); + + $('#info_contenu').replaceWith("Cliquez sur l'une des icônes, puis sélectionnez une instruction."); + } + + function changement_langage() { + var result; + + $('#conversion_algo').click(function(event) { + if(new Date().getTime() - time > TIME && process == 0) + { + $('#executer').unbind('click'); + time = new Date().getTime(); + process = 1; + result = traduction(langage, 1, 1); + if(result == "completed") + { + langage = 1; + langage_avant_publier = 1; + affiche_conversion(); + affiche_langage(); + } + process = 0; + boutons(); + $("#saisie").cleditor()[0].disable(false); + } + }); + $('#conversion_casio').click(function(event) { + if(new Date().getTime() - time > TIME && process == 0) + { + $('#executer').unbind('click'); + time = new Date().getTime(); + process = 1; + result = traduction(langage, 2, 1); + if(result == "completed") + { + langage = 2; + langage_avant_publier = 2; + affiche_conversion(); + affiche_langage(); + } + process = 0; + boutons(); + $("#saisie").cleditor()[0].disable(false); + } + }); + $('#conversion_ti').click(function(event) { + if(new Date().getTime() - time > TIME && process == 0) + { + $('#executer').unbind('click'); + time = new Date().getTime(); + process = 1; + result = traduction(langage, 3, 1); + if(result == "completed") + { + langage = 3; + langage_avant_publier = 3; + affiche_conversion(); + affiche_langage(); + } + process = 0; + boutons(); + $("#saisie").cleditor()[0].disable(false); + } + }); + } + + function init_boutons() { + $('#pause').hide(); + } + + function boutons() { + $('#executer').click(function() { + if(process == 0) + { + pause = 0; + process = 1; + reset = 0; + execution(langage, 0); + process = 0; + } + if(lire_pending == 1 && pause == 1) + { + $('#executer').hide(); + $('#pause').show(); + pause = 0; + document.getElementById("lire").focus(); + } + }); + $('#pause').click(function() { + $('#pause').hide(); + $('#executer').show(); + pause = 1; + }); + $('#reset').click(function() { + $('#pause').hide(); + $('#executer').show(); + reset = 1; + process = 0; + execution_init(); + $("#saisie").cleditor()[0].disable(false); + }); + } + + function signes() { + $('#signe1').click(function() { + addText(" ≥ "); + }); + $('#signe2').click(function() { + addText(" ≤ "); + }); + $('#signe3').click(function() { + addText(" ≠ "); + }); + $('#signe4').click(function() { + addText("Racine_Carrée("); + }); + $('#signe5').click(function() { + addText("^"); + }); + $('#signe6').click(function() { + addText("π"); + }); + $('#signe7').click(function() { + addText("exp("); + }); + $('#signe8').click(function() { + addText("ln"); + }); + } + + function addText(instext) { + /*var content = document.getElementById("saisie").value; + var saut = 0; + + if(content.lastIndexOf("
") != -1) + saut = 6; + if(content.lastIndexOf("
") != -1) + saut = 10; + + document.getElementById("saisie").value = content.substring(0, content.length - saut) + " " + instext; + + if(content.lastIndexOf("
") != -1) + document.getElementById("saisie").value += "
"; + + $("#saisie").cleditor()[0].updateFrame().focus();*/ + + if(navigator.appName=='Microsoft Internet Explorer'){ + var content = document.getElementById("saisie").value; + var saut = 0; + + if(content.lastIndexOf("
") != -1) + saut = 6; + if(content.lastIndexOf("
") != -1) + saut = 10; + + document.getElementById("saisie").value = content.substring(0, content.length - saut) + " " + instext; + + if(content.lastIndexOf("
") != -1) + document.getElementById("saisie").value += "
"; + + $("#saisie").cleditor()[0].updateFrame().focus(); + } + else + { + document.getElementById("main_iframe").blur(); + document.getElementById("main_iframe").contentWindow.document.execCommand("InsertHTML", false, instext); + document.getElementById("main_iframe").focus(); + } + } + + function menus_deroulants_init() { + $('.onglet_deroulant').hide(); + $('.instruction').hide(); + $('#selection').hide(); + } + + function menus_deroulants_show() { + $('.icone').mouseenter(function() { + var iconeNb, indice_pointeur, ongletNb; + var id = $(this).attr('id'); + + $('#selection').hide(); + + if(id == 'entrees-sorties') + iconeNb = 0; + if(id == 'conditions') + iconeNb = 1; + if(id == 'boucles') + iconeNb = 2; + if(id == 'autres') + iconeNb = 3; + + indice_pointeur = indices[(langage - 1) * 4 + iconeNb]; + ongletNb = indices[(langage - 1) * 4 + iconeNb + 1] - indice_pointeur; + + menus_deroulants_init(); + affiche_menu_deroulant(iconeNb, ongletNb, indice_pointeur); + selection(iconeNb, ongletNb, id, indice_pointeur); + menus_deroulants_hide(ongletNb, id); + }); + } + + function menus_deroulants_hide(ongletNb, id, indice_pointeur) { + $('#support_menus, .cleditorMain').mouseenter(function() { + menus_deroulants_init(); + }); + } + + function affiche_menu_deroulant(iconeNb, ongletNb, indice_pointeur) { + var i; + + $('.onglet_deroulant').css('left', 255 + 69 * iconeNb); + + for(i = 1; i <= ongletNb; i++) + { + $('#onglet_deroulant' + i).show(); + $('#instruction' + i).replaceWith("

" + instructions[indice_pointeur + i - 1] + "

"); + $('#instruction' + i).css('left', 261 + 69 * iconeNb).show(); + } + } + + function Valeur_top(valeur_top) { + var onglet_click = 0; + + switch(valeur_top) + { + case '-136px': + onglet_click = 1; + break; + case '-107px': + onglet_click = 2; + break; + case '-78px': + onglet_click = 3; + break; + case '-49px': + onglet_click = 4; + break; + case '-20px': + onglet_click = 5; + break; + case '9px': + onglet_click = 6; + break; + case '38px': + onglet_click = 7; + break; + case '67px': + onglet_click = 8; + break; + } + + return onglet_click; + } + + function selection(iconeNb, ongletNb, id, indice_pointeur) { + var i, valeur_top, onglet_click, text, syntaxe, test; + + for(i = 1; i <= ongletNb; i++) + { + $('#instruction' + i).mouseenter(function() { + valeur_top = $(this).css('top'); + onglet_click = Valeur_top(valeur_top); + + $('#selection').css('top', -155 + 29 * onglet_click) + .css('left', 255 + 69 * iconeNb) + .show(); + + text = instructions[indice_pointeur + onglet_click - 1]; + + switch(text) + { + case 'Lire': + syntaxe = "Lire variable"; + break; + + case 'Afficher': + syntaxe = "Afficher \"Mon texte\" (ou variable)"; + break; + + case 'Si': + syntaxe = "Si condition
Alors Instructions
(Sinon Instructions)
Fin_Si"; + break; + + case 'Tant_que': + syntaxe = "Tant_que condition
Instructions
Fin_Tant_que"; + break; + + case 'Fin_Tant_que': + syntaxe = "Tant_que condition
Instructions
Fin_Tant_que"; + break; + + case 'Pour': + syntaxe = "Pour variable Allant_de départ à arrivée
Instructions
Fin_Pour"; + break; + + case 'Prend_la_valeur': + syntaxe = "variable Prend_la_valeur valeur"; + break; + + case 'Hasard': + syntaxe = "Hasard((valeur maximale)"; + break; + + case 'ET': + syntaxe = "condition 1 ET condition 2"; + break; + + case 'OU': + syntaxe = "condition 1 OU condition 2"; + break; + + case 'Partie_entière': + syntaxe = "Partie_entière (valeur)"; + break; + + case 'Partie_décimale': + syntaxe = "Partie_décimale (valeur)"; + break; + + case 'Valeur_absolue': + syntaxe = "Valeur_absolue (valeur)"; + break; + + case 'Fin_programme': + syntaxe = "Fin_programme"; + break; + + case '?': + syntaxe = "? → variable"; + break; + + case '∠': + syntaxe = "\"Mon texte\" (ou variable)"; + break; + + case 'If': + syntaxe = "If condition
Then Instructions
(Else Instructions)
IfEnd"; + break; + + case 'While': + syntaxe = "While condition
Instructions
WhileEnd"; + break; + + case 'WhileEnd': + syntaxe = "While condition
Instructions
WhileEnd"; + break; + + case 'For': + syntaxe = "For départ→variable To arrivée
Instructions
Next"; + break; + + case '→': + syntaxe = "valeur variable"; + break; + + case 'rand': + syntaxe = "rand(valeur maximale)"; + break; + + case 'and': + syntaxe = "condition 1 and condition 2"; + break; + + case 'or': + syntaxe = "condition 1 or condition 2"; + break; + + case 'Int': + syntaxe = "Int(valeur)"; + break; + + case 'Frac': + syntaxe = "Frac(valeur)"; + break; + + case 'Abs': + syntaxe = "Abs(valeur)"; + break; + + case 'Stop': + syntaxe = "Stop"; + break; + + case 'Input': + syntaxe = "Input variable"; + break; + + case 'Disp': + syntaxe = "Disp \"Mon texte\" (ou variable)"; + break; + + case 'If': + syntaxe = "If condition
Then Instructions
(Else Instructions)
End"; + break; + + case 'While': + syntaxe = "While condition
Instructions
End"; + break; + + case 'For(': + syntaxe = "For(variable, départ, arrivée)
Instructions
End"; + break; + + case '#Ran': + syntaxe = "(valeur maximale)#Ran"; + break; + + case 'int(': + syntaxe = "int(valeur)"; + break; + + case 'fPart(': + syntaxe = "fPart(valeur)"; + break; + + case 'abs(': + syntaxe = "abs(valeur)"; + break; + } + + $('#info_contenu').replaceWith("

Syntaxe

" + "
" + syntaxe + "
"); + }); + } + $('.instruction').click(function() { + var num; + + valeur_top = $(this).css('top'); + menus_deroulants_init(id); + + onglet_click = Valeur_top(valeur_top); + + num = indice_pointeur + onglet_click - 1; + text = instructions[num]; + + if((num >= 16 && num <= 18) || num == 13 || (num >= 35 && num <= 37) || num == 49) + text += "()"; + if(num >= 52 && num <= 54) + text += ")"; + if(num == 32) + text = "()" + text; + + /*if(text == "∠") + text = "∠"; + if(text == "→") + text = "→";*/ + + addText(text + " "); + }); + } + + function default_code() + { + if((document.cookie.indexOf('exemple=') == -1 || readCookie('exemple') == "init") && document.cookie.indexOf('last_algo=') != -1 && document.cookie.indexOf('last_language=') != -1 && (readCookie('last_language') == 1 || readCookie('last_language') == 2 || readCookie('last_language') == 3)){ + langage = readCookie('last_language'); + + var t; + switch(langage) + { + case "1": t = 1; break; + case "2": t = 2; break; + case "3": t = 3; break; + } + langage = t; + + var code = unescape(readCookie('last_algo')); + + document.getElementById("saisie").value = code; + $("#saisie").cleditor()[0].updateFrame().focus(); + + affiche_conversion(); + affiche_langage(); + } + } + + $("#saisie").cleditor().focus(); // transforme le textarea en éditeur html + $('#debug').hide(); + $('#disable').hide(); + menus_deroulants_init(''); + affiche_langage(); + changement_langage(); + affiche_conversion(); + init_boutons(); + boutons(); + signes(); + menus_deroulants_show(); + copie_contenu(); + default_code(); + alert_mobile(); +}); + +function copie_contenu() { + $('#publier').click(function() { + var texte; + + if(langage_avant_publier == 1) + texte = document.getElementById('saisie').value; + else + texte = traduction(langage_avant_publier, 1, 0); + + while(texte.indexOf(";") != -1) + texte = texte.replace(";","@"); + createCookie("algorithme",texte,1); + }); +} + +function createCookie(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value; +} + +function readCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; +} + +function alert_mobile() { + if(/iPhone|iPod|Android|opera mini|blackberry|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine|iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce;iemobile/i.test(navigator.userAgent)){ + alert("Cette interface ne fonctionne pas encore sur mobile. Merci de vous procurer un ordinateur pour l'utiliser."); + } +} \ No newline at end of file diff --git a/jquery.cleditor.css b/jquery.cleditor.css new file mode 100644 index 0000000..ffb1fb1 --- /dev/null +++ b/jquery.cleditor.css @@ -0,0 +1,23 @@ +.cleditorMain iframe {border:none; margin:0; padding:0} +.cleditorMain textarea {border:none; margin:0; padding:0; overflow-y:scroll; font:10pt Arial,Verdana; resize:none; outline:none /* webkit grip focus */} +.cleditorToolbar {background: url('Images/toolbar.gif') repeat} +.cleditorGroup {float:left; height:26px} +.cleditorButton {float:left; width:24px; height:24px; margin:1px 0 1px 0; background: url('Images/buttons.gif')} +.cleditorDisabled {opacity:0.3; filter:alpha(opacity=30)} +.cleditorDivider {float:left; width:1px; height:23px; margin:1px 0 1px 0; background:#CCC} +.cleditorPopup {border:solid 1px #999; background-color:white; position:absolute; font:10pt Arial,Verdana; cursor:default; z-index:10000} +.cleditorList div {padding:2px 4px 2px 4px} +.cleditorList p, +.cleditorList h1, +.cleditorList h2, +.cleditorList h3, +.cleditorList h4, +.cleditorList h5, +.cleditorList h6, +.cleditorList font {padding:0; margin:0; background-color:Transparent} +.cleditorColor {width:150px; padding:1px 0 0 1px} +.cleditorColor div {float:left; width:14px; height:14px; margin:0 1px 1px 0} +.cleditorPrompt {background-color:#F6F7F9; padding:4px; font-size:8.5pt} +.cleditorPrompt input, +.cleditorPrompt textarea {font:8.5pt Arial,Verdana;} +.cleditorMsg {background-color:#FDFCEE; width:150px; padding:4px; font-size:8.5pt} diff --git a/jquery.cleditor.js b/jquery.cleditor.js new file mode 100644 index 0000000..546704b --- /dev/null +++ b/jquery.cleditor.js @@ -0,0 +1,1136 @@ +/** + @preserve CLEditor WYSIWYG HTML Editor v1.3.0 + http://premiumsoftware.net/cleditor + requires jQuery v1.4.2 or later + + Copyright 2010, Chris Landowski, Premium Software, LLC + Dual licensed under the MIT or GPL Version 2 licenses. +*/ + +// ==ClosureCompiler== +// @compilation_level SIMPLE_OPTIMIZATIONS +// @output_file_name jquery.cleditor.min.js +// ==/ClosureCompiler== + +var the_editor; + +function showCaretPos() { + document.getElementById("main_iframe").contentWindow.document.execCommand("InsertHTML", false, "
test
"); + document.getElementById("main_iframe").focus(); + + /*var el = document.getElementById("main_iframe").contentDocument.body.firstChild; + + var pos = the_editor.$frame[0].contentWindow.getSelection().getRangeAt(0).endOffset; + + var elem = the_editor.$frame[0].contentWindow.getSelection().getRangeAt(0); + //elem.setStart(el, 20); + + elem.setStart(el, 10); + elem.setEnd(el, 10); + + sel.removeRange(elem); + sel.addRange(range);*/ +} + +$.cleditor = { + + // Define the defaults used for all new cleditor instances + defaultOptions: { + width: 349, // width not including margins, borders or padding + height: 314, // height not including margins, borders or padding + controls: // controls to add to the toolbar + "undo redo | print", + useCSS: false, // use CSS to style HTML when possible (not supported in ie) + docType: // Document type contained within the editor + '', + docCSSFile: // CSS file used to style the document contained within the editor + "", + bodyStyle: // style to assign to document body contained within the editor + "margin:4px; font:10pt Arial,Verdana; cursor:text" + }, + + // Define all usable toolbar buttons - the init string property is + // expanded during initialization back into the buttons object and + // seperate object properties are created for each button. + // e.g. buttons.size.title = "Font Size" + buttons: { + // name,title,command,popupName (""=use name) + init: + "bold,,|" + + "italic,,|" + + "underline,,|" + + "strikethrough,,|" + + "subscript,,|" + + "superscript,,|" + + "font,,fontname,|" + + "size,Font Size,fontsize,|" + + "style,,formatblock,|" + + "color,Font Color,forecolor,|" + + "highlight,Text Highlight Color,hilitecolor,color|" + + "removeformat,Remove Formatting,|" + + "bullets,,insertunorderedlist|" + + "numbering,,insertorderedlist|" + + "outdent,Désindenter,|" + + "indent,Indenter,|" + + "alignleft,Align Text Left,justifyleft|" + + "center,,justifycenter|" + + "alignright,Align Text Right,justifyright|" + + "justify,,justifyfull|" + + "undo,Annuler,|" + + "redo,Rétablir,|" + + "rule,Insérer une ligne horizontale,inserthorizontalrule|" + + "image,Insert Image,insertimage,url|" + + "link,Insert Hyperlink,createlink,url|" + + "unlink,Remove Hyperlink,|" + + "cut,Couper,|" + + "copy,Copier,|" + + "paste,Coller,|" + + "pastetext,Insérer du texte,inserthtml,|" + + "print,Imprimer,|" + + "source,Show Source" + }, + + // imagesPath - returns the path to the images folder + imagesPath: function() { return imagesPath(); } + +}; + +(function($) { + + //============== + // jQuery Plugin + //============== + + // cleditor - creates a new editor for each of the matched textareas + $.fn.cleditor = function(options) { + + // Create a new jQuery object to hold the results + var $result = $([]); + + // Loop through all matching textareas and create the editors + this.each(function(idx, elem) { + if (elem.tagName == "TEXTAREA") { + var data = $.data(elem, CLEDITOR); + if (!data) data = new cleditor(elem, options); + $result = $result.add(data); + } + }); + + // return the new jQuery object + return $result; + + }; + + //================== + // Private Variables + //================== + + var + + // Misc constants + BACKGROUND_COLOR = "backgroundColor", + BUTTON = "button", + BUTTON_NAME = "buttonName", + CHANGE = "change", + CLEDITOR = "cleditor", + CLICK = "click", + DISABLED = "disabled", + DIV_TAG = "
", + TRANSPARENT = "transparent", + UNSELECTABLE = "unselectable", + + // Class name constants + MAIN_CLASS = "cleditorMain", // main containing div + TOOLBAR_CLASS = "cleditorToolbar", // toolbar div inside main div + GROUP_CLASS = "cleditorGroup", // group divs inside the toolbar div + BUTTON_CLASS = "cleditorButton", // button divs inside group div + DISABLED_CLASS = "cleditorDisabled",// disabled button divs + DIVIDER_CLASS = "cleditorDivider", // divider divs inside group div + POPUP_CLASS = "cleditorPopup", // popup divs inside body + LIST_CLASS = "cleditorList", // list popup divs inside body + COLOR_CLASS = "cleditorColor", // color popup div inside body + PROMPT_CLASS = "cleditorPrompt", // prompt popup divs inside body + MSG_CLASS = "cleditorMsg", // message popup div inside body + + // Test for ie + ie = $.browser.msie, + ie6 = /msie\s6/i.test(navigator.userAgent), + + // Test for iPhone/iTouch/iPad + iOS = /iphone|ipad|ipod/i.test(navigator.userAgent), + + // Popups are created once as needed and shared by all editor instances + popups = {}, + + // Used to prevent the document click event from being bound more than once + documentClickAssigned, + + // Local copy of the buttons object + buttons = $.cleditor.buttons; + + //=============== + // Initialization + //=============== + + // Expand the buttons.init string back into the buttons object + // and create seperate object properties for each button. + // e.g. buttons.size.title = "Font Size" + $.each(buttons.init.split("|"), function(idx, button) { + var items = button.split(","), name = items[0]; + buttons[name] = { + stripIndex: idx, + name: name, + title: items[1] === "" ? name.charAt(0).toUpperCase() + name.substr(1) : items[1], + command: items[2] === "" ? name : items[2], + popupName: items[3] === "" ? name : items[3] + }; + }); + delete buttons.init; + + //============ + // Constructor + //============ + + // cleditor - creates a new editor for the passed in textarea element + cleditor = function(area, options) { + + var editor = this; + the_editor = editor; + + // Get the defaults and override with options + editor.options = options = $.extend({}, $.cleditor.defaultOptions, options); + + // Hide the textarea and associate it with this editor + var $area = editor.$area = $(area) + .hide() + .data(CLEDITOR, editor) + .blur(function() { + // Update the iframe when the textarea loses focus + updateFrame(editor, true); + }); + + // Create the main container and append the textarea + var $main = editor.$main = $(DIV_TAG) + .addClass(MAIN_CLASS) + .width(options.width) + .height(options.height); + + // Create the toolbar + var $toolbar = editor.$toolbar = $(DIV_TAG) + .addClass(TOOLBAR_CLASS) + .appendTo($main); + + // Add the first group to the toolbar + var $group = $(DIV_TAG) + .addClass(GROUP_CLASS) + .appendTo($toolbar); + + // Add the buttons to the toolbar + $.each(options.controls.split(" "), function(idx, buttonName) { + if (buttonName === "") return true; + + // Divider + if (buttonName == "|") { + + // Add a new divider to the group + var $div = $(DIV_TAG) + .addClass(DIVIDER_CLASS) + .appendTo($group); + + // Create a new group + $group = $(DIV_TAG) + .addClass(GROUP_CLASS) + .appendTo($toolbar); + + } + + // Button + else { + + // Get the button definition + var button = buttons[buttonName]; + + // Add a new button to the group + var $buttonDiv = $(DIV_TAG) + .data(BUTTON_NAME, button.name) + .addClass(BUTTON_CLASS) + .attr("title", button.title) + .bind(CLICK, $.proxy(buttonClick, editor)) + .appendTo($group) + .hover(hoverEnter, hoverLeave); + + // Prepare the button image + var map = {}; + if (button.css) map = button.css; + else if (button.image) map.backgroundImage = imageUrl(button.image); + if (button.stripIndex) map.backgroundPosition = button.stripIndex * -24; + $buttonDiv.css(map); + + // Add the unselectable attribute for ie + if (ie) + $buttonDiv.attr(UNSELECTABLE, "on"); + + // Create the popup + if (button.popupName) + createPopup(button.popupName, options, button.popupClass, + button.popupContent, button.popupHover); + + } + + }); + + // Add the main div to the DOM and append the textarea + $main.insertBefore($area) + .append($area); + + // Bind the document click event handler + if (!documentClickAssigned) { + $(document).click(function(e) { + // Dismiss all non-prompt popups + var $target = $(e.target); + if (!$target.add($target.parents()).is("." + PROMPT_CLASS)) + hidePopups(); + }); + documentClickAssigned = true; + } + + // Bind the window resize event when the width or height is auto or % + if (/auto|%/.test("" + options.width + options.height)) + $(window).resize(function() {refresh(editor);}); + + // Create the iframe and resize the controls + refresh(editor); + + }; + + //=============== + // Public Methods + //=============== + + var fn = cleditor.prototype, + + // Expose the following private functions as methods on the cleditor object. + // The closure compiler will rename the private functions. However, the + // exposed method names on the cleditor object will remain fixed. + methods = [ + ["clear", clear], + ["disable", disable], + ["execCommand", execCommand], + ["focus", focus], + ["hidePopups", hidePopups], + ["sourceMode", sourceMode, true], + ["refresh", refresh], + ["select", select], + ["selectedHTML", selectedHTML, true], + ["selectedText", selectedText, true], + ["showMessage", showMessage], + ["updateFrame", updateFrame], + ["updateTextArea", updateTextArea] + ]; + + $.each(methods, function(idx, method) { + fn[method[0]] = function() { + var editor = this, args = [editor]; + // using each here would cast booleans into objects! + for(var x = 0; x < arguments.length; x++) {args.push(arguments[x]);} + var result = method[1].apply(editor, args); + if (method[2]) return result; + return editor; + }; + }); + + // change - shortcut for .bind("change", handler) or .trigger("change") + fn.change = function(handler) { + var $this = $(this); + return handler ? $this.bind(CHANGE, handler) : $this.trigger(CHANGE); + }; + + //=============== + // Event Handlers + //=============== + + // buttonClick - click event handler for toolbar buttons + function buttonClick(e) { + + var editor = this, + buttonDiv = e.target, + buttonName = $.data(buttonDiv, BUTTON_NAME), + button = buttons[buttonName], + popupName = button.popupName, + popup = popups[popupName]; + + // Check if disabled + if (editor.disabled || $(buttonDiv).attr(DISABLED) == DISABLED) + return; + + // Fire the buttonClick event + var data = { + editor: editor, + button: buttonDiv, + buttonName: buttonName, + popup: popup, + popupName: popupName, + command: button.command, + useCSS: editor.options.useCSS + }; + + if (button.buttonClick && button.buttonClick(e, data) === false) + return false; + + // Toggle source + if (buttonName == "source") { + + // Show the iframe + if (sourceMode(editor)) { + delete editor.range; + editor.$area.hide(); + editor.$frame.show(); + buttonDiv.title = button.title; + } + + // Show the textarea + else { + editor.$frame.hide(); + editor.$area.show(); + buttonDiv.title = "Show Rich Text"; + } + + // Enable or disable the toolbar buttons + // IE requires the timeout + setTimeout(function() {refreshButtons(editor);}, 100); + + } + + // Check for rich text mode + else if (!sourceMode(editor)) { + + // Handle popups + if (popupName) { + var $popup = $(popup); + + // URL + if (popupName == "url") { + + // Check for selection before showing the link url popup + if (buttonName == "link" && selectedText(editor) === "") { + showMessage(editor, "A selection is required when inserting a link.", buttonDiv); + return false; + } + + // Wire up the submit button click event handler + $popup.children(":button") + .unbind(CLICK) + .bind(CLICK, function() { + + // Insert the image or link if a url was entered + var $text = $popup.find(":text"), + url = $.trim($text.val()); + if (url !== "") + execCommand(editor, data.command, url, null, data.button); + + // Reset the text, hide the popup and set focus + $text.val("http://"); + hidePopups(); + focus(editor); + + }); + + } + + // Paste as Text + else if (popupName == "pastetext") { + + // Wire up the submit button click event handler + $popup.children(":button") + .unbind(CLICK) + .bind(CLICK, function() { + + // Insert the unformatted text replacing new lines with break tags + var $textarea = $popup.find("textarea"), + text = $textarea.val().replace(/\n/g, "
"); + if (text !== "") + execCommand(editor, data.command, text, null, data.button); + + // Reset the text, hide the popup and set focus + $textarea.val(""); + hidePopups(); + focus(editor); + + }); + + } + + // Show the popup if not already showing for this button + if (buttonDiv !== $.data(popup, BUTTON)) { + showPopup(editor, popup, buttonDiv); + return false; // stop propagination to document click + } + + // propaginate to documnt click + return; + + } + + // Print + else if (buttonName == "print") + editor.$frame[0].contentWindow.print(); + + // All other buttons + else if (!execCommand(editor, data.command, data.value, data.useCSS, buttonDiv)) + return false; + + } + + // Focus the editor + focus(editor); + + } + + // hoverEnter - mouseenter event handler for buttons and popup items + function hoverEnter(e) { + var $div = $(e.target).closest("div"); + $div.css(BACKGROUND_COLOR, $div.data(BUTTON_NAME) ? "#FFF" : "#FFC"); + } + + // hoverLeave - mouseleave event handler for buttons and popup items + function hoverLeave(e) { + $(e.target).closest("div").css(BACKGROUND_COLOR, "transparent"); + } + + // popupClick - click event handler for popup items + function popupClick(e) { + + var editor = this, + popup = e.data.popup, + target = e.target; + + // Check for message and prompt popups + if (popup === popups.msg || $(popup).hasClass(PROMPT_CLASS)) + return; + + // Get the button info + var buttonDiv = $.data(popup, BUTTON), + buttonName = $.data(buttonDiv, BUTTON_NAME), + button = buttons[buttonName], + command = button.command, + value, + useCSS = editor.options.useCSS; + + // Get the command value + if (buttonName == "font") + // Opera returns the fontfamily wrapped in quotes + value = target.style.fontFamily.replace(/"/g, ""); + else if (buttonName == "size") { + if (target.tagName == "DIV") + target = target.children[0]; + value = target.innerHTML; + } + else if (buttonName == "style") + value = "<" + target.tagName + ">"; + else if (buttonName == "color") + value = hex(target.style.backgroundColor); + else if (buttonName == "highlight") { + value = hex(target.style.backgroundColor); + if (ie) command = 'backcolor'; + else useCSS = true; + } + + // Fire the popupClick event + var data = { + editor: editor, + button: buttonDiv, + buttonName: buttonName, + popup: popup, + popupName: button.popupName, + command: command, + value: value, + useCSS: useCSS + }; + + if (button.popupClick && button.popupClick(e, data) === false) + return; + + // Execute the command + if (data.command && !execCommand(editor, data.command, data.value, data.useCSS, buttonDiv)) + return false; + + // Hide the popup and focus the editor + hidePopups(); + focus(editor); + + } + + //================== + // Private Functions + //================== + + // checksum - returns a checksum using the Adler-32 method + function checksum(text) + { + var a = 1, b = 0; + for (var index = 0; index < text.length; ++index) { + a = (a + text.charCodeAt(index)) % 65521; + b = (b + a) % 65521; + } + return (b << 16) | a; + } + + // clear - clears the contents of the editor + function clear(editor) { + editor.$area.val(""); + updateFrame(editor); + } + + // createPopup - creates a popup and adds it to the body + function createPopup(popupName, options, popupTypeClass, popupContent, popupHover) { + + // Check if popup already exists + if (popups[popupName]) + return popups[popupName]; + + // Create the popup + var $popup = $(DIV_TAG) + .hide() + .addClass(POPUP_CLASS) + .appendTo("body"); + + // Add the content + + // Custom popup + if (popupContent) + $popup.html(popupContent); + + // Color + else if (popupName == "color") { + var colors = options.colors.split(" "); + if (colors.length < 10) + $popup.width("auto"); + $.each(colors, function(idx, color) { + $(DIV_TAG).appendTo($popup) + .css(BACKGROUND_COLOR, "#" + color); + }); + popupTypeClass = COLOR_CLASS; + } + + // Font + else if (popupName == "font") + $.each(options.fonts.split(","), function(idx, font) { + $(DIV_TAG).appendTo($popup) + .css("fontFamily", font) + .html(font); + }); + + // Size + else if (popupName == "size") + $.each(options.sizes.split(","), function(idx, size) { + $(DIV_TAG).appendTo($popup) + .html("" + size + ""); + }); + + // Style + else if (popupName == "style") + $.each(options.styles, function(idx, style) { + $(DIV_TAG).appendTo($popup) + .html(style[1] + style[0] + style[1].replace("<", "
'); + popupTypeClass = PROMPT_CLASS; + } + + // Paste as Text + else if (popupName == "pastetext") { + $popup.html('Paste your content here and click submit.

'); + popupTypeClass = PROMPT_CLASS; + } + + // Add the popup type class name + if (!popupTypeClass && !popupContent) + popupTypeClass = LIST_CLASS; + $popup.addClass(popupTypeClass); + + // Add the unselectable attribute to all items + if (ie) { + $popup.attr(UNSELECTABLE, "on") + .find("div,font,p,h1,h2,h3,h4,h5,h6") + .attr(UNSELECTABLE, "on"); + } + + // Add the hover effect to all items + if ($popup.hasClass(LIST_CLASS) || popupHover === true) + $popup.children().hover(hoverEnter, hoverLeave); + + // Add the popup to the array and return it + popups[popupName] = $popup[0]; + return $popup[0]; + + } + + // disable - enables or disables the editor + function disable(editor, disabled) { + + // Update the textarea and save the state + if (disabled) { + editor.$area.attr(DISABLED, DISABLED); + editor.disabled = true; + $('#disable').show(); + } + else { + editor.$area.removeAttr(DISABLED); + delete editor.disabled; + $('#disable').hide(); + } + + // Switch the iframe into design mode. + // ie6 does not support designMode. + // ie7 & ie8 do not properly support designMode="off". + try { + if (ie) editor.doc.body.contentEditable = !disabled; + else editor.doc.designMode = !disabled ? "on" : "off"; + } + // Firefox 1.5 throws an exception that can be ignored + // when toggling designMode from off to on. + catch (err) {} + + // Enable or disable the toolbar buttons + refreshButtons(editor); + + } + + // execCommand - executes a designMode command + function execCommand(editor, command, value, useCSS, button) { + + // Restore the current ie selection + restoreRange(editor); + + // Set the styling method + if (!ie) { + if (useCSS === undefined || useCSS === null) + useCSS = editor.options.useCSS; + editor.doc.execCommand("styleWithCSS", 0, useCSS.toString()); + } + + // Execute the command and check for error + var success = true, description; + if (ie && command.toLowerCase() == "inserthtml") + getRange(editor).pasteHTML(value); + else { + try { success = editor.doc.execCommand(command, 0, value || null); } + catch (err) { description = err.description; success = false; } + if (!success) { + if ("cutcopypaste".indexOf(command) > -1) + showMessage(editor, "For security reasons, your browser does not support the " + + command + " command. Try using the keyboard shortcut or context menu instead.", + button); + else + showMessage(editor, + (description ? description : "Error executing the " + command + " command."), + button); + } + } + + // Enable the buttons + refreshButtons(editor); + return success; + + } + + // focus - sets focus to either the textarea or iframe + function focus(editor) { + setTimeout(function() { + if (sourceMode(editor)) editor.$area.focus(); + else editor.$frame[0].contentWindow.focus(); + //trol + refreshButtons(editor); + }, 0); + } + + // getRange - gets the current text range object + function getRange(editor) { + if (ie) return getSelection(editor).createRange(); + return getSelection(editor).getRangeAt(0); + } + + // getSelection - gets the current text range object + function getSelection(editor) { + if (ie) return editor.doc.selection; + return editor.$frame[0].contentWindow.getSelection(); + } + + // Returns the hex value for the passed in string. + // hex("rgb(255, 0, 0)"); // #FF0000 + // hex("#FF0000"); // #FF0000 + // hex("#F00"); // #FF0000 + function hex(s) { + var m = /rgba?\((\d+), (\d+), (\d+)/.exec(s), + c = s.split(""); + if (m) { + s = ( m[1] << 16 | m[2] << 8 | m[3] ).toString(16); + while (s.length < 6) + s = "0" + s; + } + return "#" + (s.length == 6 ? s : c[1] + c[1] + c[2] + c[2] + c[3] + c[3]); + } + + // hidePopups - hides all popups + function hidePopups() { + $.each(popups, function(idx, popup) { + $(popup) + .hide() + .unbind(CLICK) + .removeData(BUTTON); + }); + } + + // imagesPath - returns the path to the images folder + function imagesPath() { + var cssFile = "jquery.cleditor.css", + href = $("link[href$='" + cssFile +"']").attr("href"); + return href.substr(0, href.length - cssFile.length) + "images/"; + } + + // imageUrl - Returns the css url string for a filemane + function imageUrl(filename) { + return "url(" + imagesPath() + filename + ")"; + } + + // refresh - creates the iframe and resizes the controls + function refresh(editor) { + + var $main = editor.$main, + options = editor.options; + + // Remove the old iframe + if (editor.$frame) + editor.$frame.remove(); + + // Create a new iframe + var $frame = editor.$frame = $('
+ + + '; +} + + + + +/** + * A ReCaptchaResponse is returned from recaptcha_check_answer() + */ +class ReCaptchaResponse { + var $is_valid; + var $error; +} + + +/** + * Calls an HTTP POST function to verify if the user's guess was correct + * @param string $privkey + * @param string $remoteip + * @param string $challenge + * @param string $response + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ +function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) +{ + if ($privkey == null || $privkey == '') { + die ("To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create"); + } + + if ($remoteip == null || $remoteip == '') { + die ("For security reasons, you must pass the remote ip to reCAPTCHA"); + } + + + + //discard spam submissions + if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { + $recaptcha_response = new ReCaptchaResponse(); + $recaptcha_response->is_valid = false; + $recaptcha_response->error = 'incorrect-captcha-sol'; + return $recaptcha_response; + } + + $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", + array ( + 'privatekey' => $privkey, + 'remoteip' => $remoteip, + 'challenge' => $challenge, + 'response' => $response + ) + $extra_params + ); + + $answers = explode ("\n", $response [1]); + $recaptcha_response = new ReCaptchaResponse(); + + if (trim ($answers [0]) == 'true') { + $recaptcha_response->is_valid = true; + } + else { + $recaptcha_response->is_valid = false; + $recaptcha_response->error = $answers [1]; + } + return $recaptcha_response; + +} + +/** + * gets a URL where the user can sign up for reCAPTCHA. If your application + * has a configuration page where you enter a key, you should provide a link + * using this function. + * @param string $domain The domain where the page is hosted + * @param string $appname The name of your application + */ +function recaptcha_get_signup_url ($domain = null, $appname = null) { + return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname)); +} + +function _recaptcha_aes_pad($val) { + $block_size = 16; + $numpad = $block_size - (strlen ($val) % $block_size); + return str_pad($val, strlen ($val) + $numpad, chr($numpad)); +} + +/* Mailhide related code */ + +function _recaptcha_aes_encrypt($val,$ky) { + if (! function_exists ("mcrypt_encrypt")) { + die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); + } + $mode=MCRYPT_MODE_CBC; + $enc=MCRYPT_RIJNDAEL_128; + $val=_recaptcha_aes_pad($val); + return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); +} + + +function _recaptcha_mailhide_urlbase64 ($x) { + return strtr(base64_encode ($x), '+/', '-_'); +} + +/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ +function recaptcha_mailhide_url($pubkey, $privkey, $email) { + if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { + die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . + "you can do so at http://www.google.com/recaptcha/mailhide/apikey"); + } + + + $ky = pack('H*', $privkey); + $cryptmail = _recaptcha_aes_encrypt ($email, $ky); + + return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); +} + +/** + * gets the parts of the email to expose to the user. + * eg, given johndoe@example,com return ["john", "example.com"]. + * the email is then displayed as john...@example.com + */ +function _recaptcha_mailhide_email_parts ($email) { + $arr = preg_split("/@/", $email ); + + if (strlen ($arr[0]) <= 4) { + $arr[0] = substr ($arr[0], 0, 1); + } else if (strlen ($arr[0]) <= 6) { + $arr[0] = substr ($arr[0], 0, 3); + } else { + $arr[0] = substr ($arr[0], 0, 4); + } + return $arr; +} + +/** + * Gets html to display an email address given a public an private key. + * to get a key, go to: + * + * http://www.google.com/recaptcha/mailhide/apikey + */ +function recaptcha_mailhide_html($pubkey, $privkey, $email) { + $emailparts = _recaptcha_mailhide_email_parts ($email); + $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); + + return htmlentities($emailparts[0]) . "...@" . htmlentities ($emailparts [1]); + +} + + +?> diff --git a/refus_publication.php b/refus_publication.php new file mode 100644 index 0000000..29566ce --- /dev/null +++ b/refus_publication.php @@ -0,0 +1,3 @@ +
+Mot de passe +
\ No newline at end of file diff --git a/safari.js b/safari.js new file mode 100644 index 0000000..c21ea78 --- /dev/null +++ b/safari.js @@ -0,0 +1,3 @@ +$(document).ready(function() { + $('.Ecriture_onglet').css('top', '204px'); +}) \ No newline at end of file diff --git a/scene_en_chantier/KITCHENPOLICE.TTF b/scene_en_chantier/KITCHENPOLICE.TTF new file mode 100644 index 0000000..0385881 Binary files /dev/null and b/scene_en_chantier/KITCHENPOLICE.TTF differ diff --git a/scene_en_chantier/style.css b/scene_en_chantier/style.css new file mode 100644 index 0000000..9f17a1a --- /dev/null +++ b/scene_en_chantier/style.css @@ -0,0 +1,6 @@ + + + Untitled + +
@font-face {
font-family: 'titre';
src: url('/festivalgo/scene_en_chantier/KITCHENPOLICE.TTF');
}

+ diff --git a/signup.php b/signup.php new file mode 100644 index 0000000..b42076c --- /dev/null +++ b/signup.php @@ -0,0 +1,144 @@ + + + + + + + + + + + Festiv'Algo - Inscription + + +
+ +is_valid) { + // What happens when the CAPTCHA was entered incorrectly + $form = true; + $message = 'Votre réponse au test anti-spam est incorrecte.'; + } else { + // Your code here to handle a successful verification + + //On enleve lechappement si get_magic_quotes_gpc est active + if(get_magic_quotes_gpc()) + { + $_POST['username'] = stripslashes($_POST['username']); + $_POST['password'] = stripslashes($_POST['password']); + $_POST['passverif'] = stripslashes($_POST['passverif']); + $_POST['email'] = stripslashes($_POST['email']); + } + if($_POST['password']==$_POST['passverif']) + { + if(strlen($_POST['password'])>=6) + { + if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email'])) + { + $username = mysql_real_escape_string($_POST['username']); + $password = mysql_real_escape_string($_POST['password']); + $email = mysql_real_escape_string($_POST['email']); + $dn = mysql_num_rows(mysql_query('select id from users where username="'.$username.'"')); + if($dn==0) + { + $dn2 = mysql_num_rows(mysql_query('select id from users')); + $id = $dn2+1; + //On enregistre les informations dans la base de donnee + if(mysql_query('insert into users(id, username, password, email, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.time().'")')) + { + $form = false; + + //echo ''; + echo '
Inscription effectuée avec succès !
Vous pouvez désormais vous connecter sur le forum
'; + + } + else + { + $form = true; + $message = 'Une erreur est survenue lors de l\'inscription.'; + } + } + else + { + $form = true; + $message = 'Un autre utilisateur utilise déjà ce nom.'; + } + } + else + { + $form = true; + $message = 'L\'adresse mail que vous avez entrée n\'est pas valide.'; + } + } + else + { + $form = true; + $message = 'Votre mot de passe contient moins de 6 caractères.'; + } + } + else + { + $form = true; + $message = 'Vos mots de passe ne sont pas identiques.'; + } + } +} +else +{ + $form = true; +} +if($form) +{ + if(isset($message)) + { + echo '
'.$message.'
'; + } + //On affiche le formulaire +?> +
+
+
+ Index du forum > Inscription +
+ +
+
+
+

Festiv'Algo est un site entièrement gratuit et sécurisé.
Il ne divulguera pas votre adresse mail et vos données personnelles.

+
+
+
+
+
+ +
+ ".recaptcha_get_html($publickey)."
"; + ?> +
+
+ +
+ +
+ + + \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..7fcab94 --- /dev/null +++ b/style.css @@ -0,0 +1,268 @@ +/*****************************************************/ +/****General****/ +/** +{ + margin:0px; + padding:0px; +}*/ + +a +{ + text-decoration:none; + color:#333333; +} +a:hover +{ + color:#000000; +} +img, table, tr, td +{ + border:0px; +} +h1 +{ + text-align:center; + margin:0px; + padding:0px; +} +.clean +{ + clear:both; +} +.left +{ + text-align:left; +} +.center +{ + text-align:center; +} +input[type=text], input[type=submit], input[type=button], input[type=password] +{ + width:150px; +} +input[type=submit] +{ + margin-top: 10px; +} +label +{ + width: 200px; + display: inline-block; + vertical-align: top; + text-align: left; + margin-bottom: 8px; +} +#se_souvenir +{ + width: 351px; +} +.message_buttons input +{ + width:auto; + padding:0px 5px; +} +.button +{ + padding:5px 15px; + vertical-align:middle; + border:1px solid #aaaaaa; + font-weight:bold; + background:url('Images/button.png') repeat-x; + -moz-border-radius:6px; + -webkit-border-radius:6px; + border-radius:6px; + display:inline-block; +} + +#content table +{ + border-spacing:0px; + background:#ffffff; + padding:0px; + width:95%; + margin:5px auto 18px auto; + background-color: rgb(241, 189, 23); + border: solid; + border-width: 4px; + border-radius: 10px; + border-color: rgb(233, 153, 10); +} +tr +{ + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; + margin:0px; +} +td, th +{ + margin:0px; + border:0px; + padding:3px; + text-align:center; +} +/*****************************************************/ +/****Blocks****/ +.header +{ + margin:auto; + margin-top:10px; + padding:15px; + background:url('Images/bluec_30p.png'); + width:60%; + -moz-border-radius:20px; + -webkit-border-radius:20px; + border-radius:20px; + text-align:center; +} +.foot +{ + text-align:center; + background:url('Images/bluec_30p.png'); + width:60%; + -moz-border-radius:15px; + -webkit-border-radius:15px; + border-radius:15px; + padding:10px; + margin:20px auto; +} +.content +{ + background-color: #FFD745; + border: solid; + border-width: 4px; + border-color: #FAC801; + font-family: Normal, Arial; + margin-left: 45px; + margin-right: 45px; + border-radius:20px; + padding:20px; + margin-top:10px; +} +.box_left +{ + float:left; +} +.box_right +{ + float:right; +} +.box +{ + border: solid; + border-width: 4px; + border-radius: 10px; + border-color: #FAC801; + margin:5px auto 30px auto; + padding: 5px 10px 5px 10px; +} +.login +{ + width:355px; + margin:auto; + text-align:left; +} +.box_login +{ + background-color: rgb(250, 184, 43); + border: solid; + border-width: 4px; + border-color: rgb(247, 154, 14); + width:360px; + -moz-border-radius:10px; + -webkit-border-radius:10px; + border-radius:10px; + margin:auto; + padding:20px; + margin-top:20px; + margin-bottom: 38px; + color:#ffffff; +} +/*****************************************************/ +/****Content****/ + +.champs +{ + margin-bottom: 8px; +} + +#memorize +{ + position: absolute; + top: 419px; + left: 510px; +} + +.big +{ + font-size:1.2em; +} +.small +{ + font-size:0.7em; +} +.message +{ + -moz-border-radius:20px; + -webkit-border-radius:20px; + border-radius:20px; + padding:20px; + margin:auto; + width:500px; + background:url('Images/black_40p.png'); + color:#ffffff; + text-align:center; + font-weight:bold; + margin-top:20px; +} +.messages_table td +{ + border-top:1px solid #cccccc; + vertical-align:top; +} +.author +{ + width:150px; + border-right:1px solid #cccccc; +} +.title_cell +{ + width:45%; +} +.date +{ + font-style:italic; + text-align:right; + font-size:0.9em; + margin-right:10px; +} +.edit +{ + float:left; +} +.forum_ntop, .forum_nrep, .forum_act, .forum_auth +{ + width:100px; +} +td.forum_cat, td.forum_tops +{ + padding-left:15px; + text-align:left; +} +.categories_table td, .categories_table th, .topics_table td, .topics_table th, .list_pm td, .list_pm th +{ + border-bottom:1px solid #cccccc; +} +.categories_table tr:last-child td, .topics_table tr:last-child td, .list_pm tr:last-child td +{ + border-bottom:0px; +} +td.forum_cat .title +{ + font-weight:bold; +} +td.forum_cat .description +{ + padding-left:5px; +} diff --git a/stylesheet.css b/stylesheet.css new file mode 100644 index 0000000..ec2274d --- /dev/null +++ b/stylesheet.css @@ -0,0 +1,737 @@ +/*---------Tlchargement des polices---------*/ + +@font-face { + font-family: 'Normal'; + src: url('Polices/Crete_Round/CreteRound-Regular-webfont.eot'); + src: url('Polices/Crete_Round/CreteRound-Regular-webfont.eot?#iefix') format('embedded-opentype'), + url('Polices/Crete_Round/CreteRound-Regular-webfont.woff') format('woff'), + url('Polices/Crete_Round/CreteRound-Regular-webfont.ttf') format('truetype'), + url('Polices/Crete_Round/CreteRound-Regular-webfont.svg#CreteRoundRegular') format('svg'); + font-weight: normal; + font-style: normal; + +} + +@font-face { + font-family: 'Italic'; + src: url('Polices/Crete_Round/CreteRound-Italic-webfont.eot'); + src: url('Polices/Crete_Round/CreteRound-Italic-webfont.eot?#iefix') format('embedded-opentype'), + url('Polices/Crete_Round/CreteRound-Italic-webfont.woff') format('woff'), + url('Polices/Crete_Round/CreteRound-Italic-webfont.ttf') format('truetype'), + url('Polices/Crete_Round/CreteRound-Italic-webfont.svg#CreteRoundItalic') format('svg'); + font-weight: normal; + font-style: normal; + +} + +body +{ + background-color: #FDF697; +} + +h1 +{ + text-align: center; + display: inline; + font-weight: normal; +} + +a +{ + font-style: normal; + text-decoration: none; + color: black; + cursor: pointer; +} + +em +{ + font-style: normal; +} + +strong +{ + font-weight: normal; +} + +mark +{ + background-color: transparent; + color: inherit; +} + +#algorithmie +{ + position: relative; +} + +#content +{ + background-color: #FDE862; + width: 980px; + height: auto; + position: relative; + margin: auto; + margin-top: 50px; + margin-bottom: 50px; + border: solid; + border-width: 4px; + border-radius: 15px; + border-color: #FAC801; + padding-bottom: 30px; +} + +.conversion +{ + position: relative; + cursor: pointer; + z-index: 1; +} + +.icone +{ + position: relative; + bottom: 180px; + right: 99px; + margin-right: 7px; + cursor: pointer; +} + +#support_menus +{ + position: absolute; + top: -187px; + left: 247px; +} + +#selection +{ + position: absolute; + top: -91px; + left: 255px; + z-index: 10; +} + +.onglet_deroulant +{ + position: absolute; + left: 255px; +} + +#onglet_deroulant1 +{ + top: -126px; + z-index: 9; +} + +#onglet_deroulant2 +{ + top: -97px; + z-index: 8; +} + +#onglet_deroulant3 +{ + top: -68px; + z-index: 7; +} + +#onglet_deroulant4 +{ + top: -39px; + z-index: 6; +} + +#onglet_deroulant5 +{ + top: -10px; + z-index: 5; +} + +#onglet_deroulant6 +{ + top: 19px; + z-index: 4; +} + +#onglet_deroulant7 +{ + top: 48px; + z-index: 3; +} + +#onglet_deroulant8 +{ + top: 77px; + z-index: 2; +} + +.instruction +{ + position: absolute; + left: 470px; + font-family: Normal, Arial; + font-size: 16px; + color: #9B7606; + cursor: pointer; + width: 116px; + height: 33px; +} + +#instruction1 +{ + top: -136px; + z-index: 10; +} + +#instruction2 +{ + top: -107px; + z-index: 10; +} + +#instruction3 +{ + top: -78px; + z-index: 10; +} + +#instruction4 +{ + top: -49px; + z-index: 10; +} + +#instruction5 +{ + top: -20px; + z-index: 10; +} + +#instruction6 +{ + top: 9px; + z-index: 10; +} + +#instruction7 +{ + top: 38px; + z-index: 10; +} + +#instruction8 +{ + top: 67px; + z-index: 10; +} + +#vous_programmez_en, .langage_actuel +{ + font-family: Normal, Arial; + font-size: 16px; + position: relative; + color: #D70404; +} + +#vous_programmez_en +{ + bottom: -3px; + right: 371px; +} + +.langage_actuel +{ + bottom: 2px; +} + +#langage_algo +{ + right: 407px; +} + +#langage_casio +{ + right: 407px; +} + +#langage_ti +{ + right: 420px; +} + +#infos +{ + width: 355px; + height: 44px; + background-color: #FFD745; + border: solid; + border-width: 4px; + border-radius: 5px; + border-color: #FAC801; + position: absolute; + top: -194px; + right: 43px; + font-family: Normal, Arial; + color: #D70404; + font-size: 14px; + font-style: normal; + text-decoration: none; + text-align: justify; + padding: 6px 8px 0px 9px; + z-index: 1; + cursor: help; + overflow: auto; +} + +#syntaxe +{ + position: absolute; + top: 22px; + left: 8px; +} + +.mot_cle +{ + color: #D70404; + font-size: 16px; + font-family: Normal, Arial; +} + +.indications +{ + + color: #C17700; + font-size: 14px; + font-family: Italic, Arial; +} + +#syntaxe_titre +{ + position: absolute; + top: -8px; + left: 6px; + font-size: 11px; + color: #C17700; +} + +#annonces +{ + width: 235px; + height: 322px; + background-color: #FFE378; + border: solid; + border-width: 4px; + border-radius: 15px; + border-color: #FAC54A; + position: absolute; + top: 374px; + right: 22px; + font-family: Normal, Arial; + font-size: 12px; + color: #C17700; + font-style: normal; + text-decoration: none; + text-align: left; + padding: 0px 8px 0px 9px; +} + +#texteAnnonce +{ + position: absolute; + left: 704px; + top: 450px; + text-align: center; + width: 225px; + font-family: Navig, Arial; + font-size: 20px; + color: rgb(11, 122, 196); +} + +#pub1 +{ + position: absolute; + left: 706px; + top: 408px; + z-index: 1; +} + +#pub2 +{ + position: absolute; + left: 830px; + top: 408px; + z-index: 1; +} + +#pub3 +{ + position: absolute; + left: 784px; + top: 323px; +} + +.pub4 +{ + position: relative; + margin-top: 40px; +} + +#pub_aide +{ + position: absolute; + left: 127px; + top: 2010px; +} + +.cleditorMain +{ + position: absolute; + top: -84px; + left: 263px; + z-index: 1; + margin-bottom: 0px; + border: solid; + border-width: 4px; + border-color: #FFAF22; + padding:0 1px 1px; + background-color: #FAF07A; +} + +#disable +{ + position: absolute; + z-index: 1; + left: 263px; + top: -84px; +} + +#debug +{ + position: absolute; + width: 634px; + height: 92px; + top: 285px; + left: 42px; + background-color: #DF6060; + border: solid; + border-width: 4px; + border-color: #D12424; + overflow: auto; +} + +#attention +{ + position: absolute; + left: 10px; + top: 8px; +} + +#debug_titre +{ + position: absolute; + top: 2px; + left: 55px; + font-family: Normal, Arial; + font-size: 16px; + color: #AC0000; +} + +.erreurs +{ + position: relative; + top: 40px; + left: 14px; + text-align: left; + width: 315px; +} + +#description_erreur +{ + font-family: Normal, Arial; + font-size: 14px; + color: #771A1A; +} + +#suggestion_erreur +{ + font-family: Italic, Arial; + font-size: 14px; + color: #1B6618; +} + +.ampoule +{ + position: relative; + top: 4px; + left: 3px; + margin-right: 2px; +} + +.signes_icone +{ + position: absolute; + left: 635px; + cursor: pointer; +} + +#signe_icone1 +{ + top : -75px; +} + +#signe_icone2 +{ + top : -35px; +} + +#signe_icone3 +{ + top : 5px; +} + +#signe_icone4 +{ + top : 45px; +} + +#signe_icone5 +{ + top : 85px; +} + +#signe_icone6 +{ + top : 125px; +} + +#signe_icone7 +{ + top : 165px; +} + +#signe_icone8 +{ + top : 205px; +} + +.signes +{ + position: absolute; + left: 643px; + cursor: pointer; +} + +#signe1 +{ + top : -89px; +} + +#signe2 +{ + top : -49px; +} + +#signe3 +{ + top : -9px; +} + +#signe4 +{ + top : 34px; + left: 642px; +} + +#signe5 +{ + top : 73px; +} + +#signe6 +{ + top : 110px; +} + +#signe7 +{ + top : 150px; + left: 644px; +} + +#signe8 +{ + top : 192px; +} + +#execution +{ + width: 622px; + height: 210px; + background-color: #EED858; + border: solid; + border-width: 4px; + border-color: #D2A124; + position: absolute; + bottom: -496px; + left: 42px; + font-family: Normal, Arial; + font-style: normal; + text-decoration: none; + text-align: left; + padding: 48px 0px 8px 12px; + overflow: auto; + word-wrap: break-word; +} + +#resultats_titre +{ + position: absolute; + top: -12px; + left: 10px; + font-size: 18px; + color: #DB7517; +} + +#resultats +{ + position: relative; + bottom: 19px; + font-size: 15px; + color: #D29A17; +} + +#fin_execution +{ + color: red; + font-size: 18px; + position: absolute; + right: 14px; +} + +#lire +{ + resize: none; +} + +.bouton +{ + position: absolute; + top: 285px; + right: 158px; + cursor: pointer; +} + +#reset +{ + right: 53px; +} + +#variables +{ + width: 172px; + height: 106px; + background-color: #FFD745; + border: solid; + border-width: 4px; + border-color: #FAC801; + position: absolute; + top: 383px; + right: 53px; + font-family: Normal, Arial; + font-style: normal; + text-decoration: none; + text-align: left; + padding: 6px 8px 0px 9px; + overflow: auto; + word-wrap: break-word; +} + +#variable_titre +{ + position: absolute; + top: -12px; + left: 5px; + font-size: 14px; + color: #D70404; +} + +.vars +{ + position: relative; + top: 18px; + left: 4px; + margin-top: 3px; + margin-bottom: 0px; + font-size: 14px; + color: #D70404; +} + +#publier +{ + position: absolute; + bottom: -501px; + right: 53px; + cursor: pointer; +} + +footer +{ + text-align: center; + font-family: normal, Arial; +} + +#partenaires +{ + margin: auto; +} + +.espace +{ + margin-left: 9px; + margin-right: 9px; +} + +.nom_part +{ + font-size: 12px; +} + +#auteur +{ + font-size: 14px; +} + +#credits_images +{ + font-size: 12px; +} + +.lien +{ + color: #C51111; + text-decoration: underline; +} + +.publier_titres +{ + margin-left: 170px; +} + +#avertissement +{ + font-family: Normal, Arial; + font-size: 14px; + text-align: left; + margin-left: 200px; +} + +#capcha +{ + margin-left: 260px; +} + +#ins +{ + color: red; +} \ No newline at end of file diff --git a/toolbar-origine.gif b/toolbar-origine.gif new file mode 100644 index 0000000..e6eb2da Binary files /dev/null and b/toolbar-origine.gif differ diff --git a/traduction.js b/traduction.js new file mode 100644 index 0000000..47092d1 --- /dev/null +++ b/traduction.js @@ -0,0 +1,446 @@ +function traduction(langage_source, langage_cible, remplacer) { + var nouveau = "", u, v, z, n, result, last = new Array(), last_indice = 0; + var ligne; + + var autres = [ + "Hasard", "#Ran", "rand", + "Partie_entière", "Int", "Int", + "Partie_décimale", "Frac", "fPart", + "Valeur_absolue", "Abs", "Abs" + ]; + + $('#pause').hide(); + $('#executer').show(); + reset = 1; + process = 0; + execution_init(); + $("#saisie").cleditor()[0].disable(false); + + result = compilation(langage_source); + last[0] = "rien"; + +//affiche_resultats(); + if(result == "failed") + return "failed"; + + for(v = 0; v < k; v++) + { + if(!((code[indices[v - 1]] == "alors" || code[indices[v - 1]] == "sinon") && (code[indices[v - 1] + 1] != "fin_si" && code[indices[v - 1] + 1] != "fin_si_ou_boucle"))) + ligne = " "; + + switch(code[indices[v]]) + { + case "lire": + z = (langage_source == 2 ? 1 : 0); + + if(langage_cible == 1) + ligne += "Lire " + code[indices[v] + 2 + z].toUpperCase(); + if(langage_cible == 2) + ligne += "? → " + code[indices[v] + 2 + z].toUpperCase(); + if(langage_cible == 3) + ligne += "Input " + code[indices[v] + 2 + z].toUpperCase(); + break; + + case "afficher": + if(langage_cible == 1) + ligne += "Afficher "; + if(langage_cible == 3) + ligne += "Disp "; + if(code[indices[v] + 1] == "variable") + ligne += code[indices[v] + 2].toUpperCase(); + else if(code[indices[v] + 1] == "chaine" || code[indices[v] + 1] == "calcul") + ligne += code[indices[v] + 2]; + if(langage_cible == 2) + ligne += "∠"; + break; + + case "si": + if(langage_cible == 1) + { + ligne += "Si"; + last[last_indice] = "Fin_si"; + } + else + { + ligne += "If"; + last[last_indice] = "IfEnd"; + } + last_indice++; + + for(z = indices[v] + 1; z < indices[v + 1]; z++) + { + if(code[z] == "variable") + ligne += " " + code[z + 1].toUpperCase(); + if(code[z] == "signe" || code[z] == "calcul") + ligne += " " + code[z + 1]; + if(code[z] == "et") + { + if(langage_cible == 1) + ligne += " ET"; + else + ligne += " and"; + } + if(code[z] == "ou") + { + if(langage_cible == 1) + ligne += " OU"; + else + ligne += " or"; + } + } + + break; + + case "alors": + if(langage_cible == 1) + ligne += "Alors "; + if(langage_cible == 2 || langage_cible == 3) + ligne += "Then "; + if(code[indices[v] + 1] != "fin_si" && code[indices[v] + 1] != "fin_si_ou_boucle" && code[indices[v] + 1] != "sinon") + continue; + break; + + case "sinon": + if(langage_cible == 1) + ligne += "Sinon "; + if(langage_cible == 2 || langage_cible == 3) + ligne += "Else "; + if(code[indices[v] + 1] != "fin_si" && code[indices[v] + 1] != "fin_si_ou_boucle") + continue; + break; + + case "fin_si": + if(langage_cible == 1) + ligne += "Fin_si"; + if(langage_cible == 2) + ligne += "IfEnd"; + if(langage_cible == 3) + ligne += "End"; + break; + + case "fin_si_ou_boucle": + if(last[last_indice - 1] != "rien") + { + ligne += last[last_indice - 1]; + if(last_indice > 0) last_indice--; + } + else + { + alert("Erreur de syntaxe"); + return; + } + break; + + case "tant_que": + if(langage_cible == 1) + { + ligne += "Tant_que"; + last[last_indice] = "Fin_Tant_que"; + } + else + { + ligne += "While"; + last[last_indice] = "WhileEnd"; + } + + last_indice++; + + for(z = indices[v] + 1; z < indices[v + 1]; z++) + { + if(code[z] == "variable") + ligne += " " + code[z + 1].toUpperCase(); + if(code[z] == "signe" || code[z] == "calcul") + ligne += " " + code[z + 1]; + if(code[z] == "et") + { + if(langage_cible == 1) + ligne += " ET"; + else + ligne += " and"; + } + if(code[z] == "ou") + { + if(langage_cible == 1) + ligne += " OU"; + else + ligne += " or"; + } + } + + break; + + case "fin_tant_que": + if(langage_cible == 1) + ligne += "Fin_Tant_que"; + if(langage_cible == 2) + ligne += "WhileEnd"; + if(langage_cible == 3) + ligne += "End"; + break; + + case "pour": + var elem = new Array(); + + if(langage_source == 1) + { + elem[0] = code[indices[v] + 2].toUpperCase(); + elem[1] = code[indices[v] + 5]; + elem[2] = code[indices[v] + 8]; + } + if(langage_source == 2) + { + elem[0] = code[indices[v] + 5].toUpperCase(); + elem[1] = code[indices[v] + 2]; + elem[2] = code[indices[v] + 8]; + } + if(langage_source == 3) + { + elem[0] = code[indices[v] + 2].toUpperCase(); + elem[1] = code[indices[v] + 5]; + elem[2] = code[indices[v] + 8].substring(0, code[indices[v] + 8].length - 1); + } + + if(langage_cible == 1) + { + ligne += "Pour " + elem[0] + " Allant_de " + elem[1] + " à " + elem[2]; + last[last_indice] = "Fin_Pour"; + } + if(langage_cible == 2) + { + ligne += "For " + elem[1] + " → " + elem[0] + " To " + elem[2]; + last[last_indice] = "Next"; + } + if(langage_cible == 3) + { + ligne += "For(" + elem[0] + ", " + elem[1] + ", " + elem[2] + ")" ; + last[last_indice] = "End"; + } + + last_indice++; + break; + + case "fin_pour": + if(langage_cible == 1) + ligne += "Fin_Pour"; + if(langage_cible == 2) + ligne += "Next"; + if(langage_cible == 3) + ligne += "End"; + break; + + case "fin_programme": + if(langage_cible == 1) + ligne += "Fin_programme"; + else + ligne += "Stop"; + break; + + case "variable": + if(langage_source == 2 && code[indices[v] + 2] == "∠") + { + if(langage_cible == 1) + ligne += "Afficher "; + if(langage_cible == 3) + ligne += "Disp "; + ligne += code[indices[v] + 1].toUpperCase(); + if(langage_cible == 2) + ligne += "∠"; + } + + if(code[indices[v] + 2] == "prend_la_valeur") + ligne += code[indices[v] + 4].toUpperCase() + " → " + code[indices[v] + 1].toUpperCase(); + + if(code[indices[v] + 2] == "→" && langage_cible != 1) + ligne += code[indices[v] + 1].toUpperCase() + " → " + code[indices[v] + 4].toUpperCase(); + + if(code[indices[v] + 2] == "→" && langage_cible == 1) + ligne += code[indices[v] + 4].toUpperCase() + " prend_la_valeur " + code[indices[v] + 1].toUpperCase(); + break; + + case "calcul": + if(code[indices[v] + 2] == "→") + { + if(langage_cible == 1) + ligne += code[indices[v] + 4].toUpperCase() + " Prend_la_valeur " + code[indices[v] + 1].toUpperCase(); + else + ligne += code[indices[v] + 1].toUpperCase() + " → " + code[indices[v] + 4].toUpperCase(); + } + else if(code[indices[v] + 2] == "∠") + { + if(langage_cible == 1) + ligne += "Afficher " + code[indices[v] + 1].toUpperCase(); + else + ligne += "Disp " + code[indices[v] + 1].toUpperCase(); + } + break; + + case "chaine": + if(langage_source == 2 && code[indices[v] + 2] == "∠") + { + if(langage_cible == 1) + ligne += "Afficher "; + if(langage_cible == 3) + ligne += "Disp "; + ligne += code[indices[v] + 1]; + if(langage_cible == 2) + ligne += "∠"; + } + break; + } + + while(ligne.indexOf("#ran") != -1) + ligne = ligne.replace("#ran","#Ran"); + + while(ligne.indexOf("#RAN") != -1) + ligne = ligne.replace("#RAN","#Ran"); + + while(ligne.indexOf("hasard") != -1) + ligne = ligne.replace("hasard","Hasard"); + + while(ligne.indexOf("HASARD") != -1) + ligne = ligne.replace("HASARD","Hasard"); + + while(ligne.indexOf("Rand") != -1) + ligne = ligne.replace("Rand","rand"); + + while(ligne.indexOf("RAND") != -1) + ligne = ligne.replace("RAND","rand"); + + while(ligne.indexOf("Int") != -1) + ligne = ligne.replace("Int","INT"); + + while(ligne.indexOf("int") != -1) + ligne = ligne.replace("int","INT"); + + while(ligne.indexOf("Frac") != -1) + ligne = ligne.replace("Frac","FRAC"); + + while(ligne.indexOf("frac") != -1) + ligne = ligne.replace("frac","FRAC"); + + while(ligne.indexOf("Abs") != -1) + ligne = ligne.replace("Abs","ABS"); + + while(ligne.indexOf("abs") != -1) + ligne = ligne.replace("abs","ABS"); + + while(ligne.indexOf("fPart") != -1) + ligne = ligne.replace("fPart","FPART"); + + while(ligne.indexOf("fpart") != -1) + ligne = ligne.replace("fpart","FPART"); + + while(ligne.indexOf("Partie_entière") != -1) + ligne = ligne.replace("Partie_entière","PARTIE_ENTIÈRE"); + + while(ligne.indexOf("partie_entière") != -1) + ligne = ligne.replace("partie_entière","PARTIE_ENTIÈRE"); + + while(ligne.indexOf("Partie_décimale") != -1) + ligne = ligne.replace("Partie_décimale","PARTIE_DÉCIMALE"); + + while(ligne.indexOf("partie_décimale") != -1) + ligne = ligne.replace("partie_décimale","PARTIE_DÉCIMALE"); + + while(ligne.indexOf("Valeur_absolue") != -1) + ligne = ligne.replace("Valeur_absolue","VALEUR_ABSOLUE"); + + while(ligne.indexOf("valeur_absolue") != -1) + ligne = ligne.replace("valeur_absolue","VALEUR_ABSOLUE"); + + n = (langage_source == 1 ? 0 : 1); + + for(z = 0; z < 4; z++) + { + var ajout, current, position1, position2, expression, rebours, parentheses; + var tab = ["Hasard", "rand"]; + + while(ligne.toLowerCase().indexOf(autres[3 * z + langage_source - 1].toLowerCase()) != -1) + { + ajout = autres[3 * z + langage_cible - 1]; + if(ajout != "Int" && ajout != "fPart") + ajout += " "; + + current = ligne.indexOf(autres[3 * z + langage_source - 1]); + if(langage_source == 2) + { + if(autres[3 * z + langage_source - 1] == "#Ran" && ligne.substring(current - 1, current) == ")" && ligne.indexOf("(") < current && ligne.indexOf("(") != -1) + { + position2 = current - 1; + + parentheses = 0; + for(rebours = 0; parentheses >= 0; rebours++) + { + if(ligne.substring(current - 2 - rebours, current - 1 - rebours) == ")") + parentheses++; + if(ligne.substring(current - 2 - rebours, current - 1 - rebours) == "(") + parentheses--; + } + position1 = current - 1 - rebours; + + if(position1 != -1 && position2 != -1) + { + expression = ligne.substring(position1, position2 + 1); + ligne = ligne.substring(0, position1) + ligne.substring(position2 + 1, current + 4).toUpperCase() + expression + ligne.substring(current + 4, ligne.length); + } + } + else + { + ligne = ligne.replace(autres[3 * z + langage_source - 1].toUpperCase(), ajout); + break; + } + } + + if(langage_source != 2 && langage_cible == 2) + { + if(autres[3 * z + langage_source - 1] == tab[n] && ligne.substring(current + tab[n].length, current + tab[n].length + 1) == "(" && ligne.lastIndexOf(")") > current + tab[n].length && ligne.lastIndexOf(")") != -1) + { + position1 = current + tab[n].length; + parentheses = 0; + for(rebours = 0; parentheses >= 0; rebours++) + { + if(ligne.substring(current + tab[n].length + 1 + rebours, current + tab[n].length + 2 + rebours) == "(") + parentheses++; + if(ligne.substring(current + tab[n].length + 1 + rebours, current + tab[n].length + 2 + rebours) == ")") + parentheses--; + } + position2 = current + tab[n].length + rebours; + + if(position1 != -1 && position2 != -1) + { + expression = ligne.substring(position1, position2 + 1); + ligne = ligne.substring(0, position1 - tab[n].length) + expression + ligne.substring(position1 - tab[n].length, position1).toUpperCase() + ligne.substring(position2 + 1, ligne.length); + } + } + else + { + ligne = ligne.replace(autres[3 * z + langage_source - 1].toUpperCase(), ajout); + break; + } + } + + if(langage_source != 2 && langage_cible != 2) + ligne = ligne.replace(autres[3 * z + langage_source - 1], autres[3 * z + langage_source - 1].toUpperCase()); + + ligne = ligne.replace(autres[3 * z + langage_source - 1].toUpperCase(), ajout); + } + } + + if(ligne.search(" ") == 0) + ligne = ligne.substring(1, ligne.length); + + nouveau += "
" + ligne + "
"; + } + + if(remplacer == 1) + remplace_saisie(nouveau); + else + return nouveau; + + return "completed"; +} + +function remplace_saisie(nouvelle_saisie) { + document.getElementById("saisie").value = nouvelle_saisie; + $("#saisie").cleditor()[0].updateFrame().focus(); +} \ No newline at end of file diff --git a/users.php b/users.php new file mode 100644 index 0000000..12baa58 --- /dev/null +++ b/users.php @@ -0,0 +1,98 @@ + + + + + + + + + + + Festiv'Algo - Liste des membres + + +
+ +
+ +
+
+ Index du forum > Liste des utilisateurs +
+ +
+
+ +
+
+ Index du forum > Liste des utilisateurs +
+ +
+
+ + + + + + + + + + + + + +
Nom d'utilisateurStatut
+
+
+ + + \ No newline at end of file