<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Script Tutorials &#187; jQuery | Script Tutorials | Web development</title> <atom:link href="http://www.script-tutorials.com/category/jquery/feed/" rel="self" type="application/rss+xml" /><link>http://www.script-tutorials.com</link> <description>Tutorials for Web Developers</description> <lastBuildDate>Fri, 03 Feb 2012 06:07:51 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Powerful Chat System &#8211; Lesson 3</title><link>http://www.script-tutorials.com/powerful-chat-system-lesson-3/</link> <comments>http://www.script-tutorials.com/powerful-chat-system-lesson-3/#comments</comments> <pubDate>Mon, 30 Jan 2012 17:01:39 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[HTML5]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[ajax chat]]></category> <category><![CDATA[chat]]></category> <category><![CDATA[chat system]]></category> <category><![CDATA[registration]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1396</guid> <description><![CDATA[Powerful Chat System &#8211; Lesson 3 Today we continue a series of articles on the creation of powerful chat system. Our third lesson will contain next elements: join form (with html5 validation). A long ago, I have already made similar validation. So you can refresh your memories if you like. Today I will publish updated [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-2/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/221/thumb.png" alt="Powerful Chat System &#8211; Lesson 2" /> Powerful Chat System &#8211; Lesson 2</a></li><li> <a
href="http://www.script-tutorials.com/powerful-chat-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/218/thumb.png" alt="Powerful Chat System" /> Powerful Chat System</a></li><li> <a
href="http://www.script-tutorials.com/how-to-easily-make-ajax-style-php-chat-application/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="How to Easily Make AJAX Style PHP Chat Application" /> How to Easily Make AJAX Style PHP Chat Application</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Powerful Chat System" alt="Powerful Chat System" src="http://www.script-tutorials.com/demos/226/thumb.png"></div><p><strong>Powerful Chat System &#8211; Lesson 3</strong><br
/> <br
/>Today we continue a series of articles on the creation of powerful chat system. Our third lesson will contain next elements: join form (with html5 validation). A long ago, I have already made similar <a
target="_blank" href="http://www.script-tutorials.com/data-validation-html5/">validation</a>. So you can refresh your memories if you like.<br
/> <span
id="more-1396"></span></p><p>Today I will publish updated sources of our growing project (several files was modified, plus I expanded structure of database slightly). All project is well structured: system classes is in &#8216;classes&#8217; folder, stylesheets in &#8216;css&#8217; folder, template files in &#8216;templates&#8217; folder, and &#8211; new folder &#8216;js&#8217; for javascript files.</p><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - demo 226" href="http://www.script-tutorials.com/demos/226/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - package" href="http://www.script-tutorials.com/demos/226/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Now &#8211; download the source files and lets start coding !</p><hr
/><h3>Step 1. SQL</h3><p>I have added new field into table of profiles where we will store its first names. So, please execute next SQL:</p><pre class="brush:sql">
ALTER TABLE `cs_profiles` ADD `first_name` varchar(255) NOT NULL default '' AFTER `name`;
</pre><h3>Step 2. HTML</h3><p>I have updated template with login form. As you can see &#8211; I have expanded this markup and added join form here:</p><h4>templates/logout_form.html</h4><pre class="brush:html">
&lt;div class=&quot;column&quot;&gt;
    &lt;h3&gt;Powerful Chat System Demonstration&lt;/h3&gt;
    &lt;p&gt;Our chat will contain next features: registration, main chat, profiles with avatars, ranking system, private messaging, custom rooms, moderation / administration and possible something else (in future).&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;column&quot;&gt;

    &lt;div class=&quot;tabs_container&quot;&gt;
        &lt;ul class=&quot;tabs&quot;&gt;
            &lt;li class=&quot;active&quot;&gt;&lt;h3&gt;Log In&lt;/h3&gt;&lt;/li&gt;
            &lt;li&gt;&lt;h3&gt;Join&lt;/h3&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;

    &lt;div class=&quot;nav_container&quot;&gt;
        &lt;form class=&quot;login_form&quot; action=&quot;index.php&quot; method=&quot;post&quot; id=&quot;1&quot;&gt;
            &lt;label&gt;Username:&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;username&quot;&gt;
            &lt;label&gt;Password:&lt;/label&gt;&lt;input type=&quot;password&quot; name=&quot;password&quot;&gt;
            &lt;input type=&quot;submit&quot; name=&quot;Login&quot; value=&quot;Login&quot;&gt;
        &lt;/form&gt;
        &lt;form class=&quot;join_form&quot; action=&quot;index.php&quot; method=&quot;post&quot; id=&quot;2&quot; style=&quot;display: none;&quot;&gt;

            &lt;label&gt;Full name:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;username&quot; name=&quot;username&quot; placeholder=&quot;Your name&quot; maxlength=&quot;128&quot; title=&quot;Your name&quot; required&gt;

            &lt;label&gt;First name:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;firstname&quot; name=&quot;firstname&quot; placeholder=&quot;Your first name&quot; maxlength=&quot;128&quot; title=&quot;Your first name&quot;&gt;

            &lt;label&gt;Last name:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;lastname&quot; name=&quot;lastname&quot; placeholder=&quot;Your last name&quot; maxlength=&quot;128&quot; title=&quot;Your last name&quot;&gt;

            &lt;label&gt;Email:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;email&quot; name=&quot;email&quot; placeholder=&quot;Your email&quot; maxlength=&quot;128&quot; title=&quot;Format: *@gmail.com&quot; pattern=&quot;.*@gmail\.com&quot; required&gt;

            &lt;label&gt;Password:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;password&quot; name=&quot;password&quot; maxlength=&quot;128&quot; title=&quot;Password&quot; required&gt;

            &lt;label&gt;Repeat Password:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;password&quot; name=&quot;password&quot; maxlength=&quot;128&quot; title=&quot;Repeat password&quot; required oninput=&quot;checkpass(this)&quot;&gt;

            &lt;input type=&quot;submit&quot; name=&quot;Join&quot; value=&quot;Join&quot;&gt;
        &lt;/form&gt;
    &lt;/div&gt;

&lt;/div&gt;

&lt;script&gt;
$(document).ready(function(){
    $('.tabs li h3').click(function () {
      $('.tabs li').removeClass('active');
      $(this).parent().addClass('active');

      $('.nav_container form').hide();
      var index = $('.tabs li h3').index(this);
      $('.nav_container form').eq(index).show();
      return false;
    });
});

function checkpass(input) {
    if (input.value != document.getElementById('password').value) {
        input.setCustomValidity('Password must match.');
    } else {
        input.setCustomValidity('');
    }
}
&lt;/script&gt;
</pre><p>Please pay attention to HTML structure of join form, it contain several new attributes for html5 validation: placeholder, required and pattern. This is pretty interesting.</p><h3>Step 3. CSS</h3><p>This file has updated too</p><h4>css/main.css</h4><pre class="brush:html">
/* page layout */
*{
    margin:0;
    padding:0;
}
body {
    background-color:#eee;
    color:#fff;
    font:14px/1.3 Arial,sans-serif;
}
header {
    background-color:#212121;
    box-shadow: 0 -1px 2px #111111;
    display:block;
    height:70px;
    position:relative;
    width:100%;
    z-index:100;
}
header h2{
    font-size:22px;
    font-weight:normal;
    left:50%;
    margin-left:-400px;
    padding:22px 0;
    position:absolute;
    width:540px;
}
header a.stuts,a.stuts:visited{
    border:none;
    text-decoration:none;
    color:#fcfcfc;
    font-size:14px;
    left:50%;
    line-height:31px;
    margin:23px 0 0 110px;
    position:absolute;
    top:0;
}
header .stuts span {
    font-size:22px;
    font-weight:bold;
    margin-left:5px;
}

/* main styles */
.container {
    background-color: #222;
    color: #bbb;
    margin: 20px auto;
    overflow: hidden;
    padding: 20px;
    position: relative;
    width: 800px;
}
.container h2 {
    color: #fff;
    margin-bottom: 10px;
}
.column {
    float: left;
    width: 48%;
}
.column:first-child {
    margin-right: 4%;
}
.column &gt; * {
    color: #ddd;
    margin-bottom: 10px;
}

/* tabs section */
.tabs_container {
    margin: 0;
}
.tabs {
    overflow: hidden;
}
.tabs li {
    float: left;
    list-style: none;
}
.tabs li h3:first-child {
    margin-left: 10px
}
.tabs li h3 {
    border: 1px solid #ddd;
    border-bottom-width: 0;
    display: block;
    margin: 0 2px 0 0;
    padding: 6px 10px 4px
}
.tabs li.active h3 {
    background-color: #555;
    border: 1px solid #ddd;
    border-bottom-width: 0;

    -moz-border-radius: 4px 4px 0 0;
    -ms-border-radius: 4px 4px 0 0;
    -o-border-radius: 4px 4px 0 0;
    -webkit-border-radius: 4px 4px 0 0;
    border-radius: 4px 4px 0 0;
}
.tabs li h3:hover {
    background-color: #666;
    cursor: pointer;
}
.tabs li.active h3:hover {
    background-color: #555;
    cursor: normal;
}
.nav_container form {
    background-color: #555;
    display: block;
    padding: 15px;
}
.column h3 {
    color: #fff;
}
.login_form input,.login_form label,
.join_form input,.join_form label {
    display: block;
    margin-bottom: 10px;
}
input[type=text], input[type=password], input[type=submit] {
    -moz-border-radius: 5px;
    -ms-border-radius: 5px;
    -o-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}
input[type=text], input[type=password] {
    font-size: 16px;
    height: 25px;
    margin-right: 10px;
    width: 200px;
}
input[type=submit]{
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    height: 35px;
    padding: 5px;
}

/* chat block */
.chat_messages {
    border: 1px solid #888;
    box-shadow: 0 0 5px #AAA;
    color: #000;
    padding: 10px;
}
.chat_messages h2 {
    color: #fff;
}
.chat_messages .message {
    background-color: #fff;
    margin: 5px;
    padding: 5px;

    -moz-border-radius: 5px;
    -ms-border-radius: 5px;
    -o-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}
.chat_messages .message span {
    color: #444;
    font-size: 10px;
    margin-left: 10px;
}
.chat_submit_form {
    margin: 10px 0px;
}
.chat_submit_form div {
    float: left;
    width: 49%;
}
.chat_submit_form .error, .chat_submit_form .success, .chat_submit_form .protect {
    display: none;
}
.chat_submit_form .error {
    color: #f55;
}
.chat_submit_form .success {
    color: #5f5;
}
.chat_submit_form .protect {
    color: #55f;
}
</pre><h3>Step 4. PHP</h3><p>Now, lets review php sources. Our index.php file has updated. I have added here join processing functional. Before actual joining, we have to check if someone else was joined with same email (this field should be unique of course)</p><h4>index.php</h4><pre class="brush:php">
&lt;?php

// set error reporting level
if (version_compare(phpversion(), '5.3.0', '&gt;=') == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE);

require_once('classes/Services_JSON.php');
require_once('classes/CMySQL.php'); // including service class to work with database
require_once('classes/CLogin.php'); // including service class to work with login processing

$sErrors = '';
// join processing
if (! isset($_SESSION['member_id']) &amp;&amp; $_POST['Join'] == 'Join') {
    $sUsername = $GLOBALS['MySQL']-&gt;escape($_POST['username']);
    $sFirstname = $GLOBALS['MySQL']-&gt;escape($_POST['firstname']);
    $sLastname = $GLOBALS['MySQL']-&gt;escape($_POST['lastname']);
    $sEmail = $GLOBALS['MySQL']-&gt;escape($_POST['email']);
    $sPassword = $GLOBALS['MySQL']-&gt;escape($_POST['password']);

    if ($sUsername &amp;&amp; $sEmail &amp;&amp; $sPassword) {
        // check if already exist
        $aProfile = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `cs_profiles` WHERE `email`='{$sEmail}'&quot;);
        if ($aProfile['id'] &gt; 0) {
            $sErrors = '&lt;h2&gt;Another profile with same email already exist&lt;/h2&gt;';
        } else {
            // generate Salt and Cached password
            $sSalt = 'testing'; // TODO - we will add generation of salt in future
            $sPass = sha1(md5($sPassword) . $sSalt);

            // add new member into database
            $sSQL = &quot;
                INSERT INTO `cs_profiles` SET
                `name` = '{$sUsername}',
                `first_name` = '{$sFirstname}',
                `last_name` = '{$sLastname}',
                `email` = '{$sEmail}',
                `password` = '{$sPass}',
                `salt` = '{$sSalt}',
                `status` = 'active',
                `role` = '1',
                `date_reg` = NOW();
            &quot;;
            $GLOBALS['MySQL']-&gt;res($sSQL);

            // autologin
            $GLOBALS['CLogin']-&gt;performLogin($sUsername, $sPassword);
        }
    }
}

// login system init and generation code
$sLoginForm = $GLOBALS['CLogin']-&gt;getLoginBox();

$sChat = '&lt;h2&gt;You do not have rights to use chat&lt;/h2&gt;';
$sInput = '';
if ($_SESSION['member_id'] &amp;&amp; $_SESSION['member_status'] == 'active' &amp;&amp; $_SESSION['member_role']) {
    require_once('classes/CChat.php'); // including service class to work with chat

    // get last messages
    $sChat = $GLOBALS['MainChat']-&gt;getMessages();
    if ($_GET['action'] == 'get_last_messages') { // regular updating of messages in chat
        $oJson = new Services_JSON();
        header('Content-type: application/json');
        echo $oJson-&gt;encode(array('messages' =&gt; $sChat));
        exit;
    }

    // get input form
    $sInput = $GLOBALS['MainChat']-&gt;getInputForm();

    if ($_POST['message']) { // POST-ing of message
        $iRes = $GLOBALS['MainChat']-&gt;acceptMessage();

        $oJson = new Services_JSON();
        header('Content-type: application/json');
        echo $oJson-&gt;encode(array('result' =&gt; $iRes));
        exit;
    }
}

// draw common page
echo strtr(file_get_contents('templates/main_page.html'), array('{form}' =&gt; $sLoginForm . $sErrors, '{chat}' =&gt; $sChat, '{input}' =&gt; $sInput));
</pre><p>As you can see &#8211; I have added chat functionality today.</p><h4>classes/CLogin.php</h4><pre class="brush:php">
&lt;?php

class CLogin {

    // constructor
    function CLogin() {
        session_start();
    }

    // get login box function
    function getLoginBox() {
        if (isset($_GET['logout'])) { // logout processing
            if (isset($_SESSION['member_name']) &amp;&amp; isset($_SESSION['member_pass']))
                $this-&gt;performLogout();
        }

        if ($_POST &amp;&amp; $_POST['Login'] == 'Login' &amp;&amp; $_POST['username'] &amp;&amp; $_POST['password']) { // login processing
            if ($this-&gt;checkLogin($_POST['username'], $_POST['password'], false)) { // successful login
                $this-&gt;performLogin($_POST['username'], $_POST['password']);
                header( &quot;Location:{$_SERVER['REQUEST_URI']}&quot; );
                exit;
            } else { // wrong login
                return file_get_contents('templates/login_form.html') . '&lt;h2&gt;Username or Password is incorrect&lt;/h2&gt;';
            }
        } else { // in case if we already logged (on refresh page):
            if (isset($_SESSION['member_name']) &amp;&amp; $_SESSION['member_name'] &amp;&amp; $_SESSION['member_pass']) {
                $aReplaces = array(
                    '{name}' =&gt; $_SESSION['member_name'],
                    '{status}' =&gt; $_SESSION['member_status'],
                    '{role}' =&gt; $_SESSION['member_role'],
                );
                return strtr(file_get_contents('templates/logout_form.html'), $aReplaces);
            }

            // otherwise - draw login form
            return file_get_contents('templates/login_form.html');
        }
    }

