- 1
- 2
- 3
<?php
--"";
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−4
<?php
--"";
PHP Parse error: syntax error, unexpected ';', expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in /home/XQ5b1K/prog.php on line 3
https://ideone.com/vYLgSF
−1
class MyBigClass
{
var $allocatedSize;
var $allMyOtherStuff;
}
function AllocateMyBigClass()
{
$before = memory_get_usage();
$ret = new MyBigClass;
$after = memory_get_usage();
$ret->allocatedSize = ($after - $before);
return $ret;
}
Зачем нам в языке адекватный sizeof, у нас нет времени, чтобы ебаться с ним!
Подробнее: https://stackoverflow.com/questions/1351855/getting-size-in-memory-of-an-object-in-php
+1
/**
* Cast an object into a different class.
*
* Currently this only supports casting DOWN the inheritance chain,
* that is, an object may only be cast into a class if that class
* is a descendant of the object's current class.
*
* This is mostly to avoid potentially losing data by casting across
* incompatable classes.
*
* @param object $object The object to cast.
* @param string $class The class to cast the object into.
* @return object
*/
function cast($object, $class) {
if( !is_object($object) )
throw new InvalidArgumentException('$object must be an object.');
if( !is_string($class) )
throw new InvalidArgumentException('$class must be a string.');
if( !class_exists($class) )
throw new InvalidArgumentException(sprintf('Unknown class: %s.', $class));
if( !is_subclass_of($class, get_class($object)) )
throw new InvalidArgumentException(sprintf(
'%s is not a descendant of $object class: %s.',
$class, get_class($object)
));
/**
* This is a beautifully ugly hack.
*
* First, we serialize our object, which turns it into a string, allowing
* us to muck about with it using standard string manipulation methods.
*
* Then, we use preg_replace to change it's defined type to the class
* we're casting it to, and then serialize the string back into an
* object.
*/
return unserialize(
preg_replace(
'/^O:\d+:"[^"]++"/',
'O:'.strlen($class).':"'.$class.'"',
serialize($object)
)
);
}
Это прекрасно.
0
// CVE-2012-5692
/* 4015. */ static public function get($name)
/* 4016. */ {
/* 4017. */ // Check internal data first
/* 4018. */ if ( isset( self::$_cookiesSet[ $name ] ) )
/* 4019. */ {
/* 4020. */ return self::$_cookiesSet[ $name ];
/* 4021. */ }
/* 4022. */ else if ( isset( $_COOKIE[ipsRegistry::$settings['cookie_id'].$name] ) )
/* 4023. */ {
/* 4024. */ $_value = $_COOKIE[ ipsRegistry::$settings['cookie_id'].$name ];
/* 4025. */
/* 4026. */ if ( substr( $_value, 0, 2 ) == 'a:' )
/* 4027. */ {
/* 4028. */ return unserialize( stripslashes( urldecode( $_value ) ) );
/* 4029. */ }
/*
The vulnerability is caused due to this method unserialize user input passed through cookies without a proper
sanitization. The only one check is done at line 4026, where is controlled that the serialized string starts
with 'a:', but this is not sufficient to prevent a "PHP Object Injection" because an attacker may send a
serialized string which represents an array of objects. This can be exploited to execute arbitrary PHP code
via the "__destruct()" method of the "dbMain" class, which calls the "writeDebugLog" method to write debug
info into a file. PHP code may be injected only through the $_SERVER['QUERY_STRING'] variable, for this
reason successful exploitation of this vulnerability requires short_open_tag to be enabled.
*/
Если вы думаете, что самое плохое, что ждёт ваш уютный сайт на «PHP» — это Роберт-брось-таблицу, то вы глубоко ошибаетесь.
CSRF verification passed.
−1
$data = new stdClass();
$data->receivers_list = [];
$data->receivers_list[0] = new stdClass();
$data->receivers_list[0]->address = $user_wallet;
$data->receivers_list[0]->amount = $amount;
Кусок кода, от проекта, который мне теперь надо поддерживать.
−6
Name:
<input type="text" name=
"name"
value="<?php echo $name;?>">
E-mail: <
input type="text"
name="email" value="<?php
echo $email;?>">
Website: <input type="text" name="website" value="
<?php echo $website;?>"
>
Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea>
Gender:
<input type="radio" name="gender"
<
?
php
if (isset($gender) && $gender=="female") echo "checked";
?> value="female">Female
<input type="radio" name="gender"
<?php if (isset($gender) && $gender=="male") echo "checked";?>
value="male">
Male
<input type="radio" name="gender"
<?php if (isset($gender) && $gender=="other") echo "checked";?>value="other">Other
PHP говно
+1
<?php
echo implode ("<br>", file("govnokod.php"));
?>
Угадайте как называется это!
−1
define('DIR', pathinfo($_SERVER['SCRIPT_FILENAME'], PATHINFO_DIRNAME) . '/');
−6
$haystack
$needle
Что за тупые названия аргументов?
−1
/**
* Class Iin
* @package App\Classes\Support
*
* Класс проверки иин для казахстана
*
* ИИН содержит 12 цифр из которых
* первые 6 цифр - дата рождения [гг-мм-дд]
* 7-я цифра - пол и век (нечетные цифры - муж, четные женский)
* 1,2 - 19 век
* 3,4 - 20 век
* 5,6 - 21 век
* 7,8,9,0 - зарезирвированны на будущее
* 8 - 11 регистрационный гос номер
* и 12 - контрольный разряд
*
* Иин проверяесться по контрольной сумме через две последовательности
* Сперва каждая цифра иин, кроме последней умножается на цифру из 1-й последовательности и суммируется
* Результат делиться на 11 и если он от 0 до 9 и соотвествует 12-й цифре иин то иин верен,
* если результат 0 - иин не верен, если результат 10 - то проверка продолжается по второй последовательности
* Если результат проверки по всторой последовательности от 1 до 9 и равен 12-й цифре иин - то иин верен иначе проверка
* заканчивается и иин не верный.
*
* UPD - Хьюстон у нас проблемы - некоторые безответственные работники цонов делают неверные иин с 7,8 и 9 цифрой для 22 и 23 века.
* В итоге люди для системы как из 23 века а сами из 21 или 20 - так что пока не настал 22 и 23 век их разряды будут для 20 века.
* Не люблю костыли но работники цонов такие работники - а менеджеры и клиенты недовольны, так что придеться
*
https://habr.com/company/ua-hosting/blog/420091/