2017-07-14 4 views
0

私は直接管理者でcronjobsを作成しました。それが実行されていれば、curl = >>> mysqlの値を変更するかどうかチェックします。しかし、それは動作していません。私を助けてください @@。それはいくつかのプロセスのために認証を必要とする原因Cronjobs on Direct Adminが動作しません

<?php 

class ControllerVemaybayCronJobapp 
    { 



      function index(){ 
      $connect = $this->connect(); 
      $query_routes_1 = $connect->query("SELECT * FROM **** where status = '0' GROUP BY routes "); 
      for ($result = array(); 
      $row = $query_routes_1->fetch_assoc(); 
      $result[array_shift($row)] = $row); 

      foreach ($result as $i => $aaa){ 
       $routes = $aaa['routes']; 
       $detail_routes_2 = $connect->query("SELECT * FROM **** where routes = '" . $routes . "' AND status = '0' "); 
       for ($result2 = array(); 
       $row2 = $detail_routes_2 ->fetch_assoc(); 
       $result2[array_shift($row2)] = $row2); 

       foreach ($result2 as $t => $value1) { 

        $ngay = $value1['ngay']; 
        $thang = $value1['thang']; 
        $nam = $value1['nam']; 
        $min = $value1['minPrice']; 
        $max = $value1['maxPrice']; 
        $providers = $value1['providers']; 
        $startdate = $nam.$thang.'01'; 
        $enddate = $nam.$thang.'31'; 

        $bien = $this->getlist_ticketsofdate($routes,$startdate,$enddate); 
        foreach ($bien as $k => $value) { 
         $moi2 = array(); 
         $moi = $value['c']; 
         $moi2 = $value['f']; 
         if($value['_id']['dim'] == $ngay){ 
          if($min <= $value['c'] && $value['c'] <= $max && strpos($providers, $value['p']) !== false){ 
           $connect->query("UPDATE **** SET status='1' where customer_id = '" . $value1['customer_id'] . "' "); 
           break; 
          }else{ 
           foreach ($moi2 as $key => $value2) { 
            if($min <= $value2['cp'] && $value2['cp'] <= $max && strpos($providers, $value2['p']) !== false){ 
             $connect->query("UPDATE **** SET status='1' where customer_id = '" . $value1['customer_id'] . "' ") ; 
             break; 
            } 
           } 
          } 
         } 
        } 
       } 
      } 
     } 


     function connect(){ 
      $servername = "****"; 
      $username = "****"; 
      $password = "****"; 
      $databasename = "****"; 
      $conn = new mysqli($servername, $username, $password,$databasename); 
      if ($conn->connect_error) { 
       die("Connection failed: " . $conn->connect_error); 
      } 
      return $conn; 
     } 



     function getlist_ticketsofdate($diadiem,$startDate,$endDate){ 


      $url = '****'; 

      $providers = array(); 
      $providers[0] = '****'; 
      $providers[1] = '****'; 
      $providers[2] = '****'; 

      $routes = array(); 
      $routes[0] = $diadiem; 

      $headers = array(); 
      $headers[] = 'Content-Type: application/json'; 
      $headers[] = 'Connection:keep-alive'; 

      $param = array(
       'startDate' => $startDate, 
       'endDate' => $endDate, 
       'minPrice' => '0', 
       'maxPrice' => '700000', 
       'providers' => $providers, 
       'routes' => $routes, 
       'type' => 'date', 
      ); 

      $data_string = json_encode($param); 

      $ch = curl_init(); 
      curl_setopt($ch, CURLOPT_URL, $url);                 
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);  
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

      $response = curl_exec($ch); 
      $result_tickets = json_decode($response,true); 
      return $result_tickets; 
     } 
} 
?> 

This is my cronjobs

+1

は、CronJobapp.phpファイルのコードを提供します。 Classファイルは決して直接実行されなかったからです。 –

+0

どうすればいいのですか? –

+0

あなたはもっと具体的に話すことができますか?ありがとう –

答えて

0

cronジョブは、直接管理上で動作しない可能性があります。おかげ これは私のコードです。

サンプルのphpファイル名mail.php

<?php 
// the message 
$msg = "First line of text\nSecond line of text"; 

// use wordwrap() if lines are longer than 70 characters 
$msg = wordwrap($msg,70); 

// send email 
mail("[email protected]","My subject",$msg); 
?> 

cronコマンド:パスについては

urlに

* * * * * wget http://example.com/mail.php &> /dev/null 

* * * * * <BASE DIR>/mail.php 

このcronジョブは、メールに分ごとに送信します。

関連する問題