当前位置: 首页>>代码示例>>PHP>>正文


PHP self::open方法代码示例

本文整理汇总了PHP中self::open方法的典型用法代码示例。如果您正苦于以下问题:PHP self::open方法的具体用法?PHP self::open怎么用?PHP self::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在self的用法示例。


在下文中一共展示了self::open方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: zipTree

 public static function zipTree($dirname, $zipFilename, $flags = 0, $localname = '')
 {
     $zip = new self();
     $zip->open($zipFilename, $flags);
     $zip->addTree($dirname, $localname);
     $zip->close();
 }
开发者ID:phellmes,项目名称:hubzilla,代码行数:7,代码来源:ExtendedZip.php

示例2: createFromFile

 public static function createFromFile($file)
 {
     if (!file_exists($file)) {
         throw new \Exception('File not found.');
     }
     $stream = new self();
     $stream->open($file);
     $stream->alpha();
     return $stream;
 }
开发者ID:johnnysacrifice,项目名称:zap,代码行数:10,代码来源:zap-stream.php

示例3: zipTree

 public static function zipTree($dirname, $zipFilename, $flags = 0, $localname = '')
 {
     $zip = new self();
     if (file_exists($zipFilename)) {
         unlink($zipFilename);
     }
     $zip->open($zipFilename, ZipArchive::CREATE);
     $zip->addTree($dirname, $localname);
     $zip->close();
 }
开发者ID:rachidkada,项目名称:MRN_PRO,代码行数:10,代码来源:MZip.class.php

示例4: newFromContext

 /**
  * Creates a Database object, opens the connection and returns the instance.
  *
  * @param context TestSwarmContext
  * @param $connType int: [optional]
  */
 public static function newFromContext(TestSwarmContext $context, $connType = SWARM_DBCON_DEFAULT)
 {
     $dbConf = $context->getConf()->database;
     $db = new self();
     $db->context = $context;
     $db->host = $dbConf->host;
     $db->username = $dbConf->username;
     $db->password = $dbConf->password;
     $db->dbname = $dbConf->database;
     $db->open($connType);
     return $db;
 }
开发者ID:rosssclafani,项目名称:testswarm,代码行数:18,代码来源:Database.php

示例5: connect

 /**
  * Establish LDAP connection
  *
  * @static
  * @access public
  * @param  string $username
  * @param  string $password
  * @return Client
  */
 public static function connect($username = null, $password = null)
 {
     $client = new self();
     $client->open($client->getLdapServer());
     $username = $username ?: $client->getLdapUsername();
     $password = $password ?: $client->getLdapPassword();
     if (empty($username) && empty($password)) {
         $client->useAnonymousAuthentication();
     } else {
         $client->authenticate($username, $password);
     }
     return $client;
 }
开发者ID:phpCedu,项目名称:kanboard,代码行数:22,代码来源:Client.php

示例6: updateSitemapIndex

 /**
  * Adds sitemaps $aSitemaps to index $sFilename. If index doesn't exists it will be created.
  * 
  * @param string $aSitemaps
  * @param string $sFilename
  * @param bool $bSaveCompressed
  */
 public static function updateSitemapIndex($aSitemaps, $sFilename, $bSaveCompressed = true)
 {
     if (file_exists($sFilename)) {
         $oSitemapIndex = new self();
         $oSitemapIndex->open($sFilename);
     } else {
         $oSitemapIndex = new self();
     }
     $oSitemapIndex->addSitemaps($aSitemaps);
     if ($bSaveCompressed == true) {
         $oSitemapIndex->saveCompressed($sFilename);
     } else {
         $oSitemapIndex->saveUncompressed($sFilename);
     }
 }
开发者ID:JanChristiansen,项目名称:LargeXMLSitemap,代码行数:22,代码来源:class.xmlSitemapIndex.php

示例7: make

 /**
  * Creates a new empty zip file.
  * @param  string $destination Path for the new zip
  * @param  mixed  $source
  * @return self
  */
 public static function make($destination, $source)
 {
     $zip = new self();
     $zip->open($destination, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE);
     if (is_string($source)) {
         $zip->add($source);
     } elseif (is_callable($source)) {
         $source($zip);
     } elseif (is_array($source)) {
         foreach ($source as $_source) {
             $zip->add($_source);
         }
     }
     $zip->close();
     return $zip;
 }
