diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3be9a407..4422b82f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,6 +9,7 @@ "[php]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, + "phpSniffer.autoDetect": true, "color-highlight.markerType": "dot-before" }, "extensions": [ @@ -22,6 +23,7 @@ "bradlc.vscode-tailwindcss", "jamesbirtles.svelte-vscode", "dbaeumer.vscode-eslint", - "stylelint.vscode-stylelint" + "stylelint.vscode-stylelint", + "wongjn.php-sniffer" ] } diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..64412874 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +; top-most EditorConfig file +root = true + +; Unix-style newlines +[*] +end_of_line = lf + +[*.php] +indent_style = spaces +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 00000000..741acfb0 --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,7 @@ + + + Castopod's coding standard based on the PSR-1 standard. + + + + \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json index fe8eb469..e6b50d4c 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -5,8 +5,7 @@ "files": "*.php", "options": { "phpVersion": "7.2", - "singleQuote": true, - "trailingCommaPHP": true + "singleQuote": true } } ] diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index c34592c2..62ea05ab 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -10,7 +10,7 @@ PHP Dependencies: - [GeoIP2 PHP API](https://github.com/maxmind/GeoIP2-php) ([Apache License 2.0](https://github.com/maxmind/GeoIP2-php/blob/master/LICENSE)) - [getID3](https://github.com/JamesHeinrich/getID3) ([GNU General Public License v3](https://github.com/JamesHeinrich/getID3/blob/2.0/licenses/license.gpl-30.txt)) - [myth-auth](https://github.com/lonnieezell/myth-auth) ([MIT license](https://github.com/lonnieezell/myth-auth/blob/develop/LICENSE.md)) -- [parsedown](https://github.com/erusev/parsedown) ([MIT license](https://github.com/erusev/parsedown/blob/master/LICENSE.txt)) +- [commonmark](https://commonmark.thephpleague.com/) ([BSD 3-Clause "New" or "Revised" License](https://github.com/thephpleague/commonmark/blob/latest/LICENSE)) Javascript dependencies: diff --git a/app/Authorization/FlatAuthorization.php b/app/Authorization/FlatAuthorization.php index 48b4ad73..a732a8cb 100644 --- a/app/Authorization/FlatAuthorization.php +++ b/app/Authorization/FlatAuthorization.php @@ -1,4 +1,6 @@ -groupModel->removeUserFromAllGroups($user_id); + $this->groupModel->removeUserFromAllGroups($userId); if (empty($groups)) { return true; } foreach ($groups as $group) { - $this->addUserToGroup($user_id, $group); + $this->addUserToGroup($userId, $group); } return true; diff --git a/app/Authorization/GroupModel.php b/app/Authorization/GroupModel.php index 597a54f1..74455708 100644 --- a/app/Authorization/GroupModel.php +++ b/app/Authorization/GroupModel.php @@ -1,4 +1,6 @@ - '127.0.0.1', 'port' => 11211, @@ -87,13 +87,13 @@ class Cache extends BaseConfig ]; /* - | ------------------------------------------------------------------------- - | Redis settings - | ------------------------------------------------------------------------- - | Your Redis server can be specified below, if you are using - | the Redis or Predis drivers. - | - */ + | ------------------------------------------------------------------------- + | Redis settings + | ------------------------------------------------------------------------- + | Your Redis server can be specified below, if you are using + | the Redis or Predis drivers. + | + */ public $redis = [ 'host' => '127.0.0.1', 'password' => null, @@ -103,14 +103,14 @@ class Cache extends BaseConfig ]; /* - |-------------------------------------------------------------------------- - | Available Cache Handlers - |-------------------------------------------------------------------------- - | - | This is an array of cache engine alias' and class names. Only engines - | that are listed here are allowed to be used. - | - */ + |-------------------------------------------------------------------------- + | Available Cache Handlers + |-------------------------------------------------------------------------- + | + | This is an array of cache engine alias' and class names. Only engines + | that are listed here are allowed to be used. + | + */ public $validHandlers = [ 'dummy' => \CodeIgniter\Cache\Handlers\DummyHandler::class, 'file' => \CodeIgniter\Cache\Handlers\FileHandler::class, diff --git a/app/Config/ContentSecurityPolicy.php b/app/Config/ContentSecurityPolicy.php index 2a0f1568..2ff4a68a 100644 --- a/app/Config/ContentSecurityPolicy.php +++ b/app/Config/ContentSecurityPolicy.php @@ -1,4 +1,6 @@ - \CodeIgniter\Format\JSONFormatter::class, 'application/xml' => \CodeIgniter\Format\XMLFormatter::class, diff --git a/app/Config/Honeypot.php b/app/Config/Honeypot.php index e49a2681..fe99eb2b 100644 --- a/app/Config/Honeypot.php +++ b/app/Config/Honeypot.php @@ -1,4 +1,6 @@ - php spark migrate:create - | - | Typical formats: - | YmdHis_ - | Y-m-d-His_ - | Y_m_d_His_ - | - */ + |-------------------------------------------------------------------------- + | Timestamp Format + |-------------------------------------------------------------------------- + | + | This is the format that will be used when creating new migrations + | using the cli command: + | > php spark migrate:create + | + | Typical formats: + | YmdHis_ + | Y-m-d-His_ + | Y_m_d_His_ + | + */ public $timestampFormat = 'Y-m-d-His_'; } diff --git a/app/Config/Mimes.php b/app/Config/Mimes.php index 0e246852..ac5c7f46 100644 --- a/app/Config/Mimes.php +++ b/app/Config/Mimes.php @@ -1,4 +1,6 @@ - 'CodeIgniter\Pager\Views\default_full', 'default_simple' => 'CodeIgniter\Pager\Views\default_simple', @@ -24,12 +26,12 @@ class Pager extends BaseConfig ]; /* - |-------------------------------------------------------------------------- - | Items Per Page - |-------------------------------------------------------------------------- - | - | The default number of results shown in a single page. - | - */ + |-------------------------------------------------------------------------- + | Items Per Page + |-------------------------------------------------------------------------- + | + | The default number of results shown in a single page. + | + */ public $perPage = 20; } diff --git a/app/Config/Paths.php b/app/Config/Paths.php index f574dad5..79c3408f 100644 --- a/app/Config/Paths.php +++ b/app/Config/Paths.php @@ -1,4 +1,6 @@ - 'Windows 10', 'windows nt 6.3' => 'Windows 8.1', diff --git a/app/Config/Validation.php b/app/Config/Validation.php index d93c623f..25ec0ce8 100644 --- a/app/Config/Validation.php +++ b/app/Config/Validation.php @@ -1,4 +1,6 @@ -back() ->withInput() - ->with('errors', [lang('Contributor.alreadyAddedError')]); + ->with('errors', [ + lang('Contributor.messages.alreadyAddedError'), + ]); } return redirect()->route('contributor_list', [$this->podcast->id]); @@ -77,7 +80,7 @@ class Contributor extends BaseController $data = [ 'podcast' => $this->podcast, 'user' => $this->user, - 'contributor_group_id' => (new PodcastModel())->getContributorGroupId( + 'contributorGroupId' => (new PodcastModel())->getContributorGroupId( $this->user->id, $this->podcast->id ), @@ -104,27 +107,27 @@ class Contributor extends BaseController return redirect() ->back() ->with('errors', [ - lang('Contributor.removeOwnerContributorError'), + lang('Contributor.messages.removeOwnerContributorError'), ]); } - $podcast_model = new PodcastModel(); + $podcastModel = new PodcastModel(); if ( - !$podcast_model->removePodcastContributor( + !$podcastModel->removePodcastContributor( $this->user->id, $this->podcast->id ) ) { return redirect() ->back() - ->with('errors', $podcast_model->errors()); + ->with('errors', $podcastModel->errors()); } return redirect() ->back() ->with( 'message', - lang('Contributor.removeContributorSuccess', [ + lang('Contributor.messages.removeContributorSuccess', [ 'username' => $this->user->username, 'podcastTitle' => $this->podcast->title, ]) diff --git a/app/Controllers/Admin/Episode.php b/app/Controllers/Admin/Episode.php index 74efa436..0c5ce4c2 100644 --- a/app/Controllers/Admin/Episode.php +++ b/app/Controllers/Admin/Episode.php @@ -1,4 +1,5 @@ podcast = (new PodcastModel())->find($params[0]); if (count($params) > 1) { - $episode_model = new EpisodeModel(); if ( - !($this->episode = $episode_model + !($this->episode = (new EpisodeModel()) ->where([ 'id' => $params[1], 'podcast_id' => $params[0], @@ -78,7 +78,7 @@ class Episode extends BaseController ->with('errors', $this->validator->getErrors()); } - $new_episode = new \App\Entities\Episode([ + $newEpisode = new \App\Entities\Episode([ 'podcast_id' => $this->podcast->id, 'title' => $this->request->getPost('title'), 'slug' => $this->request->getPost('slug'), @@ -95,13 +95,13 @@ class Episode extends BaseController 'block' => (bool) $this->request->getPost('block'), ]); - $episode_model = new EpisodeModel(); + $episodeModel = new EpisodeModel(); - if (!$episode_model->save($new_episode)) { + if (!$episodeModel->save($newEpisode)) { return redirect() ->back() ->withInput() - ->with('errors', $episode_model->errors()); + ->with('errors', $episodeModel->errors()); } return redirect()->route('episode_list', [$this->podcast->id]); @@ -112,7 +112,6 @@ class Episode extends BaseController helper(['form']); $data = [ - 'podcast' => $this->podcast, 'episode' => $this->episode, ]; @@ -158,13 +157,13 @@ class Episode extends BaseController $this->episode->image = $image; } - $episode_model = new EpisodeModel(); + $episodeModel = new EpisodeModel(); - if (!$episode_model->save($this->episode)) { + if (!$episodeModel->save($this->episode)) { return redirect() ->back() ->withInput() - ->with('errors', $episode_model->errors()); + ->with('errors', $episodeModel->errors()); } return redirect()->route('episode_list', [$this->podcast->id]); @@ -172,8 +171,7 @@ class Episode extends BaseController public function delete() { - $episode_model = new EpisodeModel(); - $episode_model->delete($this->episode->id); + (new EpisodeModel())->delete($this->episode->id); return redirect()->route('episode_list', [$this->podcast->id]); } diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index 6e3b80aa..a1db30a7 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -1,4 +1,5 @@ back() ->withInput() - ->with('errors', $user_model->errors()); + ->with('errors', $userModel->errors()); } $credentials = [ @@ -52,22 +53,22 @@ class Myaccount extends BaseController return redirect() ->back() ->withInput() - ->with('errors', $user_model->errors()); + ->with('errors', $userModel->errors()); } user()->password = $this->request->getPost('new_password'); - $user_model->save(user()); + $userModel->save(user()); - if (!$user_model->save(user())) { + if (!$userModel->save(user())) { return redirect() ->back() ->withInput() - ->with('errors', $user_model->errors()); + ->with('errors', $userModel->errors()); } // Success! return redirect() ->route('myAccount') - ->with('message', lang('MyAccount.passwordChangeSuccess')); + ->with('message', lang('MyAccount.messages.passwordChangeSuccess')); } } diff --git a/app/Controllers/Admin/Podcast.php b/app/Controllers/Admin/Podcast.php index 4b99340c..99209e07 100644 --- a/app/Controllers/Admin/Podcast.php +++ b/app/Controllers/Admin/Podcast.php @@ -1,9 +1,11 @@ (new PodcastModel())->getUserPodcasts(user()->id), + 'podcasts' => (new PodcastModel())->getUserPodcasts(user()->id), ]; return view('admin/podcast/list', $data); @@ -41,7 +43,7 @@ class Podcast extends BaseController return redirect()->route('my_podcasts'); } - $data = ['all_podcasts' => (new PodcastModel())->findAll()]; + $data = ['podcasts' => (new PodcastModel())->findAll()]; return view('admin/podcast/list', $data); } @@ -62,7 +64,7 @@ class Podcast extends BaseController $data = [ 'languages' => $languageModel->findAll(), 'categories' => $categoryModel->findAll(), - 'browser_lang' => get_browser_language( + 'browserLang' => get_browser_language( $this->request->getServer('HTTP_ACCEPT_LANGUAGE') ), ]; @@ -106,26 +108,26 @@ class Podcast extends BaseController 'custom_html_head' => $this->request->getPost('custom_html_head'), ]); - $podcast_model = new PodcastModel(); + $podcastModel = new PodcastModel(); $db = \Config\Database::connect(); $db->transStart(); - if (!($new_podcast_id = $podcast_model->insert($podcast, true))) { + if (!($newPodcastId = $podcastModel->insert($podcast, true))) { $db->transComplete(); return redirect() ->back() ->withInput() - ->with('errors', $podcast_model->errors()); + ->with('errors', $podcastModel->errors()); } $authorize = Services::authorization(); - $podcast_admin_group = $authorize->group('podcast_admin'); + $podcastAdminGroup = $authorize->group('podcast_admin'); - $podcast_model->addPodcastContributor( + $podcastModel->addPodcastContributor( user()->id, - $new_podcast_id, - $podcast_admin_group->id + $newPodcastId, + $podcastAdminGroup->id ); $db->transComplete(); @@ -137,12 +139,10 @@ class Podcast extends BaseController { helper('form'); - $languageModel = new LanguageModel(); - $categoryModel = new CategoryModel(); $data = [ 'podcast' => $this->podcast, - 'languages' => $languageModel->findAll(), - 'categories' => $categoryModel->findAll(), + 'languages' => (new LanguageModel())->findAll(), + 'categories' => (new CategoryModel())->findAll(), ]; echo view('admin/podcast/edit', $data); @@ -188,13 +188,13 @@ class Podcast extends BaseController 'custom_html_head' ); - $podcast_model = new PodcastModel(); + $podcastModel = new PodcastModel(); - if (!$podcast_model->save($this->podcast)) { + if (!$podcastModel->save($this->podcast)) { return redirect() ->back() ->withInput() - ->with('errors', $podcast_model->errors()); + ->with('errors', $podcastModel->errors()); } return redirect()->route('podcast_list'); @@ -202,8 +202,7 @@ class Podcast extends BaseController public function delete() { - $podcast_model = new PodcastModel(); - $podcast_model->delete($this->podcast->id); + (new PodcastModel())->delete($this->podcast->id); return redirect()->route('podcast_list'); } diff --git a/app/Controllers/Admin/User.php b/app/Controllers/Admin/User.php index f958fe2e..98470cf1 100644 --- a/app/Controllers/Admin/User.php +++ b/app/Controllers/Admin/User.php @@ -1,4 +1,5 @@ 0) { - $user_model = new UserModel(); - if (!($this->user = $user_model->find($params[0]))) { + if (!($this->user = (new UserModel())->find($params[0]))) { throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); } } @@ -29,7 +29,7 @@ class User extends BaseController public function list() { - $data = ['all_users' => (new UserModel())->findAll()]; + $data = ['users' => (new UserModel())->findAll()]; return view('admin/user/list', $data); } @@ -45,12 +45,12 @@ class User extends BaseController public function attemptCreate() { - $user_model = new UserModel(); + $userModel = new UserModel(); // Validate here first, since some things, // like the password, can only be validated properly here. $rules = array_merge( - $user_model->getValidationRules(['only' => ['username']]), + $userModel->getValidationRules(['only' => ['username']]), [ 'email' => 'required|valid_email|is_unique[users.email]', 'password' => 'required|strong_password', @@ -74,11 +74,11 @@ class User extends BaseController // Force user to reset his password on first connection $user->forcePasswordReset(); - if (!$user_model->save($user)) { + if (!$userModel->save($user)) { return redirect() ->back() ->withInput() - ->with('errors', $user_model->errors()); + ->with('errors', $userModel->errors()); } // Success! @@ -86,7 +86,7 @@ class User extends BaseController ->route('user_list') ->with( 'message', - lang('User.createSuccess', [ + lang('User.messages.createSuccess', [ 'username' => $user->username, ]) ); @@ -114,7 +114,7 @@ class User extends BaseController ->route('user_list') ->with( 'message', - lang('User.rolesEditSuccess', [ + lang('User.messages.rolesEditSuccess', [ 'username' => $this->user->username, ]) ); @@ -122,13 +122,13 @@ class User extends BaseController public function forcePassReset() { - $user_model = new UserModel(); + $userModel = new UserModel(); $this->user->forcePasswordReset(); - if (!$user_model->save($this->user)) { + if (!$userModel->save($this->user)) { return redirect() ->back() - ->with('errors', $user_model->errors()); + ->with('errors', $userModel->errors()); } // Success! @@ -136,7 +136,7 @@ class User extends BaseController ->route('user_list') ->with( 'message', - lang('User.forcePassResetSuccess', [ + lang('User.messages.forcePassResetSuccess', [ 'username' => $this->user->username, ]) ); @@ -149,27 +149,27 @@ class User extends BaseController return redirect() ->back() ->with('errors', [ - lang('User.banSuperAdminError', [ + lang('User.messages.banSuperAdminError', [ 'username' => $this->user->username, ]), ]); } - $user_model = new UserModel(); + $userModel = new UserModel(); // TODO: add ban reason? $this->user->ban(''); - if (!$user_model->save($this->user)) { + if (!$userModel->save($this->user)) { return redirect() ->back() - ->with('errors', $user_model->errors()); + ->with('errors', $userModel->errors()); } return redirect() ->route('user_list') ->with( 'message', - lang('User.banSuccess', [ + lang('User.messages.banSuccess', [ 'username' => $this->user->username, ]) ); @@ -177,20 +177,20 @@ class User extends BaseController public function unBan() { - $user_model = new UserModel(); + $userModel = new UserModel(); $this->user->unBan(); - if (!$user_model->save($this->user)) { + if (!$userModel->save($this->user)) { return redirect() ->back() - ->with('errors', $user_model->errors()); + ->with('errors', $userModel->errors()); } return redirect() ->route('user_list') ->with( 'message', - lang('User.unbanSuccess', [ + lang('User.messages.unbanSuccess', [ 'username' => $this->user->username, ]) ); @@ -203,20 +203,19 @@ class User extends BaseController return redirect() ->back() ->with('errors', [ - lang('User.deleteSuperAdminError', [ + lang('User.messages.deleteSuperAdminError', [ 'username' => $this->user->username, ]), ]); } - $user_model = new UserModel(); - $user_model->delete($this->user->id); + (new UserModel())->delete($this->user->id); return redirect() ->back() ->with( 'message', - lang('User.deleteSuccess', [ + lang('User.messages.deleteSuccess', [ 'username' => $this->user->username, ]) ); diff --git a/app/Controllers/Analytics.php b/app/Controllers/Analytics.php index 9a2621c2..d9c82d31 100644 --- a/app/Controllers/Analytics.php +++ b/app/Controllers/Analytics.php @@ -1,4 +1,5 @@ to(media_url(implode('/', $filename))); } } diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 58cd1276..895838ca 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -50,8 +50,8 @@ class BaseController extends Controller set_user_session_referer(); } - protected static function triggerWebpageHit($postcast_id) + protected static function triggerWebpageHit($podcastId) { - webpage_hit($postcast_id); + webpage_hit($podcastId); } } diff --git a/app/Controllers/Episode.php b/app/Controllers/Episode.php index b5174ad6..d3fc965f 100644 --- a/app/Controllers/Episode.php +++ b/app/Controllers/Episode.php @@ -1,4 +1,5 @@ podcast = (new PodcastModel()) + ->where('name', $params[0]) + ->first(); - $this->podcast = $podcast_model->where('name', $params[0])->first(); - - if (count($params) > 1) { - $episode_model = new EpisodeModel(); - if ( - !($this->episode = $episode_model - ->where([ - 'podcast_id' => $this->podcast->id, - 'slug' => $params[1], - ]) - ->first()) - ) { - throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); - } + if ( + count($params) > 1 && + !($this->episode = (new EpisodeModel()) + ->where([ + 'podcast_id' => $this->podcast->id, + 'slug' => $params[1], + ]) + ->first()) + ) { + throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); } return $this->$method(); diff --git a/app/Controllers/Feed.php b/app/Controllers/Feed.php index 48064d0a..a739a793 100644 --- a/app/Controllers/Feed.php +++ b/app/Controllers/Feed.php @@ -1,4 +1,5 @@ where('name', $podcast_name)->first(); - // The page cache is set to a decade so it is deleted manually upon podcast update $this->cachePage(DECADE); + helper('rss'); + + $podcast = (new PodcastModel())->where('name', $podcastName)->first(); + return $this->response->setXML(get_rss_feed($podcast)); } } diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 0f9ca24f..7f8aad52 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -1,4 +1,5 @@ findAll(); + $allPodcasts = $model->findAll(); // check if there's only one podcast to redirect user to it - if (count($all_podcasts) == 1) { - return redirect()->route('podcast', [$all_podcasts[0]->name]); + if (count($allPodcasts) == 1) { + return redirect()->route('podcast', [$allPodcasts[0]->name]); } // default behavior: list all podcasts on home page - $data = ['podcasts' => $all_podcasts]; + $data = ['podcasts' => $allPodcasts]; return view('home', $data); } } diff --git a/app/Controllers/Migrate.php b/app/Controllers/Migrate.php index 0155b49b..6cf2b699 100644 --- a/app/Controllers/Migrate.php +++ b/app/Controllers/Migrate.php @@ -1,4 +1,5 @@ 0) { - $podcast_model = new PodcastModel(); if ( - !($this->podcast = $podcast_model + !($this->podcast = (new PodcastModel()) ->where('name', $params[0]) ->first()) ) { diff --git a/app/Controllers/UnknownUserAgents.php b/app/Controllers/UnknownUserAgents.php index 3eb28471..94718725 100644 --- a/app/Controllers/UnknownUserAgents.php +++ b/app/Controllers/UnknownUserAgents.php @@ -1,4 +1,5 @@ response->setJSON($model->getUserAgents($last_known_id)); + return $this->response->setJSON($model->getUserAgents($lastKnownId)); } } diff --git a/app/Database/Migrations/2020-05-29-152000_add_categories.php b/app/Database/Migrations/2020-05-29-152000_add_categories.php index 717adc42..576a8daa 100644 --- a/app/Database/Migrations/2020-05-29-152000_add_categories.php +++ b/app/Database/Migrations/2020-05-29-152000_add_categories.php @@ -1,4 +1,5 @@ groups as $group) { - array_push($data_groups, [ - 'id' => ++$group_id, + array_push($dataGroups, [ + 'id' => ++$groupId, 'name' => $group['name'], 'description' => $group['description'], ]); } // Map permissions to a format the `auth_permissions` table expects - $data_permissions = []; - $data_groups_permissions = []; - $permission_id = 0; + $dataPermissions = []; + $dataGroupsPermissions = []; + $permissionId = 0; foreach ($this->permissions as $context => $actions) { foreach ($actions as $action) { - array_push($data_permissions, [ - 'id' => ++$permission_id, + array_push($dataPermissions, [ + 'id' => ++$permissionId, 'name' => $context . '-' . $action['name'], 'description' => $action['description'], ]); foreach ($action['has_permission'] as $role) { // link permission to specified groups - array_push($data_groups_permissions, [ + array_push($dataGroupsPermissions, [ 'group_id' => $this->getGroupIdByName( $role, - $data_groups + $dataGroups ), - 'permission_id' => $permission_id, + 'permission_id' => $permissionId, ]); } } } - $this->db->table('auth_permissions')->insertBatch($data_permissions); - $this->db->table('auth_groups')->insertBatch($data_groups); + $this->db->table('auth_permissions')->insertBatch($dataPermissions); + $this->db->table('auth_groups')->insertBatch($dataGroups); $this->db ->table('auth_groups_permissions') - ->insertBatch($data_groups_permissions); + ->insertBatch($dataGroupsPermissions); } } diff --git a/app/Database/Seeds/CategorySeeder.php b/app/Database/Seeds/CategorySeeder.php index d256acc5..a6211398 100644 --- a/app/Database/Seeds/CategorySeeder.php +++ b/app/Database/Seeds/CategorySeeder.php @@ -1,4 +1,5 @@ db->table('users')->insert([ 'id' => 1, 'username' => 'admin', - 'email' => 'admin@castopod.com', + 'email' => 'admin@example.com', 'password_hash' => '$2y$10$TXJEHX/djW8jtzgpDVf7dOOCGo5rv1uqtAYWdwwwkttQcDkAeB2.6', 'active' => 1, diff --git a/app/Entities/AnalyticsEpisodesByCountry.php b/app/Entities/AnalyticsEpisodesByCountry.php index b22542b2..b1736443 100644 --- a/app/Entities/AnalyticsEpisodesByCountry.php +++ b/app/Entities/AnalyticsEpisodesByCountry.php @@ -1,4 +1,5 @@ attributes['parent_id']; + $parentId = $this->attributes['parent_id']; - return $parent_id != 0 - ? $category_model->find($this->attributes['parent_id']) + return $parentId != 0 + ? (new CategoryModel())->findParent($parentId) : null; } } diff --git a/app/Entities/Episode.php b/app/Entities/Episode.php index a8268f32..0bf553fa 100644 --- a/app/Entities/Episode.php +++ b/app/Entities/Episode.php @@ -1,4 +1,5 @@ isValid()) { + if (!empty($image) && $image->isValid()) { // check whether the user has inputted an image and store it $this->attributes['image_uri'] = save_podcast_media( $image, @@ -68,17 +69,17 @@ class Episode extends Entity return $this; } - public function getImage() + public function getImage(): \CodeIgniter\Files\File { return new \CodeIgniter\Files\File($this->getImageMediaPath()); } - public function getImageMediaPath() + public function getImageMediaPath(): string { return media_path($this->attributes['image_uri']); } - public function getImageUrl() + public function getImageUrl(): string { if ($image_uri = $this->attributes['image_uri']) { return media_url($image_uri); @@ -89,7 +90,7 @@ class Episode extends Entity public function setEnclosure( \CodeIgniter\HTTP\Files\UploadedFile $enclosure = null ) { - if ($enclosure->isValid()) { + if (!empty($enclosure) && $enclosure->isValid()) { helper('media'); $this->attributes['enclosure_uri'] = save_podcast_media( @@ -151,26 +152,25 @@ class Episode extends Entity public function getPodcast() { - $podcast_model = new PodcastModel(); - - return $podcast_model->find($this->attributes['podcast_id']); + return (new PodcastModel())->find($this->attributes['podcast_id']); } public function getDescriptionHtml() { - $converter = new Parsedown(); - $converter->setBreaksEnabled(true); + $converter = new CommonMarkConverter([ + 'html_input' => 'strip', + 'allow_unsafe_links' => false, + ]); if ( - $description_footer = $this->getPodcast() - ->episode_description_footer + $descriptionFooter = $this->getPodcast()->episode_description_footer ) { - return $converter->text($this->attributes['description']) . + return $converter->convertToHtml($this->attributes['description']) . ''; } - return $converter->text($this->attributes['description']); + return $converter->convertToHtml($this->attributes['description']); } } diff --git a/app/Entities/Language.php b/app/Entities/Language.php index f2b91440..aa683fd7 100644 --- a/app/Entities/Language.php +++ b/app/Entities/Language.php @@ -1,4 +1,5 @@ setBreaksEnabled(true); + $converter = new CommonMarkConverter([ + 'html_input' => 'strip', + 'allow_unsafe_links' => false, + ]); - return $converter->text($this->attributes['description']); + return $converter->convertToHtml($this->attributes['description']); } } diff --git a/app/Entities/User.php b/app/Entities/User.php index 3277fdcb..f710fd06 100644 --- a/app/Entities/User.php +++ b/app/Entities/User.php @@ -1,4 +1,6 @@ - 0 ) { if ( - $group_id = (new PodcastModel())->getContributorGroupId( + $groupId = (new PodcastModel())->getContributorGroupId( $authenticate->id(), $routerParams[0] ) ) { - if ( - $authorize->groupHasPermission($permission, $group_id) - ) { + if ($authorize->groupHasPermission($permission, $groupId)) { $result = true; break; } diff --git a/app/Helpers/analytics_helper.php b/app/Helpers/analytics_helper.php index 90282c2a..5c02363d 100644 --- a/app/Helpers/analytics_helper.php +++ b/app/Helpers/analytics_helper.php @@ -1,5 +1,5 @@ - 'Dashboard', - 'podcasts' => 'Podcasts', - 'users' => 'Users', - 'admin_home' => 'Home', - 'my_podcasts' => 'My podcasts', - 'podcast_list' => 'All podcasts', - 'podcast_create' => 'New podcast', - 'user_list' => 'All users', - 'user_create' => 'New user', - 'go_to_website' => 'Go to website' - ]; \ No newline at end of file +return [ + 'dashboard' => 'Dashboard', + 'podcasts' => 'Podcasts', + 'users' => 'Users', + 'admin_home' => 'Home', + 'my_podcasts' => 'My podcasts', + 'podcast_list' => 'All podcasts', + 'podcast_create' => 'New podcast', + 'user_list' => 'All users', + 'user_create' => 'New user', + 'go_to_website' => 'Go to website', +]; diff --git a/app/Language/en/Contributor.php b/app/Language/en/Contributor.php index 57a8448a..a9bf108b 100644 --- a/app/Language/en/Contributor.php +++ b/app/Language/en/Contributor.php @@ -1,4 +1,5 @@ - 'You can\'t remove the podcast owner!', - 'removeContributorSuccess' => 'You have successfully removed {username} from {podcastTitle}', - 'alreadyAddedError' => 'The contributor you\'re trying to add has already been added!', 'podcast_contributors' => 'Podcast contributors', 'add' => 'Add contributor', 'add_contributor' => 'Add a contributor for {0}', @@ -19,6 +17,13 @@ return [ 'user' => 'User', 'role' => 'Role', 'submit_add' => 'Add contributor', - 'submit_edit' => 'Update role' - ] + 'submit_edit' => 'Update role', + ], + 'messages' => [ + 'removeOwnerContributorError' => 'You can\'t remove the podcast owner!', + 'removeContributorSuccess' => + 'You have successfully removed {username} from {podcastTitle}', + 'alreadyAddedError' => + 'The contributor you\'re trying to add has already been added!', + ], ]; diff --git a/app/Language/en/Countries.php b/app/Language/en/Countries.php index 9bd81808..ba399019 100644 --- a/app/Language/en/Countries.php +++ b/app/Language/en/Countries.php @@ -1,4 +1,5 @@ - 'South Africa', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe', -]; \ No newline at end of file +]; diff --git a/app/Language/en/Episode.php b/app/Language/en/Episode.php index 80ae2df6..f9613bd4 100644 --- a/app/Language/en/Episode.php +++ b/app/Language/en/Episode.php @@ -1,4 +1,5 @@ - 'Go back to podcast', 'edit' => 'Edit', 'delete' => 'Delete', - 'goto_page' => 'Go to page', + 'go_to_page' => 'Go to page', 'create' => 'Add an episode', 'form' => [ 'file' => 'Audio file', @@ -33,5 +34,5 @@ return [ 'block' => 'Block', 'submit_create' => 'Create episode', 'submit_edit' => 'Save episode', - ] -]; \ No newline at end of file + ], +]; diff --git a/app/Language/en/Home.php b/app/Language/en/Home.php index 435307ef..ee188805 100644 --- a/app/Language/en/Home.php +++ b/app/Language/en/Home.php @@ -1,4 +1,5 @@ - 'Password has been successfully changed!', - 'changePassword' => 'Change my password', - 'info' => 'My account info' + 'info' => 'My account info', + 'messages' => [ + 'passwordChangeSuccess' => 'Password has been successfully changed!', + 'changePassword' => 'Change my password', + ], ]; diff --git a/app/Language/en/Podcast.php b/app/Language/en/Podcast.php index 2cad3845..d69514bf 100644 --- a/app/Language/en/Podcast.php +++ b/app/Language/en/Podcast.php @@ -1,4 +1,5 @@ - 'Delete podcast', 'see_episodes' => 'See episodes', 'see_contributors' => 'See contributors', - 'goto_page' => 'Go to page', + 'go_to_page' => 'Go to page', 'form' => [ 'title' => 'Title', 'name' => 'Name', @@ -156,5 +157,5 @@ return [ 'tv_reviews' => 'TV Reviews', ], 'list_of_episodes' => 'List of episodes', - 'no_episode' => 'No episode found' -]; \ No newline at end of file + 'no_episode' => 'No episode found', +]; diff --git a/app/Language/en/User.php b/app/Language/en/User.php index aa5491c0..2cdc1e33 100644 --- a/app/Language/en/User.php +++ b/app/Language/en/User.php @@ -1,4 +1,5 @@ - 'User created successfully! {username} will be prompted with a password reset upon first authentication.', - 'rolesEditSuccess' => '{username}\'s roles have been successfully updated.', - 'forcePassResetSuccess' => '{username} will be prompted with a password reset upon next visit.', - 'banSuccess' => '{username} has been banned.', - 'unbanSuccess' => '{username} has been unbanned.', - 'banSuperAdminError' => '{username} is a superadmin, one does not simply ban a superadmin…', - 'deleteSuperAdminError' => '{username} is a superadmin, one does not simply delete a superadmin…', - 'deleteSuccess' => '{username} has been deleted.', 'edit_roles' => 'Edit {username}\'s roles', 'forcePassReset' => 'Force pass reset', 'ban' => 'Ban', @@ -31,5 +24,20 @@ return [ 'roles' => 'Roles', 'submit_create' => 'Create user', 'submit_edit' => 'Save', - ] + ], + 'messages' => [ + 'createSuccess' => + 'User created successfully! {username} will be prompted with a password reset upon first authentication.', + 'rolesEditSuccess' => + '{username}\'s roles have been successfully updated.', + 'forcePassResetSuccess' => + '{username} will be prompted with a password reset upon next visit.', + 'banSuccess' => '{username} has been banned.', + 'unbanSuccess' => '{username} has been unbanned.', + 'banSuperAdminError' => + '{username} is a superadmin, one does not simply ban a superadmin…', + 'deleteSuperAdminError' => + '{username} is a superadmin, one does not simply delete a superadmin…', + 'deleteSuccess' => '{username} has been deleted.', + ], ]; diff --git a/app/Language/fr/Countries.php b/app/Language/fr/Countries.php index 8b25fff7..48b36541 100644 --- a/app/Language/fr/Countries.php +++ b/app/Language/fr/Countries.php @@ -1,4 +1,5 @@ - 'Afghanistan', +return [ + 'AF ' => 'Afghanistan', 'ZA ' => 'Afrique Du Sud', 'AX ' => 'Åland, Îles', 'AL ' => 'Albanie', @@ -256,4 +258,4 @@ return ['AF ' => 'Afghanistan', 'YE ' => 'Yémen', 'ZM ' => 'Zambie', 'ZW ' => 'Zimbabwe', -]; \ No newline at end of file +]; diff --git a/app/Libraries/SimpleRSSElement.php b/app/Libraries/SimpleRSSElement.php index c5211e9b..1d70a394 100644 --- a/app/Libraries/SimpleRSSElement.php +++ b/app/Libraries/SimpleRSSElement.php @@ -1,10 +1,15 @@ find($parentId); + } } diff --git a/app/Models/EpisodeModel.php b/app/Models/EpisodeModel.php index eb372fa4..9514abec 100644 --- a/app/Models/EpisodeModel.php +++ b/app/Models/EpisodeModel.php @@ -1,4 +1,5 @@ find( + $episode = (new EpisodeModel())->find( is_array($data['id']) ? $data['id'][0] : $data['id'] ); @@ -69,7 +71,7 @@ class EpisodeModel extends Model protected function clearCache(array $data) { - $episode = $this->find( + $episode = (new EpisodeModel())->find( is_array($data['id']) ? $data['id'][0] : $data['id'] ); @@ -80,6 +82,8 @@ class EpisodeModel extends Model // delete model requests cache cache()->delete("{$episode->podcast_id}_episodes"); + + return $data; } /** diff --git a/app/Models/LanguageModel.php b/app/Models/LanguageModel.php index 98143567..f89f5965 100644 --- a/app/Models/LanguageModel.php +++ b/app/Models/LanguageModel.php @@ -1,4 +1,5 @@ find( + $podcast = (new PodcastModel())->find( is_array($data['id']) ? $data['id'][0] : $data['id'] ); // delete cache for rss feed and podcast pages cache()->delete(md5($podcast->feed_url)); cache()->delete(md5($podcast->link)); - // TODO: clear cache for every podcast's episode page? - // foreach ($podcast->episodes as $episode) { - // cache()->delete(md5($episode->link)); - // } - $data['podcast'] = $podcast; + // clear cache for every podcast's episode page? + foreach ($podcast->episodes as $episode) { + cache()->delete(md5($episode->link)); + } return $data; } diff --git a/app/Models/UnknownUserAgentsModel.php b/app/Models/UnknownUserAgentsModel.php index 5cd0b71b..5afabf5d 100644 --- a/app/Models/UnknownUserAgentsModel.php +++ b/app/Models/UnknownUserAgentsModel.php @@ -1,4 +1,5 @@ where('id>', $last_known_id)->findAll(); + return $this->where('id >', $last_known_id)->findAll(); } } diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 876cc947..420c002d 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -1,10 +1,10 @@ - - - Castopod - - - - - - custom_html_head ?> - + + Castopod + + + + + + custom_html_head ?> + -
-
- Castopod -
-
-
- renderSection('content') ?> -
- +
+
+ Castopod +
+
+
+ renderSection('content') ?> +
+ diff --git a/app/Views/_message_block.php b/app/Views/_message_block.php index 2504c211..f086baf6 100644 --- a/app/Views/_message_block.php +++ b/app/Views/_message_block.php @@ -1,16 +1,17 @@ has('message')): ?> -
- -
+
+ +
has('error')): ?> -
- -
+
+ +
has('errors')): ?> +<<<<<<< HEAD +======= + + +>>>>>>> ef31ffe... refactor: add php_codesniffer to define castopod's coding style based on psr-1 diff --git a/app/Views/admin/_layout.php b/app/Views/admin/_layout.php index a2d2a763..75b11ac5 100644 --- a/app/Views/admin/_layout.php +++ b/app/Views/admin/_layout.php @@ -1,33 +1,35 @@ - + - - Castopod Admin - - - - - + + Castopod Admin + + + + + - 'flex items-center px-4 py-2 holy-grail-header', - ]) ?> - 'flex flex-col w-64 py-6 holy-grail-sidenav', - ]) ?> -
-

