ACC SHELL
<?php
//session_start();
class SimpleImage {
var $image;
var $image_type;
var $font = "Arial.ttf";
function __construct() {
}
function load($filename) {
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if ($this->image_type == IMAGETYPE_JPEG) {
$this->image = imagecreatefromjpeg($filename);
}
elseif ($this->image_type == IMAGETYPE_GIF) {
$this->image = imagecreatefromgif($filename);
}
elseif ($this->image_type == IMAGETYPE_PNG) {
$this->image = imagecreatefrompng($filename);
}
else
return false;
}
function save($filename, $image_type=IMAGETYPE_JPEG, $compression=99, $permissions=null) {
if ($this->image_type == IMAGETYPE_JPEG) {
imagejpeg($this->image, $filename, $compression);
}
elseif ($this->image_type == IMAGETYPE_GIF) {
imagegif($this->image, $filename);
}
elseif ($this->image_type == IMAGETYPE_PNG) {
imagepng($this->image, $filename);
}
}
function output($image_type=IMAGETYPE_JPEG) {
if ($this->image_type == IMAGETYPE_JPEG) {
imagejpeg($this->image);
}
elseif ($this->image_type == IMAGETYPE_GIF) {
imagegif($this->image);
}
elseif ($this->image_type == IMAGETYPE_PNG) {
imagepng($this->image);
}
}
function getWidth() {
return imagesx($this->image);
}
function getHeight() {
return imagesy($this->image);
}
function resizeToHeight($height) {
$ratio = $height / $this->getHeight();
$width = $this->getWidth() * $ratio;
$this->resize($width, $height);
}
function resizeToWidth($width) {
$ratio = $width / $this->getWidth();
$height = $this->getHeight() * $ratio;
$this->resize($width, $height);
}
function scale($scale) {
$width = $this->getWidth() * $scale / 100;
$height = $this->getHeight() * $scale / 100;
$this->resize($width, $height);
}
function resize($width, $height) {
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled( $new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight() );
$this->image = $new_image;
}
function rotate() {
$rotate = imagerotate($this->image, -90, 0);
$this->image = $rotate;
}
function toUTF8($s) {
$czUTF8=array("á"=>225,"č"=>269,"ď"=>271,"é"=>233,"ě"=>283,"í"=>237,
"ĺ"=>314,"ľ"=>318,"ň"=>328,"ó"=>243,"ř"=>345,"š"=>353,"ť"=>357,
"ú"=>250,"ů"=>367,"ý"=>253,"ž"=>382,"Á"=>193,"Č"=>268,"Ď"=>270,
"É"=>201,"Ě"=>282,"Í"=>205,"Ĺ"=>313,"Ľ"=>317,"Ň"=>327,"Ó"=>211,
"Ř"=>344,"Š"=>352,"Ť"=>356,"Ú"=>218,"Ů"=>366,"Ý"=>221,"Ž"=>381);
for($i=0; $i<strlen($s); $i++) {
if ($czUTF8[$s[$i]])
$out.=sprintf("&#%d;",$czUTF8[$s[$i]]);
else $out.=$s[$i];
}
return $out;
echo $out. "<br />";
}
function foxy_utf8_to_nce($utf) {
$max_count = 5; // flag-bits in $max_mark ( 1111 1000 == 5 times 1)
$max_mark = 248; // marker for a (theoretical ;-)) 5-byte-char and mask for a 4-byte-char;
for($str_pos = 0; $str_pos < strlen($utf); $str_pos++) {
$old_chr = $utf{$str_pos};
$old_val = ord( $utf{$str_pos} );
$new_val = 0;
$utf8_marker = 0;
// skip non-utf-8-chars
if( $old_val > 127 ) {
$mark = $max_mark;
for($byte_ctr = $max_count; $byte_ctr > 2; $byte_ctr--) {
// actual byte is utf-8-marker?
if( ( $old_val & $mark ) == ( ($mark << 1) & 255 ) ) {
$utf8_marker = $byte_ctr - 1;
break;
}
$mark = ($mark << 1) & 255;
}
}
// marker found: collect following bytes
if($utf8_marker > 1 and isset( $utf{$str_pos + 1} ) ) {
$str_off = 0;
$new_val = $old_val & (127 >> $utf8_marker);
for($byte_ctr = $utf8_marker; $byte_ctr > 1; $byte_ctr--) {
// check if following chars are UTF8 additional data blocks
// UTF8 and ord() > 127
if( (ord($utf{$str_pos + 1}) & 192) == 128 ) {
$new_val = $new_val << 6;
$str_off++;
// no need for Addition, bitwise OR is sufficient
// 63: more UTF8-bytes; 0011 1111
$new_val = $new_val | ( ord( $utf{$str_pos + $str_off} ) & 63 );
}
// no UTF8, but ord() > 127
// nevertheless convert first char to NCE
else {
$new_val = $old_val;
}
}
// build NCE-Code
$html .= '&#'.$new_val.';';
// Skip additional UTF-8-Bytes
$str_pos = $str_pos + $str_off;
}
else {
$html .= chr($old_val);
$new_val = $old_val;
}
}
return($html);
}
//echo foxy_utf8_to_nce("ěščřžýáíé");
function vodotiskVpravoDole($string) {
//$string = "This is sooo cool it works!!!";
//$font = 12;
$width = ImageFontWidth($font)* strlen($string) ;
$height = ImageFontHeight($font) ;
$im = $this->image;
$x = $this->getWidth() - $width - 10;
$y = $this->getHeight() - $height - 10;
//$string = "Příliš žluťoučký kůň úpěl ďábelské ódy";
$background_color = imagecolorallocate ($im, 255, 255, 255); //white background
$text_color = imagecolorallocate ($im, 0, 0,0);//black text
//imagettftext($im, $font, 0, $x, $y, $text_color, "athena.ttf", toUTF8($string));
imagettftext($im, $font, 0, $x, $y, $text_color, $font, $this->foxy_utf8_to_nce($string));
//imagestring ($im, $font, $x, $y, $string, $text_color);
$this->image = $im;
}
function vodotiskVlevoDole($string) {
//$string = "This is sooo cool it works!!!";
//$font = 12;
$width = ImageFontWidth($font)* strlen($string) ;
$height = ImageFontHeight($font) ;
$im = $this->image;
$x = 10;
$y = $this->getHeight() - $height - 10;
$background_color = imagecolorallocate ($im, 255, 255, 255); //white background
$text_color = imagecolorallocate ($im, 0, 0,0);//black text
imagettftext($im, $font, 0, $x, $y, $text_color, $font, $this->foxy_utf8_to_nce($string));
//imagestring ($im, $font, $x, $y, $string, $text_color);
$this->image = $im;
}
function __destruct() {
/*
if (isset($this->image)) {
imagedestroy($this->image);
}
*/
}
}
/*
* Nahraje obrazek, zmeni velikost na 250*400 a ulozi ho pod novym nazvem
$image = new SimpleImage();
$image->load('nazev_obrazku.jpg');
$image->resize(250,400);
$image->save('novy_obrazek.jpg');
*/
/*
* Nahraje obrazek, zmeni velikost sirky na 250 pricemz drzi pomer stran a ulozi ho pod novym nazvem
$image = new SimpleImage();
$image->load('nazev_obrazku.jpg');
$image->resizeToWidth(250);
$image->save('novy_obrazek.jpg');
*/
/*
* Nahraje obrazek, zmeni velikost na 50% puvodni sirky a delky ulozi ho pod novym nazvem
$image = new SimpleImage();
$image->load('nazev_obrazku.jpg');
$image->scale(50);
$image->save('novy_obrazek.jpg');
*/
?>
ACC SHELL 2018