Visualizzazione risultati 1 fino 12 di 12

Discussione: Problema con database e cometchat

  1. #1
    Guest

    Question Problema con database e cometchat

    Salve,
    non so se è questa la zona giusta per chiedere questa cosa...
    Allora ho qui con me lo script della cometchat e lo caricata sul mio spazio web di AC funziona tutto solo che per chattare bisgna eseguire il log-in e non so come far funzionare la cometchat con il database di altervista!!!
    Qualcuno ha mai usato la cometchat su altervista??Mi potrebbe spiegare qlcn come fare??
    Nella cartella non ci sono file per creare tabelle mysql nel database...è la versione 2.0.4...
    Grazie
    Ultima modifica di gsmcommunity : 12-07-2011 alle ore 16.59.24 Motivo: Dimenticato di attivare la modifica MAIL

  2. #2
    Guest

    Predefinito

    Se la chat prevede un autenticazione probabilmente ha bisogno di appoggiarsi su un sistema che memorizza a se gli utenti.

    Non l'ho mai usata, e l'ultima versione è a pagamento, se riesci dicci almeno la versione di quello che stai utilizzando, se non ci sono pagine di installazione non c'è manco un file per creare le tabelle nel database?

  3. #3
    Guest

    Predefinito

    Allora è la versione 2.0.4 e non ci sono file per tabelle
    Ho fatto ricerce 24 ore su 24 per trovare qlcs...
    ma nn ho trovato nt...
    Ultima modifica di gsmcommunity : 12-07-2011 alle ore 17.01.39

  4. #4
    Guest

    Predefinito

    Non saprei, ho fatto una mini ricerca ora e pare si appoggi a forum e blog, ho visto vbullettin e wordpress.. è mica un plugin?

  5. #5
    Guest

    Predefinito

    Il mio sito lo sto realizzando in html e php da solo senza wordpress o cose del genere...
    Però la barra della chat esce e funziona solo che ci vuole il login

  6. #6
    Guest

    Predefinito

    Però ho trovato qst script che se forse lo configuro funziona??
    <?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','1');
    define('INCLUDE_JQUERY','1');
    define('FORCE_MAGIC_QUOTES','0');

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /* DATABASE */

    include_once dirname(dirname(__FILE__))."/includes/config.php";

    // DO NOT EDIT DATABASE VALUES BELOW
    // DO NOT EDIT DATABASE VALUES BELOW
    // DO NOT EDIT DATABASE VALUES BELOW

    define('DB_SERVER', $config['MasterServer']['servername'] );
    define('DB_PORT', $config['MasterServer']['port'] );
    define('DB_USERNAME', $config['MasterServer']['username'] );
    define('DB_PASSWORD', $config['MasterServer']['password'] );
    define('DB_NAME', $config['Database']['dbname'] );
    define('TABLE_PREFIX', $config['Database']['tableprefix'] );
    define('DB_USERTABLE', 'user' );
    define('DB_USERTABLE_NAME', 'username' );
    define('DB_USERTABLE_USERID', 'userid' );
    define('DB_USERTABLE_LASTACTIVITY', 'lastactivity' );

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /* FUNCTIONS */

    function getUserID() {
    $userid = 0;
    global $config;

    $cookie = $config['Misc']['cookieprefix'].'sessionhash';

    if (!empty($_COOKIE[$cookie])) {
    $sql = ("select userid from ".TABLE_PREFIX."session where sessionhash = '".mysql_real_escape_string($_COOKIE[$cookie])."'");
    $query = mysql_query($sql);
    $session = mysql_fetch_array($query);
    $userid = $session['userid'];
    }

    $cookie = $config['Misc']['cookieprefix'].'_sessionhash';

    if (!empty($_COOKIE[$cookie])) {
    $sql = ("select userid from ".TABLE_PREFIX."session where sessionhash = '".mysql_real_escape_string($_COOKIE[$cookie])."'");
    $query = mysql_query($sql);
    $session = mysql_fetch_array($query);
    $userid = $session['userid'];
    }

    return $userid;
    }

    function getFriendsList($userid,$time) {

    $sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME. " username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTA CTIVITY." lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." link, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX."userlist join ".TABLE_PREFIX.DB_USERTABLE." on ".TABLE_PREFIX."userlist.relationid = ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." = cometchat_status.userid where ".TABLE_PREFIX."userlist.friend = 'yes' and ".TABLE_PREFIX."userlist.userid = '".mysql_real_escape_string($userid)."' order by username asc");

    if (defined('DISPLAY_ALL_USERS') && DISPLAY_ALL_USERS == 1) {

    $sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME. " username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTA CTIVITY." lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." link, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX.DB_USERTABLE." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." = cometchat_status.userid where ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." <> '".mysql_real_escape_string($userid)."' and ('".$time."'-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 getUserDetails($userid) {
    $sql = ("select ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." userid, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME. " username, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTA CTIVITY." lastactivity, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." link, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." avatar, cometchat_status.message, cometchat_status.status from ".TABLE_PREFIX.DB_USERTABLE." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." = cometchat_status.userid where ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." = '".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 getLink($link) {
    return BASE_URL."../member.php?u=".$link;
    }

    function getAvatar($image) {
    return BASE_URL."../ccpic.php?userid=".$image;
    }

    function getTimeStamp() {
    return time();
    }

    function processTime($time) {
    return $time;
    }

    function processName($name) {
    // For vBulletin users ONLY
    // Uncomment the next two lines and change only ISO-8859-9 to your site encoding type

    // $name = iconv("UTF-8", "ISO-8859-1", $name);
    // $name = iconv("ISO-8859-9", "UTF-8", $name);

    return $name;
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /* HOOKS */

    function hooks_statusupdate($userid,$unsanitizedmessage) {

    }

    function hooks_forcefriends() {

    }

    function hooks_activityupdate($userid,$unsanitizedstatus) {

    }

    function hooks_message($fromid,$toid,$unsanitizedmessage) {

    }

    function hooks_displaybar($currentstate) {
    return $currentstate;
    }

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /* LICENSE */

    include_once(dirname(__FILE__).'/license.php');
    $x="\x62a\x73\x656\x34\x5fd\x65c\157\144\x65";
    eval($x('JHI9ZXhwbG9kZSgnLScsJGxpY2Vuc2VrZXkpOyRwX z0wO2lmKCFlbXB0eSgkclsyXSkpJHBfPWludHZhbChwcmVnX3J lcGxhY2UoIi9bXjAtOV0vIiwnJywkclsyXSkpOw'));

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  7. #7
    Guest

    Predefinito

    Pare prenda i dati da un database già formato, possibile che non c'è manco un file readme che spiega se c'è una pagina di installazione via browser o meno?

  8. #8
    Guest

    Predefinito

    Non c'era nt di nt...

  9. #9
    Guest

    Predefinito

    Che cosa potrei rare

  10. #10
    Guest

    Predefinito

    Allora il sito uffficiale dice che bisogna modificare il file pubblicato sopra con la scritta rossa...
    quindi devo dare gli indirizzi per il db e fare le tabelle nell db...
    E mo come faccio a saper le tabelle che la chat utilizza?! :(

  11. #11
    Guest

    Predefinito

    Citazione Originalmente inviato da gsmcommunity Visualizza messaggio
    Allora il sito uffficiale dice che bisogna modificare il file pubblicato sopra con la scritta rossa...
    quindi devo dare gli indirizzi per il db e fare le tabelle nell db...
    E mo come faccio a saper le tabelle che la chat utilizza?! :(
    Vedi i define.. tipo:

    Codice PHP:
    define('DB_SERVER', $config['MasterServer']['servername'] );
    define('DB_PORT', $config['MasterServer']['port'] );
    define('DB_USERNAME', $config['MasterServer']['username'] );
    define('DB_PASSWORD', $config['MasterServer']['password'] );
    define('DB_NAME', $config['Database']['dbname'] );
    define('TABLE_PREFIX', $config['Database']['tableprefix'] );
    define('DB_USERTABLE', 'user' );
    define('DB_USERTABLE_NAME', 'username' );
    define('DB_USERTABLE_USERID', 'userid' );
    define('DB_USERTABLE_LASTACTIVITY', 'lastactivity' );
    user, username, userid e lastactivity devi metterli, o eventualmente li chiami in altro modo, ma devicambiare anche i define come chiami le tue tabelle, gli altri dati li prende dal file config per la connessione..
    Ultima modifica di multigame : 15-07-2011 alle ore 12.09.21

  12. #12
    Guest

    Predefinito

    Leggi qst
    This guide will help you through the installation process and get CometChat running on your site.

    Installation is very straight forward, only taking about 15 minutes from uploading the files to viewing the CometChat bar on your site.

    Before you begin, you will need an FTP client, if you do not have one, some popular solutions include FileZilla (free) or CuteFTP (trial).

    You do not need programming knowledge to install CometChat, but a working knowledge of FTP functions is a plus.

    This guide assumes that you have successfully downloaded the latest release of CometChat and have the zip file "unzipped" and ready to go. If not, you can download the package from your client area.

    The instructions will term the zip file you downloaded as cometchat.zip.

    Uploading

    At this point, you should have the zip archive cometchat.zip and find a single folder- "cometchat".

    If you don't know already, find out the folder in which Standalone site is installed.

    If you access your Standalone site site via 'www.domain.com', then look for the webroot directory.

    The "webroot" directory is usually 'public_html' or 'www', but this varies from server to server so if you're unsure, contact your hosting provider.

    Using your FTP client, copy the cometchat folder inside your Standalone site folder. e.g. www.domain.com/cometchat

    Configuration

    1. Switch on development mode

    Edit config.php and search for the tag:

    /* ADVANCED */
    Set DEV_MODE to 1 and ERROR_LOGGING to 1. After integration, you can set these to 0.

    define('DEV_MODE','1');
    define('ERROR_LOGGING','1');
    2. Add your database information

    Edit integration.php and update the DATABASE details.

    /* DATABASE */

    define('DB_SERVER','localhost');
    define('DB_PORT','3306');
    define('DB_USERNAME','root');
    define('DB_PASSWORD','password');
    define('DB_NAME','databasename');
    define('TABLE_PREFIX','');
    define('DB_USERTABLE','users');
    define('DB_USERTABLE_NAME','username');
    define('DB_USERTABLE_USERID','userid');
    define('DB_USERTABLE_LASTACTIVITY','lastactivity') ;
    The first 5 lines are used to access the database. You must access your existing database and not create a separate database for CometChat.

    The next 5 lines specify details about your database schema.

    If all your tables use a prefix, for example cc_, then specify the TABLE_PREFIX as cc_
    DB_USERTABLE specifies the name of the table in which your user information is stored.
    DB_USERTABLE_NAME specifies the name of the field in which the user's name/display name is stored.
    DB_USERTABLE_USERID specifies the name of the field in which the user's id is stored (usually id or userid or user_id or member_id). This field must be of integer type.

    define('TABLE_PREFIX','tableprefix_');
    define('DB_USERTABLE','userstable');
    define('DB_USERTABLE_NAME','username');
    define('DB_USERTABLE_USERID','userid');
    In order to keep track of which users are online, CometChat makes use of an integer field which stores a UNIX timestamp of the user's last activity. If you do not have such a field in your user's table as yet, you can execute the following SQL command:

    ALTER TABLE users ADD lastactivity INTEGER DEFAULT 0; // Update "users" to your users' table name
    3. Update single-sign-on functionality

    Scroll down to find the getUserID() function.

    The getUserID() function is used to return the logged in user's ID. Depending on how you have programmed your site, you will have to find out the user's ID.

    If you have written a simple PHP authentication, then during the authentication, you can specify a session variable like:

    /* In your own login.php */
    /* After you authenticate the user */
    $_SESSION['userid'] = $users['id']; // Modify to suit requirements
    Then your getUserID() function will look like:

    function getUserID() {
    $userid = 0; // Return 0 if user is not logged in

    if (!empty($_SESSION['userid'])) {
    $userid = $_SESSION['userid'];
    }

    return $userid;
    }
    If you are using another language like ASP, ColdFusion, Python etc. then set a cookie immediately after login with the user's ID. You can read that using the following function:

    function getUserID() {
    $userid = 0; // Return 0 if user is not logged in

    if (!empty($_COOKIE['userid'])) {
    $userid = $_COOKIE['userid'];
    }

    return $userid;
    }
    If you are using a more complex method of authentication like storing the session_hash in the database, then your getUserID() function will look something like:

    function getUserID() {
    $userid = 0; // Return 0 if user is not logged in

    if (!empty($_COOKIE['sessionhash'])) {
    $sql = ("select userid from ".TABLE_PREFIX."session
    where sessionhash = '".mysql_real_escape_string($_COOKIE['sessionhash'])."'"Zwinker;
    $query = mysql_query($sql);
    $session = mysql_fetch_array($query);
    $userid = $session['userid'];
    }

    return $userid;
    }
    4. Update Who's Online list fetching mechanism

    We modify the getFriendsList() function.

    The getFriendsList() function returns all the users' details part of the Who's Online list. This list need not necessarily be friends of the logged in user. It may simply be all online users instead. You can customize this to return any set of users.

    The default configuration assumes that you have a table called friends with the following fields:

    toid integer
    fromid integer
    All entries are assumed to be two-way i.e. if user A (id:1) and user B (id:2) are friends, then there will be two entries in the table:

    ----------------------------
    id toid fromid
    ----------------------------
    13 1 2
    14 2 1
    ----------------------------
    function getFriendsList($userid,$time) {
    $sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." userid,
    ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME. " username,
    ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTA CTIVITY." lastactivity,
    ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." 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_USERI D."
    left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." = cometchat_status.userid
    where ".TABLE_PREFIX."friends.fromid = '".mysql_real_escape_string($userid)."'
    order by username asc"Zwinker;
    return $sql;
    }
    If you would like to show all online users instead, then you can use an SQL query like:

    function getFriendsList($userid,$time) {
    $sql = ("select DISTINCT ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." userid,
    ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_NAME. " username,
    ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTA CTIVITY." lastactivity,
    ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." avatar, ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." link,
    cometchat_status.message, cometchat_status.status
    from ".TABLE_PREFIX.DB_USERTABLE." left join cometchat_status on ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." = cometchat_status.userid
    where ".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERI D." <> '".mysql_real_escape_string($userid)."' and ('".$time."'-".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_LASTA CTIVITY."<120)
    order by username asc"Zwinker;
    return $sql;
    }
    5. Update status message, avatar and links functionality

    The getUserStatus() function returns the current status message as well as state of the user (available, busy, invisible, offline). If your site already has a status updates feature, then you will have to modify the first field- cometchat_status.message which is returned to pull the status message from your table.

    Finally, we modify getLink() and getAvatar() function

    When the getFriendsList() function is executed, avatar and link contain the user id by default (you can change this if you store the avatar/link location in your table). These functions are used to post-process the data obtained from the getFriendsList() function. For example:

    function getLink($link) {
    return 'users.php?id='.$link;
    }

    function getAvatar($image) {
    if (is_file(dirname(dirname(__FILE__)).'/images/'.$image.'.gif')) {
    return '/images/'.$image.'.gif';
    } else {
    return '/images/noavatar.gif';
    }
    }
    The hooks_statusupdate() function is called when a user updates his/her status via CometChat. If your site already has a status updates feature, you can update that using this hook.

    Installation

    Step 1

    You should now run the installer file through your web browser by entering the URL to it into your browser address bar (if you have followed our example, type in www.domain.com/cometchat/install.php, naturally substituting 'domain.com' for your web address).

    If the installation was completed successfully, then two lines of HTML code will be displayed on your screen. Please copy these two lines.

    Step 2

    Now edit your template header.

    Immediately after the opening head tag add the copied code:

    Now delete install.php file from the cometchat folder.

    That's all! Now log-in to your site and you will be able to see the CometChat bar. For customizing the text, icons, plugins, theme and modules, please refer to other documents.

    Thank you for purchasing CometChat!

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •