Skip to content

Instantly share code, notes, and snippets.

@mckelvey
mckelvey / private.application.custom_fields.php
Created April 2, 2014 00:20
This Alex-made™ code demonstrates how to use five handlers to get and set a custom field on an existing LiveWhale datatype.
<?php
/*
This is a sample application designed to demonstrate how to add an additional custom field to a backend editor.
The example provided adds a "Dress Code" field to the existing event editor in LiveWhale. To add a custom field to the news editor, for example, follow the same example but change all references from events to news below.
*/
@mckelvey
mckelvey / profile.php
Last active August 29, 2015 13:57
This simple module and xphp snippet produce a link to edit the profile being viewed on any profiles details page regardless of login status.
...
<xphp content="true">
<if var="profiles_edit_link"/>
<content>
<div class="profiles_edit_link">
<xphp var="profiles_edit_link" inner="true"/>
</div>
</content>
</xphp>
// Generated by CoffeeScript 1.4.0
(function() {
var PreProcessor;
PreProcessor = (function() {
/*
from: https://github.com/sockjs/sockjs-node/commit/e0e7113f0f8bd8e5fea25e1eb2a8b1fe1413da2c
from: https://github.com/sockjs/sockjs-client/blob/a571c94e051de7af489b4fc541194956e1d171fe/lib/utils.js
*/
@mckelvey
mckelvey / private.application.community_public_group.php
Created March 3, 2014 22:24
How to use the Public group for LDAP/SSO community submissions.
<?php
$_LW->REGISTERED_APPS['community_public_group'] = array( // configure this application module
'title' => 'Community Public Group',
'handlers' => array(
'onLoad',
'onLoginSuccess',
'onLoginFailure',
'onSubnavs',
'onManagerQuery',
@mckelvey
mckelvey / public.application.short_summary.php
Last active August 29, 2015 13:56
This tiny LiveWhale application module limits the length of the summary to 90 words.
<?php
$_LW->REGISTERED_APPS['short_summary']=array(
'title'=>'Short Summary',
'handlers'=>array('onWidgetFormat'),
);
class LiveWhaleApplicationShortSummary {
public function onWidgetFormat($type, $handler, $variables) { // alter widget variables
@mckelvey
mckelvey / public.application.time_formatter.php
Last active August 29, 2015 13:56
This tiny LiveWhale application module alters the time and meridian formatting from the PHP-based LiveWhale defaults.
<?php
$_LW->REGISTERED_APPS['time_formatter']=array(
'title'=>'Time Formatter',
'handlers'=>array('onWidgetFormat'),
);
class LiveWhaleApplicationTimeFormatter {
public function onWidgetFormat($type, $handler, $variables) { // alter widget variables
@mckelvey
mckelvey / apache-livewhale.conf
Last active June 7, 2019 09:19
This is a fail2ban filter to protect against malicious use of an injection/vulnerability scanner (that might also be slamming your server with useless requests).
# Fail2Ban configuration file
#
# Intended to assist in protecting LiveWhale from malicious use
# of injection and vulnerabilty scanners such as:
#
# Acunetix Web Vulnerabilty Scanner
# Unknown Scanner (dubbed KIDC below)
# Unknown Scanner (dubbed RIPE below)
#
# Note: if you use penetration software for testing, add the server ip
@mckelvey
mckelvey / brightness.php
Created January 17, 2014 00:19
Image filtering methods.
<?php
// ref: http://www.phpied.com/image-fun-with-php-part-2/
// ref: http://www.php.net/manual/en/function.imagefilter.php
require('./image.php');
$value = (int) $_GET['value'];
$image = imagecreatefromjpeg($imagefile);
header("Content-type: image/jpeg");
@mckelvey
mckelvey / public.application.private_things_stay_private.php
Created December 16, 2013 22:12
One example code block... do remember to not have whitespace either before the opening <?php or after the closing ?>.
<?php
$_LW->REGISTERED_APPS['private_things_stay_private']=array( // register this application
'title' => 'Private Things Stay Private',
'handlers' => array('onLoad', 'onWidgetLoad'),
);
class LiveWhaleApplicationPrivateThingsStayPrivate {
protected $private_allowed = array(
@mckelvey
mckelvey / private.application.hide_comments.php
Last active December 28, 2015 03:59
Place this file inside a new hide_comments folder in your backend livewhale/clients/modules folder.
<?php
/* Hide Comments
This application hides the Comments checkbox on all editors in
the LiveWhale backend management interface, except for admins. */
$_LW->REGISTERED_APPS['hide_comments']=array( // register this application
'title'=>'Hide Comments', // the module name
'handlers'=>array('onOutput')