Skip to content

Instantly share code, notes, and snippets.

View get_current_url.php
<?php
/**
* @see: https://www.phpfreelancer.org/blog/php-get-current-url.php
*/
function get_current_url()
{
$url = false;
// check whether this script is being run as a web page
if (isset($_SERVER['SERVER_ADDR']))
View slack-auto-invite.php
<?php
$_POST['email'] = '';
// slack invite
$group = ''; // team name
$token = ''; // admin token generated at https://api.slack.com/docs/oauth-test-tokens
$data = array(
'email' => $_POST['email'],
'channels' => '',
'first_name' => '',
@Magentron
Magentron / upgrade-phpmailer.sh
Created Dec 29, 2016
Upgrade PHPMailer files automatically to latest version
View upgrade-phpmailer.sh
#!/bin/sh
#
# phpmailer-upgrade.sh - Upgrade PHPMailer files automatically to latest version
#
# Copyright (c) 2016 Derks.IT / Jeroen Derks / Magentron
#
# Licensed under the Apache License, Version 2.0 (the “License”);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@Magentron
Magentron / dpkg-verify.alias.sh
Created Aug 10, 2016
An alias to verify that installed files are unchanged using dpkg package's md5sums
View dpkg-verify.alias.sh
dpkg-verify() {
exitcode=0
for file in $*; do
pkg=`dpkg -S "$file" | cut -d: -f 1`
hashfile="/var/lib/dpkg/info/$pkg.md5sums"
if [ -s "$hashfile" ]; then
rfile=`echo "$file" | cut -d/ -f 2-`
phash=`grep -E "$rfile\$" "$hashfile" | cut -d\ -f 1`
hash=`md5sum "$file" | cut -d\ -f 1`
if [ "$hash" = "$phash" ]; then