public function addFile(\Filehosting\File $file) { $sth = $this->dbh->prepare("INSERT INTO files(filename, size, upload_time, comment, token, original_name)\n VALUES(:filename, :size, :upload_time, :comment, :token, :original_name)"); $sth->bindValue(":filename", $file->getFileName()); $sth->bindValue(":size", $file->getSize()); $sth->bindValue(":upload_time", date("Y-m-d H:i:s", $file->getUploadTime())); $sth->bindValue(":comment", $file->getComment()); $sth->bindValue(":token", $file->getToken()); $sth->bindValue(":original_name", $file->getOriginalName()); $sth->execute(); $id = $this->dbh->lastInsertId(); return $id; }
public static function validateEditorialForm(\Filehosting\File $file, $token) { if ($file->getToken() != $token) { return "токены не совпадают"; } if (mb_strlen($file->getComment()) > 150) { return "Комментарий не должен превышать 150 символов"; } return false; }