autoload() 공개 정적인 메소드

Autoload necessary libraries.
public static autoload ( )
예제 #1
0
파일: Element.php 프로젝트: horde/horde
 /**
  * Constructor.
  *
  * @param mixed $data     Data of the part. Either raw PGP data or a
  *                        OpenPGP_Message object.
  * @param array $headers  Header array.
  */
 public function __construct($data, array $headers = array())
 {
     if (!$data instanceof OpenPGP_Message) {
         Horde_Pgp_Backend_Openpgp::autoload();
         $data = OpenPGP_Message::parse($data);
     }
     $this->message = $data;
     $this->headers = $headers;
 }
예제 #2
0
 /**
  */
 public function __construct($data, array $headers = array())
 {
     if (!$data instanceof OpenPGP_Message) {
         Horde_Pgp_Backend_Openpgp::autoload();
         $msg = new OpenPGP_Message();
         /* Trailing (CR)LF is not part of signed data. */
         $pos = strpos($data, '-----BEGIN PGP SIGNATURE-----');
         if ($data[--$pos] === "\r") {
             --$pos;
         }
         $msg[] = new OpenPGP_LiteralDataPacket(self::dashUnescapeText(substr($data, 0, $pos)), array('format' => 'u'));
         $msg[] = Horde_Pgp_Element_Signature::create(substr($data, $pos) . "-----END PGP SIGNATURE-----\n")->message[0];
     } else {
         $msg = $data;
     }
     parent::__construct($msg, $headers);
 }
예제 #3
0
파일: Armor.php 프로젝트: horde/horde
 /**
  */
 public function next()
 {
     $base64 = true;
     $class = $end = $end_armor = $ob_class = $start = null;
     $headers = array();
     $stream = $this->_data;
     while (!($eof = $stream->eof())) {
         $pos = $stream->pos();
         $val = rtrim($stream->getToChar("\n", !is_null($start)));
         if (is_null($end_armor) && strpos($val, '-----BEGIN PGP ') === 0 && substr($val, -5) === '-----') {
             $armor = substr($val, 15, strpos($val, '-', 15) - 15);
             if ($start) {
                 $stream->seek($pos, false);
                 break;
             }
             switch ($armor) {
                 case 'MESSAGE':
                     $class = 'Horde_Pgp_Element_Message';
                     break;
                 case 'PUBLIC KEY BLOCK':
                     $class = 'Horde_Pgp_Element_PublicKey';
                     break;
                 case 'PRIVATE KEY BLOCK':
                     $class = 'Horde_Pgp_Element_PrivateKey';
                     break;
                 case 'SIGNATURE':
                     $class = 'Horde_Pgp_Element_Signature';
                     break;
                 case 'SIGNED MESSAGE':
                     $armor = 'SIGNATURE';
                     $base64 = false;
                     $class = 'Horde_Pgp_Element_SignedMessage';
                     break;
                 default:
                     /* Unknown: ignore. */
                     continue 2;
             }
             $end_armor = '-----END PGP ' . $armor . '-----';
         } elseif (!is_null($end_armor)) {
             if (is_null($start)) {
                 if (strlen($val)) {
                     list($h, $v) = explode(':', $val, 2);
                     $headers[trim($h)] = trim($v);
                 } else {
                     $start = $stream->pos();
                 }
             } elseif ($val === $end_armor) {
                 $end = $pos;
                 $ob_class = $class;
                 break;
             }
         }
     }
     if ($eof && (is_null($this->_key) || is_null($start))) {
         $this->_current = $this->_key = null;
         return;
     }
     if (is_null($ob_class)) {
         $ob_class = 'Horde_Pgp_Element_Text';
     }
     $pos = $stream->pos();
     $data = $stream->getString($start, $end - 1);
     $stream->seek($pos, false);
     if ($base64) {
         /* Get checksum, if it exists. */
         if ($pos = strrpos($data, "\n=")) {
             $checksum = base64_decode(substr($data, $pos + 2, 4));
             $data = base64_decode(substr($data, 0, $pos));
             Horde_Pgp_Backend_Openpgp::autoload();
             $data_checksum = substr(pack('N', OpenPGP::crc24($data)), 1);
             if ($data_checksum !== $checksum) {
                 // Checksum error!
                 return $this->next();
             }
         } else {
             $data = base64_decode($data);
         }
     }
     $this->_current = new $ob_class($data, $headers);
     $this->_key = is_null($this->_key) ? 0 : $this->_key + 1;
 }
예제 #4
0
파일: DSA.php 프로젝트: raz0rsdge/horde
 /**
  * Constructor.
  *
  * @param OpenPGP_PublicKeyPacket $key  Key data.
  */
 public function __construct(OpenPGP_PublicKeyPacket $key)
 {
     Horde_Pgp_Backend_Openpgp::autoload();
     $this->_key = $key;
 }