- 1
- 2
- 3
function nik_slashes(&$value) {
return (stripslashes($value));
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+165.2
function nik_slashes(&$value) {
return (stripslashes($value));
}
Коллега сделал свою функцию для удаления слэшей с блек джеком и всем прочим.
+158
<?php
/**
* хелпер подсчитывает кол-во дней между двух дат
*/
class ********_View_Helper_DateDiff
{
/**
* из дня, месяца и года формирует время в формате кол-ва дней
* @return integer
*/
protected function dateToDays($day, $month, $year)
{
if ($month > 2) {
// March = 0, April = 1, ..., December = 9,
// January = 10, February = 11
$month -= 3;
} else {
$month += 9;
--$year;
}
$hb_negativeyear = $year < 0;
$century = intval($year / 100);
$year = $year % 100;
if ($hb_negativeyear) {
return intval((14609700 * $century + ($year == 0 ? 1 : 0)) / 400) +
intval((1461 * $year + 1) / 4) +
intval((153 * $month + 2) / 5) +
$day + 1721118;
} else {
return intval(146097 * $century / 4) +
intval(1461 * $year / 4) +
intval((153 * $month + 2) / 5) +
$day + 1721119;
}
}
/**
* высчитывает разницу между двух дат
* @return integer
*/
public function dateDiff($day1,$month1,$year1,$day2,$month2,$year2) {
$days1 = $this->dateToDays($day1,$month1,$year1);
$days2 = $this->dateToDays($day2,$month2,$year2);
return ($days1-$days2);
}
}
кусок самописного расширения ZF.
про gregoriantojd() люди не знали.
+154.8
final class Graph extends DefaultModule implements IModule {
..........
protected function getDataByDate() {
..........
Интересно, какой скрытый смысл protected-метода в final-классе...
+160.2
function UserIsFriends($u1,$u2)
{
$db=new DB();
$db->query("SELECT `status` FROM `friends` where `status`='friends'
AND (`first`='".$u1."' or `second`='".$u1."')
AND (`first`='".$u2."' or `second`='".$u2."')");
if ($db->num_rows()!=0)$row=$db->next_record();
if ($row["status"]=="friends") return true; else return false;
}
Функция проверки дружбы между двумя людьми... ***дец
+159.4
if (Auth_OpenID_noMathSupport()) {
$null = null;
return $null;
}
взято в PHP OpenID, модуль BigMath.php, function Auth_OpenID_getMathLib
+158.6
<script type="text/javascript">
var pointsH =
[
<?php
$aPointsH = JRequest::getVar('aPoint');
if(is_array($aPointsH) && count($aPointsH) > 0){
.........
}else{
?>
[
<?php echo 0 ?>,
<?php echo 0 ?>,
'<?php echo 0 ?>',
<?php echo 0 ?>,
'<?php echo 0 ?>',
'<?php echo 0 ?>',
'<?php echo 0 ?>'
],
<?php
}
.....................
?>
....................
</script>
+141
$query =
'SELECT * ' .
'FROM `requests` ' .
'WHERE `requests`.`uid` = \'' . mysql_escape_string($uid) . '\' ' .
'AND `requests`.`status` = 0 ' .
'';
$requests = $this->execQuery($query);
if ( !$requests) {
$this->lastError = 'Error getting user\'s data. ';
return false;
} else {
$questions = $this->findAllQuestions();
foreach ($requests as $n => $request) {
$requests[$n]['quiz'] = unserialize(
unserialize($request['quiz'])
);
foreach ($requests[$n]['quiz'] as $qid => $answer) {
$currentQuestion = &$requests[$n]['quiz'][$qid];
$currentQuestion = array();
$currentQuestion['qid'] = $qid;
if (is_array($questions[$qid]['answers'])) {
$currentQuestion['question'] = $questions[$qid]['question'];
$currentQuestion['aid'] = $answer;
$currentQuestion['answer'] = $questions[$qid]['answers'][$answer]['answer'];;
} else {
$currentQuestion['question'] = $questions[$qid]['question'];
$currentQuestion['aid'] = null;
$currentQuestion['answer'] = $answer;
}
}
}
}
return $requests;
}
Я, честно говоря, так и не разобрался что "это" делает...
+141.4
function findRequest($id) {
$query =
'SELECT * ' .
'FROM `requests` ' .
'WHERE `requests`.`id` = \'' . mysql_escape_string($id) . '\' ' .
'LIMIT 0,1 ' .
'';
$request = $this->execQuery($query);
if ( !$request) {
$this->lastError = 'Error getting user\'s data. ';
return false;
} else {
$request[0]['quiz'] = unserialize(
unserialize($request[0]['quiz'])
);
}
return $request;
}
Оригинальная пунктуация сохранена
+158
<?if($addrs):?>
<?$i=0?>
<?foreach($addrs as $item):?>
<? $f = GetFields('slon_text', 43, $item['Id']) ?>
<address class="vcard">
<span class='org hidd'><?=$MG['Site_name']?></span>
<span class="adr work">
<?if(!empty($f['Город'])):?><span class="locality<?if($i!=0):?> hidd<?endif?>"><?=$f['Город']?></span><br/><?endif?>
<?if(!empty($f['Адрес'])):?><span class="street-address"><?=$f['Адрес']?></span><?endif?>
<?if(!empty($f['Страна'])):?><span class="country-name hidd"><?=$f['Страна']?></span><?endif?>
</span><br/>
<?if(!empty($f['Телефон 1'])):?>
<span class="tel">
Тел.: <span title="+38044<?=str_replace('-','',$f['Телефон 1'])?>" class="value"><?=$f['Телефон 1']?></span><?if(!empty($f['Телефон 2'])):?>, <span title="+38044<?=str_replace('-','',$f['Телефон 2'])?>" class="value"><?=$f['Телефон 2']?></span><?endif?>
</span><br/>
<?endif?>
<?if(!empty($f['E-mail'])):?><a class="email" href="mailto:<?=$f['E-mail']?>"><?=$f['E-mail']?></a><?endif?>
</address>
<?$i++?>
<?endforeach?>
<?endif?>
Говно-синтаксис
+154.6
$headers .= "From: " . '[email protected]'. " <" . '[email protected]' . ">\n";
Made by real Indians!