Skip to content

Commit

Permalink
😢
Browse files Browse the repository at this point in the history
😢
  • Loading branch information
GaneshKandu committed Sep 5, 2017
1 parent b727e01 commit f94350c
Show file tree
Hide file tree
Showing 90 changed files with 10,764 additions and 761 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ cache/*
docs
README.txt
kchat.zip
box/logs/error.log
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
92 changes: 46 additions & 46 deletions kchat/box/assets/js/kchat.js → box/assets/js/kchat.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@

kchat = new Object();
kbox = new Object();

kchat.typing = 0;
kchat.scroll = 0;
kchat.offset = 'none';
kchat.msgoffset = 0;
kchat.msg = 30;
kchat.premsg = false;
kchat.url = '';
kchat.key = '';
kbox.typing = 0;
kbox.scroll = 0;
kbox.offset = 'none';
kbox.msgoffset = 0;
kbox.msg = 30;
kbox.premsg = false;
kbox.url = '';
kbox.key = '';

kchat.init = (function(data){
kbox.init = (function(data){
this.url = data.url;
this.key = data.key;
this.LoadAssets();
this.box_Toggle = true;
window.onload = function() {
kchat.loadLogo();
kchat.initevent();
kbox.loadLogo();
kbox.initevent();
if (typeof global !== 'undefined'){
if (global.guest){
kchat.loadBox();
kbox.loadBox();
$("#KChat_heading_title").html(global.name);
}else{
kchat.loadform();
kbox.loadform();
$("#KChat_heading_title").html(global.heading);
var department = '';
for(var i = 0; i < global.dept.length; i++) {
Expand All @@ -32,7 +32,7 @@ kchat.init = (function(data){
$("#kchat_dept").html(department);
}
}else{
kchat.loadform();
kbox.loadform();
$("#KChat_heading_title").html(global.heading);
var department = '';
for(var i = 0; i < global.dept.length; i++) {
Expand All @@ -43,12 +43,12 @@ kchat.init = (function(data){

$("#KChat_scroll_panel").scroll(function(){
scrl = $("#KChat_scroll_panel").scrollTop();
if(scrl <= kchat.scroll){
if(scrl <= kbox.scroll){
//scrolling on top
}else{
//scrolling on bottom
}
kchat.scroll = scrl;
kbox.scroll = scrl;
});
if(document.getElementById("KChat_scroll_panel")){
document.getElementById("KChat_scroll_panel").addEventListener("wheel", _loadoldmsg);
Expand All @@ -58,7 +58,7 @@ kchat.init = (function(data){



kchat.LoadAssets = (function(){
kbox.LoadAssets = (function(){

if (!window.jQuery) {
var jq = document.createElement('script');
Expand Down Expand Up @@ -96,33 +96,33 @@ kchat.LoadAssets = (function(){
document.getElementsByTagName('head')[0].appendChild(jq);
});

kchat.loadLogo = (function(){
kbox.loadLogo = (function(){
$("body").append("<div id=\"KChat_btn\" ><image id=\"KChat_logo\" src=\"" + this.url + "assets/images/logo.png\" ></image></div><div id=\"KChat_box\" ></div>");
$("#KChat_btn").click(function(){
$("#KChat_btn").css("display", "none");
$("#KChat_box").css("display", "block");
kchat.box_Toggle = true;
kbox.box_Toggle = true;
});
})

kchat.initevent = (function(event){
kbox.initevent = (function(event){
document.addEventListener("keydown", function(event) {
//console.log(event.which);
if(event.which == 27){
if(kchat.box_Toggle){
if(kbox.box_Toggle){
$("#KChat_box").css("display", "none");
$("#KChat_btn").css("display", "block");
kchat.box_Toggle = false;
kbox.box_Toggle = false;
}else{
$("#KChat_btn").css("display", "none");
$("#KChat_box").css("display", "block");
kchat.box_Toggle = true;
kbox.box_Toggle = true;
}
}
});
});

kchat.loadBox = (function(){
kbox.loadBox = (function(){
html = "<div id=\"KChat_heading\" ><div id=\"KChat_heading_title\" ></div></div>";
html += "<div id=\"KChat_scroll_panel\" >";
html += "<div id=\"KChat_scroll\" >";
Expand All @@ -135,17 +135,17 @@ kchat.loadBox = (function(){
this.sync();
});

kchat.loademoji = (function(){
kbox.loademoji = (function(){
// to send a msg
$(".kchatemoji").emojioneArea({
events: {
keypress: function (editor, event) {
var keyCode = event ? (event.which ? event.which : event.keyCode) : event.keyCode;
// to change wtring status
aa = new Date();
if(kchat.typing !== aa.getSeconds()){
kchat.typing = aa.getSeconds();
$.post("kchat.php?typing",{
if(kbox.typing !== aa.getSeconds()){
kbox.typing = aa.getSeconds();
$.post(this.url + "kchat.php?typing",{
key: this.key,
},function(data,status){

Expand All @@ -159,7 +159,7 @@ kchat.loademoji = (function(){
if(msg == ""){
return false;
}
$.post("kchat.php?msg",
$.post(this.url + "kchat.php?msg",
{
msg: msg,
key: this.key,
Expand All @@ -176,26 +176,26 @@ kchat.loademoji = (function(){
});
});

kchat.loadform = (function(){
kbox.loadform = (function(){
html = "<div id=\"KChat_heading\" ><div id=\"KChat_heading_title\" ></div></div>";
html += "<div id=\"KChat_form\" >";
html +="<p type=\"text\"><input id=\"kchat_fname\" placeholder=\"Write your first name here..\"></input></p>";
html +="<p type=\"text\"><input id=\"kchat_lname\" placeholder=\"Write your lastname here..\"></input></p>";
html +="<p type=\"email\"><input id=\"kchat_email\" placeholder=\"EMail\"></input></p>";
html +="<p type=\"text\"><input id=\"kchat_msg\" placeholder=\"Type Here ...\"></input></p>";
html +="<p><select id='kchat_dept'></select></p>";
html +="<button onclick=\"kchat.start()\">Send Message</button>";
html +="<button onclick=\"kbox.start()\">Send Message</button>";
html += "</div>";
$("#KChat_box").html(html);
});

kchat.start = (function(){
kbox.start = (function(){
var kchat_fname = $( "#kchat_fname" ).val();
var kchat_lname = $( "#kchat_lname" ).val();
var kchat_email = $( "#kchat_email" ).val();
var kchat_dept = $( "#kchat_dept" ).val();
var kchat_msg = $( "#kchat_msg" ).val();
$.post("kchat.php?start",
$.post(this.url + "kchat.php?start",
{
kchat_start: 'kchat_start',
kchat_fname: kchat_fname,
Expand All @@ -207,7 +207,7 @@ kchat.start = (function(){
},
function(data,status){
global.name = kchat_fname + ' ' + kchat_lname;
kchat.loadBox();
kbox.loadBox();
$("#KChat_heading_title").html(global.name);
});
});
Expand All @@ -231,7 +231,7 @@ function kchat_json(data){
"</div>"+
"</div>";
info += messages[i].id+" ";
kchat.msgoffset = messages[i].id;
kbox.msgoffset = messages[i].id;
if(messages[i].dir == 'u2b'){
$( "#KChat_scroll" ).append(data);
$('#KChat_scroll_panel').scrollTop($('#KChat_scroll')[0].scrollHeight);
Expand All @@ -243,17 +243,17 @@ function kchat_json(data){
$( "emojionearea-editor" ).focus();
}
if (typeof response.offset !== 'undefined'){
kchat.offset = response.offset;
kbox.offset = response.offset;
}
}

function kchat_init(first){
$.post(kchat.url + "kchat.php?getmsg",
$.post(kbox.url + "kchat.php?getmsg",
{
first_run: first,
premsg: kchat.premsg,
offset:kchat.offset,
key: kchat.key,
premsg: kbox.premsg,
offset:kbox.offset,
key: kbox.key,
},
function(data,status){
if(status === "success"){
Expand All @@ -262,7 +262,7 @@ function kchat_init(first){
});
}

kchat.sync = (function(){
kbox.sync = (function(){
kchat_init('true');
setInterval(function(){ kchat_init('false'); }, 3000);
});
Expand All @@ -272,11 +272,11 @@ function _loadoldmsg() {
if(scrl == 0){
aa = new Date();
// Delay for half second for every ajax during typing
if(kchat.typing !== ((aa.getMilliseconds()-aa.getMilliseconds()%500)/500)){
kchat.typing = ((aa.getMilliseconds()-aa.getMilliseconds()%500)/500);
kchat.premsg = true;
if(kbox.typing !== ((aa.getMilliseconds()-aa.getMilliseconds()%500)/500)){
kbox.typing = ((aa.getMilliseconds()-aa.getMilliseconds()%500)/500);
kbox.premsg = true;
kchat_init('false');
kchat.premsg = false;
kbox.premsg = false;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions kchat/box/config/config.php → box/config/config.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

return array(
"kchat_path" => "E:\\Ampps\\www\\kchat\\kchat\\box",
"kchat_url" => "http://localhost/kchat/kchat/box",
"kchat_path" => "E:\\Ampps\\www\\kchat\\box",
"kchat_url" => "http://localhost/kchat/box",
"kchat_ds" => "\\",
"path" => "E:\\Ampps\\www\\kchat",
"url" => "http://localhost/kchat",
"ds" => "\\",
"secret" => "rFXrzWyK10Tt7FPV6AqBxqqNfsejVsN599Biqte5JgioXV1LGIHSlaZBlsLKDEw3",
"session" => "KChat_p5wbLdSo",
"salt" => "FembzMwpjWlB8C0BooIA82x2wZeeTbNg",
"key" => "ZAh251Lk",
"secret" => "HhMoxjS9qz30AMuPPRIAhmcG2g0U7FfrcrquXns1rrXsHZiaN1wfOzEXX42nFBi4",
"session" => "KChat_Rl9YCyLo",
"salt" => "WaXk7uOUBRmKOPuU0nYz8Q7ky0HkC1FU",
"key" => "IPemNyeLQ6GF",
"Admin" => "KkEtq2SNzvl02OR",
"version" => "1.0.0",
"db_host" => "localhost",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion kchat/box/core/kchat.php → box/core/kchat.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function msgencode($txt){
}

function msgdecode($txt){
return json_decode('"'.$txt.'"');
return json_decode('"'.$txt.'"', 1);
}

function isReq($id){
Expand Down
45 changes: 43 additions & 2 deletions kchat/box/core/sandesh.php → box/core/sandesh.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function __construct($data){
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::MYSQL_ATTR_FOUND_ROWS => TRUE
);

$this->global['pdo'] = new PDO("mysql:host=".$data['db_host'].";dbname=".$data['db_db'].";port=".$data['db_port'].";charset=utf8", $data['db_user'], $data['db_pass'],$opt);
Expand All @@ -27,6 +28,11 @@ function __construct($data){
$this->global['id'] = $row['id'];
$this->global['group_id'] = $row['group_id'];
$this->global['guest_id'] = $row['guest_id'];

$stmt = $this->global['pdo']->prepare("SELECT * FROM `{$data['db_prefix']}users` where id = :id;");
$stmt->execute(array('id' => $this->global['id']));
$row = $stmt->fetch();
$this->global = array_merge($this->global,$row);
}
}
}
Expand Down Expand Up @@ -81,12 +87,13 @@ function start($data){
'lname' => $_POST['kchat_lname'],
'password' => kchat_rand(),//random password for guest
'role' => 3,
'dept' => 1,
'dept' => null,
'email' => $_POST['kchat_email'],
)
);
// INSERT USERS END
// INSERT GROUP_USERS

foreach($users as $user){
$stmt = $this->global['pdo']->prepare("INSERT INTO `{$data['db_prefix']}group_users` (`grupid`,`users`) VALUES (:grupid,:users)");
$stmt->execute(
Expand Down Expand Up @@ -172,6 +179,36 @@ function getmsg($post,$data){

$grp_id = $this->global['group_id'];

//online
if($grp_id){
$sql = "UPDATE `{$data['db_prefix']}cache`
SET `time` = UNIX_TIMESTAMP()
WHERE uname = :uname AND
process = 1";
$sql_array = array(
'uname' => $this->global['id']
);
$stmt = $this->global['pdo']->prepare($sql);
$this->qfired++;
$stmt->execute($sql_array);
$count = $stmt->rowCount();
if($count == 0){
// process 2 new msg
$sql = "INSERT INTO `{$data['db_prefix']}cache` (`fname`,`lname`,`time`,`uname`,`group`,`process`,`value`,`dept`,`support_id`)
VALUES (:fname,:lname,UNIX_TIMESTAMP(),:uname,:group,1,1,:dept,:support_id);";
$sql_array = array(
'fname' => $this->global['fname'],
'lname' => $this->global['lname'],
'uname' => $this->global['uname'],
'group' => $grp_id,
'dept' => $this->global['dept'],
'support_id' => $this->global['id'],
);
$stmt = $this->global['pdo']->prepare($sql);
$stmt->execute($sql_array);
}
}

if(isset($post['first_run'])){

if($post['first_run'] == 'true'){
Expand Down Expand Up @@ -346,7 +383,7 @@ function css($data){
*/
function getSupportid($depart){ //{$data['db_prefix']}
// supportid user_id
if(isset($_SESSION['supportid'])){
if(!empty($_SESSION['supportid'])){
return $_SESSION['supportid'];
}

Expand All @@ -366,6 +403,10 @@ function getSupportid($depart){ //{$data['db_prefix']}

$_SESSION['supportid'] = $rids[min($ids)];

if(empty($_SESSION['supportid'])){
return 'KkEtq2SNzvl02OR';
}

return $_SESSION['supportid'];
}

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"php": ">=5.3.0",
"ext-pdo": "*",
"ext-json": "*",
"phpmailer/phpmailer": "^5.2"
"phpmailer/phpmailer": "^5.2",
"geoip/geoip": "^1.17"
},
"require-dev" : {},
"autoload": {
Expand Down
Loading

0 comments on commit f94350c

Please sign in to comment.