function get_log_lines($host, $access_log_path, &$ret_lines)
{
    global $service_type, $log_date_str, $username, $password, $impr_resin_list;
    $local_file = DATA_DIR . $service_type . ".log." . $log_date_str;
    if (!file_exists($local_file)) {
        $cmd = get_cmd($host, $access_log_path);
        $exp_temp_file = "./query_log.exp.template";
        $exp_file = "query_log.exp";
        $file_content = file_get_contents($exp_temp_file);
        $file_content = str_replace('$current_file$', $exp_file, $file_content);
        $file_content = str_replace('$username$', $username, $file_content);
        $file_content = str_replace('$password$', $password, $file_content);
        $file_content = str_replace('$cmd$', $cmd, $file_content);
        file_put_contents($exp_file, $file_content);
        $cmd = "expect {$exp_file}";
        exec($cmd, $lines, $ret);
        $max_idx = count($lines) - 1;
        $message = $lines[$max_idx];
        if ($ret != 0 || substr($message, 0, 3) == "su:") {
            $ret = 1;
            return array($ret, $message);
        } else {
            // else-2
            $urls = array();
            $isImprResin = in_array($service_type, $impr_resin_list);
            foreach ($lines as $line) {
                $url = "";
                if ($isImprResin == true) {
                    preg_match("/GET (\\/imp\\/\\w+\\.s[^ ]*)/", $line, $matches);
                    if ($matches) {
                        $url = $matches[1];
                    }
                } else {
                    preg_match("/GET (\\/clk\\/\\w+\\.s[^ ]*)/", $line, $matches);
                    if ($matches) {
                        $url = $matches[1];
                    }
                }
                if ($url != "") {
                    array_push($urls, $url);
                }
            }
            // save result to file
            $file_str = implode("\n", $urls);
            file_put_contents($local_file, $file_str);
        }
        // end of else-2
    }
    // end of else-1
    // read from file
    foreach (file($local_file) as $line) {
        array_push($ret_lines, trim($line));
    }
    return array(0, "");
}
        $pattern[5] = "/sarg/";
        $replace[5] = 'cellspacing="0"';
        foreach ($sarg as $line) {
            if (preg_match("/<.head>/", $line)) {
                $print = "ok";
            }
            if ($print == "ok" && !preg_match("/(sarg realtime|Auto Refresh)/i", $line)) {
                print preg_replace($pattern, $replace, $line);
            }
        }
    }
}
if ($_REQUEST['cmd'] != "") {
    require_once "authgui.inc";
    require_once "functions.inc";
    get_cmd();
} else {
    require "guiconfig.inc";
    $pgtitle = "Status: Sarg Realtime";
    include "head.inc";
    ?>
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
	<?php 
    include "fbegin.inc";
    ?>

	<?php 
    if ($savemsg) {
        print_info_box($savemsg);
    }
    ?>
Exemple #3
0
function process_reply_cmd($cmdid)
{
    global $socket, $users, $channels, $quota_options;
    //variable to keep track of the command ID which is currently
    //being processed.
    $curcmdid = 0;
    //variable to keep track of whether the $cmdid parameter
    //succeeded.
    $success = FALSE;
    while (TRUE) {
        //BUG: Typically the TCP recv buffer is 8192 bytes so this
        //call will fail if the command is longer.
        $line = fgets($socket);
        //do a syntax check to ensure the reply is valid.
        $cmdline = get_cmdline($line);
        if (!$cmdline) {
            return FALSE;
        }
        //extract the command name
        $cmd = get_cmd($cmdline);
        if (!$cmd) {
            return FALSE;
        }
        //process the command
        switch ($cmd) {
            case 'teamtalk':
                //welcome command (the first message when we connect
                $userid = get_int($cmdline, 'userid');
                if ($userid) {
                    echo "Got user ID# {$userid}\r\n";
                }
                $servername = get_str($cmdline, 'servername');
                echo "Server name is: " . $servername . "\r\n";
                $usertimeout = get_int($cmdline, 'usertimeout');
                if ($usertimeout) {
                    echo "Your session will time out in {$usertimeout} seconds\r\n";
                }
                break;
            case 'begin':
                //A reply to a command ID is starting.
                $curcmdid = get_int($cmdline, 'id');
                break;
            case 'end':
                //A reply to a command ID ended.
                if (get_int($cmdline, 'id') == $cmdid) {
                    return $success;
                } else {
                    $curcmdid = 0;
                }
                break;
            case 'error':
                //a command failed. We check if it's the one we're waiting
                //for.
                echo $cmdline;
                /*             if($curcmdid == $cmdid) */
                /*                 $success = FALSE; */
                break;
            case 'ok':
                //a command succeeded. We check if it's the one we're
                //waiting for.
                if ($curcmdid == $cmdid) {
                    $success = TRUE;
                }
                break;
            case 'accepted':
                if ((get_int($cmdline, 'usertype') & 2) == 0) {
                    echo "The user account for login must be an administrator account\r\n";
                    exit(1);
                }
                echo "Log in successful!\r\n";
                break;
            case 'loggedin':
            case 'adduser':
            case 'updateuser':
                $id = get_int($cmdline, 'userid');
                $users[$id]['userid'] = $id;
                $users[$id]['nickname'] = get_str($cmdline, 'nickname');
                $users[$id]['ipaddr'] = get_str($cmdline, 'ipaddr');
                $users[$id]['chanid'] = get_int($cmdline, 'chanid');
                $users[$id]['channelpath'] = getchannelpath($users[$id]['chanid']);
                $users[$id]['username'] = get_str($cmdline, 'username');
                break;
            case 'removeuser':
                $id = get_int($cmdline, 'userid');
                unset($users[$id]['chanid']);
                unset($users[$id]['channelpath']);
                break;
            case 'loggedout':
                $id = get_int($cmdline, 'userid');
                unset($users[$id]);
                break;
            case 'addchannel':
            case 'updatechannel':
                $id = get_int($cmdline, 'chanid');
                $channels[$id]['chanid'] = $id;
                $name = get_str($cmdline, 'name');
                $channels[$id]['name'] = $name;
                $parentid = get_int($cmdline, 'parentid');
                if ($parentid) {
                    $channels[$id]['parentid'] = $parentid;
                }
                $topic = get_str($cmdline, 'topic');
                if ($topic) {
                    $channels[$id]['topic'] = $topic;
                }
                $passwd = get_str($cmdline, 'password');
                if ($passwd) {
                    $channels[$id]['password'] = $passwd;
                }
                $oppasswd = get_str($cmdline, 'oppassword');
                if ($oppasswd) {
                    $channels[$id]['oppassword'] = $oppasswd;
                }
                $audiocodec = get_list($cmdline, 'audiocodec');
                if ($audiocodec) {
                    $channels[$id]['audiocodec'] = $audiocodec;
                }
                $audioconfig = get_list($cmdline, 'audiocfg');
                if ($audioconfig) {
                    $channels[$id]['audioconfig'] = $audioconfig;
                }
                break;
            case 'removechannel':
                $id = get_str($cmdline, 'chanid');
                unset($channels[$id]);
                echo "Removed channel {$id}\r\n";
                break;
            case 'joined':
                $chanid = get_str($cmdline, 'chanid');
                echo "Joined channel " . getchannelpath($chanid) . "\r\n";
                break;
            case 'left':
                $chanid = get_str($cmdline, 'chanid');
                echo "Left channel " . getchannelpath($chanid) . "\r\n";
                break;
            case 'addfile':
            case 'removefile':
                break;
            case 'useraccount':
                echo $cmdline;
                break;
            case 'userbanned':
                echo $cmdline;
                break;
            case 'messagedeliver':
                break;
            case 'stats':
                $totaltx = get_int($cmdline, 'totaltx');
                $totalrx = get_int($cmdline, 'totalrx');
                $voicetx = get_int($cmdline, 'voicetx');
                $voicerx = get_int($cmdline, 'voicerx');
                $vidcaptx = get_int($cmdline, 'videocaptx');
                $vidcaprx = get_int($cmdline, 'videocaprx');
                $mediafiletx = get_int($cmdline, 'mediafiletx');
                $mediafilerx = get_int($cmdline, 'mediafilerx');
                echo "Server statistics.\r\n";
                echo "Total TX: " . $totaltx / 1024 . " KBytes\r\n";
                echo "Total RX: " . $totalrx / 1024 . " KBytes\r\n";
                echo "Voice TX: " . $voicetx / 1024 . " KBytes\r\n";
                echo "Voice RX: " . $voicerx / 1024 . " KBytes\r\n";
                echo "Video TX: " . $videocaptx / 1024 . " KBytes\r\n";
                echo "Video RX: " . $videocaprx / 1024 . " KBytes\r\n";
                echo "Media TX: " . $mediafiletx / 1024 . " KBytes\r\n";
                echo "Media RX: " . $mediafilerx / 1024 . " KBytes\r\n";
                break;
            case 'serverupdate':
                echo "Server updated...\r\n";
                $servername = get_str($cmdline, 'servername');
                echo "Server name is: " . $servername . "\r\n";
                $maxusers = get_int($cmdline, 'maxusers');
                echo "Max users on server: {$maxusers}\r\n";
                $usertimeout = get_int($cmdline, 'usertimeout');
                echo "User timeout: {$usertimeout} seconds\r\n";
                $motd = get_str($cmdline, "motd");
                echo "Server's MOTD is: {$motd}\r\n";
                break;
            case 'pong':
                $success = TRUE;
                break;
            default:
                echo 'Unhandled cmd: ' . $cmdline;
                break;
        }
        //stop processing now if we're not waiting for a command ID to
        //finish.
        if ($cmdid == 0) {
            return TRUE;
        }
    }
}
Exemple #4
0
<?php

require_once 'includes/config.php';
require_once 'includes/access.php';
require_once 'includes/todo.php';
if (isset($_GET['logout'])) {
    $_GET['logout'] == 'true' ? logout() : '';
}
$cmd = get_cmd($_POST);
$cmd2 = get_cmd($_POST, 'cmd2');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN">
<html>
<head>
        <meta http-equiv="Content-type" value="text/html; charset=utf-8">
		<title>todo.txt</title>

       <meta name="viewport" content="initial-scale=1.0,maximum-scale=1,user-scalable=0" />
        <?php 
if ($iphoneWebApp == 'yes') {
    ?>
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <?php 
}
?>
       <link rel="apple-touch-icon" href="todotxt_logo.png"/>

		<link media="screen" href="stylesheet.css" rel="stylesheet" type="text/css">
		<link media="handheld" href="handheld.css" rel="stylesheet" type="text/css">

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>