예제 #1
0
 protected function checkExternalLibraries()
 {
     global $ms;
     $missing = false;
     ini_set('track_errors', 1);
     @(include_once 'Net/IPv4.php');
     if (isset($php_errormsg) && preg_match('/Failed opening.*for inclusion/i', $php_errormsg)) {
         static::raiseError("PEAR Net_IPv4 package is missing!");
         $missing = true;
         unset($php_errormsg);
     }
     if (isset($php_errormsg) && preg_match('/Failed opening.*for inclusion/i', $php_errormsg)) {
         print "PEAR Pager package is missing<br />\n";
         $missing = true;
         unset($php_errormsg);
     }
     @(include_once 'smarty3/Smarty.class.php');
     if (isset($php_errormsg) && preg_match('/Failed opening.*for inclusion/i', $php_errormsg)) {
         print "Smarty3 template engine is missing<br />\n";
         $missing = true;
         unset($php_errormsg);
     }
     @(include_once 'System/Daemon.php');
     if (isset($php_errormsg) && preg_match('/Failed opening.*for inclusion/i', $php_errormsg)) {
         print "PEAR System_Daemon package is missing<br />\n";
         $missing = true;
         unset($php_errormsg);
     }
     ini_restore('track_errors');
     if ($missing) {
         return false;
     }
     return parent::checkExternalLibraries();
 }
예제 #2
0
파일: Api.php 프로젝트: c15k0/psfs
 /**
  * @GET
  * @route /api/__doc/{type}
  *
  * @param string $type
  *
  * @return string JSON
  */
 public function createApiDocs($type = Api::PSFS_DOC)
 {
     ini_set('memory_limit', -1);
     ini_set('max_execution_time', -1);
     $endpoints = [];
     $modules = $this->srv->getModules();
     switch (strtolower($type)) {
         case self::SWAGGER_DOC:
             $doc = DocumentorService::swaggerFormatter($modules);
             break;
         default:
         case self::HTML_DOC:
         case self::PSFS_DOC:
             if (count($modules)) {
                 foreach ($modules as $module) {
                     $endpoints = array_merge($endpoints, $this->srv->extractApiEndpoints($module));
                 }
             }
             $doc = $endpoints;
             break;
     }
     ini_restore('max_execution_time');
     ini_restore('memory_limit');
     return $type === self::HTML_DOC ? $this->render('documentation.html.twig', ["data" => json_encode($doc)]) : $this->json($doc, 200);
 }
예제 #3
0
 protected function generateZip()
 {
     ini_set('max_execution_time', 600);
     $mime = parse_ini_file('include/mime.ini');
     $zip = new ZipArchive();
     if ($zip->open($this->pathcache . $this->filecache, ZIPARCHIVE::CREATE) !== true) {
         return false;
     }
     foreach ($this->filelist as $file) {
         $ext = strtolower(substr($file['name'], strrpos($file['name'], '.') + 1));
         $type = explode('/', $mime[$ext]);
         if ($type[0] != 'image') {
             continue;
         }
         $zip->addFile($this->pathname . $file['path'] . '/' . $file['name'], $file['name']);
     }
     $zip->close();
     $size = filesize($this->pathcache . $this->filecache);
     $archive = array();
     if ($this->albuminfo['archive']) {
         $archive = $this->albuminfo['archive'];
     }
     $archive[$this->data['type']] = $size;
     $this->album->setInfo($this->data['id'], 'archive', $archive);
     ini_restore('max_execution_time');
     return true;
 }
예제 #4
0
 /**
  * Return currencies convert rates in batch mode
  *
  * @param array $data
  * @param string $currencyFrom
  * @param array $currenciesTo
  * @return array
  */
 private function convertBatch($data, $currencyFrom, $currenciesTo)
 {
     $currenciesStr = implode(',', $currenciesTo);
     $url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, self::CURRENCY_CONVERTER_URL);
     $url = str_replace('{{CURRENCY_TO}}', $currenciesStr, $url);
     set_time_limit(0);
     try {
         $response = $this->getServiceResponse($url);
     } finally {
         ini_restore('max_execution_time');
     }
     foreach ($currenciesTo as $currencyTo) {
         if ($currencyFrom == $currencyTo) {
             $data[$currencyFrom][$currencyTo] = $this->_numberFormat(1);
         } else {
             if (empty($response['rates'][$currencyTo])) {
                 $this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $url, $currencyTo);
                 $data[$currencyFrom][$currencyTo] = null;
             } else {
                 $data[$currencyFrom][$currencyTo] = $this->_numberFormat((double) $response['rates'][$currencyTo]);
             }
         }
     }
     return $data;
 }
