Problem with the basel url in php directory

I have a problem

i have a index.php in that index
i link a

includes/meta.php

file. in that file i have style .css files and jquery .js files.

i have also

index.php

and a about/index.php

when i link the css from the include/meta.php to index.php the link works,

    <link href="vendor/css/style-front.css" type="text/css" rel="stylesheet" />

but does not work in this about/index.php directory

Why?

Someone here for a solution to fix this ?


i have tried this 


<link href="http://localhost:8888/vendor/css/style-front.css" type="text/css" rel="stylesheet" />

this works with the localhost:8888


but how fix this with like 



  <?php 
    print "<link href='{$base_url}vendor/css/style-front.css'/>";?>


Anyone here ? 

Laravel Dusk says Class ‘TestsBrowserComponents…’ could not be found

After I installed laravel-dusk following the official Laravel documentation and run this command:

php artisan make:component CardComponentTest

Then try to run immediately:

php artisan dusk tests/Browser/Components/CardComponentTest.php

I get this error:

Class 'TestsBrowserComponentsCardComponentTest' could not be found in '/var/www/html/tests/Browser/Components/CardComponentTest.php'.

I tested file and path are correct:

ls -l /var/www/html/tests/Browser/Components/CardComponentTest.php

And it says:

-rw-r--r-- 1 djw djw 6917 Dec  3 11:25 /var/www/html/tests/Browser/Components/CardComponentTest.php

So it is exists and readable.

I checked the namespace in the file:

<?php

namespace TestsBrowserComponents;

It also looks good.

I checked the composer.json and in this I have this section:

    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },

So the file exists, the namespace is good and the namespace is picked up in the composer.json.

I tried to run composer dump-autoload too. All good.

Any ide what’s wrong whit this?

Disable proceed to checkout button unless shipping method is chosen

I’ve removed the default shipping method using

add_filter( 'woocommerce_shipping_chosen_method', '__return_false', 99);

I am trying to ‘disable’ the “proceed to checkout” button on the cart/basket page so that the customer is forced to select their required shipping method.

I tried to use the following snippet that I found on google;

add_action( 'woocommerce_proceed_to_checkout', 'modify_checkout_button_no_shipping', 1 );
function modify_checkout_button_no_shipping() {
    $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
    // removes empty values from the array
    $chosen_shipping_methods = array_filter( $chosen_shipping_methods );
    if ( empty( $chosen_shipping_methods ) ) {
        remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
        echo '<a href="" class="checkout-button button alt disabled wc-forward">' . __("You must choose a shipping method", "woocommerce") . '</a>';
    }
}

This works fine but what if I only want it to apply to zone 1 and 2 without it affecting other zones.

How do I alter the if statement to only apply the remove action to specifically zone 1 and 2 or in the reverse, how not to apply it to zones 3 and 4.

Thanks in advance for any help.

how to remove a fee line from a woocommerce order using REST API?

I need to remove a fee line from an order using the woocommerce REST API. I tried passing the fee_lines as an empty array, or with the name and total of the fee line set to null or zero and none of it worked. I am using the V3 Woocommerce API. Thanks

I tried to delete the fee line by:

  • removing it from the fee_lines array
  • passing the whole fee_lines array as an empty array
  • sending the id of the fee line on (no name or total)
  • setting the fee line’s name and total as null or zero

How do I add schema markup to a loop statement without duplicating in wordpress?

I have create custom type post (FAQ) function and display function vh_display_post_faqs( $post_id = 0 ) and its working correctly. I have also added schema markup inside while statement. But I am getting this error that there is Duplicate field “FAQPage” when I test via https://search.google.com/test/rich-results. Am I looping wrongly?

Error of Duplicate field “FAQPage” Image

