source: extensions/SmiliesSupport/admin.php @ 11344

Last change on this file since 11344 was 10986, checked in by mistic100, 14 years ago

code cleanup

File size: 2.4 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4global $conf, $template;
5load_language('plugin.lang', SMILIES_PATH);
6$conf_smiliessupport = explode("," , $conf['smiliessupport']);
7
8// Enregistrement de la configuration
9if (isset($_POST['submit']))
10{
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';     
32
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  }
41}
42
43// check if the representant exists
44if (!file_exists(PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2])) {
45  array_push($page['errors'], l10n('File/directory read error').' : '.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2]);
46}
47
48$template->assign(array(
49  'TEXT1_VALUE' => $conf_smiliessupport[0],
50  'TEXT2_VALUE' => $conf_smiliessupport[1],
51  'TEXT3_VALUE' => $conf_smiliessupport[2],
52));
53
54// build the table of smilies
55include_once(SMILIES_PATH . '/smiliessupport.inc.php');
56$template->assign('smiliesfiles', get_smilies($conf_smiliessupport));
57
58// get the content of definitions file
59$smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';
60if (file_exists($smilies_file)) {
61  $content_file = file_get_contents($smilies_file);
62  $template->assign(array('CONTENT_FILE' => $content_file));
63}
64 
65$template->assign('SMILIES_PATH', SMILIES_PATH);
66$template->set_filename('smiliessupport_conf', dirname(__FILE__).'/template/smiliessupport_admin.tpl');
67$template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf');
68
69?>
Note: See TracBrowser for help on using the repository browser.