Andriod Kotlin not opening all links in webview app

my android kotlin WebView app opened successfully and navigate well through the usual URL address like mywebsite.com/register, but was unable to navigate through other links which I have used to power most of my webpages within the website like mywebsite.com/register/?route=dashboard. or ../home/?route=history.
the website programming language in totality is php ajax jquery with css and html.

Below is my MainActivity.kt file

import android.annotation.SuppressLint
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebView
import androidx.annotation.RequiresApi
class MainActivity: AppCompatActivity() {
    private lateinit
    var webView: WebView
    @RequiresApi(Build.VERSION_CODES.O)
    @SuppressLint("MissingInflatedId", "SetJavaScriptEnabled")
    override fun onCreate(savedInstanceState: Bundle ? ) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        webView = findViewById(R.id.FirstApp)
        webView.settings.apply {
            javaScriptEnabled = true
            safeBrowsingEnabled = true
            domStorageEnabled = true
            databaseEnabled = true
            allowFileAccess = true
        }
        webView.apply {
            loadUrl("https://vtuconnects.com.ng/login")
        }
    }
    @Deprecated("Deprecated in Java")
    override fun onBackPressed() {
        if (webView.canGoBack()) webView.goBack()
        else super.onBackPressed()
    }
}

The website I wanted to use it for is vtuconects.com.ng/login. if the below demo credentials can bypass the login page to the dashboard, that means the help rendered here either by code modification or replication works fine.
username: DemoLogin
password: Demo12345

updating model in try/catch : model remembers faulty update values in the catch

i have a nested function calls to update some data in database , the column im going to update is unique in database and it may be updated with a duplicate value in that case i want to flag that model/row as duplicated

here is simplified version of my code without the nested function calls

public $defaultModel ;


function errorTest(){
    $this->defaultModel = $inprogress = Process::where('inprogress' , 1 )->first();
    try
    {
        $inprogress->update( [
            'deployment_id' => 666 ,
        ]);

    }
    catch (Exception $exception)
    {
        $this->defaultModel->update([
            'inprogress' => 0  ,
            'error'=>'duplicate'
        ]);
    }
}

when i try to update the model with a duplicate value i keep getting laravel error page

  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '666' for key 
  'process_deployment_id_unique'

at first i thought maybe my try/catch isnt working and i cant catch the error , but after playing around i found out the error is caused by catch section

        $this->defaultModel->update([
            'inprogress' => 0  ,
            'error'=>'duplicate'
        ]);

even though im not updating the unique column (deployment_id) in the catch , the model is still remembering the value given in the try body and trying to update deployment_id in the catch with the 666 value

crazy part is im not even using the same variable in the catch section ! it’s like they are referencing each other

the only way around it is to do something like

        $model = $this->defaultModel->fresh();
        $model->update([
            'inprogress' => 0  ,
            'error'=>'duplicate'
        ]);

any idea why is this happening ?

Create Cronjob for wordpress plugin

Good Day, I have created a plugin to import products to woocommerce, what I want to do now is create a cronjob for it. but all that I have tried does not work. This is the code I used.

function empty_product_table_function() {
$table_name='products';
$truncatetable=$wpdb->query($wpdb->prepare("TRUNCATE TABLE $table_name"));
wp_mail( '[email protected]', 'Shop Cron', 'The Cron started' );
}
if($truncatetable !== FALSE)
{
   echo("All rows have been deleted.");
}
else
{
   echo("No rows have been deleted.");
}

from there I created a cron in wp control but still noting i used this totorial to create it
Cloudways

can someone point me in the right direction

Issue with JWTGuard and Laravel Sanctum for Authentication on cPanel Deployment

I’m encountering a problem with my Laravel project related to authentication. Locally, I’ve implemented JWTGuard and i have tried Laravel Sanctum for user authentication, and it works perfectly. However, when I deploy the project to cPanel, the login process is successful, but I’m unable to use the generated token for other routes. I’m seeking help to understand and resolve this issue.

Here are the specifics of my setup and what I’ve tried so far:

Locally, I’ve successfully configured JWTGuard and Laravel Sanctum for authentication.

Upon deployment to cPanel, the login process works but the generated token doesn’t work for other routes. The exact reason for this is unclear to me.

