Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fusiondirectory
fusiondirectory
Commits
ba9c2e72
Commit
ba9c2e72
authored
Jul 17, 2014
by
Côme Bernigaud
Browse files
Fixes
#3222
Cleaning dead code
Conflicts: include/class_certificate.inc include/class_session.inc
parent
95fe93b6
Changes
10
Hide whitespace changes
Inline
Side-by-side
include/class_SnapShotDialog.inc
View file @
ba9c2e72
...
...
@@ -64,18 +64,6 @@ class SnapShotDialog extends plugin
$this
->
snapHandler
=
new
SnapshotHandler
(
$this
->
config
);
}
/*! \brief Test if snapshoting is enabled
*
* Test weither snapshotting is enabled or not. There will also be some errors posted,
* if the configuration failed
*
* \return TRUE if snapshots are enabled, and FALSE if it is disabled
*/
function
snapshotEnabled
()
{
return
$this
->
snapHandler
->
enabled
();
}
/*!
* \brief Get all deleted snapshots
*/
...
...
include/class_acl.inc
View file @
ba9c2e72
...
...
@@ -262,22 +262,6 @@ class acl extends plugin
return
$a
;
}
/*!
* \brief Prepare for Copy & Paste
*
* \see plugin::PrepareForCopyPaste($source)
*
* \param string $source Source to prepare for copy and paste
*/
function
PrepareForCopyPaste
(
$source
)
{
plugin
::
PrepareForCopyPaste
(
$source
);
$dn
=
$source
[
'dn'
];
$acl_c
=
new
acl
(
$this
->
config
,
$dn
);
$this
->
gosaAclEntry
=
$acl_c
->
gosaAclEntry
;
}
/*!
* \brief Removes object from parent
*/
...
...
@@ -317,16 +301,6 @@ class acl extends plugin
);
}
/*!
* \brief Remove acls defined for $src
*/
function
remove_acl
()
{
acl
::
remove_acl_for
(
$this
->
dn
);
}
/*!
* \brief Remove acls defined for $src
*
...
...
include/class_baseSelector.inc
View file @
ba9c2e72
...
...
@@ -100,18 +100,6 @@ class baseSelector {
}
}
/*!
* \brief Check the base value
*
* \param String $base The base value which will be checked
*
* \return boolean
*/
function
checkBase
(
$base
)
{
return
isset
(
$this
->
pathMapping
[
$base
]);
}
/*!
* \brief Check the last base value updated
*
...
...
@@ -306,24 +294,5 @@ class baseSelector {
{
return
$this
->
base
;
}
/*!
* \brief Accessor of the action
*
* \return action of the object if exists
*/
function
getAction
()
{
// Do not do anything if this is not our BPID, or there's even no BPID available...
if
(
!
isset
(
$_REQUEST
[
'BPID'
])
||
(
$_REQUEST
[
'BPID'
]
!=
$this
->
pid
))
{
return
;
}
if
(
$this
->
action
)
{
return
array
(
"targets"
=>
array
(
$this
->
base
),
"action"
=>
$this
->
action
);
}
return
NULL
;
}
}
?>
include/class_certificate.inc
deleted
100644 → 0
View file @
95fe93b6
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
Copyright (C) 2011-2015 FusionDirectory
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*!
* \file class_certificate.inc
* Source code for class certificate
*/
/* certificates */
define
(
"PEM"
,
"pem"
);
define
(
"DER"
,
"der"
);
/*!
* \brief This class contains all the function needed to import certificates
*/
class
certificate
{
/* vars */
var
$data
;
var
$type
;
var
$error
;
/*
* \brief Certificate constructor (initialize all vars)
*/
function
certificate
()
{
$this
->
data
=
""
;
$this
->
type
=
FALSE
;
$this
->
error
=
""
;
$this
->
info
=
array
();
}
/*
* \brief Reads specified Certfile/string and convert it to PEM
*
* \param string $data
*
* \param boolean $type FALSE
*/
function
import
(
$data
,
$type
=
FALSE
)
{
/* if is file read from file, else use string as it is*/
if
(
is_file
(
$data
))
{
$fp
=
fopen
(
$data
,
"r+"
);
$str
=
""
;
if
(
!
$fp
)
{
$this
->
certificate
();
$this
->
error
=
msgPool
::
cannotReadFile
(
$data
);
return
FALSE
;
}
else
{
/* Reading data*/
while
(
!
feof
(
$fp
))
{
$str
.
=
fgets
(
$fp
,
1024
);
}
}
/* Filename given, so we use the data from the file */
$this
->
data
=
$str
;
}
else
{
/* Cert as String, use this string */
$this
->
data
=
$data
;
}
/* Data can't be empty */
if
(
$data
=
""
)
{
$this
->
certificate
();
$this
->
error
=
_
(
"Certificate is empty!"
);
return
FALSE
;
}
/* Prefer specified certtype*/
if
(
$type
)
{
$this
->
type
=
$type
;
}
else
{
/* Detect certtype, cause there is none specified */
/* PEM always starts with ----BEGIN CERTIFICATE-----*/
if
(
strstr
(
$this
->
data
,
"CERTIFICATE"
))
{
$this
->
type
=
PEM
;
}
else
{
/* We test DER now, on fail abort */
$this
->
type
=
DER
;
}
}
/* Convert to PEM to give $this->info the ability to read the cert */
if
(
$this
->
type
==
DER
)
{
$this
->
derTOpem
();
}
/* If cert is loaded correctly and is PEM now, we could read some data out of it */
if
(
count
(
$this
->
info
())
<=
1
)
{
$this
->
certificate
();
$this
->
error
=
_
(
"Cannot load certificate - only PEM/DER is supported!"
);
/* Reset*/
return
FALSE
;
}
$this
->
info
(
FALSE
);
/* Loaded a readable cert */
return
TRUE
;
}
/*
* \brief Get all data of a certificate
*
* \param boolean $ret true
*
* \return Array with all containing data
*/
function
info
(
$ret
=
TRUE
)
{
if
(
$this
->
type
!=
PEM
)
{
$this
->
error
=
_
(
"Cannot extract information for non PEM certificates!"
);
return
FALSE
;
}
else
{
/* return an array with all given information */
$this
->
info
=
openssl_x509_parse
(
$this
->
data
);
if
(
$ret
)
{
return
$this
->
info
;
}
}
}
/* Return Functions */
function
getvalidto_date
()
{
return
$this
->
_genericGet1
(
'validTo_time_t'
);
}
function
getvalidfrom_date
()
{
return
$this
->
_genericGet1
(
'validFrom_time_t'
);
}
/*!
* \brief Get the name of the certificate
*
* \return String with the name, but return FALSE if not found
*/
function
getname
()
{
return
$this
->
_genericGet1
(
'name'
);
}
/*!
* \brief Get the CN of the certificate
*
* \return String with the CN, but return FALSE if not found
*/
function
getCN
()
{
return
$this
->
_genericGet2
(
'CN'
);
}
function
getO
()
{
return
$this
->
_genericGet2
(
'O'
);
}
function
getOU
()
{
return
$this
->
_genericGet2
(
'OU'
);
}
/*!
* \brief Get the serial number of the certificate
*
* \return Integer number, but return FALSE if not found
*/
function
getSerialNumber
()
{
return
$this
->
_genericGet1
(
'serialNumber'
);
}
protected
function
_genericGet1
(
$key
)
{
if
(
isset
(
$this
->
info
[
$key
]))
{
return
$this
->
info
[
$key
];
}
else
{
return
FALSE
;
}
}
protected
function
_genericGet2
(
$key
)
{
if
(
isset
(
$this
->
info
[
'subject'
][
$key
]))
{
return
$this
->
info
[
'subject'
][
$key
];
}
else
{
return
FALSE
;
}
}
/*
* \brief Check if the certificate is valid
* Is valide if the length of array > 1
* and type is true
*/
function
isvalid
()
{
return
((
$this
->
type
!=
FALSE
)
&&
(
count
(
$this
->
info
)
>
1
));
}
/*
* \brief Export Certificate to specified file, with specified method
*
* \param boolean $type
*
* \param string $filename Initialized at 'temp'
*/
function
export
(
$type
,
$filename
=
"temp"
)
{
/* Check if valid cert is loaded*/
if
(
$this
->
type
!=
FALSE
)
{
/* Check if we must convert the cert */
if
(
$this
->
type
!=
$type
)
{
$strConv
=
$this
->
type
.
"TO"
.
$type
;
$this
->
$strConv
();
}
/* open file for writing */
$fp
=
fopen
(
$filename
,
"w+"
);
if
(
!
$fp
)
{
$this
->
error
=
msgPool
::
cannotWriteFile
(
$filename
);
return
FALSE
;
}
else
{
fwrite
(
$fp
,
$this
->
data
,
strlen
(
$this
->
data
));
}
return
TRUE
;
}
else
{
$this
->
error
=
_
(
"No valid certificate loaded!"
);
return
FALSE
;
}
return
FALSE
;
}
/*
* \brief Convert der to pem Certificate
*/
function
derTOpem
()
{
/* if type is DER start convert */
if
(
$this
->
type
==
DER
)
{
/* converting */
$this
->
type
=
PEM
;
$str
=
base64_encode
(
$this
->
data
);
$len
=
strlen
(
$str
);
$end
=
""
;
while
(
$len
>
0
)
{
$len
=
$len
-
64
;
$str1
=
substr
(
$str
,
0
,
64
)
.
"
\n
"
;
$str
=
substr
(
$str
,
64
,
$len
);
$end
.
=
$str1
;
}
$strend
=
"-----BEGIN CERTIFICATE-----
\n
"
.
$end
;
$strend
.
=
"-----END CERTIFICATE-----"
;
$this
->
data
=
$strend
;
return
TRUE
;
}
return
FALSE
;
}
/*
* Convert pem to der Certificate
*/
function
pemTOder
()
{
if
(
$this
->
type
==
PEM
)
{
$this
->
type
=
DER
;
$str
=
$this
->
data
;
$str
=
str_replace
(
"-----BEGIN CERTIFICATE-----"
,
""
,
$str
);
$str
=
str_replace
(
"-----END CERTIFICATE-----"
,
""
,
$str
);
$str
=
base64_decode
(
$str
);
$this
->
data
=
$str
;
return
TRUE
;
}
return
FALSE
;
}
}
?>
include/class_config.inc
View file @
ba9c2e72
...
...
@@ -872,87 +872,6 @@ class config {
return
$ret
;
}
/*!
* \brief Get all available shares defined in the current LDAP
*
* This function returns all available Shares defined in this ldap
*
* \param boolean $listboxEntry If set to TRUE, only name and path are
* attached to the array. If FALSE, the whole entry will be parsed an atached to the result.
*
* \return array list of share defined in the current LDAP
*/
function
getShareList
(
$listboxEntry
=
FALSE
)
{
$tmp
=
get_sub_list
(
"(&(objectClass=goShareServer)(goExportEntry=*))"
,
"server"
,
get_ou
(
"serverRDN"
),
$this
->
current
[
'BASE'
],
array
(
"goExportEntry"
,
"cn"
),
GL_NONE
);
$return
=
array
();
foreach
(
$tmp
as
$entry
)
{
if
(
isset
(
$entry
[
'goExportEntry'
][
'count'
]))
{
unset
(
$entry
[
'goExportEntry'
][
'count'
]);
}
if
(
isset
(
$entry
[
'goExportEntry'
]))
{
foreach
(
$entry
[
'goExportEntry'
]
as
$export
)
{
$shareAttrs
=
explode
(
"|"
,
$export
);
if
(
$listboxEntry
)
{
$return
[
$shareAttrs
[
0
]
.
"|"
.
$entry
[
'cn'
][
0
]]
=
$shareAttrs
[
0
]
.
" - "
.
$entry
[
'cn'
][
0
];
}
else
{
$return
[
$shareAttrs
[
0
]
.
"|"
.
$entry
[
'cn'
][
0
]][
'server'
]
=
$entry
[
'cn'
][
0
];
$return
[
$shareAttrs
[
0
]
.
"|"
.
$entry
[
'cn'
][
0
]][
'name'
]
=
$shareAttrs
[
0
];
$return
[
$shareAttrs
[
0
]
.
"|"
.
$entry
[
'cn'
][
0
]][
'description'
]
=
$shareAttrs
[
1
];
$return
[
$shareAttrs
[
0
]
.
"|"
.
$entry
[
'cn'
][
0
]][
'type'
]
=
$shareAttrs
[
2
];
$return
[
$shareAttrs
[
0
]
.
"|"
.
$entry
[
'cn'
][
0
]][
'charset'
]
=
$shareAttrs
[
3
];
$return
[
$shareAttrs
[
0
]
.
"|"
.
$entry
[
'cn'
][
0
]][
'path'
]
=
$shareAttrs
[
4
];
$return
[
$shareAttrs
[
0
]
.
"|"
.
$entry
[
'cn'
][
0
]][
'option'
]
=
$shareAttrs
[
5
];
}
}
}
}
return
$return
;
}
/*!
* \brief Return all available share servers in LDAP
*
* This function returns all available ShareServers.
*
* \return array list of share defined in the current LDAP
*/
function
getShareServerList
()
{
$return
=
array
();
$ui
=
get_userinfo
();
$base
=
$this
->
current
[
'BASE'
];
$res
=
get_sub_list
(
"(&(objectClass=goShareServer)(goExportEntry=*))"
,
"server"
,
get_ou
(
"serverRDN"
),
$base
,
array
(
"goExportEntry"
,
"cn"
),
GL_NONE
|
GL_NO_ACL_CHECK
);
foreach
(
$res
as
$entry
)
{
$acl
=
$ui
->
get_permissions
(
$entry
[
'dn'
],
"server"
,
""
);
if
(
isset
(
$entry
[
'goExportEntry'
][
'count'
]))
{
unset
(
$entry
[
'goExportEntry'
][
'count'
]);
}
foreach
(
$entry
[
'goExportEntry'
]
as
$share
)
{
$a_share
=
explode
(
"|"
,
$share
);
$sharename
=
$a_share
[
0
];
$data
=
array
();
$data
[
'NAME'
]
=
$sharename
;
$data
[
'ACL'
]
=
$acl
;
$data
[
'SERVER'
]
=
$entry
[
'cn'
][
'0'
];
$data
[
'SHARE'
]
=
$sharename
;
$data
[
'DISPLAY'
]
=
$entry
[
'cn'
][
0
]
.
" ["
.
$sharename
.
"]"
;
$return
[
$entry
[
'cn'
][
0
]
.
"|"
.
$sharename
]
=
$data
;
}
}
return
$return
;
}
/*!
* \brief Check if there's the specified bool value set in the configuration
*
...
...
@@ -1395,16 +1314,6 @@ class config {
}
);
}
/*!
* \brief Get list of object of objectType $type in $ou
*/
function
getObjectList
(
$type
,
$attrs
=
array
(),
$ou
=
NULL
,
$filter
=
''
)
{
trigger_error
(
'Deprecated'
);
return
objects
::
ls
(
$type
,
$attrs
,
$ou
,
$filter
);
}
}
?>
include/class_filter.inc
View file @
ba9c2e72
...
...
@@ -257,34 +257,6 @@ class filter
}
}
/*!
* \brief Get the current base
*
* \return String, the current base
*/
function
getCurrentBase
()
{
if
(
isset
(
$this
->
search
->
base
)
&&
((
string
)
$this
->
search
->
scope
!=
"auto"
))
{
return
FALSE
;
}
return
$this
->
base
;
}
/*!
* \brief Get the current scope
*
* \return String, the current scope
*/
function
getCurrentScope
()
{
if
(
isset
(
$this
->
search
->
scope
)
&&
((
string
)
$this
->
search
->
scope
!=
"auto"
))
{
return
(
string
)
$this
->
search
->
scope
;
}
return
$this
->
scope
;
}
/*!
* \brief Set a converter
*
...
...
@@ -648,34 +620,6 @@ class filter
}
}
}
/*!
* \brief Get the object base
*
* \param string $dn The DN
*/
function
getObjectBase
(
$dn
)
{
global
$config
;
$base
=
""
;
// Try every object storage
$storage
=
$this
->
objectStorage
;
if
(
!
is_array
(
$storage
))
{
$storage
=
array
(
$storage
);
}
foreach
(
$storage
as
$location
)
{
$pattern
=
"/^[^,]+,"
.
preg_quote
(
$location
,
'/'
)
.
"/i"
;
$base
=
preg_replace
(
$pattern
,
''
,
$dn
);
}
/* Set to base, if we're not on a correct subtree */
if
(
!
isset
(
$config
->
idepartments
[
$base
]))
{
$base
=
$config
->
current
[
'BASE'
];
}
return
$base
;
}
}
/*!
...
...
include/class_management.inc
View file @
ba9c2e72
...
...
@@ -173,7 +173,7 @@ class management
// Pre-render list to init things if a dn is gonna be opened on first load
if
(
isset
(
$_REQUEST
[
'dn'
]))
{
$this
->
headpage
->
filter
->
scope
=
'sub'
;
$this
->
headpage
->
filter
->
s
etCurrentS
cope
(
'sub'
)
;
$this
->
renderList
();
}
...
...
include/class_session.inc
View file @
ba9c2e72
...
...
@@ -28,53 +28,6 @@
* \brief This class contains all the function needed to manage sessions
*/
class
session
{
public
static
function
get_session_size
()
{
}
public
static
function
get_element_size
()
{
}
/*!
* \brief Add channel in the session
*
* \param string $name Name of the new channel
*/
public
static
function
add_channel
(
$name
)
{
/* If there's already such kind of channel, skip... */
if
(
isset
(
$_SESSION
[
$name
]))
{
return
FALSE
;
}
/* Allocate it... */