1 | <?php |
---|
2 | defined('SMILIES_ID') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | include_once(SMILIES_PATH.'include/functions.inc.php'); |
---|
5 | |
---|
6 | global $conf, $template; |
---|
7 | |
---|
8 | // get available sets |
---|
9 | $sets = array(); |
---|
10 | $handle = opendir(SMILIES_DIR); |
---|
11 | while ($folder = readdir($handle)) |
---|
12 | { |
---|
13 | if ($folder != '.' && $folder != '..' && is_dir(SMILIES_DIR.$folder)) |
---|
14 | { |
---|
15 | if (file_exists(SMILIES_DIR . $folder . '/representant.txt')) |
---|
16 | { |
---|
17 | $sets[$folder] = file_get_contents(SMILIES_DIR . $folder . '/representant.txt'); |
---|
18 | } |
---|
19 | else |
---|
20 | { |
---|
21 | $sets[$folder] = get_first_file(SMILIES_DIR . $folder, $conf['smiliessupport_ext']); |
---|
22 | } |
---|
23 | } |
---|
24 | } |
---|
25 | closedir($handle); |
---|
26 | |
---|
27 | |
---|
28 | // save configuration |
---|
29 | if (isset($_POST['submit'])) |
---|
30 | { |
---|
31 | // new configuration |
---|
32 | $conf['smiliessupport'] = array( |
---|
33 | 'folder' => $_POST['folder'], |
---|
34 | 'cols' => preg_match('#^[0-9]+$#', $_POST['cols']) ? $_POST['cols'] : 6, |
---|
35 | 'representant' => $sets[ $_POST['folder'] ], |
---|
36 | ); |
---|
37 | |
---|
38 | conf_update_param('smiliessupport', $conf['smiliessupport']); |
---|
39 | $page['infos'][] = l10n('Information data registered in database'); |
---|
40 | |
---|
41 | // shortcuts file |
---|
42 | $used = array(); |
---|
43 | $content = null; |
---|
44 | |
---|
45 | foreach ($_POST['shortcuts'] as $file => $data) |
---|
46 | { |
---|
47 | if (empty($data)) continue; |
---|
48 | |
---|
49 | $data = explode(',', stripslashes($data)); |
---|
50 | foreach ($data as $short) |
---|
51 | { |
---|
52 | if (array_key_exists($short, $used)) |
---|
53 | { |
---|
54 | $page['errors'][] = l10n( |
---|
55 | '<i>%s</i>, shortcut « %s » already used for <i>%s</i>', |
---|
56 | get_filename_wo_extension($file), |
---|
57 | $short, |
---|
58 | get_filename_wo_extension($used[ $short ]) |
---|
59 | ); |
---|
60 | } |
---|
61 | else |
---|
62 | { |
---|
63 | $used[ $short ] = $file; |
---|
64 | $content.= $short."\t\t".$file."\n"; |
---|
65 | } |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | if (@!file_put_contents(SMILIES_DIR.$_POST['folder'].'/smilies-custom.txt', $content)) |
---|
70 | { |
---|
71 | $page['errors'][] = l10n('File/directory read error').' : '.SMILIES_DIR.$_POST['folder'].'/smilies-custom.txt'; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | // template |
---|
77 | $template->assign(array( |
---|
78 | 'FOLDER' => $conf['smiliessupport']['folder'], |
---|
79 | 'COLS' => $conf['smiliessupport']['cols'], |
---|
80 | 'SETS' => $sets, |
---|
81 | 'SMILIES_PATH' => SMILIES_PATH, |
---|
82 | )); |
---|
83 | |
---|
84 | |
---|
85 | $template->set_filename('smiliessupport_conf', realpath(SMILIES_PATH . 'template/smiliessupport_admin.tpl')); |
---|
86 | $template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf'); |
---|