This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private static function autoload() | |
{ | |
spl_autoload_register(function ($class) { | |
// Define base directories for known namespaces | |
$baseDirs = [ | |
'Framework\\Core\\' => FRAMEWORK_PATH . 'Core/', | |
'App\\' => APP_PATH | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class JWT { | |
private $secretKey; | |
public function __construct($secretKey) { | |
$this->secretKey = $secretKey; | |
} | |
public function generateToken($payload, $expiration = 3600) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WhatsappClass | |
{ | |
private $phoneNumberId; | |
private $accessToken; | |
private $url; | |
/** | |
* @param string $phoneNumberId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getLocalStorage() { | |
try { | |
return window.localStorage; | |
} catch (_) { | |
const store = {}; | |
return { | |
getItem(name) { | |
return store[name] || null; | |
}, | |
setItem(name, val) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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--) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// enable errors | |
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
error_reporting(E_ALL); | |
trait PNServerHelper | |
{ | |
/** | |
* Get classname without namespace. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
NewerOlder