| [ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /** 3 * $Id: IoncubeEncoderTask.php 3076 2006-12-18 08:52:12Z fabien $ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information please see 19 * <http://phing.info>. 20 */ 21 22 require_once 'phing/Task.php'; 23 require_once 'phing/tasks/ext/ioncube/IoncubeComment.php'; 24 25 /** 26 * Invokes the ionCube Encoder (PHP4 or PHP5) 27 * 28 * @author Michiel Rook <michiel.rook@gmail.com> 29 * @version $Id: IoncubeEncoderTask.php 3076 2006-12-18 08:52:12Z fabien $ 30 * @package phing.tasks.ext.ioncube 31 * @since 2.2.0 32 */ 33 class IoncubeEncoderTask extends Task 34 { 35 private $phpVersion = "5"; 36 private $ioncubePath = "/usr/local/ioncube"; 37 private $encoderName = "ioncube_encoder"; 38 39 private $fromDir = ""; 40 private $toDir = ""; 41 42 private $encrypt = ""; 43 44 private $targetOption = ""; 45 private $binary = false; 46 private $optimize = ""; 47 private $withoutRuntimeLoaderSupport = false; 48 49 private $licensePath = ""; 50 private $passPhrase = ""; 51 52 private $comments = array(); 53 54 /** 55 * Sets the path to the ionCube encoder 56 */ 57 function setIoncubePath($ioncubePath) 58 { 59 $this->ioncubePath = $ioncubePath; 60 } 61 62 /** 63 * Returns the path to the ionCube encoder 64 */ 65 function getIoncubePath() 66 { 67 return $this->ioncubePath; 68 } 69 70 /** 71 * Sets the version of PHP to use (defaults to 5) 72 */ 73 function setPhpVersion($phpVersion) 74 { 75 $this->phpVersion = $phpVersion; 76 } 77 78 /** 79 * Returns the version of PHP to use (defaults to 5) 80 */ 81 function getPhpVersion() 82 { 83 return $this->phpVersion; 84 } 85 86 /** 87 * Sets the source directory 88 */ 89 function setFromDir($fromDir) 90 { 91 $this->fromDir = $fromDir; 92 } 93 94 /** 95 * Returns the source directory 96 */ 97 function getFromDir($fromDir) 98 { 99 return $this->fromDir; 100 } 101 102 /** 103 * Sets the target directory 104 */ 105 function setToDir($toDir) 106 { 107 $this->toDir = $toDir; 108 } 109 110 /** 111 * Returns the target directory 112 */ 113 function getToDir($toDir) 114 { 115 return $this->toDir; 116 } 117 118 /** 119 * Sets regexps of additional files to encrypt (separated by space) 120 */ 121 function setEncrypt($encrypt) 122 { 123 $this->encrypt = $encrypt; 124 } 125 126 /** 127 * Returns regexps of additional files to encrypt (separated by space) 128 */ 129 function getEncrypt() 130 { 131 return $this->encrypt; 132 } 133 134 /** 135 * Sets the binary option 136 */ 137 function setBinary($binary) 138 { 139 $this->binary = $binary; 140 } 141 142 /** 143 * Returns the binary option 144 */ 145 function getBinary() 146 { 147 return $this->binary; 148 } 149 150 /** 151 * Sets the optimize option 152 */ 153 function setOptimize($optimize) 154 { 155 $this->optimize = $optimize; 156 } 157 158 /** 159 * Returns the optimize option 160 */ 161 function getOptimize() 162 { 163 return $this->optimize; 164 } 165 166 /** 167 * Sets the without-runtime-loader-support option 168 */ 169 function setWithoutRuntimeLoaderSupport($withoutRuntimeLoaderSupport) 170 { 171 $this->withoutRuntimeLoaderSupport = $withoutRuntimeLoaderSupport; 172 } 173 174 /** 175 * Returns the without-runtime-loader-support option 176 */ 177 function getWithoutRuntimeLoaderSupport() 178 { 179 return $this->withoutRuntimeLoaderSupport; 180 } 181 182 /** 183 * Sets the option to use when encoding target directory already exists (defaults to none) 184 */ 185 function setTargetOption($targetOption) 186 { 187 $this->targetOption = $targetOption; 188 } 189 190 /** 191 * Returns he option to use when encoding target directory already exists (defaults to none) 192 */ 193 function getTargetOption() 194 { 195 return $this->targetOption; 196 } 197 198 /** 199 * Sets the path to the license file to use 200 */ 201 function setLicensePath($licensePath) 202 { 203 $this->licensePath = $licensePath; 204 } 205 206 /** 207 * Returns the path to the license file to use 208 */ 209 function getLicensePath() 210 { 211 return $this->licensePath; 212 } 213 214 /** 215 * Sets the passphrase to use when encoding files 216 */ 217 function setPassPhrase($passPhrase) 218 { 219 $this->passPhrase = $passPhrase; 220 } 221 222 /** 223 * Returns the passphrase to use when encoding files 224 */ 225 function getPassPhrase() 226 { 227 return $this->passPhrase; 228 } 229 230 /** 231 * Adds a comment to be used in encoded files 232 */ 233 function addComment(IoncubeComment $comment) 234 { 235 $this->comments[] = $comment; 236 } 237 238 /** 239 * The main entry point 240 * 241 * @throws BuildException 242 */ 243 function main() 244 { 245 $arguments = $this->constructArguments(); 246 247 $encoder = new PhingFile($this->ioncubePath, $this->encoderName . ($this->phpVersion == 5 ? '5' : '')); 248 249 $this->log("Running ionCube Encoder..."); 250 251 exec($encoder->__toString() . " " . $arguments . " 2>&1", $output, $return); 252 253 if ($return != 0) 254 { 255 throw new BuildException("Could not execute ionCube Encoder: " . implode(' ', $output)); 256 } 257 } 258 259 /** 260 * Constructs an argument string for the ionCube encoder 261 */ 262 private function constructArguments() 263 { 264 $arguments = ""; 265 266 if ($this->binary) 267 { 268 $arguments.= "--binary "; 269 } 270 271 if (!empty($this->optimize)) 272 { 273 $arguments.= "--optimize " . $this->optimize . " "; 274 } 275 276 if ($this->withoutRuntimeLoaderSupport) 277 { 278 $arguments.= "--without-runtime-loader-support "; 279 } 280 281 if (!empty($this->targetOption)) 282 { 283 switch ($this->targetOption) 284 { 285 case "replace": 286 case "merge": 287 case "update": 288 case "rename": 289 { 290 $arguments.= "--" . $this->targetOption . "-target "; 291 } break; 292 293 default: 294 { 295 throw new BuildException("Unknown target option '" . $this->targetOption . "'"); 296 } break; 297 } 298 } 299 300 if (!empty($this->encrypt)) 301 { 302 foreach (explode(" ", $this->encrypt) as $encrypt) 303 { 304 $arguments.= "--encrypt '$encrypt' "; 305 } 306 } 307 308 if (!empty($this->licensePath)) 309 { 310 $arguments.= "--with-license '" . $this->licensePath . "' "; 311 } 312 313 if (!empty($this->passPhrase)) 314 { 315 $arguments.= "--passphrase '" . $this->passPhrase . "' "; 316 } 317 318 foreach ($this->comments as $comment) 319 { 320 $arguments.= "--add-comment '" . $comment->getValue() . "' "; 321 } 322 323 if ($this->fromDir != "") 324 { 325 $arguments .= $this->fromDir . " "; 326 } 327 328 if ($this->toDir != "") 329 { 330 $arguments .= "-o " . $this->toDir . " "; 331 } 332 333 return $arguments; 334 } 335 } 336 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |