Skip to content

Instantly share code, notes, and snippets.

View szbl's full-sized avatar

Sizeable, Inc. szbl

View GitHub Profile
<?php
function rkv_login_stringcheck()
{
global $pagenow;
if ( $pagenow == 'wp-login.php' )
{
// set the location a failed attempt goes to
$redirect = 'http://www.google.com/';
// missing query string all together
70c70
< $rows = $wpdb->get_results( $wpdb->prepare( "SELECT {$wpdb->prefix}redirection_modules.name AS module_name,{$wpdb->prefix}redirection_groups.name AS group_name,{$wpdb->prefix}redirection_groups.id FROM {$wpdb->prefix}redirection_groups INNER JOIN {$wpdb->prefix}redirection_modules ON {$wpdb->prefix}redirection_modules.id={$wpdb->prefix}redirection_groups.module_id ORDER BY {$wpdb->prefix}redirection_modules.name,{$wpdb->prefix}redirection_groups.position" ) );
---
> $rows = $wpdb->get_results( "SELECT {$wpdb->prefix}redirection_modules.name AS module_name,{$wpdb->prefix}redirection_groups.name AS group_name,{$wpdb->prefix}redirection_groups.id FROM {$wpdb->prefix}redirection_groups INNER JOIN {$wpdb->prefix}redirection_modules ON {$wpdb->prefix}redirection_modules.id={$wpdb->prefix}redirection_groups.module_id ORDER BY {$wpdb->prefix}redirection_modules.name,{$wpdb->prefix}redirection_groups.position" );
<?php
// add tag support to pages
register_taxonomy_for_object_type( 'post_tag', 'page' );
// add category support to pages
register_taxonomy_for_object_type( 'category', 'page' );
@szbl
szbl / force-ssl.php
Last active December 10, 2015 09:29
<?php
if ( is_user_logged_in() && !is_ssl() )
{
$url = get_permalink( get_the_ID() );
$url = str_replace( 'http://', 'https://', $url );
wp_redirect( $url . '?' . http_build_query( $_GET ), 303 );
die;
}
<!doctype html>
<html>
<head>
<title>JS Searcher</title>
<style type="text/css">
body { font: 14px HelveticaNeue,Helvetica,Arial,Sans-serif; }
textarea.code,pre { width:100%;height:100px;margin:1em;padding:1em;border:1px solid #ccc;background:#f7f7f7;font-family:Monaco,Courier,monospace; }
#summary { margin: 1em; border-collapse: collapse; border: 1px solid #d7d7d7; }
#summary td { border: 1px solid #d7d7d7; padding: .5em; }
</style>
<?php
$string = file_get_contents( 'some-file.js' );
$pattern = '#/\*\w.+?\*/try{document.+?/\*\w.+?\*/#im';
$clean = preg_replace( $pattern, '', $string );
file_put_contents( 'some-file.js', $clean );
<!doctype html>
<html>
<head>
<title>PCRE TEST</title>
<style type="text/css">
body { font: 14px HelveticaNeue,Helvetica,Arial,Sans-serif; }
table { width: 80%; }
textarea.code,pre { width:80%;height:100px;margin:1em;padding:1em;border:1px solid #ccc;background:#f7f7f7;font-family:Monaco,Courier,monospace; overflow: scroll; }
#summary { margin: 1em; border-collapse: collapse; border: 1px solid #d7d7d7; }
#summary td { border: 1px solid #d7d7d7; padding: .5em; }
<?php
// the post
$post = 'This is only a test. Please disregard this message. http://www.warnkenlaw.com';
$actions = array(
array(
'name' => 'Read Our Blog',
'link' => 'http://www.facebook.com'
)
);
@szbl
szbl / redirection-models-group.php
Created January 18, 2013 15:14
Temporary hack-fix for Redirection plugin's improper use of $wpdb->prepare();
<?php
/*
original version's Line 70
*/
$rows = $wpdb->get_results( $wpdb->prepare( "SELECT {$wpdb->prefix}redirection_modules.name AS module_name,{$wpdb->prefix}redirection_groups.name AS group_name,{$wpdb->prefix}redirection_groups.id FROM {$wpdb->prefix}redirection_groups INNER JOIN {$wpdb->prefix}redirection_modules ON {$wpdb->prefix}redirection_modules.id={$wpdb->prefix}redirection_groups.module_id ORDER BY {$wpdb->prefix}redirection_modules.name,{$wpdb->prefix}redirection_groups.position" ) );
/*
Modified version - Line 70
*/
$rows = $wpdb->get_results( "SELECT {$wpdb->prefix}redirection_modules.name AS module_name,{$wpdb->prefix}redirection_groups.name AS group_name,{$wpdb->prefix}redirection_groups.id FROM {$wpdb->prefix}redirection_groups INNER JOIN {$wpdb->prefix}redirection_modules ON {$wpdb->prefix}redirection_modules.id={$wpdb->prefix}redirection_groups.module_id ORDER BY {$wpdb->prefix}redirection_modules.name,{$wpdb->prefix}redirection_groups.position" );
<?php
// user, pass, db name, host
$db = new wpdb( 'root', 'password', 'dbname', 'localhost' );
// insert some data
if ( $db->insert( 'company_contacts', array(
'first_name' => 'Andy',
'last_name' => 'Stratton',
'email_address' => '[email protected]'
));