- 1
- 2
- 3
- 4
final static public function route($home)
{
require_once "$home/pages/" . $_GET['q'] . ".php";
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+169
final static public function route($home)
{
require_once "$home/pages/" . $_GET['q'] . ".php";
}
Роутер и неепет.
+69
int limit = 10;
int countNews = daoService.getCountNews();
int currentPage = 1;
if (linkOffset != 0) {
currentPage += linkOffset / limit;
}
int offset = countNews - (linkOffset + limit);
if (offset < 0) {
offset = 0;
limit = (countNews - (linkOffset + limit)) + limit;
}
List newsList = daoService.getLimitNews(limit, offset);
List news = new ArrayList();
int index = 0;
for (int i = newsList.size() - 1; i >= 0; i--) {
news.add(index, newsList.get(i));
index++;
}
//DaoService.getLimitNews:
public List getLimitNews(String owner, int limit, int offset) {
return super.getSimpleJdbcTemplate().query(
"SELECT * FROM news WHERE owner=? AND apply=? AND local=? "
+ "ORDER BY created limit ? offset ?",
new NewsMapper(),
owner, true, true, limit, offset);
}
Получение списка новостей в ленте в обратном хронологическом порядке.
+151
foreach ($project as $key => $value) {
if (!in_array($key, array('homepage'))) {
if (isset($_POST['project'][$key])) {
if (in_array($key, array('cast', 'client', 'related'))) {
$project->$key = $this->typograf($_POST['project'][$key]);
} else {
$project->$key = $_POST['project'][$key];
}
}
} elseif ($key == 'homepage') {
$project->$key = isset($_POST['project'][$key]) ? 1 : 0;
}
}
Обработка формы в проекте на yii, который мне приходится рефакторить
+140
http://govnokod.ru/kucha
kucha - транслит
KO
+150
function check($string_to_search) {
$stack = array();
foreach (preg_split("//", $string_to_search) as $char) {
switch ($char) {
case '{':
case '(':
case '[':
array_push($stack, $char);
break;
case '}':
if (array_pop($stack) != "{") return false;
break;
case ')':
if (array_pop($stack) != "(") return false;
break;
case ']':
if (array_pop($stack) != "[") return false;
break;
}
}
return true;
}
by kolen
+146
... document.write('<img src="' + src + '" alt="" width="1" height="1" style="display:none"/>');
microsoft.com, 24 строчка
−83
((UIButton*)[[mCellsArray objectAtIndex:indexPath.row]viewWithTag:kSpeakGalleryCellButtonTag]).selected = !((UIButton*)[[mCellsArray objectAtIndex:indexPath.row]viewWithTag:kSpeakGalleryCellButtonTag]).selected;
Встречается в проекте раз пять такая конструкция
+164
function recoveryPassword( $data )
{
$value = implode( '', $data );
$key = implode( '', array_keys( $data ) );
$query = '
SELECT
u.user_id AS `id`,
u.login,
u.salt,
u.mail,
u.status
FROM
users AS `u`
WHERE
u.'.$key.' = "'.$value.'"
LIMIT 1;';
if( !list($result) = $this->db->get($query) )
{
...
}
Копаясь в старом студийном коде наткнулся. Видимо, предполагалось, что в качестве $data будет передан массив вида array( 'field' => 'value' ) c 1 элементом.
+161
///////////////////////////////////////////////
////////////
//Содержимое
function One($str,$tag,$num=1,$p=1){
if($num=='0'){ $num='1'; }
//Разделитель <тег
$see_st=explode('<'.$tag,$str);
if($p!==1){ $see_st=explode($p,$str);
$end=explode('>',$see_st[$num]);
$see_st[$num]='.'.$end[1];
}
//Разделитель </тег
$see_end=explode('</'.$tag,substr($see_st[$num],'1'));
return $see_end[0];
}
///////////////////////////////////////////////
/////////
//Парсинг
function Parse($go,$str=0){
if($str==0){ $str=$this->String; }
//Разбили путь
$path=explode("/",$go);
//Обрабатываем путь
for($go_n=0;$go_n<count($path);$go_n++){
//$go_n='2';
//Номер тега
$num=explode(':',$path[$go_n]);
if($num[1]==NULL){ $num[1]=1; }
if($go_n=='0'){ $string=$str;}else{ $string=$t[$go_n-1]; }
$t[$go_n]=$this->One($string,$num[0],$num[1]);
}
return $t[$go_n-1];
}
Тоже самое, но теперь с xmlD:
+162
function tegs($str){
if(!empty($str)){
$tegs = explode(',', $str);
$all_tegs = count($tegs);
$str_Tegs = '<a href="/tegs.php?search='.$tegs['0'].'">'.$tegs['0'].'</a>';
for($i = 1; $i<=$all_tegs-1; $i++){
$str_Tegs .= ', <a href="/tegs.php?search='.$tegs[$i].'">'.$tegs[$i].'</a>';
}
$str = $str_Tegs;
} else {
$str = 'Меток нет.';
}
return $str;
}
Правильный вывод меток