PHP
08 Jan 2012
 

ебать это самый говнокодный говнокод, который я видел

 
 
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
<?php
/*=====================================================
Случайная новость
=====================================================
Данный код защищен авторскими правами
ICQ: 271522951
email: kandriy2004@ukr.net
=====================================================
Файл: random_news.php
----------------------------------------------------------
Назначение: Вывод случайных 3 новости одним блоком
=====================================================*/
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
if(!is_numeric($title_length)) $title_length = 30;
if(!is_numeric($short_story_length)) $short_story_length = 50;
if(!is_numeric($img_maxsize)) $img_maxsize = 80;
if(isset($_GET['newsid'])&&is_numeric($_GET['newsid'])){
$newsid=$_GET['newsid'];}
else {$newsid=false;}//{news-id}
if(isset($thiscategoryid)&&is_numeric($thiscategoryid)){
;
}
else {
$thiscategoryid = 0;
}
if($thiscategoryid>0){
//echo "<h1>$newsid</h1>";
//echo "<hr/><b>".$cat_info[$thiscategoryid]['name']."</b>";
if($newsid){//without this?
$notthissql = " AND id<>'".$newsid."'";
}
else {
$notthissql = '';
}
$rr = $db->query("SELECT id, date, title, xfields, short_story, SUBSTRING_INDEX(category,',',1) as ready_cat, alt_name, flag
FROM ".PREFIX."_post where approve='1' AND category regexp '[[:<:]](".$thiscategoryid.")[[:>:]]'".$notthissql." ORDER by id DESC LIMIT 0,7");
$startandend = 0;
while ($row = $db->get_row($rr)){
echo '<!-- ANDNOW -->';
if($startandend<2){
$startandend++;
echo '<div style="clear:both;margin:2em;">';
}
$ttl = stripslashes($row['title']);
$title_short = substr($ttl, 0, $title_length);
$s_story = strip_tags($row['short_story']);
$s_story = stripslashes(substr($s_story, 0, $short_story_length)).'..';
preg_match('|<img(.*) src="([^"]*)"[^>]*>|is', $row['xfields'], $ps);
if($ps[2]){
$img_parts = pathinfo($ps[2]);
$img_link = $img_parts['dirname'].'/'.$img_parts['basename'];
$img_info = @getimagesize($img_link);
$img_width = $img_info[0];
$img_height = $img_info[1];
/* if ($img_width > $img_height) {
$img_code = '<IMG src="'.$img_link.'" alt="'.$ttl.'" width="'.$cat_info[$thiscategoryid]['name'].' - '.$img_maxsize.'"/></a>';
} else */
$img_code = '<IMG src="'.$config['http_home_url'].$img_link.'" alt="'.$cat_info[$thiscategoryid]['name'].' - '.$ttl.'" height="'.$img_maxsize.'"/>';
/*}*/
$img_code = str_replace('/http://','http://',$img_code);
}
else {
$img_code ='<div align="center" class="random_news_news">нет картинки</div>';
}
$full_link = $config['http_home_url'].get_url($thiscategoryid)."/".$row['id']."-".$row['alt_name'].".html";
echo '<div class="blocks tooltip">
<a title="'.$ttl.'" href="'.$_SERVER['http_host'].$full_link.'"><div class="block_img">'.$img_code.'</a></div>
<div class="block_game_name"><a title="'.$ttl.'" href="'.$_SERVER['http_host'].$full_link.'"><b>'.$title_short.'</b></a></div>
<span class="tip"><span class="tip_talk">'.$s_story.'</span></span>
</div>';
if($startandend<2){
$startandend++;
echo '</div>';
}
}
}
?>