Skip to content

Instantly share code, notes, and snippets.

View typhonius's full-sized avatar

Adam Malone typhonius

View GitHub Profile
@typhonius
typhonius / node_export_i18n.module
Created July 4, 2013 15:34
node export i18n for PHP < 5.3
<?php
/**
* @file Node Export i18n module
*/
// Ensure this node type has multilingual support
/**
<?php
function custom_import_import_files_batch_files(&$context) {
db_set_active('import');
// Build the total import count.
// need to query D5 db
// mysql> select nr.body from node_revisions nr join node n on n.nid = nr.nid where n.type = 'homepage' and nr.body like '%flipperpage%';
if (empty($context['sandbox'])) {
@typhonius
typhonius / fingerprint_conversion.py
Last active December 17, 2015 15:09
Quick snippet to convert public key signatures from an authorized_keys file into their ssh fingerprint
# Quick snippet to convert public key signatures from an authorized_keys file into their ssh fingerprint
# Usage: python fingerprint_conversion.py authorized_keys
import base64,hashlib,sys
line = sys.argv[1]
f = open(line, 'r')
for key in f:
key = str(key.strip().split()[1])
@typhonius
typhonius / isup.rb
Created May 16, 2013 13:08
My first ruby script. Is a webserver where you pass the URL like localhost:8080/http://google.com and it'll tell you if google is up and what response given etc. It's terrible but it's a start.
#!/usr/bin/ruby
#require "net/http"
require "net/https"
require "uri"
require "socket"
require "yaml"
$redirects = Array.new
@typhonius
typhonius / ttl.sh
Last active December 17, 2015 04:29
gets the actual TTL rather than the TTL a user's machine has.
#!/bin/bash
if [ -z "${1}" ] ;
then
echo 'Please enter the address the TTL should be found for'
exit 1
fi
NS=`host -t NS $1 | awk {'print $4'}`
arr=$(echo $NS | tr " " "\n")
for x in $arr
@typhonius
typhonius / match_users.php
Created April 19, 2013 01:51
when retrieving a list of users from elsewhere with emails as a shared field this will detect if they exist in the db already
<?php
$emails = array(
// fill in emails here or use array from somewhere else
);
foreach ($emails as $mail) {
$query = "SELECT 1 FROM {users} WHERE mail = :mail";
$exists = db_query_range($query, 0, 1, array(':mail' => $mail))->fetchField();
@typhonius
typhonius / odch_gag_patch.patch
Created April 18, 2013 04:39
patch for odch to allow users to be muted
diff --git a/src/commands.c b/src/commands.c
index 411f944..7af604f 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -480,6 +480,23 @@ void chat(char *buf, struct user_t *user)
logprintf(3, "OP Admin %s at %s added %s to nickban list\n", user->nick, user->hostname, tempstr);
}
}
+
+ else if(((user->permissions & BAN_ALLOW) != 0) && (strncasecmp(temp, "!gag ", 5) == 0))
@typhonius
typhonius / greentext.module
Last active February 11, 2019 08:23
A filter format for applying greentext correctly to Drupal text. The snippet will provide any filter format with the ability to change any line starting with '>' into a greentext line. >Implying anyone will use it
<?php
function greentext_filter_info() {
$filters['greentext'] = array(
'title' => t('Implying greentext'),
'description' => t('Allows you to alter any lines input starting with \'>\' to appear as greentext.'),
'process callback' => '_greentext_greentext',
'tips callback' => '_greentext_greentext_tips',
);
return $filters;
@typhonius
typhonius / anonymous_comment_delete.module
Created February 26, 2013 07:44
What is essentially a prebuilt module that allows the user to create tokens (perhaps to be sent to an email address) which contain links they can click to delete spammy comments without logging in. Necessity for this was born out of receiving "new comment" notifications on my phone and then being annoyed about having to log in on a device that I…
<?php
/**
* Implements hook_menu()
*/
function mymodule_menu() {
$items['comment/%/fastdelete/%'] = array(
'title' => 'Fast Comment Deletion',
'page callback' => 'mymodule_comment_fastdelete',
'page arguments' => array(1, 3),
@typhonius
typhonius / db_insert.pl
Created February 24, 2013 08:52
Wrapper function for inserting into an sqlite database using perl and prepared statements. The %values array is an associative array of column->value db_insert($table, %values);
sub db_connect() {
our $dbh = DBI->connect("dbi:SQLite:" . $path . '/' . $db,"","") or die "Unable to connect to database: $DBI::errstr";
return $dbh;
}
sub db_prepare($) {
my $dbh = db_connect();
my $query = shift;
my $handle = $dbh->prepare($query);
return $handle;