    // perform login
    function performLogin($sName, $sPass) {
        $this-&gt;performLogout();

        // make variables safe
        $sName = $GLOBALS['MySQL']-&gt;escape($sName);

        $aProfile = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `cs_profiles` WHERE `name`='{$sName}'&quot;);
        // $sPassEn = $aProfile['password'];
        $iPid = $aProfile['id'];
        $sSalt = $aProfile['salt'];
        $sStatus = $aProfile['status'];
        $sRole = $aProfile['role'];

        $sPass = sha1(md5($sPass) . $sSalt);

        $_SESSION['member_id'] = $iPid;
        $_SESSION['member_name'] = $sName;
        $_SESSION['member_pass'] = $sPass;
        $_SESSION['member_status'] = $sStatus;
        $_SESSION['member_role'] = $sRole;
    }

    // perform logout
    function performLogout() {
        unset($_SESSION['member_id']);
        unset($_SESSION['member_name']);
        unset($_SESSION['member_pass']);
        unset($_SESSION['member_status']);
        unset($_SESSION['member_role']);
    }

    // check login
    function checkLogin($sName, $sPass, $isHash = true) {
        // make variables safe
        $sName = $GLOBALS['MySQL']-&gt;escape($sName);
        $sPass = $GLOBALS['MySQL']-&gt;escape($sPass);

        $aProfile = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `cs_profiles` WHERE `name`='{$sName}'&quot;);
        $sPassEn = $aProfile['password'];

        if ($sName &amp;&amp; $sPass &amp;&amp; $sPassEn) {
            if (! $isHash) {
                $sSalt = $aProfile['salt'];
                $sPass = sha1(md5($sPass) . $sSalt);
            }
            return ($sPass == $sPassEn);
        }
        return false;
    }
}

