private function testGMP() {        
     $gmpfuncs = array(
         'gmp_init','gmp_setbit','gmp_strval','gmp_testbit',
         'gmp_cmp','gmp_intval','gmp_add','gmp_neg','gmp_mul',
         'gmp_sub','gmp_pow','gmp_scan0','gmp_and','gmp_or');
     return array_intersect($gmpfuncs,get_extension_funcs('gmp')) == $gmpfuncs;
 }
Пример #2
0
 protected static function testGD()
 {
     $gd = array();
     $GDfuncList = get_extension_funcs('gd');
     ob_start();
     @phpinfo(INFO_MODULES);
     $output = ob_get_contents();
     ob_end_clean();
     $matches[1] = '';
     if ($output !== '') {
         if (preg_match("/GD Version[ \t]*(<[^>]+>[ \t]*)+([^<>]+)/s", $output, $matches)) {
             $gdversion = $matches[2];
         } else {
             return $gd;
         }
     }
     if (function_exists('imagecreatetruecolor') && function_exists('imagecreatefromjpeg')) {
         $gdversion = isset($gdversion) ? $gdversion : 2;
         $gd['gd2'] = "GD: " . $gdversion;
     } elseif (function_exists('imagecreatefromjpeg')) {
         $gdversion = isset($gdversion) ? $gdversion : 1;
         $gd['gd1'] = "GD: " . $gdversion;
     }
     return $gd;
 }
Пример #3
0
 /**
  * name setter
  *
  * @param string
  */
 function setName($name)
 {
     if (!self::isName($name)) {
         return PEAR::raiseError("'{$name}' is not a valid function name");
     }
     switch ($this->role) {
         case "internal":
             if (!$this->isInternalName($name)) {
                 return PEAR::raiseError("'{$name}' is not a valid internal function name");
             }
             break;
         case "public":
             // keywords are not allowed as function names
             if (self::isKeyword($name)) {
                 return PEAR::raiseError("'{$name}' is a reserved word which is not valid for function names");
             }
             // you should not redefine standard PHP functions
             foreach (get_extension_funcs("standard") as $stdfunc) {
                 if (!strcasecmp($name, $stdfunc)) {
                     return PEAR::raiseError("'{$name}' is already the name of a PHP standard function");
                 }
             }
             break;
     }
     $this->name = $name;
     return true;
 }
Пример #4
0
 public function curl_post($url, $post, $type = 'post', $timeout = 30)
 {
     while (list($k, $v) = each($post)) {
         $get .= rawurlencode($k) . "=" . rawurlencode($v) . "&";
     }
     $get = substr($get, 0, -1);
     $url .= "?" . $get;
     if (get_extension_funcs('curl') && function_exists('curl_init') && function_exists('curl_setopt') && function_exists('curl_exec') && function_exists('curl_close')) {
         $curlHandle = curl_init();
         curl_setopt($curlHandle, CURLOPT_URL, $url);
         if ($type == 'post') {
             curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, "POST");
             curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $post);
         } else {
             curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, "GET");
         }
         curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($curlHandle, CURLOPT_SSL_VERIFYHOST, FALSE);
         curl_setopt($curlHandle, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
         curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($curlHandle, CURLOPT_AUTOREFERER, 1);
         curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
         $result = curl_exec($curlHandle);
         curl_close($curlHandle);
     }
     $result = trim($result);
     return $result;
 }
Пример #5
0
 public function getLogin($r)
 {
     $target = $r->get('target');
     if (!extension_loaded("eid")) {
         dl("eid.so");
     }
     if (!extension_loaded("eid")) {
         echo "The eid extension is not loaded into this PHP!<p>\n";
         print_r(get_loaded_extensions());
         exit;
     }
     if (!function_exists("eid_decode")) {
         echo "The eid_decode function is not available in this eid extension!<p>\n";
         print_r(get_extension_funcs("eid"));
         exit;
     }
     $ut_user = eid_decode();
     if (isset($ut_user->status) && EID_ERR_OK != $ut_user->status) {
         unset($ut_user);
     }
     if ($ut_user == NULL) {
         $url = $r->app_root . '/login?target=' . $target;
         header("Set-Cookie: DOC={$url}; path=/; domain=.utexas.edu;");
         header("Location: https://utdirect.utexas.edu");
         echo "user is not logged in";
         exit;
     }
     if ($ut_user) {
         switch ($ut_user->status) {
             case EID_ERR_OK:
                 //echo "EID decode ok<br>\n";
                 break;
             case EID_ERR_INVALID:
                 echo "Invalid EID encoding";
                 exit;
             case EID_ERR_BADARG:
                 echo "Internal error in EID decoding";
                 exit;
             case EID_ERR_BADSIG:
                 echo "Invalid EID signature";
                 exit;
         }
         $db_user = $r->getUser('none');
         if (!$db_user->retrieveByEid($ut_user->eid)) {
             $db_user->eid = strtolower($ut_user->eid);
             $db_user->name = $ut_user->name;
             $db_user->insert();
         }
         $r->setCookie('eid', $db_user->eid);
         $r->setCookie('max', $db_user->max_items);
         $r->setCookie('display', $db_user->display);
         $db_user->getHttpPassword($r->getAuthToken());
         if ($target) {
             $r->renderRedirect(urldecode($target));
         } else {
             $r->renderRedirect();
         }
     }
 }
