本文整理汇总了PHP中PEAR::loadExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::loadExtension方法的具体用法?PHP PEAR::loadExtension怎么用?PHP PEAR::loadExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR
的用法示例。
在下文中一共展示了PEAR::loadExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Check settings
*
* @since PHP 5
*/
public function __construct()
{
if (!PEAR::loadExtension('gd')) {
$this->isError(PEAR::raiseError("GD library is not available.", IMAGE_TRANSFORM_ERROR_UNSUPPORTED));
} else {
$types = ImageTypes();
if ($types & IMG_PNG) {
$this->_supported_image_types['png'] = 'rw';
}
if ($types & IMG_GIF || function_exists('imagegif')) {
$this->_supported_image_types['gif'] = 'rw';
} elseif (function_exists('imagecreatefromgif')) {
$this->_supported_image_types['gif'] = 'r';
}
if ($types & IMG_JPG) {
$this->_supported_image_types['jpeg'] = 'rw';
}
if ($types & IMG_WBMP) {
$this->_supported_image_types['wbmp'] = 'rw';
}
if (!$this->_supported_image_types) {
$this->isError(PEAR::raiseError("No supported image types available", IMAGE_TRANSFORM_ERROR_UNSUPPORTED));
}
}
}
示例2: Image_Transform_Driver_Imagick
/**
*
*
*/
function Image_Transform_Driver_Imagick()
{
if (!PEAR::loadExtension('imagick')) {
return PEAR::raiseError('The imagick extension can not be found.', true);
}
include 'Image/Transform/Driver/Imagick/ImageTypes.php';
return true;
}
示例3: __construct
/**
* @see http://www.imagemagick.org/www/formats.html
*/
function __construct()
{
if (PEAR::loadExtension('imagick')) {
include 'Image/Transform/Driver/Imagick/ImageTypes.php';
} else {
$this->isError(PEAR::raiseError('Couldn\'t find the imagick extension.', IMAGE_TRANSFORM_ERROR_UNSUPPORTED));
}
}
示例4: Image_Transform_Driver_Imagick
/**
*
*
*/
function Image_Transform_Driver_Imagick()
{
if (!extension_loaded('imagick')) {
if (!PEAR::loadExtension('imagick')) {
return PEAR::raiseError('The imagick extension can not be found.', true);
}
}
return true;
}
示例5: Auth_Container_SAP
/**
* Class constructor. Checks that required options
* are present and that the SAPRFC extension is loaded
*
* Options that can be passed and their defaults:
* <pre>
* array(
* 'ASHOST' => "",
* 'SYSNR' => "",
* 'CLIENT' => "000",
* 'GWHOST' =>"",
* 'GWSERV' =>"",
* 'MSHOST' =>"",
* 'R3NAME' =>"",
* 'GROUP' =>"",
* 'LANG' =>"EN",
* 'TRACE' =>"",
* 'GETSSO2'=> true
* )
* </pre>
*
* @param array array of options.
* @return void
*/
function Auth_Container_SAP($options)
{
$saprfc_loaded = PEAR::loadExtension('saprfc');
if (!$saprfc_loaded) {
return PEAR::raiseError('Cannot use SAP authentication, ' . 'SAPRFC extension not loaded!');
}
if (empty($options['R3NAME']) && empty($options['ASHOST'])) {
return PEAR::raiseError('R3NAME or ASHOST required for authentication');
}
$this->options = array_merge($this->options, $options);
}
示例6: testsetGzip
function testsetGzip()
{
$h =& new HTTP_Download();
$this->assertFalse(PEAR::isError($h->setGzip(false)), '$h->setGzip(false)');
$this->assertFalse($h->gzip, '$h->gzip');
if (PEAR::loadExtension('zlib')) {
$this->assertFalse(PEAR::isError($h->setGzip(true)), '$h->setGzip(true) without ext/zlib');
$this->assertTrue($h->gzip, '$h->gzip');
} else {
$this->assertTrue(PEAR::isError($h->setGzip(true)), '$h->setGzip(true) with ext/zlib');
$this->assertFalse($h->gzip, '$h->gzip');
}
unset($h);
}
示例7: __construct
/**
* Check settings
*
* @return mixed true or or a PEAR error object on error
*
* @see PEAR::isError()
*/
function __construct()
{
if (!PEAR::loadExtension('imlib')) {
$this->isError(PEAR::raiseError('Couldn\'t find the imlib extension.', IMAGE_TRANSFORM_ERROR_UNSUPPORTED));
}
}
示例8: connect
/**
* Connect to the database
*
* @return true on success, MDB2 Error Object on failure
**/
function connect()
{
$database_file = $this->_getDatabaseFile($this->database_name);
if (is_resource($this->connection)) {
if (count(array_diff($this->connected_dsn, $this->dsn)) == 0 && $this->connected_database_name == $database_file && $this->opened_persistent == $this->options['persistent']) {
return MDB2_OK;
}
$this->disconnect(false);
}
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'extension ' . $this->phptype . ' is not compiled into PHP', __FUNCTION__);
}
if (!empty($this->database_name)) {
if ($database_file !== ':memory:') {
if (!file_exists($database_file)) {
if (!touch($database_file)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not create database file', __FUNCTION__);
}
if (!isset($this->dsn['mode']) || !is_numeric($this->dsn['mode'])) {
$mode = 0644;
} else {
$mode = octdec($this->dsn['mode']);
}
if (!chmod($database_file, $mode)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not be chmodded database file', __FUNCTION__);
}
if (!file_exists($database_file)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'Could not be found database file', __FUNCTION__);
}
}
if (!is_file($database_file)) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null, 'Database is a directory name', __FUNCTION__);
}
if (!is_readable($database_file)) {
return $this->raiseError(MDB2_ERROR_ACCESS_VIOLATION, null, null, 'Could not read database file', __FUNCTION__);
}
}
$connect_function = $this->options['persistent'] ? 'sqlite_popen' : 'sqlite_open';
$php_errormsg = '';
if (version_compare('5.1.0', PHP_VERSION, '>')) {
@ini_set('track_errors', true);
$connection = @$connect_function($database_file);
@ini_restore('track_errors');
} else {
$connection = @$connect_function($database_file, 0666, $php_errormsg);
}
$this->_lasterror = $php_errormsg;
if (!$connection) {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
if (!empty($this->dsn['charset'])) {
$result = $this->setCharset($this->dsn['charset'], $connection);
if (PEAR::isError($result)) {
return $result;
}
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $database_file;
$this->opened_persistent = $this->getoption('persistent');
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
}
return MDB2_OK;
}
示例9: define
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Dave Mertens <dmertens@zyprexia.com> |
// +----------------------------------------------------------------------+
//
// $Id: Basex.php,v 1.6 2003/06/04 14:48:44 et Exp $
require_once "PEAR.php";
if (!defined('MATH_BASEX_MATHEXTENSION')) {
if (PEAR::loadExtension('bcmath')) {
define('MATH_BASEX_MATHEXTENSION', 'bcmath');
} elseif (PEAR::loadExtension('gmp')) {
define('MATH_BASEX_MATHEXTENSION', 'gmp');
} else {
define('MATH_BASEX_MATHEXTENSION', 'none');
}
}
/**
* base X coding class
*
* I noticed that value of an int is different on most systems.
* On my system (linux 2.4.18 with glibc 2.2.5) i can use 8-byte integers
* (also called int64 or int8)
* On my laptop (Windows 2000) i only could use numbers up to 4-byte (32 bit)
* integers.
* So you might want to test this first!
*
示例10: connect
/**
* Connect to the database server, log in and open the database
*
* Don't call this method directly. Use DB::connect() instead.
*
* @param array $dsn the data source name
* @param bool $persistent should the connection be persistent?
*
* @return int DB_OK on success. A DB_Error object on failure.
*/
function connect($dsn, $persistent = false)
{
if (!PEAR::loadExtension('fbsql')) {
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
}
$this->dsn = $dsn;
if ($dsn['dbsyntax']) {
$this->dbsyntax = $dsn['dbsyntax'];
}
$params = array($dsn['hostspec'] ? $dsn['hostspec'] : 'localhost', $dsn['username'] ? $dsn['username'] : null, $dsn['password'] ? $dsn['password'] : null);
$connect_function = $persistent ? 'fbsql_pconnect' : 'fbsql_connect';
$ini = ini_get('track_errors');
$php_errormsg = '';
if ($ini) {
$this->connection = @call_user_func_array($connect_function, $params);
} else {
@ini_set('track_errors', 1);
$this->connection = @call_user_func_array($connect_function, $params);
@ini_set('track_errors', $ini);
}
if (!$this->connection) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, $php_errormsg);
}
if ($dsn['database']) {
if (!@fbsql_select_db($dsn['database'], $this->connection)) {
return $this->fbsqlRaiseError();
}
}
return DB_OK;
}
示例11: array
/**
* Creates a new Image_Transform object
*
* @param string $driver name of driver class to initialize. If no driver
* is specified the factory will attempt to use 'Imagick' first
* then 'GD' second, then 'Imlib' last
*
* @return object an Image_Transform object, or PEAR_Error on error
*
* @see PEAR::isError()
* @see Image_Transform::setOption()
*/
static function &factory($driver = '')
{
if ($driver == '') {
$extensions = array('imagick' => 'Imagick2', 'gd' => 'GD', 'imlib' => 'Imlib');
foreach ($extensions as $ext => $ext_driver) {
if (PEAR::loadExtension($ext)) {
$driver = $ext_driver;
break;
}
}
if (!$driver) {
return PEAR::raiseError('No image library specified and none can be found. You must specify driver in factory() call.', IMAGE_TRANSFORM_ERROR_ARGUMENT);
}
}
@(include_once 'Image/Transform/Driver/' . basename($driver) . '.php');
$classname = "Image_Transform_Driver_{$driver}";
if (!class_exists($classname)) {
return PEAR::raiseError('Image library not supported... aborting.', IMAGE_TRANSFORM_ERROR_UNSUPPORTED);
}
$obj = new $classname();
// Check startup error
if ($error = $obj->isError()) {
$obj = $error;
}
return $obj;
}
示例12: Archive_Zip
/**
* Archive_Zip Class constructor. This flavour of the constructor only
* declare a new Archive_Zip object, identifying it by the name of the
* zip file.
*
* @param string $p_zipname The name of the zip archive to create
* @access public
*/
function Archive_Zip($p_zipname)
{
// ----- Check the zlib
if (!extension_loaded('zlib')) {
PEAR::loadExtension('zlib');
}
if (!extension_loaded('zlib')) {
die("The extension 'zlib' couldn't be found.\n" . "Please make sure your version of PHP was built " . "with 'zlib' support.\n");
return false;
}
// ----- Set the attributes
$this->_zipname = $p_zipname;
$this->_zip_fd = 0;
return;
}
示例13: connect
/**
* Connect to the database server, log in and open the database
*
* Don't call this method directly. Use DB::connect() instead.
*
* PEAR DB's sybase driver supports the following extra DSN options:
* + appname The application name to use on this connection.
* Available since PEAR DB 1.7.0.
* + charset The character set to use on this connection.
* Available since PEAR DB 1.7.0.
*
* @param array $dsn the data source name
* @param bool $persistent should the connection be persistent?
*
* @return int DB_OK on success. A DB_Error object on failure.
*/
function connect($dsn, $persistent = false)
{
if (!PEAR::loadExtension('sybase') && !PEAR::loadExtension('sybase_ct')) {
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
}
$this->dsn = $dsn;
if ($dsn['dbsyntax']) {
$this->dbsyntax = $dsn['dbsyntax'];
}
$dsn['hostspec'] = $dsn['hostspec'] ? $dsn['hostspec'] : 'localhost';
$dsn['password'] = !empty($dsn['password']) ? $dsn['password'] : false;
$dsn['charset'] = isset($dsn['charset']) ? $dsn['charset'] : false;
$dsn['appname'] = isset($dsn['appname']) ? $dsn['appname'] : false;
$connect_function = $persistent ? 'sybase_pconnect' : 'sybase_connect';
if ($dsn['username']) {
$this->connection = @$connect_function($dsn['hostspec'], $dsn['username'], $dsn['password'], $dsn['charset'], $dsn['appname']);
} else {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, 'The DSN did not contain a username.');
}
if (!$this->connection) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, @sybase_get_last_message());
}
if ($dsn['database']) {
if (!@sybase_select_db($dsn['database'], $this->connection)) {
return $this->raiseError(DB_ERROR_NODBSELECTED, null, null, null, @sybase_get_last_message());
}
$this->_db = $dsn['database'];
}
return DB_OK;
}
示例14: connect
/**
* Connect and bind to LDAP server with either anonymous or authenticated bind depending on dsn info
*
* @param array $dsninfo dsn info as passed by DB::connect()
* @param boolean $persistent kept for interface compatibility
* @return DB_OK if successfully connected. A DB error code is returned on failure.
*/
function connect($dsninfo, $persistent = false)
{
if (!PEAR::loadExtension('ldap')) {
return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
}
$this->dsn = $dsninfo;
$user = $dsninfo['username'];
$pw = $dsninfo['password'];
$host = $dsninfo['hostspec'];
$port = $dsninfo['port'];
$this->base = $dsninfo['database'];
$this->d_base = $this->base;
$version = $dsninfo['protocol'];
if (empty($host)) {
return $this->raiseError("no host specified {$host}");
}
// else ...
if (isset($port)) {
$conn = ldap_connect($host, $port);
} else {
$conn = ldap_connect($host);
}
if (!$conn) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED);
}
if (isset($version)) {
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, $version);
} else {
// Use 3 by default
$res = ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
// If 3 fails then we can try 2
if (!$res) {
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 2);
}
}
if ($user && $pw) {
$bind = @ldap_bind($conn, $user, $pw);
} else {
$bind = @ldap_bind($conn);
}
if (!$bind) {
return $this->raiseError(DB_ERROR_BIND_FAILED);
}
$this->connection = $conn;
return DB_OK;
}
示例15: connect
/**
* Connect to the database
*
* @return true on success, MDB2 Error Object on failure
*/
function connect()
{
if (is_object($this->connection)) {
if (count(array_diff($this->connected_dsn, $this->dsn)) == 0) {
return MDB2_OK;
}
$this->connection = 0;
}
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'extension ' . $this->phptype . ' is not compiled into PHP', __FUNCTION__);
}
if ($this->options['ssl']) {
$init = @mysqli_init();
@mysqli_ssl_set($init, empty($this->dsn['key']) ? null : $this->dsn['key'], empty($this->dsn['cert']) ? null : $this->dsn['cert'], empty($this->dsn['ca']) ? null : $this->dsn['ca'], empty($this->dsn['capath']) ? null : $this->dsn['capath'], empty($this->dsn['cipher']) ? null : $this->dsn['cipher']);
if ($connection = @mysqli_real_connect($init, $this->dsn['hostspec'], $this->dsn['username'], $this->dsn['password'], $this->database_name, $this->dsn['port'], $this->dsn['socket'])) {
$connection = $init;
}
} else {
$connection = @mysqli_connect($this->dsn['hostspec'], $this->dsn['username'], $this->dsn['password'], $this->database_name, $this->dsn['port'], $this->dsn['socket']);
}
if (!$connection) {
if (($err = @mysqli_connect_error()) != '') {
return $this->raiseError(null, null, null, $err, __FUNCTION__);
} else {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, 'unable to establish a connection', __FUNCTION__);
}
}
if (!empty($this->dsn['charset'])) {
$result = $this->setCharset($this->dsn['charset'], $connection);
if (PEAR::isError($result)) {
return $result;
}
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $this->database_name;
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
$this->supported['transactions'] = $this->options['use_transactions'];
if ($this->options['default_table_type']) {
switch (strtoupper($this->options['default_table_type'])) {
case 'BLACKHOLE':
case 'MEMORY':
case 'ARCHIVE':
case 'CSV':
case 'HEAP':
case 'ISAM':
case 'MERGE':
case 'MRG_ISAM':
case 'ISAM':
case 'MRG_MYISAM':
case 'MYISAM':
$this->supported['transactions'] = false;
$this->warnings[] = $this->options['default_table_type'] . ' is not a supported default table type';
break;
}
}
$this->_getServerCapabilities();
return MDB2_OK;
}