source: subversion/trunk/roundcubemail/program/steps/settings/edit_identity.inc @ 319

Last change on this file since 319 was 319, checked in by thomasb, 7 years ago

Fixed some XSS and SQL injection issues

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/settings/edit_identity.inc                              |
6 |                                                                       |
7 | This file is part of the RoundCube Webmail client                     |
8 | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Show edit form for a identity record or to add a new one            |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22if (($_GET['_iid'] || $_POST['_iid']) && $_action=='edit-identity')
23  {
24  $DB->query("SELECT * FROM ".get_table_name('identities')."
25              WHERE  identity_id=?
26              AND    user_id=?
27              AND    del<>1",
28              get_input_value('_iid', RCUBE_INPUT_GPC),
29              $_SESSION['user_id']);
30 
31  $IDENTITY_RECORD = $DB->fetch_assoc();
32 
33  if (is_array($IDENTITY_RECORD))
34    $OUTPUT->add_script(sprintf("%s.set_env('iid', '%s');", $JS_OBJECT_NAME, $IDENTITY_RECORD['identity_id']));
35   
36  $PAGE_TITLE = rcube_label('edititem');
37  }
38else
39  $PAGE_TITLE = rcube_label('newitem');
40
41
42
43function rcube_identity_form($attrib)
44  {
45  global $IDENTITY_RECORD, $JS_OBJECT_NAME;
46
47  if (!$IDENTITY_RECORD && $GLOBALS['_action']!='add-identity')
48    return rcube_label('notfound');
49
50  // add some labels to client
51  rcube_add_label('noemailwarning');
52  rcube_add_label('nonamewarning');
53
54
55  list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id']));
56  unset($attrib['form']);
57
58
59  // list of available cols
60  $a_show_cols = array('name'         => array('type' => 'text'),
61                       'email'        => array('type' => 'text'),
62                       'organization' => array('type' => 'text'),
63                       'reply-to'     => array('type' => 'text', 'label' => 'replyto'),
64                       'bcc'          => array('type' => 'text'),
65                       'signature'        => array('type' => 'textarea'),
66                       'standard'     => array('type' => 'checkbox', 'label' => 'setdefault'));
67
68
69  // a specific part is requested
70  if ($attrib['part'])
71    {
72    $colprop = $a_show_cols[$attrib['part']];
73    if (is_array($colprop))
74      {
75      $out = $form_start;
76      $out .= rcmail_get_edit_field($attrib['part'], $IDENTITY_RECORD[$attrib['part']], $attrib, $colprop['type']);
77      return $out;
78      }
79    else
80      return '';
81    }
82
83
84  // return the complete edit form as table
85  $out = "$form_start<table>\n\n";
86
87  foreach ($a_show_cols as $col => $colprop)
88    {
89    $attrib['id'] = 'rcmfd_'.$col;
90    $label = strlen($colprop['label']) ? $colprop['label'] : $col;
91    $value = rcmail_get_edit_field($col, $IDENTITY_RECORD[$col], $attrib, $colprop['type']);
92
93    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
94                    $attrib['id'],
95                    rep_specialchars_output(rcube_label($label)),
96                    $value);
97    }
98
99  $out .= "\n</table>$form_end";
100
101  return $out; 
102  }
103
104
105
106if ($_action=='add-identity' && template_exists('addidentity'))
107  parse_template('addidentity');
108
109parse_template('editidentity');
110?>
Note: See TracBrowser for help on using the repository browser.