Keresés

Hirdetés

Új hozzászólás Aktív témák

  • ztsoft

    őstag

    válasz gduck #96296 üzenetére

    Köszi! :R

    Jól jött a TC7200-hoz, már csak illeszteni kellene a CGP-hez (Collectd Graph Panel).

    Jó dolog fontosnak lenni, de fontosabb, hogy jók legyünk.

  • vargalex

    félisten

    válasz gduck #96296 üzenetére

    Igen, a Cisco és a TC7200 jelszintjeinek mentését is én követtem el. :) Csak azok még jóval egyszerűbbek voltak, így shell scriptben csináltam. Ha valakinek kellene, itt van Hitronhoz is:

    <?php
    define("MODEMUSER", "admin");
    define("MODEMPASSWORD", "admin");
    define('DBHOST', 'database_server');
    define('DBUSER', 'database_user');
    define('DBPASSWORD', 'database_password');
    define('DBDATABASE', 'database_name');
     $ch = curl_init("http://192.168.100.1/goform/login");
     curl_setopt( $ch, CURLOPT_POST, true);
     curl_setopt( $ch, CURLOPT_POSTFIELDS, "usr=admin");
     curl_setopt( $ch, CURLOPT_HEADER, true);
     curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, "AlexCurl");
     $response = curl_exec($ch);
     $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
     $headers = substr($response, 0, $header_size);
     $body = substr($response, $header_size);
     $headers = explode(PHP_EOL, $headers);
     foreach ($headers as $row) {
      $parts = explode(':', $row);
      if (count($parts) === 2) {
       $data[trim($parts[0])] = trim($parts[1]);
      }
     }
     parse_str(explode(";", $data["Set-Cookie"])[0], $cookies);
     $preSession=$cookies["preSession"];
            $ch = curl_init("http://192.168.100.1/goform/login");
            curl_setopt( $ch, CURLOPT_POST, true);
            curl_setopt( $ch, CURLOPT_POSTFIELDS, "usr=admin&pwd=admin&preSession=" . $preSession);
            curl_setopt( $ch, CURLOPT_HEADER, true);
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_USERAGENT, "AlexCurl");
            $response = curl_exec($ch);
            $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
            $headers = substr($response, 0, $header_size);
            $body = substr($response, $header_size);
            $headers = explode(PHP_EOL, $headers);
            foreach ($headers as $row) {
                    $parts = explode(':', $row);
                    if (count($parts) === 2) { 
                            $data[trim($parts[0])] = trim($parts[1]);
                    }
     }
            parse_str(explode(";", $data["Set-Cookie"])[0], $cookies);
     $sessionindex=$cookies["sessionindex"];
     $userid=$cookies["userid"];
            $ch = curl_init("http://192.168.100.1/data/dsinfo.asp");
            curl_setopt( $ch, CURLOPT_POST, false);
            curl_setopt( $ch, CURLOPT_HEADER, true);
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_USERAGENT, "AlexCurl");
            curl_setopt($ch, CURLOPT_COOKIE, "preSession=" . $preSession . "; sessionindex=" . $sessionindex . "&userid=" . $userid);
            $response = curl_exec($ch);
            $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
            $headers = substr($response, 0, $header_size);
     $body = substr($response, $header_size);
     $downstream = json_decode($body, true);
            $ch = curl_init("http://192.168.100.1/data/usinfo.asp");
            curl_setopt( $ch, CURLOPT_POST, false);
            curl_setopt( $ch, CURLOPT_HEADER, true);
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_USERAGENT, "AlexCurl");
            curl_setopt($ch, CURLOPT_COOKIE, "preSession=" . $preSession . "; sessionindex=" . $sessionindex . "&userid=" . $userid);
            $response = curl_exec($ch);
            $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
            $headers = substr($response, 0, $header_size);
            $body = substr($response, $header_size);
            $upstream = json_decode($body, true);

            $ch = curl_init("http://192.168.100.1/goform/logout");
            curl_setopt( $ch, CURLOPT_POST, true);
            curl_setopt( $ch, CURLOPT_POSTFIELDS, "byebye");
            curl_setopt( $ch, CURLOPT_HEADER, true);
            curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, "AlexCurl");
     curl_setopt($ch, CURLOPT_COOKIE, "preSession=" . $preSession . "; sessionindex=" . $sessionindex . "&userid=" . $userid);
            $response = curl_exec($ch);
            $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
            $headers = substr($response, 0, $header_size);
            $body = substr($response, $header_size);
            $headers = explode(PHP_EOL, $headers);
            foreach ($headers as $row) {
                    $parts = explode(':', $row);
                    if (count($parts) === 2) {
                            $data[trim($parts[0])] = trim($parts[1]);
                    }
            }
     parse_str(explode(";", $data["Set-Cookie"])[0], $cookies);
     $mysqli = new mysqli(DBHOST, DBUSER, DBPASSWORD, DBDATABASE);
     if ($mysqli->connect_error) {
      die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
     }
     $mysqli->query("insert into power_level_date(pld_date) values(now())");
     $dateID = $mysqli->insert_id;
     foreach ($downstream as $channel) {
      $sql = "select ch_id from channels where ch_freq='" . $mysqli->real_escape_string($channel["frequency"]) . "' and ch_type='D'";
      $result = $mysqli->query($sql) or die("Egyéb hiba");
      $row = $result->fetch_assoc();
      $channelID = $row["ch_id"];
      $row_cnt = $result->num_rows;
      $result->free();
      if ($row_cnt == 0) {
       $mysqli->query("insert into channels(ch_freq, ch_type) values('" . $channel["frequency"] . "', 'D')");
       $channelID = $mysqli->insert_id;
      }
      $mysqli->query("insert into power_levels(pl_ch_id, pl_pld_id, pl_power) values(" . $channelID . ", " . $dateID . ", " . $channel["signalStrength"] . ")");
     }
            foreach ($upstream as $channel) {
                    $sql = "select ch_id from channels where ch_freq='" . round($mysqli->real_escape_string($channel["frequency"])/10000)*10000 . "' and ch_type='U'";
                    $result = $mysqli->query($sql) or die("Egyéb hiba");
                    $row = $result->fetch_assoc();
                    $channelID = $row["ch_id"];
                    $row_cnt = $result->num_rows;
                    $result->free();
                    if ($row_cnt == 0) {
                            $mysqli->query("insert into channels(ch_freq, ch_type) values('" . $channel["frequency"] . "', 'U')");
                            $channelID = $mysqli->insert_id;
                    }
                    $mysqli->query("insert into power_levels(pl_ch_id, pl_pld_id, pl_power) values(" . $channelID . ", " . $dateID . ", " . $channel["signalStrength"] . ")");
     }
     $mysqli->close();
    ?>

    Alex

Új hozzászólás Aktív témák