Зачистка проекта

This commit is contained in:
ErickSkrauch 2016-07-03 21:47:13 +03:00
parent 796a2fcde8
commit b38b78bd1e
10 changed files with 0 additions and 241 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
/.idea
/awstat

View File

@ -1,5 +0,0 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>

90
app.php
View File

@ -1,90 +0,0 @@
<?php
define('ENCODING', 'UTF-8');
$app->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<br /> <a href="http://ely.by">Система скинов Ely.by</a>.')
->send();
});

2
cloaks/.gitignore vendored
View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,15 +0,0 @@
<?php
return new \Phalcon\Config([
'mongo' => [
'host' => 'localhost',
'port' => 27017,
'username' => '',
'password' => '',
'dbname' => 'ely_skins',
],
'application' => [
'modelsDir' => __DIR__ . '/../models/',
'baseUri' => '/',
]
]);

View File

@ -1,12 +0,0 @@
<?php
/**
* @var \Phalcon\Config $config
*/
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
$config->application->modelsDir
));
$loader->register();

View File

@ -1,46 +0,0 @@
<?php
/**
* @var \Phalcon\Config $config
*/
use Phalcon\Mvc\Collection\Manager;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\DI\FactoryDefault;
$di = new FactoryDefault();
$di->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();
});

View File

@ -1,39 +0,0 @@
<?php
use Phalcon\Mvc\Collection;
/**
* @property string $id
*/
class Skins extends Collection {
public $_id;
public $userId;
public $nickname;
public $skinId;
public $url;
public $is1_8;
public $isSlim;
public $hash;
public function getId() {
return $this->_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),
],
]);
}
}

View File

@ -1,7 +0,0 @@
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>

View File

@ -1,24 +0,0 @@
<?php
use Phalcon\Mvc\Micro;
error_reporting(E_ALL);
try {
/** @var \Phalcon\Config $config */
$config = include __DIR__ . '/../config/config.php';
/** @var \Phalcon\Loader $loader */
include __DIR__ . '/../config/loader.php';
/** @var Phalcon\DI\FactoryDefault $di */
include __DIR__ . '/../config/services.php';
$app = new Micro($di);
include __DIR__ . '/../app.php';
$app->handle();
} catch (Phalcon\Exception $e) {
echo $e->getMessage();
} catch (PDOException $e) {
echo $e->getMessage();
}