insertion image fonctionnelle

offres2
Baptiste Dudonné 1 year ago committed by Baptiste D
parent f6ef3626c1
commit 1608d3f17d

476
.gitignore vendored

@ -0,0 +1,476 @@
##### Windows
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
##### Linux
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
##### MacOS
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
##### Backup
*.bak
*.gho
*.ori
*.orig
*.tmp
##### GPG
secring.*
##### Dropbox
# Dropbox settings and caches
.dropbox
.dropbox.attr
.dropbox.cache
##### SynopsysVCS
# Waveform formats
*.vcd
*.vpd
*.evcd
*.fsdb
# Default name of the simulation executable. A different name can be
# specified with this switch (the associated daidir database name is
# also taken from here): -o <path>/<filename>
simv
# Generated for Verilog and VHDL top configs
simv.daidir/
simv.db.dir/
# Infrastructure necessary to co-simulate SystemC models with
# Verilog/VHDL models. An alternate directory may be specified with this
# switch: -Mdir=<directory_path>
csrc/
# Log file - the following switch allows to specify the file that will be
# used to write all messages from simulation: -l <filename>
*.log
# Coverage results (generated with urg) and database location. The
# following switch can also be used: urg -dir <coverage_directory>.vdb
simv.vdb/
urgReport/
# DVE and UCLI related files.
DVEfiles/
ucli.key
# When the design is elaborated for DirectC, the following file is created
# with declarations for C/C++ functions.
vc_hdrs.h
##### SVN
.svn/
##### Mercurial
.hg/
.hgignore
.hgsigs
.hgsub
.hgsubstate
.hgtags
##### Bazaar
.bzr/
.bzrignore
##### CVS
/CVS/*
**/CVS/*
.cvsignore
*/.cvsignore
##### TortoiseGit
# Project-level settings
/.tgitconfig
##### PuTTY
# Private key
*.ppk
##### Vim
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
##### Emacs
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
# network security
/network-security.data
##### SublimeText
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific
*.sublime-workspace
# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project
# SFTP configuration file
sftp-config.json
sftp-config-alt*.json
# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache
# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings
##### Notepad++
# Notepad++ backups #
*.bak
##### TextMate
*.tmproj
*.tmproject
tmtags
##### VisualStudioCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
##### NetBeans
**/nbproject/private/
**/nbproject/Makefile-*.mk
**/nbproject/Package-*.bash
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
##### JetBrains
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
##### Eclipse
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project
##### Dreamweaver
# DW Dreamweaver added files
_notes
_compareTemp
configs/
dwsync.xml
dw_php_codehinting.config
*.mno
##### CodeKit
# General CodeKit files to ignore
config.codekit
config.codekit3
/min
##### Gradle
.gradle
**/build/
!src/**/build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
##### Composer
composer.phar
/vendor/
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
##### PHP CodeSniffer
# gitignore for the PHP Codesniffer framework
# website: https://github.com/squizlabs/PHP_CodeSniffer
#
# Recommended template: PHP.gitignore
/wpcs/*
##### SASS
.sass-cache/
*.css.map
*.sass.map
*.scss.map
php/.idea/

@ -13,4 +13,5 @@ $twig = new \Twig\Environment($loader, [
'debug' => true 'debug' => true
]); ]);
$cont = new \App\controleur\FrontControleur(); $cont = new \App\controleur\FrontControleur();

@ -8,5 +8,5 @@ $dConfig['includes']= array('controleur/Validation.php');
//BD //BD
$base = 'mysql:host=localhost;dbname=dbAlica'; $base = 'mysql:host=localhost;dbname=dbAlica';
$login = 'root'; $login = 'test';
$mdp = ''; $mdp = 'test';

@ -2,16 +2,23 @@
namespace App\controleur; namespace App\controleur;
use App\gateway\Connection;
use App\gateway\ImageGateway;
use App\modele\Image;
class UtilisateurControleur class UtilisateurControleur
{ {
public function __construct() public function __construct()
{ {
global $twig; global $twig;
if (!isset($_REQUEST["action"])) { if (!isset($_REQUEST["action"])) {
$action = NULL; //$action = NULL;
$action = "CreerOffre";
} else { } else {
$action = \App\config\Validation::nettoyerString($_REQUEST["action"]); $action = \App\config\Validation::nettoyerString($_REQUEST["action"]);
} }
switch ($action) { switch ($action) {
case NULL: case NULL:
case "accueil": case "accueil":
@ -26,6 +33,13 @@ class UtilisateurControleur
case "consulterProfilLimite": case "consulterProfilLimite":
$this->consulterProfilLimite(); $this->consulterProfilLimite();
break; break;
case "CreerOffre":
//echo "test";
$this->creerOffre();
break;
case "publierOffre":
$this->publierOffre();
break;
default: default:
$dVueErreur[] ="Action inconnue ou non autorisée"; $dVueErreur[] ="Action inconnue ou non autorisée";
echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]); echo $twig->render("erreur.html",['dVueErreur' => $dVueErreur]);
@ -84,4 +98,31 @@ class UtilisateurControleur
//TODO //TODO
} }
protected function creerOffre()
{
global $twig;
echo $twig->render('testImage.html', []);
}
protected function publierOffre()
{
if(isset($_POST["submit"]))
$img = new Image($_FILES["image"]["name"],
$_FILES["image"]["size"],$_FILES["image"]["type"],file_get_contents($_FILES["image"]["tmp_name"]));
else {
echo "<h1>Image non inserée<h1>";
return;
}
$con = new Connection("mysql:host=localhost;dbname=dbAlida",'test','test');
$imgGw = new ImageGateway($con);
$imgGw->insertImage($img);
echo "<h1>Image inserée<h1>";
}
} }

@ -0,0 +1,122 @@
<?php
namespace App\gateway;
use App\modele\Image;
use PDO;
class ImageGateway
{
private Connection $con;
/**
* @param $con
*/
public function __construct(Connection $con)
{
$this->con = $con;
}
public function insertImage(Image $img)
{
$query = "INSERT INTO Image (`nom`, `taille`, `type`, `desc`, `blob`) VALUES ( :n, :t, :ty, :d, :b)";
$this->con->executeQuery($query, array(
':n' => array($img->getName(), PDO::PARAM_STR),
':t' => array($img->getTaille(), PDO::PARAM_STR),
':ty' => array($img->getType(), PDO::PARAM_STR),
':d' => array("desc", PDO::PARAM_STR),
':b' => array($img->getBlob(), PDO::PARAM_STR)
));
}
public function insert(int $id,string $name, string $desc, string $taille, string $type, string $blob)
{
$query = 'INSERT INTO Image (nom, taille, type, desc, blob) VALUES (:i, :n, :t, :ty, :d, :b)';
$this->con->executeQuery($query, array(
':i' => array($id,PDO::PARAM_INT),
':n' => array($name, PDO::PARAM_STR),
':t' => array($taille, PDO::PARAM_STR),
':ty' => array($type, PDO::PARAM_STR),
':d' => array($desc, PDO::PARAM_STR),
':b' => array($blob, PDO::PARAM_STR)
));
}
public function updateName(int $id, string $newName)
{
$query = 'UPDATE Image SET nom=:new WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT),
':new' => array($newName, PDO::PARAM_STR)
));
}
public function updateDesc(int $id, string $newDesc)
{
$query = 'UPDATE Image SET desc=:new WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT),
':new' => array($newDesc, PDO::PARAM_STR)
));
}
public function updateTaille(int $id, string $newTaille)
{
$query = 'UPDATE Image SET taille=:new WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT),
':new' => array($newTaille, PDO::PARAM_STR)
));
}
public function updateType(int $id, string $newType)
{
$query = 'UPDATE Image SET type=:new WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT),
':new' => array($newType, PDO::PARAM_STR)
));
}
public function updateBlob(int $id, string $newBlob)
{
$query = 'UPDATE Image SET blob=:new WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT),
':new' => array($newBlob, PDO::PARAM_STR)
));
}
public function delete(int $id)
{
$query = 'DELETE FROM Image WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT)
));
}
public function findById(int $id)
{
$query = 'SELECT * FROM Image WHERE id=:i';
$this->con->executeQuery($query, array(
':i' => array($id, PDO::PARAM_INT)
));
$res = $this->con->getResults();
return new Image($res[0]['nom'], $res[0]['desc'], $res[0]['taille'], $res[0]['type'], $res[0]['blob']);
}
public function getAll()
{
$query = 'SELECT * FROM Image';
$this->con->executeQuery($query);
$res = $this->con->getResults();
$array = [];
foreach ($res as $r) {
$array[] = new Image($r['nom'], $r['desc'], $r['taille'], $r['type'], $r['blob']);
}
return $array;
}
}
?>

