Skip to content

Instantly share code, notes, and snippets.

@jhafner
jhafner / gist:2630387
Created May 7, 2012 21:01
Setting Files to 755 and Directories to 644 - Bash Script
for i in $(find /home/*/public_html -maxdepth 0); do u=$(echo $i | awk -F '/' '{print $3}') && chown -R $u:$u $i; done
for i in $(grep DocumentRoot /usr/local/apache/conf/httpd.conf | awk '{print $2}' | grep -v /usr/local/apache/htdocs); do chgrp nobody $i; done
find /home/*/public_html -type d -exec chmod 755 '{}' ';'
find /home/*/public_html -type f -exec chmod 644 '{}' ';'
find /home/*/public_html -iwholename '*.cgi' -exec chmod 755 '{}' ';'
find /home/*/public_html -iwholename '*.pl' -exec chmod 755 '{}' ';'
@jhafner
jhafner / logout-return-to-index.php
Created April 30, 2012 23:24
Link to logout user and return them to the Joomla home page.
<a href="index.php?option=com_user&task=logout&return=aW5kZXgucGhw" title="Sign Out">Sign Out</a>
@jhafner
jhafner / gist:2563524
Created April 30, 2012 23:10
Limit number of words via PHP
function snippet($text,$length=100,$tail="...") {
$text = strip_tags($text);
$text = trim($text);
$txtl = strlen($text);
if($txtl > $length) {
for($i=1;$text[$length-$i]!=" ";$i++) {
if($i == $length) {
return substr($text,0,$length) . $tail;
}
}