Woooh, plein de nouveaux fichiers. Ajout des discussions avec des jolies classes.

This commit is contained in:
Mysaa 2021-06-05 20:09:07 +02:00
parent 20a9f135e7
commit 2ea296cd61
52 changed files with 7560 additions and 658 deletions

36
404.php
View File

@ -2,25 +2,37 @@
<!DOCTYPE html>
<html>
<head>
<base href="http://www.bernard.890m.com/"/>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<h1>404 Not Found</h1>
<p>La page demand&eacute;e demeure introuvable.<br/>
Cette derni&egrave;re n'existe plus ou pas encore.<br/>
Bah au pire c'est pareil xD</p>
<a href="#" onclick="history.go(-1);" style="text-decoration:none"><input type="button" value="Page pr&eacute;c&eacute;dente" /></a><br/>
<p>
La page demand&eacute;e demeure introuvable.<br/>
Cette derni&egrave;re n'existe plus ou pas encore.<br/>
Bah au pire c'est pareil xD
</p>
<button onclick="window.history.go(-1);" >Page pr&eacute;c&eacute;dente</button><br/>
Si vous le voulez , vous pouvez essayer de trouver le code html de votre page web l&agrave; dedans:<br/>
<!---->
<div id="universe_text"></div>
<div id="add_universe" style="width:34px;height:21px;">
Plus
<div id="egg" style="color:#222;">
egg
</div>
</div><br/>
<div id="universe_text">
</div>
<div id="add_universe">Plus</div>
<script>
var charsMaxPerPlus = 1000;
var charsMaxPerPlus = 1000;
var n = 1;
var clics = 0;
var plus = document.getElementById('add_universe');
@ -28,12 +40,16 @@
var textToAdd = '';
clics+=1;
while(textToAdd.length < charsMaxPerPlus*clics){
textToAdd+=n*n;
textToAdd+=Math.pow(2,n)+" ";
n+=1;
}
var div = document.getElementById("universe_text");
div.innerHTML+=textToAdd;
}
var egg = document.getElementById('egg');
egg.addEventListener('click',function(){
clics +=1000;
});
plus.onclick = addUniverseText;
addUniverseText();
</script>

1
admin.php Normal file
View File

@ -0,0 +1 @@
<?php

52
admindialog.php Normal file
View File

@ -0,0 +1,52 @@
<?php
include_once 'clazz/Membre.class.php';
include_once 'includes/bdd.php';
$me = new Membre();
$me->connect();
if($me->getAdminLevel()<15){
echo 'Your admin level is too low (15 or more required)';
exit;
}elseif(!isset($_GET['action'])){
echo 'Please set an action in the URL (GET method ,name:"action")';
exit;
}
switch ($_GET['action']){
case 'set_discutionVisibility' :
if(!isset($_POST['discutionVisibility'])){
echo 'You must give a discution visibility (POST method,name:"discutionVisibility")';
exit;
}
if(!isset($_POST['discutionID'])){
echo 'You must give a discution ID (POST method,name:"discutionID")';
exit;
}
$discutionVisibility = $_POST['discutionVisibility'];
$discutionID = $_POST['discutionID'];
if ($discutionVisibility !== 'p' and preg_match ( "#^a[0-9]+$#",$discutionVisibility ) != 1 and preg_match ( '#^x([0-9]+;)*([0-9]+)?$#', $discutionVisibility ) != 1 ){
echo 'Your discution visibility is not well-formed : it should have been formed like ("p" or "x31;41;59;26;53" or "a42")';
exit;
}
$req = $GLOBALS['bdd']->prepare('UPDATE discussions SET autorized=? WHERE ID=?');
$req->execute(array($discutionVisibility,$discution));
exit;
default :
echo 'Unknown action : '+$_GET['action'];
exit;
}

View File

@ -1,6 +1,6 @@
<?php
session_start();
include_once 'includes/bdd.php';
include_once 'includes/inter.php';
?>
<!DOCTYPE html>
<html>
@ -9,7 +9,8 @@ include_once 'includes/bdd.php';
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php include 'includes/footer.php'; ?>
</body>
</html>

View File

@ -1,6 +1,16 @@
<?php
session_start();
include_once 'includes/bdd.php';
include_once 'includes/inter.php';
$return = changePassword();
if($return = 'falsePassword'){
$_SESSION['current_error'] = 'Le mot de passe que vous avez rentré ne correspond pas à celui stoqué dans notre base de données !';
header('Location:profile.php');
exit;
}else if($return = 'passwordMissmatch'){
$_SESSION['current_error'] = 'Le nouveau mot de passe et sa confirmation ne correspondent pas';
header('Location:profile.php');
exit;
}
?>
<!DOCTYPE html>
<html>

151
clazz/Discussion.class.php Normal file
View File

@ -0,0 +1,151 @@
<?php
class Discussion{
protected $ID;
protected $name;
protected $creatorID;
protected $dateCreation;
protected $accessibility;
protected $valid;
public function __construct($ID){
$this->ID = $ID;
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE ID=?');
$req->execute(array($ID));
if($rep = $req->fetch()){
$this->valid = TRUE;
$this->name = $rep['name'];
$this->creatorID = $rep['creatorID'];
$this->dateCreation = $rep['dateCreation'];
$this->accessibility = $rep['accessibility'];
}else{
$this->valid = FALSE;
}
}
public function exists(){
return $this->valid;
}
public function __toString(){
$out = 'Discussion\n';
$out .= '\tID:' . $this->ID . '\n';
$out .= '\tName:' . $this->name . '\n';
$out .= '\tCreator\'s ID:' . $this->creatorID . '\n';
$out .= '\tDate of creation:' . $this->dateCreation . '\n';
$out .= '\tAccessibility:' . $this->accessibility . '\n';
return out;
}
//Getters
public function getID(){
return $this->ID;
}
public function getName(){
return $this->name;
}
public function getCreatorID(){
return $creatorID;
}
public function getDateCreation(){
return $this->dateCreation;
}
public function getAccessibility(){
return $this->accessibility;
}
//Useful Getters
public function canAccess($membre){
$out = $this->accessibility === 'p';
if(preg_match ( "#^a[0-9]+$#", $this->accessibility ) == 1)
$out = $out or intval ( substr ( $this->accessibility, 1 ) ) <= $membre->getAdminLevel();
$out = $out or preg_match ( '#^x([0-9]+;)*' . $membre->getID() . '(;[0-9]+)*$#', $disc ['autorized'] ) == 1;
$out = $out or $membre->getAdminLevel() >= 14;
return $out;
}
//Setters
const NAME_ALREADY_USED = 'Nom d&eacute;j&agrave; utilis&eacute;';
const ILLEGAL_NAME = 'Le nom de la discussion est incorrect : les caract&egrave;res autoris&eacutes sont :'.
'<br/> abcdefghijklmnopqrstuvwxyz<wbr/>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<wbr/>'.
'&eacute;&egrave;&agrave;&mu;_-\'()[\\]\\\\/<wbr/>,;:.&sect;!&ugrave;%&pound;$&curren;=+-*\\#~"|&ccedil;@';
const TOO_LONG_NAME = 'Le nom est trop long : maximum 256 caract&egrave;res';
public function rename($newName){
if(!exists())
return NULL;
if(getFromName($newName))
return NAME_ALREADY_USED;
$regex = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.
'éèàµ_\\-\'()\\[\\]\\\\/,;:.§!ù%£$¤=+\\-*\\#~"|ç@';
$regex = '#^['.$regex.']+$#';
if(preg_match($regex,$newName) != 1)
return ILLEGAL_NAME;
}
//Discussions getters
private static function discussionGetterOutput($req){
$out = array();
while($rep = $req->fetch())
$out[] = new Discussion($rep['ID']);
if($out)
return $out;
else
return NULL;
}
public static function getFromName($name){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE name=?');
$req->execute(array($name));
return discussionGetterOutput($req);
}
public static function getFromCreator($ID){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
$req->execute(array($ID));
return discussionGetterOutput($req);
}
public static function getFromDateCreation($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation=?');
$req->execute(array($date));
return discussionGetterOutput($req);
}
public static function getFromAccessibility($accessibility){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE creatorID=?');
$req->execute(array($accessibility));
return discussionGetterOutput($req);
}
public static function getCreatedLaterThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation>?');
$req->execute(array($date));
return discussionGetterOutput($req);
}
public static function getCreatedEarlierThan($date){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions WHERE dateCreation<?');
$req->execute(array($date));
return discussionGetterOutput($req);
}
public static function getWhichHeCanAccess($he){
$req = $GLOBALS['bdd']->prepare('SELECT * FROM discussions');
$req->execute(array());
$out = array();
while ( $rep = $req->fetch()) {
$disc = new Discussion($rep['ID']);
if ($disc->canAccess($membre))
$out[] = $disc;
}
if($out)
return $out;
else
return NULL;
}
}

107
clazz/Membre.class.php Normal file
View File

@ -0,0 +1,107 @@
<?php
class Membre {
const DEFAULT_BANNER = "pictures/bande.png";
protected $id;
protected $password;
protected $pseudo;
protected $adminLevel;
protected $dateCreation;
protected $requiredBanner;
protected $personnalMessage;
protected $connected;
public function __construct($id = NULL, $pass = NULL) {
$this->id = $id ?? $_SESSION ['session_id'];
$this->password = $pass ?? $_SESSION ['session_mdp'];
$connected = FALSE;
}
public function connect() {
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$this->id
) );
if ($rep = $req->fetch ()) {
$connected = password_verify ( $this->pass, $rep ['mdp'] );
$this->adminLevel = $connected ? $result ['administration'] : - 1;
$this->pseudo = $connected ? $result ['pseudo'] : NULL;
if ($connected)
decodeData ( $rep ['data'] );
return $this->connected = $connected;
} else {
$req->closeCursor ();
return $this->connected = FALSE;
}
}
public function hasPersonnalMessage() {
return isset ( $this->personnalMessage );
}
public function showPersonnalMessage() {
$msg = $this->personnalMessage;
$this->personnalMessage = NULL;
return $msg;
}
private function decodeData($data) {
$jsonData = json_decode ( $data );
// Set the data's required_banner if it is defined , otherwise sets the DEFAULT_BANNER
$this->requiredBanner = $jsonData ['requiredBanner'] ?? self::DEFAULT_BANNER;
$this->personnalMessage = $jsonData ['personnalMessage'] ?? NULL;
}
private function encodeData() {
$jsonArray = array ();
// Set requiredBanner only if it is different from DEFAULT_BANNER
$jsonArray ['requiredBanner'] = $this->requiredBanner !== self::DEFAULT_BANNER ? $this->requiredBanner : NULL;
$jsonArray ['personnalMessage'] = $this->personnalMessage ?? NULL;
return json_encode ( $jsonArray );
}
public function getID(){
return $this->id;
}
public function getAdminLevel() {
return $this->adminLevel;
}
public function getBanner() {
return $this->requiredBanner;
}
public function isConnected() {
return $connected;
}
public static function tryToConnect($pseudo = NULL, $mdp = NULL) {
$pseudo = $pseudo ?? $_POST ['pseudo'];
$mdp = $mdp ?? $_POST ['mdp'];
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' );
$req->execute ( array (
$pseudo
) );
$reponce = $req->fetch ();
if ($reponce != NULL) {
if (password_verify ( $mdp, $reponce ['mdp'] )) {
$req->closeCursor ();
return $reponce ['ID'];
} else {
$req->closeCursor ();
return 'errormdp';
}
} else {
$req->closeCursor ();
return 'errorpseudo';
}
}
public static function registerPerson($pseudo, $mdp) {
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" );
$req->execute ( array (
$_POST ['pseudo']
) );
if ($req->fetch ())
return 'usedPseudo';
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$_POST ['pseudo'],
password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT )
) );
return 'ok';
}
}

16
creating_discussion.php Normal file
View File

@ -0,0 +1,16 @@
<?php
session_start();
include_once 'includes/inter.php';
if(!isConnected()){
header('Location:403.php');
goto end;
}if(getAdminLevel()<2){ header('Location:401.php'); goto end;}$regex = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 éèàµ_\\-\'()\\[\\]\\\\/,;:.§!ù%£$¤=+\\-*\\#~"|ç@';$regex = '#^['.$regex.']+$#';
if(preg_match($regex,$_POST['name']) == 1){
createDiscut();
}else{ $_SESSION['current_error'] = 'Le nom de la discussion est incorrect : les caract&egrave;res autoris&eacutes sont :<br/> abcdefghijklmnopqrstuvwxyz<wbr/>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<wbr/> &eacute;&egrave;&agrave;&mu;_-\'()[\\]\\\\/<wbr/>,;:.&sect;!&ugrave;%&pound;$&curren;=+-*\\#~"|&ccedil;@';
echo $_POST['name']; header('Location:discuts.php');
goto end;
}
header('Location:discuts.php');
end:

4
css/firefoxStyle.css Normal file
View File

@ -0,0 +1,4 @@
*::-moz-selection {
background-color: rgb(100, 200, 40);
color: #222;
}

4
css/noFirefoxStyle.css Normal file
View File

@ -0,0 +1,4 @@
*::selection {
background-color: rgb(100, 200, 40);
color: #222;
}

View File

