diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/blog-engine.iml b/.idea/blog-engine.iml new file mode 100644 index 0000000..a87f5dd --- /dev/null +++ b/.idea/blog-engine.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..5965015 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + mariadb + true + org.mariadb.jdbc.Driver + jdbc:mariadb://localhost:3306/blog + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml new file mode 100644 index 0000000..4ee6cbd --- /dev/null +++ b/.idea/dbnavigator.xml @@ -0,0 +1,412 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..d8e9561 --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3ce3588 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6b49a2d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..a037805 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..288b36b --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/_config.php b/_config.php index f1bf981..19eb962 100644 --- a/_config.php +++ b/_config.php @@ -7,16 +7,16 @@ const BLOG_RAN = true; // Tytuł bloga - const BLOG_TITLE = "Kwiatowy Blog"; + const BLOG_TITLE = "nowy blog"; // Opis bloga - const BLOG_DESC = "ef"; + const BLOG_DESC = "o niczym"; // Autor bloga/Nazwa wyświetlana dla głównego administratora bloga const BLOG_AUTHOR = "Krzysiek Smaga"; // Tagi bloga - const BLOG_TAGS = "kwiaty, rośliny"; + const BLOG_TAGS = "asdf, sadf, wr"; // Domena bloga const BLOG_DOMAIN = "http://localhost"; @@ -38,17 +38,17 @@ const DB_PASS = ""; // Baza danych dla bloga - const DB_NAME = "blog"; + const DB_NAME = "blog_now"; /* * KONFIGURACJA NARZĘDZIA SERWEROWEGO */ // Port, który ma używać PHP dla serwera publicznego - const PUB_PORT = "8085"; + const PUB_PORT = "8080"; // Port, który ma używać PHP dla serwera deweloperskiego - const DEV_PORT = "8086"; + const DEV_PORT = "8081"; /* * KONFIGURACJA KONTA ADMINISTRATORA @@ -58,7 +58,7 @@ const ADMIN_USER = "admin"; // Adres mailowy kontaktowy do głównego administratora bloga - const ADMIN_EMAIL = "krzysiek-smaga@outlook.com"; + const ADMIN_EMAIL = "admin@blog.pl"; // Hasło dla głównego administratora bloga const ADMIN_PASS = "root"; @@ -81,4 +81,4 @@ const MAIL_PORT = ""; // Wymaga SSL'a - const MAIL_SSL = 1; \ No newline at end of file + const MAIL_SSL = 0; \ No newline at end of file diff --git a/be_firstrun.php b/be_firstrun.php index d666fff..3bba6f0 100644 --- a/be_firstrun.php +++ b/be_firstrun.php @@ -57,11 +57,11 @@

Jeżeli chcesz korzystać z korzyści, jakie dają wbudowane narzędzia tego silnika, możesz ustawić pod siebie to, co chcesz.

- +
- +
diff --git a/be_login.php b/be_login.php index 1202663..53ed9d3 100644 --- a/be_login.php +++ b/be_login.php @@ -10,7 +10,9 @@ if(isset($_POST['logmein'])){ $remember = ($_POST['remember'] ?? false); $auth->Authenticate($_POST['login'], $_POST['password'], $remember); + unset($_POST['logmein']); } + if(isset($_SESSION['uToken_BE'])){ if($auth->CheckRole($_SESSION['uToken_BE']) == "administrator" || $auth->CheckRole($_SESSION['uToken_BE']) == "moderator") if(isset($_GET['goto'])) diff --git a/be_panel.php b/be_panel.php index 05313c1..5369a54 100644 --- a/be_panel.php +++ b/be_panel.php @@ -3,10 +3,12 @@ require "vendor/blog-engine/php/Authentication/AuthController.php"; use BlogEngine\Authentication\AuthController; + session_start(); + $auth = new AuthController(); $conn = $auth->Connection(); - if(!isset($_COOKIE['uToken_BE'])) + if(!isset($_SESSION['uToken_BE'])) header("location: be_login.php"); $site = ($_GET['s'] ?? "home"); diff --git a/blog_panel/be_post.php b/blog_panel/be_post.php index 81ea6e9..f2c9b12 100644 --- a/blog_panel/be_post.php +++ b/blog_panel/be_post.php @@ -57,9 +57,17 @@ } } - if(isset($_POST['add'])){ - $postcon->CreatePost($_POST['title'], $_POST['content'], $_POST['name'], $_POST['tags'], $_POST['comments_status'], (isset($_POST['now_time'])?true:$_POST['add_time']), "public"); - } + if(isset($_POST['add'])) + $postcon->CreatePost($_POST['title'], $_POST['content'], $_POST['name'], $_POST['tags'], $_POST['comments_status'], (isset($_POST['now_time']) ? true : $_POST['add_time']), "public"); + + if(isset($_POST['draft'])) + $postcon->DraftPost($_POST['draft'], $_POST['title'], $_POST['content'], $_POST['name'], $_POST['tags'], $_POST['comments_status']); + + if(isset($_POST['delete'])) + $postcon->DeletePost($_POST['delete']); + + if(isset($_POST['update'])) + $postcon->UpdatePost($_POST['update'], $_POST['title'], $_POST['content'], $_POST['name'], $_POST['tags'], $_POST['comments_status']); ?> @@ -77,6 +85,7 @@
+

