Вход Регистрация
Файл: CMS/core/modules/logo.php
Строк: 126
<?php

if (!defined('CMS')) { die('Access Denied!'); }

if (
$is_logged) {

    include_once( 
dirname(__FILE__) . '/images.inc.php' );

    if (!empty(
$id)) {

        if (!
file_exists(ROOTPATH . '/images/textures/' . $id . '.jpg')) {

            
$inSes->addMessage('Ошибка! Шаблон не найден!');
            
gen_red('logo', '', RND);
        }

        
$ipath = ROOTPATH . '/images/textures/' . $id . '.jpg';
        
$iurl  = $config['site_url'] . '/images/textures/' . $id . '.jpg';

        if (!empty(
$_POST['demo']) || !empty($_POST['submit'])) {

            
$image_text_line_spacing = (int) request('line_spacing','0');
            
$image_text_padding_x    = (int) request('padding_x',0);
            
$image_text_padding_y    = (int) request('padding_y',0);
            
$image_font_size         = (int) request('size','0');
            
$image_font_path = ROOTPATH . '/gallery/fonts/' . request('font');

            
$txt = array();
            
$txt[] = 'Ник: ' . request('nick');
            
$txt[] = 'Имя: ' . request('name');
            
$txt[] = (!empty($_POST['gender']) && $_POST['gender'] == 1) ? 'Пол: Муж' : 'Пол: Жен';
            
$txt[] = 'ICQ: ' . request('icq');
            
$txt[] = 'E-Mail: ' . request('mail','---');
            
$txt[] = 'Сайт: ' . request('site','---');
            
$txt[] = 'WMID: ' . request('wmid','---');

            
$image_src   = @imagecreatefromjpeg($ipath);
            
$image_src_x = imagesx($image_src);
            
$image_src_y = imagesy($image_src);
            
$true_color  = imagecreatetruecolor($image_src_x, $image_src_y);
                           
imagealphablending($true_color, false);
                           
imagesavealpha($true_color, true);
            
$image_dst_x = 0;
            
$image_dst_y = 0;

            
//$text = explode("n", $this->image_text);
            //$char_width = imagefontwidth($this->image_text_font);
            //$char_height = imagefontheight($this->image_text_font);
            
$char_width = $char_height =0;
            
$text_height = 0;
            
$text_width = 0;
            
$line_height = 0;
            
$line_width = 0;

            foreach (
$txt as $k => $v) {
                
$w = ($char_width * strlen($v));
                if (
$w > $text_width) $text_width = $w;
                
$line_height = $char_height;
                
$text_height += $line_height + ($k < (sizeof($txt)-1) ? $image_text_line_spacing : 0);
            }
            
$text_width  += (2 * $image_text_padding_x);
            
$text_height += (2 * $image_text_padding_y);
            
$text_x  = 0;
            
$text_y  = 0;
            
$text_x += $image_text_padding_x;
            
$text_y += $image_text_padding_y;
            
$t_width = $text_width - (2 * $image_text_padding_x);
            
$t_height = $text_height - (2 * $image_text_padding_y);

            list(
$red, $green, $blue) = getcolors('#'.request('color'));
            
$text_color = imageColorAllocate($image_src, $red, $green, $blue);

            foreach (
$txt as $k => $v) {

                
$yy = $text_y + $k * ($line_height  + ($k > 0 && $k < (sizeof($txt)) ? $image_text_line_spacing : 0));
                
$pos = ImageTTFBBox ($image_font_size, 0, $image_font_path, $v);
                
$rt  = $pos[2];                 // правая координата
                
$lt  = $pos[0];                 // левая координата
                
$wt  = $rt - $lt;               // ширина надписи
                
$ht  = abs($pos[7] - $pos[1]);  // высота надписи
                
$yy = ($yy + $ht);
                
ImageTTFtext($image_src, $image_font_size, 0, $text_x, $yy, $text_color, $image_font_path, $v);
            }

            if (!empty(
$_POST['submit'])) {

                if (
$uset['users_money'] >= $config['create_logo_money']) {

                    
$pic = $db->selectRow("SELECT `users_picture` FROM ?_users WHERE `users_login` = ? LIMIT 1;", $log);

                    if (!empty(
$pic['users_picture'])) {

                        
unlink_image('upload/photos/', $pic['users_picture']);
                     }

                     
$time  = time();
                     
$ipath = ROOTPATH . '/upload/photos/' . $log . '.jpg';
                     
$iurl  = $config['site_url'] . '/upload/photos/' . $log . '.jpg';
                     
imagejpeg($image_src, $ipath, request('ql',75));
                     
imagedestroy($image_src);

                     @
chmod( $ipath, 0644);

                     
$db->query("UPDATE ?_users SET `users_money` = (`users_money` - ?), `users_avatar` = ?
                                 WHERE `users_login` = ?;"
, $config['create_logo_money'], $log . '.jpg', $log);

                     
set_users_shop($log, 'Создание логотипа', 'logo', $config['create_logo_money']);

                     
$inSes->addMessage('Созданное лого успешно установлено в Ваш профиль!', 'ok');
                 }
                 else {

                     
$inSes->addMessage('Ошибка! Недостаточно средств на счету!');
                     
gen_red('logo', $id, RND);
                 }
            }
            else {
        
                
$time  = time();
                
$ipath = ROOTPATH . '/upload/temp/' . $time . '.jpg';
                
$iurl  = $config['site_url'] . '/upload/temp/' . $time . '.jpg';
                
header('Content-Type: image/jpeg');
                
imagejpeg($image_src, $ipath, request('ql',75));
                
imagedestroy($image_src);
            }
        }

        
show_header('Создание аватарки');
        echo 
'<div class="b"><img src="' . $iurl . '" alt="" /></div>';
        
$form = new cmsForm(gen_uri('logo', $id, 'rnd=' . $_SESSION['token']), 'post');
        
$form->addText('Ник:', 'nick', request('nick', $log));
        
$form->addText('Имя:', 'name', request('name', $uset['users_first_name']));
        
$form->addSelect('Пол:', 'gender', request('gender',$uset['users_gender']), array(1 => 'Мужской', 2 => 'Женский'));
        
$form->addText('Icq:', 'icq', request('icq',$uset['users_icq']));
        
$form->addText('Email:', 'mail', request('mail',$uset['users_email']));
        
$form->addText('Сайт:', 'site', request('site',$_SERVER['HTTP_HOST']));
        
$form->addText('WMID:', 'wmid', request('wmid'));
        
$form->addCode('<br /><b>Настройки изображения:</b><br />');
        
$form->addSelect('Цвет текста:', 'color', request('color', ''), get_color());
        
$form->addText('Отступ текста X:', 'padding_x', request('padding_x','20'));
        
$form->addText('Отступ текста Y:', 'padding_y', request('padding_y','20'));
        
$form->addText('Расстояние между строками:', 'line_spacing', request('line_spacing','20'));
        
$form->addSelect('<br />Стиль шрифта:', 'font', request('font', ''), choice_fonts());
        
$form->addText('Размер шрифта:', 'size', request('size','13'));
        
$form->addText('Качество (0-100)', 'ql', request('ql', '75'));
        echo 
$form->Submit(array('Купить','Просмотр'), array('submit','demo'));
        unset(
$form);

        echo 
'<div class="b">';
        echo 
'Стоимость  добавления лого в анкету ' . moneys($config['create_logo_money']) . '<br />';
        echo 
'В наличии: ' . moneys($uset['users_money']) . '<br />';
        if (
$uset['users_money'] < $config['create_logo_money']) echo '<b>Недостаточное количество денег на счету для создания аватара!</b>';
        echo 
'</div>';
        echo 
'<div class="b">' . icon('return.png');
        echo 
'<a href="' . gen_uri('logo', '', RND) . '">Образцы аватарок</a></div>';

    }
    else {

        
show_header('Создание аватарки');

        
$array = array();
        
$globs = glob(ROOTPATH . '/images/textures/*.jpg');
        foreach(
$globs as $filename) {

            
$array[] = basename($filename);
        }
        
$onpage = 5;
        
$total = @count($array);

        if (
$total > 0) {

            
$start = ($page - 1) * $onpage;
            if (
$start < 0) $start = 0; 
            if (
$start > $total - 1) $start = $total - 1;
            
$stop = $start + $onpage;
            if (
$stop > $total) $stop = $total;

            for (
$i = $start; $i < $stop; $i++) {

                
$aid = (int) str_replace('.jpg', '', $array[$i]);
                echo 
'<div class="b">';
                echo 
'<img src="' . $config['site_url'] . '/images/textures/' . $array[$i] . '" height="50" width="50" alt="" /> ';
                echo 
'<a href="' . gen_uri('logo', $aid, RND) . '">Выбрать</a><br /></div>';
            }

            echo 
show_pages('logo', RND, 'p');

        }
        else 
show_error('Ошибка! Сервис временно недоступен!');

    }

    
/* Удаляем временные файлы */
    
DelTimeFiles(ROOTPATH . '/upload/temp');
}
else {


    
show_header('Создание аватарки');
    
show_login('Вы не авторизованы, чтобы создавать аватарки, необходимо');
}

?>
Онлайн: 0
Реклама