/** * save user privacy info * * @param array $val * @param \App\Models\User $user * @return boolean */ public function savePrivacy($val, $user = null) { $user = empty($user) ? \Auth::user() : $user; $privacy = empty($user->privacy_info) ? [] : perfectUnserialize($user->privacy_info); $privacy = array_merge($privacy, $val); $user->privacy_info = perfectSerialize(sanitizeUserInfo($privacy)); $user->save(); $this->event->fire('user.save.privacy', [$user]); return true; }
public function save($val, $game, $isAdmin = false) { $expected = ['title', 'description', 'category', 'content' => '', 'approved' => \Config::get('game-need-confirm') ? 0 : 1, 'verified' => 0, 'info' => [], 'width' => '100%', 'height' => '450']; /** * @var $title * @var $description * @var $category * @var $approved * @var $verified * @var $content * @var $info * @var $width * @var $height */ extract(array_merge($expected, $val)); if ($isAdmin or \Auth::user()->isAdmin()) { $approved = 1; } $gameFile = ''; if (\Input::hasFile('file')) { $maxSize = \Config::get('game-max-upload', 10000000); $file = \Input::file('file'); $ext = $file->getClientOriginalExtension(); if ($file->getSize() > $maxSize or strtolower($ext) != 'swf') { return false; } $userid = \Auth::user()->id; $filePath = "uploads/games/" . $userid . '/'; //ensure the folder exists $this->file->makeDirectory(public_path() . '/' . $filePath, 0777, true, true); $fileName = md5($file->getClientOriginalName() . time()) . '.swf'; $gameFile = $filePath . $fileName; if (!empty($game->game_path)) { //lets delete this old game $this->file->delete(public_path('') . '/' . $game->game_path); } $file->move(public_path() . '/' . $filePath, $fileName); } //one of game file and content must not be empty //if (empty($gameFile) and empty($content)) return false; $category = sanitizeText($category); if (!$this->category->get($category)) { return false; } if (!empty($title)) { $game->title = sanitizeText($title, 130); $game->description = sanitizeText($description); $game->category = $category; $game->user_id = \Auth::user()->id; $game->verified = $verified; $game->approved = $approved; $game->iframe_content = $content; if ($gameFile) { $game->game_path = $gameFile; } if ($width) { $game->width = sanitizeText($width); } if ($height) { $game->height = sanitizeText($height); } $game->info = serialize(sanitizeUserInfo($info)); $game->save(); return $game; } return false; }