本文整理汇总了PHP中check_gd_version函数的典型用法代码示例。如果您正苦于以下问题:PHP check_gd_version函数的具体用法?PHP check_gd_version怎么用?PHP check_gd_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_gd_version函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_settingpage
<?php
// This file defines settingpages and externalpages under the "server" category
if ($hassiteconfig) {
// speedup for non-admins, add all caps used on this page
// "systempaths" settingpage
$temp = new admin_settingpage('systempaths', new lang_string('systempaths', 'admin'));
$temp->add(new admin_setting_configselect('gdversion', new lang_string('gdversion', 'admin'), new lang_string('configgdversion', 'admin'), check_gd_version(), array('0' => new lang_string('gdnot'), '1' => new lang_string('gd1'), '2' => new lang_string('gd2'))));
$temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('pathtodu', 'admin'), new lang_string('configpathtodu', 'admin'), ''));
$temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'), new lang_string('edhelpaspellpath'), ''));
$temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'), new lang_string('pathtodot_help', 'admin'), ''));
$ADMIN->add('server', $temp);
// "supportcontact" settingpage
$temp = new admin_settingpage('supportcontact', new lang_string('supportcontact', 'admin'));
if (isloggedin()) {
global $USER;
$primaryadminemail = $USER->email;
$primaryadminname = fullname($USER, true);
} else {
// no defaults during installation - admin user must be created first
$primaryadminemail = NULL;
$primaryadminname = NULL;
}
$temp->add(new admin_setting_configtext('supportname', new lang_string('supportname', 'admin'), new lang_string('configsupportname', 'admin'), $primaryadminname, PARAM_NOTAGS));
$temp->add(new admin_setting_configtext('supportemail', new lang_string('supportemail', 'admin'), new lang_string('configsupportemail', 'admin'), $primaryadminemail, PARAM_NOTAGS));
$temp->add(new admin_setting_configtext('supportpage', new lang_string('supportpage', 'admin'), new lang_string('configsupportpage', 'admin'), '', PARAM_URL));
$ADMIN->add('server', $temp);
// "sessionhandling" settingpage
$temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandling', 'admin'));
$temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'), new lang_string('configdbsessions', 'admin'), 1));
$temp->add(new admin_setting_configselect('sessiontimeout', new lang_string('sessiontimeout', 'admin'), new lang_string('configsessiontimeout', 'admin'), 7200, array(14400 => new lang_string('numhours', '', 4), 10800 => new lang_string('numhours', '', 3), 7200 => new lang_string('numhours', '', 2), 5400 => new lang_string('numhours', '', '1.5'), 3600 => new lang_string('numminutes', '', 60), 2700 => new lang_string('numminutes', '', 45), 1800 => new lang_string('numminutes', '', 30), 900 => new lang_string('numminutes', '', 15), 300 => new lang_string('numminutes', '', 5))));
示例2: begin
function begin()
{
// {{{
$err = "";
$thumberr = "";
$dberr = "";
if (check_gd_version() == 0 && check_im_version() == 0) {
$thumberr = "<p>PHP's GD extension seems to be missing, " . "and imagemagick's \"convert\" command cannot be found - " . "no thumbnailing engines are available.";
}
if (!function_exists("mysql_connect")) {
$dberr = "<p>PHP's MySQL extension seems to be missing; you may " . "be able to use an unofficial alternative, checking " . "for libraries...";
if (!function_exists("pg_connect")) {
$dberr .= "<br>PgSQL is missing";
} else {
$dberr .= "<br>PgSQL is available";
}
if (!function_exists("sqlite_open")) {
$dberr .= "<br>SQLite is missing";
} else {
$dberr .= "<br>SQLite is available";
}
}
if ($thumberr || $dberr) {
$err = "<h3>Error</h3>";
}
print <<<EOD
\t\t<div id="iblock">
\t\t\t<h1>Shimmie Installer</h1>
\t\t\t{$err}
\t\t\t{$thumberr}
\t\t\t{$dberr}
\t\t\t<h3>Install</h3>
\t\t\t<form action="install.php" method="POST">
\t\t\t\t<center>
\t\t\t\t\t<table>
\t\t\t\t\t\t<tr><td>Database:</td><td><input type="text" name="database_dsn" size="40"></td></tr>
\t\t\t\t\t\t<tr><td colspan="2"><center><input type="submit" value="Go!"></center></td></tr>
\t\t\t\t\t</table>
\t\t\t\t</center>
\t\t\t</form>
\t\t\t<h3>Help</h3>
\t\t\t\t\t
\t\t\t<p>Databases should be specified like so:
\t\t\t<br>ie: <code>protocol://username:password@host/database?options</code>
\t\t\t<br>eg: <code>mysql://shimmie:pw123@localhost/shimmie?persist</code>
\t\t\t
\t\t\t<p>For more help with installation, visit
\t\t\t<a href="http://trac.shishnet.org/shimmie2/wiki/Guides/Admin/Install">the
\t\t\tdocumentation wiki</a>.
\t\t</div>
EOD;
}
示例3: ask_questions
function ask_questions()
{
// {{{
$warnings = array();
$errors = array();
if (check_gd_version() == 0 && check_im_version() == 0) {
$errors[] = "\n\t\t\tNo thumbnailers cound be found - install the imagemagick\n\t\t\ttools (or the PHP-GD library, of imagemagick is unavailable).\n\t\t";
} else {
if (check_im_version() == 0) {
$warnings[] = "\n\t\t\tThe 'convert' command (from the imagemagick package)\n\t\t\tcould not be found - PHP-GD can be used instead, but\n\t\t\tthe size of thumbnails will be limited.\n\t\t";
}
}
$drivers = PDO::getAvailableDrivers();
if (!in_array("mysql", $drivers) && !in_array("pgsql", $drivers) && !in_array("sqlite", $drivers)) {
$errors[] = "\n\t\t\tNo database connection library could be found; shimmie needs\n\t\t\tPDO with either Postgres, MySQL, or SQLite drivers\n\t\t";
}
$db_m = in_array("mysql", $drivers) ? '<option value="mysql">MySQL</option>' : "";
$db_p = in_array("pgsql", $drivers) ? '<option value="pgsql">PostgreSQL</option>' : "";
$db_s = in_array("sqlite", $drivers) ? '<option value="sqlite">SQLite</option>' : "";
$warn_msg = $warnings ? "<h3>Warnings</h3>" . implode("\n<br>", $warnings) : "";
$err_msg = $errors ? "<h3>Errors</h3>" . implode("\n<br>", $errors) : "";
print <<<EOD
\t\t<div id="installer">
\t\t\t<h1>Shimmie Installer</h1>
\t\t\t{$warn_msg}
\t\t\t{$err_msg}
\t\t\t<h3>Database Install</h3>
\t\t\t<form action="install.php" method="POST">
\t\t\t\t<center>
\t\t\t\t\t<table class='form'>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<th>Type:</th>
\t\t\t\t\t\t\t<td><select name="database_type" id="database_type" onchange="update_qs();">
\t\t\t\t\t\t\t\t{$db_m}
\t\t\t\t\t\t\t\t{$db_p}
\t\t\t\t\t\t\t\t{$db_s}
\t\t\t\t\t\t\t</select></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr class="dbconf mysql pgsql">
\t\t\t\t\t\t\t<th>Host:</th>
\t\t\t\t\t\t\t<td><input type="text" name="database_host" size="40" value="localhost"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr class="dbconf mysql pgsql">
\t\t\t\t\t\t\t<th>Username:</th>
\t\t\t\t\t\t\t<td><input type="text" name="database_user" size="40"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr class="dbconf mysql pgsql">
\t\t\t\t\t\t\t<th>Password:</th>
\t\t\t\t\t\t\t<td><input type="password" name="database_password" size="40"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr class="dbconf mysql pgsql sqlite">
\t\t\t\t\t\t\t<th>DB Name:</th>
\t\t\t\t\t\t\t<td><input type="text" name="database_name" size="40" value="shimmie"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr><td colspan="2"><input type="submit" value="Go!"></td></tr>
\t\t\t\t\t</table>
\t\t\t\t</center>
\t\t\t\t<script>
\t\t\t\t\$(function() {
\t\t\t\t\tupdate_qs();
\t\t\t\t});
\t\t\t\tfunction update_qs() {
\t\t\t\t\t\$(".dbconf").hide();
\t\t\t\t\tvar seldb = \$("#database_type").val() || "none";
\t\t\t\t\t\$("."+seldb).show();
\t\t\t\t}
\t\t\t\t</script>
\t\t\t</form>
\t\t\t<h3>Help</h3>
\t\t\t<p class="dbconf mysql pgsql">
\t\t\t\tPlease make sure the database you have chosen exists and is empty.<br>
\t\t\t\tThe username provided must have access to create tables within the database.
\t\t\t</p>
\t\t\t<p class="dbconf sqlite">
\t\t\t\tFor SQLite the database name will be a filename on disk, relative to
\t\t\t\twhere shimmie was installed.
\t\t\t</p>
\t\t\t<p class="dbconf none">
\t\t\t\tDrivers can generally be downloaded with your OS package manager;
\t\t\t\tfor Debian / Ubuntu you want php5-pgsql, php5-mysql, or php5-sqlite.
\t\t\t</p>
\t\t</div>
EOD;
}
示例4: form_table
function form_table($nextstage = WELCOME, $formaction = "install.php")
{
global $INSTALL, $db;
$enablenext = true;
/// Print the standard form if we aren't in the DOWNLOADLANG page
/// because it has its own form.
if ($nextstage != DOWNLOADLANG) {
$needtoopenform = false;
?>
<form id="installform" method="post" action="<?php
echo $formaction;
?>
">
<div><input type="hidden" name="stage" value="<?php
echo $nextstage;
?>
" /></div>
<?php
} else {
$needtoopenform = true;
}
?>
<table class="install_table" cellspacing="3" cellpadding="3">
<?php
/// what we do depends on the stage we're at
switch ($nextstage) {
case WELCOME:
/// Welcome and language settings
?>
<tr>
<td class="td_left"><p class="p_install"><?php
print_string('language');
?>
</p></td>
<td class="td_right">
<?php
choose_from_menu(get_installer_list_of_languages(), 'language', $INSTALL['language'], '');
?>
</td>
</tr>
<?php
break;
case COMPATIBILITY:
/// Compatibilty check
$compatsuccess = true;
/// Check that PHP is of a sufficient version
print_compatibility_row(inst_check_php_version(), get_string('phpversion', 'install'), get_string('phpversionerror', 'install'), 'phpversionhelp');
$enablenext = $enablenext && inst_check_php_version();
/// Check session auto start
print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
$enablenext = $enablenext && !ini_get_bool('session.auto_start');
/// Check magic quotes
print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
$enablenext = $enablenext && !ini_get_bool('magic_quotes_runtime');
/// Check unsupported PHP configuration
print_compatibility_row(!ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'));
$enablenext = $enablenext && !ini_get_bool('register_globals');
/// Check safe mode
print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
/// Check file uploads
print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
/// Check GD version
print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
/// Check memory limit
print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
break;
case DIRECTORY:
/// Directory settings
?>
<tr>
<td class="td_left"><p class="p_install"><?php
print_string('wwwroot', 'install');
?>
</p></td>
<td class="td_right">
<input type="text" size="40"name="wwwrootform" value="<?php
p($INSTALL['wwwrootform'], true);
?>
" />
</td>
</tr>
<tr>
<td class="td_left"><p class="p_install"><?php
print_string('dirroot', 'install');
?>
</p></td>
<td class="td_right">
<input type="text" size="40" name="dirrootform" disabled="disabled" value="<?php
p($INSTALL['dirrootform'], true);
?>
" />
</td>
</tr>
<tr>
<td class="td_left"><p class="p_install"><?php
print_string('dataroot', 'install');
//.........这里部分代码省略.........
示例5: form_table
function form_table($nextstage = WELCOME, $formaction = "install.php")
{
global $INSTALL, $db;
$enablenext = true;
/// Print the standard form
$needtoopenform = false;
?>
<form id="installform" method="post" action="<?php
echo $formaction;
?>
">
<div><input type="hidden" name="stage" value="<?php
echo $nextstage;
?>
" /></div>
<table class="install_table" cellspacing="3" cellpadding="3">
<?php
/// what we do depends on the stage we're at
switch ($nextstage) {
case WELCOME:
/// Language settings
?>
<tr>
<td class="td_left"><p class="p_install"><?php
print_string('language');
?>
</p></td>
<td class="td_right">
<?php
choose_from_menu(get_installer_list_of_languages(), 'language', $INSTALL['language'], '', 'this.form.submit();');
?>
</td>
</tr>
<?php
if (file_exists('install/versions.php')) {
include_once 'install/versions.php';
echo '<tr><td colspan="2">';
include_once 'install/welcome.html';
echo '</td></tr>';
}
break;
case COMPATIBILITY:
/// Compatibilty check
$compatsuccess = true;
/// Check that PHP is of a sufficient version
print_compatibility_row(inst_check_php_version(), get_string('phpversion', 'install'), get_string('phpversionerror', 'install'), 'phpversionhelp');
$enablenext = $enablenext && inst_check_php_version();
/// Check session auto start
print_compatibility_row(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), 'sessionautostarthelp');
$enablenext = $enablenext && !ini_get_bool('session.auto_start');
/// Check magic quotes
print_compatibility_row(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), 'magicquotesruntimehelp');
$enablenext = $enablenext && !ini_get_bool('magic_quotes_runtime');
/// Check unsupported PHP configuration
print_compatibility_row(!ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'));
$enablenext = $enablenext && !ini_get_bool('register_globals');
/// Check safe mode
print_compatibility_row(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), 'safemodehelp', true);
/// Check file uploads
print_compatibility_row(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), 'fileuploadshelp', true);
/// Check GD version
print_compatibility_row(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), 'gdversionhelp', true);
/// Check memory limit
print_compatibility_row(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), 'memorylimithelp', true);
break;
case DIRECTORY:
/// Directory settings
?>
<tr>
<td class="td_left"><p class="p_install"><?php
print_string('wwwroot', 'install');
?>
</p></td>
<td class="td_right">
<input type="text" size="40" name="wwwrootform" value="<?php
p($INSTALL['wwwrootform'], true);
?>
" />
</td>
</tr>
<tr>
<td class="td_left"><p class="p_install"><?php
print_string('dirroot', 'install');
?>
</p></td>
<td class="td_right">
<input type="text" size="40" name="dirrootform" disabled="disabled" value="<?php
p($INSTALL['dirrootform'], true);
?>
" />
</td>
</tr>
<tr>
<td class="td_left"><p class="p_install"><?php
print_string('dataroot', 'install');
?>
</p></td>
//.........这里部分代码省略.........
示例6: begin
function begin()
{
// {{{
$err = "";
$thumberr = "";
$dberr = "";
if (check_gd_version() == 0 && check_im_version() == 0) {
$thumberr = "<p>PHP's GD extension seems to be missing, " . "and imagemagick's \"convert\" command cannot be found - " . "no thumbnailing engines are available.";
}
if (!function_exists("mysql_connect")) {
$dberr = "<p>PHP's MySQL extension seems to be missing; you may " . "be able to use an unofficial alternative, checking " . "for libraries...";
if (!function_exists("pg_connect")) {
$dberr .= "<br>PgSQL is missing";
} else {
$dberr .= "<br>PgSQL is available";
}
if (!function_exists("sqlite_open")) {
$dberr .= "<br>SQLite is missing";
} else {
$dberr .= "<br>SQLite is available";
}
}
if ($thumberr || $dberr) {
$err = "<h3>Error</h3>";
}
print <<<EOD
\t\t<div id="iblock">
\t\t\t<h1>Shimmie Installer</h1>
\t\t\t{$err}
\t\t\t{$thumberr}
\t\t\t{$dberr}
\t\t\t<h3>Database Install</h3>
\t\t\t<form action="install.php" method="POST">
\t\t\t\t<center>
\t\t\t\t\t<table>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<td>Type:</td>
\t\t\t\t\t\t\t<td><select name="database_type">
\t\t\t\t\t\t\t\t<option value="mysql" selected>MySQL</option>
\t\t\t\t\t\t\t\t<option value="pgsql">PostgreSQL</option>
\t\t\t\t\t\t\t\t<option value="sqlite">SQLite</option>
\t\t\t\t\t\t\t</td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<td>Host:</td>
\t\t\t\t\t\t\t<td><input type="text" name="database_host" size="40" value="localhost"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<td>Username:</td>
\t\t\t\t\t\t\t<td><input type="text" name="database_user" size="40"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<td>Password:</td>
\t\t\t\t\t\t\t<td><input type="password" name="database_password" size="40"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t<td>Name:</td>
\t\t\t\t\t\t\t<td><input type="text" name="database_name" size="40" value="shimmie"></td>
\t\t\t\t\t\t</tr>
\t\t\t\t\t\t<tr><td colspan="2"><center><input type="submit" value="Go!"></center></td></tr>
\t\t\t\t\t</table>
\t\t\t\t</center>
\t\t\t</form>
\t\t\t<h3>Help</h3>
\t\t\t\t\t
\t\t\t<p>Please make sure the database you have chosen exists and is empty.<br>
\t\t\tThe username provided must have access to create tables within the database.
\t\t\t
\t\t</div>
EOD;
}
示例7: make_thumbnail
/**
* Create a thumbnail from image.
*
* @param string $srcimage Full path to image.
* @param string $destimage Full path to destination dir.
* @return bool
*/
function make_thumbnail($srcimage, $destimage)
{
$orig = getimagesize($srcimage);
$width = $orig[0];
$height = $orig[1];
$ratio = $width / $height;
$maxwidth = 80;
$maxheight = 80;
if ($width > $maxwidth) {
$width = $maxwidth;
$height = round($width / $ratio);
}
if ($height > $maxheight) {
$height = $maxheight;
$width = round($height * $ratio);
}
if (!$this->resize_image($srcimage, $destimage, $width, $height)) {
return false;
}
// Create a dropshadow if requested.
if ($this->module->shadow) {
if ($thumb = $this->read_image_from_file($destimage, $orig[2])) {
$newimage = check_gd_version() > 1 ? imagecreatetruecolor($width + 4, $height + 4) : imagecreate($width + 4, $height + 4);
$white = imagecolorallocate($newimage, 255, 255, 255);
$shadow = imagecolorallocate($newimage, 128, 128, 128);
imagefill($newimage, 0, 0, $white);
imagefilledrectangle($newimage, 2, 2, $width + 2, $height + 2, $shadow);
if (function_exists('imagefilter')) {
// Call it twice to get nice blur effect.
if (function_exists('imagefilter')) {
imagefilter($newimage, IMG_FILTER_GAUSSIAN_BLUR);
imagefilter($newimage, IMG_FILTER_GAUSSIAN_BLUR);
}
}
imagecopy($newimage, $thumb, 0, 0, 0, 0, $width, $height);
$this->write_image_to_file($newimage, $destimage, $orig[2]);
}
}
return true;
}
示例8: console_write
console_write("\n", '', false);
}
/// Check that PHP is of a sufficient version
check_compatibility(inst_check_php_version(), get_string('phpversion', 'install'), get_string('php52versionerror', 'install'), false, $silent);
/// Check session auto start
check_compatibility(!ini_get_bool('session.auto_start'), get_string('sessionautostart', 'install'), get_string('sessionautostarterror', 'install'), false, $silent);
/// Check magic quotes
check_compatibility(!ini_get_bool('magic_quotes_runtime'), get_string('magicquotesruntime', 'install'), get_string('magicquotesruntimeerror', 'install'), false, $silent);
/// Check unsupported PHP configuration
check_compatibility(ini_get_bool('register_globals'), get_string('globalsquotes', 'install'), get_string('globalswarning', 'install'), false, $silent);
/// Check safe mode
check_compatibility(!ini_get_bool('safe_mode'), get_string('safemode', 'install'), get_string('safemodeerror', 'install'), true, $silent);
/// Check file uploads
check_compatibility(ini_get_bool('file_uploads'), get_string('fileuploads', 'install'), get_string('fileuploadserror', 'install'), true, $silent);
/// Check GD version
check_compatibility(check_gd_version(), get_string('gdversion', 'install'), get_string('gdversionerror', 'install'), true, $silent);
/// Check memory limit
check_compatibility(check_memory_limit(), get_string('memorylimit', 'install'), get_string('memorylimiterror', 'install'), true, $silent);
//================================================================================//
// Moodle directories and web address
if ($interactive == CLI_FULL || $interactive == CLI_SEMI && (!isset($INSTALL['dirroot']) || !isset($INSTALL['wwwroot']) || !isset($INSTALL['dataroot']))) {
console_write("\n", '', false);
console_write("\n", '', false);
console_write('locationanddirectories', 'install');
console_write("\n", '', false);
console_write("\n", '', false);
}
//input the web directory
if ($interactive == CLI_FULL || $interactive == CLI_SEMI && !isset($INSTALL['dirroot'])) {
console_write('inputwebdirectory', 'install');
//if directories validation lib is found change this to read_dir() and
示例9: gd_resize_image
function gd_resize_image($image, $newimage, $newwidth, $newheight)
{
global $CFG;
if (filesize($image) < 250000) {
return false;
}
// no need to resize
$gdversion = check_gd_version();
if ($gdversion < 1) {
return false;
}
$size = getimagesize($image);
$width = $size[0];
$height = $size[1];
$type = $size[2];
if ($im = read_image_from_file($image, $type)) {
if ($newheight && $width < $height) {
$newwidth = $newheight / $height * $width;
} else {
$newheight = $newwidth / $width * $height;
}
echo get_string('originaldimentions', 'files', '', $CFG->dirroot . '/files/lang/') . ": " . get_string('width', 'files', '', $CFG->dirroot . '/files/lang/') . " = {$width} , " . get_string('height', 'files', '', $CFG->dirroot . '/files/lang/') . " = {$height} \n";
echo get_string('newdimentions', 'files', '', $CFG->dirroot . '/files/lang/') . ": " . get_string('width', 'files', '', $CFG->dirroot . '/files/lang/') . " = {$newwidth} , " . get_string('height', 'files', '', $CFG->dirroot . '/files/lang/') . " = {$newheight} \n";
if ($gdversion > 1) {
$im2 = ImageCreateTrueColor($newwidth, $newheight);
} else {
$im2 = ImageCreate($newwidth, $newheight);
}
if ($gdversion > 1) {
ImageCopyResampled($im2, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
} else {
ImageCopyResized($im2, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
echo get_string('originalsize', 'files', '', $CFG->dirroot . '/files/lang/') . " = " . filesize($image) . " \n";
clearstatcache();
unlink($image);
// delete image before overwrite
if (write_image_to_file($im2, $newimage, $type)) {
echo get_string('newsize', 'files', '', $CFG->dirroot . '/files/lang/') . " = " . filesize($newimage) . " \n";
return true;
}
}
return false;
}
示例10: admin_settingpage
<?php
// This file defines settingpages and externalpages under the "server" category
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
// "systempaths" settingpage
$temp = new admin_settingpage('systempaths', get_string('systempaths','admin'));
$temp->add(new admin_setting_configselect('gdversion', get_string('gdversion','admin'), get_string('configgdversion', 'admin'), check_gd_version(), array('0' => get_string('gdnot'),
'1' => get_string('gd1'),
'2' => get_string('gd2'))));
$temp->add(new admin_setting_configexecutable('pathtodu', get_string('pathtodu', 'admin'), get_string('configpathtodu', 'admin'), ''));
$temp->add(new admin_setting_configexecutable('aspellpath', get_string('aspellpath', 'admin'), get_string('edhelpaspellpath'), ''));
$temp->add(new admin_setting_configexecutable('pathtodot', get_string('pathtodot', 'admin'), get_string('pathtodot_help', 'admin'), ''));
$ADMIN->add('server', $temp);
// "email" settingpage
$temp = new admin_settingpage('mail', get_string('mail','admin'));
$temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'admin'), get_string('configsmtphosts', 'admin'), '', PARAM_RAW));
$temp->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
$temp->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), ''));
$temp->add(new admin_setting_configtext('smtpmaxbulk', get_string('smtpmaxbulk', 'admin'), get_string('configsmtpmaxbulk', 'admin'), 1, PARAM_INT));
$temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . get_host_from_url($CFG->wwwroot), PARAM_NOTAGS));
$temp->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00',
'01' => '01',
'02' => '02',
'03' => '03',
'04' => '04',