CRON JOB USING CODEIGNITER AND Apache

i have a function that need run every day at 00:00 AM,
i do some research but not any result coming up with my cron job.

this is my function code :

public function aro()
 {
      $this->deposito_m->exec_aro();
      echo 'oke';
 }

my deposito_m is:

function exec_aro()
 {
      $tgl_now = date('Y-m-d');
      $data = $this->get_data_deposito_aro($tgl_now);
      if (!empty($data)) {
           foreach ($data as $x) {
                $transaksi = $x->tgl_transaksi;
                $tgl_awal = substr($transaksi, 0, 10);
                $jenis_ang = $x->jenis_ang;
                $tanggal_berakhir = date('Y-m-d', strtotime("+" . $jenis_ang . " months", strtotime($tgl_awal)));
                $anggota_id = $x->anggota_id;
                $akun = $x->akun;
                $dk = $x->DK;
                // $tanggal_berakhir = $x->tgl_berakhir;
                $kas_id = $x->kas_id;
                $user_name = $x->user_name;
                $nama_penyetor = $x->nama_penyetor;
                $no_identitas = $x->no_identitas;
                $alamat = $x->alamat;
                $jumlah_awal = $x->jumlah;
                $conf_bunga = $this->bunga_m->get_key_val();
                $bunga_deposit = $conf_bunga['suku_bunga_deposit'];
                $pajak = $conf_bunga['pajak_depo'];
                $bunga = $jumlah_awal * ($bunga_deposit / 100) * ($x->jenis_ang / 12);
                $total_bunga = $bunga -  ($bunga * ($pajak / 100));
                $jumlah = $jumlah_awal + $total_bunga;
                $create_arr = array(
                     'tgl_transaksi' => $tgl_now,
                     'anggota_id'    => $anggota_id,
                     'jenis_ang'     => $jenis_ang,
                     'jumlah'        => $jumlah,
                     'keterangan'    => 'new',
                     'akun'          => $akun,
                     'DK'            => $dk,
                     'kas_id'        => $kas_id,
                     'tgl_berakhir' => $tanggal_berakhir,
                     'update_data'   => $tgl_now,
                     'user_name'     => $user_name,
                     'no_identitas'  => $no_identitas,
                     'alamat'        => $alamat,
                     'nama_penyetor' => $nama_penyetor,
                     'status'        => 'on_progress',
                );
                $this->db->insert('tbl_trans_dep', $create_arr);
           }
      } else {
           return 'tidak ada data';
      }
 }

