~ubuntu-branches/ubuntu/oneiric/phpldapadmin/oneiric-security

« back to all changes in this revision

Viewing changes to htdocs/create_form.php

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2006-01-17 20:25:18 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060117202518-hkweiuigkttwy86t
Tags: 0.9.8-1
* New upstream release.
* debian/README.Debian: added a note about dpkg-reconfigure and debconf
  questions. (Closes: #342206)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/create_form.php,v 1.30.2.1 2005/10/09 09:07:21 wurley Exp $
 
2
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/create_form.php,v 1.31.2.5 2005/12/31 04:21:37 wurley Exp $
3
3
 
4
4
/**
5
5
 * The menu where the user chooses an RDN, Container, and Template for creating a new entry.
16
16
 */
17
17
 
18
18
require './common.php';
19
 
require TMPLDIR.'template_config.php';
20
 
 
21
 
if( $ldapserver->isReadOnly() )
22
 
        pla_error( $lang['no_updates_in_read_only_mode'] );
23
 
if( ! $ldapserver->haveAuthInfo())
24
 
        pla_error( $lang['not_enough_login_info'] );
25
 
 
26
 
$step = isset( $_REQUEST['step'] ) ? $_REQUEST['step'] : 1; // defaults to 1
 
19
 
 
20
if ($ldapserver->isReadOnly())
 
21
        pla_error(_('You cannot perform updates while server is in read-only mode'));
 
22
if (! $ldapserver->haveAuthInfo())
 
23
        pla_error(_('Not enough information to login to server. Please check your configuration.'));
 
24
 
27
25
$container = $_REQUEST['container'];
28
 
 
29
26
$server_menu_html = server_select_list($ldapserver->server_id,true);
30
27
 
31
 
include './header.php'; ?>
32
 
 
33
 
<body>
34
 
 
35
 
<h3 class="title"><?php echo $lang['createf_create_object']?></h3>
36
 
<h3 class="subtitle"><?php echo $lang['createf_choose_temp']?></h3>
37
 
<center><h3><?php echo $lang['createf_select_temp']?></h3></center>
38
 
 
39
 
<form action="creation_template.php" method="post">
40
 
        <input type="hidden" name="container" value="<?php echo htmlspecialchars( $container ); ?>" />
41
 
        <table class="create">
42
 
        <tr>
43
 
                <td class="heading"><?php echo $lang['server']; ?>:</td>
44
 
                <td><?php echo $server_menu_html; ?></td>
45
 
        </tr>
46
 
 
47
 
        <tr>
48
 
                <td class="heading"><?php echo $lang['template']; ?>:</td>
49
 
                <td>
50
 
 
51
 
                <table class="template_display">
52
 
                <tr>
53
 
                        <td>
54
 
                        <table class="templates">
55
 
 
56
 
<?php
 
28
include './header.php';
 
29
 
 
30
echo '<body>';
 
31
 
 
32
printf('<h3 class="title">%s</h3>',_('Create Object'));
 
33
printf('<h3 class="subtitle">%s</h3>',_('Choose a template'));
 
34
printf('<center><h3>%s</h3></center>',_('Select a template for the creation process'));
 
35
 
 
36
echo '<form action="template_engine.php" method="post">';
 
37
printf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($container));
 
38
 
 
39
echo '<table class="create">';
 
40
printf('<tr><td class="heading">%s:</td><td>%s</td></tr>',_('Server'),$server_menu_html);
 
41
 
 
42
echo '<tr>';
 
43
printf('<td class="heading">%s:</td>',_('Template'));
 
44
echo '<td>';
 
45
 
 
46
echo '<table class="template_display">';
 
47
echo '<tr><td>';
 
48
 
 
49
echo '<table class="templates">';
 
50
 
57
51
$i = -1;
58
52
 
59
 
        if ($config->GetValue('template_engine','enable')) {
60
 
                $template_xml = new Templates($ldapserver->server_id);
61
 
 
62
 
                if ($config->GetValue('template_engine','disable_old'))
63
 
                        $templates = $template_xml->getTemplates();
64
 
 
65
 
                else
66
 
                        $templates = array_merge($template_xml->getTemplates(),$templates);
67
 
        }
68
 
 
69
 
        # Remove non-visable templates.
70
 
        foreach ($templates as $index => $template)
71
 
                if (isset($template['visible']) && (! $template['visible']))
72
 
                        unset ($templates[$index]);
 
53
$template_xml = new Templates($ldapserver->server_id);
 
54
$templates = $template_xml->_template;
 
55
 
 
56
# Remove non-visable templates.
 
57
foreach ($templates as $index => $template)
 
58
        if (isset($template['visible']) && (! $template['visible']))
 
59
                unset ($templates[$index]);
73
60
 
74
61
$templates['custom']['title'] = 'Custom';
75
62
$templates['custom']['icon'] = 'images/object.png';
76
63
 
77
 
$count = count( $templates );
78
 
foreach( $templates as $name => $template ) {
 
64
$count = count($templates);
 
65
foreach ($templates as $name => $template) {
79
66
        $i++;
80
67
 
81
68
        # If the template doesnt have a title, we'll use the desc field.
82
69
        $template['desc'] = isset($template['title']) ? $template['title'] : $template['desc'];
83
70
 
84
71
        # Balance the columns properly
85
 
        if( ( count( $templates ) % 2 == 0 && $i == intval( $count / 2 ) ) ||
86
 
                ( count( $templates ) % 2 == 1 && $i == intval( $count / 2 ) + 1 ) )
 
72
        if ((count($templates) % 2 == 0 && $i == intval($count / 2)) ||
 
73
                (count($templates) % 2 == 1 && $i == intval($count / 2) + 1))
87
74
 
88
 
                echo "</table></td><td><table class=\"templates\">";
 
75
                echo '</table></td><td><table class="templates">';
89
76
 
90
77
        # Check and see if this template should be shown in the list
91
78
        $isValid = false;
92
79
 
93
 
        if( isset($template['regexp'] ) ) {
94
 
                if( @preg_match( "/".$template['regexp']."/i", $container ) ) {
 
80
        if (isset($template['regexp'])) {
 
81
                if (@preg_match('/'.$template['regexp'].'/i',$container))
95
82
                        $isValid = true;
96
 
                }
97
 
 
98
 
        } else {
 
83
        } else
99
84
                $isValid = true;
100
85
 
101
86
        if (isset($template['invalid']) && $template['invalid'])
102
87
                $isValid = false;
103
 
        } ?>
104
 
 
105
 
                        </td>
106
 
                </tr>
107
 
 
108
 
                <tr>
109
 
<?php
110
 
        if (isset($template['invalid']) && $template['invalid'] || (isset($template['handler']) && ! file_exists(TMPLDIR.'creation/'.$template['handler']))) {
111
 
?>
112
 
                        <td class="icon">
113
 
                        <img src="images/error.png" />
114
 
                        </td>
115
 
<?php
116
 
        } else {
117
 
?>
118
 
 
119
 
                        <td>
120
 
                        <input type="radio" name="template" value="<?php echo htmlspecialchars($name);?>"
121
 
                                id="<?php echo htmlspecialchars($name); ?>"
122
 
 
123
 
        <?php
124
 
if( 0 == strcasecmp( 'Custom', $name ) ) echo ' checked';
125
 
        if( ! $isValid ) echo ' disabled';
126
 
?> />
127
 
 
128
 
                        </td>
129
 
<?php
130
 
        }
131
 
?>
132
 
 
133
 
                        <td class="icon">
134
 
                        <label for="<?php echo htmlspecialchars($name);?>">
135
 
                        <img src="<?php echo $template['icon']; ?>" />
136
 
                        </label>
137
 
                        </td>
138
 
 
139
 
                        <td>
140
 
                        <label for="<?php echo htmlspecialchars($name);?>">
141
 
 
142
 
        <?php if( 0 == strcasecmp( 'Custom', $template['desc'] ) ) echo '<b>';
143
 
 
144
 
        if( ! $isValid )
 
88
 
 
89
        echo '<tr>';
 
90
        if (! $isValid || (isset($template['handler']) && ! file_exists(TMPLDIR.'creation/'.$template['handler'])))
 
91
                echo '<td class="icon"><img src="images/error.png" /></td>';
 
92
        else
 
93
                printf('<td><input type="radio" name="template" value="%s" id="%s" %s /></td>',
 
94
                        htmlspecialchars($name),htmlspecialchars($name),
 
95
                        ! $isValid ? 'disabled' : (strcasecmp('Custom',$name) ? '' : 'checked'));
 
96
 
 
97
        printf('<td class="icon"><label for="%s"><img src="%s" /></label></td>',
 
98
                htmlspecialchars($name),$template['icon']);
 
99
 
 
100
        printf('<td class="name"><label for="%s">',
 
101
                htmlspecialchars($name));
 
102
 
 
103
        if (strcasecmp('Custom', $template['desc']) == 0)
 
104
                 echo '<b>';
 
105
 
 
106
        if (! $isValid)
145
107
                if (isset($template['invalid']) && $template['invalid'])
146
 
                        printf('<span style="color: gray"><acronym title="%s">',$lang['template_invalid']);
 
108
                        printf('<span style="color: gray"><acronym title="%s">',
 
109
                                isset($template['invalid_reason']) ? $template['invalid_reason'] :
 
110
                                        _('This template has been disabled in the XML file.'));
147
111
                else
148
 
                        printf('<span style="color: gray"><acronym title="%s">',$lang['template_restricted']);
149
 
 
150
 
        echo htmlspecialchars( $template['desc'] );
151
 
 
152
 
        if( ! $isValid ) echo "</acronym></span>";
153
 
        if( 0 == strcasecmp( 'Custom', $template['desc'] ) ) echo '</b>'; ?>
154
 
 
155
 
                        </label>
156
 
                        </td>
157
 
                </tr>
158
 
 
159
 
<?php } // end foreach ?>
160
 
 
161
 
                </table>
162
 
                </td>
163
 
        </tr>
164
 
        </table>
165
 
        </td>
166
 
</tr>
167
 
 
168
 
<tr>
169
 
        <td colspan="2"><center><input type="submit" name="submit" value="<?php echo $lang['proceed_gt']?>" /></center></td>
170
 
</tr>
171
 
 
172
 
</table>
173
 
</form>
174
 
</body>
175
 
</html>
 
112
                        printf('<span style="color: gray"><acronym title="%s">',
 
113
                                _('This template is not allowed in this container.'));
 
114
 
 
115
        echo htmlspecialchars($template['desc']);
 
116
 
 
117
        if (! $isValid) echo '</acronym></span>';
 
118
        if (strcasecmp('Custom', $template['desc']) == 0)
 
119
                echo '</b>';
 
120
 
 
121
        echo '</label></td></tr>';
 
122
 
 
123
}
 
124
 
 
125
echo '</table>';
 
126
echo '</td></tr></table>';
 
127
echo '</td></tr>';
 
128
 
 
129
printf('<tr><td colspan="2"><center><input type="submit" name="submit" value="%s" /></center></td></tr>',
 
130
        htmlspecialchars(_('Proceed >>')));
 
131
 
 
132
echo '</table>';
 
133
echo '</form></body></html>';
 
134
?>