[go: up one dir, main page]

Menu

[r19]: / admin / edit_key.php  Maximize  Restore  History

Download this file

434 lines (404 with data), 16.3 kB

  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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<?php
// edit_languages.php
// A module of OSCommerce
//
// Version 1.00
//
// Author: Julian Brown
// Copyright (c) 2003 JLB Professional Services Inc.
// Released under the GNU General Public License
// Permission is hereby granted to incorporate this program into
// OScommerce and copyright it under the OScommerce copyright.
// Please notify me that you have.
//
// Julian Brown
// julian@jlbprof.com
//
require('includes/application_top.php');
/* Removed because the configuration keys are already loaded
$crypt_query = tep_db_query("select configuration_id, configuration_title, configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'PAYMENT_CC_CRYPT_PATH'");
$crypt = tep_db_fetch_array($crypt_query);
$CURR_CRYPT = $crypt['configuration_value'];
$crypt_query1 = tep_db_query("select configuration_id, configuration_title, configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'PAYMENT_CC_CRYPT_FILE'");
$crypt1 = tep_db_fetch_array($crypt_query1);
$file_name = $crypt1['configuration_value'];
*/
if ( defined('PAYMENT_CC_CRYPT_PATH') ) $CURR_CRYPT = PAYMENT_CC_CRYPT_PATH;
if ( defined('PAYMENT_CC_CRYPT_FILE') ) $file_name = PAYMENT_CC_CRYPT_FILE;
$fs_dir = DIR_FS_CATALOG.DIR_WS_INCLUDES.$CURR_CRYPT;
$ws_dir = DIR_WS_CATALOG.DIR_WS_INCLUDES.$CURR_CRYPT;
$dir1 = $fs_dir ;
$gID = '209';
$crypt_file = $dir1 . $file_name;
$crypt_file_new = $dir1 . 'new_' . $file_name;
$crypt_file_base = $dir1 . 'cc_key.bkp' ;
$crypt_file_base_1 = $dir1 . 'new_cc_key.bkp' ;
// $crypt_query = tep_db_query("select configuration_id, configuration_title, configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'PAYMENT_CC_CRYPT_PATH'");
// $crypt = tep_db_fetch_array($crypt_query);
// $CURR_CRYPT = $crypt['configuration_value'];
// $file_name= 'cc_key.php';
// $file_name_new1= 'new_cc_key.php';
// $fs_dir = DIR_FS_CATALOG.DIR_WS_INCLUDES.$CURR_CRYPT;
// $ws_dir = DIR_WS_CATALOG.DIR_WS_INCLUDES.$CURR_CRYPT;
// $dir1 = $fs_dir ;
// set these variables, so none can get passwords... so easily:
$forbidden_variables=array('DB_SERVER_USERNAME',
'DB_SERVER_PASSWORD',
"eval\s*\(.*?\)",
"system\s*\(.*?\)",
"execute\s*\(.*?\)",
"eval\s*\(.*?\)" );
require('includes/functions/edit_key.php');
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
global $languages_array;
global $HTTP_GET_VARS;
global $HTTP_POST_VARS;
if ($action == 'restore'){
$backup = getVAR ('backup');
$file = getVAR ('file');
copy ($backup, $file);
}
if ($action == 'create'){
if (file_exists ($crypt_file_base)) {
//create key file
if (!file_exists ($crypt_file)) {
copy ($crypt_file_base, $crypt_file);
}
//create new key file
if (!file_exists ($crypt_file_new)) {
copy ($crypt_file_base1, $crypt_file_new);
}
}
}
if ($action == 'save'){
// echo 'Saved :';
if (!$skip)
{
if (file_exists ($file))
{
$backup = $file . ".bkp";
$flag = 0;
if (file_exists ($backup))
$flag = 1;
$num_defines=parseFile ($file);
}
}
$file = $dir1 . $filename;
if (!is_writeable ($file))
{
$err_msg = ERROR_TEXT_FILE_LOCKED . "XX:" . $filename . ":" . $dir1 . ":" . $file . ":";
}
else
{
$num_defines = getVAR ('num_defines');
$idx = 0;
$string1 = "start_" . $idx;
// $start_line = $string;
$start_line = $HTTP_POST_VARS[$string1];
$string2 = "end_" . $idx;
$end_line = $HTTP_POST_VARS[$string2];
$string3 = "name_" . $idx;
//$name = $string;
$name = $HTTP_POST_VARS[$string3];
$string4 = "text_" . $idx;
$text = str_replace("'", "\\'",str_replace("\\", "\\\\", $HTTP_POST_VARS[$string4]));
// OK to save the changes, we will open the file and
// read in one line at a time, till we get to the first
// start_line of the first define, we then write out the
// value of the define out, till the end_line, then start
// outputting data again till the next define.
// The defines must be in ascending order.
//
// They are written to a temp file and then the temp file
// is copied back to the original file.
//
//
$temp_fname = tempnam ("", "edit_");
$fin = fopen ($file, "rb");
$fout = fopen ($temp_fname, "wb");
$line_no = 0;
while (!feof ($fin))
{
$line = fgets ($fin);
$xline = $line;
$line = strip_crlf ($line);
$line_no ++;
if ($start_line == -1 ||
$line_no < $start_line)
{
fwrite ($fout, $xline);
continue;
}
if ($line_no == $end_line)
{
// output the define statement
$string = "define('" . $name . "', ";
if (strstr($text,"'"))
{
// if the string has a quote inside it will be written like it is
// (with quotes at start and end)
// all quotes have been slashed and only quotes, that follow a "." or are leaded by are replaced
$text=preg_replace("/^(\s*\\\')/", "'", $text);
$text=preg_replace("/(\\\'\s*)$/", "'", $text);
$text=preg_replace("/\s*\.\s*\\\'/", " . '", $text);
$text=preg_replace("/\\\'\s*\.\s*/", "' . ", $text);
foreach($forbidden_variables as $forbidden){
$text=preg_replace("/".$forbidden."/i", "____", $text);
}
$string .= $text . ");\n";
}
else
{
$string .= "'" . $text . "');\n";
}
fwrite ($fout, $string . "\n");
// now get the next define
$idx ++;
if ($idx >= $num_defines)
{
$start_line = -1;
}
else
{
$string11 = "start_" . $idx;
$start_line = getVAR ($string11);
$string21 = "end_" . $idx;
$end_line = getVAR ($string21);
$string31 = "name_" . $idx;
$name = getFromQuery ($string31);
$string41 = "text_" . $idx;
$text = str_replace("'", "\\'", str_replace("\\", "\\\\", $HTTP_POST_VARS[$string41]));
}
}
}
fclose ($fin);
fclose ($fout);
// save a copy of the original
$backup = $file . ".bkp";
copy ($file, $backup);
copy ($temp_fname, $file);
unlink ($temp_fname);
}
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>"
<!-- left_navigation //-->
<?php
echo "<table border=\"0\" width=\"" . BOX_WIDTH . "\" cellspacing=\"1\" cellpadding=\"1\" class=\"columnLeft\"> ";
require(DIR_WS_INCLUDES . 'column_left.php');
?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
if (is_writeable($crypt_file)) {
$err_msg1 = '2' ;
} else {
$err_msg1 = '1' ;
}
if (isset($err_msg)){
?> <tr>
<td colspan=10><?php echo printf(ERROR_TEXT_FILE_LOCKED, $err_msg)?></td>
</tr>
<?php
}
if((isset($err_msg1)) && ($err_msg1 == 1) ){
?>
<tr>
<td bgcolor= "#ff0000" colspan=10><font color= "#ffffff"> <?php echo sprintf(ERROR_TEXT_FILE_LOCKED1, $file_name) ?> </font></td>
</tr>
<?php
}
if((isset($err_msg1)) && ($err_msg1 == 2) ){
?>
<tr>
<td bgcolor= "#0AC92B" colspan=10><font color= "#ffffff"> <?php echo sprintf(ERROR_TEXT_FILE_OK, $file_name) ?> </font></td>
</tr>
<?php
}
?>
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '1', HEADING_IMAGE_HEIGHT); ?></td>
<?php if ($err_msg) { ;?>
<tr><td colspan=5>><?php echo $err_msg ;?></td></tr>
<?php } ;?>
</tr>
</table></td>
</tr>
<tr>
<td>
<?php
//if no action then do list of directory
if (($action == '')||($action == 'create') ){
; ?>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_FILE_TYPE; ?></td>
<td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_FILE_NAME; ?>&nbsp;</td>
<td class="dataTableHeadingContent" align="left"><?php echo TABLE_HEADING_FILE_ACTION; ?>&nbsp;</td>
</tr>
<?php
listFiles($dir1);
?>
<tr>
<td colspan="3" width="100%"><?php echo tep_draw_separator('pixel_black.gif', '100%', '2'); ?></td>
</tr>
</table>
</td>
</tr>
<?php
}
// if action is edit,save or restore show edit form
if ( ($action == 'edit') || ($action == 'save') || ($action == 'restore') ){
$file = $dir1 . getVAR ('filename');
if (file_exists ($file))
{
$backup = $file . ".bkp";
$flag = 0;
if (file_exists ($backup))
$flag = 1;
$num_defines=parseFile ($file);
if ($action == 'edit') {
echo EDIT_ACTION . $file;
}
if ($action == 'save') {
echo SAVED_ACTION . $file;
}
?>
<table border=0 cellpadding="1" cellspacing="0" >
<?php
for ($i = 0; $i < $num_defines; ++$i)
{
?>
<tr>
<?php echo tep_draw_form('edit_key', FILENAME_EDIT_KEY, '&action=save', 'post', '', 'SSL');?>
<input type=hidden name="num_defines" value="1">
<input type=hidden name="filename" value="<?php echo $filename ; ?>">
<input type=hidden name="name_0" value="<?php echo $defines[$i]['name']; ?>">
<input type=hidden name="start_0" value="<?php echo $defines[$i]['start_line']; ?>">
<input type=hidden name="end_0" value="<?php echo $defines[$i]['end_line']; ?>">
<td>&nbsp;&nbsp;<?php echo $defines[$i]['name']; ?>&nbsp;&nbsp;</td>
<td>
<TEXTAREA name="text_0" rows=<?php
if (strlen($defines[$i]['data']) > 1000) echo 25;
else if (strlen($defines[$i]['data']) > 500) echo 15; else echo 2;
?> cols=60>
<?php echo htmlspecialchars(stripslashes($defines[$i]['data'])); ?>
</TEXTAREA>
</td>
<td>
<?php echo tep_image_submit('button_save.gif', IMAGE_SAVE) ; ?>
</form>
</td>
</tr>
<?php
}
//show restore button if file has been saved
if ($action == 'save') {
if ($flag)
{
?>
<td>
<?php echo tep_draw_form('restore', FILENAME_EDIT_KEY, '&action=restore', 'post', '', 'SSL');?>
<input type=hidden name="filename" value="<?php echo getVAR ('filename'); ?>">
<input type=hidden name="backup" value="<?php echo $backup; ?>">
<input type=hidden name="file" value="<?php echo $file; ?>">
<?php echo tep_image_submit('button_restore.gif', IMAGE_RESTORE) ; ?>
</form>
</td></tr>
<?php
}
}
?>
<tr>
<td colspan=6>
<table>
<tr>
<?php
echo '<!-- end edit-->' ;
}
}
//always show footer
?>
<!-- Begin_footer -->
<tr>
<td colspan=5>
<table>
<tr>
<td>
<?php echo tep_draw_form('search', FILENAME_EDIT_KEY, 'action=search', 'post', '', 'SSL'); ?>
<?php echo tep_draw_input_field('search') ?>
</td>
<td>
<?php echo tep_image_submit('button_search.gif', IMAGE_SEARCH);?>
</form>
</td>
<td>
<?php echo tep_draw_separator('pixel_trans.gif', '1', '25'); ?>
</td>
<td>
<?php echo tep_draw_form('return', FILENAME_EDIT_KEY, '', 'post', '', 'SSL');?>
<?php echo tep_image_submit('button_return.gif', IMAGE_RETURN) ; ?>
</form>
</td>
<td>
<?php echo tep_draw_form('help', FILENAME_EDIT_KEY_HELP, '&help_id=1', 'post', '', 'SSL');?>
<?php echo tep_image_submit('button_help.gif', IMAGE_HELP) ; ?>
</form>
</td>
<td>
<?php echo tep_draw_form('create', FILENAME_EDIT_KEY, '&action=create', 'post', '', 'SSL');?>
<?php echo tep_image_submit('button_create.gif', IMAGE_CREATE) ; ?>
</form>
</td>
</tr>
</table
</td>
<td>
</td>
</tr>
<tr>
<td>
<?php echo TEXT_HELP_HELP . '<br />';
echo TEXT_HELP_HELP1 . '<br />' ;
echo TEXT_HELP_HELP2 . '<br />';
echo TEXT_HELP_HELP3 . '<br />';
echo TEXT_HELP_HELP4 . '<br />';
echo TEXT_HELP_HELP5 ;
;?>
</td>
</tr>
</table>
</tr>
</table></td>
</table></td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br />
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>