Skip to content

Instantly share code, notes, and snippets.

Bronius Motekaitis bronius

Block or report user

Report or block bronius

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
bronius / detect-if-drupal-entity-delete-form.php
Last active Dec 12, 2019
Drupal 8 / PHP 7 - Thought I could devise a super-generic form of determining if this $form_state form is an entity delete form.
View detect-if-drupal-entity-delete-form.php
$is_delete_form = FALSE;
$classes = class_uses($form_state->getFormObject());
foreach ($classes as $class) {
if ($class === 'Drupal\Core\Entity\EntityDeleteFormTrait') {
$is_delete_form = TRUE;
if ($is_delete_form) {
bronius / gist:92393784768bc531eca95fb55f68d3d2
Last active Jun 25, 2018
Super fast replacement for field_encrypt_views_query_alter in contrib module
View gist:92393784768bc531eca95fb55f68d3d2
// The original project query_alter takes each encrypted field with a value sought out of the query
// Executes a query of all other fields (or none if none)
// Creates a MySQL temporary table and populates with decrypted fields' values
// Adds that temp table as a join on the original View
// And then executes the view, letting MySQL query against that temporary table of decrypted values.
// This approach expects a parallel field, field_name_md5, to contain an md5 hash of the original,
// decrypted value (CRUD updated with entity/node hooks or as calculated field). At query execution,
bronius /
Created Apr 18, 2017 — forked from nvahalik/
Drupal patch maker
import json
import re
import urllib2
import subprocess
class Issue:
def __init__(self, number):
self.number = number
bronius / Rewrite rules for Windows DDay with Click Once installer update over Amazon AWS S3 static web hosting
Created Jan 18, 2017
Running into issues with a .Net project's ability to pull its DDay deployed Click Once installer update files hosted on Amazon S3 static website due to mysterious 404. The original manifest was pulled, and the app prompts to download update, but the update failed with 404. Turns out the subsequent requests made with superfluous forward slash ("/…
View Rewrite rules for Windows DDay with Click Once installer update over Amazon AWS S3 static web hosting
bronius / search.php
Last active Jan 27, 2016
Translated from The decoded output that gets run in an eval() in this nasty spammer script on my hijacked server. It looks like it gets called by remote spambots, but not yet sure what the request payload is to make it tick.
View search.php
// Note this is the result of a var_dump, so you should see two lines like:
// string(109877) "
@ini_set('error_log', NULL);
@ini_set('log_errors', 0);
@ini_set('max_execution_time', 0);
bronius / search.php
Last active Jan 27, 2016
Translation at Another nasty script. It is an obfuscated bunch of garbled gibberish which translates itself and then, in an eval(), acts as a pretty sophisticated, smtp-authenticated spam emailer. Here's the original source as found in a file on a VPS I manage (same cPanel account as before..…
View search.php
// Look at the bottom of this script. What was an eval() I've put into a var_dump() so you can see the script this contains
// Copy/paste this in its entirety (minus the opening ?php tag) at, and you
// will see the resulting code without it executing anything malicious.
function ntjmfak($ixdtwpth, $anmcarey){$qq = ''; for($i=0; $i < strlen($ixdtwpth); $i++){$qq .= isset($anmcarey[$ixdtwpth[$i]]) ? $anmcarey[$ixdtwpth[$i]] : $ixdtwpth[$i];}
$rzqwohzj="base64_decode";return $rzqwohzj($qq);}
$efl = 'YGyrI01f7pYts80KdV1Kp83W7Kd6bUz0nULqTLqPIkzqpvJySjQHAG1Hp80KdV1KdKd6bRPqTLqPIkzqpvJySjQH'.
bronius / post.php
Last active Nov 11, 2015
A nefarious script found on a WordPress site. It's obfuscated at least a couple layers deep. In your access_log you should see POST /post.php, and your themes' header.php files will get a little javascript injected which appears to just make a call out to some remote websites. How is this good for anyone? Please give it a whirl at http://sandbox…
View post.php
// Found this in a post.php in a hacked WordPress site. Just wanting to see how this evaluates.
bronius / megaselect.module
Created Feb 10, 2014
Attempt to nest Drupal 7 FAPI element type tableselect (Note: It doesn't work!)
View megaselect.module
* @file megaselect.module
* TODO: Enter file description here.
* Implements hook_menu().
bronius / gist:6371145
Last active Dec 21, 2015 — forked from neclimdul/gist:6370758
One way around Drupal 7 Ubercart 7.x-3.5 cache anonymous cart (in IE?). I found that 'cart' was always getting added to Drupal's cache_page table. Doesn't it make sense that it *not*? In fact, it broke checkout for our anonymous users. Try it out, let me know if it works for you. Thanks @neclimdul! Note: the fix is just the 'cart' -> drupal_page…
View gist:6371145
* Implements hook_init().
function uc_cart_init() {
global $conf;
$conf['i18n_variables'][] = 'uc_cart_breadcrumb_text';
$conf['i18n_variables'][] = 'uc_cart_help_text';
$conf['i18n_variables'][] = 'uc_continue_shopping_text';
// Don't cache any cart of checkout pages.
You can’t perform that action at this time.