Beispiel #1
0
 public function login($username, $password)
 {
     $table = self::$table;
     $found = $this->db->{$table}->findOne(['username' => $username, 'password' => Hash::hash($password)]);
     if (!$found) {
         throw new Validation_Exception("Login/Hasło", 7);
     }
     Session::set('userId', $found['_id']);
     $this->get($found['_id']);
 }
Beispiel #2
0
 public function add($data, $files)
 {
     $table = self::$table;
     $this->title = $data['title'];
     if (isset($data['autorUser'])) {
         $this->autorUser = $data['autorUser'];
         $this->tryb = $data['tryb'] == 'private' ? 'private' : 'public';
     } else {
         $this->autor = $data['autor'];
     }
     $fileExtension = pathinfo(basename($files["file"]["name"]), PATHINFO_EXTENSION);
     $targetName = Hash::hash(rand(1, 9999999) . "" . Hash::hash(rand(1, 9999999))) . "." . $fileExtension;
     $targetPath = SITE_ROOT . "/assets/uploads/" . $targetName;
     if (!move_uploaded_file($files["file"]["tmp_name"], $targetPath)) {
         throw new Validation_Exception('Zdjęcie', 13);
     }
     $this->photoPath = $targetName;
     $waterMarkName = Hash::hash(rand(1, 9999999) . "" . Hash::hash(rand(1, 9999999))) . ".jpg";
     $waterMarkPath = SITE_ROOT . "/assets/uploads/" . $waterMarkName;
     Photo::addWaterMarkText($targetPath, $waterMarkPath, "TEST");
     $this->bigPath = $waterMarkName;
     $thumbName = Hash::hash(rand(1, 9999999) . "" . Hash::hash(rand(1, 9999999))) . ".jpg";
     $thumbPath = SITE_ROOT . "/assets/uploads/" . $thumbName;
     Photo::createThumbnail($targetPath, $thumbPath);
     $this->smallPath = $thumbName;
     $this->save();
 }