- 1
- 2
- 3
- 4
<?php $o_ids = array();
foreach ($orders_num as $thiso){array_push($o_ids, $thiso->id);}
echo implode(", ", $o_ids);
?>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
<?php $o_ids = array();
foreach ($orders_num as $thiso){array_push($o_ids, $thiso->id);}
echo implode(", ", $o_ids);
?>
Найдено в дебрях легаси
+5
function fix_hacker_strings($str){
$s=$str;
$s=str_replace('/*', 'xx', $s);
$s=str_replace('*/', 'xx', $s);
$s=str_replace('../', 'xxx', $s);
$s=str_replace('..\\', 'xxx', $s);
$s=str_ireplace('file:', 'xxxxx', $s);
$s=str_ireplace(':$', 'xx', $s);
$s=str_ireplace('http:', 'xxxx', $s);
$s=str_ireplace('https:', 'xxxxx', $s);
$s=str_ireplace('script', 'xxxxxx', $s);
$s=str_ireplace('delete', 'xxxxxx', $s);
$s=str_ireplace('drop', 'xxxx', $s);
$s=str_ireplace('select', 'xxxxxx', $s);
$s=str_ireplace('update', 'xxxxxx', $s);
$s=str_ireplace('replace', 'xxxxxxx', $s);
$s=str_ireplace('/etc/', '/xxx/', $s);
$s=str_ireplace('/var/', '/xxx/', $s);
$s=str_ireplace('/root/', '/xxxx/', $s);
$s=str_ireplace('/bin/', '/xxx/', $s);
$s=str_ireplace('/usr/', '/xxx/', $s);
$s=str_ireplace('/sys/', '/xxx/', $s);
$s=str_ireplace('/sbin/', '/xxxx/', $s);
$s=str_ireplace('/proc/', '/xxxx/', $s);
$s=str_ireplace('/boot/', '/xxxx/', $s);
$s=str_ireplace('mysql', 'xxxxx', $s);
return $s;
}
обработка user input
+4
if ($input->search_text!=""){
if ($input->search_text=="хуйня" or $input->search_text=="ХУЙНЯ" or $input->search_text=="Хуйня")
$this->result.="У нас серьезная компания и мы всякой хуйни на сайте не держим.";
else{
if (strlen($input->search_text)<2)
$this->result.="Строка поискового запроса должна состоять минимум из 2 символов.<br>Пожалуйста, измените Ваш запрос и повторите поиск.";
else{
$result.="Вы искали: <u><b>".$input->search_text."</b></u><br><br>";
Вот такие вот пасхалки у серьёзных компаний. И такой код.
+1
function send_message_with_photo($token, $peer_id, $message, $image_file_path) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
/* Получаем ссылку для загрузки фотографии */
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/photos.getMessagesUploadServer');
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"access_token" => $token,
"v" => "5.103"
));
$result = json_decode(curl_exec($ch), true);
$upload_url = $result['response']['upload_url'];
/* Отправляем фотографию */
curl_setopt($ch, CURLOPT_URL, $upload_url);
$file = curl_file_create($image_file_path);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"photo" => $file,
));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
$result = json_decode(curl_exec($ch), true);
$server = $result['server'];
$photo = $result['photo'];
$hash = $result['hash'];
/* Сохраняем фотографию */
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/photos.saveMessagesPhoto');
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"access_token" => $token,
"v" => "5.103",
"server" => $server,
"photo" => $photo,
"hash" => $hash
));
$result = json_decode(curl_exec($ch), true);
$photo_id = strval($result['response'][0]['id']);
$owner_id = strval($result['response'][0]['owner_id']);
$attachment = "photo" . $owner_id . "_" . $photo_id;
/* Отправляем сообщение */
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/messages.send');
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"access_token" => $token,
"v" => "5.103",
"random_id" => rand(),
"peer_id" => $peer_id,
"message" => $message,
"attachment" => $attachment
));
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
}
Говнокод для загрузки фото в ВК)
−3
Что это за бесячая стрелка на говнокоде, которая появляется при горизонтальном скроле?
https://i.imgur.com/uRcKSDO.png
Браузер - Opera. В FF, IE, Google Chrome - не воспроизводится.
Это заговр против Норвежских разработчиков?
+1
public function update_balance()
{
$this->balance = $this->balance_at_end_of_day(time());
}
public function balance_at_end_of_day($time)
{
return $this->balance_at_beginning_of_day($time + 24*60*60);
}
когда окунулся в легаси
+1
public function cutPoly($business_id)
{
$done = [];
$red = Isochrone::where('business_id', $business_id)->where('color', 'red')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
$blue = Isochrone::where('business_id', $business_id)->where('color', 'blue')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
$green = Isochrone::where('business_id', $business_id)->where('color', 'green')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
if ($red && $blue) {
if (!$red['p_path'] || !$blue['p_path']) {
$done['red'] = 'already';
} else {
$isoString = 'POLYGON((';
$blue_path = $blue['p_path'];
$red_path = $red['p_path'];
if (!array_key_exists('lat', $blue['p_path'][0])) {
$blue_path = $blue['p_path'][0];
}
if (!array_key_exists('lat', $red['p_path'][0])) {
$red_path = $red['p_path'][0];
}
$isoString .= implode(',', array_map(function ($entry) {
return $entry['lat'] . ' ' . $entry['lng'];
}, $red_path))
. '),('.
implode(',', array_map(function ($entry) {
return $entry['lat'] . ' ' . $entry['lng'];
}, $blue_path))
.'))';
Isochrone::where('business_id', $business_id)->where('color', 'red')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
$done['red'] = 'ok';
}
} else if ($red && $green) {
if (!$red['p_path'] || !$green['p_path']) {
$done['red'] = 'already';
} else {
$isoString = 'POLYGON((';
$green_path = $green['p_path'];
$red_path = $red['p_path'];
if (!array_key_exists('lat', $green['p_path'][0])) {
$green_path = $green['p_path'][0];
}
if (!array_key_exists('lat', $red['p_path'][0])) {
$red_path = $red['p_path'][0];
}
$isoString .= implode(',', array_map(function ($entry) {
return $entry['lat'] . ' ' . $entry['lng'];
}, $red_path))
. '),('.
implode(',', array_map(function ($entry) {
return $entry['lat'] . ' ' . $entry['lng'];
}, $green_path))
.'))';
Isochrone::where('business_id', $business_id)->where('color', 'red')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
$done['red'] = 'ok green';
}
}
if ($blue && $green) {
if (!$blue['p_path'] || !$green['p_path']) {
$done['blue'] = 'already';
} else {
$isoString = 'POLYGON((';
$green_path = $green['p_path'];
$blue_path = $blue['p_path'];
if (!array_key_exists('lat', $green['p_path'][0])) {
$green_path = $green['p_path'][0];
}
if (!array_key_exists('lat', $blue['p_path'][0])) {
$blue_path = $blue['p_path'][0];
}
$isoString .= implode(',', array_map(function ($entry) {
return $entry['lat'] . ' ' . $entry['lng'];
}, $blue_path))
. '),('.
implode(',', array_map(function ($entry) {
return $entry['lat'] . ' ' . $entry['lng'];
}, $green_path))
.'))';
Isochrone::where('business_id', $business_id)->where('color', 'blue')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
$done['blue'] = 'ok';
}
}
return $done;
}
Он же через час - три дня будет разбиратся что написал
0
if (!$resp || !is_array($resp) || array_key_exists('error', $resp)) {
// TODO: what to do?
} else {
Log::channel('caridis')->info("***********************NEW_DELIVERY");
Log::channel('caridis')->info([$order]);
$order->caridis_id = $resp['data']['id'];
}
// TODO: what to do?
сука????
+1
$s = $_REQUEST['user_str'];
$lnk = mysqli_connect('localhost','root','1234','Jelwery') or die("Error ".mysqli_error($connection));
mysqli_set_charset("utf8");
$res = mysqli_query($lnk, "SELECT SUBSTRING('".$s."',1,8') as result") or $res = ("Ошибка ".mysqli_error($connection));
$row = mysqli_fetch_assoc($res);
$s = $row['t'];
echo 'Truncated string: '.$s;
Взятие подстроки (когда запретили substr($s,8) :))
+1
return Business::find(intval(OptionGroup::find(intval(OptionSet::find($this->attributes['option_set_id'])->first()->option_group_id))->business_id))->first()->
Eloquent - это пиздец какой то..