Unable to load file inside folders in Codeigniter

I am working with Codeigniter,I want to load file inside folders but unable to get html/design in webpage,In other words,my following code is working (“header.php” exist inside “common” folder)

<?php
    $this->load->view('common/header');
?>

But following code is not working (move “header.php” inside “backend” folder,Where i am wrong ?

<?php
    $this->load->view('common/backend/header');
?>

post method working but put and patch not working in laravel swagger api

when i use put/patch in mediatype=”application/json” it works finely but i need to upload file too. how can i fix this ?

/**
     * create testimonial 
     * @OAput(
     *     path="/api/testimonial/store",
     *     tags={"testimonial"},
     * security={{"apiAuth":{}}},
     *     @OARequestBody(
     *         required=true,
     *         @OAMediaType(
     *             mediaType="multipart/form-data",
     *             @OASchema(
     *                 @OAProperty(property="name",type="string"),
     *                 @OAProperty(property="description",type="string"),
     *                 @OAProperty(property="designation",type="string"),
     *                 @OAProperty(property="company",type="string"),
     *                 @OAProperty(property="image",type="file",format="string"),
     *             )
     *         )
     *     ),
     *     @OAResponse(
     *         response="200",
     *         description="successful operation",
     *     ),
     *  @OAResponse(
     *          response=400,
     *          description="invalid",
     *          @OAJsonContent(
     *              @OAProperty(property="msg", type="string", example="fail"),
     *          )
     *      )

     * )
     * */
    public function store(Request $request)
    {
        try {
            $testimonial = new Testimonial;
            $testimonial->name = $request->name;
            $testimonial->description = $request->description;
            $testimonial->designation = $request->designation;
            $testimonial->company = $request->company;
            if ($request->hasfile('image')) {
                $file = $request->file('image');
                $extenstion = $file->getClientOriginalExtension();
                $filename = time() . '.' . $extenstion;
                $file->move('uploads/testimonial/', $filename);
                $testimonial->image = $filename;
            }
            $testimonial->save();
            return $this->returnJson($testimonial, 'Testimonials successfully created!', 200, ['total' => $testimonial->count()]);
        } catch (Exception $e) {
            return $this->returnJson(false, $e->getMessage(), $e->getCode());
        }
    }

How to split AJAX response into two divs

How I could get AJAX response splitted in two separate divs?

Situation: I have custom post type (case-studies) filter by custom taxonomy(case study category). On page load I query by exact category. But when I filter it by category I want to get AJAX response divided into two parts. First one even posts appears in filtered-post-top div and odd posts appears in filtered-post-bottom div.

Here is what I have achieved so far.

functionts.php file:

function filter_ajax() {


  $category = $_POST['category'];
  $args = array(
    'post_type' => 'case-studies',
    'posts_per_page' => 4,
    'tax_query' => array(
      array(
          'taxonomy' => 'case_study_categories',
          'terms' => $category
      )
    )
  );
  
  $query = new WP_Query($args);

  if($query->have_posts()) :
      while($query->have_posts()) : $query->the_post();
        get_template_part( 'partials/case-studies-archive-post' );
      endwhile;
  endif;

    wp_reset_postdata(); 
      die();
  }

ajaxRequest.js

$(document).ready(function () {
    $('.filter-item > span').on('click', function(e) {
        e.preventDefault();
        var category = $(this).data('category');
        console.log(category);
        data = {
            'action': 'filter',
            'category': category
        };

        $.ajax({
            url : wp_ajax.ajax_url,
            data : data,
            type : 'post',
            success: function(result) {
                $('.filtered-posts').html(result);
                console.log(result);
            },
            error: function(result) {
                console.warn(result);
            }
        });
    })

});

Archive-case-studies.php

<section>
        <div class="filtered-posts-top">
            <?php 
                $args = array(
                    'post_type' => 'case-studies',
                    'posts_per_page' => 4,
                    'tax_query' => array(
                        array(
                            'taxonomy' => 'case_study_categories',
                            'terms' => 14
                        )
                      )
                );
                $counter = 0;
                $query = new WP_Query($args);
                
                if ($query->have_posts()) :
                    while ( $query->have_posts()) : $query->the_post();
                    $counter++;
                            if( $counter % 2 == 0 ) : 
                                get_template_part( 'partials/case-studies-archive-post' );
                            endif;
                    endwhile;
                endif;
                wp_reset_postdata(); ?>
        </div>
        <div class="case-studies-categories">
            <?php
            $args = array(
                'taxonomy'  => 'case_study_categories'
            );
            $categories = get_terms( $args );
            ?>
                <?php foreach ( $categories as $cat ) :?>
                    <div class="filter-item">
                        <span  data-category="<?php echo $cat->term_id;?>"><?php echo $cat->name; ?></span>
                    </div>
                <?php endforeach; ?>
        </div>
        <div class="filtered-posts-bottom">
            <?php 
                $args = array(
                    'post_type' => 'case-studies',
                    'posts_per_page' => 4,
                    'tax_query' => array(
                        array(
                            'taxonomy' => 'case_study_categories',
                            'terms' => 14
                        )
                      )
                );
                $counter = 0;
                $query = new WP_Query($args);
                
                if ($query->have_posts()) :
                    while ( $query->have_posts()) : $query->the_post();
                    $counter++;
                        if( $counter % 2 == 1 ) : 
                                get_template_part( 'partials/case-studies-archive-post' );
                        endif;
                    endwhile;
                endif;
                wp_reset_postdata(); ?>
        </div>
      
    </section>

Maybe someone will have idea how to solve the issue.

issue with checkbox when unchecked it

I have an issue with checkbox when unchecked it. it keeps the same value which is checked. the checked box works ok however i want also the unchecked box to works also.

users/”>

name=”permissions[lr_vech_group]” class=”custom-control-input” id=”lr_vech_group”>
All List

Get full current URL in pre_handle_404 filter or wp action

I am trying take an action based on a specific word present in the URL. For that I am looking at 2 options, 1 via pre_handle_404 filter and other via wp action.

The problem I am facing is that $wp->request is returning just the home page url and not the full URL so my if condition is never satisfied. The code that I have tried for the both is:

pre_handle_404

add_filter( 'pre_handle_404', 'my_filter_pre_handle_404', 1, 2 );
function my_filter_pre_handle_404( $preempt, $wp_query ) {
    global $wp;
    if (str_contains($wp->request, '/page/')) {
        global $wp_query;
        $wp_query->set_404();
        status_header( 404 );
    }

    return $preempt;
}

wp action

add_action( 'wp', 'my_action_wp', 1 );
function my_action_wp( $wp ) {
    global $wp_query;
    if (str_contains($wp->request, '/page/')) {
        global $wp_query;
        $wp_query->set_404();
        status_header( 404 );
    }
}

I tried to replace $wp->request based if condition with the following but still didn’t help:

$current_url = home_url(add_query_arg(array(), $wp->request));
if (str_contains($current_url, '/page/')) { 

Please help to get the current full url of he page in either of the above (pre_handle_404 filter or wp action)

Getting 500 error while running cURL Request with POST Data Using HTTP Controller.php

This is my FlightController.php file
public function data(){

    // URL
    $apiURL = 'http://stageapi.ksofttechnology.com/API/FLIGHT/';

    // POST Data
    $postInput = [
        "TYPE"=> "AIR",
            "NAME"=> "GET_FLIGHT",
            "STR"=> [
            "AUTH_TOKEN"=> "***********************",
            "SESSION_ID"=> "",
            "TRIP"=> "1",
            "SECTOR"=> "D",
            "SRC"=> "DEL",
            "DES"=> "BOM",
            "DEP_DATE"=> "2022-12-10",
            "RET_DATE"=> "",
            "ADT"=> "1",
            "CHD"=> "0",
            "INF"=> "0",
            "PC"=> "",
            "PF"=> "",
            "HS"=> "D",
            ],
    ];

    // Headers
    $headers = [
      
    ];

    $response = Http::withHeaders($headers)->post($apiURL, $postInput);

    $statusCode = $response->status();
    $responseBody = json_decode($response->getBody(), true);

    dd($responseBody); // body response
 
}

Route File:
Route::post(‘/flightdata’, [FlightController::class,’data’]);

Error: 500 Internal Server Error

Woocommerce Stripe gateway payment method custom style

I try to customize the style for the stripe gateway payment method (credit card), I used this guideline https://woocommerce.com/document/stripe-styling-fields/
but still have some issues, with my code:
CSS

.woocommerce form .form-row input.input-text {   
  padding: 17px 0 16px 24px; 
}

PHP

add_filter("wc_stripe_elements_styling", "snippetpress_style_stripe_1");
function snippetpress_style_stripe_1($styles)
{
  $styles = array(
    "base" => array(
      "fontFamily" => "galanogrotesque,sans-serif",
      "::placeholder" => array(
          "color" => "#979AA3",
          "fontSize" => "18px",
          "fontStyle" => "normal",
          "fontWeight" => "400",
          "lineHeight" => "normal",
          "letterSpacing" => "-0.2px",
          "textDecoration"  => "none",
          "fontVariant" => "normal",
      ),
    ),
  );
  return $styles;
}

I still need some changes:

  • make CVV and Exp date in full width (now is displayed like 2 columns)
  • the placeholder text is a few pixels higher

Any ideas?
enter image description here

MySQL update multiple rows at once using parameter binding

I passing an array of ID’s to a php file that are IDs that should be updated.
So far, checking SO I see that to update multiple values the following query must be used:

UPDATE employees SET gender = 'Male' WHERE id IN (1,2,3)

However, I think to avoid sql injections, I’m trying to code it as follows:

 $arr = [1,2,4];
 $stmt = $conn->prepare("UPDATE employees SET gender = 'Male' WHERE id IN (?)")
 $stmt->bindValue(1,  $arr);

Query executes apparently with no errors, but rows are not updating.

Laravel create a route method GET with param in url

I created a route & contronller:

Route::group(['prefix' => 'test'], function () {
        Route::get('product/{id}', ['uses' => 'ProductController@getProduct']);
});

ProductController:

class ProductController extends MyController {

public $_params = null;
public function __construct(Request $request) {
    $this->request = $request;
    $this->_params = $request->all();
    $options = array();
    parent::__construct($options);
}

public function getProduct() {
    dd($this->_params);
}
}

I requested: http://localhost/test/product/123

But the id = 123 not exist in $this->_params

PHP with SOAP, server to get xml from request

I’am new hand about soap
I’ve a client.php code witch send a xml to server.php.
How to read xml to array in my server.php?
I always get the value without the key

Do I using wsdl to parse xml?
But I’m not good at wsdl…
Can someone help me? Thx a lot.

client.php

<?php
  $data = '<?xml version = "1.0" encoding = "UTF-8"?>
  <inputMessage>
<ns0:BankCollStatusAdviseRq xmlns:ns0 = "http://ns.tcb.com.tw/XSD/TCB/BC/Message/BankCollStatusAdviseRq/01">
    <ns0:SeqNo>00000000</ns0:SeqNo>
    <ns0:TxnCode>ARROWAPAN095912  </ns0:TxnCode>
    <ns0:CollInfo>
        <ns0:CollId>006</ns0:CollId>
        <ns0:CurAmt>
            <ns0:Amt>1000</ns0:Amt>
        </ns0:CurAmt>
    </ns0:CollInfo>
    <ns0:SettlementInfo>
        <ns0:SettlementId>0063201924</ns0:SettlementId>
    </ns0:SettlementInfo>
</ns0:BankCollStatusAdviseRq>
<headers>
    <Header.PartyInfo>
        <ns0:PartyInfo xmlns:ns0 = "http://www.tibco.com/namespaces/bc/2002/04/partyinfo.xsd">
            <from>
                <name>BANK006</name>
            </from>
            <operationID>BankColl/1.0/BankCollStatusAdvise</operationID>
        </ns0:PartyInfo>
    </Header.PartyInfo>
</headers>
<ns0:_configData xmlns:ns0 = "http://tibco.com/namespaces/tnt/plugins/soap">
    <endpointURL>https://dev.admin.roombook.com.tw/automsgclient_tc.php?wsdl</endpointURL>
    <soapAction>/BankColl</soapAction>
</ns0:_configData>
</inputMessage>';
$url = "http://localhost:8080/test/soap/demo2/server.php";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
   "Content-Type: application/soap+xml",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
?>

server.php

<?php
if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){
    header($_SERVER["SERVER_PROTOCOL"]." 405 Method Not Allowed", true, 405);
    exit;
}
$postData = trim(file_get_contents('php://input'));
echo "<pre>";print_r($postData);echo "</pre>";
libxml_use_internal_errors(true);
$xml = simplexml_load_string($postData);
if($xml === false) {
    header($_SERVER["SERVER_PROTOCOL"]." 400 Bad Request", true, 400);
    foreach(libxml_get_errors() as $xmlError) {
        echo $xmlError->message . "n";
    }
    exit;
}
?>

Insert PHP form data to google sheets

We have one requirement similar to google forms, which will send the data to google Sheets.

Using PHP we built a web app(which acts like a google form that collects data from users eg Name, Email, etc) that will send output data(submits Multiple output responses in a single submit click ie array of responses, eg. output.1:- Name: john, Email: [email protected], etc and output.2:- Name: sam, Email: [email protected], etc ) to the database, now the task is, we need to send the same data to google sheets using google sheets script URL instead of the database.

This is the code that we used to insert the web app’s array of output data into the database

<?php 

insert.php

$connect = new PDO("mysql:host= localhost;dbname= ","user name","password");

$query = "
INSERT INTO expense 
(first_name, last_name, Category) 
VALUES (:first_name, :last_name, :Category)
";

for($count = 0; $count<count($_POST['hidden_first_name']); $count++)
{
    $data = array(
        ':first_name'   =>  $_POST['hidden_first_name'][$count],
        ':last_name'    =>  $_POST['hidden_last_name'][$count],
        ':Category' =>  $_POST['hidden_Category'][$count]
    );
    $statement = $connect->prepare($query);
    $statement->execute($data);
}

?>

So, we need the same kind of code which has to have the ability to send the obtained multiple output data ie array of responses (eg. output.1 : Name: john, Email: [email protected], etc and output.2: Name: sam, Email: [email protected], etc from single submit click) from the web app to google sheet.

Why CockroachDB may close connection during data raed?

I have Cockroachdb on local servers and a PHP code to read data from it using PDO. When I run the script I get the error:

PDOException: Caught PDOException (500): SQLSTATE[HY000]: General error: 7 server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

Any thoughts why this happens?

Unable to render a Livewire Full-Page Component in my developped package Laravel

I developped a package, and when it comes to render normal views, it works just fine, but now that I want to render Full Page Livewire components, I get a “view not found message” any idea why ?

For example for a show-tickets view:

web.php:

Route::get('tickets/list', ShowTickets::class);

ServiceProvider:

public function boot()
    {
        $this->loadMigrationsFrom(__DIR__ . "/database/migrations");
        $this->loadRoutesFrom(__DIR__ . "/routes/web.php");
        $this->loadViewsFrom(__DIR__ .'/resources/views', "Tickets");

        Livewire::component('show-tickets', ShowTickets::class);
    }

ShowTickets.php :

<?php

namespace UHGroupTicketsAppLivewire;

use LivewireComponent;
use UHGroupTicketsAppModelsTicket;

class ShowTickets extends Component
{

    public function mount()
    {
        $this->ticket = Ticket::where("archived_at", !null);
    }

    public function render()
    {
        $tickets = Ticket::all();

        return view('Tickets::livewire.show-tickets', compact('tickets'));
    }
}

and I’m getting the following error :

View [livewire.show-tickets] not found.

Although I do have a show-tickets.blade.php file in a livewire folder in my views folder….

undefined index shows in my debuging mode [duplicate]

PHP Notice: Undefined index: in /home/lankade792/public_html/wp-content/themes/adifier/functions.php on line 675

$list = array();
$loaded_fonts = array();
foreach( $load_fonts as $key => $data ){
    if( !empty( $data['font'] ) && !isset( $loaded_fonts[$data['font']] ) ){
        $loaded_fonts[$data['font']] = $data['weight'];
    }
    else{
        $loaded_fonts[$data['font']] .= ','.$data['weight'];
    }
}

PHP Notice: Undefined index: Rs in /home/lankade792/public_html/wp-content/plugins/adifier-system/functions.php on line 657

array(
            'font'     => adifier_get_option( 'text_font' ),
            'weight'   => adifier_get_option( 'text_font_weight' ).',600,700',
        ),
        array(
            'font'     => adifier_get_option( 'title_font' ),
            'weight'   => adifier_get_option( 'title_font_weight' ).',400,500',
        ),