function cut_text_by_p($str, $limit_words = 200) { /* Cuts a string at $limit number of words, * but looking for the next </p> to cut there. * */ // get the paragraphs $ps = explode('</p>', $str); $i = 0; $words = 0; $new_str = ''; while ($words < $limit_words && $i < count($ps)) { // COUNTING WORDS FROM A CLEAN STRING // conver the linebreaks into spaces $s = preg_replace('/\\<br(\\s*)?\\/?\\>/i', ' ', $ps[$i]); // strip tags $s = strip_tags(trim($s)); // get the words $words += count(explode(' ', $s)); /* If the last paragraph is not an image or object, * put some transparency before saving the paragraph. * */ $new_str .= $ps[$i] . '</p>'; $i++; } if (!are_tags_closed($new_str)) { $new_str = closetags($new_str); } return $new_str; }
die; } // Set edition mode on that comment if (!empty($_POST['submitEditComm'])) { $edition = $_POST['the_key']; } } else { $error['validation'] = 'What are you trying to do?'; } } // COMMENT SENT if (!empty($_POST['submitComm']) && !empty($_POST['comment_body']) && !empty($arrUser)) { // Arrange the content $comm_userId = $arrUser['idUser']; if (!empty($_POST['comment_body'])) { if (!are_tags_closed($_POST['comment_body'])) { $error['comm'] = 'Some tags are unclosed. Fix your message before send it again.'; } else { $comm_content = process_content($_POST['comment_body']); } if (empty($comm_content)) { $error['comm'] = 'No content, no comment'; } else { $comm_content = mysql_real_escape_string($comm_content); } } else { $error['comm'] = 'You have to write something if you want to comment.'; } // Store comment if (empty($error)) { if (empty($_POST['the_key'])) {
This script is called from message.php when the user has hit the 'Send' button. */ include_once '../admin/send_mail.php'; // for sending emails //Sanitize inputs if (isset($_POST['to_user'])) { $to_user = mysql_real_escape_string($_POST['to_user']); } else { $error['to_user'] = '******'; } if (isset($_POST['subject'])) { $subject = mysql_real_escape_string($_POST['subject']); } if (isset($_POST['message']) && $_POST['message'] != "") { if (!are_tags_closed($_POST['message'])) { $error['message'] = 'Tags need to be closed.'; } $message = mysql_real_escape_string(process_content($_POST['message'])); } else { $error['message'] = 'Message cannot have an empty body.'; } //load sender's id if (isset($arrUser)) { $idUser = $arrUser['idUser']; } else { $error['user'] = "******"; } //check to see if recipient exists $q = "SELECT email, idUser, notify FROM users WHERE username='******' LIMIT 1"; if (!($r = mysql_query($q, $dbConn)) || mysql_num_rows($r) == 0) {