Example #1
0
function siemens_push_str($phone_ip, $postdata)
{
    $prov_host = gs_get_conf('GS_PROV_HOST');
    $data = "POST /server_push.html/ServerPush HTTP/1.1\r\n";
    $data .= "User-Agent: Gemeinschaft\r\n";
    $data .= "Host: {$phone_ip}:8085\r\n";
    $data .= "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n";
    $data .= "Connection: keep-alive\r\n";
    $data .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $data .= "Content-Length: " . strLen($postdata) . "\r\n\r\n";
    $data .= $postdata;
    $socket = @fSockOpen($phone_ip, 8085, $error_no, $error_str, 4);
    if (!$socket) {
        gs_log(GS_LOG_NOTICE, "Siemens: Failed to open socket - IP: {$phone_ip}");
        return 0;
    }
    stream_set_timeout($socket, 4);
    $bytes_written = (int) @fWrite($socket, $data, strLen($data));
    @fFlush($socket);
    $response = @fGetS($socket);
    @fClose($socket);
    if (strPos($response, '200') === false) {
        gs_log(GS_LOG_WARNING, "Siemens: Failed to push to phone {$phone_ip}");
        return 0;
    }
    gs_log(GS_LOG_DEBUG, "Siemens: Pushed {$bytes_written} bytes to phone {$phone_ip}");
    return $bytes_written;
}
Example #2
0
function send_sip_packet($ip, $port, $packet, $source_ip = false)
{
    $spoof = $source_ip ? '-s \'' . $source_ip . '\'' : '';
    $p = pOpen('netcat -u -n -p 5060 -w 1 -q 0 ' . $spoof . ' ' . $ip . ' ' . $port . ' >>/dev/null', 'wb');
    fWrite($p, $packet, strLen($packet));
    fClose($p);
}
Example #3
0
function InitRecordCall($filename, $index, $comment)
{
    //FIXME
    $user = gs_user_get($_SESSION['sudo_user']['name']);
    $call = "Channel: SIP/" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: vm-rec-multiple\n" . "Extension: webdialrecord\n" . "Callerid: {$comment} <Aufnahme>\n" . "Setvar: __user_id=" . $_SESSION['sudo_user']['info']['id'] . "\n" . "Setvar: __user_name=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user="******"\n" . "Setvar: __record_file=" . $filename . "\n";
    $filename = '/tmp/gs-' . $_SESSION['sudo_user']['info']['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call';
    $cf = @fOpen($filename, 'wb');
    if (!$cf) {
        gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
        echo 'Failed to write call file.';
        die;
    }
    @fWrite($cf, $call, strLen($call));
    @fClose($cf);
    @chmod($filename, 0666);
    $spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
    if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
        $our_host_ids = @gs_get_listen_to_ids();
        if (!is_array($our_host_ids)) {
            $our_host_ids = array();
        }
        $user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
    } else {
        $user_is_on_this_host = true;
    }
    if ($user_is_on_this_host) {
        # the Asterisk of this user and the web server both run on this host
        $err = 0;
        $out = array();
        @exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        if ($err != 0) {
            @unlink($filename);
            gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . '/var/spool/asterisk/outgoing/' . baseName($filename) . '"');
            echo 'Failed to move call file.';
            die;
        }
    } else {
        $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
        //echo $cmd, "\n";
        @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        @unlink($filename);
        if ($err != 0) {
            gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
            echo 'Failed to scp call file.';
            die;
        }
        //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
        $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
        //echo $cmd, "\n";
        @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        if ($err != 0) {
            gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
            echo 'Failed to mv call file on remote host.';
            die;
        }
    }
}
Example #4
0
 private static function _shReadSecStatsFromFile($shFileName)
 {
     $logFile = fopen($shFileName, 'r');
     if ($logFile) {
         while (!feof($logFile)) {
             $line = fgets($logFile, 4096);
             self::_shDecodeSecLogLine($line);
         }
         fClose($logFile);
     }
 }
Example #5
0
 private function _shReadSecStatsFromFile($shFileName)
 {
     $logFile = fopen($shFileName, 'r');
     if ($logFile) {
         while (!feof($logFile)) {
             $line = fgets($logFile, 4096);
             Sh404sefHelperSecurity::_shDecodeSecLogLine($line);
         }
         fClose($logFile);
     }
 }
 /**
  * @see	\dns\system\cache\source\ICacheSource::set()
  */
 public function set($cacheName, $value, $maxLifetime)
 {
     $filename = $this->getFilename($cacheName);
     $content = "<?php exit; /* cache: " . $cacheName . " (generated at " . gmdate('r') . ") DO NOT EDIT THIS FILE */ ?>\n";
     $content .= serialize($value);
     if (!file_exists($filename)) {
         @touch($filename);
     }
     $handler = fOpen($filename, "a+");
     fWrite($handler, $content);
     fClose($handler);
 }
Example #7
0
 function parse($quizFileName)
 {
     $quizFile = fOpen($quizFileName, 'r');
     if ($quizFile) {
         $this->parseStart();
         while (($quizLine = fGets($quizFile, 4096)) !== false) {
             $this->parseLine($quizLine);
         }
         $this->parseEnd();
         fClose($quizFile);
     }
 }
