SocialMarker.com bookmarking button at the bottom of every post. Author: King Kong */ /* Copyright 2007 Sorin Iclanzan (email : contact@socialmarker.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ function sm_utf8_to_unicode( $str ) { $unicode = array(); $values = array(); $lookingFor = 1; for ( $i = 0; $i < strlen( $str ); $i ++ ) { $thisValue = ord( $str[ $i ] ); if ( $thisValue < 128 ) { $unicode[] = $thisValue; } else { if ( count( $values ) == 0 ) { $lookingFor = ( $thisValue < 224 ) ? 2 : 3; } $values[] = $thisValue; if ( count( $values ) == $lookingFor ) { $number = ( $lookingFor == 3 ) ? ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ) : ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 ); $unicode[] = $number; $values = array(); $lookingFor = 1; } } } return $unicode; } function sm_unicode_to_ascii( $unicode ) { $entities = ''; $unicode = sm_utf8_to_unicode( $unicode ); foreach ( $unicode as $value ) { $entities .= ( $value > 127 ) ? '' . $value . ';' : chr( $value ); } return $entities; } function sm_gen_keywords( $content ) { require_once( 'class.autokeyword.php' ); $params['content'] = $content; //page content //set the length of keywords you like $params['min_word_length'] = 5; //minimum length of single words $params['min_word_occur'] = 5; //minimum occur of single words $params['min_2words_length'] = 3; //minimum length of words for 2 word phrases $params['min_2words_phrase_length'] = 10; //minimum length of 2 word phrases $params['min_2words_phrase_occur'] = 3; //minimum occur of 2 words phrase $keyword = new sm_autokeyword( $params ); return $keyword->parse_words(); } function sm_gen_description( $content, $length ) { $description = substr( strip_tags( str_replace( array( "\r\n", "\n", "\r", " • " ), " ", $content ) ), 0, $length ); $poz1 = strrpos( $description, "." ); if ( $poz1 == false || substr( $description, $poz1 + 1, 1 ) != " " ) { $poz1 = 0; } $poz2 = strrpos( $description, "?" ); if ( $poz2 == false || substr( $description, $poz2 + 1, 1 ) != " " ) { $poz2 = 0; } $poz3 = strrpos( $description, "!" ); if ( $poz3 == false || substr( $description, $poz3 + 1, 1 ) != " " ) { $poz3 = 0; } $poz = max( $poz1, $poz2, $poz3 ); if ( $poz == 0 || $poz < $length - 100 ) { $poz = strrpos( $description, " " ); $description = substr( $description, 0, $poz ) . "..."; } else { $description = substr( $description, 0, $poz + 1 ); } return $description; } function encodeText($text) { return urlencode( sm_gen_description( sm_unicode_to_ascii( $text ), 200 ) ); } function insert_socialmarker_button( $content ) { if ( ! is_page() ) { $content .= '