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


PHP Connection::HttpError方法代码示例

本文整理汇总了PHP中Connection::HttpError方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::HttpError方法的具体用法?PHP Connection::HttpError怎么用?PHP Connection::HttpError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


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

示例1: header

<?php

require_once 'Connection.class.php';
if (isset($_GET['id'])) {
    // Retrieves an image by ID from Zabbix database.
    $dbh = Connection::GetDatabase();
    $stmt = $dbh->prepare('
		SELECT image
		FROM images
		WHERE imageid = :imageId
	');
    $stmt->bindParam(':imageId', $_GET['id']);
    if (!$stmt->execute()) {
        $err = $stmt->errorInfo();
        Connection::HttpError(500, "Failed to query image for '{$_GET['id']}'.<br/>{$err['0']} {$err['2']}");
    }
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    header('Content-Type: image/png');
    echo $row['image'];
}
开发者ID:pida42,项目名称:Zabbix-Addons,代码行数:20,代码来源:image.php

示例2: CreateThresholdWeightIfNotExist

 /**
  * Creates entries on the tables service_weight and service_threshold if they don't exist.
  * @param PDO   $dbh       Database connection handle.
  * @param sring $serviceId ID of service to be checked.
  */
 public static function CreateThresholdWeightIfNotExist(PDO $dbh, $serviceId)
 {
     try {
         $stmt_w = Connection::QueryDatabase($dbh, 'SELECT idservice FROM service_weight WHERE idservice = ?', $serviceId);
         if (!$stmt_w->fetch(PDO::FETCH_NUM)) {
             Connection::QueryDatabase($dbh, 'INSERT INTO service_weight (idservice) VALUES (?)', $serviceId);
         }
         $stmt_t = Connection::QueryDatabase($dbh, 'SELECT idservice FROM service_threshold WHERE idservice = ?', $serviceId);
         if (!$stmt_t->fetch(PDO::FETCH_NUM)) {
             Connection::QueryDatabase($dbh, 'INSERT INTO service_threshold (idservice) VALUES (?)', $serviceId);
         }
     } catch (Exception $e) {
         Connection::HttpError(500, sprintf(I('Failed to verify weight/threshold for service "%s".'), $serviceId) . '<br/>' . $e->getMessage());
     }
 }
开发者ID:pida42,项目名称:Zabbix-Addons,代码行数:20,代码来源:ServiceTree.class.php

示例3: header

        }
        $out = $stmt->fetchAll(PDO::FETCH_ASSOC);
        header('Content-Type: application/json');
        echo json_encode($out);
        // list of host groups
    } else {
        if ($_POST['r'] == 'hosts') {
            try {
                $stmt = Connection::QueryDatabase(Connection::GetDatabase(), "\n\t\t\tSELECT h.hostid, h.name\n\t\t\tFROM hosts h\n\t\t\tINNER JOIN hosts_groups hg ON hg.hostid = h.hostid\n\t\t\tWHERE hg.groupid = {$_POST['group']}\n\t\t\tORDER BY h.name\n\t\t");
            } catch (Exception $e) {
                Connection::HttpError(500, sprintf(I('Failed to query hosts for group %s.'), $_POST['group']) . '<br/>' . $e->getMessage());
            }
            $out = $stmt->fetchAll(PDO::FETCH_ASSOC);
            header('Content-Type: application/json');
            echo json_encode($out);
            // list of hosts
        } else {
            if ($_POST['r'] == 'triggers') {
                try {
                    $stmt = Connection::QueryDatabase(Connection::GetDatabase(), "\n\t\t\tSELECT t.triggerid, REPLACE(t.description, '{HOSTNAME}', h.host) AS description\n\t\t\tFROM triggers t\n\t\t\tINNER JOIN functions f ON f.triggerid = t.triggerid\n\t\t\tINNER JOIN items i ON i.itemid = f.itemid AND i.hostid = {$_POST['host']}\n\t\t\tINNER JOIN hosts h ON h.hostid = i.hostid\n\t\t\tORDER BY description\n\t\t");
                } catch (Exception $e) {
                    Connection::HttpError(500, sprintf(I('Failed to query triggers host %s.'), $_POST['host']) . '<br/>' . $e->getMessage());
                }
                $out = $stmt->fetchAll(PDO::FETCH_ASSOC);
                header('Content-Type: application/json');
                echo json_encode($out);
                // list of triggers
            }
        }
    }
}
开发者ID:pida42,项目名称:Zabbix-Addons,代码行数:31,代码来源:ajaxTriggers.php

