Skip to content

Instantly share code, notes, and snippets.

hakre hakre

View GitHub Profile
@hakre
hakre / dl-file.php
Created Jan 2, 2012
Wordpress login to download uploaded files
View dl-file.php
<?php
/*
* dl-file.php
*
* Protect uploaded files with login.
*
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in
*
* @author hakre <http://hakre.wordpress.com/>
* @license GPL-3.0+
@hakre
hakre / README.md
Last active Apr 12, 2019
Iterators for PHP XMLReader for ease of parsing
View README.md

Iterators for PHP XMLReader for ease of parsing

Change Log:

  • 0.1.10 maintenance release with fixes.

  • 0.1.9 maintenance release with fixes. added XMLReaderNode::expand().

  • 0.1.8 maintenance release with fixes.

@hakre
hakre / example.php
Created Jul 14, 2015
Register Xpath Namespace-Prefixes globally on a SimpleXML Document
View example.php
<?php
/**
* @link http://stackoverflow.com/questions/28520983/php-simplexml-xpath-does-not-keep-the-namespaces-when-returns-data
*/
/**
* Class SimpleXpath
*
* DOMXpath wrapper for SimpleXMLElement
*
@hakre
hakre / XmlArrayElement.php
Created Jul 14, 2015
Recursive Method Calls with SimpleXML and DOMDocument Context
View XmlArrayElement.php
<?php
/**
* Class ArrayXmlElement
*
* Use an array definition stored as XML to convert a tree structure from another DOMDocument
*
* @author hakre <http://hakre.wordpress.com>
*/
class XmlArrayElement extends SimpleXMLElement
{
@hakre
hakre / imap-attachment.php
Created Apr 11, 2012
Save attachments from imap messages to disk.
View imap-attachment.php
<?php
/**
* imap-attachment.php
*
* @author hakre <hakre.wordpress.com>
* @link http://stackoverflow.com/questions/9974334/how-to-download-mails-attachment-to-a-specific-folder-using-imap-and-php
*/
/**
* Utility Class
@hakre
hakre / output-buffer-to-temp.php
Created Dec 19, 2012
Output buffer for large output to temporary file on disk (>2MB)
View output-buffer-to-temp.php
<?php
/*
* Output buffer for large output to temporary file on disk (>2MB)
*
* @link http://stackoverflow.com/questions/5446647/how-can-i-use-var-dump-output-buffering-without-memory-errors/
*/
/**
* Iterate over lines of a stream resource.
*
@hakre
hakre / iconv-l.txt
Created Dec 2, 2012
Iconv List of Encodings
View iconv-l.txt
ANSI_X3.4-1968 ANSI_X3.4-1986 ASCII CP367 IBM367 ISO-IR-6 ISO646-US ISO_646.IRV:1991 US US-ASCII CSASCII
UTF-8
ISO-10646-UCS-2 UCS-2 CSUNICODE
UCS-2BE UNICODE-1-1 UNICODEBIG CSUNICODE11
UCS-2LE UNICODELITTLE
ISO-10646-UCS-4 UCS-4 CSUCS4
UCS-4BE
UCS-4LE
UTF-16
UTF-16BE
@hakre
hakre / simplexml-import.php
Created Feb 12, 2013
In SimpleXML, how can I add an existing SimpleXMLElement as a child element?
View simplexml-import.php
<?php
/**
* In SimpleXML, how can I add an existing SimpleXMLElement as a child element?
*
* @link http://stackoverflow.com/q/767327/367456
* @link http://eval.in/9568
* @link http://3v4l.org/1sI05
*/
/**
@hakre
hakre / magnet-links-bittorrent.php
Created Mar 1, 2012
Magnet links library for PHP
View magnet-links-bittorrent.php
@hakre
hakre / iteration-and-recursive-iteration.php
Created Sep 2, 2012
Iteration and Recursive Iteration Examples Code
View iteration-and-recursive-iteration.php
<?php
/*
* Iteration and Recursive Iteration Examples Code
*
* @link http://stackoverflow.com/questions/12077177/how-does-recursiveiteratoriterator-works-in-php
* @author hakre <http://hakre.wordpress.com>
*/
### To have these examples to work, a directory with subdirectories is needed,
### I named mine "tree":
You can’t perform that action at this time.