Example #1
0
<?php

$url = null;
if (isset($_GET['player']) && $_GET['player'] != null) {
    $url = 'http://s3.amazonaws.com/MinecraftSkins/' . $_GET['player'] . '.png';
} else {
    if (isset($_GET['skin']) && $_GET['skin'] != null) {
        $url = $_GET['skin'];
    }
}
if (is404($url) || $url == null) {
    $url = 'char.png';
}
$skin = imagecreatefrompng($url);
$preview = imagecreatetruecolor(16, 32);
$transparent = imagecolorallocatealpha($preview, 255, 255, 255, 127);
imagefill($preview, 0, 0, $transparent);
//face
imagecopy($preview, $skin, 4, 0, 8, 8, 8, 8);
//chest
imagecopy($preview, $skin, 4, 8, 20, 20, 8, 12);
//arms
imagecopy($preview, $skin, 0, 8, 44, 20, 4, 12);
imagecopy($preview, $skin, 12, 8, 44, 20, 4, 12);
//legs
imagecopy($preview, $skin, 4, 20, 4, 20, 4, 12);
imagecopy($preview, $skin, 8, 20, 4, 20, 4, 12);
//armor
imagecopy($preview, $skin, 4, 0, 40, 8, 8, 8);
imagedestroy($skin);
$fullsize = imagecreatetruecolor(200, 400);
Example #2
0
 public function dispatch()
 {
     $controller = $this->route->controller;
     $action = $this->route->action;
     $layout = $this->route->layout;
     $controller = empty($controller) ? 'default' : $controller;
     $action = empty($action) ? 'index' : $action;
     $layout = empty($layout) ? 'default' : $layout;
     if (strstr($action, '-')) {
         $words = explode('-', $action);
         $newAction = '';
         for ($i = 0; $i < count($words); $i++) {
             $word = trim($words[$i]);
             if ($i > 0) {
                 $word = ucfirst($word);
             }
             $newAction .= $word;
         }
         $action = $newAction;
     }
     $actionName = $action . 'Action';
     $layoutFile = $this->path . DS . 'mvc' . DS . 'views' . DS . 'layouts' . DS . $layout . '.php';
     if (false === File::exists($layoutFile)) {
         is404();
     }
     $controllerFile = $this->path . DS . 'mvc' . DS . 'controllers' . DS . ucfirst(Inflector::lower($controller)) . '.php';
     $tplFile = $this->path . DS . 'mvc' . DS . 'views' . DS . ucfirst(Inflector::lower($controller)) . DS . $action . '.phtml';
     $view = false;
     if (false === File::exists($controllerFile)) {
         is404();
     }
     lib('controller');
     require_once $controllerFile;
     $class = 'Thin\\' . ucfirst(Inflector::lower($controller)) . 'Mvc';
     $i = new $class();
     if (!method_exists($i, $actionName)) {
         is404();
     }
     if (File::exists($tplFile)) {
         $view = true;
         $i->view = lib('view', $tplFile);
     }
     if (method_exists($i, 'before')) {
         $i->before();
     }
     $i->{$actionName}();
     if (method_exists($i, 'after')) {
         $i->after();
     }
     $pageContent = $i->view->render();
     $isAjax = $this->route->getIsAjax();
     if (is_null($isAjax) || false === $isAjax) {
         $route = $this->route;
         $router = new Frontroute();
         require ROOT . '/includes/config/config.php';
         require $layoutFile;
     } else {
         $user = session('user')->getUser();
         if ($user) {
             $SESSID = $user['id'];
         } else {
             $SESSID = 0;
         }
         if ($isVendeur = $this->route->getIsVendeur()) {
             if (empty($_REQUEST['p'])) {
                 $_REQUEST['p'] = '/';
             }
             $STATUS = 0;
             if ($SESSID) {
                 $STATUS = 1;
                 if (!empty($user['status'])) {
                     $STATUS = $user['status'];
                 }
             }
             $minstatus = $route->status;
             if (empty($minstatus)) {
                 $minstatus = 0;
             }
             if ($STATUS < $minstatus) {
                 $_REQUEST['p'] = '/';
             }
         }
         $json = [];
         $json['ok'] = 1;
         $json['sessid'] = $SESSID;
         $title = $i->view->title;
         $UNIVERS = $i->view->univers;
         $PAGE_REQUEST = $_REQUEST['p'];
         if (isset($title)) {
             $json['title'] = $title;
         } else {
             $json['title'] = '';
         }
         $json['html'] = $pageContent;
         $json['p'] = $PAGE_REQUEST;
         $json['univers'] = empty($UNIVERS) ? '' : $UNIVERS;
         $json['nav'] = null;
         if (session('user')->getUnivers() != $UNIVERS) {
             ob_start();
             include ROOT . '/includes/navbar.php';
             $json['nav'] = ob_get_clean();
         }
         session('user')->setUnivers($UNIVERS);
         $json['exec']['time'] = number_format(\Dbjson\Dbjson::$duration, 6);
         $json['exec']['nb'] = \Dbjson\Dbjson::$queries;
         header('Content-type:application/json');
         echo json_encode($json);
     }
 }