Shift records are not being updated

I’m having an issue, when i update the staff’s weekly shift in my timekeeper, some records do not get updated at all. Here’s my function which gets the args and updates the shift.
For all the forms that i fill, i see the record updated JS popup in the bottom left.

function update_staff_shift($arg1, $arg2, $arg3, $arg4, $arg5)
{
    $model = new Staff_shiftController;
    $args = array($arg1, $arg2, $arg3, $arg4, $arg5);
    foreach ($args as $argkey => $argitem){
        if (isset($argitem)) {
            $args[$argkey] = rawurldecode(rawurldecode($argitem));
        }
    }
    $data = call_user_func_array(array($model, 'auto_update_staff_shift_edit'), $args);
    render_json($data);
}

But to me it looks like the problem is in my javascript code. For some reason when i set the shifts,
the ones that don’t get updated, don’t connect to the javascript at all. I can see this in the network inspector, the request url is the same but the response header is different :

(HTTP/1.1 200 OK
Date: Sat, 22 Jul 2023 07:40:02 GMT
Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1p PHP/7.4.33
X-Powered-By: PHP/7.4.33
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Content-Length: 2268
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8).

The shifts that do get updated always it shows this:

(HTTP/1.1 200 OK
Date: Sat, 22 Jul 2023 07:40:00 GMT
Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1p PHP/7.4.33
X-Powered-By: PHP/7.4.33
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Content-Length: 67
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8).

The records get updated as i’m setting the shifts, at the end when i click submit

$(document).on("click", "#manager_submit", function() {
    $('#staff_shift_content').submit();
});

the ones that are active(content-type application/json) are going to get updated. The other ones just get archived(i can see this in mysql database) and don’t get updated.

I tried debugging the code from the start, but the project is huge and this will take ages since we are just 2 developers. I tried to make the records get updated and submitted when you only click submit and not when you select a form to automatically get updated, but no luck.
I tried to explain as briefly as i can since there is a lot of code.

File input doesnt show up in $_POST [duplicate]

I have this input form field:

              <div class="inputContainer">
                <img src="images/3_randomfilm.jpeg" alt="image" width="100">
                <label for="radioEdit1" class="labelForm radioLabel">Afbeelding
                        <input type="radio" name="radio" value="radioAfbeelding" id="radioEdit1" onclick="showEditInput('file')" checked />
                        <span class="checkmark"></span>
                </label>
                <label for="radioEdit2" class="labelForm radioLabel">Video
                    <input type="radio" name="radio" value="radioYoutube" id="radioEdit2" onclick="showEditInput('url')"/>
                    <span class="checkmark"></span>
                </label>
                        <input type="file" id="fileEditInput" name="fileEditInput" class="input hidden" accept="image/png, image/jpg, image/gif, image/jpeg">
                        <input type="url" id="urlEditInput" name="youtube_url" class="input hidden" value="">
              </div>

When I try to post this, everything posts except the fileEditInput. I just dont get it… Why does this not post?

 <input type="file" id="fileEditInput" name="fileEditInput" class="input hidden" accept="image/png, image/jpg, image/gif, image/jpeg">

This is how I post it in PHP if you want to know:

$_POST['fileEditInput']

I tried giving it another name, but I just dont know how this can be wrong. Maybe I mistyped something but right now I cant just see it…

I hope you all can help me…

Tron api get the number of burned TRX before making a transaction

Need to receive a network commission for the transaction, as this is done in the trust wallet.

  1. Specify the wallet address
  2. Enter the amount of TRX to send
  3. Click Continue.
  4. And output, example “Network Fee: ~0.265 TRX”.

I use php language

I’ve been searching Google for 2 weeks now and can’t figure out how to do it.

How can I import static file to populate message in controller?

I have a Laravel API project where I want to hardcode response messages and to reuse them in any controller, How can I achieve this?

I have created response.php under APPTraits folder which has below code:

<php 
    return = [ 'success' => 'Response successfull!!!', 'error' => 'Error Authenticating']
?>

In my controller I tried to import via construct function, its now working:

    use AppTraitsresponse;
    public function __construct( response $response) {
        $this->response = $respose;
    }

$this->response->success;  // outputs message

Please help me. I wanted to understand how do we import such files, JSONs or any other utility function to reuse?

Make a discount depending on the country in woocommerce

Because it does not work?
I want it to also have the client’s IP to geolocate it help me
I already tried many times but I can’t get it to work.

