Your forum has been Ipsum-ified. Please consider doing a full recount, and remember to re-activate all of your plugins!', 'bbipsum' ), bb_get_uri( 'bb-admin/tools-recount.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ) ) ); } if ( !empty( $_GET['deleted'] ) ) { bb_admin_notice( sprintf( __( 'Your forum has been cleaned of gibberish. Please consider doing a full recount.', 'bbipsum' ), bb_get_uri( 'bb-admin/tools-recount.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ) ) ); } require_once dirname( __FILE__ ) . '/LoremIpsum.class.php'; $lipsum = new LoremIpsumGenerator(); ?>

getContent( 6, 'plain' ), " \t\n\r." ) ); ?>

getContent( 50, 'txt' ) ); ?>

links, bold text, and italic text in the posts.', 'bbipsum' ); ?>


:
:
:
:

get_col( $bbdb->prepare( "SELECT `user_id` FROM `$bbdb->usermeta` WHERE `meta_key` = 'bbipsum' AND `meta_value` = %d ORDER BY RAND( %d ) LIMIT %d", $ipsum_type, bbipsum_rand(), $allowed_accounts ) ) ) { bb_cache_users( $_accounts ); $accounts = array_map( 'intval', $_accounts ); } for ( $i = count( $accounts ); $i < $allowed_accounts; $i++ ) { $accounts[] = -1; } } if ( 1 > $allowed_topics = (int) $_POST['topics'] ) { bb_die( __( 'You must add at least one topic with this plugin.', 'autorank' ) ); } if ( 1 > $allowed_posts = (int) $_POST['posts'] ) { $allowed_posts = 1; } $allow_html = (boolean) (int) $_POST['html']; $forums = bb_get_forums( array( 'callback' => 'bbipsum_forum_filter' ) ); $f = count( $forums ); global $wp_users_object; $_user = bb_get_current_user_info( 'ID' ); $show_progress = false; if ( !empty( $_POST['show_progress'] ) ) { $show_progress = true; wp_enqueue_script( 'jquery' ); bb_install_header( __( 'bbIpsum is working...', 'bbipsum' ), __( 'bbIpsum is working...', 'bbipsum' ) ); wp_print_scripts(); ?>



user_nicename, 50 ); $user_email = md5( $user_login ) . '@example.com'; $user_pass = bb_generate_password(); $user_status = 0; $user = $wp_users_object->new_user( compact( 'user_login', 'user_email', 'user_nicename', 'user_status', 'user_pass' ) ); if ( is_wp_error( $user ) ) { $j--; continue; } bb_update_usermeta( $user['ID'], $bbdb->prefix . 'capabilities', array( 'inactive' => true ) ); bb_update_usermeta( $user['ID'], 'bbipsum', $ipsum_type ); $accounts[$cur_user] = $user['ID']; } $cur_user = $accounts[$cur_user]; bb_set_current_user( $cur_user ); if ( !$topic ) { $topic = bb_new_topic( bbipsum_get_gibberish( $ipsum_type ), $forums[bbipsum_rand( 0, $f )]->forum_id ); bb_update_topicmeta( $topic, 'bbipsum', $ipsum_type ); } $post_data = array( 'post_text' => bbipsum_get_gibberish_html( $ipsum_type, $allow_html ), 'topic_id' => $topic, 'poster_ip' => '127.' . bbipsum_rand( 0, 255 ) . '.' . bbipsum_rand( 0, 255 ) . '.' . bbipsum_rand( 0, 255 ) ); $post = bb_insert_post( $post_data ); bb_update_postmeta( $post, 'bbipsum', $ipsum_type ); if ( $show_progress ) { echo ''; ob_flush(); flush(); } } if ( $show_progress ) { echo ''; ob_flush(); flush(); } } $goback = add_query_arg( 'updated', 'true', remove_query_arg( 'deleted', wp_get_referer() ) ); if ( $show_progress ) { echo '

' . __( 'Go back', 'bbipsum' ) . '

'; } else { bb_safe_redirect( $goback ); } exit; } if ( $_POST['action'] == 'delete' ) { bb_check_admin_referer( 'bbipsum-delete' ); if ( empty( $_POST['delete'] ) ) { bb_safe_redirect( wp_get_referer() ); exit; } global $bbdb; $bbdb->query( "DELETE FROM `$bbdb->users` WHERE `ID` IN ( SELECT `t`.* FROM ( SELECT `user_id` FROM `$bbdb->usermeta` WHERE `meta_key` = 'bbipsum' ) AS `t` )" ); $bbdb->query( "DELETE FROM `$bbdb->usermeta` WHERE `user_id` IN ( SELECT `t`.* FROM ( SELECT `user_id` FROM `$bbdb->usermeta` WHERE `meta_key` = 'bbipsum' ) AS `t` )" ); $bbdb->query( "DELETE FROM `$bbdb->topics` WHERE `topic_id` IN ( SELECT `t`.* FROM ( SELECT `object_id` FROM `$bbdb->meta` WHERE `meta_key` = 'bbipsum' AND `object_type` = 'bb_topic' ) AS `t` )" ); $bbdb->query( "DELETE FROM `$bbdb->meta` WHERE `object_id` IN ( SELECT `t`.* FROM ( SELECT `object_id` FROM `$bbdb->meta` WHERE `meta_key` = 'bbipsum' AND `object_type` = 'bb_topic' ) AS `t` ) AND `object_type` = 'bb_topic'" ); $bbdb->query( "DELETE FROM `$bbdb->posts` WHERE `post_id` IN ( SELECT `t`.* FROM ( SELECT `object_id` FROM `$bbdb->meta` WHERE `meta_key` = 'bbipsum' AND `object_type` = 'bb_post' ) AS `t` )" ); $bbdb->query( "DELETE FROM `$bbdb->meta` WHERE `object_id` IN ( SELECT `t`.* FROM ( SELECT `object_id` FROM `$bbdb->meta` WHERE `meta_key` = 'bbipsum' AND `object_type` = 'bb_post' ) AS `t` ) AND `object_type` = 'bb_post'" ); $goback = add_query_arg( 'deleted', 'true', remove_query_arg( 'updated', wp_get_referer() ) ); bb_safe_redirect( $goback ); exit; } } } add_action( 'bbipsum_pre_head', 'bbipsum_admin_parse' ); function bbipsum_admin_add() { bb_admin_add_submenu( 'bbIpsum', 'use_keys', 'bbipsum', 'tools-recount.php' ); } add_action( 'bb_admin_menu_generator', 'bbipsum_admin_add' ); /** * The same as WP_Pass::rand() except that this one allows a constant seed. */ function bbipsum_rand( $min = 0, $max = 4294967295 ) { global $bbipsum_seed, $bbipsum_rand, $_bbipsum_rand; if ( !isset( $bbipsum_seed ) ) { $bbipsum_seed = bb_generate_password(); } // Reset $bbipsum_rand after 14 uses // 16(md5) + 20(sha1) + 20(sha1) / 4 = 14 random numbers from $bbipsum_rand if ( empty( $bbipsum_rand ) || strlen( $bbipsum_rand ) < 8 ) { $bbipsum_rand = md5( $_bbipsum_rand . $bbipsum_seed, true ); $bbipsum_rand .= sha1( $bbipsum_rand, true ); $bbipsum_rand .= sha1( $bbipsum_rand . $bbipsum_seed, true ); $bbipsum_seed = md5( $bbipsum_seed . $bbipsum_rand ); $_bbipsum_rand = $bbipsum_rand; } // Take the first 4 digits for our value $value = substr( $bbipsum_rand, 0, 4 ); // Strip the first eight, leaving the remainder for the next call to wp_rand(). $bbipsum_rand = substr( $bbipsum_rand, 4 ); $value = current( unpack( 'Nvalue', $value ) ); // Reduce the value to be within the min - max range // 4294967295 = 0xffffffff = max random number if ( $max != 4294967295 ) $value = $min + ( ( $max - $min + 1 ) * ( $value / ( 4294967295 + 1 ) ) ); return absint( $value ); } function bbipsum_get_gibberish_name( $ipsum_type ) { switch ( $ipsum_type ) { case 1: return bbipsum_asdfjkl_generate( bbipsum_rand( 5, 20 ) ); case 2: return bbipsum_aroodles_generate( bbipsum_rand( 10, 30 ) ); case 3: return bbipsum_pikachu_generate( bbipsum_rand( 10, 30 ) ); case 0: default: require_once dirname( __FILE__ ) . '/LoremIpsum.class.php'; $lipsum = new LoremIpsumGenerator(); return ucfirst( str_replace( ',', '', trim( $lipsum->getContent( bbipsum_rand( 2, 4 ), 'plain', false ), " \t\n\r." ) ) ); } } function bbipsum_get_gibberish( $ipsum_type ) { switch ( $ipsum_type ) { case 1: return bbipsum_asdfjkl_generate( bbipsum_rand( 5, 40 ) ); case 2: return bbipsum_aroodles_generate( bbipsum_rand( 10, 60 ) ); case 3: return bbipsum_pikachu_generate( bbipsum_rand( 10, 60 ) ); case 0: default: require_once dirname( __FILE__ ) . '/LoremIpsum.class.php'; $lipsum = new LoremIpsumGenerator(); return ucfirst( str_replace( ',', '', trim( $lipsum->getContent( bbipsum_rand( 2, 8 ), 'plain', false ), " \t\n\r." ) ) ); } } function bbipsum_get_gibberish_html( $ipsum_type, $html = true ) { switch ( $ipsum_type ) { case 1: return bbipsum_filter( bbipsum_asdfjkl_generate( bbipsum_rand( 500, 5000 ) ), $html ); case 2: return bbipsum_filter( bbipsum_aroodles_generate( bbipsum_rand( 500, 5000 ), true ), $html ); case 3: return bbipsum_filter( bbipsum_pikachu_generate( bbipsum_rand( 500, 5000 ), true ), $html ); case 0: default: require_once dirname( __FILE__ ) . '/LoremIpsum.class.php'; $lipsum = new LoremIpsumGenerator(); return bbipsum_filter( $lipsum->getContent( bbipsum_rand( 100, 1000 ), 'txt' ), $html ); } } function bbipsum_split( $str ) { $ret = array(); for ( $i = 0, $l = function_exists( 'mb_strlen' ) ? mb_strlen( $str ) : strlen( $str ); $i < $l; $i++ ) { $ret[] = function_exists( 'mb_substr' ) ? mb_substr( $str, $i, 1) : substr( $str, $i, 1 ); } return $ret; } function bbipsum_asdfjkl_generate( $len ) { $asdfjkl = bbipsum_split( __( 'abcdefghijklmnopqrstuvwxyz0123456789 ', 'bbipsum' ) ); $ret = ''; for ( $i = 0; $i < $len; $i++ ) { $ret .= $asdfjkl[bbipsum_rand( 0, count( $asdfjkl ) - 1 )]; } return $ret; } function bbipsum_pikachu_expand( $word ) { if ( is_array( $word ) ) $word = $word[1]; $ret = ''; $i = bbipsum_rand( 1, 3 ); while ( $i-- ) { $ret .= $word; } return $ret; } function bbipsum_pikachu_generate( $len, $punctuate = false ) { $words = array( 'Pikachu', 'Ch(u)', '(Pika)', '(Pi)', 'Pi(ka)', 'kachu', '(Chu)' ); $w = count( $words ) - 1; $separators = array( ' ', '-' ); if ( $punctuate ) $separators = array_merge( $separators, array( '. ', '? ', '! ' ) ); $s = count( $separators ) - 1; $ret = ''; while ( strlen( $ret ) < $len ) { $word = $words[bbipsum_rand( 0, $w )]; if ( $word == 'kachu' && !$ret ) continue; $ret .= $separators[bbipsum_rand( 0, $s )] . preg_replace_callback( '/\(([^\)]*)\)/', 'bbipsum_pikachu_expand', $word ); } return trim( $ret, implode( '', $separators ) ); } // Algorithm by Sam P. function bbipsum_aroodles_generate( $len, $punctuate = false ) { $consonants = bbipsum_split( _c( 'bcdfghjklmnpstvwxyz|consonants', 'bbipsum' ) ); $c = count( $consonants ) - 1; $vowels = bbipsum_split( _c( 'aeiou|vowels', 'bbipsum' ) ); $v = count( $vowels ) - 1; $separators = array( ' ', '-' ); if ( $punctuate ) $separators = array_merge( $separators, array( '. ', '? ', '! ' ) ); $s = count( $separators ) - 1; $ret = ''; while ( strlen( $ret ) < $len ) { $ret .= $separators[bbipsum_rand( 0, $s )]; // Two consonants $ret .= bbipsum_rand( 0, 1 ) ? $consonants[bbipsum_rand( 0, $c )] : strtoupper( $consonants[bbipsum_rand( 0, $c )] ); $ret .= $consonants[bbipsum_rand( 0, $c )]; // Two to ten vowel [sic] $ret .= str_repeat( $vowels[bbipsum_rand( 0, $v )], bbipsum_rand( 2, 10 ) ); // One consonant $ret .= $consonants[bbipsum_rand( 0, $c )]; } return ucfirst( ltrim( $ret, implode( '', $separators ) ) ); } function bbipsum_rand_punctuation( $allow_none = false ) { if ( $allow_none && !bbipsum_rand( 0, 2 ) ) return ''; if ( bbipsum_rand( 0, 3 ) ) return '.'; if ( bbipsum_rand( 0, 1 ) ) return '?'; return '!'; } function bbipsum_rand_formatting( $sentence ) { $words = explode( ' ', $sentence ); $tags = array( 'strong', 'em', 'a href="#"' ); $opened = array(); $ret = ''; for ( $i = 0, $l = count( $words ); $i < $l; $i++ ) { switch ( bbipsum_rand( 0, 10 ) ) { case 0: if ( $opened ) { $ret .= ' ' . $words[$i] . ''; break; } case 1: $tag = $tags[bbipsum_rand( 0, count( $tags ) - 1 )]; $ret .= ' <' . $tag . '>' . $words[$i] . ''; break; case 2: $tag = $tags[bbipsum_rand( 0, count( $tags ) - 1 )]; $ret .= ' <' . $tag . '>' . $words[$i]; $opened[] = reset( explode( ' ', $tag ) ); break; default: $ret .= ' ' . $words[$i]; } } while ( $opened ) { $ret .= ''; } return trim( $ret ); } function bbipsum_filter( $_ipsum, $full_html = false ) { if ( $full_html ) { $sentences = array_values( array_filter( explode( '. ', strip_tags( str_replace( '

', ' ', bbipsum_filter( $_ipsum . "\n" ) ) ) . ' ' ) ) ); $sentences = array_map( 'bbipsum_rand_formatting', $sentences ); $ret = ''; for ( $i = 0, $l = count( $sentences ); $i < $l; $i++ ) { $list_type = 'o'; switch ( bbipsum_rand( 0, 5 ) ) { case 0: $ret .= '

'; $_i = bbipsum_rand( 1, min( $l - $i, 5 ) ); $ret .= bbipsum_filter( strip_tags( implode( '. ', array_slice( $sentences, $i, $_i ) ) ), true ); $i += $_i; $ret .= '
'; break; case 1: $ret .= "\n\n`\n"; $ret .= $sentences[$i] . "\n"; $ret .= $sentences[$i + 1]; $ret .= "\n`\n\n"; $i++; break; case 2: case 3: $ret .= "\n\n"; for ( $j = min( $l, $i + bbipsum_rand( 1, 5 ) ); $i < $j; $i++ ) { $ret .= $sentences[$i] . bbipsum_rand_punctuation() . ' '; } $ret .= "\n\n"; break; case 4: $list_type = 'u'; case 5: $ret .= '<' . $list_type . 'l>'; for ( $j = min( $l, $i + bbipsum_rand( 1, 5 ) ); $i < $j; $i++ ) { $ret .= '
  • ' . $sentences[$i] . bbipsum_rand_punctuation( true ) . '
  • '; } $ret .= ''; break; } } return $ret; } if ( strpos( $_ipsum, "\n" !== false ) ) { return '

    ' . implode( '

    ', array_map( 'bbipsum_filter', array_filter( explode( "\n", $_ipsum ), 'trim' ) ) ) . '

    '; } $ipsum = explode( '.', $_ipsum ); $ret = ''; foreach ( $ipsum as $i ) { if ( trim( $i ) ) $ret .= ucfirst( trim( $i ) ) . '. '; } return trim( $ret ); }