Ejemplo n.º 1
0
function ShowSkin($mini = false, $name = false, $isFemale = false, $saveBuffer = false)
{
    global $site_ways;
    loadTool('skin.class.php');
    if ($isFemale !== false) {
        $cloak = false;
        $skin = MCRAFT . 'tmp/skin_buffer/default/Char' . ($isFemale ? '_female' : '') . '.png';
        $buffer = MCRAFT . 'tmp/skin_buffer/default/Char' . ($mini ? '_Mini' : '') . ($isFemale ? '_female' : '') . '.png';
    } elseif ($name) {
        $skin = MCRAFT . $site_ways['skins'] . $name . ($isFemale ? '_female' : '') . '.png';
        $cloak = MCRAFT . $site_ways['cloaks'] . $name . '.png';
        $buffer = MCRAFT . 'tmp/skin_buffer/' . $name . ($mini ? '_Mini' : '') . '.png';
    } else {
        exit;
    }
    if (file_exists($buffer)) {
        readfile($buffer);
        exit;
    } elseif ($saveBuffer) {
        $image = $mini ? SkinViewer2D::saveHead($buffer, $skin) : SkinViewer2D::savePreview($buffer, $skin, $cloak);
    } else {
        $image = $mini ? SkinViewer2D::createHead($skin) : SkinViewer2D::createPreview($skin, $cloak);
    }
    if ($image) {
        imagepng($image);
    }
}
Ejemplo n.º 2
0
 case 'ipbans':
     $timeout = Filter::input('timeout', 'post', 'int');
     if ($timeout) {
         sqlConfigSet('next-reg-time', $timeout);
         sqlConfigSet('email-verification', (int) Filter::input('emailver', 'post', 'bool'));
         $info .= lng('OPTIONS_COMPLETE');
     } elseif (POSTGood('def_skin_male') or POSTGood('def_skin_female')) {
         $female = POSTGood('def_skin_female') ? true : false;
         $tmp_dir = MCRAFT . 'tmp/';
         $default_skin = $tmp_dir . 'default_skins/Char' . ($female ? '_female' : '') . '.png';
         $default_skin_md5 = $tmp_dir . 'default_skins/md5' . ($female ? '_female' : '') . '.md5';
         $way_buffer_mini = $tmp_dir . 'skin_buffer/default/Char_Mini' . ($female ? '_female' : '') . '.png';
         $way_buffer = $tmp_dir . 'skin_buffer/default/Char' . ($female ? '_female' : '') . '.png';
         $new_file_info = POSTSafeMove($female ? 'def_skin_female' : 'def_skin_male', $tmp_dir);
         loadTool('skin.class.php');
         if ($new_file_info and SkinViewer2D::isValidSkin($tmp_dir . $new_file_info['tmp_name']) and rename($tmp_dir . $new_file_info['tmp_name'], $default_skin)) {
             chmod($default_skin, 0644);
             $info .= lng('SKIN_CHANGED') . ' (' . (!$female ? lng('MALE') : lng('FEMALE')) . ') <br/>';
             if (file_exists($default_skin_md5)) {
                 unlink($default_skin_md5);
             }
             if (file_exists($way_buffer_mini)) {
                 unlink($way_buffer_mini);
             }
             if (file_exists($way_buffer)) {
                 unlink($way_buffer);
             }
         } else {
             $info .= lng('UPLOAD_FAIL') . '. (' . (!$female ? lng('MALE') : lng('FEMALE')) . ') <br/>';
         }
     }
Ejemplo n.º 3
0
 public function Rebuild()
 {
     $skin_way = $this->base_dir . $this->fname;
     $preview_way = $this->base_dir . 'preview/' . $this->fname;
     if (!file_exists($skin_way)) {
         $this->Delete();
         vtxtlog('[Rebuild][SkinViewer2D] SPItem ID ' . $this->id . ' not founded - delete');
         return false;
     }
     if (file_exists($preview_way)) {
         unlink($preview_way);
     }
     $skin_scale = SkinViewer2D::isValidSkin($skin_way);
     if (!$skin_scale) {
         $this->Delete();
         vtxtlog('[Rebuild][SkinViewer2D] SPItem ID ' . $this->id . ' wrong skin format - delete');
         return false;
     }
     if (!SkinViewer2D::savePreview($preview_way, $skin_way, false, false, 160)) {
         $this->Delete();
         vtxtlog('[Rebuild][SkinViewer2D] Fail to create preview for SPItem ID ' . $this->id);
         return false;
     }
     if (!file_exists($preview_way)) {
         vtxtlog('[Rebuild][SkinViewer2D] Fail to save preview for SPItem ID ' . $this->id);
     }
     $skin_scale = (int) $skin_scale['scale'];
     getDB()->ask("LOCK TABLES `{$this->db_ratio}` WRITE;");
     getDB()->ask("INSERT INTO `{$this->db_ratio}` (ratio) VALUES ('" . $skin_scale . "') ON DUPLICATE KEY UPDATE `num`= num + 1;");
     getDB()->ask("UNLOCK TABLES;");
     if ($this->ratio != $skin_scale) {
         getDB()->ask("UPDATE `{$this->db}` SET `ratio` = '" . $skin_scale . "' WHERE `id`='" . $this->id . "'");
         $this->ratio = $skin_scale;
     }
 }
Ejemplo n.º 4
0
 public function changeVisual($post_name, $type = 'skin')
 {
     global $bd_users;
     if (!$this->id or !$this->getPermission($type == 'skin' ? 'change_skin' : 'change_cloak')) {
         return 1605;
     }
     if (!POSTGood($post_name)) {
         return 1604;
     }
     $tmp_dir = MCRAFT . 'tmp/';
     $new_file_info = POSTSafeMove($post_name, $tmp_dir);
     if (!$new_file_info) {
         return 1610;
     }
     $way = $tmp_dir . $new_file_info['tmp_name'];
     if ((int) $this->getPermission('max_fsize') < $new_file_info['size_mb'] * 1024) {
         unlink($way);
         return 1601;
     }
     loadTool('skin.class.php');
     $newImgInfo = $type == 'skin' ? SkinViewer2D::isValidSkin($way) : SkinViewer2D::isValidCloak($way);
     if (!$newImgInfo['scale'] or $newImgInfo['scale'] > (int) $this->getPermission('max_ratio')) {
         unlink($way);
         return 1602;
     }
     $type == 'skin' ? $this->deleteSkin() : $this->deleteCloak();
     $new_way = $type == 'skin' ? $this->getSkinFName() : $this->getCloakFName();
     if (rename($way, $new_way)) {
         chmod($new_way, 0644);
     } else {
         unlink($way);
         vtxtlog('[Ошибка модуля загрузки] Ошибка копирования [' . $way . '] в [' . $new_way . '] . Проверьте доступ на ЧТЕНИЕ \\ ЗАПИСЬ соответствующих папок.');
         return 1611;
     }
     if ($type == 'skin') {
         if (!strcmp($this->defaultSkinMD5(), md5_file($this->getSkinFName()))) {
             $this->defaultSkinTrigger(true);
         } else {
             $this->defaultSkinTrigger(false);
         }
     }
     $this->deleteBuffer();
     getDB()->ask("UPDATE `{$this->db}` SET `undress_times`=`undress_times`+1 " . "WHERE `{$bd_users['id']}`='{$this->id}'");
     return 1;
 }