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(); -}