Skip to content

Commit

Permalink
Fixes and improvements for v1.4.4.664, see CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianswebworld authored Dec 22, 2023
1 parent 603ccc3 commit c942032
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.4.4.664

- Further improved handling of 0-byte files when used to de-publish only specific subpages of a page
- Using the "Previous Page" button on page 100 now wraps around, back to the highest page number of the service
- Added ttxPrevPageNum and ttxNextPageNum to the ttxEnv section to facilitate implementation in certain mobile apps

1.4.2.662

- More sanity checks to avoid PHP warnings in some rare cases
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ The teletext pages to be displayed must be in EP1 format (Softel). This file for

The EP1 files must be suitably synchronized in the filename format PxxxSyy.EP1 (where xxx = page number, yy = subpage number) to a folder accessible to the PHP script. The file name format can be adjusted in the script if required.

Files with a size of 0 bytes (e.g. used as "deletion files" in some Sophora installations) are considered non-existent; corresponding pages are treated as non-existent pages, i.e. skipped.

### Deployment

The PHP script and all auxiliary files must be copied to the web server and configured according to the section below. The **g1.zip** file in the **g1** folder needs to be unzipped on the server (faster deployment than transferring 1024 separate files). The transfer of the EP1 files must be set up. In order to prevent users from directly accessing the EP1 files via the web server, the commented lines of the supplied .htaccess file in the ttxweb folder should be uncommented (as long as the server supports Rewrite Rules).
Expand Down
2 changes: 1 addition & 1 deletion includes/ttxweb_decoder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// ttxweb.php EP1 teletext document renderer
// version: 1.4.2.662 (2023-10-23)
// version: 1.4.4.664 (2023-12-22)
// (c) 2023 Fabian Schneider - @fabianswebworld

const EP1_HEADER_LENGTH = 6;
Expand Down
12 changes: 9 additions & 3 deletions includes/ttxweb_main.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

// ttxweb.php EP1 teletext document renderer
// version: 1.4.2.662 (2023-10-23)
// version: 1.4.4.664 (2023-12-22)
// (c) 2023 Fabian Schneider - @fabianswebworld

// GLOBAL DEFINITIONS

const TTXWEB_VERSION = '1.4.2.662 (2023-10-23)'; // version string
const TTXWEB_VERSION = '1.4.4.664 (2023-12-22)'; // version string

// for user and template configuration see ttxweb_config.php

Expand Down Expand Up @@ -77,10 +77,11 @@ function getPageNumbers() {
$nextIdx = $currentIdx + 1;
$prevIdx = $currentIdx - 1;
if ($nextIdx == sizeof($ep1FileList)) $nextIdx = 0;
if ($prevIdx == -1) $prevIdx = sizeof($ep1FileList) - 1;
}

// jump over 0-byte files (needed for some Sophora installations)
for ( ; (($nextIdx < count($ep1FileList)) && (filesize(EP1_PATH . $ep1FileList[$nextIdx]) == 0)); $nextIdx++);
for ( ; (($nextIdx <= count($ep1FileList)) && (filesize(EP1_PATH . $ep1FileList[$nextIdx]) == 0)); $nextIdx++);
for ( ; (($prevIdx >= 0) && (filesize(EP1_PATH . $ep1FileList[$prevIdx]) == 0)); $prevIdx--);

// extract page numbers from filenames in list
Expand All @@ -94,6 +95,9 @@ function getPageNumbers() {

// get number of subpages
$ep1SubpageFileList = glob(EP1_PATH . str_replace(array('%ppp%', '%ss%'), array($pageNum, '[0-9][0-9]'), EP1_PATTERN));
for ($subpageIdx = 0; $subpageIdx <= count($ep1SubpageFileList); $subpageIdx++) {
if (filesize($ep1SubpageFileList[$subpageIdx]) == 0) unset($ep1SubpageFileList[$subpageIdx]);
}
$numSubpages = count($ep1SubpageFileList);
if ($subpageNum > $numSubpages) $subpageNum = sprintf('%02d', $numSubpages);

Expand Down Expand Up @@ -287,6 +291,8 @@ function pageExists($pageNum, $subpageNum) {
<pre id="ttxRow0Template">' . ROW_0_CUSTOMHEADER . '</pre>
<pre id="ttxLanguage">' . $ttxLanguage . '</pre>
<pre id="ttxPageNum">' . $pageNum . '</pre>
<pre id="ttxPrevPageNum">' . $prevPageNum . '</pre>
<pre id="ttxNextPageNum">' . $nextPageNum . '</pre>
<pre id="ttxSubpageNum">' . intval($subpageNum) . '</pre>
<pre id="ttxNumSubpages">' . $numSubpages . '</pre>
<pre id="ttxReveal">' . intval($reveal) . '</pre>
Expand Down

0 comments on commit c942032

Please sign in to comment.