Example #1
0
function angkatan_name($a){
	if(is_array($a)) 
		$b=$a['angkatan'];
	else 
		$b=$a;
	return dbFetch("angkatan","aka_angkatan","W/replid='$b'");
}
Example #2
0
function setUser($user_id_md5)
{
    global $user;
    global $cfg;
    global $season;
    unsetUser($user);
    $user_id_md5 = stripslashes($user_id_md5);
    list($id_user, $md5_password) = unserialize($user_id_md5);
    if ($id_user != "") {
        $users_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}users` WHERE `id` = {$id_user}");
        if ($users_row = dbFetch($users_ref) and $md5_password == md5($users_row['password'])) {
            $user['uid'] = $users_row['id'];
            $user['username'] = $users_row['username'];
            if (!isset($season)) {
                $season_users_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}season_users` " . "WHERE `id_user` = {$users_row['id']} AND `id_season` = 0");
            } else {
                $season_users_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}season_users` " . "WHERE `id_user` = {$users_row['id']} AND (`id_season` = 0 OR `id_season` = {$season['id']})");
            }
            while ($season_users_row = dbFetch($season_users_ref)) {
                if ($season_users_row['usertype_root'] == 1) {
                    $user['usertype_root'] = $season_users_row['usertype_root'];
                }
                if ($season_users_row['usertype_headadmin'] == 1) {
                    $user['usertype_headadmin'] = $season_users_row['usertype_headadmin'];
                }
                if ($season_users_row['usertype_admin'] == 1) {
                    $user['usertype_admin'] = $season_users_row['usertype_admin'];
                }
                if ($season_users_row['usertype_player'] == 1) {
                    $user['usertype_player'] = $season_users_row['usertype_player'];
                }
            }
        }
    }
}
Example #3
0
function tahunajaran_name($a)
{
    if (is_array($a)) {
        $a = $a['tahunajaran'];
    }
    return dbFetch("tahunajaran", "aka_tahunajaran", "W/replid='{$a}'");
}
Example #4
0
function MstrGetReminder($a, $b)
{
    if (intval($b) == 0) {
        return 0;
    } else {
        return intval(dbFetch("reminder", "mstr_" . $a, "W/dcid='{$b}'"));
    }
}
Example #5
0
function departemen_name($a)
{
    if (is_array($a)) {
        $b = $a['departemen'];
    } else {
        $b = $a;
    }
    return dbFetch("nama", "departemen", "W/replid='{$b}'");
}
Example #6
0
function kategorirek_name($a)
{
    if (is_array($a)) {
        $b = $a['kategorirek'];
    } else {
        $b = $a;
    }
    return dbFetch("nama", "keu_kategorirek", "W/replid='{$b}'");
}
Example #7
0
function angkatan_name($a)
{
    if (is_array($a)) {
        $b = $a['angkatan'];
    } else {
        $b = $a;
    }
    return dbFetch("angkatan", "aka_angkatan", "W/replid='{$b}'");
}
Example #8
0
 public function groupList($params = array())
 {
     $CI =& get_instance();
     extract($params);
     logConfig('altoDriver_group|action:list', 'logAlto');
     $sql = "select group_id, group_name, group_type, group_detail from gun_groups order by group_name asc";
     logConfig('altoDriver_group|sql:' . $sql, 'logAlto');
     $data0 = dbFetch($sql);
     //====clean
     $groups = array();
     foreach ($data0 as $arr) {
         $groups[] = dbCleanField($arr, 'group_');
     }
     $data = array('total' => $CI->group->total(), 'group' => $groups);
     return array('code' => 9, 'data' => $data);
 }
Example #9
0
function dbFetchAll($id, $name)
{
    $data = array();
    $title = dbquery("SELECT * from titles left join templates on titles.template=templates.id where titles.id='{$id}'  ");
    $result = mysql_fetch_array($title);
    $templateXML = fopen($result["path"], "r");
    $contents = stream_get_contents($templateXML);
    $xml = new SimpleXMLElement($contents);
    foreach ($xml->geo->children() as $geo) {
        if ($geo["name"] == $name) {
            $data = dbFetch($id, $geo);
        }
    }
    foreach ($xml->overlay->children() as $geo) {
        if ($geo["name"] == $name) {
            $data = dbFetch($id, $geo);
        }
    }
    return $data;
}
Example #10
0
    echo "-i <instances> -n <number>                   Poll as instance <number> of <instances>\n";
    echo "                                             Instances start at 0. 0-3 for -n 4\n\n";
    echo "\n";
    echo "Debugging and testing options:\n";
    echo "-d                                           Enable debugging output\n";
    echo "-m                                           Specify single module to be run\n";
    echo "\n";
    echo "Invalid arguments!\n";
    exit;
}
include "includes/sql-schema/update.php";
$discovered_devices = 0;
if ($config['distributed_poller'] === TRUE) {
    $where .= " AND poller_group IN(" . $config['distributed_poller_group'] . ")";
}
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 {$where} ORDER BY device_id DESC") as $device) {
    discover_device($device, $options);
}
$end = utime();
$run = $end - $start;
$proctime = substr($run, 0, 5);
if ($discovered_devices) {
    dbInsert(array('type' => 'discover', 'doing' => $doing, 'start' => $start, 'duration' => $proctime, 'devices' => $discovered_devices), 'perf_times');
}
$string = $argv[0] . " {$doing} " . date($config['dateformat']['compact']) . " - {$discovered_devices} devices discovered in {$proctime} secs";
if ($debug) {
    echo "{$string}\n";
}
if ($options['h'] != "new" && $config['version_check']) {
    include "includes/versioncheck.inc.php";
}
Example #11
0
function app_form_gpost()
{
    $s = array();
    $a = func_get_args();
    $n = count($a);
    for ($i = 0; $i < $n; $i++) {
        if ($a[$i] == 'photo') {
            // upload foto
            $id = gpost('photo');
            if ($id != '') {
                if (intval($id) != 0) {
                    $p = dbFetch("photo", "tmp_photo", "W/replid='{$id}'") . "'";
                    dbDel("tmp_photo", "replid='{$id}'");
                    $s['photo'] = $p;
                } else {
                    $s['photo'] = '';
                }
            }
        } else {
            //selain foto
            $s[$a[$i]] = gpost($a[$i]);
        }
    }
    return $s;
}
Example #12
0
function dbFetchKeyValue($sql, $parameters = array(), $nocache = false)
{
    $data = array();
    foreach (dbFetch($sql, $parameters, $nocache) as $row) {
        $key = array_shift($row);
        if (sizeof($row) == 1) {
            // if there were only 2 fields in the result
            // use the second for the value
            $data[$key] = array_shift($row);
        } else {
            // if more than 2 fields were fetched
            // use the array of the rest as the value
            $data[$key] = $row;
        }
    }
    return $data;
}
Example #13
0
if (isset($vars['format']) && preg_match("/^[a-z]*\$/", $vars['format'])) {
    #  $map = 'digraph G { bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=LR
    $map = 'digraph G { bgcolor=transparent; splines=true; overlap=scale; rankdir=LR
     node [ fontname="helvetica", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false];
     edge [ bgcolor=white, fontname="helvetica", fontstyle=bold, arrowhead=dot, arrowtail=dot];
     graph [bgcolor=transparent;];

';
    if (!$_SESSION['authenticated']) {
        $map .= "\"没有经过身份验证\" [fontsize=20 fillcolor=\"lightblue\", URL=\"/\" shape=box3d]\n";
    } else {
        $loc_count = 1;
        $cache['where']['devices_permitted'] = generate_query_permitted(array('device'), array('device_table' => 'D'));
        foreach (dbFetch("SELECT D.*, COUNT(L.local_port_id) FROM devices AS D LEFT JOIN (ports AS I, links AS L) ON (D.device_id = I.device_id AND I.port_id = L.local_port_id) " . $where . $cache['where']['devices_permitted'] . " GROUP BY D.hostname ORDER BY COUNT(L.local_port_id) DESC") as $device) {
            if ($device) {
                $links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_port_id = I.port_id ORDER BY L.remote_hostname", array($device['device_id']));
                if (count($links)) {
                    $ranktype = substr($device['hostname'], 0, 2);
                    $ranktype2 = substr($device['hostname'], 0, 3);
                    if (!strncmp($device['hostname'], "c", 1) && !strstr($device['hostname'], "kalooga")) {
                        $ranks[$ranktype][] = $device['hostname'];
                    } else {
                        $ranks[$ranktype2][] = $device['hostname'];
                    }
                    if ($anon) {
                        $device['hostname'] = md5($device['hostname']);
                    }
                    if (!isset($locations[$device['location']])) {
                        $locations[$device['location']] = $loc_count;
                        $loc_count++;
                    }
Example #14
0
function poll_device($device, $options)
{
    global $config, $device, $polled_devices, $db_stats, $memcache;
    $attribs = get_dev_attribs($device['device_id']);
    $status = 0;
    unset($array);
    $device_start = utime();
    // Start counting device poll time
    echo $device['hostname'] . ' ' . $device['device_id'] . ' ' . $device['os'] . ' ';
    if ($config['os'][$device['os']]['group']) {
        $device['os_group'] = $config['os'][$device['os']]['group'];
        echo '(' . $device['os_group'] . ')';
    }
    echo "\n";
    unset($poll_update);
    unset($poll_update_query);
    unset($poll_separator);
    $poll_update_array = array();
    $update_array = array();
    $host_rrd = $config['rrd_dir'] . '/' . $device['hostname'];
    if (!is_dir($host_rrd)) {
        mkdir($host_rrd);
        echo "Created directory : {$host_rrd}\n";
    }
    $address_family = snmpTransportToAddressFamily($device['transport']);
    $ping_response = isPingable($device['hostname'], $address_family, $attribs);
    $device_perf = $ping_response['db'];
    $device_perf['device_id'] = $device['device_id'];
    $device_perf['timestamp'] = array('NOW()');
    if (can_ping_device($attribs) === true && is_array($device_perf)) {
        dbInsert($device_perf, 'device_perf');
    }
    $device['pingable'] = $ping_response['result'];
    $ping_time = $ping_response['last_ping_timetaken'];
    $response = array();
    $status_reason = '';
    if ($device['pingable']) {
        $device['snmpable'] = isSNMPable($device);
        if ($device['snmpable']) {
            $status = '1';
            $response['status_reason'] = '';
        } else {
            echo 'SNMP Unreachable';
            $status = '0';
            $response['status_reason'] = 'snmp';
        }
    } else {
        echo 'Unpingable';
        $status = '0';
        $response['status_reason'] = 'icmp';
    }
    if ($device['status'] != $status) {
        $poll_update .= $poll_separator . "`status` = '{$status}'";
        $poll_separator = ', ';
        dbUpdate(array('status' => $status, 'status_reason' => $response['status_reason']), 'devices', 'device_id=?', array($device['device_id']));
        dbInsert(array('importance' => '0', 'device_id' => $device['device_id'], 'message' => 'Device is ' . ($status == '1' ? 'up' : 'down')), 'alerts');
        log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device, $status == '1' ? 'up' : 'down');
    }
    if ($status == '1') {
        $graphs = array();
        $oldgraphs = array();
        if ($options['m']) {
            foreach (explode(',', $options['m']) as $module) {
                if (is_file('includes/polling/' . $module . '.inc.php')) {
                    include 'includes/polling/' . $module . '.inc.php';
                }
            }
        } else {
            foreach ($config['poller_modules'] as $module => $module_status) {
                if ($attribs['poll_' . $module] || $module_status && !isset($attribs['poll_' . $module])) {
                    // TODO per-module polling stats
                    include 'includes/polling/' . $module . '.inc.php';
                } else {
                    if (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] == '0') {
                        echo "Module [ {$module} ] disabled on host.\n";
                    } else {
                        echo "Module [ {$module} ] disabled globally.\n";
                    }
                }
            }
        }
        //end if
        if (!$options['m']) {
            // FIXME EVENTLOGGING -- MAKE IT SO WE DO THIS PER-MODULE?
            // This code cycles through the graphs already known in the database and the ones we've defined as being polled here
            // If there any don't match, they're added/deleted from the database.
            // Ideally we should hold graphs for xx days/weeks/polls so that we don't needlessly hide information.
            foreach (dbFetch('SELECT `graph` FROM `device_graphs` WHERE `device_id` = ?', array($device['device_id'])) as $graph) {
                if (isset($graphs[$graph['graph']])) {
                    $oldgraphs[$graph['graph']] = true;
                } else {
                    dbDelete('device_graphs', '`device_id` = ? AND `graph` = ?', array($device['device_id'], $graph['graph']));
                }
            }
            foreach ($graphs as $graph => $value) {
                if (!isset($oldgraphs[$graph])) {
                    echo '+';
                    dbInsert(array('device_id' => $device['device_id'], 'graph' => $graph), 'device_graphs');
                }
                echo $graph . ' ';
            }
        }
        //end if
        $device_end = utime();
        $device_run = $device_end - $device_start;
        $device_time = substr($device_run, 0, 5);
        // TODO: These should be easy converts to rrd_create_update()
        // Poller performance rrd
        $poller_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/poller-perf.rrd';
        if (!is_file($poller_rrd)) {
            rrdtool_create($poller_rrd, 'DS:poller:GAUGE:600:0:U ' . $config['rrd_rra']);
        }
        if (!empty($device_time)) {
            $fields = array('poller' => $device_time);
            rrdtool_update($poller_rrd, $fields);
        }
        // Ping response rrd
        if (can_ping_device($attribs) === true) {
            $ping_rrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/ping-perf.rrd';
            if (!is_file($ping_rrd)) {
                rrdtool_create($ping_rrd, 'DS:ping:GAUGE:600:0:65535 ' . $config['rrd_rra']);
            }
            if (!empty($ping_time)) {
                $fields = array('ping' => $ping_time);
                rrdtool_update($ping_rrd, $fields);
            }
            $update_array['last_ping'] = array('NOW()');
            $update_array['last_ping_timetaken'] = $ping_time;
        }
        $update_array['last_polled'] = array('NOW()');
        $update_array['last_polled_timetaken'] = $device_time;
        // echo("$device_end - $device_start; $device_time $device_run");
        echo "Polled in {$device_time} seconds\n";
        d_echo('Updating ' . $device['hostname'] . "\n");
        d_echo($update_array);
        $updated = dbUpdate($update_array, 'devices', '`device_id` = ?', array($device['device_id']));
        if ($updated) {
            echo "UPDATED!\n";
        }
        unset($storage_cache);
        // Clear cache of hrStorage ** MAYBE FIXME? **
        unset($cache);
        // Clear cache (unify all things here?)
    }
    //end if
}
Example #15
0
}
if (!$where) {
    print_message("%n\nUSAGE:\n{$scriptname} [-drqV] [-i instances] [-n number] [-m module] [-h device]\n\nEXAMPLE:\n-h <device id> | <device hostname wildcard>  Poll single device\n-h odd                                       Poll odd numbered devices  (same as -i 2 -n 0)\n-h even                                      Poll even numbered devices (same as -i 2 -n 1)\n-h all                                       Poll all devices\n-h new                                       Poll all devices that have not had a discovery run before\n\n-i <instances> -n <id/number>                Poll as instance <id/number> of <instances>\n                                             Instance numbers start at 0. 0-3 for -i 4\n                                             Example:\n                                               -i 4 -n 0\n                                               -i 4 -n 1\n                                               -i 4 -n 2\n                                               -i 4 -n 3\n\nOPTIONS:\n -h                                          Device hostname, id or key odd/even/all/new.\n -i                                          Poll instances count.\n -n                                          Instance id (number), must start from 0 and to be less than instances count.\n -q                                          Quiet output.\n -M                                          Show globally enabled/disabled modules and exit.\n -V                                          Show version and exit.\n\nDEBUGGING OPTIONS:\n -r                                          Do not create or update RRDs\n -d                                          Enable debugging output.\n -dd                                         More verbose debugging output.\n -m                                          Specify module(s) (separated by commas) to be run.\n\n%rInvalid arguments!%n", 'color', FALSE);
    exit;
}
if (isset($options['r'])) {
    $config['norrd'] = TRUE;
}
$cache['maint'] = cache_alert_maintenance();
rrdtool_pipe_open($rrd_process, $rrd_pipes);
print_cli_heading("%WStarting polling run at " . date("Y-m-d H:i:s"), 0);
$polled_devices = 0;
if (!isset($query)) {
    $query = "SELECT `device_id` FROM `devices` WHERE `disabled` = 0 {$where} ORDER BY `device_id` ASC";
}
foreach (dbFetch($query, $params) as $device) {
    $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
    poll_device($device, $options);
    $polled_devices++;
}
$poller_end = utime();
$poller_run = $poller_end - $poller_start;
$poller_time = substr($poller_run, 0, 5);
if ($polled_devices) {
    dbInsert(array('type' => 'poll', 'doing' => $doing, 'start' => $poller_start, 'duration' => $poller_time, 'devices' => $polled_devices), 'perf_times');
    if (is_numeric($doing)) {
        $doing = $device['hostname'];
    }
    // Single device ID convert to hostname for log
} else {
    print_warning("WARNING: 0 devices polled. Did you specify a device that does not exist?");
Example #16
0
 function setAsDelinquent()
 {
     $in['uRec'] = $this->uRec;
     $in['paymentDelinquent'] = 1;
     $sql = "SELECT * FROM stripeAuth WHERE uRec=" . $in['uRec'];
     $id = 0;
     if ($rc = dbQuery($sql)) {
         if ($row = dbFetch($rc)) {
             $id = $row["id"];
             $update = true;
         } else {
             $update = false;
         }
     } else {
         logit(WARN, " DB Error:  {$sql} in " . __FILE__ . " on line: " . __LINE__);
     }
     if ($update) {
         $sql = "UPDATE stripeAuth " . makeSql($in, "update") . " WHERE id={$id} ";
     } else {
         $sql = "INSERT INTO stripeAuth " . makeSql($in, "insert");
     }
     if ($rc = dbQuery($sql)) {
         logit(INFO, 'set customer as delinquent| sql: ' . $sql);
     } else {
         logit(WARN, " DB Error:  {$sql} in " . __FILE__ . " on line: " . __LINE__);
         return false;
     }
 }
Example #17
0
        $sR = dbFetch($id, $slantRectangle);
        slantRectangle($canvas, $sR["x"], $sR["y"], $sR["w"], $sR["h"], $sR["color"]);
    }
}
if ($xml->overlay->shadowText) {
    foreach ($xml->overlay->shadowText as $text) {
        $t = dbFetch($id, $text);
        shadowedText($canvas, $t["x"], $t["y"], $t["w"], $t["h"], $t["text"], $t["gravity"], $t["font"], $t["color"]);
    }
}
if ($xml->overlay->plainText) {
    foreach ($xml->overlay->plainText as $text) {
        $t = dbFetch($id, $text);
        plainText($canvas, $t["x"], $t["y"], $t["w"], $t["h"], $t["text"], $t["gravity"], $t["font"], $t["color"], true);
    }
}
if ($xml->overlay->placeImage) {
    foreach ($xml->overlay->placeImage as $image) {
        $l = dbFetch($id, $image);
        //print_r($l);
        placeImage($canvas, $l["x"], $l["y"], $l["w"], $l["h"], $l["path"]);
    }
}
header("Content-Type: image/png");
echo $canvas;
$thumb = $canvas->clone();
$thumb->cropImage(1440, 1080, 0, 0);
$thumb->resizeImage(53, 40, Imagick::FILTER_TRIANGLE, 1);
$thumb->writeImage('thumbs/' . $titleRow["filename"] . '.png');
$canvas->setImageDepth(8);
$canvas->writeImage('out/' . $titleRow["filename"] . '.png');
Example #18
0
     // Matchkey
     $content_tpl->set_var("I_BRACKET", htmlspecialchars($matches_row['bracket']));
     $content_tpl->set_var("I_ROUND", $matches_row['round']);
     $content_tpl->set_var("I_MATCH", $matches_row['match']);
     $content_tpl->set_var("I_ID_SEASON", $season['id']);
     $content_tpl->set_var("I_OPT", $id_match);
     $content_tpl->parse("H_ADD_REPORT", "B_ADD_REPORT");
 } else {
     if ($matches_row['id_player1'] == $user['uid']) {
         $player = "p1";
     } elseif ($matches_row['id_player2'] == $user['uid']) {
         $player = "p2";
     }
     $maps_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}maps` " . "WHERE `id_match` = {$matches_row['id']} ORDER BY `num_map` ASC");
     $comments = false;
     while ($maps_row = dbFetch($maps_ref)) {
         if ($maps_row["comment_{$player}"] == "") {
             $comments = true;
             $sshot_dir = "data/screenshots/{$season['id']}/";
             $sshot = $sshot_dir . "{$season['id']}-{$matches_row['bracket']}-{$matches_row['round']}-{$matches_row['match']}-m{$maps_row['num_map']}_thumb.jpg";
             $content_tpl->set_var("H_SCREENSHOT", "");
             if (file_exists($sshot)) {
                 $content_tpl->set_var("I_SCREENSHOT", htmlspecialchars($sshot));
                 $content_tpl->parse("H_SCREENSHOT", "B_SCREENSHOT");
             }
             $content_tpl->set_var("I_NUM_MAP", $maps_row['num_map']);
             $content_tpl->parse("H_COMMENT", "B_COMMENT", true);
         }
     }
     if (!$comments) {
         $content_tpl->parse("H_NO_COMMENT", "B_NO_COMMENT");
Example #19
0
function update_mib_graph_types($mibname, $oids, $mibdef, $graphs)
{
    $seengraphs = array();
    // Get the list of graphs currently in the database
    // FIXME: there's probably a more efficient way to do this
    foreach (dbFetch('SELECT DISTINCT `graph_subtype` FROM `graph_types` WHERE `graph_subtype` LIKE ?', array("{$mibname}-%")) as $graph) {
        $seengraphs[$graph['graph_subtype']] = true;
    }
    foreach ($oids as $index => $array) {
        $i = 1;
        foreach ($array as $oid => $val) {
            $graphname = "{$mibname}-" . $mibdef[$oid]['shortname'];
            // add the graph if it's not in the database already
            if ($graphs[$graphname] && !$seengraphs[$graphname]) {
                // construct a graph definition based on the MIB definition
                $graphdef = array();
                $graphdef['graph_type'] = 'device';
                $graphdef['graph_subtype'] = $graphname;
                $graphdef['graph_section'] = 'mib';
                $graphdef['graph_descr'] = $mibdef[$oid]['description'];
                $graphdef['graph_order'] = $i++;
                // TODO: add colours, unit_text, and ds
                // add graph to the database
                dbInsert($graphdef, 'graph_types');
            }
        }
    }
}
Example #20
0
function tahunbuku_name($a){
	return dbFetch("tahunbuku","keu_tahunbuku","W/replid='$a'");
}
Example #21
0
}
$dur = $end - $start;
$datefrom = date('Ymthis', $start);
$dateto = date('Ymthis', $end);
$dur = $end - $start;
$counttot = dbFetchCell('SELECT count(`delta`) FROM `bill_data` WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? )', array($bill_id, $start, $end));
$count = round($dur / 300 / (($ysize - 100) * 3), 0);
if ($count <= 1) {
    $count = 2;
}
// $count = round($counttot / 260, 0);
// if ($count <= 1) { $count = 2; }
// $max = dbFetchCell("SELECT delta FROM bill_data WHERE bill_id = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? ) ORDER BY delta DESC LIMIT 0,1", array($bill_id, $start, $end));
// if ($max > 1000000) { $div = "1000000"; $yaxis = "Mbit/sec";  } else { $div = "1000"; $yaxis = "Kbit/sec"; }
$i = '0';
foreach (dbFetch('SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bill_data WHERE bill_id = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? ) ORDER BY timestamp ASC', array($bill_id, $start, $end)) as $row) {
    $timestamp = $row['formatted_date'];
    if (!$first) {
        $first = $timestamp;
    }
    $delta = $row['delta'];
    $period = $row['period'];
    $in_delta = $row['in_delta'];
    $out_delta = $row['out_delta'];
    $in_value = delta_to_bits($in_delta, $period);
    $out_value = delta_to_bits($out_delta, $period);
    $last = $timestamp;
    $iter_in += $in_delta;
    $iter_out += $out_delta;
    $iter_period += $period;
    if ($iter == $count) {
            echo '<option value="' . $data['features'] . '"';
            if ($data['features'] == $vars['features']) {
                echo " selected";
            }
            echo ">" . $data['features'] . "</option>";
        }
    }
    ?>
        </select>

      </div>
      <div class="col-lg-2">
        <select class="selectpicker" name="type" id="type">
          <option value="">所有设备类型</option>
          <?php 
    foreach (dbFetch('SELECT `type` FROM `devices` AS D WHERE 1 ' . $where_form . ' GROUP BY `type` ORDER BY `type`') as $data) {
        if ($data['type']) {
            echo "<option value='" . $data['type'] . "'";
            if ($data['type'] == $vars['type']) {
                echo " selected";
            }
            echo ">" . ucfirst($data['type']) . "</option>";
        }
    }
    ?>
        </select>

      </div>
      <div class="col-lg-2 pull-right">
        <button type="submit" onClick="submitURL();" class="btn pull-right"><i class="icon-search"></i> 搜索</button>
      </div>
