Skip to content

Instantly share code, notes, and snippets.

@ryanbattles
ryanbattles / database.php
Created September 14, 2011 13:59
A database.php file for ExpressionEngine 2.x that allows for multiple server environments.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ($_SERVER['SERVER_ADDR'] == '') {
$active_group = 'staging';
} elseif ($_SERVER['SERVER_ADDR'] == '208.73.210.85') { /* using qa-zone.com */
$active_group = 'production';
} else {
$active_group = 'development';
}
$active_record = TRUE;
@ryanbattles
ryanbattles / config.php
Created September 14, 2011 14:13
A config.php file for ExpressionEngine 2.x that allows for multiple server environments.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| ExpressionEngine Config Items
|--------------------------------------------------------------------------
|
| The following items are for use with ExpressionEngine. The rest of
| the config items are for use with CodeIgniter, some of which are not
| observed by ExpressionEngine, e.g. 'permitted_uri_chars'
@ryanbattles
ryanbattles / htaccess
Created December 16, 2011 21:06
A Standard .htaccess for use on most ExpressionEngine sites
FileETag None
<IfModule mod_rewrite.c>
RewriteEngine On
# Force www
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]
# Uncomment to Remove www, but comment the above 2 lines out. :)
# Otherwise the world will end
@ryanbattles
ryanbattles / Download site as .zip
Created December 17, 2011 19:36
Download site as .zip
<!--http://stackoverflow.com/questions/1334613/how-to-recursively-zip-a-directory-in-php-->
<?php
function Zip($source, $destination)
{
if (!extension_loaded('zip') || !file_exists($source)) {
return false;
}
$zip = new ZipArchive();
@ryanbattles
ryanbattles / RSS Feed
Created January 24, 2012 01:39
RSS Feed
{!--
1. THE CHANNEL AND FIELD NAMES NEED TO BE CHECKED FOR ACCURACY
2. THE DYNAMIC LINK PATHS NEED TO BE CHECKED FOR ACCURACY
--}
{exp:rss:feed channel="news"}
<?xml version="1.0" encoding="{encoding}"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
<h4><strong><a title="{forum_name}" href="{path:viewforum}">{forum_name}</a></strong></h4>
{if logged_in} <a class="fancybox-forum" href="/resources/forum-subscriptions/&lt;?php $tokens = explode('/', '{path:viewforum}'); echo $tokens[sizeof($tokens)-2]; ?&gt;"><small>Manage Subscription</small></a> {/if} {if forum_description}
<p class="fm-description">{forum_description}</p>
{/if}
@ryanbattles
ryanbattles / gist:5662760
Last active December 17, 2015 19:49
Forum-subscriptions template fancybox code
<script type="text/javascript">// <![CDATA[
if (/forum-subscriptions/.test(self.location.href)){window.location = "/forums"}
// ]]></script>
{exp:forum_subscribe:forum_single forum_id="{segment_3}"}
<h2>{forum_name}</h2>
{if subscribed}
<strong>SUBSCRIBED</strong> - <a href="{forum_subscribe_url}">Click to Unsubscribe</a>
{if:else}
<strong>NOT SUBSCRIBED</strong> - <a href="{forum_subscribe_url}">Click to Subscribe</a>
{/if}
@ryanbattles
ryanbattles / gist:5705281
Last active December 18, 2015 01:39
Statamic .htaccess
RewriteEngine On
# secure site files
RewriteRule ^(_app) - [F,L]
RewriteRule ^(_config) - [F,L]
RewriteRule ^(_content) - [F,L]
RewriteRule ^(.*).yml$ - [F,L]
RewriteRule ^(.*).yaml$ - [F,L]
RewriteRule ^(.*).html$ - [F,L]
RewriteRule ^(.*/)?\.git+ - [F,L]
@ryanbattles
ryanbattles / gist:5842394
Created June 22, 2013 20:04
Changing the screenshot format on OS X
defaults write com.apple.screencapture type image_format
killall SystemUIServer
@ryanbattles
ryanbattles / gist:5842427
Created June 22, 2013 20:18
Changing the location of the OS X Screenshots
defaults write com.apple.screencapture location ~/Screenshots
killall SystemUIServer