diff --git a/maintain/web/api/doAction.php b/maintain/web/api/doAction.php index a2f637b..6f7746d 100644 --- a/maintain/web/api/doAction.php +++ b/maintain/web/api/doAction.php @@ -167,6 +167,13 @@ else $fileName = empty($_GET['fn']) ? '' : $_GET['fn']; $values['cmd'] = json_encode(array('url' => $_GET['url'], 'md5' => $md5, 'fileName' => $fileName)); } + else if ($action == 'upd-ota') + { + $values['cmdName'] = 'yw_upd_ota'; + $md5 = empty($_GET['md5']) ? '' : $_GET['md5']; + $fileName = empty($_GET['fn']) ? '' : $_GET['fn']; + $values['cmd'] = json_encode(array('url' => $_GET['url'], 'md5' => $md5, 'fileName' => $fileName)); + } else if ($action == 'start-frpc') { $values['cmdName'] = 'yw_cmd_start_frpc'; diff --git a/maintain/web/api/queryTerms.php b/maintain/web/api/queryTerms.php index 15c9186..e306da3 100644 --- a/maintain/web/api/queryTerms.php +++ b/maintain/web/api/queryTerms.php @@ -84,7 +84,7 @@ if (count($conditions) > 0) $conditionStr = ' WHERE ' . implode(' AND ', $conditions); } -$sql = "SELECT t1.id, t1.cmdid,t1.`display_name`,t1.`protocol`,t1.bs_identifier AS `oid`,t2.`name` AS tower_name,t3.`name` AS line_name,t4.last_raw_report AS raw_report,t4.raw_report_time AS last_heartbeat_ts,FROM_UNIXTIME(t4.raw_report_time) AS last_heartbeat,t4.in_maintain,t4.quick_hb,t4.mode_time,t4.comment"; +$sql = "SELECT t1.id, t1.cmdid,t1.`display_name`,t1.`protocol`,t1.bs_identifier AS `oid`,t2.`name` AS tower_name,t3.`name` AS line_name,t4.last_raw_report AS raw_report,t4.raw_report_time AS last_heartbeat_ts,FROM_UNIXTIME(t4.raw_report_time) AS last_heartbeat,t4.last_ip,t4.in_maintain,t4.quick_hb,t4.mode_time,t4.comment"; $sql .= " FROM terminals AS t1 JOIN towers AS t2 ON t1.tower_id=t2.id JOIN `lines` AS t3 ON t2.line_id=t3.id"; $sql .= " LEFT JOIN mntn_status AS t4 ON t1.id=t4.term_id " . $conditionStr; if (empty($orderField)) diff --git a/maintain/web/api/queryUpgrades.php b/maintain/web/api/queryUpgrades.php index 8316dc4..95e813b 100644 --- a/maintain/web/api/queryUpgrades.php +++ b/maintain/web/api/queryUpgrades.php @@ -9,7 +9,7 @@ $db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'] $result = array('res' => 0, 'data' => array()); -$sql = "SELECT `id`,`title`,file_name AS fileName,`path`,file_size AS fileSize,`md5`,create_time AS createTime,update_time AS updateTime"; +$sql = "SELECT `id`,`title`,file_name AS fileName,`path`,file_size AS fileSize,`md5`,`type`,create_time AS createTime,update_time AS updateTime"; $sql .= " FROM mntn_upgrades WHERE `status`=1 OrDER BY `id` DESC"; $stmt = $db->prepare($sql); $stmt->execute(); diff --git a/maintain/web/api/updActivity.php b/maintain/web/api/updActivity.php index 5f735bb..338beea 100644 --- a/maintain/web/api/updActivity.php +++ b/maintain/web/api/updActivity.php @@ -31,28 +31,30 @@ if ($action == 'del') else if ($action == 'edt') { $title = empty($reqData['title']) ? '' : $reqData['title']; - $id = empty($reqData['id']) ? 0 : intval($_PreqDataOST['id']); - $termIds = empty($_POST['termIds']) ? array() : $reqData['termIds']; + $id = empty($reqData['id']) ? 0 : intval($reqData['id']); + $cmdids = empty($_POST['cmdids']) ? array() : $reqData['cmdids']; + + $contents = str_replace("\r\n", "\n", $cmdids); + $contents = str_replace("\n\r", "\n", $contents); + $contents = str_replace("\r", "\n", $contents); + $cmdids = explode("\n", $contents); + $cmdids = str_replace("'", "''", $cmdids); $values = array('id' => $id, 'title' => $title); $sql = "UPDATE mntn_activities SET `title`=:title,`term_count`=:termCount WHERE `id`=:id LIMIT 1"; $stmt = $db->prepare($sql); - $stmt->execute(array('id' => $id, 'title' => $title, 'termCount' => count($termIds))); + $stmt->execute(array('id' => $id, 'title' => $title, 'termCount' => count($cmdids))); $sql = "DELETE FROM mntn_activity_terminals WHERE `activity_id`=:id"; $stmt = $db->prepare($sql); $stmt->execute(array('id' => $id)); - $sql = "INSERT INTO mntn_activity_terminals(`activity_id`,`term_id`) VALUES(:id,:termId)"; + $sql = "INSERT INTO mntn_activity_terminals(`activity_id`,`term_id`) SELECT :id AS activity_id,`id` FROM terminals WHERE `cmdid` IN('" . implode("','", $cmdids) . "')"; $stmt = $db->prepare($sql); - foreach ($termIds as $termId) - { - $stmt->closeCursor(); - $stmt->execute(array('id' => $id, 'termId' => $termId)); - } + $stmt->execute(array('id' => $id)); $result['data'][] = $id; } @@ -87,6 +89,7 @@ else if ($action == 'new') $result['data'][] = $id; } + header ('Access-Control-Allow-Origin: *'); header ('Content-type: application/json; charset=utf-8'); echo json_encode($result, JSON_UNESCAPED_UNICODE); diff --git a/maintain/web/api/uploadFile.php b/maintain/web/api/uploadFile.php index 994978d..0278b44 100644 --- a/maintain/web/api/uploadFile.php +++ b/maintain/web/api/uploadFile.php @@ -10,12 +10,13 @@ $db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'] ]); $title = empty($_POST['title']) ? '' : $_POST['title']; + $upgradeType = empty($_POST['upgradeType']) ? 0 : intval($_POST['upgradeType']); if (isset($_FILES)) { $termIds = array(); // cmdid => id $paramTermId = isset($_GET['termId']) ? intval($_GET['termId']) : 0; - $sql = "INSERT INTO mntn_upgrades(`title`,`file_name`,`path`,`file_size`,`md5`) VALUES(:title,:fileName,:path,:fileSize,:md5)"; + $sql = "INSERT INTO mntn_upgrades(`title`,`file_name`,`path`,`file_size`,`md5`,`type`) VALUES(:title,:fileName,:path,:fileSize,:md5,:upgType)"; $stmt = $db->prepare($sql); $stmt2 = null; @@ -36,7 +37,7 @@ if (isset($_FILES)) } $md5 = md5($dest); - $item = array('fileName' => $file['name'], 'path' => $fileName, 'fileSize' => $file['size'], 'title' => $title, 'md5' => $md5); + $item = array('fileName' => $file['name'], 'path' => $fileName, 'fileSize' => $file['size'], 'title' => $title, 'md5' => $md5, 'upgType' => $upgradeType); $res = $stmt->execute($item); if (!$res) { diff --git a/reports/api/queryPhoto.php b/reports/api/queryPhoto.php index 999e00f..39f510e 100644 --- a/reports/api/queryPhoto.php +++ b/reports/api/queryPhoto.php @@ -79,7 +79,7 @@ foreach ($rows as $row) } $lineCondtion = $lineId ? ' WHERE t3.`id`=' . $lineId : ''; -$sql = "SELECT t1.id, t1.cmdid,t1.`display_name`,t1.`protocol`,t2.`name` AS tower_name,t3.`name` AS line_name, FROM_UNIXTIME(t4.last_heartbeat) AS last_heartbeat,FROM_UNIXTIME(t4.boot_time) AS boot_time FROM terminals AS t1 JOIN towers AS t2 ON t1.tower_id=t2.id JOIN `lines` AS t3 ON t2.line_id=t3.id"; +$sql = "SELECT t1.id, t1.cmdid,t1.`display_name`,t1.`protocol`,t2.`name` AS tower_name,t3.`name` AS line_name, FROM_UNIXTIME(t4.last_heartbeat) AS last_heartbeat,last_heartbeat_ip,FROM_UNIXTIME(t4.boot_time) AS boot_time FROM terminals AS t1 JOIN towers AS t2 ON t1.tower_id=t2.id JOIN `lines` AS t3 ON t2.line_id=t3.id"; $sql .= " LEFT JOIN terminal_status AS t4 ON t1.id=t4.term_id " . $lineCondtion . " ORDER BY t2.line_id,t1.cmdid"; $stmt = $db->query($sql); $rows = $stmt->fetchAll();