$GLOBALS['CLogin'] = new CLogin();
</pre><p>Minor changes were made in this file too. The rest of the functional was not changed. We will continue enhance our chat soon.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - demo 226" href="http://www.script-tutorials.com/demos/226/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - package" href="http://www.script-tutorials.com/demos/226/source.zip" target="_blank" rel="nofollow">download in archive</a></strong></h5><hr
/><h3>Conclusion</h3><p>I hope that our new series of articles of chat system creation is useful and interesting for you. If you want to share your ideas, or you noticed any weakness &#8211; don&#8217;t hesitate to contact us. Good luck and welcome back!</p><div
class="shr-publisher-1396"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-2/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/221/thumb.png" alt="Powerful Chat System &#8211; Lesson 2" /> <br
/> Powerful Chat System &#8211; Lesson 2</a></li><li> <a
href="http://www.script-tutorials.com/powerful-chat-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/218/thumb.png" alt="Powerful Chat System" /> <br
/> Powerful Chat System</a></li><li> <a
href="http://www.script-tutorials.com/how-to-easily-make-ajax-style-php-chat-application/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="How to Easily Make AJAX Style PHP Chat Application" /> <br
/> How to Easily Make AJAX Style PHP Chat Application</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/powerful-chat-system-lesson-3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Powerful Chat System &#8211; Lesson 2</title><link>http://www.script-tutorials.com/powerful-chat-system-lesson-2/</link> <comments>http://www.script-tutorials.com/powerful-chat-system-lesson-2/#comments</comments> <pubDate>Wed, 18 Jan 2012 17:17:45 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[ajax chat]]></category> <category><![CDATA[chat]]></category> <category><![CDATA[chat system]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1373</guid> <description><![CDATA[Powerful Chat System &#8211; Lesson 2 Today we continue a series of articles on the creation of powerful chat system. Our second lesson will contain next elements: smart chat (ajax, with spam filtering &#8211; protection from the frequent messages). I have decided to make registration for next lesson. Hope that it is ok for you. [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-3/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/226/thumb.png" alt="Powerful Chat System &#8211; Lesson 3" /> Powerful Chat System &#8211; Lesson 3</a></li><li> <a
href="http://www.script-tutorials.com/powerful-chat-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/218/thumb.png" alt="Powerful Chat System" /> Powerful Chat System</a></li><li> <a
href="http://www.script-tutorials.com/how-to-easily-make-ajax-style-php-chat-application/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="How to Easily Make AJAX Style PHP Chat Application" /> How to Easily Make AJAX Style PHP Chat Application</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Powerful Chat System" alt="Powerful Chat System" src="http://www.script-tutorials.com/demos/221/thumb.png"></div><p><strong>Powerful Chat System &#8211; Lesson 2</strong><br
/> <br
/>Today we continue a series of articles on the creation of powerful chat system. Our second lesson will contain next elements: smart chat (ajax, with spam filtering &#8211; protection from the frequent messages). I have decided to make registration for next lesson. Hope that it is ok for you.<br
/> <span
id="more-1373"></span></p><p>Today I have included next elements: chat processor, plus &#8211; slight corrections in our previous sources. All project is well structured: system classes is in &#8216;classes&#8217; folder, stylesheets in &#8216;css&#8217; folder, template files in &#8216;templates&#8217; folder, and &#8211; new folder &#8216;js&#8217; for javascript files.</p><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - demo 221" href="http://www.script-tutorials.com/demos/221/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - package" href="http://www.script-tutorials.com/demos/221/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Now &#8211; download the source files and lets start coding !</p><hr
/><h3>Step 1. SQL</h3><p>This table has got minor changes. I have changed type of field &#8216;when&#8217;.</p><pre class="brush:sql">
CREATE TABLE `cs_messages` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sender` int(11) unsigned NOT NULL,
  `recipient` int(11) unsigned NOT NULL default '0',
  `message` VARCHAR(255) NOT NULL,
  `when` int(11) NOT NULL default '0',
  `room` int(5) unsigned NOT NULL default '0',
  `type` tinyint(1) unsigned NOT NULL default '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
</pre><h3>Step 2. HTML</h3><p>This is main (index) page html markup:</p><h4>templates/main_page.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
&lt;head&gt;
    &lt;title&gt;Powerful Chat System - Lesson 2&lt;/title&gt;
    &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
    &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;h2&gt;Powerful Chat System - Lesson 2&lt;/h2&gt;
        &lt;a href=&quot;http://www.script-tutorials.com/powerful-chat-system-lesson-2/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
    &lt;/header&gt;
    &lt;div class=&quot;container&quot;&gt;
        {form}
    &lt;/div&gt;
    &lt;div class=&quot;container&quot;&gt;
        &lt;h2&gt;Main Chat Block&lt;/h2&gt;
        &lt;div class=&quot;chat_messages&quot;&gt;
            {chat}
        &lt;/div&gt;
        {input}
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre><p>As you can see &#8211; I have changed our second container (which contains our ajax chat).</p><h4>templates/login_form.html and templates/logout_form.html</h4><p>These files haven&#8217;t changed since last time. Next one new template &#8211; chat form:</p><h4>templates/chat.html</h4><pre class="brush:html">
&lt;form class=&quot;chat_submit_form&quot;&gt;
    &lt;div&gt;&lt;input type=&quot;text&quot; name=&quot;message&quot; /&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;Submit&quot; /&gt;&lt;/div&gt;
    &lt;div&gt;
        &lt;h3 class=&quot;error&quot;&gt;Some error occurs during sending message&lt;/h3&gt;
        &lt;h3 class=&quot;success&quot;&gt;Message successfully sent&lt;/h3&gt;
        &lt;h3 class=&quot;protect&quot;&gt;Please wait 5 secs before adding next message&lt;/h3&gt;
    &lt;/div&gt;
&lt;/form&gt;
&lt;script src=&quot;js/chat.js&quot;&gt;&lt;/script&gt;
</pre><h3>Step 3. CSS</h3><p>This file contains updated styles of our chat</p><h4>css/main.css</h4><pre class="brush:html">
/* page layout */
*{
    margin:0;
    padding:0;
}
body {
    background-color:#eee;
    color:#fff;
    font:14px/1.3 Arial,sans-serif;
}
header {
    background-color:#212121;
    box-shadow: 0 -1px 2px #111111;
    display:block;
    height:70px;
    position:relative;
    width:100%;
    z-index:100;
}
header h2{
    font-size:22px;
    font-weight:normal;
    left:50%;
    margin-left:-400px;
    padding:22px 0;
    position:absolute;
    width:540px;
}
header a.stuts,a.stuts:visited{
    border:none;
    text-decoration:none;
    color:#fcfcfc;
    font-size:14px;
    left:50%;
    line-height:31px;
    margin:23px 0 0 110px;
    position:absolute;
    top:0;
}
header .stuts span {
    font-size:22px;
    font-weight:bold;
    margin-left:5px;
}

/* main styles */
.container {
    background-color: #222;
    color: #bbb;
    margin: 20px auto;
    overflow: hidden;
    padding: 20px;
    position: relative;
    width: 800px;
}
.container h2 {
    color: #fff;
    margin-bottom: 10px;
}
.column {
    float: left;
    width: 48%;
}
.column:first-child {
    margin-right: 4%;
}
.column &gt; * {
    color: #ddd;
    margin-bottom: 10px;
}
.column h3 {
    color: #fff;
}
.login_form input,.login_form label {
    display: block;
    margin-bottom: 10px;
}
input[type=text], input[type=password], input[type=submit] {
    -moz-border-radius: 5px;
    -ms-border-radius: 5px;
    -o-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}
input[type=text], input[type=password] {
    font-size: 16px;
    height: 30px;
    margin-right: 10px;
    width: 200px;
}
input[type=submit]{
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    height: 35px;
    padding: 5px;
}

/* chat block */
.chat_messages {
    border: 1px solid #888;
    box-shadow: 0 0 5px #AAA;
    color: #000;
    padding: 10px;
}
.chat_messages h2 {
    color: #fff;
}
.chat_messages .message {
    background-color: #fff;
    margin: 5px;
    padding: 5px;

    -moz-border-radius: 5px;
    -ms-border-radius: 5px;
    -o-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}
.chat_messages .message span {
    color: #444;
    font-size: 10px;
    margin-left: 10px;
}
.chat_submit_form {
    margin: 10px 0px;
}
.chat_submit_form div {
    float: left;
    width: 49%;
}
.chat_submit_form .error, .chat_submit_form .success, .chat_submit_form .protect {
    display: none;
}
.chat_submit_form .error {
    color: #f55;
}
.chat_submit_form .success {
    color: #5f5;
}
.chat_submit_form .protect {
    color: #55f;
}
</pre><h3>Step 4. JS</h3><p>I have created first JS for our chat. At beginning &#8211; it contain one function for regular obtaining messages, and handler of form submitting.</p><h4>js/chat.js</h4><pre class="brush:js">
$(function() {
    getMessages = function() {
        $.getJSON('index.php?action=get_last_messages', function(data){
            if (data.messages) {
                $('.chat_messages').html(data.messages);
            }

            // get recent chat messages in loop
            setTimeout(function(){
               getMessages();
            }, 5000);
        });
    }
    getMessages();

    $('.chat_submit_form').submit(function() {
        $.post('index.php', { message: $('.chat_submit_form input[name=message]').val() },
            function(data){
                if (data.result == 1) {
                    $('.chat_submit_form .success').fadeIn('slow', function () {
                        $(this).delay(1000).fadeOut('slow');
                    });
                } else if (data.result == 2) {
                    $('.chat_submit_form .protect').fadeIn('slow', function () {
                        $(this).delay(1000).fadeOut('slow');
                    });
                } else {
                    $('.chat_submit_form .error').fadeIn('slow', function () {
                        $(this).delay(1000).fadeOut('slow');
                    });
                }
            }
        );
        return false;
    });
});
</pre><h3>Step 5. PHP</h3><p>Now, lets review php sources:</p><h4>index.php</h4><pre class="brush:php">
&lt;?php

// set error reporting level
if (version_compare(phpversion(), '5.3.0', '&gt;=') == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE);

require_once('classes/Services_JSON.php');
require_once('classes/CMySQL.php'); // including service class to work with database
require_once('classes/CLogin.php'); // including service class to work with login processing

// login system init and generation code
$sLoginForm = $GLOBALS['CLogin']-&gt;getLoginBox();

$sChat = '&lt;h2&gt;You do not have rights to use chat&lt;/h2&gt;';
$sInput = '';
if ($_SESSION['member_id'] &amp;&amp; $_SESSION['member_status'] == 'active' &amp;&amp; $_SESSION['member_role']) {
    require_once('classes/CChat.php'); // including service class to work with chat

    // get last messages
    $sChat = $GLOBALS['MainChat']-&gt;getMessages();
    if ($_GET['action'] == 'get_last_messages') { // regular updating of messages in chat
        $oJson = new Services_JSON();
        header('Content-type: application/json');
        echo $oJson-&gt;encode(array('messages' =&gt; $sChat));
        exit;
    }

    // get input form
    $sInput = $GLOBALS['MainChat']-&gt;getInputForm();

    if ($_POST['message']) { // POST-ing of message
        $iRes = $GLOBALS['MainChat']-&gt;acceptMessage();

        $oJson = new Services_JSON();
        header('Content-type: application/json');
        echo $oJson-&gt;encode(array('result' =&gt; $iRes));
        exit;
    }
}

// draw common page
echo strtr(file_get_contents('templates/main_page.html'), array('{form}' =&gt; $sLoginForm, '{chat}' =&gt; $sChat, '{input}' =&gt; $sInput));
</pre><p>As you can see &#8211; I have added chat functionality today.</p><h4>classes/CLogin.php</h4><pre class="brush:php">
&lt;?php

class CLogin {

    // constructor
    function CLogin() {
        session_start();
    }

    // get login box function
    function getLoginBox() {
        if (isset($_GET['logout'])) { // logout processing
            if (isset($_SESSION['member_name']) &amp;&amp; isset($_SESSION['member_pass']))
                $this-&gt;performLogout();
        }

        if ($_POST &amp;&amp; $_POST['username'] &amp;&amp; $_POST['password']) { // login processing
            if ($this-&gt;checkLogin($_POST['username'], $_POST['password'], false)) { // successful login
                $this-&gt;performLogin($_POST['username'], $_POST['password']);
                header( &quot;Location:{$_SERVER['REQUEST_URI']}&quot; );
                exit;
            } else { // wrong login
                return file_get_contents('templates/login_form.html') . '&lt;h2&gt;Username or Password is incorrect&lt;/h2&gt;';
            }
        } else { // in case if we already logged (on refresh page):
            if (isset($_SESSION['member_name']) &amp;&amp; $_SESSION['member_name'] &amp;&amp; $_SESSION['member_pass']) {
                $aReplaces = array(
                    '{name}' =&gt; $_SESSION['member_name'],
                    '{status}' =&gt; $_SESSION['member_status'],
                    '{role}' =&gt; $_SESSION['member_role'],
                );
                return strtr(file_get_contents('templates/logout_form.html'), $aReplaces);
            }

            // otherwise - draw login form
            return file_get_contents('templates/login_form.html');
        }
    }

    // perform login
    function performLogin($sName, $sPass) {
        $this-&gt;performLogout();

        // make variables safe
        $sName = $GLOBALS['MySQL']-&gt;escape($sName);

        $aProfile = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `cs_profiles` WHERE `name`='{$sName}'&quot;);
        // $sPassEn = $aProfile['password'];
        $iPid = $aProfile['id'];
        $sSalt = $aProfile['salt'];
        $sStatus = $aProfile['status'];
        $sRole = $aProfile['role'];

        $sPass = sha1(md5($sPass) . $sSalt);

        $_SESSION['member_id'] = $iPid;
        $_SESSION['member_name'] = $sName;
        $_SESSION['member_pass'] = $sPass;
        $_SESSION['member_status'] = $sStatus;
        $_SESSION['member_role'] = $sRole;
    }

    // perform logout
    function performLogout() {
        unset($_SESSION['member_id']);
        unset($_SESSION['member_name']);
        unset($_SESSION['member_pass']);
        unset($_SESSION['member_status']);
        unset($_SESSION['member_role']);
    }

    // check login
    function checkLogin($sName, $sPass, $isHash = true) {
        // make variables safe
        $sName = $GLOBALS['MySQL']-&gt;escape($sName);
        $sPass = $GLOBALS['MySQL']-&gt;escape($sPass);

        $aProfile = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `cs_profiles` WHERE `name`='{$sName}'&quot;);
        $sPassEn = $aProfile['password'];

        if ($sName &amp;&amp; $sPass &amp;&amp; $sPassEn) {
            if (! $isHash) {
                $sSalt = $aProfile['salt'];
                $sPass = sha1(md5($sPass) . $sSalt);
            }
            return ($sPass == $sPassEn);
        }
        return false;
    }
}

$GLOBALS['CLogin'] = new CLogin();
</pre><p>This class is updated too. I have decided to add &#8216;member_id&#8217; in sessions too. It will useful afterward.</p><h4>classes/CMySQL.php</h4><p>This is database service class. Available in package. Pay attention &#8211; database settings of our project is in this file.</p><h4>classes/Services_JSON.php</h4><p>This is JSON service class. Available in package.</p><h4>classes/CChat.php</h4><pre class="brush:php">
&lt;?php

class CChat {

    // constructor
    function CChat() {}

    // add to DB message
    function acceptMessage() {
        $sName = $GLOBALS['MySQL']-&gt;escape($_SESSION['member_name']);
        $iPid = (int)$_SESSION['member_id'];
        $sMessage = $GLOBALS['MySQL']-&gt;escape($_POST['message']);

        if ($iPid &amp;&amp; $sName != '' &amp;&amp; $sMessage != '') {
            $sSQL = &quot;
                SELECT `id`
                FROM `cs_messages`
                WHERE `sender` = '{$iPid}' AND UNIX_TIMESTAMP( ) - `when` &lt; 5
                LIMIT 1
            &quot;;
            $iLastId = $GLOBALS['MySQL']-&gt;getOne($sSQL);
            if ($iLastId) return 2; // as protection from very often messages

            $bRes = $GLOBALS['MySQL']-&gt;res(&quot;INSERT INTO `cs_messages` SET `sender` = '{$iPid}', `message` = '{$sMessage}', `when` = UNIX_TIMESTAMP()&quot;);
            return ($bRes) ? 1 : 3;
        }
    }

    // return input text form
    function getInputForm() {
        return file_get_contents('templates/chat.html');
    }

    // get last 10 messages
    function getMessages() {
        $sSQL = &quot;
            SELECT `a` . * , `cs_profiles`.`name` , UNIX_TIMESTAMP( ) - `a`.`when` AS 'diff'
            FROM `cs_messages` AS `a`
            INNER JOIN `cs_profiles` ON `cs_profiles`.`id` = `a`.`sender`
            ORDER BY `a`.`id` DESC
            LIMIT 10
        &quot;;
        $aMessages = $GLOBALS['MySQL']-&gt;getAll($sSQL);
        asort($aMessages);

        // create list of messages
        $sMessages = '';
        foreach ($aMessages as $i =&gt; $aMessage) {
            $sExStyles = $sExJS = '';
            $iDiff = (int)$aMessage['diff'];
            if ($iDiff &lt; 7) { // less than 7 seconds
                $sExStyles = 'style=&quot;display:none;&quot;';
                $sExJS = &quot;&lt;script&gt; $('#message_{$aMessage['id']}').fadeIn('slow'); &lt;/script&gt;&quot;;
            }

            $sWhen = date(&quot;H:i:s&quot;, $aMessage['when']);
            $sMessages .= '&lt;div class=&quot;message&quot; id=&quot;message_'.$aMessage['id'].'&quot; '.$sExStyles.'&gt;&lt;b&gt;' . $aMessage['name'] . ':&lt;/b&gt; ' . $aMessage['message'] . '&lt;span&gt;(' . $sWhen . ')&lt;/span&gt;&lt;/div&gt;' . $sExJS;
        }
        return $sMessages;
    }
}

$GLOBALS['MainChat'] = new CChat();
</pre><p>This is our new class for chat processor. For now &#8211; it contain only 3 functions: acceptMessage, getInputForm and getMessages.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - demo 221" href="http://www.script-tutorials.com/demos/221/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - package" href="http://www.script-tutorials.com/demos/221/source.zip" target="_blank" rel="nofollow">download in archive</a></strong></h5><hr
/><h3>Conclusion</h3><p>I will hope that our new series of articles of chat system creation will be useful and interesting for you. If you want to share your ideas, or you noticed any weakness &#8211; don&#8217;t hesitate to contact us. Good luck and welcome back!</p><div
class="shr-publisher-1373"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-3/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/226/thumb.png" alt="Powerful Chat System &#8211; Lesson 3" /> <br
/> Powerful Chat System &#8211; Lesson 3</a></li><li> <a
href="http://www.script-tutorials.com/powerful-chat-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/218/thumb.png" alt="Powerful Chat System" /> <br
/> Powerful Chat System</a></li><li> <a
href="http://www.script-tutorials.com/how-to-easily-make-ajax-style-php-chat-application/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="How to Easily Make AJAX Style PHP Chat Application" /> <br
/> How to Easily Make AJAX Style PHP Chat Application</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/powerful-chat-system-lesson-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Isometric interactive interior guide</title><link>http://www.script-tutorials.com/isometric-interactive-interior-guide/</link> <comments>http://www.script-tutorials.com/isometric-interactive-interior-guide/#comments</comments> <pubDate>Tue, 17 Jan 2012 17:37:15 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[inspiration]]></category> <category><![CDATA[interactive guide]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1369</guid> <description><![CDATA[Isometric interactive interior guide During browsing internet, I have noticed new interesting thing &#8211; it looked like isometric guide. Today I will show you how you can create something similar. We will create isometric interactive interior guide with CSS3 and jQuery. Here are samples and downloadable package: Live Demo download in package Ok, download the [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/how-to-create-dialogs-using-ui-dialog/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/40.png" alt="How to create Animated Dialogs using UI Dialog (jQuery)" /> How to create Animated Dialogs using UI Dialog (jQuery)</a></li><li> <a
href="http://www.script-tutorials.com/html5-game-development-lesson-5/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/205/thumb.png" alt="HTML5 Game Development &#8211; Lesson 5" /> HTML5 Game Development &#8211; Lesson 5</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Isometric interactive interior guide" alt="Isometric interactive interior guide" src="http://www.script-tutorials.com/demos/220/thumb.png" /></div><p><strong>Isometric interactive interior guide</strong></p><p>During browsing internet, I have noticed new interesting thing &#8211; it looked like isometric guide. Today I will show you how you can create something similar. We will create isometric interactive interior guide with CSS3 and jQuery.</p><p><span
id="more-1369"></span></p><hr
/><p>Here are samples and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Isometric interactive interior guide - demo 220" href="http://www.script-tutorials.com/demos/220/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Isometric interactive interior guide - package" href="http://www.script-tutorials.com/demos/220/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>As usual, we start with the HTML. Here is full html code of our guide page. You can see here main scene (container object), six labels on this scene (with some description), and empty dialog element.</p><h4>index.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Isometric interactive interior guide with CSS3 and jQuery | Script Tutorials&lt;/title&gt;
        &lt;link href=&quot;css/layout.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js&quot;&gt;&lt;/script&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;header&gt;
            &lt;h2&gt;Isometric interactive interior guide&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/isometric-interactive-interior-guide/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/header&gt;

        &lt;div class=&quot;container&quot;&gt;
            &lt;div class=&quot;labels&quot;&gt;
                &lt;a id=&quot;label1&quot; class=&quot;label&quot; href=&quot;#&quot;&gt;sofa
                    &lt;p&gt;A sofa, is an item of furniture designed to seat more than one person, and providing support for the back and arms.&lt;/p&gt;
                    &lt;span /&gt;
                &lt;/a&gt;
                &lt;a id=&quot;label2&quot; class=&quot;label&quot; href=&quot;#&quot;&gt;television
                    &lt;p&gt;Television (TV) is a telecommunication medium for transmitting and receiving moving images that can be monochrome (black-and-white) or colored, with or without accompanying sound.&lt;/p&gt;
                    &lt;span /&gt;
                &lt;/a&gt;
                &lt;a id=&quot;label3&quot; class=&quot;label&quot; href=&quot;#&quot;&gt;chest
                    &lt;p&gt;In many video games, especially role-playing video games, treasure chests contain various items, currency, and sometimes monsters.&lt;/p&gt;
                    &lt;span /&gt;
                &lt;/a&gt;
                &lt;a id=&quot;label4&quot; class=&quot;label&quot; href=&quot;#&quot;&gt;workplace
                    &lt;p&gt;A virtual workplace is a workplace that is not located in any one physical space.&lt;/p&gt;
                    &lt;span /&gt;
                &lt;/a&gt;
                &lt;a id=&quot;label5&quot; class=&quot;label&quot; href=&quot;#&quot;&gt;entrance
                    &lt;p&gt;A door is a movable structure used to open and close off an entrance, typically consisting of a panel that swings on hinges or that slides or rotates inside of a space.&lt;/p&gt;
                    &lt;span /&gt;
                &lt;/a&gt;
                &lt;a id=&quot;label6&quot; class=&quot;label&quot; href=&quot;#&quot;&gt;safe room
                    &lt;p&gt;A safe room or panic room is a fortified room which is installed in a private residence or business to provide a safe shelter, or hiding place, for the inhabitants in the event of a break-in, home invasion, tornado, or other threat.&lt;/p&gt;
                    &lt;span /&gt;
                &lt;/a&gt;
            &lt;/div&gt;
            &lt;div class=&quot;dialog&quot;&gt;
                &lt;p&gt;&lt;/p&gt;
                &lt;a class=&quot;close&quot;&gt;X&lt;/a&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><h3>Step 2. CSS</h3><p>Now &#8211; CSS styles. Which I have separated into two parts: common page styles and styles of our main scene.</p><h4>css/layout.css</h4><pre class="brush:css">
/* page layout styles */
*{
    margin:0;
    padding:0;
}
body {
    background-color:#fefffa;
    color:#fff;
    font:14px/1.3 Arial,sans-serif;
}
header {
    background-color:#212121;
    box-shadow: 0 -1px 2px #111111;
    display:block;
    height:70px;
    position:relative;
    width:100%;
    z-index:100;
}
header h2{
    font-size: 22px;
    font-weight: normal;
    left: 40%;
    margin-left: -300px;
    padding: 22px 0;
    position: absolute;
    width: 1000px;
}
header a.stuts,a.stuts:visited{
    border: none;
    color: #FCFCFC;
    font-size: 14px;
    left: 50%;
    line-height: 31px;
    margin: 23px 0 0 110px;
    position: absolute;
    text-decoration: none;
    top: 0;
}
header .stuts span {
    font-size:22px;
    font-weight:bold;
    margin-left:5px;
}

/* demo */
.container {
    background: url(&quot;../images/scene.jpg&quot;) no-repeat scroll center top transparent;
    color: #000000;
    height: 535px;
    margin: 20px auto;
    overflow: hidden;
    position: relative;
    width: 1030px;
}
.dialog {
    background-color: rgba(163, 154, 77, 0.9);
    color: #FFFFFF;
    display: none;
    height: 140px;
    left: 343px;
    line-height: 24px;
    padding: 100px 30px;
    position: absolute;
    text-align: center;
    top: 97px;
    width: 280px;
    z-index: 10;

    -moz-border-radius: 170px;
    -ms-border-radius: 170px;
    -o-border-radius: 170px;
    -webkit-border-radius: 170px;
    border-radius: 170px;
}
.dialog .close {
    background-color: #65683b;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    height: 36px;
    line-height: 36px;
    position: absolute;
    right: 10px;
    top: 60px;
    width: 36px;

    -moz-border-radius: 18px;
    -ms-border-radius: 18px;
    -o-border-radius: 18px;
    -webkit-border-radius: 18px;
    border-radius: 18px;
}
.labels p {
    display: none;
}
.labels a {
    background-color: rgba(203, 189, 58, 0.8);
    color: #FFFFFF;
    display: none;
    height: 50px;
    padding: 30px 0 0;
    position: absolute !important;
    text-align: center;
    text-decoration: none;
    width: 80px;

    -moz-border-radius: 40px;
    -ms-border-radius: 40px;
    -o-border-radius: 40px;
    -webkit-border-radius: 40px;
    border-radius: 40px;
}
.labels &gt; a {
    background-color: rgba(203, 189, 58, 0.8);

    -moz-transition: .3s;
    -ms-transition: .3s;
    -o-transition: .3s;
    -webkit-transition: .3s;
    transition: .3s;
}
.labels a:hover {
    background-color: rgba(128, 128, 128, 0.8);
}
.labels a span {
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 15px solid rgba(203, 189, 58, 0.8);
    bottom: -14px;
    height: 0;
    left: 30px;
    position: absolute;
    width: 0;

    -moz-transition: .3s;
    -ms-transition: .3s;
    -o-transition: .3s;
    -webkit-transition: .3s;
    transition: .3s;
}
.labels a:hover span {
    border-top: 15px solid rgba(128, 128, 128, 0.8);
}
#label1 {
    left: 720px;
    top: 215px;
}
#label2 {
    left: 495px;
    top: 290px;
}
#label3 {
    left: 450px;
    top: 115px;
}
#label4 {
    left: 270px;
    top: 170px;
}
#label5 {
    left: 570px;
    top: 65px;
}
#label6 {
    left: 275px;
    top: 30px;
}
</pre><h3>Step 3. JS</h3><p>And now &#8211; our jQuery code:</p><h4>js/main.js</h4><pre class="brush:js">
jQuery(function(){
    // initialize of labels
    $('.labels a#label1').fadeIn(100).effect('bounce', { times:3 }, 300, function() {
        $('.labels a#label2').fadeIn(100).effect('bounce', { times:3 }, 300, function() {
            $('.labels a#label3').fadeIn(100).effect('bounce', { times:3 }, 300, function() {
                $('.labels a#label4').fadeIn(100).effect('bounce', { times:3 }, 300, function() {
                    $('.labels a#label5').fadeIn(100).effect('bounce', { times:3 }, 300, function() {
                        $('.labels a#label6').fadeIn(100).effect('bounce', { times:3 }, 300);
                    });
                });
            });
        });
    });

    // dialog close
    $('.dialog .close').click(function() {
        $(this).parent().fadeOut(500);
        return false;
    });

    // display dialog on click by labels
    $('.labels a').click(function() {
        $('.dialog p').html( $(this).find('p').html() ).parent().fadeIn(500);
        return false;
    });

    // close dialog on click outside
    $('.container').click(function() {
        $('.dialog').fadeOut(500);
    });
});
</pre><p>Here are just a few event handlers of our scene objects.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Isometric interactive interior guide - demo 220" href="http://www.script-tutorials.com/demos/220/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Isometric interactive interior guide - package" href="http://www.script-tutorials.com/demos/220/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>I will happy if our material will useful for you, and can bring you some inspiration. Don&#8217;t forget telling thanks and leaving a comment. <img
src='http://www.script-tutorials.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Good luck!</p><div
class="shr-publisher-1369"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/how-to-create-dialogs-using-ui-dialog/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/40.png" alt="How to create Animated Dialogs using UI Dialog (jQuery)" /> <br
/> How to create Animated Dialogs using UI Dialog (jQuery)</a></li><li> <a
href="http://www.script-tutorials.com/html5-game-development-lesson-5/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/205/thumb.png" alt="HTML5 Game Development &#8211; Lesson 5" /> <br
/> HTML5 Game Development &#8211; Lesson 5</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/isometric-interactive-interior-guide/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Powerful Chat System</title><link>http://www.script-tutorials.com/powerful-chat-system/</link> <comments>http://www.script-tutorials.com/powerful-chat-system/#comments</comments> <pubDate>Fri, 13 Jan 2012 14:14:57 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[ajax chat]]></category> <category><![CDATA[chat]]></category> <category><![CDATA[chat system]]></category> <category><![CDATA[profiles]]></category> <category><![CDATA[registration]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1360</guid> <description><![CDATA[Powerful Chat System Today we begin a series of articles on the creation of powerful chat system. The system will contain next elements: registration, login processing, main chat, profiles with avatars, ranking system (of profiles), private messaging, custom rooms, moderation / administration and possible something else (in future). This will be ajax chat PHP) with [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-3/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/226/thumb.png" alt="Powerful Chat System &#8211; Lesson 3" /> Powerful Chat System &#8211; Lesson 3</a></li><li> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-2/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/221/thumb.png" alt="Powerful Chat System &#8211; Lesson 2" /> Powerful Chat System &#8211; Lesson 2</a></li><li> <a
href="http://www.script-tutorials.com/how-to-easily-make-a-php-chat-application/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="How to Easily Make a PHP Chat Application" /> How to Easily Make a PHP Chat Application</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Powerful Chat System" alt="Powerful Chat System" src="http://www.script-tutorials.com/demos/218/thumb.png"></div><p><strong>Powerful Chat System</strong><br
/> <br
/>Today we begin a series of articles on the creation of powerful chat system. The system will contain next elements: registration, login processing, main chat, profiles with avatars, ranking system (of profiles), private messaging, custom rooms, moderation / administration and possible something else (in future). This will be ajax chat PHP) with storing messages in database (MySQL). Plus we will implement CSS3/HTML5 features in our development process.<br
/> <span
id="more-1360"></span></p><p>Today I have included next elements: initial code (PHP + SQL) with login processor. All project will be well structured: system classes is in &#8216;classes&#8217; folder, stylesheets in &#8216;css&#8217; folder, template files in &#8216;templates&#8217; folder.</p><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - demo 218" href="http://www.script-tutorials.com/demos/218/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - package" href="http://www.script-tutorials.com/demos/218/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Now &#8211; download the source files and lets start coding !</p><hr
/><h3>Step 1. SQL</h3><p>Here is SQL structure of tables for profiles and messages</p><pre class="brush:sql">
CREATE TABLE `cs_profiles` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `last_name` varchar(255) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  `password` varchar(40) NOT NULL default '',
  `salt` varchar(10) NOT NULL default '',
  `status` enum('active','passive') NOT NULL default 'active',
  `role` tinyint(4) unsigned NOT NULL default '1',
  `about` varchar(255) NOT NULL,
  `date_reg` datetime NOT NULL default '0000-00-00 00:00:00',
  `rate` float NOT NULL,
  `rate_count` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

INSERT INTO `cs_profiles` (`name`, `last_name`, `email`, `password`, `salt`, `status`, `role`, `about`, `date_reg`, `rate`, `rate_count`) VALUES
('test user', 'test user last name', 'user@user.com', 'b88c654d6c68fc37f4dda1d29935235eea9a845b', 'testing', 'active', 1, 'Few words about test user', '2012-01-14 00:00:00', 0, 0),
('moderator', 'moderator last name', 'moderator@moderator.com', 'b88c654d6c68fc37f4dda1d29935235eea9a845b', 'testing', 'active', 4, 'Few words about moderator', '2012-01-14 00:00:00', 0, 0),
('admin', 'admin last name', 'admin@admin.com', 'b88c654d6c68fc37f4dda1d29935235eea9a845b', 'testing', 'active', 5, 'Few words about admin', '2012-01-14 00:00:00', 0, 0);

CREATE TABLE `cs_messages` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sender` int(11) unsigned NOT NULL,
  `recipient` int(11) unsigned NOT NULL default '0',
  `message` VARCHAR(255) NOT NULL,
  `when` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP,
  `room` int(5) unsigned NOT NULL default '0',
  `type` tinyint(1) unsigned NOT NULL default '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
</pre><p>I have added 3 profiles in the system. Each of them have different role. I plan to make ordinary members (1), moderators (4), administrators (5). You can use another roles (as example 2 and 3) for any other purposes (paid members?). And, quite forgot &#8211; password for all of them is <b>&#8216;password&#8217;</b>. So you can login as &#8216;test user&#8217; -> &#8216;password&#8217;, &#8216;moderator&#8217; -> &#8216;password&#8217; and &#8216;admin&#8217; -> &#8216;password&#8217;. Registration process will in next article.</p><h3>Step 2. HTML</h3><p>This is main (index) page html markup:</p><h4>templates/main_page.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
&lt;head&gt;
    &lt;title&gt;Powerful Chat System&lt;/title&gt;
    &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;header&gt;
        &lt;h2&gt;Powerful Chat System&lt;/h2&gt;
        &lt;a href=&quot;http://www.script-tutorials.com/powerful-chat-system/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
    &lt;/header&gt;
    &lt;div class=&quot;container&quot;&gt;
        {form}
    &lt;/div&gt;
    &lt;div class=&quot;container&quot;&gt;
        {chat}
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre><p>It is easy layout, isn&#8217;t it?. Now, next template file for login form:</p><h4>templates/login_form.html</h4><pre class="brush:html">
&lt;div class=&quot;column&quot;&gt;
    &lt;h3&gt;Powerful Chat System Demonstration&lt;/h3&gt;
    &lt;p&gt;Our chat will contain next features: registration, main chat, profiles with avatars, ranking system, private messaging, custom rooms, moderation / administration and possible something else (in future).&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;column&quot;&gt;
    &lt;form class=&quot;login_form&quot; action=&quot;index.php&quot; method=&quot;post&quot;&gt;
        &lt;h3&gt;Log In&lt;/h3&gt;
        &lt;label&gt;Username:&lt;/label&gt;&lt;input type=&quot;text&quot; name=&quot;username&quot;&gt;
        &lt;label&gt;Password:&lt;/label&gt;&lt;input type=&quot;password&quot; name=&quot;password&quot;&gt;
        &lt;input type=&quot;submit&quot; name=&quot;LogIn&quot; value=&quot;Login&quot;&gt;
    &lt;/form&gt;
&lt;/div&gt;
</pre><p>Next one template &#8211; logout form:</p><h4>logout_form.html</h4><pre class="brush:html">
&lt;div class=&quot;column&quot;&gt;
    &lt;h3&gt;Hello {name}&lt;/h3&gt;
    &lt;h3&gt;Your status:&lt;/h3&gt;
    &lt;div&gt;{status}&lt;/div&gt;
    &lt;h3&gt;Your role:&lt;/h3&gt;
    &lt;div&gt;{role}&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;column&quot;&gt;
    &lt;a href=&quot;index.php?logout&quot;&gt;Log Out&lt;/a&gt;
&lt;/div&gt;
</pre><h3>Step 3. CSS</h3><p>This file contains styles of our page layout</p><h4>css/main.css</h4><pre class="brush:html">
/* page layout */
*{
    margin:0;
    padding:0;
}
body {
    background-color:#eee;
    color:#fff;
    font:14px/1.3 Arial,sans-serif;
}
header {
    background-color:#212121;
    box-shadow: 0 -1px 2px #111111;
    display:block;
    height:70px;
    position:relative;
    width:100%;
    z-index:100;
}
header h2{
    font-size:22px;
    font-weight:normal;
    left:50%;
    margin-left:-400px;
    padding:22px 0;
    position:absolute;
    width:540px;
}
header a.stuts,a.stuts:visited{
    border:none;
    text-decoration:none;
    color:#fcfcfc;
    font-size:14px;
    left:50%;
    line-height:31px;
    margin:23px 0 0 110px;
    position:absolute;
    top:0;
}
header .stuts span {
    font-size:22px;
    font-weight:bold;
    margin-left:5px;
}

/* main styles */
.container {
    background-color:#222;
    color: #bbb;
    margin: 20px auto;
    overflow: hidden;
    padding:20px;
    position: relative;
    width: 800px;
}
.column {
    float:left;
    width:48%;
}
.column:first-child {
    margin-right:4%;
}
.column &gt; * {
    color:#ddd;
    margin-bottom:10px;
}
.column h3 {
    color:#fff;
}
.login_form input,.login_form label {
    display:block;
    margin-bottom:5px;
}
input[type=text],
input[type=password] {
    width:200px;
}
input[type=submit]{
    height:30px;
    margin-top:10px;
    width:72px;
}
</pre><h3>Step 4. PHP</h3><p>Now, lets review php sources:</p><h4>index.php</h4><pre class="brush:php">
&lt;?php

// set error reporting level
if (version_compare(phpversion(), &quot;5.3.0&quot;, &quot;&gt;=&quot;) == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE);

require_once('classes/CMySQL.php'); // including service class to work with database
require_once('classes/CLogin.php'); // including service class to work with login processing

// login system init and generation code
$sLoginForm = $GLOBALS['CLogin']-&gt;getLoginBox();

$sChat = ($_SESSION['member_name'] &amp;&amp; $_SESSION['member_status'] == 'active') ? '&lt;h2&gt;TODO chat&lt;/h2&gt;' : '&lt;h2&gt;You have to login before use chat&lt;/h2&gt;';

echo strtr(file_get_contents('templates/main_page.html'), array('{form}' =&gt; $sLoginForm, '{chat}' =&gt; $sChat));
</pre><p>As we need only login processing for today &#8211; our index file is pretty small. New functional will appear in further articles. Here is sources of our login processor:</p><h4>classes/CLogin.php</h4><pre class="brush:php">
&lt;?php

class CLogin {

    // constructor
    function CLogin() {
        session_start();
    }

    // get login box function
    function getLoginBox() {
        if (isset($_GET['logout'])) { // logout processing
            if (isset($_SESSION['member_name']) &amp;&amp; isset($_SESSION['member_pass']))
                $this-&gt;performLogout();
        }

        if ($_POST &amp;&amp; $_POST['username'] &amp;&amp; $_POST['password']) { // login processing
            if ($this-&gt;checkLogin($_POST['username'], $_POST['password'], false)) { // successful login
                $this-&gt;performLogin($_POST['username'], $_POST['password']);
                header( &quot;Location:{$_SERVER['REQUEST_URI']}&quot; );
                exit;
            } else { // wrong login
                return file_get_contents('templates/login_form.html') . '&lt;h2&gt;Username or Password is incorrect&lt;/h2&gt;';
            }
        } else { // in case if we already logged (on refresh page):
            if (isset($_SESSION['member_name']) &amp;&amp; $_SESSION['member_name'] &amp;&amp; $_SESSION['member_pass']) {
                $aReplaces = array(
                    '{name}' =&gt; $_SESSION['member_name'],
                    '{status}' =&gt; $_SESSION['member_status'],
                    '{role}' =&gt; $_SESSION['member_role'],
                );
                return strtr(file_get_contents('templates/logout_form.html'), $aReplaces);
            }

            // otherwise - draw login form
            return file_get_contents('templates/login_form.html');
        }
    }

    // perform login
    function performLogin($sName, $sPass) {
        $this-&gt;performLogout();

        // make variables safe
        $sName = $GLOBALS['MySQL']-&gt;escape($sName);

        $aProfile = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `cs_profiles` WHERE `name`='{$sName}'&quot;);
        // $sPassEn = $aProfile['password'];
        $sSalt = $aProfile['salt'];
        $sStatus = $aProfile['status'];
        $sRole = $aProfile['role'];

        $sPass = sha1(md5($sPass) . $sSalt);

        $_SESSION['member_name'] = $sName;
        $_SESSION['member_pass'] = $sPass;
        $_SESSION['member_status'] = $sStatus;
        $_SESSION['member_role'] = $sRole;
    }

    // perform logout
    function performLogout() {
        unset($_SESSION['member_name']);
        unset($_SESSION['member_pass']);
        unset($_SESSION['member_status']);
        unset($_SESSION['member_role']);
    }

    // check login
    function checkLogin($sName, $sPass, $isHash = true) {
        // make variables safe
        $sName = $GLOBALS['MySQL']-&gt;escape($sName);
        $sPass = $GLOBALS['MySQL']-&gt;escape($sPass);

        $aProfile = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `cs_profiles` WHERE `name`='{$sName}'&quot;);
        $sPassEn = $aProfile['password'];

        if ($sName &amp;&amp; $sPass &amp;&amp; $sPassEn) {
            if (! $isHash) {
                $sSalt = $aProfile['salt'];
                $sPass = sha1(md5($sPass) . $sSalt);
            }
            return ($sPass == $sPassEn);
        }
        return false;
    }
}

