예제 #1
0
파일: ChatDAO.php 프로젝트: buguelos/dash2
 /**
  * Deletes message from DB
  *
  * @param number $id
  */
 public function delete($id)
 {
     $db = DBConnection::getInstance();
     $query = $db->prepare("DELETE FROM chat WHERE id=:message_id ");
     $query->bindParam('message_id', $id);
     $query->execute();
 }
예제 #2
0
 /**
  * Resends message
  *
  * @param Message $message
  */
 public function resend(Message $message)
 {
     $db = DBConnection::getInstance();
     $query = $db->prepare("UPDATE message_targets SET status = :new_status\n            WHERE\n                message_id = :message_id AND\n                status = :old_status ");
     $oldStatus = Message::MESSAGE_STATUS_SENT;
     $newStatus = 0;
     $query->bindParam('message_id', $message->getId());
     $query->bindParam('old_status', $oldStatus);
     $query->bindParam('new_status', $newStatus);
     $query->execute();
 }
예제 #3
0
파일: GroupDAO.php 프로젝트: buguelos/dash2
 public function markSynced($groupId, $numbers)
 {
     $db = DBConnection::getInstance();
     if (empty($numbers)) {
         return;
     }
     if (!is_array($numbers)) {
         $numbers = array($numbers);
     }
     $ids = '';
     foreach ($numbers as $number) {
         $ids .= "'" . $number . "',";
     }
     $ids = substr($ids, 0, -1);
     $query = $db->prepare("UPDATE numbers SET synced=1 WHERE group_id = " . $groupId . " AND target IN (" . $ids . ") ");
     $query->execute();
 }
예제 #4
0
 /**
  * Deletes sender
  *
  * @param number $id
  */
 public function delete($id)
 {
     $sender = $this->fetch($id);
     $db = DBConnection::getInstance();
     $query = $db->prepare("DELETE FROM chat WHERE `to` = :to");
     $query->bindParam('to', $sender->getUsername());
     $query->execute();
     $query = $db->prepare("DELETE FROM messages WHERE sender_id = :sender_id");
     $query->bindParam('sender_id', $id, \PDO::PARAM_INT);
     $query->execute();
     $query = $db->prepare("DELETE FROM senders WHERE id = :sender_id");
     $query->bindParam('sender_id', $id, \PDO::PARAM_INT);
     $query->execute();
 }
예제 #5
0
파일: index.php 프로젝트: buguelos/dash2
require_once __DIR__ . '/../config.php';
session_cache_limiter(false);
session_start();
// View Config
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig()));
$app->view->twigTemplateDirs = array(MAINDIR . '/tmpl');
$app->view->set('MAINURL', MAINURL);
$app->notFound(function () use($app) {
    $app->render('404.html');
});
$twig = $app->view->getInstance();
$twig->addFunction(new Twig_SimpleFunction('wordInString', function ($word, $str) {
    return in_array($word, explode(',', $str));
}));
// Auth configuration
$configStrong = array('provider' => 'PDO', 'pdo' => \GitGis\Whatsapp\Model\DBConnection::getInstance(), 'auth.type' => 'form', 'login.url' => MAINURL . '/auth/login', 'security.urls' => array(array('path' => '/messages/?.*'), array('path' => '/inbox/?.*'), array('path' => '/groups/?.*'), array('path' => '/senders/?.*'), array('path' => '/reports/?.*'), array('path' => '/users/?.*')));
$app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware());
$app->add(new \Slim\Extras\Middleware\StrongAuth($configStrong));
$app->add(new \GitGis\Auth\GitGisMiddleware());
$app->get('/auth/login', array('\\GitGis\\Auth\\AuthController', 'getLoginPage'));
$app->post('/auth/login', array('\\GitGis\\Auth\\AuthController', 'postLoginPage'));
$app->get('/auth/logout', array('\\GitGis\\Auth\\AuthController', 'getLogoutPage'));
// Routes
$app->get('/', array('\\GitGis\\Whatsapp\\MainController', 'getPage'));
$app->get('/reports/sent/?', array('\\GitGis\\Whatsapp\\ReportsController', 'getSentPage'));
$app->get('/reports/sent/:page/?', array('\\GitGis\\Whatsapp\\ReportsController', 'getSentPage'))->conditions(array('page' => '[0-9]+'));
$app->get('/reports/inbox/?', array('\\GitGis\\Whatsapp\\ReportsController', 'getInboxPage'));
$app->get('/reports/inbox/:page/?', array('\\GitGis\\Whatsapp\\ReportsController', 'getInboxPage'))->conditions(array('page' => '[0-9]+'));
$app->get('/messages/?', array('\\GitGis\\Whatsapp\\MessagesController', 'getPage'));
$app->get('/messages/:page/?', array('\\GitGis\\Whatsapp\\MessagesController', 'getPage'))->conditions(array('page' => '[0-9]+'));
$app->get('/messages/send_text', array('\\GitGis\\Whatsapp\\MessagesController', 'getSendText'));
예제 #6
0
파일: UserDAO.php 프로젝트: buguelos/dash2
 /**
  * Deletes user
  * 
  */
 public function delete($id)
 {
     $db = DBConnection::getInstance();
     $sql = " UPDATE users SET password='', dtime=:dtime WHERE id=:id ";
     $query = $db->prepare($sql);
     $query->bindParam('id', $id, \PDO::PARAM_INT);
     $query->bindParam('dtime', time());
     $query->execute();
 }