Exemple #1
0
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WEIPDCRM is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with WEIPDCRM.  If not, see <http://www.gnu.org/licenses/>.
 */
$_customct = true;
require_once 'system/common.inc.php';
if (!empty($_GET['request']) and (!empty($_SERVER['HTTP_X_UNIQUE_ID']) or DCRM_DIRECT_DOWN == 1)) {
    $lastip = DB::fetch_first("SELECT `IP` FROM `" . DCRM_CON_PREFIX . "UDID` WHERE `UDID` = '" . $_SERVER['HTTP_X_UNIQUE_ID'] . "'");
    $nowip = _ip2long(getIp());
    if (!empty($lastip) && $lastip['IP'] != $nowip) {
        DB::update(DCRM_CON_PREFIX . 'UDID', array('IP' => $nowip), array('UDID' => $_SERVER['HTTP_X_UNIQUE_ID']));
    }
    $r_path = $_GET['request'];
    $list_text = array('Release', 'Release.gpg', 'Packages', 'Packages.gz', 'Packages.bz2');
    if (in_array($r_path, $list_text)) {
        if (file_exists($r_path)) {
            downFile($r_path, $r_path);
        } else {
            httpinfo(404);
        }
    } else {
        httpinfo(405);
    }
} else {
Exemple #2
0
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;
}
Exemple #3
0
    public function NewUser($UserName, $Password, $Email, $UserGroupID = 0, $RegIP = '127.0.0.1')
    {
        $DB = new DB();
        $UserName = strtolower($UserName);
        $Hashcode = substr(md5(uniqid(rand(), true)), -6);
        $Password = md5($Password . $Hashcode . $UserName) . $Password;
        $Result = $DB->GetOne('SELECT UserID FROM tbl_users WHERE UserName=\'' . $UserName . '\'');
        if ($Result) {
            return -1;
        }
        $Result = $DB->GetOne('SELECT UserID FROM tbl_users WHERE Email=\'' . $Email . '\'');
        if ($Result) {
            return -2;
        }
        if (!$UserGroupID) {
            $UserGroup = $this->GetUserDefaultGroup();
            if ($UserGroup) {
                if ($UserGroup['RegEnable']) {
                    $UserGroupID = $UserGroup['UserGroupID'];
                } else {
                    return -4;
                }
            } else {
                return -3;
            }
        } else {
            if (!$this->GetUserGroup($UserGroupID)) {
                return -5;
            }
        }
        $RegIP = _ip2long($RegIP);
        $Sql = 'INSERT INTO tbl_users(`UserName`, `Password`,`Email`,`UserGroupID`,`Hashcode`,`RegDateTime`,`LastModified`,`RegIP`) 
		VALUES(\'' . $UserName . '\',\'' . $Password . '\',\'' . $Email . '\',\'' . $UserGroupID . '\',\'' . $Hashcode . '\',\'' . date('Y-m-d H:i:s') . '\',\'' . date('Y-m-d H:i:s') . '\',\'' . $RegIP . '\')';
        return $DB->Insert($Sql, true);
    }
Exemple #4
0
 if ($comment != '*') {
     if ($comment == '') {
         $cmtid = 0;
     } else {
         $comment = $db->real_escape_string($comment);
         $res = $db->query('SELECT `cmtid` FROM comments WHERE `cmtval`=\'' . $comment . '\'');
         if ($res->num_rows > 0) {
             $row = $res->fetch_row();
             $cmtid = (int) $row[0];
         } else {
             $cmtid = -2;
         }
         $res->close();
     }
 }
 $ipaddr = _ip2long($db->real_escape_string($ipaddr));
 $auth = $db->real_escape_string($auth);
 $name = $db->real_escape_string($name);
 $bssid = $db->real_escape_string($bssid);
 $essid = $db->real_escape_string($essid);
 $key = $db->real_escape_string($key);
 $wps = $db->real_escape_string($wps);
 $cur_page = 1;
 $per_page = 100;
 if (isset($_POST['page'])) {
     $cur_page = (int) $_POST['page'];
 }
 if ($cur_page < 1) {
     $cur_page = 1;
 }
 $sql = GenerateFindQuery($cmtid, $bssid, $essid, $auth, $name, $key, $wps, $cur_page, $per_page);
Exemple #5
0
    }
    $row['WANIP'] = _ip2long($row['WANIP']);
    if ($row['WANIP'] == 0 || $row['WANIP'] == -1) {
        $row['WANIP'] = null;
    }
    $row['WANMask'] = _ip2long($row['WANMask']);
    if ($row['WANMask'] == 0) {
        $row['WANMask'] = null;
    }
    $row['WANGateway'] = _ip2long($row['WANGateway']);
    if ($row['WANGateway'] == 0 || $row['WANGateway'] == -1) {
        $row['WANGateway'] = null;
    }
    $DNS = explode(' ', $row['DNS']);
    for ($i = 0; $i < count($DNS); $i++) {
        $DNS[$i] = _ip2long($DNS[$i]);
        if ($DNS[$i] == 0 || $DNS[$i] == -1) {
            $DNS[$i] = null;
        }
    }
    $wifi->bind_param('siiissiiissisiiiiiiiiiiiissiiissisiiiiiiiii', $row['time'], $cmtid, $row['IP'], $row['Port'], $row['Authorization'], $row['name'], $row['RadioOff'], $row['Hidden'], $NoBSSID, $row['BSSID'], $row['ESSID'], $row['Security'], $row['WiFiKey'], $row['WPSPIN'], $row['LANIP'], $row['LANMask'], $row['WANIP'], $row['WANMask'], $row['WANGateway'], $DNS[0], $DNS[1], $DNS[2], $cmtid, $row['IP'], $row['Port'], $row['Authorization'], $row['name'], $row['RadioOff'], $row['Hidden'], $NoBSSID, $row['BSSID'], $row['ESSID'], $row['Security'], $row['WiFiKey'], $row['WPSPIN'], $row['LANIP'], $row['LANMask'], $row['WANIP'], $row['WANMask'], $row['WANGateway'], $DNS[0], $DNS[1], $DNS[2]);
    $wifi->execute();
    if ($NoBSSID == 0 && $row['latitude'] != 'none') {
        if ($row['latitude'] == 'not found') {
            $row['latitude'] = 0;
            $row['longitude'] = 0;
        }
        $geo->bind_param('sddsdd', $row['BSSID'], $row['latitude'], $row['longitude'], $row['BSSID'], $row['latitude'], $row['longitude']);
        $geo->execute();
    }
}