- 1
- 2
- 3
- 4
$new_customer = 1 if ($new_customer);
$new_customer = 0 unless ($new_customer);
# запись из весьма не малого инет-магазина.... на perl'е....
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−125
$new_customer = 1 if ($new_customer);
$new_customer = 0 unless ($new_customer);
# запись из весьма не малого инет-магазина.... на perl'е....
+171
include('conf.php');
$domen=strip_tags($_POST['domain']);
$descr=strip_tags($_POST['descr']);
$admin=strip_tags($_POST['admin']);
$tech=strip_tags($_POST['tech']);
$nserver1=strip_tags($_POST['nserver1']);
$nserver2=strip_tags($_POST['nserver2']);
$mail=strip_tags($_POST['changed']);
$submit=strip_tags($_POST['s']);
if($_POST['s']){
$simbol='|[^a-z0-9-]|i'; if(!preg_match($simbol, $domen)) {
if($domen){
if($descr){
if($admin){
if($tech){
if($nserver1){
if($nserver2){
if($mail){if (preg_match("|[0-9a-z^_]+@[0-9a-z_^.]+.[a-z]{2,3}|i",$mail)){
$headers = "Content-Type: text/plain; charset=windows-1251\n";
$headers .= "From: ".$_POST['changed']."\n";
$headers .= "X-Priority: 3\r\n";
$tem="ADD $domen.org.ua";
$msg ="domain: $domen.org.ua
descr: $descr
admin-c: $admin
tech-c: $tech
nserver: $nserver1
nserver: $nserver2
changed: $mail ".date("Ymd")."
source: UANIC";
mail("[email protected]", "$tem", $msg, $headers);
echo "Заявка отправлена со следующими данными:<br><br>";
echo"Название домена: <strong><font color=\"#ff0000\">$domen.org.ua</font></strong><br>";
echo"Описание домена: <strong><font color=\"#ff0000\">$descr</font></strong><br>";
echo"Администратор домена: <strong><font color=\"#ff0000\">$admin</font></strong><br>";
echo"Технический контакт домена: <strong><font color=\"#ff0000\">$tech</font></strong><br>";
echo"DNS Сервер № 1: <strong><font color=\"#ff0000\">$nserver1</font></strong><br>";
echo"DNS Сервер № 1: <strong><font color=\"#ff0000\">$nserver2</font></strong><br>";
echo"Ваш E-mail: <strong><font color=\"#ff0000\">$mail</font> ".date("Ymd")."</strong><br><br>";
echo"В течении 10 минут проверьте ваш почтовый ящчик <strong><font color=\"#00ff00\">$mail</font></strong> на наличие ссылки о подтверждении регистрации доменного имени";
exit();
}else{echo "<center>$error9<br>"; include('index.html'); die;}
}else{echo "<center>$error8<br>"; include('index.html'); die;}
}else{echo "<center>$error7<br>"; include('index.html'); die;}
}else{echo "<center>$error6<br>"; include('index.html'); die;}
}else{echo "<center>$error5<br>"; include('index.html'); die;}
}else{echo "<center>$error4<br>"; include('index.html'); die;}
}else{echo "<center>$error3<br>"; include('index.html'); die;}
}else{echo "<center>$error2<br>"; include('index.html'); die;}
}else{echo "<center>$error10<br>"; include('index.html'); die;}
}else{echo "<center>$error1<br>"; include('index.html'); die;}
ящчик :D
+158
$('div.contain p ~ a[href$="jpg"]').attr('id', 'linker');
document.getElementById('linker').style.color = 'green';
+111
/// <summary>
/// Получает IPAdress к которому нужно подключиться
/// </summary>
private int Get_IPAdress_Server()
{
string Buf = "";
for (int i = 0; i < Server_IP.Servers_IP.Length; i++ )
{
try
{
TcpClient tc = new TcpClient(Server_IP.Servers_IP[i], Server_IP.Servers_Port[i]);
byte[] buffer = new byte[19];
NetworkStream nss = tc.GetStream();
nss.Read(buffer, 0, 19);
Buf = Encoding.ASCII.GetString(buffer).Trim();
Server_IPAdress = Buf.Substring(0, Buf.IndexOf(":"));
Server_Port = int.Parse(Buf.Substring(Buf.IndexOf(":") + 1, Buf.Length - Buf.IndexOf(":") - 1));
return 0;
}
catch (SocketException)
{
}
}
return -1;
}
Получаем индекс в коллекции где хранятся список серверов Первый доступный!
+157
struct Vertex
{
float x, y, z;
float tu0, tv0;
} vertices[20000] =
{
-X, 0, Z, 0, 0,
X, 0, Z, 0, 0,
-X, 0, -Z, 0, 0,
X, 0, -Z, 0, 0,
0, Z, X, 0, 0,
0, Z, -X, 0, 0,
0, -Z, X, 0, 0,
0, -Z, -X, 0, 0,
Z, X, 0, 0, 0,
-Z, X, 0, 0, 0,
Z, -X, 0, 0, 0,
-Z, -X, 0, 0, 0,
};
+120
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox
cb = sender as ComboBox;
TextBox
tb = new TextBox();
if (cb == comboBox1)
{
tb = textBox7;
}
if (cb == comboBox2)
{
tb = textBox6;
}
if (cb == comboBox12)
{
tb = textBox2;
}
if (cb == comboBox3)
{
tb = textBox8;
}
if (cb == comboBox4)
{
tb = textBox9;
}
if (cb == comboBox5)
{
tb = textBox10;
}
if (cb == comboBox6)
{
tb = textBox11;
}
if (cb == comboBox7)
{
tb = textBox12;
}
if (cb == comboBox8)
{
tb = textBox13;
}
if (cb == comboBox11)
{
tb = textBox14;
}
tb.Enabled = !(cb.SelectedIndex > 0);
tb.Text = (cb.SelectedIndex > 0) ? "" : tb.Text;
}
+98
procedure TfmAllParams.NInsertParamSelebrationClick(Sender: TObject);
var
str: string;
begin
str := //Новый год
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '01.01.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
' values(1,1,null,null,null) ' +
//День св. Валентина
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '14.02.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
' values(14,2,null,null,null) ' +
//8 марта
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '08.03.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
' values(8,3,' + #39 + 'жін.' + #39 + ',null,null) ' +
//1 мая
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '01.05.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
' values(1,5,null,null,null) ' +
//Пасха
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '04.04.2010' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
' values(4,4,' + #39 + 'Pasha' + #39 + ',2010) ' +
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '24.04.2011' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
' values(24,4,' + #39 + 'Pasha' + #39 + ',2011) ' +
// И 10 таких же запросов на каждый год!
' if not exists (select id from sta_param_selebration ' +
' where date_selebration=' + #39 + '24.04.2022' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
' values(24,4,' + #39 + 'Pasha' + #39 + ',2022) ' +
+164
if (strlen($str)>1 && substr($str,strlen($str)-2,1)=="1") {
switch(substr($str,strlen($str)-1,1)) {
case "0": $newstr="десять рублей";break;
case "1": $newstr="одиннадцать рублей";break;
case "2": $newstr="двенадцать рублей";break;
case "3": $newstr="тринадцать рублей";break;
case "4": $newstr="четырнадцать рублей";break;
case "5": $newstr="пятнадцать рублей";break;
case "6": $newstr="шестнадцать рублей";break;
case "7": $newstr="семьнадцать рублей";break;
case "8": $newstr="восемьнадцать рублей";break;
case "9": $newstr="девятьнадцать рублей";break;}}
else {
switch(substr($str,strlen($str)-1,1)) {
case "0": $newstr="рублей";break;
case "1": $newstr="один рубль";break;
case "2": $newstr="два рубля";break;
case "3": $newstr="три рубля";break;
case "4": $newstr="четыре рубля";break;
case "5": $newstr="пять рублей";break;
.......................................
case "7": $newstr="семь миллионов ".$newstr;break;
case "8": $newstr="восемь миллионов ".$newstr;break;
case "9": $newstr="девять миллионов ".$newstr;break;}
if (strlen($str)>7) {
switch(substr($str,strlen($str)-8,1)) {
case "2": $newstr="двадцать ".$newstr;break;
case "3": $newstr="тридцать ".$newstr;break;
case "4": $newstr="сорок ".$newstr;break;
case "5": $newstr="пятьдесят ".$newstr;break;
case "6": $newstr="шестьдесят ".$newstr;break;
case "7": $newstr="семьдесят ".$newstr;break;
case "8": $newstr="восемьдесят ".$newstr;break;
case "9": $newstr="девяносто ".$newstr;break;}}}}
if (strlen($str)>8) {
switch(substr($str,strlen($str)-9,1)) {
case "0": $newstr="сто ".$newstr;break;
case "1": $newstr="сто ".$newstr;break;
case "2": $newstr="двести ".$newstr;break;
case "3": $newstr="триста ".$newstr;break;
case "4": $newstr="четыреста ".$newstr;break;
case "5": $newstr="пятьсот ".$newstr;break;
case "6": $newstr="шестьсот ".$newstr;break;
case "7": $newstr="семьсот ".$newstr;break;
case "8": $newstr="восемьсот ".$newstr;break;
case "9": $newstr="девятьсот ".$newstr;break;}}
Вот так делают "сумму прописью".
Радует и форматирование, и порядок порядков чисел в if .. elseif .. else
+162
function get_root($root, $is = 0)
{
if (!preg_match('/^\d+$/',$root))
{
print '\$root isn\'t an integer.';
return false;
}
if (!preg_match('/^\d+$/',$is))
{
print '\$is isn\'t an integer.';
return false;
}
if ($root > 511 || $root < 0)
{
print '\$root > 255 or \$root < 0';
return false;
}
if ($root < $is) return false;
$t_arr = array ('256', '128', '64', '32', '16', '8', '4', '2', '1');
if (!in_array($is, $t_arr) && $is != 0)
{
print '\$is isn\'t in array.';
return false;
}
if ($root == 0) return array('0');
$t_int = $root;
$t_root = array();
while ($t_int > 0)
{
for ($i = 0; $i < sizeof($t_arr); $i++)
{
if ($t_int >= $t_arr[$i])
{
$t_int -= $t_arr[$i];
$t_root[] = $t_arr[$i];
}
}
}
if ($is != 0)
{ if (in_array($is, $t_root)) return true;
else return false;
}
else return $t_root;
}
Немного опешив, я наконец-то понял, что это еще один велосипед.
+181
//Эта функция потенциальный источник багов. Я гарантирую это.
и дли-и-инная функция с кучей неясностей и без единого комента 0_0
Встретил в проекте
Похоже вместо того чтобы нормально коментировать код писавший это читал лурк...