source: extensions/SmiliesSupport/admin.php @ 9764

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

[extentions] Smilies Support

  • active for admin in the comments page
  • two new sets of smilies
  • help tip on admin page (needs translation)
File size: 2.1 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                $not_save_file = true;
14        }
15       
16        $conf_smiliessupport = array(
17                isset($_POST['text1']) ? $_POST['text1'] : 'plugins/SmiliesSupport/smilies',
18                isset($_POST['text2']) ? $_POST['text2'] : '5',
19                isset($_POST['text3']) ? $_POST['text3'] : 'sourire.gif',
20        );
21       
22        if (empty($_POST['text'])) $_POST['text'] = ':)         sourire.gif';
23               
24    $new_value_smiliessupport = implode (",", $conf_smiliessupport);
25    $query = 'UPDATE ' . CONFIG_TABLE . '
26                SET value="' . $new_value_smiliessupport . '"
27                WHERE param="smiliessupport"';
28    pwg_query($query);
29   
30        if (!isset($not_save_file)) {
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                        $page['infos'][] = l10n('Information data registered in database');
39                } else {
40                        $page['errors'][] = l10n('File/directory read error').' &nbsp; '.$smilies_file;
41                }
42        }
43}
44
45$template->assign(array('TEXT1_VALUE' => $conf_smiliessupport[0]));
46$template->assign(array('TEXT2_VALUE' => $conf_smiliessupport[1]));
47$template->assign(array('TEXT3_VALUE' => $conf_smiliessupport[2]));
48
49include_once(SMILIES_PATH . '/smiliessupport.inc.php');
50$template->assign('SMILIESSUPPORT_PAGE', SmiliesTable($conf_smiliessupport));
51
52$smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';
53$content_file = null;
54
55if (file_exists($smilies_file)) {
56        $content_file = file_get_contents($smilies_file);
57        $template->assign(array('CONTENT_FILE' => $content_file));
58}
59       
60$template->set_filename('smiliessupport_conf', dirname(__FILE__).'/smiliessupport_admin.tpl');
61$template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf');
62
63?>
Note: See TracBrowser for help on using the repository browser.