public function checkQuotaStatus() { if ($this->user->isLimited() && $this->user->limitExpired() && !$this->user->aq_access) { reject("Time/Data Limit Exceeded."); } return $this; }
/** @test */ public function shouldRejectARejectedPromise() { $expected = 123; $resolved = new RejectedPromise($expected); $mock = $this->createCallableMock(); $mock->expects($this->once())->method('__invoke')->with($this->identicalTo($expected)); reject($resolved)->then($this->expectCallableNever(), $mock); }
/** * @return \Icicle\Awaitable\Awaitable */ protected function getAwaitable() { if (null === $this->promise) { $promisor = $this->promisor; $this->promisor = null; try { $this->promise = resolve($promisor()); } catch (\Throwable $exception) { $this->promise = reject($exception); } } return $this->promise; }
public function fetchAccount($acctsessionid = NULL, $acctuniqueid = NULL) { $q = Capsule::table('user_accounts as u')->select('u.uname', 'u.status', 'u.clear_pword', 'u.id', 'r.time_limit', 'r.data_limit', 'r.expiration', 'r.aq_invocked', 'v.plan_type', 'v.policy_type', 'v.policy_id', 'v.sim_sessions', 'v.interim_updates', 'l.limit_type', 'l.aq_access', 'l.aq_policy')->leftJoin('user_recharges as r', 'r.user_id', '=', 'u.id')->leftJoin('prepaid_vouchers as v', 'v.id', '=', 'r.voucher_id')->leftJoin('voucher_limits as l', 'l.id', '=', 'v.limit_id')->where('u.uname', $this->uname); if ($acctsessionid == NULL && $acctuniqueid == NULL) { $settings = Capsule::table('general_settings as s')->select('s.idle_timeout')->first(); if ($settings->idle_timeout != 0) { $this->user->idleTimeout = $settings->idle_timeout; } } if ($acctsessionid != NULL and $acctuniqueid != NULL) { $q->join('radacct as a', 'u.uname', '=', 'a.username')->where('a.')->addSelect('a.acctinputoctets', 'a.acctoutputoctets', 'a.acctsessiontime', 'r.active_tpl'); } $this->user = $q->first(); if ($this->user == NULL) { reject("No such user: {$this->uname}"); } $this->status['isActive'] = $this->user->status; $this->status['isLimited'] = $this->user->plan_type; $this->status['isUnlimited'] = !$this->user->plan_type; $this->status['haveAQAccess'] = $this->user->aq_access ? TRUE : FALSE; return $this; }
function some(array $promisesOrValues, $howMany) { if ($howMany < 1) { return resolve([]); } $len = count($promisesOrValues); if ($len < $howMany) { return reject(new Exception\LengthException(sprintf('Input array must contain at least %d item%s but contains only %s item%s.', $howMany, 1 === $howMany ? '' : 's', $len, 1 === $len ? '' : 's'))); } $cancellationQueue = new CancellationQueue(); return new Promise(function ($resolve, $reject) use($len, $promisesOrValues, $howMany, $cancellationQueue) { $toResolve = $howMany; $toReject = $len - $toResolve + 1; $values = []; $reasons = []; foreach ($promisesOrValues as $i => $promiseOrValue) { $fulfiller = function ($val) use($i, &$values, &$toResolve, $toReject, $resolve) { if ($toResolve < 1 || $toReject < 1) { return; } $values[$i] = $val; if (0 === --$toResolve) { $resolve($values); } }; $rejecter = function ($reason) use($i, &$reasons, &$toReject, $toResolve, $reject) { if ($toResolve < 1 || $toReject < 1) { return; } $reasons[$i] = $reason; if (0 === --$toReject) { $reject($reasons); } }; $cancellationQueue->enqueue($promiseOrValue); resolve($promiseOrValue)->done($fulfiller, $rejecter); } }, $cancellationQueue); }
/** @test */ public function shouldRejectIfAnyInputPromiseRejects() { $mock = $this->createCallableMock(); $mock->expects($this->once())->method('__invoke')->with($this->identicalTo(2)); all([resolve(1), reject(2), resolve(3)])->then($this->expectCallableNever(), $mock); }
public function test_reject() { assert_equal(array(1, 3), reject(array(1, 2, 3, 4), function ($v) { return $v % 2 == 0; })); }
/** @test */ public function shouldResolveWhenFirstInputPromiseResolves() { $mock = $this->createCallableMock(); $mock->expects($this->once())->method('__invoke')->with($this->identicalTo(1)); any([resolve(1), reject(2), reject(3)])->then($mock); }
/** * Perform a GET request against the link's "last" relation * * @return ExtendedPromiseInterface */ function last() : ExtendedPromiseInterface { if ($this->links() && ($last = $this->links()->getLast())) { return $this->withUrl($last)->get(); } return reject($this->links()); }
// array('confirm' => 'Are you sure you want to delete this conference?', "visible" => $ismoderator, 'role' => "button", "class" => "btn btn-danger") // ); if ($model->status != "cancelled") { $html .= CHtml::ajaxLink('Cancel', Yii::app()->createAbsoluteUrl('videoConference/cancel/' . $model->id), array('type' => 'post', 'data' => array('id' => $model->id, 'type' => 'post'), 'update' => 'message', 'success' => 'function(response) { $(".message").html(response); location.reload(); }'), array('confirm' => 'Are you sure you want to cancel this conference?', "visible" => $ismoderator, 'role' => "button", "class" => "btn btn-warning")); } } else { $invitation = VCInvitation::model()->findByAttributes(array('videoconference_id' => $model->id, 'invitee_id' => $user->id)); if ($invitation->status == "Unknown") { $html .= accept($model->id); $html .= reject($model->id); } else { if ($invitation->status == "Accepted") { $html .= reject($model->id); } else { $html .= accept($model->id); } } } $html .= "</div>"; $html = str_replace("%SUBJECT%", $model->subject, $html); $html = str_replace("%MSTATUS%", $model->status, $html); if ($model->status == "cancelled") { $html = str_replace("%STATUS%", "<p style='font-weight: bold'>Status: Cancelled</p>", $html); } else { $html = str_replace("%STATUS%", "", $html); } $html = str_replace("%SUBJECT%", $model->subject, $html); $html = str_replace("%DATE%", $user_friendly_date, $html);
/** * Get the message content as a stream. * * @see IncomingMessage::content() to get the content as a string. * * @see IncomingMessage::contentUnbuffered() to get the message content as * it becomes available. * * Closing the stream discards any remaining content. * * If the message does not contain any content, the stream will be closed * before it is returned, and no stream events will be emitted. * * @see ReadableStreamInterface::isReadable() to check if a stream can be read from. * * @return ReadableStreamInterface A stream containing the message content. * @throws LogicException The message content has already been consumed or discarded. */ public function contentStream() { if ($this->contentHandled) { return reject(new LogicException('The message content has already been consumed or discarded.')); } $this->contentHandled = true; $stream = new MemoryStream(); $stream->on('close', $this->cancelContentListener); if (0 === $this->headerFrame->contentLength) { $stream->close(); } else { $this->onBodyFrame = function ($exception, $frame, $final) use($stream) { if ($exception) { $stream->close($exception); } elseif ($final) { $stream->end($frame->content); } else { $stream->write($frame->content); } }; } return $stream; }
} // Header is most likely already: 200 Ok //error_log("Send length: $xmitbytes == ".strlen($xmit)); if (isset($_GET["ranges"])) { $myxmit = ""; $ranges = explode(",", $_GET["ranges"]); foreach ($ranges as $blocks) { $startstop = explode("-", $blocks); if (!is_numeric($startstop[0]) || !is_numeric($startstop[1])) { reject("400 Bad Request"); } if (isset($startstop[2])) { reject("400 Bad Request"); } $start = $startstop[0]; $stop = $startstop[1]; if ($start > $stop) { reject("400 Bad Request"); } $myxmit .= substr($xmit, $start, $stop - $start + 1); } header("Content-Length: " . strlen($myxmit)); mysql_query("UPDATE " . $prefix . "speedlimit SET uploaded=uploaded+" . strlen($myxmit)); echo $myxmit; } else { mysql_query("UPDATE " . $prefix . "speedlimit SET uploaded=uploaded+{$xmitbytes}"); header("Content-Length: {$xmitbytes}"); echo $xmit; } Unlock("WebSeed--{$lockno}"); exit;
<?php ## Извлекаем только четные элементы. function reject($arr, $callback) { foreach ($arr as $value) { if (!$callback($value)) { (yield $value); } } } $arr = [1, 2, 3, 4, 5, 6]; $reject = reject($arr, function ($e) { return $e % 2 == 0 ? true : false; }); foreach ($reject as $val) { echo "{$val} "; }
reject('ltrim', TRUE)->equals(''); reject('Dotink\\Lab\\Calculator::$seed', TRUE)->measures(23); }, 'Contains Rejections' => function ($data) { reject('This is a test string')->contains('foo'); reject('This is a test string')->contains('FOO', FALSE); assert(function () { reject('This is a test string')->contains('test'); })->throws('Dotink\\Lab\\FailedTestException'); assert(function () { reject('This is a test string')->contains('TEST', FALSE); })->throws('Dotink\\Lab\\FailedTestException'); assert(function () { reject('This is a test string')->contains('test', TRUE); })->throws('Dotink\\Lab\\FailedTestException'); reject(['a' => 'foo', 'b' => 'bar'])->contains('hello'); reject(function () { reject(['a' => 'foo', 'b' => 'bar'])->contains('foobar'); })->throws('Dotink\\Lab\\FailedTestException'); reject(['a' => 'foo', 'b' => 'bar'])->has('b', 'c'); assert(function () { reject(['a' => 'foo', 'b' => 'bar'])->has('b'); })->throws('Dotink\\Lab\\FailedTestException'); }, 'Ends and Begins Rejections' => function ($data) { reject('I have a merry band of brothers')->begins('I have the')->ends('group of brothers'); assert(function () { reject('I have a merry band of brothers')->begins('I have'); })->throws('Dotink\\Lab\\FailedTestException'); assert(function () { reject('I have a merry band of brothers')->ends('band of brothers'); })->throws('Dotink\\Lab\\FailedTestException'); }]];
/** * {@inheritdoc} */ public function dispose(Throwable $exception = null) { if (null === $exception) { $exception = new DisposedException(); } $this->emitter = null; if (null === $this->coroutine) { $this->queue->fail($exception); return; } if (null !== $this->onDisposed) { try { $result = ($this->onDisposed)($exception); if ($result instanceof Generator) { $awaitable = new Coroutine($result); } else { $awaitable = resolve($result); } $awaitable = $awaitable->then(function () use($exception) { throw $exception; }); } catch (Throwable $exception) { $awaitable = reject($exception); } } else { $awaitable = reject($exception); } $awaitable->done(null, [$this->coroutine, 'cancel']); }
/** * Declare this exchange. * * @recoil-coroutine * * @param boolean $passive True to use a "passive" declare mode. * @param Channel|null $channel The application-managed channel to use (null = auto-managed). * * @throws ResourceNotFoundException The exchange does not exist. * @throws DeclareException The exchange already exists with different a type or options. * @throws DeclareException A reserved exchange name was used. * @throws ConnectionException The connection is closed. * @throws ChannelException The channel is closed. */ private function declareExchange($passive, Channel $channel = null) : Generator { if ('amq.' === substr($this->name, 0, 4)) { return reject(DeclareException::exchangeNameIsReserved($this->name)); } $deferred = new Deferred(); $this->broker->acquireChannel(function ($exception, $brokerChannel) use($channel, $passive, $deferred) { if ($exception) { $deferred->reject($exception); } else { $brokerChannel->call(ExchangeDeclareFrame::create($this->name, $this->type->value(), $passive, $this->options->durable, $this->options->autoDelete, $this->options->internal, false, $this->arguments), ExchangeDeclareOkFrame::METHOD_ID, function ($exception, $frame) use($brokerChannel, $channel, $deferred) { if (!$channel) { $this->broker->releaseChannel($brokerChannel); } if ($exception) { if ($exception instanceof AmqpException) { if ($exception->getCode() === Constants::PRECONDITION_FAILED) { $exception = DeclareException::exchangeTypeOrOptionMismatch($this->name, $this->type, $this->options, $exception); } elseif ($exception->getCode() === Constants::NOT_FOUND) { $exception = ResourceNotFoundException::exchangeNotFound($this->name, $exception); } } $deferred->reject($exception); } else { $deferred->resolve($this); } }); } }, $channel); return $deferred->promise(); }
foreach ($instances as $instance) { $query = "INSERT INTO Instances(reqNo,hash,creator,creatorEmail,creatorPhone,concernedPName,concernedPEmail,concernedPPhone,appStatus,reqGId,reqDate,eventStartDate,eventEndDate,eventStartTime,eventEndTime,eventTitle,eventDesc,eventDays,concernedAdmin,room,reqType) VALUES(\n\t\t\t'" . $roomRecords['reqNo'] . "',\n\t\t\t'" . $roomRecords['hash'] . "',\n\t\t\t'" . $roomRecords['creator'] . "',\n\t\t\t'" . $roomRecords['creatorEmail'] . "',\n\t\t\t'" . $roomRecords['creatorPhone'] . "',\n\t\t\t'" . $roomRecords['concernedPName'] . "',\n\t\t\t'" . $roomRecords['concernedPEmail'] . "',\n\t\t\t'" . $roomRecords['concernedPPhone'] . "',\n\t\t\t'Accepted', \n\t\t\t'" . $roomRecords['reqGId'] . "',\n\t\t\t'" . $roomRecords['reqDate'] . "',\n\t\t\t'" . $instance . "',\n\t\t\t'" . $instance . "',\n\t\t\t'" . $roomRecords['eventStartTime'] . "',\n\t\t\t'" . $roomRecords['eventEndTime'] . "',\n\t\t\t'" . $roomRecords['eventTitle'] . "',\n\t\t\t'" . $roomRecords['eventDesc'] . "',\n\t\t\t'" . $roomRecords['eventDays'] . "',\n\t\t\t'" . $roomRecords['concernedAdmin'] . "',\n\t\t\t'" . $roomRecords['room'] . "',\n\t\t\t'" . $roomRecords['reqType'] . "'\n\t\t);"; execute($query); } $sq = "update Requests set appStatus='Accepted' where reqNo=" . $_POST['reqID'] . ";"; $clash = requestClash($roomRecords['eventStartDate'], $roomRecords['eventEndDate'], $roomRecords['eventStartTime'], $roomRecords['eventEndTime'], $roomRecords['room']); while ($req = mysql_fetch_assoc($clash)) { //print_r($req); if ($req['reqNo'] != $rID) { //echo $req['reqNo']; //echo "<HI><br><br><br><br>\n"; $otherQuery = "update Requests set appStatus = 'Rejected', reqRejectReason = 'A request conflicting with your request was accepted.' where reqNo = {$req['reqNo']}"; //echo $otherQuery."\n"; execute($otherQuery); reject($req['creator'], $req['creatorEmail'], $req['room'], $req['reqNo'], getCC($rID)); reject($req['concernedPName'], $req['concernedPEmail'], $req['room'], $req['reqNo'], getCC($rID)); } } $req = getRequestByID($rID); accept($req['creator'], $req['creatorEmail'], $req['room'], $req['reqNo'], getCC($rID)); accept($req['concernedPName'], $req['concernedPEmail'], $req['room'], $req['reqNo'], getCC($rID)); } else { if ($_POST['reqAction'] == $c) { $sq = "update Requests set concernedAdmin = {$_POST['forwardID']} where reqNo = {$_POST['reqID']}"; $req = getRequestByID($rID); $emails = getEmails($_POST['forwardID']); //print_r($emails); foreach ($emails as $email) { forward($req['concernedPName'], $email, $req['room'], $req['reqNo'], $req['concernedPEmail'], getCC($rID)); } }
// array( 'confirm'=>'Are you sure you want to delete this conference?', "visible" => $ismoderator, 'role' => "button", "class" => "btn btn-danger") // ); if ($vc->status != "cancelled") { $html .= CHtml::ajaxLink('Cancel', Yii::app()->createAbsoluteUrl('videoConference/cancel/' . $vc->id), array('type' => 'post', 'data' => array('id' => $vc->id, 'type' => 'post'), 'update' => 'message', 'success' => 'function(response) { $(".message").html(response); location.reload(); }'), array('confirm' => 'Are you sure you want to cancel this conference?', "visible" => $ismoderator, 'role' => "button", "class" => "btn btn-warning")); } } else { $invitation = VCInvitation::model()->findByAttributes(array('videoconference_id' => $vc->id, 'invitee_id' => $user->id)); if ($invitation->status == "Unknown") { $html .= accept($vc->id); $html .= reject($vc->id); } else { if ($invitation->status == "Accepted") { $html .= reject($vc->id); } else { $html .= accept($vc->id); } } } $html .= "</div>"; $html = str_replace("%SUBJECT%", $vc->subject, $html); $html = str_replace("%MSTATUS%", $vc->status, $html); $html = str_replace("%MSTATUS%", $vc->status, $html); if ($vc->status == "cancelled") { $html = str_replace("%STATUS%", "<p style='font-weight: bold'>Status: Cancelled</p>", $html); } else { $html = str_replace("%STATUS%", "", $html); } $html = str_replace("%DATE%", $user_friendly_date, $html);
function Process($db, $min, $max) { /* echo '<br><strong style="color:red">Accept/Reject these papers NOT YET IMPLEMENTED</strong><br>'; return;*/ $papersSQL = "SELECT * FROM " . $GLOBALS["DB_PREFIX"] . "Paper"; $papersSQL .= " WHERE Withdraw = 'false'"; $papers = $db->Execute($papersSQL); while ($papers && ($paperInfo = $papers->FetchNextObj())) { if ($paperInfo->OverallRating <= $max) { reject($paperInfo->PaperID); } if ($paperInfo->OverallRating >= $min) { accept($paperInfo->PaperID); } } }
/** @test */ public function shouldRejectWhenInputPromiseRejects() { $mock = $this->createCallableMock(); $mock->expects($this->once())->method('__invoke')->with($this->identicalTo(null)); reduce(reject(), $this->plus(), 1)->then($this->expectCallableNever(), $mock); }
<?php // ----------- // reject based on callerid // ----------- if ($currentCall->callerID == "4075551111") { answer(); say("Hello world!"); hangup(); } else { reject(); }
/** @test */ public function shouldRejectWhenInputContainsRejection() { $mock = $this->createCallableMock(); $mock->expects($this->once())->method('__invoke')->with($this->identicalTo(2)); map([resolve(1), reject(2), resolve(3)], $this->mapper())->then($this->expectCallableNever(), $mock); }
/** @test */ public function shouldRejectIfAnyInputPromiseRejectsBeforeDesiredNumberOfInputsAreResolved() { $mock = $this->createCallableMock(); $mock->expects($this->once())->method('__invoke')->with($this->identicalTo([1 => 2, 2 => 3])); some([resolve(1), reject(2), reject(3)], 2)->then($this->expectCallableNever(), $mock); }
private function reject($reason = null) { if (null !== $this->result) { return; } $this->settle(reject($reason)); }