开发者ID:jBOKA,项目名称:library,代码行数:22,代码来源:Zip.php

示例8: send

 public function send($data = null)
 {
     if ($this->ready_state !== 1) {
         self::throw_error('Invalid state; Cannot send unopened request', E_RECOVERABLE_ERROR);
     }
     // Build the data string
     if (!is_string($data) && $data !== null) {
         if (is_array($data)) {
             $data_arr = '';
             foreach ($data as $name => $value) {
                 $data_arr[] = urlencode($name) . ' = ' . urlencode($value);
             }
             $data = implode('&', $data_arr);
         } else {
             self::throw_error('Invalid data parameter given; Expects string, array, or NULL', E_RECOVERABLE_ERROR);
         }
     }
     // Build the request
     $request = $this->method . ' ' . $this->url_info['path'] . ' HTTP/1.1' . CRLF;
     $request .= 'Host: ' . $this->url_info['host'] . CRLF;
     foreach ($this->headers as $name => $value) {
         $request .= $name . ': ' . $value . CRLF;
     }
     $request .= CRLF . $data;
     // Send the request
     $response = '';
     fputs($this->fh, $request);
     while (!feof($this->fh)) {
         $response .= fgets($this->fh, 128);
     }
     fclose($this->fh);
     // Seperate the response
     $response = explode(CRLF . CRLF, $response, 2);
     $headers = explode(CRLF, $response[0]);
     $this->response_body = $response[1];
     // Parse the response status
     $http = array_shift($headers);
     preg_match('/^HTTP\\/[0-9.]+ ([0-9]{3}) (.*)$/', $http, $match);
     $this->status = (int) $match[1];
     $this->status_text = $match[2];
     // Parse the headers
     $parsed_headers = array();
     foreach ($headers as $header) {
         $header = explode(': ', $header, 2);
         $parsed_headers[$header[0]] = $header[1];
     }
     $this->response_headers = $parsed_headers;
     // Check for a location header
     if (isset($this->response_headers['Location'])) {
         $location = $this->response_headers;
         $sub_request = new self();
         $sub_request->__is_redirect($this->redirect_stack);
         $sub_request->open($this->method, $location);
         if ($sub_request->error_code) {
             $this->error_code = $sub_request->error_code;
             return false;
         }
         foreach ($this->headers as $name => $value) {
             $sub_request->set_request_header($name, $value);
         }
         $sub_request->send($data);
         $this->response_text = $sub_request->response_text;
         $this->response_headers = $sub_request->get_all_response_headers();
         $this->status_code = $sub_request->status_code;
         $this->status_text = $sub_request->status_text;
     }
     // All done
     $this->ready_state = 4;
     return $this;
 }
开发者ID:kbjr,项目名称:PHPHttpRequest,代码行数:70,代码来源:PHPHttpRequest.php

示例9: createFromFile

 /**
  * 
  * @param string $tmp_name path to file
  * @param string $type mime type
  * @return self
  * @throws Exception
  */
 public static function createFromFile($tmp_name, $type)
 {
     $mime_type = ElggFile::detectMimeType($tmp_name, $type);
     if (false == in_array($mime_type, array("image/jpeg", "image/jpg"))) {
         register_error(elgg_echo("gallery_field:only_jpg"));
         return null;
     }
     $ext = "jpg";
     $file = new self();
     $thumb_file = new ElggFile();
     $random_guid = self::genGUID();
     $file->setFilename($random_guid . "." . $ext);
     $thumb_file->setFilename($random_guid . "_thumb." . $ext);
     $file->setMimeType($mime_type);
     $thumb_file->setMimeType($mime_type);
     $imgsizearray = getimagesize($tmp_name);
     if ($imgsizearray == false) {
         register_error("bad file");
         return null;
     }
     $width = $imgsizearray[0];
     $height = $imgsizearray[1];
     $file->open("write");
     $file->write(self::cropImage($tmp_name, $width, $height, 760, 580));
     $file->close();
     $file->access_id = 2;
     $thumb_file->open("write");
     $thumb_file->write(self::cropImage($tmp_name, $width, $height, 200, 140));
     $thumb_file->close();
     $thumb_file->access_id = 2;
     $thumb_file->save();
     $file->thumb_file_guid = $thumb_file->guid;
     $file->save();
     return $file;
 }
