Beispiel #1
0
 /**
  * Normalise a user avatar path / URL
  * @since Version 3.9.1
  * @param array $data The data array as returned from Redis/Database
  * @return array
  */
 public static function normaliseAvatarPath($data)
 {
     if (!is_null(filter_var($data['user_avatar'], FILTER_SANITIZE_STRING))) {
         $data['user_avatar_filename'] = $data['user_avatar'];
         if (!stristr($data['user_avatar'], "http://") && !stristr($data['user_avatar'], "https://")) {
             $data['user_avatar'] = sprintf("http://%s/modules/Forums/images/avatars/%s", filter_input(INPUT_SERVER, "SERVER_NAME", FILTER_SANITIZE_STRING), $data['user_avatar']);
         }
     }
     /**
      * Set the default avatar
      */
     if (empty($data['user_avatar']) || substr($data['user_avatar'], -9, 5) == "blank") {
         $data['user_avatar'] = AvatarUtility::Format(AvatarUtility::DEFAULT_AVATAR, 120, 120);
         $data['user_avatar_filename'] = AvatarUtility::Format(AvatarUtility::DEFAULT_AVATAR, 120, 120);
         $data['user_avatar_width'] = 120;
         $data['user_avatar_height'] = 120;
     }
     return $data;
 }
Beispiel #2
0
 /**
  * Load notes
  * @since Version 3.2
  * @version 3.2
  * @return array
  */
 public function loadNotes()
 {
     $query = "SELECT n.*, u.username, user_avatar FROM loco_notes AS n LEFT JOIN nuke_users AS u ON n.user_id = u.user_id WHERE n.loco_id = ?";
     $notes = array();
     foreach ($this->db->fetchAll($query, $this->id) as $row) {
         if (!empty($row['user_avatar'])) {
             try {
                 #$User = UserFactory::CreateUser($row['user_id']);
                 $row['user_avatar'] = AvatarUtility::Format($row['user_avatar'], 50, 50);
                 #$row['user_url'] = $User->url;
                 $row['user_url'] = UserUrlUtility::MakeURLs($row);
             } catch (Exception $e) {
                 global $Error;
                 $Error->save($e);
             }
         }
         $notes[$row['note_id']] = $row;
     }
     return $notes;
 }
Beispiel #3
0
 /**
  * Get an array of this users' data
  * @since Version 3.9.1
  * @return array
  */
 public function getArray()
 {
     return array("id" => $this->id, "username" => $this->username, "realname" => $this->real_name, "contact_email" => $this->contact_email, "avatar" => $this->avatar, "avatar_sizes" => Utility\AvatarUtility::getAvatarSizes($this->avatar), "url" => $this->url->getURLs());
 }
 /**
  * Find the most concacted members between the supplied user
  * @since Version 3.10.0
  * @return array
  */
 public function getMostContactedUsers()
 {
     if (!$this->Author instanceof User) {
         throw new Exception(__NAMESPACE__ . "::Author has not been set");
     }
     $query = "SELECT COUNT(*) AS num_msgs, pm.privmsgs_to_userid AS user_id, u.username, u.user_avatar\n                        FROM nuke_bbprivmsgs AS pm \n                            LEFT JOIN nuke_users AS u ON u.user_id = pm.privmsgs_to_userid \n                        WHERE pm.privmsgs_from_userid = ? \n                        AND pm.privmsgs_to_userid != ? \n                        AND pm.privmsgs_date >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 90 day)) \n                        GROUP BY pm.privmsgs_to_userid \n                        ORDER BY COUNT(*) DESC \n                        LIMIT 0, 10";
     $params = [$this->Author->id, $this->Author->id];
     $users = $this->db->fetchAll($query, $params);
     foreach ($users as $key => $row) {
         $users[$key]['url'] = UserUrlUtility::MakeURLs($row)->getURLs();
         $users[$key]['avatar'] = array("tiny" => AvatarUtility::Format($row['user_avatar'], 25, 25), "thumb" => AvatarUtility::Format($row['user_avatar'], 50, 50), "small" => AvatarUtility::Format($row['user_avatar'], 75, 75), "medium" => AvatarUtility::Format($row['user_avatar'], 100, 100));
     }
     return $users;
 }
