powershell – Understanding an Invoke-WebRequest call with output from Fiddler

I’m trying to upload an XML config file to a Netgate router, and the page they give you is a php form. This is a normal config file upload with the GUI – when I use the GUI page, Fiddler shows that the exchange looks like this (I note that the form data is typed and the value is a file):

Fiddler - using the GUI

I try throwing this at the invoke-web request:

$RestoreArguments =  @{
    __csrf_magic=$LoopCsrfToken;
    #nopackages=$true;
    #donotbackuprrd=$true;
    donotbackuprrd='yes';
    #encrypt=$false;
    encrypt_password='';
    conffile=(xml)(get-content $conffile);
    switch_safe_restore=$true;
    #decrypt=$true;
    decrypt_password=$LoopPW;
    restorearea=$RestoreArea;
    backuparea='';
    restore='Restore Configuration'
    }
$LoopResult = Invoke-WebRequest -timeoutsec 5 -WebSession $LoopSession -Uri "$Luri/diag_backup.php" -Method 'Post' -Body $RestoreArguments 

and Fiddler capture this:

Fiddler - PS attempt 1

I thought that maybe the issue is how it’s getting the content, so I replaced the conffile parameter like this:

conffile=(xml)(get-content $conffile);

but see Fiddler capture:

Fiddler - PS attempt 2

So now I think that it is how the parameter is typed, but am not sure how to give the page what it wants. As a sidenote, no errors from the code. Thank you for your thoughts!

orders – How to call block function in CMS page?

Version: Magento 2.4 EE

I want to show the Recently Ordered Items Block in CMS page but when I call the block in page, the block is not displaying as expected and the page is empty.

In CMS page, my code is as follows

{{block class="MagentoSalesBlockOrderRecent" template="Magento_Sales::order/recent.phtml"}}

The way which I have called the block is a right one?

Any help will be appreciated

java – Android Call Forwarding: How does Windows “Your Phone” app work with Android?

For a long time now, I have been unable to wrap my head around how Microsoft has been able to achieve forwarded android calls without special privileges. I know the more modern integrated Samsung features definitely have something akin to that (e.g. mirroring multiple apps on PC), but this shouldn’t be the case for base android features. Primarily, I am concerned with call forwarding. Everything else makes more sense.

A companion app is installed on the phone that is given required permissions, pairs to the PC then reads:notifications, call logs, media and folders. Notification access allows for certain notifications to get replies, in addition to obviously making them readable.

However, Android calls are very locked down for security. I’ve looked extensively for reference on how Microsoft achieved it but I could only find many pages of guides and news articles showing it off.

The closest hunch I had was that maybe the computer’s bluetooth chipset was acting like that of a headset but after trying it several months ago I came to a dead end. When the device class was all but a few the phone refused to connect, even with different devices and setups.

It would be nice to see a cross platform solution for this. I use a Mac and an Android Phone. Like many, I need the freedom of android but require a mac for development work. I hate how *Apple has its own protectionist ecosystem, however similar restrictions are appearing on the other side of the coin now too.

If someone could shed some light I’d really appreciate it. I would love to work on an open, and cross platform alternative soon. I’m aware proprietary solutions such as AirDoid exists but currently none with no call forwarding unfortunately. That is what seems the hardest part to figure out.

office 365 – Call external Web API in SharePoint online using SharePoint framework

Use jQuery getscript method for calling external API in SharePoint environment. In your spfx webpart code, install jQuery – npm i jQuery and use the following code snippet to call your external API.

$.getScript("test.js")
  .done(( script, textStatus )=> {
    console.log( textStatus );
  })
  .fail(( jqxhr, settings, exception )=> {
    console.log("Triggered ajaxError handler.");
});

On Windows, how shall I call arbitrary ACPI methods?

On Linux, the module acpi_call enables this, however I don’t see such a thing on Windows. Is it possible through WMI ? Or do I really need to write some kernel mode code ?

Note that I’m speaking of methods that already exist, it’s not about defining new methods.

As an example, suppose I want to call _SB.PCI0.PEG0.PEGP._OFF, how shall I do this ?

custom list – Call all the versions of a SharePoint comment’s field with AngularJS

So I’ve found a way to do this.
When I make the call (or request) of the SharePoint list, I just did another one inside the modal’s function to call the version history of the selected item.

HTML:
I make an ng-repeat of the elements requested and put an ng-click to open the modal when you click on the item’s title

<table>
   <tr>
      <th>ID</td>
      <th>name</th>
   </tr>
   <tr ng-repeat="x in data">
      <td>{{x.ID}}</div>
      <td ng-click="showDetails(x)">{{x.LinkTitle}}</div>
   </tr>
</table>

JS:
A normal http request. And in the Modal’s function I make the request for the version history

$http({
   method: "GET",
   url: "https://myDomain.com/sites/mySite/_api/web/lists/getByTitle('MyListName')/items?$select=*,LinkTitle,&$top=10000",
   headers: { "Accept": "application/json; odata=verbose" }
}).then(function onSuccess(response) {
   $scope.data = response.data.d.results;
         
   //Code that opens the modal when a certain item is clicked
   $scope.showDetails = function(x){

      //Request the versions of the clicked item. Notice in the URL I put the ID of current clicked item
      $http({
         method: "GET",
         url: "https://myDomain.com/sites/mySite/_api/web/lists/getbytitle('MyListName')/items(" + x.ID + ")/versions",
         headers: { "Accept": "application/json; odata=verbose" }
      }).then(function onSuccess(response) {
         $scope.versionsData = response.data.d.results;
      });

      $scope.x = x;
      $('#myModal').modal('show');
   }
});

Here is the modal’s HTML, I’m using Bootstrap’s modal.
I’ve made a list within a list. In the Comments I put an ng-repeat for the versions, filtering only the ones where the “comments” changed (with ng-if).

<div id="myModal" class="modal fade" role="dialog" tabindex="-1">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
         </div>
         <div class="modal-body">
            <ul class="detail-view">
               <li><b>Title</b></li>
               <li>{{x.LinkTitle}}</li>
               <li><b>Comments</b></li>
               <ul>
                  <li ng-repeat="f in versionsData" ng-if="f.Comments">
                     <!-- I tried to replicate the way SharePoint shows the info (with name, date and comment --->
                     {{f.Editor.LookupValue}} ({{f.Modified | date: 'MM/dd/yyyy'}}): {{f.Comments}}
                  </li>
               </ul>
               <li><b>Status</b></li>
               <li>{{x.Status}}</li>
                .
                .
                .
            </ul>
         </div>
      </div>
   </div>
</div>

themes – Ajax Call not Working in Plugin

I’ve been developing a website using WP and to display some database information in the front-end of the site i’ve created a plugin. Right now i want to include a filtering function for that same information using the plugin, but it does not work.

This is the file where i’ve created the filters, called **showcomidas

<div class="container">
    <div class="row">
        <br />
        <div class="col-md-3">                              
            <div class="list-group">
                <h6>Modo de Confeção</h6>
                <div style="height: 180px; overflow-y: auto; overflow-x: hidden;">
                <?php

                $query =  "SELECT * FROM win_gab_modo_confecao ORDER BY designacaoModoConfecao";
                $result = $wpdb->get_results($query);
                foreach($result as $row)
                {
                ?>
                <div class="list-group-item checkbox" style="font-size: 14;">
                    <label><input type="checkbox" class="common_selector modoconf" value="<?php echo $row->idModoConfecao ?>"  > <?php echo $row->designacaoModoConfecao ?></label>
                </div>
                <?php
                }

                ?>
                </div>
            </div><br>

            <div class="list-group">
            <h6>Modo de Serviço</h6>
                <div style="overflow-y: auto; overflow-x: hidden;">
                <?php

                $query2 =  "SELECT * FROM win_gab_modo_servico ORDER BY designacaoModoServico";
                $result2 = $wpdb->get_results($query2);
                foreach($result2 as $row2)
                {
                ?>
                <div class="list-group-item checkbox" style="font-size: 14;">
                    <label><input type="checkbox" class="common_selector modoserv" value="<?php echo $row2->idModoServico ?>"  > <?php echo $row2->designacaoModoServico ?></label>
                </div>
                <?php
                }

                ?>
                </div>

            </div><br>
            
            <div class="list-group">
            <h6>Sub Categoria 1</h6>
                <div style="height: 180px; overflow-y: auto; overflow-x: hidden;">
                <?php

                $query3 =  "SELECT * FROM win_gab_sub_categorias WHERE subCategoria1 = '1' ORDER BY designacaoSubCategoria";
                $result3 = $wpdb->get_results($query3);
                foreach($result3 as $row3)
                {
                ?>
                <div class="list-group-item checkbox"  style="font-size: 14;">
                    <label><input type="checkbox" class="common_selector sub1" value="<?php echo $row3->idSubCategoria ?>"  > <?php echo $row3->designacaoSubCategoria ?></label>
                </div>
                <?php
                }
                ?>  
                </div>

            </div><br>

        
            <div class="list-group">
            <h6>Sub Categoria 2</h6>
                <div style="height: 180px; overflow-y: auto; overflow-x: hidden;">
                <?php

                $query3 =  "SELECT * FROM win_gab_sub_categorias WHERE subCategoria2 = '1' ORDER BY designacaoSubCategoria";
                $result3 = $wpdb->get_results($query3);
                foreach($result3 as $row3)
                {
                ?>
                <div class="list-group-item checkbox"  style="font-size: 14;">
                    <label><input type="checkbox" class="common_selector sub2" value="<?php echo $row3->idSubCategoria ?>"  > <?php echo $row3->designacaoSubCategoria ?></label>
                </div>
                <?php
                }
                ?>  
            </div>
        </div>

        <div class="col-md-9">
            <br />
            <div class="row filter_data">
            </div>
        </div>
    </div>
</div>

Right after this is where the problem is i believe. We begin the JS instructions that will call a file in the plugin’s directory called fetch_data.php.

    $(document).ready(function(){

filter_data();

function filter_data()
{
    $('.filter_data').html('<div id="loading" style="" ></div>');
    var action = 'fetch_data';
    var minimum_price = $('#hidden_minimum_price').val();
    var maximum_price = $('#hidden_maximum_price').val();
    var modoconf = get_filter('modoconf');
    var modoserv = get_filter('modoserv');
    var sub1 = get_filter('sub1');
    var sub2 = get_filter('sub2');


    $.ajax({
        url:"fetch_data.php",
        method:"POST",
        data:{action:action, minimum_price:minimum_price, maximum_price:maximum_price, modoconf:modoconf, modoserv:modoserv, sub1:sub1, sub2:sub2},
        success:function(data){
            $('.filter_data').html(data);
        }
    });
}

function get_filter(class_name)
{
    var filter = ();
    $('.'+class_name+':checked').each(function(){
        filter.push($(this).val());
    });
    return filter;
}

$('.common_selector').click(function(){
    filter_data();
});

$('#price_range').slider({
    range:true,
    min:1000,
    max:65000,
    values:(1000, 65000),
    step:500,
    stop:function(event, ui)
    {
        $('#price_show').html(ui.values(0) + ' - ' + ui.values(1));
        $('#hidden_minimum_price').val(ui.values(0));
        $('#hidden_maximum_price').val(ui.values(1));
        filter_data();
    }
}); 

});

Following this code, it calls the fetch_data.php like i mentioned above:

global $wpdb;

if(isset($_POST("action")))
{
    $query = "
        SELECT * FROM win_gab_ficha_tecnica WHERE idFichaTecnica != '0' 
    ";
    if(isset($_POST("modoconf")))
    {
        $conf_filter = implode("','", $_POST("modoconf"));
        $query .= "
         AND modoConfecaoFichaTecnica IN('".$conf_filter."')
        ";
    }
   
    if(isset($_POST("modoserv")))
    {
        $serv_filter = implode("','", $_POST("modoserv"));
        $query .= "
         AND modoServicoFichaTecnica IN('".$serv_filter."')
        ";
    }
    
    if(isset($_POST("subcat1")))
    {
        $subcat1_filter = implode("','", $_POST("subcat1"));
        $query .= "
         AND subCategoria1 IN('".$subcat1_filter."')
        ";
    }
    
    if(isset($_POST("subcat2")))
    {
        $subcat2_filter = implode("','", $_POST("subcat2"));
        $query .= "
        AND subCategoria2 IN('".$subcat2_filter."')
        ";
    }
    
$result = $wpdb->get_results($query);
$total_row = $wpdb->rowCount();
    $output = '';
    if($total_row > 0)
    {
        foreach($result as $row)
        {
            

    $output .= '
                <div class="col-sm-4 col-lg-3 col-md-3">
                    <div style="border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; height:450px;">
                        <img src="https://wordpress.stackexchange.com/image/". $row('fotografiaFichaTecnica') .'" alt="" class="img-responsive" >
                        <p align="center"><strong><a href="#">'. $row('nomeFichaTecnica') .'</a></strong></p>
                        <p>Modo Confeção: '. $row('modoConfecaoFichaTecnica').' MP<br />
                        Modo Serviço: '. $row('modoServicoFichaTecnica') .' <br />
                        Sub-Categoria 1: '. $row('subCategoria1') .' GB<br />
                        Sub-Categoria 2: '. $row('subCategoria2') .' GB </p>
                    </div>
    
                </div>
                ';
            }
        }
        else
        {
            $output = '<h3>No Data Found</h3>';
        }
        echo $output;
    }

We’ve all the right calls in our plugin file for enqueuing scripts and all that stuff.
When we load the wordpress page where this info is supposed to be displayed, the filtering simply does not work, and we get this console error:

jquery-1.10.2.min.js?ver=1.0:4 POST http://itamgabalgarve.pt/page-comidas/fetch_data.php 404 (Not Found)

Also, like i previosuly mentioned this is a plugin that displays the info in our custom-made theme. The page (in the theme) contains a function that calls the plugin and displays our info:

if (function_exists(get_comidas()))

What best practices/principles could help me improve my routine call placement?

I’m trying to change my module’s outline since I feel I’m blocking some reuse possibilities, but I don’t know how to justify it under the lens of good practices/design principles. Keep in mind this is supposed to become a template for this type of module.

My reasoning for the proposed change lies with the possible reuse of the action subroutines whereas I could construct the chg_rec action by simply calling dlt_rec and add_rec. Currently, the reuse of the action routines to compose more complex actions is partially disabled, since I only want one log per action (CHG_REC) and because transaction_recovery would commit the sub-actions independently.

I do believe the better approach would be to have middleware to handle auth, logs, and transaction recovery, but my architecture isn’t there yet, so I would appreciate it if the conversation wouldn’t deviate into that part of the problem without tackling the question directly.

Right now my module outline looks like this (language RPG ILE):

 * Mainline -----------------------------------------------------------------------------------
C                   exsr      first_routine                                                    
C     action        caseq     'ADD_REC'     add_rec
C     action        caseq     'CHG_REC'     chg_rec
C     action        caseq     'DLT_REC'     dlt_rec
C                   cas                     not_recognized
C                   endcs                                 
C                   exsr      last_routine                                                     
 * ADD_REC -----------------------------------------------------------------------------------
C     add_rec      begsr                                                                      
C                   exsr      auth
C                   exsr      start_log                                                        
 * add record logic here...                                                                      
C                   exsr      end_log                                                          
C                   exsr      transaction_recovery
C                   endsr                                                                      
 * CHG_REC -----------------------------------------------------------------------------------
C     chg_rec      begsr                                                                      
C                   exsr      auth
C                   exsr      start_log                                                        
 * chg record logic here...                                                                      
C                   exsr      end_log                                                          
C                   exsr      transaction_recovery
C                   endsr                                                                      
 * DLT_REC -----------------------------------------------------------------------------------
C     dlt_REC      begsr                                                                      
C                   exsr      auth
C                   exsr      start_log                                                        
 * dlt record logic here...                                                                      
C                   exsr      end_log                                                          
C                   exsr      transaction_recovery
C                   endsr                                                                      
 * NOT_RECOGNIZED -----------------------------------------------------------------------------
C     not_recognizedbegsr                                                                      
C                   exsr      auth
C                   exsr      start_log                                                        
 * send error message                                                                          
C                   exsr      end_log                                                          
C                   exsr      transaction_recovery
C                   endsr                                                                      
 * FIRST_ROUTINE ------------------------------------------------------------------------------
C     first_routine begsr                                                                      
 * do some initializations here...                                                             
C                   endsr                                                                      
 * LAST_ROUTINE -------------------------------------------------------------------------------
C     last_routine  begsr                                                                      
 * cleanup if needed here...                                                                   
C                   return                                                                     
C                   endsr                                                                      

Right now my proposal is to move the four repeating subroutines (auth, start_log, end_log and transaction_recovery) to the first_routine and last_routine making them look like the following snippet and clearing up all the other routines.

 * FIRST_ROUTINE ------------------------------------------------------------------------------
C     first_routine begsr                                                                      
 * do some inicializations here...                                                             
C                   exsr      auth
C                   exsr      start_log                                                        
C                   endsr                                                                      
 * LAST_ROUTINE -------------------------------------------------------------------------------
C     last_routine  begsr                                                                      
C                   exsr      end_log                                                          
C                   exsr      transaction_recovery
 * cleanup if needed here...                                                                   
C                   return                                                                     
C                   endsr                                                                      

All modules have the first_routine and last_routine, so that isn’t something I’m adding as part of the proposal.

sharepoint online – How do we call Power Automate Flow using Javascript button click?

we have a requirement of triggering the power automate flow using javascript button, we are still using the classic sharepoint site, we need to pass an item id to the power automate if they select an item in the list view and click on the button.

On the power automate side we will fetch the item by id and try to perform some calculations and update a different list.

Any help would be highly appreciated.