Example #23
0
 function portalLink($id)
 {
     //fb($url);
     //$ids=explode(",",$id);
     //foreach($id as $key->$value) $id[$key]=trim($value);
     $sql = "SELECT * FROM articles WHERE artId in ({$id}) ";
     if ($rc = dbQuery($sql)) {
         while ($row = dbFetch($rc)) {
             $url = articleUrl($row["artId"]);
             if ($url) {
                 if ($row["tipLong"]) {
                     $summary = $row["tipLong"];
                 } elseif ($row["tipShort"]) {
                     $summary = $row["tipShort"];
                 } elseif ($row["summary"]) {
                     $summary = $row["summary"];
                 }
                 $str .= "<p><a class='portalLink' href='{$url}'>{$row["headline"]}</a><br>\r\n\t\t\t\t\t\t<span class='portalText'>{$summary}</span></p>";
             }
         }
     }
     return $str;
 }
Example #24
0
         $inp[$v] = gpost($v);
     }
     if (dbInsert("book", $inp)) {
         echo "TBook information has been saved.";
     } else {
         echo 'F<span style="colo:#ff0000">Failed to save book information.</span>';
     }
 } else {
     if ($q == "addbook2") {
         $a = array('catalog', 'barcode', 'nid', 'callnumber', 'shelf', 'source', 'sourceval');
         $inp = array();
         foreach ($a as $k => $v) {
             $inp[$v] = gpost($v);
         }
         if (dbInsert("book", $inp)) {
             $tbl = dbFetch("ntable", "so_history", "W/status!=0");
             dbInsert($tbl, array('catalog' => $inp['catalog'], 'barcode' => $inp['barcode']));
             echo "TBook information has been saved.";
         } else {
             echo 'F<span style="colo:#ff0000">Failed to save book information.</span>';
         }
     } else {
         if ($q == "revbook") {
             $dcid = gpost('dcid');
             $a = array('catalog', 'barcode', 'nid', 'callnumber', 'shelf', 'source', 'sourceval');
             $inp = array();
             foreach ($a as $k => $v) {
                 $inp[$v] = gpost($v);
             }
             if (dbUpdate("book", $inp, "dcid='{$dcid}'")) {
                 echo "TBook information has been saved.";
function transferOverview($bill_id, $history)
{
    global $list_colour_a, $list_colour_b, $config;
    $i = 0;
    $tot = array();
    $traf = array();
    $start = $history['timestampfrom'];
    $end = $history['timestampto'];
    //$background= $history['background'];
    $res = "";
    $res .= "<table class=\"transferOverview\">";
    $res .= "  <tr bgcolor=\"#000\">";
    $res .= "    <th class=\"period\">Date</th>";
    $res .= "    <th class=\"inbound\">Inbound</th>";
    $res .= "    <th class=\"outbound\">Outbound</th>";
    $res .= "    <th class=\"total\">Total</th>";
    $res .= "  </tr>";
    foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data) {
        $date = strftime("%A, %e %B %Y", $data['timestamp']);
        $tot['in'] += gbConvert($data['traf_in']);
        $tot['out'] += gbConvert($data['traf_out']);
        $tot['tot'] += gbConvert($data['traf_total']);
        $traf['in'] = formatStorage(gbConvert($data['traf_in']), "3");
        $traf['out'] = formatStorage(gbConvert($data['traf_out']), "3");
        $traf['tot'] = formatStorage(gbConvert($data['traf_total']), "3");
        $row_colour = !is_integer($i / 2) ? $list_colour_a : $list_colour_b;
        $res .= "  <tr bgcolor=\"" . $row_colour . "\">";
        $res .= "    <td>" . $date . "</td>";
        $res .= "    <td class=\"right\">" . $traf['in'] . "</td>";
        $res .= "    <td class=\"right\">" . $traf['out'] . "</td>";
        $res .= "    <td class=\"right\">" . $traf['tot'] . "</td>";
        $res .= "  </tr>";
        $i++;
    }
    $tot['in'] = formatStorage($tot['in']);
    $tot['out'] = formatStorage($tot['out']);
    $tot['tot'] = formatStorage($tot['tot']);
    $res .= "  <tr bgcolor=\"#ccc\" style=\"border-top: 1px solid #000;\">";
    $res .= "    <td></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['in'] . "</b></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['out'] . "</b></td>";
    $res .= "    <td class=\"right\"><b>" . $tot['tot'] . "</b></td>";
    $res .= "  </tr>";
    $res .= "</table>";
    return $res;
}
Example #26
0
function tahunlulus_name($a){
	if(is_array($a))$a=$a['tahunlulus'];
	return dbFetch("nama","aka_tahunlulus","W/replid='$a'");
}
Example #27
0
function delete_device($id)
{
    global $config, $debug;
    $ret = '';
    $host = dbFetchCell("SELECT hostname FROM devices WHERE device_id = ?", array($id));
    if (empty($host)) {
        return "No such host.";
    }
    // Remove IPv4/IPv6 addresses before removing ports as they depend on port_id
    dbQuery("DELETE `ipv4_addresses` FROM `ipv4_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv4_addresses`.`port_id` WHERE `device_id`=?", array($id));
    dbQuery("DELETE `ipv6_addresses` FROM `ipv6_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv6_addresses`.`port_id` WHERE `device_id`=?", array($id));
    foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data) {
        $int_if = $int_data['ifDescr'];
        $int_id = $int_data['port_id'];
        delete_port($int_id);
        $ret .= "Removed interface {$int_id} ({$int_if})\n";
    }
    $fields = array('device_id', 'host');
    foreach ($fields as $field) {
        foreach (dbFetch("SELECT table_name FROM information_schema.columns WHERE table_schema = ? AND column_name = ?", array($config['db_name'], $field)) as $table) {
            $table = $table['table_name'];
            $entries = (int) dbDelete($table, "`{$field}` =  ?", array($id));
            if ($entries > 0 && $debug === true) {
                $ret .= "{$field}@{$table} = #{$entries}\n";
            }
        }
    }
    $ex = shell_exec("bash -c '( [ ! -d " . trim($config['rrd_dir']) . "/" . $host . " ] || rm -vrf " . trim($config['rrd_dir']) . "/" . $host . " 2>&1 ) && echo -n OK'");
    $tmp = explode("\n", $ex);
    if ($tmp[sizeof($tmp) - 1] != "OK") {
        $ret .= "Could not remove files:\n{$ex}\n";
    }
    $ret .= "Removed device {$host}\n";
    return $ret;
}
        if (!is_file($rrd)) {
            rrdtool_create($rrd, '--step 300 
     DS:inutil:GAUGE:600:0:100 
     DS:oututil:GAUGE:600:0:100 
     DS:outdropped:DERIVE:600:0:125000000000 
     DS:outerrors:DERIVE:600:0:125000000000 
     DS:inerrors:DERIVE:600:0:125000000000 ' . $config['rrd_rra']);
        }
        rrdtool_update($rrd, $fields);
    }
    //end foreach
    // print_r($entPhysical_state);
}
//end if
// Set Entity state
foreach (dbFetch('SELECT * FROM `entPhysical_state` WHERE `device_id` = ?', array($device['device_id'])) as $entity) {
    if (!isset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']])) {
        dbDelete('entPhysical_state', '`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?', array($device['device_id'], $entity['entPhysicalIndex'], $entity['subindex'], $entity['group'], $entity['key']));
    } else {
        if ($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']] != $entity['value']) {
            echo 'no match!';
        }
        unset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]);
    }
}
//end foreach
// End Set Entity Attrivs
// Delete Entity state
foreach ($entPhysical_state as $epi => $entity) {
    foreach ($entity as $subindex => $si) {
        foreach ($si as $group => $ti) {
Example #29
0
<?php

$content_tpl->set_block("F_CONTENT", "B_ADD_COUNTRY", "H_ADD_COUNTRY");
$content_tpl->set_block("F_CONTENT", "B_SIGNUP", "H_SIGNUP");
$content_tpl->set_block("F_CONTENT", "B_ADD_ACCOUNT", "H_ADD_ACCOUNT");
// Countries
$countries_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}countries` " . "WHERE `active` = 1 " . "ORDER BY `name` ASC");
while ($countries_row = dbFetch($countries_ref)) {
    $content_tpl->set_var("I_ID_COUNTRY", $countries_row['id']);
    $content_tpl->set_var("I_COUNTRY", htmlspecialchars($countries_row['name']));
    $content_tpl->parse("H_ADD_COUNTRY", "B_ADD_COUNTRY", true);
}
// Signup
if ($season['status'] == "signups") {
    $content_tpl->parse("H_SIGNUP", "B_SIGNUP");
}
$content_tpl->set_var("I_ID_SEASON", $season['id']);
$content_tpl->parse("H_ADD_ACCOUNT", "B_ADD_ACCOUNT");
Example #30
0
<?php

$content_tpl->set_block("F_CONTENT", "B_MESSAGE_NEWS_EDITED", "H_MESSAGE_NEWS_EDITED");
$content_tpl->set_block("F_CONTENT", "B_MESSAGE", "H_MESSAGE");
$content_tpl->set_block("F_CONTENT", "B_WARNING_HEADING", "H_WARNING_HEADING");
$content_tpl->set_block("F_CONTENT", "B_WARNING_BODY", "H_WARNING_BODY");
$content_tpl->set_block("F_CONTENT", "B_WARNING_NO_ACCESS", "H_WARNING_NO_ACCESS");
$content_tpl->set_block("F_CONTENT", "B_WARNING", "H_WARNING");
$content_tpl->set_block("F_CONTENT", "B_BACK", "H_BACK");
$content_tpl->set_block("F_CONTENT", "B_BACK_OVERVIEW", "H_BACK_OVERVIEW");
$id_news = intval($_REQUEST['opt']);
$news_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}news` WHERE `id` = {$id_news} AND `deleted` = 0");
$news_row = dbFetch($news_ref);
// Access for headadmins [public / private news]
// Access for admins [public / private news that they wrote themselves]
if ($user['usertype_headadmin'] or $user['uid'] == $news_row['id_user']) {
    $is_complete = 1;
    if ($_REQUEST['heading'] == "") {
        $is_complete = 0;
        $content_tpl->parse("H_WARNING_HEADING", "B_WARNING_HEADING");
    }
    if ($_REQUEST['body'] == "") {
        $is_complete = 0;
        $content_tpl->parse("H_WARNING_BODY", "B_WARNING_BODY");
    }
    if ($is_complete) {
        $heading = dbEscape($_REQUEST['heading']);
        $body = dbEscape($_REQUEST['body']);
        dbQuery("UPDATE `{$cfg['db_table_prefix']}news` " . "SET `heading` = '{$heading}', " . "`body` = '{$body}' " . "WHERE `id` = {$news_row['id']}");
        $content_tpl->parse("H_MESSAGE_NEWS_EDITED", "B_MESSAGE_NEWS_EDITED");
        $content_tpl->parse("H_MESSAGE", "B_MESSAGE");