Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. add_action('init', 'start_ap_session', 1);
  2.  
  3. function start_ap_session() {
  4.  
  5.     if( !session_id() ) {
  6.  
  7.         session_start();
  8.  
  9.         if ( isset( $_SESSION['last_activity'] ) && ( time() - $_SESSION['last_activity'] > 1800) ) {
  10.  
  11.             session_unset();
  12.             session_destroy();
  13.  
  14.         }
  15.  
  16.         $_SESSION['last_activity'] = time();
  17.  
  18.         if ( !isset( $_SESSION['records'] ) ) {
  19.  
  20.             require ABSPATH . '/FM/fmdb.php';
  21.  
  22.             $records = get_webflats();
  23.  
  24.             foreach ($records as $key => $value) {
  25.                 if ( $value->floor == 'ground floor' ) {
  26.                     unset($records[$key]);
  27.                 }
  28.             }
  29.  
  30.             $_SESSION['records'] = $records;
  31.  
  32.             $total_disp_nr = count($records);
  33.  
  34.             foreach ( $records as $r ) {
  35.                 if ( $r->reserved == 'yes' ) {
  36.                     $total_disp_nr--;
  37.                 }
  38.             }
  39.  
  40.             $_SESSION['disp'] = $total_disp_nr;
  41.  
  42.         }
  43.  
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement