Created
April 16, 2012 13:28
-
-
Save VitaliiTsilnyk/2398813 to your computer and use it in GitHub Desktop.
ебать это самый говнокодный говнокод, который я видел
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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>'; | |
| } | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment