- 1
$lib = $app['memcache.wrapper'] === false ? false : $app['memcache.wrapper'];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+173
$lib = $app['memcache.wrapper'] === false ? false : $app['memcache.wrapper'];
я туплю????? или кто-то получает за количество символов ????
+165
$transaction_number = (int)$this->security->xss_clean(trim(htmlspecialchars(substr($transaction_number, 0, 50))));
if(!$transaction_number OR $transaction_number < 0)
$transaction_number = 0;
один из наших программистов пишет.
CodeIgniter.
+167
// Проверка на спам
$Spam = false;
if ( substr_count( GetParam( 'info', true ), '[url' ) > 0 )
{
$Spam = true;
};
if ( substr_count( GetParam( 'info', true ), 'viagra' ) > 0 )
{
$Spam = true;
};
if ( substr_count( GetParam( 'info', true ), 'cialis' ) > 0 )
{
$Spam = true;
};
if ( substr_count( GetParam( 'info', true ), 'casino' ) > 0 )
{
$Spam = true;
};
if ( strlen( GetParam( 'info', true ) ) < 10 )
{
$Spam = true;
};
if ( $Spam )
{
$Message = "В тексте сообщения находятся спам-подобные слова.";
}
кусок кода одного скрипта, гордо именуемого CMS
+174
mysql_query("TRUNCATE TABLE ".$this->mysqlTable) or die(mysql_error()) or die(mysql_error());
Хороший киллер всегда делает контрольный выстрел.
+159
private function cp1251_utf8($sInput) {
$sOutput = "";
for ( $i = 0; $i < strlen( $sInput ); $i++ )
{
$iAscii = ord( $sInput[$i] );
if ( $iAscii >= 192 && $iAscii <= 255 )
$sOutput .= "&#".( 1040 + ( $iAscii - 192 ) ).";";
else if ( $iAscii == 168 )
$sOutput .= "&#".( 1025 ).";";
else if ( $iAscii == 184 )
$sOutput .= "&#".( 1105 ).";";
else
$sOutput .= $sInput[$i];
}
return $sOutput;
}
protected function utf8_strtr($str, $from, $to = '') {
$str = iconv('UTF-8', 'cp1251', $str);
$str = $to ? strtr($str, $from, $to) : strtr($str, $from);
return iconv('cp1251', 'UTF-8', $str);
}
public function date_rus($str) {
$str = str_replace('Jan', 'Янв', $str);
$str = str_replace('Feb', 'Фев', $str);
$str = str_replace('Mar', 'Мар', $str);
$str = str_replace('Apr', 'Апр', $str);
$str = str_replace('May', 'Май', $str);
$str = str_replace('Jun', 'Июн', $str);
$str = str_replace('Jul', 'Июл', $str);
$str = str_replace('Aug', 'Авг', $str);
$str = str_replace('Sep', 'Сен', $str);
$str = str_replace('Oct', 'Окт', $str);
$str = str_replace('Nov', 'Ноя', $str);
$str = str_replace('Dec', 'Дек', $str);
return $str;
}
пара функций из одного интересного проекта =)
перекодировка с подвыпердоворотом, перевод даты на русский без компромисов
+162
public function editSetting($group, $data, $store_id = 0) {
$this->db->query("DELETE FROM " . DB_PREFIX . "setting WHERE store_id = '" . (int)$store_id . "' AND `group` = '" . $this->db->escape($group) . "'");
foreach ($data as $key => $value) {
if (!is_array($value)) {
$this->db->query("INSERT INTO " . DB_PREFIX . "setting SET store_id = '" . (int)$store_id . "', `group` = '" . $this->db->escape($group) . "', `key` = '" . $this->db->escape($key) . "', `value` = '" . $this->db->escape($value) . "'");
} else {
$this->db->query("INSERT INTO " . DB_PREFIX . "setting SET store_id = '" . (int)$store_id . "', `group` = '" . $this->db->escape($group) . "', `key` = '" . $this->db->escape($key) . "', `value` = '" . $this->db->escape(serialize($value)) . "', serialized = '1'");
}
}
}
Всё оттуда же (Open Cart).
Оно бы вроде и ничего, если бы не id и автоинкрементом в таблице "setting". Вот так вот, каждый раз сохраняя настройки, мы прибиваем стопицот старых значений и заводим столько же совершенно новых, которые, тем не менее, в большинстве своём ничем не отличаются от старых.
+159
if (isset($this->request->post['config_image_manufacturer_height'])) {
$this->data['config_image_manufacturer_height'] = $this->request->post['config_image_manufacturer_height'];
} else {
$this->data['config_image_manufacturer_height'] = $this->config->get('config_image_manufacturer_height');
}
if (isset($this->request->post['config_image_additional_width'])) {
$this->data['config_image_additional_width'] = $this->request->post['config_image_additional_width'];
} else {
$this->data['config_image_additional_width'] = $this->config->get('config_image_additional_width');
}
if (isset($this->request->post['config_image_additional_height'])) {
$this->data['config_image_additional_height'] = $this->request->post['config_image_additional_height'];
} else {
$this->data['config_image_additional_height'] = $this->config->get('config_image_additional_height');
}
if (isset($this->request->post['config_image_related_width'])) {
$this->data['config_image_related_width'] = $this->request->post['config_image_related_width'];
} else {
$this->data['config_image_related_width'] = $this->config->get('config_image_related_width');
}
if (isset($this->request->post['config_image_related_height'])) {
$this->data['config_image_related_height'] = $this->request->post['config_image_related_height'];
} else {
$this->data['config_image_related_height'] = $this->config->get('config_image_related_height');
}
if (isset($this->request->post['config_image_compare_width'])) {
$this->data['config_image_compare_width'] = $this->request->post['config_image_compare_width'];
} else {
$this->data['config_image_compare_width'] = $this->config->get('config_image_compare_width');
}
Всего лишь небольшой кусок кода из админки OpenCart-а.
Люди! OpenCart - гамно.
+146
function define_week_start_and_end($what)
{
$time_stamp = time();
$cur_day = getdate($time_stamp);
$month_day = $cur_day['mday'];
$month_num = $cur_day['mon'];
$year_num = $cur_day['year'];
$day_num = $cur_day['wday'];
if ($day_num!=0)
{
$week_start = $month_day-$day_num+1;
}
else
{
$week_start = $month_day-6;
}
$week_end = $week_start+6;
$week_start_month_num = $month_num;
$week_end_month_num = $month_num;
$week_start_year_num = $year_num;
$week_end_year_num = $year_num;
if ($week_start < 1)
{
if ($month_num == 1)
{
$week_start_year_num--;
$week_start_month_num = 12;
}
else
{
$week_start_month_num--;
}
$last_day_in_previous_month = 31;
while (!checkdate ($week_start_month_num, $last_day_in_previous_month, $week_start_year_num))
{
$last_day_in_previous_month--;
}
$week_start += $last_day_in_previous_month;
}
$last_day_in_month = 31;
while (!checkdate ($week_start_month_num, $last_day_in_month, $week_start_year_num))
{
$last_day_in_month--;
}
if ($week_end > $last_day_in_month)
{
if ($month_num == 12)
{
$week_end_year_num++;
$week_end_month_num = 1;
}
else
{
$week_end_month_num++;
}
$week_end = $week_end-$last_day_in_month;
}
$week_start_time_stamp = gmmktime (0, 0, 0, $week_start_month_num, $week_start, $week_start_year_num);
$week_end_time_stamp = gmmktime (23, 59, 59, $week_end_month_num, $week_end, $week_end_year_num);
if ($what == "start")
{
return $week_start_time_stamp;
}
else if ($what == "end")
{
return $week_end_time_stamp;
}
return NULL;
}
определение конца недели
+147
function ckos() {
$so = $_SERVER['HTTP_USER_AGENT'];
$windowsxp = preg_match("/windows nt 5.1/i", $so);
$windowsxp2 = preg_match("/windows xp/i", $so);
$linux = preg_match("/linux/i", $so);
$windowsme = preg_match("/win 9x 4.90/i", $so);
$windowsme2 = preg_match("/windows me/i", $so);
$windows2k = preg_match("/windows nt 5.0/i", $so);
$windows2kb = preg_match("/windows 2000/i", $so);
$windowsnt = preg_match("/windows nt 3.1/i", $so);
$windowsnt2 = preg_match("/windows nt 3.5.0/i", $so);
$windowsnt3 = preg_match("/windows nt 3.5.1/i", $so);
$windowsnt4 = preg_match("/windows nt 4.0/i", $so);
$windows98 = preg_match("/windows 98/i", $so);
$windows95 = preg_match("/windows 95/i", $so);
if ($windowsxp == 1 or $windowsxp2 == 1) {
$sys = "Windows XP";
} else if ($linux == 1) {
$sys = "Linux";
} else if ($windowsme == 1 or $windowsme2 == 1) {
$sys = "Windows ME";
} else if ($windows2k == 1 or $windows2kb == 1) {
$sys = "Windows 2000";
} else if ($windowsnt == 1 or $windowsnt2 == 1 or $windowsnt3 == 1 or $windowsnt4 == 1) {
$sys = "Windows NT";
} else if ($windows98 == 1 and $windowsme != 1) {
$sys = "Windows 98";
} else if ($windows95 == 1) {
$sys = "Windows 95";
} else {
$sys = "Not identified";
}
return($sys);
}
вариация на тему броузеросниффера
+170
<?php
// $Id: post.php, v 1.12 2010/08/09 11:42:55 dries Exp $
/**
* Description of post
* Sending Email
*
* @author Unknown
*/
class post {
public function send ( $email, $subject, $message, $addHeaders, $addParameters ) {
return mail($email, $subject, $message, $addHeaders, $addParameters);
}
}
?>
Цит: "Говорят, что сначала была нарисована какая-то картина, а потом Малевич закрасил ее в черный цвет".
Ну мы ХОТЕЛИ нарисовать. Очень очень...