예제 #5
0
파일: io.php 프로젝트: LFSF/oras
function CreateServerFolder($folderPath)
{
    $sParent = GetParentFolder($folderPath);
    // Check if the parent exists, or create it.
    if (!file_exists($sParent)) {
        $sErrorMsg = CreateServerFolder($sParent);
        if ($sErrorMsg != '') {
            return $sErrorMsg;
        }
    }
    if (!file_exists($folderPath)) {
        // Turn off all error reporting.
        error_reporting(0);
        // Enable error tracking to catch the error.
        ini_set('track_errors', '1');
        // To create the folder with 0777 permissions, we need to set umask to zero.
        $oldumask = umask(0);
        mkdir($folderPath, 0777);
        umask($oldumask);
        $sErrorMsg = $php_errormsg;
        // Restore the configurations.
        ini_restore('track_errors');
        ini_restore('error_reporting');
        return $sErrorMsg;
    } else {
        return '';
    }
}
 /**
  * testParserResetsReconfiguredXdebugMaxNestingLevel
  *
  * @return void
  * @covers stdClass
  * @group pdepend
  * @group pdepend::bugs
  * @group regressiontest
  */
 public function testParserResetsReconfiguredXdebugMaxNestingLevel()
 {
     ini_restore('xdebug.max_nesting_level');
     $level = ini_get('xdebug.max_nesting_level');
     self::parseTestCaseSource(__METHOD__);
     $this->assertEquals($level, ini_get('xdebug.max_nesting_level'));
 }
 /**
  * testParserResetsReconfiguredXdebugMaxNestingLevel
  *
  * @return void
  */
 public function testParserResetsReconfiguredXdebugMaxNestingLevel()
 {
     ini_restore('xdebug.max_nesting_level');
     $level = ini_get('xdebug.max_nesting_level');
     self::parseCodeResourceForTest();
     $this->assertEquals($level, ini_get('xdebug.max_nesting_level'));
 }
예제 #8
0
 function forgetmail($to, $subject, $data, $filename, $from)
 {
     if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
         $eol = "\r\n";
     } elseif (strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) {
         $eol = "\r";
     } else {
         $eol = "\n";
     }
     //$filename = "email/signup.tpl";
     if (!file_exists($filename)) {
         echo "Error Loading file";
         exit;
     }
     $str = "";
     $str = file_get_contents($filename);
     foreach ($data as $key => $value) {
         $str = str_replace("%" . $key . "%", "{$value}", "{$str}");
     }
     $headers .= 'From: ' . $from['name'] . ' <' . $from['email'] . '>' . $eol;
     $headers .= 'Reply-To: ' . $to['name'] . ' <' . $to['email'] . '>' . $eol;
     $headers .= "Message-ID: <" . $now . " TheSystem@" . $_SERVER['SERVER_NAME'] . ">" . $eol;
     $headers .= "X-Mailer: PHP v" . phpversion() . $eol;
     // These two to help avoid spam-filters
     $headers .= "Content-Type: text/html; charset=ISO-8859-1 " . $eol;
     $headers .= "MIME-Version: 1.0 " . $eol;
     ini_set(sendmail_from, $from['email']);
     // the INI lines are to force the From Address to be used !
     if (!mail($to['email'], $subject, $str, $headers)) {
         echo "Error Email Sending ";
         exit;
     }
     ini_restore(sendmail_from);
 }
예제 #9
0
파일: Bourinator.php 프로젝트: forxer/tao
 public function stop()
 {
     $exectime = microtime(true) - $this->iStartTime;
     ini_restore(self::MAX_EXECUTION_TIME);
     ini_restore(self::MEMORY_LIMIT);
     return $exectime;
 }
