1
Я хочу ударить этого контроллер через хронКоманда для хрон ударить контроллер через CLI
<?php
set_time_limit(0);
include 'vendor/autoload.php';
include 'endroid/vendor/autoload.php';
include 'lib/FPDI_Protection.php';
use Endroid\QrCode\QrCode;
class pdf extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('product_model');
}
public function index() {
$hDB = new Mysqli('localhost', 'root', '', 'new');
$result = $hDB->query('SELECT * from requests order by requests.request_id asc limit 1');
while ($row = $result->fetch_assoc()) {
$pro_id = $row['id'];
$request_id = $row['request_id'];
$product = $row['product_id'];
$quantity = $row['batch_quantity'];
$new = $row['new'];
$batchpath = './output/' . $product . '/';
$batchpath1 = './output/' . $product . '/';
if ($new == 1) {
$rand = $quantity;
} else {
$rand = 0;
}
@mkdir($batchpath);
for ($i = 0; $i < $quantity; $i++) {
$qr_content = $product . '-' . $rand;
$qrCode = new QrCode();
$qrCode
->setText($qr_content)
->setSize(97)
->setPadding(5)
->setErrorCorrection('high')
->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))
->save($batchpath . '/' . $i . '.png');
$rand++;
}
for ($i = 0; $i < $quantity; $i++) {
$qr_content = $product . '-' . $rand;
$im = @imagecreate(300, 90)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, 50, 0, 10, 59, $text_color, './captcha_fonts/myfont.ttf', $qr_content);
imagejpeg($im, $batchpath1 . 'qr' . $i . '.png');
system('montage ' . $batchpath1 . 'qr' . $i . '.png ' . $batchpath1 . $i . '.png -tile 2x1 ' . $batchpath1 . 'final' . $i . '.png');
$rand++;
}
if ($new == 0) {
system('montage ' . $batchpath1 . 'final*.png -tile 4x4 ' . $batchpath1 . $product . '.png');
system('convert ' .$batchpath . $product . '*.png '.$batchpath . $product . '.pdf');
} else {
system('montage ' . $batchpath . 'final*.png -tile 4x4 ' . $batchpath1 . $product . '_new' . $quantity . '.png');
system('convert ' .$batchpath . $product . '_new*.png '.$batchpath . $product . '_new' . $quantity . '.pdf');
}
if ($new == 0) {
$arr['pdf'] = $product . '.pdf';
} else {
$arr['pdf'] = $product . '_new' . $quantity . '.pdf';
}
$arr['product_id'] = $product;
$arr['status'] = 1;
$this->product_model->insert_pdf($arr);
$this->product_model->request_status($pro_id);
$this->product_model->delete_request($request_id);
$pass = $this->product_model->pdf_password();
if ($new == 1) {
$origfile = $batchpath1. $product . '_new' . $quantity . '.pdf';
$destfile = $batchpath1 . $product . '_new' . $quantity . '_crypt.pdf';
} else {
$origfile = $batchpath1 . $product . '.pdf';
$destfile = $batchpath1 . $product . '_crypt.pdf';
}
$this->pdfEncrypt($origfile, $pass['pdf_password'], $destfile);
pdfEncrypt('./output/' . $product . '.pdf', 'slinfy007', './output/' . $product . '_crypt.pdf');
$rand++;
}
}
Это то, что я пишу в команде хрон
* * * * */USR/местные/бен/PHP [file_path] index.php кли/PDF
Я думаю дер некоторые проблемы в моей команде хрон, потому что, когда я непосредственно попал PHP index.php PDF кли это работает отлично
Благодаря его теперь работает отлично. –