function obtener_pais_por_ip() {
    // Reemplaza 'TU_CLAVE_DE_API' con tu clave de API de ipstack
    $api_key = 'TU_CLAVE_DE_API';

    $user_ip = $_SERVER['REMOTE_ADDR'];

    // Realizar la solicitud a ipstack
    $response = wp_remote_get("http://api.ipstack.com/$user_ip?access_key=$api_key");

    if (is_wp_error($response)) {
        return false;
    }

    $body = wp_remote_retrieve_body($response);
    $data = json_decode($body);

    return $data->country_code;
}

function aplicar_descuento_por_pais($price, $product) {
    $user_country = obtener_pais_por_ip();

    // Define los países elegibles para el descuento y el porcentaje del descuento para cada país
    $countries_discount = array(
        'ES' => 10, // 10% de descuento para España (código ISO 'ES')
        'US' => 15, // 15% de descuento para Estados Unidos (código ISO 'US')
        // Agrega más países y sus respectivos porcentajes de descuento según tus necesidades
    );

    if (isset($countries_discount[$user_country])) {
        // Aplicar el descuento si el país del usuario está en la lista de países elegibles
        $discounted_price = $price * (1 - ($countries_discount[$user_country] / 100));
        return $discounted_price;
    }

    // Si el país del usuario no está en la lista de países elegibles, retornar el precio sin descuento
    return $price;
}

add_filter('woocommerce_product_get_price', 'aplicar_descuento_por_pais', 10, 2);

I want to make them have discounts depending on the country

/:id in node. Is there something similar to that in php

I worked with nodejs and I was working with router/:id, so is there something similar to that I php?

I need something similar to that.

Thanks for reading my question.

I think that thing is the most powerful thing. So is there anything similar to that I php? And how can I do it I there are?

Why the login page in PHP is not working? [closed]

index.php:

<?php
// index.php

session_start();

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Retrieve the submitted login form data
    $username = $_POST['username'];
    $password = $_POST['password'];

    // Validate the login credentials
    // Query the database to check if the username and password match
    // You'll need to replace 'citizens' with the actual table name and adapt the query accordingly

    // Assuming you're using MySQLi
    $mysqli = new mysqli('localhost', 'root', '', 'online_fir');

    $stmt = $mysqli->prepare("SELECT id, password FROM police WHERE Email = ?");
    $stmt->bind_param("s", $username);
    $stmt->execute();
    $stmt->store_result();

    if ($stmt->num_rows === 1) {
        // User found, verify the password
        $stmt->bind_result($id, $storedPassword);
        $stmt->fetch();

        if ($password === $storedPassword) {
            // Store relevant information in the session
            $_SESSION['user_id'] = $id;
            $_SESSION['username'] = $username;

            // Redirect the user to the welcome page or perform other actions
            header("Location: home.php");
            exit();
        }
    }

    // If the login credentials are invalid, show an error message or redirect back to the login page
    $error = "Invalid username or password.";
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>FIR</title>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <header>
        <div class="navbar">
            <a href="index.php">
                <div class="logo">
                    <img src="img/logo.jpg" alt="Logo" oncontextmenu="return false;">
                    <span class="logo-text">NYPD</span>
                </div>
            </a>
        </div>
    </header>

    <div class="login-container">
        <h2 class="login-title">Login</h2>
        <form method="POST" action="index.php">
            <div class="form-group">
                <label for="username">Username:</label>
                <input type="text" id="username" name="username">
            </div>

            <div class="form-group">
                <label for="password">Password:</label>
                <input type="password" id="password" name="password">
            </div>
            <div class="error">
                <?php if (isset($error)) { ?>
                <p<p style="color:red;"><?php echo $error; ?></p>
                <?php } ?>
            </div>
            <button type="submit">Login</button>
            <a href="register.php">Register User</a>
        </form>
    </div>
</body>
</html>

This is my code. Everything worked fine few days before. Now it’s not working. When I try to login, it says “Invalid username or password” even if the username and the password is correct. Anyone please help.

PS: I’m using XAMPP Server. And I’ve stored the password in the database as plain text.

I tried to login. But its not logging-in. It says “Invalid username or password” even if the username and the password is correct.

RECV_VIDEO_DECODE_FAILED_RECOVER, uid: 3

When I initiate a 1-to-1 video call from the web to Android, I encounter a black screen problem. However, I must mention that the video call between two Android devices is working perfectly fine. During the web-to-Android video call, I notice that the remote device’s video status changes from “playing” to “waiting.” This inconsistency is causing a disruption in our video communication.

i have tred to join both uers to the channel, and tthey started to do audio call, when case is video the receive end android is giving black video , or the video is not playng but web to web or andorid to android is fine

Creating Custom REST API in WordPress

To create custom APIs on my WordPress website, I have installed two plugins: “WP REST API v2” and “JWT Authentication for WP-API.” However, I am encountering difficulties as I cannot seem to write any data into the database despite my efforts.

