Skip to content

Instantly share code, notes, and snippets.

View alpenzoo's full-sized avatar

Narcis Iulian Paun alpenzoo

View GitHub Profile
<?php
//create random hash, please notice $6$ as first chars in salt string
$salt = "$6$5e2de398074f9213";
$hash = crypt('pswt1', $salt);
echo $hash;
//mariaDB compatible code: select ENCRYPT('pswt1', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16)));
echo "<hr>";
@alpenzoo
alpenzoo / send-fcm.php
Created August 24, 2017 12:21
Firebase FCM from PHP the easy way. Send payload as desired. Returns execution result. Just a gist, no production code.
<?php
$deviceToken = $_POST['dt'];
$body = $_POST['b'];
if (empty($deviceToken)){
die ("nothing to do, no device. exit");
}
#API access key from Google API's Console
define( 'API_ACCESS_KEY', '' );
#prep the bundle
<?php
/**
* The __halt_compiler() function will stop the PHP compiler when called.
* You can then use the __COMPILER_HALT_OFFSET__ constant to grab the contents of the PHP file after the halt.
* In this example a PHP template is stored after the halt, to allow simple separation of logic from templating.
* The template is stored in a temporary file so it can be included and parsed.
*
* See: https://github.com/bobthecow/mustache.php/blob/dev/src/Mustache/Loader/InlineLoader.php
* http://php.net/manual/en/function.halt-compiler.php
*/