- 1
define('OKVED_TRY_BUILD_CHUNK_IF_IT_NOT_FOUND_IN_CHUNKCACHE', TRUE);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
define('OKVED_TRY_BUILD_CHUNK_IF_IT_NOT_FOUND_IN_CHUNKCACHE', TRUE);
Написал строчку и думаю - то ли я наговнокодил с названием, то ли соломки подстелил, так, что через месяц я ТОЧНО вспомню, зачем оно нужно...
+1
foreach ($child as $ch) {
if ($ch->nodeName === 'w:style') {
$sum++;
if ($ch->hasAttributes()) {
/** @var DOMAttr $attribute */
foreach ($ch->attributes as $attribute) {
if ($attribute->name === 'styleId') {
if ($attribute->value == $sTempStyle) {
/** @var DOMElement $styleNode */
foreach ($ch->childNodes as $styleNode) {
if (isset($styleNode->tagName) && $styleNode->tagName === 'w:basedOn') {
$basedOn = $styleNode->getAttribute('w:val');
$properties = $this->wordStyle2Array($basedOn, $tagName, $properties);
}
if (isset($styleNode->tagName) && $styleNode->tagName === $tagName) {
$elements = $styleNode->childNodes;
/** @var DOMElement $element */
foreach ($elements as $element) {
if (isset($element->tagName)) {
switch ($element->tagName) {
case 'w:color':
if ($element->hasAttribute('w:val')) {
$properties['color']['hex'] = '#' . $element->getAttribute
('w:val');
}
break;
case 'w:rFonts':
if ($element->hasAttribute('w:ascii')) {
$properties['font_family'] = $element->getAttribute('w:ascii');
}
break;
//кейсы - бесконечные как осень в России
}
}
}
}
}
}
}
}
}
}
Чувак, мы слышали ты любишь плодить уровни вложенности, поэтому мы написали switch в if в foreach в if в foreach в if в if в foreach в if в if в foreach, кажется.
+1
#pragma strict
function Start () {
function OnMouseDown (); {
if(name=="new") { Application.LoadLevel("procedural"); }
if(name=="set") { }
if(name=="exit") { Application.Quit(); }
}
}
+1
<span style="font-size: 16px; line-height: 12px;">
<b style="color: rgb(255, 102, 102);background-color:rgb(255, 204, 204);">
<span <a href="news/"><b style="color:rgb(153, 102, 0);">Новости</b></span>
________________________________________________________</b></span>
html код на одном сайте
+1
$row['sub']=str_replace("{&quot;",'{"',$row['sub']);
$row['sub']=str_replace("&quot;:&quot;",'":"',$row['sub']);
$row['sub']=str_replace(""",'"',$row['sub']);
$row['sub']=str_replace("&",'"',$row['sub']);
$row['sub']=str_replace("quot;:quot;",'":"',$row['sub']);
$row['sub']=str_replace("{quot;",'{"',$row['sub']);
$row['sub']=str_replace("quot;}",'"}',$row['sub']);
$row['sub']=str_replace("quot;:",'":',$row['sub']);
$sub = json_decode($row['sub']);
+1
$sql = array();
foreach ($stats as $date => $array) {
$where="";
$where = array();
$where['date'] = $date;
foreach ($array as $sub => $array1) {
$where['sub'] = $nosqlmap->text($sub);
foreach ($array1 as $webmaster => $array2) {
$where['user']=$webmaster;
foreach ($array2 as $offer => $array3) {
$where['offer'] = $offer;
foreach ($array3 as $promo => $array4) {
$where['promo'] = $promo;
foreach ($array4 as $potoc => $array5) {
$where['potoc'] = $nosqlmap->o9($potoc);
if (!isset($stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['orders'])) $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['orders'] = 0;
if (!isset($stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['aprove'])) $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['aprove'] = 0;
if (!isset($stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['noorder'])) $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['noorder'] = 0;
if (!isset($stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['money'])) $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['money'] = 0;
$where['unics'] = $array5['unics'];
$where['hits'] = $array5['hits'];
$where['orders'] = $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['orders'];
$where['aprove'] = $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['aprove'];
$where['noorder'] = $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['noorder'];
$where['money'] = $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['money'];
$sql[] = $where;
}
}
}
}
}
}
+1
$error = 0;
list($date, $time) = explode(' ', $_POST['date_till']);
if (isset($date) && isset($time)) {
list($day, $month, $year) = explode('.', $date);
list($hour, $min) = explode(':', $time);
if (isset($day) && isset($month) && isset($year) && isset($hour) && isset($min)) {
$date_till = "$year-$month-$day $hour:$min:00";
$executed = Groups::setOutOfRangeGroups($date_till);
if (!$executed) {echo 'q';
$error = 1;
}
} else {echo 'w';
$error = 1;
}
} else {echo 'e';
$error = 1;
}
Нормальные герои всегда идут в обход!
+1
bool isNoGoodCommentText = String.IsNullOrEmpty(this.txbxCommentCtrl.Text) || String.IsNullOrWhiteSpace(this.txbxCommentCtrl.Text);
И действительно, is not good
+1
// Определение метода Q3CanvasText::text()
class Q_COMPAT_EXPORT Q3CanvasText : public Q3CanvasItem {
//...
QString text() const;
//...
};
// Далее уже в "моем" классе строчка:
class CDevice : public CDiagramObject {
// ...
private:
Q3CanvasText * m_pTitle;
//....
public:
const QString & stitle() const { return m_pTitle->text(); } // обратим вниманиена возвращаемый тип
// ...
};
// Еще один класс и отображение тултипа при наведении
void CDiagramView::showToolTip( const QPoint & p, CDevice * d ) {
if( d ) {
QString tmp;
if( d->group() == QString::null || d->group() == "" )
tmp = ( d->stitle().left( d->stitle().indexOf(":") ) ); // вылетало здесь : d->stitle().indexOf(":") segmentation fault
else
tmp = d->group();
//.....
}
}
Нашел магию!
Юзаю Qt 4.8.6 в Linux
Под Виндой новая версия перепиливаемой проги компилится и работает,
под Линухом новая версия вылетает, старая робит.
Соль в том, что метод stitle() по факту возвращает ссылку на копию текста возвращенного Q3CanvasText::text(), которая внезапно удаляется при выходе из метода.
Но почему тот же gcc под виндой скомпилил это без багов?
+1
[2 Cubi Gold] <a target="_blank" href="index.php?vote=xtreme">xtremetop.com</a>
<?php
if ($_GET["vote"] == "xtreme")
{
$host='localhost';
$database='pw';
$user='root';
$pswd='password';
$dbh = mysql_connect($host, $user, $pswd) or die("Не могу соединиться с MySQL.");
mysql_select_db($database) or die("Не могу подключиться к базе.");
$search=CAuth::getLoggedName();
$search=mysql_real_escape_string($search);
$query="SELECT xtreme FROM `users` where name='".$search."'";
$res = mysql_query($query);
$row = mysql_fetch_row($res);
$dateVote=strtotime($row[0]);
$dateVote2=$row[0];
$nullDate="0000-00-00 00:00:00";
$nullDate = strtotime($nullDate);
$now=date("Y-m-d H:i:s");
$now=mysql_real_escape_string($now);
if($dateVote==$nullDate)
{
$query="UPDATE users SET xtreme='$now' WHERE name='$search'";
$query = mysql_query($query);
//запись в лог и редирект
$log_file="/var/www/html/log.txt";
$f=fopen($log_file,"a+");
$ip=getenv("REMOTE_ADDR");
fputs($f, "\n325325253\t" .date("d.m.Y H:i:s").' '.$ip."\t".CAuth::getLoggedName().' '."\t1");
fclose($f);
echo "\nYou will be redirected to xtremetop...";
echo "<meta http-equiv='Refresh' content='3;URL=http://google.ru'>";
}
else if ((strtotime($now)-strtotime($dateVote2)) < 21600)
{
echo "You can't vote. Please wait ",21600 - (strtotime($now)-strtotime($dateVote2))," seconds.";
}
else
{
$query="UPDATE users SET xtreme='$now' WHERE name='$search'";
$query = mysql_query($query);
//запись в лог и редирект
$log_file="/var/www/html/log.txt";
$f=fopen($log_file,"a+");
$ip=getenv("REMOTE_ADDR");
fputs($f, "\n325325253\t" .date("d.m.Y H:i:s").' '.$ip."\t".CAuth::getLoggedName().' '."\t1");
fclose($f);
echo "\nYou will be redirected to xtremetop...";
echo "<meta http-equiv='Refresh' content='3;URL=http://google.ru'>";
}
}
?>
Можете ли вы найти уязвимость?
Ну хоть с этим у него хорошо )))