Skip to content

Instantly share code, notes, and snippets.

View md-riaz's full-sized avatar
👨‍💻
PHP Developer

MD Riaz md-riaz

👨‍💻
PHP Developer
View GitHub Profile
function getLocalStorage() {
try {
return window.localStorage;
} catch (_) {
const store = {};
return {
getItem(name) {
return store[name] || null;
},
setItem(name, val) {
// Define: Linkify plugin
(function($){
var url1 = /(^|<|\s)(www\..+?\..+?)(\s|>|$)/g,
url2 = /(^|<|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|>|$)/g,
linkifyThis = function () {
var childNodes = this.childNodes,
i = childNodes.length;
while(i--)
<?php
function create_zip(array $files, string $destination, bool $overwrite = false): bool
{
// If the zip file already exists and overwrite is false, throw an exception
if (file_exists($destination) && !$overwrite) {
throw new Exception("Zip file already exists and overwrite is false.");
}
// Filter out any non-existing files
$valid_files = array_filter($files, "file_exists");
// If we have valid files...
#!/bin/bash
# Configuration variables
DOMAIN="example.com"
WILDCARD="*.example.com"
EMAIL="admin@example.com"
API_ENDPOINT="https://your-api-endpoint.com/update-dns-record"
SLEEP_INTERVAL=86400 # 24 hours in seconds
# Function to add DNS record using custom API request
<?php
// enable errors
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
trait PNServerHelper
{
/**
* Get classname without namespace.
<?php
function singular(string $word)
{
//"-es" is used for words that end in "-x", "-s", "-z", "-sh", "-ch" in which case you add
if (substr($word, -2) == "es") {
if (substr($word, -4) == "sses") { // eg. 'addresses' to 'address'
return substr($word, 0, -2);
} elseif (substr($word, -3) == "ses") { // eg. 'databases' to 'database' (necessary!)
return substr($word, 0, -1);
<?php
$secret = ''; // paste your Secret here
//fetch request body
$data = file_get_contents('php://input');
$payload = $_SERVER["HTTP_HB_TIMESTAMP"] . $data;
$signature = hash_hmac('sha256', $payload, $secret);

Here's how you can do it:

  1. Create a New Server Block Configuration File: First, create a new Nginx server block configuration file for your subdomain. You can create this file in the /etc/nginx/sites-available/ directory. Replace subdomain.example.com with your actual subdomain:

    sudo nano /etc/nginx/sites-available/subdomain.example.com
  2. Configure the Server Block:

#!/bin/bash
# Function to create the website directory and files
function create_website() {
local domain_name=$1
# Check if the domain name is provided
if [ -z "$domain_name" ]; then
echo "Please provide a domain name."
exit 1
<?php
function get_sans_from_csr($csr) {
$tempFile = tempnam(sys_get_temp_dir(), 'csr');
file_put_contents($tempFile, $csr);
$opensslCsrOutput = shell_exec("openssl req -noout -text -in " . escapeshellarg($tempFile));
unlink($tempFile);
if ($opensslCsrOutput !== null) {