2010-08-26 19:14:53 +00:00
|
|
|
<?php
|
2015-05-11 21:38:52 +00:00
|
|
|
|
2010-08-26 19:14:53 +00:00
|
|
|
/**
|
2015-05-11 21:38:52 +00:00
|
|
|
* PHPExcel_DocumentSecurity
|
2010-08-26 19:14:53 +00:00
|
|
|
*
|
2015-05-02 22:50:37 +00:00
|
|
|
* Copyright (c) 2006 - 2015 PHPExcel
|
2010-08-26 19:14:53 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* @category PHPExcel
|
|
|
|
* @package PHPExcel
|
2015-05-02 22:50:37 +00:00
|
|
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
2015-05-11 21:38:52 +00:00
|
|
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
2010-08-26 19:14:53 +00:00
|
|
|
* @version ##VERSION##, ##DATE##
|
|
|
|
*/
|
|
|
|
class PHPExcel_DocumentSecurity
|
|
|
|
{
|
2015-05-11 21:38:52 +00:00
|
|
|
/**
|
|
|
|
* LockRevision
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
|
|
|
private $_lockRevision;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* LockStructure
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
|
|
|
private $_lockStructure;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* LockWindows
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
|
|
|
private $_lockWindows;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RevisionsPassword
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_revisionsPassword;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WorkbookPassword
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $_workbookPassword;
|
2010-08-26 19:14:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new PHPExcel_DocumentSecurity
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2015-05-11 21:38:52 +00:00
|
|
|
// Initialise values
|
|
|
|
$this->_lockRevision = false;
|
|
|
|
$this->_lockStructure = false;
|
|
|
|
$this->_lockWindows = false;
|
|
|
|
$this->_revisionsPassword = '';
|
|
|
|
$this->_workbookPassword = '';
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is some sort of dcument security enabled?
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function isSecurityEnabled()
|
|
|
|
{
|
|
|
|
return $this->_lockRevision ||
|
|
|
|
$this->_lockStructure ||
|
|
|
|
$this->_lockWindows;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get LockRevision
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function getLockRevision()
|
|
|
|
{
|
|
|
|
return $this->_lockRevision;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set LockRevision
|
|
|
|
*
|
|
|
|
* @param boolean $pValue
|
|
|
|
* @return PHPExcel_DocumentSecurity
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function setLockRevision($pValue = false)
|
|
|
|
{
|
|
|
|
$this->_lockRevision = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get LockStructure
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function getLockStructure()
|
|
|
|
{
|
|
|
|
return $this->_lockStructure;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set LockStructure
|
|
|
|
*
|
|
|
|
* @param boolean $pValue
|
|
|
|
* @return PHPExcel_DocumentSecurity
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function setLockStructure($pValue = false)
|
|
|
|
{
|
|
|
|
$this->_lockStructure = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get LockWindows
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function getLockWindows()
|
|
|
|
{
|
|
|
|
return $this->_lockWindows;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set LockWindows
|
|
|
|
*
|
|
|
|
* @param boolean $pValue
|
|
|
|
* @return PHPExcel_DocumentSecurity
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function setLockWindows($pValue = false)
|
|
|
|
{
|
|
|
|
$this->_lockWindows = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get RevisionsPassword (hashed)
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function getRevisionsPassword()
|
|
|
|
{
|
|
|
|
return $this->_revisionsPassword;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set RevisionsPassword
|
|
|
|
*
|
2015-05-11 21:38:52 +00:00
|
|
|
* @param string $pValue
|
|
|
|
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
2010-08-26 19:14:53 +00:00
|
|
|
* @return PHPExcel_DocumentSecurity
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false)
|
|
|
|
{
|
|
|
|
if (!$pAlreadyHashed) {
|
|
|
|
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
|
|
|
}
|
|
|
|
$this->_revisionsPassword = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get WorkbookPassword (hashed)
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function getWorkbookPassword()
|
|
|
|
{
|
|
|
|
return $this->_workbookPassword;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set WorkbookPassword
|
|
|
|
*
|
2015-05-11 21:38:52 +00:00
|
|
|
* @param string $pValue
|
|
|
|
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
2010-08-26 19:14:53 +00:00
|
|
|
* @return PHPExcel_DocumentSecurity
|
|
|
|
*/
|
2015-05-11 21:38:52 +00:00
|
|
|
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false)
|
|
|
|
{
|
|
|
|
if (!$pAlreadyHashed) {
|
|
|
|
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
|
|
|
}
|
|
|
|
$this->_workbookPassword = $pValue;
|
|
|
|
return $this;
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
2015-05-11 21:38:52 +00:00
|
|
|
/**
|
|
|
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
|
|
|
*/
|
|
|
|
public function __clone()
|
|
|
|
{
|
|
|
|
$vars = get_object_vars($this);
|
|
|
|
foreach ($vars as $key => $value) {
|
|
|
|
if (is_object($value)) {
|
|
|
|
$this->$key = clone $value;
|
|
|
|
} else {
|
|
|
|
$this->$key = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|