开发者ID:serega3000,项目名称:elgg_gallery_field,代码行数:42,代码来源:GalleryFieldImage.php

示例10: group

 /**
  * @param $name
  * @param Closure $builder
  * @return $this
  */
 public function group($name, Closure $builder)
 {
     $instance = new self($this->presenter, $this->dataStore, $this->config);
     $instance->open($this->open->name)->bare();
     $builder($instance);
     $instance->close();
     $this->elements[$name ?: 'element-' . count($this->elements)] = $instance;
     return $this;
 }
开发者ID:laraplus,项目名称:form,代码行数:14,代码来源:Form.php

示例11: fromFile

 /**
  * Creates new Image object from image file
  *
  * @param string $pathToFile Path to image file
  * @return self
  */
 public static function fromFile($pathToFile)
 {
     $newImage = new self();
     $newImage->open($pathToFile);
     return $newImage;
 }
开发者ID:petrknap,项目名称:php-image,代码行数:12,代码来源:Image.php

示例12: getArchive

 /**
  * Returns an ArchiveInfo object for an embedded archive file with the contents
  * analyzed (initially without recursion). Calls to this method can also be
  * chained together to navigate the tree, e.g.:
  *
  *    $rar->getArchive('parent.rar')->getArchive('child.zip')->getFileList();
  *
  * @param   string   $filename   the embedded archive filename
  * @return  ArchiveInfo|boolean  false if an object can't be returned
  */
 public function getArchive($filename)
 {
     if (!$this->reader || !$this->allowsRecursion()) {
         return false;
     }
     // Check the cache first
     if (isset($this->archives[$filename])) {
         return $this->archives[$filename];
     }
     foreach ($this->reader->getFileList(true) as $file) {
         if ($file['name'] == $filename && isset($file['range'])) {
             // Create the new archive object
             $archive = new self();
             $archive->externalClients = $this->externalClients;
             $archive->extensions = $this->extensions;
             if ($this->inheritReaders) {
                 $archive->setReaders($this->readers, true);
             }
             // Extract any compressed data to a temporary file if supported
             if ($this->canExtract() && !empty($file['compressed']) && empty($file['pass'])) {
                 list($hash, $temp) = $this->getTempFileName("{$file['name']}:{$file['range']}");
                 if (!isset($this->tempFiles[$hash])) {
                     $this->reader->extractFile($file['name'], $temp);
                     @chmod($temp, 0777);
                     $this->tempFiles[$hash] = $temp;
                 }
                 if ($this->reader->error) {
                     $archive->error = $this->reader->error;
                     $archive->readers = array();
                 } else {
                     $archive->open($temp, $this->isFragment);
                     $archive->isTemporary = true;
                 }
                 return $archive;
             }
             // Otherwise we shouldn't process any files that are unreadable
             if (!empty($file['compressed']) || !empty($file['pass'])) {
                 $archive->readers = array();
             }
             // Try to parse the raw source file/data
             $range = explode('-', $file['range']);
             if ($this->file) {
                 $archive->open($this->file, $this->isFragment, $range);
             } else {
                 $archive->setData($this->data, $this->isFragment, $range);
             }
             // Make error messages more specific
             if (!empty($file['compressed'])) {
                 $archive->error = 'The archive is compressed and cannot be read';
             }
             if (!empty($file['pass']) || !empty($archive->isEncrypted)) {
                 $archive->error = 'The archive is encrypted and cannot be read';
             }
             return $archive;
         }
     }
     // Something went wrong
     return false;
 }
开发者ID:kaibosh,项目名称:nZEDb,代码行数:69,代码来源:archiveinfo.php

示例13: log

 /**
  * Insertion rapide dans un fichier de log
  */
 public static function log($file, $line)
 {
     $csv = new self();
     $csv->open($file);
     $csv->addLine($line);
 }
开发者ID:johnstyle,项目名称:sjo,代码行数:9,代码来源:Csv.php


注:本文中的self::open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。