Ignore:
Timestamp:
May 19, 2012, 12:07:43 AM (12 years ago)
Author:
mistic100
Message:

fix textarea size
better PHP code for config

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmiliesSupport/admin.php

    r14526 r15110  
    1717{
    1818  // the smilies.txt file is not saved if the directory is changed
    19   if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport['folder'])
     19  if (isset($_POST['folder']) AND $_POST['folder'] != $conf_smiliessupport['folder'])
    2020  {
    2121    $not_save_file = true;
    2222   
    23     $handle = opendir(SMILIES_PATH.'smilies/'.$_POST['text1']);
    24     $i = 0;
    25     while (false !== ($file = readdir($handle)))
     23    if (!file_exists(SMILIES_PATH.'smilies/'.$_POST['folder'].'/'.$_POST['representant']))
    2624    {
    27       if ( $file != '.' AND $file != '..' AND in_array(get_extension($file), array('gif', 'jpg', 'png')) )
     25      $handle = opendir(SMILIES_PATH.'smilies/'.$_POST['folder']);
     26      $i = 0;
     27      while (false !== ($file = readdir($handle)))
    2828      {
    29         $_POST['text3'] = $file;
    30         closedir($handle);
    31         break;
     29        if ( $file != '.' AND $file != '..' AND in_array(get_extension($file), array('gif', 'jpg', 'png')) )
     30        {
     31          $_POST['representant'] = $file;
     32          closedir($handle);
     33          break;
     34        }
    3235      }
    3336    }
     
    3639  // new configuration
    3740  $conf_smiliessupport = array(
    38     'folder' => isset($_POST['text1']) ? $_POST['text1'] : 'crystal',
    39     'cols' => isset($_POST['text2']) ? $_POST['text2'] : '6',
    40     'representant' => isset($_POST['text3']) ? $_POST['text3'] : 'smile.png',
     41    'folder' => isset($_POST['folder']) ? $_POST['folder'] : 'crystal',
     42    'cols' => isset($_POST['cols']) ? $_POST['cols'] : '6',
     43    'representant' => isset($_POST['representant']) ? $_POST['representant'] : 'smile.png',
    4144  );
    42   if (empty($_POST['text'])) $_POST['text'] = ':)    smile.png';
     45  if (empty($_POST['text'])) $_POST['text'] = '';
    4346   
    4447  conf_update_param('smiliessupport', serialize($conf_smiliessupport));
     
    97100
    98101$template->assign(array(
    99   'TEXT1_VALUE' => $conf_smiliessupport['folder'],
    100   'TEXT2_VALUE' => $conf_smiliessupport['cols'],
    101   'TEXT3_VALUE' => $conf_smiliessupport['representant'],
     102  'FOLDER' => $conf_smiliessupport['folder'],
     103  'COLS' => $conf_smiliessupport['cols'],
     104  'REPRESENTANT' => $conf_smiliessupport['representant'],
    102105  'sets' => $sets,
    103106  'smiliesfiles' => $smilies_table,
     
    107110// get the content of definitions file
    108111$smilies_file = SMILIES_PATH.'smilies/'.$conf_smiliessupport['folder'].'/smilies.txt';
    109 if (file_exists($smilies_file)) {
     112if (file_exists($smilies_file))
     113{
    110114  $content_file = file_get_contents($smilies_file);
    111115  $template->assign(array('CONTENT_FILE' => $content_file));
Note: See TracChangeset for help on using the changeset viewer.