<?php
/**
	Descriptionn: Cryptex Admin Settings Page
	Plugin URI: http://andidittrich.de/go/cryptex
	Version: 1.2
	Author: Andi Dittrich
	Author URI: http://andidittrich.de
	License: MIT X11-License
	
	Copyright (c) 2013-2014, Andi Dittrich

	Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
	
	The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
?>
<?php if (!defined('CRYPTEX_INIT')) die('DIRECT ACCESS PROHIBITED'); ?>

<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div>
<h2><?php _e('Cryptex | E-Mail-Address Protection', 'cryptex'); ?></h2>


<!-- Breadcrumb -->
<?php add_thickbox(); ?>
<div id='setting-error-settings_updated' class='updated settings-error'> 
<p><strong><?php _e('Cryptex related:', 'cryptex'); ?> </strong>
	<a href="#TB_inline?height=500&width=800&inlineId=CryptexHelp" class="thickbox" rel="Cryptex Help"><?php _e('View Help', 'cryptex'); ?></a> | 
	<a href="https://github.com/AndiDittrich/WordPress.Cryptex"><?php _e('Cryptex on GitHub', 'cryptex'); ?></a> | 
	<a href="http://wordpress.org/plugins/cryptex/"><?php _e('Cryptex on WordPress.org', 'cryptex'); ?></a> | 
	<a href="https://github.com/AndiDittrich/WordPress.Cryptex/issues"><?php _e('Report a Bug', 'cryptex'); ?></a>
</p>
<p><strong><?php _e('Howto:', 'cryptex'); ?> </strong><?php _e('Just insert a email-address surrounded by cryptex shortcode into your post! Example:', 'cryptex'); ?> <strong>[email]your.address@yourdomain.tld[/email]</strong></p>
</div>

<!-- Help Overlay Content -->
<?php require('Help.phtml'); ?>

<!-- settings !-->
<form method="post" action="options.php">
    <?php settings_fields('cryptex-settings-group' ); ?>
    
    <!-- System Info -->
    <h3><?php _e('System Info', 'cryptex'); ?></h3>
    <div class="CryptexBlockcontent">
    <ul> 
    	<?php 
    	// PHP version
    	if (version_compare(phpversion(), '5.3', '>=')){
    		echo '<li>', __('PHP Version:', 'cryptex'), ' <span class="CryptexTRUE">', phpversion() , '</span></li>';
    	}else{
    		echo '<li>', __('PHP Version:', 'cryptex'), ' <span class="CryptexFALSE">', phpversion() ,'</span></li>';
    	}
    	
    	// server os
    	echo '<li>', __('Server Software:', 'cryptex'), ' <span class="CryptexTRUE">', PHP_OS, '</span></li>';
    	
    	// cryptex version
    	echo '<li>', __('Cryptex Plugin Version:', 'cryptex'), ' <span class="CryptexTRUE">', CRYPTEX_VERSION, '</span></li>';
    	
    	// check for gdlib
    	if (function_exists('gd_info')){
    		echo '<li>', __('GD library installed:', 'cryptex'), ' <span class="CryptexTRUE">', __('true', 'cryptex'), '</span></li>';
    		$info = gd_info(); 

    		// check GD lib version
   			echo '<li>', __('GD version:', 'cryptex'), ' <span class="CryptexTRUE">',  $info['GD Version'], __(' (supported)', 'cryptex'), '</span></li>';
    		
    		// check png support
    		if ($info['PNG Support']){
    			echo '<li>', __('PNG support:', 'cryptex'), ' <span class="CryptexTRUE">', __('true', 'cryptex'), '</span></li>';
    		}else{
    			echo '<li>', __('PNG support:', 'cryptex'), ' <span class="CryptexFALSE">', __('false', 'cryptex'), '</span></li>';
    		}
    		
    	}else{
    		echo '<li>', __('GD library installed:', 'cryptex'), ' <span class="CryptexFALSE">', __('false', 'cryptex'), '</span></li>';
    	}
    	
    	// check for available fonts
    	if (count($fontlist)>0){    	
    		echo '<li>', __('Fonts available (within selected directory):', 'cryptex'),' <span class="CryptexTRUE">', __('true', 'cryptex'), '</span></li>';	
    	}else{
    		echo '<li>', __('Fonts available (within selected directory):', 'cryptex'),' <span class="CryptexFALSE">', __('false', 'cryptex'), '</span></li>';
    	}
    	
    	// plugin cache path writeable ?
    	$cachePath = CRYPTEX_PLUGIN_PATH.DIRECTORY_SEPARATOR.'cache';
    	if (is_dir($cachePath) && is_writable($cachePath)){
    		echo '<li>', __('Cache writeable', 'cryptex'),' (<code>', $cachePath ,'</code>): <span class="CryptexTRUE">', __('true', 'cryptex'), '</span></li>';
    	}else{
    		echo '<li>', __('Cache writeable', 'cryptex'),' (<code>', $cachePath ,'</code>): <span class="CryptexFALSE">', __('false', 'cryptex'), '</span></li>';
    	}
    	?>
    </ul>	
    </div>
    
    <!-- System Font Source -->
    <h3><?php _e('Font Source', 'cryptex'); ?></h3>
    <div class="CryptexBlockcontent">
        <p><?php _e('Cryptex requires server-side stored TrueTypeFonts to generate the images. Select the font location which should be used - only <strong>.ttf</strong> files are supported! The location will be recursivly scanned by the plugin (including all subdirectories).', 'cryptex'); ?></p>
   		<p>
		<?php _e('<strong>System Fonts</strong> - the default font location of your server', 'cryptex'); ?> (<code><?php echo implode(';', Cryptex\FontManager::$WindowsFontPaths); ?></code> <?php _e('on Windows', 'cryptex'); ?>; <code><?php echo implode(';', Cryptex\FontManager::$LinuxFontPaths); ?></code> <?php _e('on Linux', 'cryptex'); ?><br />
		<?php _e('<strong>Plugin Directory</strong> - the <code>fonts</code> directory within the cryptex plugin path', 'cryptex'); ?> (<code><?php echo CRYPTEX_DEFAULT_FONT_PATH ?></code>)<br />
		<?php _e('<strong>Custom Directory</strong> - enter a custom directory of your choice', 'cryptex'); ?>
		</p>
		
		<h4><?php _e('TrueTypeFont Location'); ?></h4>
		<!-- Font Source -->
		<?php $this->_settingsUtility->displaySelect(__('Font-Source', 'cryptex'), 'font-source', array(__('System Fonts', 'cryptex') => 'system', __('Plugin Directory', 'cryptex') => 'plugin', __('Custom Directory', 'cryptex') => 'custom')); ?>
		
		<!-- Custom Font Path -->
		<div id="CryptexCustomFontpath">
		<?php $this->_settingsUtility->displayInput(__('Font-Path', 'cryptex'), 'custom-font-path', __('e.g.', 'cryptex').' /usr/share/fonts'); ?>
		</div>
		
		<input name="submit" id="CryptexApplyChanges" class="button button-primary" value="<?php _e('Apply Changes', 'cryptex'); ?>" type="submit" />
	</div>
    
	<!-- appearance !-->
    <h3><?php _e('Appearance', 'cryptex'); ?></h3>
    <div class="CryptexBlockcontent">
    	<h4><?php _e('Font Styles', 'cryptex'); ?></h4>
		<p><?php _e('Change these settings to match your current theme styles.', 'cryptex'); ?> <br />
		<?php _e('<strong>Note: </strong>It`s strongly recommend to use standard fonts only', 'cryptex'); ?>
		</p>

		<!-- Font List -->
		<?php $this->_settingsUtility->displaySelect(__('Font-Family', 'cryptex'), 'font-file', $fontlist); ?>
		
		<!-- Font Size -->
		<?php $this->_settingsUtility->displayInput(__('Font-Size (px)', 'cryptex'), 'font-size', __('e.g. 12', 'cryptex')); ?>
		
		<!-- Font Color -->
		<?php $this->_settingsUtility->displayInput(__('Font-Color', 'cryptex'), 'font-color', __('e.g. #000000, #ff00c1', 'cryptex'), 'CryptexColorChooser'); ?>
		
		<h4><?php _e('E-Mail Text Transformations', 'cryptex'); ?></h4>
		<p><?php _e('These replacements are only applied to E-Mail-Addresses', 'cryptex'); ?></p>
		
		<!-- @ replacement -->
    	<p><?php _e('Instead of using the @ sign for emails, you can choose between some options - this could increase the protection level against spiders/bots using OCR.', 'cryptex'); ?>				
  	 	<br /><?php _e('<strong>Note:</strong> Use ALWAYS the @ sign in the cryptex shortcode!', 'cryptex'); ?></p>
		<?php $this->_settingsUtility->displaySelect(__('@Sign-Replacement', 'cryptex'), 'email-divider', array(__('No Replacement',  'cryptex') => '@', '(at)' => '(at)', '[at]' => '[at]', '{at}' => '{at}', '/AT/' => '/AT/')); ?>
		
		<br /><?php _e('<strong>Note:</strong> Use ALWAYS the . in the cryptex shortcode!', 'cryptex'); ?></p>
		<?php $this->_settingsUtility->displaySelect(__('Dot-Replacement', 'cryptex'), 'email-replacement-dot', array(__('No Replacement',  'cryptex') => '.', '(dot)' => '(dot)', '[dot]' => '[dot]', '{dot}' => '{dot}', '(.)' => '(.)', '[.]' => '[.]')); ?>
		
				
		<h4><?php _e('General Settings', 'cryptex'); ?></h4>
		<!-- hyperlinks !-->
		<p><?php _e('Should E-Mail-Addresses clickable ? (mailto:youremail@example.com)', 'cryptex'); ?><br />
		<?php _e('Cryptex provides an integrated key-shifting based encryption/decryption of hyperlinks to ensure maximum protection.', 'cryptex'); ?>
		</p>
		<?php $this->_settingsUtility->displayCheckbox(__('Enable-Hyperlinks', 'cryptex'), 'enable-hyperlink'); ?>
		
		<!-- EMail Security Level -->
		<p><?php _e('E-Mail-addresses can be displayed as a single image or, in case of higher security, as a multipart-image.', 'cryptex'); ?><br />
		<?php _e('The address will be splitted into 2 parts (before and after the @ sign). Each part is displayed as a single image, the @ sign as plain text. This feature provides an improved protection against ocr-grabbing spambots, which will analyze page images.', 'cryptex'); ?><br />
		<?php _e('Note: This option will only influence E-Mail-addresses, other content will be still displayed as a single image!', 'cryptex'); ?>
		</p>
		<?php $this->_settingsUtility->displaySelect(__('E-Mail Security Level', 'cryptex'), 'security-level', array(__('Text (not recommended)', 'cryptex') => '0', __('Single Image', 'cryptex') => '1', __('Multipart Image (2 Images, seperated by @ sign)', 'cryptex') => '2', __('Advanced Multipart Image (Multiple Images, seperated by dot AND @ sign)', 'cryptex') => '3')); ?>
	</div>
	
	<!-- EMail Autodetection !-->
    <h3><?php _e('E-Mail-Address Autodetction', 'cryptex'); ?></h3>
    <div class="CryptexBlockcontent">
		<p><?php _e('Should E-Mail-Addresses automatically transformed into images ? No need for shortcode!', 'cryptex'); ?><br />
		<?php _e('Note: <strong>ALL</strong> E-Mail-Addresses on your page will be transformed. This will be a usefull functionality on most blogs but can cause problems when posting sourcecode.', 'cryptex'); ?>
		</p>
		
		<!-- Enable Detection -->
		<?php $this->_settingsUtility->displayCheckbox(__('Enable Autodetection', 'cryptex'), 'email-autodetect'); ?>

		<div id="CryptexAutodetectionOptions">
			<!-- Exclude post/pages from autodetection -->
			<p><?php _e('You can exclude several post/pages from beeing autodetected by adding their IDs to the following list (comma sperated)', 'cryptex'); ?></p>
			<?php $this->_settingsUtility->displayInput(__('Exclude Post/Pages', 'cryptex'), 'email-autodetect-excludeid', __('e.g. 17, 18, 45', 'cryptex')); ?>
					
			<h4><?php _e('Filter Targets', 'cryptex'); ?></h4>
			<p><?php _e('Choose the content-sections to which the autodetect-filter should be applied.', 'cryptex'); ?></p>
			<!-- Enable the_content filter -->
			<?php $this->_settingsUtility->displayCheckbox(__('Transform the_content', 'cryptex'), 'email-autodetect-content'); ?>
			
			<!-- Enable the_excerpt filter -->
			<?php $this->_settingsUtility->displayCheckbox(__('Transform the_excerpt', 'cryptex'), 'email-autodetect-excerpt'); ?>
			
			<!-- Enable comment-text filter -->
			<?php $this->_settingsUtility->displayCheckbox(__('Transform comments', 'cryptex'), 'email-autodetect-comments'); ?>
			
			<!-- Enable comment-excerpt filter -->
			<?php $this->_settingsUtility->displayCheckbox(__('Transform comments-excerpt', 'cryptex'), 'email-autodetect-comments-excerpt'); ?>
		</div>
    </div>
	
	<!-- offsets !-->
    <h3><?php _e('Image Offsets', 'cryptex'); ?></h3>
    <div class="CryptexBlockcontent">
 		<!-- Image Offsets -->
		<p><?php _e('Sometimes the generated text, depending on the selected font family, won`t fit into his image box - it is possible to configure the following offsets (in px) to fix this issue:', 'cryptex')?><br />
		<?php _e('Offsets can also be used to adjust the font baseline (use Offset A and Offset B).', 'cryptex'); ?>
		</p>
		<p><img src="<?php echo plugins_url('/cryptex/resources/admin/offsets.png'); ?>" alt="offsets" /></p>
		<h4><?php _e('Offset Values', 'cryptex'); ?></h4>
		<?php $this->_settingsUtility->displayInput(__('Offset X (width)', 'cryptex'), 'offset-x', 'e.g. 5'); ?>
		<?php $this->_settingsUtility->displayInput(__('Offset Y (height)', 'cryptex'), 'offset-y', 'e.g. 5'); ?>
		<?php $this->_settingsUtility->displayInput(__('Offset A (font position x)', 'cryptex'), 'offset-a', 'e.g. 2'); ?>
		<?php $this->_settingsUtility->displayInput(__('Offset B (font position y)', 'cryptex'), 'offset-b', 'e.g. 2'); ?>   
    </div>
	
	<!-- CDN SETTINGS -->
	<h3><?php _e('CDN (Content Delivery Network)', 'cryptex'); ?></h3>
	<div class="CryptexBlockcontent">		
		<p><?php _e('These options might be required when using a Content-Delivery-Network (CDN) or another server/location which outsources your CSS+Javascript files.', 'cryptex'); ?><br />
		<?php _e('In this case you have to manually include Cryptex.js and Cryptex.css into your page!', 'cryptex'); ?><br />
		<?php _e('The generated styles are', 'cryptex'); ?> <a href="<?php echo plugins_url('/cryptex/cache/Cryptex.css') ?>"><?php _e('available here', 'cryptex'); ?></a> (cryptex/cache/Cryptex.css).</p>
		
		<!-- embed css !-->
		<?php $this->_settingsUtility->displayCheckbox(__('Include Cryptex-CSS', 'cryptex'), 'embed-css') ?>
	
		<!-- embed JS !-->
		<?php $this->_settingsUtility->displayCheckbox(__('Include Cryptex-Javascript', 'cryptex'), 'embed-js'); ?>

	</div>
	
	<!-- ADVANCED SETTINGS -->
	<h3><?php _e('Advanced', 'cryptex'); ?></h3>
	<p><strong><?php _e('Warning: These options are for advanced users only!', 'cryptex'); ?></strong></p>
	<div class="CryptexBlockcontent">
		<h4><?php _e('Miscellaneous', 'cryptex'); ?></h4>
		<p><?php _e('Should the shortcode [email] added as alias for cryptex? Kindly note that this can influence other plugins because of identical names!', 'cryptex'); ?></p>
		<!-- email shortcode !-->
		<?php $this->_settingsUtility->displayCheckbox(__('Use [email] Shortcode', 'cryptex'), 'shortcode-email') ?>
	
		<!-- font filenames -->
		<p><?php _e('Should the full font-paths be displayed on this settings page or only their file names ?', 'cryptex')?></p>
		<?php $this->_settingsUtility->displayCheckbox(__('Show the full font-paths.', 'cryptex'), 'show-full-paths') ?>
	
		<h4><?php _e('CSS Options', 'cryptex'); ?></h4>
		<!-- css prefix -->
		<p><?php _e('An optional prefix added to the generated css classes to match your content-container and retain cryptex styles.', 'cryptex'); ?></p>
		<?php $this->_settingsUtility->displayInput(__('CSS Prefix', 'cryptex'), 'css-prefix', __('e.g. #content, .mycontentarea', 'cryptex')); ?>
		
		<!-- css classes -->
		<p><?php _e('Additional css classes added to the outer span-tag - maybe used to add icons.', 'cryptex')?></p>
		<?php $this->_settingsUtility->displayInput(__('Additional Classes', 'cryptex'), 'css-classes', __('e.g. email mailicon', 'cryptex')); ?>
		
		<!-- Nested Shortcodes -->
		<h4><?php _e('Nested Shortcodes', 'cryptex'); ?></h4>
		<p><?php _e('In some cases it can be necessary to process nested-shortcodes (shortcodes within a cryptex/email tag) - maybe the inner shortcode fetches some content from your database, etc. Only enable this option if you exactly know what your doing!', 'cryptex'); ?></p>
		<?php $this->_settingsUtility->displayCheckbox(__('Enable Nested-Shortcodes', 'cryptex'), 'nestedShortcodes'); ?>
	
		<!-- I18n -->
		<h4><?php _e('I18n (Internationalization)', 'cryptex'); ?></h4>
		<p><?php _e('Should the plugin load the language files (if available) to translate the settings page ?', 'cryptex'); ?></p>
		<?php $this->_settingsUtility->displayCheckbox(__('Enable I18n', 'cryptex'), 'translation-enabeled'); ?>
	</div>
	
	
	<!-- submit !-->
    <?php submit_button(); ?>

</form>

<p><a href="http://www.a3non.org/go/cryptex">Cryptex</a> <?php _e('is developed by', 'cryptex'); ?> <a href="http://andidittrich.de">Andi Dittrich</a>. <?php _e('It`s released under the terms of the MIT X11 License.', 'cryptex'); ?> <?php _e('Includes:', 'cryptex'); ?> <a href="http://www.eyecon.ro/colorpicker/">Colorpicker</a> <?php _e('by', 'cryptex'); ?> <a href="http://www.eyecon.ro">Stefan Petre</a> - MIT/GPL <?php _e('License', 'cryptex'); ?></p>
</div>
