/** * 获得系统的信息 * * @access public * @return array 系统各项信息组成的数组 */ function get_system_info($_LANG = array()) { $system_info = array(); /* 检查系统基本参数 */ $system_info[] = array($_LANG['php_os'], PHP_OS); $system_info[] = array($_LANG['php_ver'], PHP_VERSION); /* 检查MYSQL支持情况 */ $mysql_enabled = function_exists('mysql_connect') ? $_LANG['support'] : $_LANG['not_support']; $system_info[] = array($_LANG['does_support_mysql'], $mysql_enabled); /* 检查图片处理函数库 */ $gd_ver = get_gd_version(); $gd_ver = empty($gd_ver) ? $_LANG['not_support'] : $gd_ver; if ($gd_ver > 0) { if (PHP_VERSION >= '4.3' && function_exists('gd_info')) { $gd_info = gd_info(); $jpeg_enabled = $gd_info['JPEG Support'] === true ? $_LANG['support'] : $_LANG['not_support']; $gif_enabled = $gd_info['GIF Create Support'] === true ? $_LANG['support'] : $_LANG['not_support']; $png_enabled = $gd_info['PNG Support'] === true ? $_LANG['support'] : $_LANG['not_support']; } else { if (function_exists('imagetypes')) { $jpeg_enabled = (imagetypes() & IMG_JPG) > 0 ? $_LANG['support'] : $_LANG['not_support']; $gif_enabled = (imagetypes() & IMG_GIF) > 0 ? $_LANG['support'] : $_LANG['not_support']; $png_enabled = (imagetypes() & IMG_PNG) > 0 ? $_LANG['support'] : $_LANG['not_support']; } else { $jpeg_enabled = $_LANG['not_support']; $gif_enabled = $_LANG['not_support']; $png_enabled = $_LANG['not_support']; } } } else { $jpeg_enabled = $_LANG['not_support']; $gif_enabled = $_LANG['not_support']; $png_enabled = $_LANG['not_support']; } $system_info[] = array($_LANG['gd_version'], $gd_ver); $system_info[] = array($_LANG['jpeg'], $jpeg_enabled); $system_info[] = array($_LANG['gif'], $gif_enabled); $system_info[] = array($_LANG['png'], $png_enabled); /* 检查系统是否支持以dwt,lib,dat为扩展名的文件 */ // $file_types = array( // 'dwt' => ROOT_PATH . 'themes/default/index.dwt', // 'lbi' => ROOT_PATH . 'themes/default/library/member.lbi', // 'dat' => ROOT_PATH . 'includes/codetable/ipdata.dat' // ); // $exists_info = file_types_exists($file_types); // $exists_info = empty($exists_info) ? $_LANG['support_dld'] : $exists_info; // $system_info[] = array($_LANG['does_support_dld'], $exists_info); /* 服务器是否安全模式开启 */ $safe_mode = ini_get('safe_mode') == '1' ? $_LANG['safe_mode_on'] : $_LANG['safe_mode_off']; $system_info[] = array($_LANG['safe_mode'], $safe_mode); return $system_info; }
function wp_dashboard_serverinfo() { global $text_direction; if ('rtl' == $text_direction) { echo '<style type="text/css"> #wp-serverinfo ul { padding-left: 15px !important; } </style>'; echo '<div id="wp-serverinfo" style="direction: ltr; text-align: left;">'; } echo '<p><strong>' . __('General', 'wp-serverinfo') . '</strong></p>'; echo '<ul>'; echo '<li>' . __('OS', 'wp-serverinfo') . ': <strong>' . PHP_OS . '</strong></li>'; echo '<li>' . __('Server', 'wp-serverinfo') . ': <strong>' . $_SERVER["SERVER_SOFTWARE"] . '</strong></li>'; echo '<li>' . __('Hostname', 'wp-serverinfo') . ': <strong>' . $_SERVER['SERVER_NAME'] . '</strong></li>'; echo '<li>' . __('IP:Port', 'wp-serverinfo') . ': <strong>' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT'] . '</strong></li>'; echo '<li>' . __('Document Root', 'wp-serverinfo') . ': <strong>' . $_SERVER['DOCUMENT_ROOT'] . '</strong></li>'; echo '</ul>'; echo '<p><strong>PHP</strong></p>'; echo '<ul>'; echo '<li>v<strong>' . PHP_VERSION . '</strong></li>'; echo '<li>GD: <strong>' . get_gd_version() . '</strong></li>'; echo '<li>' . __('Magic Quotes GPC', 'wp-serverinfo') . ': <strong>' . get_php_magic_quotes_gpc() . '</strong></li>'; echo '<li>' . __('Memory Limit', 'wp-serverinfo') . ': <strong>' . format_php_size(get_php_memory_limit()) . '</strong></li>'; echo '<li>' . __('Max Upload Size', 'wp-serverinfo') . ': <strong>' . format_php_size(get_php_upload_max()) . '</strong></li>'; echo '</ul>'; echo '<p><strong>MYSQL</strong></p>'; echo '<ul>'; echo '<li>v<strong>' . get_mysql_version() . '</strong></li>'; echo '<li>' . __('Maximum No. Connections', 'wp-serverinfo') . ': <strong>' . number_format_i18n(get_mysql_max_allowed_connections(), 0) . '</strong></li>'; echo '<li>' . __('Maximum Packet Size', 'wp-serverinfo') . ': <strong>' . format_filesize(get_mysql_max_allowed_packet()) . '</strong></li>'; echo '<li>' . __('Data Disk Usage', 'wp-serverinfo') . ': <strong>' . format_filesize(get_mysql_data_usage()) . '</strong></li>'; echo '<li>' . __('Index Disk Usage', 'wp-serverinfo') . ': <strong>' . format_filesize(get_mysql_index_usage()) . '</strong></li>'; echo '</ul>'; echo '<p class="textright"><a href="' . admin_url('index.php?page=wp-serverinfo/wp-serverinfo.php') . '" class="button">' . __('View all', 'wp-serverinfo') . '</a></p>'; if ('rtl' == $text_direction) { echo '</div>'; } }
$f_captcha = gpc_get_string('captcha', ''); $f_username = trim($f_username); $f_email = email_append_domain(trim($f_email)); $f_captcha = utf8_strtolower(trim($f_captcha)); # Retrieve captcha key now, as session might get cleared by logout $t_form_key = session_get_int(CAPTCHA_KEY, null); # force logout on the current user if already authenticated if (auth_is_user_authenticated()) { auth_logout(); } # Check to see if signup is allowed if (OFF == config_get_global('allow_signup')) { print_header_redirect('login_page.php'); exit; } if (ON == config_get('signup_use_captcha') && get_gd_version() > 0 && helper_call_custom_function('auth_can_change_password', array())) { # captcha image requires GD library and related option to ON $t_key = utf8_strtolower(utf8_substr(md5(config_get('password_confirm_hash_magic_string') . $t_form_key), 1, 5)); if ($t_key != $f_captcha) { trigger_error(ERROR_SIGNUP_NOT_MATCHING_CAPTCHA, ERROR); } # Clear captcha cache session_delete(CAPTCHA_IMG); } email_ensure_not_disposable($f_email); # notify the selected group a new user has signed-up if (user_signup($f_username, $f_email)) { email_notify_new_account($f_username, $f_email); } form_security_purge('signup'); html_page_top1();
function masc_captcha($config) { // Test for GD-Library(-Version) $this->gd_version = get_gd_version(); if ($this->gd_version == 0) { die("There is no GD-Library-Support enabled. The Captcha-Class cannot be used!"); } if ($this->debug) { echo "\n<br />-Captcha-Debug: The available GD-Library has major version " . $this->gd_version; } // extracts config array if (is_array($config)) { if ($this->debug) { echo "\n<br />-Captcha-Debug: Extracts Config-Array in unsecure-mode!"; } foreach ($config as $k => $v) { $this->{$k} = $v; } } // check vars for maxtry, secretposition and min-max-size if ($this->minsize > $this->maxsize) { $temp = $this->minsize; $this->minsize = $this->maxsize; $this->maxsize = $temp; if ($this->debug) { echo "<br />-Captcha-Debug: Arrghh! What do you think I mean with min and max? Switch minsize with maxsize."; } } // check TrueTypeFonts if (is_array($this->TTF_RANGE)) { if ($this->debug) { echo "\n<br />-Captcha-Debug: Check given TrueType-Array! (" . count($this->TTF_RANGE) . ")"; } $temp = array(); foreach ($this->TTF_RANGE as $k => $v) { if (is_readable($this->TTF_folder . $v)) { $temp[] = $v; } } $this->TTF_RANGE = $temp; if ($this->debug) { echo "\n<br />-Captcha-Debug: Valid TrueType-files: (" . count($this->TTF_RANGE) . ")"; } //if(count($this->TTF_RANGE) < 1) die('No Truetypefont available for the CaptchaClass.'); } else { if ($this->debug) { echo "\n<br />-Captcha-Debug: Check given TrueType-File! (" . $this->TTF_RANGE . ")"; } if (!is_readable($this->TTF_folder . $this->TTF_RANGE)) { die('No Truetypefont available for the CaptchaClass.'); } } // select first TrueTypeFont $this->change_TTF(); if ($this->debug) { echo "\n<br />-Captcha-Debug: Set current TrueType-File: (" . $this->TTF_file . ")"; } // get number of noise-chars for background if is enabled $this->nb_noise = $this->noise ? $this->chars * $this->noisefactor : 0; if ($this->debug) { echo "\n<br />-Captcha-Debug: Set number of noise characters to: (" . $this->nb_noise . ")"; } // set dimension of image $this->lx = ($this->chars + 1) * (int) (($this->maxsize + $this->minsize) / 1.5); $this->ly = (int) (2.4 * $this->maxsize); if ($this->debug) { echo "\n<br />-Captcha-Debug: Set image dimension to: (" . $this->lx . " x " . $this->ly . ")"; } }
print_test_row('check mail configuration: allow_signup = ON requires enable_email_notification = ON', OFF == config_get_global('allow_signup') || ON == config_get_global('enable_email_notification')); print_test_row('check mail configuration: allow_signup = ON requires send_reset_password = ON', OFF == config_get_global('allow_signup') || ON == config_get_global('send_reset_password')); print_test_row('check language configuration: fallback_language is not \'auto\'', 'auto' != config_get_global('fallback_language')); print_test_row('check configuration: allow_anonymous_login = ON requires anonymous_account to be set', OFF == config_get_global('allow_anonymous_login') || strlen(config_get_global('anonymous_account')) > 0); $t_anon_user = false; print_test_row('check configuration: anonymous_account is a valid username if set', strlen(config_get_global('anonymous_account')) > 0 ? ($t_anon_user = user_get_id_by_name(config_get_global('anonymous_account'))) !== false : TRUE); print_test_row('check configuration: anonymous_account should not be an administrator', $t_anon_user ? !user_is_administrator($t_anon_user) : TRUE); print_test_row('$g_bug_link_tag is not empty ("' . config_get_global('bug_link_tag') . '")', '' != config_get_global('bug_link_tag')); print_test_row('$g_bugnote_link_tag is not empty ("' . config_get_global('bugnote_link_tag') . '")', '' != config_get_global('bugnote_link_tag')); print_test_row('filters: dhtml_filters = ON requires use_javascript = ON', OFF == config_get_global('dhtml_filters') || ON == config_get_global('use_javascript')); print_test_row('Phpmailer sendmail configuration requires escapeshellcmd. Please use a different phpmailer method if this is blocked.', PHPMAILER_METHOD_SENDMAIL != config_get('phpMailer_method') || PHPMAILER_METHOD_SENDMAIL == config_get('phpMailer_method') && function_exists('escapeshellcmd')); print_test_row('Phpmailer sendmail configuration requires escapeshellarg. Please use a different phpmailer method if this is blocked.', PHPMAILER_METHOD_SENDMAIL != config_get('phpMailer_method') || PHPMAILER_METHOD_SENDMAIL == config_get('phpMailer_method') && function_exists('escapeshellarg')); check_zend_optimiser_version(); if (plugin_is_installed('MantisGraph')) { plugin_push_current('MantisGraph'); print_test_row('checking gd is enabled, and version 2...', get_gd_version() == 2); if (plugin_config_get('eczlibrary', ON) == OFF) { $t_jpgraph_path = config_get('absolute_path') . 'library' . DIRECTORY_SEPARATOR . 'jpgraph' . DIRECTORY_SEPARATOR; if (!file_exists($t_jpgraph_path . 'jpgraph.php')) { print_test_row('checking we can find jpgraph class files...', false); } else { require_once $t_jpgraph_path . 'jpgraph.php'; print_test_row('Checking Jpgraph version (if installed)...', version_compare(JPG_VERSION, '2.3.0') ? true : false, JPG_VERSION); } print_test_row('check configuration: jpgraph (if used) requires php bundled gd for antialiasing support', plugin_config_get('jpgraph_antialias', OFF) == OFF || function_exists('imageantialias')); } plugin_pop_current(); } print_test_row('Checking if ctype is enabled in php (required for rss feeds)....', extension_loaded('ctype')); print_test_row('Checking for mysql is at least version 4.1...', !(db_is_mysql() && version_compare($t_serverinfo['version'], '4.1.0', '<'))); print_test_row('Checking for broken mysql version ( bug 10250)...', !(db_is_mysql() && $t_serverinfo['version'] == '4.1.21'));
* * @uses check_api.php * @uses config_api.php */ if (!defined('CHECK_DISPLAY_INC_ALLOW')) { return; } # MantisBT Check API require_once 'check_api.php'; require_api('config_api.php'); check_print_section_header_row('Display'); check_print_test_row('bug_link_tag is not blank/null', config_get_global('bug_link_tag'), array(false => 'The value of the bug_link_tag option cannot be blank/null.')); check_print_test_row('bugnote_link_tag is not blank/null', config_get_global('bugnote_link_tag'), array(false => 'The value of the bugnote_link_tag option cannot be blank/null.')); if (plugin_is_installed('MantisGraph')) { plugin_push_current('MantisGraph'); check_print_test_row('Checking GD library is enabled, and version 2...', get_gd_version() == 2); if (plugin_config_get('eczlibrary', ON) == OFF) { $t_jpgraph_path = plugin_config_get('jpgraph_path'); if ($t_jpgraph_path == '') { $t_jpgraph_path = config_get('absolute_path') . 'library/jpgraph'; } $t_jpgraph_path .= '/jpgraph.php'; $t_jpgraph_found = check_print_test_row('Checking we can find jpgraph library class files', file_exists($t_jpgraph_path), dirname($t_jpgraph_path)); if ($t_jpgraph_found) { require_once $t_jpgraph_path; # Old versions of jpgraph did not define the constant $t_jpgraph_version = defined('JPG_VERSION') ? JPG_VERSION : 'Unknown version'; check_print_test_row('Checking jpgraph library version is at least 2.3.0', version_compare($t_jpgraph_version, '2.3.0', '>='), $t_jpgraph_version); } $t_jpgraph_antialias = plugin_config_get('jpgraph_antialias', OFF); if ($t_jpgraph_antialias) {
</div> <div class="field-container"> <label for="email-field"><span><?php echo lang_get('email_label'); ?> </span></label> <span class="input"><?php print_email_input('email', ''); ?> </span> <span class="label-style"></span> </div> <?php $t_allow_passwd = helper_call_custom_function('auth_can_change_password', array()); if (ON == config_get('signup_use_captcha') && get_gd_version() > 0 && true == $t_allow_passwd) { # captcha image requires GD library and related option to ON echo '<div class="field-container">'; echo '<label for="captcha-field"><span>' . lang_get('signup_captcha_request_label') . '</span></label>'; echo '<span id="captcha-input" class="input">'; print_captcha_input('captcha', ''); echo '<span class="captcha-image"><img src="make_captcha_img.php?public_key=' . $t_public_key . '" alt="visual captcha" /></span>'; echo '</span>'; echo '<input type="hidden" name="public_key" value="' . $t_public_key . '" />'; echo '<span class="label-style"></span>'; echo '</div>'; } if (false == $t_allow_passwd) { echo '<span id="no-password-msg">'; echo lang_get('no_password_request'); echo '</span>';
/** * Resize an image to the specified size, but retain the aspect ratio. * * @param URLPATH The URL to the image to resize * @param PATH The file path (including filename) to where the resized image will be saved * @param integer The maximum width we want our new image to be (-1 means "don't factor this in") * @param integer The maximum height we want our new image to be (-1 means "don't factor this in") * @param integer This is only considered if both $width and $height are -1. If set, it will fit the image to a box of this dimension (suited for resizing both landscape and portraits fairly) * @param boolean Whether to exit ocPortal if an error occurs * @param ?string The file extension to save with (NULL: same as our input file) * @param boolean Whether $from was in fact a path, not a URL * @param boolean Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images) * @param ?array This optional parameter allows us to specify cropping or padding for the image. See comments in the function. (NULL: no details passed) * @return boolean Success */ function convert_image($from, $to, $width, $height, $box_width = -1, $exit_on_error = true, $ext2 = NULL, $using_path = false, $only_make_smaller = false, $thumb_options = NULL) { disable_php_memory_limit(); // Load $ext = get_file_extension($from); if ($using_path) { if (!check_memory_limit_for($from, $exit_on_error)) { return false; } $from_file = @file_get_contents($from); } else { $file_path_stub = convert_url_to_path($from); if (!is_null($file_path_stub)) { if (!check_memory_limit_for($file_path_stub, $exit_on_error)) { return false; } $from_file = @file_get_contents($file_path_stub); } else { $from_file = http_download_file($from, 1024 * 1024 * 20, false); if (is_null($from_file)) { $from_file = false; } } } if ($from_file === false) { if ($exit_on_error) { warn_exit(do_lang_tempcode('UPLOAD_PERMISSION_ERROR', escape_html($from))); } require_code('site'); if (!file_exists(get_custom_file_base() . '/uploads/missing_ok')) { attach_message(do_lang_tempcode('UPLOAD_PERMISSION_ERROR', escape_html($from)), 'warn'); } return false; } $source = @imagecreatefromstring($from_file); if (!is_null($thumb_options) || !$only_make_smaller) { unset($from_file); } if ($source === false) { if ($exit_on_error) { warn_exit(do_lang_tempcode('CORRUPT_FILE', escape_html($from))); } require_code('site'); attach_message(do_lang_tempcode('CORRUPT_FILE', escape_html($from)), 'warn'); return false; } // Derive actual width x height, for the given maximum box (maintain aspect ratio) // =============================================================================== $sx = imagesx($source); $sy = imagesy($source); $red = NULL; if (is_null($thumb_options)) { if ($width == 0) { $width = 1; } if ($height == 0) { $height = 1; } // If we're not sure if this is gonna stretch to fit a width or stretch to fit a height if ($width == -1 && $height == -1) { if ($sx > $sy) { $width = $box_width; } else { $height = $box_width; } } if ($width != -1 && $height != -1) { if (floatval($sx) / floatval($width) > floatval($sy) / floatval($height)) { $_width = $width; $_height = intval($sy * ($width / $sx)); } else { $_height = $height; $_width = intval($sx * ($height / $sy)); } } elseif ($height == -1) { $_width = $width; $_height = intval($width / ($sx / $sy)); } elseif ($width == -1) { $_height = $height; $_width = intval($height / ($sy / $sx)); } if ($_width > $sx && $only_make_smaller) { $_width = $sx; $_height = $sy; // We can just escape, nothing to do imagedestroy($source); if ($using_path && $from == $to) { return true; } if ($using_path) { copy($from, $to); } else { $_to = @fopen($to, 'wb') or intelligent_write_error($to); fwrite($_to, $from_file); fclose($_to); } fix_permissions($to); sync_file($to); return true; } if ($_width < 1) { $_width = 1; } if ($_height < 1) { $_height = 1; } // Pad out options for imagecopyresized // $dst_im,$src_im,$dst_x,$dst_y,$src_x,$src_y,$dst_w,$dst_h,$src_w,$src_h $dest_x = 0; $dest_y = 0; $source_x = 0; $source_y = 0; } else { // Thumbnail-specific (for the moment) behaviour. We require the ability // to crop (ie. window-off a section of the image), and pad (ie. provide a // background around the image). We keep this separate to the above code // because that already works well across various aspects of the site. // // Format of the array is 'type'=>'crop' or 'type'=>'pad'; 'where'=>'end', // 'where'=>'start' or 'where'=>'both'. For padding, there is an optional // 'background'=>'RRGGBBAA' or 'background'=>'RRGGBB' for colored padding // with or without transparency. // Grab the dimensions we would get if we didn't crop or scale $wrong_x = intval(round(floatval($sx) / $thumb_options['scale'])); $wrong_y = intval(round(floatval($sy) / $thumb_options['scale'])); // Handle cropping here if ($thumb_options['type'] == 'crop' || $thumb_options['type'] == 'pad_horiz_crop_horiz' && $wrong_x > $width || $thumb_options['type'] == 'pad_vert_crop_vert' && $wrong_y > $height) { // See which direction we're cropping in if (intval(round(floatval($sx) / $thumb_options['scale'])) != $width) { $crop_direction = 'x'; } else { $crop_direction = 'y'; } // We definitely have to crop, since symbols.php only tells us to crop // if it has to. Thus we know we're going to fill the output image, the // only question is with what part of the source image? // Get the amount we'll lose from the source if ($crop_direction == 'x') { $crop_off = intval($sx - $width * $thumb_options['scale']); } elseif ($crop_direction == 'y') { $crop_off = intval($sy - $height * $thumb_options['scale']); } // Now we see how much to chop off the start (we don't care about the // end, as this will be handled by using an appropriate window size) $displacement = 0; if ($thumb_options['where'] == 'start' || $thumb_options['where'] == 'start_if_vertical' && $crop_direction == 'y' || $thumb_options['where'] == 'start_if_horizontal' && $crop_direction == 'x') { $displacement = 0; } elseif ($thumb_options['where'] == 'end' || $thumb_options['where'] == 'end_if_vertical' && $crop_direction == 'y' || $thumb_options['where'] == 'end_if_horizontal' && $crop_direction == 'x') { $displacement = intval(floatval($crop_off)); } else { $displacement = intval(floatval($crop_off) / 2.0); } // Now we convert this to the right x and y start locations for the // window $source_x = $crop_direction == 'x' ? $displacement : 0; $source_y = $crop_direction == 'y' ? $displacement : 0; // Now we set the width and height of our window, which will be scaled // versions of the width and height of the output $sx = intval($width * $thumb_options['scale']); $sy = intval($height * $thumb_options['scale']); // We start at the origin of our output $dest_x = 0; $dest_y = 0; // and it is always the full size it can be (or else we'd be cropping // too much) $_width = $width; $_height = $height; } elseif ($thumb_options['type'] == 'pad' || $thumb_options['type'] == 'pad_horiz_crop_horiz' && $wrong_x < $width || $thumb_options['type'] == 'pad_vert_crop_vert' && $wrong_y < $height) { // Padding code lives here. We definitely need to pad some excess space // because otherwise symbols.php would not call us. Thus we need a // background (can be transparent). Let's see if we've been given one. if (array_key_exists('background', $thumb_options) && !is_null($thumb_options['background'])) { if (substr($thumb_options['background'], 0, 1) == '#') { $thumb_options['background'] = substr($thumb_options['background'], 1); } // We've been given a background, let's find out what it is if (strlen($thumb_options['background']) == 8) { // We've got an alpha channel $using_alpha = true; $red_str = substr($thumb_options['background'], 0, 2); $green_str = substr($thumb_options['background'], 2, 2); $blue_str = substr($thumb_options['background'], 4, 2); $alpha_str = substr($thumb_options['background'], 6, 2); } else { // We've not got an alpha channel $using_alpha = false; $red_str = substr($thumb_options['background'], 0, 2); $green_str = substr($thumb_options['background'], 2, 2); $blue_str = substr($thumb_options['background'], 4, 2); } $red = intval($red_str, 16); $green = intval($green_str, 16); $blue = intval($blue_str, 16); if ($using_alpha) { $alpha = intval($alpha_str, 16); } } else { // We've not got a background, so let's find a representative color // for the image by resampling the whole thing to 1 pixel. $temp_img = imagecreatetruecolor(1, 1); // Make an image to map on to imagecopyresampled($temp_img, $source, 0, 0, 0, 0, 1, 1, $sx, $sy); // Map the source image on to the 1x1 image $rgb_index = imagecolorat($temp_img, 0, 0); // Grab the color index of the single pixel $rgb_array = imagecolorsforindex($temp_img, $rgb_index); // Get the channels for it $red = $rgb_array['red']; // Grab the red $green = $rgb_array['green']; // Grab the green $blue = $rgb_array['blue']; // Grab the blue // Sort out if we're using alpha $using_alpha = false; if (array_key_exists('alpha', $rgb_array)) { $using_alpha = true; } if ($using_alpha) { $alpha = 255 - ($rgb_array['alpha'] * 2 + 1); } // Destroy the temporary image imagedestroy($temp_img); } // Now we need to work out how much padding we're giving, and where // The axis if (intval(round(floatval($sx) / $thumb_options['scale'])) != $width) { $pad_axis = 'x'; } else { $pad_axis = 'y'; } // The amount if ($pad_axis == 'x') { $padding = intval(round(floatval($width) - floatval($sx) / $thumb_options['scale'])); } else { $padding = intval(round(floatval($height) - floatval($sy) / $thumb_options['scale'])); } // The distribution if ($thumb_options['where'] == 'start' || $thumb_options['where'] == 'start_if_vertical' && $pad_axis == 'y' || $thumb_options['where'] == 'start_if_horizontal' && $pad_axis == 'x') { $pad_amount = 0; } else { $pad_amount = intval(floatval($padding) / 2.0); } // Now set all of the parameters needed for blitting our image // $sx and $sy are fine, since they cover the whole image $source_x = 0; $source_y = 0; $_width = $pad_axis == 'x' ? intval(round(floatval($sx) / $thumb_options['scale'])) : $width; $_height = $pad_axis == 'y' ? intval(round(floatval($sy) / $thumb_options['scale'])) : $height; $dest_x = $pad_axis == 'x' ? $pad_amount : 0; $dest_y = $pad_axis == 'y' ? $pad_amount : 0; } } // Resample/copy $gd_version = get_gd_version(); if ($gd_version >= 2.0) { // Set the background if we have one if (!is_null($thumb_options) && !is_null($red)) { $dest = imagecreatetruecolor($width, $height); imagealphablending($dest, false); if (function_exists('imagecolorallocatealpha') && $using_alpha) { $back_col = imagecolorallocatealpha($dest, $red, $green, $blue, 127 - intval(floatval($alpha) / 2.0)); } else { $back_col = imagecolorallocate($dest, $red, $green, $blue); } imagefilledrectangle($dest, 0, 0, $width, $height, $back_col); if (function_exists('imagesavealpha')) { imagesavealpha($dest, true); } } else { $dest = imagecreatetruecolor($_width, $_height); imagealphablending($dest, false); if (function_exists('imagesavealpha')) { imagesavealpha($dest, true); } } imagecopyresampled($dest, $source, $dest_x, $dest_y, $source_x, $source_y, $_width, $_height, $sx, $sy); } else { // Set the background if we have one if (!is_null($thumb_options) && !is_null($red)) { $dest = imagecreate($width, $height); $back_col = imagecolorallocate($dest, $red, $green, $blue); imagefill($dest, 0, 0, $back_col); } else { $dest = imagecreate($_width, $_height); } imagecopyresized($dest, $source, $dest_x, $dest_y, $source_x, $source_y, $_width, $_height, $sx, $sy); } // Clean up imagedestroy($source); // Save if (is_null($ext2)) { $ext2 = get_file_extension($to); } // If we've got transparency then we have to save as PNG if (!is_null($thumb_options) && isset($red) && $using_alpha) { $ext2 = 'png'; } if (function_exists('imagepng') && $ext2 == 'png') { if (strtolower(substr($to, -4)) != '.png') { $to = $to . '.png'; } $test = @imagepng($dest, $to); if (!$test) { if ($exit_on_error) { warn_exit(do_lang_tempcode('ERROR_IMAGE_SAVE', @strval($php_errormsg))); } require_code('site'); attach_message(do_lang_tempcode('ERROR_IMAGE_SAVE', @strval($php_errormsg)), 'warn'); return false; } } elseif (function_exists('imagejpeg') && ($ext2 == 'jpg' || $ext2 == 'jpeg')) { $jpeg_quality = get_value('jpeg_quality'); if ($jpeg_quality !== NULL) { $test = @imagejpeg($dest, $to, intval($jpeg_quality)); } else { $test = @imagejpeg($dest, $to); } if (!$test) { if ($exit_on_error) { warn_exit(do_lang_tempcode('ERROR_IMAGE_SAVE', @strval($php_errormsg))); } require_code('site'); attach_message(do_lang_tempcode('ERROR_IMAGE_SAVE', @strval($php_errormsg)), 'warn'); return false; } } elseif (function_exists('imagegif') && $ext2 == 'gif') { $test = @imagegif($dest, $to); if (!$test) { if ($exit_on_error) { warn_exit(do_lang_tempcode('ERROR_IMAGE_SAVE', @strval($php_errormsg))); } require_code('site'); attach_message(do_lang_tempcode('ERROR_IMAGE_SAVE', @strval($php_errormsg)), 'warn'); return false; } } else { if ($exit_on_error) { warn_exit(do_lang_tempcode('UNKNOWN_FORMAT', escape_html($ext2))); } require_code('site'); attach_message(do_lang_tempcode('UNKNOWN_FORMAT', escape_html($ext2)), 'warn'); return false; } // Clean up imagedestroy($dest); fix_permissions($to); sync_file($to); return true; }
<div class="field-container"> <label for="email-field"><span><?php echo lang_get('email_label'); ?> </span></label> <span class="input"><?php print_email_input('email', ''); ?> </span> <span class="label-style"></span> </div> <?php $t_allow_passwd_change = helper_call_custom_function('auth_can_change_password', array()); # captcha image requires GD library and related option to ON if (ON == config_get('signup_use_captcha') && get_gd_version() > 0 && $t_allow_passwd_change) { $t_securimage_path = 'library/securimage'; $t_securimage_show = $t_securimage_path . '/securimage_show.php'; $t_securimage_play = $t_securimage_path . '/securimage_play.swf?' . http_build_query(array('audio_file' => $t_securimage_path . '/securimage_play.php', 'bgColor1=' => '#fff', 'bgColor2=' => '#fff', 'iconColor=' => '#777', 'borderWidth=' => 1, 'borderColor=' => '#000')); ?> <div class="field-container"> <label for="captcha-field"> <span><?php echo lang_get('signup_captcha_request_label'); ?> </span> </label> <span id="captcha-input" class="input"> <?php print_captcha_input('captcha'); ?>
if ($maj == 5 && $min >= 3) { return true; } elseif ($maj > 5) { return true; } else { return false; } } if (isset($_POST['calibre_dir'])) { $calibre_dir = $_POST['calibre_dir']; $cd = check_calibre($calibre_dir); } else { $calibre_dir = null; $cd = null; } $srv = $_SERVER['SERVER_SOFTWARE']; $is_a = is_apache($srv); if ($is_a) { $mre = mod_rewrite_enabled(); } else { $mre = false; } $gdv = get_gd_version(); if ($gdv >= 2) { $gde = true; } else { $gde = false; } $template = $twig->loadTemplate('installcheck.html'); echo $template->render(array('page' => array('rot' => '', 'version' => '1.3.3'), 'is_a' => $is_a, 'srv' => $srv, 'mre' => $mre, 'calibre_dir' => $calibre_dir, 'cd' => $cd, 'htaccess' => file_exists('./.htaccess'), 'hsql' => has_sqlite(), 'hgd2' => $gde, 'hgd2v' => $gdv, 'dwrit' => fw('./data'), 'intl' => extension_loaded('intl'), 'mcrypt' => extension_loaded('mcrypt'), 'mwrit' => fw('./data/data.db'), 'opd' => ini_get('open_basedir'), 'php' => check_php(), 'phpv' => phpversion())); #echo phpinfo();
/** * liberty_gd_resize_image * * @param array $pFileHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function liberty_gd_resize_image(&$pFileHash) { global $gBitSystem; $ret = NULL; list($iwidth, $iheight, $itype, $iattr) = @getimagesize($pFileHash['source_file']); list($type, $ext) = explode('/', strtolower($pFileHash['type'])); if (empty($pFileHash['max_width']) || empty($pFileHash['max_height']) || $iwidth <= $pFileHash['max_width'] && $iheight <= $pFileHash['max_height'] && ($ext == 'gif' || $ext == 'png' || $ext == 'jpg' || $ext == 'jpeg')) { // Keep the same dimensions as input file $pFileHash['max_width'] = $iwidth; $pFileHash['max_height'] = $iheight; } elseif ($iheight && $iwidth / $iheight > 0 && !empty($pFileHash['max_width']) && !empty($pFileHash['max_height'])) { // we have a portrait image, flip everything $temp = $pFileHash['max_width']; $pFileHash['max_height'] = $pFileHash['max_width']; $pFileHash['max_width'] = $temp; } // we need to scale and/or reformat $fp = fopen($pFileHash['source_file'], "rb"); $data = fread($fp, filesize($pFileHash['source_file'])); fclose($fp); if (function_exists("ImageCreateFromString")) { $img = @imagecreatefromstring($data); } if (!empty($img)) { $size_x = imagesx($img); $size_y = imagesy($img); } if (!empty($img) && $size_x && $size_y) { if ($size_x > $size_y && !empty($pFileHash['max_width'])) { $tscale = (int) $size_x / $pFileHash['max_width']; } elseif (!empty($pFileHash['max_height'])) { $tscale = (int) $size_y / $pFileHash['max_height']; } else { $tscale = 1; } $tw = (int) ($size_x / $tscale); $ty = (int) ($size_y / $tscale); if (get_gd_version() > 1) { $t = imagecreatetruecolor($tw, $ty); imagesavealpha($t, TRUE); imagealphablending($t, FALSE); imagecopyresampled($t, $img, 0, 0, 0, 0, $tw, $ty, $size_x, $size_y); } else { $t = imagecreate($tw, $ty); //$imagegallib->ImageCopyResampleBicubic($t, $img, 0, 0, 0, 0, $tw, $ty, $size_x, $size_y); } // override $mimeExt if we have a custom setting for it if ($gBitSystem->isFeatureActive('liberty_thumbnail_format')) { $mimeExt = $gBitSystem->getConfig('liberty_thumbnail_format'); } else { // make sure we have image_type_to_extension available include_once UTIL_PKG_PATH . 'PHP_Compat/Compat/Function/image_type_to_mime_type.php'; list($type, $mimeExt) = explode('/', strtolower(image_type_to_mime_type($itype))); } if ($mimeExt = preg_replace("!^(x-)?(jpeg|png|gif)\$!", "\$2", $mimeExt)) { $targetType = $mimeExt; $destExt = '.' . $mimeExt; } if (!$mimeExt || $mimeExt == 'jpeg') { $targetType = 'jpeg'; $destExt = '.jpg'; } if (!empty($pFileHash['dest_file'])) { $destFile = $pFileHash['dest_file']; } else { $destFile = STORAGE_PKG_PATH . $pFileHash['dest_branch'] . $pFileHash['dest_base_name'] . $destExt; } switch ($targetType) { case 'png': if (imagetypes() & IMG_PNG) { // png alpha stuff - needs more testing - spider // imagecolorallocatealpha ( $t, 0, 0, 0, 127 ); // $ImgWhite = imagecolorallocate($t, 255, 255, 255); // imagefill($t, 0, 0, $ImgWhite); // imagecolortransparent($t, $ImgWhite); imagepng($t, $destFile); break; } case 'gif': // This must go immediately before default so default will be hit for PHP's without gif support if (imagetypes() & IMG_GIF) { imagecolortransparent($t); imagegif($t, $destFile); break; } default: imagejpeg($t, $destFile); break; } // set permissions if possible - necessary for some wonky shared hosting environments if (chmod($pFileHash['source_file'], 0644)) { // does nothing, but fails elegantly } $pFileHash['name'] = $pFileHash['dest_base_name'] . $destExt; $pFileHash['size'] = filesize($destFile); $ret = $destFile; } elseif ($iwidth && $iheight) { $ret = liberty_process_generic($pFileHash, FALSE); } return $ret; }
function get_system_info() { global $_LANG; $system_info = array(); /* 检查系统基本参数 */ $system_info[] = array($_LANG['php_os'], PHP_OS); $system_info[] = array($_LANG['php_ver'], PHP_VERSION); /* 检查MYSQL支持情况 */ $mysql_enabled = function_exists('mysql_connect') ? $_LANG['support'] : $_LANG['not_support']; $system_info[] = array($_LANG['does_support_mysql'], $mysql_enabled); /* 检查图片处理函数库 */ $gd_ver = get_gd_version(); $gd_ver = empty($gd_ver) ? $_LANG['not_support'] : $gd_ver; if ($gd_ver > 0) { if (PHP_VERSION >= '4.3' && function_exists('gd_info')) { $gd_info = gd_info(); $jpeg_enabled = $gd_info['JPG Support'] === true ? $_LANG['support'] : $_LANG['not_support']; $gif_enabled = $gd_info['GIF Create Support'] === true ? $_LANG['support'] : $_LANG['not_support']; $png_enabled = $gd_info['PNG Support'] === true ? $_LANG['support'] : $_LANG['not_support']; } else { if (function_exists('imagetypes')) { $jpeg_enabled = (imagetypes() & IMG_JPG) > 0 ? $_LANG['support'] : $_LANG['not_support']; $gif_enabled = (imagetypes() & IMG_GIF) > 0 ? $_LANG['support'] : $_LANG['not_support']; $png_enabled = (imagetypes() & IMG_PNG) > 0 ? $_LANG['support'] : $_LANG['not_support']; } else { $jpeg_enabled = $_LANG['not_support']; $gif_enabled = $_LANG['not_support']; $png_enabled = $_LANG['not_support']; } } } else { $jpeg_enabled = $_LANG['not_support']; $gif_enabled = $_LANG['not_support']; $png_enabled = $_LANG['not_support']; } $system_info[] = array($_LANG['gd_version'], $gd_ver); $system_info[] = array($_LANG['jpeg'], $jpeg_enabled); $system_info[] = array($_LANG['gif'], $gif_enabled); $system_info[] = array($_LANG['png'], $png_enabled); /* 服务器是否安全模式开启 */ $safe_mode = ini_get('safe_mode') == '1' ? $_LANG['safe_mode_on'] : $_LANG['safe_mode_off']; $system_info[] = array($_LANG['safe_mode'], $safe_mode); return $system_info; }
$f_username = trim( $f_username ); $f_email = email_append_domain( trim( $f_email ) ); $f_captcha = utf8_strtolower( trim( $f_captcha ) ); # force logout on the current user if already authenticated if( auth_is_user_authenticated() ) { auth_logout(); } # Check to see if signup is allowed if ( OFF == config_get_global( 'allow_signup' ) ) { print_header_redirect( 'login_page.php' ); exit; } if( ON == config_get( 'signup_use_captcha' ) && get_gd_version() > 0 && helper_call_custom_function( 'auth_can_change_password', array() ) ) { # captcha image requires GD library and related option to ON $t_private_key = substr( hash( 'whirlpool', 'captcha' . config_get_global( 'crypto_master_salt' ) . $f_public_key, false ), 0, 5 ); if ( $t_private_key != $f_captcha ) { trigger_error( ERROR_SIGNUP_NOT_MATCHING_CAPTCHA, ERROR ); } } email_ensure_not_disposable( $f_email ); # notify the selected group a new user has signed-up if( user_signup( $f_username, $f_email ) ) { email_notify_new_account( $f_username, $f_email ); }