Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * $Id: IoncubeLicenseTask.php 325 2007-12-20 15:44:58Z hans $
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 "make_license" program
27
 *
28
 * @author Michiel Rook <michiel.rook@gmail.com>
29
 * @version $Id: IoncubeLicenseTask.php 325 2007-12-20 15:44:58Z hans $
30
 * @package phing.tasks.ext.ioncube
31
 * @since 2.2.0
32
 */
33
class IoncubeLicenseTask extends Task
34
{
35
	private $ioncubePath = "/usr/local/ioncube";
36
 
37
	private $licensePath = "";
38
	private $passPhrase = "";
39
 
40
	private $comments = array();
41
 
42
	/**
43
	 * Sets the path to the ionCube encoder
44
	 */
45
	function setIoncubePath($ioncubePath)
46
	{
47
		$this->ioncubePath = $ioncubePath;
48
	}
49
 
50
	/**
51
	 * Returns the path to the ionCube encoder
52
	 */
53
	function getIoncubePath()
54
	{
55
		return $this->ioncubePath;
56
	}
57
 
58
	/**
59
	 * Sets the path to the license file to use
60
	 */
61
	function setLicensePath($licensePath)
62
	{
63
		$this->licensePath = $licensePath;
64
	}
65
 
66
	/**
67
	 * Returns the path to the license file to use
68
	 */
69
	function getLicensePath()
70
	{
71
		return $this->licensePath;
72
	}
73
 
74
	/**
75
	 * Sets the passphrase to use when encoding files
76
	 */
77
	function setPassPhrase($passPhrase)
78
	{
79
		$this->passPhrase = $passPhrase;
80
	}
81
 
82
	/**
83
	 * Returns the passphrase to use when encoding files
84
	 */
85
	function getPassPhrase()
86
	{
87
		return $this->passPhrase;
88
	}
89
 
90
	/**
91
	 * Adds a comment to be used in encoded files
92
	 */
93
	function addComment(IoncubeComment $comment)
94
	{
95
		$this->comments[] = $comment;
96
	}
97
 
98
	/**
99
	 * The main entry point
100
	 *
101
	 * @throws BuildException
102
	 */
103
	function main()
104
	{
105
		$arguments = $this->constructArguments();
106
 
107
		$makelicense = new PhingFile($this->ioncubePath, 'make_license');
108
 
109
		$this->log("Running ionCube make_license...");
110
 
111
		exec($makelicense->__toString() . " " . $arguments . " 2>&1", $output, $return);
112
 
113
        if ($return != 0)
114
        {
115
			throw new BuildException("Could not execute ionCube make_license: " . implode(' ', $output));
116
        }
117
	}
118
 
119
	/**
120
	 * Constructs an argument string for the ionCube make_license
121
	 */
122
	private function constructArguments()
123
	{
124
		$arguments = "";
125
 
126
		if (!empty($this->passPhrase))
127
		{
128
			$arguments.= "--passphrase '" . $this->passPhrase . "' ";
129
		}
130
 
131
		foreach ($this->comments as $comment)
132
		{
133
			$arguments.= "--header-line '" . $comment->getValue() . "' ";
134
		}
135
 
136
		if (!empty($this->licensePath))
137
		{
138
			$arguments.= "--o '" . $this->licensePath . "' ";
139
		}
140
 
141
		return $arguments;
142
	}
143
}