-
Notifications
You must be signed in to change notification settings - Fork 2
/
qqq8.php
52 lines (46 loc) · 1.55 KB
/
qqq8.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
ini_set("max_execution_time",10000);
$set_charset = 'export LANG=ko_KR.UTF-8;';
set_time_limit(10000);
$name=$_GET['name'];
$start_time=$_GET['begin'];
$end_time=$_GET['end'];
$cmd=$set_charset.'/usr/bin/python3 /media/ubuntu/Newdisk/xyo/admin/aacc_80/wwwroot/zhengqiya.py '.$name.' '.$start_time.' '.$end_time.' 2> error.txt';
$l = exec($cmd,$res,$ret);
DEFINE ('DB_USER','root');
DEFINE ('DB_PASSWORD','caucse1234');
DEFINE ('DB_HOST','localhost');
DEFINE ('DB_NAME','virus');
$dbc=@mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME) OR die('Could not to connect to Mysql:'.mysqli_connect_error());
header("content-type:text/json;charset=utf-8");
$db_selected=@mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME) OR die('Could not to connect to Mysql:'.mysqli_connect_error());
if (!$db_selected)
{
die ("Can\'t use " );
}
//执行MySQL查询-设置UTF8格式
// mysqli_query("SET NAMES utf8");
// mysqli_query()
$sql = "SELECT DATE_FORMAT(weather.date,'%Y-%m-%d') time FROM test,weather where test.KID=weather.KID and weather.date >='$start_time' AND weather.date < '$end_time' group by time";
$result = mysqli_query($dbc,$sql);
//定义变量json存储值
$data="";
$array= array();
$array=$res;
$time=array();
class emp{
public $time;
public $value;
}
$array1= array();
while ($row = mysqli_fetch_row($result))
{
array_push($time,$row);
//数组赋值
}
for ($i=0;$i<count($time);$i++){
$array1[] = [$time[$i][0],floatval($array[$i])];
}
$data = json_encode($array1);
echo $data;
?>