| 
									
										
										
										
											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
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |      * Is some sort of document security enabled? | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @return boolean | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |     public function isSecurityEnabled() | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         return  $this->_lockRevision || | 
					
						
							|  |  |  |                 $this->_lockStructure || | 
					
						
							|  |  |  |                 $this->_lockWindows; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get LockRevision | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return boolean | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |     public function getLockRevision() | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         return $this->_lockRevision; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Set LockRevision | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param boolean $pValue | 
					
						
							|  |  |  |      * @return PHPExcel_DocumentSecurity | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |     public function setLockRevision($pValue = false) | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $this->_lockRevision = $pValue; | 
					
						
							|  |  |  |         return $this; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get LockStructure | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return boolean | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |     public function getLockStructure() | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         return $this->_lockStructure; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Set LockStructure | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param boolean $pValue | 
					
						
							|  |  |  |      * @return PHPExcel_DocumentSecurity | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |     public function setLockStructure($pValue = false) | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $this->_lockStructure = $pValue; | 
					
						
							|  |  |  |         return $this; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get LockWindows | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return boolean | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |     public function getLockWindows() | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         return $this->_lockWindows; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Set LockWindows | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param boolean $pValue | 
					
						
							|  |  |  |      * @return PHPExcel_DocumentSecurity | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |     public function setLockWindows($pValue = false) | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $this->_lockWindows = $pValue; | 
					
						
							|  |  |  |         return $this; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get RevisionsPassword (hashed) | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return string | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-12 09:22:06 +00:00
										 |  |  |     public function getRevisionsPassword() | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         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-12 09:22:06 +00:00
										 |  |  |     public function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         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-12 09:22:06 +00:00
										 |  |  |     public function getWorkbookPassword() | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         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-12 09:22:06 +00:00
										 |  |  |     public function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) | 
					
						
							| 
									
										
										
										
											2015-05-11 21:38:52 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         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
										 |  |  | } |