Пример #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     //post 传入 xml 模板文件
     $data = ["status" => "", "experimentId" => "", "link" => ""];
     $validatorRules = array('id' => 'required|integer|exists:reports,id', 'xml' => 'required');
     $validatorAttributes = array('id' => '生成报告ID', 'xml' => '模板xml文件');
     postCheck($validatorRules, Config::get('phylab.validatorMessage'), $validatorAttributes);
     //ToDo
     $xmlLink = getRandName() . ".xml";
     try {
         Storage::put("xml_tmp/" . $xmlLink, Request::get('xml'));
     } catch (Exception $e) {
         throw new FileIOException();
     }
     $tmpName = getRandName();
     $report = Report::find(Request::get('id'));
     $scriptLink = $report->script_link;
     $experimentId = $report->experiment_id;
     $system = exec(Config::get('phylab.scriptPath') . "create.sh " . Config::get('phylab.tmpReportPath') . " " . Config::get('phylab.scriptPath') . $scriptLink . " " . Config::get('phylab.tmpXmlPath') . $xmlLink . " " . Config::get('phylab.tmpReportPath') . $tmpName . ".tex", $output, $reval);
     #echo Config::get('phylab.scriptPath')."create.sh ".Config::get('phylab.tmpReportPath')." ".Config::get('phylab.scriptPath').$scriptLink." ".Config::get('phylab.tmpXmlPath').$xmlLink." ".Config::get('phylab.tmpReportPath').$tmpName.".tex";
     #echo $out;
     #echo $system."\n";
     #echo $reval."\n";
     #echo var_dump($output);
     if ($reval == 0) {
         #echo $system.'\n';
         #echo "python ".storage_path()."/app/script/".$scriptLink." ".storage_path()."/app/xml_tmp/".$xmlLink." ".public_path()."/pdf_tmp/".$tmpName.".tex";
         $system = json_decode($system);
         if ($system->status == SUCCESS_MESSAGE) {
             $data["status"] = SUCCESS_MESSAGE;
             $data["link"] = $tmpName . ".pdf";
             $data["experimentId"] = $experimentId;
         } else {
             $data["status"] = FAIL_MESSAGE;
         }
     } else {
         $data["status"] = FAIL_MESSAGE;
     }
     return response()->json($data);
 }
Пример #2
0
 /**
  * set user's avatar
  *
  * @return \Illuminate\Http\Response
  */
 public function setAvatar()
 {
     $data = ["status" => "", "avatarPath" => ""];
     if (Request::hasFile('avatar')) {
         $avatar = Request::file('avatar');
         if (preg_match(Config::get('phylab.allowedFileFormat'), $avatar->getClientOriginalExtension()) && $avatar->getSize() < Config::get('phylab.maxUploadSize')) {
             $fname = getRandName() . '.' . $avatar->getClientOriginalExtension();
             $avatar->move(Config::get('phylab.avatarPath'), $fname);
             $auth = Auth::user();
             try {
                 if ($auth->avatar_path != Config::get('phylab.defaultAvatarPath')) {
                     Storage::disk('local_public')->delete('avatar/' . $auth->avatar_path);
                 }
             } catch (Exception $e) {
                 throw new FileIOException();
             }
             try {
                 $auth->avatar_path = $fname;
                 $auth->save();
                 $data["status"] = SUCCESS_MESSAGE;
                 $data["avatarPath"] = $fname;
             } catch (Exception $e) {
                 throw new DatabaseOperatorException();
             }
         } else {
             throw new InvalidFileFormatException();
         }
     } else {
         throw new InvalidRequestInputException("上传参数不正确");
     }
     return response()->json($data);
 }
Пример #3
0
require_once '../include/conmysql.php';
require_once '../include/public_function.php';
require_once 'function/czj_public_function.php';
$public_function = new public_function();
$blog_userid = $_SESSION['UID'];
if ($_SESSION['UID'] == null || $_SESSION['UID'] == 0) {
    echo "<script>location.href='../admin.php'</script>";
}
if (str_replace(" ", "", $_GET['url']) == "") {
    $url = "yh_gl_xm_info";
} else {
    $url = str_replace(" ", "", $_GET['url']);
}
//项目编号
$xm_num = date("YmdHis", time()) . getRandName(2);
//项目类型
$xm_fl = str_replace(" ", "", $_POST['xm_fl']);
//项目类别
$xm_lb = str_replace(" ", "", $_POST['xm_lb']);
//项目规模
$xm_gm = str_replace(" ", "", $_POST['xm_gm']);
//项目名称
$xm_mc0 = str_replace(" ", "", $_POST['xm_mc']);
if ($xm_mc0 == "" || $xm_mc0 == null) {
    $xm_mc = "";
} else {
    $xm_mc = $xm_mc0;
}
//子项目名称
$z_xm_mc0 = str_replace(" ", "", $_POST['z_xm_mc']);