public function start()
 {
     $this->delimiter = "\t";
     //datei oeffnen mit fopen und Parameter w fuer Write mit Dateianlegen
     $this->DumpFileA = fOpen($this->FileNameA, "a");
     $this->DumpFileB = fOpen($this->FileNameB, "a");
 }
Example #2
0
 public function start($language)
 {
     $this->language = $language;
     $this->counter = 0;
     $this->FileName = "TEIL 2 properties_{$language}.sql";
     $this->DumpFile = fOpen($this->FileName, "w");
 }
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
File: util.php Project: rkania/GS3
function gs_write_error($data)
{
    if (!defined('STDERR')) {
        define('STDERR', @fOpen('php://stderr', 'wb'));
    }
    if (php_sapi_name() === 'cli' && STDERR) {
        @fWrite(STDERR, $data, strLen($data));
        @fFlush(STDERR);
    } else {
        echo $data;
    }
}
Example #5
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);
     }
 }
 /**
  * @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);
 }
function gs_hylafax_authfile_create($authfile)
{
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get user list
    #
    $rs = $db->execute('SELECT `id`, `user`, `pin`
FROM `users`
WHERE `nobody_index` IS NULL
ORDER BY `id`');
    if (!$rs) {
        return new GsError('Error.');
    }
    # create temporary hylafax host/user authentication file
    #
    if (file_exists($authfile) && !is_writable($authfile)) {
        @exec('sudo rm -f ' . qsa($authfile) . ' 2>>/dev/null');
    }
    $fh = @fOpen($authfile, 'w');
    if (!$fh) {
        return new GsError('Failed to open HylaFax authfile.');
    }
    # create localhost access without authentication first, if enabled
    #
    if (gs_get_conf('GS_FAX_NOAUTH_LOCALHOST') === true) {
        fWrite($fh, "127.0.0.1\n", strLen("127.0.0.1\n"));
    }
    # create admin entry first
    #
    if (gs_get_conf('GS_FAX_HYLAFAX_ADMIN') != '') {
        $crypted = crypt(gs_get_conf('GS_FAX_HYLAFAX_PASS'), 'pF');
        $user_entry = '^' . preg_quote(gs_get_conf('GS_FAX_HYLAFAX_ADMIN')) . '@:' . '0' . ':' . $crypted . ':' . $crypted . "\n";
        fWrite($fh, $user_entry, strLen($user_entry));
    }
    # create user entries
    #
    while ($user = $rs->fetchRow()) {
        $crypted = crypt($user['pin'], 'ml');
        $user_entry = '^' . preg_quote($user['user']) . '@:' . $user['id'] . ':' . $crypted . "\n";
        fWrite($fh, $user_entry, strLen($user_entry));
    }
    # close file
    #
    if (@fclose($fh)) {
        return true;
    } else {
        return new GsError('Error.');
    }
}
Example #8
0
 /**
  * My prompt func because realine is not default module
  */
 public function ask($string, $length = 1024)
 {
     static $tty;
     if (!isset($tty)) {
         if (substr(PHP_OS, 0, 3) == "WIN") {
             $tty = fOpen("\\con", "rb");
         } else {
             if (!($tty = fOpen("/dev/tty", "r"))) {
                 $tty = fOpen("php://stdin", "r");
             }
         }
     }
     echo $string;
     $result = trim(fGets($tty, $length));
     return $result;
 }
