Skip to content

Instantly share code, notes, and snippets.

@jamesshannon
jamesshannon / benchmark.php
Last active December 16, 2015 21:29
Site benchmarking tool. The goal is to provide times that are relevant to hosting a web app (ie, unlike most other benchmarks, it includes MySQL access). Drop into the root of your concrete5 directory and it'll automatically detect your database connection info. If not, update the strings at the top.
<?php
$scriptStart = microtime(true);
$iterations = 5000;
$longString = str_repeat('0123456789', 102 * 5); // 10 * 102 * 5 = 5k
if (is_file(dirname(__FILE__) . '/config/site.php')) {
include(dirname(__FILE__) . '/config/site.php');
if (defined('DB_SERVER')) {
@jamesshannon
jamesshannon / site_events.php
Created December 21, 2012 22:29
Concrete Wall for #concrete5 -- Integration of the core discussion forums addon. This adds wall postings when a user creates a new discussion or replies to an existing one. Add this code anywhere that gets run on every request -- /config/site_events.php is a good place.
<?php
// register event so that our SiteDiscussionWallPoster::hookPageAdd() gets called when pages get added
Events::extend('on_page_add', 'SiteDiscussionWallPoster', 'hookPageAdd', false);
class SiteDiscussionWallPoster {
/**
* gets called when on_page_add event is fired. adds a wall posting if page of type "discussion_post" was added
@jamesshannon
jamesshannon / model.php
Created October 26, 2012 19:47
#concrete5 Model and DatabaseItemList class extensions to make for easier active record based CRUD
<?php
namespace LSL\Libraries;
defined('C5_EXECUTE') or die('Access Denied.');
/**
* @package lerteco_shared_libraries
* @subpackage helpers
* @copyright James Shannon
*/
@jamesshannon
jamesshannon / site_post.php
Created June 26, 2012 05:34
Concrete5 Password Reset Script
<?php
/**
* This script will reset your admin password to "password"
* It should be named site_post.php and placed at [your web root]/config/site_post.php
* After it's been copied, load your website, and your admin password will be reset
* **** REMEMBER TO DELETE THIS FILE AFTERWARDS, OR YOUR PASSWORD WILL BE CONSTANTLY RESET *****
* Enjoy. james@jamesshannon.com
*/
$ui = UserInfo::getByID(USER_SUPER_ID);