@@ -87,9 +96,9 @@
- Zaktualizuj":"") ?> - - + Zaktualizuj":"") ?> + +
@@ -102,10 +111,11 @@

Ustawienia posta

+
Status posta

Kto może publikować komentarze
- @@ -138,12 +148,11 @@
"); ?> - '; + } + ?>
@@ -174,6 +204,11 @@ diff --git a/compile.php b/compile.php index 5e6640b..ad5ba97 100644 --- a/compile.php +++ b/compile.php @@ -1,4 +1,9 @@ 1){ switch($argv[1]){ + case "init": + $this->init(); + break; case "compile": if($argv[2] != null) switch($argv[2]) { @@ -105,7 +113,7 @@ $site = str_replace($page_tag, $this->dictionary->page_tags[$page_tag], $site); } - $site = str_replace("", "\n", $site); + $site = str_replace("", "\n", $site); $site_file = fopen("$folder/" . $name, "w"); fwrite($site_file, $site); @@ -215,12 +223,136 @@ Aby zatrzymać serwer, naciśnij Ctrl+C = Krzysztof KrzysiekSiemv Smaga 2023 =============================== Dostępne komendy dla narzędzia: - + +* init - uruchamia kreator bloga * start-server [pub/dev] - uruchom serwer dla projektu. Opcja 'dev' specjalna dla programisty, opcja 'pub' dla każdego użytkownika. Domyślnie 'pub' * help - wyświetl listę komend * compile [pub/dev] - skompiluj projekt strony z folderu 'src'. Opcja 'dev' specjalna dla programisty, opcja 'pub' dla każdego użytkownika. Domyślnie 'pub' "; } + + public function init() : void { + $data = array(); + echo "Okeeej! Czas na konfiguracje serwera blogowego! Zacznijmy od początku.\n"; + $_POST['BLOG_AUTHOR'] = readline("Jak się nazywasz: "); + echo "\n> Cześć, {$_POST['BLOG_AUTHOR']}! "; + + $_POST['BLOG_TITLE'] = readline("Jak będzie się ten blog nazywał: "); + while($_POST['BLOG_TITLE'] == ""){ + $_POST['BLOG_TITLE'] = readline("Jeszcze raz... Jak się będzie nazywać ten blog: "); + } + + $_POST['BLOG_DESC'] = readline("O czym jest ten blog? Jaki jest jego opis: "); + while($_POST['BLOG_DESC'] == ""){ + $_POST['BLOG_DESC'] = readline("Jeszcze raz... O czym jest ten blgo? Jaki jest jego opis: "); + } + + $_POST['BLOG_TAGS'] = readline("Jakie są słowa kluczowe dla tego bloga (oddziel przecinkiem): "); + while($_POST['BLOG_TAGS'] == ""){ + $_POST['BLOG_TAGS'] = readline("Jeszcze raz... Jakie są słowa kluczowe dla tego bloga? Oddziel słowa przecinkiem: "); + } + + $_POST['BLOG_DOMAIN'] = readline("Na jakiej domenie będzie stał blog? (Domyślnie http://localhost): "); + if($_POST['BLOG_DOMAIN'] == "") + $_POST['BLOG_DOMAIN'] = "http://localhost"; + + echo "\nDobrze, przejdźmy do konfiguracji bazy danych. Nie będzie trudno\n"; + $_POST['DB_HOST'] = readline("Jaki jest adres serwera bazy danych? (Domyślnie: 127.0.0.1:3306): "); + if($_POST['DB_HOST'] == "") + $_POST['DB_HOST'] = "127.0.0.1:3306"; + + $_POST['DB_USER'] = readline("Nazwa użytkownika (Domyślnie: root): "); + if($_POST['DB_USER'] == "") + $_POST['DB_USER'] = "root"; + + $_POST['DB_PASS'] = readline("Hasło: "); + + $_POST['DB_NAME'] = readline("Baza danych: "); + while($_POST['DB_NAME'] == "") + $_POST['DB_NAME'] = readline("Podaj poprawną nazwę bazy danych: "); + + echo "\nUstawmy teraz odpowiednie porty\n"; + $_POST['PUB_PORT'] = readline("Port dla publicznego trybu serwera (Domyślnie: 8080): "); + if($_POST['PUB_PORT'] == "") + $_POST['PUB_PORT'] = "8080"; + + $_POST['DEV_PORT'] = readline("Port dla deweloperskiego trybu serwera (Domyślnie: 8081): "); + if($_POST['DEV_PORT'] == "") + $_POST['DEV_PORT'] = "8081"; + + echo "\nTeraz skonfigurujmy konto administratora dla bloga\n"; + $_POST['ADMIN_USER'] = readline("Nazwa użytkownika (Domyślnie: admin): "); + if($_POST['ADMIN_USER'] == "") + $_POST['ADMIN_USER'] = "admin"; + + $_POST['ADMIN_EMAIL'] = readline("Adres e-mail: "); + while($_POST['ADMIN_EMAIL'] == "") + $_POST['ADMIN_EMAIL'] = readline("Podaj poprawny adres mailowy: "); + + $ADMIN_PASS = readline("Hasło: "); + $ADMIN_REPASS = readline("Powtórz hasło: "); + + while($ADMIN_PASS != $ADMIN_REPASS){ + echo "\nBłędnie wpisano hasła. Wpisz ponownie hasło\n"; + $ADMIN_PASS = readline("Hasło: "); + $ADMIN_REPASS = readline("Powtórz hasło: "); + } + + $_POST['ADMIN_PASS'] = $ADMIN_PASS; + + if(strtolower(readline("Czy chcesz skonfigurować teraz serwer poczty? (Y/N) (Domyślnie: N): ")) == "y"){ + $_POST['MAIL_NAME'] = readline("Podaj adres, z którego będą wysyłane maile: "); + while($_POST['MAIL_NAME'] == "") + $_POST['MAIL_NAME'] = readline("Podaj adres, z którego będą wysyłane maile: "); + + $_POST['MAIL_PASS'] = readline("Hasło: "); + while($_POST['MAIL_PASS'] == "") + $_POST['MAIL_PASS'] = readline("Hasło: "); + + $_POST['MAIL_SRV'] = readline("Serwer poczty wychodzącej (SMTP): "); + while($_POST['MAIL_SRV'] == "") + $_POST['MAIL_SRV'] = readline("Serwer poczty wychodzącej (SMTP): "); + + $_POST['MAIL_PORT'] = readline("Port serwera: "); + while($_POST['MAIL_PORT'] == "") + $_POST['MAIL_PORT'] = readline("Port serwera: "); + + $MAIL_SSL = strtolower(readline("Czy serwer poczty wymaga certyfikatu SSL? (Y/n): ")); + while($MAIL_SSL != "y" && $MAIL_SSL != "n"){ + $MAIL_SSL = strtolower(readline("Czy serwer poczty wymaga certyfikatu SSL? (Y/n): ")); + } + + if($MAIL_SSL == "y") + $MAIL_SSL = 1; + else + $MAIL_SSL = 0; + } else { + $_POST['MAIL_NAME'] = ""; + $_POST['MAIL_PASS'] = ""; + $_POST['MAIL_SRV'] = ""; + $_POST['MAIL_PORT'] = ""; + $MAIL_SSL = 0; + } + + $data = [ + "BLOG_TITLE" => $_POST['BLOG_TITLE'], "BLOG_DESC" => $_POST['BLOG_DESC'], "BLOG_AUTHOR" => $_POST['BLOG_AUTHOR'], "BLOG_TAGS" => $_POST['BLOG_TAGS'], "BLOG_DOMAIN" => $_POST['BLOG_DOMAIN'], "BLOG_ICON" => $file, + "DB_HOST" => $_POST['DB_HOST'], "DB_USER" => $_POST['DB_USER'], "DB_PASS" => $_POST['DB_PASS'], "DB_NAME" => $_POST['DB_NAME'], + "PUB_PORT" => $_POST['PUB_PORT'], "DEV_PORT" => $_POST['DEV_PORT'], + "ADMIN_USER" => $_POST['ADMIN_USER'], "ADMIN_EMAIL" => $_POST['ADMIN_EMAIL'], "ADMIN_PASS" => $_POST['ADMIN_PASS'], + "MAIL_NAME" => $_POST['MAIL_NAME'], "MAIL_PASS" => $_POST['MAIL_PASS'], "MAIL_SRV" => $_POST['MAIL_SRV'], "MAIL_PORT" => $_POST['MAIL_PORT'], "MAIL_SSL" => $MAIL_SSL + ]; + + $configuration = new Configuration(); + $auth = new AuthController(); + + $configuration->SendData($data); + + include "_config.php"; + + $auth->CreateDatabase(); + + echo "Pomyślnie skonfigurowano!"; + } } $exec = new CompileIt(); diff --git a/composer.json b/composer.json index e746397..55bfd28 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,8 @@ "require": { "twbs/bootstrap": "^5.2", "phpmailer/phpmailer": "^6.7.1", - "ext-mysqli": "*" + "ext-mysqli": "*", + "ext-readline": "*", + "ext-mbstring": "*" } } \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index b2dcd87..5b11893 100644 --- a/dev/index.html +++ b/dev/index.html @@ -5,21 +5,20 @@ Witaj świecie! - Kwiatowy Blog - - + - + - +

Kwiatowy Blog

-

ef

+

dsfsadf

Zaloguj się do panelu - - + + \ No newline at end of file diff --git a/post.php b/post.php new file mode 100644 index 0000000..80e35b1 --- /dev/null +++ b/post.php @@ -0,0 +1,12 @@ +Connection(); \ No newline at end of file diff --git a/public/index.html b/public/index.html index 3e7ea48..861953b 100644 --- a/public/index.html +++ b/public/index.html @@ -5,17 +5,20 @@ Witaj świecie! - Kwiatowy Blog - + - + +

Kwiatowy Blog

-

ef

+

dsfsadf

+ Zaloguj się do panelu - + + \ No newline at end of file diff --git a/vendor/blog-engine/php/Posts/Autosave.php b/vendor/blog-engine/php/Posts/Autosave.php deleted file mode 100644 index 4bb99ec..0000000 --- a/vendor/blog-engine/php/Posts/Autosave.php +++ /dev/null @@ -1,13 +0,0 @@ -Connection(); - - if(isset($_POST['title']) && isset($_POST['content']) && isset($_POST['name'])){ - - } - - $conn->close(); \ No newline at end of file diff --git a/vendor/blog-engine/php/Posts/Calls/AutosaveCall.php b/vendor/blog-engine/php/Posts/Calls/AutosaveCall.php new file mode 100644 index 0000000..6c31e08 --- /dev/null +++ b/vendor/blog-engine/php/Posts/Calls/AutosaveCall.php @@ -0,0 +1,22 @@ +Connection(); + + $postcon = new PostController($auth); + + if(isset($_POST['name']) && isset($_POST['title']) && isset($_POST['content'])){ + $id = $_POST['id'] ?? 0; + if($postcon->AutoSave($id, $_POST['name'], $_POST['title'], $_POST['content'], (isset($_POST['tags'])?$_POST['tags']:null), $_POST['commentStatus'])) + echo "Zapisano zmiany!"; + else + echo "Błąd w zapisie! Spróbuj ponownie później"; + } \ No newline at end of file diff --git a/vendor/blog-engine/php/Posts/PostController.php b/vendor/blog-engine/php/Posts/PostController.php index a903cb3..81d9591 100644 --- a/vendor/blog-engine/php/Posts/PostController.php +++ b/vendor/blog-engine/php/Posts/PostController.php @@ -1,6 +1,7 @@ close(); header("location: ../../../be_panel.php?s=posts"); } + + public function DraftPost($id = 0, $title = '', $content = '', $name = '', $tags = [], $commentStatus = ''){ + $srv = $this->auth->Connection(); + + $date = (is_bool($add_time)?"NOW":Date("'Y-m-d H:i:s'", strtotime($add_time))); + $id_user = $this->auth->GetID($_SESSION['uToken_BE']); + + if($id == 0){ + $id = mysqli_fetch_row(mysqli_query($srv, "SELECT MAX(id_post) FROM posts;"))[0] + 1; + + $insert_post = "INSERT INTO posts VALUES($last_id_post, $id_user, '$name', '$title', '$content', 'draft', '$commentStatus', 0, $date, null);"; + mysqli_query($srv, $insert_post); + + foreach ($tags as $tag){ + mysqli_query($srv, "INSERT INTO tag_to_post VALUES($tag, $id)"); + } + } else { + $update_post = "UPDATE posts SET id_post = $id, name = '$name', title = '$title', content = '$content', status = 'draft', comments = '$commentStatus' WHERE id_post = $id;"; + mysqli_query($srv, $update_post); + mysqli_query($srv, "DELETE FROM tag_to_post WHERE id_post = $id"); + + foreach ($tags as $tag){ + mysqli_query($srv, "INSERT INTO tag_to_post VALUES($tag, $id)"); + } + } + + $srv->close(); + header("location: ../../../be_panel.php?s=posts"); + } + + public function UpdatePost($id, $title, $content, $name, $tags, $commentStatus){ + $srv = $this->auth->Connection(); + + $date = (is_bool($add_time)?"NOW":Date("'Y-m-d H:i:s'", strtotime($add_time))); + $id_user = $this->auth->GetID($_SESSION['uToken_BE']); + + $update_post = "UPDATE posts SET id_post = $id, name = '$name', title = '$title', content = '$content', status = 'public', comments = '$commentStatus', updated_at = NOW() WHERE id_post = $id;"; + mysqli_query($srv, $update_post); + mysqli_query($srv, "DELETE FROM tag_to_post WHERE id_post = $id"); + + foreach ($tags as $tag){ + mysqli_query($srv, "INSERT INTO tag_to_post VALUES($tag, $id)"); + } + + $srv->close(); + header("location: ../../../be_panel.php?s=posts"); + } + + public function DeletePost($id){ + $srv = $this->auth->Connection(); + mysqli_query($srv, "DELETE FROM tag_to_post WHERE id_post = $id"); + mysqli_query($srv, "DELETE FROM posts WHERE id_post = $id"); + $srv->close(); + header("location: ../../../be_panel.php?s=posts"); + } + + public function AutoSave($id, $name, $title, $content, $tags = null, $commentStatus = "open") : bool { + $srv = $this->auth->Connection(); + $response = false; + $id_user = $this->auth->GetID($_SESSION['uToken_BE']); + + $post = ""; + if($id == null || $id == 0){ + $post = "INSERT INTO posts VALUES(null, $id_user, '$name', '$title', '$content', 'draft', '$commentStatus', 0, NOW(), null)"; + } else { + $post = "UPDATE posts SET name = '$name', title = '$title', content = '$content', status = 'draft', comments = '$commentStatus' WHERE id_post = $id"; + } + + if(mysqli_query($srv, $post)) + $response = true; + + $srv->close(); + + return $response; + } + + public function DownloadPost($year, $month, $date, $name) : array { + $srv = $this->auth->Connection(); + $post = array(); + + $get_post = "SELECT users.display_name AS autor, posts.title AS tytul, posts.content AS tresc, posts.views AS wyswietlenia, posts.added_at AS dodano, (SELECT GROUP_CONCAT(CONCAT(comments.author, ";;", comments.content, ";;", comments.added_at)) FROM comments WHERE comments.id_post = posts.id_post GROUP BY comments.id_comment) AS komentarze FROM posts, users WHERE users.id_user = posts.id_user AND YEAR(added_at) = '$year' AND MONTH(added_at) = '$month' AND DAY(added_at) = '$day' AND posts.name = '$name';"; + $res_post = mysqli_query($srv, $get_post); + + if($row = mysqli_fetch_row($res_post)){ + array_push($post, [ + "Autor" => $row[0], + "Tytul" => $row[1], + "Tresc" => $row[2], + "Wyswietlenia" => $row[3], + "Dodano" => $row[4], + "Komentarze" => array() + ]); + + $comments = mb_split("||||", $row[5]); + + foreach($comments as $comment){ + $data = mb_split(";;", $comment); + array_push($post[0]["Komentarze"], [ + "Autor" => $data[0], + "Tresc" => $data[1], + "Dodano" => $data[2] + ]); + } + } + + return post; + } } } \ No newline at end of file diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index afef3fa..7824d8f 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -42,35 +42,37 @@ namespace Composer\Autoload; */ class ClassLoader { - /** @var ?string */ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr0 = array(); @@ -78,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array + * @var array */ private $classMap = array(); @@ -87,29 +88,29 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array + * @var array */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); } /** - * @return string[] + * @return array> */ public function getPrefixes() { @@ -121,8 +122,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array> + * @return array> */ public function getPrefixesPsr4() { @@ -130,8 +130,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirs() { @@ -139,8 +138,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirsPsr4() { @@ -148,8 +146,7 @@ class ClassLoader } /** - * @return string[] Array of classname => path - * @psalm-return array + * @return array Array of classname => path */ public function getClassMap() { @@ -157,8 +154,7 @@ class ClassLoader } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap + * @param array $classMap Class to filename map * * @return void */ @@ -175,24 +171,25 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -201,19 +198,19 @@ class ClassLoader $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -222,9 +219,9 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -232,17 +229,18 @@ class ClassLoader */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -252,18 +250,18 @@ class ClassLoader throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -272,8 +270,8 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories * * @return void */ @@ -290,8 +288,8 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -425,7 +423,8 @@ class ClassLoader public function loadClass($class) { if ($file = $this->findFile($class)) { - includeFile($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } @@ -476,9 +475,9 @@ class ClassLoader } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array */ public static function getRegisteredLoaders() { @@ -555,18 +554,26 @@ class ClassLoader return false; } -} -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - * @private - */ -function includeFile($file) -{ - include $file; + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } } diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index c6b54af..51e734a 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -98,7 +98,7 @@ class InstalledVersions { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; } } @@ -119,7 +119,7 @@ class InstalledVersions */ public static function satisfies(VersionParser $parser, $packageName, $constraint) { - $constraint = $parser->parseConstraints($constraint); + $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); @@ -328,7 +328,9 @@ class InstalledVersions if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { self::$installed = $installed[count($installed) - 1]; } @@ -340,12 +342,17 @@ class InstalledVersions // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; } else { self::$installed = array(); } } - $installed[] = self::$installed; + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } return $installed; } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index cc34b17..bf74ca9 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'krzysieksiemv/blog', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '905de3bcc7dff60b47d30a2f635649c644437b23', + 'reference' => 'e7dd0b2fd68fa13c0a39aee2f4a6f43a02202ec1', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ 'krzysieksiemv/blog' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '905de3bcc7dff60b47d30a2f635649c644437b23', + 'reference' => 'e7dd0b2fd68fa13c0a39aee2f4a6f43a02202ec1', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/version b/version index d8263ee..4fe5631 100644 --- a/version +++ b/version @@ -1 +1 @@ -2 \ No newline at end of file +3.2 \ No newline at end of file