Forums / Cotonti / Support / CometChat include cotonti

MecTruy
#1 2013-10-25 15:13

How i can do this ? Cometchat chat module i want connect with cotonti Geneo, i have cometchat files but i need help

im using Cotonti Genoa

Added 28 minutes later:

integration.php

PHP
1
2
3
4
5
6
7
8
9
10
define('DB_SERVER','localhost');
define('DB_PORT','3306');
define('DB_USERNAME','empiremu_c');
define('DB_PASSWORD','1122333');
define('DB_NAME','empiremu_c');
define('TABLE_PREFIX','sed_');
define('DB_USERTABLE','users');
define('DB_USERTABLE_NAME','user_name');
define('DB_USERTABLE_USERID','user_id');
define('DB_USERTABLE_LASTACTIVITY','user_lastactivity');

 

alot of script wordking this model

Added 6 hours later:

CometChat documans

http://www.cometchat.com/documentation/installing-cometchat/custom-coded-site/php-site

 

integration.php

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
/* ADVANCED */
 
define('SET_SESSION_NAME','');          // Session name
define('DO_NOT_START_SESSION','0');     // Set to 1 if you have already started the session
define('DO_NOT_DESTROY_SESSION','0');   // Set to 1 if you do not want to destroy session on logout
define('SWITCH_ENABLED','0');      
define('INCLUDE_JQUERY','1');  
define('FORCE_MAGIC_QUOTES','0');
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
/* DATABASE */
 
 
 
// DO NOT EDIT DATABASE VALUES BELOW
// DO NOT EDIT DATABASE VALUES BELOW
// DO NOT EDIT DATABASE VALUES BELOW
 
define('DB_SERVER',                 "localhost"                             ); // Site's Database Host.
define('DB_PORT',                   "3306"                                  ); // Site's Database Port.
define('DB_USERNAME',               "root"                                  ); // Site's Database User.
define('DB_PASSWORD',               "password"                              ); // Site's Database Password.
define('DB_NAME',                   "databasename"                          ); // Site's Database Name.
define('TABLE_PREFIX',              ""                                      ); // Site's Table Prefix.
define('DB_USERTABLE',              "users"                                 ); // Site's Users table.
define('DB_USERTABLE_USERID',       "userid"                                ); // Numeric primary or unique key of Users table.
define('DB_USERTABLE_NAME',         "username"                              ); // Display Name from users table.
define('DB_AVATARTABLE',            " "                                     ); // If profile pictures are stored in the different table then Join clause with this table table(eg. " left join avatars on avatar.userid = ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." ") else leave it empty.
define('DB_AVATARFIELD',            " ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." "); // Field that stores profile picture
define('DB_USERTABLE_LASTACTIVITY', "lastactivity"                          ); // Field that stores last active time for a user if you have any such field then modify the constant DB_USERTABLE_LASTACTIVITY and set ADD_LAST_ACTIVITY to 0.
define('ADD_LAST_ACTIVITY',         "1"                                     ); // Set this field to 0 If users table alredy has the field to store last active time of a user.
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
/* FUNCTIONS */
 
function getUserID() {
    $userid = 0;   
    if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
        $_REQUEST['basedata'] = $_SESSION['basedata'];
    }
     
    if (!empty($_REQUEST['basedata'])) {   
        if (function_exists('mcrypt_encrypt')) {
            $key = KEY_A.KEY_B.KEY_C;
            $uid = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($_REQUEST['basedata']), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
            if (intval($uid) > 0) {
                $userid = $uid;
            }
        } else {
            $userid = $_REQUEST['basedata'];
        }
    }
    if (!empty($_SESSION['userid'])) {
        $userid = $_SESSION['userid'];
    }
     
    $userid = intval($userid);
    return $userid;
}
 
function chatLogin($userName,$userPass) {
    $userid = 0;
    if (filter_var($userName, FILTER_VALIDATE_EMAIL)) {
        $sql = ("SELECT * FROM `".TABLE_PREFIX.DB_USERTABLE."` WHERE email ='".$userName."'");
    } else {
        $sql = ("SELECT * FROM `".TABLE_PREFIX.DB_USERTABLE."` WHERE username ='".$userName."'");
    }
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    $salted_password = md5($row1['value'].$userPass.$row['salt']);
    if ($row['password'] == $salted_password) {
        $userid = $row['user_id'];
    }
    if ($userid && function_exists('mcrypt_encrypt')) {
        $key = KEY_A.KEY_B.KEY_C;
        $userid = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $userid, MCRYPT_MODE_CBC, md5(md5($key))));
    }
 
    return $userid;
}
 
