From 36cda91529c6e9e0977f29ca703609a555f2764c Mon Sep 17 00:00:00 2001 From: Spine Date: Sun, 23 Feb 2025 05:09:28 +0000 Subject: [PATCH] declare strict types and Gazelle namespace --- app/ApplicantRole.php | 2 +- app/Artist.php | 8 +-- app/ArtistRole.php | 4 +- app/BaseManager.php | 2 +- app/BasePgObject.php | 2 +- app/Cache.php | 2 +- app/Collage.php | 14 ++-- app/Collector.php | 4 +- app/Contest.php | 4 +- app/Debug.php | 4 +- app/Download.php | 6 +- app/ForumPost.php | 2 +- app/ForumThread.php | 2 +- app/Invite.php | 2 +- app/Json.php | 2 +- app/Log.php | 2 +- app/Manager/User.php | 13 ++-- app/Pg.php | 10 +-- app/ReportAuto.php | 4 +- app/Request.php | 2 +- app/Staff.php | 2 +- app/TGroup.php | 29 ++++---- app/Tag.php | 8 +-- app/Task.php | 2 +- app/Top10/Torrent.php | 16 +++-- app/Torrent.php | 14 ++-- app/TorrentAbstract.php | 4 +- app/Upload.php | 12 ++-- app/User.php | 14 ++-- app/UserRank.php | 6 +- misc/phpstan-baseline.neon | 33 +++------- sections/ajax/add_log.php | 12 ++-- sections/ajax/announcements.php | 12 ++-- sections/ajax/artist.php | 16 +++-- sections/ajax/better/index.php | 4 ++ sections/ajax/better/single.php | 8 ++- sections/ajax/better/transcode.php | 8 ++- sections/ajax/bookmarks/artists.php | 8 ++- sections/ajax/bookmarks/index.php | 4 ++ sections/ajax/bookmarks/torrents.php | 14 ++-- sections/ajax/browse.php | 22 ++++--- sections/ajax/clear_user_notification.php | 4 ++ sections/ajax/collage.php | 12 ++-- sections/ajax/forum/forum.php | 12 ++-- sections/ajax/forum/index.php | 4 ++ sections/ajax/forum/main.php | 8 ++- sections/ajax/forum/thread.php | 14 ++-- sections/ajax/get_user_notifications.php | 6 +- sections/ajax/inbox/inbox.php | 8 ++- sections/ajax/inbox/index.php | 4 ++ sections/ajax/inbox/viewconv.php | 8 ++- sections/ajax/index.php | 8 ++- sections/ajax/info.php | 4 ++ sections/ajax/loadavg.php | 4 ++ sections/ajax/logchecker.php | 4 ++ sections/ajax/loggy.php | 6 +- sections/ajax/news_ajax.php | 6 +- sections/ajax/notifications.php | 12 ++-- sections/ajax/password_validate.php | 6 +- sections/ajax/post_edit.php | 8 ++- sections/ajax/preview.php | 12 ++-- sections/ajax/raw_bbcode.php | 6 +- sections/ajax/request.php | 14 ++-- sections/ajax/requests.php | 12 ++-- sections/ajax/riplog.php | 8 ++- sections/ajax/similar_artists.php | 8 ++- sections/ajax/stats.php | 12 ++-- sections/ajax/stats/torrents.php | 6 +- sections/ajax/stats/users.php | 9 +-- sections/ajax/subscriptions.php | 8 ++- sections/ajax/tcomments.php | 12 ++-- sections/ajax/top10/index.php | 4 ++ sections/ajax/top10/tags.php | 8 ++- sections/ajax/top10/torrents.php | 13 +++- sections/ajax/top10/users.php | 10 ++- sections/ajax/torrent.php | 10 ++- sections/ajax/torrent_remove_cover_art.php | 6 +- sections/ajax/torrent_tag_add.php | 6 +- sections/ajax/torrent_tag_remove.php | 8 ++- sections/ajax/torrentgroup.php | 10 ++- sections/ajax/torrentgroupalbumart.php | 6 +- sections/ajax/upload.php | 8 ++- sections/ajax/user.php | 8 ++- sections/ajax/user_recents.php | 8 ++- sections/ajax/userhistory/index.php | 4 ++ sections/ajax/userhistory/post_history.php | 14 ++-- sections/ajax/usersearch.php | 10 ++- sections/ajax/vote_handle.php | 8 ++- sections/ajax/wiki.php | 12 ++-- sections/api/index.php | 6 +- sections/apply/admin.php | 8 ++- sections/apply/apply.php | 10 ++- sections/apply/edit.php | 10 ++- sections/apply/index.php | 4 ++ sections/apply/view.php | 8 ++- sections/artist/add_alias.php | 8 ++- sections/artist/add_similar.php | 6 +- sections/artist/artist.php | 45 +++++++------ sections/artist/autocomplete.php | 6 +- sections/artist/change_artistid.php | 6 +- sections/artist/delete.php | 10 ++- sections/artist/delete_alias.php | 8 ++- sections/artist/delete_similar.php | 7 +- sections/artist/download.php | 10 ++- sections/artist/edit.php | 8 ++- sections/artist/edit_handle.php | 10 ++- sections/artist/edit_request.php | 8 ++- sections/artist/edit_request_handle.php | 12 ++-- sections/artist/history.php | 6 +- sections/artist/index.php | 6 +- sections/artist/notify.php | 6 +- sections/artist/notify_remove.php | 6 +- sections/artist/rename.php | 12 ++-- sections/artist/vote_similar.php | 6 +- sections/better/better.php | 28 ++++---- sections/better/index.php | 4 ++ sections/better/transcode.php | 8 ++- sections/blog/blog_page.php | 8 ++- sections/blog/dead_thread.php | 6 +- sections/blog/delete_blog.php | 6 +- sections/blog/edit_blog_handle.php | 12 ++-- sections/blog/index.php | 4 ++ sections/blog/new_blog_handle.php | 22 ++++--- sections/bonus/bprates.php | 10 ++- sections/bonus/history.php | 10 ++- sections/bonus/index.php | 4 ++ sections/bonus/invite.php | 6 +- sections/bonus/purchase.php | 6 +- sections/bonus/store.php | 10 ++- sections/bonus/title.php | 8 ++- sections/bonus/token_other.php | 8 ++- sections/bonus/tokens.php | 4 ++ sections/bookmarks/add.php | 10 ++- sections/bookmarks/artists.php | 8 ++- sections/bookmarks/edit_torrents.php | 10 ++- sections/bookmarks/index.php | 4 ++ sections/bookmarks/mass_edit.php | 6 +- sections/bookmarks/remove.php | 6 +- sections/bookmarks/remove_snatched.php | 6 +- sections/bookmarks/torrents.php | 28 ++++---- sections/chat/index.php | 4 ++ sections/chat/join.php | 4 ++ sections/chat/webirc.php | 4 ++ sections/chat/webirc_disabled.php | 4 ++ sections/collages/add_artist.php | 8 ++- sections/collages/add_torrent.php | 8 ++- sections/collages/ajax_add.php | 10 ++- sections/collages/all_comments.php | 16 +++-- sections/collages/autocomplete.php | 6 +- sections/collages/browse.php | 14 ++-- sections/collages/collage.php | 8 ++- sections/collages/collage_artists.php | 10 ++- sections/collages/collage_torrent.php | 20 +++--- sections/collages/delete.php | 6 +- sections/collages/delete_handle.php | 8 ++- sections/collages/download.php | 10 ++- sections/collages/edit.php | 10 ++- sections/collages/edit_handle.php | 8 ++- sections/collages/index.php | 4 ++ sections/collages/manage.php | 8 ++- sections/collages/manage_artists.php | 6 +- sections/collages/manage_artists_handle.php | 8 ++- sections/collages/manage_handle.php | 8 ++- sections/collages/new.php | 6 +- sections/collages/new_handle.php | 12 ++-- sections/collages/recover.php | 6 +- sections/comments/comments.php | 22 ++++--- sections/comments/delete_handle.php | 6 +- sections/comments/edit_handle.php | 10 ++- sections/comments/get.php | 6 +- sections/comments/index.php | 4 ++ sections/comments/jump.php | 6 +- sections/comments/post_handle.php | 6 +- sections/comments/warn.php | 6 +- sections/comments/warn_handle.php | 6 +- sections/contest/admin.php | 8 ++- sections/contest/index.php | 6 +- sections/contest/leaderboard.php | 12 ++-- sections/donate/index.php | 8 ++- sections/enable/index.php | 6 +- sections/error/403.php | 7 +- sections/error/404.php | 6 ++ sections/error/413.php | 6 +- sections/error/504.php | 6 +- sections/error/index.php | 4 ++ sections/forums/add_poll_option.php | 6 +- sections/forums/autosub.php | 6 +- sections/forums/catchup.php | 6 +- sections/forums/change_vote.php | 6 +- sections/forums/delete.php | 6 +- sections/forums/delete_poll_option.php | 6 +- sections/forums/do_warn.php | 4 ++ sections/forums/edit_handle.php | 10 ++- sections/forums/forum.php | 8 ++- sections/forums/get_post.php | 6 +- sections/forums/index.php | 4 ++ sections/forums/main.php | 6 +- sections/forums/new_thread.php | 8 ++- sections/forums/new_thread_handle.php | 16 +++-- sections/forums/poll_mod.php | 6 +- sections/forums/poll_vote.php | 8 ++- sections/forums/reply_handle.php | 16 +++-- sections/forums/search.php | 16 +++-- sections/forums/sticky_post.php | 6 +- sections/forums/thread.php | 36 +++++----- sections/forums/thread_handle.php | 10 ++- sections/forums/thread_notes_handle.php | 6 +- sections/forums/warn.php | 8 ++- sections/forums/warn_handle.php | 6 +- sections/friends/add.php | 8 ++- sections/friends/comment.php | 8 ++- sections/friends/friends.php | 10 ++- sections/friends/index.php | 4 ++ sections/friends/remove.php | 8 ++- sections/inbox/compose.php | 8 ++- sections/inbox/compose_handle.php | 11 +++- sections/inbox/conversation.php | 12 ++-- sections/inbox/edit_handle.php | 6 +- sections/inbox/forward.php | 8 ++- sections/inbox/get_post.php | 6 +- sections/inbox/inbox.php | 6 +- sections/inbox/index.php | 4 ++ sections/inbox/massdelete_handle.php | 4 ++ sections/index/index.php | 4 ++ sections/index/private.php | 34 +++++----- sections/index/public.php | 6 +- sections/locked/index.php | 4 ++ sections/log/index.php | 9 ++- sections/logchecker/index.php | 4 ++ sections/logchecker/test.php | 4 ++ sections/logchecker/test_handle.php | 4 ++ sections/logchecker/update.php | 8 ++- sections/logchecker/upload.php | 6 +- sections/logchecker/upload_handle.php | 14 ++-- sections/login/disabled.php | 8 ++- sections/login/index.php | 4 ++ sections/login/login.php | 18 +++-- sections/login/recover_step1.php | 10 ++- sections/login/recover_step2.php | 14 ++-- sections/logout/index.php | 4 ++ sections/random/index.php | 10 ++- sections/recovery/admin.php | 8 ++- sections/recovery/browse.php | 6 +- sections/recovery/index.php | 4 ++ sections/recovery/pair.php | 8 ++- sections/recovery/recover.php | 4 ++ sections/recovery/save.php | 4 ++ sections/recovery/view.php | 6 +- sections/referral/index.php | 14 ++-- sections/register/index.php | 34 +++++----- sections/report_auto/index.php | 4 ++ sections/report_auto/reports.php | 16 +++-- sections/report_auto/reports_handle.php | 4 ++ sections/reports/ajax_add_notes.php | 6 +- sections/reports/ajax_claim_report.php | 6 +- sections/reports/ajax_resolve_report.php | 6 +- sections/reports/ajax_unclaim_report.php | 6 +- sections/reports/array.php | 4 ++ sections/reports/compose.php | 32 +++++---- sections/reports/compose_handle.php | 6 +- sections/reports/index.php | 4 ++ sections/reports/report.php | 34 +++++----- sections/reports/report_handle.php | 10 ++- sections/reports/reports.php | 20 +++--- sections/reports/resolve_handle.php | 6 +- sections/reports/stats.php | 6 +- sections/reportsv2/ajax_claim.php | 6 +- .../reportsv2/ajax_get_resolve_options.php | 6 +- sections/reportsv2/ajax_new_report.php | 15 +++-- sections/reportsv2/ajax_report.php | 8 ++- sections/reportsv2/ajax_switch.php | 12 ++-- sections/reportsv2/ajax_take_pm.php | 10 ++- sections/reportsv2/ajax_unclaim.php | 6 +- sections/reportsv2/ajax_update_comment.php | 6 +- sections/reportsv2/ajax_update_resolve.php | 8 ++- sections/reportsv2/create.php | 12 ++-- sections/reportsv2/header.php | 4 ++ sections/reportsv2/index.php | 4 ++ sections/reportsv2/report_handle.php | 12 ++-- sections/reportsv2/reports.php | 4 ++ sections/reportsv2/resolve_handle.php | 14 ++-- sections/reportsv2/search.php | 12 ++-- sections/reportsv2/static.php | 38 ++++++----- sections/reportsv2/views.php | 10 ++- sections/requests/bounty_handle.php | 8 ++- sections/requests/delete_handle.php | 8 ++- sections/requests/edit.php | 22 ++++--- sections/requests/edit_bounty.php | 6 +- sections/requests/edit_handle.php | 24 ++++--- sections/requests/fill_handle.php | 10 ++- sections/requests/index.php | 4 ++ sections/requests/interim.php | 6 +- sections/requests/new.php | 24 ++++--- sections/requests/new_handle.php | 32 +++++---- sections/requests/request.php | 22 ++++--- sections/requests/requests.php | 16 +++-- sections/requests/unfill_handle.php | 8 ++- sections/requests/vote_handle.php | 6 +- sections/rules/index.php | 12 ++-- sections/staff/index.php | 6 +- sections/staffblog/index.php | 8 ++- sections/staffpm/ajax_delete_response.php | 6 +- sections/staffpm/ajax_edit_response.php | 6 +- sections/staffpm/ajax_get_response.php | 8 ++- sections/staffpm/assign.php | 10 ++- sections/staffpm/common_responses.php | 8 ++- sections/staffpm/get_post.php | 8 ++- sections/staffpm/index.php | 6 +- sections/staffpm/multiresolve.php | 6 +- sections/staffpm/scoreboard.php | 8 ++- sections/staffpm/staff_inbox.php | 10 ++- sections/staffpm/unresolve.php | 6 +- sections/staffpm/user_inbox.php | 10 ++- sections/staffpm/viewconv.php | 10 ++- sections/staffpm/viewconv_handle.php | 6 +- sections/stats/index.php | 4 ++ sections/stats/torrents.php | 6 +- sections/stats/users.php | 6 +- sections/tools/data/bonus_stats.php | 8 ++- sections/tools/data/economic_stats.php | 6 +- sections/tools/data/invite_pool.php | 8 ++- sections/tools/data/platform_usage.php | 6 +- sections/tools/data/ratio_watch.php | 8 ++- sections/tools/data/registration_log.php | 10 ++- sections/tools/data/site_info.php | 12 ++-- sections/tools/data/special_users.php | 6 +- sections/tools/data/torrent_stats.php | 12 ++-- sections/tools/data/user_flow.php | 8 ++- sections/tools/data/user_info.php | 10 +-- sections/tools/development/analysis.php | 6 +- sections/tools/development/analysis_list.php | 10 ++- sections/tools/development/clear_cache.php | 8 ++- sections/tools/development/db_sandbox.php | 8 ++- sections/tools/development/mysql.php | 18 +++-- sections/tools/development/notification.php | 10 ++- sections/tools/development/periodic_alter.php | 8 ++- .../tools/development/periodic_detail.php | 10 ++- sections/tools/development/periodic_edit.php | 6 +- sections/tools/development/periodic_run.php | 6 +- sections/tools/development/periodic_stats.php | 6 +- sections/tools/development/periodic_view.php | 6 +- sections/tools/development/pg.php | 12 ++-- sections/tools/development/process_info.php | 4 ++ .../tools/development/referral_sandbox.php | 12 ++-- sections/tools/development/service_stats.php | 6 +- sections/tools/development/site_options.php | 10 ++- sections/tools/finances/donation_log.php | 12 ++-- sections/tools/finances/donor_rewards.php | 8 ++- sections/tools/finances/payment_alter.php | 14 ++-- sections/tools/finances/payment_list.php | 8 ++- sections/tools/index.php | 4 ++ .../managers/ajax_take_enable_request.php | 12 ++-- sections/tools/managers/asn_search.php | 8 ++- sections/tools/managers/bans.php | 12 ++-- sections/tools/managers/bonus_points.php | 6 +- sections/tools/managers/categories_alter.php | 8 ++- sections/tools/managers/categories_list.php | 6 +- sections/tools/managers/change_log.php | 8 ++- sections/tools/managers/create_user.php | 8 ++- sections/tools/managers/custom_pm.php | 10 ++- sections/tools/managers/db_key.php | 4 ++ sections/tools/managers/dnu_alter.php | 10 ++- sections/tools/managers/dnu_list.php | 6 +- sections/tools/managers/dupe_ip.php | 8 ++- sections/tools/managers/email_blacklist.php | 8 ++- .../tools/managers/email_blacklist_alter.php | 8 ++- sections/tools/managers/email_search.php | 10 ++- sections/tools/managers/enable_requests.php | 16 +++-- sections/tools/managers/featured_album.php | 20 +++--- sections/tools/managers/forum_alter.php | 8 ++- sections/tools/managers/forum_list.php | 10 ++- .../managers/forum_transitions_alter.php | 10 ++- .../tools/managers/forum_transitions_list.php | 13 ++-- .../tools/managers/global_notification.php | 6 +- sections/tools/managers/invite_source.php | 10 ++- .../tools/managers/invite_source_config.php | 6 +- sections/tools/managers/ip_search.php | 10 ++- sections/tools/managers/login_watch.php | 12 ++-- sections/tools/managers/manipulate_tree.php | 14 ++-- sections/tools/managers/mass_pm.php | 8 ++- sections/tools/managers/navigation_alter.php | 8 ++- sections/tools/managers/navigation_list.php | 6 +- sections/tools/managers/news.php | 25 ++++--- sections/tools/managers/ocelot.php | 6 +- sections/tools/managers/ocelot_info.php | 12 ++-- sections/tools/managers/privilege_matrix.php | 8 ++- sections/tools/managers/quick_ban.php | 6 +- sections/tools/managers/rate_limit.php | 12 ++-- sections/tools/managers/reaper.php | 6 +- sections/tools/managers/referral_accounts.php | 17 +++-- sections/tools/managers/referral_alter.php | 8 ++- sections/tools/managers/referral_users.php | 8 ++- sections/tools/managers/ssl_host.php | 6 +- .../tools/managers/staff_groups_alter.php | 8 ++- sections/tools/managers/staff_groups_list.php | 6 +- sections/tools/managers/stylesheets_list.php | 8 ++- sections/tools/managers/tags.php | 8 ++- sections/tools/managers/tags_aliases.php | 6 +- sections/tools/managers/tags_official.php | 6 +- sections/tools/managers/take_mass_pm.php | 8 ++- sections/tools/managers/tokens.php | 6 +- sections/tools/managers/tor_node.php | 6 +- .../tools/managers/torrent_report_edit.php | 12 ++-- .../tools/managers/torrent_report_view.php | 6 +- sections/tools/managers/userclass_alter.php | 22 ++++--- sections/tools/managers/userclass_edit.php | 8 ++- sections/tools/managers/userclass_list.php | 6 +- sections/tools/managers/whitelist_alter.php | 8 ++- sections/tools/managers/whitelist_list.php | 6 +- sections/tools/services/get_cc.php | 4 ++ sections/tools/services/get_host.php | 4 ++ sections/tools/tools.php | 6 +- sections/top10/donors.php | 6 +- sections/top10/history.php | 10 ++- sections/top10/index.php | 4 ++ sections/top10/lastfm.php | 6 +- sections/top10/tags.php | 6 +- sections/top10/torrents.php | 31 +++++---- sections/top10/users.php | 6 +- sections/top10/votes.php | 24 ++++--- sections/torrents/add_alias.php | 8 ++- sections/torrents/add_cover_art.php | 8 ++- sections/torrents/autocomplete_tags.php | 4 ++ sections/torrents/browse.php | 35 ++++++---- sections/torrents/collector.php | 12 ++-- sections/torrents/delete.php | 12 ++-- sections/torrents/delete_alias.php | 8 ++- sections/torrents/delete_handle.php | 8 ++- sections/torrents/details.php | 42 ++++++------ sections/torrents/downloadlist.php | 10 ++- sections/torrents/edit.php | 16 +++-- sections/torrents/edit_category_handle.php | 12 ++-- sections/torrents/edit_group.php | 12 ++-- sections/torrents/edit_group_handle.php | 10 ++- sections/torrents/edit_handle.php | 23 ++++--- sections/torrents/edit_log.php | 10 ++- sections/torrents/edit_log_handle.php | 6 +- sections/torrents/edit_request.php | 8 ++- sections/torrents/edit_request_handle.php | 12 ++-- sections/torrents/filelist.php | 6 +- sections/torrents/grouplog.php | 8 ++- sections/torrents/history.php | 6 +- sections/torrents/index.php | 8 ++- sections/torrents/log_ajax.php | 8 ++- sections/torrents/manage_artists.php | 6 +- sections/torrents/masspm.php | 8 ++- sections/torrents/masspm_handle.php | 10 ++- sections/torrents/merge.php | 10 ++- sections/torrents/new_group_handle.php | 16 +++-- sections/torrents/new_groupid.php | 8 ++- sections/torrents/nonwikiedit.php | 10 ++- sections/torrents/notify.php | 22 ++++--- sections/torrents/notify_actions.php | 6 +- sections/torrents/peerlist.php | 10 ++- sections/torrents/redownload.php | 16 +++-- sections/torrents/regen.php | 10 ++- sections/torrents/remove_log.php | 14 +++- sections/torrents/remove_logs.php | 10 ++- sections/torrents/rename.php | 4 ++ sections/torrents/rescore_log.php | 12 ++-- sections/torrents/reseed.php | 6 +- sections/torrents/snatchlist.php | 10 ++- sections/torrents/user.php | 26 ++++---- sections/torrents/vote_tag.php | 8 ++- sections/upload/index.php | 4 ++ sections/upload/parse_html.php | 2 + sections/upload/upload.php | 22 ++++--- sections/upload/upload_handle.php | 50 +++++++------- sections/user/2fa/complete.php | 8 ++- sections/user/2fa/configure.php | 6 +- sections/user/2fa/confirm.php | 4 ++ sections/user/2fa/index.php | 6 +- sections/user/2fa/remove.php | 6 +- sections/user/advancedsearch.php | 14 ++-- sections/user/audit.php | 4 +- sections/user/delete_invite.php | 6 +- sections/user/edit.php | 26 ++++---- sections/user/edit_handle.php | 40 ++++++----- sections/user/index.php | 6 +- sections/user/invite.php | 16 +++-- sections/user/invite_handle.php | 10 ++- sections/user/invitetree.php | 8 ++- sections/user/lastfm.php | 6 +- sections/user/load-invitetree.php | 8 ++- sections/user/moderate_handle.php | 42 +++++++----- sections/user/notify_edit.php | 8 ++- sections/user/notify_handle.php | 10 ++- sections/user/permissions.php | 6 +- sections/user/push_handle.php | 8 ++- sections/user/seedbox_edit.php | 8 ++- sections/user/seedbox_view.php | 16 +++-- sections/user/sessions.php | 8 ++- sections/user/token.php | 6 +- sections/user/user.php | 66 ++++++++++--------- sections/user/user_stats.php | 6 +- sections/user/userlink_handle.php | 10 ++- sections/user/vote_history.php | 10 ++- sections/userhistory/announce_key_history.php | 6 +- sections/userhistory/catchup_collages.php | 12 ++-- sections/userhistory/collage_subscribe.php | 6 +- sections/userhistory/comments_subscribe.php | 6 +- sections/userhistory/email_history.php | 10 ++- sections/userhistory/index.php | 6 +- sections/userhistory/ip_history.php | 10 ++- sections/userhistory/ip_tracker_history.php | 10 ++- sections/userhistory/password_history.php | 6 +- sections/userhistory/post_history.php | 10 ++- sections/userhistory/quote_notifications.php | 8 ++- sections/userhistory/subscribed_collages.php | 20 +++--- sections/userhistory/subscriptions.php | 28 ++++---- sections/userhistory/thread_subscribe.php | 8 ++- sections/userhistory/token_history.php | 10 ++- sections/userhistory/topic_history.php | 10 ++- sections/view/index.php | 4 ++ sections/wiki/add_alias.php | 8 ++- sections/wiki/article.php | 10 ++- sections/wiki/compare.php | 14 +++- sections/wiki/create.php | 8 ++- sections/wiki/create_handle.php | 8 ++- sections/wiki/delete.php | 6 +- sections/wiki/delete_alias.php | 6 +- sections/wiki/delete_handle.php | 6 +- sections/wiki/edit.php | 10 ++- sections/wiki/edit_handle.php | 8 ++- sections/wiki/index.php | 6 +- sections/wiki/revisions.php | 6 +- sections/wiki/search.php | 12 ++-- sections/wiki/wiki_browse.php | 6 +- templates/register/create.twig | 2 +- 529 files changed, 3509 insertions(+), 1516 deletions(-) diff --git a/app/ApplicantRole.php b/app/ApplicantRole.php index e4a915482..dd3f72b05 100644 --- a/app/ApplicantRole.php +++ b/app/ApplicantRole.php @@ -99,7 +99,7 @@ class ApplicantRole extends BaseObject { ); (new Manager\Applicant())->flush(); (new Manager\ApplicantRole())->flush(); - return new \Gazelle\Applicant(self::$db->inserted_id()); + return new Applicant(self::$db->inserted_id()); } public function modify(): bool { diff --git a/app/Artist.php b/app/Artist.php index e542a9db9..9b73f0d27 100644 --- a/app/Artist.php +++ b/app/Artist.php @@ -317,7 +317,7 @@ class Artist extends BaseObject implements CollageEntry { * Revert to a prior revision of the artist metadata * (Which also creates a new revision). */ - public function revertRevision(int $revisionId, \Gazelle\User $user): int { + public function revertRevision(int $revisionId, User $user): int { self::$db->prepared_query(" INSERT INTO wiki_artists (Body, Image, PageID, UserID, Summary) @@ -726,7 +726,7 @@ class Artist extends BaseObject implements CollageEntry { // Cache clearing self::$cache->delete_multi([array_map(fn ($id) => "notify_artists_$id", $bookmarkList)]); - self::$cache->delete_multi([array_map(fn ($id) => sprintf(\Gazelle\Collage::CACHE_KEY, $id), $collageList)]); + self::$cache->delete_multi([array_map(fn ($id) => sprintf(Collage::CACHE_KEY, $id), $collageList)]); foreach ($artistCollageList as $collageId) { $collMan->findById($collageId)?->flush(); } @@ -892,7 +892,7 @@ class Artist extends BaseObject implements CollageEntry { $id = $this->id; $name = $this->name(); $this->flush(); - $db = new \Gazelle\DB(); + $db = new DB(); self::$db->begin_transaction(); $db->relaxConstraints(true); @@ -903,7 +903,7 @@ class Artist extends BaseObject implements CollageEntry { self::$db->prepared_query("DELETE FROM wiki_artists WHERE PageID = ?", $id); $db->relaxConstraints(false); - (new \Gazelle\Manager\Comment())->remove('artist', $id); + (new Manager\Comment())->remove('artist', $id); $this->logger()->general( "Artist $id ($name) was deleted by {$user->username()}" ); diff --git a/app/ArtistRole.php b/app/ArtistRole.php index a2c7ab47e..caeb03b22 100644 --- a/app/ArtistRole.php +++ b/app/ArtistRole.php @@ -4,7 +4,7 @@ namespace Gazelle; use Gazelle\Intf\CategoryHasArtist; -abstract class ArtistRole extends \Gazelle\Base { +abstract class ArtistRole extends Base { protected const RENDER_TEXT = 1; protected const RENDER_HTML = 2; @@ -20,7 +20,7 @@ abstract class ArtistRole extends \Gazelle\Base { public function __construct( protected readonly CategoryHasArtist $object, - protected readonly \Gazelle\Manager\Artist $manager, + protected readonly Manager\Artist $manager, ) {} protected function artistList(): array { diff --git a/app/BaseManager.php b/app/BaseManager.php index bddd59c0c..f8f03bdcf 100644 --- a/app/BaseManager.php +++ b/app/BaseManager.php @@ -9,5 +9,5 @@ abstract class BaseManager extends Base { * Gazelle objects. Handy if you want to pass arbitrary * managers around. */ - abstract public function findById(int $id): ?\Gazelle\Base; + abstract public function findById(int $id): ?Base; } diff --git a/app/BasePgObject.php b/app/BasePgObject.php index 6d5a754ce..50a59b3ad 100644 --- a/app/BasePgObject.php +++ b/app/BasePgObject.php @@ -3,7 +3,7 @@ namespace Gazelle; abstract class BasePgObject extends BaseObject { - use \Gazelle\Pg; + use Pg; public function modify(): bool { if (!$this->dirty()) { diff --git a/app/Cache.php b/app/Cache.php index 8fae70f28..27c203c1f 100644 --- a/app/Cache.php +++ b/app/Cache.php @@ -12,7 +12,7 @@ order to better handle the caching of full pages with bits of dynamic content that are different for every user. Also, Memcache::get and Memcache::set have been wrapped by -Gazelle\Cache::get_value and Gazelle\Cache::cache_value. get_value uses +Cache::get_value and Cache::cache_value. get_value uses the same argument as get, but cache_value only takes the key, the value, and the duration (no zlib). diff --git a/app/Collage.php b/app/Collage.php index ea9cf9688..0b2241be4 100644 --- a/app/Collage.php +++ b/app/Collage.php @@ -380,13 +380,13 @@ class Collage extends BaseObject { } public function setFreeleech( - \Gazelle\Manager\Torrent $torMan, - \Gazelle\Tracker $tracker, - \Gazelle\User $user, - LeechType $leechType, - LeechReason $reason, - int $threshold = 0, - bool $all = false, + Manager\Torrent $torMan, + Tracker $tracker, + User $user, + LeechType $leechType, + LeechReason $reason, + int $threshold = 0, + bool $all = false, ): int { $regular = []; $large = []; diff --git a/app/Collector.php b/app/Collector.php index f0edd41bc..a971d9378 100644 --- a/app/Collector.php +++ b/app/Collector.php @@ -61,8 +61,8 @@ abstract class Collector extends Base { abstract public function fillZip(\ZipStream\ZipStream $zip): int; public function __construct( - protected \Gazelle\User $user, - protected \Gazelle\Manager\Torrent $torMan, + protected User $user, + protected Manager\Torrent $torMan, protected readonly string $title, protected int $orderBy, ) { diff --git a/app/Contest.php b/app/Contest.php index 0c0cef73c..e45891fa6 100644 --- a/app/Contest.php +++ b/app/Contest.php @@ -51,7 +51,7 @@ class Contest extends BaseObject { } // upload-flac-no-single => UploadFlacNoSingle - $className = '\\Gazelle\\Contest\\' . implode('', array_map('ucfirst', explode('-', $info['contest_type']))); + $className = 'Contest\\' . implode('', array_map('ucfirst', explode('-', $info['contest_type']))); $info['type'] = new $className($this->id, $info['date_begin'], $info['date_end']); if ($info['bonus_pool_id']) { @@ -104,7 +104,7 @@ class Contest extends BaseObject { return $this->info()['name']; } - public function rank(\Gazelle\User $user): ?array { + public function rank(User $user): ?array { $page = 0; $userId = $user->id(); while (true) { diff --git a/app/Debug.php b/app/Debug.php index d9657b03e..6e7c51664 100644 --- a/app/Debug.php +++ b/app/Debug.php @@ -88,7 +88,7 @@ class Debug { } $errorList = (string)json_encode(self::$Errors); - $id = (new \Gazelle\Manager\ErrorLog())->create( + $id = (new Manager\ErrorLog())->create( uri: $uri, userId: $userId, duration: $this->duration(), @@ -113,7 +113,7 @@ class Debug { 'flags' => $this->markList(), 'includes' => $this->includeList(), 'perf' => $this->perfInfo(), - 'ocelot' => (new \Gazelle\Tracker())->requestList(), + 'ocelot' => (new Tracker())->requestList(), 'searches' => class_exists('Sphinxql') ? \Sphinxql::$Queries : [], 'searches_time' => class_exists('Sphinxql') ? \Sphinxql::$Time : 0.0, 'queries' => $this->db->queryList(), diff --git a/app/Download.php b/app/Download.php index 3382688a0..ce39976aa 100644 --- a/app/Download.php +++ b/app/Download.php @@ -18,8 +18,8 @@ class Download extends Base { protected DownloadStatus $status; public function __construct( - protected \Gazelle\Torrent $torrent, - protected \Gazelle\User\UserclassRateLimit $limiter, + protected Torrent $torrent, + protected User\UserclassRateLimit $limiter, protected bool $useToken, ) {} @@ -101,7 +101,7 @@ class Download extends Base { self::$db->rollback(); return DownloadStatus::no_tokens; } - if (!(new \Gazelle\Tracker())->addToken($this->torrent, $user)) { + if (!(new Tracker())->addToken($this->torrent, $user)) { self::$db->rollback(); return DownloadStatus::tracker; } diff --git a/app/ForumPost.php b/app/ForumPost.php index b2aaaa296..391de511c 100644 --- a/app/ForumPost.php +++ b/app/ForumPost.php @@ -210,7 +210,7 @@ class ForumPost extends BaseObject { self::$db->commit(); $this->thread()->forum()->adjust(); - (new \Gazelle\Manager\Subscription())->flushPage('forums', $threadId); + (new Manager\Subscription())->flushPage('forums', $threadId); $thread->flushPostCatalogue($this); $thread->flush(); diff --git a/app/ForumThread.php b/app/ForumThread.php index ec6224671..465021975 100644 --- a/app/ForumThread.php +++ b/app/ForumThread.php @@ -310,7 +310,7 @@ class ForumThread extends BaseObject { // LastPostID is a chicken and egg situation when removing a thread, // so foreign key constraints must be suspended temporarily. - $db = new \Gazelle\DB(); + $db = new DB(); $db->relaxConstraints(true); self::$db->prepared_query(" DELETE ft, fp, unq diff --git a/app/Invite.php b/app/Invite.php index 6068e7e3f..ac18c21f3 100644 --- a/app/Invite.php +++ b/app/Invite.php @@ -2,7 +2,7 @@ namespace Gazelle; -class Invite extends \Gazelle\Base { +class Invite extends Base { protected array $info; public function __construct( diff --git a/app/Json.php b/app/Json.php index 2638f537f..8c2016ec9 100644 --- a/app/Json.php +++ b/app/Json.php @@ -82,7 +82,7 @@ abstract class Json extends Base { } $info = [ 'debug' => [ - 'queries' => \Gazelle\DB::DB()->queryList(), + 'queries' => DB::DB()->queryList(), ], ]; if (class_exists('Sphinxql')) { diff --git a/app/Log.php b/app/Log.php index 79cd012d9..081a224dd 100644 --- a/app/Log.php +++ b/app/Log.php @@ -48,7 +48,7 @@ class Log extends Base { return $this; } - public function merge(\Gazelle\TGroup $old, \Gazelle\TGroup $new): int { + public function merge(TGroup $old, TGroup $new): int { self::$db->prepared_query(" UPDATE group_log SET GroupID = ? diff --git a/app/Manager/User.php b/app/Manager/User.php index 3cc56d459..40f992ab4 100644 --- a/app/Manager/User.php +++ b/app/Manager/User.php @@ -261,16 +261,19 @@ class User extends \Gazelle\BaseManager { * @return array $classes */ public function classList(): array { - if (($classList = self::$cache->get_value('user_class')) === false) { - $qid = self::$db->get_query_id(); + $classList = self::$cache->get_value('user_class'); + if ($classList === false) { self::$db->prepared_query(" SELECT ID, Name, Level, Secondary, badge FROM permissions ORDER BY Level "); - $classList = self::$db->to_array('ID'); - self::$db->set_query_id($qid); - self::$cache->cache_value('user_class', $classList, 7200); + $classList = []; + foreach (self::$db->to_array(false, MYSQLI_ASSOC, false) as $row) { + $row['Level'] = (int)$row['Level']; + $classList[$row['ID']] = $row; + } + self::$cache->cache_value('user_class', $classList, 86400); } return $classList; } diff --git a/app/Pg.php b/app/Pg.php index 26c73434b..48dbfb7a5 100644 --- a/app/Pg.php +++ b/app/Pg.php @@ -6,16 +6,16 @@ trait Pg { protected static \Gazelle\DB\Pg $pgro; // R/O access protected static \Gazelle\DB\Pg $pg; // R/W access - public function pgro(): \Gazelle\DB\Pg { - return self::$pgro ??= new \Gazelle\DB\Pg(PG_RO_DSN); + public function pgro(): DB\Pg { + return self::$pgro ??= new DB\Pg(PG_RO_DSN); } - public function pg(): \Gazelle\DB\Pg { + public function pg(): DB\Pg { return self::pgStatic(); } // disgusting hack required for \View class - public static function pgStatic(): \Gazelle\DB\Pg { - return self::$pg ??= new \Gazelle\DB\Pg(PG_RW_DSN); + public static function pgStatic(): DB\Pg { + return self::$pg ??= new DB\Pg(PG_RW_DSN); } } diff --git a/app/ReportAuto.php b/app/ReportAuto.php index da13b363e..9ed4e8465 100644 --- a/app/ReportAuto.php +++ b/app/ReportAuto.php @@ -9,7 +9,7 @@ class ReportAuto extends BasePgObject { public function __construct( protected int $id, - protected $typeMan = new \Gazelle\Manager\ReportAutoType(), + protected $typeMan = new Manager\ReportAutoType(), ) { parent::__construct($id); } @@ -143,7 +143,7 @@ class ReportAuto extends BasePgObject { /** * returns comment id on success, null otherwise */ - public function addComment(\Gazelle\User $user, string $comment): ?int { + public function addComment(User $user, string $comment): ?int { $commentId = $this->pg()->scalar(" INSERT INTO report_auto_comment (id_report_auto, id_user, comment) diff --git a/app/Request.php b/app/Request.php index 6ae096724..659e78900 100644 --- a/app/Request.php +++ b/app/Request.php @@ -915,7 +915,7 @@ class Request extends BaseObject implements CategoryHasArtist { REPLACE INTO sphinx_requests_delta (ID) VALUES (?) ", $this->id ); - (new \Gazelle\Manager\Comment())->remove('requests', $this->id); + (new Manager\Comment())->remove('requests', $this->id); self::$db->commit(); foreach ($artisIds as $artistId) { diff --git a/app/Staff.php b/app/Staff.php index 796837c19..fefbc5856 100644 --- a/app/Staff.php +++ b/app/Staff.php @@ -61,7 +61,7 @@ class Staff extends BaseUser { WHERE " . implode(' AND ', $cond), ...$args); } - public function userStaffPmList(\Gazelle\User $user): array { + public function userStaffPmList(User $user): array { self::$db->prepared_query(" SELECT spc.ID AS pm_id, spc.Subject AS subject, diff --git a/app/TGroup.php b/app/TGroup.php index 8a7a0f0d2..286e045db 100644 --- a/app/TGroup.php +++ b/app/TGroup.php @@ -403,7 +403,7 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { public function releaseTypeName(): ?string { static $releaseTypes; if (is_null($releaseTypes)) { - $releaseTypes = (new \Gazelle\ReleaseType())->list(); + $releaseTypes = (new ReleaseType())->list(); } return $this->info()['ReleaseType'] == 0 ? null : $releaseTypes[$this->releaseType()]; } @@ -440,7 +440,7 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { /** * Delegate stats methods to the Stats\TGroup class */ - public function stats(): \Gazelle\Stats\TGroup { + public function stats(): Stats\TGroup { if (!isset($this->stats)) { $this->stats = new Stats\TGroup($this->id); } @@ -620,7 +620,7 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { $n = count($names); for ($i = 0; $i < $n; $i++) { $role = $roles[$i]; - $name = \Gazelle\Artist::sanitize($names[$i]); + $name = Artist::sanitize($names[$i]); if (!$name || !in_array($role, array_keys(ARTIST_TYPE))) { continue; } @@ -807,9 +807,9 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { } public function setFreeleech( - \Gazelle\Manager\Torrent $torMan, - \Gazelle\Tracker $tracker, - \Gazelle\User $user, + Manager\Torrent $torMan, + Tracker $tracker, + User $user, LeechType $leechType, LeechReason $reason, int $threshold = 0, @@ -853,11 +853,10 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { $old->flush(); $old->refresh(); } else { - (new \Gazelle\Manager\Bookmark())->merge($old, $this); - (new \Gazelle\Manager\Comment())->merge('torrents', $oldId, $this->id); - (new \Gazelle\Manager\Vote())->merge($old, $this, new Manager\User()); + (new Manager\Bookmark())->merge($old, $this); + (new Manager\Comment())->merge('torrents', $oldId, $this->id); + (new Manager\Vote())->merge($old, $this, new Manager\User()); $this->logger()->merge($old, $this); - $old->remove($user); } $this->logger() @@ -927,12 +926,12 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { ", $this->id ); foreach ($CollageIDs as $CollageID) { - self::$cache->delete_value(sprintf(\Gazelle\Collage::CACHE_KEY, $CollageID)); + self::$cache->delete_value(sprintf(Collage::CACHE_KEY, $CollageID)); } self::$cache->delete_value("torrent_collages_" . $this->id); } - (new \Gazelle\Manager\Comment())->remove('torrents', $this->id); + (new Manager\Comment())->remove('torrents', $this->id); // Requests self::$db->prepared_query(" @@ -967,7 +966,7 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { ", $this->id ); - $manager = new \Gazelle\DB(); + $manager = new DB(); [$ok, $message] = $manager->softDelete(MYSQL_DB, 'torrents_group', [['ID', $this->id]]); if (!$ok) { return false; @@ -983,8 +982,8 @@ class TGroup extends BaseObject implements CategoryHasArtist, CollageEntry { "torrent_group_{$this->id}", sprintf(self::CACHE_KEY, $this->id), sprintf(self::CACHE_TLIST_KEY, $this->id), - sprintf(\Gazelle\Manager\TGroup::ID_KEY, $this->id), - sprintf(\Gazelle\Manager\Torrent::CACHE_KEY_LATEST_UPLOADS, 5), + sprintf(Manager\TGroup::ID_KEY, $this->id), + sprintf(Manager\Torrent::CACHE_KEY_LATEST_UPLOADS, 5), ]); return true; } diff --git a/app/Tag.php b/app/Tag.php index dc5026428..6b0d5ddea 100644 --- a/app/Tag.php +++ b/app/Tag.php @@ -107,7 +107,7 @@ class Tag extends BaseObject { return self::$db->to_array(false, MYSQLI_ASSOC, false); } - public function addTGroup(\Gazelle\TGroup $tgroup, \Gazelle\User $user, int $weight): int { + public function addTGroup(TGroup $tgroup, User $user, int $weight): int { self::$db->begin_transaction(); self::$db->prepared_query(" INSERT INTO torrents_tags @@ -154,7 +154,7 @@ class Tag extends BaseObject { return self::$db->to_array(false, MYSQLI_ASSOC, false); } - public function voteTGroup(\Gazelle\TGroup $tgroup, \Gazelle\User $user, string $way): int { + public function voteTGroup(TGroup $tgroup, User $user, string $way): int { self::$db->begin_transaction(); self::$db->prepared_query(" SELECT TagID @@ -196,7 +196,7 @@ class Tag extends BaseObject { return $affected; } - public function hasVoteTGroup(\Gazelle\TGroup $tgroup, \Gazelle\User $user): bool { + public function hasVoteTGroup(TGroup $tgroup, User $user): bool { return (bool)self::$db->scalar(" SELECT 1 FROM torrents_tags_votes @@ -207,7 +207,7 @@ class Tag extends BaseObject { ); } - public function removeTGroup(\Gazelle\TGroup $tgroup): bool { + public function removeTGroup(TGroup $tgroup): bool { $tgroupId = $tgroup->id(); self::$db->begin_transaction(); self::$db->prepared_query(" diff --git a/app/Task.php b/app/Task.php index 1eb7375bf..c98dc6c91 100644 --- a/app/Task.php +++ b/app/Task.php @@ -80,7 +80,7 @@ abstract class Task extends Base { if (!$this->isDebug && $severity === 'debug') { return; } - $this->events[] = new TaskScheduler\Event($severity, $message, $reference, \Gazelle\Util\Time::sqlTime()); + $this->events[] = new TaskScheduler\Event($severity, $message, $reference, Util\Time::sqlTime()); } public function debug(string $message, int $reference = 0): void { diff --git a/app/Top10/Torrent.php b/app/Top10/Torrent.php index 579de4a0b..fd73803bc 100644 --- a/app/Top10/Torrent.php +++ b/app/Top10/Torrent.php @@ -5,9 +5,9 @@ namespace Gazelle\Top10; class Torrent extends \Gazelle\Base { private string $baseQuery = " SELECT - t.ID, - g.ID, - ((t.Size * tls.Snatched) + (t.Size * 0.5 * tls.Leechers)) AS Data + t.ID AS torrent_id, + g.ID AS tgroup_id, + ((t.Size * tls.Snatched) + (t.Size * 0.5 * tls.Leechers)) AS score FROM torrents AS t INNER JOIN torrents_leech_stats tls ON (tls.TorrentID = t.ID) INNER JOIN torrents_group AS g ON (g.ID = t.GroupID) @@ -22,7 +22,7 @@ class Torrent extends \Gazelle\Base { ) {} public function getTopTorrents($getParameters, $details = 'all', $limit = 10): array { - $cacheKey = "top10_{$details}_{$limit}_" + $cacheKey = "T10_{$details}_{$limit}_" . trim(signature(implode('', $getParameters), TOP10_SALT), '='); $topTorrents = self::$cache->get_value($cacheKey); @@ -81,7 +81,11 @@ class Torrent extends \Gazelle\Base { ); self::$db->prepared_query($query, ...$parameters); - $topTorrents = self::$db->to_array(); + $topTorrents = []; + foreach (self::$db->to_array(false, MYSQLI_ASSOC, false) as $row) { + $row['score'] = (float)$row['score']; // wtf + $topTorrents[] = $row; + } self::$cache->cache_value($cacheKey, $topTorrents, 3600 * 6); self::$cache->delete_value("{$cacheKey}_lock"); @@ -99,7 +103,7 @@ class Torrent extends \Gazelle\Base { return match ($details) { 'snatched' => 'tls.Snatched', 'seeded' => 'tls.Seeders', - 'data' => 'Data', + 'data' => 'score', default => '(tls.Seeders + tls.Leechers)', }; } diff --git a/app/Torrent.php b/app/Torrent.php index d24f71d0a..0e599e00f 100644 --- a/app/Torrent.php +++ b/app/Torrent.php @@ -94,7 +94,7 @@ class Torrent extends TorrentAbstract { * Convert a stored torrent into a binary file that can be loaded in a torrent client */ public function torrentBody(string $announceUrl): string { - $filer = new \Gazelle\File\Torrent(); + $filer = new File\Torrent(); $contents = $filer->get($this->id); if ($contents == false) { return ''; @@ -184,7 +184,7 @@ class Torrent extends TorrentAbstract { return $affected; } - public function rescoreLog(int $logId, \Gazelle\Logfile $logfile, string $version): int { + public function rescoreLog(int $logId, Logfile $logfile, string $version): int { self::$db->prepared_query(" UPDATE torrents_logs SET Score = ?, `Checksum` = ?, ChecksumState = ?, Ripper = ?, RipperVersion = ?, @@ -311,7 +311,7 @@ class Torrent extends TorrentAbstract { self::$db->begin_transaction(); $this->info(); if ($this->id > MAX_PREV_TORRENT_ID && $removePoints) { - (new \Gazelle\User\Bonus($this->uploader()))->removePointsForUpload($this); + (new User\Bonus($this->uploader()))->removePointsForUpload($this); } $edition = $this->edition(); @@ -322,13 +322,13 @@ class Torrent extends TorrentAbstract { $media = $this->media(); $format = $this->format(); $encoding = $this->encoding(); - (new \Gazelle\Tracker())->update('delete_torrent', [ + (new Tracker())->update('delete_torrent', [ 'id' => $this->id, 'info_hash' => $this->infohashEncoded(), 'reason' => $trackerReason, ]); - $manager = new \Gazelle\DB(); + $manager = new DB(); $manager->relaxConstraints(true); [$ok, $message] = $manager->softDelete(MYSQL_DB, 'torrents_leech_stats', [['TorrentID', $this->id]], false); if (!$ok) { @@ -439,7 +439,7 @@ class Torrent extends TorrentAbstract { ); $affected = self::$db->affected_rows(); self::$cache->delete_value("users_tokens_{$user->id()}"); - (new \Gazelle\Tracker())->removeToken($this, $user); + (new Tracker())->removeToken($this, $user); return $affected; } @@ -573,7 +573,7 @@ class Torrent extends TorrentAbstract { * * @return int number of files regenned */ - public function regenerateFilelist(\Gazelle\File\Torrent $filer, \OrpheusNET\BencodeTorrent\BencodeTorrent $encoder): int { + public function regenerateFilelist(File\Torrent $filer, \OrpheusNET\BencodeTorrent\BencodeTorrent $encoder): int { $torrentFile = $filer->get($this->id); if ($torrentFile === false) { return 0; diff --git a/app/TorrentAbstract.php b/app/TorrentAbstract.php index 6a5a0b696..6cf732e86 100644 --- a/app/TorrentAbstract.php +++ b/app/TorrentAbstract.php @@ -494,7 +494,7 @@ abstract class TorrentAbstract extends BaseObject { return $this->info()['LogScore']; } - public function logfileList(\Gazelle\File\RipLog $ripFiler, \Gazelle\File\RipLogHTML $htmlFiler): array { + public function logfileList(File\RipLog $ripFiler, File\RipLogHTML $htmlFiler): array { self::$db->prepared_query(" SELECT LogID AS id, Score, @@ -567,7 +567,7 @@ abstract class TorrentAbstract extends BaseObject { /** * Get the reports associated with this torrent * - * @return array of ids of \Gazelle\Torrent\Report + * @return array of ids of Torrent\Report */ public function reportIdList(User $viewer): array { if ($this->isDeleted()) { diff --git a/app/Upload.php b/app/Upload.php index 704058f2b..9e761c439 100644 --- a/app/Upload.php +++ b/app/Upload.php @@ -4,14 +4,14 @@ namespace Gazelle; use Gazelle\Util\Textarea; -class Upload extends \Gazelle\Base { +class Upload extends Base { final public const TORRENT_INPUT_ACCEPT = ['application/x-bittorrent', '.torrent']; final public const JSON_INPUT_ACCEPT = ['application/json', '.json']; protected bool $isUploaded; public function __construct( - protected \Gazelle\User $user, + protected User $user, protected array|false $Torrent = false, protected string|false $Error = false, ) { @@ -66,7 +66,7 @@ class Upload extends \Gazelle\Base { } public function foot(bool $showFooter): string { - $torMan = new \Gazelle\Manager\Torrent(); + $torMan = new Manager\Torrent(); return self::$twig->render('upload/footer.twig', [ 'is_upload' => !$this->isUploaded || isset($this->Torrent['add-format']), 'info' => $this->Torrent, @@ -129,18 +129,18 @@ class Upload extends \Gazelle\Base { ]); } - public function music(array $GenreTags, \Gazelle\Manager\TGroup $manager): string { + public function music(array $GenreTags, Manager\TGroup $manager): string { return self::$twig->render('upload/music.twig', [ 'add_format' => $this->isUploaded && is_array($this->Torrent) && isset($this->Torrent['add-format']), 'description_album' => $this->albumDescription(), 'description_release' => $this->releaseDescription(), 'is_uploaded' => $this->isUploaded, 'logchecker_accept' => \OrpheusNET\Logchecker\Logchecker::getAcceptValues(), - 'release_type' => (new \Gazelle\ReleaseType())->list(), + 'release_type' => (new ReleaseType())->list(), 'tag_list' => $GenreTags, 'tgroup' => $this->isUploaded && is_array($this->Torrent) ? $manager->findById($this->Torrent['GroupID']) : null, 'torrent' => $this->Torrent, - 'torrent_flags' => \Gazelle\Enum\TorrentFlag::cases(), + 'torrent_flags' => Enum\TorrentFlag::cases(), 'user' => $this->user, ]); } diff --git a/app/User.php b/app/User.php index 6b88499e1..06c040db1 100644 --- a/app/User.php +++ b/app/User.php @@ -90,7 +90,7 @@ class User extends BaseObject { return $this->snatch ??= new User\Snatch($this); } - public function stats(): \Gazelle\Stats\User { + public function stats(): Stats\User { return $this->stats ??= new Stats\User($this->id); } @@ -918,9 +918,9 @@ class User extends BaseObject { /** * Warn a user. Returns expiry date. */ - public function warn(int $duration, string $reason, \Gazelle\User $staff, string $userMessage): string { + public function warn(int $duration, string $reason, User $staff, string $userMessage): string { $warnTime = Time::offset($duration * 7 * 86_400); - $warning = new \Gazelle\User\Warning($this); + $warning = new User\Warning($this); $expiry = $warning->warningExpiry(); if ($expiry) { $subject = 'You have received a new warning'; @@ -943,7 +943,7 @@ class User extends BaseObject { public function warnPost( BaseObject $post, int $weekDuration, - \Gazelle\User $staffer, + User $staffer, string $staffReason, string $userMessage ): void { @@ -1310,7 +1310,7 @@ class User extends BaseObject { return stripos($info['Artists'], "|$name|") !== false; } - public function addArtistNotification(\Gazelle\Artist $artist): int { + public function addArtistNotification(Artist $artist): int { $info = $this->loadArtistNotifications(); $alias = implode('|', $artist->aliasNameList()); if (!$alias) { @@ -1353,7 +1353,7 @@ class User extends BaseObject { return !$this->hasAttr('no-pm-delete-download'); } - public function removeArtistNotification(\Gazelle\Artist $artist): int { + public function removeArtistNotification(Artist $artist): int { $info = $this->loadArtistNotifications(); $aliasList = $artist->aliasNameList(); foreach ($aliasList as $alias) { @@ -1939,7 +1939,7 @@ class User extends BaseObject { ", $this->id, $name, $token ); return $token; - } catch (\Gazelle\DB\MysqlDuplicateKeyException) { + } catch (DB\MysqlDuplicateKeyException) { ; } } diff --git a/app/UserRank.php b/app/UserRank.php index a0a683042..31c14b4ef 100644 --- a/app/UserRank.php +++ b/app/UserRank.php @@ -11,7 +11,7 @@ namespace Gazelle; * * It begins with a RANKING_WEIGHT table in the configuration, which * specifies the weight a dimension has towards the overall score, and - * a class name X that points to \Gazelle\UserRank\X. + * a class name X that points to UserRank\X. * * To explore and test in Boris: * Consider that there are two users, one who has up/down votes a @@ -41,7 +41,7 @@ namespace Gazelle; * This then has to hooked up to sections/user/user.php and * sections/ajax/user.php * - * Future directions: pass a \Gazelle\User object to the UserRank + * Future directions: pass a User object to the UserRank * object, and define the appropriate ethod names in the ranking * table so that the dimension classes can obtain the metrics * directly and not need to have them passed in. @@ -53,7 +53,7 @@ class UserRank extends Base { final public const PREFIX = 'percentiles_'; // Prefix for memcache keys, to make life easier - public function __construct(protected \Gazelle\UserRank\Configuration $config, protected array $dimension) { + public function __construct(protected UserRank\Configuration $config, protected array $dimension) { $definition = $this->config->definition(); foreach ($definition as $d) { $this->rank[$d] = $this->config->instance($d)->rank( diff --git a/misc/phpstan-baseline.neon b/misc/phpstan-baseline.neon index 988105521..c965221b8 100644 --- a/misc/phpstan-baseline.neon +++ b/misc/phpstan-baseline.neon @@ -221,12 +221,7 @@ parameters: path: ../classes/sphinxqlresult.class.php - - message: "#^Function payload\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#" - count: 1 - path: ../sections/ajax/top10/torrents.php - - - - message: "#^Function payload\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Function \\w+\\\\payload\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#" count: 1 path: ../sections/ajax/top10/torrents.php @@ -241,37 +236,37 @@ parameters: path: ../sections/better/better.php - - message: "#^Function notify invoked with 2 parameters, 3 required\\.$#" + message: "#^Function Gazelle\\\\notify invoked with 2 parameters, 3 required\\.$#" count: 1 path: ../sections/error/404.php - - message: "#^Function notify invoked with 2 parameters, 3 required\\.$#" + message: "#^Function Gazelle\\\\notify invoked with 2 parameters, 3 required\\.$#" count: 1 path: ../sections/error/413.php - - message: "#^Function notify invoked with 2 parameters, 3 required\\.$#" + message: "#^Function Gazelle\\\\notify invoked with 2 parameters, 3 required\\.$#" count: 1 path: ../sections/error/504.php - - message: "#^Function notify\\(\\) has no return type specified\\.$#" + message: "#^Function Gazelle\\\\notify\\(\\) has no return type specified\\.$#" count: 1 path: ../sections/error/index.php - - message: "#^Function notify\\(\\) has parameter \\$Channel with no type specified\\.$#" + message: "#^Function Gazelle\\\\notify\\(\\) has parameter \\$Channel with no type specified\\.$#" count: 1 path: ../sections/error/index.php - - message: "#^Function notify\\(\\) has parameter \\$Message with no type specified\\.$#" + message: "#^Function Gazelle\\\\notify\\(\\) has parameter \\$Message with no type specified\\.$#" count: 1 path: ../sections/error/index.php - - message: "#^Function notify\\(\\) has parameter \\$Viewer with no type specified\\.$#" + message: "#^Function Gazelle\\\\notify\\(\\) has parameter \\$Viewer with no type specified\\.$#" count: 1 path: ../sections/error/index.php @@ -291,7 +286,7 @@ parameters: path: ../sections/recovery/save.php - - message: "#^Function print_or_return\\(\\) has no return type specified\\.$#" + message: "#^Function Gazelle\\\\print_or_return\\(\\) has no return type specified\\.$#" count: 1 path: ../sections/requests/fill_handle.php @@ -300,11 +295,6 @@ parameters: count: 1 path: ../sections/tools/managers/ajax_take_enable_request.php - - - message: "#^Function type_list\\(\\) has parameter \\$Types with no value type specified in iterable type array\\.$#" - count: 1 - path: ../sections/tools/managers/referral_accounts.php - - message: "#^Parameter \\#1 \\(array\\\\|string\\) of echo cannot be converted to string\\.$#" count: 1 @@ -319,8 +309,3 @@ parameters: message: "#^Variable \\$url might not be defined\\.$#" count: 2 path: ../sections/tools/development/referral_sandbox.php - - - - message: "#^Function diff\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: ../sections/wiki/compare.php diff --git a/sections/ajax/add_log.php b/sections/ajax/add_log.php index e609895c7..e79eed12e 100644 --- a/sections/ajax/add_log.php +++ b/sections/ajax/add_log.php @@ -1,7 +1,11 @@ findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$torrent = (new Manager\Torrent())->findById((int)($_GET['id'] ?? 0)); if (is_null($torrent)) { json_error('bad parameters'); } @@ -12,11 +16,11 @@ if (empty($_FILES) || empty($_FILES['logfiles'])) { json_error('no log files uploaded'); } -echo (new Gazelle\Json\AddLog( +echo (new Json\AddLog( $torrent, $Viewer, - new Gazelle\Manager\TorrentLog(new Gazelle\File\RipLog(), new Gazelle\File\RipLogHTML()), - new Gazelle\LogfileSummary($_FILES['logfiles']), + new Manager\TorrentLog(new File\RipLog(), new File\RipLogHTML()), + new LogfileSummary($_FILES['logfiles']), )) ->setVersion(1) ->response(); diff --git a/sections/ajax/announcements.php b/sections/ajax/announcements.php index 6b66734b1..c31ea5580 100644 --- a/sections/ajax/announcements.php +++ b/sections/ajax/announcements.php @@ -1,7 +1,11 @@ latestId() < $newsReader->lastRead($Viewer)) { $newsReader->witness($Viewer); @@ -18,12 +22,12 @@ foreach ($headlines as $item) { 'newsId' => $item['id'], 'title' => $item['title'], 'bbBody' => $item['body'], - 'body' => Text::full_format($item['body']), + 'body' => \Text::full_format($item['body']), 'newsTime' => $item['created'], ]; } -$headlines = (new Gazelle\Manager\Blog())->headlines(); +$headlines = (new Manager\Blog())->headlines(); $blog = []; foreach ($headlines as $item) { $blog[] = [ @@ -31,7 +35,7 @@ foreach ($headlines as $item) { 'author' => $item->userId(), 'title' => $item->title(), 'bbBody' => $item->body(), - 'body' => Text::full_format($item->body()), + 'body' => \Text::full_format($item->body()), 'blogTime' => $item->created(), 'threadId' => $item->threadId(), ]; diff --git a/sections/ajax/artist.php b/sections/ajax/artist.php index 282cf8748..a4d119b9c 100644 --- a/sections/ajax/artist.php +++ b/sections/ajax/artist.php @@ -1,7 +1,11 @@ setReleasesOnly(!empty($_GET['artistreleases'])) ->setVersion(2) diff --git a/sections/ajax/better/index.php b/sections/ajax/better/index.php index 79626d470..dba0028e9 100644 --- a/sections/ajax/better/index.php +++ b/sections/ajax/better/index.php @@ -1,5 +1,9 @@ include_once 'transcode.php', 'single' => include_once 'single.php', diff --git a/sections/ajax/better/single.php b/sections/ajax/better/single.php index 4aedd7920..29f46dd73 100644 --- a/sections/ajax/better/single.php +++ b/sections/ajax/better/single.php @@ -1,9 +1,13 @@ setVersion(2) ->response(); diff --git a/sections/ajax/better/transcode.php b/sections/ajax/better/transcode.php index a0d6a1a4f..195bfd85c 100644 --- a/sections/ajax/better/transcode.php +++ b/sections/ajax/better/transcode.php @@ -1,15 +1,19 @@ setViewer($Viewer)); +$search = new Search\Transcode($Viewer, (new Manager\Torrent())->setViewer($Viewer)); if (isset($_GET['search'])) { $search->setSearch($_GET['search']); } -echo (new Gazelle\Json\Better\Transcode($Viewer->announceKey(), $search)) +echo (new Json\Better\Transcode($Viewer->announceKey(), $search)) ->setVersion(2) ->response(); diff --git a/sections/ajax/bookmarks/artists.php b/sections/ajax/bookmarks/artists.php index 8ad3e6b0b..82a73bf59 100644 --- a/sections/ajax/bookmarks/artists.php +++ b/sections/ajax/bookmarks/artists.php @@ -1,17 +1,21 @@ permitted('users_override_paranoia')) { json_die('failure'); } - $user = (new Gazelle\Manager\User())->findById((int)$_GET['userid']); + $user = (new Manager\User())->findById((int)$_GET['userid']); if (is_null($user)) { json_die('failure'); } } -echo (new Gazelle\Json\Bookmark\Artist(new Gazelle\User\Bookmark($user))) +echo (new Json\Bookmark\Artist(new User\Bookmark($user))) ->response(); diff --git a/sections/ajax/bookmarks/index.php b/sections/ajax/bookmarks/index.php index 5f209587b..f56a63b13 100644 --- a/sections/ajax/bookmarks/index.php +++ b/sections/ajax/bookmarks/index.php @@ -1,5 +1,9 @@ permitted('users_override_paranoia')) { json_error('bad parameters'); } - $user = (new Gazelle\Manager\User())->findById((int)($_GET['userid'] ?? 0)); + $user = (new Manager\User())->findById((int)($_GET['userid'] ?? 0)); if (is_null($user)) { json_error('bad parameters'); } } -echo (new Gazelle\Json\Bookmark\TGroup( - new Gazelle\User\Bookmark($user), - new Gazelle\Manager\TGroup(), - new Gazelle\Manager\Torrent()) +echo (new Json\Bookmark\TGroup( + new User\Bookmark($user), + new Manager\TGroup(), + new Manager\Torrent()) ) ->setVersion(2) ->response(); diff --git a/sections/ajax/browse.php b/sections/ajax/browse.php index 4147a6380..bacc2014e 100644 --- a/sections/ajax/browse.php +++ b/sections/ajax/browse.php @@ -1,7 +1,11 @@ snatch(), - new Gazelle\Manager\Artist(), - (new Gazelle\Manager\TGroup())->setViewer($Viewer), - (new Gazelle\Manager\Torrent())->setViewer($Viewer), + new Manager\Artist(), + (new Manager\TGroup())->setViewer($Viewer), + (new Manager\Torrent())->setViewer($Viewer), $Results, $GroupResults, $resultTotal, diff --git a/sections/ajax/clear_user_notification.php b/sections/ajax/clear_user_notification.php index 68446d8a8..50761b04c 100644 --- a/sections/ajax/clear_user_notification.php +++ b/sections/ajax/clear_user_notification.php @@ -1,6 +1,10 @@ findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$collage = (new Manager\Collage())->findById((int)($_GET['id'] ?? 0)); if (is_null($collage)) { json_die('bad parameters'); } -echo (new Gazelle\Json\Collage( +echo (new Json\Collage( $collage, (int)($_GET['page'] ?? 1), $Viewer, - new Gazelle\Manager\TGroup(), - new Gazelle\Manager\Torrent() + new Manager\TGroup(), + new Manager\Torrent() )) ->response(); diff --git a/sections/ajax/forum/forum.php b/sections/ajax/forum/forum.php index 144e3ffc4..968481a2e 100644 --- a/sections/ajax/forum/forum.php +++ b/sections/ajax/forum/forum.php @@ -1,7 +1,11 @@ findById((int)($_GET['forumid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$forum = (new Manager\Forum())->findById((int)($_GET['forumid'] ?? 0)); if (is_null($forum)) { print json_die(['status' => $_GET]); } @@ -9,11 +13,11 @@ if (!$Viewer->readAccess($forum)) { json_die("failure", "insufficient permission"); } -echo (new Gazelle\Json\Forum( +echo (new Json\Forum( $forum, $Viewer, - new Gazelle\Manager\ForumThread(), - new Gazelle\Manager\User(), + new Manager\ForumThread(), + new Manager\User(), isset($_GET['pp']) ? (int)$_GET['pp'] : $Viewer->postsPerPage(), (int)($_GET['page'] ?? 1), )) diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php index ea6e39ce1..756b170b2 100644 --- a/sections/ajax/forum/index.php +++ b/sections/ajax/forum/index.php @@ -1,6 +1,10 @@ disableForums()) { print json_die('failure'); } diff --git a/sections/ajax/forum/main.php b/sections/ajax/forum/main.php index 10f8b49c8..866101f15 100644 --- a/sections/ajax/forum/main.php +++ b/sections/ajax/forum/main.php @@ -1,11 +1,15 @@ id() => $Viewer]; $category = []; -foreach ((new Gazelle\Manager\Forum())->forumList() as $forum) { +foreach ((new Manager\Forum())->forumList() as $forum) { if (!$Viewer->readAccess($forum)) { continue; } diff --git a/sections/ajax/forum/thread.php b/sections/ajax/forum/thread.php index 6f00a88b6..6c0e93aa9 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -1,15 +1,19 @@ findById((int)$_GET['postid']); + $post = (new Manager\ForumPost())->findById((int)$_GET['postid']); if (is_null($post)) { json_error('bad post id'); } $thread = $post->thread(); } elseif (isset($_GET['threadid']) || isset($_GET['topicid'])) { $post = false; - $thread = (new Gazelle\Manager\ForumThread()) + $thread = (new Manager\ForumThread()) ->findById((int)($_GET['threadid'] ?? $_GET['topicid'] ?? 0)); if (is_null($thread)) { json_error('bad thread id'); @@ -31,15 +35,15 @@ $postNum = match (true) { default => 1, }; $perPage = (int)($_GET['pp'] ?? $Viewer->postsPerPage()); -$paginator = new Gazelle\Util\Paginator( +$paginator = new Util\Paginator( $perPage, (int)($_GET['page'] ?? ceil($postNum / $perPage)), ); -echo (new Gazelle\Json\ForumThread( +echo (new Json\ForumThread( $thread, $Viewer, $paginator, isset($_GET['updatelastread']), - new Gazelle\Manager\User(), + new Manager\User(), ))->response(); diff --git a/sections/ajax/get_user_notifications.php b/sections/ajax/get_user_notifications.php index aaad4324c..e9e0fd8a8 100644 --- a/sections/ajax/get_user_notifications.php +++ b/sections/ajax/get_user_notifications.php @@ -1,7 +1,11 @@ alertList(); +declare(strict_types=1); + +namespace Gazelle; + +$alertList = (new User\Notification($Viewer))->alertList(); $payload = []; foreach ($alertList as $alert) { diff --git a/sections/ajax/inbox/inbox.php b/sections/ajax/inbox/inbox.php index bcf058976..3b0468796 100644 --- a/sections/ajax/inbox/inbox.php +++ b/sections/ajax/inbox/inbox.php @@ -1,12 +1,16 @@ 'viewconv.php', default => 'inbox.php', diff --git a/sections/ajax/inbox/viewconv.php b/sections/ajax/inbox/viewconv.php index 802307083..3553e2d0f 100644 --- a/sections/ajax/inbox/viewconv.php +++ b/sections/ajax/inbox/viewconv.php @@ -1,10 +1,14 @@ findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$pm = (new Manager\PM($Viewer))->findById((int)($_GET['id'] ?? 0)); if (is_null($pm)) { json_die('failure'); } $pm->markRead(); -echo (new Gazelle\Json\PM($pm, new Gazelle\Manager\User()))->response(); +echo (new Json\PM($pm, new Manager\User()))->response(); diff --git a/sections/ajax/index.php b/sections/ajax/index.php index 6c523def0..45e25a63a 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -3,6 +3,10 @@ /** @phpstan-var ?\Gazelle\User $Viewer */ /** @phpstan-var \Gazelle\Cache $Cache */ +declare(strict_types=1); + +namespace Gazelle; + define('AJAX', !isset($_POST['auth'])); /* 'x' requests every 'y' seconds: [5,10] = 5 requests every 10 seconds */ @@ -81,7 +85,7 @@ if (!$Viewer->permitted('site_unlimit_ajax') && isset($LimitedPages[$Action])) { } else { $Cache->increment_value('ajax_requests_' . $UserID); if ($UserRequests > $rate) { - Gazelle\Util\Irc::sendMessage(IRC_CHAN_STATUS, "ajax rate limit hit by {$Viewer->username()} on $Action"); + Util\Irc::sendMessage(IRC_CHAN_STATUS, "ajax rate limit hit by {$Viewer->username()} on $Action"); json_error("Rate limit exceeded"); } } @@ -196,7 +200,7 @@ switch ($Action) { include_once 'wiki.php'; break; case 'get_friends': - echo json_encode((new Gazelle\User\Friend($Viewer))->userList()); + echo json_encode((new User\Friend($Viewer))->userList()); break; case 'news_ajax': include_once 'news_ajax.php'; diff --git a/sections/ajax/info.php b/sections/ajax/info.php index 071a76d8a..884335d23 100644 --- a/sections/ajax/info.php +++ b/sections/ajax/info.php @@ -1,6 +1,10 @@ permitted('site_archive_ajax')) { json_die('failure', 'insufficient permissions to view page'); } @@ -16,7 +20,7 @@ if ($_GET['type'] === 'active') { } $where = implode(' AND ', $where); -$db = Gazelle\DB::DB(); +$db = DB::DB(); $db->prepared_query("SELECT t.ID FROM torrents t INNER JOIN torrents_leech_stats tls ON (tls.TorrentID = t.ID) WHERE {$where}"); json_print('success', ['IDs' => $db->collect('ID', false)]); diff --git a/sections/ajax/news_ajax.php b/sections/ajax/news_ajax.php index dabe22ccf..7e1ec8635 100644 --- a/sections/ajax/news_ajax.php +++ b/sections/ajax/news_ajax.php @@ -1,5 +1,9 @@ 10) { json_die('failure'); } -echo (new Gazelle\Json\News($limit, $offset))->setVersion(2)->response(); +echo (new Json\News($limit, $offset))->setVersion(2)->response(); diff --git a/sections/ajax/notifications.php b/sections/ajax/notifications.php index fd33ad4c9..251a62ed4 100644 --- a/sections/ajax/notifications.php +++ b/sections/ajax/notifications.php @@ -1,14 +1,18 @@ permitted('site_torrents_notify')) { json_die("failure"); } -echo (new Gazelle\Json\Notification\Torrent( - new Gazelle\User\Notification\Torrent($Viewer), - new Gazelle\Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)), - new Gazelle\Manager\Torrent(), +echo (new Json\Notification\Torrent( + new User\Notification\Torrent($Viewer), + new Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)), + new Manager\Torrent(), )) ->setVersion(2) ->response(); diff --git a/sections/ajax/password_validate.php b/sections/ajax/password_validate.php index aba9fe7c7..296e4376f 100644 --- a/sections/ajax/password_validate.php +++ b/sections/ajax/password_validate.php @@ -1,7 +1,11 @@ permitted('site_admin_forums')) { error(403); } @@ -19,7 +23,7 @@ if ($_GET['depth'] != $depth) { die("bad depth"); } -$commentMan = new Gazelle\Manager\Comment(); +$commentMan = new Manager\Comment(); $history = $commentMan->loadEdits($pageType, $postId); [$userId, $editTime] = $history[$depth]; @@ -27,7 +31,7 @@ if ($depth != 0) { $body = $history[$depth - 1][2]; } else { $body = match ($pageType) { - 'forums' => (new Gazelle\Manager\ForumPost())->findById($postId)->body(), + 'forums' => (new Manager\ForumPost())->findById($postId)->body(), default => $commentMan->findById($postId)->body(), }; } diff --git a/sections/ajax/preview.php b/sections/ajax/preview.php index 2d82af738..ef8992b4e 100644 --- a/sections/ajax/preview.php +++ b/sections/ajax/preview.php @@ -1,11 +1,15 @@ findById((int)($_GET['postid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$post = (new Manager\ForumPost())->findById((int)($_GET['postid'] ?? 0)); if (is_null($post)) { json_die("failure", "empty postid"); } elseif (!$Viewer->readAccess($post->thread()->forum())) { diff --git a/sections/ajax/request.php b/sections/ajax/request.php index b2229912f..0e3f5a7dc 100644 --- a/sections/ajax/request.php +++ b/sections/ajax/request.php @@ -1,17 +1,21 @@ findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$request = (new Manager\Request())->findById((int)($_GET['id'] ?? 0)); if (is_null($request)) { json_die("failure"); } -echo (new Gazelle\Json\Request( +echo (new Json\Request( $request, $Viewer, - new Gazelle\User\Bookmark($Viewer), - new Gazelle\Comment\Request($request->id(), (int)($_GET['page'] ?? 1), (int)($_GET['post'] ?? 0)), - new Gazelle\Manager\User(), + new User\Bookmark($Viewer), + new Comment\Request($request->id(), (int)($_GET['page'] ?? 1), (int)($_GET['post'] ?? 0)), + new Manager\User(), )) ->setVersion(2) ->response(); diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php index 9f3277232..b45e412e9 100644 --- a/sections/ajax/requests.php +++ b/sections/ajax/requests.php @@ -1,9 +1,13 @@ limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE); } else { @@ -121,6 +125,6 @@ $search->execute( ); $paginator->setTotal($search->total()); -echo (new Gazelle\Json\Requests($search, $paginator->page(), $userMan)) +echo (new Json\Requests($search, $paginator->page(), $userMan)) ->setVersion(2) ->response(); diff --git a/sections/ajax/riplog.php b/sections/ajax/riplog.php index effd00507..ce815ac04 100644 --- a/sections/ajax/riplog.php +++ b/sections/ajax/riplog.php @@ -1,14 +1,18 @@ findById((int)($_GET['id'] ?? 0)); +$torrent = (new Manager\Torrent())->findById((int)($_GET['id'] ?? 0)); if (is_null($torrent)) { json_error('torrent not found'); } -echo (new Gazelle\Json\RipLog($torrent->id(), $logId)) +echo (new Json\RipLog($torrent->id(), $logId)) ->setVersion(2) ->response(); diff --git a/sections/ajax/similar_artists.php b/sections/ajax/similar_artists.php index 7a4a3ec1e..2905bfef8 100644 --- a/sections/ajax/similar_artists.php +++ b/sections/ajax/similar_artists.php @@ -1,9 +1,13 @@ findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$artist = (new Manager\Artist())->findById((int)($_GET['id'] ?? 0)); if (is_null($artist)) { print json_die('missing artist id'); } $limit = max(50, (int)($_GET['limit'] ?? 10)); -echo (new Gazelle\Json\ArtistSimilar($artist, $limit))->response(); +echo (new Json\ArtistSimilar($artist, $limit))->response(); diff --git a/sections/ajax/stats.php b/sections/ajax/stats.php index 04823f4be..c89f45645 100644 --- a/sections/ajax/stats.php +++ b/sections/ajax/stats.php @@ -1,9 +1,13 @@ setVersion(2) ->response(); diff --git a/sections/ajax/stats/torrents.php b/sections/ajax/stats/torrents.php index 34cb954ae..a12576b1f 100644 --- a/sections/ajax/stats/torrents.php +++ b/sections/ajax/stats/torrents.php @@ -1,5 +1,9 @@ setVersion(2) ->response(); diff --git a/sections/ajax/stats/users.php b/sections/ajax/stats/users.php index 5653452cc..bf41a2c0c 100644 --- a/sections/ajax/stats/users.php +++ b/sections/ajax/stats/users.php @@ -1,9 +1,10 @@ setVersion(2) ->response(); diff --git a/sections/ajax/subscriptions.php b/sections/ajax/subscriptions.php index d0a575058..5661cfcea 100644 --- a/sections/ajax/subscriptions.php +++ b/sections/ajax/subscriptions.php @@ -1,14 +1,18 @@ disableForums()) { json_die('failure'); } $showUnread = (bool)($_GET['showunread'] ?? true); -$forMan = new Gazelle\Manager\Forum(); -$paginator = new Gazelle\Util\Paginator($Viewer->postsPerPage(), (int)($_GET['page'] ?? 1)); +$forMan = new Manager\Forum(); +$paginator = new Util\Paginator($Viewer->postsPerPage(), (int)($_GET['page'] ?? 1)); $paginator->setTotal( $showUnread ? $forMan->unreadSubscribedForumTotal($Viewer) : $forMan->subscribedForumTotal($Viewer) ); diff --git a/sections/ajax/tcomments.php b/sections/ajax/tcomments.php index 798a30789..e135de460 100644 --- a/sections/ajax/tcomments.php +++ b/sections/ajax/tcomments.php @@ -1,15 +1,19 @@ load()->thread(); $userCache = []; -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); $JsonComments = []; foreach ($thread as $Post) { @@ -22,14 +26,14 @@ foreach ($thread as $Post) { 'postId' => $PostID, 'addedTime' => $AddedTime, 'bbBody' => $Body, - 'body' => Text::full_format($Body), + 'body' => \Text::full_format($Body), 'editedUserId' => $EditedUserID, 'editedTime' => $EditedTime, 'editedUsername' => $EditedUsername, 'userinfo' => [ 'authorId' => $AuthorID, 'authorName' => $author->username(), - 'donor' => (new Gazelle\User\Donor($author))->isDonor(), + 'donor' => (new User\Donor($author))->isDonor(), 'warned' => $author->isWarned(), 'avatar' => $author->avatar(), 'enabled' => $author->isEnabled(), diff --git a/sections/ajax/top10/index.php b/sections/ajax/top10/index.php index 608f64b78..47ef66615 100644 --- a/sections/ajax/top10/index.php +++ b/sections/ajax/top10/index.php @@ -1,6 +1,10 @@ permitted('site_top10')) { json_die('failure'); } diff --git a/sections/ajax/top10/tags.php b/sections/ajax/top10/tags.php index 0bdb9690f..fca988b78 100644 --- a/sections/ajax/top10/tags.php +++ b/sections/ajax/top10/tags.php @@ -1,5 +1,9 @@ 'bad details parameter']); @@ -10,10 +14,10 @@ if (!in_array($limit, [10, 100, 250])) { json_die(['status' => 'bad limit parameter']); } -echo (new Gazelle\Json\Top10\Tag( +echo (new Json\Top10\Tag( details: $details, limit: $limit, - manager: new Gazelle\Manager\Tag(), + manager: new Manager\Tag(), )) ->setVersion(2) ->response(); diff --git a/sections/ajax/top10/torrents.php b/sections/ajax/top10/torrents.php index 89bdf32c4..3921d7b10 100644 --- a/sections/ajax/top10/torrents.php +++ b/sections/ajax/top10/torrents.php @@ -2,13 +2,17 @@ // phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols /** @phpstan-var \Gazelle\User $Viewer */ +declare(strict_types=1); + +namespace Gazelle; + $details = isset($_GET['details']) && in_array($_GET['details'], ['day', 'week', 'overall', 'snatched', 'data', 'seeded', 'month', 'year']) ? $_GET['details'] : 'all'; $limit = (int)($_GET['limit'] ?? 10); $limit = in_array($limit, [10, 100, 250]) && $details !== 'all' ? $limit : 10; -$top10 = new Gazelle\Top10\Torrent(FORMAT, $Viewer); -$torMan = new Gazelle\Manager\Torrent(); +$top10 = new Top10\Torrent(FORMAT, $Viewer); +$torMan = new Manager\Torrent(); $result = []; // Filter out common parameters that are not needed in getTopTorrents to get more cache hits @@ -91,7 +95,10 @@ print json_encode([ 'response' => $result ]); -function payload(Gazelle\Manager\Torrent $torMan, array $details): array { +/** + * @return array> + */ +function payload(Manager\Torrent $torMan, array $details): array { $results = []; foreach ($details as $detail) { $torrent = $torMan->findById($detail[0]); diff --git a/sections/ajax/top10/users.php b/sections/ajax/top10/users.php index 8eaa66729..62f8fe41a 100644 --- a/sections/ajax/top10/users.php +++ b/sections/ajax/top10/users.php @@ -1,5 +1,9 @@ setVersion(2) ->response(); diff --git a/sections/ajax/torrent.php b/sections/ajax/torrent.php index 0eae9fea4..d900d7d8b 100644 --- a/sections/ajax/torrent.php +++ b/sections/ajax/torrent.php @@ -1,17 +1,21 @@ findByInfohash($_GET['hash'] ?? ''); + $torrent = (new Manager\Torrent())->findByInfohash($_GET['hash'] ?? ''); } else { - $torrent = (new Gazelle\Manager\Torrent())->findById((int)$_GET['id']); + $torrent = (new Manager\Torrent())->findById((int)$_GET['id']); } if (is_null($torrent)) { json_error('bad parameters'); } -echo (new Gazelle\Json\Torrent($torrent, $Viewer, new Gazelle\Manager\Torrent())) +echo (new Json\Torrent($torrent, $Viewer, new Manager\Torrent())) ->setVersion(5) ->response(); diff --git a/sections/ajax/torrent_remove_cover_art.php b/sections/ajax/torrent_remove_cover_art.php index af83ffcff..e74415cf0 100644 --- a/sections/ajax/torrent_remove_cover_art.php +++ b/sections/ajax/torrent_remove_cover_art.php @@ -1,11 +1,15 @@ permitted('site_edit_wiki')) { json_die('failure', 'forbidden'); } -$tgroup = (new Gazelle\Manager\TGroup())->findById((int)$_GET['groupid']); +$tgroup = (new Manager\TGroup())->findById((int)$_GET['groupid']); $coverId = (int)$_GET['id']; if (!$coverId || is_null($tgroup)) { json_die('failure', 'bad parameters'); diff --git a/sections/ajax/torrent_tag_add.php b/sections/ajax/torrent_tag_add.php index 221293012..e0ac19d8c 100644 --- a/sections/ajax/torrent_tag_add.php +++ b/sections/ajax/torrent_tag_add.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Gazelle\Cache $Cache */ +declare(strict_types=1); + +namespace Gazelle; + if ($Viewer->disableTagging()) { json_or_error('tagging disabled for your account', 403); } @@ -10,7 +14,7 @@ if (!defined('AJAX') || !AJAX) { authorize(); } -$tgMan = new Gazelle\Manager\TGroup(); +$tgMan = new Manager\TGroup(); $tgroup = $tgMan->findById((int)($_REQUEST['groupid'] ?? 0)); if (is_null($tgroup)) { json_or_error('invalid groupid', 0); diff --git a/sections/ajax/torrent_tag_remove.php b/sections/ajax/torrent_tag_remove.php index 8cfe00ad1..d6b4d077f 100644 --- a/sections/ajax/torrent_tag_remove.php +++ b/sections/ajax/torrent_tag_remove.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Gazelle\Cache $Cache */ +declare(strict_types=1); + +namespace Gazelle; + authorize(); if ($Viewer->disableTagging() || !$Viewer->permitted('site_delete_tag')) { error(403); } -$tagMan = new Gazelle\Manager\Tag(); -$tgMan = new Gazelle\Manager\TGroup(); +$tagMan = new Manager\Tag(); +$tgMan = new Manager\TGroup(); $tag = $tagMan->findById((int)$_GET['tagid']); $tgroup = $tgMan->findById((int)$_GET['groupid']); diff --git a/sections/ajax/torrentgroup.php b/sections/ajax/torrentgroup.php index 905539554..286f10ece 100644 --- a/sections/ajax/torrentgroup.php +++ b/sections/ajax/torrentgroup.php @@ -1,13 +1,17 @@ findByTorrentInfohash($infohash) : $tgMan->findById($groupId); @@ -16,9 +20,9 @@ if (is_null($tgroup)) { json_error('bad parameters'); } -echo (new Gazelle\Json\TGroup( +echo (new Json\TGroup( $tgroup, $Viewer, - (new \Gazelle\Manager\Torrent())->setViewer($Viewer)) + (new Manager\Torrent())->setViewer($Viewer)) )->setVersion(2) ->response(); diff --git a/sections/ajax/torrentgroupalbumart.php b/sections/ajax/torrentgroupalbumart.php index 8e2594e2e..a8fca1597 100644 --- a/sections/ajax/torrentgroupalbumart.php +++ b/sections/ajax/torrentgroupalbumart.php @@ -1,6 +1,10 @@ findById((int)$_GET['id']); +declare(strict_types=1); + +namespace Gazelle; + +$tgroup = (new Manager\TGroup())->findById((int)$_GET['id']); if (is_null($tgroup)) { json_die('failure', 'bad id parameter'); } diff --git a/sections/ajax/upload.php b/sections/ajax/upload.php index fb966d46b..fb1b62937 100644 --- a/sections/ajax/upload.php +++ b/sections/ajax/upload.php @@ -1,9 +1,13 @@ albumReleaseJS() - : $uploadForm->music((new Gazelle\Manager\Tag())->genreList(), new Gazelle\Manager\TGroup()); + : $uploadForm->music((new Manager\Tag())->genreList(), new Manager\TGroup()); break; default: diff --git a/sections/ajax/user.php b/sections/ajax/user.php index 9e73f24de..c61bfcc13 100644 --- a/sections/ajax/user.php +++ b/sections/ajax/user.php @@ -1,11 +1,15 @@ findById((int)$_GET['id']); +declare(strict_types=1); + +namespace Gazelle; + +$user = (new Manager\User())->findById((int)$_GET['id']); if (is_null($user)) { json_die("failure", "bad id parameter"); } -echo (new Gazelle\Json\User($user, $Viewer)) +echo (new Json\User($user, $Viewer)) ->setVersion(2) ->response(); diff --git a/sections/ajax/user_recents.php b/sections/ajax/user_recents.php index 4c19aa6b4..5b49a9c15 100644 --- a/sections/ajax/user_recents.php +++ b/sections/ajax/user_recents.php @@ -1,7 +1,11 @@ findById((int)($_GET['userid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$user = (new Manager\User())->findById((int)($_GET['userid'] ?? 0)); if (is_null($user)) { json_error("bad userid"); } @@ -10,7 +14,7 @@ if ($limit < 1 || $limit > 50) { json_error("bad limit"); } -echo (new Gazelle\Json\UserRecent($user, $Viewer, new Gazelle\Manager\TGroup())) +echo (new Json\UserRecent($user, $Viewer, new Manager\TGroup())) ->setLimit($limit) ->setVersion(2) ->response(); diff --git a/sections/ajax/userhistory/index.php b/sections/ajax/userhistory/index.php index 65b1e2cfc..86e56fe74 100644 --- a/sections/ajax/userhistory/index.php +++ b/sections/ajax/userhistory/index.php @@ -1,5 +1,9 @@ include_once 'post_history.php', default => json_error('bad type'), diff --git a/sections/ajax/userhistory/post_history.php b/sections/ajax/userhistory/post_history.php index 58336adc8..bd82506c6 100644 --- a/sections/ajax/userhistory/post_history.php +++ b/sections/ajax/userhistory/post_history.php @@ -1,23 +1,27 @@ disableForums()) { json_error('You do not have access to the forums!'); } -$user = empty($_GET['userid']) ? $Viewer : (new Gazelle\Manager\User())->findById((int)$_GET['userid']); +$user = empty($_GET['userid']) ? $Viewer : (new Manager\User())->findById((int)$_GET['userid']); if (is_null($user)) { json_error('User does not exist!'); } $ownProfile = ($user->id() === $Viewer->id()); -$forumSearch = (new Gazelle\Search\Forum($user)) +$forumSearch = (new Search\Forum($user)) ->setViewer($Viewer) ->setShowGrouped($ownProfile && (!isset($_GET['group']) || !!$_GET['group'])) ->setShowUnread($ownProfile && (!isset($_GET['showunread']) || !!$_GET['showunread'])); -echo (new Gazelle\Json\PostHistory( +echo (new Json\PostHistory( $forumSearch, - new Gazelle\Manager\User(), - new Gazelle\Util\Paginator($Viewer->postsPerPage(), (int)($_GET['page'] ?? 1)) + new Manager\User(), + new Util\Paginator($Viewer->postsPerPage(), (int)($_GET['page'] ?? 1)) ))->response(); diff --git a/sections/ajax/usersearch.php b/sections/ajax/usersearch.php index d469db3ab..0624af2bb 100644 --- a/sections/ajax/usersearch.php +++ b/sections/ajax/usersearch.php @@ -1,16 +1,20 @@ setVersion(2) ->response(); diff --git a/sections/ajax/vote_handle.php b/sections/ajax/vote_handle.php index a54aa3a4a..788b3f0c9 100644 --- a/sections/ajax/vote_handle.php +++ b/sections/ajax/vote_handle.php @@ -1,16 +1,20 @@ permitted('site_album_votes')) { json_error('forbidden'); } -$tgroup = (new Gazelle\Manager\TGroup())->findById((int)$_REQUEST['groupid']); +$tgroup = (new Manager\TGroup())->findById((int)$_REQUEST['groupid']); if (is_null($tgroup)) { json_error('no such group'); } -$vote = new Gazelle\User\Vote($Viewer); +$vote = new User\Vote($Viewer); if ($_REQUEST['do'] != 'vote') { json_error('bad args'); diff --git a/sections/ajax/wiki.php b/sections/ajax/wiki.php index 79c5f74c2..c4bf6f052 100644 --- a/sections/ajax/wiki.php +++ b/sections/ajax/wiki.php @@ -1,7 +1,11 @@ findById((int)$_GET['id']); } elseif (isset($_GET['name'])) { @@ -17,15 +21,15 @@ if ($wiki->minClassRead() > $Viewer->privilege()->effectiveClassLevel()) { json_error("higher user class required to view article"); } -Text::$TOC = true; +\Text::$TOC = true; json_print("success", [ 'title' => $wiki->title(), 'bbBody' => $wiki->body(), - 'body' => Text::full_format($wiki->body(), false), + 'body' => \Text::full_format($wiki->body(), false), 'aliases' => $wiki->alias(), 'authorID' => $wiki->authorId(), - 'authorName' => (new Gazelle\Manager\User())->findById($wiki->authorId())?->username(), + 'authorName' => (new Manager\User())->findById($wiki->authorId())?->username(), 'date' => $wiki->date(), 'revision' => $wiki->revision(), ]); diff --git a/sections/api/index.php b/sections/api/index.php index 0c907768e..f0c7ef92e 100644 --- a/sections/api/index.php +++ b/sections/api/index.php @@ -1,10 +1,14 @@ validateToken((int)($_GET['aid'] ?? 0), $_GET['token'] ?? '')) { +if (!(new API())->validateToken((int)($_GET['aid'] ?? 0), $_GET['token'] ?? '')) { json_error('invalid token'); } $className = "Gazelle\\API\\" . str_replace("_", "", ucwords($_GET['action'], "_")); diff --git a/sections/apply/admin.php b/sections/apply/admin.php index b41cb0c9b..bbbdf2155 100644 --- a/sections/apply/admin.php +++ b/sections/apply/admin.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$appRoleMan = new Gazelle\Manager\ApplicantRole(); +declare(strict_types=1); + +namespace Gazelle; + +$appRoleMan = new Manager\ApplicantRole(); if ($Viewer->permitted('admin_manage_applicants')) { $list = $appRoleMan->list(); // everything, including archived roles } else { @@ -33,6 +37,6 @@ if (isset($_POST['auth'])) { echo $Twig->render('applicant/admin.twig', [ 'error' => $error, 'list' => $list, - 'text' => new Gazelle\Util\Textarea('description', ''), + 'text' => new Util\Textarea('description', ''), 'viewer' => $Viewer, ]); diff --git a/sections/apply/apply.php b/sections/apply/apply.php index f7abd1d4f..ed1ac6304 100644 --- a/sections/apply/apply.php +++ b/sections/apply/apply.php @@ -2,8 +2,12 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$appMan = new Gazelle\Manager\Applicant(); -$roleMan = new Gazelle\Manager\ApplicantRole(); +declare(strict_types=1); + +namespace Gazelle; + +$appMan = new Manager\Applicant(); +$roleMan = new Manager\ApplicantRole(); if (isset($_POST['auth'])) { authorize(); @@ -27,7 +31,7 @@ if (isset($_POST['auth'])) { } echo $Twig->render('applicant/apply.twig', [ - 'body' => new Gazelle\Util\Textarea('body', $body ?? ''), + 'body' => new Util\Textarea('body', $body ?? ''), 'error' => $error ?? null, 'list' => $roleMan->publishedList(), 'role' => $role ?? null, diff --git a/sections/apply/edit.php b/sections/apply/edit.php index eaecff2e9..fef1e8b3e 100644 --- a/sections/apply/edit.php +++ b/sections/apply/edit.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_manage_applicants')) { error(403); } -$role = (new Gazelle\Manager\ApplicantRole())->findById((int)($_GET['id'] ?? 0)); +$role = (new Manager\ApplicantRole())->findById((int)($_GET['id'] ?? 0)); if (is_null($role)) { error(404); } @@ -29,10 +33,10 @@ if (isset($_POST['auth'])) { } } -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); echo $Twig->render('applicant/role.twig', [ - 'text' => new Gazelle\Util\Textarea('description', $role->description()), + 'text' => new Util\Textarea('description', $role->description()), 'role' => $role, 'error' => $error ?? null, 'viewer' => $Viewer, diff --git a/sections/apply/index.php b/sections/apply/index.php index 5c05436ed..ad90e733b 100644 --- a/sections/apply/index.php +++ b/sections/apply/index.php @@ -1,5 +1,9 @@ 'admin.php', 'edit' => 'edit.php', diff --git a/sections/apply/view.php b/sections/apply/view.php index 8289b2619..f0f7b9982 100644 --- a/sections/apply/view.php +++ b/sections/apply/view.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$appMan = new Gazelle\Manager\Applicant(); +declare(strict_types=1); + +namespace Gazelle; + +$appMan = new Manager\Applicant(); if (isset($_REQUEST['id'])) { $app = $appMan->findById((int)$_GET['id']); if (is_null($app)) { @@ -46,6 +50,6 @@ echo $Twig->render('applicant/view.twig', [ $Viewer->permitted('users_mod') => $appMan->openList($Viewer), default => $appMan->userList($Viewer), }, - 'note' => new Gazelle\Util\Textarea('note_reply', ''), + 'note' => new Util\Textarea('note_reply', ''), 'viewer' => $Viewer, ]); diff --git a/sections/artist/add_alias.php b/sections/artist/add_alias.php index 4361b316a..fc04dbbbd 100644 --- a/sections/artist/add_alias.php +++ b/sections/artist/add_alias.php @@ -2,18 +2,22 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('torrents_edit')) { error(403); } authorize(); $redirectId = (int)$_POST['redirect']; -$newName = Gazelle\Artist::sanitize($_POST['name']); +$newName = Artist::sanitize($_POST['name']); if (empty($newName)) { error('The specified name is empty.'); } -$artMan = new Gazelle\Manager\Artist(); +$artMan = new Manager\Artist(); $artist = $artMan->findById((int)$_POST['artistid']); if (is_null($artist)) { error(404); diff --git a/sections/artist/add_similar.php b/sections/artist/add_similar.php index 17a4f5a30..bf49461ca 100644 --- a/sections/artist/add_similar.php +++ b/sections/artist/add_similar.php @@ -1,11 +1,15 @@ findById((int)($_POST['artistid'] ?? 0)); if (is_null($artist)) { if (defined('AJAX')) { diff --git a/sections/artist/artist.php b/sections/artist/artist.php index 8fee5c5cb..bf5d603c6 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -4,8 +4,12 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + $revisionId = (int)($_GET['revisionid'] ?? 0); -$artistMan = new Gazelle\Manager\Artist(); +$artistMan = new Manager\Artist(); $artist = $revisionId ? $artistMan->findByIdAndRevision((int)($_GET['id'] ?? 0), $revisionId) : $artistMan->findById((int)($_GET['id'] ?? 0)); @@ -15,21 +19,22 @@ if (is_null($artist)) { $artist->loadArtistRole(); $artistId = $artist->id(); -$bookmark = new Gazelle\User\Bookmark($Viewer); -$collageMan = new Gazelle\Manager\Collage(); -$tgMan = (new Gazelle\Manager\TGroup())->setViewer($Viewer); -$torMan = (new Gazelle\Manager\Torrent())->setViewer($Viewer); -$stats = new Gazelle\Stats\Artist($artistId); -$userMan = new Gazelle\Manager\User(); -$reportMan = new Gazelle\Manager\Report($userMan); -$vote = new Gazelle\User\Vote($Viewer); -$imgProxy = new Gazelle\Util\ImageProxy($Viewer); +$bookmark = new User\Bookmark($Viewer); +$collageMan = new Manager\Collage(); +$tgMan = (new Manager\TGroup())->setViewer($Viewer); +$torMan = (new Manager\Torrent())->setViewer($Viewer); +$stats = new Stats\Artist($artistId); +$userMan = new Manager\User(); +$reportMan = new Manager\Report($userMan); +$vote = new User\Vote($Viewer); +$imgProxy = new Util\ImageProxy($Viewer); + +$isSubscribed = (new User\Subscription($Viewer))->isSubscribedComments('artist', $artistId); +$requestList = $Viewer->disableRequests() ? [] : (new Manager\Request())->findByArtist($artist); -$isSubscribed = (new Gazelle\User\Subscription($Viewer))->isSubscribedComments('artist', $artistId); -$requestList = $Viewer->disableRequests() ? [] : (new Gazelle\Manager\Request())->findByArtist($artist); if (count($artist->groupIds()) > 1000) { // prevent OOMs - Gazelle\DB::DB()->disableQueryLog(); + DB::DB()->disableQueryLog(); } echo $Twig->render('artist/header.twig', [ @@ -39,9 +44,7 @@ echo $Twig->render('artist/header.twig', [ 'revision_id' => $revisionId, 'viewer' => $Viewer, ]); -?> -sections(); foreach ($sections as $sectionId => $groupList) { @@ -198,7 +201,7 @@ if ($sections = $artist->sections()) { imagePath(); + $urlStem = (new User\Stylesheet($Viewer))->imagePath(); $groupsClosed = (bool)$Viewer->option('TorrentGrouping'); $snatcher = $Viewer->snatch(); @@ -301,14 +304,14 @@ echo $Twig->render('artist/similar-graph.twig', [ Artist InformationToggle -
body())?>
+
body())?>
load()->handleSubscription($Viewer); -$paginator = new Gazelle\Util\Paginator(TORRENT_COMMENTS_PER_PAGE, $commentPage->pageNum()); +$paginator = new Util\Paginator(TORRENT_COMMENTS_PER_PAGE, $commentPage->pageNum()); $paginator->setAnchor('comments')->setTotal($commentPage->total())->removeParam('postid'); echo $Twig->render('comment/thread.twig', [ @@ -318,7 +321,7 @@ echo $Twig->render('comment/thread.twig', [ 'comment' => $commentPage, 'paginator' => $paginator, 'subbed' => $isSubscribed, - 'textarea' => (new Gazelle\Util\Textarea('quickpost', '', 90, 8))->setPreviewManual(true), + 'textarea' => (new Util\Textarea('quickpost', '', 90, 8))->setPreviewManual(true), 'url' => $_SERVER['REQUEST_URI'], 'url_stem' => 'comments.php?page=artist', 'userMan' => $userMan, @@ -330,4 +333,4 @@ echo $Twig->render('comment/thread.twig', [
$prefix, - 'suggestions' => (new Gazelle\Manager\Artist())->autocompleteList($prefix), + 'suggestions' => (new Manager\Artist())->autocompleteList($prefix), ]); diff --git a/sections/artist/change_artistid.php b/sections/artist/change_artistid.php index e85ceaf31..f54f9d2cd 100644 --- a/sections/artist/change_artistid.php +++ b/sections/artist/change_artistid.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('torrents_edit')) { error(403); } authorize(); -$artMan = new Gazelle\Manager\Artist(); +$artMan = new Manager\Artist(); $artist = $artMan->findById((int)($_POST['artistid'] ?? 0)); if (is_null($artist)) { error('Please select a valid artist to change.'); diff --git a/sections/artist/delete.php b/sections/artist/delete.php index 7d0141933..99ed61657 100644 --- a/sections/artist/delete.php +++ b/sections/artist/delete.php @@ -2,20 +2,24 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!($Viewer->permitted('site_delete_artist') && $Viewer->permitted('torrents_delete'))) { error(403); } authorize(); -$artist = (new Gazelle\Manager\Artist())->findById((int)($_GET['artistid'] ?? 0)); +$artist = (new Manager\Artist())->findById((int)($_GET['artistid'] ?? 0)); if (is_null($artist)) { error(404); } -$tgMan = new Gazelle\Manager\TGroup(); +$tgMan = new Manager\TGroup(); $tgroupList = array_map(fn ($id) => $tgMan->findById($id), $artist->tgroupIdUsage()); -$reqMan = new Gazelle\Manager\Request(); +$reqMan = new Manager\Request(); $requestList = array_map(fn ($id) => $reqMan->findById($id), $artist->requestIdUsage()); if (count($tgroupList) + count($requestList) > 0) { diff --git a/sections/artist/delete_alias.php b/sections/artist/delete_alias.php index e43190688..24f4244fa 100644 --- a/sections/artist/delete_alias.php +++ b/sections/artist/delete_alias.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('torrents_edit')) { error(403); } authorize(); -$artMan = new Gazelle\Manager\Artist(); +$artMan = new Manager\Artist(); $aliasId = (int)$_GET['aliasid']; $artist = $artMan->findByAliasId($aliasId); if (is_null($artist)) { @@ -23,7 +27,7 @@ if (!empty($artist->aliasInfo()[$aliasId]['alias'])) { error("This alias has redirecting aliases attached."); } -$tgroupList = $artMan->tgroupList($aliasId, new Gazelle\Manager\TGroup()); +$tgroupList = $artMan->tgroupList($aliasId, new Manager\TGroup()); if ($tgroupList) { echo $Twig->render('artist/tgroup-usage.twig', [ 'artist' => $artist, diff --git a/sections/artist/delete_similar.php b/sections/artist/delete_similar.php index 2b62563ab..05a2aef95 100644 --- a/sections/artist/delete_similar.php +++ b/sections/artist/delete_similar.php @@ -1,13 +1,17 @@ permitted('site_delete_tag')) { error(403); } -$artistMan = new Gazelle\Manager\Artist(); +$artistMan = new Manager\Artist(); $artist = $artistMan->findById((int)($_GET['artistid'] ?? 0)); $similar = $artistMan->findById((int)($_GET['similarid'] ?? 0)); if (is_null($artist) || is_null($similar)) { @@ -15,4 +19,5 @@ if (is_null($artist) || is_null($similar)) { } $artist->similar()->removeSimilar($similar, $Viewer); + header("Location: " . redirectUrl($artist->location())); diff --git a/sections/artist/download.php b/sections/artist/download.php index b4b2049f1..4b28a1e7c 100644 --- a/sections/artist/download.php +++ b/sections/artist/download.php @@ -1,21 +1,25 @@ permitted('zip_downloader')) { error(403); } if (!isset($_REQUEST['preference']) || count($_REQUEST['list']) === 0) { error('No artist collector preference specified'); } -$artist = (new Gazelle\Manager\Artist())->findById((int)($_REQUEST['artistid'] ?? 0)); +$artist = (new Manager\Artist())->findById((int)($_REQUEST['artistid'] ?? 0)); if (is_null($artist)) { error(404); } -$collector = new Gazelle\Collector\Artist($Viewer, new Gazelle\Manager\Torrent(), $artist, (int)$_REQUEST['preference']); +$collector = new Collector\Artist($Viewer, new Manager\Torrent(), $artist, (int)$_REQUEST['preference']); if (!$collector->prepare($_REQUEST['list'])) { error("Nothing to gather, choose some encodings and media!"); } $Viewer->modifyOption('Collector', [implode(':', $_REQUEST['list']), $_REQUEST['preference']]); -$collector->emitZip(Gazelle\Util\Zip::make($artist->name())); +$collector->emitZip(Util\Zip::make($artist->name())); diff --git a/sections/artist/edit.php b/sections/artist/edit.php index 82c4671d4..9fc6414b4 100644 --- a/sections/artist/edit.php +++ b/sections/artist/edit.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('torrents_edit')) { error(403); } -$artist = (new Gazelle\Manager\Artist())->findById((int)$_GET['artistid']); +$artist = (new Manager\Artist())->findById((int)$_GET['artistid']); if (is_null($artist)) { $id = html_escape($_GET['artistid']); // might not be a number error("Cannot find an artist with the ID $id: See the site log."); @@ -14,6 +18,6 @@ if (is_null($artist)) { echo $Twig->render('artist/edit.twig', [ 'artist' => $artist, - 'body' => new Gazelle\Util\Textarea('body', $artist->body() ?? '', 91, 15), + 'body' => new Util\Textarea('body', $artist->body() ?? '', 91, 15), 'viewer' => $Viewer, ]); diff --git a/sections/artist/edit_handle.php b/sections/artist/edit_handle.php index 8172f4e96..406120521 100644 --- a/sections/artist/edit_handle.php +++ b/sections/artist/edit_handle.php @@ -1,13 +1,17 @@ permitted('site_edit_wiki')) { error(403); } authorize(); -$artist = (new Gazelle\Manager\Artist())->findById((int)$_POST['artistid']); +$artist = (new Manager\Artist())->findById((int)$_POST['artistid']); if (is_null($artist)) { error(404); } @@ -34,7 +38,7 @@ if ($image != $artist->image()) { if (!preg_match(IMAGE_REGEXP, $image)) { error(display_str($image) . " does not look like a valid image url"); } - $banned = (new Gazelle\Util\ImageProxy($Viewer))->badHost($image); + $banned = (new Util\ImageProxy($Viewer))->badHost($image); if ($banned) { error("Please rehost images from $banned elsewhere."); } @@ -51,7 +55,7 @@ $summary = []; $discogsId = (int)($_POST['discogs-id']); if ($discogsId != $artist->discogs()->id()) { $summary[] = $discogsId ? "Discogs relation set to $discogsId" : "Discogs relation cleared"; - $artist->setField('discogs', new Gazelle\Util\Discogs($discogsId)); + $artist->setField('discogs', new Util\Discogs($discogsId)); } if (isset($_POST['locked'])) { diff --git a/sections/artist/edit_request.php b/sections/artist/edit_request.php index 441f3974e..fa4b036a2 100644 --- a/sections/artist/edit_request.php +++ b/sections/artist/edit_request.php @@ -2,13 +2,17 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$artist = (new Gazelle\Manager\Artist())->findById((int)($_GET['artistid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$artist = (new Manager\Artist())->findById((int)($_GET['artistid'] ?? 0)); if (is_null($artist)) { error(404); } echo $Twig->render('artist/request-edit.twig', [ 'artist' => $artist, - 'details' => new Gazelle\Util\Textarea('edit_details', '', 80, 10), + 'details' => new Util\Textarea('edit_details', '', 80, 10), 'viewer' => $Viewer, ]); diff --git a/sections/artist/edit_request_handle.php b/sections/artist/edit_request_handle.php index dcb50e72e..0e43ccd4a 100644 --- a/sections/artist/edit_request_handle.php +++ b/sections/artist/edit_request_handle.php @@ -2,15 +2,19 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$artist = (new Gazelle\Manager\Artist())->findById((int)($_POST['artistid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$artist = (new Manager\Artist())->findById((int)($_POST['artistid'] ?? 0)); if (is_null($artist)) { error(404); } authorize(); -$thread = (new Gazelle\Manager\ForumThread())->create( - forum: new Gazelle\Forum(EDITING_FORUM_ID), - user: new Gazelle\User(SYSTEM_USER_ID), +$thread = (new Manager\ForumThread())->create( + forum: new Forum(EDITING_FORUM_ID), + user: new User(SYSTEM_USER_ID), title: "Editing request – Artist: " . $artist->name(), body: $Twig->render('forum/edit-request-body.twig', [ 'link' => '[artist]' . $artist->name() . '[/artist]', diff --git a/sections/artist/history.php b/sections/artist/history.php index 7f3fe3210..f30f6f2c0 100644 --- a/sections/artist/history.php +++ b/sections/artist/history.php @@ -1,7 +1,11 @@ findById((int)$_GET['artistid']); if (is_null($artist)) { error(404); diff --git a/sections/artist/index.php b/sections/artist/index.php index 42d6b5848..fc13d89d1 100644 --- a/sections/artist/index.php +++ b/sections/artist/index.php @@ -1,6 +1,10 @@ include_once 'add_similar.php', @@ -34,7 +38,7 @@ if (!empty($_POST['action'])) { } elseif (empty($_GET['artistname'])) { header('Location: torrents.php'); } else { - $db = Gazelle\DB::DB(); + $db = DB::DB(); $NameSearch = str_replace('\\', '\\\\', trim($_GET['artistname'])); $db->prepared_query(" SELECT ArtistID, Name diff --git a/sections/artist/notify.php b/sections/artist/notify.php index 922983e0e..aef6776d8 100644 --- a/sections/artist/notify.php +++ b/sections/artist/notify.php @@ -1,12 +1,16 @@ permitted('site_torrents_notify')) { error(403); } authorize(); -$artist = (new Gazelle\Manager\Artist())->findById((int)$_GET['artistid']); +$artist = (new Manager\Artist())->findById((int)$_GET['artistid']); if (is_null($artist)) { error(404); } diff --git a/sections/artist/notify_remove.php b/sections/artist/notify_remove.php index fc7afa298..fc139b94f 100644 --- a/sections/artist/notify_remove.php +++ b/sections/artist/notify_remove.php @@ -1,12 +1,16 @@ permitted('site_torrents_notify')) { error(403); } authorize(); -$artist = (new Gazelle\Manager\Artist())->findById((int)$_GET['artistid']); +$artist = (new Manager\Artist())->findById((int)$_GET['artistid']); if (is_null($artist)) { error(404); } diff --git a/sections/artist/rename.php b/sections/artist/rename.php index f94edc0fd..9021919f4 100644 --- a/sections/artist/rename.php +++ b/sections/artist/rename.php @@ -1,13 +1,17 @@ permitted('torrents_edit')) { error(403); } authorize(); -$artistMan = new Gazelle\Manager\Artist(); +$artistMan = new Manager\Artist(); $artist = $artistMan->findById((int)($_POST['artistid'] ?? 0)); if (is_null($artist) || empty($_POST['aliasid'])) { error(404); @@ -16,7 +20,7 @@ if (is_null($artist) || empty($_POST['aliasid'])) { } $aliasId = (int)$_POST['aliasid']; -$newName = Gazelle\Artist::sanitize($_POST['name']); +$newName = Artist::sanitize($_POST['name']); if (empty($newName)) { error('No new name given.'); } elseif (!isset($artist->aliasList()[$aliasId])) { @@ -35,8 +39,8 @@ $result = $artist->renameAlias( $aliasId, $newName, $Viewer, - new Gazelle\Manager\Request(), - new Gazelle\Manager\TGroup(), + new Manager\Request(), + new Manager\TGroup(), ); if (is_null($result)) { diff --git a/sections/artist/vote_similar.php b/sections/artist/vote_similar.php index 07a47c975..94425693a 100644 --- a/sections/artist/vote_similar.php +++ b/sections/artist/vote_similar.php @@ -1,12 +1,16 @@ findById((int)($_GET['artistid'] ?? 0)); $similar = $artistMan->findById((int)($_GET['similarid'] ?? 0)); if (is_null($artist) || is_null($similar)) { diff --git a/sections/better/better.php b/sections/better/better.php index f7c07f1fc..7f1ccadbd 100644 --- a/sections/better/better.php +++ b/sections/better/better.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$userMan = new Gazelle\Manager\User(); +declare(strict_types=1); + +namespace Gazelle; + +$userMan = new Manager\User(); if (isset($_GET['userid']) && $Viewer->permitted('users_override_paranoia')) { $user = $userMan->findById((int)$_GET['userid']); if (is_null($user)) { @@ -21,20 +25,20 @@ if (($_GET['method'] ?? '') === 'single') { } $better = match ($type) { - 'artistcollage' => new Gazelle\Better\ArtistCollage($user, $filter, new Gazelle\Manager\Artist()), - 'artistdesc' => new Gazelle\Better\ArtistDescription($user, $filter, new Gazelle\Manager\Artist()), - 'artistdiscogs' => new Gazelle\Better\ArtistDiscogs($user, $filter, new Gazelle\Manager\Artist()), - 'artistimg' => new Gazelle\Better\ArtistImage($user, $filter, new Gazelle\Manager\Artist()), - 'artwork' => new Gazelle\Better\Artwork($user, $filter, (new Gazelle\Manager\TGroup())->setViewer($Viewer)), - 'checksum' => new Gazelle\Better\Checksum($user, $filter, (new Gazelle\Manager\Torrent())->setViewer($Viewer)), - 'single' => new Gazelle\Better\SingleSeeded($user, $filter, (new Gazelle\Manager\Torrent())->setViewer($Viewer)), + 'artistcollage' => new Better\ArtistCollage($user, $filter, new Manager\Artist()), + 'artistdesc' => new Better\ArtistDescription($user, $filter, new Manager\Artist()), + 'artistdiscogs' => new Better\ArtistDiscogs($user, $filter, new Manager\Artist()), + 'artistimg' => new Better\ArtistImage($user, $filter, new Manager\Artist()), + 'artwork' => new Better\Artwork($user, $filter, (new Manager\TGroup())->setViewer($Viewer)), + 'checksum' => new Better\Checksum($user, $filter, (new Manager\Torrent())->setViewer($Viewer)), + 'single' => new Better\SingleSeeded($user, $filter, (new Manager\Torrent())->setViewer($Viewer)), 'files', 'folders', 'lineage', 'tags', 'trumpable' - => (new Gazelle\Better\Bad($user, $filter, new Gazelle\Manager\Torrent()))->setBadType($type), + => (new Better\Bad($user, $filter, new Manager\Torrent()))->setBadType($type), default => error(404), }; -if (isset($_GET['remove']) && $better instanceof Gazelle\Better\Bad && $Viewer->permitted('admin_reports')) { - $torrent = (new Gazelle\Manager\Torrent())->findById((int)$_GET['remove']); +if (isset($_GET['remove']) && $better instanceof Better\Bad && $Viewer->permitted('admin_reports')) { + $torrent = (new Manager\Torrent())->findById((int)$_GET['remove']); if ($torrent) { $torrent->removeFlag($better->torrentFlag()); } @@ -53,7 +57,7 @@ if ($search) { $better->setSearch($search); } -$paginator = new Gazelle\Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($better->total()); echo $Twig->render('better/better.twig', [ diff --git a/sections/better/index.php b/sections/better/index.php index b55a840b7..69dbfceb8 100644 --- a/sections/better/index.php +++ b/sections/better/index.php @@ -1,5 +1,9 @@ 'transcode.php', default => 'better.php', diff --git a/sections/better/transcode.php b/sections/better/transcode.php index 490f97d25..781ab0552 100644 --- a/sections/better/transcode.php +++ b/sections/better/transcode.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + /** * New transcode module: * $_GET['filter'] determines which torrents should be shown and can be uploaded (default), snatched or seeding @@ -18,7 +22,7 @@ if (!isset($_GET['userid'])) { if (!$Viewer->permitted('users_override_paranoia')) { error(403); } - $user = (new Gazelle\Manager\User())->findById((int)$_GET['userid']); + $user = (new Manager\User())->findById((int)$_GET['userid']); if (is_null($user)) { error(404); } @@ -27,7 +31,7 @@ if (!isset($_GET['userid'])) { $filter = $_GET['filter'] ?? 'uploaded'; $search = $_GET['search'] ?? null; $target = $_GET['target'] ?? null; -$better = new Gazelle\Search\Transcode($user, new Gazelle\Manager\Torrent()); +$better = new Search\Transcode($user, new Manager\Torrent()); switch ($filter) { case 'seeding': diff --git a/sections/blog/blog_page.php b/sections/blog/blog_page.php index 5cbf201e5..7c486725c 100644 --- a/sections/blog/blog_page.php +++ b/sections/blog/blog_page.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$blogMan = new Gazelle\Manager\Blog(); +declare(strict_types=1); + +namespace Gazelle; + +$blogMan = new Manager\Blog(); $action = ($_GET['action'] ?? '') === 'editblog' ? 'Edit' : 'Create'; if ($Viewer->permitted('admin_manage_blog')) { $blog = $blogMan->findById((int)($_GET['id'] ?? 0)); - $body = new Gazelle\Util\Textarea('body', $blog ? $blog->body() : ''); + $body = new Util\Textarea('body', $blog ? $blog->body() : ''); } else { $blog = null; $body = null; diff --git a/sections/blog/dead_thread.php b/sections/blog/dead_thread.php index ec18a8b3e..2e4f1bec4 100644 --- a/sections/blog/dead_thread.php +++ b/sections/blog/dead_thread.php @@ -1,12 +1,16 @@ permitted('admin_manage_blog')) { error(403); } authorize(); -$blog = (new Gazelle\Manager\Blog())->findById((int)($_GET['id'] ?? 0)); +$blog = (new Manager\Blog())->findById((int)($_GET['id'] ?? 0)); if (is_null($blog)) { error('Please provide the ID of a blog post from which to remove the thread link.'); } diff --git a/sections/blog/delete_blog.php b/sections/blog/delete_blog.php index f7b6ad42c..6c17125ce 100644 --- a/sections/blog/delete_blog.php +++ b/sections/blog/delete_blog.php @@ -1,12 +1,16 @@ permitted('admin_manage_blog')) { error(403); } authorize(); -$blogMan = new Gazelle\Manager\Blog(); +$blogMan = new Manager\Blog(); $blog = $blogMan->findById((int)($_GET['id'] ?? 0)); if (is_null($blog)) { error('You must provide an ID of a blog to delete'); diff --git a/sections/blog/edit_blog_handle.php b/sections/blog/edit_blog_handle.php index 52cc9d006..9ab3b3ba2 100644 --- a/sections/blog/edit_blog_handle.php +++ b/sections/blog/edit_blog_handle.php @@ -1,6 +1,10 @@ permitted('admin_manage_blog')) { error(403); } @@ -16,16 +20,16 @@ if (empty($title)) { error('The title of the blog article must not be empty'); } -$blog = (new Gazelle\Manager\Blog())->findById((int)($_POST['blogid'] ?? 0)); +$blog = (new Manager\Blog())->findById((int)($_POST['blogid'] ?? 0)); if (is_null($blog)) { error(404); } -$manager = new Gazelle\Manager\ForumThread(); +$manager = new Manager\ForumThread(); $thread = match ((int)($_POST['thread'] ?? -1)) { -1 => null, 0 => $manager->create( - forum: new Gazelle\Forum(ANNOUNCEMENT_FORUM_ID), + forum: new Forum(ANNOUNCEMENT_FORUM_ID), user: $Viewer, title: $title, body: $body, @@ -42,7 +46,7 @@ $blog->setField('Body', $body) ->modify(); if ($thread && isset($_POST['subscribe'])) { - (new Gazelle\User\Subscription($Viewer))->subscribe($thread->id()); + (new User\Subscription($Viewer))->subscribe($thread->id()); } header('Location: blog.php'); diff --git a/sections/blog/index.php b/sections/blog/index.php index e56f4884f..7f7e95c2d 100644 --- a/sections/blog/index.php +++ b/sections/blog/index.php @@ -1,5 +1,9 @@ 'dead_thread.php', 'deleteblog' => 'delete_blog.php', diff --git a/sections/blog/new_blog_handle.php b/sections/blog/new_blog_handle.php index 0e60814ca..c91ba940a 100644 --- a/sections/blog/new_blog_handle.php +++ b/sections/blog/new_blog_handle.php @@ -1,6 +1,12 @@ permitted('admin_manage_blog')) { error(403); } @@ -18,16 +24,16 @@ if (empty($title)) { $thread = match ((int)($_POST['thread'] ?? -1)) { -1 => null, - 0 => (new Gazelle\Manager\ForumThread())->create( - forum: new Gazelle\Forum(ANNOUNCEMENT_FORUM_ID), + 0 => (new Manager\ForumThread())->create( + forum: new Forum(ANNOUNCEMENT_FORUM_ID), user: $Viewer, title: $title, body: $body, ), - default => (new Gazelle\Manager\ForumThread())->findById((int)$_POST['thread']), + default => (new Manager\ForumThread())->findById((int)$_POST['thread']), }; -$blog = (new Gazelle\Manager\Blog())->create([ +$blog = (new Manager\Blog())->create([ 'title' => $title, 'body' => $body, 'important' => isset($_POST['important']) ? 1 : 0, @@ -36,11 +42,11 @@ $blog = (new Gazelle\Manager\Blog())->create([ ]); if ($thread && isset($_POST['subscribe'])) { - (new Gazelle\User\Subscription($Viewer))->subscribe($thread->id()); + (new User\Subscription($Viewer))->subscribe($thread->id()); } -$notification = new Gazelle\Manager\Notification(); -$notification->push($notification->pushableTokens(Gazelle\Enum\NotificationType::BLOG), "New blog article", $blog->title(), $blog->publicLocation()); +$notification = new Manager\Notification(); +$notification->push($notification->pushableTokens(NotificationType::BLOG), "New blog article", $blog->title(), $blog->publicLocation()); -Gazelle\Util\Irc::sendMessage(IRC_CHAN, "New blog article: " . $blog->title()); +Util\Irc::sendMessage(IRC_CHAN, "New blog article: " . $blog->title()); header('Location: blog.php'); diff --git a/sections/bonus/bprates.php b/sections/bonus/bprates.php index fe6a77f3e..e52b1c6c3 100644 --- a/sections/bonus/bprates.php +++ b/sections/bonus/bprates.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + $page = max(1, (int)($_GET['page'] ?? 1)); $limit = TORRENTS_PER_PAGE; $offset = TORRENTS_PER_PAGE * ($page - 1); @@ -18,7 +22,7 @@ $heading = new \Gazelle\Util\SortableTableHeader('hourlypoints', [ 'pointspergb' => ['dbColumn' => 'points_per_gb', 'defaultSort' => 'desc', 'text' => 'BP/GB/year'], ]); -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); if (empty($_GET['userid'])) { $user = $Viewer; $ownProfile = true; @@ -33,9 +37,9 @@ if (empty($_GET['userid'])) { $ownProfile = false; } -$bonus = new Gazelle\User\Bonus($user); +$bonus = new User\Bonus($user); $total = $bonus->userTotals(); -$paginator = new Gazelle\Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($total['total_torrents']); echo $Twig->render('user/bonus.twig', [ diff --git a/sections/bonus/history.php b/sections/bonus/history.php index 45424d430..70eedcc73 100644 --- a/sections/bonus/history.php +++ b/sections/bonus/history.php @@ -2,22 +2,26 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!isset($_GET['userid'])) { $user = $Viewer; } else { if (!$Viewer->permitted('admin_bp_history')) { error(403); } - $user = (new Gazelle\Manager\User())->findById((int)($_GET['userid'] ?? 0)); + $user = (new Manager\User())->findById((int)($_GET['userid'] ?? 0)); if (is_null($user)) { error(404); } } -$bonus = new Gazelle\User\Bonus($user); +$bonus = new User\Bonus($user); $summary = $bonus->summary(); $poolSummary = $bonus->poolHistory(); -$paginator = new Gazelle\Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($summary['nr']); echo $Twig->render('user/bonus-history.twig', [ diff --git a/sections/bonus/index.php b/sections/bonus/index.php index 286aeda82..ddf0ef45c 100644 --- a/sections/bonus/index.php +++ b/sections/bonus/index.php @@ -1,6 +1,10 @@ disableBonusPoints()) { error('Your bonus points have been deactivated.'); } diff --git a/sections/bonus/invite.php b/sections/bonus/invite.php index 0ebda97b9..8105d4ced 100644 --- a/sections/bonus/invite.php +++ b/sections/bonus/invite.php @@ -1,8 +1,12 @@ purchaseInvite()) { +if (!(new User\Bonus($Viewer))->purchaseInvite()) { error("You cannot purchase an invite (either you don't have the privilege or you don't have enough bonus points)."); } header('Location: bonus.php?complete=invite'); diff --git a/sections/bonus/purchase.php b/sections/bonus/purchase.php index ac225be63..6bcfed37c 100644 --- a/sections/bonus/purchase.php +++ b/sections/bonus/purchase.php @@ -1,10 +1,14 @@ purchaseCollage($label)) { diff --git a/sections/bonus/store.php b/sections/bonus/store.php index 7ea6c69c4..6f0fd45db 100644 --- a/sections/bonus/store.php +++ b/sections/bonus/store.php @@ -2,7 +2,13 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$bonus = new Gazelle\User\Bonus($Viewer); +declare(strict_types=1); + +namespace Gazelle; + +$bonus = new User\Bonus($Viewer); +$bonusMan = new Manager\Bonus(); + $purchase = isset($_GET['complete']) ? $bonus->item($_GET['complete'])['Title'] : false; if (($_GET['action'] ?? '') !== 'donate') { $donate = false; @@ -24,8 +30,6 @@ if (($_GET['action'] ?? '') !== 'donate') { } } -$bonusMan = new Gazelle\Manager\Bonus(); - echo $Twig->render('bonus/store.twig', [ 'bonus' => $bonus, 'discount' => $bonusMan->discount(), diff --git a/sections/bonus/title.php b/sections/bonus/title.php index 559a34fb5..c3468c746 100644 --- a/sections/bonus/title.php +++ b/sections/bonus/title.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + /** * @var array $Item * @var int $Price @@ -9,8 +13,8 @@ if (isset($_REQUEST['preview']) && isset($_REQUEST['title']) && isset($_REQUEST['BBCode'])) { echo $_REQUEST['BBCode'] === 'true' - ? Text::full_format($_REQUEST['title']) - : Text::strip_bbcode($_REQUEST['title']); + ? \Text::full_format($_REQUEST['title']) + : \Text::strip_bbcode($_REQUEST['title']); exit; } diff --git a/sections/bonus/token_other.php b/sections/bonus/token_other.php index f7ea33136..a565f2f89 100644 --- a/sections/bonus/token_other.php +++ b/sections/bonus/token_other.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + /** * @var array $Item * @var string $Label @@ -13,7 +17,7 @@ if (isset($_POST['confirm'])) { if (empty($_POST['user'])) { error('You have to enter a username to give tokens to.'); } - $user = (new Gazelle\Manager\User())->findByUsername(urldecode($_POST['user'])); + $user = (new Manager\User())->findByUsername(urldecode($_POST['user'])); if (is_null($user)) { error('Nobody with that name found at ' . SITE_NAME . '. Try a user search and give them tokens from their profile page.'); } elseif ($user->id() == $Viewer->id()) { @@ -30,6 +34,6 @@ echo $Twig->render('bonus/token-other.twig', [ 'auth' => $Viewer->auth(), 'price' => $Price, 'label' => $Label, - 'textarea' => new Gazelle\Util\Textarea('message', ''), + 'textarea' => new Util\Textarea('message', ''), 'item' => $Item['Title'] ]); diff --git a/sections/bonus/tokens.php b/sections/bonus/tokens.php index b2b3ca5fd..76e8056db 100644 --- a/sections/bonus/tokens.php +++ b/sections/bonus/tokens.php @@ -1,6 +1,10 @@ create($type, $id)) { +$id = (int)($_GET['id'] ?? 0); +if (!(new User\Bookmark($Viewer))->create($type, $id)) { json_error('bad parameters'); } if ($type === 'request') { - (new Gazelle\Manager\Request())->findById($id)?->updateBookmarkStats(); + (new Manager\Request())->findById($id)?->updateBookmarkStats(); } print(json_encode('OK')); diff --git a/sections/bookmarks/artists.php b/sections/bookmarks/artists.php index 9049824a8..3ba673fea 100644 --- a/sections/bookmarks/artists.php +++ b/sections/bookmarks/artists.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$userMan = new Gazelle\Manager\User(); +declare(strict_types=1); + +namespace Gazelle; + +$userMan = new Manager\User(); if (!isset($_GET['userid'])) { $user = $Viewer; } else { @@ -16,7 +20,7 @@ if (!isset($_GET['userid'])) { } echo $Twig->render('bookmark/artist.twig', [ - 'list' => (new Gazelle\User\Bookmark($user))->artistList(), + 'list' => (new User\Bookmark($user))->artistList(), 'user' => $user, 'viewer' => $Viewer, ]); diff --git a/sections/bookmarks/edit_torrents.php b/sections/bookmarks/edit_torrents.php index 7e7ca2ab6..490d69941 100644 --- a/sections/bookmarks/edit_torrents.php +++ b/sections/bookmarks/edit_torrents.php @@ -2,22 +2,26 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (empty($_GET['userid'])) { $user = $Viewer; } else { if (!$Viewer->permitted('users_override_paranoia')) { error(403); } - $user = (new Gazelle\Manager\User())->findById((int)($_GET['userid'] ?? 0)); + $user = (new Manager\User())->findById((int)($_GET['userid'] ?? 0)); if (is_null($user)) { error(404); } } -$tgMan = new Gazelle\Manager\TGroup(); +$tgMan = new Manager\TGroup(); $list = []; -foreach ((new Gazelle\User\Bookmark($user))->tgroupBookmarkList() as $info) { +foreach ((new User\Bookmark($user))->tgroupBookmarkList() as $info) { $tgroup = $tgMan->findById($info['tgroup_id']); if (is_null($tgroup)) { continue; diff --git a/sections/bookmarks/index.php b/sections/bookmarks/index.php index 7a5df0a2f..bfa4abbd7 100644 --- a/sections/bookmarks/index.php +++ b/sections/bookmarks/index.php @@ -1,5 +1,9 @@ id()); + $editor = new Editor\UserBookmark($Viewer->id()); if (isset($_POST['update']) && !empty($_POST['sort'])) { $editor->modify($_POST['sort']); } elseif (isset($_POST['delete'])) { diff --git a/sections/bookmarks/remove.php b/sections/bookmarks/remove.php index 121770325..b2d8689fe 100644 --- a/sections/bookmarks/remove.php +++ b/sections/bookmarks/remove.php @@ -1,9 +1,13 @@ remove($_GET['type'], (int)$_GET['id'])) { +if ((new User\Bookmark($Viewer))->remove($_GET['type'], (int)$_GET['id'])) { print(json_encode('OK')); } else { json_error('bad parameters'); diff --git a/sections/bookmarks/remove_snatched.php b/sections/bookmarks/remove_snatched.php index 56c3f6dec..8385c8bae 100644 --- a/sections/bookmarks/remove_snatched.php +++ b/sections/bookmarks/remove_snatched.php @@ -1,8 +1,12 @@ removeSnatched(); +(new User\Bookmark($Viewer))->removeSnatched(); header('Location: bookmarks.php'); diff --git a/sections/bookmarks/torrents.php b/sections/bookmarks/torrents.php index 16619f1ad..4b2d346e5 100644 --- a/sections/bookmarks/torrents.php +++ b/sections/bookmarks/torrents.php @@ -4,12 +4,16 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + ini_set('max_execution_time', 600); set_time_limit(0); //~~~~~~~~~~~ Main bookmarks page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); if (empty($_GET['userid'])) { $user = $Viewer; $ownProfile = true; @@ -24,23 +28,23 @@ if (empty($_GET['userid'])) { $ownProfile = ($user->id() === $Viewer->id()); } -$bookmark = new Gazelle\User\Bookmark($user); +$bookmark = new User\Bookmark($user); $snatcher = $Viewer->snatch(); -$reportMan = new Gazelle\Manager\Report($userMan); -$tgMan = (new Gazelle\Manager\TGroup())->setViewer($Viewer); -$torMan = (new Gazelle\Manager\Torrent())->setViewer($Viewer); -$collMan = (new Gazelle\Manager\Collage())->setImageProxy(new Gazelle\Util\ImageProxy($Viewer)); +$reportMan = new Manager\Report($userMan); +$tgMan = (new Manager\TGroup())->setViewer($Viewer); +$torMan = (new Manager\Torrent())->setViewer($Viewer); +$collMan = (new Manager\Collage())->setImageProxy(new Util\ImageProxy($Viewer)); -$paginator = new Gazelle\Util\Paginator(200, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(200, (int)($_GET['page'] ?? 1)); $paginator->setTotal($bookmark->torrentTotal()); $bookmarkList = $bookmark->torrentList($paginator->limit(), $paginator->offset()); $NumGroups = count($bookmarkList); -$artistLeaderboard = $bookmark->torrentArtistLeaderboard(new Gazelle\Manager\Artist()); +$artistLeaderboard = $bookmark->torrentArtistLeaderboard(new Manager\Artist()); $tagLeaderboard = $bookmark->torrentTagLeaderboard(); $CollageCovers = (int)($Viewer->option('CollageCovers') ?? 25); -View::show_header($user->username() . " › Bookmarked torrent groups", ['js' => 'browse,collage']); +\View::show_header($user->username() . " › Bookmarked torrent groups", ['js' => 'browse,collage']); ?>
@@ -78,7 +82,7 @@ if (count($bookmarkList) === 0) { ?>
@@ -294,4 +298,4 @@ foreach ($bookmarkList as $bm) { isLocked()) { include_once 'webirc_disabled.php'; exit; diff --git a/sections/chat/join.php b/sections/chat/join.php index b5af6bce6..53e4b5c9f 100644 --- a/sections/chat/join.php +++ b/sections/chat/join.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + echo $Twig->render('chat/index.twig', [ 'user' => $Viewer, ]); diff --git a/sections/chat/webirc.php b/sections/chat/webirc.php index 61da57b29..6864e1195 100644 --- a/sections/chat/webirc.php +++ b/sections/chat/webirc.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->disableIRC() && !$Viewer->IRCKey()) { $ircKey = randomString(32); $Viewer->setField('IRCKey', $ircKey)->modify(); diff --git a/sections/chat/webirc_disabled.php b/sections/chat/webirc_disabled.php index 936c09348..2ce5dac67 100644 --- a/sections/chat/webirc_disabled.php +++ b/sections/chat/webirc_disabled.php @@ -2,6 +2,10 @@ /** @phpstan-var ?\Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + $ircNick = sanitize_irc_nick($Viewer?->username() ?? $_GET['nick'] ?? ''); echo $Twig->render('chat/webirc.twig', [ diff --git a/sections/collages/add_artist.php b/sections/collages/add_artist.php index 01475989f..aef12a389 100644 --- a/sections/collages/add_artist.php +++ b/sections/collages/add_artist.php @@ -1,13 +1,17 @@ permitted('site_collages_manage') && !$Viewer->activePersonalColla error(403); } -$collageMan = new Gazelle\Manager\Collage(); +$collageMan = new Manager\Collage(); if (isset($_POST['collage_combo']) && (int)$_POST['collage_combo']) { $collage = $collageMan->findById((int)$_POST['collage_combo']); // From release page } elseif (isset($_POST['collage_ref'])) { @@ -60,7 +64,7 @@ if ($_REQUEST['action'] == 'add_torrent') { } /* check that they correspond to torrent pages */ -$tgroupMan = new Gazelle\Manager\TGroup(); +$tgroupMan = new Manager\TGroup(); $list = []; foreach ($URL as $u) { preg_match(TGROUP_REGEXP, $u, $match); diff --git a/sections/collages/ajax_add.php b/sections/collages/ajax_add.php index fcfd07022..eacb1b368 100644 --- a/sections/collages/ajax_add.php +++ b/sections/collages/ajax_add.php @@ -1,6 +1,10 @@ auth() != $_REQUEST['auth']) { @@ -9,7 +13,7 @@ if ($Viewer->auth() != $_REQUEST['auth']) { if (!$Viewer->permitted('site_collages_manage') && !$Viewer->activePersonalCollages()) { json_die('failure', 'access'); } -$collMan = new Gazelle\Manager\Collage(); +$collMan = new Manager\Collage(); $collage = $collMan->findById((int)($_REQUEST['collage_id'] ?? 0)); if (is_null($collage)) { if (preg_match(COLLAGE_REGEXP, trim($_REQUEST['name']), $match)) { @@ -24,13 +28,13 @@ if (is_null($collage)) { json_die("failure", "collage not found"); } } -$entryManager = $collage->isArtist() ? new Gazelle\Manager\Artist() : new Gazelle\Manager\TGroup(); +$entryManager = $collage->isArtist() ? new Manager\Artist() : new Manager\TGroup(); $entry = $entryManager->findById((int)($_REQUEST['entry_id'] ?? 0)); if (is_null($entry)) { json_die('failure', 'entry not found'); } -echo (new Gazelle\Json\Ajax\CollageAdd( +echo (new Json\Ajax\CollageAdd( collage: $collage, entry: $entry, user: $Viewer, diff --git a/sections/collages/all_comments.php b/sections/collages/all_comments.php index d432c47cc..4812ab1f1 100644 --- a/sections/collages/all_comments.php +++ b/sections/collages/all_comments.php @@ -2,24 +2,28 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$collage = (new Gazelle\Manager\Collage())->findById((int)($_GET['collageid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$collage = (new Manager\Collage())->findById((int)($_GET['collageid'] ?? 0)); if (is_null($collage)) { error(404); } -$commentPage = new Gazelle\Comment\Collage($collage->id(), (int)($_GET['page'] ?? 0), (int)($_GET['postid'] ?? 0)); +$commentPage = new Comment\Collage($collage->id(), (int)($_GET['page'] ?? 0), (int)($_GET['postid'] ?? 0)); $commentPage->load()->handleSubscription($Viewer); -$paginator = new Gazelle\Util\Paginator(TORRENT_COMMENTS_PER_PAGE, $commentPage->pageNum()); +$paginator = new Util\Paginator(TORRENT_COMMENTS_PER_PAGE, $commentPage->pageNum()); $paginator->setAnchor('comments')->setTotal($commentPage->total())->removeParam('postid'); echo $Twig->render('collage/comment.twig', [ 'collage' => $collage, 'comment' => $commentPage, - 'is_subscribed' => (new Gazelle\User\Subscription($Viewer))->isSubscribedComments('collages', $collage->id()), + 'is_subscribed' => (new User\Subscription($Viewer))->isSubscribedComments('collages', $collage->id()), 'paginator' => $paginator, - 'textarea' => (new Gazelle\Util\Textarea('quickpost', '', 90, 8))->setPreviewManual(true), + 'textarea' => (new Util\Textarea('quickpost', '', 90, 8))->setPreviewManual(true), 'url' => $_SERVER['REQUEST_URI'], - 'userMan' => new Gazelle\Manager\User(), + 'userMan' => new Manager\User(), 'viewer' => $Viewer, ]); diff --git a/sections/collages/autocomplete.php b/sections/collages/autocomplete.php index a63a9ce2e..efb89b2d3 100644 --- a/sections/collages/autocomplete.php +++ b/sections/collages/autocomplete.php @@ -1,6 +1,10 @@ $fullName, - 'suggestions' => (new Gazelle\Manager\Collage())->autocomplete($fullName, isset($_GET['artist'])), + 'suggestions' => (new Manager\Collage())->autocomplete($fullName, isset($_GET['artist'])), ]); diff --git a/sections/collages/browse.php b/sections/collages/browse.php index 93fa4ac54..16f658b74 100644 --- a/sections/collages/browse.php +++ b/sections/collages/browse.php @@ -2,8 +2,12 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$userMan = new Gazelle\Manager\User(); -$search = (new Gazelle\Search\Collage())->setLookup($_GET['type'] ?? 'name'); +declare(strict_types=1); + +namespace Gazelle; + +$userMan = new Manager\User(); +$search = (new Search\Collage())->setLookup($_GET['type'] ?? 'name'); if (!empty($_GET['bookmarks'])) { $search->setBookmarkView($Viewer); @@ -19,7 +23,7 @@ if (($_GET['action'] ?? '') === 'mine') { } if (!empty($_GET['tags'])) { - $tagMan = new Gazelle\Manager\Tag(); + $tagMan = new Manager\Tag(); $list = explode(',', $_GET['tags']); $taglist = []; foreach ($list as $name) { @@ -52,14 +56,14 @@ if (($_GET['action'] ?? '') === 'mine') { } } -$paginator = new Gazelle\Util\Paginator(COLLAGES_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(COLLAGES_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($search->total()); echo $Twig->render('collage/browse.twig', [ 'input' => $_GET, 'page' => $search->page($paginator->limit(), $paginator->offset()), 'paginator' => $paginator, - 'personal' => (new Gazelle\Manager\Collage())->findPersonalByUser($Viewer), + 'personal' => (new Manager\Collage())->findPersonalByUser($Viewer), 'search' => $search, 'viewer' => $Viewer, ]); diff --git a/sections/collages/collage.php b/sections/collages/collage.php index b96d56afa..3fec42352 100644 --- a/sections/collages/collage.php +++ b/sections/collages/collage.php @@ -1,6 +1,10 @@ findById((int)($_GET['id'] ?? 0)); if (is_null($Collage)) { error(404); @@ -13,4 +17,4 @@ if ($Collage->isDeleted()) { require_once $Collage->isArtist() ? 'collage_artists.php' : 'collage_torrent.php'; -View::show_footer(); +\View::show_footer(); diff --git a/sections/collages/collage_artists.php b/sections/collages/collage_artists.php index 8c79e32f1..475014fc7 100644 --- a/sections/collages/collage_artists.php +++ b/sections/collages/collage_artists.php @@ -1,10 +1,14 @@ setViewer($Viewer); $CollageID = $Collage->id(); $CollageCovers = (int)($Viewer->option('CollageCovers') ?? 25) * (1 - (int)$Viewer->option('HideCollage')); @@ -39,7 +43,7 @@ if ($CollageCovers) { } echo $Twig->render('collage/header.twig', [ - 'bookmarked' => (new Gazelle\User\Bookmark($Viewer))->isCollageBookmarked($CollageID), + 'bookmarked' => (new User\Bookmark($Viewer))->isCollageBookmarked($CollageID), 'collage' => $Collage, 'object' => 'artist', 'viewer' => $Viewer, @@ -48,7 +52,7 @@ echo $Twig->render('collage/header.twig', [ echo $Twig->render('collage/sidebar.twig', [ 'artists' => 0, // only makes sense for torrent collages 'collage' => $Collage, - 'comments' => (new Gazelle\Manager\Comment())->collageSummary($CollageID), + 'comments' => (new Manager\Comment())->collageSummary($CollageID), 'contributors' => array_slice($Collage->contributors(), 0, 5, true), 'entries' => $Collage->numArtists(), 'object' => 'artist', diff --git a/sections/collages/collage_torrent.php b/sections/collages/collage_torrent.php index f63f81b99..b72b71737 100644 --- a/sections/collages/collage_torrent.php +++ b/sections/collages/collage_torrent.php @@ -4,14 +4,18 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect -$tgMan = (new Gazelle\Manager\TGroup())->setViewer($Viewer); -$torMan = (new Gazelle\Manager\Torrent())->setViewer($Viewer); -$bookmark = new Gazelle\User\Bookmark($Viewer); -$collMan = (new Gazelle\Manager\Collage())->setImageProxy(new \Gazelle\Util\ImageProxy($Viewer)); -$urlStem = (new Gazelle\User\Stylesheet($Viewer))->imagePath(); -$vote = new Gazelle\User\Vote($Viewer); +declare(strict_types=1); -/** @var Gazelle\Collage $Collage required from collage.php */ +namespace Gazelle; + +$tgMan = (new Manager\TGroup())->setViewer($Viewer); +$torMan = (new Manager\Torrent())->setViewer($Viewer); +$bookmark = new User\Bookmark($Viewer); +$collMan = (new Manager\Collage())->setImageProxy(new \Gazelle\Util\ImageProxy($Viewer)); +$urlStem = (new User\Stylesheet($Viewer))->imagePath(); +$vote = new User\Vote($Viewer); + +/** @var Collage $Collage required from collage.php */ $Collage->setViewer($Viewer); $CollageID = $Collage->id(); @@ -32,7 +36,7 @@ echo $Twig->render('collage/header.twig', [ echo$Twig->render('collage/sidebar.twig', [ 'artists' => $Collage->numArtists(), 'collage' => $Collage, - 'comments' => (new Gazelle\Manager\Comment())->collageSummary($CollageID), + 'comments' => (new Manager\Comment())->collageSummary($CollageID), 'contributors' => array_slice($Collage->contributors(), 0, 5, true), 'entries' => $Collage->numEntries(), 'object' => 'torrent', diff --git a/sections/collages/delete.php b/sections/collages/delete.php index fb08cbdcd..a5a2af23f 100644 --- a/sections/collages/delete.php +++ b/sections/collages/delete.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$collage = (new Gazelle\Manager\Collage())->findById((int)($_GET['collageid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$collage = (new Manager\Collage())->findById((int)($_GET['collageid'] ?? 0)); if (is_null($collage)) { error(404); } diff --git a/sections/collages/delete_handle.php b/sections/collages/delete_handle.php index 13649221e..b8b43380b 100644 --- a/sections/collages/delete_handle.php +++ b/sections/collages/delete_handle.php @@ -1,6 +1,10 @@ findById((int)$_POST['collageid']); +$collage = (new Manager\Collage())->findById((int)$_POST['collageid']); if (is_null($collage)) { error(404); } @@ -20,7 +24,7 @@ $collageId = $collage->id(); $name = $collage->name(); $collage->remove(); -(new Gazelle\Manager\Subscription())->flushPage('collages', $collageId); +(new Manager\Subscription())->flushPage('collages', $collageId); $collage->logger()->general( "Collage $collageId ($name) was deleted by {$Viewer->username()}: $reason" ); diff --git a/sections/collages/download.php b/sections/collages/download.php index 056344245..652169b9a 100644 --- a/sections/collages/download.php +++ b/sections/collages/download.php @@ -1,6 +1,10 @@ permitted('zip_downloader')) { error(403); } @@ -9,15 +13,15 @@ if (!isset($_REQUEST['preference']) || count($_REQUEST['list']) === 0) { error('No collage collector preference specified'); } -$collage = (new Gazelle\Manager\Collage())->findById((int)($_REQUEST['collageid'] ?? 0)); +$collage = (new Manager\Collage())->findById((int)($_REQUEST['collageid'] ?? 0)); if (is_null($collage)) { error(404); } -$collector = new Gazelle\Collector\Collage($Viewer, new Gazelle\Manager\Torrent(), $collage, (int)$_REQUEST['preference']); +$collector = new Collector\Collage($Viewer, new Manager\Torrent(), $collage, (int)$_REQUEST['preference']); if (!$collector->prepare($_REQUEST['list'])) { error("Nothing to gather, choose some encodings and media!"); } $Viewer->modifyOption('Collector', [implode(':', $_REQUEST['list']), $_REQUEST['preference']]); -$collector->emitZip(Gazelle\Util\Zip::make($collage->name())); +$collector->emitZip(Util\Zip::make($collage->name())); diff --git a/sections/collages/edit.php b/sections/collages/edit.php index 75e35a381..42dc3c94d 100644 --- a/sections/collages/edit.php +++ b/sections/collages/edit.php @@ -2,24 +2,28 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_edit_wiki')) { error(403); } -$collage = (new Gazelle\Manager\Collage())->findById((int)($_GET['collageid'] ?? 0)); +$collage = (new Manager\Collage())->findById((int)($_GET['collageid'] ?? 0)); if (is_null($collage)) { error(404); } if ($collage->isPersonal() && !$collage->isOwner($Viewer) && !$Viewer->permitted('site_collages_delete')) { error(403); } -$torMan = new Gazelle\Manager\Torrent(); +$torMan = new Manager\Torrent(); echo $Twig->render('collage/edit.twig', [ 'can_rename' => $Viewer->permitted('site_collages_delete') || ($collage->isPersonal() && $collage->isOwner($Viewer) && $Viewer->permitted('site_collages_renamepersonal')), 'collage' => $collage, - 'description' => new Gazelle\Util\Textarea('description', $collage->description(), 60, 10), + 'description' => new Util\Textarea('description', $collage->description(), 60, 10), 'error' => $Err ?? false, 'leech_type' => $torMan->leechTypeList(), 'leech_reason' => $torMan->leechReasonList(), diff --git a/sections/collages/edit_handle.php b/sections/collages/edit_handle.php index 07bb457c4..966e568f8 100644 --- a/sections/collages/edit_handle.php +++ b/sections/collages/edit_handle.php @@ -1,6 +1,10 @@ permitted('site_edit_wiki')) { authorize(); -$collageMan = new Gazelle\Manager\Collage(); +$collageMan = new Manager\Collage(); $collage = $collageMan->findById((int)($_POST['collageid'] ?? 0)); if (is_null($collage)) { error(404); @@ -47,7 +51,7 @@ if (isset($_POST['name'])) { if (!isset($_POST['regen-tags'])) { $collage->setField( 'TagList', - (new Gazelle\Manager\Tag()) + (new Manager\Tag()) ->normalize(str_replace(',', ' ', (string)$_POST['tags'])) ); } else { diff --git a/sections/collages/index.php b/sections/collages/index.php index 4ec4d28aa..91ef774fb 100644 --- a/sections/collages/index.php +++ b/sections/collages/index.php @@ -1,5 +1,9 @@ 'add_torrent.php', diff --git a/sections/collages/manage.php b/sections/collages/manage.php index b375c2a12..c32036214 100644 --- a/sections/collages/manage.php +++ b/sections/collages/manage.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_collages_manage')) { error(403); } -$collage = (new Gazelle\Manager\Collage())->findById((int)($_GET['collageid'] ?? $_GET['id'] ?? 0)); +$collage = (new Manager\Collage())->findById((int)($_GET['collageid'] ?? $_GET['id'] ?? 0)); if (is_null($collage) || $collage->isArtist()) { error(404); } @@ -16,6 +20,6 @@ if ($collage->isPersonal() && !$collage->isOwner($Viewer) && !$Viewer->permitted echo $Twig->render('collage/manage-tgroup.twig', [ 'collage' => $collage, - 'list' => object_generator(new Gazelle\Manager\TGroup(), $collage->groupIds()), + 'list' => object_generator(new Manager\TGroup(), $collage->groupIds()), 'viewer' => $Viewer, ]); diff --git a/sections/collages/manage_artists.php b/sections/collages/manage_artists.php index 46073948a..4c3c43853 100644 --- a/sections/collages/manage_artists.php +++ b/sections/collages/manage_artists.php @@ -2,10 +2,14 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_collages_create')) { error(403); } -$collage = (new Gazelle\Manager\Collage())->findById((int)$_GET['collageid']); +$collage = (new Manager\Collage())->findById((int)$_GET['collageid']); if (is_null($collage)) { error(404); } diff --git a/sections/collages/manage_artists_handle.php b/sections/collages/manage_artists_handle.php index f362a7757..1f6429fb5 100644 --- a/sections/collages/manage_artists_handle.php +++ b/sections/collages/manage_artists_handle.php @@ -1,17 +1,21 @@ permitted('site_collages_create')) { error(403); } authorize(); -$artist = (new Gazelle\Manager\Artist())->findById((int)($_POST['artistid'] ?? 0)); +$artist = (new Manager\Artist())->findById((int)($_POST['artistid'] ?? 0)); if (is_null($artist)) { error(404); } -$collage = (new Gazelle\Manager\Collage())->findById((int)$_POST['collageid']); +$collage = (new Manager\Collage())->findById((int)$_POST['collageid']); if (is_null($collage)) { error(404); } diff --git a/sections/collages/manage_handle.php b/sections/collages/manage_handle.php index eb9e4a08c..e44d0e8b0 100644 --- a/sections/collages/manage_handle.php +++ b/sections/collages/manage_handle.php @@ -1,13 +1,17 @@ permitted('site_collages_manage')) { error(403); } authorize(); -$collage = (new Gazelle\Manager\Collage())->findById((int)($_POST['collageid'])); +$collage = (new Manager\Collage())->findById((int)($_POST['collageid'])); if (is_null($collage)) { error("Cannot find the requested collage"); } @@ -18,7 +22,7 @@ if ($collage->isPersonal() && !$collage->isOwner($Viewer) && !$Viewer->permitted if (isset($_POST['drag_drop_collage_sort_order'])) { $collage->updateSequence($_POST['drag_drop_collage_sort_order']); } elseif (isset($_POST['groupid'])) { - $tgroup = (new Gazelle\Manager\TGroup())->findById((int)($_POST['groupid'] ?? 0)); + $tgroup = (new Manager\TGroup())->findById((int)($_POST['groupid'] ?? 0)); if (is_null($tgroup)) { error("Cannot find torrent group"); } diff --git a/sections/collages/new.php b/sections/collages/new.php index 242347d70..e573ce82e 100644 --- a/sections/collages/new.php +++ b/sections/collages/new.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Enum\CollageType; if (!$Viewer->permitted('site_collages_create') && !$Viewer->canCreatePersonalCollage()) { @@ -12,7 +16,7 @@ if (!$Viewer->permitted('site_collages_create') && !$Viewer->canCreatePersonalCo echo $Twig->render('collage/new.twig', [ 'category' => $Category ?? false, - 'description' => new Gazelle\Util\Textarea('description', $Description ?? '', 60, 10), + 'description' => new Util\Textarea('description', $Description ?? '', 60, 10), 'error' => $Err ?? false, 'name' => $Name ?? '', 'no_name' => !$Viewer->permitted('site_collages_renamepersonal') && (!$Viewer->permitted('site_collages_create') || ($Category ?? -1) === CollageType::personal->value), diff --git a/sections/collages/new_handle.php b/sections/collages/new_handle.php index f5da39045..fc37c8b4d 100644 --- a/sections/collages/new_handle.php +++ b/sections/collages/new_handle.php @@ -1,6 +1,10 @@ permitted('site_collages_create') && !$Viewer->canCreatePersonalCollage()) { @@ -13,9 +17,9 @@ if (!isset($_POST['category'])) { error(403); } $categoryId = (int)$_POST['category']; -$collageMan = new Gazelle\Manager\Collage(); +$collageMan = new Manager\Collage(); -$Val = new Gazelle\Util\Validator(); +$Val = new Util\Validator(); if ($categoryId != CollageType::personal->value || $Viewer->permitted('site_collages_renamepersonal')) { $Val->setField('name', true, 'string', 'The name must be between 3 and 100 characters', ['range' => [3, 100]]); $name = trim($_POST['name']); @@ -63,12 +67,12 @@ $collage = $collageMan->create( $categoryId, $name, $_POST['description'], - (new Gazelle\Manager\Tag())->normalize(str_replace(',', ' ', (string)$_POST['tags'])), + (new Manager\Tag())->normalize(str_replace(',', ' ', (string)$_POST['tags'])), ); if ($Viewer->option('AutoSubscribe')) { $collage->toggleSubscription($Viewer); - (new Gazelle\User\Subscription($Viewer))->subscribeComments('collages', $collage->id()); + (new User\Subscription($Viewer))->subscribeComments('collages', $collage->id()); } header('Location: ' . $collage->location()); diff --git a/sections/collages/recover.php b/sections/collages/recover.php index 35a341329..2d1187d04 100644 --- a/sections/collages/recover.php +++ b/sections/collages/recover.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_collages_recover')) { error(403); } @@ -11,7 +15,7 @@ $_POST['name'] = trim($_POST['name'] ?? ''); if (!empty($_POST['id']) || $_POST['name'] !== '') { authorize(); - $collageMan = new Gazelle\Manager\Collage(); + $collageMan = new Manager\Collage(); $collage = null; if (!empty($_POST['id'])) { diff --git a/sections/comments/comments.php b/sections/comments/comments.php index 3f7c04be9..6e322368f 100644 --- a/sections/comments/comments.php +++ b/sections/comments/comments.php @@ -4,6 +4,10 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + /* * $_REQUEST['action'] is artist, collages, requests or torrents (default torrents) * $_REQUEST['type'] depends on the page: @@ -18,7 +22,7 @@ * If missing or invalid, this defaults to the comments one made */ -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); if (!isset($_GET['id'])) { $User = $Viewer; } else { @@ -181,10 +185,10 @@ $joinArgs[] = $Action; $Join = implode("\n", $Join); $cond = 'WHERE ' . implode(" AND ", $condition); -$db = Gazelle\DB::DB(); +$db = DB::DB(); // Posts per page limit stuff -$paginator = new Gazelle\Util\Paginator($Viewer->postsPerPage(), (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator($Viewer->postsPerPage(), (int)($_GET['page'] ?? 1)); $paginator->setTotal( (int)$db->scalar(" SELECT count(DISTINCT C.ID) FROM $table $Join $cond", ...array_merge($joinArgs, $condArgs) @@ -213,13 +217,13 @@ $Comments = $db->prepared_query(" $requestList = []; $tgroupList = []; if ($Action == 'requests') { - $requestMan = new Gazelle\Manager\Request(); + $requestMan = new Manager\Request(); foreach (array_flip(array_flip($db->collect('PageID'))) as $id) { $id = (int)$id; $requestList[$id] = $requestMan->findById($id); } } elseif ($Action == 'torrents') { - $tgMan = new Gazelle\Manager\TGroup(); + $tgMan = new Manager\TGroup(); foreach (array_flip(array_flip($db->collect('PageID'))) as $id) { $id = (int)$id; $tgroupList[$id] = $tgMan->findById($id); @@ -239,7 +243,7 @@ if ($TypeLinks) { )); } -View::show_header(sprintf($Title, $Username), ['js' => 'bbcode,comments']); +\View::show_header(sprintf($Title, $Username), ['js' => 'bbcode,comments']); ?>
@@ -255,10 +259,10 @@ View::show_header(sprintf($Title, $Username), ['js' => 'bbcode,comments']); linkbox(); - $commentMan = new Gazelle\Manager\Comment(); + $commentMan = new Manager\Comment(); $db->set_query_id($Comments); while ([$AuthorID, $Page, $PageID, $Name, $PostID, $Body, $AddedTime, $EditedTime, $EditedUserID] = $db->next_record(escape: false)) { - $author = new Gazelle\User($AuthorID); + $author = new User($AuthorID); echo $Twig->render('comment/comment.twig', [ 'added_time' => $AddedTime, 'author' => $author, @@ -283,4 +287,4 @@ View::show_header(sprintf($Title, $Username), ['js' => 'bbcode,comments']); ?>
permitted('site_moderate_forums')) { error(403); } authorize(); -$comment = (new Gazelle\Manager\Comment())->findById((int)($_REQUEST['postid'] ?? 0)); +$comment = (new Manager\Comment())->findById((int)($_REQUEST['postid'] ?? 0)); if (is_null($comment)) { error(404); } diff --git a/sections/comments/edit_handle.php b/sections/comments/edit_handle.php index 1768f1251..6413fbdd7 100644 --- a/sections/comments/edit_handle.php +++ b/sections/comments/edit_handle.php @@ -1,6 +1,10 @@ disablePosting()) { error('Your posting privileges have been removed.'); } @@ -11,14 +15,14 @@ if (!strlen($body)) { error(404); } -$comment = (new Gazelle\Manager\Comment())->findById((int)($_REQUEST['postid'] ?? 0)); +$comment = (new Manager\Comment())->findById((int)($_REQUEST['postid'] ?? 0)); if (is_null($comment)) { error(404); } if ($comment->userId() != $Viewer->id() && !$Viewer->permitted('site_moderate_forums')) { error(403); } -$user = (new Gazelle\Manager\User())->findById($comment->userId()); +$user = (new Manager\User())->findById($comment->userId()); if (is_null($user)) { error(404); } @@ -34,4 +38,4 @@ if ((bool)($_POST['pm'] ?? false) && !$comment->isAuthor($Viewer)) { } // This gets sent to the browser, which echoes it in place of the old body -echo Text::full_format($body); +echo \Text::full_format($body); diff --git a/sections/comments/get.php b/sections/comments/get.php index adbebb9a4..62e56cbc9 100644 --- a/sections/comments/get.php +++ b/sections/comments/get.php @@ -1,6 +1,10 @@ findBodyById((int)($_GET['postid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$body = (new Manager\Comment())->findBodyById((int)($_GET['postid'] ?? 0)); if (is_null($body)) { error(404); } diff --git a/sections/comments/index.php b/sections/comments/index.php index c6cc74686..ad7f5eb1f 100644 --- a/sections/comments/index.php +++ b/sections/comments/index.php @@ -1,5 +1,9 @@ 'get.php', 'jump' => 'jump.php', diff --git a/sections/comments/jump.php b/sections/comments/jump.php index e32dca5d1..8b1ef93bd 100644 --- a/sections/comments/jump.php +++ b/sections/comments/jump.php @@ -1,6 +1,10 @@ findById((int)($_REQUEST['postid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$comment = (new Manager\Comment())->findById((int)($_REQUEST['postid'] ?? 0)); if (is_null($comment)) { error(404); } diff --git a/sections/comments/post_handle.php b/sections/comments/post_handle.php index d29414a4f..b6edd1a15 100644 --- a/sections/comments/post_handle.php +++ b/sections/comments/post_handle.php @@ -1,6 +1,10 @@ disablePosting()) { error('Your posting privileges have been removed.'); } @@ -16,7 +20,7 @@ if (!$pageId) { error(404); } -$commentMan = new Gazelle\Manager\Comment(); +$commentMan = new Manager\Comment(); $comment = $commentMan->create($Viewer, $page, $pageId, $_POST['quickpost']); $subscription = new \Gazelle\User\Subscription($Viewer); diff --git a/sections/comments/warn.php b/sections/comments/warn.php index 7c401b4e3..172edcfd2 100644 --- a/sections/comments/warn.php +++ b/sections/comments/warn.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('users_warn')) { error(403); } -$comment = (new Gazelle\Manager\Comment())->findById((int)($_POST['postid'] ?? 0)); +$comment = (new Manager\Comment())->findById((int)($_POST['postid'] ?? 0)); if (is_null($comment)) { error(404); } diff --git a/sections/comments/warn_handle.php b/sections/comments/warn_handle.php index e70b967c8..86e710630 100644 --- a/sections/comments/warn_handle.php +++ b/sections/comments/warn_handle.php @@ -1,8 +1,12 @@ setField('Body', $body) ->setField('EditedUserID', $Viewer->id())->modify(); diff --git a/sections/contest/admin.php b/sections/contest/admin.php index e6f78ddf8..486f59375 100644 --- a/sections/contest/admin.php +++ b/sections/contest/admin.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_manage_contest')) { error(403); } -$contestMan = new Gazelle\Manager\Contest(); +$contestMan = new Manager\Contest(); $create = isset($_GET['action']) && $_GET['action'] === 'create'; $saved = false; @@ -52,7 +56,7 @@ if (isset($_POST['cid'])) { echo $Twig->render('contest/admin.twig', [ 'contest' => $contest, 'create' => $create, - 'intro' => new Gazelle\Util\Textarea('description', $contest?->description() ?? '', 60, 8), + 'intro' => new Util\Textarea('description', $contest?->description() ?? '', 60, 8), 'list' => $contestMan->contestList(), 'saved' => $saved, 'type' => $contestMan->contestTypes(), diff --git a/sections/contest/index.php b/sections/contest/index.php index 5c02cd82c..db42b9384 100644 --- a/sections/contest/index.php +++ b/sections/contest/index.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$contestMan = new Gazelle\Manager\Contest(); +declare(strict_types=1); + +namespace Gazelle; + +$contestMan = new Manager\Contest(); switch ($_GET['action'] ?? '') { case 'leaderboard': diff --git a/sections/contest/leaderboard.php b/sections/contest/leaderboard.php index 9e721e774..14da14c27 100644 --- a/sections/contest/leaderboard.php +++ b/sections/contest/leaderboard.php @@ -2,13 +2,17 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -/** @var Gazelle\Manager\Contest $contestMan */ +declare(strict_types=1); + +namespace Gazelle; + +/** @var Manager\Contest $contestMan */ $prior = $contestMan->priorContests(); if (!empty($_POST['leaderboard'])) { - $contest = new Gazelle\Contest((int)$_POST['leaderboard']); + $contest = new Contest((int)$_POST['leaderboard']); } elseif (!empty($_GET['id'])) { - $contest = new Gazelle\Contest((int)$_GET['id']); + $contest = new Contest((int)$_GET['id']); } else { $contest = $contestMan->currentContest(); if (is_null($contest)) { @@ -16,7 +20,7 @@ if (!empty($_POST['leaderboard'])) { } } -$paginator = new Gazelle\Util\Paginator(CONTEST_ENTRIES_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(CONTEST_ENTRIES_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($contest->totalUsers()); $isRequestFill = $contest instanceof \Gazelle\Contest\RequestFill; diff --git a/sections/donate/index.php b/sections/donate/index.php index 66abec739..b321c1e6b 100644 --- a/sections/donate/index.php +++ b/sections/donate/index.php @@ -2,15 +2,19 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (MONERO_DONATION_ADDRESS) { - $moneroDonation = new Gazelle\Donate\Monero(); + $moneroDonation = new Donate\Monero(); $moneroAddr = $moneroDonation->address($Viewer->id()); } else { $moneroAddr = null; } if (BITCOIN_DONATION_XYZPUB) { - $btcDonation = new Gazelle\Donate\Bitcoin(); + $btcDonation = new Donate\Bitcoin(); $btcAddr = $btcDonation->address($Viewer->id()); } else { $btcAddr = null; diff --git a/sections/enable/index.php b/sections/enable/index.php index a2d143aa0..5e926ec9e 100644 --- a/sections/enable/index.php +++ b/sections/enable/index.php @@ -1,6 +1,10 @@ findByToken($_GET['token']); +$enabler = (new Manager\AutoEnable())->findByToken($_GET['token']); if (is_null($enabler)) { error('invalid enable token'); } diff --git a/sections/error/403.php b/sections/error/403.php index fc540a422..47a22064f 100644 --- a/sections/error/403.php +++ b/sections/error/403.php @@ -1,4 +1,9 @@ -

Error: 403

Forbidden. +

Error: 403

Forbidden. diff --git a/sections/error/404.php b/sections/error/404.php index 501a56ae3..ce23f87ef 100644 --- a/sections/error/404.php +++ b/sections/error/404.php @@ -1,5 +1,11 @@ +

Error: 404

Not Found. Error: 413 Request is too large. +

Error: 413

Request is too large. diff --git a/sections/error/504.php b/sections/error/504.php index 4b154209b..239cc871c 100644 --- a/sections/error/504.php +++ b/sections/error/504.php @@ -1,3 +1,7 @@ -

Error: 504

Gateway timeout. +

Error: 504

Gateway timeout. diff --git a/sections/error/index.php b/sections/error/index.php index 706330a01..be945cc22 100644 --- a/sections/error/index.php +++ b/sections/error/index.php @@ -3,6 +3,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Util\Irc; function notify($Viewer, $Channel, $Message) { diff --git a/sections/forums/add_poll_option.php b/sections/forums/add_poll_option.php index 151721e57..7c8f8d5f9 100644 --- a/sections/forums/add_poll_option.php +++ b/sections/forums/add_poll_option.php @@ -1,12 +1,16 @@ permitted('site_moderate_forums')) { error(403); } authorize(); -$poll = (new Gazelle\Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); +$poll = (new Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); if (is_null($poll)) { error(404); } diff --git a/sections/forums/autosub.php b/sections/forums/autosub.php index d61638b73..e3307d0d5 100644 --- a/sections/forums/autosub.php +++ b/sections/forums/autosub.php @@ -1,12 +1,16 @@ permitted('site_forum_autosub')) { json_error('forbidden'); } authorize(); -$forum = (new Gazelle\Manager\Forum())->findById((int)($_POST['id'] ?? 0)); +$forum = (new Manager\Forum())->findById((int)($_POST['id'] ?? 0)); if (is_null($forum)) { json_error('not found'); } diff --git a/sections/forums/catchup.php b/sections/forums/catchup.php index d9faeced9..859736ffe 100644 --- a/sections/forums/catchup.php +++ b/sections/forums/catchup.php @@ -1,6 +1,10 @@ findById((int)($_GET['forumid'] ?? 0)); +$forum = (new Manager\Forum())->findById((int)($_GET['forumid'] ?? 0)); if (is_null($forum)) { error(404); } diff --git a/sections/forums/change_vote.php b/sections/forums/change_vote.php index e9da142db..b240f2c11 100644 --- a/sections/forums/change_vote.php +++ b/sections/forums/change_vote.php @@ -1,9 +1,13 @@ findById((int)($_POST['threadid'] ?? 0)); +$poll = (new Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); if (is_null($poll)) { error(404); } diff --git a/sections/forums/delete.php b/sections/forums/delete.php index 88b79e06d..f7e1173bb 100644 --- a/sections/forums/delete.php +++ b/sections/forums/delete.php @@ -1,12 +1,16 @@ permitted('site_forum_post_delete')) { error(403); } authorize(); -$post = (new Gazelle\Manager\ForumPost())->findById((int)($_GET['postid'] ?? 0)); +$post = (new Manager\ForumPost())->findById((int)($_GET['postid'] ?? 0)); if (is_null($post)) { error(404); } diff --git a/sections/forums/delete_poll_option.php b/sections/forums/delete_poll_option.php index 351091aad..e5f6c1189 100644 --- a/sections/forums/delete_poll_option.php +++ b/sections/forums/delete_poll_option.php @@ -1,13 +1,17 @@ permitted('site_moderate_forums')) { error(403); } -$poll = (new Gazelle\Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); +$poll = (new Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); if (is_null($poll)) { error(404); } diff --git a/sections/forums/do_warn.php b/sections/forums/do_warn.php index db16fcd66..af4338e4c 100644 --- a/sections/forums/do_warn.php +++ b/sections/forums/do_warn.php @@ -1,6 +1,10 @@ disablePosting()) { error("Your posting privileges have been removed."); } authorize(); -$post = (new Gazelle\Manager\ForumPost())->findById((int)($_POST['post'] ?? 0)); +$post = (new Manager\ForumPost())->findById((int)($_POST['post'] ?? 0)); if (!$post) { error(display_str("No forum post #{$_POST['post']} found")); } @@ -23,7 +27,7 @@ if ($Viewer->id() != $post->userId()) { error("You cannot edit someone else's post"); } if ($_POST['pm'] ?? 0) { - $user = (new Gazelle\Manager\User())->findById($post->userId()); + $user = (new Manager\User())->findById($post->userId()); if (is_null($user)) { error('Author of post not found'); } @@ -37,6 +41,6 @@ if ($Viewer->id() != $post->userId()) { $post->edit($Viewer, trim($_POST['body'])); // This gets sent to the browser, which echoes it in place of the old body -echo Text::full_format($post->body()); +echo \Text::full_format($post->body()); ?>

Last edited by link() ?> Just now diff --git a/sections/forums/forum.php b/sections/forums/forum.php index 67f3cdb96..b61cbe721 100644 --- a/sections/forums/forum.php +++ b/sections/forums/forum.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + /**********|| Page to show individual forums || ********************************\ Things to expect in $_GET: @@ -11,7 +15,7 @@ Things to expect in $_GET: ********************************************************************************/ -$forum = (new Gazelle\Manager\Forum())->findById((int)$_GET['forumid']); +$forum = (new Manager\Forum())->findById((int)$_GET['forumid']); if (!$forum) { error(404); } @@ -20,7 +24,7 @@ if (!$Viewer->readAccess($forum)) { error(403); } -$paginator = new Gazelle\Util\Paginator(TOPICS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(TOPICS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($forum->threadCount()); $userLastRead = $forum->userLastRead($Viewer); diff --git a/sections/forums/get_post.php b/sections/forums/get_post.php index 00f165981..e8020daad 100644 --- a/sections/forums/get_post.php +++ b/sections/forums/get_post.php @@ -1,7 +1,11 @@ findById((int)($_GET['post'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$post = (new Manager\ForumPost())->findById((int)($_GET['post'] ?? 0)); if (is_null($post)) { error(404); } diff --git a/sections/forums/index.php b/sections/forums/index.php index c9fa90e45..5ad68747b 100644 --- a/sections/forums/index.php +++ b/sections/forums/index.php @@ -1,6 +1,10 @@ disableForums()) { error(403); } diff --git a/sections/forums/main.php b/sections/forums/main.php index 2baef71bd..1ecb1d36d 100644 --- a/sections/forums/main.php +++ b/sections/forums/main.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + echo $Twig->render('forum/main.twig', [ - 'toc' => (new Gazelle\Manager\Forum())->tableOfContents($Viewer), + 'toc' => (new Manager\Forum())->tableOfContents($Viewer), 'viewer' => $Viewer, ]); diff --git a/sections/forums/new_thread.php b/sections/forums/new_thread.php index 1f27fb971..f08f1cf2e 100644 --- a/sections/forums/new_thread.php +++ b/sections/forums/new_thread.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$forum = (new Gazelle\Manager\Forum())->findById((int)($_GET['forumid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$forum = (new Manager\Forum())->findById((int)($_GET['forumid'] ?? 0)); if (!$forum) { error(404); } @@ -13,6 +17,6 @@ if (!$Viewer->writeAccess($forum) || !$Viewer->createAccess($forum)) { echo $Twig->render('forum/new-thread.twig', [ 'id' => $forum->id(), 'name' => $forum->name(), - 'textarea' => new Gazelle\Util\Textarea('body', '', 90, 8), + 'textarea' => new Util\Textarea('body', '', 90, 8), 'viewer' => $Viewer, ]); diff --git a/sections/forums/new_thread_handle.php b/sections/forums/new_thread_handle.php index 9fbf1d0ff..c01e780f2 100644 --- a/sections/forums/new_thread_handle.php +++ b/sections/forums/new_thread_handle.php @@ -1,6 +1,10 @@ findById((int)$_POST['forum']); +$forum = (new Manager\Forum())->findById((int)$_POST['forum']); if (is_null($forum)) { error(404); } @@ -60,10 +64,10 @@ if (empty($_POST['question']) || empty($_POST['answers']) || !$Viewer->permitted } } -$thread = (new Gazelle\Manager\ForumThread())->create($forum, $Viewer, $title, $body); +$thread = (new Manager\ForumThread())->create($forum, $Viewer, $title, $body); $threadId = $thread->id(); if ($needPoll) { - (new Gazelle\Manager\ForumPoll())->create($threadId, $question, $answerList); + (new Manager\ForumPoll())->create($threadId, $question, $answerList); if ($forum->id() == STAFF_FORUM_ID) { Irc::sendMessage( IRC_CHAN_STAFF, @@ -73,13 +77,13 @@ if ($needPoll) { } if (isset($_POST['subscribe'])) { - (new Gazelle\User\Subscription($Viewer))->subscribe($threadId); + (new User\Subscription($Viewer))->subscribe($threadId); } -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); foreach ($forum->autoSubscribeUserIdList() as $userId) { $user = $userMan->findById($userId); if ($user) { - (new Gazelle\User\Subscription($user))->subscribe($threadId); + (new User\Subscription($user))->subscribe($threadId); } } diff --git a/sections/forums/poll_mod.php b/sections/forums/poll_mod.php index fc12c03d2..1ed40c61d 100644 --- a/sections/forums/poll_mod.php +++ b/sections/forums/poll_mod.php @@ -1,12 +1,16 @@ permitted('forums_polls_moderate')) { error(403); } authorize(); -$poll = (new Gazelle\Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); +$poll = (new Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); if (is_null($poll)) { error('Cannot find a poll for that thread'); } diff --git a/sections/forums/poll_vote.php b/sections/forums/poll_vote.php index 76e43db77..e5dc6522e 100644 --- a/sections/forums/poll_vote.php +++ b/sections/forums/poll_vote.php @@ -3,7 +3,11 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect -$poll = (new Gazelle\Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$poll = (new Manager\ForumPoll())->findById((int)($_POST['threadid'] ?? 0)); if (is_null($poll)) { error(404); } @@ -42,7 +46,7 @@ if (!isset($_POST['vote']) || !is_number($_POST['vote'])) {
    hasRevealVotes()) { - $staffVote = $poll->staffVote(new Gazelle\Manager\User()); + $staffVote = $poll->staffVote(new Manager\User()); foreach ($staffVote as $response => $info) { if ($response !== 'missing') { ?> diff --git a/sections/forums/reply_handle.php b/sections/forums/reply_handle.php index 0322f9ed2..d17222a3b 100644 --- a/sections/forums/reply_handle.php +++ b/sections/forums/reply_handle.php @@ -1,12 +1,16 @@ disablePosting()) { error('Your posting privileges have been removed.'); } authorize(); -$thread = (new Gazelle\Manager\ForumThread())->findById((int)($_POST['threadid'] ?? 0)); +$thread = (new Manager\ForumThread())->findById((int)($_POST['threadid'] ?? 0)); if (is_null($thread)) { error(404); } @@ -25,7 +29,7 @@ if ($body === '') { } if ($thread->lastAuthorId() == $Viewer->id() && isset($_POST['merge'])) { - $post = (new Gazelle\Manager\ForumPost())->findById($thread->lastPostId()); + $post = (new Manager\ForumPost())->findById($thread->lastPostId()); if (is_null($post)) { error("cannot find post #{$thread->lastPostId()} in thread {$thread->id()}"); } @@ -34,13 +38,13 @@ if ($thread->lastAuthorId() == $Viewer->id() && isset($_POST['merge'])) { $post = $thread->addPost($Viewer, $body); } -(new Gazelle\User\Notification\Quote($Viewer))->create( - new Gazelle\Manager\User(), $body, $post->id(), 'forums', $threadId +(new User\Notification\Quote($Viewer))->create( + new Manager\User(), $body, $post->id(), 'forums', $threadId ); -$subscription = new Gazelle\User\Subscription($Viewer); +$subscription = new User\Subscription($Viewer); if (isset($_POST['subscribe']) && !$subscription->isSubscribed($threadId)) { $subscription->subscribe($threadId); } -(new Gazelle\Manager\Subscription())->flushPage('forums', $threadId); +(new Manager\Subscription())->flushPage('forums', $threadId); header("Location: {$post->location()}"); diff --git a/sections/forums/search.php b/sections/forums/search.php index 424800428..c391d2907 100644 --- a/sections/forums/search.php +++ b/sections/forums/search.php @@ -3,9 +3,13 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Util\Time; -$search = new Gazelle\Search\Forum($Viewer); +$search = new Search\Forum($Viewer); $search->setSearchType($_GET['type'] ?? 'title') ->setSearchText(trim($_GET['search'] ?? '')); @@ -66,10 +70,10 @@ if (isset($_GET['forums']) && is_array($_GET['forums'])) { $search->setForumList($_GET['forums']); } -$paginator = new Gazelle\Util\Paginator(POSTS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(POSTS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($search->totalHits()); -View::show_header('Forums › Search', ['js' => 'bbcode,forum_search']); +\View::show_header('Forums › Search', ['js' => 'bbcode,forum_search']); ?>
    @@ -131,7 +135,7 @@ echo "class='hidden'"; } ?>> $LastCategoryID = -1; $Columns = 0; $i = 0; - foreach ((new Gazelle\Manager\Forum())->forumList() as $forum) { + foreach ((new Manager\Forum())->forumList() as $forum) { if (!$Viewer->readAccess($forum)) { continue; } @@ -232,7 +236,7 @@ echo "&postid=$PostID#post$PostID"; } ?>"> isBodySearch()) { ?>
- + ">linkbox() ?> permitted('site_moderate_forums')) { error(403); } authorize(); -$post = (new Gazelle\Manager\ForumPost())->findById((int)($_GET['postid'] ?? 0)); +$post = (new Manager\ForumPost())->findById((int)($_GET['postid'] ?? 0)); if (is_null($post)) { error(404); } diff --git a/sections/forums/thread.php b/sections/forums/thread.php index ee31da1ae..cdad8f110 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -5,11 +5,15 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Enum\CacheBucket; -$forumMan = new Gazelle\Manager\Forum(); +$forumMan = new Manager\Forum(); if (isset($_GET['postid'])) { - $post = (new Gazelle\Manager\ForumPost())->findById((int)$_GET['postid']); + $post = (new Manager\ForumPost())->findById((int)$_GET['postid']); if (is_null($post)) { error(404); } @@ -20,7 +24,7 @@ if (isset($_GET['postid'])) { $thread = $post->thread(); } elseif (isset($_GET['threadid'])) { $post = null; - $thread = (new Gazelle\Manager\ForumThread())->findById((int)$_GET['threadid']); + $thread = (new Manager\ForumThread())->findById((int)$_GET['threadid']); if (is_null($thread)) { error(404); } @@ -51,7 +55,7 @@ if (($Page - 1) * $PerPage > $thread->postTotal()) { $Page = (int)ceil($thread->postTotal() / $PerPage); } $slice = $thread->slice(perPage: $PerPage, page: $Page); -$paginator = new Gazelle\Util\Paginator($PerPage, $Page); +$paginator = new Util\Paginator($PerPage, $Page); $paginator->setTotal($thread->postTotal()); $firstOnPage = current($slice)['ID'] ?? 0; @@ -60,7 +64,7 @@ if ($lastOnPage <= $thread->pinnedPostId() && $thread->postTotal() <= $PerPage * $lastOnPage = $thread->pinnedPostId(); } -$quote = new Gazelle\User\Quote($Viewer); +$quote = new User\Quote($Viewer); if ($quote->unreadTotal()) { $quote->clearThread($threadId, $firstOnPage, $lastOnPage); } @@ -70,19 +74,19 @@ if ($lastRead < $lastOnPage) { $thread->catchup($Viewer, $lastOnPage); } -$isSubscribed = (new Gazelle\User\Subscription($Viewer))->isSubscribed($threadId); +$isSubscribed = (new User\Subscription($Viewer))->isSubscribed($threadId); if ($isSubscribed) { $Cache->delete_value('subscriptions_user_new_' . $Viewer->id()); } -$userMan = new Gazelle\Manager\User(); -$avatarFilter = Gazelle\Util\Twig::factory($userMan)->createTemplate('{{ user|avatar(viewer)|raw }}'); +$userMan = new Manager\User(); +$avatarFilter = Util\Twig::factory($userMan)->createTemplate('{{ user|avatar(viewer)|raw }}'); -$transitions = (new Gazelle\Manager\ForumTransition())->threadTransitionList($Viewer, $thread); +$transitions = (new Manager\ForumTransition())->threadTransitionList($Viewer, $thread); $department = $forum->departmentList($Viewer); $auth = $Viewer->auth(); -View::show_header("Forums › $ForumName › {$thread->title()}", +\View::show_header("Forums › $ForumName › {$thread->title()}", ['js' => 'comments,subscriptions,bbcode' . ($IsDonorForum ? ',donor_titles' : '')] ); echo $Twig->render('forum/thread-header.twig', [ @@ -94,7 +98,7 @@ echo $Twig->render('forum/thread-header.twig', [ ]); echo $Twig->render('forum/poll.twig', [ - 'poll' => $thread->hasPoll() ? new Gazelle\ForumPoll($threadId) : false, + 'poll' => $thread->hasPoll() ? new ForumPoll($threadId) : false, 'user_man' => $userMan, 'viewer' => $Viewer, ]); @@ -114,11 +118,11 @@ if ($thread->pinnedPostId()) { } // Enable TOC -Text::$TOC = true; +\Text::$TOC = true; foreach ($slice as $Key => $Post) { [$PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime] = array_values($Post); - $author = new Gazelle\User($AuthorID); + $author = new User($AuthorID); $tableClass = ['forum_post', 'wrap_overflow', 'box vertical_margin']; if ( (!$thread->isLocked() || $thread->isPinned()) @@ -187,7 +191,7 @@ if (!empty($userTitle)) { Report permitted('users_warn') && $Viewer->id() != $AuthorID && $Viewer->classLevel() >= $author->classLevel()) { ?> @@ -213,7 +217,7 @@ if (!empty($userTitle)) {
showAvatars()) { echo ' colspan="2"'; } ?>>
- +

@@ -242,7 +246,7 @@ if ($Viewer->permitted('site_moderate_forums') || ($Viewer->writeAccess($forum) 'object' => $thread, 'merge' => strtotime($lastPost['AddedTime']) > time() - 3600 && $lastPost['AuthorID'] == $Viewer->id(), 'subbed' => $isSubscribed, - 'textarea' => (new Gazelle\Util\Textarea('quickpost', '', 90, 8))->setPreviewManual(true), + 'textarea' => (new Util\Textarea('quickpost', '', 90, 8))->setPreviewManual(true), 'viewer' => $Viewer, ]); } diff --git a/sections/forums/thread_handle.php b/sections/forums/thread_handle.php index 5b4bb5966..00b7db6e4 100644 --- a/sections/forums/thread_handle.php +++ b/sections/forums/thread_handle.php @@ -1,14 +1,18 @@ permitted('site_moderate_forums') && empty($_POST['transition'])) { error(403); } authorize(); -$forumMan = new Gazelle\Manager\Forum(); +$forumMan = new Manager\Forum(); -$thread = (new Gazelle\Manager\ForumThread())->findById((int)($_POST['threadid'] ?? 0)); +$thread = (new Manager\ForumThread())->findById((int)($_POST['threadid'] ?? 0)); if (is_null($thread)) { error(404); } @@ -57,7 +61,7 @@ if (isset($_POST['transition'])) { if ($transId < 1) { error('No forum transition ID specified'); } - $transitions = (new Gazelle\Manager\ForumTransition())->threadTransitionList($Viewer, $thread); + $transitions = (new Manager\ForumTransition())->threadTransitionList($Viewer, $thread); if (!isset($transitions[$transId])) { error('Forum transition not found'); } diff --git a/sections/forums/thread_notes_handle.php b/sections/forums/thread_notes_handle.php index 24667ada2..73ce5cf2f 100644 --- a/sections/forums/thread_notes_handle.php +++ b/sections/forums/thread_notes_handle.php @@ -1,12 +1,16 @@ permitted('site_moderate_forums')) { error(403); } authorize(); -$thread = (new Gazelle\Manager\ForumThread())->findById((int)($_POST['threadid'] ?? 0)); +$thread = (new Manager\ForumThread())->findById((int)($_POST['threadid'] ?? 0)); if (is_null($thread)) { error(404); } diff --git a/sections/forums/warn.php b/sections/forums/warn.php index 0ab4ca171..7914d783d 100644 --- a/sections/forums/warn.php +++ b/sections/forums/warn.php @@ -2,16 +2,20 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('users_warn')) { error(403); } authorize(); -$post = (new Gazelle\Manager\ForumPost())->findById((int)($_POST['postid'] ?? 0)); +$post = (new Manager\ForumPost())->findById((int)($_POST['postid'] ?? 0)); if (is_null($post)) { error(404); } -$user = (new Gazelle\Manager\User())->findById((int)($_POST['userid'] ?? 0)); +$user = (new Manager\User())->findById((int)($_POST['userid'] ?? 0)); if (is_null($user)) { error(404); } diff --git a/sections/forums/warn_handle.php b/sections/forums/warn_handle.php index bf2b4ac5e..0f38e674d 100644 --- a/sections/forums/warn_handle.php +++ b/sections/forums/warn_handle.php @@ -1,8 +1,12 @@ edit($Viewer, $body); if ($post->isPinned()) { $post->thread()->flush(); diff --git a/sections/friends/add.php b/sections/friends/add.php index 1580da461..bac739ac5 100644 --- a/sections/friends/add.php +++ b/sections/friends/add.php @@ -1,9 +1,13 @@ findById((int)($_GET['friendid'] ?? 0)); +$friend = (new Manager\User())->findById((int)($_GET['friendid'] ?? 0)); if (!$friend) { error("no such user found"); } @@ -12,7 +16,7 @@ if ($friend->id() === $Viewer->id()) { error("you cannot add yourself as a friend"); } -if (!(new Gazelle\User\Friend($Viewer))->add($friend)) { +if (!(new User\Friend($Viewer))->add($friend)) { error("you are already friends with {$friend->username()}"); } diff --git a/sections/friends/comment.php b/sections/friends/comment.php index b686bea8a..8ec354e0c 100644 --- a/sections/friends/comment.php +++ b/sections/friends/comment.php @@ -1,14 +1,18 @@ findById((int)($_POST['friendid'] ?? 0)); +$friend = (new Manager\User())->findById((int)($_POST['friendid'] ?? 0)); if (!$friend) { error("no such user found"); } -$viewerFriend = new Gazelle\User\Friend($Viewer); +$viewerFriend = new User\Friend($Viewer); if (!$viewerFriend->isFriend($friend)) { error("you are not friends with {$friend->username()}"); } diff --git a/sections/friends/friends.php b/sections/friends/friends.php index 9b735f412..a7d089531 100644 --- a/sections/friends/friends.php +++ b/sections/friends/friends.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$friend = new Gazelle\User\Friend($Viewer); -$paginator = new Gazelle\Util\Paginator(FRIENDS_PER_PAGE, (int)($_GET['page'] ?? 1)); +declare(strict_types=1); + +namespace Gazelle; + +$friend = new User\Friend($Viewer); +$paginator = new Util\Paginator(FRIENDS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($friend->total()); echo $Twig->render('user/friend.twig', [ - 'list' => $friend->page(new Gazelle\Manager\User(), $paginator->limit(), $paginator->offset()), + 'list' => $friend->page(new Manager\User(), $paginator->limit(), $paginator->offset()), 'paginator' => $paginator, 'viewer' => $Viewer, ]); diff --git a/sections/friends/index.php b/sections/friends/index.php index de04fed74..9ab942007 100644 --- a/sections/friends/index.php +++ b/sections/friends/index.php @@ -1,5 +1,9 @@ 'add.php', 'Save notes' => 'comment.php', diff --git a/sections/friends/remove.php b/sections/friends/remove.php index 2d6b195e8..cdc160cbe 100644 --- a/sections/friends/remove.php +++ b/sections/friends/remove.php @@ -1,13 +1,17 @@ findById((int)($_POST['friendid'] ?? 0)); +$friend = (new Manager\User())->findById((int)($_POST['friendid'] ?? 0)); if (!$friend) { error("no such user found"); } -(new Gazelle\User\Friend($Viewer))->remove($friend); +(new User\Friend($Viewer))->remove($friend); header('Location: friends.php'); diff --git a/sections/inbox/compose.php b/sections/inbox/compose.php index f27694db7..70beeac99 100644 --- a/sections/inbox/compose.php +++ b/sections/inbox/compose.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$recipient = (new Gazelle\Manager\User())->findById((int)$_GET['toid']); +declare(strict_types=1); + +namespace Gazelle; + +$recipient = (new Manager\User())->findById((int)$_GET['toid']); if (is_null($recipient)) { error(404); } @@ -14,7 +18,7 @@ if ($recipient->id() == $Viewer->id()) { } echo $Twig->render('inbox/compose.twig', [ - 'body' => new Gazelle\Util\Textarea('body', '', 95, 10), + 'body' => new Util\Textarea('body', '', 95, 10), 'recipient' => $recipient, 'viewer' => $Viewer, ]); diff --git a/sections/inbox/compose_handle.php b/sections/inbox/compose_handle.php index c06ec83be..a89e4a6b5 100644 --- a/sections/inbox/compose_handle.php +++ b/sections/inbox/compose_handle.php @@ -1,9 +1,13 @@ findById((int)$_POST['toid']); +$recipient = (new Manager\User())->findById((int)$_POST['toid']); if (is_null($recipient)) { error(404); } @@ -16,8 +20,8 @@ if ($body === '') { error('You cannot send a message without a body.'); } -$userMan = new Gazelle\Manager\User(); -$pmMan = new Gazelle\Manager\PM($Viewer); +$userMan = new Manager\User(); +$pmMan = new Manager\PM($Viewer); $pm = $pmMan->findById((int)($_POST['convid'] ?? 0)); if ($pm) { $userMan->replyPM($recipient->id(), $Viewer->id(), $pm->subject(), $body, $pm->id()); @@ -28,4 +32,5 @@ if ($pm) { } $pm = $recipient->inbox()->create($Viewer, $subject, $body); } + header("Location: inbox.php"); diff --git a/sections/inbox/conversation.php b/sections/inbox/conversation.php index 127ccb404..14aca4ef2 100644 --- a/sections/inbox/conversation.php +++ b/sections/inbox/conversation.php @@ -2,22 +2,26 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$pm = (new Gazelle\Manager\PM($Viewer))->findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$pm = (new Manager\PM($Viewer))->findById((int)($_GET['id'] ?? 0)); if (is_null($pm)) { error(404); } $pm->markRead(); $postTotal = $pm->postTotal(); -$paginator = new Gazelle\Util\Paginator(POSTS_PER_PAGE, (int)($_GET['page'] ?? ceil($postTotal / POSTS_PER_PAGE))); +$paginator = new Util\Paginator(POSTS_PER_PAGE, (int)($_GET['page'] ?? ceil($postTotal / POSTS_PER_PAGE))); $paginator->setTotal($postTotal); echo $Twig->render('inbox/conversation.twig', [ - 'body' => new Gazelle\Util\Textarea('body', '', 90, 10), + 'body' => new Util\Textarea('body', '', 90, 10), 'inbox' => $Viewer->inbox()->setFolder($_GET['section'] ?? 'inbox'), 'paginator' => $paginator, 'pm' => $pm, 'post_list' => $pm->postList($paginator->limit(), $paginator->offset()), - 'staff_list' => (new Gazelle\Manager\User())->staffPMList(), + 'staff_list' => (new Manager\User())->staffPMList(), 'viewer' => $Viewer, ]); diff --git a/sections/inbox/edit_handle.php b/sections/inbox/edit_handle.php index be391c34c..69de6b1da 100644 --- a/sections/inbox/edit_handle.php +++ b/sections/inbox/edit_handle.php @@ -1,9 +1,13 @@ findById((int)$_POST['convid']); +$pm = (new Manager\PM($Viewer))->findById((int)$_POST['convid']); if (is_null($pm)) { error(404); } diff --git a/sections/inbox/forward.php b/sections/inbox/forward.php index 58ca414a3..ed703e1e3 100644 --- a/sections/inbox/forward.php +++ b/sections/inbox/forward.php @@ -1,13 +1,17 @@ findById((int)$_POST['convid']); +$pm = (new Manager\PM($Viewer))->findById((int)$_POST['convid']); if (is_null($pm)) { error('Sorry, there is no trace of that conversation in your folder'); } -$recipient = (new Gazelle\Manager\User())->findById((int)$_POST['receiverid']); +$recipient = (new Manager\User())->findById((int)$_POST['receiverid']); if (is_null($recipient)) { error('Sorry, there is no-one here by that name'); } diff --git a/sections/inbox/get_post.php b/sections/inbox/get_post.php index ccf9b893c..5bf49a9b3 100644 --- a/sections/inbox/get_post.php +++ b/sections/inbox/get_post.php @@ -1,8 +1,12 @@ findByPostId($postId); +$pm = (new Manager\PM($Viewer))->findByPostId($postId); if (is_null($pm)) { error(403); } diff --git a/sections/inbox/inbox.php b/sections/inbox/inbox.php index 7bc535807..6378e9a6b 100644 --- a/sections/inbox/inbox.php +++ b/sections/inbox/inbox.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + $inbox = $Viewer->inbox(); $inbox->setFolder($_GET['section'] ?? $_GET['action'] ?? 'inbox'); if (isset($_GET['searchtype'])) { @@ -18,7 +22,7 @@ if ($filter) { $inbox->setFilter($filter); } -$paginator = new Gazelle\Util\Paginator(MESSAGES_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(MESSAGES_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($inbox->messageTotal()); echo $Twig->render('inbox/inbox.twig', [ diff --git a/sections/inbox/index.php b/sections/inbox/index.php index 3959b8a37..07a38a437 100644 --- a/sections/inbox/index.php +++ b/sections/inbox/index.php @@ -1,5 +1,9 @@ 'compose.php', 'forward' => 'forward.php', diff --git a/sections/inbox/massdelete_handle.php b/sections/inbox/massdelete_handle.php index 3d3e693b8..86168eea6 100644 --- a/sections/inbox/massdelete_handle.php +++ b/sections/inbox/massdelete_handle.php @@ -1,6 +1,10 @@ $id > 0); if (empty($messageIds)) { diff --git a/sections/index/index.php b/sections/index/index.php index 033db062b..3e2439fe5 100644 --- a/sections/index/index.php +++ b/sections/index/index.php @@ -1,6 +1,10 @@ latestId() != -1 && $newsReader->lastRead($Viewer) < $newsMan->latestId()) { $newsReader->witness($Viewer); @@ -29,7 +33,7 @@ if (!$contest) { $leaderboard = []; } else { $leaderboard = array_slice($leaderboard, 0, 3); - $userMan = new Gazelle\Manager\User(); + $userMan = new Manager\User(); foreach ($leaderboard as &$entry) { $entry['username'] = $userMan->findById($entry['user_id'])->username(); } @@ -40,17 +44,17 @@ if (!$contest) { } echo $Twig->render('index/private-sidebar.twig', [ - 'blog' => new Gazelle\Manager\Blog(), - 'collage_count' => (new Gazelle\Stats\Collage())->collageTotal(), + 'blog' => new Manager\Blog(), + 'collage_count' => (new Stats\Collage())->collageTotal(), 'contest_rank' => $contestRank, 'leaderboard' => $leaderboard, 'aotm' => $featured->findByType(FeaturedAlbumType::AlbumOfTheMonth), 'showcase' => $featured->findByType(FeaturedAlbumType::Showcase), - 'staff_blog' => new Gazelle\Manager\StaffBlog(), - 'poll' => (new Gazelle\Manager\ForumPoll())->findByFeaturedPoll(), - 'request_stats' => new Gazelle\Stats\Request(), - 'torrent_stats' => new Gazelle\Stats\Torrent(), - 'user_stats' => new Gazelle\Stats\Users(), + 'staff_blog' => new Manager\StaffBlog(), + 'poll' => (new Manager\ForumPoll())->findByFeaturedPoll(), + 'request_stats' => new Stats\Request(), + 'torrent_stats' => new Stats\Torrent(), + 'user_stats' => new Stats\Users(), 'viewer' => $Viewer, ]); diff --git a/sections/index/public.php b/sections/index/public.php index 54dee6d68..a2fa67201 100644 --- a/sections/index/public.php +++ b/sections/index/public.php @@ -1,10 +1,14 @@ render('index/public.twig', [ - 'new' => (new Gazelle\Stats\Users())->enabledUserTotal() == 0, + 'new' => (new Stats\Users())->enabledUserTotal() == 0, ]); diff --git a/sections/locked/index.php b/sections/locked/index.php index 67b5fa727..1c0fab0fe 100644 --- a/sections/locked/index.php +++ b/sections/locked/index.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('users_mod') && !$Viewer->isLocked()) { header('Location: /'); exit; diff --git a/sections/log/index.php b/sections/log/index.php index c0fad8c8a..e2ef9e5b2 100644 --- a/sections/log/index.php +++ b/sections/log/index.php @@ -1,14 +1,19 @@ permitted('site_search_many')) { $page = min($page, (int)(MAX_LOG_DEPTH / LOG_ENTRIES_PER_PAGE)); } $search = $_GET['search'] ?? ''; -$paginator = new Gazelle\Util\Paginator(LOG_ENTRIES_PER_PAGE, $page); +$paginator = new Util\Paginator(LOG_ENTRIES_PER_PAGE, $page); $paginator->setTotal($siteLog->total($search)); echo $Twig->render('sitelog.twig', [ diff --git a/sections/logchecker/index.php b/sections/logchecker/index.php index 7cf13ef9f..d4b112c06 100644 --- a/sections/logchecker/index.php +++ b/sections/logchecker/index.php @@ -1,5 +1,9 @@ 'update.php', 'upload' => 'upload.php', diff --git a/sections/logchecker/test.php b/sections/logchecker/test.php index 9c8594f7a..f6b5f7a86 100644 --- a/sections/logchecker/test.php +++ b/sections/logchecker/test.php @@ -1,6 +1,10 @@ render('logchecker/test.twig', [ diff --git a/sections/logchecker/test_handle.php b/sections/logchecker/test_handle.php index e07cdf8b7..b55f6d912 100644 --- a/sections/logchecker/test_handle.php +++ b/sections/logchecker/test_handle.php @@ -1,6 +1,10 @@ render('logchecker/update.twig', [ - 'accepted' => OrpheusNET\Logchecker\Logchecker::getAcceptValues(), - 'list' => (new Gazelle\Manager\Torrent())->logFileList($Viewer->id()), + 'accepted' => \OrpheusNET\Logchecker\Logchecker::getAcceptValues(), + 'list' => (new Manager\Torrent())->logFileList($Viewer->id()), ]); diff --git a/sections/logchecker/upload.php b/sections/logchecker/upload.php index 6fdefc037..514c6b7fa 100644 --- a/sections/logchecker/upload.php +++ b/sections/logchecker/upload.php @@ -2,9 +2,13 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use OrpheusNET\Logchecker\Logchecker; echo $Twig->render('logchecker/upload.twig', [ 'accepted' => Logchecker::getAcceptValues(), - 'list' => (new Gazelle\Manager\Torrent())->setViewer($Viewer)->missingLogfiles($Viewer->id()), + 'list' => (new Manager\Torrent())->setViewer($Viewer)->missingLogfiles($Viewer->id()), ]); diff --git a/sections/logchecker/upload_handle.php b/sections/logchecker/upload_handle.php index a0f35ad4d..6bb62ff48 100644 --- a/sections/logchecker/upload_handle.php +++ b/sections/logchecker/upload_handle.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use OrpheusNET\Logchecker\Logchecker; ini_set('upload_max_filesize', 1_000_000); -$torrent = (new Gazelle\Manager\Torrent())->findById((int)$_POST['torrentid']); +$torrent = (new Manager\Torrent())->findById((int)$_POST['torrentid']); if (is_null($torrent)) { error('No torrent is selected.'); } @@ -18,18 +22,18 @@ if ($torrent->uploaderId() != $Viewer->id() && !$Viewer->permitted('admin_add_lo } $action = in_array($_POST['from_action'], ['upload', 'update']) ? $_POST['from_action'] : 'upload'; -$logfileSummary = new Gazelle\LogfileSummary($_FILES['logfiles']); +$logfileSummary = new LogfileSummary($_FILES['logfiles']); if (!$logfileSummary->total()) { error("No logfiles uploaded."); } else { - $ripFiler = new Gazelle\File\RipLog(); - $htmlFiler = new Gazelle\File\RipLogHTML(); + $ripFiler = new File\RipLog(); + $htmlFiler = new File\RipLogHTML(); $torrent->removeLogDb(); $ripFiler->remove([$torrent->id(), null]); $htmlFiler->remove([$torrent->id(), null]); - $torrentLogManager = new Gazelle\Manager\TorrentLog($ripFiler, $htmlFiler); + $torrentLogManager = new Manager\TorrentLog($ripFiler, $htmlFiler); $checkerVersion = Logchecker::getLogcheckerVersion(); foreach ($logfileSummary->all() as $logfile) { diff --git a/sections/login/disabled.php b/sections/login/disabled.php index 94376fdae..728b83d57 100644 --- a/sections/login/disabled.php +++ b/sections/login/disabled.php @@ -1,11 +1,15 @@ findByUsername(trim($_POST['username'])); + $user = (new Manager\User())->findByUsername(trim($_POST['username'])); if ($user) { - $enabler = (new Gazelle\Manager\AutoEnable())->create($user, $_POST['email']); + $enabler = (new Manager\AutoEnable())->create($user, $_POST['email']); if ($enabler) { setcookie('username', '', [ 'expires' => time() + 60 * 60, diff --git a/sections/login/index.php b/sections/login/index.php index 150b1ea52..ce11071f1 100644 --- a/sections/login/index.php +++ b/sections/login/index.php @@ -1,5 +1,9 @@ 'disabled.php', 'recover' => isset($_REQUEST['key']) ? 'recover_step2.php' : 'recover_step1.php', diff --git a/sections/login/login.php b/sections/login/login.php index 8c0ed6f61..fc9448b6c 100644 --- a/sections/login/login.php +++ b/sections/login/login.php @@ -2,13 +2,17 @@ /** @phpstan-var ?\Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (isset($Viewer)) { header("Location: /index.php"); exit; } -$login = new Gazelle\Login(); -$watch = new Gazelle\LoginWatch($login->requestContext()->remoteAddr()); +$login = new Login(); +$watch = new LoginWatch($login->requestContext()->remoteAddr()); if (!empty($_POST['username']) && !empty($_POST['password'])) { $user = $login->login( @@ -16,7 +20,7 @@ if (!empty($_POST['username']) && !empty($_POST['password'])) { password: $_POST['password'], watch: $watch, twofa: $_POST['twofa'] ?? '', - persistent: $_POST['keeplogged'] ?? false, + persistent: isset($_POST['keeplogged']), ); if ($user) { @@ -35,14 +39,14 @@ if (!empty($_POST['username']) && !empty($_POST['password'])) { } if ($user->isEnabled()) { - if (!\Gazelle\Util\PasswordCheck::checkPasswordStrength($_POST['password'], $user)) { + if (!Util\PasswordCheck::checkPasswordStrength($_POST['password'], $user)) { $user->addStaffNote("login prevented because of weak/compromised password")->modify(); $user->logoutEverywhere(); echo $Twig->render('login/weak-password.twig'); exit; } $useragent = $_SERVER['HTTP_USER_AGENT'] ?? '[no-useragent]'; - $context = new Gazelle\BaseRequestContext( + $context = new BaseRequestContext( $_SERVER['SCRIPT_NAME'], $_SERVER['REMOTE_ADDR'], $useragent, @@ -50,7 +54,7 @@ if (!empty($_POST['username']) && !empty($_POST['password'])) { if ($user->permitted('site_disable_ip_history')) { $context->anonymize(); } - $session = new Gazelle\User\Session($user); + $session = new User\Session($user); $current = $session->create([ 'keep-logged' => $login->persistent() ? '1' : '0', 'browser' => $context->ua(), @@ -74,7 +78,7 @@ echo $Twig->render('login/login.twig', [ 'delta' => $watch->bannedEpoch() - time(), 'error' => $login->error(), 'ip_addr' => $login->requestContext()->remoteAddr(), - 'tor_node' => (new Gazelle\Manager\Tor())->isExitNode( + 'tor_node' => (new Manager\Tor())->isExitNode( $login->requestContext()->remoteAddr() ), 'watch' => $watch, diff --git a/sections/login/recover_step1.php b/sections/login/recover_step1.php index 215c4c0d7..23653c877 100644 --- a/sections/login/recover_step1.php +++ b/sections/login/recover_step1.php @@ -1,7 +1,11 @@ setField('email', true, 'email', 'You entered an invalid email address.'); $error = false; @@ -12,9 +16,9 @@ if (isset($_REQUEST['expired'])) { $error = $validator->validate($_REQUEST) ? false : $validator->errorMessage(); if (!$error) { $sent = true; - $user = (new Gazelle\Manager\User())->findByEmail(trim($_REQUEST['email'])); + $user = (new Manager\User())->findByEmail(trim($_REQUEST['email'])); if ($user?->isEnabled()) { - (new Gazelle\Manager\UserToken())->createPasswordResetToken($user); + (new Manager\UserToken())->createPasswordResetToken($user); } } } diff --git a/sections/login/recover_step2.php b/sections/login/recover_step2.php index c4f4de600..f2d9060c9 100644 --- a/sections/login/recover_step2.php +++ b/sections/login/recover_step2.php @@ -1,20 +1,24 @@ findByToken($_GET['key']); +$userToken = (new Manager\UserToken())->findByToken($_GET['key']); if ($userToken?->type() != UserTokenType::password) { header('Location: login.php?action=recover'); exit; } -$validator = new Gazelle\Util\Validator(); +$validator = new Util\Validator(); $validator->setFields([ ['verifypassword', true, 'compare', 'Your passwords did not match.', ['comparefield' => 'password']], ['password', true, 'regex', 'You entered an invalid password. A strong password is 8 characters or longer, contains at least 1 lowercase and uppercase letter, and contains at least a number or symbol, or is 20 characters or longer', - ['regex' => \Gazelle\Util\PasswordCheck::REGEXP] + ['regex' => Util\PasswordCheck::REGEXP] ], ]); @@ -23,8 +27,8 @@ $success = false; if (!empty($_REQUEST['password'])) { if (!$validator->validate($_REQUEST)) { $error = $validator->errorMessage(); - } elseif (!\Gazelle\Util\PasswordCheck::checkPasswordStrength($_REQUEST['password'], $userToken->user())) { - $error = \Gazelle\Util\PasswordCheck::ERROR_MSG; + } elseif (!Util\PasswordCheck::checkPasswordStrength($_REQUEST['password'], $userToken->user())) { + $error = Util\PasswordCheck::ERROR_MSG; } else { // Form validates without error, try and use the token if (!$userToken->consume()) { diff --git a/sections/logout/index.php b/sections/logout/index.php index a8fc51524..7882d5145 100644 --- a/sections/logout/index.php +++ b/sections/logout/index.php @@ -1,6 +1,10 @@ logout(); header("Location: /index.php"); diff --git a/sections/random/index.php b/sections/random/index.php index 909df7ab9..55070fc2e 100644 --- a/sections/random/index.php +++ b/sections/random/index.php @@ -1,9 +1,13 @@ (new Gazelle\Manager\Artist())->findRandom(), - 'collage' => (new Gazelle\Manager\Collage())->findRandom(), - default => (new Gazelle\Manager\TGroup())->findRandom(), + 'artist' => (new Manager\Artist())->findRandom(), + 'collage' => (new Manager\Collage())->findRandom(), + default => (new Manager\TGroup())->findRandom(), }; if (is_null($object)) { error(404); /* only likely to happen on a brand new installation */ diff --git a/sections/recovery/admin.php b/sections/recovery/admin.php index 890dbc64b..bb13e63a3 100644 --- a/sections/recovery/admin.php +++ b/sections/recovery/admin.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_recovery')) { error(403); } -$recovery = new Gazelle\Manager\Recovery(); +$recovery = new Manager\Recovery(); if (isset($_GET['task'])) { $id = (int)($_GET['id'] ?? 0); if ($id) { @@ -40,7 +44,7 @@ if (isset($_GET['task'])) { } $state = $_GET['state'] ?? 'pending'; -$paginator = new Gazelle\Util\Paginator(ITEMS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(ITEMS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($recovery->total($state, $Viewer->id())); echo $Twig->render('recovery/admin.twig', [ diff --git a/sections/recovery/browse.php b/sections/recovery/browse.php index 1ddae5a12..59a766c26 100644 --- a/sections/recovery/browse.php +++ b/sections/recovery/browse.php @@ -2,10 +2,14 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_recovery')) { error(403); } -$recovery = new Gazelle\Manager\Recovery(); +$recovery = new Manager\Recovery(); if (isset($_POST['username']) && strlen($_POST['username'])) { $class = 'username'; diff --git a/sections/recovery/index.php b/sections/recovery/index.php index 065b1d115..0a6773926 100644 --- a/sections/recovery/index.php +++ b/sections/recovery/index.php @@ -1,5 +1,9 @@ 'admin.php', 'browse' => 'browse.php', diff --git a/sections/recovery/pair.php b/sections/recovery/pair.php index 3407a0fa3..7feecb407 100644 --- a/sections/recovery/pair.php +++ b/sections/recovery/pair.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_recovery')) { error(403); } @@ -12,11 +16,11 @@ $currId = false; $result = false; $confirm = false; $message = false; -$recovery = new Gazelle\Manager\Recovery(); +$recovery = new Manager\Recovery(); if (isset($_POST['curr']) && isset($_POST['prev'])) { authorize(); - $userMan = new Gazelle\Manager\User(); + $userMan = new Manager\User(); $currId = (int)trim($_POST['curr']); $curr = $userMan->findById($currId); if (is_null($curr)) { diff --git a/sections/recovery/recover.php b/sections/recovery/recover.php index 20bb2ed3a..9293ad02c 100644 --- a/sections/recovery/recover.php +++ b/sections/recovery/recover.php @@ -2,6 +2,10 @@ /** @phpstan-var ?\Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (isset($Viewer)) { header("Location: index.php"); exit; diff --git a/sections/recovery/save.php b/sections/recovery/save.php index 45c9687fd..99abb94e9 100644 --- a/sections/recovery/save.php +++ b/sections/recovery/save.php @@ -1,6 +1,10 @@ permitted('admin_recovery')) { error(403); } -$recovery = new Gazelle\Manager\Recovery(); +$recovery = new Manager\Recovery(); if (isset($_GET['id']) && (int)$_GET['id'] > 0) { $id = (int)$_GET['id']; diff --git a/sections/referral/index.php b/sections/referral/index.php index 68ea5ed67..3ece1c3bf 100644 --- a/sections/referral/index.php +++ b/sections/referral/index.php @@ -3,6 +3,10 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + if ($Viewer) { header("Location: index.php"); exit; @@ -18,21 +22,21 @@ if (session_status() === PHP_SESSION_NONE) { getActiveAccounts(); if (!OPEN_EXTERNAL_REFERRALS || !count($Accounts) || $ReferralManager->readOnly) { - View::show_header("Referrals are closed"); + \View::show_header("Referrals are closed"); ?>
Sorry, is currently not accepting referrals.

@@ -153,4 +157,4 @@ View::show_header('External Tracker Referrals'); findByToken($_REQUEST['confirm']); + $token = (new Manager\UserToken())->findByToken($_REQUEST['confirm']); if (!$token || $token->type() != UserTokenType::confirm || !$token->consume()) { // we have no token, or not of the right type, or not consumable (expired) echo $Twig->render('register/expired.twig'); @@ -19,20 +23,20 @@ if (isset($_REQUEST['confirm'])) { $Twig->render('register/welcome.bbcode.twig', ['user' => $user]) ); echo $Twig->render('register/complete.twig'); - (new Gazelle\Tracker())->addUser($user); -} elseif (OPEN_REGISTRATION || isset($_REQUEST['invite']) || (new Gazelle\Stats\Users())->enabledUserTotal() == 0) { + (new Tracker())->addUser($user); +} elseif (OPEN_REGISTRATION || isset($_REQUEST['invite']) || (new Stats\Users())->enabledUserTotal() == 0) { if ($_REQUEST['invite']) { - if (!(new Gazelle\Manager\Invite())->inviteExists($_GET['invite'])) { + if (!(new Manager\Invite())->inviteExists($_REQUEST['invite'])) { echo $Twig->render('register/no-invite.twig'); exit; } } - $validator = new Gazelle\Util\Validator(); + $validator = new Util\Validator(); $validator->setFields([ ['username', true, 'regex', 'You did not enter a valid username.', ['regex' => USERNAME_REGEXP]], ['email', true, 'email', 'You did not enter a valid email address.'], - ['password', true, 'regex', 'A strong password is 8 characters or longer, contains at least 1 lowercase and uppercase letter, and contains at least a number or symbol, or is 20 characters or longer', ['regex' => \Gazelle\Util\PasswordCheck::REGEXP]], + ['password', true, 'regex', 'A strong password is 8 characters or longer, contains at least 1 lowercase and uppercase letter, and contains at least a number or symbol, or is 20 characters or longer', ['regex' => Util\PasswordCheck::REGEXP]], ['confirm_password', true, 'compare', 'Your passwords do not match.', ['comparefield' => 'password']], ['readrules', true, 'checkbox', 'You did not select the box that says you will read the rules.'], ['readwiki', true, 'checkbox', 'You did not select the box that says you will read the wiki.'], @@ -50,12 +54,12 @@ if (isset($_REQUEST['confirm'])) { $username = trim($_POST['username']); $email = trim($_POST['email']); - if (!\Gazelle\Util\PasswordCheck::checkPasswordStrengthNoUser($_POST['password'], $username, $email)) { - $error = \Gazelle\Util\PasswordCheck::ERROR_MSG; + if (!Util\PasswordCheck::checkPasswordStrengthNoUser($_POST['password'], $username, $email)) { + $error = Util\PasswordCheck::ERROR_MSG; break; } - $creator = new Gazelle\UserCreator(); + $creator = new UserCreator(); $creator->setUsername($username) ->setEmail($email) ->setPassword($_POST['password']); @@ -70,15 +74,15 @@ if (isset($_REQUEST['confirm'])) { header("Location: /login.php"); exit; } - (new Gazelle\Util\Mail())->send($user->email(), 'New account confirmation at ' . SITE_NAME, + (new Util\Mail())->send($user->email(), 'New account confirmation at ' . SITE_NAME, $Twig->render('email/registration.twig', [ 'ipaddr' => $user->requestContext()->remoteAddr(), 'user' => $user, - 'token' => (new \Gazelle\Manager\UserToken())->create(UserTokenType::confirm, $user), + 'token' => (new Manager\UserToken())->create(UserTokenType::confirm, $user), ]) ); $emailSent = true; - } catch (Gazelle\Exception\UserCreatorException $e) { + } catch (Exception\UserCreatorException $e) { switch ($e->getMessage()) { case 'duplicate': $error = 'Someone already took that username :-('; @@ -116,9 +120,9 @@ if (isset($_REQUEST['confirm'])) { 'is_new' => $newInstall ?? false, 'username' => $_REQUEST['username'] ?? '', 'email' => $_REQUEST['email'] ?? '', - 'readrules' => $_REQUEST['readrules'] ?? false, - 'readwiki' => $_REQUEST['readwiki'] ?? false, - 'agereq' => $_REQUEST['agereq'] ?? false, + 'readrules' => isset($_REQUEST['readrules']), + 'readwiki' => isset($_REQUEST['readwiki']), + 'agereq' => isset($_REQUEST['agereq']), ]); } else { echo $Twig->render(isset($_GET['welcome']) diff --git a/sections/report_auto/index.php b/sections/report_auto/index.php index caec96a24..0f5bca614 100644 --- a/sections/report_auto/index.php +++ b/sections/report_auto/index.php @@ -1,5 +1,9 @@ permitted('users_auto_reports')) { error(403); } -$userMan = new Gazelle\Manager\User(); -$ratMan = new Gazelle\Manager\ReportAutoType(); -$search = new Gazelle\Search\ReportAuto(new Gazelle\Manager\ReportAuto($ratMan), $ratMan); +$userMan = new Manager\User(); +$ratMan = new Manager\ReportAutoType(); +$search = new Search\ReportAuto(new Manager\ReportAuto($ratMan), $ratMan); $isOld = isset($_GET['view']) && $_GET['view'] === 'old'; if (isset($_GET['id'])) { $search->setId((int)$_GET['id']); } elseif (empty($_GET['view'])) { - $search->setState(\Gazelle\Enum\ReportAutoState::open); + $search->setState(Enum\ReportAutoState::open); } elseif ($isOld) { - $search->setState(\Gazelle\Enum\ReportAutoState::closed); + $search->setState(Enum\ReportAutoState::closed); } else { error(404); } @@ -46,7 +50,7 @@ if (isset($_GET['type'])) { $search->setType($type); } -$paginator = new Gazelle\Util\Paginator(REPORTS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(REPORTS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($search->total()); $requestUri = (string)$_SERVER['REQUEST_URI']; diff --git a/sections/report_auto/reports_handle.php b/sections/report_auto/reports_handle.php index d9b96a747..34e4f275c 100644 --- a/sections/report_auto/reports_handle.php +++ b/sections/report_auto/reports_handle.php @@ -1,6 +1,10 @@ permitted('users_auto_reports')) { diff --git a/sections/reports/ajax_add_notes.php b/sections/reports/ajax_add_notes.php index e3b1350b0..c821cc600 100644 --- a/sections/reports/ajax_add_notes.php +++ b/sections/reports/ajax_add_notes.php @@ -1,10 +1,14 @@ permitted('site_moderate_forums')) { json_error('forbidden'); } -$report = (new Gazelle\Manager\Report(new Gazelle\Manager\User()))->findById((int)($_POST['id'] ?? 0)); +$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['id'] ?? 0)); if (is_null($report)) { json_error('bad post id'); } diff --git a/sections/reports/ajax_claim_report.php b/sections/reports/ajax_claim_report.php index d3c4ffc40..6336dd18b 100644 --- a/sections/reports/ajax_claim_report.php +++ b/sections/reports/ajax_claim_report.php @@ -1,11 +1,15 @@ permittedAny('admin_reports', 'site_moderate_forums')) { json_error('bad parameters'); } -$report = (new Gazelle\Manager\Report(new Gazelle\Manager\User()))->findById((int)($_POST['id'] ?? 0)); +$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['id'] ?? 0)); if (is_null($report)) { json_error('no report id'); } diff --git a/sections/reports/ajax_resolve_report.php b/sections/reports/ajax_resolve_report.php index 0e7588af6..27a4bff36 100644 --- a/sections/reports/ajax_resolve_report.php +++ b/sections/reports/ajax_resolve_report.php @@ -1,12 +1,16 @@ permittedAny('admin_reports', 'site_moderate_forums')) { json_error('forbidden'); } authorize(); -$report = (new Gazelle\Manager\Report(new Gazelle\Manager\User()))->findById((int)($_POST['reportid'] ?? 0)); +$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['reportid'] ?? 0)); if (is_null($report)) { json_error('no report id'); } diff --git a/sections/reports/ajax_unclaim_report.php b/sections/reports/ajax_unclaim_report.php index a560af166..99302af0e 100644 --- a/sections/reports/ajax_unclaim_report.php +++ b/sections/reports/ajax_unclaim_report.php @@ -1,11 +1,15 @@ permitted('site_moderate_forums') || empty($_POST['remove'])) { json_error('bad parameters'); } -$report = (new Gazelle\Manager\Report(new Gazelle\Manager\User()))->findById((int)($_POST['id'] ?? 0)); +$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['id'] ?? 0)); if (is_null($report)) { json_error('no report id'); } diff --git a/sections/reports/array.php b/sections/reports/array.php index 94a386fef..1b58e658e 100644 --- a/sections/reports/array.php +++ b/sections/reports/array.php @@ -1,5 +1,9 @@ permitted('site_moderate_forums')) { error(403); } @@ -19,7 +23,7 @@ $reportType = $Types[$type]; $user = null; if (!isset($Return)) { - $user = (new Gazelle\Manager\User())->findById((int)($_GET['toid'] ?? 0)); + $user = (new Manager\User())->findById((int)($_GET['toid'] ?? 0)); if (is_null($user)) { error(404); } @@ -30,58 +34,58 @@ if (!isset($Return)) { switch ($type) { case 'user': - $reported = (new Gazelle\Manager\User())->findById($id); + $reported = (new Manager\User())->findById($id); if (is_null($reported)) { error(404); } - $report = new Gazelle\Report\User($reportId, $reported); + $report = new Report\User($reportId, $reported); break; case 'request': case 'request_update': - $request = (new Gazelle\Manager\Request())->findById($id); + $request = (new Manager\Request())->findById($id); if (is_null($request)) { error(404); } - $report = new Gazelle\Report\Request($reportId, $request); + $report = new Report\Request($reportId, $request); break; case 'collage': - $collage = (new Gazelle\Manager\Collage())->findById($id); + $collage = (new Manager\Collage())->findById($id); if (is_null($collage)) { error(404); } - $report = new Gazelle\Report\Collage($reportId, $collage); + $report = new Report\Collage($reportId, $collage); break; case 'thread': - $thread = (new Gazelle\Manager\ForumThread())->findById($id); + $thread = (new Manager\ForumThread())->findById($id); if (is_null($thread)) { error(404); } if (!$Viewer->readAccess($thread->forum())) { error(403); } - $report = new Gazelle\Report\ForumThread($reportId, $thread); + $report = new Report\ForumThread($reportId, $thread); break; case 'post': - $post = (new Gazelle\Manager\ForumPost())->findById($id); + $post = (new Manager\ForumPost())->findById($id); if (is_null($post)) { error(404); } if (!$Viewer->readAccess($post->thread()->forum())) { error(403); } - $report = new Gazelle\Report\ForumPost($reportId, $post); + $report = new Report\ForumPost($reportId, $post); break; case 'comment': - $comment = (new Gazelle\Manager\Comment())->findById($id); + $comment = (new Manager\Comment())->findById($id); if (is_null($comment)) { error(404); } - $report = (new Gazelle\Report\Comment($reportId, $comment))->setContext($reportType['title']); + $report = (new Report\Comment($reportId, $comment))->setContext($reportType['title']); break; default: @@ -92,7 +96,7 @@ echo $Twig->render('report/compose-reply.twig', [ 'report' => $report, 'user' => $user, 'viewer' => $Viewer, - 'body' => new Gazelle\Util\Textarea( + 'body' => new Util\Textarea( 'body', "You reported {$report->bbLink()} for the reason:\n[quote]{$report->reason()}[/quote]", 90, 8 diff --git a/sections/reports/compose_handle.php b/sections/reports/compose_handle.php index 4d9f27b6f..049430f83 100644 --- a/sections/reports/compose_handle.php +++ b/sections/reports/compose_handle.php @@ -1,9 +1,13 @@ findById((int)($_POST['toid'] ?? 0)); if (is_null($recipient)) { error("No such recipient!"); diff --git a/sections/reports/index.php b/sections/reports/index.php index 1192ac359..004524bbd 100644 --- a/sections/reports/index.php +++ b/sections/reports/index.php @@ -1,5 +1,9 @@ 'ajax_add_notes.php', 'claim' => 'ajax_claim_report.php', diff --git a/sections/reports/report.php b/sections/reports/report.php index 75f680418..99abbe95f 100644 --- a/sections/reports/report.php +++ b/sections/reports/report.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + $id = (int)$_GET['id']; if (!$id) { error(404); @@ -16,68 +20,68 @@ $reportType = $Types[$type]; switch ($type) { case 'user': - $user = (new Gazelle\Manager\User())->findById($id); + $user = (new Manager\User())->findById($id); if (is_null($user)) { error(404); } - $report = new Gazelle\Report\User($id, $user); + $report = new Report\User($id, $user); break; case 'request': - $request = (new Gazelle\Manager\Request())->findById($id); + $request = (new Manager\Request())->findById($id); if (is_null($request)) { error(404); } - $report = new Gazelle\Report\Request($id, $request); + $report = new Report\Request($id, $request); break; case 'request_update': - $request = (new Gazelle\Manager\Request())->findById($id); + $request = (new Manager\Request())->findById($id); if (is_null($request)) { error(404); } if ($request->isFilled() || $request->categoryName() != 'Music' || $request->year() != 0) { error(403); } - $report = (new Gazelle\Report\Request($id, $request))->isUpdate(true); + $report = (new Report\Request($id, $request))->isUpdate(true); break; case 'collage': - $collage = (new Gazelle\Manager\Collage())->findById($id); + $collage = (new Manager\Collage())->findById($id); if (is_null($collage)) { error(404); } - $report = new Gazelle\Report\Collage($id, $collage); + $report = new Report\Collage($id, $collage); break; case 'thread': - $thread = (new Gazelle\Manager\ForumThread())->findById($id); + $thread = (new Manager\ForumThread())->findById($id); if (is_null($thread)) { error(404); } if (!$Viewer->readAccess($thread->forum())) { error(403); } - $report = new Gazelle\Report\ForumThread($id, $thread); + $report = new Report\ForumThread($id, $thread); break; case 'post': - $post = (new Gazelle\Manager\ForumPost())->findById($id); + $post = (new Manager\ForumPost())->findById($id); if (is_null($post)) { error(404); } if (!$Viewer->readAccess($post->thread()->forum())) { error(403); } - $report = new Gazelle\Report\ForumPost($id, $post); + $report = new Report\ForumPost($id, $post); break; case 'comment': - $comment = (new Gazelle\Manager\Comment())->findById($id); + $comment = (new Manager\Comment())->findById($id); if (is_null($comment)) { error(404); } - $report = (new Gazelle\Report\Comment($id, $comment))->setContext($reportType['title']); + $report = (new Report\Comment($id, $comment))->setContext($reportType['title']); break; default: error('Unknown report target'); @@ -85,7 +89,7 @@ switch ($type) { echo $Twig->render('report/create.twig', [ 'id' => $id, - 'release' => (new Gazelle\ReleaseType())->list(), + 'release' => (new ReleaseType())->list(), 'report' => $report, 'report_type' => $reportType, 'type' => $type, diff --git a/sections/reports/report_handle.php b/sections/reports/report_handle.php index 468d9bf65..61d882c8f 100644 --- a/sections/reports/report_handle.php +++ b/sections/reports/report_handle.php @@ -1,6 +1,10 @@ findNameById($_POST['releasetype'])) . " . \n\n"; + ? 'Not given' : (new ReleaseType())->findNameById((int)$_POST['releasetype'])) . " . \n\n"; $reason .= '[b]Additional comments[/b]: ' . $_POST['comment']; } $location = match ($subjectType) { 'collage' => "collages.php?id=$subjectId", 'comment' => "comments.php?action=jump&postid=$subjectId", - 'post' => (new Gazelle\Manager\ForumPost())->findById($subjectId)?->location(), // could be null + 'post' => (new Manager\ForumPost())->findById($subjectId)?->location(), // could be null 'request', 'request_update' => "requests.php?action=view&id=$subjectId", 'thread' => "forums.php?action=viewthread&threadid=$subjectId", @@ -45,7 +49,7 @@ if (is_null($location)) { error("Cannot generate a link to the reported item"); } -$report = (new Gazelle\Manager\Report(new Gazelle\Manager\User()))->create($Viewer, $subjectId, $subjectType, $reason); +$report = (new Manager\Report(new Manager\User()))->create($Viewer, $subjectId, $subjectType, $reason); if (in_array($report->subjectType(), ['user', 'comment'])) { Irc::sendMessage( IRC_CHAN_MOD, diff --git a/sections/reports/reports.php b/sections/reports/reports.php index 5fbcf90df..f6c731a65 100644 --- a/sections/reports/reports.php +++ b/sections/reports/reports.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Enum\SearchReportOrder; if (!$Viewer->permittedAny('admin_reports', 'site_moderate_forums')) { @@ -10,8 +14,8 @@ if (!$Viewer->permittedAny('admin_reports', 'site_moderate_forums')) { require_once 'array.php'; -$search = new Gazelle\Search\Report(); -$paginator = new Gazelle\Util\Paginator(REPORTS_PER_PAGE, (int)($_REQUEST['page'] ?? 1)); +$search = new Search\Report(); +$paginator = new Util\Paginator(REPORTS_PER_PAGE, (int)($_REQUEST['page'] ?? 1)); $typeList = ['collage', 'comment', 'post', 'request', 'thread', 'user']; if (!$Viewer->permitted('admin_reports')) { @@ -60,13 +64,13 @@ if (isset($_REQUEST['id'])) { $paginator->setTotal($search->total()); echo $Twig->render('report/index.twig', [ - 'list' => (new Gazelle\Manager\Report(new Gazelle\Manager\User()))->decorate( + 'list' => (new Manager\Report(new Manager\User()))->decorate( $search->page($paginator->limit(), $paginator->offset()), - new Gazelle\Manager\Collage(), - new Gazelle\Manager\Comment(), - new Gazelle\Manager\ForumThread(), - new Gazelle\Manager\ForumPost(), - new Gazelle\Manager\Request(), + new Manager\Collage(), + new Manager\Comment(), + new Manager\ForumThread(), + new Manager\ForumPost(), + new Manager\Request(), ), 'paginator' => $paginator, 'type' => $Types, diff --git a/sections/reports/resolve_handle.php b/sections/reports/resolve_handle.php index 3bf0505f5..cf75777c9 100644 --- a/sections/reports/resolve_handle.php +++ b/sections/reports/resolve_handle.php @@ -1,12 +1,16 @@ permittedAny('admin_reports', 'site_moderate_forums')) { error(403); } authorize(); -$report = (new Gazelle\Manager\Report(new Gazelle\Manager\User()))->findById((int)($_POST['id'] ?? 0)); +$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['id'] ?? 0)); if (is_null($report)) { json_error('no report id'); } diff --git a/sections/reports/stats.php b/sections/reports/stats.php index a368fc5b1..576dd2358 100644 --- a/sections/reports/stats.php +++ b/sections/reports/stats.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permittedAny('admin_reports', 'site_moderate_forums')) { error(403); } echo $Twig->render('report/stats.twig', [ - 'stats' => new Gazelle\Stats\Report(), + 'stats' => new Stats\Report(), 'viewer' => $Viewer, ]); diff --git a/sections/reportsv2/ajax_claim.php b/sections/reportsv2/ajax_claim.php index 1db3a2848..408f636cc 100644 --- a/sections/reportsv2/ajax_claim.php +++ b/sections/reportsv2/ajax_claim.php @@ -1,10 +1,14 @@ permitted('admin_reports')) { error(403); } -echo (new Gazelle\Manager\Torrent\Report(new Gazelle\Manager\Torrent())) +echo (new Manager\Torrent\Report(new Manager\Torrent())) ->findById((int)($_GET['id'] ?? 0)) ?->claim($Viewer) ?? 0; diff --git a/sections/reportsv2/ajax_get_resolve_options.php b/sections/reportsv2/ajax_get_resolve_options.php index 7771f1902..cc7b9f59f 100644 --- a/sections/reportsv2/ajax_get_resolve_options.php +++ b/sections/reportsv2/ajax_get_resolve_options.php @@ -1,6 +1,10 @@ permitted('admin_reports')) { json_error("forbidden"); } -$reportType = (new Gazelle\Manager\Torrent\ReportType())->findByType($_GET['type'] ?? ''); +$reportType = (new Manager\Torrent\ReportType())->findByType($_GET['type'] ?? ''); if (is_null($reportType)) { json_error("bad type"); } diff --git a/sections/reportsv2/ajax_new_report.php b/sections/reportsv2/ajax_new_report.php index ee8f867eb..f669a8bb4 100644 --- a/sections/reportsv2/ajax_new_report.php +++ b/sections/reportsv2/ajax_new_report.php @@ -4,6 +4,10 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + /* * This is the AJAX page that gets called from the JavaScript * function NewReport(), any changes here should probably be @@ -14,9 +18,10 @@ if (!$Viewer->permitted('admin_reports')) { error(403); } -$torMan = new Gazelle\Manager\Torrent(); -$reportMan = new Gazelle\Manager\Torrent\Report($torMan); -$report = $reportMan->findNewest(); +$torMan = new Manager\Torrent(); +$reportMan = new Manager\Torrent\Report($torMan); + +$report = $reportMan->findNewest(); if (is_null($report->torrent())) { echo $Twig->render('reportsv2/deleted.twig', [ 'report' => $report, @@ -27,10 +32,10 @@ if (is_null($report->torrent())) { $report->claim($Viewer); echo $Twig->render('reportsv2/new.twig', [ - 'category_list' => (new Gazelle\Manager\Torrent\ReportType()) + 'category_list' => (new Manager\Torrent\ReportType()) ->categoryList($report->reportType()->categoryId()), 'report' => $report, - 'request_list' => (new Gazelle\Manager\Request())->findByTorrentReported($report->torrent()), + 'request_list' => (new Manager\Request())->findByTorrentReported($report->torrent()), 'size' => '(' . number_format($report->torrent()->size() / (1024 * 1024), 2) . ' MiB)', 'torrent' => $report->torrent(), 'other' => [ diff --git a/sections/reportsv2/ajax_report.php b/sections/reportsv2/ajax_report.php index 050334d88..7bbecf658 100644 --- a/sections/reportsv2/ajax_report.php +++ b/sections/reportsv2/ajax_report.php @@ -2,6 +2,10 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + /* * The backend to changing the report type when making a report. * It prints out the relevant report_messages from the array, then @@ -10,13 +14,13 @@ authorize(); -$reportType = (new Gazelle\Manager\Torrent\ReportType())->findByType($_POST['type'] ?? ''); +$reportType = (new Manager\Torrent\ReportType())->findByType($_POST['type'] ?? ''); if (is_null($reportType)) { json_error("bad parameters"); } ?>
    -
  • explanation()) ?>
  • +
  • explanation()) ?>

diff --git a/sections/reportsv2/ajax_switch.php b/sections/reportsv2/ajax_switch.php index 64c816c6a..899fb3c11 100644 --- a/sections/reportsv2/ajax_switch.php +++ b/sections/reportsv2/ajax_switch.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + /* * This page is for creating a report using AJAX. * It should have the following posted fields: @@ -17,13 +21,13 @@ if (!$Viewer->permitted('admin_reports')) { } authorize(); -$torMan = new Gazelle\Manager\Torrent(); +$torMan = new Manager\Torrent(); $other = $torMan->findById((int)$_POST['otherid']); if (is_null($other)) { json_error("bad other id"); } -$reportMan = new Gazelle\Manager\Torrent\Report($torMan); +$reportMan = new Manager\Torrent\Report($torMan); if ($reportMan->existsRecent($other->id(), $Viewer->id())) { json_error("too soon"); } @@ -34,12 +38,12 @@ if (is_null($report)) { $new = $reportMan->create( torrent: $other, - user: new Gazelle\User($report->reporterId()), + user: new User($report->reporterId()), reportType: $report->reportType(), reason: $report->reason(), image: implode(' ', $report->image()), otherIdList: (string)$report->torrentId(), - irc: new Gazelle\Util\Irc(), + irc: new Util\Irc(), ); if ($other->uploaderId() != $Viewer->id()) { diff --git a/sections/reportsv2/ajax_take_pm.php b/sections/reportsv2/ajax_take_pm.php index f7972af25..36c7385b8 100644 --- a/sections/reportsv2/ajax_take_pm.php +++ b/sections/reportsv2/ajax_take_pm.php @@ -1,6 +1,10 @@ permitted('admin_reports')) { die(); } -$torrent = (new Gazelle\Manager\Torrent())->findById((int)($_POST['torrentid'] ?? 0)); +$torrent = (new Manager\Torrent())->findById((int)($_POST['torrentid'] ?? 0)); if (is_null($torrent)) { json_error("bad parameters"); } @@ -29,7 +33,7 @@ if (!isset($_POST['from_delete'])) { json_error("bad parameters from_delete"); } -$reportType = (new Gazelle\Manager\Torrent\ReportType())->findByType($_POST['resolve_type'] ?? ''); +$reportType = (new Manager\Torrent\ReportType())->findByType($_POST['resolve_type'] ?? ''); switch ($_POST['pm_type']) { case 'Uploader': @@ -50,7 +54,7 @@ switch ($_POST['pm_type']) { json_error("no recipient target"); } -$recipient = (new Gazelle\Manager\User())->findById($ToID); +$recipient = (new Manager\User())->findById($ToID); if (is_null($recipient)) { json_error("bad recipient id"); } elseif ($ToID == $Viewer->id()) { diff --git a/sections/reportsv2/ajax_unclaim.php b/sections/reportsv2/ajax_unclaim.php index ddce65547..3d761114d 100644 --- a/sections/reportsv2/ajax_unclaim.php +++ b/sections/reportsv2/ajax_unclaim.php @@ -1,10 +1,14 @@ permitted('admin_reports')) { error(403); } -(new Gazelle\Manager\Torrent\Report(new Gazelle\Manager\Torrent())) +(new Manager\Torrent\Report(new Manager\Torrent())) ->findById((int)($_GET['id'] ?? 0)) ?->unclaim(); diff --git a/sections/reportsv2/ajax_update_comment.php b/sections/reportsv2/ajax_update_comment.php index 74b91cb71..56dad5603 100644 --- a/sections/reportsv2/ajax_update_comment.php +++ b/sections/reportsv2/ajax_update_comment.php @@ -1,12 +1,16 @@ permitted('admin_reports')) { error(403); } authorize(); -(new Gazelle\Manager\Torrent\Report(new Gazelle\Manager\Torrent())) +(new Manager\Torrent\Report(new Manager\Torrent())) ->findById((int)($_POST['reportid'] ?? 0)) ?->modifyComment($_POST['comment'] ?? ''); diff --git a/sections/reportsv2/ajax_update_resolve.php b/sections/reportsv2/ajax_update_resolve.php index 8d62ccd52..064cae3e7 100644 --- a/sections/reportsv2/ajax_update_resolve.php +++ b/sections/reportsv2/ajax_update_resolve.php @@ -1,6 +1,10 @@ permitted('admin_reports')) { @@ -9,12 +13,12 @@ if (!$Viewer->permitted('admin_reports')) { authorize(); -$reportType = (new Gazelle\Manager\Torrent\ReportType())->findByType($_GET['newresolve'] ?? ''); +$reportType = (new Manager\Torrent\ReportType())->findByType($_GET['newresolve'] ?? ''); if (is_null($reportType)) { json_error("bad newresolve"); } -$report = (new Gazelle\Manager\Torrent\Report(new Gazelle\Manager\Torrent()))->findById((int)($_GET['reportid'] ?? 0)); +$report = (new Manager\Torrent\Report(new Manager\Torrent()))->findById((int)($_GET['reportid'] ?? 0)); if (is_null($report)) { json_error("bad reportid"); } diff --git a/sections/reportsv2/create.php b/sections/reportsv2/create.php index d56bdf6eb..680f84853 100644 --- a/sections/reportsv2/create.php +++ b/sections/reportsv2/create.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$torMan = (new Gazelle\Manager\Torrent())->setViewer($Viewer); +declare(strict_types=1); + +namespace Gazelle; + +$torMan = (new Manager\Torrent())->setViewer($Viewer); $id = (int)($_GET['id'] ?? 0); $torrent = $torMan->findById($id); if (is_null($torrent)) { @@ -18,11 +22,11 @@ echo $Twig->render('reportsv2/create.twig', [ 'sitelink' => $_POST['sitelink'] ?? '', 'track' => $_POST['track'] ?? '', ], - 'report_man' => new Gazelle\Manager\Torrent\Report($torMan), - 'rtype_list' => (new Gazelle\Manager\Torrent\ReportType()) + 'report_man' => new Manager\Torrent\Report($torMan), + 'rtype_list' => (new Manager\Torrent\ReportType()) ->categoryList($torrent->group()->categoryId()), 'torrent' => $torrent, 'tor_man' => $torMan, - 'url_stem' => (new Gazelle\User\Stylesheet($Viewer))->imagePath(), + 'url_stem' => (new User\Stylesheet($Viewer))->imagePath(), 'viewer' => $Viewer, ]); diff --git a/sections/reportsv2/header.php b/sections/reportsv2/header.php index 52648cad9..ba164ed2f 100644 --- a/sections/reportsv2/header.php +++ b/sections/reportsv2/header.php @@ -2,4 +2,8 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + echo $Twig->render('reportsv2/linkbox.twig', ['viewer' => $Viewer]); diff --git a/sections/reportsv2/index.php b/sections/reportsv2/index.php index 7317b6cbf..a2f5ec6af 100644 --- a/sections/reportsv2/index.php +++ b/sections/reportsv2/index.php @@ -1,5 +1,9 @@ 'ajax_claim.php', 'ajax_get_resolve_options' => 'ajax_get_resolve_options.php', diff --git a/sections/reportsv2/report_handle.php b/sections/reportsv2/report_handle.php index 940845a1b..fb16733cb 100644 --- a/sections/reportsv2/report_handle.php +++ b/sections/reportsv2/report_handle.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + /* * This page handles the backend from when a user submits a report. * It checks for (in order): @@ -15,18 +19,18 @@ authorize(); -$torMan = new Gazelle\Manager\Torrent(); +$torMan = new Manager\Torrent(); $torrent = $torMan->findById((int)($_POST['torrentid'] ?? 0)); if (is_null($torrent)) { error(404); } -$reportMan = new Gazelle\Manager\Torrent\Report($torMan); +$reportMan = new Manager\Torrent\Report($torMan); if ($reportMan->existsRecent($torrent->id(), $Viewer->id())) { error("Slow down, you're moving too fast!"); } -$reportType = (new Gazelle\Manager\Torrent\ReportType())->findByType($_POST['type'] ?? ''); +$reportType = (new Manager\Torrent\ReportType())->findByType($_POST['type'] ?? ''); if (is_null($reportType)) { error("bad report type"); } @@ -113,7 +117,7 @@ $report = $reportMan->create( track: $trackList, image: $Images, link: $Links, - irc: new Gazelle\Util\Irc(), + irc: new Util\Irc(), ); if (!$reportType->isInvisible() && $torrent->uploaderId() != $Viewer->id()) { diff --git a/sections/reportsv2/reports.php b/sections/reportsv2/reports.php index ec4bddad7..c98048b99 100644 --- a/sections/reportsv2/reports.php +++ b/sections/reportsv2/reports.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_reports')) { error(403); } diff --git a/sections/reportsv2/resolve_handle.php b/sections/reportsv2/resolve_handle.php index 754d06c47..c41bd6eab 100644 --- a/sections/reportsv2/resolve_handle.php +++ b/sections/reportsv2/resolve_handle.php @@ -3,6 +3,10 @@ /** @phpstan-var \Gazelle\Cache $Cache */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Enum\TorrentFlag; /* @@ -19,14 +23,14 @@ if (!$Viewer->permitted('admin_reports')) { authorize(); $fromReportPage = !isset($_POST['from_delete']); -$reportTypeMan = new Gazelle\Manager\Torrent\ReportType(); -$reportMan = new Gazelle\Manager\Torrent\Report(new Gazelle\Manager\Torrent()); -$userMan = new Gazelle\Manager\User(); +$reportTypeMan = new Manager\Torrent\ReportType(); +$reportMan = new Manager\Torrent\Report(new Manager\Torrent()); +$userMan = new Manager\User(); $report = $reportMan->findById((int)($_POST['reportid'] ?? 0)); if (is_null($report)) { // torrent is being deleted using RM link - $torMan = new Gazelle\Manager\Torrent(); + $torMan = new Manager\Torrent(); $torrent = $torMan->findById((int)($_POST['torrentid'] ?? 0)); if (is_null($torrent)) { json_die("failure", "torrent not found"); @@ -39,7 +43,7 @@ if (is_null($report)) { torrent: $torrent, user: $Viewer, reportType: $reportType, - irc: new Gazelle\Util\Irc(), + irc: new Util\Irc(), reason: '', otherIdList: '', ); diff --git a/sections/reportsv2/search.php b/sections/reportsv2/search.php index 16804d03c..01ce5ee14 100644 --- a/sections/reportsv2/search.php +++ b/sections/reportsv2/search.php @@ -2,13 +2,17 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_reports')) { error(403); } -$userMan = new Gazelle\Manager\User(); -$reportMan = new Gazelle\Manager\Torrent\Report(new Gazelle\Manager\Torrent()); -$reportTypeMan = new Gazelle\Manager\Torrent\ReportType(); +$userMan = new Manager\User(); +$reportMan = new Manager\Torrent\Report(new Manager\Torrent()); +$reportTypeMan = new Manager\Torrent\ReportType(); $categories = $reportMan->categories(); $filter = []; @@ -57,7 +61,7 @@ if (isset($_GET['dt-until']) && preg_match('/(\d\d\d\d-\d\d-\d\d)/', $_GET['dt-u $dtUntil = date('Y-m-d'); } -$paginator = new Gazelle\Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(TORRENTS_PER_PAGE, (int)($_GET['page'] ?? 1)); if (!$filter) { $list = []; diff --git a/sections/reportsv2/static.php b/sections/reportsv2/static.php index 3c2f8506b..0a1b0800d 100644 --- a/sections/reportsv2/static.php +++ b/sections/reportsv2/static.php @@ -4,6 +4,10 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + /* * This page is used for viewing reports in every viewpoint except auto. * It doesn't AJAX grab a new report when you resolve each one, use auto @@ -18,22 +22,22 @@ if (!$Viewer->permitted('admin_reports')) { error(403); } -$torMan = new Gazelle\Manager\Torrent(); -$reportMan = new Gazelle\Manager\Torrent\Report($torMan); -$reportTypeMan = new Gazelle\Manager\Torrent\ReportType(); -$requestMan = new Gazelle\Manager\Request(); -$userMan = new Gazelle\Manager\User(); -$search = new Gazelle\Search\Torrent\Report($_GET['view'] ?? '', $_GET['id'] ?? '', $reportTypeMan, $userMan); -$imgProxy = new Gazelle\Util\ImageProxy($Viewer); -$ripFiler = new Gazelle\File\RipLog(); -$htmlFiler = new Gazelle\File\RipLogHTML(); +$torMan = new Manager\Torrent(); +$reportMan = new Manager\Torrent\Report($torMan); +$reportTypeMan = new Manager\Torrent\ReportType(); +$requestMan = new Manager\Request(); +$userMan = new Manager\User(); +$search = new Search\Torrent\Report($_GET['view'] ?? '', $_GET['id'] ?? '', $reportTypeMan, $userMan); +$imgProxy = new Util\ImageProxy($Viewer); +$ripFiler = new File\RipLog(); +$htmlFiler = new File\RipLogHTML(); -$paginator = new Gazelle\Util\Paginator(REPORTS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(REPORTS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($search->total()); $page = $search->page($reportMan, $paginator->limit(), $paginator->offset()); -View::show_header('Torrent Reports', ['js' => 'reportsv2,bbcode,browse,torrent']); +\View::show_header('Torrent Reports', ['js' => 'reportsv2,bbcode,browse,torrent']); ?>

title() ?>

@@ -150,7 +154,7 @@ if ($search->canUnclaim($Viewer)) { description()) { ?> -
Release info: description()) ?> +
Release info: description()) ?> @@ -161,7 +165,7 @@ if ($search->canUnclaim($Viewer)) {
- + status() == 'InProgress') { /* BEGIN MOD STUFF */ ?> @@ -392,4 +396,4 @@ if ($search->canUnclaim($Viewer)) { linkbox(); -View::show_footer(); +\View::show_footer(); diff --git a/sections/reportsv2/views.php b/sections/reportsv2/views.php index b77d8ed0c..0e8d4b515 100644 --- a/sections/reportsv2/views.php +++ b/sections/reportsv2/views.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + /* * This page is to outline all of the views built into reports v2. * It's used as the main page as it also lists the current reports by type @@ -12,9 +16,9 @@ if (!$Viewer->permitted('admin_reports')) { error(403); } -$reportMan = new Gazelle\Manager\Torrent\Report(new Gazelle\Manager\Torrent()); -$reportTypeMan = new Gazelle\Manager\Torrent\ReportType(); -$userMan = new Gazelle\Manager\User(); +$reportMan = new Manager\Torrent\Report(new Manager\Torrent()); +$reportTypeMan = new Manager\Torrent\ReportType(); +$userMan = new Manager\User(); echo $Twig->render('reportsv2/summary.twig', [ 'in_progress' => $reportMan->inProgressSummary($userMan), diff --git a/sections/requests/bounty_handle.php b/sections/requests/bounty_handle.php index 004be9ab6..5907d9bb6 100644 --- a/sections/requests/bounty_handle.php +++ b/sections/requests/bounty_handle.php @@ -1,13 +1,17 @@ permitted('site_admin_requests')) { error(403); } -$request = (new Gazelle\Manager\Request())->findById((int)$_POST['id']); +$request = (new Manager\Request())->findById((int)$_POST['id']); if (is_null($request)) { error(404); } @@ -46,7 +50,7 @@ foreach ($_POST as $k => $v) { * $check: * 4 => true */ -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); $refund = []; $remove = []; foreach ($action as $userId => $operation) { diff --git a/sections/requests/delete_handle.php b/sections/requests/delete_handle.php index d87cded7a..585296525 100644 --- a/sections/requests/delete_handle.php +++ b/sections/requests/delete_handle.php @@ -1,9 +1,13 @@ findById((int)$_POST['id']); +$request = (new Manager\Request())->findById((int)$_POST['id']); if (is_null($request)) { error(404); } @@ -14,7 +18,7 @@ if ($Viewer->id() != $request->userId() && !$Viewer->permitted('site_moderate_re $reason = trim($_POST['reason']); $title = $request->text(); if ($request->userId() !== $Viewer->id()) { - $user = (new Gazelle\Manager\User())->findById($request->userId()); + $user = (new Manager\User())->findById($request->userId()); if ($user) { $user->inbox()->createSystem( 'A request you created has been deleted', diff --git a/sections/requests/edit.php b/sections/requests/edit.php index 0998a480f..b7deb23d1 100644 --- a/sections/requests/edit.php +++ b/sections/requests/edit.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$request = (new Gazelle\Manager\Request())->findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$request = (new Manager\Request())->findById((int)($_GET['id'] ?? 0)); if (is_null($request)) { error(404); } @@ -17,10 +21,10 @@ if (isset($returnEdit)) { // if we are coming back from an edit, these were already initialized in take_new_edit /** @var string $categoryName */ /** @var array $artistRole */ - /** @var Gazelle\Request\Encoding $encoding */ - /** @var Gazelle\Request\Format $format */ - /** @var Gazelle\Request\Media $media */ - /** @var Gazelle\Request\LogCue $logCue */ + /** @var Request\Encoding $encoding */ + /** @var Request\Format $format */ + /** @var Request\Media $media */ + /** @var Request\LogCue $logCue */ } else { $categoryId = $request->categoryId(); $categoryName = $request->categoryName(); @@ -47,12 +51,12 @@ echo $Twig->render('request/request.twig', [ 'request' => $request, 'category_name' => $categoryName, 'artist_role' => $artistRole, - 'tgroup' => (new Gazelle\Manager\TGroup())->findById((int)($groupId ?? $request->tgroupId())), - 'release_list' => (new Gazelle\ReleaseType())->list(), - 'tag_list' => (new Gazelle\Manager\Tag())->genreList(), + 'tgroup' => (new Manager\TGroup())->findById((int)($groupId ?? $request->tgroupId())), + 'release_list' => (new ReleaseType())->list(), + 'tag_list' => (new Manager\Tag())->genreList(), 'catalogue_number' => $catalogueNumber ?? $request->catalogueNumber(), 'category_id' => $categoryId ?? $request->categoryId(), - 'description' => new Gazelle\Util\Textarea('description', $description ?? $request->description(), 70, 7), + 'description' => new Util\Textarea('description', $description ?? $request->description(), 70, 7), 'encoding' => $encoding, 'format' => $format, 'log_cue' => $logCue, diff --git a/sections/requests/edit_bounty.php b/sections/requests/edit_bounty.php index 7f032e8c1..277d77144 100644 --- a/sections/requests/edit_bounty.php +++ b/sections/requests/edit_bounty.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_admin_requests')) { error(403); } -$request = (new Gazelle\Manager\Request())->findById((int)$_GET['id']); +$request = (new Manager\Request())->findById((int)$_GET['id']); if (is_null($request)) { error(404); } diff --git a/sections/requests/edit_handle.php b/sections/requests/edit_handle.php index 135d20b79..239aa7be4 100644 --- a/sections/requests/edit_handle.php +++ b/sections/requests/edit_handle.php @@ -1,9 +1,13 @@ findById((int)($_POST['requestid'] ?? 0)); if (is_null($request)) { error(404); @@ -35,7 +39,7 @@ $format = null; $media = null; while (true) { - $validator = new Gazelle\Util\Validator(); + $validator = new Util\Validator(); if (isset($_POST['description'])) { $validator->setField('description', true, 'string', 'You forgot to enter a description.', ['maxlength' => 32000]); } @@ -90,7 +94,7 @@ while (true) { if (isset($_POST['releasetype'])) { $releaseType = (int)$_POST['releasetype']; - if (!(new Gazelle\ReleaseType())->findNameById($releaseType)) { + if (!(new ReleaseType())->findNameById($releaseType)) { $error = 'Please pick a release type'; break; } @@ -100,7 +104,7 @@ while (true) { } if (isset($_POST['formats']) && $Viewer->permitted('site_moderate_requests')) { - $format = new Gazelle\Request\Format(isset($_POST['all_formats']), $_POST['formats'] ?? []); + $format = new Request\Format(isset($_POST['all_formats']), $_POST['formats'] ?? []); if (!$format->isValid()) { $error = 'You must require at least one valid format'; break; @@ -113,7 +117,7 @@ while (true) { if (!isset($_POST['bitrates'])) { $encoding = null; } else { - $encoding = new Gazelle\Request\Encoding(isset($_POST['all_bitrates']), $_POST['bitrates'] ?? []); + $encoding = new Request\Encoding(isset($_POST['all_bitrates']), $_POST['bitrates'] ?? []); if (!$encoding->isValid()) { $error = 'You must require at least one valid encoding'; break; @@ -124,7 +128,7 @@ while (true) { } if (isset($_POST['media']) && $Viewer->permitted('site_moderate_requests')) { - $media = new Gazelle\Request\Media(isset($_POST['all_media']), $_POST['media'] ?? []); + $media = new Request\Media(isset($_POST['all_media']), $_POST['media'] ?? []); if (!$media->isValid()) { $error = 'You must require at least one valid media'; break; @@ -139,7 +143,7 @@ while (true) { $request->setField('Checksum', 0); $request->setField('LogCue', ''); } else { - $logCue = new Gazelle\Request\LogCue( + $logCue = new Request\LogCue( needCue: isset($_POST['needcue']), needLog: isset($_POST['needlog']), needLogChecksum: isset($_POST['needcksum']), @@ -164,7 +168,7 @@ while (true) { ? (int)$match['id'] : (int)$_POST['groupid']; if ($tgroupId > 0) { - $tgroup = (new Gazelle\Manager\TGroup())->findById($tgroupId); + $tgroup = (new Manager\TGroup())->findById($tgroupId); if (is_null($tgroup)) { $error = 'The torrent group, if entered, must correspond to a music torrent group on the site.'; break; @@ -235,10 +239,10 @@ if (isset($_POST['oclc'])) { $request->modify(); if ($categoryName === 'Music' && $Viewer->permittedAny('site_edit_requests', 'site_moderate_requests')) { - $request->artistRole()->set($artistRole, $Viewer, new Gazelle\Manager\Artist()); + $request->artistRole()->set($artistRole, $Viewer, new Manager\Artist()); } if (isset($_POST['tags'])) { - (new Gazelle\Manager\Tag())->replaceTagList( + (new Manager\Tag())->replaceTagList( $request, array_unique(array_map('trim', explode(',', trim($_POST['tags'])))), $Viewer, diff --git a/sections/requests/fill_handle.php b/sections/requests/fill_handle.php index d23095cca..e1df4ccf2 100644 --- a/sections/requests/fill_handle.php +++ b/sections/requests/fill_handle.php @@ -1,6 +1,10 @@ findById((int)$_REQUEST['requestid']); +$request = (new Manager\Request())->findById((int)$_REQUEST['requestid']); if (is_null($request)) { error(404); } $error = []; $torrent = null; -$tgMan = new Gazelle\Manager\Torrent(); +$tgMan = new Manager\Torrent(); $isAdmin = $Viewer->permitted('site_moderate_requests'); if (!empty($_REQUEST['torrentid'])) { $torrent = $tgMan->findById((int)$_REQUEST['torrentid']); @@ -43,7 +47,7 @@ if (is_null($torrent)) { } if (!empty($_REQUEST['user']) && $isAdmin) { - $filler = (new Gazelle\Manager\User())->findByUsername($_REQUEST['user']); + $filler = (new Manager\User())->findByUsername($_REQUEST['user']); if (is_null($filler)) { $error[] = 'No such user to fill for!'; } diff --git a/sections/requests/index.php b/sections/requests/index.php index e85e60958..658a298a5 100644 --- a/sections/requests/index.php +++ b/sections/requests/index.php @@ -1,6 +1,10 @@ disableRequests()) { error('Your request privileges have been removed.'); } diff --git a/sections/requests/interim.php b/sections/requests/interim.php index 17ca8d920..00eb14916 100644 --- a/sections/requests/interim.php +++ b/sections/requests/interim.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$request = (new Gazelle\Manager\Request())->findById((int)$_GET['id']); +declare(strict_types=1); + +namespace Gazelle; + +$request = (new Manager\Request())->findById((int)$_GET['id']); if (is_null($request)) { error(404); } diff --git a/sections/requests/new.php b/sections/requests/new.php index fc558602a..060d611ef 100644 --- a/sections/requests/new.php +++ b/sections/requests/new.php @@ -2,20 +2,24 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if ($Viewer->uploadedSize() < 250 * 1024 * 1024 || !$Viewer->permitted('site_submit_requests')) { error('You have not enough upload to make a request.'); } // We may be able to prepare some things based on whence we came if (isset($_GET['artistid'])) { - $artist = (new Gazelle\Manager\Artist())->findById((int)$_GET['artistid']); + $artist = (new Manager\Artist())->findById((int)$_GET['artistid']); if ($artist) { $artistRole = [ ARTIST_MAIN => [$artist->name()], ]; } } elseif (isset($_GET['groupid'])) { - $tgroup = (new Gazelle\Manager\TGroup())->findById((int)$_GET['groupid']); + $tgroup = (new Manager\TGroup())->findById((int)$_GET['groupid']); if ($tgroup) { $categoryId = $tgroup->categoryId(); $categoryName = $tgroup->categoryName(); @@ -28,7 +32,7 @@ if (isset($_GET['artistid'])) { } } -$bounty = $_POST['amount'] ?? $Viewer->ordinal()->value('request-bounty-create'); +$bounty = (float)($_POST['amount'] ?? $Viewer->ordinal()->value('request-bounty-create')); [$amount, $unit] = array_values(byte_format_array($bounty)); if (in_array($unit, ['GiB', 'TiB'])) { $unitGiB = true; @@ -45,19 +49,19 @@ echo $Twig->render('request/request.twig', [ 'error' => $error ?? null, 'tgroup' => $tgroup ?? null, 'viewer' => $Viewer, - 'release_list' => (new Gazelle\ReleaseType())->list(), - 'tag_list' => (new Gazelle\Manager\Tag())->genreList(), + 'release_list' => (new ReleaseType())->list(), + 'tag_list' => (new Manager\Tag())->genreList(), 'amount' => $bounty, 'amount_box' => $amount ?? REQUEST_MIN, 'unit_GiB' => isset($unitGiB), 'artist_role' => $artistRole ?? [], 'catalogue_number' => $catalogueNumber ?? '', 'category_id' => $categoryId ?? null, - 'description' => new Gazelle\Util\Textarea('description', $description ?? '', 70, 7), - 'encoding' => $encoding ?? new Gazelle\Request\Encoding(), - 'format' => $format ?? new Gazelle\Request\Format(), - 'log_cue' => $logCue ?? new Gazelle\Request\LogCue(), - 'media' => $media ?? new Gazelle\Request\Media(), + 'description' => new Util\Textarea('description', $description ?? '', 70, 7), + 'encoding' => $encoding ?? new Request\Encoding(), + 'format' => $format ?? new Request\Format(), + 'log_cue' => $logCue ?? new Request\LogCue(), + 'media' => $media ?? new Request\Media(), 'oclc' => $oclc ?? '', 'image' => $image ?? '', 'record_label' => $recordLabel ?? '', diff --git a/sections/requests/new_handle.php b/sections/requests/new_handle.php index 24b6eca36..cef9848cb 100644 --- a/sections/requests/new_handle.php +++ b/sections/requests/new_handle.php @@ -1,6 +1,10 @@ permitted('site_submit_requests') || $Viewer->uploadedSize() < 250 * 1024 * 1024) { @@ -27,15 +31,15 @@ $tgroup = null; $title = null; $year = null; -$encoding = new Gazelle\Request\Encoding( +$encoding = new Request\Encoding( isset($_POST['all_bitrates']), array_trim_prefix('bitrate_', $_POST['bitrates'] ?? []) ); -$format = new Gazelle\Request\Format( +$format = new Request\Format( isset($_POST['all_formats']), array_trim_prefix('format_', $_POST['formats'] ?? []) ); -$media = new Gazelle\Request\Media( +$media = new Request\Media( isset($_POST['all_media']), array_trim_prefix('media_', $_POST['media'] ?? []) ); @@ -53,16 +57,16 @@ $amount = (int)$_POST['amount']; while (true) { // break early on error if ($categoryName !== 'Music') { $artistRole = []; - $logCue = new Gazelle\Request\LogCue(); + $logCue = new Request\LogCue(); } else { $logCue = $format->exists('FLAC') && $media->exists('CD') - ? new Gazelle\Request\LogCue( + ? new Request\LogCue( isset($_POST['needcksum']), isset($_POST['needcue']), isset($_POST['needlog']), (int)($_POST['minlogscore'] ?? 0) ) - : new Gazelle\Request\LogCue(); + : new Request\LogCue(); if (empty($_POST['artists'])) { $error = 'You did not enter any artists.'; @@ -99,7 +103,7 @@ while (true) { // break early on error break; } - if (!(new Gazelle\ReleaseType())->findNameById($releaseType)) { + if (!(new ReleaseType())->findNameById($releaseType)) { $error = 'Please pick a release type'; break; } @@ -133,7 +137,7 @@ while (true) { // break early on error ? (int)$match['id'] : (int)$_POST['groupid']; if ($GroupID > 0) { - $tgroup = (new Gazelle\Manager\TGroup())->findById($GroupID); + $tgroup = (new Manager\TGroup())->findById($GroupID); if (is_null($tgroup)) { $error = 'The torrent group, if entered, must correspond to a music torrent group on the site.'; break; @@ -141,7 +145,7 @@ while (true) { // break early on error } } - $validator = new Gazelle\Util\Validator(); + $validator = new Util\Validator(); $validator->setFields([ ['description', true, 'string', 'You forgot to enter a description.', ['maxlength' => 32000]], ['image', false, 'image', ''], @@ -179,7 +183,7 @@ if (isset($error)) { exit; } -$request = (new Gazelle\Manager\Request())->create( +$request = (new Manager\Request())->create( user: $Viewer, bounty: $amount, categoryId: $categoryId, @@ -199,9 +203,9 @@ $request = (new Gazelle\Manager\Request())->create( groupId: $tgroup?->id(), ); if ($categoryName == 'Music') { - $request->artistRole()->set($artistRole, $Viewer, new Gazelle\Manager\Artist()); + $request->artistRole()->set($artistRole, $Viewer, new Manager\Artist()); } -(new Gazelle\Manager\Tag())->replaceTagList( +(new Manager\Tag())->replaceTagList( $request, array_map('trim', explode(',', $tags)), $Viewer @@ -209,10 +213,10 @@ if ($categoryName == 'Music') { $tgroup?->flush(); if ($Viewer->option('AutoSubscribe')) { - (new Gazelle\User\Subscription($Viewer))->subscribeComments('requests', $request->id()); + (new User\Subscription($Viewer))->subscribeComments('requests', $request->id()); } -Gazelle\Util\Irc::sendMessage( +Util\Irc::sendMessage( IRC_CHAN_REQUEST, "{$request->text()} – {$request->publicLocation()} – " . implode(' ', $request->tagNameList()) ); diff --git a/sections/requests/request.php b/sections/requests/request.php index 263d68f35..1ebd03db0 100644 --- a/sections/requests/request.php +++ b/sections/requests/request.php @@ -2,20 +2,24 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$request = (new Gazelle\Manager\Request())->findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$request = (new Manager\Request())->findById((int)($_GET['id'] ?? 0)); if (is_null($request)) { error(404); } -$commentPage = new Gazelle\Comment\Request($request->id(), (int)($_GET['page'] ?? 0), (int)($_GET['postid'] ?? 0)); +$commentPage = new Comment\Request($request->id(), (int)($_GET['page'] ?? 0), (int)($_GET['postid'] ?? 0)); $commentPage->load()->handleSubscription($Viewer); -$paginator = new Gazelle\Util\Paginator(TORRENT_COMMENTS_PER_PAGE, $commentPage->pageNum()); +$paginator = new Util\Paginator(TORRENT_COMMENTS_PER_PAGE, $commentPage->pageNum()); $paginator->setAnchor('comments')->setTotal($commentPage->total())->removeParam('postid'); -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); $bounty = $Viewer->ordinal()->value('request-bounty-create'); -[$amount, $unit] = array_values(byte_format_array($bounty)); +[$amount, $unit] = array_values(byte_format_array((float)$bounty)); if (in_array($unit, ['GiB', 'TiB'])) { $unitGiB = true; if ($unit == 'TiB') { @@ -31,13 +35,13 @@ echo $Twig->render('request/detail.twig', [ 'unit_GiB' => isset($unitGiB), 'comment_page' => $commentPage, 'filler' => $userMan->findById($request->fillerId()), - 'is_bookmarked' => (new Gazelle\User\Bookmark($Viewer))->isRequestBookmarked($request->id()), - 'is_subscribed' => (new Gazelle\User\Subscription($Viewer))->isSubscribedComments('requests', $request->id()), + 'is_bookmarked' => (new User\Bookmark($Viewer))->isRequestBookmarked($request->id()), + 'is_subscribed' => (new User\Subscription($Viewer))->isSubscribedComments('requests', $request->id()), 'paginator' => $paginator, - 'reply' => (new Gazelle\Util\Textarea('quickpost', '', 90, 8))->setPreviewManual(true), + 'reply' => (new Util\Textarea('quickpost', '', 90, 8))->setPreviewManual(true), 'request' => $request, 'tax_rate' => sprintf("%0.2f", 100 * (1 - REQUEST_TAX)), - 'tgroup' => (new Gazelle\Manager\TGroup())->findById((int)$request->tgroupId()), + 'tgroup' => (new Manager\TGroup())->findById((int)$request->tgroupId()), 'uri' => $_SERVER['REQUEST_URI'], 'user_man' => $userMan, 'viewer' => $Viewer, diff --git a/sections/requests/requests.php b/sections/requests/requests.php index a25839e6f..b44c76dc9 100644 --- a/sections/requests/requests.php +++ b/sections/requests/requests.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$userMan = new Gazelle\Manager\User(); +declare(strict_types=1); + +namespace Gazelle; + +$userMan = new Manager\User(); if (!isset($_GET['userid'])) { $user = $Viewer; } else { @@ -12,7 +16,7 @@ if (!isset($_GET['userid'])) { } } -$search = new Gazelle\Search\Request(new Gazelle\Manager\Request()); +$search = new Search\Request(new Manager\Request()); $initial = !isset($_GET['submit']); $bookmarkView = false; @@ -93,7 +97,7 @@ if (isset($_GET['year'])) { $search->setYear((int)$_GET['year']); } -$header = new Gazelle\Util\SortableTableHeader('created', [ +$header = new Util\SortableTableHeader('created', [ 'year' => ['dbColumn' => 'year', 'defaultSort' => 'desc', 'text' => 'Year'], 'votes' => ['dbColumn' => 'votes', 'defaultSort' => 'desc', 'text' => 'Votes'], 'bounty' => ['dbColumn' => 'bounty', 'defaultSort' => 'desc', 'text' => 'Bounty'], @@ -103,7 +107,7 @@ $header = new Gazelle\Util\SortableTableHeader('created', [ 'random' => ['dbColumn' => 'RAND()', 'defaultSort' => ''], ]); -$paginator = new Gazelle\Util\Paginator(REQUESTS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(REQUESTS_PER_PAGE, (int)($_GET['page'] ?? 1)); if ($header->getOrderBy() === 'random') { $search->limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE); } else { @@ -130,8 +134,8 @@ echo $Twig->render('request/index.twig', [ 'requestor' => $requestor ?? null, 'tag_mode' => $_GET['tag_mode'] ?? 'all', 'filtering' => true, // false on artist page - 'show_filled' => $_GET['show_filled'] ?? null, - 'show_old' => $_GET['showall'] ?? null, + 'show_filled' => isset($_GET['show_filled']), + 'show_old' => isset($_GET['showall']), 'type' => $_GET['type'] ?? null, 'user' => $user, 'viewer' => $Viewer, diff --git a/sections/requests/unfill_handle.php b/sections/requests/unfill_handle.php index 85e1cf87e..7906352ce 100644 --- a/sections/requests/unfill_handle.php +++ b/sections/requests/unfill_handle.php @@ -1,9 +1,13 @@ findById((int)$_REQUEST['id']); +$request = (new Manager\Request())->findById((int)$_REQUEST['id']); if (is_null($request)) { error(404); } @@ -17,6 +21,6 @@ if ( error(403); } -$request->unfill($Viewer, trim($_POST['reason']), new Gazelle\Manager\Torrent()); +$request->unfill($Viewer, trim($_POST['reason']), new Manager\Torrent()); header('Location: ' . $request->location()); diff --git a/sections/requests/vote_handle.php b/sections/requests/vote_handle.php index d43919286..3f6f2eb03 100644 --- a/sections/requests/vote_handle.php +++ b/sections/requests/vote_handle.php @@ -1,13 +1,17 @@ permitted('site_vote')) { error(403); } authorize(); -$request = (new Gazelle\Manager\Request())->findById((int)($_GET['id'] ?? 0)); +$request = (new Manager\Request())->findById((int)($_GET['id'] ?? 0)); if (is_null($request)) { $result = ['status' => 'missing', 'get' => $_GET]; } elseif ($request->isFilled()) { diff --git a/sections/rules/index.php b/sections/rules/index.php index 101bd150e..a90c89211 100644 --- a/sections/rules/index.php +++ b/sections/rules/index.php @@ -2,13 +2,17 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + switch ($_GET['p'] ?? '') { case 'chat': echo $Twig->render('rules/chat.twig'); break; case 'clients': echo $Twig->render('rules/client-whitelist.twig', [ - 'list' => (new Gazelle\Manager\ClientWhitelist())->list(), + 'list' => (new Manager\ClientWhitelist())->list(), ]); break; case 'collages': @@ -37,10 +41,10 @@ switch ($_GET['p'] ?? '') { echo $Twig->render('rules/tag-page.twig'); break; case 'upload': - Text::$TOC = true; + \Text::$TOC = true; echo $Twig->render('rules/upload.twig', [ - 'body' => Text::full_format((new Gazelle\Wiki(RULES_WIKI_PAGE_ID))->body(), false, 3, true), - 'toc' => Text::parse_toc(0, true), + 'body' => \Text::full_format((new Wiki(RULES_WIKI_PAGE_ID))->body(), false, 3, true), + 'toc' => \Text::parse_toc(0, true), ]); break; default: diff --git a/sections/staff/index.php b/sections/staff/index.php index 19b6125e6..72f8f171d 100644 --- a/sections/staff/index.php +++ b/sections/staff/index.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + $userMan = new \Gazelle\Manager\User(); $classList = $userMan->classList(); echo $Twig->render('staff/index.twig', [ 'hidden' => true, - 'reply' => new Gazelle\Util\Textarea('quickpost', ''), + 'reply' => new Util\Textarea('quickpost', ''), 'fls' => $userMan->flsList(), 'staff' => $userMan->staffListGrouped(), 'user' => $Viewer, diff --git a/sections/staffblog/index.php b/sections/staffblog/index.php index 1fbf2bbd1..ca5e77b8a 100644 --- a/sections/staffblog/index.php +++ b/sections/staffblog/index.php @@ -2,13 +2,17 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Util\Irc; if (!$Viewer->permitted('users_mod')) { error(403); } -$blogMan = new Gazelle\Manager\StaffBlog(); +$blogMan = new Manager\StaffBlog(); $blogMan->catchup($Viewer); if ($Viewer->permitted('admin_manage_blog')) { @@ -52,7 +56,7 @@ if ($Viewer->permitted('admin_manage_blog')) { } } -View::show_header('Staff Blog', ['js' => 'bbcode']); +\View::show_header('Staff Blog', ['js' => 'bbcode']); if (in_array($_REQUEST['action'] ?? '', ['', 'editblog'])) { echo $Twig->render('staffblog/edit.twig', [ diff --git a/sections/staffpm/ajax_delete_response.php b/sections/staffpm/ajax_delete_response.php index 0aada2ad1..d6cc7b0d6 100644 --- a/sections/staffpm/ajax_delete_response.php +++ b/sections/staffpm/ajax_delete_response.php @@ -1,10 +1,14 @@ isStaffPMReader()) { error(403); } authorize(); -echo (new Gazelle\Manager\StaffPM())->removeCommonAnswer((int)($_POST['id'] ?? 0)); +echo (new Manager\StaffPM())->removeCommonAnswer((int)($_POST['id'] ?? 0)); diff --git a/sections/staffpm/ajax_edit_response.php b/sections/staffpm/ajax_edit_response.php index 11559642b..937b3c563 100644 --- a/sections/staffpm/ajax_edit_response.php +++ b/sections/staffpm/ajax_edit_response.php @@ -1,6 +1,10 @@ isStaffPMReader()) { error(403); } @@ -13,7 +17,7 @@ if (!$name || !$message) { } $id = (int)($_POST['id'] ?? 0); -$spmMan = new Gazelle\Manager\StaffPM(); +$spmMan = new Manager\StaffPM(); $answer = $spmMan->commonAnswer($id); if (is_null($answer)) { $spmMan->createCommonAnswer($name, $message); diff --git a/sections/staffpm/ajax_get_response.php b/sections/staffpm/ajax_get_response.php index 459641028..41e23238c 100644 --- a/sections/staffpm/ajax_get_response.php +++ b/sections/staffpm/ajax_get_response.php @@ -1,9 +1,13 @@ isStaffPMReader()) { error(403); } -$answer = (new Gazelle\Manager\StaffPM())->commonAnswer((int)($_GET['id'] ?? 0)); -echo (int)($_GET['plain'] ?? 0) === 1 ? $answer : Text::full_format($answer); +$answer = (new Manager\StaffPM())->commonAnswer((int)($_GET['id'] ?? 0)); +echo (int)($_GET['plain'] ?? 0) === 1 ? $answer : \Text::full_format($answer); diff --git a/sections/staffpm/assign.php b/sections/staffpm/assign.php index cb650cb54..483b6f0d1 100644 --- a/sections/staffpm/assign.php +++ b/sections/staffpm/assign.php @@ -1,11 +1,15 @@ isStaffPMReader()) { error(403); } -$staffPm = (new Gazelle\Manager\StaffPM())->findById((int)($_REQUEST['convid'] ?? 0)); +$staffPm = (new Manager\StaffPM())->findById((int)($_REQUEST['convid'] ?? 0)); if (is_null($staffPm)) { header('Location: staffpm.php'); exit; @@ -19,7 +23,7 @@ if (isset($_GET['convid'])) { if (empty($_GET['to'])) { error(404); } - $classList = (new Gazelle\Manager\User())->classList(); + $classList = (new Manager\User())->classList(); match ($_GET['to']) { 'forum' => $staffPm->assignClass($classList[FORUM_MOD]['Level'], $Viewer), 'staff' => $staffPm->assignClass($classList[MOD]['Level'], $Viewer), @@ -39,7 +43,7 @@ if ($Viewer->privilege()->effectiveClassLevel() < $staffPm->classLevel() && $Vie if ($assignTo == 'class') { $staffPm->assignClass($NewLevel, $Viewer); } else { - $assignee = (new Gazelle\Manager\User())->findById($NewLevel); + $assignee = (new Manager\User())->findById($NewLevel); if (is_null($assignee)) { error(404); } diff --git a/sections/staffpm/common_responses.php b/sections/staffpm/common_responses.php index 26d163d08..46d84e76d 100644 --- a/sections/staffpm/common_responses.php +++ b/sections/staffpm/common_responses.php @@ -2,13 +2,17 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->isStaffPMReader()) { error(403); } echo $Twig->render('staffpm/common-response.twig', [ 'conv_id' => $_GET['convid'] ?? false, - 'list' => (new Gazelle\Manager\StaffPM())->commonAnswerList(), - 'new' => new Gazelle\Util\Textarea("answer-0", '', 87, 10), + 'list' => (new Manager\StaffPM())->commonAnswerList(), + 'new' => new Util\Textarea("answer-0", '', 87, 10), 'viewer' => $Viewer, ]); diff --git a/sections/staffpm/get_post.php b/sections/staffpm/get_post.php index cc5652119..2805d7bf9 100644 --- a/sections/staffpm/get_post.php +++ b/sections/staffpm/get_post.php @@ -1,8 +1,12 @@ findByPostId($postId); +$pm = (new Manager\StaffPM())->findByPostId($postId); if (is_null($pm)) { error(404); } @@ -12,6 +16,6 @@ if (!$pm->visible($Viewer)) { header('Content-Type: application/json; charset=utf-8'); echo json_encode([ - 'username' => (new Gazelle\Manager\User())->findById((int)$pm->postUserId($postId))?->username(), + 'username' => (new Manager\User())->findById((int)$pm->postUserId($postId))?->username(), 'body' => $pm->postBody($postId), ]); diff --git a/sections/staffpm/index.php b/sections/staffpm/index.php index 7deb56a85..0c2000410 100644 --- a/sections/staffpm/index.php +++ b/sections/staffpm/index.php @@ -1,6 +1,10 @@ permitted('admin_staffpm_stats')) { error(403); } -$userMan = new Gazelle\Manager\User(); -$spmMan = new Gazelle\Manager\StaffPM(); +$userMan = new Manager\User(); +$spmMan = new Manager\StaffPM(); $isStaffView = ($_REQUEST['view'] ?? 'staff') === 'staff'; $SupportStaff = [...array_keys($userMan->flsList()), ...array_keys($userMan->staffList())]; diff --git a/sections/staffpm/staff_inbox.php b/sections/staffpm/staff_inbox.php index b01d68d16..8e653a18e 100644 --- a/sections/staffpm/staff_inbox.php +++ b/sections/staffpm/staff_inbox.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$staffpmMan = new Gazelle\Manager\StaffPM(); +declare(strict_types=1); + +namespace Gazelle; + +$staffpmMan = new Manager\StaffPM(); $viewMap = [ '' => [ 'status' => ['Unanswered'], @@ -47,7 +51,7 @@ if (isset($_GET['id'])) { } if ($viewMap[$view]['title'] === 'Your Unanswered') { - $classlist = (new Gazelle\Manager\User())->classList(); + $classlist = (new Manager\User())->classList(); if ($Viewer->privilege()->effectiveClassLevel() >= $classlist[MOD]['Level']) { $staffpmMan->setUserclassLevel($classlist[MOD]['Level']); } elseif ($Viewer->privilege()->effectiveClassLevel() == $classlist[FORUM_MOD]['Level']) { @@ -55,7 +59,7 @@ if ($viewMap[$view]['title'] === 'Your Unanswered') { } } -$paginator = new Gazelle\Util\Paginator(MESSAGES_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(MESSAGES_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($staffpmMan->searchTotal()); echo $Twig->render('staffpm/staff-inbox.twig', [ diff --git a/sections/staffpm/unresolve.php b/sections/staffpm/unresolve.php index 839226f6a..09c83dc51 100644 --- a/sections/staffpm/unresolve.php +++ b/sections/staffpm/unresolve.php @@ -1,7 +1,11 @@ findById((int)($_GET['id'] ?? 0)); +declare(strict_types=1); + +namespace Gazelle; + +$spm = (new Manager\StaffPM())->findById((int)($_GET['id'] ?? 0)); if (is_null($spm)) { error(404); } diff --git a/sections/staffpm/user_inbox.php b/sections/staffpm/user_inbox.php index 2c20951ca..41c5c85a1 100644 --- a/sections/staffpm/user_inbox.php +++ b/sections/staffpm/user_inbox.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$classList = (new Gazelle\Manager\User())->classList(); +declare(strict_types=1); + +namespace Gazelle; + +$classList = (new Manager\User())->classList(); echo $Twig->render('staffpm/user-inbox.twig', [ 'level' => [ @@ -10,8 +14,8 @@ echo $Twig->render('staffpm/user-inbox.twig', [ 'mod' => $classList[MOD]['Level'], 'sysop' => $classList[SYSOP]['Level'], ], - 'list' => (new Gazelle\Manager\StaffPM())->findAllByUser($Viewer), + 'list' => (new Manager\StaffPM())->findAllByUser($Viewer), 'max' => 'Sysop', - 'reply' => new Gazelle\Util\Textarea('quickpost', ''), + 'reply' => new Util\Textarea('quickpost', ''), 'viewer' => $Viewer, ]); diff --git a/sections/staffpm/viewconv.php b/sections/staffpm/viewconv.php index a03d0c7d4..7b5263a1a 100644 --- a/sections/staffpm/viewconv.php +++ b/sections/staffpm/viewconv.php @@ -2,7 +2,11 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ -$manager = new Gazelle\Manager\StaffPM(); +declare(strict_types=1); + +namespace Gazelle; + +$manager = new Manager\StaffPM(); $staffPM = $manager->findById((int)($_GET['id'] ?? 0)); if (is_null($staffPM)) { error(404); @@ -14,14 +18,14 @@ if ($staffPM->userId() === $Viewer->id() && $staffPM->isUnread()) { // User is viewing their own unread conversation, set it to read $staffPM->markAsRead($Viewer); } -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); echo $Twig->render('staffpm/message.twig', [ 'author' => $userMan->findById($staffPM->userId()), 'common' => $manager->commonAnswerList(), 'heading' => $manager->heading($Viewer), 'pm' => $staffPM, - 'textarea' => new Gazelle\Util\Textarea('quickpost', '', 90, 10), + 'textarea' => new Util\Textarea('quickpost', '', 90, 10), 'staff_level' => $userMan->staffClassList(), 'staff' => $userMan->staffList(), 'fls' => $userMan->flsList(), diff --git a/sections/staffpm/viewconv_handle.php b/sections/staffpm/viewconv_handle.php index 1fe8323a2..c76967ed8 100644 --- a/sections/staffpm/viewconv_handle.php +++ b/sections/staffpm/viewconv_handle.php @@ -1,7 +1,11 @@ flow(); echo $Twig->render('stats/torrent.twig', [ diff --git a/sections/stats/users.php b/sections/stats/users.php index 212d4a0e3..3cbd50d71 100644 --- a/sections/stats/users.php +++ b/sections/stats/users.php @@ -1,7 +1,11 @@ flow(); echo $Twig->render('stats/user.twig', [ diff --git a/sections/tools/data/bonus_stats.php b/sections/tools/data/bonus_stats.php index 975dd8c8e..1c77c4715 100644 --- a/sections/tools/data/bonus_stats.php +++ b/sections/tools/data/bonus_stats.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_bp_history')) { error(403); } -$bonus = new Gazelle\Stats\Bonus(); +$bonus = new Stats\Bonus(); $day = []; $week = []; $month = []; @@ -21,5 +25,5 @@ echo $Twig->render('admin/bonus-stats.twig', [ 'day' => $day, 'week' => $week, 'month' => $month, - 'fl' => (new Gazelle\Stats\Users())->stockpileTokenList(10), + 'fl' => (new Stats\Users())->stockpileTokenList(10), ]); diff --git a/sections/tools/data/economic_stats.php b/sections/tools/data/economic_stats.php index 183c088bd..24fa2aee7 100644 --- a/sections/tools/data/economic_stats.php +++ b/sections/tools/data/economic_stats.php @@ -2,10 +2,14 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_view_flow')) { error(403); } echo $Twig->render('admin/economy.twig', [ - 'info' => new Gazelle\Stats\Economic(), + 'info' => new Stats\Economic(), ]); diff --git a/sections/tools/data/invite_pool.php b/sections/tools/data/invite_pool.php index 37e64d616..27f2747ea 100644 --- a/sections/tools/data/invite_pool.php +++ b/sections/tools/data/invite_pool.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('users_view_invites')) { error(403); } -$inviteMan = new Gazelle\Manager\Invite(); +$inviteMan = new Manager\Invite(); $removed = null; if (!empty($_POST['invitekey']) && $Viewer->permitted('users_edit_invites')) { @@ -20,7 +24,7 @@ if ($search) { } $pending = $inviteMan->totalPending(); -$paginator = new Gazelle\Util\Paginator(INVITES_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(INVITES_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($pending); echo $Twig->render('invite/pool.twig', [ diff --git a/sections/tools/data/platform_usage.php b/sections/tools/data/platform_usage.php index f4939eb73..de22b6e60 100644 --- a/sections/tools/data/platform_usage.php +++ b/sections/tools/data/platform_usage.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_debug')) { error(403); } -$stats = new Gazelle\Stats\Users(); +$stats = new Stats\Users(); echo $Twig->render('admin/platform-usage.twig', [ 'os_list' => $stats->operatingSystemList(), diff --git a/sections/tools/data/ratio_watch.php b/sections/tools/data/ratio_watch.php index 25fc0579c..4b5862fdc 100644 --- a/sections/tools/data/ratio_watch.php +++ b/sections/tools/data/ratio_watch.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_view_flow')) { error(403); } -$userMan = new Gazelle\Manager\User(); -$paginator = new Gazelle\Util\Paginator(USERS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$userMan = new Manager\User(); +$paginator = new Util\Paginator(USERS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($userMan->totalRatioWatchUsers()); echo $Twig->render('admin/ratio-watch.twig', [ diff --git a/sections/tools/data/registration_log.php b/sections/tools/data/registration_log.php index 5acfba15c..523ef8055 100644 --- a/sections/tools/data/registration_log.php +++ b/sections/tools/data/registration_log.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permittedAny('users_view_ips', 'users_view_email')) { error(403); } -$registration = new Gazelle\Manager\Registration(new Gazelle\Manager\User()); +$registration = new Manager\Registration(new Manager\User()); if (isset($_REQUEST['before_date'])) { if (!str_contains($_SERVER['REQUEST_URI'], '&before_date=')) { @@ -21,13 +25,13 @@ if (isset($_REQUEST['after_date'])) { $registration->setAfterDate($_REQUEST['after_date']); } -$paginator = new Gazelle\Util\Paginator(USERS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(USERS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($registration->total()); echo $Twig->render('admin/registration.twig', [ 'after' => $_REQUEST['after_date'] ?? null, 'before' => $_REQUEST['before_date'] ?? null, - 'ipv4' => new Gazelle\Manager\IPv4(), + 'ipv4' => new Manager\IPv4(), 'list' => $registration->page($paginator->limit(), $paginator->offset()), 'paginator' => $paginator, ]); diff --git a/sections/tools/data/site_info.php b/sections/tools/data/site_info.php index 2e3c37081..cf8c5b762 100644 --- a/sections/tools/data/site_info.php +++ b/sections/tools/data/site_info.php @@ -3,6 +3,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_site_debug')) { error(403); } @@ -18,7 +22,7 @@ function gid(int $id): string { } if (isset($_GET['mode']) && $_GET['mode'] === 'userrank') { - $config = new Gazelle\UserRank\Configuration(RANKING_WEIGHT); + $config = new UserRank\Configuration(RANKING_WEIGHT); $names = array_keys(RANKING_WEIGHT); $rankTable = []; foreach ($names as $name) { @@ -34,8 +38,8 @@ if (isset($_GET['mode']) && $_GET['mode'] === 'userrank') { ]); } else { $random = openssl_random_pseudo_bytes(8, $strong); - $db = new Gazelle\DB(); - $pg = new Gazelle\DB\Pg(PG_RO_DSN); + $db = new DB(); + $pg = new DB\Pg(PG_RO_DSN); echo $Twig->render('admin/site-info.twig', [ 'uid' => uid(posix_getuid()), 'gid' => gid(posix_getgid()), @@ -46,7 +50,7 @@ if (isset($_GET['mode']) && $_GET['mode'] === 'userrank') { 'pg_checkpoint' => $pg->checkpointInfo(), 'pg_version' => $pg->version(), 'php_version' => phpversion(), - 'site_info' => new Gazelle\SiteInfo(), + 'site_info' => new SiteInfo(), 'timestamp_php' => date('Y-m-d H:i:s'), 'timestamp_db' => $db->now(), ]); diff --git a/sections/tools/data/special_users.php b/sections/tools/data/special_users.php index 05c125175..05ea863b6 100644 --- a/sections/tools/data/special_users.php +++ b/sections/tools/data/special_users.php @@ -2,10 +2,14 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_manage_permissions')) { error(403); } echo $Twig->render('admin/user-custom-permission.twig', [ - 'list' => (new Gazelle\Manager\User())->findAllByCustomPermission() + 'list' => (new Manager\User())->findAllByCustomPermission() ]); diff --git a/sections/tools/data/torrent_stats.php b/sections/tools/data/torrent_stats.php index 532c589b5..2a7d61063 100644 --- a/sections/tools/data/torrent_stats.php +++ b/sections/tools/data/torrent_stats.php @@ -4,15 +4,17 @@ declare(strict_types=1); +namespace Gazelle; + if (!$Viewer->permitted('site_view_flow')) { error(403); } -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); echo $Twig->render('admin/stats/torrent.twig', [ - 'notification' => new Gazelle\Manager\Notification(), - 'reaper' => new Gazelle\Torrent\Reaper(new Gazelle\Manager\Torrent(), $userMan), - 'torr_stat' => new Gazelle\Stats\Torrent(), - 'user_stat' => new Gazelle\Stats\Users(), + 'notification' => new Manager\Notification(), + 'reaper' => new Torrent\Reaper(new Manager\Torrent(), $userMan), + 'torr_stat' => new Stats\Torrent(), + 'user_stat' => new Stats\Users(), 'user_man' => $userMan, ]); diff --git a/sections/tools/data/user_flow.php b/sections/tools/data/user_flow.php index 3f61c405d..7a8f51682 100644 --- a/sections/tools/data/user_flow.php +++ b/sections/tools/data/user_flow.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_view_flow')) { error(403); } -$userMan = new Gazelle\Manager\User(); -$paginator = new Gazelle\Util\Paginator(100, (int)($_GET['page'] ?? 1)); +$userMan = new Manager\User(); +$paginator = new Util\Paginator(100, (int)($_GET['page'] ?? 1)); $paginator->setTotal($userMan->userflowTotal()); $showFlow = $paginator->page() === 1; diff --git a/sections/tools/data/user_info.php b/sections/tools/data/user_info.php index 4d1cd2de0..5146de9fc 100644 --- a/sections/tools/data/user_info.php +++ b/sections/tools/data/user_info.php @@ -4,12 +4,14 @@ declare(strict_types=1); +namespace Gazelle; + if (!$Viewer->permitted('users_view_ips')) { error(403); } -$userMan = new Gazelle\Manager\User(); +$userMan = new Manager\User(); $user = $userMan->findById((int)($_GET['userid'] ?? 0)); if (is_null($user)) { error(404); @@ -20,11 +22,11 @@ $direction = $_GET['dir'] ?? 'up'; echo $Twig->render('admin/user-info.twig', [ 'ancestry' => $userMan->ancestry($user), - 'asn' => new Gazelle\Search\ASN(), + 'asn' => new Search\ASN(), 'column' => $column, 'direction' => $direction, - 'invite_source' => new Gazelle\Manager\InviteSource(), - 'hist' => new Gazelle\User\History($user, $column, $direction), + 'invite_source' => new Manager\InviteSource(), + 'hist' => new User\History($user, $column, $direction), 'now' => date('Y-m-d H:i:s'), 'user' => $user, ]); diff --git a/sections/tools/development/analysis.php b/sections/tools/development/analysis.php index d313f0cce..2df8396b7 100644 --- a/sections/tools/development/analysis.php +++ b/sections/tools/development/analysis.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_analysis')) { error(403); } -$errorLog = new Gazelle\Manager\ErrorLog(); +$errorLog = new Manager\ErrorLog(); $case = null; if (isset($_POST['remove'])) { diff --git a/sections/tools/development/analysis_list.php b/sections/tools/development/analysis_list.php index 985086e77..f86bd44cc 100644 --- a/sections/tools/development/analysis_list.php +++ b/sections/tools/development/analysis_list.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('site_analysis')) { error(403); } -$errMan = new Gazelle\Manager\ErrorLog(); +$errMan = new Manager\ErrorLog(); $remove = array_key_extract_suffix('clear-', $_POST); if ($remove) { $removed = $errMan->remove($remove); @@ -20,10 +24,10 @@ if (isset($_REQUEST['filter']) && isset($_REQUEST['search'])) { $errMan->setFilter(trim($_REQUEST['search'])); } -$paginator = new Gazelle\Util\Paginator(ITEMS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(ITEMS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($errMan->total()); -$heading = new Gazelle\Util\SortableTableHeader('updated', [ +$heading = new Util\SortableTableHeader('updated', [ // see Gazelle\ErrorLog for these table aliases 'id' => ['dbColumn' => 'error_log_id', 'defaultSort' => 'desc', 'text' => 'Case'], 'duration' => ['dbColumn' => 'duration', 'defaultSort' => 'desc', 'text' => 'Duration'], diff --git a/sections/tools/development/clear_cache.php b/sections/tools/development/clear_cache.php index fc78f838d..08e1f2c70 100644 --- a/sections/tools/development/clear_cache.php +++ b/sections/tools/development/clear_cache.php @@ -3,12 +3,16 @@ /** @phpstan-var \Gazelle\Cache $Cache */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_clear_cache')) { error(403); } $result = []; -if (isset($_POST['confirm-global']) && isset($_POST['flush-global'])) { +if (isset($_POST['confirm-flush']) && isset($_POST['global_flush'])) { authorize(); $Cache->flush(); $result['global flush'] = $Cache->getResultMessage(); @@ -36,7 +40,7 @@ if (!empty($_REQUEST['key'])) { } } } else { - $flusher = new Gazelle\Util\CacheMultiFlush(); + $flusher = new Util\CacheMultiFlush(); foreach (array_keys(CACHE_DB) as $namespace) { if (empty($_REQUEST["flush-$namespace"])) { continue; diff --git a/sections/tools/development/db_sandbox.php b/sections/tools/development/db_sandbox.php index 5dfd87a18..2d49f2bd2 100644 --- a/sections/tools/development/db_sandbox.php +++ b/sections/tools/development/db_sandbox.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Enum\SourceDB; use Gazelle\Util\Text; @@ -23,7 +27,7 @@ if (isset($_GET['debug'])) { } $textAreaRows = max(8, substr_count($query, "\n") + 2); } elseif (isset($_GET['table'])) { - $query = (new Gazelle\DB())->selectQuery($_GET['table']); + $query = (new DB())->selectQuery($_GET['table']); $textAreaRows = max(8, substr_count($query, "\n") + 2); } elseif (!empty($_POST['query'])) { $query = trim($_POST['query']); @@ -42,7 +46,7 @@ if ($execute) { $db = new \Gazelle\DB\Pg(PG_RO_DSN); $result = $db->all($query); } else { - $db = Gazelle\DB::DB(readWrite: false); + $db = DB::DB(readWrite: false); $db->prepared_query($query); $result = $db->to_array(false, MYSQLI_ASSOC, false); } diff --git a/sections/tools/development/mysql.php b/sections/tools/development/mysql.php index bcf4de6d1..f6c6d3542 100644 --- a/sections/tools/development/mysql.php +++ b/sections/tools/development/mysql.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Enum\Direction; use Gazelle\Enum\MysqlInfoOrderBy; use Gazelle\Enum\MysqlTableMode; @@ -11,10 +15,10 @@ if (!$Viewer->permitted('site_database_specifics')) { } // View table definition -$db = Gazelle\DB::DB(); +$db = DB::DB(); if (!empty($_GET['table']) && preg_match('/([\w-]+)/', $_GET['table'], $match)) { $tableName = $match[1]; - $siteInfo = new Gazelle\SiteInfo(); + $siteInfo = new SiteInfo(); if (!$siteInfo->tableExists($tableName)) { error("No such table"); } @@ -28,10 +32,10 @@ if (!empty($_GET['table']) && preg_match('/([\w-]+)/', $_GET['table'], $match)) exit; } -$info = (new Gazelle\DB\MysqlInfo( - Gazelle\DB\MysqlInfo::lookupTableMode($_GET['mode'] ?? MysqlTableMode::all->value), - Gazelle\DB\MysqlInfo::lookupOrderby($_GET['order'] ?? MysqlInfoOrderBy::tableName->value), - Gazelle\DB::lookupDirection($_GET['sort'] ?? Direction::ascending->value)) +$info = (new DB\MysqlInfo( + DB\MysqlInfo::lookupTableMode($_GET['mode'] ?? MysqlTableMode::all->value), + DB\MysqlInfo::lookupOrderby($_GET['order'] ?? MysqlInfoOrderBy::tableName->value), + DB::lookupDirection($_GET['sort'] ?? Direction::ascending->value)) ); $list = $info->info(); $column = $info->orderBy() == MysqlInfoOrderBy::tableName @@ -45,7 +49,7 @@ foreach ($list as $t) { echo $Twig->render('admin/mysql-table-summary.twig', [ 'header' => new \Gazelle\Util\SortableTableHeader( MysqlInfoOrderBy::tableName->value, - Gazelle\DB\MysqlInfo::columnList(), + DB\MysqlInfo::columnList(), ), 'list' => $list, 'graph' => [ diff --git a/sections/tools/development/notification.php b/sections/tools/development/notification.php index 6f57be35f..e85a6aa04 100644 --- a/sections/tools/development/notification.php +++ b/sections/tools/development/notification.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_view_notifications')) { error(403); } -$torrent = (new Gazelle\Manager\Torrent())->findById((int)($_POST['torrentid'] ?? 0)); +$torrent = (new Manager\Torrent())->findById((int)($_POST['torrentid'] ?? 0)); $notifiedId = null; $result = []; @@ -16,7 +20,7 @@ if ($torrent) { $result = $notification->userFilterList(); if (isset($_POST['notifiedid'])) { - $notified = (new Gazelle\Manager\User())->find(trim($_POST['notifiedid'])); + $notified = (new Manager\User())->find(trim($_POST['notifiedid'])); if ($notified) { $notifiedId = $notified->id(); $result = array_filter($result, fn($r) => $r['user_id'] === $notifiedId); @@ -24,7 +28,7 @@ if ($torrent) { } foreach ($result as &$r) { - $r['filter'] = new Gazelle\NotificationFilter($r['filter_id']); + $r['filter'] = new NotificationFilter($r['filter_id']); } unset($r); } diff --git a/sections/tools/development/periodic_alter.php b/sections/tools/development/periodic_alter.php index 39ec7e638..32004d0ba 100644 --- a/sections/tools/development/periodic_alter.php +++ b/sections/tools/development/periodic_alter.php @@ -1,6 +1,10 @@ permitted('admin_periodic_task_manage')) { error(403); } @@ -8,7 +12,7 @@ if (!$Viewer->permitted('admin_periodic_task_manage')) { authorize(); $p = $_POST; -$scheduler = new Gazelle\TaskScheduler(); +$scheduler = new TaskScheduler(); if ($p['submit'] == 'Delete') { if (!is_number($p['id']) || $p['id'] == '') { @@ -17,7 +21,7 @@ if ($p['submit'] == 'Delete') { $scheduler->deleteTask($p['id']); } else { - $Val = new Gazelle\Util\Validator(); + $Val = new Util\Validator(); $Val->setFields([ ['name', true, 'string', 'The name must be set, and has a max length of 64 characters', ['maxlength' => 64]], ['classname', true, 'string', 'The class name must be set, and has a max length of 32 characters', ['maxlength' => 32]], diff --git a/sections/tools/development/periodic_detail.php b/sections/tools/development/periodic_detail.php index d75a2227f..dd3560632 100644 --- a/sections/tools/development/periodic_detail.php +++ b/sections/tools/development/periodic_detail.php @@ -2,17 +2,21 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_periodic_task_view')) { error(403); } -$scheduler = new Gazelle\TaskScheduler(); +$scheduler = new TaskScheduler(); $id = (int)($_GET['id'] ?? 0); if (!$scheduler->getTask($id)) { error(404); } -$header = new Gazelle\Util\SortableTableHeader('launchtime', [ +$header = new Util\SortableTableHeader('launchtime', [ 'id' => ['defaultSort' => 'desc'], 'launchtime' => ['defaultSort' => 'desc', 'text' => 'Launch Time'], 'duration' => ['defaultSort' => 'desc', 'text' => 'Duration'], @@ -21,7 +25,7 @@ $header = new Gazelle\Util\SortableTableHeader('launchtime', [ 'errors' => ['defaultSort' => 'desc', 'text' => 'Errors'] ]); -$paginator = new Gazelle\Util\Paginator(ITEMS_PER_PAGE, (int)($_GET['page'] ?? 1)); +$paginator = new Util\Paginator(ITEMS_PER_PAGE, (int)($_GET['page'] ?? 1)); $paginator->setTotal($scheduler->getTotal($id)); $stats = $scheduler->getTaskRuntimeStats($id); diff --git a/sections/tools/development/periodic_edit.php b/sections/tools/development/periodic_edit.php index a7e369780..16b566cc4 100644 --- a/sections/tools/development/periodic_edit.php +++ b/sections/tools/development/periodic_edit.php @@ -2,12 +2,16 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_periodic_task_manage')) { error(403); } echo $Twig->render('admin/scheduler/edit.twig', [ 'err' => $err ?? null, - 'task_list' => (new Gazelle\TaskScheduler())->getTasks(), + 'task_list' => (new TaskScheduler())->getTasks(), 'viewer' => $Viewer, ]); diff --git a/sections/tools/development/periodic_run.php b/sections/tools/development/periodic_run.php index aa2dc2723..4d617f38c 100644 --- a/sections/tools/development/periodic_run.php +++ b/sections/tools/development/periodic_run.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_schedule')) { error(403); } @@ -13,7 +17,7 @@ if (!$taskId) { error("Task not found"); } -$scheduler = new Gazelle\TaskScheduler(); +$scheduler = new TaskScheduler(); ob_start(); $processed = $scheduler->runTask($taskId, true); $output = ob_get_flush(); diff --git a/sections/tools/development/periodic_stats.php b/sections/tools/development/periodic_stats.php index 09906ae4c..b55e147b1 100644 --- a/sections/tools/development/periodic_stats.php +++ b/sections/tools/development/periodic_stats.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_periodic_task_view')) { error(403); } -$stats = (new Gazelle\TaskScheduler())->getRuntimeStats(); +$stats = (new TaskScheduler())->getRuntimeStats(); echo $Twig->render('admin/scheduler/stats.twig', [ 'hourly' => [ 'duration' => json_encode($stats['hourly'][0]['data']), diff --git a/sections/tools/development/periodic_view.php b/sections/tools/development/periodic_view.php index 28beaad43..3d6d29c16 100644 --- a/sections/tools/development/periodic_view.php +++ b/sections/tools/development/periodic_view.php @@ -2,11 +2,15 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_periodic_task_view')) { error(403); } -$scheduler = new Gazelle\TaskScheduler(); +$scheduler = new TaskScheduler(); $taskId = (int)($_REQUEST['id'] ?? 0); if ($taskId && $_REQUEST['mode'] === 'run_now') { diff --git a/sections/tools/development/pg.php b/sections/tools/development/pg.php index 96fe2adcf..8f2a23b09 100644 --- a/sections/tools/development/pg.php +++ b/sections/tools/development/pg.php @@ -2,6 +2,10 @@ /** @phpstan-var \Gazelle\User $Viewer */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + use Gazelle\Enum\PgInfoOrderBy; use Gazelle\Enum\Direction; @@ -9,15 +13,15 @@ if (!$Viewer->permitted('site_database_specifics')) { error(403); } -$info = new Gazelle\DB\PgInfo( - Gazelle\DB\PgInfo::lookupOrderby($_GET['order'] ?? PgInfoOrderBy::tableName->value), - Gazelle\DB::lookupDirection($_GET['sort'] ?? Direction::ascending->value) +$info = new DB\PgInfo( + DB\PgInfo::lookupOrderby($_GET['order'] ?? PgInfoOrderBy::tableName->value), + DB::lookupDirection($_GET['sort'] ?? Direction::ascending->value) ); echo $Twig->render('admin/pg-table-summary.twig', [ 'header' => new \Gazelle\Util\SortableTableHeader( PgInfoOrderBy::tableName->value, - Gazelle\DB\PgInfo::columnList() + DB\PgInfo::columnList() ), 'list' => $info->info(), ]); diff --git a/sections/tools/development/process_info.php b/sections/tools/development/process_info.php index eab7ecf9d..ce2d2cdaf 100644 --- a/sections/tools/development/process_info.php +++ b/sections/tools/development/process_info.php @@ -3,6 +3,10 @@ /** @phpstan-var \Gazelle\Cache $Cache */ /** @phpstan-var \Twig\Environment $Twig */ +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_site_debug')) { error(403); } diff --git a/sections/tools/development/referral_sandbox.php b/sections/tools/development/referral_sandbox.php index b9c68205a..ebe5dbd9b 100644 --- a/sections/tools/development/referral_sandbox.php +++ b/sections/tools/development/referral_sandbox.php @@ -3,11 +3,15 @@ // phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +declare(strict_types=1); + +namespace Gazelle; + if (!$Viewer->permitted('admin_manage_referrals')) { error(403); } -$referralManager = new Gazelle\Manager\Referral(); +$referralManager = new Manager\Referral(); $referralAccounts = $referralManager->getFullAccounts(); $cookie = []; @@ -17,7 +21,7 @@ $hasResult = false; if (isset($_POST['url'])) { authorize(); $url = $_POST['url']; - $proxy = new Gazelle\Util\Proxy(REFERRAL_KEY, REFERRAL_BOUNCER); + $proxy = new Util\Proxy(REFERRAL_KEY, REFERRAL_BOUNCER); $hasResult = true; $failedLogin = false; @@ -52,7 +56,7 @@ if (isset($_POST['url'])) { } } -View::show_header("Referral Sandbox"); +\View::show_header("Referral Sandbox"); ?>
ReportedRelevant
logDetails(); ?>
    @@ -204,8 +208,8 @@ if ($search->canUnclaim($Viewer)) {
-id()); + id()); $details = $log->logDetails(); ?>
    @@ -273,7 +277,7 @@ if ($search->canUnclaim($Viewer)) {
User comment:reason()) ?>reason()) ?>