Mise en place de Laravel 11 avec Fortify
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*/
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*/
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* The list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BotController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,644 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\BrowserKit\HttpBrowser;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
|
||||
class ContestController extends Controller
|
||||
{
|
||||
public function twitterlist()
|
||||
{
|
||||
$client = new HttpBrowser(HttpClient::create(['verify_peer' => false, 'verify_host' => false, 'timeout' => '60']));
|
||||
|
||||
// Création des informations d'authentification
|
||||
$username = 'autokdo';
|
||||
$password = '@Gaudin95';
|
||||
$credentials = base64_encode("$username:$password");
|
||||
|
||||
// Ajout des informations d'authentification à l'en-tête de la demande HTTP
|
||||
$client->setServerParameter('HTTP_AUTHORIZATION', 'Basic ' . $credentials);
|
||||
$client->setServerParameter('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36');
|
||||
$crawler = $client->request('GET', 'https://nitter.lucabased.xyz/i/lists/1686126753205387264');
|
||||
|
||||
$i = 1;
|
||||
|
||||
while ($i < 10){
|
||||
$results = $crawler->filterXPath('//div[@class="timeline-item "]')->each(function ($node) {
|
||||
$id = ($node->filterXPath('//*[@class="tweet-link"]'))->attr('href');
|
||||
$created_at = ($node->filterXPath('//span[@class="tweet-date"]/a'))->attr('title');
|
||||
$text = ($node->filterXPath('//*[@class="tweet-content media-body"]'))->text();
|
||||
$screen = ($node->filterXPath('//a[@class="username"]'))->text();
|
||||
$picture = ($node->filterXPath('//a[@class="still-image"]'))->attr('href');
|
||||
$nbretweet = ($node->filterXPath('//*[@class="tweet-stat"][2]'))->text();
|
||||
$nbretweet = str_replace(',', '', $nbretweet);
|
||||
$nblike = ($node->filterXPath('//*[@class="tweet-stat"][4]'))->text();
|
||||
$nblike = str_replace(',', '', $nblike);
|
||||
$nbreply = ($node->filterXPath('//*[@class="tweet-stat"][1]'))->text();
|
||||
$nbreply = str_replace(',', '', $nbreply);
|
||||
|
||||
//Modifications
|
||||
$picture = urldecode($picture);
|
||||
$picture = str_replace('/pic/orig/', 'https://pbs.twimg.com/', $picture);
|
||||
$screen = str_replace('@', '', $screen);
|
||||
$id = str_replace('/'.$screen.'/status/', '', $id);
|
||||
$id = str_replace('#m', '', $id);
|
||||
|
||||
$contest = Contest::where('tweetid', $id)->first();
|
||||
|
||||
if(empty($contest) && $nbretweet > 100) {
|
||||
$regex_detect_rts =
|
||||
[
|
||||
"/\bRT\b/",
|
||||
"/RETWEET/i",
|
||||
"/REPUBL/i",
|
||||
"/REPOST/i",
|
||||
];
|
||||
foreach ($regex_detect_rts as $regex_detect_rt) {
|
||||
//if (strstr($string, $url)) { // mine version
|
||||
preg_match($regex_detect_rt, $text, $invites);
|
||||
if (isset($invites[0])) {
|
||||
$rt = true;
|
||||
}
|
||||
}
|
||||
|
||||
//On verifie que si RT
|
||||
if (isset($rt)) {
|
||||
$inputs = array();
|
||||
//On recherche la date de fin du concours
|
||||
$date = $this->getDate($text);
|
||||
if ($date != null) {
|
||||
$fin = $date;
|
||||
} else {
|
||||
$fin = $this->getTwitterDate($created_at);
|
||||
}
|
||||
//On recherche la date de fin du concours
|
||||
if ($fin >= Carbon::now()->format('Y-m-d')) {
|
||||
|
||||
$categorie = $this->getCategorie($text);
|
||||
|
||||
$organizer = $this->getOrganizer($screen);
|
||||
|
||||
$concours = Contest::create([
|
||||
'category_id' => $categorie,
|
||||
'organizer_id' => $organizer,
|
||||
'description' => $text,
|
||||
'url' => 'https://twitter.com/'.$screen.'/status/'.$id,
|
||||
'tweetid' => $id,
|
||||
'fin' => $fin,
|
||||
'nbretweet' => $nbretweet,
|
||||
'nblike' => $nblike,
|
||||
'nbreply' => $nbreply,
|
||||
]);
|
||||
|
||||
//On recherche un tag
|
||||
$regex_detect_tags =
|
||||
[
|
||||
"/INVIT/i",
|
||||
"/IDENTIFI/i",
|
||||
"/TAG/i",
|
||||
"/HASHTAG/i",
|
||||
"/RT AVEC/i",
|
||||
"/MENTIONN/i",
|
||||
"/COMMENT/i",
|
||||
"/RETWEET AVEC/i",
|
||||
"/TWEET AVEC/i",
|
||||
];
|
||||
|
||||
foreach ($regex_detect_tags as $regex_detect_tag) {
|
||||
//if (strstr($string, $url)) { // mine version
|
||||
preg_match($regex_detect_tag, $text, $invites);
|
||||
if (isset($invites[0])) {
|
||||
$tweet = true;
|
||||
}
|
||||
}
|
||||
|
||||
//On verifie s'il demande un tag ou un hashtag
|
||||
if (isset($tweet)) {
|
||||
|
||||
$tag = 'Je veux gagner ce concours @ActuFoot_ @Mediavenir';
|
||||
|
||||
preg_match_all("/#[a-zA-Z0-9]+/", $text, $hashtag);
|
||||
|
||||
if (isset($hashtag[0])) {
|
||||
$hashtags = implode(" ", $hashtag[0]);
|
||||
$tag = $tag . ' ' . $hashtags;
|
||||
}
|
||||
|
||||
$tag = urlencode($tag);
|
||||
|
||||
//On tweet avec un le tag
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'reply',
|
||||
'value' => $tag,
|
||||
]);
|
||||
|
||||
//On follow les autres
|
||||
preg_match_all("/\s@([\w_-]+)/", $text, $matches);
|
||||
$mentions = $matches[1];
|
||||
$mentions[] = $screen;
|
||||
$mentions = array_unique($mentions);
|
||||
foreach ($mentions as $mention) {
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'follow',
|
||||
'value' => $mention,
|
||||
]);
|
||||
}
|
||||
|
||||
//On like si besoin
|
||||
preg_match("/LIKE/i", $text, $like);
|
||||
if (isset($like[0])) {
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'like',
|
||||
'value' => $id,
|
||||
]);
|
||||
}
|
||||
} //Sinon on retweet tout simplement
|
||||
else {
|
||||
//On follow les autres
|
||||
preg_match_all("/\s@([\w_-]+)/", $text, $matches);
|
||||
$mentions = $matches[1];
|
||||
$mentions[] = $screen;
|
||||
$mentions = array_unique($mentions);
|
||||
foreach ($mentions as $mention) {
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'follow',
|
||||
'value' => $mention,
|
||||
]);
|
||||
}
|
||||
|
||||
//On like si besoin
|
||||
preg_match("/LIKE/i", $text, $like);
|
||||
if (isset($like[0])) {
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'like',
|
||||
'value' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
$nextPageButton = $crawler->filterXPath('//div[@class="show-more"]/a')->link();
|
||||
$url = $nextPageButton->getUri();
|
||||
$crawler = $client->request('GET', $url);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$reponse = $client->getResponse();
|
||||
var_dump($reponse);
|
||||
|
||||
Cache::flush();
|
||||
|
||||
echo 'Fait !';
|
||||
|
||||
}
|
||||
|
||||
public function searchcontest()
|
||||
{
|
||||
$search = [
|
||||
"#concours",
|
||||
"concours like",
|
||||
"concours rt",
|
||||
"concours follow",
|
||||
"#JeuConcours",
|
||||
"JeuConcours",
|
||||
"giveaway",
|
||||
"concours pour gagner",
|
||||
"gagner rt",
|
||||
"Gagnez rt + follow",
|
||||
"offre follow gagnant",
|
||||
"RT & follow",
|
||||
"rt follow",
|
||||
//"rt suivre t.a.s",
|
||||
"concours tas le",
|
||||
"concours résultats le rt",
|
||||
"concours rt like",
|
||||
"concours rt fav",
|
||||
"RT tweet Follow",
|
||||
"concours rt follow",
|
||||
"rt follow tas",
|
||||
"rt follow tirage au sort",
|
||||
//"rt follow t.a.s",
|
||||
"rt follow gagner",
|
||||
"rt follow commente",
|
||||
"rt suivre concours",
|
||||
"rt suivez concours",
|
||||
"rt suivre tirage au sort",
|
||||
"rt suivre tas",
|
||||
"concours remporter",
|
||||
"remporter rt",
|
||||
//"concours t.a.s le",
|
||||
"tirage au sort concours",
|
||||
"concours",
|
||||
"concours résultat le rt"
|
||||
];
|
||||
|
||||
$k = array_rand($search);
|
||||
$phrase = $search[$k];
|
||||
|
||||
$date = Carbon::now()->subDays(2)->format('Y-m-d');
|
||||
|
||||
$url = 'https://nitter-autokdo.fly.dev/search?f=tweets&q='.urlencode('min_replies:500 lang:fr -filter:replies '.$phrase).'&since='.$date;
|
||||
|
||||
$client = new HttpBrowser(HttpClient::create(['verify_peer' => false, 'verify_host' => false, 'timeout' => '60']));
|
||||
|
||||
// Création des informations d'authentification
|
||||
$username = 'autokdo';
|
||||
$password = '@Gaudin95';
|
||||
$credentials = base64_encode("$username:$password");
|
||||
|
||||
// Ajout des informations d'authentification à l'en-tête de la demande HTTP
|
||||
$client->setServerParameter('HTTP_AUTHORIZATION', 'Basic ' . $credentials);
|
||||
$client->setServerParameter('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36');
|
||||
$crawler = $client->request('GET', $url);
|
||||
|
||||
$reponse = $client->getResponse();
|
||||
var_dump($reponse);
|
||||
|
||||
try{
|
||||
$results = $crawler->filterXPath('//div[@class="timeline-item "]')->each(function ($node) {
|
||||
$id = ($node->filterXPath('//*[@class="tweet-link"]'))->attr('href');
|
||||
$created_at = ($node->filterXPath('//span[@class="tweet-date"]/a'))->attr('title');
|
||||
$text = ($node->filterXPath('//*[@class="tweet-content media-body"]'))->text();
|
||||
$screen = ($node->filterXPath('//a[@class="username"]'))->text();
|
||||
$nbretweet = ($node->filterXPath('//*[@class="tweet-stat"][2]'))->text();
|
||||
$nbretweet = str_replace(',', '', $nbretweet);
|
||||
$nblike = ($node->filterXPath('//*[@class="tweet-stat"][4]'))->text();
|
||||
$nblike = str_replace(',', '', $nblike);
|
||||
$nbreply = ($node->filterXPath('//*[@class="tweet-stat"][1]'))->text();
|
||||
$nbreply = str_replace(',', '', $nbreply);
|
||||
|
||||
//Modifications
|
||||
$screen = str_replace('@', '', $screen);
|
||||
$id = str_replace('/'.$screen.'/status/', '', $id);
|
||||
$id = str_replace('#m', '', $id);
|
||||
|
||||
$contest = Contest::where('tweetid', $id)->first();
|
||||
$fake = Fake::where('screen_name', $screen)->first();
|
||||
|
||||
if(!$contest && !$fake && $nbretweet > 100) {
|
||||
$regex_detect_rts =
|
||||
[
|
||||
"/RT/",
|
||||
"/RETWEET/i",
|
||||
];
|
||||
foreach ($regex_detect_rts as $regex_detect_rt) {
|
||||
//if (strstr($string, $url)) { // mine version
|
||||
preg_match($regex_detect_rt, $text, $invites);
|
||||
if (isset($invites[0])) {
|
||||
$rt = true;
|
||||
}
|
||||
}
|
||||
|
||||
//On verifie que si RT
|
||||
if (isset($rt)) {
|
||||
$inputs = array();
|
||||
//On recherche la date de fin du concours
|
||||
$date = $this->getDate($text);
|
||||
if ($date != null) {
|
||||
$fin = $date;
|
||||
} else {
|
||||
$fin = $this->getTwitterDate($created_at);
|
||||
}
|
||||
//On recherche la date de fin du concours
|
||||
if ($fin >= Carbon::now()->format('Y-m-d')) {
|
||||
|
||||
$categorie = $this->getCategorie($text);
|
||||
|
||||
$organizer = $this->getOrganizer($screen);
|
||||
|
||||
$concours = Contest::create([
|
||||
'category_id' => $categorie,
|
||||
'organizer_id' => $organizer,
|
||||
'description' => $text,
|
||||
'url' => 'https://twitter.com/'.$screen.'/status/'.$id,
|
||||
'tweetid' => $id,
|
||||
'fin' => $fin,
|
||||
'nbretweet' => $nbretweet,
|
||||
'nblike' => $nblike,
|
||||
'nbreply' => $nbreply,
|
||||
]);
|
||||
|
||||
//On recherche un tag
|
||||
$regex_detect_tags =
|
||||
[
|
||||
"/INVIT/i",
|
||||
"/IDENTIFI/i",
|
||||
"/TAG/i",
|
||||
"/HASHTAG/i",
|
||||
"/RT AVEC/i",
|
||||
"/MENTIONN/i",
|
||||
"/COMMENT/i",
|
||||
"/RETWEET AVEC/i",
|
||||
"/TWEET AVEC/i",
|
||||
];
|
||||
|
||||
foreach ($regex_detect_tags as $regex_detect_tag) {
|
||||
//if (strstr($string, $url)) { // mine version
|
||||
preg_match($regex_detect_tag, $text, $invites);
|
||||
if (isset($invites[0])) {
|
||||
$tweet = true;
|
||||
}
|
||||
}
|
||||
|
||||
//On verifie s'il demande un tag ou un hashtag
|
||||
if (isset($tweet)) {
|
||||
|
||||
$tag = 'Je veux gagner ce concours @ActuFoot_ @Mediavenir';
|
||||
|
||||
preg_match_all("/#[a-zA-Z0-9]+/", $text, $hashtag);
|
||||
|
||||
if (isset($hashtag[0])) {
|
||||
$hashtags = implode(" ", $hashtag[0]);
|
||||
$tag = $tag . ' ' . $hashtags;
|
||||
}
|
||||
|
||||
$tag = urlencode($tag);
|
||||
|
||||
//On tweet avec un le tag
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'reply',
|
||||
'value' => $tag,
|
||||
]);
|
||||
|
||||
//On follow les autres
|
||||
preg_match_all("/\s@([\w_-]+)/", $text, $matches);
|
||||
$mentions = $matches[1];
|
||||
$mentions[] = $screen;
|
||||
$mentions = array_unique($mentions);
|
||||
foreach ($mentions as $mention) {
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'follow',
|
||||
'value' => $mention,
|
||||
]);
|
||||
}
|
||||
|
||||
//On like si besoin
|
||||
preg_match("/LIKE/i", $text, $like);
|
||||
if (isset($like[0])) {
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'like',
|
||||
'value' => $id,
|
||||
]);
|
||||
}
|
||||
} //Sinon on retweet tout simplement
|
||||
else {
|
||||
//On follow les autres
|
||||
preg_match_all("/\s@([\w_-]+)/", $text, $matches);
|
||||
$mentions = $matches[1];
|
||||
$mentions[] = $screen;
|
||||
$mentions = array_unique($mentions);
|
||||
foreach ($mentions as $mention) {
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'follow',
|
||||
'value' => $mention,
|
||||
]);
|
||||
}
|
||||
|
||||
//On like si besoin
|
||||
preg_match("/LIKE/i", $text, $like);
|
||||
if (isset($like[0])) {
|
||||
Action::create([
|
||||
'contest_id' => $concours->id,
|
||||
'type' => 'like',
|
||||
'value' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
Cache::flush();
|
||||
|
||||
echo 'Fait !';
|
||||
|
||||
}
|
||||
|
||||
public function getOrganizer($screen)
|
||||
{
|
||||
$organiser = Organizer::where('screen_name', $screen)->first();
|
||||
|
||||
if ($organiser){
|
||||
return $organiser->id;
|
||||
}else
|
||||
{
|
||||
$client = new HttpBrowser(HttpClient::create(['verify_peer' => false, 'verify_host' => false, 'timeout' => '60']));
|
||||
// Création des informations d'authentification
|
||||
$username = 'autokdo';
|
||||
$password = '@Gaudin95';
|
||||
$credentials = base64_encode("$username:$password");
|
||||
|
||||
// Ajout des informations d'authentification à l'en-tête de la demande HTTP
|
||||
$client->setServerParameter('HTTP_AUTHORIZATION', 'Basic ' . $credentials);
|
||||
$client->setServerParameter('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36');
|
||||
$crawler = $client->request('GET', 'https://nitter-autokdo.fly.dev/'.$screen);
|
||||
try{
|
||||
$name = $crawler->filterXPath('//*[@class="profile-card-fullname"]')->text();
|
||||
$description = $crawler->filterXPath('//*[@class="profile-bio"]')->text();
|
||||
$profileUrl = $crawler->getUri();
|
||||
$parsedUrl = parse_url($profileUrl);
|
||||
$baseTwitterUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
|
||||
|
||||
|
||||
$image = $crawler->filterXPath('//meta[@property="og:image"]')->attr('content');
|
||||
$url = str_replace("http://nitter-autokdo.fly.dev/pic/", "", $image);
|
||||
$url = urldecode($url);
|
||||
$url = 'https://'.$url;
|
||||
$response = Http::get($url);
|
||||
$contents = $response->body();
|
||||
|
||||
// Utilisation de getimagesize pour obtenir les informations sur l'image
|
||||
$imageInfo = getimagesizefromstring($contents);
|
||||
|
||||
if ($imageInfo === false) {
|
||||
$filename = 'icon-96x96.png';
|
||||
}
|
||||
|
||||
$format = image_type_to_extension($imageInfo[2], false);
|
||||
$filename = uniqid() . '.' . $format;
|
||||
|
||||
// Stocker l'image dans le répertoire 'ads' du stockage
|
||||
Storage::put('/public/logo/'.$filename, $contents);
|
||||
|
||||
$organiser = Organizer::create([
|
||||
'name' => $name,
|
||||
'screen_name' => $screen,
|
||||
'description' => $description,
|
||||
'logo' => $filename,
|
||||
'url' => 'https://twitter.com/'.$screen,
|
||||
]);
|
||||
|
||||
return $organiser->id;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function getCategorie($data)
|
||||
{
|
||||
$client = new HttpBrowser(HttpClient::create(['verify_peer' => false, 'verify_host' => false, 'timeout' => '60']));
|
||||
$client->request('GET', 'https://api.uclassify.com/v1/twittercontests/categories/classify/?readKey=c7ivTcoN2ycU&text='.$data);
|
||||
|
||||
$json = $client->getResponse()->getContent();
|
||||
|
||||
$array = json_decode($json,true);
|
||||
|
||||
$laravelArray = collect($array);
|
||||
|
||||
$laravelArray = $laravelArray->sortDesc();
|
||||
|
||||
$value = $laravelArray->first();
|
||||
|
||||
if($value < '0.5'){
|
||||
$categorie = '20';
|
||||
}
|
||||
else{
|
||||
|
||||
$cat = $laravelArray->keys()->first();
|
||||
|
||||
if($cat == 'argent'){
|
||||
$categorie = '1';
|
||||
}elseif($cat == 'beaute'){
|
||||
$categorie = '2';
|
||||
}elseif($cat == 'console'){
|
||||
$categorie = '3';
|
||||
}elseif($cat == 'cuisine'){
|
||||
$categorie = '4';
|
||||
}elseif($cat == 'dvd'){
|
||||
$categorie = '5';
|
||||
}elseif($cat == 'enfant'){
|
||||
$categorie = '6';
|
||||
}elseif($cat == 'goodies'){
|
||||
$categorie = '7';
|
||||
}elseif($cat == 'invitation'){
|
||||
$categorie = '8';
|
||||
}elseif($cat == 'livre'){
|
||||
$categorie = '9';
|
||||
}elseif($cat == 'maison'){
|
||||
$categorie = '10';
|
||||
}elseif($cat == 'mode'){
|
||||
$categorie = '11';
|
||||
}elseif($cat == 'pc'){
|
||||
$categorie = '12';
|
||||
}elseif($cat == 'sport'){
|
||||
$categorie = '13';
|
||||
}elseif($cat == 'telephone'){
|
||||
$categorie = '14';
|
||||
}elseif($cat == 'voiture'){
|
||||
$categorie = '15';
|
||||
}elseif($cat == 'voyage'){
|
||||
$categorie = '16';
|
||||
}else{
|
||||
$categorie = '20';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $categorie;
|
||||
|
||||
}
|
||||
|
||||
private function getDate($string) {
|
||||
// Pattern pour détecter les dates au format JJ/MM ou JJ.MM
|
||||
$pattern_jjmm = '/\b(\d{1,2})(\/|\.)\d{1,2}\b/';
|
||||
|
||||
// Pattern pour détecter les dates du style "1 août" (ou autre mois en français)
|
||||
$mois_fr = array(
|
||||
'janvier', 'février', 'mars', 'avril', 'mai', 'juin',
|
||||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'
|
||||
);
|
||||
$pattern_jj_mois_fr = '/\b(\d{1,2}) (' . implode('|', $mois_fr) . ')\b/i';
|
||||
|
||||
// Stocker les correspondances dans un tableau
|
||||
$correspondances = array();
|
||||
|
||||
// Chercher les dates au format JJ/MM ou JJ.MM
|
||||
if (preg_match_all($pattern_jjmm, $string, $matches)) {
|
||||
$correspondances = array_merge($correspondances, $matches[0]);
|
||||
}
|
||||
|
||||
// Chercher les dates du style "1 août" (ou autre mois en français)
|
||||
if (preg_match_all($pattern_jj_mois_fr, $string, $matches)) {
|
||||
// Convertir le mois en format numérique (1 pour janvier, 2 pour février, etc.)
|
||||
$mois_numerique = array_flip($mois_fr);
|
||||
foreach ($matches[2] as $index => $mois) {
|
||||
$matches[0][$index] = $matches[1][$index] . '/' . str_pad($mois_numerique[strtolower($mois)] + 1, 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
$correspondances = array_merge($correspondances, $matches[0]);
|
||||
}
|
||||
|
||||
// Vérifier s'il y a des dates détectées
|
||||
if (empty($correspondances)) {
|
||||
// Afficher une erreur si aucune date n'est détectée
|
||||
return "";
|
||||
}
|
||||
|
||||
// Récupérer la dernière date détectée
|
||||
$derniere_date = end($correspondances);
|
||||
|
||||
// Convertir la dernière date au format "Y-m-d" (année-mois-jour)
|
||||
if (strpos($derniere_date, '/') !== false) {
|
||||
// Format JJ/MM
|
||||
list($jour, $mois) = explode('/', $derniere_date);
|
||||
$annee = date('Y');
|
||||
} else {
|
||||
// Format JJ.MM
|
||||
list($jour, $mois) = explode('.', $derniere_date);
|
||||
$annee = date('Y');
|
||||
}
|
||||
|
||||
$date_convertie = date('Y-m-d', strtotime("$annee-$mois-$jour"));
|
||||
|
||||
return $date_convertie;
|
||||
}
|
||||
|
||||
private function getTwitterDate($text){
|
||||
// Utilisez une expression régulière pour extraire la date
|
||||
$pattern = '/(\w{3} \d{1,2}, \d{4})/';
|
||||
preg_match($pattern, $text, $matches);
|
||||
|
||||
if (count($matches) >= 2) {
|
||||
// Format de date extrait
|
||||
$dateString = $matches[1];
|
||||
|
||||
// Analyse de la date
|
||||
$date = Carbon::createFromFormat('M d, Y', $dateString);
|
||||
|
||||
// Obtenez la date au format Y-m-d
|
||||
$formattedDate = $date->addDays(1)->format('Y-m-d');
|
||||
|
||||
return $formattedDate;
|
||||
} else {
|
||||
return Carbon::now()->addDays(1)->format('Y-m-d');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
abstract class Controller
|
||||
{
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
//
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Account extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $casts = [
|
||||
'password' => 'encrypted',
|
||||
'cookies' => 'encrypted',
|
||||
];
|
||||
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function contests()
|
||||
{
|
||||
return $this->hasMany(Contest::class);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Contest extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $guarded = [];
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
public function organizer()
|
||||
{
|
||||
return $this->belongsTo(Organizer::class);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fake extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Organizer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function contests()
|
||||
{
|
||||
return $this->hasMany(Contest::class);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*/
|
||||
public function shouldDiscoverEvents(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class FortifyServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Fortify::createUsersUsing(CreateNewUser::class);
|
||||
//Fortify::createUsersUsing(CreateNewUser::class);
|
||||
Fortify::updateUserProfileInformationUsing(UpdateUserProfileInformation::class);
|
||||
Fortify::updateUserPasswordsUsing(UpdateUserPassword::class);
|
||||
Fortify::resetUserPasswordsUsing(ResetUserPassword::class);
|
||||
@@ -42,5 +42,33 @@ class FortifyServiceProvider extends ServiceProvider
|
||||
RateLimiter::for('two-factor', function (Request $request) {
|
||||
return Limit::perMinute(5)->by($request->session()->get('login.id'));
|
||||
});
|
||||
|
||||
Fortify::loginView(function () {
|
||||
return view('auth.login');
|
||||
});
|
||||
|
||||
//Fortify::registerView(function () {
|
||||
// return view('auth.register');
|
||||
//});
|
||||
|
||||
Fortify::requestPasswordResetLinkView(function () {
|
||||
return view('auth.forgot-password');
|
||||
});
|
||||
|
||||
Fortify::resetPasswordView(function ($request) {
|
||||
return view('auth.reset-password', ['request' => $request]);
|
||||
});
|
||||
|
||||
// Fortify::verifyEmailView(function () {
|
||||
// return view('auth.verify-email');
|
||||
// });
|
||||
|
||||
Fortify::confirmPasswordView(function () {
|
||||
return view('auth.confirm-password');
|
||||
});
|
||||
|
||||
Fortify::twoFactorChallengeView(function () {
|
||||
return view('auth.two-factor-challenge');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to your application's "home" route.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user