Hard PHP problem

software development

#1

Hello guys i moved from another host, to dreamhost and part of the site doesn’t work. When installing the script i was notified that the host doesnt support Buffer Output, everything else was OK. I am not sure if it is cos of this or not. Tried with PHP5 and 4 - still the same.
The directory cat is created, but there is no corresponding image there, while in the html <src …> the file’s address is just fine, the thumbnail isn’t there…
Here is the source, if you got any ideas… i would be happy to hear them

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()-(36002427));

$db->query("SELECT id, title, date, alt_name, short_story, news_read FROM " . PREFIX . “_post WHERE approve=’$conf[allow_index_metka]’ AND category regexp ‘[:<:][[:>:]]’ ORDER BY date DESC LIMIT 0,$conf[top_number_mod]”);

while($row = $db->get_row()){

$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)."";
else
$link = “<a {$go_page}href=”$PHP_SELF?newsid=".$row[‘id’]."">".stripslashes($title)."";
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 = “”;
}
else
{
$images_show = “<a href=”$img" target="_blank">";
$images_show_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 ‘
RNB: Unable to mkdir: "’.CAT_IMG.’"’; }
if ( !(@chmod(CAT_IMG, 0777)) ) { return ‘
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 ‘
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">".“Äàëåå”."";
}else{
$links = “<a {$go_page} href=”".$config[‘http_home_url’].date(‘Y/m/d/’, $row[‘date’]).$row[‘alt_name’].".html">"."";
}
else
if ($conf[‘allow_dalee’]==“yes”){
$links = “<a {$go_page}href=”$PHP_SELF?newsid=".$row[‘id’]."">".“Äàëåå”."";
}else{
$links = “<a {$go_page}href=”$PHP_SELF?newsid=".$row[‘id’]."">"."";
}
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($conf[‘timestamp_active’], $row[‘date’]);
};
$top_read_cat_1 .= “<table width=“100%” border=“0” cellspacing=“0” cellpadding=“0”>

<div class=”$conf[index_top_css_mod_title]">»".$link.$read."
".$date_story."".$images.stripslashes("<div class="$conf[index_top_css]">".$short_story."");
}else{
$top_read_cat_1 .= “<div class=”$conf[index_top_css_mod_title]">»".$link.$read.$register."";
}
}
}

$db->free();
create_cache (“top_read_cat_1”, $top_read_cat_1, $conf[‘skin’]);
}

AND the function for creating thumb

/**

function cropImage($nw, $nh, $source, $dest)
{
$size = getimagesize($source);
$w = $size[0];
$h = $size[1];

$stypeArr = explode( ‘.’, $source );
$stype = strtolower( end($stypeArr) );

switch($stype)
{
case ‘gif’:
$simg = imagecreatefromgif($source);
break;
case ‘jpeg’:
$simg = imagecreatefromjpeg($source);
break;
case ‘jpg’:
$simg = imagecreatefromjpeg($source);
break;
case ‘png’:
$simg = imagecreatefrompng($source);
break;
}

$dimg = imagecreatetruecolor($nw, $nh);

$wm = $w/$nw;
$hm = $h/$nh;

$h_height = $nh/2;
$w_height = $nw/2;

if($w> $h)
{
$adjusted_width = $w / $hm;
$half_width = $adjusted_width / 2;
$int_width = $half_width - $w_height;

imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);
}
elseif( ($w <$h) || ($w == $h) )
{
$adjusted_height = $h / $wm;
$half_height = $adjusted_height / 2;
$int_height = $half_height - $h_height;

imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h);
}
else
{
imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
}

imagejpeg($dimg,$dest,85);
}

}