Example #9
0
function makeImgMovie($imgFile)
{
    //Make sure this file is an actual jpg file
    if (is_file($imgFile) && ereg("\\.jpg\$", $imgFile)) {
        //Launch Flash
        $movie = new swfMovie();
        $movie->setBackground(255, 255, 255);
        //Import a bitmap
        $b = new SWFBitmap(fOpen($imgFile, "rb"));
        //Get it's width and height
        $w = $b->getWidth();
        $h = $b->getHeight();
        //Make stage as big as the width and height of our bitmap
        $movie->setDimension($w, $h);
        //Convert Bitmap to a shape for Flash.
        //This process is automated upon import in Flash, but with
        //Ming we have have to do it ourselves. I see it as more control:)
        $s = new SWFShape();
        $f = $s->addFill($b);
        $s->setRightFill($f);
        //draw corners for the bitmap shape
        $s->drawLine($w, 0);
        $s->drawLine(0, $h);
        $s->drawLine(-$w, 0);
        $s->drawLine(0, -$h);
        //CreateEmptyMovieclip
        $p = new SWFSprite();
        //add our bitmap shape to this movieclip
        $p->add($s);
        $p->nextFrame();
        //Add this movieclip to our main movie's timeline
        //Much like dragging a symbol from the library in Flash.
        $i = $movie->add($p);
        //Give this instance a name.. let's call it mImg as in movie image
        $i->setName("mImg");
        //Output the movie.. Ctrl+Enter!
        // header("Content-Type:application/x-shockwave-flash");
        $movie->output();
    }
    //End if
}
                    echo 'Error.';
                } else {
                    @($_SESSION['sudo_user']['pb-csv-file'] = $filename);
                    $action = 'preview';
                }
            }
        }
    }
}
if ($action === 'preview' || $action === 'import') {
    if (!@array_key_exists('pb-csv-file', @$_SESSION['sudo_user']) || !is_file(@$_SESSION['sudo_user']['pb-csv-file'])) {
        $action = '';
    } else {
        $rem_old_entries = (bool) @$_REQUEST['rem_old_entries'];
        $file = @$_SESSION['sudo_user']['pb-csv-file'];
        $fh = @fOpen($file, 'rb');
        if (!$fh) {
            echo 'Could not read file.';
        } else {
            if (@array_key_exists('sep', @$_REQUEST) && @array_key_exists('encl', @$_REQUEST) && @array_key_exists('enc', @$_REQUEST)) {
                $sep = @$_REQUEST['sep'];
                $encl = @$_REQUEST['encl'];
                $enc = @$_REQUEST['enc'];
            } else {
                # try to guess separator
                $line = @fGets($fh);
                @rewind($fh);
                $cnt = array();
                $cnt['s'] = (int) preg_match_all('/;/', $line, $m);
                $cnt['c'] = (int) preg_match_all('/,/', $line, $m);
                $cnt['t'] = (int) preg_match_all('/\\t/', $line, $m);
Example #11
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 #12
0
    if (!$cidnum) {
        $callerid = $firstname_abbr . $user['lastname'] . ' <' . $from_num_effective . '>';
    } else {
        $callerid = $firstname_abbr . $user['lastname'] . ' <' . ($cidnum ? $cidnum : $from_num_effective) . '>';
    }
} else {
    $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 {
 /**
  * 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);
         }
     }
 }
 public function start()
 {
     $this->DumpFile = fOpen($this->FileName, "a");
 }
Example #15
0
function gs_callwaiting_activate($user, $active)
{
    if (!preg_match('/^[a-z0-9\\-_.]+$/', $user)) {
        return new GsError('User must be alphanumeric.');
    }
    $active = !!$active;
    # 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 `s`.`name` `ext`
FROM
	`users` `u` JOIN
	`ast_sipfriends` `s` ON (`s`.`_user_id`=`u`.`id`)
WHERE `u`.`user`=\'' . $db->escape($user) . '\'');
    if (!$user_ext) {
        return new GsError('Unknown user.');
    }
    # (de)activate
    #
    $num = $db->executeGetOne('SELECT COUNT(*) FROM `callwaiting` WHERE `user_id`=' . $user_id);
    if ($num < 1) {
        $ok = $db->execute('INSERT INTO `callwaiting` (`user_id`, `active`) VALUES (' . $user_id . ', 0)');
    } else {
        $ok = true;
    }
    $ok = $ok && $db->execute('UPDATE `callwaiting` SET `active`=' . (int) $active . ' WHERE `user_id`=' . $user_id);
    if (!$ok) {
        return new GsError('Failed to set call waiting.');
    }
    $call = "Channel: local/toggle@toggle-cwait-hint\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: toggle-cwait-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";
    $filename = '/tmp/gs-' . $user_id . '-' . time() . '-' . rand(10000, 99999) . '.call';
    $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.');
        }
    }
    # reload phone config
    #
    //$user_name = $db->executeGetOne( 'SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`='. $user_id );
    //@ exec( 'asterisk -rx \'sip notify snom-reboot '. $user_name .'\'' );
    //@ gs_prov_phone_checkcfg_by_user( $user, false ); //FIXME
    return true;
}
Example #16
0
<?php

set_time_limit(0);
$command = "/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print \$1}'";
$localIP = exec($command);
echo $localIP;
$socket = stream_socket_server("tcp://{$localIP}" . ':8080', $errorNumber, $errorString);
if (!$socket) {
    echo "{$errorNumber} ({$errorString})<br />\n";
} else {
    while ($conn = stream_socket_accept($socket)) {
        $logFile = fOpen('logFile.txt', 'a');
        echo $socket;
        $input = fread($conn, 1024);
        echo gettype($input);
        logFileAppend($input, $logFile);
        handleIncomingTraffic($input, $conn);
        //print_r($input);
        fwrite($conn, '<html><body>hello</body></html>');
        //fclose($conn);
    }
    fclose($socket);
}
function handleIncomingTraffic($HttpRequest, $connection)
{
    if (strpos($HttpRequest, 'addToBotNet') != 0) {
        echo 'added to botnet';
        checkFingerPrint();
    } else {
        fwrite($connection, "200 OK HTTP/1.1\r\n" . "Connection: close\r\n" . "Content-Type: text/html\r\n" . "\r\n" . "<html><body>Hello World!</html> ");
        echo 'other';
 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);
     }
 }
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 #19
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 #20
0
function shReadFile($shFileName, $asString = false)
{
    $ret = array();
    if (is_readable($shFileName)) {
        $shFile = fOpen($shFileName, 'r');
        do {
            $shRead = fgets($shFile, 1024);
            if (!empty($shRead) && JString::substr($shRead, 0, 1) != '#') {
                $ret[] = JString::trim(stripslashes($shRead));
            }
        } while (!feof($shFile));
        fclose($shFile);
    }
    if ($asString) {
        $ret = implode("\n", $ret);
    }
    return $ret;
}
Example #21
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>";
    }
}
Example #22
0
    set_magic_quotes_runtime(0);
}
//set_include_path('.');
set_time_limit(65);
# STDIN, STDOUT, STDERR
#
# http://bugs.php.net/bug.php?id=43283
# http://bugs.centos.org/view.php?id=1633
if (!defined('STDIN')) {
    define('STDIN', @fOpen('php://stdin', 'rb'));
}
if (!defined('STDOUT')) {
    define('STDOUT', @fOpen('php://stdout', 'wb'));
}
if (!defined('STDERR')) {
    define('STDERR', @fOpen('php://stderr', 'wb'));
}
# our root directory
#
define('GS_DIR', realPath(dirName(__FILE__) . '/../') . '/');
# DO NOT CHANGE!
# log levels
#
define('GS_LOG_FATAL', 1 << 1);
# SYSTEM CONSTANTS. DO NOT CHANGE!
define('GS_LOG_WARNING', 1 << 2);
#  "
define('GS_LOG_NOTICE', 1 << 3);
#  "
define('GS_LOG_DEBUG', 1 << 4);
#  "
Example #23
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 #24
0
 /**
  *	@Description: Gets a line from standard input
  *	@param	len		Int		The number of characters that should be read from standard in (if 0, keep going until EOF)
  *	@return			String	Info from standar input
  */
 function readInput($len = 0)
 {
     $f = fOpen('php://stdin', 'r');
     $result = null;
     while (!fEOF($f)) {
         if ((int) $len && strLen($result) > $len) {
             break;
         } else {
             $result .= fGetc($f);
         }
     }
     fClose($f);
     return $result;
 }
            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 #26
0
$figlet = 'figlet -f slant ';
//toilet -f mono12  Linux
$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);
 public function start()
 {
     //datei �ffnen mit fopen und Parameter w f�r Write mit Dateianlegen
     $this->DumpFile = fOpen($this->FileName, "a");
 }
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
        $handler = fOpen("/srv/bind/" . $zone['soa']['origin'] . "db", "a+");
        fWrite($handler, $out);
        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") {