- 1
- 2
- 3
- 4
- 5
try:
os.mkdir(conf_path)
except WindowsError,e:
if "[Error 183]" not in str(e):
QMessageBox.critical(self, "Logon error","Я блять настоящий индус!")
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−178
try:
os.mkdir(conf_path)
except WindowsError,e:
if "[Error 183]" not in str(e):
QMessageBox.critical(self, "Logon error","Я блять настоящий индус!")
+164
$img_type = ".jpg";
$s = getimagesize($image);
if ($s[2] == "1") {
$img_type = ".gif";
} elseif ($as2] == "3") {
$img_type = ".png";
}
if ($img_type == ".jpg") {
$img = imagecreatefromjpeg($image);
} elseif($img_type == ".gif") {
$img = imagecreatefromgif($image);
} elseif ($img_type == ".png") {
$img = imagecreatefrompng($image);
}
$im = add_watermark($img, $image, $watermark);
if ($img_type == ".jpg") {
imagejpeg($im, $image, 85);
} elseif { ($img_type == ".gif")
imagegif($im , $image);
} elseif { ($img_type == ".png")
imagepng($im , $image);
}
Накладываем водяной знак на изображение
+145
/*Выпадающее меню - рассчитывание координат и выполнение определенных действий при определенных координатах курсора*/
//document.onmousemove = function(e){
// var mCur = mousePageXY(e);
//}
//function mousePageXY(e)
//{
// var x = 0, y = 0;
//
// if (!e) e = window.event;
//
// if (e.pageX || e.pageY)
// {
// x = e.pageX;
// y = e.pageY;
// }
//
// else if (e.clientX || e.clientY)
// {
// x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
// y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
// }
// if ((((screen.width/2-491)>x)||(screen.width/2+409<x))||((screen.width/2-491<x)&&(y<125)&&((screen.width/2-274)>x))||(y>170+height)||(((screen.width/2-274)<x)&&(y<173))) {
// document.getElementById("menu").style.display = 'none'
// }
// return {
// "x":x,
// "y":y
// };
//}
+187
function get_rand_symbols($numeric) {
if($numeric == '1') { return 'п'; }
if($numeric == '2') { return 'р'; }
if($numeric == '3') { return 'о'; }
if($numeric == '4') { return 'к'; }
if($numeric == '5') { return 'е'; }
if($numeric == '6') { return 'а'; }
if($numeric == '7') { return 'д'; }
if($numeric == '8') { return 'е'; }
if($numeric == '9') { return 'й'; }
if($numeric == '10') { return 'в'; }
if($numeric == '11') { return 'м'; }
if($numeric == '12') { return 'л'; }
if($numeric == '13') { return 'с'; }
if($numeric == '14') { return 'т'; }
if($numeric == '15') { return 'у'; }
if($numeric == '16') { return 'н'; }
if($numeric == '17') { return 'ш'; }
if($numeric == '18') { return 'х'; }
if($numeric == '19') { return 'щ'; }
if($numeric == '20') { return 'ъ'; }
if($numeric == '21') { return 'ю'; }
if($numeric == '22') { return 'б'; }
if($numeric == '23') { return 'я'; }
if($numeric == '24') { return 'ц'; }
if($numeric == '25') { return 'ч'; }
if($numeric == '26') { return 'ё'; }
if($numeric == '27') { return 'э'; }
if($numeric == '28') { return 'з'; }
if($numeric == '29') { return 'и'; }
if($numeric == '30') { return 'ы'; }
}
function all_rand() {
return get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30)).get_rand_symbols(rand(1, 30));
}
случайная строка с русскими символами
−196
SELECT SQL_CALC_FOUND_ROWS h.hotel_id , h.class, h.review_score, hr.view_count, MIN(r.min_price) as min_price
FROM hotel_facility hf11, hotel_facility hf39, hotel h
LEFT JOIN hotels.room r ON r.hotel_id = h.hotel_id
LEFT JOIN hotels.hotel_reiting_our hr ON h.hotel_id = hr.hotel_id
WHERE h.is_closed != 1 AND city_id=2760 and h.hotel_id = hf11.hotel_id and h.hotel_id = hf39.hotel_id AND hf11.hotelfacilitytype_id = 11 AND hf39.hotelfacilitytype_id = 39
GROUP BY h.hotel_id
ORDER BY h.ranking DESC;
+163
function get_date($timestamp){
return strftime("%Y", $timestamp)."-".strftime("%m", $timestamp)."-".strftime("%d", $timestamp);
}
$Time = time();
$Time2 = $Time - 604800;
$Date2 = get_date($Time2);
Чудесным образом получаем дату%)
Писал программист с опытом 12 лет.
+106
// процедура ввода новой даты в RTC
long __new_date()
{
date sysdate;
unsigned long str,i;
unsigned char tmpbuf[16];
// ...
nextda: __putsV("\n\rВведите новую дату: ");
__getsV(tmpbuf,10);
if(tmpbuf[0]==0) goto daok;
//проверка строки на допустимые символы '0'-'9' и '.'
for(i=0; tmpbuf[i]!=0; i++)
{ if((tmpbuf[i]>0x39 || tmpbuf[i]<0x30) && tmpbuf[i]!=0x2e) goto baddat;
}
//проверка числа в диапазоне 01-31
if(((tmpbuf[0]==0x33)&&(tmpbuf[1]>0x31)) || (tmpbuf[0]>0x33)
|| (tmpbuf[1]==0x2e) || ((tmpbuf[0]==0x30)&&(tmpbuf[1]==0x30)) ) goto baddat;
//проверка точки после числа
if((tmpbuf[2]!=0x2e) && (tmpbuf[2]!=0x0)) goto baddat;
if((tmpbuf[2]==0x0) || (tmpbuf[3]==0x00))
{ sysdate.ti_date=(tmpbuf[1]-0x30)+((tmpbuf[0]-0x30)<<4);
goto fordok; }
//проверка месяца в диапазоне 01-12
if(((tmpbuf[3]==0x31)&&(tmpbuf[4]>0x32)) || (tmpbuf[3]>0x31)
|| (tmpbuf[4]==0x2e) || ((tmpbuf[3]==0x30)&&(tmpbuf[4]==0x30)) ) goto baddat;
//проверка точки после месяца
if((tmpbuf[5]!=0x2e) && (tmpbuf[5]!=0x0)) goto baddat;
if((tmpbuf[5]==0x0) || (tmpbuf[6]==0x00))
{ sysdate.ti_date=(tmpbuf[1]-0x30)+((tmpbuf[0]-0x30)<<4);
sysdate.ti_month=(tmpbuf[4]-0x30)+((tmpbuf[3]-0x30)<<4);
goto fordok; }
//проверка года в диапазоне 00-99
if((tmpbuf[6]==0x2e) || (tmpbuf[7]==0x2e)) goto baddat;
if(tmpbuf[7]==0x00) goto baddat;
if(tmpbuf[8]==0x0)
{ sysdate.ti_date=(tmpbuf[1]-0x30)+((tmpbuf[0]-0x30)<<4);
sysdate.ti_month=(tmpbuf[4]-0x30)+((tmpbuf[3]-0x30)<<4);
sysdate.ti_year=(tmpbuf[7]-0x30)+((tmpbuf[6]-0x30)<<4);
goto fordok; }
baddat: __putsV("\n\rДата введена неверно (дд.мм.гг)");
goto nextda;
//установка новой даты
fordok:
__set_date(&sysdate);
daok:
return 0;
}
Из ПО отечественного шифродевайса. Функция получает от "оператора" время (дд.мм.гг), проверяет его на корректность и пишет в Real Time Clock.
+169
<?php
if($key === false){
return false;
}else{
return $key;
}
+167
...
$query = "INSERT INTO `test`.`users` (`id` ,`email` ,`password` ,`nick` ,`sex` ,`date_birth` ,`about`) VALUES(NULL,'$email','$password','$nick','$sex','$dataBirth','$about')";
$db->query($query);
$query = "SELECT `id` FROM `users` WHERE `email` = '$email' AND `password` = '$password'";
$result = $db->select($query);
...
теперь так определяется ключ, вставленный автоинкрементом
+162
public function save()
{
$query = "SELECT * FROM `users` WHERE `id` = '$this->userId'";
$result = $this->db->select($query);
if (!empty($result)) {
$query = "UPDATE `users` SET `email` = '$this->email', `password` = '$this->pass', `name` = '$this->name', `age` = '$this->age', `date_birth` = '$this->dateBirth', `sex` = '$this->sex', `aboute` = '$this->about' WHERE `id` = '$this->userId'";
} else {
$query = "INSERT INTO `users` VALUES('$this->userId','$this->email','$this->pass','$this->name','$this->age','$this->dateBirth','$this->sex','$this->about')";
}
$this->db->query($query);
}