$GLOBALS['CLogin'] = new CLogin();
</pre><p>I hope you still remember our <a
href="http://www.script-tutorials.com/creating-advance-level-login-system-with-logic-captcha/" target="_blank">previous article of advanced login system</a>. We will have similar system with using sha1 + md5 encryption. All profiles will kept in database.</p><h4>classes/CMySQL.php</h4><p>This is database service class. Available in package. Pay attention &#8211; database settings of our project is in this file.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - demo 218" href="http://www.script-tutorials.com/demos/218/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Powerful Chat System - package" href="http://www.script-tutorials.com/demos/218/source.zip" target="_blank" rel="nofollow">download in archive</a></strong></h5><hr
/><h3>Conclusion</h3><p>I will hope that our new series of articles of chat system creation will be useful and interesting for you. If you want to share your ideas, or you noticed any weakness &#8211; don&#8217;t hesitate to contact us. Good luck and welcome back!</p><div
class="shr-publisher-1360"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-3/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/226/thumb.png" alt="Powerful Chat System &#8211; Lesson 3" /> <br
/> Powerful Chat System &#8211; Lesson 3</a></li><li> <a
href="http://www.script-tutorials.com/powerful-chat-system-lesson-2/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/221/thumb.png" alt="Powerful Chat System &#8211; Lesson 2" /> <br
/> Powerful Chat System &#8211; Lesson 2</a></li><li> <a
href="http://www.script-tutorials.com/how-to-easily-make-a-php-chat-application/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="How to Easily Make a PHP Chat Application" /> <br
/> How to Easily Make a PHP Chat Application</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/powerful-chat-system/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Creating photo album with jQuery Fotorama</title><link>http://www.script-tutorials.com/photo-album-with-jquery-fotorama/</link> <comments>http://www.script-tutorials.com/photo-album-with-jquery-fotorama/#comments</comments> <pubDate>Wed, 11 Jan 2012 12:44:06 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[Fotorama]]></category> <category><![CDATA[iphone]]></category> <category><![CDATA[photo album]]></category> <category><![CDATA[touch]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1353</guid> <description><![CDATA[Creating photo album with jQuery Fotorama Today I have prepared tutorial about using new impressive jQuery gallery &#8211; Fotorama. This is a nice looking javascript gallery with intuitive controls, and great browser compatibility. You can use this plugin at iPhones and any other mobile devices (you can slide photos with touch). Here are links to [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-photo-album-with-galleriffic-jquery-plugin/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/156/thumb.png" alt="Creating a Photo Album with Galleriffic jQuery plugin" /> Creating a Photo Album with Galleriffic jQuery plugin</a></li><li> <a
href="http://www.script-tutorials.com/creating-photo-album-with-jquery-chop-slider/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/196/thumb.png" alt="Creating photo album with jQuery Chop Slider" /> Creating photo album with jQuery Chop Slider</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-photo-album-with-tn3/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/146/thumb.png" alt="How to Create a Fantastic Photo Album with TN3" /> How to Create a Fantastic Photo Album with TN3</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Creating photo album with jQuery Fotorama" alt="Creating photo album with jQuery Fotorama" src="http://www.script-tutorials.com/demos/216/thumb.png"></div><p><strong>Creating photo album with jQuery Fotorama</strong><br
/> <br
/>Today I have prepared tutorial about using new impressive jQuery gallery &#8211; Fotorama. This is a nice looking javascript gallery with intuitive controls, and great browser compatibility. You can use this plugin at iPhones and any other mobile devices (you can slide photos with touch).<br
/> <span
id="more-1353"></span></p><p>Here are links to demo and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="Creating photo album with jQuery Fotorama - demo 216" href="http://www.script-tutorials.com/demos/216/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Creating photo album with jQuery Fotorama - package" href="http://www.script-tutorials.com/demos/216/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, lets download the example files and goto coding !</p><hr
/><h3>Step 1. HTML</h3><h4>index.html</h4><p>This is markup of our result page with Fotorama gallery. Here it is.</p><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Creating photo album with jQuery Fotorama | Script Tutorials&lt;/title&gt;
        &lt;link href=&quot;css/layout.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
        &lt;link href=&quot;css/fotorama.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
        &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/fotorama.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;header&gt;
            &lt;h2&gt;Creating photo album with jQuery Fotorama&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/photo-album-with-jquery-fotorama/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/header&gt;
        &lt;div class=&quot;container&quot;&gt;

            &lt;div id=&quot;fotorama&quot;&gt;
                &lt;img src=&quot;images/pic1.jpg&quot; alt=&quot;photo #1&quot; /&gt;
                &lt;img src=&quot;images/pic2.jpg&quot; alt=&quot;photo #2&quot; /&gt;
                &lt;img src=&quot;images/pic3.jpg&quot; alt=&quot;photo #3&quot; /&gt;
                &lt;img src=&quot;images/pic4.jpg&quot; alt=&quot;photo #4&quot; /&gt;
                &lt;img src=&quot;images/pic5.jpg&quot; alt=&quot;photo #5&quot; /&gt;
                &lt;img src=&quot;images/pic6.jpg&quot; alt=&quot;photo #6&quot; /&gt;
                &lt;img src=&quot;images/pic7.jpg&quot; alt=&quot;photo #7&quot; /&gt;
                &lt;img src=&quot;images/pic8.jpg&quot; alt=&quot;photo #8&quot; /&gt;
                &lt;img src=&quot;images/pic9.jpg&quot; alt=&quot;photo #9&quot; /&gt;
                &lt;img src=&quot;images/pic10.jpg&quot; alt=&quot;photo #10&quot; /&gt;
                &lt;img src=&quot;images/pic11.jpg&quot; alt=&quot;photo #11&quot; /&gt;
                &lt;img src=&quot;images/pic12.jpg&quot; alt=&quot;photo #12&quot; /&gt;
            &lt;/div&gt;

        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><p>Very easy &#8211; right?</p><h3>Step 2. CSS</h3><h4>css/layout.css and css/fotorama.css</h4><p>First stylesheet is page layout of our page. Second one is default stylesheet file of fotorama gallery. You can customize it (if need). Both files available in our package.</p><h3>Step 3. JS</h3><h4>js/fotorama.js</h4><p>This is main gallery javascript file. It uses jQuery, so we have to include both (fotorama.js and jquery) files. This file available in package.</p><h4>js/main.js</h4><pre class="brush:js">
