source: extensions/SmiliesSupport/admin.php @ 9816

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

[extentions] Smilies Support

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_1',
18                isset($_POST['text2']) ? $_POST['text2'] : '6',
19                isset($_POST['text3']) ? $_POST['text3'] : 'smile.png',
20        );
21       
22        if (empty($_POST['text'])) $_POST['text'] = ':)         smile.png';
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(
46        'TEXT1_VALUE' => $conf_smiliessupport[0],
47        'TEXT2_VALUE' => $conf_smiliessupport[1],
48        'TEXT3_VALUE' => $conf_smiliessupport[2],
49));
50
51include_once(SMILIES_PATH . '/smiliessupport.inc.php');
52$template->assign('SMILIESSUPPORT_PAGE', SmiliesTable($conf_smiliessupport));
53
54$smilies_file = PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/smilies.txt';
55
56if (file_exists($smilies_file)) {
57        $content_file = file_get_contents($smilies_file);
58        $template->assign(array('CONTENT_FILE' => $content_file));
59}
60       
61$template->assign('SMILIES_PATH', SMILIES_PATH);
62$template->set_filename('smiliessupport_conf', dirname(__FILE__).'/template/smiliessupport_admin.tpl');
63$template->assign_var_from_handle('ADMIN_CONTENT', 'smiliessupport_conf');
64
65?>
Note: See TracBrowser for help on using the repository browser.