@ -0,0 +1,54 @@
<?php
namespace App\modele;
class Image
{
//private int $id;
private string $name;
private string $taille;
private string $type;
private string $blob;
/**
* @param string $name
* @param string $desc
* @param string $taille
* @param string $type
* @param string $blob
*/
public function __construct( string $name, string $taille, string $type, string $blob)
{
//$this->id = $id;
$this->name = $name;
$this->taille = $taille;
$this->type = $type;
$this->blob = $blob;
}
public function getName(): string
{
return $this->name;
}
public function getTaille(): string
{
return $this->taille;
}
public function getType(): string
{
return $this->type;
}
public function getBlob(): string
{
return $this->blob;
}
}

@ -34,8 +34,8 @@ class UtilisateurModele
public function inscription(string $email, string $hashpassword): \App\modele\Alumni public function inscription(string $email, string $hashpassword): \App\modele\Alumni
{ {
$dsn = "mysql:host=localhost;dbname=dbAlica"; $dsn = "mysql:host=localhost;dbname=dbAlica";
$username = "Dev"; $username = "test";
$password = "Dev"; $password = "test";
$role = "Utilisateur"; $role = "Utilisateur";
$con = new \App\gateway\Connection($dsn, $username, $password); $con = new \App\gateway\Connection($dsn, $username, $password);

@ -0,0 +1,144 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Publier une Offre</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="accueil.html">Reseau Alica Info</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">A propos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Evenements</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Offres</a>
</li>
</ul>
</div>
</nav>
</header>
<main class="container mt-4">
<h1>Publier Une Offre</h1>
<form style="background-color: #00DBFF" class="p-4" enctype="multipart/form-data" action="../php/modeles/OffreModele.php" method="post">
<div class="form-group">
<label for="name">Intitulé de l'offre</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Intitulé">
</div>
<div class="form-group">
<label for="entreprise">Nom de l'entreprise :</label>
<input type="text" class="form-control" id="entreprise" name="entreprise" placeholder="Entreprise">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" id="description" name="description" placeholder="Description rapide"></textarea>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="fullRemote" name="fullRemote">
<label class="form-check-label" for="fullRemote">Full Remote</label>
</div>
<div class="form-group">
<label for="ville">Ville</label>
<input type="text" class="form-control" id="ville" name="ville" placeholder="Ville">
</div>
<div class="form-group">
<label for="choixContrat">Choisissez un type de contrat :</label>
<select class="form-control" id="choixContrat" name="typeContrat">
<option value="CDI">CDI</option>
<option value="CDD">CDD</option>
<option value="Alternance">Alternance</option>
<option value="Stage">Stage</option>
</select>
</div>
<div class="form-group">
<label for="descriptPoste">Descriptif du Poste :</label>
<textarea class="form-control" id="descriptPoste" name="descriptPoste" placeholder="Description du Poste"></textarea>
</div>
<div class="form-group">
<label for="profilRecherche">Profil Recherché :</label>
<textarea class="form-control" id="profilRecherche" name="profilRecherche" placeholder="Profil recherché"></textarea>
</div>
<div class="form-group">
<label for="choixExp">Experience Recherchée :</label>
<select class="form-control" id="choixExp" name="choixExp">
<option value="Junior">Junior</option>
<option value="Senior">Senior</option>
<option value="Indifférent">Indifferent</option>
</select>
</div>
<label>Niveau d'études :</label>
<div class="form-check-inline">
<input type="checkbox" class="form-check-input" id="indifferent" name="education" value="indifferent" checked>
<label class="form-check-label" for="indifferent">Indifférent</label>
</div>
<div class="form-check-inline">
<input type="checkbox" class="form-check-input" id="bac2" name="education" value="bac2">
<label class="form-check-label" for="bac2">Bac +2</label>
</div>
<div class="form-check-inline">
<input type="checkbox" class="form-check-input" id="bac5" name="education" value="bac5">
<label class="form-check-label" for="bac5">Bac +5</label>
</div>
<div class="form-check-inline">
<input type="checkbox" class="form-check-input" id="bac8" name="education" value="bac8">
<label class="form-check-label" for="bac8">Bac +8</label>
</div>
<div class="form-group">
<label for="mail">Email de contact :</label>
<input type="text" class="form-control" id="mail" name="mail" placeholder="Adresse de contact">
</div>
<div class="form-group">
<label for="num">Numero de contact :</label>
<input type="text" class="form-control" id="num" name="num" placeholder="Numéro de contact">
</div>
<div class="form-group">
<label for="site">Site web de l'annonce ou entreprise :</label>
<input type="text" class="form-control" id="site" name="site" placeholder="Adresse web">
</div>
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Publier L'annonce" name="submit">
</form>
</main>
<!-- scripts : -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="../scripts/creerOffre.js"></script>
</body>
</html>

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../public/css/accueil.css"> <link rel="stylesheet" type="text/css" href="css/accueil.css">
<title>Alica - Accueil</title> <title>Alica - Accueil</title>
</head> </head>

@ -14,6 +14,7 @@
<p>{{value}}</p> <p>{{value}}</p>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<form action="../public/index.php" method="POST"> <form action="../public/index.php" method="POST">
<input type="submit" value="Retourner à l'accueil"> <input type="submit" value="Retourner à l'accueil">
</form> </form>

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Img</title>
</head>
<body>
<form name="form" action="index.php?action=publierOffre" method="post" enctype="multipart/form-data">
<label>Image:</label>
<input type="file" name="image" id="image">
<input type="submit" value="Publier L'annonce" name="submit">
</form>
</body>
</html>
Loading…
Cancel
Save