function getFriendsList($userid,$time) {   
    $sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity, ".DB_AVATARFIELD." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX."friends join ".TABLE_PREFIX.DB_USERTABLE." on  ".TABLE_PREFIX."friends.toid = ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = cometchat_status.userid ".DB_AVATARTABLE." where ".TABLE_PREFIX."friends.fromid = '".mysql_real_escape_string($userid)."' order by username asc");
    if ((defined('MEMCACHE') && MEMCACHE <> 0) || DISPLAY_ALL_USERS == 1) {      
        $sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity, " .DB_AVATARFIELD. " avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX.DB_USERTABLE." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = cometchat_status.userid ".DB_AVATARTABLE." where ('".mysql_real_escape_string($time)."'-".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." < '".((ONLINE_TIMEOUT)*2)."') and (cometchat_status.status IS NULL OR cometchat_status.status <> 'invisible' OR cometchat_status.status <> 'offline') order by username asc");       
    }
    return $sql;
}
 
function getFriendsIds($userid) {
    $sql = ("select group_concat(friends.myfrndids) myfrndids from (SELECT toid as myfrndids FROM `friends` WHERE status =1 and fromid = '".mysql_real_escape_string($userid)."' union SELECT fromid as myfrndids FROM `friends` WHERE status =1 and toid = '".mysql_real_escape_string($userid)."') friends ");
 
    return $sql;
}
 
function getUserDetails($userid) {
    $sql = ("select ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME." username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTACTIVITY." lastactivity,  ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." link, ".DB_AVATARFIELD." avatar, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX.DB_USERTABLE." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = cometchat_status.userid ".DB_AVATARTABLE." where ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." = '".mysql_real_escape_string($userid)."'");
     
    return $sql;
}
 
function updateLastActivity($userid) {
    $sql = ("update `".TABLE_PREFIX.DB_USERTABLE."` set ".DB_USERTABLE_LASTACTIVITY." = '".getTimeStamp()."' where ".DB_USERTABLE_USERID." = '".mysql_real_escape_string($userid)."'");
     
    return $sql;
}
 
function getUserStatus($userid) {
    $sql = ("select cometchat_status.message, cometchat_status.status from cometchat_status where userid = '".mysql_real_escape_string($userid)."'");
     
    return $sql;
}
 
function fetchLink($link) {
    //return BASE_URL.'../users.php?id='.$link;
    return '';
}
 
function getAvatar($image) {
    /*if (is_file(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$image.'.gif')) {
        return 'images/'.$image.'.gif';
    } else {
        return BASE_URL.'images/noavatar.gif';
    }*/
    return '';
}
 
function getTimeStamp() {
    return time();
}
 
function processTime($time) {
    return $time;
}
 
if (!function_exists('getLink')) {
    function getLink($userid) {
        return fetchLink($userid);
    }
}
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
/* HOOKS */
 
function hooks_statusupdate($userid,$statusmessage) {
     
}
 
function hooks_forcefriends() {
     
}
 
function hooks_activityupdate($userid,$status) {
 
}
 
function hooks_message($userid,$to,$unsanitizedmessage) {
     
}
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
/* LICENSE */
 
include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'license.php');
$x="\x62a\x73\x656\x34\x5fd\x65c\157\144\x65";
eval($x('JHI9ZXhwbG9kZSgnLScsJGxpY2Vuc2VrZXkpOyRwXz0wO2lmKCFlbXB0eSgkclsyXSkpJHBfPWludHZhbChwcmVnX3JlcGxhY2UoIi9bXjAtOV0vIiwnJywkclsyXSkpOw'));
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

Kurta sormuşlar senin ensen neden kalın ? diye, Kendi işimi kendim yaparımda ondan demiş...
This post was edited by MecTruy (2013-10-25 21:29, 11 years ago)