Apache Note

Read More

Apache Notes - preventing external hot links

/**
.htaccess code to prevent external sites from directly linking to to files in an Apache directory. This prevent external sites from "hot-linking"
**/

SetEnvIf Referer "^http://subdomain\.domain\.edu" local_referral
SetEnvIf Referer "^https://subdomain\.domain\.edu" local_referral

Order Deny,Allow
Deny from all
Allow from env=local_referral
Allow from env=auth_referral


// Double check for all .htaccess files in a directory
find . -name ".htaccess" -type f

// Now delete theme
find . -name ".htaccess" -type f -delete

Hypertufa Pagoda Test Fit, Hypertufa Mix Consistency, Pagoda Base Layout, Sample Pagoda - seen in passing

Read More

Hypertufa Pagoda Project - Molding Cement

Hypertufa Cement Mix - Zen Garden Pagoda Project

3.5 part portland cement
2 part kids play sand
1 part vermiculite
4 part peat moss
1-2 cup acrylic binding agent

These are the rough proportions for our Hypertufa mix, your mileage may very. Just be sure to use the same measuring container.

Obviously we added water too, though we didn't measure the proportions. We mixed in water until the consistency would form a solid ball.


Hypertufa Material List

Pagoda Base Layout

Hypertufa Mix, Hypertufa Garden Pots @ 10 years

Read More

Add users from a text file to a Drupal User Role

#!/bin/bash

# Add Users To a Specific Role
# Setup These Variables

# Set Site Path
sitepath="/opt/var/www/htdocs/"

# Set Site Name
site="example.com"

# add user to ContentAuthor
#echo "Add users to ContentAuthor role"
cat example-users.txt | while read line
do
drush -d -r $sitepath -u 1 -l $site user-add-role "ContentAuthor" $line

#echo $line
done
 

#####################
#
# Drupal 7 Example - used for printing fields in template files
# Check if a field exists, then do something

$public_field_location = field_get_items('node', $node, 'field_public_display_location');

if ($public_field_location) {
// do something
echo "<div id=\"node_section\"><h2> Where: </h2><div id=\"node_section_text\"> ";
print render($content['field_public_display_location']);
echo "</div></div>";
} else {
echo " No public location Set" ;
}

Hypertufa Batch Mix, Poor Man's Rebar

Read More

Shell Script From PPH

# Simple PHP / Bash Shell Sample

# FOOBAR.php
# php code
echo "Running Pull.sh Shell Script";
$output = shell_exec('/html/scripts/pull.sh');
echo "<pre>$output</pre>";

# FOOBAR.sh
#!/bin/bash
touch temp/FOOBAR.txt
echo "FOO-BAR-Script-Output" > temp/FOOBAR.txt
cat temp/FOOBAR.txt

###############

# More Complex PHP / Bash
# PHP code to run script with parameter variables from page node

drupal_set_message(t('We are running a PHP rule to create a QR code for this node'));
$mynode =(token_replace('[node:nid]', array('node' => $node)));
$mytitle = $node->title;
$backgroundcolor = $node->field_background_color[0]['value'];
$foregroundcolor =$node->field_foreground_color[0]['value'];
$qrsize =$node->field_qr_size[0]['value'];
shell_exec('/opt/www/{SITENAME}/html/{SCRIPT_PATH}/qr_build_script.sh'." ".escapeshellarg($mynode)." ".escapeshellarg($mytitle)." ".escapeshellarg($backgroundcolor) ." ".escapeshellarg($foregroundcolor)." ".escapeshellarg($qrsize));

Base Mold Pour 3 of 4

Read More

Random Drupal 7 Cheat Sheet Notes - Drupal show roles and Profile Data

/* List a user's roles */

foreach($user->roles as $role) {
print "Role: ".$role." ";
}

/* Check if user is in role *>

if (in_array('Web Manager', $user->roles)) {$display ="on";}


global $user;
$uid = user_load($user->uid);
$profile = profile2_load_by_user($uid, 'main');
$full_name = " ";
$full_name = $profile->field_profile_full_name;
if (isset($full_name['und'][0]['value'])) {
echo $profile->field_profile_full_name['und'][0]['value'];
} else {
print '<div class=messages--error>WARNING: We do not appear to have your Full Name on file. Please update your contact details to include this information. Thank You.</div>' ;
}


/* Logging out of Cosign / Drupal - EAT COOKIES */

global $user;

 watchdog('user', 'Session closed for %name.', array('%name' => $user->name));

  // Eat the cookies
  foreach($_COOKIE AS $key => $value)
  {
    setcookie($key,$value,1);
    unset($_COOKIE[$key]);
  }

  // Destroy the current session:
  session_destroy();
  $_SESSION = array();

  // Only variables can be passed by reference workaround.
  $null = NULL;
  user_module_invoke('logout', $null, $user);

  // Load the anonymous user
  $user = drupal_anonymous_user();

header('Cache-Control: no-cache');
header('Expires: -1');
$query_string = $_SERVER['QUERY_STRING'];
$service_name = $_SERVER['COSIGN_SERVICE'];
$central = "https:// COSIGN SEVER /logout/logout.cgi";

setcookie($service_name, "null", time()-3600, '/', "", 1 );
setcookie("logoutcookie",logout, time()+110);
setcookie("browseropen","open");
header( "Location: $central?$query_string" );

 

Pages

Subscribe to Front page feed