I wanted to modify this script so that it will show only news that contain
picture in short_story. It does work but it counts the news which dont have a picture. And if i set a limit of 5 news maximum to dispay, the ones without a picture are also counted.. Any ideas where im wrong?
<?PHP
if ($conf['index_allow_top_read_cat_1'] == "yes"){
$top_read_cat_1 = dle_cache("top_read_cat_1", $conf['skin']);
if (!$top_read_cat_1) {
$this_month = date ('Y-m-d', time()-(3600*24*27));
$db->query("SELECT id, title, date, alt_name, short_story, news_read FROM " . PREFIX . "_post WHERE approve='$conf[allow_index_metka]' AND category regexp '[[:<:]]($conf[cat_num_1])[[:>:]]' ORDER BY date DESC LIMIT 0,$conf[top_number_mod]");
while($row = $db->get_row()){
////// check for image
if (get_img_basic($row['short_story'])){
////// check for image
$row['date'] = strtotime($row['date']);
if (strlen($row['title']) > 10)
$title = substr ($row['title'], 0, $conf["index_top_title"])." ...";
else
$title = $row['title'];
$go_page = ($config['ajax']) ? "onclick=\"DlePage('newsid=".$row['id']."'); return false;\" " : "";
if ($conf['allow_alt_url'] == "yes")
$link = "<a {$go_page}href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">".stripslashes($title)."</a>";
else
$link = "<a {$go_page}href=\"$PHP_SELF?newsid=".$row['id']."\">".stripslashes($title)."</a>";
if ($conf['allow_read_num']=="yes")
$read = "(".$row['news_read'].")";
if ($conf['allow_images_catindex'] == "yes")
{
unset($img);
$img = get_img_basic($row['short_story']);
if ($img =="")
$images ="";
else
if ($conf['img_blank'] == "yes")
{
$images_show = "<a href=\"$img\" target=\"_top\">";
$images_show_a = "</a>";
}
else
{
$images_show = "<a href=\"$img\" target=\"_blank\">";
$images_show_a = "</a>";
};
if ($conf['img_click_allow'] == "no")
{
$images_show = "";
$images_show_a = "";
}
//--------------
define( 'CAT_IMG', ROOT_DIR.'/uploads/cat/' );
define( 'CAT_HTTP_IMG', $config['http_home_url'].'uploads/cat/' );
if (!file_exists(CAT_IMG))
{
if ( !(@mkdir(CAT_IMG, 0777)) ) { return '<br> RNB: Unable to mkdir: "'.CAT_IMG.'"'; }
if ( !(@chmod(CAT_IMG, 0777)) ) { return '<br> RNB: Unable to chmod: "'.CAT_IMG.'"'; }
}
$not_resized_image = $img;
$resized_image = CAT_IMG.basename($img);
if (
( $size_img = @getimagesize($not_resized_image) ) &&
(
( $size_img[0] > (int)$conf[img_catindex_wigth]) || ($size_img[1] > (int)$conf[img_catindex_hieght]) )
)
{
if (!file_exists( $resized_image ))
{ # make resize:
$cim = new fth_cropImage;
$cim->cropImage(
intval($conf[img_catindex_wigth]),
intval($conf[img_catindex_hieght]),
$not_resized_image,
$resized_image
);
if ( !(@chmod ($resized_image, 0666)) ) { return '<br> CAT: Unable to chmod: "'.$resized_image.'"'; }
}
}
//--------------
if ($img)
$images = $images_show."<img src=\"".CAT_HTTP_IMG.basename($img)."\" align=\"".$conf[img_catindex_align]."\" border=0>".$images_show_a;
}
$row['short_story'] = strip_tags( $row['short_story'] );
if ($conf['allow_short_story']=="yes"){
if ($conf['allow_alt_url'] == "yes")
if ($conf['allow_dalee']=="yes"){
$links = "<a {$go_page} href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">"."Read more"."</a>";
}else{
$links = "<a {$go_page} href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">"."</a>";
}
else
if ($conf['allow_dalee']=="yes"){
$links = "<a {$go_page}href=\"$PHP_SELF?newsid=".$row['id']."\">"."Read more"."</a>";
}else{
$links = "<a {$go_page}href=\"$PHP_SELF?newsid=".$row['id']."\">"."</a>";
}
if (strlen($row['short_story']) > 50)
$short_story = substr ($row['short_story'],0, $conf["index_top_symbol"])."...$links";
else
$short_story = stripslashes($row['short_story']);
if ($conf['date_story']=="yes"){
$date_story = langdate($config['timestamp_active'], $row['date']);
};
$top_read_cat_1 .= "<td valign=\"top\" width=\"175px\"><table width=\"175px\"><tr><td>".$link.$read."</td></tr><tr><td>".$images."</td></tr><tr><td>".stripslashes("<br>".$short_story."</td></tr><tr><td>".$date_story."</td></tr></table></td>");
}
}
////// check for image
}
////// check for image
}
$db->free();
create_cache ("top_read_cat_1", $top_read_cat_1, $conf['skin']);
}
?>