renderSection('title') ?>

- - renderSection('content') ?> -
- + 'flex items-center px-4 py-2 holy-grail-header', + ]) ?> + 'flex flex-col w-64 py-6 holy-grail-sidenav', + ]) ?> +
+

renderSection('title') ?>

+ + renderSection('content') ?> +
+ - + diff --git a/app/Views/admin/_partials/_episode-card.php b/app/Views/admin/_partials/_episode-card.php index 6bdfede8..baf0b567 100644 --- a/app/Views/admin/_partials/_episode-card.php +++ b/app/Views/admin/_partials/_episode-card.php @@ -1,4 +1,6 @@ - +
<?= $episode->title ?> @@ -27,7 +29,7 @@ 'episode', $episode->podcast->id, $episode->slug - ) ?>"> + ) ?>"> diff --git a/app/Views/admin/episode/create.php b/app/Views/admin/episode/create.php index 0238c0fa..1651f833 100644 --- a/app/Views/admin/episode/create.php +++ b/app/Views/admin/episode/create.php @@ -97,19 +97,19 @@ !old('type') || old('type') == 'full' ): ?> checked /> - + diff --git a/app/Views/admin/episode/edit.php b/app/Views/admin/episode/edit.php index 54b49fd4..4128b906 100644 --- a/app/Views/admin/episode/edit.php +++ b/app/Views/admin/episode/edit.php @@ -7,10 +7,13 @@ section('content') ?> -id, $episode->id), [ - 'method' => 'post', - 'class' => 'flex flex-col max-w-md', -]) ?> +podcast->id, $episode->id), + [ + 'method' => 'post', + 'class' => 'flex flex-col max-w-md', + ] +) ?>
diff --git a/app/Views/admin/episode/view.php b/app/Views/admin/episode/view.php index e54cc0d4..5bea39c4 100644 --- a/app/Views/admin/episode/view.php +++ b/app/Views/admin/episode/view.php @@ -20,10 +20,10 @@ ) ?>"> @@ -15,8 +15,8 @@ section('content') ?>
- - + + $podcast, ]) ?> diff --git a/app/Views/admin/podcast/view.php b/app/Views/admin/podcast/view.php index b0af9c9d..9a781031 100644 --- a/app/Views/admin/podcast/view.php +++ b/app/Views/admin/podcast/view.php @@ -1,4 +1,6 @@ - + extend('admin/_layout') ?> @@ -28,7 +30,7 @@ + ) ?>"> username ?> email ?> diff --git a/app/Views/auth/login.php b/app/Views/auth/login.php index 2d7fcee1..106851d0 100644 --- a/app/Views/auth/login.php +++ b/app/Views/auth/login.php @@ -1,28 +1,28 @@ extend($config->viewLayout) ?> section('title') ?> - + endSection() ?> section('content') ?>
- + - - + + - - + + - +
endSection() ?> @@ -31,14 +31,14 @@ section('footer') ?>
- allowRegistration): ?> - - - + allowRegistration): ?> + + +
endSection() ?> diff --git a/app/Views/errors/cli/error_exception.php b/app/Views/errors/cli/error_exception.php index a91a3f6a..1ad33d06 100644 --- a/app/Views/errors/cli/error_exception.php +++ b/app/Views/errors/cli/error_exception.php @@ -6,14 +6,18 @@ Filename: getFile(), "\n" ?> Line Number: getLine() ?> - - Backtrace: - getTrace() as $error): ?> - - - - + Backtrace: + getTrace() as $error): ?> + + + + diff --git a/app/Views/errors/html/debug.css b/app/Views/errors/html/debug.css index e526b24f..6595eedb 100644 --- a/app/Views/errors/html/debug.css +++ b/app/Views/errors/html/debug.css @@ -1,176 +1,177 @@ body { - height: 100%; - background: #fafafa; - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - color: #777; - font-weight: 300; - margin: 0; - padding: 0; + height: 100%; + background: #fafafa; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #777; + font-weight: 300; + margin: 0; + padding: 0; } h1 { - font-weight: lighter; - letter-spacing: 0.8; - font-size: 3rem; - color: #222; - margin: 0; + font-weight: lighter; + letter-spacing: 0.8; + font-size: 3rem; + color: #222; + margin: 0; } h1.headline { - margin-top: 20%; - font-size: 5rem; + margin-top: 20%; + font-size: 5rem; } .text-center { - text-align: center; + text-align: center; } p.lead { - font-size: 1.6rem; + font-size: 1.6rem; } .container { - max-width: 75rem; - margin: 0 auto; - padding: 1rem; + max-width: 75rem; + margin: 0 auto; + padding: 1rem; } .header { - background: #85271f; - color: #fff; + background: #85271f; + color: #fff; } .header h1 { - color: #fff; + color: #fff; } .header p { - font-size: 1.2rem; - margin: 0; - line-height: 2.5; + font-size: 1.2rem; + margin: 0; + line-height: 2.5; } .header a { - color: rgba(255,255,255,0.5); - margin-left: 2rem; - display: none; - text-decoration: none; + color: rgba(255, 255, 255, 0.5); + margin-left: 2rem; + display: none; + text-decoration: none; } .header:hover a { - display: inline; + display: inline; } .footer .container { - border-top: 1px solid #e7e7e7; - margin-top: 1rem; - text-align: center; + border-top: 1px solid #e7e7e7; + margin-top: 1rem; + text-align: center; } .source { - background: #333; - color: #c7c7c7; - padding: 0.5em 1em; - border-radius: 5px; - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - margin: 0; + background: #333; + color: #c7c7c7; + padding: 0.5em 1em; + border-radius: 5px; + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + margin: 0; } .source span.line { - line-height: 1.4; + line-height: 1.4; } .source span.line .number { - color: #666; + color: #666; } .source .line .highlight { - display: block; - background: #555; - color: #fff; + display: block; + background: #555; + color: #fff; } .source span.highlight .number { - color: #fff; + color: #fff; } .tabs { - list-style: none; - list-style-position: inside; - margin: 0; - padding: 0; - margin-bottom: -1px; + list-style: none; + list-style-position: inside; + margin: 0; + padding: 0; + margin-bottom: -1px; } .tabs li { - display: inline; + display: inline; } .tabs a:link, .tabs a:visited { - padding: 0rem 1rem; - line-height: 2.7; - text-decoration: none; - color: #a7a7a7; - background: #f1f1f1; - border: 1px solid #e7e7e7; - border-bottom: 0; - border-top-left-radius: 5px; - border-top-right-radius: 5px; - display: inline-block; + padding: 0rem 1rem; + line-height: 2.7; + text-decoration: none; + color: #a7a7a7; + background: #f1f1f1; + border: 1px solid #e7e7e7; + border-bottom: 0; + border-top-left-radius: 5px; + border-top-right-radius: 5px; + display: inline-block; } .tabs a:hover { - background: #e7e7e7; - border-color: #e1e1e1; + background: #e7e7e7; + border-color: #e1e1e1; } .tabs a.active { - background: #fff; + background: #fff; } .tab-content { - background: #fff; - border: 1px solid #efefef; + background: #fff; + border: 1px solid #efefef; } .content { - padding: 1rem; + padding: 1rem; } .hide { - display: none; + display: none; } .alert { - margin-top: 2rem; - display: block; - text-align: center; - line-height: 3.0; - background: #d9edf7; - border: 1px solid #bcdff1; - border-radius: 5px; - color: #31708f; + margin-top: 2rem; + display: block; + text-align: center; + line-height: 3; + background: #d9edf7; + border: 1px solid #bcdff1; + border-radius: 5px; + color: #31708f; } -ul, ol { - line-height: 1.8; +ul, +ol { + line-height: 1.8; } table { - width: 100%; - overflow: hidden; + width: 100%; + overflow: hidden; } th { - text-align: left; - border-bottom: 1px solid #e7e7e7; - padding-bottom: 0.5rem; + text-align: left; + border-bottom: 1px solid #e7e7e7; + padding-bottom: 0.5rem; } td { - padding: 0.2rem 0.5rem 0.2rem 0; + padding: 0.2rem 0.5rem 0.2rem 0; } tr:hover td { - background: #f1f1f1; + background: #f1f1f1; } td pre { - white-space: pre-wrap; + white-space: pre-wrap; } .trace a { - color: inherit; + color: inherit; } .trace table { - width: auto; + width: auto; } .trace tr td:first-child { - min-width: 5em; - font-weight: bold; + min-width: 5em; + font-weight: bold; } .trace td { - background: #e7e7e7; - padding: 0 1rem; + background: #e7e7e7; + padding: 0 1rem; } .trace td pre { - margin: 0; + margin: 0; } .args { - display: none; -} \ No newline at end of file + display: none; +} diff --git a/app/Views/errors/html/debug.js b/app/Views/errors/html/debug.js index 07e8124e..3428750f 100644 --- a/app/Views/errors/html/debug.js +++ b/app/Views/errors/html/debug.js @@ -2,107 +2,108 @@ // Tabs //-------------------------------------------------------------------- -var tabLinks = new Array(); -var contentDivs = new Array(); +var tabLinks = []; +var contentDivs = []; function init() { - - // Grab the tab links and content divs from the page - var tabListItems = document.getElementById('tabs').childNodes; - console.log(tabListItems); - for (var i = 0; i < tabListItems.length; i++) { - if (tabListItems[i].nodeName == "LI") { - var tabLink = getFirstChildWithTagName(tabListItems[i], 'A'); - var id = getHash(tabLink.getAttribute('href')); - tabLinks[id] = tabLink; - contentDivs[id] = document.getElementById(id); - } + // Grab the tab links and content divs from the page + var tabListItems = document.getElementById("tabs").childNodes; + console.log(tabListItems); + for (var i = 0; i < tabListItems.length; i++) { + if (tabListItems[i].nodeName == "LI") { + var tabLink = getFirstChildWithTagName(tabListItems[i], "A"); + var id = getHash(tabLink.getAttribute("href")); + tabLinks[id] = tabLink; + contentDivs[id] = document.getElementById(id); } + } - // Assign onclick events to the tab links, and - // highlight the first tab - var i = 0; + // Assign onclick events to the tab links, and + // highlight the first tab + var j = 0; - for (var id in tabLinks) { - tabLinks[id].onclick = showTab; - tabLinks[id].onfocus = function () { this.blur() }; - if (i == 0) { - tabLinks[id].className = 'active'; - } - i++; + for (id in tabLinks) { + tabLinks[id].onclick = showTab; + tabLinks[id].onfocus = function () { + this.blur(); + }; + if (j == 0) { + tabLinks[id].className = "active"; } + j++; + } - // Hide all content divs except the first - var i = 0; + // Hide all content divs except the first + var k = 0; - for (var id in contentDivs) { - if (i != 0) { - console.log(contentDivs[id]); - contentDivs[id].className = 'content hide'; - } - i++; + for (id in contentDivs) { + if (k != 0) { + console.log(contentDivs[id]); + contentDivs[id].className = "content hide"; } + k++; + } } //-------------------------------------------------------------------- function showTab() { - var selectedId = getHash(this.getAttribute('href')); + var selectedId = getHash(this.getAttribute("href")); - // Highlight the selected tab, and dim all others. - // Also show the selected content div, and hide all others. - for (var id in contentDivs) { - if (id == selectedId) { - tabLinks[id].className = 'active'; - contentDivs[id].className = 'content'; - } - else { - tabLinks[id].className = ''; - contentDivs[id].className = 'content hide'; - } + // Highlight the selected tab, and dim all others. + // Also show the selected content div, and hide all others. + for (var id in contentDivs) { + if (id == selectedId) { + tabLinks[id].className = "active"; + contentDivs[id].className = "content"; + } else { + tabLinks[id].className = ""; + contentDivs[id].className = "content hide"; } + } - // Stop the browser following the link - return false; + // Stop the browser following the link + return false; } //-------------------------------------------------------------------- function getFirstChildWithTagName(element, tagName) { - for (var i = 0; i < element.childNodes.length; i++) { - if (element.childNodes[i].nodeName == tagName) { - return element.childNodes[i]; - } + for (var i = 0; i < element.childNodes.length; i++) { + if (element.childNodes[i].nodeName == tagName) { + return element.childNodes[i]; } + } } //-------------------------------------------------------------------- function getHash(url) { - var hashPos = url.lastIndexOf('#'); - return url.substring(hashPos + 1); + var hashPos = url.lastIndexOf("#"); + return url.substring(hashPos + 1); } //-------------------------------------------------------------------- function toggle(elem) { - elem = document.getElementById(elem); + elem = document.getElementById(elem); - if (elem.style && elem.style['display']) { - // Only works with the "style" attr - var disp = elem.style['display']; - } - else if (elem.currentStyle) { - // For MSIE, naturally - var disp = elem.currentStyle['display']; - } - else if (window.getComputedStyle) { - // For most other browsers - var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display'); - } + var disp = ""; + if (elem.style && elem.style["display"]) { + // Only works with the "style" attr + disp = elem.style["display"]; + } else if (elem.currentStyle) { + // For MSIE, naturally + disp = elem.currentStyle["display"]; + } else if (window.getComputedStyle) { + // For most other browsers + disp = document.defaultView + .getComputedStyle(elem, null) + .getPropertyValue("display"); + } - // Toggle the state of the "display" style - elem.style.display = disp == 'block' ? 'none' : 'block'; + // Toggle the state of the "display" style + elem.style.display = disp == "block" ? "none" : "block"; - return false; -} \ No newline at end of file + return false; +} diff --git a/app/Views/errors/html/error_404.php b/app/Views/errors/html/error_404.php index 35017d33..a1f3f32f 100644 --- a/app/Views/errors/html/error_404.php +++ b/app/Views/errors/html/error_404.php @@ -2,94 +2,94 @@ - - 404 Page Not Found + + 404 Page Not Found - + a:active, + a:link, + a:visited { + color: #dd4814; + } + -
-

404 - File Not Found

+
+

404 - File Not Found

-

- - - - Sorry! Cannot seem to find the page you were looking for. - -

-
+

+ + + + Sorry! Cannot seem to find the page you were looking for. + +

+
\ No newline at end of file diff --git a/app/Views/errors/html/error_exception.php b/app/Views/errors/html/error_exception.php index 7eb3736a..5101f1e1 100644 --- a/app/Views/errors/html/error_exception.php +++ b/app/Views/errors/html/error_exception.php @@ -3,426 +3,532 @@ - - + + - <?= htmlspecialchars($title, ENT_SUBSTITUTE, 'UTF-8') ?> - + <?= htmlspecialchars($title, ENT_SUBSTITUTE, 'UTF-8') ?> + - + - -
-
-

getCode() ? ' #' . $exception->getCode() : '' ?>

-

- getMessage() ?> - getMessage()) - ) ?>" rel="noreferrer" target="_blank">search → -

-
-
+ +
+
+

getCode() + ? ' #' . $exception->getCode() + : '' ?>

+

+ getMessage() ?> + getMessage() + ) + ) ?>" rel="noreferrer" target="_blank">search → +

+
+
- -
-

at line

+ +
+

at line

- -
- -
- -
+ +
+ +
+ +
-
+
- + -
+
- -
+ +
-
    - $row): ?> +
      + $row): ?> +
    1. +

      + + + + + {PHP internal code} + -

    2. -

      - - - - - {PHP internal code} - + + +   —   + + + ( arguments ) +

      + - - -   —   - - - ( arguments ) -
      -
      + getParameters(); + } + foreach ( + $row['args'] + as $key => $value + ): ?> + + + + + - getParameters(); - } - foreach ($row['args'] as $key => $value): ?> - - - - - + + + () + + + + +   —   () + +

      + + + +
      + +
      + + + + + + + + + +
      + + + +

      $

      + +
      name + : "#$key", + ENT_SUBSTITUTE, + 'UTF-8' + ) ?> +
      +
      name : "#$key", - ENT_SUBSTITUTE, - 'UTF-8' - ) ?> -
      -
      + + + + + + + + $value): ?> + + + + + + +
      KeyValue
      + + + + ' . + print_r($value, true) ?> + +
      + + + + + + +

      Constants

      + + + + + + + + + + $value + ): ?> + + + + + + +
      KeyValue
      + + + + ' . + print_r($value, true) ?> + +
      + +
      + + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Pathuri ?>
      HTTP MethodgetMethod(true) ?>
      IP AddressgetIPAddress() ?>
      Is AJAX Request?isAJAX() ? 'yes' : 'no' ?>
      Is CLI Request?isCLI() ? 'yes' : 'no' ?>
      Is Secure Request?isSecure() ? 'yes' : 'no' ?>
      User AgentgetUserAgent() + ->getAgentString() ?>
      + + + + + + + + +

      $

      + + + + + + + + + + $value): ?> + + + + + + +
      KeyValue
      + + + + ' . + print_r($value, true) ?> + +
      + + + + +
      + No $_GET, $_POST, or $_COOKIE Information to show. +
      + + + + getHeaders(); ?> + +

      Headers

      + + + + + + + + + + + + + + + + + + + + +
      HeaderValue
      getName(), + 'html' + ) ?>getValueLine(), + 'html' + ) ?>
      + + +
      + + + setStatusCode(http_response_code()); ?> +
      + + + + + +
      Response StatusgetStatusCode() . + ' - ' . + $response->getReason() ?>
      - -
      - - () - - + getHeaders(); ?> + + - -   —   () - -

      +

      Headers

      - - -
      - -
      - -
    3. + + + + + + + + + $value): ?> + + + + + + +
      HeaderValue
      getHeaderLine($name), + 'html' + ) ?>
      - -
    + +
-
+ +
+ - -
- - +
    + +
  1. + +
+
-

$

+ +
- - - - - - - - - $value): ?> - - - - - - -
KeyValue
- - - - ' . print_r($value, true) ?> - -
+ + + + + + + + + + + + + + + +
Memory Usage
Peak Memory Usage:
Memory Limit:
- +
- - - -

Constants

+
- - - - - - - - - $value): ?> - - - - - - -
KeyValue
- - - - ' . print_r($value, true) ?> - -
- -
+
- -
- + - -
- - +
+
diff --git a/app/Views/errors/html/production.php b/app/Views/errors/html/production.php index 983f519f..7197c1c0 100644 --- a/app/Views/errors/html/production.php +++ b/app/Views/errors/html/production.php @@ -18,11 +18,8 @@
-

Whoops!

-

We seem to have hit a snag. Please try again later...

-
diff --git a/app/Views/podcast.php b/app/Views/podcast.php index b4ba052a..b64782b0 100644 --- a/app/Views/podcast.php +++ b/app/Views/podcast.php @@ -24,7 +24,6 @@ title ?> #number ?> -

description ?>