jQuery(function(){
    $('#fotorama').fotorama({
        // width: 1000, // Width of container
        // height: 600, // Height of container
        startImg: 10, // Initial image
        transitionDuration: 400, // Duration of transition
        touchStyle: true, // Enable dragging
        // pseudoClick: true, // Slide between images by click (if touchStyle = true)
        // loop: false, // Loop for images (if touchStyle = false)
        // backgroundColor: null, // Custom background color
        margin: 10, // Margin between images
        // minPadding: 10, // Min padding
        // alwaysPadding: false, // Apply padding for images
        // preload: 3, // Amount of pre-loaded images from each end of the active image
        // resize: false, // Resize images
        // zoomToFit: true, // Zoom to fit
        // cropToFit: false, // Crop to fit
        // vertical: false, // Vertical thumbs
        // verticalThumbsRight: false, // Vertical thumbs at right
        // arrows: true, // Draw arrows
        arrowsColor: '#3399cc', // Arrows color
        // thumbs: true, // Draw thumbs
        // thumbsBackgroundColor: null, // Thumbs Background Color
        // thumbColor: null, // Thumb Color
        // thumbsPreview: true, // Thumb Preview
        thumbSize: 50, // Thumb size (height)
        // thumbMargin: 5, // Thumb margins
        thumbBorderWidth: 1, // Thumb border width
        // thumbBorderColor: null, // Thumb Border Color
        caption: true, // Display captions
        // html: null, // You can full html code of gallery here
        // onShowImg: null, // Custom function when we select image
        // shadows: true // Display shadows
    });
});
</pre><p>This is main initialization of fotorama gallery. Several styles was customized, another &#8211; no. I have added descriptions of all possible parameters of this gallery.</p><p><a
rel="nofollow" href="http://fotoramajs.com/">Here</a> you can find official documentation of this gallery.</p><h3>Step 4. Images</h3><p>All gallery images is in &#8216;images&#8217; folder.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Creating photo album with jQuery Fotorama - demo 216" href="http://www.script-tutorials.com/demos/216/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Creating photo album with jQuery Fotorama - package" href="http://www.script-tutorials.com/demos/216/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>I hope that today we made new nice photo gallery. Good luck in your projects!</p><div
class="shr-publisher-1353"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-photo-album-with-galleriffic-jquery-plugin/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/156/thumb.png" alt="Creating a Photo Album with Galleriffic jQuery plugin" /> <br
/> Creating a Photo Album with Galleriffic jQuery plugin</a></li><li> <a
href="http://www.script-tutorials.com/creating-photo-album-with-jquery-chop-slider/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/196/thumb.png" alt="Creating photo album with jQuery Chop Slider" /> <br
/> Creating photo album with jQuery Chop Slider</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-photo-album-with-tn3/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/146/thumb.png" alt="How to Create a Fantastic Photo Album with TN3" /> <br
/> How to Create a Fantastic Photo Album with TN3</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/photo-album-with-jquery-fotorama/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Creating photo album with jQuery Chop Slider</title><link>http://www.script-tutorials.com/creating-photo-album-with-jquery-chop-slider/</link> <comments>http://www.script-tutorials.com/creating-photo-album-with-jquery-chop-slider/#comments</comments> <pubDate>Tue, 06 Dec 2011 15:52:45 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1277</guid> <description><![CDATA[Creating photo album with jQuery Chop Slider Today I will tell you about new impressive jQuery slider &#8211; Chop. This slider have already had quite 200 different transition effects. Here are many 2D and 3D effects. Plus, here are you can find even few NonCss3 effects (to old IE browsers) and five effects for mobile [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-photo-album-with-galleriffic-jquery-plugin/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/156/thumb.png" alt="Creating a Photo Album with Galleriffic jQuery plugin" /> Creating a Photo Album with Galleriffic jQuery plugin</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-photo-gallery-using-slider-kit-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/72/thumb.png" alt="How to Create Animated Photo Gallery using jQuery (Slider Kit)" /> How to Create Animated Photo Gallery using jQuery (Slider Kit)</a></li><li> <a
href="http://www.script-tutorials.com/using-flux-slider-jquery-plugin/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/94/thumb.png" alt="Using Flux Slider jQuery plugin" /> Using Flux Slider jQuery plugin</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="creating photo album with Chop Slider" alt="creating photo album with Chop Slider" src="http://www.script-tutorials.com/demos/196/thumb.png"></div><p><strong>Creating photo album with jQuery Chop Slider</strong><br
/> <br
/>Today I will tell you about new impressive jQuery slider &#8211; Chop. This slider have already had quite 200 different transition effects. Here are many 2D and 3D effects. Plus, here are you can find even few NonCss3 effects (to old IE browsers) and five effects for mobile browsers (for cellphones). Plus, we can create our own new transitions (if you want).<br
/> <span
id="more-1277"></span></p><p>Here are links to demo and downloadable package:</p><h5 style="text-align: center;"><strong><a
title="creating photo album with Chop Slider - demo 196" href="http://www.script-tutorials.com/demos/196/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="creating photo album with Chop Slider - package" href="http://www.script-tutorials.com/demos/196/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Ok, lets download the example files and goto coding !</p><hr
/><h3>Step 1. HTML</h3><h4>index.html</h4><p>Here are HTML source code of our Chop photo slider.</p><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Creating photo album with jQuery Chop Slider | Script Tutorials&lt;/title&gt;

        &lt;link href=&quot;css/layout.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
        &lt;link href=&quot;css/chopslider.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

        &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/jquery.id.chopslider-2.2.0.free.min.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/jquery.id.cstransitions-1.2.min.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;header&gt;
            &lt;h2&gt;Creating photo album with jQuery Chop Slider&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/creating-photo-album-with-jquery-chop-slider/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/header&gt;
        &lt;div class=&quot;container&quot;&gt;

            &lt;div class=&quot;wrapper&quot;&gt;
              &lt;div class=&quot;s-shadow-b&quot;&gt;&lt;/div&gt;
              &lt;a id=&quot;slide-next&quot; href=&quot;#&quot;&gt;&lt;/a&gt;
              &lt;a id=&quot;slide-prev&quot; href=&quot;#&quot;&gt;&lt;/a&gt;
              &lt;div id=&quot;slider&quot;&gt;
                &lt;div class=&quot;slide cs-activeSlide&quot;&gt; &lt;img src=&quot;slide_images/pic1.jpg&quot; width=&quot;900&quot; height=&quot;300&quot; alt=&quot;photo #1&quot; /&gt; &lt;/div&gt;
                &lt;div class=&quot;slide&quot;&gt; &lt;img src=&quot;slide_images/pic2.jpg&quot; width=&quot;900&quot; height=&quot;300&quot; alt=&quot;photo #2&quot; /&gt; &lt;/div&gt;
                &lt;div class=&quot;slide&quot;&gt; &lt;img src=&quot;slide_images/pic3.jpg&quot; width=&quot;900&quot; height=&quot;300&quot; alt=&quot;photo #3&quot; /&gt; &lt;/div&gt;
                &lt;div class=&quot;slide&quot;&gt; &lt;img src=&quot;slide_images/pic4.jpg&quot; width=&quot;900&quot; height=&quot;300&quot; alt=&quot;photo #4&quot; /&gt; &lt;/div&gt;
                &lt;div class=&quot;slide&quot;&gt; &lt;img src=&quot;slide_images/pic5.jpg&quot; width=&quot;900&quot; height=&quot;300&quot; alt=&quot;photo #5&quot; /&gt; &lt;/div&gt;
                &lt;div class=&quot;slide&quot;&gt; &lt;img src=&quot;slide_images/pic6.jpg&quot; width=&quot;900&quot; height=&quot;300&quot; alt=&quot;photo #6&quot; /&gt; &lt;/div&gt;
                &lt;div class=&quot;slide&quot;&gt; &lt;img src=&quot;slide_images/pic7.jpg&quot; width=&quot;900&quot; height=&quot;300&quot; alt=&quot;photo #7&quot; /&gt; &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;pagination&quot;&gt;
                &lt;span class=&quot;slider-pagination&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;slider-pagination&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;slider-pagination&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;slider-pagination&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;slider-pagination&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;slider-pagination&quot;&gt;&lt;/span&gt;
                &lt;span class=&quot;slider-pagination&quot;&gt;&lt;/span&gt;
              &lt;/div&gt;
              &lt;div class=&quot;slide-descriptions&quot;&gt;
                &lt;div class=&quot;sl-descr&quot;&gt;Thailand, There are very many different ATM in one place&lt;/div&gt;
                &lt;div class=&quot;sl-descr&quot;&gt;All city colour is bright, nothing black&lt;/div&gt;
                &lt;div class=&quot;sl-descr&quot;&gt;Floating market. Shopping on river&lt;/div&gt;
                &lt;div class=&quot;sl-descr&quot;&gt;Sunset on Koh Phangan island&lt;/div&gt;
                &lt;div class=&quot;sl-descr&quot;&gt;Shortly before sunset&lt;/div&gt;
                &lt;div class=&quot;sl-descr&quot;&gt;Good sculpture on Koh Samui island&lt;/div&gt;
                &lt;div class=&quot;sl-descr&quot;&gt;That is such cute barmaid you can see here&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;caption&quot;&gt;&lt;/div&gt;
            &lt;/div&gt;

        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><p>All slides wrap into own DIV parent elements with class name &#8216;slide&#8217;. Pay attention, that we have to create same amount of slider-pagination elements as amount of slider. Same for description.</p><h3>Step 2. CSS</h3><h4>css/layout.css and css/chopslider.css</h4><p>First file is layout of our demo page. Second one is CSS file of Chop slider. You can customize it as you like. Right now it contain next styles:</p><pre class="brush:css">
.wrapper {
	position:relative;
	margin-left:auto;
	margin-right:auto;
	width:960px;
	height:300px;
	display:block;
	padding-top:150px;
	padding-bottom:120px;
	background:url(../images/podium.png) no-repeat bottom;
	z-index:2;
}
.wrapper2 {
	position:relative;
	margin-left:auto;
	margin-right:auto;
	margin-top:20px;
	width:960px;
	height:300px;
	display:block;
	z-index:2;
	text-align:center;
	padding-bottom:50px;
}
.wrapper2 a {
	display:inline-block;
	padding:0px 5px;
	background:#fff;
	border:1px solid #ccc;
	border-radius:3px;
	text-decoration:none;
	margin:0px 5px;
}
.wrapper2 .active-transition {
	background:#222;
	color:#fff;
}
/*---------- Slider ----------- */

/*---------- Left and Right Triggers ----------- */
#slide-prev {
	position:absolute;
	width:21px;
	height:33px;
	bottom:39px;
	left:26px;
	z-index:4;
	background:url(../images/sl-control.png) left top no-repeat;
}
#slide-next {
	position:absolute;
	width:21px;
	height:33px;
	bottom:39px;
	right:26px;
	z-index:4;
	background:url(../images/sl-control.png) left bottom no-repeat;
}

/*---------- Shadow, just for styling ----------- */
.s-shadow-b{
	background:url(../images/shadow.png) no-repeat top;
	width:876px;
	height:55px;
	position:absolute;
	left:42px;
	bottom:60px;
	z-index:1;
}
/*---------- Main Slider Container----------- */
#slider {
	width:900px;
	height:300px;
	margin-left:auto;
	margin-right:auto;
	position:relative;
	z-index:2;
	display:block;
}
/* Every slide must be hidden by default */
.slide { display:none; }

/*
   And only the slide with &quot;cs-activeSlide&quot; class must be visible!
   !Reserved Class name. Required class!
*/
.cs-activeSlide { display:block; }

/* Container with caption's text. Must be hidden */
.slide-descriptions {
	display:none;
}

/* Container with caption, must be hidden by default */
.caption {
	background: url(&quot;../images/d-bg.png&quot;) repeat scroll 0 0 transparent;
    color: #FFFFFF;
    display: none;
    height: 280px;
    padding: 20px;
    position: absolute;
    right: 40px;
    top: 140px;
    width: 180px;
    z-index: 3;
}
.full-3D {
	right: 40px;
    top: 580px;
    width: 840px;
	height:20px;
}
/* Container with Pagination buttons */
.pagination {
	bottom: 50px;
    left: 345px;
    margin-top: 50px;
    position: absolute;
    text-align: center;
}
.slider-pagination {
	display:inline-block;
	width:15px;
	height:10px;
	background:url(../images/navi.png) no-repeat left bottom;
	margin:0 10px;
	cursor:pointer;
	position:relative;
	z-index:200;
}
/* This is a required class for the &quot;Active&quot; pagination button. ! Reserved Class Name ! */
.cs-active-pagination {
	background:url(../images/navi.png) no-repeat left top;
}

/* Multiple SLiders */
.slider-2 {
	padding-top:0;
	margin-top:20px;
}
#slider-1, #slider-2 {
	width:900px;
	height:300px;
	margin-left:auto;
	margin-right:auto;
	position:relative;
	z-index:2;
	display:block;
}
.cs-activeSlide-2 {
	display:block
}
.cs-active-pagination-2 {
	background:url(../images/navi.png) no-repeat left top;
}
</pre><h3>Step 3. JS</h3><h4>js/jquery.id.chopslider-2.2.0.free.min.js and js/jquery.id.cstransitions-1.2.min.js</h4><p>These are two JS files in this slider. We just have to include it to our page.</p><h4>js/main.js</h4><pre class="brush:js">
jQuery(function(){
    $(&quot;#slider&quot;).chopSlider({
        /* slide element */
        slide : &quot;.slide&quot;,
        /* controlers */
        nextTrigger : &quot;a#slide-next&quot;,
        prevTrigger : &quot;a#slide-prev&quot;,
        hideTriggers : true,
        sliderPagination : &quot;.slider-pagination&quot;,
        /* captions */
        useCaptions : true,
        everyCaptionIn : &quot;.sl-descr&quot;,
        showCaptionIn : &quot;.caption&quot;,
        captionTransform : &quot;scale(0) translate(-600px,0px) rotate(45deg)&quot;,
        /* autoplay */
        autoplay : true,
        autoplayDelay : 5000,
        /* for Browsers that support 3D transforms */
        t3D : csTransitions['3DFlips']['random'], /* all will be picked up randomly */
        t2D : [ csTransitions['multi']['random'], csTransitions['vertical']['random'] ],
        noCSS3 : csTransitions['noCSS3']['random'],
        mobile : csTransitions['mobile']['random'],
        onStart: function(){},
        onEnd: function(){}
    })
})
</pre><p>This is initialization of Chop slider. I set all effects (transitions) to random to display different effects to different browsers. Also I have enabled autoplay and display captions (descriptions).</p><p><a
rel="nofollow" href="http://www.idangero.us/cs/">Here</a> you can find full documentation for this slider (with detailed explanation of all params).</p><h3>Step 4. Images</h3><p>For slider interface we are using few images (caption-bg.png, d-bg.png, navi.png, podium.png, shadow.png and sl-control.png). All these images available in our package. All slider images is in &#8216;slide_images&#8217; folder.</p><hr
/><h5 style="text-align: center;"><strong><a
title="creating photo album with Chop Slider - demo 196" href="http://www.script-tutorials.com/demos/196/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="creating photo album with Chop Slider - package" href="http://www.script-tutorials.com/demos/196/source.zip" target="_blank" rel="nofollow">download in package</a></strong></h5><hr
/><h3>Conclusion</h3><p>I hope that today we made new nice photo slider. Good luck in your projects!</p><div
class="shr-publisher-1277"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/creating-photo-album-with-galleriffic-jquery-plugin/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/156/thumb.png" alt="Creating a Photo Album with Galleriffic jQuery plugin" /> <br
/> Creating a Photo Album with Galleriffic jQuery plugin</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-photo-gallery-using-slider-kit-jquery/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/72/thumb.png" alt="How to Create Animated Photo Gallery using jQuery (Slider Kit)" /> <br
/> How to Create Animated Photo Gallery using jQuery (Slider Kit)</a></li><li> <a
href="http://www.script-tutorials.com/using-flux-slider-jquery-plugin/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/94/thumb.png" alt="Using Flux Slider jQuery plugin" /> <br
/> Using Flux Slider jQuery plugin</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/creating-photo-album-with-jquery-chop-slider/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>10 interesting jQuery plugins (november 2011)</title><link>http://www.script-tutorials.com/10-interesting-jquery-plugins-november-2011/</link> <comments>http://www.script-tutorials.com/10-interesting-jquery-plugins-november-2011/#comments</comments> <pubDate>Mon, 05 Dec 2011 14:44:29 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[jQuery]]></category> <category><![CDATA[resources]]></category> <category><![CDATA[plugins]]></category> <category><![CDATA[roundup]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1274</guid> <description><![CDATA[10 interesting jQuery plugins (november 2011) Today I have collected with own hands new most interesting jQuery plugins that have released over the last month. Here are different plugins like face detector, sliders, plugins for forms, even full UI widgets pack etc. 1. Face detection A jQuery plugin which detects faces in pictures and returns [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/10-interesting-jquery-plugins-of-october-2011/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/175/thumb.png" alt="10 interesting jQuery plugins of October 2011" /> 10 interesting jQuery plugins of October 2011</a></li><li> <a
href="http://www.script-tutorials.com/10-interesting-jquery-plugins-september-2011/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/151/thumb.png" alt="10 interesting jQuery plugins (september 2011)" /> 10 interesting jQuery plugins (september 2011)</a></li><li> <a
href="http://www.script-tutorials.com/10-interesting-jquery-plugins-august-2011/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/131/thumb.png" alt="10 interesting jQuery plugins (august 2011)" /> 10 interesting jQuery plugins (august 2011)</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Ten fresh interesting jQuery plugins (november 2011)" src="http://www.script-tutorials.com/demos/195/thumb.png"></div><p><strong>10 interesting jQuery plugins (november 2011)</strong><br
/> <br
/>Today I have collected with own hands new most interesting jQuery plugins that have released over the last month. Here are different plugins like face detector, sliders, plugins for forms, even full UI widgets pack etc.<br
/> <span
id="more-1274"></span></p><hr
/><h3><a
rel="nofollow" target="_blank" href="https://github.com/jaysalvat/jquery.facedetection">1. Face detection</a></h3><p>A jQuery plugin which detects faces in pictures and returns theirs coords. This plugin uses an algorithm by Liu Liu. Online demo you can find <a
rel="nofollow" target="_blank" href="http://facedetection.jaysalvat.com/">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img1.jpg" alt="Face detection" /></p><h3><a
rel="nofollow" target="_blank" href="http://isotope.metafizzy.co/index.html">2. Isotope</a></h3><p>Isotope is an exquisite jQuery plugin for magical layouts. You can find demo at same page.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img2.jpg" alt="Isotope" /></p><h3><a
rel="nofollow" target="_blank" href="http://christianv.github.com/jquery-lifestream/">3. jQuery Lifestream</a></h3><p>This plugin can help you to create own activity feed (SPY) of your website. Online demo you can find <a
rel="nofollow" target="_blank" href="http://christianv.github.com/jquery-lifestream/example.html">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img3.jpg" alt="jQuery Lifestream" /></p><h3><a
rel="nofollow" target="_blank" href="https://github.com/christophercliff/sausage">4. Sausage</a></h3><p>This is jQuery UI widget for contextual pagination for your pages. Pagination can be really user friendly! Online demo you can find <a
rel="nofollow" target="_blank" href="http://christophercliff.github.com/sausage/examples/couchdb.html">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img4.jpg" alt="sausage" /></p><h3><a
rel="nofollow" target="_blank" href="http://buildinternet.com/project/supersized/">5. Supersized</a></h3><p>Supersized is a fullscreen background slideshow built using the jQuery library. Online demo you can find <a
rel="nofollow" target="_blank" href="http://buildinternet.com/project/supersized/slideshow/3.2/demo.html">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img5.jpg" alt="Supersized" /></p><h3><a
rel="nofollow" target="_blank" href="https://github.com/davatron5000/FitVids.js">6. FitVids.js</a></h3><p>A lightweight, easy-to-use jQuery plugin for fluid width video embeds. Online demo you can find <a
rel="nofollow" target="_blank" href="http://fitvidsjs.com/">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img6.jpg" alt="FitVids.js" /></p><h3><a
rel="nofollow" target="_blank" href="https://github.com/harvesthq/chosen/">7. Chosen</a></h3><p>Chosen is a library for making long, unwieldy select boxes (combo boxes) more user friendly. Online demo you can find <a
rel="nofollow" target="_blank" href="http://harvesthq.github.com/chosen/">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img7.jpg" alt="Chosen" /></p><h3><a
rel="nofollow" target="_blank" href="http://www.jqwidgets.com/">8. jQuery Widgets</a></h3><p>jQWidgets gives us something new and special. It’s a new and unique library for jQuery UI development and unlike others it makes our Apps and Websites look beautiful on desktops, touch devices and mobile phones. Online demo you can find <a
rel="nofollow" target="_blank" href="http://www.jqwidgets.com/jquery-widgets-demo/">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img8.jpg" alt="jQuery Widgets" /></p><h3><a
rel="nofollow" target="_blank" href="https://github.com/nathansmith/formalize">9. Formalize</a></h3><p>Teach your forms some manners &#8211; this plugin allow us to enhance our forms. Online demo you can find <a
rel="nofollow" target="_blank" href="http://formalize.me/demo.html">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img9.jpg" alt="Formalize" /></p><h3><a
rel="nofollow" target="_blank" href="http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/">10. Background Image Slider</a></h3><p>And finally, our own original image slider here. Online demo you can find <a
rel="nofollow" target="_blank" href="http://www.script-tutorials.com/demos/185/index.html">here</a>.<br
/> <img
src="http://www.script-tutorials.com/demos/195/img10.jpg" alt="Background Image Slider" /></p><hr
/><h3>Conclusion</h3><p>Hope that our new collection of new jQuery plugins was interested for you. Good luck!</p><div
class="shr-publisher-1274"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/10-interesting-jquery-plugins-of-october-2011/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/175/thumb.png" alt="10 interesting jQuery plugins of October 2011" /> <br
/> 10 interesting jQuery plugins of October 2011</a></li><li> <a
href="http://www.script-tutorials.com/10-interesting-jquery-plugins-september-2011/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/151/thumb.png" alt="10 interesting jQuery plugins (september 2011)" /> <br
/> 10 interesting jQuery plugins (september 2011)</a></li><li> <a
href="http://www.script-tutorials.com/10-interesting-jquery-plugins-august-2011/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/131/thumb.png" alt="10 interesting jQuery plugins (august 2011)" /> <br
/> 10 interesting jQuery plugins (august 2011)</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/10-interesting-jquery-plugins-november-2011/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Cool Background Image Sliding effect with jQuery</title><link>http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/</link> <comments>http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/#comments</comments> <pubDate>Fri, 18 Nov 2011 17:55:19 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[animation]]></category> <category><![CDATA[background]]></category> <category><![CDATA[effect]]></category> <category><![CDATA[sliding]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1222</guid> <description><![CDATA[Cool Background Image Sliding effect with jQuery Today I am going to show you how to create sliding image cell effect. This is will something like small photo gallery. I prepared 3 demos for you with different effects. Please pay attention that our demo will work in browsers that support used CSS3 properties. Live Demo [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/71/thumb.png" alt="Cross-browser Supported Image Skew effect using Javascript" /> Cross-browser Supported Image Skew effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/jquery-css-tutorial-zooming-image/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/3/images/ajax_small.gif" alt="Jquery CSS Tutorial on Zooming Image" /> Jquery CSS Tutorial on Zooming Image</a></li><li> <a
href="http://www.script-tutorials.com/creating-css3-drop-sliding-list-menu-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/113/thumb.png" alt="Creating CSS3 Drop sliding list Menu #6" /> Creating CSS3 Drop sliding list Menu #6</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Cool Background Image Sliding effect with jQuery" alt="Cool Background Image Sliding effect with jQuery" src="http://www.script-tutorials.com/demos/185/thumb.png"></div><p><strong>Cool Background Image Sliding effect with jQuery</strong><br
/> <br
/>Today I am going to show you how to create sliding image cell effect. This is will something like small photo gallery. I prepared 3 demos for you with different effects. Please pay attention that our demo will work in browsers that support used CSS3 properties.<br
/> <span
id="more-1222"></span></p><h5 style="text-align: center;"><strong><a
title="Cool Background Image Sliding effect with jQuery - demo 185" href="http://www.script-tutorials.com/demos/185/index.html" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Cool Background Image Sliding effect with jQuery - package" href="http://www.script-tutorials.com/demos/185/source.zip" target="_blank">download result</a></strong></h5><hr
/><p>Ok, download the example files and lets start coding !</p><hr
/><h3>Step 1. HTML</h3><p>Here are full html code of our result. For our demonstration I use 5 photos &#8211; same amount of &#8216;navigation&#8217; elements you can see here too.</p><h4>index.html</h4><pre class="brush:html">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Cool Background Image Sliding effect with jQuery | Script Tutorials&lt;/title&gt;
        &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;

        &lt;!--[if lt IE 9]&gt;
          &lt;script src=&quot;http://html5shiv.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
        &lt;![endif]--&gt;
        &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;js/main.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div class=&quot;container&quot; id=&quot;container&quot;&gt;
            &lt;ul class=&quot;nav&quot;&gt;
                &lt;li id=&quot;m1&quot;&gt;Pic 1&lt;/li&gt;
                &lt;li id=&quot;m2&quot;&gt;Pic 2&lt;/li&gt;
                &lt;li id=&quot;m3&quot;&gt;Pic 3&lt;/li&gt;
                &lt;li id=&quot;m4&quot;&gt;Pic 4&lt;/li&gt;
                &lt;li id=&quot;m5&quot;&gt;Pic 5&lt;/li&gt;
            &lt;/ul&gt;

            &lt;ul class=&quot;grid&quot;&gt;
                &lt;li id=&quot;g1&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g2&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g3&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g4&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g5&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
                &lt;li id=&quot;g6&quot;&gt;
                    &lt;div class=&quot;d1&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d2&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d3&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d4&quot;&gt;&lt;/div&gt;
                    &lt;div class=&quot;d5&quot;&gt;&lt;/div&gt;
                &lt;/li&gt;
            &lt;/ul&gt;
            &lt;ul class=&quot;demos&quot;&gt;
                &lt;li&gt;&lt;a href=&quot;index.html&quot;&gt;Demo 1&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;index2.html&quot;&gt;Demo 2&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;index3.html&quot;&gt;Demo 3&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
        &lt;/div&gt;
        &lt;footer&gt;
            &lt;h2&gt;Cool Background Image Sliding effect with jQuery&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/footer&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><h3>Step 2. CSS</h3><p>Now &#8211; our CSS styles. I will omit unnecessary styles of page layout, but will show you most important</p><h4>css/main.css</h4><pre class="brush:css">
.nav {
    background-color:#DDD;
    list-style:none outside none;
    overflow:hidden;
    padding:5px 140px;
}
.nav li {
    border-radius:10px;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;

    border:2px outset #000000;
    color:#000;
    cursor:pointer;
    float:left;
    font-size:18px;
    font-weight:bold;
    margin-right:5px;
    padding:10px;
}

.demos {
    background-color:#DDD;
    list-style:none outside none;
    overflow:hidden;
    padding:5px 165px;
}
.demos li {
    border-radius:10px;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;

    border:2px outset #000000;
    color:#000;
    float:left;
    font-size:18px;
    font-weight:bold;
    margin-right:5px;
    padding:10px;
}
.demos li a {
    color:#000;
    cursor:pointer;
    display:block;
    font-size:20px;
    font-weight:bold;
    height:30px;
    line-height:30px;
    text-decoration:none;
}