@ -1,208 +1,307 @@
/* General */
#postMessageForm textarea,#editMessageForm textarea{
background-color:#292828;
resize: none;
width:95%;
color:#5dd528;
text-align: center;
}
.fullscreen{
position:fixed;
top:0;
right:0;
width:100%;
height:100%;
vertical-align:middle;
background-color: #222;
}
.opaque{
opacity: 0.75;
}
.absent {
display:none;
}
.screen-vertical-centered{
text-align:center;
margin-top: 50vh;
transform: translateY(-50%);
}
.screen-horizontal-centered{
display:inline;
opacity:1;
font-size:42px;
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
.bigText{
position: absolute;
top:0;
right:0;
background-color: #DDD;
color: rgb(155,55,215);
height : 100%;
width : 100%;
text-align : center;
}
a {
background-color: #222;
color: rgb(100, 200, 40);
text-align: center;
color: rgb(100, 200, 40);
}
body{
body {
background-color: #222;
color: rgb(100, 200, 40);
text-align: center;
color: rgb(100, 200, 40);
text-align : center;
}
body::selection, br::selection {
background-color: rgb(100, 200, 40);
color: #222;
article{
margin: 20px;
padding: 5px;
border: 3px #999 outset;
text-align: center;
}
.articlePic{
text-align: left;
border: px rgb(100, 200, 40) outset;
margin: 20px;
}
.articleTitle{
float: center;
text-decoration:underline;
}
.articleText{
text-align: left;
margin: 25px 125px;
}
article {
margin: 20px;
padding: 5px;
border: 3px #999 outset;
h1 {
text-decoration:underline;
}
header {
background-color: #222;
color: rgb(100, 200, 40);
margin: 0px;
padding: 10px;
border-bottom: 3px rgb(100, 200, 40) solid;
text-align: center;
color: rgb(100, 200, 40);
margin: 0px;
padding: 10px;
border-bottom: 3px rgb(100, 200, 40) solid;
text-align: center;
}
header a {
color: rgb(100, 200, 40);
}
nav {
text-align: center;
color: rgb(100, 200, 40);
}
#navLinks a {
color: rgb(100, 200, 40);
padding-left: 70px;
padding-right: 70px;
background-color: #222;
font-size: 4ex;
border: 3px rgb(100, 200, 40) outset;
border-collapse: collapse;
text-decoration: none;
color: rgb(100, 200, 40);
padding-left: 30px;
padding-right: 30px;
font-size: 4ex;
border: 3px rgb(100, 200, 40) outset;
border-collapse: collapse;
text-decoration: none;
}
footer {
border-top: 10px rgb(100, 200, 40) double;
background-color: #222;
text-align: center;
height: 250px
border-top: 10px rgb(100, 200, 40) double;
text-align: center;
height: 250px
}
#bienvenue {
border-bottom: 3px rgb(100, 200, 40) solid;
font-size: 20px;
border-bottom: 3px rgb(100, 200, 40) solid;
font-size: 20px;
}
#bande {
display: block;
padding-bottom: 5px;
margin-left: auto;
margin-right: auto;
display: block;
padding-bottom: 5px;
margin-left: auto;
margin-right: auto;
}
#copyright {
float: left;
color: rgb(100, 200, 40);
float: left;
color: rgb(100, 200, 40);
}
#me_contacter {
float: right;
color: rgb(100, 200, 40);
#nous_contacter {
float: right;
color: rgb(100, 200, 40);
}
a #haut_de_page {
background-color: rgb(100, 200, 40);
color: #222;
position: relative;
top: 10px;
padding: 10px;
background-color: rgb(100, 200, 40);
color: #222;
position: relative;
top: 10px;
padding: 10px;
}
/* 404 */
#universe_text{
#universe_text {
word-wrap: break-word;
}
#add_universe{
#add_universe {
text-align: center;
margin : 50px auto;
margin: 15px auto;
border: 5px solid rgb(100, 200, 40);
background-color: #222;
}
/* Login & Register */
#loginForm {
margin-left: auto;
margin-right: auto;
margin-bottom: 100px;
margin-top: 100px;
margin-left: auto;
margin-right: auto;
margin-bottom: 100px;
margin-top: 100px;
}
#headDisconnectForm {
display: inline;
display: inline;
}
#disconnectText, #passwordChangedText {
margin-left: auto;
margin-right: auto;
margin-bottom: 100px;
margin-top: 20px;
font-size: 30px;
margin-left: auto;
margin-right: auto;
margin-bottom: 100px;
margin-top: 20px;
font-size: 30px;
}
#headLoginForm {
margin-left: auto;
margin-right: auto;
margin-bottom: 0px;
margin-top: 0px;
display: inline;
margin-left: auto;
margin-right: auto;
margin-bottom: 0px;
margin-top: 0px;
display: inline;
}
#headLittleLoginForm {
margin-left: auto;
margin-right: auto;
margin-bottom: 0px;
margin-top: 0px;
display: none;
}
#headRegisterForm {
display: inline;
display: inline;
}
#registerForm, #changePasswordForm{
margin-left: auto;
margin-right: auto;
margin-bottom: 100px;
margin-top: 20px;
#registerForm, #changePasswordForm {
margin-left: auto;
margin-right: auto;
margin-bottom: 100px;
margin-top: 20px;
}
/* Projet/Versions */
.project_option_img {
display: inline;
display: inline;
}
.disabeled{
opacity : 0.2;
.disabeled {
opacity: 0.2;
}
.project_option {
color:#222;
}
.versionTable {
margin-left: auto;
margin-right: auto;
margin-bottom: 50px;
margin-top: 0px;
border-collapse: collapse;
display: inline;
border-collapse: collapse;
}
td, th {
background-color: #222;
color: rgb(100, 200, 40);
text-align: center;
border: 1px solid black;
color: rgb(100, 200, 40);
text-align: center;
border: 1px solid black;
}
/* Forum */
#createNewDiscForm{
display: none;
}
section.message {
padding-left: 5px;
padding-right: 5px;
padding-top: 5px;
padding-bottom: 10px;
margin-top: 5px;
margin-bottom: 5px;
margin-left: auto;
margin-right: auto;
border: 1px solid rgb(100, 200, 40);
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
section.message div {
padding-left: auto;
padding-right: auto;
padding-top: 10px;
text-align: right;
}
/* Disposition with width */
.nav2x2{
display:none;
.nav2x2 {
display: none;
}
.navV{
display:none;
.navV {
display: none;
}
@media screen and (max-width: 1050px){ /* Cacher bandeau */
#bande{
display:none;
@media screen and (max-width: 1050px) { /* Cacher bandeau */
#bande {
display: none;
}
}
@media screen and (max-width: 705px){ /* Cacher login/register */
#headLoginForm , #headRegisterForm{
display:none;
@media screen and (max-width: 705px) { /* Cacher login/register */
#headLoginForm {
display: none;
}
#headLittleLoginForm {
display: inline
}
#headLittleLoginForm {
display: inline;
}
}
@media screen and (max-width: 1180px){ /* Afficher nav2x2 */
.nav2x2{
display:inline;
@media screen and (max-width: 1180px) { /* Afficher nav2x2 */
.nav2x2 {
display: inline;
}
#navLinks a {
display: inline-block;
width : 250px;
width: 250px;
font-size: 3ex;
padding-left: 30px;
padding-right: 30px;
@ -210,13 +309,13 @@ td, th {
}
}
@media screen and (max-width: 615px){ /* Afficher navV */
.navV{
display:inline;
@media screen and (max-width: 615px) { /* Afficher navV */
.navV {
display: inline;
}
#navLinks a {
display: inline-block;
width:200px;
width: 200px;
font-size: 2ex;
padding-left: 30px;
padding-right: 30px;

20
deletingMessage.php Normal file
View File

@ -0,0 +1,20 @@
<?php
session_start();
include_once 'includes/inter.php';
if(!isConnected()){
header('Location:401.php');
goto end;
}
$messageData = getMessage();
if($messageData == -1){
header('Location:404.php');
goto end;
}
if(getAdminLevel()<6 && $_SESSION['session_id'] != $messageData['senderID']){
header('Location:403.php');
goto end;
}
removeMessage();
header('Location:discut.php?d=' . $messageData['discussion_id']);
end:

View File

@ -1,21 +1,7 @@
<?php session_start();
$_SESSION = array(); ?>
<!DOCTYPE html>
<html>
unset($_SESSION['session_id']);
unset($_SESSION['session_mdp']);
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php
include 'includes/head.php';
?>
<div id="disconnectText">Vous avez été correctement déconnécté !</div>
<?php
include 'includes/foot.php'
?>
</body>
</html>
header('Location:index.php');
$_SESSION['current_error'] = 'La d&eacute;connexion se sera correctement pass&eacutee!';
?>

130
discut.php Normal file
View File

@ -0,0 +1,130 @@
<?php
session_start ();
include_once 'includes/inter.php';
?><!DOCTYPE html><html><head>
<?php include 'includes/meta.php'; ?>
</head><body> <script type="text/javascript" src="he.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<?php include 'includes/header.php'; ?>
<br />
<?php
$disc = getDiscutInfos ();
$adminLevel = - 1;
if (isConnected ())
$adminLevel = getAdminLevel ();
if (! ($disc ['autorized'] === 'p' or (preg_match ( "#^a[0-9]+$#", $disc ['autorized'] ) == 1) ? (intval ( substr ( $disc ['autorized'], 1 ) ) <= $adminLevel) : FALSE or preg_match ( '#^x([0-9];)*' . $_SESSION ['session_id'] . '(;[0-9])*$#', $disc ['autorized'] ) == 1 or $adminLevel >= 14)) {
header ( 'Location:403.php' );
goto end;
} else if (! discutExists ()) {
header ( 'Location:40A.php' );
goto end;
}
else if (isConnected ()) {
?>
<form id="postMessageForm" action="posting_message.php?d=<?php echo $_GET['d'];?>" method="post"> <textarea row="5" placeholder="Votre message :" name="msg" autofocus="autofocus" required="required"></textarea> <input type="submit" value="Poster le message"> </form>
<!-- Entrée->envoyer le message (dégeulasse) --> <script type="text/javascript"> $('#postMessageForm textarea').on('keypress',function(e){ if(e.which == 13){ $('#postMessageForm input').trigger('click'); e.stopPropagation(); } }); </script>
<?php }else{ ?>
<div>Vous devez vous connecter pour envoyer des messages !</div>
<?php } ?>
<main> </main> <script type="text/javascript"> var oldTimeout = setTimeout; window.setTimeout = function(callback, timeout) { console.log("timeout started"); return oldTimeout(function() { console.log('timeout finished'); callback(); }, timeout); }
function reloadEditListeners(){
$('.editLink').on('click',function(e){
editingLink = e.target;
e.target.innerHTML = 'Edition';
$('#editMessageFullScreen').css('display','block');
$('#editMessageFullScreen div div form').attr('action','editing_message.php?d='+$(e.target).data('messageID'));
$('#editMessageFullScreen').animate({opacity:0.97},1000);
e.stopPropagation();
});
$('.delLink').on('click',function(e){
//console.log(e); e.target.innerHTML = 'Supression'; window.clearTimeout(currentClock);
$.post('deletingMessage.php?m='+$(e.target).data('messageID'),{},askData);
e.stopPropagation();
});
$('#abortEdition').on('click',function(e){
editingLink.innerHTML = 'Editer';
$('#editMessageFullScreen div div form').attr('action','js_waiting');
$('#editMessageFullScreen').animate({opacity:0.00},1000,function(e){
$('#editMessageFullScreen').css('display','none');
});
});
}
</script> <!-- Messages download --> <script type="text/javascript"> var currentClock = null;
var askData = function(){
$.post('getDiscutsMessages.php?d=<?php echo testInt($_GET['d'],'40A.php');?>',{},dataGet);
}
var dataGet = function(data,status){
var newData = eval(data);
newData = newData.sort(function(a,b){return b.sendTimestamp-a.sendTimestamp;});
var messageGlobal = document.createElement('main');
for(messagePos in newData){
var message = newData[messagePos];
//console.log(message);
var section = document.createElement('section');
section.className = 'message';
var messageText = document.createTextNode(he.decode(message.texte).replace(/\n/g, "<br />"));
section.appendChild(messageText);
section.appendChild(document.createElement('br'));
var messageData = document.createElement('div');
var pseudoText = document.createTextNode(message.pseudo);
var pseudoTimeSeparator = document.createTextNode(' ');//Quatre espaces
var time = document.createElement('time');
var sendTimeText = document.createTextNode(message.sendTime);
time.appendChild(sendTimeText);
messageData.appendChild(pseudoText);
messageData.appendChild(pseudoTimeSeparator);
messageData.appendChild(time);
section.appendChild(messageData);
if(message.rights){
var editPane = document.createElement('nav');
editPane.className = 'editPaneMessages';
var editLink = document.createElement('a');
editLink.className = 'editLink';
$(editLink).data('messageID',message.messageID);
editLink.appendChild(document.createTextNode('Editer'));
var delLink = document.createElement('a');
delLink.className = 'delLink';
$(delLink).data('messageID',message.messageID);
delLink.appendChild(document.createTextNode('Supprimer'));
editPane.appendChild(editLink);
editPane.appendChild(document.createTextNode(' '));
editPane.appendChild(delLink);
section.appendChild(editPane);
}
messageGlobal.appendChild(section);
}
document.body.replaceChild(messageGlobal,document.getElementsByTagName('main')[0]);
reloadEditListeners();
currentClock = setTimeout(askData,15000);
}
$(document).ready(askData);
</script>
<div id="editMessageFullScreen" class="fullscreen absent">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered">
<form id="editMessageForm" action="js modified" method="post">
<textarea row="5" placeholder="Le nouveau message :" name="msg" autofocus="autofocus" required="required"></textarea>
<input value="Modifier le message" type="submit">
<input id="abortEdition" value="Annuler" type="button"/>
</form>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>
</body></html><?php end: ?>

44
discuts.php Normal file
View File

@ -0,0 +1,44 @@
<?php
session_start ();
include_once 'includes/inter.php';
?><!DOCTYPE html><html><head>
<?php include 'includes/meta.php'; ?>
</head><body>
<?php include 'includes/header.php'; ?>
<br />
<?php
$discs = getDiscuts ();
$adminLevel = - 1;
if (isConnected ())
$adminLevel = getAdminLevel ();
foreach ( $discs as $disc ) {
if ($disc ['autorized'] === 'p' or
(preg_match ( "#^a[0-9]+$#", $disc ['autorized'] ) == 1) ? (intval ( substr ( $disc ['autorized'], 1 ) ) <= $adminLevel) : FALSE or
preg_match ( '#^x([0-9];)*' . $_SESSION ['session_id'] . '(;[0-9])*$#', $disc ['autorized'] ) == 1 or
$adminLevel >= 14) {
echo '<a href="discut.php?d=' . $disc ['ID'] . '">' . $disc ['name'] . ' par ' . getPseudoOf ( $disc ['creator_id'] ) . '</a><br/>';
}
}
?>
<br />
<?php if(isConnected() && getAdminLevel()>=2){?>
<span id="createNewDiscBefore">Creer une nouvelle discussion</span> <form id="createNewDiscForm" action="creating_discussion.php" method="post"> <label for="newDiscText"></label> <input id="newDiscText" type="text" name="name" /> <input type="submit" value="Cr&eacute;er la discussion" /> </form> <script type="text/javascript">
var span = document.getElementById('createNewDiscBefore');
span.addEventListener('click',function(){
document.getElementById('createNewDiscBefore').style.display = 'none';
document.getElementById('createNewDiscForm').style.display = 'block';
});
</script> <br /> <br />
<?php }?>
<?php include 'includes/footer.php'; ?>
</body></html>

47
downloadJar.php Normal file
View File

@ -0,0 +1,47 @@
<?php
session_start();
echo 'extensions:"'.ini_get('extensions').'"';
include_once "../includes/bdd.php";
include_once "../includes/inter.php";
include_once "megaapi.php";
$permissions = array (
FALSE,
FALSE,
FALSE,
FALSE
);
$connected = isConnected ();
$owner = FALSE;
$adminLevel = - 1;
$data = NULL;
if (isset ( $_GET ['id'] ) && isset ( $_GET ['v'] )) {
$data = getProjectVersionData( $_GET ['id'], $_GET ['v'] );
if ($data != NULL) {
$permissions = getPermissions( $data );
} else {
header('Location:../40A.php');
goto end;
}
} else {
header('Location:../40A.php');
goto end;
}
if (! $connected) {
header( 'Location:../401.php' );
goto end;
}
$owner = preg_match ( '#[^0-9]?' . $_SESSION ['session_id'] . '[^0-9]?#', $data ['owners'] );
$adminLevel = getAdminLevel ();
if (! $owner && $adminLevel < 12) {
header( 'Location:../403.php' );
goto end;
}
$megaapi = new MegaApiPHP("mA9D1IQQ", "PHP bernard.com");
$megaapi->login("bernard.lafayette63@gmail.com", "*******************");
$node = $megaapi->getNodeByPath('imageFinal.jpg', $megaapi->getRootNode());
$megaapi->startDownload($node, './');
end:

46
editVersion.php Normal file
View File

@ -0,0 +1,46 @@
<?php
session_start ();
include_once 'includes/inter.php';
?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php include_once 'includes/inter.php';
$data = getProjectVersionData();
if(!isConnected()){
header("Location:401.php");
goto end;
}else if(!preg_match('#[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?#',$data ['owners'])){
header("Location:403.php");
goto end;
}
?>
<br />
<br />
<br />
<br />
<form action="editingVersion.php?id=<?php $_GET['id'];?>&amp;v=<?php $_GET['v'];?>" method="post">
<label for="newVersionName">Nom de la version :</label> <input
type="text" maxlength="100" id="newVersionName" name="name" /><br />
<br />
<select name="language">
<option value="Java">Java</option>
<option value="VBA">VBA</option>
</select>
<br />
<br />
<input type="submit" value="Modifier la version" />
</form>
<br />
<br />
<br />
<br />
<?php include 'includes/footer.php'; ?>
</body>
</html>
<?php end:
?>

43
executor.php Normal file
View File

@ -0,0 +1,43 @@
<?php
session_start ();
include_once 'clazz/Membre.class.php';
$me = new Membre ();
if (! isset ( $_GET ['action'] )) {
header ( 'Location:40A.php' );
exit();
}
switch ($_GET ['action']) {
case 'register' :
if (isset ( $_POST ['pseudo'] ) && isset ( $_POST ['mdp'] ) && isset ( $_POST ['mdp2'] )) {
if ($_POST ['mdp'] === $_POST ['mdp2']) {
if (preg_match ( "#^[a-zA-Z0-9\\-_]+$#", $_POST ['pseudo'] )) {
if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&éèàùçµ\"\\#'{}()[\\]|\\^@°+=\$¤£*!§:/;.,?²]+$#", $_POST ['mdp'] )) {
switch (Membre::registerPerson ()) {
case 'ok' :
$_SESSION ['current_error'] = 'Vous avez déjà été correctement inscrit sur bernard.com';
header('Location:login.php');
exit();
case 'usedPseudo' :
$_SESSION ['current_error'] = 'Le pseudonyme est déjà utilisé (par une entité differente de vous)';
break;
}
} else {
$_SESSION ['current_error'] = 'Le mot de passe fut incorrect : Les seuls caractères autorisés sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&éèàùçµ"#\'{}()[]|^@°+=$¤£*!§:/;.,?²';
}
} else {
$_SESSION ['current_error'] = 'Le pseudo sera incorrect : Les seuls caractères autorisés sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_';
}
} else {
$_SESSION ['current_error'] = 'Tu auras du rentrer deux fois le même mot de passe (tu permet aussi de rendre le champs "Recopier le mot de passe" utile)';
}
} else {
$_SESSION ['current_error'] = 'Quand on demande des données , on donne des données !!!';
}
header ( 'Location:register.php' );
}

27
getDiscutsMessages.php Normal file
View File

@ -0,0 +1,27 @@
<?php
session_start();
include_once 'includes/inter.php';
$query = 'SELECT m.ID AS messageID,u.ID AS senderID, u.pseudo AS pseudo, m.texte AS texte, m.sendTime AS sendTime, UNIX_TIMESTAMP(m.sendTime) AS sendTimestamp FROM users AS u INNER JOIN messages AS m ON u.ID = m.senderID WHERE m.discussion_id=?';
$data = array ();
$pseudoID = -1;
$adminLevel = -1;
if(isConnected()){
$pseudoID = $_SESSION['session_id'];
$adminLevel = getAdminLevel();
}
$req = $GLOBALS ['bdd']->prepare ( $query );
$req->execute ( array (
$_GET ['d']
) );
while ( $donnees = $req->fetch () ) {
$donnees['rights'] = $donnees['senderID'] == $pseudoID || $adminLevel>=6;
array_push ( $data, $donnees );
$bool = true;
}
$req->closeCursor ();
echo json_encode ( $data );
flush ();

View File

@ -9,4 +9,26 @@
</div>
<a href="" id="haut_de_page">Haut de page</a>
</footer>
</footer>
<?php
if(isset($_SESSION['current_error'])){
?>
<div class="fullscreen opaque">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered"><?php echo $_SESSION['current_error'];?></div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$('.fullscreen').on('click',function(){
$('.fullscreen').animate({opacity:0},1000,function(){
$('.fullscreen').css('display','none');
});
});
</script>
<?php
unset($_SESSION['current_error']);
}
?>

View File

@ -1,13 +1,25 @@
<header>
<?php include_once('includes/bdd.php');
$req = $bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?');
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp']));
$rep = $req->fetch();
}if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && isset($rep['pseudo']) ){
<!--
000000000000000800000000000000000000000000000000000000000000000000000
000000000000008000000000000000000000000000000000000000000000000000000
000000000000080000000000000888000000000000000000000000000000000000000
000000000000800000000000088000880000000000000000000000000000000000000
000000000008008000000000000000080000000000000000000000000000000000000
000000000080008000000000000000800000000000000000000000000000000000000
000000000888888888000000000008000000000000000000000000000000000000000
000000000000008000000000000080000000000000000000000000000000000000000
000000000000008000000000000800000000000000000000000000000000000000000
000000000000008000000000088888880000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
-->
<?php
include_once('includes/inter.php');
if(isConnected()){
?>
<div id="bienvenue">Bienvenue &agrave; toi ,<?php echo $rep['pseudo']; ?>
<div id="bienvenue">Bienvenue &agrave; toi, <?php echo getPseudo(); ?>
<form id="headDisconnectForm" method="post" action="disconnect.php">
<input type="submit" value="Se d&eacute;connecter" />
</form>
@ -17,24 +29,26 @@
<form id="headLoginForm" method="post" action="logging.php">
<label for="pseudo">Pseudo :</label>
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" required />
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" />
<label for="mdp">Mot de passe :</label>
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" required />
<input type="Submit" value="Se connecter" />
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" />
<input type="submit" value="Se connecter" />
</form>
<form id="headLittleLoginForm" method="post" action="login.php">
<input type="submit" value="Se connecter" />
</form>
<form id="headRegisterForm" method="post" action="register.php">
<input type="submit" value="S'inscrire" />
<br/>
</form>
<?php } ?>
<img id="bande" src="pictures/bande.png" alt="Erreur d'affichage de l'image" />
<img id="bande" src="pictures/<?php if(rand()*31415 < 110*42)echo "lucas_president.png";else echo "bande.png";?>" alt="Erreur d'affichage de l'image" width=1000 height="89" />
<nav id="navLinks">
<a href="index.php">Acceuil</a><br class="navV"/>
<a href="index.php">Accueil</a><br class="navV"/>
<a href="projets.php">Mes Projets</a><br class="nav2x2"/>
<a href="others.php">Tous les projets</a><br class="navV"/>
<a href="discuts.php">Discussions</a><br class="navV"/>
<a href="profile.php">Mon profil</a><br class="navV"/>
</nav>
</header>
</header>

View File

@ -1,32 +1,123 @@
<?php
include_once 'includes/bdd.php';
function isConnected2S($username, $mdp) {
$req = $bdd->prepare ( 'SELECT * FROM users WHERE ID=? AND mdp=?' );
function isConnected($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$username,
$mdp
$sid
) );
return ( bool ) $req->fetch ();
if ($rep = $req->fetch ()) {
$connected = password_verify ( $mdp, $rep ['mdp'] );
} else {
$connected = FALSE;
}
$req->closeCursor ();
return $connected;
}
function isConnected() {
return isConnected2S ( $_SESSION ['session_id'], $_SESSION ['session_mdp'] );
}
function getProjectVersionDataFromIDs($project, $version) {
$req = $bdd->prepare ( 'SELECT p.ID AS pID , ' . 'v.versionAbs AS versionAbs , ' . 'p.name AS name , ' . 'v.version AS version , ' . 'v.language AS language , ' . 'p.permissions AS permissions , ' . 'p.ownersID AS owners ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE v.project_id LIKE = ? AND v.versionAbs = ?' );
function getAdminLevel($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return - 1;
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$_GET ['id'],
$_GET ['v']
$sid
) );
if ($result = $req->fetch ()) {
$adminLevel = $result ['administration'];
} else {
$adminLevel = - 1;
}
$req->closeCursor ();
return intval($adminLevel);
}
function getPseudo($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return "neant";
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function getPseudoOf($sid) {
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function tryToConnect($pseudo = NULL, $mdp = NULL) {
if (! isset ( $pseudo ) or ! isset ( $mdp )) {
$pseudo = $_POST ['pseudo'];
$mdp = $_POST ['mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' );
$req->execute ( array (
$pseudo
) );
$reponce = $req->fetch ();
if ($reponce != NULL) {
if (password_verify ( $mdp, $reponce ['mdp'] )) {
$req->closeCursor ();
return $reponce ['ID'];
} else {
$req->closeCursor ();
return 'errormdp';
}
} else {
$req->closeCursor ();
return 'errorpseudo';
}
}
function getProjectVersionData($project = NULL, $version = NULL) {
if (! isset ( $project ) or ! isset ( $version )) {
$project = $_GET ['id'];
$version = $_GET ['v'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS pID ,' . ' ' . 'v.versionAbs AS versionAbs , ' . ' ' . 'p.name AS name ,' . ' ' . 'v.version AS version ,' . ' ' . 'v.language AS language ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'INNER JOIN versions AS v' . ' ' . 'ON v.project_id = p.ID' . ' ' . 'WHERE v.project_id = ? AND v.versionAbs = ?' );
$req->execute ( array (
$project,
$version
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
}
function getProjectVersionData() {
return getProjectVersionDataFromIds ( $_GET ['id'], $_GET ['v'] );
function getProjectData($project = NULL) {
if (! isset ( $project )) {
$project = $_GET ['id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS ID ,' . ' ' . 'p.name AS name ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'WHERE p.ID = ?' );
$req->execute ( array (
$project
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
}
function getPermissionsFromData($data) {
function getPermissions($data) {
$permissions = array (
FALSE,
FALSE,
@ -37,6 +128,196 @@ function getPermissionsFromData($data) {
$permissions [1] = preg_match ( '#^(0|1)1#', $data ['permissions'] );
$permissions [2] = preg_match ( '#^(0|1){2}1#', $data ['permissions'] );
$permissions [3] = preg_match ( '#^(0|1){3}1#', $data ['permissions'] );
return $permissions;
}
function getProjectsWithFirstPermission() {
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.permissions LIKE "1%" ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
$req->closeCursor ();
return $projects;
}
function getVersions($pid = NULL) {
if (! isset ( $pid )) {
$pid = $_GET ['id'];
}
$requete = 'SELECT * FROM versions WHERE project_id = ?';
$req = $GLOBALS ['bdd']->prepare ( $requete );
$req->execute ( array (
$pid
) );
// ADDPOINT langage
$versions = array (
array (),
array ()
);
while ( $rep = $req->fetch () ) {
$versions [$rep ['language']] [] = array (
'versionAbs' => $rep ['versionAbs'],
'versionName' => $rep ['version']
);
}
$req->closeCursor ();
return $versions;
}
function getOwnersisProjects($sid = NULL) {
if (! isset ( $sid )) {
$sid = $_SESSION ['session_id'];
}
$requete = 'SELECT p.ownersID AS ownersID , p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.ownersID REGEXP \'[^0-9]?' . $sid . '[^0-9]?\' ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
return $projects;
}
function registerPerson($pseudo, $mdp) {
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" );
$req->execute ( array (
$_POST ['pseudo']
) );
if ($req->fetch ()) {
return 'usedPseudo';
} else {
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$_POST ['pseudo'],
password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT )
) );
return 'ok';
}
}
function getMessages($discut = NULL) {
if (! isset ( $discut )) {
$discut = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE discussion_id=? ORDER BY sendTime DESC" );
$req->execute ( array (
$discut
) );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 0)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscuts() {
$req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions ORDER BY date_creation DESC" );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 1)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscutInfos($did = NULL) {
if (! isset ( $did )) {
$did = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM discussions WHERE ID=?" );
$req->execute ( array (
$did
) );
return $req->fetch ();
}
function sendMessage($discut = NULL, $text = NULL, $sender = NULL) {
if (! isset ( $discut ) || ! isset ( $text ) || ! isset ( $sender )) {
$discut = $_GET ['d'];
$text = $_POST ['msg'];
$sender = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
$req->execute ( array (
$discut,
htmlspecialchars ( $text ),
$sender
) );
return 'ok';
}
function createDiscut($name = NULL, $owner = NULL) {
if (! isset ( $name ) || ! isset ( $owner )) {
$name = $_POST ['name'];
$owner = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO discussions(name,creator_id,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$name,
$owner
) );
return 'ok';
}
function testInt($var, $errorLocation = NULL) {
if (preg_match ( '#^[0-9]+$#', $var )) {
return intval ( $var );
} else {
if (isset ( $errorLocation )) {
header ( 'Location:' + $errorLocation );
exit ();
}
return null;
}
}
function getMessage($m = NULL) {
if (! isset ( $m )) {
$m = $_GET ['m'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE ID=?" );
$req->execute ( array (
$m
) );
if ($rep = $req->fetch ())
return $rep;
return - 1;
}
function removeMessage($m = NULL) {
if (! isset ( $m )) {
$m = $_GET ['m'];
}
$req = $GLOBALS ['bdd']->prepare ( "DELETE FROM messages WHERE ID=?" );
$req->execute ( array (
$m
) );
}
function changePassword($oldPassword = NULL, $newPassword = NULL, $newPasswordBis = NULL) {
if (! isset ( $oldPassword ) || ! isset ( $newPassword ) || ! isset ( $newPasswordBis )) {
$oldPassword = $_POST ['rmdp'];
$newPassword = $_POST ['nmdp'];
$newPasswordBis = $_POST ['nmdp2'];
}
if(!isConnected($_SESSION['session_id'],$oldPassword))
return 'falsePassword';
if($newPassword != $newPasswordBis)
return 'passwordMissmatch';
$req = $GLOBALS['bdd']->prepare('UPDATE users SET mdp=? WHERE ID=?');
$req->execute(array(password_hash ( $newPassword, PASSWORD_DEFAULT ),$_SESSION['session_id']));
return true;
}
function discutExists($did = NULL) {
if (! isset ( $did )) {
$did = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM discussions WHERE ID=?" );
$req->execute ( array (
$did
) );
return $req->fetch();
}
?>

View File

@ -1,11 +1,19 @@
<title>Le site de tous les bernards !</title>
<meta charset="utf-8" />
<meta name="keywords" lang="fr" content="cercloid officiel, zx project" />
<meta name="keywords" lang="fr" content="cercloid officiel, zeidhyx project" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="css/style.css" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
<script type="text/x-mathjax-config"> MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); </script>
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"> </script>
<script type="text/javascript">
var link = document.createElement( "link" );
link.type = "text/css";
link.rel = "stylesheet";
link.media = "screen,print";
if(!!navigator.userAgent.match(/firefox/i)){
link.href = "css/firefoxStyle.css";
}else{
link.href = "css/noFirefoxStyle.css";
}
document.getElementsByTagName("head")[0].appendChild( link );
</script>

210
index.php
View File

@ -2,124 +2,124 @@
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?></head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<h1>Bernard</h1>
<p><font size=4>J'ai le plaisir de vous souhaiter la bienvenue au sein de notre site: bernard.890m.com</font></p>
<article>
<div>
<div style="float:left;">
<h2><u><strong>ZX Project</strong></u></h2>
<a href="tempPreMega/intoDonut.png"><img src="tempPreMega/intoDonut.png" width="128" /></a>
</div>
<p>
2016/21/09 19h - A090 : T&eacute;l&eacute;chargement du workspace Eclipse <a href="tempPreMega/workspace.zip">ici</a> !
<br/> Eclipse Neon download:
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-win64.exe"> Win64</a>,
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-win32.exe"> Win32</a>,
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-linux64.tar.gz"> Linux64</a>,
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-linus32.tar.gz"> Linux32</a>,
<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-mac64.tar.gz"> Mac64</a>.
<br/> Nihil morati post haec militares avidi saepe turbarum adorti sunt Montium primum, qui divertebat in proximo, levi corpore senem
atque morbosum, et hirsutis resticulis cruribus eius innexis divaricaturn sine spiramento ullo ad usque praetorium traxere praefecti.Alii summum decus in
carruchis solito altioribus et ambitioso vestium cultu ponentes sudant sub ponderibus lacernarum, quas in collis insertas cingulis ipsis adnectunt nimia
subtegminum tenuitate perflabiles, expandentes eas crebris agitationibus maximeque sinistra, ut longiores fimbriae tunicaeque perspicue luceant varietate
liciorum effigiatae in species animalium multiformes.Haec dum oriens diu perferret, caeli reserato tepore Constantius consulatu suo septies et Caesaris
ter egressus Arelate Valentiam petit, in Gundomadum et Vadomarium fratres Alamannorum reges arma moturus, quorum crebris excursibus vastabantur confines
limitibus terrae Gallorum.Constituendi autem sunt qui sint in amicitia fines et quasi termini diligendi.De quibus tres video sententias ferri, quarum
nullam probo, unam, ut eodem modo erga amicum adfecti simus, quo erga nosmet ipsos, alteram, ut nostra in amicos benevolentia illorum erga nos
benevolentiae pariter aequaliterque respondeat, tertiam, ut, quanti quisque se ipse facit, tanti fiat ab amicis.Quid enim tam absurdum quam delectari
multis inanimis rebus, ut honore, ut gloria, ut aedificio, ut vestitu cultuque corporis, animante virtute praedito, eo qui vel amare vel, ut ita dicam,
redamare possit, non admodum delectari? Nihil est enim remuneratione benevolentiae, nihil vicissitudine studiorum officiorumque iucundius.
</p>
</div>
<hr><!--############### BlaBlaBla ###############-->
<div>
<div style="float:left;">
<h2><u><strong>Cerclo&iuml;de</strong></u></h2>
<a href="tempPreMega/cercloidCacahuete.png"><img src="tempPreMega/cercloidCacahuete.png" width="128" /></a>
</div>
$$C: \sum_{n=1}^N{\sqrt[p]{\sum_{g=1}^G{\left|F_{g,n}-A_n\right|^p}}}=R$$
<article id="cercloidOfficiel">
<h2 class="articleTitle"><strong>Cerclo&iuml;de</strong></h2>
<a class="articlePic" href="pictures/cercloid_cacahuete.png"><img src="pictures/cercloid_cacahuete.png" width="128" /></a>
<div class="articleText">
$$C: \sum_{n=1}^N{\sqrt[p]{\sum_{g=1}^G{\left|F_{g,n}-A_n\right|^p}}}=r$$
<ul>
<li>\(p \in \mathbb{R}^*\) l'exposant qui d&eacute;termine la norme utilis&eacute;</li>
<li>\(N \in \mathbb{N}^*\) le nombre de dimension de l'espace</li>
<li>\(G \in \mathbb{N}^*\) le nombre de foyer</li>
<li>\(R \in \mathbb{R}_+\) le rayon</li>
<li>\(A \in \mathbb{R}^N\) le point consid&eacute;r&eacute;</li>
<li>\(F \in (\mathbb{R}^N)^G\) le tableau de foyer</li>
<li>\(p \in \mathbb{R}^*\) : l'exposant qui d&eacute;termine la norme utilis&eacute;</li>
<li>\(N \in \mathbb{N}^*\) : le nombre de dimension de l'espace</li>
<li>\(G \in \mathbb{N}^*\) : le nombre de foyer</li>
<li>\(r \in \mathbb{R}_+\) : le rayon</li>
<li>\(A \in \mathbb{R}^N\) : le point consid&eacute;r&eacute;</li>
<li>\(F \in (\mathbb{R}^N)^G\) : le tableau de foyer</li>
</ul>
</div>
<hr><!--############### Laissez en bloc ###############-->
<div>
<h2 style="float:left;"><u><strong>Lorem Ipsum</strong></u></h2>
</article>
<article id="zeidhyxProject">
<h2 class="articleTitle"><strong>Zeidhyx Project</strong></h2>
<a class="articlePic" href="pictures/into_donut.png"><img src="pictures/into_donut.png" width="128" /></a>
<div class="articleText">
<p>
Eclipse Neon download: <a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-win64.exe"> Win64</a>|<a href="http://ftp-stud.fht-esslingen.de/Mirrors/eclipse/oomph/epp/neon/R/eclipse-inst-win32.exe">32</a>.<br/>
T&eacute;l&eacute;chargement du workspace Eclipse ici :
</p>
<ul>
<li>2016/09/21 19h : <a href="tempPreMega/zeidhyx1.zip">download</a></li>
<li>2016/10/15 23h : <a href="tempPreMega/zeidhyx2.zip">download</a></li>
</ul>
</div>
</article>
<article id="bezierCurve">
<h2 class="articleTitle"><strong>Courbe de B&eacute;zier</strong></h2>
<a class="articlePic" href="pictures/gebra_bezier_a_12.png"><img src="pictures/gebra_bezier_a_12.png" width="128" /></a>
<div class="articleText">
<ul>
<li>\(N \in \mathbb{N}^*\) : nombre de point n&eacute;cessaire pour d&eacute;crire la courbe.</li>
<li>\(p \in \mathbb{R}^N\) : tableau de points ordonn&eacute;s d&eacute;crivant la courbe (indices allant de 0 &agrave; N-1).</li>
<li>\(t \in [0;1]\) : param&egrave;tre de l'&eacute;quation param&eacute;trique.</li>
<li>\(n\) et \(m \in \mathbb{N}\) : variables it&eacute;ratives des sommations.</li>
</ul><br/>
$$b&eacute;zier(t, P) = \frac{\displaystyle\sum_{n=0}^{N-1}{\frac{t^{N-n-1} n! \displaystyle\sum_{m=0}^{N-1}{\frac{(-1)^{m-n-1}m!p_{N-m-1}}{(N-m-1)!(N-2m-1)!}}}{(N-n-1)!}}}{(N-1)!}$$
Nihil morati post haec militares avidi saepe turbarum adorti sunt Montium primum, qui divertebat in proximo, levi corpore senem
atque morbosum, et hirsutis resticulis cruribus eius innexis divaricaturn sine spiramento ullo ad usque praetorium traxere praefecti.Alii summum decus in
carruchis solito altioribus et ambitioso vestium cultu ponentes sudant sub ponderibus lacernarum, quas in collis insertas cingulis ipsis adnectunt nimia
subtegminum tenuitate perflabiles, expandentes eas crebris agitationibus maximeque sinistra, ut longiores fimbriae tunicaeque perspicue luceant varietate
liciorum effigiatae in species animalium multiformes.Haec dum oriens diu perferret, caeli reserato tepore Constantius consulatu suo septies et Caesaris
ter egressus Arelate Valentiam petit, in Gundomadum et Vadomarium fratres Alamannorum reges arma moturus, quorum crebris excursibus vastabantur confines
limitibus terrae Gallorum.Constituendi autem sunt qui sint in amicitia fines et quasi termini diligendi.De quibus tres video sententias ferri, quarum
nullam probo, unam, ut eodem modo erga amicum adfecti simus, quo erga nosmet ipsos, alteram, ut nostra in amicos benevolentia illorum erga nos
benevolentiae pariter aequaliterque respondeat, tertiam, ut, quanti quisque se ipse facit, tanti fiat ab amicis.Quid enim tam absurdum quam delectari
multis inanimis rebus, ut honore, ut gloria, ut aedificio, ut vestitu cultuque corporis, animante virtute praedito, eo qui vel amare vel, ut ita dicam,
redamare possit, non admodum delectari? Nihil est enim remuneratione benevolentiae, nihil vicissitudine studiorum officiorumque iucundius.Accenderat
super his incitatum propositum ad nocendum aliqua mulier vilis, quae ad palatium ut poposcerat intromissa insidias ei latenter obtendi prodiderat a
militibus obscurissimis.quam Constantina exultans ut in tuto iam locata mariti salute muneratam vehiculoque inpositam per regiae ianuas emisit in
publicum, ut his inlecebris alios quoque ad indicanda proliceret paria vel maiora.Haec igitur Epicuri non probo, inquam.De cetero vellem equidem aut
ipse doctrinis fuisset instructior est enim, quod tibi ita videri necesse est, non satis politus iis artibus, quas qui tenent, eruditi appellantur aut ne
deterruisset alios a studiis.quamquam te quidem video minime esse deterritum.Cuius acerbitati uxor grave accesserat incentivum, germanitate Augusti
turgida supra modum, quam Hannibaliano regi fratris filio antehac Constantinus iunxerat pater, Megaera quaedam mortalis, inflammatrix saevientis adsidua,
humani cruoris avida nihil mitius quam maritus; qui paulatim eruditiores facti processu temporis ad nocendum per clandestinos versutosque rumigerulos
conpertis leviter addere quaedam male suetos falsa et placentia sibi discentes, adfectati regni vel artium nefandarum calumnias insontibus adfligebant.
Quibus ita sceleste patratis Paulus cruore perfusus reversusque ad principis castra multos coopertos paene catenis adduxit in squalorem deiectos atque
maestitiam, quorum adventu intendebantur eculei uncosque parabat carnifex et tormenta.et ex is proscripti sunt plures actique in exilium alii, non nullos
gladii consumpsere poenales.nec enim quisquam facile meminit sub Constantio, ubi susurro tenus haec movebantur, quemquam absolutum.Sed quid est quod in
hac causa maxime homines admirentur et reprehendant meum consilium, cum ego idem antea multa decreverim, que magis ad hominis dignitatem quam ad rei
publicae necessitatem pertinerent? Supplicationem quindecim dierum decrevi sententia mea.Rei publicae satis erat tot dierum quot C.Mario ; dis
immortalibus non erat exigua eadem gratulatio quae ex maximis bellis.Ergo ille cumulus dierum hominis est dignitati tributus.Sed maximum est in amicitia
parem esse inferiori.Saepe enim excellentiae quaedam sunt, qualis erat Scipionis in nostro, ut ita dicam, grege.Numquam se ille Philo, numquam Rupilio,
numquam Mummio anteposuit, numquam inferioris ordinis amicis, Q.vero Maximum fratrem, egregium virum omnino, sibi nequaquam parem, quod is anteibat aetate,
tamquam superiorem colebat suosque omnes per se posse esse ampliores volebat.Dum haec in oriente aguntur, Arelate hiemem agens Constantius post theatralis
ludos atque circenses ambitioso editos apparatu diem sextum idus Octobres, qui imperii eius annum tricensimum terminabat, insolentiae pondera gravius
librans, siquid dubium deferebatur aut falsum, pro liquido accipiens et conperto, inter alia excarnificatum Gerontium Magnentianae comitem partis exulari
maerore multavit.Haec et huius modi quaedam innumerabilia ultrix facinorum impiorum bonorumque praemiatrix aliquotiens operatur Adrastia atque utinam
semper quam vocabulo duplici etiam Nemesim appellamus: ius quoddam sublime numinis efficacis, humanarum mentium opinione lunari circulo superpositum,
el ut definiunt alii, substantialis tutela generali potentia partilibus praesidens fatis, quam theologi veteres fingentes Iustitiae filiam ex abdita
quadam aeternitate tradunt omnia despectare terrena.Adolescebat autem obstinatum propositum erga haec et similia multa scrutanda, stimulos admovente
regina, quae abrupte mariti fortunas trudebat in exitium praeceps, cum eum potius lenitate feminea ad veritatis humanitatisque viam reducere utilia
suadendo deberet, ut in Gordianorum actibus factitasse Maximini truculenti illius imperatoris rettulimus coniugem.Quam ob rem ut ii qui superiores
suntubmittere se debent in amicitia, sic quodam modo inferiores extollere.Sunt enim quidam qui molestas amicitias faciunt, cum ipsi se contemni putant;
quod non fere contingit nisi iis qui etiam contemnendos se arbitrantur; qui hac opinione non modo verbis sed etiam opere levandi sunt.Auxerunt haec vulgi
sordidioris audaciam, quod cum ingravesceret penuria commeatuum, famis et furoris inpulsu Eubuli cuiusdam inter suos clari domum ambitiosam ignibus
subditis inflammavit rectoremque ut sibi iudicio imperiali addictum calcibus incessens et pugnis conculcans seminecem laniatu miserando discerpsit.post
cuius lacrimosum interitum in unius exitio quisque imaginem periculi sui considerans documento recenti similia formidabat.Utque aegrum corpus quassari
etiam levibus solet offensis, ita animus eius angustus et tener, quicquid increpuisset, ad salutis suae dispendium existimans factum aut cogitatum,
insontium caedibus fecit victoriam luctuosam.Proinde concepta rabie saeviore, quam desperatio incendebat et fames, amplificatis viribus ardore incohibili
in excidium urbium matris Seleuciae efferebantur, quam comes tuebatur Castricius tresque legiones bellicis sudoribus induratae.Eius populus ab
incunabulis primis ad usque pueritiae tempus extremum, quod annis circumcluditur fere trecentis, circummurana pertulit bella, deinde aetatem ingressus
adultam post multiplices bellorum aerumnas Alpes transcendit et fretum, in iuvenem erectus et virum ex omni plaga quam orbis ambit inmensus, reportavit
laureas et triumphos, iamque vergens in senium et nomine solo aliquotiens vincens ad tranquilliora vitae discessit.Incenderat autem audaces usque ad
insaniam homines ad haec, quae nefariis egere conatibus, Luscus quidam curator urbis subito visus: eosque ut heiulans baiolorum praecentor ad expediendum
quod orsi sunt incitans vocibus crebris.qui haut longe postea ideo vivus exustus est.
<br/><ul>
<li>Avec 1 point, la courbe est ce point.</li>
<li>Avec 2 points, la courbe est un fragment de droite, le segment reliant ces deux points.</li>
<li>Avec N points, la courbe est un fragment de courbe de degr&eacute; N-1, comman&ccedil;ant au point 0 et se terminant au point N-1.</li>
</ul>
<div style="color: #222;">Geogebra tester in works : <a href="tempPreMega/bezierN.ggb" style="color: #222;">download</a> (version 201603121831)</div>
Pour ceux qui pr&eacute;f&egrave;rent, voici un petit algorithme r&eacute;cursif fonctionnant normalement pour 2 dimensions.<br/><!-- Ca fait pas beaucoup :p -->
<br/><code><!-- Je verrais plus tard pour faire un css, voir un peu de js, pour que le <code> soit plus lisible, de l interieur comme de l exterieur -->
public static Point recursiveBezier(double t,Point... p){<br/>
&nbsp;&nbsp;Point[] out = new Point[points.length-1];<br/>
&nbsp;&nbsp;for(int i = 1; i &lt; p.length; i++)<br/>
&nbsp;&nbsp;&nbsp;&nbsp;out[i-1] = p[i-1].set(p[i-1].x + t*(p[i].x-p[i-1].x), p[i-1].y + t*(p[i].y-p[i-1].y));<br/>
&nbsp;&nbsp;return (out.lenght == 1) ? out[0] : recursiveBezier(t, out);<br/><!-- voila ta punition, mechant -->
}<br/>
</code>
</div>
</article>
<article id="administration">
<h2 class="articleTitle"><strong>Administration</strong></h2>
<div class="articleText">
<ol>
<!-- 01 --><li>Coming soon (or not)</li>
<!-- 02 --><li>Possibilit&eacute; de cr&eacute;er des discussions</li>
<!-- 03 --><li>Coming soon (or not)</li>
<!-- 04 --><li>Coming soon (or not)</li>
<!-- 05 --><li>Coming soon (or not)</li>
<!-- 06 --><li>Possibilit&eacute; d'editer ou de supprimer n'importe quel message</li>
<!-- 07 --><li>Coming soon (or not)</li>
<!-- 08 --><li>Coming soon (or not)</li>
<!-- 09 --><li>Coming soon (or not)</li>
<!-- 10 --><li>Coming soon (or not)</li>
<!-- 11 --><li>Coming soon (or not)</li>
<!-- 12 --><li>Acc&egrave;s en t&eacute;l&eacute;chargement des fichiers des projets m&ecirc;me priv&eacute;s</li>
<!-- 13 --><li>Coming soon (or not)</li>
<!-- 14 --><li>Acc&egrave;der &agrave; toutes les discussions (m&ecirc;me priv&eacute;es)</li>
<!-- 15 --><li>Acc&egrave;s &agrave; la pass&eacute;e console d'administration</li>
</ol>
</div>
</article>
<article id="disorderer">
<h2 class="articleTitle">Formules en vrac</h2>
<div class="articleText">
<ul>
<li>\(e^{i\pi} + 1 = 0\)</li>
<li>\(\pi = \frac{9801}{2\sqrt{2} \displaystyle\sum^{+\infty}_{n=0} \frac{(4n)!}{(n!)^4} \times \frac{[1103 + 26390n]}{(4 \times 99)^{4n}}} = 6\displaystyle\sum^{+\infty}_{n=1}{\frac{1}{n^2}}\)</li>
<li>\(\begin{pmatrix} 1 &amp; 0 &amp; 0 \\ 0 &amp; \cos \alpha &amp; -\sin \alpha \\ 0 &amp; \sin \alpha &amp; \cos \alpha \\ \end{pmatrix} \begin{pmatrix} \cos \beta &amp; 0 &amp; \sin \beta \\ 0 &amp; 1 &amp; 0 \\ -\sin \beta &amp; 0 &amp; \cos \beta \\ \end{pmatrix} \begin{pmatrix} \cos \gamma &amp; -\sin \gamma &amp; 0 \\ \sin \gamma &amp; \cos \gamma &amp; 0 \\ 0 &amp; 0 &amp; 1 \\ \end{pmatrix}\), la matrice de rotation dans \(\mathbb{R}^3\) d'angle \(\alpha\) autour de l'axe x, \(\beta\) autour de y et \(\gamma\) autour de z.</li>
</ul>
</div>
</article>
<?php include 'includes/footer.php'; ?>
<?php
if(isset($_GET['i'])){
if($_GET['i'] == 0){
echo "<script>alert('Connexion effectuee avec succes !')</script>";
}
}
?>
</body>
</html>

262
inter.php Normal file
View File

@ -0,0 +1,262 @@
<?php
include_once 'includes/bdd.php';
function isConnected($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
if ($rep = $req->fetch ()) {
$connected = password_verify ( $mdp, $rep ['mdp'] );
} else {
$connected = FALSE;
}
$req->closeCursor ();
return $connected;
}
function getAdminLevel($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return - 1;
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
if ($result = $req->fetch ()) {
$adminLevel = $result ['administration'];
} else {
$adminLevel = - 1;
}
$req->closeCursor ();
return $adminLevel;
}
function getPseudo($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return "neant";
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function getPseudoOf($sid) {
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function tryToConnect($pseudo = NULL, $mdp = NULL) {
if (! isset ( $pseudo ) or ! isset ( $mdp )) {
$pseudo = $_POST ['pseudo'];
$mdp = $_POST ['mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' );
$req->execute ( array (
$pseudo
) );
$reponce = $req->fetch ();
if ($reponce != NULL) {
if (password_verify ( $mdp, $reponce ['mdp'] )) {
$req->closeCursor ();
return $reponce ['ID'];
} else {
$req->closeCursor ();
return 'errormdp';
}
} else {
$req->closeCursor ();
return 'errorpseudo';
}
}
function getProjectVersionData($project = NULL, $version = NULL) {
if (! isset ( $project ) or ! isset ( $version )) {
$project = $_GET ['id'];
$version = $_GET ['v'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS pID ,' . ' ' . 'v.versionAbs AS versionAbs , ' . ' ' . 'p.name AS name ,' . ' ' . 'v.version AS version ,' . ' ' . 'v.language AS language ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'INNER JOIN versions AS v' . ' ' . 'ON v.project_id = p.ID' . ' ' . 'WHERE v.project_id = ? AND v.versionAbs = ?' );
$req->execute ( array (
$project,
$version
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
}
function getProjectData($project = NULL) {
if (! isset ( $project )) {
$project = $_GET ['id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS ID ,' . ' ' . 'p.name AS name ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'WHERE p.ID = ?' );
$req->execute ( array (
$project
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
}
function getPermissions($data) {
$permissions = array (
FALSE,
FALSE,
FALSE,
FALSE
);
$permissions [0] = preg_match ( '#^1#', $data ['permissions'] );
$permissions [1] = preg_match ( '#^(0|1)1#', $data ['permissions'] );
$permissions [2] = preg_match ( '#^(0|1){2}1#', $data ['permissions'] );
$permissions [3] = preg_match ( '#^(0|1){3}1#', $data ['permissions'] );
return $permissions;
}
function getProjectsWithFirstPermission() {
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.permissions LIKE "1%" ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
$req->closeCursor ();
return $projects;
}
function getVersions($pid = NULL) {
if (! isset ( $pid )) {
$pid = $_GET ['id'];
}
$requete = 'SELECT * FROM versions WHERE project_id = ?';
$req = $GLOBALS ['bdd']->prepare ( $requete );
$req->execute ( array (
$pid
) );
// ADDPOINT langage
$versions = array (
array (),
array ()
);
while ( $rep = $req->fetch () ) {
$versions [$rep ['language']] [] = array (
'versionAbs' => $rep ['versionAbs'],
'versionName' => $rep ['version']
);
}
$req->closeCursor ();
return $versions;
}
function getOwnersisProjects($sid = NULL) {
if (! isset ( $sid )) {
$sid = $_SESSION ['session_id'];
}
$requete = 'SELECT p.ownersID AS ownersID , p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.ownersID REGEXP \'[^0-9]?' . $sid . '[^0-9]?\' ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
return $projects;
}
function registerPerson($pseudo, $mdp) {
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" );
$req->execute ( array (
$_POST ['pseudo']
) );
if ($req->fetch ()) {
return 'usedPseudo';
} else {
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$_POST ['pseudo'],
password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT )
) );
return 'ok';
}
}
function getMessages($discut = NULL) {
if (! isset ( $discut )) {
$discut = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE discussion_id=? ORDER BY sendTime DESC" );
$req->execute ( array (
$discut
) );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 0)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscuts() {
$req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions ORDER BY date_creation DESC" );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 1)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscutInfos($did = NULL) {
if(!isset($did)){
$did = $_GET['d'];
}
$req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions WHERE ID=?" );
return $req->fetch();
}
function sendMessage($discut = NULL, $text = NULL, $sender = NULL) {
if (! isset ( $discut ) || ! isset ( $text ) || ! isset ( $sender )) {
$discut = $_GET ['d'];
$text = $_POST ['msg'];
$sender = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
$req->execute ( array (
$discut,
htmlspecialchars ( $text ),
$sender
) );
return 'ok';
}
function createDiscut($name = NULL, $owner = NULL) {
if (! isset ( $name ) || ! isset ( $owner )) {
$name = $_POST ['name'];
$owner = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO discussions(name,creator_id,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$name,
$owner
) );
return 'ok';
}

View File

@ -1,26 +1,25 @@
<?php
session_start();
include_once 'includes/bdd.php';
include_once 'includes/inter.php';
$req=$bdd->prepare('SELECT * FROM users WHERE pseudo=?');
$req->execute(array($_POST['pseudo']));
$reponce=$req->fetch();
if($reponce != null){
if($reponce['mdp']===$_POST['mdp']){
$_SESSION['session_id'] = $reponce['ID'];
$_SESSION['session_mdp'] = $reponce['mdp'];
header('Location:index.php?i=0');
}else{
header('Location:login.php?i=2');
}
}else{
header('Location:login.php?i=1');
}
$result = tryToConnect();
switch($result){
case 'errormdp':
header('Location:login.php');
$_SESSION['current_error'] = 'Mot de passe incorrect ...';
break;
case 'errorpseudo':
header('Location:login.php');
$_SESSION['current_error'] = 'Nom d\'utilisateur incorrect ...';
break;
default:
echo $result;
echo $_POST['mdp'];
$_SESSION['session_id'] = $result;
$_SESSION['session_mdp'] = $_POST['mdp'];
$_SESSION['current_error'] = 'Vous &ecirc;tes bien connect&eacute; (vous l\'avez &eacute;t&eacute; et le serez &eacutegalement)!';
header('Location:index.php');
break;
$req->closeCursor();
?>
}

View File

@ -11,15 +11,15 @@
<form id="loginForm" method="post" action="logging.php">
<label for="pseudo">Pseudo :</label>
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" required/>
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" />
<br/>
<label for="mdp">Mot de passe :</label>
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" required/>
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" />
<br/>
<input type="Submit" value="Se connecter">
</form>
<?php include 'includes/foot.php' ?>
<?php include 'includes/footer.php' ?>
<?php
if(isset($_GET['i'])){
if($_GET['i'] == 1){

57
mandelbrot.html Normal file
View File

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html>
<head>
<?php session_start();?>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<canvas id="mandelbrot" width="500" height="500">walou</canvas>
BIS
<script type="text/javascript">
window.onload = function() {
var canvas = document.getElementById('mandelbrot');
if (!canvas) {
alert("Impossible de récupérer le canvas");
return;
}
var context = canvas.getContext('2d');
if (!context) {
alert("Impossible de récupérer le context du canvas");
return;
}
context.fillStyle = "#ff0000";
var x1 = -2.1, x2 = 0.6, y1 = -1.2, y2 = 1.2, zoom = 100, iterations_max = 50, image_x = (x2 - x1)
* zoom, image_y = (y2 - y1) * zoom;
canvas.width = image_x;
canvas.heigth = image_y;
for (x = 0; x < image_x; x++) {
for (y = 0; y < image_y; y++) {
c_r = x / zoom + x1;
c_i = y / zoom + y1;
z_r = 0;
z_i = 0;
i = 0;
do {
var tmp = z_r;
z_r = z_r * z_r - z_i * z_i + c_r;
z_i = 2 * tmp * z_i + c_i;
i++;
} while (z_r * z_r + z_i * z_i < 4 && i < iterations_max);
if (i == iterations_max) {
context.fillStyle = "#FFFFFF";
context.fillRect(x, y, 1, 1);
}else{
context.fillStyle = "rgb(0, 0, "+255-(i*255/iterations_max)+")";
context.fillRect(x,y,1,1);
}
alert('done');
}
}
}
</script>

View File

@ -0,0 +1,47 @@
<?php
session_start();
echo ('extensions:"'.ini_get('extension_dir').'"');
include_once "../includes/bdd.php";
include_once "../includes/inter.php";
include_once "megaapi.php";
$permissions = array (
FALSE,
FALSE,
FALSE,
FALSE
);
$connected = isConnected ();
$owner = FALSE;
$adminLevel = - 1;
$data = NULL;
if (isset ( $_GET ['id'] ) && isset ( $_GET ['v'] )) {
$data = getProjectVersionData( $_GET ['id'], $_GET ['v'] );
if ($data != NULL) {
$permissions = getPermissions( $data );
} else {
header('Location:../40A.php');
goto end;
}
} else {
header('Location:../40A.php');
goto end;
}
if (! $connected) {
header( 'Location:../401.php' );
goto end;
}
$owner = preg_match ( '#[^0-9]?' . $_SESSION ['session_id'] . '[^0-9]?#', $data ['owners'] );
$adminLevel = getAdminLevel ();
if (! $owner && $adminLevel < 12) {
header( 'Location:../403.php' );
goto end;
}
$megaapi = new MegaApiPHP("mA9D1IQQ", "PHP bernard.com");
$megaapi->login("bernard.lafayette63@gmail.com", "*******************");
$node = $megaapi->getNodeByPath('imageFinal.jpg', $megaapi->getRootNode());
$megaapi->startDownload($node, './');
end:

3618
megaProcess/mega.php Normal file

File diff suppressed because it is too large Load Diff

1115
megaProcess/megaapi.php Normal file

File diff suppressed because it is too large Load Diff

688
megaProcess/megacli.php Normal file
View File

@ -0,0 +1,688 @@
#!/usr/bin/env php
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
set_time_limit(0);
set_include_path(get_include_path() . PATH_SEPARATOR . "../../bindings/php");
include 'megaapi.php';
require_once('vendor/autoload.php');
use Symfony\Component\Console\Shell;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
$megaapi = NULL;
$cwd = NULL;
class AppListener implements MegaListenerInterface
{
public function onRequestStart($megaApi, $request)
{
}
public function onRequestFinish($megaApi, $request, $error)
{
global $cwd;
if($error->getErrorCode() != MegaError::API_OK)
{
print("INFO: Request finished with error ( " . $request . " ) Result: " . $error . "\n");
print("MEGA > ");
return;
}
$requestType = $request->getType();
if($requestType == MegaRequest::TYPE_LOGIN)
{
print("Fetchning nodes. Please wait...\n");
print("MEGA > ");
$megaApi->fetchNodes();
}
else if($requestType == MegaRequest::TYPE_FETCH_NODES)
{
print("Account correctly loaded\n");
print("MEGA > ");
$cwd = $megaApi->getRootNode();
}
else if($requestType == MegaRequest::TYPE_EXPORT)
{
print("INFO: Exported link: " . $request->getLink() . "\n");
print("MEGA > ");
}
else if($requestType == MegaRequest::TYPE_ACCOUNT_DETAILS)
{
$accountDetails = $request->getMegaAccountDetails();
print("INFO: Account details received\n");
print("Account e-mail: " . $megaApi->getMyEmail() . "\n");
print("Storage: " . $accountDetails->getStorageUsed() . " of " . $accountDetails->getStorageMax() .
" (" . (100 * $accountDetails->getStorageUsed() / $accountDetails->getStorageMax()) . "%)\n");
print("Pro level: " . $accountDetails->getProLevel() . "\n");
print("MEGA > ");
}
}
public function onRequestTemporaryError($megaApi, $request, $error)
{
print("INFO: Request temporary error ( " . $request . " ) Error: " + $error . "\n");
}
public function onTransferStart($megaApi, $transfer)
{
print("INFO: Transfer start ( " . $transfer . " " . $transfer->getFileName() . " )\n");
}
public function onTransferFinish($megaApi, $transfer, $error)
{
print("INFO: Transfer finished ( " . $transfer . " " . $transfer->getFileName() . " ) Result: " . $error . "\n");
print("MEGA > ");
}
public function onTransferUpdate($megaApi, $transfer)
{
print("INFO: Transfer update ( " . $transfer . " " . $transfer->getFileName() . " ) Progress: " . $transfer->getTransferredBytes()/1024 ." KB of " . $transfer->getTotalBytes()/1024 . " KB, " . $transfer->getSpeed()/1024 . " KB/s\n");
}
public function onTransferTemporaryError($megaApi, $request, $error)
{
print("INFO: Transfer temporary error ( " . $transfer . " " . $transfer->getFileName() . " ) Error: " . $error . "\n");
}
public function onUsersUpdate($megaApi, $users)
{
}
public function onNodesUpdate($megaApi, $nodes)
{
global $cwd;
if($nodes != NULL)
{
print("INFO: Nodes updated ( " . count($nodes) . " )\n");
print("MEGA > ");
}
else
$cwd = $megaApi->getRootNode();
}
public function onReloadNeeded($megaApi)
{
}
}
class LoginCommand extends Command
{
protected function configure()
{
$this->setName('login');
$this->setDescription('Log in to a MEGA account');
$this->addArgument('email', InputArgument::REQUIRED, 'Email of the account');
$this->addArgument('password', InputArgument::REQUIRED, 'Password of the account');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
$email = $input->getArgument('email');
$password = $input->getArgument('password');
$megaapi->login($email, $password);
}
}
class LogoutCommand extends Command
{
protected function configure()
{
$this->setName('logout');
$this->setDescription('Log out a MEGA account');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
$megaapi->logout();
$cwd = null;
}
}
class LsCommand extends Command
{
protected function configure()
{
$this->setName('ls');
$this->setDescription('List a MEGA folder');
$this->addArgument('path', InputArgument::OPTIONAL, 'folder path');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$path = $input->getArgument('path');
if ($path)
{
$folder = $megaapi->getNodeByPath($path, $cwd);
}
else
{
$folder = $cwd;
}
$output->writeln(" .");
if($megaapi->getParentNode($folder) != NULL)
{
$output->writeln(" ..");
}
$children = $megaapi->getChildren($folder);
foreach($children as $node)
{
$output->write(" " . $node->getName());
if($node->getType() == MegaNode::TYPE_FILE)
{
$output->writeln(" (" . $node->getSize() . " bytes)");
}
else
{
$output->writeln(" (folder)");
}
}
}
}
class MkdirCommand extends Command
{
protected function configure()
{
$this->setName('mkdir');
$this->setDescription('Create a folder');
$this->addArgument('name', InputArgument::REQUIRED, 'folder name');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$name = $input->getArgument('name');
$megaapi->createFolder($name, $cwd);
}
}
class CdCommand extends Command
{
protected function configure()
{
$this->setName('cd');
$this->setDescription('Change the current directory');
$this->addArgument('path', InputArgument::REQUIRED, 'new current directory');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$path = $input->getArgument('path');
$new = $megaapi->getNodeByPath($path, $cwd);
if($new == null)
{
$output->writeln("Invalid path");
return;
}
$cwd = $new;
}
}
class MvCommand extends Command
{
protected function configure()
{
$this->setName('mv');
$this->setDescription('Move a file/folder');
$this->addArgument('source', InputArgument::REQUIRED, 'Source file/folder');
$this->addArgument('destination', InputArgument::REQUIRED, 'Destination file/folder');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$source = $input->getArgument('source');
$name = $input->getArgument('destination');
$srcNode = $megaapi->getNodeByPath($source, $cwd);
if($srcNode == null)
{
$output->writeln($source . ": No such file or directory");
return;
}
$dstNode = $megaapi->getNodeByPath($name, $cwd);
if(($dstNode != null) && $dstNode->isFile())
{
$output->writeln($name . ": Not a directory");
return;
}
if($dstNode != null)
{
$megaapi->moveNode($srcNode, $dstNode);
return;
}
if(strpos($name,"/") !== false || strpos($name,"\\") !== false)
{
$str1 = strrchr($name, "/");
$str2 = strrchr($name, "\\");
$index = null;
if($str2 == FALSE || strlen($str1) < strlen($str2))
{
echo "A\n";
$index = strlen($name) - strlen($str1);
}
else
{
echo "B\n";
$index = strlen($name) - strlen($str2);
}
$path = substr($name, 0, $index);
$base = $megaapi->getNodeByPath($path, $cwd);
$name = substr($name, $index+1);
echo "INDEX: " . $index . "\n";
echo "str1: " . $str1 . "\n";
echo "str2: " . $str2 . "\n";
echo "PATH: " . $path . "\n";
echo "NAME: " . $name . "\n";
if($base == null)
{
$output->writeln($path . ": Not such directory");
return;
}
if($base->isFile())
{
$output->writeln($path . ": Not a directory");
return;
}
$megaapi->moveNode($srcNode, $base);
if(strlen($name) != 0)
{
$megaapi->renameNode($srcNode, $name);
}
return;
}
if($dstNode == null)
{
$megaapi->renameNode($srcNode, $name);
}
}
}
class PwdCommand extends Command
{
protected function configure()
{
$this->setName('pwd');
$this->setDescription('Get the current working directory');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$output->writeln($megaapi->getNodePath($cwd));
}
}
class RmCommand extends Command
{
protected function configure()
{
$this->setName('rm');
$this->setDescription('Remove a file/folder');
$this->addArgument('path', InputArgument::REQUIRED, 'Path to file/folder to delete');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$path = $input->getArgument('path');
$node = $megaapi->getNodeByPath($path, $cwd);
if($node == null)
{
$output->writeln("Invalid path");
return;
}
$megaapi->remove($node);
}
}
class GetCommand extends Command
{
protected function configure()
{
$this->setName('get');
$this->setDescription('Download a file from MEGA');
$this->addArgument('path', InputArgument::REQUIRED, 'Path to the file');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$path = $input->getArgument('path');
$node = $megaapi->getNodeByPath($path, $cwd);
if($node == null)
{
$output->writeln("Invalid path");
return;
}
if(!$node->isFile())
{
$output->writeln("Not a file");
return;
}
$megaapi->startDownload($node, "./");
}
}
class PutCommand extends Command
{
protected function configure()
{
$this->setName('put');
$this->setDescription('Upload a file to MEGA');
$this->addArgument('path', InputArgument::REQUIRED, 'Path to the local file');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$path = $input->getArgument('path');
$megaapi->startUpload($path, $cwd);
}
}
class ExportCommand extends Command
{
protected function configure()
{
$this->setName('export');
$this->setDescription('Generate a public link');
$this->addArgument('path', InputArgument::REQUIRED, 'Path to the file/folder in MEGA');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$path = $input->getArgument('path');
$node = $megaapi->getNodeByPath($path, $cwd);
if($node == null)
{
$output->writeln("Invalid path");
return;
}
$megaapi->exportNode($node);
}
}
class ImportCommand extends Command
{
protected function configure()
{
$this->setName('import');
$this->setDescription('Import a MEGA public file link');
$this->addArgument('link', InputArgument::REQUIRED, 'Public MEGA file link');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$link = $input->getArgument('link');
$megaapi->importFileLink($link, $cwd);
}
}
class PasswdCommand extends Command
{
protected function configure()
{
$this->setName('passwd');
$this->setDescription('Change the access password');
$this->addArgument('current_password', InputArgument::REQUIRED, 'Current password');
$this->addArgument('new_password', InputArgument::REQUIRED, 'New password');
$this->addArgument('repeat_new_password', InputArgument::REQUIRED, 'New password');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$current_password = $input->getArgument('current_password');
$new_password = $input->getArgument('new_password');
$repeat_new_password = $input->getArgument('repeat_new_password');
if($new_password != $repeat_new_password)
{
$output->writeln("Error: Password mismatch");
return;
}
$megaapi->changePassword($current_password, $new_password);
}
}
class WhoamiCommand extends Command
{
protected function configure()
{
$this->setName('whoami');
$this->setDescription('Show info about the current user');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$output->writeln($megaapi->getMyEmail());
$megaapi->getAccountDetails();
}
}
class MountCommand extends Command
{
protected function configure()
{
$this->setName('mount');
$this->setDescription('Show incoming shares');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
global $megaapi;
global $cwd;
if($cwd == null)
{
$output->writeln("Not logged in");
return;
}
$output->writeln("INFO: INSHARES:");
$users = $megaapi->getContacts();
foreach($users as $user)
{
$megaapi->getInShares();
$inshares = $megaapi->getInShares($user);
foreach($inshares as $share)
{
$output->writeln("INFO: INSHARE on " . $user->getEmail() . " " . $share->getName() . " Access level: " . $megaapi->getAccess($share));
}
}
}
}
class ExitCommand extends Command
{
protected function configure()
{
$this->setName('exit');
$this->setDescription('Exit the app');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
exit(0);
}
}
class QuitCommand extends ExitCommand
{
protected function configure()
{
$this->setName('quit');
$this->setDescription('Exit the app');
}
}
MegaApi::setLogLevel(MegaApi::LOG_LEVEL_ERROR);
$applistener = new AppListener();
$megaapi = new MegaApiPHP("API_KEY", "PHP megacli");
$megaapi->addListener($applistener);
$application = new Application('MEGA', 'PHP');
$application->add(new LoginCommand());
$application->add(new LogoutCommand());
$application->add(new LsCommand());
$application->add(new MkdirCommand());
$application->add(new CdCommand());
$application->add(new PwdCommand());
$application->add(new RmCommand());
$application->add(new GetCommand());
$application->add(new PutCommand());
$application->add(new ExitCommand());
$application->add(new QuitCommand());
$application->add(new ExportCommand());
$application->add(new ImportCommand());
$application->add(new WhoamiCommand());
$application->add(new PasswdCommand());
$application->add(new MountCommand());
$application->add(new MvCommand());
$shell = new Shell($application);
$shell->run();
?>

46
newVersion.php Normal file
View File

@ -0,0 +1,46 @@
<?php
session_start ();
include_once 'includes/inter.php';
?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php include_once 'includes/inter.php';
$data = getProjectData();
if(!isConnected()){
header("Location:401.php");
goto end;
}else if(!preg_match('#[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?#',$data ['owners'])){
header("Location:403.php");
goto end;
}
?>
<br />
<br />
<br />
<br />
<form action="creatingVersion.php?id=<?php $_GET['id'];?>" method="post">
<label for="newVersionName">Nom de la version :</label> <input
type="text" maxlength="100" id="newVersionName" name="name" /><br />
<br />
<select name="language">
<option value="Java">Java</option>
<option value="VBA">VBA</option>
</select><br />
<br />
<input type="submit" value="Cr&eacute;er une nouvelle version" />
</form>
<br />
<br />
<br />
<br />
<?php include 'includes/footer.php'; ?>
</body>
</html>
<?php
end:
?>

View File

@ -12,23 +12,9 @@
<h1>Tous les projets</h1>
<?php
include_once 'includes/bdd.php';
include_once 'includes/inter.php';
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE p.permissions LIKE "1%" ';
$req = $bdd->query($requete)or die(print_r($bdd->errorInfo()));
$projects = array();
while($rep = $req->fetch()){
if(!isset($projects[$rep['projectID']])){
$projects[$rep['projectID']] = $rep;
}else if($projects[$rep['projectID']]['versionAbs'] < $rep['versionAbs']){
$projects[$rep['projectID']] = $rep;
}
}
$projects = getProjectsWithFirstPermission();
foreach($projects as $project){
echo ('<a href="projet.php?id='. $project['projectID'] .'&amp;v='. $project['versionAbs'] .'">Le projet ' . $project['projectName'] . ' en version ' . $project['versionName'] . '</a><br/>');

Binary file not shown.

Binary file not shown.

BIN
pictures/hexa_soucoupe.png Normal file

Binary file not shown.

BIN
pictures/into_donut.png Normal file

Binary file not shown.

Binary file not shown.

BIN
pictures/water.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 KiB

16
posting_message.php Normal file
View File

@ -0,0 +1,16 @@
<?php
session_start();
include_once 'includes/inter.php';
if(!isConnected()){
header('Location:403.php');
goto end;
}else if(!discutExists()){ header ( 'Location:40A.php' ); goto end;}else if(preg_match("#^p$#",$disc['autorized']) || (preg_match("#^a[0-9]+$#",$disc['autorized']))?substr($disc['autorized'],1)<=$adminLevel:FALSE || preg_match('#^x([0-9];)*' . $_SESSION['session_id'] . '(;[0-9])*$#',$disc['autorized']) || $adminLevel>=14){
header('Location:401.php');
goto end;
}
sendMessage();
header('Location:discut.php?d='.$_GET['d']);
end:

View File

@ -8,26 +8,21 @@
<?php include 'includes/header.php'; ?>
<?php
include_once 'includes/bdd.php';
include_once 'includes/inter.php';
$req=$bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?');
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp']));
}
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && $req->fetch() ){
if(isConnected()){
?>
<form method="post" action="change_password.php" id="changePasswordForm">
Changer le mot de passe :<br/>
<label for="real_mdp_ask">Votre ancien mot de passe :</label>
<input type="password" id="real_mdp_ask" name="rmdp" required/>
<input type="password" id="real_mdp_ask" name="rmdp" />
<br/>
<label for="new_mdp2_ask">Votre nouveau mot de passe :</label>
<input type="password" id="new_mdp_ask" name="nmdp" required/>
<input type="password" id="new_mdp_ask" name="nmdp" />
<br/>
<label for="new_mdp2_ask">R&eacute;p&eacute;tez-le :</label>
<input type="password" id="new_mdp2_ask" name="nmdp2" required/>
<input type="password" id="new_mdp2_ask" name="nmdp2" />
<br/>
<input type="submit" value="Changer le mot de passe">
</form>

View File

@ -1,156 +1,120 @@
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<!DOCTYPE html>
<html>
<head>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<body>
<?php include 'includes/header.php'; ?>
<?php
include_once 'includes/inter.php';
$permissions = array (
FALSE,
FALSE,
FALSE,
FALSE
);
$connected = isConnected ();
$owner = FALSE;
$data = array ();
if (isset ( $_GET ['id'] ) && isset ( $_GET ['v'] )) {
$data = getProjectVersionData ();
if ($data == NULL) {
$permissions = getPermissionsWithData ( $data );
} else {
header ( 'Location:40A.php' );
goto end;
}
} else {
header ( 'Location:40A.php' );
goto end;
}
if ($connected)
$owner = preg_match ( '[^0-9]?' . $_SESSION ['session_id'] . '[^0-9]?', $data ['owners'] );
if ($permissions [0] || $owner) {
?>
<?php
include_once 'includes/inter.php';
$permissions=array(FALSE,FALSE,FALSE,FALSE);
$connected = isConnected();
$owner = FALSE;
$adminLevel=-1;
$data = array();
if(isset($_GET['id']) && isset($_GET['v'])){
$data = getProjectVersionData($_GET['id'],$_GET['v']);
if($data != NULL){
$permissions = getPermissions($data);
}else{
header('Location:40A.php');
goto end;
}
}else{
header('Location:40A.php');
goto end;
}
if($connected)
$owner = preg_match('#[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?#',$data ['owners']);
$adminLevel = getAdminLevel();
if($permissions[0] || $owner){
?>
<h1>Le projet <?php echo($data['name']) ?> en version <?php echo($data['version']) ?></h1>
<br />
<?php if($rep['language'] == 0){?>
<a class="project_option"
href=<?php if($permissions[1]){ echo( '"megaProcess/downloadJar.php?id='. $data[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img
class="project_option_img<?php if(!$permissions[1]){echo(" disabeled");} ?>"
alt="T&eacute;l&eacute;charger le jar"
title="T&eacute;l&eacute;charger le jar"
src="pictures/download_jar.png" />
<br/>
<?php if($data['language'] == 0){?>
<a class="project_option" href=<?php if($permissions[1] OR $owner OR $adminLevel>12){ echo( '"megaProcess/downloadJar.php?id='. $data[ 'pID'] . '&amp;v='. $data[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!$permissions[1] OR $owner OR $adminLevel>12){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger le jar" title="T&eacute;l&eacute;charger le jar" src="pictures/download_jar.png"/>
</a>
<a class="project_option" href=<?php if($permissions[2] OR $owner OR $adminLevel>12){ echo( '"megaProcess/viewJavaSrc.php?id='. $data[ 'pID'] . '&amp;v='. $data[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!$permissions[2] OR $owner OR $adminLevel>12){echo(" disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/view_code.png"/>
</a>
<a class="project_option" href=<?php if($permissions[2] OR $owner OR $adminLevel>12){ echo( '"megaProcess/downloadJavaSrc.php?id='. $data[ 'pID'] . '&amp;v='. $data[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!$permissions[2] OR $owner OR $adminLevel>12){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_code.png"/>
</a>
<a class="project_option" href=<?php if($permissions[3] OR $owner OR $adminLevel>12){ echo( '"megaProcess/viewJavadoc.php?id='. $data[ 'pID'] . '&amp;v='. $data[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!$permissions[3] OR $owner OR $adminLevel>12){echo(" disabeled");} ?>" alt="Voir la doc" title="Voir la doc" src="pictures/view_javadoc.png"/>
</a>
<a class="project_option" href=<?php if($permissions[3] OR $owner OR $adminLevel>12){ echo( '"megaProcess/downloadJavadoc.php?id='. $data[ 'pID'] . '&amp;v='. $data[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!$permissions[3] OR $owner OR $adminLevel>12){echo(" disabeled");} ?>" alt="T&eacute;lecharger la doc" title="T&eacute;lecharger la doc" src="pictures/download_javadoc.png"/>
</a>
</a>
<a class="project_option"
href=<?php if($permissions[2]){ echo( '"megaProcess/viewJavaSrc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>"
alt="Voir la source" title="Voir la source"
src="pictures/view_code.png" />
</a>
<a class="project_option"
href=<?php if($permissions[2]){ echo( '"megaProcess/downloadJavaSrc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>"
alt="T&eacute;l&eacute;charger la source"
title="T&eacute;l&eacute;charger la source"
src="pictures/download_code.png" />
</a>
<a class="project_option"
href=<?php if($permissions[3]){ echo( '"megaProcess/viewJavadoc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img
class="project_option_img<?php if(!$permissions[3]){echo(" disabeled");} ?>"
alt="Voir la doc" title="Voir la doc" src="pictures/view_javadoc.png" />
</a>
<a class="project_option"
href=<?php if($permissions[3]){ echo( '"megaProcess/downloadJavadoc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img
class="project_option_img<?php if(!$permissions[3]){echo(" disabeled");} ?>"
alt="T&eacute;lecharger la doc" title="T&eacute;lecharger la doc"
src="pictures/download_javadoc.png" />
</a>
<br />
<?php }else if($rep['projectLanguage'] == 1){?>
<a class="project_option"
href=<?php if($permissions[1]){ echo( '"megaProcess/downloadXlsm.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img
class="project_option_img<?php if(!$permissions[1]){echo(" disabeled");} ?>"
alt="T&eacute;l&eacute;charger le xlsm"
title="T&eacute;l&eacute;charger le xlsm"
src="pictures/download_xlsm.png" />
</a>
<a class="project_option"
href=<?php if($permissions[2]){ echo( '"megaProcess/viewVbSrc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>"
alt="Voir la source" title="Voir la source" src="pictures/voir_vb.png" />
</a>
<a class="project_option"
href=<?php if($permissions[2]){ echo( '"megaProcess/downloadVbSrc.php?id='. $rep[ 'pID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img
class="project_option_img<?php if(!$permissions[2]){echo(" disabeled");} ?>"
alt="T&eacute;l&eacute;charger la source"
title="T&eacute;l&eacute;charger la source"
src="pictures/download_vb.png" />
</a>
<br/>
<?php }else if($data['language'] == 1){?>
<a class="project_option" href=<?php if($permissions[1] OR $owner OR $adminLevel>12){ echo( '"megaProcess/downloadXlsm.php?id='. $data[ 'pID'] . '&amp;v='. $data[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!$permissions[1] OR $owner OR $adminLevel>12){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger le xlsm" title="T&eacute;l&eacute;charger le xlsm" src="pictures/download_xlsm.png"/>
</a>
<a class="project_option" href=<?php if($permissions[2] OR $owner OR $adminLevel>12){ echo( '"megaProcess/viewVbSrc.php?id='. $data[ 'pID'] . '&amp;v='. $data[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!$permissions[2] OR $owner OR $adminLevel>12){echo(" disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/voir_vb.png"/>
</a>
<a class="project_option" href=<?php if($permissions[2] OR $owner OR $adminLevel>12){ echo( '"megaProcess/downloadVbSrc.php?id='. $data[ 'pID'] . '&amp;v='. $data[ 'versionAbs'] . '"');}else{ echo( "\"#\"");} ?>>
<img class="project_option_img<?php if(!$permissions[2] OR $owner OR $adminLevel>12){echo(" disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_vb.png"/>
</a>
<?php } ?>
<br />
<br />
<h3>Toutes les versions :</h3>
<br />
<table class="versionTable">
<tr>
<th>Version</th>
</tr>
<?php
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE v.project_id = ?';
$req = $bdd->prepare ( $requete );
$req->execute ( array (
$_GET ['id']
) );
while ( $rep = $req->fetch () ) {
?>
<tr>
<td><a
href=<?php echo( '"projet.php?id='. $rep[ 'projectID'] . '&v='. $rep[ 'versionAbs'] . '"'); ?>><?php echo($rep['versionName']);?></a>
</td>
</tr>
<?php } ?>
<br/>
<br/>
<h3>Toutes les versions :</h3>
<br/>
<?php
$versions = getVersions($_GET ['id']);
?>
<?php if(count($versions[0]) > 0){?>
<table class="versionTable">
<tr>
<th>Java</th>
</tr>
<?php foreach ($versions[0] as $version){ ?>
<tr><td><a href = "projet.php?id=<?php echo $_GET['id']?>&amp;v=<?php echo $version['versionAbs'];?>"><?php echo $version['versionName'] ?></a></td></tr>
<?php }?>
</table>
<?
} else {
header ( 'Location:403.php' );
goto end;
}
?>
<?php }?>
<?php if(count($versions[1]) > 0){?>
<table class="versionTable">
<tr>
<th>VBA</th>
</tr>
<?php foreach ($versions[1] as $version){ ?>
<tr><td><a href = "projet.php?id=<?php echo $_GET['id']?>&amp;v=<?php echo $version['versionAbs'];?>"><?php echo $version['versionName'] ?></a></td></tr>
<?php }?>
</table>
<?php }?>
<br/>
<br/>
<?php if($owner){ ?>
<a href="newVersion.php?id=<?php echo $_GET['id'];?>">Nouvelle version</a><br/>
<a href="editVersion.php?id=<?php echo $_GET['id'];?>&amp;v=<?php echo $_GET['v'];?>">Modifier la version</a><br/>
<a href="delVersion.php?id=<?php echo $_GET['id'];?>&amp;v=<?php echo $_GET['v'];?>">Supprimer la version</a><br/>
<a href="editProject.php?id=<?php echo $_GET['id'];?>">Modifier le projet</a><br/>
<a href="delProject.php?id=<?php echo $_GET['id'];?>">Supprimer le projet</a><br/>
<?php } ?>
<?}else{
header('Location:403.php');
goto end;
}?>
<?php
end:
?>
end:
?>
<?php include 'includes/footer.php'; ?>
</body>
</html>
</html>

View File

@ -1,104 +0,0 @@
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<?php include 'includes/meta.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<?php
include_once 'includes/bdd.php';
$req=$bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?');
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp']));
$connected = $req->fetch();
}
$req=$bdd->prepare('SELECT * FROM projets WHERE permissions LIKE "1___" AND ID=?');
$req->execute(array($_GET['id']));
$viewPerm = $req->fetch();
if(($connected && isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])) || $viewPerm){
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName , v.language AS projectLanguage , p.permissions AS permissions '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE v.project_id = ? AND v.versionAbs = ?';
$req = $bdd->prepare($requete);
$req->execute(array($_GET['id'],$_GET['v']));
$rep=$req->fetch();
if($rep){
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE v.project_id = ? AND v.versionAbs = ? AND (p.ownersID REGEXP \'[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?\' OR p.permissions LIKE "1%")';
$req = $bdd->prepare($requete);
$req->execute(array($_GET['id'],$_GET['v']));
$fsyuf = $req->fetch();
$req = $bdd->prepare('SELECT p.ID AS projectID FROM projets AS p INNER JOIN versions AS v ON v.project_id = p.ID WHERE v.project_id = ? AND v.versionAbs = ? AND p.ownersID REGEXP \'[^0-9]?' . (isset($_SESSION['session_id']))?$_SESSION['session_id']:'err' .'[^0-9]?\'');
$req->execute(array($_GET['id'],$_GET['v']));
if($req->fetch()){
$owner=TRUE;
}else{
$owner=FALSE;
}
echo($owner."###".$_SESSION['session_id']);
$exeAccess = preg_match('#^11(0|1)*#',$rep['permissions']) || $owner;
$docAccess = preg_match('#^111(0|1)*#',$rep['permissions']) || $owner;
$srcAccess = preg_match('#^1111(0|1)*#',$rep['permissions']) || $owner;
if($fsyuf){?>
<h1>Le projet <?php echo($rep['projectName']) ?> en version <?php echo($rep['versionName']) ?></h1>
<br/>
<?php if($rep['projectLanguage'] == 0){?>
<a class="project_option" href=<?php if($exeAccess){ echo( '"megaProcess/downloadJar.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$exeAccess){echo("disabeled");} ?>" alt="T&eacute;l&eacute;charger le jar" title="T&eacute;l&eacute;charger le jar" src="pictures/download_jar.png"></img></a>
<a class="project_option" href=<?php if($srcAccess){ echo( '"megaProcess/viewJavaSrc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/view_code.png"></img></a>
<a class="project_option" href=<?php if($srcAccess){ echo( '"megaProcess/downloadJavaSrc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_code.png"></img></a>
<a class="project_option" href=<?php if($docAccess){ echo( '"megaProcess/viewJavadoc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$docAccess){echo("disabeled");} ?>" alt="Voir la doc" title="Voir la doc" src="pictures/view_javadoc.png"></img></a>
<a class="project_option" href=<?php if($docAccess){ echo( '"megaProcess/downloadJavadoc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$docAccess){echo("disabeled");} ?>" alt="T&eacute;lecharger la doc" title="T&eacute;lecharger la doc" src="pictures/download_javadoc.png"></img></a>
<br/>
<?php }else if($rep['projectLanguage'] == 1){?>
<a class="project_option" href=<?php if($exeAccess){ echo( '"megaProcess/downloadXlsm.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$exeAccess){echo("disabeled");} ?>" alt="T&eacute;l&eacute;charger le xlsm" title="T&eacute;l&eacute;charger le xlsm" src="pictures/download_xlsm.png"></img></a>
<a class="project_option" href=<?php if($srcAccess){ echo( '"megaProcess/viewVbSrc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="Voir la source" title="Voir la source" src="pictures/voir_vb.png"></img></a>
<a class="project_option" href=<?php if($srcAccess){ echo( '"megaProcess/downloadVbSrc.php?id='. $rep[ 'projectID'] . '&amp;v='. $rep[ 'versionAbs'] . '"');}else{ echo("\"#\"");} ?>><img class="project_option_img <?php if(!$srcAccess){echo("disabeled");} ?>" alt="T&eacute;l&eacute;charger la source" title="T&eacute;l&eacute;charger la source" src="pictures/download_vb.png"></img></a>
<?php } ?>
<br/> <a href="#">##################################</a>
<br/>
<br/>
<h3>Toutes les versions :</h3>
<br/>
<table class="versionTable">
<tr>
<th>Version</th>
</tr>
<?php
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE v.project_id = ?';
$req = $bdd->prepare($requete);
$req->execute(array($_GET['id']));
while($rep = $req->fetch()){
?>
<tr>
<td> <a href=<?php echo( '"projet.php?id='. $rep[ 'projectID'] . '&v='. $rep[ 'versionAbs'] . '"'); ?>><?php echo($rep['versionName']);?></a> </td>
</tr>
<?php } ?>
</table>
<?php
}else{
header('Location:403.php');
}
}else{
header('Location:40A.php');
}
}else{
header('Location:401.php');
}
?>
<?php include 'includes/footer.php'; ?>
</body>
</html>

View File

@ -12,31 +12,11 @@
<h1>Mes projets</h1>
<?php
include_once 'includes/bdd.php';
include_once 'includes/inter.php';
$req=$bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?');
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp']));
}
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && $req->fetch() ){
if(isConnected()){
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName '.
'FROM projets AS p '.
'INNER JOIN versions AS v '.
'ON v.project_id = p.ID '.
'WHERE p.ownersID REGEXP \'[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?\' ';
$req = $bdd->query($requete)or die(print_r($bdd->errorInfo()));
//$req = $bdd->query('SELECT * FROM projets WHERE ownersID REGEXP \'[^0-9]?' . $_SESSION['session_id'] .'[^0-9]?\'');
$projects = array();
while($rep = $req->fetch()){
if(!isset($projects[$rep['projectID']])){
$projects[$rep['projectID']] = $rep;
}else if($projects[$rep['projectID']]['versionAbs'] < $rep['versionAbs']){
$projects[$rep['projectID']] = $rep;
}
}
$projects = getOwnersisProjects();
foreach($projects as $project){
echo ('<a href="projet.php?id='. $project['projectID'] .'&amp;v='. $project['versionAbs'] .'">Le projet ' . $project['projectName'] . ' en version ' . $project['versionName'] . '</a><br/>');
}

View File

@ -9,33 +9,15 @@
<body>
<?php include 'includes/header.php'; ?>
<?php
if(isset($_GET['i'])){
if($_GET['i'] == 1){
echo "<script>alert('Vous n\\'avez pas rentré toutes les données !')</script>";
} elseif($_GET['i'] == 2){
echo "<script>alert('Les mots de passe ne correspondent pas')</script>";
} elseif($_GET['i'] == 3){
echo "<script>alert('Le pseudo n\\'est pas bien formé (Il ne peux contenir que des lettres (majuscules et minuscules), des nombres, le tiret(-) et l\\'underscore(_) ')</script>";
} elseif($_GET['i'] == 4){
echo "<script>alert('Le mot de passe n\\'est pas bien formé (Caractères autorisés : abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&é\"#\\'{}()[]|è\\ç^à@°+=\$¤£*µ!§:/;.,?²)')</script>";
} elseif($_GET['i'] == 5){
echo "<script>alert('Pseudo déjà utilisé')</script>";
} elseif($_GET['i'] == 6){
echo "<script>alert('Vous etes correctement inscrit sur bernard.com !!!')</script>";
}
}
?>
<form id="registerForm" method="post" action="registering.php">
<label for="pseudo">Pseudo :</label>
<input type="text" name="pseudo" id="pseudo" placeholder="Votre pseudo" required />
<input type="text" name="pseudo" id="pseudo" placeholder="Votre pseudo" />
<br/>
<label for="mdp">Mot de passe :</label>
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" required />
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" />
<br/>
<label for="mdp2">Mot de passe (bis) :</label>
<input type="password" name="mdp2" id="mdp2" placeholder="Votre mot de passe" required />
<input type="password" name="mdp2" id="mdp2" placeholder="Votre mot de passe" />
<br/>
<input type="Submit" value="S'inscrire">
</form>

View File

@ -1,31 +1,38 @@
<?php session_start();
include_once 'includes/bdd.php';
if(isset($_POST['pseudo']) && isset($_POST['mdp']) && isset($_POST['mdp2'])){
if($_POST['mdp'] === $_POST['mdp2']){
if(preg_match("#^[a-zA-Z0-9\\-_]+$#",$_POST['pseudo'])){
if(preg_match("#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&éèàùçµ\"\\#'{}()[\\]|\\^@°+=\$¤£*!§:/;.,?²]+$#",$_POST['mdp'])){
$req = $bdd->prepare("SELECT * FROM users WHERE pseudo=?");
$req->execute(array($_POST['pseudo']));
if($req->fetch()){
header('Location:register.php?i=5');
}else{
$req = $bdd->prepare('INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())');
$req->execute(array($_POST['pseudo'],$_POST['mdp']));
$_SESSION['session_id'] = $reponce['ID'];
$_SESSION['session_mdp'] = $reponce['mdp'];
header('Location:register.php?i=6');
}
}else{
header('Location:register.php?i=4');
}
}else{
header('Location:register.php?i=3');
}
}else{
header('Location:register.php?i=2');
}
}else{
header('Location:register.php?i=1');
}
<?php
session_start ();
?>
include_once 'includes/inter.php';
if (isset ( $_POST ['pseudo'] ) && isset ( $_POST ['mdp'] ) && isset ( $_POST ['mdp2'] )) {
if ($_POST ['mdp'] === $_POST ['mdp2']) {
if (preg_match ( "#^[a-zA-Z0-9\\-_]+$#", $_POST ['pseudo'] )) {
if (preg_match ( "#^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\\-_&éèàùçµ\"\\#'{}()[\\]|\\^@°+=\$¤£*!§:/;.,?²]+$#", $_POST ['mdp'] )) {
switch (registerPerson ( $_POST ['pseudo'], $_POST ['mdp'] )) {
case 'ok' :
$_SESSION ['current_error'] = 'Vous avez déjà été correctement inscrit sur bernard.com';
break;
case 'usedPseudo' :
$_SESSION ['current_error'] = 'Le pseudonyme est déjà utilisé (par une entité differente de vous)';
break;
}
} else {
$_SESSION ['current_error'] = 'Le mot de passe fut incorrect : Les seuls caractères autorisés sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_&éèàùçµ"#\'{}()[]|^@°+=$¤£*!§:/;.,?²';
}
} else {
$_SESSION ['current_error'] = 'Le pseudo sera incorrect : Les seuls caractères autorisés sont :<br/>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_';
}
} else {
$_SESSION ['current_error'] = 'Tu auras du rentrer deux fois le même mot de passe (tu permet aussi de rendre le champs "Recopier le mot de passe" utile)';
}
} else {
$_SESSION ['current_error'] = 'Quand on demande des données , on donne des données !!!';
}
header ( 'Location:register.php' );

108
sortBDD.php Normal file
View File

@ -0,0 +1,108 @@
<?php
session_start ();
include_once 'includes/inter.php';
if (! isConnected ()) {
header ( 'Location:401.php' );
goto end;
} else if (getAdminLevel () < 16) {
header ( 'Location:403.php' );
goto end;
} else {
try {
echo '[' . date ( 'H:i:s' ) . ']' . 'Start sorting bdd<br/>';
/*-------------------- USERS --------------------*/
$idAssos = array();
echo '[' . date ( 'H:i:s' ) . ']' . 'Table users<br/>';
$rep = $GLOBALS ['bdd']->query ( 'SELECT * FROM users ORDER BY ID' );
$users = array ();
while ( $user = $rep->fetch () ) {
echo '----' . $user ['ID'] . ':"' . $user ['pseudo'] . '";"' . $user ['mdp'] . '";' . $user ['date_creation'] . ';' . $user ['administration'] . '<br/>';
$users [] = $user;
}
$rep->closeCursor ();
$GLOBALS ['bdd']->exec ( 'TRUNCATE TABLE users' );
echo '[' . date ( 'H:i:s' ) . ']' . 'Table users effacée<br/>';
$currentID = 1;
foreach ( $users as $u ) {
$req = $GLOBALS['bdd']->prepare('INSERT INTO users(pseudo,mdp,date_creation,administration) VALUES (?,?,?,?)');
$req->execute(array($u ['pseudo'],$u ['mdp'], $u ['date_creation'], $u ['administration']));
$idAssos[$u['ID']] = $currentID;
$currentID +=1;
echo '----' . $u ['ID'] . '->' . $idAssos[$u['ID']] . '<br/>';
}
echo '[' . date ( 'H:i:s' ) . ']' . 'Pseudos réinsérés triés par ID<br/>';
/*-------------------- PROJETS --------------------*/
$pidAssos = array();
echo '[' . date ( 'H:i:s' ) . ']' . 'Table projets<br/>';
$rep = $GLOBALS ['bdd']->query ( 'SELECT * FROM projets ORDER BY ID' );
$projects = array ();
while ( $project = $rep->fetch () ) {
echo '----' . $project ['ID'] . ':"' . $project['name'] . '";"' . $project ['ownersID'] . '";' . $project ['permissions'] . '<br/>';
$projects[] = $project;
}
$rep->closeCursor();
$GLOBALS ['bdd']->exec ( 'TRUNCATE TABLE projets' );
echo '[' . date ( 'H:i:s' ) . ']' . 'Table projets effacée<br/>';
$currentID = 1;
foreach ( $projects as $p ) {
$ownersID = explode(';',$p['ownersID']);
$ownersNewID = array();
foreach($ownersID AS $o){
if(isset($idAssos[$o])){
$ownersNewID[] = $idAssos[$o];
}
}
$newOwnersID = implode(';',$ownersNewID);
if(count($ownersNewID)<=0){
echo '####################' . 'Le projet '.print_r($p,TRUE).' n\'a aucun poss&eacute;sseur<br/>';
}else{
echo '--------' . 'Owners :'.$p['ownersID'].' &agrave; '.$newOwnersID.'<br/>';
}
$req = $GLOBALS['bdd']->prepare('INSERT INTO projets(name,ownersID,permissions) VALUES (?,?,?)');
$req->execute(array($p ['name'],$newOwnersID,$p['permissions']));
$pidAssos[$p['ID']] = $currentID;
$currentID +=1;
echo '----' . $p ['ID'] . '->' . $pidAssos[$p['ID']] . '<br/>';
}
echo '[' . date ( 'H:i:s' ) . ']' . 'Projets réinsérés triés par ID<br/>';
/*-------------------- VERSIONS --------------------*/
$vidAssos=array();
echo '[' . date ( 'H:i:s' ) . ']' . 'Table versions<br/>';
$rep = $GLOBALS ['bdd']->query ( 'SELECT * FROM versions ORDER BY id' );
$versions = array ();
while ( $version = $rep->fetch () ) {
echo '----' . $version ['id'] . ':' . $version['project_id'] . ';"' . $version ['version'] . '";"' . $version ['versionAbs'].'";'.$version['language'] . '<br/>';
$versions[] = $version;
}
$rep->closeCursor();
$GLOBALS ['bdd']->exec ( 'TRUNCATE TABLE versions' );
echo '[' . date ( 'H:i:s' ) . ']' . 'Table versions effacée<br/>';
$currentID = 1;
foreach ( $versions as $v ) {
$newProjectId=$pidAssos[$v['project_id']];
$req = $GLOBALS['bdd']->prepare('INSERT INTO versions(project_id,version,versionAbs,language) VALUES (?,?,?,?)');
$req->execute(array($pidAssos,$v ['version'],$v['versionAbs'],$v ['language']));
$vidAssos[$v['id']] = $currentID;
$currentID +=1;
echo '----' . $v ['id'] . '->' . $vidAssos[$v['id']] . '<br/>';
}
echo '[' . date ( 'H:i:s' ) . ']' . 'Versions réinsérés triés par ID<br/>';
} catch ( Exception $e ) {
echo $GLOBALS['bdd']->error;
}
}
end:
?>

Binary file not shown.

BIN
tempPreMega/bezierN.ggb Normal file

Binary file not shown.

Binary file not shown.

7
todo.list Normal file
View File

@ -0,0 +1,7 @@
discuts.php
createDiscuts.php
sendMessage.php
MEGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
version edit + editing