Merge branch ztflow-liugang-release/21.7.2#liugang of zentao/zentaopms (#9374)
This commit is contained in:
+30
-26
@@ -381,34 +381,38 @@ class ai extends control
|
||||
{
|
||||
if(empty($_FILES)) return $this->sendError(array('file' => sprintf($this->lang->error->notempty, $this->lang->ai->installPackage)));
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$errors = $this->ai->verifyRequiredFields(array('category' => $this->lang->ai->miniPrograms->category, 'published' => $this->lang->ai->toPublish));
|
||||
if($errors !== false) return $this->sendError($errors);
|
||||
$failResponse = array('result' => 'fail', 'message' => $this->lang->ai->saveFail, 'locate' => $this->createLink('ai', 'miniprograms'));
|
||||
if(empty($_POST)) return $this->send($failResponse);
|
||||
|
||||
$file = $_FILES['file'];
|
||||
$filePath = $file['tmp_name'];
|
||||
$result = $this->ai->extractZtAppZip($filePath);
|
||||
if(is_array($result))
|
||||
{
|
||||
$info = $result[0];
|
||||
$fileName = $info['filename'];
|
||||
include_once($fileName);
|
||||
if(isset($ztApp))
|
||||
{
|
||||
$ztApp = json_decode($ztApp);
|
||||
$ztApp->name = $this->ai->getUniqueAppName($ztApp->name);
|
||||
$ztApp->published = $_POST['published'];
|
||||
$ztApp->category = $_POST['category'];
|
||||
$this->ai->createMiniProgram($ztApp);
|
||||
unlink($fileName);
|
||||
return $this->sendSuccess(array('message' => $this->lang->saveSuccess, 'locate' => 'reload'));
|
||||
}
|
||||
unlink($fileName);
|
||||
}
|
||||
$errors = $this->ai->verifyRequiredFields(array('category' => $this->lang->ai->miniPrograms->category, 'published' => $this->lang->ai->toPublish));
|
||||
if($errors !== false) return $this->sendError($errors);
|
||||
|
||||
return $this->send(array('result' => 'fail', 'message' => $this->lang->ai->saveFail, 'locate' => $this->createLink('ai', 'miniprograms')));
|
||||
}
|
||||
$file = $_FILES['file'];
|
||||
$filePath = $file['tmp_name'];
|
||||
$result = $this->ai->extractZtAppZip($filePath);
|
||||
if(!is_array($result)) return $this->send($failResponse);
|
||||
|
||||
$info = $result[0];
|
||||
$fileName = $info['filename'];
|
||||
if(!is_file($fileName)) return $this->send($failResponse);
|
||||
|
||||
$content = file_get_contents($fileName);
|
||||
$content = str_replace(['<?php', "\r", "\n"], '', $content);
|
||||
unlink($fileName);
|
||||
if(empty($content)) return $this->send($failResponse);
|
||||
|
||||
$pos = strpos($content, "\$ztApp = '");
|
||||
if($pos != 0) return $this->send($failResponse);
|
||||
|
||||
$config = rtrim(substr($content, $pos + strlen("\$ztApp = '")), "';");
|
||||
$ztApp = json_decode($config);
|
||||
if(!is_object($ztApp)) return $this->send($failResponse);
|
||||
|
||||
$ztApp->name = $this->ai->getUniqueAppName($ztApp->name);
|
||||
$ztApp->published = $_POST['published'];
|
||||
$ztApp->category = $_POST['category'];
|
||||
$this->ai->createMiniProgram($ztApp);
|
||||
return $this->sendSuccess(array('message' => $this->lang->saveSuccess, 'locate' => 'reload'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user