- 1
- 2
- 3
- 4
$val = $_POST["value"];
$val = str_replace("e", "e", $val);
$val = str_replace("E", "E", $val);
mysql_query("insert into `table` (`value`) values '$val'");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
$val = $_POST["value"];
$val = str_replace("e", "e", $val);
$val = str_replace("E", "E", $val);
mysql_query("insert into `table` (`value`) values '$val'");
Это мы так спасаемся от mysql-инъекций.
+158
#ifndef _header_hpp_included_
#define _header_hpp_included_
#include <iostream>
#include <cstdio>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/lexical_cast.hpp>
enum { recv_buffer_size = 13 };
enum { send_buffer_size = 13 };
volatile size_t counter = 0;
void client_readed(
boost::asio::ip::tcp::socket&,
char*,
FILE*,
const boost::system::error_code&
);
void client_read(
boost::asio::ip::tcp::socket& sock,
FILE* out
) {
char* buf = new char[recv_buffer_size];
boost::asio::async_read(
sock,
boost::asio::buffer(buf, recv_buffer_size),
boost::bind(
&client_readed,
boost::ref(sock),
buf,
out,
boost::asio::placeholders::error));}
void client_readed(
boost::asio::ip::tcp::socket& sock,
char* buf,
FILE* out,
const boost::system::error_code& e) {
if ( e ) {
if ( !counter ) return;
std::cout << "read handler: " << e.message() << std::endl;
return;
}
fwrite(buf, recv_buffer_size, 1, out);
counter--;
#ifdef _my_debug_
printf("client_readed(): %s", buf);
fflush(stdout);
#endif
static size_t idx = 0;
size_t tmp = 0;
char* p = strchr(buf, ':');
if ( p ) {
p++;
sscanf(p, "%8d", &tmp);
} else
throw std::runtime_error("input data error!");
delete[] buf;
if ( idx != tmp ) {
std::ostringstream os;
os << "read error. expected " << idx << " get " << tmp;
throw std::runtime_error(os.str());
}
idx++;
client_read(sock, out);
}
void writen(
char*,
FILE*,
const boost::system::error_code&
);
void start_write(
boost::asio::ip::tcp::socket& sock,
char* buf,
FILE* out) {
counter++;
boost::asio::async_write(
sock,
boost::asio::buffer(buf, send_buffer_size),
boost::bind(
&writen,
buf,
out,
boost::asio::placeholders::error)
);
}
+161
#include "header.hpp"
int main(int argc, char** argv) {
if ( argc != 4 ) {
std::cout << "client ip port 0/1 - sleed disabled/enabled" << std::endl;
return 0;
}
std::string ip = argv[1];
boost::uint16_t port = boost::lexical_cast<boost::uint16_t>(argv[2]);
bool wsleep = (argv[3][0] == '1');
std::cout << "sleep " << (wsleep?"enabled":"disabled") << std::endl;
FILE* in = fopen("client_in.log", "wb");
FILE* out= fopen("client_out.log", "wb");
if ( !out || !in ) {
std::cout << "can`t open file!" << std::endl;
return 1;
}
boost::asio::ip::tcp::endpoint endpoint(
boost::asio::ip::address::from_string(ip), port
);
boost::asio::io_service ios;
boost::shared_ptr<boost::asio::io_service::work> work(new boost::asio::io_service::work(ios));
boost::thread thread(boost::bind(&boost::asio::io_service::run, &ios));
boost::asio::ip::tcp::socket socket(ios);
socket.connect(endpoint);
boost::asio::socket_base::non_blocking_io non_blocking_io(true);
socket.io_control(non_blocking_io);
client_read(socket, in);
for ( size_t idx = 0; idx < 100000000; ++idx ) {
char* buf = new char[send_buffer_size];
sprintf(buf, "cs:%8dn", idx);
start_write(socket, buf, out);
if ( wsleep ) {
boost::this_thread::sleep(boost::posix_time::microseconds(1000));
}
}
std::cout
<< "send data to server finished!" << std::endl
<< "waiting for all ask`s from server..." << std::endl;
work.reset();
while ( counter ) {
boost::this_thread::sleep(boost::posix_time::microseconds(1000));
std::cout << "." << std::flush;
}
std::cout << std::endl << std::endl
<< "all ask`s received." << std::endl
<< "terminate client..." << std::endl;
socket.cancel();
socket.close();
thread.join();
fclose(in);
fclose(out);
}
+166
$dctEvent =new EventData_IEM_ADDON_DYNAMICCONTENTTAGS_REPLACETAGCONTENT();
Из одной системы мэйлмаркетинга. Там еще много ГК...
+161
$tmpProduct = array(
...
'FARE' => $tmpFares,
'~FARE' => CTRSCurrency::GetStringFull($row['FARE'], $o['CURRENCY']),
'TAX' => CTRSCurrency::GetString($row['TAX'], $o['CURRENCY']),
'~TAX' => CTRSCurrency::GetStringFull($row['TAX'], $o['CURRENCY']),
...
);
...
$tmpProduct['FARE_'] = $tmpProduct['~FARE'];
$tmpProduct['TAX_'] = $tmpProduct['~TAX'];
$tmpProduct['~FARE_'] = $row['FARE'];
$tmpProduct['~TAX_'] = $row['TAX'];
Из одного очень большего компонента...
+161
//стандарт
$price_st = mysql_query("select price from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do>= '$izmer' and `type`='$type_st' limit 1");
$price_st = mysql_result($price_st, 0);
$minprice_st = mysql_query("select minprice from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do >= '$izmer' and `type`='$type_st' limit 1");
$minprice_st = mysql_result($minprice_st, 0);
$time_st = mysql_query("select time from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do >= '$izmer' and `type`='$type_st' limit 1");
$time_st = mysql_result($time_st, 0);
//экспресс
$price_ex = mysql_query("select price from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do>= '$izmer' and `type`='$type_ex' limit 1");
$price_ex = mysql_result($price_ex, 0);
$minprice_ex = mysql_query("select minprice from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do >= '$izmer' and `type`='$type_ex' limit 1");
$minprice_ex = mysql_result($minprice_ex, 0);
$time_ex = mysql_query("select time from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do >= '$izmer' and `type`='$type_ex' limit 1");
$time_ex = mysql_result($time_ex, 0);
//Ритейл
$price_pallet = mysql_query("select price from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$pallets' and ves_do>= '$pallets' and `type`='$type_rit' limit 1");
$price_pallet = mysql_result($price_pallet, 0);
$time_pallet = mysql_query("select time from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$pallets' and ves_do >= '$pallets' and `type`='$type_rit' limit 1");
$time_pallet = mysql_result($time_pallet, 0);
//авиа
if ($start==getIdCity('Москва')){
if ($volume*167>$weight){
$izmer=(float)($volume*167);
$kol_av = $volume*167;
}
else
{
$izmer=$weight;
$kol_av = $weight;
}
$price_av = mysql_query("select price from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do>= '$izmer' and `type`='$type_av' limit 1");
$price_av = mysql_result($price_av, 0);
$minprice_av = mysql_query("select minprice from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do >= '$izmer' and `type`='$type_av' limit 1");
$minprice_av = mysql_result($minprice_av, 0);
$time_av = mysql_query("select time from db_tarif where `from` = '$start' and `to` = '$finish' and ves_ot <= '$izmer' and ves_do >= '$izmer' and `type`='$type_av' limit 1");
$time_av = mysql_result($time_av, 0);
}
else{
$cost_av = "Тариф недоступен";
}
калькулятор стоимости перевозки
+163
$gun = 0;
while ($gun < 10000000)
{
// Дохуя кода
$gun++;
if ( $win2 >= $casbank )
{
$gun = 12;
}
else
{
$gun = 13500000;
}
}
+163
class CStateShortMap
{
public:
CStateShortMap(int id, TDateTime time, TZReadOnlyQuery* query);
void Load(TZReadOnlyQuery* query, TDateTime time);
int GetTypeSize() const { return Items.size(); }
char GetType(int idx)
{
return Items[idx].first;
}
std::vector< std::vector<CStateShortItem> >& GetItems(char type)
{
for(int i=0; i < Items.size(); i++)
{
if( Items[i].first == type )
return Items[i].second;
}
return Items[0].second;
}
private:
const int Id;
std::vector< std::pair<char, std::vector< std::vector<CStateShortItem> > > > Items;
};
CStateShortMap::CStateShortMap(int id, TDateTime time, TZReadOnlyQuery* query)
: Id(id)
{
Load( query, time );
}
void CStateShortMap::Load(TZReadOnlyQuery* query, TDateTime time)
{
Items.clear();
String sql;
sql.sprintf( "select map.id_, equipment.type_"
" from map left join equipment on map.equipment_id=equipment.id_"
" where map.station_id=%d order by equipment.type_", Id );
query->SQL->Text = sql;
query->Open();
vector< pair<int, char> > mapId;
while( !query->Eof )
{
mapId.push_back( pair<int, char>(query->FieldByName( "id_" )->AsInteger, query->FieldByName( "type_" )->AsString[1]) );
query->Next();
}
Items.clear();
for(int i=0; i<mapId.size(); i++)
{
sql.sprintf( "select status.color, status.name_, map.number_equipment, equipment_status.status_id, equipment_status.begin_, equipment_status.plan_end_"
" from equipment_status left join map on equipment_status.map_id=map.id_"
" left join status on equipment_status.status_id=status.id_"
" where equipment_status.map_id=%d and begin_<='%s' order by equipment_status.begin_ desc limit 1",
mapId[i].first, time.FormatString("yyyy-mm-dd hh:nn:ss") ); //equipment_status.id_
query->SQL->Text = sql;
query->Open();
if( query->Eof ) continue;
int id[] = { 0, 1, 1, 1, 1, 2, 3, 1, 1, 1 };
int j;
for(j=0; j<Items.size(); j++)
if( Items[j].first==mapId[i].second )
break;
if( j!=Items.size() )
Items[j].second[id[query->FieldByName( "status_id" )->AsInteger]].push_back( CStateShortItem( query ) );
else
{
Items.push_back( std::pair<char, std::vector< std::vector<CStateShortItem> > >( mapId[i].second, std::vector< std::vector<CStateShortItem> >() ) );
Items[ Items.size()-1 ].second.resize( 4 );
Items[ Items.size()-1 ].second[ id[query->FieldByName( "status_id" )->AsInteger] ].push_back( CStateShortItem( query ) );
}
}
for(int i=0; i<Items.size(); i++)
{
sort( Items[i].second[0].begin(), Items[i].second[0].end() );
sort( Items[i].second[1].begin(), Items[i].second[1].end() );
sort( Items[i].second[2].begin(), Items[i].second[2].end() );
sort( Items[i].second[3].begin(), Items[i].second[3].end() );
}
}
старый проект на борландбыдлере, найденный на новой работе
+169
(($student[$i][1]+$student[$i][2]+$student[$i][3]+$student[$i][4]+$student[$i][5])/5)
человек посчитал среднее значение по оценкам студента
+146
Говно код
form1.open
суперский код правда не работает