Ignore:
Timestamp:
01/09/14 13:36:32 (6 years ago)
Author:
mistic100
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/CryptograPHP/admin.php

    r26072 r26554  
    3434    'height'          => (int)$_POST['height'], 
    3535    'perturbation'    => (float)$_POST['perturbation'], 
    36     'image_bg_color'  => $_POST['image_bg_color'], 
     36    'background'      => $_POST['background'], 
     37    'bg_color'        => $_POST['bg_color'], 
     38    'bg_image'        => $_POST['bg_image'], 
    3739    'code_length'     => (int)$_POST['code_length'], 
    3840    'text_color'      => $_POST['text_color'], 
     
    5052 
    5153$presets = array( 
    52   'bluenoise' =>  array('perturbation'=>0.25, 'image_bg_color'=>'ffffff', 'text_color'=>'0000ff', 'num_lines'=>2, 'line_color'=>'0000ff', 'noise_level'=>2,   'noise_color'=>'0000ff', 'ttf_file'=>'AlteHassGroteskB'), 
    53   'gray' =>       array('perturbation'=>1,    'image_bg_color'=>'ffffff', 'text_color'=>'8a8a8a', 'num_lines'=>2, 'line_color'=>'8a8a8a', 'noise_level'=>0.1, 'noise_color'=>'8a8a8a', 'ttf_file'=>'TopSecret'), 
    54   'xcolor' =>     array('perturbation'=>0.5,  'image_bg_color'=>'ffffff', 'text_color'=>'random', 'num_lines'=>1, 'line_color'=>'ffffff', 'noise_level'=>2,   'noise_color'=>'ffffff', 'ttf_file'=>'Dread'), 
    55   'pencil' =>     array('perturbation'=>0.8,  'image_bg_color'=>'9e9e9e', 'text_color'=>'363636', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0,   'noise_color'=>'ffffff', 'ttf_file'=>'AllStar'), 
     54  'bluenoise' =>  array('perturbation'=>0.25, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'0000ff', 'num_lines'=>2, 'line_color'=>'0000ff', 'noise_level'=>2, 'noise_color'=>'0000ff', 'ttf_file'=>'AlteHassGroteskB'), 
     55  'gray' =>       array('perturbation'=>1, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'8a8a8a', 'num_lines'=>2, 'line_color'=>'8a8a8a', 'noise_level'=>0.1, 'noise_color'=>'8a8a8a', 'ttf_file'=>'TopSecret'), 
     56  'xcolor' =>     array('perturbation'=>0.5, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'ffffff', 'text_color'=>'random', 'num_lines'=>1, 'line_color'=>'ffffff', 'noise_level'=>2, 'noise_color'=>'ffffff', 'ttf_file'=>'Dread'), 
     57  'pencil' =>     array('perturbation'=>0.8, 'background'=>'color', 'bg_image'=>'', 'bg_color'=>'9e9e9e', 'text_color'=>'363636', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0, 'noise_color'=>'ffffff', 'ttf_file'=>'AllStar'), 
     58  'ransom' =>     array('perturbation'=>0, 'background'=>'image', 'bg_image'=>'bg1.jpg', 'bg_color'=>'ffffff', 'text_color'=>'4a003a', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0, 'noise_color'=>'ffffff', 'ttf_file'=>'ransom'), 
    5659  ); 
    57    
     60 
     61 
     62$template->assign(array( 
     63  'crypto' => $conf['cryptographp'], 
     64  'loaded' => $loaded, 
     65  'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'), 
     66  'backgrounds' => list_backgrounds(CRYPTO_PATH.'securimage/backgrounds'), 
     67  'PRESETS' => $presets, 
     68  'CRYPTO_PATH' => CRYPTO_PATH, 
     69  )); 
     70 
     71$template->set_filename('plugin_admin_content', realpath(CRYPTO_PATH . 'template/admin.tpl')); 
     72$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 
     73 
     74 
     75 
    5876function list_fonts($dir) 
    5977{ 
     
    6583  { 
    6684    if ($file !== '.' && $file !== '..' && get_extension($file)=='ttf')  
    67       $fonts[] = get_filename_wo_extension($file); 
     85    { 
     86      $fonts[get_filename_wo_extension($file)] = $dir . '/' . $file; 
     87    } 
    6888  } 
    6989   
     
    7292} 
    7393 
    74 $template->assign(array( 
    75   'crypto' => $conf['cryptographp'], 
    76   'loaded' => $loaded, 
    77   'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'), 
    78   'PRESETS' => $presets, 
    79   'CRYPTO_PATH' => CRYPTO_PATH, 
    80   )); 
    81  
    82 $template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl'); 
    83 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 
     94function list_backgrounds($dir) 
     95{ 
     96  $dir = rtrim($dir, '/'); 
     97  $dh = opendir($dir); 
     98  $backgrounds = array(); 
     99   
     100  while (($file = readdir($dh)) !== false ) 
     101  { 
     102    if ($file !== '.' && $file !== '..') 
     103    { 
     104      $ext = get_extension($file); 
     105      if ($ext=='jpg' || $ext=='png' || $ext=='jpeg' || $ext=='gif') 
     106      { 
     107        $backgrounds[$file] = $dir . '/' . $file; 
     108      } 
     109    } 
     110  } 
     111   
     112  closedir($dh); 
     113  return $backgrounds; 
     114} 
Note: See TracChangeset for help on using the changeset viewer.