diff --git a/.htaccess b/.htaccess index 2e514f4..e6f7e91 100644 --- a/.htaccess +++ b/.htaccess @@ -1,4 +1,6 @@ RewriteEngine On +RewriteCond %{HTTPS} off +RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [NC,L] \ No newline at end of file diff --git a/libs/timeline.css b/libs/timeline.css index f4cfabf..243c6bf 100644 --- a/libs/timeline.css +++ b/libs/timeline.css @@ -405,6 +405,22 @@ nav.pagnation { border-radius: 0.25rem; } + +.pagnation { + display: flex; + justify-content: center; + margin: 1rem; +} + +.pagnation a { + text-decoration: none; + background-color: var(--accent-bg); +} + +.pagnation strong { + padding: 0 1rem; +} + /* === FOOTER === */ body > footer { diff --git a/libs/twtxt.php b/libs/twtxt.php index c127bfd..0fed709 100644 --- a/libs/twtxt.php +++ b/libs/twtxt.php @@ -169,12 +169,21 @@ function replaceMentionsFromTwt(string $twtString): string { // Example output: Hello @eapl.mx@eapl.mx/twtxt.txt, how are you? @nick@server.com/something/twtxt.txt $pattern = '/@<([^ ]+)\s([^>]+)>/'; + //$replacement = '@$1'; $replacement = '@$1'; - $replacement .= ''; // Adds a hidden link direcly to the twtxt.txt of the mentioned target + //$replacement .= ''; // Adds a hidden link direcly to the twtxt.txt of the mentioned target #$twtString = '@'; #$pattern = '/@<([^ ]+) ([^>]+)>/'; #$replacement = '@$1'; + + /* + $pattern_only_url = '/@<(https?:\/\/[^>]+)>/'; + if (preg_match($pattern_only_url, $twtString)) { + $replacement = '@$1'; + } + */ + $result = preg_replace($pattern, $replacement, $twtString); return $result; diff --git a/partials/base.php b/partials/base.php index 5ebf492..1d835c3 100644 --- a/partials/base.php +++ b/partials/base.php @@ -22,10 +22,10 @@ require_once('libs/twtxt.php'); require_once('libs/hash.php'); require_once('libs/Parsedown.php'); -const TWTS_PER_PAGE = 10; - +const TWTS_PER_PAGE = 20; // TODO: Move twts per page to config.ini // Add a fallback if the number is invalid (it should be between 1 and 999) + $config = parse_ini_file('private/config.ini'); // TODO: Take the title from the config.ini @@ -157,6 +157,9 @@ if (!empty($_GET['hash'])) { } // Pagnation + +//$twts_per_page = $config['twts_per_page']; + $page = 1; if (!empty($_GET['page'])) { $page = intval($_GET['page']); diff --git a/partials/pagnation.php b/partials/pagnation.php new file mode 100644 index 0000000..83501cb --- /dev/null +++ b/partials/pagnation.php @@ -0,0 +1,47 @@ +"; + +if (!empty($_GET['page'])) { + + if (preg_match('/\?page=/', $page_url)) { + //echo "cotains ?page= so reuse that
"; + $page_url = preg_replace('/\?page=\d*/', "", $page_url) . '?page='; + } + + if (preg_match('/&page=/', $page_url)) { + //echo "cotains &page= so reuse that
"; + $page_url = preg_replace('/&page=\d*/', "", $page_url) . '&page='; + } + +} else { + + if (!preg_match('/(\?|&)/', $page_url)) { + //echo "No param, so use ?page
"; + $page_url = $page_url . '?page='; + } + + if (!preg_match('/(\?|&)page/', $page_url)) { + //echo "other param than _page, so use &page
"; + $page_url = $page_url . '&page='; + } +} + +?> + +
+ 1) { ?> + Previous + + Previous + +    + Next +
diff --git a/partials/timeline.php b/partials/timeline.php index 0c966da..552ca57 100644 --- a/partials/timeline.php +++ b/partials/timeline.php @@ -6,9 +6,11 @@ --> + + - +
@@ -50,55 +52,8 @@ "; - -if (!empty($_GET['page'])) { - - if (preg_match('/\?page=/', $page_url)) { - //echo "cotains ?page= so reuse that
"; - $page_url = preg_replace('/\?page=\d*/', "", $page_url) . '?page='; - } - - if (preg_match('/&page=/', $page_url)) { - echo "cotains &page= so reuse that
"; - $page_url = preg_replace('/&page=\d*/', "", $page_url) . '&page='; - } - -} else { - - if (!preg_match('/(\?|&)/', $page_url)) { - //echo "No param, so use ?page
"; - $page_url = $page_url . '?page='; - } - - if (!preg_match('/(\?|&)page/', $page_url)) { - //echo "other param than _page, so use &page
"; - $page_url = $page_url . '&page='; - } -} - -?> - -

- 1) { ?> - Prev - - Prev - -    - Next -

- -"; //echo __DIR__ . "
"; + //echo "upload path: " . $config["media_upload"]; - $target_dir = getcwd()."/media/"; - $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); + //$media_upload = getcwd()."/media/"; + $media_upload = getcwd().$config["media_upload"]; + $target_file = $media_upload . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); @@ -39,7 +43,7 @@ if (!empty($_POST)) { // Check file size if ($_FILES["fileToUpload"]["size"] > 5000000) { - echo "Sorry, your file is too large.
"; + echo "

Sorry, your file is too large.

"; $uploadOk = 0; } @@ -66,7 +70,6 @@ if (!empty($_POST)) { ?> -
Select image to upload:

@@ -74,4 +77,33 @@ if (!empty($_POST)) {
+ -(filemtime($a) - filemtime($b))); + +echo ''; + +foreach ($imgs_on_server as $img) { + + $public_file = $config["public_media"] . "/" . basename($img); + + echo ''; + echo ''; + + //$img = str_replace('../', $base_url, $img); + echo ''; + echo ''; +} + +echo '
'; + echo ''; + echo '![]('.$public_file.')
'; + +?> + + +