예제 #10
0
 /**
  * Zend_Feed_Entry_Abstract constructor
  *
  * The Zend_Feed_Entry_Abstract constructor takes the URI of the feed the entry
  * is part of, and optionally an XML construct (usually a
  * SimpleXMLElement, but it can be an XML string or a DOMNode as
  * well) that contains the contents of the entry.
  *
  * @param  string $uri
  * @param  SimpleXMLElement|DOMNode|string  $element
  * @return void
  */
 public function __construct($uri = null, $element = null)
 {
     if (!$element instanceof DOMElement) {
         if ($element) {
             // Load the feed as an XML DOMDocument object
             @ini_set('track_errors', 1);
             $doc = new DOMDocument();
             $success = @$doc->loadXML($element);
             @ini_restore('track_errors');
             if (!$success) {
                 throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}");
             }
             $element = $doc->getElementsByTagName($this->_rootElement)->item(0);
             if (!$element) {
                 throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.');
             }
         } else {
             $doc = new DOMDocument('1.0', 'utf-8');
             if ($this->_rootNamespace !== null) {
                 $element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement);
             } else {
                 $element = $doc->createElement($this->_rootElement);
             }
         }
     }
     parent::__construct($element);
 }
예제 #11
0
 function connect()
 {
     $user = $this->config->get('user');
     $pw = $this->config->get('password');
     $hostspec = $this->config->get('host');
     $port = $this->config->get('port');
     $db = $this->config->get('database');
     $persistent = isset($this->config['persistent']) ? $this->config['persistent'] : null;
     $charset = isset($this->config['charset']) ? $this->config['charset'] : null;
     $connect_function = $persistent ? 'oci_pconnect' : 'oci_connect';
     @ini_set('track_errors', true);
     if ($hostspec && $port) {
         $hostspec .= ':' . $port;
     }
     if ($db && $hostspec && $user && $pw) {
         $conn = @$connect_function($user, $pw, "//{$hostspec}/{$db}", $charset);
     } elseif ($hostspec && $user && $pw) {
         $conn = @$connect_function($user, $pw, $hostspec, $charset);
     } else {
         $conn = false;
     }
     @ini_restore('track_errors');
     if ($conn == false) {
         $this->_raiseError();
     }
     $this->connectionId = $conn;
     //connected ok, need to set a few environment settings
     //please note, if this is changed, the function setTimestamp and setDate in OCI8PreparedStatement.php
     //must be changed to match
     //$sql = "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'";
     //$this->execute($sql);
 }
예제 #12
0
 public function __destruct()
 {
     ini_restore('session.use_only_cookies');
     $this->sessionName = NULL;
     $this->isValid = NULL;
     $this->figerprint = NULL;
     $this->fingerHead = NULL;
 }
예제 #13
0
 public function setUp()
 {
     ini_restore('soap.wsdl_cache_enabled');
     ini_restore('soap.wsdl_cache');
     ini_restore('soap.wsdl_cache_dir');
     ini_restore('soap.wsdl_cache_ttl');
     ini_restore('soap.wsdl_cache_limit');
 }
예제 #14
0
 protected function tearDown()
 {
     parent::tearDown();
     if ($this->captureErrorLog()) {
         ini_restore('error_log');
         unlink($this->errorLogFile);
     }
 }
예제 #15
0
 /**
  * Connect to a database and log in as the specified user.
  *
  * @param $dsn the data source name (see DB::parseDSN for syntax)
  * @param $flags Any conneciton flags.
  * @access public
  * @throws SQLException
  * @return void
  */
 function connect($dsninfo, $flags = 0)
 {
     if (!extension_loaded('mysql')) {
         throw new SQLException('mysql extension not loaded');
     }
     $this->dsn = $dsninfo;
     $this->flags = $flags;
     $persistent = ($flags & Creole::PERSISTENT) === Creole::PERSISTENT;
     if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') {
         $dbhost = ':' . $dsninfo['socket'];
     } else {
         $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
         if (!empty($dsninfo['port'])) {
             $dbhost .= ':' . $dsninfo['port'];
         }
     }
     $user = $dsninfo['username'];
     $pw = $dsninfo['password'];
     $connect_function = $persistent ? 'mysql_pconnect' : 'mysql_connect';
     @ini_set('track_errors', true);
     if ($dbhost && $user && $pw) {
         $conn = @$connect_function($dbhost, $user, $pw);
     } elseif ($dbhost && $user) {
         $conn = @$connect_function($dbhost, $user);
     } elseif ($dbhost) {
         $conn = @$connect_function($dbhost);
     } else {
         $conn = false;
     }
     @ini_restore('track_errors');
     if (empty($conn)) {
         if (($err = @mysql_error()) != '') {
             throw new SQLException("connect failed", $err);
         } elseif (empty($php_errormsg)) {
             throw new SQLException("connect failed");
         } else {
             throw new SQLException("connect failed", $php_errormsg);
         }
     }
     if ($dsninfo['database']) {
         if (!@mysql_select_db($dsninfo['database'], $conn)) {
             switch (mysql_errno($conn)) {
                 case 1049:
                     $exc = new SQLException("no such database", mysql_error($conn));
                     break;
                 case 1044:
                     $exc = new SQLException("access violation", mysql_error($conn));
                     break;
                 default:
                     $exc = new SQLException("cannot select database", mysql_error($conn));
             }
             throw $exc;
         }
         // fix to allow calls to different databases in the same script
         $this->database = $dsninfo['database'];
     }
     $this->dblink = $conn;
 }
