<?php
/*
Файл: randimg.php
-----------------------------------------------------
Назначение: рандомный вывод картинок из новостей
=====================================================
*/
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
$randimg = dle_cache( "randimg", $config['skin'] );
if( ! $randimg ) {
$db->query( "SELECT id, short_story, title, date, alt_name, category, flag FROM " . PREFIX . "_post WHERE approve='1' ORDER BY RAND() LIMIT 1" );
while ( $row = $db->get_row() ) {
$row['date'] = strtotime( $row['date'] );
$row['category'] = intval( $row['category'] );
if( $config['allow_alt_url'] == "yes" ) {
if( $row['flag'] and $config['seo_type'] ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
if( strlen( $row['title'] ) > 55 ) $title = substr( $row['title'], 0, 55 ) . " ...";
else $title = $row['title'];
$short = stripslashes($row['short_story']);
preg_match('/src=\"(.*?)\"/',$short,$image);
$img=trim($image[1]);
if($img!=''){$imag="<img align=\"left\" style = \" width: auto; height: 120px; margin-right:5px;\" src=\"".$img."\"/>";}else {$imag="<img align=\"left\" style = \" width: auto; height: 120px; margin-right:5px;\" src=\"uploads/noimage.jpg\"/>";}
$randimg .= "<div><a href=\"" . $full_link . "\">".$imag."</a></div><br>";
}
$db->free();
create_cache( "randimg", $randimg, $config['skin'] );
}
?>