- 1
- 2
- 3
- 4
- 5
- 6
- 7
protected function readConfig($configPath) {
$ini = parse_ini_file($configPath);
foreach ($ini as $key => $value) {
$config[$key] = $value;
}
return $config;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
protected function readConfig($configPath) {
$ini = parse_ini_file($configPath);
foreach ($ini as $key => $value) {
$config[$key] = $value;
}
return $config;
}
+120
var trimmedKey = Regex.Split(key, @"\.").Last();
if (_options.Any(o => o == ModelBinderOptions.ExpectUnderLineSymbolAsPrefixDelimiter))
trimmedKey = Regex.Split(trimmedKey, "_").Last();
if (_allRequiredParameters.Any(p => p.Key.ToLower() == trimmedKey.ToLower()))
{
var param = _allRequiredParameters.Single(p => p.Key.ToLower() == trimmedKey.ToLower());
try
{
if (param.Value != typeof(string))
{
if (Nullable.GetUnderlyingType(param.Value) != null)
{
try
{
var parseMethod = Nullable.GetUnderlyingType(param.Value).GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
var value = parseMethod.Invoke(null, new object[] { form[key] });
formValues.Add(param.Key, value);
}
catch(Exception)
{
formValues.Add(param.Key, null);
}
}
else
{
var parseMethod = param.Value.GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
var value = parseMethod.Invoke(null, new object[] { form[key] });
formValues.Add(param.Key, value);
}
}
else
{
formValues.Add(param.Key, form[key]);
}
}
catch (Exception)
{
// Если произошла ошибка парсинга - печально, но ничего не поделать
}
}
Фееричный парсер
+171
var e=("article,aside,footer,header,nav,section").split(',');
Найдено в дебрях одного сайта.
+150
$black = "eval|file_get_contents|mysql_(.*?)|include|require|readfile|show_source|highlight|import_request_variables|extract|parse_str|assert|passthru|exec|system|shell_exec|proc_open|fopen|echo";
if(preg_match("#\<\?(.*?)($black)(.*?)\?\>#i", $template)){
exit ("1");
break;
}
+159
#include <math.h>
#include <iostream>
using namespace std;
void main()
{ int month,day;
cin>>month,day;
int den=1;
switch(month)
{ case 1: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<den;}
break;
case 2: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==28){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 3:cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 4:cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 5: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 6: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 7: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 8: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 9: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 10: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 11: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
break;
case 12: cout<<"month: "<<month<<endl<<"day: "<<day+1;
if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
}
cin.get();
cin.get();
}
+82
/*
todo it seems that code below will be right, when client will be changed
*/
Вот такой емкий комментарий перед 200 закоментированными строками кода
+147
if ($a = 1) {
...бла-бла-бла
}
+156
<?php
if(isset($_GET["status"])) {
//Определяем переменные
$user_id = $_GET['user_id'];
$operator_id = $_GET['operator_id'];
$smsid = $_GET['smsid'];
$operator_id_str = $_GET['operator_id_str'];
$num = $_GET['num'];
$msg_trans = $_GET['msg_trans'];
$msg = $_GET['msg'];
$cost_rur = $_GET['cost_rur'];
$ratepoints = $cost_rur; //Рейтинг = стоимость смс
//Подключаемся к бд
$dblocation = "localhost"; // Имя сервера
$dbuser = "****"; // Имя пользователя
$dbpasswd = "******"; // Пароль
$dbname = "******"; //Имя бд
$dbcnx = @mysql_connect($dblocation,$dbuser,$dbpasswd);
if (!$dbcnx) {
echo("Не удалось установить соеденение");
exit();
} else {
if (!@mysql_select_db($dbname, $dbcnx)) {
echo "База данных недоступна <br />" ;
exit();
} else {
//Проверяем зарегестрирован ли пользователь
$changeuser = @mysql_query("SELECT * FROM jos_users WHERE username='$user_id'");
if(@mysql_num_rows($changeuser) > 0) {
//Пользователь зарегестрирован
@mysql_query("INSERT INTO sms (operator_id, operator_id_str, user_id, smsid, num, msg_trans, msg, cost_rur) VALUES ('$operator_id','$operator_id_str','$user_id','$smsid','$num','$msg_trans','$msg','$cost_rur')"); //Добавляем смс
@mysql_query("UPDATE jos_users SET rate = rate +1 WHERE username='$user_id'"); //Увеличиваем рейтинг
@mysql_query("UPDATE jos_users SET sms = sms +1 WHERE username='$user_id'"); //Увеличиваем кол-во смс
$rate = @mysql_fetch_array(@mysql_query("SELECT rate FROM jos_users WHERE username='$user_id'"));
echo "SMS Send OK rate +1 your rate: ".$rate['rate']."";
} else {
/*Пользователь не зарегестрирован,
Регестрируем пользователя*/
$regdate = date("Y-m-d H:i:s");
//Генерируем пароль
$pass = rand(10000, 99999);
$sqlpass = md5($pass);
//Добавляем пользователя
@mysql_query("INSERT INTO jos_users (name, username, password, usertype, gid, registerDate, lastvisitDate) VALUES ('$user_id', '$user_id', '$sqlpass', 'Registered', '18', '$regdate', '$regdate')");
$getnewuserid = @mysql_fetch_array(@mysql_query("SELECT id FROM jos_users WHERE username='$user_id'"));
@mysql_query("INSERT INTO jos_core_acl_aro (section_value, value, order_value, name, hidden) VALUES ('users', '{$getnewuserid['id']}', '0', '$user_id', '0')");
$getaro_id = @mysql_fetch_array(@mysql_query("SELECT id FROM jos_core_acl_aro WHERE name='$user_id'"));
@mysql_query("INSERT INTO jos_core_acl_groups_aro_map (group_id, aro_id) VALUES ('18', '{$getaro_id['id']}')");
@mysql_query("INSERT INTO sms (operator_id, operator_id_str, user_id, smsid, num, msg_trans, msg, cost_rur) VALUES ('$operator_id','$operator_id_str','$user_id','$smsid','$num','$msg_trans','$msg','$cost_rur')");
@mysql_query("UPDATE jos_users SET rate = rate +1 WHERE username='$user_id'");
@mysql_query("UPDATE jos_users SET sms = sms +1 WHERE username='$user_id'");
$rate = @mysql_fetch_array(@mysql_query("SELECT rate FROM jos_users WHERE username='$user_id'"));
echo "SMS Register complete. Login: ".$user_id." Pass: ".$pass." Your rate: ".$rate['rate']."";
}
}
}
}
?>
+165
ASSERT(mStartSamples.size() == mFades.size() == mIsFadeIns.size() == inOutBlock->GetNumChannels());
ASSERT(iGainData.size() == mSizes.size() == inStartSamples.size() != 0);
Краткость - сестра таланта
+76
public class ValueList< T > implements Cloneable
{
public ValueList() { }
public void addValue( final T value ) {
list.add( value );
}
@Override
@SuppressWarnings( { "unchecked", "unchecked" } )
public Object clone() throws CloneNotSupportedException {
super.clone();
ValueList< T > object = new ValueList< T >();
List< T > objectList = object.getList();
objectList = ( List< T > )list.clone();
for( int index = 0; index < list.size() ; ++index ) {
objectList.set( index, ( Object )list.get( index ).clone() );
}
return object;
}
public List< T > getList() {
return list;
}
private ArrayList< T > list = new ArrayList< T >();
}
Человек из соседнего отдела порадовал...