本文整理匯總了PHP中Shell::ExecuteRaw方法的典型用法代碼示例。如果您正苦於以下問題:PHP Shell::ExecuteRaw方法的具體用法?PHP Shell::ExecuteRaw怎麽用?PHP Shell::ExecuteRaw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Shell
的用法示例。
在下文中一共展示了Shell::ExecuteRaw方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Create
/**
* Create new system user
* @access public
* @param string $username System username
* @param string $password Password
* @param string $homedir Home directory
* @param string $shell Shell path
* @return SystemUser SystemUser instance
*/
public function Create($username, $password, $homedir = NULL, $shell = NULL)
{
// Check if skel exists
if ($this->SkelDir && !is_readable($this->SkelDir))
Core::RaiseError(sprintf(_("User home skeleton directory (%s) not readable"), self::SKEL_DIR));
// Get default shell
if (!$shell)
$shell = $this->ShellPath;
//Get default homedir
if (!$homedir)
$homedir = self::HOME_DIR ."/". $username;
// Check useradd tool
if (!is_executable($this->UserAddPath))
Core::RaiseError(sprintf(_("%s not executable"), $this->UserAddPath));
//Check chpasswd tool
if (!is_executable($this->ChpasswdPath))
Core::RaiseError(sprintf(_("%s not executable"), $this->ChpasswdPath));
if ($this->SkelDir)
$skeldir = "-k {$this->SkelDir}";
if ($this->SystemStats->IsFreeBSD)
$args = "useradd {$username} -d {$homedir} -g {$this->UserGroup} {$skeldir} -s {$shell}";
else
$args = " -d {$homedir} -s {$shell} -m {$skeldir} {$username}";
$retval = $this->Shell->ExecuteRaw("{$this->UserAddPath} {$args}");
if ($this->SystemStats->IsFreeBSD)
$retval &= $this->Shell->ExecuteRaw("echo '{$password}' | {$this->ChpasswdPath} usermod {$username} $1 -h 0");
else
$retval &= $this->Shell->ExecuteRaw("echo {$username}:{$password} | {$this->ChpasswdPath}");
// Return SystemUser or false
$retval = $retval ? $this->GetUserByName($username) : false;
return($retval);
}