Skip to main content

Posts

Discord webhook attachment json

I already found this post: https://www.reddit.com/r/discordapp/comments/83itgm/does_anyone_know_how_to_send_embeds_from_php_to_a/ But I'm trying to send a attachment/a csv file. Someone have an idea how it works? API-Description: https://discord.com/developers/docs/resources/webhook#execute-webhook But I dont know how to solve it. I'm able to send messages with embeds and fields and stuff, but I dont know how the json should look. Current json which I'm sending. Array ( [content] => [embeds] => Array ( [0] => Array ( [title] => Title [color] => 65300 [url] => /var/www/html/includes/discord/CSV_from_2021-05-27_00-00-00_to_2021-05-27_23-59-59.csv [description] => Desc ) ) [file] => /var/www/html/includes/discord/CSV_from_2021-05-27_00-00-00_to_2021-05-27_23-59-59.csv ) And I also change the head

Laravel 8.x redirect()->intended() keeps changing to the wrong url

I am trying to create a way to confirm the password when executing a sensible action on a website using laravel. I use a form to create the action, that uses a route to the sensible action, using a middleware to confirm the password. At the end of the confirmation it returns redirect()->intended() to redirect to the action the route was originally was supposed to if no password verification took place. The problem here is that no matter what, redirect()->intended() is never the action I wanted to execute in the first place, it just redirects to the page where the first form is generated. I use a form to execute said action. <form method="post" action="/user//sensible_page/" enctype="multipart/form-data"> <button type="submit" id="sensible_button" class="col-auto align-self-end btn btn-danger">Click to go to sensible page</a> </form> Here are the routes I use Route::g

Allow login only for active users

I need to allow login only for allowed users, this is my controller: class LoginController extends Controller { public function index() { return view('login'); } public function login(Request $request) { $credentials = $request->only('user', 'password'); if (!Auth::attempt($credentials)) { return back()->with('error', 'Usuario o ContraseƱa Invalidos!'); } else if (Auth::user()->status != 1) { return back()->with('error', 'Usuario no autorizado'); } $request->session()->regenerate(); return redirect('home'); } public function logout(Request $request) { Auth::logout(); $request->session()->regenerate(); return redirect('/login'); } } it works but it is allowing all the users, even those with status = 0, what am i doing wrong? thanks for your help..

Symlink Error: PHP Warning: symlink(): File exists

Good day, Could someone please assist / advise as I am trying to create a symlink between the images folder in the public_html directory and the images folder in the App directory. When running the symlink file, the message displays: "Symlink process successfully completed", but I receive an error log stating: PHP Warning: symlink(): File exists in /home/property/public_html/symlink.php on line 5 The code that I am using in order to try and create the symlink are: <?php $targetFolder = '/home/property/app/images'; $linkFolder = '/home/property/public_html/images'; symlink($targetFolder,$linkFolder); echo 'Symlink process successfully completed'; ?> source https://stackoverflow.com/questions/67740392/symlink-error-php-warning-symlink-file-exists

Not sure if this is hard or easy way, need advice with getting info from database and displaying

Im trying to figure out what is best and easy way without writing much code. So there is Admin panel and I want many stuff to show from database info, like how many users, how many posts and etc. Here is controller: public function userCount() { $count = DB::select('select count(*) as total from users'); return view('/admin', ['count' => $count[0]->total]); } Then here is Route: Route::get('/admin', [AdminController::class, 'userCount']); And then in admin.blade.php where is info just printing The question is if its right way to make like this or there is better way? Example I can create maybe 1 controller "InfoController" and get all info from FB, create them as a functions and then print in admin.blade.php? Should I be using for every function a new route? Also if there is any fixes

data base data is not showing up in index

commandes.php <?php function ajouter($nom,$categorie,$prix){ if(connectMaBasi()){ $bd= connectMaBasi() ; $sql = "INSERT INTO produits (nom, categorie, prix)VALUES ('$nom','$categorie','$prix')"; $resultat = mysqli_query($bd,$sql) or die ('Erreur SQL !'.$sql.'<br />'.mysqli_error()); return $resultat; mysqli_close(); } } function afficher(){ $bd = mysqli_connect ('localhost', 'root', '','ecommerce'); return $bd; if($bd) { $bd= connectMaBasi() ; $sql = "SELECT * FROM produits"; $resultat = mysqli_query($bd,$sql) or die ('Erreur SQL !'.$sql.'<br />'.mysqli_error()); //$ligne = mysqli_fetch_assoc($resultat); return $resultat; mysqli_close(); } } function supprimer($id){ if(connectMaBasi()) { $bd= connectMaBasi() ; $sql = "DEL

Optimize filter() to stop after take limit reached

I have created the following code to search and page through an array: let data = ['banana1','banana2','apple1','apple2','apple3','apple4','apple5','apple6','apple7','apple8','apple9','apple10','apple11','apple12','strawberry1','strawberry2','strawberry3','strawberry4','strawberry5']; let searchTerm = "app"; let skip = 5; let take = 2; let count = 0; var filtered = data.filter( (item, index) => { if(index < skip) return false; if(count >= take) return false; if(item.includes(searchTerm)){ count++; return true; }; return false; }); console.log(filtered); It works but once the take limit is reached if will keep looping for entire array. Is there a way to exit filter when take limit is hit or a different more efficient way to write this code? Via Active questions tagged javascript - Stack Over