예제 #16
0
 /**
  * Connect to a database and log in as the specified user.
  *
  * @param $dsn the data source name (see DB::parseDSN for syntax)
  * @param $flags Any conneciton flags.
  * @access public
  * @throws SQLException
  * @return void
  */
 public function connect($dsninfo, $flags = 0)
 {
     if (!extension_loaded('mysqli')) {
         throw new SQLException('mysqli extension not loaded');
     }
     $this->dsn = $dsninfo;
     $this->flags = $flags;
     $dbhost = null;
     if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') {
         $dbhost = ':' . $dsninfo['socket'];
     } else {
         $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
         if (!empty($dsninfo['port'])) {
             $dbhost .= ':' . $dsninfo['port'];
         }
     }
     $host = !empty($dsninfo['hostspec']) ? $dsninfo['hostspec'] : null;
     $user = !empty($dsninfo['username']) ? $dsninfo['username'] : null;
     $pw = !empty($dsninfo['password']) ? $dsninfo['password'] : null;
     $port = !empty($dsninfo['port']) ? $dsninfo['port'] : null;
     $socket = !empty($dsninfo['socket']) ? $dsninfo['socket'] : null;
     $database = !empty($dsninfo['database']) ? $dsninfo['database'] : null;
     $encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null;
     @ini_set('track_errors', true);
     $conn = mysqli_connect($host, $user, $pw, $database, $port, $socket);
     @ini_restore('track_errors');
     if (empty($conn)) {
         if (($err = @mysqli_error()) != '') {
             throw new SQLException("connect failed", $err);
         } elseif (empty($php_errormsg)) {
             throw new SQLException("connect failed");
         } else {
             throw new SQLException("connect failed", $php_errormsg);
         }
     }
     if ($dsninfo['database']) {
         if (!@mysqli_select_db($conn, $dsninfo['database'])) {
             switch (mysqli_errno($conn)) {
                 case 1049:
                     $exc = new SQLException("no such database", mysqli_error($conn));
                     break;
                 case 1044:
                     $exc = new SQLException("access violation", mysqli_error($conn));
                     break;
                 default:
                     $exc = new SQLException("cannot select database", mysqli_error($conn));
             }
             throw $exc;
         }
         // fix to allow calls to different databases in the same script
         $this->database = $dsninfo['database'];
     }
     $this->dblink = $conn;
     if ($encoding) {
         $this->executeUpdate("SET NAMES " . $encoding);
     }
 }
예제 #17
0
 /**
  * Overrides the parent tearDown method.
  *
  * @return  void
  *
  * @see     PHPUnit_Framework_TestCase::tearDownAfterClass()
  * @since   11.3
  */
 public static function tearDownAfterClass()
 {
     $pidPath = JPATH_BASE . '/japplicationdaemontest.pid';
     if (file_exists($pidPath)) {
         unlink($pidPath);
     }
     ini_restore('memory_limit');
     parent::tearDownAfterClass();
 }
 public function send()
 {
     $this->setHeaders();
     $this->setMessage();
     ini_set(sendmail_from, $this->from);
     // the INI lines are to force the From Address to be used !
     $mail_sent = @mail($this->to, $this->subject, $this->new_msg, $this->headers);
     ini_restore(sendmail_from);
     return $mail_sent;
 }
예제 #19
0
파일: Msgpack.php 프로젝트: horde/horde
 /**
  */
 public function unpack($data)
 {
     ini_set('track_errors', 1);
     $out = @msgpack_unpack($data);
     ini_restore('track_errors');
     if (!isset($php_errormsg)) {
         return $out;
     }
     throw new Horde_Pack_Exception('Error when unpacking Msgpack data.');
 }