Пример #6
0
 /**
  * Sets all custom function properties to null.
  *
  * @param string $namespace  The namespace from which the global function will be called.
  * @param array  $extensions Array of PHP extensions whose functions will be mocked.
  *
  * @return void
  */
 public static function reset($namespace = null, array $extensions = array())
 {
     self::$functions = array();
     foreach ($extensions as $extension) {
         foreach (\get_extension_funcs($extension) as $name) {
             self::evaluate($namespace, $name);
         }
     }
 }
Пример #7
0
 /**
  * Verify GD2 settings (that the right version is actually installed).
  *
  * @return
  *   A boolean indicating if the GD toolkit is avaiable on this machine.
  */
 public function toolkit_check()
 {
     if ($check = get_extension_funcs('gd')) {
         if (in_array('imagegd2', $check)) {
             // GD2 support is available.
             return TRUE;
         }
     }
     return FALSE;
 }
Пример #8
0
 /**
  * Figures out if the Freetype-Extension (part of GD) is installed.
  */
 private function isFreetypeInstalled()
 {
     $arrExtensions = get_loaded_extensions();
     if (in_array('gd', $arrExtensions)) {
         $arrGdFunctions = get_extension_funcs('gd');
         if (in_array('imagettftext', $arrGdFunctions)) {
             $this->boolFreetypeInstalled = true;
         }
     }
 }
Пример #9
0
/**
 * GD2 has to be available on the system
 *
 * @return boolean
 */
function gd_available()
{
    if ($check = get_extension_funcs('gd')) {
        if (in_array('imagegd2', $check)) {
            // GD2 support is available.
            return true;
        }
    }
    return false;
}
 private function checkForExtensionUse($ext)
 {
     $funcs = get_extension_funcs($ext);
     foreach ($funcs as $func) {
         $process = $this->runCommand(sprintf('grep -ri "%s(" src | wc -l', $func));
         if (substr($process->getOutput(), 0, 1) !== "0") {
             return true;
         }
     }
     return false;
 }
 public function __construct()
 {
     foreach (get_loaded_extensions() as $module) {
         $funcs = get_extension_funcs($module);
         if (!$funcs) {
             continue;
         }
         foreach ($funcs as $f) {
             $this->list[] = $f;
         }
     }
 }
Пример #12
0
 /**
  * Verify basic functionality of reset().
  *
  * @test
  * @covers ::reset
  * @uses \Chadicus\FunctionRegistry::get
  *
  * @return void
  */
 public function reset()
 {
     foreach (\get_extension_funcs('date') as $name) {
         $this->assertFalse(function_exists(__NAMESPACE__ . "\\{$name}"));
     }
     FunctionRegistry::reset(__NAMESPACE__, ['date']);
     foreach (\get_extension_funcs('date') as $name) {
         $this->assertTrue(function_exists(__NAMESPACE__ . "\\{$name}"));
     }
     // call reset again just to ensure no exceptions thrown
     FunctionRegistry::reset(__NAMESPACE__, ['date']);
 }
Пример #13
0
 /**
  * @return array
  */
 public function getFunctions()
 {
     if (defined('HHVM_VERSION')) {
         $extension = $this->getReflector()->getCore()->getExtension($this->getExtensionName());
         foreach ($extension->getFunctionNames() as $function) {
             (yield [$function]);
         }
     } else {
         foreach (get_extension_funcs($this->getExtensionName()) as $function) {
             (yield [$function]);
         }
     }
 }
