diff --git a/codeigniter/.htaccess b/codeigniter/.htaccess new file mode 100644 index 0000000..8fbdab9 --- /dev/null +++ b/codeigniter/.htaccess @@ -0,0 +1,3 @@ +RewriteEngine on +RewriteCond $1 !^(index\.php|css|js|images|robots\.txt) +RewriteRule ^(.*)$ /index.php/$1 [L] \ No newline at end of file diff --git a/codeigniter/application/config/autoload.php b/codeigniter/application/config/autoload.php index 53129c9..a5768a2 100644 --- a/codeigniter/application/config/autoload.php +++ b/codeigniter/application/config/autoload.php @@ -52,7 +52,7 @@ | $autoload['libraries'] = array('database', 'session', 'xmlrpc'); */ -$autoload['libraries'] = array(); +$autoload['libraries'] = array('database','session','form_validation'); /* @@ -64,7 +64,7 @@ | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array(); +$autoload['helper'] = array('url','form'); /* diff --git a/codeigniter/application/config/config.php b/codeigniter/application/config/config.php index f7f125f..b5e76a4 100644 --- a/codeigniter/application/config/config.php +++ b/codeigniter/application/config/config.php @@ -14,7 +14,7 @@ | path to your installation. | */ -$config['base_url'] = ''; +$config['base_url'] = 'http://satishathome.net/'; /* |-------------------------------------------------------------------------- @@ -26,7 +26,7 @@ | variable so that it is blank. | */ -$config['index_page'] = 'index.php'; +$config['index_page'] = ''; /* |-------------------------------------------------------------------------- @@ -69,7 +69,7 @@ | than english. | */ -$config['language'] = 'japanese'; +$config['language'] = 'english'; /* |-------------------------------------------------------------------------- @@ -224,7 +224,7 @@ | MUST set an encryption key. See the user guide for info. | */ -$config['encryption_key'] = ''; +$config['encryption_key'] = 'REALLY_LONG_NUMBER'; /* |-------------------------------------------------------------------------- @@ -279,7 +279,7 @@ | COOKIE data is encountered | */ -$config['global_xss_filtering'] = FALSE; +$config['global_xss_filtering'] = TRUE; /* |-------------------------------------------------------------------------- @@ -293,7 +293,7 @@ | 'csrf_cookie_name' = The cookie name | 'csrf_expire' = The number in seconds the token should expire. */ -$config['csrf_protection'] = FALSE; +$config['csrf_protection'] = TRUE; $config['csrf_token_name'] = 'csrf_test_name'; $config['csrf_cookie_name'] = 'csrf_cookie_name'; $config['csrf_expire'] = 7200; diff --git a/codeigniter/application/config/constants.php b/codeigniter/application/config/constants.php index 4a879d3..7b0fb45 100644 --- a/codeigniter/application/config/constants.php +++ b/codeigniter/application/config/constants.php @@ -1,5 +1,9 @@ before(); + return call_user_func_array(array($this, $method), $args); + } + show_404(); //if the user enters any other function which is not in this class + } + + private function before() { + if($this->session->userdata('logged_in')){ + redirect('room','refresh'); + } + } + + public function index(){ + $data['message'] = NO_MESSAGE; + $this->load->view('loginView',$data); + } + + private function verifyLogin(){ + $this->form_validation->set_rules('username', 'Username', 'trim|xss_clean'); + $this->form_validation->set_rules('password', 'Password', 'trim|xss_clean'); + + if ($this->form_validation->run() == FALSE) { //if form validation fails, redirect to login page with message + $data['message'] = LOGIN_FAILED; + return $this->load->view('loginView',$data); + } else { //if form validation passes, get data and check database + $email = htmlspecialchars($_POST['email']); + $password = sha1(htmlspecialchars($_POST['password'])); + $this->load->model('users'); + $singleRowResult=$this->users->authenticate($email,$password); //the authenticate function is in model:users + } + + if ($singleRowResult) { //if user exists create session and redirect to room + $sess_array = array(); + $sess_array = array('userid' => $singleRowResult['userid'],'username' => $singleRowResult['username']); + $this->session->set_userdata('logged_in', $sess_array); + redirect('room','refresh'); + } else { // if user does not exist, redirect to login page with message + $data['message'] = LOGIN_FAILED; + $this->load->view('loginView',$data); + } + } +} diff --git a/codeigniter/application/controllers/register.php b/codeigniter/application/controllers/register.php new file mode 100644 index 0000000..023c9b1 --- /dev/null +++ b/codeigniter/application/controllers/register.php @@ -0,0 +1,48 @@ +before(); + return call_user_func_array(array($this, $method), $args); + } + show_404(); + } + + private function before() { + if($this->session->userdata('logged_in')){ + redirect('room','refresh'); + } + } + + public function index(){ + $this->load->view('registerView'); + } + + private function verifyRegister(){ + $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean'); + $this->form_validation->set_rules('email', 'Email', 'trim|xss_clean|required|valid_email|is_unique[users.email]'); + $this->form_validation->set_rules('password', 'Password', 'trim|xss_clean|required'); + $this->form_validation->set_rules('confirmPassword', 'Confirm Password', 'trim|xss_clean|matches[password]|required'); + + if ($this->form_validation->run() == FALSE){ // if form validation fails,load the registrationForm + $this->load->view('registerView'); + } else { //if form validation passes,authenticate,set the session and redirect to room + $username = htmlspecialchars($_POST['username']); + $password =sha1(htmlspecialchars($_POST['password'])); + $email = $_POST['email']; + $this->load->model('users'); + $isRegistered = $this->users->register($username,$email,$password); + if ($isRegistered) { + $singleRowResult=$this->users->authenticate($email,$password); + $sess_array = array(); + $sess_array = array('userid' => $singleRowResult['userid'],'username' => $singleRowResult['username']); + $this->session->set_userdata('logged_in', $sess_array); + redirect('room','refresh'); + } else { + echo("A technical error has occurred!"); + } + } + } +} \ No newline at end of file diff --git a/codeigniter/application/controllers/room.php b/codeigniter/application/controllers/room.php new file mode 100644 index 0000000..d6354c1 --- /dev/null +++ b/codeigniter/application/controllers/room.php @@ -0,0 +1,98 @@ +before(); + return call_user_func_array(array($this, $method), $args); + } + show_404(); //if the user enters any other function which is not in this class + } + + private function before() { + if($this->session->userdata('logged_in')){ + return true; + } + else{ + redirect('login','refresh'); + } + } + + public function index(){ + $posts = $this->showInitialPosts(); + if($posts){ //if result exists send the result to room for display + $data['jsonObject'] = $posts; + $this->load->view('roomView',$data); + } + else{ + $data['message'] = "NO_POSTS_YET"; + $this->load->view('roomView',$data); + } + } + + public function showInitialPosts(){ + $this->load->model('posts'); + $postsFromDB = $this->posts->getInitialPosts(); + + if ($postsFromDB) { + return json_encode($postsFromDB); + } else { + return false; + } + } + + public function showPosts($parameter){ + $postid = (int) $parameter; //type casting the parameter to integer will cause page to be 0 is it contains alphabets + + $this->load->model('posts'); + $postsFromDB = $this->posts->getPosts($postid); + + if ($postsFromDB) { + return json_encode($postsFromDB); + } else { + return false; + } + } + + public function ajaxDisplay(){ + $postid = $_POST['postid']; + $posts = $this->showPosts($postid); + if($posts){ + print_r($posts); //returns the JSON Object Array to ajax responseText + } + else{ + echo("[{\"message\":\"OUT_OF_INDEX\"}]"); + } + } + + public function ajaxPost(){ + $session_data = $this->session->userdata('logged_in'); + if(isset($_POST['status'])){ + $userid = $session_data['userid']; + $username = $session_data['username']; + $posts = $_POST['status']; + $time_of_post = date("Y-m-d H:i:s"); + + $this->load->model('posts'); + $insertPost = $this->posts->post($userid,$username,$posts,$time_of_post); + } else { + echo("VARIABLES_NOT_SET_IN_AJAXPOST"); + } + + if($insertPost){ + echo($time_of_post); + } + else{ + echo("POST_NOT_INSERTED"); + } + } + + public function logout(){ + $this->session->unset_userdata('logged_in'); + $this->session->sess_destroy(); + redirect('login', 'refresh'); + } +} + +?> diff --git a/codeigniter/application/controllers/room_1.php b/codeigniter/application/controllers/room_1.php new file mode 100644 index 0000000..97fdb6d --- /dev/null +++ b/codeigniter/application/controllers/room_1.php @@ -0,0 +1,100 @@ +before(); + return call_user_func_array(array($this, $method), $args); + } + show_404(); //if the user enters any other function which is not in this class + } + + private function before() { + if($this->session->userdata('logged_in')){ + return true; + } + else{ + redirect('login','refresh'); + } + } + + + public function index(){ + $posts = $this->showPosts("1"); + if($posts){ //if result exists send the result to room for display + $this->load->view('roomView',$posts); + } + else{ + $data['message'] = "NO_POSTS_YET"; + $this->load->view('roomView',$data); + } + } + + public function showPosts($parameter){ + $page = (int) $parameter; //type casting the parameter to integer will cause page to be 0 is it contains alphabets + $session_data = $this->session->userdata('logged_in'); + + $this->load->model('posts'); + $postsFormDB = $this->posts->getPosts($page); + + if($postsFormDB){ + if(!isset($postsFormDB['message'])){ + $postsFormDB['message'] = "NOT_SET"; + } + $n = count($postsFormDB); + array_unshift($postsFormDB,$session_data['username'],$n + 2,$page); + //setting the data to be sent to the view + for($i = 0; $i < $n + 2; $i++){ + $di = 'di'.$i; + $data[$di] = $postsFormDB[$i]; + } + $data['message'] = $postsFormDB['message']; + return $data; + } + else{ + return false; + } + } + + public function ajax($param){ + $posts = $this->showPosts($param); + if($posts){ + print_r($posts); //returns the array to ajax responseText + } + else{ + echo("NO!"); + } + } + + public function ajaxPost(){ + if(isset($_POST['username'])&&isset($_POST['status'])){ + $username = $_POST['username']; + $posts = $_POST['status']; + $date = date("Y-m-d H:i:s"); + + $this->load->model('posts'); + $insertPost = $this->posts->post($username,$posts,$date); + + if($insertPost){ + echo($date); + } + else{ + echo("false"); + } + } + else{ + echo("VARIABLES_NOT_SET"); + } + } + + public function logout(){ + $this->session->unset_userdata('logged_in'); + session_destroy(); + redirect('login', 'refresh'); + } +} + +?> diff --git a/codeigniter/application/models/DBFunctions.php b/codeigniter/application/models/DBFunctions.php new file mode 100644 index 0000000..ca68c29 --- /dev/null +++ b/codeigniter/application/models/DBFunctions.php @@ -0,0 +1,95 @@ + db -> select('userID, username,email, password'); + $this -> db -> from('users'); + $this -> db -> where('email', $email); + $this -> db -> where('password', $password); + $this -> db -> limit(1); + + $query = $this -> db -> get(); + + if($query -> num_rows() == 1){ + return $query->result(); + } + else{ + return false; + } + } + + public function userExists($email){ + $this->db->select('email'); + $this->db->from('users'); + $this->db->where('email',$email); + $this->db->limit(1); + + $query = $this->db->get(); + + if($query->num_rows == 1){ + return true; + } + else{ + return false; + } + } + + public function register($username,$email,$password){ + $this->db->set('username',$username); + $this->db->set('email',$email); + $this->db->set('password',$password); + + $this->db->insert('users'); + + if($this->db->affected_rows() == 1){ + return $this->db->affected_rows(); + }else{ + return false; + } + } + + public function post($username,$posts,$date){ + $this->db->set('username',$username); + $this->db->set('posts',$posts); + $this->db->set('time_of_post',$date); + + $this->db->insert('posts'); + + if($this->db->affected_rows() == 1){ + return true; + } + else{ + return false; + } + } + + public function getPosts($page){ + $this->db->select('username,posts,time_of_post'); + $this->db->from('posts'); + $this->db->order_by('time_of_post','DESC'); + $this->db->limit(LENGTH,LENGTH*($page - 1)); + + $query = $this->db->get(); + + if($query->num_rows()>0){ + if($query->num_rowsresult_array(); + $data['message'] = "MAX_VIEW_REACHED"; + } + else{ + $data = $query->result_array(); //when MAX_VIEW_NOT_REACHED message is not set + } + return $data; + } + else{ + return false; + } + } +} +?> \ No newline at end of file diff --git a/codeigniter/application/models/posts.php b/codeigniter/application/models/posts.php new file mode 100644 index 0000000..9dbe08d --- /dev/null +++ b/codeigniter/application/models/posts.php @@ -0,0 +1,64 @@ +session->userdata('logged_in'); + $userid = $session_data['userid']; + $this->db->select('postid,username,posts,time_of_post'); + $this->db->from('posts'); + $this->db->where('userid',$userid); + $this->db->order_by('time_of_post','DESC'); + $this->db->limit(LENGTH); + + $query = $this->db->get(); + + if ($query->num_rows()>0) { + return $query->result_array(); + } else { + return false; + } + } + + public function getPosts($page){ + $session_data = $this->session->userdata('logged_in'); + $userid = $session_data['userid']; + $this->db->select('postid,username,posts,time_of_post'); + $this->db->from('posts'); + $this->db->where('userid',$userid); + $this->db->where('postid <',$page); + $this->db->order_by('time_of_post','DESC'); + $this->db->limit(LENGTH); + + $query = $this->db->get(); + + if ($query->num_rows()>0) { + return $query->result_array(); + } else { + return false; + } + } + + public function post($userid,$username,$posts,$time_of_post){ + $this->db->set('userid',$userid); + $this->db->set('username',$username); + $this->db->set('posts',$posts); + $this->db->set('time_of_post',$time_of_post); + + $this->db->insert('posts'); + + if($this->db->affected_rows() == 1){ + return true; + } + else{ + return false; + } + } + +} +?> \ No newline at end of file diff --git a/codeigniter/application/models/users.php b/codeigniter/application/models/users.php new file mode 100644 index 0000000..c12bceb --- /dev/null +++ b/codeigniter/application/models/users.php @@ -0,0 +1,40 @@ + db -> select('userid, username,email, password'); + $this -> db -> from('users'); + $this -> db -> where('email', $email); + $this -> db -> where('password', $password); + + $query = $this -> db -> get(); + + if($query -> num_rows() == 1){ + return $query->row_array(); + } + else{ + return false; + } + } + + public function register($username,$email,$password){ + $this->db->set('username',$username); + $this->db->set('email',$email); + $this->db->set('password',$password); + + $this->db->insert('users'); + + if($this->db->affected_rows() == 1){ + return true; + }else{ + return false; + } + } +} +?> \ No newline at end of file diff --git a/codeigniter/application/views/loginView.php b/codeigniter/application/views/loginView.php new file mode 100644 index 0000000..6649420 --- /dev/null +++ b/codeigniter/application/views/loginView.php @@ -0,0 +1,52 @@ + + + + +Welcome to Twitter::Login + + + + + + + + + +
Mini Twitter
+ +
+ +
"> + +
+ +
+ +
+ 'loginForm','id'=>'loginFID')); +echo form_label('Email', 'loginemailID', array( 'id' => 'loginlabelEmailID')); +echo form_input(array('name'=> 'email','id'=> 'loginemailID')); +echo form_label('Password', 'loginpasswordID', array( 'id' => 'loginlabelPassID')); +echo form_password(array('name'=> 'password','id'=> 'loginpasswordID')); +echo form_close(); +?> + +
+ + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/codeigniter/application/views/registerView.php b/codeigniter/application/views/registerView.php new file mode 100644 index 0000000..14a7d35 --- /dev/null +++ b/codeigniter/application/views/registerView.php @@ -0,0 +1,54 @@ + + + + +Welcome to Twitter::Registration + + + + + + + + +
New User Registration
+ +
+ +
"> + +
+ +
+ +
+ 'registerForm','id'=>'registerFID')); +echo form_label('Username', 'usernameID', array( 'id' => 'labelUserID')); +echo form_input(array('name'=> 'username','id' => 'usernameID','value'=>set_value('username'))); +echo form_label('Email', 'emailID', array( 'id' => 'labelEmailID')); +echo form_input(array('name'=> 'email','id'=> 'emailID','value'=>set_value('email'))); +echo form_label('Password', 'passwordID', array( 'id' => 'labelPassID')); +echo form_password(array('name'=> 'password','id'=> 'passwordID','value'=>set_value('password'))); +echo form_label('Confirm Password', 'confirmPasswordID', array( 'id' => 'labelConfirmPassID')); +echo form_password(array('name'=> 'confirmPassword','id'=> 'confirmPasswordID','value'=>set_value('confirmPassword'))); +echo form_close(); +?> + + + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/codeigniter/application/views/roomView.php b/codeigniter/application/views/roomView.php new file mode 100644 index 0000000..f41563b --- /dev/null +++ b/codeigniter/application/views/roomView.php @@ -0,0 +1,189 @@ +session->userdata('logged_in');?> + + + + +Room + + + + + + + + +
+ +Logout +
+ + + + +
+ +
+
+load->helper('form'); +echo form_open('room/post',array('name' => 'statusInputForm')); +?> + + + +
+
+ + +
+
+
+ + + $(document).ready(function(){ + $(\"#morePostID\").hide(); + }); + "); + echo("
"); + echo("

".$message."

"); +} +else{ + $data = json_decode($jsonObject); + $postid = $data[count($data)-1]->postid; + for($i = 0; $i < LENGTH; $i++){ + if(isset($data[$i]->username)){ + echo("
"); + echo("

".$data[$i]->username."".$data[$i]->time_of_post."

"); + echo("

".$data[$i]->posts."

"); + echo("
"); + } + } +} +?> + +
+
+ +
+ +
+
+see more..");?> + +
+
+
+ +
+ +
+ + \ No newline at end of file diff --git a/codeigniter/codeigniter.sql b/codeigniter/codeigniter.sql new file mode 100644 index 0000000..dbfff36 --- /dev/null +++ b/codeigniter/codeigniter.sql @@ -0,0 +1,54 @@ +-- phpMyAdmin SQL Dump +-- version 4.1.14 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: May 08, 2014 at 12:56 AM +-- Server version: 5.5.37-log +-- PHP Version: 5.4.27 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Database: `codeigniter` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `posts` +-- + +CREATE TABLE IF NOT EXISTS `posts` ( + `postid` int(11) NOT NULL AUTO_INCREMENT, + `userid` varchar(50) NOT NULL, + `username` varchar(50) NOT NULL, + `posts` text NOT NULL, + `time_of_post` datetime NOT NULL, + PRIMARY KEY (`postid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE IF NOT EXISTS `users` ( + `userid` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(50) NOT NULL, + `email` varchar(50) NOT NULL, + `password` varchar(50) NOT NULL, + PRIMARY KEY (`userid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/codeigniter/css/mystyle.css b/codeigniter/css/mystyle.css new file mode 100644 index 0000000..2c14d0e --- /dev/null +++ b/codeigniter/css/mystyle.css @@ -0,0 +1,519 @@ +@charset "utf-8"; +/* CSS Document */ + +body{ + margin-bottom:0px; + margin-left:15%; + margin-right:15%; + margin-top:0px; +} + +/* ----------------------------------------------LOGO CSS------------------------------------------- */ + +#logoID{ + background:#B40313; + color:#FFFFFF; + height:70px; + border-bottom:1px #E5E5E5 solid; + font-family:"Arial Black", Gadget, sans-serif; + font-size:xx-large; + font-weight:bold; + padding:20px 0px 0px 20px; +} + +/* ----------------------------------------------SPACER CSS------------------------------------------- */ + +#spacerID{ + padding-top:5px; + padding-bottom:5px; + padding-left:10px; + padding-right:10px; +} + +/* ----------------------------------------------MESSAGE CSS------------------------------------------- */ + +#msgID{ + background:#FFC; + font-weight:bold; + text-align:center; + font-size:12px; + border:1px #69C solid; + font-family:Arial, Helvetica, sans-serif; + padding:10px 10px 10px 10px; +} + +/* ----------------------------------------------LOGIN FORM CSS------------------------------------------- */ + +#loginFormID{ + background:#F5F5F5; + width:300px; + height:250px; + position:relative; + left:36%; + border:1px #E5E5E5 solid; +} + +/* ----------------------------------------------LOGIN EMAIL CSS------------------------------------------- */ + +#loginlabelEmailID{ + position:absolute; + top: 20px; + width:36px; + left: 90px; + padding:5px 5px 5px 5px; + font-family:Arial, Helvetica, sans-serif; + font-size:smaller; + color:#B40313; + font-weight:bold; +} + +#loginemailID{ + position:absolute; + top: 53px; + border:2px #B40313 solid; + width:160px; + left: 89px; + padding:5px 5px 5px 5px; +} + +/* ----------------------------------------------LOGIN PASSWORD CSS------------------------------------------- */ + +#loginlabelPassID{ + position:absolute; + left: 90px; + top: 86px; + width: 60px; + padding:5px 5px 5px 5px; + font-family:Arial, Helvetica, sans-serif; + font-size:smaller; + color:#B40313; + font-weight:bold; +} + + +#loginpasswordID{ + position:absolute; + border:2px #B40313 solid; + left: 89px; + top: 117px; + width: 160px; + padding:5px 5px 5px 5px; +} + +/* ----------------------------------------------LOGIN LOGIN BUTTON CSS------------------------------------------- */ + +#loginloginbuttonID a{ + position:absolute; + left: 105px; + top: 160px; + width: 50px; + height: 20px; + text-align:center; + font:11px arial; + color: #FFFFFF; + font-weight:bold; + padding-top:8px; + padding-bottom:2px; + padding-left:5px; + padding-right:5px; + text-decoration: none; + background-color:#B40313; +} +#loginloginbuttonID a:hover{ + color:#ffffff; + background:#DE909D; +} + +/* ----------------------------------------------LOGIN REGISTER BUTTON CSS------------------------------------------- */ + +#loginregisterbuttonID a{ + position:absolute; + left: 177px; + top: 160px; + width: 50px; + height: 20px; + text-align:center; + font:11px arial; + color: #FFFFFF; + font-weight:bold; + padding-top:8px; + padding-bottom:2px; + padding-left:5px; + padding-right:5px; + text-decoration: none; + background-color:#B40313; +} +#loginregisterbuttonID a:hover{ + color:#ffffff; + background:#DE909D; +} + +/* ----------------------------------------------LOGIN FORGOT PASSWORD CSS------------------------------------------- */ + +#loginforgotpassID a{ + position:absolute; + left: 119px; + top: 198px; + font-family:Georgia, "Times New Roman", Times, serif; + font-size:smaller; + color:#B40313; +} +#loginforgotpassID a:hover{ + text-decoration:none; +} + + +/* ----------------------------------------------REGISTER FORM CSS------------------------------------------- */ + +#registerFormID{ + background:#F5F5F5; + width:300px; + height:360px; + position:relative; + left:36%; + border:1px #E5E5E5 solid; +} + +/* ----------------------------------------------REGISTER USERNAME CSS------------------------------------------- */ + +#usernameID{ + position:absolute; + top: 46px; + border:2px #B40313 solid; + width:160px; + left: 89px; + padding:5px 5px 5px 5px; +} + +#labelUserID{ + position:absolute; + top: 20px; + width:36px; + left: 90px; + padding:5px 5px 5px 5px; + font-family:Arial, Helvetica, sans-serif; + font-size:smaller; + color:#B40313; + font-weight:bold; +} + +/* ----------------------------------------------REGISTER EMAIL CSS------------------------------------------- */ + +#emailID{ + position:absolute; + top: 111px; + border:2px #B40313 solid; + width:160px; + left: 89px; + padding:5px 5px 5px 5px; +} + +#labelEmailID{ + position:absolute; + top: 78px; + width:36px; + left: 90px; + padding:5px 5px 5px 5px; + font-family:Arial, Helvetica, sans-serif; + font-size:smaller; + color:#B40313; + font-weight:bold; +} + +/* ----------------------------------------------REGISTER PASSWORD CSS------------------------------------------- */ + +#passwordID{ + position:absolute; + border:2px #B40313 solid; + left: 89px; + top: 175px; + width: 160px; + padding:5px 5px 5px 5px; +} + +#labelPassID{ + position:absolute; + left: 90px; + top: 144px; + width: 60px; + padding:5px 5px 5px 5px; + font-family:Arial, Helvetica, sans-serif; + font-size:smaller; + color:#B40313; + font-weight:bold; +} + +/* ----------------------------------------------REGISTER CONFIRM PASSWORD CSS------------------------------------------- */ + +#confirmPasswordID{ + position:absolute; + border:2px #B40313 solid; + left: 89px; + top: 238px; + width: 160px; + padding:5px 5px 5px 5px; +} + +#labelConfirmPassID{ + position:absolute; + left: 90px; + top: 210px; + padding:5px 5px 5px 5px; + font-family:Arial, Helvetica, sans-serif; + font-size:smaller; + color:#B40313; + font-weight:bold; +} + +/* ----------------------------------------------REGISTER LOGIN BUTTON CSS------------------------------------------- */ + +#loginbuttonID a{ + position:absolute; + left: 105px; + top: 285px; + width: 50px; + height: 20px; + text-align:center; + font:11px arial; + color: #FFFFFF; + font-weight:bold; + padding-top:8px; + padding-bottom:2px; + padding-left:5px; + padding-right:5px; + text-decoration: none; + background-color:#B40313; +} +#loginbuttonID a:hover{ + color:#ffffff; + background:#DE909D; +} + +/* ----------------------------------------------REGISTER REGISTER BUTTON CSS------------------------------------------- */ + +#registerbuttonID a{ + position:absolute; + left: 177px; + top: 285px; + width: 50px; + height: 20px; + text-align:center; + font:11px arial; + color: #FFFFFF; + font-weight:bold; + padding-top:8px; + padding-bottom:2px; + padding-left:5px; + padding-right:5px; + text-decoration: none; + background-color:#B40313; +} +#registerbuttonID a:hover{ + color:#ffffff; + background:#DE909D; +} + +/* ----------------------------------------------REGISTER FORGOT PASSWORD CSS------------------------------------------- */ + +#forgotpassID a{ + position:absolute; + left: 119px; + top: 320px; + font-family:Georgia, "Times New Roman", Times, serif; + font-size:smaller; + color:#B40313; +} +#forgotpassID a:hover{ + text-decoration:none; +} + +/* ----------------------------------------------ROOM CSS------------------------------------------- */ + +#roomMenuID{ + color:#FFFFFF; + text-align:right; + font:11px arial; + font-weight:bold; + padding-top:10px; + padding-bottom:10px; + padding-left:20px; + padding-right:20px; + text-decoration: none; + background-color:#B40313; + text-transform:capitalize; +} + +#footerID{ + color:#FFFFFF; + text-align:center; + font:11px arial; + font-weight:bold; + height:50px; + padding-top:10px; + padding-bottom:10px; + padding-left:20px; + padding-right:20px; + text-decoration: none; + background-color:#B40313; + text-transform:capitalize; +} + +#roomMenuID a{ + color:#FFFFFF; + text-align:right; + font:11px arial; + font-weight:bold; + padding-top:10px; + padding-bottom:10px; + padding-left:20px; + padding-right:50px; + text-decoration: none; + background-color:#B40313; + text-transform:capitalize; +} + +#roomBodyID{ + background:#F5F5F5; + width:100%; + height:100%; + border:1px #E5E5E5 solid; +} + +#statusInputID{ + width:50%; + height:100px; + position:relative; + left:24.5%; + border:0px #E5E5E5 solid; +} + +#postButtonID a{ + position:relative; + left:46%; + width: 100px; + height: 20px; + text-align:center; + font:11px arial; + color: #FFFFFF; + font-weight:bold; + padding-top:10px; + padding-bottom:10px; + padding-left:25px; + padding-right:25px; + text-decoration: none; + background-color:#B40313; +} + +#postButtonID a:hover{ + color:#ffffff; + background:#DE909D; +} + + +#statusDisplayID{ + background:#FFFFFF; + width:53.4%; + position:relative; + left:22%; + border:1px #E5E5E5 solid; + padding-bottom:0px; + padding-left:10px; + padding-right:10px; + padding-top:0px; +} + +.statusDisplayClass{ + background:#FFFFFF; + width:53.4%; + position:relative; + left:22%; + border:1px #E5E5E5 solid; + padding-bottom:0px; + padding-left:10px; + padding-right:10px; + padding-top:0px; +} + +#NoPostID{ + background:#FFFFFF; + width:53.4%; + position:relative; + left:22%; + border:1px #E5E5E5 solid; + padding-bottom:0px; + padding-left:10px; + padding-right:10px; + padding-top:0px; +} + +#statusByAjaxID{ + +} + +#morePostID a{ + position:relative; + left:45%; + width: 100px; + height: 20px; + text-align:center; + font:11px arial; + color: #FFFFFF; + font-weight:bold; + padding-top:10px; + padding-bottom:10px; + padding-left:25px; + padding-right:25px; + text-decoration: none; + background-color:#B40313; +} + +#morePostID a:hover{ + color:#ffffff; + background:#DE909D; +} + +p.usernameClass{ + text-transform:capitalize; + font-weight:bold; +} + +h7.dateClass{ + text-align:right; + float:right; + font-weight:normal; + color:#999; + font-style:italic; + font-size:small; +} + + +/*---------------------------------------------------------------------GLOWING TEXTAREA-----------------------------------------------------------*/ + +textarea#textAreaID{ + resize:none; + color:#666; + font-size:14px; + -moz-border-radius: 0px; -webkit-border-radius: 0px; + margin:5px 0px 10px 0px; + padding:10px; + height:70px; + width:450px; + border:#999 1px solid; + font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; + transition: all 0.25s ease-in-out; + -webkit-transition: all 0.25s ease-in-out; + -moz-transition: all 0.25s ease-in-out; + box-shadow: 0 0 5px rgba(81, 203, 238, 0); + -webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 0); + -moz-box-shadow: 0 0 5px rgba(81, 203, 238, 0); +} + +textarea#styleid:focus{ + color:#000; + outline:none; + border:#35a5e5 1px solid; + font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; + box-shadow: 0 0 5px rgba(81, 203, 238, 1); + -webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 1); + -moz-box-shadow: 0 0 5px rgba(81, 203, 238, 1); +} \ No newline at end of file diff --git a/codeigniter/js/myjavascript.js b/codeigniter/js/myjavascript.js new file mode 100644 index 0000000..ef5da59 --- /dev/null +++ b/codeigniter/js/myjavascript.js @@ -0,0 +1,101 @@ +// JavaScript Document +function appendAtEnd(data,numberOfPosts){ + var arrayDiv = new Array(); //to hold div element + + var length = ; + var increment = length * (parseInt(data[0][2]) - 2); + for(var k = 0; k < numberOfPosts; k++){ + var dText="

" + data[k+1][0]+""+data[k+1][2]+"

"+data[k+1][1]+"

"; + var br = document.createElement('br'); + arrayDiv[increment] = document.createElement('div'); + arrayDiv[increment].id = 'statusDisplayID' + increment; + arrayDiv[increment].className = 'statusDisplayClass'; + statusByAjaxID.appendChild(arrayDiv[increment]); + statusByAjaxID.appendChild(br); + document.getElementById("statusDisplayID" + increment).innerHTML = dText; + increment++; + } + return true; +} + +function getData(rawData,numberOfPosts){ + var arraySeparated = new Array(); + var data = new Array(); + + var tableColumn = ["username","posts","time_of_post"]; //only in case if the table contains any other columns + var numCol = tableColumn.length; + + for(var i = 0; i <= numberOfPosts + 1; i++){ + arraySeparated[i] = rawData.split("Array")[i].split("=>"); //a 2-dimensional dirty but yet useful array + } + + for(var i = 0;i <3; i++){ //loop=3 because index=1 of arraySeparated contains LOGGED_IN_USER,TOTAL_DISPLAYING,PAGE + data[i] = arraySeparated[1][i + 1].substring(1,arraySeparated[1][i + 1].indexOf("\n")); + } + for(var j = 2; j <= numberOfPosts+1; j++){ //index 2 to numberOfPosts+1 contains all the posts fetched in one time + for(var k = 1; k <= numCol; k++){ + data[i] = arraySeparated[j][k].substring(1,arraySeparated[j][k].indexOf("\n")); + i++; + } + } + data[i] = arraySeparated[j-1][k].substring(1,arraySeparated[j-1][k].indexOf("\n")); //the last index contains message + + //objectification of the data + var post = new Array(); + + post[0] = new Array(); + for(var j=0; j < 3;j++){ + post[0][j] = data[j]; + } + for(var i = 1;i <= numberOfPosts; i++){ + post[i] = new Array(); + for(var k=0; k < numCol; k++){ + post[i][k] = data[j]; + j++; + } + } + post[i] = new Array(); + post[i][0] = data[j]; + + return post; +} + +function ajaxPegination(str) { + if (str=="") { + document.getElementById("statusDisplayID").innerHTML=""; + return; + } + if (window.XMLHttpRequest) { + // code for IE7+, Firefox, Chrome, Opera, Safari + xmlhttp=new XMLHttpRequest(); + } else { // code for IE6, IE5 + xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); + } + xmlhttp.onreadystatechange=function() { + if (xmlhttp.readyState==4 && xmlhttp.status==200) { + var rawData = xmlhttp.responseText; + + var numberOfPosts = rawData.split("Array").length-2; //number of posts is 2 lesser + + var data = new Array(); //converting string type responseText into array + var data = getData(rawData,numberOfPosts); + + var page = parseInt(data[0][2]) + 1; //to fetch next particular size of data from database + var message = data[numberOfPosts + 1][0]; //this checks if last entry has reached by MAX_VIEW_REACHED + + document.getElementById("see_moreID").href = "javascript:ajaxPegination(" + page + ")"; //pegination link + + document.getElementById("msgID").innerHTML = message; //message + + if(message == "MAX_VIEW_REACHED"){ //if max view reached pegination link changes + document.getElementById("see_moreID").href = ""; + document.getElementById("see_moreID").innerHTML = "recent only..."; + } + + appendAtEnd(data,numberOfPosts); //to append the posts at the end + //console.log(data); + } + } + xmlhttp.open("GET",""+str,true); + xmlhttp.send(); +} \ No newline at end of file