Nginx downloading specific PHP file instead of executing

I moved a small bundle of scripts from Apache to Nginx. This is a directory full of files, where specific extensions (php, txt, js, html) need to be shown through one script, other files need to be downloaded, and directories need to be browseable. To note, gallery.php is currently not being used. All of this was functional with the htaccess below:

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !prettify.php
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteCond %{REQUEST_FILENAME} !upload.php
RewriteCond %{REQUEST_FILENAME} !gallery.php
RewriteRule ^(.*.(php|txt|js|html)) prettify.php?f=$1 (QSA,L)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ index.php?dir=$1 (L,QSA)

RemoveHandler .php .phtml .php3
RemoveType .php .phtml .php3
php_flag engine off

After trying a bunch of stuff, I landed on this nginx config, which allows me to see the main directory through index.php:

server {
    client_max_body_size 8M;
    listen 80;
    listen (::):80;

    server_name paste.<host>;

    error_log /vmdata/services/web/logs/paste.error.log;
    access_log /vmdata/services/web/logs/paste.access.log;

    root /vmdata/services/web/vhosts/paste;
    index index.php;

    location /index.php {
        fastcgi_pass php_php73-fpm:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    location /prettify.php {
        fastcgi_pass php_php73-fpm:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    location /upload.php {
        fastcgi_pass php_php73-fpm:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    location /gallery.php {
        fastcgi_pass php_php73-fpm:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    location ~* ^(.*.(php|txt|js|html))$ {
        try_files prettify.php?f=$1;

    location ~* ^(.*)/$ {
        try_files index.php?dir=$1;

    location / {
        try_files $uri $uri/ /index.php?dir=$1;

Files download fine, but the files matched by the location block for specific extensions start a download, containing the source of prettify.php. Directories don’t go to index.php, but simply cause a 404.

What am I doing wrong here? From what I understand, the 4 specific PHP file location blocks should be executed first (as they’re the longest), but somehow this isn’t working.

I could find lots of similar questions, but sadly none that really helped me

Any guidance would be much appreciated, if there’s specific reading I can do to actually understand where it’s going wrong that would be even better.

filesystem – File ownership for file tree php user ID – Folder permission 775

I have the same issue as the below topic, where all my folder are set to 755 but I am unable to run updates or upload new media due to folder permissions. Once I set it to 775, the problem is resolved.

However, in this thread above it mentioned to “set ownership of your file tree php user id”. In my namesco account I have the below FTP accounts:  

The website was uploaded using the example.com_admin

The owner/group of the files and folders for the website are:


If I am able to access the files and folders with the and reset the permissions to 755. Will this “set ownership of your file tree php user id” and also fix the problem?

php – IF statement not working – Any suggestions?

So I have a function which counts the amount of customer orders.

I want to show a congratulations modal that appears when a customer hits a specific amount of orders.

All of my code is working fine, except when I add this part to the IF statement:

|| in_array($count, $the_digits) && isset( $_COOKIE('tier_advance') ) && $_COOKIE('tier_advance') !== $count )

The cookie is being saved properly, and when saved the number is saved as the current value of count. The idea is that the modal will only show if:

A) their current count is in $the_digits array & the cookie is not set.
B) their current count is in $the_digits array & the cookie IS set, however the cookies value does not equal their current order $count amount.

This is to prevent the modal showing after the initial display, but still allow it to show again if they hit the next $count amount to move to the next tier.

Can’t figure out what is wrong. Or perhaps there is a better way to do this. All help appreciated.

        $the_digits = ('3','5','15','30','50');

        if ( in_array($count, $the_digits) && !isset( $_COOKIE( 'tier_advance' ) ) || in_array($count, $the_digits) && isset( $_COOKIE('tier_advance') ) && $_COOKIE('tier_advance') !== $count )  {
                    jQuery(document).on("click", "#tier_confirm", function(){            
                        // Set a cookie
                        Cookies.set("tier_advance", "' . $count . '", { expires: 356 });

            <!-- BEGIN Share Modal -->
            <div class="modal fade" id="tier_advance" tabindex="-1" role="dialog">
              <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                  <div class="modal-header text-center">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                  <div class="modal-body text-center">
                  <p>You are now a <strong class="all-caps"> ' . $tier_name . ' </strong>tier customer!</p>
                  <p>Expect some dope rewards to start coming your way!</p>
                  <div class="modal-footer modal-footer-centered">
                    <button id="tier_confirm" type="button" class="btn btn-secondary" data-dismiss="modal">Awesome, thanks!</button>
            <!-- END Share Modal -->';


php – How to fix “Object of class WP_Term could not be converted to string”?

I basically want to loop through each post I have and get the taxonomy/category id. After that I want to output those id’s into a single string (not as a numeric value), separated by a space.

I get this error when I try to echo the string: “Object of class WP_Term could not be converted to string”

Here is what i have so far:

          $taxonomy = wp_get_object_terms($post->ID, 'categories');
          $ids = "";
          foreach ($taxonomy as $cat) {
              $ids .= $cat;

php – Working with Bitcoin node on Windows as a developer?

I’m a web developer looking to integrate a Bitcoin node into a PHP application and I am unsure how I would go about interacting with the Bitcoin core in a developer environment for my machine.

The most straightforward way of doing it would be to just use JSONRPC to hit bitcoind‘s API.

My goal is to pull transaction history on a particular address without using any 3rd party APIs and as such I need to use some sort of Bitcoin interface to do that.

bitcoind doesn’t allow you to directly access an “address mapping”. Some applications (notably Electrum servers) build additional indexes which allow them to expose you “by address” APIs and other handy informations.

This usually is a tradeoff between storage vs efficiency.

I believe that I need to use the Bitcoin daemon in some sort of manner however I do not know how to use it on my current PC as It is a Windows 10 machine.

Bitcoin-core allows you to build on Windows and provides Windows binaries as part of the releases.

More subjectively, I usually recommend the Esplora API (which is more precisely the electrs fork of Blockstream’s API) which uses quite a lot of storage but is very efficient for address-based requests.

You can start it quite easily by using the Docker instructions, and for example set it up behind an nginx reverse proxy on a server so you can hit it (or just use Docker on your Windows machine).

javascript – Passing a value from an input field to a php function in WordPress?

When I select the category from the dropdown menu, it updates correctly in the input field. Ideally, it should update the recipe filter in recipeIndex.php.

I’ve tried wrapping the input in a form with method “get” but that still doesn’t work.

The HTML is in an HTML widget on the Recipe Index page. The CSS, JavaScript and PHP code are in separate snippets (I used the Woody Snippets WordPress plugin

Please help.


      <div class="dropdown">
        <div class="select">
          <span class="select_span">Select Category</span>
          <i class="fa fa-chevron-down"></i>
        <form action="" method="get">  
        <input type="hidden" name="category" id="category">
        <ul class="dropdown-menu" id="recipeDropdown">
            <li id="All" name="All" value="All">All</li>
          <li id="Vegan" name="Vegan" value="Vegan">Vegan</li>
          <li id="Vegetarian" name="Vegetarian" value="Vegetarian">Vegetarian</li>


.dropdown_container {
  width: 160px;

.select {
    width: 160px;

/*Styling Selectbox*/
.dropdown {
  width: 160px;
  display: inline-block;
  background-color: #fff;
  border-radius: 2px;
  box-shadow: 0 0 2px rgb(204, 204, 204);
  transition: all .5s ease;
  position: relative;
  font-size: 14px;
  color: #474747;
  height: 100%;
  text-align: left
.dropdown .select {
    cursor: pointer;
    display: block;
    padding: 10px;
.dropdown .select > i {
    font-size: 13px;
    color: #888;
    cursor: pointer;
    transition: all .3s ease-in-out;
    float: right;
    line-height: 15px
.dropdown:hover {
    box-shadow: 0 0 4px rgb(204, 204, 204)
.dropdown:active {
    background-color: #f8f8f8
}, {
    box-shadow: 0 0 4px rgb(204, 204, 204);
    border-radius: 2px 2px 0 0;
    background-color: #f8f8f8
} .select > i {
    transform: rotate(-90deg)
.dropdown .dropdown-menu {
    width: 100%;
    position: absolute;
    background-color: #fff;
    left: 0;
    margin-top: 1px;
    box-shadow: 0 1px 2px rgb(204, 204, 204);
    border-radius: 0 1px 2px 2px;
    overflow: hidden;
    display: none;
    overflow-y: auto;
    z-index: 9
.dropdown .dropdown-menu li {
    transition: all .2s ease-in-out;
    cursor: pointer
.dropdown .dropdown-menu {
    padding: 0;
    list-style: none
.dropdown .dropdown-menu li:hover {
    background-color: #f2f2f2
.dropdown .dropdown-menu li:active {
    background-color: #e2e2e2


var $ = jQuery;

    $('.dropdown').click(function () {
        $(this).attr('tabindex', 1).focus();
    $('.dropdown').focusout(function () {
    $('.dropdown .dropdown-menu li').click(function () {
        var value = $(this).attr("value");
        $(this).parents('.dropdown').find('input').attr('value', $(this).attr('id'));


// Posts or Portfolio Widget
add_action( 'elementor/query/recipe-index-filter', function( $query ) {
    // Modify the posts query here
    $category =  $_GET('category');
    $query->set( 'category_name', $category );
} );

php – How clean is my close_account code?

Hello i’m coding a social site and I need to know how clean this code is. I read other answers people told me from my previous questions like this and used it as guidelines. So now I wanna know if anything could be improved. Thank you.



include 'includes/header.php';

$userLoggedIn = $_SESSION('thesocial_username');

$post_id = isset($_POST('cancel')) ? header("Location: settings.php") : '';

if(isset($_POST('close_account'))) {
    $close_query = $con->prepare('UPDATE users SET user_closed = "yes" WHERE username = ?');
    $close_query->bind_param("s", $userLoggedIn);

    header("Location: register.php");


<div class="close_column close_account">
    <h4>Close Account</h4>
    Are you sure you want to close your account ?<br><br>

    Closing your account will hide your profile and activity from users.<br><br>
    You can reopen your account at anytime by logging in.<br><br>

    <form action="close_account.php" method="POST">
        <input type="submit" name="close_account" id="close_account" value="Yes, Close my account.">
        <input type="submit" name="cancel" id="update_details" value="Nevermind.">


ajax – Erro a chamada de Json com php

Estou a um certo tempo tentando implementar uma chamada de json, para poder pegar a session_id do pagseguro
eu até consigo pegar o id da session com o pagseguro mas não consigo enviar ela pro retorno do ajax…
sempre me da um erro de chamada de classe, mesmo colocando o ajax como asynt ou await.
Estou utilizando smarty como template de front-end, mas o erro da pra qualquer classe.


function iniciaSessao(){
        .then(function(response) {
            return response;
        .then(function(json) {



$Smarty = new Template();
$PagamentoPS = new PagamentoPS();


  curl_setopt($Curl,CURLOPT_HTTPHEADER,array("Content-Type: application/x-www-form-urlencoded; charset=UTF-8"));
  return $Xml;

Ele sempre me retorna esse erro a baixo

Fatal error: Uncaught Error: Class 'Template' not found in C:wamp64wwwclientespivastore-roomcontrollerrealizar_pagamentos.php on line 2

php – Erro no groub By do laravel, alguem pode me ajudar

Estou fazendo uma consulta assim


ele da um erro sempre que tento suar o groupBy

SQLSTATE(42000): Syntax error or access violation: 1055 'survey.surveys.title' isn't in GROUP BY (SQL: select `surveys`.`title`, `surveys`.`id` from `options` inner join `surveys` on `options`.`survey_id` = `surveys`.`id` group by `votes`)

Pesquisei sobre o erro, e ja coloquei o strict como false, mesmo assim o erro continua.