예제 #20
0
 /**
  * Load the feed as an XML DOMDocument object
  */
 public function __wakeup()
 {
     @ini_set('track_errors', 1);
     $doc = new DOMDocument();
     $success = @$doc->loadXML($this->_element);
     @ini_restore('track_errors');
     if (!$success) {
         throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}");
     }
     $this->_element = $doc;
 }
 /**
  * Create a new raw PHP session handler instance.
  *
  * @param string $namespace Keep session data in a $_SESSION sub-array
  */
 public function __construct($namespace = null)
 {
     // Laravel 5 registers a callback function to handle unserializing session objects, which means you get
     // a fatal error if the object can't be unserialized (which I get since I'm sharing session with another app).
     // This is probably NOT the best way to handle the situation, need to sort this out.
     ini_restore('unserialize_callback_func');
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     $this->setupNamespace($namespace);
 }
예제 #22
0
function stop_catch_error_log()
{
    global $errlog_fn;
    ini_restore('error_log');
    if (!file_exists($errlog_fn)) {
        return null;
    }
    return array_map(function ($l) {
        $l = rtrim($l);
        preg_match('/GMT\\] (.+)/', $l, $m);
        return isset($m[1]) ? $m[1] : $l;
    }, file($errlog_fn));
}
예제 #23
0
 public function testLogFacility()
 {
     if (defined('HHVM_VERSION')) {
         $this->markTestSkipped('Hiphop VM does not support ini settings yet');
     }
     ini_set("error_log", "error.log");
     $this->object = new \Aimeos\MW\Logger\Errorlog(\Aimeos\MW\Logger\Base::DEBUG, array('test'));
     $this->object->log('info test', \Aimeos\MW\Logger\Base::INFO, 'info');
     ini_restore("error_log");
     if (file_exists('error.log')) {
         throw new \RuntimeException('File "error.log" should not be created');
     }
 }
예제 #24
0
파일: Nls.php 프로젝트: netcon-source/apps
 /**
  * Check to see if character set is valid for htmlspecialchars() calls.
  *
  * @param string $charset  The character set to check.
  *
  * @return boolean  Is charset valid for the current system?
  */
 public static function checkCharset($charset)
 {
     if (is_null($charset) || empty($charset)) {
         return false;
     }
     $valid = true;
     ini_set('track_errors', 1);
     @htmlspecialchars('', ENT_COMPAT, $charset);
     if (isset($php_errormsg)) {
         $valid = false;
     }
     ini_restore('track_errors');
     return $valid;
 }
예제 #25
0
 public function tearDown()
 {
     // Restore original autoloaders
     $loaders = spl_autoload_functions();
     foreach ($loaders as $loader) {
         spl_autoload_unregister($loader);
     }
     foreach ($this->loaders as $loader) {
         spl_autoload_register($loader);
     }
     foreach ($this->iniOptions as $key) {
         ini_restore($key);
     }
 }
예제 #26
0
 public function tearDown()
 {
     // Restore original autoloaders
     $loaders = spl_autoload_functions();
     foreach ($loaders as $loader) {
         spl_autoload_unregister($loader);
     }
     foreach ($this->loaders as $loader) {
         spl_autoload_register($loader);
     }
     foreach ($this->iniOptions as $key) {
         ini_restore($key);
     }
     // Reset autoloader instance so it doesn't affect other tests
     Zend_Loader_Autoloader::resetInstance();
 }