The website is hosted on Auba.

Here my .php file :

<?php
/*
Plugin Name: Custom API
Description: Plugin per le API personalizzate per la tabella custom_table.
*/

// Esempio di impostazione di sql_mode
global $wpdb;
$wpdb->query("SET SESSION sql_mode = 'valore_desiderato';");

// Registra le routes API personalizzate
add_action('rest_api_init', 'register_custom_api_routes');

function register_custom_api_routes() {
    register_rest_route('custom/v1', '/data', array(
        'methods' => 'GET',
        'callback' => 'get_custom_data',
    ));

    register_rest_route('custom/v1', '/data', array(
        'methods' => 'POST',
        'callback' => 'create_custom_data',
        'permission_callback' => function () {
            return current_user_can('edit_posts'); // Solo gli utenti con il permesso di edit_posts possono creare nuovi dati
        },
    ));

    register_rest_route('custom/v1', '/data/(?P<id>d+)', array(
        'methods' => 'PUT',
        'callback' => 'update_custom_data',
        'permission_callback' => function () {
            return current_user_can('edit_posts'); // Solo gli utenti con il permesso di edit_posts possono aggiornare i dati
        },
    ));

    register_rest_route('custom/v1', '/data/(?P<id>d+)', array(
        'methods' => 'DELETE',
        'callback' => 'delete_custom_data',
        'permission_callback' => function () {
            return current_user_can('edit_posts'); // Solo gli utenti con il permesso di edit_posts possono eliminare i dati
        },
    ));
}

// Funzione per ottenere tutti i dati dalla tabella custom_table
function get_custom_data() {
    global $wpdb;
    $table_name = $wpdb->prefix . 'custom_table';
    $query = "SELECT * FROM $table_name";
    $results = $wpdb->get_results($query, ARRAY_A);
    var_dump($results);
    return rest_ensure_response($results);
}

// Funzione per creare un nuovo dato nella tabella custom_table
function create_custom_data($request) {
    $data = $request->get_json_params();
    if (empty($data['nome'])) {
        return new WP_Error('empty_data', 'Il campo "nome" non può essere vuoto.', array('status' => 400));
    }

    global $wpdb;
    $table_name = $wpdb->prefix . 'custom_table';
    $wpdb->insert($table_name, array('nome' => $data['nome']), array('%s'));
    $id = $wpdb->insert_id;

    return rest_ensure_response(array('id' => $id, 'nome' => $data['nome']));
}

// Funzione per aggiornare un dato esistente nella tabella custom_table
function update_custom_data($request) {
    $data = $request->get_json_params();
    if (empty($data['nome'])) {
        return new WP_Error('empty_data', 'Il campo "nome" non può essere vuoto.', array('status' => 400));
    }

    $id = $request->get_param('id');
    global $wpdb;
    $table_name = $wpdb->prefix . 'custom_table';
    $wpdb->update($table_name, array('nome' => $data['nome']), array('id' => $id), array('%s'), array('%d'));

    return rest_ensure_response(array('id' => $id, 'nome' => $data['nome']));
}

// Funzione per eliminare un dato dalla tabella custom_table
function delete_custom_data($request) {
    $id = $request->get_param('id');
    global $wpdb;
    $table_name = $wpdb->prefix . 'custom_table';
    $wpdb->delete($table_name, array('id' => $id), array('%d'));

    return rest_ensure_response(array('message' => 'Dato eliminato con successo.'));
}

I get a 200 response for each API call, but in reality, I don’t see any data being saved in the database. As an administrator, I have all the necessary permissions for both reading and writing to the database, and the website functions without any issues, as I can save articles, images, etc.

What I’m doing wrong?

My update function in my controller is not run at all

I created my model with this command php artisan make:model BuildingOnRent -mcr which created the controller and the resources.

In my web.php, I passed the resource route like this

My web.php

Route::resource('br', BuildingOnRentController::class);

In the controller scaffolded by Laravel herself, I added the code under the update function like this.

My controller

public function update(Request $request, BuildingOnRent $br)
    {
        echo $br;
        $request->validate([
            'purpose'=>'required',
            'rooms'=>'required',
            'bathrooms'=>'required',
            'parlour'=>'required',
            'rent_period'=>'required',
            'cost'=>'required',
            'city'=>'required',
            'state'=>'required',
            'locate'=>'required',
        ]);
        dd($br);
        $br->update($request->all());

        return redirect()->route('br.index')->with('success','Property updated successfully');
    }

My edit.blade form action

action="{{ route('br.update',['br'=>$br]) }}"

When I fill and submit the form in the edit.blade, hence triggering the update function in the controller, I am redirected to the route br.index but nothing is updated. In fact, the update code is not even run as I tried to echo $br and dd($br) but nothing was echoed or dumped. I take it that the update code is not run at all.

