- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
if ($review) {
# даем возможность исполнителю оставить свой отзыв
}else{
# заморозила именно администрация
echo json_encode(array(
'status' => 'error',
'message' => 'Задание заморожено Администрацией.',
));
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+143
if ($review) {
# даем возможность исполнителю оставить свой отзыв
}else{
# заморозила именно администрация
echo json_encode(array(
'status' => 'error',
'message' => 'Задание заморожено Администрацией.',
));
}
Нам важно ваше мнение
+175
function json2array($json_data)
{
$json_array = false;
$json = substr($json, 1, -1);
$json = str_replace(array(":", "{", "[", "}", "]"), array("=>", "array(", "array(", ")", ")"), $json_data);
@eval("\$json_array = array({$json});");
return $json_array;
}
Парсим json
+142
<?$last_update = filemtime('../b/z.zip');
$formatter = new IntlDateFormatter('ru_RU', IntlDateFormatter::FULL, IntlDateFormatter::FULL);
$formatter->setPattern(' d MMMM y года ');
$dateOstap = $formatter->format(new DateTime(date('Y-m-d H:i:s', $last_update)));
echo $dateOstap;?>//30 мая 2015 года
масло масленное
+141
private function toZeroIfNotSet($param) {
if (isset($param)) {
return $param;
} else {
return 0;
}
}
на старом проекте)
+143
/**
* Returns the first line of docblock.
*
* @param \Reflector $reflection
* @return string
*/
protected function parseDocCommentSummary($reflection)
{
$docLines = preg_split('~\R~u', $reflection->getDocComment());
if (isset($docLines[1])) {
return trim($docLines[1], "\t *");
}
return '';
}
/**
* Returns full description from the docblock.
*
* @param \Reflector $reflection
* @return string
*/
protected function parseDocCommentDetail($reflection)
{
$comment = strtr(trim(preg_replace('/^\s*\**( |\t)?/m', '', trim($reflection->getDocComment(), '/'))), "\r", '');
if (preg_match('/^\s*@\w+/m', $comment, $matches, PREG_OFFSET_CAPTURE)) {
$comment = trim(substr($comment, 0, $matches[0][1]));
}
if ($comment !== '') {
return rtrim(Console::renderColoredString(Console::markdownToAnsi($comment)));
}
return '';
}
Yii2, SOLID, очередной класс консольного приложения, который делает все подряд и хуево
https://github.com/yiisoft/yii2/blob/47bcd020fff582395db8fe9e00598acad0257922/framework/console/Controller.php#L481-L512
+143
class Security{
private $workFactor, $salt;
public function __construct(){
$this->setWorkFactor();
$salt = $this->getSaltBytes();
$this->setSalt($salt);
}
public function hash($password, $workFactor = 6){
$options = [
'cost' => (int)$workFactor,
'salt' => $this->getSalt()
];
$hash = password_hash($password, PASSWORD_BCRYPT, $options);
return $hash;
}
public function checkHash($password, $passwordHash, $options = []){
if( isset($options['salt'])){
$this->setSalt($options['salt']);
}
$workFactor = isset($options['workFactor']) ?
$options['workFactor'] : $this->getWorkFactor();
return $passwordHash === $this->hash($password, $workFactor);
}
public function isLegacyHash($passwordHash){
return strlen($passwordHash) === 60;
}
public function getSalt(){
return $this->salt;
}
public function setSalt($salt){
$this->salt = $salt;
}
public function getSaltBytes($lenght = 24){
return $this->getRandomBytes($lenght);
}
public function getRandomBytes($lenght = 24){
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $lenght; $i++){
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
public function setWorkFactor($workFactor = 6){
$this->workFactor = (int)$workFactor;
}
public function getWorkFactor(){
return $this->workFactor;
}
}
+144
if ((int)$qty && ((int)$qty > 0)) {
OpenCart
+149
$flag = "yes";
/* ... */
if($flag) {
$flag = $flag;
}
+142
// Check if the subnet begins with $startip and ends before $endip
if (($targetsub_min == $startip) && ip_less_than($targetsub_max, $endip)) {
break;
}
// Check if the subnet ends at $endip and starts after $startip
if (ip_greater_than($targetsub_min, $startip) && ($targetsub_max == $endip)) {
break;
}
// Check if the subnet is between $startip and $endip
if (ip_greater_than($targetsub_min, $startip) && ip_less_than($targetsub_max, $endip)) {
break;
}
Коль уж старые посты потерлись, принесу это говно снова. Я тогда самое главное забыл. Теперь эти пидорасы не оправдаются ущербностью PHP.
https://github.com/pfsense/pfsense/blob/master/etc/inc/util.inc#L542-L555
+143
http://govnokod.ru/comments/18245/rss ru [email protected] (govnokod.ru support) Mzz.Framework v.100500-release Wed, 27 May 2015 21:20:29 +0400 Fatal error: Call to a member function getCreated() on a non-object in /home/striker/applications/govnokod/tmp/templates_c/1563503196.file.export_quote_rss.tpl.php-ru.php on line 21
http://govnokod.ru/, в чём дело: