function phpFreaksCrypto($key = 'a843l?nv89rjfd}O(jdnsleken0', $iv = false, $algorithm = 'tripledes', $mode = 'ecb') { if (extension_loaded('mcrypt') === FALSE) { $prefix = PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''; dl($prefix . 'mcrypt.' . PHP_SHLIB_SUFFIX) or die('The Mcrypt module could not be loaded.'); } if ($mode != 'ecb' && $iv === false) { /* the iv must remain the same from encryption to decryption and is usually passed into the encrypted string in some form, but not always. */ die('In order to use encryption modes other then ecb, you must specify a unique and consistent initialization vector.'); } // set mcrypt mode and cipher $this->td = mcrypt_module_open($algorithm, '', $mode, ''); // Unix has better pseudo random number generator then mcrypt, so if it is available lets use it! //$random_seed = strstr(PHP_OS, "WIN") ? MCRYPT_RAND : MCRYPT_DEV_RANDOM; $random_seed = MCRYPT_RAND; // if initialization vector set in constructor use it else, generate from random seed $iv = $iv === false ? mcrypt_create_iv(mcrypt_enc_get_iv_size($this->td), $random_seed) : substr($iv, 0, mcrypt_enc_get_iv_size($this->td)); // get the expected key size based on mode and cipher $expected_key_size = mcrypt_enc_get_key_size($this->td); // we dont need to know the real key, we just need to be able to confirm a hashed version $key = substr(md5($key), 0, $expected_key_size); // initialize mcrypt library with mode/cipher, encryption key, and random initialization vector mcrypt_generic_init($this->td, $key, $iv); }
/** * check if SQLite extension is loaded, and if not load it. */ function CheckExtension($extName) { $SQL_SERVER_OS = strtoupper(substr(PHP_OS, 0, 3)); if ($SQL_SERVER_OS == 'WIN') { $preffix = 'php_'; $suffix = '.dll'; } elseif ($SQL_SERVER_OS == 'NET') { $preffix = 'php_'; $suffix = '.nlm'; } elseif ($SQL_SERVER_OS == 'LIN' || $SQL_SERVER_OS == 'DAR') { $preffix = ''; $suffix = '.so'; } $extensions = get_loaded_extensions(); foreach ($extensions as $key => $ext) { $extensions[$key] = strtolower($ext); } if (!extension_loaded($extName) && !in_array($extName, get_loaded_extensions())) { if (DEBUG) { $oldLevel = error_reporting(); error_reporting(E_ERROR); $extensionLoaded = dl($preffix . $extName . $suffix); error_reporting($oldLevel); } else { $extensionLoaded = @dl($preffix . $extName . $suffix); } if ($extensionLoaded) { return true; } else { return false; } } else { return true; } }
static function load_gd() { if (!extension_loaded("gd")) { dprint("Warning No gd <br> "); dl("gd." . PHP_SHLIB_SUFFIX); } }
/** * construct * */ public function __construct(array $options) { // ๅ ่ฝฝๆฉๅฑ if (!extension_loaded('snmp_plugin')) { dl('snmp_plugin.' . PHP_SHLIB_SUFFIX); } // ๆฃๆต้่ฆ็็ฑป $classes = array('PHPSnmpEngine', 'SnmpServerInfo', 'PHPSystemDescRequest', 'PHPEnumCPUUtilizationRateRequest', 'PHPEnumNetworkRequest', 'PHPEnumStorageRequest', 'PHPEnumDiskIORequest'); foreach ($classes as $class) { if (!class_exists($class)) { throw new Oray_Exception("Class {$class} not exist"); } } // ๅๅงๅ้ ็ฝฎ while (list($name, $value) = each($options)) { if (array_key_exists($name, $this->_options)) { $this->_options[$name] = $value; } } // ่ฎพ็ฝฎ้ ็ฝฎๅฐSnmpServerInfo็ฑป $ServerInfo = new SnmpServerInfo(); foreach ($this->_options as $name => $value) { $ServerInfo->{$name} = $value; } // ่ฎพ็ฝฎ่ฟๆฅ่ถ ๆถ $ServerInfo->connect_server_timeout = 20000; // ๅฎไพๅๅผๆใ่ฟๆฅๆๅกๅจ $this->_snmpEngine = new PHPSnmpEngine(); $this->_snmpEngine->ConnectSnmpServer($ServerInfo); }
/** * Loads a dynamic library. * * @see php://dl * @param string name * @return bool TRUE if the library was loaded, FALSE if it was already loaded * @throws lang.IllegalAccessException in case library loading is prohibited * @throws lang.ElementNotFoundException in case the library does not exist * @throws lang.RuntimeError in case dl() fails */ public function loadLibrary($name) { if (extension_loaded($name)) { return false; } // dl() will fatal if any of these are set - prevent this if (!(bool) ini_get('enable_dl') || (bool) ini_get('safe_mode')) { throw new IllegalAccessException(sprintf('Loading libraries not permitted by system configuration [enable_dl= %s, safe_mode= %s]', ini_get('enable_dl'), ini_get('safe_mode'))); } // Qualify filename $path = rtrim(realpath(ini_get('extension_dir')), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $filename = $name . '.' . PHP_SHLIB_SUFFIX; // Try php_<name>.<ext>, <name>.<ext> if (file_exists($lib = $path . 'php_' . $filename)) { // E.g. php_sybase_ct.dll } else { if (file_exists($lib = $path . $filename)) { // E.g. sybase_ct.so } else { throw new ElementNotFoundException('Cannot find library "' . $name . '" in "' . $path . '"'); } } // Found library, try to load it. dl() expects given argument to not contain // a path and will fail with "Temporary module name should contain only // filename" if it does. if (!dl(basename($lib))) { throw new RuntimeError('dl() failed for ' . $lib); } return true; }
function sso_auth() { $auth_check = TRUE; $non_check_uri = array('remote', 'auth'); if (isset($_SERVER['PATH_INFO'])) { $path_info = $_SERVER['PATH_INFO']; foreach ($non_check_uri as $uri) { if (strpos($path_info, $uri) === 1) { $auth_check = FALSE; break; } } } if (!extension_loaded('haes')) { if (phpversion() >= '5.0') { @dl('haes.so'); } else { @dl(HOME_PATH . '../approval/lib/haes.so'); } } $this->_load_global_config(); if ($auth_check) { $this->_check_auth(); $this->_load_timezone_config($GLOBALS['_HANBIRO_GW']['ID']); } }
protected function in() { $path_to_phpgroupware = dirname(__FILE__) . '/../..'; // need to be adapted if this script is moved somewhere else $_GET['domain'] = 'default'; $GLOBALS['phpgw_info']['flags'] = array('currentapp' => 'login', 'noapi' => True); /** * Include phpgroupware header */ include $path_to_phpgroupware . '/header.inc.php'; unset($GLOBALS['phpgw_info']['flags']['noapi']); $db_type = $GLOBALS['phpgw_domain'][$_GET['domain']]['db_type']; if ($db_type == 'postgres') { $db_type = 'pgsql'; } if (!extension_loaded($db_type) && !dl($db_type . '.so')) { echo "Extension '{$db_type}' is not loaded and can't be loaded via dl('{$db_type}.so') !!!\n"; } $GLOBALS['phpgw_info']['server']['sessions_type'] = 'db'; /** * Include API functions */ include PHPGW_API_INC . '/functions.inc.php'; for ($i = 0; $i < 10; $i++) { restore_error_handler(); //Remove at least 10 levels of custom error handling } for ($i = 0; $i < 10; $i++) { restore_exception_handler(); //Remove at least 10 levels of custom exception handling } $this->initializeContext(); }
protected function execute(InputInterface $input, OutputInterface $output) { if (!class_exists('Event')) { dl('event.so'); } $listen = $input->getOption('listen'); if ($listen === null) { $listen = 8080; } $this->socket = new SocketIO(); $this->socket->on('addme', function (Event\MessageEvent $messageEvent) { return $this->onAddme($messageEvent); })->on('msg', function (Event\MessageEvent $messageEvent) { return $this->onMsg($messageEvent); }); $this->socket->listen($listen)->onConnect(function () { })->onRequest('/brocast', function ($connection, \EventHttpRequest $request) { if ($request->getCommand() == \EventHttpRequest::CMD_POST) { if (($data = json_decode($request->getInputBuffer()->read(1024), true)) !== NULL) { $response = $this->onBrocast($data); } else { $response = new Response('fail', Response::HTTP_NOT_FOUND); } } else { $response = new Response('fail', Response::HTTP_NOT_FOUND); } $connection->sendResponse($response); })->dispatch(); }
/** * Singleton Pattern, Unique Instance of This * * @param $config_file mixed * @param $queueIndex * * @return static */ public static function getInstance($config_file = null, $queueIndex = null) { if (PHP_SAPI != 'cli' || isset($_SERVER['HTTP_HOST'])) { die("This script can be run only in CLI Mode.\n\n"); } declare (ticks=10); set_time_limit(0); if (static::$__INSTANCE === null) { if (!extension_loaded("pcntl") && (bool) ini_get("enable_dl")) { dl("pcntl.so"); } if (!function_exists('pcntl_signal')) { $msg = "****** PCNTL EXTENSION NOT LOADED. KILLING THIS PROCESS COULD CAUSE UNPREDICTABLE ERRORS ******"; static::_TimeStampMsg($msg); } else { static::_TimeStampMsg(str_pad(" Registering signal handlers ", 60, "*", STR_PAD_BOTH)); pcntl_signal(SIGTERM, array(get_called_class(), 'sigSwitch')); pcntl_signal(SIGINT, array(get_called_class(), 'sigSwitch')); pcntl_signal(SIGHUP, array(get_called_class(), 'sigSwitch')); $msg = str_pad(" Signal Handler Installed ", 60, "-", STR_PAD_BOTH); static::_TimeStampMsg("{$msg}"); } static::$__INSTANCE = new static($config_file, $queueIndex); } return static::$__INSTANCE; }
/** * Checks required modules * * @param string $name * @param array $directive * @return boolean */ public function testModule($name, $directive = array()) { $return = array("title" => $directive['title'], "name" => $name, "current" => "", "test" => false); if (is_array($directive)) { //If the extension is loaded if (!extension_loaded($name)) { $return["current"] = t("Not Loaded"); //If we require this module loaded, then fail if ($directive["loaded"]) { $return["test"] = "Failed"; } //If we require this module to be installed if ($directive["installed"] && function_exists('dl')) { if (!dl($name)) { $return["test"] = "Failed"; $return["current"] = t("Not Installed"); } } } else { $return["current"] = _("Loaded"); if ($directive["loaded"]) { $return["test"] = "Passed"; } } //@TODO If we have alternative modules if (!$return['test'] && isset($directive['alternate'])) { //$altName = } } return $return; }
function __construct($sid, $verificaSID = true) { if (!function_exists('ms_GetVersion')) { if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) { if (!@dl('php_mapscript_48.dll')) { dl('php_mapscript.dll'); } } else { dl('php_mapscript.so'); } } //include("../../classesphp/carrega_ext.php"); //verifica๏ฟฝ๏ฟฝo de seguran๏ฟฝa if ($verificaSID == true) { $_SESSION = array(); session_name("i3GeoPHP"); session_id($sid); session_start(); if (@$_SESSION["fingerprint"]) { $f = explode(",", $_SESSION["fingerprint"]); if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"], $f)) { exit; } } else { exit; } } if (!isset($_SESSION["map_file"])) { exit; } $this->map_file = $_SESSION["map_file"]; $this->postgis_mapa = $_SESSION["postgis_mapa"]; $this->url = $_SESSION["tmpurl"]; $this->ext = $_SESSION["mapext"]; }
function __construct() { global $config_vars, $cache; require_once Environment::getBasePath() . 'classes' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'InstallSchema.class.php'; $this->config_vars = $config_vars; //Disable caching so we don't exceed maximum memory settings. $cache->_onlyMemoryCaching = TRUE; ini_set('default_socket_timeout', 5); ini_set('allow_url_fopen', 1); //As of PHP v5.3 some SAPI's don't support dl(), however it appears that php.ini can still have it enabled. //Double check to make sure the dl() function exists prior to calling it. if (version_compare(PHP_VERSION, '5.3.0', '<') and function_exists('dl') == TRUE and (bool) ini_get('enable_dl') == TRUE and (bool) ini_get('safe_mode') == FALSE) { $prefix = PHP_SHLIB_SUFFIX === 'dll' ? 'php_' : ''; if (extension_loaded('mysql') == FALSE) { @dl($prefix . 'mysql.' . PHP_SHLIB_SUFFIX); } if (extension_loaded('mysqli') == FALSE) { @dl($prefix . 'mysqli.' . PHP_SHLIB_SUFFIX); } if (extension_loaded('pgsql') == FALSE) { @dl($prefix . 'pgsql.' . PHP_SHLIB_SUFFIX); } } return TRUE; }
/** * Get file contents from temp file * @return string */ public function get() { if (!file_exists($this->tempName)) { throw new BadMethodCallException('Called before being fetched with Zip->get(). Don\'t call this directly!'); } switch ($this->method) { case 8: $_method = 'gzinflate'; break; case 12: if (!extension_loaded('bz2')) { @dl(strtolower(substr(PHP_OS, 0, 3)) == 'win' ? 'php_bz2.dll' : 'bz2.so'); } if (extension_loaded('bz2')) { $_method = 'bzdecompress'; break; } else { throw new RuntimeException('Unable to decompress, failed to load bz2 extension'); } default: $_method = false; } if ($_method) { return call_user_func_array($_method, array(file_get_contents($this->tempName) . $this->purge())); } else { return file_get_contents($this->tempName) . $this->purge(); } }
function init() { if (extension_loaded("imap")) { return true; } $prefix = PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''; $EXTENSION = $prefix . 'imap.' . PHP_SHLIB_SUFFIX; if (function_exists('dl')) { $fatalMessage = 'The system tried to load dynamically the ' . $EXTENSION . ' extension'; $fatalMessage .= '<br/>If you see this message, that means the system could not load this PHP extension'; $fatalMessage .= '<br/>Please enable the PHP Extension ' . $EXTENSION; ob_start(); echo $fatalMessage; dl($EXTENSION); $warnings = str_replace($fatalMessage, '', ob_get_clean()); if (extension_loaded("imap") or function_exists('imap_open')) { return true; } } if ($this->report) { acymailing::display('The extension "' . $EXTENSION . '" could not be loaded, please change your PHP configuration to enable it', 'error'); if (!empty($warnings)) { acymailing::display($warnings, 'warning'); } } return false; }
/** * Sets up the shared fixture. * * @return void * @link http://phpunit.de/manual/current/en/fixtures.html#fixtures.sharing-fixture */ public static function setUpBeforeClass() { if (self::$ext) { $name = strtolower(self::$ext); self::$obj = new ExtensionFactory($name); } if (!self::$obj instanceof ReferenceInterface) { self::$obj = null; return; } self::$ext = $extname = self::$obj->getName(); self::$optionalreleases = array(); if (!extension_loaded($extname)) { // if dynamic extension load is activated $loaded = (bool) ini_get('enable_dl'); if ($loaded) { // give a second chance $prefix = PHP_SHLIB_SUFFIX === 'dll' ? 'php_' : ''; @dl($prefix . $extname . '.' . PHP_SHLIB_SUFFIX); } } if (!extension_loaded($extname)) { self::$obj = null; } else { $releases = array_keys(self::$obj->getReleases()); $currentVersion = self::$obj->getCurrentVersion(); // platform dependant foreach ($releases as $rel_version) { if (version_compare($currentVersion, $rel_version, 'lt')) { array_push(self::$optionalreleases, $rel_version); } } } }
function logon($engine, $dbfile, $username, $password, $host, $name) { // connect string if ($dbfile) { // datasource mostly to support sqlite: dbengine://dbfile?mode=xxxx $datasource = $engine . ':///' . $dbfile . '?mode=0666'; $options = array('debug' => 4); if (!extension_loaded('sqlite3') && !extension_loaded('SQLITE3')) { dl('sqlite3.so'); } } else { // datasource in in this style: dbengine://username:password@host/database $datasource = $engine . '://' . $username . ':' . $password . '@' . $host . '/' . $name; // options $options = array('debug' => 2, 'portability' => DB_PORTABILITY_LOWERCASE | DB_PORTABILITY_RTRIM | DB_PORTABILITY_DELETE_COUNT | DB_PORTABILITY_NUMROWS | DB_PORTABILITY_ERRORS | DB_PORTABILITY_NULL_TO_EMPTY); } // attempt connection $dbh = DB::connect($datasource, $options); // if connection failed show error if (DB::isError($dbh)) { $_SESSION['ari_error'] .= $dbh->getMessage() . "<br><br>"; return; } return $dbh; }
function translation($warnings = False) { for ($i = 1; $i <= 9; $i++) { $this->placeholders[] = '%' . $i; } $this->db = is_object($GLOBALS['phpgw']->db) ? $GLOBALS['phpgw']->db : $GLOBALS['phpgw_setup']->db; if (!isset($GLOBALS['phpgw_setup'])) { $this->system_charset = @$GLOBALS['phpgw_info']['server']['system_charset']; } else { $this->db->query("SELECT config_value FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='system_charset'", __LINE__, __FILE__); if ($this->db->next_record()) { $this->system_charset = $this->db->f(0); } } // load multi-byte-string-extension if needed, and set its internal encodeing to your system_charset if ($this->system_charset && substr($this->system_charset, 0, 9) != 'iso-8859-1') { if ($this->mbstring = extension_loaded('mbstring') || @dl(PHP_SHLIB_PREFIX . 'mbstring.' . PHP_SHLIB_SUFFIX)) { ini_set('mbstring.internal_encoding', $this->system_charset); if (ini_get('mbstring.func_overload') < 7) { if ($warnings) { echo "<p>Warning: Please set <b>mbstring.func_overload = 7</b> in your php.ini for useing <b>{$this->system_charset}</b> as your charset !!!</p>\n"; } } } else { if ($warnings) { echo "<p>Warning: Please get and/or enable the <b>mbstring extension</b> in your php.ini for useing <b>{$this->system_charset}</b> as your charset, we are defaulting to <b>iconv</b> for now !!!</p>\n"; } } } }
function cdLoadDLL($ext) { global $cdDebug; if ($cdDebug || error_reporting() != 0) { echo '<br><b>Trying to load "' . $ext . '" from the PHP extension directory ' . listExtDir() . '.</b><br>'; } @cdSetHint(ini_get("extension_dir")); if (dl($ext)) { return true; } $ver = explode('.', phpversion()); $ver = $ver[0] * 10000 + $ver[1] * 100 + $ver[2]; if (!$cdDebug && $ver >= 50205) { return false; } $scriptPath = dirname(__FILE__); $tryPath = getRelExtPath($scriptPath); if (!$tryPath) { return false; } if ($cdDebug || error_reporting() != 0) { echo '<br><b>Trying to load "' . $ext . '" from ' . listRelExtDir($scriptPath) . '.</b><br>'; } @cdSetHint($scriptPath); return dl($tryPath . "/{$ext}"); }
function getEngine() { static $engine = -1; if ($engine != -1) { return $engine; } if (!$this->useEngine) { $engine = SB_CHARSET_IGNORE; return $engine; } if (!function_exists('iconv') && !extension_loaded('iconv')) { $this->useHandler(false); @dl('iconv'); $this->useHandler(); } if (function_exists('iconv')) { $engine = SB_CHARSET_ICONV; } elseif (function_exists('libiconv')) { $engine = SB_CHARSET_LIBICONV; } else { if (!function_exists('recode_string') && !extension_loaded('recode')) { $this->useHandler(false); @dl('recode'); $this->useHandler(); } if (function_exists('recode_string')) { $engine = SB_CHARSET_RECODE; } else { $engine = SB_CHARSET_IGNORE; } } return $engine; }
/** * Register the specified binding into the container * * @param string $binding * @return void */ public function register($binding) { if (!extension_loaded('wxwidgets')) { if (!@dl('wxwidgets.' . PHP_SHLIB_SUFFIX)) { echo 'wxWidgets extension not installed or dynamically loaded extensions are not enabled' . PHP_EOL; exit(1); } } switch ($binding) { case 'view.viewparser': $this->registerViewParser(); break; case 'wx': $this->registerWx(); break; case 'launcher': $this->registerLauncher(); break; case 'giml.collection': $this->registerGimlCollection(); break; default: $this->registerGimlCollection(); $this->registerViewParser(); $this->registerWx(); $this->registerLauncher(); break; } }
/** * constructor */ function helper_plugin_sqlite() { if (!$this->extension) { if (!extension_loaded('pdo_sqlite')) { $prefix = PHP_SHLIB_SUFFIX === 'dll' ? 'php_' : ''; if (function_exists('dl')) { @dl($prefix . 'pdo_sqlite.' . PHP_SHLIB_SUFFIX); } } if (class_exists('pdo')) { $this->extension = DOKU_EXT_PDO; } } if (!$this->extension) { if (!extension_loaded('sqlite')) { $prefix = PHP_SHLIB_SUFFIX === 'dll' ? 'php_' : ''; if (function_exists('dl')) { @dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX); } } if (function_exists('sqlite_open')) { $this->extension = DOKU_EXT_SQLITE; } } if (!$this->extension) { msg('SQLite & PDO SQLite support missing in this PHP install - plugin will not work', -1); } }
/** * Metainformation catalogue * -------------------------------------------------- * * Lib_XML for MicKa * * @link http://www.bnhelp.cz * @package Micka * @category Metadata * @version 20121206 * */ function applyTemplate($xmlSource, $xsltemplate) { $rs = FALSE; if (File_Exists(CSW_XSL . '/' . $xsltemplate)) { if (!extension_loaded("xsl")) { if (substr(PHP_OS, 0, 3) == "WIN") { dl("php_xsl.dll"); } else { dl("php_xsl.so"); } } $xp = new XsltProcessor(); $xml = new DomDocument(); $xsl = new DomDocument(); $xml->loadXML($xmlSource); $xsl->load(CSW_XSL . '/' . $xsltemplate); $xp->importStyleSheet($xsl); //$xp->setParameter("","lang",$lang); $xp->setParameter("", "user", $_SESSION['u']); $rs = $xp->transformToXml($xml); } if ($rs === FALSE) { setMickaLog('applyTemplate === FALSE', 'ERROR', 'micka_lib_xml.php'); } return $rs; }
/** Open an MSSQL database and return a resource handle to it * NOTE: only $dbName is used, the other parameters are irrelevant for MSSQL databases */ function open($server, $user, $password, $dbName) { wfProfileIn(__METHOD__); # Test for missing mysql.so # First try to load it if (!@extension_loaded('mssql')) { @dl('mssql.so'); } # Fail now # Otherwise we get a suppressed fatal error, which is very hard to track down if (!function_exists('mssql_connect')) { throw new DBConnectionError($this, "MSSQL functions missing, have you compiled PHP with the --with-mssql option?\n"); } $this->close(); $this->mServer = $server; $this->mUser = $user; $this->mPassword = $password; $this->mDBname = $dbName; wfProfileIn("dbconnect-{$server}"); # Try to connect up to three times # The kernel's default SYN retransmission period is far too slow for us, # so we use a short timeout plus a manual retry. $this->mConn = false; $max = 3; for ($i = 0; $i < $max && !$this->mConn; $i++) { if ($i > 1) { usleep(1000); } if ($this->mFlags & DBO_PERSISTENT) { @($this->mConn = mssql_pconnect($server, $user, $password)); } else { # Create a new connection... @($this->mConn = mssql_connect($server, $user, $password, true)); } } wfProfileOut("dbconnect-{$server}"); if ($dbName != '') { if ($this->mConn !== false) { $success = @mssql_select_db($dbName, $this->mConn); if (!$success) { $error = "Error selecting database {$dbName} on server {$this->mServer} " . "from client host " . wfHostname() . "\n"; wfLogDBError(" Error selecting database {$dbName} on server {$this->mServer} \n"); wfDebug($error); } } else { wfDebug("DB connection error\n"); wfDebug("Server: {$server}, User: {$user}, Password: "******"...\n"); $success = false; } } else { # Delay USE query $success = (bool) $this->mConn; } if (!$success) { $this->reportConnectionError(); } $this->mOpened = $success; wfProfileOut(__METHOD__); return $success; }
/** * @return void * @param int $length string length * @param int $size font size * @param String $type image type * @desc generate the main image */ function CaptchaNumbers($length = '', $size = '', $type = '') { /* * make sure that the gd extension is loaded (for graphics) */ if (!extension_loaded('gd')) { if (strtoupper(substr(PHP_OS, 3)) == "WIN") { dl('php_gd2.dll'); } else { dl('gd.so'); } } //putenv('GDFONTPATH=' . realpath('.')); if ($length != '') { $this->length = $length; } if ($size != '') { $this->size = $size; } if ($type != '') { $this->type = $type; } $this->width = $this->length * $this->size + $this->grid; $this->height = $this->size + 2 * $this->grid; $this->generateString(); }
function trustcommerce_refund($params) { if (!extension_loaded("tclink")) { $extfname = "tclink.so"; if (!dl($extfname)) { $msg = "Please check to make sure the module TCLink is properly built"; return array("status" => "error", "rawdata" => array("error" => $msg)); } } $tc_params = array("action" => "credit"); $tc_params['custid'] = $params['username']; $tc_params['password'] = $params['password']; $tc_params['demo'] = $params['testmode'] ? "y" : "n"; $tc_params['transid'] = $params['transid']; $tc_params['amount'] = $params['amount'] * 100; $tc_result = tclink_send($tc_params); if ($tc_result['status'] == "approved" || $tc_result['status'] == "accepted") { $result = array("status" => "success", "transid" => $tc_result['transid'], "rawdata" => $tc_result); } else { if ($tc_result['status'] == "decline" || $tc_result['status'] == "rejected") { $result = array("status" => "declined", "rawdata" => $tc_result); } else { if ($tc_result['status'] == "baddata") { $result = array("status" => "baddata", "rawdata" => $tc_result); } else { $result = array("status" => "error", "rawdata" => $tc_result); } } } return $result; }
private function save_data_to_text() { if (!extension_loaded('soap')) { dl("php_soap.dll"); } $i = 0; if (!($f = Functions::file_open($this->TEMP_FILE_PATH . "/processed.txt", "a"))) { return; } foreach (new FileIterator($this->TEMP_FILE_PATH . "taxa.txt") as $line_number => $line) { $line = explode("\t", $line); $guid = $line[0]; if ($result = self::access_pesi_service_with_retry($guid, 1)) { if (self::is_array_empty($result, 1)) { echo "\n investigate guid no record: [{$guid}]\n"; continue; } $info = self::get_parent_taxon($result); $parent_taxa = $info["taxon"]; $parent_rank = $info["rank"]; if ($i % 100 == 0) { echo "\n SOAP response: {$i}. {$result->scientificname} -- {$result->GUID} -- {$parent_taxa}"; } $line = self::clean_str($result->GUID) . "\t" . self::clean_str($result->scientificname) . "\t" . self::clean_str($result->authority) . "\t" . self::clean_str($result->rank) . "\t" . self::clean_str($parent_taxa) . "\t" . self::clean_str($parent_rank) . "\t" . self::clean_str($result->citation) . "\n"; fwrite($f, $line); $i++; } else { echo "\n investigate guid no record: [{$guid}]\n"; continue; } // if($i >= 20) break; // debug - to limit during development } fclose($f); echo "\n\n total: {$i} \n\n"; }
/** * Get GD version * * @return string|false */ public static function getGDVer() { if (self::$_gdVer != null) { return self::$_gdVer; } $res = false; if (!extension_loaded('gd')) { if (dl('gd.so')) { $res = true; } } else { $res = true; } if ($res) { if (function_exists('gd_info')) { $gdInfo = gd_info(); preg_match('/\\d/', $gdInfo['GD Version'], $match); self::$_gdVer = $match[0]; if (self::$_gdVer >= 2) { $res = self::$_gdVer; } } else { $res = false; } } return $res; }
function PMA_dl($module) { if (!isset($GLOBALS['PMA_dl_allowed'])) { if (!@ini_get('safe_mode') && @ini_get('enable_dl') && @function_exists('dl')) { ob_start(); phpinfo(INFO_GENERAL); /* Only general info */ $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) { if (preg_match('@Server API[[:space:]]*\\(CGI\\|CLI\\)@', $a)) { $GLOBALS['PMA_dl_allowed'] = TRUE; } else { $GLOBALS['PMA_dl_allowed'] = FALSE; } } else { $GLOBALS['PMA_dl_allowed'] = TRUE; } } else { $GLOBALS['PMA_dl_allowed'] = FALSE; } } if (PMA_IS_WINDOWS) { $suffix = '.dll'; } else { $suffix = '.so'; } if ($GLOBALS['PMA_dl_allowed']) { return @dl($module . $suffix); } else { return FALSE; } }
protected function connect() { switch ($this->type) { case "mysql": // Check for MySQLi $this->mysqli = extension_loaded("mysqli"); if (!$this->mysqli) { $prefix = PHP_SHLIB_SUFFIX === "dll" ? "php_" : ""; if (@dl($prefix . "mysqli." . PHP_SHLIB_SUFFIX)) { $this->mysqli = extension_loaded("mysqli"); } } try { $this->on = true; $this->res = $this->mysqli ? new mysqli($this->config['hostname'], $this->config['username'], $this->config['password'], $this->config['database']) : mysql_connect($this->config['hostname'], $this->config['username'], $this->config['password']); if (!$this->mysqli) { mysql_select_db($this->config['database'], $this->res); } $this->conn = true; if ($this->mysqli && $this->res->connect_error) { $this->conn = false; throw new Exception("Could not connect to the DB: " . $this->res->connect_error); } else { if (!$this->res) { $this->conn = false; throw new Exception("Could not connect to the DB: " . mysql_error($this->res)); } } } catch (Exception $e) { throw new Exception("Could not connect to the DB: " . $e->getMessage()); } break; } }
public function __construct(array $db, $IPMethod = 0) { $this->setMethod($IPMethod); $checkKeys = array('user', 'name', 'pass'); foreach ($checkKeys as $k) { if (!isset($db["{$k}"])) { throw new Exception('Key: ' . $k . ' is not defined'); } $this->_db["{$k}"] = $db["{$k}"]; } $this->_db['constr'] = isset($db['socket']) ? ':' . $db['socket'] : $db['host']; if (empty($this->_db['constr'])) { throw new Exception('Host & Socket both were not defined'); } if (!extension_loaded('mysql') and !(ini_get('enable_dl') == "1" and (dl('mysql.so') or dl('mysql.dll')))) { die("Please load mysql\n"); } if (!($con = mysql_connect($this->_db['constr'], $this->_db['user'], $this->_db['pass']))) { throw new Exception('Could not connect to MySQL Server: ' . mysql_error($con)); } if (!mysql_select_db($this->_db['name'], $con)) { throw new Exception('Could not select database: ' . mysql_error($con)); } $this->_db['con'] = $con; return $this; }