Example #8
0
function gs_send_phone_desktop_msg($ip, $port, $ext, $registrar, $text, $extra = array())
{
    static $sock = null;
    static $lAddr = '0.0.0.0';
    static $lPort = 0;
    static $have_sockets = null;
    if ($have_sockets === null) {
        $have_sockets = function_exists('socket_create');
        // about 15 to 45 % faster
    }
    if (is_array($extra) && array_key_exists('fake_callid', $extra)) {
        $fake_callid = $extra['fake_callid'];
    } else {
        $fake_callid = rand(1000000000, 2000000000);
    }
    if ($have_sockets) {
        if (!$sock) {
            $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
            if (!$sock) {
                return false;
            }
            //socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1);
            //socket_bind($sock, '0.0.0.0', 12345);
            @socket_getSockName($sock, $lAddr, $lPort);
            //echo "Local socket is at $lAddr:$lPort\n";
            @socket_set_nonblock($sock);
        }
    } else {
        $sock = @fSockOpen('udp://' . $ip, $port, $err, $errmsg, 1);
        if (!$sock) {
            return false;
        }
        @stream_set_blocking($sock, 0);
        @stream_set_timeout($sock, 1);
    }
    $sipmsg = 'MESSAGE sip:' . $ext . '@' . $ip . ' SIP/2.0' . "\r\n" . 'Via: SIP/2.0/UDP ' . $registrar . ':' . $lPort . "\r\n" . 'To: sip:' . $ext . '@' . $ip . '' . "\r\n" . 'Call-ID: ' . $fake_callid . '@' . $registrar . "\r\n" . 'CSeq: 1 MESSAGE' . "\r\n" . 'Content-Type: text/plain; charset=utf-8' . "\r\n" . 'Max-Forwards: 9' . "\r\n" . 'From: sip:fake@' . $registrar . ':' . $lPort . ';tag=fake' . "\r\n" . 'Content-Length: ' . strLen($text) . "\r\n" . 'Content-Disposition: desktop' . "\r\n" . "\r\n" . $text;
    if ($have_sockets) {
        return @socket_sendto($sock, $sipmsg, strLen($sipmsg), 0, $ip, $port);
    } else {
        $written = @fWrite($sock, $sipmsg, strlen($sipmsg));
        @fClose($sock);
        return $written;
    }
}
Example #9
0
 function send($data = '')
 {
     if ($this->sock) {
         fwrite($this->sock, trim(strToUpper($this->method)) . " " . (array_key_exists('path', $this->url) ? $this->url['path'] : "") . (array_key_exists('query', $this->url) ? "?{$this->url['query']}" : "") . " HTTP/1.1\r\n" . "Host: {$this->url['host']}\r\n" . $this->requestHeaders . (preg_match("/(^|\r\n)Connection: /", $this->requestHeaders) ? "" : "Connection: Close\r\n") . "\r\n" . $data);
         $this->responseText = '';
         $this->status = null;
         $this->statusText = null;
         $isBody = false;
         while (!feof($this->sock)) {
             $line = fgets($this->sock, 1024);
             if ($this->status === null) {
                 if (!preg_match("/^HTTP\\/[\\d.]+\\s+(\\d+)(\\s+([^\r\n]+))?/i", $line, $matches)) {
                     throw new Exception('Invalid response');
                 }
                 $this->status = intval($matches[1]);
                 if (isset($matches[3])) {
                     $this->statusText = $matches[3];
                 }
             } else {
                 if ($isBody) {
                     $this->responseText .= $line;
                 } else {
                     if (preg_match("/^[\r\n]+\$/", $line)) {
                         $isBody = true;
                     } else {
                         if (!preg_match("/^([^:]+):\\s*([^\r\n]+)/", $line, $matches)) {
                             throw new Exception('Invalid header');
                         }
                         $this->responseHeaders[$this->capitalize($matches[1])] = $matches[2];
                     }
                 }
             }
         }
         fClose($this->sock);
         if (array_key_exists('Transfer-Encoding', $this->responseHeaders) && preg_match('/(^|[,\\s])chunked([,\\s]|$)/i', $this->responseHeaders['Transfer-Encoding'])) {
             $this->responseText = preg_replace("/^[a-f0-9]+[^\r\n]*\r?\n|\r?\n0+[^\r\n]*[\r\n]+\$/i", '', $this->responseText);
         }
     }
 }
Example #10
0
function aastra_push_str($phone_ip, $xml)
{
    $prov_host = gs_get_conf('GS_PROV_HOST');
    //FIXME - call wget or something. this function should not block
    // for so long!
    // see _gs_prov_phone_checkcfg_by_ip_do_aastra() in
    // opt/gemeinschaft/inc/gs-fns/gs_prov_phone_checkcfg.php
    //$xml = utf8_decode($xml);
    if (subStr($xml, 0, 5) !== '<' . '?xml') {
        $xmlpi = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' . "\n";
    } else {
        $xmlpi = '';
    }
    $data = "POST / HTTP/1.1\r\n";
    $data .= "Host: {$phone_ip}\r\n";
    $data .= "Referer: {$prov_host}\r\n";
    $data .= "Connection: Close\r\n";
    $data .= "Content-Type: text/xml; charset=utf-8\r\n";
    $data .= "Content-Length: " . (strLen('xml=') + strLen($xmlpi) + strLen($xml)) . "\r\n";
    $data .= "\r\n";
    $data .= 'xml=' . $xmlpi . $xml;
    $socket = @fSockOpen($phone_ip, 80, $error_no, $error_str, 4);
    if (!$socket) {
        gs_log(GS_LOG_NOTICE, "Aastra: Failed to open socket - IP: {$phone_ip}");
        return 0;
    }
    stream_set_timeout($socket, 4);
    $bytes_written = (int) @fWrite($socket, $data, strLen($data));
    @fFlush($socket);
    $response = @fGetS($socket);
    @fClose($socket);
    if (strPos($response, '200') === false) {
        gs_log(GS_LOG_WARNING, "Aastra: Failed to push XML to phone {$phone_ip}");
        return 0;
    }
    gs_log(GS_LOG_DEBUG, "Aastra: Pushed {$bytes_written} bytes to phone {$phone_ip}");
    return $bytes_written;
}
 protected function parseIt($filename = '')
 {
     if (!file_exists($filename) || !is_readable($filename)) {
         echo "file name error!";
         return FALSE;
     }
     $header = NULL;
     $data = array();
     if (($handle = fopen($filename, 'r')) !== FALSE) {
         while (($row = fgetcsv($handle, 0, ',')) !== FALSE) {
             if (!$header) {
                 $header = $row;
             } else {
                 $data[] = array_combine($header, $row);
             }
         }
         fClose($handle);
     }
     return $data;
 }
Example #12
0
function shCloseLogFile()
{
    global $shLogger;
    if (!empty($shLogger)) {
        $shLogger->log('Closing log file at shutdown' . "\n\n");
        if (!empty($shLogger->logFile)) {
            fClose($shLogger->logFile);
        }
    }
}
 public function finish()
 {
     fClose($this->DumpFile);
 }
 /**
  * build language files from database
  *
  * @param	boolean	$force
  */
 public static function buildlanguage($force = false)
 {
     $availableLanguages = array("de", "en");
     foreach ($availableLanguages as $languageID => $languageCode) {
         $file = DNS_DIR . "/lang/" . $languageCode . ".lang.php";
         if (!file_exists($file) || filemtime($file) + 86400 < time() || $force === true) {
             if (file_exists($file)) {
                 @unlink($file);
             }
             @touch($file);
             $items = self::getDB()->query("select * from dns_language where languageID = ?", array($languageID));
             $content = "<?php\n/**\n* language: " . $languageCode . "\n* encoding: UTF-8\n* generated at " . gmdate("r") . "\n* \n* DO NOT EDIT THIS FILE\n*/\n";
             $content .= "\$lang = array();\n";
             while ($row = self::getDB()->fetch_array($items)) {
                 print_r($row);
                 $content .= "\$lang['" . $row['languageItem'] . "'] = '" . str_replace("\$", '$', $row['languageValue']) . "';\n";
             }
             $handler = fOpen($file, "a+");
             fWrite($handler, $content);
             fClose($handler);
         }
     }
 }