Why is the update code block not run?

How can I make it to run?

I am using laravel 10. Please help out.

is_paged returning fales incorrectly | WordPress Comments

I have modified the comments.php file of the theme, but I’m told the is_paged is returning false when the comments are actually paginated.

Here is the code:

<?php
/**
 * The template for displaying comments.
 *
 * This is the template that displays the area of the page that contains both the current comments
 * and the comment form.
 *
 * @package HelloElementor
 */

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

if (!post_type_supports(get_post_type(), 'comments')) {
    return;
}

if (!have_comments() && !comments_open()) {
    return;
}

// Comment Reply Script.
if (comments_open() && get_option('thread_comments')) {
    wp_enqueue_script('comment-reply');
}

// Check if we're on a paginated comments page
$is_comments_paged = (get_query_var('cpage') > 1);

?>
<section id="comments" class="comments-area">
    <?php
    comment_form(
        [
            'id_form'       => 'commentform',
            'comment_field' => '<p class="comment-form-comment"><label for="comment">' . __('Join the discussion', 'text-domain') . '</label><textarea id="comment" name="comment" cols="45" rows="5" style="height: 100px;" placeholder="' . __('Type Here...', 'text-domain') . '" aria-required="true"></textarea></p>',
            'fields'        => [
                'author' => '<p class="comment-form-author"><label for="author">' . __('Display Name', 'text-domain') . '</label> ' .
                    ($req ? '<span class="required">*</span>' : '') .
                    '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30" placeholder="' . __('Display Name', 'text-domain') . '"' . $aria_req . ' /></p>',
                'email'  => '<p class="comment-form-email"><label for="email">' . __('Email Address (Not Shown Publicly)', 'text-domain') . '</label> ' .
                    ($req ? '<span class="required">*</span>' : '') .
                    '<input id="email" name="email" type="email" value="' . esc_attr($commenter['comment_author_email']) . '" size="30" placeholder="' . __('Email (Not Shown Publicly)', 'text-domain') . '"' . $aria_req . ' /></p>',
            ],
        ]
    );

    if (have_comments()) : ?>
        <h3 class="title-comments">
            <?php
            $comments_number = get_comments_number();
            if ('1' === $comments_number) {
                printf(esc_html_x('One Comment', 'comments title', 'hello-elementor'));
            } else {
                printf(
                    esc_html(_nx(
                        '%1$s Comment',
                        '%1$s Comments',
                        $comments_number,
                        'comments title',
                        'hello-elementor'
                    )),
                    esc_html(number_format_i18n($comments_number))
                );
            }
            ?>
        </h3>

        <ol class="comment-list">
            <?php
            wp_list_comments(
                [
                    'style'       => 'ol',
                    'short_ping'  => true,
                    'avatar_size' => 42,
                ]
            );
            ?>
        </ol><!-- .comment-list -->

        <?php
        ob_start(); // Start output buffering.
        paginate_comments_links(['prev_text' => '&lsaquo; BACK', 'next_text' => 'MORE &rsaquo;']);
        $pagination = ob_get_clean(); // Get output and stop buffering.
        echo str_replace('<a', '<a rel="nofollow"', $pagination); // Add rel="nofollow" to the links.
        ?>

    <?php endif; // Check for have_comments(). ?>

</section><!-- .comments-area -->

Here is the page:
https://www.symetriarecovery.com/blog/what-is-suboxone-how-does-it-work/

Any thoughts?

I saw another post on here where the solution was that a condition wasn’t closed. But, I do not see that as a problem here.

I tried setting the is_paged in this comments.php, but I couldn’t get anything to work.

I checked with ChatGPT code interpreter.

I took out the no follow code part.

When fixed, RankMath should automatically change the pagnated pages to noindex. I know this is something I can do editing the funtions.php file, but I’d like it to work properly instead.

PHP explode return different results [duplicate]

I have a string from front end application json. Need to call explode(‘ ‘, $string) on it and make some logic above the result. The string looks like “27 609,66 CZK”. But it seems like there are not spaces in the string and explode return whole string as is. I also tried to use non beaking space sign as separator. But no success. I made simple test on it which looks like:

$a = explode(" ", "27 609,66 CZK");  // This is the application string
$b = explode(" ", "27 609,66 CZK");  // This is written on keyboard

var_dump($a);
var_dump($b);

The result looks like

array (size=1)
  0 => string '27 609,66 CZK' (length=15)

array (size=3)
  0 => string '27' (length=2)
  1 => string '609,66' (length=6)
  2 => string 'CZK' (length=3)

Can somebody tell me plaese what could be the problem?