Remove the extra path part
[viewsvn.git] / includes / shellcmd.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # ViewSVN [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Class that interacts with the command line system
24 *
25 * @pacakge ViewSVN
26 */
27
28 /**
29 * Interacts with the command line via escapes and executions
30 *
31 * @package ViewSVN
32 * @version $Id$
33 */
34 class Shell
35 {
36 /**
37 * Controller
38 * @var object
39 * @access private
40 */
41 var $controller = null;
42
43 // ###################################################################
44 /**
45 * Constructor
46 *
47 * @access public
48 *
49 * @param object Controller
50 */
51 function Shell(&$controller)
52 {
53 $this->controller =& $controller;
54 }
55
56 /**
57 * Wrapper for escapeshellarg()
58 *
59 * @access public
60 *
61 * @param string The argument
62 *
63 * @return string Cleaned argument
64 */
65 function arg($argument)
66 {
67 return escapeshellarg($argument);
68 }
69
70 /**
71 * Wrapper for escapeshellcmd
72 *
73 * @access public
74 *
75 * @param string Command
76 *
77 * @return string Cleaned command
78 */
79 function cmd($command)
80 {
81 return escapeshellcmd($command);
82 }
83
84 /**
85 * Executes a shell command and returns all the output
86 * as an array
87 *
88 * @access public
89 *
90 * @param string UNIX command
91 *
92 * @return array Output
93 */
94 function exec($command)
95 {
96 $start = microtime();
97
98 exec($command, $output);
99
100 $this->controller->registry->debug("exec(" . $this->controller->registry->funct->fetch_microtime_diff($start) . "): $command");
101
102 return $output;
103 }
104 }
105
106 /*=====================================================================*\
107 || ###################################################################
108 || # $HeadURL$
109 || # $Id$
110 || ###################################################################
111 \*=====================================================================*/
112 ?>