function gs_callforward_activate($user, $source, $case, $active)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    if (!in_array($source, array('internal', 'external'), true)) {
        return new GsError('Source must be internal|external.');
    }
    if (!in_array($case, array('always', 'busy', 'unavail', 'offline'), true)) {
        return new GsError('Case must be always|busy|unavail|offline.');
    }
    if (!in_array($active, array('no', 'std', 'var', 'vml', 'ano', 'trl', 'par'), true)) {
        return new GsError('Active must be no|std|var|vml|ano|trl|par.');
    }
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user_id
    #
    $user_id = $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\'');
    if (!$user_id) {
        return new GsError('Unknown user.');
    }
    # get user_ext
    #
    $user_ext = $db->executeGetOne('SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`=\'' . $db->escape($user_id) . '\'');
    if (!$user_ext) {
        return new GsError('Unknown user extension.');
    }
    # check if user has an entry
    #
    $num = $db->executeGetOne('SELECT COUNT(*) FROM `callforwards` WHERE `user_id`=' . $user_id . ' AND `source`=\'' . $db->escape($source) . '\' AND `case`=\'' . $db->escape($case) . '\'');
    if ($num < 1) {
        $ok = $db->execute('INSERT INTO `callforwards` (`user_id`, `source`, `case`, `number_std`, `number_var`, `number_vml`, `active`) VALUES (' . $user_id . ', \'' . $db->escape($source) . '\', \'' . $db->escape($case) . '\', \'\', \'\', \'\', \'no\')');
    } else {
        $ok = true;
    }
    # do not allow time rules if no time rules  are defined
    #
    if ($active == 'trl') {
        $id = (int) $db->executeGetOne('SELECT `_user_id` from `cf_timerules` WHERE `_user_id`=' . $user_id);
        if (!$id) {
            return new GsError('No time rules defined. Cannot activate call forward.');
        }
    } else {
        if ($active == 'par') {
            $id = (int) $db->executeGetOne('SELECT `_user_id` from `cf_parallelcall` WHERE `_user_id`=' . $user_id);
            if (!$id) {
                return new GsError('No parsllel call tragets. Cannot activate call forward.');
            }
        }
    }
    # set state
    #
    $ok = $ok && $db->execute('UPDATE `callforwards` SET
	`active`=\'' . $db->escape($active) . '\'
WHERE
	`user_id`=' . $user_id . ' AND
	`source`=\'' . $db->escape($source) . '\' AND
	`case`=\'' . $db->escape($case) . '\'
LIMIT 1');
    if (!$ok) {
        return new GsError('Failed to set call forwarding status.');
    }
    # do not allow an empty number to be active
    #
    if ($active == 'std' || $active == 'var') {
        $field = 'number_' . $active;
        $number = $db->executeGetOne('SELECT `' . $field . '` FROM `callforwards` WHERE `user_id`=' . $user_id . ' AND `source`=\'' . $db->escape($source) . '\' AND `case`=\'' . $db->escape($case) . '\'');
        if (trim($number) == '') {
            $db->execute('UPDATE `callforwards` SET `active`=\'no\' WHERE `user_id`=' . $user_id . ' AND `source`=\'' . $db->escape($source) . '\' AND `case`=\'' . $db->escape($case) . '\'');
            return new GsError('Number is empty. Cannot activate call forward.');
        }
    }
    if ($case === 'always') {
        $filename = '/tmp/gs-' . $user_id . '-' . time() . '-' . rand(10000, 99999) . '.call';
        $call = "Channel: local/toggle@toggle-cfwd-hint\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: toggle-cfwd-hint\n" . "Extension: toggle\n" . "Callerid: {$user} <Toggle>\n" . "Setvar: __user_id=" . $user_id . "\n" . "Setvar: __user_name=" . $user_ext . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user="******"\n" . "Setvar: __record_file=" . $filename . "\n";
        $cf = @fOpen($filename, 'wb');
        if (!$cf) {
            gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
            return new GsError('Failed to write call file.');
        }
        @fWrite($cf, $call, strLen($call));
        @fClose($cf);
        @chmod($filename, 0666);
        $spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
        if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
            $our_host_ids = @gs_get_listen_to_ids();
            if (!is_array($our_host_ids)) {
                $our_host_ids = array();
            }
            $user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
        } else {
            $user_is_on_this_host = true;
        }
        if ($user_is_on_this_host) {
            # the Asterisk of this user and the web server both run on this host
            $err = 0;
            $out = array();
            @exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
            if ($err != 0) {
                @unlink($filename);
                gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . $spoolfile . '"');
                return new GsError('Failed to move call file.');
            }
        } else {
            $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
            //echo $cmd, "\n";
            @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
            @unlink($filename);
            if ($err != 0) {
                gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
                return new GsError('Failed to scp call file.');
            }
            //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
            $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
            //echo $cmd, "\n";
            @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
            if ($err != 0) {
                gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
                return new GsError('Failed to mv call file on remote host.');
            }
        }
    }
    return true;
}
Example #16
0
        fClose($handler);
        $signed = false;
        if ($sign === true) {
            shell_exec("cd /srv/bind/ && /usr/sbin/dnssec-signzone -r /dev/urandom -A -N INCREMENT -K /srv/bind/dnssec/" . $zone['soa']['origin'] . "/ -o " . $zone['soa']['origin'] . " -t " . $zone['soa']['origin'] . "db");
            if (file_exists("/srv/bind/" . $zone['soa']['origin'] . "db.signed")) {
                $signed = true;
            }
        }
        $cout = "zone \"" . $zone['soa']['origin'] . "\" {\n";
        $cout .= "\ttype master;\n";
        $cout .= "\tnotify no;\n";
        $cout .= "\tfile \"/srv/bind/" . $zone['soa']['origin'] . "db" . ($signed === true ? ".signed" : "") . "\";\n";
        $cout .= "};\n\n";
        $handler = fOpen("/srv/bind/domains.cfg", "a+");
        fWrite($handler, $cout);
        fClose($handler);
    }
    shell_exec("/etc/init.d/bind9 reload");
}
function getFileName($zone, $algo, $id, $type)
{
    $len = strlen($id);
    if ($len == "1") {
        $id = "0000" . $id;
    } else {
        if ($len == "2") {
            $id = "000" . $id;
        } else {
            if ($len == "3") {
                $id = "00" . $id;
            } else {
Example #17
0
function readDataFile($data_file)
{
    global $node;
    $datafilep = @fOpen($data_file, 'rb');
    if (!$datafilep) {
        write_log("Cannot open {$data_file} for reading! Using cluster data from configuration. This will reset *all* states!");
        return 1;
    }
    $datafilesize = fileSize($data_file);
    $save_struct = @fRead($datafilep, $datafilesize);
    $node = unSerialize($save_struct);
    fClose($datafilep);
}
Example #18
0
 public static function writeFile($file, $content)
 {
     $success = false;
     if ($handle = @fOpen($file, "w")) {
         if (fWrite($handle, $content)) {
             $success = true;
             self::log(sprintf(ERR_NONE, self::bold($file)), self::LOG_OK);
         } else {
             self::log(sprintf(ERR_WRITE_FILE, self::bold($file)), self::LOG_ERROR);
         }
         fClose($handle);
     } else {
         self::log(sprintf(ERR_CREATE_FILE, self::bold($file)), self::LOG_ERROR);
     }
     if ($success) {
         @chmod($file, Util::FILE_ACCESS);
     }
     return $success;
 }
Example #19
0
function readFiles($a)
{
    $fname = explode("/", $a);
    $fnameNums = count($fname);
    $fname = $fname[$fnameNums - 1];
    if (strcmp($fname, "loaddir.php") == 0) {
        echo "<script>alert('不能编辑该文件!');location.href='loaddir.php';</script>";
    }
    //$exts=substr($a,-3);
    $exts = explode(".", $a);
    $extsNums = count($exts);
    $exts = $exts[$extsNums - 1];
    if ($exts == "php" || $exts == "asp" || $exts == "txt" || $exts == "html" || $exts == "aspx" || $exts == "jsp" || $exts == "htm") {
        $handle = @fOpen($a, "r");
        if ($handle) {
            echo "<h3>修改文件:{$a}</h3>";
            echo "<form action='loaddir.php?action=doedit&urlstr={$a}' method='post'><textarea style='width:99%;height:300px;margin-left:auto;margin-right:auto;' name='content'>";
            while (!fEof($handle)) {
                //$buffer=fGets($handle);
                //echo ubb(mb_convert_variables(fGets($handle),"gb2312","gb2312,utf-8"));
                //echo ubb(mb_convert_encoding(fGets($handle),"gb2312","utf-8,gb2312"));
                echo ubb(mb_convert_encoding(fGets($handle), "utf-8", "auto"));
                //echo ubb(iconv("utf-8,gb2312","gb2312",fGets($handle)));
                //echo ubb(fGets($handle));
            }
            fClose($handle);
            echo "</textarea><h3><input type='submit' value='修改' /></h3></form>";
        } else {
            //echo "文件不存在或不可用";
            echo "<script>alert('文件不存在或不可用');location.href='loaddir.php';</script>";
        }
    } else {
        //echo "不能编辑该文件";
        echo "<script>alert('不能编辑该文件');location.href='loaddir.php';</script>";
    }
}
            foreach ($pofiles as $pofile) {
                $domain = baseName($pofile, '.po');
                $lang = baseName(dirName(dirName($pofile)));
                /*
                # build .mo file for gettext
                #
                echo "Building $lang $domain.mo ...\n";
                $mofile = preg_replace('/\.po$/', '.mo', $pofile);
                passThru( 'msgfmt -o '. qsa($mofile) .' '. qsa($pofile), $err );
                if ($err !== 0) {
                	echo "  Failed.";
                	if ($err === 127) echo " (msgfmt not found. gettext not installed?)";
                	echo "\n";
                }
                */
                # build .php file for php
                #
                echo "Building {$lang} {$domain}.php ...\n";
                $phpout = _po_to_php($pofile);
                if (!is_array($phpout)) {
                    $phpout = array();
                }
                $phpout = '<' . "?php\n" . "// AUTO-GENERATED FILE. TO MAKE CHANGES EDIT\n" . "// " . $domain . ".po AND REBUILD\n\n" . $copyright . "\n\n" . '$g_gs_LANG[\'' . $lang . '\'][\'' . $domain . '\'] = ' . var_export($phpout, true) . ";\n\n" . '?' . '>';
                $phpfile = preg_replace('/\\.po$/', '.php', $pofile);
                $f = fOpen($phpfile, 'wb');
                fWrite($f, $phpout, strLen($phpout));
                fClose($f);
            }
        }
    }
}
Example #21
0
 public static function setSMTPconnectionParams()
 {
     $configs = array(array('ssl://', 465), array('tls://', 587), array('', 587), array('', 588), array('tls://', 25), array('', 25));
     $host = Configuration::get('PS_MAIL_SERVER');
     $connected = FALSE;
     for ($i = 0; $i < count($configs); ++$i) {
         $soc = @fSockOpen($configs[$i][0] . $host, $configs[$i][1], $errno, $errstr, 5);
         if ($soc) {
             fClose($soc);
             $connected = TRUE;
             break;
         }
     }
     if ($connected) {
         if ('ssl://' == $configs[$i][0]) {
             Configuration::updateValue('PS_MAIL_SMTP_ENCRYPTION', 'ssl');
         } elseif ('tls://' == $configs[$i][0]) {
             Configuration::updateValue('PS_MAIL_SMTP_ENCRYPTION', 'tls');
         } else {
             Configuration::updateValue('PS_MAIL_SMTP_ENCRYPTION', '');
         }
         Configuration::updateValue('PS_MAIL_SMTP_PORT', $configs[$i][1]);
     }
 }
Example #22
0
function shLogToSecFile($logData)
{
    $shNum = 12 * (intval(date('Y')) - 2000) + intval(date('m'));
    // number current month
    $shFileName = sh404SEF_ADMIN_ABS_PATH . 'logs/' . date('Y') . '-' . date('m') . '-' . 'sh404SEF_security_log.' . $shNum . '.log';
    $fileIsThere = file_exists($shFileName);
    if (!$fileIsThere) {
        // create file
        $fileHeader = "Date\tTime\tCause\tIP\tName\tUser agent\tRequest method\tRequest URI\tComment\n";
    } else {
        $fileHeader = '';
    }
    if (!$fileIsThere || $fileIsThere && is_writable($shFileName)) {
        $logFile = fopen($shFileName, 'ab');
        if ($logFile) {
            if (!empty($fileHeader)) {
                fWrite($logFile, $fileHeader);
            }
            fWrite($logFile, $logData);
            fClose($logFile);
        }
    }
}
Example #23
0
 public static function generate($key, array $updateIds = [])
 {
     $success = false;
     $reqDBC = [];
     if (file_exists('setup/tools/filegen/' . $key . '.func.php')) {
         require_once 'setup/tools/filegen/' . $key . '.func.php';
     } else {
         if (empty(self::$tplFiles[$key])) {
             CLISetup::log(sprintf(ERR_MISSING_INCL, $key, 'setup/tools/filegen/' . $key . '.func.php', CLISetup::LOG_ERROR));
             return false;
         }
     }
     CLISetup::log('FileGen::generate() - gathering data for ' . $key);
     if (!empty(self::$tplFiles[$key])) {
         list($file, $destPath, $deps) = self::$tplFiles[$key];
         if ($content = file_get_contents(FileGen::$tplPath . $file . '.in')) {
             if ($dest = @fOpen($destPath . $file, "w")) {
                 // replace constants
                 $content = strtr($content, FileGen::$txtConstants);
                 // check for required auxiliary DBC files
                 foreach ($reqDBC as $req) {
                     if (!CLISetup::loadDBC($req)) {
                         continue 2;
                     }
                 }
                 // must generate content
                 // PH format: /*setup:<setupFunc>*/
                 $funcOK = true;
                 if (preg_match_all('/\\/\\*setup:([\\w\\-_]+)\\*\\//i', $content, $m)) {
                     foreach ($m[1] as $func) {
                         if (function_exists($func)) {
                             $content = str_replace('/*setup:' . $func . '*/', $func(), $content);
                         } else {
                             $funcOK = false;
                             CLISetup::log('No function for was registered for placeholder ' . $func . '().', CLISetup::LOG_ERROR);
                             if (!array_reduce(get_included_files(), function ($inArray, $itr) use($func) {
                                 return $inArray || false !== strpos($itr, $func);
                             }, false)) {
                                 CLISetup::log('Also, expected include setup/tools/filegen/' . $name . '.func.php was not found.');
                             }
                         }
                     }
                 }
                 if (fWrite($dest, $content)) {
                     CLISetup::log(sprintf(ERR_NONE, CLISetup::bold($destPath . $file)), CLISetup::LOG_OK);
                     if ($content && $funcOK) {
                         $success = true;
                     }
                 } else {
                     CLISetup::log(sprintf(ERR_WRITE_FILE, CLISetup::bold($destPath . $file)), CLISetup::LOG_ERROR);
                 }
                 fClose($dest);
             } else {
                 CLISetup::log(sprintf(ERR_CREATE_FILE, CLISetup::bold($destPath . $file)), CLISetup::LOG_ERROR);
             }
         } else {
             CLISetup::log(sprintf(ERR_READ_FILE, CLISetup::bold(FileGen::$tplPath . $file . '.in')), CLISetup::LOG_ERROR);
         }
     } else {
         if (!empty(self::$datasets[$key])) {
             if (function_exists($key)) {
                 // check for required auxiliary DBC files
                 foreach ($reqDBC as $req) {
                     if (!CLISetup::loadDBC($req)) {
                         return false;
                     }
                 }
                 $success = $key($updateIds);
             } else {
                 CLISetup::log(' - subscript \'' . $key . '\' not defined in included file', CLISetup::LOG_ERROR);
             }
         }
     }
     set_time_limit(FileGen::$defaultExecTime);
     // reset to default for the next script
     return $success;
 }
Example #24
0
    $callerid = 'Anonymous <anonymous>';
}
if (!$is_foreign) {
    //FIXME? - is this code correct for numbers in the same area?
    $to_num = subStr($to_num_obj->dial, 0, 1) === '0' ? '0' . $to_num_obj->dial : $to_num_obj->dial;
    $from_num_dial = subStr($from_num_effective_obj->dial, 0, 1) === '0' ? '0' . $from_num_effective_obj->dial : $from_num_effective_obj->dial;
    $call = "Channel: Local/urldial-" . $from_num_dial . "@to-internal-users-self\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: urldial\n" . "Extension: {$prvPrefix}{$to_num}\n" . "Callerid: Rufaufbau <call>\n" . "Setvar: __user_id=" . $user['id'] . "\n" . "Setvar: __user_name=" . $user['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __saved_callerid=" . $callerid . "\n" . "Setvar: __callfile_from_user="******"\n";
    //echo $call;
    $filename = '/tmp/gs-' . $user['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call';
    $cf = @fOpen($filename, 'wb');
    if (!$cf) {
        gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
        die_error('Failed to write call file.');
    }
    @fWrite($cf, $call, strLen($call));
    @fClose($cf);
    @chmod($filename, 0666);
    $spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
    if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
        $our_host_ids = @gs_get_listen_to_ids();
        if (!is_array($our_host_ids)) {
            $our_host_ids = array();
        }
        $user_is_on_this_host = in_array($user['host_id'], $our_host_ids);
    } else {
        $user_is_on_this_host = true;
    }
    if ($user_is_on_this_host) {
        # the Asterisk of this user and the web server both run on this host
        //$ok = @rename( $filename, $spoolfile );
        $err = 0;
Example #25
0
$boxes = '|boxes -d santa';
//boxes -d <boxid>
$cusfuncshell = 'echo "Your Message here"|boxes';
//justom function what you want. JUST TERMINAL CODES like echo "some think" or "cd /somedir" etc.
###############################################################
$cusfunc = "  " . $cusfuncshell;
###############################################################
//PocketControl
$control1 = shell_exec("dpkg -s figlet");
if (strstr($control1, "install ok installed")) {
    $control2 = shell_exec("dpkg -s boxes");
    if (strstr($control2, "install ok installed")) {
        //Bashrc Control
        $dosya_ici = fOpen("/root/.bashrc", "r");
        $dosya_oku = fRead($dosya_ici, fileSize("/root/.bashrc"));
        fClose($dosya_ici);
        //somecommands
        $whoami = shell_exec("whoami");
        $say = count($_SERVER['argv']);
        $argum = $_SERVER['argv'];
        if (strstr($dosya_oku, "php CusTerm.php", true)) {
            ###############################################################
            if (@$argum[1] == "--help") {
                echo "yardım mı lazımdır?";
                exit;
            }
            if ($ne == "standard") {
                $nick = exec("whoami");
                echo $figlet = shell_exec($figlet . " " . $nick . $boxes);
                echo $customch = shell_exec($cusfunc);
                echo "CusTerm v1.0.0\n";
 function execFFMPEG($i = '', $o = '', $p = '', $pkey = '')
 {
     if ($pkey == '') {
         $pkey = rand();
     }
     $fpath = FFMPEG_PATH;
     if (empty($fpath)) {
         $this->logError('ffmpeg-progressbar: missing ffmpeg path', date("d-m-y") . '.error.log');
         exit('ffmpeg-progressbar: missing ffmpeg path');
     } else {
         if (!file_exists($fpath)) {
             $this->logError('ffmpeg-progressbar: wrong ffmpeg path \'' . FFMPEG_PATH . '\'', date("d-m-y") . '.error.log');
             exit('ffmpeg-progressbar: wrong ffmpeg path \'' . FFMPEG_PATH . '\'');
         }
     }
     if (empty($i)) {
         $this->logError('ffmpeg: missing argument for option \'i\'', date("d-m-y") . '.error.log');
         exit('ffmpeg: missing argument for option \'i\'');
     } elseif (!file_exists($i)) {
         $this->logError($i . ':  no such file or directory', date("d-m-y") . '.error.log');
         exit($i . ':  no such file or directory');
     } elseif (empty($o)) {
         $this->logError('ffmpeg: At least one output file must be specified', date("d-m-y") . '.error.log');
         exit('ffmpeg: At least one output file must be specified');
     } elseif (file_exists($o)) {
         $this->logError('ffmpeg: File \'' . $o . '\' already exists.', date("d-m-y") . '.error.log');
         exit('ffmpeg: File \'' . $o . '\' already exists.');
     } elseif (empty($p)) {
         $this->logError('ffmpeg: No Param has been specified... use default settings for converting...', date("d-m-y") . '.warn.log');
     } else {
         //Executing FFMPEG
         $handler = fOpen(dirname(__FILE__) . '/../log/' . $pkey . '.ffmpeg.file', "w");
         fWrite($handler, $i . "\n" . $o . "\n" . $p . "\n");
         fClose($handler);
         $this->logError("Sending FFMPEG exec command to " . $_SERVER["HTTP_HOST"] . "...");
         $curdir = getcwd();
         $cmd = " -i '" . $i . "' " . $p . " '" . $o . "' 2> " . $curdir . "/log/" . $pkey . ".ffmpeg";
         $postdata = "cmd=" . $cmd . "&ffmpegpw=" . FFMPEG_PW;
         $fp = fsockopen($_SERVER["HTTP_HOST"], 80, $errno, $errstr, 30);
         fputs($fp, "POST " . dirname($_SERVER["SCRIPT_NAME"]) . "/inc/execFFMPEG.php HTTP/1.0\n");
         fputs($fp, "Host: " . $_SERVER["HTTP_HOST"] . "\n");
         fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
         fputs($fp, "Content-length: " . strlen($postdata) . "\n");
         // Faking User-Agent to Microsoft Internet Explorer 7
         fputs($fp, "User-agent: Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)\n");
         fputs($fp, "Connection: close\n\n");
         fputs($fp, $postdata);
         fclose($fp);
     }
 }
 private function streamClose()
 {
     if ($this->fp) {
         @fClose($this->fp);
     }
 }
Example #28
0
		private function attack_log_module(){
			$str = '';
			//logs
			{
				//Stores the IP string to search for or false
				$search = (isset($_POST['IpSearch']) && trim($_POST['IpSearch']) != "" ) ? $_POST['IpSearch'] : false;
				$remIP  = (isset($_POST['IpRemove']) && trim($_POST['IpRemove']) != "" ) ? $_POST['IpRemove'] : false;
								
				if($remIP !== false){
					$arr = array('act'=>'get_attacks','host'=>$this->host,'what'=>'remove', 'ip'=>$remIP);
					$check = $this->sl_post_request('remote4.php',http_build_query($arr,'','&'));
				}
				if(isset($_POST['action']) && $_POST['action'] == "delete" && isset($_POST['selected_attacks']) && !empty($_POST['selected_attacks'])){
					$sURL = array('act'=>'remove_attack','host'=>$this->host);
					foreach($_POST['selected_attacks'] as $attack){
						$sURL['id'][] = $attack;
					}
					$check = $this->sl_post_request('remote4.php', http_build_query($sURL,'','&'));
				}
					
				
	            $str .= '        <!-- Adverts -->';
	            $str .= '        <div class="s5_wrap" >';
	            $str .= '            <div class="s5_w_modwrap">';
	            $str .= '                <div class="s5_backmiddlemiddle2">';
	            $str .= $this->ModuleStart("1", "100", "-light", "Attack Log <div style='float: right; clear: none; margin-right: 37px;'><a href=\"#\" onclick=\"sl_gateway.open('attacklog','&export_log=1');return false;\"><img src='".$this->filepath."/images/cvs_icon.png' style='margin-top: -4px;' /></a></div>", "advert", TRUE);
	            //$str .= '					<div id="" style="display:none;"></div>'."\n";
	            $str .= ' 					<form id="frmAttacks" style="clear: none;" method="POST" action="#" onsubmit="sl_gateway.open(\'attacklog\',this);return false;">'."\n";
	            $str .= '					<input type="hidden" name="action" value="delete"/>'."\n";
	            $str .= '                    <table>'."\n";
	            $str .= '                        <tr>'."\n";
	            $str .= '                            	 <td><span style="color:#000; font-weight: bold"><input type="checkbox" onclick="sl_Attacks_toggleSelectAll(this);" id="cbToogleSelectAll"/></span></td>'."\n";
	            $str .= '                            	 <td><span style="color:#000; font-weight: bold">#</span></td>'."\n";
	                $str .= '                            <td><span style="color:#000; font-weight: bold">IP Address</span></td>'."\n";
	                $str .= '                            <td><span style="color:#000; font-weight: bold">Attack Type</span></td>'."\n";
	                $str .= '                            <td><span style="color:#000; font-weight: bold">Attack ID</span></td>'."\n";
	                $str .= '                            <td><span style="color:#000; font-weight: bold">Threat Level</span></td>'."\n";
	                $str .= '                            <td><span style="color:#000; font-weight: bold">Date</span></td>'."\n";
	                $str .= '                            <td><span style="color:#000; font-weight: bold">Time</span></td>'."\n";
	            $str .= '                        </tr>'."\n";
	            $length = 30;
	            $start = isset($_POST['id']) ? $_POST['id'] : null;
	            $start = floor($start/30);
	            $start *= 30;
	            //call
	            if($search){
	            	$arr = array('act'=>'get_attacks','host'=>$this->host,'what'=>'search','where'=>$start, 'ip'=>$search);
				}
	            else {
	            	$arr = array('act'=>'get_attacks','host'=>$this->host,'what'=>'logs','where'=>$start);
				}
	            $retData = $this->sl_post_request('remote4.php',http_build_query($arr,'','&'));
	            //loop
	            $total = $retData[1];
	            for($i=2;$i<count($retData)-1;$i++){ //begin loop
	                $counter = $total-$i+2-$start;

	                $atk_arr = explode('~',$retData[$i]);
	                $atk_id = $atk_arr[0];
	                $atk_ip = $atk_arr[1];
	                $atk_date = intval($atk_arr[2]);
	                $atk_type = $atk_arr[3];
	                $threat_level = $atk_arr[4];
	                $country = $atk_arr[5];
	                $atk_ccflag = $this->sl_convert_country($country);

	                $atk_info = explode("~", $this->sl_attack_breakdown($atk_type));
	                $atk_color = $atk_info[0];
	                $why = $atk_info[1];
	                $atk_desc = $atk_info[2];

	                $atk_str = explode("#", $atk_type);
	                $atk_name = str_replace(" - id", "", $atk_str[0]);
	                if(substr_count($atk_str[1],' ')){
	                	$atk_typeid = @trim(reset(explode(' ',$atk_str[1])), '.');
					} else {
						$atk_typeid = trim($atk_str[1], '.');
					}
	                

	                $atk_dte = date("m/d/Y",$atk_date);
	                $atk_tme = date("H:i:s",$atk_date);

	                $str .= '                        <tr>'."\n";
	                $str .= '							 <td width="20px"><input value="'.$atk_id.'~'.$atk_ip.'" type="checkbox" name="selected_attacks[]" id="cbAttack_'.$i.'" /></td>'."\n";
	                $str .= '                            <td width="40px"><span style="color:'.$atk_color.'; font-weight: bold">'.$counter.'</span></td>'."\n";
	                $str .= '                            <td width="125px">'.(!empty($atk_ccflag) ? '<img src="'.$this->filepath.'/images/flags/'.$atk_ccflag.'" alt="'.$country.'" title="'.$country.'" />' : '').' <a href="#" onclick="sl_gateway.open(\'details\',\'&id='.$atk_id.'~'.$atk_ip.'\');return false;"><span style="color:#000; font-weight: bold"><acronym title="View details about '.$atk_ip.'">'.$atk_ip.'</acronym></span></a></td>'."\n";
	                $str .= '                            <td width="400px"><span style="color:'.$atk_color.'; font-weight: bold">'.$this->nicetrim($atk_name, 50).'</span></td>'."\n";
	                $str .= '                            <td width="125px"><span style="color:'.$atk_color.'; font-weight: bold">'.$atk_typeid.'</span></td>'."\n";
	                $str .= '                            <td width="125px" align="center"><acronym title="Threat: '.$threat_level.'">'.$this->LinkThreatLevel($threat_level).'</acronym></td>'."\n";
	                $str .= '                            <td width="100px"><span style="color:'.$atk_color.'; font-weight: bold">'.$atk_dte.'</span></td>'."\n";
	                $str .= '                            <td width="100px"><span style="color:'.$atk_color.'; font-weight: bold">'.$atk_tme.'</span></td>'."\n";
	                $str .= '                        </tr>'."\n";
	            }//  loop though query result to generate TRs
	            
	            $str .= '                        <tr>'."\n";
	            $str .= '                            <td colspan="7" align="right">'."\n";
	        	$str .= '                                  <input type="submit" name="sl_remove_selected" value="Remove Selected" class="submit" style="width: 135px; cursor: pointer; background-image: url(\''.$this->filepath.'/images/submit_long.png\');" onclick="sl_prompt=prompt(\'If you really want to remove this attack from the blacklist, type SECURELIVE in the box and press OK.\');return sl_prompt&&sl_prompt.toLowerCase()==\'securelive\'?true:false;">'."\n";
	            if($start+$length<$total){
	            	$str .= '                               '.($start-$length >= 0 ? '<a href="#" onclick="sl_gateway.open(\'attacklog\',\'&id='.($start-$length).'\');return false;">BACK</a>&nbsp;' : '').$this->sl_page_selector($start, $length, $total).'&nbsp;<a href="#" onclick="sl_gateway.open(\'attacklog\',\'&id='.($start+$length).'\');return false;">MORE</a></td>'."\n";
	            } elseif($start-$length>=0){
	            	$str .= '								<a href="#" onclick="sl_gateway.open(\'attacklog\',\'&id='.($start-$length).'\');return false;">BACK</a>&nbsp;'.$this->sl_page_selector($start, $length, $total)."\n";
	            }
	            $str .= '								</td>'."\n";
	            $str .= '							</tr>'."\n";
	            $str .= '                    </table>'."\n";
	            $str .= ' 			     </form>'."\n";
	            $str .= $this->EndModule();
	            $str .= '            <div style="clear:both;"></div>'."\n";
	            $str .= '        </div>'."\n";
	            $str .= '    </div>'."\n";
	            $str .= '    <div class="s5_w_modbl"></div>'."\n";
	            $str .= '    <div class="s5_w_modbm"></div>'."\n";
	            $str .= '    <div class="s5_w_modbr"></div>'."\n";
	            $str .= '    <div style="clear:both;"></div>'."\n";
	            $str .= '    <div class="s5_leftshadow" ></div>'."\n";
	            $str .= '    <div class="s5_rightshadow" ></div>'."\n";
	            $str .= '    <!-- End Adverts -->'."\n";
	            $str .= '    <div style="clear:both;"></div>'."\n";
	            $str .= '    <!-- Bottom Modules -->'."\n";
	            $str .= '        <div class="s5_wrap">'."\n";
	            $str .= '            <div class="s5_bblack_tl"></div>'."\n";
	            $str .= '            <div class="s5_bblack_tm"></div>'."\n";
	            $str .= '            <div class="s5_bblack_tr"></div>'."\n";
	            $str .= '            <div style="clear:both;"></div>'."\n";
	            $str .= '            <div class="s5_bblack_outter">'."\n";
	            $str .= '                <div class="s5_backmiddlemiddle" style="padding-left:8px;">'."\n";
	            $str .= $this->ModuleStart("1", "100", "", "Information Section", "user", FALSE);
	            $str .= '            <span style="color: #fff; font-weight: bold;">NOTE</span><sup style="color: #ff0000; font-weight: bold;">*</sup> Click on the IP Address to see more detailed information about the attack<br /><br />'."\n";
	            $str .= '			 <div style="margin-bottom: 10px;">'."\n";
	            $str .= '				<table>'."\n";
	            $str .= '					<tbody>'."\n";
	            $str .= '						<tr>'."\n";
	            $str .= '							<td>'."\n";
	            $str .= '			 					<form id="frmIpSearch" style="clear: none;" method="POST" action="#" onsubmit="sl_gateway.open(\'attacklog\',this);return false;">'."\n";
	            $str .= '			 						<div style="clear: none;">Find Attacks By IP:</div>'."\n";
	            $str .= '			 						<input type="text" id="sl_IpSearch" name="IpSearch" value="" />'."\n";
	            $str .= '			 						<input type="submit" value="Search" />'."\n";
	            $str .= '			 					</form>'."\n";
	            $str .= '							</td>'."\n";
	            $str .= '							<td>'."\n";
	            $str .= '			 					<form id="frmIpRemove" style="clear: none;" margin-left: 8px;" method="POST" action="#" onsubmit="sl_prompt=prompt(\'If you really want to remove all instances of this IP, type SECURELIVE in the box and press OK.\');if(!sl_prompt||sl_prompt.toLowerCase()!=\'securelive\'){return false;};sl_gateway.open(\'attacklog\',this);return false;">'."\n";
	            $str .= '							 		<div style="clear: none;">Remove Attacks By IP:</div>'."\n";
	            $str .= '							 		<input type="text" id="sl_IpRemove" name="IpRemove" value="" />'."\n";
	            $str .= '							 		<input type="submit" value="Remove" />'."\n";
	            $str .= '							 	</form>'."\n";
	            $str .= '							</td>'."\n";
	            $str .= '						</tr>'."\n";
	            $str .= '					</tbody>'."\n";
	            $str .= '				</table>'."\n";
	            
	            
	            
	            $str .= '			 </div>'."\n";
	            $str .= $this->EndModule();
	            $str .= '                        <div style="clear:both;"></div>'."\n";
	            $str .= '                    </div>'."\n";
	            $str .= '                </div>'."\n";
	            $str .= '                <div class="s5_bblack_bl"></div>'."\n";
	            $str .= '                <div class="s5_bblack_bm"></div>'."\n";
	            $str .= '                <div class="s5_bblack_br"></div>'."\n";
	            $str .= '                <div style="clear:both;"></div>'."\n";
	            $str .= '                <div class="s5_leftshadow"></div>'."\n";
	            $str .= '                <div class="s5_rightshadow"></div>'."\n";
	            $str .= '            </div>'."\n";
	            $str .= '            <!-- End Bottom Modules -->'."\n";
	            $str .= '            <div style="clear:both;"></div>'."\n";
            }
            //Export
            {
            	if(isset($_POST['export_log'])){
					//Create file...
					$tmpFile = dirname(__FILE__)."/attack_log.php";
					if(file_exists($tmpFile))
						unlink($tmpFile);
            		$f_handel = fOpen($tmpFile,"w");
            		$writeBlock = "<?php
            				header(\"Content-type: application/octet-stream\");
            				header(\"Content-Disposition: attachment; filename=attack_log.csv\");
            			?>#ID,#IP,#Unix Time,#Real Time,#Reason,#Threat,#Country\n";

            		//Loop...
		            for($i = 2; $i < count($retData) -1; $i++){
		            	
		            	$parts = explode("~",$retData[$i]);
		            	
		            	$line = "";
		            	for($pi = 0; $pi < count($parts); $pi++){
		            		$line .= str_replace(",",".",$parts[$pi]).",";
		            		
		            		if($pi == 2){
		            			$line .= str_replace(",",".", date("r", $parts[$pi])).",";	
							}
						}
		            	
		            	$writeBlock .= trim(rtrim($line,","))."\n";
		            	//$writeBlock .= str_replace("~",",", str_replace(",", " ", $retData[$i]))."\n";
					}
					$writeBlock .= "<?php @unlink(__FILE__); ?>";
            		fwrite($f_handel, $writeBlock);
					fClose($f_handel);

					//Java start download
					$dir = $this->sl_get_path()."/attack_log.php";
					$str .= '
						<script type="text/javascript">
							window.open("'.$dir.'");
						</script>
					';
				}
			}
			return "DONE*sl^module#message*$str";
		}
Example #29
0
 function getSize($lpszFileName, &$width, &$height)
 {
     if (!($fh = @fOpen($lpszFileName, "rb"))) {
         return false;
     }
     $data = @fRead($fh, @fileSize($lpszFileName));
     @fClose($fh);
     $gfh = new CGIFFILEHEADER();
     if (!$gfh->load($data, $len = 0)) {
         return false;
     }
     $width = $gfh->m_nWidth;
     $height = $gfh->m_nHeight;
     return true;
 }
Example #30
0
 public function ami_logout()
 {
     if (!$this->_check_socket()) {
         return false;
     }
     $data = $this->ami_send_command('Action: Logoff' . "\r\n\r\n");
     if (strToLower($data['Response']) === 'goodbye') {
         fClose($this->_socket);
         return true;
     } else {
         return false;
     }
 }