Ignore:
Timestamp:
May 22, 2011, 12:48:18 PM (14 years ago)
Author:
mistic100
Message:

code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmiliesSupport/admin.php

    r9966 r10986  
    99if (isset($_POST['submit']))
    1010{
    11         // the smilies.txt file is not saved if the directory is changed
    12         if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0])
    13         {
    14                 $not_save_file = true;
    15         }
    16        
    17         // new configuration
    18         $conf_smiliessupport = array(
    19                 isset($_POST['text1']) ? $_POST['text1'] : 'plugins/SmiliesSupport/smilies_1',
    20                 isset($_POST['text2']) ? $_POST['text2'] : '6',
    21                 isset($_POST['text3']) ? $_POST['text3'] : 'smile.png',
    22         );
    23         if (empty($_POST['text'])) $_POST['text'] = ':)         smile.png';
    24                
    25     $new_value_smiliessupport = implode(",", $conf_smiliessupport);
    26     $query = "UPDATE " . CONFIG_TABLE . "
    27                 SET value='" . $new_value_smiliessupport . "'
    28                 WHERE param='smiliessupport'";
    29     pwg_query($query);
    30        
    31         // new definitions file
    32         if (!isset($not_save_file))
    33         {
    34                 $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';     
     11  // the smilies.txt file is not saved if the directory is changed
     12  if (isset($_POST['text1']) AND $_POST['text1'] != $conf_smiliessupport[0])
     13  {
     14    $not_save_file = true;
     15  }
     16 
     17  // new configuration
     18  $conf_smiliessupport = array(
     19    isset($_POST['text1']) ? $_POST['text1'] : 'plugins/SmiliesSupport/smilies_1',
     20    isset($_POST['text2']) ? $_POST['text2'] : '6',
     21    isset($_POST['text3']) ? $_POST['text3'] : 'smile.png',
     22  );
     23  if (empty($_POST['text'])) $_POST['text'] = ':)    smile.png';
     24   
     25  conf_update_param('smiliessupport', implode(",", $conf_smiliessupport));
     26  array_push($page['infos'], l10n('Information data registered in database'));
     27 
     28  // new definitions file
     29  if (!isset($not_save_file))
     30  {
     31    $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';     
    3532
    36                 if (file_exists($smilies_file)) {
    37                         @copy($smilies_file, get_filename_wo_extension($smilies_file).'.bak');
    38                 }
    39                
    40                 if (@file_put_contents($smilies_file, stripslashes($_POST['text']))) { 
    41                         $page['infos'][] = l10n('Information data registered in database');
    42                 } else {
    43                         $page['errors'][] = l10n('File/directory read error').' : '.$smilies_file;
    44                 }
    45         }
     33    if (file_exists($smilies_file)) {
     34      @copy($smilies_file, get_filename_wo_extension($smilies_file).'.bak');
     35    }
     36   
     37    if (@!file_put_contents($smilies_file, stripslashes($_POST['text']))) { 
     38      array_push($page['errors'], l10n('File/directory read error').' : '.$smilies_file);
     39    }
     40  }
    4641}
    4742
    4843// check if the representant exists
    4944if (!file_exists(PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2])) {
    50         $page['errors'][] = l10n('File/directory read error').' : '.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2];
     45  array_push($page['errors'], l10n('File/directory read error').' : '.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2]);
    5146}
    5247
    5348$template->assign(array(
    54         'TEXT1_VALUE' => $conf_smiliessupport[0],
    55         'TEXT2_VALUE' => $conf_smiliessupport[1],
    56         'TEXT3_VALUE' => $conf_smiliessupport[2],
     49  'TEXT1_VALUE' => $conf_smiliessupport[0],
     50  'TEXT2_VALUE' => $conf_smiliessupport[1],
     51  'TEXT3_VALUE' => $conf_smiliessupport[2],
    5752));
    5853
     
    6459$smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';
    6560if (file_exists($smilies_file)) {
    66         $content_file = file_get_contents($smilies_file);
    67         $template->assign(array('CONTENT_FILE' => $content_file));
     61  $content_file = file_get_contents($smilies_file);
     62  $template->assign(array('CONTENT_FILE' => $content_file));
    6863}
    69        
     64 
    7065$template->assign('SMILIES_PATH', SMILIES_PATH);
    7166$template->set_filename('smiliessupport_conf', dirname(__FILE__).'/template/smiliessupport_admin.tpl');
Note: See TracChangeset for help on using the changeset viewer.