Пример #14
0
 function detect()
 {
     $GDfuncList = get_extension_funcs('gd');
     if ($GDfuncList) {
         if (in_array('imagegd2', $GDfuncList)) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Пример #15
0
 public function getFunctionsDisplay()
 {
     $return = array();
     $name = 'zend opcache';
     $functions = get_extension_funcs($name);
     if (!$functions) {
         $name = 'zend optimizer+';
         $functions = get_extension_funcs($name);
     }
     if ($functions) {
         $return[] = $this->_printTable($functions);
     }
     return implode(PHP_EOL, $return);
 }
Пример #16
0
 /**
  * Crypt_RSA_Math_BigInt constructor.
  * Checks an existance of big_int PECL math package.
  * This package is available at http://pecl.php.net/packages/big_int
  * On failure saves error description in $this->errstr
  *
  * @access public
  */
 function Crypt_RSA_Math_BigInt()
 {
     if (!extension_loaded('big_int')) {
         if (!@dl('big_int.' . PHP_SHLIB_SUFFIX) && !@dl('php_big_int.' . PHP_SHLIB_SUFFIX)) {
             // cannot load big_int extension
             $this->errstr = 'Crypt_RSA package requires big_int PECL package. ' . 'It is available at http://pecl.php.net/packages/big_int';
             return;
         }
     }
     // check version of big_int extension ( Crypt_RSA requires version 1.0.2 and higher )
     if (!in_array('bi_info', get_extension_funcs('big_int'))) {
         // there is no bi_info() function in versions, older than 1.0.2
         $this->errstr = 'Crypt_RSA package requires big_int package version 1.0.2 and higher';
     }
 }
Пример #17
0
/**
 * Turn a string or array into valid, standards-compliant (x)HTML
 *
 * Uses configuraton options in tidy.conf - which should minimally have show-body-only set to yes
 *
 * @param mixed $text The data to be tidied up
 * @return mixed $result Tidied data
 */
function tidy($text)
{
    static $tidy_funcs;
    static $tidy_conf;
    if (!isset($tidy_conf)) {
        $tidy_conf = SETTINGS_INC . 'tidy.conf';
    }
    if (is_array($text)) {
        $result = array();
        foreach (array_keys($text) as $key) {
            $result[$key] = tidy($text[$key]);
        }
        return $result;
    }
    // determine what tidy libraries are available
    if (empty($tidy_funcs)) {
        $tidy_funcs = get_extension_funcs('tidy');
    }
    $tidy_1_lib_available = !empty($tidy_funcs) && array_search('tidy_setopt', $tidy_funcs) !== false;
    $tidy_2_lib_available = !empty($tidy_funcs) && array_search('tidy_setopt', $tidy_funcs) === false;
    $tidy_command_line_available = TIDY_EXE ? file_exists(TIDY_EXE) : false;
    $text = protect_string_from_tidy($text);
    $text = '<html><body>' . $text . '</body></html>';
    if ($tidy_2_lib_available) {
        $tidy = new tidy();
        $tidy->parseString($text, $tidy_conf, 'utf8');
        $tidy->cleanRepair();
        $result = $tidy;
    } elseif ($tidy_1_lib_available) {
        tidy_load_config($tidy_conf);
        tidy_set_encoding('utf8');
        tidy_parse_string($text);
        tidy_clean_repair();
        $result = tidy_get_output();
    } elseif ($tidy_command_line_available) {
        $arg = escapeshellarg($text);
        // escape the bad stuff in the text
        $cmd = 'echo ' . $arg . ' | ' . TIDY_EXE . ' -q -config ' . $tidy_conf . ' 2> /dev/null';
        // the actual command - pipes the input to tidy which diverts its output to the random file
        $result = shell_exec($cmd);
        // execute the command
    } else {
        trigger_error('tidy does not appear to be available within php or at the command line - no tidying is taking place.');
        $result = $text;
    }
    return trim($result);
}
Пример #18
0
function opecc_convert($file_path)
{
    //check opencc module load correctly.
    $br = php_sapi_name() == "cli" ? "" : "<br>";
    if (!extension_loaded('opencc')) {
        dl('opencc.' . PHP_SHLIB_SUFFIX);
        echo "dl\n";
    }
    $module = 'opencc';
    $functions = get_extension_funcs($module);
    //read file
    $text = file_get_contents($file_path);
    $od = opencc_open("zhs2zht.ini");
    $text = opencc_convert($od, $text);
    opencc_close($od);
    return $text;
}
Пример #19
0
function newbb_getImageLibs()
{
    global $xoopsModuleConfig;
    $imageLibs = array();
    unset($output, $status);
    if ($xoopsModuleConfig['image_lib'] == 1 or $xoopsModuleConfig['image_lib'] == 0) {
        $path = empty($xoopsModuleConfig['path_magick']) ? "" : $xoopsModuleConfig['path_magick'] . "/";
        @exec($path . 'convert -version', $output, $status);
        if (empty($status) && !empty($output)) {
            if (preg_match("/imagemagick[ \t]+([0-9\\.]+)/i", $output[0], $matches)) {
                $imageLibs['imagemagick'] = $matches[0];
            }
        }
        unset($output, $status);
    }
    if ($xoopsModuleConfig['image_lib'] == 2 or $xoopsModuleConfig['image_lib'] == 0) {
        $path = empty($xoopsModuleConfig['path_netpbm']) ? "" : $xoopsModuleConfig['path_netpbm'] . "/";
        @exec($path . 'jpegtopnm -version 2>&1', $output, $status);
        if (empty($status) && !empty($output)) {
            if (preg_match("/netpbm[ \t]+([0-9\\.]+)/i", $output[0], $matches)) {
                $imageLibs['netpbm'] = $matches[0];
            }
        }
        unset($output, $status);
    }
    $GDfuncList = get_extension_funcs('gd');
    ob_start();
    @phpinfo(INFO_MODULES);
    $output = ob_get_contents();
    ob_end_clean();
    $matches[1] = '';
    $gdversion = '';
    if (preg_match("/GD Version[ \t]*(<[^>]+>[ \t]*)+([^<>]+)/s", $output, $matches)) {
        $gdversion = $matches[2];
    }
    if ($GDfuncList) {
        if (in_array('imagegd2', $GDfuncList)) {
            $imageLibs['gd2'] = $gdversion;
        } else {
            $imageLibs['gd1'] = $gdversion;
        }
    }
    return $imageLibs;
}
Пример #20
0
 /**
  * Testcase Constructor.
  *
  * @return void
  */
 public function setUpSuccess()
 {
     if (extension_loaded('http') === FALSE || empty(get_extension_funcs('http')) === FALSE) {
         $this->markTestSkipped('Extension http (2.x) is required.');
     }
     $this->header = $this->getMock('http\\Header', ['parse']);
     $method = [get_class($this->header), 'parse'];
     $parsed = file_get_contents(TEST_STATICS . '/Vortex/mpns_response_parsed.txt');
     $this->mock_method($method, "return {$parsed};");
     $this->logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $response = $this->getMockBuilder('Lunr\\Network\\CurlResponse')->disableOriginalConstructor()->getMock();
     $response->expects($this->once())->method('get_network_error_number')->will($this->returnValue(0));
     $file = TEST_STATICS . '/Vortex/mpns_response.txt';
     $map = [['http_code', 200], ['header_size', 129], ['url', 'http://localhost/']];
     $response->expects($this->exactly(3))->method('__get')->will($this->returnValueMap($map));
     $response->expects($this->once())->method('get_result')->will($this->returnValue(file_get_contents($file)));
     $this->class = new MPNSResponse($response, $this->logger, $this->header);
     $this->reflection = new ReflectionClass('Lunr\\Vortex\\MPNS\\MPNSResponse');
     $this->unmock_method($method);
 }
Пример #21
0
function CheckGDVersion()
{
    $GDfuncList = get_extension_funcs('gd');
    if (!$GDfuncList) {
        return 0;
    } else {
        if (in_array('imagegd2', $GDfuncList) && in_array('imagecreatetruecolor', $GDfuncList)) {
            return 2;
        } else {
            return 1;
        }
    }
}
Пример #22
0
 protected function compileState()
 {
     $status = opcache_get_status();
     $config = opcache_get_configuration();
     $files = [];
     if (!empty($status['scripts'])) {
         uasort($status['scripts'], function ($a, $b) {
             return $a['hits'] < $b['hits'];
         });
         foreach ($status['scripts'] as &$file) {
             $file['full_path'] = str_replace('\\', '/', $file['full_path']);
             $file['readable'] = ['hits' => number_format($file['hits']), 'memory_consumption' => $this->size($file['memory_consumption'])];
         }
         $files = array_values($status['scripts']);
     }
     $overview = array_merge($status['memory_usage'], $status['opcache_statistics'], ['used_memory_percentage' => round(100 * (($status['memory_usage']['used_memory'] + $status['memory_usage']['wasted_memory']) / $config['directives']['opcache.memory_consumption'])), 'hit_rate_percentage' => round($status['opcache_statistics']['opcache_hit_rate']), 'wasted_percentage' => round($status['memory_usage']['current_wasted_percentage'], 2), 'readable' => ['total_memory' => $this->size($config['directives']['opcache.memory_consumption']), 'used_memory' => $this->size($status['memory_usage']['used_memory']), 'free_memory' => $this->size($status['memory_usage']['free_memory']), 'wasted_memory' => $this->size($status['memory_usage']['wasted_memory']), 'num_cached_scripts' => number_format($status['opcache_statistics']['num_cached_scripts']), 'hits' => number_format($status['opcache_statistics']['hits']), 'misses' => number_format($status['opcache_statistics']['misses']), 'blacklist_miss' => number_format($status['opcache_statistics']['blacklist_misses']), 'num_cached_keys' => number_format($status['opcache_statistics']['num_cached_keys']), 'max_cached_keys' => number_format($status['opcache_statistics']['max_cached_keys']), 'start_time' => date_format(date_create("@{$status['opcache_statistics']['start_time']}"), 'Y-m-d H:i:s'), 'last_restart_time' => $status['opcache_statistics']['last_restart_time'] == 0 ? 'never' : date_format(date_create("@{$status['opcache_statistics']['last_restart_time']}"), 'Y-m-d H:i:s')]]);
     $directives = [];
     ksort($config['directives']);
     foreach ($config['directives'] as $k => $v) {
         $directives[] = ['k' => $k, 'v' => $v];
     }
     $version = array_merge($config['version'], ['php' => phpversion(), 'server' => $_SERVER['SERVER_SOFTWARE'], 'host' => function_exists('gethostname') ? gethostname() : (php_uname('n') ?: (empty($_SERVER['SERVER_NAME']) ? $_SERVER['HOST_NAME'] : $_SERVER['SERVER_NAME']))]);
     return ['version' => $version, 'overview' => $overview, 'files' => $files, 'directives' => $directives, 'blacklist' => $config['blacklist'], 'functions' => get_extension_funcs('Zend OPcache')];
 }
<?php

if (!extension_loaded('templates')) {
    dl('templates.so');
}
$module = 'templates';
$functions = get_extension_funcs($module);
echo "Functions available in the test extension:<br>\n";
foreach ($functions as $func) {
    echo $func . "<br>\n";
}
echo "<br>\n";
$function = 'confirm_' . $module . '_compiled';
if (extension_loaded($module)) {
    $str = $function($module);
} else {
    $str = "Module {$module} is not compiled into PHP";
}
echo "{$str}\n";
Пример #24
0
function showCodeImage($code)
{
    global $settings, $user_info, $modSettings;
    /*
    	Note: The higher the value of visual_verification_type the harder the verification is - from 0 as disabled through to 4 as "Very hard".
    */
    // What type are we going to be doing?
    $imageType = $modSettings['visual_verification_type'];
    // Special case to allow the admin center to show samples.
    if ($user_info['is_admin'] && isset($_GET['type'])) {
        $imageType = (int) $_GET['type'];
    }
    // Some quick references for what we do.
    // Do we show no, low or high noise?
    $noiseType = $imageType == 3 ? 'low' : ($imageType == 4 ? 'high' : ($imageType == 5 ? 'extreme' : 'none'));
    // Can we have more than one font in use?
    $varyFonts = $imageType > 3 ? true : false;
    // Just a plain white background?
    $simpleBGColor = $imageType < 3 ? true : false;
    // Plain black foreground?
    $simpleFGColor = $imageType == 0 ? true : false;
    // High much to rotate each character.
    $rotationType = $imageType == 1 ? 'none' : ($imageType > 3 ? 'low' : 'high');
    // Do we show some characters inversed?
    $showReverseChars = $imageType > 3 ? true : false;
    // Special case for not showing any characters.
    $disableChars = $imageType == 0 ? true : false;
    // What do we do with the font colors. Are they one color, close to one color or random?
    $fontColorType = $imageType == 1 ? 'plain' : ($imageType > 3 ? 'random' : 'cyclic');
    // Are the fonts random sizes?
    $fontSizeRandom = $imageType > 3 ? true : false;
    // How much space between characters?
    $fontHorSpace = $imageType > 3 ? 'high' : ($imageType == 1 ? 'medium' : 'minus');
    // Where do characters sit on the image? (Fixed position or random/very random)
    $fontVerPos = $imageType == 1 ? 'fixed' : ($imageType > 3 ? 'vrandom' : 'random');
    // Make font semi-transparent?
    $fontTrans = $imageType == 2 || $imageType == 3 ? true : false;
    // Give the image a border?
    $hasBorder = $simpleBGColor;
    // Is this GD2? Needed for pixel size.
    $testGD = get_extension_funcs('gd');
    $gd2 = in_array('imagecreatetruecolor', $testGD) && function_exists('imagecreatetruecolor');
    unset($testGD);
    // The amount of pixels inbetween characters.
    $character_spacing = 1;
    // What color is the background - generally white unless we're on "hard".
    if ($simpleBGColor) {
        $background_color = array(255, 255, 255);
    } else {
        $background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243);
    }
    // The color of the characters shown (red, green, blue).
    if ($simpleFGColor) {
        $foreground_color = array(0, 0, 0);
    } else {
        $foreground_color = array(64, 101, 136);
        // Has the theme author requested a custom color?
        if (isset($settings['verification_foreground'])) {
            $foreground_color = $settings['verification_foreground'];
        }
    }
    if (!is_dir($settings['default_theme_dir'] . '/fonts')) {
        return false;
    }
    // Get a list of the available fonts.
    $font_dir = dir($settings['default_theme_dir'] . '/fonts');
    $font_list = array();
    $ttfont_list = array();
    while ($entry = $font_dir->read()) {
        if (preg_match('~^(.+)\\.gdf$~', $entry, $matches) === 1) {
            $font_list[] = $entry;
        } elseif (preg_match('~^(.+)\\.ttf$~', $entry, $matches) === 1) {
            $ttfont_list[] = $entry;
        }
    }
    if (empty($font_list)) {
        return false;
    }
    // For non-hard things don't even change fonts.
    if (!$varyFonts) {
        $font_list = array($font_list[0]);
        // Try use Screenge if we can - it looks good!
        if (in_array('Screenge.ttf', $ttfont_list)) {
            $ttfont_list = array('Screenge.ttf');
        } else {
            $ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]);
        }
    }
    // Create a list of characters to be shown.
    $characters = array();
    $loaded_fonts = array();
    for ($i = 0; $i < strlen($code); $i++) {
        $characters[$i] = array('id' => $code[$i], 'font' => array_rand($font_list));
        $loaded_fonts[$characters[$i]['font']] = null;
    }
    // Load all fonts and determine the maximum font height.
    foreach ($loaded_fonts as $font_index => $dummy) {
        $loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]);
    }
    // Determine the dimensions of each character.
    $total_width = $character_spacing * strlen($code) + 20;
    $max_height = 0;
    foreach ($characters as $char_index => $character) {
        $characters[$char_index]['width'] = imagefontwidth($loaded_fonts[$character['font']]);
        $characters[$char_index]['height'] = imagefontheight($loaded_fonts[$character['font']]);
        $max_height = max($characters[$char_index]['height'] + 5, $max_height);
        $total_width += $characters[$char_index]['width'];
    }
    // Create an image.
    $code_image = $gd2 ? imagecreatetruecolor($total_width, $max_height) : imagecreate($total_width, $max_height);
    // Draw the background.
    $bg_color = imagecolorallocate($code_image, $background_color[0], $background_color[1], $background_color[2]);
    imagefilledrectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $bg_color);
    // Randomize the foreground color a little.
    for ($i = 0; $i < 3; $i++) {
        $foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255));
    }
    $fg_color = imagecolorallocate($code_image, $foreground_color[0], $foreground_color[1], $foreground_color[2]);
    // Color for the dots.
    for ($i = 0; $i < 3; $i++) {
        $dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255);
    }
    $randomness_color = imagecolorallocate($code_image, $dotbgcolor[0], $dotbgcolor[1], $dotbgcolor[2]);
    // Some squares/rectanges for new extreme level
    if ($noiseType == 'extreme') {
        for ($i = 0; $i < rand(1, 5); $i++) {
            $x1 = rand(0, $total_width / 4);
            $x2 = $x1 + round(rand($total_width / 4, $total_width));
            $y1 = rand(0, $max_height);
            $y2 = $y1 + round(rand(0, $max_height / 3));
            imagefilledrectangle($code_image, $x1, $y1, $x2, $y2, mt_rand(0, 1) ? $fg_color : $randomness_color);
        }
    }
    // Fill in the characters.
    if (!$disableChars) {
        $cur_x = 0;
        foreach ($characters as $char_index => $character) {
            // Can we use true type fonts?
            $can_do_ttf = function_exists('imagettftext');
            // How much rotation will we give?
            if ($rotationType == 'none') {
                $angle = 0;
            } else {
                $angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10);
            }
            // What color shall we do it?
            if ($fontColorType == 'cyclic') {
                // Here we'll pick from a set of acceptance types.
                $colors = array(array(10, 120, 95), array(46, 81, 29), array(4, 22, 154), array(131, 9, 130), array(0, 0, 0), array(143, 39, 31));
                if (!isset($last_index)) {
                    $last_index = -1;
                }
                $new_index = $last_index;
                while ($last_index == $new_index) {
                    $new_index = mt_rand(0, count($colors) - 1);
                }
                $char_fg_color = $colors[$new_index];
                $last_index = $new_index;
            } elseif ($fontColorType == 'random') {
                $char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2]));
            } else {
                $char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]);
            }
            if (!empty($can_do_ttf)) {
                // GD2 handles font size differently.
                if ($fontSizeRandom) {
                    $font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25);
                } else {
                    $font_size = $gd2 ? 18 : 24;
                }
                // Work out the sizes - also fix the character width cause TTF not quite so wide!
                $font_x = $fontHorSpace == 'minus' && $cur_x > 0 ? $cur_x - 3 : $cur_x + 5;
                $font_y = $max_height - ($fontVerPos == 'vrandom' ? mt_rand(2, 8) : ($fontVerPos == 'random' ? mt_rand(3, 5) : 5));
                // What font face?
                if (!empty($ttfont_list)) {
                    $fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)];
                }
                // What color are we to do it in?
                $is_reverse = $showReverseChars ? mt_rand(0, 1) : false;
                $char_color = function_exists('imagecolorallocatealpha') && $fontTrans ? imagecolorallocatealpha($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2], 50) : imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]);
                $fontcord = @imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $char_color, $fontface, $character['id']);
                if (empty($fontcord)) {
                    $can_do_ttf = false;
                } elseif ($is_reverse) {
                    imagefilledpolygon($code_image, $fontcord, 4, $fg_color);
                    // Put the character back!
                    imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $randomness_color, $fontface, $character['id']);
                }
                if ($can_do_ttf) {
                    $cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3);
                }
            }
            if (!$can_do_ttf) {
                // Rotating the characters a little...
                if (function_exists('imagerotate')) {
                    $char_image = $gd2 ? imagecreatetruecolor($character['width'], $character['height']) : imagecreate($character['width'], $character['height']);
                    $char_bgcolor = imagecolorallocate($char_image, $background_color[0], $background_color[1], $background_color[2]);
                    imagefilledrectangle($char_image, 0, 0, $character['width'] - 1, $character['height'] - 1, $char_bgcolor);
                    imagechar($char_image, $loaded_fonts[$character['font']], 0, 0, $character['id'], imagecolorallocate($char_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]));
                    $rotated_char = imagerotate($char_image, mt_rand(-100, 100) / 10, $char_bgcolor);
                    imagecopy($code_image, $rotated_char, $cur_x, 0, 0, 0, $character['width'], $character['height']);
                    imagedestroy($rotated_char);
                    imagedestroy($char_image);
                } else {
                    imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]));
                }
                $cur_x += $character['width'] + $character_spacing;
            }
        }
    } else {
        imageline($code_image, 0, 0, $total_width, $max_height, $fg_color);
        imageline($code_image, 0, $max_height, $total_width, 0, $fg_color);
    }
    // Make the background color transparent on the hard image.
    if (!$simpleBGColor) {
        imagecolortransparent($code_image, $bg_color);
    }
    if ($hasBorder) {
        imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color);
    }
    // Add some noise to the background?
    if ($noiseType != 'none') {
        for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2)) {
            for ($j = mt_rand(0, 10); $j < $total_width; $j += mt_rand(1, 10)) {
                imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color);
            }
        }
        // Put in some lines too?
        if ($noiseType != 'extreme') {
            $num_lines = $noiseType == 'high' ? mt_rand(3, 7) : mt_rand(2, 5);
            for ($i = 0; $i < $num_lines; $i++) {
                if (mt_rand(0, 1)) {
                    $x1 = mt_rand(0, $total_width);
                    $x2 = mt_rand(0, $total_width);
                    $y1 = 0;
                    $y2 = $max_height;
                } else {
                    $y1 = mt_rand(0, $max_height);
                    $y2 = mt_rand(0, $max_height);
                    $x1 = 0;
                    $x2 = $total_width;
                }
                imagesetthickness($code_image, mt_rand(1, 2));
                imageline($code_image, $x1, $y1, $x2, $y2, mt_rand(0, 1) ? $fg_color : $randomness_color);
            }
        } else {
            // Put in some ellipse
            $num_ellipse = $noiseType == 'extreme' ? mt_rand(6, 12) : mt_rand(2, 6);
            for ($i = 0; $i < $num_ellipse; $i++) {
                $x1 = round(rand($total_width / 4 * -1, $total_width + $total_width / 4));
                $x2 = round(rand($total_width / 2, 2 * $total_width));
                $y1 = round(rand($max_height / 4 * -1, $max_height + $max_height / 4));
                $y2 = round(rand($max_height / 2, 2 * $max_height));
                imageellipse($code_image, $x1, $y1, $x2, $y2, mt_rand(0, 1) ? $fg_color : $randomness_color);
            }
        }
    }
    // Show the image.
    if (function_exists('imagegif')) {
        header('Content-type: image/gif');
        imagegif($code_image);
    } else {
        header('Content-type: image/png');
        imagepng($code_image);
    }
    // Bail out.
    imagedestroy($code_image);
    die;
}
Пример #25
0
                            <div style="display:none" id="i-ext-<?php 
    echo md5($v);
    ?>
