Skip to content

Instantly share code, notes, and snippets.

@rxu
rxu / enviroment_checker.php
Created September 4, 2011 13:16
Enviroment checker variant
<?php
/**
*
* @package phpBB
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
@rxu
rxu / extract_globals.php
Created March 19, 2012 14:16
Extract into globals
// Param $event_data array Compacted array of variables
function phpbb_add_event($event_name = '', $event_data = array())
{
global $phpbb_dispatcher;
// Return if no event data is given
if (empty($event_name) || empty($event_data))
{
return;
}
@rxu
rxu / gist:0660eef7a2f9e7992db6
Created November 9, 2014 16:24
IDN URL validation example
// Start with characters that are NFKC Case folded (as in IDNA2003)
// \P{Changes_When_NFKC_Casefolded}
// Remove Control Characters and Whitespace (as in IDNA2003)
$no_cc = '[^\p{C}\p{Z}]';
// Remove Symbols, Punctuation, non-decimal Numbers, and Enclosing Marks
$no_symbol = '[^\p{S}\p{P}\p{Nl}\p{No}\p{Me}]';
@rxu
rxu / gist:0e4ceefdc84d7e85430f
Last active August 29, 2015 14:09
Get PHP wrappers
<?php
$w = stream_get_wrappers();
echo 'openssl: ', extension_loaded ('openssl') ? 'yes':'no', "\n";
echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
echo 'wrappers: ', var_dump($w);
@rxu
rxu / gist:d586d7e01199fd6c0ff2
Last active August 29, 2015 14:09
@event core.message_parser_check_message
/**
* This event can be used for additional message checks/cleanup before parsing
*
* @event core.message_parser_check_message
* @var bool allow_bbcode Do we allow BBCodes
* @var bool allow_magic_url Do we allow magic urls
* @var bool allow_smilies Do we allow smilies
* @var bool allow_img_bbcode Do we allow image BBCode
* @var bool allow_flash_bbcode Do we allow flash BBCode
* @var bool allow_quote_bbcode Do we allow quote BBCode
@rxu
rxu / gist:8d80afb54839d2baf69e
Created May 30, 2015 06:00
The way to set array values in Twig template
{% set definition={FOO : true} %}
{% if definition.FOO %}
Hello world
{% endif %}
{
"name": "ayphix/clans",
"type": "phpbb-extension",
"description": "This shows your clan",
"version": "1.0.0",
"license": "GPL-2.0",
"authors": [
{
"name": "Jin Muhjo",
"homepage": "http://johnsmith.com",
#0 zend_mm_alloc_small (size=<optimized out>, bin_num=0, heap=0x7fffece00040) at /usr/local/src/php/Zend/zend_alloc.c:1271
#1 zend_mm_alloc_heap (size=<optimized out>, heap=0x7fffece00040) at /usr/local/src/php/Zend/zend_alloc.c:1338
#2 zend_mm_realloc_heap (heap=0x7fffece00040, ptr=0x7fffe7ad9200, size=<optimized out>, copy_size=8) at /usr/local/src/php/Zend/zend_alloc.c:1601
#3 0x000000000081ada4 in pass_two (op_array=0x7fffe913f6a8) at /usr/local/src/php/Zend/zend_opcode.c:588
#4 0x0000000000813fc1 in zend_compile_func_decl (result=result@entry=0x0, ast=ast@entry=0x7fffe641d2e8) at /usr/local/src/php/Zend/zend_compile.c:4838
#5 0x000000000081211a in zend_compile_stmt (ast=0x7fffe641d2e8) at /usr/local/src/php/Zend/zend_compile.c:7017
#6 0x0000000000812967 in zend_compile_stmt_list (ast=ast@entry=0x7fffe641d078) at /usr/local/src/php/Zend/zend_compile.c:4289
#7 0x0000000000811f9e in zend_compile_stmt (ast=ast@entry=0x7fffe641d078) at /usr/local/src/php/Zend/zend_compile.c:6961
#8 0x0000000000812c9d
[Wed Aug 12 07:52:06.961784 2015] [:error] [pid 51552] [client 127.0.0.1:38658] PHP Fatal error: Uncaught Twig_Error_Loader: The "../language//email" directory does not exist. in /var/www/html/phpbb30/phpBB/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:93\nStack trace:\n#0 /var/www/html/phpbb30/phpBB/vendor/twig/twig/lib/Twig/Loader/Filesystem.php(75): Twig_Loader_Filesystem->addPath('../language//em...', '__main__')\n#1 /var/www/html/phpbb30/phpBB/phpbb/template/twig/twig.php(236): Twig_Loader_Filesystem->setPaths(Array)\n#2 /var/www/html/phpbb30/phpBB/includes/functions_messenger.php(662): phpbb\\template\\twig\\twig->set_custom_style(Array, Array)\n#3 /var/www/html/phpbb30/phpBB/includes/functions_messenger.php(255): messenger->set_template_paths(Array, Array)\n#4 /var/www/html/phpbb30/phpBB/phpbb/install/module/install_finish/task/notify_user.php(104): messenger->template('installed', '')\n#5 /var/www/html/phpbb30/phpBB/phpbb/install/module_base.php(169): phpbb\\install\\module\\install_finish\\task\\n
@rxu
rxu / gist:da473e83cbf6477764c5
Created September 12, 2015 17:53
user_get_id_name() example
$username_ary = array();
// Selecting usernames for user_id of 22, 3, 14 (for example)
$user_id_ary = array(22, 3, 14);
user_get_id_name($user_id_ary, $username_ary);
var_dump($username_ary);