Example #1
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Example #2
0
 function __construct()
 {
     $this->conex = Conex::getInstance()->getPDO();
 }
Example #3
0
function sendChat()
{
    $from = $_SESSION['id_us'];
    $to = $_POST['to'];
    $message = $_POST['message'];
    //--
    //Bloque para traerme el contenido de los nombres del usuario
    $bd = new Conex();
    $bd->conectar();
    $sql2 = "SELECT usuario_login FROM tbl_usuarios WHERE tbl_usuarios.id_usuarios='" . $to . "';";
    $rs_to = $bd->execute($sql2);
    $to_us = $rs_to[0][0];
    //--
    $_SESSION['openChatBoxes'][$_POST['to']] = date('Y-m-d H:i:s', time());
    $messagesan = sanitize($message);
    if (!isset($_SESSION['chatHistory'][$_POST['to']])) {
        $_SESSION['chatHistory'][$_POST['to']] = '';
    }
    $_SESSION['chatHistory'][$_POST['to']] .= <<<EOD
\t\t\t\t\t   {
\t\t\t"s": "1",
\t\t\t"f": "{$to}",
\t\t\t"m": "{$messagesan}",
\t\t\t"h": "{$to_us}"
\t   },
EOD;
    unset($_SESSION['tsChatBoxes'][$_POST['to']]);
    $fecha = date("Y-m-d");
    $bd = new Conex();
    $bd->conectar();
    $sql = "insert into tbl_chat (de,para,message,sent) values ('" . $from . "', '" . $to . "','" . $message . "','" . $fecha . "')";
    //--Para mysql
    //$query = mysql_query($sql);
    //--Para postgresql
    $query = $bd->execute($sql);
    //
    echo "1";
    exit(0);
}