">
                                <h3>Function in extension: <?php 
    echo $v;
    ?>
</h3>
                                <?php 
    $funcs = get_extension_funcs($v);
    $funcs = empty($funcs) ? array() : $funcs;
    if ($funcs) {
        ?>
                                    <table cellpadding="0" cellspacing="0">
                                        <?php 
        foreach (get_extension_funcs($v) as $k => $func) {
            ?>
                                            <tr>
                                                <td><?php 
            echo $k++;
            ?>
</td>
                                                <td><?php 
            echo $func;
            ?>
</td>
                                            </tr>
                                        <?php 
        }
        ?>
                                    </table>
Пример #26
0
 public function env_check()
 {
     print "------------------environment checking------------------\r\n";
     //step1, shallow check : check  openssl and curl extensions
     print "[notice] start shallow check !\r\n";
     $extensions = get_loaded_extensions();
     if (!in_array('curl', $extensions)) {
         print "[error] shallow Check failed: please enable curl extension for php !\r\n";
         return FALSE;
     }
     if (!in_array('openssl', $extensions)) {
         print "[error] shallow Check failed: please enable openssl extension for php !\r\n";
         return FALSE;
     }
     print "[notice] shallow check passed !\r\n";
     //step2, function check : check used functions of openssl and curl
     print "[notice] start function check !\r\n";
     $func_openssl = get_extension_funcs("openssl");
     if (!in_array('openssl_pkey_get_public', $func_openssl)) {
         print "[error] function check failed: unknow function openssl_pkey_get_public !\r\n";
         return FALSE;
     }
     if (!in_array('openssl_public_encrypt', $func_openssl)) {
         print "[error] function check failed: unknow function openssl_public_encrypt !\r\n";
         return FALSE;
     }
     $func_curl = get_extension_funcs("curl");
     if (!in_array('curl_init', $func_curl)) {
         print "[error] function check failed: unknow function curl_init !\r\n";
         return FALSE;
     }
     if (!in_array('curl_setopt', $func_curl)) {
         print "[error] function check failed: unknow function curl_setopt !\r\n";
         return FALSE;
     }
     if (!in_array('curl_exec', $func_curl)) {
         print "[error] function check failed: unknow function curl_exec !\r\n";
         return FALSE;
     }
     if (!in_array('curl_error', $func_curl)) {
         print "[error] function check failed: unknow function curl_error !\r\n";
         return FALSE;
     }
     if (!in_array('curl_close', $func_curl)) {
         print "[error] function check failed: unknow function curl_close !\r\n";
         return FALSE;
     }
     if (!in_array('curl_errno', $func_curl)) {
         print "[error] function check failed: unknow function curl_errno !\r\n";
         return FALSE;
     }
     print "[notice] function check passed !\r\n";
     //step3, deep check: test pub encrypt and curl post indeed
     print "[notice] start deep check !\r\n";
     $path = PhpBaseRoot . 'app/baidu/dataApi/';
     $rsa = new RsaPublicEncrypt($path);
     if (!$rsa->pubEncrypt("test pub encrypt")) {
         print "[error] deep check failed: pub encrypt failed !\r\n";
         return false;
     }
     $url = "www.baidu.com";
     $heads = array('Content-Type:  text/html;charset=UTF-8');
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
     curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
     curl_setopt($curl, CURLOPT_HTTPHEADER, $heads);
     curl_setopt($curl, CURLOPT_POST, 1);
     curl_setopt($curl, CURLOPT_POSTFIELDS, "test curl post");
     curl_setopt($curl, CURLOPT_TIMEOUT, 30);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     $tmpInfo = curl_exec($curl);
     if (curl_errno($curl)) {
         print "[error] deep check failed: curl post failed !\r\n";
         return FALSE;
     }
     curl_close($curl);
     print "[notice] deep check passed !\r\n";
     print "----------------environment checking End----------------\r\n";
 }
Пример #27
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
extract($_POST);
extract($_REQUEST);
include "auth.php";
include "db_backup.php";
$backup_path = "./backup/";
//subfolder of .../admin/ where all the backups will be stored
$delimiter = ";#%%";
//delimiter for sql insert
if (!get_extension_funcs('zlib')) {
    echo "<p class='warn'>Compression module status notice:\r\n\t\t\t<font color='red'>Zlib is NOT installed on the server! Backup disabled!</p>\r\n\t";
}
//      Headline for BACKUP MANAGEMENT
echo "<div class='submenu cntr'>| Backup Management for Database:&nbsp;'{$database}' |</div>\r\n\t<div class='tblhead'>\r\n\t\t<form name='dobackup' id='dbform1' method='post' action='admin.php'>\r\n\t\t<dl class='tblhead'>\r\n\t\t\t";
//      List available backup files
if (!is_dir($backup_path)) {
    mkdir($backup_path, 0766);
}
$bgcolor = 'odrow';
$is_first = 1;
$folder = scandir($backup_path);
if ($is_first == 1) {
    echo "<dt class='headline x2 cntr'>Backup Files</dt>\r\n\t\t\t<dd class='headline cntr'>Manage</dd>\r\n\t\t\t";
}
$is_first = 0;
$count_backup = 0;
foreach ($folder as $backname) {
    if (eregi("__", $backname)) {
        //show only folder with two _ in its name
Пример #28
0
<?php

echo 'Function sets supported in this install are:<br />';
$extensions = get_loaded_extensions();
foreach ($extensions as $each_ext) {
    echo "{$each_ext} <br />";
    echo '<ul>';
    $ext_funcs = get_extension_funcs($each_ext);
    foreach ($ext_funcs as $func) {
        echo "<li> {$func} </li>";
    }
    echo '</ul>';
}
Пример #29
0
function CheckGDVersion()
{
    if (!function_exists("imagetypes") || !function_exists('imagecreatefromstring')) {
        return 0;
    }
    $GDfuncList = get_extension_funcs('gd');
    if (!$GDfuncList) {
        return 0;
    } else {
        if (in_array('imagegd2', $GDfuncList) && in_array('imagecreatetruecolor', $GDfuncList)) {
            return 2;
        } else {
            return 1;
        }
    }
}
Пример #30
0
    ?>
            </table></fieldset></div>
<?php 
} elseif ($info == 'php_extensions') {
    ?>
            <div class="listArea"></div>
            <div class="comboHeading dataTableRowGreenLite"><h2><?php 
    echo HEADING_PHP_EXT;
    ?>
</h2></div>
<?php 
    $extensions_array = get_loaded_extensions();
    $cells = 3;
    $php_base_link = 'http://www.php.net/manual/en/function.';
    foreach ($extensions_array as $extension) {
        $funcs_array = get_extension_funcs($extension);
        if (empty($funcs_array)) {
            continue;
        }
        ?>
            <div class="formArea"><fieldset><legend><?php 
        echo $extension . ' [' . count($funcs_array) . ']';
        ?>
</legend><table class="tabledata">
<?php 
        sort($funcs_array);
        $rows = $index = 0;
        foreach ($funcs_array as $function) {
            if (!($index % $cells)) {
                $row_class = $rows % 2 ? 'dataTableRowBlueLite' : 'dataTableRowAlt';
                echo '<tr class="' . $row_class . '">';