コード例 #1
0
 /**
  * Class Constructor
  */
 function Image_Transform_Driver_NetPBM()
 {
     if (!defined('IMAGE_TRANSFORM_LIB_PATH')) {
         include_once 'System/Command.php';
         $path = str_replace('pnmscale', '', escapeshellcmd(System_Command::which('pnmscale')));
         define('IMAGE_TRANSFORM_LIB_PATH', $path);
     }
     return true;
 }
コード例 #2
0
ファイル: fs.php プロジェクト: Rudi9719/lucid
 function mime_content_type($file)
 {
     $cmd = new System_Command();
     if (!$cmd->which("file")) {
         unset($cmd);
         return false;
     }
     $cmd->pushCommand("file", "-bi '{$file}'");
     $res = $cmd->execute();
     unset($cmd);
     return $res;
 }
コード例 #3
0
ファイル: Type.php プロジェクト: chajianku/admin_eXtplorer
 /**
  * Autodetect a file's MIME-type with 'file' and System_Command
  *
  * This function may be called staticly.
  *
  * @param  string $file   Path to the file to get the type of
  * @return string $file's MIME-type
  * @since 1.0.0beta1
  * @static
  */
 function _fileAutoDetect($file)
 {
     // Sanity checks
     if (!file_exists($file)) {
         return PEAR::raiseError("File \"{$file}\" doesn't exist");
     }
     if (!is_readable($file)) {
         return PEAR::raiseError("File \"{$file}\" is not readable");
     }
     $cmd = new System_Command();
     // Make sure we have the 'file' command.
     $fileCmd = PEAR::getStaticProperty('MIME_Type', 'fileCmd');
     if (!$cmd->which($fileCmd)) {
         unset($cmd);
         return PEAR::raiseError("Can't find file command \"{$fileCmd}\"");
     }
     $cmd->pushCommand($fileCmd, "-bi '{$file}'");
     $res = $cmd->execute();
     unset($cmd);
     return $res;
 }
コード例 #4
0
 /**
  * Autodetect a file's MIME-type with 'file' and System_Command
  *
  * This function may be called staticly.
  *
  * @param string $file Path to the file to get the type of
  *
  * @return string $file's MIME-type
  *
  * @since 1.0.0beta1
  * @static
  */
 function _fileAutoDetect($file)
 {
     $cmd = new System_Command();
     $magic = '';
     // Make sure we have the 'file' command.
     $fileCmd = PEAR::getStaticProperty('MIME_Type', 'fileCmd');
     if (!$cmd->which($fileCmd)) {
         unset($cmd);
         return PEAR::raiseError("Can't find file command \"{$fileCmd}\"");
     }
     if (strlen($this->magicFile)) {
         $magic = '--magic-file ' . escapeshellarg($this->magicFile);
     }
     $cmd->pushCommand($fileCmd, $magic, "-bi " . escapeshellarg($file));
     $res = $cmd->execute();
     unset($cmd);
     return $res;
 }
コード例 #5
0
ファイル: LDAP.php プロジェクト: noikiy/owaspbwa
 function addUser2($username, $password, $additional)
 {
     include_once "System/Command.php";
     // build up the admin user's Distinguished Name
     $adminuser = escapeshellcmd(trim($this->options["adminuser"]));
     $adminpass = escapeshellcmd(trim($this->options["adminpass"]));
     $basedn = $this->options["basedn"];
     $useroc = $this->options["useroc"];
     $userdn = $this->options["userdn"];
     $userattr = $this->options["userattr"];
     $status = "";
     // flow:
     // make sure we have all the required variables
     if (empty($username) || $username == "") {
         $status = "User's name cannot be blank";
     } elseif (empty($password) || $password == "") {
         $status = "User's password cannot be blank";
     } elseif (!isset($additional["email"])) {
         $status = "User's email address cannot be blank";
     } elseif (empty($this->options["adminuser"]) || $this->options["adminuser"] == "") {
         $status = "adminuser cannot be blank";
     } elseif (empty($this->options["adminpass"]) || $this->options["adminpass"] == "") {
         $status = "adminpass cannot be blank";
     }
     // if we've gotten an error message already, just exit
     if ($status != "") {
         return new PEAR_Error($status, PEAR_ERROR_RETURN);
     }
     $command = "ldapmodify";
     $arguments = " -a -x -D \"" . $adminuser . "\" -w \"" . $adminpass . "\"";
     if (!empty($userdn)) {
         $userdn .= ",";
     }
     $input = "dn: " . $userattr . "=" . $username . "," . $userdn . $basedn . "\n" . $userattr . ": " . $username . "\n" . "sn: " . $username . "\n" . "userPassword: "******"\n" . "mail: " . $additional["email"] . "\n" . "objectClass: top\n" . "objectClass: " . $useroc . "\n" . "\n\n";
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
     // workout whether we have the ldapmodify command or not
     $cmd = new System_Command();
     $command = $cmd->which($command);
     $cmd = null;
     $result = "";
     // if the command wasn't found, just exit
     if ($command == false) {
         $status = "Unable to find required command 'ldapmodify'.";
     } else {
         // open the process
         $process = proc_open($command . $arguments, $descriptorspec, $pipes);
         // make sure it worked
         if (is_resource($process)) {
             // write out the creation strings
             fwrite($pipes[0], $input);
             fclose($pipes[0]);
             // get the input
             while (!feof($pipes[1])) {
                 $result .= fgets($pipes[1], 1024);
             }
             fclose($pipes[1]);
             $return = proc_close($process);
             $pos = strstr($result, "adding new entry");
             if ($return == 0 && $pos != false) {
                 return true;
             } else {
                 $status = "Arguments: {$arguments}\nResult: " . $return . "\n" . $result . "\n\nInput:\n" . $input;
             }
         } else {
             $status = "Failed to open command.";
         }
     }
     if ($this->debug != false) {
         mail($this->debug, "adduser", $status);
     }
     return PEAR::raiseError("Auth_Container_LDAP: " . $status, -1, PEAR_ERROR_PRINT);
 }