This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * This file is part of PHPPresentation - A pure PHP library for reading and writing |
||
4 | * presentations documents. |
||
5 | * |
||
6 | * PHPPresentation is free software distributed under the terms of the GNU Lesser |
||
7 | * General Public License version 3 as published by the Free Software Foundation. |
||
8 | * |
||
9 | * For the full copyright and license information, please read the LICENSE |
||
10 | * file that was distributed with this source code. For the full list of |
||
11 | * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. |
||
12 | * |
||
13 | * @link https://github.com/PHPOffice/PHPPresentation |
||
14 | * @copyright 2009-2015 PHPPresentation contributors |
||
15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
||
16 | */ |
||
17 | |||
18 | namespace PhpOffice\PhpPresentation\Writer; |
||
19 | |||
20 | use DirectoryIterator; |
||
21 | use PhpOffice\Common\Adapter\Zip\ZipArchiveAdapter; |
||
22 | use PhpOffice\PhpPresentation\HashTable; |
||
23 | use PhpOffice\PhpPresentation\PhpPresentation; |
||
24 | use PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack; |
||
25 | use PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\PackDefault; |
||
26 | |||
27 | /** |
||
28 | * \PhpOffice\PhpPresentation\Writer\PowerPoint2007 |
||
29 | */ |
||
30 | class PowerPoint2007 extends AbstractWriter implements WriterInterface |
||
31 | { |
||
32 | /** |
||
33 | * Use disk caching where possible? |
||
34 | * |
||
35 | * @var boolean |
||
36 | */ |
||
37 | protected $useDiskCaching = false; |
||
38 | |||
39 | /** |
||
40 | * Disk caching directory |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $diskCachingDir; |
||
45 | |||
46 | /** |
||
47 | * Layout pack to use |
||
48 | * @deprecated 0.7 |
||
49 | * @var \PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack |
||
50 | */ |
||
51 | protected $layoutPack; |
||
52 | |||
53 | /** |
||
54 | * Create a new PowerPoint2007 file |
||
55 | * |
||
56 | * @param PhpPresentation $pPhpPresentation |
||
57 | * @throws \Exception |
||
58 | */ |
||
59 | 123 | public function __construct(PhpPresentation $pPhpPresentation = null) |
|
60 | { |
||
61 | // Assign PhpPresentation |
||
62 | 123 | $this->setPhpPresentation($pPhpPresentation); |
|
63 | |||
64 | // Set up disk caching location |
||
65 | 123 | $this->diskCachingDir = './'; |
|
66 | |||
67 | // Set layout pack |
||
68 | 123 | $this->layoutPack = new PackDefault(); |
|
0 ignored issues
–
show
The class
PhpOffice\PhpPresentatio...\LayoutPack\PackDefault has been deprecated with message: 0.7
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. ![]() |
|||
69 | |||
70 | // Set HashTable variables |
||
71 | 123 | $this->oDrawingHashTable = new HashTable(); |
|
72 | |||
73 | 123 | $this->setZipAdapter(new ZipArchiveAdapter()); |
|
74 | 123 | } |
|
75 | |||
76 | /** |
||
77 | * Save PhpPresentation to file |
||
78 | * |
||
79 | * @param string $pFilename |
||
80 | * @throws \Exception |
||
81 | */ |
||
82 | 117 | public function save($pFilename) |
|
83 | { |
||
84 | 117 | if (empty($pFilename)) { |
|
85 | 1 | throw new \Exception("Filename is empty"); |
|
86 | } |
||
87 | 116 | $oPresentation = $this->getPhpPresentation(); |
|
88 | |||
89 | // If $pFilename is php://output or php://stdout, make it a temporary file... |
||
90 | 115 | $originalFilename = $pFilename; |
|
91 | 115 | if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') { |
|
92 | $pFilename = @tempnam('./', 'phppttmp'); |
||
93 | if ($pFilename == '') { |
||
94 | $pFilename = $originalFilename; |
||
95 | } |
||
96 | } |
||
97 | |||
98 | // Create drawing dictionary |
||
99 | 115 | $this->getDrawingHashTable()->addFromSource($this->allDrawings()); |
|
100 | |||
101 | 115 | $oZip = $this->getZipAdapter(); |
|
102 | 115 | $oZip->open($pFilename); |
|
103 | |||
104 | 115 | $oDir = new DirectoryIterator(dirname(__FILE__).DIRECTORY_SEPARATOR.'PowerPoint2007'); |
|
105 | 115 | $arrayFiles = array(); |
|
106 | 115 | foreach ($oDir as $oFile) { |
|
107 | 115 | if (!$oFile->isFile()) { |
|
108 | 115 | continue; |
|
109 | } |
||
110 | |||
111 | 115 | $class = __NAMESPACE__ . '\\PowerPoint2007\\' . $oFile->getBasename('.php'); |
|
112 | 115 | $class = new \ReflectionClass($class); |
|
113 | |||
114 | 115 | if ($class->isAbstract() || !$class->isSubclassOf('PhpOffice\PhpPresentation\Writer\PowerPoint2007\AbstractDecoratorWriter')) { |
|
115 | 115 | continue; |
|
116 | } |
||
117 | 115 | $arrayFiles[$oFile->getBasename('.php')] = $class; |
|
118 | } |
||
119 | |||
120 | 115 | ksort($arrayFiles); |
|
121 | |||
122 | 115 | foreach ($arrayFiles as $o) { |
|
123 | 115 | $oService = $o->newInstance(); |
|
124 | 115 | $oService->setZip($oZip); |
|
125 | 115 | $oService->setPresentation($oPresentation); |
|
126 | 115 | $oService->setDrawingHashTable($this->getDrawingHashTable()); |
|
127 | 115 | $oZip = $oService->render(); |
|
128 | 115 | unset($oService); |
|
129 | } |
||
130 | |||
131 | // Close file |
||
132 | 112 | $oZip->close(); |
|
133 | |||
134 | // If a temporary file was used, copy it to the correct file stream |
||
135 | 112 | if ($originalFilename != $pFilename) { |
|
136 | if (copy($pFilename, $originalFilename) === false) { |
||
137 | throw new \Exception("Could not copy temporary zip file $pFilename to $originalFilename."); |
||
138 | } |
||
139 | if (@unlink($pFilename) === false) { |
||
140 | throw new \Exception('The file '.$pFilename.' could not be removed.'); |
||
141 | } |
||
142 | } |
||
143 | 112 | } |
|
144 | |||
145 | /** |
||
146 | * Get use disk caching where possible? |
||
147 | * |
||
148 | * @return boolean |
||
149 | */ |
||
150 | 1 | public function hasDiskCaching() |
|
151 | { |
||
152 | 1 | return $this->useDiskCaching; |
|
153 | } |
||
154 | |||
155 | /** |
||
156 | * Set use disk caching where possible? |
||
157 | * |
||
158 | * @param boolean $pValue |
||
159 | * @param string $pDirectory Disk caching directory |
||
160 | * @throws \Exception |
||
161 | * @return \PhpOffice\PhpPresentation\Writer\PowerPoint2007 |
||
162 | */ |
||
163 | 2 | public function setUseDiskCaching($pValue = false, $pDirectory = null) |
|
164 | { |
||
165 | 2 | $this->useDiskCaching = $pValue; |
|
166 | |||
167 | 2 | if (!is_null($pDirectory)) { |
|
168 | 2 | if (!is_dir($pDirectory)) { |
|
169 | 1 | throw new \Exception("Directory does not exist: $pDirectory"); |
|
170 | } |
||
171 | 1 | $this->diskCachingDir = $pDirectory; |
|
172 | } |
||
173 | |||
174 | 1 | return $this; |
|
175 | } |
||
176 | |||
177 | /** |
||
178 | * Get disk caching directory |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | 2 | public function getDiskCachingDirectory() |
|
183 | { |
||
184 | 2 | return $this->diskCachingDir; |
|
185 | } |
||
186 | |||
187 | /** |
||
188 | * Get layout pack to use |
||
189 | * |
||
190 | * @deprecated 0.7 |
||
191 | * @return \PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack |
||
192 | */ |
||
193 | 2 | public function getLayoutPack() |
|
194 | { |
||
195 | 2 | return $this->layoutPack; |
|
0 ignored issues
–
show
The property
PhpOffice\PhpPresentatio...rPoint2007::$layoutPack has been deprecated with message: 0.7
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
196 | } |
||
197 | |||
198 | /** |
||
199 | * Set layout pack to use |
||
200 | * |
||
201 | * @deprecated 0.7 |
||
202 | * @param \PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\AbstractLayoutPack $pValue |
||
203 | * @return \PhpOffice\PhpPresentation\Writer\PowerPoint2007 |
||
204 | */ |
||
205 | 1 | public function setLayoutPack(AbstractLayoutPack $pValue = null) |
|
206 | { |
||
207 | 1 | $this->layoutPack = $pValue; |
|
0 ignored issues
–
show
The property
PhpOffice\PhpPresentatio...rPoint2007::$layoutPack has been deprecated with message: 0.7
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. ![]() |
|||
208 | |||
209 | 1 | return $this; |
|
210 | } |
||
211 | } |
||
212 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.