I’ve addressed CORS (Cross-Origin Resource Sharing) locally, and it’s functioning correctly.

Here are the approaches I’ve tried to resolve the issue:

Adding headers in the beginning of the api.php file to handle CORS.

Implementing simple middleware to handle CORS.

I’m looking for suggestions, tips, or insights on what might be causing this problem specifically when deploying to cPanel. Any guidance on how to troubleshoot and resolve this issue would be greatly appreciated.

 <?php

namespace AppHttpMiddleware;

use Closure;
use IlluminateHttpRequest;

class Cors
{
   
    public function handle($request, Closure $next)
    {
        return $next($request)
            ->header('Access-Control-Allow-Origin', '*');

    }
}

at my api.php file

    header('Access-Control-Allow-Methods: "GET", "POST", "PATCH", "PUT", "DELETE", 
   "OPTIONS"');
   header('Access-Control-Allow-Headers: "Origin", "Content-Type", "X-Auth-Token", 
   "Authorization", "Accept", "charset", "boundary", "Content-Length"');
   header('Access-Control-Allow-Origin: "*"');

this is my .htaccess

<IfModule mod_rewrite.c>

<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ mydomain.net/$1 [R,L]

 </IfModule>

<FilesMatch .*.ph.*$>
  Order Allow,Deny
   Deny from all
</FilesMatch>


<FilesMatch "index.php$">
 Order Allow,Deny
  Allow from all
</FilesMatch>

Symfony : Warning:session_id(): Session id cannot be changed after headers have already been sent

I’m facing a weird issue with my PHP/Symfony application.
PHP version : 8.1.24
Symfony version : 6.3

I used the standard Symfony cli to generate the application.

When working on local env, no issue.

But when deployed on a remote server (nginx through Docker), after a while, EVERY POSTS start firing random “Warning:session_id(): Session id cannot be changed after headers have already been sent“. Usually resending the post is working, but sometimes not.
It happens with EVERY posts in app, whether it’s login, easy admin or custom forms.

If I reboot the server, the error disapear (and returns after few minutes)

I didn’t find any solution.
I searched for print or dump : I have not (and since it’s failing even for easy admin generated classes, I doubt it’s the solution). No blanks left before <PHP tag (and again, probably not the solution here).

Thanks for your help.

I checked for blank Space before <PHP and for print/dump fonction in the code.

Full stack trace :

Warning: session_id(): Session ID cannot be changed after headers have already been sent
ErrorException
Show exception properties
in vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php (line 84)
in vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php -> setId (line 191)
in vendor/symfony/http-foundation/Session/Session.php -> setId (line 185)
in vendor/symfony/http-kernel/EventListener/AbstractSessionListener.php -> setId (line 84)
in vendor/symfony/http-foundation/Request.php -> SymfonyComponentHttpKernelEventListener{closure} (line 723)
in vendor/symfony/http-foundation/Request.php -> getSession (line 740)
in vendor/symfony/security-http/Firewall/ContextListener.php -> hasPreviousSession (line 90)
in vendor/symfony/security-bundle/Debug/WrappedLazyListener.php -> authenticate (line 46)
in vendor/symfony/security-http/Firewall/AbstractListener.php -> authenticate (line 26)
in vendor/symfony/security-bundle/Security/LazyFirewallContext.php -> __invoke (line 60)
in vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php -> __invoke (line 73)
in vendor/symfony/security-http/Firewall.php -> callListeners (line 95)
in vendor/symfony/event-dispatcher/Debug/WrappedListener.php -> onKernelRequest (line 116)
in vendor/symfony/event-dispatcher/EventDispatcher.php -> __invoke (line 220)
in vendor/symfony/event-dispatcher/EventDispatcher.php -> callListeners (line 56)
in vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php -> dispatch (line 139)
in vendor/symfony/http-kernel/HttpKernel.php -> dispatch (line 158)
in vendor/symfony/http-kernel/HttpKernel.php -> handleRaw (line 76)
in vendor/symfony/http-kernel/Kernel.php -> handle (line 197)
in vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php -> handle (line 35)
in vendor/autoload_runtime.php -> run (line 29)
require_once(‘/var/www/caestats/vendor/autoload_runtime.php’)
in public/index.php (line 5)

is it possible to make inserts with an interval of every 10 minutes? [closed]

this is my program, I have tried but it inserts with duplicate data
please help me

$minute = date("i:s");
$datesql = date('Y-m-d H:i:s');
if($minute=="10:00"){
    $qrecord = mysqli_query($conn220,
        "INSERT INTO `history_rpm_mesin`(`id`, `nomesin`, `shift`, `nama_op`, `flv`, `rpm`, `std`, `time_stamp`, `dept`) 
        VALUES ('','$nomesin','$sh_op','$namaop','$flv','$value','$rpm_op','$datesql','BUMBU')");
}

Laravel Project: localhost connection refused error [closed]

I am currently working on a Laravel project and have encountered a perplexing issue when trying to run it on my local system. I’m receiving the error message, “This site can’t be reached,” with the additional note that “localhost refused to connect.” This issue is preventing me from accessing my Laravel project through my web browser.
I configured the .env file and database connection.
I tried maximum solution but can’t get the solution
My .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

Kindly help me out with this problem

How can I fix the undefined array errors on my wordpress website?

My wordpress site indicates an undefined array on line 1001 & 1004 of plugin.php:

**1001**  if ( is_object( $callback[0] ) ) {
        // Object class calling.
        return spl_object_hash( $callback[0] ) . $callback[1];
**1004**  } elseif ( is_string( $callback[0] ) ) {
        // Static calling.
        return $callback[0] . '::' . $callback[1];
    }

My wordpress child theme’s functions.php code is this:

<?php
add_action( `wp_enqueue_scripts`, `theme_enqueue_styles`); 
function theme_enqueue_styles() {
wp_enqueue_style( `parent-style`, get_template_directory_uri() . `/style.css`);
}

How can i modify it? The errors only appeared when I activated my child theme, so I figured that’s where the problem is. My child theme only has a css file and the functions.php…

I tried to deactivate all plugins since the error said it came from plugin.php at first, it didn’t work

I tried modifying the code of plugin.php to this

if (is_string($callback[0]) || is_object($callback[0])) {
// Static or object calling.
return $callback[0] . '::' . $callback[1];
} else {
// Object class calling.
return spl_object_hash($callback[0]) . $callback[1];
}

made everything worse

I don’t know much php so I would rather ask. Thank you for your help

How to place a table or image dynamically to pdf in PHP

I’ve a pdf file of a rule that need to pass a several approval. In the end of the file (content), I need to:

  1. Add a QR Code as an e-sign in the specific place, or
  2. Add a border-less table that include some text and a QR Code after the last content of the pdf. Which mean if the last content of pdf ends in the height(x) of 200, then the content should placed in (as an example) the height(x) of 210.

Example

Is that possible?

TCPDF writeHtml will place the generated html in the top of the page, while writeHTMLCell and MultiCell will need a specific x and y to be defined.

I’m also trying in MPDF, but it stuck like the TCPDF.

The code before writing the html looks like this,

$pageCount = PDF::setSourceFile($file);
$template = PDF::importPage($i);
$size = PDF::getTemplateSize($template);
PDF::AddPage($size['orientation'], array($size['width'], $size['height']));
PDF::useTemplate($template);

// After this, I need to call writeHtml, writeHTMLCell, or MultiCell, but none of those met what I need.
// Or placing an image with PDF::Image also need to define the x and y
...
// PDF::SetX()
// PDF::SetY()
// PDF::Image($qrPath, null, null, 12, 12, 'PNG');
// PDF::WriteHTML(view('document-requests.approver.stamp', ['qr' => $qrPath]), true, false, true, false, '');
PDF::Output($file, 'F');

Get WordPress Attachment PowerPoint URL in Post

I want to show the PPT file in this frame in WordPress post.

<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=<?php echo $attachment_url ?>" width="100%" height="500px" frameborder="0"></iframe>

I have placed this loop in post.php. But is not working.

<?php
$args = array(
    'post_type' => 'attachment', // Retrieve attachments
    'post_mime_type' => 'application/vnd.ms-powerpoint', // Filter by MIME type for PPT files
    'posts_per_page' => -1, // Retrieve all attachments
);

$attachments = new WP_Query($args);

if ($attachments->have_posts()) :
    while ($attachments->have_posts()) : $attachments->the_post();
        $attachment_id = get_the_ID();
        $attachment_title = get_the_title();
        $attachment_url = wp_get_attachment_url($attachment_id);


    endwhile;
endif;

wp_reset_postdata(); // Restore the original post data
?>`

Someone please help us in correcting this code.

I want when the user has submitted his shipping address then go for payment and after the payment is done the order info should be shown to the user

codeigniter3 as you can see in the below PHP code I’m using the Paytm payment gateway in my code for checkout process
But when I want to show the order info to the user, I get a ‘Transaction Failed’ message. Want to show order information to my user.

controller- Checkout.php

method-> process_order

        $cartItems = $this->cart->contents();
      if($this->cart->total_items() > 0){ foreach($cartItems as $item){ 
        header("Pragma: no-cache");
        header("Cache-Control: no-cache");
        header("Expires: 0");
        $checkSum = "";
        $paramList = array();

        $CHANNEL_ID = 'WEB';

       
        $paramList["MID"] = PAYTM_MERCHANT_MID;
        $paramList["ORDER_ID"] = 'ORDS' . rand(10000,99999999);
        $paramList["CUST_ID"] = '44667226220';
        $paramList["INDUSTRY_TYPE_ID"] = INDUSTRY_TYPE_ID;
        $paramList["CHANNEL_ID"] = $CHANNEL_ID;
        $paramList["TXN_AMOUNT"] = $item["subtotal"];
        $paramList["WEBSITE"] = PAYTM_MERCHANT_WEBSITE;

        $paramList["CALLBACK_URL"] = base_url('Checkout/payment_response');
        $paramList["MSISDN"] = 'xxxxxxxxxx'; //Mobile number of customer
        $paramList["EMAIL"] = 'xxxxxxxxxx'; //Email ID of customer
        $paramList["VERIFIED_BY"] = "MSISDN";
        $paramList["IS_USER_VERIFIED"] = "YES";

        $checkSum = $this->paytm->getChecksumFromArray($paramList,PAYTM_MERCHANT_KEY);
        $transaction_url = PAYTM_TXN_URL;
        $data = array('paramList' => $paramList,'transaction_url' => $transaction_url,'checkSum' => $checkSum);

        // ,'order_id' => $order_id
    $this->load->view('order_process',$data);
      }
    }
    }

method-> payment_response

      $paytmChecksum = "";
      $paramList = array(); 
     $isValidChecksum = FALSE;

       $paramList = $_POST;
  
       $paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; 


   $isValidChecksum = $this->paytm->verifychecksum_e($paramList, PAYTM_MERCHANT_KEY, $paytmChecksum); 
  
 
    if($isValidChecksum == "TRUE") {

  
    
        $orderId = $paramList['ORDERID'];
        $amount = $paramList['TXNAMOUNT']; 

      
        // Load the user's order based on the order ID
        $order = $this->Product->getOrderByOrderId($orderId);
        
        if ($order) {
            // Update the order status and generate a delivery ID
            $deliveryId = 'D' . uniqid(); // Example: D12345678
            
            // Update the order status and delivery ID in the database
            $this->Product->updateOrderStatus($orderId, 'Delivered');
            $this->Product->updateDeliveryId($orderId, $deliveryId);
            
            // Load a view to display the order status to the user
            $data['order_status'] = 'Delivered';
            $data['delivery_id'] = $deliveryId;
            $data['order_details'] = $order;
            
            $this->load->view('checkout_view', $data);
   }
   else{
echo 'Transaction Failed';
   }
   }else{
   echo 'Not Valid Check Sum';
   }

    }
    }

Product.php // model

  public function updateOrderStatus($orderId, $status) {
        // Replace this with your database update logic
        $this->db->where('order_id', $orderId);
        $this->db->update('orders', array('order_status' => $status));
    }

    public function updateDeliveryId($orderId, $deliveryId) {
        // Replace this with your database update logic
        $this->db->where('order_id', $orderId);
        $this->db->update('orders', array('delivery_id' => $deliveryId));
    }

WordPress paginate_links function give wrong url

i want to setup my pagination in wordpress. This is my function call. The problem is, the function returned the urls to this /taxonomy/term/paged/2. But i want it to /taxonomy/term/?page=2. What is wrong?

$pages = paginate_links( array_merge( [
            'base'         => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
            'format'       => '?page=%#%',
            'current'      => max( 1, get_query_var( 'paged' ) ),
            'total'        => $wp_query->max_num_pages,
            'type'         => 'array',
            'show_all'     => false,
            'end_size'     => 3,
            'mid_size'     => 1,
            'prev_next'    => true,
            'prev_text'    => __( '« Prev' ),
            'next_text'    => __( 'Next »' ),
            'add_args'     => $add_args,
            'add_fragment' => ''
        ], $params )

How can I fetch the content of an Elementor post and format it correctly?

I’m working on a website where the pages are built using Elementor (Free) on WordPress. The client has decided that one of the built pages should now be shown in a popup when a user clicks on a button on another page (also built using Elementor).

I’ve created the button, I’ve created the popup and I’m using Ajax to fetch the post_content field contents from a PHP plugin. The problem I’m having is that the post_content field doesn’t contain all of the wrapping elements that Elementor places around elements when the content is shown as a page, resulting in the same content not being styled correctly when shown in the popup. There’s a style sheet and then basic elements only. When the same content is viewed as a page, Elementor somehow builds other wrapping elements that make the styling work.

I know all the Elementor CSS and Javascript is enqueued and Elementor is initialised because the page that triggers the popup is built using Elementor.

I’ve tried using the elementor_template shortcode in the PHP hoping that will format the content correctly, but that’s just returning the shortcode text implying that the shortcode is not active (perhaps it’s Pro only).

is there a way in my PHP plugin that I can fetch the post content and use Ajax to send back to the page the content fully formatted so that the Elementor styling works?

PHP Query Parameter Not Passing to products.php from index.php” [closed]

I’m encountering an issue with passing query parameters from index.php to products.php in a simple PHP web application. Here’s the code I’m using:

index.php:

<ul class="dropdown-menu">
  <li><a class="dropdown-item" href="products.php?category=laptops">laptops</a></li>
  <li><a class="dropdown-item" href="products.php?category=phones">phones</a></li>
</ul>

products.php:

<?php

    if (isset($_GET['category'])) {
        $selectedCategory = $_GET['category'];
        echo "The category from the clicked link is: " . $selectedCategory;
    } else {
        echo "No category was passed.";
    }
?>

The expected behavior is that when I click on a link in index.php, it should take me to products.php with the selected category as a query parameter, and products.php should display "The category from the clicked link is: [selectedCategory]" if the category query parameter is set, or "No category was passed" if it’s not set. Currently it always shows "No category was passed"

PHP appears to work properly because index.php has the following code which works without problems:

<?php
    $servername = "localhost";
    $username = "root";
    $password = "Admin";
    $database = "testdata";
    $MK = "";
    
    $conn = new mysqli($servername, $username, $password, $database);
    if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);}
    $sql = "SELECT * FROM product WHERE category = 'laptops'";
    $result = $conn->query($sql);
    
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
        
            $MK = $MK . "
            <div class='col'>
                <div class='card h-100'>
                    <div class='card-header text-capitalize'>" . $row["category"] . "</div>
                    <img src='img/testimg.png' class='card-img-top mt-3' alt='...'>
                    
                    <div class='card-body'>
                        <h5 class='card-title mk-truncate-2'>" . $row["name"] . "</h5> 
                        <div class=''><p class='mk-truncate-2'>" . $row["description"] . "</p></div>               
                    </div>
                    
                    <div class='card-footer p-0'>
                        <div class='row'>
                            <div class='col-sm pt-3'>€ " . $row["price"] . "</div>
                            <div class='col-sm border-start p-2'>
                                <small class='text-muted'>
                                    <a href='#' class='btn btn-primary'>Buy</a>
                                </small>
                            </div>
                        </div>
                    </div>
                </div>  
            </div>";
        }
        
    } else {
        echo "No records found with category 'a'";
    }
    $conn->close();
?>   

• I work in Visual Studio Code
• Both index.php and products.php are in the same directory.

What could be causing this issue, and how can I troubleshoot it?