Skip to content

Instantly share code, notes, and snippets.

@janus57
janus57 / upload.php
Created September 11, 2022 07:50
Simple PHP upload test
<?php
####
#### Source : https://www.w3schools.com/php/php_file_upload.asp
#### Modified by : janus57
####
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
@janus57
janus57 / how-to_add_public_key.md
Last active October 5, 2019 09:18
add public key

Check sshd_config for openssh

First open the "sshd_config" config file (/etc/ssh/sshd_config) en check these lines :

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
AuthorizedKeysFile  .ssh/authorized_keys .ssh/authorized_keys2

AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 ⇒ need to be uncommented

After that restart sshd service : systemctl restart sshd.service

@janus57
janus57 / sources-list-stretch.sh
Last active September 1, 2018 16:53
Use default French mirror of Debian 9 (stretch) - main & contrib
#!/bin/bash
# Generator used : https://debgen.simplylinux.ch/
printf "#------------------------------------------------------------------------------#
# OFFICIAL DEBIAN REPOS
#------------------------------------------------------------------------------#
###### Debian Main Repos
deb http://ftp.fr.debian.org/debian/ stretch main
deb http://ftp.fr.debian.org/debian/ stretch-updates main
@janus57
janus57 / recaptchav2_test.php
Created May 20, 2018 22:36
Test ReCaptcha V2 - all in one
<?php
htmlentities(extract($_POST));
if ( $submit && isset($comment) ) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
@janus57
janus57 / curl_test.php
Last active December 21, 2023 21:57
cURL test with PHP into browser
<?php
$USERAGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/115.0';
$URL = false;
$curl_error = false;
$validation = true;
if (!empty($_POST['url']) && filter_var($_POST['url'], FILTER_VALIDATE_URL)) {
$URL = $_POST['url'];
}
elseif (!empty($_POST['url']) && !filter_var($_POST['url'], FILTER_VALIDATE_URL)) {
$validation = false;
@janus57
janus57 / make_patch_files.sh
Created October 2, 2017 11:26
Create a patch file for specific files (.css & .tpl) and save it under the same tree
#!/bin/bash
FOLDER_OLD="phpboost_5-0"
FOLDER_NEW="phpboost_5-1"
FOLDER_PATCHES="./patches"
mkdir -p ${FOLDER_PATCHES}
for newfile in `find $FOLDER_NEW -type f -name "*.css" -o -name "*.tpl"`
do
sufix=${newfile#${FOLDER_NEW}/}
oldfile="${FOLDER_OLD}/${sufix}"
@janus57
janus57 / install.sh
Created June 10, 2017 14:26
Images optimization
apt install jpegoptim pngquant optipng
@janus57
janus57 / .htaccess
Last active September 23, 2018 15:05
www or none ? That is the question
# Rewrite engine => "Power ON"
RewriteEngine On
RewriteBase /
# Force non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Force www
RewriteCond %{HTTP_HOST} !^www\. [NC]
@janus57
janus57 / install_php_sury.sh
Last active March 12, 2024 21:14
Install "deb.sury.org" repository for PHP
#!/bin/bash
# For up-to-date version see : https://packages.sury.org/php/README.txt
wget https://packages.sury.org/php/apt.gpg -O /usr/share/keyrings/deb.sury.org-php.gpg
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php-sury.list
apt update
@janus57
janus57 / sources-list-jessie.sh
Last active August 10, 2018 16:56
Use default French mirror of Debian 8 (jessie) - main & contrib
#!/bin/bash
# Generator used : https://debgen.simplylinux.ch/
printf "#------------------------------------------------------------------------------#
# OFFICIAL DEBIAN REPOS #
#------------------------------------------------------------------------------#
###### Debian Main Repos
deb http://ftp.fr.debian.org/debian/ jessie main contrib
deb-src http://ftp.fr.debian.org/debian/ jessie main contrib