Esempio n. 1
0
 public static function getUsersData($group_type = self::REG_ORDER_BY_DAY)
 {
     switch ($group_type) {
         case self::REG_ORDER_BY_DAY:
             $group = 'date(timestamp)';
             break;
         case self::REG_ORDER_BY_MONTH:
             $group = 'month(timestamp)';
             break;
         case self::REG_ORDER_BY_YEAR:
             $group = 'year(timestamp)';
             break;
     }
     $regs_rs = Default_UsersModel::getStats($group);
     $logins_rs = Default_LogsModel::getStats($group);
     //		$return = array(
     //			'dates'  => array(),
     //			'regs'   => array(),
     //			'logins' => array(),
     //		);
     // fill the info
     $k = 1;
     $return = array();
     foreach ($logins_rs as $date => $row) {
         $return[$k]['dates'] = $date;
         $return[$k]['regs'] = isset($regs_rs[$date]) ? $regs_rs[$date]->count : 0;
         $return[$k]['logins'] = $logins_rs[$date]->count;
         $k++;
     }
     return $return;
 }
Esempio n. 2
0
 public function statsAction()
 {
     $return = array();
     /* get disk space free (in bytes) */
     $df = disk_free_space("/");
     /* and get disk space total (in bytes)  */
     $dt = disk_total_space("/");
     /* now we calculate the disk space used (in bytes) */
     $du = $dt - $df;
     /* percentage of disk used - this will be used to also set the width % of the progress bar */
     $dp = sprintf('%.2f', $du / $dt * 100);
     /* and we formate the size from bytes to MB, GB, etc. */
     $df = Core_Tools::formatSize($df);
     $du = Core_Tools::formatSize($du);
     $dt = Core_Tools::formatSize($dt);
     $return['disk'] = array('free' => $df, 'total' => $dt, 'usage' => $du, 'percente' => $dp);
     $return['cpu'] = sys_getloadavg();
     //uptime
     exec("uptime", $system);
     // get the uptime stats
     $string = $system[0];
     // this might not be necessary
     @(list($dummy, $uptime, $dummy, $up_days, $dummy, $dummy, $dummy, $dummy, $users, $dummy, $dummy, $dummy, $dummy, $load0, $load1, $load2, ) = explode(" ", $string));
     unset($dummy);
     $return['uptime'] = array('uptime' => $uptime, 'up_days' => $up_days, 'users' => $users, 'load0' => $load0, 'load1' => $load1, 'load2' => $load2);
     //memory
     $free = shell_exec('free');
     $free = (string) trim($free);
     $free_arr = explode("\n", $free);
     $mem = explode(" ", $free_arr[1]);
     $mem = array_filter($mem);
     $mem = array_merge($mem);
     $total_available = $mem[1];
     $memory_usage = $mem[2];
     $return['memory'] = array('total' => $total_available / 1000000, 'used' => $memory_usage / 1000000, 'free' => ($total_available - $memory_usage) / 1000000);
     // users
     $users_rs = Default_UsersModel::getCount();
     $return['users'] = $users_rs['cnt'];
     // coments
     $comments_rs = Default_CommentsModel::getCount();
     $return['comments'] = $comments_rs['cnt'];
     // feedback
     $feedback_rs = Default_FeedbackModel::getCount(array('is_read' => 0));
     $return['feedback'] = $feedback_rs['cnt'];
     // reports
     $reports_rs = Default_ReportsModel::getCount(array('is_read' => 0));
     $return['reports'] = $reports_rs['cnt'];
     // slips
     $slips_rs = Default_BettingSlipsModel::getCount();
     $return['slips'] = $slips_rs['cnt'];
     // messages
     $messages_rs = Default_MessagesModel::getCount();
     $return['messages'] = $messages_rs['cnt'];
     //		online users
     $online_rs = Default_UsersModel::getOnline(cfg()->activity_period);
     $return['online'] = count($online_rs);
     // regs nad logins
     $regs_and_logins = Api_StatisticsHelper::getUsersData();
     $return['regs'] = $regs_and_logins;
     // votes
     $votes_rs = Default_VotesModel::getCount();
     $return['votes'] = $votes_rs['cnt'];
     // ALL translates
     $translates_rs = Default_TranslateModel::getCount(array('not_found_date' => '0000-00-00 00:00:00'));
     $return['translates'] = $translates_rs['cnt'];
     $this->addResponse($return);
 }
Esempio n. 3
0
 /**
  * @param $user_id
  * @param $user_data
  */
 protected static function loadUser($user_id, &$user_data)
 {
     if (isset($user_data['user'])) {
         unset($user_data['user']);
     }
     $user_data['user'] = Core_Tools::toArray(Default_UsersModel::get(array('id' => $user_id)));
     // Fix Language
     if (!$user_data['user']['language_code']) {
         foreach (cfg()->language_codes as $code => $name) {
             Default_UsersModel::set(array('language_code' => $code), array('id' => $user_id));
             $user_data['user']['language_code'] = $code;
             break;
         }
     }
 }