function checkServer() { $isrunningmac = ismac(); if ($isrunningmac = true) { $cmd = "ps aux < /dev/null | grep siriproxy"; exec($cmd, $output, $result); if (count($output) >= 3) { return true; } $cmd = "ps aux < /dev/null | grep ruby"; exec($cmd, $output2, $result); if (count($output2) >= 3) { return true; } return false; } $cmd = "ps -C siriproxy"; exec($cmd, $output, $result); if (count($output) >= 2) { return true; } $cmd = "ps -C ruby"; exec($cmd, $output2, $result); if (count($output2) >= 2) { return true; } return false; }
function db_add_ap($row, $cmtid, $uid) { global $checkexist; global $db; global $aps; // Отбираем только валидные точки доступа $addr = $row[0]; $port = $row[1]; if ($addr == 'IP Address' && $port == 'Port') { return 1; } $bssid = $row[8]; $essid = $row[9]; if (strlen($essid) > 32) { $essid = substr($essid, 0, 32); } $sec = $row[10]; $key = $row[11]; if (strlen($key) > 64) { $key = substr($key, 0, 64); } $wps = preg_replace('~\\D+~', '', $row[12]); // Оставляем только цифры if ($bssid == '<no wireless>') { return 2; } if (ismac($bssid)) { $NoBSSID = 0; $bssid = mac2dec($bssid); } else { $NoBSSID = 1; if ($bssid == '<access denied>') { $NoBSSID = 2; } if ($bssid == '<not accessible>') { $NoBSSID = 3; } if ($bssid == '<not implemented>') { $NoBSSID = 4; } $bssid = 0; } if (($NoBSSID || $wps == '') && ($essid == '' || $sec == '' || $sec == '-' || $key == '' || $key == '-')) { if ($NoBSSID == 0 || $essid != '' || $sec != '' || $key != '' || $wps != '') { return 3; } else { return 1; } // Вообще не содержит данных } if ($checkexist) { if (db_ap_exist($NoBSSID, $bssid, $essid, $key)) { return 4; // Уже есть в базе, пропускаем } } if ($NoBSSID == 0) { $aps[] = $bssid; // Записываем в очередь ожидания $chkgeo = QuerySql("SELECT `BSSID` FROM GEO_TABLE WHERE `BSSID`={$bssid} LIMIT 1"); if ($chkgeo->num_rows == 0) { // Добавляем новый BSSID с координатами NULL QuerySql("INSERT INTO GEO_TABLE (`BSSID`) VALUES ({$bssid})"); } $chkgeo->close(); } if ($cmtid == null) { $cmtid = 'NULL'; } $addr = _ip2long($addr); // IP Address if ($addr == 0 || $addr == -1) { $addr = 'NULL'; } $port = $port == '' ? 'NULL' : (int) $port; // Port $auth = $row[4] == '' ? 'NULL' : '\'' . $db->real_escape_string($row[4]) . '\''; // Authorization $name = '\'' . $db->real_escape_string($row[5]) . '\''; // Device Name $radio = $row[6] == '[X]' ? 1 : 0; // RadioOff $hide = $row[7] == '[X]' ? 1 : 0; // Hidden $essid = '\'' . $db->real_escape_string($essid) . '\''; // ESSID $sec = str2sec($sec); // Security $key = '\'' . $db->real_escape_string($key) . '\''; // Wi-Fi Key $wps = $wps == '' ? 1 : (int) $wps; // WPS PIN $lanip = _ip2long($row[13]); // LAN IP if ($lanip == 0 || $lanip == -1) { $lanip = 'NULL'; } $lanmsk = _ip2long($row[14]); // LAN Mask if ($lanmsk == 0) { $lanmsk = 'NULL'; } $wanip = _ip2long($row[15]); // WAN IP if ($wanip == 0 || $wanip == -1) { $wanip = 'NULL'; } $wanmsk = _ip2long($row[16]); // WAN Mask if ($wanmsk == 0) { $wanmsk = 'NULL'; } $gate = _ip2long($row[17]); // WAN Gateway if ($gate == 0 || $gate == -1) { $gate = 'NULL'; } $DNS = explode(' ', $row[18]); // DNS (up to 3 servers) for ($i = 0; $i < count($DNS); $i++) { $DNS[$i] = _ip2long($DNS[$i]); if ($DNS[$i] == 0 || $DNS[$i] == -1) { $DNS[$i] = 'NULL'; } } for ($i = 0; $i <= 3; $i++) { if (!isset($DNS[$i])) { $DNS[$i] = 'NULL'; } } QuerySql("INSERT INTO BASE_TABLE (`cmtid`,`IP`,`Port`,`Authorization`,`name`,`RadioOff`,`Hidden`,`NoBSSID`,`BSSID`,`ESSID`,`Security`,`WiFiKey`,`WPSPIN`,`LANIP`,`LANMask`,`WANIP`,`WANMask`,`WANGateway`,`DNS1`,`DNS2`,`DNS3`)\n\t\t\tVALUES ({$cmtid}, {$addr}, {$port}, {$auth}, {$name}, {$radio}, {$hide}, {$NoBSSID}, {$bssid}, {$essid}, {$sec}, {$key}, {$wps}, {$lanip}, {$lanmsk}, {$wanip}, {$wanmsk}, {$gate}, {$DNS['0']}, {$DNS['1']}, {$DNS['2']})\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t`cmtid`={$cmtid},`IP`={$addr},`Port`={$port},`Authorization`={$auth},`name`={$name},`RadioOff`={$radio},`Hidden`={$hide},`NoBSSID`={$NoBSSID},`BSSID`={$bssid},`ESSID`={$essid},`Security`={$sec},`WiFiKey`={$key},`WPSPIN`={$wps},`LANIP`={$lanip},`LANMask`={$lanmsk},`WANIP`={$wanip},`WANMask`={$wanmsk},`WANGateway`={$gate},`DNS1`={$DNS['0']},`DNS2`={$DNS['1']},`DNS3`={$DNS['2']};"); if (!is_null($uid)) { // Берём id точки из таблицы base в любом случае (могут быть расхождения с mem_base) $res = $db->query("SELECT id FROM " . BASE_TABLE . " WHERE NoBSSID={$NoBSSID} AND BSSID={$bssid} AND ESSID={$essid} AND Security={$sec} AND WiFiKey={$key} AND WPSPIN={$wps}"); $row = $res->fetch_row(); $res->close(); $id = (int) $row[0]; // Выясняем, если кто-то уже загрузил такую точку $res = $db->query("SELECT COUNT(uid) FROM uploads WHERE id={$id}"); $row = $res->fetch_row(); $res->close(); $creator = $row[0] > 0 ? 0 : 1; // Привязываем загруженную точку к аккаунту $db->query("INSERT IGNORE INTO uploads (uid, id, creator) VALUES ({$uid}, {$id}, {$creator})"); } return 0; }
} if (!isinteger($ui->post['ram'])) { $fail = 1; $template_file .= "Ram"; } if (!isinteger($ui->post['minram'])) { $fail = 1; $template_file .= "MinRam"; } else { $minram = $ui->post['minram']; } if (!isinteger($ui->post['maxram'])) { $fail = 1; $template_file .= "MaxRam"; } if (!ismac($ui->post['mac'])) { $fail = 1; $template_file .= "MAC"; } if (!active_check($ui->post['active'])) { $fail = 1; $template_file .= "Active"; } if ($reseller_id == 0) { $query = $sql->prepare("SELECT * FROM `virtualcontainer` WHERE `id`=? LIMIT 1"); $query->execute(array($id)); } else { $query = $sql->prepare("SELECT * FROM `virtualcontainer` WHERE `id`=? AND `resellerid`=? LIMIT 1"); $query->execute(array($id, $reseller_id)); } while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$row['comment'] = trim(preg_replace('/\\s+/', ' ', $row['comment'])); if ($row['comment'] == 'none') { $row['comment'] = ''; } $cmtid = getCommentId($row['comment'], true); $row['IP'] = _ip2long($row['IP']); if ($row['IP'] == 0 || $row['IP'] == -1) { $row['IP'] = null; } $row['Port'] = $row['Port'] == '' ? null : (int) $row['Port']; if ($row['Authorization'] == '') { $row['Authorization'] = null; } $row['RadioOff'] = $row['RadioOff'] == '[X]' ? 1 : 0; $row['Hidden'] = $row['Hidden'] == '[X]' ? 1 : 0; if (ismac($row['BSSID'])) { $NoBSSID = 0; $row['BSSID'] = mac2dec($row['BSSID']); } else { $NoBSSID = 1; if ($row['BSSID'] == '<access denied>') { $NoBSSID = 2; } if ($row['BSSID'] == '<not accessible>') { $NoBSSID = 3; } if ($row['BSSID'] == '<not implemented>') { $NoBSSID = 4; } $row['BSSID'] = 0; }