- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
Попытка
ДокО.Записать();
Исключение
Попытка
ДокО.Записать();
Исключение
КонецПопытки;
КонецПопытки;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−165
Попытка
ДокО.Записать();
Исключение
Попытка
ДокО.Записать();
Исключение
КонецПопытки;
КонецПопытки;
а вдруг!
−402
UIDevice* thisDevice = [UIDevice currentDevice];
char cfunktion[] = {'u', 'n', 'i', 'q', 'u', 'e', 'I', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r',0};
SEL udid = NSSelectorFromString([NSString stringWithUTF8String:cfunktion]);
id identifier =[thisDevice performSelector:udid];
Безпалевно вызываем скрытые апи.
+50
if (tp==-1 || c==a[tp]-'a') tp++; else {
l[ts+1]=la; p[ts+1]=ts;
l[ts]=l[tv]; r[ts]=tp-1; p[ts]=p[tv]; t[ts][c]=ts+1; t[ts][a[tp]-'a']=tv;
l[tv]=tp; p[tv]=ts; t[p[ts]][a[l[ts]]-'a']=ts; ts+=2;
tv=s[p[ts-2]]; tp=l[ts-2];
while (tp<=r[ts-2]) { tv=t[tv][a[tp]-'a']; tp+=r[tv]-l[tv]+1;}
if (tp==r[ts-2]+1) s[ts-2]=tv; else s[ts-2]=ts;
tp=r[tv]-(tp-r[ts-2])+2; goto suff;
}
Говнокод олимпиадный.
http://e-maxx.ru/algo/ukkonen
+157
public function toArray()
{
$that = $this;
$profile = $this->getProfile();
return [
'sex' => $profile->getSex(),
'distance' => (int) $profile->get($profile::FIELD_DISTANCE),
'balance' => new Object_Response_Model_User_Balance($profile->get($profile::FIELD_BALANCE)),
'payments' => call_user_func(function() use ($that) {
$return = [];
$checkoutTypes = $that->getRelationCheckoutTypes()->find_all()->as_array();
foreach($checkoutTypes as $checkoutType) {
if (json_decode($checkoutType->data)[0]->value) {
$return[] = $checkoutType;
}
}
return $return;
}),
'vk' => $this->getRelationSocial()->getProfileUrl(),
'validate' => $this->getValidate()
];
};
Автор: просто php нам дало анонимные функции, почему бы ими не пользоваться?
+151
public function toArray()
{
$that = $this;
$profile = $this->getProfile();
return [
'sex' => $profile->getSex(),
'distance' => (int) $profile->get($profile::FIELD_DISTANCE),
'balance' => new Object_Response_Model_User_Balance($profile->get($profile::FIELD_BALANCE)),
'payments' => call_user_func(function() use ($that) {
$return = [];
$checkoutTypes = $that->getRelationCheckoutTypes()->find_all()->as_array();
foreach($checkoutTypes as $checkoutType) {
if (json_decode($checkoutType->data)[0]->value) {
$return[] = $checkoutType;
}
}
return $return;
}),
'vk' => $this->getRelationSocial()->getProfileUrl(),
'validate' => $this->getValidate()
];
};
−161
error_response("400 Bad request", "") unless (<> =~ /^GET\s+(.+?)\s+HTTP\/1\.1\r$/);
my $request_url = $1;
log_message "REQUEST $request_url";
get_bans() if ($request_url =~ /^\/bans\?auth=$authkey$/);
remove_ban($1) if ($request_url =~ /^\/bans\/(\d+\.\d+\.\d+\.\d+)\/remove\?auth=$authkey$/);
error_response("404 Not found", "");
REST API через inetd (на этом серваке нету веб сервера, и ставить его влом). Новая жизнь старых технологий ;)
+118
protected static final float PI_2 = (float)(Math.PI / 2.0);
+154
$a = null;
var_dump($a, $a[0], $a); // NULL, NULL, NULL // what the fuck?
$a[0] = null;
var_dump($a); // array(0 => NULL)
"PHP и type juggling", том третий. При этом на первый вызов $a[0] не ругается, будто при приведении NULL к пустому массиву в нем появляется нулевой элемент.
+154
class Session {
.....
public function getIdUser()
{
if ($this->isAnonymous()) {
return null;
}
return (int)$this->attributes[self::ATTR_ID_USER];
}
public function isAnonymous()
{
return empty($this->attributes[self::ATTR_ID_USER]);
}
....
}
............
$userId = $session->isAnonymous() ? null : (int)$session->getIdUser();
+154
class Registration{
protected $data;
protected $linc = "reg.php";
protected $v_log;
protected $query_login;
protected $v_pass;
protected $v_r_pass;
protected $v_pass_r_pass;
protected $v_mail;
public function __construct() {
$this->data = array('login'=> NULL, 'password'=> NULL, 'r_password'=> NULL, 'mail'=> NULL);
foreach($this->data as $key => $val) {
$this->data[$key] = $_POST[$key];
}
$this->v_log = $this->ver_login($this->data['login']);
$this->v_pass = $this->ver_pass($this->data['password']);
$this->v_r_pass = $this->ver_r_pass($this->data['r_password']);
$this->v_pass_r_pass = $this->ver_pass_r_pass($this->data['password'],$this->data['r_password']);
$this->v_mail = $this->ver_mail($this->data['mail']);
$this->error_reporting($this->v_log,$this->v_pass,$this->v_r_pass,$this->v_pass_r_pass,$this->v_mail, $this->error_log($this->linc));
}
protected function error_log($linc){
return("<p>В поле введены неверные данные!</p></br>"
. "<form action='$linc' metod='get'>"
. "<p>Вернуться и проверить<input type = 'submit' value = 'вернуться'></p>"
. "</form>");
}
protected function ver_login($login) {
if(empty($login) or (!preg_match("/^\A(\w){6,20}\Z/", $login))) {
$login = FALSE;
unset($login);
}else{
$login == TRUE;
$this->ver_db($login);
return($login);
}
}
protected function ver_db($log) {
$q = mysql_query("SELECT id FROM users WHERE login = '$log'");
$f = mysql_fetch_array($q);
if(empty($f['id']) or $f['id'] == '') {
return($log);
}else{
echo('Есть такой');
}
}
protected function ver_pass($pass) {
if(empty($pass) or (!preg_match("/^\A(\w){6,20}\Z/", $pass))) {
$pass == FALSE;
unset($pass);
}else {
$pass == TRUE;
$pass = md5($pass);
return($pass);
}
}
protected function ver_r_pass($r_pass) {
if(empty($r_pass) or (!preg_match("/^\A(\w){6,20}\Z/", $r_pass))) {
$r_pass == FALSE;
unset($r_pass);
}else {
$r_pass == TRUE;
$r_pass = md5($r_pass);
return($r_pass);
}
}
protected function ver_pass_r_pass($pass,$r_pass) {
if($pass != $r_pass) {
return(FALSE);
}else {
return (TRUE);
}
}
protected function ver_mail($mail) {
if(empty($mail) or (!preg_match("/^[a-zA-Z0-9_\.\-]+@([a-zA-Z0-9\-]+\.)+[a-zA-Z]{2,6}$/", $mail))) {
$mail == FALSE;
unset($mail);
}else {
$mail == TRUE;
return($mail);
}
}
protected function reg_ins($log,$pass,$mail) {
$date = date("d.m.y");
$const = ACCES_KEY_DEFAULT;
$ins_query = "INSERT INTO users(login,password,mail,date,acces) VALUES ('$log','$pass','$mail','$date','$const')";
$insert = mysql_query($ins_query);
if(!$insert){
echo('error');
} else {
echo('ok');
}
}
protected function error_reporting($log,$pass,$r_pass,$pass_r_pass,$mail,$error) {
if($log == FALSE or $pass == FALSE or $r_pass == FALSE or $pass_r_pass == FALSE or $mail == FALSE){
echo($error);
} else {
//выполняем если все данные введены верно
$this->reg_ins($log, $pass, $mail);
}
:)