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 | if (!isset($_POST['text1'])) $_POST['text1'] = 'plugins/SmiliesSupport/smilies'; |
---|
12 | if (!isset($_POST['text2'])) $_POST['text2'] = '5'; |
---|
13 | if (!isset($_POST['text3'])) $_POST['text3'] = 'sourire.gif'; |
---|
14 | |
---|
15 | $conf_smiliessupport = array( |
---|
16 | $_POST['text1'], |
---|
17 | $_POST['text2'], |
---|
18 | $_POST['text3'] |
---|
19 | ); |
---|
20 | |
---|
21 | $new_value_smiliessupport = implode ("," , $conf_smiliessupport); |
---|
22 | $query = 'UPDATE ' . CONFIG_TABLE . ' |
---|
23 | SET value="' . $new_value_smiliessupport . '" |
---|
24 | WHERE param="smiliessupport"'; |
---|
25 | pwg_query($query); |
---|
26 | |
---|
27 | $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt'; |
---|
28 | |
---|
29 | if (file_exists($smilies_file)) |
---|
30 | { |
---|
31 | if (@copy($smilies_file , get_filename_wo_extension($smilies_file).'.bak')) |
---|
32 | { |
---|
33 | $file = @fopen($smilies_file , "w"); |
---|
34 | fwrite($file , stripslashes($content_file = $_POST['text'])); |
---|
35 | fclose($file); |
---|
36 | array_push($page['infos'], l10n('Configuration saved.')); |
---|
37 | } |
---|
38 | else |
---|
39 | { |
---|
40 | array_push($page['errors'], l10n('Configuration not saved. (copy : '.$smilies_file.' to '.get_filename_wo_extension($smilies_file).'.bak').')' ); |
---|
41 | } |
---|
42 | } |
---|
43 | else |
---|
44 | { |
---|
45 | array_push($page['errors'], l10n('Configuration not saved. (file exists : '.$smilies_file.')' )); |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | $template->assign(array('TEXT1_VALUE' => $conf_smiliessupport[0])); |
---|
50 | $template->assign(array('TEXT2_VALUE' => $conf_smiliessupport[1])); |
---|
51 | $template->assign(array('TEXT3_VALUE' => $conf_smiliessupport[2])); |
---|
52 | |
---|
53 | include_once(SMILIES_PATH . '/smiliessupport.inc.php'); |
---|
54 | $template->assign('SMILIESSUPPORT_PAGE', SmiliesTable($conf_smiliessupport)); |
---|
55 | |
---|
56 | $smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt'; |
---|
57 | $content_file = ''; |
---|
58 | |
---|
59 | if (file_exists($smilies_file)) |
---|
60 | { |
---|
61 | $content_file = file_get_contents($smilies_file); |
---|
62 | $template->assign(array('CONTENT_FILE' =>$content_file )); |
---|
63 | } |
---|
64 | |
---|
65 | $template->set_filename('smiliessupport_conf', dirname(__FILE__).'/smiliessupport_admin.tpl'); |
---|
66 | $template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf'); |
---|
67 | |
---|
68 | ?> |
---|