本文整理汇总了PHP中db_fetch_cell函数的典型用法代码示例。如果您正苦于以下问题:PHP db_fetch_cell函数的具体用法?PHP db_fetch_cell怎么用?PHP db_fetch_cell使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_fetch_cell函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ss_mikrotik_qusers_getvalue
function ss_mikrotik_qusers_getvalue($hostid, $index, $column)
{
global $config;
switch ($column) {
case "curBytesIn":
case "curBytesOut":
case "curPacketsIn":
case "curPacketsOut":
case "connectTime":
$value = db_fetch_cell("SELECT\n\t\t\t{$column} AS value\n\t\t\tFROM plugin_mikrotik_users\n\t\t\tWHERE (name='{$index}'\n\t\t\tAND host_id='{$hostid}')");
break;
case "avgBytesIn":
case "avgBytesOut":
case "avgPacketsIn":
case "avgPacketsOut":
$column = str_replace("avgB", "b", $column);
$column = str_replace("avgP", "p", $column);
$value = db_fetch_cell("SELECT\n\t\t\tIF(connectTime>0,({$column}/connectTime),0) AS value\n\t\t\tFROM plugin_mikrotik_users\n\t\t\tWHERE (name='{$index}'\n\t\t\tAND host_id='{$hostid}')");
break;
case "bytesIn":
case "bytesOut":
case "packetsIn":
case "packetsOut":
$value = db_fetch_cell("SELECT\n\t\t\t{$column} AS value\n\t\t\tFROM plugin_mikrotik_users\n\t\t\tWHERE (name='{$index}'\n\t\t\tAND host_id='{$hostid}')");
break;
}
if (!empty($value)) {
return $value;
} else {
return "0";
}
}
示例2: auth_control_data_save
/**
* Saves auth control data for a certain control id
*
* Saves auth control data for a certain control id
*
* @return 1 on success, 0 on error
*/
function auth_control_data_save($data, $category = "SYSTEM", $enable_user_edit = 0, $plugin_id = 0, $control_id = 0) {
/* Validate input */
if (!is_array($data)) {
return 0;
}
if (!is_numeric($enable_user_edit)) {
return 0;
}
if (($enable_user_edit < 0) || ($enable_user_edit > 1)) {
$enable_user_edit = 0;
}
if (!is_numeric($plugin_id)) {
return 0;
}
if (!is_numeric($control_id)) {
return 0;
}
if (empty($control_id)) {
$control_id = $_SESSION["sess_user_id"];
}
/* Create SQL Query */
$username = db_fetch_cell("SELECT username FROM user_auth WHERE id = " . $control_id, "username");
$sql = "REPLACE INTO `auth_data` (`control_id`,`plugin_id`,`category`,`name`,`value`,`enable_user_edit`,`updated_when`,`updated_by`) VALUES ";
foreach ($data as $name => $value) {
$sql .= "(" . $control_id . "," . $plugin_id . ",'" . $category . "','" . $name . "','" . $value . "'," . $enable_user_edit . ",NOW(),'" . $username . "'),";
}
$sql = substr($sql,0,strlen($sql) - 1);
/* Execute query and return */
return db_execute($sql);
}
示例3: upgrade_to_0_8_6i
function upgrade_to_0_8_6i() {
/* once again, larger fields for OID's and the like */
db_install_execute("0.8.6i", "ALTER TABLE `poller_item` MODIFY COLUMN `arg1` TEXT;");
db_install_execute("0.8.6i", "ALTER TABLE `poller_reindex` MODIFY COLUMN `arg1` VARCHAR(255) NOT NULL;");
db_install_execute("0.8.6i", "ALTER TABLE `host_snmp_cache` MODIFY COLUMN `oid` TEXT NOT NULL;");
/* let's add more graph tree items for those larger installations */
db_install_execute("0.8.6i", "ALTER TABLE `graph_tree_items` MODIFY COLUMN `id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT;");
/* let's keep track of an important statistical value */
db_install_execute("0.8.6i", "ALTER TABLE `poller_time` ADD COLUMN `pid` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `id`;");
/* add some missing information from default/system data input methods */
/* first we must see if the user was smart enough to add it themselves */
$snmp_get = db_fetch_cell("SELECT id FROM data_input_fields WHERE data_name='snmp_port' AND data_input_id='1'");
$snmp_index = db_fetch_cell("SELECT id FROM data_input_fields WHERE data_name='snmp_port' AND data_input_id='2'");
if ($snmp_index > 0) {
db_install_execute("0.8.6i", "REPLACE INTO `data_input_fields` VALUES ($snmp_index, 'c1f36ee60c3dc98945556d57f26e475b',2,'SNMP Port','snmp_port','in','',0,'snmp_port','','');");
}else{
db_install_execute("0.8.6i", "REPLACE INTO `data_input_fields` VALUES (0, 'c1f36ee60c3dc98945556d57f26e475b',2,'SNMP Port','snmp_port','in','',0,'snmp_port','','');");
}
if ($snmp_get > 0) {
db_install_execute("0.8.6i", "REPLACE INTO `data_input_fields` VALUES ($snmp_get, 'fc64b99742ec417cc424dbf8c7692d36',1,'SNMP Port','snmp_port','in','',0,'snmp_port','','');");
}else{
db_install_execute("0.8.6i", "REPLACE INTO `data_input_fields` VALUES (0, 'fc64b99742ec417cc424dbf8c7692d36',1,'SNMP Port','snmp_port','in','',0,'snmp_port','','');");
}
}
示例4: rrdclean_check_upgrade
function rrdclean_check_upgrade()
{
global $config;
$files = array('index.php', 'plugins.php', 'rrdcleaner.php');
if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
return;
}
$current = plugin_rrdclean_version();
$current = $current['version'];
$old = db_fetch_row("SELECT * FROM plugin_config WHERE directory='rrdclean'");
if (sizeof($old) && $current != $old["version"]) {
/* if the plugin is installed and/or active */
if ($old["status"] == 1 || $old["status"] == 4) {
/* re-register the hooks */
plugin_rrdclean_install();
/* perform a database upgrade */
rrdclean_database_upgrade();
}
# stub for updating tables
#$_columns = array_rekey(db_fetch_assoc("SHOW COLUMNS FROM <table>"), "Field", "Field");
#if (!in_array("<new column>", $_columns)) {
# db_execute("ALTER TABLE <table> ADD COLUMN <new column> VARCHAR(40) NOT NULL DEFAULT '' AFTER <old column>");
#}
# new hooks
#api_plugin_register_hook('rrdclean', 'config_settings', 'rrdclean_config_settings', 'setup.php');
#if (api_plugin_is_enabled('rrdclean')) {
# may sound ridiculous, but enables new hooks
# api_plugin_enable_hooks('rrdclean');
#}
# register new version
$info = plugin_rrdclean_version();
$id = db_fetch_cell("SELECT id FROM plugin_config WHERE directory='rrdclean'");
db_execute("UPDATE plugin_config\r\n\t\t\tSET name='" . $info["longname"] . "',\r\n\t\t\tauthor='" . $info["author"] . "',\r\n\t\t\twebpage='" . $info["homepage"] . "',\r\n\t\t\tversion='" . $info["version"] . "'\r\n\t\t\tWHERE id='{$id}'");
}
}
示例5: form_save
function form_save()
{
global $export_types, $export_errors;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_post('export_item_id'));
/* ==================================================== */
if (isset($_POST['save_component_export'])) {
$export_errors = 0;
$xml_data = get_item_xml($_POST['export_type'], $_POST['export_item_id'], (isset($_POST['include_deps']) ? $_POST['include_deps'] : '') == '' ? false : true);
if ($_POST['output_format'] == '1') {
top_header();
print "<table width='100%' align='center'><tr><td><pre>" . htmlspecialchars($xml_data) . '</pre></td></tr></table>';
bottom_footer();
} elseif ($_POST['output_format'] == '2') {
header('Content-type: application/xml');
if ($export_errors) {
echo "WARNING: Export Errors Encountered. Refresh Browser Window for Details!\n";
}
print $xml_data;
} elseif ($_POST['output_format'] == '3') {
if ($export_errors) {
header('Location: templates_export.php');
} else {
header('Content-type: application/xml');
header('Content-Disposition: attachment; filename=cacti_' . $_POST['export_type'] . '_' . strtolower(clean_up_file_name(db_fetch_cell(str_replace('|id|', $_POST['export_item_id'], $export_types[$_POST['export_type']]['title_sql'])))) . '.xml');
print $xml_data;
}
}
}
}
示例6: ss_mikrotik_queue_simple_getvalue
function ss_mikrotik_queue_simple_getvalue($host_id, $index, $column)
{
$return_arr = array();
switch ($column) {
case 'qsInOctets':
$column = 'curBytesIn';
break;
case 'qsOutOctets':
$column = 'curBytesOut';
break;
case 'qsInPackets':
$column = 'curPacketsIn';
break;
case 'qsOutPackets':
$column = 'curPacketsOut';
break;
case 'qsInQueues':
$column = 'curQueuesIn';
break;
case 'qsOutQueues':
$column = 'curQueuesOut';
break;
case 'qsInDropped':
$column = 'curDroppedIn';
break;
case 'qsOutDropped':
$column = 'curDroppedOut';
break;
}
$index2 = str_replace('_', ' ', $index);
$value = db_fetch_cell("SELECT\n\t\t{$column} AS value\n\t\tFROM plugin_mikrotik_queues\n\t\tWHERE name IN ('{$index}', '{$index2}')\n\t\tAND host_id='{$host_id}'");
return $value;
}
示例7: get_full_script_path
function get_full_script_path($data_source_id) {
require_once(CACTI_BASE_PATH . "/lib/sys/variable.php");
require_once(CACTI_BASE_PATH . "/include/data_source/data_source_constants.php");
$data_input_type = db_fetch_cell("select data_input_type from data_source where id = $data_source_id");
/* snmp-actions don't have paths */
if ($data_input_type != DATA_INPUT_TYPE_SCRIPT) {
return false;
}
$data_source_fields = array_rekey(db_fetch_assoc("select name,value from data_source_field where data_source_id = $data_source_id"), "name", "value");
if (isset($data_source_fields["script_id"])) {
$script_path = db_fetch_cell("select input_string from data_input where id = " . $data_source_fields["script_id"]);
/* exclude the manditory script_id field */
unset($data_source_fields["script_id"]);
/* substitute user variables */
while (list($name, $value) = each($data_source_fields)) {
$script_path = str_replace("<" . $name . ">", $value, $script_path);
}
/* substitute path variables */
$script_path = substitute_path_variables($script_path);
/* remove all remaining variables */
$script_path = preg_replace("/(<[A-Za-z0-9_]+>)+/", "", $script_path);
return $script_path;
}
}
示例8: form_save
function form_save()
{
global $export_types, $export_errors;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_post("export_item_id"));
/* ==================================================== */
if (isset($_POST["save_component_export"])) {
$export_errors = 0;
$xml_data = get_item_xml($_POST["export_type"], $_POST["export_item_id"], (isset($_POST["include_deps"]) ? $_POST["include_deps"] : "") == "" ? false : true);
if ($_POST["output_format"] == "1") {
include_once "./include/top_header.php";
print "<table width='100%' align='center'><tr><td><pre>" . htmlspecialchars($xml_data) . "</pre></td></tr></table>";
include_once "./include/bottom_footer.php";
} elseif ($_POST["output_format"] == "2") {
header("Content-type: application/xml");
if ($export_errors) {
echo "WARNING: Export Errors Encountered. Refresh Browser Window for Details!\n";
}
print $xml_data;
} elseif ($_POST["output_format"] == "3") {
if ($export_errors) {
header("Location: templates_export.php");
} else {
header("Content-type: application/xml");
header("Content-Disposition: attachment; filename=cacti_" . $_POST["export_type"] . "_" . strtolower(clean_up_file_name(db_fetch_cell(str_replace("|id|", $_POST["export_item_id"], $export_types[$_POST["export_type"]]["title_sql"])))) . ".xml");
print $xml_data;
}
}
}
}
示例9: upgrade_to_0_8_7c
function upgrade_to_0_8_7c() {
/* speed up the UI, missed in 0.8.7b upgrade, avoid failures if index already exists */
$result = db_fetch_assoc("SHOW INDEX FROM `data_local`") or die (mysql_error());
$indices = array();
foreach($result as $index => $arr) {
$indices[] = $arr["Key_name"];
}
if (!in_array('host_id', $indices)) {
db_install_execute("0.8.7c", "ALTER TABLE `data_local` ADD INDEX `host_id`(`host_id`)");
}
$result = db_fetch_assoc("SHOW INDEX FROM `host_snmp_cache`") or die (mysql_error());
$indices = array();
foreach($result as $index => $arr) {
$indices[] = $arr["Key_name"];
}
if (!in_array('field_name', $indices)) {
db_install_execute("0.8.7c", "ALTER TABLE `host_snmp_cache` ADD INDEX `field_name`(`field_name`)");
}
if (!in_array('field_value', $indices)) {
db_install_execute("0.8.7c", "ALTER TABLE `host_snmp_cache` ADD INDEX `field_value`(`field_value`)");
}
/* speed up graph automations some more */
db_install_execute("0.8.7c", "ALTER TABLE `data_input_fields` ADD INDEX `input_output`(`input_output`)");
/* increase the width of the settings field, but only if MySQL is >= 5 */
if (substr(db_fetch_cell("SELECT @@version"), 0, 1) >= 5) {
db_install_execute("0.8.7c", "ALTER TABLE `settings` MODIFY COLUMN `name` VARCHAR(512) NOT NULL DEFAULT ''");
}
/* add a default for NOT NULL columns */
db_install_execute("0.8.7c", "ALTER TABLE `data_local` MODIFY COLUMN `snmp_index` VARCHAR(255) NOT NULL DEFAULT '';");
db_install_execute("0.8.7c", "ALTER TABLE `graph_local` MODIFY COLUMN `snmp_index` VARCHAR(255) NOT NULL DEFAULT '';");
db_install_execute("0.8.7c", "ALTER TABLE `graph_templates_graph` MODIFY COLUMN `upper_limit` VARCHAR(20) NOT NULL DEFAULT '0';");
db_install_execute("0.8.7c", "ALTER TABLE `graph_templates_graph` MODIFY COLUMN `lower_limit` VARCHAR(20) NOT NULL DEFAULT '0';");
db_install_execute("0.8.7c", "ALTER TABLE `graph_templates_graph` MODIFY COLUMN `scale_log_units` CHAR(2) DEFAULT NULL;");
db_install_execute("0.8.7c", "ALTER TABLE `host` MODIFY COLUMN `availability` DECIMAL(8,5) NOT NULL DEFAULT '100.00000';");
db_install_execute("0.8.7c", "ALTER TABLE `host_snmp_cache` MODIFY COLUMN `snmp_index` VARCHAR(255) NOT NULL DEFAULT '';");
db_install_execute("0.8.7c", "ALTER TABLE `host_snmp_cache` MODIFY COLUMN `oid` TEXT NOT NULL;");
db_install_execute("0.8.7c", "ALTER TABLE `poller_item` MODIFY COLUMN `snmp_auth_protocol` VARCHAR(5) NOT NULL DEFAULT '';");
db_install_execute("0.8.7c", "ALTER TABLE `poller_item` MODIFY COLUMN `snmp_priv_passphrase` VARCHAR(200) NOT NULL DEFAULT '';");
db_install_execute("0.8.7c", "ALTER TABLE `poller_item` MODIFY COLUMN `snmp_priv_protocol` VARCHAR(6) NOT NULL DEFAULT '';");
db_install_execute("0.8.7c", "ALTER TABLE `poller_item` MODIFY COLUMN `rrd_next_step` MEDIUMINT(8) NOT NULL DEFAULT '0';");
db_install_execute("0.8.7c", "ALTER TABLE `poller_item` MODIFY COLUMN `arg1` TEXT DEFAULT NULL;");
db_install_execute("0.8.7c", "ALTER TABLE `poller_reindex` MODIFY COLUMN `arg1` VARCHAR(255) NOT NULL DEFAULT '';");
db_install_execute("0.8.7c", "ALTER TABLE `user_auth` MODIFY COLUMN `enabled` CHAR(2) NOT NULL DEFAULT 'on';");
db_install_execute("0.8.7c", "ALTER TABLE `user_log` MODIFY COLUMN `ip` VARCHAR(40) NOT NULL DEFAULT '';");
/* change size of columns to match current cacti.sql file */
db_install_execute("0.8.7c", "ALTER TABLE `poller_item` MODIFY COLUMN `rrd_step` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '300';");
db_install_execute("0.8.7c", "ALTER TABLE `poller_time` MODIFY COLUMN `pid` INT(11) UNSIGNED NOT NULL DEFAULT '0';");
/* Update deletion verification setting */
db_install_execute("0.8.7c", "UPDATE settings SET name = 'deletion_verification' WHERE name = 'remove_verification'");
/* Correct issue where rrd_next_step goes large in a positive way instead of the way it should go */
db_install_execute("0.8.7c", "ALTER TABLE `poller_item` MODIFY COLUMN `rrd_step` MEDIUMINT(8) NOT NULL DEFAULT 300");
}
示例10: ss_mikrotik_procs
function ss_mikrotik_procs($hostid = "")
{
$procs = db_fetch_cell("SELECT processes\n\t\tFROM plugin_mikrotik_system\n\t\tWHERE host_id={$hostid}");
if ($procs == '') {
$procs = 'U';
}
return $procs;
}
示例11: display_help
function display_help()
{
$version = db_fetch_cell('SELECT cacti FROM version');
echo "Empty Poller Output Table Utility, Version {$version}, " . COPYRIGHT_YEARS . "\n\n";
print "usage: poller_output_empty.php [-h] [--help] [-v] [--version]\n\n";
print "-v --version - Display this help message\n";
print "-h --help - Display this help message\n";
}
示例12: ss_mikrotik_users
function ss_mikrotik_users($hostid = "")
{
$users = db_fetch_cell("SELECT users\n\t\tFROM plugin_mikrotik_system\n\t\tWHERE host_id={$hostid}");
if ($users == '') {
$users = 'U';
}
return $users;
}
示例13: ss_mikrotik_health
function ss_mikrotik_health($hostid = "", $column = "no")
{
$value = db_fetch_cell("SELECT {$column}\n\t\tFROM plugin_mikrotik_system_health\n\t\tWHERE host_id={$hostid}");
if ($value == '') {
$value = 'U';
}
return $value;
}
示例14: ss_mikrotik_trees
function ss_mikrotik_trees($hostid = "")
{
$trees = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_mikrotik_trees\n\t\tWHERE host_id={$hostid}");
if ($trees == '') {
$trees = 'U';
}
return $trees;
}
示例15: ss_mikrotik_wapcount
function ss_mikrotik_wapcount($hostid = "")
{
$waps = db_fetch_cell("SELECT count(*)\n\t\tFROM plugin_mikrotik_wireless_aps\n\t\tWHERE host_id={$hostid} \n\t\tAND unix_timestamp(last_seen)>unix_timestamp()-1200");
if ($waps == '') {
$waps = 'U';
}
return $waps;
}