From b38b78bd1e60f81a092422e810a16ba4c52404bb Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Sun, 3 Jul 2016 21:47:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D1=87=D0=B8=D1=81=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - .htaccess | 5 --- app.php | 90 --------------------------------------------- cloaks/.gitignore | 2 - config/config.php | 15 -------- config/loader.php | 12 ------ config/services.php | 46 ----------------------- models/Skins.php | 39 -------------------- public/.htaccess | 7 ---- public/index.php | 24 ------------ 10 files changed, 241 deletions(-) delete mode 100644 .htaccess delete mode 100644 app.php delete mode 100644 cloaks/.gitignore delete mode 100644 config/config.php delete mode 100644 config/loader.php delete mode 100644 config/services.php delete mode 100644 models/Skins.php delete mode 100644 public/.htaccess delete mode 100644 public/index.php diff --git a/.gitignore b/.gitignore index df1697c..a09c56d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /.idea -/awstat \ No newline at end of file diff --git a/.htaccess b/.htaccess deleted file mode 100644 index aa6a7f7..0000000 --- a/.htaccess +++ /dev/null @@ -1,5 +0,0 @@ - - RewriteEngine on - RewriteRule ^$ public/ [L] - RewriteRule (.*) public/$1 [L] - \ No newline at end of file diff --git a/app.php b/app.php deleted file mode 100644 index cb14912..0000000 --- a/app.php +++ /dev/null @@ -1,90 +0,0 @@ -get('/skins/{nickname}', function ($nickname) use ($app) { - // $systemVersion = $app->request->get('version', 'int'); - // $minecraftVersion = $app->request->get('minecraft_version', 'string'); - - // На всякий случай проверка на наличие .png для файла - if (strrpos($nickname, '.png') != -1) { - $nickname = explode('.', $nickname)[0]; - } - - // TODO: восстановить функцию деградации скинов - - $skin = Skins::findByNickname($nickname); - if (!$skin || $skin->skinId == 0) { - return $app->response->redirect('http://skins.minecraft.net/MinecraftSkins/' . $nickname . '.png', true); - } - - return $app->response->redirect($skin->url); -})->setName('skinSystem'); - -$app->get('/cloaks/{nickname}', function ($nickname) use ($app) { - // На всякий случай проверка на наличие .png для файла - if (strrpos($nickname, '.png') != -1) { - $nickname = explode('.', $nickname)[0]; - } - - return $app->response->redirect('http://skins.minecraft.net/MinecraftCloaks/'.$nickname.'.png'); -}); - -$app->get('/textures/{nickname}', function($nickname) use ($app) { - $skin = Skins::findByNickname($nickname); - if ($skin && $skin->skinId != 0) { - $url = $skin->url; - $hash = $skin->hash; - } else { - $url = 'http://skins.minecraft.net/MinecraftSkins/'.$nickname.'.png'; - $hash = md5('non-ely-' . mktime(date('H'), 0, 0) . '-' . $nickname); - } - - // TODO: в authserver.ely.by есть готовый класс для работы с форматом текстур. Так что если мы его вынесем в - // common library, то нужно будет заменить его здесь - - $textures = [ - 'SKIN' => [ - 'url' => $url, - 'hash' => $hash, - ], - ]; - - if ($skin && $skin->isSlim) { - $textures['SKIN']['metadata']['model'] = 'slim'; - } - - return $app->response->setContentType('application/json')->setJsonContent($textures); -}); - -$app->post('/system/setSkin', function() use ($app) { - $headers = getallheaders(); - if (!array_key_exists('X-Ely-key', $headers) || $headers['X-Ely-key'] != '43fd2ce61b3f5704dfd729c1f2d6ffdb') { - return $app->response->setStatusCode(403, 'Forbidden')->setContent('Хорошая попытка, мерзкий хакер.'); - } - - $request = $app->request; - $nickname = mb_convert_case($request->getPost('nickname', 'string'), MB_CASE_LOWER, ENCODING); - - $skin = Skins::findByNickname($nickname); - if (!$skin) { - $skin = new Skins(); - $skin->nickname = $nickname; - } - - $skin->userId = (int) $request->getPost('userId', 'int'); - $skin->skinId = (int) $request->getPost('skinId', 'int'); - $skin->hash = $request->getPost('hash', 'string'); - $skin->is1_8 = (bool) $request->getPost('is1_8', 'int'); - $skin->isSlim = (bool) $request->getPost('isSlim', 'int'); - $skin->url = $request->getPost('url', 'string'); - - return $app->view->setContent($skin->save() ? 'OK' : 'ERROR'); -}); - -$app->notFound(function () use ($app) { - $app->response - ->setStatusCode(404, 'Not Found') - ->setContent('Not Found
Система скинов Ely.by.') - ->send(); -}); diff --git a/cloaks/.gitignore b/cloaks/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/cloaks/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/config/config.php b/config/config.php deleted file mode 100644 index 4060a06..0000000 --- a/config/config.php +++ /dev/null @@ -1,15 +0,0 @@ - [ - 'host' => 'localhost', - 'port' => 27017, - 'username' => '', - 'password' => '', - 'dbname' => 'ely_skins', - ], - 'application' => [ - 'modelsDir' => __DIR__ . '/../models/', - 'baseUri' => '/', - ] -]); diff --git a/config/loader.php b/config/loader.php deleted file mode 100644 index eda8dce..0000000 --- a/config/loader.php +++ /dev/null @@ -1,12 +0,0 @@ -registerDirs(array( - $config->application->modelsDir -)); - -$loader->register(); diff --git a/config/services.php b/config/services.php deleted file mode 100644 index f245bda..0000000 --- a/config/services.php +++ /dev/null @@ -1,46 +0,0 @@ -set('view', function () { - $view = new View(); - $view->disable(); - - return $view; -}); - -/** - * The URL component is used to generate all kind of urls in the application - */ -$di->set('url', function () use ($config) { - $url = new UrlResolver(); - $url->setBaseUri($config->application->baseUri); - - return $url; -}); - -$di->set('mongo', function() use ($config) { - /** @var StdClass $mongoConfig */ - $mongoConfig = $config->mongo; - $connectionString = 'mongodb://'; - if ($mongoConfig->username && $mongoConfig->password) { - $connectionString .= "{$mongoConfig->username}:{$mongoConfig->password}@"; - } - - $connectionString .= $mongoConfig->host . ':' . $mongoConfig->port; - $mongo = new MongoClient($connectionString); - - return $mongo->selectDb($mongoConfig->dbname); -}); - -$di->setShared('collectionManager', function() { - return new Manager(); -}); diff --git a/models/Skins.php b/models/Skins.php deleted file mode 100644 index 07a69cc..0000000 --- a/models/Skins.php +++ /dev/null @@ -1,39 +0,0 @@ -_id; - } - - public function getSource() { - return 'skins'; - } - - /** - * @param string $nickname - * @return bool|Skins - */ - public static function findByNickname($nickname) { - return static::findFirst([ - [ - 'nickname' => mb_convert_case($nickname, MB_CASE_LOWER, ENCODING), - ], - ]); - } - -} diff --git a/public/.htaccess b/public/.htaccess deleted file mode 100644 index 297b8a6..0000000 --- a/public/.htaccess +++ /dev/null @@ -1,7 +0,0 @@ -AddDefaultCharset UTF-8 - - - RewriteEngine On - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] - \ No newline at end of file diff --git a/public/index.php b/public/index.php deleted file mode 100644 index 3583edf..0000000 --- a/public/index.php +++ /dev/null @@ -1,24 +0,0 @@ -handle(); - -} catch (Phalcon\Exception $e) { - echo $e->getMessage(); -} catch (PDOException $e) { - echo $e->getMessage(); -}