Example #1
0
 public static function close()
 {
     // garbage collect once in a hundred page requests
     if (rand(1, 100) == 100) {
         Session::cleanup();
     }
     return @sqlite_close(SESSION_DB_LINK);
 }
Example #2
0
File: auth.php Project: pihizi/qf
 static function login($token)
 {
     // session_unset();
     Session::cleanup();
     session_regenerate_id();
     $_SESSION['auth.token'] = $token;
     Event::trigger('auth.login', $token);
     return $token;
 }
Example #3
0
 /**
  * Add unread notification count to all API responses, when logged in
  *
  * @return boolean hook flag
  */
 public function onEndSetApiUser($user)
 {
     // cleanup sessions, to allow for simultaneous http-requests,
     // e.g. if posting a notice takes a very long time
     Session::cleanup();
     if (!$user instanceof User) {
         return true;
     }
     $user_id = $user->id;
     $notification = new QvitterNotification();
     $notification->selectAdd();
     $notification->selectAdd('ntype');
     $notification->selectAdd('count(id) as count');
     $notification->whereAdd("(to_profile_id = '" . $user_id . "')");
     // the user might have opted out from certain notification types
     $current_profile = $user->getProfile();
     $disable_notify_replies_and_mentions = Profile_prefs::getConfigData($current_profile, 'qvitter', 'disable_notify_replies_and_mentions');
     $disable_notify_favs = Profile_prefs::getConfigData($current_profile, 'qvitter', 'disable_notify_favs');
     $disable_notify_repeats = Profile_prefs::getConfigData($current_profile, 'qvitter', 'disable_notify_repeats');
     $disable_notify_follows = Profile_prefs::getConfigData($current_profile, 'qvitter', 'disable_notify_follows');
     if ($disable_notify_replies_and_mentions == '1') {
         $notification->whereAdd('qvitternotification.ntype != "mention"');
         $notification->whereAdd('qvitternotification.ntype != "reply"');
     }
     if ($disable_notify_favs == '1') {
         $notification->whereAdd('qvitternotification.ntype != "like"');
     }
     if ($disable_notify_repeats == '1') {
         $notification->whereAdd('qvitternotification.ntype != "repeat"');
     }
     if ($disable_notify_follows == '1') {
         $notification->whereAdd('qvitternotification.ntype != "follow"');
     }
     $notification->groupBy('ntype');
     $notification->whereAdd("(is_seen = '0')");
     $notification->whereAdd("(notice_id IS NOT NULL)");
     // sometimes notice_id is NULL, those notifications are corrupt and should be discarded
     $notification->find();
     $new_notifications = array();
     while ($notification->fetch()) {
         $new_notifications[$notification->ntype] = $notification->count;
     }
     header('Qvitter-Notifications: ' . json_encode($new_notifications));
     return true;
 }
Example #4
0
 /**
  * Add unread notification count to all API responses, when logged in
  *
  * @return boolean hook flag
  */
 public function onEndSetApiUser($user)
 {
     // cleanup sessions, to allow for simultaneous http-requests,
     // e.g. if posting a notice takes a very long time
     Session::cleanup();
     if (!$user instanceof User) {
         return true;
     }
     $user_id = $user->id;
     $notification = new QvitterNotification();
     $notification->selectAdd();
     $notification->selectAdd('ntype');
     $notification->selectAdd('count(id) as count');
     $notification->whereAdd("(to_profile_id = '" . $user_id . "')");
     $notification->groupBy('ntype');
     $notification->whereAdd("(is_seen = '0')");
     $notification->whereAdd("(notice_id IS NOT NULL)");
     // sometimes notice_id is NULL, those notifications are corrupt and should be discarded
     $notification->find();
     $new_notifications = array();
     while ($notification->fetch()) {
         $new_notifications[$notification->ntype] = $notification->count;
     }
     header('Qvitter-Notifications: ' . json_encode($new_notifications));
     return true;
 }