Skip to content

Instantly share code, notes, and snippets.

<?php
class HttpException extends Exception
{
/**
* List of HTTP status codes
*
* From http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
*
* @var array
@live627
live627 / instr.php
Last active July 9, 2023 08:51 — forked from joshuaadickerson/instr.php
An insitu (no copy) string comparison comparable to substr_compare()
<?php
function instr(string $string, string $substr, int $offset = 0, int $length = null): bool
{
for ($pos = $offset, $substr_pos = 0; $pos !== $length; $pos++, $substr_pos++)
{
if (isset($substr[$substr_pos]))
{
if (isset($string[$pos]))
{
INSERT IGNORE INTO `smf_log_notify`(`id_member`, `id_topic`, `id_board`, `sent`) 
SELECT id_member,0,id_board,0
FROM  smf_boards
CROSS JOIN smf_members
WHERE id_member BETWEEN 100 AND 1000

INSERT IGNORE INTO `smf_log_notify`(`id_member`, `id_topic`, `id_board`, `sent`) 
SELECT id_member,id_last_msg,0,0
FROM  smf_boards
<?php
define('SMF', 1);
include('Sources/Subs-MembersOnline.php');
// Users from log_online
$users = array(array('real_name' => 'User 1',
'id_member' => 0,
'member_name' => 'user1',
@live627
live627 / benchmark.php
Created February 22, 2020 04:09
Benchmarking several methods of script timing taken from https://www.php.net/manual/en/function.microtime.php#66187
<?php
if (isset($_SERVER['SERVER_PROTOCOL'])) { echo "<html><head><title>microtime conversion timing comparison</title></head><body><pre>\n"; }
$iterations=1000000;
$sortResults=true;
$usedTime=array();
$output=array();
@live627
live627 / exceptions-tree.php
Last active January 26, 2020 23:16 — forked from mlocati/exceptions-tree.php
Throwable and Exceptions tree
<?php
if (!function_exists('interface_exists')) {
die('PHP version too old');
}
$throwables = listThrowableClasses();
$throwablesPerParent = splitInParents($throwables);
printTree($throwablesPerParent);
if (count($throwablesPerParent) !== 0) {
die('ERROR!!!');
@live627
live627 / Form.php
Last active September 7, 2016 10:50
Form class
<?php
/**
* @package LiveGallery
* @version 2.0
* @author John Rayes <live627@gmail.com>
* @copyright Copyright (c) 2011-2016, John Rayes
* @license proprietary
*/
@live627
live627 / jquery.selectbox.js
Created January 8, 2012 03:57 — forked from lennart/jquery.selectbox.js
jQuery SelectBox plugin, with _slight_ modifications
/**
* jQuery Selectbox plugin 0.1
*
* Copyright 2011, Dimitar Ivanov (http://www.bulgaria-web-developers.com/projects/javascript/selectbox/)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/
(function ($, undefined) {
var PROP_NAME = 'selectbox',
FALSE = false,
TRUE = true;