Skip to content

Instantly share code, notes, and snippets.

View gaffling's full-sized avatar
🕚
I don't have time to hurry!

Igor Gaffling gaffling

🕚
I don't have time to hurry!
View GitHub Profile
@gaffling
gaffling / class-htmlfixer.php
Last active February 7, 2020 11:59
[HTML fixer] PHP class taht clean & repair html code, unofficial copy of http://barattalo.it/html-fixer/ #php #class #HTMLrepair
<?PHP
/* -------------------------------------------------------------------------------------------------------------------------------- */
/* [HTML fixer] PHP class taht clean & repair html code, unofficial copy of http://barattalo.it/html-fixer/ #php #class #HTMLrepair */
/* -------------------------------------------------------------------------------------------------------------------------------- */
class HtmlFixer {
/* USAGE:
$class = new HtmlFixer();
$clean_html = $class->getFixedHtml($dirty_html); */
@gaffling
gaffling / function.php
Last active December 1, 2020 16:38
[Array 2 Table] HTML Generator #php #class #table
<?php
/* ---------------------------------------------------- */
/* [Array 2 Table] HTML Generator #php #function #table */
/* ---------------------------------------------------- */
/**
* Generate a table from an array
* @see https://stackoverflow.com/questions/4746079/how-to-create-a-html-table-from-a-php-array
*
@gaffling
gaffling / class-backup-mySQL.php
Last active February 7, 2020 07:37
[Backup mySQL & ZIP] Backup you mySQL Database #php #class #backup
<?php
/* ------------------------------------------------------------------- */
/* [Backup mySQL & ZIP] Backup you mySQL Database #php #class #backup */
/* ------------------------------------------------------------------- */
// SETUP
$config = array(
'backup_version' => '1.0.0', // version of the backup app
'backup_db_host' => 'localhost', // the mySQL host name - most time localhost
@gaffling
gaffling / Exception.php
Last active February 7, 2020 11:36
[Exeption] Custom Exceptions #php #class #errorhandling
<?php
/* ------------------------------------------------------- */
/* [Exeption] Custom Exceptions #php #class #errorhandling */
/* ------------------------------------------------------- */
interface IException {
/* Protected methods inherited from Exception class */
public function getMessage(); // Exception message
public function getCode(); // User-defined Exception code
@gaffling
gaffling / avatar.php
Last active February 7, 2020 12:13
[Avatar Generator] Make Avatar Image Tag or SVG from given Name or mail address #php #function #avatar
<?php
/* ------------------------------------------------------------------------------------------------------ */
/* [Avatar Generator] Make Avatar Image Tag or SVG from given Name or mail address #php #function #avatar */
/* ------------------------------------------------------------------------------------------------------ */
function avatar ($name, $type='', $size=64) {
/*TODO
Flat Hash (from http://flathash.com/)
Robot and monsters Hash (from https://robohash.org/)
@gaffling
gaffling / cron-returns.php
Last active February 7, 2020 07:59
[Cronjob Returns] Returns of a Script that started via cronjob and processes background tasks #php #function #cronjob
<?php
/* --------------------------------------------------------------------------------------------------------------------- */
/* [Cronjob Returns] Returns of a Script that started via cronjob and processes background tasks #php #function #cronjob */
/* --------------------------------------------------------------------------------------------------------------------- */
// ...here the work is done... (use $status for feedback to browser)
if(php_sapi_name() == "cli") {
// if it is called over console maybe its a cronjob an no answer is given
@gaffling
gaffling / form.php
Last active February 12, 2020 14:13
[File Upload] HTML Form and Upload Script #php #upload #materialize
<?php
/* ------------------------------------------------------------------------ */
/* [File Upload] HTML Form and Upload Script #function #upload #materialize */
/* ------------------------------------------------------------------------ */
$id = '4711'; // SETUP ID of the Upload Record
?>
<!DOCTYPE html>
<html lang="en">
@gaffling
gaffling / html-compress.php
Last active February 7, 2020 07:34
[HTML Compress] This function can be used to minify HTML #php #function #HTMLminify
<?php
/* ----------------------------------------------------------------------------------- */
/* [HTML Compress] This function can be used to minify HTML #php #function #HTMLminify */
/* ----------------------------------------------------------------------------------- */
function html_compress($url) {
/*
+ Remove white spaces and tags before and after HTML tags
+ Remove comments
@gaffling
gaffling / mail.tpl.htm
Last active February 20, 2020 12:05
[Send Mail] Use PHPMailer or PHP mail() function as fallback NEED logo.png and mail.tpl.htm & github.com/PHPMailer/PHPMailer #php #class #html #email
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>[SUBJECT]</title>
<style>
/* -------------------------------------
RESPONSIVE AND MOBILE FRIENDLY STYLES
------------------------------------- */
@gaffling
gaffling / session.php
Last active February 7, 2020 07:26
[Session Wrapper] A simple Session Wrapper #php #class #session
<?php
/* --------------------------------------------------------------- */
/* [Session Wrapper] A simple Session Wrapper #php #class #session */
/* --------------------------------------------------------------- */
include_once 'CustomException.php';
if ( !class_exists('CustomException') ) {
class CustomException extends Exception {}