Skip to content

Instantly share code, notes, and snippets.

@Tolrep
Tolrep / delete.php
Created April 17, 2018 16:22
delete.php
if (isset($_POST['delete'])) {
if (is_dir($_POST['delete'])) {
if(count(scandir($_POST['delete']))<=2) {
rmdir($_POST['delete']);
header('location:index.php');
die;
}else {
echo "Impossible de supprimer un dossier non-vide";
}
}else {
@Tolrep
Tolrep / edouard_p_wcs_lyon.sql
Last active March 14, 2018 12:52
Interagir avec uns base de donnee SQL
-- MySQL dump 10.13 Distrib 5.7.21, for Linux (x86_64)
--
-- Host: localhost Database: edouard_p_wcs_lyon
-- ------------------------------------------------------
-- Server version 5.7.21-0ubuntu0.16.04.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
@Tolrep
Tolrep / index.php
Created March 12, 2018 13:16
Fonction en php
<?php
declare(strict_types=1);
function writeSecretSentence (string $parametre1, string $parametre2) {
$secretSentence = $parametre1 . ' s\'incline face à ' . $parametre2;
return $secretSentence;
}
echo writeSecretSentence('Le lapin', 'la louve');
@Tolrep
Tolrep / form.php
Last active March 12, 2018 08:56
Formulaire
<?php
if($_POST){
$error = [];
//Erreur//
if(empty($_POST['userName'])){
$error['userName1'] = 'Votre nom merci';
@Tolrep
Tolrep / procedural.php
Created March 6, 2018 10:22
PHP procedural
<?php
$weapons = ['fists', 'whip', 'gun'];
$opponentWeapon = $weapons[rand(0,2)];
if ($opponentWeapon == 'fists'){
$indyWeapon = 'gun';
}
elseif ($opponentWeapon == 'whip'){
@Tolrep
Tolrep / tableauxBoucles.php
Last active March 5, 2018 17:34
Tableaux et Boucles
<?php
$films = [
'Raiders of the Lost Ark' => ['Harrison Ford', 'Karen Allen', 'John Rhys-Davies'],
'Indiana Jones and the Temple of Doom' => ['Harrison Ford', 'Kate Capshaw', 'Amrish Puri'],
'Indiana Jones and the Last Crusade' => ['Harrison Ford', 'Julian Glover', 'Sean Connery']
];
foreach ($films as $key => $value) {
echo "Dans Le film ";
@Tolrep
Tolrep / Decrpytage
Created March 5, 2018 15:37
Les chaines de caractere en PHP
<?php
$chainePapyrus1="0@sn9sirppa@#?ia'jgtvryko1";
$chainePapyrus2="q8e?wsellecif@#?sel@#?setuotpazdsy0*b9+mw@x1vj";
function decodeur ($chainePapyrus)
{
$chiffreCle=(strlen($chainePapyrus))/2;
$chaineChiffreCle= substr ($chainePapyrus , 5, $chiffreCle);
$chaineavecEspace=str_replace('@#?' , ' ' , $chaineChiffreCle);
$chaineDecrypte1= strrev($chaineavecEspace);
@Tolrep
Tolrep / Historique
Last active March 1, 2018 17:34
Debut git
1 chsh -s /bin/zsh
2 sudo apt-get install vim
3 vim
4 curl http://install.sublivim.com | sh
5 sudo apt-get install sublime-text
6 wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
7 echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
8 sudo apt-get update
9 sudo apt-get install sublime-text
10 vim
@Tolrep
Tolrep / Chartre.txt
Created March 1, 2018 14:11
Charte d'un apprenant efficace
1. Je m'engage à ne pas partir avant d'avoir finit ce aue j'ai commencé.
2. Je m'engage a faire une pause a midi.
3. Je m'engage a demander si je ne comprend pas quelque chose.
4. Je m'engage a faire le point avec mon groupe chaque jour sur l'état du projet en cour.
@Tolrep
Tolrep / Variables.php
Last active March 1, 2018 14:13
Indiana Jones
<?php
$filmName="Indiana Jones and the Last Crusade";
$filmYear=1989;
$filmSeen=true;
$filmMark=8.3;
echo $filmName;
echo "<br>";
echo $filmSeen;
echo "<br>";