function vh_display_post_faqs( $post_id = 0 ) {
    // Return if post id is empty.
    if ( empty( $post_id ) ) {
        return;
    }

    // Get the categories' ids using the passed post id.
    $categories_ids = wp_get_post_terms( $post_id, 'category', array( 'fields' => 'ids' ) );

    // Validate for empty ids or wp errors.
    if ( empty( $categories_ids ) || is_wp_error( $categories_ids ) ) {
        return;
    }

    // Prepare query args, using tax query.
    $query_args = array(
        'post_type'      => 'faq',
        'posts_per_page' => 2,
        'tax_query'      => array( // phpcs:ignore WordPress.DB.SlowDBQuery
            'taxonomy' => 'category',
            'field'    => 'term_id',
            'terms'    => $categories_ids,
        ),
    );

    // Run query and fetch faq posts.
    $faqs = new WP_Query( $query_args );
    
    // Check if we have posts from the query.
    if ( $faqs->have_posts() ) :

        // Loop through the query posts.
        while ( $faqs->have_posts() ) :
            $faqs->the_post();
            $striped = the_content();
            $strip = str_replace(['"',"'"], "", $striped);

            // Print the content.
            ?>
            <div class="faq-post">
                <h2 class="faq-title"><?php the_title(); ?></h2>

                <div class="faq-content"><?php the_content(); ?>
            </div>
            <script type="application/ld+json">
            {
              "@context": "https://schema.org",
              "@type": "FAQPage",
              "mainEntity": [{
                "@type": "Question",
                "name": "<?php the_title(); ?>",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "<?php str_replace("n","",the_content()); ?>"
                }
              }]
            }
            </script>
            <?php

        endwhile;

        // Reset the post data.
        wp_reset_postdata();

    endif;
}

How to format JSON via PHP

I have a PHP that writes JSON Code to a JSON file, looks like this:

`

if ($_GET["aktion"] == "erstellen") {
  $date = new DateTime('now', new DateTimeZone('Europe/Berlin'));

  $text_in = $_POST["inhalt"];
  $text_in = htmlentities($text_in);
  $text_in = str_replace("n", "<br>", $text_in);

  $newTicket = [
    'ticket_art' => $_POST["art"],
    'von_name' => $_POST["name"],
    'ticket_titel' => $_POST["titel"],
    'ticket' => $text_in,
    'datum' => date("d.m.Y"),
    'uhrzeit' => $date->format('H:i:s'),
    'status' => "Ausstehend",
    'zustand' => "open"
  ];

  array_push($items, $newTicket);
  file_put_contents('DB/open/tickets.json', json_encode($items, JSON_PRETTY_PRINT));

  echo "<meta http-equiv="refresh" content="0;URL=?aktion=0&iid=">";
}

// Löschen von Ticket
if ($_GET["aktion"] == 11) {

  $iindex = $_GET['iid'];
  $index = count($items) - 1 - $iindex;

  unset($items[$index]);
  file_put_contents('DB/open/tickets.json', json_encode($items, JSON_PRETTY_PRINT));  

  echo "<meta http-equiv="refresh" content="0;URL=?aktion=0&iid=">";
}

if ($aktion == 12) {
  $id_index = count($items) - 1 - $_GET["iid"];

  foreach ($items as $index => $row) {
    if ($index == $id_index) {
      $xxa = $row['ticket_art'];
      $xxb = $row['von_name'];
      $xxc = $row['ticket_titel'];
      $xxd = $row['ticket'];
      $xxe = $row['datum'];
      $xxf = $row['uhrzeit'];
      $xxg = $row['status'];
      $xxh = $row['zustand'];
    }
  }

  $repTicket = [
    'ticket_art' => $xxa,
    'von_name' => $xxb,
    'ticket_titel' => $xxc,
    'ticket' => $xxd,
    'datum' => $xxe,
    'uhrzeit' => $xxf,
    'status' => $xxg,
    'zustand' => "wait"
  ];

  $items[$id_index] = $repTicket;
  file_put_contents('DB/open/tickets.json', json_encode($items, JSON_PRETTY_PRINT));

  $handler = fopen('DB/abzihen.txt', 'a+');
  fwrite($handler, ".n");
  fclose($handler);

  echo "<meta http-equiv="refresh" content="0;URL=?aktion=0&iid=">";
}

`

Okay and if I push a SEND Button, the JSON File looks normal like:

[ { "someting": "something", "something": "something" } ]

And if I push a delete Button, my Json looks like this:

