* @license http://opensource.org/licenses/gpl-license.php GNU Public License */ Class cryptX { // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- /** * Constructor * * This constructor attaches the needer plugin hook callbacks */ function cryptX() { global $cryptX_var; // attach the converstion handlers // if (@$cryptX_var[theContent]) { $this->_filter('the_content'); } if (@$cryptX_var[theExcerpt]) { $this->_filter('the_excerpt'); } // attach to admin menu // if (is_admin()) { add_action('admin_menu', array(&$this, '_menu') ); } // attach to plugin installation // add_action( 'activate_' . str_replace( DIRECTORY_SEPARATOR, '/', str_replace( realpath(ABSPATH . PLUGINDIR) . DIRECTORY_SEPARATOR, '', __FILE__ ) ), array(&$this, '_install') ); // attach javascript to Header // if (@$cryptX_var[java]) { add_action( 'wp_head', array(&$this, '_header') ); } } // End function // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function _filter($apply) { global $cryptX_var; if (@$cryptX_var[autolink]) { add_filter($apply, array(&$this, '_autolink')); } if (@$cryptX_var[java]) { add_filter($apply, array(&$this, '_encrypt')); } else { add_filter($apply, array(&$this, '_unicode')); } } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function _linktext($txt) { global $cryptX_var; switch ($cryptX_var[opt_linktext]) { case 1: // alternative text for mail link $linktext = $cryptX_var[alt_linktext]; break; case 2: // alternative image for mail link $linktext = "\"email\""; break; case 3: // uploaded image for mail link $imgurl = "/" . PLUGINDIR . "/" . dirname(plugin_basename (__FILE__)) . "/images/" . $cryptX_var[alt_uploadedimage]; $linktext = "\"""; break; default: $linktext = str_replace( "@", $cryptX_var[at], $txt); $linktext = str_replace( ".", $cryptX_var[dot], $linktext); } return $linktext; } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function _dirImages() { $dir = $_SERVER["DOCUMENT_ROOT"].'/'.PLUGINDIR.'/'.dirname(plugin_basename (__FILE__)).'/images'; $fh = opendir($dir); //Verzeichnis $verzeichnisinhalt = array(); while (true == ($file = readdir($fh))) { if ((substr(strtolower($file), -3)=="jpg") or (substr(strtolower($file), -3)=="gif")) //Abfrage nach gültigen Datenformat { $verzeichnisinhalt[] = $file; } } return $verzeichnisinhalt; } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function _encrypt($content) { global $cryptX_var; preg_match_all('/]*href=["|\'](.*)["|\'].*>(.*)<\/a>/iUs', $content, $links, PREG_SET_ORDER); foreach( $links as $link ) { if(preg_match('/mailto:(.*)/', $link[1], $mail)) { $crypt = ''; $ascii = 0; for ($i = 0; $i < strlen( $mail[1] ); $i++) { $ascii = ord ( substr ( $mail[1], $i ) ); if (8364 <= $char) { $ascii = 128; } $crypt .= chr($ascii + 1); } $temp = str_replace( $link[1], "javascript:DeCryptX('" . $crypt . "')", $link[0]); $temp = str_replace( $link[2], $this->_linktext($link[2]), $temp); $content = str_replace( $link[0], $temp, $content); } } // foreach return $content; } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function _unicode($content) { global $cryptX_var; preg_match_all('/]*href=["|\'](.*)["|\'].*>(.*)<\/a>/iUs', $content, $links, PREG_SET_ORDER); foreach( $links as $link ) { if(preg_match('/mailto:(.*)/', $link[1], $mail)) { $mailto = "mailto:" . $mail[1]; $crypt = ''; for ($i = 0; $i < strlen( $mailto ); $i++) { $crypt .= "&#" . ord ( substr ( $mailto, $i ) ) . ";"; } $content = str_replace( $mailto, $crypt, $content); $content = str_replace( $link[2], $this->_linktext($link[2]), $content); } } // foreach return $content; } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function _autolink($content) { $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si"; $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si"; $src[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si"; $src[]="/(]*>)]*>/"; $src[]="/(<\/A>)<\/A>/i"; $tar[]="\\1\\2"; $tar[]="\\1\\2\\6"; $tar[]="\\0"; $tar[]="\\1"; $tar[]="\\1"; $content = preg_replace($src,$tar,$content); return $content; } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function _install() { add_option( 'cryptX', array( 'at' => ' [at] ', 'dot' => ' [dot] ', 'theContent' => 1, 'theExcerpt' => 0, 'java' => 1, 'opt_linktext' => 0, ) ); } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- /** * Attach the menu page to the `Options` tab */ function _header() { $cryptX_script.= "\n"; print($cryptX_script); } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- /** * Attach the menu page to the `Options` tab */ function _menu() { add_submenu_page('options-general.php', 'CryptX', 'CryptX', 9, __FILE__, array($this, '_submenu') ); } /** * Handles and renders the menu page */ function _submenu() { global $cryptX_var; // sanitize referrer // $_SERVER['HTTP_REFERER'] = preg_replace( '~&saved=.*$~Uis','', $_SERVER['HTTP_REFERER'] ); // information updated ? // if ($_POST['submit']) { // save // update_option( 'cryptX', $_POST['cryptX_var'] ); die(""); } // operation report detected // if (@$_GET['saved']) { list($saved, $ts) = explode(':', $_GET['saved']); if (time() - $ts < 10) { echo '

'; switch ($saved) { case 'settings' : echo 'Settings saved.'; break; } echo '

'; } } // read the settings // //$cryptX = (array) get_option('cryptX'); ?>

/>     
    
/>   
/>   
/>   
 

type="checkbox" />  
type="checkbox" />

type="radio" value="1" />
type="radio" value="0" />

type="checkbox" />
_autolink( $content ); if(@$cryptX_var[java]) { $content = $cryptX->_encrypt( $content ); } else { $content = $cryptX->_unicode( $content ); } if("" != $text) { $content = preg_replace( "/(]*>)(.*)(<\/a>)/i", '$1'.$text.'$3', $content ); } if("" != $css) { $content = preg_replace( "/(]*)(>)/i", '$1 class="'.$css.'"$2', $content ); } if(1 == $echo) echo $content; return $content; } ?>