Location: PHPKode > projects > Jarida > jarida_1.0/comment.php
<?php

//Initialization....

require_once('./include/config.php');
require_once('./include/common.php');



switch ($db_type)
{
 case 'mysql':
   require_once('./classes/class.db.cnx.mysql.php');
   $db = new dbCnxMysql($db_host, $db_user, $db_pass, $db_name);
   break;
 case 'sqlite':
   require_once('./classes/class.db.cnx.sqlite.php');
   $db_file = "./include/" . $db_file;
   $db = new dbCnxSqlite($db_file);
   break;
}


//Initialize the Database
if(!$db->initialize())
{
  echo $db->getError();
}

require_once('./classes/Entry.php');
require_once('./classes/Comment.php');
require_once('./classes/ArticleComment.php');
require_once('./classes/PhotoComment.php');
require_once('./classes/Link.php');

$name = $_POST['name'];
$web = $_POST['web'];
$title = $_POST['title']; 
$body = $_POST['body'];
$ip = $_SERVER['REMOTE_ADDR'];
$article_id = $_POST['id'];
$date = time();


//If there is no "http://" in the web address,
//we append it...
///////////////////////////////////////////////////
if(!empty($web))
{
  if(!ereg("http://", $web))
    {
      $web = "http://" . $web;
    }
}


switch($_POST['type'])
{
 case 'article':
   $redirect_url = "./article.php?id=" . $_POST['id'];
   $query = "INSERT INTO tblArticleComment (comment_article_id, comment_title, comment_date, comment_body, comment_name, comment_web, comment_ip)
                VALUES('$article_id', '$title', '$date', '$body', '$name', '$web', '$ip')";
   break;

 case 'photo':
   $redirect_url = "./photo.php?id=" . $_POST['id'];
   $query = "INSERT INTO tblPhotoComment (comment_photo_id, comment_title, comment_date, comment_body, comment_name, comment_web, comment_ip)
                VALUES('$article_id', '$title', '$date', '$body', '$name', '$web', '$ip')";
   break;
}

$query2 = "SELECT ban_ip FROM tblBan WHERE ban_ip = '$ip'";
$result2 = $db->doQuery($query2);

if($result2->getNumRows() < 1)
{
  $result = $db->doQuery($query);
}

header("Location: $redirect_url");



?>
Return current item: Jarida