Sulu CMF: Access control to parts of the website

I try to create a password protected area of a webpage using Sulu CMF and have problems making it work properly.

I followed this guide: https://docs.sulu.io/en/2.5/cookbook/user-context-caching.html

As a consequence, when activating permissions for a subpage in the admin, the page is not displayed in the navigation anymore, which is good. But I am still able to display the page using the corresponding url in the browser, instead of beeing redirected to the login page.

What am I missing?

Subject: Azure Blob Storage – Issue with MAC Signature Mismatch in Block Blob Upload

I’m currently facing an issue with uploading block blobs to Azure Blob Storage using the REST API. I’m constructing the string-to-sign as per the Azure documentation, but I’m consistently receiving a 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. error.

$str2sign = "PUTnnn$blockSizenn$blockMimeTypennnnnnx-ms-blob-type:BlockBlobnx-ms-date:$Datenx-ms-version:2019-12-12n$headerResourcen$urlResource";

Where $headerResource is x-ms-blob-type:BlockBlobnx-ms-date:$Datenx-ms-version:2019-12-12 and $urlResource is /$storageAccountname/$containerName/$blobNamenblockid:" . urlencode($blockId) . "ncomp:block".

I’m then creating the signature as follows:

<?php
$sig = base64_encode(hash_hmac('sha256', urldecode(utf8_encode($str2sign)), base64_decode($accesskey), true));
?>

And the authorization header:

<?php
$authHeader = "SharedKey $storageAccountname:$sig";
?>

The headers for the request are set as follows:

<?php
$headers = [
  'Authorization: ' . $authHeader,
  'x-ms-date: ' . $Date,
  'x-ms-version: 2019-12-12',
  'Content-Length: ' . strlen($blockList),
  'Content-Type: application/xml',
];
?>

And the request is sent using curl:

<?php
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $blockList);

$result = curl_exec($ch);
?>

Despite following the documentation, I’m still facing this issue. I’ve also ensured that the Content-Length header is included in the string-to-sign if it is included in the request, and that the query parameters in the CanonicalizedResource part of the string-to-sign are in lexicographical order.

Interestingly, I have other functions for uploading and showing blobs that are working fine, which are using the same method for authentication. Here’s an excerpt from the show function:

<?php
// Azure Blob Storage download
$Date = gmdate('D, d M Y H:i:s GMT');

$headerResource = "x-ms-date:$Datenx-ms-version:2019-12-12";
$urlResource = "/$storageAccountname/$containerName/$blobName";

$arraysign = array();
$arraysign[] = 'GET';               /*HTTP Verb*/
$arraysign[] = '';                  /*Content-Encoding*/
$arraysign[] = '';                  /*Content-Language*/
$arraysign[] = '';                  /*Content-Length (include value when zero)*/
$arraysign[] = '';                  /*Content-MD5*/
$arraysign[] = '';                  /*Content-Type*/
$arraysign[] = '';                  /*Date*/
$arraysign[] = '';                  /*If-Modified-Since */
$arraysign[] = '';                  /*If-Match*/
$arraysign[] = '';                  /*If-None-Match*/
?>

I would appreciate any guidance or suggestions on what might be causing this issue and how to resolve it.

Thank you.

shopify private app is not installed giving me this error

I have cross checked my redirect link is valid oauth even. I have created so many app for shopify private but this one is giving me an

The installation link for this app is invalid
The link for installing MeloshluxurygateSlink2 cannot be used. Contact the app developer for more information.

could you help me when this error come?

CodeIgniter 3: Function assignment by reference

I have a CodeIgniter 3 application that cannot be converted to CI4 or anything else for that matter given that it is a large application of over 2 million lines of code, is a business critical system, andthere is no budget or time to do this right now. I therefore need a solution other than instead of “Upgrade your platform” or “Use a different platform”, please 🙂

Here is the problem:

In CodeIgniter 3, the function get_instance() is declared by reference:

function &get_instance()
{
    return CI_Controller::get_instance();
}

We are getting this error on PHP 8.0.27 (it is not our production server – that is on PHP 8.1, we’re trying to test the waters on a test server before going to 8.2 on production):

Notice: Only variables should be assigned by reference in 
--------/views/errors/html/error_php.php on line 80

Some part of our code is broken, and our error handler is triggered, which bombs out in this case (original error is not shown – only the error that occurs in the error handler). Our error handler is obviously borked, which I am trying to resolve. It appears at the time this error occurs that the CI super object seems to be not available.

Solving the error that triggers the error handler would make this go away for this particular case, but is not a solution, because the next error that occurs will just bring it back, so hopefully someone has a solution to the fact that CI uses function &get_isntance() declaration which our PHP version does not like, preferably in such a way that I do not have to retrofit an entire 2 million line codebase (right now).

Issue with Shopware Installation Using XAMPP: “Shopware Could Not Be Downloaded”

I’m encountering an issue while trying to install Shopware using XAMPP. I followed a tutorial on YouTube (https://www.youtube.com/watch?v=h8ufOH8kHmA) and successfully downloaded the shopware-installer.phar.php file into my xampp/htdocs/shopware folder.

After starting the Apache server, I navigated to http://localhost/shopware/shopware-installer.phar.php/install and configured the PHP binary field value to C:xamppapachebinhttpd.exe on the page http://localhost/shopware/shopware-installer.phar.php/configure.

However, when I click the download button, I receive the following error message: “Shopware could not be downloaded. You can access the log file here.”

The content of the log file is as follows:

Usage: C:\xampp\apache\bin\httpd.exe [-D name] [-d directory] [-f file]
                                         [-C "directive"] [-c "directive"]
                                         [-w] [-k start|restart|stop|shutdown] [-n service_name]
                                         [-k install|config|uninstall] [-n service_name]
                                         [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
Options:
  -D name            : define a name for use in <IfDefine> directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -n name            : set service name and use its ServerConfigFile and ServerRoot
  -k start           : tell Apache to start
  -k restart         : tell running Apache to do a graceful restart
  -k stop|shutdown   : tell running Apache to shutdown
  -k install         : install an Apache service
  -k config          : change startup Options of an Apache service
  -k uninstall       : uninstall an Apache service
  -w                 : hold open the console window on error
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed vhost settings
  -t -D DUMP_RUN_CFG : show parsed run settings
  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
  -t -D DUMP_MODULES : show all loaded modules 
  -M                 : a synonym for -t -D DUMP_MODULES
  -t -D DUMP_INCLUDES: show all included configuration files
  -t                 : run syntax check for config files
  -T                 : start without DocumentRoot(s) check
  -X                 : debug mode (only one worker, do not detach)

How to add one year to a DateTime in a leap Year

I want to get the last day of the month of the next year from a given date

Here is how I did :

$copy = new DateTime();
$lastDay = new DateTime($copy->add((new DateInterval('P1Y')))->format('Y-m-t'));

This works exept in this exemple :

$copy = new DateTime('2024-02-29');
$lastDay = new DateTime($copy->add((new DateInterval('P1Y')))->format('Y-m-t'));

It returns me ‘2025-03-31’ while I want ‘2025-02-28’

File transfer from one host to another host through PHP and cURL

I want to transfer a file from one host to another through PHP and cURL. This is my code :

<?php
    $source = 'https://drive.google.com/uc?id=xxxxxxxxxxxxxxxxx&export=download';
    $fh = fopen( basename( $source ), 'w' );
    $ch = curl_init( $source );
    curl_setopt( $ch, CURLOPT_FILE, $fh );
    curl_exec( $ch );
    curl_close( $ch );
    fclose( $fh );
    echo 'yes';
?>

An empty file is created on the destination host with the name : uc?id=xxxxxxxxxxxxxxxxx&export=download.

I have 2 questions :

  1. Why does it show zero volume on the destination host?
  2. The name of the file on the source host is index.html, how can I change it from uc?id=xxxxxxxxxxxxxxxxxx&export=download to index.html when transferring to the destination host?

I hope you help. Thank you.

Php subtract returns a scientific notation value

I’m doing calculations for the accounting. When I trying the subtraction, it returns a scientific notation value.

Below is Sample Data for the Calculation

Year is 2021 
   [debit is 0.00]
   [credit is 0.00] 
   [Total is 0] 
   [OB is 0]
Year is 2022 
   [debit is 0.00] 
   [credit is 1229.40] 
   [Total is -1229.4] 
   [OB is -1229.4]
Year is 2023 
   [debit is 55048.52] 
   [credit is 53819.12] 
   [Total is 1229.4] 
   [OB is -5.911715561524E-12] 

Below is code for calculation

function ob($code,$year){
    $begin_year = report_begin_year();
    $bal        = 0;
    $m          = 'all';
    
    if($year == $begin_year) {
        return 0;
    }else{
        $year       = (is_array($year) && count($year) > 0 ? $year : explode(" ",$year));
        if(is_array($year)){
            $d  = str_replace( ',', '', get_total_debit($code,$m,$year[0]));
            $c  = str_replace( ',', '', get_total_credit($code,$m,$year[0]));  
            $t  = $d - $c;
            $ob = 0;
            for($i=$begin_year;$i<$year[0];$i++){                             
                $db = str_replace( ',', '', get_total_debit($code,$m,$i));
                $cr = str_replace( ',', '', get_total_credit($code,$m,$i)); 
                $tot= $db - $cr;
                $ob = $ob + $tot;   
            }            
            $bal = $ob;
            return $bal;
        }
    }
}

Function calling ob(23,2024);
It returns the value -5.911715561524E-12
But it should return 0;

Anyone can please help me to fix this. Thanks in Advance

Permalinks breaking daily

This has been going on for over a month, and there are times the permalinks are guaranteed to break (if we activate/deactivate Ocean Extra, modify a tag name (not the slug). There are also random times the permalinks break (I think corresponding to the host’s backups, but not always.) There are certainly times the permalinks break, when the site appears not to have been touched at all, by any staff.

We have deactivated and reactivated all the plugins, slowly, checking each one. The problem appears independent of plugins, aside from Ocean Extra. We have switched out theme from Ocean and Ocean Extra to Hello Elementor (as our site is with elementor), and we still have permalinks breaking daily.

The site host is adamant that it’s not them. We currently have cache disabled, as the caching system from the host was constant, and required a cache flush each and every time the site was updated. We are going to copy the site to another host, to rule out the hosting as the culprit.

Anything else we can check?

Expecting property name enclosed in double quotes in Laravel with Httpie command

working with Laravel project and httpie command prompt and I tried insert json type data in to the table using following command destination:='{"lat":12.323536, "lng": 23.359230}' origin:='{"lat": 35.293583, "lng": 39.203905}' but when I execute enter command cmd occurred following error message 'destination:={lat:12.323536, lng: 23.359230}': Expecting property name enclosed in double quotes: line 1 column 2 (char 1) how to fix this

PHP and SQL Server Login Page issue

I am trying to create a login page using php and sql server, but its not working. It looks like the $row_count is 0, because I’m getting the error message on the url.

I run the query on MS SQL Management Studio and it worked.

Here is my code:

include_once('connection.php');

if(isset($_POST['hidden_login'])) {
    $username = str_replace("'", "''", $_POST['username']);
    $password = $_POST['password'];
    
    $sql = "select 
    [login_id], 
    username,
    [password]
    from [login_authentication]
    where username = '$username' and password = '$password'";
    $stmt = sqlsrv_query( $conn, $sql, array(), array( "Scrollable" => 'static' ));
    $row_count = sqlsrv_num_rows( $stmt );
    if( $stmt === false ) { die( print_r( sqlsrv_errors(), true));}
    
    if($row_count == 0) {
        header("location: index.php?msg=Incorrect username or password&key=danger");
        exit;
    } else {
        #creates sessions
        while($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)){
            $_SESSION['login_id'] = $row['login_id'];
        }
        #redirects user
        header("Location: portal.php");
        }
    }

sqlsrv_close( $conn );

how to get source email details from google Calendar events source.url in JSON

so i’m working on my project, getting events from Google Calendar and i want to show the content body from email source, here is the example one of my events list return.

{
   "kind": "calendar#event",
   "etag": ""3408893757386000"",
   "id": "_6tlnaqrle5p6cpb4dhmj4phpegsncq3aclhmcr3ie9nnarbe6cs6iqbbephj4dbc6kp3ie346lo68tb2cpmn0predkpmcpr4ehlmed9ocpgme",
   "status": "confirmed",
   "htmlLink": "https://www.google.com/calendar/event?eid=XzZ0bG5hcXJsZTVwNmNwYjRkaG1qNHBocGVnc25jcTNhY2xobWNyM2llOW5uYXJiZTZjczZpcWJiZXBoajRkYmM2a3AzaWUzNDZsbzY4dGIyY3BtbjBwcmVka3BtY3ByNGVobG1lZDlvY3BnbWUgYXBwcy5zYXNtaXRvYmFndXNzQG0",
   "created": "2024-01-05T09:27:58.000Z",
   "updated": "2024-01-05T09:27:58.693Z",
   "summary": "Stay at Hilton San Francisco Union Square",
   "description": "To see detailed information for automatically created events like this one, use the official Google Calendar app. https://g.co/calendarnnThis event was created from an email you received in Gmail. https://mail.google.com/mail?extsrc=cal&plid=ACUX6DNFxHlx_cWuOdV_6Fygl9Yq3JSChNeHvX0n",
   "location": "Hilton San Francisco Union Square, San Francisco",
   "creator": {
    "email": "[email protected]",
    "self": true
   },
   "organizer": {
    "email": "[email protected]"
   },
   "start": {
    "date": "2027-04-11"
   },
   "end": {
    "date": "2027-04-14"
   },
   "transparency": "transparent",
   "visibility": "private",
   "iCalUID": "7kukuqrfedlm2f9t9vhjecflrroumn38iikvc25l5298d5pdubfmpgnm3fgdtkg58fag",
   "sequence": 0,
   "attendees": [
    {
     "email": "[email protected]",
     "self": true,
     "responseStatus": "accepted"
    }
   ],
   "guestsCanInviteOthers": false,
   "privateCopy": true,
   "reminders": {
    "useDefault": false
   },
   "source": {
    "url": "https://mail.google.com/mail?extsrc=cal&plid=ACUX6DNFxHlx_cWuOdV_6Fygl9Yq3JSChNeHvX0",
    "title": ""
   },
   "eventType": "default"
  }

i have tried to access link from source.url with accessToken but it just returned text/html, not the message id or anything that can lead me to email source details. or maybe anyone can show me the other way to get email body and events. * sorry for my bad english

i’m expecting to get both event details from google calendar and source email details that trigger events created from email markup hotel reservation in json.

proper opcache configuration for CLI

what is the proper opcache configuration when using PHP for CLI only?

I find very confusing/old resources and am not sure this is the proper conf:

[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.file_cache=/tmp/php-opcache

More specifically: the doc describe opcache.file_cache as a second level cache, SHM memory being the 1st level. But I can’t find any recent resource indicating whether the SHM memory is shared across PHP’s cli invocations depending on this, either opcache.file_cache isn’t nescessary or opcache.file_cache_only is required.

Secondly, I’d like to determine the required management over the content of the directory that opcache.file_cache points to

  • it should be created beforehand with the proper rights
  • should it be emptied of old files manually?