Skip to content
WJunction - Webmaster Forum

Module Random News error

Status
Not open for further replies.
This is the code of the module.
It worked in dle 9.5 after upgrading to 9.8 DLE does not work anymore: all the links pointing to non-existent pages that start with / 1969/12/31 /.

Code:
<?php
if(!defined('DATALIFEENGINE')){die("Hacking attempt!");}
/*
---------------------------------------------
Ìîäóëÿ âûâîäà ñëó÷àéíîé íîâîñòè èç áàçû ñàéòà
---------------------------------------------
Àâòîð: Maxic
Îáíîâèë è èñïðàâèë: Yeti 
---------------------------------------------
*/
$kol = 100; // le nombre de caracteres dans la sortie de la section nouvelles breves
$maxWidth = 150; // largeur maximale de l'image
$maxHeight = 150; // la hauteur maximale de l'image

$db->query("SELECT COUNT(*) FROM ".PREFIX ."_post");
$row = $db->get_row();

$offset = mt_rand(0, $row['COUNT(*)']-1);
$db->query("SELECT * FROM ".PREFIX ."_post LIMIT 1 OFFSET $offset");

$row = $db->get_row();
preg_match_all( '|<img[\s]+src[\s]*=[\s]*\"([^\"]*)\"|', $row['short_story'], $matches );

if ($matches[1][0] != '') {
$imageinfo = @getimagesize($matches[1][0]);  
$width  = $imageinfo[0];
$height = $imageinfo[1];

if ($width > $height) {
   $fltRatio = floatval($maxWidth / $width);
 } else {
   $fltRatio = floatval($maxHeight / $height);
}
 
$intNewWidth  = intval($fltRatio * $width);
$intNewHeight = intval($fltRatio * $height);
    
$pic = '<center><img src="'.$matches[1][0].'" width="'.$intNewWidth.'" height="'.$intNewHeight.'"></center>';
} else {$img = '';}

$news_r = '<b>'.ucfirst($row['title']).'</b>';
if ($pic != '') {$news_r .= '<br>'.$pic;}
$story = strip_tags($row['short_story']);
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($story) >= 0) {$news_r .= '<br>'.substr($story,0,$kol).'...<br><a href="'.$full_link.'">read news</a>';}


echo $news_r;
echo "\n<!-- Copyright by_WeBBster  (http://power-dle.com) -->\r\n";
?>

How I can fix it ?

Thanks Hiro
 

2 comments

dle_post table in your MySQL database it's the first think that I checked ....
I found this:

Sometimes a bug in the software will cause these fields to lose their value -- maybe during a software update or database migration -- and that's when you see the epoch date (12-31-1969) instead of the value you were expecting.
------
after 4 hours of work on php I found the solution:

delete this
Code:
else {$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";}
 
Status
Not open for further replies.

About the author

H
Active Member · Joined
Gli anni Settanta - Gli anni '70 sono anni di libertà, di trasgressione, di lotte politiche. Esplodono la...
32
Messages
0
Reactions
6
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom