Jump to content

Alpine418

Members
  • Posts

    89
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Alpine418

  1. I solved it myself by the following code. 1. Create a custom RepeaterPage class for my tracks and add a specific method to create a session-based URL for streaming. <?php namespace ProcessWire; /** * @property Pagefile $audio */ class TracksRepeaterPage extends RepeaterPage { /** * @param string $streamUrl Default stream URL when audio file does not exist * * @return string */ public function getStreamUrl(string $streamUrl = ''): string { // Check whether audio file exists and if it does create a session-based stream URL if ($this->audio) { // Create the file hash and add it to the session as key for the audio file path $audioPath = $this->audio->filename(); $fileHash = hash('sha1', $audioPath . session_id()); session()->setFor('stream', $fileHash, $audioPath); // Create the stream URL with the file hash $streamUrl = '/stream/' . $fileHash . '.mp3'; } return $streamUrl; } } 2. Create a custom hook to watch for the stream URL in the ready.php: <?php namespace ProcessWire; if (!defined("PROCESSWIRE")) { die(); } wire()->addHook('/stream/([\w\d]+).mp3', function ($event) { // Get the audio file path by file hash $fileHash = $event->arguments(1); $audioPath = session()->getFor('stream', $fileHash); // Check whether audio file exists and stream it when it does or throw 404 if (file_exists($audioPath)) { wireSendFile($audioPath, [], [ 'content-transfer-encoding' => 'chunked', 'accept-ranges' => 'bytes', 'cache-control' => 'no-cache' ]); } throw new Wire404Exception(); }); Ta da! 🙂 When the session expires, the session-based file hashes are destroyed and the stream URL no longer work. So every time the session is renewed with a new session ID, a new unique session-based stream URL is generated for each tracks. Have I missed anything or are there any security issues?
  2. Hi guys, I want to publish some mp3 files on my website. But I want to prevent users from linking directly to the mp3 file. Instead of using some .htaccess request hacks I want to handle it with proper session based links. Something like https://foo.bar/site/assets /[session id]/[page id]/my-fancy-song.mp3 Once the session expires, the link to the mp3 file won't work. Does ProcessWire already provide such a solution or do I have to create it myself? Does anyone have any experience with this? Thank you for your support!
  3. Yes, this is my current workaround. But there is still the fieldset in the tab.
  4. Hi guys. I love FieldtypeFieldset and use it in all of my templates. Especially to add meta informations for each page. But I miss one simple feature: It would be cool if FieldtypeFieldsetPage would also offer a solution to make it accessible as tab instead of only a fieldset. Because FieldtypeFieldsetTabOpen has no page reference. Best way would be to make another module called FieldtypeFieldsetPageTab or even better, make FieldtypeFieldsetPage configurable to set the access as tab or fieldset. What you guys think? Any chance for an version 0.0.2 of FieldtypeFieldset with a feature upgrade? Best regards.
  5. Thank you very much! I already thought this is the way, but it is good to hear an approval from a professional.
  6. Hi. Can anybody explain why I can add the system field "admin_theme" to a new custom template? And for example why not the system field "pass"? Is there a setting to define what system fields are addable to new custom templates? Thanks.
  7. Hi. I've stopped using PW end of last year and shut off all my websites. Until then I could add a custom composer.json in the root dir of my PW installations. But now I'm building a new website with PW and just saw in the root dir of the latest blank installation a composer.json of @ryan. How should I handle my custom composer settings like PSR-4 autoloading? Can I just customize and add my custom setting in the already existing composer.json like this (check the few latest lines in code below) or are there better practises? { "name": "processwire/processwire", "type": "library", "description": "ProcessWire CMS/CMF", "keywords": [ "processwire", "cms","cmf", "content management system" ], "license": "MPL-2.0", "homepage": "https://processwire.com", "authors": [ { "name": "Ryan Cramer", "email": "ryan@processwire.com", "homepage": "https://processwire.com", "role": "Developer" } ], "require": { "php": ">=5.5", "ext-gd": "*" }, "autoload": { "files": [ "wire/core/ProcessWire.php" "site/my-custom-functions.php" ], "psr-4": { "My\\Custom\\": "site/classes" }, } } Thanks for your support!
  8. Hello. 2 years later I retested the case and still: The table of a field in the database does not get deleted. Why? And is there a clean up function? I've created a text field called "test", executed a few manipulations (added to template, saved text, etc.) and then I deleted it later on. But the table "field_test" ist still in the database. Thanks.
  9. Any solution to catch a custom exception (e.g. RuntimeException) before ProcessWire does? I can catch it like in the first post above, but ProcessWire throws it anyway. Edit: Dont know why. But now it works. Strange.
  10. Hi. Again me with a question. How does the migration of modules work with RockMigration? There is a watcher, but it only watches files and no database changes. Example: I've installed a new module installed with a few custom configurations on my dev environment (e.g. the Duplicator module). Now I want to have the module installed on prod environment too. Does RockMigrations with watcher really catch the module installation and configuration or what is the best way to do handle a new module installation and configuration? Thanks for your support, and no... I don't really need a first class VIP support video from @bernhard again. But you are free born of course?
  11. Hi, I want to use comments module for a new web project. Can I redisgn the form output completely based on current Bootstrap standards? If yes, how? Thanks.
  12. Yes, but $input->post helps only when the data got send as FormData. But you can post data also as json in the body of request (fewer code in JavaScript). Native PHP example for reading them: // Takes raw data from the request $json = file_get_contents('php://input'); // Converts it into a PHP object $data = json_decode($json); Looks like PW has no functions. So I will use the native solutions from PHP. No problem ?
  13. Thank you! URL hooks looks like the easiest way without overhead for a a few API calls. Did PW offer any solution for POST request with JSON body? Or do I need to use native PHP functions?
  14. Hi, I've a few ajax calls from the frontend, which I handle in the _init.php file in the template folder. The response is always json. The code works, but is there a "better" place for such code than in the _init.php? The functionality on my enviroment is some kind of signature/login validation which should be called on every page, idenified by a query param (e.g. /example/path?foo=1). Dummy example: if (input()->get('foo')) { // do foo and response json $foo = [ 'foo' => 'bar' ]; header('Content-Type: application/json; charset=utf-8'); echo json_encode($foo); exit; } if (input()->get('bar')) { // do bar and response json $bar = [ 'foo' => 'bar' ]; header('Content-Type: application/json; charset=utf-8'); echo json_encode($bar); exit; } Thanks.
  15. Yes, when echoed in a HTML tags it got only outputted once. But if this is the case with markup regions, then the code out of html tags will be executed two times and does hurt the performance. Or not?
  16. Hi, I've a simple echo output on the top of a template file. But ProcessWire outputs the echo 2 times. Does this mean the template file gets loaded 2 times? Or is there a misconfiguration on my side? I use markup regions as output strategy as you can seen with pw-id="content". Thanks for your support!
  17. Thank you! Will give it a try again. Update: Sorry, I was in hurry. I just saw you made a video for me. This is like VIP support ?
  18. Hi. I have tried out RockMigration and have a few questions (and still dont get it, I how it should be implemented in a running website on dev and prod stages). I have a working website. Can I generate a fully migrate.php file or do I need to create it manually with the code hints of each field/template? Last one would be a real pain if there are many fields. If I have a field added and want to remove it later on in development process. Then how can I different the state of the field in the migrate.php? Top to down, first added and then removed in one run? But how would the migrate.php looks then? Are there any advanced examples of migrate.php for learning the basics and inspiration? Or advanced docs? Thanks.
  19. Last update. My fix was to add the following command to my npm script: --no-ghost-mode "browser:sync": "browser-sync start --proxy dev.local --no-notify --no-ghost-mode --files public/site/templates/**/* public/static/**/*", The commands disables the mirror of all clicks, scrolls & form inputs via browser-sync. Source: https://browsersync.io/docs/command-line
  20. lol.... issue posted and problem found. It looks like it is a combination of browser-sync as proxy when running ProcessWire unter localhost:3000. When I want to switch the tab, injected browser-sync reloads the page. But why I dont know.
  21. Hi, I've a field of FieldsetPage mapped with a few fields. E.g. If I now want to disable the "required" state of title I need to switch to the tab "Input" of the field mapped to the Fieldset. But when I click "Input" the page completely reloads and I'm landing on the admin site with the page tree. I'm using the latest version 3.0.210. Does anybody else have the same problem? It is a relatively plain installation. I just have RockMigration installed and uninstalled. And TinyMCE installed. Thanks for your support!
  22. I am getting errors when using cron.php Can you check/test it? I am on my phone and cannot access the error message properly. Thanks.
  23. I cannot see the default value settings for image fields on the latest PW versions. Did I miss something?
  24. I've a regular updated PW installation (3.0.191) which is more than a year old. I cannot find any AdminStyleRock module. Why? And how can I install it the best way?
×
×
  • Create New...