Welcome Guest, Not a member yet? Register   Sign In
Beta - but working - code for a new and extensive Session Library.
#4

[eluser]starbbs[/eluser]
Code:
function check_activity(){
  // it selects the field nick (which is the only one to be displayd) and then it filters for 1 day or less in age of activity. after that, it filters for 5 minutes or less in activity.
  // first you need to filter away the other days, or your script might get fooled to think that yesterdays login was todays.
  // SELECT nick FROM `users` WHERE TO_DAYS( NOW( ) ) - TO_DAYS( last_login ) <=1 AND DATE_FORMAT( CURRENT_TIMESTAMP( ) , '%H%i' ) - DATE_FORMAT( last_login, '%H%i' ) <=5 ORDER BY `nick` ASC;
}

/**
  * Get the number of online users
  *
  *   This is not 100% accurate. It depends on how often the garbage collector is run
  *
  * @return integer approximate number of users currently online
  */
function get_users_online(){
  // counts the rows from the database
  $result = $CI->db->query('SELECT COUNT(session_id) as count FROM ' . $this->tablename . '');
  // return the number of found rows
  return $result["count"];
}

/**
  * Enter description here...
  *
  * Use like this. $this->Session->setFlash('This has been saved');
  *
  * @param string $flashMessage Message to be flashed
  * @param string $layout Layout to wrap flash message in
  * @param array $params Parameters to be sent to layout as view variables
  * @param string $key Message key, default is 'flash'
  * @return string Last session error
  */
function setFlash($flashMessage, $layout = 'default', $params = array(), $key = 'flash'){
  if ($layout == 'default'){
   $out = '<div id="' . $key . 'Message" class="message">' . $flashMessage . '</div>';
  }else if($layout == '' || $layout == null){
   $out = $flashMessage;
  }else{
   $ctrl = null;
   $view = new View($ctrl);
   $view->base = $this->base;
   $view->webroot = $this->webroot;
   $view->here = $this->here;
   $view->params = $this->params;
   $view->action = $this->action;
   $view->val = $this->val;
   $view->plugin = $this->plugin;
   $view->helpers = array('Html');
   $view->layout = $layout;
   $view->pageTitle = '';
   $view->_viewVars = $params;
   $out = $view->renderLayout($flashMessage);
  }
  $this->write('Message.' . $key, $out);
}
/**
  * Use like this. $this->Session->flash();
  *
  * @param string $key Optional message key
  * @return null
  */
function flash($key = 'flash'){
  if ($this->check('Message.' . $key)){
   e($this->read('Message.' . $key));
   $this->del('Message.' . $key);
  }else{
   return false;
  }
}
}

?&gt;

Thats it... your guruus can figure this out


Messages In This Thread
Beta - but working - code for a new and extensive Session Library. - by El Forum - 07-19-2007, 12:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB