示例#1
0
function addCity()
{
    $arr = $_POST;
    $city_get = getTemp($arr['city']);
    $city_info['city'] = $arr['city'];
    $city_info['pinyin'] = $city_get['pinyin'];
    $city_info['pubDate'] = $city_get['date'];
    $city_info['longitude'] = $city_get['longitude'];
    $city_info['latitude'] = $city_get['latitude'];
    $city_info['altitude'] = $city_get['altitude'];
    $city_info['pId'] = $arr['pId'];
    $city_info['totalCap'] = 0;
    $cName = $city_info['city'];
    $pinyin = $city_info['pinyin'];
    $str = "<?php" . "\r\n" . "require_once '../lib/mysql.func.php';\r\n" . "require_once '../lib/temp.func.php';\r\n" . "\r\n" . "mysql_connect(\"localhost:/tmp/mysql.sock\",\"root\",\"\");\r\n" . "mysql_set_charset(\"utf8\");\r\n" . "mysql_select_db(\"biogas\");\r\n" . "\r\n" . "\$res = getItem('" . $cName . "');\r\n" . "\$res_insert = array();\r\n" . "\$res_insert['date'] = \$res['date'];\r\n" . "\$res_insert['l_tmp'] = \$res['l_tmp'];\r\n" . "\$res_insert['h_tmp'] = \$res['h_tmp'];\r\n" . "insert(\$res['pinyin'].\"_tmp\", \$res_insert);";
    $filename = '../tmp_update/' . $pinyin . '_update.php';
    if (insert("biogas_city", $city_info)) {
        createTable($city_info['pinyin']);
        //(1) 创建城市温度表
        file_put_contents($filename, $str);
        //(2) 创建温度更新脚本
        chmod($filename, 0777);
        $mes = "添加成功!<br/><a href='addCity.php'>继续添加!</a>|<a href='listCity.php'>查看列表!</a>";
    } else {
        $mes = "添加失败!<br/><a href='addCity.php'>重新添加!</a>|<a href='listCity.php'>查看列表!</a>";
    }
    return $mes;
}
示例#2
0
function getNotification($msg, $type = '')
{
    $msg = explode('|', $msg);
    if ($msg[1] && $msg[0]) {
        $r = str_replace('{msg}', $msg[1], getTemp($msg[0]));
        if ($type == '2') {
            return $r;
        } else {
            $_SESSION[$msg[0]] = $r;
            $_SESSION['typ'] = $msg[0];
        }
    }
}
?>
</span></h4></div>
			<div class="col-xs-0 col-sm-6 col-md-8"></div>
		</div>
		<div class="row">
			<div class="col-xs-6 col-sm-3 col-md-2"><h4>Next Change:</h4></div>
			<div class="col-xs-6 col-sm-3 col-md-2"><h4><span class="label label-primary col-xs-12 col-md-12"><?php 
echo getNextChange();
?>
</span></div>
			<div class="col-xs-0 col-sm-6 col-md-8"></div>
		</div>
		<div class="row">
			<div class="col-xs-6 col-sm-3 col-md-2"><h4>Ext Temp:</h4></div>
			<div class="col-xs-6 col-sm-3 col-md-2"><h4><span class="label label-primary col-xs-12 col-md-12"><?php 
echo getTemp();
?>
&deg;C</span></h4></div>
			<div class="col-xs-0 col-sm-6 col-md-8"></div>
		</div>

		<div class="row">
			<div class="col-xs-12"><br/></div>
		</div>

		<div class="row">
			<div class="col-xs-12 col-sm-6 col-md-4">
				<form action="boost.php">
				<?php 
$tempCold = getTempCold();
if (isBoostActive()) {
        $boostExit = "expired";
        unlink("schedule/boost");
        $heatingBoost = false;
    }
} else {
    $heatingBoost = false;
}
// Timer
$now = date("N") - 1 . "-" . date("G") . "-" . floor(date("i") / 15) * 15;
if (file_exists("schedule/" . $now)) {
    $heating = true;
} else {
    $heating = false;
}
// Weather
$tempNow = getTemp();
$tempCold = getTempCold();
if ($tempNow <= $tempCold) {
    $weatherCold = true;
} else {
    $weatherCold = false;
}
// Logic
if ($heatingBoost) {
    if (!$heatingActive) {
        file_put_contents($gpioFile, $gpioOn);
        file_put_contents($logFile, date("d/m/y @ H:i") . " Heating On (Boost Active)\n", FILE_APPEND);
    }
    exit;
}
if ($heating && $weatherCold) {