source: extensions/CryptograPHP/template/admin.tpl @ 26554

Revision 26554, 12.0 KB checked in by mistic100, 6 years ago (diff)

update Securimage to 3.5.1, new font, new preset, allow to use backgrounds

Line 
1{combine_css path=$CRYPTO_PATH|cat:'template/style.css'}
2
3{combine_css path=$CRYPTO_PATH|cat:'template/colorpicker/colorpicker.css'}
4{combine_script id='jquery.colorpicker' load='footer' path=$CRYPTO_PATH|cat:'template/colorpicker/colorpicker.js'}
5
6{combine_css path='themes/default/js/plugins/chosen.css'}
7{combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'}
8
9
10{footer_script}
11var time = 0;
12
13// colorpicker
14$('.colorpicker-input')
15  .ColorPicker({
16    onSubmit: function(hsb, hex, rgb, el) {
17      $(el).val(hex);
18      $(el).ColorPickerHide();
19    },
20    onChange: function(hsb, hex, rgb, el) {
21      $(el).val(hex).trigger('change');
22      changeColor(el, hex);
23    },
24    onBeforeShow: function () {
25      $(this).ColorPickerSetColor(this.value);
26    }
27  })
28  .bind('keyup', function() {
29    $(this).ColorPickerSetColor(this.value);
30    changeColor(this, $(this).val());
31  })
32  .each(function() {
33    changeColor(this, $(this).val());
34  });
35 
36 
37$('.button').click(function() {
38  $(this).siblings('.button').removeClass('selected');
39  $(this).addClass('selected');
40  $('input[name='+ $(this).data('input') +']').val($(this).data('val')).trigger('change');
41});
42
43// change button
44$('input[name=button_color]').change(function() {
45  $('#reload').attr('src', '{$CRYPTO_PATH}template/refresh_'+ $(this).val() +'.png');
46});
47
48// apply a preset
49$('input[name=theme]').change(function() {
50  var id = $(this).val();
51 
52  for (key in presets[id]) {
53    if ($('input[name="'+ key +'"]').attr('type') == 'radio') {
54      $('input[name="'+ key +'"][value="'+ presets[id][key] +'"]').prop('checked', true).trigger('change', false);
55    }
56    else {
57      $('input[name="'+ key +'"]').val(presets[id][key]).trigger('change', false);
58    }
59  }
60 
61  $('.colorpicker-input').each(function() {
62    changeColor(this, $(this).val());
63  });
64
65  changePreview();
66});
67
68// toggle background type
69$('input[name=background]').change(function() {
70  $('li[id^=background]').hide().filter('#background-'+$(this).val()).show();
71});
72
73// display customization panel
74$('.customize').click(function() {
75  $('#theming').toggle();
76});
77
78// change theme to 'custom' if a parameter is changed
79$('input.istheme').change(function(e, p) {
80  if (p!==false) setThemeCustom();
81});
82
83// update the preview
84$('input.preview').change(function(e, p) {
85  if (p!==false) changePreview();
86});
87$('#reload').click(function() {
88  changePreview();
89});
90
91// links for random color
92$('a.random').click(function() {
93  $(this).prev('label').children('input').val('random').trigger('change');
94  changeColor($(this).prev('label').children('input'), 'random');
95});
96
97// multiselect
98$("select").css({
99  width: 300
100}).chosen({
101  disable_search:true,
102});
103
104function setThemeCustom() {
105  $('.button[data-input=theme]').removeClass('selected');
106  $('input[name=theme]').val('custom');
107}
108
109function changePreview() {
110  var now = (new Date()).getTime();
111
112  if (now-time < 1000) {
113    return;
114  }
115  time = now;
116 
117  options = new Array();
118  str = '';
119 
120  $('input.preview:not([type=radio]), input[type=radio].preview:checked').each(function() {
121    options[$(this).attr('name')] = $(this).val();
122  });
123 
124  for (x in options) {
125    str+= '&' + x + '=' + options[x];
126  }
127  $('#captcha').attr('src', '{$CRYPTO_PATH}securimage/securimage_preview.php?' + new Date().getTime() + str);
128}
129
130function changeColor(target, color) {
131  if (color == 'random') {
132    color = '808080';
133  }
134  if (parseInt(color, 16) > 16777215/2) {
135    $(target).css('color', '#222');
136  }
137  else {
138    $(target).css('color', '#ddd');
139  }
140  $(target).css('background', '#'+color)
141}
142
143var presets = {
144{foreach from=$PRESETS key=name item=params}
145  "{$name}" : {
146  {foreach from=$params key=key item=value}
147    "{$key}" : "{$value}",
148  {/foreach}
149  },
150{/foreach}
151};
152{/footer_script}
153
154
155{html_style}
156{foreach from=$fonts item=path key=font}
157@font-face { 
158  font-family: '{$font}'; 
159  src: url({$path}) format("truetype"); 
160}
161{/foreach}
162{/html_style}
163
164
165<div class="titrePage">
166  <h2>Crypto Captcha</h2>
167</div>
168
169<form method="post" class="properties">
170<fieldset>
171  <legend>{'Configuration'|translate}</legend>
172 
173  <ul>
174    <li>
175      <b>{'Activate on'|translate}</b>
176      <select name="activate_on[]" multiple>
177        <option value="picture" {if $crypto.activate_on.picture}selected{/if}>{'Picture comments'|translate}</option>
178        {if $loaded.category}<option value="category" {if $crypto.activate_on.category}selected{/if}>{'Album comments'|translate}</option>{/if}
179        <option value="register" {if $crypto.activate_on.register}selected{/if}>{'Register form'|translate}</option>
180        {if $loaded.contactform}<option value="contactform" {if $crypto.activate_on.contactform}selected{/if}>{'Contact form'|translate}</option>{/if}
181        {if $loaded.guestbook}<option value="guestbook" {if $crypto.activate_on.guestbook}selected{/if}>{'Guestbook'|translate}</option>{/if}
182      </select>
183    </li>
184    <li>
185      <b>{'Comments action'|translate}</b>
186      <label><input type="radio" name="comments_action" value="reject" {if $crypto.comments_action == 'reject'}checked="checked"{/if}> {'Reject'|translate}</label>
187      <label><input type="radio" name="comments_action" value="moderate" {if $crypto.comments_action == 'moderate'}checked="checked"{/if}> {'Moderate'|translate}</label>
188    </li>
189    <li>
190      <b>{'Captcha type'|translate}</b>
191      <label><input type="radio" name="captcha_type" class="preview" value="string" {if $crypto.captcha_type == 'string'}checked="checked"{/if}> {'Random string'|translate}</label>
192      <label><input type="radio" name="captcha_type" class="preview" value="math" {if $crypto.captcha_type == 'math'}checked="checked"{/if}> {'Simple equation'|translate}</label>
193    </li>
194    <!--<li>
195      <b>{'Case sensitive'|translate}</b>
196      <label><input type="radio" name="case_sensitive" value="false" {if $crypto.case_sensitive == 'false'}checked="checked"{/if}> {'No'|translate}</label>
197      <label><input type="radio" name="case_sensitive" value="true" {if $crypto.case_sensitive == 'true'}checked="checked"{/if}> {'Yes'|translate}</label>
198    </li>-->
199    <li>
200      <b>{'Code lenght'|translate}</b>
201      <label><input type="text" name="code_length" class="preview" value="{$crypto.code_length}" size="6" maxlength="2"></label>
202    </li>
203    <li>
204      <b>{'Width'|translate}</b>
205      <label><input type="text" name="width" class="preview" value="{$crypto.width}" size="6" maxlength="3"> {'good value:'|translate} lenght&times;30</label>
206    </li>
207    <li>
208      <b>{'Height'|translate}</b>
209      <label><input type="text" name="height" class="preview" value="{$crypto.height}" size="6" maxlength="3"> {'good value:'|translate} lenght&times;12</label>
210    </li>
211    <li>
212      <b>{'Button color'|translate}</b>
213      <a class="button {if $crypto.button_color == 'dark'}selected{/if}" data-val="dark" data-input="button_color"><img src="{$CRYPTO_PATH}template/refresh_dark.png" alt="dark"></a>
214      <a class="button {if $crypto.button_color == 'light'}selected{/if}" data-val="light" data-input="button_color"><img src="{$CRYPTO_PATH}template/refresh_light.png" alt="light"></a>
215      <input type="hidden" name="button_color" value="{$crypto.button_color}">
216    </li>
217    <li>
218      <b>{'Captcha theme'|translate}</b>
219    {foreach from=$PRESETS key=preset item=params}
220      <a class="button {if $crypto.theme == $preset}selected{/if}" data-val="{$preset}" data-input="theme"><img src="{$CRYPTO_PATH}template/presets/{$preset}.png" alt="{$preset}"></a>
221    {/foreach}
222      <input type="hidden" name="theme" value="{$crypto.theme}">
223      <a class="customize">{'Customize'|translate}</a>
224    </li>
225  </ul>
226 
227  <fieldset {if $crypto.theme != 'custom'}style="display:none;"{/if} id="theming">
228    <legend>{'Customize'|translate}</legend>
229   
230    <ul>
231      <li>
232        <b>{'Perturbation'|translate}</b>
233        <label><input type="text" name="perturbation" value="{$crypto.perturbation}" class="istheme preview" size="6" maxlength="4"> {'range:'|translate} 0 - 1</label>
234      </li>
235      <li>
236        <b>{'Background'|translate}</b>
237        <label><input type="radio" name="background" class="istheme preview" value="color" {if $crypto.background == 'color'}checked="checked"{/if}> {'Color'|translate}</label>
238        <label><input type="radio" name="background" class="istheme preview" value="image" {if $crypto.background == 'image'}checked="checked"{/if}> {'Image'|translate}</label>
239      </li>
240      <li id="background-color" {if $crypto.background != 'color'}style="display:none;"{/if}>
241        <b>{'Background color'|translate}</b>
242        <label><input type="text" name="bg_color" value="{$crypto.bg_color}" class="colorpicker-input istheme preview" size="6" maxlength="6"></label>
243        <a class="random" title="{'random'|translate}"><img src="{$CRYPTO_PATH}/template/arrow_switch.png"></a>
244      </li>
245      <li id="background-image" {if $crypto.background != 'image'}style="display:none;"{/if}>
246        <b>{'Background image'|translate}</b>
247      {foreach from=$backgrounds item=path key=background}
248        <a class="button {if $crypto.bg_image == $background}selected{/if}" data-val="{$background}" data-input="bg_image"><img src="{$path}" alt="{$background}" style="width:120px;height:40px;"></a>
249      {/foreach}
250        <!-- <a class="button {if $crypto.bg_image == 'random'}selected{/if}" title="{'random'|translate}" data-val="random" data-input="bg_image"><img src="{$CRYPTO_PATH}/template/arrow_switch.png"></a> -->
251        <input type="hidden" name="bg_image" value="{$crypto.bg_image}" class="istheme preview">
252      </li>
253      <li>
254        <b>{'Text color'|translate}</b>
255        <label><input type="text" name="text_color" value="{$crypto.text_color}" class="colorpicker-input istheme preview" size="6" maxlength="6"></label>
256        <a class="random" title="{'random'|translate}"><img src="{$CRYPTO_PATH}/template/arrow_switch.png"></a>
257      </li>
258      <li>
259        <b>{'Lines density'|translate}</b>
260        <label><input type="text" name="num_lines" value="{$crypto.num_lines}" class="istheme preview" size="6" maxlength="4"> {'range:'|translate} 0 - 10</label>
261      </li>
262      <li>
263        <b>{'Lines color'|translate}</b>
264        <label><input type="text" name="line_color" value="{$crypto.line_color}" class="colorpicker-input istheme preview" size="6" maxlength="6"></label>
265        <a class="random" title="{'random'|translate}"><img src="{$CRYPTO_PATH}/template/arrow_switch.png"></a>
266      </li>
267      <li>
268        <b>{'Noise level'|translate}</b>
269        <label><input type="text" name="noise_level" value="{$crypto.noise_level}" class="istheme preview" size="6" maxlength="4"> {'range:'|translate} 0 - 10</label>
270      </li>
271      <li>
272        <b>{'Noise color'|translate}</b>
273        <label><input type="text" name="noise_color" value="{$crypto.noise_color}" class="colorpicker-input istheme preview" size="6" maxlength="6"></label>
274        <a class="random" title="{'random'|translate}"><img src="{$CRYPTO_PATH}/template/arrow_switch.png"></a>
275      </li>
276      <li>
277        <b>{'Font'|translate}</b>
278      {foreach from=$fonts item=path key=font}
279        <label style="font-family:{$font};" title="{$font}"><input type="radio" name="ttf_file" value="{$font}" {if $crypto.ttf_file == $font}checked="checked"{/if} class="istheme preview"> {$font}</label>
280      {/foreach}
281      </li>
282    </ul>
283   
284    {'Tip: type "random" on a color field to have a random color'|translate}
285  </fieldset>
286 
287  <ul style="margin-top:30px;">
288    <li>
289      <b>{'Preview'|translate}</b>
290      <img id="captcha" src="{$CRYPTO_PATH}securimage/securimage_show.php" alt="CAPTCHA Image">
291      <a href="#" onClick="return false;"><img id="reload" src="{$CRYPTO_PATH}template/refresh_{$crypto.button_color}.png"></a>
292    </li>
293  </ul>
294 
295</fieldset>
296
297<p class="formButtons"><input class="submit" type="submit" value="{'Submit'|translate}" name="submit"></p>
298</form>
299
300<div style="text-align:right;">
301  All free fonts from <a href="http://www.dafont.com" target="_blank">dafont.com</a> |
302  Powered by : <a href="http://www.phpcaptcha.org/" target="_blank"><img src="{$CRYPTO_PATH}template/logo.png" alt="Secureimage"></a>
303</div>
Note: See TracBrowser for help on using the repository browser.