This repository has been archived by the owner on May 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditdef.php
163 lines (136 loc) · 5.41 KB
/
editdef.php
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
153
154
155
156
157
158
159
160
161
162
163
<?php
/*
This file is a part of DAlbum. Copyright (c) 2003 Alexei Shamov, DeltaX Inc.
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; either version 2 of the License, or
(at your option) any later version.
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("DALBUM_ROOT"))
define("DALBUM_ROOT",".");
if (!defined("DALBUM_BROWSERROOT"))
define("DALBUM_BROWSERROOT","");
define("DALBUM_EDITDEF_PAGE","1");
require_once(DALBUM_ROOT."/include/md5crypt.php");
require_once(DALBUM_ROOT . "/include/functions.php");
require_once(file_exists(DALBUM_ROOT."/config/config.php")?DALBUM_ROOT."/config/config.php":DALBUM_ROOT."/include/config.php");
require_once(DALBUM_ROOT."/include/conffix.php");
require_once(DALBUM_ROOT."/include/createhta.php");
require_once(DALBUM_ROOT."/include/createini.php");
require_once(DALBUM_ROOT."/include/album.php");
// Include custom functions
if (file_exists(DALBUM_ROOT . "/config/custom.php"))
include_once(DALBUM_ROOT . "/config/custom.php");
elseif (file_exists(DALBUM_ROOT . "/include/custom.php"))
include_once(DALBUM_ROOT . "/include/custom.php");
if ($g_bGZip)
ob_start("ob_gzhandler");
// Start session and get current user name
$sUserName=StartSessionAndGetUserName('private; must-revalidate');
if (function_exists('everypageCallback'))
everypageCallback($sUserName);
function CheckFilename($filelocation, &$albRoot)
{
global $g_sAlbumdef;
if (basename($filelocation)!=$g_sAlbumdef ||
strstr($filelocation,".."))
die("Security violation");
$alb=$albRoot->FindAlbum(dirname_ex($filelocation));
if (empty($alb) || $alb->m_bPrivate)
die("Security violation");
return true;
}
if (isset($_POST['url']))
$url=$_POST['url'];
if (empty($url) && isset($_GET['url']))
$url=@$_GET['url'];
if (empty($url))
$url=base64_encode(translateRef("index.php"));
$c=parse_url(base64_decode($url));
$sTarget=basename($c['path'] );
if (!empty($c['query']))
$sTarget.='?' . $c['query'];
if (!isAdminMode($sUserName) || isset($_POST['cancel']))
{
dalbum_relocate($sTarget);
return;
}
$albRoot=&CAlbum::CreateFromArchive();
$albRoot->SetAccess($sUserName);
if (isset($_POST['newcontent']))
{
$newcontent=$_POST['newcontent'];
$filelocation = $_POST['filename'];
CheckFilename($filelocation,$albRoot);
if ($g_Demo || @save_file(absfname($filelocation),$newcontent))
{
RefreshAlbumAndSaveTree(dirname_ex($filelocation));
dalbum_relocate($sTarget);
return;
}
else
{
reportError(strtr($lang['editSaveError'],array('#filename#'=>quotehtml($newfname))));
return;
}
}
if (!isset($_GET['filename']))
die("Invalid arguments!");
$filelocation=$_GET['filename'];
CheckFilename($filelocation,$albRoot);
$content = "";
$newfile = fopen(absfname($filelocation),"r");
$warning="";
if (!$newfile)
{
$warning= $lang['editNewFileMessage'];
}
else
{
$content = quotehtml(fread($newfile, filesize(absfname($filelocation))));
fclose($newfile);
}
global $g_sCharset;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html>
<head>
<title><?php print strtr($lang['editTitle'],array('#filename#'=>quotehtml($filelocation))); ?></title>
<meta http-equiv="pragma" content="nocache">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script src="<?php print DALBUM_BROWSERROOT . 'dalbum.js'; ?>" type="text/javascript"></script>
<link rel="stylesheet" href="<?php print $g_sStylesheet; ?>" type="text/css">
<link rel="stylesheet" href="<?php print $g_sCustomStylesheet; ?>" type="text/css" >
<meta http-equiv="Content-Type" content="text/html; charset=<?php print $g_sCharset;?>">
</head>
<body onload="javascript: dalbum_firstFocus();" class=centered>
<form action="" method="POST">
<table border="0" class="dialog">
<tr>
<th><?php print quotehtml($filelocation); ?></th>
<tr>
<td>
<textarea name="newcontent" cols=80 rows=25 wrap=off><?php print "$content"; ?></textarea>
<input type='hidden' name='filename' value='<?php print quoteurl($filelocation); ?>'>
<input type='hidden' name='url' value='<?php print quoteurl($url); ?>'>
</td>
</tr>
<tr>
<td style="text-align:right;">
<input type="submit" name="save" value="<?php print $lang['editSaveBtn']; ?>">
<input type="submit" name="cancel" value="<?php print $lang['editCancelBtn']; ?>">
</td>
</tr>
</table>
</form>
<div><a href='<?php print translateRef("index.php");?>' class='pageLink' ><?php print $lang['mainPage'];?></a></div>
</body>
</html>
<?php if ($g_bGZip) ob_end_flush(); ?>