// Connect to Database include 'db.php'; // ----------------------------------- // BLOG - SUBSCRIBE // ----------------------------------- $subscribed = false; if($_POST['subscribe'] == "true" && $_POST['email'] != "" && $_POST['name'] != ""){ // Get POST variables $name = trim($_POST['name']); $email = trim($_POST['email']); // Validate POST Variables if ($name != '' && $email != '' && strpos($email,'@') != false && strpos($email,'.') != false){ // MySQL - Add to mailing list $sql = mysql_query("SELECT * FROM bloggers WHERE email='$email'"); $num = mysql_num_rows($sql); if ($num == 0 || $num == false){ // MySQL - Add to bloggers list $sql = mysql_query("INSERT INTO bloggers (name, email) VALUES ('$name','$email')"); } // Show Subscribed Text $subscribed = true; } } // ----------------------------------- // BLOG - ADD NEW COMMENT // ----------------------------------- if($_POST['newcomment'] == "true" && $_POST['postid'] != ""){ // Check Human Variables $a = trim($_POST['a']); $b = trim($_POST['b']); $answer = trim($_POST['answer']); // Get POST variables $postid = trim($_POST['postid']); $name = trim($_POST['name']); $email = trim($_POST['email']); $comment = strip_tags(trim($_POST['comment'])); // Make sure Title & Content were included if ($postid != '' && $name != '' && $email != '' && strpos($email,'@') != false && strpos($email,'.') != false && $comment != '' && ($a + $b) == $answer){ // Add user to bloggers list if requested if ($_POST['subscribeblog'] == "on"){ // MySQL - Add to mailing list $sql = mysql_query("SELECT * FROM bloggers WHERE email='$email'"); $num = mysql_num_rows($sql); if ($num == 0 || $num == false){ // MySQL - Add to bloggers list $sql = mysql_query("INSERT INTO bloggers (name, email) VALUES ('$name','$email')"); } } // Add user to mailing list if requested if ($_POST['mailinglist'] == "on"){ // MySQL - Add to mailing list $sql = mysql_query("SELECT * FROM mailinglist WHERE email='$email'"); $num = mysql_num_rows($sql); if ($num == 0 || $num == false){ // MySQL - Add to mailing list $sql = mysql_query("INSERT INTO mailinglist (name, email) VALUES ('$name','$email')"); } } // MySQL - Add Image to Database $sql = mysql_query("INSERT INTO blogcomments (postid, name, email, comment, dateadded) VALUES ('$postid','$name','$email','$comment',now())"); if(!sql){ $error = "Your Comment could not be added to MySQL Database (blog)"; } else { // Prepare Email $subject = "Van Hargis Blog - New Comment"; $body = '
Adminstrator,
Name: '.$name.'
If you wish to remove this comment, please login to your Administrative Panel and remove it immediately.
|
VAN'S BLOGConversations on horsemanship... and humanship
// ---------------------------- // Show Additional Page Links // ---------------------------- // See if there are more than NUMTOSHOW if ($num > $numtoshow){ ?> Page // Show Links to sets of NUMTOSHOW posts for ($m = 1; $m <= floor($num / $numtoshow)+1; $m++){ // Darker Background for Current Page if ($m != $page){ $bgcolor = '#FFFFFF'; $bgcolorhover = '#DDDDDD'; // Format page URL $pageurl = $_SERVER['REQUEST_URI']; if (strpos($pageurl,"?") == false){ $pageurl = $pageurl."?"; } else { $pageurl = $pageurl."&"; } ?> echo $m; ?> } else { $bgcolor = '#990000'; ?> echo $m; ?> } } ?> } ?> |
Subscribe:
// SUBSCRIBE FORM
if ($subscribed == false){
?>
}
// SUCCESSFULLY SUBSCRIBED
else {
?>
Thank you! Categories:
// -----------------------
// Show Categories
// -----------------------
$sqlcategories = mysql_query("SELECT * FROM blog WHERE active='Y' ORDER BY category ASC");
$numcategories = mysql_num_rows($sqlcategories);
// Array Holding Categories Displayed
$categories = array();
$count = 0;
if ($numcategories > 0){
for ($i = 0; $i < $numcategories; $i++){
// Get Category
$category = mysql_result($sqlcategories,$i,'category');
// Check if this category is in array
if (in_array($category,$categories) == false){
// Add category to Array
array_push($categories,$category);
// If count > 0
if ($count > 0){
echo "(".$count.")";
// Reset Counter
$count = 0;
}
// Increment Counter
$count++;
?>
echo $category; ?> } // Category Already in Array else { // Increment Counter $count++; } } } // If count > 0 if ($count > 0){ echo "(".$count.") "; // Reset Counter $count = 0; } ?>Archives:
// -----------------------
// Show Archives by Month
// -----------------------
$sql = mysql_query("SELECT * FROM blog WHERE active='Y' ORDER BY dateadded DESC");
$num = mysql_num_rows($sql);
// Array Holding Months Displayed
$months = array();
$count = 0;
if ($num > 0){
for ($i = 0; $i < $num; $i++){
// Get Date Variables
$dateadded = mysql_result($sql,$i,'dateadded');
$date_m = date('F',strtotime($dateadded));
$date_y = date('Y',strtotime($dateadded));
$date = $date_m." ".$date_y;
// Check if this month is in array
if (in_array($date,$months) == false){
// Add month to Array
array_push($months,$date);
// If count > 0
if ($count > 0){
echo "(".$count.")";
// Reset Counter
$count = 0;
}
// Increment Counter
$count++;
?>
echo $date; ?> } // Month Already in Array else { // Increment Counter $count++; } } } // If count > 0 if ($count > 0){ echo "(".$count.") "; // Reset Counter $count = 0; } ?> |