예제 #27
0
파일: Abstract.php 프로젝트: nhp/shopware-4
    /**
     * Zend_Feed_Entry_Abstract constructor
     *
     * The Zend_Feed_Entry_Abstract constructor takes the URI of the feed the entry
     * is part of, and optionally an XML construct (usually a
     * SimpleXMLElement, but it can be an XML string or a DOMNode as
     * well) that contains the contents of the entry.
     *
     * @param  string $uri
     * @param  SimpleXMLElement|DOMNode|string  $element
     * @return void
     * @throws Zend_Feed_Exception
     */
    public function __construct($uri = null, $element = null)
    {
        if (!($element instanceof DOMElement)) {
            if ($element) {
                // Load the feed as an XML DOMDocument object
                @ini_set('track_errors', 1);
                $doc = new DOMDocument();
                $status = @$doc->loadXML($element);
                @ini_restore('track_errors');

                if (!$status) {
                    // prevent the class to generate an undefined variable notice (ZF-2590)
                    if (!isset($php_errormsg)) {
                        if (function_exists('xdebug_is_enabled')) {
                            $php_errormsg = '(error message not available, when XDebug is running)';
                        } else {
                            $php_errormsg = '(error message not available)';
                        }
                    }

                    /**
                     * @see Zend_Feed_Exception
                     */
                    require_once 'Zend/Feed/Exception.php';
                    throw new Zend_Feed_Exception("DOMDocument cannot parse XML: $php_errormsg");
                }

                $element = $doc->getElementsByTagName($this->_rootElement)->item(0);
                if (!$element) {
                    /**
                     * @see Zend_Feed_Exception
                     */
                    require_once 'Zend/Feed/Exception.php';
                    throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.');
                }
            } else {
                $doc = new DOMDocument('1.0', 'utf-8');
                if ($this->_rootNamespace !== null) {
                    $element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement);
                } else {
                    $element = $doc->createElement($this->_rootElement);
                }
            }
        }

        parent::__construct($element);
    }
예제 #28
0
function ut_main()
{
    $res_str = '';
    $lang = ut_loc_get_default();
    $res_str .= "Default locale: {$lang}";
    $res_str .= "\n";
    locale_set_default('de-DE');
    $lang = ut_loc_get_default();
    $res_str .= "Default locale: {$lang}";
    $res_str .= "\n";
    ini_set('intl.default_locale', 'fr');
    $lang = ut_loc_get_default();
    $res_str .= "Default locale: {$lang}";
    $res_str .= "\n";
    ini_restore("intl.default_locale");
    return $res_str;
}
예제 #29
0
 /**
  * Connect to a database and log in as the specified user.
  *
  * @param $dsn the data source name (see DB::parseDSN for syntax)
  * @param $flags Any conneciton flags.
  * @access public
  * @throws SQLException
  * @return void
  */
 function connect($dsninfo, $flags = 0)
 {
     if (!extension_loaded('ldap')) {
         throw new SQLException('ldap extension not loaded');
     }
     $this->dsn = $dsninfo;
     $this->flags = $flags;
     $user = $dsninfo['username'];
     $pw = $dsninfo['password'];
     $dbport = $dsninfo['port'];
     if ($dsninfo['phptype'] == 'ldaps') {
         $dbhost = 'ldaps://' . $dsninfo['hostspec'];
         if (!isset($dbport)) {
             $dbport = LdapConnection::TLSPORT;
         }
     } else {
         $dbhost = $dsninfo['hostspec'];
         $dbport = $dsninfo['port'];
         if (!isset($dbport)) {
             $dbport = LdapConnection::PORT;
         }
     }
     @ini_set('track_errors', true);
     if ($dbhost) {
         $conn = @ldap_connect($dbhost, $dbport);
         $bind = @ldap_bind($conn, $user, $pw);
     } else {
         $conn = false;
     }
     @ini_restore('track_errors');
     if (empty($conn)) {
         if (($err = @ldap_error()) != '') {
             throw new SQLException("connect failed", $err);
         } elseif (empty($php_errormsg)) {
             throw new SQLException("connect failed");
         } else {
             throw new SQLException("connect failed", $php_errormsg);
         }
     }
     if (!$dsninfo['database']) {
         throw new SQLException("You must specify base DN");
     }
     $this->basedn = $dsninfo['database'];
     $this->dblink = $conn;
     $this->bind = $bind;
 }
예제 #30
0
 public static function getPageContent($url, $timeout = 5)
 {
     $result = null;
     $userAgent = 'Subrion CMS Bot';
     if (extension_loaded('curl')) {
         $ch = curl_init();
         curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_HEADER => false, CURLOPT_REFERER => IA_CLEAR_URL, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => (int) $timeout, CURLOPT_USERAGENT => $userAgent));
         $result = curl_exec($ch);
         curl_close($ch);
     } elseif (ini_get('allow_url_fopen')) {
         ini_set('user_agent', $userAgent);
         $result = file_get_contents($url, false);
         ini_restore('user_agent');
     } else {
         $result = false;
     }
     return $result;
 }