.grid {
    background-color:#DDD;
    list-style:none outside none;
    width:100%;
}
.grid li {
    border:1px solid #777777;
    float:left;
    height:240px;
    width:211px;

    transition:all 0.5s linear;
    -moz-transition:all 0.5s linear;
    -o-transition:all 0.5s linear;
    -webkit-transition:all 0.5s linear;
}
.grid li div {
    transition:all 0.5s ease-in-out;
    -moz-transition:all 0.5s ease-in-out;
    -o-transition:all 0.5s ease-in-out;
    -webkit-transition:all 0.5s ease-in-out;

    float:left;
}
.grid li .d1 {
    background:transparent url(../images/grid1.jpg) no-repeat top left;
    height:100%;
    width:211px;
}
.grid li .d2 {
    background:transparent url(../images/grid2.jpg) no-repeat top left;
    height:100%;
    width:0;
}
.grid li .d3 {
    background:transparent url(../images/grid3.jpg) no-repeat top left;
    height:100%;
    width:0;
}
.grid li .d4 {
    background:transparent url(../images/grid4.jpg) no-repeat top left;
    height:100%;
    width:0;
}
.grid li .d5 {
    background:transparent url(../images/grid5.jpg) no-repeat top left;
    height:100%;
    width:0;
}
.grid li#g2 div {
    background-position:-211px 0;
}
.grid li#g3 div {
    background-position:-422px 0;
}
.grid li#g4 div {
    background-position:0 -240px;
}
.grid li#g5 div {
    background-position:-211px -240px;
}
.grid li#g6 div {
    background-position:-422px -240px;
}
</pre><p>As you can see &#8211; each grid cell element (LI) have some defined background, but with own background positions. And, I will use jQuery &#8216;animate&#8217; to shift these positions when we will switch our images (through navigation)</p><h3>Step 3. jQuery</h3><h4>js/main.js</h4><pre class="brush:js">
$(function(){
    $(&quot;.nav li&quot;).hover(
      function () {
        $('.grid li div').stop().animate({width:&quot;0&quot;},0);

        var ind = $(&quot;.nav li&quot;).index(this);
        $($('.grid li#g1 div')[ind]).stop().animate({width:&quot;211px&quot;},0);
        $($('.grid li#g2 div')[ind]).stop().animate({width:&quot;211px&quot;},50);
        $($('.grid li#g3 div')[ind]).stop().animate({width:&quot;211px&quot;},100);
        $($('.grid li#g4 div')[ind]).stop().animate({width:&quot;211px&quot;},150);
        $($('.grid li#g5 div')[ind]).stop().animate({width:&quot;211px&quot;},200);
        $($('.grid li#g6 div')[ind]).stop().animate({width:&quot;211px&quot;},250);
      }
    );
});
</pre><p>As you can see &#8211; all very easy.</p><hr
/><h5 style="text-align: center;"><strong><a
title="Cool Background Image Sliding effect with jQuery - demo 185" href="http://www.script-tutorials.com/demos/185/index.html" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Cool Background Image Sliding effect with jQuery - package" href="http://www.script-tutorials.com/demos/185/source.zip" target="_blank" rel="nofollow">download result</a></strong></h5><hr
/><h3>Conclusion</h3><p>All another demos very similar, only few changes in styles and javascript code. You are welcome to play with our demos. Good luck!</p><div
class="shr-publisher-1222"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/cross-browser-image-shaking-effect-using-javascript/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/71/thumb.png" alt="Cross-browser Supported Image Skew effect using Javascript" /> <br
/> Cross-browser Supported Image Skew effect using Javascript</a></li><li> <a
href="http://www.script-tutorials.com/jquery-css-tutorial-zooming-image/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/3/images/ajax_small.gif" alt="Jquery CSS Tutorial on Zooming Image" /> <br
/> Jquery CSS Tutorial on Zooming Image</a></li><li> <a
href="http://www.script-tutorials.com/creating-css3-drop-sliding-list-menu-6/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/113/thumb.png" alt="Creating CSS3 Drop sliding list Menu #6" /> <br
/> Creating CSS3 Drop sliding list Menu #6</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/cool-background-image-sliding-effect-with-jquery/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Creating Your Own Ajax Poll System</title><link>http://www.script-tutorials.com/creating-own-ajax-poll-system/</link> <comments>http://www.script-tutorials.com/creating-own-ajax-poll-system/#comments</comments> <pubDate>Wed, 16 Nov 2011 17:38:11 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[ajax tutorial]]></category> <category><![CDATA[poll]]></category> <category><![CDATA[polling system]]></category> <category><![CDATA[system]]></category> <category><![CDATA[tutorial]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1213</guid> <description><![CDATA[Creating own ajax poll system Today I prepared new interesting tutorial &#8211; we will creating own Poll system (AJAX) for your projects with PHP. Polls, answers and results I going to keep in single SQL table. When we will vote for one of variants &#8211; jQuery will POST data, and then we will animate our [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/how-to-create-own-commenting-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/163/thumb.png" alt="Creating Your Own Commenting System from Scratch" /> Creating Your Own Commenting System from Scratch</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-own-voting-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/155/thumb.png" alt="How to Create Your Own 5 Stars Voting System" /> How to Create Your Own 5 Stars Voting System</a></li><li> <a
href="http://www.script-tutorials.com/ajax-file-upload-methods/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="Creating Ajax based file uploaders" /> Creating Ajax based file uploaders</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="Creating own ajax poll system" alt="Creating own ajax poll system" src="http://www.script-tutorials.com/demos/183/thumb.png"></div><p><strong>Creating own ajax poll system</strong><br
/> <br
/>Today I prepared new interesting tutorial &#8211; we will creating own Poll system (AJAX) for your projects with PHP. Polls, answers and results I going to keep in single SQL table. When we will vote for one of variants &#8211; jQuery will POST data, and then we will animate our results in realtime.<br
/> <span
id="more-1213"></span></p><h5 style="text-align: center;"><strong><a
title="Creating own ajax poll system - demo 183" href="http://www.script-tutorials.com/demos/183/index.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Creating own ajax poll system - package" href="http://www.script-tutorials.com/demos/183/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Now &#8211; download the source files and lets start coding !</p><hr
/><h3>Step 1. SQL</h3><p>We will need to add one table into our database:</p><pre class="brush:php">
CREATE TABLE `s183_polls` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(255) default '',
  `answers` text NOT NULL,
  `results` varchar(60) NOT NULL default '',
  `total_votes` int(10) NOT NULL default '0',
  `when` int(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

INSERT INTO `s183_polls` (`id`, `title`, `answers`, `results`, `total_votes`, `when`) VALUES
(NULL, 'First poll question', 'Answer 1&lt;sep&gt;Answer 2&lt;sep&gt;Answer 3&lt;sep&gt;Answer 4', '', 0, UNIX_TIMESTAMP()),
(NULL, 'Second poll question', 'Answer 21&lt;sep&gt;Answer 22&lt;sep&gt;Answer 23&lt;sep&gt;Answer 24', '', 0, UNIX_TIMESTAMP()+1),
(NULL, 'Third poll question', 'Answer 31&lt;sep&gt;Answer 32&lt;sep&gt;Answer 33&lt;sep&gt;Answer 34', '', 0, UNIX_TIMESTAMP()+2),
(NULL, 'Forth poll question', 'Answer 41&lt;sep&gt;Answer 42&lt;sep&gt;Answer 43&lt;sep&gt;Answer 44', '', 0, UNIX_TIMESTAMP()+3),
(NULL, 'Fifth poll question', 'Answer 51&lt;sep&gt;Answer 52&lt;sep&gt;Answer 53&lt;sep&gt;Answer 54', '', 0, UNIX_TIMESTAMP()+4);
</pre><p>This is pur main Polls table.</p><h3>Step 2. PHP</h3><p>Here are source code of our main file:</p><h4>index.php</h4><pre class="brush:php">
&lt;?php
// disable  warnings
if (version_compare(phpversion(), &quot;5.3.0&quot;, &quot;&gt;=&quot;)  == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE); 

require_once('classes/CMySQL.php'); // including service class to work with database

if ($_POST['do'] == 'vote') { // in case if we submitted poll
    $iPollId = (int)$_POST['id'];
    $iAnswer = (int)$_POST['answer'];

    if ($iPollId &amp;&amp; $iAnswer &gt;= 0 &amp;&amp; ! isset($_COOKIE['av' . $iPollId])) {
        // get poll info
        $aPollInfo = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `s183_polls` WHERE `id` = '{$iPollId}'&quot;);

        // updating of poll results
        $aAnswers = explode('&lt;sep&gt;', $aPollInfo['answers']);
        $iCnt = count($aAnswers);
        $aVotes = ($aPollInfo['results'] == '') ? array_fill(0, $iCnt, 0) : explode('&lt;sep&gt;', $aPollInfo['results']);
        $aVotes[$iAnswer]++;
        $iVotesCount = array_sum($aVotes);
        $sVotes = implode('&lt;sep&gt;', $aVotes);
        $GLOBALS['MySQL']-&gt;res(&quot;UPDATE `s183_polls` SET `results` = '{$sVotes}', `total_votes` = {$iVotesCount} WHERE `id` = {$iPollId}&quot;);

        // recalculation of percents
        $iVotesCnt = $aPollInfo['total_votes'] + 1;
        $aPercents = array();
        foreach ($aAnswers as $i =&gt; $sAnswer) {
            $aPercents[$i] = round( (0 != $iVotesCnt ? (( $aVotes[$i] / $iVotesCnt ) * 100) : 0), 1);
        }

        setcookie('av' . $iPollId, '1', time() + 24*3600, '/'); // easy protection from duplicate votes

        // return back to JS
        echo json_encode($aPercents);
        exit;
    } else {
        exit;
    }
}

$sCode = '';
$iItemId = (int)$_GET['id'];
if ($iItemId) { // View item output
    $aItemInfo = $GLOBALS['MySQL']-&gt;getRow(&quot;SELECT * FROM `s183_polls` WHERE `id` = '{$iItemId}'&quot;); // get poll info

    $aAnswers = explode('&lt;sep&gt;', $aItemInfo['answers']);
    $iCnt = count($aAnswers);
    $aVotes = ($aItemInfo['results'] == '') ? array_fill(0, $iCnt, 0) : explode('&lt;sep&gt;', $aItemInfo['results']);

    $iVotesCnt = $aItemInfo['total_votes'];

    $sAnswers = '';
    foreach ($aAnswers as $i =&gt; $sAnswer) {
        $fPercent = round((0 != $iVotesCnt ? (($aVotes[$i] / $iVotesCnt) * 100) : 0), 1);
        $sAnswers .= &quot;&lt;div id='{$i}'&gt;&lt;div&gt;{$sAnswer} (&lt;span&gt;{$aVotes[$i]}&lt;/span&gt;)&lt;/div&gt;&lt;div class='row' style='width:{$fPercent}%'&gt;{$fPercent}%&lt;/div&gt;&lt;/div&gt;&quot;;
    }

    ob_start();
    ?&gt;
&lt;h1&gt;&lt;?= $aItemInfo['title'] ?&gt;&lt;/h1&gt;
&lt;h3&gt;&lt;?= date('F j, Y', $aItemInfo['when']) ?&gt;&lt;/h3&gt;&lt;hr /&gt;
&lt;div class=&quot;answers&quot;&gt;&lt;?= $sAnswers ?&gt;&lt;/div&gt;
&lt;hr /&gt;&lt;h3&gt;&lt;a href=&quot;&lt;?= $_SERVER['PHP_SELF'] ?&gt;&quot;&gt;back&lt;/a&gt;&lt;/h3&gt;
&lt;script&gt;
$(function(){
    $('.answers &gt; div').click(function () {

        var answer = $(this).attr('id');
        var $span = $(this).find('span');

        $.post('&lt;?= $_SERVER['PHP_SELF'] ?&gt;', {id: &lt;?= $iItemId ?&gt;, answer: answer, do: 'vote'},
            function(data){
                if (data) {
                    var da = eval('(' + data + ')');
                    for (var p in da) {
                        $($('.answers &gt; div .row')[p]).animate({
                            width: da[p] + &quot;%&quot;
                        }, 500);
                        $($('.answers &gt; div .row')[p]).text(da[p] + &quot;%&quot;);
                    }
                    $span.text(parseInt($span.text()) + 1);
                }
            }
        );
    });
});
&lt;/script&gt;
    &lt;?
    $sCode .= ob_get_clean();
} else {
    $sCode .= '&lt;h1&gt;List of polls:&lt;/h1&gt;';

    // taking info about all polls from database
    $aItems = $GLOBALS['MySQL']-&gt;getAll(&quot;SELECT * FROM `s183_polls` ORDER by `when` ASC&quot;);
    foreach ($aItems as $i =&gt; $aItemInfo) {
        $sCode .= '&lt;h2&gt;&lt;a href=&quot;'.$_SERVER['PHP_SELF'].'?id='.$aItemInfo['id'].'&quot;&gt;'.$aItemInfo['title'].'&lt;/a&gt;&lt;/h2&gt;';
    }
}

?&gt;
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;Creating own ajax poll system | Script Tutorials&lt;/title&gt;

        &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery-1.5.2.min.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div class=&quot;container&quot;&gt;
            &lt;?= $sCode ?&gt;
        &lt;/div&gt;
        &lt;footer&gt;
            &lt;h2&gt;Creating own own ajax poll system&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/creating-own-ajax-poll-system/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/footer&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><p>When we open this page in first time &#8211; it will draw list of polls. Each poll unit have own page. At this page we going to display Poll title, date of adding and all possible answers. On click &#8211; script will send (POST) data to same script. In this moment we are adding this vote, and then we will send back new percentages for all variants. And jQuery will re-animate all these bars. I added my comments in most of places for better understanding.</p><p>I have another one PHP file in my project:</p><h4>classes/CMySQL.php</h4><p>This is service class to work with database prepared by me. This is nice class which you can use too. Database connection details present in that class file in few variables, sure that you will able to configure this to your database. I will not publish sources of this file &#8211; this is not necessary right now. Available in package.</p><h3>Step 3. JS</h3><h4>js/jquery-1.5.2.min.js</h4><p>This is just jQuery library. Available in package.</p><h3>Step 4. CSS</h3><p>Now &#8211; all used CSS styles:</p><h4>css/main.css</h4><pre class="brush:js">
