Skip to content

Commit a0cf781

Browse files
committed
Added BCMath extension checking.
1 parent 515ebf7 commit a0cf781

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

class.IP2Proxy.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Database {
3232
*
3333
* @var string
3434
*/
35-
const VERSION = '1.1.1';
35+
const VERSION = '1.1.2';
3636

3737
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3838
// Error field constants ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -221,6 +221,13 @@ class Database {
221221
*/
222222
const EXCEPTION_NO_PATH = 10009;
223223

224+
/**
225+
* BCMath extension not installed
226+
*
227+
* @var int
228+
*/
229+
const EXCEPTION_BCMATH_NOT_INSTALLED = 10010;
230+
224231
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
225232
// Caching method constants ////////////////////////////////////////////////////////////////////////////////////////////////////////////
226233
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -471,6 +478,10 @@ public function __destruct() {
471478
* @throws \Exception
472479
*/
473480
public function open($file = null, $mode = self::FILE_IO, $defaultFields = self::ALL) {
481+
if (!function_exists('bcadd')) {
482+
throw new \Exception(__CLASS__ . ": BCMath extension is not installed.", self::EXCEPTION_BCMATH_NOT_INSTALLED);
483+
}
484+
474485
// find the referred file and its size
475486
$rfile = self::findFile($file);
476487
$size = filesize($rfile);

0 commit comments

Comments
 (0)