and my controller is :

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Deposito_status extends OperatorController
{
     public function __construct()
     {
          parent::__construct();
          $this->load->helper('fungsi');
          $this->load->model('deposito_m');
          $this->load->model('general_m');
     }

     public function index()
     {
          $this->data['judul_browser'] = 'Data Deposito';
          $this->data['judul_utama'] = 'Deposito';
          $this->data['judul_sub'] = 'Status Deposito';

          //table
          $this->data['css_files'][] = base_url() . 'assets/extra/bootstrap-table/bootstrap-table.min.css';
          $this->data['js_files2'][] = base_url() . 'assets/extra/bootstrap-table/bootstrap-table.min.js';
          $this->data['js_files2'][] = base_url() . 'assets/extra/bootstrap-table/extensions/filter-control/bootstrap-table-filter-control.min.js';
          $this->data['js_files2'][] = base_url() . 'assets/extra/bootstrap-table/bootstrap-table-id-ID.js';

          //modal
          $this->data['css_files'][] = base_url() . 'assets/extra/bootstrap-modal/css/bootstrap-modal-bs3patch.css';
          $this->data['css_files'][] = base_url() . 'assets/extra/bootstrap-modal/css/bootstrap-modal.css';
          $this->data['js_files'][] = base_url() . 'assets/extra/bootstrap-modal/js/bootstrap-modalmanager.js';
          $this->data['js_files'][] = base_url() . 'assets/extra/bootstrap-modal/js/bootstrap-modal.js';
          $this->data['js_files'][] = base_url() . 'assets/extra/bootstrap-modal/js/nsi_modal_default.js';

          // datepicker
          $this->data['css_files'][] = base_url() . 'assets/theme_admin/css/datepicker/datepicker3.css';
          $this->data['js_files'][] = base_url() . 'assets/theme_admin/js/plugins/datepicker/bootstrap-datepicker.js';
          $this->data['js_files'][] = base_url() . 'assets/theme_admin/js/plugins/datepicker/locales/bootstrap-datepicker.id.js';
          //$this->data['barang_id'] = $this->pinjaman_m->get_id_barang();

          //daterange
          $this->data['css_files'][] = base_url() . 'assets/theme_admin/css/daterangepicker/daterangepicker-bs3.css';
          $this->data['js_files'][] = base_url() . 'assets/theme_admin/js/plugins/daterangepicker/daterangepicker.js';

          //select2
          $this->data['css_files'][] = base_url() . 'assets/extra/select2/select2.css';
          $this->data['js_files'][] = base_url() . 'assets/extra/select2/select2.min.js';

          //editable
          $this->data['css_files'][] = base_url() . 'assets/extra/bootstrap3-editable/css/bootstrap-editable.css';
          $this->data['js_files'][] = base_url() . 'assets/extra/bootstrap3-editable/js/bootstrap-editable.min.js';

          $this->data['jenis_ags'] = $this->deposito_m->get_data_angsuran();

          $this->data['isi'] = $this->load->view('deposito_status_v', $this->data, TRUE);
          $this->load->view('themes/layout_utama_v', $this->data);
     }
     public function ajax_deposito()
     {
          // $this->load->model('deposito_m');
          $out = $this->deposito_m->get_deposito();
          header('Content-Type: application/json');
          echo json_encode($out);
          exit();
     }
     function aksi()
     {
          $this->load->model('deposito_m');
          if ($this->deposito_m->deposito_aksi()) {
               echo 'OK';
          } else {
               echo 'Gagal';
          }
     }
     // function get_jenis_simpanan()
     // {
     //      $id = $this->input->post('jenis_id');
     //      $jenis_simpanan = $this->general_m->get_id_simpanan();
     //      foreach ($jenis_simpanan as $row) {
     //           if ($row->id == $id) {
     //                echo number_format($row->jumlah);
     //           }
     //      }
     //      exit();
     // }

     function get_jenis_angsuran()
     {
          $id = $this->input->post('jenis_ang_grid');
          $jenis_angsuran = $this->general_m->get_jns_angsuran();
          foreach ($jenis_angsuran as $row) {
               if ($row->ket == $id) {
                    echo number_format($row->jumlah);
               }
          }
          exit();
     }

     public function aro()
     {
          $this->deposito_m->exec_aro();
          echo 'oke';
     }
}

my crontab -l in server is :

0 0 * * * /usr/bin/php /home/admin/web/kspspmi.dieselone.co.id/public_html/index.php deposito_status/aro

i try with * * * * * to know my cron is running or not, in log there is some CMD running but nothing happens with my data in database.

Can someone help me what is wrong or how to do cron job in server,
Thank you.

Laravel Twilio Store User Reply Input to Database in Response to Send SMS Order ID

I need help in Twilio getting reply responses and storing them in the database in response to sending SMS after user input in response to the message. I am sending an SMS to the user about his/her order schedule and asking him/her to confirm delivery by inputting Ok and when he/she confirm, I am getting his response successfully.

The question or the issue I am facing is that I want to know that when he/she confirm the delivery, I want to update the database record in response to the delivery SMS we sent to him/her earlier. My issue will be resolved if I am able to get order_id from the first message and send it in replytoSMS function.

My Code to send SMS and webhook (replytoSMS) are given below.

<?php

 public function initiateSMS(Request $request) {
  try {
  foreach ( $request->get('items') as $item ) {
    $order_id = $item['order_id'];
    $phone    = $item['phone_number'];
    $order     = Orders::where('id', $order_id)->first();

    $phone_number = $this->client->lookups->v1->phoneNumbers($phone)->fetch();

  if($phone_number) {
   
      $template_value = $order->message; 

      $sms = $this->client->messages->create($phone, [
        'from' => $this->from, 
        'body' => $template_value,
        "method" => 'POST',
        "statusCallbackMethod" => 'POST',
        "statusCallback" => 'https://example.com/simply/public/api/notification/statusMessageBack?order_id='.$order_id.'',
        ]);

       // print($sms->sid);
  }
} // foreach loop end
  if($sms){
    return Response::json(['success' => 'sms initiated successfully!']);
  }
} catch (Exception $e) {
  return Response::json(['Error' => $e->getMessage()]);
} catch (RestException $rest) {
  return Response::json(['Error' => $rest->getMessage()]);
}
}

