- 1
- 2
- 3
- 4
$n = array(38, 95,10, 8, 95, 38, 10);
sort($n);
$n = implode(',', $n);
$uniq_num = preg_replace('#,?(\d+),\1,?#', '', $n);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
$n = array(38, 95,10, 8, 95, 38, 10);
sort($n);
$n = implode(',', $n);
$uniq_num = preg_replace('#,?(\d+),\1,?#', '', $n);
+139
class secure
{
public function clear_get($_GET)
{
foreach ($_GET as $inx => $var)
{
if (!empty($_GET[$inx]))
{
$_GET[$inx] = trim($_GET[$inx]);
$_GET[$inx] = mysql_real_escape_string($_GET[$inx]);
$_GET[$inx] = htmlspecialchars($_GET[$inx]);
}
else
$_GET[$inx] =NULL;
}
}
public function clear_post($_POST)
{
foreach ($_POST as $inx => $var)
{
if (!empty($_GET[$inx]))
{
$_POST[$inx] = trim($_POST[$inx]);
$_POST[$inx] = mysql_real_escape_string($_POST[$inx]);
}
else
$_POST[$inx] =NULL;
}
}
}
Опытный прогер. мля
+156
try {
document.domain = "wolframalpha.com";
context = parent ? parent : document;
} catch(e){}
try {
if (typeof(context.$) == "undefined") {
context = window;
} else {
$=context.$;
}
}
catch(e){ context = window; }
Если с первого раза не получилось...
+165
function sorti()
{
if($_GET['where']=='desc'?$where='asc':$where='desc');
return 'where='.$where;
}
+166
public function getPreviousId(){
return $this->getId() - 1;
}
А вот так из модели можно возвратить айдишник предыдущей записи, и ничего страшного что запись с этим айдишником может не существовать в базе
+144
http://nm.merz-akademie.de/~alexander.schlegel/pixeledit/pixeleditor2.php
смотрите какой гений верстки пейсал ЭТО.
+151
$(".selection a").click(function(event){
if(this==event.target) {
$(this).toggleClass("m1active")
sel1="0"; sel2="0"; sel3="0"; sel4="0"; sel5="0"; onb="0"; sel6="0"; sel7="0"; sel8="0"; sel9="0"; sel10="0"; sel11="0"; sel12="0";
if($("#sel1").hasClass("m1active")) { sel1="1"; }
if($("#sel2").hasClass("m1active")) { sel2="1"; }
if($("#sel3").hasClass("m1active")) { sel3="1"; }
if($("#sel4").hasClass("m1active")) { sel4="1"; }
if($("#sel5").hasClass("m1active")) { sel5="1"; }
if($("#sel6").hasClass("m1active")) { sel6="1"; }
if($("#sel7").hasClass("m1active")) { sel7="1"; }
if($("#sel8").hasClass("m1active")) { sel8="1"; }
if($("#sel9").hasClass("m1active")) { sel9="1"; }
if($("#sel10").hasClass("m1active")) { sel10="1"; }
if($("#sel11").hasClass("m1active")) { sel11="1"; }
if($("#sel12").hasClass("m1active")) { sel12="1"; }
if($("#onb").hasClass("m1active")) { onb="1"; }
// var txff="eddm.php?sel1=".sel1;
$("#content-ajax").load("eddm.php",{ sel1: sel1, sel2: sel2, sel3: sel3, sel4: sel4, sel5: sel5, sel6: sel6, sel7: sel7, sel8: sel8, sel9: sel9, sel10: sel10, sel11: sel11, sel12: sel12, onb: onb }, function() {
$(".editus tr:nth-child(even)").css('background-color','#ffeedd');
});
Ребята, прошу покритиковать сайт web-school.su и предложить правильные решения
+156
list($year, $month, $day) = split('[/.-]', $r['data']);
//$month = $man[(int)$month];
$date = "$day.$month.$year";
DATE_FORMAT
+158
<script type="text/javascript">
jQuery('.container').cycle({
fx: 'scrollHorz',
prev: '#prev2',
next: '#next2',
timeout: 0});
</script>
<img id="prev2" src="<?=$this->getSkinUrl('images/leftarr.png')?>" alt="Left Arrow" />
<?php foreach ($_gallery as $_image)
$__gallery[] = $_image;
?>
<ul class="container">
<?php
for($i = 0;$i < count($__gallery);$i++):
$_image = $__gallery[($i) % count($__gallery)];
?>
<li>
<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" onclick="slide('<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()) ?>',<?php echo ($s = isset($s) ? ++$s : 0) ?>,'<?php echo $this->getGalleryUrl($_image) ?>'); return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(90); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
</li>
<?php endfor; ?>
</ul>
<ul class="container">
<?php
for($i = 0;$i < count($__gallery);$i++):
$_image = $__gallery[($i+1) % count($__gallery)];
?>
<li>
<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" onclick="slide('<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()) ?>',<?php echo ($s = isset($s) ? ++$s : 0) ?>,'<?php echo $this->getGalleryUrl($_image) ?>'); return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(90); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
</li>
<?php endfor; ?>
</ul>
<ul class="container">
<?php
for($i = 0;$i < count($__gallery);$i++):
$_image = $__gallery[($i+2) % count($__gallery)];
?>
<li>
<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" onclick="slide('<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()) ?>',<?php echo ($s = isset($s) ? ++$s : 0) ?>,'<?php echo $this->getGalleryUrl($_image) ?>'); return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(90); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
</li>
<?php endfor; ?>
</ul>
<ul class="container">
<?php
for($i = 0;$i < count($__gallery);$i++):
$_image = $__gallery[($i+3) % count($__gallery)];
?>
<li>
<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" onclick="slide('<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()) ?>',<?php echo ($s = isset($s) ? ++$s : 0) ?>,'<?php echo $this->getGalleryUrl($_image) ?>'); return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(90); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
</li>
<?php endfor; ?>
</ul>
слайдер с прокруткой с помощью цайкла
+166
template <typename RetT> RetT Max() { return (RetT)0; }
template <typename RetT, typename ArgT, typename ... Args> RetT Max(ArgT Arg1, Args ... args)
{ RetT Temp = Max<RetT>(args ...); return ((RetT)Arg1 > Temp) ? ((RetT)Arg1) : (Temp); }
int main(int argc, char* argv[])
{
printf("%d\n", Max<int>(100, 200.356, false, -300));
return 0;
}
оцените полет человеческой мысли и чудеса нового стандарта С++0x... семпл мой, правда довольно редко используется...