示例4: service_icon

			goodsla = ?
			WHERE serviceid = ?
		', $data->name, $data->algorithm, $data->triggerid, $data->showsla, $data->goodsla, $data->id);
        Connection::QueryDatabase($dbh, 'DELETE FROM service_icon WHERE idservice = ?', $data->id);
        if ($data->imageid !== null) {
            Connection::QueryDatabase($dbh, 'INSERT INTO service_icon (idservice,idicon) VALUES (?,?)', $data->id, $data->imageid);
        }
        $dbh->commit();
    } catch (Exception $e) {
        $dbh->rollback();
        Connection::HttpError(500, sprintf(I('Failed to update service with id=%s.<br/>%s'), $data->id, $e->getMessage()));
    }
    header('Content-Type: application/json');
    echo json_encode(array('status' => 'ok'));
    // output status
} else {
    if (isset($_REQUEST['serviceId'])) {
        // --- Query service information. ------------------------------------------
        header('Content-Type: application/json');
        echo json_encode(ServiceTree::GetInfo($dbh, $_REQUEST['serviceId']));
    } else {
        if (isset($_POST['images'])) {
            // --- Query all available images from Zabbix. -----------------------------
            header('Content-Type: application/json');
            echo json_encode(ServiceTree::GetAllImages($dbh));
        } else {
            // --- No request? ---------------------------------------------------------
            Connection::HttpError(400, I('No retrieve/save service request... what are you trying to do?'));
        }
    }
}
开发者ID:pida42,项目名称:Zabbix-Addons,代码行数:31,代码来源:ajaxService.php

示例5: _TellDbError

 /**
  * Outputs latest database error.
  * @param PDO    $dbh Database connection handle.
  * @param string $msg Additional text to be outputted.
  */
 private static function _TellDbError(PDO $dbh, $msg)
 {
     $err = $dbh->errorInfo();
     Connection::HttpError(500, "{$msg}<br/>{$err['0']} {$err['2']}");
 }
开发者ID:pida42,项目名称:Zabbix-Addons,代码行数:10,代码来源:Install.class.php

示例6: session_start

<?php

session_start();
require 'inc/Connection.class.php';
require 'inc/ServiceTree.class.php';
require_once '__conf.php';
require_once 'i18n/i18n.php';
i18n_set_map('en', $LANG, false);
if (isset($_REQUEST['root'])) {
    // List of root service names.
    $dbh = Connection::GetDatabase();
    header('Content-Type: application/json');
    echo json_encode(ServiceTree::GetRootList($dbh));
} else {
    if (isset($_REQUEST['serviceId']) && $_REQUEST['serviceId'] != '' || isset($_REQUEST['serviceName']) && $_REQUEST['serviceName'] != '') {
        // Build and return the service tree.
        // Service may be queried by its ID or name.
        $dbh = Connection::GetDatabase();
        $serviceId = isset($_REQUEST['serviceId']) && $_REQUEST['serviceId'] != '' ? $_REQUEST['serviceId'] : ServiceTree::GetIdByName($dbh, $_REQUEST['serviceName']);
        // Output JSON data.
        $statusCount = array(0, 0, 0, 0, 0, 0);
        $root = ServiceTree::GetAllToHtml5($dbh, $serviceId, $statusCount);
        header('Content-Type: application/json');
        echo json_encode(array('tree' => $root, 'statusCount' => $statusCount));
    } else {
        Connection::HttpError(400, I('Service tree: no parameters, nothing to query.'));
    }
}
开发者ID:pida42,项目名称:Zabbix-Addons,代码行数:28,代码来源:ajaxServiceTree.php

示例7: unset

// Requests processing.
if (isset($_POST['logoff'])) {
    // --- Logoff process. -----------------------------------------------------
    if (isset($_SESSION['user'])) {
        unset($_SESSION['user']);
        // remove session data
        unset($_SESSION['hash']);
    }
    header('Content-Type: application/json');
    echo json_encode(array('status' => 'ok'));
    // output status
} else {
    if (isset($_POST['user']) && isset($_POST['pass'])) {
        // --- Login process. ------------------------------------------------------
        $zabbix = Connection::GetZabbixApi(null);
        // no hash
        try {
            $hash = $zabbix->autenticar($_POST['user'], $_POST['pass']);
        } catch (Exception $e) {
            Connection::HttpError(401, sprintf(I('Zabbix login failed for user %s.'), $_POST['user']));
        }
        $_SESSION['user'] = $_POST['user'];
        // save session data
        $_SESSION['hash'] = $hash;
        header('Content-Type: application/json');
        echo json_encode(array('status' => 'ok', 'user' => $_POST['user'], 'hash' => $hash));
    } else {
        // --- No request? ---------------------------------------------------------
        Connection::HttpError(400, I('No parameters... what do you want to do?'));
    }
}
开发者ID:pida42,项目名称:Zabbix-Addons,代码行数:31,代码来源:ajaxLogin.php


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