function statusMessageBack(){
 header('Content-type: text/xml');
 header('Cache-Control: no-cache');
 $response = new MessagingResponse();
 $order_id = $_REQUEST['order_id'];
 $user_phone = $_REQUEST['To'];
 $MessageSid = (!empty($_REQUEST['MessageSid'])) ? $_REQUEST['MessageSid'] : '';
 $MessageStatus = (!empty($_REQUEST['MessageStatus'])) ? $_REQUEST['MessageStatus'] :              '';
  if($MessageStatus && $MessageStatus == "delivered"){

  $notification = Notification::create([                            
  "response_code" => $MessageSid,
  "type" => $category,
  "table_ref"  => "orders",
  "table_ref_pk"  => $order_id, 
  "response_status" => "",
  "medium" => $user_phone,
  "status" => $MessageStatus,
  "sender_id" => $sender_id
 ]);
  
}
 print $response; exit;
}

 public function replyToSMS(){
 header('Content-type: text/xml');
 header('Cache-Control: no-cache');
 $response = new MessagingResponse();
 $MessageSid = (!empty($_REQUEST['MessageSid'])) ? $_REQUEST['MessageSid'] : '';
 $MessageStatus = (!empty($_REQUEST['MessageStatus'])) ? $_REQUEST['MessageStatus'] : '';

$body = $_REQUEST['Body'];
$order_id = $_REQUEST['order_id'];
$from_phone = $_REQUEST['From'];

if (strtolower($body) == 'ok' || strtolower($body) == 'yes' || strtolower($body) == 'confirm') {
  $response->message('Your delivery has been confirmed. Thank you', [
    'callbackUrl' => "https://example.com/api/notification/reply_status?order_id='.$order_id.'",
    'callbackMethod' => "POST"
    ]);
    $notification = Notification::where('order_id', $order_id)->update(array("response_status" => "confirmed"));
 } else {
   $response->message('Sorry');
   $notification = Notification::where('order_id', $order_id)->update(array("response_status" => "call store"));
 }
  print $response;

 }

function reply_status(){
header('Content-type: text/xml');
header('Cache-Control: no-cache');
$response = new MessagingResponse();
echo $order_id = $_REQUEST['order_id'];
$user_phone = $_REQUEST['To'];
$MessageSid = (!empty($_REQUEST['MessageSid'])) ? $_REQUEST['MessageSid'] : '';
$MessageStatus = (!empty($_REQUEST['MessageStatus'])) ? $_REQUEST['MessageStatus'] : '';
if($MessageStatus && $MessageStatus == "delivered"){

}
  print $response; exit;
}

Automatically Input Date Every Week

I have a chart using Chart JS and The Labels is Monday, Tuesday, Wednesday, Thursday, Friday