Beispiel #5
0
 /**
  * Get users of this camera, and order them by quanity of photos
  * @since Version 3.10.0
  * @return array
  */
 public function getRailpageUsersByQuantity()
 {
     $query = "SELECT COUNT(*) AS num_photos, u.user_id, u.username, u.user_avatar\r\n                    FROM nuke_users AS u\r\n                    LEFT JOIN image AS i ON i.user_id = u.user_id\r\n                    LEFT JOIN image_exif AS f ON f.image_id = i.id\r\n                    WHERE f.camera_id = ?\r\n                    AND i.user_id != 0\r\n                    GROUP BY u.user_id\r\n                    ORDER BY COUNT(*) DESC";
     $result = $this->db->fetchAll($query, $this->id);
     foreach ($result as $id => $row) {
         if ($row['username'] == "phpunit6") {
             unset($result[$id]);
             continue;
         }
         $row['avatar_sizes'] = array("tiny" => AvatarUtility::Format($row['user_avatar'], 25, 25), "thumb" => AvatarUtility::Format($row['user_avatar'], 50, 50), "small" => AvatarUtility::Format($row['user_avatar'], 75, 75), "medium" => AvatarUtility::Format($row['user_avatar'], 100, 100));
         $result[$id] = $row;
     }
     return $result;
 }
Beispiel #6
0
 /**
  * Get the screener of the selected image
  * @since Version 3.10.0
  * @param \Railpage\Images\Image $imageObject
  * @return array
  */
 public function getImageScreener(Image $imageObject)
 {
     $query = "SELECT f.*, f.screened_by AS user_id, u.username, u.user_avatar, CONCAT('/user/', f.screened_by) AS url FROM image_flags AS f LEFT JOIN nuke_users AS u ON f.screened_by = u.user_id WHERE image_id = ?";
     $row = $this->db->fetchRow($query, $imageObject->id);
     $av = $row['user_avatar'];
     $row['user_avatar'] = ["tiny" => AvatarUtility::Format($av, 25, 25), "thumb" => AvatarUtility::Format($av, 50, 50), "small" => AvatarUtility::Format($av, 75, 75), "medium" => AvatarUtility::Format($av, 100, 100)];
     return $row;
 }
Beispiel #7
0
 /**
  * Get actions on this article
  * @since Version 3.10.0
  * @return array
  */
 public function getChangelog()
 {
     $query = "SELECT u.username, u.user_id, u.user_avatar, s.time AS timestamp, 'Article created' AS title, '' AS args\r\n                        FROM nuke_stories AS s\r\n                        LEFT JOIN nuke_users AS u ON u.user_id = s.user_id\r\n                        WHERE s.sid = ?\r\n                    UNION \r\n                    SELECT u.username, l.user_id, u.user_avatar, l.timestamp, l.title, l.args \r\n                        FROM log_staff AS l \r\n                        LEFT JOIN nuke_users AS u ON u.user_id = l.user_id\r\n                        WHERE `key` = 'article_id' \r\n                        AND key_val = ? \r\n                    UNION \r\n                    SELECT u.username, l.user_id, u.user_avatar, l.timestamp, l.title, l.args \r\n                        FROM log_general AS l \r\n                        LEFT JOIN nuke_users AS u ON u.user_id = l.user_id\r\n                        WHERE `key` = 'article_id' \r\n                        AND value = ? \r\n                    ORDER BY UNIX_TIMESTAMP(`timestamp`) DESC";
     $params = [$this->id, $this->id, $this->id];
     $return = $this->db->fetchAll($query, $params);
     foreach ($return as $key => $val) {
         $return[$key]['user'] = array("user_id" => $val['user_id'], "username" => $val['username'], "avatar" => array("small" => AvatarUtility::Format($val['user_avatar'], 50, 50), "medium" => AvatarUtility::Format($val['user_avatar'], 80, 80), "large" => AvatarUtility::Format($val['user_avatar'], 128, 128)), "url" => UrlUtility::MakeURLs($val)->getURLs());
         $return[$key]['args'] = json_decode($val['args'], true);
     }
     return $return;
 }