1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
include_once(LOCALEDIT_PATH.'include/functions.inc.php');
load_language('plugin.lang', LOCALEDIT_PATH);
$my_base_url = get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__));
// +-----------------------------------------------------------------------+
// | Tabssheet
// +-----------------------------------------------------------------------+
if (empty($conf['LocalFilesEditor_tabs']))
{
$conf['LocalFilesEditor_tabs'] = array('localconf', 'css', 'tpl', 'lang', 'plug');
}
$page['tab'] = isset($_GET['tab']) ? $_GET['tab'] : $conf['LocalFilesEditor_tabs'][0];
if (!in_array($page['tab'], $conf['LocalFilesEditor_tabs'])) die('Hacking attempt!');
$tabsheet = new tabsheet();
foreach ($conf['LocalFilesEditor_tabs'] as $tab)
{
$tabsheet->add($tab, l10n('locfiledit_onglet_'.$tab), $my_base_url.'-'.$tab);
}
$tabsheet->select($page['tab']);
$tabsheet->assign();
include_once(LOCALEDIT_PATH.'include/'.$page['tab'].'.inc.php');
// +-----------------------------------------------------------------------+
// | Load backup file
// +-----------------------------------------------------------------------+
if (isset($_POST['restore']))
{
$content_file = file_get_contents(get_bak_file($edited_file));
array_push($page['infos'],
l10n('locfiledit_bak_loaded1'),
l10n('locfiledit_bak_loaded2'));
}
// +-----------------------------------------------------------------------+
// | Save file
// +-----------------------------------------------------------------------+
if (isset($_POST['submit']))
{
check_pwg_token();
if (!is_webmaster())
{
array_push($page['errors'], l10n('locfiledit_webmaster_only'));
}
else
{
$content_file = stripslashes($_POST['text']);
if (get_extension($edited_file) == 'php')
{
$content_file = eval_syntax($content_file);
}
if ($content_file === false)
{
array_push($page['errors'], l10n('locfiledit_syntax_error'));
}
else
{
if ($page['tab'] == 'plug' and !is_dir(PHPWG_PLUGINS_PATH . 'PersonalPlugin'))
{
@mkdir(PHPWG_PLUGINS_PATH . "PersonalPlugin");
}
if (file_exists($edited_file))
{
@copy($edited_file, get_bak_file($edited_file));
array_push($page['infos'], sprintf(l10n('locfiledit_saved_bak'), substr(get_bak_file($edited_file), 2)));
}
if ($file = @fopen($edited_file , "w"))
{
@fwrite($file , $content_file);
@fclose($file);
array_unshift($page['infos'], l10n('locfiledit_save_config'));
$template->delete_compiled_templates();
}
else
{
array_push($page['errors'], l10n('locfiledit_cant_save'));
}
}
}
}
// +-----------------------------------------------------------------------+
// | template initialization
// +-----------------------------------------------------------------------+
$template->set_filenames(array(
'plugin_admin_content' => dirname(__FILE__) . '/template/admin.tpl'));
if (!empty($edited_file))
{
if (!empty($page['errors']))
{
$content_file = stripslashes($_POST['text']);
}
$template->assign('zone_edit',
array(
'EDITED_FILE' => $edited_file,
'CONTENT_FILE' => htmlspecialchars($content_file),
'FILE_NAME' => trim($edited_file, './\\')
)
);
if (file_exists(get_bak_file($edited_file)))
{
$template->assign('restore', true);
}
if (file_exists($edited_file))
{
$template->assign('restore_infos', true);
}
}
$template->assign(array(
'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=plugin-LocalFilesEditor-'.$page['tab'],
'LOCALEDIT_PATH' => LOCALEDIT_PATH,
'PWG_TOKEN' => get_pwg_token(),
'CODEMIRROR_MODE' => @$codemirror_mode
)
);
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
?>
|