Jump to content

Cute News problems


deathwish76

Recommended Posts

Hello guys!

I have an error in Cute News and I was wondering if any of you could help me out ::)

 

Under the comments list I get this kind of message:

 

Warning: Division by zero in .../inc/functions.inc.php on line 528

 

I checked the line and that's what I found:

 

function insertSmilies($insert_location, $break_location = FALSE, $admincp = FALSE, $wysiwyg = FALSE)
{
    global $config_http_script_dir, $config_smilies;

    $smilies = explode(",", $config_smilies);
        foreach($smilies as $smile)
        {
        $i++; $smile = trim($smile);
              if($admincp){
                    if($wysiwyg){
//                       $advanced_smile = "<img alt=\':$smile:\' src=\'data/emoticons/$smile.gif\' />";
  //                     $output .= "<a href=# onclick=\"javascript:InsertIntoArea('$insert_location','$advanced_smile'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
                       $output .= "<a href=# onclick=\"document.getElementById('$insert_location').contentWindow.document.execCommand('InsertImage', false, '$config_http_script_dir/data/emoticons/$smile.gif'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";

                    }
                    else{ $output .= "<a href=# onclick=\"javascript:document.getElementById('$insert_location').value += ' :$smile:'; return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>"; }
              }else{
                    $output .= "<a href=\"javascript:insertext(':$smile:','$insert_location')\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
              }
                if($i%$break_location == 0 and $break_location)
                {
                        $output .= "<br />";
                }else{ $output .= " "; }
    }
        return $output;
}

 

if($i%$break_location == 0 and $break_location) - that's line 528. I'd be really grateful, if you could help me with that,

 

And one more thing which is completely strange to me. There's never been any kind of problems with adding comments until one day I opened the page (I've done nothing earlier!) and it turned out that some of the latest comments disappeared and since then the comments cannot be posted and there is such an information: CuteNews did not added your comment because there is some problem with the comments database. What could've happened? :-[

 

 

Link to comment
Share on other sites

$break_location = FALSE - thats the default value if nothing is passed to the fucntion..

 

this line

 

if($i%$break_location == 0 and $break_location)

 

is dividing $i by $break_location if break location is false (0 as php will do an internal conversion to the 'correct data type) the you are trying to divide a number by 0 which will throw the error you are recieving..

 

so the fix...

 

either use error suppression with the @ operator or change this section of code

 

if($i%$break_location == 0 and $break_location)
                {
                        $output .= "<br />";
                }else{ $output .= " "; }

 

to

 

if (
   (bool)$break_location != false
   )
{
if (
    $i % $break_location == 0
    )
{
  $output .= "<br />";
}
else
{
  $output .= " ";
}
}
else
{
$output .= " ";
}

 

the error supression is easier option

 

if(@$i%$break_location == 0 and $break_location)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.