~ubuntu-branches/debian/sid/phpldapadmin/sid

« back to all changes in this revision

Viewing changes to htdocs/add_attr.php

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2009-03-16 14:54:15 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090316145415-7dsvj319dd02h83j
Tags: 1.1.0.6-1
* New upstream release. (Closes: #518578)
* debian/rules: removed "-m 644" from the dh_install call. (Closes: #518847)
* debian/postrm: remove config.php at purge time. (Closes: #519086)
* debian/patches/hungarian.dpatch: fixed a hungarian translation.
  (Closes: #505559)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_attr.php,v 1.20.2.1 2007/12/26 09:26:32 wurley Exp $
 
2
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/add_attr.php,v 1.20.2.2 2008/12/12 12:20:22 wurley Exp $
3
3
 
4
4
/**
5
5
 * Adds an attribute/value pair to an object
19
19
require './common.php';
20
20
 
21
21
if ($ldapserver->isReadOnly())
22
 
        pla_error(_('You cannot perform updates while server is in read-only mode'));
 
22
        error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
23
23
 
24
24
if (! $_SESSION[APPCONFIG]->isCommandAvailable('attribute_add'))
25
 
        pla_error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute')));
 
25
        error(sprintf('%s%s %s',_('This operation is not permitted by the configuration'),_(':'),_('add attribute')),'error','index.php');
26
26
 
 
27
$entry = array();
27
28
$entry['val'] = get_request('val','POST');
28
29
$entry['binary'] = get_request('binary','POST');
29
30
 
34
35
$entry['attr']['encode'] = rawurlencode($entry['attr']['string']);
35
36
 
36
37
if ((strlen($entry['binary']) <= 0) && (strlen($entry['val']) <= 0))
37
 
        pla_error(_('You left the attribute value blank. Please go back and try again.'));
 
38
        error(_('You left the attribute value blank. Please go back and try again.'),'error','index.php');
38
39
 
39
40
/*
40
41
 * Special case for binary attributes (like jpegPhoto and userCertificate):
48
49
        $href = htmlspecialchars(sprintf('cmd.php?cmd=search&search=true&form=advanced&server_id=%s&filter=%s=%s',
49
50
                $ldapserver->server_id,$entry['attr']['string'],$badattr));
50
51
 
51
 
        pla_error(sprintf(_('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$entry['attr']['string'],$badattr,$entry['dn']['string'],$href));
 
52
        error(sprintf(_('Your attempt to add <b>%s</b> (<i>%s</i>) to <br><b>%s</b><br> is NOT allowed. That attribute/value belongs to another entry.<p>You might like to <a href=\'%s\'>search</a> for that entry.'),$entry['attr']['string'],$badattr,$entry['dn']['string'],$href),'error','index.php');
52
53
}
53
54
 
54
55
if (strlen($entry['binary']) > 0) {
55
56
        if ($_FILES['val']['size'] == 0)
56
 
                pla_error(_('The file you chose is either empty or does not exist. Please go back and try again.'));
 
57
                error(_('The file you chose is either empty or does not exist. Please go back and try again.'),'error','index.php');
57
58
 
58
59
        if (! is_uploaded_file($_FILES['val']['tmp_name'])) {
59
60
                if (isset($_FILES['val']['error']))
60
61
 
61
62
                        switch($_FILES['val']['error']) {
62
63
                                case 0: # No error; possible file attack!
63
 
                                        pla_error(_('Security error: The file being uploaded may be malicious.'));
 
64
                                        error(_('Security error: The file being uploaded may be malicious.'),'error','index.php');
64
65
                                        break;
65
66
 
66
67
                                case 1: # Uploaded file exceeds the upload_max_filesize directive in php.ini
67
 
                                        pla_error(_('The file you uploaded is too large. Please check php.ini, upload_max_size setting'));
 
68
                                        error(_('The file you uploaded is too large. Please check php.ini, upload_max_size setting'),'error','index.php');
68
69
                                        break;
69
70
 
70
71
                                case 2: # Uploaded file exceeds the MAX_FILE_SIZE directive specified in the html form
71
 
                                        pla_error(_('The file you uploaded is too large. Please check php.ini, upload_max_size setting'));
 
72
                                        error(_('The file you uploaded is too large. Please check php.ini, upload_max_size setting'),'error','index.php');
72
73
                                        break;
73
74
 
74
75
                                case 3: # Uploaded file was only partially uploaded
75
 
                                        pla_error(_('The file you selected was only partially uploaded, likley due to a network error.'));
 
76
                                        error(_('The file you selected was only partially uploaded, likley due to a network error.'),'error','index.php');
76
77
                                        break;
77
78
 
78
79
                                case 4: # No file was uploaded
79
 
                                        pla_error(_('You left the attribute value blank. Please go back and try again.'));
 
80
                                        error(_('You left the attribute value blank. Please go back and try again.'),'error','index.php');
80
81
                                        break;
81
82
 
82
83
                                default: # A default error, just in case!  :)
83
 
                                        pla_error(_('Security error: The file being uploaded may be malicious.'));
 
84
                                        error(_('Security error: The file being uploaded may be malicious.'),'error','index.php');
84
85
                                        break;
85
86
                        }
86
87
 
87
88
                else
88
 
                        pla_error(_('Security error: The file being uploaded may be malicious.'));
 
89
                        error(_('Security error: The file being uploaded may be malicious.'),'error','index.php');
89
90
        }
90
91
 
91
92
        $binaryfile['name'] = $_FILES['val']['tmp_name'];
125
126
        die();
126
127
 
127
128
} else {
128
 
        pla_error(_('Failed to add the attribute.'),$ldapserver->error(),$ldapserver->errno());
 
129
        system_message(array(
 
130
                'title'=>_('Failed to add the attribute.'),
 
131
                'body'=>ldap_error_msg($ldapserver->error(),$ldapserver->errno()),
 
132
                'type'=>'error'));
129
133
}
130
134
 
131
135
/**