Сертификаты и компетенции



[insert_php]
function make_thumb($src, $dest, $desired_height) {
/* read the source image */
$source_image = @imagecreatefromjpeg($src);
if (!$source_image) {
$source_image = imagecreate(100, 100); /* создать пустое изображение */
$bgc = imagecolorallocate($source_image, 255, 255, 255);
$tc = imagecolorallocate($source_image, 0, 0, 0);
imagefilledrectangle($source_image, 0, 0, 150, 30, $bgc);
/* вывести errmsg */
imagestring($source_image, 1, 5, 5, «Error», $tc);
}
$width = imagesx($source_image);
$height = imagesy($source_image);

/* find the «desired height» of this thumbnail, relative to the desired width */
$desired_width = floor($width * ($desired_height / $height));

/* create a new, «virtual» image */
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);

/* copy source image at a resized size */
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);

/* create the physical thumbnail image to its destination */
imagejpeg($virtual_image, $dest);
}

function file_path($file_name, $subfolder) {
return «http://» . $_SERVER[«HTTP_HOST»] . «/» . $subfolder . «/» . $file_name;
}

$dir = $_SERVER[«DOCUMENT_ROOT»];
$dir = $dir . «/files/certificates»;
$files = scandir($dir);
$server = $_SERVER[«HTTP_HOST»];
for ($i = 2; $i < count($files); $i++) { if ($files[$i] != "thumb") { if (!file_exists(file_path($files[$i], "files/certificates/thumb"))) { make_thumb($dir . "/" . $files[$i], $dir . "/thumb/" . $files[$i], 100); } echo("

«);
}
}
[/insert_php]