本文整理汇总了PHP中Error::http方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::http方法的具体用法?PHP Error::http怎么用?PHP Error::http使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::http方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
function get()
{
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] and $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
Error::http(403, "Requests for the sim/records resource must originate from the server environment.");
}
$sql = "SELECT brand_id FROM brands WHERE type_system='sim'";
$rows = DBquery::get($sql);
$this->numBrands = count($rows);
shuffle($rows);
$brands = array();
foreach ($rows as $b) {
$brands[] = DBquery::get("CALL budgetRevExp(" . $b['brand_id'] . ")")[0];
if (!$this->rating[$b['brand_id']]) {
$this->setRatings($b['brand_id']);
}
}
foreach ($brands as &$b) {
$b['revBal'] = 1 * $b['revBal'];
$b['expBal'] = 1 * $b['expBal'];
$b['inflow'] = 1 * $b['inflow'];
$b['lastWeekAdded'] = 1 * $b['lastWeekAdded'];
if (!$b['revBal'] and !$b['expBal']) {
$this->addBudget($b);
} else {
if ($b['lastWeekAdded'] < $this->weekNum and $b['revBal'] > $b['inflow']) {
$this->addBudget($b);
} else {
$this->transact($b, $brands[mt_rand(0, $this->numBrands - 1)]);
}
}
}
return $brands;
}
示例2: asApplied
function asApplied($filters)
{
if (!is_array($filters['brand_id'])) {
$filters['brand_id'] = explode(",", $filters['brand_id']);
}
if (!$filters['brand_id']) {
Error::http(400, "An array of brand_id values are required when testing the applicability of throttle #{$this->throttle_id}.");
}
$currtime = time();
$throttle_id = $filters['throttle_id'] ? $filters['throttle_id'] : $this->throttle_id;
$sql = "SELECT a.brand_id, from_user, amount, r.created\n\t\t\tFROM records r\n\t\t\tJOIN accounts a ON a.account_id=from_acct\n\t\t\tWHERE r.throttle_id=? AND r.status>-1 AND r.txntype='pn' AND {$currtime} - UNIX_TIMESTAMP(r.created) < {$this->period};";
$rows = DBquery::get($sql, array($throttle_id));
$used = array('by_all' => 0, 'by_brand' => array("0" => 0), 'by_user' => 0);
foreach ($rows as $r) {
$used['by_all'] += $r['amount'];
if (in_array($r['brand_id'], $filters['brand_id'])) {
$used['by_brand'][$r['brand_id']] += $r['amount'];
}
if (Requester::$user_id == $r['from_user']) {
$used['by_user'] += $r['amount'];
}
}
$this->unusedAmt = min(max($this->by_all - $used['by_all'], 0), max($this->by_brand - min($used['by_brand']), 0), max($this->by_user - $used['by_user'], 0));
unset($used['by_brand']["0"]);
$this->used = $used;
return array($this);
}
示例3: prepOther
function prepOther($data)
{
if (is_numeric($data->brand_id)) {
return;
}
if (substr($data->brand_id, 0, 1) != "~") {
$data->brand_id = "~" . $data->brand_id;
}
$data->brand_id = substr($data->brand_id, 0, 200);
$sql = "SELECT brand_id FROM brands WHERE name LIKE ? LIMIT 1";
$rows = DBquery::get($sql, array($data->brand_id));
if ($rows) {
$data->brand_id = $rows[0]['brand_id'];
} else {
require_once "models/BrandCollection.php";
$Brand = (new BrandCollection(json_decode('{
"name": "' . $data->brand_id . '",
"mission": "simulate a well-known brand for whitelisting or blacklisting",
"description": "This is a simulated brand to be used for testing the tatag system.",
"type_system": "sim"
}')))->add()[0];
$data->brand_id = $Brand->brand_id;
if (!$data->brand_id) {
Error::http(500, "Failed to create or use a new brand_id for what you are rating.");
}
}
}
示例4: get
function get()
{
if (!$this->txntype) {
$this->issued = $this->{'@id'} . "?txntype=np";
$this->revTransfer = $this->{'@id'} . "?txntype=nn";
$this->expTransfer = $this->{'@id'} . "?txntype=pp";
$this->intrause = $this->{'@id'} . "?txntype=pn&subtype=intrause";
$this->inflow = $this->{'@id'} . "?txntype=pn&subtype=inflow";
$this->outflow = $this->{'@id'} . "?txntype=pn&subtype=outflow";
return array_merge(array($this), $this->getByTxnType('np'), $this->getByTxnType('nn'), $this->getByTxnType('pp'), $this->getIntrause(), $this->getInflow(), $this->getOutflow());
} else {
if ($this->txntype != 'pn') {
return $this->getByTxnType();
} else {
if ($this->subtype == 'intrause') {
return $this->getIntrause();
} else {
if ($this->subtype == 'inflow') {
return $this->getInflow();
} else {
if ($this->subtype == 'outflow') {
return $this->getOutflow();
} else {
Error::http(403, "When requesting records with txntype='pn', a URL query parameter value must be provided for 'subtype' and the value must equal 'intrause', 'inflow', OR 'outflow'. Actual value='{$this->subtype}'.");
}
}
}
}
}
}
示例5: __construct
function __construct()
{
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] and $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
Error::http(403, "Requests for cron resources must originate from the server environment.");
}
$this->{"@id"} = "/cron/budgetAdd";
$this->{"@type"} = "CronAdd";
}
示例6: add
function add()
{
include_once "models/BrandMembers.php";
include_once "models/Accounts.php";
include_once "models/Holders.php";
$this->okToAdd = array('name', 'mission', 'description', 'type_system', 'type_id', 'country_code', 'area_code', 'url', 'advisor', 'logo');
$this->addKeyVal("type_system", "nonprofit", "ifMissing");
$this->addKeyVal("type_id", 10, "ifMissing");
$this->addKeyVal("country_code", "USA", "ifMissing");
$this->addKeyVal("area_code", 206, "ifMissing");
$this->addKeyVal("logo", 'NULL', "ifMissing");
//$this->addKeyVal("mission", 'NULL', "ifMissing");
$this->addKeyVal("url", 'NULL', "ifMissing");
$this->addKeyVal("advisor", 'NULL', "ifMissing");
$Brand = $this->obj;
$Brand->brand_id = $this->insert();
//print_r($Brand); print_r(Requester);
if (!$Brand->brand_id) {
Error::http(500, "Failed to fully create a new brand.");
}
$Members = new BrandMembers(json_decode('{
"brand_id":' . $Brand->brand_id . ',
"user_id":' . Requester::$user_id . ',
"role":"admin",
"hours":0
}'));
$Brand->members = $Members->add();
$MainRev = (new Accounts(json_decode('{
"brand_id": ' . $Brand->brand_id . ',
"name": "Main Revenue",
"authcode": "cftix",
"unit": "hour",
"sign": -1
}')))->add();
$MainExp = (new Accounts(json_decode('{
"brand_id": ' . $Brand->brand_id . ',
"name": "Main Expense",
"authcode": "cftix",
"unit": "hour",
"sign": 1
}')))->add();
$Brand->accounts = array($MainRev, $MainExp);
if ($Brand->type_system == 'sim') {
$Members->resetSimMember();
} else {
$Brand->holders[] = (new Holders(json_decode('{
"account_id": ' . $MainRev->account_id . ',
"user_id":' . Requester::$user_id . ',
"authcode": "cftix"
}')))->add();
$Brand->holders[] = (new Holders(json_decode('{
"account_id": ' . $MainExp->account_id . ',
"user_id":' . Requester::$user_id . ',
"authcode": "cftix"
}')))->add();
}
return array($Brand);
}
示例7: get
function get()
{
if (isset($_GET['save'])) {
$this->set();
}
$f = "ref/forms/" . Router::$subresource . ".json";
if (!file_exists($f)) {
Error::http(404, "The form='" . Router::$subresource . "' was not found.");
}
return array(json_decode(file_get_contents($f)));
}
示例8: setDetails
function setDetails($throttle_id = 0)
{
$sql = "SELECT * FROM {$this->table} WHERE throttle_id=?";
$row = DBquery::get($sql, array($throttle_id ? $throttle_id : $this->throttle_id));
if (!$row) {
Error::http(404, "No details were found for throttle #'{$this->throttle_id}'.");
}
foreach ($row[0] as $k => $v) {
$this->{$k} = $v;
}
}
示例9: __construct
function __construct($data = '')
{
//move to advisor
$this->from_brand = ($data and isset($data->from_brand)) ? $data->from_brand : $_GET['from_brand'];
$this->to_brand = ($data and isset($data->to_brand)) ? $data->to_brand : $_GET['to_brand'];
if (!$this->from_brand or !$this->to_brand) {
Error::http(400, "A non-zero integer value must be specified for from_brand (specified '{$this->from_brand}') and to_brand ('{$this->to_brand}') as GET query parameters.");
}
$this->consumer_id = ($data and isset($data->from_brand)) ? 0 : $this->getID();
$this->{"@id"} = $this->consumer_id ? "{$this->root}/app/{$this->consumer_id}/advise" : "{$this->root}/app/advise";
$this->{"@type"} = "appAdvise";
}
示例10: __construct
function __construct($data = '')
{
$this->{"@type"} = "teamOrders";
$this->brand_id = $this->getID();
if (!Requester::isMember($this->brand_id)) {
Error::http(403, "Only members or admins of brand #{$this->brand_id} can view its orders.");
}
$this->{'@id'} = "{$this->root}/team/{$this->brand_id}/orders";
$this->table = "records";
$this->collectionOf = "order";
$this->init($data);
$this->okToFilterBy = array("record_id");
}
示例11: __construct
function __construct($data = '')
{
$this->brand_id = $this->getID();
if (!Requester::isMember($this->brand_id)) {
Error::http(403, "The '/team/{$this->brand_id}' resource is only viewable by members of brand #{$this->brand_id}.");
}
$this->{"@type"} = 'brandTally';
$this->{"@id"} = "{$this->root}/team/{$this->brand_id}/tally";
$this->table = "members";
$this->init($data);
$this->okToFilterBy = array("brand_id", "member_id");
$this->okToSet = array("joined", "revoked");
}
示例12: __construct
function __construct($data = '')
{
$this->user_id = $this->getID();
if (!Requester::isUser($this->user_id)) {
Error::http(401, "The requester must be logged in as the requested user.");
}
$this->{"@id"} = "/user/{$this->user_id}/apps";
$this->{'@type'} = "userApps";
$this->collectionOf = "app";
$this->table = "consumers";
$this->init($data);
$this->okToAdd = array("name", "secret", "type", "redirect_url");
}
示例13: set
function set()
{
$this->setFilters($_GET);
$sql = "SELECT user_id, member_id FROM members WHERE {$this->filterCond}";
$rows = DBquery::get($sql, $this->filterValArr);
foreach ($rows as $r) {
if ($r['user_id'] != Requester::$user_id) {
Error::http(403, "The requester cannot set another member's information. \n\t\t\t\tPlease check that requester (#{$this->user_id}) is filtering by his or her own member_id (#" . $r['member_id'] . ").");
}
}
$this->update();
return array($this->obj);
}
示例14: set
function set()
{
if (!$_GET['record_id']) {
Error::http(403, 'Missing record_id GET query parameter value, which is required for updating the record status.');
}
if ($this->status == 7) {
$row = DBquery::get("CALL approveRecord(" . $_GET['record_id'] . ")");
} else {
$this->setFilters($_GET);
$row = $this->update();
}
return array($this->obj);
}
示例15: __construct
function __construct($data = '')
{
$this->brand_id = $this->getID();
if (!Requester::isBrandAdmin($this->brand_id)) {
Error::http(403, "The requester is not an admin for brand #{$this->brand_id}.");
}
$this->{"@type"} = 'brand';
$this->{"@id"} = "{$this->root}/brand/{$this->brand_id}";
$this->role = "admin";
$this->table = "brands";
$this->init($data);
$this->okToSet = array("name", "ended", "mission", "description", "url", "advisor", "type_system", "type_id", "country_code", "area_code", "logo");
$this->okToFilterBy = array("brand_id");
}