Jump to content

flydev

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    47

Posts posted by flydev

  1. Ok, then try the following, you need to know what's the error. Which version of PHP you are running the code on ?

    Also, checking the target logs might give you more hints on what's is missing. A cookie maybe ?

    $url = 'https://json-api-url-domain.com/matches?id=XX&division=YY&teams=[ZZ]';
    
    $cURL = curl_init();
    
    curl_setopt($cURL, CURLOPT_URL, $url);
    curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
      'Content-Type: application/json',
      'Accept: application/json'
    ));
    
    $result = curl_exec($cURL);
    if (curl_errno($cURL)) {
      echo curl_error($cURL);
      die();
    }
    
    $http_code = curl_getinfo($cURL, CURLINFO_HTTP_CODE);
    if ($http_code == intval(200)) {
    
    $json = json_decode($result, true);
      echo "Resource OK: ";
      var_dump($json);
    } else {
      echo "Resource NOTOK: " . $http_code;
    }
    
    die();

     

  2. If you are throwing the request from a ProcessWire template, then please show us the code. The 500 error is quite strange there, you should at least get a pw exception if $debug is true, and in reality, you shouldn't get a 500 error. (The code posted above run on PW with php-7/8 printing curl error if one exist)

    Gve more details on your setup 🙂 

      

    6 hours ago, Tyssen said:

    I am trying to do this on a PW site

    The site is the source or the target ?

  3. Hi, the code seem good, and what I understand from the result, is that the request is ok, as you get a result, but as a result, the server tell you there was an error, and it seem that the error come from a javascript backend. You could try to run curl from cmd line, and compare response headers.

    Are you sure you do not need CURLOPT_FOLLOWLOCATION ?

    try to dump error:

    $url = 'https://json-api-url-domain.com/matches?id=XX&division=YY&teams=[ZZ]';
    
    $cURL = curl_init();
    try {
      curl_setopt($cURL, CURLOPT_URL, $url);
      curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Accept: application/json'
      ));
    
      $result = curl_exec($cURL);
      if (curl_errno($cURL)) {
        echo curl_error($cURL);
        die();
      }
    
      $http_code = curl_getinfo($cURL, CURLINFO_HTTP_CODE);
      if ($http_code == intval(200)) {
    
        $json = json_decode($result, true);
        echo "Resource OK: ";
        var_dump($json);
      } else {
        echo "Resource NOTOK: " . $http_code;
      }
    } catch (\Throwable $th) {
      throw $th;
    } finally {
      curl_close($cURL);
    }
    die();

     

  4. Test the solution below if it fit your needs :

    if ($user->hasRole('testrole')) {
      // $ap = $user->editable_pages[0]->id; //there is always only one page
      // $wire->addHookBefore('Page(id!=' . $ap . '|1023)::listable', function ($event) { //1058 is the id of the parent page
      //   $event->return = false;
      // });
      // 👇
      // get the parent id of the user's editable page
      $parent_id = $user->editable_pages[0]->parent_id; //there is always only one page
      $this->addHookBefore('ProcessPageList::execute', function (HookEvent $event) {
        // hide root (/) page in list (optional)
        $event->object->showRootPage = false;
        // limit number of pages shown - that's the trick to avoid pagination in the lister
        $event->object->limit = 100; // you might need to adjust this value
      });
      $this->addHookAfter('ProcessPageList::execute', function (HookEvent $event) use ($parent_id) {
        // run only on ajax requests
        if ($this->config->ajax) {
          // manipulate the json returned
          $json = json_decode($event->return, true);
          // remove any pages that are not editable or addable and not the parent page
          foreach ($json['children'] as $key => $child) {
            $p = $this->pages->get($child['id']);
            if (!$p['editable'] && !$p['addable'] && $p['id'] !== $parent_id) {
              // remove the page from the json
              unset($json['children'][$key]);
            }
          }
          // set the json back to the event
          $json['children'] = array_values($json['children']);
          $event->return = json_encode($json);
        }
      });
    }

    Clipboard01.png.e0d373b4ba712e0e2d6ed454c4a67aa0.png

    • Like 2
  5. On 11/21/2022 at 8:49 PM, James Morris said:

    I am getting an error of 'Class "DUP_Logs" not found' when upgrading to the latest version (1.4.26) when using the Amazon S3 option.  The provided SDK is on place, all was working fine before the upgrade.  Reverting back to 1.4.0 solved the problem.  Here is the full call stack for reference:

    Fixed it, it will be released in Duplicator v1.5.0. I tested AWS, no problem found. I will release also the updated Duplicator-SDKs.

     

    On 3/23/2023 at 8:47 PM, adrian said:

    I am still confused why the .zip is kept - shouldn't that be deleted after the creation of the .zip.enc file?

    It's committed.

  6. 2 hours ago, adrian said:

    Actually, should both be exactly the same file size - does the encryption not result in some change?

     

    Missed your question, and the answer is not necessarily.

    In our case, we use asymmetric file encryption and the lib run his seals operations on a resource implementing StreamInterface (PSR-7). Just to say that, without going into deep details, the methods read the file from a stream block by block, with a defined buffer size, and a minimum shortest cypher text of 100 bytes, then run the cipher algo (XChaCha20) on the blocks till the EOF. This mean that your file should have the same size. The encrypted file could have 100 bytes more than the source.

    You can try to run in the terminal `du -b source_file` and `du -b encrypted_file` to compare them. By curiosity, you can also test it with openssl by running :

    `openssl enc -d -chacha20 -K YOUR_PUBLIC_KEY -iv 0123456789abcdef0123456789abcdef -in SOURCE.zip > ENCRYPTED.zip`

    (the difference between Chacha20 and XChacha20 is the last use an extended nonce, the result should be same size).

  7. 16 minutes ago, adrian said:

    I am still confused why the .zip is kept - shouldn't that be deleted after the creation of the .zip.enc file?

    Yes sorry, I edited my post after posting it.

    17 minutes ago, adrian said:

    I came across the timeout when trying to run a backup from ProcessDuplicator using the native DB / local only options - I still think this need to work.

    Yes ok, that's what I had in mind. Actually, with Halite, it shouldn't be possible. The only solution I have in mind after I read the C library yesterday, is the need to write another wrapper to be able to set max execution time limit in the process. This is what I meant on my previous post > As I have no control over the stream (Halite seal encryption use chunks on stream when using the File class)...

    • Like 1
  8. Hi @adrian hope you are fine and thanks for testing.

    1 hour ago, adrian said:

    Actually, it's just a case of inverted logic in your code

    Oh common! 🤭 I introduced it when testing the ui and pushed as is - corrected.

    On your second post, we can see that everything look ok to use it. Can you tell me if you are on a DigitalOcean solution or maybe an AWS one ?

    Anyway, the cause of #3 is due to the max_execution_time limit. Can you tell me which options you use in Duplicator settings (cron, local, google) ? 

    I will test with GoogleDrive right now to see what happen, I have not tested it with the encryption enabled. In local mode only, you should not hit the limit (but that's depend your server type), as the php-cli is by default not supposed to be interfered by this settings, only if set some where, and that's the reason we call cron.php from the task scheduler or from the terminal. As I have no control over the stream (Halite seal encryption use chunks on stream when using the File class), it will hit this limit on nearly each managed host (at least I think).

    #2 There will be an options available to keep the zip or not. By default it will be deleted if encryption is enabled.

     

    1 hour ago, adrian said:

    Do you think it would make sense to override the php time limit within this process to avoid this?

    I could make a settings available to adjust this, but again, we need to see from where the value is set. I bet it's the google mode. If not, I will try to find in you hosting provider documentation if there is a limit set on the php-cli. Checking and listening to your answer about this.

  9. Then I must say that the bad performances was due to my machine and/or setup (caddy/php-fpm, thats is quite bad and sad on Windows).

    On the Windows Server, performance are 🚀 !

    A backup of a setup of 2.11GB, once compressed, 801MB, the whole process took 107sec 🎉🎉

    • encryption: 2.5sec
    • decryption: 3.5sec
    Quote

    2023-03-23 16:17:10    root    /backend/setup/duplicator/?action=backup_now    Backup Database
    2023-03-23 16:17:10    root    /backend/setup/duplicator/?action=backup_now    - Backup using native tools
    2023-03-23 16:18:50    root    /backend/setup/duplicator/?action=backup_now    - package built successfully in 100.684342sec
    2023-03-23 16:18:50    root    /backend/setup/duplicator/?action=backup_now    - package encryption starting...
    2023-03-23 16:18:53    root    /backend/setup/duplicator/?action=backup_now    - package encryption success, took 2.431822sec
    2023-03-23 16:18:53    root    /backend/setup/duplicator/?action=backup_now    - package decryption starting...
    2023-03-23 16:18:56    root    /backend/setup/duplicator/?action=backup_now    - package decryption success, took 3.465724sec
    2023-03-23 16:18:56    root    /backend/setup/duplicator/?action=backup_now    - package saved in local folder: 2023-03-23_16-17-29-test.me.package2.zip
    2023-03-23 16:18:56    root    /backend/setup/duplicator/?action=backup_now    - orphaned log files not cleaned (disabled by settings)
    2023-03-23 16:18:56    root    /backend/setup/duplicator/?action=backup_now    - job finished in 106.586344sec

    Not bad 🙂

     

    • Like 2
  10. 4 hours ago, szabesz said:

    Under 4 hours 27 mins 52 secs?

    Yes, but was the whole process, encrypting the 687MB and decrypting it. Encrypting took nearly 1h48. On my side, it's not usable as I have some databases of 7GB or even 11GB, and a custom tool handle it, but of course, it's only available on private server where we have the hand on it. I will launch this afternoon a test on a Windows Server with Xeon CPU and 32GB of RAM, let's see..

    The issue of processing time will be tackled, but only on a private server. Anyway, having a huge database or file size on a shared server should not be too frequent (I have no stats to look at..). 

     

    Do not take care of performance info given on this post, see 👇

    • Like 1
  11. Incoming update of Duplicator v1.5

    ---

    Encryption is being implemented, if you want to give a try, the feature is available on the branch feature-encryption :

    -  https://github.com/flydev-fr/Duplicator/tree/feature-encryption

    More infos and Instructions can be found by reading or running the script generate-keys.php on a terminal.

    ---

    I shared infos with Steve, I also want to share it with you :

     => Test on a Package of 687MB on PHP8.1

    Quote

    2023-03-22 21:30:55    guest   http://processwire.sek/http404/  Backup Database
    2023-03-22 21:30:55    guest   http://processwire.sek/http404/  - Backup using native tools
    2023-03-22 21:31:14    guest   http://processwire.sek/http404/  - package built successfully in 18.953901sec
    2023-03-22 21:31:14    guest   http://processwire.sek/http404/  - package encryption starting...
    2023-03-22 23:19:16    guest   http://processwire.sek/http404/  - package encryption success, took 6482.159817sec
    2023-03-22 23:19:16    guest   http://processwire.sek/http404/  - package decryption staring...
    2023-03-23 01:58:47    guest   http://processwire.sek/http404/  - package decryption success, took 9571.181766sec
    2023-03-23 01:58:47    guest   http://processwire.sek/http404/  - job finished in 16072.312503sec

    Do not take care of performance info given on this post, see 👇

    • Like 3
  12. There are not so many, it's only the vars of the pw-theme that need to be done.

    For the native dark theme (inverse), you can try it by adding `uk-dark` to the body, but will also see that there are some hardcoded value (like the background with #fff) in the pw theme.

    Will make a example, with a simple script, we can automate the vars declaration 🙂 stay tuned.

    Example :👇

     

    0.png

    1.png

    2.png

    • Like 2
  13. From mobile, but try that:

    on the bottom of your less variables, write:

    :root {
      —rf-primary: @rf-primary;
    }
     

    Then save and refresh, you can now from your CSS module just call like :

    .rock-textfield {
      color: var(—rf-primary);

    }

    You will see exposed var in the devtool too. And then we will be able to use ‘inverse’ color without overriding everything.

    🙂

    • Like 1
  14. On 3/18/2023 at 2:12 PM, bernhard said:

    Where is that variable coming from? Is that already part of uikit or did you add that?

    From nowhere, but that's the missing part, I will push a fork of the official AdminThemeUikit so you can try it. The `pw-theme` should expose by default a `:root { --text-color; --bg-color; etc. }` to be used in CSS files shipped with our modules.

     

    On 3/18/2023 at 2:12 PM, bernhard said:

    You might have a look at https://github.com/baumrock/Scss 

    I Will do that.

    On 3/18/2023 at 2:12 PM, bernhard said:

    Didn't want to sound offending, sorry if I did.

    Nahh 🙂

    • Like 1
×
×
  • Create New...