当前位置: 首页>>代码示例>>PHP>>正文


PHP delete_device函数代码示例

本文整理汇总了PHP中delete_device函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_device函数的具体用法?PHP delete_device怎么用?PHP delete_device使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了delete_device函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: del_device

function del_device()
{
    // This will add a device using the data passed encoded with json
    global $config;
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $hostname = $router['hostname'];
    // Default status to error and change it if we need to.
    $status = 'error';
    $code = 500;
    if (empty($hostname) || $config['api_demo'] == 1) {
        $message = 'No hostname has been provided to delete';
        if ($config['api_demo'] == 1) {
            $message = "This feature isn\\'t available in the demo";
        }
        $output = array('status' => $status, 'message' => $message);
    } else {
        // allow deleting by device_id or hostname
        $device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
        $device = null;
        if ($device_id) {
            // save the current details for returning to the client on successful delete
            $device = device_by_id_cache($device_id);
        }
        if ($device) {
            $response = delete_device($device_id);
            if (empty($response)) {
                // FIXME: Need to provide better diagnostics out of delete_device
                $output = array('status' => $status, 'message' => 'Device deletion failed');
            } else {
                // deletion succeeded - include old device details in response
                $code = 200;
                $status = 'ok';
                $output = array('status' => $status, 'message' => $response, 'devices' => array($device));
            }
        } else {
            // no device matching the name
            $code = 404;
            $output = array('status' => $status, 'message' => "Device {$hostname} not found");
        }
    }
    $app->response->setStatus($code);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
开发者ID:RobsanInc,项目名称:librenms,代码行数:45,代码来源:api_functions.inc.php

示例2: demo_account

if ($_SESSION['userlevel'] < 10) {
    require 'includes/error-no-perm.inc.php';
    exit;
}
$pagetitle[] = "Delete device";
if ($_SESSION['userlevel'] == 11) {
    demo_account();
} else {
    if (is_numeric($_REQUEST['id'])) {
        echo '
            <div class="row">
            <div class="col-sm-offset-2 col-sm-7">
            ';
        if ($_REQUEST['confirm']) {
            print_message(nl2br(delete_device(mres($_REQUEST['id']))) . "\n");
        } else {
            $device = device_by_id_cache($_REQUEST['id']);
            print_error("Are you sure you want to delete device " . $device['hostname'] . "?");
            ?>
<br />
<center>
  <font color="red"></font><i class="fa fa-exclamation-triangle fa-3x"></i></font>
  <br>
  <form name="form1" method="post" action="" class="form-horizontal" role="form">
    <div class="form-group">
      <input type="hidden" name="id" value="<?php 
            echo $_REQUEST['id'];
            ?>
" />
      <input type="hidden" name="confirm" value="1" />
开发者ID:samyscoub,项目名称:librenms,代码行数:30,代码来源:delhost.inc.php

示例3: device_by_id_cache

 * @package    observium
 * @subpackage webui
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
if ($_SESSION['userlevel'] < 10) {
    include "includes/error-no-perm.inc.php";
    exit;
}
$page_title[] = "删除设备";
if (is_numeric($vars['id'])) {
    $device = device_by_id_cache($vars['id']);
    if ($device && $vars['confirm']) {
        $delete_rrd = $vars['deleterrd'] == 'confirm' ? TRUE : FALSE;
        print_message(delete_device($vars['id'], $delete_rrd), 'console');
        //echo('<div class="btn-group ">
        //        <button type="button" class="btn btn-default"><a href="/"><i class="oicon-globe-model"></i> 概述</a></button>
        //        <button type="button" class="btn btn-default"><a href="/devices/"><i class="oicon-servers"></i> 设备列表</a></button>
        //      </div>');
    } else {
        print_warning("您确定需要删除该设备吗 <strong>" . $device['hostname'] . "</strong>?");
        ?>
<br />
<form name="form1" method="post" action="" class="form-horizontal" >
  <input type="hidden" name="id" value="<?php 
        echo $vars['id'];
        ?>
" />
  <input type="hidden" name="confirm" value="1" />
  <!--<input type="submit" class="submit" name="Submit" value="确认删除主机" />-->
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:delhost.inc.php

示例4: array

#!/usr/bin/env php
<?php 
/**
 * LibreNMS
 *
 *   This file is part of LibreNMS.
 *
 * @package    LibreNMS
 * @subpackage cli
 * @copyright  (C) 2006 - 2012 Adam Armstrong
 */
$init_modules = array();
require __DIR__ . '/includes/init.php';
// Remove a host and all related data from the system
if ($argv[1]) {
    $host = strtolower($argv[1]);
    $id = getidbyname($host);
    if ($id) {
        echo delete_device($id) . "\n";
    } else {
        echo "Host doesn't exist!\n";
    }
} else {
    echo "Host Removal Tool\nUsage: ./delhost.php <hostname>\n";
}
开发者ID:Rosiak,项目名称:librenms,代码行数:25,代码来源:delhost.php

示例5: chdir

 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage cli
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
chdir(dirname($argv[0]));
include "includes/defaults.inc.php";
include "config.php";
include "includes/definitions.inc.php";
include "includes/functions.inc.php";
$scriptname = basename($argv[0]);
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WRemove Device%n\n", 'color');
// Remove a host and all related data from the system
if ($argv[1]) {
    $host = strtolower($argv[1]);
    $id = getidbyname($host);
    $delete_rrd = isset($argv[2]) && strtolower($argv[2]) == 'rrd' ? TRUE : FALSE;
    // Test if a valid id was fetched from getidbyname.
    if (isset($id) && is_numeric($id)) {
        print_warning(delete_device($id, $delete_rrd));
        print_success("Device {$host} removed.");
    } else {
        print_error("Device {$host} doesn't exist!");
    }
} else {
    print_message("%n\nUSAGE:\n{$scriptname} <hostname> [rrd]\n\nEXAMPLE:\n%WKeep RRDs%n:   {$scriptname} <hostname>\n%WRemove RRDs%n: {$scriptname} <hostname> rrd\n\n%rInvalid arguments!%n", 'color', FALSE);
}
// EOF
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:delete_device.php

示例6: print_message

<h2>Delete Device</h2>

<?php 
if ($_SESSION['userlevel'] < 10) {
    include "includes/error-no-perm.inc.php";
    exit;
}
$pagetitle[] = "Delete device";
if (is_numeric($_REQUEST['id'])) {
    if ($_REQUEST['confirm']) {
        print_message(delete_device(mres($_REQUEST['id'])));
    } else {
        $device = device_by_id_cache($_REQUEST['id']);
        print_message("Are you sure you want to delete device " . $device['hostname'] . "?");
        ?>
<br />
<form name="form1" method="post" action="" class="form-horizontal" >
    <input type="hidden" name="id" value="<?php 
        echo $_REQUEST['id'];
        ?>
" />
    <input type="hidden" name="confirm" value="1" />
    <input type="submit" class="submit" name="Submit" value="Confirm host deletion" />

<?php 
    }
} else {
    ?>

<form name="form1" method="post" action="" class="form-horizontal" >
开发者ID:RomanBogachev,项目名称:observium,代码行数:30,代码来源:delhost.inc.php

示例7: chdir

#!/usr/bin/env php
<?php 
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage cli
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006 - 2012 Adam Armstrong
 *
 */
chdir(dirname($argv[0]));
include "includes/defaults.inc.php";
include "config.php";
include "includes/definitions.inc.php";
include "includes/functions.php";
# Remove a host and all related data from the system
if ($argv[1]) {
    $host = strtolower($argv[1]);
    $id = getidbyname($host);
    if ($id) {
        echo delete_device($id);
        echo "Removed {$host}\n";
    } else {
        echo "Host doesn't exist!\n";
    }
} else {
    echo "Host Removal Tool\nUsage: ./delhost.php <hostname>\n";
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:31,代码来源:delhost.php

示例8: print_success

 *
 * @package    observium
 * @subpackage webui
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
if ($_SESSION['userlevel'] < 10) {
    include "includes/error-no-perm.inc.php";
    exit;
}
$pagetitle[] = "删除设备";
if (is_numeric($_REQUEST['id'])) {
    if ($_REQUEST['confirm']) {
        $delete_rrd = $_REQUEST['deleterrd'] == 'confirm' ? TRUE : FALSE;
        print_success(delete_device(mres($_REQUEST['id']), $delete_rrd));
        echo '<div class="btn-group ">
            <button type="button" class="btn btn-default"><a href="/"><i class="oicon-globe-model"></i> 概述</a></button>
            <button type="button" class="btn btn-default"><a href="/devices/"><i class="oicon-servers"></i> 设备列表</a></button>
          </div>';
    } else {
        $device = device_by_id_cache($_REQUEST['id']);
        print_warning("您确定需要删除该设备吗 <strong>" . $device['hostname'] . "</strong>?");
        ?>
<br />
<form name="form1" method="post" action="" class="form-horizontal" >
  <input type="hidden" name="id" value="<?php 
        echo $_REQUEST['id'];
        ?>
" />
  <input type="hidden" name="confirm" value="1" />
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:delhost.inc.php

示例9: device_by_id_cache

 * @package    observium
 * @subpackage webui
 * @author     Adam Armstrong <adama@memetic.org>
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
if ($_SESSION['userlevel'] < 10) {
    include "includes/error-no-perm.inc.php";
    exit;
}
$pagetitle[] = "Delete devices";
if (is_numeric($vars['id'])) {
    $device = device_by_id_cache($vars['id']);
    if ($device && $vars['confirm']) {
        $delete_rrd = $vars['deleterrd'] == 'confirm' ? TRUE : FALSE;
        print_warning(delete_device($vars['id'], $delete_rrd));
        //echo('<div class="btn-group ">
        //        <button type="button" class="btn btn-default"><a href="/"><i class="oicon-globe-model"></i> Overview</a></button>
        //        <button type="button" class="btn btn-default"><a href="/devices/"><i class="oicon-servers"></i> Devices List</a></button>
        //      </div>');
    } else {
        print_warning("Are you sure you want to delete device <strong>" . $device['hostname'] . "</strong>?");
        ?>
<br />
<form name="form1" method="post" action="" class="form-horizontal" >
  <input type="hidden" name="id" value="<?php 
        echo $vars['id'];
        ?>
" />
  <input type="hidden" name="confirm" value="1" />
  <!--<input type="submit" class="submit" name="Submit" value="Confirm host deletion" />-->
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:delhost.inc.php

示例10: dbase_parse

function dbase_parse($cmd, $message)
{
    global $pisql, $dbhost, $dbuser, $dbpass, $dbname;
    global $log;
    // Used by daemon
    global $apperr, $appmsg;
    // For ajax usage
    if (!$pisql || !$pisql->ping()) {
        $log->lwrite("dbase_parse:: Ping failed, making new pisql connection to server", 1);
        $pisql = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
    }
    // If there is an error
    if ($pisql->connect_errno) {
        $log->lwrite("dbase_parse:: Failed to connect to MySQL: (" . $pisql->connect_errno . ") " . $pisql->connect_error, 1);
        return -1;
    }
    // For logging only
    if (is_array($message)) {
        $str = "";
        foreach ($message as $key => $val) {
            $str .= " {" . $key . ":" . $val . "},";
        }
        $log->lwrite("dbase_parse:: " . $cmd . ": " . $str, 1);
    } else {
        $log->lwrite("dbase_parse:: message: " . $cmd . ": " . $message, 1);
    }
    //
    // Depending on $cmd execute database function
    switch ($cmd) {
        // Database
        case "load_database":
            $ret = load_database();
            break;
            // Device
        // Device
        case "load_devices":
            $ret = load_devices();
            break;
        case "add_device":
            $ret = add_device($message);
            break;
        case "delete_device":
            $ret = delete_device($message);
            break;
        case "store_device":
            $ret = store_device($message);
            break;
            // Room
        // Room
        case "add_room":
            $ret = add_room($message);
            break;
        case "delete_room":
            $ret = delete_room($message);
            break;
            // Scene
        // Scene
        case "read_scene":
            $ret = load_scene($message);
            break;
        case "load_scenes":
            $ret = load_scenes();
            break;
        case "add_scene":
            $ret = add_scene($message);
            break;
        case "delete_scene":
            $ret = delete_scene($message);
            break;
        case "upd_scene":
            $ret = upd_scene($message);
            break;
        case "store_scene":
            $ret = store_scene($message);
            break;
            // Timer
        // Timer
        case "add_timer":
            $ret = add_timer($message);
            break;
        case "delete_timer":
            $ret = delete_timer($message);
            break;
        case "store_timer":
            $ret = store_timer($message);
            break;
            // Handset
        // Handset
        case "add_handset":
            $ret = add_handset($message);
            break;
        case "delete_handset":
            $ret = delete_handset($message);
            break;
        case "store_handset":
            $ret = store_handset($message);
            break;
            // Weather
        // Weather
        case "add_weather":
//.........这里部分代码省略.........
开发者ID:RobQuistNL,项目名称:LamPI-2.0,代码行数:101,代码来源:backend_sql.php

示例11: demo_account

if ($_SESSION['userlevel'] < 10) {
    require 'includes/error-no-perm.inc.php';
    exit;
}
$pagetitle[] = "Delete device";
if ($_SESSION['userlevel'] == 11) {
    demo_account();
} else {
    if (is_numeric($vars['id'])) {
        echo '
            <div class="row">
            <div class="col-sm-offset-2 col-sm-7">
            ';
        if ($vars['confirm']) {
            print_message(nl2br(delete_device(mres($vars['id']))) . "\n");
        } else {
            $device = device_by_id_cache($vars['id']);
            print_error("Are you sure you want to delete device " . $device['hostname'] . "?");
            ?>
<br />
<center>
  <font color="red"></font><i class="fa fa-exclamation-triangle fa-3x"></i></font>
  <br>
  <form name="form1" method="post" action="" class="form-horizontal" role="form">
    <div class="form-group">
      <input type="hidden" name="id" value="<?php 
            echo $vars['id'];
            ?>
" />
      <input type="hidden" name="confirm" value="1" />
开发者ID:jmacul2,项目名称:librenms,代码行数:30,代码来源:delhost.inc.php

示例12: dbase_parse

function dbase_parse($cmd, $message)
{
    //
    switch ($cmd) {
        case "add_device":
            $ret = add_device($message);
            break;
        case "delete_device":
            $ret = delete_device($message);
            break;
        case "add_room":
            $ret = add_room($message);
            break;
        case "delete_room":
            $ret = delete_room($message);
            break;
        case "add_scene":
            break;
        case "delete_scene":
            break;
        case "upd_scene":
            break;
        case "add_timer":
            break;
        case "delete_timer":
            break;
        case "store_timer":
            break;
        case "add_handset":
            break;
        case "delete_handset":
            break;
        case "store_handset":
            break;
        case "add_weather":
            break;
        case "delete_weather":
            break;
        case "store_setting":
            break;
        default:
    }
    if ($ret >= 0) {
        // Prepare structure to send back to the calling ajax client (in stdout)
        $send = array('tcnt' => $ret, 'appmsg' => $appmsg, 'status' => 'OK', 'apperr' => $apperr);
        $output = json_encode($send);
    } else {
        //	Functions need to fill apperr themselves!
        $send = array('tcnt' => $ret, 'appmsg' => $appmsg, 'status' => 'ERR', 'apperr' => $apperr);
        $output = json_encode($send);
    }
    return $output;
}
开发者ID:RobQuistNL,项目名称:LamPI-2.0,代码行数:53,代码来源:frontend_sql.php


注:本文中的delete_device函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。