Public Member Functions | |
| checkCommand ($cmd, $handler='') | |
| checks if a command is valid or not updates global vars | |
| getCommand ($cmd, $handler='', $handlerOpt='') | |
| returns a command string for exec(), system() | |
| addPaths ($paths) | |
| Extend the preset paths. | |
| _getPaths () | |
| set the search paths from different sources | |
| _init () | |
| init | |
| _initPaths ($paths='') | |
| init and extend the preset paths with own | |
|
|
set the search paths from different sources
Definition at line 201 of file class.t3lib_exec.php. References $TYPO3_CONF_VARS, $val, _fixPath(), and _getOS(). Referenced by _initPaths(). 00201 {
00202 global $TYPO3_CONF_VARS;
00203
00204 $pathsArr = array();
00205 $sysPathArr = array();
00206 $osType = t3lib_exec::_getOS();
00207
00208 // image magick paths first
00209 // im_path_lzw take precedence over im_path
00210 if ($imPath = ($TYPO3_CONF_VARS['GFX']['im_path_lzw'] ? $TYPO3_CONF_VARS['GFX']['im_path_lzw'] : $TYPO3_CONF_VARS['GFX']['im_path'])) {
00211 $imPath = t3lib_exec::_fixPath($imPath);
00212 $pathsArr[$imPath] = $imPath;
00213 }
00214
00215 // add configured paths
00216 if ($TYPO3_CONF_VARS['SYS']['binPath']) {
00217 $sysPath = t3lib_div::trimExplode(',',$TYPO3_CONF_VARS['SYS']['binPath'],1);
00218 reset($sysPath);
00219 while(list(,$val)=each($sysPath)) {
00220 $val = t3lib_exec::_fixPath($val);
00221 $sysPathArr[$val]=$val;
00222 }
00223 }
00224
00225
00226
00227
00228 # ???? t3lib_div::getIndpEnv('REQUEST_URI');
00229
00230
00231 // add path from environment
00232 #TODO: how does this work for WIN
00233 if ($GLOBALS['_SERVER']['PATH']) {
00234 $sep = ($osType=='WIN') ? ';' : ':';
00235 $envPath = t3lib_div::trimExplode($sep,$GLOBALS['_SERVER']['PATH'],1);
00236 reset($envPath);
00237 while(list(,$val)=each($envPath)) {
00238 $val = t3lib_exec::_fixPath($val);
00239 $sysPathArr[$val]=$val;
00240 }
00241 }
00242
00243 if ($osType=='WIN') {
00244 #TODO: add the most common paths for WIN
00245 $sysPathArr = array_merge($sysPathArr, array (
00246 '/usr/bin/' => '/usr/bin/',
00247 '/perl/bin/' => '/perl/bin/',
00248 ));
00249 } else { // UNIX
00250 $sysPathArr = array_merge($sysPathArr, array (
00251 '/usr/bin/' => '/usr/bin/',
00252 '/usr/local/bin/' => '/usr/local/bin/',
00253 ));
00254 }
00255
00256 #debug($pathsArr, '$pathsArr', __LINE__, __FILE__);
00257 #debug($GLOBALS['_SERVER']['PATH'], 'PATH', __LINE__, __FILE__);
00258
00259 $pathsArr = array_merge($pathsArr, $sysPathArr);
00260 return $pathsArr;
00261 }
|
|
|
init
Definition at line 269 of file class.t3lib_exec.php. References _initPaths(). Referenced by checkCommand(), and getCommand(). 00269 {
00270 if (!$GLOBALS['t3lib_exec']['init']) {
00271
00272 t3lib_exec::_initPaths();
00273 $GLOBALS['t3lib_exec']['apps'] = array();
00274 $GLOBALS['t3lib_exec']['init'] = true;
00275 }
00276 }
|
|
|
init and extend the preset paths with own
Definition at line 285 of file class.t3lib_exec.php. References _getPaths(), and PATH_site. Referenced by _init(), and addPaths(). |
|
|
Extend the preset paths. This way an extension can install an axecutable and provide the path to t3lib_exec.
Definition at line 191 of file class.t3lib_exec.php. References _initPaths(). 00191 {
00192 t3lib_exec::_initPaths($paths);
00193 }
|
|
||||||||||||
|
checks if a command is valid or not updates global vars
Definition at line 91 of file class.t3lib_exec.php. References _getOS(), and _init(). Referenced by t3lib_svbase::checkExec(), t3lib_extMgm::findService(), and getCommand(). 00091 {
00092
00093 t3lib_exec::_init();
00094 $osType = t3lib_exec::_getOS();
00095
00096
00097 #debug($GLOBALS['t3lib_exec'], 't3lib_exec', __LINE__, __FILE__);
00098
00099 if ($handler && !t3lib_exec::checkCommand($handler)) {
00100 return -1;
00101 }
00102 // already checked and valid
00103 if ($GLOBALS['t3lib_exec']['apps'][$cmd]['valid']) {
00104 return true;
00105 }
00106 // is set but was (above) not true
00107 if (isset($GLOBALS['t3lib_exec']['apps'][$cmd]['valid'])) {
00108 return false;
00109 }
00110
00111 reset($GLOBALS['t3lib_exec']['paths']);
00112 foreach($GLOBALS['t3lib_exec']['paths'] as $path => $validPath) {
00113 // ignore invalid (false) paths
00114 if ($validPath) {
00115 if ($osType=='WIN') {
00116 if (@is_file($path.$cmd)) {
00117 $GLOBALS['t3lib_exec']['apps'][$cmd]['app'] = $cmd;
00118 $GLOBALS['t3lib_exec']['apps'][$cmd]['path'] = $path;
00119 $GLOBALS['t3lib_exec']['apps'][$cmd]['valid'] = true;
00120 return true;
00121 }
00122 if (@is_file($path.$cmd.'.exe')) {
00123 $GLOBALS['t3lib_exec']['apps'][$cmd]['app'] = $cmd.'.exe';
00124 $GLOBALS['t3lib_exec']['apps'][$cmd]['path'] = $path;
00125 $GLOBALS['t3lib_exec']['apps'][$cmd]['valid'] = true;
00126 return true;
00127 }
00128 } else { // UNIX
00129 if (@is_executable($path.$cmd)) {
00130 $GLOBALS['t3lib_exec']['apps'][$cmd]['app'] = $cmd;
00131 $GLOBALS['t3lib_exec']['apps'][$cmd]['path'] = $path;
00132 $GLOBALS['t3lib_exec']['apps'][$cmd]['valid'] = true;
00133 return true;
00134 }
00135 }
00136 }
00137 }
00138
00139 // try to get the executable with the command 'which'. It do the same like already done, but maybe on other paths??
00140 if ($osType=='UNIX') {
00141 $cmd = @exec ('which '.$val['cmd']);
00142
00143 if (@is_executable($cmd)) {
00144 $GLOBALS['t3lib_exec']['apps'][$cmd]['app'] = $cmd;
00145 $GLOBALS['t3lib_exec']['apps'][$cmd]['path'] = dirname($cmd).'/';
00146 $GLOBALS['t3lib_exec']['apps'][$cmd]['valid'] = true;
00147 return true;
00148 }
00149 }
00150
00151 return false;
00152 }
|
|
||||||||||||||||
|
returns a command string for exec(), system()
Definition at line 162 of file class.t3lib_exec.php. References _init(), and checkCommand(). 00162 {
00163
00164 t3lib_exec::_init();
00165
00166 // handler
00167 if ($handler) {
00168 $handler = t3lib_exec::getCommand($handler);
00169
00170 if (!$handler) {
00171 return -1;
00172 }
00173 $handler .= ' '.$handlerOpt.' ';
00174 }
00175
00176 // command
00177 if (!t3lib_exec::checkCommand($cmd)) {
00178 return false;
00179 }
00180 $cmd = $GLOBALS['t3lib_exec']['apps'][$cmd]['path'].$GLOBALS['t3lib_exec']['apps'][$cmd]['app'].' ';
00181
00182 return $handler.$cmd;
00183 }
|
1.3.8-20040913