and then this is my code

    <?php foreach($connect->query(
    "SELECT Process_Date, 
    COUNT(*) 
    FROM tb_main 
    WHERE DATE(Process_Date) = '2022-03-28 00:00:00' 
    GROUP BY Process_Date 
    LIMIT 1") as $row) {
    echo $row['COUNT(*)'];}?>,

this code is repeated 5 times (to fill data every day).

I want to change that (‘2022-03-28 00:00:00’) Automatically every week. Example :
This week Monday until Friday is 2022-03-28 – 2022-04-01. and then the next week is automatically change to 2022-04-04 – 2022-04-08.
is it Possible?

iTunes API URL redirects to Music app instead of getting data on iOS

I have made a script to get AlbumArt form the iTunes API, and this is working great on every device, except for iOS Safari.
When the device connects to the (example) URL https://itunes.apple.com/search?term=Taylor+Swift&media=music&entity=song&attribute=artistTerm&limit=100&callback=jQuery360009460325774006106_1648473977767&_=1648473977777

The request will be automatically converted by Apple to musics//, in other words it’s trying to open the app instead of getting the data.

Is there a way to prevent this by adding a parameter on the URL or add something on javascript code?

how to add react js script to my html code?

i have code like this

import React, { Component } from 'react'
import { Button, Container, Modal, Overlay } from 'react-bootstrap'
import TextareaAutosize from 'react-textarea-autosize'
import request from '../helpers/request'
import Pusher from 'pusher-js'
import { URL_API, PUSHER_KEY, PUSHER_CLUSTER, CHANNEL_DEFAULT } from '../configs/keys'
import { getID, setID } from '../helpers/cookies'

const customModal = {
  width: '40%'
}

// class App extends Component {
export default class FloatButton extends Component {
  targetRef = React.createRef()
  messagesEndRef = React.createRef()

  constructor() {

i have try use this code

<body>
    <div id="container"></div>
    <script src="https://*/react-15.0.0.js"></script>
    <script src="https://*/react-dom-15.0.0.js"></script>
<script src="https://js.pusher.com/7.0/pusher.min.js"></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<script type="text/babel" src="FloatButton.js"></script>
    
</html>
  </body>

my question is how to add my java script to my existing html ? because when i run my html i got problem.. can someone help me for fix my issue ?

PHP error – The first argument to copy() function cannot be a directory in

I’m trying to move all images files from folder into another folder but i’m having this warning and i can’t go further, did some search here but not getting the desired solution

having those errors

Warning: copy(): The first argument to copy() function cannot be a directory in /home/XXX/public_html/miga/db/teste.php on line 16

Warning: copy(): The first argument to copy() function cannot be a directory in /home/XXX/public_html/miga/db/teste.php on line 16

Warning: copy(): The first argument to copy() function cannot be a directory in /home/XXX/public_html/miga/db/teste.php on line 16

error_reporting(E_ALL);
ini_set('display_errors', 1);
$files = scandir("../uploads");
$source = $_SERVER['DOCUMENT_ROOT'] . '/miga/uploads/';
$haveImages = glob($source."*.{jpg,jpeg,png,gif}", GLOB_BRACE);
$keepFiles = array('miga.png');
$destination = $_SERVER['DOCUMENT_ROOT'] . '/miga/media/';
if(!empty($haveImages)){
    echo $source;
    foreach ($files as $file) {
        if (in_array($file, array(".",".."))
        ) continue;
        // If we copied this successfully, mark it for deletion
        if (copy($source.$file, $destination.$file)) {
            $delete[] = $source.$file;
            $gravacao[] = $source.$destination;
        }
    }
}
else{
    echo  "here 0";
}

Woocommerce API retrives an incomplete list of products

I am trying to automate the process of shop prices update by using python scripts
The total product count in the shop is 6939. When I use a built-in WooCommerce option to export to csv, I also got the right product count 6939, but when I get all products via API request I get 6923 in total, here is the python code I use:

from woocommerce import API
from openpyxl import *
import time


start_time = time.time()


wcapi = API(
    url="*******",
    consumer_key="ck_*******",
    consumer_secret="cs_*******",
    version="wc/v3"
)

products_sorted = {}
page = 1

while True:
    products = wcapi.get('products', params={'per_page': 100, 'page': page}).json()

    for i in range(0, len(products)):
        products_sorted[products[i]['id']] = {
            'sku': products[i]['sku'],
            'regular_price': products[i]['regular_price'],
            'stock_status': products[i]['stock_status'],
            'catalog_visibility': products[i]['catalog_visibility'],
        }

    print(page)
    page += 1

    if len(products) == 0:  # no more products
        break

print(len(products_sorted))

Any ideas?

Run custom PHP function in WordPress once a day

I am writing a custom php code that get some data via API request in WordPress and attach the function to function.php. The problem is the function run whenever I reload the webpage. I want it to run only once in 24 hrs i.e I want it to make api request once a day. How can I do that. Can someone please give me some idea.

Eloquent Get Collection if it has at least one relation

I have a scenario where I have a model A that has 3 relations B, C, and D.
I’m trying to get collections in A where it has at least one relation
so I don’t want {id:1,B:[],C;[],D:[]} But I would accept {id:2,B:[{id:6}],C;[],D:[]}
I tried getting them by 3 has but that only gets it if it has all 3.
I also tried getting all then checking by if but I want a faster way.

Paypal. button in bootstrap 5 accordion

I have an accordion with some items. Now I want to show a paypal pay button in each accordion item. I am using the paypal JS SDK. So for it is working just for the first open accordion item. There the paypal button is shown, I can click on it and paypal modal is opening to login and pay.

I have created a file where I have added the “paypal-button-container” and included a PHP file with the paypal JS script:

<?php                                            
include_once ('method/paypal_accordion.php');
?>
<div id="paypal-button-container"></div>
                                        

In the included file ‘method/paypal_accordion.php’ I have the paypal script with the variables for the payment:

<script>
    // Loop over each funding source/payment method
    var FUNDING_SOURCES = [
        paypal.FUNDING.PAYPAL
    ];

    FUNDING_SOURCES.forEach(function(fundingSource) {
        // Initialize the buttons
        var button = paypal.Buttons({
            fundingSource: fundingSource,
            createOrder: function (data, actions) {
                return actions.order.create({
                    application_context: {
                        brand_name: 'my-page.com',
                        locale: 'en_gb',
                        shipping_preference: 'SET_PROVIDED_ADDRESS',
                    },
                    intent: 'CAPTURE',
                    payer: {
                        email_address: '<?php echo $email; ?>',
                    ...
                     onApprove: function (data, actions) {
                     return actions.order.capture().then(function (orderData) {
                     ...
                      });
            },

How can the paypal button be shown on every opened accordion item?
Currently I just see the paypal div there, but no button:

<div id="paypal-button-container"></div>

Should I reload the DOM or is there an event in the accordion to do that?
Or should I use a button with a form or some AJAX?

Symfony/PHP: ldap_explode_dn function problem

I use the ldap_explode_dn Function for encoding my ldap string.

$ldapDnParts = ldap_explode_dn($groupMembership, 1);

But I get the Undefined-Function-Error:

Attempted to call function "ldap_explode_dn" from namespace "AppFactory".

The class where I call teh function is under AppFactory. I do not understand why it takes this namespace when searching the native function.
Can anyone help me with this?
I use PHP8 and Symfony 5.4.

How to find out that a div is not fitted on page for printing

I want to print some shop factors, so within foreach loop, I tried echoing each factor like this:

enter image description here

But let’s say that the 2nd factor which is div2 in this case, has many more items, so if you try to print that, it will collapse the page and goes to the next page for printing!

So I need to determine that if a custom div is going out of the entire page, do not show it at the current and show it at next page instead.

So how to do this?

how to use php preg_match_all() with overlap matches [duplicate]

I am trying (with no success) to get all possible matches with preg_match_all().

Any help would be greatly apreciated. Thank you in advance.
No related questions and answers clearly give a way to do that.

Here is a typical example :

the code is :

$str = "manger des pâtes à la carbonara dans un restaurant de pâtes";
$pattern = "/(.*) (son |sa |ses |un |une |des |du |le |les |la)(.*) dans (son |sa |ses |un |une |de la |des |du |la |le |les |l')(.*)/";
if(preg_match_all($pattern, $str, $matches, PREG_SET_ORDER)) {
  print_r($matches);
}

the result (correct but incomplete for what I want) is :

  • Array ( [0] => Array ( [0] => manger des pâtes à la carbonara dans un restaurant de pâtes [1] => manger des pâtes à [2] => la [3] => carbonara [4] => un [5] => restaurant de pâtes ) )

what is missing is the following match :

  • Array ( [0] => Array ( [0] => manger des pâtes à la carbonara dans un restaurant de pâtes [1] => manger [2] => des [3] => pâtes à la carbonara [4] => un [5] => restaurant de pâtes ) )

overall I would like to get :

  • Array ( [0] => Array ( [0] => manger des pâtes à la carbonara dans un restaurant de pâtes [1] => manger des pâtes à [2] => la [3] => carbonara [4] => un [5] => restaurant de pâtes )
    [1] => Array ( [0] => manger des pâtes à la carbonara dans un restaurant de pâtes [1] => manger [2] => des [3] => pâtes à la carbonara [4] => un [5] => restaurant de pâtes )
    )