Beispiel #1
0
function sanitize($name)
{
    // Sanitize image filename (taken from http://iamcam.wordpress.com/2007/03/20/clean-file-names-using-php-preg_replace/ )
    $fname = $name;
    $replace = "_";
    $pattern = "/([[:alnum:]_\\.-]*)/";
    $fname = str_replace(str_split_php4(preg_replace($pattern, $replace, $fname)), $replace, $fname);
    return $fname;
}
Beispiel #2
0
 function str_split($string, $length = 1)
 {
     return str_split_php4($string, $length);
 }
<?php

//recent posts
//echo a title
$print_rec = "<p align='center' class='recent'><strong>Recent Comments</strong></p>";
echo $print_rec;
//find out if they want a spedcific blog or are looking generally
if (empty($blog_name)) {
    $recentpostswhere = "";
} else {
    $recentpostwhere = "WHERE comment_blog = '" . $mysqli->real_escape_string($blog_name) . "'";
}
//get the seven most recent entries from the database
$sql_rec1 = "SELECT comment_entry, comment_blog, comment_name, comment_text FROM blogs_comments " . $recentpostwhere . " ORDER BY comment_timestamp DESC LIMIT 7";
$request_rec1 = $mysqli->query($sql_rec1) or die($mysqli->error);
//print them
while ($row_rec1 = $request_rec1->fetch_assoc()) {
    $rec_id = $row_rec1['comment_entry'];
    $rec_blog = $row_rec1['comment_blog'];
    $rec_name = $row_rec1['comment_name'];
    $rec_text = removecrap(html_entity_decode($row_rec1['comment_text']));
    //cut it down a bit
    $rec_text_split = str_split_php4($rec_text, 17);
    $rec_text_echo = htmlentities($rec_text_split[0]);
    //echo the output
    $print_rec = "<p align='left' class='recent'><a href='?blog={$rec_blog}&amp;show=entry&amp;id={$rec_id}' class='recent'><strong>{$rec_name}</strong> {$rec_text_echo}...</a></p>";
    echo $print_rec;
}
//end while