1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | global $conf, $template; |
---|
5 | load_language('plugin.lang', SMILIES_PATH); |
---|
6 | $conf_smiliessupport = explode("," , $conf['smiliessupport']); |
---|
7 | |
---|
8 | // Enregistrement de la configuration |
---|
9 | if (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 | $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'; |
---|
35 | |
---|
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 | } |
---|
46 | } |
---|
47 | |
---|
48 | // check if the representant exists |
---|
49 | if (!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]; |
---|
51 | } |
---|
52 | |
---|
53 | $template->assign(array( |
---|
54 | 'TEXT1_VALUE' => $conf_smiliessupport[0], |
---|
55 | 'TEXT2_VALUE' => $conf_smiliessupport[1], |
---|
56 | 'TEXT3_VALUE' => $conf_smiliessupport[2], |
---|
57 | )); |
---|
58 | |
---|
59 | // build the table of smilies |
---|
60 | include_once(SMILIES_PATH . '/smiliessupport.inc.php'); |
---|
61 | $template->assign('smiliesfiles', get_smilies($conf_smiliessupport)); |
---|
62 | |
---|
63 | // get the content of definitions file |
---|
64 | $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt'; |
---|
65 | if (file_exists($smilies_file)) { |
---|
66 | $content_file = file_get_contents($smilies_file); |
---|
67 | $template->assign(array('CONTENT_FILE' => $content_file)); |
---|
68 | } |
---|
69 | |
---|
70 | $template->assign('SMILIES_PATH', SMILIES_PATH); |
---|
71 | $template->set_filename('smiliessupport_conf', dirname(__FILE__).'/template/smiliessupport_admin.tpl'); |
---|
72 | $template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf'); |
---|
73 | |
---|
74 | ?> |
---|