*{
    margin:0;
    padding:0;
}
body {
    background-repeat:no-repeat;
    background-color:#bababa;
    background-image: -webkit-radial-gradient(600px 200px, circle, #eee, #bababa 40%);
    background-image: -moz-radial-gradient(600px 200px, circle, #eee, #bababa 40%);
    background-image: -o-radial-gradient(600px 200px, circle, #eee, #bababa 40%);
    background-image: radial-gradient(600px 200px, circle, #eee, #bababa 40%);
    color:#fff;
    font:14px/1.3 Arial,sans-serif;
    min-height:600px;
}
footer {
    background-color:#212121;
    bottom:0;
    box-shadow: 0 -1px 2px #111111;
    display:block;
    height:70px;
    left:0;
    position:fixed;
    width:100%;
    z-index:100;
}
footer h2{
    font-size:22px;
    font-weight:normal;
    left:50%;
    margin-left:-400px;
    padding:22px 0;
    position:absolute;
    width:540px;
}
footer a.stuts,a.stuts:visited{
    border:none;
    text-decoration:none;
    color:#fcfcfc;
    font-size:14px;
    left:50%;
    line-height:31px;
    margin:23px 0 0 110px;
    position:absolute;
    top:0;
}
footer .stuts span {
    font-size:22px;
    font-weight:bold;
    margin-left:5px;
}
.container {
    border:3px #111 solid;
    color:#000;
    margin:20px auto;
    padding:15px;
    position:relative;
    text-align:center;
    width:500px;

    border-radius:15px;
    -moz-border-radius:15px;
    -webkit-border-radius:15px;
}

.answers &gt; div {
    cursor:pointer;
    margin:0 0 0 40px;
    padding:10px;
    text-align:left;
}
.answers &gt; div:hover {
    background-color: rgba(255, 255, 255, 0.4);
}
.answers div .row {
     background-color:#0f0;
}
</pre><hr
/><h5 style="text-align: center;"><strong><a
title="Creating own ajax poll system - demo 183" href="http://www.script-tutorials.com/demos/183/index.php" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="Creating own ajax poll system - package" href="http://www.script-tutorials.com/demos/183/source.zip" target="_blank" rel="nofollow">download in archive</a></strong></h5><hr
/><h3>Conclusion</h3><p>Today we prepared great AJAX Poll system for your website. Sure that this material will useful for your own projects. Good luck in your work!</p><div
class="shr-publisher-1213"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/how-to-create-own-commenting-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/163/thumb.png" alt="Creating Your Own Commenting System from Scratch" /> <br
/> Creating Your Own Commenting System from Scratch</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-own-voting-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/155/thumb.png" alt="How to Create Your Own 5 Stars Voting System" /> <br
/> How to Create Your Own 5 Stars Voting System</a></li><li> <a
href="http://www.script-tutorials.com/ajax-file-upload-methods/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="Creating Ajax based file uploaders" /> <br
/> Creating Ajax based file uploaders</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/creating-own-ajax-poll-system/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Creating a Diary style PHP Guestbook</title><link>http://www.script-tutorials.com/php-guestbook/</link> <comments>http://www.script-tutorials.com/php-guestbook/#comments</comments> <pubDate>Mon, 07 Nov 2011 18:02:58 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[HTML/CSS]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[diary]]></category> <category><![CDATA[guestbook]]></category> <category><![CDATA[script]]></category> <category><![CDATA[style]]></category> <category><![CDATA[tutorial]]></category><guid
isPermaLink="false">http://www.script-tutorials.com/?p=1187</guid> <description><![CDATA[PHP guestbook Today I prepared new interesting tutorial &#8211; I will tell how you can create ajax PHP guestbook with own unique design. Our records will be saved into SQL database. This table will contain next info: name of sender, email, guestbook record, date-time of record and ip of sender. Of course, we will use [...]<div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/how-to-make-a-php-guestbook-with-math-captcha-security/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="How to make a PHP Guestbook with Math Captcha Security" /> How to make a PHP Guestbook with Math Captcha Security</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-own-commenting-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/163/thumb.png" alt="Creating Your Own Commenting System from Scratch" /> Creating Your Own Commenting System from Scratch</a></li><li> <a
href="http://www.script-tutorials.com/autocomplete-with-php-jquery-mysql-and-xml/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/160/thumb.png" alt="Autocomplete with PHP, jQuery, MySQL and XML" /> Autocomplete with PHP, jQuery, MySQL and XML</a></li></ol></div>]]></description> <content:encoded><![CDATA[<div
class="thumb"><img
width="128" height="128" class="aligncenter" title="PHP guestbook" alt="PHP guestbook" src="http://www.script-tutorials.com/demos/178/thumb.png"></div><p><strong>PHP guestbook</strong><br
/> <br
/>Today I prepared new interesting tutorial &#8211; I will tell how you can create ajax PHP guestbook with own unique design. Our records will be saved into SQL database. This table will contain next info: name of sender, email, guestbook record, date-time of record and ip of sender. Of course, we will use jQuery too (to make it ajaxy). One of important features will spam protection (we can post no more than one record every 10 minutes)!<br
/> <span
id="more-1187"></span></p><h5 style="text-align: center;"><strong><a
title="PHP guestbook - demo 178" href="http://www.script-tutorials.com/demos/178/guestbook.php" target="_blank">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="PHP guestbook - package" href="http://www.script-tutorials.com/demos/178/source.zip" target="_blank">download in package</a></strong></h5><hr
/><p>Now &#8211; download the source files and lets start coding !</p><hr
/><h3>Step 1. SQL</h3><p>We need to add one table to our database (to store our records):</p><pre class="brush:php">
CREATE TABLE IF NOT EXISTS `s178_guestbook` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(255) default '',
  `email` varchar(255) default '',
  `description` varchar(255) default '',
  `when` int(11) NOT NULL default '0',
  `ip` varchar(20) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
</pre><h3>Step 2. PHP</h3><p>Here are source code of our main file:</p><h4>guestbook.php</h4><pre class="brush:php">
&lt;?php
// disabling possible warnings
if (version_compare(phpversion(), &quot;5.3.0&quot;, &quot;&gt;=&quot;)  == 1)
  error_reporting(E_ALL &amp; ~E_NOTICE &amp; ~E_DEPRECATED);
else
  error_reporting(E_ALL &amp; ~E_NOTICE); 

require_once('classes/CMySQL.php'); // including service class to work with database

// get visitor IP
function getVisitorIP() {
    $ip = &quot;0.0.0.0&quot;;
    if( ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) &amp;&amp; ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } elseif( ( isset( $_SERVER['HTTP_CLIENT_IP'])) &amp;&amp; (!empty($_SERVER['HTTP_CLIENT_IP'] ) ) ) {
        $ip = explode(&quot;.&quot;,$_SERVER['HTTP_CLIENT_IP']);
        $ip = $ip[3].&quot;.&quot;.$ip[2].&quot;.&quot;.$ip[1].&quot;.&quot;.$ip[0];
    } elseif((!isset( $_SERVER['HTTP_X_FORWARDED_FOR'])) || (empty($_SERVER['HTTP_X_FORWARDED_FOR']))) {
        if ((!isset( $_SERVER['HTTP_CLIENT_IP'])) &amp;&amp; (empty($_SERVER['HTTP_CLIENT_IP']))) {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
    }
    return $ip;
}

// get last guestbook records
function getLastRecords($iLimit = 3) {
    $sRecords = '';
    $aRecords = $GLOBALS['MySQL']-&gt;getAll(&quot;SELECT * FROM `s178_guestbook` ORDER BY `id` DESC LIMIT {$iLimit}&quot;);
    foreach ($aRecords as $i =&gt; $aInfo) {
        $sWhen = date('F j, Y H:i', $aInfo['when']);
        $sRecords .= &lt;&lt;&lt;EOF
&lt;div class=&quot;record&quot; id=&quot;{$aInfo['id']}&quot;&gt;
    &lt;p&gt;Record from {$aInfo['name']} &lt;span&gt;({$sWhen})&lt;/span&gt;:&lt;/p&gt;
    &lt;p&gt;{$aInfo['description']}&lt;/p&gt;
&lt;/div&gt;
EOF;
    }
    return $sRecords;
}

if ($_POST) { // accepting new records

    $sIp = getVisitorIP();
    $sName = $GLOBALS['MySQL']-&gt;escape(strip_tags($_POST['name']));
    $sEmail = $GLOBALS['MySQL']-&gt;escape(strip_tags($_POST['name']));
    $sDesc = $GLOBALS['MySQL']-&gt;escape(strip_tags($_POST['text']));

    if ($sName &amp;&amp; $sEmail &amp;&amp; $sDesc &amp;&amp; $sIp) {

        // spam protection
        $iOldId = $GLOBALS['MySQL']-&gt;getOne(&quot;SELECT `id` FROM `s178_guestbook` WHERE `ip` = '{$sIp}' AND `when` &gt;= UNIX_TIMESTAMP() - 600 LIMIT 1&quot;);
        if (! $iOldId) {

            // allow to add comment
            $GLOBALS['MySQL']-&gt;res(&quot;INSERT INTO `s178_guestbook` SET `name` = '{$sName}', `email` = '{$sEmail}', `description` = '{$sDesc}', `when` = UNIX_TIMESTAMP(), `ip` = '{$sIp}'&quot;);

            // drawing last 10 records
            $sOut = getLastRecords();
            echo $sOut;
            exit;
        }
    }
    echo 1;
    exit;
}

// drawing last 10 records
$sRecords = getLastRecords();

ob_start();
?&gt;
&lt;div class=&quot;container&quot; id=&quot;records&quot;&gt;
    &lt;div id=&quot;col1&quot;&gt;
        &lt;h2&gt;Guestbook Records&lt;/h2&gt;
        &lt;div id=&quot;records_list&quot;&gt;&lt;?= $sRecords ?&gt;&lt;/div&gt;
    &lt;/div&gt;

    &lt;div id=&quot;col2&quot;&gt;
        &lt;h2&gt;Add your record here&lt;/h2&gt;
        &lt;script type=&quot;text/javascript&quot;&gt;
        function submitComment(e) {
            var name = $('#name').val();
            var email = $('#email').val();
            var text = $('#text').val();

            if (name &amp;&amp; email &amp;&amp; text) {
                $.post('guestbook.php', { 'name': name, 'email': email, 'text': text },
                    function(data){
                        if (data != '1') {
                          $('#records_list').fadeOut(1000, function () {
                            $(this).html(data);
                            $(this).fadeIn(1000);
                          });
                        } else {
                          $('#warning2').fadeIn(2000, function () {
                            $(this).fadeOut(2000);
                          });
                        }
                    }
                );
            } else {
              $('#warning1').fadeIn(2000, function () {
                $(this).fadeOut(2000);
              });
            }
        };
        &lt;/script&gt;

        &lt;form onsubmit=&quot;submitComment(this); return false;&quot;&gt;
            &lt;table&gt;
                &lt;tr&gt;&lt;td class=&quot;label&quot;&gt;&lt;label&gt;Your name: &lt;/label&gt;&lt;/td&gt;&lt;td class=&quot;field&quot;&gt;&lt;input type=&quot;text&quot; value=&quot;&quot; title=&quot;Please enter your name&quot; id=&quot;name&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
                &lt;tr&gt;&lt;td class=&quot;label&quot;&gt;&lt;label&gt;Your email: &lt;/label&gt;&lt;/td&gt;&lt;td class=&quot;field&quot;&gt;&lt;input type=&quot;text&quot; value=&quot;&quot; title=&quot;Please enter your email&quot; id=&quot;email&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
                &lt;tr&gt;&lt;td class=&quot;label&quot;&gt;&lt;label&gt;Comment: &lt;/label&gt;&lt;/td&gt;&lt;td class=&quot;field&quot;&gt;&lt;textarea name=&quot;text&quot; id=&quot;text&quot; maxlength=&quot;255&quot;&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
                &lt;tr&gt;&lt;td class=&quot;label&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class=&quot;field&quot;&gt;
                    &lt;div id=&quot;warning1&quot; style=&quot;display:none&quot;&gt;Don`t forget to fill all required fields&lt;/div&gt;
                    &lt;div id=&quot;warning2&quot; style=&quot;display:none&quot;&gt;You can post no more than one comment every 10 minutes (spam protection)&lt;/div&gt;
                    &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
                &lt;/td&gt;&lt;/tr&gt;
            &lt;/table&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;?
$sGuestbookBlock = ob_get_clean();

?&gt;
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot; &gt;
    &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;title&gt;PHP guestbook | Script Tutorials&lt;/title&gt;

        &lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
        &lt;!--[if lt IE 9]&gt;
          &lt;script src=&quot;http://html5shiv.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
        &lt;![endif]--&gt;
        &lt;script src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;?= $sGuestbookBlock ?&gt;
        &lt;footer&gt;
            &lt;h2&gt;PHP guestbook&lt;/h2&gt;
            &lt;a href=&quot;http://www.script-tutorials.com/php-guestbook/&quot; class=&quot;stuts&quot;&gt;Back to original tutorial on &lt;span&gt;Script Tutorials&lt;/span&gt;&lt;/a&gt;
        &lt;/footer&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre><p>When we open this page we will see book, at left side we will draw list of last three records, at right &#8211; form of posting new records. When we submitting form &#8211; script sending POST data (to same php page), script saving this data to database, and returning us list of fresh 3 records. Then, via fading effect we draw returned data at left column. All code contains comments &#8211; read it for better understanding code. Ok, next PHP file is:</p><h4>classes/CMySQL.php</h4><p>This is my own service class to work with database. This is nice class which you can use too. Database connection details located in this class in few variables, sure that you will able to configure this to your database. I don`t will publish its sources &#8211; this is not necessary for now. Available in package.</p><h3>Step 3. CSS</h3><p>Now &#8211; all used CSS styles:</p><h4>css/main.css</h4><pre class="brush:js">
*{
    margin:0;
    padding:0;
}
body {
    background-color:#fff;
    color:#fff;
    font:14px/1.3 Arial,sans-serif;
}
footer {
    background-color:#212121;
    bottom:0;
    box-shadow: 0 -1px 2px #111111;
    display:block;
    height:70px;
    left:0;
    position:fixed;
    width:100%;
    z-index:100;
}
footer h2{
    font-size:22px;
    font-weight:normal;
    left:50%;
    margin-left:-400px;
    padding:22px 0;
    position:absolute;
    width:540px;
}
footer a.stuts,a.stuts:visited{
    border:none;
    text-decoration:none;
    color:#fcfcfc;
    font-size:14px;
    left:50%;
    line-height:31px;
    margin:23px 0 0 110px;
    position:absolute;
    top:0;
}
footer .stuts span {
    font-size:22px;
    font-weight:bold;
    margin-left:5px;
}

.container {
    background: transparent url(../images/book_open.jpg) no-repeat top center ;
    color: #000000;
    height: 600px;
    margin: 20px auto;
    overflow: hidden;
    padding: 35px 100px;
    position: relative;
    width: 600px;
}
#col1, #col2 {
    float: left;
    margin: 0 10px;
    overflow: hidden;
    text-align: center;
    width: 280px;
}
#col1 {
    -webkit-transform: rotate(3deg);
    -moz-transform: rotate(3deg);
    -ms-transform: rotate(3deg);
    -o-transform: rotate(3deg);
}
#records form {
    margin:10px 0;
    padding:10px;
    text-align:left;
}
#records table td.label {
    color: #000;
    font-size: 13px;
    padding-right: 3px;
    text-align: right;
}
#records table label {
    font-size: 12px;
    vertical-align: middle;
}
#records table td.field input, #records table td.field textarea {
    background-color: rgba(255, 255, 255, 0.4);
    border: 0px solid #96A6C5;
    font-family: Verdana,Arial,sans-serif;
    font-size: 13px;
    margin-top: 2px;
    padding: 6px;
    width: 190px;
}
#records table td.field input[type=submit] {
    background-color: rgba(200, 200, 200, 0.4);
    cursor: pointer;
    float:right;
    width: 100px;
}
#records table td.field input[type=submit]:hover {
    background-color: rgba(200, 200, 200, 0.8);
}
#records_list {
    text-align:left;
}
#records_list .record {
    border-top: 1px solid #000000;
    font-size: 13px;
    padding: 10px;
}
#records_list .record:first-child {
    border-top-width:0px;
}
#records_list .record p:first-child {
    font-weight:bold;
    font-size:11px;
}
</pre><hr
/><h5 style="text-align: center;"><strong><a
title="PHP guestbook - demo 178" href="http://www.script-tutorials.com/demos/178/guestbook.php" target="_blank" rel="nofollow">Live Demo</a></strong></h5><h5 style="text-align: center;"><strong><a
title="PHP guestbook - package" href="http://www.script-tutorials.com/demos/178/source.zip" target="_blank" rel="nofollow">download in archive</a></strong></h5><hr
/><h3>Conclusion</h3><p>Today we have prepared great PHP guestbook for your website. Sure that this material will be useful for your own projects. Good luck in your work!</p><div
class="shr-publisher-1187"></div><div
id="main-related"><h4>Related Stuff You Will Love!</h4><ol
class="related-posts"><li> <a
href="http://www.script-tutorials.com/how-to-make-a-php-guestbook-with-math-captcha-security/" rel="bookmark"> <img
src="/ssimages/no_image.gif" alt="How to make a PHP Guestbook with Math Captcha Security" /> <br
/> How to make a PHP Guestbook with Math Captcha Security</a></li><li> <a
href="http://www.script-tutorials.com/how-to-create-own-commenting-system/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/163/thumb.png" alt="Creating Your Own Commenting System from Scratch" /> <br
/> Creating Your Own Commenting System from Scratch</a></li><li> <a
href="http://www.script-tutorials.com/autocomplete-with-php-jquery-mysql-and-xml/" rel="bookmark"> <img
src="http://www.script-tutorials.com/demos/160/thumb.png" alt="Autocomplete with PHP, jQuery, MySQL and XML" /> <br
/> Autocomplete with PHP, jQuery, MySQL and XML</a></li></ol></div>]]></content:encoded> <wfw:commentRss>http://www.script-tutorials.com/php-guestbook/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic (User agent is rejected)
Database Caching using disk: basic

Served from: www.script-tutorials.com @ 2012-02-04 21:51:41 -->
