Author Topic: free mini shoutbox etano 1.23 facebook style  (Read 2880 times)

csibusz

  • Prime Member
  • ****
  • Posts: 167
  • Karma: +17/-2
free mini shoutbox etano 1.23 facebook style
« on: August 05, 2014, 03:07:27 AM »


1. create database table .

Code: [Select]
CREATE TABLE IF NOT EXISTS `dsb_shout_box` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user` varchar(60) NOT NULL,
  `message` varchar(100) NOT NULL,
  `date_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `ip_address` varchar(40) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

2.create shout.php root folder :

Code: [Select]
<?php
####### db config ##########
$db_username 'etano';
$db_password '111111';
$db_name 'etano';
$db_host 'localhost';
####### db config end ##########

if($_POST)
{
//connect to mysql db
$sql_con mysqli_connect($db_host$db_username$db_password,$db_name)or die('could not connect to database');

//check if its an ajax request, exit if not
    
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
        die();
    } 

if(isset($_POST["message"]) &&  strlen($_POST["message"])>0)
{
//sanitize user name and message received from chat box
//You can replace username with registerd username, if only registered users are allowed.
$username filter_var(trim($_POST["username"]),FILTER_SANITIZE_STRINGFILTER_FLAG_STRIP_LOW FILTER_FLAG_STRIP_HIGH);
$message filter_var(trim($_POST["message"]),FILTER_SANITIZE_STRINGFILTER_FLAG_STRIP_LOW FILTER_FLAG_STRIP_HIGH);
$user_ip $_SERVER['REMOTE_ADDR'];


//insert new message in db
if(mysqli_query($sql_con,"INSERT INTO dsb_shout_box(user, message, ip_address) value('$username','$message','$user_ip')"))
{
$msg_time date('h:i A M d',time()); // current time
echo '<div class="shout_msg"><time>'.$msg_time.'</time><span class="username">'.$username.'</span><span class="message">'.$message.'</span></div>';
}

// delete all records except last 10, if you don't want to grow your db size!
mysqli_query($sql_con,"DELETE FROM dsb_shout_box WHERE id NOT IN (SELECT * FROM (SELECT id FROM dsb_shout_box ORDER BY id DESC LIMIT 0, 10) as sb)");
}
elseif($_POST["fetch"]==1)
{
$results mysqli_query($sql_con,"SELECT user, message, date_time FROM (select * from dsb_shout_box ORDER BY id DESC LIMIT 10) dsb_shout_box ORDER BY dsb_shout_box.id ASC");
while($row mysqli_fetch_array($results))
{
$msg_time date('h:i A M d',strtotime($row["date_time"])); //message posted time
echo '<div class="shout_msg"><time>'.$msg_time.'</time><span class="username">'.$row["user"].'</span> <span class="message">'.$row["message"].'</span></div>';
}
}
else
{
header('HTTP/1.1 500 Are you kiddin me?');
    
exit();
}
}

csibusz

  • Prime Member
  • ****
  • Posts: 167
  • Karma: +17/-2
Re: free mini shoutbox etano 1.23 facebook style
« Reply #1 on: August 05, 2014, 03:08:10 AM »
3. root folder/js create jquery-1.9.0.min.js :

faxxxx

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: free mini shoutbox etano 1.23 facebook style
« Reply #2 on: August 12, 2014, 02:31:54 AM »
Hi csibusz
can you explain better point nr. 3?

csibusz

  • Prime Member
  • ****
  • Posts: 167
  • Karma: +17/-2
Re: free mini shoutbox etano 1.23 facebook style
« Reply #3 on: August 15, 2014, 01:43:39 AM »
Full install tutorial install.txt :

http://tattooandlove.com/install.txt

libritario

  • Confirmed Member
  • **
  • Posts: 7
  • Karma: +0/-0
Re: free mini shoutbox etano 1.23 facebook style
« Reply #4 on: August 15, 2014, 10:45:05 AM »
I did it and look nice,  can you implement a link on username to click and open new private shoutbox with this user ?
Thanks for share.

acei7una

  • Confirmed Member
  • **
  • Posts: 17
  • Karma: +0/-0
Re: free mini shoutbox etano 1.23 facebook style
« Reply #5 on: September 08, 2014, 08:10:00 AM »
It may sounds like a noob question. But its because i am a noob!  :P

In step 2. When you create the .php and you add the db information... Is it possible that someone can read that information? Because it is in the public folder. I think that php files can not be read. But I'm a noob so I have to ask. I don't want to put that info if someone is able to read it in some way. Just asking.
Thanks!!