{ "0": { "something": "something", "something": "something" } }

So here is my question: How do I get the JSON into the old format back, where it is a Array?
Is there any PHP method to format it back or something like that?

Thank you!

I would be verry Happy if you can help me please

Raw SQL Query working fine in MySQL Workbench, but causing SQLSTATE[22007] when executed through Laravel

I’m trying to execute a RAW query (using DB::select(DB::raw(..))) in Laravel, but it returns
SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect time value.
FYI, columns are TIMESTAMP data type in MySQL db.
That same query, executed in MySQL Workbench works fine.

I’m assuming some default settings for Laravel-MySQL communication could be to blame, but I may be wrong.

Thanks in advance!

Tried Google-ing the issue, couldn’t find much on the matter, except to change the config/database.php >> mysql >> strict mode to False, since default is True.
I wouldn’t want to change config files unless absolutely necessary.
Which brings me to, what exactly does the MySQL Strict Mode refer to?

How to run multiple charts in chartjs

I am creating a bar graph with a dropdown menu at the top and how can i do it, In my localhost the code works but when uploaded online only the gender chart is working how can i fix this.You’r help is much appreciated

It works in the localhost but not when i uploaded it in a server only the gender chart is working and the others are not .

 <?php
            //gender graph 
                if(@$_GET['q']==10) {

                    include_once 'dbConnection.php';
                    $query = $con->query("
                    SELECT gender, COUNT(*) as total
                    FROM rank
                    GROUP BY gender;
                    ");

                foreach($query as $data)
                {
                    $gender[] = $data['gender'];
                    $total[] = $data['total'];
                }
                echo '<div style="width: 900px; margin: auto; padding-top: 100px; text-align: center;">';
                echo '
                <select onchange="location = this.value;">
                <option value="superadmin.php?q=10">Gender</option>
                <option value="superadmin.php?q=11">Age</option>
                <option value="superadmin.php?q=12">Strand</option>
               </select>

               <canvas id="myChart"></canvas>
               </div>';
            }
            ?>
            <script>
                // === include 'setup' then 'config' above ===
                const labels = <?php echo json_encode($gender) ?>;
                const data = {
                    labels: labels,
                    datasets: [{
                    label: 'Gender',
                    data: <?php echo json_encode($total) ?>,
                    backgroundColor: [
                        'rgba(255, 99, 132, 0.5)',
                        'rgba(255, 159, 64, 0.5)',
                        'rgba(255, 205, 86, 0.5)',
                        'rgba(75, 192, 192, 0.5)',
                        'rgba(54, 162, 235, 0.5)',
                        'rgba(153, 102, 255, 0.5)',
                        'rgba(201, 203, 207, 0.5)'
                    ],
                    borderColor: [
                        'rgb(255, 99, 132)',
                        'rgb(255, 159, 64)',
                        'rgb(255, 205, 86)',
                        'rgb(75, 192, 192)',
                        'rgb(54, 162, 235)',
                        'rgb(153, 102, 255)',
                        'rgb(201, 203, 207)'
                    ],
                    borderWidth: 2
                    }]
                };

                const config = {
                    type: 'bar',
                    data: data,
                    options: {
                    scales: {
                        y: {
                        beginAtZero: true
                        }
                    }
                    },
                };

                var myChart = new Chart(
                    document.getElementById('myChart'),
                    config
                );
                </script>


            <?php
            //age graph
                if(@$_GET['q']==11) {

                    include_once 'dbConnection.php';
                    $query = $con->query("
                    SELECT age, COUNT(*) as total
                    FROM rank
                    GROUP BY age;
                    ");

                foreach($query as $data)
                {
                    $age[] = $data['age'];
                    $total[] = $data['total'];
                }
                echo '<div style="width: 900px; margin: auto; padding-top: 100px; text-align: center;">';

                echo '
                <select onchange="location = this.value;">
                <option value="superadmin.php?q=11">Age</option>
                <option value="superadmin.php?q=10">Gender</option>
                <option value="superadmin.php?q=12">Strand</option>
               </select>

               <canvas id="myChart2"></canvas>
               </div>';
            }
            ?>
            <script>
                // === include 'setup' then 'config' above ===
                const labels = <?php echo json_encode($age) ?>;
                const data = {
                    labels: labels,
                    datasets: [{
                    label: 'Age',
                    data: <?php echo json_encode($total) ?>,
                    backgroundColor: [
                        'rgba(255, 99, 132, 0.5)',
                        'rgba(255, 159, 64, 0.5)',
                        'rgba(255, 205, 86, 0.5)',
                        'rgba(75, 192, 192, 0.5)',
                        'rgba(54, 162, 235, 0.5)',
                        'rgba(153, 102, 255, 0.5)',
                        'rgba(201, 203, 207, 0.5)'
                    ],
                    borderColor: [
                        'rgb(255, 99, 132)',
                        'rgb(255, 159, 64)',
                        'rgb(255, 205, 86)',
                        'rgb(75, 192, 192)',
                        'rgb(54, 162, 235)',
                        'rgb(153, 102, 255)',
                        'rgb(201, 203, 207)'
                    ],
                    borderWidth: 2
                    }]
                };

                const config = {
                    type: 'bar',
                    data: data,
                    options: {
                    scales: {
                        y: {
                        beginAtZero: true
                        }
                    }
                    },
                };

                var myChart = new Chart(
                    document.getElementById('myChart2'),
                    
                );
                </script>

Setting up cronjob in cpanel using codeigniter php not working

i have a page in my website where i have a script in my view page mysite.com/feepayment/homecontroller/mystatus, whenever we visit the link, the script runs, now i want to add it to cronjob in cpanel, the cronjob in cpanel was showing an example like this:
PHP command examples:
General example:
/usr/local/bin/php /home/mnyfxhioxjmc/public_html/path/to/cron/script

so i set the time setting to twice in 1 hour and in command box i gave:
/usr/local/bin/php /home/mnyfxhioxjmc/public_html/feepayment/application/views/mystatus.php

but this doesnt seem to work, its giving me error in my mail like below:

Could not open input file: /home/mnyfxhioxjmc/public_html/feepayment/application/views/mystatus.php

can anyone please tel me whats wrong in here, thanks in advance

How to preview / show document before downloadingin symfony

I come to you, for an question about preview/show document action on php / symfony

I have my ressource for project management, user can upload / delete / download ressource with panel, but i want to put a system to show/preview document when user click on ‘eye icon’, for moment i use modal and on modal i have iframe of google to display my pdf

<iframe src="http://docs.google.com/gview?url=http://www.yoursite.com/xyz.doc&amp;embedded=true"></iframe>

But i think is not the best method.

I search on Packagist an package to display preview of pdf but nothing is optimize

PS: My user can upload png or jpg

Thx for your help

Excuse for my bad english

Remove last suffiv by reg in php

I have random strings in the form of K1/ABC/J/123456/2020/O, A4/ABCD/J1/2123456/2022/Ok etc. They are always 5x “/”.
I need a redex function to suppress the last suffix (so everything after /d{4}/).

On the example of the above examples, as a result of the function I should get: K1/ABC/J/123456/2020 and A4/ABCD/J1/2123456/2022.
All characters can be different, the number of “/” is constant.

Could I ask for help?
I beginner, please help me 🙂

$number = getActionNumber($data); // in this place i have: K1/ABC/J/123456/2020/O, A4/ABCD/J1/2123456/2022/Ok etc

$myNewNumberWithoutSuffix = ..... // here i need K1/ABC/J/123456/2020 and A4/ABCD/J1/2123456/2022

Add Tester to play Track with Php

Trying to add programatically tester email’s to google play track for intern Test.
How can i do that with Php?
I tried to post new tester unsuccessfully

<?php 
        $headers = array();
        $body    = array(  
                    'grant_type'    => 'authorization_code',
                    'code'          => $code."#",
                    'client_id'     => $client_id,
                    'client_secret' => $client_secret,
                    'redirect_uri'  => "https://website.com/callback",
        );

        $response = UnirestRequest::post("https://accounts.google.com/o/oauth2/token", $headers, $body);

        var_dump($response->body);

?>